diff --git a/published/20180116 Command Line Heroes- Season 1- OS Wars_2.md b/published/20180116 Command Line Heroes- Season 1- OS Wars_2.md new file mode 100644 index 0000000000..68f6f81913 --- /dev/null +++ b/published/20180116 Command Line Heroes- Season 1- OS Wars_2.md @@ -0,0 +1,171 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11296-1.html) +[#]: subject: (Command Line Heroes: Season 1: OS Wars) +[#]: via: (https://www.redhat.com/en/command-line-heroes/season-1/os-wars-part-2-rise-of-linux) +[#]: author: (redhat https://www.redhat.com) + +《代码英雄》第一季(2):操作系统战争(下)Linux 崛起 +====== + +> 代码英雄讲述了开发人员、程序员、黑客、极客和开源反叛者如何彻底改变技术前景的真实史诗故事。 + +![](https://www.redhat.com/files/webux/img/bandbg/bkgd-clh-ep2-2000x950.png) + +本文是《[代码英雄](https://www.redhat.com/en/command-line-heroes)》系列播客[第一季(2):操作系统战争(下)](https://www.redhat.com/en/command-line-heroes/season-1/os-wars-part-2-rise-of-linux) 的[音频](https://dts.podtrac.com/redirect.mp3/audio.simplecast.com/2199861a.mp3)脚本。 + +> 微软帝国控制着 90% 的用户。操作系统的完全标准化似乎是板上钉钉的事了。但是一个不太可能的英雄出现在开源反叛组织中。戴着眼镜,温文尔雅的林纳斯·托瓦兹Linus Torvalds免费发布了他的 Linux® 程序。微软打了个趔趄,并且开始重整旗鼓而来,战场从个人电脑转向互联网。 + +**Saron Yitbarek:** 这玩意开着的吗?让我们进一段史诗般的星球大战的开幕吧,开始了。 + +配音:第二集:Linux® 的崛起。微软帝国控制着 90% 的桌面用户。操作系统的全面标准化似乎是板上钉钉的事了。然而,互联网的出现将战争的焦点从桌面转向了企业,在该领域,所有商业组织都争相构建自己的服务器。*[00:00:30]*与此同时,一个不太可能的英雄出现在开源反叛组织中。固执、戴着眼镜的 林纳斯·托瓦兹Linus Torvalds免费发布了他的 Linux 系统。微软打了个趔趄,并且开始重整旗鼓而来。 + +**Saron Yitbarek:** 哦,我们书呆子就是喜欢那样。上一次我们讲到哪了?苹果和微软互相攻伐,试图在一场争夺桌面用户的战争中占据主导地位。*[00:01:00]* 在第一集的结尾,我们看到微软获得了大部分的市场份额。很快,由于互联网的兴起以及随之而来的开发者大军,整个市场都经历了一场地震。互联网将战场从在家庭和办公室中的个人电脑用户转移到拥有数百台服务器的大型商业客户中。 + +这意味着巨量资源的迁移。突然间,所有相关企业不仅被迫为服务器空间和网站建设付费,而且还必须集成软件来进行资源跟踪和数据库监控等工作。*[00:01:30]* 你需要很多开发人员来帮助你。至少那时候大家都是这么做的。 + +在操作系统之战的第二部分,我们将看到优先级的巨大转变,以及像林纳斯·托瓦兹和理查德·斯托尔曼Richard Stallman这样的开源反逆者是如何成功地在微软和整个软件行业的核心地带引发恐惧的。 + +我是 Saron Yitbarek,你现在收听的是代码英雄,一款红帽公司原创的播客节目。*[00:02:00]* 每一集,我们都会给你带来“从码开始”改变技术的人的故事。 + +好。想象一下你是 1991 年时的微软。你自我感觉良好,对吧?满怀信心。确立了全球主导的地位感觉不错。你已经掌握了与其他企业合作的艺术,但是仍然将大部分开发人员、程序员和系统管理员排除在联盟之外,而他们才是真正的步兵。*[00:02:30]* 这时出现了个叫林纳斯·托瓦兹的芬兰极客。他和他的开源程序员团队正在开始发布 Linux,这个操作系统内核是由他们一起编写出来的。 + +坦白地说,如果你是微软公司,你并不会太在意 Linux,甚至不太关心开源运动,但是最终,Linux 的规模变得如此之大,以至于微软不可能不注意到。*[00:03:00]* Linux 第一个版本出现在 1991 年,当时大概有 1 万行代码。十年后,变成了 300 万行代码。如果你想知道,今天则是 2000 万行代码。 + +*[00:03:30]* 让我们停留在 90 年代初一会儿。那时 Linux 还没有成为我们现在所知道的庞然大物。这个奇怪的病毒式的操作系统只是正在这个星球上蔓延,全世界的极客和黑客都爱上了它。那时候我还太年轻,但有点希望我曾经经历过那个时候。在那个时候,发现 Linux 就如同进入了一个秘密社团一样。就像其他人分享地下音乐混音带一样,程序员与朋友们分享 Linux CD 集。 + +开发者 Tristram Oaten *[00:03:40]* 讲讲你 16 岁时第一次接触 Linux 的故事吧。 + +**Tristram Oaten:** 我和我的家人去了红海的 Hurghada 潜水度假。那是一个美丽的地方,强烈推荐。第一天,我喝了自来水。也许,我妈妈跟我说过不要这么做。我整个星期都病得很厉害,没有离开旅馆房间。*[00:04:00]* 当时我只带了一台新安装了 Slackware Linux 的笔记本电脑,我听说过这玩意并且正在尝试使用它。所有的东西都在 8 张 cd 里面。这种情况下,我只能整个星期都去了解这个外星一般的系统。我阅读手册,摆弄着终端。我记得当时我甚至不知道一个点(表示当前目录)和两个点(表示前一个目录)之间的区别。 + +*[00:04:30]* 我一点头绪都没有。犯过很多错误,但慢慢地,在这种强迫的孤独中,我突破了障碍,开始理解并明白命令行到底是怎么回事。假期结束时,我没有看过金字塔、尼罗河等任何埃及遗址,但我解锁了现代世界的一个奇迹。我解锁了 Linux,接下来的事大家都知道了。 + +**Saron Yitbarek:** 你会从很多人那里听到关于这个故事的不同说法。访问 Linux 命令行是一种革命性的体验。 + +**David Cantrell:** *[00:05:00]* 它给了我源代码。我当时的感觉是,“太神奇了。” + +**Saron Yitbarek:** 我们正在参加一个名为 Flock to Fedora 的 2017 年 Linux 开发者大会。 + +**David Cantrell:** ……非常有吸引力。我觉得我对这个系统有了更多的控制力,它越来越吸引我。我想,从 1995 年我第一次编译 Linux 内核那时起,我就迷上了它。 + +**Saron Yitbarek:** 开发者 David Cantrell 与 Joe Brockmire。 + +**Joe Brockmeier:** *[00:05:30]* 我在 Cheap Software 转的时候发现了一套四张 CD 的 Slackware Linux。它看起来来非常令人兴奋而且很有趣,所以我把它带回家,安装在第二台电脑上,开始摆弄它,有两件事情让我感到很兴奋:一个是,我运行的不是 Windows,另一个是 Linux 的开源特性。 + +**Saron Yitbarek:** *[00:06:00]* 某种程度上来说,对命令行的使用总是存在的。在开源真正开始流行还要早的几十年前,人们(至少在开发人员中是这样)总是希望能够做到完全控制。让我们回到操作系统大战之前的那个时代,在苹果和微软为他们的 GUI 而战之前。那时也有代码英雄。保罗·琼斯Paul Jones教授(在线图书馆 ibiblio.org 的负责人)在那个古老的时代,就是一名开发人员。 + +**Paul Jones:** *[00:06:30]* 从本质上讲,互联网在那个时候客户端-服务器架构还是比较少的,而更多的是点对点架构的。确实,我们会说,某种 VAX 到 VAX 的连接(LCTT 译注:DEC 的一种操作系统),某种科学工作站到科学工作站的连接。这并不意味着没有客户端-服务端的架构及应用程序,但这的确意味着,最初的设计是思考如何实现点对点,*[00:07:00]* 它与 IBM 一直在做的东西相对立。IBM 给你的只有哑终端,这种终端只能让你管理用户界面,却无法让你像真正的终端一样为所欲为。 + +**Saron Yitbarek:** 图形用户界面在普通用户中普及的同时,在工程师和开发人员中总是存在着一股相反的力量。早在 Linux 出现之前的二十世纪七八十年代,这股力量就存在于 Emacs 和 GNU 中。有了斯托尔曼的自由软件基金会后,总有某些人想要使用命令行,但上世纪 90 年代的 Linux 提供了前所未有的东西。 + +*[00:07:30]* Linux 和其他开源软件的早期爱好者是都是先驱。我正站在他们的肩膀上。我们都是。 + +你现在收听的是代码英雄,一款由红帽公司原创的播客。这是操作系统大战的第二部分:Linux 崛起。 + +**Steven Vaughan-Nichols:** 1998 年的时候,情况发生了变化。 + +**Saron Yitbarek:** *[00:08:00]* Steven Vaughan-Nichols 是 zdnet.com 的特约编辑,他已经写了几十年关于技术商业方面的文章了。他将向我们讲述 Linux 是如何慢慢变得越来越流行,直到自愿贡献者的数量远远超过了在 Windows 上工作的微软开发人员的数量的。不过,Linux 从未真正追上微软桌面客户的数量,这也许就是微软最开始时忽略了 Linux 及其开发者的原因。Linux 真正大放光彩的地方是在服务器机房。当企业开始线上业务时,每个企业都需要一个满足其需求的独特编程解决方案。 + +*[00:08:30]* WindowsNT 于 1993 年问世,当时它已经在与其他的服务器操作系统展开竞争了,但是许多开发人员都在想,“既然我可以通过 Apache 构建出基于 Linux 的廉价系统,那我为什么要购买 AIX 设备或大型 Windows 设备呢?”关键点在于,Linux 代码已经开始渗透到几乎所有网上的东西中。 + +**Steven Vaughan-Nichols:** *[00:09:00]* 令微软感到惊讶的是,它开始意识到,Linux 实际上已经开始有一些商业应用,不是在桌面环境,而是在商业服务器上。因此,他们发起了一场运动,我们称之为 FUD - 恐惧、不确定和怀疑fear, uncertainty and double。他们说,“哦,Linux 这玩意,真的没有那么好。它不太可靠。你一点都不能相信它”。 + +**Saron Yitbarek:** 这种软宣传式的攻击持续了一段时间。微软也不是唯一一个对 Linux 感到紧张的公司。这其实是整个行业在对抗这个奇怪新人的挑战。*[00:09:30]* 例如,任何与 UNIX 有利害关系的人都可能将 Linux 视为篡夺者。有一个案例很著名,那就是 SCO 组织(它发行过一种 UNIX 版本)在过去 10 多年里发起一系列的诉讼,试图阻止 Linux 的传播。SCO 最终失败而且破产了。与此同时,微软一直在寻找机会,他们必须要采取动作,只是不清楚具体该怎么做。 + +**Steven Vaughan-Nichols:** *[00:10:00]* 让微软真正担心的是,第二年,在 2000 年的时候,IBM 宣布,他们将于 2001 年投资 10 亿美元在 Linux 上。现在,IBM 已经不再涉足个人电脑业务。(那时)他们还没有走出去,但他们正朝着这个方向前进,他们将 Linux 视为服务器和大型计算机的未来,在这一点上,剧透警告,IBM 是正确的。*[00:10:30]* Linux 将主宰服务器世界。 + +**Saron Yitbarek:** 这已经不再仅仅是一群黑客喜欢他们对命令行的绝地武士式的控制了。金钱的投入对 Linux 助力极大。Linux 国际Linux International的执行董事 John “Mad Dog” Hall 有一个故事可以解释为什么会这样。我们通过电话与他取得了联系。 + +**John Hall:** *[00:11:00]* 我有一个名叫 Dirk Holden 的朋友,他是德国德意志银行的系统管理员,他也参与了个人电脑上早期 X Windows 系统图形项目的工作。有一天我去银行拜访他,我说:“Dirk,你银行里有 3000 台服务器,用的都是 Linux。为什么不用 Microsoft NT 呢?”*[00:11:30]* 他看着我说:“是的,我有 3000 台服务器,如果使用微软的 Windows NT 系统,我需要 2999 名系统管理员。”他继续说道:“而使用 Linux,我只需要四个。”这真是完美的答案。 + +**Saron Yitbarek:** 程序员们着迷的这些东西恰好对大公司也极具吸引力。但由于 FUD 的作用,一些企业对此持谨慎态度。*[00:12:00]* 他们听到开源,就想:“开源。这看起来不太可靠,很混乱,充满了 BUG”。但正如那位银行经理所指出的,金钱有一种有趣的方式,可以说服人们克服困境。甚至那些只需要网站的小公司也加入了 Linux 阵营。与一些昂贵的专有选择相比,使用一个廉价的 Linux 系统在成本上是无法比拟的。如果你是一家雇佣专业人员来构建网站的商店,那么你肯定想让他们使用 Linux。 + +让我们快进几年。Linux 运行每个人的网站上。Linux 已经征服了服务器世界,然后智能手机也随之诞生。*[00:12:30]* 当然,苹果和他们的 iPhone 占据了相当大的市场份额,而且微软也希望能进入这个市场,但令人惊讶的是,Linux 也在那,已经做好准备了,迫不及待要大展拳脚。 + +作家兼记者 James Allworth。 + +**James Allworth:** 肯定还有容纳第二个竞争者的空间,那本可以是微软,但是实际上却是 Android,而 Andrid 基本上是基于 Linux 的。众所周知,Android 被谷歌所收购,现在运行在世界上大部分的智能手机上,谷歌在 Linux 的基础上创建了 Android。*[00:13:00]* Linux 使他们能够以零成本从一个非常复杂的操作系统开始。他们成功地实现了这一目标,最终将微软挡在了下一代设备之外,至少从操作系统的角度来看是这样。 + +**Saron Yitbarek:** *[00:13:30]* 这可是个大地震,很大程度上,微软有被埋没的风险。John Gossman 是微软 Azure 团队的首席架构师。他还记得当时困扰公司的困惑。 + +**John Gossman:** 像许多公司一样,微软也非常担心知识产权污染。他们认为,如果允许开发人员使用开源代码,那么他们可能只是将一些代码复制并粘贴到某些产品中,就会让某种病毒式的许可证生效从而引发未知的风险……他们也很困惑,*[00:14:00]* 我认为,这跟公司文化有关,很多公司,包括微软,都对开源开发的意义和商业模式之间的分歧感到困惑。有一种观点认为,开源意味着你所有的软件都是免费的,人们永远不会付钱。 + +**Saron Yitbarek:** 任何投资于旧的、专有软件模型的人都会觉得这里发生的一切对他们构成了威胁。当你威胁到像微软这样的大公司时,是的,他们一定会做出反应。*[00:14:30]* 他们推动所有这些 FUD —— 恐惧、不确定性和怀疑是有道理的。当时,商业运作的方式基本上就是相互竞争。不过,如果是其他公司的话,他们可能还会一直怀恨在心,抱残守缺,但到了 2013 年的微软,一切都变了。 + +微软的云计算服务 Azure 上线了,令人震惊的是,它从第一天开始就提供了 Linux 虚拟机。*[00:15:00]* 史蒂夫·鲍尔默Steve Ballmer,这位把 Linux 称为癌症的首席执行官,已经离开了,代替他的是一位新的有远见的首席执行官萨提亚·纳德拉Satya Nadella。 + +**John Gossman:** 萨提亚有不同的看法。他属于另一个世代。比保罗、比尔和史蒂夫更年轻的世代,他对开源有不同的看法。 + +**Saron Yitbarek:** 还是来自微软 Azure 团队的 John Gossman。 + +**John Gossman:** *[00:15:30]* 大约四年前,处于实际需要,我们在 Azure 中添加了 Linux 支持。如果访问任何一家企业客户,你都会发现他们并不会才试着决定是使用 Windows 还是使用 Linux、 使用 .net 还是使用 Java ^TM 。他们在很久以前就做出了决定 —— 大约 15 年前才有这样的一些争论。*[00:16:00]* 现在,我见过的每一家公司都混合了 Linux 和 Java、Windows 和 .net、SQL Server、Oracle 和 MySQL —— 基于专有源代码的产品和开放源代码的产品。 + +如果你打算运维一个云服务,允许这些公司在云上运行他们的业务,那么你根本不能告诉他们,“你可以使用这个软件,但你不能使用那个软件。” + +**Saron Yitbarek:** *[00:16:30]* 这正是萨提亚·纳德拉采纳的哲学思想。2014 年秋季,他站在舞台上,希望传递一个重要信息。“微软爱 Linux”。他接着说,“20% 的 Azure 业务量已经是 Linux 了,微软将始终对 Linux 发行版提供一流的支持。”没有哪怕一丝对开源的宿怨。 + +为了说明这一点,在他们的背后有一个巨大的标志,上面写着:“Microsoft ❤️ Linux”。哇噢。对我们中的一些人来说,这种转变有点令人震惊,但实际上,无需如此震惊。下面是 Steven Levy,一名科技记者兼作家。 + +**Steven Levy:** *[00:17:00]* 当你在踢足球的时候,如果草坪变滑了,那么你也许会换一种不同的鞋子。他们当初就是这么做的。*[00:17:30]* 他们不能否认现实,而且他们里面也有聪明人,所以他们必须意识到,这就是这个世界的运行方式,不管他们早些时候说了什么,即使他们对之前的言论感到尴尬,但是让他们之前关于开源多么可怕的言论影响到现在明智的决策那才真的是疯了。 + +**Saron Yitbarek:** 微软低下了它高傲的头。你可能还记得苹果公司,经过多年的孤立无援,最终转向与微软构建合作伙伴关系。现在轮到微软进行 180 度转变了。*[00:18:00]* 经过多年的与开源方式的战斗后,他们正在重塑自己。要么改变,要么死亡。Steven Vaughan-Nichols。 + +**Steven Vaughan-Nichols:** 即使是像微软这样规模的公司也无法与数千个开发着包括 Linux 在内的其它大项目的开源开发者竞争。很长时间以来他们都不愿意这么做。前微软首席执行官史蒂夫·鲍尔默对 Linux 深恶痛绝。*[00:18:30]* 由于它的 GPL 许可证,他视 Linux 为一种癌症,但一旦鲍尔默被扫地出门,新的微软领导层说,“这就好像试图命令潮流不要过来,但潮水依然会不断涌进来。我们应该与 Linux 合作,而不是与之对抗。” + +**Saron Tiebreak:** 事实上,互联网技术史上最大的胜利之一就是微软最终决定做出这样的转变。*[00:19:00]* 当然,当微软出现在开源圈子时,老一代的铁杆 Linux 支持者是相当怀疑的。他们不确定自己是否能接受这些家伙,但正如 Vaughan-Nichols 所指出的,今天的微软已经不是以前的微软了。 + +**Steven Vaughan-Nichols:** 2017 年的微软既不是史蒂夫·鲍尔默的微软,也不是比尔·盖茨的微软。这是一家完全不同的公司,有着完全不同的方法,而且,一旦使用了开源,你就无法退回到之前。*[00:19:30]* 开源已经吞噬了整个技术世界。从未听说过 Linux 的人可能对它并不了解,但是每次他们访问 Facebook,他们都在运行 Linux。每次执行谷歌搜索时,你都在运行 Linux。 + +*[00:20:00]* 每次你用 Android 手机,你都在运行 Linux。它确实无处不在,微软无法阻止它,而且我认为以为微软能以某种方式接管它的想法,太天真了。 + +**Saron Yitbarek:** 开源支持者可能一直担心微软会像混入羊群中的狼一样,但事实是,开源软件的本质保护了它无法被完全控制。*[00:20:30]* 没有一家公司能够拥有 Linux 并以某种特定的方式控制它。Greg Kroah-Hartman 是 Linux 基金会的一名成员。 + +**Greg Kroah-Hartman:** 每个公司和个人都以自私的方式为 Linux 做出贡献。他们之所以这样做是因为他们想要解决他们所面临的问题,可能是硬件无法工作,或者是他们想要添加一个新功能来做其他事情,又或者想在他们的产品中使用它。这很棒,因为他们会把代码贡献回去,此后每个人都会从中受益,这样每个人都可以用到这份代码。正是因为这种自私,所有的公司,所有的人都能从中受益。 + +**Saron Yitbarek:** *[00:21:00]* 微软已经意识到,在即将到来的云战争中,与 Linux 作战就像与空气作战一样。Linux 和开源不是敌人,它们是空气。如今,微软以白金会员的身份加入了 Linux 基金会。他们成为 GitHub 开源项目的头号贡献者。*[00:21:30]* 2017 年 9 月,他们甚至加入了开源促进联盟Open Source Initiative。现在,微软在开源许可证下发布了很多代码。微软的 John Gossman 描述了他们开源 .net 时所发生的事情。起初,他们并不认为自己能得到什么回报。 + +**John Gossman:** 我们本没有指望来自社区的贡献,然而,三年后,超过 50% 的对 .net 框架库的贡献来自于微软之外。这包括大量的代码。*[00:22:00]* 三星为 .net 提供了 ARM 支持。Intel 和 ARM 以及其他一些芯片厂商已经为 .net 框架贡献了特定于他们处理器的代码生成,以及数量惊人的修复、性能改进等等 —— 既有单个贡献者也有社区。 + +**Saron Yitbarek:** 直到几年前,今天的这个微软,这个开放的微软,还是不可想象的。 + +*[00:22:30]* 我是 Saron Yitbarek,这里是代码英雄。好吧,我们已经看到了为了赢得数百万桌面用户的爱而战的激烈场面。我们已经看到开源软件在专有软件巨头的背后悄然崛起,并攫取了巨大的市场份额。*[00:23:00]* 我们已经看到了一批批的代码英雄将编程领域变成了我你今天看到的这个样子。如今,大企业正在吸收开源软件,通过这一切,每个人都从他人那里受益。 + +在技术的西部荒野,一贯如此。苹果受到施乐的启发,微软受到苹果的启发,Linux 受到 UNIX 的启发。进化、借鉴、不断成长。如果比喻成大卫和歌利亚(LCTT 译注:西方经典的以弱胜强战争中的两个主角)的话,开源软件不再是大卫,但是,你知道吗?它也不是歌利亚。*[00:23:30]* 开源已经超越了传统。它已经成为其他人战斗的战场。随着开源道路变得不可避免,新的战争,那些在云计算中进行的战争,那些在开源战场上进行的战争正在加剧。 + +这是 Steven Levy,他是一名作者。 + +**Steven Levy:** 基本上,到目前为止,包括微软在内,有四到五家公司,正以各种方式努力把自己打造成为全方位的平台,比如人工智能领域。你能看到智能助手之间的战争,你猜怎么着?*[00:24:00]* 苹果有一个智能助手,叫 Siri。微软有一个,叫 Cortana。谷歌有谷歌助手。三星也有一个智能助手。亚马逊也有一个,叫 Alexa。我们看到这些战斗遍布各地。也许,你可以说,最热门的人工智能平台将控制我们生活中所有的东西,而这五家公司就是在为此而争斗。 + +**Saron Yitbarek:** *[00:24:30]* 如果你正在寻找另一个反叛者,它们就像 Linux 奇袭微软那样,偷偷躲在 Facebook、谷歌或亚马逊身后,你也许要等很久,因为正如作家 James Allworth 所指出的,成为一个真正的反叛者只会变得越来越难。 + +**James Allworth:** 规模一直以来都是一种优势,但规模优势本质上……怎么说呢,我认为以前它们在本质上是线性的,现在它们在本质上是指数型的了,所以,一旦你开始以某种方法走在前面,另一个新玩家要想赶上来就变得越来越难了。*[00:25:00]* 我认为在互联网时代这大体来说来说是正确的,无论是因为规模,还是数据赋予组织的竞争力的重要性和优势。一旦你走在前面,你就会吸引更多的客户,这就给了你更多的数据,让你能做得更好,这之后,客户还有什么理由选择排名第二的公司呢,难道是因为因为他们落后了这么远么?*[00:25:30]* 我认为在云的时代这个逻辑也不会有什么不同。 + +**Saron Yitbarek:** 这个故事始于史蒂夫·乔布斯和比尔·盖茨这样的非凡的英雄,但科技的进步已经呈现出一种众包、有机的感觉。我认为据说我们的开源英雄林纳斯·托瓦兹在第一次发明 Linux 内核时甚至没有一个真正的计划。他无疑是一位才华横溢的年轻开发者,但他也像潮汐前的一滴水一样。*[00:26:00]* 变革是不可避免的。据估计,对于一家专有软件公司来说,用他们老式的、专有的方式创建一个 Linux 发行版将花费他们超过 100 亿美元。这说明了开源的力量。 + +最后,这并不是一个专有模型所能与之竞争的东西。成功的公司必须保持开放。这是最大、最终极的教训。*[00:26:30]* 还有一点要记住:当我们连接在一起的时候,我们在已有基础上成长和建设的能力是无限的。不管这些公司有多大,我们都不必坐等他们给我们更好的东西。想想那些为了纯粹的创造乐趣而学习编码的新开发者,那些自己动手丰衣足食的人。 + +未来的优秀程序员无管来自何方,只要能够访问代码,他们就能构建下一个大项目。 + +*[00:27:00]* 以上就是我们关于操作系统战争的两个故事。这场战争塑造了我们的数字生活。争夺主导地位的斗争从桌面转移到了服务器机房,最终进入了云计算领域。过去的敌人难以置信地变成了盟友,众包的未来让一切都变得开放。*[00:27:30]* 听着,我知道,在这段历史之旅中,还有很多英雄我们没有提到,所以给我们写信吧。分享你的故事。[Redhat.com/commandlineheroes](https://www.redhat.com/commandlineheroes) 。我恭候佳音。 + +在本季剩下的时间里,我们将学习今天的英雄们在创造什么,以及他们要经历什么样的战斗才能将他们的创造变为现实。让我们从壮丽的编程一线回来看看更多的传奇故事吧。我们每两周放一集新的博客。几周后,我们将为你带来第三集:敏捷革命。 + +*[00:28:00]* 代码英雄是一款红帽公司原创的播客。要想免费自动获得新一集的代码英雄,请订阅我们的节目。只要在苹果播客、Spotify、谷歌 Play,或其他应用中搜索“Command Line Heroes”。然后点击“订阅”。这样你就会第一个知道什么时候有新剧集了。 + +我是 Saron Yitbarek。感谢收听。继续编码。 + +-------------------------------------------------------------------------------- + +via: https://www.redhat.com/en/command-line-heroes/season-1/os-wars-part-2-rise-of-linux + +作者:[redhat][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.redhat.com +[b]: https://github.com/lujun9972 diff --git a/published/20180330 Go on very small hardware Part 1.md b/published/20180330 Go on very small hardware Part 1.md new file mode 100644 index 0000000000..e4759907fc --- /dev/null +++ b/published/20180330 Go on very small hardware Part 1.md @@ -0,0 +1,480 @@ +Go 语言在极小硬件上的运用(一) +========= + +Go 语言,能在多低下的配置上运行并发挥作用呢? + +我最近购买了一个特别便宜的开发板: + +![STM32F030F4P6](https://ziutek.github.io/images/mcu/f030-demo-board/board.jpg) + +我购买它的理由有三个。首先,我(作为程序员)从未接触过 STM320 系列的开发板。其次,STM32F10x 系列使用也有点少了。STM320 系列的 MCU 很便宜,有更新一些的外设,对系列产品进行了改进,问题修复也做得更好了。最后,为了这篇文章,我选用了这一系列中最低配置的开发板,整件事情就变得有趣起来了。 + +### 硬件部分 + +[STM32F030F4P6][3] 给人留下了很深的印象: + +* CPU: [Cortex M0][1] 48 MHz(最低配置,只有 12000 个逻辑门电路) +* RAM: 4 KB, +* Flash: 16 KB, +* ADC、SPI、I2C、USART 和几个定时器 + +以上这些采用了 TSSOP20 封装。正如你所见,这是一个很小的 32 位系统。 + +### 软件部分 + +如果你想知道如何在这块开发板上使用 [Go][4] 编程,你需要反复阅读硬件规范手册。你必须面对这样的真实情况:在 Go 编译器中给 Cortex-M0 提供支持的可能性很小。而且,这还仅仅只是第一个要解决的问题。 + +我会使用 [Emgo][5],但别担心,之后你会看到,它如何让 Go 在如此小的系统上尽可能发挥作用。 + +在我拿到这块开发板之前,对 [stm32/hal][6] 系列下的 F0 MCU 没有任何支持。在简单研究[参考手册][7]后,我发现 STM32F0 系列是 STM32F3 削减版,这让在新端口上开发的工作变得容易了一些。 + +如果你想接着本文的步骤做下去,需要先安装 Emgo + +``` +cd $HOME +git clone https://github.com/ziutek/emgo/ +cd emgo/egc +go install +``` + +然后设置一下环境变量 + +``` +export EGCC=path_to_arm_gcc # eg. /usr/local/arm/bin/arm-none-eabi-gcc +export EGLD=path_to_arm_linker # eg. /usr/local/arm/bin/arm-none-eabi-ld +export EGAR=path_to_arm_archiver # eg. /usr/local/arm/bin/arm-none-eabi-ar + +export EGROOT=$HOME/emgo/egroot +export EGPATH=$HOME/emgo/egpath + +export EGARCH=cortexm0 +export EGOS=noos +export EGTARGET=f030x6 +``` + +更详细的说明可以在 [Emgo][8] 官网上找到。 + +要确保 `egc` 在你的 `PATH` 中。 你可以使用 `go build` 来代替 `go install`,然后把 `egc` 复制到你的 `$HOME/bin` 或 `/usr/local/bin` 中。 + +现在,为你的第一个 Emgo 程序创建一个新文件夹,随后把示例中链接器脚本复制过来: + +``` +mkdir $HOME/firstemgo +cd $HOME/firstemgo +cp $EGPATH/src/stm32/examples/f030-demo-board/blinky/script.ld . +``` + +### 最基本程序 + +在 `main.go` 文件中创建一个最基本的程序: + +``` +package main + +func main() { +} +``` + +文件编译没有出现任何问题: + +``` +$ egc +$ arm-none-eabi-size cortexm0.elf + text data bss dec hex filename + 7452 172 104 7728 1e30 cortexm0.elf +``` + +第一次编译可能会花点时间。编译后产生的二进制占用了 7624 个字节的 Flash 空间(文本 + 数据)。对于一个什么都没做的程序来说,占用的空间有些大。还剩下 8760 字节,可以用来做些有用的事。 + +不妨试试传统的 “Hello, World!” 程序: + +``` +package main + +import "fmt" + +func main() { + fmt.Println("Hello, World!") +} +``` + +不幸的是,这次结果有些糟糕: + +``` +$ egc +/usr/local/arm/bin/arm-none-eabi-ld: /home/michal/P/go/src/github.com/ziutek/emgo/egpath/src/stm32/examples/f030-demo-board/blog/cortexm0.elf section `.text' will not fit in region `Flash' +/usr/local/arm/bin/arm-none-eabi-ld: region `Flash' overflowed by 10880 bytes +exit status 1 +``` + + “Hello, World!” 需要 STM32F030x6 上至少 32KB 的 Flash 空间。 + +`fmt` 包强制包含整个 `strconv` 和 `reflect` 包。这三个包,即使在精简版本中的 Emgo 中,占用空间也很大。我们不能使用这个例子了。有很多的应用不需要好看的文本输出。通常,一个或多个 LED,或者七段数码管显示就足够了。不过,在第二部分,我会尝试使用 `strconv` 包来格式化,并在 UART 上显示一些数字和文本。 + +### 闪烁 + +我们的开发板上有一个与 PA4 引脚和 VCC 相连的 LED。这次我们的代码稍稍长了一些: + +``` +package main + +import ( + "delay" + + "stm32/hal/gpio" + "stm32/hal/system" + "stm32/hal/system/timer/systick" +) + +var led gpio.Pin + +func init() { + system.SetupPLL(8, 1, 48/8) + systick.Setup(2e6) + + gpio.A.EnableClock(false) + led = gpio.A.Pin(4) + + cfg := &gpio.Config{Mode: gpio.Out, Driver: gpio.OpenDrain} + led.Setup(cfg) +} + +func main() { + for { + led.Clear() + delay.Millisec(100) + led.Set() + delay.Millisec(900) + } +} +``` + +按照惯例,`init` 函数用来初始化和配置外设。 + +`system.SetupPLL(8, 1, 48/8)` 用来配置 RCC,将外部的 8 MHz 振荡器的 PLL 作为系统时钟源。PLL 分频器设置为 1,倍频数设置为 48/8 =6,这样系统时钟频率为 48MHz。 + +`systick.Setup(2e6)` 将 Cortex-M SYSTICK 时钟作为系统时钟,每隔 2e6 次纳秒运行一次(每秒钟 500 次)。 + +`gpio.A.EnableClock(false)` 开启了 GPIO A 口的时钟。`False` 意味着这一时钟在低功耗模式下会被禁用,但在 STM32F0 系列中并未实现这一功能。 + +`led.Setup(cfg)` 设置 PA4 引脚为开漏输出。 + +`led.Clear()` 将 PA4 引脚设为低,在开漏设置中,打开 LED。 + +`led.Set()` 将 PA4 设为高电平状态,关掉LED。 + +编译这个代码: + +``` +$ egc +$ arm-none-eabi-size cortexm0.elf + text data bss dec hex filename + 9772 172 168 10112 2780 cortexm0.elf +``` + +正如你所看到的,这个闪烁程序占用了 2320 字节,比最基本程序占用空间要大。还有 6440 字节的剩余空间。 + +看看代码是否能运行: + +``` +$ openocd -d0 -f interface/stlink.cfg -f target/stm32f0x.cfg -c 'init; program cortexm0.elf; reset run; exit' +Open On-Chip Debugger 0.10.0+dev-00319-g8f1f912a (2018-03-07-19:20) +Licensed under GNU GPL v2 +For bug reports, read + http://openocd.org/doc/doxygen/bugs.html +debug_level: 0 +adapter speed: 1000 kHz +adapter_nsrst_delay: 100 +none separate +adapter speed: 950 kHz +target halted due to debug-request, current mode: Thread +xPSR: 0xc1000000 pc: 0x0800119c msp: 0x20000da0 +adapter speed: 4000 kHz +** Programming Started ** +auto erase enabled +target halted due to breakpoint, current mode: Thread +xPSR: 0x61000000 pc: 0x2000003a msp: 0x20000da0 +wrote 10240 bytes from file cortexm0.elf in 0.817425s (12.234 KiB/s) +** Programming Finished ** +adapter speed: 950 kHz +``` + +在这篇文章中,这是我第一次,将一个短视频转换成[动画 PNG][9]。我对此印象很深,再见了 YouTube。 对于 IE 用户,我很抱歉,更多信息请看 [apngasm][10]。我本应该学习 HTML5,但现在,APNG 是我最喜欢的,用来播放循环短视频的方法了。 + +![STM32F030F4P6](https://ziutek.github.io/images/mcu/f030-demo-board/blinky.png) + +### 更多的 Go 语言编程 + +如果你不是一个 Go 程序员,但你已经听说过一些关于 Go 语言的事情,你可能会说:“Go 语法很好,但跟 C 比起来,并没有明显的提升。让我看看 Go 语言的通道和协程!” + +接下来我会一一展示: + +``` +import ( + "delay" + + "stm32/hal/gpio" + "stm32/hal/system" + "stm32/hal/system/timer/systick" +) + +var led1, led2 gpio.Pin + +func init() { + system.SetupPLL(8, 1, 48/8) + systick.Setup(2e6) + + gpio.A.EnableClock(false) + led1 = gpio.A.Pin(4) + led2 = gpio.A.Pin(5) + + cfg := &gpio.Config{Mode: gpio.Out, Driver: gpio.OpenDrain} + led1.Setup(cfg) + led2.Setup(cfg) +} + +func blinky(led gpio.Pin, period int) { + for { + led.Clear() + delay.Millisec(100) + led.Set() + delay.Millisec(period - 100) + } +} + +func main() { + go blinky(led1, 500) + blinky(led2, 1000) +} + +``` + +代码改动很小: 添加了第二个 LED,上一个例子中的 `main` 函数被重命名为 `blinky` 并且需要提供两个参数。 `main` 在新的协程中先调用 `blinky`,所以两个 LED 灯在并行使用。值得一提的是,`gpio.Pin` 可以同时访问同一 GPIO 口的不同引脚。 + +Emgo 还有很多不足。其中之一就是你需要提前规定 `goroutines(tasks)` 的最大执行数量。是时候修改 `script.ld` 了: + +``` +ISRStack = 1024; +MainStack = 1024; +TaskStack = 1024; +MaxTasks = 2; + +INCLUDE stm32/f030x4 +INCLUDE stm32/loadflash +INCLUDE noos-cortexm +``` + +栈的大小需要靠猜,现在还不用关心这一点。 + +``` +$ egc +$ arm-none-eabi-size cortexm0.elf + text data bss dec hex filename + 10020 172 172 10364 287c cortexm0.elf +``` + +另一个 LED 和协程一共占用了 248 字节的 Flash 空间。 + +![STM32F030F4P6](https://ziutek.github.io/images/mcu/f030-demo-board/goroutines.png) + +### 通道 + +通道是 Go 语言中协程之间相互通信的一种[推荐方式][11]。Emgo 甚至能允许通过*中断处理*来使用缓冲通道。下一个例子就展示了这种情况。 + +``` +package main + +import ( + "delay" + "rtos" + + "stm32/hal/gpio" + "stm32/hal/irq" + "stm32/hal/system" + "stm32/hal/system/timer/systick" + "stm32/hal/tim" +) + +var ( + leds [3]gpio.Pin + timer *tim.Periph + ch = make(chan int, 1) +) + +func init() { + system.SetupPLL(8, 1, 48/8) + systick.Setup(2e6) + + gpio.A.EnableClock(false) + leds[0] = gpio.A.Pin(4) + leds[1] = gpio.A.Pin(5) + leds[2] = gpio.A.Pin(9) + + cfg := &gpio.Config{Mode: gpio.Out, Driver: gpio.OpenDrain} + for _, led := range leds { + led.Set() + led.Setup(cfg) + } + + timer = tim.TIM3 + pclk := timer.Bus().Clock() + if pclk < system.AHB.Clock() { + pclk *= 2 + } + freq := uint(1e3) // Hz + timer.EnableClock(true) + timer.PSC.Store(tim.PSC(pclk/freq - 1)) + timer.ARR.Store(700) // ms + timer.DIER.Store(tim.UIE) + timer.CR1.Store(tim.CEN) + + rtos.IRQ(irq.TIM3).Enable() +} + +func blinky(led gpio.Pin, period int) { + for range ch { + led.Clear() + delay.Millisec(100) + led.Set() + delay.Millisec(period - 100) + } +} + +func main() { + go blinky(leds[1], 500) + blinky(leds[2], 500) +} + +func timerISR() { + timer.SR.Store(0) + leds[0].Set() + select { + case ch <- 0: + // Success + default: + leds[0].Clear() + } +} + +//c:__attribute__((section(".ISRs"))) +var ISRs = [...]func(){ + irq.TIM3: timerISR, +} +``` + +与之前例子相比较下的不同: + +1. 添加了第三个 LED,并连接到 PA9 引脚(UART 头的 TXD 引脚)。 +2. 时钟(`TIM3`)作为中断源。 +3. 新函数 `timerISR` 用来处理 `irq.TIM3` 的中断。 +4. 新增容量为 1 的缓冲通道是为了 `timerISR` 和 `blinky` 协程之间的通信。 +5. `ISRs` 数组作为*中断向量表*,是更大的*异常向量表*的一部分。 +6. `blinky` 中的 `for` 语句被替换成 `range` 语句。 + +为了方便起见,所有的 LED,或者说它们的引脚,都被放在 `leds` 这个数组里。另外,所有引脚在被配置为输出之前,都设置为一种已知的初始状态(高电平状态)。 + +在这个例子里,我们想让时钟以 1 kHz 的频率运行。为了配置 TIM3 预分频器,我们需要知道它的输入时钟频率。通过参考手册我们知道,输入时钟频率在 `APBCLK = AHBCLK` 时,与 `APBCLK` 相同,反之等于 2 倍的 `APBCLK`。 + +如果 CNT 寄存器增加 1 kHz,那么 ARR 寄存器的值等于*更新事件*(重载事件)在毫秒中的计数周期。 为了让更新事件产生中断,必须要设置 DIER 寄存器中的 UIE 位。CEN 位能启动时钟。 + +时钟外设在低功耗模式下必须启用,为了自身能在 CPU 处于休眠时保持运行: `timer.EnableClock(true)`。这在 STM32F0 中无关紧要,但对代码可移植性却十分重要。 + +`timerISR` 函数处理 `irq.TIM3` 的中断请求。`timer.SR.Store(0)` 会清除 SR 寄存器里的所有事件标志,无效化向 [NVIC][12] 发出的所有中断请求。凭借经验,由于中断请求无效的延时性,需要在程序一开始马上清除所有的中断标志。这避免了无意间再次调用处理。为了确保万无一失,需要先清除标志,再读取,但是在我们的例子中,清除标志就已经足够了。 + +下面的这几行代码: + +``` +select { +case ch <- 0: + // Success +default: + leds[0].Clear() +} +``` + +是 Go 语言中,如何在通道上非阻塞地发送消息的方法。中断处理程序无法一直等待通道中的空余空间。如果通道已满,则执行 `default`,开发板上的LED就会开启,直到下一次中断。 + +`ISRs` 数组包含了中断向量表。`//c:__attribute__((section(".ISRs")))` 会导致链接器将数组插入到 `.ISRs` 节中。 + +`blinky` 的 `for` 循环的新写法: + +``` +for range ch { + led.Clear() + delay.Millisec(100) + led.Set() + delay.Millisec(period - 100) +} +``` + +等价于: + +``` +for { + _, ok := <-ch + if !ok { + break // Channel closed. + } + led.Clear() + delay.Millisec(100) + led.Set() + delay.Millisec(period - 100) +} +``` + +注意,在这个例子中,我们不在意通道中收到的值,我们只对其接受到的消息感兴趣。我们可以在声明时,将通道元素类型中的 `int` 用空结构体 `struct{}` 来代替,发送消息时,用 `struct{}{}` 结构体的值代替 0,但这部分对新手来说可能会有些陌生。 + +让我们来编译一下代码: + +``` +$ egc +$ arm-none-eabi-size cortexm0.elf + text data bss dec hex filename + 11096 228 188 11512 2cf8 cortexm0.elf +``` + +新的例子占用了 11324 字节的 Flash 空间,比上一个例子多占用了 1132 字节。 + +采用现在的时序,两个闪烁协程从通道中获取数据的速度,比 `timerISR` 发送数据的速度要快。所以它们在同时等待新数据,你还能观察到 `select` 的随机性,这也是 [Go 规范][13]所要求的。 + +![STM32F030F4P6](https://ziutek.github.io/images/mcu/f030-demo-board/channels1.png) + +开发板上的 LED 一直没有亮起,说明通道从未出现过溢出。 + +我们可以加快消息发送的速度,将 `timer.ARR.Store(700)` 改为 `timer.ARR.Store(200)`。 现在 `timerISR` 每秒钟发送 5 条消息,但是两个接收者加起来,每秒也只能接受 4 条消息。 + +![STM32F030F4P6](https://ziutek.github.io/images/mcu/f030-demo-board/channels2.png) + +正如你所看到的,`timerISR` 开启黄色 LED 灯,意味着通道上已经没有剩余空间了。 + +第一部分到这里就结束了。你应该知道,这一部分并未展示 Go 中最重要的部分,接口。 + +协程和通道只是一些方便好用的语法。你可以用自己的代码来替换它们,这并不容易,但也可以实现。接口是Go 语言的基础。这是文章中 [第二部分][14]所要提到的. + +在 Flash 上我们还有些剩余空间。 + +-------------------------------------------------------------------------------- + +via: https://ziutek.github.io/2018/03/30/go_on_very_small_hardware.html + +作者:[Michał Derkacz][a] +译者:[wenwensnow](https://github.com/wenwensnow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://ziutek.github.io/ +[1]:https://en.wikipedia.org/wiki/ARM_Cortex-M#Cortex-M0 +[2]:https://ziutek.github.io/2018/03/30/go_on_very_small_hardware.html +[3]:http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32-mainstream-mcus/stm32f0-series/stm32f0x0-value-line/stm32f030f4.html +[4]:https://golang.org/ +[5]:https://github.com/ziutek/emgo +[6]:https://github.com/ziutek/emgo/tree/master/egpath/src/stm32/hal +[7]:http://www.st.com/resource/en/reference_manual/dm00091010.pdf +[8]:https://github.com/ziutek/emgo +[9]:https://en.wikipedia.org/wiki/APNG +[10]:http://apngasm.sourceforge.net/ +[11]:https://blog.golang.org/share-memory-by-communicating +[12]:http://infocenter.arm.com/help/topic/com.arm.doc.ddi0432c/Cihbecee.html +[13]:https://golang.org/ref/spec#Select_statements +[14]:https://ziutek.github.io/2018/04/14/go_on_very_small_hardware2.html diff --git a/published/20180704 BASHing data- Truncated data items.md b/published/20180704 BASHing data- Truncated data items.md new file mode 100644 index 0000000000..dad03bf3da --- /dev/null +++ b/published/20180704 BASHing data- Truncated data items.md @@ -0,0 +1,115 @@ +如何发现截断的数据项 +====== + +**截断**(形容词):缩写、删节、缩减、剪切、剪裁、裁剪、修剪…… + +数据项被截断的一种情况是将其输入到数据库字段中,该字段的字符限制比数据项的长度要短。例如,字符串: + +``` +Yarrow Ravine Rattlesnake Habitat Area, 2 mi ENE of Yermo CA +``` + +是 60 个字符长。如果你将其输入到具有 50 个字符限制的“位置”字段,则可以获得: + +``` +Yarrow Ravine Rattlesnake Habitat Area, 2 mi ENE #末尾带有一个空格 +``` + +截断也可能导致数据错误,比如你打算输入: + +``` +Sally Ann Hunter (aka Sally Cleveland) +``` + +但是你忘记了闭合的括号: + +``` +Sally Ann Hunter (aka Sally Cleveland +``` + +这会让使用数据的用户觉得 Sally 是否有被修剪掉了数据项的其它的别名。 + +截断的数据项很难检测。在审核数据时,我使用三种不同的方法来查找可能的截断,但我仍然可能会错过一些。 + +**数据项的长度分布。**第一种方法是捕获我在各个字段中找到的大多数截断的数据。我将字段传递给 `awk` 命令,该命令按字段宽度计算数据项,然后我使用 `sort` 以宽度的逆序打印计数。例如,要检查以 `tab` 分隔的文件 `midges` 中的第 33 个字段: + +``` +awk -F"\t" 'NR>1 {a[length($33)]++} \ + END {for (i in a) print i FS a[i]}' midges | sort -nr +``` + +![distro1][1] + +最长的条目恰好有 50 个字符,这是可疑的,并且在该宽度处存在数据项的“凸起”,这更加可疑。检查这些 50 个字符的项目会发现截断: + +![distro2][2] + +我用这种方式检查的其他数据表有 100、200 和 255 个字符的“凸起”。在每种情况下,这种“凸起”都包含明显的截断。 + +**未匹配的括号。**第二种方法查找类似 `...(Sally Cleveland` 的数据项。一个很好的起点是数据表中所有标点符号的统计。这里我检查文件 `mag2`: + +``` +grep -o "[[:punct:]]" file | sort | uniqc +``` + +![punct][3] + +请注意,`mag2` 中的开括号和闭括号的数量不相等。要查看发生了什么,我使用 `unmatched` 函数,它接受三个参数并检查数据表中的所有字段。第一个参数是文件名,第二个和第三个是开括号和闭括号,用引号括起来。 + +``` +unmatched() +{ + awk -F"\t" -v start="$2" -v end="$3" \ + '{for (i=1;i<=NF;i++) \ + if (split($i,a,start) != split($i,b,end)) \ + print "line "NR", field "i":\n"$i}' "$1" +} +``` + +如果在字段中找到开括号和闭括号之间不匹配,则 `unmatched` 会报告行号和字段号。这依赖于 `awk` 的 `split` 函数,它返回由分隔符分隔的元素数(包括空格)。这个数字总是比分隔符的数量多一个: + +![split][4] + +这里 `ummatched` 检查 `mag2` 中的圆括号并找到一些可能的截断: + +![unmatched][5] + +我使用 `unmatched` 来找到不匹配的圆括号 `()`、方括号 `[]`、花括号 `{}` 和尖括号 `<>`,但该函数可用于任何配对的标点字符。 + +**意外的结尾。**第三种方法查找以尾随空格或非终止标点符号结尾的数据项,如逗号或连字符。这可以在单个字段上用 `cut` 用管道输入到 `grep` 完成,或者用 `awk` 一步完成。在这里,我正在检查以制表符分隔的表 `herp5` 的字段 47,并提取可疑数据项及其行号: + +``` +cut -f47 herp5 | grep -n "[ ,;:-]$" +或 +awk -F"\t" '$47 ~ /[ ,;:-]$/ {print NR": "$47}' herp5 +``` + +![herps5][6] + +用于制表符分隔文件的 awk 命令的全字段版本是: + +``` +awk -F"\t" '{for (i=1;i<=NF;i++) if ($i ~ /[ ,;:-]$/) \ + print "line "NR", field "i":\n"$i}' file +``` + +**谨慎的想法。**在我对字段进行的验证测试期间也会出现截断。例如,我可能会在“年”的字段中检查合理的 4 位数条目,并且有个 `198` 可能是 198n?还是 1898 年?带有丢失字符的截断数据项是个谜。 作为数据审计员,我只能报告(可能的)字符损失,并建议数据编制者或管理者恢复(可能)丢失的字符。 + +-------------------------------------------------------------------------------- + +via: https://www.polydesmida.info/BASHing/2018-07-04.html + +作者:[polydesmida][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.polydesmida.info/ +[1]:https://www.polydesmida.info/BASHing/img1/2018-07-04_1.png +[2]:https://www.polydesmida.info/BASHing/img1/2018-07-04_2.png +[3]:https://www.polydesmida.info/BASHing/img1/2018-07-04_3.png +[4]:https://www.polydesmida.info/BASHing/img1/2018-07-04_4.png +[5]:https://www.polydesmida.info/BASHing/img1/2018-07-04_5.png +[6]:https://www.polydesmida.info/BASHing/img1/2018-07-04_6.png diff --git a/published/20180802 Top 5 CAD Software Available for Linux in 2018.md b/published/20180802 Top 5 CAD Software Available for Linux in 2018.md new file mode 100644 index 0000000000..6607e44885 --- /dev/null +++ b/published/20180802 Top 5 CAD Software Available for Linux in 2018.md @@ -0,0 +1,141 @@ +Linux 上 5 个最好 CAD 软件 +====== + +[计算机辅助设计 (CAD)][1] 是很多工程流程的必不可少的部分。CAD 用于建筑、汽车零部件设计、航天飞机研究、航空、桥梁施工、室内设计,甚至服装和珠宝设计等专业领域。 + +在 Linux 上并不原生支持一些专业级 CAD 软件,如 SolidWorks 和 Autodesk AutoCAD。因此,今天,我们将看看排名靠前的 Linux 上可用的 CAD 软件。预知详情,请看下文。 + +### Linux 可用的最好的 CAD 软件 + +![CAD Software for Linux][2] + +在我们查看这份 Linux 的 CAD 软件列表前,你应该记住一件事,在这里不是所有的应用程序都是开源软件。我们也将包含一些非自由和开源软件的 CAD 软件来帮助普通的 Linux 用户。 + +我们为基于 Ubuntu 的 Linux 发行版提供了安装操作指南。对于其它发行版,你可以检查相应的网站来了解安装程序步骤。 + +该列表没有任何特殊顺序。在第一顺位的 CAD 应用程序不能认为比在第三顺位的好,以此类推。 + +#### 1、FreeCAD + +对于 3D 建模,FreeCAD 是一个极好的选择,它是自由 (免费和自由) 和开源软件。FreeCAD 坚持以构建机械工程和产品设计为目标。FreeCAD 是多平台的,可用于 Windows、Mac OS X+ 以及 Linux。 + +![freecad][3] + +尽管 FreeCAD 已经是很多 Linux 用户的选择,应该注意到,FreeCAD 仍然是 0.17 版本,因此,不适用于重要的部署。但是最近开发加速了。 + +- [FreeCAD][4] + +FreeCAD 并不专注于 direct-2D 绘图和真实形状的动画,但是它对机械工程相关的设计极好。FreeCAD 的 0.15 版本在 Ubuntu 存储库中可用。你可以通过运行下面的命令安装。 + +``` +sudo apt install freecad +``` + +为获取新的每日构建(目前 0.17),打开一个终端(`ctrl+alt+t`),并逐个运行下面的命令。 + +``` +sudo add-apt-repository ppa:freecad-maintainers/freecad-daily +sudo apt update +sudo apt install freecad-daily +``` + +#### 2、LibreCAD + +LibreCAD 是一个自由开源的、2D CAD 解决方案。一般来说,CAD 是一个资源密集型任务,如果你有一个相当普通的硬件,那么我建议你使用 LibreCAD ,因为它在资源使用方面真的轻量化。LibreCAD 是几何图形结构方面的一个极好的候选者。 + +![librecad][5] + +作为一个 2D 工具,LibreCAD 是好的,但是它不能在 3D 模型和渲染上工作。它有时可能不稳定,但是,它有一个可靠的自动保存,它不会让你的工作浪费。 + +- [LibreCAD][6] + +你可以通过运行下面的命令安装 LibreCAD。 + +``` +sudo apt install librecad +``` + +#### 3、OpenSCAD + +OpenSCAD 是一个自由的 3D CAD 软件。OpenSCAD 非常轻量和灵活。OpenSCAD 不是交互式的。你需要‘编程’模型,OpenSCAD 来解释这些代码来渲染一个可视化模型。在某种意义上说,它是一个编译器。你不能直接绘制模型,而是描述模型。 + +![openscad][7] + +OpenSCAD 是这个列表上最复杂的工具,但是,一旦你了解它,它将提供一个令人愉快的工作经历。 + +- [OpenSCAD][8] + +你可以使用下面的命令来安装 OpenSCAD。 + +``` +sudo apt-get install openscad +``` + +#### 4、BRL-CAD + +BRL-CAD 是最老的 CAD 工具之一。它也深受 Linux/UNIX 用户喜爱,因为它与模块化和自由的 *nix 哲学相一致。 + +![BRL-CAD rendering by Sean][9] + +BRL-CAD 始于 1979 年,并且,它仍然在积极开发。现在,BRL-CAD 不是 AutoCAD,但是对于像热穿透和弹道穿透等等的运输研究仍然是一个极好的选择。BRL-CAD 构成 CSG 的基础,而不是边界表示。在选择 BRL-CAD 时,你可能需要记住这一点。你可以从它的官方网站下载 BRL-CAD 。 + +- [BRL-CAD][10] + +#### 5、DraftSight (非开源) + +如果你习惯在 AutoCAD 上作业。那么,DraftSight 将是完美的替代。 + +DraftSight 是一个在 Linux 上可用的极好的 CAD 工具。它有相当类似于 AutoCAD 的工作流,这使得迁移更容易。它甚至提供一种类似的外观和感觉。DrafSight 也兼容 AutoCAD 的 .dwg 文件格式。 但是,DrafSight 是一个 2D CAD 软件。截至当前,它不支持 3D CAD 。 + +![draftsight][11] + +尽管 DrafSight 是一款起价 149 美元的商业软件。在 [DraftSight 网站][12]上可获得一个免费版本。你可以下载 .deb 软件包,并在基于 Ubuntu 的发行版上安装它。为了开始使用 DraftSight ,你需要使用你的电子邮件 ID 来注册你的免费版本。 + +- [DraftSight][12] + +#### 荣誉提名 + +* 随着云计算技术的巨大发展,像 [OnShape][13] 的云 CAD 解决方案已经变得日渐流行。 +* [SolveSpace][14] 是另一个值得一提的开源软件项目。它支持 3D 模型。 +* 西门子 NX 是一个在 Windows、Mac OS 及 Linux 上可用的工业级 CAD 解决方案,但是它贵得离谱,所以,在这个列表中被忽略。 +* 接下来,你有 [LeoCAD][15],它是一个 CAD 软件,在软件中你使用乐高积木来构建东西。你使用这些信息做些什么取决于你。 + +### 我对 Linux 上的 CAD 的看法 + +尽管在 Linux 上游戏变得流行,我总是告诉我的铁杆游戏朋友坚持使用 Windows。类似地,如果你是一名在你是课程中使用 CAD 的工科学生,我建议你使用学校规定的软件 (AutoCAD、SolidEdge、Catia),这些软件通常只在 Windows 上运行。 + +对于高级专业人士来说,当我们讨论行业标准时,这些工具根本达不到标准。 + +对于想在 WINE 中运行 AutoCAD 的那些人来说,尽管一些较旧版本的 AutoCAD 可以安装在 WINE 上,它们根本不执行工作,小故障和崩溃严重损害这些体验。 + +话虽如此,我高度尊重上述列表中软件的开发者的工作。他们丰富了 FOSS 世界。很高兴看到像 FreeCAD 一样的软件在近些年中加速开发速度。 + +好了,今天到此为止。使用下面的评论区与我们分享你的想法,不用忘记分享这篇文章。谢谢。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/cad-software-linux/ + +作者:[Aquil Roshan][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://itsfoss.com/author/aquil/ +[1]:https://en.wikipedia.org/wiki/Computer-aided_design +[2]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/08/cad-software-linux.jpeg +[3]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/freecad.jpg +[4]:https://www.freecadweb.org/ +[5]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/librecad.jpg +[6]:https://librecad.org/ +[7]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/openscad.jpg +[8]:http://www.openscad.org/ +[9]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/brlcad.jpg +[10]:https://brlcad.org/ +[11]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/draftsight.jpg +[12]:https://www.draftsight2018.com/ +[13]:https://www.onshape.com/ +[14]:http://solvespace.com/index.pl +[15]:https://www.leocad.org/ diff --git a/published/20180904 How blockchain can complement open source.md b/published/20180904 How blockchain can complement open source.md new file mode 100644 index 0000000000..a8f2d15a3c --- /dev/null +++ b/published/20180904 How blockchain can complement open source.md @@ -0,0 +1,89 @@ +区块链能如何补充开源 +====== + +> 了解区块链如何成为去中心化的开源补贴模型。 + +![](https://img.linux.net.cn/data/attachment/album/201909/16/111521od1yn9r1nr1eii9o.jpg) + +《[大教堂与集市][1]The Cathedral and The Bazaar》是 20 年前由埃里克·史蒂文·雷蒙德Eric Steven Raymond(ESR)撰写的经典开源故事。在这个故事中,ESR 描述了一种新的革命性的软件开发模型,其中复杂的软件项目是在没有(或者很少的)集中管理的情况下构建的。这个新模型就是开源open source。 + +ESR 的故事比较了两种模式: + +* 经典模型(由“大教堂”所代表),其中软件由一小群人在封闭和受控的环境中通过缓慢而稳定的发布制作而成。 +* 以及新模式(由“集市”所代表),其中软件是在开放的环境中制作的,个人可以自由参与,但仍然可以产生一个稳定和连贯的系统。 +   +开源如此成功的一些原因可以追溯到 ESR 所描述的创始原则。尽早发布、经常发布,并接受许多头脑必然比一个更好的事实,让开源项目进入全世界的人才库(很少有公司能够使用闭源模式与之匹敌)。 + +在 ESR 对黑客社区的反思分析 20 年后,我们看到开源成为占据主导地位的的模式。它不再仅仅是为了满足开发人员的个人喜好,而是创新发生的地方。甚至是全球[最大][2]软件公司也正在转向这种模式,以便继续占据主导地位。 + +### 易货系统 + +如果我们仔细研究开源模型在实践中的运作方式,我们就会意识到它是一个封闭系统,只对开源开发者和技术人员开放。影响项目方向的唯一方法是加入开源社区,了解成文和不成文的规则,学习如何贡献、编码标准等,并自己亲力完成。 + +这就是集市的运作方式,也是这个易货系统类比的来源。易货系统是一种交换服务和货物以换取其他服务和货物的方法。在市场中(即软件的构建地)这意味着为了获取某些东西,你必须自己也是一个生产者并回馈一些东西——那就是通过交换你的时间和知识来完成任务。集市是开源开发者与其他开源开发者交互并以开源方式生成开源软件的地方。 + +易货系统向前迈出了一大步,从自给自足的状态演变而来,而在自给自足的状态下,每个人都必须成为所有行业的杰出人选。使用易货系统的集市(开源模式)允许具有共同兴趣和不同技能的人们收集、协作和创造个人无法自行创造的东西。易货系统简单,没有现代货币系统那么复杂,但也有一些局限性,例如: + +* 缺乏可分性:在没有共同的交换媒介的情况下,不能将较大的不可分割的商品/价值兑换成较小的商品/价值。例如,如果你想在开源项目中进行一些哪怕是小的更改,有时你可能仍需要经历一个高进入门槛。 +* 存储价值:如果一个项目对贵公司很重要,你可能需要投入大量投资/承诺。但由于它是开源开发者之间的易货系统,因此拥有强大发言权的唯一方法是雇佣许多开源贡献者,但这并非总是可行的。 +* 转移价值:如果你投资了一个项目(受过培训的员工、雇用开源开发者)并希望将重点转移到另一个项目,却不可能快速转移(你在上一个项目中拥有的)专业知识、声誉和影响力。 +* 时间脱钩:易货系统没有为延期或提前承诺提供良好的机制。在开源世界中,这意味着用户无法提前或在未来期间以可衡量的方式表达对项目的承诺或兴趣。 +   +下面,我们将探讨如何使用集市的后门解决这些限制。 + +### 货币系统 + +人们因为不同的原因勾连于集市上:有些人在那里学习,有些是出于满足开发者个人的喜好,有些人为大型软件工厂工作。因为在集市中拥有发言权的唯一方法是成为开源社区的一份子并加入这个易货系统,为了在开源世界获得信誉,许多大型软件公司雇用这些开发者并以货币方式支付薪酬。这代表可以使用货币系统来影响集市,开源不再只是为了满足开发者个人的喜好,它也占据全球整体软件生产的重要部分,并且有许多人想要施加影响。 + +开源设定了开发人员交互的指导原则,并以分布式方式构建一致的系统。它决定了项目的治理方式、软件的构建方式以及其成果如何分发给用户。它是分散的实体共同构建高质量软件的开放共识模型。但是开源模型并没有包括如何补贴开源的部分,无论是直接还是间接地,通过内在或外在动机的赞助,都与集市无关。 + +![](https://opensource.com/sites/default/files/uploads/tokenomics_-_page_4.png) + +目前,没有相当于以补贴为目的的去中心化式开源开发模型。大多数开源补贴都是集中式的,通常一家公司通过雇用该项目的主要开源开发者来主导该项目。说实话,这是目前最好的状况,因为它保证了开发人员将长期获得报酬,项目也将继续蓬勃发展。 + +项目垄断情景也有例外情况:例如,一些云原生计算基金会(CNCF)项目是由大量的竞争公司开发的。此外,Apache 软件基金会(ASF)旨在通过鼓励不同的贡献者来使他们管理的项目不被单一供应商所主导,但实际上大多数受欢迎的项目仍然是单一供应商项目。 + +我们缺少的是一个开放的、去中心化的模式,就像一个没有集中协调和所有权的集市一样,消费者(开源用户)和生产者(开源开发者)在市场力量和开源价值的驱动下相互作用。为了补充开源,这样的模型也必须是开放和去中心化的,这就是为什么我认为区块链技术[最适合][3]的原因。 + +旨在补贴开源开发的大多数现有区块链(和非区块链)平台主要针对的是漏洞赏金、小型和零碎的任务。少数人还专注于资助新的开源项目。但并没有多少平台旨在提供维持开源项目持续开发的机制 —— 基本上,这个系统可以模仿开源服务提供商公司或开放核心、基于开源的 SaaS 产品公司的行为:确保开发人员可以获得持续和可预测的激励,并根据激励者(即用户)的优先事项指导项目开发。这种模型将解决上面列出的易货系统的局限性: + +* 允许可分性:如果你想要一些小的修复,你可以支付少量费用,而不是成为项目的开源开发者的全部费用。 +* 存储价值:你可以在项目中投入大量资金,并确保其持续发展和你的发言权。 +* 转移价值:在任何时候,你都可以停止投资项目并将资金转移到其他项目中。 +* 时间脱钩:允许定期定期付款和订阅。 + +还有其他好处,纯粹是因为这种基于区块链的系统是透明和去中心化的:根据用户的承诺、开放的路线图承诺、去中心化决策等来量化项目的价值/实用性。 + +### 总结 + +一方面,我们看到大公司雇用开源开发者并收购开源初创公司甚至基础平台(例如微软收购 GitHub)。许多(甚至大多数)能够长期成功运行的开源项目都集中在单个供应商周围。开源的重要性及其集中化是一个事实。 + +另一方面,[维持开源软件][4]的挑战正变得越来越明显,许多人正在更深入地研究这个领域及其基本问题。有一些项目具有很高的知名度和大量的贡献者,但还有许多其他也重要的项目缺乏足够的贡献者和维护者。 + +有[许多努力][3]试图通过区块链来解决开源的挑战。这些项目应提高透明度、去中心化和补贴,并在开源用户和开发人员之间建立直接联系。这个领域还很年轻,但是进展很快,随着时间的推移,集市将会有一个加密货币系统。 + +如果有足够的时间和足够的技术,去中心化就会发生在很多层面: + +* 互联网是一种去中心化的媒介,它释放了全球分享和获取知识的潜力。 +* 开源是一种去中心化的协作模式,它释放了全球的创新潜力。 +* 同样,区块链可以补充开源,成为去中心化的开源补贴模式。 + +请在[推特][5]上关注我在这个领域的其他帖子。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/barter-currency-system + +作者:[Bilgin lbryam][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bibryam +[1]: http://catb.org/ +[2]: http://oss.cash/ +[3]: https://opensource.com/article/18/8/open-source-tokenomics +[4]: https://www.youtube.com/watch?v=VS6IpvTWwkQ +[5]: http://twitter.com/bibryam diff --git a/published/20181113 Eldoc Goes Global.md b/published/20181113 Eldoc Goes Global.md new file mode 100644 index 0000000000..4714f966a1 --- /dev/null +++ b/published/20181113 Eldoc Goes Global.md @@ -0,0 +1,48 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11306-1.html) +[#]: subject: (Eldoc Goes Global) +[#]: via: (https://emacsredux.com/blog/2018/11/13/eldoc-goes-global/) +[#]: author: (Bozhidar Batsov https://emacsredux.com) + +Emacs:Eldoc 全局化了 +====== + +![](https://img.linux.net.cn/data/attachment/album/201909/05/045702d99v9vv4xy0aybmm.jpg) + +最近我注意到 Emacs 25.1 增加了一个名为 `global-eldoc-mode` 的模式,它是流行的 `eldoc-mode` 的一个全局化的变体。而且与 `eldoc-mode` 不同的是,`global-eldoc-mode` 默认是开启的! + +这意味着你可以删除 Emacs 配置中为主模式开启 `eldoc-mode` 的代码了: + +``` +;; That code is now redundant +(add-hook 'emacs-lisp-mode-hook #'eldoc-mode) +(add-hook 'ielm-mode-hook #'eldoc-mode) +(add-hook 'cider-mode-hook #'eldoc-mode) +(add-hook 'cider-repl-mode-hook #'eldoc-mode) +``` + +[有人说][1] `global-eldoc-mode` 在某些不支持的模式中会有性能问题。我自己从未遇到过,但若你像禁用它则只需要这样: + +``` +(global-eldoc-mode -1) +``` + +现在是时候清理我的配置了!删除代码就是这么爽! + +-------------------------------------------------------------------------------- + +via: https://emacsredux.com/blog/2018/11/13/eldoc-goes-global/ + +作者:[Bozhidar Batsov][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://emacsredux.com +[b]: https://github.com/lujun9972 +[1]: https://emacs.stackexchange.com/questions/31414/how-to-globally-disable-eldoc diff --git a/published/20181227 Linux commands for measuring disk activity.md b/published/20181227 Linux commands for measuring disk activity.md new file mode 100644 index 0000000000..05988cbf63 --- /dev/null +++ b/published/20181227 Linux commands for measuring disk activity.md @@ -0,0 +1,252 @@ +[#]: collector: (lujun9972) +[#]: translator: (laingke) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11387-1.html) +[#]: subject: (Linux commands for measuring disk activity) +[#]: via: (https://www.networkworld.com/article/3330497/linux/linux-commands-for-measuring-disk-activity.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +用于测量磁盘活动的 Linux 命令 +====== +> Linux 发行版提供了几个度量磁盘活动的有用命令。让我们了解一下其中的几个。 + +![](https://images.idgesg.net/images/article/2018/12/tape-measure-100782593-large.jpg) + +Linux 系统提供了一套方便的命令,帮助你查看磁盘有多忙,而不仅仅是磁盘有多满。在本文中,我们将研究五个非常有用的命令,用于查看磁盘活动。其中两个命令(`iostat` 和 `ioping`)可能必须添加到你的系统中,这两个命令一样要求你使用 sudo 特权,所有这五个命令都提供了查看磁盘活动的有用方法。 + +这些命令中最简单、最直观的一个可能是 `dstat` 了。 + +### dtstat + +尽管 `dstat` 命令以字母 “d” 开头,但它提供的统计信息远远不止磁盘活动。如果你只想查看磁盘活动,可以使用 `-d` 选项。如下所示,你将得到一个磁盘读/写测量值的连续列表,直到使用 `CTRL-c` 停止显示为止。注意,在第一个报告信息之后,显示中的每个后续行将在接下来的时间间隔内报告磁盘活动,缺省值仅为一秒。 + +``` +$ dstat -d +-dsk/total- + read writ + 949B 73k + 65k 0 <== first second + 0 24k <== second second + 0 16k + 0 0 ^C +``` + +在 `-d` 选项后面包含一个数字将把间隔设置为该秒数。 + +``` +$ dstat -d 10 +-dsk/total- + read writ + 949B 73k + 65k 81M <== first five seconds + 0 21k <== second five second + 0 9011B ^C +``` + +请注意,报告的数据可能以许多不同的单位显示——例如,M(Mb)、K(Kb)和 B(字节)。 + +如果没有选项,`dstat` 命令还将显示许多其他信息——指示 CPU 如何使用时间、显示网络和分页活动、报告中断和上下文切换。 + +``` +$ dstat +You did not select any stats, using -cdngy by default. +--total-cpu-usage-- -dsk/total- -net/total- ---paging-- ---system-- +usr sys idl wai stl| read writ| recv send| in out | int csw + 0 0 100 0 0| 949B 73k| 0 0 | 0 3B| 38 65 + 0 0 100 0 0| 0 0 | 218B 932B| 0 0 | 53 68 + 0 1 99 0 0| 0 16k| 64B 468B| 0 0 | 64 81 ^C +``` + +`dstat` 命令提供了关于整个 Linux 系统性能的有价值的见解,几乎可以用它灵活而功能强大的命令来代替 `vmstat`、`netstat`、`iostat` 和 `ifstat` 等较旧的工具集合,该命令结合了这些旧工具的功能。要深入了解 `dstat` 命令可以提供的其它信息,请参阅这篇关于 [dstat][1] 命令的文章。 + +### iostat + +`iostat` 命令通过观察设备活动的时间与其平均传输速率之间的关系,帮助监视系统输入/输出设备的加载情况。它有时用于评估磁盘之间的活动平衡。 + +``` +$ iostat +Linux 4.18.0-041800-generic (butterfly) 12/26/2018 _x86_64_ (2 CPU) + +avg-cpu: %user %nice %system %iowait %steal %idle + 0.07 0.01 0.03 0.05 0.00 99.85 + +Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn +loop0 0.00 0.00 0.00 1048 0 +loop1 0.00 0.00 0.00 365 0 +loop2 0.00 0.00 0.00 1056 0 +loop3 0.00 0.01 0.00 16169 0 +loop4 0.00 0.00 0.00 413 0 +loop5 0.00 0.00 0.00 1184 0 +loop6 0.00 0.00 0.00 1062 0 +loop7 0.00 0.00 0.00 5261 0 +sda 1.06 0.89 72.66 2837453 232735080 +sdb 0.00 0.02 0.00 48669 40 +loop8 0.00 0.00 0.00 1053 0 +loop9 0.01 0.01 0.00 18949 0 +loop10 0.00 0.00 0.00 56 0 +loop11 0.00 0.00 0.00 7090 0 +loop12 0.00 0.00 0.00 1160 0 +loop13 0.00 0.00 0.00 108 0 +loop14 0.00 0.00 0.00 3572 0 +loop15 0.01 0.01 0.00 20026 0 +loop16 0.00 0.00 0.00 24 0 +``` + +当然,当你只想关注磁盘时,Linux 回环设备上提供的所有统计信息都会使结果显得杂乱无章。不过,该命令也确实提供了 `-p` 选项,该选项使你可以仅查看磁盘——如以下命令所示。 + +``` +$ iostat -p sda +Linux 4.18.0-041800-generic (butterfly) 12/26/2018 _x86_64_ (2 CPU) + +avg-cpu: %user %nice %system %iowait %steal %idle + 0.07 0.01 0.03 0.05 0.00 99.85 + +Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn +sda 1.06 0.89 72.54 2843737 232815784 +sda1 1.04 0.88 72.54 2821733 232815784 +``` + +请注意 `tps` 是指每秒的传输量。 + +你还可以让 `iostat` 提供重复的报告。在下面的示例中,我们使用 `-d` 选项每五秒钟进行一次测量。 + +``` +$ iostat -p sda -d 5 +Linux 4.18.0-041800-generic (butterfly) 12/26/2018 _x86_64_ (2 CPU) + +Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn +sda 1.06 0.89 72.51 2843749 232834048 +sda1 1.04 0.88 72.51 2821745 232834048 + +Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn +sda 0.80 0.00 11.20 0 56 +sda1 0.80 0.00 11.20 0 56 +``` + +如果你希望省略第一个(自启动以来的统计信息)报告,请在命令中添加 `-y`。 + +``` +$ iostat -p sda -d 5 -y +Linux 4.18.0-041800-generic (butterfly) 12/26/2018 _x86_64_ (2 CPU) + +Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn +sda 0.80 0.00 11.20 0 56 +sda1 0.80 0.00 11.20 0 56 +``` + +接下来,我们看第二个磁盘驱动器。 + +``` +$ iostat -p sdb +Linux 4.18.0-041800-generic (butterfly) 12/26/2018 _x86_64_ (2 CPU) + +avg-cpu: %user %nice %system %iowait %steal %idle + 0.07 0.01 0.03 0.05 0.00 99.85 + +Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn +sdb 0.00 0.02 0.00 48669 40 +sdb2 0.00 0.00 0.00 4861 40 +sdb1 0.00 0.01 0.00 35344 0 +``` + +### iotop + +`iotop` 命令是类似 `top` 的实用程序,用于查看磁盘 I/O。它收集 Linux 内核提供的 I/O 使用信息,以便你了解哪些进程在磁盘 I/O 方面的要求最高。在下面的示例中,循环时间被设置为 5 秒。显示将自动更新,覆盖前面的输出。 + +``` +$ sudo iotop -d 5 +Total DISK READ: 0.00 B/s | Total DISK WRITE: 1585.31 B/s +Current DISK READ: 0.00 B/s | Current DISK WRITE: 12.39 K/s + TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND +32492 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.12 % [kworker/u8:1-ev~_power_efficient] + 208 be/3 root 0.00 B/s 1585.31 B/s 0.00 % 0.11 % [jbd2/sda1-8] + 1 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % init splash + 2 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kthreadd] + 3 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [rcu_gp] + 4 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [rcu_par_gp] + 8 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [mm_percpu_wq] +``` + +### ioping + +`ioping` 命令是一种完全不同的工具,但是它可以报告磁盘延迟——也就是磁盘响应请求需要多长时间,而这有助于诊断磁盘问题。 + +``` +$ sudo ioping /dev/sda1 +4 KiB <<< /dev/sda1 (block device 111.8 GiB): request=1 time=960.2 us (warmup) +4 KiB <<< /dev/sda1 (block device 111.8 GiB): request=2 time=841.5 us +4 KiB <<< /dev/sda1 (block device 111.8 GiB): request=3 time=831.0 us +4 KiB <<< /dev/sda1 (block device 111.8 GiB): request=4 time=1.17 ms +^C +--- /dev/sda1 (block device 111.8 GiB) ioping statistics --- +3 requests completed in 2.84 ms, 12 KiB read, 1.05 k iops, 4.12 MiB/s +generated 4 requests in 3.37 s, 16 KiB, 1 iops, 4.75 KiB/s +min/avg/max/mdev = 831.0 us / 947.9 us / 1.17 ms / 158.0 us +``` + +### atop + +`atop` 命令,像 `top` 一样提供了大量有关系统性能的信息,包括有关磁盘活动的一些统计信息。 + +``` +ATOP - butterfly 2018/12/26 17:24:19 37d3h13m------ 10ed +PRC | sys 0.03s | user 0.01s | #proc 179 | #zombie 0 | #exit 6 | +CPU | sys 1% | user 0% | irq 0% | idle 199% | wait 0% | +cpu | sys 1% | user 0% | irq 0% | idle 99% | cpu000 w 0% | +CPL | avg1 0.00 | avg5 0.00 | avg15 0.00 | csw 677 | intr 470 | +MEM | tot 5.8G | free 223.4M | cache 4.6G | buff 253.2M | slab 394.4M | +SWP | tot 2.0G | free 2.0G | | vmcom 1.9G | vmlim 4.9G | +DSK | sda | busy 0% | read 0 | write 7 | avio 1.14 ms | +NET | transport | tcpi 4 | tcpo stall 8 | udpi 1 | udpo 0swout 2255 | +NET | network | ipi 10 | ipo 7 | ipfrw 0 | deliv 60.67 ms | +NET | enp0s25 0% | pcki 10 | pcko 8 | si 1 Kbps | so 3 Kbp0.73 ms | + + PID SYSCPU USRCPU VGROW RGROW ST EXC THR S CPUNR CPU CMD 1/1673e4 | + 3357 0.01s 0.00s 672K 824K -- - 1 R 0 0% atop + 3359 0.01s 0.00s 0K 0K NE 0 0 E - 0% + 3361 0.00s 0.01s 0K 0K NE 0 0 E - 0% + 3363 0.01s 0.00s 0K 0K NE 0 0 E - 0% +31357 0.00s 0.00s 0K 0K -- - 1 S 1 0% bash + 3364 0.00s 0.00s 8032K 756K N- - 1 S 1 0% sleep + 2931 0.00s 0.00s 0K 0K -- - 1 I 1 0% kworker/u8:2-e + 3356 0.00s 0.00s 0K 0K -E 0 0 E - 0% + 3360 0.00s 0.00s 0K 0K NE 0 0 E - 0% + 3362 0.00s 0.00s 0K 0K NE 0 0 E - 0% +``` + +如果你*只*想查看磁盘统计信息,则可以使用以下命令轻松进行管理: + +``` +$ atop | grep DSK +DSK | sda | busy 0% | read 122901 | write 3318e3 | avio 0.67 ms | +DSK | sdb | busy 0% | read 1168 | write 103 | avio 0.73 ms | +DSK | sda | busy 2% | read 0 | write 92 | avio 2.39 ms | +DSK | sda | busy 2% | read 0 | write 94 | avio 2.47 ms | +DSK | sda | busy 2% | read 0 | write 99 | avio 2.26 ms | +DSK | sda | busy 2% | read 0 | write 94 | avio 2.43 ms | +DSK | sda | busy 2% | read 0 | write 94 | avio 2.43 ms | +DSK | sda | busy 2% | read 0 | write 92 | avio 2.43 ms | +^C +``` + +### 了解磁盘 I/O + +Linux 提供了足够的命令,可以让你很好地了解磁盘的工作强度,并帮助你关注潜在的问题或减缓。希望这些命令中的一个可以告诉你何时需要质疑磁盘性能。偶尔使用这些命令将有助于确保当你需要检查磁盘,特别是忙碌或缓慢的磁盘时可以显而易见地发现它们。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3330497/linux/linux-commands-for-measuring-disk-activity.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[laingke](https://github.com/laingke) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3291616/linux/examining-linux-system-performance-with-dstat.html +[2]: https://www.facebook.com/NetworkWorld/ +[3]: https://www.linkedin.com/company/network-world diff --git a/published/20190129 Create an online store with this Java-based framework.md b/published/20190129 Create an online store with this Java-based framework.md new file mode 100644 index 0000000000..ad9c52ab6f --- /dev/null +++ b/published/20190129 Create an online store with this Java-based framework.md @@ -0,0 +1,227 @@ +[#]: collector: (lujun9972) +[#]: translator: (laingke) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11373-1.html) +[#]: subject: (Create an online store with this Java-based framework) +[#]: via: (https://opensource.com/article/19/1/scipio-erp) +[#]: author: (Paul Piper https://opensource.com/users/madppiper) + +使用 Java 框架 Scipio ERP 创建一个在线商店 +====== + +> Scipio ERP 具有包罗万象的应用程序和功能。 + +![](https://img.linux.net.cn/data/attachment/album/201909/22/133258hqvwax5w1zvq5ffa.jpg) + +如果,你想在网上销售产品或服务,但要么找不到合适的软件,要么觉得定制成本太高?那么,[Scipio ERP][1] 也许正是你想要的。 + +Scipio ERP 是一个基于 Java 的开源的电子商务框架,具有包罗万象的应用程序和功能。这个项目于 2014 年从 [Apache OFBiz][2] 分叉而来,侧重于更好的定制和更现代的吸引力。这个电子商务组件非常丰富,可以在多商店环境中工作,同时支持国际化,具有琳琅满目的产品配置,而且它还兼容现代 HTML 框架。该软件还为许多其他业务场景提供标准应用程序,例如会计、仓库管理或销售团队自动化。它都是高度标准化的,因此易于定制,如果你想要的不仅仅是一个虚拟购物车,这是非常棒的。 + +该系统也使得跟上现代 Web 标准变得非常容易。所有界面都是使用系统的“[模板工具包][3]”构建的,这是一个易于学习的宏集,可以将 HTML 与所有应用程序分开。正因为如此,每个应用程序都已经标准化到核心。听起来令人困惑?它真的不是 HTML——它看起来很像 HTML,但你写的内容少了很多。 + +### 初始安装 + +在你开始之前,请确保你已经安装了 Java 1.8(或更高版本)的 SDK 以及一个 Git 客户端。完成了?太棒了!接下来,切换到 Github 上的主分支: + +``` +git clone https://github.com/ilscipio/scipio-erp.git +cd scipio-erp +git checkout master +``` + +要安装该系统,只需要运行 `./install.sh` 并从命令行中选择任一选项。在开发过程中,最好一直使用 “installation for development”(选项 1),它还将安装一系列演示数据。对于专业安装,你可以修改初始配置数据(“种子数据”),以便自动为你设置公司和目录数据。默认情况下,系统将使用内部数据库运行,但是它[也可以配置][4]使用各种关系数据库,比如 PostgreSQL 和 MariaDB 等。 + +![安装向导][6] + +*按照安装向导完成初始配置* + +通过命令 `./start.sh` 启动系统然后打开链接 完成配置。如果你安装了演示数据, 你可以使用用户名 `admin` 和密码 `scipio` 进行登录。在安装向导中,你可以设置公司简介、会计、仓库、产品目录、在线商店和额外的用户配置信息。暂时在产品商店配置界面上跳过网站实体的配置。系统允许你使用不同的底层代码运行多个在线商店;除非你想这样做,一直选择默认值是最简单的。 + +祝贺你,你刚刚安装了 Scipio ERP!在界面上操作一两分钟,感受一下它的功能。 + +### 捷径 + +在你进入自定义之前,这里有一些方便的命令可以帮助你: + + * 创建一个 shop-override:`./ant create-component-shop-override` + * 创建一个新组件:`./ant create-component` + * 创建一个新主题组件:`./ant create-theme` + * 创建管理员用户:`./ant create-admin-user-login` + * 各种其他实用功能:`./ant -p` + * 用于安装和更新插件的实用程序:`./git-addons help` + +另外,请记下以下位置: + + * 将 Scipio 作为服务运行的脚本:`/tools/scripts/` + * 日志输出目录:`/runtime/logs` + * 管理应用程序:`` + * 电子商务应用程序:`` + +最后,Scipio ERP 在以下五个主要目录中构建了所有代码: + + * `framework`: 框架相关的源,应用程序服务器,通用界面和配置 + * `applications`: 核心应用程序 + * `addons`: 第三方扩展 + * `themes`: 修改界面外观 + * `hot-deploy`: 你自己的组件 + +除了一些配置,你将在 `hot-deploy` 和 `themes` 目录中进行开发。 + +### 在线商店定制 + +要真正使系统成为你自己的系统,请开始考虑使用[组件][7]。组件是一种模块化方法,可以覆盖、扩展和添加到系统中。你可以将组件视为独立 Web 模块,可以捕获有关数据库([实体][8])、功能([服务][9])、界面([视图][10])、[事件和操作][11]和 Web 应用程序等的信息。由于组件功能,你可以添加自己的代码,同时保持与原始源兼容。 + +运行命令 `./ant create-component-shop-override` 并按照步骤创建你的在线商店组件。该操作将会在 `hot-deploy` 目录内创建一个新目录,该目录将扩展并覆盖原始的电子商务应用程序。 + +![组件目录结构][13] + +*一个典型的组件目录结构。* + +你的组件将具有以下目录结构: + + * `config`: 配置 + * `data`: 种子数据 + * `entitydef`: 数据库表定义 + * `script`: Groovy 脚本的位置 + * `servicedef`: 服务定义 + * `src`: Java 类 + * `webapp`: 你的 web 应用程序 + * `widget`: 界面定义 + +此外,`ivy.xml` 文件允许你将 Maven 库添加到构建过程中,`ofbiz-component.xml` 文件定义整个组件和 Web 应用程序结构。除了一些在当前目录所能够看到的,你还可以在 Web 应用程序的 `WEB-INF` 目录中找到 `controller.xml` 文件。这允许你定义请求实体并将它们连接到事件和界面。仅对于界面来说,你还可以使用内置的 CMS 功能,但优先要坚持使用核心机制。在引入更改之前,请熟悉 `/applications/shop/`。 + +#### 添加自定义界面 + +还记得[模板工具包][3]吗?你会发现它在每个界面都有使用到。你可以将其视为一组易于学习的宏,它用来构建所有内容。下面是一个例子: + +``` +<@section title="Title"> +    <@heading id="slider">Slider +    <@row> +        <@cell columns=6> +            <@slider id="" class="" controls=true indicator=true> +                <@slide link="#" image="https://placehold.it/800x300">Just some content… +                <@slide title="This is a title" link="#" image="https://placehold.it/800x300"> +            +        +        <@cell columns=6>Second column +    + +``` + +不是很难,对吧?同时,主题包含 HTML 定义和样式。这将权力交给你的前端开发人员,他们可以定义每个宏的输出,并坚持使用自己的构建工具进行开发。 + +我们快点试试吧。首先,在你自己的在线商店上定义一个请求。你将修改此代码。一个内置的 CMS 系统也可以通过 进行访问,它允许你以更有效的方式创建新模板和界面。它与模板工具包完全兼容,并附带可根据你的喜好采用的示例模板。但是既然我们试图在这里理解系统,那么首先让我们采用更复杂的方法。 + +打开你商店 `webapp` 目录中的 [controller.xml][14] 文件。控制器会跟踪请求事件并相应地执行操作。下面的操作将会在 `/shop/test` 下创建一个新的请求: + +``` + + +      +      + +``` + +你可以定义多个响应,如果需要,可以在请求中使用事件或服务调用来确定你可能要使用的响应。我选择了“视图”类型的响应。视图是渲染的响应;其他类型是请求重定向、转发等。系统附带各种渲染器,可让你稍后确定输出;为此,请添加以下内容: + +``` + + +``` + +用你自己的组件名称替换 `my-component`。然后,你可以通过在 `widget/CommonScreens.xml` 文件的标签内添加以下内容来定义你的第一个界面: + +``` + +       
+            +            +            +                +                    +                        +                    +                +            +       
+   
+``` + +商店界面实际上非常模块化,由多个元素组成([小部件、动作和装饰器][15])。为简单起见,请暂时保留原样,并通过添加第一个模板工具包文件来完成新网页。为此,创建一个新的 `webapp/mycomponent/test/test.ftl` 文件并添加以下内容: + +``` +<@alert type="info">Success! +``` + +![自定义的界面][17] + +*一个自定义的界面。* + +打开 并惊叹于你自己的成就。 + +#### 自定义主题 + +通过创建自己的主题来修改商店的界面外观。所有主题都可以作为组件在 `themes` 文件夹中找到。运行命令 `./ant create-theme` 来创建你自己的主题。 + +![主题组件布局][19] + +*一个典型的主题组件布局。* + +以下是最重要的目录和文件列表: + + * 主题配置:`data/*ThemeData.xml` + * 特定主题封装的 HTML:`includes/*.ftl` + * 模板工具包 HTML 定义:`includes/themeTemplate.ftl` + * CSS 类定义:`includes/themeStyles.ftl` + * CSS 框架: `webapp/theme-title/` + +快速浏览工具包中的 Metro 主题;它使用 Foundation CSS 框架并且充分利用了这个框架。然后,然后,在新构建的 `webapp/theme-title` 目录中设置自己的主题并开始开发。Foundation-shop 主题是一个非常简单的特定于商店的主题实现,你可以将其用作你自己工作的基础。 + +瞧!你已经建立了自己的在线商店,准备个性化定制吧! + +![搭建完成的 Scipio ERP 在线商店][21] + +*一个搭建完成的基于 Scipio ERP的在线商店。* + +### 接下来是什么? + +Scipio ERP 是一个功能强大的框架,可简化复杂的电子商务应用程序的开发。为了更完整的理解,请查看项目[文档][7],尝试[在线演示][22],或者[加入社区][23]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/scipio-erp + +作者:[Paul Piper][a] +选题:[lujun9972][b] +译者:[laingke](https://github.com/laingke) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/madppiper +[b]: https://github.com/lujun9972 +[1]: https://www.scipioerp.com +[2]: https://ofbiz.apache.org/ +[3]: https://www.scipioerp.com/community/developer/freemarker-macros/ +[4]: https://www.scipioerp.com/community/developer/installation-configuration/configuration/#database-configuration +[5]: /file/419711 +[6]: https://opensource.com/sites/default/files/uploads/setup_step5_sm.jpg (Setup wizard) +[7]: https://www.scipioerp.com/community/developer/architecture/components/ +[8]: https://www.scipioerp.com/community/developer/entities/ +[9]: https://www.scipioerp.com/community/developer/services/ +[10]: https://www.scipioerp.com/community/developer/views-requests/ +[11]: https://www.scipioerp.com/community/developer/events-actions/ +[12]: /file/419716 +[13]: https://opensource.com/sites/default/files/uploads/component_structure.jpg (component directory structure) +[14]: https://www.scipioerp.com/community/developer/views-requests/request-controller/ +[15]: https://www.scipioerp.com/community/developer/views-requests/screen-widgets-decorators/ +[16]: /file/419721 +[17]: https://opensource.com/sites/default/files/uploads/success_screen_sm.jpg (Custom screen) +[18]: /file/419726 +[19]: https://opensource.com/sites/default/files/uploads/theme_structure.jpg (theme component layout) +[20]: /file/419731 +[21]: https://opensource.com/sites/default/files/uploads/finished_shop_1_sm.jpg (Finished Scipio ERP shop) +[22]: https://www.scipioerp.com/demo/ +[23]: https://forum.scipioerp.com/ diff --git a/published/20190401 Build and host a website with Git.md b/published/20190401 Build and host a website with Git.md new file mode 100644 index 0000000000..fd3b19a04f --- /dev/null +++ b/published/20190401 Build and host a website with Git.md @@ -0,0 +1,223 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11303-1.html) +[#]: subject: (Build and host a website with Git) +[#]: via: (https://opensource.com/article/19/4/building-hosting-website-git) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +用 Git 建立和托管网站 +====== + +> 你可以让 Git 帮助你轻松发布你的网站。在我们《鲜为人知的 Git 用法》系列的第一篇文章中学习如何做到。 + +![](https://img.linux.net.cn/data/attachment/album/201909/04/134312l912496eegpoqaqe.png) + +[Git][2] 是一个少有的能将如此多的现代计算封装到一个程序之中的应用程序,它可以用作许多其他应用程序的计算引擎。虽然它以跟踪软件开发中的源代码更改而闻名,但它还有许多其他用途,可以让你的生活更轻松、更有条理。在这个 Git 系列中,我们将分享七种鲜为人知的使用 Git 的方法。 + +创建一个网站曾经是极其简单的,而同时它又是一种黑魔法。回到 Web 1.0 的旧时代(不是每个人都会这样称呼它),你可以打开任何网站,查看其源代码,并对 HTML 及其内联样式和基于表格的布局进行反向工程,在这样的一两个下午之后,你就会感觉自己像一个程序员一样。不过要让你创建的页面放到互联网上,仍然有一些问题,因为这意味着你需要处理服务器、FTP 以及 webroot 目录和文件权限。虽然从那时起,现代网站变得愈加复杂,但如果你让 Git 帮助你,自出版可以同样容易(或更容易!)。 + +### 用 Hugo 创建一个网站 + +[Hugo][3] 是一个开源的静态站点生成器。静态网站是过去的 Web 的基础(如果你回溯到很久以前,那就是 Web 的*全部*了)。静态站点有几个优点:它们相对容易编写,因为你不必编写代码;它们相对安全,因为页面上没有执行代码;并且它们可以非常快,因为除了在页面上传输的任何内容之外没有任何处理。 + +Hugo 并不是唯一一个静态站点生成器。[Grav][4]、[Pico][5]、[Jekyll][6]、[Podwrite][7] 以及许多其他的同类软件都提供了一种创建一个功能最少的、只需要很少维护的网站的简单方法。Hugo 恰好是内置集成了 GitLab 集成的一个静态站点生成器,这意味着你可以使用免费的 GitLab 帐户生成和托管你的网站。 + +Hugo 也有一些非常大的用户。例如,如果你曾经去过 [Let's Encrypt](https://letsencrypt.org/) 网站,那么你已经用过了一个用 Hugo 构建的网站。 + +![Let's Encrypt website][8] + +#### 安装 Hugo + +Hugo 是跨平台的,你可以在 [Hugo 的入门资源][9]中找到适用于 MacOS、Windows、Linux、OpenBSD 和 FreeBSD 的安装说明。 + +如果你使用的是 Linux 或 BSD,最简单的方法是从软件存储库或 ports 树安装 Hugo。确切的命令取决于你的发行版,但在 Fedora 上,你应该输入: + +``` +$ sudo dnf install hugo +``` + +通过打开终端并键入以下内容确认你已正确安装: + +``` +$ hugo help +``` + +这将打印 `hugo` 命令的所有可用选项。如果你没有看到,你可能没有正确安装 Hugo 或需要[将该命令添加到你的路径][10]。 + +#### 创建你的站点 + +要构建 Hugo 站点,你必须有个特定的目录结构,通过输入以下命令 Hugo 将为你生成它: + +``` +$ hugo new site mysite +``` + +你现在有了一个名为 `mysite` 的目录,它包含构建 Hugo 网站所需的默认目录。 + +Git 是你将网站放到互联网上的接口,因此切换到你新的 `mysite` 文件夹,并将其初始化为 Git 存储库: + +``` +$ cd mysite +$ git init . +``` + +Hugo 与 Git 配合的很好,所以你甚至可以使用 Git 为你的网站安装主题。除非你计划开发你正在安装的主题,否则可以使用 `--depth` 选项克隆该主题的源的最新状态: + +``` +$ git clone --depth 1 https://github.com/darshanbaral/mero.git themes/mero +``` + +现在为你的网站创建一些内容: + +``` +$ hugo new posts/hello.md +``` + +使用你喜欢的文本编辑器编辑 `content/posts` 目录中的 `hello.md` 文件。Hugo 接受 Markdown 文件,并会在发布时将它们转换为经过主题化的 HTML 文件,因此你的内容必须采用 [Markdown 格式][11]。 + +如果要在帖子中包含图像,请在 `static` 目录中创建一个名为 `images` 的文件夹。将图像放入此文件夹,并使用以 `/images` 开头的绝对路径在标记中引用它们。例如: + +``` +![A picture of a thing](/images/thing.jpeg) +``` + +#### 选择主题 + +你可以在 [themes.gohugo.io][12] 找到更多主题,但最好在测试时保持一个基本主题。标准的 Hugo 测试主题是 [Ananke][13]。某些主题具有复杂的依赖关系,而另外一些主题如果没有复杂的配置的话,也许不会以你预期的方式呈现页面。本例中使用的 Mero 主题捆绑了一个详细的 `config.toml` 配置文件,但是(为了简单起见)我将在这里只提供基本的配置。在文本编辑器中打开名为 `config.toml` 的文件,并添加三个配置参数: + +``` +languageCode = "en-us" +title = "My website on the web" +theme = "mero" + +[params] + author = "Seth Kenlon" + description = "My hugo demo" +``` + +#### 预览 + +在你准备发布之前不必(预先)在互联网上放置任何内容。在你开发网站时,你可以通过启动 Hugo 附带的仅限本地访问的 Web 服务器来预览你的站点。 + +``` +$ hugo server --buildDrafts --disableFastRender +``` + +打开 Web 浏览器并导航到 以查看正在进行的工作。 + +### 用 Git 发布到 GitLab + +要在 GitLab 上发布和托管你的站点,请为你的站点内容创建一个存储库。 + +要在 GitLab 中创建存储库,请单击 GitLab 的 “Projects” 页面中的 “New Project” 按钮。创建一个名为 `yourGitLabUsername.gitlab.io` 的空存储库,用你的 GitLab 用户名或组名替换 `yourGitLabUsername`。你必须使用此命名方式作为该项目的名称。你也可以稍后为其添加自定义域。 + +不要在 GitLab 上包含许可证或 README 文件(因为你已经在本地启动了一个项目,现在添加这些文件会使将你的数据推向 GitLab 时更加复杂,以后你可以随时添加它们)。 + +在 GitLab 上创建空存储库后,将其添加为 Hugo 站点的本地副本的远程位置,该站点已经是一个 Git 存储库: + +``` +$ git remote add origin git@gitlab.com:skenlon/mysite.git +``` + +创建名为 `.gitlab-ci.yml` 的 GitLab 站点配置文件并输入以下选项: + +``` +image: monachus/hugo + +variables: + GIT_SUBMODULE_STRATEGY: recursive + +pages: + script: + - hugo + artifacts: + paths: + - public + only: + - master +``` + +`image` 参数定义了一个为你的站点提供服务的容器化图像。其他参数是告诉 GitLab 服务器在将新代码推送到远程存储库时要执行的操作的说明。有关 GitLab 的 CI/CD(持续集成和交付)选项的更多信息,请参阅 [GitLab 文档的 CI/CD 部分][14]。 + +#### 设置排除的内容 + +你的 Git 存储库已配置好,在 GitLab 服务器上构建站点的命令也已设置,你的站点已准备好发布了。对于你的第一个 Git 提交,你必须采取一些额外的预防措施,以便你不会对你不打算进行版本控制的文件进行版本控制。 + +首先,将构建你的站点时 Hugo 创建的 `/public` 目录添加到 `.gitignore` 文件。你无需在 Git 中管理已完成发布的站点;你需要跟踪的是你的 Hugo 源文件。 + +``` +$ echo "/public" >> .gitignore +``` + +如果不创建 Git 子模块,则无法在 Git 存储库中维护另一个 Git 存储库。为了简单起见,请移除嵌入的存储库的 `.git` 目录,以使主题(存储库)只是一个主题(目录)。 + +请注意,你**必须**将你的主题文件添加到你的 Git 存储库,以便 GitLab 可以访问该主题。如果不提交主题文件,你的网站将无法成功构建。 + +``` +$ mv themes/mero/.git ~/.local/share/Trash/files/ +``` + +你也可以像使用[回收站][15]一样使用 `trash`: + +``` +$ trash themes/mero/.git +``` + +现在,你可以将本地项目目录的所有内容添加到 Git 并将其推送到 GitLab: + +``` +$ git add . +$ git commit -m 'hugo init' +$ git push -u origin HEAD +``` + +### 用 GitLab 上线 + +将代码推送到 GitLab 后,请查看你的项目页面。有个图标表示 GitLab 正在处理你的构建。第一次推送代码可能需要几分钟,所以请耐心等待。但是,请不要**一直**等待,因为该图标并不总是可靠地更新。 + +![GitLab processing your build][16] + +当你在等待 GitLab 组装你的站点时,请转到你的项目设置并找到 “Pages” 面板。你的网站准备就绪后,它的 URL 就可以用了。该 URL 是 `yourGitLabUsername.gitlab.io/yourProjectName`。导航到该地址以查看你的劳动成果。 + +![Previewing Hugo site][17] + +如果你的站点无法正确组装,GitLab 提供了可以深入了解 CI/CD 管道的日志。查看错误消息以找出发生了什么问题。 + +### Git 和 Web + +Hugo(或 Jekyll 等类似工具)只是利用 Git 作为 Web 发布工具的一种方式。使用服务器端 Git 挂钩,你可以使用最少的脚本设计你自己的 Git-to-web 工作流。使用 GitLab 的社区版,你可以自行托管你自己的 GitLab 实例;或者你可以使用 [Gitolite][18] 或 [Gitea][19] 等替代方案,并使用本文作为自定义解决方案的灵感来源。祝你玩得开心! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/building-hosting-website-git + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh (web development and design, desktop and browser) +[2]: https://git-scm.com/ +[3]: http://gohugo.io +[4]: http://getgrav.org +[5]: http://picocms.org/ +[6]: https://jekyllrb.com +[7]: http://slackermedia.info/podwrite/ +[8]: https://opensource.com/sites/default/files/uploads/letsencrypt-site.jpg (Let's Encrypt website) +[9]: https://gohugo.io/getting-started/installing +[10]: https://opensource.com/article/17/6/set-path-linux +[11]: https://commonmark.org/help/ +[12]: https://themes.gohugo.io/ +[13]: https://themes.gohugo.io/gohugo-theme-ananke/ +[14]: https://docs.gitlab.com/ee/ci/#overview +[15]: http://slackermedia.info/trashy +[16]: https://opensource.com/sites/default/files/uploads/hugo-gitlab-cicd.jpg (GitLab processing your build) +[17]: https://opensource.com/sites/default/files/uploads/hugo-demo-site.jpg (Previewing Hugo site) +[18]: http://gitolite.com +[19]: http://gitea.io diff --git a/published/20190402 Manage your daily schedule with Git.md b/published/20190402 Manage your daily schedule with Git.md new file mode 100644 index 0000000000..88ae47f664 --- /dev/null +++ b/published/20190402 Manage your daily schedule with Git.md @@ -0,0 +1,244 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11320-1.html) +[#]: subject: (Manage your daily schedule with Git) +[#]: via: (https://opensource.com/article/19/4/calendar-git) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +用 Git 管理你的每日行程 +====== + +> 像源代码一样对待时间并在 Git 的帮助下维护你的日历。 + +![](https://img.linux.net.cn/data/attachment/album/201909/09/061835la7ne9edtlr7kn18.png) + +[Git][2] 是一个少有的能将如此多的现代计算封装到一个程序之中的应用程序,它可以用作许多其他应用程序的计算引擎。虽然它以跟踪软件开发中的源代码更改而闻名,但它还有许多其他用途,可以让你的生活更轻松、更有条理。在这个 Git 系列中,我们将分享七种鲜为人知的使用 Git 的方法。 + +今天,我们将使用 Git 来跟踪你的日历。 + +### 使用 Git 跟踪你的日程安排 + +如果时间本身只是可以管理和版本控制的源代码呢?虽然证明或反驳这种理论可能超出了本文的范围,但在 Git 的帮助下,你可以将时间视为源代码并管理你的日程安排。 + +日历的卫冕冠军是 [CalDAV][3] 协议,它支撑了如 [NextCloud][4] 这样的流行的开源及闭源的日历应用程序。CalDAV 没什么问题(评论者,请注意),但它并不适合所有人,除此之外,它还有一种不同于单一文化的鼓舞人心的东西。 + +因为我对大量使用 GUI 的 CalDAV 客户端没有兴趣(如果你正在寻找一个好的终端 CalDAV 查看器,请参阅 [khal][5]),我开始研究基于文本的替代方案。基于文本的日历具有在[明文][6]中工作的所有常见好处。它很轻巧,非常便携,只要它结构化,就很容易解析和美化(无论*美丽*对你意味着什么)。 + +最重要的是,它正是 Git 旨在管理的内容。 + +### Org 模式不是一种可怕的方式 + +如果你没有对你的明文添加结构,它很快就会陷入一种天马行空般的混乱,变成恶魔才能懂的符号。幸运的是,有一种用于日历的标记语法,它包含在令人尊敬的生产力 Emacs 模式 —— [Org 模式][7] 中(承认吧,你其实一直想开始使用它)。 + +许多人没有意识到 Org 模式的惊人之处在于[你不需要知道甚至不需要使用 Emacs][8]来利用 Org 模式建立的约定。如果你使用 Emacs,你会得到许多很棒的功能,但是如果 Emacs 对你来说太难了,那么你可以实现一个基于 Git 的 Org 模式的日历系统,而不需要安装 Emacs。 + +关于 Org 模式你唯一需要知道的部分是它的语法。Org 模式的语法维护成本低、直观。使用 Org 模式而不是 GUI 日历应用程序进行日历记录的最大区别在于工作流程:你可以创建一个任务列表,然后每天分配一个任务,而不是转到日历并查找要安排任务的日期。 + +组织模式中的列表使用星号(`*`)作为项目符号。这是我的游戏任务列表: + +``` +* Gaming +** Build Stardrifter character +** Read Stardrifter rules +** Stardrifter playtest + +** Blue Planet @ Mike's + +** Run Rappan Athuk +*** Purchase hard copy +*** Skim Rappan Athuk +*** Build Rappan Athuk maps in maptool +*** Sort Rappan Athuk tokens +``` + +如果你熟悉 [CommonMark][9] 或 Markdown,你会注意到,Org 模式不是使用空格来创建子任务,而是更明确地使用了其它项目符号。无论你的使用背景和列表是什么,这都是一种构建列表的直观且简单的方法,它显然与 Emacs 没有内在联系(尽管使用 Emacs 为你提供了快捷方式,因此你可以快速地重新排列列表)。 + +要将列表转换为日历中的计划任务或事件,请返回并添加关键字 `SCHEDULED` 和(可选)`:CATEGORY:`。 + +``` +* Gaming +:CATEGORY: Game +** Build Stardrifter character +SCHEDULED: <2019-03-22 18:00-19:00> +** Read Stardrifter rules +SCHEDULED: <2019-03-22 19:00-21:00> +** Stardrifter playtest +SCHEDULED: <2019-03-25 0900-1300> +** Blue Planet @ Mike's +SCHEDULED: <2019-03-18 18:00-23:00 +1w> + +and so on... +``` + +`SCHEDULED` 关键字将该条目标记为你希望收到通知的事件,并且可选的 `:CATEGORY:` 关键字是一个可供你自己使用的任意标记系统(在 Emacs 中,你可以根据类别对条目使用颜色代码)。 + +对于重复事件,你可以使用符号(如`+1w`)创建每周事件或 `+2w` 以进行每两周一次的事件,依此类推。 + +所有可用于 Org 模式的花哨标记都[记录于文档][10],所以不要犹豫,找到更多技巧来让它满足你的需求。 + +### 放进 Git + +如果没有 Git,你的 Org 模式的日程安排只不过是本地计算机上的文件。这是 21 世纪,所以你至少需要可以在手机上使用你的日历,即便不是在你所有的个人电脑上。你可以使用 Git 为自己和他人发布日历。 + +首先,为 `.org` 文件创建一个目录。我将我的存储在 `~/cal` 中。 + +``` +$ mkdir ~/cal +``` + +转到你的目录并使其成为 Git 存储库: + +``` +$ cd cal +$ git init +``` + +将 `.org` 文件移动到你本地的 Git 存储库。在实践中,我为每个类别维护一个 `.org` 文件。 + +``` +$ mv ~/*.org ~/cal +$ ls +Game.org Meal.org Seth.org Work.org +``` + +暂存并提交你的文件: + +``` +$ git add *.org +$ git commit -m 'cal init' +``` + +### 创建一个 Git 远程源 + +要在任何地方提供日历,你必须在互联网上拥有 Git 存储库。你的日历是纯文本,因此任何 Git 存储库都可以。你可以将日历放在 [GitLab][11] 或任何其他公共 Git 托管服务(甚至是专有服务)上,只要你的主机允许,你甚至可以将该存储库标记为私有库。如果你不想将日历发布到你无法控制的服务器,则可以自行托管 Git 存储库,或者为单个用户使用裸存储库,或者使用 [Gitolite][12] 或 [Gitea][13] 等前端服务。 + +为了简单起见,我将假设一个自托管的 Git 裸存储库。你可以使用 Git 命令在任何具有 SSH 访问权限的服务器上创建一个远程裸存储库: + +``` +$ ssh -p 22122 [seth@example.com][14] +[remote]$ mkdir cal.git +[remote]$ cd cal.git +[remote]$ git init --bare +[remote]$ exit +``` + +这个裸存储库可以作为你日历在互联网上的家。 + +将其设置为本地 Git 存储库(在你的计算机上,而不是你的服务器上)的远程源: + +``` +$ git remote add origin seth@example.com:/home/seth/cal.git +``` + +然后推送你的日历到该服务器: + +``` +$ git push -u origin HEAD +``` + +将你的日历放在 Git 存储库中,就可以在任何运行 Git 的设备上使用它。这意味着你可以对计划进行更新和更改,并将更改推送到上游,以便在任何地方进行更新。 + +我使用这种方法使我的日历在我的工作笔记本电脑和家庭工作站之间保持同步。由于我每天大部分时间都在使用 Emacs,因此能够在 Emacs 中查看和编辑我的日历是一个很大的便利。对于大多数使用移动设备的人来说也是如此,因此下一步是在移动设备上设置 Org 模式的日历系统。 + +### 移动设备上的 Git + +由于你的日历数据是纯文本的,严格来说,你可以在任何可以读取文本文件的设备上“使用”它。这是这个系统之美的一部分;你永远不会缺少原始数据。但是,要按照你希望的现代日历的工作方式将日历集成到移动设备上,你需要两个组件:移动设备上的 Git 客户端和 Org 模式查看器。 + +#### 移动设备上的 Git 客户端 + +[MGit][15] 是 Android 上的优秀 Git 客户端。同样,iOS 也有 Git 客户端。 + +一旦安装了 MGit(或类似的 Git 客户端),你必须克隆日历存储库,以便在你的手机上有副本。要从移动设备访问服务器,必须设置 SSH 密钥进行身份验证。MGit 可以为你生成和存储密钥,你必须将其添加到服务器的 `~/.ssh/authorized_keys` 文件或托管的 Git 的帐户设置中的 SSH 密钥中。 + +你必须手动执行此操作。MGit 没有登录你的服务器或托管的 Git 帐户的界面。如果你不这样做,你的移动设备将无法访问你的服务器以访问你的日历数据。 + +我是通过将我在 MGit 中生成的密钥文件通过 [KDE Connect][16] 复制到我的笔记本电脑来实现的(但你可以通过蓝牙、SD 卡读卡器或 USB 电缆进行相同操作,具体取决于你访问手机上的数据的首选方法)。 我用这个命令将密钥(一个名为 `calkey` 的文件)复制到我的服务器: + +``` +$ cat calkey | ssh seth@example.com "cat >> /home/seth/.ssh/authorized_keys" +``` + +你可能有不同的方法,但如果你曾经将服务器设置为无密码登录,这是完全相同的过程。如果你使用的是 GitLab 等托管的 Git 服务,则必须将密钥文件的内容复制并粘贴到用户帐户的 SSH 密钥面板中。 + +![Adding key file data to GitLab][17] + +完成后,你的移动设备可以向你的服务器授权,但仍需要知道在哪里查找你的日历数据。不同的应用程序可能使用不同的表示法,但 MGit 使用普通的旧式 Git-over-SSH。这意味着如果你使用的是非标准 SSH 端口,则必须指定要使用的 SSH 端口: + +``` +$ git clone ssh://seth@example.com:22122//home/seth/git/cal.git +``` + +![Specifying SSH port in MGit][18] + +如果你使用其他应用程序,它可能会使用不同的语法,允许你在特殊字段中提供端口,或删除 `ssh://` 前缀。如果遇到问题,请参阅应用程序文档。 + +将存储库克隆到手机。 + +![Cloned repositories][19] + +很少有 Git 应用程序设置为自动更新存储库。有一些应用程序可以用来自动拉取,或者你可以设置 Git 钩子来推送服务器的更新 —— 但我不会在这里讨论这些。目前,在对日历进行更新后,请务必在 MGit 中手动提取新更改(或者如果在手机上更改了事件,请将更改推送到服务器)。 + +![MGit push/pull settings][20] + +#### 移动设备上的日历 + +有一些应用程序可以为移动设备上的 Org 模式提供前端。[Orgzly][21] 是一个很棒的开源 Android 应用程序,它为 Org 模式的从 Agenda 模式到 TODO 列表的大多数功能提供了一个界面。安装并启动它。 + +从主菜单中,选择“设置同步存储库”,然后选择包含日历文件的目录(即,从服务器克隆的 Git 存储库)。 + +给 Orgzly 一点时间来导入数据,然后使用 Orgzly 的[汉堡包][22]菜单选择日程视图。 + +![Orgzly's agenda view][23] + +在 Orgzly 的“设置提醒”菜单中,你可以选择在手机上触发通知的事件类型。你可以获得 `SCHEDULED` 任务,`DEADLINE` 任务或任何分配了事件时间的任何通知。如果你将手机用作任务管理器,那么你将永远不会错过 Org 模式和 Orgzly 的活动。 + +![Orgzly notification][24] + +Orgzly 不仅仅是一个解析器。你可以编辑和更新事件,甚至标记事件为 `DONE`。 + +![Orgzly to-do list][25] + +### 专为你而设计 + +关于使用 Org 模式和 Git 的重要一点是,这两个应用程序都非常灵活,并且你可以自定义它们的工作方式和内容,以便它们能够适应你的需求。如果本文中的内容是对你如何组织生活或管理每周时间表的冒犯,但你喜欢此提案提供的其他部分,那么请丢弃你不喜欢的部分。如果需要,你可以在 Emacs 中使用 Org 模式,或者你可以将其用作日历标记。你可以将手机设置为在一天结束时从计算机上拉取 Git 数据,而不是从互联网上的服务器上,或者你可以将计算机配置为在手机插入时同步日历,或者你可以每天管理它,就像你把你工作日所需的所有东西都装到你的手机上一样。这取决于你,而这是关于 Git、Org 模式和开源的最重要的事情。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/calendar-git + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web-design-monitor-website.png?itok=yUK7_qR0 (website design image) +[2]: https://git-scm.com/ +[3]: https://tools.ietf.org/html/rfc4791 +[4]: http://nextcloud.com +[5]: https://github.com/pimutils/khal +[6]: https://plaintextproject.online/ +[7]: https://orgmode.org +[8]: https://opensource.com/article/19/1/productivity-tool-org-mode +[9]: https://commonmark.org/ +[10]: https://orgmode.org/manual/ +[11]: http://gitlab.com +[12]: http://gitolite.com/gitolite/index.html +[13]: https://gitea.io/en-us/ +[14]: mailto:seth@example.com +[15]: https://f-droid.org/en/packages/com.manichord.mgit +[16]: https://community.kde.org/KDEConnect +[17]: https://opensource.com/sites/default/files/uploads/gitlab-add-key.jpg (Adding key file data to GitLab) +[18]: https://opensource.com/sites/default/files/uploads/mgit-0.jpg (Specifying SSH port in MGit) +[19]: https://opensource.com/sites/default/files/uploads/mgit-1.jpg (Cloned repositories) +[20]: https://opensource.com/sites/default/files/uploads/mgit-2.jpg (MGit push/pull settings) +[21]: https://f-droid.org/en/packages/com.orgzly/ +[22]: https://en.wikipedia.org/wiki/Hamburger_button +[23]: https://opensource.com/sites/default/files/uploads/orgzly-agenda.jpg (Orgzly's agenda view) +[24]: https://opensource.com/sites/default/files/uploads/orgzly-cal-notify.jpg (Orgzly notification) +[25]: https://opensource.com/sites/default/files/uploads/orgzly-cal-todo.jpg (Orgzly to-do list) diff --git a/published/20190403 Use Git as the backend for chat.md b/published/20190403 Use Git as the backend for chat.md new file mode 100644 index 0000000000..100750937b --- /dev/null +++ b/published/20190403 Use Git as the backend for chat.md @@ -0,0 +1,144 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11342-1.html) +[#]: subject: (Use Git as the backend for chat) +[#]: via: (https://opensource.com/article/19/4/git-based-chat) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +用 Git 作为聊天应用的后端 +====== + +> GIC 是一个聊天应用程序的原型,展示了一种使用 Git 的新方法。 + +![](https://img.linux.net.cn/data/attachment/album/201909/15/100905euzi3l5xgslsgx7i.png) + +[Git][2] 是一个少有的能将如此多的现代计算封装到一个程序之中的应用程序,它可以用作许多其他应用程序的计算引擎。虽然它以跟踪软件开发中的源代码更改而闻名,但它还有许多其他用途,可以让你的生活更轻松、更有条理。在这个 Git 系列中,我们将分享七种鲜为人知的使用 Git 的方法。 + +今天我们来看看 GIC,它是一个基于 Git 的聊天应用。 + +### 初识 GIC + +虽然 Git 的作者们可能期望会为 Git 创建前端,但毫无疑问他们从未预料到 Git 会成为某种后端,如聊天客户端的后端。然而,这正是开发人员 Ephi Gabay 用他的实验性的概念验证应用 [GIC][3] 所做的事情:用 [Node.js][4] 编写的聊天客户端,使用 Git 作为其后端数据库。 + +GIC 并没有打算用于生产用途。这纯粹是一种编程练习,但它证明了开源技术的灵活性。令人惊讶的是,除了 Node 库和 Git 本身,该客户端只包含 300 行代码。这是这个聊天客户端和开源所反映出来的最好的地方之一:建立在现有工作基础上的能力。眼见为实,你应该自己亲自来了解一下 GIC。 + +### 架设起来 + +GIC 使用 Git 作为引擎,因此你需要一个空的 Git 存储库为聊天室和记录器提供服务。存储库可以托管在任何地方,只要你和需要访问聊天服务的人可以访问该存储库就行。例如,你可以在 GitLab 等免费 Git 托管服务上设置 Git 存储库,并授予聊天用户对该 Git 存储库的贡献者访问权限。(他们必须能够提交到存储库,因为每个聊天消息都是一个文本的提交。) + +如果你自己托管,请创建一个中心化的裸存储库。聊天中的每个用户必须在裸存储库所在的服务器上拥有一个帐户。你可以使用如 [Gitolite][5] 或 [Gitea][6] 这样的 Git 托管软件创建特定于 Git 的帐户,或者你可以在服务器上为他们提供个人用户帐户,可以使用 `git-shell` 来限制他们只能访问 Git。 + +自托管实例的性能最好。无论你是自己托管还是使用托管服务,你创建的 Git 存储库都必须具有一个活跃分支,否则 GIC 将无法在用户聊天时进行提交,因为没有 Git HEAD。确保分支初始化和活跃的最简单方法是在创建存储库时提交 `README` 或许可证文件。如果你没有这样做,你可以在事后创建并提交一个: + +``` +$ echo "chat logs" > README +$ git add README +$ git commit -m 'just creating a HEAD ref' +$ git push -u origin HEAD +``` + +### 安装 GIC + +由于 GIC 基于 Git 并使用 Node.js 编写,因此必须首先安装 Git、Node.js 和 Node 包管理器npm(它应该与 Node 捆绑在一起)。安装它们的命令因 Linux 或 BSD 发行版而异,这是 Fedora 上的一个示例命令: + +``` +$ sudo dnf install git nodejs +``` + +如果你没有运行 Linux 或 BSD,请按照 [git-scm.com][7] 和 [nodejs.org][8] 上的安装说明进行操作。 + +因此,GIC 没有安装过程。每个用户(在此示例中为 Alice 和 Bob)必须将存储库克隆到其硬盘驱动器: + +``` +$ git clone https://github.com/ephigabay/GIC GIC +``` + +将目录更改为 GIC 目录并使用 `npm` 安装 Node.js 依赖项: + +``` +$ cd GIC +$ npm install +``` + +等待 Node 模块下载并安装。 + +### 配置 GIC + +GIC 唯一需要的配置是 Git 聊天存储库的位置。编辑 `config.js` 文件: + +``` +module.exports = { + gitRepo: 'seth@example.com:/home/gitchat/chatdemo.git', + messageCheckInterval: 500, + branchesCheckInterval: 5000 +}; +``` + +在尝试 GIC 之前测试你与 Git 存储库的连接,以确保你的配置是正确的: + +``` +$ git clone --quiet seth@example.com:/home/gitchat/chatdemo.git > /dev/null +``` + +假设你没有收到任何错误,就可以开始聊天了。 + +### 用 Git 聊天 + +在 GIC 目录中启动聊天客户端: + +``` +$ npm start +``` + +客户端首次启动时,必须克隆聊天存储库。由于它几乎是一个空的存储库,因此不会花费很长时间。输入你的消息,然后按回车键发送消息。 + +![GIC][10] + +*基于 Git 的聊天客户端。 他们接下来会怎么想?* + +正如问候消息所说,Git 中的分支在 GIC 中就是聊天室或频道。无法在 GIC 的 UI 中创建新分支,但如果你在另一个终端会话或 Web UI 中创建一个分支,它将立即显示在 GIC 中。将一些 IRC 式的命令加到 GIC 中并不需要太多工作。 + +聊了一会儿之后,可以看看你的 Git 存储库。由于聊天发生在 Git 中,因此存储库本身也是聊天日志: + +``` +$ git log --pretty=format:"%p %cn %s" +4387984 Seth Kenlon Hey Chani, did you submit a talk for All Things Open this year? +36369bb Chani No I didn't get a chance. Did you? +[...] +``` + +### 退出 GIC + +Vim 以来,还没有一个应用程序像 GIC 那么难以退出。你看,没有办法停止 GIC。它会一直运行,直到它被杀死。当你准备停止 GIC 时,打开另一个终端选项卡或窗口并发出以下命令: + +``` +$ kill `pgrep npm` +``` + +GIC 是一个新奇的事物。这是一个很好的例子,说明开源生态系统如何鼓励和促进创造力和探索,并挑战我们从不同角度审视应用程序。尝试下 GIC,也许它会给你一些思路。至少,它可以让你与 Git 度过一个下午。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/git-based-chat + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/talk_chat_team_mobile_desktop.png?itok=d7sRtKfQ (Team communication, chat) +[2]: https://git-scm.com/ +[3]: https://github.com/ephigabay/GIC +[4]: https://nodejs.org/en/ +[5]: http://gitolite.com +[6]: http://gitea.io +[7]: http://git-scm.com +[8]: http://nodejs.org +[9]: mailto:seth@example.com +[10]: https://opensource.com/sites/default/files/uploads/gic.jpg (GIC) diff --git a/published/20190408 A beginner-s guide to building DevOps pipelines with open source tools.md b/published/20190408 A beginner-s guide to building DevOps pipelines with open source tools.md new file mode 100644 index 0000000000..bbd85a891f --- /dev/null +++ b/published/20190408 A beginner-s guide to building DevOps pipelines with open source tools.md @@ -0,0 +1,345 @@ +[#]: collector: (lujun9972) +[#]: translator: (LuuMing) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11307-1.html) +[#]: subject: (A beginner's guide to building DevOps pipelines with open source tools) +[#]: via: (https://opensource.com/article/19/4/devops-pipeline) +[#]: author: (Bryant Son https://opensource.com/users/brson/users/milindsingh/users/milindsingh/users/dscripter) + +使用开源工具构建 DevOps 流水线的初学者指南 +====== + +> 如果你是 DevOps 新人,请查看这 5 个步骤来构建你的第一个 DevOps 流水线。 + +![](https://img.linux.net.cn/data/attachment/album/201909/05/060323yizmqwn43zwy13za.jpg) + +DevOps 已经成为解决软件开发过程中出现的缓慢、孤立或者其他故障的默认方式。但是当你刚接触 DevOps 并且不确定从哪开始时,就意义不大了。本文探索了什么是 DevOps 流水线并且提供了创建它的 5 个步骤。尽管这个教程并不全面,但可以给你以后上手和扩展打下基础。首先,插入一个小故事。 + +### 我的 DevOps 之旅 + +我曾经在花旗集团的云小组工作,开发Infrastructure as a Service基础设施即服务网页应用来管理花旗的云基础设施,但我经常对研究如何让开发流水线更加高效以及如何带给团队积极的文化感兴趣。我在 Greg Lavender 推荐的书中找到了答案。Greg Lavender 是花旗的云架构和基础设施工程(即 [Phoenix 项目][2])的 CTO。这本书尽管解释的是 DevOps 原理,但它读起来像一本小说。 + +书后面的一张表展示了不同公司部署在发布环境上的频率: + +公司 | 部署频率 +---|--- +Amazon | 23,000 次/天 +Google | 5,500 次/天 +Netflix | 500 次/天 +Facebook | 1 次/天 +Twitter | 3 次/周 +典型企业 | 1 次/9 个月 + +Amazon、Google、Netflix 怎么能做到如此之频繁?那是因为这些公司弄清楚了如何去实现一个近乎完美的 DevOps 流水线。 + +但在花旗实施 DevOps 之前,情况并非如此。那时候,我的团队拥有不同构建阶段stage的环境,但是在开发服务器上的部署非常手工。所有的开发人员都只能访问一个基于 IBM WebSphere Application 社区版的开发环境服务器。问题是当多个用户同时尝试部署时,服务器就会宕机,因此开发人员在部署时就得互相通知,这一点相当痛苦。此外,还存在代码测试覆盖率低、手动部署过程繁琐以及无法根据定义的任务或用户需求跟踪代码部署的问题。 + +我意识到必须做些事情,同时也找到了一个有同样感受的同事。我们决定合作去构建一个初始的 DevOps 流水线 —— 他设置了一个虚拟机和一个 Tomcat 服务器,而我则架设了 Jenkins,集成了 Atlassian Jira、BitBucket 和代码覆盖率测试。这个业余项目非常成功:我们近乎全自动化了开发流水线,并在开发服务器上实现了几乎 100% 的正常运行,我们可以追踪并改进代码覆盖率测试,并且 Git 分支能够与部署任务和 jira 任务关联在一起。此外,大多数用来构建 DevOps 所使用的工具都是开源的。 + +现在我意识到了我们的 DevOps 流水线是多么的原始,因为我们没有利用像 Jenkins 文件或 Ansible 这样的高级设置。然而,这个简单的过程运作良好,这也许是因为 [Pareto][3] 原则(也被称作 80/20 法则)。 + +### DevOps 和 CI/CD 流水线的简要介绍 + +如果你问一些人,“什么是 DevOps?”,你或许会得到一些不同的回答。DevOps,就像敏捷,已经发展到涵盖着诸多不同的学科,但大多数人至少会同意这些:DevOps 是一个软件开发实践或一个软件开发生命周期software development lifecycle(SDLC),并且它的核心原则是一种文化上的变革 —— 开发人员与非开发人员呼吸着同一片天空的气息,之前手工的事情变得自动化;每个人做着自己擅长的事;同一时间的部署变得更加频繁;吞吐量提升;灵活度增加。 + +虽然拥有正确的软件工具并非实现 DevOps 环境所需的唯一东西,但一些工具却是必要的。最关键的一个便是持续集成和持续部署(CI/CD)。在流水线环境中,拥有不同的构建阶段(例如:DEV、INT、TST、QA、UAT、STG、PROD),手动的工作能实现自动化,开发人员可以实现高质量的代码,灵活而且大量部署。 + +这篇文章描述了一个构建 DevOps 流水线的五步方法,就像下图所展示的那样,使用开源的工具实现。 + +![Complete DevOps pipeline][4] + +闲话少说,让我们开始吧。 + +### 第一步:CI/CD 框架 + +首先你需要的是一个 CI/CD 工具,Jenkins,是一个基于 Java 的 MIT 许可下的开源 CI/CD 工具,它是推广 DevOps 运动的工具,并已成为了事实标准de facto standard。 + +所以,什么是 Jenkins?想象它是一种神奇的万能遥控,能够和许多不同的服务器和工具打交道,并且能够将它们统一安排起来。就本身而言,像 Jenkins 这样的 CI/CD 工具本身是没有用的,但随着接入不同的工具与服务器时会变得非常强大。 + +Jenkins 仅是众多构建 DevOps 流水线的开源 CI/CD 工具之一。 + +名称 | 许可证 +---|--- +[Jenkins][5] | Creative Commons 和 MIT +[Travis CI][6] | MIT +[CruiseControl][7] | BSD +[Buildbot][8] | GPL +[Apache Gump][9] | Apache 2.0 +[Cabie][10] | GNU + +下面就是使用 CI/CD 工具时 DevOps 看起来的样子。 + +![CI/CD tool][11] + +你的 CI/CD 工具在本地主机上运行,但目前你还不能够做些别的。让我们紧随 DevOps 之旅的脚步。 + +### 第二步:源代码控制管理 + +验证 CI/CD 工具可以执行某些魔术的最佳(也可能是最简单)方法是与源代码控制管理(SCM)工具集成。为什么需要源代码控制?假设你在开发一个应用。无论你什么时候构建应用,无论你使用的是 Java、Python、C++、Go、Ruby、JavaScript 或任意一种语言,你都在编程。你所编写的程序代码称为源代码。在一开始,特别是只有你一个人工作时,将所有的东西放进本地文件夹里或许都是可以的。但是当项目变得庞大并且邀请其他人协作后,你就需要一种方式来避免共享代码修改时的合并冲突。你也需要一种方式来恢复一个之前的版本——备份、复制并粘贴的方式已经过时了。你(和你的团队)想要更好的解决方式。 + +这就是 SCM 变得不可或缺的原因。SCM 工具通过在仓库中保存代码来帮助进行版本控制与多人协作。 + +尽管这里有许多 SCM 工具,但 Git 是最标准恰当的。我极力推荐使用 Git,但如果你喜欢这里仍有其他的开源工具。 + +名称 | 许可证 +---|--- +[Git][12] | GPLv2 & LGPL v2.1 +[Subversion][13] | Apache 2.0 +[Concurrent Versions System][14] (CVS) | GNU +[Vesta][15] | LGPL +[Mercurial][16] | GNU GPL v2+ + +拥有 SCM 之后,DevOps 流水线看起来就像这样。 + +![Source control management][17] + +CI/CD 工具能够自动化进行源代码检入检出以及完成成员之间的协作。还不错吧?但是,如何才能把它变成可工作的应用程序,使得数十亿人来使用并欣赏它呢? + +### 第三步:自动化构建工具 + +真棒!现在你可以检出代码并将修改提交到源代码控制,并且可以邀请你的朋友就源代码控制进行协作。但是到目前为止你还没有构建出应用。要想让它成为一个网页应用,必须将其编译并打包成可部署的包或可执行程序(注意,像 JavaScript 或 PHP 这样的解释型编程语言不需要进行编译)。 + +于是就引出了自动化构建工具。无论你决定使用哪一款构建工具,它们都有一个共同的目标:将源代码构建成某种想要的格式,并且将清理、编译、测试、部署到某个位置这些任务自动化。构建工具会根据你的编程语言而有不同,但这里有一些通常使用的开源工具值得考虑。 + +名称 | 许可证 | 编程语言 +---|---|--- +[Maven][18] | Apache 2.0 | Java +[Ant][19] | Apache 2.0 | Java +[Gradle][20] | Apache 2.0 | Java +[Bazel][21] | Apache 2.0 | Java +[Make][22] | GNU | N/A +[Grunt][23] | MIT | JavaScript +[Gulp][24] | MIT | JavaScript +[Buildr][25] | Apache | Ruby +[Rake][26] | MIT | Ruby +[A-A-P][27] | GNU | Python +[SCons][28] | MIT | Python +[BitBake][29] | GPLv2 | Python +[Cake][30] | MIT | C# +[ASDF][31] | Expat (MIT) | LISP +[Cabal][32] | BSD | Haskell + +太棒了!现在你可以将自动化构建工具的配置文件放进源代码控制管理系统中,并让你的 CI/CD 工具构建它。 + +![Build automation tool][33] + +一切都如此美好,对吧?但是在哪里部署它呢? + +### 第四步:网页应用服务器 + +到目前为止,你有了一个可执行或可部署的打包文件。对任何真正有用的应用程序来说,它必须提供某种服务或者接口,所以你需要一个容器来发布你的应用。 + +对于网页应用,网页应用服务器就是容器。应用程序服务器提供了环境,让可部署包中的编程逻辑能够被检测到、呈现界面,并通过打开套接字为外部世界提供网页服务。在其他环境下你也需要一个 HTTP 服务器(比如虚拟机)来安装服务应用。现在,我假设你将会自己学习这些东西(尽管我会在下面讨论容器)。 + +这里有许多开源的网页应用服务器。 + +名称 | 协议 | 编程语言 +---|---|--- +[Tomcat][34] | Apache 2.0 | Java +[Jetty][35] | Apache 2.0 | Java +[WildFly][36] | GNU Lesser Public | Java +[GlassFish][37] | CDDL & GNU Less Public | Java +[Django][38] | 3-Clause BSD | Python +[Tornado][39] | Apache 2.0 | Python +[Gunicorn][40] | MIT | Python +[Python Paste][41] | MIT | Python +[Rails][42] | MIT | Ruby +[Node.js][43] | MIT | Javascript + +现在 DevOps 流水线差不多能用了,干得好! + +![Web application server][44] + +尽管你可以在这里停下来并进行进一步的集成,但是代码质量对于应用开发者来说是一件非常重要的事情。 + +### 第五步:代码覆盖测试 + +实现代码测试件可能是另一个麻烦的需求,但是开发者需要尽早地捕捉程序中的所有错误并提升代码质量来保证最终用户满意度。幸运的是,这里有许多开源工具来测试你的代码并提出改善质量的建议。甚至更好的,大部分 CI/CD 工具能够集成这些工具并将测试过程自动化进行。 + +代码测试分为两个部分:“代码测试框架”帮助进行编写与运行测试,“代码质量改进工具”帮助提升代码的质量。 + +#### 代码测试框架 + +名称 | 许可证 | 编程语言 +---|---|--- +[JUnit][45] | Eclipse Public License | Java +[EasyMock][46] | Apache | Java +[Mockito][47] | MIT | Java +[PowerMock][48] | Apache 2.0 | Java +[Pytest][49] | MIT | Python +[Hypothesis][50] | Mozilla | Python +[Tox][51] | MIT | Python + +#### 代码质量改进工具 + +名称 | 许可证 | 编程语言 +---|---|--- +[Cobertura][52] | GNU | Java +[CodeCover][53] | Eclipse Public (EPL) | Java +[Coverage.py][54] | Apache 2.0 | Python +[Emma][55] | Common Public License | Java +[JaCoCo][56] | Eclipse Public License | Java +[Hypothesis][50] | Mozilla | Python +[Tox][51] | MIT | Python +[Jasmine][57] | MIT | JavaScript +[Karma][58] | MIT | JavaScript +[Mocha][59] | MIT | JavaScript +[Jest][60] | MIT | JavaScript + +注意,之前提到的大多数工具和框架都是为 Java、Python、JavaScript 写的,因为 C++ 和 C# 是专有编程语言(尽管 GCC 是开源的)。 + +现在你已经运用了代码覆盖测试工具,你的 DevOps 流水线应该就像教程开始那幅图中展示的那样了。 + +### 可选步骤 + +#### 容器 + +正如我之前所说,你可以在虚拟机(VM)或服务器上发布你的应用,但是容器是一个更好的解决方法。 + +[什么是容器][61]?简要的介绍就是 VM 需要占用操作系统大量的资源,它提升了应用程序的大小,而容器仅仅需要一些库和配置来运行应用程序。显然,VM 仍有重要的用途,但容器对于发布应用(包括应用程序服务器)来说是一个更为轻量的解决方式。 + +尽管对于容器来说也有其他的选择,但是 Docker 和 Kubernetes 更为广泛。 + +名称 | 许可证 +---|--- +[Docker][62] | Apache 2.0 +[Kubernetes][63] | Apache 2.0 + +了解更多信息,请查看 [Opensource.com][64] 上关于 Docker 和 Kubernetes 的其它文章: + + * [什么是 Docker?][65] + * [Docker 简介][66] + * [什么是 Kubernetes?][67] + * [从零开始的 Kubernetes 实践][68] + +#### 中间件自动化工具 + +我们的 DevOps 流水线大部分集中在协作构建与部署应用上,但你也可以用 DevOps 工具完成许多其他的事情。其中之一便是利用它实现基础设施管理Infrastructure as Code(IaC)工具,这也是熟知的中间件自动化工具。这些工具帮助完成中间件的自动化安装、管理和其他任务。例如,自动化工具可以用正确的配置下拉应用程序,例如网页服务器、数据库和监控工具,并且部署它们到应用服务器上。 + +这里有几个开源的中间件自动化工具值得考虑: + +名称 | 许可证 +---|--- +[Ansible][69] | GNU Public +[SaltStack][70] | Apache 2.0 +[Chef][71] | Apache 2.0 +[Puppet][72] | Apache or GPL + +获取更多中间件自动化工具,查看 [Opensource.com][64] 上的其它文章: + + * [Ansible 快速入门指南][73] + * [Ansible 自动化部署策略][74] + * [配置管理工具 Top 5][75] + +### 之后的发展 + +这只是一个完整 DevOps 流水线的冰山一角。从 CI/CD 工具开始并且探索其他可以自动化的东西来使你的团队更加轻松的工作。并且,寻找[开源通讯工具][76]可以帮助你的团队一起工作的更好。 + +发现更多见解,这里有一些非常棒的文章来介绍 DevOps : + + * [什么是 DevOps][77] + * [掌握 5 件事成为 DevOps 工程师][78] + * [所有人的 DevOps][79] + * [在 DevOps 中开始使用预测分析][80] + +使用开源 agile 工具来集成 DevOps 也是一个很好的主意: + + * [什么是 agile ?][81] + * [4 步成为一个了不起的 agile 开发者][82] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/devops-pipeline + +作者:[Bryant Son][a] +选题:[lujun9972][b] +译者:[LuMing](https://github.com/LuuMing) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/brson/users/milindsingh/users/milindsingh/users/dscripter +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/network_team_career_hand.png?itok=_ztl2lk_ (Shaking hands, networking) +[2]: https://www.amazon.com/dp/B078Y98RG8/ +[3]: https://en.wikipedia.org/wiki/Pareto_principle +[4]: https://opensource.com/sites/default/files/uploads/1_finaldevopspipeline.jpg (Complete DevOps pipeline) +[5]: https://github.com/jenkinsci/jenkins +[6]: https://github.com/travis-ci/travis-ci +[7]: http://cruisecontrol.sourceforge.net +[8]: https://github.com/buildbot/buildbot +[9]: https://gump.apache.org +[10]: http://cabie.tigris.org +[11]: https://opensource.com/sites/default/files/uploads/2_runningjenkins.jpg (CI/CD tool) +[12]: https://git-scm.com +[13]: https://subversion.apache.org +[14]: http://savannah.nongnu.org/projects/cvs +[15]: http://www.vestasys.org +[16]: https://www.mercurial-scm.org +[17]: https://opensource.com/sites/default/files/uploads/3_sourcecontrolmanagement.jpg (Source control management) +[18]: https://maven.apache.org +[19]: https://ant.apache.org +[20]: https://gradle.org/ +[21]: https://bazel.build +[22]: https://www.gnu.org/software/make +[23]: https://gruntjs.com +[24]: https://gulpjs.com +[25]: http://buildr.apache.org +[26]: https://github.com/ruby/rake +[27]: http://www.a-a-p.org +[28]: https://www.scons.org +[29]: https://www.yoctoproject.org/software-item/bitbake +[30]: https://github.com/cake-build/cake +[31]: https://common-lisp.net/project/asdf +[32]: https://www.haskell.org/cabal +[33]: https://opensource.com/sites/default/files/uploads/4_buildtools.jpg (Build automation tool) +[34]: https://tomcat.apache.org +[35]: https://www.eclipse.org/jetty/ +[36]: http://wildfly.org +[37]: https://javaee.github.io/glassfish +[38]: https://www.djangoproject.com/ +[39]: http://www.tornadoweb.org/en/stable +[40]: https://gunicorn.org +[41]: https://github.com/cdent/paste +[42]: https://rubyonrails.org +[43]: https://nodejs.org/en +[44]: https://opensource.com/sites/default/files/uploads/5_applicationserver.jpg (Web application server) +[45]: https://junit.org/junit5 +[46]: http://easymock.org +[47]: https://site.mockito.org +[48]: https://github.com/powermock/powermock +[49]: https://docs.pytest.org +[50]: https://hypothesis.works +[51]: https://github.com/tox-dev/tox +[52]: http://cobertura.github.io/cobertura +[53]: http://codecover.org/ +[54]: https://github.com/nedbat/coveragepy +[55]: http://emma.sourceforge.net +[56]: https://github.com/jacoco/jacoco +[57]: https://jasmine.github.io +[58]: https://github.com/karma-runner/karma +[59]: https://github.com/mochajs/mocha +[60]: https://jestjs.io +[61]: /resources/what-are-linux-containers +[62]: https://www.docker.com +[63]: https://kubernetes.io +[64]: http://Opensource.com +[65]: https://opensource.com/resources/what-docker +[66]: https://opensource.com/business/15/1/introduction-docker +[67]: https://opensource.com/resources/what-is-kubernetes +[68]: https://opensource.com/article/17/11/kubernetes-lightning-talk +[69]: https://www.ansible.com +[70]: https://www.saltstack.com +[71]: https://www.chef.io +[72]: https://puppet.com +[73]: https://opensource.com/article/19/2/quickstart-guide-ansible +[74]: https://opensource.com/article/19/1/automating-deployment-strategies-ansible +[75]: https://opensource.com/article/18/12/configuration-management-tools +[76]: https://opensource.com/alternatives/slack +[77]: https://opensource.com/resources/devops +[78]: https://opensource.com/article/19/2/master-devops-engineer +[79]: https://opensource.com/article/18/11/how-non-engineer-got-devops +[80]: https://opensource.com/article/19/1/getting-started-predictive-analytics-devops +[81]: https://opensource.com/article/18/10/what-agile +[82]: https://opensource.com/article/19/2/steps-agile-developer diff --git a/published/20190409 Working with variables on Linux.md b/published/20190409 Working with variables on Linux.md new file mode 100644 index 0000000000..f51bf503fa --- /dev/null +++ b/published/20190409 Working with variables on Linux.md @@ -0,0 +1,261 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11344-1.html) +[#]: subject: (Working with variables on Linux) +[#]: via: (https://www.networkworld.com/article/3387154/working-with-variables-on-linux.html#tk.rss_all) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在 Linux 中使用变量 +====== + +> 变量通常看起来像 `$var` 这样,但它们也有 `$1`、`$*`、`$?` 和 `$$` 这种形式。让我们来看看所有这些 `$` 值可以告诉你什么。 + +![](https://img.linux.net.cn/data/attachment/album/201909/15/105140faf2jzyybubu1d0c.jpg) + +有许多重要的值都存储在 Linux 系统中,我们称为“变量”,但实际上变量有几种类型,并且一些有趣的命令可以帮助你使用它们。在上一篇文章中,我们研究了[环境变量][2]以及它们定义在何处。在本文中,我们来看一看在命令行和脚本中使用的变量。 + +### 用户变量 + +虽然在命令行中设置变量非常容易,但是有一些有趣的技巧。要设置变量,你只需这样做: + +``` +$ myvar=11 +$ myvar2="eleven" +``` + +要显示这些值,只需这样做: + +``` +$ echo $myvar +11 +$ echo $myvar2 +eleven +``` + +你也可以使用这些变量。例如,要递增一个数字变量,使用以下任意一个命令: + +``` +$ myvar=$((myvar+1)) +$ echo $myvar +12 +$ ((myvar=myvar+1)) +$ echo $myvar +13 +$ ((myvar+=1)) +$ echo $myvar +14 +$ ((myvar++)) +$ echo $myvar +15 +$ let "myvar=myvar+1" +$ echo $myvar +16 +$ let "myvar+=1" +$ echo $myvar +17 +$ let "myvar++" +$ echo $myvar +18 +``` + +使用其中的一些,你可以增加一个变量的值。例如: + +``` +$ myvar0=0 +$ ((myvar0++)) +$ echo $myvar0 +1 +$ ((myvar0+=10)) +$ echo $myvar0 +11 +``` + +通过这些选项,你可能会发现它们是容易记忆、使用方便的。 + +你也可以*删除*一个变量 -- 这意味着没有定义它。 + +``` +$ unset myvar +$ echo $myvar +``` + +另一个有趣的选项是,你可以设置一个变量并将其设为**只读**。换句话说,变量一旦设置为只读,它的值就不能改变(除非一些非常复杂的命令行魔法才可以)。这意味着你也不能删除它。 + +``` +$ readonly myvar3=1 +$ echo $myvar3 +1 +$ ((myvar3++)) +-bash: myvar3: readonly variable +$ unset myvar3 +-bash: unset: myvar3: cannot unset: readonly variable +``` + +你可以使用这些设置和递增选项中来赋值和操作脚本中的变量,但也有一些非常有用的*内部变量*可以用于在脚本中。注意,你无法重新赋值或增加它们的值。 + +### 内部变量 + +在脚本中可以使用很多变量来计算参数并显示有关脚本本身的信息。 + +* `$1`、`$2`、`$3` 等表示脚本的第一个、第二个、第三个等参数。 +* `$#` 表示参数的数量。 +* `$*` 表示所有参数。 +* `$0` 表示脚本的名称。 +* `$?` 表示先前运行的命令的返回码(0 代表成功)。 +* `$$` 显示脚本的进程 ID。 +* `$PPID` 显示 shell 的进程 ID(脚本的父进程)。 + +其中一些变量也适用于命令行,但显示相关信息: + +* `$0` 显示你正在使用的 shell 的名称(例如,-bash)。 +* `$$` 显示 shell 的进程 ID。 +* `$PPID` 显示 shell 的父进程的进程 ID(对我来说,是 sshd)。 + +为了查看它们的结果,如果我们将所有这些变量都放入一个脚本中,比如: + +``` +#!/bin/bash + +echo $0 +echo $1 +echo $2 +echo $# +echo $* +echo $? +echo $$ +echo $PPID +``` + +当我们调用这个脚本时,我们会看到如下内容: + +``` +$ tryme one two three +/home/shs/bin/tryme <== 脚本名称 +one <== 第一个参数 +two <== 第二个参数 +3 <== 参数的个数 +one two three <== 所有的参数 +0 <== 上一条 echo 命令的返回码 +10410 <== 脚本的进程 ID +10109 <== 父进程 ID +``` + +如果我们在脚本运行完毕后检查 shell 的进程 ID,我们可以看到它与脚本中显示的 PPID 相匹配: + +``` +$ echo $$ +10109 <== shell 的进程 ID +``` + +当然,比起简单地显示它们的值,更有用的方式是使用它们。我们来看一看它们可能的用处。 + +检查是否已提供参数: + +``` +if [ $# == 0 ]; then + echo "$0 filename" + exit 1 +fi +``` + +检查特定进程是否正在运行: + +``` +ps -ef | grep apache2 > /dev/null +if [ $? != 0 ]; then + echo Apache is not running + exit +fi +``` + +在尝试访问文件之前验证文件是否存在: + +``` +if [ $# -lt 2 ]; then + echo "Usage: $0 lines filename" + exit 1 +fi + +if [ ! -f $2 ]; then + echo "Error: File $2 not found" + exit 2 +else + head -$1 $2 +fi +``` + +在下面的小脚本中,我们检查是否提供了正确数量的参数、第一个参数是否为数字,以及第二个参数代表的文件是否存在。 + +``` +#!/bin/bash + +if [ $# -lt 2 ]; then + echo "Usage: $0 lines filename" + exit 1 +fi + +if [[ $1 != [0-9]* ]]; then + echo "Error: $1 is not numeric" + exit 2 +fi + +if [ ! -f $2 ]; then + echo "Error: File $2 not found" + exit 3 +else + echo top of file + head -$1 $2 +fi +``` + +### 重命名变量 + +在编写复杂的脚本时,为脚本的参数指定名称通常很有用,而不是继续将它们称为 `$1`、`$2` 等。等到第 35 行,阅读你脚本的人可能已经忘了 `$2` 表示什么。如果你将一个重要参数的值赋给 `$filename` 或 `$numlines`,那么他就不容易忘记。 + +``` +#!/bin/bash + +if [ $# -lt 2 ]; then + echo "Usage: $0 lines filename" + exit 1 +else + numlines=$1 + filename=$2 +fi + +if [[ $numlines != [0-9]* ]]; then + echo "Error: $numlines is not numeric" + exit 2 +fi + +if [ ! -f $ filename]; then + echo "Error: File $filename not found" + exit 3 +else + echo top of file + head -$numlines $filename +fi +``` + +当然,这个示例脚本只是运行 `head` 命令来显示文件中的前 x 行,但它的目的是显示如何在脚本中使用内部参数来帮助确保脚本运行良好,或在失败时清晰地知道失败原因。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3387154/working-with-variables-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/04/variable-key-keyboard-100793080-large.jpg +[2]: https://linux.cn/article-10916-1.html +[3]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/20161106 Myths about -dev-urandom.md b/published/201905/20161106 Myths about -dev-urandom.md similarity index 100% rename from published/20161106 Myths about -dev-urandom.md rename to published/201905/20161106 Myths about -dev-urandom.md diff --git a/published/20171214 Build a game framework with Python using the module Pygame.md b/published/201905/20171214 Build a game framework with Python using the module Pygame.md similarity index 100% rename from published/20171214 Build a game framework with Python using the module Pygame.md rename to published/201905/20171214 Build a game framework with Python using the module Pygame.md diff --git a/published/20171215 How to add a player to your Python game.md b/published/201905/20171215 How to add a player to your Python game.md similarity index 100% rename from published/20171215 How to add a player to your Python game.md rename to published/201905/20171215 How to add a player to your Python game.md diff --git a/published/20180130 An introduction to the DomTerm terminal emulator for Linux.md b/published/201905/20180130 An introduction to the DomTerm terminal emulator for Linux.md similarity index 100% rename from published/20180130 An introduction to the DomTerm terminal emulator for Linux.md rename to published/201905/20180130 An introduction to the DomTerm terminal emulator for Linux.md diff --git a/published/201905/20180312 ddgr - A Command Line Tool To Search DuckDuckGo From The Terminal.md b/published/201905/20180312 ddgr - A Command Line Tool To Search DuckDuckGo From The Terminal.md new file mode 100644 index 0000000000..3d8083d440 --- /dev/null +++ b/published/201905/20180312 ddgr - A Command Line Tool To Search DuckDuckGo From The Terminal.md @@ -0,0 +1,229 @@ +ddgr:一个从终端搜索 DuckDuckGo 的命令行工具 +====== + +在 Linux 中,Bash 技巧非常棒,它使 Linux 中的一切成为可能。 + +对于开发人员或系统管理员来说,它真的很管用,因为他们大部分时间都在使用终端。你知道他们为什么喜欢这种技巧吗? + +因为这些技巧可以提高他们的工作效率,也能使他们工作更快。 + +### 什么是 ddgr + +[ddgr][1] 是一个命令行实用程序,用于从终端搜索 DuckDuckGo。如果设置了 `BROWSER` 环境变量,ddgr 可以在几个基于文本的浏览器中开箱即用。 + +确保你的系统安装了任何一个基于文本的浏览器。你可能知道 [googler][2],它允许用户从 Linux 命令行进行 Google 搜索。 + +它在命令行用户中非常受欢迎,他们期望对隐私敏感的 DuckDuckGo 也有类似的实用程序,这就是 `ddgr` 出现的原因。 + +与 Web 界面不同,你可以指定每页要查看的搜索结果数。 + +**建议阅读:** + +- [Googler – 从 Linux 命令行搜索 Google][2] +- [Buku – Linux 中一个强大的命令行书签管理器][3] +- [SoCLI – 从终端搜索和浏览 StackOverflow 的简单方法][4] +- [RTV(Reddit 终端查看器)- 一个简单的 Reddit 终端查看器][5] + +### 什么是 DuckDuckGo + +DDG 即 DuckDuckGo。DuckDuckGo(DDG)是一个真正保护用户搜索和隐私的互联网搜索引擎。它没有过滤用户的个性化搜索结果,对于给定的搜索词,它会向所有用户显示相同的搜索结果。 + +大多数用户更喜欢谷歌搜索引擎,但是如果你真的担心隐私,那么你可以放心地使用 DuckDuckGo。 + +### ddgr 特性 + + * 快速且干净(没有广告、多余的 URL 或杂物参数),自定义颜色 + * 旨在以最小的空间提供最高的可读性 + * 指定每页显示的搜索结果数 + * 可以在 omniprompt 中导航结果,在浏览器中打开 URL + * 用于 Bash、Zsh 和 Fish 的搜索和选项补完脚本 + * 支持 DuckDuckGo Bang(带有自动补完) + * 直接在浏览器中打开第一个结果(如同 “I’m Feeling Ducky”) + * 不间断搜索:无需退出即可在 omniprompt 中触发新搜索 + * 关键字支持(例如:filetype:mime、site:somesite.com) + * 按时间、指定区域搜索,禁用安全搜索 + * 支持 HTTPS 代理,支持 Do Not Track,可选择禁用用户代理字符串 + * 支持自定义 URL 处理程序脚本或命令行实用程序 + * 全面的文档,man 页面有方便的使用示例 + * 最小的依赖关系 + +### 需要条件 + +`ddgr` 需要 Python 3.4 或更高版本。因此,确保你的系统应具有 Python 3.4 或更高版本。 + +``` +$ python3 --version +Python 3.6.3 +``` + +### 如何在 Linux 中安装 ddgr + +我们可以根据发行版使用以下命令轻松安装 `ddgr`。 + +对于 Fedora ,使用 [DNF 命令][6]来安装 `ddgr`。 + +``` +# dnf install ddgr +``` + +或者我们可以使用 [SNAP 命令][7]来安装 `ddgr`。 + +``` +# snap install ddgr +``` + +对于 LinuxMint/Ubuntu,使用 [APT-GET 命令][8] 或 [APT 命令][9]来安装 `ddgr`。 + +``` +$ sudo add-apt-repository ppa:twodopeshaggy/jarun +$ sudo apt-get update +$ sudo apt-get install ddgr +``` + +对于基于 Arch Linux 的系统,使用 [Yaourt 命令][10]或 [Packer 命令][11]从 AUR 仓库安装 `ddgr`。 + +``` +$ yaourt -S ddgr +或 +$ packer -S ddgr +``` + +对于 Debian,使用 [DPKG 命令][12] 安装 `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 +``` + +对于 CentOS 7,使用 [YUM 命令][13]来安装 `ddgr`。 + +``` +# yum install https://github.com/jarun/ddgr/releases/download/v1.2/ddgr-1.2-1.el7.3.centos.x86_64.rpm +``` + +对于 opensuse,使用 [zypper 命令][14]来安装 `ddgr`。 + +``` +# zypper install https://github.com/jarun/ddgr/releases/download/v1.2/ddgr-1.2-1.opensuse42.3.x86_64.rpm +``` + +### 如何启动 ddgr + +在终端上输入 `ddgr` 命令,不带任何选项来进行 DuckDuckGo 搜索。你将获得类似于下面的输出。 + +``` +$ ddgr +``` + +![][16] + +### 如何使用 ddgr 进行搜索 + +我们可以通过两种方式启动搜索。从 omniprompt 或者直接从终端开始。你可以搜索任何你想要的短语。 + +直接从终端: + +``` +$ ddgr 2daygeek +``` + +![][17] + +从 omniprompt: + +![][18] + +### Omniprompt 快捷方式 + +输入 `?` 以获得 omniprompt,它将显示关键字列表和进一步使用 `ddgr` 的快捷方式。 + +![][19] + +### 如何移动下一页、上一页和第一页 + +它允许用户移动下一页、上一页或第一页。 + + * `n`: 移动到下一组搜索结果 + * `p`: 移动到上一组搜索结果 + * `f`: 跳转到第一页 + +![][20] + +### 如何启动新搜索 + +`d` 选项允许用户从 omniprompt 发起新的搜索。例如,我搜索了 “2daygeek website”,现在我将搜索 “Magesh Maruthamuthu” 这个新短语。 + +从 omniprompt: + +``` +ddgr (? for help) d magesh maruthmuthu +``` + +![][21] + +### 在搜索结果中显示完整的 URL + +默认情况下,它仅显示文章标题,在搜索中添加 `x` 选项以在搜索结果中显示完整的文章网址。 + +``` +$ ddgr -n 5 -x 2daygeek +``` + +![][22] + +### 限制搜索结果 + +默认情况下,搜索结果每页显示 10 个结果。如果你想为方便起见限制页面结果,可以使用 `ddgr` 带有 `--num` 或 ` -n` 参数。 + +``` +$ ddgr -n 5 2daygeek +``` + +![][23] + +### 网站特定搜索 + +要搜索特定网站的特定页面,使用以下格式。这将从网站获取给定关键字的结果。例如,我们在 2daygeek 网站下搜索 “Package Manager”,查看结果。 + +``` +$ 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] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) +选题:[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 diff --git a/published/201905/20180429 The Easiest PDO Tutorial (Basics).md b/published/201905/20180429 The Easiest PDO Tutorial (Basics).md new file mode 100644 index 0000000000..cadc526b0f --- /dev/null +++ b/published/201905/20180429 The Easiest PDO Tutorial (Basics).md @@ -0,0 +1,155 @@ +PHP PDO 简单教程 +====== + +![](http://www.theitstuff.com/wp-content/uploads/2018/04/php-language.jpg) + +大约 80% 的 Web 应用程序由 PHP 提供支持。类似地,SQL 也是如此。PHP 5.5 版本之前,我们有用于访问 MySQL 数据库的 mysql_ 命令,但由于安全性不足,它们最终被弃用。 + +弃用这件事是发生在 2013 年的 PHP 5.5 上,我写这篇文章的时间是 2018 年,PHP 版本为 7.2。mysql_ 的弃用带来了访问数据库的两种主要方法:mysqli 和 PDO 库。 + +虽然 mysqli 库是官方指定的,但由于 mysqli 只能支持 mysql 数据库,而 PDO 可以支持 12 种不同类型的数据库驱动程序,因此 PDO 获得了更多的赞誉。此外,PDO 还有其它一些特性,使其成为大多数开发人员的更好选择。你可以在下表中看到一些特性比较: + +| | PDO | MySQLi +---|---|--- +| 数据库支持 | 12 种驱动 | 只有 MySQL +| 范例 | OOP | 过程 + OOP +| 预处理语句(客户端侧) | Yes | No +| 1命名参数 | Yes | No + +现在我想对于大多数开发人员来说,PDO 是首选的原因已经很清楚了。所以让我们深入研究它,并希望在本文中尽量涵盖关于 PDO 你需要的了解的。 + +### 连接 + +第一步是连接到数据库,由于 PDO 是完全面向对象的,所以我们将使用 PDO 类的实例。 + +我们要做的第一件事是定义主机、数据库名称、用户名、密码和数据库字符集。 + +``` +$host = 'localhost'; +$db = 'theitstuff'; +$user = 'root'; +$pass = 'root'; +$charset = 'utf8mb4'; +$dsn = "mysql:host=$host;dbname=$db;charset=$charset"; +$conn = new PDO($dsn, $user, $pass); +``` + +之后,正如你在上面的代码中看到的,我们创建了 DSN 变量,DSN 变量只是一个保存数据库信息的变量。对于一些在外部服务器上运行 MySQL 的人,你还可以通过提供一个 `port=$port_number` 来调整端口号。 + +最后,你可以创建一个 PDO 类的实例,我使用了 `$conn` 变量,并提供了 `$dsn`、`$user`、`$pass` 参数。如果你遵循这些步骤,你现在应该有一个名为 `$conn` 的对象,它是 PDO 连接类的一个实例。现在是时候进入数据库并运行一些查询。 + +### 一个简单的 SQL 查询 + +现在让我们运行一个简单的 SQL 查询。 + +``` +$tis = $conn->query('SELECT name, age FROM students'); +while ($row = $tis->fetch()) +{ + echo $row['name']."\t"; + echo $row['age']; + echo "
"; +} +``` + +这是使用 PDO 运行查询的最简单形式。我们首先创建了一个名为 `tis`(TheITStuff 的缩写 )的变量,然后你可以看到我们使用了创建的 `$conn` 对象中的查询函数。 + +然后我们运行一个 `while` 循环并创建了一个 `$row` 变量来从 `$tis` 对象中获取内容,最后通过调用列名来显示每一行。 + +很简单,不是吗?现在让我们来看看预处理语句。 + +### 预处理语句 + +预处理语句是人们开始使用 PDO 的主要原因之一,因为它提供了可以阻止 SQL 注入的语句。 + +有两种基本方法可供使用,你可以使用位置参数或命名参数。 + +#### 位置参数 + +让我们看一个使用位置参数的查询示例。 + +``` +$tis = $conn->prepare("INSERT INTO STUDENTS(name, age) values(?, ?)"); +$tis->bindValue(1,'mike'); +$tis->bindValue(2,22); +$tis->execute(); +``` + +在上面的例子中,我们放置了两个问号,然后使用 `bindValue()` 函数将值映射到查询中。这些值绑定到语句问号中的位置。 + +我还可以使用变量而不是直接提供值,通过使用 `bindParam()` 函数相同例子如下: + +``` +$name='Rishabh'; $age=20; +$tis = $conn->prepare("INSERT INTO STUDENTS(name, age) values(?, ?)"); +$tis->bindParam(1,$name); +$tis->bindParam(2,$age); +$tis->execute(); +``` + +### 命名参数 + +命名参数也是预处理语句,它将值/变量映射到查询中的命名位置。由于没有位置绑定,因此在多次使用相同变量的查询中非常有效。 + +``` +$name='Rishabh'; $age=20; +$tis = $conn->prepare("INSERT INTO STUDENTS(name, age) values(:name, :age)"); +$tis->bindParam(':name', $name); +$tis->bindParam(':age', $age); +$tis->execute(); +``` + +你可以注意到,唯一的变化是我使用 `:name` 和 `:age` 作为占位符,然后将变量映射到它们。冒号在参数之前使用,让 PDO 知道该位置是一个变量,这非常重要。 + +你也可以类似地使用 `bindValue()` 来使用命名参数直接映射值。 + +### 获取数据 + +PDO 在获取数据时非常丰富,它实际上提供了许多格式来从数据库中获取数据。 + +你可以使用 `PDO::FETCH_ASSOC` 来获取关联数组,`PDO::FETCH_NUM` 来获取数字数组,使用 `PDO::FETCH_OBJ` 来获取对象数组。 + +``` +$tis = $conn->prepare("SELECT * FROM STUDENTS"); +$tis->execute(); +$result = $tis->fetchAll(PDO::FETCH_ASSOC); +``` + +你可以看到我使用了 `fetchAll`,因为我想要所有匹配的记录。如果只需要一行,你可以简单地使用 `fetch`。 + +现在我们已经获取了数据,现在是时候循环它了,这非常简单。 + +``` +foreach ($result as $lnu){ + echo $lnu['name']; + echo $lnu['age']."
"; +} +``` + +你可以看到,因为我请求了关联数组,所以我正在按名称访问各个成员。 + +虽然在定义希望如何传输递数据方面没有要求,但在定义 `$conn` 变量本身时,实际上可以将其设置为默认值。 + +你需要做的就是创建一个 `$options` 数组,你可以在其中放入所有默认配置,只需在 `$conn` 变量中传递数组即可。 + +``` +$options = [ + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, +]; +$conn = new PDO($dsn, $user, $pass, $options); +``` + +这是一个非常简短和快速的 PDO 介绍,我们很快就会制作一个高级教程。如果你在理解本教程的任何部分时遇到任何困难,请在评论部分告诉我,我会在那你为你解答。 + +-------------------------------------------------------------------------------- + +via: http://www.theitstuff.com/easiest-pdo-tutorial-basics + +作者:[Rishabh Kandari][a] +选题:[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/) 荣誉推出 + +[a]:http://www.theitstuff.com/author/reevkandari diff --git a/translated/tech/20180518 What-s a hero without a villain- How to add one to your Python game.md b/published/201905/20180518 What-s a hero without a villain- How to add one to your Python game.md similarity index 83% rename from translated/tech/20180518 What-s a hero without a villain- How to add one to your Python game.md rename to published/201905/20180518 What-s a hero without a villain- How to add one to your Python game.md index a4a2138136..c4bb5c84f0 100644 --- a/translated/tech/20180518 What-s a hero without a villain- How to add one to your Python game.md +++ b/published/201905/20180518 What-s a hero without a villain- How to add one to your Python game.md @@ -1,21 +1,22 @@ -没有恶棍,英雄又将如何?如何向你的 Python 游戏中添加一个敌人 +如何向你的 Python 游戏中添加一个敌人 ====== + +> 在本系列的第五部分,学习如何增加一个坏蛋与你的好人战斗。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/game-dogs-chess-play-lead.png?itok=NAuhav4Z) 在本系列的前几篇文章中(参见 [第一部分][1]、[第二部分][2]、[第三部分][3] 以及 [第四部分][4]),你已经学习了如何使用 Pygame 和 Python 在一个空白的视频游戏世界中生成一个可玩的角色。但没有恶棍,英雄又将如何? 如果你没有敌人,那将会是一个非常无聊的游戏。所以在此篇文章中,你将为你的游戏添加一个敌人并构建一个用于创建关卡的框架。 -在对玩家妖精实现全部功能仍有许多事情可做之前,跳向敌人似乎就很奇怪。但你已经学到了很多东西,创造恶棍与与创造玩家妖精非常相似。所以放轻松,使用你已经掌握的知识,看看能挑起怎样一些麻烦。 +在对玩家妖精实现全部功能之前,就来实现一个敌人似乎就很奇怪。但你已经学到了很多东西,创造恶棍与与创造玩家妖精非常相似。所以放轻松,使用你已经掌握的知识,看看能挑起怎样一些麻烦。 针对本次训练,你能够从 [Open Game Art][5] 下载一些预创建的素材。此处是我使用的一些素材: - -+ 印加花砖(译注:游戏中使用的花砖贴图) ++ 印加花砖(LCTT 译注:游戏中使用的花砖贴图) + 一些侵略者 + 妖精、角色、物体以及特效 - ### 创造敌方妖精 是的,不管你意识到与否,你其实已经知道如何去实现敌人。这个过程与创造一个玩家妖精非常相似: @@ -24,40 +25,27 @@ 2. 创建 `update` 方法使得敌人能够检测碰撞 3. 创建 `move` 方法使得敌人能够四处游荡 - - -从类入手。从概念上看,它与你的 Player 类大体相同。你设置一张或者一组图片,然后设置妖精的初始位置。 +从类入手。从概念上看,它与你的 `Player` 类大体相同。你设置一张或者一组图片,然后设置妖精的初始位置。 在继续下一步之前,确保你有一张你的敌人的图像,即使只是一张临时图像。将图像放在你的游戏项目的 `images` 目录(你放置你的玩家图像的相同目录)。 如果所有的活物都拥有动画,那么游戏看起来会好得多。为敌方妖精设置动画与为玩家妖精设置动画具有相同的方式。但现在,为了保持简单,我们使用一个没有动画的妖精。 在你代码 `objects` 节的顶部,使用以下代码创建一个叫做 `Enemy` 的类: + ``` class Enemy(pygame.sprite.Sprite): -     ''' - 生成一个敌人 -     ''' -     def __init__(self,x,y,img): -         pygame.sprite.Sprite.__init__(self) -         self.image = pygame.image.load(os.path.join('images',img)) -         self.image.convert_alpha() -         self.image.set_colorkey(ALPHA) -         self.rect = self.image.get_rect() -         self.rect.x = x -         self.rect.y = y - ``` 如果你想让你的敌人动起来,使用让你的玩家拥有动画的 [相同方式][4]。 @@ -67,25 +55,21 @@ class Enemy(pygame.sprite.Sprite): 你能够通过告诉类,妖精应使用哪张图像,应出现在世界上的什么地方,来生成不只一个敌人。这意味着,你能够使用相同的敌人类,在游戏世界的任意地方生成任意数量的敌方妖精。你需要做的仅仅是调用这个类,并告诉它应使用哪张图像,以及你期望生成点的 X 和 Y 坐标。 再次,这从原则上与生成一个玩家精灵相似。在你脚本的 `setup` 节添加如下代码: + ``` enemy   = Enemy(20,200,'yeti.png') # 生成敌人 - enemy_list = pygame.sprite.Group() # 创建敌人组 - enemy_list.add(enemy)              # 将敌人加入敌人组 - ``` -在示例代码中,X 坐标为 20,Y 坐标为 200。你可能需要根据你的敌方妖精的大小,来调整这些数字,但尽量生成在一个地方,使得你的玩家妖精能够到它。`Yeti.png` 是用于敌人的图像。 +在示例代码中,X 坐标为 20,Y 坐标为 200。你可能需要根据你的敌方妖精的大小,来调整这些数字,但尽量生成在一个范围内,使得你的玩家妖精能够碰到它。`Yeti.png` 是用于敌人的图像。 接下来,将敌人组的所有敌人绘制在屏幕上。现在,你只有一个敌人,如果你想要更多你可以稍后添加。一但你将一个敌人加入敌人组,它就会在主循环中被绘制在屏幕上。中间这一行是你需要添加的新行: + ```     player_list.draw(world) -     enemy_list.draw(world)  # 刷新敌人 -     pygame.display.flip() - ``` 启动你的游戏,你的敌人会出现在游戏世界中你选择的 X 和 Y 坐标处。 @@ -96,42 +80,31 @@ enemy_list.add(enemy)              # 将敌人加入敌人组 思考一下“关卡”是什么。你如何知道你是在游戏中的一个特定关卡中呢? -你可以把关卡想成一系列项目的集合。就像你刚刚创建的这个平台中,一个关卡,包含了平台、敌人放置、赃物等的一个特定排列。你可以创建一个类,用来在你的玩家附近创建关卡。最终,当你创建了超过一个关卡,你就可以在你的玩家达到特定目标时,使用这个类生成下一个关卡。 +你可以把关卡想成一系列项目的集合。就像你刚刚创建的这个平台中,一个关卡,包含了平台、敌人放置、战利品等的一个特定排列。你可以创建一个类,用来在你的玩家附近创建关卡。最终,当你创建了一个以上的关卡,你就可以在你的玩家达到特定目标时,使用这个类生成下一个关卡。 将你写的用于生成敌人及其群组的代码,移动到一个每次生成新关卡时都会被调用的新函数中。你需要做一些修改,使得每次你创建新关卡时,你都能够创建一些敌人。 + ``` class Level(): -     def bad(lvl,eloc): -         if lvl == 1: -             enemy = Enemy(eloc[0],eloc[1],'yeti.png') # 生成敌人 -             enemy_list = pygame.sprite.Group() # 生成敌人组 -             enemy_list.add(enemy)              # 将敌人加入敌人组 -         if lvl == 2: -             print("Level " + str(lvl) ) - -         return enemy_list - ``` `return` 语句确保了当你调用 `Level.bad` 方法时,你将会得到一个 `enemy_list` 变量包含了所有你定义的敌人。 因为你现在将创造敌人作为每个关卡的一部分,你的 `setup` 部分也需要做些更改。不同于创造一个敌人,取而代之的是你必须去定义敌人在那里生成,以及敌人属于哪个关卡。 + ``` eloc = [] - eloc = [200,20] - enemy_list = Level.bad( 1, eloc ) - ``` 再次运行游戏来确认你的关卡生成正确。与往常一样,你应该会看到你的玩家,并且能看到你在本章节中添加的敌人。 @@ -140,31 +113,27 @@ enemy_list = Level.bad( 1, eloc ) 一个敌人如果对玩家没有效果,那么它不太算得上是一个敌人。当玩家与敌人发生碰撞时,他们通常会对玩家造成伤害。 -因为你可能想要去跟踪玩家的生命值,因此碰撞检测发生在 Player 类,而不是 Enemy 类中。当然如果你想,你也可以跟踪敌人的生命值。它们之间的逻辑与代码大体相似,现在,我们只需要跟踪玩家的生命值。 +因为你可能想要去跟踪玩家的生命值,因此碰撞检测发生在 `Player` 类,而不是 `Enemy` 类中。当然如果你想,你也可以跟踪敌人的生命值。它们之间的逻辑与代码大体相似,现在,我们只需要跟踪玩家的生命值。 为了跟踪玩家的生命值,你必须为它确定一个变量。代码示例中的第一行是上下文提示,那么将第二行代码添加到你的 Player 类中: + ```         self.frame  = 0 -         self.health = 10 - ``` -在你 Player 类的 `update` 方法中,添加如下代码块: +在你 `Player` 类的 `update` 方法中,添加如下代码块: + ```         hit_list = pygame.sprite.spritecollide(self, enemy_list, False) -         for enemy in hit_list: -             self.health -= 1 -             print(self.health) - ``` 这段代码使用 Pygame 的 `sprite.spritecollide` 方法,建立了一个碰撞检测器,称作 `enemy_hit`。每当它的父类妖精(生成检测器的玩家妖精)的碰撞区触碰到 `enemy_list` 中的任一妖精的碰撞区时,碰撞检测器都会发出一个信号。当这个信号被接收,`for` 循环就会被触发,同时扣除一点玩家生命值。 -一旦这段代码出现在你 Player 类的 `update` 方法,并且 `update` 方法在你的主循环中被调用,Pygame 会在每个时钟 tick 检测一次碰撞。 +一旦这段代码出现在你 `Player` 类的 `update` 方法,并且 `update` 方法在你的主循环中被调用,Pygame 会在每个时钟滴答中检测一次碰撞。 ### 移动敌人 @@ -176,60 +145,41 @@ enemy_list = Level.bad( 1, eloc ) 举个例子,你告诉你的敌方妖精向右移动 10 步,向左移动 10 步。但敌方妖精不会计数,因此你需要创建一个变量来跟踪你的敌人已经移动了多少步,并根据计数变量的值来向左或向右移动你的敌人。 -首先,在你的 Enemy 类中创建计数变量。添加以下代码示例中的最后一行代码: +首先,在你的 `Enemy` 类中创建计数变量。添加以下代码示例中的最后一行代码: + ```         self.rect = self.image.get_rect() -         self.rect.x = x -         self.rect.y = y -         self.counter = 0 # 计数变量 - ``` -然后,在你的 Enemy 类中创建一个 `move` 方法。使用 if-else 循环来创建一个所谓的死循环: +然后,在你的 `Enemy` 类中创建一个 `move` 方法。使用 if-else 循环来创建一个所谓的死循环: * 如果计数在 0 到 100 之间,向右移动; * 如果计数在 100 到 200 之间,向左移动; * 如果计数大于 200,则将计数重置为 0。 - - 死循环没有终点,因为循环判断条件永远为真,所以它将永远循环下去。在此情况下,计数器总是介于 0 到 100 或 100 到 200 之间,因此敌人会永远地从左向右再从右向左移动。 你用于敌人在每个方向上移动距离的具体值,取决于你的屏幕尺寸,更确切地说,取决于你的敌人移动的平台大小。从较小的值开始,依据习惯逐步提高数值。首先进行如下尝试: + ```     def move(self): -         ''' - 敌人移动 -         ''' -         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 - ``` 你可以根据需要调整距离和速度。 @@ -237,13 +187,11 @@ enemy_list = Level.bad( 1, eloc ) 当你现在启动游戏,这段代码有效果吗? 当然不,你应该也知道原因。你必须在主循环中调用 `move` 方法。如下示例代码中的第一行是上下文提示,那么添加最后两行代码: + ```     enemy_list.draw(world) #refresh enemy -     for e in enemy_list: -         e.move() - ``` 启动你的游戏看看当你打击敌人时发生了什么。你可能需要调整妖精的生成地点,使得你的玩家和敌人能够碰撞。当他们发生碰撞时,查看 [IDLE][6] 或 [Ninja-IDE][7] 的控制台,你可以看到生命值正在被扣除。 @@ -261,15 +209,15 @@ via: https://opensource.com/article/18/5/pygame-enemy 作者:[Seth Kenlon][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[cycoe](https://github.com/cycoe) -校对:[校对者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/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 +[1]:https://linux.cn/article-9071-1.html +[2]:https://linux.cn/article-10850-1.html +[3]:https://linux.cn/article-10858-1.html +[4]:https://linux.cn/article-10874-1.html [5]:https://opengameart.org [6]:https://docs.python.org/3/library/idle.html [7]:http://ninja-ide.org/ diff --git a/published/20180605 How to use autofs to mount NFS shares.md b/published/201905/20180605 How to use autofs to mount NFS shares.md similarity index 100% rename from published/20180605 How to use autofs to mount NFS shares.md rename to published/201905/20180605 How to use autofs to mount NFS shares.md diff --git a/published/201905/20180611 3 open source alternatives to Adobe Lightroom.md b/published/201905/20180611 3 open source alternatives to Adobe Lightroom.md new file mode 100644 index 0000000000..4cebea72fa --- /dev/null +++ b/published/201905/20180611 3 open source alternatives to Adobe Lightroom.md @@ -0,0 +1,86 @@ +Adobe Lightroom 的三个开源替代品 +======= + +> 摄影师们:在没有 Lightroom 套件的情况下,可以看看这些 RAW 图像处理器。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/camera-photography-film.jpg?itok=oe2ixyu6) + +如今智能手机的摄像功能已经完备到多数人认为可以代替传统摄影了。虽然这在傻瓜相机的市场中是个事实,但是对于许多摄影爱好者和专业摄影师看来,一个高端单反相机所能带来的照片景深、清晰度以及真实质感是口袋中的智能手机无法与之相比的。 + +所有的这些功能在便利性上要付出一些很小的代价;就像传统的胶片相机中的反色负片,单反照相得到的 RAW 格式文件必须预先处理才能印刷或编辑;因此对于单反相机,照片的后期处理是无可替代的,并且 首选应用就是 Adobe Lightroom。但是由于 Adobe Lightroom 的昂贵价格、基于订阅的定价模式以及专有许可证都使更多人开始关注其开源替代品。 + +Lightroom 有两大主要功能:处理 RAW 格式的图片文件,以及数字资产管理系统(DAM) —— 通过标签、评星以及其他元数据信息来简单清晰地整理照片。 + +在这篇文章中,我们将介绍三个开源的图片处理软件:Darktable、LightZone 以及 RawTherapee。所有的软件都有 DAM 系统,但没有任何一个具有 Lightroom 基于机器学习的图像分类和标签功能。如果你想要知道更多关于开源的 DAM 系统的软件,可以看 Terry Hacock 的文章:“[开源项目的 DAM 管理][2]”,他分享了他在自己的 [Lunatics!][3] 电影项目研究过的开源多媒体软件。 + +### Darktable + +![Darktable][4] + +类似其他两个软件,Darktable 可以处理 RAW 格式的图像并将它们转换成可用的文件格式 —— JPEG、PNG、TIFF、PPM、PFM 和 EXR,它同时支持 Google 和 Facebook 的在线相册,上传至 Flikr,通过邮件附件发送以及创建在线相册。 + +它有 61 个图像处理模块,可以调整图像的对比度、色调、明暗、色彩、噪点;添加水印;切割以及旋转;等等。如同另外两个软件一样,不论你做出多少次修改,这些修改都是“无损的” —— 你的初始 RAW 图像文件始终会被保存。 + +Darktable 可以从 400 多种相机型号中直接导入照片,以及有 JPEG、CR2、DNG、OpenEXR 和 PFM 等格式的支持。图像在一个数据库中显示,因此你可以轻易地过滤并查询这些元数据,包括了文字标签、评星以及颜色标签。软件同时支持 21 种语言,支持 Linux、MacOS、BSD、Solaris 11/GNOME 以及 Windows(Windows 版本是最新发布的,Darktable 声明它比起其他版本可能还有一些不完备之处,有一些未实现的功能)。 + +Darktable 在开源许可证 [GPLv3][7] 下发布,你可以了解更多它的 [特性][8],查阅它的 [用户手册][9],或者直接去 Github 上看[源代码][10] 。 + +### LightZone + +![LightZone's tool stack][11] + +[LightZone][12] 和其他两个软件类似同样是无损的 RAW 格式图像处理工具:它是跨平台的,有 Windows、MacOS 和 Linux 版本,除 RAW 格式之外,它还支持 JPG 和 TIFF 格式的图像处理。接下来说说 LightZone 其他独特特性。 + +这个软件最初在 2005 年时,是以专有许可证发布的图像处理软件,后来在 BSD 证书下开源。此外,在你下载这个软件之前,你必须注册一个免费账号,以便 LightZone的 开发团队可以跟踪软件的下载数量以及建立相关社区。(许可很快,而且是自动的,因此这不是一个很大的使用障碍。) + +除此之外的一个特性是这个软件的图像处理通常是通过很多可组合的工具实现的,而不是叠加滤镜(就像大多数图像处理软件),这些工具组可以被重新编排以及移除,以及被保存并且复制用到另一些图像上。如果想要编辑图片的部分区域,你还可以通过矢量工具或者根据色彩和亮度来选择像素。 + +想要了解更多,见 LightZone 的[论坛][13] 或者查看 Github上的 [源代码][14]。 + +### RawTherapee + +![RawTherapee][15] + +[RawTherapee][16] 是另一个值得关注的开源([GPL][17])的 RAW 图像处理器。就像 Darktable 和 LightZone,它是跨平台的(支持 Windows、MacOS 和 Linux),一切修改都在无损条件下进行,因此不论你叠加多少滤镜做出多少改变,你都可以回到你最初的 RAW 文件。 + +RawTherapee 采用的是一个面板式的界面,包括一个历史记录面板来跟踪你做出的修改,以方便随时回到先前的图像;一个快照面板可以让你同时处理一张照片的不同版本;一个可滚动的工具面板可以方便准确地选择工具。这些工具包括了一系列的调整曝光、色彩、细节、图像变换以及去马赛克功能。 + +这个软件可以从多数相机直接导入 RAW 文件,并且支持超过 25 种语言,得到了广泛使用。批量处理以及 [SSE][18] 优化这类功能也进一步提高了图像处理的速度以及对 CPU 性能的利用。 + +RawTherapee 还提供了很多其他 [功能][19];可以查看它的 [官方文档][20] 以及 [源代码][21] 了解更多细节。 + +你是否在摄影中使用另外的开源 RAW 图像处理工具?有任何建议和推荐都可以在评论中分享。 + +------ + +via: https://opensource.com/alternatives/adobe-lightroom + +作者:[Opensource.com][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[scoutydren](https://github.com/scoutydren) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com +[1]: https://en.wikipedia.org/wiki/Raw_image_format +[2]: https://opensource.com/article/18/3/movie-open-source-software +[3]: http://lunatics.tv/ +[4]: https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/raw-image-processors_darkroom1.jpg?itok=0fjk37tC "Darktable" +[5]: http://www.darktable.org/ +[6]: https://www.darktable.org/about/faq/#faq-windows +[7]: https://github.com/darktable-org/darktable/blob/master/LICENSE +[8]: https://www.darktable.org/about/features/ +[9]: https://www.darktable.org/resources/ +[10]: https://github.com/darktable-org/darktable +[11]: https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/raw-image-processors_lightzone1tookstack.jpg?itok=1e3s85CZ +[12]: http://www.lightzoneproject.org/ +[13]: http://www.lightzoneproject.org/Forum +[14]: https://github.com/ktgw0316/LightZone +[15]: https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/raw-image-processors_rawtherapee.jpg?itok=meiuLxPw "RawTherapee" +[16]: http://rawtherapee.com/ +[17]: https://github.com/Beep6581/RawTherapee/blob/dev/LICENSE.txt +[18]: https://en.wikipedia.org/wiki/Streaming_SIMD_Extensions +[19]: http://rawpedia.rawtherapee.com/Features +[20]: http://rawpedia.rawtherapee.com/Main_Page +[21]: https://github.com/Beep6581/RawTherapee diff --git a/published/201905/20180725 Put platforms in a Python game with Pygame.md b/published/201905/20180725 Put platforms in a Python game with Pygame.md new file mode 100644 index 0000000000..d5f6a910d2 --- /dev/null +++ b/published/201905/20180725 Put platforms in a Python game with Pygame.md @@ -0,0 +1,593 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10902-1.html) +[#]: subject: (Put platforms in a Python game with Pygame) +[#]: via: (https://opensource.com/article/18/7/put-platforms-python-game) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +在 Pygame 游戏中放置平台 +====== + +> 在这个从零构建一个 Python 游戏系列的第六部分中,为你的角色创建一些平台来旅行。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/header.png?itok=iq8HFoEJ) + +这是仍在进行中的关于使用 Pygame 模块来在 Python 3 中创建电脑游戏的系列文章的第六部分。先前的文章是: + ++ [通过构建一个简单的掷骰子游戏去学习怎么用 Python 编程][24] ++ [使用 Python 和 Pygame 模块构建一个游戏框架][25] ++ [如何在你的 Python 游戏中添加一个玩家][26] ++ [用 Pygame 使你的游戏角色移动起来][27] ++ [如何向你的 Python 游戏中添加一个敌人][28] + +一个平台类游戏需要平台。 + +在 [Pygame][1] 中,平台本身也是个妖精,正像你那个可玩的妖精。这一点是重要的,因为有个是对象的平台,可以使你的玩家妖精更容易与之互动。 + +创建平台有两个主要步骤。首先,你必须给该对象编写代码,然后,你必须映射出你希望该对象出现的位置。 + +### 编码平台对象 + +要构建一个平台对象,你要创建一个名为 `Platform` 的类。它是一个妖精,正像你的 `Player` [妖精][2] 一样,带有很多相同的属性。 + +你的 `Platform` 类需要知道很多平台类型的信息,它应该出现在游戏世界的哪里、它应该包含的什么图片等等。这其中很多信息可能还尚不存在,这要看你为你的游戏计划了多少,但是没有关系。正如直到[移动你的游戏角色][3]那篇文章结束时,你都没有告诉你的玩家妖精移动速度有多快,你不必事先告诉 `Platform` 每一件事。 + +在这系列中你所写的脚本的开头附近,创建一个新的类。在这个代码示例中前三行是用于说明上下文,因此在注释的下面添加代码: + +``` +import pygame +import sys +import os +## 新代码如下: + +class Platform(pygame.sprite.Sprite): +# x location, y location, img width, img height, img file     +def __init__(self,xloc,yloc,imgw,imgh,img): +    pygame.sprite.Sprite.__init__(self) +    self.image = pygame.image.load(os.path.join('images',img)).convert() +    self.image.convert_alpha() +    self.image.set_colorkey(ALPHA) +    self.rect = self.image.get_rect() +    self.rect.y = yloc +    self.rect.x = xloc +``` + +当被调用时,这个类在某个 X 和 Y 位置上创建一个屏上对象,具有某种宽度和高度,并使用某种图像作为纹理。这与如何在屏上绘制出玩家或敌人非常类似。 + +### 平台的类型 + +下一步是绘制出你的平台需要出现的地方。 + +#### 瓷砖方式 + +实现平台类游戏世界有几种不同的方法。在最初的横向滚轴游戏中,例如,马里奥超级兄弟和刺猬索尼克,这个技巧是使用“瓷砖”方式,也就是说有几个代表地面和各种平台的块,并且这些块被重复使用来制作一个关卡。你只能有 8 或 12 种不同的块,你可以将它们排列在屏幕上来创建地面、浮动的平台,以及你游戏中需要的一切其它的事物。有人发现这是制作游戏最容易的方法了,因为你只需要制作(或下载)一小组关卡素材就能创建很多不同的关卡。然而,这里的代码需要一点数学知识。 + +![Supertux, a tile-based video game][5] + +*[SuperTux][6] ,一个基于瓷砖的电脑游戏。* + +#### 手工绘制方式 + +另一种方法是将每个素材作为一个整体图像。如果你喜欢为游戏世界创建素材,那你会在用图形应用程序构建游戏世界的每个部分上花费很多时间。这种方法不需要太多的数学知识,因为所有的平台都是整体的、完整的对象,你只需要告诉 [Python][7] 将它们放在屏幕上的什么位置。 + +每种方法都有优势和劣势,并且根据于你选择使用的方式,代码稍有不同。我将覆盖这两方面,所以你可以在你的工程中使用一种或另一种,甚至两者的混合。 + +### 关卡绘制 + +总的来说,绘制你的游戏世界是关卡设计和游戏编程中的一个重要的部分。这需要数学知识,但是没有什么太难的,而且 Python 擅长数学,它会有所帮助。 + +你也许发现先在纸张上设计是有用的。拿一张表格纸,并绘制一个方框来代表你的游戏窗体。在方框中绘制平台,并标记其每一个平台的 X 和 Y 坐标,以及它的宽度和高度。在方框中的实际位置没有必要是精确的,你只要保持数字合理即可。譬如,假设你的屏幕是 720 像素宽,那么你不能在一个屏幕上放 8 块 100 像素的平台。 + +当然,不是你游戏中的所有平台都必须容纳在一个屏幕大小的方框里,因为你的游戏将随着你的玩家行走而滚动。所以,可以继续绘制你的游戏世界到第一屏幕的右侧,直到关卡结束。 + +如果你更喜欢精确一点,你可以使用方格纸。当设计一个瓷砖类的游戏时,这是特别有用的,因为每个方格可以代表一个瓷砖。 + +![Example of a level map][9] + +*一个关卡地图示例。* + +#### 坐标系 + +你可能已经在学校中学习过[笛卡尔坐标系][10]。你学习的东西也适用于 Pygame,除了在 Pygame 中你的游戏世界的坐标系的原点 `0,0` 是放置在你的屏幕的左上角而不是在中间,是你在地理课上用过的坐标是在中间的。 + +![Example of coordinates in Pygame][12] + +*在 Pygame 中的坐标示例。* + +X 轴起始于最左边的 0,向右无限增加。Y 轴起始于屏幕顶部的 0,向下延伸。 + +#### 图片大小 + +如果你不知道你的玩家、敌人、平台是多大的,绘制出一个游戏世界是毫无意义的。你可以在图形程序中找到你的平台或瓷砖的尺寸。例如在 [Krita][13] 中,单击“图像”菜单,并选择“属性”。你可以在“属性”窗口的最顶部处找到它的尺寸。 + +另外,你也可以创建一个简单的 Python 脚本来告诉你的一个图像的尺寸。打开一个新的文本文件,并输入这些代码到其中: + +``` +#!/usr/bin/env python3 + +from PIL import Image +import os.path +import sys + +if len(sys.argv) > 1: +    print(sys.argv[1]) +else: +    sys.exit('Syntax: identify.py [filename]') + +pic = sys.argv[1] +dim = Image.open(pic) +X   = dim.size[0] +Y   = dim.size[1] + +print(X,Y) +``` + +保存该文本文件为 `identify.py`。 + +要使用这个脚本,你必须安装一些额外的 Python 模块,它们包含了这个脚本中新使用的关键字: + +``` +$ pip3 install Pillow --user +``` + +一旦安装好,在你游戏工程目录中运行这个脚本: + +``` +$ python3 ./identify.py images/ground.png +(1080, 97) +``` + +在这个示例中,地面平台的图形的大小是 1080 像素宽和 97 像素高。 + +### 平台块 + +如果你选择单独地绘制每个素材,你必须创建想要插入到你的游戏世界中的几个平台和其它元素,每个素材都放在它自己的文件中。换句话说,你应该让每个素材都有一个文件,像这样: + +![One image file per object][15] + +*每个对象一个图形文件。* + +你可以按照你希望的次数重复使用每个平台,只要确保每个文件仅包含一个平台。你不能使用一个文件包含全部素材,像这样: + +![Your level cannot be one image file][17] + +*你的关卡不能是一个图形文件。* + +当你完成时,你可能希望你的游戏看起来像这样,但是如果你在一个大文件中创建你的关卡,你就没有方法从背景中区分出一个平台,因此,要么把对象绘制在它们自己的文件中,要么从一个更大的文件中裁剪出它们,并保存为单独的副本。 + +**注意:** 如同你的其它素材,你可以使用 [GIMP][18]、Krita、[MyPaint][19],或 [Inkscape][20] 来创建你的游戏素材。 + +平台出现在每个关卡开始的屏幕上,因此你必须在你的 `Level` 类中添加一个 `platform` 函数。在这里特例是地面平台,它重要到应该拥有它自己的一个组。通过把地面看作一组特殊类型的平台,你可以选择它是否滚动,或它上面是否可以站立,而其它平台可以漂浮在它上面。这取决于你。 + +添加这两个函数到你的 `Level` 类: + +``` +def ground(lvl,x,y,w,h): +    ground_list = pygame.sprite.Group() +    if lvl == 1: +        ground = Platform(x,y,w,h,'block-ground.png') +        ground_list.add(ground) + +    if lvl == 2: +        print("Level " + str(lvl) ) + +    return ground_list + +def platform( lvl ): +    plat_list = pygame.sprite.Group() +    if lvl == 1: +        plat = Platform(200, worldy-97-128, 285,67,'block-big.png') +        plat_list.add(plat) +        plat = Platform(500, worldy-97-320, 197,54,'block-small.png') +        plat_list.add(plat) +    if lvl == 2: +        print("Level " + str(lvl) ) +        +    return plat_list +``` + +`ground` 函数需要一个 X 和 Y 位置,以便 Pygame 知道在哪里放置地面平台。它也需要知道平台的宽度和高度,这样 Pygame 知道地面延伸到每个方向有多远。该函数使用你的 `Platform` 类来生成一个屏上对象,然后将这个对象添加到 `ground_list` 组。 + +`platform` 函数本质上是相同的,除了其有更多的平台。在这个示例中,仅有两个平台,但是你可以想有多少就有多少。在进入一个平台后,在列出另一个前你必须添加它到 `plat_list` 中。如果你不添加平台到组中,那么它将不出现在你的游戏中。 + +> **提示:** 很难想象你的游戏世界的 0 是在顶部,因为在真实世界中发生的情况是相反的;当估计你有多高时,你不会从上往下测量你自己,而是从脚到头顶来测量。 +> +> 如果对你来说从“地面”上来构建你的游戏世界更容易,将 Y 轴值表示为负数可能有帮助。例如,你知道你的游戏世界的底部是 `worldy` 的值。因此 `worldy` 减去地面的高度(在这个示例中是 97)是你的玩家正常站立的位置。如果你的角色是 64 像素高,那么地面减去 128 正好是你的玩家的两倍高。事实上,一个放置在 128 像素处平台大约是相对于你的玩家的两层楼高度。一个平台在 -320 处比三层楼更高。等等。 + +正像你现在可能所知的,如果你不使用它们,你的类和函数是没有价值的。添加这些代码到你的设置部分(第一行只是上下文,所以添加最后两行): + +``` +enemy_list  = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,0,worldy-97,1080,97 ) +plat_list   = Level.platform( 1 ) +``` + +并把这些行加到你的主循环(再一次,第一行仅用于上下文): + +``` +enemy_list.draw(world)  # 刷新敌人 +ground_list.draw(world)  # 刷新地面 +plat_list.draw(world)  # 刷新平台 +``` + +### 瓷砖平台 + +瓷砖类游戏世界更容易制作,因为你只需要在前面绘制一些块,就能在游戏中一再使用它们创建每个平台。在像 [OpenGameArt.org][21] 这样的网站上甚至有一套瓷砖供你来使用。 + +`Platform` 类与在前面部分中的类是相同的。 + +`ground` 和 `platform` 在 `Level` 类中,然而,必须使用循环来计算使用多少块来创建每个平台。 + +如果你打算在你的游戏世界中有一个坚固的地面,这种地面是很简单的。你只需要从整个窗口的一边到另一边“克隆”你的地面瓷砖。例如,你可以创建一个 X 和 Y 值的列表来规定每个瓷砖应该放置的位置,然后使用一个循环来获取每个值并绘制每一个瓷砖。这仅是一个示例,所以不要添加这到你的代码: + +``` +# Do not add this to your code +gloc = [0,656,64,656,128,656,192,656,256,656,320,656,384,656] +``` + +不过,如果你仔细看,你可以看到所有的 Y 值是相同的,X 值以 64 的增量不断地增加 —— 这就是瓷砖的大小。这种重复是精确地,是计算机擅长的,因此你可以使用一点数学逻辑来让计算机为你做所有的计算: + +添加这些到你的脚本的设置部分: + +``` +gloc = [] +tx   = 64 +ty   = 64 + +i=0 +while i <= (worldx/tx)+tx: +    gloc.append(i*tx) +    i=i+1 + +ground_list = Level.ground( 1,gloc,tx,ty ) +``` + +现在,不管你的窗口的大小,Python 会通过瓷砖的宽度分割游戏世界的宽度,并创建一个数组列表列出每个 X 值。这里不计算 Y 值,因为在平的地面上这个从不会变化。 + +为了在一个函数中使用数组,使用一个 `while` 循环,查看每个条目并在适当的位置添加一个地面瓷砖: + +``` +def ground(lvl,gloc,tx,ty): +    ground_list = pygame.sprite.Group() +    i=0 +    if lvl == 1: +        while i < len(gloc): +            ground = Platform(gloc[i],worldy-ty,tx,ty,'tile-ground.png') +            ground_list.add(ground) +            i=i+1 + +    if lvl == 2: +        print("Level " + str(lvl) ) + +    return ground_list +``` + +除了 `while` 循环,这几乎与在上面一部分中提供的瓷砖类平台的 `ground` 函数的代码相同。 + +对于移动的平台,原理是相似的,但是这里有一些技巧可以使它简单。 + +你可以通过它的起始像素(它的 X 值)、距地面的高度(它的 Y 值)、绘制多少瓷砖来定义一个平台,而不是通过像素绘制每个平台。这样,你不必操心每个平台的宽度和高度。 + +这个技巧的逻辑有一点复杂,因此请仔细复制这些代码。有一个 `while` 循环嵌套在另一个 `while` 循环的内部,因为这个函数必须考虑每个数组项的三个值来成功地建造一个完整的平台。在这个示例中,这里仅有三个平台以 `ploc.append` 语句定义,但是你的游戏可能需要更多,因此你需要多少就定义多少。当然,有一些不会出现,因为它们远在屏幕外,但是一旦当你进行滚动时,它们将呈现在眼前。 + +``` +def platform(lvl,tx,ty): +    plat_list = pygame.sprite.Group() +    ploc = [] +    i=0 +    if lvl == 1: +        ploc.append((200,worldy-ty-128,3)) +        ploc.append((300,worldy-ty-256,3)) +        ploc.append((500,worldy-ty-128,4)) +        while i < len(ploc): +            j=0 +            while j <= ploc[i][2]: +                plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'tile.png') +                plat_list.add(plat) +                j=j+1 +            print('run' + str(i) + str(ploc[i])) +            i=i+1 +            +    if lvl == 2: +        print("Level " + str(lvl) ) + +    return plat_list +``` + +要让这些平台出现在你的游戏世界,它们必须出现在你的主循环中。如果你还没有这样做,添加这些行到你的主循环(再一次,第一行仅被用于上下文)中: + +``` +        enemy_list.draw(world)  # 刷新敌人 +        ground_list.draw(world) # 刷新地面 +        plat_list.draw(world)   # 刷新平台 +``` + +启动你的游戏,根据需要调整你的平台的放置位置。如果你看不见屏幕外产生的平台,不要担心;你不久后就可以修复它。 + +到目前为止,这是游戏的图片和代码: + +![Pygame game][23] + +*到目前为止,我们的 Pygame 平台。* + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved.  This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): +    # x location, y location, img width, img height, img file     +    def __init__(self,xloc,yloc,imgw,imgh,img): +        pygame.sprite.Sprite.__init__(self) +        self.image = pygame.image.load(os.path.join('images',img)).convert() +        self.image.convert_alpha() +        self.rect = self.image.get_rect() +        self.rect.y = yloc +        self.rect.x = xloc + +class Player(pygame.sprite.Sprite): +    ''' +    Spawn a player +    ''' +    def __init__(self): +        pygame.sprite.Sprite.__init__(self) +        self.movex = 0 +        self.movey = 0 +        self.frame = 0 +        self.health = 10 +        self.score = 1 +        self.images = [] +        for i in range(1,9): +            img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() +            img.convert_alpha() +            img.set_colorkey(ALPHA) +            self.images.append(img) +            self.image = self.images[0] +            self.rect  = self.image.get_rect() + +    def control(self,x,y): +        ''' +        control player movement +        ''' +        self.movex += x +        self.movey += y + +    def update(self): +        ''' +        Update sprite position +        ''' + +        self.rect.x = self.rect.x + self.movex +        self.rect.y = self.rect.y + self.movey + +        # moving left +        if self.movex < 0: +            self.frame += 1 +            if self.frame > ani*3: +                self.frame = 0 +            self.image = self.images[self.frame//ani] + +        # moving right +        if self.movex > 0: +            self.frame += 1 +            if self.frame > ani*3: +                self.frame = 0 +            self.image = self.images[(self.frame//ani)+4] + +        # collisions +        enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) +        for enemy in enemy_hit_list: +            self.health -= 1 +            print(self.health) + +        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) +        for g in ground_hit_list: +            self.health -= 1 +            print(self.health) + + +class Enemy(pygame.sprite.Sprite): +    ''' +    Spawn an enemy +    ''' +    def __init__(self,x,y,img): +        pygame.sprite.Sprite.__init__(self) +        self.image = pygame.image.load(os.path.join('images',img)) +        #self.image.convert_alpha() +        #self.image.set_colorkey(ALPHA) +        self.rect = self.image.get_rect() +        self.rect.x = x +        self.rect.y = y +        self.counter = 0 + +    def move(self): +        ''' +        enemy movement +        ''' +        distance = 80 +        speed = 8 + +        if self.counter >= 0 and self.counter <= distance: +            self.rect.x += speed +        elif self.counter >= distance and self.counter <= distance*2: +            self.rect.x -= speed +        else: +            self.counter = 0 + +        self.counter += 1 + +class Level(): +    def bad(lvl,eloc): +        if lvl == 1: +            enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy +            enemy_list = pygame.sprite.Group() # create enemy group +            enemy_list.add(enemy)              # add enemy to group + +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return enemy_list + +    def loot(lvl,lloc): +        print(lvl) + +    def ground(lvl,gloc,tx,ty): +        ground_list = pygame.sprite.Group() +        i=0 +        if lvl == 1: +            while i < len(gloc): +                print("blockgen:" + str(i)) +                ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') +                ground_list.add(ground) +                i=i+1 + +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return ground_list + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # frame rate +ani = 4  # animation cycles +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE  = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # spawn player +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 # how fast to move + +eloc = [] +eloc = [200,20] +gloc = [] +#gloc = [0,630,64,630,128,630,192,630,256,630,320,630,384,630] +tx = 64 #tile size +ty = 64 #tile size + +i=0 +while i <= (worldx/tx)+tx: +    gloc.append(i*tx) +    i=i+1 +    print("block: " + str(i)) + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) + +''' +Main loop +''' +while main == True: +    for event in pygame.event.get(): +        if event.type == pygame.QUIT: +            pygame.quit(); sys.exit() +            main = False + +        if event.type == pygame.KEYDOWN: +            if event.key == pygame.K_LEFT or event.key == ord('a'): +                player.control(-steps,0) +            if event.key == pygame.K_RIGHT or event.key == ord('d'): +                player.control(steps,0) +            if event.key == pygame.K_UP or event.key == ord('w'): +                print('jump') + +        if event.type == pygame.KEYUP: +            if event.key == pygame.K_LEFT or event.key == ord('a'): +                player.control(steps,0) +            if event.key == pygame.K_RIGHT or event.key == ord('d'): +                player.control(-steps,0) +            if event.key == ord('q'): +                pygame.quit() +                sys.exit() +                main = False + +#    world.fill(BLACK) +    world.blit(backdrop, backdropbox) +    player.update() +    player_list.draw(world) #refresh player position +    enemy_list.draw(world)  # refresh enemies +    ground_list.draw(world)  # refresh enemies +    for e in enemy_list: +        e.move() +    pygame.display.flip() +    clock.tick(fps) +``` + +(LCTT 译注:到本文翻译完为止,该系列已经近一年没有继续更新了~) + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/7/put-platforms-python-game + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://www.pygame.org/news +[2]: https://opensource.com/article/17/12/game-python-add-a-player +[3]: https://opensource.com/article/17/12/game-python-moving-player +[4]: /file/403841 +[5]: https://opensource.com/sites/default/files/uploads/supertux.png (Supertux, a tile-based video game) +[6]: https://www.supertux.org/ +[7]: https://www.python.org/ +[8]: /file/403861 +[9]: https://opensource.com/sites/default/files/uploads/layout.png (Example of a level map) +[10]: https://en.wikipedia.org/wiki/Cartesian_coordinate_system +[11]: /file/403871 +[12]: https://opensource.com/sites/default/files/uploads/pygame_coordinates.png (Example of coordinates in Pygame) +[13]: https://krita.org/en/ +[14]: /file/403876 +[15]: https://opensource.com/sites/default/files/uploads/pygame_floating.png (One image file per object) +[16]: /file/403881 +[17]: https://opensource.com/sites/default/files/uploads/pygame_flattened.png (Your level cannot be one image file) +[18]: https://www.gimp.org/ +[19]: http://mypaint.org/about/ +[20]: https://inkscape.org/en/ +[21]: https://opengameart.org/content/simplified-platformer-pack +[22]: /file/403886 +[23]: https://opensource.com/sites/default/files/uploads/pygame_platforms.jpg (Pygame game) +[24]: https://linux.cn/article-9071-1.html +[25]: https://linux.cn/article-10850-1.html +[26]: https://linux.cn/article-10858-1.html +[27]: https://linux.cn/article-10874-1.html +[28]: https://linux.cn/article-10883-1.html + diff --git a/published/20181212 TLP - An Advanced Power Management Tool That Improve Battery Life On Linux Laptop.md b/published/201905/20181212 TLP - An Advanced Power Management Tool That Improve Battery Life On Linux Laptop.md similarity index 100% rename from published/20181212 TLP - An Advanced Power Management Tool That Improve Battery Life On Linux Laptop.md rename to published/201905/20181212 TLP - An Advanced Power Management Tool That Improve Battery Life On Linux Laptop.md diff --git a/translated/tech/20181218 Using Pygame to move your game character around.md b/published/201905/20181218 Using Pygame to move your game character around.md similarity index 86% rename from translated/tech/20181218 Using Pygame to move your game character around.md rename to published/201905/20181218 Using Pygame to move your game character around.md index 5d94f6a620..9605601ad7 100644 --- a/translated/tech/20181218 Using Pygame to move your game character around.md +++ b/published/201905/20181218 Using Pygame to move your game character around.md @@ -1,15 +1,16 @@ [#]: collector: (lujun9972) [#]: translator: (cycoe) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10874-1.html) [#]: subject: (Using Pygame to move your game character around) [#]: via: (https://opensource.com/article/17/12/game-python-moving-player) [#]: author: (Seth Kenlon https://opensource.com/users/seth) 用 Pygame 使你的游戏角色移动起来 ====== -在本系列的第四部分,学习如何编写移动游戏角色的控制代码。 +> 在本系列的第四部分,学习如何编写移动游戏角色的控制代码。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python4-game.png?itok=tXFHaLdt) 在这个系列的第一篇文章中,我解释了如何使用 Python 创建一个简单的[基于文本的骰子游戏][1]。在第二部分中,我向你们展示了如何从头开始构建游戏,即从 [创建游戏的环境][2] 开始。然后在第三部分,我们[创建了一个玩家妖精][3],并且使它在你的(而不是空的)游戏世界内生成。你可能已经注意到,如果你不能移动你的角色,那么游戏不是那么有趣。在本篇文章中,我们将使用 Pygame 来添加键盘控制,如此一来你就可以控制你的角色的移动。 @@ -18,7 +19,7 @@ 在本系列的第二篇文章中,你已经为退出游戏创建了一个按键,移动角色的(按键)原则也是相同的。但是,使你的角色移动起来要稍微复杂一点。 -让我们从简单的部分入手:设置控制器按键 +让我们从简单的部分入手:设置控制器按键。 ### 为控制你的玩家妖精设置按键 @@ -56,11 +57,11 @@ while main == True:                 main = False     ``` -一些人偏好使用键盘字母 W、A、S 和 D 来控制玩家角色,而另一些偏好使用方向键。因此确保你包含了两种选项。 +一些人偏好使用键盘字母 `W`、`A`、`S` 和 `D` 来控制玩家角色,而另一些偏好使用方向键。因此确保你包含了两种选项。 -**注意:**当你在编程时,同时考虑所有用户是非常重要的。如果你写代码只是为了自己运行,那么很可能你会成为你写的程序的唯一用户。更重要的是,如果你想找一个通过写代码赚钱的工作,你写的代码就应该让所有人都能运行。给你的用户选择权,比如提供使用方向键或 WASD 的选项,是一个优秀程序员的标志。 +注意:当你在编程时,同时考虑所有用户是非常重要的。如果你写代码只是为了自己运行,那么很可能你会成为你写的程序的唯一用户。更重要的是,如果你想找一个通过写代码赚钱的工作,你写的代码就应该让所有人都能运行。给你的用户选择权,比如提供使用方向键或 WASD 的选项,是一个优秀程序员的标志。 -使用 Python 启动你的游戏,并在你按下“上下左右”方向键或 A、D 和 W 键的时候查看控制台窗口的输出。 +使用 Python 启动你的游戏,并在你按下“上下左右”方向键或 `A`、`D` 和 `W` 键的时候查看控制台窗口的输出。 ``` $ python ./your-name_game.py @@ -77,9 +78,9 @@ $ python ./your-name_game.py 为了使你的妖精移动起来,你必须为你的妖精创建一个属性代表移动。当你的妖精没有在移动时,这个变量被设为 `0`。 -如果你正在为你的妖精设置动画,或者你决定在将来为他设置动画,你还必须跟踪帧来使走路循环保持在轨迹上。 +如果你正在为你的妖精设置动画,或者你决定在将来为它设置动画,你还必须跟踪帧来使走路循环保持在轨迹上。 -在 Player 类中创建如下变量。开头两行作为上下文对照(如果你一直跟着做,你的代码中就已经有这两行),因此只需要添加最后三行: +在 `Player` 类中创建如下变量。开头两行作为上下文对照(如果你一直跟着做,你的代码中就已经有这两行),因此只需要添加最后三行: ```     def __init__(self): @@ -91,9 +92,9 @@ $ python ./your-name_game.py 设置好了这些变量,是时候去为妖精移动编写代码了。 -玩家妖精不需要时刻响应控制,优势它并没有在移动。控制妖精的代码,仅仅只是玩家妖精所有能做的事情中的一小部分。在 Python 中,当你想要使一个对象做某件事并独立于剩余其他代码时,你可以将你的新代码放入一个函数。Python 的函数以关键词 `def` 开头,(该关键词)代表了定义函数。 +玩家妖精不需要时刻响应控制,有时它并没有在移动。控制妖精的代码,仅仅只是玩家妖精所有能做的事情中的一小部分。在 Python 中,当你想要使一个对象做某件事并独立于剩余其他代码时,你可以将你的新代码放入一个函数。Python 的函数以关键词 `def` 开头,(该关键词)代表了定义函数。 -在你的 Player 类中创建如下函数,来为你的妖精在屏幕上的位置增加几个像素。现在先不要担心你增加几个像素,这将在后续的代码中确定。 +在你的 `Player` 类中创建如下函数,来为你的妖精在屏幕上的位置增加几个像素。现在先不要担心你增加几个像素,这将在后续的代码中确定。 ```     def control(self,x,y): @@ -154,7 +155,7 @@ steps = 10  # 移动多少个像素 现在你已经有了适当的函数和变量,使用你的按键来触发函数并将变量传递给你的妖精。 -为此,将主循环中的 `print` 语句替换为玩家妖精的名字(player)、函数(.control)以及你希望玩家妖精在每个循环中沿 X 轴和 Y 轴移动的步数。 +为此,将主循环中的 `print` 语句替换为玩家妖精的名字(`player`)、函数(`.control`)以及你希望玩家妖精在每个循环中沿 X 轴和 Y 轴移动的步数。 ```         if event.type == pygame.KEYDOWN: @@ -176,7 +177,7 @@ steps = 10  # 移动多少个像素                 main = False ``` -记住,`steps` 变量代表了当一个按键被按下时,你的妖精会移动多少个像素。如果当你按下 D 或右方向键时,你的妖精的位置增加了 10 个像素。那么当你停止按下这个键时,你必须(将 `step`)减 10(`-steps`)来使你的妖精的动量回到 0。 +记住,`steps` 变量代表了当一个按键被按下时,你的妖精会移动多少个像素。如果当你按下 `D` 或右方向键时,你的妖精的位置增加了 10 个像素。那么当你停止按下这个键时,你必须(将 `step`)减 10(`-steps`)来使你的妖精的动量回到 0。 现在尝试你的游戏。注意:它不会像你预想的那样运行。 @@ -340,14 +341,14 @@ via: https://opensource.com/article/17/12/game-python-moving-player 作者:[Seth Kenlon][a] 选题:[lujun9972][b] 译者:[cycoe](https://github.com/cycoe) -校对:[校对者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/seth [b]: https://github.com/lujun9972 -[1]: https://opensource.com/article/17/10/python-101 -[2]: https://opensource.com/article/17/12/program-game-python-part-2-creating-game-world -[3]: https://opensource.com/article/17/12/program-game-python-part-3-spawning-player +[1]: https://linux.cn/article-9071-1.html +[2]: https://linux.cn/article-10850-1.html +[3]: https://linux.cn/article-10858-1.html [4]: http://pygame.org/docs/ref/joystick.html [5]: http://pygame.org/docs/ref/mouse.html#module-pygame.mouse diff --git a/published/201905/20190107 Aliases- To Protect and Serve.md b/published/201905/20190107 Aliases- To Protect and Serve.md new file mode 100644 index 0000000000..60299f61c5 --- /dev/null +++ b/published/201905/20190107 Aliases- To Protect and Serve.md @@ -0,0 +1,172 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10918-1.html) +[#]: subject: (Aliases: To Protect and Serve) +[#]: via: (https://www.linux.com/blog/learn/2019/1/aliases-protect-and-serve) +[#]: author: (Paul Brown https://www.linux.com/users/bro66) + +命令别名:保护和服务 +====== + +> Linux shell 允许你将命令彼此链接在一起,一次触发执行复杂的操作,并且可以对此创建别名作为快捷方式。 + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/prairie-path_1920.jpg?itok=wRARsM7p) + +让我们将继续我们的别名系列。到目前为止,你可能已经阅读了我们的[关于别名的第一篇文章][1],并且应该非常清楚它们是如何为你省去很多麻烦的最简单方法。例如,你已经看到它们帮助我们减少了输入,让我们看看别名派上用场的其他几个案例。 + +### 别名即快捷方式 + +Linux shell 最美妙的事情之一是可以使用数以万计的选项和把命令连接在一起执行真正复杂的操作。好吧,也许这种美丽是在旁观者的眼中的,但是我们觉得这个功能很实用。 + +不利的一面是,你经常需要记得难以记忆或难以打字出来的命令组合。比如说硬盘上的空间非常宝贵,而你想要做一些清洁工作。你的第一步可能是寻找隐藏在你的家目录里的东西。你可以用来判断的一个标准是查找不再使用的内容。`ls` 可以帮助你: + +``` +ls -lct +``` + +上面的命令显示了每个文件和目录的详细信息(`-l`),并显示了每一项上次访问的时间(`-c`),然后它按从最近访问到最少访问的顺序排序这个列表(`-t`)。 + +这难以记住吗?你可能不会每天都使用 `-c` 和 `-t` 选项,所以也许是吧。无论如何,定义一个别名,如: + +``` +alias lt='ls -lct' +``` + +会更容易一些。 + +然后,你也可能希望列表首先显示最旧的文件: + +``` +alias lo='lt -F | tac' +``` + +![aliases][3] + +*图 1:使用 lt 和 lo 别名。* + +这里有一些有趣的事情。首先,我们使用别名(`lt`)来创建另一个别名 —— 这是完全可以的。其次,我们将一个新参数传递给 `lt`(后者又通过 `lt` 别名的定义传递给了 `ls`)。 + +`-F` 选项会将特殊符号附加到项目的名称后,以便更好地区分常规文件(没有符号)和可执行文件(附加了 `*`)、目录文件(以 `/` 结尾),以及所有链接文件、符号链接文件(以 `@` 符号结尾)等等。`-F` 选项是当你回归到单色终端的日子里,没有其他方法可以轻松看到列表项之间的差异时用的。在这里使用它是因为当你将输出从 `lt` 传递到 `tac` 时,你会丢失 `ls` 的颜色。 + +第三件我们需要注意的事情是我们使用了管道。管道用于你将一个命令的输出传递给另外一个命令时。第二个命令可以使用这些输出作为它的输入。在包括 Bash 在内的许多 shell 里,你可以使用管道符(`|`) 来做传递。 + +在这里,你将来自 `lt -F` 的输出导给 `tac`。`tac` 这个命令有点玩笑的意思,你或许听说过 `cat` 命令,它名义上用于将文件彼此连接(con`cat`),而在实践中,它被用于将一个文件的内容打印到终端。`tac` 做的事情一样,但是它是以逆序将接收到的内容输出出来。明白了吗?`cat` 和 `tac`,技术人有时候也挺有趣的。 + +`cat` 和 `tac` 都能输出通过管道传递过来的内容,在这里,也就是一个按时间顺序排序的文件列表。 + +那么,在有些离题之后,最终我们得到的就是这个列表将当前目录中的文件和目录以新鲜度的逆序列出(即老的在前)。 + +最后你需要注意的是,当在当前目录或任何目录运行 `lt` 时: + +``` +# 这可以工作: +lt +# 这也可以: +lt /some/other/directory +``` + +……而 `lo` 只能在当前目录奏效: + +``` +# 这可工作: +lo +# 而这不行: +lo /some/other/directory +``` + +这是因为 Bash 会展开别名的组分。当你键入: + +``` +lt /some/other/directory +``` + +Bash 实际上运行的是: + +``` +ls -lct /some/other/directory +``` + +这是一个有效的 Bash 命令。 + +而当你键入: + +``` +lo /some/other/directory +``` + +Bash 试图运行: + +``` +ls -lct -F | tac /some/other/directory +``` + +这不是一个有效的命令,主要是因为 `/some/other/directory` 是个目录,而 `cat` 和 `tac` 不能用于目录。 + +### 更多的别名快捷方式 + + * `alias lll='ls -R'` 会打印出目录的内容,并深入到子目录里面打印子目录的内容,以及子目录的子目录,等等。这是一个查看一个目录下所有内容的方式。 + * `mkdir='mkdir -pv'` 可以让你一次性创建目录下的目录。按照 `mkdir` 的基本形式,要创建一个包含子目录的目录,你必须这样: + +``` +mkdir newdir +mkdir newdir/subdir +``` + +或这样: + +``` +mkdir -p newdir/subdir +``` + +而用这个别名你将只需要这样就行: + +``` +mkdir newdir/subdir +``` + +你的新 `mkdir` 也会告诉你创建子目录时都做了什么。 + +### 别名也是一种保护 + +别名的另一个好处是它可以作为防止你意外地删除或覆写已有的文件的保护措施。你可能听说过这个 Linux 新用户的传言,当他们以 root 身份运行: + +``` +rm -rf / +``` + +整个系统就爆了。而决定输入如下命令的用户: + +``` +rm -rf /some/directory/ * +``` + +就很好地干掉了他们的家目录的全部内容。这里不小心键入的目录和 `*` 之间的那个空格有时候很容易就会被忽视掉。 + +这两种情况我们都可以通过 `alias rm='rm -i'` 别名来避免。`-i` 选项会使 `rm` 询问用户是否真的要做这个操作,在你对你的文件系统做出不可弥补的损失之前给你第二次机会。 + +对于 `cp` 也是一样,它能够覆盖一个文件而不会给你任何提示。创建一个类似 `alias cp='cp -i'` 来保持安全吧。 + +### 下一次 + +我们越来越深入到了脚本领域,下一次,我们将沿着这个方向,看看如何在命令行组合命令以给你真正的乐趣,并可靠地解决系统管理员每天面临的问题。 + + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2019/1/aliases-protect-and-serve + +作者:[Paul Brown][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/bro66 +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-10377-1.html +[2]: https://www.linux.com/files/images/fig01png-0 +[3]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/fig01_0.png?itok=crqTm_va (aliases) +[4]: https://www.linux.com/licenses/category/used-permission diff --git a/published/20190307 How to Restart a Network in Ubuntu -Beginner-s Tip.md b/published/201905/20190307 How to Restart a Network in Ubuntu -Beginner-s Tip.md similarity index 100% rename from published/20190307 How to Restart a Network in Ubuntu -Beginner-s Tip.md rename to published/201905/20190307 How to Restart a Network in Ubuntu -Beginner-s Tip.md diff --git a/translated/tech/20190308 Virtual filesystems in Linux- Why we need them and how they work.md b/published/201905/20190308 Virtual filesystems in Linux- Why we need them and how they work.md similarity index 56% rename from translated/tech/20190308 Virtual filesystems in Linux- Why we need them and how they work.md rename to published/201905/20190308 Virtual filesystems in Linux- Why we need them and how they work.md index cac4eb99b7..8ffd7c6ab0 100644 --- a/translated/tech/20190308 Virtual filesystems in Linux- Why we need them and how they work.md +++ b/published/201905/20190308 Virtual filesystems in Linux- Why we need them and how they work.md @@ -1,20 +1,20 @@ [#]: collector: (lujun9972) [#]: translator: (wxy) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10884-1.html) [#]: subject: (Virtual filesystems in Linux: Why we need them and how they work) [#]: via: (https://opensource.com/article/19/3/virtual-filesystems-linux) [#]: author: (Alison Chariken ) -Linux 中的虚拟文件系统 +详解 Linux 中的虚拟文件系统 ====== > 虚拟文件系统是一种神奇的抽象,它使得 “一切皆文件” 哲学在 Linux 中成为了可能。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/documents_papers_file_storage_work.png?itok=YlXpAqAJ) -什么是文件系统?根据早期的 Linux 贡献者和作家 [Robert Love][1] 所说,“文件系统是一个遵循特定结构的数据的分层存储。” 不过,这种描述也同样适用于 VFAT(虚拟文件分配表)、Git 和[Cassandra][2](一种 [NoSQL 数据库][3])。那么如何区别文件系统呢? +什么是文件系统?根据早期的 Linux 贡献者和作家 [Robert Love][1] 所说,“文件系统是一个遵循特定结构的数据的分层存储。” 不过,这种描述也同样适用于 VFAT(虚拟文件分配表Virtual File Allocation Table)、Git 和[Cassandra][2](一种 [NoSQL 数据库][3])。那么如何区别文件系统呢? ### 文件系统基础概念 @@ -22,72 +22,73 @@ Linux 内核要求文件系统必须是实体,它还必须在持久对象上 ![][5] -如果我们能够 `open()`、`read()` 和 `write()`,它就是一个文件,如这个主控台会话所示。 +*如果我们能够 `open()`、`read()` 和 `write()`,它就是一个文件,如这个主控台会话所示。* -VFS 是著名的类 Unix 系统中 “一切皆文件” 的基础。让我们看一下它有多奇怪,上面的小演示体现了字符设备 `/dev/console` 实际的工作。该图显示了一个在虚拟电传打字(tty)上的交互式 Bash 会话。将一个字符串发送到虚拟控制台设备会使其显示在虚拟屏幕上。而 VFS 甚至还有其它更奇怪的属性。例如,它[可以在其中寻址][6]。 +VFS 是著名的类 Unix 系统中 “一切皆文件” 概念的基础。让我们看一下它有多奇怪,上面的小小演示体现了字符设备 `/dev/console` 实际的工作。该图显示了一个在虚拟电传打字控制台(tty)上的交互式 Bash 会话。将一个字符串发送到虚拟控制台设备会使其显示在虚拟屏幕上。而 VFS 甚至还有其它更奇怪的属性。例如,它[可以在其中寻址][6]。 -熟悉的文件系统如 ext4、NFS 和 /proc 在名为 [file_operations] [7] 的 C 语言数据结构中都提供了三大函数的定义。此外,特定的文件系统会以熟悉的面向对象的方式扩展和覆盖了 VFS 功能。正如 Robert Love 指出的那样,VFS 的抽象使 Linux 用户可以轻松地将文件复制到(复制自)外部操作系统或抽象实体(如管道),而无需担心其内部数据格式。在用户空间,通过系统调用,进程可以使用一个文件系统的 `read()`方法从文件复制到内核的数据结构中,然后使用另一种文件系统的 `write()` 方法输出数据。 +我们熟悉的文件系统如 ext4、NFS 和 /proc 都在名为 [file_operations] [7] 的 C 语言数据结构中提供了三大函数的定义。此外,个别的文件系统会以熟悉的面向对象的方式扩展和覆盖了 VFS 功能。正如 Robert Love 指出的那样,VFS 的抽象使 Linux 用户可以轻松地将文件复制到(或复制自)外部操作系统或抽象实体(如管道),而无需担心其内部数据格式。在用户空间这一侧,通过系统调用,进程可以使用文件系统方法之一 `read()` 从文件复制到内核的数据结构中,然后使用另一种文件系统的方法 `write()` 输出数据。 -属于 VFS 基本类型的函数定义本身可以在内核源代码的 [fs/*.c 文件][8] 中找到,而 `fs/` 的子目录中包含了特定的文件系统。内核还包含了类似文件系统的实体,例如 cgroup、`/dev` 和 tmpfs,它们在引导过程的早期需要,因此定义在内核的 `init/` 子目录中。请注意,cgroup、`/dev` 和 tmpfs 不会调用 `file_operations` 的三大函数,而是直接读取和写入内存。 +属于 VFS 基本类型的函数定义本身可以在内核源代码的 [fs/*.c 文件][8] 中找到,而 `fs/` 的子目录中包含了特定的文件系统。内核还包含了类似文件系统的实体,例如 cgroup、`/dev` 和 tmpfs,在引导过程的早期需要它们,因此定义在内核的 `init/` 子目录中。请注意,cgroup、`/dev` 和 tmpfs 不会调用 `file_operations` 的三大函数,而是直接读取和写入内存。 -下图大致说明了用户空间如何访问通常挂载在 Linux 系统上的各种类型的文件系统。未显示的是像管道、dmesg 和 POSIX 时钟这样的结构,它们也实现了 `struct file_operations`,并且因此其访问要通过 VFS 层。 +下图大致说明了用户空间如何访问通常挂载在 Linux 系统上的各种类型文件系统。像管道、dmesg 和 POSIX 时钟这样的结构在此图中未显示,它们也实现了 `struct file_operations`,而且其访问也要通过 VFS 层。 ![How userspace accesses various types of filesystems][9] -VFS 是系统调用和特定 `file_operations` 的实现(如 ext4 和 procfs)之间的“垫片层”。然后,`file_operations` 函数可以与特定于设备的驱动程序或内存访问器进行通信。tmpfs、devtmpfs 和 cgroup 不使用 `file_operations` 而是直接访问内存。 +VFS 是个“垫片层”,位于系统调用和特定 `file_operations` 的实现(如 ext4 和 procfs)之间。然后,`file_operations` 函数可以与特定于设备的驱动程序或内存访问器进行通信。tmpfs、devtmpfs 和 cgroup 不使用 `file_operations` 而是直接访问内存。 -VFS 的存在促进了代码重用,因为与文件系统相关的基本方法不需要由每种文件系统类型重新实现。代码重用是一种被广泛接受的软件工程最佳实践!唉,如果重用的代码[引入了严重的错误][10],那么继承常用方法的所有实现都会受到影响。 +VFS 的存在促进了代码重用,因为与文件系统相关的基本方法不需要由每种文件系统类型重新实现。代码重用是一种被广泛接受的软件工程最佳实践!唉,但是如果重用的代码[引入了严重的错误][10],那么继承常用方法的所有实现都会受到影响。 ### /tmp:一个小提示 -找出系统中存在的 VFS 的简单方法是键入 `mount | grep -v sd | grep -v :/`,在大多数计算机上,它将列出所有未驻留在磁盘上也不是 NFS 的已挂载文件系统。其中一个列出的 VFS 挂载肯定是 `/ tmp`,对吧? +找出系统中存在的 VFS 的简单方法是键入 `mount | grep -v sd | grep -v :/`,在大多数计算机上,它将列出所有未驻留在磁盘上,同时也不是 NFS 的已挂载文件系统。其中一个列出的 VFS 挂载肯定是 `/tmp`,对吧? ![Man with shocked expression][11] -*每个人都知道把 /tmp 放在物理存储设备上简直是疯了!图片:* +*谁都知道把 /tmp 放在物理存储设备上简直是疯了!图片:* 为什么把 `/tmp` 留在存储设备上是不可取的?因为 `/tmp` 中的文件是临时的(!),并且存储设备比内存慢,所以创建了 tmpfs 这种文件系统。此外,比起内存,物理设备频繁写入更容易磨损。最后,`/tmp` 中的文件可能包含敏感信息,因此在每次重新启动时让它们消失是一项功能。 -不幸的是,默认情况下,某些 Linux 发行版的安装脚本仍会在存储设备上创建 /tmp。如果你的系统出现这种情况,请不要绝望。按照一直优秀的 [Arch Wiki][12] 上的简单说明来解决问题就行,记住分配给 tmpfs 的内存不能用于其他目的。换句话说,带有巨大 tmpfs 并且其中包含大文件的系统可能会耗尽内存并崩溃。另一个提示:编辑 `/etc/fstab` 文件时,请务必以换行符结束,否则系统将无法启动。(猜猜我怎么知道。) +不幸的是,默认情况下,某些 Linux 发行版的安装脚本仍会在存储设备上创建 /tmp。如果你的系统出现这种情况,请不要绝望。按照一直优秀的 [Arch Wiki][12] 上的简单说明来解决问题就行,记住分配给 tmpfs 的内存就不能用于其他目的了。换句话说,包含了大文件的庞大的 tmpfs 可能会让系统耗尽内存并崩溃。 + +另一个提示:编辑 `/etc/fstab` 文件时,请务必以换行符结束,否则系统将无法启动。(猜猜我怎么知道。) ### /proc 和 /sys -除了 `/tmp` 之外,大多数 Linux 用户最熟悉的 VFS 是 `/proc` 和 `/sys`。(`/dev` 依赖于共享内存,没有 `file_operations`)。为什么有两种?让我们来看看更多细节。 +除了 `/tmp` 之外,大多数 Linux 用户最熟悉的 VFS 是 `/proc` 和 `/sys`。(`/dev` 依赖于共享内存,而没有 `file_operations` 结构)。为什么有两种呢?让我们来看看更多细节。 -procfs 提供了内核的瞬时状态及其为用户空间控制的进程的快照。在 `/proc` 中,内核发布有关其提供的工具的信息,如中断、虚拟内存和调度程序。此外,`/proc/sys` 是存放可以通过 [sysctl 命令][13]配置的设置的地方,可供用户空间访问。单个进程的状态和统计信息在 `/proc/` 目录中报告。 +procfs 为用户空间提供了内核及其控制的进程的瞬时状态的快照。在 `/proc` 中,内核发布有关其提供的设施的信息,如中断、虚拟内存和调度程序。此外,`/proc/sys` 是存放可以通过 [sysctl 命令][13]配置的设置的地方,可供用户空间访问。单个进程的状态和统计信息在 `/proc/` 目录中报告。 ![Console][14] */proc/meminfo 是一个空文件,但仍包含有价值的信息。* -`/proc` 文件的行为说明了 VFS 可以与磁盘上的文件系统不同。一方面,`/proc/meminfo` 包含命令 `free` 提供的信息。另一方面,它还是空的!怎么会这样?这种情况让人联想起康奈尔大学物理学家 N. David Mermin 在 1985 年写的一篇名为“[没有人看见月亮的情况吗?][15]现实和量子理论。”事实是当进程从 `/proc` 请求内存时内核再收集有关内存的统计信息,并且当没有人在查看时,`/proc` 中的文件实际上没有任何内容。正如 [Mermin 所说][16],“这是一个基本的量子学说,一般来说,测量不会揭示被测属性的预先存在的价值。”(关于月球的问题的答案留作练习。) +`/proc` 文件的行为说明了 VFS 可以与磁盘上的文件系统不同。一方面,`/proc/meminfo` 包含了可由命令 `free` 展现出来的信息。另一方面,它还是空的!怎么会这样?这种情况让人联想起康奈尔大学物理学家 N. David Mermin 在 1985 年写的一篇名为《[没有人看见月亮的情况吗?][15]现实和量子理论》。事实是当进程从 `/proc` 请求数据时内核再收集有关内存的统计信息,而且当没有人查看它时,`/proc` 中的文件实际上没有任何内容。正如 [Mermin 所说][16],“这是一个基本的量子学说,一般来说,测量不会揭示被测属性的预先存在的价值。”(关于月球的问题的答案留作练习。) ![Full moon][17] *当没有进程访问它们时,/proc 中的文件为空。([来源][18])* -procfs 的空文件是有道理的,因为那里可用的信息是动态的。sysfs 的情况不同。让我们比较一下 `/proc` 与 `/sys` 中不为空的文件数量。 +procfs 的空文件是有道理的,因为那里可用的信息是动态的。sysfs 的情况则不同。让我们比较一下 `/proc` 与 `/sys` 中不为空的文件数量。 ![](https://opensource.com/sites/default/files/uploads/virtualfilesystems_6-filesize.png) -procfs 只有一个,即导出的内核配置,这是一个例外,因为每次启动只需要生成一次。另一方面,`/sys` 有许多较大的文件,其中大多数包含一页内存。通常,sysfs 文件只包含一个数字或字符串,与通过读取 `/proc/meminfo` 等文件生成的信息表格形成鲜明对比。 +procfs 只有一个不为空的文件,即导出的内核配置,这是一个例外,因为每次启动只需要生成一次。另一方面,`/sys` 有许多更大一些的文件,其中大多数由一页内存组成。通常,sysfs 文件只包含一个数字或字符串,与通过读取 `/proc/meminfo` 等文件生成的信息表格形成鲜明对比。 -sysfs 的目的是将内核称为“kobjects”的可读写属性公开给用户空间。kobjects 的唯一目的是引用计数:当删除对 kobject 的最后一个引用时,系统将回收与之关联的资源。然而,`/sys` 构成了内核著名的“[到用户空间的稳定 ABI][19]”,它的大部分内容[在任何情况下都没有人会“破坏”][20]。这并不意味着 sysfs 中的文件是静态,这与易失性对象的引用计数相反。 +sysfs 的目的是将内核称为 “kobject” 的可读写属性公开给用户空间。kobject 的唯一目的是引用计数:当删除对 kobject 的最后一个引用时,系统将回收与之关联的资源。然而,`/sys` 构成了内核著名的“[到用户空间的稳定 ABI][19]”,它的大部分内容[在任何情况下都没有人能“破坏”][20]。但这并不意味着 sysfs 中的文件是静态,这与易失性对象的引用计数相反。 -内核的稳定 ABI 反而限制了 `/sys` 中可能出现的内容,而不是任何给定时刻实际存在的内容。列出 sysfs 中文件的权限可以了解如何设置或读取设备、模块、文件系统等的可配置、可调参数。Logic 强调 procfs 也是内核稳定 ABI 的一部分的结论,尽管内核的[文档][19]没有明确说明。 +内核的稳定 ABI 限制了 `/sys` 中可能出现的内容,而不是任何给定时刻实际存在的内容。列出 sysfs 中文件的权限可以了解如何设置或读取设备、模块、文件系统等的可配置、可调参数。逻辑上强调 procfs 也是内核稳定 ABI 的一部分的结论,尽管内核的[文档][19]没有明确说明。 ![Console][21] -*sysfs 中的文件恰好描述了实体的每个属性,并且可以是可读的、可写的或两者兼而有之。文件中的“0”表示 SSD 不可移动的存储设备。* +*sysfs 中的文件确切地描述了实体的每个属性,并且可以是可读的、可写的,或两者兼而有之。文件中的“0”表示 SSD 不可移动的存储设备。* ### 用 eBPF 和 bcc 工具一窥 VFS 内部 -了解内核如何管理 sysfs 文件的最简单方法是观察它的运行情况,在 ARM64 或 x86_64 上观看的最简单方法是使用 eBPF。eBPF(扩展的伯克利数据包过滤器extended Berkeley Packet Filter)由[在内核中运行的虚拟机][22]组成,特权用户可以从命令行进行查询。内核源代码告诉读者内核可以做什么;在一个启动的系统上运行 eBPF 工具会显示内核实际上做了什么。 +了解内核如何管理 sysfs 文件的最简单方法是观察它的运行情况,在 ARM64 或 x86_64 上观看的最简单方法是使用 eBPF。eBPF(扩展的伯克利数据包过滤器extended Berkeley Packet Filter)由[在内核中运行的虚拟机][22]组成,特权用户可以从命令行进行查询。内核源代码告诉读者内核可以做什么;而在一个启动的系统上运行 eBPF 工具会显示内核实际上做了什么。 -令人高兴的是,通过 [bcc][23] 工具入门使用 eBPF 非常容易,这些工具在[主要 Linux 发行版的软件包][24] 中都有,并且已经由 Brendan Gregg [充分地给出了文档说明][25]。bcc 工具是带有小段嵌入式 C 语言片段的 Python 脚本,这意味着任何对这两种语言熟悉的人都可以轻松修改它们。当前统计,[bcc/tools 中有 80 个 Python 脚本][26],使系统管理员或开发人员很有可能能够找到与她/他的需求相关的现有脚本。 - -要了解 VFS 在正在运行的系统上的工作情况,请尝试使用简单的 [vfscount][27] 或 [vfsstat][28],这表明每秒都会发生数十次对 `vfs_open()` 及其相关的调用 +令人高兴的是,通过 [bcc][23] 工具入门使用 eBPF 非常容易,这些工具在[主要 Linux 发行版的软件包][24] 中都有,并且已经由 Brendan Gregg [给出了充分的文档说明][25]。bcc 工具是带有小段嵌入式 C 语言片段的 Python 脚本,这意味着任何对这两种语言熟悉的人都可以轻松修改它们。据当前统计,[bcc/tools 中有 80 个 Python 脚本][26],使得系统管理员或开发人员很有可能能够找到与她/他的需求相关的已有脚本。 +要了解 VFS 在正在运行中的系统上的工作情况,请尝试使用简单的 [vfscount][27] 或 [vfsstat][28] 脚本,这可以看到每秒都会发生数十次对 `vfs_open()` 及其相关的调用。 ![Console - vfsstat.py][29] @@ -95,37 +96,35 @@ sysfs 的目的是将内核称为“kobjects”的可读写属性公开给用户 作为一个不太重要的例子,让我们看一下在运行的系统上插入 USB 记忆棒时 sysfs 中会发生什么。 - ![Console when USB is inserted][30] *用 eBPF 观察插入 USB 记忆棒时 /sys 中会发生什么,简单的和复杂的例子。* -在上面的第一个简单示例中,只要 `sysfs_create_files()` 命令运行,[trace.py][31] bcc 工具脚本就会打印出一条消息。我们看到 `sysfs_create_files()` 由一个 kworker 线程启动,以响应 USB 棒插入事件,但是它创建了什么文件?第二个例子说明了 eBPF 的强大能力。这里,`trace.py` 正在打印内核回溯(`-K` 选项)以及 `sysfs_create_files()` 创建的文件的名称。单引号内的代码段是一些 C 源代码,包括一个易于识别的格式字符串,提供的 Python 脚本[引入 LLVM 即时编译器(JIT)][32] 在内核虚拟机内编译和执行它。必须在第二个命令中重现完整的 `sysfs_create_files()` 函数签名,以便格式字符串可以引用其中一个参数。在此 C 片段中出错会导致可识别的 C 编译器错误。例如,如果省略 `-I` 参数,则结果为“无法编译 BPF 文本”。熟悉 C 或 Python 的开发人员会发现 bcc 工具易于扩展和修改。 +在上面的第一个简单示例中,只要 `sysfs_create_files()` 命令运行,[trace.py][31] bcc 工具脚本就会打印出一条消息。我们看到 `sysfs_create_files()` 由一个 kworker 线程启动,以响应 USB 棒的插入事件,但是它创建了什么文件?第二个例子说明了 eBPF 的强大能力。这里,`trace.py` 正在打印内核回溯(`-K` 选项)以及 `sysfs_create_files()` 创建的文件的名称。单引号内的代码段是一些 C 源代码,包括一个易于识别的格式字符串,所提供的 Python 脚本[引入 LLVM 即时编译器(JIT)][32] 来在内核虚拟机内编译和执行它。必须在第二个命令中重现完整的 `sysfs_create_files()` 函数签名,以便格式字符串可以引用其中一个参数。在此 C 片段中出错会导致可识别的 C 编译器错误。例如,如果省略 `-I` 参数,则结果为“无法编译 BPF 文本”。熟悉 C 或 Python 的开发人员会发现 bcc 工具易于扩展和修改。 插入 USB 记忆棒后,内核回溯显示 PID 7711 是一个 kworker 线程,它在 sysfs 中创建了一个名为 `events` 的文件。使用 `sysfs_remove_files()` 进行相应的调用表明,删除 USB 记忆棒会导致删除该 `events` 文件,这与引用计数的想法保持一致。在 USB 棒插入期间(未显示)在 eBPF 中观察 `sysfs_create_link()` 表明创建了不少于 48 个符号链接。 -无论如何,`events` 文件的目的是什么?使用 [cscope][33] 查找函数 [`__device_add_disk()`][34] 显示它调用 `disk_add_events()`,并且可以将 “media_change” 或 “eject_request” 写入到该文件。这里,内核的块层通知用户空间 “磁盘” 的出现和消失。考虑一下这种调查 USB 棒插入工作原理的方法与试图仅从源头中找出该过程的速度有多快。 +无论如何,`events` 文件的目的是什么?使用 [cscope][33] 查找函数 [`__device_add_disk()`][34] 显示它调用 `disk_add_events()`,并且可以将 “media_change” 或 “eject_request” 写入到该文件。这里,内核的块层通知用户空间该 “磁盘” 的出现和消失。考虑一下这种检查 USB 棒的插入的工作原理的方法与试图仅从源头中找出该过程的速度有多快。 ### 只读根文件系统使得嵌入式设备成为可能 确实,没有人通过拔出电源插头来关闭服务器或桌面系统。为什么?因为物理存储设备上挂载的文件系统可能有挂起的(未完成的)写入,并且记录其状态的数据结构可能与写入存储器的内容不同步。当发生这种情况时,系统所有者将不得不在下次启动时等待 [fsck 文件系统恢复工具][35] 运行完成,在最坏的情况下,实际上会丢失数据。 -然而,狂热爱好者会听说许多物联网和嵌入式设备,如路由器、恒温器和汽车现在都运行 Linux。许多这些设备几乎完全没有用户界面,并且没有办法干净地“解除启动”它们。想一想使用启动电池耗尽的汽车,其中[运行 Linux 的主机设备][36] 的电源会不断加电断电。当引擎最终开始运行时,系统如何在没有长时间 fsck 的情况下启动呢?答案是嵌入式设备依赖于[只读根文件系统][37](简称 ro-rootfs)。 - +然而,狂热爱好者会听说许多物联网和嵌入式设备,如路由器、恒温器和汽车现在都运行着 Linux。许多这些设备几乎完全没有用户界面,并且没有办法干净地让它们“解除启动”。想一想启动电池耗尽的汽车,其中[运行 Linux 的主机设备][36] 的电源会不断加电断电。当引擎最终开始运行时,系统如何在没有长时间 fsck 的情况下启动呢?答案是嵌入式设备依赖于[只读根文件系统][37](简称 ro-rootfs)。 ![Photograph of a console][38] *ro-rootfs 是嵌入式系统不经常需要 fsck 的原因。 来源:* -ro-rootfs 提供了许多优点,虽然这些优点不如耐用性那么显然。一个是,如果没有 Linux 进程可以写入,那么恶意软件无法写入 `/usr` 或 `/lib`。另一个是,基本上不可变的文件系统对于远程设备的现场支持至关重要,因为支持人员拥有名义上与现场相同的本地系统。也许最重要(但也是最微妙)的优势是 ro-rootfs 迫使开发人员在项目的设计阶段就决定哪些系统对象是不可变的。处理 ro-rootfs 可能经常是不方便甚至是痛苦的,[编程语言中的常量变量][39]经常就是这样,但带来的好处很容易偿还额外的开销。 +ro-rootfs 提供了许多优点,虽然这些优点不如耐用性那么显然。一个是,如果 Linux 进程不可以写入,那么恶意软件也无法写入 `/usr` 或 `/lib`。另一个是,基本上不可变的文件系统对于远程设备的现场支持至关重要,因为支持人员拥有理论上与现场相同的本地系统。也许最重要(但也是最微妙)的优势是 ro-rootfs 迫使开发人员在项目的设计阶段就决定好哪些系统对象是不可变的。处理 ro-rootfs 可能经常是不方便甚至是痛苦的,[编程语言中的常量变量][39]经常就是这样,但带来的好处很容易偿还这种额外的开销。 -对于嵌入式开发人员,创建只读根文件系统确实需要做一些额外的工作,而这正是 VFS 的用武之地。Linux 需要 `/var` 中的文件可写,此外,嵌入式系统运行的许多流行应用程序将尝试在 `$HOME` 中创建配置点文件。放在家目录中的配置文件的一种解决方案通常是预生成它们并将它们构建到 rootfs 中。对于 `/var`,一种方法是将其挂载在单独的可写分区上,而 `/` 本身以只读方式挂载。使用绑定或叠加挂载是另一种流行的替代方案。 +对于嵌入式开发人员,创建只读根文件系统确实需要做一些额外的工作,而这正是 VFS 的用武之地。Linux 需要 `/var` 中的文件可写,此外,嵌入式系统运行的许多流行应用程序会尝试在 `$HOME` 中创建配置的点文件。放在家目录中的配置文件的一种解决方案通常是预生成它们并将它们构建到 rootfs 中。对于 `/var`,一种方法是将其挂载在单独的可写分区上,而 `/` 本身以只读方式挂载。使用绑定或叠加挂载是另一种流行的替代方案。 ### 绑定和叠加挂载以及在容器中的使用 -运行 [man mount][40] 是了解绑定挂载bind mount叠加挂载overlay mount的最好办法,这使嵌入式开发人员和系统管理员能够在一个路径位置创建文件系统,然后在另外一个路径将其提供给应用程序。对于嵌入式系统,这代表着可以将文件存储在 `/var` 中的不可写闪存设备上,但是在启动时将 tmpfs 中的路径叠加挂载或绑定挂载到 `/var` 路径上,这样应用程序就可以在那里随意写它们的内容了。下次加电时,`/var` 中的变化将会消失。叠加挂载提供了 tmpfs 和底层文件系统之间的联合,允许对 ro-rootfs 中的现有文件进行直接修改,而绑定挂载可以使新的空 tmpfs 目录在 ro-rootfs 路径中显示为可写。虽然叠加文件系统是一种适当的文件系统类型,但绑定挂载由 [VFS 命名空间工具][41] 实现的。 +运行 [man mount][40] 是了解绑定挂载bind mount叠加挂载overlay mount的最好办法,这种方法使得嵌入式开发人员和系统管理员能够在一个路径位置创建文件系统,然后以另外一个路径将其提供给应用程序。对于嵌入式系统,这代表着可以将文件存储在 `/var` 中的不可写闪存设备上,但是在启动时将 tmpfs 中的路径叠加挂载或绑定挂载到 `/var` 路径上,这样应用程序就可以在那里随意写它们的内容了。下次加电时,`/var` 中的变化将会消失。叠加挂载为 tmpfs 和底层文件系统提供了联合,允许对 ro-rootfs 中的现有文件进行直接修改,而绑定挂载可以使新的空 tmpfs 目录在 ro-rootfs 路径中显示为可写。虽然叠加文件系统是一种适当的文件系统类型,而绑定挂载由 [VFS 命名空间工具][41] 实现的。 -根据叠加挂载和绑定挂载的描述,没有人会对 [Linux容器][42] 大量使用它们感到惊讶。让我们通过运行 bcc 的 `mountsnoop` 工具监视当使用 [systemd-nspawn][43] 启动容器时会发生什么: +根据叠加挂载和绑定挂载的描述,没有人会对 [Linux 容器][42] 中大量使用它们感到惊讶。让我们通过运行 bcc 的 `mountsnoop` 工具监视当使用 [systemd-nspawn][43] 启动容器时会发生什么: ![Console - system-nspawn invocation][44] @@ -135,13 +134,13 @@ ro-rootfs 提供了许多优点,虽然这些优点不如耐用性那么显然 ![Console - Running mountsnoop][45] -在容器 “启动” 期间运行 `mountsnoop` 可以看到容器运行时很大程度上依赖于绑定挂载。(仅显示冗长输出的开头) +*在容器 “启动” 期间运行 `mountsnoop` 可以看到容器运行时很大程度上依赖于绑定挂载。(仅显示冗长输出的开头)* -这里,`systemd-nspawn` 将主机的 procfs 和 sysfs 中的选定文件其 rootfs 中的路径提供给容器按。除了设置绑定挂载时的 `MS_BIND` 标志之外,`mount` 系统调用的一些其他标志用于确定主机命名空间和容器中的更改之间的关系。例如,绑定挂载可以将 `/proc` 和 `/sys` 中的更改传播到容器,也可以隐藏它们,具体取决于调用。 +这里,`systemd-nspawn` 将主机的 procfs 和 sysfs 中的选定文件按其 rootfs 中的路径提供给容器。除了设置绑定挂载时的 `MS_BIND` 标志之外,`mount` 系统调用的一些其它标志用于确定主机命名空间和容器中的更改之间的关系。例如,绑定挂载可以将 `/proc` 和 `/sys` 中的更改传播到容器,也可以隐藏它们,具体取决于调用。 ### 总结 -理解 Linux 内部结构似乎是一项不可能完成的任务,因为除了 Linux 用户空间应用程序和 glibc 这样的 C 库中的系统调用接口,内核本身也包含大量代码。取得进展的一种方法是阅读一个内核子系统的源代码,重点是理解面向用户空间的系统调用和头文件以及主要的内核内部接口,这里以 `file_operations` 表为例的。`file_operations` 使得“一切都是文件”可以实际工作,因此掌握它们收获特别大。顶级 `fs/` 目录中的内核 C 源文件构成了虚拟文件系统的实现,虚拟文件​​系统是支持流行的文件系统和存储设备的广泛且相对简单的互操作性的垫片层。通过 Linux 命名空间进行绑定挂载和覆盖挂载是 VFS 魔术,它使容器和只读根文件系统成为可能。结合对源代码的研究,eBPF 内核工具及其 bcc 接口使得探测内核比以往任何时候都更简单。 +理解 Linux 内部结构看似是一项不可能完成的任务,因为除了 Linux 用户空间应用程序和 glibc 这样的 C 库中的系统调用接口,内核本身也包含大量代码。取得进展的一种方法是阅读一个内核子系统的源代码,重点是理解面向用户空间的系统调用和头文件以及主要的内核内部接口,这里以 `file_operations` 表为例。`file_operations` 使得“一切都是文件”得以可以实际工作,因此掌握它们收获特别大。顶级 `fs/` 目录中的内核 C 源文件构成了虚拟文件系统的实现,虚拟文件​​系统是支持流行的文件系统和存储设备的广泛且相对简单的互操作性的垫片层。通过 Linux 命名空间进行绑定挂载和覆盖挂载是 VFS 魔术,它使容器和只读根文件系统成为可能。结合对源代码的研究,eBPF 内核工具及其 bcc 接口使得探测内核比以往任何时候都更简单。 非常感谢 [Akkana Peck][46] 和 [Michael Eager][47] 的评论和指正。 @@ -154,7 +153,7 @@ via: https://opensource.com/article/19/3/virtual-filesystems-linux 作者:[Alison Chariken][a] 选题:[lujun9972][b] 译者:[wxy](https://github.com/wxy) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/201905/20190319 Blockchain 2.0- Blockchain In Real Estate -Part 4.md b/published/201905/20190319 Blockchain 2.0- Blockchain In Real Estate -Part 4.md new file mode 100644 index 0000000000..0ea20b929a --- /dev/null +++ b/published/201905/20190319 Blockchain 2.0- Blockchain In Real Estate -Part 4.md @@ -0,0 +1,56 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10914-1.html) +[#]: subject: (Blockchain 2.0: Blockchain In Real Estate [Part 4]) +[#]: via: (https://www.ostechnix.com/blockchain-2-0-blockchain-in-real-estate/) +[#]: author: (ostechnix https://www.ostechnix.com/author/editor/) + +区块链 2.0:房地产区块链(四) +====== + +![](https://www.ostechnix.com/wp-content/uploads/2019/03/Blockchain-In-Real-Estate-720x340.png) + +### 区块链 2.0:“更”智能的房地产 + +在本系列的[上一篇文章][1]中我们探讨了区块链的特征,这些区块链将使机构能够将**传统银行**和**融资系统**转换和交织在一起。这部分将探讨**房地产区块链**。房地产业正在走向革命。它是人类已知的交易最活跃、最重要的资产类别之一。然而,由于充满了监管障碍和欺诈、欺骗的无数可能性,它也是最难参与交易的之一。利用适当的共识算法的区块链的分布式分类账本功能被吹捧为这个行业的前进方向,而这个行业传统上被认为其面对变革是保守的。 + +就其无数的业务而言,房地产一直是一个非常保守的行业。这似乎也是理所当然的。2008 年金融危机或 20 世纪上半叶的大萧条等重大经济危机成功摧毁了该行业及其参与者。然而,与大多数具有经济价值的产品一样,房地产行业具有弹性,而这种弹性则源于其保守性。 + +全球房地产市场由价值 228 万亿 [^1] 美元的资产类别组成,出入不大。其他投资资产,如股票、债券和股票合计价值仅为 170 万亿美元。显然,在这样一个行业中实施的交易在很大程度上都是精心策划和执行的。很多时候,房地产也因许多欺诈事件而臭名昭著,并且随之而来的是毁灭性的损失。由于其运营非常保守,该行业也难以驾驭。它受到了法律的严格监管,创造了一个交织在一起的细微差别网络,这对于普通人来说太难以完全理解,使得大多数人无法进入和参与。如果你曾参与过这样的交易,那么你就会知道纸质文件的重要性和长期性。 + +从一个微不足道的开始,虽然是一个重要的例子,以显示当前的记录管理实践在房地产行业有多糟糕,考虑一下[产权保险业务][2] [^3]。产权保险用于对冲土地所有权和所有权记录不可接受且从而无法执行的可能性。诸如此类的保险产品也称为赔偿保险。在许多情况下,法律要求财产拥有产权保险,特别是在处理多年来多次易手的财产时。抵押贷款公司在支持房地产交易时也可能坚持同样的要求。事实上,这种产品自 19 世纪 50 年代就已存在,并且仅在美国每年至少有 1.5 万亿美元的商业价值这一事实证明了一开始的说法。在这种情况下,这些记录的维护方式必须进行改革,区块链提供了一个可持续解决方案。根据[美国土地产权协会][4],平均每个案例的欺诈平均约为 10 万美元,并且涉及交易的所有产权中有 25% 的文件存在问题。区块链允许设置一个不可变的永久数据库,该数据库将跟踪资产本身,记录已经进入的每个交易或投资。这样的分类帐本系统将使包括一次性购房者在内的房地产行业的每个人的生活更加轻松,并使诸如产权保险等金融产品基本上无关紧要。将诸如房地产之类的实物资产转换为这样的数字资产是非常规的,并且目前仅在理论上存在。然而,这种变化迫在眉睫,而不是迟到 [^5]。 + +区块链在房地产中影响最大的领域如上所述,在维护透明和安全的产权管理系统方面。基于区块链的财产记录可以包含有关财产、其所在地、所有权历史以及相关的公共记录的[信息][6]。这将允许房地产交易快速完成,并且无需第三方监控和监督。房地产评估和税收计算等任务成为有形的、客观的参数问题,而不是主观测量和猜测,因为可靠的历史数据是可公开验证的。[UBITQUITY][7] 就是这样一个平台,为企业客户提供定制的基于区块链的解决方案。该平台允许客户跟踪所有房产细节、付款记录、抵押记录,甚至允许运行智能合约,自动处理税收和租赁。 + +这为我们带来了房地产区块链的第二大机遇和用例。由于该行业受到众多第三方的高度监管,除了参与交易的交易对手外,尽职调查和财务评估可能非常耗时。这些流程主要通过离线渠道进行,文书工作需要在最终评估报告出来之前进行数天。对于公司房地产交易尤其如此,这构成了顾问所收取的总计费时间的大部分。如果交易由抵押背书,则这些过程的重复是不可避免的。一旦与所涉及的人员和机构的数字身份相结合,就可以完全避免当前的低效率,并且可以在几秒钟内完成交易。租户、投资者、相关机构、顾问等可以单独验证数据并达成一致的共识,从而验证永久性的财产记录 [^8]。这提高了验证流程的准确性。房地产巨头 RE/MAX 最近宣布与服务提供商 XYO Network Partners 合作,[建立墨西哥房上市地产国家数据库][9]。他们希望有朝一日能够创建世界上最大的(截至目前)去中心化房地产登记中心之一。 + +然而,区块链可以带来的另一个重要且可以说是非常民主的变化是投资房地产。与其他投资资产类别不同,即使是小型家庭投资者也可能参与其中,房地产通常需要大量的手工付款才能参与。诸如 ATLANT 和 BitOfProperty 之类的公司将房产的账面价值代币化,并将其转换为加密货币的等价物。这些代币随后在交易所出售,类似于股票和股票的交易方式。[房地产后续产生的任何现金流都会根据其在财产中的“份额”记入贷方或借记给代币所有者][4]。 + +然而,尽管如此,区块链技术仍处于房地产领域的早期采用阶段,目前的法规还没有明确定义它。诸如分布式应用程序、分布式匿名组织(DAO)、智能合约等概念在许多国家的法律领域是闻所未闻的。一旦所有利益相关者充分接受了区块链复杂性的良好教育,就会彻底改革现有的法规和指导方针,这是最务实的前进方式。 同样,这将是一个缓慢而渐进的变化,但是它是一个急需的变化。本系列的下一篇文章将介绍 “智能合约”,例如由 UBITQUITY 和 XYO 等公司实施的那些是如何在区块链中创建和执行的。 + +[^1]: HSBC, “Global Real Estate,” no. April, 2008 +[^3]: D. B. Burke, Law of title insurance. Aspen Law & Business, 2000. +[^5]: M. Swan, O’Reilly – Blockchain. Blueprint for a New Economy – 2015. +[^8]: Deloite, “Blockchain in commercial real estate The future is here ! Table of contents.” + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/blockchain-2-0-blockchain-in-real-estate/ + +作者:[ostechnix][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-10689-1.html +[2]: https://www.forbes.com/sites/jordanlulich/2018/06/21/what-is-title-insurance-and-why-its-important/#1472022b12bb +[4]: https://www.cbinsights.com/research/blockchain-real-estate-disruption/#financing +[6]: https://www2.deloitte.com/us/en/pages/financial-services/articles/blockchain-in-commercial-real-estate.html +[7]: https://www.ubitquity.io/ +[9]: https://www.businesswire.com/news/home/20181012005068/en/XYO-Network-Partners-REMAX-M%C3%A9xico-Bring-Blockchain diff --git a/published/20190327 Why DevOps is the most important tech strategy today.md b/published/201905/20190327 Why DevOps is the most important tech strategy today.md similarity index 100% rename from published/20190327 Why DevOps is the most important tech strategy today.md rename to published/201905/20190327 Why DevOps is the most important tech strategy today.md diff --git a/published/201905/20190329 How to manage your Linux environment.md b/published/201905/20190329 How to manage your Linux environment.md new file mode 100644 index 0000000000..0a226f79f7 --- /dev/null +++ b/published/201905/20190329 How to manage your Linux environment.md @@ -0,0 +1,173 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10916-1.html) +[#]: subject: (How to manage your Linux environment) +[#]: via: (https://www.networkworld.com/article/3385516/how-to-manage-your-linux-environment.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如何管理你的 Linux 环境变量 +====== + +> Linux 用户环境变量可以帮助你找到你需要的命令,无须了解系统如何配置的细节而完成大量工作。而这些设置来自哪里和如何被修改它们是另一个话题。 + +![IIP Photo Archive \(CC BY 2.0\)][1] + +在 Linux 系统上的用户账户配置以多种方法简化了系统的使用。你可以运行命令,而不需要知道它们的位置。你可以重新使用先前运行的命令,而不用发愁系统是如何追踪到它们的。你可以查看你的电子邮件,查看手册页,并容易地回到你的家目录,而不用管你在文件系统中身在何方。并且,当需要的时候,你可以调整你的账户设置,以便其更符合你喜欢的方式。 + +Linux 环境设置来自一系列的文件:一些是系统范围(意味着它们影响所有用户账户),一些是处于你的家目录中的配置文件里。系统范围的设置在你登录时生效,而本地设置在其后生效,所以,你在你账户中作出的更改将覆盖系统范围设置。对于 bash 用户,这些文件包含这些系统文件: + +``` +/etc/environment +/etc/bash.bashrc +/etc/profile +``` + +以及一些本地文件: + +``` +~/.bashrc +~/.profile # 如果有 ~/.bash_profile 或 ~/.bash_login 就不会读此文件 +~/.bash_profile +~/.bash_login +``` + +你可以修改本地存在的四个文件的任何一个,因为它们处于你的家目录,并且它们是属于你的。 + +### 查看你的 Linux 环境设置 + +为查看你的环境设置,使用 `env` 命令。你的输出将可能与这相似: + +``` +$ env +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=01;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:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31: +*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31: +*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31: +*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=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;35:*.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;35:*.xwd=01;35:*.yuv=01;35: +*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36: +*.m4a=00;36:*.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:*.spf=00;36: +SSH_CONNECTION=192.168.0.21 34975 192.168.0.11 22 +LESSCLOSE=/usr/bin/lesspipe %s %s +LANG=en_US.UTF-8 +OLDPWD=/home/shs +XDG_SESSION_ID=2253 +USER=shs +PWD=/home/shs +HOME=/home/shs +SSH_CLIENT=192.168.0.21 34975 22 +XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop +SSH_TTY=/dev/pts/0 +MAIL=/var/mail/shs +TERM=xterm +SHELL=/bin/bash +SHLVL=1 +LOGNAME=shs +DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus +XDG_RUNTIME_DIR=/run/user/1000 +PATH=/home/shs/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin +LESSOPEN=| /usr/bin/lesspipe %s +_=/usr/bin/env +``` + +虽然你可能会看到大量的输出,上面显示的第一大部分用于在命令行上使用颜色标识各种文件类型。当你看到类似 `*.tar=01;31:` 这样的东西,这告诉你 `tar` 文件将以红色显示在文件列表中,然而 `*.jpg=01;35:` 告诉你 jpg 文件将以紫色显现出来。这些颜色旨在使它易于从一个文件列表中分辨出某些文件。你可以在《[在 Linux 命令行中自定义你的颜色][3]》处学习更多关于这些颜色的定义,和如何自定义它们。 + +当你更喜欢一种不加装饰的显示时,一种关闭颜色显示的简单方法是使用如下命令: + +``` +$ ls -l --color=never +``` + +这个命令可以简单地转换到一个别名: + +``` +$ alias ll2='ls -l --color=never' +``` + +你也可以使用 `echo` 命令来单独地显现某个设置。在这个命令中,我们显示在历史缓存区中将被记忆命令的数量: + +``` +$ echo $HISTSIZE +1000 +``` + +如果你已经移动到某个位置,你在文件系统中的最后位置会被记在这里: + +``` +PWD=/home/shs +OLDPWD=/tmp +``` + +### 作出更改 + +你可以使用一个像这样的命令更改环境设置,但是,如果你希望保持这个设置,在你的 `~/.bashrc` 文件中添加一行代码,例如 `HISTSIZE=1234`。 + +``` +$ export HISTSIZE=1234 +``` + +### “export” 一个变量的本意是什么 + +导出一个环境变量可使设置用于你的 shell 和可能的子 shell。默认情况下,用户定义的变量是本地的,并不被导出到新的进程,例如,子 shell 和脚本。`export` 命令使得环境变量可用在子进程中发挥功用。 + +### 添加和移除变量 + +你可以很容易地在命令行和子 shell 上创建新的变量,并使它们可用。然而,当你登出并再次回来时这些变量将消失,除非你也将它们添加到 `~/.bashrc` 或一个类似的文件中。 + +``` +$ export MSG="Hello, World!" +``` + +如果你需要,你可以使用 `unset` 命令来消除一个变量: + +``` +$ unset MSG +``` + +如果变量是局部定义的,你可以通过加载你的启动文件来简单地将其设置回来。例如: + +``` +$ echo $MSG +Hello, World! +$ unset $MSG +$ echo $MSG + +$ . ~/.bashrc +$ echo $MSG +Hello, World! +``` + +### 小结 + +用户账户是用一组恰当的启动文件设立的,创建了一个有用的用户环境,而个人用户和系统管理员都可以通过编辑他们的个人设置文件(对于用户)或很多来自设置起源的文件(对于系统管理员)来更改默认设置。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3385516/how-to-manage-your-linux-environment.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/03/environment-rocks-leaves-100792229-large.jpg +[2]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua +[3]: https://www.networkworld.com/article/3269587/customizing-your-text-colors-on-the-linux-command-line.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/20190401 What is 5G- How is it better than 4G.md b/published/201905/20190401 What is 5G- How is it better than 4G.md similarity index 100% rename from published/20190401 What is 5G- How is it better than 4G.md rename to published/201905/20190401 What is 5G- How is it better than 4G.md diff --git a/published/20190405 Command line quick tips- Cutting content out of files.md b/published/201905/20190405 Command line quick tips- Cutting content out of files.md similarity index 100% rename from published/20190405 Command line quick tips- Cutting content out of files.md rename to published/201905/20190405 Command line quick tips- Cutting content out of files.md diff --git a/published/20190408 Getting started with Python-s cryptography library.md b/published/201905/20190408 Getting started with Python-s cryptography library.md similarity index 100% rename from published/20190408 Getting started with Python-s cryptography library.md rename to published/201905/20190408 Getting started with Python-s cryptography library.md diff --git a/published/20190408 How to quickly deploy, run Linux applications as unikernels.md b/published/201905/20190408 How to quickly deploy, run Linux applications as unikernels.md similarity index 100% rename from published/20190408 How to quickly deploy, run Linux applications as unikernels.md rename to published/201905/20190408 How to quickly deploy, run Linux applications as unikernels.md diff --git a/published/20190409 Anbox - Easy Way To Run Android Apps On Linux.md b/published/201905/20190409 Anbox - Easy Way To Run Android Apps On Linux.md similarity index 100% rename from published/20190409 Anbox - Easy Way To Run Android Apps On Linux.md rename to published/201905/20190409 Anbox - Easy Way To Run Android Apps On Linux.md diff --git a/published/20190409 How To Install And Configure Chrony As NTP Client.md b/published/201905/20190409 How To Install And Configure Chrony As NTP Client.md similarity index 100% rename from published/20190409 How To Install And Configure Chrony As NTP Client.md rename to published/201905/20190409 How To Install And Configure Chrony As NTP Client.md diff --git a/published/20190409 How To Install And Configure NTP Server And NTP Client In Linux.md b/published/201905/20190409 How To Install And Configure NTP Server And NTP Client In Linux.md similarity index 100% rename from published/20190409 How To Install And Configure NTP Server And NTP Client In Linux.md rename to published/201905/20190409 How To Install And Configure NTP Server And NTP Client In Linux.md diff --git a/published/20190411 Installing Ubuntu MATE on a Raspberry Pi.md b/published/201905/20190411 Installing Ubuntu MATE on a Raspberry Pi.md similarity index 100% rename from published/20190411 Installing Ubuntu MATE on a Raspberry Pi.md rename to published/201905/20190411 Installing Ubuntu MATE on a Raspberry Pi.md diff --git a/published/20190415 12 Single Board Computers- Alternative to Raspberry Pi.md b/published/201905/20190415 12 Single Board Computers- Alternative to Raspberry Pi.md similarity index 100% rename from published/20190415 12 Single Board Computers- Alternative to Raspberry Pi.md rename to published/201905/20190415 12 Single Board Computers- Alternative to Raspberry Pi.md diff --git a/published/20190415 How To Enable (UP) And Disable (DOWN) A Network Interface Port (NIC) In Linux.md b/published/201905/20190415 How To Enable (UP) And Disable (DOWN) A Network Interface Port (NIC) In Linux.md similarity index 100% rename from published/20190415 How To Enable (UP) And Disable (DOWN) A Network Interface Port (NIC) In Linux.md rename to published/201905/20190415 How To Enable (UP) And Disable (DOWN) A Network Interface Port (NIC) In Linux.md diff --git a/published/20190415 Inter-process communication in Linux- Shared storage.md b/published/201905/20190415 Inter-process communication in Linux- Shared storage.md similarity index 100% rename from published/20190415 Inter-process communication in Linux- Shared storage.md rename to published/201905/20190415 Inter-process communication in Linux- Shared storage.md diff --git a/published/201905/20190415 Kubernetes on Fedora IoT with k3s.md b/published/201905/20190415 Kubernetes on Fedora IoT with k3s.md new file mode 100644 index 0000000000..a8293d4d3b --- /dev/null +++ b/published/201905/20190415 Kubernetes on Fedora IoT with k3s.md @@ -0,0 +1,209 @@ +[#]: collector: (lujun9972) +[#]: translator: (StdioA) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10908-1.html) +[#]: subject: (Kubernetes on Fedora IoT with k3s) +[#]: via: (https://fedoramagazine.org/kubernetes-on-fedora-iot-with-k3s/) +[#]: author: (Lennart Jern https://fedoramagazine.org/author/lennartj/) + +使用 k3s 在 Fedora IoT 上运行 K8S +====== + +![](https://img.linux.net.cn/data/attachment/album/201905/28/094048yrzlik9oek5rbs5s.jpg) + +Fedora IoT 是一个即将发布的、面向物联网的 Fedora 版本。去年 Fedora Magazine 的《[如何使用 Fedora IoT 点亮 LED 灯][2]》一文第一次介绍了它。从那以后,它与 Fedora Silverblue 一起不断改进,以提供针对面向容器的工作流的不可变基础操作系统。 + +Kubernetes 是一个颇受欢迎的容器编排系统。它可能最常用在那些能够处理巨大负载的强劲硬件上。不过,它也能在像树莓派 3 这样轻量级的设备上运行。让我们继续阅读,来了解如何运行它。 + +### 为什么用 Kubernetes? + +虽然 Kubernetes 在云计算领域风靡一时,但让它在小型单板机上运行可能并不是常见的。不过,我们有非常明确的理由来做这件事。首先,这是一个不需要昂贵硬件就可以学习并熟悉 Kubernetes 的好方法;其次,由于它的流行性,市面上有[大量应用][3]进行了预先打包,以用于在 Kubernetes 集群中运行。更不用说,当你遇到问题时,会有大规模的社区用户为你提供帮助。 + +最后但同样重要的是,即使是在家庭实验室这样的小规模环境中,容器编排也确实能够使事情变得更加简单。虽然在学习曲线方面,这一点并不明显,但这些技能在你将来与任何集群打交道的时候都会有帮助。不管你面对的是一个单节点树莓派集群,还是一个大规模的机器学习场,它们的操作方式都是类似的。 + +#### K3s - 轻量级的 Kubernetes + +一个“正常”安装的 Kubernetes(如果有这么一说的话)对于物联网来说有点沉重。K8s 的推荐内存配置,是每台机器 2GB!不过,我们也有一些替代品,其中一个新人是 [k3s][4] —— 一个轻量级的 Kubernetes 发行版。 + +K3s 非常特殊,因为它将 etcd 替换成了 SQLite 以满足键值存储需求。还有一点,在于整个 k3s 将使用一个二进制文件分发,而不是每个组件一个。这减少了内存占用并简化了安装过程。基于上述原因,我们只需要 512MB 内存即可运行 k3s,极度适合小型单板电脑! + +### 你需要的东西 + +1. Fedora IoT 运行在虚拟机或实体设备中运行的。在[这里][5]可以看到优秀的入门指南。一台机器就足够了,不过两台可以用来测试向集群添加更多节点。 +2. [配置防火墙][6],允许 6443 和 8372 端口的通信。或者,你也可以简单地运行 `systemctl stop firewalld` 来为这次实验关闭防火墙。 + +### 安装 k3s + +安装 k3s 非常简单。直接运行安装脚本: + +``` +curl -sfL https://get.k3s.io | sh - +``` + +它会下载、安装并启动 k3s。安装完成后,运行以下命令来从服务器获取节点列表: + +``` +kubectl get nodes +``` + +需要注意的是,有几个选项可以通过环境变量传递给安装脚本。这些选项可以在[文档][7]中找到。当然,你也完全可以直接下载二进制文件来手动安装 k3s。 + +对于实验和学习来说,这样已经很棒了,不过单节点的集群也不能算一个集群。幸运的是,添加另一个节点并不比设置第一个节点要难。只需要向安装脚本传递两个环境变量,它就可以找到第一个节点,而不用运行 k3s 的服务器部分。 + +``` +curl -sfL https://get.k3s.io | K3S_URL=https://example-url:6443 \ + K3S_TOKEN=XXX sh - +``` + +上面的 `example-url` 应被替换为第一个节点的 IP 地址,或一个完全限定域名。在该节点中,(用 XXX 表示的)令牌可以在 `/var/lib/rancher/k3s/server/node-token` 文件中找到。 + +### 部署一些容器 + +现在我们有了一个 Kubernetes 集群,我们可以真正做些什么呢?让我们从部署一个简单的 Web 服务器开始吧。 + +``` +kubectl create deployment my-server --image nginx +``` + +这会从名为 `nginx` 的容器镜像中创建出一个名叫 `my-server` 的 [部署][8](默认使用 docker hub 注册中心,以及 `latest` 标签)。 + +``` +kubectl get pods +``` + +为了访问到 pod 中运行的 nginx 服务器,首先通过一个 [服务][9] 来暴露该部署。以下命令将创建一个与该部署同名的服务。 + +``` +kubectl expose deployment my-server --port 80 +``` + +服务将作为一种负载均衡器和 Pod 的 DNS 记录来工作。比如,当运行第二个 Pod 时,我们只需指定 `my-server`(服务名称)就可以通过 `curl` 访问 nginx 服务器。有关如何操作,可以看下面的实例。 + +``` +# 启动一个 pod,在里面以交互方式运行 bash +kubectl run debug --generator=run-pod/v1 --image=fedora -it -- bash +# 等待 bash 提示符出现 +curl my-server +# 你可以看到“Welcome to nginx!”的输出页面 +``` + +### Ingress 控制器及外部 IP + +默认状态下,一个服务只能获得一个 ClusterIP(只能从集群内部访问),但你也可以通过把它的类型设置为 [LoadBalancer][10] 为该服务申请一个外部 IP。不过,并非所有应用都需要自己的 IP 地址。相反,通常可以通过基于 Host 请求头部或请求路径进行路由,从而使多个服务共享一个 IP 地址。你可以在 Kubernetes 使用 [Ingress][11] 完成此操作,而这也是我们要做的。Ingress 也提供了额外的功能,比如无需配置应用即可对流量进行 TLS 加密。 + +Kubernetes 需要 Ingress 控制器来使 Ingress 资源工作,k3s 包含 [Traefik][12] 正是出于此目的。它还包含了一个简单的服务负载均衡器,可以为集群中的服务提供外部 IP。这篇[文档][13]描述了这种服务: + +> k3s 包含一个使用可用主机端口的基础服务负载均衡器。比如,如果你尝试创建一个监听 80 端口的负载均衡器,它会尝试在集群中寻找一个 80 端口空闲的节点。如果没有可用端口,那么负载均衡器将保持在 Pending 状态。 +> +> k3s README + +Ingress 控制器已经通过这个负载均衡器暴露在外。你可以使用以下命令找到它正在使用的 IP 地址。 + +``` +$ kubectl get svc --all-namespaces +NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE + default kubernetes ClusterIP 10.43.0.1 443/TCP 33d + default my-server ClusterIP 10.43.174.38 80/TCP 30m + kube-system kube-dns ClusterIP 10.43.0.10 53/UDP,53/TCP,9153/TCP 33d + kube-system traefik LoadBalancer 10.43.145.104 10.0.0.8 80:31596/TCP,443:31539/TCP 33d +``` + +找到名为 `traefik` 的服务。在上面的例子中,我们感兴趣的 IP 是 10.0.0.8。 + +### 路由传入的请求 + +让我们创建一个 Ingress,使它通过基于 Host 头部的路由规则将请求路由至我们的服务器。这个例子中我们使用 [xip.io][14] 来避免必要的 DNS 记录配置工作。它的工作原理是将 IP 地址作为子域包含,以使用 `10.0.0.8.xip.io` 的任何子域来达到 IP `10.0.0.8`。换句话说,`my-server.10.0.0.8.xip.io` 被用于访问集群中的 Ingress 控制器。你现在就可以尝试(使用你自己的 IP,而不是 10.0.0.8)。如果没有 Ingress,你应该会访问到“默认后端”,只是一个写着“404 page not found”的页面。 + +我们可以使用以下 Ingress 让 Ingress 控制器将请求路由到我们的 Web 服务器的服务。 + +``` +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: my-server +spec: + rules: + - host: my-server.10.0.0.8.xip.io + http: + paths: + - path: / + backend: + serviceName: my-server + servicePort: 80 +``` + +将以上片段保存到 `my-ingress.yaml` 文件中,然后运行以下命令将其加入集群: + +``` +kubectl apply -f my-ingress.yaml +``` + +你现在应该能够在你选择的完全限定域名中访问到 nginx 的默认欢迎页面了。在我的例子中,它是 `my-server.10.0.0.8.xip.io`。Ingress 控制器会通过 Ingress 中包含的信息来路由请求。对 `my-server.10.0.0.8.xip.io` 的请求将被路由到 Ingress 中定义为 `backend` 的服务和端口(在本例中为 `my-server` 和 `80`)。 + +### 那么,物联网呢? + +想象如下场景:你的家或农场周围有很多的设备。它是一个具有各种硬件功能、传感器和执行器的物联网设备的异构集合。也许某些设备拥有摄像头、天气或光线传感器。其它设备可能会被连接起来,用来控制通风、灯光、百叶窗或闪烁的 LED。 + +这种情况下,你想从所有传感器中收集数据,在最终使用它来制定决策和控制执行器之前,也可能会对其进行处理和分析。除此之外,你可能还想配置一个仪表盘来可视化那些正在发生的事情。那么 Kubernetes 如何帮助我们来管理这样的事情呢?我们怎么保证 Pod 在合适的设备上运行? + +简单的答案就是“标签”。你可以根据功能来标记节点,如下所示: + +``` +kubectl label nodes = +# 举例 +kubectl label nodes node2 camera=available +``` + +一旦它们被打上标签,我们就可以轻松地使用 [nodeSelector][15] 为你的工作负载选择合适的节点。拼图的最后一块:如果你想在*所有*合适的节点上运行 Pod,那应该使用 [DaemonSet][16] 而不是部署。换句话说,应为每个使用唯一传感器的数据收集应用程序创建一个 DaemonSet,并使用 nodeSelector 确保它们仅在具有适当硬件的节点上运行。 + +服务发现功能允许 Pod 通过服务名称来寻找彼此,这项功能使得这类分布式系统的管理工作变得易如反掌。你不需要为应用配置 IP 地址或自定义端口,也不需要知道它们。相反,它们可以通过集群中的命名服务轻松找到彼此。 + +#### 充分利用空闲资源 + +随着集群的启动并运行,收集数据并控制灯光和气候,可能使你觉得你已经把它完成了。不过,集群中还有大量的计算资源可以用于其它项目。这才是 Kubernetes 真正出彩的地方。 + +你不必担心这些资源的确切位置,或者去计算是否有足够的内存来容纳额外的应用程序。这正是编排系统所解决的问题!你可以轻松地在集群中部署更多的应用,让 Kubernetes 来找出适合运行它们的位置(或是否适合运行它们)。 + +为什么不运行一个你自己的 [NextCloud][17] 实例呢?或者运行 [gitea][18]?你还可以为你所有的物联网容器设置一套 CI/CD 流水线。毕竟,如果你可以在集群中进行本地构建,为什么还要在主计算机上构建并交叉编译它们呢? + +这里的要点是,Kubernetes 可以更容易地利用那些你可能浪费掉的“隐藏”资源。Kubernetes 根据可用资源和容错处理规则来调度 Pod,因此你也无需手动完成这些工作。但是,为了帮助 Kubernetes 做出合理的决定,你绝对应该为你的工作负载添加[资源请求][19]配置。 + +### 总结 + +尽管 Kuberenetes 或一般的容器编排平台通常不会与物联网相关联,但在管理分布式系统时,使用一个编排系统肯定是有意义的。你不仅可以使用统一的方式来处理多样化和异构的设备,还可以简化它们的通信方式。此外,Kubernetes 还可以更好地对闲置资源加以利用。 + +容器技术使构建“随处运行”应用的想法成为可能。现在,Kubernetes 可以更轻松地来负责“随处”的部分。作为构建一切的不可变基础,我们使用 Fedora IoT。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/kubernetes-on-fedora-iot-with-k3s/ + +作者:[Lennart Jern][a] +选题:[lujun9972][b] +译者:[StdioA](https://github.com/StdioA) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/lennartj/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/04/k3s-1-816x345.png +[2]: https://linux.cn/article-10380-1.html +[3]: https://hub.helm.sh/ +[4]: https://k3s.io +[5]: https://docs.fedoraproject.org/en-US/iot/getting-started/ +[6]: https://github.com/rancher/k3s#open-ports--network-security +[7]: https://github.com/rancher/k3s#systemd +[8]: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/ +[9]: https://kubernetes.io/docs/concepts/services-networking/service/ +[10]: https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer +[11]: https://kubernetes.io/docs/concepts/services-networking/ingress/ +[12]: https://traefik.io/ +[13]: https://github.com/rancher/k3s/blob/master/README.md#service-load-balancer +[14]: http://xip.io/ +[15]: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ +[16]: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/ +[17]: https://nextcloud.com/ +[18]: https://gitea.io/en-us/ +[19]: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/ diff --git a/published/20190416 Building a DNS-as-a-service with OpenStack Designate.md b/published/201905/20190416 Building a DNS-as-a-service with OpenStack Designate.md similarity index 100% rename from published/20190416 Building a DNS-as-a-service with OpenStack Designate.md rename to published/201905/20190416 Building a DNS-as-a-service with OpenStack Designate.md diff --git a/translated/tech/20190416 Detecting malaria with deep learning.md b/published/201905/20190416 Detecting malaria with deep learning.md similarity index 51% rename from translated/tech/20190416 Detecting malaria with deep learning.md rename to published/201905/20190416 Detecting malaria with deep learning.md index 2089636e6a..a1ce049292 100644 --- a/translated/tech/20190416 Detecting malaria with deep learning.md +++ b/published/201905/20190416 Detecting malaria with deep learning.md @@ -1,85 +1,86 @@ [#]: collector: (lujun9972) [#]: translator: (warmfrog) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10891-1.html) [#]: subject: (Detecting malaria with deep learning) [#]: via: (https://opensource.com/article/19/4/detecting-malaria-deep-learning) -[#]: author: (Dipanjan Sarkar https://opensource.com/users/djsarkar) +[#]: author: (Dipanjan Sarkar https://opensource.com/users/djsarkar) 使用深度学习检测疟疾 ================== -人工智能结合开源硬件工具能够提升严重传染病疟疾的诊断。 + +> 人工智能结合开源硬件工具能够提升严重传染病疟疾的诊断。 + ![][1] -人工智能(AI)和开源工具,技术,和框架是促进社会进步的强有力的结合。_“健康就是财富”_可能有点陈词滥调,但它却是非常准确的!在本篇文章,我们将测试 AI 是如何与低花费,有效,精确的开源深度学习方法一起被利用来检测致死的传染病疟疾。 +人工智能(AI)和开源工具、技术和框架是促进社会进步的强有力的结合。“健康就是财富”可能有点陈词滥调,但它却是非常准确的!在本篇文章,我们将测试 AI 是如何与低成本、有效、精确的开源深度学习方法结合起来一起用来检测致死的传染病疟疾。 我既不是一个医生,也不是一个医疗保健研究者,我也绝不像他们那样合格,我只是对将 AI 应用到医疗保健研究感兴趣。在这片文章中我的想法是展示 AI 和开源解决方案如何帮助疟疾检测和减少人工劳动的方法。 ![Python and TensorFlow][2] -Python and TensorFlow: 一个构建开源深度学习方法的很棒的结合 +*Python 和 TensorFlow: 一个构建开源深度学习方法的很棒的结合* -感谢 Python 的强大 和像 TensorFlow 这样的深度学习框架,我们能够构建鲁棒的,大规模的,有效的深度学习方法。因为这些工具是自由和开源的,我们能够构建低成本的能够轻易被任何人采纳和使用的解决方案。让我们开始吧! +感谢 Python 的强大和像 TensorFlow 这样的深度学习框架,我们能够构建健壮的、大规模的、有效的深度学习方法。因为这些工具是自由和开源的,我们能够构建非常经济且易于被任何人采纳和使用的解决方案。让我们开始吧! ### 项目动机 -疟疾是由_疟原虫_造成的致死的,有传染性的,蚊子传播的疾病,主要通过受感染的雌性按蚊叮咬传播。共有五种寄生虫能够造成疟疾,但是样例中的大多数是这两种类型- _恶性疟原虫_ 和 _间日疟原虫_ 造成的。 +疟疾是由*疟原虫*造成的致死的、有传染性的、蚊子传播的疾病,主要通过受感染的雌性按蚊叮咬传播。共有五种寄生虫能够引起疟疾,但是大多数病例是这两种类型造成的:恶性疟原虫和间日疟原虫。 ![疟疾热图][3] 这个地图显示了疟疾在全球传播分布形势,尤其在热带地区,但疾病的性质和致命性是该项目的主要动机。 -如果一个雌性蚊子咬了你,蚊子携带的寄生虫进入你的血液并且开始破坏携带氧气的红细胞(RBC)。通常,疟疾的最初症状类似于流感病毒,在蚊子叮咬后,他们通常在几天或几周内发作。然而,这些致死的寄生虫可以在你的身体里生存长达一年并且不会造成任何症状,延迟治疗可能造成并发症甚至死亡。因此,早期的检查能够挽救生命。 +如果一只受感染雌性蚊子叮咬了你,蚊子携带的寄生虫进入你的血液,并且开始破坏携带氧气的红细胞(RBC)。通常,疟疾的最初症状类似于流感病毒,在蚊子叮咬后,他们通常在几天或几周内发作。然而,这些致死的寄生虫可以在你的身体里生存长达一年并且不会造成任何症状,延迟治疗可能造成并发症甚至死亡。因此,早期的检查能够挽救生命。 -世界健康组织(WHO)的[疟疾事件][4]暗示世界近乎一半的人口面临疟疾的风险,有超过 2 亿 的疟疾病例,每年由于疟疾造成的死亡近乎 40 万。这是使疟疾检测和诊断快速,简单和有效的一个动机。 +世界健康组织(WHO)的[疟疾实情][4]表明,世界近乎一半的人口面临疟疾的风险,有超过 2 亿的疟疾病例,每年由于疟疾造成的死亡将近 40 万。这是使疟疾检测和诊断快速、简单和有效的一个动机。 ### 检测疟疾的方法 -有几种方法能够用来检测和诊断疟疾。该文中的项目就是基于 Rajaraman,et al. 的论文:“[预先训练的卷积神经网络作为特征提取器,用于改善薄血涂片图像中的疟疾寄生虫检测][5]”,介绍了一些方法,包含聚合酶链反应(PCR)和快速诊断测试(RDT)。这两种测试通常在高质量的显微镜下使用,但这样的设备不是轻易能够获得的。 +有几种方法能够用来检测和诊断疟疾。该文中的项目就是基于 Rajaraman, et al. 的论文:“[预先训练的卷积神经网络作为特征提取器,用于改善薄血涂片图像中的疟疾寄生虫检测][5]”介绍的一些方法,包含聚合酶链反应(PCR)和快速诊断测试(RDT)。这两种测试通常用于无法提供高质量显微镜服务的地方。 -标准的疟疾诊断通常使基于血液涂片工作流的,根据 Carlos Ariza 的文章“[Malaria Hero: 一个更快诊断疟原虫的网络应用][6]”,我从中了解到 Adrian Rosebrock 的“[使用 Keras 的深度学习和医学图像分析][7]”。我感激这些优秀的资源的作者,让我在疟原虫预防,诊断和治疗方面有了更多的想法。 +标准的疟疾诊断通常是基于血液涂片工作流程的,根据 Carlos Ariza 的文章“[Malaria Hero:一个更快诊断疟原虫的网络应用][6]”,我从中了解到 Adrian Rosebrock 的“[使用 Keras 的深度学习和医学图像分析][7]”。我感激这些优秀的资源的作者,让我在疟原虫预防、诊断和治疗方面有了更多的想法。 ![疟原虫检测的血涂片工作流程][8] -一个疟原虫检测的血涂片工作流程 +*一个疟原虫检测的血涂片工作流程* -根据 WHO 草案,诊断通常包括对放大 100 倍的血涂片的集中检测。训练人们人工计数在 5000 个细胞中有多少红细胞中包含疟原虫。正如上述解释中引用的 Rajaraman, et al. 的论文: +根据 WHO 方案,诊断通常包括对放大 100 倍的血涂片的集中检测。受过训练的人们手工计算在 5000 个细胞中有多少红细胞中包含疟原虫。正如上述解释中引用的 Rajaraman, et al. 的论文: -> 薄血涂片帮助检测疟原虫的存在性并且帮助识别造成传染(疾病控制和抑制中心,2012)的物种。诊断准确性在很大程度上取决于人类的专业知识,并且可能受到观察者间差异和疾病流行/资源受限区域大规模诊断所造成的不利影响(Mitiku, Mengistu, and Gelaw, 2003)。可替代的技术是使用聚合酶链反应(PCR)和快速诊断测试(RDT);然而,PCR 分析受限于它的性能(Hommelsheim, et al., 2014),RDT 在疾病流行的地区成本效益低(Hawkes,Katsuva, and Masumbuko, 2009)。 +> 厚血涂片有助于检测寄生虫的存在,而薄血涂片有助于识别引起感染的寄生虫种类(疾病控制和预防中心, 2012)。诊断准确性在很大程度上取决于诊断人的专业知识,并且可能受到观察者间差异和疾病流行/资源受限区域大规模诊断所造成的不利影响(Mitiku, Mengistu 和 Gelaw, 2003)。可替代的技术是使用聚合酶链反应(PCR)和快速诊断测试(RDT);然而,PCR 分析受限于它的性能(Hommelsheim, et al., 2014),RDT 在疾病流行的地区成本效益低(Hawkes, Katsuva 和 Masumbuko, 2009)。 因此,疟疾检测可能受益于使用机器学习的自动化。 -### 疟原虫检测的深度学习 +### 疟疾检测的深度学习 -人工诊断血涂片是一个加强的人工过程,需要专业知识来分类和计数被寄生虫感染的和未感染的细胞。这个过程可能不能很好的规模化,尤其在那些专业人士不足的地区。在利用最先进的图像处理和分析技术提取人工选取特征和构建基于机器学习的分类模型方面取得了一些进展。然而,这些模型不能大规模推广,因为没有更多的数据用来训练,并且人工选取特征需要花费很长时间。 +人工诊断血涂片是一个繁重的手工过程,需要专业知识来分类和计数被寄生虫感染的和未感染的细胞。这个过程可能不能很好的规模化,尤其在那些专业人士不足的地区。在利用最先进的图像处理和分析技术提取人工选取特征和构建基于机器学习的分类模型方面取得了一些进展。然而,这些模型不能大规模推广,因为没有更多的数据用来训练,并且人工选取特征需要花费很长时间。 -深度学习模型,或者更具体地讲,卷积神经网络(CNNs),已经被证明在各种计算机视觉任务中非常有效。(如果你想有额外的关于 CNNs 的背景知识,我推荐你阅读[视觉识别的 CS2331n 卷积神经网络][9]。)简单地讲,CNN 模型的关键层包含卷积和池化层,正如下面图像显示。 +深度学习模型,或者更具体地讲,卷积神经网络(CNN),已经被证明在各种计算机视觉任务中非常有效。(如果你想更多的了解关于 CNN 的背景知识,我推荐你阅读[视觉识别的 CS2331n 卷积神经网络][9]。)简单地讲,CNN 模型的关键层包含卷积和池化层,正如下图所示。 ![A typical CNN architecture][10] -一个典型的 CNN 架构 +*一个典型的 CNN 架构* -卷积层从数据中学习空间层级模式,它是平移不变的,因此它们能够学习不同方面的图像。例如,第一个卷积层将学习小的和本地图案,例如边缘和角落,第二个卷积层学习基于第一层的特征的更大的图案,等等。这允许 CNNs 自动化提取特征并且学习对于新数据点通用的有效的特征。池化层帮助下采样和降维。 +卷积层从数据中学习空间层级模式,它是平移不变的,因此它们能够学习图像的不同方面。例如,第一个卷积层将学习小的和局部图案,例如边缘和角落,第二个卷积层将基于第一层的特征学习更大的图案,等等。这允许 CNN 自动化提取特征并且学习对于新数据点通用的有效的特征。池化层有助于下采样和减少尺寸。 -因此,CNNs 帮助自动化和规模化的特征工程。同样,在模型末尾加上密集层允许我们执行像图像分类这样的任务。使用像 CNNs 者的深度学习模型自动的疟疾检测可能非常有效,便宜和具有规模性,尤其是迁移学习和预训练模型效果非常好,甚至在少量数据的约束下。 +因此,CNN 有助于自动化和规模化的特征工程。同样,在模型末尾加上密集层允许我们执行像图像分类这样的任务。使用像 CNN 这样的深度学习模型自动的疟疾检测可能非常有效、便宜和具有规模性,尤其是迁移学习和预训练模型效果非常好,甚至在少量数据的约束下。 -Rajaraman, et al. 的论文在一个数据集上利用六个预训练模型在检测疟疾 vs 无感染样本获取到令人吃惊的 95.9% 的准确率。我们的关注点是从头开始尝试一些简单的 CNN 模型和用一个预训练的训练模型使用迁移学习来查看我们能够从相同的数据集中得到什么。我们将使用开源工具和框架,包括 Python 和 TensorFlow,来构建我们的模型。 +Rajaraman, et al. 的论文在一个数据集上利用六个预训练模型在检测疟疾对比无感染样本获取到令人吃惊的 95.9% 的准确率。我们的重点是从头开始尝试一些简单的 CNN 模型和用一个预训练的训练模型使用迁移学习来查看我们能够从相同的数据集中得到什么。我们将使用开源工具和框架,包括 Python 和 TensorFlow,来构建我们的模型。 ### 数据集 -我们分析的数据来自 Lister Hill 国家生物医学交流中心(LHNCBC),国家医学图书馆(NLM)的一部分,他们细心收集和标记了健康和受感染的血涂片图像的[公众可获得的数据集][11]。这些研究者已经开发了一个运行在 Android 智能手机的移动[疟疾检测应用][12],连接到一个传统的光学显微镜。它们使用 吉姆萨染液 将 150 个受恶性疟原虫感染的和 50 个健康病人的薄血涂片染色,这些薄血涂片是在孟加拉的吉大港医学院附属医院收集和照相的。使用智能手机的内置相机获取每个显微镜视窗内的图像。这些图片由在泰国曼谷的马希多-牛津热带医学研究所的一个专家使用幻灯片阅读器标记的。 +我们分析的数据来自 Lister Hill 国家生物医学交流中心(LHNCBC)的研究人员,该中心是国家医学图书馆(NLM)的一部分,他们细心收集和标记了公开可用的健康和受感染的血涂片图像的[数据集][11]。这些研究者已经开发了一个运行在 Android 智能手机的[疟疾检测手机应用][12],连接到一个传统的光学显微镜。它们使用吉姆萨染液将 150 个受恶性疟原虫感染的和 50 个健康病人的薄血涂片染色,这些薄血涂片是在孟加拉的吉大港医学院附属医院收集和照相的。使用智能手机的内置相机获取每个显微镜视窗内的图像。这些图片由在泰国曼谷的马希多-牛津热带医学研究所的一个专家使用幻灯片阅读器标记的。 -让我们简洁的查看数据集的结构。首先,我将安装一些基础的依赖(基于使用的操作系统)。 +让我们简要地查看一下数据集的结构。首先,我将安装一些基础的依赖(基于使用的操作系统)。 ![Installing dependencies][13] -我使用的是云上的带有一个 GPU 的基于 Debian 的操作系统,这样我能更快的运行我的模型。为了查看目录结构,我们必须安装 tree 依赖(如果我们没有安装的话)使用 **sudo apt install tree**。 +我使用的是云上的带有一个 GPU 的基于 Debian 的操作系统,这样我能更快的运行我的模型。为了查看目录结构,我们必须使用 `sudo apt install tree` 安装 `tree` 及其依赖(如果我们没有安装的话)。 ![Installing the tree dependency][14] -我们有两个文件夹包含血细胞的图像,包括受感染的和健康的。我们可以获取关于图像总数更多的细节通过输入: - +我们有两个文件夹包含血细胞的图像,包括受感染的和健康的。我们通过输入可以获取关于图像总数更多的细节: ``` import os @@ -97,7 +98,7 @@ len(infected_files), len(healthy_files) (13779, 13779) ``` -看起来我们有一个平衡的 13,779 张疟疾的 和 13,779 张非疟疾的(健康的)血细胞图像。让我们根据这些构建数据帧,我们将用这些数据帧来构建我们的数据集。 +看起来我们有一个平衡的数据集,包含 13,779 张疟疾的和 13,779 张非疟疾的(健康的)血细胞图像。让我们根据这些构建数据帧,我们将用这些数据帧来构建我们的数据集。 ``` @@ -107,8 +108,8 @@ import pandas as pd np.random.seed(42) files_df = pd.DataFrame({ -'filename': infected_files + healthy_files, -'label': ['malaria'] * len(infected_files) + ['healthy'] * len(healthy_files) + 'filename': infected_files + healthy_files, + 'label': ['malaria'] * len(infected_files) + ['healthy'] * len(healthy_files) }).sample(frac=1, random_state=42).reset_index(drop=True) files_df.head() @@ -116,9 +117,9 @@ files_df.head() ![Datasets][15] -### 构建和参所图像数据集 +### 构建和了解图像数据集 -为了构建深度学习模型,我们需要训练数据,但是我们还需要使用不可见的数据测试模型的性能。相应的,我们将使用 60:10:30 的划分用于训练,验证和测试数据集。我们将在训练期间应用训练和验证数据集并用测试数据集来检查模型的性能。 +为了构建深度学习模型,我们需要训练数据,但是我们还需要使用不可见的数据测试模型的性能。相应的,我们将使用 60:10:30 的比例来划分用于训练、验证和测试的数据集。我们将在训练期间应用训练和验证数据集,并用测试数据集来检查模型的性能。 ``` @@ -126,24 +127,23 @@ from sklearn.model_selection import train_test_split from collections import Counter train_files, test_files, train_labels, test_labels = train_test_split(files_df['filename'].values, -files_df['label'].values, -test_size=0.3, random_state=42) + files_df['label'].values, + test_size=0.3, random_state=42) train_files, val_files, train_labels, val_labels = train_test_split(train_files, -train_labels, -test_size=0.1, random_state=42) + train_labels, + test_size=0.1, random_state=42) print(train_files.shape, val_files.shape, test_files.shape) print('Train:', Counter(train_labels), '\nVal:', Counter(val_labels), '\nTest:', Counter(test_labels)) # Output (17361,) (1929,) (8268,) -Train: Counter({'healthy': 8734, 'malaria': 8627}) -Val: Counter({'healthy': 970, 'malaria': 959}) +Train: Counter({'healthy': 8734, 'malaria': 8627}) +Val: Counter({'healthy': 970, 'malaria': 959}) Test: Counter({'malaria': 4193, 'healthy': 4075}) ``` -这些图片维度并不相同,因此血涂片和细胞图像是基于人类,测试方法,图片的朝向。让我们总结我们的训练数据集的统计信息来决定最佳的图像维度(牢记,我们根本不会碰测试数据集)。 - +这些图片尺寸并不相同,因为血涂片和细胞图像是基于人、测试方法、图片方向不同而不同的。让我们总结我们的训练数据集的统计信息来决定最佳的图像尺寸(牢记,我们根本不会碰测试数据集)。 ``` import cv2 @@ -151,24 +151,25 @@ from concurrent import futures import threading def get_img_shape_parallel(idx, img, total_imgs): -if idx % 5000 == 0 or idx == (total_imgs - 1): -print('{}: working on img num: {}'.format(threading.current_thread().name, -idx)) -return cv2.imread(img).shape - + if idx % 5000 == 0 or idx == (total_imgs - 1): + print('{}: working on img num: {}'.format(threading.current_thread().name, + idx)) + return cv2.imread(img).shape + ex = futures.ThreadPoolExecutor(max_workers=None) data_inp = [(idx, img, len(train_files)) for idx, img in enumerate(train_files)] print('Starting Img shape computation:') -train_img_dims_map = ex.map(get_img_shape_parallel, -[record[0] for record in data_inp], -[record[1] for record in data_inp], -[record[2] for record in data_inp]) +train_img_dims_map = ex.map(get_img_shape_parallel, + [record[0] for record in data_inp], + [record[1] for record in data_inp], + [record[2] for record in data_inp]) train_img_dims = list(train_img_dims_map) -print('Min Dimensions:', np.min(train_img_dims, axis=0)) +print('Min Dimensions:', np.min(train_img_dims, axis=0)) print('Avg Dimensions:', np.mean(train_img_dims, axis=0)) print('Median Dimensions:', np.median(train_img_dims, axis=0)) print('Max Dimensions:', np.max(train_img_dims, axis=0)) + # Output Starting Img shape computation: ThreadPoolExecutor-0_0: working on img num: 0 @@ -176,27 +177,26 @@ ThreadPoolExecutor-0_17: working on img num: 5000 ThreadPoolExecutor-0_15: working on img num: 10000 ThreadPoolExecutor-0_1: working on img num: 15000 ThreadPoolExecutor-0_7: working on img num: 17360 -Min Dimensions: [46 46 3] -Avg Dimensions: [132.77311215 132.45757733 3.] -Median Dimensions: [130. 130. 3.] -Max Dimensions: [385 394 3] +Min Dimensions: [46 46 3] +Avg Dimensions: [132.77311215 132.45757733 3.] +Median Dimensions: [130. 130. 3.] +Max Dimensions: [385 394 3] ``` -我们应用并行处理来加速图像读取,并且在总结统计时,我们将重新调整每幅图片到 125x125 像素。让我们载入我们所有的图像并重新调整它们为这些固定的大小。 - +我们应用并行处理来加速图像读取,并且基于汇总统计结果,我们将每幅图片的尺寸重新调整到 125x125 像素。让我们载入我们所有的图像并重新调整它们为这些固定尺寸。 ``` IMG_DIMS = (125, 125) def get_img_data_parallel(idx, img, total_imgs): -if idx % 5000 == 0 or idx == (total_imgs - 1): -print('{}: working on img num: {}'.format(threading.current_thread().name, -idx)) -img = cv2.imread(img) -img = cv2.resize(img, dsize=IMG_DIMS, -interpolation=cv2.INTER_CUBIC) -img = np.array(img, dtype=np.float32) -return img + if idx % 5000 == 0 or idx == (total_imgs - 1): + print('{}: working on img num: {}'.format(threading.current_thread().name, + idx)) + img = cv2.imread(img) + img = cv2.resize(img, dsize=IMG_DIMS, + interpolation=cv2.INTER_CUBIC) + img = np.array(img, dtype=np.float32) + return img ex = futures.ThreadPoolExecutor(max_workers=None) train_data_inp = [(idx, img, len(train_files)) for idx, img in enumerate(train_files)] @@ -204,27 +204,28 @@ val_data_inp = [(idx, img, len(val_files)) for idx, img in enumerate(val_files)] test_data_inp = [(idx, img, len(test_files)) for idx, img in enumerate(test_files)] print('Loading Train Images:') -train_data_map = ex.map(get_img_data_parallel, -[record[0] for record in train_data_inp], -[record[1] for record in train_data_inp], -[record[2] for record in train_data_inp]) +train_data_map = ex.map(get_img_data_parallel, + [record[0] for record in train_data_inp], + [record[1] for record in train_data_inp], + [record[2] for record in train_data_inp]) train_data = np.array(list(train_data_map)) print('\nLoading Validation Images:') -val_data_map = ex.map(get_img_data_parallel, -[record[0] for record in val_data_inp], -[record[1] for record in val_data_inp], -[record[2] for record in val_data_inp]) +val_data_map = ex.map(get_img_data_parallel, + [record[0] for record in val_data_inp], + [record[1] for record in val_data_inp], + [record[2] for record in val_data_inp]) val_data = np.array(list(val_data_map)) print('\nLoading Test Images:') -test_data_map = ex.map(get_img_data_parallel, -[record[0] for record in test_data_inp], -[record[1] for record in test_data_inp], -[record[2] for record in test_data_inp]) +test_data_map = ex.map(get_img_data_parallel, + [record[0] for record in test_data_inp], + [record[1] for record in test_data_inp], + [record[2] for record in test_data_inp]) test_data = np.array(list(test_data_map)) -train_data.shape, val_data.shape, test_data.shape +train_data.shape, val_data.shape, test_data.shape + # Output Loading Train Images: @@ -245,23 +246,22 @@ ThreadPoolExecutor-1_8: working on img num: 8267 ((17361, 125, 125, 3), (1929, 125, 125, 3), (8268, 125, 125, 3)) ``` -我们再次应用并行处理来加速有关图像载入和重新调整大小。最终,我们获得了想要的维度的图片张量,正如之前描述的。我们现在查看一些血细胞图像样本来对我们的数据什么样有个印象。 - +我们再次应用并行处理来加速有关图像载入和重新调整大小的计算。最终,我们获得了所需尺寸的图片张量,正如前面的输出所示。我们现在查看一些血细胞图像样本,以对我们的数据有个印象。 ``` import matplotlib.pyplot as plt %matplotlib inline plt.figure(1 , figsize = (8 , 8)) -n = 0 +n = 0 for i in range(16): -n += 1 -r = np.random.randint(0 , train_data.shape[0] , 1) -plt.subplot(4 , 4 , n) -plt.subplots_adjust(hspace = 0.5 , wspace = 0.5) -plt.imshow(train_data[r[0]]/255.) -plt.title('{}'.format(train_labels[r[0]])) -plt.xticks([]) , plt.yticks([]) + n += 1 + r = np.random.randint(0 , train_data.shape[0] , 1) + plt.subplot(4 , 4 , n) + plt.subplots_adjust(hspace = 0.5 , wspace = 0.5) + plt.imshow(train_data[r[0]]/255.) + plt.title('{}'.format(train_labels[r[0]])) + plt.xticks([]) , plt.yticks([]) ``` ![Malaria cell samples][16] @@ -270,7 +270,6 @@ plt.xticks([]) , plt.yticks([]) 开始我们的模型训练前,我们必须建立一些基础的配置设置。 - ``` BATCH_SIZE = 64 NUM_CLASSES = 2 @@ -290,12 +289,12 @@ val_labels_enc = le.transform(val_labels) print(train_labels[:6], train_labels_enc[:6]) + # Output ['malaria' 'malaria' 'malaria' 'healthy' 'healthy' 'malaria'] [1 1 1 0 0 1] ``` -我们修复我们的图像维度,批大小,和历元并编码我们的分类类标签。TensorFlow 2.0 于 2019 年三月发布,这个练习是非常好的借口来试用它。 - +我们修复我们的图像尺寸、批量大小,和纪元,并编码我们的分类的类标签。TensorFlow 2.0 于 2019 年三月发布,这个练习是尝试它的完美理由。 ``` import tensorflow as tf @@ -312,24 +311,23 @@ tf.__version__ ### 深度学习训练 -在模型训练阶段,我们将构建三个深度训练模型,使用我们的训练集训练,使用验证数据比较它们的性能。我们然后保存这些模型并在之后的模型评估阶段使用它们。 +在模型训练阶段,我们将构建三个深度训练模型,使用我们的训练集训练,使用验证数据比较它们的性能。然后,我们保存这些模型并在之后的模型评估阶段使用它们。 #### 模型 1:从头开始的 CNN 我们的第一个疟疾检测模型将从头开始构建和训练一个基础的 CNN。首先,让我们定义我们的模型架构, - ``` inp = tf.keras.layers.Input(shape=INPUT_SHAPE) -conv1 = tf.keras.layers.Conv2D(32, kernel_size=(3, 3), -activation='relu', padding='same')(inp) +conv1 = tf.keras.layers.Conv2D(32, kernel_size=(3, 3), + activation='relu', padding='same')(inp) pool1 = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(conv1) -conv2 = tf.keras.layers.Conv2D(64, kernel_size=(3, 3), -activation='relu', padding='same')(pool1) +conv2 = tf.keras.layers.Conv2D(64, kernel_size=(3, 3), + activation='relu', padding='same')(pool1) pool2 = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(conv2) -conv3 = tf.keras.layers.Conv2D(128, kernel_size=(3, 3), -activation='relu', padding='same')(pool2) +conv3 = tf.keras.layers.Conv2D(128, kernel_size=(3, 3), + activation='relu', padding='same')(pool2) pool3 = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(conv3) flat = tf.keras.layers.Flatten()(pool3) @@ -343,31 +341,32 @@ out = tf.keras.layers.Dense(1, activation='sigmoid')(drop2) model = tf.keras.Model(inputs=inp, outputs=out) model.compile(optimizer='adam', -loss='binary_crossentropy', -metrics=['accuracy']) + loss='binary_crossentropy', + metrics=['accuracy']) model.summary() + # Output Model: "model" _________________________________________________________________ -Layer (type) Output Shape Param # +Layer (type) Output Shape Param # ================================================================= -input_1 (InputLayer) [(None, 125, 125, 3)] 0 +input_1 (InputLayer) [(None, 125, 125, 3)] 0 _________________________________________________________________ -conv2d (Conv2D) (None, 125, 125, 32) 896 +conv2d (Conv2D) (None, 125, 125, 32) 896 _________________________________________________________________ -max_pooling2d (MaxPooling2D) (None, 62, 62, 32) 0 +max_pooling2d (MaxPooling2D) (None, 62, 62, 32) 0 _________________________________________________________________ -conv2d_1 (Conv2D) (None, 62, 62, 64) 18496 +conv2d_1 (Conv2D) (None, 62, 62, 64) 18496 _________________________________________________________________ ... ... _________________________________________________________________ -dense_1 (Dense) (None, 512) 262656 +dense_1 (Dense) (None, 512) 262656 _________________________________________________________________ -dropout_1 (Dropout) (None, 512) 0 +dropout_1 (Dropout) (None, 512) 0 _________________________________________________________________ -dense_2 (Dense) (None, 1) 513 +dense_2 (Dense) (None, 1) 513 ================================================================= Total params: 15,102,529 Trainable params: 15,102,529 @@ -375,26 +374,26 @@ Non-trainable params: 0 _________________________________________________________________ ``` -基于这些代码的架构,我们的 CNN 模型有三个卷积和一个池化层,跟随两个致密层,以及用于正则化的丢失。让我们训练我们的模型。 +基于这些代码的架构,我们的 CNN 模型有三个卷积和一个池化层,其后是两个致密层,以及用于正则化的失活。让我们训练我们的模型。 ``` import datetime -logdir = os.path.join('/home/dipanzan_sarkar/projects/tensorboard_logs', -datetime.datetime.now().strftime("%Y%m%d-%H%M%S")) +logdir = os.path.join('/home/dipanzan_sarkar/projects/tensorboard_logs', + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")) tensorboard_callback = tf.keras.callbacks.TensorBoard(logdir, histogram_freq=1) reduce_lr = tf.keras.callbacks.ReduceLROnPlateau(monitor='val_loss', factor=0.5, -patience=2, min_lr=0.000001) + patience=2, min_lr=0.000001) callbacks = [reduce_lr, tensorboard_callback] -history = model.fit(x=train_imgs_scaled, y=train_labels_enc, -batch_size=BATCH_SIZE, -epochs=EPOCHS, -validation_data=(val_imgs_scaled, val_labels_enc), -callbacks=callbacks, -verbose=1) - +history = model.fit(x=train_imgs_scaled, y=train_labels_enc, + batch_size=BATCH_SIZE, + epochs=EPOCHS, + validation_data=(val_imgs_scaled, val_labels_enc), + callbacks=callbacks, + verbose=1) + # Output Train on 17361 samples, validate on 1929 samples @@ -439,57 +438,53 @@ l2 = ax2.legend(loc="best") ![Learning curves for basic CNN][17] -基础 CNN 学习曲线 - -我们可以看在在第五个历元,情况并没有改善很多。让我们保存这个模型用于将来的评估。 +*基础 CNN 学习曲线* +我们可以看在在第五个纪元,情况并没有改善很多。让我们保存这个模型用于将来的评估。 ``` -`model.save('basic_cnn.h5')` +model.save('basic_cnn.h5') ``` #### 深度迁移学习 -就像人类有与生俱来的能力在不同任务间传输知识,迁移学习允许我们利用从以前任务学到的知识用到新的任务,相关的任务,甚至在机器学习或深度学习的上下文中。如果想深入探究迁移学习,你应该看我的文章“[一个易于理解与现实应用一起学习深度学习中的迁移学习的指导实践][18]”和我的书[ Python 迁移学习实践][19]。 +就像人类有与生俱来在不同任务间传输知识的能力一样,迁移学习允许我们利用从以前任务学到的知识用到新的相关的任务,即使在机器学习或深度学习的情况下也是如此。如果想深入探究迁移学习,你应该看我的文章“[一个易于理解与现实应用一起学习深度学习中的迁移学习的指导实践][18]”和我的书《[Python 迁移学习实践][19]》。 ![深度迁移学习的想法][20] 在这篇实践中我们想要探索的想法是: -> 在我们的问题上下文中,我们能够利用一个预训练深度学习模型(在大数据集上训练的,像 ImageNet)通过应用和迁移知识来解决疟疾检测的问题吗? +> 在我们的问题背景下,我们能够利用一个预训练深度学习模型(在大数据集上训练的,像 ImageNet)通过应用和迁移知识来解决疟疾检测的问题吗? -我们将应用两个深度迁移学习的最流行的策略。 +我们将应用两个最流行的深度迁移学习策略。 * 预训练模型作为特征提取器 * 微调的预训练模型 - - -我们将使用预训练的 VGG-19 深度训练模型,由剑桥大学的视觉几何组(VGG)开发,作为我们的实验。一个像 VGG-19 的预训练模型在一个大的数据集上使用了很多不同的图像分类训练([Imagenet][21])。因此,这个模型应该已经学习到了鲁棒的特征层级结构,相对于你的 CNN 模型学到的特征,是空间不变的,转动不变的,平移不变的。因此,这个模型,已经从百万幅图片中学习到了一个好的特征显示,对于像疟疾检测这样的计算机视觉问题,可以作为一个好的合适新图像的特征提取器。在我们的问题中释放迁移学习的能力之前,让我们先讨论 VGG-19 模型。 +我们将使用预训练的 VGG-19 深度训练模型(由剑桥大学的视觉几何组(VGG)开发)进行我们的实验。像 VGG-19 这样的预训练模型是在一个大的数据集([Imagenet][21])上使用了很多不同的图像分类训练的。因此,这个模型应该已经学习到了健壮的特征层级结构,相对于你的 CNN 模型学到的特征,是空间不变的、转动不变的、平移不变的。因此,这个模型,已经从百万幅图片中学习到了一个好的特征显示,对于像疟疾检测这样的计算机视觉问题,可以作为一个好的合适新图像的特征提取器。在我们的问题中发挥迁移学习的能力之前,让我们先讨论 VGG-19 模型。 ##### 理解 VGG-19 模型 -VGG-19 模型是一个构建在 ImageNet 数据库之上的 19 层(卷积和全连接的)的深度学习网络,该数据库为了图像识别和分类的目的而开发。该模型由 Karen Simonyan 和 Andrew Zisserman 构建,在它们的论文”[大规模图像识别的非常深的卷积网络][22]“中描述。VGG-19 的架构模型是: +VGG-19 模型是一个构建在 ImageNet 数据库之上的 19 层(卷积和全连接的)的深度学习网络,ImageNet 数据库为了图像识别和分类的目的而开发。该模型是由 Karen Simonyan 和 Andrew Zisserman 构建的,在他们的论文“[大规模图像识别的非常深的卷积网络][22]”中进行了描述。VGG-19 的架构模型是: ![VGG-19 模型架构][23] -你可以看到我们总共有 16 个使用 3x3 卷积过滤器的卷积层,与最大的池化层来下采样,和由 4096 个单元组成的两个全连接的隐藏层,每个隐藏层之后跟随一个由 1000 个单元组成的致密层,每个单元代表 ImageNet 数据库中的一个分类。我们不需要最后三层,因为我们将使用我们自己的全连接致密层来预测疟疾。我们更关心前五块,因此我们可以利用 VGG 模型作为一个有效的特征提取器。 +你可以看到我们总共有 16 个使用 3x3 卷积过滤器的卷积层,与最大的池化层来下采样,和由 4096 个单元组成的两个全连接的隐藏层,每个隐藏层之后跟随一个由 1000 个单元组成的致密层,每个单元代表 ImageNet 数据库中的一个分类。我们不需要最后三层,因为我们将使用我们自己的全连接致密层来预测疟疾。我们更关心前五个块,因此我们可以利用 VGG 模型作为一个有效的特征提取器。 -我们将使用模型之一作为一个简单的特征提取器通过冻结五个卷积块的方式来确保它们的位权在每个时期后不会更新。对于最后一个模型,我们会应用微调到 VGG 模型,我们会解冻最后两个块(第 4 和第 5)因此当我们训练我们的模型时,它们的位权在每个时期(每批数据)被更新。 +我们将使用模型之一作为一个简单的特征提取器,通过冻结五个卷积块的方式来确保它们的位权在每个纪元后不会更新。对于最后一个模型,我们会对 VGG 模型进行微调,我们会解冻最后两个块(第 4 和第 5)因此当我们训练我们的模型时,它们的位权在每个时期(每批数据)被更新。 #### 模型 2:预训练的模型作为一个特征提取器 -为了构建这个模型,我们将利用 TensorFlow 载入 VGG-19 模型并且冻结卷积块因此我们用够将他们用作特征提取器。我们插入我们自己的致密层在末尾来执行分类任务。 - +为了构建这个模型,我们将利用 TensorFlow 载入 VGG-19 模型并冻结卷积块,因此我们能够将它们用作特征提取器。我们在末尾插入我们自己的致密层来执行分类任务。 ``` -vgg = tf.keras.applications.vgg19.VGG19(include_top=False, weights='imagenet', -input_shape=INPUT_SHAPE) +vgg = tf.keras.applications.vgg19.VGG19(include_top=False, weights='imagenet', + input_shape=INPUT_SHAPE) vgg.trainable = False # Freeze the layers for layer in vgg.layers: -layer.trainable = False - + layer.trainable = False + base_vgg = vgg base_out = base_vgg.output pool_out = tf.keras.layers.Flatten()(base_out) @@ -502,37 +497,38 @@ out = tf.keras.layers.Dense(1, activation='sigmoid')(drop2) model = tf.keras.Model(inputs=base_vgg.input, outputs=out) model.compile(optimizer=tf.keras.optimizers.RMSprop(lr=1e-4), -loss='binary_crossentropy', -metrics=['accuracy']) + loss='binary_crossentropy', + metrics=['accuracy']) model.summary() + # Output Model: "model_1" _________________________________________________________________ -Layer (type) Output Shape Param # +Layer (type) Output Shape Param # ================================================================= -input_2 (InputLayer) [(None, 125, 125, 3)] 0 +input_2 (InputLayer) [(None, 125, 125, 3)] 0 _________________________________________________________________ -block1_conv1 (Conv2D) (None, 125, 125, 64) 1792 +block1_conv1 (Conv2D) (None, 125, 125, 64) 1792 _________________________________________________________________ -block1_conv2 (Conv2D) (None, 125, 125, 64) 36928 +block1_conv2 (Conv2D) (None, 125, 125, 64) 36928 _________________________________________________________________ ... ... _________________________________________________________________ -block5_pool (MaxPooling2D) (None, 3, 3, 512) 0 +block5_pool (MaxPooling2D) (None, 3, 3, 512) 0 _________________________________________________________________ -flatten_1 (Flatten) (None, 4608) 0 +flatten_1 (Flatten) (None, 4608) 0 _________________________________________________________________ -dense_3 (Dense) (None, 512) 2359808 +dense_3 (Dense) (None, 512) 2359808 _________________________________________________________________ -dropout_2 (Dropout) (None, 512) 0 +dropout_2 (Dropout) (None, 512) 0 _________________________________________________________________ -dense_4 (Dense) (None, 512) 262656 +dense_4 (Dense) (None, 512) 262656 _________________________________________________________________ -dropout_3 (Dropout) (None, 512) 0 +dropout_3 (Dropout) (None, 512) 0 _________________________________________________________________ -dense_5 (Dense) (None, 1) 513 +dense_5 (Dense) (None, 1) 513 ================================================================= Total params: 22,647,361 Trainable params: 2,622,977 @@ -540,45 +536,42 @@ Non-trainable params: 20,024,384 _________________________________________________________________ ``` -输出是很明白的,在我们的模型中我们有了很多层,我们将只利用 VGG-19 模型的冻结层作为特征提取器。你可以使用下列代码来验证我们的模型有多少层是实际训练的,我们的网络中总共存在多少层。 - +从整个输出可以明显看出,在我们的模型中我们有了很多层,我们将只利用 VGG-19 模型的冻结层作为特征提取器。你可以使用下列代码来验证我们的模型有多少层是实际可训练的,以及我们的网络中总共存在多少层。 ``` print("Total Layers:", len(model.layers)) -print("Total trainable layers:", -sum([1 for l in model.layers if l.trainable])) +print("Total trainable layers:", + sum([1 for l in model.layers if l.trainable])) # Output Total Layers: 28 Total trainable layers: 6 ``` -我们将使用和我们之前的模型相似的配置和回调来训练我们的模型。参考 [我的 GitHub 仓库][24] 获取训练模型的完整代码。我们观察下列显示模型精确度和损失曲线。 +我们将使用和我们之前的模型相似的配置和回调来训练我们的模型。参考[我的 GitHub 仓库][24]以获取训练模型的完整代码。我们观察下列图表,以显示模型精确度和损失曲线。 ![Learning curves for frozen pre-trained CNN][25] -冻结的预训练的 CNN 的学习曲线 - -这显示了我们的模型没有像我们的基础 CNN 模型那样过拟合,但是性能有点不如我们的基础的 CNN 模型。让我们保存这个模型用户将来的评估。 +*冻结的预训练的 CNN 的学习曲线* +这表明我们的模型没有像我们的基础 CNN 模型那样过拟合,但是性能有点不如我们的基础的 CNN 模型。让我们保存这个模型,以备将来的评估。 ``` -`model.save('vgg_frozen.h5')` +model.save('vgg_frozen.h5') ``` #### 模型 3:使用图像增强来微调预训练的模型 -在我们的最后一个模型中,我们微调预定义好的 VGG-19 模型的最后两个块中层的位权。我们同样引入图像增强的概念。图像增强背后的想法和名字一样。我们从训练数据集中载入已存在的图像,并且应用转换操作,例如旋转,裁剪,转换,放大缩小,等等,来产生新的,改变的版本。由于这些随机的转换,我们每次获取到的图像不一样。我们将应用一个在 **tf.keras** 的优秀的工具叫做 **ImageDataGenerator** 来帮助构建图像增强器。 - +在我们的最后一个模型中,我们将在预定义好的 VGG-19 模型的最后两个块中微调层的位权。我们同样引入了图像增强的概念。图像增强背后的想法和其名字一样。我们从训练数据集中载入现有图像,并且应用转换操作,例如旋转、裁剪、转换、放大缩小等等,来产生新的、改变过的版本。由于这些随机转换,我们每次获取到的图像不一样。我们将应用 tf.keras 中的一个名为 ImageDataGenerator 的优秀工具来帮助构建图像增强器。 ``` train_datagen = tf.keras.preprocessing.image.ImageDataGenerator(rescale=1./255, -zoom_range=0.05, -rotation_range=25, -width_shift_range=0.05, -height_shift_range=0.05, -shear_range=0.05, horizontal_flip=True, -fill_mode='nearest') + zoom_range=0.05, + rotation_range=25, + width_shift_range=0.05, + height_shift_range=0.05, + shear_range=0.05, horizontal_flip=True, + fill_mode='nearest') val_datagen = tf.keras.preprocessing.image.ImageDataGenerator(rescale=1./255) @@ -587,13 +580,12 @@ train_generator = train_datagen.flow(train_data, train_labels_enc, batch_size=BA val_generator = val_datagen.flow(val_data, val_labels_enc, batch_size=BATCH_SIZE, shuffle=False) ``` -我们不会应用任何转换在我们的验证数据集上(除非是调整大小,它是强制性适应的)因为我们将在每个时期来评估我们的模型性能。对于在传输学习上下文中的图像增强的详细解释,请自由查看我们上述引用的[文章][18]。让我们从一批图像增强转换中查看一些样本结果。 - +我们不会对我们的验证数据集应用任何转换(除非是调整大小,因为这是必须的),因为我们将使用它评估每个纪元的模型性能。对于在传输学习环境中的图像增强的详细解释,请随时查看我上面引用的[文章][18]。让我们从一批图像增强转换中查看一些样本结果。 ``` img_id = 0 sample_generator = train_datagen.flow(train_data[img_id:img_id+1], train_labels[img_id:img_id+1], -batch_size=1) + batch_size=1) sample = [next(sample_generator) for i in range(0,5)] fig, ax = plt.subplots(1,5, figsize=(16, 6)) print('Labels:', [item[1][0] for item in sample]) @@ -602,24 +594,23 @@ l = [ax[i].imshow(sample[i][0][0]) for i in range(0,5)] ![Sample augmented images][26] -你可以清晰的看到与之前的输出中我们图像的轻微变化。我们现在构建我们的学习模型,确保 VGG-19 模型的最后两块是可以训练的。 - +你可以清晰的看到与之前的输出的我们图像的轻微变化。我们现在构建我们的学习模型,确保 VGG-19 模型的最后两块是可以训练的。 ``` -vgg = tf.keras.applications.vgg19.VGG19(include_top=False, weights='imagenet', -input_shape=INPUT_SHAPE) +vgg = tf.keras.applications.vgg19.VGG19(include_top=False, weights='imagenet', + input_shape=INPUT_SHAPE) # Freeze the layers vgg.trainable = True set_trainable = False for layer in vgg.layers: -if layer.name in ['block5_conv1', 'block4_conv1']: -set_trainable = True -if set_trainable: -layer.trainable = True -else: -layer.trainable = False - + if layer.name in ['block5_conv1', 'block4_conv1']: + set_trainable = True + if set_trainable: + layer.trainable = True + else: + layer.trainable = False + base_vgg = vgg base_out = base_vgg.output pool_out = tf.keras.layers.Flatten()(base_out) @@ -632,31 +623,32 @@ out = tf.keras.layers.Dense(1, activation='sigmoid')(drop2) model = tf.keras.Model(inputs=base_vgg.input, outputs=out) model.compile(optimizer=tf.keras.optimizers.RMSprop(lr=1e-5), -loss='binary_crossentropy', -metrics=['accuracy']) + loss='binary_crossentropy', + metrics=['accuracy']) print("Total Layers:", len(model.layers)) print("Total trainable layers:", sum([1 for l in model.layers if l.trainable])) + # Output Total Layers: 28 Total trainable layers: 16 ``` -在我们的模型中我们降低了学习率,因为我们微调的时候不想在预训练的数据集上做大的位权更新。模型的训练过程可能有轻微的不同,因为我们使用了数据生成器,因此我们应用了 **fit_generator(...)** 函数。 - +在我们的模型中我们降低了学习率,因为我们不想在微调的时候对预训练的层做大的位权更新。模型的训练过程可能有轻微的不同,因为我们使用了数据生成器,因此我们将应用 `fit_generator(...)` 函数。 ``` tensorboard_callback = tf.keras.callbacks.TensorBoard(logdir, histogram_freq=1) reduce_lr = tf.keras.callbacks.ReduceLROnPlateau(monitor='val_loss', factor=0.5, -patience=2, min_lr=0.000001) + patience=2, min_lr=0.000001) callbacks = [reduce_lr, tensorboard_callback] train_steps_per_epoch = train_generator.n // train_generator.batch_size val_steps_per_epoch = val_generator.n // val_generator.batch_size history = model.fit_generator(train_generator, steps_per_epoch=train_steps_per_epoch, epochs=EPOCHS, -validation_data=val_generator, validation_steps=val_steps_per_epoch, -verbose=1) + validation_data=val_generator, validation_steps=val_steps_per_epoch, + verbose=1) + # Output Epoch 1/25 @@ -675,21 +667,20 @@ Epoch 25/25 ![Learning curves for fine-tuned pre-trained CNN][27] -微调预训练的 CNN 的学习曲线 +*微调过的预训练 CNN 的学习曲线* 让我们保存这个模型,因此我们能够在测试集上使用。 ``` -`model.save('vgg_finetuned.h5')` +model.save('vgg_finetuned.h5') ``` -这完成了我们的模型训练阶段。我们准备好在测试集上测试我们模型的性能。 +这就完成了我们的模型训练阶段。现在我们准备好了在测试集上测试我们模型的性能。 ### 深度学习模型性能评估 -我们将评估我们在训练阶段构建的三个模型,通过在我们的测试集上做预测,因为仅仅验证是不够的!我们同样构建了一个检测工具模块叫做 **model_evaluation_utils**,我们可以使用相关分类指标用来评估使用我们深度学习模型的性能。第一步是测量我们的数据集。 - +我们将通过在我们的测试集上做预测来评估我们在训练阶段构建的三个模型,因为仅仅验证是不够的!我们同样构建了一个检测工具模块叫做 `model_evaluation_utils`,我们可以使用相关分类指标用来评估使用我们深度学习模型的性能。第一步是扩展我们的数据集。 ``` test_imgs_scaled = test_data / 255. @@ -701,7 +692,6 @@ test_imgs_scaled.shape, test_labels.shape 下一步包括载入我们保存的深度学习模型,在测试集上预测。 - ``` # Load Saved Deep Learning Models basic_cnn = tf.keras.models.load_model('./basic_cnn.h5') @@ -713,16 +703,15 @@ basic_cnn_preds = basic_cnn.predict(test_imgs_scaled, batch_size=512) vgg_frz_preds = vgg_frz.predict(test_imgs_scaled, batch_size=512) vgg_ft_preds = vgg_ft.predict(test_imgs_scaled, batch_size=512) -basic_cnn_pred_labels = le.inverse_transform([1 if pred > 0.5 else 0 -for pred in basic_cnn_preds.ravel()]) -vgg_frz_pred_labels = le.inverse_transform([1 if pred > 0.5 else 0 -for pred in vgg_frz_preds.ravel()]) -vgg_ft_pred_labels = le.inverse_transform([1 if pred > 0.5 else 0 -for pred in vgg_ft_preds.ravel()]) +basic_cnn_pred_labels = le.inverse_transform([1 if pred > 0.5 else 0 + for pred in basic_cnn_preds.ravel()]) +vgg_frz_pred_labels = le.inverse_transform([1 if pred > 0.5 else 0 + for pred in vgg_frz_preds.ravel()]) +vgg_ft_pred_labels = le.inverse_transform([1 if pred > 0.5 else 0 + for pred in vgg_ft_preds.ravel()]) ``` -下一步是应用我们的 **model_evaluation_utils** 模块根据相应分类指标来检查每个模块的性能。 - +下一步是应用我们的 `model_evaluation_utils` 模块根据相应分类指标来检查每个模块的性能。 ``` import model_evaluation_utils as meu @@ -732,30 +721,30 @@ basic_cnn_metrics = meu.get_metrics(true_labels=test_labels, predicted_labels=ba vgg_frz_metrics = meu.get_metrics(true_labels=test_labels, predicted_labels=vgg_frz_pred_labels) vgg_ft_metrics = meu.get_metrics(true_labels=test_labels, predicted_labels=vgg_ft_pred_labels) -pd.DataFrame([basic_cnn_metrics, vgg_frz_metrics, vgg_ft_metrics], -index=['Basic CNN', 'VGG-19 Frozen', 'VGG-19 Fine-tuned']) +pd.DataFrame([basic_cnn_metrics, vgg_frz_metrics, vgg_ft_metrics], + index=['Basic CNN', 'VGG-19 Frozen', 'VGG-19 Fine-tuned']) ``` ![Model accuracy][28] -看起来我们的第三个模型在我们的测试集上执行的最好,给出了一个模型精确性为 96% 的 F1得分,比起上述我们早期引用的研究论文和文章中提及的复杂的模型是相当好的。 +看起来我们的第三个模型在我们的测试集上执行的最好,给出了一个模型精确性为 96% 的 F1 得分,这非常好,与我们之前提到的研究论文和文章中的更复杂的模型相当。 ### 总结 -疟疾检测不是一个简单的程序,全球的合格的人员的可获得性在样例诊断和治疗当中是一个严重的问题。我们看到一个关于疟疾的有趣的真实世界的医学影像案例。易于构建的,开源的技术利用 AI 在检测疟疾方面可以给我们最先进的精确性,因此允许 AI 对社会是有益的。 +疟疾检测不是一个简单的过程,全球的合格人员的不足在病例诊断和治疗当中是一个严重的问题。我们研究了一个关于疟疾的有趣的真实世界的医学影像案例。利用 AI 的、易于构建的、开源的技术在检测疟疾方面可以为我们提供最先进的精确性,因此使 AI 具有社会效益。 -我鼓励你检查这片文章中提到的文章和研究论文,没有它们,我就不能形成概念并写出来。如果你对运行和采纳这些技术感兴趣,本篇文章所有的代码都可以在[我的 GitHub 仓库][24]获得。记得从[官方网站][11]下载数据。 +我鼓励你查看这篇文章中提到的文章和研究论文,没有它们,我就不能形成概念并写出来。如果你对运行和采纳这些技术感兴趣,本篇文章所有的代码都可以在[我的 GitHub 仓库][24]获得。记得从[官方网站][11]下载数据。 -让我们希望在健康医疗方面更多的采纳开源的 AI 能力,使它在世界范围内变得便宜些,易用些。 +让我们希望在健康医疗方面更多的采纳开源的 AI 能力,使它在世界范围内变得更便宜、更易用。 -------------------------------------------------------------------------------- via: https://opensource.com/article/19/4/detecting-malaria-deep-learning -作者:[Dipanjan (DJ) Sarkar (Red Hat)][a] +作者:[Dipanjan (DJ) Sarkar][a] 选题:[lujun9972][b] 译者:[warmfrog](https://github.com/warmfrog) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20190416 Inter-process communication in Linux- Using pipes and message queues.md b/published/201905/20190416 Inter-process communication in Linux- Using pipes and message queues.md similarity index 100% rename from published/20190416 Inter-process communication in Linux- Using pipes and message queues.md rename to published/201905/20190416 Inter-process communication in Linux- Using pipes and message queues.md diff --git a/published/20190419 Building scalable social media sentiment analysis services in Python.md b/published/201905/20190419 Building scalable social media sentiment analysis services in Python.md similarity index 100% rename from published/20190419 Building scalable social media sentiment analysis services in Python.md rename to published/201905/20190419 Building scalable social media sentiment analysis services in Python.md diff --git a/published/20190419 Getting started with social media sentiment analysis in Python.md b/published/201905/20190419 Getting started with social media sentiment analysis in Python.md similarity index 100% rename from published/20190419 Getting started with social media sentiment analysis in Python.md rename to published/201905/20190419 Getting started with social media sentiment analysis in Python.md diff --git a/published/20190419 This is how System76 does open hardware.md b/published/201905/20190419 This is how System76 does open hardware.md similarity index 100% rename from published/20190419 This is how System76 does open hardware.md rename to published/201905/20190419 This is how System76 does open hardware.md diff --git a/published/20190422 2 new apps for music tweakers on Fedora Workstation.md b/published/201905/20190422 2 new apps for music tweakers on Fedora Workstation.md similarity index 100% rename from published/20190422 2 new apps for music tweakers on Fedora Workstation.md rename to published/201905/20190422 2 new apps for music tweakers on Fedora Workstation.md diff --git a/published/20190422 8 environment-friendly open software projects you should know.md b/published/201905/20190422 8 environment-friendly open software projects you should know.md similarity index 100% rename from published/20190422 8 environment-friendly open software projects you should know.md rename to published/201905/20190422 8 environment-friendly open software projects you should know.md diff --git a/published/20190422 Tracking the weather with Python and Prometheus.md b/published/201905/20190422 Tracking the weather with Python and Prometheus.md similarity index 100% rename from published/20190422 Tracking the weather with Python and Prometheus.md rename to published/201905/20190422 Tracking the weather with Python and Prometheus.md diff --git a/published/20190423 Four Methods To Check The Default Gateway Or Router IP Address In Linux.md b/published/201905/20190423 Four Methods To Check The Default Gateway Or Router IP Address In Linux.md similarity index 100% rename from published/20190423 Four Methods To Check The Default Gateway Or Router IP Address In Linux.md rename to published/201905/20190423 Four Methods To Check The Default Gateway Or Router IP Address In Linux.md diff --git a/published/20190423 How To Monitor Disk I-O Activity Using iotop And iostat Commands In Linux.md b/published/201905/20190423 How To Monitor Disk I-O Activity Using iotop And iostat Commands In Linux.md similarity index 100% rename from published/20190423 How To Monitor Disk I-O Activity Using iotop And iostat Commands In Linux.md rename to published/201905/20190423 How To Monitor Disk I-O Activity Using iotop And iostat Commands In Linux.md diff --git a/translated/tech/20190425 Automate backups with restic and systemd.md b/published/201905/20190425 Automate backups with restic and systemd.md similarity index 62% rename from translated/tech/20190425 Automate backups with restic and systemd.md rename to published/201905/20190425 Automate backups with restic and systemd.md index f3ac58b09c..677a87c3f4 100644 --- a/translated/tech/20190425 Automate backups with restic and systemd.md +++ b/published/201905/20190425 Automate backups with restic and systemd.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10875-1.html) [#]: subject: (Automate backups with restic and systemd) [#]: via: (https://fedoramagazine.org/automate-backups-with-restic-and-systemd/) [#]: author: (Link Dupont https://fedoramagazine.org/author/linkdupont/) @@ -12,18 +12,17 @@ ![][1] -及时备份很重要。即使在 [Fedora Magazine][3] 中,[备份软件][2] 也是一个常见的讨论话题。本文演示了如何仅使用 systemd 以及 **restic** 来自动备份。 +及时备份很重要。即使在 [Fedora Magazine][3] 中,[备份软件][2] 也是一个常见的讨论话题。本文演示了如何仅使用 systemd 以及 `restic` 来自动备份。 +有关 `restic` 的介绍,请查看我们的文章[在 Fedora 上使用 restic 进行加密备份][4]。然后继续阅读以了解更多详情。 -有关 restic 的介绍,请查看我们的文章[在 Fedora 上使用 restic 进行加密备份][4]。然后继续阅读以了解更多详情。 - -为了自动创建快照以及清理数据,需要运行两个 systemd 服务。第一个运行_备份_命令的服务需要以常规频率运行。第二个服务负责数据清理。 +为了自动创建快照以及清理数据,需要运行两个 systemd 服务。第一个运行*备份*命令的服务需要以常规频率运行。第二个服务负责数据清理。 如果你根本不熟悉 systemd,那么这是个很好的学习机会。查看 [Magazine 上关于 systemd 的系列文章] [5],从单元文件的这个入门开始: -> [systemd 单元文件基础][6] +- [systemd 单元文件基础][6] -如果你还没有安装 restic,请注意它在官方的 Fedora 仓库中。要安装它,请[带上 sudo][7] 运行此命令: +如果你还没有安装 `restic`,请注意它在官方的 Fedora 仓库中。要安装它,请[带上 sudo][7] 运行此命令: ``` $ sudo dnf install restic @@ -31,7 +30,7 @@ $ sudo dnf install restic ### 备份 -首先,创建 _~/.config/systemd/user/restic-backup.service_。将下面的文本复制并粘贴到文件中以获得最佳效果。 +首先,创建 `~/.config/systemd/user/restic-backup.service`。将下面的文本复制并粘贴到文件中以获得最佳效果。 ``` [Unit] @@ -43,7 +42,7 @@ ExecStartPost=restic forget --verbose --tag systemd.timer --group-by "paths,tags EnvironmentFile=%h/.config/restic-backup.conf ``` -此服务引用环境文件来加载密钥(例如 _RESTIC_PASSWORD_)。创建 _~/.config/restic-backup.conf_。复制并粘贴以下内容以获得最佳效果。此示例使用 BackBlaze B2 存储。请相应地调整 ID、密钥、仓库和密码值。 +此服务引用环境文件来加载密钥(例如 `RESTIC_PASSWORD`)。创建 `~/.config/restic-backup.conf`。复制并粘贴以下内容以获得最佳效果。此示例使用 BackBlaze B2 存储。请相应地调整 ID、密钥、仓库和密码值。 ``` BACKUP_PATHS="/home/rupert" @@ -58,9 +57,9 @@ RESTIC_REPOSITORY=b2:XXXXXXXXXXXXXXXXXX:/ RESTIC_PASSWORD=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ``` -现在已安装该服务,请重新加载 systemd:_systemctl -user daemon-reload_。尝试手动运行该服务以创建备份:_systemctl -user start restic-backup_。 +现在已安装该服务,请重新加载 systemd:`systemctl -user daemon-reload`。尝试手动运行该服务以创建备份:`systemctl -user start restic-backup`。 -因为该服务类型是 _oneshot_,它将运行一次并退出。验证服务运行并根据需要创建快照后,设置计时器以定期运行此服务。例如,要每天运行 _restic-backup.service_,请按如下所示创建 _~/.config/systemd/user/restic-backup.timer_。再次复制并粘贴此文本: +因为该服务类型是*一次性*,它将运行一次并退出。验证服务运行并根据需要创建快照后,设置计时器以定期运行此服务。例如,要每天运行 `restic-backup.service`,请按如下所示创建 `~/.config/systemd/user/restic-backup.timer`。再次复制并粘贴此文本: ``` [Unit] @@ -80,7 +79,7 @@ $ systemctl --user enable --now restic-backup.timer ### 清理 -虽然主服务运行 _forget_ 命令仅保留保留策略中的快照,但实际上并未从 restic 仓库中删除数据。 _prune_ 命令检查仓库和当前快照,并删除与快照无关的所有数据。由于 _prune_ 可能是一个耗时的过程,因此无需在每次运行备份时运行。这是第二个服务和计时器的场景。首先,通过复制和粘贴此文本来创建文件 _~/.config/systemd/user/restic-prune.service_: +虽然主服务运行 `forget` 命令仅保留保留策略中的快照,但实际上并未从 `restic` 仓库中删除数据。 `prune` 命令检查仓库和当前快照,并删除与快照无关的所有数据。由于 `prune` 可能是一个耗时的过程,因此无需在每次运行备份时运行。这是第二个服务和计时器的场景。首先,通过复制和粘贴此文本来创建文件 `~/.config/systemd/user/restic-prune.service`: ``` [Unit] @@ -91,7 +90,7 @@ ExecStart=restic prune EnvironmentFile=%h/.config/restic-backup.conf ``` -与主 _restic-backup.service_ 服务类似,_restic-prune_ 也是 onehot 服务,并且可以手动运行。设置完服务后,创建 _~/.config/systemd/user/restic-prune.timer_ 并启用相应的计时器: +与主 `restic-backup.service` 服务类似,`restic-prune` 也是一次性服务,并且可以手动运行。设置完服务后,创建 `~/.config/systemd/user/restic-prune.timer` 并启用相应的计时器: ``` [Unit] @@ -103,11 +102,11 @@ Persistent=true WantedBy=timers.target ``` -就是这些了!restic 将会每日运行并按月清理数据。 +就是这些了!`restic` 将会每日运行并按月清理数据。 * * * -图片来自 _[Unsplash][9]_ 由 _[ Samuel Zeller][8]_ 拍摄。 +图片来自 [Unsplash][9] 由 [Samuel Zeller][8] 拍摄。 -------------------------------------------------------------------------------- @@ -116,7 +115,7 @@ via: https://fedoramagazine.org/automate-backups-with-restic-and-systemd/ 作者:[Link Dupont][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20190430 Upgrading Fedora 29 to Fedora 30.md b/published/201905/20190430 Upgrading Fedora 29 to Fedora 30.md similarity index 100% rename from published/20190430 Upgrading Fedora 29 to Fedora 30.md rename to published/201905/20190430 Upgrading Fedora 29 to Fedora 30.md diff --git a/published/201905/20190501 3 apps to manage personal finances in Fedora.md b/published/201905/20190501 3 apps to manage personal finances in Fedora.md new file mode 100644 index 0000000000..dee4fb0985 --- /dev/null +++ b/published/201905/20190501 3 apps to manage personal finances in Fedora.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10903-1.html) +[#]: subject: (3 apps to manage personal finances in Fedora) +[#]: via: (https://fedoramagazine.org/3-apps-to-manage-personal-finances-in-fedora/) +[#]: author: (Paul W. Frields https://fedoramagazine.org/author/pfrields/) + +3 款在 Fedora 中管理个人财务的应用 +====== + +![][1] + +网上有很多可以用来管理你个人财务的服务。虽然它们可能很方便,但这通常也意味着将你最宝贵的个人数据放在你无法监控的公司。也有些人对这些不太在意。 + +无论你是否在意,你可能会对你自己系统上的应用感兴趣。这意味着如果你不想,你的数据永远不会离开自己的计算机。这三款之一可能就是你想找的。 + +### HomeBank + +HomeBank 是一款可以管理多个账户的全功能软件。它很容易设置并保持更新。它有多种方式画出你的分类和负债,以便你可以看到资金流向何处。它可以通过官方 Fedora 仓库下载。 + +![A simple account set up in HomeBank with a few transactions.][2] + +要安装 HomeBank,请打开“软件中心”,搜索 “HomeBank”,然后选择该应用。单击“安装”将其添加到你的系统中。HomeBank 也可以通过 Flatpak 安装。 + +### KMyMoney + +KMyMoney 是一个成熟的应用,它已经存在了很长一段时间。它有一系列稳定的功能,可帮助你管理多个帐户,包括资产、负债、税收等。KMyMoney 包含一整套用于管理投资和进行预测的工具。它还提供大量报告,以了解你的资金运作方式。 + +![A subset of the many reports available in KMyMoney.][3] + +要安装它,请使用软件中心,或使用命令行: + +``` +$ sudo dnf install kmymoney +``` + +### GnuCash + +用于个人财务的最受欢迎的免费 GUI 应用之一是 GnuCash。GnuCash 不仅可以用于个人财务。它还有管理企业收入、资产和负债的功能。这并不意味着你不能用它来管理自己的账户。从查看[在线教程和指南][4]开始了解。 + +![Checking account records shown in GnuCash.][5] + +打开“软件中心”,搜索 “GnuCash”,然后选择应用。单击“安装”将其添加到你的系统中。或者如上所述使用 `dnf install` 来安装 “gnucash” 包。 + +它现在可以通过 Flathub 安装,这使得安装变得简单。如果你没有安装 Flathub,请查看 [Fedora Magazine 上的这篇文章][6]了解如何使用它。这样你也可以在终端使用 `flatpak install gnucash` 命令。 + +* * * + +照片由 [Fabian Blank][7] 拍摄,发布在 [Unsplash][8] 上。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/3-apps-to-manage-personal-finances-in-fedora/ + +作者:[Paul W. Frields][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/04/personal-finance-3-apps-816x345.jpg +[2]: https://fedoramagazine.org/wp-content/uploads/2019/04/Screenshot-from-2019-04-28-16-16-16-1024x637.png +[3]: https://fedoramagazine.org/wp-content/uploads/2019/04/Screenshot-from-2019-04-28-16-27-10-1-1024x649.png +[4]: https://www.gnucash.org/viewdoc.phtml?rev=3&lang=C&doc=guide +[5]: https://fedoramagazine.org/wp-content/uploads/2019/04/Screenshot-from-2019-04-28-16-41-27-1024x631.png +[6]: https://fedoramagazine.org/install-flathub-apps-fedora/ +[7]: https://unsplash.com/photos/pElSkGRA2NU?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[8]: https://unsplash.com/search/photos/money?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/translated/talk/20190501 Cisco issues critical security warning for Nexus data-center switches.md b/published/201905/20190501 Cisco issues critical security warning for Nexus data-center switches.md similarity index 54% rename from translated/talk/20190501 Cisco issues critical security warning for Nexus data-center switches.md rename to published/201905/20190501 Cisco issues critical security warning for Nexus data-center switches.md index c9df2cf407..e71bd21d6b 100644 --- a/translated/talk/20190501 Cisco issues critical security warning for Nexus data-center switches.md +++ b/published/201905/20190501 Cisco issues critical security warning for Nexus data-center switches.md @@ -1,67 +1,60 @@ [#]: collector: (lujun9972) [#]: translator: (hopefully2333) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10876-1.html) [#]: subject: (Cisco issues critical security warning for Nexus data-center switches) -[#]: via: (https://www.networkworld.com/article/3392858/cisco-issues-critical-security-warning-for-nexus-data-center-switches.html#tk.rss_all) +[#]: via: (https://www.networkworld.com/article/3392858/cisco-issues-critical-security-warning-for-nexus-data-center-switches.html) [#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) 思科针对 Nexus 数据中心交换机发出危急安全预警 ====== -思科围绕着 Nexus 的交换机、Firepower 防火墙和其他设备,发布了 40 个安全报告。 + +> 思科围绕着 Nexus 的交换机、Firepower 防火墙和其他设备,发布了 40 个安全报告。 + ![Thinkstock][1] -今天思科发布了 40 个左右的安全报告,但只有其中的一个被评定为“危急”-思科 Nexus 9000 系列应用中心基础设施(ACI)模式数据中心交换机中的一个漏洞,可能会让攻击者隐秘地访问到系统资源。 +日前,思科发布了 40 个左右的安全报告,但只有其中的一个被评定为“[危急][2]”:思科 Nexus 9000 系列应用中心基础设施(ACI)模式数据中心交换机中的一个漏洞,可能会让攻击者隐秘地访问到系统资源。 这个新发现的漏洞,被通用漏洞评分系统给到了 9.8 分(满分 10 分),思科表示,它是思科 Nexus 9000 系列的安全 shell (ssh)密钥管理方面的问题,这个漏洞允许远程攻击者以 root 用户的权限来连接到受影响的系统。 -**[ 另请阅读:如何规划一个软件定义的数据中心网络 ][3] ]** +思科表示,“**这个漏洞是因为所有的设备都存在一对默认的 ssh 密钥对**,攻击者可以使用提取到的密钥材料,并通过 IPv6 来创建连接到目标设备的 SSH 连接。这个漏洞仅能通过 IPv6 来进行利用,IPv4 不会被攻击”。 -思科表示,“这个漏洞是因为所有的设备都存在一对默认的 ssh 密钥对,攻击者可以使用提取到的密钥材料,并通过 IPv6 来创建连接到目标设备的 SSH 连接。这个漏洞仅能通过 IPv6 来进行利用,IPv4 不会被攻击”。 +型号为 Nexus 9000 系列且 NX-OS 软件版本在 14.1 之前的设备会受此漏洞的影响,该公司表示没有解决这个问题的变通办法。 -型号为 Nexus 9000 系列且 NX-OS 软件版本在 14.1 之前的设备会受此漏洞的影响,该公司表示没有解决这个问题的办法。 - -然而,思科公司已经为解决这个漏洞发布了免费的软件更新。 +然而,思科公司已经为解决这个漏洞[发布了免费的软件更新][4]。 该公司同样对 Nexus 9000 系列发布了一个“高危”级别的安全预警报告,报告中表示存在一种攻击,允许攻击者以 root 用户权限在受影响的设备上执行任意操作系统命令。思科表示,如果要用这种方式攻击成功,攻击者需要对应设备的有效的管理员用户凭证。 -思科表示,这个漏洞是由于过于宽泛的系统文件权限造成的。攻击者可以通过向受影响的设备进行认证,构造一个精心设计的命令字符串,并将这个字符串写入到特定位置的文件里。攻击者通过这种方式来利用这个漏洞。 - -**[[通过 PluralSight 的综合在线课程成为一名认证信息安全系统工程师。现在提供为期 10 天的免费试用!][6] ]** +[思科表示][5],这个漏洞是由于过于宽泛的系统文件权限造成的。攻击者可以通过向受影响的设备进行认证,构造一个精心设计的命令字符串,并将这个字符串写入到特定位置的文件里。攻击者通过这种方式来利用这个漏洞。 思科发布了解决这个漏洞的软件更新。 另外两个被评为“高危”级别的漏洞的影响范围同样包括 Nexus 9000 系列: -思科 Nexus 9000 系列软件后台操作功能中的漏洞,能够允许一个已认证的本地攻击者在受影响的设备上提升到 root 权限。这个漏洞是由于在受影响的设备上用户提供的文件验证不充分。思科表示,攻击者可以通过登录到受影响设备的命令行界面,并在文件系统的特定目录中构造一个精心设计过的文件,以此来利用这个漏洞。 +- 思科 Nexus 9000 系列软件后台操作功能中的[漏洞][7],能够允许一个已认证的本地攻击者在受影响的设备上提权到 root 权限。这个漏洞是由于在受影响的设备上用户提供的文件验证不充分。思科表示,攻击者可以通过登录到受影响设备的命令行界面,并在文件系统的特定目录中构造一个精心设计过的文件,以此来利用这个漏洞。 +- 交换机软件后台操作功能中的[弱点][7]能够允许攻击者登录到受影响设备的命令行界面,并在文件系统的特定目录里创建一个精心构造过的文件。思科表示,这个漏洞是由于在受影响的设备上用户提供的文件验证不充分。 -交换机软件后台操作功能中的弱点能够允许攻击者登录到受影响设备的命令行界面,并在文件系统的特定目录里创建一个精心构造过的文件。思科表示,这个漏洞是由于在受影响的设备上用户提供的文件验证不充分。 - - - -思科同样为这些漏洞发布了软件更新。 +思科同样为这些漏洞[发布了软件更新][4]。 此外,这些安全警告中的一部分是针对思科 FirePower 防火墙系列中大量的“高危”漏洞警告。 -例如,思科写道,思科 Firepower 威胁防御软件的 SMB 协议预处理检测引擎中的多个漏洞能够允许未认证的相邻、远程攻击者造成拒绝服务攻击(DoS)的情况。 +例如,思科[写道][8],思科 Firepower 威胁防御软件的 SMB 协议预处理检测引擎中的多个漏洞能够允许未认证的相邻、远程攻击者造成拒绝服务攻击(DoS)的情况。 -思科表示,思科 Firepower 2100 系列中思科 Firepower 软件里的内部数据包处理功能有另一个漏洞,能够让未认证的远程攻击者造成受影响的设备停止处理流量,从而导致 DOS 的情况。 +思科表示,思科 Firepower 2100 系列中思科 Firepower 软件里的内部数据包处理功能有[另一个漏洞][9],能够让未认证的远程攻击者造成受影响的设备停止处理流量,从而导致 DOS 的情况。 -软件补丁可用于这些漏洞。 +[软件补丁][4]可用于这些漏洞。 -其他的产品,比如思科自适应安全虚拟设备和 web 安全设备同样也有高优先级的补丁。 - -加入 Facebook 和 LinkedIn 中的网络世界社区,在最上面的主题里做评论。 +其他的产品,比如思科[自适应安全虚拟设备][10]和 [web 安全设备][11]同样也有高优先级的补丁。 -------------------------------------------------------------------------------- -via: https://www.networkworld.com/article/3392858/cisco-issues-critical-security-warning-for-nexus-data-center-switches.html#tk.rss_all +via: https://www.networkworld.com/article/3392858/cisco-issues-critical-security-warning-for-nexus-data-center-switches.html 作者:[Michael Cooney][a] 选题:[lujun9972][b] 译者:[hopefully2333](https://github.com/hopefully2333) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20190501 Write faster C extensions for Python with Cython.md b/published/201905/20190501 Write faster C extensions for Python with Cython.md similarity index 100% rename from published/20190501 Write faster C extensions for Python with Cython.md rename to published/201905/20190501 Write faster C extensions for Python with Cython.md diff --git a/published/20190502 Format Python however you like with Black.md b/published/201905/20190502 Format Python however you like with Black.md similarity index 100% rename from published/20190502 Format Python however you like with Black.md rename to published/201905/20190502 Format Python however you like with Black.md diff --git a/translated/tech/20190502 Get started with Libki to manage public user computer access.md b/published/201905/20190502 Get started with Libki to manage public user computer access.md similarity index 61% rename from translated/tech/20190502 Get started with Libki to manage public user computer access.md rename to published/201905/20190502 Get started with Libki to manage public user computer access.md index d8cda03623..347196d553 100644 --- a/translated/tech/20190502 Get started with Libki to manage public user computer access.md +++ b/published/201905/20190502 Get started with Libki to manage public user computer access.md @@ -1,28 +1,29 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10880-1.html) [#]: subject: (Get started with Libki to manage public user computer access) [#]: via: (https://opensource.com/article/19/5/libki-computer-access) [#]: author: (Don Watkins https://opensource.com/users/don-watkins/users/tony-thomas) -开始使用 Libk i来管理公共用户访问计算机 +使用 Libki 来管理公共用户访问计算机 ====== -Libki 是一个跨平台的计算机预约和时间管理系统。 -![][1] +> Libki 是一个跨平台的计算机预约和用时管理系统。 -提供公共计算机的图书馆、学校、学院和其他组织需要一种管理用户访问权限的好方法 - 否则,就无法阻止某些人独占机器并确保每个人都有公平的时间。这是 [Libki][2] 要解决的问题。 +![](https://img.linux.net.cn/data/attachment/album/201905/20/230201d26yuo261uu6s61i.jpg) -Libki 是一个面向 Windows 和 Linux PC 的开源、跨平台的计算机预约和时间管理系统。它提供了一个基于 Web 的服务器和一个基于 Web 的管理系统,员工可以使用它来管理计算机访问,包括创建和删除用户、设置帐户时间限制、登出和禁止用户以及设置访问限制。 +提供公共计算机的图书馆、学校、学院和其他组织需要一种管理用户访问权限的好方法 —— 否则,就无法阻止某些人独占机器并确保每个人都有公平的用时。这是 [Libki][2] 要解决的问题。 -根据首席开发人员 [Kyle Hall][3] 所说,Libki 主要用于 PC 时间控制,作为 Envisionware 的专有计算机访问控制软件的开源替代品。当用户登录 Libki 管理的计算机时,他们会有一段时间来使用计算机。时间到了之后,他们就会被登出。时间默认设置为 45 分钟,但可以使用基于 Web 的管理系统轻松调整。一些组织在登出用户之前提供 24 小时访问权限,而有的组织则使用它来跟踪使用情况而不设置时间限制。 +Libki 是一个面向 Windows 和 Linux PC 的开源、跨平台的计算机预约和用时管理系统。它提供了一个基于 Web 的服务器和一个基于 Web 的管理系统,员工可以使用它来管理计算机访问,包括创建和删除用户、设置帐户用时限制、登出和禁止用户以及设置访问限制。 -Kyle 目前是 [ByWater Solutions][4] 的首席开发人员,该公司为图书馆提供开源软件解决方案(包括 Libki)。在职业生涯早期,他在宾夕法尼亚州的[米德维尔公共图书馆][5]担任 IT 技术时开发了 Libki。在其他员工的午休期间,偶尔会要求他关注孩子的房间。图书馆使用纸质注册表来管理对儿童房间计算机的访问,这意味着不断的监督和检查,以确保来到那里的人能够公平地使用。 +根据其首席开发人员 [Kyle Hall][3] 所说,Libki 主要用于 PC 用时控制,作为 Envisionware 出品的专有计算机访问控制软件的开源替代品。当用户登录 Libki 管理的计算机时,他们会有一段使用计算机的时间。时间到了之后,他们就会被登出。时间默认设置为 45 分钟,但可以使用基于 Web 的管理系统轻松调整。一些组织在登出用户之前提供 24 小时访问权限,而有的组织则使用它来跟踪使用情况而不设置用时限制。 -Kyle 说,“我发现这个系统很麻烦、很尴尬,我想找到一个解决方案。这个解决方案需要同时是 FOSS 和跨平台的。最后,没有现有的软件适合我们的特殊需求,那就是为什么我开发了 Libki。“ +Kyle 目前是 [ByWater Solutions][4] 的首席开发人员,该公司为图书馆提供开源软件解决方案(包括 Libki)。在职业生涯早期,他在宾夕法尼亚州的[米德维尔公共图书馆][5]担任 IT 技术时开发了 Libki。在其他员工的午休期间,偶尔会要求他关注孩子们的房间。图书馆使用纸质注册表来管理对儿童房间计算机的访问,这意味着不断的监督和检查,以确保来到那里的人能够公平地使用。 -或者,正如 Libki 的网站所宣称的那样,“Libki 的诞生是为了避免与青少年互动,现在允许图书馆员避免与世界各地的青少年互动!” +Kyle 说,“我发现这很笨拙而不便的,我想找到一个解决方案。这个解决方案需要同时是 FOSS 和跨平台的。最后,没有现有的软件适合我们的特殊需求,那就是为什么我开发了 Libki。“ + +或者,正如 Libki 的网站所宣称的那样,“Libki 的诞生是为了避免与青少年打交道(的麻烦),现在允许图书馆员避免与世界各地的青少年打交道(的麻烦)!” ### 易于安装和使用 @@ -30,7 +31,7 @@ Kyle 说,“我发现这个系统很麻烦、很尴尬,我想找到一个解 我计划在我们当地的图书馆支持 Libki,但我想知道在那些没有 IT 相关经验的人或者无法构建和部署服务器的图书馆是怎样的。Kyle 说:“ByWater Solutions 可以云端托管 Libki 服务器,这使得每个人的维护和管理变得更加简单。” -Kyle 表示,ByWater 并不打算将 Libki 与其最受欢迎的产品,开源集成图书馆系统 (ILS)Koha 或其支持的任何其他[项目][7]捆绑在一起。他说: “Libki 和 Koha 是不同[类型]的软件,满足不同的需求,但它们在图书馆中确实很好地协同工作。事实上,我很早就开发了 Libki 的 SIP2 集成,因此它可以支持使用 Koha 进行单点登录,“ 。 +Kyle 表示,ByWater 并不打算将 Libki 与其最受欢迎的产品,开源集成图书馆系统 (ILS)Koha 或其支持的任何其他[项目][7]捆绑在一起。他说: “Libki 和 Koha 是不同[类型]的软件,满足不同的需求,但它们在图书馆中确实很好地协同工作。事实上,我很早就开发了 Libki 的 SIP2 集成,因此它可以支持使用 Koha 进行单点登录。“ ### 如何贡献 @@ -40,10 +41,10 @@ Libki 客户端是 GPLv3 许可,Libki 服务器是 AGPLv3 许可。Kyle 说他 via: https://opensource.com/article/19/5/libki-computer-access -作者:[Don Watkins ][a] +作者:[Don Watkins][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/201905/20190503 API evolution the right way.md b/published/201905/20190503 API evolution the right way.md new file mode 100644 index 0000000000..069687be7a --- /dev/null +++ b/published/201905/20190503 API evolution the right way.md @@ -0,0 +1,693 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10900-1.html) +[#]: subject: (API evolution the right way) +[#]: via: (https://opensource.com/article/19/5/api-evolution-right-way) +[#]: author: (A. Jesse https://opensource.com/users/emptysquare) + +API 演进的正确方式 +====== + +> 负责任的库作者与其用户的十个约定。 + +![Browser of things](https://img.linux.net.cn/data/attachment/album/201905/26/134131jnymeg7t7gmo6qcy.jpg) + +想象一下你是一个造物主,为一个生物设计一个身体。出于仁慈,你希望它能随着时间进化:首先,因为它必须对环境的变化作出反应;其次,因为你的智慧在增长,你对这个小东西想到了更好的设计,它不应该永远保持一个样子。 + +![Serpents][2] + +然而,这个生物可能有赖于其目前解剖学的特征。你不能无所顾忌地添加翅膀或改变它的身材比例。它需要一个有序的过程来适应新的身体。作为一个负责任的设计者,你如何才能温柔地引导这种生物走向更大的进步呢? + +对于负责任的库维护者也是如此。我们向依赖我们代码的人保证我们的承诺:我们会发布 bug 修复和有用的新特性。如果对库的未来有利,我们有时会删除某些特性。我们会不断创新,但我们不会破坏使用我们库的人的代码。我们怎样才能一次实现所有这些目标呢? + +### 添加有用的特性 + +你的库不应该永远保持不变:你应该添加一些特性,使你的库更适合用户。例如,如果你有一个爬行动物类,并且如果有个可以飞行的翅膀是有用的,那就去添加吧。 + +``` +class Reptile: + @property + def teeth(self): + return 'sharp fangs' + + # 如果 wings 是有用的,那就添加它! + @property + def wings(self): + return 'majestic wings' +``` + +但要注意,特性是有风险的。考虑 Python 标准库中以下功能,看看它出了什么问题。 + +``` +bool(datetime.time(9, 30)) == True +bool(datetime.time(0, 0)) == False +``` + +这很奇怪:将任何时间对象转换为布尔值都会得到 True,但午夜时间除外。(更糟糕的是,时区感知时间的规则更加奇怪。) + +我已经写了十多年的 Python 了,但直到上周才发现这条规则。这种奇怪的行为会在用户代码中引起什么样的 bug? + +比如说一个日历应用程序,它带有一个创建事件的函数。如果一个事件有一个结束时间,那么函数也应该要求它有一个开始时间。 + +``` +def create_event(day, + start_time=None, + end_time=None): + if end_time and not start_time: + raise ValueError("Can't pass end_time without start_time") + +# 女巫集会从午夜一直开到凌晨 4 点 +create_event(datetime.date.today(), + datetime.time(0, 0), + datetime.time(4, 0)) +``` + +不幸的是,对于女巫来说,从午夜开始的事件无法通过校验。当然,一个了解午夜怪癖的细心程序员可以正确地编写这个函数。 + +``` +def create_event(day, + start_time=None, + end_time=None): + if end_time is not None and start_time is None: + raise ValueError("Can't pass end_time without start_time") +``` + +但这种微妙之处令人担忧。如果一个库作者想要创建一个伤害用户的 API,那么像午夜的布尔转换这样的“特性”很有效。 + +![Man being chased by an alligator][3] + +但是,负责任的创建者的目标是使你的库易于正确使用。 + +这个功能是由 Tim Peters 在 2002 年首次编写 datetime 模块时造成的。即时是像 Tim 这样的奠基 Python 的高手也会犯错误。[这个怪异之处后来被消除了][4],现在所有时间的布尔值都是 True。 + +``` +# Python 3.5 以后 + +bool(datetime.time(9, 30)) == True +bool(datetime.time(0, 0)) == True +``` + +不知道午夜怪癖的古怪之处的程序员现在可以从这种晦涩的 bug 中解脱出来,但是一想到任何依赖于古怪的旧行为的代码现在没有注意变化,我就会感到紧张。如果从来没有实现这个糟糕的特性,情况会更好。这就引出了库维护者的第一个承诺: + +#### 第一个约定:避免糟糕的特性 + +最痛苦的变化是你必须删除一个特性。一般来说,避免糟糕特性的一种方法是少添加特性!没有充分的理由,不要使用公共方法、类、功能或属性。因此: + +#### 第二个约定:最小化特性 + +特性就像孩子:在充满激情的瞬间孕育,但是它们必须要支持多年(LCTT 译注:我怀疑作者在开车,可是我没有证据)。不要因为你能做傻事就去做傻事。不要画蛇添足! + +![Serpents with and without feathers][5] + +但是,当然,在很多情况下,用户需要你的库中尚未提供的东西,你如何选择合适的功能给他们?以下另一个警示故事。 + +### 一个来自 asyncio 的警示故事 + +你可能知道,当你调用一个协程函数,它会返回一个协程对象: + +``` +async def my_coroutine(): + pass + +print(my_coroutine()) +``` + +``` + +``` + +你的代码必须 “等待await” 这个对象以此来运行协程。人们很容易忘记这一点,所以 asyncio 的开发人员想要一个“调试模式”来捕捉这个错误。当协程在没有等待的情况下被销毁时,调试模式将打印一个警告,并在其创建的行上进行回溯。 + +当 Yury Selivanov 实现调试模式时,他添加了一个“协程装饰器”的基础特性。装饰器是一个函数,它接收一个协程并返回任何内容。Yury 使用它在每个协程上接入警告逻辑,但是其他人可以使用它将协程转换为字符串 “hi!”。 + +``` +import sys + +def my_wrapper(coro): + return 'hi!' + +sys.set_coroutine_wrapper(my_wrapper) + +async def my_coroutine(): + pass + +print(my_coroutine()) +``` + +``` +hi! +``` + +这是一个地狱般的定制。它改变了 “异步async" 的含义。调用一次 `set_coroutine_wrapper` 将在全局永久改变所有的协程函数。正如 [Nathaniel Smith 所说][6]:“一个有问题的 API” 很容易被误用,必须被删除。如果 asyncio 开发人员能够更好地按照其目标来设计该特性,他们就可以避免删除该特性的痛苦。负责任的创建者必须牢记这一点: + +#### 第三个约定:保持特性单一 + +幸运的是,Yury 有良好的判断力,他将该特性标记为临时,所以 asyncio 用户知道不能依赖它。Nathaniel 可以用更单一的功能替换 `set_coroutine_wrapper`,该特性只定制回溯深度。 + +``` +import sys + +sys.set_coroutine_origin_tracking_depth(2) + +async def my_coroutine(): + pass + +print(my_coroutine()) + +``` + +``` + + +RuntimeWarning:'my_coroutine' was never awaited + +Coroutine created at (most recent call last) + File "script.py", line 8, in + print(my_coroutine()) +``` + +这样好多了。没有可以更改协程的类型的其他全局设置,因此 asyncio 用户无需编写防御代码。造物主应该像 Yury 一样有远见。 + +#### 第四个约定:标记实验特征“临时” + +如果你只是预感你的生物需要犄角和四叉舌,那就引入这些特性,但将它们标记为“临时”。 + +![Serpent with horns][7] + +你可能会发现犄角是无关紧要的,但是四叉舌是有用的。在库的下一个版本中,你可以删除前者并标记后者为正式的。 + +### 删除特性 + +无论我们如何明智地指导我们的生物进化,总会有一天想要删除一个正式特征。例如,你可能已经创建了一只蜥蜴,现在你选择删除它的腿。也许你想把这个笨拙的家伙变成一条时尚而现代的蟒蛇。 + +![Lizard transformed to snake][8] + +删除特性主要有两个原因。首先,通过用户反馈或者你自己不断增长的智慧,你可能会发现某个特性是个坏主意。午夜怪癖的古怪行为就是这种情况。或者,最初该特性可能已经很好地适应了你的库环境,但现在生态环境发生了变化,也许另一个神发明了哺乳动物,你的生物想要挤进哺乳动物的小洞穴里,吃掉里面美味的哺乳动物,所以它不得不失去双腿。 + +![A mouse][9] + +同样,Python 标准库会根据语言本身的变化删除特性。考虑 asyncio 的 Lock 功能,在把 `await` 作为一个关键字添加进来之前,它一直在等待: + +``` +lock = asyncio.Lock() + +async def critical_section(): + await lock + try: + print('holding lock') + finally: + lock.release() +``` + +但是现在,我们可以做“异步锁”: + + +``` +lock = asyncio.Lock() + +async def critical_section(): + async with lock: + print('holding lock') +``` + +新方法好多了!很短,并且在一个大函数中使用其他 try-except 块时不容易出错。因为“尽量找一种,最好是唯一一种明显的解决方案”,[旧语法在 Python 3.7 中被弃用][10],并且很快就会被禁止。 + +不可避免的是,生态变化会对你的代码产生影响,因此要学会温柔地删除特性。在此之前,请考虑删除它的成本或好处。负责任的维护者不会愿意让用户更改大量代码或逻辑。(还记得 Python 3 在重新添加会 `u` 字符串前缀之前删除它是多么痛苦吗?)如果代码删除是机械性的动作,就像一个简单的搜索和替换,或者如果该特性是危险的,那么它可能值得删除。 + +#### 是否删除特性 + +![Balance scales][11] + +反对 | 支持 +---|--- +代码必须改变 | 改变是机械性的 +逻辑必须改变 | 特性是危险的 + +就我们饥饿的蜥蜴而言,我们决定删除它的腿,这样它就可以滑进老鼠洞里吃掉它。我们该怎么做呢?我们可以删除 `walk` 方法,像下面一样修改代码: + +``` +class Reptile: + def walk(self): + print('step step step') +``` + +变成这样: + +``` +class Reptile: + def slither(self): + print('slide slide slide') +``` + +这不是一个好主意,这个生物习惯于走路!或者,就库而言,你的用户拥有依赖于现有方法的代码。当他们升级到最新库版本时,他们的代码将会崩溃。 + +``` +# 用户的代码,哦,不! +Reptile.walk() +``` + +因此,负责任的创建者承诺: + +#### 第五条预定:温柔地删除 + +温柔地删除一个特性需要几个步骤。从用腿走路的蜥蜴开始,首先添加新方法 `slither`。接下来,弃用旧方法。 + +``` +import warnings + +class Reptile: + def walk(self): + warnings.warn( + "walk is deprecated, use slither", + DeprecationWarning, stacklevel=2) + print('step step step') + + def slither(self): + print('slide slide slide') +``` + +Python 的 warnings 模块非常强大。默认情况下,它会将警告输出到 stderr,每个代码位置只显示一次,但你可以禁用警告或将其转换为异常,以及其它选项。 + +一旦将这个警告添加到库中,PyCharm 和其他 IDE 就会使用删除线呈现这个被弃用的方法。用户马上就知道该删除这个方法。 + +> Reptile().~~walk()~~ + +当他们使用升级后的库运行代码时会发生什么? + +``` +$ python3 script.py + +DeprecationWarning: walk is deprecated, use slither + script.py:14: Reptile().walk() + +step step step +``` + +默认情况下,他们会在 stderr 上看到警告,但脚本会成功并打印 “step step step”。警告的回溯显示必须修复用户代码的哪一行。(这就是 `stacklevel` 参数的作用:它显示了用户需要更改的调用,而不是库中生成警告的行。)请注意,错误消息有指导意义,它描述了库用户迁移到新版本必须做的事情。 + +你的用户可能会希望测试他们的代码,并证明他们没有调用弃用的库方法。仅警告不会使单元测试失败,但异常会失败。Python 有一个命令行选项,可以将弃用警告转换为异常。 + +``` +> python3 -Werror::DeprecationWarning script.py + +Traceback (most recent call last): + File "script.py", line 14, in + Reptile().walk() + File "script.py", line 8, in walk + DeprecationWarning, stacklevel=2) +DeprecationWarning: walk is deprecated, use slither +``` + +现在,“step step step” 没有输出出来,因为脚本以一个错误终止。 + +因此,一旦你发布了库的一个版本,该版本会警告已启用的 `walk` 方法,你就可以在下一个版本中安全地删除它。对吧? + +考虑一下你的库用户在他们项目的 `requirements` 中可能有什么。 + +``` +# 用户的 requirements.txt 显示 reptile 包的依赖关系 +reptile +``` + +下次他们部署代码时,他们将安装最新版本的库。如果他们尚未处理所有的弃用,那么他们的代码将会崩溃,因为代码仍然依赖 `walk`。你需要温柔一点,你必须向用户做出三个承诺:维护更改日志,选择版本化方案和编写升级指南。 + +#### 第六个约定:维护变更日志 + +你的库必须有更改日志,其主要目的是宣布用户所依赖的功能何时被弃用或删除。 + +> **版本 1.1 中的更改** +> +> **新特性** +> +> * 新功能 Reptile.slither() +> +> **弃用** +> +> * Reptile.walk() 已弃用,将在 2.0 版本中删除,请使用 slither() + +负责任的创建者会使用版本号来表示库发生了怎样的变化,以便用户能够对升级做出明智的决定。“版本化方案”是一种用于交流变化速度的语言。 + +#### 第七个约定:选择一个版本化方案 + +有两种广泛使用的方案,[语义版本控制][12]和基于时间的版本控制。我推荐任何库都进行语义版本控制。Python 的风格在 [PEP 440][13] 中定义,像 `pip` 这样的工具可以理解语义版本号。 + +如果你为库选择语义版本控制,你可以使用版本号温柔地删除腿,例如: + +> 1.0: 第一个“稳定”版,带有 `walk()` +> 1.1: 添加 `slither()`,废弃 `walk()` +> 2.0: 删除 `walk()` + +你的用户依赖于你的库的版本应该有一个范围,例如: + +``` +# 用户的 requirements.txt +reptile>=1,<2 +``` + +这允许他们在主要版本中自动升级,接收错误修正并可能引发一些弃用警告,但不会升级到**下**个主要版本并冒着更改破坏其代码的风险。 + +如果你遵循基于时间的版本控制,则你的版本可能会编号: + +> 2017.06.0: 2017 年 6 月的版本 +> 2018.11.0: 添加 `slither()`,废弃 `walk()` +> 2019.04.0: 删除 `walk()` + +用户可以这样依赖于你的库: + +``` +# 用户的 requirements.txt,基于时间控制的版本 +reptile==2018.11.* +``` + +这非常棒,但你的用户如何知道你的版本方案,以及如何测试代码来进行弃用呢?你必须告诉他们如何升级。 + +#### 第八个约定:写一个升级指南 + +下面是一个负责任的库创建者如何指导用户: + +> **升级到 2.0** +> +> **从弃用的 API 迁移** +> +> 请参阅更改日志以了解已弃用的特性。 +> +> **启用弃用警告** +> +> 升级到 1.1 并使用以下代码测试代码: +> +> `python -Werror::DeprecationWarning` +> +>​​​​​​ 现在可以安全地升级了。 + +你必须通过向用户显示命令行选项来教会用户如何处理弃用警告。并非所有 Python 程序员都知道这一点 —— 我自己就每次都得查找这个语法。注意,你必须*发布*一个版本,它输出来自每个弃用的 API 的警告,以便用户可以在再次升级之前使用该版本进行测试。在本例中,1.1 版本是小版本。它允许你的用户逐步重写代码,分别修复每个弃用警告,直到他们完全迁移到最新的 API。他们可以彼此独立地测试代码和库的更改,并隔离 bug 的原因。 + +如果你选择语义版本控制,则此过渡期将持续到下一个主要版本,从 1.x 到 2.0,或从 2.x 到 3.0 以此类推。删除生物腿部的温柔方法是至少给它一个版本来调整其生活方式。不要一次性把腿删掉! + +![A skink][14] + +版本号、弃用警告、更改日志和升级指南可以协同工作,在不违背与用户约定的情况下温柔地改进你的库。[Twisted 项目的兼容性政策][15] 解释的很漂亮: + +> “先行者总是自由的” +> +> 运行的应用程序在没有任何警告的情况下都可以升级为 Twisted 的一个次要版本。 +> +> 换句话说,任何运行其测试而不触发 Twisted 警告的应用程序应该能够将其 Twisted 版本升级至少一次,除了可能产生新警告之外没有任何不良影响。 +> + +现在,我们的造物主已经获得了智慧和力量,可以通过添加方法来添加特性,并温柔地删除它们。我们还可以通过添加参数来添加特性,但这带来了新的难度。你准备好了吗? + +### 添加参数 + +想象一下,你只是给了你的蛇形生物一对翅膀。现在你必须允许它选择是滑行还是飞行。目前它的 `move` 功能只接受一个参数。 + +``` +# 你的库代码 +def move(direction): + print(f'slither {direction}') + +# 用户的应用 +move('north') +``` + +你想要添加一个 `mode` 参数,但如果用户升级库,这会破坏他们的代码,因为他们只传递了一个参数。 + +``` +# 你的库代码 +def move(direction, mode): + assert mode in ('slither', 'fly') + print(f'{mode} {direction}') + +# 一个用户的代码,出现错误! +move('north') +``` + +一个真正聪明的创建者者会承诺不会以这种方式破坏用户的代码。 + +#### 第九条约定:兼容地添加参数 + +要保持这个约定,请使用保留原始行为的默认值添加每个新参数。 + +``` +# 你的库代码 +def move(direction, mode='slither'): + assert mode in ('slither', 'fly') + print(f'{mode} {direction}') + +# 用户的应用 +move('north') +``` + +随着时间推移,参数是函数演化的自然历史。它们首先列出最老的参数,每个都有默认值。库用户可以传递关键字参数以选择特定的新行为,并接受所有其他行为的默认值。 + +``` +# 你的库代码 +def move(direction, + mode='slither', + turbo=False, + extra_sinuous=False, + hail_lyft=False): + # ... + +# 用户应用 +move('north', extra_sinuous=True) +``` + +但是有一个危险,用户可能会编写如下代码: + +``` +# 用户应用,简写 +move('north', 'slither', False, True) +``` + +如果在你在库的下一个主要版本中去掉其中一个参数,例如 `turbo`,会发生什么? + +``` +# 你的库代码,下一个主要版本中 "turbo" 被删除 +def move(direction, + mode='slither', + extra_sinuous=False, + hail_lyft=False): + # ... + +# 用户应用,简写 +move('north', 'slither', False, True) +``` + +用户的代码仍然能编译,这是一件坏事。代码停止了曲折的移动并开始招呼 Lyft,这不是它的本意。我相信你可以预测我接下来要说的内容:删除参数需要几个步骤。当然,首先弃用 `trubo` 参数。我喜欢这种技术,它可以检测任何用户的代码是否依赖于这个参数。 + +``` +# 你的库代码 +_turbo_default = object() + +def move(direction, + mode='slither', + turbo=_turbo_default, + extra_sinuous=False, + hail_lyft=False): + if turbo is not _turbo_default: + warnings.warn( + "'turbo' is deprecated", + DeprecationWarning, + stacklevel=2) + else: + # The old default. + turbo = False +``` + +但是你的用户可能不会注意到警告。警告声音不是很大:它们可以在日志文件中被抑制或丢失。用户可能会漫不经心地升级到库的下一个主要版本——那个删除 `turbo` 的版本。他们的代码运行时将没有错误、默默做错误的事情!正如 Python 之禅所说:“错误绝不应该被默默 pass”。实际上,爬行动物的听力很差,所有当它们犯错误时,你必须非常大声地纠正它们。 + +![Woman riding an alligator][16] + +保护用户的最佳方法是使用 Python 3 的星型语法,它要求调用者传递关键字参数。 + +``` +# 你的库代码 +# 所有 “*” 后的参数必须以关键字方式传输。 +def move(direction, + *, + mode='slither', + turbo=False, + extra_sinuous=False, + hail_lyft=False): + # ... + +# 用户代码,简写 +# 错误!不能使用位置参数,关键字参数是必须的 +move('north', 'slither', False, True) +``` + +有了这个星,以下是唯一允许的语法: + +``` +# 用户代码 +move('north', extra_sinuous=True) +``` + +现在,当你删除 `turbo` 时,你可以确定任何依赖于它的用户代码都会明显地提示失败。如果你的库也支持 Python2,这没有什么大不了。你可以模拟星型语法([归功于 Brett Slatkin][17]): + +``` +# 你的库代码,兼容 Python 2 +def move(direction, **kwargs): + mode = kwargs.pop('mode', 'slither') + turbo = kwargs.pop('turbo', False) + sinuous = kwargs.pop('extra_sinuous', False) + lyft = kwargs.pop('hail_lyft', False) + + if kwargs: + raise TypeError('Unexpected kwargs: %r' + % kwargs) + +# ... +``` + +要求关键字参数是一个明智的选择,但它需要远见。如果允许按位置传递参数,则不能仅在以后的版本中将其转换为仅关键字。所以,现在加上星号。你可以在 asyncio API 中观察到,它在构造函数、方法和函数中普遍使用星号。尽管到目前为止,`Lock` 只接受一个可选参数,但 asyncio 开发人员立即添加了星号。这是幸运的。 + +``` +# In asyncio. +class Lock: + def __init__(self, *, loop=None): + # ... +``` + +现在,我们已经获得了改变方法和参数的智慧,同时保持与用户的约定。现在是时候尝试最具挑战性的进化了:在不改变方法或参数的情况下改变行为。 + +### 改变行为 + +假设你创造的生物是一条响尾蛇,你想教它一种新行为。 + +![Rattlesnake][18] + +横向移动!这个生物的身体看起来是一样的,但它的行为会发生变化。我们如何为这一进化步骤做好准备? + +![][19] + +*Image by HCA [[CC BY-SA 4.0][20]], [via Wikimedia Commons][21], 由 Opensource.com 修改* + +当行为在没有新函数或新参数的情况下发生更改时,负责任的创建者可以从 Python 标准库中学习。很久以前,os 模块引入了 `stat` 函数来获取文件统计信息,比如创建时间。起初,这个时间总是整数。 + +``` +>>> os.stat('file.txt').st_ctime +1540817862 +``` + +有一天,核心开发人员决定在 `os.stat` 中使用浮点数来提供亚秒级精度。但他们担心现有的用户代码还没有做好准备更改。于是他们在 Python 2.3 中创建了一个设置 `stat_float_times`,默认情况下是 `False` 。用户可以将其设置为 True 来选择浮点时间戳。 + +``` +>>> # Python 2.3. +>>> os.stat_float_times(True) +>>> os.stat('file.txt').st_ctime +1540817862.598021 +``` + +从 Python 2.5 开始,浮点时间成为默认值,因此 2.5 及之后版本编写的任何新代码都可以忽略该设置并期望得到浮点数。当然,你可以将其设置为 `False` 以保持旧行为,或将其设置为 `True` 以确保所有 Python 版本都得到浮点数,并为删除 `stat_float_times` 的那一天准备代码。 + +多年过去了,在 Python 3.1 中,该设置已被弃用,以便为人们为遥远的未来做好准备,最后,经过数十年的旅程,[这个设置被删除][22]。浮点时间现在是唯一的选择。这是一个漫长的过程,但负责任的神灵是有耐心的,因为我们知道这个渐进的过程很有可能于意外的行为变化拯救用户。 + +#### 第十个约定:逐渐改变行为 + +以下是步骤: + + * 添加一个标志来选择新行为,默认为 `False`,如果为 `False` 则发出警告 + * 将默认值更改为 `True`,表示完全弃用标记 + * 删除该标志 + +如果你遵循语义版本控制,版本可能如下: + +库版本 | 库 API | 用户代码 +---|---|--- +1.0 | 没有标志 | 预期的旧行为 +1.1 | 添加标志,默认为 `False`,如果是 `False`,则警告 | 设置标志为 `True`,处理新行为 +2.0 | 改变默认为 `True`,完全弃用标志 | 处理新行为 +3.0 | 移除标志 | 处理新行为 + +你需要**两**个主要版本来完成该操作。如果你直接从“添加标志,默认为 `False`,如果是 `False` 则发出警告”变到“删除标志”,而没有中间版本,那么用户的代码将无法升级。为 1.1 正确编写的用户代码必须能够升级到下一个版本,除了新警告之外,没有任何不良影响,但如果在下一个版本中删除了该标志,那么该代码将崩溃。一个负责任的神明从不违反扭曲的政策:“先行者总是自由的”。 + +### 负责任的创建者 + +![Demeter][23] + +我们的 10 个约定大致可以分为三类: + +**谨慎发展** + + 1. 避免不良功能 + 2. 最小化特性 + 3. 保持功能单一 + 4. 标记实验特征“临时” + 5. 温柔删除功能 + +**严格记录历史** + + 1. 维护更改日志 + 2. 选择版本方案 + 3. 编写升级指南 + +**缓慢而明显地改变** + + 1. 兼容添加参数 + 2. 逐渐改变行为 + +如果你对你所创造的物种保持这些约定,你将成为一个负责任的造物主。你的生物的身体可以随着时间的推移而进化,一直在改善和适应环境的变化,而不是在生物没有准备好就突然改变。如果你维护一个库,请向用户保留这些承诺,这样你就可以在不破坏依赖该库的代码的情况下对库进行更新。 + +* * * + +_这篇文章最初是在 [A. Jesse Jiryu Davis 的博客上'][24]出现的,经允许转载。_ + +插图参考: + + * [《世界进步》, Delphian Society, 1913][25] + * [《走进蛇的历史》, Charles Owen, 1742][26] + * [关于哥斯达黎加的 batrachia 和爬行动物,关于尼加拉瓜和秘鲁的爬行动物和鱼类学的记录, Edward Drinker Cope, 1875][27] + * [《自然史》, Richard Lydekker et. al., 1897][28] + * [Mes Prisons, Silvio Pellico, 1843][29] + * [Tierfotoagentur / m.blue-shadow][30] + * [洛杉矶公共图书馆, 1930][31] + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/api-evolution-right-way + +作者:[A. Jesse][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/emptysquare +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_desktop_website_checklist_metrics.png?itok=OKKbl1UR (Browser of things) +[2]: https://opensource.com/sites/default/files/uploads/praise-the-creator.jpg (Serpents) +[3]: https://opensource.com/sites/default/files/uploads/bite.jpg (Man being chased by an alligator) +[4]: https://bugs.python.org/issue13936 +[5]: https://opensource.com/sites/default/files/uploads/feathers.jpg (Serpents with and without feathers) +[6]: https://bugs.python.org/issue32591 +[7]: https://opensource.com/sites/default/files/uploads/horns.jpg (Serpent with horns) +[8]: https://opensource.com/sites/default/files/uploads/lizard-to-snake.jpg (Lizard transformed to snake) +[9]: https://opensource.com/sites/default/files/uploads/mammal.jpg (A mouse) +[10]: https://bugs.python.org/issue32253 +[11]: https://opensource.com/sites/default/files/uploads/scale.jpg (Balance scales) +[12]: https://semver.org +[13]: https://www.python.org/dev/peps/pep-0440/ +[14]: https://opensource.com/sites/default/files/uploads/skink.jpg (A skink) +[15]: https://twistedmatrix.com/documents/current/core/development/policy/compatibility-policy.html +[16]: https://opensource.com/sites/default/files/uploads/loudly.jpg (Woman riding an alligator) +[17]: http://www.informit.com/articles/article.aspx?p=2314818 +[18]: https://opensource.com/sites/default/files/uploads/rattlesnake.jpg (Rattlesnake) +[19]: https://opensource.com/sites/default/files/articles/neonate_sidewinder_sidewinding_with_tracks_unlabeled.png +[20]: https://creativecommons.org/licenses/by-sa/4.0 +[21]: https://commons.wikimedia.org/wiki/File:Neonate_sidewinder_sidewinding_with_tracks_unlabeled.jpg +[22]: https://bugs.python.org/issue31827 +[23]: https://opensource.com/sites/default/files/uploads/demeter.jpg (Demeter) +[24]: https://emptysqua.re/blog/api-evolution-the-right-way/ +[25]: https://www.gutenberg.org/files/42224/42224-h/42224-h.htm +[26]: https://publicdomainreview.org/product-att/artist/charles-owen/ +[27]: https://archive.org/details/onbatrachiarepti00cope/page/n3 +[28]: https://www.flickr.com/photos/internetarchivebookimages/20556001490 +[29]: https://www.oldbookillustrations.com/illustrations/stationery/ +[30]: https://www.alamy.com/mediacomp/ImageDetails.aspx?ref=D7Y61W +[31]: https://www.vintag.es/2013/06/riding-alligator-c-1930s.html diff --git a/published/201905/20190503 Check your spelling at the command line with Ispell.md b/published/201905/20190503 Check your spelling at the command line with Ispell.md new file mode 100644 index 0000000000..a4c84a78d8 --- /dev/null +++ b/published/201905/20190503 Check your spelling at the command line with Ispell.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10895-1.html) +[#]: subject: (Check your spelling at the command line with Ispell) +[#]: via: (https://opensource.com/article/19/5/spelling-command-line-ispell) +[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) + +使用 Ispell 在命令行中检查拼写 +====== + +> Ispell 可以帮助你在纯文本中消除超过 50 种语言的拼写错误。 + +![Command line prompt](https://img.linux.net.cn/data/attachment/album/201905/24/192644wqqv6d0lztmqoqyl.jpg) + +好的拼写是一种技巧。它是一项需要时间学习和掌握的技能。也就是说,有些人从来没有完全掌握这种技能,我知道有两三个出色的作家就无法完全掌握拼写。 + +即使你拼写得很好,偶尔也会输入错字。特别是在最后期限前如果你快速敲击键盘,那就更是如此。无论你的拼写的是什么,通过拼写检查器检查你所写的内容总是一个好主意。 + +我用[纯文本][2]完成了我的大部分写作,并经常使用名为 [Aspell][3] 的命令行拼写检查器来完成这项工作。Aspell 不是唯一的工具。你可能还想要看下不错的 [Ispell][4]。 + +### 入门 + +自 1971 年以来,Ispell 就以各种形式出现过。不要被它的年龄欺骗。Ispell 仍然是一个可以在 21 世纪高效使用的应用。 + +在开始之前,请打开终端窗口并输入 `which ispell` 来检查计算机上是否安装了 Ispell。如果未安装,请打开发行版的软件包管理器并从那里安装 Ispell。 + +不要忘记为你使用的语言安装词典。我唯一使用的语言是英语,所以我只需下载美国和英国英语字典。你可以不局限于我的(也是唯一的)母语。Ispell 有[超过 50 种语言的词典][5]。 + +![Installing Ispell dictionaries][6] + +### 使用 Ispell + +如果你还没有猜到,Ispell 只能用在文本文件。这包括用 HTML、LaTeX 和 [nroff 或 troff][7] 标记的文档。之后会有更多相关内容。 + +要开始使用,请打开终端窗口并进入包含要运行拼写检查的文件的目录。输入 `ispell` 后跟文件名,然后按回车键。 + +![Checking spelling with Ispell][8] + +Ispell 高亮了它无法识别的第一个词。如果单词拼写错误,Ispell 通常会提供一个或多个备选方案。按下 `R`,然后按下正确选择旁边的数字。在上面的截图中,我按了 `R` 和 `0` 来修复错误。 + +另一方面,如果单词拼写正确,请按下 `A` 然后移动到下一个拼写错误的单词。 + +继续这样做直到到达文件的末尾。Ispell 会保存你的更改,创建你刚检查的文件的备份(扩展名为 `.bak`),然后关闭。 + +### 其他几个选项 + +此示例说明了 Ispell 的基本用法。这个程序有[很多选项][9],有些你*可能*会用到,而另一些你*可能永远*不会使用。让我们快速看下我经常使用的一些。 + +之前我提到过 Ispell 可以用于某些标记语言。你需要告诉它文件的格式。启动 Ispell 时,为 TeX 或 LaTeX 文件添加 `-t`,为 HTML 文件添加 `-H`,对于 groff 或 troff 文件添加 `-n`。例如,如果输入 `ispell -t myReport.tex`,Ispell 将忽略所有标记。 + +如果你不想在检查文件后创建备份文件,请将 `-x` 添加到命令行。例如,`ispell -x myFile.txt`。 + +如果 Ispell 遇到拼写正确但不在其字典中的单词,比如名字,会发生什么?你可以按 `I` 将该单词添加到个人单词列表中。这会将单词保存到 `/home` 目录下的 `.ispell_default` 的文件中。 + +这些是我在使用 Ispell 时最有用的选项,但请查看 [Ispell 的手册页][9]以了解其所有选项。 + +Ispell 比 Aspell 或其他命令行拼写检查器更好或者更快么?我会说它不比其他的差或者慢。Ispell 不是适合所有人。它也许也不适合你。但有更多选择也不错,不是么? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/spelling-command-line-ispell + +作者:[Scott Nesbitt][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/scottnesbitt +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg (Command line prompt) +[2]: https://plaintextproject.online +[3]: https://opensource.com/article/18/2/how-check-spelling-linux-command-line-aspell +[4]: https://www.cs.hmc.edu/~geoff/ispell.html +[5]: https://www.cs.hmc.edu/~geoff/ispell-dictionaries.html +[6]: https://opensource.com/sites/default/files/uploads/ispell-install-dictionaries.png (Installing Ispell dictionaries) +[7]: https://opensource.com/article/18/2/how-format-academic-papers-linux-groff-me +[8]: https://opensource.com/sites/default/files/uploads/ispell-checking.png (Checking spelling with Ispell) +[9]: https://www.cs.hmc.edu/~geoff/ispell-man.html diff --git a/translated/tech/20190503 Say goodbye to boilerplate in Python with attrs.md b/published/201905/20190503 Say goodbye to boilerplate in Python with attrs.md similarity index 53% rename from translated/tech/20190503 Say goodbye to boilerplate in Python with attrs.md rename to published/201905/20190503 Say goodbye to boilerplate in Python with attrs.md index e80b5b03e1..f6d3d5a0c0 100644 --- a/translated/tech/20190503 Say goodbye to boilerplate in Python with attrs.md +++ b/published/201905/20190503 Say goodbye to boilerplate in Python with attrs.md @@ -1,26 +1,27 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) +[#]: reviewer: (wxy) [#]: publisher: ( ) [#]: url: ( ) [#]: subject: (Say goodbye to boilerplate in Python with attrs) [#]: via: (https://opensource.com/article/19/5/python-attrs) -[#]: author: (Moshe Zadka https://opensource.com/users/moshez/users/moshez) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez/users/moshez) 使用 attrs 来告别 Python 中的样板 ====== -在我们覆盖 7 个 PyPI 库的系列文章中了解更多解决 Python 问题的信息。 -![Programming at a browser, orange hands][1] -Python是当今使用最多[流行的编程语言] [2]之一 - 并且有充分的理由:它是开源的,它具有广泛的用途(例如Web编程,业务应用程序,游戏,科学编程等等)更多),它有一个充满活力和专注的社区支持它。这个社区是我们在[Python Package Index] [3](PyPI)中提供如此庞大,多样化的软件包的原因,以扩展和改进Python并解决不可避免的问题。 +> 在我们覆盖 7 个 PyPI 库的系列文章中了解更多解决 Python 问题的信息。 -在本系列中,我们将介绍七个可以帮助你解决常见 Python 问题的 PyPI 库。今天,我们将研究 [**attrs**][4],这是一个帮助你快速编写简洁,正确的代码的 Python 包。 +![Programming at a browser, orange hands](https://img.linux.net.cn/data/attachment/album/201905/18/211211lhqqbemqwkeqc2bb.jpg) + +Python是当今使用最多[流行的编程语言][2]之一,因为:它是开源的,它具有广泛的用途(例如 Web 编程、业务应用、游戏、科学编程等等),它有一个充满活力和专注的社区支持它。这个社区是我们在 [Python Package Index][3](PyPI)中提供如此庞大、多样化的软件包的原因,用以扩展和改进 Python。并解决不可避免的问题。 + +在本系列中,我们将介绍七个可以帮助你解决常见 Python 问题的 PyPI 库。今天,我们将研究 [attrs][4],这是一个帮助你快速编写简洁、正确的代码的 Python 包。 ### attrs 如果你已经写过一段时间的 Python,那么你可能习惯这样写代码: - ``` class Book(object): @@ -30,7 +31,7 @@ class Book(object): self.author = author ``` -接着写一个 **__repr__** 函数。否则,很难记录 **Book** 的实例: +接着写一个 `__repr__` 函数。否则,很难记录 `Book` 的实例: ``` @@ -38,11 +39,10 @@ def __repr__(self): return f"Book({self.isbn}, {self.name}, {self.author})" ``` -接下来你会写一个好看的 docstring 来记录期望的类型。但是你注意到你忘了添加 **edition** 和 **published_year** 属性,所以你必须在五个地方修改它们。 +接下来你会写一个好看的 docstring 来记录期望的类型。但是你注意到你忘了添加 `edition` 和 `published_year` 属性,所以你必须在五个地方修改它们。 如果你不必这么做如何? - ``` @attr.s(auto_attribs=True) class Book(object): @@ -53,11 +53,10 @@ class Book(object): edition: int ``` -使用新的类型注释语法注释类型属性,**attrs** 会检测注释并创建一个类。 +使用新的类型注释语法注释类型属性,`attrs` 会检测注释并创建一个类。 ISBN 有特定格式。如果我们想强行使用该格式怎么办? - ``` @attr.s(auto_attribs=True) class Book(object): @@ -73,14 +72,14 @@ class Book(object): edition: int ``` -**attrs** 库也对[不可变风格编程][5]支持良好。将第一行改成 **@attr.s(auto_attribs=True, frozen=True)** 意味着 **Book** 现在是不可变的:尝试修改一个属性将会引发一个异常。相反,比如,如果希望将发布日期向后一年,我们可以修改成 **attr.evolve(old_book, published_year=old_book.published_year+1)** 来得到一个_新的_实例。 +`attrs` 库也对[不可变式编程][5]支持良好。将第一行改成 `@attr.s(auto_attribs=True, frozen=True)` 意味着 `Book` 现在是不可变的:尝试修改一个属性将会引发一个异常。相反,比如,如果希望将发布日期向后一年,我们可以修改成 `attr.evolve(old_book, published_year=old_book.published_year+1)` 来得到一个*新的*实例。 -本系列的下一篇文章我们将来看下 **singledispatch**,一个能让你向 Python 库添加方法的库。 +本系列的下一篇文章我们将来看下 `singledispatch`,一个能让你向 Python 库添加方法的库。 #### 查看本系列先前的文章 - * [Cython][6] - * [Black][7] +* [Cython][6] +* [Black][7] @@ -88,10 +87,10 @@ class Book(object): via: https://opensource.com/article/19/5/python-attrs -作者:[Moshe Zadka ][a] +作者:[Moshe Zadka][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -102,5 +101,5 @@ via: https://opensource.com/article/19/5/python-attrs [3]: https://pypi.org/ [4]: https://pypi.org/project/attrs/ [5]: https://opensource.com/article/18/10/functional-programming-python-immutable-data-structures -[6]: https://opensource.com/article/19/4/7-python-problems-solved-cython -[7]: https://opensource.com/article/19/4/python-problems-solved-black +[6]: https://linux.cn/article-10859-1.html +[7]: https://linux.cn/article-10864-1.html diff --git a/published/201905/20190504 Add methods retroactively in Python with singledispatch.md b/published/201905/20190504 Add methods retroactively in Python with singledispatch.md new file mode 100644 index 0000000000..b0704dd59f --- /dev/null +++ b/published/201905/20190504 Add methods retroactively in Python with singledispatch.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10887-1.html) +[#]: subject: (Add methods retroactively in Python with singledispatch) +[#]: via: (https://opensource.com/article/19/5/python-singledispatch) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +使用 singledispatch 在 Python 中追溯地添加方法 +====== + +> 在我们覆盖 7 个 PyPI 库的系列文章中了解更多解决 Python 问题的信息。 + +![](https://img.linux.net.cn/data/attachment/album/201905/23/093515sgmu4auml9caz54l.jpg) + +Python 是当今使用最多[流行的编程语言][2]之一,因为:它是开源的,它具有广泛的用途(例如 Web 编程、业务应用、游戏、科学编程等等),它有一个充满活力和专注的社区支持它。这个社区是我们在 [Python Package Index][3](PyPI)中提供如此庞大、多样化的软件包的原因,用以扩展和改进 Python。并解决不可避免的问题。 + +在本系列中,我们将介绍七个可以帮助你解决常见 Python 问题的 PyPI 库。今天,我们将研究 [singledispatch][4],这是一个能让你追溯地向 Python 库添加方法的库。 + +### singledispatch + +想象一下,你有一个有 Circle、Square 等类的“形状”库。 + +Circle 类有半径、Square 有边、Rectangle 有高和宽。我们的库已经存在,我们不想改变它。 + +然而,我们想给库添加一个面积计算。如果我们不会和其他人共享这个库,我们只需添加 `area` 方法,这样我们就能调用 `shape.area()` 而无需关心是什么形状。 + +虽然可以进入类并添加一个方法,但这是一个坏主意:没有人希望他们的类会被添加新的方法,程序会因奇怪的方式出错。 + +相反,functools 中的 `singledispatch` 函数可以帮助我们。 + + +``` +@singledispatch +def get_area(shape): + raise NotImplementedError("cannot calculate area for unknown shape", + shape) +``` + +`get_area` 函数的“基类”实现会报错。这保证了如果我们出现一个新的形状时,我们会明确地报错而不是返回一个无意义的结果。 + + +``` +@get_area.register(Square) +def _get_area_square(shape): + return shape.side ** 2 +@get_area.register(Circle) +def _get_area_circle(shape): + return math.pi * (shape.radius ** 2) +``` + +这种方式的好处是如果某人写了一个匹配我们代码的*新*形状,它们可以自己实现 `get_area`。 + + +``` +from area_calculator import get_area + +@attr.s(auto_attribs=True, frozen=True) +class Ellipse: + horizontal_axis: float + vertical_axis: float + +@get_area.register(Ellipse) +def _get_area_ellipse(shape): + return math.pi * shape.horizontal_axis * shape.vertical_axis +``` + +*调用* `get_area` 很直接。 + + +``` +print(get_area(shape)) +``` + +这意味着我们可以将大量的 `if isintance()`/`elif isinstance()` 的代码以这种方式修改,而无需修改接口。下一次你要修改 if isinstance,你试试 `singledispatch! + +在本系列的下一篇文章中,我们将介绍 tox,一个用于自动化 Python 代码测试的工具。 + +#### 回顾本系列的前几篇文章: + + * [Cython][5] + * [Black][6] + * [attrs][7] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/python-singledispatch + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV +[2]: https://opensource.com/article/18/5/numbers-python-community-trends +[3]: https://pypi.org/ +[4]: https://pypi.org/project/singledispatch/ +[5]: https://linux.cn/article-10859-1.html +[6]: https://linux.cn/article-10864-1.html +[7]: https://linux.cn/article-10871-1.html diff --git a/published/201905/20190504 Using the force at the Linux command line.md b/published/201905/20190504 Using the force at the Linux command line.md new file mode 100644 index 0000000000..8b340047f6 --- /dev/null +++ b/published/201905/20190504 Using the force at the Linux command line.md @@ -0,0 +1,219 @@ +[#]: collector: (lujun9972) +[#]: translator: (Moelf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10881-1.html) +[#]: subject: (Using the force at the Linux command line) +[#]: via: (https://opensource.com/article/19/5/may-the-force-linux) +[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss) + +在 Linux 命令行下使用“原力” +====== + +> 和绝地武士的原力一样,`-f` 参数是很强大的,并伴随着潜在的毁灭性,在你能用好的时候又很便利。 + +![Fireworks](https://img.linux.net.cn/data/attachment/album/201905/21/083913jqbwn4ywq1jqnb9y.jpg) + +近些年来,科幻发烧友开始在每年的 5 月 4 日庆祝[星战节][2],其口号是绝地武士的祝福语”愿原力Force和你同在“。虽然大多数 Linux 用户可能不是绝地武士,但我们依然可以使用原力Force。自然,如果尤达大师只是叫天行者卢克输入什么 “man X-Wing 战机“、“man 原力”,或者 RTFM(去读原力手册,肯定是这个意思对不对),那这电影肯定没啥意思。(LCTT 译注:RTFM 是 “Read The Fucking Manual” 的缩写 —— 读读该死的手册吧)。 + +很多 Linux 命令都有 `-f` 选项,意思你现在肯定也知道了,原力(LCTT 译注:force 选项原意是“强制”)!很多时候你先尝试执行命令然后失败了,或者提示你需要补充输入更多选项。通常这都是为了保护你试着改变的文件,或者告诉用户该设备正忙或文件已经存在之类的。 + +如果你不想被这些提醒打扰或者压根就不在乎,就使用原力吧! + +不过要小心,通常使用原力选项是摧毁性的。所以用户一定要格外注意!并且确保你知道自己在做什么!用原力就要承担后果! + +以下是一些常见 Linux 命令的原力选项和它们的效果,以及常见使用场景。 + +### cp + +`cp` 是 “copy” 的缩写,这是个被用来复制文件或者目录的命令。其 [man 页面][3] 说: + +> -f, --force +> +> 如果已经存在的目标文件无法被打开,删除它并重试 + +你可能会用它来处理只读状态的文件: + +``` +[alan@workstation ~]$ ls -l +total 8 +-rw-rw---- 1 alan alan 13 May 1 12:24 Hoth +-r--r----- 1 alan alan 14 May 1 12:23 Naboo +[alan@workstation ~]$ cat Hoth Naboo +Icy Planet + +Green Planet +``` + +如果你想要复制一个叫做 `Hoth` 的文件到 `Naboo`,但因为 `Naboo` 目前是只读状态,`cp` 命令不会执行: + +``` +[alan@workstation ~]$ cp Hoth Naboo +cp: cannot create regular file 'Naboo': Permission denied +``` + +但通过使用原力,`cp` 会强制执行。`Hoth` 的内容和文件权限会直接被复制到 `Naboo`: + + +``` +[alan@workstation ~]$ cp -f Hoth Naboo +[alan@workstation ~]$ cat Hoth Naboo +Icy Planet + +Icy Planet + +[alan@workstation ~]$ ls -l +total 8 +-rw-rw---- 1 alan alan 12 May 1 12:32 Hoth +-rw-rw---- 1 alan alan 12 May 1 12:38 Naboo +``` + +### ln + +`ln` 命令是用来在文件之间建立链接的,其 [man 页面][4] 描述的原力选项如下: + + +> -f, --force +> +> 移除当前存在的文件 + + +假设莱娅公主在维护一个 Java 应用服务器,并且她又一个存放这所有 Java 版本的目录,比如: + +``` +leia@workstation:/usr/lib/java$ ls -lt +total 28 +lrwxrwxrwx 1 leia leia 12 Mar 5 2018 jdk -> jdk1.8.0_162 +drwxr-xr-x 8 leia leia 4096 Mar 5 2018 jdk1.8.0_162 +drwxr-xr-x 8 leia leia 4096 Aug 28 2017 jdk1.8.0_144 +``` + +正如你所看到的,这里有很多个版本的 JDK,并有一个符号链接指向最新版的 JDK。她接着用一个脚本来安装最新版本的 JDK。但是如果没有原力选项的话以下命令是不会成功的: + +``` +tar xvzmf jdk1.8.0_181.tar.gz -C jdk1.8.0_181/ +ln -vs jdk1.8.0_181 jdk +``` + +`tar` 命令会解压 .gz 文件到一个特定的目标目录,但 `ln` 命令会失败,因为这个链接已经存在了。这样的结果是该符号链接不会指向最新版本的 JDK: + +``` +leia@workstation:/usr/lib/java$ ln -vs jdk1.8.0_181 jdk +ln: failed to create symbolic link 'jdk/jdk1.8.0_181': File exists +leia@workstation:/usr/lib/java$ ls -lt +total 28 +drwxr-x--- 2 leia leia 4096 May 1 15:44 jdk1.8.0_181 +lrwxrwxrwx 1 leia leia 12 Mar 5 2018 jdk -> jdk1.8.0_162 +drwxr-xr-x 8 leia leia 4096 Mar 5 2018 jdk1.8.0_162 +drwxr-xr-x 8 leia leia 4096 Aug 28 2017 jdk1.8.0_144 +``` + +她可以通过使用原力选项强制 `ln` 更新链接,但这里她还需要使用 `-n`,`-n` 是因为这个情况下链接其实指向一个目录而非文件。这样的话,链接就会正确指向最新版本的JDK了。 + +``` +leia@workstation:/usr/lib/java$ ln -vsnf jdk1.8.0_181 jdk +'jdk' -> 'jdk1.8.0_181' +leia@workstation:/usr/lib/java$ ls -lt +total 28 +lrwxrwxrwx 1 leia leia 12 May 1 16:13 jdk -> jdk1.8.0_181 +drwxr-x--- 2 leia leia 4096 May 1 15:44 jdk1.8.0_181 +drwxr-xr-x 8 leia leia 4096 Mar 5 2018 jdk1.8.0_162 +drwxr-xr-x 8 leia leia 4096 Aug 28 2017 jdk1.8.0_144 +``` + +你可以配置 Java 应用使其一直使用在 `/usr/lib/java/jdk` 处的 JDK,而不用每次升级都更新。 + +### rm + +`rm` 命令是 “remove” 的缩写(也叫做删除,因为某些系统 `del` 命令也干这事)。其 [man 页面][5] 对原力选项的描述如下: + + +> -f, --force +> +> 无视不存在的文件或者参数,不向用户确认 + +如果你尝试删除一个只读的文件,`rm` 会寻求用户的确认: + +``` +[alan@workstation ~]$ ls -l +total 4 +-r--r----- 1 alan alan 16 May 1 11:38 B-wing +[alan@workstation ~]$ rm B-wing +rm: remove write-protected regular file 'B-wing'? +``` + +你一定要输入 `y` 或者 `n` 来回答确认才能让 `rm` 命令继续。如果你使用原力选项,`rm` 就不会寻求你的确认而直接删除文件: + +``` +[alan@workstation ~]$ rm -f B-wing +[alan@workstation ~]$ ls -l +total 0 +[alan@workstation ~]$ +``` + +最常见的 `rm` 原力选项用法是用来删除目录。 `-r`(递归)选项会让 `rm` 删除目录,当和原力选项结合起来,它会删除这个文件夹及其内容而无需用户确认。 + +`rm` 命令和一些选项结合起来是致命的,一直以来互联网上都有关于误用 `rm` 删除整个系统之类的玩笑和鬼故事。比如最出名的一不当心执行 `rm -rf .` 会直接删除目录和文件(没有用户确认)。(LCTT 译注:真的这么干过的校对飘过~~请按下回车前再三确认:我是谁,我在哪里,我在干什么) + +### userdel + +`userdel` 命令使用来删除用户的。其 [man 页面][6] 是这样描述它的原力选项的: + +> -f, --force +> +> 这个选项会强制移除用户,即便用户当前处于登入状态。它同时还会强制 +删除用户的目录和邮件存储,即便这个用户目录被别人共享或者邮件存储并不 +属于这个用户。如果 `USERGROUPS_ENAB` 在 `/etc/login.defs` 里是 `yes` +并且有一个组和此用户同名的话,这个组也会被移除,即便这个组还是别 +的用户的主要用户组也一样。 +> +> 注意:这个选项有风险并可能让系统处于不稳定状态。 + +当欧比旺抵达穆斯塔法星的时候,他知道自己的使命。他需要删掉达斯·维达的用户账户——而达斯还在里面呢。 + +``` +[root@workstation ~]# ps -fu darth +UID PID PPID C STIME TTY TIME CMD +darth 7663 7655 0 13:28 pts/3 00:00:00 -bash +[root@workstation ~]# userdel darth +userdel: user darth is currently used by process 7663 +``` + +因为达斯还登在系统里,欧比旺需要使用原力选项操作 `userdel`。这能强制删除当前登入的用户。 + +``` +[root@workstation ~]# userdel -f darth +userdel: user darth is currently used by process 7663 +[root@workstation ~]# finger darth +finger: darth: no such user. +[root@workstation ~]# ps -fu darth +error: user name does not exist +``` + +正如我们所见到的一样,`finger` 和 `ps` 命令让我们确认了达斯已经被删除了。 + +### 在 Shell 脚本里使用原力 + +很多命令都有原力选项,而在 shell 脚本里他们特别有用。因为我们经常使用脚本完成定期或者自动化的任务,避免用户输入至关重要,不然的话自动任务就无法完成了 + +我希望上面的几个例子能帮你理解一些需要使用原力的情况。你在命令行使用原力或把它们写入脚本之前应当完全理解它们的作用。误用原力会有毁灭性的后果——时常是对整个系统,甚至不仅限于一台设备。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/may-the-force-linux + +作者:[Alan Formy-Duval][a] +选题:[lujun9972][b] +译者:[Jerry Ling](https://github.com/Moelf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alanfdoss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fireworks_light_art_design.jpg?itok=hfx9i4By (Fireworks) +[2]: https://www.starwars.com/star-wars-day +[3]: http://man7.org/linux/man-pages/man1/cp.1.html +[4]: http://man7.org/linux/man-pages/man1/ln.1.html +[5]: http://man7.org/linux/man-pages/man1/rm.1.html +[6]: http://man7.org/linux/man-pages/man8/userdel.8.html diff --git a/published/201905/20190505 Duc - A Collection Of Tools To Inspect And Visualize Disk Usage.md b/published/201905/20190505 Duc - A Collection Of Tools To Inspect And Visualize Disk Usage.md new file mode 100644 index 0000000000..13d10c9c57 --- /dev/null +++ b/published/201905/20190505 Duc - A Collection Of Tools To Inspect And Visualize Disk Usage.md @@ -0,0 +1,244 @@ +[#]: collector: (lujun9972) +[#]: translator: (tomjlw) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10892-1.html) +[#]: subject: (Duc – A Collection Of Tools To Inspect And Visualize Disk Usage) +[#]: via: (https://www.ostechnix.com/duc-a-collection-of-tools-to-inspect-and-visualize-disk-usage/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +Duc:一个能够可视化洞察硬盘使用情况的工具包 +====== + +![Duc:一个能够洞察并可视化硬盘使用情况的工具包][1] + +Duc 是一个在类 Unix 操作系统上可以用来索引、洞察及可视化硬盘使用情况的工具包。别把它当成一个仅能用漂亮图表展现硬盘使用情况的 CLI 工具。它对巨大的文件系统也支持的很好。Duc 已在由超过五亿个文件和几 PB 的存储组成的系统上测试过,没有任何问题。 + +Duc 是一个快速而且灵活的工具。它将你的硬盘使用情况存在一个优化过的数据库里,这样你就可以在索引完成后迅速找到你的数据。此外,它自带不同的用户交互界面与后端以访问数据库并绘制图表。 + +以下列出的是目前支持的用户界面(UI): + + 1. 命令行界面(`duc ls`) + 2. Ncurses 控制台界面(`duc ui`) + 3. X11 GUI(`duc gui`) + 4. OpenGL GUI(`duc gui`) + +支持的后端数据库: + + * Tokyocabinet + * Leveldb + * Sqlite3 + +Duc 默认使用 Tokyocabinet 作为后端数据库。 + +### 安装 Duc + +Duc 可以从 Debian 以及其衍生品例如 Ubuntu 的默认仓库中获取。因此在基于 DEB 的系统上安装 Duc 是小菜一碟。 + +``` +$ sudo apt-get install duc +``` + +在其它 Linux 发行版上你需要像以下所展示的那样手动从源代码编译安装 Duc。 + +可以从 Github 上的[发行][2]页面下载最新的 Duc 源代码的 .tgz 文件。在写这篇教程的时候,最新的版本是1.4.4。 + +``` +$ wget https://github.com/zevv/duc/releases/download/1.4.4/duc-1.4.4.tar.gz +``` + +然后一个接一个地运行以下命令来安装 DUC。 + +``` +$ tar -xzf duc-1.4.4.tar.gz +$ cd duc-1.4.4 +$ ./configure +$ make +$ sudo make install +``` + +### 使用 Duc + +`duc` 的典型用法是: + +``` +$ duc +``` + +你可以通过运行以下命令来浏览总的选项列表以及子命令: + +``` +$ duc help +``` + +你也可以像下面这样了解一个特定子命令的用法。 + +``` +$ duc help +``` + +要查看所有命令与其选项的列表,仅需运行: + +``` +$ duc help --all +``` + +让我们看看一些 `duc` 工具的特定用法。 + +### 创建索引(数据库) + +首先,你需要创建一个你文件系统的索引文件(数据库)。使用 `duc index` 命令以创建索引文件。 + +比如说,要创建你的 `/home` 目录的索引,仅需运行: + +``` +$ duc index /home +``` + +上述命令将会创建你的 `/home` 目录的索引,并将其保存在 `$HOME/.duc.db` 文件中。如果你以后需要往 `/home` 目录添加新的文件或目录,只要在之后重新运行一下上面的命令来重建索引。 + +### 查询索引 + +Duc 有不同的子命令来查询并探索索引。 + +要查看可访问的索引列表,运行: + +``` +$ duc info +``` + +示例输出: + +``` +Date Time Files Dirs Size Path +2019-04-09 15:45:55 3.5K 305 654.6M /home +``` + +如你在上述输出所见,我已经索引好了 `/home` 目录。 + +要列出当前工作目录中所有的文件和目录,你可以这样做: + +``` +$ duc ls +``` + +要列出指定的目录,例如 `/home/sk/Downloads` 中的文件/目录,仅需像下面这样将路径作为参数传过去。 + +``` +$ duc ls /home/sk/Downloads +``` + +类似的,运行 `duc ui` 命令来打开基于 ncurses 的控制台用户界面以探索文件系统使用情况,运行`duc gui` 以打开图形界面(X11)来探索文件系统。 + +要了解更多子命令的用法,仅需参考帮助部分。 + +``` +$ duc help ls +``` + +上述命令将会展现 `ls` 子命令的帮助部分。 + +### 可视化硬盘使用状况 + +在之前的部分我们以及看到如何用 duc 子命令列出文件和目录。在此之外,你甚至可以用一张漂亮的图表展示文件大小。 + +要展示所提供目录的图表,像以下这样使用 `ls` 子命令。 + +``` +$ duc ls -Fg /home/sk +``` + +示例输出: + +![使用 “duc ls” 命令可视化硬盘使用情况][3] + +如你在上述输出所见,`ls` 子命令查询 duc 数据库并列出了所提供目录包含的文件与目录的大小,在这里就是 `/home/sk/`。 + +这里 `-F` 选项是往条目中用来添加文件类型指示符(`/`),`-g` 选项是用来绘制每个条目相对大小的图表。 + +请注意如果未提供任何路径,就会使用当前工作目录。 + +你可以使用 `-R` 选项来用[树状结构][4]浏览硬盘使用情况。 + +``` +$ duc ls -R /home/sk +``` + +![用树状结构可视化硬盘使用情况][5] + +要查询 duc 数据库并打开基于 ncurses 的控制台以探索所提供的目录,像以下这样使用 `ui` 子命令。 + +``` +$ duc ui /home/sk +``` + +![][6] + +类似的,我们使用 `gui *` 子命令来查询 duc 数据库以及打开一个图形界面(X11)来了解指定路径的硬盘使用情况。 + +``` +$ duc gui /home/sk +``` + +![][7] + +像我之前所提到的,我们可以像下面这样了解更多关于特定子命令的用法。 + +``` +$ duc help <子命令名字> +``` + +我仅仅覆盖了基本用法的部分,参考 man 页面了解关于 `duc` 工具的更多细节。 + +``` +$ man duc +``` + +相关阅读: + + * [Filelight – 在你的 Linux 系统上可视化硬盘使用情况][8] + * [一些好的 du 命令的替代品][9] + * [如何在 Linux 中用 Ncdu 检查硬盘使用情况][10] + * [Agedu——发现 Linux 中被浪费的硬盘空间][11] + * [如何在 Linux 中找到目录大小][12] + * [为初学者打造的带有示例的 df 命令教程][13] + +### 总结 + +Duc 是一款简单却有用的硬盘用量查看器。如果你想要快速简便地知道哪个文件/目录占用你的硬盘空间,Duc 可能是一个好的选择。你还等什么呢?获取这个工具,扫描你的文件系统,摆脱无用的文件/目录。 + +现在就到此为止了。希望这篇文章有用处。更多好东西马上就到。保持关注! + +欢呼吧! + +资源: + + * [Duc 网站][14] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/duc-a-collection-of-tools-to-inspect-and-visualize-disk-usage/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[tomjlw](https://github.com/tomjlw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/04/duc-720x340.png +[2]: https://github.com/zevv/duc/releases +[3]: http://www.ostechnix.com/wp-content/uploads/2019/04/duc-1-1.png +[4]: https://www.ostechnix.com/view-directory-tree-structure-linux/ +[5]: http://www.ostechnix.com/wp-content/uploads/2019/04/duc-2.png +[6]: http://www.ostechnix.com/wp-content/uploads/2019/04/duc-3.png +[7]: http://www.ostechnix.com/wp-content/uploads/2019/04/duc-4.png +[8]: https://www.ostechnix.com/filelight-visualize-disk-usage-on-your-linux-system/ +[9]: https://www.ostechnix.com/some-good-alternatives-to-du-command/ +[10]: https://www.ostechnix.com/check-disk-space-usage-linux-using-ncdu/ +[11]: https://www.ostechnix.com/agedu-find-out-wasted-disk-space-in-linux/ +[12]: https://www.ostechnix.com/find-size-directory-linux/ +[13]: https://www.ostechnix.com/the-df-command-tutorial-with-examples-for-beginners/ +[14]: https://duc.zevv.nl/ diff --git a/published/20190505 How To Create SSH Alias In Linux.md b/published/201905/20190505 How To Create SSH Alias In Linux.md similarity index 100% rename from published/20190505 How To Create SSH Alias In Linux.md rename to published/201905/20190505 How To Create SSH Alias In Linux.md diff --git a/published/20190505 Kindd - A Graphical Frontend To dd Command.md b/published/201905/20190505 Kindd - A Graphical Frontend To dd Command.md similarity index 100% rename from published/20190505 Kindd - A Graphical Frontend To dd Command.md rename to published/201905/20190505 Kindd - A Graphical Frontend To dd Command.md diff --git a/published/20190505 Linux Shell Script To Monitor Disk Space Usage And Send Email.md b/published/201905/20190505 Linux Shell Script To Monitor Disk Space Usage And Send Email.md similarity index 100% rename from published/20190505 Linux Shell Script To Monitor Disk Space Usage And Send Email.md rename to published/201905/20190505 Linux Shell Script To Monitor Disk Space Usage And Send Email.md diff --git a/published/20190505 Ping Multiple Servers And Show The Output In Top-like Text UI.md b/published/201905/20190505 Ping Multiple Servers And Show The Output In Top-like Text UI.md similarity index 100% rename from published/20190505 Ping Multiple Servers And Show The Output In Top-like Text UI.md rename to published/201905/20190505 Ping Multiple Servers And Show The Output In Top-like Text UI.md diff --git a/published/20190505 apt-clone - Backup Installed Packages And Restore Those On Fresh Ubuntu System.md b/published/201905/20190505 apt-clone - Backup Installed Packages And Restore Those On Fresh Ubuntu System.md similarity index 100% rename from published/20190505 apt-clone - Backup Installed Packages And Restore Those On Fresh Ubuntu System.md rename to published/201905/20190505 apt-clone - Backup Installed Packages And Restore Those On Fresh Ubuntu System.md diff --git a/translated/tech/20190506 How to Add Application Shortcuts on Ubuntu Desktop.md b/published/201905/20190506 How to Add Application Shortcuts on Ubuntu Desktop.md similarity index 74% rename from translated/tech/20190506 How to Add Application Shortcuts on Ubuntu Desktop.md rename to published/201905/20190506 How to Add Application Shortcuts on Ubuntu Desktop.md index 3c836b069a..2e6946ac79 100644 --- a/translated/tech/20190506 How to Add Application Shortcuts on Ubuntu Desktop.md +++ b/published/201905/20190506 How to Add Application Shortcuts on Ubuntu Desktop.md @@ -1,18 +1,18 @@ [#]: collector: (lujun9972) [#]: translator: (warmfrog) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10872-1.html) [#]: subject: (How to Add Application Shortcuts on Ubuntu Desktop) [#]: via: (https://itsfoss.com/ubuntu-desktop-shortcut/) [#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) -在 Ubuntu 桌面如何添加应用快捷方式 +如何在 Ubuntu 桌面手动添加应用快捷方式 =============================== -_**在这篇快速指南中,你将学到如何在 Ubuntu 桌面和其他使用 GNOME 桌面的发行版中添加应用图标。**_ +> 在这篇快速指南中,你将学到如何在 Ubuntu 桌面和其他使用 GNOME 桌面的发行版中添加应用图标。 -一个经典的桌面操作系统在 ‘桌面屏’ 上总是有图标的。这些桌面图标包括文件管理器,回收站和应用图标。 +一个经典的桌面操作系统在“桌面屏”上总是有图标的。这些桌面图标包括文件管理器、回收站和应用图标。 当在 Windows 中安装应用时,一些程序会询问你是否在桌面创建一个快捷方式。但在 Linux 系统中不是这样。 @@ -26,43 +26,37 @@ _**在这篇快速指南中,你将学到如何在 Ubuntu 桌面和其他使用 ![][5] -个人来讲,我更喜欢为应用图标准备的 Ubuntu 启动器方式。如果我经常使用一个程序,我会添加到启动器。但是我知道不是每个人都有相同的偏好并且少数人更喜欢桌面的快捷方式。 +个人来讲,我更喜欢为应用图标准备的 Ubuntu 启动器方式。如果我经常使用一个程序,我会添加到启动器。但是我知道不是每个人都有相同的偏好,可能少数人更喜欢桌面的快捷方式。 让我们看在桌面中创建应用快捷方式的最简单方式。 -免责声明 +> 免责声明 -这篇指南已经在 Ubuntu18.04 LTS 的 GNOME 桌面上测试过了。它可能在其他发行版和桌面环境上也能发挥作用,但你必须自己尝试。一些 GNOME 特定步骤可能会变,所以请在[其他桌面环境][7]尝试时注意。 - -[Subscribe to our YouTube Channel for More Linux Videos][8] +> 这篇指南已经在 Ubuntu 18.04 LTS 的 GNOME 桌面上测试过了。它可能在其他发行版和桌面环境上也能发挥作用,但你必须自己尝试。一些 GNOME 特定步骤可能会变,所以请在[其他桌面环境][7]尝试时注意。 #### 准备 首先最重要的事是确保你有 GNOME 桌面的图标权限。 -如果你跟随 Ubuntu 18.04 自定义提示,你会知道如何安装 GNOME Tweaks 工具。在这个工具中,确保你设置 ‘Show Icons’ 选项为允许。 +如果你跟随 Ubuntu 18.04 自定义提示,你会知道如何安装 GNOME Tweaks 工具。在这个工具中,确保你设置“Show Icons”选项为启用。 ![Allow icons on desktop in GNOME][9] 一旦你确保已经设置,是时候在桌面添加应用快捷方式了。 -[][10] - -建议阅读在双启动中如何替代一个 Linux 发行版 [保留 Home分区] - #### 第一步:定位应用的 .desktop 文件 -到 Files -> Other Location -> Computer。 +到 “Files -> Other Location -> Computer”。 ![Go to Other Locations -> Computer][11] -从这里,到目录 usr -> share -> applications。你会在这里看到几个你已经安装的 [Ubuntu 应用][12]。即使你没有看到图标,你应该看到被命名为 应用名.desktop 形式的文件。 +从这里,到目录 “usr -> share -> applications”。你会在这里看到几个你已经安装的 [Ubuntu 应用][12]。即使你没有看到图标,你应该看到被命名为“应用名.desktop”形式的文件。 ![Application Shortcuts][13] #### 第二步:拷贝 .desktop 文件到桌面 -现在你要做的只是查找应用图标(或者它的 desktop 文件)。当你找到后,拖文件到桌面或者拷贝文件(使用 Ctrl+C 快捷方式)并在桌面粘贴(使用 Ctrl+V 快捷方式)。 +现在你要做的只是查找应用图标(或者它的 desktop 文件)。当你找到后,拖文件到桌面或者拷贝文件(使用 `Ctrl+C` 快捷方式)并在桌面粘贴(使用 `Ctrl+V` 快捷方式)。 ![Add .desktop file to the desktop][14] @@ -70,7 +64,7 @@ _**在这篇快速指南中,你将学到如何在 Ubuntu 桌面和其他使用 当你这么做,你应该在桌面上看到一个图标的文本文件而不是应用 logo。别担心,一会就不一样了。 -你要做的就是双击桌面的那个文件。它将警告你它是一个 ‘未信任的应用启动器’,点击信任并启动。 +你要做的就是双击桌面的那个文件。它将警告你它是一个“未信任的应用启动器’,点击“信任并启动”。 ![Launch Desktop Shortcut][15] @@ -80,20 +74,16 @@ _**在这篇快速指南中,你将学到如何在 Ubuntu 桌面和其他使用 #### Ubuntu 19.04 或者 GNOME 3.32 用户的疑难杂症 -如果你使用 Ubuntu 19.04 或者 GNOME 3.32,你的 .desktop 文件可能根本不会启动。你应该右击 .desktop 文件并选择 “Allow Launching”。 +如果你使用 Ubuntu 19.04 或者 GNOME 3.32,你的 .desktop 文件可能根本不会启动。你应该右击 .desktop 文件并选择 “允许启动”。 在这之后,你应该能够启动应用并且桌面上的应用快捷方式能够正常显示了。 -**总结** +### 总结 如果你不喜欢桌面的某个应用启动器,选择删除就是了。它会删除应用快捷方式,但是应用仍安全的保留在你的系统中。 我希望你发现这篇快速指南有帮助并喜欢在 Ubuntu 桌面上的应用快捷方式。 -[][17] - -建议阅读在 Ubuntu 中如何安装和设置 Nemo 为默认的文件管理器。 - 如果你有问题或建议,请在下方评论让我知道。 -------------------------------------------------------------------------------- @@ -103,7 +93,7 @@ via: https://itsfoss.com/ubuntu-desktop-shortcut/ 作者:[Abhishek Prakash][a] 选题:[lujun9972][b] 译者:[warmfrog](https://github.com/warmfrog) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20190508 How to use advanced rsync for large Linux backups.md b/published/201905/20190508 How to use advanced rsync for large Linux backups.md similarity index 100% rename from published/20190508 How to use advanced rsync for large Linux backups.md rename to published/201905/20190508 How to use advanced rsync for large Linux backups.md diff --git a/published/20190509 21 Best Kali Linux Tools for Hacking and Penetration Testing.md b/published/201905/20190509 21 Best Kali Linux Tools for Hacking and Penetration Testing.md similarity index 100% rename from published/20190509 21 Best Kali Linux Tools for Hacking and Penetration Testing.md rename to published/201905/20190509 21 Best Kali Linux Tools for Hacking and Penetration Testing.md diff --git a/published/20190510 How to Use 7Zip in Ubuntu and Other Linux -Quick Tip.md b/published/201905/20190510 How to Use 7Zip in Ubuntu and Other Linux -Quick Tip.md similarity index 100% rename from published/20190510 How to Use 7Zip in Ubuntu and Other Linux -Quick Tip.md rename to published/201905/20190510 How to Use 7Zip in Ubuntu and Other Linux -Quick Tip.md diff --git a/translated/tech/20190510 PHP in 2019.md b/published/201905/20190510 PHP in 2019.md similarity index 56% rename from translated/tech/20190510 PHP in 2019.md rename to published/201905/20190510 PHP in 2019.md index e8da83742d..5b6aa01eb2 100644 --- a/translated/tech/20190510 PHP in 2019.md +++ b/published/201905/20190510 PHP in 2019.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (wxy) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10870-1.html) [#]: subject: (PHP in 2019) [#]: via: (https://stitcher.io/blog/php-in-2019) [#]: author: (Brent https://stitcher.io/blog/php-in-2019) @@ -10,75 +10,75 @@ 9102 年的 PHP ====== -你还记得篇流行的《[PHP:糟糕设计的分形][3]》博客文章吗?我第一次读它时,我在一个有很多遗留的 PHP 项目的糟糕地方工作。这篇文章让我去思考我是否应该放弃并去做与编程完全不同的事情。 +你还记得篇流行的博客文章《[PHP:设计糟糕的分形][3]》吗?我第一次读到它时,我在一个有很多遗留的 PHP 项目的糟糕地方工作。这篇文章让我觉得我是否应该放弃,并去做与编程完全不同的事情。 -幸运的是,我之后很快就换了工作,更重要的是,自从 5.x 版本以来,PHP 成功地进步了很多。今天,我在向那些不再使用 PHP 编程,或者陷入遗留项目的人们致敬。 +还好,我之后很快就换了工作,更重要的是,自从 5.x 版本以来,PHP 成功地进步了很多。今天,我在向那些不再使用 PHP 编程,或者陷入遗留项目的人们致意。 -剧透:今天有些事情仍然很糟糕,就像几乎每种编程语言都有它的怪癖一样。许多核心功能仍然有不一致的调用方法,仍然有令人困惑的配置设置,仍有许多开发人员在那里写蹩脚的代码 —— 因为他们必须如此,或因为他们不知道更好的写法。 +剧透:今天有些事情仍然很糟糕,就像几乎每种编程语言都有它的怪癖一样。许多核心功能仍然有不一致的调用方法,仍然有令人困惑的配置设置,仍然有许多开发人员在那里写蹩脚的代码 —— 因为他们必须如此,或是他们不知道更好的写法。 -今天我想看看好的一面:让我们关注已经发生变化的事情以及编写干净而可维护的 PHP 代码的方法。在此之前,我想请你暂时搁置任何偏见。 +今天我想看看好的一面:让我们关注已经发生变化的事情,以及编写干净而可维护的 PHP 代码的方法。在此之前,我想请你暂时搁置任何偏见。 -之后,你可以像以前一样自由地对 PHP 发表你的看法。虽然你可能会对 PHP 在过去的几年里的一些改进感到惊讶。 +然后,你可以像以前一样对 PHP 自由吐槽。虽然,你可能会对 PHP 在过去的几年里的一些改进感到惊讶。(LCTT 译注:说实话,我是真的感到吃惊) ### 提前看结论 -* PHP 在积极开发,每年都有新版本 -* 自 PHP 5 时代以来的性能翻倍,如果不是三倍的话 +* PHP 在积极地开发,每年都有新版本 +* 自 PHP 5 时代以来的性能已经翻倍,如果不是三倍的话 * 有一个非常活跃的框架、包和平台的生态系统 * PHP 在过去几年中添加了许多新功能,并且这种语言在不断发展 * 像静态分析这样的工具在过去几年中已经成熟,并且一直保持增长    -更新:人们让我展示一些实际的代码。我觉得这没问题!这是我的一个爱好项目的[源代码][4],用 PHP 和 Laravel 编写;[这里][5]列出了我们在办公室维护的几百个自由开源软件包。这两者都是现代 PHP 项目的好例子。 +更新:人们让我展示一些实际的代码。我觉得这没问题!这是我的一个业余项目的[源代码][4],用 PHP 和 Laravel 编写的;[这里][5]列出了我们在办公室维护的几百个自由开源软件包。这两者都是现代 PHP 项目的好例子。 -开始吧。 +那让我们开始吧。 ### 历史总结 出于更好地衡量的目的,让我们快速回顾一下如今的 PHP 发布周期。我们现在的 PHP 为 7.3,预计在 2019 年底为 7.4。PHP 8.0 将是 7.4 之后的下一个版本。 -自从 5.x 时代以来,核心团队试图保持每年的发布周期,并且在过去的四年中成功地做到了。 +自从 5.x 时代以来,核心团队试图保持每年发布一个版本的周期,并且他们在过去的四年中成功地做到了这一点。 一般来说,每个新版本都会在两年内得到积极支持,并再获得一年以上的“安全修复”。其目标是激励 PHP 开发人员尽可能保持最新:例如,每年进行小规模升级比在 5.4 到 7.0 之间跳转更容易。 可以在 [这里][6] 找到 PHP 时间轴的活动概述。 -最后,PHP 5.6 是最新的 5.x 版本,而 7.0 是 6.x 的下一个版本。 如果你想知道 PHP 6 发生了什么,你可以听 [PHP Roundtable 播客][7]。 +最后,PHP 5.6 是最新的 5.x 版本,而 8.0 是当前的下一个大版本。如果你想知道 PHP 6 发生了什么,你可以听听 [PHP Roundtable 播客][7]。 了解了这个,让我们揭穿一些关于现代 PHP 的常见误解。 -### PHP的性能 +### PHP 的性能 -早在 5.x 时代,PHP 的表现就是……嗯,平均水平。但是在 7.0 版本中,PHP 的核心部分从头开始重写,导致性能提升了两到三倍! +早在 5.x 时代,PHP 的表现就是……嗯,平均水平。但是在 7.0 版本中,PHP 从头开始重写了核心部分,导致其性能提升了两到三倍! -但光是嘴说是不够的。我们来看看基准测试。幸运的是,人们花了很多时间来对 PHP 性能进行基准测试。 我发现 [Kinsta][8] 有一个很好的更新列表。 +但光是嘴说是不够的。让我们来看看基准测试。幸运的是,人们花了很多时间对 PHP 性能进行了基准测试。 我发现 [Kinsta][8] 有一个很好的更新的测试列表。 -自 7.0 升级以来,性能就只有提升而没有回退。PHP Web 应用程序的性能就可与其他语言中的 Web 框架相提并论,甚至在某些情况下更好。你可以看看这个[广泛的基准测试套件][9]。 +自 7.0 升级以来,性能就一直在提升而没有回退。PHP Web 应用程序的性能可与其它语言中的 Web 框架相提并论,甚至在某些情况下更好。你可以看看这个[广泛的基准测试套件][9]。 当然 PHP 框架不会胜过 C 和 Rust,但它们比 Rails 或 Django 要好得多,并且与 ExpressJS 相当。 ### 框架和生态系统 -说到框架:PHP 可不仅仅是 WordPress。让我告诉你,某些专业的 PHP 开发人员:WordPress 绝不代表当代的 PHP 生态系统。 +说到框架:PHP 可不仅仅是 WordPress。让我告诉你 —— 某些专业的 PHP 开发人员:WordPress 绝不代表当代的 PHP 生态系统。 -一般来说,有两个主要的 Web 应用程序框架,[Symfony][10] 和 [Laravel][11],以及一些较小的应用程序框架。当然还有 Zend、Yii、Cake、Code Igniter 等等,但是如果你想知道现代 PHP 开发是怎么样的,这两者之一都是很好的对象。 +一般来说,有两个主要的 Web 应用程序框架,[Symfony][10] 和 [Laravel][11],以及一些较小的应用程序框架。当然还有 Zend、Yii、Cake、Code Igniter 等等,但是如果你想知道现代 PHP 开发是怎么样的,这两者之一都是很好的选择。 这两个框架都有一个庞大的包和产品的生态系统。从管理面板和 CRM 到独立软件包,从 CI 到分析器,以及几个 Web 套接字服务器、队列管理器、支付集成等众多服务。老实说,要列出的内容太多了。 -这些框架虽然适用于实际开发。如果你只是需要个内容管理系统(CMS),WordPress 和 CraftCMS 等平台会越来越好。 +这些框架虽然适用于实际开发。如果你只是需要个内容管理系统(CMS),WordPress 和 CraftCMS 等平台就够了。 -衡量 PHP 生态系统当前状态的一种方法是查看 Packagist,这是 PHP 的主要软件包存储库。它已呈指数级增长。每天下载量达到 2500 万次,这可以说 PHP 生态系统已不再是以前的小型弱势群体。 +衡量 PHP 生态系统当前状态的一种方法是查看 Packagist,这是 PHP 主要的软件包存储库。它现在呈指数级增长。每天下载量达到了 2500 万次,可以说 PHP 生态系统已不再是以前的小型弱势群体了。 -请查看此图表,它列出一段时间内的软件包和版本数量。它也可以在 [Packagist 网站][12]上找到。 +请查看此图表,它列出一段时间内的软件包和版本数量变化。它也可以在 [Packagist 网站][12]上找到它。 ![][13] 除了应用程序框架和 CMS 之外,我们还看到过去几年里异步框架的兴起。 -这些是用 PHP 或其他语言编写的框架和服务器,允许用户运行真正的异步 PHP。这些例子包括 [Swoole][14](创始人韩天峰),以及 [Amp][15] 和 [ReactPHP][16]。 +这些是用 PHP 或其他语言编写的框架和服务器,允许用户运行真正的异步 PHP,这些例子包括 [Swoole][14](创始人韩天峰),以及 [Amp][15] 和 [ReactPHP][16]。 -我们已经进入了异步世界冒险,像 Web 套接字和具有大量 IO 的应用程序之类的东西在 PHP 世界中已经变得非常重要。 +我们已经进入了异步的世界,像 Web 套接字和具有大量 I/O 的应用程序之类的东西在 PHP 世界中已经变得非常重要。 -在内部邮件列表里(核心开发人员讨论语言开发的地方)已经谈到了[将 libuv 添加到核心][17]。如果你还不知道 libuv:Node.js 全赖它提供了异步性。 +在内部邮件列表里(PHP 核心开发人员讨论语言开发的地方)已经谈到了[将 libuv 添加到核心][17]。如果你还不知道 libuv:Node.js 全有赖它提供异步性。 ### 语言本身 @@ -90,7 +90,7 @@ + [Trait](https://www.php.net/manual/en/language.oop5.traits.php)(一种代码重用方式) + [属性类型](https://stitcher.io/blog/new-in-php-74#typed-properties-rfc) + [展开操作符](https://wiki.php.net/rfc/argument_unpacking)(参数解包 `...`) -+ [JIT 编译器](https://wiki.php.net/rfc/jit) ++ [JIT 编译器](https://wiki.php.net/rfc/jit)(即时编译器) + [FFI](https://wiki.php.net/rfc/ffi)(外部函数接口) + [匿名类](https://www.php.net/manual/en/language.oop5.anonymous.php) + [返回类型声明](https://www.php.net/manual/en/functions.returning-values.php#functions.returning-values.type-declaration) @@ -98,31 +98,31 @@ + [生成器](https://wiki.php.net/rfc/generators) + [等等](https://www.php.net/ChangeLog-7.php) -当我们讨论语言功能时,我们还要谈谈当今语言的发展过程。虽然社区可以提出 RFC,但是得有一个活跃的志愿者核心团队才能推着语言前进。 +当我们讨论语言功能时,我们还要谈谈当今该语言的发展过程。虽然社区可以提出 RFC,但是得有一个活跃的志愿者核心团队才能推着它前进。 -接下来,这些 RFC 将在“内部”邮件列表中进行讨论,这个邮件列表也可以[在线阅读][18]。在添加新语言功能之前,必须进行投票。只有得到了至少 2/3 多数的 RFC 才能进入核心。 +接下来,这些 RFC 将在“内部”邮件列表中进行讨论,这个邮件列表也可以[在线阅读][18]。在添加新的语言特性之前,必须进行投票。只有得到了至少 2/3 多数同意的 RFC 才能进入核心。 -可能有大约 100 人能投票,但不需要对每个 RFC 进行投票。核心团队的成员当然可以投票,他们是维护代码库的人。除了他们之外,还有一群人从 PHP 社区中被单独挑选出来。这些人包括 PHP 文档的维护者,对 PHP 项目整体有贡献的人,以及 PHP 社区中的杰出开发人员。 +可能有大约 100 人能够投票,但不需要每个人对每个 RFC 进行投票。核心团队的成员当然可以投票,他们是维护代码库的人。除了他们之外,还有一群人从 PHP 社区中被单独挑选出来。这些人包括 PHP 文档的维护者,对 PHP 项目整体有贡献的人,以及 PHP 社区中的杰出开发人员。 -虽然大多数核心开发都是在自愿的基础上完成的,但其中一位核心 PHP 开发人员 Nikita Popov 最近受雇于 [JetBrains][19] 全职从事于该语言。另一个例子是 Linux 基金会最近决定[投资 Zend 框架][20]。像这样的雇佣和收购确保了 PHP 未来发展的稳定性。 +虽然大多数核心开发都是在自愿的基础上完成的,但其中一位核心 PHP 开发人员 Nikita Popov 最近受雇于 [JetBrains][19] 全职从事于 PHP 语言的开发。另一个例子是 Linux 基金会最近决定[投资 Zend 框架][20]。像这样的雇佣和收购确保了 PHP 未来发展的稳定性。 ### 工具 -除了核心本身,我们看到过去几年中围绕它的工具有所增加。浮现于我脑海中的是静态分析器,如由 Vimeo 创建 [Psalm][21],以及 [Phan][22] 和 [PHPStan][23]。 +除了核心本身,我们看到过去几年中围绕它的工具有所增加。首先浮现于我脑海中的是静态分析器,比如由 Vimeo 创建 [Psalm][21],以及 [Phan][22] 和 [PHPStan][23]。 -这些工具将静态分析你的 PHP 代码并报告任何的类型错误和可能的错误等。在某种程度上,它们提供的功能可以与 TypeScript 进行比较,但是现在这种语言不能转译transpiling,因此不支持使用自定义语法。 +这些工具将静态分析你的 PHP 代码并报告任何类型错误和可能的错误等。在某种程度上,它们提供的功能可以与 TypeScript 进行比较,但是现在这种语言不能转译transpiling,因此不支持使用自定义语法。 -尽管这意味着我们需要依赖 docblocks,但是 PHP 的原创建者 Rasmus Lerdorf 确实提到了[添加静态分析引擎][24]到核心的想法。虽然会有很多潜力,但这是一项艰巨的任务。 +尽管这意味着我们需要依赖 docblocks,但是 PHP 之父 Rasmus Lerdorf 确实提到了[添加静态分析引擎][24]到核心的想法。虽然会有很多潜力,但这是一项艰巨的任务。 -说到转译,以及受到 JavaScript 社区的启发;他们已经努力在用户领域中扩展 PHP 语法。一个名为 [Pre][25] 的项目正是如此:允许新的 PHP 语法转译为普通的 PHP 代码。 +说到转译,以及受到 JavaScript 社区的启发;他们已经努力在用户领域中扩展 PHP 语法。一个名为 [Pre][25] 的项目正是如此:允许将新的 PHP 语法转译为普通的 PHP 代码。 虽然这个思路已经在 JavaScript 世界中被证明了,但如果提供了适当的 IDE 和静态分析支持,它就能在 PHP 中工作了。这是一个非常有趣的想法,但必须发展起来才能称之为“主流”。 ### 结语 -尽管如此,你仍然可以将 PHP 视为一种糟糕的语言。虽然这种语言肯定有它的缺点和与之而来的 20 年的遗产;但我可以放胆地说,我喜欢和它一起工作。 +尽管如此,你仍然可以将 PHP 视为一种糟糕的语言。虽然这种语言肯定有它的缺点和背负了 20 年的遗产;但我可以放胆地说,我喜欢用它工作。 -根据我的经验,我能够创建可靠、可维护和高质量的软件。我工作的客户对最终结果感到满意,就像我一样。 +根据我的经验,我能够创建可靠、可维护和高质量的软件。我工作的客户对最终结果感到满意,“俺也一样”。 尽管仍然可以用 PHP 做很多乱七八糟的事情,但我认为如果明智和正确地使用的话,它是 Web 开发的绝佳选择。 @@ -135,7 +135,7 @@ via: https://stitcher.io/blog/php-in-2019 作者:[Brent][a] 选题:[lujun9972][b] 译者:[wxy](https://github.com/wxy) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/201905/20190513 How to SSH into a Raspberry Pi -Beginner-s Tip.md b/published/201905/20190513 How to SSH into a Raspberry Pi -Beginner-s Tip.md new file mode 100644 index 0000000000..ca59e6c392 --- /dev/null +++ b/published/201905/20190513 How to SSH into a Raspberry Pi -Beginner-s Tip.md @@ -0,0 +1,120 @@ +[#]: collector: (lujun9972) +[#]: translator: (tomjlw) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10888-1.html) +[#]: subject: (How to SSH into a Raspberry Pi [Beginner’s Tip]) +[#]: via: (https://itsfoss.com/ssh-into-raspberry/) +[#]: author: (Chinmay https://itsfoss.com/author/chinmay/) + +新手教程:如何 SSH 进入树莓派 +====== + +> 在这篇树莓派文章中,你将学到如何在树莓派中启用 SSH 以及之后如何通过 SSH 进入树莓派。 + +在你可以用[树莓派][1]做的所有事情中,将其作为一个家庭网络的服务器是十分流行的做法。小体积与低功耗使它成为运行轻量级服务器的完美设备。 + +在这种情况下你做得到的事情之一是能够每次在树莓派上无须接上显示器、键盘、鼠标以及走到放置你的树莓派的地方就可以运行指令。 + +你可以从其它任意电脑、笔记本、台式机甚至你的手机通过 SSH([Secure Shell][2])登入你的树莓派来做到这一点。让我展示给你看: + +### 如何 SSH 进入树莓派 + +![][3] + +我假设你已经[在你的树莓派上运行 Raspbian][4] 并已经成功通过有线或者无线网连进网络了。你的树莓派接入网络这点是很重要的,否则你无法通过 SSH 连接树莓派(抱歉说出这种显而易见的事实)。 + +#### 步骤一:在树莓派上启用 SSH + +SSH 在树莓派上是默认关闭的,因此在你安装好全新的 Raspbian 后打开树莓派时,你需要启用它。 + +首先通过菜单进入树莓派的配置界面。 + +![树莓派菜单,树莓派配置][5] + +现在进入接口interfaces标签,启动 SSH 并重启你的树莓派。 + +![在树莓派上启动 SSH][6] + +你也可以通过终端直接启动 SSH。仅需输入命令 `sudo raspi-config` 然后进入高级设置以启用 SSH。 + +#### 步骤二: 找到树莓派的 IP 地址 + +在大多数情况下,你的树莓派会被分配一个看起来长得像 `192.168.x.x` 或者 `10.x.x.x` 的本地 IP 地址。你可以[使用多种 Linux 命令来找到 IP 地址][7]。 + +我在这使用古老而好用的 `ifconfig` 命令,但是你也可以使用 `ip address`。 + +``` +ifconfig +``` + +![树莓派网络配置][9] + +这行命令展现了所有活跃中的网络适配器以及其配置的列表。第一个条目(`eth0`)展示了例如`192.168.2.105` 的有效 IP 地址。我用有线网将我的树莓派连入网络,因此这里显示的是 `eth0`。如果你用无线网的话在叫做 `wlan0` 的条目下查看。 + +你也可以用其他方法例如查看你的路由器或者调制解调器的网络设备表以找到 IP 地址。 + +#### 步骤三:SSH 进你的树莓派 + +既然你已经启用了 SSH 功能并且找到了 IP 地址,你可以从任何电脑 SSH 进入你的树莓派。你同样需要树莓派的用户名和密码。 + +默认用户名和密码是: + + * 用户名:`pi` + * 密码:`raspberry` + +如果你已改变了默认的密码,那就使用新的而不是以上的密码。理想状态下你必须改变默认的密码。在过去,有一款[恶意软件感染数千使用默认用户名和密码的树莓派设备][8]。 + +(在 Mac 或 Linux 上)从你想要 SSH 进树莓派的电脑上打开终端输入以下命令,在 Windows 上,你可以用类似 [Putty][10] 的 SSH 客户端。 + +这里,使用你在之前步骤中找到的 IP 地址。 + +``` +ssh [受保护的邮件] +``` + +> 注意: 确保你的树莓派和你用来 SSH 进入树莓派的电脑接入了同一个网络。 + +![通过命令行 SSH][11] + +第一次你会看到一个警告,输入 `yes` 并按下回车。 + +![输入密码 \(默认是 ‘raspberry‘\)][12] + +现在,输入密码按下回车。 + +![成功通过 SSH 登入][13] + +成功登入你将会看到树莓派的终端。现在你可以通过这个终端无需物理上访问你的树莓派就可以远程(在当前网络内)在它上面运行指令。 + +在此之上你也可以设置 SSH 密钥这样每次通过 SSH 登入时就可以无需输入密码,但那完全是另一个话题了。 + +我希望你通过跟着这个教程已能够 SSH 进入你的树莓派。在下方评论中让我知道你打算用你的树莓派做些什么! + +-------------------------------------------------------------------------- + +via: https://itsfoss.com/ssh-into-raspberry/ + +作者:[Chinmay][a] +选题:[lujun9972][b] +译者:[tomjlw](https://github.com/tomjlw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/chinmay/ +[b]: https://github.com/lujun9972 +[1]: https://www.raspberrypi.org/ +[2]: https://en.wikipedia.org/wiki/Secure_Shell +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/ssh-into-raspberry-pi.png?resize=800%2C450&ssl=1 +[4]: https://itsfoss.com/tutorial-how-to-install-raspberry-pi-os-raspbian-wheezy/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/Raspberry-pi-configuration.png?ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/enable-ssh-raspberry-pi.png?ssl=1 +[7]: https://linuxhandbook.com/find-ip-address/ +[8]: https://itsfoss.com/raspberry-pi-malware-threat/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/ifconfig-rapberry-pi.png?ssl=1 +[10]: https://itsfoss.com/putty-linux/ +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/05/SSH-into-pi-warning.png?fit=800%2C199&ssl=1 +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/SSH-into-pi-password.png?fit=800%2C202&ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/SSH-into-Pi-successful-login.png?fit=800%2C306&ssl=1 +[14]: https://itsfoss.com/speed-up-ubuntu-unity-on-low-end-system/ diff --git a/published/201905/20190516 Building Smaller Container Images.md b/published/201905/20190516 Building Smaller Container Images.md new file mode 100644 index 0000000000..35efa5ea3a --- /dev/null +++ b/published/201905/20190516 Building Smaller Container Images.md @@ -0,0 +1,117 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10885-1.html) +[#]: subject: (Building Smaller Container Images) +[#]: via: (https://fedoramagazine.org/building-smaller-container-images/) +[#]: author: (Muayyad Alsadi https://fedoramagazine.org/author/alsadi/) + +构建更小的容器镜像的技巧 +====== + +![][1] + +Linux 容器已经成为一个热门话题,保证容器镜像较小被认为是一个好习惯。本文提供了有关如何构建较小 Fedora 容器镜像的一些技巧。 + +### microdnf + +Fedora 的 DNF 是用 Python 编写的,因为它有各种各样的插件,因此它的设计是可扩展的。但是 有一个 Fedora 基本容器镜像替代品,它使用一个较小的名为 [microdnf][2] 的包管理器,使用 C 编写。要在 Dockerfile 中使用这个最小的镜像,`FROM` 行应该如下所示: + +``` +FROM registry.fedoraproject.org/fedora-minimal:30 +``` + +如果你的镜像不需要像 Python 这样的典型 DNF 依赖项,例如,如果你在制作 NodeJS 镜像时,那么这是一个重要的节省项。 + +### 在一个层中安装和清理 + +为了节省空间,使用 `dnf clean all` 或其 microdnf 等效的 `microdnf clean all` 删除仓库元数据非常重要。但是你不应该分两步执行此操作,因为这实际上会将这些文件保存在容器镜像中,然后在另一层中将其标记为删除。要正确地执行此操作,你应该像这样一步完成安装和清理: + +``` +FROM registry.fedoraproject.org/fedora-minimal:30 +RUN microdnf install nodejs && microdnf clean all +``` + +### 使用 microdnf 进行模块化 + +模块化是一种给你选择不同堆栈版本的方法。例如,你可能需要在项目中用非 LTS 的 NodeJS v11,旧的 LTS NodeJS v8 用于另一个,最新的 LTS NodeJS v10 用于另一个。你可以使用冒号指定流。 + +``` +# dnf module list +# dnf module install nodejs:8 +``` + +`dnf module install` 命令意味着两个命令,一个启用流,另一个是从它安装 nodejs。 + +``` +# dnf module enable nodejs:8 +# dnf install nodejs +``` + +尽管 `microdnf` 不提供与模块化相关的任何命令,但是可以启用带有配置文件的模块,并且 libdnf(被 microdnf 使用)[似乎][3]支持模块化流。该文件看起来像这样: + +``` +/etc/dnf/modules.d/nodejs.module +[nodejs] +name=nodejs +stream=8 +profiles= +state=enabled +``` + +使用模块化的 `microdnf` 的完整 Dockerfile 如下所示: + +``` +FROM registry.fedoraproject.org/fedora-minimal:30 +RUN \ + echo -e "[nodejs]\nname=nodejs\nstream=8\nprofiles=\nstate=enabled\n" > /etc/dnf/modules.d/nodejs.module && \ + microdnf install nodejs zopfli findutils busybox && \ + microdnf clean all +``` + +### 多阶段构建 + +在许多情况下,你可能需要大量的无需用于运行软件的构建时依赖项,例如构建一个静态链接依赖项的 Go 二进制文件。多阶段构建是分离应用构建和应用运行时的有效方法。 + +例如,下面的 Dockerfile 构建了一个 Go 应用 [confd][4]。 + +``` +# building container +FROM registry.fedoraproject.org/fedora-minimal AS build +RUN mkdir /go && microdnf install golang && microdnf clean all +WORKDIR /go +RUN export GOPATH=/go; CGO_ENABLED=0 go get github.com/kelseyhightower/confd + +FROM registry.fedoraproject.org/fedora-minimal +WORKDIR / +COPY --from=build /go/bin/confd /usr/local/bin +CMD ["confd"] +``` + +通过在 `FROM` 指令之后添加 `AS` 并从基本容器镜像中添加另一个 `FROM` 然后使用 `COPY --from=` 指令将内容从*构建*的容器复制到第二个容器来完成多阶段构建。 + +可以使用 `podman` 构建并运行此 Dockerfile: + +``` +$ podman build -t myconfd . +$ podman run -it myconfd +``` + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/building-smaller-container-images/ + +作者:[Muayyad Alsadi][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/alsadi/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/05/smaller-container-images-816x345.jpg +[2]: https://github.com/rpm-software-management/microdnf +[3]: https://bugzilla.redhat.com/show_bug.cgi?id=1575626 +[4]: https://github.com/kelseyhightower/confd diff --git a/published/201905/20190516 Querying 10 years of GitHub data with GHTorrent and Libraries.io.md b/published/201905/20190516 Querying 10 years of GitHub data with GHTorrent and Libraries.io.md new file mode 100644 index 0000000000..5c51721c84 --- /dev/null +++ b/published/201905/20190516 Querying 10 years of GitHub data with GHTorrent and Libraries.io.md @@ -0,0 +1,156 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10906-1.html) +[#]: subject: (Querying 10 years of GitHub data with GHTorrent and Libraries.io) +[#]: via: (https://opensource.com/article/19/5/chaossearch-github-ghtorrent) +[#]: author: (Pete Cheslock https://opensource.com/users/petecheslock/users/ghaff/users/payalsingh/users/davidmstokes) + +用 GHTorrent 和 Libraries.io 查询 10 年的 GitHub 数据 +====== + +> 有一种方法可以在没有任何本地基础设施的情况下使用开源数据集探索 GitHub 数据。 + +![magnifying glass on computer screen](https://img.linux.net.cn/data/attachment/album/201905/27/220200jlzrlz333vkfl8ok.jpg) + +我一直在寻找新的数据集,以用它们来展示我们团队工作的力量。[CHAOSSEARCH][2] 可以将你的 [Amazon S3][3] 对象存储数据转换为完全可搜索的 [Elasticsearch][4] 式集群。使用 Elasticsearch API 或 [Kibana][5] 等工具,你可以查询你所要找的任何数据。 + +当我找到 [GHTorrent][6] 项目进行探索时,我很兴奋。GHTorrent 旨在通过 GitHub API 构建所有可用数据的离线版本。如果你喜欢数据集,这是一个值得一看的项目,甚至你可以考虑[捐赠一个 GitHub API 密钥][7]。 + +### 访问 GHTorrent 数据 + +有许多方法可以访问和使用 [GHTorrent 的数据][8],它以 [NDJSON][9] 格式提供。这个项目可以以多种形式提供数据,包括用于恢复到 [MySQL][11] 数据库的 [CSV][10],可以转储所有对象的 [MongoDB][12],以及用于将数据直接导出到 Google 对象存储中的 Google Big Query(免费)。 有一点需要注意:这个数据集有从 2008 年到 2017 年几乎完整的数据集,但从 2017 年到现在的数据还不完整。这将影响我们确定性查询的能力,但它仍然是一个令人兴奋的信息量。 + +我选择 Google Big Query 来避免自己运行任何数据库,那么我就可以很快下载包括用户和项目在内的完整数据库。CHAOSSEARCH 可以原生分析 NDJSON 格式,因此在将数据上传到 Amazon S3 之后,我能够在几分钟内对其进行索引。CHAOSSEARCH 平台不要求用户设置索引模式或定义其数据的映射,它可以发现所有字段本身(字符串、整数等)。 + +随着我的数据完全索引并准备好进行搜索和聚合,我想深入了解看看我们可以发现什么,比如哪些软件语言是 GitHub 项目最受欢迎的。 + +(关于格式化的说明:下面这是一个有效的 JSON 查询,我们不会在这里正确格式化以避免滚动疲劳。要正确格式化它,你可以在本地复制它并发送到命令行实用程序,如 [jq][13]。) + +``` +{"aggs":{"2":{"date_histogram":{"field":"root.created_at","interval":"1M","time_zone":"America/New_York","min_doc_count":1}}},"size":0,"_source":{"excludes":[]},"stored_fields":["*"],"script_fields":{},"docvalue_fields":["root.created_at","root.updated_at"],"query":{"bool":{"must":[],"filter":[{"match_all":{}}],"should":[],"must_not":[{"match_phrase":{"root.language":{"query":""}}}]}}} +``` + +对于那些近年来跟踪开源语言状态的人来说,这个结果并不令人惊讶。 + +![Which software languages are the most popular on GitHub.][14] + +[JavaScript][15] 仍然是卫冕冠军,虽然有些人认为 JavaScript 正在逐渐消失,但它仍然是 800 磅重的大猩猩,很可能会保持这种状态一段时间。[Java][16] 面临类似的谣言,但这些数据表明它是开源生态系统的重要组成部分。 + +考虑到像 [Docker][17] 和 [Kubernetes][18] 这样的项目的流行,你可能会想,“Go([Golang][19])怎么样?”这是一个提醒的好时机,这里讨论的 GitHub 数据集包含一些空缺,最明显的是在 2017 年之后我看到 Golang 项目随处可见,而这里并没有显示。我希望用完整的 GitHub 数据集重复此搜索,看看它是否会改变排名。 + +现在让我们来探讨项目创建的速度。 (提醒:这是为了便于阅读而合并的有效 JSON。) + +``` +{"aggs":{"2":{"date_histogram":{"field":"root.created_at","interval":"1M","time_zone":"America/New_York","min_doc_count":1}}},"size":0,"_source":{"excludes":[]},"stored_fields":["*"],"script_fields":{},"docvalue_fields":["root.created_at","root.updated_at"],"query":{"bool":{"must":[],"filter":[{"match_all":{}}],"should":[],"must_not":[{"match_phrase":{"root.language":{"query":""}}}]}}} +``` + +我们可以看到创建新项目的速度,也会给人留下深刻的印象,从 2012 年左右开始大幅增长: + +![The rate at which new projects are created on GitHub.][20] + +既然我知道了创建项目的速度以及用于创建这些项目的最流行的语言,我还想知道这些项目选择的开源许可证。遗憾的是,这个 GitHub 项目数据集中并不存在这些数据,但是 [Tidelift][21] 的精彩团队在 [Libraries.io][22] [数据][23] 里发布了一个 GitHub 项目的详细列表,包括使用的许可证以及其中有关开源软件状态的其他详细信息。将此数据集导入 CHAOSSEARCH 只花了几分钟,让我看看哪些开源软件许可证在 GitHub 上最受欢迎: + +(提醒:这是为了便于阅读而合并的有效 JSON。) + +``` +{"aggs":{"2":{"terms":{"field":"Repository License","size":10,"order":{"_count":"desc"}}}},"size":0,"_source":{"excludes":[]},"stored_fields":["*"],"script_fields":{},"docvalue_fields":["Created Timestamp","Last synced Timestamp","Latest Release Publish Timestamp","Updated Timestamp"],"query":{"bool":{"must":[],"filter":[{"match_all":{}}],"should":[],"must_not":[{"match_phrase":{"Repository License":{"query":""}}}]}}} +``` + +结果显示了一些重要的异常值: + +![Which open source software licenses are the most popular on GitHub.][24] + +如你所见,[MIT 许可证][25] 和 [Apache 2.0 许可证][26] 的开源项目远远超过了其他大多数开源许可证,而 [各种 BSD 和 GPL 许可证][27] 则差得很远。鉴于 GitHub 的开放模式,我不能说我对这些结果感到惊讶。我猜想是用户(而不是公司)创建了大多数项目,并且他们使用 MIT 许可证可以使其他人轻松地使用、共享和贡献。而鉴于有不少公司希望确保其商标得到尊重并为其业务提供开源组件,那么 Apache 2.0 许可证数量高企的背后也是有道理的。 + +现在我确定了最受欢迎的许可证,我很想看看最少使用的许可证。通过调整我的上一个查询,我将前 10 名逆转为最后 10 名,并且只找到了两个使用 [伊利诺伊大学 - NCSA 开源许可证][28] 的项目。我之前从未听说过这个许可证,但它与 Apache 2.0 非常接近。看到所有 GitHub 项目中使用了多少个不同的软件许可证,这很有意思。 + +![The University of Illinois/NCSA open source license.][29] + +之后,我针对特定语言(JavaScript)来查看最常用的许可证。(提醒:这是为了便于阅读而合并的有效JSON。) + +``` +{"aggs":{"2":{"terms":{"field":"Repository License","size":10,"order":{"_count":"desc"}}}},"size":0,"_source":{"excludes":[]},"stored_fields":["*"],"script_fields":{},"docvalue_fields":["Created Timestamp","Last synced Timestamp","Latest Release Publish Timestamp","Updated Timestamp"],"query":{"bool":{"must":[{"match_phrase":{"Repository Language":{"query":"JavaScript"}}}],"filter":[{"match_all":{}}],"should":[],"must_not":[{"match_phrase":{"Repository License":{"query":""}}}]}}} +``` + +这个输出有一些意外。 + +![The most popular open source licenses used for GitHub JavaScript projects.][30] + +尽管使用 `npm init` 创建的 [NPM][31] 模块的默认许可证是来自 [Internet Systems Consortium(ISC)][32] 的许可证,但你可以看到相当多的这些项目使用 MIT 以及 Apache 2.0 的开源许可证。 + +由于 Libraries.io 数据集中包含丰富的开源项目内容,并且由于 GHTorrent 数据缺少最近几年的数据(因此缺少有关 Golang 项目的任何细节),因此我决定运行类似的查询来查看 Golang 项目是如何许可他们的代码的。 + +(提醒:这是为了便于阅读而合并的有效 JSON。) + +``` +{"aggs":{"2":{"terms":{"field":"Repository License","size":10,"order":{"_count":"desc"}}}},"size":0,"_source":{"excludes":[]},"stored_fields":["*"],"script_fields":{},"docvalue_fields":["Created Timestamp","Last synced Timestamp","Latest Release Publish Timestamp","Updated Timestamp"],"query":{"bool":{"must":[{"match_phrase":{"Repository Language":{"query":"Go"}}}],"filter":[{"match_all":{}}],"should":[],"must_not":[{"match_phrase":{"Repository License":{"query":""}}}]}}} +``` + +结果与 Javascript 完全不同。 + +![How Golang projects license their GitHub code.][33] + +Golang 项目与 JavaScript 项目惊人逆转 —— 使用 Apache 2.0 的 Golang 项目几乎是 MIT 许可证的三倍。虽然很难准确地解释为什么会出现这种情况,但在过去的几年中,Golang 已经出现了大规模的增长,特别是在开源和商业化的项目和软件产品公司中。 + +正如我们上面所了解的,这些公司中的许多公司都希望强制执行其商标策略,因此转向 Apache 2.0 许可证是有道理的。 + +#### 总结 + +最后,我通过深入了解 GitHub 用户和项目的数据找到了一些有趣的结果。其中一些我肯定会猜到,但是一些结果对我来说也是惊喜,特别是像很少使用的 NCSA 许可证这样的异常值。 + +总而言之,你可以看到 CHAOSSEARCH 平台能够快速轻松地找到有趣问题的复杂答案。我无需自己运行任何数据库就可以深入研究这个数据集,甚至可以在 Amazon S3 上以低成本的方式存储数据,因此无需维护。 现在,我可以随时查询有关这些数据的任何其他问题。 + +你对数据提出了哪些其他问题,以及你使用了哪些数据集?请在评论或推特上告诉我 [@petecheslock] [34]。 + +本文的一个版本最初发布在 [CHAOSSEARCH][35],有更多结果可供发现。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/chaossearch-github-ghtorrent + +作者:[Pete Cheslock][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/petecheslock/users/ghaff/users/payalsingh/users/davidmstokes +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/search_find_code_issue_bug_programming.png?itok=XPrh7fa0 (magnifying glass on computer screen) +[2]: https://chaossearch.io/ +[3]: https://aws.amazon.com/s3/ +[4]: https://www.elastic.co/ +[5]: https://www.elastic.co/products/kibana +[6]: http://ghtorrent.org +[7]: http://ghtorrent.org/services.html +[8]: http://ghtorrent.org/downloads.html +[9]: http://ndjson.org +[10]: https://en.wikipedia.org/wiki/Comma-separated_values +[11]: https://en.wikipedia.org/wiki/MySQL +[12]: https://www.mongodb.com/ +[13]: https://stedolan.github.io/jq/ +[14]: https://opensource.com/sites/default/files/uploads/github-1_500.png (Which software languages are the most popular on GitHub.) +[15]: https://en.wikipedia.org/wiki/JavaScript +[16]: /resources/java +[17]: /resources/what-docker +[18]: /resources/what-is-kubernetes +[19]: https://golang.org/ +[20]: https://opensource.com/sites/default/files/uploads/github-2_500.png (The rate at which new projects are created on GitHub.) +[21]: https://tidelift.com +[22]: http://libraries.io/ +[23]: https://libraries.io/data +[24]: https://opensource.com/sites/default/files/uploads/github-3_500.png (Which open source software licenses are the most popular on GitHub.) +[25]: https://opensource.org/licenses/MIT +[26]: https://opensource.org/licenses/Apache-2.0 +[27]: https://opensource.org/licenses +[28]: https://tldrlegal.com/license/university-of-illinois---ncsa-open-source-license-(ncsa) +[29]: https://opensource.com/sites/default/files/uploads/github-4_500_0.png (The University of Illinois/NCSA open source license.) +[30]: https://opensource.com/sites/default/files/uploads/github-5_500_0.png (The most popular open source licenses used for GitHub JavaScript projects.) +[31]: https://www.npmjs.com/ +[32]: https://en.wikipedia.org/wiki/ISC_license +[33]: https://opensource.com/sites/default/files/uploads/github-6_500.png (How Golang projects license their GitHub code.) +[34]: https://twitter.com/petecheslock +[35]: https://chaossearch.io/blog/where-are-the-github-users-part-1/ diff --git a/published/201905/20190518 Change Power Modes in Ubuntu with Slimbook Battery Optimizer.md b/published/201905/20190518 Change Power Modes in Ubuntu with Slimbook Battery Optimizer.md new file mode 100644 index 0000000000..15c51dc608 --- /dev/null +++ b/published/201905/20190518 Change Power Modes in Ubuntu with Slimbook Battery Optimizer.md @@ -0,0 +1,102 @@ +[#]: collector: (lujun9972) +[#]: translator: (zhs852) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10897-1.html) +[#]: subject: (Change Power Modes in Ubuntu with Slimbook Battery Optimizer) +[#]: via: (https://itsfoss.com/slimbook-battry-optimizer-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +在 Ubuntu 中使用 Slimbook Battery Optimizer 切换电源模式 +====== + +> Slimbook Battery Optimizer 是一个美观实用的指示器小程序,它可以让你在安装了 Linux 的笔记本上快速切换电源模式来延长续航时间。 + +[Slimbook][1] 是一个销售 [预装 Linux 的笔记本电脑][2] 的西班牙电脑制造商,他们发布了一款好用的小程序,用来在基于 Ubuntu 的 Linux 发行版下调整电池性能。 + +因为 Slimbook 销售他们自己的 Linux 系统,所以他们制作了一些在 Linux 上用于调整他们自己硬件性能的小工具。Battery Optimizer 就是这样一个工具。 + +要使用这个实用小程序,你不必购买 Slimbook 的产品,因为 Slimbook 已经将它在 [他们的官方 PPA 源][3] 发行了。 + +### Slimbook Battery Optimizer 简介 + +这个程序叫 Slimbook Battery。它是一个常驻顶栏的指示器小程序,使得你可以快速切换电源模式。 + +![Slimbook Battery Mode Ubuntu][4] + +你可能在 Windows 中见过类似的程序。Slimbook Battery 和它们一样,提供了类似的电源计划: + + * 节能:最大程度延长电池续航时间 + * 平衡:性能与节能间的最佳平衡 + * 高性能:最大程度提高性能 + +你可以在高级模式中配置这些模式: + +![配置多种多样的电源模式][5] + +如果你觉得你把设置调乱了,你可以用“恢复默认设置”的按钮还原它。 + +你也可以修改像程序自启或默认电源模式这样的通用设置。 + +![Slimbook Battery 通用设置][6] + +Slimbook 有专门为多种电源管理参数提供的页面。如果你希望自己配置,请参照 [此页][7]。 + +不过,我认为 Slimbook 的界面需要一些改进。例如,某些页面上的“问题标记”的图标应该改为可点击的,以此提供更多信息。然而,在我写这篇文章时,那个标记仍然无法点击。 + +总的来说,Slimbook Battery 是一个小巧精美的软件,你可以用它来快速切换电源模式。如果你决定在 Ubuntu 及其衍生发行版上(比如 Linux Mint 或 elementary OS 等),你可以使用官方 [PPA 源][8]。 + +#### 在基于 Ubuntu 的发行版上安装 Slimbook Battery + +打开终端,一步一步地使用以下命令: + +``` +sudo add-apt-repository ppa:slimbook/slimbook +sudo apt update +sudo apt install slimbookbattery +``` + +安装好之后,在菜单中搜索 Slimbook Battery: + +![启动 Slimbook Battery Optimizer][10] + +在你点击它之后,你会发现它出现在了顶栏。你可以在这里选择你希望使用的电源模式。 + +![Slimbook Battery 电源模式][4] + +#### 卸载 Slimbook Battery + +如果你不再使用它,你可以通过以下命令来卸载它: + +``` +sudo apt remove slimbookbattery +sudo add-apt-repository -r ppa:slimbook/slimbook +``` + +在我看来,这样的应用程序为某些特定的目的服务,这是值得鼓励的。这个工具给了你一条调整电源模式的捷径,和调整性能的更多选项。 + +你用过 Slimbook Battery 吗?你觉得它如何? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/slimbook-battry-optimizer-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[zhs852](https://github.com/zhs852) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://slimbook.es/en/ +[2]: https://itsfoss.com/get-linux-laptops/ +[3]: https://launchpad.net/~slimbook/+archive/ubuntu/slimbook +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/05/slimbook-battery-mode-ubuntu.jpg?resize=800%2C400&ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/slimbook-battery-optimizer-2.jpg?ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/slimbook-battery-optimizer-1.jpg?ssl=1 +[7]: https://slimbook.es/en/tutoriales/aplicaciones-slimbook/398-slimbook-battery-3-application-for-optimize-battery-of-your-laptop +[8]: https://itsfoss.com/ppa-guide/ +[9]: https://itsfoss.com/ubuntu-forums-hacked-again/ +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/05/slimbook-battery-optimizer.jpg?ssl=1 diff --git a/published/201905/20190520 PiShrink - Make Raspberry Pi Images Smaller.md b/published/201905/20190520 PiShrink - Make Raspberry Pi Images Smaller.md new file mode 100644 index 0000000000..3913d663df --- /dev/null +++ b/published/201905/20190520 PiShrink - Make Raspberry Pi Images Smaller.md @@ -0,0 +1,118 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10894-1.html) +[#]: subject: (PiShrink – Make Raspberry Pi Images Smaller) +[#]: via: (https://www.ostechnix.com/pishrink-make-raspberry-pi-images-smaller/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +PiShrink:使树莓派镜像更小 +====== + +![Make Raspberry Pi Images Smaller With PiShrink In Linux][1] + +树莓派不需要过多介绍。它是一款小巧、价格实惠,只有信用卡大小的电脑,它可以连接到显示器或电视。我们可以连接一个标准的键盘和鼠标,并将其用作一台成熟的台式计算机来完成日常任务,如互联网浏览、播放视频/玩游戏、文字处理和电子表格制作等。它主要是为学校的计算机科学教学而开发的。如今,树莓派被广泛用于大学、中小型组织和研究所来教授编码。 + +如果你有一台树莓派,你可能需要了解一个名为 PiShrink 的 bash 脚本,该脚本可使树莓派镜像更小。PiShrink 将自动缩小镜像,然后在启动时将其调整为 SD 卡的最大大小。这能更快地将镜像复制到 SD 卡中,同时缩小的镜像将更好地压缩。这对于将大容量镜像放入 SD 卡非常有用。在这个简短的指南中,我们将学习如何在类 Unix 系统中将树莓派镜像缩小到更小。 + +### 安装 PiShrink + +要在 Linux 机器上安装 PiShrink,请先使用以下命令下载最新版本: + +``` +$ wget https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh +``` + +接下来,将下载的 PiShrink 变成二进制可执行文件: + +``` +$ chmod +x pishrink.sh +``` + +最后,移动到目录: + +``` +$ sudo mv pishrink.sh /usr/local/bin/ +``` + +### 使树莓派镜像更小 + +你可能已经知道,Raspbian 是所有树莓派型号的官方操作系统。树莓派基金会为 PC 和 Mac 开发了树莓派桌面版本。你可以创建一个 live CD,并在虚拟机中运行它,甚至也可以将其安装在桌面上。树莓派也有少量非官方​​操作系统镜像。为了测试,我从[官方下载页面][2]下载了官方的 Raspbian 系统。 + +解压下载的系统镜像: + +``` +$ unzip 2019-04-08-raspbian-stretch-lite.zip +``` + +上面的命令将提取当前目录中 `2019-04-08-raspbian-stretch-lite.zip` 文件的内容。 + +让我们看下提取文件的实际大小: + +``` +$ du -h 2019-04-08-raspbian-stretch-lite.img +1.7G 2019-04-08-raspbian-stretch-lite.img +``` + +如你所见,提取的树莓派系统镜像大小为 1.7G。 + +现在,使用 PiShrink 缩小此文件的大小,如下所示: + +``` +$ sudo pishrink.sh 2019-04-08-raspbian-stretch-lite.img +``` + +示例输出: + +``` +Creating new /etc/rc.local +rootfs: 39795/107072 files (0.1% non-contiguous), 239386/428032 blocks +resize2fs 1.45.0 (6-Mar-2019) +resize2fs 1.45.0 (6-Mar-2019) +Resizing the filesystem on /dev/loop1 to 280763 (4k) blocks. +Begin pass 3 (max = 14) +Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +Begin pass 4 (max = 3728) +Updating inode references XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +The filesystem on /dev/loop1 is now 280763 (4k) blocks long. + +Shrunk 2019-04-08-raspbian-stretch-lite.img from 1.7G to 1.2G +``` + +正如你在上面的输出中看到的,树莓派镜像的大小已减少到 1.2G。 + +你还可以使用 `-s` 标志跳过该过程的自动扩展部分。 + +``` +$ sudo pishrink.sh -s 2019-04-08-raspbian-stretch-lite.img newpi.img +``` + +这将创建一个源镜像文件(即 `2019-04-08-raspbian-stretch-lite.img`)的副本到一个新镜像文件(`newpi.img`)并进行处理。有关更多详细信息,请查看最后给出的官方 GitHub 页面。 + +就是这些了。希望本文有用。还有更多好东西,敬请期待! + + +资源: + + * [PiShrink 的 GitHub 仓库][4] + * [树莓派网站][5] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/pishrink-make-raspberry-pi-images-smaller/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/05/pishrink-720x340.png +[2]: https://www.raspberrypi.org/downloads/ +[3]: http://www.ostechnix.com/wp-content/uploads/2019/05/pishrink-1.png +[4]: https://github.com/Drewsif/PiShrink +[5]: https://www.raspberrypi.org/ diff --git a/published/201905/20190520 xsos - A Tool To Read SOSReport In Linux.md b/published/201905/20190520 xsos - A Tool To Read SOSReport In Linux.md new file mode 100644 index 0000000000..af4e47f976 --- /dev/null +++ b/published/201905/20190520 xsos - A Tool To Read SOSReport In Linux.md @@ -0,0 +1,396 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10889-1.html) +[#]: subject: (xsos – A Tool To Read SOSReport In Linux) +[#]: via: (https://www.2daygeek.com/xsos-a-tool-to-read-sosreport-in-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +xsos:一个在 Linux 上阅读 SOSReport 的工具 +====== + +![](https://img.linux.net.cn/data/attachment/album/201905/23/133305accwpsvhk1epsisc.jpg) + +我们都已经知道 [SOSReport][1]。它用来收集可用于诊断的系统信息。Redhat 的支持服务建议我们在提交案例时提供 SOSReport 来分析当前的系统状态。 + +它会收集全部类型的报告,以帮助用户找出问题的根本原因。我们可以轻松地提取和阅读 SOSReport,但它很难阅读。因为它的每个部分都是一个单独的文件。 + +那么,在 Linux 中使用语法高亮显示阅读所有这些内容的最佳方法是什么。是的,这可以通过 `xsos` 工具做到。 + +### sosreport + +`sosreport` 命令是一个从运行中的系统(尤其是 RHEL 和 OEL 系统)收集大量配置细节、系统信息和诊断信息的工具。它可以帮助技术支持工程师在很多方面分析系统。 + +此报告包含有关系统的大量信息,例如引导信息、文件系统、内存、主机名、已安装的 RPM、系统 IP、网络详细信息、操作系统版本、已安装的内核、已加载的内核模块、打开的文件列表、PCI 设备列表、挂载点及其细节、运行中的进程信息、进程树输出、系统路由、位于 `/etc` 文件夹中的所有配置文件,以及位于 `/var` 文件夹中的所有日志文件。 + +这将需要一段时间来生成报告,这取决于你的系统安装和配置。 + +完成后,`sosreport` 将在 `/tmp` 目录下生成一个压缩的归档文件。 + +### xsos + +[xsos][3] 是一个帮助用户轻松读取 Linux 系统上的 `sosreport` 的工具。另一方面,我们可以说它是 `sosreport` 考官。 + +它可以立即从 `sosreport` 或正在运行的系统中汇总系统信息。 + +`xsos` 将尝试简化、解析、计算并格式化来自数十个文件(和命令)的数据,以便为你提供有关系统的详细概述。 + +你可以通过运行以下命令立即汇总系统信息。 + +``` +# curl -Lo ./xsos bit.ly/xsos-direct; chmod +x ./xsos; ./xsos -ya +``` + +![][5] + +### 如何在 Linux 上安装 xsos + +我们可以使用以下两种方法轻松安装 `xsos`。 + +如果你正在寻找最新的前沿版本。使用以下步骤: + +``` +# curl -Lo /usr/local/bin/xsos bit.ly/xsos-direct +# chmod +x /usr/local/bin/xsos +``` + +下面是安装 `xsos` 的推荐方法。它将从 rpm 文件安装 `xsos`。 + +``` +# yum install http://people.redhat.com/rsawhill/rpms/latest-rsawaroha-release.rpm +# yum install xsos +``` + +### 如何在 Linux 上使用 xsos + +一旦通过上述方法之一安装了 xsos。只需运行 `xsos` 命令,不带任何选项,它们会显示有关系统的基本信息。 + +``` +# xsos + +OS + Hostname: CentOS7.2daygeek.com + Distro: [redhat-release] CentOS Linux release 7.6.1810 (Core) + [centos-release] CentOS Linux release 7.6.1810 (Core) + [os-release] CentOS Linux 7 (Core) 7 (Core) + RHN: (missing) + RHSM: (missing) + YUM: 2 enabled plugins: fastestmirror, langpacks + Runlevel: N 5 (default graphical) + SELinux: enforcing (default enforcing) + Arch: mach=x86_64 cpu=x86_64 platform=x86_64 + Kernel: + Booted kernel: 3.10.0-957.el7.x86_64 + GRUB default: 3.10.0-957.el7.x86_64 + Build version: + Linux version 3.10.0-957.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red + Hat 4.8.5-36) (GCC) ) #1 SMP Thu Nov 8 23:39:32 UTC 2018 + Booted kernel cmdline: + root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet + LANG=en_US.UTF-8 + GRUB default kernel cmdline: + root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet + LANG=en_US.UTF-8 + Taint-check: 0 (kernel untainted) + - - - - - - - - - - - - - - - - - - - + Sys time: Sun May 12 10:05:21 CDT 2019 + Boot time: Sun May 12 09:50:20 CDT 2019 (epoch: 1557672620) + Time Zone: America/Chicago + Uptime: 15 min, 1 user + LoadAvg: [1 CPU] 0.00 (0%), 0.04 (4%), 0.09 (9%) + /proc/stat: + procs_running: 2 procs_blocked: 0 processes [Since boot]: 6423 + cpu [Utilization since boot]: + us 1%, ni 0%, sys 1%, idle 99%, iowait 0%, irq 0%, sftirq 0%, steal 0% +``` + +### 如何使用 xsos 命令在 Linux 中查看生成的 SOSReport 输出? + +我们需要份 SOSReport 以使用 `xsos` 命令进一步阅读。 + +是的,我已经生成了一个 SOSReport,文件如下。 + +``` +# ls -lls -lh /var/tmp/sosreport-CentOS7-01-1005-2019-05-12-pomeqsa.tar.xz +9.8M -rw-------. 1 root root 9.8M May 12 10:13 /var/tmp/sosreport-CentOS7-01-1005-2019-05-12-pomeqsa.tar.xz +``` + +运行如下命令解开它。 + +``` +# tar xf sosreport-CentOS7-01-1005-2019-05-12-pomeqsa.tar.xz +``` + +要查看全部信息,带上 `-a` 或 `--all` 开关运行 `xsos`: + +``` +# xsos --all /var/tmp/sosreport-CentOS7-01-1005-2019-05-12-pomeqsa +``` + +要查看 BIOS 信息,带上 `-b` 或 `--bios` 开关运行 `xsos`。 + +``` +# xsos --bios /var/tmp/sosreport-CentOS7-01-1005-2019-05-12-pomeqsa +DMIDECODE + BIOS: + Vend: innotek GmbH + Vers: VirtualBox + Date: 12/01/2006 + BIOS Rev: + FW Rev: + System: + Mfr: innotek GmbH + Prod: VirtualBox + Vers: 1.2 + Ser: 0 + UUID: 002f47b8-2af2-48f5-be1d-67b67e03514c + CPU: + 0 of 0 CPU sockets populated, 0 cores/0 threads per CPU + 0 total cores, 0 total threads + Mfr: + Fam: + Freq: + Vers: + Memory: + Total: 0 MiB (0 GiB) + DIMMs: 0 of 0 populated + MaxCapacity: 0 MiB (0 GiB / 0.00 TiB) +``` + +要查看系统基本信息,如主机名、发行版、SELinux、内核信息、正常运行时间等,请使用 `-o` 或 `--os` 开关运行 `xsos`。 + +``` +# xsos --os /var/tmp/sosreport-CentOS7-01-1005-2019-05-12-pomeqsa +OS + Hostname: CentOS7.2daygeek.com + Distro: [redhat-release] CentOS Linux release 7.6.1810 (Core) + [centos-release] CentOS Linux release 7.6.1810 (Core) + [os-release] CentOS Linux 7 (Core) 7 (Core) + RHN: (missing) + RHSM: (missing) + YUM: 2 enabled plugins: fastestmirror, langpacks + SELinux: enforcing (default enforcing) + Arch: mach=x86_64 cpu=x86_64 platform=x86_64 + Kernel: + Booted kernel: 3.10.0-957.el7.x86_64 + GRUB default: 3.10.0-957.el7.x86_64 + Build version: + Linux version 3.10.0-957.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red + Hat 4.8.5-36) (GCC) ) #1 SMP Thu Nov 8 23:39:32 UTC 2018 + Booted kernel cmdline: + root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet + LANG=en_US.UTF-8 + GRUB default kernel cmdline: + root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet + LANG=en_US.UTF-8 + Taint-check: 536870912 (see https://access.redhat.com/solutions/40594) + 29 TECH_PREVIEW: Technology Preview code is loaded + - - - - - - - - - - - - - - - - - - - + Sys time: Sun May 12 10:12:22 CDT 2019 + Boot time: Sun May 12 09:50:20 CDT 2019 (epoch: 1557672620) + Time Zone: America/Chicago + Uptime: 22 min, 1 user + LoadAvg: [1 CPU] 1.19 (119%), 0.27 (27%), 0.14 (14%) + /proc/stat: + procs_running: 8 procs_blocked: 2 processes [Since boot]: 9005 + cpu [Utilization since boot]: + us 1%, ni 0%, sys 1%, idle 99%, iowait 0%, irq 0%, sftirq 0%, steal 0% +``` + +要查看 kdump 配置,请使用 `-k` 或 `--kdump` 开关运行 `xsos`。 + +``` +# xsos --kdump /var/tmp/sosreport-CentOS7-01-1005-2019-05-12-pomeqsa +KDUMP CONFIG + kexec-tools rpm version: + kexec-tools-2.0.15-21.el7.x86_64 + Service enablement: + UNIT STATE + kdump.service enabled + kdump initrd/initramfs: + 13585734 Feb 19 05:51 initramfs-3.10.0-957.el7.x86_64kdump.img + Memory reservation config: + /proc/cmdline { crashkernel=auto } + GRUB default { crashkernel=auto } + Actual memory reservation per /proc/iomem: + 2a000000-340fffff : Crash kernel + kdump.conf: + path /var/crash + core_collector makedumpfile -l --message-level 1 -d 31 + kdump.conf "path" available space: + System MemTotal (uncompressed core size) { 1.80 GiB } + Available free space on target path's fs { 22.68 GiB } (fs=/) + Panic sysctls: + kernel.sysrq [bitmask] = "16" (see proc man page) + kernel.panic [secs] = 0 (no autoreboot on panic) + kernel.hung_task_panic = 0 + kernel.panic_on_oops = 1 + kernel.panic_on_io_nmi = 0 + kernel.panic_on_unrecovered_nmi = 0 + kernel.panic_on_stackoverflow = 0 + kernel.softlockup_panic = 0 + kernel.unknown_nmi_panic = 0 + kernel.nmi_watchdog = 1 + vm.panic_on_oom [0-2] = 0 (no panic) +``` + +要查看有关 CPU 的信息,请使用 `-c` 或 `--cpu` 开关运行 `xsos`。 + +``` +# xsos --cpu /var/tmp/sosreport-CentOS7-01-1005-2019-05-12-pomeqsa +CPU + 1 logical processors + 1 Intel Core i7-6700HQ CPU @ 2.60GHz (flags: aes,constant_tsc,ht,lm,nx,pae,rdrand) +``` + +要查看内存利用情况,请使用 `-m` 或 `--mem` 开关运行 `xsos`。 + +``` +# xsos --mem /var/tmp/sosreport-CentOS7-01-1005-2019-05-12-pomeqsa +MEMORY + Stats graphed as percent of MemTotal: + MemUsed ▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊..................... 58.8% + Buffers .................................................. 0.6% + Cached ▊▊▊▊▊▊▊▊▊▊▊▊▊▊▊................................... 29.9% + HugePages .................................................. 0.0% + Dirty .................................................. 0.7% + RAM: + 1.8 GiB total ram + 1.1 GiB (59%) used + 0.5 GiB (28%) used excluding Buffers/Cached + 0.01 GiB (1%) dirty + HugePages: + No ram pre-allocated to HugePages + LowMem/Slab/PageTables/Shmem: + 0.09 GiB (5%) of total ram used for Slab + 0.02 GiB (1%) of total ram used for PageTables + 0.01 GiB (1%) of total ram used for Shmem + Swap: + 0 GiB (0%) used of 2 GiB total +``` + +要查看添加的磁盘信息,请使用 `-d` 和 `-disks` 开关运行 `xsos`。 + +``` +# xsos --disks /var/tmp/sosreport-CentOS7-01-1005-2019-05-12-pomeqsa +STORAGE + Whole Disks from /proc/partitions: + 2 disks, totaling 40 GiB (0.04 TiB) + - - - - - - - - - - - - - - - - - - - - - + Disk Size in GiB + ---- ----------- + sda 30 + sdb 10 +``` + +要查看网络接口配置,请使用 `-e` 或 `--ethtool` 开关运行 `xsos`。 + +``` +# xsos --ethtool /var/tmp/sosreport-CentOS7-01-1005-2019-05-12-pomeqsa +ETHTOOL + Interface Status: + enp0s10 0000:00:0a.0 link=up 1000Mb/s full (autoneg=Y) rx ring 256/4096 drv e1000 v7.3.21-k8-NAPI / fw UNKNOWN + enp0s9 0000:00:09.0 link=up 1000Mb/s full (autoneg=Y) rx ring 256/4096 drv e1000 v7.3.21-k8-NAPI / fw UNKNOWN + virbr0 N/A link=DOWN rx ring UNKNOWN drv bridge v2.3 / fw N/A + virbr0-nic tap link=DOWN rx ring UNKNOWN drv tun v1.6 / fw UNKNOWN +``` + +要查看有关 IP 地址的信息,请使用 `-i` 或 `--ip` 开关运行 `xsos`。 + +``` +# xsos --ip /var/tmp/sosreport-CentOS7-01-1005-2019-05-12-pomeqsa +IP4 + Interface Master IF MAC Address MTU State IPv4 Address + ========= ========= ================= ====== ===== ================== + lo - - 65536 up 127.0.0.1/8 + enp0s9 - 08:00:27:0b:bc:e9 1500 up 192.168.1.8/24 + enp0s10 - 08:00:27:b2:08:91 1500 up 192.168.1.9/24 + virbr0 - 52:54:00:ae:01:94 1500 up 192.168.122.1/24 + virbr0-nic virbr0 52:54:00:ae:01:94 1500 DOWN - + +IP6 + Interface Master IF MAC Address MTU State IPv6 Address Scope + ========= ========= ================= ====== ===== =========================================== ===== + lo - - 65536 up ::1/128 host + enp0s9 - 08:00:27:0b:bc:e9 1500 up fe80::945b:8333:f4bc:9723/64 link + enp0s10 - 08:00:27:b2:08:91 1500 up fe80::7ed4:1fab:23c3:3790/64 link + virbr0 - 52:54:00:ae:01:94 1500 up - - + virbr0-nic virbr0 52:54:00:ae:01:94 1500 DOWN - - +``` + +要通过 `ps` 查看正在运行的进程,请使用 `-p` 或 `--ps` 开关运行 `xsos`。 + +``` +# xsos --ps /var/tmp/sosreport-CentOS7-01-1005-2019-05-12-pomeqsa +PS CHECK + Total number of threads/processes: + 501 / 171 + Top users of CPU & MEM: + USER %CPU %MEM RSS + root 20.6% 14.1% 0.30 GiB + gdm 0.3% 16.8% 0.33 GiB + postfix 0.0% 0.6% 0.01 GiB + polkitd 0.0% 0.6% 0.01 GiB + daygeek 0.0% 0.2% 0.00 GiB + colord 0.0% 0.4% 0.01 GiB + Uninteruptible sleep threads/processes (0/0): + [None] + Defunct zombie threads/processes (0/0): + [None] + Top CPU-using processes: + USER PID %CPU %MEM VSZ-MiB RSS-MiB TTY STAT START TIME COMMAND + root 6542 15.6 4.2 875 78 pts/0 Sl+ 10:11 0:07 /usr/bin/python /sbin/sosreport + root 7582 3.0 0.1 10 2 pts/0 S 10:12 0:00 /bin/bash /usr/sbin/dracut --print-cmdline + root 7969 0.7 0.1 95 4 ? Ss 10:12 0:00 /usr/sbin/certmonger -S -p + root 7889 0.4 0.2 24 4 ? Ss 10:12 0:00 /usr/lib/systemd/systemd-hostnamed + gdm 3866 0.3 7.1 2856 131 ? Sl 09:50 0:04 /usr/bin/gnome-shell + root 8553 0.2 0.1 47 3 ? S 10:12 0:00 /usr/lib/systemd/systemd-udevd + root 6971 0.2 0.4 342 9 ? Sl 10:12 0:00 /usr/sbin/abrt-dbus -t133 + root 3200 0.2 0.9 982 18 ? Ssl 09:50 0:02 /usr/sbin/libvirtd + root 2855 0.1 0.1 88 3 ? Ss 09:50 0:01 /sbin/rngd -f + rtkit 2826 0.0 0.0 194 2 ? SNsl 09:50 0:00 /usr/libexec/rtkit-daemon + Top MEM-using processes: + USER PID %CPU %MEM VSZ-MiB RSS-MiB TTY STAT START TIME COMMAND + gdm 3866 0.3 7.1 2856 131 ? Sl 09:50 0:04 /usr/bin/gnome-shell + root 6542 15.6 4.2 875 78 pts/0 Sl+ 10:11 0:07 /usr/bin/python /sbin/sosreport + root 3264 0.0 1.2 271 23 tty1 Ssl+ 09:50 0:00 /usr/bin/X :0 -background + root 3200 0.2 0.9 982 18 ? Ssl 09:50 0:02 /usr/sbin/libvirtd + root 3189 0.0 0.9 560 17 ? Ssl 09:50 0:00 /usr/bin/python2 -Es /usr/sbin/tuned + gdm 4072 0.0 0.9 988 17 ? Sl 09:50 0:00 /usr/libexec/gsd-media-keys + gdm 4076 0.0 0.8 625 16 ? Sl 09:50 0:00 /usr/libexec/gsd-power + gdm 4056 0.0 0.8 697 16 ? Sl 09:50 0:00 /usr/libexec/gsd-color + root 2853 0.0 0.7 622 14 ? Ssl 09:50 0:00 /usr/sbin/NetworkManager --no-daemon + gdm 4110 0.0 0.7 544 14 ? Sl 09:50 0:00 /usr/libexec/gsd-wacom + Top thread-spawning processes: + # USER PID %CPU %MEM VSZ-MiB RSS-MiB TTY STAT START TIME COMMAND + 17 root 3200 0.2 0.9 982 18 ? - 09:50 0:02 /usr/sbin/libvirtd + 12 root 6542 16.1 4.5 876 83 pts/0 - 10:11 0:07 /usr/bin/python /sbin/sosreport + 10 gdm 3866 0.3 7.1 2856 131 ? - 09:50 0:04 /usr/bin/gnome-shell + 7 polkitd 2864 0.0 0.6 602 13 ? - 09:50 0:01 /usr/lib/polkit-1/polkitd --no-debug + 6 root 2865 0.0 0.0 203 1 ? - 09:50 0:00 /usr/sbin/gssproxy -D + 5 root 3189 0.0 0.9 560 17 ? - 09:50 0:00 /usr/bin/python2 -Es /usr/sbin/tuned + 5 root 2823 0.0 0.3 443 6 ? - 09:50 0:00 /usr/libexec/udisks2/udisksd + 5 gdm 4102 0.0 0.2 461 5 ? - 09:50 0:00 /usr/libexec/gsd-smartcard + 4 root 3215 0.0 0.2 470 4 ? - 09:50 0:00 /usr/sbin/gdm + 4 gdm 4106 0.0 0.2 444 5 ? - 09:50 0:00 /usr/libexec/gsd-sound +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/xsos-a-tool-to-read-sosreport-in-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/how-to-create-collect-sosreport-in-linux/ +[2]: https://www.2daygeek.com/oswbb-how-to-install-and-configure-oswatcher-black-box-for-system-diagnostics/ +[3]: https://github.com/ryran/xsos +[4]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[5]: https://www.2daygeek.com/wp-content/uploads/2019/05/xsos-a-tool-to-read-sosreport-in-linux-1.jpg diff --git a/published/20190524 Spell Checking Comments.md b/published/20190524 Spell Checking Comments.md new file mode 100644 index 0000000000..d48358c2a9 --- /dev/null +++ b/published/20190524 Spell Checking Comments.md @@ -0,0 +1,40 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11294-1.html) +[#]: subject: (Spell Checking Comments) +[#]: via: (https://emacsredux.com/blog/2019/05/24/spell-checking-comments/) +[#]: author: (Bozhidar Batsov https://emacsredux.com) + +Emacs 注释中的拼写检查 +====== + +我出了名的容易拼错单词(特别是在播客当中)。谢天谢地 Emacs 内置了一个名为 `flyspell` 的超棒模式来帮助像我这样的可怜的打字员。flyspell 会在你输入时突出显示拼错的单词 (也就是实时的) 并提供有用的快捷键来快速修复该错误。 + +大多输入通常会对派生自 `text-mode`(比如 `markdown-mode`,`adoc-mode` )的主模式启用 `flyspell`,但是它对程序员也有所帮助,可以指出他在注释中的错误。所需要的只是启用 `flyspell-prog-mode`。我通常在所有的编程模式中(至少在 `prog-mode` 派生的模式中)都启用它: + +``` +(add-hook 'prog-mode-hook #'flyspell-prog-mode) +``` + +现在当你在注释中输入错误时,就会得到即时反馈了。要修复单词只需要将光标置于单词后,然后按下 `C-c $` (`M-x flyspell-correct-word-before-point`)。(还有许多其他方法可以用 `flyspell` 来纠正拼写错误的单词,但为了简单起见,我们暂时忽略它们。) + +![flyspell_prog_mode.gif][1] + +今天的分享就到这里!我要继续修正这些讨厌的拼写错误了! + +-------------------------------------------------------------------------------- + +via: https://emacsredux.com/blog/2019/05/24/spell-checking-comments/ + +作者:[Bozhidar Batsov][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://emacsredux.com +[b]: https://github.com/lujun9972 +[1]: https://emacsredux.com/assets/images/flyspell_prog_mode.gif diff --git a/published/201906/20170410 Writing a Time Series Database from Scratch.md b/published/201906/20170410 Writing a Time Series Database from Scratch.md new file mode 100644 index 0000000000..9093e4dc2a --- /dev/null +++ b/published/201906/20170410 Writing a Time Series Database from Scratch.md @@ -0,0 +1,484 @@ +从零写一个时间序列数据库 +================== + +编者按:Prometheus 是 CNCF 旗下的开源监控告警解决方案,它已经成为 Kubernetes 生态圈中的核心监控系统。本文作者 Fabian Reinartz 是 Prometheus 的核心开发者,这篇文章是其于 2017 年写的一篇关于 Prometheus 中的时间序列数据库的设计思考,虽然写作时间有点久了,但是其中的考虑和思路非常值得参考。长文预警,请坐下来慢慢品味。 + +--- + +![](https://img.linux.net.cn/data/attachment/album/201906/11/180646l7cqbhazqs7nsqsn.jpg) + +我从事监控工作。特别是在 [Prometheus][2] 上,监控系统包含一个自定义的时间序列数据库,并且集成在 [Kubernetes][3] 上。 + +在许多方面上 Kubernetes 展现出了 Prometheus 所有的设计用途。它使得持续部署continuous deployments弹性伸缩auto scaling和其他高动态环境highly dynamic environments下的功能可以轻易地访问。查询语句和操作模型以及其它概念决策使得 Prometheus 特别适合这种环境。但是,如果监控的工作负载动态程度显著地增加,这就会给监控系统本身带来新的压力。考虑到这一点,我们就可以特别致力于在高动态或瞬态服务transient services环境下提升它的表现,而不是回过头来解决 Prometheus 已经解决的很好的问题。 + +Prometheus 的存储层在历史以来都展现出卓越的性能,单一服务器就能够以每秒数百万个时间序列的速度摄入多达一百万个样本,同时只占用了很少的磁盘空间。尽管当前的存储做的很好,但我依旧提出一个新设计的存储子系统,它可以修正现存解决方案的缺点,并具备处理更大规模数据的能力。 + +> 备注:我没有数据库方面的背景。我说的东西可能是错的并让你误入歧途。你可以在 Freenode 的 #prometheus 频道上对我(fabxc)提出你的批评。 + +## 问题,难题,问题域 + +首先,快速地概览一下我们要完成的东西和它的关键难题。我们可以先看一下 Prometheus 当前的做法 ,它为什么做的这么好,以及我们打算用新设计解决哪些问题。 + +### 时间序列数据 + +我们有一个收集一段时间数据的系统。 + +``` +identifier -> (t0, v0), (t1, v1), (t2, v2), (t3, v3), .... +``` + +每个数据点是一个时间戳和值的元组。在监控中,时间戳是一个整数,值可以是任意数字。64 位浮点数对于计数器和测量值来说是一个好的表示方法,因此我们将会使用它。一系列严格单调递增的时间戳数据点是一个序列,它由标识符所引用。我们的标识符是一个带有标签维度label dimensions字典的度量名称。标签维度划分了单一指标的测量空间。每一个指标名称加上一个唯一标签集就成了它自己的时间序列,它有一个与之关联的数据流value stream。 + +这是一个典型的序列标识符series identifier集,它是统计请求指标的一部分: + +``` +requests_total{path="/status", method="GET", instance=”10.0.0.1:80”} +requests_total{path="/status", method="POST", instance=”10.0.0.3:80”} +requests_total{path="/", method="GET", instance=”10.0.0.2:80”} +``` + +让我们简化一下表示方法:度量名称可以当作另一个维度标签,在我们的例子中是 `__name__`。对于查询语句,可以对它进行特殊处理,但与我们存储的方式无关,我们后面也会见到。 + +``` +{__name__="requests_total", path="/status", method="GET", instance=”10.0.0.1:80”} +{__name__="requests_total", path="/status", method="POST", instance=”10.0.0.3:80”} +{__name__="requests_total", path="/", method="GET", instance=”10.0.0.2:80”} +``` + +我们想通过标签来查询时间序列数据。在最简单的情况下,使用 `{__name__="requests_total"}` 选择所有属于 `requests_total` 指标的数据。对于所有选择的序列,我们在给定的时间窗口内获取数据点。 + +在更复杂的语句中,我们或许想一次性选择满足多个标签的序列,并且表示比相等条件更复杂的情况。例如,非语句(`method!="GET"`)或正则表达式匹配(`method=~"PUT|POST"`)。 + +这些在很大程度上定义了存储的数据和它的获取方式。 + +### 纵与横 + +在简化的视图中,所有的数据点可以分布在二维平面上。水平维度代表着时间,序列标识符域经纵轴展开。 + +``` +series + ^ + | . . . . . . . . . . . . . . . . . . . . . . {__name__="request_total", method="GET"} + | . . . . . . . . . . . . . . . . . . . . . . {__name__="request_total", method="POST"} + | . . . . . . . + | . . . . . . . . . . . . . . . . . . . ... + | . . . . . . . . . . . . . . . . . . . . . + | . . . . . . . . . . . . . . . . . . . . . {__name__="errors_total", method="POST"} + | . . . . . . . . . . . . . . . . . {__name__="errors_total", method="GET"} + | . . . . . . . . . . . . . . + | . . . . . . . . . . . . . . . . . . . ... + | . . . . . . . . . . . . . . . . . . . . + v + <-------------------- time ---------------------> +``` + +Prometheus 通过定期地抓取一组时间序列的当前值来获取数据点。我们从中获取到的实体称为目标。因此,写入模式完全地垂直且高度并发,因为来自每个目标的样本是独立摄入的。 + +这里提供一些测量的规模:单一 Prometheus 实例从数万个目标中收集数据点,每个数据点都暴露在数百到数千个不同的时间序列中。 + +在每秒采集数百万数据点这种规模下,批量写入是一个不能妥协的性能要求。在磁盘上分散地写入单个数据点会相当地缓慢。因此,我们想要按顺序写入更大的数据块。 + +对于旋转式磁盘,它的磁头始终得在物理上向不同的扇区上移动,这是一个不足为奇的事实。而虽然我们都知道 SSD 具有快速随机写入的特点,但事实上它不能修改单个字节,只能写入一页或更多页的 4KiB 数据量。这就意味着写入 16 字节的样本相当于写入满满一个 4Kib 的页。这一行为就是所谓的[写入放大][4],这种特性会损耗你的 SSD。因此它不仅影响速度,而且还毫不夸张地在几天或几个周内破坏掉你的硬件。 + +关于此问题更深层次的资料,[“Coding for SSDs”系列][5]博客是极好的资源。让我们想想主要的用处:顺序写入和批量写入分别对于旋转式磁盘和 SSD 来说都是理想的写入模式。大道至简。 + +查询模式比起写入模式明显更不同。我们可以查询单一序列的一个数据点,也可以对 10000 个序列查询一个数据点,还可以查询一个序列几个周的数据点,甚至是 10000 个序列几个周的数据点。因此在我们的二维平面上,查询范围不是完全水平或垂直的,而是二者形成矩形似的组合。 + +[记录规则][6]可以减轻已知查询的问题,但对于点对点ad-hoc查询来说并不是一个通用的解决方法。 + +我们知道我们想要批量地写入,但我们得到的仅仅是一系列垂直数据点的集合。当查询一段时间窗口内的数据点时,我们不仅很难弄清楚在哪才能找到这些单独的点,而且不得不从磁盘上大量随机的地方读取。也许一条查询语句会有数百万的样本,即使在最快的 SSD 上也会很慢。读入也会从磁盘上获取更多的数据而不仅仅是 16 字节的样本。SSD 会加载一整页,HDD 至少会读取整个扇区。不论哪一种,我们都在浪费宝贵的读取吞吐量。 + +因此在理想情况下,同一序列的样本将按顺序存储,这样我们就能通过尽可能少的读取来扫描它们。最重要的是,我们仅需要知道序列的起始位置就能访问所有的数据点。 + +显然,将收集到的数据写入磁盘的理想模式与能够显著提高查询效率的布局之间存在着明显的抵触。这是我们 TSDB 需要解决的一个基本问题。 + +#### 当前的解决方法 + +是时候看一下当前 Prometheus 是如何存储数据来解决这一问题的,让我们称它为“V2”。 + +我们创建一个时间序列的文件,它包含所有样本并按顺序存储。因为每几秒附加一个样本数据到所有文件中非常昂贵,我们在内存中打包 1Kib 样本序列的数据块,一旦打包完成就附加这些数据块到单独的文件中。这一方法解决了大部分问题。写入目前是批量的,样本也是按顺序存储的。基于给定的同一序列的样本相对之前的数据仅发生非常小的改变这一特性,它还支持非常高效的压缩格式。Facebook 在他们 Gorilla TSDB 上的论文中描述了一个相似的基于数据块的方法,并且[引入了一种压缩格式][7],它能够减少 16 字节的样本到平均 1.37 字节。V2 存储使用了包含 Gorilla 变体等在内的各种压缩格式。 + +``` + +----------+---------+---------+---------+---------+ series A + +----------+---------+---------+---------+---------+ + +----------+---------+---------+---------+---------+ series B + +----------+---------+---------+---------+---------+ + . . . + +----------+---------+---------+---------+---------+---------+ series XYZ + +----------+---------+---------+---------+---------+---------+ + chunk 1 chunk 2 chunk 3 ... +``` + +尽管基于块存储的方法非常棒,但为每个序列保存一个独立的文件会给 V2 存储带来麻烦,因为: + +* 实际上,我们需要的文件比当前收集数据的时间序列数量要多得多。多出的部分在序列分流Series Churn上。有几百万个文件,迟早会使用光文件系统中的 [inode][1]。这种情况我们只能通过重新格式化来恢复磁盘,这种方式是最具有破坏性的。我们通常不想为了适应一个应用程序而格式化磁盘。 +* 即使是分块写入,每秒也会产生数千块的数据块并且准备持久化。这依然需要每秒数千次的磁盘写入。尽管通过为每个序列打包好多个块来缓解,但这反过来还是增加了等待持久化数据的总内存占用。 +* 要保持所有文件打开来进行读写是不可行的。特别是因为 99% 的数据在 24 小时之后不再会被查询到。如果查询它,我们就得打开数千个文件,找到并读取相关的数据点到内存中,然后再关掉。这样做就会引起很高的查询延迟,数据块缓存加剧会导致新的问题,这一点在“资源消耗”一节另作讲述。 +* 最终,旧的数据需要被删除,并且数据需要从数百万文件的头部删除。这就意味着删除实际上是写密集型操作。此外,循环遍历数百万文件并且进行分析通常会导致这一过程花费数小时。当它完成时,可能又得重新来过。喔天,继续删除旧文件又会进一步导致 SSD 产生写入放大。 +* 目前所积累的数据块仅维持在内存中。如果应用崩溃,数据就会丢失。为了避免这种情况,内存状态会定期的保存在磁盘上,这比我们能接受数据丢失窗口要长的多。恢复检查点也会花费数分钟,导致很长的重启周期。 + +我们能够从现有的设计中学到的关键部分是数据块的概念,我们当然希望保留这个概念。最新的数据块会保持在内存中一般也是好的主意。毕竟,最新的数据会大量的查询到。 + +一个时间序列对应一个文件,这个概念是我们想要替换掉的。 + +### 序列分流 + +在 Prometheus 的上下文context中,我们使用术语序列分流series churn来描述一个时间序列集合变得不活跃,即不再接收数据点,取而代之的是出现一组新的活跃序列。 + +例如,由给定微服务实例产生的所有序列都有一个相应的“instance”标签来标识其来源。如果我们为微服务执行了滚动更新rolling update,并且为每个实例替换一个新的版本,序列分流便会发生。在更加动态的环境中,这些事情基本上每小时都会发生。像 Kubernetes 这样的集群编排Cluster orchestration系统允许应用连续性的自动伸缩和频繁的滚动更新,这样也许会创建成千上万个新的应用程序实例,并且伴随着全新的时间序列集合,每天都是如此。 + +``` +series + ^ + | . . . . . . + | . . . . . . + | . . . . . . + | . . . . . . . + | . . . . . . . + | . . . . . . . + | . . . . . . + | . . . . . . + | . . . . . + | . . . . . + | . . . . . + v + <-------------------- time ---------------------> +``` + +所以即便整个基础设施的规模基本保持不变,过一段时间后数据库内的时间序列还是会成线性增长。尽管 Prometheus 很愿意采集 1000 万个时间序列数据,但要想在 10 亿个序列中找到数据,查询效果还是会受到严重的影响。 + +#### 当前解决方案 + +当前 Prometheus 的 V2 存储系统对所有当前保存的序列拥有基于 LevelDB 的索引。它允许查询语句含有给定的标签对label pair,但是缺乏可伸缩的方法来从不同的标签选集中组合查询结果。 + +例如,从所有的序列中选择标签 `__name__="requests_total"` 非常高效,但是选择  `instance="A" AND __name__="requests_total"` 就有了可伸缩性的问题。我们稍后会重新考虑导致这一点的原因和能够提升查找延迟的调整方法。 + +事实上正是这个问题才催生出了对更好的存储系统的最初探索。Prometheus 需要为查找亿万个时间序列改进索引方法。 + +### 资源消耗 + +当试图扩展 Prometheus(或其他任何事情,真的)时,资源消耗是永恒不变的话题之一。但真正困扰用户的并不是对资源的绝对渴求。事实上,由于给定的需求,Prometheus 管理着令人难以置信的吞吐量。问题更在于面对变化时的相对未知性与不稳定性。通过其架构设计,V2 存储系统缓慢地构建了样本数据块,这一点导致内存占用随时间递增。当数据块完成之后,它们可以写到磁盘上并从内存中清除。最终,Prometheus 的内存使用到达稳定状态。直到监测环境发生了改变——每次我们扩展应用或者进行滚动更新,序列分流都会增加内存、CPU、磁盘 I/O 的使用。 + +如果变更正在进行,那么它最终还是会到达一个稳定的状态,但比起更加静态的环境,它的资源消耗会显著地提高。过渡时间通常为数个小时,而且难以确定最大资源使用量。 + +为每个时间序列保存一个文件这种方法也使得一个单个查询就很容易崩溃 Prometheus 进程。当查询的数据没有缓存在内存中,查询的序列文件就会被打开,然后将含有相关数据点的数据块读入内存。如果数据量超出内存可用量,Prometheus 就会因 OOM 被杀死而退出。 + +在查询语句完成之后,加载的数据便可以被再次释放掉,但通常会缓存更长的时间,以便更快地查询相同的数据。后者看起来是件不错的事情。 + +最后,我们看看之前提到的 SSD 的写入放大,以及 Prometheus 是如何通过批量写入来解决这个问题的。尽管如此,在许多地方还是存在因为批量太小以及数据未精确对齐页边界而导致的写入放大。对于更大规模的 Prometheus 服务器,现实当中会发现缩减硬件寿命的问题。这一点对于高写入吞吐量的数据库应用来说仍然相当普遍,但我们应该放眼看看是否可以解决它。 + +### 重新开始 + +到目前为止我们对于问题域、V2 存储系统是如何解决它的,以及设计上存在的问题有了一个清晰的认识。我们也看到了许多很棒的想法,这些或多或少都可以拿来直接使用。V2 存储系统相当数量的问题都可以通过改进和部分的重新设计来解决,但为了好玩(当然,在我仔细的验证想法之后),我决定试着写一个完整的时间序列数据库——从头开始,即向文件系统写入字节。 + +性能与资源使用这种最关键的部分直接影响了存储格式的选取。我们需要为数据找到正确的算法和磁盘布局来实现一个高性能的存储层。 + +这就是我解决问题的捷径——跳过令人头疼、失败的想法,数不尽的草图,泪水与绝望。 + +### V3—宏观设计 + +我们存储系统的宏观布局是什么?简而言之,是当我们在数据文件夹里运行 `tree` 命令时显示的一切。看看它能给我们带来怎样一副惊喜的画面。 + +``` +$ tree ./data +./data ++-- b-000001 +| +-- chunks +| | +-- 000001 +| | +-- 000002 +| | +-- 000003 +| +-- index +| +-- meta.json ++-- b-000004 +| +-- chunks +| | +-- 000001 +| +-- index +| +-- meta.json ++-- b-000005 +| +-- chunks +| | +-- 000001 +| +-- index +| +-- meta.json ++-- b-000006 + +-- meta.json + +-- wal + +-- 000001 + +-- 000002 + +-- 000003 +``` + +在最顶层,我们有一系列以 `b-` 为前缀编号的block。每个块中显然保存了索引文件和含有更多编号文件的 `chunk` 文件夹。`chunks` 目录只包含不同序列数据点的原始块raw chunks of data points。与 V2 存储系统一样,这使得通过时间窗口读取序列数据非常高效并且允许我们使用相同的有效压缩算法。这一点被证实行之有效,我们也打算沿用。显然,这里并不存在含有单个序列的文件,而是一堆保存着许多序列的数据块。 + +`index` 文件的存在应该不足为奇。让我们假设它拥有黑魔法,可以让我们找到标签、可能的值、整个时间序列和存放数据点的数据块。 + +但为什么这里有好几个文件夹都是索引和块文件的布局?并且为什么存在最后一个包含 `wal` 文件夹?理解这两个疑问便能解决九成的问题。 + +#### 许多小型数据库 + +我们分割横轴,即将时间域分割为不重叠的块。每一块扮演着完全独立的数据库,它包含该时间窗口所有的时间序列数据。因此,它拥有自己的索引和一系列块文件。 + +``` + +t0 t1 t2 t3 now + +-----------+ +-----------+ +-----------+ +-----------+ + | | | | | | | | +------------+ + | | | | | | | mutable | <--- write ---- ┤ Prometheus | + | | | | | | | | +------------+ + +-----------+ +-----------+ +-----------+ +-----------+ ^ + +--------------+-------+------+--------------+ | + | query + | | + merge -------------------------------------------------+ +``` + +每一块的数据都是不可变的immutable。当然,当我们采集新数据时,我们必须能向最近的块中添加新的序列和样本。对于该数据块,所有新的数据都将写入内存中的数据库中,它与我们的持久化的数据块一样提供了查找属性。内存中的数据结构可以高效地更新。为了防止数据丢失,所有传入的数据同样被写入临时的预写日志write ahead log中,这就是 `wal` 文件夹中的一些列文件,我们可以在重新启动时通过它们重新填充内存数据库。 + +所有这些文件都带有序列化格式,有我们所期望的所有东西:许多标志、偏移量、变体和 CRC32 校验和。纸上得来终觉浅,绝知此事要躬行。 + +这种布局允许我们扩展查询范围到所有相关的块上。每个块上的部分结果最终合并成完整的结果。 + +这种横向分割增加了一些很棒的功能: + +* 当查询一个时间范围,我们可以简单地忽略所有范围之外的数据块。通过减少需要检查的数据集,它可以初步解决序列分流的问题。 +* 当完成一个块,我们可以通过顺序的写入大文件从内存数据库中保存数据。这样可以避免任何的写入放大,并且 SSD 与 HDD 均适用。 +* 我们延续了 V2 存储系统的一个好的特性,最近使用而被多次查询的数据块,总是保留在内存中。 +* 很好,我们也不再受限于 1KiB 的数据块尺寸,以使数据在磁盘上更好地对齐。我们可以挑选对单个数据点和压缩格式最合理的尺寸。 +* 删除旧数据变得极为简单快捷。我们仅仅只需删除一个文件夹。记住,在旧的存储系统中我们不得不花数个小时分析并重写数亿个文件。 + +每个块还包含了 `meta.json` 文件。它简单地保存了关于块的存储状态和包含的数据,以便轻松了解存储状态及其包含的数据。 + +##### mmap + +将数百万个小文件合并为少数几个大文件使得我们用很小的开销就能保持所有的文件都打开。这就解除了对 [mmap(2)][8] 的使用的阻碍,这是一个允许我们通过文件透明地回传虚拟内存的系统调用。简单起见,你可以将其视为交换空间swap space,只是我们所有的数据已经保存在了磁盘上,并且当数据换出内存后不再会发生写入。 + +这意味着我们可以当作所有数据库的内容都视为在内存中却不占用任何物理内存。仅当我们访问数据库文件某些字节范围时,操作系统才会从磁盘上惰性加载lazy load页数据。这使得我们将所有数据持久化相关的内存管理都交给了操作系统。通常,操作系统更有资格作出这样的决定,因为它可以全面了解整个机器和进程。查询的数据可以相当积极的缓存进内存,但内存压力会使得页被换出。如果机器拥有未使用的内存,Prometheus 目前将会高兴地缓存整个数据库,但是一旦其他进程需要,它就会立刻返回那些内存。 + +因此,查询不再轻易地使我们的进程 OOM,因为查询的是更多的持久化的数据而不是装入内存中的数据。内存缓存大小变得完全自适应,并且仅当查询真正需要时数据才会被加载。 + +就个人理解,这就是当今大多数数据库的工作方式,如果磁盘格式允许,这是一种理想的方式,——除非有人自信能在这个过程中超越操作系统。我们做了很少的工作但确实从外面获得了很多功能。 + +#### 压缩 + +存储系统需要定期“切”出新块并将之前完成的块写入到磁盘中。仅在块成功的持久化之后,才会被删除之前用来恢复内存块的日志文件(wal)。 + +我们希望将每个块的保存时间设置的相对短一些(通常配置为 2 小时),以避免内存中积累太多的数据。当查询多个块,我们必须将它们的结果合并为一个整体的结果。合并过程显然会消耗资源,一个星期的查询不应该由超过 80 个的部分结果所组成。 + +为了实现两者,我们引入压缩compaction。压缩描述了一个过程:取一个或更多个数据块并将其写入一个可能更大的块中。它也可以在此过程中修改现有的数据。例如,清除已经删除的数据,或重建样本块以提升查询性能。 + +``` + +t0 t1 t2 t3 t4 now + +------------+ +----------+ +-----------+ +-----------+ +-----------+ + | 1 | | 2 | | 3 | | 4 | | 5 mutable | before + +------------+ +----------+ +-----------+ +-----------+ +-----------+ + +-----------------------------------------+ +-----------+ +-----------+ + | 1 compacted | | 4 | | 5 mutable | after (option A) + +-----------------------------------------+ +-----------+ +-----------+ + +--------------------------+ +--------------------------+ +-----------+ + | 1 compacted | | 3 compacted | | 5 mutable | after (option B) + +--------------------------+ +--------------------------+ +-----------+ +``` + +在这个例子中我们有顺序块 `[1,2,3,4]`。块 1、2、3 可以压缩在一起,新的布局将会是 `[1,4]`。或者,将它们成对压缩为 `[1,3]`。所有的时间序列数据仍然存在,但现在整体上保存在更少的块中。这极大程度地缩减了查询时间的消耗,因为需要合并的部分查询结果变得更少了。 + +#### 保留 + +我们看到了删除旧的数据在 V2 存储系统中是一个缓慢的过程,并且消耗 CPU、内存和磁盘。如何才能在我们基于块的设计上清除旧的数据?相当简单,只要删除我们配置的保留时间窗口里没有数据的块文件夹即可。在下面的例子中,块 1 可以被安全地删除,而块 2 则必须一直保留,直到它落在保留窗口边界之外。 + +``` + | + +------------+ +----+-----+ +-----------+ +-----------+ +-----------+ + | 1 | | 2 | | | 3 | | 4 | | 5 | . . . + +------------+ +----+-----+ +-----------+ +-----------+ +-----------+ + | + | + retention boundary +``` + +随着我们不断压缩先前压缩的块,旧数据越大,块可能变得越大。因此必须为其设置一个上限,以防数据块扩展到整个数据库而损失我们设计的最初优势。 + +方便的是,这一点也限制了部分存在于保留窗口内部分存在于保留窗口外的块的磁盘消耗总量。例如上面例子中的块 2。当设置了最大块尺寸为总保留窗口的 10% 后,我们保留块 2 的总开销也有了 10% 的上限。 + +总结一下,保留与删除从非常昂贵到了几乎没有成本。 + +> 如果你读到这里并有一些数据库的背景知识,现在你也许会问:这些都是最新的技术吗?——并不是;而且可能还会做的更好。 +> +> 在内存中批量处理数据,在预写日志中跟踪,并定期写入到磁盘的模式在现在相当普遍。 +> +> 我们看到的好处无论在什么领域的数据里都是适用的。遵循这一方法最著名的开源案例是 LevelDB、Cassandra、InfluxDB 和 HBase。关键是避免重复发明劣质的轮子,采用经过验证的方法,并正确地运用它们。 +> +> 脱离场景添加你自己的黑魔法是一种不太可能的情况。 + +### 索引 + +研究存储改进的最初想法是解决序列分流的问题。基于块的布局减少了查询所要考虑的序列总数。因此假设我们索引查找的复杂度是 `O(n^2)`,我们就要设法减少 n 个相当数量的复杂度,之后就相当于改进 `O(n^2)` 复杂度。——恩,等等……糟糕。 + +快速回顾一下“算法 101”课上提醒我们的,在理论上它并未带来任何好处。如果之前就很糟糕,那么现在也一样。理论是如此的残酷。 + +实际上,我们大多数的查询已经可以相当快响应。但是,跨越整个时间范围的查询仍然很慢,尽管只需要找到少部分数据。追溯到所有这些工作之前,最初我用来解决这个问题的想法是:我们需要一个更大容量的[倒排索引][9]。 + +倒排索引基于数据项内容的子集提供了一种快速的查找方式。简单地说,我可以通过标签 `app="nginx"` 查找所有的序列而无需遍历每个文件来看它是否包含该标签。 + +为此,每个序列被赋上一个唯一的 ID ,通过该 ID 可以恒定时间内检索它(`O(1)`)。在这个例子中 ID 就是我们的正向索引。 + +> 示例:如果 ID 为 10、29、9 的序列包含标签 `app="nginx"`,那么 “nginx”的倒排索引就是简单的列表 `[10, 29, 9]`,它就能用来快速地获取所有包含标签的序列。即使有 200 多亿个数据序列也不会影响查找速度。 + +简而言之,如果 `n` 是我们序列总数,`m` 是给定查询结果的大小,使用索引的查询复杂度现在就是 `O(m)`。查询语句依据它获取数据的数量 `m` 而不是被搜索的数据体 `n` 进行缩放是一个很好的特性,因为 `m` 一般相当小。 + +为了简单起见,我们假设可以在恒定时间内查找到倒排索引对应的列表。 + +实际上,这几乎就是 V2 存储系统具有的倒排索引,也是提供在数百万序列中查询性能的最低需求。敏锐的人会注意到,在最坏情况下,所有的序列都含有标签,因此 `m` 又成了 `O(n)`。这一点在预料之中,也相当合理。如果你查询所有的数据,它自然就会花费更多时间。一旦我们牵扯上了更复杂的查询语句就会有问题出现。 + +#### 标签组合 + +与数百万个序列相关的标签很常见。假设横向扩展着数百个实例的“foo”微服务,并且每个实例拥有数千个序列。每个序列都会带有标签 `app="foo"`。当然,用户通常不会查询所有的序列而是会通过进一步的标签来限制查询。例如,我想知道服务实例接收到了多少请求,那么查询语句便是 `__name__="requests_total" AND app="foo"`。 + +为了找到满足两个标签选择子的所有序列,我们得到每一个标签的倒排索引列表并取其交集。结果集通常会比任何一个输入列表小一个数量级。因为每个输入列表最坏情况下的大小为 `O(n)`,所以在嵌套地为每个列表进行暴力求解brute force solution下,运行时间为 `O(n^2)`。相同的成本也适用于其他的集合操作,例如取并集(`app="foo" OR app="bar"`)。当在查询语句上添加更多标签选择子,耗费就会指数增长到 `O(n^3)`、`O(n^4)`、`O(n^5)`……`O(n^k)`。通过改变执行顺序,可以使用很多技巧以优化运行效率。越复杂,越是需要关于数据特征和标签之间相关性的知识。这引入了大量的复杂度,但是并没有减少算法的最坏运行时间。 + +这便是 V2 存储系统使用的基本方法,幸运的是,看似微小的改动就能获得显著的提升。如果我们假设倒排索引中的 ID 都是排序好的会怎么样? + +假设这个例子的列表用于我们最初的查询: + +``` +__name__="requests_total" -> [ 9999, 1000, 1001, 2000000, 2000001, 2000002, 2000003 ] + app="foo" -> [ 1, 3, 10, 11, 12, 100, 311, 320, 1000, 1001, 10002 ] + + intersection => [ 1000, 1001 ] +``` + +它的交集相当小。我们可以为每个列表的起始位置设置游标,每次从最小的游标处移动来找到交集。当二者的数字相等,我们就添加它到结果中并移动二者的游标。总体上,我们以锯齿形扫描两个列表,因此总耗费是 `O(2n)=O(n)`,因为我们总是在一个列表上移动。 + +两个以上列表的不同集合操作也类似。因此 `k` 个集合操作仅仅改变了因子 `O(k*n)` 而不是最坏情况下查找运行时间的指数 `O(n^k)`。 + +我在这里所描述的是几乎所有[全文搜索引擎][10]使用的标准搜索索引的简化版本。每个序列描述符都视作一个简短的“文档”,每个标签(名称 + 固定值)作为其中的“单词”。我们可以忽略搜索引擎索引中通常遇到的很多附加数据,例如单词位置和和频率。 + +关于改进实际运行时间的方法似乎存在无穷无尽的研究,它们通常都是对输入数据做一些假设。不出意料的是,还有大量技术来压缩倒排索引,其中各有利弊。因为我们的“文档”比较小,而且“单词”在所有的序列里大量重复,压缩变得几乎无关紧要。例如,一个真实的数据集约有 440 万个序列与大约 12 个标签,每个标签拥有少于 5000 个单独的标签。对于最初的存储版本,我们坚持使用基本的方法而不压缩,仅做微小的调整来跳过大范围非交叉的 ID。 + +尽管维持排序好的 ID 听起来很简单,但实践过程中不是总能完成的。例如,V2 存储系统为新的序列赋上一个哈希值来当作 ID,我们就不能轻易地排序倒排索引。 + +另一个艰巨的任务是当磁盘上的数据被更新或删除掉后修改其索引。通常,最简单的方法是重新计算并写入,但是要保证数据库在此期间可查询且具有一致性。V3 存储系统通过每块上具有的独立不可变索引来解决这一问题,该索引仅通过压缩时的重写来进行修改。只有可变块上的索引需要被更新,它完全保存在内存中。 + +## 基准测试 + +我从存储的基准测试开始了初步的开发,它基于现实世界数据集中提取的大约 440 万个序列描述符,并生成合成数据点以输入到这些序列中。这个阶段的开发仅仅测试了单独的存储系统,对于快速找到性能瓶颈和高并发负载场景下的触发死锁至关重要。 + +在完成概念性的开发实施之后,该基准测试能够在我的 Macbook Pro 上维持每秒 2000 万的吞吐量 —— 并且这都是在打开着十几个 Chrome 的页面和 Slack 的时候。因此,尽管这听起来都很棒,它这也表明推动这项测试没有的进一步价值(或者是没有在高随机环境下运行)。毕竟,它是合成的数据,因此在除了良好的第一印象外没有多大价值。比起最初的设计目标高出 20 倍,是时候将它部署到真正的 Prometheus 服务器上了,为它添加更多现实环境中的开销和场景。 + +我们实际上没有可重现的 Prometheus 基准测试配置,特别是没有对于不同版本的 A/B 测试。亡羊补牢为时不晚,[不过现在就有一个了][11]! + +我们的工具可以让我们声明性地定义基准测试场景,然后部署到 AWS 的 Kubernetes 集群上。尽管对于全面的基准测试来说不是最好环境,但它肯定比 64 核 128GB 内存的专用裸机服务器bare metal servers更能反映出我们的用户群体。 + +我们部署了两个 Prometheus 1.5.2 服务器(V2 存储系统)和两个来自 2.0 开发分支的 Prometheus (V3 存储系统)。每个 Prometheus 运行在配备 SSD 的专用服务器上。我们将横向扩展的应用部署在了工作节点上,并且让其暴露典型的微服务度量。此外,Kubernetes 集群本身和节点也被监控着。整套系统由另一个 Meta-Prometheus 所监督,它监控每个 Prometheus 的健康状况和性能。 + +为了模拟序列分流,微服务定期的扩展和收缩来移除旧的 pod 并衍生新的 pod,生成新的序列。通过选择“典型”的查询来模拟查询负载,对每个 Prometheus 版本都执行一次。 + +总体上,伸缩与查询的负载以及采样频率极大的超出了 Prometheus 的生产部署。例如,我们每隔 15 分钟换出 60% 的微服务实例去产生序列分流。在现代的基础设施上,一天仅大约会发生 1-5 次。这就保证了我们的 V3 设计足以处理未来几年的工作负载。就结果而言,Prometheus 1.5.2 和 2.0 之间的性能差异在极端的环境下会变得更大。 + +总而言之,我们每秒从 850 个目标里收集大约 11 万份样本,每次暴露 50 万个序列。 + +在此系统运行一段时间之后,我们可以看一下数字。我们评估了两个版本在 12 个小时之后到达稳定时的几个指标。 + +> 请注意从 Prometheus 图形界面的截图中轻微截断的 Y 轴 + +![Heap usage GB](https://fabxc.org/tsdb/assets/heap_usage.png) + +*堆内存使用(GB)* + +内存资源的使用对用户来说是最为困扰的问题,因为它相对的不可预测且可能导致进程崩溃。 + +显然,查询的服务器正在消耗内存,这很大程度上归咎于查询引擎的开销,这一点可以当作以后优化的主题。总的来说,Prometheus 2.0 的内存消耗减少了 3-4 倍。大约 6 小时之后,在 Prometheus 1.5 上有一个明显的峰值,与我们设置的 6 小时的保留边界相对应。因为删除操作成本非常高,所以资源消耗急剧提升。这一点在下面几张图中均有体现。 + +![CPU usage cores](https://fabxc.org/tsdb/assets/cpu_usage.png) + +*CPU 使用(核心/秒)* + +类似的模式也体现在 CPU 使用上,但是查询的服务器与非查询的服务器之间的差异尤为明显。每秒获取大约 11 万个数据需要 0.5 核心/秒的 CPU 资源,比起评估查询所花费的 CPU 时间,我们的新存储系统 CPU 消耗可忽略不计。总的来说,新存储需要的 CPU 资源减少了 3 到 10 倍。 + +![Disk writes](https://fabxc.org/tsdb/assets/disk_writes.png) + +*磁盘写入(MB/秒)* + +迄今为止最引人注目和意想不到的改进表现在我们的磁盘写入利用率上。这就清楚的说明了为什么 Prometheus 1.5 很容易造成 SSD 损耗。我们看到最初的上升发生在第一个块被持久化到序列文件中的时期,然后一旦删除操作引发了重写就会带来第二个上升。令人惊讶的是,查询的服务器与非查询的服务器显示出了非常不同的利用率。 + +在另一方面,Prometheus 2.0 每秒仅向其预写日志写入大约一兆字节。当块被压缩到磁盘时,写入定期地出现峰值。这在总体上节省了:惊人的 97-99%。 + +![Disk usage](https://fabxc.org/tsdb/assets/disk_usage.png) + +*磁盘大小(GB)* + +与磁盘写入密切相关的是总磁盘空间占用量。由于我们对样本(这是我们的大部分数据)几乎使用了相同的压缩算法,因此磁盘占用量应当相同。在更为稳定的系统中,这样做很大程度上是正确地,但是因为我们需要处理高的序列分流,所以还要考虑每个序列的开销。 + +如我们所见,Prometheus 1.5 在这两个版本达到稳定状态之前,使用的存储空间因其保留操作而急速上升。Prometheus 2.0 似乎在每个序列上的开销显著降低。我们可以清楚的看到预写日志线性地充满整个存储空间,然后当压缩完成后瞬间下降。事实上对于两个 Prometheus 2.0 服务器,它们的曲线并不是完全匹配的,这一点需要进一步的调查。 + +前景大好。剩下最重要的部分是查询延迟。新的索引应当优化了查找的复杂度。没有实质上发生改变的是处理数据的过程,例如 `rate()` 函数或聚合。这些就是查询引擎要做的东西了。 + +![Query latency](https://fabxc.org/tsdb/assets/query_latency.png) + +*第 99 个百分位查询延迟(秒)* + +数据完全符合预期。在 Prometheus 1.5 上,查询延迟随着存储的序列而增加。只有在保留操作开始且旧的序列被删除后才会趋于稳定。作为对比,Prometheus 2.0 从一开始就保持在合适的位置。 + +我们需要花一些心思在数据是如何被采集上,对服务器发出的查询请求通过对以下方面的估计来选择:范围查询和即时查询的组合,进行更轻或更重的计算,访问更多或更少的文件。它并不需要代表真实世界里查询的分布。也不能代表冷数据的查询性能,我们可以假设所有的样本数据都是保存在内存中的热数据。 + +尽管如此,我们可以相当自信地说,整体查询效果对序列分流变得非常有弹性,并且在高压基准测试场景下提升了 4 倍的性能。在更为静态的环境下,我们可以假设查询时间大多数花费在了查询引擎上,改善程度明显较低。 + +![Ingestion rate](https://fabxc.org/tsdb/assets/ingestion_rate.png) + +*摄入的样本/秒* + +最后,快速地看一下不同 Prometheus 服务器的摄入率。我们可以看到搭载 V3 存储系统的两个服务器具有相同的摄入速率。在几个小时之后变得不稳定,这是因为不同的基准测试集群节点由于高负载变得无响应,与 Prometheus 实例无关。(两个 2.0 的曲线完全匹配这一事实希望足够具有说服力) + +尽管还有更多 CPU 和内存资源,两个 Prometheus 1.5.2 服务器的摄入率大大降低。序列分流的高压导致了无法采集更多的数据。 + +那么现在每秒可以摄入的绝对最大absolute maximum样本数是多少? + +但是现在你可以摄取的每秒绝对最大样本数是多少? + +我不知道 —— 虽然这是一个相当容易的优化指标,但除了稳固的基线性能之外,它并不是特别有意义。 + +有很多因素都会影响 Prometheus 数据流量,而且没有一个单独的数字能够描述捕获质量。最大摄入率在历史上是一个导致基准出现偏差的度量,并且忽视了更多重要的层面,例如查询性能和对序列分流的弹性。关于资源使用线性增长的大致猜想通过一些基本的测试被证实。很容易推断出其中的原因。 + +我们的基准测试模拟了高动态环境下 Prometheus 的压力,它比起真实世界中的更大。结果表明,虽然运行在没有优化的云服务器上,但是已经超出了预期的效果。最终,成功将取决于用户反馈而不是基准数字。 + +> 注意:在撰写本文的同时,Prometheus 1.6 正在开发当中,它允许更可靠地配置最大内存使用量,并且可能会显著地减少整体的消耗,有利于稍微提高 CPU 使用率。我没有重复对此进行测试,因为整体结果变化不大,尤其是面对高序列分流的情况。 + +## 总结 + +Prometheus 开始应对高基数序列与单独样本的吞吐量。这仍然是一项富有挑战性的任务,但是新的存储系统似乎向我们展示了未来的一些好东西。 + +第一个配备 V3 存储系统的 [alpha 版本 Prometheus 2.0][12] 已经可以用来测试了。在早期阶段预计还会出现崩溃,死锁和其他 bug。 + +存储系统的代码可以在[这个单独的项目中找到][13]。Prometheus 对于寻找高效本地存储时间序列数据库的应用来说可能非常有用,这一点令人非常惊讶。 + +> 这里需要感谢很多人作出的贡献,以下排名不分先后: + +> Bjoern Rabenstein 和 Julius Volz 在 V2 存储引擎上的打磨工作以及 V3 存储系统的反馈,这为新一代的设计奠定了基础。 + +> Wilhelm Bierbaum 对新设计不断的建议与见解作出了很大的贡献。Brian Brazil 不断的反馈确保了我们最终得到的是语义上合理的方法。与 Peter Bourgon 深刻的讨论验证了设计并形成了这篇文章。 + +> 别忘了我们整个 CoreOS 团队与公司对于这项工作的赞助与支持。感谢所有那些听我一遍遍唠叨 SSD、浮点数、序列化格式的同学。 + +-------------------------------------------------------------------------------- + +via: https://fabxc.org/blog/2017-04-10-writing-a-tsdb/ + +作者:[Fabian Reinartz][a] +译者:[LuuMing](https://github.com/LuuMing) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://twitter.com/fabxc +[1]:https://en.wikipedia.org/wiki/Inode +[2]:https://prometheus.io/ +[3]:https://kubernetes.io/ +[4]:https://en.wikipedia.org/wiki/Write_amplification +[5]:http://codecapsule.com/2014/02/12/coding-for-ssds-part-1-introduction-and-table-of-contents/ +[6]:https://prometheus.io/docs/practices/rules/ +[7]:http://www.vldb.org/pvldb/vol8/p1816-teller.pdf +[8]:https://en.wikipedia.org/wiki/Mmap +[9]:https://en.wikipedia.org/wiki/Inverted_index +[10]:https://en.wikipedia.org/wiki/Search_engine_indexing#Inverted_indices +[11]:https://github.com/prometheus/prombench +[12]:https://prometheus.io/blog/2017/04/10/promehteus-20-sneak-peak/ +[13]:https://github.com/prometheus/tsdb diff --git a/published/201906/20170414 5 projects for Raspberry Pi at home.md b/published/201906/20170414 5 projects for Raspberry Pi at home.md new file mode 100644 index 0000000000..3d6f5b2382 --- /dev/null +++ b/published/201906/20170414 5 projects for Raspberry Pi at home.md @@ -0,0 +1,149 @@ +[#]: collector: (lujun9972) +[#]: translator: (warmfrog) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10936-1.html) +[#]: subject: (5 projects for Raspberry Pi at home) +[#]: via: (https://opensource.com/article/17/4/5-projects-raspberry-pi-home) +[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall) + +5 个可在家中使用的树莓派项目 +====================================== + +![5 projects for Raspberry Pi at home][1] + +[树莓派][2] 电脑可被用来进行多种设置用于不同的目的。显然它在教育市场帮助学生在教室和创客空间中学习编程与创客技巧方面占有一席之地,它在工作场所和工厂中有大量行业应用。我打算介绍五个你可能想要在你的家中构建的项目。 + +### 媒体中心 + +在家中人们常用树莓派作为媒体中心来服务多媒体文件。它很容易搭建,树莓派提供了大量的 GPU(图形处理单元)运算能力来在大屏电视上渲染你的高清电视节目和电影。将 [Kodi][3](从前的 XBMC)运行在树莓派上是一个很棒的方式,它可以播放你的硬盘或网络存储上的任何媒体。你同样可以安装一个插件来播放 YouTube 视频。 + +还有几个略微不同的选择,最常见的是 [OSMC][4](开源媒体中心)和 [LibreELEC][5],都是基于 Kodi 的。它们在放映媒体内容方面表现的都非常好,但是 OSMC 有一个更酷炫的用户界面,而 LibreElec 更轻量级。你要做的只是选择一个发行版,下载镜像并安装到一个 SD 卡中(或者仅仅使用 [NOOBS][6]),启动,然后就准备好了。 + +![LibreElec ][7] + +*LibreElec;树莓派基金会, CC BY-SA* + +![OSMC][8] + +*OSMC.tv, 版权所有, 授权使用* + +在往下走之前,你需要决定[使用哪种树莓派][9]。这些发行版在任何树莓派(1、2、3 或 Zero)上都能运行,视频播放在这些树莓派中的任何一个上都能胜任。除了 Pi 3(和 Zero W)有内置 Wi-Fi,唯一可察觉的不同是用户界面的反应速度,在 Pi 3 上更快。Pi 2 也不会慢太多,所以如果你不需要 Wi-Fi 它也是可以的,但是当切换菜单时,你会注意到 Pi 3 比 Pi 1 和 Zero 表现的更好。 + +### SSH 网关 + +如果你想从外部网络访问你的家庭局域网的电脑和设备,你必须打开这些设备的端口来允许外部访问。在互联网中开放这些端口有安全风险,意味着你总是你总是处于被攻击、滥用或者其他各种未授权访问的风险中。然而,如果你在你的网络中安装一个树莓派,并且设置端口映射来仅允许通过 SSH 访问树莓派,你可以这么用来作为一个安全的网关来跳到网络中的其他树莓派和 PC。 + +大多数路由允许你配置端口映射规则。你需要给你的树莓派一个固定的内网 IP 地址来设置你的路由器端口 22 映射到你的树莓派端口 22。如果你的网络服务提供商给你提供了一个静态 IP 地址,你能够通过 SSH 和主机的 IP 地址访问(例如,`ssh pi@123.45.56.78`)。如果你有一个域名,你可以配置一个子域名指向这个 IP 地址,所以你没必要记住它(例如,`ssh pi@home.mydomain.com`)。 + +![][11] + +然而,如果你不想将树莓派暴露在互联网上,你应该非常小心,不要让你的网络处于危险之中。如果你遵循一些简单的步骤来使它更安全: + +1. 大多数人建议你更换你的登录密码(有道理,默认密码 “raspberry” 是众所周知的),但是这不能阻挡暴力攻击。你可以改变你的密码并添加一个双重验证(所以你需要你的密码*和*一个手机生成的与时间相关的密码),这么做更安全。但是,我相信最好的方法阻止入侵者访问你的树莓派是在你的 SSH 配置中[禁止密码认证][12],这样只能通过 SSH 密匙进入。这意味着任何试图猜测你的密码尝试登录的人都不会成功。只有你的私有密匙可以访问。简单来说,很多人建议将 SSH 端口从默认的 22 换成其他的,但是通过简单的 [Nmap][13] 扫描你的 IP 地址,你信任的 SSH 端口就会暴露。 +2. 最好,不要在这个树莓派上运行其他的软件,这样你不会意外暴露其他东西。如果你想要运行其他软件,你最好在网络中的其他树莓派上运行,它们没有暴露在互联网上。确保你经常升级来保证你的包是最新的,尤其是 `openssh-server` 包,这样你的安全缺陷就被打补丁了。 +3. 安装 [sshblack][14] 或 [fail2ban][15] 来将任何表露出恶意的用户加入黑名单,例如试图暴力破解你的 SSH 密码。 + +使树莓派安全后,让它在线,你将可以在世界的任何地方登录你的网络。一旦你登录到你的树莓派,你可以用 SSH 访问本地网络上的局域网地址(例如,192.168.1.31)访问其他设备。如果你在这些设备上有密码,用密码就好了。如果它们同样只允许 SSH 密匙,你需要确保你的密匙通过 SSH 转发,使用 `-A` 参数:`ssh -A pi@123.45.67.89`。 + +### CCTV / 宠物相机 + +另一个很棒的家庭项目是安装一个相机模块来拍照和录视频,录制并保存文件,在内网或者外网中进行流式传输。你想这么做有很多原因,但两个常见的情况是一个家庭安防相机或监控你的宠物。 + +[树莓派相机模块][16] 是一个优秀的配件。它提供全高清的相片和视频,包括很多高级配置,很[容易编程][17]。[红外线相机][18]用于这种目的是非常理想的,通过一个红外线 LED(树莓派可以控制的),你就能够在黑暗中看见东西。 + +如果你想通过一定频率拍摄静态图片来留意某件事,你可以仅仅写一个简短的 [Python][19] 脚本或者使用命令行工具 [raspistill][20], 在 [Cron][21] 中规划它多次运行。你可能想将它们保存到 [Dropbox][22] 或另一个网络服务,上传到一个网络服务器,你甚至可以创建一个[web 应用][23]来显示他们。 + +如果你想要在内网或外网中流式传输视频,那也相当简单。在 [picamera 文档][24]中(在 “web streaming” 章节)有一个简单的 MJPEG(Motion JPEG)例子。简单下载或者拷贝代码到文件中,运行并访问树莓派的 IP 地址的 8000 端口,你会看见你的相机的直播输出。 + +有一个更高级的流式传输项目 [pistreaming][25] 也可以,它通过在网络服务器中用 [JSMpeg][26] (一个 JavaScript 视频播放器)和一个用于相机流的单独运行的 websocket。这种方法性能更好,并且和之前的例子一样简单,但是如果要在互联网中流式传输,则需要包含更多代码,并且需要你开放两个端口。 + +一旦你的网络流建立起来,你可以将你的相机放在你想要的地方。我用一个来观察我的宠物龟: + +![Tortoise ][27] + +*Ben Nuttall, CC BY-SA* + +如果你想控制相机位置,你可以用一个舵机。一个优雅的方案是用 Pimoroni 的 [Pan-Tilt HAT][28],它可以让你简单的在二维方向上移动相机。为了与 pistreaming 集成,可以看看该项目的 [pantilthat 分支][29]. + +![Pan-tilt][30] + +*Pimoroni.com, Copyright, 授权使用* + +如果你想将你的树莓派放到户外,你将需要一个防水的外围附件,并且需要一种给树莓派供电的方式。POE(通过以太网提供电力)电缆是一个不错的实现方式。 + +### 家庭自动化或物联网 + +现在是 2017 年(LCTT 译注:此文发表时间),到处都有很多物联网设备,尤其是家中。我们的电灯有 Wi-Fi,我们的面包烤箱比过去更智能,我们的茶壶处于俄国攻击的风险中,除非你确保你的设备安全,不然别将没有必要的设备连接到互联网,之后你可以在家中充分的利用物联网设备来完成自动化任务。 + +市场上有大量你可以购买或订阅的服务,像 Nest Thermostat 或 Philips Hue 电灯泡,允许你通过你的手机控制你的温度或者你的亮度,无论你是否在家。你可以用一个树莓派来催动这些设备的电源,通过一系列规则包括时间甚至是传感器来完成自动交互。用 Philips Hue,你做不到的当你进房间时打开灯光,但是有一个树莓派和一个运动传感器,你可以用 Python API 来打开灯光。类似地,当你在家的时候你可以通过配置你的 Nest 打开加热系统,但是如果你想在房间里至少有两个人时才打开呢?写一些 Python 代码来检查网络中有哪些手机,如果至少有两个,告诉 Nest 来打开加热器。 + +不用选择集成已存在的物联网设备,你可以用简单的组件来做的更多。一个自制的窃贼警报器,一个自动化的鸡笼门开关,一个夜灯,一个音乐盒,一个定时的加热灯,一个自动化的备份服务器,一个打印服务器,或者任何你能想到的。 + +### Tor 协议和屏蔽广告 + +Adafruit 的 [Onion Pi][31] 是一个 [Tor][32] 协议来使你的网络通讯匿名,允许你使用互联网而不用担心窥探者和各种形式的监视。跟随 Adafruit 的指南来设置 Onion Pi,你会找到一个舒服的匿名的浏览体验。 + +![Onion-Pi][33] + +*Onion-pi from Adafruit, Copyright, 授权使用* + +![Pi-hole][34] + +可以在你的网络中安装一个树莓派来拦截所有的网络交通并过滤所有广告。简单下载 [Pi-hole][35] 软件到 Pi 中,你的网络中的所有设备都将没有广告(甚至屏蔽你的移动设备应用内的广告)。 + +树莓派在家中有很多用法。你在家里用树莓派来干什么?你想用它干什么? + +在下方评论让我们知道。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/4/5-projects-raspberry-pi-home + +作者:[Ben Nuttall][a] +选题:[lujun9972][b] +译者:[warmfrog](https://github.com/warmfrog) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberry_pi_home_automation.png?itok=2TnmJpD8 (5 projects for Raspberry Pi at home) +[2]: https://www.raspberrypi.org/ +[3]: https://kodi.tv/ +[4]: https://osmc.tv/ +[5]: https://libreelec.tv/ +[6]: https://www.raspberrypi.org/downloads/noobs/ +[7]: https://opensource.com/sites/default/files/libreelec_0.png (LibreElec ) +[8]: https://opensource.com/sites/default/files/osmc.png (OSMC) +[9]: https://opensource.com/life/16/10/which-raspberry-pi-should-you-choose-your-project +[10]: mailto:pi@home.mydomain.com +[11]: https://opensource.com/sites/default/files/resize/screenshot_from_2017-04-07_15-13-01-700x380.png +[12]: http://stackoverflow.com/questions/20898384/ssh-disable-password-authentication +[13]: https://nmap.org/ +[14]: http://www.pettingers.org/code/sshblack.html +[15]: https://www.fail2ban.org/wiki/index.php/Main_Page +[16]: https://www.raspberrypi.org/products/camera-module-v2/ +[17]: https://opensource.com/life/15/6/raspberry-pi-camera-projects +[18]: https://www.raspberrypi.org/products/pi-noir-camera-v2/ +[19]: http://picamera.readthedocs.io/ +[20]: https://www.raspberrypi.org/documentation/usage/camera/raspicam/raspistill.md +[21]: https://www.raspberrypi.org/documentation/linux/usage/cron.md +[22]: https://github.com/RZRZR/plant-cam +[23]: https://github.com/bennuttall/bett-bot +[24]: http://picamera.readthedocs.io/en/release-1.13/recipes2.html#web-streaming +[25]: https://github.com/waveform80/pistreaming +[26]: http://jsmpeg.com/ +[27]: https://opensource.com/sites/default/files/tortoise.jpg (Tortoise) +[28]: https://shop.pimoroni.com/products/pan-tilt-hat +[29]: https://github.com/waveform80/pistreaming/tree/pantilthat +[30]: https://opensource.com/sites/default/files/pan-tilt.gif (Pan-tilt) +[31]: https://learn.adafruit.com/onion-pi/overview +[32]: https://www.torproject.org/ +[33]: https://opensource.com/sites/default/files/onion-pi.jpg (Onion-Pi) +[34]: https://opensource.com/sites/default/files/resize/pi-hole-250x250.png (Pi-hole) +[35]: https://pi-hole.net/ + + + diff --git a/published/201906/20180324 Memories of writing a parser for man pages.md b/published/201906/20180324 Memories of writing a parser for man pages.md new file mode 100644 index 0000000000..ffaebad575 --- /dev/null +++ b/published/201906/20180324 Memories of writing a parser for man pages.md @@ -0,0 +1,103 @@ +为 man 手册页编写解析器的备忘录 +====== +![](https://img.linux.net.cn/data/attachment/album/201906/11/235607fiqfqapvpzqhh8n1.jpg) + +我一般都很喜欢无所事事,但有时候太无聊了也不行 —— 2015 年的一个星期天下午就是这样,我决定开始写一个开源项目来让我不那么无聊。 + +在我寻求创意时,我偶然发现了一个请求,要求构建一个由 [Mathias Bynens][2] 提出的“[按 Web 标准构建的 Man 手册页查看器][1]”。没有考虑太多,我开始使用 JavaScript 编写一个手册页解析器,经过大量的反复思考,最终做出了一个 [Jroff][3]。 + +那时候,我非常熟悉手册页这个概念,而且使用过很多次,但我知道的仅止于此,我不知道它们是如何生成的,或者是否有一个标准。在经过两年后,我有了一些关于此事的想法。 + +### man 手册页是如何写的 + +当时令我感到惊讶的第一件事是,手册页的核心只是存储在系统某处的纯文本文件(你可以使用 `manpath` 命令检查这些目录)。 + +此文件中不仅包含文档,还包含使用了 20 世纪 70 年代名为 `troff` 的排版系统的格式化信息。 + +> troff 及其 GNU 实现 groff 是处理文档的文本描述以生成适合打印的排版版本的程序。**它更像是“你所描述的即你得到的”,而不是你所见即所得的。** +> +> - 摘自 [troff.org][4] + +如果你对排版格式毫不熟悉,可以将它们视为 steroids 期刊用的 Markdown,但其灵活性带来的就是更复杂的语法: + +![groff-compressor][5] + +`groff` 文件可以手工编写,也可以使用许多不同的工具从其他格式生成,如 Markdown、Latex、HTML 等。 + +为什么 `groff` 和 man 手册页绑在一起是有历史原因的,其格式[随时间有变化][6],它的血统由一系列类似命名的程序组成:RUNOFF > roff > nroff > troff > groff。 + +但这并不一定意味着 `groff` 与手册页有多紧密的关系,它是一种通用格式,已被用于[书籍][7],甚至用于[照相排版][8]。 + +此外,值得注意的是 `groff` 也可以调用后处理器将其中间输出结果转换为最终格式,这对于终端显示来说不一定是 ascii !一些支持的格式是:TeX DVI、HTML、Canon、HP LaserJet4 兼容格式、PostScript、utf8 等等。 + +### 宏 + +该格式的其他很酷的功能是它的可扩展性,你可以编写宏来增强其基本功能。 + +鉴于 *nix 系统的悠久历史,有几个可以根据你想要生成的输出而将特定功能组合在一起的宏包,例如 `man`、`mdoc`、`mom`、`ms`、`mm` 等等。 + +手册页通常使用 `man` 和 `mdoc` 宏包编写。 + +区分原生的 `groff` 命令和宏的方式是通过标准 `groff` 包大写其宏名称。对于 `man` 宏包,每个宏的名称都是大写的,如 `.PP`、`.TH`、`.SH` 等。对于 `mdoc` 宏包,只有第一个字母是大写的: `.Pp`、`.Dt`、`.Sh`。 + +![groff-example][9] + +### 挑战 + +无论你是考虑编写自己的 `groff` 解析器,还是只是好奇,这些都是我发现的一些更具挑战性的问题。 + +#### 上下文敏感的语法 + +表面上,`groff` 的语法是上下文无关的,遗憾的是,因为宏描述的是主体不透明的令牌,所以包中的宏集合本身可能不会实现上下文无关的语法。 + +这导致我在那时做不出来一个解析器生成器(不管好坏)。 + +#### 嵌套的宏 + +`mdoc` 宏包中的大多数宏都是可调用的,这差不多意味着宏可以用作其他宏的参数,例如,你看看这个: + +* 宏 `Fl`(Flag)会在其参数中添加破折号,因此 `Fl s` 会生成 `-s` +* 宏 `Ar`(Argument)提供了定义参数的工具 +* 宏 `Op`(Optional)会将其参数括在括号中,因为这是将某些东西定义为可选的标准习惯用法 +* 以下组合 `.Op Fl s Ar file ` 将生成 `[-s file]`,因为 `Op` 宏可以嵌套。 + +#### 缺乏适合初学者的资源 + +让我感到困惑的是缺乏一个规范的、定义明确的、清晰的来源,网上有很多信息,这些信息对读者来说很重要,需要时间来掌握。 + +### 有趣的宏 + +总结一下,我会向你提供一个非常简短的宏列表,我在开发 jroff 时发现它很有趣: + +`man` 宏包: + +* `.TH`:用 `man` 宏包编写手册页时,你的第一个不是注释的行必须是这个宏,它接受五个参数:`title`、`section`、`date`、`source`、`manual`。 +* `.BI`:粗体加斜体(特别适用于函数格式) +* `.BR`:粗体加正体(特别适用于参考其他手册页) + +`mdoc` 宏包: + +* `.Dd`、`.Dt`、`.Os`:类似于 `man` 宏包需要 `.TH`,`mdoc` 宏也需要这三个宏,需要按特定顺序使用。它们的缩写分别代表:文档日期、文档标题和操作系统。 +* `.Bl`、`.It`、`.El`:这三个宏用于创建列表,它们的名称不言自明:开始列表、项目和结束列表。 + +-------------------------------------------------------------------------------- + +via: https://monades.roperzh.com/memories-writing-parser-man-pages/ + +作者:[Roberto Dip][a] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) +选题:[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 diff --git a/published/201906/20180416 How To Resize Active-Primary root Partition Using GParted Utility.md b/published/201906/20180416 How To Resize Active-Primary root Partition Using GParted Utility.md new file mode 100644 index 0000000000..4afa58fffa --- /dev/null +++ b/published/201906/20180416 How To Resize Active-Primary root Partition Using GParted Utility.md @@ -0,0 +1,191 @@ +如何使用 GParted 实用工具缩放根分区 +====== + +今天,我们将讨论磁盘分区。这是 Linux 中的一个好话题。这允许用户来重新调整在 Linux 中的活动 root 分区。 + +在这篇文章中,我们将教你如何使用 GParted 缩放在 Linux 上的活动根分区。 + +比如说,当我们安装 Ubuntu 操作系统时,并没有恰当地配置,我们的系统仅有 30 GB 磁盘。我们需要安装另一个操作系统,因此我们想在其中制作第二个分区。 + +虽然不建议重新调整活动分区。然而,我们要执行这个操作,因为没有其它方法来释放系统分区。 + +> 注意:在执行这个动作前,确保你备份了重要的数据,因为如果一些东西出错(例如,电源故障或你的系统重启),你可以得以保留你的数据。 + +### Gparted 是什么 + +[GParted][1] 是一个自由的分区管理器,它使你能够缩放、复制和移动分区,而不丢失数据。通过使用 GParted 的 Live 可启动镜像,我们可以使用 GParted 应用程序的所有功能。GParted Live 可以使你能够在 GNU/Linux 以及其它的操作系统上使用 GParted,例如,Windows 或 Mac OS X 。 + +#### 1) 使用 df 命令检查磁盘空间利用率 + +我只是想使用 `df` 命令向你显示我的分区。`df` 命令输出清楚地表明我仅有一个分区。 + +``` +$ df -h +Filesystem Size Used Avail Use% Mounted on +/dev/sda1 30G 3.4G 26.2G 16% / +none 4.0K 0 4.0K 0% /sys/fs/cgroup +udev 487M 4.0K 487M 1% /dev +tmpfs 100M 844K 99M 1% /run +none 5.0M 0 5.0M 0% /run/lock +none 498M 152K 497M 1% /run/shm +none 100M 52K 100M 1% /run/user +``` + +#### 2) 使用 fdisk 命令检查磁盘分区 + +我将使用 `fdisk` 命令验证这一点。 + +``` +$ sudo fdisk -l +[sudo] password for daygeek: + +Disk /dev/sda: 33.1 GB, 33129218048 bytes +255 heads, 63 sectors/track, 4027 cylinders, total 64705504 sectors +Units = sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes +Disk identifier: 0x000473a3 + + Device Boot Start End Blocks Id System +/dev/sda1 * 2048 62609407 31303680 83 Linux +/dev/sda2 62611454 64704511 1046529 5 Extended +/dev/sda5 62611456 64704511 1046528 82 Linux swap / Solaris +``` + +#### 3) 下载 GParted live ISO 镜像 + +使用下面的命令来执行下载 GParted live ISO。 + +``` +$ wget https://downloads.sourceforge.net/gparted/gparted-live-0.31.0-1-amd64.iso +``` + +#### 4) 使用 GParted Live 安装介质启动你的系统 + +使用 GParted Live 安装介质(如烧录的 CD/DVD 或 USB 或 ISO 镜像)启动你的系统。你将获得类似于下面屏幕的输出。在这里选择 “GParted Live (Default settings)” ,并敲击回车按键。 + +![][3] + +#### 5) 键盘选择 + +默认情况下,它选择第二个选项,按下回车即可。 + +![][4] + +#### 6) 语言选择 + +默认情况下,它选择 “33” 美国英语,按下回车即可。 + +![][5] + +#### 7) 模式选择(图形用户界面或命令行) + +默认情况下,它选择 “0” 图形用户界面模式,按下回车即可。 + +![][6] + +#### 8) 加载 GParted Live 屏幕 + +现在,GParted Live 屏幕已经加载,它显示我以前创建的分区列表。 + +![][7] + +#### 9) 如何重新调整根分区大小 + +选择你想重新调整大小的根分区,在这里仅有一个分区,所以我将编辑这个分区以便于安装另一个操作系统。 + +![][8] + +为做到这一点,按下 “Resize/Move” 按钮来重新调整分区大小。 + +![][9] + +现在,在第一个框中输入你想从这个分区中取出的大小。我将索要 “10GB”,所以,我添加 “10240MB”,并让该对话框的其余部分为默认值,然后点击 “Resize/Move” 按钮。 + +![][10] + +它将再次要求你确认重新调整分区的大小,因为你正在编辑活动的系统分区,然后点击 “Ok”。 + +![][11] + +分区从 30GB 缩小到 20GB 已经成功。也显示 10GB 未分配的磁盘空间。 + +![][12] + +最后点击 “Apply” 按钮来执行下面剩余的操作。 + +![][13] + +`e2fsck` 是一个文件系统检查实用程序,自动修复文件系统中与 HDD 相关的坏扇道、I/O 错误。 + +![][14] + +`resize2fs` 程序将重新调整 ext2、ext3 或 ext4 文件系统的大小。它可以被用于扩大或缩小一个位于设备上的未挂载的文件系统。 + +![][15] + +`e2image` 程序将保存位于设备上的关键的 ext2、ext3 或 ext4 文件系统的元数据到一个指定文件中。 + +![][16] + +所有的操作完成,关闭对话框。 + +![][17] + +现在,我们可以看到未分配的 “10GB” 磁盘分区。 + +![][18] + +重启系统来检查这一结果。 + +![][19] + +#### 10) 检查剩余空间 + +重新登录系统,并使用 `fdisk` 命令来查看在分区中可用的空间。是的,我可以看到这个分区上未分配的 “10GB” 磁盘空间。 + +``` +$ sudo parted /dev/sda print free +[sudo] password for daygeek: +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 + 32.3kB 10.7GB 10.7GB Free Space + 1 10.7GB 32.2GB 21.5GB primary ext4 boot +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility/ + +作者:[Magesh Maruthamuthu][a] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) +选题:[lujun9972](https://github.com/lujun9972) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.2daygeek.com/author/magesh/ +[1]:https://gparted.org/ +[2]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-1.png +[4]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-2.png +[5]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-3.png +[6]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-4.png +[7]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-5.png +[8]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-6.png +[9]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-7.png +[10]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-8.png +[11]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-9.png +[12]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-10.png +[13]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-11.png +[14]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-12.png +[15]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-13.png +[16]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-14.png +[17]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-15.png +[18]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-16.png +[19]:https://www.2daygeek.com/wp-content/uploads/2014/08/how-to-resize-active-primary-root-partition-in-linux-using-gparted-utility-17.png diff --git a/published/201906/20180604 BootISO - A Simple Bash Script To Securely Create A Bootable USB Device From ISO File.md b/published/201906/20180604 BootISO - A Simple Bash Script To Securely Create A Bootable USB Device From ISO File.md new file mode 100644 index 0000000000..c16f90cfad --- /dev/null +++ b/published/201906/20180604 BootISO - A Simple Bash Script To Securely Create A Bootable USB Device From ISO File.md @@ -0,0 +1,172 @@ +BootISO:从 ISO 文件中创建一个可启动的 USB 设备 +====== + +![](https://img.linux.net.cn/data/attachment/album/201906/16/110109qq0b7atyaped3ij2.jpg) + +为了安装操作系统,我们中的大多数人(包括我)经常从 ISO 文件中创建一个可启动的 USB 设备。为达到这个目的,在 Linux 中有很多自由可用的应用程序。甚至在过去我们写了几篇介绍这种实用程序的文章。 + +每个人使用不同的应用程序,每个应用程序有它们自己的特色和功能。在这些应用程序中,一些应用程序属于 CLI 程序,一些应用程序则是 GUI 的。 + +今天,我们将讨论名为 BootISO 的实用程序类似工具。它是一个简单的 bash 脚本,允许用户来从 ISO 文件中创建一个可启动的 USB 设备。 + +很多 Linux 管理员使用 `dd` 命令开创建可启动的 ISO ,它是一个著名的原生方法,但是与此同时,它也是一个非常危险的命令。因此,小心,当你用 `dd` 命令执行一些动作时。 + +建议阅读: + +- [Etcher:从一个 ISO 镜像中创建一个可启动的 USB 驱动器 & SD 卡的简单方法][1] +- [在 Linux 上使用 dd 命令来从一个 ISO 镜像中创建一个可启动的 USB 驱动器][2] + +### BootISO 是什么 + +[BootISO][3] 是一个简单的 bash 脚本,允许用户来安全的从一个 ISO 文件中创建一个可启动的 USB 设备,它是用 bash 编写的。 + +它不提供任何图形用户界面而是提供了大量的选项,可以让初学者顺利地在 Linux 上来创建一个可启动的 USB 设备。因为它是一个智能工具,能自动地选择连接到系统上的 USB 设备。 + +当系统有多个 USB 设备连接,它将打印出列表。当你手动选择了另一个硬盘而不是 USB 时,在这种情况下,它将安全地退出,而不会在硬盘上写入任何东西。 + +这个脚本也将检查依赖关系,并提示用户安装,它可以与所有的软件包管理器一起工作,例如 apt-get、yum、dnf、pacman 和 zypper。 + +### BootISO 的功能 + + * 它检查选择的 ISO 是否是正确的 mime 类型。如果不是,那么退出。 + * 如果你选择除 USB 设备以外的任何其它的磁盘(本地硬盘),BootISO 将自动地退出。 + * 当你有多个驱动器时,BootISO 允许用户选择想要使用的 USB 驱动器。 + * 在擦除和分区 USB 设备前,BootISO 会提示用户确认。 + * BootISO 将正确地处理来自一个命令的任何错误,并退出。 + * BootISO 在遇到问题退出时将调用一个清理例行程序。 + +### 如何在 Linux 中安装 BootISO + +在 Linux 中安装 BootISO 有几个可用的方法,但是,我建议用户使用下面的方法安装。 + +``` +$ curl -L https://git.io/bootiso -O +$ chmod +x bootiso +$ sudo mv bootiso /usr/local/bin/ +``` + +一旦 BootISO 已经安装,运行下面的命令来列出可用的 USB 设备。 + +``` +$ bootiso -l + +Listing USB drives available in your system: +NAME HOTPLUG SIZE STATE TYPE +sdd 1 32G running disk +``` + +如果你仅有一个 USB 设备,那么简单地运行下面的命令来从一个 ISO 文件中创建一个可启动的 USB 设备。 + +``` +$ bootiso /path/to/iso file +``` + +``` +$ bootiso /opt/iso_images/archlinux-2018.05.01-x86_64.iso +Granting root privileges for bootiso. +Listing USB drives available in your system: +NAME HOTPLUG SIZE STATE TYPE +sdd 1 32G running disk +Autoselecting `sdd' (only USB device candidate) +The selected device `/dev/sdd' is connected through USB. +Created ISO mount point at `/tmp/iso.vXo' +`bootiso' is about to wipe out the content of device `/dev/sdd'. +Are you sure you want to proceed? (y/n)>y +Erasing contents of /dev/sdd... +Creating FAT32 partition on `/dev/sdd1'... +Created USB device mount point at `/tmp/usb.0j5' +Copying files from ISO to USB device with `rsync' +Synchronizing writes on device `/dev/sdd' +`bootiso' took 250 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 ! +``` + +当你有多个 USB 设备时,可以使用 `--device` 选项指明你的设备名称。 + +``` +$ bootiso -d /dev/sde /opt/iso_images/archlinux-2018.05.01-x86_64.iso +``` + +默认情况下,BootISO 使用 `rsync` 命令来执行所有的动作,如果你想使用 `dd` 命令代替它,使用下面的格式。 + +``` +$ bootiso --dd -d /dev/sde /opt/iso_images/archlinux-2018.05.01-x86_64.iso +``` + +如果你想跳过 mime 类型检查,BootISO 实用程序带有下面的选项。 + +``` +$ bootiso --no-mime-check -d /dev/sde /opt/iso_images/archlinux-2018.05.01-x86_64.iso +``` + +为 BootISO 添加下面的选项来跳过在擦除和分区 USB 设备前的用户确认。 + +``` +$ bootiso -y -d /dev/sde /opt/iso_images/archlinux-2018.05.01-x86_64.iso +``` + +连同 `-y` 选项一起,启用自动选择 USB 设备。 + +``` +$ bootiso -y -a /opt/iso_images/archlinux-2018.05.01-x86_64.iso +``` + +为知道更多的 BootISO 选项,运行下面的命令。 + +``` +$ bootiso -h +Create a bootable USB from any ISO securely. +Usage: bootiso [...] + +Options + +-h, --help, help Display this help message and exit. +-v, --version Display version and exit. +-d, --device Select block file as USB device. + If is not connected through USB, `bootiso' will fail and exit. + Device block files are usually situated in /dev/sXX or /dev/hXX. + You will be prompted to select a device if you don't use this option. +-b, --bootloader Install a bootloader with syslinux (safe mode) for non-hybrid ISOs. Does not work with `--dd' option. +-y, --assume-yes `bootiso' won't prompt the user for confirmation before erasing and partitioning USB device. + Use at your own risks. +-a, --autoselect Enable autoselecting USB devices in conjunction with -y option. + Autoselect will automatically select a USB drive device if there is exactly one connected to the system. + Enabled by default when neither -d nor --no-usb-check options are given. +-J, --no-eject Do not eject device after unmounting. +-l, --list-usb-drives List available USB drives. +-M, --no-mime-check `bootiso' won't assert that selected ISO file has the right mime-type. +-s, --strict-mime-check Disallow loose application/octet-stream mime type in ISO file. +-- POSIX end of options. +--dd Use `dd' utility instead of mounting + `rsync'. + Does not allow bootloader installation with syslinux. +--no-usb-check `bootiso' won't assert that selected device is a USB (connected through USB bus). + Use at your own risks. + +Readme + + Bootiso v2.5.2. + Author: Jules Samuel Randolph + Bugs and new features: https://github.com/jsamr/bootiso/issues + If you like bootiso, please help the community by making it visible: + * star the project at https://github.com/jsamr/bootiso + * upvote those SE post: https://goo.gl/BNRmvm https://goo.gl/YDBvFe +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/bootiso-a-simple-bash-script-to-securely-create-a-bootable-usb-device-in-linux-from-iso-file/ + +作者:[Prakash Subramanian][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.2daygeek.com/author/prakash/ +[1]:https://www.2daygeek.com/etcher-easy-way-to-create-a-bootable-usb-drive-sd-card-from-an-iso-image-on-linux/ +[2]:https://www.2daygeek.com/create-a-bootable-usb-drive-from-an-iso-image-using-dd-command-on-linux/ +[3]:https://github.com/jsamr/bootiso diff --git a/sources/tech/20180831 Get desktop notifications from Emacs shell commands .md b/published/201906/20180831 Get desktop notifications from Emacs shell commands .md similarity index 62% rename from sources/tech/20180831 Get desktop notifications from Emacs shell commands .md rename to published/201906/20180831 Get desktop notifications from Emacs shell commands .md index 7d04e6d0a7..773e650420 100644 --- a/sources/tech/20180831 Get desktop notifications from Emacs shell commands .md +++ b/published/201906/20180831 Get desktop notifications from Emacs shell commands .md @@ -1,21 +1,22 @@ [#]: collector: (lujun9972) [#]: translator: (lujun9972) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10977-1.html) [#]: subject: (Get desktop notifications from Emacs shell commands ·) [#]: via: (https://blog.hoetzel.info/post/eshell-notifications/) [#]: author: (Jürgen Hötzel https://blog.hoetzel.info) -Get desktop notifications from Emacs shell commands · +让 Emacs shell 命令发送桌面通知 ====== -When interacting with the operating systems I always use [Eshell][1] because it integrates seamlessly with Emacs, supports (remote) [TRAMP][2] file names and also works nice on Windows. -After starting shell commands (like long running build jobs) I often lose track the task when switching buffers. +我总是使用 [Eshell][1] 来与操作系统进行交互,因为它与 Emacs 无缝整合、支持处理 (远程) [TRAMP][2] 文件,而且在 Windows 上也能工作得很好。 -Thanks to Emacs [hooks][3] mechanism you can customize Emacs to call a elisp function when an external command finishes. +启动 shell 命令后 (比如耗时严重的构建任务) 我经常会由于切换缓冲区而忘了追踪任务的运行状态。 -I use [John Wiegleys][4] excellent [alert][5] package to send desktop notifications: +多亏了 Emacs 的 [钩子][3] 机制,你可以配置 Emacs 在某个外部命令完成后调用一个 elisp 函数。 + +我使用 [John Wiegleys][4] 所编写的超棒的 [alert][5] 包来发送桌面通知: ``` (require 'alert) @@ -32,7 +33,7 @@ I use [John Wiegleys][4] excellent [alert][5] package to send desktop notificati (add-hook 'eshell-kill-hook #'eshell-command-alert) ``` -[alert][5] rules can be setup programmatically. In my case I only want to get notified if the corresponding buffer is not visible: +[alert][5] 的规则可以用程序来设置。就我这个情况来看,我只需要当对应的缓冲区不可见时得到通知: ``` (alert-add-rule :status '(buried) ;only send alert when buffer not visible @@ -40,7 +41,8 @@ I use [John Wiegleys][4] excellent [alert][5] package to send desktop notificati :style 'notifications) ``` -This even works on [TRAMP][2] buffers. Below is a screenshot showing a Gnome desktop notification of a failed `make` command. + +这甚至对于 [TRAMP][2] 也一样生效。下面这个截屏展示了失败的 `make` 命令产生的 Gnome 桌面通知。 ![../../img/eshell.png][6] @@ -51,7 +53,7 @@ via: https://blog.hoetzel.info/post/eshell-notifications/ 作者:[Jürgen Hötzel][a] 选题:[lujun9972][b] 译者:[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/) 荣誉推出 @@ -62,4 +64,4 @@ via: https://blog.hoetzel.info/post/eshell-notifications/ [3]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Hooks.html (hooks) [4]: https://github.com/jwiegley (John Wiegleys) [5]: https://github.com/jwiegley/alert (alert) -[6]: https://blog.hoetzel.info/img/eshell.png (../../img/eshell.png) +[6]: https://blog.hoetzel.info/img/eshell.png diff --git a/published/201906/20180914 A day in the life of a log message.md b/published/201906/20180914 A day in the life of a log message.md new file mode 100644 index 0000000000..3c86e1e815 --- /dev/null +++ b/published/201906/20180914 A day in the life of a log message.md @@ -0,0 +1,56 @@ +一条日志消息的现代生活 +====== + +> 从一条日志消息的角度来巡览现代分布式系统。 + +![](https://img.linux.net.cn/data/attachment/album/201906/18/193030frxkcoccjhorz42o.jpg) + +混沌系统往往是不可预测的。在构建像分布式系统这样复杂的东西时,这一点尤其明显。如果不加以控制,这种不可预测性会无止境的浪费时间。因此,分布式系统的每个组件,无论多小,都必须设计成以简化的方式组合在一起。 + +[Kubernetes][1] 为抽象计算资源提供了一个很有前景的模型 —— 但即使是它也必须与其他分布式平台(如 [Apache Kafka][2])协调一致,以确保可靠的数据传输。如果有人要整合这两个平台,它会如何运作?此外,如果你通过这样的系统跟踪像日志消息这么简单的东西,它会是什么样子?本文将重点介绍来自在 [OKD][3] 内运行的应用程序的日志消息如何通过 Kafka 进入数据仓库(OKD 是为 Red Hat OpenShift 提供支持的 Kubernetes 的原初社区发行版)。 + +### OKD 定义的环境 + +这样的旅程始于 OKD,因为该容器平台完全覆盖了它抽象的硬件。这意味着日志消息等待由驻留在容器中的应用程序写入 stdout 或 stderr 流。从那里,日志消息被容器引擎(例如 [CRI-O][4])重定向到节点的文件系统。 + +![](https://opensource.com/sites/default/files/uploads/logmessagepathway.png) + +在 OpenShift 中,一个或多个容器封装在称为 pod(豆荚)的虚拟计算节点中。实际上,在 OKD 中运行的所有应用程序都被抽象为 pod。这允许应用程序以统一的方式操纵。这也大大简化了分布式组件之间的通信,因为 pod 可以通过 IP 地址和[负载均衡服务][5]进行系统寻址。因此,当日志消息由日志收集器应用程序从节点的文件系统获取时,它可以很容易地传递到在 OpenShift 中运行的另一个 pod 中。 + +### 在豆荚里的两个豌豆 + +为了确保可以在整个分布式系统中四处传播日志消息,日志收集器需要将日志消息传递到在 OpenShift 中运行的 Kafka 集群数据中心。通过 Kafka,日志消息可以以可靠且容错的方式低延迟传递给消费应用程序。但是,为了在 OKD 定义的环境中获得 Kafka 的好处,Kafka 需要完全集成到 OKD 中。 + +运行 [Strimzi 操作子][6]将所有 Kafka 组件实例化为 pod,并将它们集成在 OKD 环境中运行。 这包括用于排队日志消息的 Kafka 代理,用于从 Kafka 代理读取和写入的 Kafka 连接器,以及用于管理 Kafka 集群状态的 Zookeeper 节点。Strimzi 还可以将日志收集器实例化兼做 Kafka 连接器,允许日志收集器将日志消息直接提供给在 OKD 中运行的 Kafka 代理 pod。 + +### 在 OKD 内的 Kafka + +当日志收集器 pod 将日志消息传递给 Kafka 代理时,收集器会写到单个代理分区,并将日志消息附加到该分区的末尾。使用 Kafka 的一个优点是它将日志收集器与日志的最终目标分离。由于解耦,日志收集器不关心日志最后是放在 [Elasticsearch][7]、Hadoop、Amazon S3 中的某个还是全都。Kafka 与所有基础设施连接良好,因此 Kafka 连接器可以在任何需要的地方获取日志消息。 + +一旦写入 Kafka 代理的分区,该日志消息就会在 Kafka 集群内的跨代理分区复制。这是它的一个非常强大的概念;结合平台的自愈功能,它创建了一个非常有弹性的分布式系统。例如,当节点变得不可用时,(故障)节点上运行的应用程序几乎立即在健康节点上生成。因此,即使带有 Kafka 代理的节点丢失或损坏,日志消息也能保证存活在尽可能多的节点上,并且新的 Kafka 代理将快速原位取代。 + +### 存储起来 + +在日志消息被提交到 Kafka 主题后,它将等待 Kafka 连接器使用它,该连接器将日志消息中继到分析引擎或日志记录仓库。在传递到其最终目的地时,可以分析日志消息以进行异常检测,也可以查询日志以立即进行根本原因分析,或用于其他目的。无论哪种方式,日志消息都由 Kafka 以安全可靠的方式传送到目的地。 + +OKD 和 Kafka 是正在迅速发展的功能强大的分布式平台。创建能够在不影响性能的情况下抽象出分布式计算的复杂特性的系统至关重要。毕竟,如果我们不能简化单一日志消息的旅程,我们怎么能夸耀全系统的效率呢? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/life-log-message + +作者:[Josef Karásek][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jkarasek +[1]: https://kubernetes.io/ +[2]: https://kafka.apache.org/ +[3]: https://www.okd.io/ +[4]: http://cri-o.io/ +[5]: https://kubernetes.io/docs/concepts/services-networking/service/ +[6]: http://strimzi.io/ +[7]: https://www.elastic.co/ diff --git a/published/201906/20190109 GoAccess - A Real-Time Web Server Log Analyzer And Interactive Viewer.md b/published/201906/20190109 GoAccess - A Real-Time Web Server Log Analyzer And Interactive Viewer.md new file mode 100644 index 0000000000..48d7ca0474 --- /dev/null +++ b/published/201906/20190109 GoAccess - A Real-Time Web Server Log Analyzer And Interactive Viewer.md @@ -0,0 +1,178 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10969-1.html) +[#]: subject: (GoAccess – A Real-Time Web Server Log Analyzer And Interactive Viewer) +[#]: via: (https://www.2daygeek.com/goaccess-a-real-time-web-server-log-analyzer-and-interactive-viewer/) +[#]: author: (Vinoth Kumar https://www.2daygeek.com/author/vinoth/) + +GoAccess:一个实时的 Web 日志分析器及交互式查看器 +====== + +![](https://img.linux.net.cn/data/attachment/album/201906/12/222616h80pl0k0tt811071.jpg) + +分析日志文件对于 Linux 管理员来说是一件非常令人头疼的事情,因为它记录了很多东西。大多数新手和初级管理员都不知道如何分析。如果你在分析日志方面拥有很多知识,那么你就成了 *NIX 系统高手。 + +Linux 中有许多工具可以轻松分析日志。GoAccess 是允许用户轻松分析 Web 服务器日志的工具之一。我们将在本文中详细讨论 GoAccess 工具。 + +### GoAccess + +GoAccess 是一个实时 Web 日志分析器和交互式查看器,可以在 *nix 系统中的终端运行或通过浏览器访问。 + +GoAccess 需要的依赖极少,它是用 C 语言编写的,只需要 ncurses。 + +它支持 Apache、Nginx 和 Lighttpd 日志。它为需要动态可视化服务器报告的系统管理员即时提供了快速且有价值的 HTTP 统计信息。 + +GoAccess 可以解析指定的 Web 日志文件并将数据输出到 X 终端和浏览器。 + +GoAccess 被设计成一个基于终端的快速日志分析器。其核心思想是实时快速分析和查看 Web 服务器统计信息,而无需使用浏览器。 + +默认输出是在终端输出,它也能够生成完整的、自包含的实时 HTML 报告,以及 JSON 和 CSV 报告。 + +GoAccess 支持任何自定义日志格式,并包含以下预定义日志格式选项:Apache/Nginx 中的组合日志格式 XLF/ELF,Apache 中的通用日志格式 CLF,但不限于此。 + +### GoAccess 功能 + +* 完全实时:所有指标在终端上每 200 毫秒更新一次,在 HTML 输出上每秒更新一次。 +* 跟踪应用程序响应时间:跟踪服务请求所需的时间。如果你想跟踪减慢了网站速度的网页,则非常有用。 +* 访问者:按小时或日期确定最慢运行的请求的点击量、访问者数、带宽数和指标。 +* 按虚拟主机的度量标准:如果有多个虚拟主机(`Server`),它提供了一个面板,可显示哪些虚拟主机正在消耗大部分 Web 服务器资源。 + +### 如何安装 GoAccess? + +我建议用户在包管理器的帮助下从发行版官方的存储库安装 GoAccess。它在大多数发行版官方存储库中都可用。 + +我们知道,我们在标准发行方式的发行版中得到的是过时的软件包,而滚动发行方式的发行版总是包含最新的软件包。 + +如果你使用标准发行方式的发行版运行操作系统,我建议你检查替代选项,如 PPA 或 GoAccess 官方维护者存储库等,以获取最新的软件包。 + +对于 Debian / Ubuntu 系统,使用 [APT-GET 命令][1]或 [APT 命令][2]在你的系统上安装 GoAccess。 + +``` +# apt install goaccess +``` + +要获取最新的 GoAccess 包,请使用以下 GoAccess 官方存储库。 + +``` +$ echo "deb https://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list +$ wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key add - +$ sudo apt-get update +$ sudo apt-get install goaccess +``` + +对于 RHEL / CentOS 系统,使用 [YUM 包管理器][3]在你的系统上安装 GoAccess。 + +``` +# yum install goaccess +``` + +对于 Fedora 系统,使用 [DNF 包管理器][4]在你的系统上安装 GoAccess。 + +``` +# dnf install goaccess +``` + +对于基于 ArchLinux / Manjaro 的系统,使用 [Pacman 包管理器][5]在你的系统上安装 GoAccess。 + +``` +# pacman -S goaccess +``` + +对于 openSUSE Leap 系统,使用[Zypper 包管理器][6]在你的系统上安装 GoAccess。 + +``` +# zypper install goaccess +# zypper ar -f obs://server:http +# zypper ref && zypper in goaccess +``` + +### 如何使用 GoAccess? + +成功安装 GoAccess 后。只需输入 `goaccess` 命令,然后输入 Web 服务器日志位置即可查看。 + +``` +# goaccess [options] /path/to/Web Server/access.log +# goaccess /var/log/apache/2daygeek_access.log +``` + +执行上述命令时,它会要求您选择日志格式配置。 + +![][8] + +我用 Apache 访问日志对此进行了测试。Apache 日志被分为十五个部分。详情如下。主要部分显示了这十五个部分的摘要。 + +以下屏幕截图包括四个部分,例如唯一身份访问者、请求的文件、静态请求、未找到的网址。 + +![][10] + +以下屏幕截图包括四个部分,例如访客主机名和 IP、操作系统、浏览器、时间分布。 + +![][10] + +以下屏幕截图包括四个部分,例如来源网址、来源网站,Google 的搜索引擎结果、HTTP状态代码。 + +![][11] + +如果要生成 html 报告,请使用以下命令。最初我在尝试生成 html 报告时遇到错误。 + +``` +# goaccess 2daygeek_access.log -a > report.html + +GoAccess - version 1.3 - Nov 23 2018 11:28:19 +Config file: No config file used + +Fatal error has occurred +Error occurred at: src/parser.c - parse_log - 2764 +No time format was found on your conf file.Parsing... [0] [0/s] +``` + +它说“你的 conf 文件没有找到时间格式”。要解决此问题,请为其添加 “COMBINED” 日志格式选项。 + +``` +# goaccess -f 2daygeek_access.log --log-format=COMBINED -o 2daygeek.html +Parsing...[0,165] [50,165/s] +``` + +![][12] + +GoAccess 也允许你访问和分析实时日志并进行过滤和解析。 + +``` +# tail -f /var/log/apache/2daygeek_access.log | goaccess - +``` + +更多细节请参考其 man 手册页或帮助。 + +``` +# man goaccess +或 +# goaccess --help +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/goaccess-a-real-time-web-server-log-analyzer-and-interactive-viewer/ + +作者:[Vinoth Kumar][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/vinoth/ +[b]: https://github.com/lujun9972 +[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/ +[7]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[8]: https://www.2daygeek.com/wp-content/uploads/2019/01/goaccess-a-real-time-web-server-log-analyzer-and-interactive-viewer-1.png +[9]: https://www.2daygeek.com/wp-content/uploads/2019/01/goaccess-a-real-time-web-server-log-analyzer-and-interactive-viewer-2.png +[10]: https://www.2daygeek.com/wp-content/uploads/2019/01/goaccess-a-real-time-web-server-log-analyzer-and-interactive-viewer-3.png +[11]: https://www.2daygeek.com/wp-content/uploads/2019/01/goaccess-a-real-time-web-server-log-analyzer-and-interactive-viewer-4.png +[12]: https://www.2daygeek.com/wp-content/uploads/2019/01/goaccess-a-real-time-web-server-log-analyzer-and-interactive-viewer-5.png diff --git a/published/201906/20190111 Top 5 Linux Distributions for Productivity.md b/published/201906/20190111 Top 5 Linux Distributions for Productivity.md new file mode 100644 index 0000000000..57a17925cd --- /dev/null +++ b/published/201906/20190111 Top 5 Linux Distributions for Productivity.md @@ -0,0 +1,140 @@ +[#]: collector: "lujun9972" +[#]: translator: "qfzy1233" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11028-1.html" +[#]: subject: "Top 5 Linux Distributions for Productivity" +[#]: via: "https://www.linux.com/blog/learn/2019/1/top-5-linux-distributions-productivity" +[#]: author: "Jack Wallen https://www.linux.com/users/jlwallen" + +5 个最具生产力的 Linux 发行版 +====== + +> 如果你正在寻找一个适合开发工作的完美环境,我敢说你找不到比 Pop!_OS 更好的选择。 + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/productivity_main.jpg?itok=2IKyg_7_) + +必须承认的是,这样的一个热门话题其实很难被总结的话题。为什么呢?首先,Linux 在就是一种有生产力的操作系统。由于它极强的可靠性和稳定的平台,使得完成工作变得很容易。其次为了衡量工作的效率,你需要考虑到哪项工作需要得到生产力方面的助推。是日常办公?开发类工作?学校事务?数据挖掘?或者是人力资源?你可以看到这个问题有多复杂。 + +然而,这并不意味着某些发行版无法更好地配置将底层操作系统呈现为一个有效的平台来完成工作。恰恰相反,许多发行版在偏离生产力这条道路上越走越远,所以你不会意识到你自己处在工作的窘境中,而是继续挖掘自己的潜力在工期结束之前拼命赶上进度。这些 Linux 发行版可以帮助你化繁为简,因此或许可以减少你工作流程中的痛点。 + +让我们来看一下这些发行版并为你找出适合你的最佳选择。为了更具条理,我按照生产力诉求把它们分成了几类。这项任务本身也是一种挑战,因为每个人在生产力提升上的需要是千差万别的。然而,我所关注的是下列的几项: + + * 常规:适于那些只需要有效地完成多项工作的人。 + * 设计:适于那些从事设计创造和图像处理的人。 + * 开发:适于那些使用 Linux 桌面发行版来进行编程工作的人。 + * 运维:适于那些需要一个发行版来促进其执行系统管理任务的人。 + * 教育:适于那些需要桌面发行版可以助力他们在教育领域更高效的人。 + +诚然,有很多很多类别的发行版可供挑选,其中的很多可能用起来十分得心应手,但这五种或许是你最为需要的。 + +### 常规 + +对于常规的生产力诉求来说,你不会找到比 [Ubuntu][1] 更为高效的了。在这个类别中首推 Ubuntu 最主要的原因是因为它实现了桌面操作系统、软件、服务的无缝集成。你可能会问为什么我不选择同类别的 Linux Mint 呢?因为 Ubuntu 现在默认的的桌面环境为 GNOME 桌面,而它拥有 GNOME 许多扩展程序的优势的加成(图 1)。 + +![GNOME Clipboard][3] + +*图 1:运行中的 GNOME 桌面的剪切板管理工具。* + +这些扩展程序在提升生产力方面做了很多努力(所以 Ubuntu 比 Linux Mint 获得了更多的认可)。但是 Ubuntu 不仅仅是装了一个普通的 GNOME 桌面。事实上,他们致力于将它改进的更为轻量化、更为高效、以及用户友好度更高、开箱即用。总而言之,由于 Ubuntu 正确的融合了多种特性,开箱即用,完善的软件支持(仅对工作方面而言),这些特性使它几乎成为了生产力领域最为完美的一个平台。 + +不管你是要写一篇文档,制作一张电子表格,写一个新的软件,开发公司的网站,设计商用的图形,管理一个服务器或是网络,抑或是在你的公司内从事人力资源管理工作,Ubuntu 都可以满足你的需求。Ubuntu 桌面发行版也并不要求你耗费很大的精力才能开始开始开展工作……它直接就能使用(并且工作的十分优秀)。最后,得益于它是基于 Debian 的,使得在 Ubuntu 上安装第三方的软件十分简便。 + +很难不支持这一发行版独占生产力发行版列表的鳌头,尽管 Ubuntu 几乎已经成为几乎所有“某某类顶级发行版”列表的榜首。 + +### 设计 + +如果你正在寻求提升你的平面设计效率,你不能错过 [Fedora 设计套件][5]。这一 Fedora 衍生版是由负责 Fedora 相关的艺术作品的团队亲自操刀制作的。虽然其默认选择的应用程序并不是一个庞大的工具集合,但它所包含的工具都是创建和处理图像专用的。 + +有了 GIMP、Inkscape、Darktable、Krita、Entangle、Blender、Pitivi、Scribus 等应用程序(图 2),你可以找到完成图像编辑工作所需要的一切。但是 Fedora 设计套件并不仅限于此。这个桌面平台还包括一堆教程,涵盖了许多已安装的应用程序。对于任何想要尽可能提高效率的人来说,这将是一些非常有用的信息。不过,我要说的是,GNOME 收藏夹中的教程并没有超乎[此页中][6]链接的内容。 + +![Fedora Design Suite Favorites][8] + +*图 2:Fedora 设计套件收藏夹菜单包含了许多工具,可以让你用于图形设计。* + +那些使用数码相机的用户肯定会喜欢 Entangle 应用程序,它可以让你在电脑上控制单反相机。 + +### 开发 + +几乎所有的 Linux 发行版都是程序员的绝佳平台。然而,有一种特定的发行版脱颖而出,并超越了其他发行版,它将是你见过的用于编程类最有效率的工具之一。这个操作系统来自 [System76][9](LCTT 译注:一家美国的计算机制造商),名为 [Pop!\_OS][10]。Pop!\_OS 是专门为创作者定制的,但不是针对艺术类。相反,Pop!\_OS 面向专门从事开发、编程和软件制作的程序员。如果你需要一个既能完美的胜任开发工作又包含符合使用习惯的桌面操作系统的开发环境,Pop!\_OS 将会是你的不二选择。(图 3) + +可能会让你感到惊讶(考虑到这个操作系统是多么“年轻”)的是 Pop!\_OS 也是你将使用的基于 GNOME 平台的最稳定系统的之一。这意味着 Pop!\_OS 不只是为创作者和创客准备的,也是为任何想要一个可靠的操作系统的人准备的。你可以下载针对你的硬件的专门 ISO 文件,这一点是许多用户十分欣赏的。如果你有英特尔硬件,[下载][10] Intel 或 AMD 的版本。如果你的显卡是 NVIDIA,请下载该特定版本。不管怎样,你肯定会得到针对不同平台进行特殊定制的稳定版本。 + +![Pop!_OS][12] + +*图 3:装有 GNOME 桌面的 Pop!_OS 一览。* + +有趣的是,在 Pop!\_OS 中,你不会找到太多预装的开发工具。你也不会找到 IDE 或许多其他开发工具。但是,你可以在 Pop 商店中中找到所需的所有开发工具。 + +### 运维 + +如果你正在寻找适合系统管理的最具生产力的发行版,[Debian][13] 将会是你的不二之选。为什么这么说呢?因为 Debian 不仅仅拥有无与伦比的可靠性,它也是众多能从苦海中将你解救出来的最好的一个发行版。Debian 是易用性和无限可能性的完美结合。最重要的是,因为它是许多其他发行版的基础,所以可以打赌,如果你需要一个任务的管理工具,那么它一定支持 Debian 系统。当然,我们讨论的是一般的系统管理任务,这意味着大多数时候你需要使用终端窗口 SSH 连接到服务器(图 4),或者在浏览器上使用网络上基于 web 的 GUI 工具。既然如此为什么还要使用一个增加复杂性的桌面呢(比如 Fedora 中的 SELinux 或 openSUSE 中的 YaST)呢?所以,应选择更为简洁易用的那一种。 + +![Debian][15] + +*图 4:在 Debian 系统上通过 SSH 连接到远程服务器。* + +你可以选择你想要的不同的桌面(包括 GNOME、Xfce、KDE、Cinnamon、MATE、LXDE),可以确保你所使用的桌面外观最适合你的工作习惯。 + +### 教育 + +如果你是一名老师或学生,抑或是其他从事与教育相关工作的人士,你需要适当的工具来提高生产力。之前,有 Edubuntu 这样的版本。这一版本位列教育类相关发行版排名的前列。然而,自从 Ubuntu 14.04 版之后这一发行版就再也没有更新。还好,现在有一款基于 openSUSE 的新的以教育为基础的发行版有望夺摘得桂冠。这一改版叫做 [openSUSE:Education-Li-f-e][16](Li-f-e:Linux For Education - 图 5),它基于 openSUSE Leap 42.1 (所以它可能稍微有一点过时)。 + +openSUSE:Education-Li-f-e 包含了以下工具: + + * Brain Workshop(大脑工坊):一种基于 dual n-back 模式的大脑训练软件(LCTT 译注:dual n-back 训练是一种科学的智力训练方法,可以改善人的工作记忆和流体智力) + * GCompris:一种针对青少年的教育软件包 + * gElemental:一款元素周期表查看工具 + * iGNUit:一款通用的记忆卡片工具 + * Little Wizard:基于 Pascal 语言的少儿编程开发环境 + * Stellarium:天文模拟器 + * TuxMath:数学入门游戏 + * TuxPaint:一款少儿绘画软件 + * TuxType:一款为少儿准备的打字入门软件 + * wxMaxima:一个跨平台的计算机代数系统 + * Inkscape:矢量图形编辑软件 + * GIMP:图像处理软件(LCTT 译注:被誉为 Linux 上的 PhotoShop) + * Pencil:GUI 模型制作工具 + * Hugin:全景照片拼接及 HDR 效果混合软件 + + +![Education][18] + +*图 5:openSUSE:Education-Li-f-e 发行版拥有大量的工具可以帮你在学校中变得更为高效。* + +同时还集成在 openSUSE:Education-Li-f-e 中的还有 [KIWI-LTSP Server][19] 。KIWI-LTSP 服务器是一个灵活的、经济高效的解决方案,旨在使全世界的学校、企业和组织能够轻松地安装和部署桌面工作站。虽然这可能不会直接帮助学生变得更具生产力,但它肯定会使教育机构在部署供学生使用的桌面时更有效率。有关配置 KIWI-LTSP 的更多信息,请查看 openSUSE [KIWI-LTSP 快速入门指南][20]。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2019/1/top-5-linux-distributions-productivity + +作者:[Jack Wallen][a] +选题:[lujun9972][b] +译者:[qfzy1233](https://github.com/qfzy1233) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/jlwallen +[b]: https://github.com/lujun9972 +[1]: https://www.ubuntu.com/ +[2]: /files/images/productivity1jpg +[3]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/productivity_1.jpg?itok=yxez3X1w "GNOME Clipboard" +[4]: /licenses/category/used-permission +[5]: https://labs.fedoraproject.org/en/design-suite/ +[6]: https://fedoraproject.org/wiki/Design_Suite/Tutorials +[7]: /files/images/productivity2jpg +[8]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/productivity_2.jpg?itok=ke0b8qyH "Fedora Design Suite Favorites" +[9]: https://system76.com/ +[10]: https://system76.com/pop +[11]: /files/images/productivity3jpg-0 +[12]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/productivity_3_0.jpg?itok=8UkCUfsD "Pop!_OS" +[13]: https://www.debian.org/ +[14]: /files/images/productivity4jpg +[15]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/productivity_4.jpg?itok=c9yD3Xw2 "Debian" +[16]: https://en.opensuse.org/openSUSE:Education-Li-f-e +[17]: /files/images/productivity5jpg +[18]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/productivity_5.jpg?itok=oAFtV8nT "Education" +[19]: https://en.opensuse.org/Portal:KIWI-LTSP +[20]: https://en.opensuse.org/SDB:KIWI-LTSP_quick_start +[21]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/published/201906/20190219 5 Good Open Source Speech Recognition-Speech-to-Text Systems.md b/published/201906/20190219 5 Good Open Source Speech Recognition-Speech-to-Text Systems.md new file mode 100644 index 0000000000..07d273c666 --- /dev/null +++ b/published/201906/20190219 5 Good Open Source Speech Recognition-Speech-to-Text Systems.md @@ -0,0 +1,126 @@ +[#]: collector: (lujun9972) +[#]: translator: (luuming) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11004-1.html) +[#]: subject: (5 Good Open Source Speech Recognition/Speech-to-Text Systems) +[#]: via: (https://fosspost.org/lists/open-source-speech-recognition-speech-to-text) +[#]: author: (Simon James https://fosspost.org/author/simonjames) + +5 款不错的开源语音识别/语音文字转换系统 +====== + +![](https://i0.wp.com/fosspost.org/wp-content/uploads/2019/02/open-source-speech-recognition-speech-to-text.png?resize=1237%2C527&ssl=1) + +语音文字转换speech-to-text(STT)系统就像它名字所蕴含的意思那样,是一种将说出的单词转换为文本文件以供后续用途的方式。 + +语音文字转换技术非常有用。它可以用到许多应用中,例如自动转录,使用自己的声音写书籍或文本,用生成的文本文件和其他工具做复杂的分析等。 + +在过去,语音文字转换技术以专有软件和库为主导,要么没有开源替代品,要么有着严格的限制,也没有社区。这一点正在发生改变,当今有许多开源语音文字转换工具和库可以让你随时使用。 + +这里我列出了 5 个。 + +### 开源语音识别库 + +#### DeepSpeech 项目 + +![5 Good Open Source Speech Recognition/Speech-to-Text Systems 15 open source speech recognition][1] + +该项目由 Firefox 浏览器的开发组织 Mozilla 团队开发。它是 100% 的自由开源软件,其名字暗示使用了 TensorFlow 机器学习框架实现去功能。 + +换句话说,你可以用它训练自己的模型获得更好的效果,甚至可以用它来转换其它的语言。你也可以轻松的将它集成到自己的 Tensorflow 机器学习项目中。可惜的是项目当前默认仅支持英语。 + +它也支持许多编程语言,例如 Python(3.6)。可以让你在数秒之内完成工作: + +``` +pip3 install deepspeech +deepspeech --model models/output_graph.pbmm --alphabet models/alphabet.txt --lm models/lm.binary --trie models/trie --audio my_audio_file.wav +``` + +你也可以通过 `npm` 安装它: + +``` +npm install deepspeech +``` + +- [项目主页][2] + +#### Kaldi + +![5 Good Open Source Speech Recognition/Speech-to-Text Systems 17 open source speech recognition][3] + +Kaldi 是一个用 C++ 编写的开源语音识别软件,并且在 Apache 公共许可证下发布。它可以运行在 Windows、macOS 和 Linux 上。它的开发始于 2009。 + +Kaldi 超过其他语音识别软件的主要特点是可扩展和模块化。社区提供了大量的可以用来完成你的任务的第三方模块。Kaldi 也支持深度神经网络,并且在它的网站上提供了[出色的文档][4]。 + +虽然代码主要由 C++ 完成,但它通过 Bash 和 Python 脚本进行了封装。因此,如果你仅仅想使用基本的语音到文字转换功能,你就会发现通过 Python 或 Bash 能够轻易的实现。 + +- [项目主页][5] + +#### Julius + +![5 Good Open Source Speech Recognition/Speech-to-Text Systems 19 open source speech recognition][6] + +它可能是有史以来最古老的语音识别软件之一。它的开发始于 1991 年的京都大学,之后在 2005 年将所有权转移到了一个独立的项目组。 + +Julius 的主要特点包括了执行实时 STT 的能力,低内存占用(20000 单词少于 64 MB),能够输出最优词N-best word词图Word-graph,能够作为服务器单元运行等等。这款软件主要为学术和研究所设计。由 C 语言写成,并且可以运行在 Linux、Windows、macOS 甚至 Android(在智能手机上)。 + +它当前仅支持英语和日语。软件应该能够从 Linux 发行版的仓库中轻松安装。只要在软件包管理器中搜索 julius 即可。最新的版本[发布][7]于本文发布前大约一个半月之前。 + +- [项目主页][8] + +#### Wav2Letter++ + +![5 Good Open Source Speech Recognition/Speech-to-Text Systems 21 open source speech recognition][9] + +如果你在寻找一个更加时髦的,那么这款一定适合。Wav2Letter++ 是一款由 Facebook 的 AI 研究团队于 2 个月之前发布的开源语言识别软件。代码在 BSD 许可证下发布。 + +Facebook 描述它的库是“最快、最先进state-of-the-art的语音识别系统”。构建它时的理念使其默认针对性能进行了优化。Facebook 最新的机器学习库 [FlashLight][11] 也被用作 Wav2Letter++ 的底层核心。 + +Wav2Letter++ 需要你先为所描述的语言建立一个模型来训练算法。没有任何一种语言(包括英语)的预训练模型,它仅仅是个机器学习驱动的文本语音转换工具,它用 C++ 写成,因此被命名为 Wav2Letter++。 + +- [项目主页][12] + +#### DeepSpeech2 + +![5 Good Open Source Speech Recognition/Speech-to-Text Systems 23 open source speech recognition][13] + +中国软件巨头百度的研究人员也在开发他们自己的语音文字转换引擎,叫做“DeepSpeech2”。它是一个端对端的开源引擎,使用“PaddlePaddle”深度学习框架进行英语或汉语的文字转换。代码在 BSD 许可证下发布。 + +该引擎可以在你想用的任何模型和任何语言上训练。模型并未随代码一同发布。你要像其他软件那样自己建立模型。DeepSpeech2 的源代码由 Python 写成,如果你使用过就会非常容易上手。 + +- [项目主页][14] + +### 总结 + +语音识别领域仍然主要由专有软件巨头所占据,比如 Google 和 IBM(它们为此提供了闭源商业服务),但是开源同类软件很有前途。这 5 款开源语音识别引擎应当能够帮助你构建应用,随着时间推移,它们会不断地发展。在几年之后,我们希望开源成为这些技术中的常态,就像其他行业那样。 + +如果你对清单有其他的建议或评论,我们很乐意在下面听到。 + +-------------------------------------------------------------------------------- + +via: https://fosspost.org/lists/open-source-speech-recognition-speech-to-text + +作者:[Simon James][a] +选题:[lujun9972][b] +译者:[LuuMing](https://github.com/LuuMing) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fosspost.org/author/simonjames +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/fosspost.org/wp-content/uploads/2019/02/hero_speech-machine-learning2.png?resize=820%2C280&ssl=1 (5 Good Open Source Speech Recognition/Speech-to-Text Systems 16 open source speech recognition) +[2]: https://github.com/mozilla/DeepSpeech +[3]: https://i0.wp.com/fosspost.org/wp-content/uploads/2019/02/Screenshot-at-2019-02-19-1134.png?resize=591%2C138&ssl=1 (5 Good Open Source Speech Recognition/Speech-to-Text Systems 18 open source speech recognition) +[4]: http://kaldi-asr.org/doc/index.html +[5]: http://kaldi-asr.org +[6]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/02/mic_web.png?resize=385%2C100&ssl=1 (5 Good Open Source Speech Recognition/Speech-to-Text Systems 20 open source speech recognition) +[7]: https://github.com/julius-speech/julius/releases +[8]: https://github.com/julius-speech/julius +[9]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/02/fully_convolutional_ASR.png?resize=850%2C177&ssl=1 (5 Good Open Source Speech Recognition/Speech-to-Text Systems 22 open source speech recognition) +[10]: https://code.fb.com/ai-research/wav2letter/ +[11]: https://github.com/facebookresearch/flashlight +[12]: https://github.com/facebookresearch/wav2letter +[13]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/02/ds2.png?resize=850%2C313&ssl=1 (5 Good Open Source Speech Recognition/Speech-to-Text Systems 24 open source speech recognition) +[14]: https://github.com/PaddlePaddle/DeepSpeech diff --git a/published/201906/20190308 Blockchain 2.0 - Explaining Smart Contracts And Its Types -Part 5.md b/published/201906/20190308 Blockchain 2.0 - Explaining Smart Contracts And Its Types -Part 5.md new file mode 100644 index 0000000000..62499247c1 --- /dev/null +++ b/published/201906/20190308 Blockchain 2.0 - Explaining Smart Contracts And Its Types -Part 5.md @@ -0,0 +1,163 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10956-1.html) +[#]: subject: (Blockchain 2.0 – Explaining Smart Contracts And Its Types [Part 5]) +[#]: via: (https://www.ostechnix.com/blockchain-2-0-explaining-smart-contracts-and-its-types/) +[#]: author: (editor https://www.ostechnix.com/author/editor/) + +区块链 2.0:智能合约及其类型(五) +====== + +![Explaining Smart Contracts And Its Types][1] + +这是 区块链 2.0 系列的第 5 篇文章。本系列的前一篇文章探讨了我们如何[在房地产行业实现区块链][2]。本文简要探讨了区块链及相关技术领域内的智能合约Smart Contract主题。智能合约是在区块链上验证和创建新“数据块”的基本协议,它被吹捧为该系统未来发展和应用的焦点。 然而,像所有“万灵药”一样,它不是一切的答案。我们将从基础知识中探索这个概念,以了解“智能合约”是什么以及它们不是什么。 + +### 不断发展的合同 + +这个世界建立在合同(合约)之上。在当前社会,没有合约的使用和再利用,地球上任何个人或公司都无法运作。订立、维护和执行合同的任务变得如此复杂,以至于整个司法和法律系统都必须以“合同法”的名义建立起来以支持它。事实上,大多数合同都是由一个“可信的”第三方监督,以确保最终的利益攸关者按照达成的条件得到妥善处理。有些合同甚至涉及到了第三方受益人。此类合同旨在对不是合同的活跃(或参与)方的第三方产生影响。解决和争论合同义务占据了民事诉讼所涉及的大部分法律纠纷。当然,更好的处理合同的方式来对于个人和企业来说都是天赐之物。更不用说它将以核查和证明的名义节省政府的巨大的[文书工作][7] [^1]。 + +本系列中的大多数文章都研究了如何利用现有的区块链技术。相比之下,这篇文章将更多地讲述对未来几年的预期。关于“智能合约”的讨论源于前一篇文章中提出的财产讨论。当前这篇文章旨在概述区块链自动执行“智能”可执行程序的能力。务实地处理这个问题意味着我们首先必须定义和探索这些“智能合约”是什么,以及它们如何适应现有的合同系统。我们将在下一篇题为“区块链 2.0:正在进行的项目”的文章中查看当前该领域正在进行的主要应用和项目。 + +### 定义智能合约 + +[本系列的第一篇文章][3]从基本的角度来看待区块链,将其看作由数据块组成的“分布式分类账本”,这些数据块是: + +* 防篡改 +* 不可否认(意味着每个数据块都是由某人显式创建的,并且该人不能否认相同的责任) +* 安全,且能抵御传统的网络攻击方法 +* 几乎是永久性的(当然这取决于区块链协议层) +* 高度冗余,通过存在于多个网络节点或参与者系统上,其中一个节点的故障不会以任何方式影响系统的功能,并且, +* 根据应用的不同可以提供更快的处理速度。 + +由于每个数据实例都是安全存储和通过适当的凭证访问的,因此区块链网络可以为精确验证事实和信息提供简便的基础,而无需第三方监督。区块链 2.0 开发也允许“分布式应用程序(DApp)”(我们将在接下来的文章中详细介绍这个术语)。这些分布式应用程序要求存在网络上并在其上运行。当用户需要它们时就会调用它们,并通过使用已经过审核并存储在区块链上的信息来执行它们。 + +上面的最后一段为智能合约的定义提供了基础。数字商会The Chamber for Digital Commerce提供了一个许多专家都同意的智能合约定义。 + +> “(智能合约是一种)计算机代码,在发生指定条件时,能够根据预先指定的功能自动运行。该代码可以在分布式分类帐本上存储和处理,并将产生的任何更改写入分布式分类帐本” [^2]。 + +智能合约如上所述是一种简单的计算机程序,就像 “if-then” 或 “if-else if” 语句一样工作。关于其“智能”的方面来自这样一个事实,即该程序的预定义输入来自区块链分类账本,如上所述,它是一个记录信息的安全可靠的来源。如有必要,程序可以调用外部服务或来源以获取信息,以验证操作条款,并且仅在满足所有预定义条件后才执行。 + +必须记住,与其名称所暗示的不同,智能合约通常不是自治实体,严格来说,也不是合同。1996 年,Nick Szabo 很早就提到了智能合约,他将其与接受付款并交付用户选择的产品的自动售货机进行了比较。可以在[这里][4]查看全文。此外,人们正在制定允许智能合约进入主流合同使用的法律框架,因此目前该技术的使用仅限于法律监督不那么明确和严格的领域 [^4]。 + +### 智能合约的主要类型 + +假设读者对合同和计算机编程有基本的了解,并且基于我们对智能合约的定义,我们可以将智能合约和协议粗略地分类为以下主要类别。 + +#### 1、智能法律合约 + +这大概是最明显的一种。大多数(如果不是全部)合同都具有法律效力。在不涉及太多技术问题的情况下,智能法律合约是涉及到严格的法律追索权的合同,以防参与合同的当事人不履行其交易的目的。如前所述,不同国家和地区的现行法律框架对区块链上的智能和自动化合约缺乏足够的支持,其法律地位也不明确。但是,一旦制定了法律,就可以订立智能合约,以简化目前涉及严格监管的流程,如金融和房地产市场交易、政府补贴、国际贸易等。 + +#### 2、DAO + +去中心化自治组织Decentralized Autonomous Organization,即DAO,可以粗略地定义为区块链上存在的社区。该社区可以通过一组规则来定义,这些规则通过智能合约来体现并放入代码中。然后,每个参与者的每一个行动都将受到这些规则的约束,其任务是在程序中断的情况下执行并获得追索权。许多智能合约构成了这些规则,它们协同监管和监督参与者。 + +名为“创世纪 DAO” 的 DAO 是由以太坊参与者于 2016 年 5 月创建。该社区旨在成为众筹和风险投资平台。在极短的时间内,他们设法筹集了惊人的 1.5 亿美元。然而,由于黑客在系统中发现了漏洞,并设法从众筹投资者手中窃取价值约 5000 万美元的以太币。这次黑客破坏的后果导致以太坊区块链[分裂为两个][8],以太坊和以太坊经典。 + +#### 3、应用逻辑合约(ALC) + +如果你已经听说过与区块链相结合的物联网,那么很可能它涉及到了应用逻辑合约Application logic contract,即 ALC。此类智能合约包含特定于应用的代码,这些代码可以与区块链上的其他智能合约和程序一起工作。它们有助于与设备进行通信并验证设备之间的通信(在物联网领域)。ALC 是每个多功能智能合约的关键部分,并且大多数都是在一个管理程序下工作。在这里引用的大多数例子中,它们到处都能找到[应用][9] [^6]。 + +*由于该领域还在开发中,因此目前所说的任何定义或标准最多只能说是变化而模糊的。* + +### 智能合约是如何工作的? + +为简化起见,让我们用个例子来说明。 + +约翰和彼得是两个争论足球比赛得分的人。他们对比赛结果持有相互矛盾的看法,他们都支持不同的球队(这是背景情况)。由于他们两个都需要去其他地方并且无法看完比赛,所以约翰认为如果 A 队在比赛中击败 B 队,他就*支付*给彼得 100 美元。彼得*考虑*之后*接受*了该赌注,同时明确表示他们必须接受这些条款。但是,他们没有兑现该赌注的相互信任,也没有时间和钱来指定第三方监督赌注。 + +假设约翰和彼得都使用像 [Etherparty][5] 这样的智能合约平台,它可以在合约谈判时自动结算赌注,他们都会将基于区块链的身份链接到该合约,并设置条款,明确表示一旦比赛结束,该程序将找出获胜方是谁,并自动将该金额从输家中归入获胜者银行账户。一旦比赛结束并且媒体报道同样的结果,该程序将在互联网上搜索规定的来源,确定哪支球队获胜,将其与合约条款联系起来,在这种情况下,如果 A 队赢了彼得将从约翰哪里得到钱,也就是说将约翰的 100 美元转移到彼得的账户。执行完毕后,除非另有说明,否则智能合约将终止并在未来所有的时间内处于非活动状态。 + +抛开例子的简单不说,这种情况涉及到一个经典的合同,而参与者选择使用智能合约实现了相同目的。所有的智能合约基本上都遵循类似的原则,对程序进行编码,以便在预定义的参数上执行,并且只抛出预期的输出。智能合同咨询的外部来源可以是有时被称为 IT 世界中的神谕Oracle。神谕是当今全球许多智能合约系统的常见部分。 + +在这种情况下使用智能合约使参与者可以获得以下好处: + +* 它比在一起并手动结算更快。 +* 从其中删除了信任问题。 +* 消除了受信任的第三方代表有关各方处理和解的必要性。 +* 执行时无需任何费用。 +* 在如何处理参数和敏感数据方面是安全的。 +* 相关数据将永久保留在他们运行的区块链平台中,未来可以通过调用相同的函数并为其提供更多输入来设置投注。 +* 随着时间的推移,假设约翰和彼得变得赌博成瘾,该程序可以帮助他们开发可靠的统计数据来衡量他们的连胜纪录。 +   +现在我们知道**什么是智能合约**和**它们如何工作**,我们还没有解决**为什么我们需要它们**。 + +### 智能合约的需要 + +正如之前的例子我们重点提到过的,出于各种原因,我们需要智能合约。 + +#### 透明度 + +交易对手非常清楚所涉及的条款和条件。此外,由于程序或智能合约的执行涉及某些明确的输入,因此用户可以非常直接地核实会影响他们和合约受益人的因素。 + +#### 时间效率 + +如上所述,智能合约一旦被控制变量或用户调用所触发,就立即开始工作。由于数据是通过区块链和网络中的其它来源即时提供给系统,因此执行不需要任何时间来验证和处理信息并解决交易。例如,转移土地所有权契约,这是一个涉及手工核实大量文书工作并且需要数周时间的过程,可以在几分钟甚至几秒钟内通过智能合约程序来处理文件和相关各方。 + +#### 精度 + +由于平台基本上只是计算机代码和预定义的内容,因此不存在主观错误,所有结果都是精确的,完全没有人为错误。 + +#### 安全 + +区块链的一个固有特征是每个数据块都是安全加密的。这意味着为了实现冗余,即使数据存储在网络上的多个节点上,**也只有数据所有者才能访问以查看和使用数据**。类似地,利用区块链在过程中存储重要变量和结果,所有过程都将是完全安全和防篡改的。同样也通过按时间顺序为审计人员提供原始的、未经更改的和不可否认的数据版本,简化了审计和法规事务。 + +#### 信任 + +这个文章系列开篇说到区块链为互联网及其上运行的服务增加了急需的信任层。智能合约在任何情况下都不会在执行协议时表现出偏见或主观性,这意味着所涉及的各方对结果完全有约束力,并且可以不附带任何条件地信任该系统。这也意味着,在具有重要价值的传统合同中所需的“可信第三方”,在此处不需要。当事人之间的犯规和监督将成为过去的问题。 + +#### 成本效益 + +如示例中所强调的,使用智能合约需要最低的成本。企业通常有专门从事使其交易合法并遵守法规的行政人员。如果交易涉及多方,则重复工作是不可避免的。智能合约基本上使前者无关紧要,并且消除了重复,因为双方可以同时完成尽职调查。 + +### 智能合约的应用 + +基本上,如果两个或多个参与方使用共同的区块链平台,并就一组原则或业务逻辑达成一致,他们可以一起在区块链上创建一个智能合约,并且在没有人为干预的情况下执行。没有人可以篡改所设置的条件,如果原始代码允许,任何更改都会加上时间戳并带有编辑者的指纹,从而增加了问责制。想象一下,在更大的企业级规模上出现类似的情况,你就会明白智能合约的能力是什么,实际上从 2016 年开始的 **Capgemini 研究** 发现智能合约实际上可能是**“未来几年的”** [^8] 商业主流。商业的应用涉及保险、金融市场、物联网、贷款、身份管理系统、托管账户、雇佣合同以及专利和版税合同等用途。像以太坊这样的区块链平台,是一个设计时就考虑了智能合约的系统,它允许个人私人用户免费使用智能合约。 + +通过对处理智能合约的公司的探讨,本系列的下一篇文章中将更全面地概述智能合约在当前技术问题上的应用。 + +### 那么,它有什么缺点呢? + +这并不是说对智能合约的使用没有任何顾虑。这种担忧实际上也减缓了这方面的发展。所有区块链的防篡改性质实质上使得,如果所涉及的各方需要在没有重大改革或法律追索的情况下,几乎不可能修改或添加现有条款的新条款。 + +其次,即使公有链上的活动是开放的,所有人都可以看到和观察。交易中涉及的各方的个人身份并不总是已知的。这种匿名性造成在任何一方违约的情况下法律有罪不罚的问题,特别是因为现行法律和立法者并不完全适应现代技术。 + +第三,区块链和智能合约在很多方面仍然存在安全缺陷,因为对其所以涉及的技术仍处于发展的初期阶段。 对代码和平台的这种缺乏经验最终导致了 2016 年的 DAO 事件。 + +所有这些都可能导致企业或公司在需要调整区块链以供其使用时需要大量的初始投资。然而,这些是最初的一次性投资,并且随之而来的是潜在的节约,这才是人们感兴趣的。 + +### 结论 + +目前的法律框架并没有真正支持一个全面的智能合约的社会,并且由于显然的原因,在不久的将来也不会支持。一个解决方案是选择**“混合”合约**,它将传统的法律文本和文件与在为此目的设计的区块链上运行的智能合约代码相结合。然而,即使是混合合约仍然很大程度上尚未得到探索,因为需要创新的立法机构才能实现这些合约。这里简要提到的应用以及更多内容将在[本系列的下一篇文章][6]中详细探讨。 + +[^1]: S. C. A. Chamber of Digital Commerce, “Smart contracts – Is the law ready,” no. September, 2018. +[^2]: S. C. A. Chamber of Digital Commerce, “Smart contracts – Is the law ready,” no. September, 2018. +[^4]: Cardozo Blockchain Project, “‘Smart Contracts’ & Legal Enforceability,” vol. 2, p. 28, 2018. +[^6]: F. Idelberger, G. Governatori, R. Riveret, and G. Sartor, “Evaluation of Logic-Based Smart Contracts for Blockchain Systems,” 2016, pp. 167–183. +[^8]: B. Cant et al., “Smart Contracts in Financial Services : Getting from Hype to Reality,” Capgemini Consult., pp. 1–24, 2016. + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/blockchain-2-0-explaining-smart-contracts-and-its-types/ + +作者:[ostechnix][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/03/smart-contracts-720x340.png +[2]: https://linux.cn/article-10914-1.html +[3]: https://linux.cn/article-10650-1.html +[4]: http://www.fon.hum.uva.nl/rob/Courses/InformationInSpeech/CDROM/Literature/LOTwinterschool2006/szabo.best.vwh.net/smart_contracts_2.html +[5]: https://etherparty.com/ +[6]: https://www.ostechnix.com/blockchain-2-0-ongoing-projects-the-state-of-smart-contracts-now/ +[7]: http://www.legal-glossary.org/ +[8]: https://futurism.com/the-dao-heist-undone-97-of-eth-holders-vote-for-the-hard-fork/ +[9]: https://www.everestgrp.com/2016-10-types-smart-contracts-based-applications-market-insights-36573.html/ diff --git a/published/201906/20190331 How to build a mobile particulate matter sensor with a Raspberry Pi.md b/published/201906/20190331 How to build a mobile particulate matter sensor with a Raspberry Pi.md new file mode 100644 index 0000000000..587c69b785 --- /dev/null +++ b/published/201906/20190331 How to build a mobile particulate matter sensor with a Raspberry Pi.md @@ -0,0 +1,127 @@ +[#]: collector: (lujun9972) +[#]: translator: (tomjlw) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10939-1.html) +[#]: subject: (How to build a mobile particulate matter sensor with a Raspberry Pi) +[#]: via: (https://opensource.com/article/19/3/mobile-particulate-matter-sensor) +[#]: author: (Stephan Tetzel https://opensource.com/users/stephan) + +如何用树莓派搭建一个颗粒物传感器 +====== + +> 用树莓派、一个廉价的传感器和一个便宜的屏幕监测空气质量。 + +![](https://img.linux.net.cn/data/attachment/album/201906/05/005121bbveeavwgyc1i1gk.jpg) + +大约一年前,我写了一篇关于如何使用树莓派和廉价传感器测量[空气质量][2]的文章。我们这几年已在学校里和私下使用了这个项目。然而它有一个缺点:由于它基于无线/有线网,因此它不是便携的。如果你的树莓派、你的智能手机和电脑不在同一个网络的话,你甚至都不能访问传感器测量的数据。 + +为了弥补这一缺陷,我们给树莓派添加了一块小屏幕,这样我们就可以直接从该设备上读取数据。以下是我们如何为我们的移动细颗粒物传感器搭建并配置好屏幕。 + +### 为树莓派搭建好屏幕 + +在[亚马逊][3]、阿里巴巴以及其它来源有许多可以买到的树莓派屏幕,从 ePaper 屏幕到可触控 LCD。我们选择了一个便宜的带触控功能且分辨率为 320*480 像素的[3.5英寸 LCD][3],可以直接插进树莓派的 GPIO 引脚。3.5 英寸屏幕和树莓派几乎一样大,这一点不错。 + +当你第一次启动屏幕打开树莓派的时候,会因为缺少驱动屏幕会保持白屏。你得首先为屏幕安装[合适的驱动][5]。通过 SSH 登入并执行以下命令: + +``` +$ rm -rf LCD-show +$ git clone +$ chmod -R 755 LCD-show +$ cd LCD-show/ +``` + +为你的屏幕执行合适的命令以安装驱动。例如这是给我们 MPI3501 型屏幕的命令: + +``` +$ sudo ./LCD35-show +``` + +这行命令会安装合适的驱动并重启树莓派。 + +### 安装 PIXEL 桌面并设置自动启动 + +以下是我们想要我们项目能够做到的事情:如果树莓派启动,我们想要展现一个有我们空气质量测量数据的网站。 + +首先,安装树莓派的[PIXEL 桌面环境][6]: + +``` +$ sudo apt install raspberrypi-ui-mods +``` + +然后安装 Chromium 浏览器以显示网站: + +``` +$ sudo apt install chromium-browser +``` + +需要自动登录以使测量数据在启动后直接显示;否则你将只会看到登录界面。然而树莓派用户并没有默认设置好自动登录。你可以用 `raspi-config` 工具设置自动登录: + +``` +$ sudo raspi-config +``` + +在菜单中,选择:“3 Boot Options → B1 Desktop / CLI → B4 Desktop Autologin”。 + +在启动后用 Chromium 打开我们的网站这块少了一步。创建文件夹 `/home/pi/.config/lxsession/LXDE-pi/`: + +``` +$ mkdir -p /home/pi/config/lxsession/LXDE-pi/ +``` + +然后在该文件夹里创建 `autostart` 文件: + +``` +$ nano /home/pi/.config/lxsession/LXDE-pi/autostart +``` + +并粘贴以下代码: + +``` +#@unclutter +@xset s off +@xset -dpms +@xset s noblank + +# Open Chromium in Full Screen Mode +@chromium-browser --incognito --kiosk +``` + +如果你想要隐藏鼠标指针,你得安装 `unclutter` 包并移除 `autostart` 文件开头的注释。 + +``` +$ sudo apt install unclutter +``` + +![移动颗粒物传感器][7] + +我对去年的代码做了些小修改。因此如果你之前搭建过空气质量项目,确保用[原文章][2]中的指导为 AQI 网站重新下载脚本和文件。 + +通过添加触摸屏,你现在拥有了一个便携的颗粒物传感器!我们在学校用它来检查教室里的空气质量或者进行比较测量。使用这种配置,你无需再依赖网络连接或 WLAN。你可以在任何地方使用这个小型测量站——你甚至可以使用移动电源以摆脱电网。 + +* * * + +这篇文章原来在[开源学校解决方案][8]Open Scool Solutions上发表,获得许可重新发布。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/3/mobile-particulate-matter-sensor + +作者:[Stephan Tetzel][a] +选题:[lujun9972][b] +译者:[tomjlw](https://github.com/tomjlw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/stephan +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/talk_chat_team_mobile_desktop.png?itok=d7sRtKfQ (Team communication, chat) +[2]: https://linux.cn/article-9620-1.html +[3]: https://www.amazon.com/gp/search/ref=as_li_qf_sp_sr_tl?ie=UTF8&tag=openschoolsol-20&keywords=lcd%20raspberry&index=aps&camp=1789&creative=9325&linkCode=ur2&linkId=51d6d7676e10d6c7db203c4a8b3b529a +[4]: https://amzn.to/2CcvgpC +[5]: https://github.com/goodtft/LCD-show +[6]: https://linux.cn/article-8459-1.html +[7]: https://opensource.com/sites/default/files/uploads/mobile-aqi-sensor.jpg (Mobile particulate matter sensor) +[8]: https://openschoolsolutions.org/mobile-particulate-matter-sensor/ + diff --git a/published/201906/20190404 Running LEDs in reverse could cool computers.md b/published/201906/20190404 Running LEDs in reverse could cool computers.md new file mode 100644 index 0000000000..b3ebbed273 --- /dev/null +++ b/published/201906/20190404 Running LEDs in reverse could cool computers.md @@ -0,0 +1,64 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10984-1.html) +[#]: subject: (Running LEDs in reverse could cool computers) +[#]: via: (https://www.networkworld.com/article/3386876/running-leds-in-reverse-could-cool-computers.html#tk.rss_all) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +反向运行 LED 能够冷却计算机 +====== + +> 电子产品的小型化正在触及其极限,部分原因在于热量管理。许多人现在都在积极地尝试解决这个问题。其中一种正在探索的途径是反向运行的 LED。 + +![monsitj / Getty Images][1] + +寻找更有效的冷却计算机的方法,几乎与渴望发现更好的电池化学成分一样,在科学家的研究日程中也处于重要位置。 + +更多的冷却手段对于降低成本至关重要。冷却技术也使得在较小的空间中可以进行更强大的处理,其有限的处理能力应该是进行计算而不是浪费热量。冷却技术可以阻止热量引起的故障,从而延长部件的使用寿命,并且可以促进环保的数据中心 —— 更少的热量意味着对环境的影响更小。 + +如何从微处理器中消除热量是科学家们一直在探索的一个方向,他们认为他们已经提出了一个简单而不寻常、且反直觉的解决方案。他们说可以运行一个发光二极管(LED)的变体,其电极反转可以迫使该元件表现得像处于异常低温下工作一样。如果将其置于较热的电子设备旁边,然后引入纳米级间隙,可以使 LED 吸收热量。 + +“一旦 LED 反向偏置,它就会像一个非常低温的物体一样,吸收光子,”密歇根大学机械工程教授埃德加·梅霍夫在宣布了这一突破的[新闻稿][4]中说。 “与此同时,该间隙可防止热量返回,从而产生冷却效果。” + +研究人员表示,LED 和相邻的电子设备(在这种情况下是热量计,通常用于测量热能)必须非常接近。他们说他们已经能够证明达到了每平方米 6 瓦的冷却功率。他们解释说,这是差不多是地球表面所接受到的阳光的能量。 + +物联网(IoT)设备和智能手机可能是最终将受益于这种 LED 改造的电子产品。这两种设备都需要在更小的空间中容纳更多的计算功率。 + +“从微处理器中可以移除的热量开始限制在给定空间内容纳的功率,”密歇根大学的公告说。 + +### 材料科学和冷却计算机 + +[我之前写过关于新形式的计算机冷却的文章][5]。源自材料科学的外来材料是正在探索的想法之一。美国能源部劳伦斯伯克利国家实验室表示,钠铋(Na3Bi)可用于晶体管设计。这种新物质带电荷,重要的是具有可调节性;但是,它不需要像超导体那样进行冷却。 + +事实上,这是超导体的一个问题。不幸的是,它们比大多数电子设备需要更多的冷却 —— 通过极端冷却消除电阻。 + +另外,[康斯坦茨大学的德国研究人员][6]表示他们很快将拥有超导体驱动的计算机,没有废热。他们计划使用电子自旋 —— 一种新的电子物理维度,可以提高效率。该大学去年在一份新闻稿中表示,这种方法“显著降低了计算中心的能耗”。 + +另一种减少热量的方法可能是用嵌入在微处理器上的[螺旋和回路来取代传统的散热器][7]。宾汉姆顿大学的科学家们表示,印在芯片上的微小通道可以为冷却剂提供单独的通道。 + +康斯坦茨大学说:“半导体技术的小型化正在接近其物理极限。”热管理现在被科学家提上了议事日程。这是“小型化的一大挑战”。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3386876/running-leds-in-reverse-could-cool-computers.html#tk.rss_all + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/big_data_center_server_racks_storage_binary_analytics_by_monsitj_gettyimages-944444446_3x2-100787357-large.jpg +[2]: https://www.networkworld.com/article/3242807/data-center/top-10-data-center-predictions-idc.html#nww-fsb +[3]: https://www.networkworld.com/newsletters/signup.html#nww-fsb +[4]: https://news.umich.edu/running-an-led-in-reverse-could-cool-future-computers/ +[5]: https://www.networkworld.com/article/3326831/computers-could-soon-run-cold-no-heat-generated.html +[6]: https://www.uni-konstanz.de/en/university/news-and-media/current-announcements/news/news-in-detail/Supercomputer-ohne-Abwaerme/ +[7]: https://www.networkworld.com/article/3322956/chip-cooling-breakthrough-will-reduce-data-center-power-costs.html +[8]: https://www.facebook.com/NetworkWorld/ +[9]: https://www.linkedin.com/company/network-world diff --git a/published/201906/20190405 Blockchain 2.0 - Ongoing Projects (The State Of Smart Contracts Now) -Part 6.md b/published/201906/20190405 Blockchain 2.0 - Ongoing Projects (The State Of Smart Contracts Now) -Part 6.md new file mode 100644 index 0000000000..dbc3c03306 --- /dev/null +++ b/published/201906/20190405 Blockchain 2.0 - Ongoing Projects (The State Of Smart Contracts Now) -Part 6.md @@ -0,0 +1,100 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11013-1.html) +[#]: subject: (Blockchain 2.0 – Ongoing Projects (The State Of Smart Contracts Now) [Part 6]) +[#]: via: (https://www.ostechnix.com/blockchain-2-0-ongoing-projects-the-state-of-smart-contracts-now/) +[#]: author: (editor https://www.ostechnix.com/author/editor/) + +区块链 2.0:智能合约如今的发展(六) +====== + +![The State Of Smart Contracts Now][1] + +继续我们的[前面的关于智能合约的文章][2],这篇文章旨在讨论智能合约的发展形势,重点介绍目前正在该领域进行开发的一些项目和公司。如本系列前一篇文章中讨论的,智能合约是在区块链网络上存在并执行的程序。我们探讨了智能合约的工作原理以及它们优于传统数字平台的原因。这里描述的公司分布于各种各样的行业中,但是大多涉及到身份管理系统、金融服务、众筹系统等,因为这些是被认为最适合切换到基于区块链的数据库系统的领域。 + +### 开放平台 + +诸如 [Counterparty][8] 和 Solidity(以太坊)等平台是完全公用的构建模块,开发者可以以之创建自己的智能合约。大量的开发人员参与此类项目使这些项目成为开发智能合约、设计自己的加密货币令牌系统,以及创建区块链运行协议的事实标准。许多值得称赞的项目都来源于它们。摩根大通派生自以太坊的 [Quorum][9],就是一个例子。而瑞波是另一个例子。 + +### 管理金融交易 + +通过互联网转账加密货币被吹捧为在未来几年会成为常态。与此相关的不足之处是: + +* 身份和钱包地址是匿名的。如果接收方不履行交易,则付款人没有任何第一追索权。 +* 错误交易(如果无法追踪任何交易)。 +* 密码生成的哈希密钥很难用于人类,人为错误是主要关注点。 + +在这种情况下,可以让其他人暂时接受该交易并在接受尽职调查后与接收方结算。 + +[EscrowMyEther][10] 和 [PAYFAIR][11] 是两个这样的托管平台。基本上,托管公司采用商定的金额并向接收方发送令牌。一旦接收方通过相同的托管平台提供付款人想要的内容,两者都会确认并最终付款。 这些得到了自由职业者和业余爱好者收藏家广泛在线使用。 + +### 金融服务 + +小额融资和小额保险项目的发展将改善世界上大多数贫穷或没有银行账户的人的银行金融服务。据估计,社会中较贫穷的“无银行账户”人群可以为银行和机构的增加 3800 亿美元收入 [^5]。这一金额要远远超过银行切换到区块链分布式账本技术(DLT)预期可以节省的运营费用。 + +位于美国中西部的 BankQu Inc. 的口号是“通过身份而尊严”。他们的平台允许个人建立他们自己的数字身份记录,其中所有交易将在区块链上实时审查和处理。在底层代码上记录并为其用户构建唯一的在线标识,从而实现超快速的交易和结算。BankQu 案例研究探讨了他们如何以这种方式帮助个人和公司,可以在[这里][3]看到。 + +[Stratumn][12] 正在帮助保险公司通过自动化早期由人类微观管理的任务来提供更好的保险服务。通过自动化、端到端可追溯性和高效的数据隐私方法,他们彻底改变了保险索赔的结算方式。改善客户体验以及显著降低成本为客户和相关的公司带来双赢局面。 + +法国保险公司 [AXA][14] 目前正在试行类似的努力。其产品 [fizzy][13] 允许用户以少量费用订阅其服务并输入他们的航班详细信息。如果航班延误或遇到其他问题,该程序会自动搜索在线数据库,检查保险条款并将保险金额记入用户的帐户。这样就用户或客户无需在手动检查条款后提出索赔,并且就长期而言,一旦这样的系统成为主流,就增加了航空公司的责任心。 + +### 跟踪所有权 + +理论上可以利用 DLT 中的带时间戳的数据块来跟踪媒体的创建到最终用户消费。Peertracks 公司和 Mycelia 公司目前正在帮助音乐家发布内容,而不必担心其内容被盗或被滥用。他们帮助艺术家直接向粉丝和客户销售,同时获得工作报酬,而无需通过权利和唱片公司 [^9]。 + +### 身份管理平台 + +基于区块链的身份管理平台可以将你的身份存储在分布式分类帐本中。设置帐户后,会对其进行安全加密,然后将其发送给所有参与节点。但是,作为数据块的所有者,只有该用户才能访问该数据。一旦你在网络上建立身份并开始交易,网络中的自动程序将验证与你的帐户关联的先前所有的交易,在检查要求后将其发送给监管备案,并在程序认为交易合法时自动执行结算。这里的好处是,由于区块链上的数据是防篡改的,而智能合约以零偏差(或主观性)检查输入,如前所述,交易不需要任何人的监督或批准,并且需要小心是即刻生效的。 + +像 [ShoCard][15] 、[Credits][16] 和 [OneName][17] 这样的初创公司目前正在推出类似的服务,目前正在与政府和社会机构进行谈判,以便将它们整合到主流用途中。 + +开发商的其他独立项目如 Chris Ellis 和 David Duccini 分别开发或提出了替代的身份管理系统,分别是 “[世界公民][4]”和 [IDCoin][5]。Ellis 先生甚至通过在区块链网络上创建护照来证明他的工作能力。 + +### 资源共享 + +[Share & Charge][18] ([Slock.It][19]) 是一家欧洲的区块链初创公司。他们的移动应用程序允许房主和其他个人投入资金建立充电站与其他正在寻找快速充电的人分享他们的资源。这不仅使业主能够收回他们的一些投资,而且还允许 EV 司机在其近地域获得更多的充电点,从而允许供应商以方便的方式满足需求。一旦“客户”完成对其车辆的充电,相关的硬件就会创建一个由数据组成的安全时间戳块,并且在该平台上工作的智能合约会自动将相应的金额记入所有者账户。记录所有此类交易的跟踪并保持适当的安全验证。有兴趣的读者可以看一下[这里][6],了解他们产品背后的技术角度。该公司的平台将逐步使用户能够与有需要的个人分享其他产品和服务,并从中获得被动收入。 + +我们在这里看到的公司,以及一个很短的正在进行中的项目的清单,这些项目利用智能合约和区块链数据库系统。诸如此类的平台有助于构建一个安全的“盒子”,其中包含仅由用户自己、其上的代码或智能合约访问的信息。基于触发器对信息进行实时审查、检查,并且算法由系统执行。这样的平台人为监督最小化,这是在安全数字自动化方面朝着正确方向迈出的急需的一步,这在以前从未被考虑过如此规模。 + +下一篇文章将阐述不同类型的区块链。单击以下链接以了解有关此主题的更多信息。 + +* [区块链 2.0:公有链与私有链的比较][7] + + +[^5]: B. Pani, “Blockchain Powered Financial Inclusion,” 2016. +[^9]: M. Gates, “Blockchain. Ultimate guide to understanding blockchain bitcoin cryptocurrencies smart-contracts and the future of money.pdf.” 2017. + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/blockchain-2-0-ongoing-projects-the-state-of-smart-contracts-now/ + +作者:[ostechnix][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/04/State-Of-Smart-Contracts-720x340.png +[2]: https://linux.cn/article-10956-1.html +[3]: https://banqu.co/case-study/ +[4]: https://github.com/MrChrisJ/World-Citizenship +[5]: https://github.com/IDCoin/IDCoin +[6]: https://blog.slock.it/share-charge-smart-contracts-the-technical-angle-58b93ce80f15 +[7]: https://www.ostechnix.com/blockchain-2-0-public-vs-private-blockchain-comparison/ +[8]: https://counterparty.io/platform/ +[9]: https://www.jpmorgan.com/global/Quorum +[10]: http://escrowmyether.com/ +[11]: https://payfair.io/ +[12]: https://stratumn.com/business-case/insurance-claim-automation-across-europe/ +[13]: https://fizzy.axa/en-gb/ +[14]: https://group.axa.com/en/newsroom/news/axa-goes-blockchain-with-fizzy +[15]: https://techcrunch.com/2015/05/05/shocard-is-a-digital-identity-card-on-the-blockchain/ +[16]: https://techcrunch.com/2014/10/31/your-next-passport-could-be-on-the-blockchain/ +[17]: https://wiki.namecoin.org/index.php?title=OneName +[18]: https://blog.slock.it/share-charge-launches-its-app-on-boards-over-1-000-charging-stations-on-the-blockchain-ba8275390309 +[19]: https://slock.it/ diff --git a/published/201906/20190409 5 Linux rookie mistakes.md b/published/201906/20190409 5 Linux rookie mistakes.md new file mode 100644 index 0000000000..dadd5807a8 --- /dev/null +++ b/published/201906/20190409 5 Linux rookie mistakes.md @@ -0,0 +1,56 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10952-1.html) +[#]: subject: (5 Linux rookie mistakes) +[#]: via: (https://opensource.com/article/19/4/linux-rookie-mistakes) +[#]: author: (Jen Wike Huger https://opensource.com/users/jen-wike/users/bcotton/users/petercheer/users/greg-p/users/greg-p) + +5 个 Linux 新手会犯的失误 +====== + +> Linux 爱好者们分享了他们犯下的一些最大错误。 + +![](https://img.linux.net.cn/data/attachment/album/201906/09/103635akfkghwh5mp58g68.jpg) + +终身学习是明智的 —— 它可以让你的思维敏捷,让你在就业市场上更具竞争力。但是有些技能比其他技能更难学,尤其是那些小菜鸟错误,当你尝试修复它们时可能会花费你很多时间,给你带来很大困扰。 + +以学习 [Linux][2] 为例。如果你习惯于在 Windows 或 MacOS 图形界面中工作,那么转移到 Linux,要将不熟悉的命令输入到终端中,可能会有很大的学习曲线。但是,其回报是值得的,因为已经有数以百万计的人们已经证明了这一点。 + +也就是说,这趟学习之旅并不是一帆风顺的。我们让一些 Linux 爱好者回想了一下他们刚开始使用 Linux 的时候,并告诉我们他们犯下的最大错误。 + +“不要进入[任何类型的命令行界面(CLI)工作]时就期望命令会以合理或一致的方式工作,因为这可能会导致你感到挫折。这不是因为设计选择不当 —— 虽然当你在键盘上敲击时就像在敲在你的脑袋上一样 —— 而是反映了这些系统是历经了几代的软件和操作系统的发展而陆续添加完成的事实。顺其自然,写下或记住你需要的命令,并且(尽量不要)在[事情不是你所期望的][3]时感到沮丧。” —— [Gina Likins] [4] + +“尽可能简单地复制和粘贴命令以使事情顺利进行,首先阅读命令,至少对将要执行的操作有一个大致的了解,特别是如果有管道命令时,如果有多个管道更要特别注意。有很多破坏性的命令看起来无害 —— 直到你意识到它们能做什么(例如 `rm`、`dd`),而你不会想要意外破坏什么东西(别问我怎么知道)。” —— [Katie McLaughlin] [5] + +“在我的 Linux 之旅的早期,我并不知道我所处在文件系统中的位置的重要性。我正在删除一些我认为是我的主目录的文件,我输入了 `sudo rm -rf *`,然后就删除了我系统上的所有启动文件。现在,我经常使用 `pwd` 来确保我在发出这样的命令之前确认我在哪里。幸运的是,我能够使用 USB 驱动器启动被搞坏的笔记本电脑并恢复我的文件。” —— [Don Watkins] [6] + +“不要因为你认为‘权限很难理解’而你希望应用程序可以访问某些内容时就将整个文件系统的权限重置为 [777][7]。”—— [Matthew Helmke] [8] + +“我从我的系统中删除一个软件包,而我没有检查它依赖的其他软件包。我只是让它删除它想删除要的东西,最终导致我的一些重要程序崩溃并变得不可用。” —— [Kedar Vijay Kulkarni] [9] + +你在学习使用 Linux 时犯过什么错误?请在评论中分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/linux-rookie-mistakes + +作者:[Jen Wike Huger][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jen-wike/users/bcotton/users/petercheer/users/greg-p/users/greg-p +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mistake_bug_fix_find_error.png?itok=PZaz3dga (magnifying glass on computer screen, finding a bug in the code) +[2]: https://opensource.com/resources/linux +[3]: https://lintqueen.com/2017/07/02/learning-while-frustrated/ +[4]: https://opensource.com/users/lintqueen +[5]: https://opensource.com/users/glasnt +[6]: https://opensource.com/users/don-watkins +[7]: https://www.maketecheasier.com/file-permissions-what-does-chmod-777-means/ +[8]: https://twitter.com/matthewhelmke +[9]: https://opensource.com/users/kkulkarn diff --git a/published/201906/20190409 5 open source mobile apps.md b/published/201906/20190409 5 open source mobile apps.md new file mode 100644 index 0000000000..e51f6dbc93 --- /dev/null +++ b/published/201906/20190409 5 open source mobile apps.md @@ -0,0 +1,108 @@ +[#]: collector: "lujun9972" +[#]: translator: "fuzheng1998" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-10931-1.html" +[#]: subject: "5 open source mobile apps" +[#]: via: "https://opensource.com/article/19/4/mobile-apps" +[#]: author: "Chris Hermansen https://opensource.com/users/clhermansen/users/bcotton/users/clhermansen/users/bcotton/users/clhermansen" + +5 个可以满足你的生产力、沟通和娱乐需求的开源手机应用 +====== + +> 你可以依靠这些应用来满足你的生产力、沟通和娱乐需求。 + +![](https://img.linux.net.cn/data/attachment/album/201906/03/001949brnq19j5qeqn3onv.jpg) + +像世界上大多数人一样,我的手似乎就没有离开过手机。多亏了我从 Google Play 和 F-Droid 安装的开源移动应用程序,让我的 Android 设备好像提供了无限的沟通、生产力和娱乐服务一样。 + +在我的手机上的许多开源应用程序中,当想听音乐、与朋友/家人和同事联系、或者在旅途中完成工作时,以下五个是我一直使用的。 + +### MPDroid + +一个音乐播放器进程 (MPD)的 Android 控制器。 + +![MPDroid][2] + +MPD 是将音乐从小型音乐服务器电脑传输到大型的黑色立体声音箱的好方法。它直连 ALSA,因此可以通过 ALSA 硬件接口与数模转换器(DAC)对话,它可以通过我的网络进行控制——但是用什么东西控制呢?好吧,事实证明 MPDroid 是一个很棒的 MPD 控制器。它可以管理我的音乐数据库,显示专辑封面,处理播放列表,并支持互联网广播。而且它是开源的,所以如果某些东西不好用的话…… + +MPDroid 可在 [Google Play][4] 和 [F-Droid][5] 上找到。 + +### RadioDroid + +一台能单独使用及与 Chromecast 搭配使用的 Android 网络收音机。 + +![RadioDroid][6] + +RadioDroid 是一个网络收音机,而 MPDroid 则管理我音乐的数据库;从本质上讲,RadioDroid 是 [Internet-Radio.com][7] 的一个前端。此外,通过将耳机插入 Android 设备,通过耳机插孔或 USB 将 Android 设备直接连接到立体声系统,或通过兼容设备使用其 Chromecast 功能,可以享受 RadioDroid。这是一个查看芬兰天气情况,听取排名前 40 的西班牙语音乐,或收到到最新新闻消息的好方法。 + +RadioDroid 可在 [Google Play][8] 和 [F-Droid][9] 上找到。 + +### Signal + +一个支持 Android、iOS,还有桌面系统的安全即时消息客户端。 + +![Signal][10] + +如果你喜欢 WhatsApp,但是因为它与 Facebook [日益密切][11]的关系而感到困扰,那么 Signal 应该是你的下一个产品。Signal 的唯一问题是说服你的朋友们最好用 Signal 取代 WhatsApp。但除此之外,它有一个与 WhatsApp 类似的界面;很棒的语音和视频通话;很好的加密;恰到好处的匿名;并且它受到了一个不打算通过使用软件来获利的基金会的支持。为什么不喜欢它呢? + +Signal 可用于 [Android][12]、[iOS][13] 和 [桌面][14]。 + +### ConnectBot + +Android SSH 客户端。 + +![ConnectBot][15] + +有时我离电脑很远,但我需要登录服务器才能办事。[ConnectBot][16] 是将 SSH 会话搬到手机上的绝佳解决方案。 + +ConnectBot 可在 [Google Play][17] 上找到。 + +### Termux + +有多种熟悉的功能的安卓终端模拟器。 + +![Termux][18] + +你是否需要在手机上运行 `awk` 脚本?[Termux][19] 是个解决方案。如果你需要做终端类的工作,而且你不想一直保持与远程计算机的 SSH 连接,请使用 ConnectBot 将文件放到手机上,然后退出会话,在 Termux 中执行你的操作,用 ConnectBot 发回结果。 + +Termux 可在 [Google Play][20] 和 [F-Droid][21] 上找到。 + +* * * + +你最喜欢用于工作或娱乐的开源移动应用是什么呢?请在评论中分享它们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/mobile-apps + +作者:[Chris Hermansen][a] +选题:[lujun9972][b] +译者:[fuzheng1998](https://github.com/fuzheng1998) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clhermansen/users/bcotton/users/clhermansen/users/bcotton/users/clhermansen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003588_01_rd3os.combacktoschoolserieshe_rh_041x_0.png?itok=tfg6_I78 +[2]: https://opensource.com/sites/default/files/uploads/mpdroid.jpg "MPDroid" +[3]: https://opensource.com/article/17/4/fun-new-gadget +[4]: https://play.google.com/store/apps/details?id=com.namelessdev.mpdroid&hl=en_US +[5]: https://f-droid.org/en/packages/com.namelessdev.mpdroid/ +[6]: https://opensource.com/sites/default/files/uploads/radiodroid.png "RadioDroid" +[7]: https://www.internet-radio.com/ +[8]: https://play.google.com/store/apps/details?id=net.programmierecke.radiodroid2 +[9]: https://f-droid.org/en/packages/net.programmierecke.radiodroid2/ +[10]: https://opensource.com/sites/default/files/uploads/signal.png "Signal" +[11]: https://opensource.com/article/19/3/open-messenger-client +[12]: https://play.google.com/store/apps/details?id=org.thoughtcrime.securesms +[13]: https://itunes.apple.com/us/app/signal-private-messenger/id874139669?mt=8 +[14]: https://signal.org/download/ +[15]: https://opensource.com/sites/default/files/uploads/connectbot.png "ConnectBot" +[16]: https://connectbot.org/ +[17]: https://play.google.com/store/apps/details?id=org.connectbot +[18]: https://opensource.com/sites/default/files/uploads/termux.jpg "Termux" +[19]: https://termux.com/ +[20]: https://play.google.com/store/apps/details?id=com.termux +[21]: https://f-droid.org/packages/com.termux/ diff --git a/published/201906/20190409 VSCodium- 100- Open Source Version of Microsoft VS Code.md b/published/201906/20190409 VSCodium- 100- Open Source Version of Microsoft VS Code.md new file mode 100644 index 0000000000..1038abc8c2 --- /dev/null +++ b/published/201906/20190409 VSCodium- 100- Open Source Version of Microsoft VS Code.md @@ -0,0 +1,118 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11023-1.html) +[#]: subject: (VSCodium: 100% Open Source Version of Microsoft VS Code) +[#]: via: (https://itsfoss.com/vscodium/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +VSCodium:100% 开源的 VS Code +====== + +> VSCodium 是微软流行的 Visual Studio Code 编辑器的一个分支。它与 VS Code 完全相同,唯一不同的是,VSCodium 不跟踪你的使用数据。 + +微软的 [Visual Studio Code][1] 是一个出色的编辑器,不仅对于 Web 开发人员,也适合其他程序员。由于它的功能,它被认为是最好的开源代码编辑器之一。 + +是的,它是微软众多开源产品之一。因为有 DEB、RPM 和 Snap 包形式的二进制文件,你可以[在 Linux 中轻松安装 Visual Studio Code][2]。 + +但它存在一个问题,对于普通用户而言可能不是问题,但对于纯粹开源主义者而言是重要的。 + +Microsoft 说提供的二进制文件是不开源的。 + +感到困惑么?让我解释下。 + +VS Code 的源码是在 MIT 许可下开源的。你可以在 [GitHub][3] 上访问它。但是,[Microsoft 创建的安装包含专有的跟踪程序][4]。 + +此跟踪基本上用来收集使用数据并将其发送给 Microsoft 以“帮助改进其产品和服务”。如今,远程报告在软件产品中很常见。即使 [Ubuntu 也这样做,但它透明度更高][5]。 + +你可以[在 VS Code 中禁用远程报告][6],但是你能完全信任微软吗?如果答案是否定的,那你有什么选择? + +你可以从源代码构建它,从而保持全都是开源的。但是如今[从源代码安装][7]并不总是最好的选择,因为我们习惯于使用二进制文件。 + +另一种选择是使用 VSCodium ! + +### VSCodium:100% 开源形式的 Visual Studio Code + +![][8] + +[VSCodium][9] 是微软 Visual Studio Code 的一个分支。该项目的唯一目的是为你提供现成的二进制文件,而没有 Microsoft 的远程收集代码。 + +这解决了你想在去掉 Microsoft 的专有代码的情况下使用 VS Code ,而你又不习惯从源代码构建它的问题。 + +由于 [VSCodium 是 VS Code 的一个分支][11],它的外观和功能与 VS Code 完全相同。 + +这是 Ubuntu 中第一次运行 VS Code 和 VSCodium 的截图。你能分辨出来吗? + +![Can you guess which is VSCode and VSCodium?][12] + +如果你无法区分这两者,请看下面。 + +![That’s Microsoft][13] + +除此之外,还有两个应用的 logo,没有其他明显的区别。 + +![VSCodium and VS Code in GNOME Menu][14] + +#### 在 Linux 上安装 VSCodium + +虽然 VSCodium 存在于某些发行版(如 Parrot OS)中,但你必须在其他 Linux 发行版中添加额外的仓库。 + +在基于 Ubuntu 和 Debian 的发行版上,你可以使用以下命令安装 VSCodium。 + +首先,添加仓库的 GPG 密钥: + +``` +wget -qO - https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg | sudo apt-key add - +``` + +然后添加仓库: + +``` +echo 'deb https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/repos/debs/ vscodium main' | sudo tee --append /etc/apt/sources.list.d/vscodium.list +``` + +现在更新你的系统并安装 VSCodium: + +``` +sudo apt update && sudo apt install codium +``` + +你可以在它的页面上找到[其他发行版的安装说明][15]。你还应该阅读[有关从 VS Code 迁移到 VSCodium 的说明][16]。 + +### 你如何看待 VSCodium? + +就个人而言,我喜欢 VSCodium 的概念。说的老套一点,它的初心是好的。我认为,致力于开源的 Linux 发行版甚至可能开始将其包含在官方仓库中。 + +你怎么看?是否值得切换到 VSCodium 或者你选择关闭远程报告并继续使用 VS Code? + +请不要出现“我使用 Vim” 的评论 :D + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/vscodium/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://code.visualstudio.com/ +[2]: https://itsfoss.com/install-visual-studio-code-ubuntu/ +[3]: https://github.com/Microsoft/vscode +[4]: https://github.com/Microsoft/vscode/issues/60#issuecomment-161792005 +[5]: https://itsfoss.com/ubuntu-data-collection-stats/ +[6]: https://code.visualstudio.com/docs/supporting/faq#_how-to-disable-telemetry-reporting +[7]: https://itsfoss.com/install-software-from-source-code/ +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/04/vscodium.png?resize=800%2C450&ssl=1 +[9]: https://vscodium.com/ +[11]: https://github.com/VSCodium/vscodium +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/04/vscodium-vs-vscode.png?resize=800%2C450&ssl=1 +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/04/microsoft-vscode-tracking.png?resize=800%2C259&ssl=1 +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/04/vscodium-and-vscode.jpg?resize=800%2C220&ssl=1 +[15]: https://vscodium.com/#install +[16]: https://vscodium.com/#migrate diff --git a/published/201906/20190410 How we built a Linux desktop app with Electron.md b/published/201906/20190410 How we built a Linux desktop app with Electron.md new file mode 100644 index 0000000000..2afe6f57d6 --- /dev/null +++ b/published/201906/20190410 How we built a Linux desktop app with Electron.md @@ -0,0 +1,98 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10957-1.html) +[#]: subject: (How we built a Linux desktop app with Electron) +[#]: via: (https://opensource.com/article/19/4/linux-desktop-electron) +[#]: author: (Nils Ganther https://opensource.com/users/nils-ganther) + +我们是如何使用 Electron 构建 Linux 桌面应用程序的 +====== + +> 这是借助 Electron 框架,构建一个在 Linux 桌面上原生运行的开源电子邮件服务的故事。 + +![document sending](https://img.linux.net.cn/data/attachment/album/201906/10/123114abz0lvbllktkulx7.jpg) + +[Tutanota][2] 是一种安全的开源电子邮件服务,它可通过浏览器使用,也有 iOS 和 Android 应用。其客户端代码在 GPLv3 下发布,Android 应用程序可在 [F-Droid][3] 上找到,以便每个人都可以使用完全与 Google 无关的版本。 + +由于 Tutanota 关注开源和 Linux 客户端开发,因此我们希望为 Linux 和其他平台发布一个桌面应用程序。作为一个小团队,我们很快就排除了为 Linux、Windows 和 MacOS 构建原生应用程序的可能性,并决定使用 [Electron][4] 来构建我们的应用程序。 + +对于任何想要快速交付视觉一致的跨平台应用程序的人来说,Electron 是最适合的选择,尤其是如果你已经有一个 Web 应用程序,想要从浏览器 API 的束缚中摆脱出来时。Tutanota 就是这样一个案例。 + +Tutanota 基于 [SystemJS][5] 和 [Mithril][6],旨在为每个人提供简单、安全的电子邮件通信。 因此,它必须提供很多用户期望从电子邮件客户端获得的标准功能。 + +由于采用了现代 API 和标准,其中一些功能(如基本的推送通知、搜索文本和联系人以及支持双因素身份验证)很容易在浏览器中提供。其它功能(例如自动备份或无需我们的服务器中转的 IMAP 支持)需要对系统资源的限制性访问,而这正是 Electron 框架提供的功能。 + +虽然有人批评 Electron “只是一个基本的包装”,但它有明显的好处: + +* Electron 可以使你能够快速地为 Linux、Windows 和 MacOS 桌面构造 Web 应用。事实上,大多数 Linux 桌面应用都是使用 Electron 构建的。 +* Electron 可以轻松地将桌面客户端与 Web 应用程序达到同样的功能水准。 +* 发布桌面应用程序后,你可以自由使用开发功能添加桌面端特定的功能,从而增强可用性和安全性。 +* 最后但同样重要的是,这是让应用程序具备原生的感觉、融入用户系统,而同时保持其识别度的好方法。 +   +### 满足用户的需求 + +Tutanota 不依靠于大笔的投资资金,而是依靠社区驱动的项目。基于越来越多的用户升级到我们的免费服务的付费计划,我们有机地发展我们的团队。倾听用户的需求不仅对我们很重要,而且对我们的成功至关重要。 + +提供桌面客户端是 Tutanota 用户[最想要的功能][7],我们感到自豪的是,我们现在可以为所有用户提供免费的桌面客户端测试版。(我们还实现了另一个高度要求的功能 —— [搜索加密数据][8] —— 但这是另一个主题了。) + +我们喜欢为用户提供签名版本的 Tutanota 并支持浏览器中无法实现的功能,例如通过后台进程推送通知。 现在,我们计划添加更多特定于桌面的功能,例如 IMAP 支持(而不依赖于我们的服务器充当代理),自动备份和离线可用性。 + +我们选择 Electron 是因为它的 Chromium 和 Node.js 的组合最适合我们的小型开发团队,因为它只需要对我们的 Web 应用程序进行最小的更改。在我们开始使用时,可以将浏览器 API 用于所有功能特别有用,随着我们的进展,慢慢地用更多原生版本替换这些组件。这种方法对附件下载和通知特别方便。 + +### 调整安全性 + +我们知道有些人关注 Electron 的安全问题,但我们发现 Electron 在 Web 应用程序中微调访问的选项非常令人满意。你可以使用 Electron 的[安全文档][9]和 Luca Carettoni 的[Electron 安全清单][10]等资源,来帮助防止 Web 应用程序中不受信任的内容发生灾难性事故。 + +### 实现特定功能 + +Tutanota Web 客户端从一开始就构建了一个用于进程间通信的可靠协议。我们利用 Web 线程在加密和请求数据时保持用户界面(UI)响应性。当我们开始实现我们的移动应用时,这就派上用场,这些应用程序使用相同的协议在原生部分和 Web 视图之间进行通信。 + +这就是为什么当我们开始构建桌面客户端时,很多用于本机推送通知、打开邮箱和使用文件系统的部分等已经存在,因此只需要实现原生端(Node.js)。 + +另一个便利是我们的构建过程使用 [Babel 转译器][11],它允许我们以现代 ES6 JavaScript 编写整个代码库,并在不同环境之间混合和匹配功能模块。这使我们能够快速调整基于 Electron 的桌面应用程序的代码。但是,我们也遇到了一些挑战。 + +### 克服挑战 + +虽然 Electron 允许我们很容易地与不同平台的桌面环境集成,但你不能低估投入的时间!最后,正是这些小事情占用了比我们预期更多的时间,但对完成桌面客户端项目也至关重要。 + +特定于平台的代码导致了大部分阻碍: + +* 例如,窗口管理和托盘仍然在三个平台上以略有不同的方式处理。 +* 注册 Tutanota 作为默认邮件程序并设置自动启动需要深入 Windows 注册表,同时确保以 [UAC] [12] 兼容的方式提示用户进行管理员访问。 +* 我们需要使用 Electron 的 API 作为快捷方式和菜单,以提供复制、粘贴、撤消和重做等标准功能。 + +由于用户对不同平台上的应用程序的某些(有时不直接兼容)行为的期望,此过程有点复杂。使三个版本感觉像原生的需要一些迭代,甚至需要对 Web 应用程序进行一些适度的补充,以提供类似于浏览器中的文本搜索的功能。 + +### 总结 + +我们在 Electron 方面的经验基本上是积极的,我们在不到四个月的时间内完成了该项目。尽管有一些相当耗时的功能,但我们感到惊讶的是,我们可以轻松地为 Linux 提供一个测试版的 [Tutanota 桌面客户端][13]。如果你有兴趣,可以深入了解 [GitHub][14] 上的源代码。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/linux-desktop-electron + +作者:[Nils Ganther][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/nils-ganther +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_paper_envelope_document.png?itok=uPj_kouJ (document sending) +[2]: https://tutanota.com/ +[3]: https://f-droid.org/en/packages/de.tutao.tutanota/ +[4]: https://electronjs.org/ +[5]: https://github.com/systemjs/systemjs +[6]: https://mithril.js.org/ +[7]: https://tutanota.uservoice.com/forums/237921-general/filters/top?status_id=1177482 +[8]: https://tutanota.com/blog/posts/first-search-encrypted-data/ +[9]: https://electronjs.org/docs/tutorial/security +[10]: https://www.blackhat.com/docs/us-17/thursday/us-17-Carettoni-Electronegativity-A-Study-Of-Electron-Security-wp.pdf +[11]: https://babeljs.io/ +[12]: https://en.wikipedia.org/wiki/User_Account_Control +[13]: https://tutanota.com/blog/posts/desktop-clients/ +[14]: https://www.github.com/tutao/tutanota diff --git a/published/201906/20190411 Be your own certificate authority.md b/published/201906/20190411 Be your own certificate authority.md new file mode 100644 index 0000000000..e5f09b6935 --- /dev/null +++ b/published/201906/20190411 Be your own certificate authority.md @@ -0,0 +1,135 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10921-1.html) +[#]: subject: (Be your own certificate authority) +[#]: via: (https://opensource.com/article/19/4/certificate-authority) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez/users/elenajon123) + + +自己成为一个证书颁发机构(CA) +====== + +> 为你的微服务架构或者集成测试创建一个简单的内部 CA。 + +![](https://img.linux.net.cn/data/attachment/album/201905/31/091023sg9s0ss11rsoseqg.jpg) + +传输层安全([TLS][2])模型(有时也称它的旧名称 SSL)基于[证书颁发机构][3]certificate authoritie(CA)的概念。这些机构受到浏览器和操作系统的信任,从而*签名*服务器的的证书以用于验证其所有权。 + +但是,对于内部网络,微服务架构或集成测试,有时候*本地 CA*更有用:一个只在内部受信任的 CA,然后签名本地服务器的证书。 + +这对集成测试特别有意义。获取证书可能会带来负担,因为这会占用服务器几分钟。但是在代码中使用“忽略证书”可能会被引入到生产环境,从而导致安全灾难。 + +CA 证书与常规服务器证书没有太大区别。重要的是它被本地代码信任。例如,在 Python `requests` 库中,可以通过将 `REQUESTS_CA_BUNDLE` 变量设置为包含此证书的目录来完成。 + +在为集成测试创建证书的例子中,不需要*长期的*证书:如果你的集成测试需要超过一天,那么你应该已经测试失败了。 + +因此,计算**昨天**和**明天**作为有效期间隔: + +``` +>>> import datetime +>>> one_day = datetime.timedelta(days=1) +>>> today = datetime.date.today() +>>> yesterday = today - one_day +>>> tomorrow = today - one_day +``` + +现在你已准备好创建一个简单的 CA 证书。你需要生成私钥,创建公钥,设置 CA 的“参数”,然后自签名证书:CA 证书*总是*自签名的。最后,导出证书文件以及私钥文件。 + +``` +from cryptography.hazmat.primitives.asymmetric import rsa +from cryptography.hazmat.primitives import hashes, serialization +from cryptography import x509 +from cryptography.x509.oid import NameOID + + +private_key = rsa.generate_private_key( + public_exponent=65537, + key_size=2048, + backend=default_backend() +) +public_key = private_key.public_key() +builder = x509.CertificateBuilder() +builder = builder.subject_name(x509.Name([ + x509.NameAttribute(NameOID.COMMON_NAME, 'Simple Test CA'), +])) +builder = builder.issuer_name(x509.Name([ + x509.NameAttribute(NameOID.COMMON_NAME, 'Simple Test CA'), +])) +builder = builder.not_valid_before(yesterday) +builder = builder.not_valid_after(tomorrow) +builder = builder.serial_number(x509.random_serial_number()) +builder = builder.public_key(public_key) +builder = builder.add_extension( + x509.BasicConstraints(ca=True, path_length=None), + critical=True) +certificate = builder.sign( + private_key=private_key, algorithm=hashes.SHA256(), + backend=default_backend() +) +private_bytes = private_key.private_bytes( + encoding=serialization.Encoding.PEM, + format=serialization.PrivateFormat.TraditionalOpenSSL, + encryption_algorithm=serialization.NoEncrption()) +public_bytes = certificate.public_bytes( + encoding=serialization.Encoding.PEM) +with open("ca.pem", "wb") as fout: + fout.write(private_bytes + public_bytes) +with open("ca.crt", "wb") as fout: + fout.write(public_bytes) +``` + +通常,真正的 CA 会需要[证书签名请求][4](CSR)来签名证书。但是,当你是自己的 CA 时,你可以制定自己的规则!可以径直签名你想要的内容。 + +继续集成测试的例子,你可以创建私钥并立即签名相应的公钥。注意 `COMMON_NAME` 需要是 `https` URL 中的“服务器名称”。如果你已配置名称查询,你需要服务器能响应对 `service.test.local` 的请求。 + +``` +service_private_key = rsa.generate_private_key( + public_exponent=65537, + key_size=2048, + backend=default_backend() +) +service_public_key = service_private_key.public_key() +builder = x509.CertificateBuilder() +builder = builder.subject_name(x509.Name([ + x509.NameAttribute(NameOID.COMMON_NAME, 'service.test.local') +])) +builder = builder.not_valid_before(yesterday) +builder = builder.not_valid_after(tomorrow) +builder = builder.public_key(public_key) +certificate = builder.sign( + private_key=private_key, algorithm=hashes.SHA256(), + backend=default_backend() +) +private_bytes = service_private_key.private_bytes( + encoding=serialization.Encoding.PEM, + format=serialization.PrivateFormat.TraditionalOpenSSL, + encryption_algorithm=serialization.NoEncrption()) +public_bytes = certificate.public_bytes( + encoding=serialization.Encoding.PEM) +with open("service.pem", "wb") as fout: + fout.write(private_bytes + public_bytes) +``` + +现在 `service.pem` 文件有一个私钥和一个“有效”的证书:它已由本地的 CA 签名。该文件的格式可以给 Nginx、HAProxy 或大多数其他 HTTPS 服务器使用。 + +通过将此逻辑用在测试脚本中,只要客户端配置信任该 CA,那么就可以轻松创建看起来真实的 HTTPS 服务器。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/certificate-authority + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez/users/elenajon123 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_commun_4604_02_mech_connections_rhcz0.5x.png?itok=YPPU4dMj +[2]: https://en.wikipedia.org/wiki/Transport_Layer_Security +[3]: https://en.wikipedia.org/wiki/Certificate_authority +[4]: https://en.wikipedia.org/wiki/Certificate_signing_request diff --git a/published/201906/20190417 Inter-process communication in Linux- Sockets and signals.md b/published/201906/20190417 Inter-process communication in Linux- Sockets and signals.md new file mode 100644 index 0000000000..7a4c304246 --- /dev/null +++ b/published/201906/20190417 Inter-process communication in Linux- Sockets and signals.md @@ -0,0 +1,374 @@ +[#]: collector: "lujun9972" +[#]: translator: "FSSlc" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-10930-1.html" +[#]: subject: "Inter-process communication in Linux: Sockets and signals" +[#]: via: "https://opensource.com/article/19/4/interprocess-communication-linux-networking" +[#]: author: "Marty Kalin https://opensource.com/users/mkalindepauledu" + +Linux 下的进程间通信:套接字和信号 +====== + +> 学习在 Linux 中进程是如何与其他进程进行同步的。 + +![](https://img.linux.net.cn/data/attachment/album/201906/02/234437y6gig4tg4yy94356.jpg) + +本篇是 Linux 下[进程间通信][1](IPC)系列的第三篇同时也是最后一篇文章。[第一篇文章][2]聚焦在通过共享存储(文件和共享内存段)来进行 IPC,[第二篇文章][3]则通过管道(无名的或者命名的)及消息队列来达到相同的目的。这篇文章将目光从高处(套接字)然后到低处(信号)来关注 IPC。代码示例将用力地充实下面的解释细节。 + +### 套接字 + +正如管道有两种类型(命名和无名)一样,套接字也有两种类型。IPC 套接字(即 Unix 套接字)给予进程在相同设备(主机)上基于通道的通信能力;而网络套接字给予进程运行在不同主机的能力,因此也带来了网络通信的能力。网络套接字需要底层协议的支持,例如 TCP(传输控制协议)或 UDP(用户数据报协议)。 + +与之相反,IPC 套接字依赖于本地系统内核的支持来进行通信;特别的,IPC 通信使用一个本地的文件作为套接字地址。尽管这两种套接字的实现有所不同,但在本质上,IPC 套接字和网络套接字的 API 是一致的。接下来的例子将包含网络套接字的内容,但示例服务器和客户端程序可以在相同的机器上运行,因为服务器使用了 `localhost`(127.0.0.1)这个网络地址,该地址表示的是本地机器上的本地机器地址。 + +套接字以流的形式(下面将会讨论到)被配置为双向的,并且其控制遵循 C/S(客户端/服务器端)模式:客户端通过尝试连接一个服务器来初始化对话,而服务器端将尝试接受该连接。假如万事顺利,来自客户端的请求和来自服务器端的响应将通过管道进行传输,直到其中任意一方关闭该通道,从而断开这个连接。 + +一个迭代服务器(只适用于开发)将一直和连接它的客户端打交道:从最开始服务第一个客户端,然后到这个连接关闭,然后服务第二个客户端,循环往复。这种方式的一个缺点是处理一个特定的客户端可能会挂起,使得其他的客户端一直在后面等待。生产级别的服务器将是并发的,通常使用了多进程或者多线程的混合。例如,我台式机上的 Nginx 网络服务器有一个 4 个工人worker的进程池,它们可以并发地处理客户端的请求。在下面的代码示例中,我们将使用迭代服务器,使得我们将要处理的问题保持在一个很小的规模,只关注基本的 API,而不去关心并发的问题。 + +最后,随着各种 POSIX 改进的出现,套接字 API 随着时间的推移而发生了显著的变化。当前针对服务器端和客户端的示例代码特意写的比较简单,但是它着重强调了基于流的套接字中连接的双方。下面是关于流控制的一个总结,其中服务器端在一个终端中开启,而客户端在另一个不同的终端中开启: + + * 服务器端等待客户端的连接,对于给定的一个成功连接,它就读取来自客户端的数据。 + * 为了强调是双方的会话,服务器端会对接收自客户端的数据做回应。这些数据都是 ASCII 字符代码,它们组成了一些书的标题。 + * 客户端将书的标题写给服务器端的进程,并从服务器端的回应中读取到相同的标题。然后客户端和服务器端都在屏幕上打印出标题。下面是服务器端的输出,客户端的输出也和它完全一样: + +``` +Listening on port 9876 for clients... +War and Peace +Pride and Prejudice +The Sound and the Fury +``` + +#### 示例 1. 使用套接字的客户端程序 + +```c +#include +#include +#include +#include +#include +#include +#include +#include +#include "sock.h" + +void report(const char* msg, int terminate) { + perror(msg); + if (terminate) exit(-1); /* failure */ +} + +int main() { + int fd = socket(AF_INET, /* network versus AF_LOCAL */ + SOCK_STREAM, /* reliable, bidirectional: TCP */ + 0); /* system picks underlying protocol */ + if (fd < 0) report("socket", 1); /* terminate */ + + /* bind the server's local address in memory */ + struct sockaddr_in saddr; + memset(&saddr, 0, sizeof(saddr)); /* clear the bytes */ + saddr.sin_family = AF_INET; /* versus AF_LOCAL */ + saddr.sin_addr.s_addr = htonl(INADDR_ANY); /* host-to-network endian */ + saddr.sin_port = htons(PortNumber); /* for listening */ + + if (bind(fd, (struct sockaddr *) &saddr, sizeof(saddr)) < 0) + report("bind", 1); /* terminate */ + + /* listen to the socket */ + if (listen(fd, MaxConnects) < 0) /* listen for clients, up to MaxConnects */ + report("listen", 1); /* terminate */ + + fprintf(stderr, "Listening on port %i for clients...\n", PortNumber); + /* a server traditionally listens indefinitely */ + while (1) { + struct sockaddr_in caddr; /* client address */ + int len = sizeof(caddr); /* address length could change */ + + int client_fd = accept(fd, (struct sockaddr*) &caddr, &len); /* accept blocks */ + if (client_fd < 0) { + report("accept", 0); /* don't terminated, though there's a problem */ + continue; + } + + /* read from client */ + int i; + for (i = 0; i < ConversationLen; i++) { + char buffer[BuffSize + 1]; + memset(buffer, '\0', sizeof(buffer)); + int count = read(client_fd, buffer, sizeof(buffer)); + if (count > 0) { + puts(buffer); + write(client_fd, buffer, sizeof(buffer)); /* echo as confirmation */ + } + } + close(client_fd); /* break connection */ + } /* while(1) */ + return 0; +} +``` + +上面的服务器端程序执行典型的 4 个步骤来准备回应客户端的请求,然后接受其他的独立请求。这里每一个步骤都以服务器端程序调用的系统函数来命名。 + + 1. `socket(…)`:为套接字连接获取一个文件描述符 + 2. `bind(…)`:将套接字和服务器主机上的一个地址进行绑定 + 3. `listen(…)`:监听客户端请求 + 4. `accept(…)`:接受一个特定的客户端请求 + +上面的 `socket` 调用的完整形式为: + +``` +int sockfd = socket(AF_INET,      /* versus AF_LOCAL */ +                    SOCK_STREAM,  /* reliable, bidirectional */ +                    0);           /* system picks protocol (TCP) */ +``` + +第一个参数特别指定了使用的是一个网络套接字,而不是 IPC 套接字。对于第二个参数有多种选项,但 `SOCK_STREAM` 和 `SOCK_DGRAM`(数据报)是最为常用的。基于流的套接字支持可信通道,在这种通道中如果发生了信息的丢失或者更改,都将会被报告。这种通道是双向的,并且从一端到另外一端的有效载荷在大小上可以是任意的。相反的,基于数据报的套接字大多是不可信的,没有方向性,并且需要固定大小的载荷。`socket` 的第三个参数特别指定了协议。对于这里展示的基于流的套接字,只有一种协议选择:TCP,在这里表示的 `0`。因为对 `socket` 的一次成功调用将返回相似的文件描述符,套接字可以被读写,对应的语法和读写一个本地文件是类似的。 + +对 `bind` 的调用是最为复杂的,因为它反映出了在套接字 API 方面上的各种改进。我们感兴趣的点是这个调用将一个套接字和服务器端所在机器中的一个内存地址进行绑定。但对 `listen` 的调用就非常直接了: + +``` +if (listen(fd, MaxConnects) < 0) +``` + +第一个参数是套接字的文件描述符,第二个参数则指定了在服务器端处理一个拒绝连接错误之前,有多少个客户端连接被允许连接。(在头文件 `sock.h` 中 `MaxConnects` 的值被设置为 `8`。) + +`accept` 调用默认将是一个阻塞等待:服务器端将不做任何事情直到一个客户端尝试连接它,然后进行处理。`accept` 函数返回的值如果是 `-1` 则暗示有错误发生。假如这个调用是成功的,则它将返回另一个文件描述符,这个文件描述符被用来指代另一个可读可写的套接字,它与 `accept` 调用中的第一个参数对应的接收套接字有所不同。服务器端使用这个可读可写的套接字来从客户端读取请求然后写回它的回应。接收套接字只被用于接受客户端的连接。 + +在设计上,服务器端可以一直运行下去。当然服务器端可以通过在命令行中使用 `Ctrl+C` 来终止它。 + +#### 示例 2. 使用套接字的客户端 + +```c +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sock.h" + +const char* books[] = {"War and Peace", + "Pride and Prejudice", + "The Sound and the Fury"}; + +void report(const char* msg, int terminate) { + perror(msg); + if (terminate) exit(-1); /* failure */ +} + +int main() { + /* fd for the socket */ + int sockfd = socket(AF_INET, /* versus AF_LOCAL */ + SOCK_STREAM, /* reliable, bidirectional */ + 0); /* system picks protocol (TCP) */ + if (sockfd < 0) report("socket", 1); /* terminate */ + + /* get the address of the host */ + struct hostent* hptr = gethostbyname(Host); /* localhost: 127.0.0.1 */ + if (!hptr) report("gethostbyname", 1); /* is hptr NULL? */ + if (hptr->h_addrtype != AF_INET) /* versus AF_LOCAL */ + report("bad address family", 1); + + /* connect to the server: configure server's address 1st */ + struct sockaddr_in saddr; + memset(&saddr, 0, sizeof(saddr)); + saddr.sin_family = AF_INET; + saddr.sin_addr.s_addr = + ((struct in_addr*) hptr->h_addr_list[0])->s_addr; + saddr.sin_port = htons(PortNumber); /* port number in big-endian */ + + if (connect(sockfd, (struct sockaddr*) &saddr, sizeof(saddr)) < 0) + report("connect", 1); + + /* Write some stuff and read the echoes. */ + puts("Connect to server, about to write some stuff..."); + int i; + for (i = 0; i < ConversationLen; i++) { + if (write(sockfd, books[i], strlen(books[i])) > 0) { + /* get confirmation echoed from server and print */ + char buffer[BuffSize + 1]; + memset(buffer, '\0', sizeof(buffer)); + if (read(sockfd, buffer, sizeof(buffer)) > 0) + puts(buffer); + } + } + puts("Client done, about to exit..."); + close(sockfd); /* close the connection */ + return 0; +} +``` + +客户端程序的设置代码和服务器端类似。两者主要的区别既不是在于监听也不在于接收,而是连接: + +``` +if (connect(sockfd, (struct sockaddr*) &saddr, sizeof(saddr)) < 0) +``` + +对 `connect` 的调用可能因为多种原因而导致失败,例如客户端拥有错误的服务器端地址或者已经有太多的客户端连接上了服务器端。假如 `connect` 操作成功,客户端将在一个 `for` 循环中,写入它的请求然后读取返回的响应。在会话后,服务器端和客户端都将调用 `close` 去关闭这个可读可写套接字,尽管任何一边的关闭操作就足以关闭它们之间的连接。此后客户端可以退出了,但正如前面提到的那样,服务器端可以一直保持开放以处理其他事务。 + +从上面的套接字示例中,我们看到了请求信息被回显给客户端,这使得客户端和服务器端之间拥有进行丰富对话的可能性。也许这就是套接字的主要魅力。在现代系统中,客户端应用(例如一个数据库客户端)和服务器端通过套接字进行通信非常常见。正如先前提及的那样,本地 IPC 套接字和网络套接字只在某些实现细节上面有所不同,一般来说,IPC 套接字有着更低的消耗和更好的性能。它们的通信 API 基本是一样的。 + +### 信号 + +信号会中断一个正在执行的程序,在这种意义下,就是用信号与这个程序进行通信。大多数的信号要么可以被忽略(阻塞)或者被处理(通过特别设计的代码)。`SIGSTOP` (暂停)和 `SIGKILL`(立即停止)是最应该提及的两种信号。这种符号常量有整数类型的值,例如 `SIGKILL` 对应的值为 `9`。 + +信号可以在与用户交互的情况下发生。例如,一个用户从命令行中敲了 `Ctrl+C` 来终止一个从命令行中启动的程序;`Ctrl+C` 将产生一个 `SIGTERM` 信号。`SIGTERM` 意即终止,它可以被阻塞或者被处理,而不像 `SIGKILL` 信号那样。一个进程也可以通过信号和另一个进程通信,这样使得信号也可以作为一种 IPC 机制。 + +考虑一下一个多进程应用,例如 Nginx 网络服务器是如何被另一个进程优雅地关闭的。`kill` 函数: + +``` +int kill(pid_t pid, int signum); /* declaration */ +``` + +可以被一个进程用来终止另一个进程或者一组进程。假如 `kill` 函数的第一个参数是大于 `0` 的,那么这个参数将会被认为是目标进程的 `pid`(进程 ID),假如这个参数是 `0`,则这个参数将会被视作信号发送者所属的那组进程。 + +`kill` 的第二个参数要么是一个标准的信号数字(例如 `SIGTERM` 或 `SIGKILL`),要么是 `0` ,这将会对信号做一次询问,确认第一个参数中的 `pid` 是否是有效的。这样优雅地关闭一个多进程应用就可以通过向组成该应用的一组进程发送一个终止信号来完成,具体来说就是调用一个 `kill` 函数,使得这个调用的第二个参数是 `SIGTERM` 。(Nginx 主进程可以通过调用 `kill` 函数来终止其他工人进程,然后再停止自己。)就像许多库函数一样,`kill` 函数通过一个简单的可变语法拥有更多的能力和灵活性。 + +#### 示例 3. 一个多进程系统的优雅停止 + +```c +#include +#include +#include +#include +#include + +void graceful(int signum) { +  printf("\tChild confirming received signal: %i\n", signum); +  puts("\tChild about to terminate gracefully..."); +  sleep(1); +  puts("\tChild terminating now..."); +  _exit(0); /* fast-track notification of parent */ +} + +void set_handler() { +  struct sigaction current; +  sigemptyset(¤t.sa_mask);         /* clear the signal set */ +  current.sa_flags = 0;                  /* enables setting sa_handler, not sa_action */ +  current.sa_handler = graceful;         /* specify a handler */ +  sigaction(SIGTERM, ¤t, NULL);    /* register the handler */ +} + +void child_code() { +  set_handler(); + +  while (1) {   /` loop until interrupted `/ +    sleep(1); +    puts("\tChild just woke up, but going back to sleep."); +  } +} + +void parent_code(pid_t cpid) { +  puts("Parent sleeping for a time..."); +  sleep(5); + +  /* Try to terminate child. */ +  if (-1 == kill(cpid, SIGTERM)) { +    perror("kill"); +    exit(-1); +  } +  wait(NULL); /` wait for child to terminate `/ +  puts("My child terminated, about to exit myself..."); +} + +int main() { +  pid_t pid = fork(); +  if (pid < 0) { +    perror("fork"); +    return -1; /* error */ +  } +  if (0 == pid) +    child_code(); +  else +    parent_code(pid); +  return 0;  /* normal */ +} +``` + +上面的停止程序模拟了一个多进程系统的优雅退出,在这个例子中,这个系统由一个父进程和一个子进程组成。这次模拟的工作流程如下: + + * 父进程尝试去 `fork` 一个子进程。假如这个 `fork` 操作成功了,每个进程就执行它自己的代码:子进程就执行函数 `child_code`,而父进程就执行函数 `parent_code`。 + * 子进程将会进入一个潜在的无限循环,在这个循环中子进程将睡眠一秒,然后打印一个信息,接着再次进入睡眠状态,以此循环往复。来自父进程的一个 `SIGTERM` 信号将引起子进程去执行一个信号处理回调函数 `graceful`。这样这个信号就使得子进程可以跳出循环,然后进行子进程和父进程之间的优雅终止。在终止之前,进程将打印一个信息。 + * 在 `fork` 一个子进程后,父进程将睡眠 5 秒,使得子进程可以执行一会儿;当然在这个模拟中,子进程大多数时间都在睡眠。然后父进程调用 `SIGTERM` 作为第二个参数的 `kill` 函数,等待子进程的终止,然后自己再终止。 + +下面是一次运行的输出: + +``` +% ./shutdown +Parent sleeping for a time... +        Child just woke up, but going back to sleep. +        Child just woke up, but going back to sleep. +        Child just woke up, but going back to sleep. +        Child just woke up, but going back to sleep. +        Child confirming received signal: 15  ## SIGTERM is 15 +        Child about to terminate gracefully... +        Child terminating now... +My child terminated, about to exit myself... +``` + +对于信号的处理,上面的示例使用了 `sigaction` 库函数(POSIX 推荐的用法)而不是传统的 `signal` 函数,`signal` 函数有移植性问题。下面是我们主要关心的代码片段: + +* 假如对 `fork` 的调用成功了,父进程将执行 `parent_code` 函数,而子进程将执行 `child_code` 函数。在给子进程发送信号之前,父进程将会等待 5 秒: + + ``` +puts("Parent sleeping for a time..."); +sleep(5); +if (-1 == kill(cpid, SIGTERM)) { +...sleepkillcpidSIGTERM... +``` + + 假如 `kill` 调用成功了,父进程将在子进程终止时做等待,使得子进程不会变成一个僵尸进程。在等待完成后,父进程再退出。 + +* `child_code` 函数首先调用 `set_handler` 然后进入它的可能永久睡眠的循环。下面是我们将要查看的 `set_handler` 函数: + + ``` +void set_handler() { +  struct sigaction current;            /* current setup */ +  sigemptyset(¤t.sa_mask);       /* clear the signal set */ +  current.sa_flags = 0;                /* for setting sa_handler, not sa_action */ +  current.sa_handler = graceful;       /* specify a handler */ +  sigaction(SIGTERM, ¤t, NULL);  /* register the handler */ +} +``` + + 上面代码的前三行在做相关的准备。第四个语句将为 `graceful` 设定为句柄,它将在调用 `_exit` 来停止之前打印一些信息。第 5 行和最后一行的语句将通过调用 `sigaction` 来向系统注册上面的句柄。`sigaction` 的第一个参数是 `SIGTERM` ,用作终止;第二个参数是当前的 `sigaction` 设定,而最后的参数(在这个例子中是 `NULL` )可被用来保存前面的 `sigaction` 设定,以备后面的可能使用。 + +使用信号来作为 IPC 的确是一个很轻量的方法,但确实值得尝试。通过信号来做 IPC 显然可以被归入 IPC 工具箱中。 + +### 这个系列的总结 + +在这个系列中,我们通过三篇有关 IPC 的文章,用示例代码介绍了如下机制: + + * 共享文件 + * 共享内存(通过信号量) + * 管道(命名和无名) + * 消息队列 + * 套接字 + * 信号 + +甚至在今天,在以线程为中心的语言,例如 Java、C# 和 Go 等变得越来越流行的情况下,IPC 仍然很受欢迎,因为相比于使用多线程,通过多进程来实现并发有着一个明显的优势:默认情况下,每个进程都有它自己的地址空间,除非使用了基于共享内存的 IPC 机制(为了达到安全的并发,竞争条件在多线程和多进程的时候必须被加上锁),在多进程中可以排除掉基于内存的竞争条件。对于任何一个写过即使是基本的通过共享变量来通信的多线程程序的人来说,他都会知道想要写一个清晰、高效、线程安全的代码是多么具有挑战性。使用单线程的多进程的确是很有吸引力的,这是一个切实可行的方式,使用它可以利用好今天多处理器的机器,而不需要面临基于内存的竞争条件的风险。 + +当然,没有一个简单的答案能够回答上述 IPC 机制中的哪一个更好。在编程中每一种 IPC 机制都会涉及到一个取舍问题:是追求简洁,还是追求功能强大。以信号来举例,它是一个相对简单的 IPC 机制,但并不支持多个进程之间的丰富对话。假如确实需要这样的对话,另外的选择可能会更合适一些。带有锁的共享文件则相对直接,但是当要处理大量共享的数据流时,共享文件并不能很高效地工作。管道,甚至是套接字,有着更复杂的 API,可能是更好的选择。让具体的问题去指导我们的选择吧。 + +尽管所有的示例代码(可以在[我的网站][4]上获取到)都是使用 C 写的,其他的编程语言也经常提供这些 IPC 机制的轻量包装。这些代码示例都足够短小简单,希望这样能够鼓励你去进行实验。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/interprocess-communication-linux-networking + +作者:[Marty Kalin][a] +选题:[lujun9972][b] +译者:[FSSlc](https://github.com/FSSlc) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mkalindepauledu +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Inter-process_communication +[2]: https://linux.cn/article-10826-1.html +[3]: https://linux.cn/article-10845-1.html +[4]: http://condor.depaul.edu/mkalin diff --git a/published/201906/20190422 4 open source apps for plant-based diets.md b/published/201906/20190422 4 open source apps for plant-based diets.md new file mode 100644 index 0000000000..7399627ee1 --- /dev/null +++ b/published/201906/20190422 4 open source apps for plant-based diets.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10926-1.html) +[#]: subject: (4 open source apps for plant-based diets) +[#]: via: (https://opensource.com/article/19/4/apps-plant-based-diets) +[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) + +4 款“吃草”的开源应用 +====== + +> 这些应用使素食者、纯素食主义者和那些想吃得更健康的杂食者找到可以吃的食物。 + +![](https://img.linux.net.cn/data/attachment/album/201906/01/193302nompumppxnmnxirz.jpg) + +减少对肉类、乳制品和加工食品的消费对地球来说更好,也对你的健康更有益。改变你的饮食习惯可能很困难,但是一些开源的 Android 应用可以让你吃的更清淡。无论你是参加[无肉星期一][2]、践行 Mark Bittman 的 [6:00 前的素食][3]指南,还是完全切换到[植物全食饮食][4]whole-food, plant-based diet(WFPB),这些应用能帮助你找出要吃什么、发现素食和素食友好的餐馆,并轻松地将你的饮食偏好传达给他人,来助你更好地走这条路。所有这些应用都是开源的,可从 [F-Droid 仓库][5]下载。 + +### Daily Dozen + +![Daily Dozen app][6] + +[Daily Dozen][7] 提供了医学博士、美国法医学会院士(FACLM) Michael Greger 推荐的项目清单作为健康饮食和生活方式的一部分。Greger 博士建议食用由多种食物组成的基于植物的全食饮食,并坚持日常锻炼。该应用可以让你跟踪你吃的每种食物的份数,你喝了多少份水(或其他获准的饮料,如茶),以及你是否每天锻炼。每类食物都提供食物分量和属于该类别的食物清单。例如,十字花科蔬菜类包括白菜、花椰菜、抱子甘蓝等许多其他建议。 + +### Food Restrictions + +![Food Restrictions app][8] + +[Food Restrictions][9] 是一个简单的应用,它可以帮助你将你的饮食限制传达给他人,即使这些人不会说你的语言。用户可以输入七种不同类别的食物限制:鸡肉、牛肉、猪肉、鱼、奶酪、牛奶和辣椒。每种类别都有“我不吃”和“我过敏”选项。“不吃”选项会显示带有红色 X 的图标。“过敏” 选项显示 “X” 和小骷髅图标。可以使用文本而不是图标显示相同的信息,但文本仅提供英语和葡萄牙语。还有一个选项可以显示一条文字信息,说明用户是素食主义者或纯素食主义者,它比选择选项更简洁、更准确地总结了这些饮食限制。纯素食主义者的文本清楚地提到不吃鸡蛋和蜂蜜,这在选择选项中是没有的。但是,就像选择选项方式的文字版本一样,这些句子仅提供英语和葡萄牙语。 + +### OpenFoodFacts + +![Open Food Facts app][10] + +购买杂货时避免买入不必要的成分可能令人沮丧,但 [OpenFoodFacts][11] 可以帮助简化流程。该应用可让你扫描产品上的条形码,以获得有关产品成分和是否健康的报告。即使产品符合纯素产品的标准,产品仍然可能非常不健康。拥有成分列表和营养成分可让你在购物时做出明智的选择。此应用的唯一缺点是数据是用户贡献的,因此并非每个产品都可有数据,但如果你想回馈项目,你可以贡献新数据。 + +### OpenVegeMap + +![OpenVegeMap app][12] + +使用 [OpenVegeMap][13] 查找你附近的纯素食或素食主义餐厅。此应用可以通过手机的当前位置或者输入地址来搜索。餐厅分类为仅限纯素食者、适合纯素食者,仅限素食主义者,适合素食者,非素食和未知。该应用使用来自 [OpenStreetMap][14] 的数据和用户提供的有关餐馆的信息,因此请务必仔细检查以确保所提供的信息是最新且准确的。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/apps-plant-based-diets + +作者:[Joshua Allen Holm][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/holmja +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003588_01_rd3os.combacktoschoolserieshe_rh_041x_0.png?itok=tfg6_I78 +[2]: https://www.meatlessmonday.com/ +[3]: https://www.amazon.com/dp/0385344740/ +[4]: https://nutritionstudies.org/whole-food-plant-based-diet-guide/ +[5]: https://f-droid.org/ +[6]: https://opensource.com/sites/default/files/uploads/daily_dozen.png (Daily Dozen app) +[7]: https://f-droid.org/en/packages/org.nutritionfacts.dailydozen/ +[8]: https://opensource.com/sites/default/files/uploads/food_restrictions.png (Food Restrictions app) +[9]: https://f-droid.org/en/packages/br.com.frs.foodrestrictions/ +[10]: https://opensource.com/sites/default/files/uploads/openfoodfacts.png (Open Food Facts app) +[11]: https://f-droid.org/en/packages/openfoodfacts.github.scrachx.openfood/ +[12]: https://opensource.com/sites/default/files/uploads/openvegmap.png (OpenVegeMap app) +[13]: https://f-droid.org/en/packages/pro.rudloff.openvegemap/ +[14]: https://www.openstreetmap.org/ diff --git a/published/201906/20190423 Edge computing is in most industries- future.md b/published/201906/20190423 Edge computing is in most industries- future.md new file mode 100644 index 0000000000..c27a689af9 --- /dev/null +++ b/published/201906/20190423 Edge computing is in most industries- future.md @@ -0,0 +1,59 @@ +[#]: collector: (lujun9972) +[#]: translator: (ninifly) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11009-1.html) +[#]: subject: (Edge computing is in most industries’ future) +[#]: via: (https://www.networkworld.com/article/3391016/edge-computing-is-in-most-industries-future.html) +[#]: author: (Anne Taylor https://www.networkworld.com/author/Anne-Taylor/) + +边缘计算是大多数行业的未来 +====== + +> 几乎每个行业都可以利用边缘计算来加速数字化转型。 + +![](https://img.linux.net.cn/data/attachment/album/201906/23/231224cdl3kwedn0hw2lie.jpg) + +边缘计算的发展将取得一次巨大的飞跃。[据 Gartner 数据][2],现在公司有 10% 的数据是在传统数据中心或云之外生成的。但在未来六年内,这一比例将升至 75%。 + +这很大程度上取决于处理来自设备数据的需要,比如物联网(IoT)数据传感器。早期采用这一方法的包括: + +* **制造商**:设备与传感器似乎是这个行业特有的,因此需要为产生的数据找到更快速的方法也就不足为奇。一份 [Automation World][3] 最近的研究发现 43% 的制造商已经部署了边缘计算项目。最常用用途包括生产/制造数据分析与设备数据分析。 +* **零售商**:与大多数深受数字化运营需求影响的产业一样,零售商也不得不革新了其客户体验。为此,这些组织“正在积极投资贴近于买家的计算能力”,施耐德电气公司 IT 部门执行副总裁 [Dave Johnson][4] 如是说。他列举了一些例子,例如在试衣间的增强现实(AR)镜子,提供了不同的服装选择,而不用顾客试用这些服装。又如用于显示店内导航的基于信标的热图。 +* **医疗保健机构**:随着医疗保健成本的不断上升,这一行业已经具备了提高生产能力与成本效率方面的创新能力。管理咨询公司[麦肯锡已经确定][5],至少有 11 个有益于患者、医疗机构或两者的医疗保健用例。举两个例子:提高护理效率并有助于优化设备的跟踪移动医疗设备;跟踪用户锻炼并提供健康建议的可穿戴设备。 + +虽然以上这些是明显的用例,随着边缘计算市场的扩大,采用它的行业也会增加。 + +### 数字化转型的优势 + +随着边缘计算的快速处理能力完全符合数字化转型的目标:提高效率、生产能力和加速产品上市和客户体验。以下是一些有潜力的应用及将被边缘计算改变的行业: + +**农业**:农民和组织已经使用无人机将农田和气候环境传给灌溉设备。其他的应用可能包括了对工人、牲畜和设备的监测与位置跟踪,从而改善生产能力、效率和成本。 + +**能源**:在这一领域有许多的潜在的应用,可以使消费者与供应商都受益。例如,智能电表有助于业主更好地管理能源使用,同时减少电网运营商对手动抄表的需求。同样的,水管上的传感器能够监测到漏水,同时提供实时漏水数据。 + +**金融服务**:银行正在采取交互式 ATM 机,这种交互式 ATM 机能够快速地处理数据以提供更好的用户体验。在管理层次,可以更快速地分析交易数据中的欺诈行为。 + +**物流**:由于消费者需要更快速地交付商品和服务,物流公司将需要转换其地图和寻路功能以获取实时数据,尤其在最后一公里计划和跟踪方面。这可能涉及到基于街道、包裹及汽车的传感器数据传输处理过程。 + +得益于边缘计算,所有行业都有转型的潜力。但是,这将取决于他们如何处理计算基础设施。可以在 [APC.com][6] 找到如何克服任何 IT 阻碍的解决方案。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3391016/edge-computing-is-in-most-industries-future.html + +作者:[Anne Taylor][a] +选题:[lujun9972][b] +译者:[ninifly](https://github.com/ninifly) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Anne-Taylor/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/04/istock-1019389496-100794424-large.jpg +[2]: https://www.gartner.com/smarterwithgartner/what-edge-computing-means-for-infrastructure-and-operations-leaders/ +[3]: https://www.automationworld.com/article/technologies/cloud-computing/its-not-edge-vs-cloud-its-both +[4]: https://blog.schneider-electric.com/datacenter/2018/07/10/why-brick-and-mortar-retail-quickly-establishing-leadership-edge-computing/ +[5]: https://www.mckinsey.com/industries/high-tech/our-insights/new-demand-new-markets-what-edge-computing-means-for-hardware-companies +[6]: https://www.apc.com/us/en/solutions/business-solutions/edge-computing.jsp diff --git a/published/201906/20190423 Epic Games Store is Now Available on Linux Thanks to Lutris.md b/published/201906/20190423 Epic Games Store is Now Available on Linux Thanks to Lutris.md new file mode 100644 index 0000000000..419ad7303b --- /dev/null +++ b/published/201906/20190423 Epic Games Store is Now Available on Linux Thanks to Lutris.md @@ -0,0 +1,137 @@ +[#]: collector: (lujun9972) +[#]: translator: (Modrisco) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10968-1.html) +[#]: subject: (Epic Games Store is Now Available on Linux Thanks to Lutris) +[#]: via: (https://itsfoss.com/epic-games-lutris-linux/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +有了 Lutris,Linux 现在也可以启动 Epic 游戏商城 +====== + +> 开源游戏平台 Lutris 现在使你能够在 Linux 上使用 Epic 游戏商城。我们使用 Ubuntu 19.04 版本进行了测试,以下是我们的使用体验。 + +[在 Linux 上玩游戏][1] 正变得越来越容易。Steam [正在开发中的][3] 特性可以帮助你实现 [在 Linux 上玩 Windows 游戏][2]。 + +如果说 Steam 在 Linux 运行 Windows 游戏领域还是新玩家,而 Lutris 却已从事多年。 + +[Lutris][4] 是一款为 Linux 开发的开源游戏平台,提供诸如 Origin、Steam、战网等平台的游戏安装器。它使用 Wine 来运行 Linux 不能支持的程序。 + +Lutris 近期宣布你可以通过它来运行 Epic 游戏商店。 + +### Lutris 为 Linux 带来了 Epic 游戏 + +![Epic Games Store Lutris Linux][5] + +[Epic 游戏商城][6] 是一个类似 Steam 的电子游戏分销平台。它目前只支持 Windows 和 macOS。 + +Lutris 团队付出了大量努力使 Linux 用户可以通过 Lutris 使用 Epic 游戏商城。虽然我不用 Epic 商城,但可以通过 Lutris 在 Linux 上运行 Epic 商城终归是个好消息。 + +> 好消息! 你现在可以通过 Lutris 安装获得 [@EpicGames][7] 商城在 Linux 下的全功能支持!没有发现任何问题。 [@TimSweeneyEpic][8] 可能会很喜欢 😊 +> +> ![pic.twitter.com/7mt9fXt7TH][9] +> +> — Lutris Gaming (@LutrisGaming) [April 17, 2019][10] + +作为一名狂热的游戏玩家和 Linux 用户,我立即得到了这个消息,并安装了 Lutris 来运行 Epic 游戏。 + +**备注:** 我使用 [Ubuntu 19.04][11] 来测试 Linux 环境下的游戏运行情况。 + +### 通过 Lutris 在 Linux 下使用 Epic 游戏商城 + +为了在你的 Linux 系统中安装 Epic 游戏商城,请确保你已经安装了 Wine 和 Python 3。接下来,[在 Ubuntu 中安装 Wine][12] ,或任何你正在使用的 Linux 发行版本也都可以。然后, [从官方网站下载 Lutris][13]. + +#### 安装 Epic 游戏商城 + +Lutris 安装成功后,直接启动它。 + +当我尝试时,我遇到了一个问题(当我用 GUI 启动时却没有遇到)。当我尝试在命令行输入 `lutris` 来启动时,我发现了下图所示的错误: + +![][15] + +感谢 Abhishek,我了解到了这是一个常见问题 (你可以在 [GitHub][16] 上查看这个问题)。 + +总之,为了解决这个问题,我需要在命令行中输入以下命令: + +``` +export LC_ALL=C +``` + +当你遇到同样的问题时,只要你输入这个命令,就能正常启动 Lutris 了。 + +**注意**:每次启动 Lutris 时都必须输入这个命令。因此,最好将其添加到 `.bashrc` 文件或环境变量列表中。 + +上述操作完成后,只要启动并搜索 “Epic Games Store” 会显示以下图片中的内容: + +![Epic Games Store in Lutris][17] + +在这里,我已经安装过了,所以你将会看到“安装”选项,它会自动询问你是否需要安装需要的包。只需要继续操作就可以成功安装。就是这样,不需要任何黑科技。 + +#### 玩一款 Epic 游戏商城中的游戏 + +![Epic Games Store][18] + +现在我们已经通过 Lutris 在 Linux 上安装了 Epic 游戏商城,启动它并登录你的账号就可以开始了。 + +但这真会奏效吗? + +*是的,Epic 游戏商城可以运行。* **但是所有游戏都不能玩。**(LCTT 译注:莫生气,请看文末的进一步解释!) + +好吧,我并没有尝试过所有内容,但是我拿了一个免费的游戏(Transistor —— 一款回合制 ARPG 游戏)来检查它是否工作。 + +![Transistor – Epic Games Store][19] + +很不幸,游戏没有启动。当我运行时界面显示了 “Running” 不过什么都没有发生。 + +到目前为止,我还不知道有什么解决方案 —— 所以如果我找到解决方案,我会尽力让你们知道最新情况。 + +### 总结 + +通过 Lutris 这样的工具使 Linux 的游戏场景得到了改善,这终归是个好消息 。不过,仍有许多工作要做。 + +对于在 Linux 上运行的游戏来说,无障碍运行仍然是一个挑战。其中可能就会有我遇到的这种问题,或者其它类似的。但它正朝着正确的方向发展 —— 即使还存在着一些问题。 + +你有什么看法吗?你是否也尝试用 Lutris 在 Linux 上启动 Epic 游戏商城?在下方评论让我们看看你的意见。 + +### 补充 + +Transistor 实际上有一个原生的 Linux 移植版。到目前为止,我从 Epic 获得的所有游戏都是如此。所以我会试着压下我的郁闷,而因为 Epic 只让你玩你通过他们的商店/启动器购买的游戏,所以在 Linux 机器上用 Lutris 玩这个原生的 Linux 游戏是不可能的。这简直愚蠢极了。Steam 有一个原生的 Linux 启动器,虽然不是很理想,但它可以工作。GOG 允许你从网站下载购买的内容,可以在你喜欢的任何平台上玩这些游戏。他们的启动器完全是可选的。 + +我对此非常恼火,因为我在我的 Epic 库中的游戏都是可以在我的笔记本电脑上运行得很好的游戏,当我坐在桌面前时,玩起来很有趣。但是因为那台桌面机是我唯一拥有的 Windows 机器…… + +我选择使用 Linux 时已经知道会存在兼容性问题,并且我有一个专门用于游戏的 Windows 机器,而我通过 Epic 获得的游戏都是免费的,所以我在这里只是表示一下不满。但是,他们两个作为最著名的竞争对手,Epic 应该有在我的 Linux 机器上玩原生 Linux 移植版的机制。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/epic-games-lutris-linux/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[Modrisco](https://github.com/Modrisco) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-7316-1.html +[2]: https://linux.cn/article-10061-1.html +[3]: https://linux.cn/article-10054-1.html +[4]: https://lutris.net/ +[5]: https://itsfoss.com/wp-content/uploads/2019/04/epic-games-store-lutris-linux-800x450.png +[6]: https://www.epicgames.com/store/en-US/ +[7]: https://twitter.com/EpicGames?ref_src=twsrc%5Etfw +[8]: https://twitter.com/TimSweeneyEpic?ref_src=twsrc%5Etfw +[9]: https://pbs.twimg.com/media/D4XkXafX4AARDkW?format=jpg&name=medium +[10]: https://twitter.com/LutrisGaming/status/1118552969816018948?ref_src=twsrc%5Etfw +[11]: https://itsfoss.com/ubuntu-19-04-release-features/ +[12]: https://itsfoss.com/install-latest-wine/ +[13]: https://lutris.net/downloads/ +[14]: https://itsfoss.com/ubuntu-mate-entroware/ +[15]: https://itsfoss.com/wp-content/uploads/2019/04/lutris-error.jpg +[16]: https://github.com/lutris/lutris/issues/660 +[17]: https://itsfoss.com/wp-content/uploads/2019/04/lutris-epic-games-store-800x520.jpg +[18]: https://itsfoss.com/wp-content/uploads/2019/04/epic-games-store-800x450.jpg +[19]: https://itsfoss.com/wp-content/uploads/2019/04/transistor-game-epic-games-store-800x410.jpg +[20]: https://itsfoss.com/skpe-alpha-linux/ diff --git a/sources/tech/20190423 How to identify same-content files on Linux.md b/published/201906/20190423 How to identify same-content files on Linux.md similarity index 55% rename from sources/tech/20190423 How to identify same-content files on Linux.md rename to published/201906/20190423 How to identify same-content files on Linux.md index 8d9b34b30a..6353fe86b3 100644 --- a/sources/tech/20190423 How to identify same-content files on Linux.md +++ b/published/201906/20190423 How to identify same-content files on Linux.md @@ -1,26 +1,25 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (tomjlw) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10955-1.html) [#]: subject: (How to identify same-content files on Linux) [#]: via: (https://www.networkworld.com/article/3390204/how-to-identify-same-content-files-on-linux.html#tk.rss_all) [#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) -How to identify same-content files on Linux +如何在 Linux 上识别同样内容的文件 ====== -Copies of files sometimes represent a big waste of disk space and can cause confusion if you want to make updates. Here are six commands to help you identify these files. +> 有时文件副本相当于对硬盘空间的巨大浪费,并会在你想要更新文件时造成困扰。以下是用来识别这些文件的六个命令。 + ![Vinoth Chandar \(CC BY 2.0\)][1] -In a recent post, we looked at [how to identify and locate files that are hard links][2] (i.e., that point to the same disk content and share inodes). In this post, we'll check out commands for finding files that have the same _content_ , but are not otherwise connected. +在最近的帖子中,我们看了[如何识别并定位硬链接的文件][2](即,指向同一硬盘内容并共享 inode)。在本文中,我们将查看能找到具有相同*内容*,却不相链接的文件的命令。 -Hard links are helpful because they allow files to exist in multiple places in the file system while not taking up any additional disk space. Copies of files, on the other hand, sometimes represent a big waste of disk space and run some risk of causing some confusion if you want to make updates. In this post, we're going to look at multiple ways to identify these files. +硬链接很有用是因为它们能够使文件存放在文件系统内的多个地方却不会占用额外的硬盘空间。另一方面,有时文件副本相当于对硬盘空间的巨大浪费,在你想要更新文件时也会有造成困扰之虞。在本文中,我们将看一下多种识别这些文件的方式。 -**[ Two-Minute Linux Tips:[Learn how to master a host of Linux commands in these 2-minute video tutorials][3] ]** +### 用 diff 命令比较文件 -### Comparing files with the diff command - -Probably the easiest way to compare two files is to use the **diff** command. The output will show you the differences between the two files. The < and > signs indicate whether the extra lines are in the first (<) or second (>) file provided as arguments. In this example, the extra lines are in backup.html. +可能比较两个文件最简单的方法是使用 `diff` 命令。输出会显示你文件的不同之处。`<` 和 `>` 符号代表在当参数传过来的第一个(`<`)或第二个(`>`)文件中是否有额外的文字行。在这个例子中,在 `backup.html` 中有额外的文字行。 ``` $ diff index.html backup.html @@ -30,18 +29,18 @@ $ diff index.html backup.html > ``` -If diff shows no output, that means the two files are the same. +如果 `diff` 没有输出那代表两个文件相同。 ``` $ diff home.html index.html $ ``` -The only drawbacks to diff are that it can only compare two files at a time, and you have to identify the files to compare. Some commands we will look at in this post can find the duplicate files for you. +`diff` 的唯一缺点是它一次只能比较两个文件并且你必须指定用来比较的文件,这篇帖子中的一些命令可以为你找到多个重复文件。 -### Using checksums +### 使用校验和 -The **cksum** (checksum) command computes checksums for files. Checksums are a mathematical reduction of the contents to a lengthy number (like 2819078353 228029). While not absolutely unique, the chance that files that are not identical in content would result in the same checksum is extremely small. +`cksum`(checksum) 命令计算文件的校验和。校验和是一种将文字内容转化成一个长数字(例如2819078353 228029)的数学简化。虽然校验和并不是完全独有的,但是文件内容不同校验和却相同的概率微乎其微。 ``` $ cksum *.html @@ -50,11 +49,11 @@ $ cksum *.html 4073570409 227985 index.html ``` -In the example above, you can see how the second and third files yield the same checksum and can be assumed to be identical. +在上述示例中,你可以看到产生同样校验和的第二个和第三个文件是如何可以被默认为相同的。 -### Using the find command +### 使用 find 命令 -While the find command doesn't have an option for finding duplicate files, it can be used to search files by name or type and run the cksum command. For example: +虽然 `find` 命令并没有寻找重复文件的选项,它依然可以被用来通过名字或类型寻找文件并运行 `cksum` 命令。例如: ``` $ find . -name "*.html" -exec cksum {} \; @@ -63,9 +62,9 @@ $ find . -name "*.html" -exec cksum {} \; 4073570409 227985 ./index.html ``` -### Using the fslint command +### 使用 fslint 命令 -The **fslint** command can be used to specifically find duplicate files. Note that we give it a starting location. The command can take quite some time to complete if it needs to run through a large number of files. Here's output from a very modest search. Note how it lists the duplicate files and also looks for other issues, such as empty directories and bad IDs. +`fslint` 命令可以被特地用来寻找重复文件。注意我们给了它一个起始位置。如果它需要遍历相当多的文件,这就需要花点时间来完成。注意它是如何列出重复文件并寻找其它问题的,比如空目录和坏 ID。 ``` $ fslint . @@ -86,15 +85,15 @@ index.html -------------------------Non Stripped executables ``` -You may have to install **fslint** on your system. You will probably have to add it to your search path, as well: +你可能需要在你的系统上安装 `fslint`。你可能也需要将它加入你的命令搜索路径: ``` $ export PATH=$PATH:/usr/share/fslint/fslint ``` -### Using the rdfind command +### 使用 rdfind 命令 -The **rdfind** command will also look for duplicate (same content) files. The name stands for "redundant data find," and the command is able to determine, based on file dates, which files are the originals — which is helpful if you choose to delete the duplicates, as it will remove the newer files. +`rdfind` 命令也会寻找重复(相同内容的)文件。它的名字意即“重复数据搜寻”,并且它能够基于文件日期判断哪个文件是原件——这在你选择删除副本时很有用因为它会移除较新的文件。 ``` $ rdfind ~ @@ -111,7 +110,7 @@ Totally, 223 KiB can be reduced. Now making results file results.txt ``` -You can also run this command in "dryrun" (i.e., only report the changes that might otherwise be made). +你可以在 `dryrun` 模式中运行这个命令 (换句话说,仅仅汇报可能会另外被做出的改动)。 ``` $ rdfind -dryrun true ~ @@ -128,7 +127,7 @@ Removed 9 files due to unique sizes from list.2 files left. (DRYRUN MODE) Now making results file results.txt ``` -The rdfind command also provides options for things such as ignoring empty files (-ignoreempty) and following symbolic links (-followsymlinks). Check out the man page for explanations. +`rdfind` 命令同样提供了类似忽略空文档(`-ignoreempty`)和跟踪符号链接(`-followsymlinks`)的功能。查看 man 页面获取解释。 ``` -ignoreempty ignore empty files @@ -146,7 +145,7 @@ The rdfind command also provides options for things such as ignoring empty files -n, -dryrun display what would have been done, but don't do it ``` -Note that the rdfind command offers an option to delete duplicate files with the **-deleteduplicates true** setting. Hopefully the command's modest problem with grammar won't irritate you. ;-) +注意 `rdfind` 命令提供了 `-deleteduplicates true` 的设置选项以删除副本。希望这个命令语法上的小问题不会惹恼你。;-) ``` $ rdfind -deleteduplicates true . @@ -154,11 +153,11 @@ $ rdfind -deleteduplicates true . Deleted 1 files. <== ``` -You will likely have to install the rdfind command on your system. It's probably a good idea to experiment with it to get comfortable with how it works. +你将可能需要在你的系统上安装 `rdfind` 命令。试验它以熟悉如何使用它可能是一个好主意。 -### Using the fdupes command +### 使用 fdupes 命令 -The **fdupes** command also makes it easy to identify duplicate files and provides a large number of useful options — like **-r** for recursion. In its simplest form, it groups duplicate files together like this: +`fdupes` 命令同样使得识别重复文件变得简单。它同时提供了大量有用的选项——例如用来迭代的 `-r`。在这个例子中,它像这样将重复文件分组到一起: ``` $ fdupes ~ @@ -173,7 +172,7 @@ $ fdupes ~ /home/shs/hideme.png ``` -Here's an example using recursion. Note that many of the duplicate files are important (users' .bashrc and .profile files) and should clearly not be deleted. +这是使用迭代的一个例子,注意许多重复文件是重要的(用户的 `.bashrc` 和 `.profile` 文件)并且不应被删除。 ``` # fdupes -r /home @@ -204,7 +203,7 @@ Here's an example using recursion. Note that many of the duplicate files are imp /home/shs/PNGs/Sandra_rotated.png ``` -The fdupe command's many options are listed below. Use the **fdupes -h** command, or read the man page for more details. +`fdupe` 命令的许多选项列如下。使用 `fdupes -h` 命令或者阅读 man 页面获取详情。 ``` -r --recurse recurse @@ -229,15 +228,11 @@ The fdupe command's many options are listed below. Use the **fdupes -h** command -h --help displays help ``` -The fdupes command is another one that you're like to have to install and work with for a while to become familiar with its many options. +`fdupes` 命令是另一个你可能需要安装并使用一段时间才能熟悉其众多选项的命令。 -### Wrap-up +### 总结 -Linux systems provide a good selection of tools for locating and potentially removing duplicate files, along with options for where you want to run your search and what you want to do with duplicate files when you find them. - -**[ Also see:[Invaluable tips and tricks for troubleshooting Linux][4] ]** - -Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. +Linux 系统提供能够定位并(潜在地)能移除重复文件的一系列的好工具,以及能让你指定搜索区域及当对你所发现的重复文件时的处理方式的选项。 -------------------------------------------------------------------------------- @@ -245,8 +240,8 @@ via: https://www.networkworld.com/article/3390204/how-to-identify-same-content-f 作者:[Sandra Henry-Stocker][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[tomjlw](https://github.com/tomjlw) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -258,3 +253,4 @@ via: https://www.networkworld.com/article/3390204/how-to-identify-same-content-f [4]: https://www.networkworld.com/article/3242170/linux/invaluable-tips-and-tricks-for-troubleshooting-linux.html [5]: https://www.facebook.com/NetworkWorld/ [6]: https://www.linkedin.com/company/network-world + diff --git a/published/201906/20190427 Monitoring CPU and GPU Temperatures on Linux.md b/published/201906/20190427 Monitoring CPU and GPU Temperatures on Linux.md new file mode 100644 index 0000000000..1ba2cb1a9b --- /dev/null +++ b/published/201906/20190427 Monitoring CPU and GPU Temperatures on Linux.md @@ -0,0 +1,146 @@ +[#]: collector: (lujun9972) +[#]: translator: (cycoe) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10929-1.html) +[#]: subject: (Monitoring CPU and GPU Temperatures on Linux) +[#]: via: (https://itsfoss.com/monitor-cpu-gpu-temp-linux/) +[#]: author: (It's FOSS Community https://itsfoss.com/author/itsfoss/) + +在 Linux 上监控 CPU 和 GPU 温度 +====== + +> 本篇文章讨论了在 Linux 命令行中监控 CPU 和 GPU 温度的两种简单方式。 + +由于 [Steam][1](包括 [Steam Play][2],即 Proton)和一些其他的发展,GNU/Linux 正在成为越来越多计算机用户的日常游戏平台的选择。也有相当一部分用户在遇到像[视频编辑][3]或图形设计等(Kdenlive 和 [Blender][4] 是这类应用程序中很好的例子)资源消耗型计算任务时,也会使用 GNU/Linux。 + +不管你是否是这些用户中的一员或其他用户,你也一定想知道你的电脑 CPU 和 GPU 能有多热(如果你想要超频的话更会如此)。如果是这样,那么继续读下去。我们会介绍两个非常简单的命令来监控 CPU 和 GPU 温度。 + +我的装置包括一台 [Slimbook Kymera][5] 和两台显示器(一台 TV 和一台 PC 监视器),使得我可以用一台来玩游戏,另一台来留意监控温度。另外,因为我使用 [Zorin OS][6],我会将关注点放在 Ubuntu 和 Ubuntu 的衍生发行版上。 + +为了监控 CPU 和 GPU 的行为,我们将利用实用的 `watch` 命令在每几秒钟之后动态地得到读数。 + +![][7] + +### 在 Linux 中监控 CPU 温度 + +对于 CPU 温度,我们将结合使用 `watch` 与 `sensors` 命令。一篇关于[此工具的图形用户界面版本][8]的有趣文章已经在 It's FOSS 中介绍过了。然而,我们将在此处使用命令行版本: + +``` +watch -n 2 sensors +``` + +`watch` 保证了读数会在每 2 秒钟更新一次(当然,这个周期值能够根据你的需要去更改): + +``` +Every 2,0s: sensors + +iwlwifi-virtual-0 +Adapter: Virtual device +temp1: +39.0°C + +acpitz-virtual-0 +Adapter: Virtual device +temp1: +27.8°C (crit = +119.0°C) +temp2: +29.8°C (crit = +119.0°C) + +coretemp-isa-0000 +Adapter: ISA adapter +Package id 0: +37.0°C (high = +82.0°C, crit = +100.0°C) +Core 0: +35.0°C (high = +82.0°C, crit = +100.0°C) +Core 1: +35.0°C (high = +82.0°C, crit = +100.0°C) +Core 2: +33.0°C (high = +82.0°C, crit = +100.0°C) +Core 3: +36.0°C (high = +82.0°C, crit = +100.0°C) +Core 4: +37.0°C (high = +82.0°C, crit = +100.0°C) +Core 5: +35.0°C (high = +82.0°C, crit = +100.0°C) +``` + +除此之外,我们还能得到如下信息: + + * 我们有 5 个核心正在被使用(并且当前的最高温度为 37.0℃)。 + * 温度超过 82.0℃ 会被认为是过热。 + * 超过 100.0℃ 的温度会被认为是超过临界值。 + +根据以上的温度值我们可以得出结论,我的电脑目前的工作负载非常小。 + +### 在 Linux 中监控 GPU 温度 + +现在让我们来看看显卡。我从来没使用过 AMD 的显卡,因此我会将重点放在 Nvidia 的显卡上。我们需要做的第一件事是从 [Ubuntu 的附加驱动][10] 中下载合适的最新驱动。 + +在 Ubuntu(Zorin 或 Linux Mint 也是相同的)中,进入“软件和更新 > 附加驱动”选项,选择最新的可用驱动。另外,你可以添加或启用显示卡的官方 ppa(通过命令行或通过“软件和更新 > 其他软件”来实现)。安装驱动程序后,你将可以使用 “Nvidia X Server” 的 GUI 程序以及命令行工具 `nvidia-smi`(Nvidia 系统管理界面)。因此我们将使用 `watch` 和 `nvidia-smi`: + +``` +watch -n 2 nvidia-smi +``` + +与 CPU 的情况一样,我们会在每两秒得到一次更新的读数: + +``` +Every 2,0s: nvidia-smi + +Fri Apr 19 20:45:30 2019 ++-----------------------------------------------------------------------------+ +| Nvidia-SMI 418.56 Driver Version: 418.56 CUDA Version: 10.1 | +|-------------------------------+----------------------+----------------------+ +| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | +| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | +|===============================+======================+======================| +| 0 GeForce GTX 106... Off | 00000000:01:00.0 On | N/A | +| 0% 54C P8 10W / 120W | 433MiB / 6077MiB | 4% Default | ++-------------------------------+----------------------+----------------------+ + ++-----------------------------------------------------------------------------+ +| Processes: GPU Memory | +| GPU PID Type Process name Usage | +|=============================================================================| +| 0 1557 G /usr/lib/xorg/Xorg 190MiB | +| 0 1820 G /usr/bin/gnome-shell 174MiB | +| 0 7820 G ...equest-channel-token=303407235874180773 65MiB | ++-----------------------------------------------------------------------------+ +``` + +从这个表格中我们得到了关于显示卡的如下信息: + + * 它正在使用版本号为 418.56 的开源驱动。 + * 显示卡的当前温度为 54.0℃,并且风扇的使用量为 0%。 + * 电量的消耗非常低:仅仅 10W。 + * 总量为 6GB 的 vram(视频随机存取存储器),只使用了 433MB。 + * vram 正在被 3 个进程使用,他们的 ID 分别为 1557、1820 和 7820。 + +大部分这些事实或数值都清晰地表明,我们没有在玩任何消耗系统资源的游戏或处理大负载的任务。当我们开始玩游戏、处理视频或其他类似任务时,这些值就会开始上升。 + +#### 结论 + +即便我们有 GUI 工具,但我还是发现这两个命令对于实时监控硬件非常的顺手。 + +你将如何去使用它们呢?你可以通过阅读他们的 man 手册来学习更多关于这些工具的使用技巧。 + +你有其他偏爱的工具吗?在评论里分享给我们吧 ;)。 + +玩得开心! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/monitor-cpu-gpu-temp-linux/ + +作者:[Alejandro Egea-Abellán][a] +选题:[lujun9972][b] +译者:[cycoe](https://github.com/cycoe) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/itsfoss/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/install-steam-ubuntu-linux/ +[2]: https://itsfoss.com/steam-play-proton/ +[3]: https://itsfoss.com/best-video-editing-software-linux/ +[4]: https://www.blender.org/ +[5]: https://slimbook.es/ +[6]: https://zorinos.com/ +[7]: https://itsfoss.com/wp-content/uploads/2019/04/monitor-cpu-gpu-temperature-linux-800x450.png +[8]: https://itsfoss.com/check-laptop-cpu-temperature-ubuntu/ +[9]: https://itsfoss.com/best-command-line-games-linux/ +[10]: https://itsfoss.com/install-additional-drivers-ubuntu/ +[11]: https://itsfoss.com/review-googler-linux/ +[12]: https://itsfoss.com/wp-content/uploads/2019/04/EGEA-ABELLAN-Alejandro.jpg diff --git a/published/201906/20190428 Installing Budgie Desktop on Ubuntu -Quick Guide.md b/published/201906/20190428 Installing Budgie Desktop on Ubuntu -Quick Guide.md new file mode 100644 index 0000000000..457caaa69a --- /dev/null +++ b/published/201906/20190428 Installing Budgie Desktop on Ubuntu -Quick Guide.md @@ -0,0 +1,112 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10919-1.html) +[#]: subject: (Installing Budgie Desktop on Ubuntu [Quick Guide]) +[#]: via: (https://itsfoss.com/install-budgie-ubuntu/) +[#]: author: (Atharva Lele https://itsfoss.com/author/atharva/) + +在 Ubuntu 上安装 Budgie 桌面 +====== + +> 在这个逐步的教程中学习如何在 Ubuntu 上安装 Budgie 桌面。 + +在所有[各种 Ubuntu 版本][1]中,[Ubuntu Budgie][2] 是最被低估的版本。它外观优雅,而且需要的资源也不多。 + +阅读这篇 《[Ubuntu Budgie 点评][3]》或观看下面的视频,了解 Ubuntu Budgie 18.04 的外观如何。 + +- [Ubuntu 18.04 Budgie Desktop Tour [It's Elegant]](https://youtu.be/KXgreWOK33k) + +如果你喜欢 [Budgie 桌面][5]但你正在使用其他版本的 Ubuntu,例如默认 Ubuntu 带有 GNOME 桌面,我有个好消息。你可以在当前的 Ubuntu 系统上安装 Budgie 并切换桌面环境。 + +在这篇文章中,我将告诉你到底该怎么做。但首先,对那些不了解 Budgie 的人进行一点介绍。 + +Budgie 桌面环境主要由 [Solus Linux 团队开发][6]。它的设计注重优雅和现代使用。Budgie 适用于所有主流 Linux 发行版,可以让用户在其上尝试体验这种新的桌面环境。Budgie 现在非常成熟,并提供了出色的桌面体验。 + +> 警告 +> +> 在同一系统上安装多个桌面可能会导致冲突,你可能会遇到一些问题,如面板中缺少图标或同一程序的多个图标。 +> +> 你也许不会遇到任何问题。是否要尝试不同桌面由你决定。 + +### 在 Ubuntu 上安装 Budgie + +此方法未在 Linux Mint 上进行测试,因此我建议你 Mint 上不要按照此指南进行操作。 + +对于正在使用 Ubuntu 的人,Budgie 现在默认是 Ubuntu 仓库的一部分。因此,我们不需要添加任何 PPA 来下载 Budgie。 + +要安装 Budgie,只需在终端中运行此命令即可。我们首先要确保系统已完全更新。 + +``` +sudo apt update && sudo apt upgrade +sudo apt install ubuntu-budgie-desktop +``` + +下载完成后,你将看到选择显示管理器的提示。选择 “lightdm” 以获得完整的 Budgie 体验。 + +![Select lightdm][7] + +安装完成后,重启计算机。然后,你会看到 Budgie 的登录页面。输入你的密码进入主屏幕。 + +![Budgie Desktop Home][8] + +### 切换到其他桌面环境 + +![Budgie login screen][9] + +你可以单击登录名旁边的 Budgie 图标获取登录选项。在那里,你可以在已安装的桌面环境(DE)之间进行选择。就我而言,我看到了 Budgie 和默认的 Ubuntu(GNOME)桌面。 + +![Select your DE][10] + +因此,无论何时你想登录 GNOME,都可以使用此菜单执行此操作。 + +### 如何删除 Budgie + +如果你不喜欢 Budgie 或只是想回到常规的以前的 Ubuntu,你可以如上节所述切换回常规桌面。 + +但是,如果你真的想要删除 Budgie 及其组件,你可以按照以下命令回到之前的状态。 + +**在使用这些命令之前先切换到其他桌面环境:** + +``` +sudo apt remove ubuntu-budgie-desktop ubuntu-budgie* lightdm +sudo apt autoremove +sudo apt install --reinstall gdm3 +``` + +成功运行所有命令后,重启计算机。 + +现在,你将回到 GNOME 或其他你有的桌面。 + +### 你对 Budgie 有什么看法? + +Budgie 是[最佳 Linux 桌面环境][12]之一。希望这个简短的指南帮助你在 Ubuntu 上安装了很棒的 Budgie 桌面。 + +如果你安装了 Budgie,你最喜欢它的什么?请在下面的评论中告诉我们。像往常一样,欢迎任何问题或建议。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-budgie-ubuntu/ + +作者:[Atharva Lele][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/atharva/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/which-ubuntu-install/ +[2]: https://ubuntubudgie.org/ +[3]: https://itsfoss.com/ubuntu-budgie-18-review/ +[4]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[5]: https://github.com/solus-project/budgie-desktop +[6]: https://getsol.us/home/ +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/04/budgie_install_select_dm.png?fit=800%2C559&ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/04/budgie_homescreen.jpg?fit=800%2C500&ssl=1 +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/04/budgie_install_lockscreen.png?fit=800%2C403&ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/04/budgie_install_lockscreen_select_de.png?fit=800%2C403&ssl=1 +[11]: https://itsfoss.com/snapd-error-ubuntu/ +[12]: https://itsfoss.com/best-linux-desktop-environments/ diff --git a/translated/tech/20190505 How To Install-Uninstall Listed Packages From A File In Linux.md b/published/201906/20190505 How To Install-Uninstall Listed Packages From A File In Linux.md similarity index 74% rename from translated/tech/20190505 How To Install-Uninstall Listed Packages From A File In Linux.md rename to published/201906/20190505 How To Install-Uninstall Listed Packages From A File In Linux.md index b825435dcb..4960672f5a 100644 --- a/translated/tech/20190505 How To Install-Uninstall Listed Packages From A File In Linux.md +++ b/published/201906/20190505 How To Install-Uninstall Listed Packages From A File In Linux.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (way-ww) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10923-1.html) [#]: subject: (How To Install/Uninstall Listed Packages From A File In Linux?) [#]: via: (https://www.2daygeek.com/how-to-install-uninstall-listed-packages-from-a-file-in-linux/) [#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) @@ -10,25 +10,17 @@ 如何在 Linux 上安装/卸载一个文件中列出的软件包? ====== -在某些情况下,你可能想要将一个服务器上的软件包列表安装到另一个服务器上。 +在某些情况下,你可能想要将一个服务器上的软件包列表安装到另一个服务器上。例如,你已经在服务器 A 上安装了 15 个软件包并且这些软件包也需要被安装到服务器 B、服务器 C 上等等。 -例如,你已经在服务器A 上安装了 15 个软件包并且这些软件包也需要被安装到服务器B,服务器C 上等等。 +我们可以手动去安装这些软件但是这将花费大量的时间。你可以手动安装一俩个服务器,但是试想如果你有大概十个服务器呢。在这种情况下你无法手动完成工作,那么怎样才能解决问题呢? -我们可以手动去安装这些软件但是这将花费大量的时间。 - -你可以手动安装一俩个服务器,但是试想如果你有大概十个服务器呢。 - -在这种情况下你无法手动完成工作,那么怎样才能解决问题呢? - -不要担心我们可以帮你摆脱这样的情况和场景。 - -我们在这篇文章中增加了四种方法来克服困难。 +不要担心我们可以帮你摆脱这样的情况和场景。我们在这篇文章中增加了四种方法来克服困难。 我希望这可以帮你解决问题。我已经在 Centos7 和 Ubuntu 18.04 上测试了这些命令。 我也希望这可以在其他发行版上工作。这仅仅需要使用该发行版的官方包管理器命令替代本文中的包管理器命令就行了。 -如果想要 **[检查 Linux 系统上已安装的软件包列表][1]** 请点击链接。 +如果想要 [检查 Linux 系统上已安装的软件包列表][1],请点击链接。 例如,如果你想要在基于 RHEL 系统上创建软件包列表请使用以下步骤。其他发行版也一样。 @@ -53,11 +45,9 @@ apr-util-1.5.2-6.el7.x86_64 apr-1.4.8-3.el7_4.1.x86_64 ``` -### 方法一 : 如何在 Linux 上使用 cat 命令安装文件中列出的包? +### 方法一:如何在 Linux 上使用 cat 命令安装文件中列出的包? -为实现这个目标,我将使用简单明了的第一种方法。 - -为此,创建一个文件并添加上你想要安装的包列表。 +为实现这个目标,我将使用简单明了的第一种方法。为此,创建一个文件并添加上你想要安装的包列表。 出于测试的目的,我们将只添加以下的三个软件包名到文件中。 @@ -69,7 +59,7 @@ mariadb-server nano ``` -只要简单的运行 **[apt 命令][2]** 就能在 Ubuntu/Debian 系统上一次性安装所有的软件包。 +只要简单的运行 [apt 命令][2] 就能在 Ubuntu/Debian 系统上一次性安装所有的软件包。 ``` # apt -y install $(cat /tmp/pack1.txt) @@ -138,20 +128,19 @@ Processing triggers for install-info (6.5.0.dfsg.1-2) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ... ``` -使用 **[yum 命令][3]** 在基于 RHEL (如 Centos,RHEL (Redhat) 和 OEL (Oracle Enterprise Linux)) 的系统上安装文件中列出的软件包。 - +使用 [yum 命令][3] 在基于 RHEL (如 Centos、RHEL (Redhat) 和 OEL (Oracle Enterprise Linux)) 的系统上安装文件中列出的软件包。 ``` # yum -y install $(cat /tmp/pack1.txt) ``` -使用以命令在基于 RHEL (如 Centos,RHEL (Redhat) 和 OEL (Oracle Enterprise Linux)) 的系统上卸载文件中列出的软件包。 +使用以命令在基于 RHEL (如 Centos、RHEL (Redhat) 和 OEL (Oracle Enterprise Linux)) 的系统上卸载文件中列出的软件包。 ``` # yum -y remove $(cat /tmp/pack1.txt) ``` -使用以下 **[dnf 命令][4]** 在 Fedora 系统上安装文件中列出的软件包。 +使用以下 [dnf 命令][4] 在 Fedora 系统上安装文件中列出的软件包。 ``` # dnf -y install $(cat /tmp/pack1.txt) @@ -163,7 +152,7 @@ Processing triggers for man-db (2.8.3-2ubuntu0.1) ... # dnf -y remove $(cat /tmp/pack1.txt) ``` -使用以下 **[zypper 命令][5]** 在 openSUSE 系统上安装文件中列出的软件包。 +使用以下 [zypper 命令][5] 在 openSUSE 系统上安装文件中列出的软件包。 ``` # zypper -y install $(cat /tmp/pack1.txt) @@ -175,7 +164,7 @@ Processing triggers for man-db (2.8.3-2ubuntu0.1) ... # zypper -y remove $(cat /tmp/pack1.txt) ``` -使用以下 **[pacman 命令][6]** 在基于 Arch Linux (如 Manjaro 和 Antergos) 的系统上安装文件中列出的软件包。 +使用以下 [pacman 命令][6] 在基于 Arch Linux (如 Manjaro 和 Antergos) 的系统上安装文件中列出的软件包。 ``` # pacman -S $(cat /tmp/pack1.txt) @@ -188,36 +177,35 @@ Processing triggers for man-db (2.8.3-2ubuntu0.1) ... # pacman -Rs $(cat /tmp/pack1.txt) ``` -### 方法二 : 如何使用 cat 和 xargs 命令在 Linux 中安装文件中列出的软件包。 +### 方法二:如何使用 cat 和 xargs 命令在 Linux 中安装文件中列出的软件包。 甚至,我更喜欢使用这种方法,因为这是一种非常简单直接的方法。 -使用以下 apt 命令在基于 Debian 的系统 (如 Debian,Ubuntu和Linux Mint) 上安装文件中列出的软件包。 - +使用以下 `apt` 命令在基于 Debian 的系统 (如 Debian、Ubuntu 和 Linux Mint) 上安装文件中列出的软件包。 ``` # cat /tmp/pack1.txt | xargs apt -y install ``` -使用以下 apt 命令 从基于 Debian 的系统 (如 Debian,Ubuntu和Linux Mint) 上卸载文件中列出的软件包。 +使用以下 `apt` 命令 从基于 Debian 的系统 (如 Debian、Ubuntu 和 Linux Mint) 上卸载文件中列出的软件包。 ``` # cat /tmp/pack1.txt | xargs apt -y remove ``` -使用以下 yum 命令在基于 RHEL (如 Centos,RHEL (Redhat) 和 OEL (Oracle Enterprise Linux)) 的系统上安装文件中列出的软件包。 +使用以下 `yum` 命令在基于 RHEL (如 Centos,RHEL (Redhat) 和 OEL (Oracle Enterprise Linux)) 的系统上安装文件中列出的软件包。 ``` # cat /tmp/pack1.txt | xargs yum -y install ``` -使用以命令从基于 RHEL (如 Centos,RHEL (Redhat) 和 OEL (Oracle Enterprise Linux)) 的系统上卸载文件中列出的软件包。 +使用以命令从基于 RHEL (如 Centos、RHEL (Redhat) 和 OEL (Oracle Enterprise Linux)) 的系统上卸载文件中列出的软件包。 ``` # cat /tmp/pack1.txt | xargs yum -y remove ``` -使用以下 dnf 命令在 Fedora 系统上安装文件中列出的软件包。 +使用以下 `dnf` 命令在 Fedora 系统上安装文件中列出的软件包。 ``` # cat /tmp/pack1.txt | xargs dnf -y install @@ -229,7 +217,7 @@ Processing triggers for man-db (2.8.3-2ubuntu0.1) ... # cat /tmp/pack1.txt | xargs dnf -y remove ``` -使用以下 zypper 命令在 openSUSE 系统上安装文件中列出的软件包。 +使用以下 `zypper` 命令在 openSUSE 系统上安装文件中列出的软件包。 ``` @@ -242,7 +230,7 @@ Processing triggers for man-db (2.8.3-2ubuntu0.1) ... # cat /tmp/pack1.txt | xargs zypper -y remove ``` -使用以下 pacman 命令在基于 Arch Linux (如 Manjaro 和 Antergos) 的系统上安装文件中列出的软件包。 +使用以下 `pacman` 命令在基于 Arch Linux (如 Manjaro 和 Antergos) 的系统上安装文件中列出的软件包。 ``` # cat /tmp/pack1.txt | xargs pacman -S @@ -254,17 +242,17 @@ Processing triggers for man-db (2.8.3-2ubuntu0.1) ... # cat /tmp/pack1.txt | xargs pacman -Rs ``` -### 方法三 : 如何使用 For Loop 在 Linux 上安装文件中列出的软件包? -我们也可以使用 For 循环命令来实现此目的。 +### 方法三 : 如何使用 For 循环在 Linux 上安装文件中列出的软件包 -安装批量包可以使用以下一条 For 循环的命令。 +我们也可以使用 `for` 循环命令来实现此目的。 + +安装批量包可以使用以下一条 `for` 循环的命令。 ``` # for pack in `cat /tmp/pack1.txt` ; do apt -y install $i; done ``` -要使用 shell 脚本安装批量包,请使用以下 For 循环。 - +要使用 shell 脚本安装批量包,请使用以下 `for` 循环。 ``` # vi /opt/scripts/bulk-package-install.sh @@ -275,7 +263,7 @@ do apt -y remove $pack done ``` -为 bulk-package-install.sh 设置可执行权限。 +为 `bulk-package-install.sh` 设置可执行权限。 ``` # chmod + bulk-package-install.sh @@ -287,17 +275,17 @@ done # sh bulk-package-install.sh ``` -### 方法四 : 如何使用 While 循环在 Linux 上安装文件中列出的软件包。 +### 方法四:如何使用 While 循环在 Linux 上安装文件中列出的软件包 -我们也可以使用 While 循环命令来实现目的。 +我们也可以使用 `while` 循环命令来实现目的。 -安装批量包可以使用以下一条 While 循环的命令。 +安装批量包可以使用以下一条 `while` 循环的命令。 ``` # file="/tmp/pack1.txt"; while read -r pack; do apt -y install $pack; done < "$file" ``` -要使用 shell 脚本安装批量包,请使用以下 While 循环。 +要使用 shell 脚本安装批量包,请使用以下 `while` 循环。 ``` # vi /opt/scripts/bulk-package-install.sh @@ -309,7 +297,7 @@ do apt -y remove $pack done < "$file" ``` -为 bulk-package-install.sh 设置可执行权限。 +为 `bulk-package-install.sh` 设置可执行权限。 ``` # chmod + bulk-package-install.sh @@ -328,13 +316,13 @@ via: https://www.2daygeek.com/how-to-install-uninstall-listed-packages-from-a-fi 作者:[Magesh Maruthamuthu][a] 选题:[lujun9972][b] 译者:[way-ww](https://github.com/way-ww) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]: https://www.2daygeek.com/author/magesh/ [b]: https://github.com/lujun9972 -[1]: https://www.2daygeek.com/check-installed-packages-in-rhel-centos-fedora-debian-ubuntu-opensuse-arch-linux/ +[1]: https://linux.cn/article-10116-1.html [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/ diff --git a/published/201906/20190508 Why startups should release their code as open source.md b/published/201906/20190508 Why startups should release their code as open source.md new file mode 100644 index 0000000000..ff12c65320 --- /dev/null +++ b/published/201906/20190508 Why startups should release their code as open source.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11000-1.html) +[#]: subject: (Why startups should release their code as open source) +[#]: via: (https://opensource.com/article/19/5/startups-release-code) +[#]: author: (Clément Flipo https://opensource.com/users/cl%C3%A9ment-flipo) + +为什么初创公司应该将代码开源 +====== + +> Dokit 曾经怀疑将自己的知识开源可能是一个失败的商业决策,然而正是这个选择奠定了它的成功。 + +![open source button on keyboard][1] + +回想一个项目开展最初期的细节并不是一件容易的事情,但这有时候可以帮助你更清晰地理解这个项目。如果让我来说,关于 [Dokit][2] 这个用来创建用户手册和文档的平台的最早的想法来自我的童年。小时候我家里都是 Meccano(LCTT 译注:一种类似乐高的拼装玩具)和飞机模型之类的玩具,对于我来说,游戏中很重要的一部分就是动手制作,把独立的零件组装在一起来创造一个新的东西。我父亲在一家 DIY 公司工作,所以家里到处都建筑、修理,以及使用说明书。小的时候父母还让我参加了童子军,在那里我们制作桌子和帐篷,还有泥巴做的烧烤炉,这些事情都培养了我在共同学习中感受到的乐趣,就像我在开源活动中感受到的一样。 + +在童年学到的修理东西和回收产品的本领成为了我工作的一部分。后来我决心要用线上的方式,还原这种在家里或者小组里学习如何制作和修理东西时的那种非常棒的感觉。Dokit 就从这个想法中诞生了。 + +### 创业初期 + +事情并非一帆风顺,在我们的公司于 2017 年成立之后,我很快就意识到那些最庞大、最值得奋斗的目标一般来说也总是最困难的。如果想要实现我们的计划 —— 彻底改变 [老式的说明书和用户手册的编写和发行方式][3],并且在这个细分市场(我们非常清楚这一点)里取得最大的影响力 —— 那么确立一个主导任务就十分关键,它关乎项目的组织方式。我们据此做出了第一个重要决策:首先 [在短时间内使用一个已有的开源框架 MediaWiki 制作产品原型来验证我们的想法][4],然后将我们的全部代码都作为开源项目发布。 + +当时 [MediaWiki][5] 已经在正常运作了,事后看来,这一点让我们的决策变得容易了许多。这个平台已经拥有我们设想的最小可用产品(MVP)所需要的 90% 的功能,并且在全世界范围内有 15000 名活跃的开发者。MediaWiki 因为是维基百科的驱动引擎而小有名气,如果没有来自它的支持,事情对我们来说无疑会困难很多。还有一个许多公司都在使用的文档平台 Confluence 也有一些不错的功能,但是最终在这两者之间做出选择还是很容易的。 + +出于对社区的信赖,我们把自己平台的初始版本完全放在了 GitHub 上。我们甚至还没有真正开始进行推广,就已经可以看到世界各地的创客们开始使用我们的平台,这种令人激动的感觉似乎说明我们的选择是正确的。尽管 [创客以及 Fablab 运动][6](LCTT 译注:Fablab 是一种向个人提供包括 3D 打印在内的电子化制造服务的小型工坊)都在鼓励用户积极分享说明材料,并且在 [Fablab 章程][7] 中也写明了这一点,但现实中像模像样的文档还是不太多见。 + +人们喜欢使用我们这个平台的首要原因是它可以解决一个非常实在的问题:一个本来还不错的项目,却使用了非常糟糕的文档 —— 其实这个项目本来可以变得更好的。对我们来说,这有点儿像是在修复创客及 DIY 社区里的一个裂缝。在我们的平台发布后的一年之内,Fablabs、[Wikifab][8]、[Open Source Ecology][9]、[Les Petits Debrouillards][10]、[Ademe][11] 以及 [Low-Tech Lab][12] 都在他们的服务器上安装了我们的工具,用来制作逐步引导的教程。 + +甚至在我们还没有发新闻稿之前,我们的其中一个用户 Wikifab 就开始在全国性媒体上收到“DIY 界的维基百科”这样的称赞了。短短两年之内,我们看到有数百的社区都在他们自己的 Dokits 上开展了项目,从有意思的、搞笑的,到那种很正式的产品手册都有。这种社区的力量正是我们想要驾驭的,并且有这么多的项目 —— 从风力涡轮机到宠物喂食器 —— 都在使用我们创建的平台编写非常有吸引力的产品手册,这件事情真的令我们赞叹不已。 + +### 项目开源 + +回头看看前两年的成功,很明显选择开源是我们能迅速取得成果的关键因素。最有价值的事情就是在开源项目中获得反馈的能力了。如果一段代码无法正常运行,[会有人立刻告诉我们][14]。如果可以从这些已经在使用你提供的服务的人那里学到这么多东西,为什么还要需要等着和顾问们开会呢? + +社区对我们这个项目的关注程度也反映出了这个市场的潜力(包括利润上的潜力)。[巴黎有一个非常好的、成长迅速的开发者社区][15](LCTT 译注:Dokit 是一家设立在巴黎的公司),但是开源将我们从一个只有数千当地人的小池子里带到了全世界数百万的开发者身边,他们都将成为我们的创作中的一部分。与此同时,代码的开放性也让我们的用户和客户更加放心,因为即使我们这个公司不在了,代码仍然会存续下去。 + +如果说上面这些都是在我们之前对开源的预期之中的话,其实这一路上也有不少惊喜。因为开源,我们获得了更多的客户、声望以及精准推广,这种推广本来以我们有限的预算是负担不起的,现在却不需要我们支付费用。我们发现开源代码还改善了我们的招聘流程,因为在雇佣之前就可以通过我们的代码来测试候选人,并且被雇佣之后的入职过程也会更加顺利。 + +开发者在完全公开的情况下写代码,既有一点尴尬,同时也很团结,这对我们提升产品质量很有帮助。人们可以互相发表意见和反馈,并且因为工作都是完全公开的,人们似乎会尽可能地想做到最好。为了不断优化、不断重构 Dokit 的运行方式,我们明白未来应该在对社区的支持上做得更好。 + +### 下一步是什么? + +尽管我们对正在做的事情一直都很有信念,并且看到很多出色的产品说明书都是用我们的软件制作出来的,我们还是会对这个项目的成长不断地感到兴奋,并且非常确信未来一定会很好。 + +在创业初期,我们对将自己的知识免费分发出去这件事还是非常担心的。事实证明正好相反 —— 正是开源让我们能够迅速构建起一个可持续的初创企业。Dokit 平台的设计初衷是通过社区的支持,让它的用户有信心去构建、组装、修理和创造全新的发明。事后看来,我们用开源的方式去构建了 Dokit 这个平台,这和 Dokit 本身想做的其实正好是同一件事情。 + +如同修理或者组装一件实体产品一样,只有当你对自己的方法有信心的时候,事情才会越来越顺利。现在,在我们创业的第三个年头,我们开始注意到全世界对这个领域的兴趣在增加,因为它迎合了出于不断变化的居家和生活方式的需求而 [想要使用或重复利用以及组装产品的新一代客户][16]。我们正是在通过线上社区的支持,创造一个让大家能够在自己动手做东西的时候感到更加有信心的平台。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/startups-release-code + +作者:[Clément Flipo][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/cl%C3%A9ment-flipo +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/button_push_open_keyboard_file_organize.png?itok=KlAsk1gx (open source button on keyboard) +[2]: https://dokit.io/ +[3]: https://dokit.io/9-reasons-to-stop-writing-your-user-manuals-or-work-instructions-with-word-processors/ +[4]: https://medium.com/@gofloaters/5-cheap-ways-to-build-your-mvp-71d6170d5250 +[5]: https://en.wikipedia.org/wiki/MediaWiki +[6]: https://en.wikipedia.org/wiki/Maker_culture +[7]: http://fab.cba.mit.edu/about/charter/ +[8]: https://wikifab.org/ +[9]: https://www.opensourceecology.org/ +[10]: http://www.lespetitsdebrouillards.org/ +[11]: https://www.ademe.fr/en +[12]: http://lowtechlab.org/ +[13]: https://www.20minutes.fr/magazine/economie-collaborative-mag/2428995-20160919-pour-construire-leurs-meubles-eux-memes-ils-creent-le-wikipedia-du-bricolage +[14]: https://opensource.guide/how-to-contribute/ +[15]: https://www.rudebaguette.com/2013/03/here-are-the-details-on-the-new-developer-school-that-xavier-niel-is-launching-tomorrow/?lang=en +[16]: https://www.inc.com/ari-zoldan/why-now-is-the-best-time-to-start-a-diy-home-based.html diff --git a/published/201906/20190509 5 essential values for the DevOps mindset.md b/published/201906/20190509 5 essential values for the DevOps mindset.md new file mode 100644 index 0000000000..f3193a3d95 --- /dev/null +++ b/published/201906/20190509 5 essential values for the DevOps mindset.md @@ -0,0 +1,83 @@ +[#]: collector: (lujun9972) +[#]: translator: (arrowfeng) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10992-1.html) +[#]: subject: (5 essential values for the DevOps mindset) +[#]: via: (https://opensource.com/article/19/5/values-devops-mindset) +[#]: author: (Brent Aaron Reed https://opensource.com/users/brentaaronreed/users/wpschaub/users/wpschaub/users/wpschaub/users/cobiacomm/users/marcobravo/users/brentaaronreed) + +DevOps 思维模式的 5 个基本价值观 +====== + +> 人和流程比在解决的业务问题的任何技术“银弹”更重要,且需要花更多的时间。 + +![human head, brain outlined with computer hardware background][1] + +今天的许多 IT 专业人士都在努力适应变化和扰动。这么说吧,你是否正在努力适应变化?你觉得不堪重负吗?这并不罕见。今天,IT 的现状还不够好,所以需要不断尝试重新自我演进。 + +凭借 30 多年的IT综合经验,我们见证了人员与关系对于 IT 企业提高效率和帮助企业蓬勃发展的重要性。但是,在大多数情况下,我们关于 IT 解决方案的对话始于技术,而不是从人员和流程开始。寻找“银弹”来解决业务和 IT 挑战的倾向过于普遍。但你不能想着可以买到创新、DevOps 或有效的团队和工作方式;他们需要得到培养,支持和引导。 + +由于扰动如此普遍,并且对变革速度存在如此迫切的需求,我们需要纪律和围栏。下面描述的 DevOps 思维模式的五个基本价值观将支持将我们的实践。这些价值观不是新观念;正如我们从经验中学到的那样,它们被重构了。一些价值观可以互换的,它们是灵活的,并且它们如支柱一样导向了支持这五个价值观的整体原则。 + +![5 essential values for the DevOps mindset][2] + +### 1、利益相关方的反馈至关重要 + +我们如何知道我们是否为我们创造了比利益相关方更多的价值?我们需要持久的质量数据来分析、通知并推动更好的决策。来自可靠来源的相关信息对于任何业务的蓬勃发展至关重要。我们需要倾听并理解我们的利益相关方所说的,而不是说我们需要以一种方式实施变革,使我们能够调整我们的思维、流程和技术,并根据需要对其进行调整以使我们的利益相关者满意。由于信息(数据)不正确,我们常常看到的变化过少,或者由于错误的原因而发生了很多变化。因此,将变更与利益相关方的反馈结合起来是一项基本价值观,并有助我们专注于使公司成功最重要的事情。 + +> 关注我们的利益相关方及其反馈,而不仅仅是为了改变而改变。 + +### 2、超越当今流程的极限进行改进 + +我们希望我们的产品和服务能够不断让客户满意,他们是我们最重要的利益相关方。因此,我们需要不断改进。这不仅仅是关系到质量;它还可能意味着成本、可用性、相关性以及许多其他目标和因素。创建可重复的流程或使用通用框架是非常棒的,它们可以改善治理和许多其他问题。但是,这不应该是我们的最终目标。在寻找改进方法时,我们必须调整我们的流程,并辅以正确的技术和工具。可能有理由抛出一个“所谓的”框架,因为不这样做可能会增加浪费,更糟糕的是只是“货物结果”(做一些没有价值或目的的东西)。 + +> 力争始终创新并改进可重复的流程和框架。 + +### 3、不要用新的孤岛来打破旧的孤岛 + +孤岛和 DevOps 是不兼容的。我们经常能看到:IT 主管带来了所谓的“专家”来实施敏捷和 DevOps,他们做了什么?这些“专家”在现有问题的基础上创建了一个新问题,这是 IT 部门和业务中又增加了一个孤岛。创造“DevOps”职位违背了敏捷和 DevOps 基于打破孤岛的原则。在敏捷和 DevOps 中,团队合作是必不可少的,如果你不在自组织团队中工作,那么你就不会做任何事情。 + +> 相互激励和共享,而不是成为英雄或创建一个孤岛。 + +### 4、了解你的客户意味着跨组织协作 + +企业的任何一个部分都不是一个独立的实体,因为它们都有利益相关方,主要利益相关方始终是客户。“客户永远是对的”(或国王,我喜欢这样说)。关键是,没有客户就真的没有业务,而且为了保持业务,如今我们需要与竞争对手“区别对待”。我们还需要了解客户对我们的看法以及他们对我们的期望。了解客户的需求势在必行,需要及时反馈,以确保业务能够快速、负责地满足这些主要利益相关者的需求和关注。 + +![Minimize time spent with build-measure-learn process][3] + +无论是想法、概念、假设还是直接利益相关方的反馈,我们都需要通过使用探索、构建、测试和交付生命周期来识别和衡量我们的产品提供的功能或服务。从根本上说,这意味着我们需要在整个组织中“插入”我们的组织。在持续创新、学习和 DevOps 方面没有任何边界。因此,当我们在整个企业中进行衡量时,我们可以理解整体并采取可行的、有意义的步骤来改进。 + +> 衡量整个组织的绩效,而不仅仅是在业务范围内。 + +### 5、通过热情鼓励采纳 + +不是每个人都要被驱使去学习、适应和改变;然而,就像微笑可能具有传染性一样,学习和意愿成为变革文化的一部分也是如此。在学习文化中适应和演化为一群人提供了学习和传递信息(即文化传播)的自然机制。学习风格、态度、方法和过程不断演化,因此我们可以改进它们。下一步是应用所学和改进的内容并与同事分享信息。学习不会自动发生;它需要努力、评估、纪律、意识,特别是沟通;遗憾的是,这些都是工具和自动化无法提供的。检查你的流程、自动化、工具策略和实施工作,使其透明化,并与你的同事协作重复使用和改进。 + +> 通过精益交付促进学习文化,而不仅仅是工具和自动化。 + +### 总结 + +![Continuous goals of DevOps mindset][4] + +随着我们的公司采用 DevOps,我们继续在各种书籍、网站或自动化软件上倡导这五个价值观。采用这种思维方式需要时间,这与我们以前作为系统管理员所做的完全不同。这是一种全新的工作方式,需要很多年才能成熟。这些原则是否与你自己的原则一致?在评论或我们的网站 [Agents of chaos][5] 上分享。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/values-devops-mindset + +作者:[Brent Aaron Reed][a] +选题:[lujun9972][b] +译者:[arrowfeng](https://github.com/arrowfeng) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/brentaaronreed/users/wpschaub/users/wpschaub/users/wpschaub/users/cobiacomm/users/marcobravo/users/brentaaronreed +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_data.png?itok=RH6NA32X (human head, brain outlined with computer hardware background) +[2]: https://opensource.com/sites/default/files/uploads/devops_mindset_values.png (5 essential values for the DevOps mindset) +[3]: https://opensource.com/sites/default/files/uploads/devops_mindset_minimze-time.jpg (Minimize time spent with build-measure-learn process) +[4]: https://opensource.com/sites/default/files/uploads/devops_mindset_continuous.png (Continuous goals of DevOps mindset) +[5]: http://agents-of-chaos.org diff --git a/published/201906/20190513 How To Check Whether The Given Package Is Installed Or Not On Debian-Ubuntu System.md b/published/201906/20190513 How To Check Whether The Given Package Is Installed Or Not On Debian-Ubuntu System.md new file mode 100644 index 0000000000..a0f55d4b7b --- /dev/null +++ b/published/201906/20190513 How To Check Whether The Given Package Is Installed Or Not On Debian-Ubuntu System.md @@ -0,0 +1,133 @@ +[#]: collector: (lujun9972) +[#]: translator: (yizhuoyan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11010-1.html) +[#]: subject: (How To Check Whether The Given Package Is Installed Or Not On Debian/Ubuntu System?) +[#]: via: (https://www.2daygeek.com/how-to-check-whether-the-given-package-is-installed-or-not-on-ubuntu-debian-system/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + + +如何在 Debian/Ubuntu 系统中检查程序包是否安装? +====== + +![](https://img.linux.net.cn/data/attachment/album/201906/23/235541yl41p73z5jv78y8p.jpg) + +我们近期发布了一篇关于批量程序包安装的文章。在此同时,关于如何获取系统上已安装了的程序包信息,我也做了些调查然后找到了些方法。我会把这些方法分享在我们的网站上,希望能帮助到其他人。 + +有很多种方法可以检查程序包是否已安装,我找到了 7 种命令,你可以从中选择你喜欢的使用。 + +如下: + + * `apt-cache`:可用于查询 APT 缓存或程序包的元数据。 + * `apt`:是基于 Debian 的系统中的安装、下载、删除、搜索和管理包的强有力的工具。 + * `dpkg-query`:一个查询 dpkg 数据库的工具。 + * `dpkg`:基于 Debian 的系统的包管理工具。 + * `which`:返回在终端中输入命令时执行的可执行文件的全路径。 + * `whereis`:可用于搜索指定命令的二进制文件、源码文件和帮助文件。 + * `locate`:比 `find` 命令快,因为其使用 `updatedb` 数据库搜索,而 `find`命令在实际系统中搜索。 + +### 方法一、使用 apt-cache 命令 + +`apt-cache` 命令用于从 APT 内部数据库中查询**APT 缓存**和**包的元数据**,将会搜索和显示指定包的信息,包括是否安装、程序包版本、源码仓库信息等。 + +下面的示例清楚的显示 `nano` 包已经在系统中安装了以及对应安装的版本号。 + +``` +# apt-cache policy nano +nano: + Installed: 2.9.3-2 + Candidate: 2.9.3-2 + Version table: + *** 2.9.3-2 500 + 500 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 Packages + 100 /var/lib/dpkg/status +``` + +### 方法二、使用 apt 命令 + +`apt` 是一个功能强大的命令行工具,可用于安装、下载、删除、搜索、管理程序包以及查询关于程序包的信息,类似对于 `libapt-pkg` 库的所有功能的底层访问。其包含一些与包管理相关的但很少用到的命令行功能。 + +``` +# apt -qq list nano +nano/bionic,now 2.9.3-2 amd64 [installed] +``` + +### 方法三、使用 dpkg-query 命令 + +`dpkg-query` 是显示 `dpkg` 数据库中程序包信息列表的一个工具。 + +下面示例中的输出的第一列 `ii`,表示查询的程序包已安装了。 + +``` +# dpkg-query --list | grep -i nano +ii nano 2.9.3-2 amd64 small, friendly text editor inspired by Pico +``` + +### 方法四、使用 dpkg 命令 + +`dpkg`(**d**ebian **p**ac**k**a**g**e)是一个安装、构建、删除和管理 Debian 包的工具,但和其他包管理系统不同的是,其不能自动下载和安装包或包依赖。 + +下面示例中的输出的第一列 `ii`,表示查询的包已安装了。 + +``` +# dpkg -l | grep -i nano +ii nano 2.9.3-2 amd64 small, friendly text editor inspired by Pico +``` + +### 方法五、使用 which 命令 + +`which` 命令返回在终端中输入命令时执行的可执行文件的全路径。这对于你想要给可执行文件创建桌面快捷方式或符号链接时非常有用。 + +`which` 命令仅在当前用户 `PATH` 环境变量配置的目录列表中搜索,而不是在所有用户的目录中搜索。这意思是当你登入你自己账号时,其不会在 `root` 用户文件或目录中搜索。 + +如果对于指定的程序包或可执行文件路径有如下输出,则表示已安装了,否则没有。 + +``` +# which nano +/bin/nano +``` + +### 方法六、使用 whereis 命令 + +`whereis` 命令用于针对指定命令搜索对应的程序二进制文件、源码文件以及帮助文件等。 + +如果对于指定的程序包或可执行文件路径有如下输出,则表示已安装了,否则没有。 + +``` +# whereis nano +nano: /bin/nano /usr/share/nano /usr/share/man/man1/nano.1.gz /usr/share/info/nano.info.gz +``` + +### 方法七、使用 locate 命令 + +`locate` 命令比 `find` 命令快,因为其在 `updatedb` 数据库中搜索,而 `find` 命令在实际系统中进行搜索。 + +对于获取指定文件,其使用数据库而不是在特定目录路径中搜索。 + +`locate` 命令不会预安装在大多数系统中,需要手动安装。 + +`locate` 使用的数据库会根据定时任务定期更新。当然,我们也可以手动更新。 + +如果对于指定的程序包或可执行文件路径有如下输出,则表示已安装了,否则没有。 + +``` +# locate --basename '\nano' +/usr/bin/nano +/usr/share/nano +/usr/share/doc/nano +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-check-whether-the-given-package-is-installed-or-not-on-ubuntu-debian-system/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[yizhuoyan](https://github.com/yizhuoyan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 diff --git a/published/201906/20190517 10 Places Where You Can Buy Linux Computers.md b/published/201906/20190517 10 Places Where You Can Buy Linux Computers.md new file mode 100644 index 0000000000..92a334f37d --- /dev/null +++ b/published/201906/20190517 10 Places Where You Can Buy Linux Computers.md @@ -0,0 +1,299 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10982-1.html) +[#]: subject: (10 Places Where You Can Buy Linux Computers) +[#]: via: (https://itsfoss.com/get-linux-laptops/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +可以买到 Linux 电脑的 10 个地方 +====== + +> 你在找 Linux 笔记本吗? 这里列出一些出售 Linux 电脑或者是专注于 Linux 系统的电商。 + +如今市面上几乎所有的电脑(苹果除外)都预装了 Windows 系统。Linux 使用者的惯常做法就是买一台这样的电脑,然后要么删除 Windows 系统并安装 Linux,要么[安装 Linux 和 Windows 的双系统][1]。 + +但 Windows 系统并非无法避免。你其实也可以买到 Linux 电脑。 + +不过,既然可以轻松地在任何一台电脑上安装 Linux,为什么还要买一台预装了 Linux 的电脑呢?下面列举几个原因: + + * 预装 Windows 系统意味着你额外支付了 Windows 许可证的费用。你可以节省这笔开销。 + * 预装 Linux 的电脑都经过了硬件适配测试。你不需要担心系统无法正常运行 WiFi 或者蓝牙,也不再需要亲自去搞定这些事情了。 + * 购买 Linux 电脑相当于间接地支持了 Linux。更多的销售额可以反应出对 Linux 产品的需求,也就可能会有更多商家提供 Linux 作为一种可以选择的操作系统。 + +如果你正想买一台 Linux 的笔记本,不妨考虑一下我的建议。下面这些制造商或者商家都提供开箱即用的 Linux 系统。 + +![][2] + +### 可以买到 Linux 笔记本或者台式机的 10 个地方 + +在揭晓这个提供预装 Linux 电脑的商家的清单之前,需要先声明一下。 + +请根据你的独立决策购买。我在这里只是简单地列出一些售卖 Linux 电脑的商家,并不保证他们的产品质量、售后服务等等这些事情。 + +这也并不是一个排行榜。清单并不是按照某个特定次序排列的,每一项前面的数字只是为了方便计数,而并不代表名次。 + +让我们看看你可以在哪儿买到预装 Linux 的台式机或者笔记本吧。 + +#### 1、戴尔 + +![戴尔 XPS Ubuntu | 图片所有权: Lifehacker][3] + +戴尔提供 Ubuntu 笔记本已经有好几年了。他们的旗舰产品 XPS 系列的亮点之一就是预装了 Ubuntu 的开发者版本系列产品。 + +如果你读过我的 [戴尔 XPS Ubuntu 版本评测][4]就知道我是很喜欢这款笔记本的。两年多过去了,这个笔记本依然状况良好,没有性能恶化的迹象。 + +戴尔 XPS 是售价超过 1000 美元的昂贵设备。如果你的预算没有这么多,可以考虑戴尔更加亲民的 Inspiron 系列笔记本。 + +值得一提的是,戴尔并没有在它的官网上展示 Ubuntu 或者 Linux 笔记本产品。除非你知道戴尔提供 Linux 笔记本,你是不会找到它们的。 + +所以,去戴尔的官网上搜索关键字 “Ubuntu” 来获取预装 Ubuntu 的产品的信息吧。 + +**支持范围**:世界上大部分地区。 + +- [戴尔][5] + +#### 2、System76 + +[System76][6] 是 Linux 计算机世界里的一个响亮的名字。这家总部设在美国的企业专注于运行 Linux 的高端技术设备。他们的目标用户群体是软件开发者。 + +最初,System76 在自己的机器上提供的是 Ubuntu 系统。2017 年,他们发布了属于自己的 Linux 发行版,基于 Ubuntu 的 [Pop!\_OS][7]。从此以后,Pop!\_OS 就是他们机器上的默认操作系统了,但是仍然保留了 Ubuntu 这个选择。 + +除了性能之外,System76 还格外重视设计。他们的 [Thelio 系列台式机][8] 采用纯手工木制设计。 + +![System76 Thelio 台式机][9] + +你可以在 [这里][10] 查看他们提供的 Linux 笔记本。他们同时也提供 [基于 Linux 的迷你电脑][11] 和 [服务器][12]。 + +值得一提的是,System76 在美国制造他们的电脑,而没有使用中国大陆或者台湾这种常规的选择。也许是出于这个原因,他们产品的售价较为高昂。 + +**支持范围**:美国以及其它 60 个国家。在美国境外可能会有额外的关税。更多信息见[这里][13]. + +- [System76][6] + +#### 3、Purism + +Purism 是一个总部设在美国的企业,以提供确保数据安全和隐私的产品和服务为荣。这就是为什么 Purism 称自己为 “效力社会的公司”。 + +Purism 是从一个众筹项目开始的,该项目旨在创造一个几乎没有任何专有软件的高端开源笔记本。2015年,从这个 [成功的 25 万美元的众筹项目][15] 中诞生了 [Librem 15][16] 笔记本。 + +![Purism Librem 13][17] + +后来 Purism 发布了一个 13 英寸的版本 [Librem 13][18]。Purism 还开发了一个自己的 Linux 发行版 [Pure OS][19],该发行版非常注重隐私和安全问题。 + +[Pure OS 在台式设备和移动设备上都可以运行][20],并且是 Librem 笔记本和[Librem 5 Linux 手机][21] 的默认操纵系统。 + +Purism 的零部件来自中国大陆、台湾、日本以及美国,并在美国完成组装。他们的所有设备都有可以直接关闭的硬件开关,用来关闭麦克风、摄像头、无线连接或者是蓝牙。 + +**支持范围**:全世界范围国际免邮。可能需要支付额外的关税。 + +- [Purism][22] + +#### 4、Slimbook + +Slimbook 是一个总部设在西班牙的 Linux 电脑销售商。Slimbook 在发行了 [第一款 KDE 品牌笔记本][23]之后成为了人们关注的焦点。 + +他们的产品不仅限于 KDE Neon。他们还提供 Ubuntu、Kubuntu、Ubuntu MATE、Linux Mint 以及包括 [Lliurex][24] 和 [Max][25] 这样的西班牙发行版。你也可以选择 Windows(需要额外付费)或者不预装任何操作系统。 + +Slimbook 有众多 Linux 笔记本、台式机和迷你电脑可供选择。他们另外一个非常不错的产品是一个类似于 iMac 的 24 英寸 [拥有内置 CPU 的曲面显示屏][26]。 + +![Slimbook Kymera Aqua 水冷 Linux 电脑][27] + +想要一台水冷 Linux 电脑吗?Slimbook 的 [Kymera Aqua][28] 是合适之选。 + +**支持范围**:全世界范围,不过在邮费和关税上都可能产生额外费用。 + +- [Slimbook][29] + +#### 5、TUXEDO + +作为这个 Linux 电脑销售商清单里的另一个欧洲成员,[TUXEDO][30] 总部设在德国,主要服务德国用户,其次是欧洲用户。 + +TUXEDO 只使用 Linux 系统,产品都是“德国制造”,并且提供 5 年保修和终生售后支持。 + +TUXEDO 在 Linux 系统的硬件适配上下了很大功夫。并且如果你遇到了麻烦或者是想从头开始,可以通过系统恢复选项,自动恢复出厂设置。 + +![Tuxedo 电脑支持众多发行版][31] + +TUXEDO 有许多 Linux 笔记本、台式机和迷你电脑产品可供选择。他们还同时支持 Intel 和 AMD 的处理器。除了电脑,TUXEDO 还提供一系列 Linux 支持的附件,比如扩展坞、DVD 和蓝光刻录机、移动电源以及其它外围设备。 + +**支持范围**:150 欧元以上的订单在德国和欧洲范围内免邮。欧洲外国家会有额外的运费和关税。更多信息见 [这里][32]. + +- [TUXEDO][33] + +#### 6、Vikings + +[Vikings][34] 的总部设在德国(而不是斯堪的纳维亚半岛,哈哈)。Vikings 拥有[自由软件基金会][35]的认证,专注于自由友好的硬件。 + +![Vikings 的产品经过了自由软件基金会认证][36] + +Vikings 的 Linux 笔记本和台式机使用的是 [coreboot][37] 或者 [Libreboot][38],而不是像 BIOS 和 UEFI 这样的专有启动系统。你还可以购买不运行任何专有软件的 [硬件服务器][39]。 + +Vikings 还有包括路由器、扩展坞等在内的其它配件。他们的产品都是在德国组装完成的。 + +**支持范围**:全世界(除了朝鲜)。非欧洲国家可能会有额外关税费用。更多信息见[这里][40]。 + +- [Vikings][41] + +#### 7、Ubuntushop.be + +不不!尽管名字里有 Ubuntu,但这不是官方的 Ubuntu 商店。Ubuntushop 总部位于比利时,最初是销售安装了 Ubuntu 的电脑。 + +如今,你可以买到预装了包括 Mint、Manjaro、elementrayOS 在内的 Linux 发行版的笔记本电脑。你还可以要求所购买的设备上安装你所选择的发行版。 + +![][42] + +Ubuntushop 的一个独特之处在于,它的所有电脑都带有默认的 Tails OS live 选项。即使你安装了某个其它的 Linux 发行版作为日常使用的系统,也随时可以选择启动到 Tails OS(不需要使用 live USB)。[Tails OS][43] 是一个基于 Debian 的发行版,它在用户注销后会删除所有使用痕迹,并且在默认情况下使用 Tor 网络。 + +和此列表中的许多其他重要玩家不同,我觉得 Ubuntushop 所提供的更像是一种“家庭工艺”。商家手动组装一个电脑,安装 Linux 然后卖给你。不过他们也在一些可选项上下了功夫,比如说轻松的重装系统,拥有自己的云服务器等等。 + +你可以找一台旧电脑快递给他们,就可以变成一台新安装 Linux 的电脑,他们就会在你的旧电脑上安装 [轻量级 Linux][45] 系统然后快递回来,这样你这台旧电脑就可以重新投入使用了。 + +**支持范围**:比利时以及欧洲的其它地区。 + +- [Ubuntushop.be][46] + +#### 8、Minifree + +[Minifree][47],是自由部门Ministry of Freedom的缩写,他们是一家注册在英格兰的公司。 + +你可以猜到 Minifree 非常注重自由。他们提供安全以及注重隐私的电脑,预装 [Libreboot][38] 而不是 BIOS 或者 UEFI。 + +Minifree 的设备经过了 [自由软件基金会][48] 的认证,所以你可以放心买到的电脑都遵循了自由开源软件的指导规则。 + +![][49] + +和这个清单中许多其它 Linux 笔记本销售商不同,Minifree 的电脑并不是特别贵。花 200 欧元就可以买到一台预装了 Libreboot 和 [Trisquel GNU/Linux][50] 的 Linux 电脑。 + +除了笔记本以外,Minifree 还有一系列的配件,比如 Libre 路由器、平板电脑、扩展坞、电池、键盘、鼠标等等。 + +如果你和 [Richard Stallman][51] 一样,希望只运行 100% 自由的软件的话,Minifree 就再适合不过了。 + +**支持范围**:全世界。运费信息见 [这里][52]。 + +- [Minifree][47] + +#### 9、Entroware + +[Entroware][53] 是另一个总部设在英国的销售商,专注基于 Linux 系统的笔记本、台式机和服务器。 + +和这个清单里的很多其它商家一样,Entroware 也选择 Ubuntu 作为 Linux 发行版。[Ubuntu MATE 也是 Entroware Linux 笔记本的一种可选系统][54]. + +![][55] + +除了笔记本、台式机和服务器之外,Entroware 还拥有自己的 [迷你电脑 Aura][56],以及一个 iMac 风格的[内置 CPU 的显示器 Ares][57]. + +支持范围: 英国、爱尔兰、法国、德国、意大利、西班牙。 + +- [Entroware][58] + +#### 10、Juno + +这是我们清单上的一个新的 Linux 笔记本销售商。Juno 的总部同样设在英国,提供预装 Linux 的电脑。可选择的 Linux 发行版包括 elementary OS、Ubuntu 和 Solus OS。 + +Juno 提供一系列的笔记本,以及一款叫做 Olympia 迷你电脑。和列表里其它商家提供的大多数迷你电脑一样,Olympia 也基本上相当于一个 [Intel NUC][59]。 + +Juno 的主要特色是 Juve,一款售价 299 美元的 Chromebook 的低成本替代品。它运行一个双系统,包括 Solus 或者 elementray,以及一个基于安卓的电脑操作系统 [Prime OS][60]。 + +![Juve With Android-based Prime Os][61] + +支持范围:英国、美国、加拿大、墨西哥、南美和欧洲的大部分地区、新西兰、亚洲和非洲的某些地区。更多信息见 [这里][62]。 + +- [Juno Computers][63] + +#### 荣誉奖 + +我列举了 10 个可以买到 Linux 电脑的地方,但其实还有一些其它类似的商店。清单里放不下这么多,并且它们其中的几个似乎大多数商品都缺货。不过我还是要在这里稍微提一下它们,方便你自己查找相关信息: + + * [ZaReason][64] + * [Libiquity][65] + * [StationX][66] + * [Linux Certified][67] + * [Think Penguin][68] + +包括宏碁和联想在内的其它主流电脑生产商可能也有基于 Linux 系统的产品,所以你不妨也查看一下他们的产品目录吧。 + +你有没有买过 Linux 电脑?在哪儿买的?使用体验怎么样?Linux 笔记本值不值得买?分享一下你的想法吧。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/get-linux-laptops/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/guide-install-linux-mint-16-dual-boot-windows/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/05/buy-linux-laptops.jpeg?resize=800%2C450&ssl=1 +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/05/dell-xps-ubuntu.jpg?resize=800%2C450&ssl=1 +[4]: https://itsfoss.com/dell-xps-13-ubuntu-review/ +[5]: https://www.dell.com +[6]: https://system76.com/ +[7]: https://itsfoss.com/pop-os-linux-review/ +[8]: https://system76.com/desktops +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/system76-thelio-desktop.jpg?ssl=1 +[10]: https://system76.com/laptops +[11]: https://itsfoss.com/4-linux-based-mini-pc-buy-2015/ +[12]: https://system76.com/servers +[13]: https://system76.com/shipping +[14]: https://itsfoss.com/use-google-drive-linux/ +[15]: https://www.crowdsupply.com/purism/librem-15 +[16]: https://puri.sm/products/librem-15/ +[17]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/purism-librem-13.jpg?resize=800%2C471&ssl=1 +[18]: https://puri.sm/products/librem-13/ +[19]: https://www.pureos.net/ +[20]: https://itsfoss.com/pureos-convergence/ +[21]: https://itsfoss.com/librem-linux-phone/ +[22]: https://puri.sm/ +[23]: https://itsfoss.com/slimbook-kde/ +[24]: https://distrowatch.com/table.php?distribution=lliurex +[25]: https://en.wikipedia.org/wiki/MAX_(operating_system) +[26]: https://slimbook.es/en/aio-curve-all-in-one-for-gnu-linux +[27]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/Slimbook-Kymera-Aqua-Liquid-Cool-Linux-Computer.jpg?ssl=1 +[28]: https://slimbook.es/en/kymera-aqua-the-gnu-linux-computer-with-custom-water-cooling +[29]: https://slimbook.es/en/ +[30]: https://www.tuxedocomputers.com/ +[31]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/tuxedo-computers.jpeg?resize=800%2C400&ssl=1 +[32]: https://www.tuxedocomputers.com/en/Shipping-Returns.tuxedo +[33]: https://www.tuxedocomputers.com/en# +[34]: https://store.vikings.net/index.php?route=common/home +[35]: https://www.fsf.org +[36]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/vikings-computer.jpeg?resize=800%2C450&ssl=1 +[37]: https://www.coreboot.org/ +[38]: https://libreboot.org/ +[39]: https://store.vikings.net/libre-friendly-hardware/the-server-1u +[40]: https://store.vikings.net/index.php?route=information/information&information_id=8 +[41]: https://store.vikings.net/libre-friendly-hardware +[42]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/manjarobook-by-ubuntushop.jpeg?ssl=1 +[43]: https://tails.boum.org/ +[44]: https://itsfoss.com/things-to-do-after-installing-ubuntu-18-04/ +[45]: https://itsfoss.com/lightweight-linux-beginners/ +[46]: https://www.ubuntushop.be/index.php/en/ +[47]: https://minifree.org/ +[48]: https://www.fsf.org/ +[49]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/minifree.jpg?resize=800%2C550&ssl=1 +[50]: https://trisquel.info/ +[51]: https://en.wikipedia.org/wiki/Richard_Stallman +[52]: https://minifree.org/shipping-costs/ +[53]: https://www.entroware.com/ +[54]: https://itsfoss.com/ubuntu-mate-entroware/ +[55]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/entroware.jpg?resize=800%2C450&ssl=1 +[56]: https://itsfoss.com/ubuntu-entroware-aura-mini-pc/ +[57]: https://www.entroware.com/store/ares +[58]: https://www.entroware.com/store/index.php?route=common/home +[59]: https://www.amazon.com/Intel-NUC-Mainstream-Kit-NUC8i3BEH/dp/B07GX4X4PW?psc=1&SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B07GX4X4PW (Intel NUC) +[60]: https://primeos.in/ +[61]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/juve-with-prime-os.jpeg?ssl=1 +[62]: https://junocomputers.com/shipping +[63]: https://junocomputers.com/ +[64]: https://zareason.com/ +[65]: https://libiquity.com/ +[66]: https://stationx.rocks/ +[67]: https://www.linuxcertified.com/linux_laptops.html +[68]: https://www.thinkpenguin.com/ diff --git a/published/201906/20190517 Using Testinfra with Ansible to verify server state.md b/published/201906/20190517 Using Testinfra with Ansible to verify server state.md new file mode 100644 index 0000000000..9b2dc01e26 --- /dev/null +++ b/published/201906/20190517 Using Testinfra with Ansible to verify server state.md @@ -0,0 +1,154 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10943-1.html) +[#]: subject: (Using Testinfra with Ansible to verify server state) +[#]: via: (https://opensource.com/article/19/5/using-testinfra-ansible-verify-server-state) +[#]: author: (Clement Verna https://opensource.com/users/cverna/users/paulbischoff/users/dcritch/users/cobiacomm/users/wgarry155/users/kadinroob/users/koreyhilpert) + +使用 Testinfra 和 Ansible 验证服务器状态 +====== + +> Testinfra 是一个功能强大的库,可用于编写测试来验证基础设施的状态。另外它与 Ansible 和 Nagios 相结合,提供了一个用于架构即代码 (IaC) 的简单解决方案。 + +![Terminal command prompt on orange background][1] + +根据设计,[Ansible][2] 传递机器的期望状态,以确保 Ansible 剧本或角色的内容部署到目标机器上。但是,如果你需要确保所有基础架构更改都在 Ansible 中,该怎么办?或者想随时验证服务器的状态? + +[Testinfra][3] 是一个基础架构测试框架,它可以轻松编写单元测试来验证服务器的状态。它是一个 Python 库,使用强大的 [pytest][4] 测试引擎。 + +### 开始使用 Testinfra + +可以使用 Python 包管理器(`pip`)和 Python 虚拟环境轻松安装 Testinfra。 + +``` +$ python3 -m venv venv +$ source venv/bin/activate +(venv) $ pip install testinfra +``` + +Testinfra 也可以通过 Fedora 和 CentOS 的 EPEL 仓库中使用。例如,在 CentOS 7 上,你可以使用以下命令安装它: + +``` +$ yum install -y epel-release +$ yum install -y python-testinfra +``` + +#### 一个简单的测试脚本 + +在 Testinfra 中编写测试很容易。使用你选择的代码编辑器,将以下内容添加到名为 `test_simple.py` 的文件中: + +``` +import testinfra + +def test_os_release(host): + assert host.file("/etc/os-release").contains("Fedora") + +def test_sshd_inactive(host): + assert host.service("sshd").is_running is False +``` + +默认情况下,Testinfra 为测试用例提供了一个 `host` 对象,该对象能访问不同的辅助模块。例如,第一个测试使用 `file` 模块来验证主机上文件的内容,第二个测试用例使用 `service` 模块来检查 systemd 服务的状态。 + +要在本机运行这些测试,请执行以下命令: + +``` +(venv)$ pytest test_simple.py +================================ test session starts ================================ +platform linux -- Python 3.7.3, pytest-4.4.1, py-1.8.0, pluggy-0.9.0 +rootdir: /home/cverna/Documents/Python/testinfra +plugins: testinfra-3.0.0 +collected 2 items +test_simple.py .. + +================================ 2 passed in 0.05 seconds ================================ +``` + +有关 Testinfra API 的完整列表,你可以参考[文档][5]。 + +### Testinfra 和 Ansible + +Testinfra 支持的后端之一是 Ansible,这意味着 Testinfra 可以直接使用 Ansible 的清单文件和清单中定义的一组机器来对它们进行测试。 + +我们使用以下清单文件作为示例: + +``` +[web] +app-frontend01 +app-frontend02 + +[database] +db-backend01 +``` + +我们希望确保我们的 Apache Web 服务器在 `app-frontend01` 和 `app-frontend02` 上运行。让我们在名为 `test_web.py` 的文件中编写测试: + +``` +def check_httpd_service(host): + """Check that the httpd service is running on the host""" + assert host.service("httpd").is_running +``` + +要使用 Testinfra 和 Ansible 运行此测试,请使用以下命令: + + +``` +(venv) $ pip install ansible +(venv) $ py.test --hosts=web --ansible-inventory=inventory --connection=ansible test_web.py +``` + +在调用测试时,我们使用 Ansible 清单文件的 `[web]` 组作为目标计算机,并指定我们要使用 Ansible 作为连接后端。 + +#### 使用 Ansible 模块 + +Testinfra 还为 Ansible 提供了一个很好的可用于测试的 API。该 Ansible 模块能够在测试中运行 Ansible 动作,并且能够轻松检查动作的状态。 + +``` +def check_ansible_play(host): + """ + Verify that a package is installed using Ansible + package module + """ + assert not host.ansible("package", "name=httpd state=present")["changed"] +``` + +默认情况下,Ansible 的[检查模式][6]已启用,这意味着 Ansible 将报告在远程主机上执行动作时会发生的变化。 + +### Testinfra 和 Nagios + +现在我们可以轻松地运行测试来验证机器的状态,我们可以使用这些测试来触发监控系统上的警报。这是捕获意外的更改的好方法。 + +Testinfra 提供了与 [Nagios][7] 的集成,它是一种流行的监控解决方案。默认情况下,Nagios 使用 [NRPE][8] 插件对远程主机进行检查,但使用 Testinfra 可以直接从 Nagios 主控节点上运行测试。 + +要使 Testinfra 输出与 Nagios 兼容,我们必须在触发测试时使用 `--nagios` 标志。我们还使用 `-qq` 这个 pytest 标志来启用 pytest 的静默模式,这样就不会显示所有测试细节。 + +``` +(venv) $ py.test --hosts=web --ansible-inventory=inventory --connection=ansible --nagios -qq line test.py +TESTINFRA OK - 1 passed, 0 failed, 0 skipped in 2.55 seconds +``` + +Testinfra 是一个功能强大的库,可用于编写测试以验证基础架构的状态。 另外与 Ansible 和 Nagios 相结合,提供了一个用于架构即代码 (IaC) 的简单解决方案。 它也是使用 [Molecule][9] 开发 Ansible 角色过程中添加测试的关键组件。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/using-testinfra-ansible-verify-server-state + +作者:[Clement Verna][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/cverna/users/paulbischoff/users/dcritch/users/cobiacomm/users/wgarry155/users/kadinroob/users/koreyhilpert +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/terminal_command_linux_desktop_code.jpg?itok=p5sQ6ODE (Terminal command prompt on orange background) +[2]: https://www.ansible.com/ +[3]: https://testinfra.readthedocs.io/en/latest/ +[4]: https://pytest.org/ +[5]: https://testinfra.readthedocs.io/en/latest/modules.html#modules +[6]: https://docs.ansible.com/ansible/playbooks_checkmode.html +[7]: https://www.nagios.org/ +[8]: https://en.wikipedia.org/wiki/Nagios#NRPE +[9]: https://github.com/ansible/molecule diff --git a/published/201906/20190520 Getting Started With Docker.md b/published/201906/20190520 Getting Started With Docker.md new file mode 100644 index 0000000000..2349664ad9 --- /dev/null +++ b/published/201906/20190520 Getting Started With Docker.md @@ -0,0 +1,471 @@ +[#]: collector: "lujun9972" +[#]: translator: "zhang5788" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-10940-1.html" +[#]: subject: "Getting Started With Docker" +[#]: via: "https://www.ostechnix.com/getting-started-with-docker/" +[#]: author: "sk https://www.ostechnix.com/author/sk/" + +Docker 入门指南 +====== + +![Getting Started With Docker][1] + +在我们的上一个教程中,我们已经了解[如何在 Ubuntu 上安装 Docker][1],和如何在 [CentOS 上安装 Docker][2]。今天,我们将会了解 Docker 的一些基础用法。该教程包含了如何创建一个新的 Docker 容器,如何运行该容器,如何从现有的 Docker 容器中创建自己的 Docker 镜像等 Docker 的一些基础知识、操作。所有步骤均在 Ubuntu 18.04 LTS server 版本下测试通过。 + +### 入门指南 + +在开始指南之前,不要混淆 Docker 镜像和 Docker 容器这两个概念。在之前的教程中,我就解释过,Docker 镜像是决定 Docker 容器行为的一个文件,Docker 容器则是 Docker 镜像的运行态或停止态。(LCTT 译注:在 macOS 下使用 Docker 终端时,不需要加 `sudo`) + +#### 1、搜索 Docker 镜像 + +我们可以从 Docker 仓库中获取镜像,例如 [Docker hub][3],或者自己创建镜像。这里解释一下,Docker hub 是一个云服务器,用来提供给 Docker 的用户们创建、测试,和保存他们的镜像。 + +Docker hub 拥有成千上万个 Docker 镜像文件。你可以通过 `docker search`命令在这里搜索任何你想要的镜像。 + +例如,搜索一个基于 Ubuntu 的镜像文件,只需要运行: + +```shell +$ sudo docker search ubuntu +``` + +示例输出: + +![][5] + +搜索基于 CentOS 的镜像,运行: + +```shell +$ sudo docker search centos +``` + +搜索 AWS 的镜像,运行: + +```shell +$ sudo docker search aws +``` + +搜索 WordPress 的镜像: + +```shell +$ sudo docker search wordpress +``` + +Docker hub 拥有几乎所有种类的镜像,包含操作系统、程序和其他任意的类型,这些你都能在 Docker hub 上找到已经构建完的镜像。如果你在搜索时,无法找到你想要的镜像文件,你也可以自己构建一个,将其发布出去,或者仅供你自己使用。 + +#### 2、下载 Docker 镜像 + +下载 Ubuntu 的镜像,你需要在终端运行以下命令: + +```shell +$ sudo docker pull ubuntu +``` + +这条命令将会从 Docker hub 下载最近一个版本的 Ubuntu 镜像文件。 + +示例输出: + +``` +Using default tag: latest +latest: Pulling from library/ubuntu +6abc03819f3e: Pull complete +05731e63f211: Pull complete +0bd67c50d6be: Pull complete +Digest: sha256:f08638ec7ddc90065187e7eabdfac3c96e5ff0f6b2f1762cf31a4f49b53000a5 +Status: Downloaded newer image for ubuntu:latest +``` + +![下载 Docker 镜像][6] + +你也可以下载指定版本的 Ubuntu 镜像。运行以下命令: + +```shell +$ docker pull ubuntu:18.04 +``` + +Docker 允许在任意的宿主机操作系统下,下载任意的镜像文件,并运行。 + +例如,下载 CentOS 镜像: + +```shell +$ sudo docker pull centos +``` + +所有下载的镜像文件,都被保存在 `/var/lib/docker` 文件夹下。(LCTT 译注:不同操作系统存放的文件夹并不是一致的,具体存放位置请在官方查询) + +查看已经下载的镜像列表,可以使用以下命令: + +```shell +$ sudo docker images +``` + +示例输出: + +```shell +REPOSITORY TAG IMAGE ID CREATED SIZE +ubuntu latest 7698f282e524 14 hours ago 69.9MB +centos latest 9f38484d220f 2 months ago 202MB +hello-world latest fce289e99eb9 4 months ago 1.84kB +``` + +正如你看到的那样,我已经下载了三个镜像文件:`ubuntu`、`centos` 和 `hello-world`。 + +现在,让我们继续,来看一下如何运行我们刚刚下载的镜像。 + +#### 3、运行 Docker 镜像 + +运行一个容器有两种方法。我们可以使用标签或者是镜像 ID。标签指的是特定的镜像快照。镜像 ID 是指镜像的唯一标识。 + +正如上面结果中显示,`latest` 是所有镜像的一个标签。`7698f282e524` 是 Ubuntu Docker 镜像的镜像 ID,`9f38484d220f`是 CentOS 镜像的镜像 ID,`fce289e99eb9` 是 hello_world 镜像的 镜像 ID。 + +下载完 Docker 镜像之后,你可以通过下面的命令来使用其标签来启动: + +```shell +$ sudo docker run -t -i ubuntu:latest /bin/bash +``` + +在这条语句中: + +* `-t`:在该容器中启动一个新的终端 +* `-i`:通过容器中的标准输入流建立交互式连接 +* `ubuntu:latest`:带有标签 `latest` 的 Ubuntu 容器 +* `/bin/bash`:在新的容器中启动 BASH Shell + +或者,你可以通过镜像 ID 来启动新的容器: + +```shell +$ sudo docker run -t -i 7698f282e524 /bin/bash +``` + +在这条语句里: + +* `7698f282e524` — 镜像 ID + +在启动容器之后,将会自动进入容器的 shell 中(注意看命令行的提示符)。 + +![][7] + +*Docker 容器的 Shell* + +如果想要退回到宿主机的终端(在这个例子中,对我来说,就是退回到 18.04 LTS),并且不中断该容器的执行,你可以按下 `CTRL+P`,再按下 `CTRL+Q`。现在,你就安全的返回到了你的宿主机系统中。需要注意的是,Docker 容器仍然在后台运行,我们并没有中断它。 + +可以通过下面的命令来查看正在运行的容器: + +```shell +$ sudo docker ps +``` + +示例输出: + +```shell +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +32fc32ad0d54 ubuntu:latest "/bin/bash" 7 minutes ago Up 7 minutes modest_jones +``` + +![][8] + +*列出正在运行的容器* + +可以看到: + +* `32fc32ad0d54` – 容器 ID +* `ubuntu:latest` – Docker 镜像 + +需要注意的是,容器 ID 和 Docker 的镜像 ID是不同的。 + +可以通过以下命令查看所有正在运行和停止运行的容器: + +```shell +$ sudo docker ps -a +``` + +在宿主机中断容器的执行: + +```shell +$ sudo docker stop +``` + +例如: + +```shell +$ sudo docker stop 32fc32ad0d54 +``` + +如果想要进入正在运行的容器中,你只需要运行: + +```shell +$ sudo docker attach 32fc32ad0d54 +``` + +正如你看到的,`32fc32ad0d54` 是一个容器的 ID。当你在容器中想要退出时,只需要在容器内的终端中输入命令: + +```shell +# exit +``` + +你可以使用这个命令查看后台正在运行的容器: + +```shell +$ sudo docker ps +``` + +#### 4、构建自己的 Docker 镜像 + +Docker 不仅仅可以下载运行在线的容器,你也可以创建你的自己的容器。 + +想要创建自己的 Docker 镜像,你需要先运行一个你已经下载完的容器: + +```shell +$ sudo docker run -t -i ubuntu:latest /bin/bash +``` + +现在,你运行了一个容器,并且进入了该容器。然后,在该容器安装任意一个软件或做任何你想做的事情。 + +例如,我们在容器中安装一个 Apache web 服务器。 + +当你完成所有的操作,安装完所有的软件之后,你可以执行以下的命令来构建你自己的 Docker 镜像: + +```shell +# apt update +# apt install apache2 +``` + +同样的,在容器中安装和测试你想要安装的所有软件。 + +当你安装完毕之后,返回的宿主机的终端。记住,不要关闭容器。想要返回到宿主机而不中断容器。请按下`CTRL+P`,再按下 `CTRL+Q`。 + +从你的宿主机的终端中,运行以下命令如寻找容器的 ID: + +```shell +$ sudo docker ps +``` + +最后,从一个正在运行的容器中创建 Docker 镜像: + +```shell +$ sudo docker commit 3d24b3de0bfc ostechnix/ubuntu_apache +``` + +示例输出: + +```shell +sha256:ce5aa74a48f1e01ea312165887d30691a59caa0d99a2a4aa5116ae124f02f962 +``` + +在这里: + +* `3d24b3de0bfc` — 指 Ubuntu 容器的 ID。 +* `ostechnix` — 我们创建的容器的用户名称 +* `ubuntu_apache` — 我们创建的镜像 + +让我们检查一下我们新创建的 Docker 镜像: + +```shell +$ sudo docker images +``` + +示例输出: + +```shell +REPOSITORY TAG IMAGE ID CREATED SIZE +ostechnix/ubuntu_apache latest ce5aa74a48f1 About a minute ago 191MB +ubuntu latest 7698f282e524 15 hours ago 69.9MB +centos latest 9f38484d220f 2 months ago 202MB +hello-world latest fce289e99eb9 4 months ago 1.84kB +``` + +![][9] + +*列出所有的 Docker 镜像* + +正如你看到的,这个新的镜像就是我们刚刚在本地系统上从运行的容器上创建的。 + +现在,你可以从这个镜像创建一个新的容器。 + +```shell +$ sudo docker run -t -i ostechnix/ubuntu_apache /bin/bash +``` + +#### 5、删除容器 + +如果你在 Docker 上的工作已经全部完成,你就可以删除那些你不需要的容器。 + +想要删除一个容器,首先,你需要停止该容器。 + +我们先来看一下正在运行的容器有哪些 + +```shell +$ sudo docker ps +``` + +示例输出: + +```shell +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +3d24b3de0bfc ubuntu:latest "/bin/bash" 28 minutes ago Up 28 minutes goofy_easley +``` + +使用容器 ID 来停止该容器: + +```shell +$ sudo docker stop 3d24b3de0bfc +``` + +现在,就可以删除该容器了。 + +```shell +$ sudo docker rm 3d24b3de0bfc +``` + +你就可以按照这样的方法来删除那些你不需要的容器了。 + +当需要删除的容器数量很多时,一个一个删除也是很麻烦的,我们可以直接删除所有的已经停止的容器。只需要运行: + +```shell +$ sudo docker container prune +``` + +按下 `Y`,来确认你的操作: + +```sehll +WARNING! This will remove all stopped containers. +Are you sure you want to continue? [y/N] y +Deleted Containers: +32fc32ad0d5445f2dfd0d46121251c7b5a2aea06bb22588fb2594ddbe46e6564 +5ec614e0302061469ece212f0dba303c8fe99889389749e6220fe891997f38d0 + +Total reclaimed space: 5B +``` + +这个命令仅支持最新的 Docker。(LCTT 译注:仅支持 1.25 及以上版本的 Docker) + +#### 6、删除 Docker 镜像 + +当你删除了不要的 Docker 容器后,你也可以删除你不需要的 Docker 镜像。 + +列出已经下载的镜像: + +```shell +$ sudo docker images +``` + +示例输出: + +```shell +REPOSITORY TAG IMAGE ID CREATED SIZE +ostechnix/ubuntu_apache latest ce5aa74a48f1 5 minutes ago 191MB +ubuntu latest 7698f282e524 15 hours ago 69.9MB +centos latest 9f38484d220f 2 months ago 202MB +hello-world latest fce289e99eb9 4 months ago 1.84kB +``` + +由上面的命令可以知道,在本地的系统中存在三个镜像。 + +使用镜像 ID 来删除镜像。 + +```shell +$ sudo docekr rmi ce5aa74a48f1 +``` + +示例输出: + +```shell +Untagged: ostechnix/ubuntu_apache:latest +Deleted: sha256:ce5aa74a48f1e01ea312165887d30691a59caa0d99a2a4aa5116ae124f02f962 +Deleted: sha256:d21c926f11a64b811dc75391bbe0191b50b8fe142419f7616b3cee70229f14cd +``` + +#### 解决问题 + +Docker 禁止我们删除一个还在被容器使用的镜像。 + +例如,当我试图删除 Docker 镜像 `b72889fa879c` 时,我只能获得一个错误提示: + +```shell +Error response from daemon: conflict: unable to delete b72889fa879c (must be forced) - image is being used by stopped container dde4dd285377 +``` + +这是因为这个 Docker 镜像正在被一个容器使用。 + +所以,我们来检查一个正在运行的容器: + +```shell +$ sudo docker ps +``` + +示例输出: + +![][10] + +注意,现在并没有正在运行的容器!!! + +查看一下所有的容器(包含所有的正在运行和已经停止的容器): + +```shell +$ sudo docker pa -a +``` + +示例输出: + +![][11] + +可以看到,仍然有一些已经停止的容器在使用这些镜像。 + +让我们把这些容器删除: + +```shell +$ sudo docker rm 12e892156219 +``` + +我们仍然使用容器 ID 来删除这些容器。 + +当我们删除了所有使用该镜像的容器之后,我们就可以删除 Docker 的镜像了。 + +例如: + +```shell +$ sudo docekr rmi b72889fa879c +``` + +我们再来检查一下本机存在的镜像: + +```shell +$ sudo docker images +``` + +想要知道更多的细节,请参阅本指南末尾给出的官方资源的链接或者在评论区进行留言。 + +这就是全部的教程了,希望你可以了解 Docker 的一些基础用法。 + +更多的教程马上就会到来,敬请关注。 + +--- + +via: https://www.ostechnix.com/getting-started-with-docker/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[zhang5788](https://github.com/zhang5788) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2016/04/docker-basics-720x340.png +[2]: http://www.ostechnix.com/install-docker-ubuntu/ +[3]: https://www.ostechnix.com/install-docker-centos/ +[4]: https://hub.docker.com/ +[5]: http://www.ostechnix.com/wp-content/uploads/2016/04/Search-Docker-images.png +[6]: http://www.ostechnix.com/wp-content/uploads/2016/04/Download-docker-images.png +[7]: http://www.ostechnix.com/wp-content/uploads/2016/04/Docker-containers-shell.png +[8]: http://www.ostechnix.com/wp-content/uploads/2016/04/List-running-containers.png +[9]: http://www.ostechnix.com/wp-content/uploads/2016/04/List-docker-images.png +[10]: http://www.ostechnix.com/wp-content/uploads/2016/04/sk@sk-_005-1-1.jpg +[11]: http://www.ostechnix.com/wp-content/uploads/2016/04/sk@sk-_006-1.jpg +[12]: https://ostechnix.tradepub.com/free/w_java39/prgm.cgi?a=1 +[13]: https://ostechnix.tradepub.com/free/w_pacb32/prgm.cgi?a=1 +[14]: https://ostechnix.tradepub.com/free/w_pacb31/prgm.cgi?a=1 +[15]: https://ostechnix.tradepub.com/free/w_pacb29/prgm.cgi?a=1 +[16]: https://ostechnix.tradepub.com/free/w_pacb28/prgm.cgi?a=1 diff --git a/published/201906/20190520 When IoT systems fail- The risk of having bad IoT data.md b/published/201906/20190520 When IoT systems fail- The risk of having bad IoT data.md new file mode 100644 index 0000000000..6d8ee2c96a --- /dev/null +++ b/published/201906/20190520 When IoT systems fail- The risk of having bad IoT data.md @@ -0,0 +1,75 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10961-1.html) +[#]: subject: (When IoT systems fail: The risk of having bad IoT data) +[#]: via: (https://www.networkworld.com/article/3396230/when-iot-systems-fail-the-risk-of-having-bad-iot-data.html) +[#]: author: (Fredric Paul https://www.networkworld.com/author/Fredric-Paul/) + +当物联网系统出现故障:使用低质量物联网数据的风险 +====== + +> 伴随着物联网设备使用量的增长,这些设备产生的数据可以让消费者节约巨大的开支,也给商家带来新的机遇。但是当故障不可避免地出现的时候,会发生什么呢? + +![Oonal / Getty Images][1] + +不管你看的是什么统计数字,很明显物联网正在走进个人和私人生活的方方面面。这种增长虽然有不少好处,但是也带来了新的风险。一个很重要的问题是,出现问题的时候谁来负责呢? + +也许最大的问题出在基于物联网数据进行的个性化营销以及定价策略上。[保险公司长期以来致力于寻找利用物联网数据的最佳方式][2],我去年写过家庭财产保险公司是如何开始利用物联网传感器减少水灾带来的损失的。一些公司正在研究保险公司竞购消费者的可能性:这种业务基于智能家居数据所揭示的风险的高低。 + +但是最大的进步出现在汽车保险领域。许多汽车保险公司已经可以让客户在车辆上安装追踪设备,如果数据证明他们的驾驶习惯良好就可以获取保险折扣。 + +- 延伸阅读:[保险公司终于有了一个利用智能家居物联网的好办法][3] + +### UBI 车险的崛起 + +UBI(基于使用的保险usage-based insurance)车险是一种“按需付费”的业务,可以通过追踪速度、位置,以及其他因素来评估风险并计算车险保费。到 2020 年,预计有 [5000 万美国司机][4]会加入到 UBI 车险的项目中。 + +不出所料,保险公司对 UBI 车险青睐有加,因为 UBI 车险可以帮助他们更加精确地计算风险。事实上,[AIG 爱尔兰已经在尝试让国家向 25 岁以下的司机强制推行 UBI 车险][5]。并且,被认定为驾驶习惯良好的司机自然也很乐意节省一笔费用。当然也有反对的声音了,大多数是来自于隐私权倡导者,以及会因此支付更多费用的群体。 + +### 出了故障会发生什么? + +但是还有一个更加令人担忧的潜在问题:当物联网设备提供的数据有错误,或者在传输过程中出了问题会发生什么?因为尽管有自动化程序、错误检查等等,还是不可避免地会偶尔发生一些故障。 + +不幸的是,这并不是一个理论上某天会给细心的司机不小心多扣几块钱保费的问题。这已经是一个会带来严重后果的现实问题。就像[保险行业仍然没有想清楚谁应该“拥有”面向客户的物联网设备产生的数据][6]一样,我们也不清楚谁将对这些数据所带来的问题负责。 + +计算机“故障”据说曾导致赫兹的出租车辆被误报为被盗(虽然在这个例子中这并不是一个严格意义上的物联网问题),并且导致无辜的租车人被逮捕并扣留。结果呢?刑事指控,多年的诉讼官司,以及舆论的指责。非常强烈的舆论指责。 + +我们非常容易想象一些类似的情况,比如说一个物联网传感器出了故障,然后报告说某辆车超速了,然而事实上并没有超速。想想为这件事打官司的麻烦吧,或者想想和你的保险公司如何争执不下。 + +(当然,这个问题还有另外一面:消费者可能会想办法篡改他们的物联网设备上的数据,以获得更低的费率或者转移事故责任。我们同样也没有可行的办法来应对*这个问题*。) + +### 政府监管是否有必要 + +考虑到这些问题的潜在影响,以及所涉及公司对处理这些问题的无动于衷,我们似乎有理由猜想政府干预的必要性。 + +这可能是美国众议员 Bob Latta(俄亥俄州,共和党)[重新引入 SMART IOT(物联网现代应用、研究及趋势的现状)法案][7]背后的一个动机。这项由 Latta 和美国众议员 Peter Welch(佛蒙特州,民主党)领导的两党合作物联网工作组提出的[法案][8],于去年秋天通过美国众议院,但被美国参议院驳回了。美国商务部需要研究物联网行业的状况,并在两年后向美国众议院能源与商业部和美国参议院商务委员会报告。 + +Latta 在一份声明中表示,“由于预计会有数万亿美元的经济影响,我们需要考虑物联网所带来的的政策,机遇和挑战。SMART IoT 法案会让人们更容易理解美国政府在物联网政策上的做法、可以改进的地方,以及美国联邦政策如何影响尖端技术的研究和发明。” + +这项研究受到了欢迎,但该法案甚至可能不会被通过。即便通过了,物联网在两年的等待时间里也可能会翻天覆地,让美国政府还是无法跟上。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3396230/when-iot-systems-fail-the-risk-of-having-bad-iot-data.html + +作者:[Fredric Paul][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Fredric-Paul/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/08/cloud_connected_smart_cars_by_oonal_gettyimages-692819426_1200x800-100767788-large.jpg +[2]: https://www.networkworld.com/article/3264655/most-insurance-carriers-not-ready-to-use-iot-data.html +[3]: https://www.networkworld.com/article/3296706/finally-a-smart-way-for-insurers-to-leverage-iot-in-smart-homes.html +[4]: https://www.businessinsider.com/iot-is-changing-the-auto-insurance-industry-2015-8 +[5]: https://www.iotforall.com/iot-data-is-disrupting-the-insurance-industry/ +[6]: https://www.sas.com/en_us/insights/articles/big-data/5-challenges-for-iot-in-insurance-industry.html +[7]: https://www.multichannel.com/news/latta-re-ups-smart-iot-act +[8]: https://latta.house.gov/uploadedfiles/smart_iot_116th.pdf +[9]: https://www.facebook.com/NetworkWorld/ +[10]: https://www.linkedin.com/company/network-world diff --git a/published/201906/20190520 Zettlr - Markdown Editor for Writers and Researchers.md b/published/201906/20190520 Zettlr - Markdown Editor for Writers and Researchers.md new file mode 100644 index 0000000000..487c0f0fe3 --- /dev/null +++ b/published/201906/20190520 Zettlr - Markdown Editor for Writers and Researchers.md @@ -0,0 +1,109 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10922-1.html) +[#]: subject: (Zettlr – Markdown Editor for Writers and Researchers) +[#]: via: (https://itsfoss.com/zettlr-markdown-editor/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +Zettlr:适合写作者和研究人员的 Markdown 编辑器 +====== + +有很多[适用于 Linux 的 Markdown 编辑器][1],并且还在继续增加。问题是,像 [Boostnote][2] 一样,大多数是为编码人员设计的,可能不会受到非技术人员的欢迎。让我们看一个想要替代 Word 和昂贵的文字处理器,适用于非技术人员的 Markdown 编辑器。我们来看看 Zettlr 吧。 + +### Zettlr Markdown 编辑器 + +![Zettlr Light Mode][3] + +我可能在网站上提到过一两次,我更喜欢用 [Markdown][4] 写下我的所有文档。它易于学习,不会让你受困于专有文档格式。我还在我的[适合作者的开源工具列表][5]中提到了 Markdown 编辑器。 + +我用过许多 Markdown 编辑器,但是我一直有兴趣尝试新的。最近,我遇到了 Zettlr,一个开源 Markdown 编辑器。 + +[Zettlr][6] 是一位名叫 [Hendrik Erz][7] 的德国社会学家/政治理论家创建的。Hendrik 创建了 Zettlr,因为他对目前的文字处理器感到不满意。他想要可以让他“专注于写作和阅读”的编辑器。 + +在发现 Markdown 之后,他在不同的操作系统上尝试了几个 Markdown 编辑器。但它们都没有他想要的东西。[根据 Hendrik 的说法][8],“但我不得不意识到没有为高效组织大量文本而写的编辑器。大多数编辑都是由编码人员编写的,因此可以满足工程师和数学家的需求。没有为我这样的社会科学、历史或政治学的学生的编辑器。“ + +所以他决定创造自己的。2017 年 11 月,他开始编写 Zettlr。 + +![Zettlr About][9] + +#### Zettlr 功能 + +Zettlr 有许多简洁的功能,包括: + + * 从 [Zotero 数据库][10]导入源并在文档中引用它们 +  * 使用可选的行屏蔽,让你无打扰地专注于写作 +  * 支持代码高亮 +  * 使用标签对信息进行排序 +  * 能够为该任务设定写作目标 +  * 查看一段时间的写作统计 +  * 番茄钟计时器 +  * 浅色/深色主题 +  * 使用 [reveal.js][11] 创建演示文稿 +  * 快速预览文档 +  * 可以在一个项目文件夹中搜索 Markdown 文档,并用热图展示文字搜索密度。 +  * 将文件导出为 HTML、PDF、ODT、DOC、reStructuredText、LaTex、TXT、Emacs ORG、[TextBundle][12] 和 Textpack +  * 将自定义 CSS 添加到你的文档 + +当我写这篇文章时,一个对话框弹出来告诉我最近发布了 [1.3.0 beta][14]。此测试版将包括几个新的主题,以及一大堆修复,新功能和改进。 + +![Zettlr Night Mode][15] + +#### 安装 Zettlr + +目前,唯一可安装 Zettlr 的 Linux 存储库是 [AUR][16]。如果你的 Linux 发行版不是基于 Arch 的,你可以从网站上下载 macOS、Windows、Debian 和 Fedora 的[安装程序][17]。 + +#### 对 Zettlr 的最后一点想法 + +注意:为了测试 Zettlr,我用它来写这篇文章。 + +Zettlr 有许多我希望我之前选择的编辑器 (ghostwriter) 有的简洁的功能,例如为文档设置字数目标。我也喜欢在不打开文档的情况下预览文档的功能。 + +![Zettlr Settings][18] + +我也遇到了几个问题,但这些更多的是因为 Zettlr 与 ghostwriter 的工作方式略有不同。例如,当我尝试从网站复制引用或名称时,它会将内嵌样式粘贴到 Zettlr 中。幸运的是,它有一个“不带样式粘贴”的选项。有几次我在打字时有轻微的延迟。但那可能是因为它是一个 Electron 程序。 + +总的来说,我认为 Zettlr 是第一次使用 Markdown 用户的好选择。它有许多 Markdown 编辑器已有的功能,并为那些只使用过文字处理器的用户增加了一些功能。 + +正如 Hendrik 在 [Zettlr 网站][8]中所说的那样,“让自己摆脱文字处理器的束缚,看看你的写作过程如何通过身边的技术得到改善!” + +如果你觉得 Zettlr 有用,请考虑支持 [Hendrik][19]。正如他在网站上所说,“它是免费的,因为我不相信激烈竞争、早逝的创业文化。我只是想帮忙。” + +你有没有用过 Zettlr?你最喜欢的 Markdown 编辑器是什么?请在下面的评论中告诉我们。 + +如果你觉得这篇文章有趣,请在社交媒体,Hacker News 或 [Reddit][21] 上分享它。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/zettlr-markdown-editor/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/best-markdown-editors-linux/ +[2]: https://itsfoss.com/boostnote-linux-review/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/05/Zettlr-light-mode.png?fit=800%2C462&ssl=1 +[4]: https://daringfireball.net/projects/markdown/ +[5]: https://itsfoss.com/open-source-tools-writers/ +[6]: https://www.zettlr.com/ +[7]: https://github.com/nathanlesage +[8]: https://www.zettlr.com/about +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/05/zettlr-about.png?fit=800%2C528&ssl=1 +[10]: https://www.zotero.org/ +[11]: https://revealjs.com/#/ +[12]: http://textbundle.org/ +[13]: https://itsfoss.com/great-little-book-shelf-review/ +[14]: https://github.com/Zettlr/Zettlr/releases/tag/v1.3.0-beta +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/Zettlr-night-mode.png?fit=800%2C469&ssl=1 +[16]: https://aur.archlinux.org/packages/zettlr-bin/ +[17]: https://www.zettlr.com/download +[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/05/zettlr-settings.png?fit=800%2C353&ssl=1 +[19]: https://www.zettlr.com/supporters +[21]: http://reddit.com/r/linuxusersgroup diff --git a/published/201906/20190522 French IT giant Atos enters the edge-computing business.md b/published/201906/20190522 French IT giant Atos enters the edge-computing business.md new file mode 100644 index 0000000000..1be6353555 --- /dev/null +++ b/published/201906/20190522 French IT giant Atos enters the edge-computing business.md @@ -0,0 +1,62 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10934-1.html) +[#]: subject: (French IT giant Atos enters the edge-computing business) +[#]: via: (https://www.networkworld.com/article/3397139/atos-is-the-latest-to-enter-the-edge-computing-business.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +法国 IT 巨头 Atos 进军边缘计算 +====== + +> Atos 另辟蹊径,通过一种只有行李箱大小的设备 BullSequana Edge 进军边缘计算。 + +![iStock][1] + +法国 IT 巨头 Atos 是最近才开展边缘计算业务的,他们的产品是一个叫做 BullSequana Edge 的小型设备。和竞争对手们的集装箱大小的设备不同(比如说 Vapor IO 和 Schneider Electronics 的产品),Atos 的边缘设备完全可以被放进衣柜里。 + +Atos 表示,他们的这个设备使用人工智能应用提供快速响应,适合需要快速响应的领域比如生产 4.0、自动驾驶汽车、健康管理,以及零售业和机场的安保系统。在这些领域,数据需要在边缘进行实时处理和分析。 + +[延伸阅读:[什么是边缘计算?][2] 以及 [边缘网络和物联网如何重新定义数据中心][3]] + +BullSequana Edge 可以作为独立的基础设施单独采购,也可以和 Atos 的边缘软件捆绑采购,并且这个软件还是非常出色的。Atos 表示 BullSequana Edge 主要支持三种使用场景: + + * AI(人工智能):Atos 的边缘计算机视觉软件为监控摄像头提供先进的特征抽取和分析技术,包括人像、人脸、行为等特征。这些分析可以支持系统做出自动化响应。 + * 大数据:Atos 边缘数据分析系统通过预测性和规范性的解决方案,帮助机构优化商业模型。它使用数据湖的功能,确保数据的可信度和可用性。 + * 容器:Atos 边缘数据容器(EDC)是一种一体化容器解决方案。它可以作为一个去中心化的 IT 系统在边缘运行,并且可以在没有数据中心的环境下自动运行,而不需要现场操作。 + +由于体积小,BullSequana Edge 并不具备很强的处理能力。它装载一个 16 核的 Intel Xeon 中央处理器,可以装备最多两枚英伟达 Tesla T4 图形处理器或者是 FPGA(现场可编程门阵列)。Atos 表示,这就足够让复杂的 AI 模型在边缘进行低延迟的运行了。 + +考虑到数据的敏感性,BullSequana Edge 同时装备了一个入侵感应器,用来在遭遇物理入侵的时候禁用机器。 + +虽然大多数边缘设备都被安放在信号塔附近,但是考虑到边缘系统可能被安放在任何地方,BullSequana Edge 还支持通过无线电、全球移动通信系统(GSM),或者 Wi-Fi 来进行通信。 + +Atos 在美国也许不是一个家喻户晓的名字,但是在欧洲它可以和 IBM 相提并论,并且在过去的十年里已经收购了诸如 Bull SA、施乐 IT 外包以及西门子 IT 等 IT 巨头们。 + +关于边缘网络的延伸阅读: + + * [边缘网络和物联网如何重新定义数据中心][3] + * [边缘计算的最佳实践][4] + * [边缘计算如何提升物联网安全][5] + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3397139/atos-is-the-latest-to-enter-the-edge-computing-business.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/01/huawei-18501-edge-gartner-100786331-large.jpg +[2]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[3]: https://www.networkworld.com/article/3291790/data-center/how-edge-networking-and-iot-will-reshape-data-centers.html +[4]: https://www.networkworld.com/article/3331978/lan-wan/edge-computing-best-practices.html +[5]: https://www.networkworld.com/article/3331905/internet-of-things/how-edge-computing-can-help-secure-the-iot.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/published/201906/20190522 Securing telnet connections with stunnel.md b/published/201906/20190522 Securing telnet connections with stunnel.md new file mode 100644 index 0000000000..644d288c41 --- /dev/null +++ b/published/201906/20190522 Securing telnet connections with stunnel.md @@ -0,0 +1,201 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10945-1.html) +[#]: subject: (Securing telnet connections with stunnel) +[#]: via: (https://fedoramagazine.org/securing-telnet-connections-with-stunnel/) +[#]: author: (Curt Warfield https://fedoramagazine.org/author/rcurtiswarfield/) + +使用 stunnel 保护 telnet 连接 +====== + +![][1] + +Telnet 是一种客户端-服务端协议,通过 TCP 的 23 端口连接到远程服务器。Telnet 并不加密数据,因此它被认为是不安全的,因为数据是以明文形式发送的,所以密码很容易被嗅探。但是,仍有老旧系统需要使用它。这就是用到 **stunnel** 的地方。 + +stunnel 旨在为使用不安全连接协议的程序增加 SSL 加密。本文将以 telnet 为例介绍如何使用它。 + +### 服务端安装 + +[使用 sudo][2] 安装 stunnel 以及 telnet 的服务端和客户端: + +``` +sudo dnf -y install stunnel telnet-server telnet +``` + +添加防火墙规则,在提示时输入你的密码: + +``` +firewall-cmd --add-service=telnet --perm +firewall-cmd --reload +``` + +接下来,生成 RSA 私钥和 SSL 证书: + +``` +openssl genrsa 2048 > stunnel.key +openssl req -new -key stunnel.key -x509 -days 90 -out stunnel.crt +``` + +系统将一次提示你输入以下信息。当询问 `Common Name` 时,你必须输入正确的主机名或 IP 地址,但是你可以按回车键跳过其他所有内容。 + +``` +You are about to be asked to enter information that will be +incorporated into your certificate request. +What you are about to enter is what is called a Distinguished Name or a DN. +There are quite a few fields but you can leave some blank +For some fields there will be a default value, +If you enter '.', the field will be left blank. +----- +Country Name (2 letter code) [XX]: +State or Province Name (full name) []: +Locality Name (eg, city) [Default City]: +Organization Name (eg, company) [Default Company Ltd]: +Organizational Unit Name (eg, section) []: +Common Name (eg, your name or your server's hostname) []: +Email Address [] +``` + +将 RSA 密钥和 SSL 证书合并到单个 `.pem` 文件中,并将其复制到 SSL 证书目录: + +``` +cat stunnel.crt stunnel.key > stunnel.pem +sudo cp stunnel.pem /etc/pki/tls/certs/ +``` + +现在可以定义服务和用于加密连接的端口了。选择尚未使用的端口。此例使用 450 端口进行隧道传输 telnet。编辑或创建 `/etc/stunnel/telnet.conf`: + +``` +cert = /etc/pki/tls/certs/stunnel.pem +sslVersion = TLSv1 +chroot = /var/run/stunnel +setuid = nobody +setgid = nobody +pid = /stunnel.pid +socket = l:TCP_NODELAY=1 +socket = r:TCP_NODELAY=1 +[telnet] +accept = 450 +connect = 23 +``` + +`accept` 选项是服务器将监听传入 telnet 请求的接口。`connect` 选项是 telnet 服务器的内部监听接口。 + +接下来,创建一个 systemd 单元文件的副本来覆盖原来的版本: + +``` +sudo cp /usr/lib/systemd/system/stunnel.service /etc/systemd/system +``` + +编辑 `/etc/systemd/system/stunnel.service` 来添加两行。这些行在启动时为服务创建 chroot 监狱。 + +``` +[Unit] +Description=TLS tunnel for network daemons +After=syslog.target network.target + +[Service] +ExecStart=/usr/bin/stunnel +Type=forking +PrivateTmp=true +ExecStartPre=-/usr/bin/mkdir /var/run/stunnel +ExecStartPre=/usr/bin/chown -R nobody:nobody /var/run/stunnel + +[Install] +WantedBy=multi-user.target +``` + +接下来,配置 SELinux 以在你刚刚指定的新端口上监听 telnet: + +``` +sudo semanage port -a -t telnetd_port_t -p tcp 450 +``` + +最后,添加新的防火墙规则: + +``` +firewall-cmd --add-port=450/tcp --perm +firewall-cmd --reload +``` + +现在你可以启用并启动 telnet 和 stunnel。 + +``` +systemctl enable telnet.socket stunnel@telnet.service --now +``` + +要注意 `systemctl` 命令是有顺序的。systemd 和 stunnel 包默认提供额外的[模板单元文件][3]。该模板允许你将 stunnel 的多个配置文件放到 `/etc/stunnel` 中,并使用文件名启动该服务。例如,如果你有一个 `foobar.conf` 文件,那么可以使用 `systemctl start stunnel@foobar.service` 启动该 stunnel 实例,而无需自己编写任何单元文件。 + +如果需要,可以将此 stunnel 模板服务设置为在启动时启动: + +``` +systemctl enable stunnel@telnet.service +``` + +### 客户端安装 + +本文的这部分假设你在客户端系统上以普通用户([拥有 sudo 权限][2])身份登录。安装 stunnel 和 telnet 客户端: + +``` +dnf -y install stunnel telnet +``` + +将 `stunnel.pem` 从远程服务器复制到客户端的 `/etc/pki/tls/certs` 目录。在此例中,远程 telnet 服务器的 IP 地址为 `192.168.1.143`。 + +``` +sudo scp myuser@192.168.1.143:/etc/pki/tls/certs/stunnel.pem +/etc/pki/tls/certs/ +``` + +创建 `/etc/stunnel/telnet.conf`: + +``` +cert = /etc/pki/tls/certs/stunnel.pem +client=yes +[telnet] +accept=450 +connect=192.168.1.143:450 +``` + +`accept` 选项是用于 telnet 会话的端口。`connect` 选项是你远程服务器的 IP 地址以及监听的端口。 + +接下来,启用并启动 stunnel: + +``` +systemctl enable stunnel@telnet.service --now +``` + +测试你的连接。由于有一条已建立的连接,你会 `telnet` 到 `localhost` 而不是远程 telnet 服务器的主机名或者 IP 地址。 + +``` +[user@client ~]$ telnet localhost 450 +Trying ::1... +telnet: connect to address ::1: Connection refused +Trying 127.0.0.1... +Connected to localhost. +Escape character is '^]'. + +Kernel 5.0.9-301.fc30.x86_64 on an x86_64 (0) +server login: myuser +Password: XXXXXXX +Last login: Sun May 5 14:28:22 from localhost +[myuser@server ~]$ +``` + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/securing-telnet-connections-with-stunnel/ + +作者:[Curt Warfield][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/rcurtiswarfield/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/05/stunnel-816x345.jpg +[2]: https://fedoramagazine.org/howto-use-sudo/ +[3]: https://fedoramagazine.org/systemd-template-unit-files/ diff --git a/published/201906/20190525 4 Ways to Run Linux Commands in Windows.md b/published/201906/20190525 4 Ways to Run Linux Commands in Windows.md new file mode 100644 index 0000000000..88944d79af --- /dev/null +++ b/published/201906/20190525 4 Ways to Run Linux Commands in Windows.md @@ -0,0 +1,119 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10935-1.html) +[#]: subject: (4 Ways to Run Linux Commands in Windows) +[#]: via: (https://itsfoss.com/run-linux-commands-in-windows/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +在 Windows 中运行 Linux 命令的 4 种方法 +====== + +> 想要使用 Linux 命令,但又不想离开 Windows ?以下是在 Windows 中运行 Linux bash 命令的几种方法。 + +如果你正在课程中正在学习 shell 脚本,那么需要使用 Linux 命令来练习命令和脚本。 + +你的学校实验室可能安装了 Linux,但是你自己没有安装了 [Linux 的笔记本电脑][1],而是像其他人一样的 Windows 计算机。你的作业需要运行 Linux 命令,你或许想知道如何在 Windows 上运行 Bash 命令和脚本。 + +你可以[在双启动模式下同时安装 Windows 和 Linux][2]。此方法能让你在启动计算机时选择 Linux 或 Windows。但是,为了运行 Linux 命令而使用单独分区的麻烦可能不适合所有人。 + +你也可以[使用在线 Linux 终端][3],但你的作业无法保存。 + +好消息是,有几种方法可以在 Windows 中运行 Linux 命令,就像其他常规应用一样。不是很酷吗? + +### 在 Windows 中使用 Linux 命令 + +![](https://img.linux.net.cn/data/attachment/album/201906/04/093809hlz2tblfzt7mbwwl.jpg) + +作为一个热心的 Linux 用户和推广者,我希望看到越来越多的人使用“真正的” Linux,但我知道有时候,这不是优先考虑的问题。如果你只是想练习 Linux 来通过考试,可以使用这些方法之一在 Windows 上运行 Bash 命令。 + +#### 1、在 Windows 10 上使用 Linux Bash Shell + +你是否知道可以在 Windows 10 中运行 Linux 发行版? [Windows 的 Linux 子系统 (WSL)][5] 能让你在 Windows 中运行 Linux。即将推出的 WSL 版本将在 Windows 内部使用真正 Linux 内核。 + +此 WSL 也称为 Bash on Windows,它作为一个常规的 Windows 应用运行,并提供了一个命令行模式的 Linux 发行版。不要害怕命令行模式,因为你的目的是运行 Linux 命令。这就是你所需要的。 + +![Ubuntu Linux inside Windows][6] + +你可以在 Windows 应用商店中找到一些流行的 Linux 发行版,如 Ubuntu、Kali Linux、openSUSE 等。你只需像任何其他 Windows 应用一样下载和安装它。安装后,你可以运行所需的所有 Linux 命令。 + +![Linux distributions in Windows 10 Store][8] + +请参考教程:[在 Windows 上安装 Linux bash shell][9]。 + +#### 2、使用 Git Bash 在 Windows 上运行 Bash 命令 + +你可能知道 [Git][10] 是什么。它是由 [Linux 创建者 Linus Torvalds][11] 开发的版本控制系统。 + +[Git for Windows][12] 是一组工具,能让你在命令行和图形界面中使用 Git。Git for Windows 中包含的工具之一是 Git Bash。 + +Git Bash 为 Git 命令行提供了仿真层。除了 Git 命令,Git Bash 还支持许多 Bash 程序,如 `ssh`、`scp`、`cat`、`find` 等。 + +![Git Bash][13] + +换句话说,你可以使用 Git Bash 运行许多常见的 Linux/Bash 命令。 + +你可以从其网站免费下载和安装 Git for Windows 工具来在 Windows 中安装 Git Bash。 + +- [下载 Git for Windows][12] + +#### 3、使用 Cygwin 在 Windows 中使用 Linux 命令 + +如果要在 Windows 中运行 Linux 命令,那么 Cygwin 是一个推荐的工具。Cygwin 创建于 1995 年,旨在提供一个原生运行于 Windows 中的 POSIX 兼容环境。Cygwin 是由 Red Hat 员工和许多其他志愿者维护的自由开源软件。 + +二十年来,Windows 用户使用 Cygwin 来运行和练习 Linux/Bash 命令。十多年前,我甚至用 Cygwin 来学习 Linux 命令。 + +![Cygwin][14] + +你可以从下面的官方网站下载 Cygwin。我还建议你参考这个 [Cygwin 备忘录][15]来开始使用。 + +- [下载 Cygwin][16] + +#### 4、在虚拟机中使用 Linux + +另一种方法是使用虚拟化软件并在其中安装 Linux。这样,你可以在 Windows 中安装 Linux 发行版(带有图形界面)并像常规 Windows 应用一样运行它。 + +这种方法要求你的系统有大的内存,至少 4GB ,但如果你有超过 8GB 的内存那么更好。这里的好处是你可以真实地使用桌面 Linux。如果你喜欢这个界面,那么你可能会在以后决定[切换到 Linux][17]。 + +![Ubuntu Running in Virtual Machine Inside Windows][18] + +有两种流行的工具可在 Windows 上创建虚拟机,它们是 Oracle VirtualBox 和 VMware Workstation Player。你可以使用两者中的任何一个。就个人而言,我更喜欢 VirtualBox。 + +你可以按照[本教程学习如何在 VirtualBox 中安装 Linux][20]。 + +### 总结 + +运行 Linux 命令的最佳方法是使用 Linux。当选择不安装 Linux 时,这些工具能让你在 Windows 上运行 Linux 命令。都试试看,看哪种适合你。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/run-linux-commands-in-windows/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/get-linux-laptops/ +[2]: https://itsfoss.com/guide-install-linux-mint-16-dual-boot-windows/ +[3]: https://itsfoss.com/online-linux-terminals/ +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/run-linux-commands-in-windows.png?resize=800%2C450&ssl=1 +[5]: https://itsfoss.com/bash-on-windows/ +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/08/install-ubuntu-windows-10-linux-subsystem-10.jpeg?resize=800%2C268&ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/08/install-ubuntu-windows-10-linux-subsystem-4.jpeg?resize=800%2C632&ssl=1 +[9]: https://itsfoss.com/install-bash-on-windows/ +[10]: https://itsfoss.com/basic-git-commands-cheat-sheet/ +[11]: https://itsfoss.com/linus-torvalds-facts/ +[12]: https://gitforwindows.org/ +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/git-bash.png?ssl=1 +[14]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/05/cygwin-shell.jpg?ssl=1 +[15]: http://www.voxforge.org/home/docs/cygwin-cheat-sheet +[16]: https://www.cygwin.com/ +[17]: https://itsfoss.com/reasons-switch-linux-windows-xp/ +[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/05/ubuntu-running-in-virtual-machine-inside-windows.jpeg?resize=800%2C450&ssl=1 +[20]: https://itsfoss.com/install-linux-in-virtualbox/ diff --git a/published/201906/20190527 20- FFmpeg Commands For Beginners.md b/published/201906/20190527 20- FFmpeg Commands For Beginners.md new file mode 100644 index 0000000000..2a646c6d89 --- /dev/null +++ b/published/201906/20190527 20- FFmpeg Commands For Beginners.md @@ -0,0 +1,471 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10932-1.html) +[#]: subject: (20+ FFmpeg Commands For Beginners) +[#]: via: (https://www.ostechnix.com/20-ffmpeg-commands-beginners/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +给初学者的 20 多个 FFmpeg 命令示例 +====== + +![FFmpeg Commands](https://img.linux.net.cn/data/attachment/album/201906/03/011553xu323dzu40pb03bx.jpg) + +在这个指南中,我将用示例来阐明如何使用 FFmpeg 媒体框架来做各种各样的音频、视频转码和转换的操作。我已经为初学者汇集了最常用的 20 多个 FFmpeg 命令,我将不时地添加更多的示例来保持更新这个指南。请给这个指南加书签,以后回来检查更新。让我们开始吧,如果你还没有在你的 Linux 系统中安装 FFmpeg,参考下面的指南。 + +* [在 Linux 中安装 FFmpeg][2] + +### 针对初学者的 20 多个 FFmpeg 命令 + +FFmpeg 命令的典型语法是: + +``` +ffmpeg [全局选项] {[输入文件选项] -i 输入_url_地址} ... + {[输出文件选项] 输出_url_地址} ... +``` + +现在我们将查看一些重要的和有用的 FFmpeg 命令。 + +#### 1、获取音频/视频文件信息 + +为显示你的媒体文件细节,运行: + +``` +$ ffmpeg -i video.mp4 +``` + +样本输出: + +``` +ffmpeg version n4.1.3 Copyright (c) 2000-2019 the FFmpeg developers +built with gcc 8.2.1 (GCC) 20181127 +configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3 +libavutil 56. 22.100 / 56. 22.100 +libavcodec 58. 35.100 / 58. 35.100 +libavformat 58. 20.100 / 58. 20.100 +libavdevice 58. 5.100 / 58. 5.100 +libavfilter 7. 40.101 / 7. 40.101 +libswscale 5. 3.100 / 5. 3.100 +libswresample 3. 3.100 / 3. 3.100 +libpostproc 55. 3.100 / 55. 3.100 +Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4': +Metadata: +major_brand : isom +minor_version : 512 +compatible_brands: isomiso2avc1mp41 +encoder : Lavf58.20.100 +Duration: 00:00:28.79, start: 0.000000, bitrate: 454 kb/s +Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 318 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default) +Metadata: +handler_name : ISO Media file produced by Google Inc. Created on: 04/08/2019. +Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default) +Metadata: +handler_name : ISO Media file produced by Google Inc. Created on: 04/08/2019. +At least one output file must be specified +``` + +如你在上面的输出中看到的,FFmpeg 显示该媒体文件信息,以及 FFmpeg 细节,例如版本、配置细节、版权标记、构建参数和库选项等等。 + +如果你不想看 FFmpeg 标语和其它细节,而仅仅想看媒体文件信息,使用 `-hide_banner` 标志,像下面。 + +``` +$ ffmpeg -i video.mp4 -hide_banner +``` + +样本输出: + +![][3] + +*使用 FFMpeg 查看音频、视频文件信息。* + +看见了吗?现在,它仅显示媒体文件细节。 + + +#### 2、转换视频文件到不同的格式 + +FFmpeg 是强有力的音频和视频转换器,因此,它能在不同格式之间转换媒体文件。举个例子,要转换 mp4 文件到 avi 文件,运行: + +``` +$ ffmpeg -i video.mp4 video.avi +``` + +类似地,你可以转换媒体文件到你选择的任何格式。 + +例如,为转换 YouTube flv 格式视频为 mpeg 格式,运行: + +``` +$ ffmpeg -i video.flv video.mpeg +``` + +如果你想维持你的源视频文件的质量,使用 `-qscale 0` 参数: + +``` +$ ffmpeg -i input.webm -qscale 0 output.mp4 +``` + +为检查 FFmpeg 的支持格式的列表,运行: + +``` +$ ffmpeg -formats +``` + +#### 3、转换视频文件到音频文件 + +我转换一个视频文件到音频文件,只需具体指明输出格式,像 .mp3,或 .ogg,或其它任意音频格式。 + +上面的命令将转换 input.mp4 视频文件到 output.mp3 音频文件。 + +``` +$ ffmpeg -i input.mp4 -vn output.mp3 +``` + +此外,你也可以对输出文件使用各种各样的音频转换编码选项,像下面演示。 + +``` +$ ffmpeg -i input.mp4 -vn -ar 44100 -ac 2 -ab 320 -f mp3 output.mp3 +``` + +在这里, + + * `-vn` – 表明我们已经在输出文件中禁用视频录制。 + * `-ar` – 设置输出文件的音频频率。通常使用的值是22050 Hz、44100 Hz、48000 Hz。 + * `-ac` – 设置音频通道的数目。 + * `-ab` – 表明音频比特率。 + * `-f` – 输出文件格式。在我们的实例中,它是 mp3 格式。 + +#### 4、更改视频文件的分辨率 + +如果你想设置一个视频文件为指定的分辨率,你可以使用下面的命令: + +``` +$ ffmpeg -i input.mp4 -filter:v scale=1280:720 -c:a copy output.mp4 +``` + +或, + +``` +$ ffmpeg -i input.mp4 -s 1280x720 -c:a copy output.mp4 +``` + +上面的命令将设置所给定视频文件的分辨率到 1280×720。 + +类似地,为转换上面的文件到 640×480 大小,运行: + +``` +$ ffmpeg -i input.mp4 -filter:v scale=640:480 -c:a copy output.mp4 +``` + +或者, + +``` +$ ffmpeg -i input.mp4 -s 640x480 -c:a copy output.mp4 +``` + +这个技巧将帮助你缩放你的视频文件到较小的显示设备上,例如平板电脑和手机。 + +#### 5、压缩视频文件 + +减小媒体文件的大小到较小来节省硬件的空间总是一个好主意. + +下面的命令将压缩并减少输出文件的大小。 + +``` +$ ffmpeg -i input.mp4 -vf scale=1280:-1 -c:v libx264 -preset veryslow -crf 24 output.mp4 +``` + +请注意,如果你尝试减小视频文件的大小,你将损失视频质量。如果 24 太有侵略性,你可以降低 `-crf` 值到或更低值。 + +你也可以通过下面的选项来转换编码音频降低比特率,使其有立体声感,从而减小大小。 + +``` +-ac 2 -c:a aac -strict -2 -b:a 128k +``` + +#### 6、压缩音频文件 + +正像压缩视频文件一样,为节省一些磁盘空间,你也可以使用 `-ab` 标志压缩音频文件。 + +例如,你有一个 320 kbps 比特率的音频文件。你想通过更改比特率到任意较低的值来压缩它,像下面。 + +``` +$ ffmpeg -i input.mp3 -ab 128 output.mp3 +``` + +各种各样可用的音频比特率列表是: + + 1. 96kbps + 2. 112kbps + 3. 128kbps + 4. 160kbps + 5. 192kbps + 6. 256kbps + 7. 320kbps + +#### 7、从一个视频文件移除音频流 + +如果你不想要一个视频文件中的音频,使用 `-an` 标志。 + +``` +$ ffmpeg -i input.mp4 -an output.mp4 +``` + +在这里,`-an` 表示没有音频录制。 + +上面的命令会撤销所有音频相关的标志,因为我们不要来自 input.mp4 的音频。 + +#### 8、从一个媒体文件移除视频流 + +类似地,如果你不想要视频流,你可以使用 `-vn` 标志从媒体文件中简单地移除它。`-vn` 代表没有视频录制。换句话说,这个命令转换所给定媒体文件为音频文件。 + +下面的命令将从所给定媒体文件中移除视频。 + +``` +$ ffmpeg -i input.mp4 -vn output.mp3 +``` + +你也可以使用 `-ab` 标志来指出输出文件的比特率,如下面的示例所示。 + +``` +$ ffmpeg -i input.mp4 -vn -ab 320 output.mp3 +``` + +#### 9、从视频中提取图像 + +FFmpeg 的另一个有用的特色是我们可以从一个视频文件中轻松地提取图像。如果你想从一个视频文件中创建一个相册,这可能是非常有用的。 + +为从一个视频文件中提取图像,使用下面的命令: + +``` +$ ffmpeg -i input.mp4 -r 1 -f image2 image-%2d.png +``` + +在这里, + + * `-r` – 设置帧速度。即,每秒提取帧到图像的数字。默认值是 25。 + * `-f` – 表示输出格式,即,在我们的实例中是图像。 + * `image-%2d.png` – 表明我们如何想命名提取的图像。在这个实例中,命名应该像这样image-01.png、image-02.png、image-03.png 等等开始。如果你使用 `%3d`,那么图像的命名像 image-001.png、image-002.png 等等开始。 + +#### 10、裁剪视频 + +FFMpeg 允许以我们选择的任何范围裁剪一个给定的媒体文件。 + +裁剪一个视频文件的语法如下给定: + +``` +ffmpeg -i input.mp4 -filter:v "crop=w:h:x:y" output.mp4 +``` + +在这里, + + * `input.mp4` – 源视频文件。 + * `-filter:v` – 表示视频过滤器。 + * `crop` – 表示裁剪过滤器。 + * `w` – 我们想自源视频中裁剪的矩形的宽度。 + * `h` – 矩形的高度。 + * `x` – 我们想自源视频中裁剪的矩形的 x 坐标 。 + * `y` – 矩形的 y 坐标。 + +比如说你想要一个来自视频的位置 (200,150),且具有 640 像素宽度和 480 像素高度的视频,命令应该是: + +``` +$ ffmpeg -i input.mp4 -filter:v "crop=640:480:200:150" output.mp4 +``` + +请注意,剪切视频将影响质量。除非必要,请勿剪切。 + +#### 11、转换一个视频的具体的部分 + +有时,你可能想仅转换视频文件的一个具体的部分到不同的格式。以示例说明,下面的命令将转换所给定视频input.mp4 文件的开始 10 秒到视频 .avi 格式。 + +``` +$ ffmpeg -i input.mp4 -t 10 output.avi +``` + +在这里,我们以秒具体说明时间。此外,以 `hh.mm.ss` 格式具体说明时间也是可以的。 + +#### 12、设置视频的屏幕高宽比 + +你可以使用 `-aspect` 标志设置一个视频文件的屏幕高宽比,像下面。 + +``` +$ ffmpeg -i input.mp4 -aspect 16:9 output.mp4 +``` + +通常使用的高宽比是: + + * 16:9 + * 4:3 + * 16:10 + * 5:4 + * 2:21:1 + * 2:35:1 + * 2:39:1 + +#### 13、添加海报图像到音频文件 + +你可以添加海报图像到你的文件,以便图像将在播放音频文件时显示。这对托管在视频托管主机或共享网站中的音频文件是有用的。 + +``` +$ ffmpeg -loop 1 -i inputimage.jpg -i inputaudio.mp3 -c:v libx264 -c:a aac -strict experimental -b:a 192k -shortest output.mp4 +``` + +#### 14、使用开始和停止时间剪下一段媒体文件 + +可以使用开始和停止时间来剪下一段视频为小段剪辑,我们可以使用下面的命令。 + +``` +$ ffmpeg -i input.mp4 -ss 00:00:50 -codec copy -t 50 output.mp4 +``` + +在这里, + + * `–s` – 表示视频剪辑的开始时间。在我们的示例中,开始时间是第 50 秒。 + * `-t` – 表示总的持续时间。 + +当你想使用开始和结束时间从一个音频或视频文件剪切一部分时,它是非常有用的。 + +类似地,我们可以像下面剪下音频。 + +``` +$ ffmpeg -i audio.mp3 -ss 00:01:54 -to 00:06:53 -c copy output.mp3 +``` + +#### 15、切分视频文件为多个部分 + +一些网站将仅允许你上传具体指定大小的视频。在这样的情况下,你可以切分大的视频文件到多个较小的部分,像下面。 + +``` +$ ffmpeg -i input.mp4 -t 00:00:30 -c copy part1.mp4 -ss 00:00:30 -codec copy part2.mp4 +``` + +在这里, + + * `-t 00:00:30` 表示从视频的开始到视频的第 30 秒创建一部分视频。 + * `-ss 00:00:30` 为视频的下一部分显示开始时间戳。它意味着第 2 部分将从第 30 秒开始,并将持续到原始视频文件的结尾。 + +#### 16、接合或合并多个视频部分到一个 + +FFmpeg 也可以接合多个视频部分,并创建一个单个视频文件。 + +创建包含你想接合文件的准确的路径的 `join.txt`。所有的文件都应该是相同的格式(相同的编码格式)。所有文件的路径应该逐个列出,像下面。 + +``` +file /home/sk/myvideos/part1.mp4 +file /home/sk/myvideos/part2.mp4 +file /home/sk/myvideos/part3.mp4 +file /home/sk/myvideos/part4.mp4 +``` + +现在,接合所有文件,使用命令: + +``` +$ ffmpeg -f concat -i join.txt -c copy output.mp4 +``` + +如果你得到一些像下面的错误; + +``` +[concat @ 0x555fed174cc0] Unsafe file name '/path/to/mp4' +join.txt: Operation not permitted +``` + +添加 `-safe 0` : + +``` +$ ffmpeg -f concat -safe 0 -i join.txt -c copy output.mp4 +``` + +上面的命令将接合 part1.mp4、part2.mp4、part3.mp4 和 part4.mp4 文件到一个称为 output.mp4 的单个文件中。 + +#### 17、添加字幕到一个视频文件 + +我们可以使用 FFmpeg 来添加字幕到视频文件。为你的视频下载正确的字幕,并如下所示添加它到你的视频。 + +``` +$ fmpeg -i input.mp4 -i subtitle.srt -map 0 -map 1 -c copy -c:v libx264 -crf 23 -preset veryfast output.mp4 +``` + +#### 18、预览或测试视频或音频文件 + +你可能希望通过预览来验证或测试输出的文件是否已经被恰当地转码编码。为完成预览,你可以从你的终端播放它,用命令: + +``` +$ ffplay video.mp4 +``` + +![][7] + +类似地,你可以测试音频文件,像下面所示。 + +``` +$ ffplay audio.mp3 +``` + +![][8] + +#### 19、增加/减少视频播放速度 + +FFmpeg 允许你调整视频播放速度。 + +为增加视频播放速度,运行: + +``` +$ ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" output.mp4 +``` + +该命令将双倍视频的速度。 + +为降低你的视频速度,你需要使用一个大于 1 的倍数。为减少播放速度,运行: + +``` +$ ffmpeg -i input.mp4 -vf "setpts=4.0*PTS" output.mp4 +``` + +#### 20、创建动画的 GIF + +出于各种目的,我们在几乎所有的社交和专业网络上使用 GIF 图像。使用 FFmpeg,我们可以简单地和快速地创建动画的视频文件。下面的指南阐释了如何在类 Unix 系统中使用 FFmpeg 和 ImageMagick 创建一个动画的 GIF 文件。 + + * [在 Linux 中如何创建动画的 GIF][9] + +#### 21、从 PDF 文件中创建视频 + +我长年累月的收集了很多 PDF 文件,大多数是 Linux 教程,保存在我的平板电脑中。有时我懒得从平板电脑中阅读它们。因此,我决定从 PDF 文件中创建一个视频,在一个大屏幕设备(像一台电视机或一台电脑)中观看它们。如果你想知道如何从一批 PDF 文件中制作一个电影,下面的指南将帮助你。 + + * [在 Linux 中如何从 PDF 文件中创建一个视频][10] + +#### 22、获取帮助 + +在这个指南中,我已经覆盖大多数常常使用的 FFmpeg 命令。它有很多不同的选项来做各种各样的高级功能。要学习更多用法,请参考手册页。 + +``` +$ man ffmpeg +``` + +这就是全部了。我希望这个指南将帮助你入门 FFmpeg。如果你发现这个指南有用,请在你的社交和专业网络上分享它。更多好东西将要来。敬请期待! + +谢谢! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/20-ffmpeg-commands-beginners/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2017/05/FFmpeg-Commands-720x340.png +[2]: https://www.ostechnix.com/install-ffmpeg-linux/ +[3]: http://www.ostechnix.com/wp-content/uploads/2017/05/sk@sk_001.png +[4]: https://ostechnix.tradepub.com/free/w_make141/prgm.cgi +[5]: https://ostechnix.tradepub.com/free/w_make75/prgm.cgi +[6]: https://ostechnix.tradepub.com/free/w_make235/prgm.cgi +[7]: http://www.ostechnix.com/wp-content/uploads/2017/05/Menu_004.png +[8]: http://www.ostechnix.com/wp-content/uploads/2017/05/Menu_005-3.png +[9]: https://www.ostechnix.com/create-animated-gif-ubuntu-16-04/ +[10]: https://www.ostechnix.com/create-video-pdf-files-linux/ diff --git a/published/201906/20190527 5 GNOME keyboard shortcuts to be more productive.md b/published/201906/20190527 5 GNOME keyboard shortcuts to be more productive.md new file mode 100644 index 0000000000..9ba4bc2d57 --- /dev/null +++ b/published/201906/20190527 5 GNOME keyboard shortcuts to be more productive.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10997-1.html) +[#]: subject: (5 GNOME keyboard shortcuts to be more productive) +[#]: via: (https://fedoramagazine.org/5-gnome-keyboard-shortcuts-to-be-more-productive/) +[#]: author: (Clément Verna https://fedoramagazine.org/author/cverna/) + +5 个提高效率的 GNOME 快捷键 +====== + +![][1] + +对于某些人来说,使用 GNOME Shell 作为传统的桌面管理器可能会感觉沮丧,因为它通常需要更多的鼠标操作。事实上,GNOME Shell 也是一个专为键盘操作而设计的[桌面管理器][2]。通过这五种使用键盘而不是鼠标的方法,了解如何使用 GNOME Shell 提高效率。 + +### GNOME 活动概述 + +可以使用键盘上的 `Super` 键轻松打开活动概述。(`Super` 键通常有一个标识——比如 Windows 徽标……)这在启动应用程序时非常有用。例如,使用以下键序列 `Super + f i r + Enter` 可以轻松启动 Firefox Web 浏览器 + +![][3] + +### 消息托盘 + +在 GNOME 中,消息托盘中提供了通知。这也是日历和世界时钟出现的地方。要使用键盘打开信息托盘,请使用 `Super + m` 快捷键。要关闭消息托盘,只需再次使用相同的快捷方式。 + +![][4] + +### 在 GNOME 中管理工作空间 + +GNOME Shell 使用动态工作空间,这意味着它可以根据需要创建更多工作空间。使用 GNOME 提高工作效率的一个好方法是为每个应用程序或每个专用活动使用一个工作区,然后使用键盘在这些工作区之间导航。 + +让我们看一个实际的例子。要在当前工作区中打开终端,请按以下键:`Super + t e r + Enter`。然后,要打开新工作区,请按 `Super + PgDn`。 打开 Firefox( `Super + f i r + Enter`)。 要返回终端(所在的工作空间),请使用 `Super + PgUp`。 + +![][5] + +### 管理应用窗口 + +使用键盘也可以轻松管理应用程序窗口的大小。最小化、最大化和将应用程序移动到屏幕的左侧或右侧只需几个击键即可完成。使用 `Super + ↑` 最大化、`Super + ↓` 最小化、`Super + ←` 和 `Super + →` 左右移动窗口。 + +![][6] + +### 同一个应用的多个窗口 + +使用活动概述启动应用程序非常有效。但是,尝试从已经运行的应用程序打开一个新窗口只能将焦点转移到已经打开的窗口。要创建一个新窗口,就不是简单地按 `Enter` 启动应用程序,请使用 `Ctrl + Enter`。 + +因此,例如,使用应用程序概述启动终端的第二个实例,`Super + t e r + (Ctrl + Enter)`。 + +![][7] + +然后你可以使用 `Super` + ` 在同一个应用程序的窗口之间切换。 + +![][8] + +如图所示,当用键盘控制时,GNOME Shell 是一个非常强大的桌面环境。学习使用这些快捷方式并训练你的肌肉记忆以不使用鼠标将为你提供更好的用户体验,并在使用 GNOME 时提高你的工作效率。有关其他有用的快捷方式,请查看 [GNOME wiki 上的此页面][9]。 + +*图片来自 [1AmFcS][10],[Unsplash][11]* + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/5-gnome-keyboard-shortcuts-to-be-more-productive/ + +作者:[Clément Verna][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/cverna/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/05/5-gnome-keycombos-816x345.jpg +[2]: https://fedoramagazine.org/gnome-3-32-released-coming-to-fedora-30/ +[3]: https://fedoramagazine.org/wp-content/uploads/2019/05/Peek-2019-05-23-10-50.gif +[4]: https://fedoramagazine.org/wp-content/uploads/2019/05/Peek-2019-05-23-11-01.gif +[5]: https://fedoramagazine.org/wp-content/uploads/2019/05/Peek-2019-05-23-12-57.gif +[6]: https://fedoramagazine.org/wp-content/uploads/2019/05/Peek-2019-05-23-13-06.gif +[7]: https://fedoramagazine.org/wp-content/uploads/2019/05/Peek-2019-05-23-13-19.gif +[8]: https://fedoramagazine.org/wp-content/uploads/2019/05/Peek-2019-05-23-13-22.gif +[9]: https://wiki.gnome.org/Design/OS/KeyboardShortcuts +[10]: https://unsplash.com/photos/MuTWth_RnEs?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[11]: https://unsplash.com/search/photos/keyboard?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/201906/20190527 A deeper dive into Linux permissions.md b/published/201906/20190527 A deeper dive into Linux permissions.md new file mode 100644 index 0000000000..a4bba97507 --- /dev/null +++ b/published/201906/20190527 A deeper dive into Linux permissions.md @@ -0,0 +1,171 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10947-1.html) +[#]: subject: (A deeper dive into Linux permissions) +[#]: via: (https://www.networkworld.com/article/3397790/a-deeper-dive-into-linux-permissions.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +更深入地了解 Linux 权限 +====== +> 在 Linux 上查看文件权限时,有时你会看到的不仅仅是普通的 r、w、x 和 -。如何更清晰地了解这些字符试图告诉你什么以及这些权限如何工作? + +![Sandra Henry-Stocker](https://img.linux.net.cn/data/attachment/album/201906/07/150718q09wnve6ne6v9063.jpg) + +在 Linux 上查看文件权限时,有时你会看到的不仅仅是普通的 `r`、`w`、`x` 和 `-`。除了在所有者、组和其他中看到 `rwx` 之外,你可能会看到 `s` 或者 `t`,如下例所示: + +``` +drwxrwsrwt +``` + +要进一步明确的方法之一是使用 `stat` 命令查看权限。`stat` 的第四行输出以八进制和字符串格式显示文件权限: + +``` +$ stat /var/mail + File: /var/mail + Size: 4096 Blocks: 8 IO Block: 4096 directory +Device: 801h/2049d Inode: 1048833 Links: 2 +Access: (3777/drwxrwsrwt) Uid: ( 0/ root) Gid: ( 8/ mail) +Access: 2019-05-21 19:23:15.769746004 -0400 +Modify: 2019-05-21 19:03:48.226656344 -0400 +Change: 2019-05-21 19:03:48.226656344 -0400 + Birth: - +``` + +这个输出提示我们,分配给文件权限的位数超过 9 位。事实上,有 12 位。这些额外的三位提供了一种分配超出通常的读、写和执行权限的方法 - 例如,`3777`(二进制 `011111111111`)表示使用了两个额外的设置。 + +该值的第一个 `1` (第二位)表示 SGID(设置 GID),为运行文件而赋予临时权限,或以该关联组的权限来使用目录。 + +``` +011111111111 + ^ +``` + +SGID 将正在使用该文件的用户作为该组成员之一而分配临时权限。 + +第二个 `1`(第三位)是“粘连”位。它确保*只有*文件的所有者能够删除或重命名该文件或目录。 + +``` +011111111111 + ^ +``` + +如果权限是 `7777` 而不是 `3777`,我们知道 SUID(设置 UID)字段也已设置。 + +``` +111111111111 +^ +``` + +SUID 将正在使用该文件的用户作为文件拥有者分配临时权限。 + +至于我们上面看到的 `/var/mail` 目录,所有用户都需要访问,因此需要一些特殊值来提供它。 + +但现在让我们更进一步。 + +特殊权限位的一个常见用法是使用 `passwd` 之类的命令。如果查看 `/usr/bin/passwd` 文件,你会注意到 SUID 位已设置,它允许你更改密码(以及 `/etc/shadow` 文件的内容),即使你是以普通(非特权)用户身份运行,并且对此文件没有读取或写入权限。当然,`passwd` 命令很聪明,不允许你更改其他人的密码,除非你是以 root 身份运行或使用 `sudo`。 + +``` +$ ls -l /usr/bin/passwd +-rwsr-xr-x 1 root root 63736 Mar 22 14:32 /usr/bin/passwd +$ ls -l /etc/shadow +-rw-r----- 1 root shadow 2195 Apr 22 10:46 /etc/shadow +``` + +现在,让我们看一下使用这些特殊权限可以做些什么。 + +### 如何分配特殊文件权限 + +与 Linux 命令行中的许多东西一样,你可以有不同的方法设置。 `chmod` 命令允许你以数字方式或使用字符表达式更改权限。 + +要以数字方式更改文件权限,你可以使用这样的命令来设置 SUID 和 SGID 位: + +``` +$ chmod 6775 tryme +``` + +或者你可以使用这样的命令: + +``` +$ chmod ug+s tryme <== 用于 SUID 和 SGID 权限 +``` + +如果你要添加特殊权限的文件是脚本,你可能会对它不符合你的期望感到惊讶。这是一个非常简单的例子: + +``` +$ cat tryme +#!/bin/bash + +echo I am $USER +``` + +即使设置了 SUID 和 SGID 位,并且 root 是文件所有者,运行脚本也不会产生你可能期望的 “I am root”。为什么?因为 Linux 会忽略脚本的 SUID 和 SGID 位。 + +``` +$ ls -l tryme +-rwsrwsrwt 1 root root 29 May 26 12:22 tryme +$ ./tryme +I am jdoe +``` + +另一方面,如果你对一个编译的程序之类进行类似的尝试,就像下面这个简单的 C 程序一样,你会看到不同的效果。在此示例程序中,我们提示用户输入文件名并创建它,并给文件写入权限。 + +``` +#include + +int main() +{ + FILE *fp; /* file pointer*/ + char fName[20]; + + printf("Enter the name of file to be created: "); + scanf("%s",fName); + + /* create the file with write permission */ + fp=fopen(fName,"w"); + /* check if file was created */ + if(fp==NULL) + { + printf("File not created"); + exit(0); + } + + printf("File created successfully\n"); + return 0; +} +``` + +编译程序并运行该命令以使 root 用户成为所有者并设置所需权限后,你将看到它以预期的 root 权限运行 - 留下新创建的 root 为所有者的文件。当然,你必须具有 `sudo` 权限才能运行一些需要的命令。 + +``` +$ cc -o mkfile mkfile.c <== 编译程序 +$ sudo chown root:root mkfile <== 更改所有者和组为 “root” +$ sudo chmod ug+s mkfile <== 添加 SUID and SGID 权限 +$ ./mkfile <== 运行程序 +Enter name of file to be create: empty +File created successfully +$ ls -l empty +-rw-rw-r-- 1 root root 0 May 26 13:15 empty +``` + +请注意,文件所有者是 root - 如果程序未以 root 权限运行,则不会发生这种情况。 + +权限字符串中不常见设置的位置(例如,rw**s**rw**s**rw**t**)可以帮助提醒我们每个位的含义。至少第一个 “s”(SUID) 位于所有者权限区域中,第二个 (SGID) 位于组权限区域中。为什么粘连位是 “t” 而不是 “s” 超出了我的理解。也许创造者想把它称为 “tacky bit”,但由于这个词的不太令人喜欢的第二个定义而改变了他们的想法。无论如何,额外的权限设置为 Linux 和其他 Unix 系统提供了许多额外的功能。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3397790/a-deeper-dive-into-linux-permissions.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/05/shs_rwsr-100797564-large.jpg +[2]: https://www.facebook.com/NetworkWorld/ +[3]: https://www.linkedin.com/company/network-world diff --git a/published/201906/20190527 Dockly - Manage Docker Containers From Terminal.md b/published/201906/20190527 Dockly - Manage Docker Containers From Terminal.md new file mode 100644 index 0000000000..44e9dc2c21 --- /dev/null +++ b/published/201906/20190527 Dockly - Manage Docker Containers From Terminal.md @@ -0,0 +1,146 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10925-1.html) +[#]: subject: (Dockly – Manage Docker Containers From Terminal) +[#]: via: (https://www.ostechnix.com/dockly-manage-docker-containers-from-terminal/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +Dockly:从终端管理 Docker 容器 +====== + +![](https://img.linux.net.cn/data/attachment/album/201906/01/144422bfwx1e7fqx1ee11x.jpg) + +几天前,我们发布了一篇指南,其中涵盖了[开始使用 Docker][2] 时需要了解的几乎所有细节。在该指南中,我们向你展示了如何详细创建和管理 Docker 容器。还有一些可用于管理 Docker 容器的非官方工具。如果你看过我们以前的文章,你可能会看到两个基于 Web 的工具,[Portainer][3] 和 [PiCluster][4]。它们都使得 Docker 管理任务在 Web 浏览器中变得更加容易和简单。今天,我遇到了另一个名为 Dockly 的 Docker 管理工具。 + +与上面的工具不同,Dockly 是一个 TUI(文本界面)程序,用于在类 Unix 系统中从终端管理 Docker 容器和服务。它是使用 NodeJS 编写的自由开源工具。在本简要指南中,我们将了解如何安装 Dockly 以及如何从命令行管理 Docker 容器。 + +### 安装 Dockly + +确保已在 Linux 上安装了 NodeJS。如果尚未安装,请参阅以下指南。 + +* [如何在 Linux 上安装 NodeJS][5] + +安装 NodeJS 后,运行以下命令安装 Dockly: + +``` +# npm install -g dockly +``` + +### 使用 Dockly 在终端管理 Docker 容器 + +使用 Dockly 管理 Docker 容器非常简单!你所要做的就是打开终端并运行以下命令: + +``` +# dockly +``` + +Dockly 将通过 unix 套接字自动连接到你的本机 docker 守护进程,并在终端中显示正在运行的容器列表,如下所示。 + +![][6] + +*使用 Dockly 管理 Docker 容器* + +正如你在上面的截图中看到的,Dockly 在顶部显示了运行容器的以下信息: + +* 容器 ID, +* 容器名称, +* Docker 镜像, +* 命令, +* 运行中容器的状态, +* 状态。 + +在右上角,你将看到容器的 CPU 和内存利用率。使用向上/向下箭头键在容器之间移动。 + +在底部,有少量的键盘快捷键来执行各种 Docker 管理任务。以下是目前可用的键盘快捷键列表: + +* `=` - 刷新 Dockly 界面, +* `/` - 搜索容器列表视图, +* `i` - 显示有关当前所选容器或服务的信息, +* `回车` - 显示当前容器或服务的日志, +* `v` - 在容器和服务视图之间切换, +* `l` - 在选定的容器上启动 `/bin/bash` 会话, +* `r` - 重启选定的容器, +* `s` - 停止选定的容器, +* `h` - 显示帮助窗口, +* `q` - 退出 Dockly。 + +#### 查看容器的信息 + +使用向上/向下箭头选择一个容器,然后按 `i` 以显示所选容器的信息。 + +![][7] + +*查看容器的信息* + +#### 重启容器 + +如果你想随时重启容器,只需选择它并按 `r` 即可重新启动。 + +![][8] + +*重启 Docker 容器* + +#### 停止/删除容器和镜像 + +如果不再需要容器,我们可以立即停止和/或删除一个或所有容器。为此,请按 `m` 打开菜单。 + +![][9] + +*停止,删除 Docker 容器和镜像* + +在这里,你可以执行以下操作。 + +* 停止所有 Docker 容器, +* 删除选定的容器, +* 删除所有容器, +* 删除所有 Docker 镜像等。 + +#### 显示 Dockly 帮助部分 + +如果你有任何疑问,只需按 `h` 即可打开帮助部分。 + +![][10] + +*Dockly 帮助* + +有关更多详细信息,请参考最后给出的官方 GitHub 页面。 + +就是这些了。希望这篇文章有用。如果你一直在使用 Docker 容器,请试试 Dockly,看它是否有帮助。 + +建议阅读: + + * [如何自动更新正在运行的 Docker 容器][11] + * [ctop:一个 Linux 容器的命令行监控工具][12] + +资源: + + * [Dockly 的 GitHub 仓库][13] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/dockly-manage-docker-containers-from-terminal/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/05/Dockly-720x340.png +[2]: https://www.ostechnix.com/getting-started-with-docker/ +[3]: https://www.ostechnix.com/portainer-an-easiest-way-to-manage-docker/ +[4]: https://www.ostechnix.com/picluster-simple-web-based-docker-management-application/ +[5]: https://www.ostechnix.com/install-node-js-linux/ +[6]: http://www.ostechnix.com/wp-content/uploads/2019/05/Manage-Docker-Containers-Using-Dockly.png +[7]: http://www.ostechnix.com/wp-content/uploads/2019/05/View-containers-information.png +[8]: http://www.ostechnix.com/wp-content/uploads/2019/05/Restart-containers.png +[9]: http://www.ostechnix.com/wp-content/uploads/2019/05/stop-remove-containers-and-images.png +[10]: http://www.ostechnix.com/wp-content/uploads/2019/05/Dockly-Help.png +[11]: https://www.ostechnix.com/automatically-update-running-docker-containers/ +[12]: https://www.ostechnix.com/ctop-commandline-monitoring-tool-linux-containers/ +[13]: https://github.com/lirantal/dockly diff --git a/published/201906/20190527 How To Check Available Security Updates On Red Hat (RHEL) And CentOS System.md b/published/201906/20190527 How To Check Available Security Updates On Red Hat (RHEL) And CentOS System.md new file mode 100644 index 0000000000..e853c92615 --- /dev/null +++ b/published/201906/20190527 How To Check Available Security Updates On Red Hat (RHEL) And CentOS System.md @@ -0,0 +1,312 @@ +[#]: collector: (lujun9972) +[#]: translator: (jdh8383) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10938-1.html) +[#]: subject: (How To Check Available Security Updates On Red Hat (RHEL) And CentOS System?) +[#]: via: (https://www.2daygeek.com/check-list-view-find-available-security-updates-on-redhat-rhel-centos-system/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +如何在 CentOS 或 RHEL 系统上检查可用的安全更新? +====== + +![](https://img.linux.net.cn/data/attachment/album/201906/05/003907tljfmy4bnn4qj1tp.jpg) + +当你更新系统时,根据你所在公司的安全策略,有时候可能只需要打上与安全相关的补丁。大多数情况下,这应该是出于程序兼容性方面的考量。那该怎样实践呢?有没有办法让 `yum` 只安装安全补丁呢? + +答案是肯定的,可以用 `yum` 包管理器轻松实现。 + +在这篇文章中,我们不但会提供所需的信息。而且,我们会介绍一些额外的命令,可以帮你获取指定安全更新的详实信息。 + +希望这样可以启发你去了解并修复你列表上的那些漏洞。一旦有安全漏洞被公布,就必须更新受影响的软件,这样可以降低系统中的安全风险。 + +对于 RHEL 或 CentOS 6 系统,运行下面的 [Yum 命令][1] 来安装 yum 安全插件。 + +``` +# yum -y install yum-plugin-security +``` + +在 RHEL 7&8 或是 CentOS 7&8 上面,这个插件已经是 `yum` 的一部分了,不用单独安装。 + +要列出全部可用的补丁(包括安全、Bug 修复以及产品改进),但不安装它们: + +``` +# yum updateinfo list available +Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, + : subscription-manager, verify, versionlock +RHSA-2014:1031 Important/Sec. 389-ds-base-1.3.1.6-26.el7_0.x86_64 +RHSA-2015:0416 Important/Sec. 389-ds-base-1.3.3.1-13.el7.x86_64 +RHBA-2015:0626 bugfix 389-ds-base-1.3.3.1-15.el7_1.x86_64 +RHSA-2015:0895 Important/Sec. 389-ds-base-1.3.3.1-16.el7_1.x86_64 +RHBA-2015:1554 bugfix 389-ds-base-1.3.3.1-20.el7_1.x86_64 +RHBA-2015:1960 bugfix 389-ds-base-1.3.3.1-23.el7_1.x86_64 +RHBA-2015:2351 bugfix 389-ds-base-1.3.4.0-19.el7.x86_64 +RHBA-2015:2572 bugfix 389-ds-base-1.3.4.0-21.el7_2.x86_64 +RHSA-2016:0204 Important/Sec. 389-ds-base-1.3.4.0-26.el7_2.x86_64 +RHBA-2016:0550 bugfix 389-ds-base-1.3.4.0-29.el7_2.x86_64 +RHBA-2016:1048 bugfix 389-ds-base-1.3.4.0-30.el7_2.x86_64 +RHBA-2016:1298 bugfix 389-ds-base-1.3.4.0-32.el7_2.x86_64 +``` + +要统计补丁的大约数量,运行下面的命令: + +``` +# yum updateinfo list available | wc -l +11269 +``` + +想列出全部可用的安全补丁但不安装,以下命令用来展示你系统里已安装和待安装的推荐补丁: + +``` +# yum updateinfo list security all +Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, + : subscription-manager, verify, versionlock + RHSA-2014:1031 Important/Sec. 389-ds-base-1.3.1.6-26.el7_0.x86_64 + RHSA-2015:0416 Important/Sec. 389-ds-base-1.3.3.1-13.el7.x86_64 + RHSA-2015:0895 Important/Sec. 389-ds-base-1.3.3.1-16.el7_1.x86_64 + RHSA-2016:0204 Important/Sec. 389-ds-base-1.3.4.0-26.el7_2.x86_64 + RHSA-2016:2594 Moderate/Sec. 389-ds-base-1.3.5.10-11.el7.x86_64 + RHSA-2017:0920 Important/Sec. 389-ds-base-1.3.5.10-20.el7_3.x86_64 + RHSA-2017:2569 Moderate/Sec. 389-ds-base-1.3.6.1-19.el7_4.x86_64 + RHSA-2018:0163 Important/Sec. 389-ds-base-1.3.6.1-26.el7_4.x86_64 + RHSA-2018:0414 Important/Sec. 389-ds-base-1.3.6.1-28.el7_4.x86_64 + RHSA-2018:1380 Important/Sec. 389-ds-base-1.3.7.5-21.el7_5.x86_64 + RHSA-2018:2757 Moderate/Sec. 389-ds-base-1.3.7.5-28.el7_5.x86_64 + RHSA-2018:3127 Moderate/Sec. 389-ds-base-1.3.8.4-15.el7.x86_64 + RHSA-2014:1031 Important/Sec. 389-ds-base-libs-1.3.1.6-26.el7_0.x86_64 +``` + +要显示所有待安装的安全补丁: + +``` +# yum updateinfo list security all | grep -v "i" + + RHSA-2014:1031 Important/Sec. 389-ds-base-1.3.1.6-26.el7_0.x86_64 + RHSA-2015:0416 Important/Sec. 389-ds-base-1.3.3.1-13.el7.x86_64 + RHSA-2015:0895 Important/Sec. 389-ds-base-1.3.3.1-16.el7_1.x86_64 + RHSA-2016:0204 Important/Sec. 389-ds-base-1.3.4.0-26.el7_2.x86_64 + RHSA-2016:2594 Moderate/Sec. 389-ds-base-1.3.5.10-11.el7.x86_64 + RHSA-2017:0920 Important/Sec. 389-ds-base-1.3.5.10-20.el7_3.x86_64 + RHSA-2017:2569 Moderate/Sec. 389-ds-base-1.3.6.1-19.el7_4.x86_64 + RHSA-2018:0163 Important/Sec. 389-ds-base-1.3.6.1-26.el7_4.x86_64 + RHSA-2018:0414 Important/Sec. 389-ds-base-1.3.6.1-28.el7_4.x86_64 + RHSA-2018:1380 Important/Sec. 389-ds-base-1.3.7.5-21.el7_5.x86_64 + RHSA-2018:2757 Moderate/Sec. 389-ds-base-1.3.7.5-28.el7_5.x86_64 +``` + +要统计全部安全补丁的大致数量,运行下面的命令: + +``` +# yum updateinfo list security all | wc -l +3522 +``` + +下面根据已装软件列出可更新的安全补丁。这包括 bugzilla(bug 修复)、CVE(知名漏洞数据库)、安全更新等: + +``` +# yum updateinfo list security + +或者 + +# yum updateinfo list sec + +Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, + : subscription-manager, verify, versionlock + +RHSA-2018:3665 Important/Sec. NetworkManager-1:1.12.0-8.el7_6.x86_64 +RHSA-2018:3665 Important/Sec. NetworkManager-adsl-1:1.12.0-8.el7_6.x86_64 +RHSA-2018:3665 Important/Sec. NetworkManager-bluetooth-1:1.12.0-8.el7_6.x86_64 +RHSA-2018:3665 Important/Sec. NetworkManager-config-server-1:1.12.0-8.el7_6.noarch +RHSA-2018:3665 Important/Sec. NetworkManager-glib-1:1.12.0-8.el7_6.x86_64 +RHSA-2018:3665 Important/Sec. NetworkManager-libnm-1:1.12.0-8.el7_6.x86_64 +RHSA-2018:3665 Important/Sec. NetworkManager-ppp-1:1.12.0-8.el7_6.x86_64 +RHSA-2018:3665 Important/Sec. NetworkManager-team-1:1.12.0-8.el7_6.x86_64 +RHSA-2018:3665 Important/Sec. NetworkManager-tui-1:1.12.0-8.el7_6.x86_64 +RHSA-2018:3665 Important/Sec. NetworkManager-wifi-1:1.12.0-8.el7_6.x86_64 +RHSA-2018:3665 Important/Sec. NetworkManager-wwan-1:1.12.0-8.el7_6.x86_64 +``` + +显示所有与安全相关的更新,并且返回一个结果来告诉你是否有可用的补丁: + +``` +# yum --security check-update +Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock +rhel-7-server-rpms | 2.0 kB 00:00:00 +--> policycoreutils-devel-2.2.5-20.el7.x86_64 from rhel-7-server-rpms excluded (updateinfo) +--> smc-raghumalayalam-fonts-6.0-7.el7.noarch from rhel-7-server-rpms excluded (updateinfo) +--> amanda-server-3.3.3-17.el7.x86_64 from rhel-7-server-rpms excluded (updateinfo) +--> 389-ds-base-libs-1.3.4.0-26.el7_2.x86_64 from rhel-7-server-rpms excluded (updateinfo) +--> 1:cups-devel-1.6.3-26.el7.i686 from rhel-7-server-rpms excluded (updateinfo) +--> openwsman-client-2.6.3-3.git4391e5c.el7.i686 from rhel-7-server-rpms excluded (updateinfo) +--> 1:emacs-24.3-18.el7.x86_64 from rhel-7-server-rpms excluded (updateinfo) +--> augeas-libs-1.4.0-2.el7_4.2.i686 from rhel-7-server-rpms excluded (updateinfo) +--> samba-winbind-modules-4.2.3-10.el7.i686 from rhel-7-server-rpms excluded (updateinfo) +--> tftp-5.2-11.el7.x86_64 from rhel-7-server-rpms excluded (updateinfo) +. +. +35 package(s) needed for security, out of 115 available +NetworkManager.x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms +NetworkManager-adsl.x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms +NetworkManager-bluetooth.x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms +NetworkManager-config-server.noarch 1:1.12.0-10.el7_6 rhel-7-server-rpms +NetworkManager-glib.x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms +NetworkManager-libnm.x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms +NetworkManager-ppp.x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms +``` + +列出所有可用的安全补丁,并且显示其详细信息: + +``` +# yum info-sec +. +. +=============================================================================== + tzdata bug fix and enhancement update +=============================================================================== + Update ID : RHBA-2019:0689 + Release : 0 + Type : bugfix + Status : final + Issued : 2019-03-28 19:27:44 UTC +Description : The tzdata packages contain data files with rules for various + : time zones. + : + : The tzdata packages have been updated to version + : 2019a, which addresses recent time zone changes. + : Notably: + : + : * The Asia/Hebron and Asia/Gaza zones will start + : DST on 2019-03-30, rather than 2019-03-23 as + : previously predicted. + : * Metlakatla rejoined Alaska time on 2019-01-20, + : ending its observances of Pacific standard time. + : + : (BZ#1692616, BZ#1692615, BZ#1692816) + : + : Users of tzdata are advised to upgrade to these + : updated packages. + Severity : None +``` + +如果你想要知道某个更新的具体内容,可以运行下面这个命令: + +``` +# yum updateinfo RHSA-2019:0163 + +Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock +rhel-7-server-rpms | 2.0 kB 00:00:00 +=============================================================================== + Important: kernel security, bug fix, and enhancement update +=============================================================================== + Update ID : RHSA-2019:0163 + Release : 0 + Type : security + Status : final + Issued : 2019-01-29 15:21:23 UTC + Updated : 2019-01-29 15:23:47 UTC Bugs : 1641548 - CVE-2018-18397 kernel: userfaultfd bypasses tmpfs file permissions + : 1641878 - CVE-2018-18559 kernel: Use-after-free due to race condition in AF_PACKET implementation + CVEs : CVE-2018-18397 + : CVE-2018-18559 +Description : The kernel packages contain the Linux kernel, the core of any + : Linux operating system. + : + : Security Fix(es): + : + : * kernel: Use-after-free due to race condition in + : AF_PACKET implementation (CVE-2018-18559) + : + : * kernel: userfaultfd bypasses tmpfs file + : permissions (CVE-2018-18397) + : + : For more details about the security issue(s), + : including the impact, a CVSS score, and other + : related information, refer to the CVE page(s) + : listed in the References section. + : + : Bug Fix(es): + : + : These updated kernel packages include also + : numerous bug fixes and enhancements. Space + : precludes documenting all of the bug fixes in this + : advisory. See the descriptions in the related + : Knowledge Article: + : https://access.redhat.com/articles/3827321 + Severity : Important +updateinfo info done +``` + +跟之前类似,你可以只查询那些通过 CVE 释出的系统漏洞: + +``` +# yum updateinfo list cves + +Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, + : subscription-manager, verify, versionlock +CVE-2018-15688 Important/Sec. NetworkManager-1:1.12.0-8.el7_6.x86_64 +CVE-2018-15688 Important/Sec. NetworkManager-adsl-1:1.12.0-8.el7_6.x86_64 +CVE-2018-15688 Important/Sec. NetworkManager-bluetooth-1:1.12.0-8.el7_6.x86_64 +CVE-2018-15688 Important/Sec. NetworkManager-config-server-1:1.12.0-8.el7_6.noarch +CVE-2018-15688 Important/Sec. NetworkManager-glib-1:1.12.0-8.el7_6.x86_64 +CVE-2018-15688 Important/Sec. NetworkManager-libnm-1:1.12.0-8.el7_6.x86_64 +CVE-2018-15688 Important/Sec. NetworkManager-ppp-1:1.12.0-8.el7_6.x86_64 +CVE-2018-15688 Important/Sec. NetworkManager-team-1:1.12.0-8.el7_6.x86_64 +``` + +你也可以查看那些跟 bug 修复相关的更新,运行下面的命令: + +``` +# yum updateinfo list bugfix | less + +Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, + : subscription-manager, verify, versionlock +RHBA-2018:3349 bugfix NetworkManager-1:1.12.0-7.el7_6.x86_64 +RHBA-2019:0519 bugfix NetworkManager-1:1.12.0-10.el7_6.x86_64 +RHBA-2018:3349 bugfix NetworkManager-adsl-1:1.12.0-7.el7_6.x86_64 +RHBA-2019:0519 bugfix NetworkManager-adsl-1:1.12.0-10.el7_6.x86_64 +RHBA-2018:3349 bugfix NetworkManager-bluetooth-1:1.12.0-7.el7_6.x86_64 +RHBA-2019:0519 bugfix NetworkManager-bluetooth-1:1.12.0-10.el7_6.x86_64 +RHBA-2018:3349 bugfix NetworkManager-config-server-1:1.12.0-7.el7_6.noarch +RHBA-2019:0519 bugfix NetworkManager-config-server-1:1.12.0-10.el7_6.noarch +``` + +要想得到待安装更新的摘要信息,运行这个: + +``` +# yum updateinfo summary +Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock +rhel-7-server-rpms | 2.0 kB 00:00:00 +Updates Information Summary: updates + 13 Security notice(s) + 9 Important Security notice(s) + 3 Moderate Security notice(s) + 1 Low Security notice(s) + 35 Bugfix notice(s) + 1 Enhancement notice(s) +updateinfo summary done +``` + +如果只想打印出低级别的安全更新,运行下面这个命令。类似的,你也可以只查询重要级别和中等级别的安全更新。 + +``` +# yum updateinfo list sec | grep -i "Low" + +RHSA-2019:0201 Low/Sec. libgudev1-219-62.el7_6.3.x86_64 +RHSA-2019:0201 Low/Sec. systemd-219-62.el7_6.3.x86_64 +RHSA-2019:0201 Low/Sec. systemd-libs-219-62.el7_6.3.x86_64 +RHSA-2019:0201 Low/Sec. systemd-sysv-219-62.el7_6.3.x86_64 +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/check-list-view-find-available-security-updates-on-redhat-rhel-centos-system/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[jdh8383](https://github.com/jdh8383) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ diff --git a/published/201906/20190527 How to write a good C main function.md b/published/201906/20190527 How to write a good C main function.md new file mode 100644 index 0000000000..4f993ee777 --- /dev/null +++ b/published/201906/20190527 How to write a good C main function.md @@ -0,0 +1,474 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10949-1.html) +[#]: subject: (How to write a good C main function) +[#]: via: (https://opensource.com/article/19/5/how-write-good-c-main-function) +[#]: author: (Erik O'Shaughnessy https://opensource.com/users/jnyjny) + +如何写好 C main 函数 +====== + +> 学习如何构造一个 C 文件并编写一个 C main 函数来成功地处理命令行参数。 + +![Hand drawing out the word "code"](https://img.linux.net.cn/data/attachment/album/201906/08/211422umrzznnvmapcwuc3.jpg) + +我知道,现在孩子们用 Python 和 JavaScript 编写他们的疯狂“应用程序”。但是不要这么快就否定 C 语言 —— 它能够提供很多东西,并且简洁。如果你需要速度,用 C 语言编写可能就是你的答案。如果你正在寻找稳定的职业或者想学习如何捕获[空指针解引用][2],C 语言也可能是你的答案!在本文中,我将解释如何构造一个 C 文件并编写一个 C main 函数来成功地处理命令行参数。 + +我:一个顽固的 Unix 系统程序员。 + +你:一个有编辑器、C 编译器,并有时间打发的人。 + +让我们开工吧。 + +### 一个无聊但正确的 C 程序 + +![Parody O'Reilly book cover, "Hating Other People's Code"][3] + +C 程序以 `main()` 函数开头,通常保存在名为 `main.c` 的文件中。 + +``` +/* main.c */ +int main(int argc, char *argv[]) { + +} +``` + +这个程序可以*编译*但不*干*任何事。 + +``` +$ gcc main.c +$ ./a.out -o foo -vv +$ +``` + +正确但无聊。 + +### main 函数是唯一的。 + +`main()` 函数是开始执行时所执行的程序的第一个函数,但不是第一个执行的函数。*第一个*函数是 `_start()`,它通常由 C 运行库提供,在编译程序时自动链入。此细节高度依赖于操作系统和编译器工具链,所以我假装没有提到它。 + +`main()` 函数有两个参数,通常称为 `argc` 和 `argv`,并返回一个有符号整数。大多数 Unix 环境都希望程序在成功时返回 `0`(零),失败时返回 `-1`(负一)。 + +参数 | 名称 | 描述 +---|---|--- +`argc` | 参数个数 | 参数向量的个数 +`argv` | 参数向量 | 字符指针数组 + +参数向量 `argv` 是调用你的程序的命令行的标记化表示形式。在上面的例子中,`argv` 将是以下字符串的列表: + +``` +argv = [ "/path/to/a.out", "-o", "foo", "-vv" ]; +``` + +参数向量在其第一个索引 `argv[0]` 中确保至少会有一个字符串,这是执行程序的完整路径。 + +### main.c 文件的剖析 + +当我从头开始编写 `main.c` 时,它的结构通常如下: + +``` +/* main.c */ +/* 0 版权/许可证 */ +/* 1 包含 */ +/* 2 定义 */ +/* 3 外部声明 */ +/* 4 类型定义 */ +/* 5 全局变量声明 */ +/* 6 函数原型 */ + +int main(int argc, char *argv[]) { +/* 7 命令行解析 */ +} + +/* 8 函数声明 */ +``` + +下面我将讨论这些编号的各个部分,除了编号为 0 的那部分。如果你必须把版权或许可文本放在源代码中,那就放在那里。 + +另一件我不想讨论的事情是注释。 + +``` +“评论谎言。” +- 一个愤世嫉俗但聪明又好看的程序员。 +``` + +与其使用注释,不如使用有意义的函数名和变量名。 + +鉴于程序员固有的惰性,一旦添加了注释,维护负担就会增加一倍。如果更改或重构代码,则需要更新或扩充注释。随着时间的推移,代码会变得面目全非,与注释所描述的内容完全不同。 + +如果你必须写注释,不要写关于代码正在做*什么*,相反,写下代码*为什么*要这样写。写一些你将要在五年后读到的注释,那时你已经将这段代码忘得一干二净。世界的命运取决于你。*不要有压力。* + +#### 1、包含 + +我添加到 `main.c` 文件的第一个东西是包含文件,它们为程序提供大量标准 C 标准库函数和变量。C 标准库做了很多事情。浏览 `/usr/include` 中的头文件,你可以了解到它们可以做些什么。 + +`#include` 字符串是 [C 预处理程序][4](cpp)指令,它会将引用的文件完整地包含在当前文件中。C 中的头文件通常以 `.h` 扩展名命名,且不应包含任何可执行代码。它只有宏、定义、类型定义、外部变量和函数原型。字符串 `` 告诉 cpp 在系统定义的头文件路径中查找名为 `header.h` 的文件,它通常在 `/usr/include` 目录中。 + +``` +/* main.c */ +#include +#include +#include +#include +#include +#include +#include +#include +``` + +这是我默认会全局包含的最小包含集合,它将引入: + +\#include 文件 | 提供的东西 +---|--- +stdio | 提供 `FILE`、`stdin`、`stdout`、`stderr` 和 `fprint()` 函数系列 +stdlib | 提供 `malloc()`、`calloc()` 和 `realloc()` +unistd | 提供 `EXIT_FAILURE`、`EXIT_SUCCESS` +libgen | 提供 `basename()` 函数 +errno | 定义外部 `errno` 变量及其可以接受的所有值 +string | 提供 `memcpy()`、`memset()` 和 `strlen()` 函数系列 +getopt | 提供外部 `optarg`、`opterr`、`optind` 和 `getopt()` 函数 +sys/types | 类型定义快捷方式,如 `uint32_t` 和 `uint64_t` + +#### 2、定义 + +``` +/* main.c */ +<...> + +#define OPTSTR "vi:o:f:h" +#define USAGE_FMT "%s [-v] [-f hexflag] [-i inputfile] [-o outputfile] [-h]" +#define ERR_FOPEN_INPUT "fopen(input, r)" +#define ERR_FOPEN_OUTPUT "fopen(output, w)" +#define ERR_DO_THE_NEEDFUL "do_the_needful blew up" +#define DEFAULT_PROGNAME "george" +``` + +这在现在没有多大意义,但 `OPTSTR` 定义我这里会说明一下,它是程序推荐的命令行开关。参考 [getopt(3)][5] man 页面,了解 `OPTSTR` 将如何影响 `getopt()` 的行为。 + +`USAGE_FMT` 定义了一个 `printf()` 风格的格式字符串,它用在 `usage()` 函数中。 + +我还喜欢将字符串常量放在文件的 `#define` 这一部分。如果需要,把它们收集在一起可以更容易地修正拼写、重用消息和国际化消息。 + +最后,在命名 `#define` 时全部使用大写字母,以区别变量和函数名。如果需要,可以将单词放连在一起或使用下划线分隔,只要确保它们都是大写的就行。 + +#### 3、外部声明 + +``` +/* main.c */ +<...> + +extern int errno; +extern char *optarg; +extern int opterr, optind; +``` + +`extern` 声明将该名称带入当前编译单元的命名空间(即 “文件”),并允许程序访问该变量。这里我们引入了三个整数变量和一个字符指针的定义。`opt` 前缀的几个变量是由 `getopt()` 函数使用的,C 标准库使用 `errno` 作为带外通信通道来传达函数可能的失败原因。 + +#### 4、类型定义 + +``` +/* main.c */ +<...> + +typedef struct { + int verbose; + uint32_t flags; + FILE *input; + FILE *output; +} options_t; +``` + +在外部声明之后,我喜欢为结构、联合和枚举声明 `typedef`。命名一个 `typedef` 是一种传统习惯。我非常喜欢使用 `_t` 后缀来表示该名称是一种类型。在这个例子中,我将 `options_t` 声明为一个包含 4 个成员的 `struct`。C 是一种空格无关的编程语言,因此我使用空格将字段名排列在同一列中。我只是喜欢它看起来的样子。对于指针声明,我在名称前面加上星号,以明确它是一个指针。 + +#### 5、全局变量声明 + +``` +/* main.c */ +<...> + +int dumb_global_variable = -11; +``` + +全局变量是一个坏主意,你永远不应该使用它们。但如果你必须使用全局变量,请在这里声明,并确保给它们一个默认值。说真的,*不要使用全局变量*。 + +#### 6、函数原型 + +``` +/* main.c */ +<...> + +void usage(char *progname, int opt); +int do_the_needful(options_t *options); +``` + +在编写函数时,将它们添加到 `main()` 函数之后而不是之前,在这里放函数原型。早期的 C 编译器使用单遍策略,这意味着你在程序中使用的每个符号(变量或函数名称)必须在使用之前声明。现代编译器几乎都是多遍编译器,它们在生成代码之前构建一个完整的符号表,因此并不严格要求使用函数原型。但是,有时你无法选择代码要使用的编译器,所以请编写函数原型并继续这样做下去。 + +当然,我总是包含一个 `usage()` 函数,当 `main()` 函数不理解你从命令行传入的内容时,它会调用这个函数。 + +#### 7、命令行解析 + +``` +/* main.c */ +<...> + +int main(int argc, char *argv[]) { + int opt; + options_t options = { 0, 0x0, stdin, stdout }; + + opterr = 0; + + while ((opt = getopt(argc, argv, OPTSTR)) != EOF) + switch(opt) { + case 'i': + if (!(options.input = fopen(optarg, "r")) ){ + perror(ERR_FOPEN_INPUT); + exit(EXIT_FAILURE); + /* NOTREACHED */ + } + break; + + case 'o': + if (!(options.output = fopen(optarg, "w")) ){ + perror(ERR_FOPEN_OUTPUT); + exit(EXIT_FAILURE); + /* NOTREACHED */ + } + break; + + case 'f': + options.flags = (uint32_t )strtoul(optarg, NULL, 16); + break; + + case 'v': + options.verbose += 1; + break; + + case 'h': + default: + usage(basename(argv[0]), opt); + /* NOTREACHED */ + break; + } + + if (do_the_needful(&options) != EXIT_SUCCESS) { + perror(ERR_DO_THE_NEEDFUL); + exit(EXIT_FAILURE); + /* NOTREACHED */ + } + + return EXIT_SUCCESS; +} +``` + +好吧,代码有点多。这个 `main()` 函数的目的是收集用户提供的参数,执行最基本的输入验证,然后将收集到的参数传递给使用它们的函数。这个示例声明一个使用默认值初始化的 `options` 变量,并解析命令行,根据需要更新 `options`。 + +`main()` 函数的核心是一个 `while` 循环,它使用 `getopt()` 来遍历 `argv`,寻找命令行选项及其参数(如果有的话)。文件前面定义的 `OPTSTR` 是驱动 `getopt()` 行为的模板。`opt` 变量接受 `getopt()` 找到的任何命令行选项的字符值,程序对检测命令行选项的响应发生在 `switch` 语句中。 + +如果你注意到了可能会问,为什么 `opt` 被声明为 32 位 `int`,但是预期是 8 位 `char`?事实上 `getopt()` 返回一个 `int`,当它到达 `argv` 末尾时取负值,我会使用 `EOF`(*文件末尾*标记)匹配。`char` 是有符号的,但我喜欢将变量匹配到它们的函数返回值。 + +当检测到一个已知的命令行选项时,会发生特定的行为。在 `OPTSTR` 中指定一个以冒号结尾的参数,这些选项可以有一个参数。当一个选项有一个参数时,`argv` 中的下一个字符串可以通过外部定义的变量 `optarg` 提供给程序。我使用 `optarg` 来打开文件进行读写,或者将命令行参数从字符串转换为整数值。 + +这里有几个关于代码风格的要点: + + * 将 `opterr` 初始化为 `0`,禁止 `getopt` 触发 `?`。 + * 在 `main()` 的中间使用 `exit(EXIT_FAILURE);` 或 `exit(EXIT_SUCCESS);`。 + * `/* NOTREACHED */` 是我喜欢的一个 lint 指令。 + * 在返回 int 类型的函数末尾使用 `return EXIT_SUCCESS;`。 + * 显示强制转换隐式类型。 + +这个程序的命令行格式,经过编译如下所示: + +``` +$ ./a.out -h +a.out [-v] [-f hexflag] [-i inputfile] [-o outputfile] [-h] +``` + +事实上,在编译后 `usage()` 就会向 `stderr` 发出这样的内容。 + +#### 8、函数声明 + +``` +/* main.c */ +<...> + +void usage(char *progname, int opt) { + fprintf(stderr, USAGE_FMT, progname?progname:DEFAULT_PROGNAME); + exit(EXIT_FAILURE); + /* NOTREACHED */ +} + +int do_the_needful(options_t *options) { + + if (!options) { + errno = EINVAL; + return EXIT_FAILURE; + } + + if (!options->input || !options->output) { + errno = ENOENT; + return EXIT_FAILURE; + } + + /* XXX do needful stuff */ + + return EXIT_SUCCESS; +} +``` + +我最后编写的函数不是个样板函数。在本例中,函数 `do_the_needful()` 接受一个指向 `options_t` 结构的指针。我验证 `options` 指针不为 `NULL`,然后继续验证 `input` 和 `output` 结构成员。如果其中一个测试失败,返回 `EXIT_FAILURE`,并且通过将外部全局变量 `errno` 设置为常规错误代码,我可以告知调用者常规的错误原因。调用者可以使用便捷函数 `perror()` 来根据 `errno` 的值发出便于阅读的错误消息。 + +函数几乎总是以某种方式验证它们的输入。如果完全验证代价很大,那么尝试执行一次并将验证后的数据视为不可变。`usage()` 函数使用 `fprintf()` 调用中的条件赋值验证 `progname` 参数。接下来 `usage()` 函数就退出了,所以我不会费心设置 `errno`,也不用操心是否使用正确的程序名。 + +在这里,我要避免的最大错误是解引用 `NULL` 指针。这将导致操作系统向我的进程发送一个名为 `SYSSEGV` 的特殊信号,导致不可避免的死亡。用户最不希望看到的是由 `SYSSEGV` 而导致的崩溃。最好是捕获 `NULL` 指针以发出更合适的错误消息并优雅地关闭程序。 + +有些人抱怨在函数体中有多个 `return` 语句,他们喋喋不休地说些“控制流的连续性”之类的东西。老实说,如果函数中间出现错误,那就应该返回这个错误条件。写一大堆嵌套的 `if` 语句只有一个 `return` 绝不是一个“好主意”™。 + +最后,如果你编写的函数接受四个以上的参数,请考虑将它们绑定到一个结构中,并传递一个指向该结构的指针。这使得函数签名更简单,更容易记住,并且在以后调用时不会出错。它还可以使调用函数速度稍微快一些,因为需要复制到函数堆栈中的东西更少。在实践中,只有在函数被调用数百万或数十亿次时,才会考虑这个问题。如果认为这没有意义,那也无所谓。 + +### 等等,你不是说没有注释吗!?!! + +在 `do_the_needful()` 函数中,我写了一种特殊类型的注释,它被是作为占位符设计的,而不是为了说明代码: + +``` +/* XXX do needful stuff */ +``` + +当你写到这里时,有时你不想停下来编写一些特别复杂的代码,你会之后再写,而不是现在。那就是我留给自己再次回来的地方。我插入一个带有 `XXX` 前缀的注释和一个描述需要做什么的简短注释。之后,当我有更多时间的时候,我会在源代码中寻找 `XXX`。使用什么前缀并不重要,只要确保它不太可能在另一个上下文环境(如函数名或变量)中出现在你代码库里。 + +### 把它们组合在一起 + +好吧,当你编译这个程序后,它*仍然*几乎没有任何作用。但是现在你有了一个坚实的骨架来构建你自己的命令行解析 C 程序。 + +``` +/* main.c - the complete listing */ + +#include +#include +#include +#include +#include +#include +#include + +#define OPTSTR "vi:o:f:h" +#define USAGE_FMT "%s [-v] [-f hexflag] [-i inputfile] [-o outputfile] [-h]" +#define ERR_FOPEN_INPUT "fopen(input, r)" +#define ERR_FOPEN_OUTPUT "fopen(output, w)" +#define ERR_DO_THE_NEEDFUL "do_the_needful blew up" +#define DEFAULT_PROGNAME "george" + +extern int errno; +extern char *optarg; +extern int opterr, optind; + +typedef struct { + int verbose; + uint32_t flags; + FILE *input; + FILE *output; +} options_t; + +int dumb_global_variable = -11; + +void usage(char *progname, int opt); +int do_the_needful(options_t *options); + +int main(int argc, char *argv[]) { + int opt; + options_t options = { 0, 0x0, stdin, stdout }; + + opterr = 0; + + while ((opt = getopt(argc, argv, OPTSTR)) != EOF) + switch(opt) { + case 'i': + if (!(options.input = fopen(optarg, "r")) ){ + perror(ERR_FOPEN_INPUT); + exit(EXIT_FAILURE); + /* NOTREACHED */ + } + break; + + case 'o': + if (!(options.output = fopen(optarg, "w")) ){ + perror(ERR_FOPEN_OUTPUT); + exit(EXIT_FAILURE); + /* NOTREACHED */ + } + break; + + case 'f': + options.flags = (uint32_t )strtoul(optarg, NULL, 16); + break; + + case 'v': + options.verbose += 1; + break; + + case 'h': + default: + usage(basename(argv[0]), opt); + /* NOTREACHED */ + break; + } + + if (do_the_needful(&options) != EXIT_SUCCESS) { + perror(ERR_DO_THE_NEEDFUL); + exit(EXIT_FAILURE); + /* NOTREACHED */ + } + + return EXIT_SUCCESS; +} + +void usage(char *progname, int opt) { + fprintf(stderr, USAGE_FMT, progname?progname:DEFAULT_PROGNAME); + exit(EXIT_FAILURE); + /* NOTREACHED */ +} + +int do_the_needful(options_t *options) { + + if (!options) { + errno = EINVAL; + return EXIT_FAILURE; + } + + if (!options->input || !options->output) { + errno = ENOENT; + return EXIT_FAILURE; + } + + /* XXX do needful stuff */ + + return EXIT_SUCCESS; +} +``` + +现在,你已经准备好编写更易于维护的 C 语言。如果你有任何问题或反馈,请在评论中分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/how-write-good-c-main-function + +作者:[Erik O'Shaughnessy][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jnyjny +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_hand_draw.png?itok=dpAf--Db (Hand drawing out the word "code") +[2]: https://www.owasp.org/index.php/Null_Dereference +[3]: https://opensource.com/sites/default/files/uploads/hatingotherpeoplescode-big.png (Parody O'Reilly book cover, "Hating Other People's Code") +[4]: https://en.wikipedia.org/wiki/C_preprocessor +[5]: https://linux.die.net/man/3/getopt +[6]: http://www.opengroup.org/onlinepubs/009695399/functions/fopen.html +[7]: http://www.opengroup.org/onlinepubs/009695399/functions/perror.html +[8]: http://www.opengroup.org/onlinepubs/009695399/functions/exit.html +[9]: http://www.opengroup.org/onlinepubs/009695399/functions/strtoul.html +[10]: http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html diff --git a/published/201906/20190529 NVMe on Linux.md b/published/201906/20190529 NVMe on Linux.md new file mode 100644 index 0000000000..374d3ef2f2 --- /dev/null +++ b/published/201906/20190529 NVMe on Linux.md @@ -0,0 +1,68 @@ +[#]: collector: (lujun9972) +[#]: translator: (warmfrog) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10946-1.html) +[#]: subject: (NVMe on Linux) +[#]: via: (https://www.networkworld.com/article/3397006/nvme-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +Linux 上的 NVMe +=============== + +> 如果你还没注意到,一些极速的固态磁盘技术已经可以用在 Linux 和其他操作系统上了。 + +![Sandra Henry-Stocker][1] + +NVMe 意即非易失性内存主机控制器接口规范non-volatile memory express,它是一个主机控制器接口和存储协议,用于加速企业和客户端系统以及固态驱动器(SSD)之间的数据传输。它通过电脑的高速 PCIe 总线工作。每当我看到这些名词时,我的感受是“羡慕”。而羡慕的原因很重要。 + +使用 NVMe,数据传输的速度比旋转磁盘快很多。事实上,NVMe 驱动能够比 SATA SSD 快 7 倍。这比我们今天很多人用的固态硬盘快了 7 倍多。这意味着,如果你用一个 NVMe 驱动盘作为启动盘,你的系统能够启动的非常快。事实上,如今任何人买一个新的系统可能都不会考虑那些没有自带 NVMe 的,不管是服务器或者个人电脑。 + +### NVMe 在 Linux 下能工作吗? + +是的!NVMe 自 Linux 内核 3.3 版本就支持了。然而,要升级系统,通常同时需要一个 NVMe 控制器和一个 NVMe 磁盘。一些外置磁盘也行,但是要连接到系统上,需要的可不仅仅是通用的 USB 接口。 + +先使用下列命令检查内核版本: + +``` +$ uname -r +5.0.0-15-generic +``` + +如果你的系统已经用了 NVMe,你将看到一个设备(例如,`/dev/nvme0`),但是只有在你安装了 NVMe 控制器的情况下才显示。如果你没有 NVMe 控制器,你可以用下列命令获取使用 NVMe 的相关信息。 + +``` +$ modinfo nvme | head -6 +filename: /lib/modules/5.0.0-15-generic/kernel/drivers/nvme/host/nvme.ko +version: 1.0 +license: GPL +author: Matthew Wilcox +srcversion: AA383008D5D5895C2E60523 +alias: pci:v0000106Bd00002003sv*sd*bc*sc*i* +``` + +### 了解更多 + +如果你想了解极速的 NVMe 存储的更多细节,可在 [PCWorld][3] 获取。 + +规范、白皮书和其他资源可在 [NVMexpress.org][4] 获取。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3397006/nvme-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[warmfrog](https://github.com/warmfrog) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/05/nvme-100797708-large.jpg +[2]: https://www.networkworld.com/slideshow/153439/linux-best-desktop-distros-for-newbies.html#tk.nww-infsb +[3]: https://www.pcworld.com/article/2899351/everything-you-need-to-know-about-nvme.html +[4]: https://nvmexpress.org/ +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/201906/20190530 A short primer on assemblers, compilers, and interpreters.md b/published/201906/20190530 A short primer on assemblers, compilers, and interpreters.md new file mode 100644 index 0000000000..1c60f1adcc --- /dev/null +++ b/published/201906/20190530 A short primer on assemblers, compilers, and interpreters.md @@ -0,0 +1,138 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11021-1.html) +[#]: subject: (A short primer on assemblers, compilers, and interpreters) +[#]: via: (https://opensource.com/article/19/5/primer-assemblers-compilers-interpreters) +[#]: author: (Erik O'Shaughnessy https://opensource.com/users/jnyjny/users/shawnhcorey/users/jnyjny/users/jnyjny) + +浅谈汇编器、编译器和解释器 +====== + +> 简单介绍一下编程方式的历史演变。 + +![](https://img.linux.net.cn/data/attachment/album/201906/26/181309vdouxdfktr344rm4.jpg) + +在计算机诞生不久的早期年代,硬件非常昂贵,而程序员比较廉价。这些廉价程序员甚至都没有“程序员”这个头衔,并且常常是由数学家或者电气工程师来充当这个角色的。早期的计算机被用来快速解决复杂的数学问题,所以数学家天然就适合“编程”工作。 + +### 什么是程序? + +首先来看一点背景知识。计算机自己是做不了任何事情的,它们的任何行为都需要程序来引导。你可以把程序看成是非常精确的菜谱,这种菜谱读取一个输入,然后生成对应的输出。菜谱里的各个步骤由操作数据的指令构成。听上去有点儿复杂,不过你或许知道下面这个语句是什么意思: + +``` +1 + 2 = 3 +``` + +其中的加号是“指令”,而数字 1 和 2 是数据。数学上的等号意味着等式两边的部分是“等价”的,不过在大部分编程语言中对变量使用等号是“赋值”的意思。如果计算机执行上面这个语句,它会把这个加法的结果(也就是“3”)储存在内存中的某个地方。 + +计算机知道如何使用数字进行数学运算,以及如何在内存结构中移动数据。在这里就不对内存进行展开了,你只需要知道内存一般分为两大类:“速度快/空间小”和“速度慢/空间大”。CPU 寄存器的读写速度非常快,但是空间非常小,相当于一个速记便签。主存储器通常有很大的空间,但是读写速度就比寄存器差远了。在程序运行的时候,CPU 不断将它所需要用到的数据从主存储器挪动到寄存器,然后再把结果放回到主存储器。 + +### 汇编器 + +当时的计算机很贵,而人力比较便宜。程序员需要耗费很多时间把手写的数学表达式翻译成计算机可以执行的指令。最初的计算机只有非常糟糕的用户界面,有些甚至只有前面板上的拨动开关。这些开关就代表一个内存“单元”里的一个个 “0” 和 “1”。程序员需要配置一个内存单元,选择好储存位置,然后把这个单元提交到内存里。这是一个既耗时又容易出错的过程。 + +![Programmers operate the ENIAC computer][2] + +*程序员[Betty Jean Jennings][3] (左) 和 [Fran Bilas][4] (右) 在操作 [ENIAC][5] 的主控制面板* + +后来有一名 [电气工程师][6] 认为自己的时间很宝贵,就写了一个程序,能够把人们可以读懂的“菜谱”一样的输入转换成计算机可以读懂的版本。这就是最初的“汇编器”,在当时引起了不小的争议。这些昂贵机器的主人不希望把计算资源浪费在人们已经能做的任务上(虽然又慢又容易出错)。不过随着时间的推移,人们逐渐发现使用汇编器在速度和准确性上都胜于人工编写机器语言,并且计算机完成的“实际工作量”增加了。 + +尽管汇编器相比在机器面板上切换比特的状态已经是很大的进步了,这种编程方式仍然非常专业。上面加法的例子在汇编语言中看起来差不多是这样的: + +``` +01 MOV R0, 1 +02 MOV R1, 2 +03 ADD R0, R1, R2 +04 MOV 64, R0 +05 STO R2, R0 +``` + +每一行都是一个计算机指令,前面是一个指令的简写,后面是指令所操作的数据。这个小小的程序首先会将数值 1 “移动”到寄存器 R0,然后把 2 移动到寄存器 R1。03 行把 R0 和 R1 两个寄存器里的数值相加,然后将结果储存在 R2 寄存器里。最后,04 行和 05 行决定结果应该被放在主存储器里的什么位置(在这里是地址 64)。管理内存中存储数据的位置是编程过程中最耗时也最容易出错的部分之一。 + +### 编译器 + +汇编器已经比手写计算机指令要好太多了,不过早期的程序员还是渴望能够按照他们所习惯的方式,像书写数学公式一样地去写程序。这种需求推动了高级编译语言的发展,其中有一些已经成为历史,另一些如今还在使用。比如 [ALGO][7] 就已经成为历史了,但是像 [Fortran][8] 和 [C][9] 这样的语言仍然在不断解决实际问题。 + +![Genealogy tree of ALGO and Fortran][10] + +*ALGO 和 Fortran 编程语言的谱系树* + +这些“高级”语言使得程序员可以用更简单的方式编写程序。在 C 语言中,我们的加法程序就变成了这样: + +``` +int x; +x = 1 + 2; +``` + +第一个语句描述了该程序将要使用的一块内存。在这个例子中,这块内存应该占一个整数的大小,名字是 `x`。第二个语句是加法,虽然是倒着写的。一个 C 语言的程序员会说这是 “X 被赋值为 1 加 2 的结果”。需要注意的是,程序员并不需要决定在内存的什么位置储存 `x`,这个任务交给编译器了。 + +这种被称为“编译器”的新程序可以把用高级语言写的程序转换成汇编语言,再使用汇编器把汇编语言转换成机器可读的程序。这种程序组合常常被称为“工具链”,因为一个程序的输出就直接成为另一个程序的输入。 + +编译语言相比汇编语言的优势体现在从一台计算机迁移到不同型号或者品牌的另一台计算机上的时候。在计算机的早期岁月里,包括 IBM、DEC、德州仪器、UNIVAC 以及惠普在内的很多公司都在制造除了大量不同类型的计算机硬件。这些计算机除了都需要连接电源之外就没有太多共同点了。它们在内存和 CPU 架构上的差异相当大,当时经常需要人们花费数年来将一台计算机的程序翻译成另一台计算机的程序。 + +有了高级语言,我们只需要把编译器工具链迁移到新的平台就行了。只要有可用的编译器,高级语言写的程序最多只需要经过小幅修改就可以在新的计算机上被重新编译。高级语言的编译是一个真正的革命性成果。 + +![IBM PC XT][11] + +*1983 发布的 IBM PC XT 是硬件价格下降的早期例子。* + +程序员们的生活得到了很好的改善。相比之下,通过高级语言表达他们想要解决的问题让事情变得轻松很多。由于半导体技术的进步以及集成芯片的发明,计算机硬件的价格急剧下降。计算机的速度越来越快,能力也越来越强,并且还便宜了很多。从某个时间点往后(也许是 80 年代末期吧),事情发生了反转,程序员变得比他们所使用的硬件更值钱了。 + +### 解释器 + +随着时间的推移,一种新的编程方式兴起了。一种被称为“解释器”的特殊程序可以直接读取一个程序将其转换成计算机指令以立即执行。和编译器差不多,解释器读取程序并将它转换成一个中间形态。但和编译器不同的是,解释器直接执行程序的这个中间形态。解释型语言在每一次执行的时候都要经历这个过程;而编译程序只需要编译一次,之后计算机每次只需要执行编译好的机器指令就可以了。 + +顺便说一句,这个特性就是导致人们感觉解释型程序运行得比较慢的原因。不过现代计算机的性能出奇地强大,以至于大多数人无法区分编译型程序和解释型程序。 + +解释型程序(有时也被成为“脚本”)甚至更容易被移植到不同的硬件平台上。因为脚本并不包含任何机器特有的指令,同一个版本的程序可以不经过任何修改就直接在很多不同的计算机上运行。不过当然了,解释器必须得先移植到新的机器上才行。 + +一个很流行的解释型语言是 [perl][12]。用 perl 完整地表达我们的加法问题会是这样的: + +``` +$x = 1 + 2 +``` + +虽然这个程序看起来和 C 语言的版本差不多,运行上也没有太大区别,但却缺少了初始化变量的语句。其实还有一些其它的区别(超出这篇文章的范围了),但你应该已经注意到,我们写计算机程序的方式已经和数学家用纸笔手写数学表达式非常接近了。 + +### 虚拟机 + +最新潮的编程方式要数虚拟机(经常简称 VM)了。虚拟机分为两大类:系统虚拟机和进程虚拟机。这两种虚拟机都提供一种对“真实的”计算硬件的不同级别的抽象,不过它们的作用域不同。系统虚拟机是一个提供物理硬件的替代品的软件,而进程虚拟机则被设计用来以一种“系统独立”的方式执行程序。所以在这个例子里,进程虚拟机(往后我所说的虚拟机都是指这个类型)的作用域和解释器的比较类似,因为也是先将程序编译成一个中间形态,然后虚拟机再执行这个中间形态。 + +虚拟机和解释器的主要区别在于,虚拟机创造了一个虚拟的 CPU,以及一套虚拟的指令集。有了这层抽象,我们就可以编写前端工具来把不同语言的程序编译成虚拟机可以接受的程序了。也许最流行也最知名的虚拟机就是 Java 虚拟机(JVM)了。JVM 最初在 1990 年代只支持 Java 语言,但是如今却可以运行 [许多][13] 流行的编程语言,包括 Scala、Jython、JRuby、Clojure,以及 Kotlin 等等。还有其它一些不太常见的例子,在这里就不说了。我也是最近才知道,我最喜欢的语言 Python 并不是一个解释型语言,而是一个 [运行在虚拟机上的语言][15]! + +虚拟机仍然在延续这样一个历史趋势:让程序员在使用特定领域的编程语言解决问题的时候,所需要的对特定计算平台的了解变得越来越少了。 + +### 就是这样了 + +希望你喜欢这篇简单介绍软件背后运行原理的短文。有什么其它话题是你想让我接下来讨论的吗?在评论里告诉我吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/primer-assemblers-compilers-interpreters + +作者:[Erik O'Shaughnessy][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jnyjny/users/shawnhcorey/users/jnyjny/users/jnyjny +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_keyboard_coding.png?itok=E0Vvam7A (keyboard with connected dots) +[2]: https://opensource.com/sites/default/files/uploads/two_women_operating_eniac.gif (Programmers operate the ENIAC computer) +[3]: https://en.wikipedia.org/wiki/Jean_Bartik (Jean Bartik) +[4]: https://en.wikipedia.org/wiki/Frances_Spence (Frances Spence) +[5]: https://en.wikipedia.org/wiki/ENIAC +[6]: https://en.wikipedia.org/wiki/Nathaniel_Rochester_%28computer_scientist%29 +[7]: https://en.wikipedia.org/wiki/ALGO +[8]: https://en.wikipedia.org/wiki/Fortran +[9]: https://en.wikipedia.org/wiki/C_(programming_language) +[10]: https://opensource.com/sites/default/files/uploads/algolfortran_family-by-borkowski.png (Genealogy tree of ALGO and Fortran) +[11]: https://opensource.com/sites/default/files/uploads/639px-ibm_px_xt_color.jpg (IBM PC XT) +[12]: www.perl.org +[13]: https://en.wikipedia.org/wiki/List_of_JVM_languages +[14]: /resources/python +[15]: https://opensource.com/article/18/4/introduction-python-bytecode +[16]: https://pybit.es/python-interpreters.html diff --git a/published/201906/20190531 Learn Python with these awesome resources.md b/published/201906/20190531 Learn Python with these awesome resources.md new file mode 100644 index 0000000000..80aaa801f4 --- /dev/null +++ b/published/201906/20190531 Learn Python with these awesome resources.md @@ -0,0 +1,91 @@ +[#]: collector: (lujun9972) +[#]: translator: (tomjlw) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11015-1.html) +[#]: subject: (Learn Python with these awesome resources) +[#]: via: (https://opensource.com/article/19/5/resources-learning-python) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +学习 Python 的精品 PLN 资源 +====== + +> 通过将这些资源加入你自己的私人学习网络以拓展 Python 知识。 + +![](https://img.linux.net.cn/data/attachment/album/201906/25/002706hrx0d3dfrxeid3nj.jpg) + +我使用和教授 Python 已有很长时间了,但我总是乐于增加我对这门实用语言的知识。这就是为什么我一直试着拓展我的 Python [个人学习网络][2]personal learning network(PLN),这是一个描述用于分享信息的非正式的互惠型网络的概念。 + +教育学家 [Kelly Paredes][3] 和 [Sean Tibor][4] 最近在他们的播客 [Teaching Python][5] 上谈到了如何搭建 Python PLN。我在克里夫兰的 [PyCon 2019][6] 遇到他们之后就订阅了这个频道(并把它们加入到我的 Python PLN 当中)。这个播客激发了我对 Python PLN 中的人的思考,包括那些我最近在 PyCon 遇到的人们。 + +我会分享一些我找到 PLN 成员的地方;可能它们也可以变成你的 Python PLN 的一部分。 + +### Young Coders 导师 + +Python 基金会的活动协调者 [Betsy Waliszewski][7] 是我的 Python PLN 中的一员。当我们在 PyCon2019 见到时,因为我是个老师,她推荐我看看为十二岁及以上的孩子打造的 [Young Coders][8] 工作室。在那我遇到了正在负责这个计划的 [Katie Cunningham][9],它会教参与者如何搭建和配置树莓派并使用 Python 项目。年轻学生也会收到两本书 Jason Briggs 的 《[Python for Kids][10]》 和 Craig Richardson 的 《[Learn to Program with Minecraft][11]》。我一直寻找提升我教学水平的新方式,因此我在该会议上的 [NoStarch Press][12] 展台迅速拿到了两本 Minecraft 书。Katie 是一名优秀的教师,也是一名多产作家,拥有一个充满 Python 培训视频的 [YouTube][13] 精彩频道。 + +我把 Kattie 与我在 Young Coders 工作室碰到的另外两个人加入我的 PLN:[Nat Dunn][14] 和 [Sean Valentine][15]。像 Katie 一样,他们自愿花时间把 Python 介绍给青年程序员们。Nat 是 [Webucator][16] 的总裁,这是一家 IT 培训公司,多年来一直是 Python 软件基金会赞助商,并赞助了 PyCon 2018 教育峰会。在将 Python 教他 13 岁的儿子和 14 岁的侄子之后,他决定在 Young Coders 任教。Sean 是 [Hidden Genius 项目][17] 的战略计划总监,这是一个针对黑人男性青年的技术及领导力打造的教导项目。Sean 说许多 Hidden Genius 参与者“用 Python 打造项目因此我们认为 [Young Coders] 是一个很好的合作机会”。了解 Hidden Genius 项目激发了我更深层次地思考编程的未来以及其改变生活的威力。 + +### Open Spaces 聚会 + +我发现 PyCon 的 [Open Spaces][18] —— 这是一个一小时左右的自组织的即兴聚会 —— 跟正式的项目活动一样有用。我的最爱之一是 [Circuit Playground Express][19] 设备,它是我们会议主题包的一部分。我很喜欢这个设备,并且 Open Space 提供了学习它的一条大道。组织者提供了工作表和一个 [Github][20] 仓库,其中包含有我们成功所需要的所有工具,也提供了一个上手实践的机会以及探索这个独特硬件的方向。 + +这次会面激起了了我对学习 Circuit Playground Express 更新信息的兴趣,因此在 PyCon 之后, 我在 Twitter 上接触到了在会议上就该设备编程发表主旨演讲的 [Nina Zakharenko][21]。Nina 自从去年秋天我在 [All Things Open][23] 上听过她的演讲后就在我的 Python PLN 里了。我最近报名参加了她的 [Python 基础][24]课程以加深我的学习。Nina 推荐我将 [Kattni Rembor][25] 加入我的 Python PLN。他的[示例代码][26]正帮助我学习用 CircuitPython 编程。 + +### 我的 PLN 中的其他资源 + +我在 PyCon 2019 也遇见了 [Opensource.com][27] 社区版主 [Moshe Zadka][28],并和他来了场长谈。他分享了几个新的 Python 资源,包括 [如何像电脑科学家一样思考][29]。社区版主 [Seth Kenlon][30] 是我的 PLN 中的另一名成员;他发表了许多优秀的 [Python 文章][31],我也推荐你关注他。 + +我的 Python PLN 每天都在持续扩大。除了我已经提到的,我同样推荐你关注 [Al Sweigart][32]、[Eric Matthes][33] 以及 [Adafruit][34]他们分享的优质内容。我也推荐这本书《[制作:由 Adafruit Circuit Playground Express 开始][35]》和《[Podcast.\_\_init\_\_][36]》,这是一个关于 Python 社区的播客。这两个都是我从我的 PLN 中了解到的。 + +谁在你的 Python PLN 中?请在留言区分享你的最爱。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/resources-learning-python + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[tomjlw](https://github.com/tomjlw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/reading_book_stars_list.png?itok=Iwa1oBOl (Book list, favorites) +[2]: https://en.wikipedia.org/wiki/Personal_learning_network +[3]: https://www.teachingpython.fm/hosts/kellypared +[4]: https://twitter.com/smtibor +[5]: https://www.teachingpython.fm/20 +[6]: https://us.pycon.org/2019/ +[7]: https://www.linkedin.com/in/betsywaliszewski +[8]: https://us.pycon.org/2019/events/letslearnpython/ +[9]: https://www.linkedin.com/in/kcunning/ +[10]: https://nostarch.com/pythonforkids +[11]: https://nostarch.com/programwithminecraft +[12]: https://nostarch.com/ +[13]: https://www.youtube.com/c/KatieCunningham +[14]: https://www.linkedin.com/in/natdunn/ +[15]: https://www.linkedin.com/in/sean-valentine-b370349b/ +[16]: https://www.webucator.com/ +[17]: http://www.hiddengeniusproject.org/ +[18]: https://us.pycon.org/2019/events/open-spaces/ +[19]: https://www.adafruit.com/product/3333 +[20]: https://github.com/adafruit/PyCon2019 +[21]: https://twitter.com/nnja +[22]: https://www.youtube.com/watch?v=35mXD40SvXM +[23]: https://allthingsopen.org/ +[24]: https://frontendmasters.com/courses/python/ +[25]: https://twitter.com/kattni +[26]: https://github.com/kattni/ChiPy_2018 +[27]: http://Opensource.com +[28]: https://opensource.com/users/moshez +[29]: http://openbookproject.net/thinkcs/python/english3e/ +[30]: https://opensource.com/users/seth +[31]: https://www.google.com/search?source=hp&ei=gVToXPq-FYXGsAW-mZ_YAw&q=site%3Aopensource.com+%22Seth+Kenlon%22+%2B+Python&oq=site%3Aopensource.com+%22Seth+Kenlon%22+%2B+Python&gs_l=psy-ab.12...627.15303..15584...1.0..0.176.2802.4j21......0....1..gws-wiz.....0..35i39j0j0i131j0i67j0i20i263.r2SAW3dxlB4 +[32]: http://alsweigart.com/ +[33]: https://twitter.com/ehmatthes?lang=en +[34]: https://twitter.com/adafruit +[35]: https://www.adafruit.com/product/3944 +[36]: https://www.pythonpodcast.com/episodes/ diff --git a/published/201906/20190531 Unity Editor is Now Officially Available for Linux.md b/published/201906/20190531 Unity Editor is Now Officially Available for Linux.md new file mode 100644 index 0000000000..7b579caf06 --- /dev/null +++ b/published/201906/20190531 Unity Editor is Now Officially Available for Linux.md @@ -0,0 +1,89 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10974-1.html) +[#]: subject: (Unity Editor is Now Officially Available for Linux) +[#]: via: (https://itsfoss.com/unity-editor-linux/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Unity 编辑器现已正式面向 Linux 推出 +====== + +如果你是设计师、开发者或艺术家,你可能一直在使用 Linux 上的实验性 [Unity 编辑器][1]。然而,不能一直用实验性版本 —— 开发者需要一个完整稳定的工作经验。 + +因此,他们最近宣布你可以在 Linux 上使用完整功能的 Unity 编辑器了。 + +虽然这是一个令人兴奋的消息,但它正式支持哪些 Linux 发行版?我们来谈谈更多细节…… + +> 非 FOSS 警告 + +> Linux (或任何其他平台)上的 Unity 编辑器不是开源软件。我们在这里介绍它是因为: + +### 官方支持 Ubuntu 和 CentOS 7 + +![][2] + +无论你拥有个人许可还是专业许可,如果你安装了 Unity 2019.1 或更高版本,都可以使用该编辑器。 + +此外,他们优先支持 Ubuntu 16.04、Ubuntu 18.04 和 CentOS 7。 + +在[公告][3]中,他们还提到了支持的配置: + +* x86-64 架构 +* 运行在 X11 窗口系统之上的 Gnome 桌面环境 +* Nvidia 官方专有显卡驱动和 AMD Mesa 显卡驱动 +* 桌面计算机,在没有仿真或兼容层的设备/硬件上运行 + +你可以尝试其他的 —— 但最好坚持官方要求以获得最佳体验。 + +> 关于第三方工具的说明 + +> 如果你碰巧在某个项目中使用了任何第三方工具,那么必须单独检查它们是否支持。 + +### 如何在 Linux 上安装 Unity 编辑器 + +现在你已经了解了,那么该如何安装? + +要安装 Unity,你需要下载并安装 [Unity Hub][4]。 + +![Unity Hub][5] + +你需要完成以下步骤: + +* 从[官方论坛页面][4]下载适用于 Linux 的 Unity Hub。 +* 它将下载一个 AppImage 文件。简单地说,让它可执行并运行它。如果你不了解,你应该查看关于[如何在 Linux 上使用 AppImage][6] 的指南。 +* 启动 Unity Hub 后,它会要求你使用 Unity ID 登录(或注册)以激活许可证。有关许可证生效的更多信息,请参阅他们的 [FAQ 页面][7]。 +* 使用 Unity ID 登录后,进入 “Installs” 选项(如上图所示)并添加所需的版本/组件。 + +就是这些了。这就是获取并快速安装的最佳方法。 + +### 总结 + +即使这是一个令人兴奋的消息,但官方配置支持似乎并不广泛。如果你在 Linux 上使用它,请在[他们的 Linux 论坛帖子][9]上分享你的反馈和意见。 + +你觉得怎么样?此外,你是使用 Unity Hub 安装它,还是有更好的方法来安装? + +请在下面的评论中告诉我们你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/unity-editor-linux/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://unity3d.com/unity/editor +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/Unity-Editor-on-Linux.png?resize=800%2C450&ssl=1 +[3]: https://blogs.unity3d.com/2019/05/30/announcing-the-unity-editor-for-linux/ +[4]: https://forum.unity.com/threads/unity-hub-v-1-6-0-is-now-available.640792/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/unity-hub.jpg?fit=800%2C532&ssl=1 +[6]: https://itsfoss.com/use-appimage-linux/ +[7]: https://support.unity3d.com/hc/en-us/categories/201268913-Licenses +[9]: https://forum.unity.com/forums/linux-editor.93/ diff --git a/published/201906/20190531 Why translation platforms matter.md b/published/201906/20190531 Why translation platforms matter.md new file mode 100644 index 0000000000..92cdbb20b1 --- /dev/null +++ b/published/201906/20190531 Why translation platforms matter.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10953-1.html) +[#]: subject: (Why translation platforms matter) +[#]: via: (https://opensource.com/article/19/5/translation-platforms) +[#]: author: (Jean-Baptiste Holcroft https://opensource.com/users/jibec/users/annegentle/users/bcotton) + +什么是翻译平台最重要的地方? +====== + +> 技术上的考虑并不是判断一个好的翻译平台的最佳方式。 + +![](https://img.linux.net.cn/data/attachment/album/201906/09/112224nvvkrv16qv60vwpv.jpg) + +语言翻译可以使开源软件能够被世界各地的人们使用,这是非开发人员参与他们喜欢的(开源)项目的好方法。有许多[翻译工具][2],你可以根据他们处理翻译中涉及的主要功能区域的能力来评估:技术交互能力、团队支持能力和翻译支持能力。 + +技术交互方面包括: + +* 支持的文件格式 +* 与开源存储库的同步 +* 自动化支持工具 +* 接口可能性 + +对团队合作(也可称为“社区活力”)的支持包括该平台如何: + +* 监控变更(按译者、项目等) +* 跟进由项目推动的更新 +* 显示进度状态 +* 是否启用审核和验证步骤 +* 协助(来自同一团队和跨语言的)翻译人员和项目维护人员之间的讨论 +* 平台支持的全球通讯(新闻等) + +翻译协助包括: + +* 清晰、符合人体工程学的界面 +* 简单几步就可以找到项目并开始工作 +* 可以简单地了解到翻译和分发之间流程 +* 可以使用翻译记忆机 +* 词汇表丰富 + +前两个功能区域与源代码管理平台的差别不大,只有一些小的差别。我觉得最后一个区域也主要与源代码有关。但是,它们处理的数据非常不同,翻译平台的用户通常也不如开发人员了解技术,而数量也更多。 + +### 我的推荐 + +在我看来,GNOME 平台提供了最好的翻译平台,原因如下: + +* 其网站包含了团队组织和翻译平台。很容易看出谁在负责以及他们在团队中的角色。一切都集中在几个屏幕之内。 +* 很容易找到要处理的内容,并且你会很快意识到你必须将文件下载到本地计算机并在修改后将其发回。这个流程不是很先进,但逻辑很容易理解。 +* 一旦你发回文件,平台就可以向邮件列表发送通告,以便团队知道后续步骤,并且可以全局轻松讨论翻译(而不是评论特定句子)。 +* 它支持多达 297 种语言。 +* 它显示了基本句子、高级菜单和文档的明确的进度百分比。 +   +再加上可预测的 GNOME 发布计划,社区可以使用一切可以促进社区工作的工具。 + +如果我们看看 Debian 翻译团队,他们多年来一直在为 Debian (LCTT 译注:此处原文是“Fedora”,疑为笔误)翻译了难以想象的大量内容(尤其是新闻),我们看到他们有一个高度以来于规则的翻译流程,完全基于电子邮件,手动推送到存储库。该团队还将所有内容都放在流程中,而不是工具中,尽管这似乎需要相当大的技术能力,但它已成为领先的语言群体之一,已经运作多年。 + +我认为,成功的翻译平台的主要问题不是基于单一的(技术、翻译)工作的能力,而是基于如何构建和支持翻译团队的流程。这就是可持续性的原因。 + +生产过程是构建团队最重要的方式;通过正确地将它们组合在一起,新手很容易理解该过程是如何工作的,采用它们,并将它们解释给下一组新人。 + +要建立一个可持续发展的社区,首先要考虑的是支持协同工作的工具,然后是可用性。 + +这解释了我为什么对 [Zanata][3] 工具沮丧,从技术和界面的角度来看,这是有效的,但在帮助构建社区方面却很差。我认为翻译是一个社区驱动的过程(可能是开源软件开发中最受社区驱动的过程之一),这对我来说是一个关键问题。 + +* * * + +本文改编自“[什么是一个好的翻译平台?][4]”,最初发表在 Jibec 期刊上,并经许可重复使用。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/translation-platforms + +作者:[Jean-Baptiste Holcroft][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jibec/users/annegentle/users/bcotton +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/people_remote_teams_world.png?itok=_9DCHEel +[2]: https://opensource.com/article/17/6/open-source-localization-tools +[3]: http://zanata.org/ +[4]: https://jibecfed.fedorapeople.org/blog-hugo/en/2016/09/whats-a-good-translation-platform/ diff --git a/published/201906/20190604 How To Verify NTP Setup (Sync) is Working or Not In Linux.md b/published/201906/20190604 How To Verify NTP Setup (Sync) is Working or Not In Linux.md new file mode 100644 index 0000000000..4c28227f63 --- /dev/null +++ b/published/201906/20190604 How To Verify NTP Setup (Sync) is Working or Not In Linux.md @@ -0,0 +1,145 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10951-1.html) +[#]: subject: (How To Verify NTP Setup (Sync) is Working or Not In Linux?) +[#]: via: (https://www.2daygeek.com/check-verify-ntp-sync-is-working-or-not-in-linux-using-ntpq-ntpstat-timedatectl/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +如何在 Linux 下确认 NTP 是否同步? +====== + +![](https://img.linux.net.cn/data/attachment/album/201906/08/215622oqdhiuhocsndijlu.jpg) + +NTP 意即网络时间协议Network Time Protocol,它通过网络同步计算机系统之间的时钟。NTP 服务器可以使组织中的所有服务器保持同步,以准确时间执行基于时间的作业。NTP 客户端会将其时钟与 NTP 服务器同步。 + +我们已经写了一篇关于 NTP 服务器和客户端安装和配置的文章。如果你想查看这些文章,请导航至以下链接。 + + * [如何在 Linux 上安装、配置 NTP 服务器和客户端?][1] + * [如何安装和配置 Chrony 作为 NTP 客户端?][2] + +我假设我你经使用上述链接设置了 NTP 服务器和 NTP 客户端。现在,如何验证 NTP 设置是否正常工作? + +Linux 中有三个命令可用于验证 NTP 同步情况。详情如下。在本文中,我们将告诉您如何使用所有这些命令验证 NTP 同步。 + + * `ntpq`:ntpq 是一个标准的 NTP 查询程序。 + * `ntpstat`:显示网络世界同步状态。 + * `timedatectl`:它控制 systemd 系统中的系统时间和日期。 + +### 方法 1:如何使用 ntpq 命令检查 NTP 状态? + +`ntpq` 实用程序用于监视 NTP 守护程序 `ntpd` 的操作并确定性能。 + +该程序可以以交互模式运行,也可以使用命令行参数进行控制。它通过向服务器发送多个查询来打印出连接的对等项列表。如果 NTP 正常工作,你将获得类似于下面的输出。 + +``` +# ntpq -p + + remote refid st t when poll reach delay offset jitter +============================================================================== +*CentOS7.2daygee 133.243.238.163 2 u 14 64 37 0.686 0.151 16.432 +``` + +细节: + +* `-p`:打印服务器已知的对等项列表以及其状态摘要。 + +### 方法 2:如何使用 ntpstat 命令检查 NTP 状态? + +`ntpstat` 将报告在本地计算机上运行的 NTP 守护程序(`ntpd`)的同步状态。如果发现本地系统与参考时间源保持同步,则 `ntpstat` 将报告大致的时间精度。 + +`ntpstat` 命令根据 NTP 同步状态返回三种状态码。详情如下。 + +* `0`:如果时钟同步则返回 0。 +* `1`:如果时钟不同步则返回 1。 +* `2`:如果时钟状态不确定,则返回 2,例如 ntpd 不可联系时。 + +``` +# ntpstat + +synchronised to NTP server (192.168.1.8) at stratum 3 + time correct to within 508 ms + polling server every 64 s +``` + +### 方法 3:如何使用 timedatectl 命令检查 NTP 状态? + +[timedatectl 命令][3]用于查询和更改系统时钟及其在 systmed 系统中的设置。 + +``` +# timedatectl +或 +# timedatectl status + + Local time: Thu 2019-05-30 05:01:05 CDT + Universal time: Thu 2019-05-30 10:01:05 UTC + RTC time: Thu 2019-05-30 10:01:05 + Time zone: America/Chicago (CDT, -0500) + NTP enabled: yes +NTP synchronized: yes + RTC in local TZ: no + DST active: yes + Last DST change: DST began at + Sun 2019-03-10 01:59:59 CST + Sun 2019-03-10 03:00:00 CDT + Next DST change: DST ends (the clock jumps one hour backwards) at + Sun 2019-11-03 01:59:59 CDT + Sun 2019-11-03 01:00:00 CST +``` + +### 更多技巧 + +Chrony 是一个 NTP 客户端的替代品。它可以更快地同步系统时钟,时间精度更高,对于一直不在线的系统尤其有用。 + +chronyd 较小,它使用较少的内存,只在必要时才唤醒 CPU,这样可以更好地节省电能。即使网络拥塞较长时间,它也能很好地运行。 + +你可以使用以下任何命令来检查 Chrony 状态。 + +检查 Chrony 跟踪状态。 + +``` +# chronyc tracking + +Reference ID : C0A80105 (CentOS7.2daygeek.com) +Stratum : 3 +Ref time (UTC) : Thu Mar 28 05:57:27 2019 +System time : 0.000002545 seconds slow of NTP time +Last offset : +0.001194361 seconds +RMS offset : 0.001194361 seconds +Frequency : 1.650 ppm fast +Residual freq : +184.101 ppm +Skew : 2.962 ppm +Root delay : 0.107966967 seconds +Root dispersion : 1.060455322 seconds +Update interval : 2.0 seconds +Leap status : Normal +``` + +运行 `sources` 命令以显示有关当前时间源的信息。 + +``` +# chronyc sources + +210 Number of sources = 1 +MS Name/IP address Stratum Poll Reach LastRx Last sample +=============================================================================== +^* CentOS7.2daygeek.com 2 6 17 62 +36us[+1230us] +/- 1111ms +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/check-verify-ntp-sync-is-working-or-not-in-linux-using-ntpq-ntpstat-timedatectl/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-10811-1.html +[2]: https://linux.cn/article-10820-1.html +[3]: https://www.2daygeek.com/change-set-time-date-and-timezone-on-linux/ diff --git a/published/201906/20190604 Kubernetes is a dump truck- Here-s why.md b/published/201906/20190604 Kubernetes is a dump truck- Here-s why.md new file mode 100644 index 0000000000..b8f0930300 --- /dev/null +++ b/published/201906/20190604 Kubernetes is a dump truck- Here-s why.md @@ -0,0 +1,53 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11011-1.html) +[#]: subject: (Kubernetes is a dump truck: Here's why) +[#]: via: (https://opensource.com/article/19/6/kubernetes-dump-truck) +[#]: author: (Scott McCarty https://opensource.com/users/fatherlinux) + +为什么说 Kubernetes 是一辆翻斗车 +====== + +> 翻斗车是解决各种基本业务问题的优雅解决方案。 + +![](https://img.linux.net.cn/data/attachment/album/201906/24/012846v737bts00uwk3qd7.jpg) + +这篇文章写于 Kubernetes 的生日(6 月 7 日星期五)前夕。 + +翻斗车很优雅。说真的,不信你听我说。它们以优雅的方式解决了各种各样的技术问题。它们可以搬动泥土、砾石、岩石、煤炭、建筑材料或道路上的障碍。它们甚至可以拉动拖车及它们上面的其他重型设备。你可以给一辆翻斗车装上五吨泥土,然后自驾游遍全国。对于像我这样的电脑极客来说,那就是优雅。 + +但是,它们并不容易使用。驾驶翻斗车需要特殊的驾驶执照。它们也不容易装配和维护。购买翻斗车和各种维护时要做很多选择。但是,它们可以优雅的搬动那些垃圾。 + +你知道搬动垃圾有什么不优雅的地方吗?假如你有一款新型的紧凑型轿车,它们到处可以买到,易于驾驶、更易于维护。但是,用它们来装泥土就很糟糕。这需要跑 200 趟才能运走 5 吨垃圾,而且,之后没人再会想要这辆车了。 + +好吧,你可以买一辆出售的翻斗车,而不是想自己造一辆。但是我不同,我是个极客,我喜欢自己造东西。但…… + +如果你拥有一家建筑公司,你就不会想着自己造一辆翻斗车。你肯定不会维持一条供应链来重构翻斗车(这可是一条很大的供应链)。但你可以学会驾驶一辆。 + +好吧,我的这个比喻很粗糙,但很容易理解。易用性是相对的,易于维护是相对的,易于装配也是相对的。这实际上取决于你想要做什么。[Kubernetes][2] 也不例外。 + +一次性构建 Kubernetes 并不太难。配置好 Kubernetes 呢?好吧,这稍微难一些。你如何看待 KubeCon?它们又宣布了多少新项目?哪些是“真实的”呢?而你应该学习哪些?你对 Harbour、TikV、NATD、Vitess,开放策略代理有多深入的了解?更不用说 Envoy、eBPF 和 Linux 中的一系列底层技术?这就像是 1904 年工业革命爆发时建造翻斗车一样,你要弄清楚使用的螺钉、螺栓、金属和活塞。(有没有蒸汽朋克在这里吗?) + +像翻斗车一样构造和配置 Kubernetes 是一个技术问题,如果你从事金融服务、零售、生物研究、食品服务等等,这可能不是你应该做的事情。但是,学习如何驾驶 Kubernetes 肯定是你应该学习的东西。 + +Kubernetes 就像一辆翻斗车,因其可以解决的各种技术问题(以及它所拖带的生态系统)而优雅。所以,我会给你一句引用的话,这是我的一位计算机科学教授在我大学的第一年告诉我们的,她说,“有一天,你会看到一段代码并对自己说,‘真特么优雅!’” + +Kubernetes 很优雅。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/kubernetes-dump-truck + +作者:[Scott McCarty][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/fatherlinux +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/dump_truck_car_container_kubernetes.jpg?itok=4BdmyVGd (Dump truck with kids standing in the foreground) +[2]: https://kubernetes.io/ diff --git a/published/201906/20190604 Two Methods To Check Or List Installed Security Updates on Redhat (RHEL) And CentOS System.md b/published/201906/20190604 Two Methods To Check Or List Installed Security Updates on Redhat (RHEL) And CentOS System.md new file mode 100644 index 0000000000..97cb82380d --- /dev/null +++ b/published/201906/20190604 Two Methods To Check Or List Installed Security Updates on Redhat (RHEL) And CentOS System.md @@ -0,0 +1,164 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10960-1.html) +[#]: subject: (Two Methods To Check Or List Installed Security Updates on Redhat (RHEL) And CentOS System) +[#]: via: (https://www.2daygeek.com/check-installed-security-updates-on-redhat-rhel-and-centos-system/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +在 RHEL 和 CentOS 上检查或列出已安装的安全更新的两种方法 +====== + +![](https://img.linux.net.cn/data/attachment/album/201906/11/100735bdnjzkkmjbxbttmm.jpg) + +我们过去曾写过两篇关于这个主题的文章,每篇文章都是根据不同的要求发表的。如果你想在开始之前浏览这些文章。请通过以下链接: + +* [如何检查 RHEL 和 CentOS 上的可用安全更新?][1] +* [在 RHEL 和 CentOS 上安装安全更新的四种方法?][2] + +这些文章与其他文章相互关联,因此,在深入研究之前,最好先阅读这些文章。 + +在本文中,我们将向你展示如何检查已安装的安全更新。我会介绍两种方法,你可以选择最适合你的。 + +此外,我还添加了一个小的 shell 脚本,它为你提供已安装的安全包计数。 + +运行以下命令获取系统上已安装的安全更新的列表。 + +``` +# yum updateinfo list security installed + +Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, + : subscription-manager, verify, versionlock +RHSA-2015:2315 Moderate/Sec. ModemManager-glib-1.1.0-8.git20130913.el7.x86_64 +RHSA-2015:2315 Moderate/Sec. NetworkManager-1:1.0.6-27.el7.x86_64 +RHSA-2016:2581 Low/Sec. NetworkManager-1:1.4.0-12.el7.x86_64 +RHSA-2017:2299 Moderate/Sec. NetworkManager-1:1.8.0-9.el7.x86_64 +RHSA-2015:2315 Moderate/Sec. NetworkManager-adsl-1:1.0.6-27.el7.x86_64 +RHSA-2016:2581 Low/Sec. NetworkManager-adsl-1:1.4.0-12.el7.x86_64 +RHSA-2017:2299 Moderate/Sec. NetworkManager-adsl-1:1.8.0-9.el7.x86_64 +RHSA-2015:2315 Moderate/Sec. NetworkManager-bluetooth-1:1.0.6-27.el7.x86_64 +``` + +要计算已安装的安全包的数量,请运行以下命令: + +``` +# yum updateinfo list security installed | wc -l +1046 +``` + +仅打印安装包列表: + +``` +# yum updateinfo list security all | grep -w "i" + +i RHSA-2015:2315 Moderate/Sec. ModemManager-glib-1.1.0-8.git20130913.el7.x86_64 +i RHSA-2015:2315 Moderate/Sec. NetworkManager-1:1.0.6-27.el7.x86_64 +i RHSA-2016:2581 Low/Sec. NetworkManager-1:1.4.0-12.el7.x86_64 +i RHSA-2017:2299 Moderate/Sec. NetworkManager-1:1.8.0-9.el7.x86_64 +i RHSA-2015:2315 Moderate/Sec. NetworkManager-adsl-1:1.0.6-27.el7.x86_64 +i RHSA-2016:2581 Low/Sec. NetworkManager-adsl-1:1.4.0-12.el7.x86_64 +i RHSA-2017:2299 Moderate/Sec. NetworkManager-adsl-1:1.8.0-9.el7.x86_64 +i RHSA-2015:2315 Moderate/Sec. NetworkManager-bluetooth-1:1.0.6-27.el7.x86_64 +i RHSA-2016:2581 Low/Sec. NetworkManager-bluetooth-1:1.4.0-12.el7.x86_64 +i RHSA-2017:2299 Moderate/Sec. NetworkManager-bluetooth-1:1.8.0-9.el7.x86_64 +i RHSA-2015:2315 Moderate/Sec. NetworkManager-config-server-1:1.0.6-27.el7.x86_64 +i RHSA-2016:2581 Low/Sec. NetworkManager-config-server-1:1.4.0-12.el7.x86_64 +i RHSA-2017:2299 Moderate/Sec. NetworkManager-config-server-1:1.8.0-9.el7.noarch +``` + +要计算已安装的安全包的数量,请运行以下命令: + +``` +# yum updateinfo list security all | grep -w "i" | wc -l +1043 +``` + +或者,你可以检查指定包修复的漏洞列表。 + +在此例中,我们将检查 “openssh” 包中已修复的漏洞列表: + +``` +# rpm -q --changelog openssh | grep -i CVE + +- Fix for CVE-2017-15906 (#1517226) +- CVE-2015-8325: privilege escalation via user's PAM environment and UseLogin=yes (#1329191) +- CVE-2016-1908: possible fallback from untrusted to trusted X11 forwarding (#1298741) +- CVE-2016-3115: missing sanitisation of input for X11 forwarding (#1317819) +- prevents CVE-2016-0777 and CVE-2016-0778 +- Security fixes released with openssh-6.9 (CVE-2015-5352) (#1247864) +- only query each keyboard-interactive device once (CVE-2015-5600) (#1245971) +- add new option GSSAPIEnablek5users and disable using ~/.k5users by default CVE-2014-9278 +- prevent a server from skipping SSHFP lookup - CVE-2014-2653 (#1081338) +- change default value of MaxStartups - CVE-2010-5107 (#908707) +- CVE-2010-4755 +- merged cve-2007_3102 to audit patch +- fixed audit log injection problem (CVE-2007-3102) +- CVE-2006-5794 - properly detect failed key verify in monitor (#214641) +- CVE-2006-4924 - prevent DoS on deattack detector (#207957) +- CVE-2006-5051 - don't call cleanups from signal handler (#208459) +- use fork+exec instead of system in scp - CVE-2006-0225 (#168167) +``` + +同样,你可以通过运行以下命令来检查相应的包中是否修复了指定的漏洞: + +``` +# rpm -q --changelog openssh | grep -i CVE-2016-3115 + +- CVE-2016-3115: missing sanitisation of input for X11 forwarding (#1317819) +``` + +### 如何使用 Shell 脚本计算安装的安全包? + +我添加了一个小的 shell 脚本,它可以帮助你计算已安装的安全包列表。 + +``` +# vi /opt/scripts/security-check.sh + +#!/bin/bash +echo "+-------------------------+" +echo "|Security Advisories Count|" +echo "+-------------------------+" +for i in Important Moderate Low +do +sec=$(yum updateinfo list security installed | grep $i | wc -l) +echo "$i: $sec" +done | column -t +echo "+-------------------------+" +``` + +给 `security-check.sh` 文件执行权限。 + +``` +$ chmod +x security-check.sh +``` + +最后执行脚本统计。 + +``` +# sh /opt/scripts/security-check.sh + ++-------------------------+ +|Security Advisories Count| ++-------------------------+ +Important: 480 +Moderate: 410 +Low: 111 ++-------------------------+ +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/check-installed-security-updates-on-redhat-rhel-and-centos-system/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-10938-1.html +[2]: https://www.2daygeek.com/install-security-updates-on-redhat-rhel-centos-system/ diff --git a/published/201906/20190605 How to navigate the Kubernetes learning curve.md b/published/201906/20190605 How to navigate the Kubernetes learning curve.md new file mode 100644 index 0000000000..74c3187b50 --- /dev/null +++ b/published/201906/20190605 How to navigate the Kubernetes learning curve.md @@ -0,0 +1,72 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11026-1.html) +[#]: subject: (How to navigate the Kubernetes learning curve) +[#]: via: (https://opensource.com/article/19/6/kubernetes-learning-curve) +[#]: author: (Scott McCarty https://opensource.com/users/fatherlinux/users/fatherlinux) + +如何跨越 Kubernetes 学习曲线 +====== + +> Kubernetes 就像一辆翻斗车。它非常适合解决它所针对的问题,但你必须首先掌握其学习曲线。 + +![](https://img.linux.net.cn/data/attachment/album/201906/28/131501h8vydvd4tyx5gz5t.jpg) + +在[为什么说 Kubernetes 是一辆翻斗车][2]中,我谈到了一个工具如何优雅地解决它所设计用来解决的问题 —— 只是你要学会如何使用它。在本系列的第 2 部分中,我将更深入地了解 Kubernetes 的学习曲线。 + +[Kubernetes][3] 的旅程通常从在一台主机上运行一个容器开始。你可以快速了解运行新版本软件的难易程度,与其他人分享该软件的难易程度,以及对于这些用户按照你预期方式运行它的难易程度。 + +但是你需要: + +* 两个容器 +* 两个主机 + +使用容器在端口 80 上启动一个 Web 服务器很容易,但是当你需要在端口 80 上启动第二个容器时会发生什么?当你构建生产环境时,需要容器化 Web 服务器在发生故障时转移到第二个主机时会发生什么?在任何一种情况下,这个答案简单来说就是你必须采用容器编排。 + +当你开始处理两个容器或两个主机问题时,你将不可避免地引入了复杂性,因此,这就是一个学习曲线。这个两个服务(容器的更通用说法)或两个主机的问题已经存在了很长时间,并且由此带来了复杂性。 + +从历史上看,这将涉及负载均衡、集群软件甚至集群文件系统。每个服务的配置逻辑都嵌入在每个系统(负载均衡、集群软件和文件系统)中。在负载平衡器后运行 60 或 70 个集群的服务是复杂的。添加另一个新服务也很复杂。更糟糕的是,撤下服务简直是一场噩梦。回想起我对生产环境中的 MySQL 和 Apache 服务器进行故障排除的日子,这些服务器的逻辑嵌入在三、四个或五个不同的地方,所有这些都采用不同的格式,让我头疼不已。 + +Kubernetes 使用一个软件优雅地解决了所有这些问题: + +1. 两项服务(容器):✅ +2. 两台服务器(高可用性):✅ +3. 单一配置来源:✅ +4. 标准配置格式:✅ +5. 网络:✅ +6. 储存:✅ +7. 依赖关系(什么服务与哪些数据库对应):✅ +8. 易于配置:✅ +9. 轻松取消配置:✅(也许是 Kubernetes **最**强大的部分) + +等等,这样初看起来 Kubernetes 非常优雅、非常强大。 **没错。**你可以在 Kubernetes 中建模一整个微型 IT 世界。 + +![Kubernetes business model][4] + +所以,是的,就像开始使用巨型翻斗车(或任何专业设备)时,有一个学习曲线。使用 Kubernetes 还有一个学习曲线,但它值得,因为你可以用一个工具解决这么多问题。如果你对学习曲线感到担忧,请仔细考虑 IT 基础架构中的所有底层网络、存储和安全问题,并设想一下今天的解决方案 —— 这并不容易。特别是当你越来越快地引入越来越多的服务时。速度是当今的目标,因此要特别考虑配置和取消配置问题。 + +但是,不要混淆了建造或配置 Kubernetes 的学习曲线(为你的翻斗车挑选合适的挡泥板可能很难,LOL)和使用它的学习曲线。学习用如此多的不同层次(容器引擎、日志记录、监控、服务网格、存储、网络)的技术来建立自己的 Kubernetes 有很多不同的选择,还有每六个月维护每个组件的更新选择,这可能不值得投资 —— 但学会使用它绝对是值得的。 + +我每天都与 Kubernetes 和容器泡在一起,即使这样我都很难跟踪几乎每天都在宣布的所有重大新项目。 但是,每一天我都对使用单一工具来模拟整个 IT 多个方面的运营优势感到兴奋。此外,记住 Kubernetes 已经成熟了很多,并将继续发展下去。与之前的 Linux 和 OpenStack 一样,每一层的接口和事实上的项目都将成熟并变得更容易选择。 + +在本系列的第三篇文章中,我将深入挖掘你在驾驶 Kubernetes “卡车”之前需要了解的内容。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/kubernetes-learning-curve + +作者:[Scott McCarty][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/fatherlinux/users/fatherlinux +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/dumptruck_car_vehicle_storage_container_road.jpg?itok=TWK0CbX_ (Dump truck rounding a turn in the road) +[2]: https://linux.cn/article-11011-1.html +[3]: https://kubernetes.io/ +[4]: https://opensource.com/sites/default/files/uploads/developer_native_experience_-_mapped_to_traditional_1.png (Kubernetes business model) diff --git a/published/201906/20190606 Cisco to buy IoT security, management firm Sentryo.md b/published/201906/20190606 Cisco to buy IoT security, management firm Sentryo.md new file mode 100644 index 0000000000..302ea5e3f4 --- /dev/null +++ b/published/201906/20190606 Cisco to buy IoT security, management firm Sentryo.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (hopefully2333) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11035-1.html) +[#]: subject: (Cisco to buy IoT security, management firm Sentryo) +[#]: via: (https://www.networkworld.com/article/3400847/cisco-to-buy-iot-security-management-firm-sentryo.html) +[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) + +思科收购了物联网安全管理公司 Sentryo +====== +> 买下 Sentryo 将给思科在工业物联网的异常和实时威胁检测两方面予以支持。 + +![IDG Worldwide][1] + +为了扩展自己的物联网安全管理产品,思科计划收购 Sentryo,这是一家总部位于法国的公司,Sentryo 为工业物联网提供异常检测和实时威胁检测。 + +Sentryo 成立于 2014 年,产品包括 ICS CyberVision(一种用于资产库存、网络监控和威胁情报的平台)以及 CyberVision 网络边界传感器,这用于分析网络流量。 + +**更多关于物联网的信息:** + + * [什么是物联网?物联网如何运行?][4] + * [什么是边缘计算,这会如何改变我们的网络?][5] + * [最强的物联网公司][6] + * [10 个值得关注的热门物联网创业公司][7] + * [在物联网领域赚钱的六种方法][8] + * [什么是数字双胞胎技术? [以及它为什么重要]][9] + * [区块链,以服务为中心的网络是物联网成功的关键][10] + * [物联网以网络和安全作为基础][11] + * [构建完整的物联网网络必须优先完成][12] + * [什么是工业物联网?[为什么风险如此之高]][13] + +“我们通过思科的 IOx 应用框架将 Sentryo 的边缘传感器和我们的工业网络硬件相结合”,思科企业发展和思科投资的副总裁 Rob Salvagno 在一篇关于计划收购的博客中写道。 + +“我们相信连接是物联网项目的基础,通过释放网络的力量,我们可以大大提高运作的效率并发现新的商业机会。随着 Sentryo 的加入,思科可以为系统控制工程师提供更加深入的资产可见度,以此来对系统进行优化,检测异常并保护他们的网络。” + +Gartner 对 Sentryo 的系统写道:“ICS CyberVision 产品以其所有 OT 用户都能理解的方式提供对其客户 OT 网络的可视性,而不仅仅是 IT 技术人员。随着黑客和监管机构越来越关注工业控制系统,一个组织的 OT 拥有完整的可见性是至关重要的一件事。很多的 OT 网络不仅在地理上位置分散,而且也很复杂,由成千上万的组件组成。” + +Frost & Sullivan 的工业分析师 Nandini Natarajan 表示,Sentryo 的 ICS CyberVision 让企业能够确保其工业运作的连续性、动态弹性和安全性,并以此预防可能的网络攻击。“它将使用标签形式的独特的 ‘通用 OT 语言’ 来自动描述资产和通信流程,以纯文本的方式描述每个资产在做什么。ICS CyberVision 可以让任何人都能立刻查看一台设备的类别和行为;它利用人工智能算法提供很多不同的分析视图,来让用户深入了解到一个典型的工业控制系统可以产生多么庞大的数据。Sentryo 可以轻松查看重要或相关的信息。” + +Natarajan 表示,除此之外,Sentryo 的平台使用深度数据包检测(DPI)从工业设备之间的通信数据包里提取信息。DPI 引擎通过边缘计算架构进行部署,它可以运行在 Sentryo 传感器设备上,也可以在已经安装好的网络设备上运行。因此,Sentryo 可以将可见性和网络安全特性嵌入进工业网络中,而非部署带外监控网络。 + +Sentryo 的技术将扩大思科在物联网上的总体计划。在今年一月,思科推出了一整套的交换机、软件、开发工具和蓝图,这些东西将用于把物联网、基于意图联网的工业网络、传统信息安全、传统信息监控、应用开发支持融为一体。 + +这个新平台可以通过思科的 DNA 中心进行管理,让客户能将他们的物联网、工业网络控制和他们的商业 IT 世界融为一体。 + +DNA 中心是思科用于企业网络的中央管理工具,具有自动化、确保设置、结构配置、基于策略进行分割的功能。它也是该公司 IBN 计划的核心,用于主动向客户提供动态自动化实施网络和策略变更的能力,并在这个过程中确保数据的交付。IoT Field Network Director 是管理思科工业、连接网格路由器和终端的多服务网络的软件。 + +思科物联网业务部的高级副总裁兼总经理 Liz Centoni 表示,公司希望 Sentryo 的技术能以多种方式帮助物联网客户: + +支持网络的被动 DPI 功能,这用于发现 IOT 和 OT 设备,并且在设备和系统之间建立起通信模式。Sentryo 的传感器可以在思科的 IOx 框架里进行本地部署,并且可以内置到这些设备运行的工业网络中,而不是添加额外的硬件。 + +随着设备识别和通信模式的建立,思科将把 DNA 中心和身份识别服务引擎(ISE)集成到一起,以便客户能够很轻松地定义分割策略。这种集成将使 OT 团队能够利用 IT 安全团队的专业知识来保护他们的环境,而不会对运营的流程造成风险。 + +由于这些物联网设备缺乏现代嵌入式软件和安全功能,网络分段将成为允许运作设备向合法系统进行通信的关键技术,并降低像我们看见的 WannaCry 和 Norsk Hydro 那样网络安全事件的风险。 + +据 Crunchbase 称,Sentryo 的每年预计收入为 350 万美元,与 Cymmetria、Team8 和 Indegy 的竞争最为激烈。此次收购预期将在思科 2020 财年的第一季度 - 2019 年 10 月 26 日 - 结束前完成。思科并未详细披露此次收购的财务细节。 + +Sentryo 是思科今年的第二次收购。思科在今年一月收购了 Singularity 公司的网络分析技术。在 2018 年,思科收购了包含 Duo security software 在内的 6 家公司。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3400847/cisco-to-buy-iot-security-management-firm-sentryo.html + +作者:[Michael Cooney][a] +选题:[lujun9972][b] +译者:[hopefully2333](https://github.com/hopefully2333) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Michael-Cooney/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/09/nwan_019_iiot-100771131-large.jpg +[2]: https://www.sentryo.net/ +[3]: https://www.networkworld.com/article/3243928/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html +[4]: https://www.networkworld.com/article/3207535/internet-of-things/what-is-the-iot-how-the-internet-of-things-works.html +[5]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[6]: https://www.networkworld.com/article/2287045/internet-of-things/wireless-153629-10-most-powerful-internet-of-things-companies.html +[7]: https://www.networkworld.com/article/3270961/internet-of-things/10-hot-iot-startups-to-watch.html +[8]: https://www.networkworld.com/article/3279346/internet-of-things/the-6-ways-to-make-money-in-iot.html +[9]: https://www.networkworld.com/article/3280225/internet-of-things/what-is-digital-twin-technology-and-why-it-matters.html +[10]: https://www.networkworld.com/article/3276313/internet-of-things/blockchain-service-centric-networking-key-to-iot-success.html +[11]: https://www.networkworld.com/article/3269736/internet-of-things/getting-grounded-in-iot-networking-and-security.html +[12]: https://www.networkworld.com/article/3276304/internet-of-things/building-iot-ready-networks-must-become-a-priority.html +[13]: https://www.networkworld.com/article/3243928/internet-of-things/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html +[14]: https://blogs.cisco.com/news/cisco-industrial-iot-news +[15]: https://www.globenewswire.com/news-release/2018/06/28/1531119/0/en/Sentryo-Named-a-Cool-Vendor-by-Gartner.html +[16]: https://www.linkedin.com/pulse/industrial-internet-things-iiot-decoded-nandini-natarajan/ +[17]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr +[18]: https://www.cisco.com/c/dam/en_us/solutions/iot/ihs-report.pdf +[19]: https://www.networkworld.com/article/3336454/cisco-goes-after-industrial-iot.html +[20]: https://www.networkworld.com/article/3202699/what-is-intent-based-networking.html +[21]: https://blogs.cisco.com/news/securing-the-internet-of-things-cisco-announces-intent-to-acquire-sentryo +[22]: https://blogs.cisco.com/security/talos/wannacry +[23]: https://www.securityweek.com/norsk-hydro-may-have-lost-40m-first-week-after-cyberattack +[24]: https://www.crunchbase.com/organization/sentryo#section-web-traffic-by-similarweb +[25]: https://www.facebook.com/NetworkWorld/ +[26]: https://www.linkedin.com/company/network-world diff --git a/published/201906/20190606 How Linux can help with your spelling.md b/published/201906/20190606 How Linux can help with your spelling.md new file mode 100644 index 0000000000..abb26b7f91 --- /dev/null +++ b/published/201906/20190606 How Linux can help with your spelling.md @@ -0,0 +1,262 @@ +[#]: collector: (lujun9972) +[#]: translator: (Modrisco) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10986-1.html) +[#]: subject: (How Linux can help with your spelling) +[#]: via: (https://www.networkworld.com/article/3400942/how-linux-can-help-with-your-spelling.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如何用 Linux 帮助你拼写 +====== + +> 无论你是纠结一个难以理解的单词,还是在将报告发给老板之前再检查一遍,Linux 都可以帮助你解决拼写问题。 + +![Sandra Henry-Stocker](https://img.linux.net.cn/data/attachment/album/201906/17/214715jayk1k1kbiatkido.jpg) + +Linux 为数据分析和自动化提供了各种工具,它也帮助我们解决了一个一直都在纠结的问题 —— 拼写!无论在写每周报告时努力拼出一个单词,还是在提交商业计划书之前想要借助计算机的“眼睛”来找出你的拼写错误。现在我们来看一下它是如何帮助你的。 + +### look + +`look` 是其中一款工具。如果你知道一个单词的开头,你就可以用这个命令来获取以这些字母开头的单词列表。除非提供了替代词源,否则 `look` 将使用 `/usr/share/dict/words` 中的内容来为你标识单词。这个文件有数十万个单词,可以满足我们日常使用的大多数英语单词的需要,但是它可能不包含我们计算机领域中的一些人倾向于使用的更加生僻的单词,如 zettabyte。 + +`look` 命令的语法非常简单。输入 `look word` ,它将遍历单词文件中的所有单词并找到匹配项。 + +``` +$ look amelio +ameliorable +ameliorableness +ameliorant +ameliorate +ameliorated +ameliorates +ameliorating +amelioration +ameliorations +ameliorativ +ameliorative +amelioratively +ameliorator +amelioratory +``` + +如果你遇到系统中单词列表中未包含的单词,将无法获得任何输出。 + +``` +$ look zetta +$ +``` + +如果你没有看到你所希望出现的单词,也不要绝望。你可以在你的单词文件中添加单词,甚至引用一个完全不同的单词列表,在网上找一个或者干脆自己创建一个。你甚至不必将添加的单词放在按字母顺序排列的正确位置;只需将其添加到文件的末尾即可。但是,你必须以 root 用户身份执行此操作。例如(要注意 `>>`!): + +``` +# echo “zettabyte” >> /usr/share/dict/words +``` + +当使用不同的单词列表时,例如这个例子中的 “jargon” ,你只需要添加文件的名称。如果不采用默认文件时,请使用完整路径。 + +``` +$ look nybble /usr/share/dict/jargon +nybble +nybbles +``` + +`look` 命令大小写不敏感,因此你不必关心要查找的单词是否应该大写。 + +``` +$ look zet +ZETA +Zeta +zeta +zetacism +Zetana +zetas +Zetes +zetetic +Zethar +Zethus +Zetland +Zetta +``` + +当然,不是所有的单词列表都是一样的。一些 Linux 发行版在单词文件中提供了*多得多*的内容。你的文件中可能有十万或者更多倍的单词。 + +在我的一个 Linux 系统中: + +``` +$ wc -l /usr/share/dict/words +102402 /usr/share/dict/words +``` + +在另一个系统中: + +``` +$ wc -l /usr/share/dict/words +479828 /usr/share/dict/words +``` + +请记住,`look` 命令只适用于通过单词开头查找,但如果你不想从单词的开头查找,还可以使用其他选项。 + +### grep + +我们深爱的 `grep` 命令像其他工具一样可以从一个单词文件中选出单词。如果你正在找以某些字母开头或结尾的单词,使用 `grep` 命令是自然而然的事情。它可以通过单词的开头、结尾或中间部分来匹配单词。系统中的单词文件可以像使用 `look` 命令时在 `grep` 命令中轻松使用。不过唯一的缺点是你需要指定文件,这一点与 `look` 不尽相同。 + +在单词的开头前加上 `^`: + +``` +$ grep ^terra /usr/share/dict/words +terrace +terrace's +terraced +terraces +terracing +terrain +terrain's +terrains +terrapin +terrapin's +terrapins +terraria +terrarium +terrarium's +terrariums +``` + +在单词的结尾后加上 `$`: + +``` +$ grep bytes$ /usr/share/dict/words +bytes +gigabytes +kilobytes +megabytes +terabytes +``` + +使用 `grep` 时,你需要考虑大小写,不过 `grep` 命令也提供了一些选项。 + +``` +$ grep ^[Zz]et /usr/share/dict/words +Zeta +zeta +zetacism +Zetana +zetas +Zetes +zetetic +Zethar +Zethus +Zetland +Zetta +zettabyte +``` + +为单词文件添加软连接能使这种搜索方式更加便捷: + +``` +$ ln -s /usr/share/dict/words words +$ grep ^[Zz]et words +Zeta +zeta +zetacism +Zetana +zetas +Zetes +zetetic +Zethar +Zethus +Zetland +Zetta +zettabytye +``` + +### aspell + +`aspell` 命令提供了一种不同的方式。它提供了一种方法来检查你提供给它的任何文件或文本的拼写。你可以通过管道将文本传递给它,然后它会告诉你哪些单词看起来有拼写错误。如果所有单词都拼写正确,则不会有任何输出。 + +``` +$ echo Did I mispell that? | aspell list +mispell +$ echo I can hardly wait to try out aspell | aspell list +aspell +$ echo Did I misspell anything? | aspell list +$ +``` + +`list` 参数告诉 `aspell` 为标准输入单词提供拼写错误的单词列表。 + +你还可以使用 `aspell` 来定位和更正文本文件中的单词。如果它发现一个拼写错误的单词,它将为你提供一个相似(但拼写正确的)单词列表来替换这个单词,你也可以将该单词加入个人词库(`~/.aspell.en.pws`)并忽略拼写错误,或者完全中止进程(使文件保持处理前的状态)。 + +``` +$ aspell -c mytext +``` + +一旦 `aspell` 发现一个单词出现了拼写错误,它将会为不正确的 “mispell” 提供一个选项列表: + +``` +1) mi spell 6) misplay +2) mi-spell 7) spell +3) misspell 8) misapply +4) Ispell 9) Aspell +5) misspells 0) dispel +i) Ignore I) Ignore all +r) Replace R) Replace all +a) Add l) Add Lower +b) Abort x) Exit +``` + +请注意,备选单词和拼写是数字编号的,而其他选项是由字母选项表示的。你可以选择备选拼写中的一项或者自己输入替换项。“Abort” 选项将使文件保持不变,即使你已经为某些单词选择了替换。你选择添加的单词将被插入到本地单词文件中(例如 `~/.aspell.en.pws`)。 + +#### 其他单词列表 + +厌倦了英语? `aspell` 命令可以在其他语言中使用,只要你添加了相关语言的单词列表。例如,在 Debian 系统中添加法语的词库,你可以这样做: + +``` +$ sudo apt install aspell-fr +``` + +这个新的词库文件会被安装为 `/usr/share/dict/French`。为了使用它,你只需要简单地告诉 `aspell` 你想要使用替换的单词列表: + +``` +$ aspell --lang=fr -c mytext +``` + +这种情况下,当 `aspell` 读到单词 “one” 时,你可能会看到下面的情况: + +``` +1) once 6) orné +2) onde 7) ne +3) ondé 8) né +4) onze 9) on +5) orne 0) cône +i) Ignore I) Ignore all +r) Replace R) Replace all +a) Add l) Add Lower +b) Abort x) Exit +``` + +你也可以从 [GNU 官网][3]获取其他语言的词库。 + +### 总结 + +即使你是全国拼字比赛的冠军,你可能偶尔也会需要一点拼写方面的帮助,哪怕只是为了找出你手滑打错的单词。`aspell` 工具,加上 `look` 和 `grep` 命令已经准备来助你一臂之力了。 + + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3400942/how-linux-can-help-with-your-spelling.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[Modrisco](https://github.com/Modrisco) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/06/linux-spelling-100798596-large.jpg +[2]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua +[3]: ftp://ftp.gnu.org/gnu/aspell/dict/0index.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/201906/20190606 Kubernetes basics- Learn how to drive first.md b/published/201906/20190606 Kubernetes basics- Learn how to drive first.md new file mode 100644 index 0000000000..2e93d2d5d9 --- /dev/null +++ b/published/201906/20190606 Kubernetes basics- Learn how to drive first.md @@ -0,0 +1,74 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11036-1.html) +[#]: subject: (Kubernetes basics: Learn how to drive first) +[#]: via: (https://opensource.com/article/19/6/kubernetes-basics) +[#]: author: (Scott McCarty https://opensource.com/users/fatherlinux/users/fatherlinux/users/fatherlinux) + +Kubernetes 基础:首先学习如何使用 +====== + +> 不要被新项目分心,而是专注于取得你的 Kubernetes 翻斗车驾驶执照。 + +![Truck steering wheel and dash][1] + +在本系列的前两篇文章中,我解释了为何 Kubernetes [像翻斗车][2],并且想要理解像 [Kubernetes][4](和翻斗车,起重机等)这样优雅、专业工具总是有[学习曲线][3]的。本文是下一步:学习如何驾驶。 + +最近,我在 Reddit 上看到了一个关于[重要的 Kubernetes 项目][5]的帖子。人们似乎很想知道他们应该学习如何开始使用 Kubernetes。“驾驶翻斗车的类比”有助于确保这个问题回到轨道上去。在这个帖子中的某个人提到,除非必要,你不应该运行自己的镜像仓库,所以人们开始逐渐接受驾驭 Kubernetes 而不是构建它的想法。 + +API 是 Kubernetes 的引擎和变速器。像翻斗车的方向盘、离合器、汽油和制动踏板一样,用于构建应用程序的 YAML 或 JSON 文件是机器的主要接口。当你第一次学习 Kubernetes 时,这应该是你的主要关注点。了解你的控制部件。不要分心于最新和最大的那些项目。当你刚学会开车时,不要尝试驾驶实验性的翻斗车。相反,请专注于基础知识。 + +### 定义状态和实际状态 + +首先,Kubernetes 遵循定义状态和实际状态的原则。 + +![Defined state and actual state][6] + +人类(开发人员/系统管理员/运维人员)使用他们提交给 Kubernetes API 的 YAML/JSON 文件指定定义的状态。然后,Kubernetes 使用控制器来分析 YAML/JSON 中定义的新状态与集群中的实际状态之间的差异。 + +在上面的例子中,Replication Controller 可以看到用户指定的三个 pod 之间的差异,其中一个 pod 正在运行,并调度另外两个 Pod。如果你登录 Kubernetes 并手动杀死其中一个 Pod,它会不断启动另一个来替换它。在实际状态与定义的状态匹配之前,Kubernetes 不会停止。这是非常强大的。 + +### 原语 + +接下来,你需要了解可以在 Kubernetes 中指定的原语。 + +![Kubernetes primitives][7] + +这些原语不仅仅有 Pod,还有部署Deployment持久化卷声明Persistent Volume Claim服务Service路由route等。使用支持 Kubernetes 的平台 [OpenShift][8],你可以添加构建build和 BuildConfig。你大概需要一天左右的时间来了解这些原语。你可以在你的用例变得更加复杂时再深入了解。 + +### 将原生开发者映射到传统 IT 环境 + +最后,考虑这该如何映射到你在传统 IT 环境中的操作。 + +![Mapping developer-native to traditional IT environments][9] + +尽管是一个技术问题,但用户一直在尝试解决业务问题。从历史上看,我们使用诸如剧本playbook之类的东西将业务逻辑与单一语言的 IT 系统绑定起来。对于运维人员来说,这很不错,但是当你尝试将其扩展到开发人员时,它会变得更加繁琐。 + +直到 Kubernete 出现之前,我们从未能够以原生开发者的方式真正同时指定一组 IT 系统应如何表现和交互。如果你考虑一下,我们正在使用在 Kubernetes 中编写的 YAML/JSON 文件以非常便携和声明的方式扩展了管理存储、网络和计算资源的能力,但它们总会映射到某处的“真实”资源。我们不必以开发者身份担心它。 + +因此,快放弃关注 Kubernetes 生态系统中的新项目,而是专注开始使用它。在下一篇文章中,我将分享一些可以帮助你使用 Kubernetes 的工具和工作流程。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/kubernetes-basics + +作者:[Scott McCarty][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/fatherlinux/users/fatherlinux/users/fatherlinux +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/truck_steering_wheel_drive_car_kubernetes.jpg?itok=0TOzve80 (Truck steering wheel and dash) +[2]: https://linux.cn/article-11011-1.html +[3]: https://linux.cn/article-11026-1.html +[4]: https://opensource.com/resources/what-is-kubernetes +[5]: https://www.reddit.com/r/kubernetes/comments/bsoixc/what_are_the_essential_kubernetes_related/ +[6]: https://opensource.com/sites/default/files/uploads/defined_state_-_actual_state.png (Defined state and actual state) +[7]: https://opensource.com/sites/default/files/uploads/new_primitives.png (Kubernetes primatives) +[8]: https://www.openshift.com/ +[9]: https://opensource.com/sites/default/files/uploads/developer_native_experience_-_mapped_to_traditional.png (Mapping developer-native to traditional IT environments) diff --git a/published/201906/20190607 5 reasons to use Kubernetes.md b/published/201906/20190607 5 reasons to use Kubernetes.md new file mode 100644 index 0000000000..8de8d3ad4a --- /dev/null +++ b/published/201906/20190607 5 reasons to use Kubernetes.md @@ -0,0 +1,68 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10973-1.html) +[#]: subject: (5 reasons to use Kubernetes) +[#]: via: (https://opensource.com/article/19/6/reasons-kubernetes) +[#]: author: (Daniel Oh https://opensource.com/users/daniel-oh) + +使用 Kubernetes 的 5 个理由 +====== + +> Kubernetes 解决了一些开发和运维团队每天关注的的常见问题。 + +![](https://img.linux.net.cn/data/attachment/album/201906/14/110657gk2jz6f6kqff2kk4.jpg) + +[Kubernetes][2](K8S)是面向企业的开源容器编排工具的事实标准。它提供了应用部署、扩展、容器管理和其他功能,使企业能够通过容错能力快速优化硬件资源利用率并延长生产环境运行时间。该项目最初由谷歌开发,并将该项目捐赠给[云原生计算基金会][3](CNCF)。2018 年,它成为第一个从 CNCF [毕业][4]的项目。 + +这一切都很好,但它并不能解释为什么开发者和运维人员应该在 Kubernetes 上投入宝贵的时间和精力。Kubernetes 之所以如此有用,是因为它有助于开发者和运维人员迅速解决他们每天都在努力解决的问题。 + +以下是 Kubernetes 帮助开发者和运维人员解决他们最常见问题的五种能力。 + +### 1、厂商无关 + +许多公有云提供商不仅提供托管 Kubernetes 服务,还提供许多基于这些服务构建的云产品,来用于本地应用容器编排。由于与供应商无关,使运营商能够轻松、安全地设计、构建和管理多云和混合云平台,而不会有供应商锁定的风险。Kubernetes 还消除了运维团队对复杂的多云/混合云战略的担忧。 + +### 2、服务发现 + +为了开发微服务应用,Java 开发人员必须控制服务可用性(就应用是否可以提供服务而言),并确保服务持续存在,以响应客户端的请求,而没有任何例外。Kubernetes 的[服务发现功能][5]意味着开发人员不再需要自己管理这些东西。 + +### 3、触发 + +你的 DevOps 会如何在上千台虚拟机上部署多语言、云原生应用?理想情况下,开发和运维会在 bug 修复、功能增强、新功能、安全更新时触发部署。Kubernetes 的[部署功能][6]会自动化这个日常工作。更重要的时,它支持高级部署策略,例如[蓝绿部署和金丝雀部署][7]。 + +### 4、可伸缩性 + +自动扩展是处理云环境中大量工作负载所需的关键功能。通过构建容器平台,你可以为终端用户提高系统可靠性。[Kubernetes Horizo​​ntal Pod Autoscaler][8](HPA)允许一个集群增加或减少应用程序(或 Pod)的数量,以应对峰值流量或性能峰值,从而减少对意外系统中断的担忧。 + +### 5、容错性 + +在现代应用体系结构中,应考虑故障处理代码来控制意外错误并快速从中恢复。但是开发人员需要花费大量的时间和精力来模拟偶然的错误。Kubernetes 的 [ReplicaSet][9] 通过确保指定数量的 Pod 持续保持活动来帮助开发人员解决此问题。 + +### 结论 + +Kubernetes 使企业能够轻松、快速、安全地解决常见的开发和运维问题。它还提供其他好处,例如构建无缝的多云/混合云战略,节省基础架构成本以及加快产品上市时间。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/reasons-kubernetes + +作者:[Daniel Oh][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/daniel-oh +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/ship_wheel_gear_devops_kubernetes.png?itok=xm4a74Kv +[2]: https://opensource.com/resources/what-is-kubernetes +[3]: https://www.cncf.io/projects/ +[4]: https://www.cncf.io/blog/2018/03/06/kubernetes-first-cncf-project-graduate/ +[5]: https://kubernetes.io/docs/concepts/services-networking/service/ +[6]: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/ +[7]: https://opensource.com/article/17/5/colorful-deployments +[8]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/ +[9]: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ diff --git a/published/201906/20190608 An open source bionic leg, Python data pipeline, data breach detection, and more news.md b/published/201906/20190608 An open source bionic leg, Python data pipeline, data breach detection, and more news.md new file mode 100644 index 0000000000..4df0e7accd --- /dev/null +++ b/published/201906/20190608 An open source bionic leg, Python data pipeline, data breach detection, and more news.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10965-1.html) +[#]: subject: (An open source bionic leg, Python data pipeline, data breach detection, and more news) +[#]: via: (https://opensource.com/article/19/6/news-june-8) +[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) + +开源新闻:开源仿生腿、Python 数据管道、数据泄露检测 +====== + +> 了解过去两周来最大的开源头条新闻。 + +![][1] + +在本期开源新闻综述中,我们将介绍一个开源仿生腿、一个新的开源医学影像组织,麦肯锡发布的首个开源软件,以及更多! + +### 使用开源推进仿生学 + +我们这一代人从电视剧《六百万美元人》和《仿生女人》中学到了仿生学一词。让科幻小说(尽管基于事实)正在成为现实的,要归功于[由密歇根大学和 Shirley Ryan AbilityLab 设计][2]的假肢。 + +该腿采用简单、低成本的模块化设计,“旨在通过为仿生学领域的零碎研究工作提供统一的平台,提高患者的生活质量并加速科学进步”。根据首席设计师 Elliot Rouse 的说法,它将“使研究人员能够有效地解决与一系列的实验室和社区活动中控制仿生腿相关的挑战。” + +你可以从[开源腿][3]网站了解有该腿的更多信息并下载该设计。 + +### 麦肯锡发布了一个用于构建产品级数据管道的 Python 库 + +咨询巨头麦肯锡公司最近发布了其[第一个开源工具][4],名为 Kedro,它是一个用于创建机器学习和数据管道的 Python 库。 + +Kedro 使得“管理大型工作流程更加容易,并确保整个项目的代码质量始终如一”,产品经理 Yetunde Dada 说。虽然它最初是作为一种专有的工具,但麦肯锡开源了 Kedro,因此“客户可以在我们离开项目后使用它 —— 这是我们回馈的方式,”工程师 Nikolaos Tsaousis 说。 + +如果你有兴趣了解一下,可以从 GitHub 上获取 [Kedro 的源代码][5]。 + +### 新联盟推进开源医学成像 + +一组专家和患者倡导者聚集在一起组成了[开源成像联盟][6]。该联盟旨在“通过数字成像和机器学习帮助推进特发性肺纤维化和其他间质性肺病的诊断。” + +根据联盟执行董事 Elizabeth Estes 的说法,该项目旨在“协作加速诊断,帮助预后处置,最终让医生更有效地治疗患者”。为此,他们正在组织和分享“来自患者的 15,000 个匿名图像扫描和临床数据,这将作为机器学习程序的输入数据来开发算法。” + +### Mozilla 发布了一种简单易用的方法,以确定你是否遭受过数据泄露 + +向不那么精通软件的人解释安全性始终是一项挑战,无论你的技能水平如何,都很难监控你的风险。Mozilla 发布了 [Firefox Monitor][7],其数据由 [Have I Been Pwned][8] 提供,它是一种查看你的任何电子邮件是否出现在重大数据泄露事件中的简单方式。你可以输入电子邮件逐个搜索,或注册他们的服务以便将来通知你。 + +该网站还提供了大量有用的教程,用于了解黑客如何做的,数据泄露后如何处理以及如何创建强密码。请务必将网站加入书签,以防家人要求你在假日期间提供建议。 + +### 其它新闻 + +* [想要一款去谷歌化的 Android?把你的手机发送给这个人][9] +* [CockroachDB 发行版使用了非 OSI 批准的许可证,但仍然保持开源][10] +* [基础设施自动化公司 Chef 承诺开源][11] +* [俄罗斯的 Windows 替代品将获得安全升级][12] +* [使用此代码在几分钟内从 Medium 切换到你自己的博客][13] +* [开源推进联盟宣布与台湾自由软件协会建立新合作伙伴关系][14] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/news-june-8 + +作者:[Scott Nesbitt][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/scottnesbitt +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/weekly_news_roundup_tv.png?itok=B6PM4S1i +[2]: https://news.umich.edu/open-source-bionic-leg-first-of-its-kind-platform-aims-to-rapidly-advance-prosthetics/ +[3]: https://opensourceleg.com/ +[4]: https://www.information-age.com/kedro-mckinseys-open-source-software-tool-123482991/ +[5]: https://github.com/quantumblacklabs/kedro +[6]: https://pulmonaryfibrosisnews.com/2019/05/31/international-open-source-imaging-consortium-osic-launched-to-advance-ipf-diagnosis/ +[7]: https://monitor.firefox.com/ +[8]: https://haveibeenpwned.com/ +[9]: https://fossbytes.com/want-a-google-free-android-send-your-phone-to-this-guy/ +[10]: https://www.cockroachlabs.com/blog/oss-relicensing-cockroachdb/ +[11]: https://www.infoq.com/news/2019/05/chef-open-source/ +[12]: https://www.nextgov.com/cybersecurity/2019/05/russias-would-be-windows-replacement-gets-security-upgrade/157330/ +[13]: https://github.com/mathieudutour/medium-to-own-blog +[14]: https://opensource.org/node/994 diff --git a/published/201906/20190610 Applications for writing Markdown.md b/published/201906/20190610 Applications for writing Markdown.md new file mode 100644 index 0000000000..0c7477e7fb --- /dev/null +++ b/published/201906/20190610 Applications for writing Markdown.md @@ -0,0 +1,76 @@ +[#]: collector: (lujun9972) +[#]: translator: (murphyzhao) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11027-1.html) +[#]: subject: (Applications for writing Markdown) +[#]: via: (https://fedoramagazine.org/applications-for-writing-markdown/) +[#]: author: (Ryan Lerch https://fedoramagazine.org/author/ryanlerch/) + +三个在 Fedora 平台上撰写 Markdown 的软件 +====== + +![][1] + +Markdown 是一种轻量级标记语言,可以在添加格式后以纯文本格式查看时依然保持可读性。Markdown(和 Markdown 衍生物)被广泛用作 GitHub 和 pagure 等服务上格式化文档的主要形式。根据其设计,可以在文本编辑器中轻松创建和编辑 Markdown,但是,有许多编辑器可以提供 Markdown 标记的格式化预览,或提供 Markdown 语法高亮显示。 + +本文介绍了针对 Fedora 平台的 3 个桌面应用程序,以帮助编辑 Markdown。 + +### UberWriter + +[UberWriter][2] 是一个小巧的 Markdown 编辑器和预览器,允许你以文本方式编辑,并预览渲染的文档。 + +![][3] + +该编辑器本身具有内置的内联预览,因此标记为粗体的文本以粗体显示。编辑器还提供图像、公式、脚注等标记的内联预览。按住 `Ctrl` 键单击其中的一个标记可以即时预览要显示的元素。 + +除了编辑器功能外,UberWriter 还具有全屏模式和聚焦模式,有助于最大限度地减少干扰。焦点模式将以灰色显示除当前段落以外的所有内容,以帮助你专注于文档中当前元素。 + +从第三方 Flathub 存储库安装 UberWriter 到 Fedora 平台。在将系统[设置为从 Flathub 安装][4]后,可以直接从 Software 应用程序中安装它。 + +### Marker + +Marker 是一个 Markdown 编辑器,它提供了一个简单的文本编辑器来编写 Markdown,并提供渲染文档的实时预览。界面采用分屏设计,左侧为编辑器,右侧为实时预览。 + +![][5] + +此外,Marker 允许你以各种格式导出文档,包括 HTML、PDF 和开放文档格式(ODF)。 + +从第三方 Flathub 存储库安装 Marker 到 Fedora 平台。在将系统[设置为从 Flathub 安装][4]后,可以直接从 Software 应用程序中安装它。 + +### Ghostwriter + +以前的编辑更专注于最小的用户体验,Ghostwriter 提供了更多的功能和选项。Ghostwriter 提供了一个文本编辑器,当你以 Markdown 格式书写时,编辑器将 Markdown 部分样式化。粗体标记文本显示为粗体,标题标记显示为较大的字体,以帮助编写 Markdown 标记。 + +![][6] + +它还提供了一个分屏,包含渲染文档的实时更新预览。 + +![][7] + +Ghostwriter 还包括一系列其他功能,包括能够选择渲染预览的 Markdown 风格,以及用于渲染预览的样式表。 + +此外,它还提供了一个格式菜单(和键盘快捷键)来插入一些频繁的 Markdown 标记,如粗体、项目符号和斜体。 + +从第三方 Flathub 存储库安装 Ghostwriter 到 Fedora 平台。在将系统[设置为从 Flathub 安装][4]后,可以直接从 Software 应用程序中安装它。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/applications-for-writing-markdown/ + +作者:[Ryan Lerch][a] +选题:[lujun9972][b] +译者:[murphyzhao](https://github.com/murphyzhao) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/ryanlerch/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/06/markdownapps.png-816x345.jpg +[2]: https://uberwriter.github.io/uberwriter/#1 +[3]: https://fedoramagazine.org/wp-content/uploads/2019/06/uberwriter-editor-1.png +[4]: https://fedoramagazine.org/install-flathub-apps-fedora/ +[5]: https://fedoramagazine.org/wp-content/uploads/2019/06/marker-screenshot-1024x500.png +[6]: https://fedoramagazine.org/wp-content/uploads/2019/06/ghostwriter-1024x732.png +[7]: https://fedoramagazine.org/wp-content/uploads/2019/06/ghostwriter2-1024x566.png diff --git a/published/201906/20190610 Expand And Unexpand Commands Tutorial With Examples.md b/published/201906/20190610 Expand And Unexpand Commands Tutorial With Examples.md new file mode 100644 index 0000000000..38d9c91ba4 --- /dev/null +++ b/published/201906/20190610 Expand And Unexpand Commands Tutorial With Examples.md @@ -0,0 +1,146 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10983-1.html) +[#]: subject: (Expand And Unexpand Commands Tutorial With Examples) +[#]: via: (https://www.ostechnix.com/expand-and-unexpand-commands-tutorial-with-examples/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +expand 与 unexpand 命令实例教程 +====== + +![Expand And Unexpand Commands Explained][1] + +本指南通过实际的例子解释两个 Linux 命令,即 `expand` 和 `unexpand`。对于好奇的人,`expand` 和 `unexpand` 命令用于将文件中的 `TAB` 字符替换为空格,反之亦然。在 MS-DOS 中也有一个名为 `expand` 的命令,它用于解压压缩文件。但 Linux 的 `expand` 命令只是将 `TAB` 转换为空格。这两个命令是 GNU coreutils 包的一部分,由 David MacKenzie 编写。 + +为了演示,我将在本文使用名为 `ostechnix.txt` 的文本文件。下面给出的所有命令都在 Arch Linux 中进行测试。 + +### expand 命令示例 + +与我之前提到的一样,`expand` 命令使用空格替换文件中的 `TAB` 字符。 + +现在,让我们将 `ostechnix.txt` 中的 `TAB` 转换为空格,并将结果写入标准输出: + +``` +$ expand ostechnix.txt +``` + +如果你不想在标准输出中显示结果,只需将其写入另一个文件,如下所示。 + +``` +$ expand ostechnix.txt>output.txt +``` + +我们还可以将标准输入中的 `TAB` 转换为空格。为此,只需运行 `expand` 命令而不带文件名: + +``` +$ expand +``` + +只需输入文本并按回车键就能将 `TAB` 转换为空格。按 `CTRL+C` 退出。 + +如果你不想转换非空白字符后的 `TAB`,请使用 `-i` 标记,如下所示。 + +``` +$ expand -i ostechnix.txt +``` + +我们还可以设置每个 `TAB` 为指定数字的宽度,而不是 `8`(默认值)。 + +``` +$ expand -t=5 ostechnix.txt +``` + +我们甚至可以使用逗号分隔指定多个 `TAB` 位置,如下所示。 + +``` +$ expand -t 5,10,15 ostechnix.txt +``` + +或者, + +``` +$ expand -t "5 10 15" ostechnix.txt +``` + +有关更多详细信息,请参阅手册页。 + +``` +$ man expand +``` + +### unexpand 命令示例 + +正如你可能已经猜到的那样,`unexpand` 命令将执行与 `expand` 命令相反的操作。即它会将空格转换为 `TAB`。让我向你展示一些例子,以了解如何使用 `unexpand` 命令。 + +要将文件中的空白(当然是空格)转换为 `TAB` 并将输出写入标准输出,请执行以下操作: + +``` +$ unexpand ostechnix.txt +``` + +如果要将输出写入文件而不是仅将其显示到标准输出,请使用以下命令: + +``` +$ unexpand ostechnix.txt>output.txt +``` + +从标准输出读取内容,将空格转换为制表符: + +``` +$ unexpand +``` + +默认情况下,`unexpand` 命令仅转换初始的空格。如果你想转换所有空格而不是只是一行开头的空格,请使用 `-a` 标志: + +``` +$ unexpand -a ostechnix.txt +``` + +仅转换一行开头的空格(请注意它会覆盖 `-a`): + +``` +$ unexpand --first-only ostechnix.txt +``` + +使多少个空格替换成一个 `TAB`,而不是 `8`(会启用 `-a`): + +``` +$ unexpand -t 5 ostechnix.txt +``` + +相似地,我们可以使用逗号分隔指定多个 `TAB` 的位置。 + +``` +$ unexpand -t 5,10,15 ostechnix.txt +``` + +或者, + +``` +$ unexpand -t "5 10 15" ostechnix.txt +``` + +有关更多详细信息,请参阅手册页。 + +``` +$ man unexpand +``` + +在处理大量文件时,`expand` 和 `unexpand` 命令对于用空格替换不需要的 `TAB` 时非常有用,反之亦然。 + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/expand-and-unexpand-commands-tutorial-with-examples/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/05/Expand-And-Unexpand-Commands-720x340.png diff --git a/published/201906/20190610 Graviton- A Minimalist Open Source Code Editor.md b/published/201906/20190610 Graviton- A Minimalist Open Source Code Editor.md new file mode 100644 index 0000000000..395f0f5687 --- /dev/null +++ b/published/201906/20190610 Graviton- A Minimalist Open Source Code Editor.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10988-1.html) +[#]: subject: (Graviton: A Minimalist Open Source Code Editor) +[#]: via: (https://itsfoss.com/graviton-code-editor/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Graviton:极简的开源代码编辑器 +====== + +[Graviton][1]是一款开发中的自由开源的跨平台代码编辑器。他的开发者 16 岁的 Marc Espin 强调说,它是一个“极简”的代码编辑器。我不确定这点,但它确实有一个清爽的用户界面,就像其他的[现代代码编辑器,如 Atom][2]。 + +![Graviton Code Editor Interface][3] + +开发者还将其称为轻量级代码编辑器,尽管 Graviton 基于 [Electron][4]。 + +Graviton 拥有你在任何标准代码编辑器中所期望的功能,如语法高亮、自动补全等。由于 Graviton 仍处于测试阶段,因此未来版本中将添加更多功能。 + +![Graviton Code Editor with Syntax Highlighting][5] + +### Graviton 代码编辑器的特性 + +Graviton 一些值得一说的特性有: + + * 使用 [CodeMirrorJS][6] 为多种编程语言提供语法高亮 +  * 自动补全 +  * 支持插件和主题。 +  * 提供英语、西班牙语和一些其他欧洲语言。 +  * 适用于 Linux、Windows 和 macOS。 + +我快速看来一下 Graviton,它可能不像 [VS Code][7] 或 [Brackets][8] 那样功能丰富,但对于一些简单的代码编辑来说,它还算不错的工具。 + +### 下载并安装 Graviton + +![Graviton Code Editor][9] + +如上所述,Graviton 是一个可用于 Linux、Windows 和 macOS 的跨平台代码编辑器。它仍处于测试阶段,这意味着将来会添加更多功能,并且你可能会遇到一些 bug。 + +你可以在其发布页面上找到最新版本的 Graviton。Debian 和 [Ubuntu 用户可以使用 .deb 安装][10]。它已提供 [AppImage][11],以便可以在其他发行版中使用它。DMG 和 EXE 文件也分别可用于 macOS 和 Windows。 + +- [下载 Graviton][12] + +如果你有兴趣,你可以在 GitHub 仓库中找到 Graviton 的源代码: + +- [GitHub 中 Graviton 的源码][13] + +如果你决定使用 Graviton 并发现了一些问题,请在[此处][14]写一份错误报告。如果你使用 GitHub,你可能想为 Graviton 项目加星。这可以提高开发者的士气,因为他知道有更多的用户欣赏他的努力。 + +如果你看到现在,我相信你了解[如何从源码安装软件][16] + +### 写在最后 + +有时,简单本身就成了一个特性,而 Graviton 专注于极简可以帮助它在已经拥挤的代码编辑器世界中获取一席之地。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/graviton-code-editor/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://graviton.ml/ +[2]: https://itsfoss.com/best-modern-open-source-code-editors-for-linux/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/graviton-code-editor-interface.jpg?resize=800%2C571&ssl=1 +[4]: https://electronjs.org/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/graviton-code-editor-interface-2.jpg?resize=800%2C522&ssl=1 +[6]: https://codemirror.net/ +[7]: https://itsfoss.com/install-visual-studio-code-ubuntu/ +[8]: https://itsfoss.com/install-brackets-ubuntu/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/graviton-code-editor-800x473.jpg?resize=800%2C473&ssl=1 +[10]: https://itsfoss.com/install-deb-files-ubuntu/ +[11]: https://itsfoss.com/use-appimage-linux/ +[12]: https://github.com/Graviton-Code-Editor/Graviton-App/releases +[13]: https://github.com/Graviton-Code-Editor/Graviton-App +[14]: https://github.com/Graviton-Code-Editor/Graviton-App/issues +[16]: https://itsfoss.com/install-software-from-source-code/ +[17]: https://itsfoss.com/contact-us/ diff --git a/published/201906/20190610 Neofetch - Display Linux system Information In Terminal.md b/published/201906/20190610 Neofetch - Display Linux system Information In Terminal.md new file mode 100644 index 0000000000..006ca80113 --- /dev/null +++ b/published/201906/20190610 Neofetch - Display Linux system Information In Terminal.md @@ -0,0 +1,216 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10991-1.html) +[#]: subject: (Neofetch – Display Linux system Information In Terminal) +[#]: via: (https://www.ostechnix.com/neofetch-display-linux-systems-information/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +Neofetch:在终端中显示 Linux 系统信息 +====== + +![Display Linux system information using Neofetch][1] + +Neofetch 是一个简单但有用的命令行系统信息工具,它用 Bash 编写。它会收集有关系统软硬件的信息,并在终端中显示结果。默认情况下,系统信息将与操作系统的 logo 一起显示。但是,你可以进一步地自定义使用 ascii 图像或其他任何图片。你还可以配置 Neofetch 显示的信息、信息的显示位置和时间。Neofetch 主要用于系统信息的截图。它支持 Linux、BSD、Mac OS X、iOS 和 Windows 操作系统。在这个简短的教程中,让我们看看如何使用 Neofetch 显示 Linux 系统信息。 + +### 安装 Neofetch + +Neofetch 可在大多数 Linux 发行版的默认仓库中找到。 + +在 Arch Linux 及其衍生版上,使用这个命令安装它: + +``` +$ sudo pacman -S netofetch +``` + +在 Debian(Stretch / Sid)上: + +``` +$ sudo apt-get install neofetch +``` + +在 Fedora 27 上: + +``` +$ sudo dnf install neofetch +``` + +在 RHEL、CentOS 上: + +启用 EPEL 仓库: + +``` +# yum install epel-relase +``` + +获取 neofetch 仓库: + +``` +# curl -o /etc/yum.repos.d/konimex-neofetch-epel-7.repo +https://copr.fedorainfracloud.org/coprs/konimex/neofetch/repo/epel-7/konimex-neofetch-epel-7.repo +``` + +然后,安装 Neofetch: + +``` +# yum install neofetch +``` + +在 Ubuntu 17.10 和更新版本上: + +``` +$ sudo apt-get install neofetch +``` + +在 Ubuntu 16.10 和更低版本上: + +``` +$ sudo add-apt-repository ppa:dawidd0811/neofetch + +$ sudo apt update + +$ sudo apt install neofetch +``` + +在 NixOS 上: + +``` +$ nix-env -i neofetch +``` + +### 使用 Neofetch 显示 Linux 系统信息 + +Neofetch 非常简单直接。让我们看一些例子。 + +打开终端,然后运行以下命令: + +``` +$ neofetch +``` + +示例输出: + +![][2] + +*使用 Neofetch 显示 Linux 系统信息* + +正如你在上面的输出中所看到的,Neofetch 显示了我的 Arch Linux 系统的以下详细信息: + +* 已安装操作系统的名称, +* 笔记本型号, +* 内核详细信息, +* 系统运行时间, +* 默认和其他软件包管理器安装的软件数量 +* 默认 shell, +* 屏幕分辨率, +* 桌面环境, +* 窗口管理器, +* 窗口管理器的主题, +* 系统主题, +* 系统图标, +* 默认终端, +* CPU 类型, +* GPU 类型, +* 已安装的内存。 + +Neofetch 还有很多其他选项。我们会看到其中一些。 + +### 如何在 Neofetch 输出中使用自定义图像? + +默认情况下,Neofetch 将显示你的操作系统 logo 以及系统信息。当然,你可以根据需要更改图像。 + +要显示图像,Linux 系统应该安装以下依赖项: + +1. w3m-img(用于显示图像。w3m-img 有时与 w3m 包捆绑在一起), +2. Imagemagick(用于创建缩略图), +3. 支持 `\033[14t` 或者 xdotool 或者 xwininfo + xprop 或者 xwininfo + xdpyinfo 的终端。 + +大多数 Linux 发行版的默认仓库中都提供了 W3m-img 和 ImageMagick 包。因此,你可以使用你的发行版的默认包管理器来安装它们。 + +例如,运行以下命令在 Debian、Ubuntu、Linux Mint 上安装 w3m-img 和 ImageMagick: + +``` +$ sudo apt install w3m-img imagemagick +``` + +以下是带 w3m-img 支持的终端列表: + + 1. Gnome-terminal, + 2. Konsole, + 3. st, + 4. Terminator, + 5. Termite, + 6. URxvt, + 7. Xfce4-Terminal, + 8. Xterm + +如果你的系统上已经有了 kitty、Terminology 和 iTerm,那么就无需安装 w3m-img。 + +现在,运行以下命令以使用自定义图像显示系统信息: + +``` +$ neofetch --w3m /home/sk/Pictures/image.png +``` + +或者, + +``` +$ neofetch --w3m --source /home/sk/Pictures/image.png +``` + +示例输出: + +![][3] + +*使用自定义 logo 的 Neofetch 输出* + +使用你自己的图片替换上面图片的路径。 + +或者,你可以指向包含以下图像的目录。 + +``` +$ neofetch --w3m +``` + +### 配置 Neofetch + +当我们第一次运行 Neofetch 时,它默认会为每个用户在 `$HOME/.config/neofetch/config.conf` 中创建一个配置文件。它还会在 `$HOME/.config/neofetch/config` 中创建一个全局的 neofetch 配置文件。你可以调整此文件来告诉 neofetch 该显示、删除和/或修改哪些详细信息。 + +还可以在不同版本中保留此配置文件。这意味着你只需根据自己的喜好自定义一次,并在升级到更新版本后使用相同的设置。你甚至可以将此文件共享给你的朋友和同事,使他拥有与你相同的设置。 + +要查看 Neofetch 帮助部分,请运行: + +``` +$ neofetch --help +``` + +就我测试的 Neofetch 而言,它在我的 Arch Linux 系统中完美地工作。它是一个非常方便的工具,可以在终端中轻松快速地打印系统的详细信息。 + +相关阅读: + + * [如何使用 inxi 查看 Linux 系统详细信息][4] + +资源: + + * [Neofetch 的 GitHub 页面][5] + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/neofetch-display-linux-systems-information/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2016/06/neofetch-1-720x340.png +[2]: http://www.ostechnix.com/wp-content/uploads/2016/06/Neofetch-1.png +[3]: http://www.ostechnix.com/wp-content/uploads/2016/06/Neofetch-with-custom-logo.png +[4]: https://www.ostechnix.com/how-to-find-your-system-details-using-inxi/ +[5]: https://github.com/dylanaraps/neofetch diff --git a/published/201906/20190610 Screen Command Examples To Manage Multiple Terminal Sessions.md b/published/201906/20190610 Screen Command Examples To Manage Multiple Terminal Sessions.md new file mode 100644 index 0000000000..936974a5d2 --- /dev/null +++ b/published/201906/20190610 Screen Command Examples To Manage Multiple Terminal Sessions.md @@ -0,0 +1,282 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10962-1.html) +[#]: subject: (Screen Command Examples To Manage Multiple Terminal Sessions) +[#]: via: (https://www.ostechnix.com/screen-command-examples-to-manage-multiple-terminal-sessions/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +screen 命令示例:管理多个终端会话 +====== + +![Screen Command Examples To Manage Multiple Terminal Sessions](https://img.linux.net.cn/data/attachment/album/201906/11/124801th0uy0hti3y211ha.jpg) + +GNU Screen 是一个终端多路复用器(窗口管理器)。顾名思义,Screen 可以在多个交互式 shell 之间复用物理终端,因此我们可以在每个终端会话中执行不同的任务。所有的 Screen 会话都完全独立地运行程序。因此,即使会话意外关闭或断开连接,在 Screen 会话内运行的程序或进程也将继续运行。例如,当通过 SSH [升级 Ubuntu][2] 服务器时,`screen` 命令将继续运行升级过程,以防万一 SSH 会话因任何原因而终止。 + +GNU Screen 允许我们轻松创建多个 Screen 会话,在不同会话之间切换,在会话之间复制文本,随时连上或脱离会话等等。它是每个 Linux 管理员应该在必要时学习和使用的重要命令行工具之一。在本简要指南中,我们将看到 `screen` 命令的基本用法以及在 Linux 中的示例。 + +### 安装 GNU Screen + +GNU Screen 在大多数 Linux 操作系统的默认存储库中都可用。 + +要在 Arch Linux 上安装 GNU Screen,请运行: + +``` +$ sudo pacman -S screen +``` + +在 Debian、Ubuntu、Linux Mint 上: + +``` +$ sudo apt-get install screen +``` + +在 Fedora 上: + +``` +$ sudo dnf install screen +``` + +在 RHEL、CentOS 上: + +``` +$ sudo yum install screen +``` + +在 SUSE/openSUSE 上: + +``` +$ sudo zypper install screen +``` + +让我们继续看一些 `screen` 命令示例。 + +### 管理多个终端会话的 Screen 命令示例 + +在 Screen 中所有命令的默认前缀快捷方式是 `Ctrl + a`。使用 Screen 时,你需要经常使用此快捷方式。所以,要记住这个键盘快捷键。 + +#### 创建新的 Screen 会话 + +让我们创建一个新的 Screen 会话并连上它。为此,请在终端中键入以下命令: + +``` +screen +``` + +现在,在此会话中运行任何程序或进程,即使你与此会话断开连接,正在运行的进程或程序也将继续运行。 + +#### 从 Screen 会话脱离 + +要从屏幕会话中脱离,请按 `Ctrl + a` 和 `d`。你无需同时按下两个组合键。首先按 `Ctrl + a` 然后按 `d`。从会话中脱离后,你将看到类似下面的输出。 + +``` +[detached from 29149.pts-0.sk] +``` + +这里,`29149` 是 Screen ID,`pts-0.sk` 是屏幕会话的名称。你可以使用 Screen ID 或相应的会话名称来连上、脱离和终止屏幕会话。 + +#### 创建命名会话 + +你还可以用你选择的任何自定义名称创建一个 Screen 会话,而不是默认用户名,如下所示。 + +``` +screen -S ostechnix +``` + +上面的命令将创建一个名为 `xxxxx.ostechnix` 的新 Screen 会话,并立即连上它。要从当前会话中脱离,请按 `Ctrl + a`,然后按 `d`。 + +当你想要查找哪些进程在哪些会话上运行时,命名会话会很有用。例如,当在会话中设置 LAMP 系统时,你可以简单地将其命名为如下所示。 + +``` +screen -S lampstack +``` + +#### 创建脱离的会话 + +有时,你可能想要创建一个会话,但不希望自动连上该会话。在这种情况下,运行以下命令来创建名为`senthil` 的已脱离会话: + +``` +screen -S senthil -d -m +``` + +也可以缩短为: + +``` +screen -dmS senthil +``` + +上面的命令将创建一个名为 `senthil` 的会话,但不会连上它。 + +#### 列出屏幕会话 + +要列出所有正在运行的会话(连上的或脱离的),请运行: + +``` +screen -ls +``` + +示例输出: + +``` +There are screens on: + 29700.senthil (Detached) + 29415.ostechnix (Detached) + 29149.pts-0.sk (Detached) +3 Sockets in /run/screens/S-sk. +``` + +如你所见,我有三个正在运行的会话,并且所有会话都已脱离。 + +#### 连上 Screen 会话 + +如果你想连上会话,例如 `29415.ostechnix`,只需运行: + +``` +screen -r 29415.ostechnix +``` + +或: + +``` +screen -r ostechnix +``` + +或使用 Screen ID: + +``` +screen -r 29415 +``` + +要验证我们是否连上到上述会话,只需列出打开的会话并检查。 + +``` +screen -ls +``` + +示例输出: + +``` +There are screens on: + 29700.senthil (Detached) + 29415.ostechnix (Attached) + 29149.pts-0.sk (Detached) +3 Sockets in /run/screens/S-sk. +``` + +如你所见,在上面的输出中,我们目前已连上到 `29415.ostechnix` 会话。要退出当前会话,请按 `ctrl + a d`。 + +#### 创建嵌套会话 + +当我们运行 `screen` 命令时,它将为我们创建一个会话。但是,我们可以创建嵌套会话(会话内的会话)。 + +首先,创建一个新会话或连上已打开的会话。然后我将创建一个名为 `nested` 的新会话。 + +``` +screen -S nested +``` + +现在,在会话中按 `Ctrl + a` 和 `c` 创建另一个会话。只需重复此操作即可创建任意数量的嵌套 Screen 会话。每个会话都将分配一个号码。号码将从 `0` 开始。 + +你可以按 `Ctrl + n` 移动到下一个会话,然后按 `Ctrl + p` 移动到上一个会话。 + +以下是管理嵌套会话的重要键盘快捷键列表。 + +* `Ctrl + a "` - 列出所有会话 +* `Ctrl + a 0` - 切换到会话号 0 +* `Ctrl + a n` - 切换到下一个会话 +* `Ctrl + a p` - 切换到上一个会话 +* `Ctrl + a S` - 将当前区域水平分割为两个区域 +* `Ctrl + a l` - 将当前区域垂直分割为两个区域 +* `Ctrl + a Q` - 关闭除当前会话之外的所有会话 +* `Ctrl + a X` - 关闭当前会话 +* `Ctrl + a \` - 终止所有会话并终止 Screen +* `Ctrl + a ?` - 显示键绑定。要退出,请按回车 +   +#### 锁定会话 + +Screen 有一个锁定会话的选项。为此,请按 `Ctrl + a` 和 `x`。 输入你的 Linux 密码以锁定。 + +``` +Screen used by sk on ubuntuserver. +Password: +``` + +#### 记录会话 + +你可能希望记录 Screen 会话中的所有内容。为此,只需按 `Ctrl + a` 和 `H` 即可。 + +或者,你也可以使用 `-L` 参数启动新会话来启用日志记录。 + +``` +screen -L +``` + +从现在开始,你在会话中做的所有活动都将记录并存储在 `$HOME` 目录中名为 `screenlog.x` 的文件中。这里,`x` 是一个数字。 + +你可以使用 `cat` 命令或任何文本查看器查看日志文件的内容。 + +![][3] + +*记录 Screen 会话* + +#### 终止 Screen 会话 + +如果不再需要会话,只需杀死它。要杀死名为 `senthil` 的脱离会话: + +``` +screen -r senthil -X quit +``` + +或: + +``` +screen -X -S senthil quit +``` + +或: + +``` +screen -X -S 29415 quit +``` + +如果没有打开的会话,你将看到以下输出: + +``` +$ screen -ls +No Sockets found in /run/screens/S-sk. +``` + +更多细节请参照 man 手册页: + +``` +$ man screen +``` + +还有一个名为 Tmux 的类似的命令行实用程序,它与 GNU Screen 执行相同的工作。要了解更多信息,请参阅以下指南。 + +* [Tmux 命令示例:管理多个终端会话][5] + +### 资源 + + * [GNU Screen 主页][6] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/screen-command-examples-to-manage-multiple-terminal-sessions/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/06/Screen-Command-Examples-720x340.jpg +[2]: https://www.ostechnix.com/how-to-upgrade-to-ubuntu-18-04-lts-desktop-and-server/ +[3]: https://www.ostechnix.com/wp-content/uploads/2019/06/Log-screen-sessions.png +[4]: https://www.ostechnix.com/record-everything-terminal/ +[5]: https://www.ostechnix.com/tmux-command-examples-to-manage-multiple-terminal-sessions/ +[6]: https://www.gnu.org/software/screen/ diff --git a/published/201906/20190610 Search Linux Applications On AppImage, Flathub And Snapcraft Platforms.md b/published/201906/20190610 Search Linux Applications On AppImage, Flathub And Snapcraft Platforms.md new file mode 100644 index 0000000000..0ba4d3469b --- /dev/null +++ b/published/201906/20190610 Search Linux Applications On AppImage, Flathub And Snapcraft Platforms.md @@ -0,0 +1,90 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10994-1.html) +[#]: subject: (Search Linux Applications On AppImage, Flathub And Snapcraft Platforms) +[#]: via: (https://www.ostechnix.com/search-linux-applications-on-appimage-flathub-and-snapcraft-platforms/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +在 AppImage、Flathub 和 Snapcraft 平台上搜索 Linux 应用 +====== + +![Search Linux Applications On AppImage, Flathub And Snapcraft][1] + +Linux 一直在发展。过去,开发人员必须分别为不同的 Linux 发行版构建应用。由于存在多种 Linux 变体,因此为所有发行版构建应用变得很繁琐,而且非常耗时。后来一些开发人员发明了包转换器和构建器,如 [Checkinstall][2]、[Debtap][3] 和 [Fpm][4]。但他们也没有完全解决问题。所有这些工具都只是将一种包格式转换为另一种包格式。我们仍然需要找到应用并安装运行所需的依赖项。 + +好吧,时代已经变了。我们现在有了通用的 Linux 应用。这意味着我们可以在大多数 Linux 发行版上安装这些应用。无论是 Arch Linux、Debian、CentOS、Redhat、Ubuntu 还是任何流行的 Linux 发行版,通用应用都可以正常使用。这些应用与所有必需的库和依赖项打包在一个包中。我们所要做的就是在我们使用的任何 Linux 发行版上下载并运行它们。流行的通用应用格式有 AppImage、[Flatpak][5] 和 [Snap][6]。 + +AppImage 由 Simon peter 创建和维护。许多流行的应用,如 Gimp、Firefox、Krita 等等,都有这些格式,并可直接在下载页面下载。只需下载它们,使其可执行并立即运行它。你甚至无需 root 权限来运行 AppImage。 + +Flatpak 的开发人员是 Alexander Larsson(RedHat 员工)。Flatpak 应用托管在名为 “Flathub” 的中央仓库(商店)中。如果你是开发人员,建议你使用 Flatpak 格式构建应用,并通过 Flathub 将其分发给用户。 + +Snap 由 Canonical 而建,主要用于 Ubuntu。但是,其他 Linux 发行版的开发人员开始为 Snap 打包格式做出贡献。因此,Snap 也开始适用于其他 Linux 发行版。Snap 可以直接从应用的下载页面下载,也可以从 Snapcraft 商店下载。 + +许多受欢迎的公司和开发人员已经发布了 AppImage、Flatpak 和 Snap 格式的应用。如果你在寻找一款应用,只需进入相应的商店并获取你选择的应用并运行它,而不用管你使用何种 Linux 发行版。 + +还有一个名为 “Chob” 的命令行通用应用搜索工具可在 AppImage、Flathub 和 Snapcraft 平台上轻松搜索 Linux 应用。此工具仅搜索给定的应用并在默认浏览器中显示官方链接。它不会安装它们。本指南将解释如何安装 Chob 并使用它来搜索 Linux 上的 AppImage、Flatpak 和 Snap。 + +### 使用 Chob 在 AppImage、Flathub 和 Snapcraft 平台上搜索 Linux 应用 + +从[发布页面][7]下载最新的 Chob 二进制文件。在编写本指南时,最新版本为 0.3.5。 + +``` +$ wget https://github.com/MuhammedKpln/chob/releases/download/0.3.5/chob-linux +``` + +使其可执行: + +``` +$ chmod +x chob-linux +``` + +最后,搜索你想要的应用。例如,我将搜索与 Vim 相关的应用。 + +``` +$ ./chob-linux vim +``` + +Chob 将在 AppImage、Flathub 和 Snapcraft 平台上搜索给定的应用(和相关应用)并显示结果。 + +![][8] + +*使用 Chob 搜索 Linux 应用* + +只需要输入你想要应用前面的数字就可在默认浏览器中打开它的官方链接,并可在其中阅读应用的详细信息。 + +![][9] + +在浏览器中查看 Linux 应用的详细信息 + +有关更多详细信息,请查看下面的 Chob 官方 GitHub 页面。 + +资源: + + * [Chob 的 GitHub 仓库][10] + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/search-linux-applications-on-appimage-flathub-and-snapcraft-platforms/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/05/chob-720x340.png +[2]: https://www.ostechnix.com/build-packages-source-using-checkinstall/ +[3]: https://www.ostechnix.com/convert-deb-packages-arch-linux-packages/ +[4]: https://www.ostechnix.com/build-linux-packages-multiple-platforms-easily/ +[5]: https://www.ostechnix.com/flatpak-new-framework-desktop-applications-linux/ +[6]: https://www.ostechnix.com/introduction-ubuntus-snap-packages/ +[7]: https://github.com/MuhammedKpln/chob/releases +[8]: http://www.ostechnix.com/wp-content/uploads/2019/05/Search-Linux-applications-Using-Chob.png +[9]: http://www.ostechnix.com/wp-content/uploads/2019/05/View-Linux-applications-Details.png +[10]: https://github.com/MuhammedKpln/chob diff --git a/published/201906/20190610 Try a new game on Free RPG Day.md b/published/201906/20190610 Try a new game on Free RPG Day.md new file mode 100644 index 0000000000..64e95e2ac3 --- /dev/null +++ b/published/201906/20190610 Try a new game on Free RPG Day.md @@ -0,0 +1,84 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10976-1.html) +[#]: subject: (Try a new game on Free RPG Day) +[#]: via: (https://opensource.com/article/19/5/free-rpg-day) +[#]: author: (Seth Kenlon https://opensource.com/users/seth/users/erez/users/seth) + +在免费 RPG 日试玩一下新游戏 +====== + +> 6 月 15 日,你可以在当地的游戏商家庆祝桌面角色扮演游戏并获得免费的 RPG 资料。 + +![plastic game pieces on a board](https://img.linux.net.cn/data/attachment/album/201906/15/103929zqshc08df49dv0c2.jpg) + +(LCTT 译注:“免费 RPG 日Free RPG Day”是受“免费漫画书日Free Comic Book Day”启发而发起的庆祝活动,从 2007 年开始已经举办多次。这里的 RPG 游戏并非我们通常所指的电脑 RPG 游戏,而是指使用纸和笔的桌面游戏,是一种西方传统游戏形式。) + +你有没有想过尝试一下《龙与地下城Dungeons & Dragons》,但不知道如何开始?你是否在年轻时玩过《开拓者Pathfinder》并一直在考虑重返快乐时光?你是否对角色扮演游戏(RPG)感到好奇,但不确定你是否想玩一个?你是否对桌面游戏的概念完全陌生,直到现在才听说过这种 RPG 游戏?无论是哪一个并不重要,因为[免费 RPG 日] [2]适合所有人! + +第一个免费 RPG 日活动发生在 2007 年,是由世界各地的桌面游戏商家举办的。这个想法是以 0 美元的价格为新手和有经验的游戏玩家带来新的、独家的 RPG 快速入门规则和冒险体验。在这样的一天里,你可以走进当地的桌面游戏商家,得到一本小册子,其中包含桌面 RPG 的简单的初学者规则,你可以在商家里与那里的人或者回家与朋友一起玩。这本小册子是给你的,应该一直留着的。 + +这一活动如此的受欢迎,此后该传统一直延续至今。今年,免费 RPG 日定于 6 月 15 日星期六举行。 + +### 有什么收获? + +显然,免费 RPG 日背后的想法是让你沉迷于桌面 RPG 游戏。但在你本能的犬儒主义开始之前,考虑到它会慢慢上瘾,爱上一个鼓励你阅读规则和知识的游戏并不太糟,这样你和你的家人、朋友就有了共度时光的借口了。桌面 RPG 是一个功能强大、富有想象力和有趣的媒介,而免费 RPG 日则是对这种游戏很好的介绍。 + +![FreeRPG Day logo][3] + +### 开源游戏 + +像许多其他行业一样,开源现象影响了桌面游戏。回到世纪之交,《Magic:The Gathering and Dungeons&Dragons》 的提供者[威世智公司][4]Wizards of the Coast决定通过开发[开源游戏许可证][5]Open Game License(OGL)来采用开源方法。他们将此许可证用于世界上第一个 RPG(《龙与地下城Dungeons & Dragons》,D&D)的版本 3 和 3.5。几年后,当他们在第四版上(对开源)产生了动摇时,《Dragon》杂志的出版商复刻了 D&D 3.5 的“代码”,将其混制版本发布为《开拓者Pathfinder》 RPG,从而保持了创新和整个第三方游戏开发者产业的健康发展。最近,威世智公司在 D&D 5e 版本中才又重回了 OGL。 + +OGL 允许开发人员至少可以在他们自己产品中使用该游戏的机制。不管你可以不可以使用自定义怪物、武器、王国或流行角色的名称,但你可以随时使用 OGL 游戏的规则和数学计算。事实上,OGL 游戏的规则通常作为[系统参考文档][6](SRD)免费发布的,因此,无论你是否购买了规则书的副本,你都可以了解游戏的玩法。 + +如果你之前从未玩过桌面 RPG,那么使用笔和纸玩的游戏也可以拥有游戏引擎似乎很奇怪,但计算就是计算,不管是数字的还是模拟的。作为一个简单的例子:假设游戏引擎规定玩家角色有一个代表其力量的数字。当那个玩家角色与一个有其两倍力量的巨人战斗时,在玩家掷骰子以增加她的角色的力量攻击时,真的会感到紧张。如果没有掷出一个很好的点数的话,她的力量将无法与巨人相匹敌。知道了这一点,第三方或独立开发者就可以为这个游戏引擎设计一个怪物,同时了解骰子滚动可能对玩家的能力得分产生的影响。这意味着他们可以根据游戏引擎的优先级进行数学计算。他们可以设计一系列用来杀死的怪物,在游戏引擎的环境中它们具有有意义的能力和技能,并且他们可以宣称与该引擎的兼容性。 + +此外,OGL 允许出版商为其材料定义产品标识。产品标识可以是出版物的商业外观(图形元素和布局)、徽标、术语、传说、专有名称等。未经出版商同意,任何定义为产品标识的内容都可能**无法**重复使用。例如,假设一个出版商发行了一本武器手册,其中包括一个名为 Sigint 的魔法砍刀,它对所有针对僵尸的攻击都给予 +2 魔法附加攻击值。这个特性来自一个故事,该砍刀是一个具有潜伏的僵尸基因的科学家锻造的。但是,该出版物在 OGL 第 1e 节中列出的所有武器的正确名称都被保留为产品标识。这意味着你可以在自己的出版物中使用该数字(武器的持久性、它所造成的伤害,+2 魔法奖励等等)以及与该武器相关的传说(它由一个潜伏的僵尸锻造),但是你不能使用该武器的名称(Sigint)。 + +OGL 是一个非常灵活的许可证,因此开发人员必须仔细阅读其第 1e 节。 一些出版商只保留出版物本身的布局,而其他出版商保留除数字和最通用术语之外的所有内容。 + +当卓越的 RPG 特许经营权拥抱开源时,至今仍能感受到的它给整个行业掀起的波澜。第三方开发人员可以为 5e 和《开拓者》系统创建内容。由威世智公司创建的整个 [DungeonMastersGuild.com][7] 网站为 D&D 5e 制作了独立内容,旨在促进独立出版。[Starfinder][8]、[OpenD6][9]、[战士,盗贼和法师][10]、[剑与巫师][11] 等及很多其它游戏都采用了 OGL。其他系统,如 Brent Newhall 的 《[Dungeon Delvers][12]》、《[Fate][13]》、《[Dungeon World][14]》 等等,都是根据[知识共享许可][15]授权的的。 + +### 获取你的 RPG + +在免费 RPG 日,你可以前往当地游戏商铺,玩 RPG 以及获取与朋友将来一起玩的 RPG 游戏材料。就像[Linux 安装节][16]Linux installfest[软件自由日][17]Software Freedom Day一样,该活动的定义很松散。每个商家举办的自由 RPG 日都有所不同,每个商家都可以玩他们选择的任何游戏。但是,游戏发行商捐赠的免费内容每年都是相同的。显然,免费的东西视情况而定,但是当你参加免费 RPG 日活动时,请注意有多少游戏采用了开源许可证(如果是 OGL 游戏,OGL 会打印在书背面)。《开拓者》、《Starfinder》 和 D&D 的任何内容肯定都会带有 OGL 的一些优势。许多其他系统的内容使用知识共享许可。有些则像 90 年代复活的 [Dead Earth][18] RPG 一样,使用 [GNU 自由文档许可证] [19]。 + +有大量的游戏资源是通过开源许可证开发的。你可能需要也可能不需要关心游戏的许可证;毕竟,许可证与你是否可以与朋友一起玩无关。但是如果你喜欢支持[自由文化][20]而不仅仅是你运行的软件,那么试试一些 OGL 或知识共享游戏吧。如果你不熟悉游戏,请在免费 RPG 日在当地游戏商家试玩桌面 RPG 游戏! + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/free-rpg-day + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth/users/erez/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team-game-play-inclusive-diversity-collaboration.png?itok=8sUXV7W1 (plastic game pieces on a board) +[2]: https://www.freerpgday.com/ +[3]: https://opensource.com/sites/default/files/uploads/freerpgday-logoblank.jpg (FreeRPG Day logo) +[4]: https://company.wizards.com/ +[5]: http://www.opengamingfoundation.org/licenses.html +[6]: https://www.d20pfsrd.com/ +[7]: https://www.dmsguild.com/ +[8]: https://paizo.com/starfinder +[9]: https://ogc.rpglibrary.org/index.php?title=OpenD6 +[10]: http://www.stargazergames.eu/games/warrior-rogue-mage/ +[11]: https://froggodgames.com/frogs/product/swords-wizardry-complete-rulebook/ +[12]: http://brentnewhall.com/games/doku.php?id=games:dungeon_delvers +[13]: http://www.faterpg.com/licensing/licensing-fate-cc-by/ +[14]: http://dungeon-world.com/ +[15]: https://creativecommons.org/ +[16]: https://www.tldp.org/HOWTO/Installfest-HOWTO/introduction.html +[17]: https://www.softwarefreedomday.org/ +[18]: https://mixedsignals.ml/games/blog/blog_dead-earth +[19]: https://www.gnu.org/licenses/fdl-1.3.en.html +[20]: https://opensource.com/article/18/1/creative-commons-real-world diff --git a/published/201906/20190610 Welcoming Blockchain 3.0.md b/published/201906/20190610 Welcoming Blockchain 3.0.md new file mode 100644 index 0000000000..0bd9086504 --- /dev/null +++ b/published/201906/20190610 Welcoming Blockchain 3.0.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: (murphyzhao) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10987-1.html) +[#]: subject: (Welcoming Blockchain 3.0) +[#]: via: (https://www.ostechnix.com/welcoming-blockchain-3-0/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +迎接区块链 3.0 +====== + +![欢迎区块链 3.0][1] + +“[区块链 2.0][2]” 系列文章讨论了自 2008 年比特币等加密货币问世以来区块链技术的发展。本文将探讨区块链的未来发展。**区块链 3.0** 这一新的 DLT(分布式分类帐本技术Distributed Ledger Technology)演进浪潮将回答当前区块链所面临的问题(每一个问题都会在这里总结)。下一版本的技术标准也将带来全新的应用和使用案例。在本文的最后,我们也会看一些当前使用这些原则的案例。 + +以下是现有区块链平台的几个缺点,并针对这些缺点给出了建议的解决方案。 + +### 问题 1:可扩展性 + +这个问题 [^1]被视为普遍采用该技术的第一个主要障碍。正如之前所讨论的,很多因素限制了区块链同时处理大量交易的能力。诸如 [以太坊][3] 之类的现有网络每秒能够进行 10-15 次交易(TPS),而像 Visa 所使用的主流网络每秒能够进行超过 2000 次交易。**可扩展性**是困扰所有现代数据库系统的问题。正如我们在这里看到的那样,改进的共识算法和更好的区块链架构设计正在改进它。 + +#### 解决可扩展性 + +已经提出了更精简、更有效的一致性算法来解决可扩展性问题,并且不会影响区块链的主要结构。虽然大多数加密货币和区块链平台使用资源密集型的 PoW 算法(例如,比特币和以太坊)来生成区块,但是存在更新的 DPoS 和 PoET 算法来解决这个问题。DPoS 和 PoET 算法(还有一些正在开发中)需要更少的资源来维持区块链,并且已显示具有高达 1000 TPS 的吞吐量,可与流行的非区块链系统相媲美。 + +可扩展性问题的第二个解决方案是完全改变区块链结构和功能。我们不会详细介绍这一点,但已经提出了诸如有向无环图Directed Acyclic Graph(DAG)之类的替代架构来处理这个问题。从本质上讲,这项工作假设并非所有网络节点都需要整个区块链的副本才能使区块链正常工作,或者并非所有的参与者需要从 DLT 系统获得好处。系统不要求所有参与者验证交易,只需要交易发生在共同的参考框架中并相互链接。 + +在比特币系统中使用[闪电网络][11]Lightning network来实现 DAG,而以太坊使用他们的[切片][12]Sharding 协议来实现 DAG。本质上,从技术上来看 DAG 实现并不是区块链。它更像是一个错综复杂的迷宫,只是仍然保留了区块链的点对点和分布式数据库属性。稍后我们将在另一篇文章中探讨 DAG 和 Tangle 网络。 + +### 问题 2:互通性 + +**互通性**[^4] [^5] 被称为跨链访问,基本上就是指不同区块链之间彼此相互通信以交换指标和信息。由于目前有数不清的众多平台,不同公司为各种应用提供了各种专有系统,平台之间的互操作性就至关重要。例如,目前在一个平台上拥有数字身份的人无法利用其他平台提供的功能,因为各个区块链彼此之间互不了解、不能沟通。这是由于缺乏可靠的验证、令牌交换等有关的问题仍然存在。如果平台之间不能够相互通信,面向全球推出[智能合约][4]也是不可行的。 + +#### 解决互通性 + +有一些协议和平台专为实现互操作性而设计。这些平台实现了原子交换协议,并向不同的区块链系统提供开放场景,以便在它们之间进行通信和交换信息。**“0x (ZRX)”** 就是其中的一个例子,稍后将对进行描述。 + +### 问题 3:治理 + +公有链中的治理 [^6] 本身不是限制,而是需要像社区道德指南针一样,在区块链的运作中考虑每个人的意见。结合起来并规模性地看,能预见这样一个问题,即要么协议更改太频繁,要么协议被拥有最多令牌的“中央”权威一时冲动下修改。不过这不是大多数公共区块链目前正在努力避免的问题,因为其运营规模和运营性质不需要更严格的监管。 + +#### 解决治理问题 + +上面提到的复杂的框架或 DAG 几乎可以消除对全球(平台范围)治理法规的需要和使用。相反,程序可以自动监督事务和用户类型,并决定需要执行的法律。 + +### 问题 4:可持续性 + +可持续性再次建立在可扩展性问题的基础上。当前的区块链和加密货币因不可长期持续而倍遭批评,这是由于仍然需要大量的监督,并且需要大量资源保持系统运行。如果你读过最近“挖掘加密货币”已经没有这么大利润的相关报道,你就知道“挖矿”图利就是它的本来面目。保持现有平台运行所需的资源量在全球范围和主流使用方面根本不实用。 + +#### 解决不可持续性问题 + +从资源或经济角度来看,可持续性的答案与可扩展性的答案类似。但是,要在全球范围内实施这一制度,法律和法规必须予以认可。然而,这取决于世界各国政府。来自美国和欧洲政府的有利举措重新燃起了对这方面的希望。 + +### 问题 5:用户采用 + +目前,阻止消费者广泛采用 [^7] 基于区块链的应用程序的一个障碍是消费者对平台及其底层的技术不熟悉。事实上,大多数应用程序都需要某种技术和计算背景来弄清楚它们是如何工作的,这在这方面也没有帮助。区块链开发的第三次浪潮旨在缩小消费者知识与平台可用性之间的差距。 + +#### 解决用户采用问题 + +互联网花了很长的时间才发展成现在的样子。多年来,人们在开发标准化互联网技术栈方面做了大量的工作,使 Web 能够像现在这样运作。开发人员正在开发面向用户的前端分布式应用程序,这些应用程序应作为现有 Web 3.0 技术之上的一层,同时由下面的区块链和开放协议的支持。这样的[分布式应用][5]将使用户更熟悉底层技术,从而增加主流采用。 + +### 在当前场景中的应用 + +我们已经从理论上讨论了上述问题的解决方法,现在我们将继续展示这些方法在当前场景中的应用。 + +- [0x][6] – 是一种去中心化的令牌交换,不同平台的用户可以在不需要中央权威机构审查的情况下交换令牌。他们的突破在于,他们如何设计系统使得仅在交易结算后才记录和审查数据块,而不是通常的在交易之间进行(为了验证上下文,通常也会验证交易之前的数据块)。这使在线数字资产交换更快速。 +- [Cardano][7] – 由以太坊的联合创始人之一创建,Cardano 自诩为一个真正“科学”的平台,和采用了严格的协议,对开发的代码和算法进行了多次审查。Cardano 的所有内容都在数学上尽可能的进行了优化。他们的共识算法叫做 **Ouroboros**,是一种改进的权益证明Proof of Stake(PoS)算法。Cardano 是用 [**haskell**][8] 开发的,智能合约引擎使用 haskell 的衍生工具 **plutus** 进行操作。这两者都是函数式编程语言,可以保证安全交易而不会影响效率。 +- EOS – 我们已经在 [这篇文章][9] 中描述了 EOS。 +- [COTI][10] – 一个鲜为人知的架构,COTI 不需要挖矿,而且在运行过程中趋近于零功耗。它还将资产存储在本地用户设备上的离线钱包中,而不是存储在纯粹的对等网络上。它们也遵循基于 DAG 的架构,并声称处理吞吐量高达 10000 TPS。他们的平台允许企业在不利用区块链的情况下建立自己的加密货币和数字化货币钱包。 + +[^1]: A. P. Paper, K. Croman, C. Decker, I. Eyal, A. E. Gencer, and A. Juels, “On Scaling Decentralized Blockchains | SpringerLink,” 2018. +[^4]: [Why is blockchain interoperability important][13] +[^5]: [The Importance of Blockchain Interoperability][14] +[^6]: R. Beck, C. Müller-Bloch, and J. L. King, “Governance in the Blockchain Economy: A Framework and Research Agenda,” J. Assoc. Inf. Syst., pp. 1020–1034, 2018. +[^7]: J. M. Woodside, F. K. A. Jr, W. Giberson, F. K. J. Augustine, and W. Giberson, “Blockchain Technology Adoption Status and Strategies,” J. Int. Technol. Inf. Manag., vol. 26, no. 2, pp. 65–93, 2017. + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/welcoming-blockchain-3-0/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[murphyzhao](https://github.com/murphyzhao) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/06/blockchain-720x340.jpg +[2]: https://linux.cn/article-10650-1.html +[3]: https://www.ostechnix.com/blockchain-2-0-what-is-ethereum/ +[4]: https://www.ostechnix.com/blockchain-2-0-explaining-smart-contracts-and-its-types/ +[5]: https://www.ostechnix.com/blockchain-2-0-explaining-distributed-computing-and-distributed-applications/ +[6]: https://0x.org/ +[7]: https://www.cardano.org/en/home/ +[8]: https://www.ostechnix.com/getting-started-haskell-programming-language/ +[9]: https://www.ostechnix.com/blockchain-2-0-eos-io-is-building-infrastructure-for-developing-dapps/ +[10]: https://coti.io/ +[11]: https://cryptoslate.com/beyond-blockchain-directed-acylic-graphs-dag/ +[12]: https://github.com/ethereum/wiki/wiki/Sharding-FAQ#introduction +[13]: https://www.capgemini.com/2019/02/can-the-interoperability-of-blockchains-change-the-world/ +[14]: https://medium.com/wanchain-foundation/the-importance-of-blockchain-interoperability-b6a0bbd06d11 diff --git a/published/201906/20190612 Installing alternative versions of RPMs in Fedora.md b/published/201906/20190612 Installing alternative versions of RPMs in Fedora.md new file mode 100644 index 0000000000..54406f13ba --- /dev/null +++ b/published/201906/20190612 Installing alternative versions of RPMs in Fedora.md @@ -0,0 +1,133 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10999-1.html) +[#]: subject: (Installing alternative versions of RPMs in Fedora) +[#]: via: (https://fedoramagazine.org/installing-alternative-rpm-versions-in-fedora/) +[#]: author: (Adam Šamalík https://fedoramagazine.org/author/asamalik/) + +在 Fedora 中安装替代版本的 RPM 包 +====== + +![][1] + +[模块化][2]Modularity使 Fedora 能够在仓库中提供替代版本的 RPM 软件包。每个 Fedroa 版本可以原生构建不同应用、语言运行时和工具版本的多个版本。 + +Fedora Magazine 大约一年前就写了 [Fedora 28 服务器版的模块化][3]。那时,它只是一个有附加内容的可选仓库,并且明确只支持服务器版。到目前为止,它已经发生了很多变化,现在**模块化是 Fedora 发行版的核心部分**。一些软件包已完全变成模块。在编写本文时,Fedora 30 的 49,464 个二进制 RPM 软件包中的 1,119(2.26%)来自模块([关于这个数字的更多信息][4])。 + +### 模块化基础知识 + +由于许多软件包有不同的版本会让人难以承受(并且难以管理),所以包被分组为**模块**,它可以代表一个应用程序、一个语言运行时或任何其他合理的组。 + +模块通常有多个**流**,这通常代表软件的主要版本。它可以并行使用,但在给定系统上只能安装每个模块的一个流。 + +为了不让用户因为太多选择而难以承受,每个 Fedora 版本都有一组**默认**,因此只需要在需要时做出决定。 + +最后,为了简化安装,可以根据用例使用预定义的 **profile** 选择性地安装模块。例如,数据库模块可以作为客户端,服务端或同时安装。 + +### 实际使用模块化 + +当你在 Fedora 系统上安装 RPM 软件包时,它很可能它来自模块流。你可能没有注意到的原因之一是模块化的核心原则之一是在你探究之前保持不可见。 + +让我们比较以下两种情况。首先,安装流行的 i3 平铺窗口管理器,然后安装极简化的 dwm 窗口管理器: + +``` +$ sudo dnf install i3 +... +Done! +``` + +正如所料,上面的命令会在系统上安装 i3 包及其依赖项。这里没有其他事情发生。但另一个会怎么样? + +``` +$ sudo dnf install dwm +... +Enabling module streams: + dwm 6.1 +... +Done! +``` + +感觉是一样的,但后台发生了一些事情 。它启用了默认的 dwm 模块流(6.1),并且安装了模块中的 dwm 包。 + +为了保持透明,输出中有一条关于模块自动启用的消息。但除此之外,用户不需要了解模块化的任何信息,以便按照他们一贯的方式使用他们的系统。 + +但如果他们使用模块化方式呢?让我们看看如何安装不同版本的 dwm。 + +使用以下命令查看可用的模块流: + +``` +$ sudo dnf module list +... +dwm latest ... +dwm 6.0 ... +dwm 6.1 [d] ... +dwm 6.2 ... +... +Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled +``` + +输出显示 dwm 模块有四个流,6.1 是默认值。 + +要安装不同版本的 dwm 包,例如,安装 6.2 的流。启用它,然后使用以下两个命令安装软件包: + +``` +$ sudo dnf module enable dwm:6.2 +... +Enabling module streams: + dwm 6.2 +... +Done! +$ sudo dnf install dwm +... +Done! +``` + +最后,让我们看下配置,以 PostgreSQL 为例。 + +``` +$ sudo dnf module list +... +postgresql 9.6 client, server ... +postgresql 10 client, server ... +postgresql 11 client, server ... +... +``` + +要安装 PostgreSQL 11 服务端,使用以下命令: + +``` +$ sudo dnf module install postgresql:11/server +``` + +请注意,除了启用流之外,我们可以指定配置从而使用一条命令安装模块。 + +可以立即安装多个版本。要添加客户端工具,使用下面的命令: + +``` +$ sudo dnf module install postgresql:11/client +``` + +还有许多其他带有多个流的模块可供选择。在编写本文时,Fedora 30 中有 83 个模块流。包括两个版本的 MariaDB、三个版本的 Node.js、两个版本的 Ruby 等等。 + +有关完整的命令集(包括从一个流切换到另一个流),请参阅[模块化的官方用户文档][5]。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/installing-alternative-rpm-versions-in-fedora/ + +作者:[Adam Šamalík][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/asamalik/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/06/modularity-f30-816x345.jpg +[2]: https://docs.pagure.org/modularity +[3]: https://linux.cn/article-10479-1.html +[4]: https://blog.samalik.com/2019/06/12/counting-modularity-packages.html +[5]: https://docs.fedoraproject.org/en-US/modularity/using-modules/ diff --git a/published/201906/20190613 Open hardware for musicians and music lovers- Headphone, amps, and more.md b/published/201906/20190613 Open hardware for musicians and music lovers- Headphone, amps, and more.md new file mode 100644 index 0000000000..03a5f4dd47 --- /dev/null +++ b/published/201906/20190613 Open hardware for musicians and music lovers- Headphone, amps, and more.md @@ -0,0 +1,94 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10998-1.html) +[#]: subject: (Open hardware for musicians and music lovers: Headphone, amps, and more) +[#]: via: (https://opensource.com/article/19/6/hardware-music) +[#]: author: (Michael Weinberg https://opensource.com/users/mweinberg) + +音乐家和音乐爱好者的开放硬件:耳机、放大器等 +====== + +> 从 3D 打印乐器到无线播放声音的设备,有很多通过开放硬件项目来奏乐的方法。 + +![][1] + +这个世界到处都是很棒的[开源音乐播放器][2],但为什么只是将开源用在播放音乐上呢?你还可以使用开源硬件奏乐。本文中描述的所有工具都是经过了[开源硬件协会][3](OSHWA)认证的。这意味着你可以自由地构建它们,重新组合它们,或者用它们做任何其他事情。 + +### 开源乐器 + +当你想奏乐时使用乐器总是最好的方式之一。如果你喜欢传统的的乐器,那么 [F-F-Fiddle][4] 可能适合你。 + +![F-f-fiddle][5] + +F-F-Fiddle 是一款全尺寸电子小提琴,你可以使用标准的桌面 3D 打印机制作(采用[熔丝制造][6])。如果你想眼见为真,那么这里有一个 F-F-Fiddle 的视频: https://img.linux.net.cn/static/video/The%20F-F-Fiddle-8NDWVcJJS2Y.mp4 + +如果你精通小提琴,但还对一些更具异国情调的东西感兴趣?[开源的特雷门琴][7]Open Theremin怎么样? + +![Open Theremin][8] + +与所有特雷门琴一样,开源特雷门琴可让你在不触碰乐器的情况下播放音乐。当然,它特别擅长为你的下一个科幻视频或空间主题派对制作[令人毛骨悚然的空间声音][9]。 + +[Waft][10] 的操作类似,也可以远程控制声音。它使用[激光雷达][11]来测量手与传感器的距离。看看这个: https://img.linux.net.cn/static/video/Waft%20Prototype%2012-Feb-2017-203705197.mp4 + +Waft 是特雷门琴吗?我不确定算不算,特雷门琴高手可以在下面的评论里发表一下看法。 + +如果特雷门琴对你来说太熟悉了,[SIGNUM][12] 可能就是你想要的。用其开发人员的话说,SIGNUM 通过将不可见的无线通信转换为可听信号来“揭示加密的信息代码和人/机通信的语言”。 + +![SIGNUM][13] + +这是演示: https://img.linux.net.cn/static/video/SIGNUM_Portable%20Analog%20Instrumentation%20Amplifier-142831757.mp4 + +### 输入 + +无论你使用什么乐器,都需要将其接到某些东西上。如果你想要连接到树莓派,请尝试 [AudioSense-Pi][14],它允许你一次将多个输入和输出连接到你的树莓派。 + +![AudioSense-Pi][15] + +### 合成器 + +合成器怎么样?SparkFun 的 [SparkPunk Sound Kit][16] 是一个简单的合成器,为你提供了很多音色。 + +![SparkFun SparkPunk Sound Kit][17] + +### 耳机 + +制作所有这些音乐很棒,但你还需要考虑如何听它。幸运的是,[EQ-1耳机][18]是开源,支持 3D 打印。 + +![EQ-1 headphones][19] + +你用开源硬件制作音乐吗?让我们在评论中知道! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/hardware-music + +作者:[Michael Weinberg][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mweinberg +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LIFE_musicinfinity.png?itok=7LkfjcS9 +[2]: https://opensource.com/article/19/2/audio-players-linux +[3]: https://certification.oshwa.org/ +[4]: https://certification.oshwa.org/us000010.html +[5]: https://opensource.com/sites/default/files/uploads/f-f-fiddle.png (F-f-fiddle) +[6]: https://en.wikipedia.org/wiki/Fused_filament_fabrication +[7]: https://certification.oshwa.org/ch000001.html +[8]: https://opensource.com/sites/default/files/uploads/open-theremin.png (Open Theremin) +[9]: https://youtu.be/p05ZSHRYXVA?t=771 +[10]: https://certification.oshwa.org/uk000005.html +[11]: https://en.wikipedia.org/wiki/Lidar +[12]: https://certification.oshwa.org/es000003.html +[13]: https://opensource.com/sites/default/files/uploads/signum.png (SIGNUM) +[14]: https://certification.oshwa.org/in000007.html +[15]: https://opensource.com/sites/default/files/uploads/audiosense-pi.png (AudioSense-Pi) +[16]: https://certification.oshwa.org/us000016.html +[17]: https://opensource.com/sites/default/files/uploads/sparkpunksoundkit.png (SparkFun SparkPunk Sound Kit) +[18]: https://certification.oshwa.org/us000038.html +[19]: https://opensource.com/sites/default/files/uploads/eq-1-headphones.png (EQ-1 headphones) diff --git a/published/201906/20190613 Ubuntu Kylin- The Official Chinese Version of Ubuntu.md b/published/201906/20190613 Ubuntu Kylin- The Official Chinese Version of Ubuntu.md new file mode 100644 index 0000000000..fe9c2a13a6 --- /dev/null +++ b/published/201906/20190613 Ubuntu Kylin- The Official Chinese Version of Ubuntu.md @@ -0,0 +1,119 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10995-1.html) +[#]: subject: (Ubuntu Kylin: The Official Chinese Version of Ubuntu) +[#]: via: (https://itsfoss.com/ubuntu-kylin/) +[#]: author: (Avimanyu Bandyopadhyay https://itsfoss.com/author/avimanyu/) + +优麒麟:Ubuntu 的官方中文版本 +====== + +> 让我们来看看国外是如何看优麒麟的。 + +[Ubuntu 有几个官方特色版本][1],优麒麟(Ubuntu Kylin)是它们中的一个。在这篇文章中,你将了解到优麒麟,它是什么,它为什么被创建,它的特色是什么。 + +麒麟操作系统最初由中华人民共和国的[国防科技大学][2]的院士在 2001 年开发。名字来源于[麒麟][3],这是一种来自中国神话的神兽。 + +麒麟操作系统的第一个版本基于 [FreeBSD][4],计划用于中国军方和其它政府组织。麒麟 3.0 完全基于 Linux 内核,并且在 2010 年 12 月发布一个称为 [NeoKylin][5] 的版本。 + +在 2013 年,[Canonical][6] (Ubuntu 的母公司) 与中华人民共和国的[工业和信息化部][7] 达成共识,共同创建和发布一个针对中国市场特色的基于 Ubuntu 的操作系统。 + +![Ubuntu Kylin][8] + +### 优麒麟是什么? + +根据上述 2013 年的共识,优麒麟现在是 Ubuntu 的官方中国版本。它不仅仅是语言本地化。事实上,它决心服务中国市场,就像 Ubuntu 服务全球市场一样。 + +[优麒麟][9]的第一个版本与 Ubuntu 13.04 一起到来。像 Ubuntu 一样,优麒麟也有 LTS (长期支持)和非 LTS 版本。 + +当前,优麒麟 19.04 LTS 采用了 [UKUI][10] 桌面环境,修改了启动动画、登录/锁屏程序和操作系统主题。为给用户提供更友好的体验,它修复了一些错误,带有文件预览、定时注销等功能,最新的 [WPS 办公组件][11]和 [搜狗][12] 输入法集成于其中。 + +- [https://youtu.be/kZPtFMWsyv4](https://youtu.be/kZPtFMWsyv4) + +银河麒麟 4.0.2 是一个基于优麒麟 16.04 LTS 的社区版本。它包含一些带有长期稳定支持的第三方应用程序。它非常适合服务器和日常桌面办公使用,欢迎开发者[下载][13]。麒麟论坛积极地获取来自提供的反馈以及解决问题来找到解决方案。 + +#### UKUI:优麒麟的桌面环境 + +![Ubuntu Kylin 19.04 with UKUI Desktop][15] + +[UKUI][16] 由优麒麟开发小组设计和开发,有一些非常好的特色和预装软件: + + * 类似 Windows 的交互功能,带来更友好的用户体验。安装导向易于使用,用户可以快速使用优麒麟。 + * 控制中心对主题和窗口采用了新的设置。如开始菜单、任务栏、文件管理器、窗口管理器和其它的组件进行了更新。 + * 在 Ubuntu 和 Debian 存储库上都可用,为 Debian/Ubuntu 发行版和其全球衍生版的的用户提供一个新单独桌面环境。 + * 新的登录和锁定程序,它更稳定和具有很多功能。 + * 包括一个反馈问题的实用的反馈程序。 + +#### 麒麟软件中心 + +![Kylin Software Center][17] + +麒麟有一个软件中心,类似于 Ubuntu 软件中心,并被称为优麒麟软件中心。它是优麒麟软件商店的一部分,该商店也包含优麒麟开发者平台和优麒麟存储库,具有一个简单的用户界面,并功能强大。它同时支持 Ubuntu 和优麒麟存储库,并特别适用于由优麒麟小组开发的中文特有的软件的快速安装! + +#### 优客:一系列的工具 + +优麒麟也有一系列被命名为优客的工具。在麒麟开始菜单中输入 “Youker” 将带来麒麟助手。如果你在键盘上按 “Windows” 按键,像你在 Windows 上一样,它将打开麒麟开始菜单。 + +![Kylin Assistant][18] + +其它麒麟品牌的应用程序包括麒麟影音(播放器)、麒麟刻录,优客天气、优客 Fcitx 输入法,它们更好地支持办公工作和个人娱乐。 + +![Kylin Video][19] + +#### 特别专注于中文 + +通过与金山软件合作,优麒麟开发者也致力于 Linux 版本的搜狗拼音输入法、快盘和优麒麟版本的金山 WPS,并解决了智能拼音、云存储和办公应用程序方面的问题。[拼音][20] 是中文字符的拉丁化系统。使用这个系统,用户用英文键盘输入,但在屏幕上将显示中文字符。 + +#### 有趣的事实:优麒麟运行在中国超级计算机上 + +![Tianhe-2 Supercomputer. Photo by O01326 – Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=45399546][22] + +众所周知[世界上最快的超级计算机 500 强都在运行 Linux][23]。中国超级计算机[天河-1][24]和[天河-2][25]都使用优麒麟的 64 位版本,致力于高性能的[并行计算][26]优化、电源管理和高性能的[虚拟化计算][27]。 + +### 总结 + +我希望你喜欢这篇优麒麟世界的介绍。你可以从它的[官方网站][28]获得优麒麟 19.04 或基于 Ubuntu 16.04 的社区版本(银河麒麟)。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-kylin/ + +作者:[Avimanyu Bandyopadhyay][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/avimanyu/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/which-ubuntu-install/ +[2]: https://english.nudt.edu.cn +[3]: https://www.thoughtco.com/what-is-a-qilin-195005 +[4]: https://itsfoss.com/freebsd-12-release/ +[5]: https://thehackernews.com/2015/09/neokylin-china-linux-os.html +[6]: https://www.canonical.com/ +[7]: http://english.gov.cn/state_council/2014/08/23/content_281474983035940.htm +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/Ubuntu-Kylin.jpeg?resize=800%2C450&ssl=1 +[9]: http://www.ubuntukylin.com/ +[10]: http://ukui.org +[11]: https://www.wps.com/ +[12]: https://en.wikipedia.org/wiki/Sogou_Pinyin +[13]: http://www.ubuntukylin.com/downloads/show.php?lang=en&id=122 +[14]: https://itsfoss.com/solve-ubuntu-error-failed-to-download-repository-information-check-your-internet-connection/ +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/ubuntu-Kylin-19-04-desktop.jpg?resize=800%2C450&ssl=1 +[16]: http://www.ukui.org/ +[17]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/kylin-software-center.jpg?resize=800%2C496&ssl=1 +[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/kylin-assistant.jpg?resize=800%2C535&ssl=1 +[19]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/kylin-video.jpg?resize=800%2C533&ssl=1 +[20]: https://en.wikipedia.org/wiki/Pinyin +[21]: https://itsfoss.com/remove-old-kernels-ubuntu/ +[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/tianhe-2.jpg?resize=800%2C600&ssl=1 +[23]: https://itsfoss.com/linux-runs-top-supercomputers/ +[24]: https://en.wikipedia.org/wiki/Tianhe-1 +[25]: https://en.wikipedia.org/wiki/Tianhe-2 +[26]: https://en.wikipedia.org/wiki/Parallel_computing +[27]: https://computer.howstuffworks.com/how-virtual-computing-works.htm +[28]: http://www.ubuntukylin.com diff --git a/published/201906/20190614 How to send email from the Linux command line.md b/published/201906/20190614 How to send email from the Linux command line.md new file mode 100644 index 0000000000..b8754241ab --- /dev/null +++ b/published/201906/20190614 How to send email from the Linux command line.md @@ -0,0 +1,169 @@ +[#]: collector: (lujun9972) +[#]: translator: (Modrisco) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11020-1.html) +[#]: subject: (How to send email from the Linux command line) +[#]: via: (https://www.networkworld.com/article/3402027/how-to-send-email-from-the-linux-command-line.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如何用 Linux 命令行发电子邮件 +====== + +> Linux 提供了几个可以让你通过终端发送电子邮件的命令,下面来展示一些有趣的方法。 + +![Molnia/iStock][1] + +Linux 可以用多种方式通过命令行发送电子邮件。有一些方法十分简单,有一些相对会复杂一些,不过仍旧提供了很多有用的特性。选择哪一种方式取决于你想要什么 —— 向同事快速发送消息,还是向一批人群发带有附件的更复杂的信息。接下来看一看几种可行方案: + +### mail + +发送一条简单消息最便捷的 Linux 命令是 `mail`。假设你需要提醒老板你今天得早点走,你可以使用这样的一条命令: + +``` +$ echo "Reminder: Leaving at 4 PM today" | mail -s "early departure" myboss +``` + +另一种方式是从一个文件中提取出你想要发送的文本信息: + +``` +$ mail -s "Reminder:Leaving early" myboss < reason4leaving +``` + +在以上两种情况中,你都可以通过 `-s` 来为邮件添加标题。 + +### sendmail + +使用 `sendmail` 命令可以发送一封不包含标题的快信。(用目标收件人替换 `recip`): + +``` +$ echo "leaving now" | sendmail recip +``` + +你可以用这条命令发送一条只有标题,没有内容的信息: + +``` +$ echo "Subject: leaving now" | sendmail recip +``` + +你也可以用 `sendmail` 发送一条包含一条标题行的完整信息。不过使用这个方法时,你的标题行会被添加到要发送的文件中,如下例所示: + +``` +Subject: Requested lyrics +I would just like to say that, in my opinion, longer hair and other flamboyant +affectations of appearance are nothing more ... +``` + +你也可以发送这样的文件(`lyric` 文件包含标题和正文): + +``` +$ sendmail recip < lyrics +``` + +`sendmain` 的输出也可以很冗长。如果你感到好奇并希望查看发送系统和接收系统之间的交互,请添加 `-v` (verbose)选项。 + +``` +$ sendmail -v recip@emailsite.com < lyrics +``` + +### mutt + +`mutt` 是通过命令行发送邮件的一个很好的工具,在使用前你需要安装它。`mutt` 的一个很方便的优势就是它允许你在邮件中添加附件。 + +使用 `mutt` 发送一条快速信息: + +``` +$ echo "Please check last night's backups" | mutt -s "backup check" recip +``` + +从文件中获取内容: + +``` +$ mutt -s "Agenda" recip < agenda +``` + +使用 `-a` 选项在 `mutt` 中添加附件。你甚至可以添加不止一个附件 —— 如下一条命令所示: + +``` +$ mutt -s "Agenda" recip -a agenda -a speakers < msg +``` + +在以上的命令中,`msg` 文件包含了邮件中的正文。如果你没有其他补充的内容,你可以这样来代替之前的命令: + +``` +$ echo "" | mutt -s "Agenda" recip -a agenda -a speakers +``` + +`mutt` 另一个有用的功能是可以添加抄送(`-c`)和密送(`-b`)。 + +``` +$ mutt -s "Minutes from last meeting" recip@somesite.com -c myboss < mins +``` + +### telnet + +如果你想深入了解发送电子邮件的细节,你可以使用 `telnet` 来进行电子邮件交互操作。但正如所说的那样,你需要“学习术语”。邮件服务器期望一系列命令,其中包括自我介绍(`EHLO` 命令)、提供发件人(`MAIL FROM` 命令)、指定收件人(`RCPT TO` 命令),然后添加消息(`DATA`)并以 `.` 结束消息。并不是所有的电子邮件服务器都会响应这些请求。此方法通常仅用于故障排除。 + +``` +$ telnet emailsite.org 25 +Trying 192.168.0.12... +Connected to emailsite. +Escape character is '^]'. +220 localhost ESMTP Sendmail 8.15.2/8.15.2/Debian-12; Wed, 12 Jun 2019 16:32:13 -0400; (No UCE/UBE) logging access from: mysite(OK)-mysite [192.168.0.12] +EHLO mysite.org <== introduce yourself +250-localhost Hello mysite [127.0.0.1], pleased to meet you +250-ENHANCEDSTATUSCODES +250-PIPELINING +250-EXPN +250-VERB +250-8BITMIME +250-SIZE +250-DSN +250-ETRN +250-AUTH DIGEST-MD5 CRAM-MD5 +250-DELIVERBY +250 HELP +MAIL FROM: me@mysite.org <== 指定发件人 +250 2.1.0 shs@mysite.org... Sender ok +RCPT TO: recip <== 指定收件人 +250 2.1.5 recip... Recipient ok +DATA <== 邮件内容开始 +354 Enter mail, end with "." on a line by itself +This is a test message. Please deliver it for me. +. <== 内容结束 +250 2.0.0 x5CKWDds029287 Message accepted for delivery +quit <== 结束交互 +``` + +### 向多个收件人发送电子邮件 + +如果你希望通过 Linux 命令行向一大组收件人发送电子邮件,你可以使用一个循环来帮助你完成任务,如下面应用在 `mutt` 中的例子: + +``` +$ for recip in `cat recips` +do + mutt -s "Minutes from May meeting" $recip < May_minutes +done +``` + +### 总结 + +有很多方法可以从 Linux 命令行发送电子邮件。有些工具提供了相当多的选项。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3402027/how-to-send-email-from-the-linux-command-line.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[Modrisco](https://github.com/Modrisco) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2017/08/email_image_blue-100732096-large.jpg +[2]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/201906/20190614 Personal assistant with Mycroft and Fedora.md b/published/201906/20190614 Personal assistant with Mycroft and Fedora.md new file mode 100644 index 0000000000..4b0a46c79d --- /dev/null +++ b/published/201906/20190614 Personal assistant with Mycroft and Fedora.md @@ -0,0 +1,92 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11022-1.html) +[#]: subject: (Personal assistant with Mycroft and Fedora) +[#]: via: (https://fedoramagazine.org/personal-assistant-with-mycroft-and-fedora/) +[#]: author: (Clément Verna https://fedoramagazine.org/author/cverna/) + +在 Fedora 中使用私人助理 Mycroft +====== + +![][1] + +> 想要找个开源的私人助理么?[Mycroft][2] 可以让你运行一个开源的服务,从而更好地控制你的数据。 + +### 在 Fedora 上安装 Mycroft + +Mycroft 目前不存在于官方软件包集合中,但它可以轻松地从源码安装。第一步是从 Mycroft 的 GitHub 仓库下载源码。 + +``` +$ git clone https://github.com/MycroftAI/mycroft-core.git +``` + +Mycroft 是一个 Python 应用,它提供了一个脚本负责在安装 Mycroft 及其依赖项之前创建虚拟环境。 + +``` +$ cd mycroft-core +$ ./dev_setup.sh +``` + +安装脚本会提示用户以帮助他完成安装过程。建议运行稳定版本并获取自动更新。 + +当提示在本地安装 Mimic 文字转语音引擎时,请回答否。因为根据安装描述,这可能需要很长时间,并且 Mimic 有适合 Fedora 的 rpm 包,因此可以使用 `dnf` 进行安装。 + +``` +$ sudo dnf install mimic +``` + +### 开始使用 Mycroft + +安装完成后,可以使用以下脚本启动 Mycroft 服务。 + +``` +$ ./start-mycroft.sh all +``` + +要开始使用 Mycroft,需要注册运行服务的设备。因此需要一个帐户,可以在 中创建。 + +创建帐户后,可以在 [https://account.mycroft.ai/devices][3] 中添加新设备。添加新设备需要配对码,你的设备会在所有服务启动后告诉你。 + +![][4] + +现在可以使用该设备了。 + +### 使用 Mycroft + +Mycroft 提供了一组默认启用的[技能][5],它们或者可以从[市场][5]下载。刚开始,你可以简单地向 Mycroft 问好,或天气如何。 + +``` +Hey Mycroft, how are you ? + +Hey Mycroft, what's the weather like ? +``` + +如果你对它是如何工作的感兴趣,`start-mycroft.sh` 脚本提供了一个命令行选项,它能让你使用命令行交互。它也会显示用于调试的有用信息。 + +Mycroft 总在学习新技能,并且有很多方法给 Mycroft 社区做[贡献][6]。 + +由 [Przemyslaw Marczynski][7] 摄影,发布于 [Unsplash][8] + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/personal-assistant-with-mycroft-and-fedora/ + +作者:[Clément Verna][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/cverna/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2017/08/mycroft-816x345.jpg +[2]: https://mycroft.ai/ +[3]: https://account.mycroft.ai/devices +[4]: https://fedoramagazine.org/wp-content/uploads/2019/06/Screenshot_2019-06-14-Account.png +[5]: https://market.mycroft.ai/skills +[6]: https://mycroft.ai/contribute/ +[7]: https://unsplash.com/@pemmax?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[8]: https://unsplash.com/search/photos/ai?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/201906/20190617 Exploring -run on Linux.md b/published/201906/20190617 Exploring -run on Linux.md new file mode 100644 index 0000000000..575d5ffd0b --- /dev/null +++ b/published/201906/20190617 Exploring -run on Linux.md @@ -0,0 +1,120 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11008-1.html) +[#]: subject: (Exploring /run on Linux) +[#]: via: (https://www.networkworld.com/article/3403023/exploring-run-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +探索 Linux 上的 /run +====== + +> Linux 系统在运行时数据方面的工作方式发生了微小但重大的变化。 + +![](https://img.linux.net.cn/data/attachment/album/201906/23/092816aqczi984w30j8k12.jpg) + +如果你没有密切关注,你可能没有注意到 Linux 系统在运行时数据方面的工作方式有一些小但重大的变化。 它重新组织了文件系统中可访问的方式和位置,而这个变化在大约八年前就开始了。虽然这种变化可能不足以让你的袜子变湿,但它在 Linux 文件系统中提供了更多一致性,值得进行一些探索。 + +要开始,请转到 `/run`。如果你使用 `df` 来检查它,你会看到这样的输出: + +``` +$ df -k . +Filesystem 1K-blocks Used Available Use% Mounted on +tmpfs 609984 2604 607380 1% /run +``` + +它被识别为 “tmpfs”(临时文件系统),因此我们知道 `/run` 中的文件和目录没有存储在磁盘上,而只存储在内存中。它们表示保存在内存(或基于磁盘的交换空间)中的数据,它看起来像是一个已挂载的文件系统,这个可以使其更易于访问和管理。 + +`/run` 是各种各样数据的家园。例如,如果你查看 `/run/user`,你会注意到一组带有数字名称的目录。 + +``` +$ ls /run/user +1000 1002 121 +``` + +使用长文件列表可以发现这些数字的重要性。 + +``` +$ ls -l +total 0 +drwx------ 5 shs shs 120 Jun 16 12:44 1000 +drwx------ 5 dory dory 120 Jun 16 16:14 1002 +drwx------ 8 gdm gdm 220 Jun 14 12:18 121 +``` + +我们看到每个目录与当前登录的用户或显示管理器 gdm 相关。数字代表他们的 UID。每个目录的内容都是运行中的进程所使用的文件。 + +`/run/user` 文件只是你在 `/run` 中找到的一小部分。还有很多其他文件。有一些文件包含了各种系统进程的进程 ID。 + +``` +$ ls *.pid +acpid.pid atopacctd.pid crond.pid rsyslogd.pid +atd.pid atop.pid gdm3.pid sshd.pid +``` + +如下所示,上面列出的 `sshd.pid` 文件包含 ssh 守护程序(`sshd`)的进程 ID。 + +``` +$ cat sshd.pid +1148 +$ ps -ef | grep sshd +root 1148 1 0 Jun14 ? 00:00:00 /usr/sbin/sshd -D <== +root 10784 1148 0 12:44 ? 00:00:00 sshd: shs [priv] +shs 10922 10784 0 12:44 ? 00:00:00 sshd: shs@pts/0 +root 18109 1148 0 16:13 ? 00:00:00 sshd: dory [priv] +dory 18232 18109 0 16:14 ? 00:00:00 sshd: dory@pts/1 +shs 19276 10923 0 16:50 pts/0 00:00:00 grep --color=auto sshd +``` + +`/run` 中的某些子目录只能使用 root 权限访问,例如 `/run/sudo`。例如,以 root 身份运行我们可以看到一些与真实或尝试使用 `sudo` 相关的文件: + +``` +/run/sudo/ts# ls -l +total 8 +-rw------- 1 root dory 112 Jun 16 16:37 dory +-rw------- 1 root shs 168 Jun 17 08:33 shs +``` + +为了与 `/run` 的变化保持一致,一些运行时数据的旧位置现在是符号链接。`/var/run` 现在是指向 `/run` 的指针,`/var/lock` 指向 `/run/lock` 的指针,可以保证旧的引用按预期工作。 + +``` +$ ls -l /var +total 52 +drwxr-xr-x 2 root root 4096 Jun 17 07:36 backups +drwxr-xr-x 19 root root 4096 Apr 18 13:46 cache +drwxrwsrwt 2 root whoopsie 4096 Jun 13 07:39 crash +drwxr-xr-x 75 root root 4096 Jun 9 15:14 lib +drwxrwsr-x 2 root staff 4096 Oct 16 2017 local +lrwxrwxrwx 1 root root 9 May 14 2018 lock -> /run/lock +drwxrwxr-x 17 root syslog 4096 Jun 17 00:00 log +drwxrwsrwt 2 root mail 4096 Jun 13 12:10 mail +drwxrwsrwt 2 root whoopsie 4096 Jan 5 2018 metrics +drwxr-xr-x 2 root root 4096 Jan 5 2018 opt +lrwxrwxrwx 1 root root 4 May 14 2018 run -> /run +drwxr-xr-x 9 root root 4096 Jun 16 2018 snap +drwxr-xr-x 9 root root 4096 Jun 9 15:14 spool +drwxrwxrwt 8 root root 4096 Jun 17 00:00 tmp +drwxr-xr-x 3 root root 4096 Jan 19 12:14 www +``` + +虽然技术上的变化很小,但转换到使用 `/run` 只是为了在 Linux 文件系统中更好地组织运行时数据。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3403023/exploring-run-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/06/exploring_run-100799398-large.jpg +[2]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua +[3]: https://www.networkworld.com/article/3242170/linux/invaluable-tips-and-tricks-for-troubleshooting-linux.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/201906/20190619 Get the latest Ansible 2.8 in Fedora.md b/published/201906/20190619 Get the latest Ansible 2.8 in Fedora.md new file mode 100644 index 0000000000..dd851a1dde --- /dev/null +++ b/published/201906/20190619 Get the latest Ansible 2.8 in Fedora.md @@ -0,0 +1,60 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11002-1.html) +[#]: subject: (Get the latest Ansible 2.8 in Fedora) +[#]: via: (https://fedoramagazine.org/get-the-latest-ansible-2-8-in-fedora/) +[#]: author: (Paul W. Frields https://fedoramagazine.org/author/pfrields/) + +在 Fedora 中获取最新的 Ansible 2.8 +====== + +![][1] + +Ansible 是世界上最受欢迎的自动化引擎之一。它能让你自动化几乎任何事情,从本地系统的设置到大量的平台和应用。它是跨平台的,因此你可以将其用于各种操作系统。请继续阅读以获取有关如何在 Fedora 中获取最新 Ansible,以及它的一些更改和改进,以及如何使用它。 + +### 发布版本和功能 + +Ansible 2.8 最近发布了,其中包含许多修复、功能和增强。仅仅几天之后,它就可在 Fedora 29 和 30 以及 EPEL 中获取。两周前发布了后续版本 2.8.1。同样,新版本在几天内就可以在 Fedora 中获取。 + +[使用 sudo][2] 能够非常容易地从官方仓库安装: + +``` +$ sudo dnf -y install ansible +``` + +2.8 版本有很长的更新列表,你可以在 [2.8 的迁移指南][3]中阅读查看。但其中包含了一些好东西,比如 *Python 解释器发现功能* 。Ansible 2.8 现在会试图找出哪个 Python 是它所运行的平台的首选版本。如果失败,Ansible 会使用后备列表。但是,你仍然可以使用变量 `ansible_python_interpreter` 来设置 Python 解释器。 + +另一个变化使 Ansible 在各个平台上更加一致。由于 `sudo` 专用于 UNIX/Linux,而其他平台并没有,因此现在在更多地方使用 `become`。这包括了命令行开关。例如,`-ask-sudo-pass` 已变成了 `-ask-become-pass`,提示符也变成了 `BECOME password:`。 + +2.8 和 2.8.1 版本中还有许多其他功能。有关所有细节,请查看 [GitHub 上的官方更新日志][4]。 + +### 使用 Ansible + +也许你不确定 Ansible 是否可以实际使用。别担心,你并不是唯一一个这样想的,因为它太强大了。但事实证明,它并不难以使用,在一个家庭内的几台电脑(甚至一台电脑)上设置都可以。 + +我们之前在 Fedora Magazine 中也讨论过这个话题: + +- [使用 Ansible 设置工作站][5] + +试试看 Ansible,说下你的想法。很重要的一部分是让 Fedora 保持最新版本。自动化快乐! + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/get-the-latest-ansible-2-8-in-fedora/ + +作者:[Paul W. Frields][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/06/ansible28-816x345.jpg +[2]: https://fedoramagazine.org/howto-use-sudo/ +[3]: https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.8.html +[4]: https://github.com/ansible/ansible/blob/stable-2.8/changelogs/CHANGELOG-v2.8.rst +[5]: https://fedoramagazine.org/using-ansible-setup-workstation/ diff --git a/published/201906/20190621 Bash Script to Monitor Memory Usage on Linux.md b/published/201906/20190621 Bash Script to Monitor Memory Usage on Linux.md new file mode 100644 index 0000000000..ee2a3cba8c --- /dev/null +++ b/published/201906/20190621 Bash Script to Monitor Memory Usage on Linux.md @@ -0,0 +1,151 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11007-1.html) +[#]: subject: (Bash Script to Monitor Memory Usage on Linux) +[#]: via: (https://www.2daygeek.com/linux-bash-script-to-monitor-memory-utilization-usage-and-send-email/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +用 Bash 脚本监控 Linux 上的内存使用情况 +====== + +![](https://img.linux.net.cn/data/attachment/album/201906/23/085446setqkshf5zk0tn2x.jpg) + +目前市场上有许多开源监控工具可用于监控 Linux 系统的性能。当系统达到指定的阈值限制时,它可以发送电子邮件警报。它可以监视 CPU 利用率、内存利用率、交换利用率、磁盘空间利用率等所有内容。 + +如果你只有很少的系统并且想要监视它们,那么编写一个小的 shell 脚本可以使你的任务变得非常简单。 + +在本教程中,我们添加了两个 shell 脚本来监视 Linux 系统上的内存利用率。当系统达到给定阈值时,它将给特定电子邮件地址发邮件。 + +### 方法-1:用 Linux Bash 脚本监视内存利用率并发送电子邮件 + +如果只想在系统达到给定阈值时通过邮件获取当前内存利用率百分比,请使用以下脚本。 + +这是个非常简单直接的单行脚本。在大多数情况下,我更喜欢使用这种方法。 + +当你的系统达到内存利用率的 80% 时,它将触发一封电子邮件。 + +``` +*/5 * * * * /usr/bin/free | awk '/Mem/{printf("RAM Usage: %.2f%\n"), $3/$2*100}' | awk '{print $3}' | awk '{ if($1 > 80) print $0;}' | mail -s "High Memory Alert" 2daygeek@gmail.com +``` + +**注意:**你需要更改电子邮件地址而不是使用我们的电子邮件地址。此外,你可以根据你的要求更改内存利用率阈值。 + +**输出:**你将收到类似下面的电子邮件提醒。 + +``` +High Memory Alert: 80.40% +``` + +我们过去添加了许多有用的 shell 脚本。如果要查看这些内容,请导航至以下链接。 + + * [如何使用 shell 脚本自动执行日常活动?][1] + +### 方法-2:用 Linux Bash 脚本监视内存利用率并发送电子邮件 + +如果要在邮件警报中获取有关内存利用率的更多信息。使用以下脚本,其中包括基于 `top` 命令和 `ps` 命令的最高内存利用率和进程详细信息。 + +这将立即让你了解系统的运行情况。 + +当你的系统达到内存利用率的 “80%” 时,它将触发一封电子邮件。 + +**注意:**你需要更改电子邮件地址而不是使用我们的电子邮件地址。此外,你可以根据你的要求更改内存利用率阈值。 + +``` +# vi /opt/scripts/memory-alert.sh + +#!/bin/sh +ramusage=$(free | awk '/Mem/{printf("RAM Usage: %.2f\n"), $3/$2*100}'| awk '{print $3}') + +if [ "$ramusage" > 20 ]; then + + SUBJECT="ATTENTION: Memory Utilization is High on $(hostname) at $(date)" + MESSAGE="/tmp/Mail.out" + TO="2daygeek@gmail.com" + echo "Memory Current Usage is: $ramusage%" >> $MESSAGE + echo "" >> $MESSAGE + echo "------------------------------------------------------------------" >> $MESSAGE + echo "Top Memory Consuming Process Using top command" >> $MESSAGE + echo "------------------------------------------------------------------" >> $MESSAGE + echo "$(top -b -o +%MEM | head -n 20)" >> $MESSAGE + echo "" >> $MESSAGE + echo "------------------------------------------------------------------" >> $MESSAGE + echo "Top Memory Consuming Process Using ps command" >> $MESSAGE + echo "------------------------------------------------------------------" >> $MESSAGE + echo "$(ps -eo pid,ppid,%mem,%Memory,cmd --sort=-%mem | head)" >> $MESSAGE + mail -s "$SUBJECT" "$TO" < $MESSAGE + rm /tmp/Mail.out +fi +``` + +最后添加一个 [cron 任务][2] 来自动执行此操作。它将每 5 分钟运行一次。 + +``` +# crontab -e +*/5 * * * * /bin/bash /opt/scripts/memory-alert.sh +``` + +**注意:**由于脚本计划每 5 分钟运行一次,因此你将在最多 5 分钟后收到电子邮件提醒(但不是 5 分钟,取决于具体时间)。 + +比如说,如果你的系统达到 8.25 的给定限制,那么你将在 5 分钟内收到电子邮件警报。希望现在说清楚了。 + +**输出:**你将收到类似下面的电子邮件提醒。 + +``` +Memory Current Usage is: 80.71% + ++------------------------------------------------------------------+ +Top Memory Consuming Process Using top command ++------------------------------------------------------------------+ +top - 12:00:58 up 5 days, 9:03, 1 user, load average: 1.82, 2.60, 2.83 +Tasks: 314 total, 1 running, 313 sleeping, 0 stopped, 0 zombie +%Cpu0 : 8.3 us, 12.5 sy, 0.0 ni, 75.0 id, 0.0 wa, 0.0 hi, 4.2 si, 0.0 st +%Cpu1 : 13.6 us, 4.5 sy, 0.0 ni, 81.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu2 : 21.7 us, 21.7 sy, 0.0 ni, 56.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu3 : 13.6 us, 9.1 sy, 0.0 ni, 77.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu4 : 17.4 us, 8.7 sy, 0.0 ni, 73.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu5 : 20.8 us, 4.2 sy, 0.0 ni, 70.8 id, 0.0 wa, 0.0 hi, 4.2 si, 0.0 st +%Cpu6 : 9.1 us, 0.0 sy, 0.0 ni, 90.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu7 : 17.4 us, 4.3 sy, 0.0 ni, 78.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +KiB Mem : 16248588 total, 5015964 free, 6453404 used, 4779220 buff/cache +KiB Swap: 17873388 total, 16928620 free, 944768 used. 6423008 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND +17163 daygeek 20 2033204 487736 282888 S 10.0 3.0 8:26.07 /usr/lib/firefox/firefox -contentproc -childID 15 -isForBrowser -prefsLen 9408 -prefMapSize 184979 -parentBuildID 20190521202118 -greomni /u+ + 1121 daygeek 20 4191388 419180 100552 S 5.0 2.6 126:02.84 /usr/bin/gnome-shell + 1902 daygeek 20 1701644 327216 82536 S 20.0 2.0 153:27.92 /opt/google/chrome/chrome + 2969 daygeek 20 1051116 324656 92388 S 15.0 2.0 149:38.09 /opt/google/chrome/chrome --type=renderer --field-trial-handle=10346122902703263820,11905758137655502112,131072 --service-pipe-token=1339861+ + 1068 daygeek 20 1104856 309552 278072 S 5.0 1.9 143:47.42 /usr/lib/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -nolisten tcp -background none -noreset -keeptty -verbose 3 +27246 daygeek 20 907344 265600 108276 S 30.0 1.6 10:42.80 /opt/google/chrome/chrome --type=renderer --field-trial-handle=10346122902703263820,11905758137655502112,131072 --service-pipe-token=8587368+ + ++------------------------------------------------------------------+ +Top Memory Consuming Process Using ps command ++------------------------------------------------------------------+ + PID PPID %MEM %CPU CMD + 8223 1 6.4 6.8 /usr/lib/firefox/firefox --new-window +13948 1121 6.3 1.2 /usr/bin/../lib/notepadqq/notepadqq-bin + 8671 8223 4.4 7.5 /usr/lib/firefox/firefox -contentproc -childID 5 -isForBrowser -prefsLen 6999 -prefMapSize 184979 -parentBuildID 20190521202118 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 8223 true tab +17163 8223 3.0 0.6 /usr/lib/firefox/firefox -contentproc -childID 15 -isForBrowser -prefsLen 9408 -prefMapSize 184979 -parentBuildID 20190521202118 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 8223 true tab + 1121 1078 2.5 1.6 /usr/bin/gnome-shell +17937 8223 2.5 0.8 /usr/lib/firefox/firefox -contentproc -childID 16 -isForBrowser -prefsLen 9410 -prefMapSize 184979 -parentBuildID 20190521202118 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 8223 true tab + 8499 8223 2.2 0.6 /usr/lib/firefox/firefox -contentproc -childID 4 -isForBrowser -prefsLen 6635 -prefMapSize 184979 -parentBuildID 20190521202118 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 8223 true tab + 8306 8223 2.2 0.8 /usr/lib/firefox/firefox -contentproc -childID 1 -isForBrowser -prefsLen 1 -prefMapSize 184979 -parentBuildID 20190521202118 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 8223 true tab + 9198 8223 2.1 0.6 /usr/lib/firefox/firefox -contentproc -childID 7 -isForBrowser -prefsLen 8604 -prefMapSize 184979 -parentBuildID 20190521202118 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 8223 true tab +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-bash-script-to-monitor-memory-utilization-usage-and-send-email/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/category/shell-script/ +[2]: https://www.2daygeek.com/crontab-cronjob-to-schedule-jobs-in-linux/ diff --git a/published/201906/20190622 Open Source Slack Alternative Mattermost Gets -50M Funding.md b/published/201906/20190622 Open Source Slack Alternative Mattermost Gets -50M Funding.md new file mode 100644 index 0000000000..8d6b7aad8a --- /dev/null +++ b/published/201906/20190622 Open Source Slack Alternative Mattermost Gets -50M Funding.md @@ -0,0 +1,91 @@ +[#]: collector: (lujun9972) +[#]: translator: (wahailin) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11014-1.html) +[#]: subject: (Open Source Slack Alternative Mattermost Gets $50M Funding) +[#]: via: (https://itsfoss.com/mattermost-funding/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Slack 的开源替代品 Mattermost 获得 5000 万美元融资 +====== + +[Mattermost][1],作为 [Slack][2] 的开源替代品,获得了 5000 万美元的 B 轮融资。这个消息极其令人振奋。 + +[Slack][3] 是一个基于云的团队内部沟通协作软件。企业、初创企业、甚至全球化的开源项目都在使用 Slack 进行同事及项目成员间的沟通。 + +[Slack 在 2019 年 6 月的估值为 200 亿美元][4],由此可见其在科技行业的巨大影响,当然也就有更多产品想与之竞争。 + +### 5000 万美元开源项目 + +![][5] + +就我个人而言,我并不知道 MatterMost 这个产品。但 [VentureBeat][6] 对这则新闻的报道,激发了我的好奇心。这次融资由 [Y Combinator][7] 的 Continuity 与一家新的投资方 BattleVentures 领投,现有投资者 Redpoint 和 S28 Captial 共同跟投。 + +在[公告][8]中,他们也提到: + +> 今天的公告中,Mattermost 成为了 YC 有史以来规模最大的 B 轮投资项目,更重要的是,它是 YC 迄今为止投资额最高的开源项目。 + +下面是摘自 VentureBeat 的报道,你可以从中了解到一些细节: + +> 本次资本注入,是继 2017 年 2 月的种子轮 350 万融资和今年 2 月份的 2000 万 A 轮融资之后进行的,并使得这家总部位于美国加州帕罗奥图Palo Alto的公司融资总额达到了约 7000 万美元。 + +如果你对他们的规划感兴趣,可以阅读[官方公告][8]。 + +尽管听起来很不错,但可能你并不知道 Mattermost 是什么。所以我们先来作个简单了解: + +### Mattermost 快览 + +![Mattermost][9] + +前面已经提到,Mattermost 是 Slack 的开源替代品。 + +乍一看,它几乎照搬了 Slack 的界面外观,没错,这就是关键所在,你将拥有你可以轻松使用的软件的开源解决方案。 + +它甚至集成了一些流行的 DevOps 工具,如 Git、自动机器人和 CI/CD。除了这些功能外,它还关注安全性和隐私。 + +同样,和 Slack 类似,它支持和多种应用程序与服务的集成。 + +听起来很有前景?我也这么认为。 + +#### 定价:企业版和团队版 + +如果你希望由 Mattermost 托管该服务(或获得优先支持),应选择其企业版。但如果你不想使用付费托管,可以下载[团队版][11],并将其安装到基于 Linux 的云服务器或 VPS 服务器上。 + +当然,我们不会在此进行深入探究。我确想在此提及的是,企业版并不昂贵。 + +![][12] + +### 总结 + +MatterMost 无疑相当出色,有了 5000 万巨额资金的注入,对于那些正在寻求安全的并能提供高效团队协作支持的开源通讯平台的用户,Mattermost 很可能成为开源社区重要的部分。 + +你觉得这条新闻怎么样?对你来说有价值吗?你是否已了解 Mattermost 是 Slack 的替代品? + +请在下面的评论中给出你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/mattermost-funding/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wahailin](https://github.com/wahailin) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://mattermost.com/ +[2]: https://itsfoss.com/slack-use-linux/ +[3]: https://slack.com +[4]: https://www.ft.com/content/98747b36-9368-11e9-aea1-2b1d33ac3271 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/mattermost-wallpaper.png?resize=800%2C450&ssl=1 +[6]: https://venturebeat.com/2019/06/19/mattermost-raises-50-million-to-advance-its-open-source-slack-alternative/ +[7]: https://www.ycombinator.com/ +[8]: https://mattermost.com/blog/yc-leads-50m-series-b-in-mattermost-as-open-source-slack-alternative/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/mattermost-screenshot.jpg?fit=800%2C497&ssl=1 +[10]: https://itsfoss.com/zettlr-markdown-editor/ +[11]: https://mattermost.com/download/ +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/mattermost-enterprise-plan.jpg?fit=800%2C325&ssl=1 diff --git a/published/201906/20190624 Raspberry Pi 4 is here.md b/published/201906/20190624 Raspberry Pi 4 is here.md new file mode 100644 index 0000000000..3aab50ec31 --- /dev/null +++ b/published/201906/20190624 Raspberry Pi 4 is here.md @@ -0,0 +1,93 @@ +[#]: collector: (lujun9972) +[#]: translator: (wahailin) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11034-1.html) +[#]: subject: (Raspberry Pi 4 is here!) +[#]: via: (https://opensource.com/article/19/6/raspberry-pi-4) +[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall) + +树莓派 4 来袭! +====== + +![](https://img.linux.net.cn/data/attachment/album/201906/29/161918icu6zrn8qrg3p38u.png) + +> 售价 35 美元起的新一代树莓派单板计算机,装载了 1.5 GHz 的 Arm 芯片,并支持双 HDMI 4K 显示,全吞吐量千兆以太网,以及更多新特性。 + +![Raspberry Pi 4 board][1] + +树莓派的最新版本树莓派 4 代,已于近日(北京时间 6 月 24 日)发布,这早于此前预期。树莓派 4 装载了 1.5 GHz 的 Arm 芯片和 VideoCore GPU,支持双 4K 显示输出,并引入了 USB 3 接口和全吞吐量千兆以太网,以及最高可达 4G 的多个可选 RAM 配置。 + +![Raspberry Pi 4 case][2] + +树莓派 4 是非常强大的单板计算机,其起始售价依然是 35 美元。起始版的 RAM 配置为 1G,2G RAM 配置的树莓派售价为 45 美元,顶配 4G RAM 的树莓派售价为 55 美元,采用这种差异化定价对树莓派尚属首次。 + +树莓派 4 的详细配置如下: + + * 1.5 GHz 4 核心 64 位博通 BCM2711 A72 CPU + * VideoCore VI GPU + * 千兆以太网端口 + * 1GB/2GB/4GB LPDDR4 SDRAM 内存 + * 双 Micro-HDMI 接口 + * 两个 USB 3 接口 + * 两个 USB 2 接口 + * 双频(2.4 GHz 和 5 GHz)无线网络 + * 蓝牙 5.0 + * USB Type C 电源接口 + * CSI 摄像头接口 + * DSI 显示接口 + * MicroSD 卡槽 + * PoE(以太网供电)供电针 + * 完全兼容早期的树莓派产品 + +### USB 接口和网络 + +树莓派 4 板载了更高速率的 USB 3 接口;它通过 Type C 接口供电,并提供两个 USB 3 接口和两个 USB 2 接口。USB 3 接口可以为连接的硬盘和其它外部设备提供更高的速率。 + +![Raspberry Pi 4 USBs][3] + +基于 BCM2835 的树莓派 1 到 3 代的芯片只有一个本地 USB 接口,并且没有以太网接口,因而需要使用板子的 USB 集线器给出更多的 USB 接口和以太网接口。树莓派 3B+ 增加了一个专用的局域网(LAN)芯片,装载了千兆以太网,但它受到 USB 2 速率的限制。树莓派 4 板载了专门的千兆以太网,并且由于它不再受到 USB 速率的限制,网络速度要快得多。 + +树莓派 4 采用了 3B+ 中已有的技术 —— 该技术使得树莓派 3B+ 成为了第一个带有双频无线网络的单板计算机,即可以同时连接 2.4 GHz 和 5 GHz 频率的网络。 + +### 显示 + +设计第一代树莓派时,其 CPU 和 GPU 性能的平衡大大偏向于 GPU。VideoCore IV 是一个非常强大的图形处理器,支持全高清 1080p 多媒体的处理,这就是为什么树莓派一直作为家庭媒体中心而广受欢迎的原因。树莓派 2 代在某种程度上进行了权衡修改,并将 CPU 的性能进行提升,将树莓派从单核发展成四核 ARM 芯片。而树莓派 4 代将 CPU 和 GPU 的性能都进行了大幅提升。新的 VideoCore VI GPU 支持 4K 视频,并允许通过板子上的两个 Micro HDMI 端口(板子特意保持了和旧有型号相同的尺寸)进行双显示输出,这里要用一个适配器或 Micro HDMI 转 full HDMI 的转换线连接到 HDMI 屏幕。 + +当你需要同时浏览多个窗口时,需要用到更多的物理显示屏,双显示的好处在此时就得到了绝佳体现。如果你正在编程,你可能会在其中一个屏幕上编写代码,构建网站或应用,而在另一个屏幕上查看数据库、Web 浏览器、电子邮件或其他内容。这是树莓派首次可以不必将开发局限在一台显示器上,从而可以让你在需要时,在不同的屏幕上构建具有不同内容的基于树莓派的项目。 + +该树莓派还有一个显示器串行接口(DSI),用于驱动另一个特殊的显示-这里并非指另一个监视器本身,而是通过一根挠性电缆连接的官方树莓派触摸屏显示器。 + +### Raspbian Buster + +树莓派 4 发布后,紧接着更新了基于 Debian 的系统 Raspbian Buster,而新的树莓派对 OpenGL ES 3 的支持,使我们在 Raspbian Buster 上为树莓派 4 开发任意软件成为可能。Buster 对界面进行了一些调整,并对很多软件进行了升级,其中包括 Python3.7。 + +![Raspbian Buster][4] + +### 开源图形驱动程序 + +在过去的五年中,Eric Anholt 一直致力于为树莓派编写开源图形驱动程序。现在,Raspbian 可以使用这个驱动程序加速树莓派上的 Web 浏览、桌面图形和 3D 应用,这取代了以前需要的大量闭源代码。非常感谢 Eric 和博通的贡献。 + +按之前预计,树莓派 4 将于明年完成,但由于芯片设计比预期更早投入生产,树莓派 4 因而可以提早到现在发布。 + +* * * + +树莓派 4 已经开始发售,你会选择哪个型号呢?在评论中说出你的想法吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/raspberry-pi-4 + +作者:[Ben Nuttall][a] +选题:[lujun9972][b] +译者:[wahailin](https://github.com/wahailin) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberry-pi-4_lead.jpg?itok=2bkk43om (Raspberry Pi 4 board) +[2]: https://opensource.com/sites/default/files/uploads/raspberry-pi-4-case.jpg (Raspberry Pi 4 case) +[3]: https://opensource.com/sites/default/files/uploads/raspberry-pi-4-usb.jpg (Raspberry Pi 4 USBs) +[4]: https://opensource.com/sites/default/files/uploads/raspbian-buster.png (Raspbian Buster) diff --git a/published/201906/20190624 Using i3 with multiple monitors.md b/published/201906/20190624 Using i3 with multiple monitors.md new file mode 100644 index 0000000000..33eeeac1e2 --- /dev/null +++ b/published/201906/20190624 Using i3 with multiple monitors.md @@ -0,0 +1,192 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11031-1.html) +[#]: subject: (Using i3 with multiple monitors) +[#]: via: (https://fedoramagazine.org/using-i3-with-multiple-monitors/) +[#]: author: (Adam Šamalík https://fedoramagazine.org/author/asamalik/) + +将 i3 与多个显示器配合使用 +====== + +![][1] + +你在 Linux 工作站上使用多个显示器吗?一次看到很多东西可能是有益的。但在我们的工作中通常有比实际显示器更多的窗口 —— 这是一件好事,因为一次看到太多东西可能会分散注意力。因此能够切换我们在单个显示器上看到的内容似乎很重要。 + +让我们来看看 i3,它是一个流行的平铺窗口管理器,可以与多个显示器配合使用。并且有许多其他窗口管理器没有的便利功能,它能够独立地在各个显示器上切换工作区。 + +### 快速介绍 i3 + +大约三年前,[Fedora Magazine 已经写了一篇关于 i3 的文章][2]。这是有史以来最受欢迎的文章之一!虽然情况并非总是如此,但 i3 非常稳定,而且那篇文章如今也很准确。所以,这次不会重复太多内容,本篇只涵盖了让 i3 启动和运行的极少内容,如果你是 i3 的新手,想要了解更多基础知识的话,欢迎你继续阅读。 + +要在系统上安装 i3,请运行以下命令: + +``` +$ sudo dnf install i3 +``` + +完成后,注销,然后在登录屏幕上选择 i3 作为窗口管理器,然后重新登录。 + +当你第一次运行 i3 时,系统会询问你是否要继续进行自动配置 —— 在此处回答是。之后,你将被要求选择 “mod 键”。如果你不确定,只需接受默认值,即将 Windows/Super 键设置为 mod 键。你将主要使用此键用于窗口管理器中的快捷方式。 + +此时,你应该在底部看到一个小条和一个空白屏幕。我们来看看一些基本的快捷方式。 + +打开终端: + +``` +$mod + enter +``` + +切换到第二个工作区: + +``` +$mod + 2 +``` + +通过以下两个步骤打开 firefox,首先: + +``` +$mod + d +``` + +然后输入 “firefox” 并按回车键。 + +将其移动到第一个工作区: + +``` +$mod + shift + 1 +``` + +切换到第一个工作区: + +``` +$mod + 1 +``` + +此时,你将并排看到一个终端和一个 firefox 窗口。要关闭窗口,请按: + +``` +$mod + shift + q +``` + +还有更多的快捷方式,但这些足够让你开始使用 i3。 + +要退出 i3(并退出登录)按: + +``` +$mod + shift + e +``` + +然后在右上角使用鼠标确认。 + +### 同时让多个屏幕工作 + +现在我们已经启动并运行了 i3,让我们把所有这些屏幕都用到! + +为此,我们需要使用命令行,因为 i3 非常轻量级,并且没有 GUI 来管理其他屏幕。如果这听起来很难也不用担心,它实际上非常简单! + +我们将使用的命令称为 `xrandr`。如果你的系统上没有 `xrandr`,请运行以下命令安装: + +``` +$ sudo dnf install xrandr +``` + +当它安装完毕后,让我们继续运行它: + +``` +$ xrandr +``` + +输出列出了所有可用输出设备,并通过显示支持的分辨率指示哪些输出连接了屏幕(通过电缆连接的显示器)。好消息是,我们不需要关心使它们工作的分辨率。 + +这个例子显示了笔记本电脑的主屏幕(名为 eDP1),以及连接到 HDMI-2 输出的第二个显示器,它位于笔记本电脑的右侧。要打开它,请运行以下命令: + +``` +$ xrandr --output HDMI-2 --auto --right-of eDP1 +``` + +就是这样!你的屏幕现已激活。 + +![第二个屏幕激活。截屏上显示命令与文章中略有不同,它设置了更小的分辨率以使截屏适合阅读][3] + +### 在多个屏幕上管理工作区 + +在多个屏幕上切换工作区和创建新工作区非常类似于只有一个屏幕的情况。新工作区会在当前处于活动状态(鼠标光标所在位置)的屏幕上创建。 + +因此,要切换到特定工作区(或在不存在的情况下创建新工作区),请按: + +``` +$mod + NUMBER +``` + +你可以独立切换各个显示器上的工作区! + +![工作空间 2 在左侧屏幕,工作空间 4 在右侧屏幕][4] + +![左侧屏幕切换为工作空间 3,右侧屏幕仍为工作空间 4][5] + +![右侧屏幕切换为工作空间 5,左侧屏幕仍为空间空间 3][6] + +### 在显示器之间移动工作区 + +我们可以通过以下命令将窗口移动到不同的工作区: + +``` +$mod + shift + NUMBER +``` + +我们也可以将工作区移动到不同的屏幕。但是,此操作没有默认快捷方式,因此我们必须先创建它。 + +要创建自定义快捷方式,你需要在你选择的文本编辑器中打开配置文件(本文使用 `vim`): + +``` +$ vim ~/.config/i3/config +``` + +并将以下行添加到配置文件的最底部: + +``` +# Moving workspaces between screens +bindsym $mod+p move workspace to output right +``` + +保存、关闭并重新加载以使配置生效,按下: + +``` +$mod + shift + r +``` + +现在你可以将活跃的工作区移动到第二个显示器: + +``` +$mod + p +``` + +![打开火狐浏览器的工作空间 2 在左侧][7] + +![打开火狐浏览器的工作空间 2 移动到第二个屏幕][8] + +就是这些了!享受你的新多显示器体验,并了解更多 i3,欢迎阅读 Fedora Magazine 上之前关于 i3 的文章,或者查看官方 i3 文档。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/using-i3-with-multiple-monitors/ + +作者:[Adam Šamalík][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/asamalik/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/06/i3-title-816x345.jpg +[2]: https://fedoramagazine.org/getting-started-i3-window-manager/ +[3]: https://fedoramagazine.org/wp-content/uploads/2019/06/0-1-1024x384.png +[4]: https://fedoramagazine.org/wp-content/uploads/2019/06/1-1-1024x384.png +[5]: https://fedoramagazine.org/wp-content/uploads/2019/06/1-2-1024x384.png +[6]: https://fedoramagazine.org/wp-content/uploads/2019/06/1-3-1024x384.png +[7]: https://fedoramagazine.org/wp-content/uploads/2019/06/2-1-1024x384.png +[8]: https://fedoramagazine.org/wp-content/uploads/2019/06/2-2-1024x384.png diff --git a/published/201906/20190628 FreeDOS turns 25 years old- An origin story.md b/published/201906/20190628 FreeDOS turns 25 years old- An origin story.md new file mode 100644 index 0000000000..bf11ae7964 --- /dev/null +++ b/published/201906/20190628 FreeDOS turns 25 years old- An origin story.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11033-1.html) +[#]: subject: (FreeDOS turns 25 years old: An origin story) +[#]: via: (https://opensource.com/article/19/6/freedos-anniversary) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) + +25 岁的 FreeDOS:起源故事 +====== + +> 操作系统的历史是开发人员共同造物的开源软件模型的很好例子。 + +![FreeDOS fish logo and command prompt on computer](https://img.linux.net.cn/data/attachment/album/201906/29/154802szbavz4a0fa8a27f.jpg) + +6 月 29 日是 [FreeDOS][2] 25 周年的日子。不管对于哪个开源软件项目来说,这都是一个重要的里程碑,我为过去这 1/4 个世纪来我们在这方面所做的工作感到自豪。我也为我们如何构建 FreeDOS 感到自豪,因为它是开源软件模型如何工作的一个很好的例子。 + +在它的那个时代,MS-DOS 是一个功能强大的操作系统。自从我的父母用新的 IBM 机器取代了老化的 Apple II 计算机以来,我已经使用 DOS 多年了。MS-DOS 提供了一个灵活的命令行,我非常喜欢它,它可以方便地操作我的文件。多年来,我学会了如何在 C 中编写自己的实用程序,以进一步扩展其命令行功能。 + +大约在 1994 年,微软宣布其下一代的 Windows 将取消 MS-DOS。但我喜欢 DOS,即使我已经开始迁移到 Linux,我仍然会启动到 MS-DOS 来运行一些 Linux 尚未拥有的应用程序。 + +我想,如果我们想留下 DOS,我们需要自己编写一个。FreeDOS 就是这样诞生的。 + +1994 年 6 月 29 日,我向 Usenet 上的 comp.os.msdos.apps 新闻组发表了关于我的想法的一个小小公告: + +> PD-DOS 项目公告: +> +> 几个月前,我发布了有关启动公共域(PD)版本 DOS 的文章。当时对此的普遍支持很强烈,很多人都赞同:“开始编写吧!”所以,我… +> +> 宣布开发 PD-DOS 的首次尝试。我写了一个“清单”来描述这样的一个项目的目标和工作大纲,以及一个“任务列表”,它准确地显示了需要编码开发的内容。我会在这里发布,然后讨论。 +> + +虽然我宣布该项目为 PD-DOS(“公共领域”的意思,缩写是为了模仿 IBM 的“PC-DOS”),但我们很快将名称改为 Free-DOS,再后来又改为 FreeDOS。 + +我马上开始开发它。首先,我分享了我编写的用于扩展 DOS 命令行功能的实用程序。它们中的许多程序都重现了 MS-DOS 功能,包括 `CLS`、`DATE`、`DEL`、`FIND`、`HELP` 和 `MORE`。有些是我从 Unix 借来的新功能,比如 `TEE` 和 `TRCH`(Unix 的 `tr` 的简单实现)。我贡献了十几个 FreeDOS 工具。 + +通过分享我的实用程序,我给了其他开发人员一个起点。通过在 [GNU 通用公共许可证][3](GNU GPL)下共享我的源代码,我隐含地允许其他人添加新功能并修复错误。 + +看到 FreeDOS 开始成型的其他开发人员联系了我并希望提供帮助。Tim Norman 是第一个人,Tim 自愿编写命令行 shell(`COMMAND.COM`,后来命名为 `FreeCOM`)。其他人贡献了复制或扩展了 DOS 命令行的实用程序。 + +我们尽快发布了第一个 alpha 版本。在宣布了 FreeDOS 后不到三个月,我们就有了一个集合了我们所编写的功能的 Alpha 1 发行版。当我们发布 Alpha 5 时,FreeDOS 已经拥有了 60 多个实用程序。FreeDOS 包含了 MS-DOS 中从未想过的功能,包括通过 PPP 拨号驱动程序实现的互联网连接,以及使用主 VGA 监视器和辅助单色监视器的双显示器支持。 + +新的开发人员加入了该项目,我们很欢迎他们。到 1998 年 10 月,感谢 Pat Villani,FreeDOS 有了一个可以工作的内核。FreeDOS 还提供了许多新功能,不仅带来了与 MS-DOS 的同等性,而且超越了 MS-DOS,包括 ANSI 支持和类似 Unix lpr 的打印后台处理程序。 + +你可能熟悉其他的里程碑版本。我们继续向 1.0 版本迈进,终于在 2006 年 9 月发布了 FreeDOS 1.0,在 2012 年 1 月发布了 FreeDOS 1.1,在 2016 年 12 月发布了 FreeDOS 1.2。而 MS-DOS 很久以前就停止了开发,因此我们在 1.0 发布之后不需要经常更新了。 + +如今,FreeDOS 已经是一个非常现代的 DOS。我们已经超越了“经典 DOS”,现在 FreeDOS 拥有许多开发工具,如编译器、汇编器和调试器。除了普通的 DOS Edit 编辑器之外,我们还有许多编辑器,包括 Fed、Pico、TDE 以及 Emacs 和 Vi 的一个版本。FreeDOS 支持网络,甚至还提供简单的图形 Web 浏览器(Dillo)。我们有大量的新工具,包括许多可以让 Linux 用户感到熟悉的实用工具。 + +正因为开发人员的共同创造,FreeDOS 才走到如今。本着开源软件的精神,我们通过修复错误和添加新功能为彼此的工作做出了贡献。我们将用户视为共同开发者;我们总能找到方法来吸引贡献者,无论是编写代码还是编写文档。我们基于优点达成共识。如果这听起来很熟悉,那是因为这些是开源软件的核心价值:透明度、协作、尽早发布、经常发布、精英管理和社区。这就是[开源方式][4]! + +我鼓励你下载 FreeDOS 1.2 并尝试一下。 + +### 更多资源 + + * [FreeDOS 官方网站][2] + * [FreeDOS wiki][5] + * [下载 FreeDOS 1.2][6] + * [FreeDOS 的免费电子书][7] + * [FreeDOS 的简单介绍][8] + * [FreeDOS 起源与革命][9] + * [4 个 FreeDOS 的有趣事实][10] + * [如何使用 FreeDOS 升级你的系统 BIOS][11] + * [庆祝 FreeDOS 24 岁生日:有用的命令速查表][12] + * [如何在 Linux 中运行 DOS 程序][13] + * [让 DOS 活到现在并通过开源来起步][14] + * [在树莓派上运行 DOS][15] + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/freedos-anniversary + +作者:[Jim Hall][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jim-hall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/freedos-fish-laptop-color.png?itok=vfv_Lpph (FreeDOS fish logo and command prompt on computer) +[2]: https://www.freedos.org/ +[3]: https://www.gnu.org/licenses/licenses.en.html +[4]: https://opensource.com/open-source-way +[5]: http://wiki.freedos.org/ +[6]: https://www.freedos.org/download/ +[7]: https://www.freedos.org/ebook/ +[8]:https://linux.cn/article-9983-1.html +[9]: https://opensource.com/article/17/10/freedos +[10]: https://opensource.com/article/17/6/freedos-still-cool-today +[11]: https://opensource.com/article/17/6/upgrade-bios-freedos +[12]: https://opensource.com/article/18/6/freedos-commands-cheat-sheet +[13]: https://linux.cn/article-9014-1.html +[14]: https://opensource.com/life/16/9/interview-jim-hall-freedos +[15]: https://linux.cn/article-9544-1.html diff --git a/published/20190603 How many browser tabs do you usually have open.md b/published/20190603 How many browser tabs do you usually have open.md new file mode 100644 index 0000000000..9366464b0c --- /dev/null +++ b/published/20190603 How many browser tabs do you usually have open.md @@ -0,0 +1,44 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11322-1.html) +[#]: subject: (How many browser tabs do you usually have open?) +[#]: via: (https://opensource.com/article/19/6/how-many-browser-tabs) +[#]: author: (Lauren Pritchett https://opensource.com/users/lauren-pritchett/users/sarahwall/users/ksonney/users/jwhitehurst) + +你通常打开多少个浏览器标签页? +====== + +> 外加一些提高浏览器效率的技巧。 + +![Browser of things][1] + +这里有一个别有用心的问题:你通常一次打开多少个浏览器标签页?你是否有多个窗口,每个窗口都有多个标签页?或者你是一个极简主义者,一次只打开两个标签页。另一种选择是将一个 20 个标签页的浏览器窗口移动到另一个屏幕上去,这样在处理特定任务时它就不会碍事了。你的处理方法在工作、个人和移动浏览器之间有什么不同吗?你的浏览器策略是否与你的[工作习惯][2]有关? + +### 4 个提高浏览器效率的技巧 + +1. 了解浏览器快捷键以节省单击。无论你使用 Firefox 还是 Chrome,都有很多快捷键可以让你方便地执行包括切换标签页在内的某些功能。例如,Chrome 可以很方便地打开一个空白的谷歌文档。使用快捷键 `Ctrl + t` 打开一个新标签页,然后键入 `doc.new` 即可。电子表格、幻灯片和表单也可以这样做。 +2. 用书签文件夹组织最频繁的任务。当开始一项特定的任务时,只需打开文件夹中的所有书签 (`Ctrl + 点击`),就可以快速地从列表中勾选它。 +3. 使用正确的浏览器扩展。成千上万的浏览器扩展都声称可以提高工作效率。在安装之前,确定你不是仅仅在屏幕上添加更多的干扰而已。 +4. 使用计时器减少看屏幕的时间。无论你使用的是老式的 egg 定时器还是花哨的浏览器扩展,都没有关系。为了防止眼睛疲劳,执行 20/20/20 规则。每隔 20 分钟,离开屏幕 20 秒,看看 20 英尺以外的东西。 + +参加我们的投票来分享你一次打开多少个浏览器标签。请务必在评论中告诉我们你最喜欢的浏览器技巧。 + +生产力有两个组成部分——做正确的事情和高效地做那些事情…… + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/how-many-browser-tabs + +作者:[Lauren Pritchett][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lauren-pritchett/users/sarahwall/users/ksonney/users/jwhitehurst +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_desktop_website_checklist_metrics.png?itok=OKKbl1UR (Browser of things) +[2]: https://enterprisersproject.com/article/2019/1/5-time-wasting-habits-break-new-year diff --git a/published/20190603 How to stream music with GNOME Internet Radio.md b/published/20190603 How to stream music with GNOME Internet Radio.md new file mode 100644 index 0000000000..3387da566b --- /dev/null +++ b/published/20190603 How to stream music with GNOME Internet Radio.md @@ -0,0 +1,58 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11325-1.html) +[#]: subject: (How to stream music with GNOME Internet Radio) +[#]: via: (https://opensource.com/article/19/6/gnome-internet-radio) +[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss/users/r3bl) + +如何使用 GNOME 的 Internet Radio 播放流音乐 +====== + +> 如果你正在寻找一个简单、直观的界面,让你可以播放流媒体,可以尝试一下 GNOME 的 Internet Radio 插件。 + +![](https://img.linux.net.cn/data/attachment/album/201909/10/114049ppzxeug7xx7jm7ko.jpg) + +网络广播是收听世界各地电台节目的好方法。和许多开发人员一样,我喜欢在编写代码时打开电台。你可以使用 [MPlayer][2] 或 [mpv][3] 等终端媒体播放器收听网络广播,我就是这样通过 Linux 命令行收听广播的。但是,如果你喜欢使用图形用户界面 (GUI),你可以尝试一下 [GNOME Internet Radio][4],这是一个用于 GNOME 桌面的漂亮插件。你可以在包管理器中找到它。 + +![GNOME Internet Radio plugin][5] + +使用图形桌面操作系统收听网络广播通常需要启动一个应用程序,比如 [Audacious][6] 或 [Rhythmbox][7]。它们有很好的界面,很多选项,以及很酷的音频可视化工具。但如果你只想要一个简单、直观的界面播放你的流媒体,GNOME Internet Radio 就是你的选择。 + +安装之后,工具栏中会出现一个小图标,你可以在其中进行所有配置和管理。 + +![GNOME Internet Radio icons][8] + +我做的第一件事是进入设置菜单。我启用了以下两个选项:显示标题通知和显示音量调整。 + +![GNOME Internet Radio Settings][9] + +GNOME Internet Radio 包含一些预置的电台,并且很容易添加其他电台。只需点击(“+”)符号即可。你需要输入一个频道名称,它可以是你喜欢的任何内容(包括电台名称)和电台地址。例如,我喜欢听 Synthetic FM。我输入名称(Synthetic FM),以及流地址(https://mediaserv38.live-streams.nl:2199/tunein/syntheticfm.pls)。 + +然后单击流旁边的星号将其添加到菜单中。 + +不管你听什么音乐,不管你选择什么类型,很明显,程序员需要他们的音乐!GNOME Internet Radio 插件使你可以轻松地让你排好喜爱的网络电台。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/gnome-internet-radio + +作者:[Alan Formy-Duval][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alanfdoss/users/r3bl +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/video_editing_folder_music_wave_play.png?itok=-J9rs-My (video editing dashboard) +[2]: https://opensource.com/article/18/12/linux-toy-mplayer +[3]: https://mpv.io/ +[4]: https://extensions.gnome.org/extension/836/internet-radio/ +[5]: https://opensource.com/sites/default/files/uploads/packagemanager_s.png (GNOME Internet Radio plugin) +[6]: https://audacious-media-player.org/ +[7]: https://help.gnome.org/users/rhythmbox/stable/ +[8]: https://opensource.com/sites/default/files/uploads/titlebaricons.png (GNOME Internet Radio icons) +[9]: https://opensource.com/sites/default/files/uploads/gnomeinternetradio_settings.png (GNOME Internet Radio Settings) diff --git a/published/20190628 How to Install and Use R on Ubuntu.md b/published/20190628 How to Install and Use R on Ubuntu.md new file mode 100644 index 0000000000..787e359848 --- /dev/null +++ b/published/20190628 How to Install and Use R on Ubuntu.md @@ -0,0 +1,196 @@ +[#]: collector: (lujun9972) +[#]: translator: (guevaraya) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11331-1.html) +[#]: subject: (How to Install and Use R on Ubuntu) +[#]: via: (https://itsfoss.com/install-r-ubuntu/) +[#]: author: (Sergiu https://itsfoss.com/author/sergiu/) + +如何在 Ubuntu 上安装和使用 R 语言 +====== + +> 这个教程指导你如何在 Ubuntu 上安装 R 语言。你也将同时学习到如何在 Ubuntu 上用不同方法运行简单的 R 语言程序。 + +[R][1],和 Python 一样,它是在统计计算和图形处理上最常用的编程语言,易于处理数据。随着数据分析、数据可视化、数据科学(机器学习热)的火热化,对于想深入这一领域的人来说,它是一个很好的工具。 + +R 语言的优点是它的语法非常简练,你可以找到它的很多实际使用的教程或指南。 + +本文将介绍包含如何在 Ubuntu 下安装 R 语言,也会介绍在 Linux 下如何运行第一个 R 程序。 + +![][2] + +### 如何在 Ubuntu 上安装 R 语言 + +R 默认在 Ubuntu 的软件库里。用以下命令很容易安装: + +``` +sudo apt install r-base +``` + +请注意这可能会安装一个较老的版本。在我写这篇文字的时候,Ubuntu 提供的是 3.4,但是最新的是3.6。 + +*我建议除非你必须使用最新版本,否则直接使用 Ubuntu 的配套版本。* + +#### 如何在 Ubuntu 上安装最新 3.6 版本的 R 环境 + +如果想安装最新的版本(或特殊情况指定版本),你必须用 [CRAN][3](Comprehensive R Archive Network)。这个是 R 最新版本的镜像列表。 + +如需获取 3.6 的版本,需要添加镜像到你的源索引里。我已经简化其命令如下: + +``` +sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran35/" +``` + +下面你需要添加密钥到服务器中: + +``` +sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 +``` + +然后更新服务器信息并安装R环境: + +``` +sudo apt update +sudo apt install r-base +``` + +就这样安装完成。 + +### 如何在 Ubuntu 下使用 R 语言编程 + +R 的用法多样,我将介绍运行多个运行 R 语言的方式。 + +#### R 语言的交互模式 + +安装了 R 语言后,你可以在控制台上直接运行: + +``` +R +``` + +这样会打开交互模式: + +![R Interactive Mode][5] + +R 语言的控制台与 Python 和 Haskell 的交互模式很类似。你可以输入 R 命令做一些基本的数学运算,例如: + +``` +> 20+40 +[1] 60 + +> print ("Hello World!") +[1] "Hello World!" +``` + +你可以测试绘图: + +![R Plotting][6] + +如果想退出可以用 `q()`或按下 `CTRL+c`键。接着你会被提示是否保存工作空间镜像;工作空间是创建变量的环境。 + +#### 用 R 脚本运行程序 + +第二种运行 R 程序的方式是直接在 Linux 命令行下运行。你可以用 `RScript` 执行,它是一个包含 `r-base` 软件包的工具。 + +首先,你需要用你在 [Linux 下常用的编辑器][7]保存 R 程序到文件。文件的扩展名必须是 `.r`。 + +下面是一个打印 “Hello World” 的 R 程序。你可以保存其为 `hello.r`。 + +``` +print("Hello World!") +a <- rnorm(100) +plot(a) +``` + +用下面命令运行 R 程序: + +``` +Rscript hello.r +``` + +你会得到如下输出结果: + +``` +[1] "Hello World!" +``` + +结果将会保存到当前工作目录,文件名为 `Rplots.pdf`: + +![Rplots.pdf][8] + +小提示:`Rscript` 默认不会加载 `methods` 包。确保在脚本中[显式加载][9]它。 + +#### 在 Ubuntu 下用 RStudio 运行 R 语言 + +最常见的 R 环境是 [RStudio][10],这是一个强大的跨平台的开源 IDE。你可以用 deb 文件在 Ubuntu 上安装它。下载 deb 文件的链接如下。你需要向下滚动找到 Ubuntu 下的 DEB 文件。 + +- [下载 Ubuntu 的 Rstudio][12] + +下载了 DEB 文件后,直接点击安装。 + +下载后从菜单搜索启动它。程序主界面会弹出如下: + +![RStudio 主界面][13] + +现在可以看到和 R 命令终端一样的工作台。 + +创建一个文件:点击顶栏 “File” 然后选择 “New File > Rscript”(或 `CTRL+Shift+n`): + +![RStudio 新建文件][15] + +按下 `CTRL+s` 保存文件选择路径和命名: + +![RStudio 保存文件][16] + +这样做了后,点击 “Session > Set Working Directory > To Source File Location” 修改工作目录为你的脚本路径: + +![RStudio 工作目录][17] + +现在一切准备就绪!编写代码然后点击运行。你可以在控制台和图形窗口看到结果: + +![RStudio 运行][18] + +### 结束语 + +这篇文章中展示了如何在 Ubuntu 下使用 R 语言。包含了以下几个方面:R 控制台 —— 可用于测试,Rscript —— 终端达人操作,RStudio —— 你想要的 IDE。 + +无论你正在从事数据科学或只是热爱数据统计,作为一个数据分析的完美工具,R 都是一个比较好的编程装备。 + +你想使用 R 吗?你入门了吗?让我们了解你是如何学习 R 的以及为什么要学习 R! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-r-ubuntu/ + +作者:[Sergiu][a] +选题:[lujun9972][b] +译者:[guevaraya](https://github.com/guevaraya) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/sergiu/ +[b]: https://github.com/lujun9972 +[1]: https://www.r-project.org/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/install-r-on-ubuntu.jpg?resize=800%2C450&ssl=1 +[3]: https://cran.r-project.org/ +[4]: https://itsfoss.com/bootable-windows-usb-linux/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/r_interactive_mode.png?fit=800%2C516&ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/r_plotting.jpg?fit=800%2C434&ssl=1 +[7]: https://itsfoss.com/best-modern-open-source-code-editors-for-linux/ +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/rplots_pdf.png?fit=800%2C539&ssl=1 +[9]: https://www.dummies.com/programming/r/how-to-install-load-and-unload-packages-in-r/ +[10]: https://www.rstudio.com/ +[11]: https://itsfoss.com/install-deb-files-ubuntu/ +[12]: https://www.rstudio.com/products/rstudio/download/#download +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_home.jpg?fit=800%2C603&ssl=1 +[14]: https://itsfoss.com/python-setup-linux/ +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_new_file.png?fit=800%2C392&ssl=1 +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_save_file.png?fit=800%2C258&ssl=1 +[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_working_directory.png?fit=800%2C394&ssl=1 +[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_run.jpg?fit=800%2C626&ssl=1 +[19]: https://i1.wp.com/images-na.ssl-images-amazon.com/images/I/51oIJTbUlnL._SL160_.jpg?ssl=1 +[20]: https://www.amazon.com/Learn-R-Day-Steven-Murray-ebook/dp/B00GC2LKOK?SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B00GC2LKOK (Learn R in a Day) +[21]: https://www.amazon.com/Learn-R-Day-Steven-Murray-ebook/dp/B00GC2LKOK?SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B00GC2LKOK (Buy on Amazon) + diff --git a/published/201907/20171226 Top 10 Microsoft Visio Alternatives for Linux.md b/published/201907/20171226 Top 10 Microsoft Visio Alternatives for Linux.md new file mode 100644 index 0000000000..d146b9bd16 --- /dev/null +++ b/published/201907/20171226 Top 10 Microsoft Visio Alternatives for Linux.md @@ -0,0 +1,227 @@ +10 个 Linux 中最好的 Visio 替代品 +====== + +> 如果你正在 Linux 中寻找一个好的 Visio 查看器,这里有一些可以在 Linux 中使用的微软 Visio 的替代方案。 + +[微软 Visio][1] 是创建或生成关键任务图和矢量表示的绝佳工具。虽然它可能是制作平面图或其他类型图表的好工具 —— 但它既不是免费的,也不是开源的 + +此外,微软 Visio 不是一个独立的产品。它与微软 Office 捆绑在一起。我们过去已经看过 [MS Office 的开源替代品][2]。今天我们将看看你可以在 Linux 上使用哪些工具代替 Visio。 + +### 适用于 Linux 的最佳 微软 Visio 备选方案 + +![用于 Linux 的微软 Visio 备选方案][4] + +此处为强制性免责声明。该列表不是排名。排名第三的产品并不比排名第六的好。 + +我还提到了两个可以从 Web 界面使用的非开源 Visio 软件。 + +| 软件 | 类型 | 许可证类型 | +| --- | --- | --- | +| [LibreOffice Draw][6] | 桌面软件 | 自由开源 | +| [OpenOffice Draw][10] | 桌面软件 | 自由开源 | +| [Dia][12] | 桌面软件 | 自由开源 | +| [yED Graph Editor][14] | 桌面和基于 Web | 免费增值 | +| [Inkscape][16] | 桌面软件 | 自由开源 | +| [Pencil][18] | 桌面和基于 Web | 自由开源 | +| [Graphviz][20] | 桌面软件 | 自由开源 | +| [darw.io][22] | 桌面和基于 Web | 自由开源 | +| [Lucidchart][24] | 基于 Web | 免费增值 | +| [Calligra Flow][27] | 桌面软件 | 自由开源 | + + +### 1、LibreOffice Draw + +![][5] + +LibreOffice Draw 模块是微软 Visio 的最佳开源替代方案之一。在它的帮助下,你可以选择制作一个想法的速写或一个复杂的专业平面布置图来展示。流程图、组织结构图、网络图、小册子、海报等等!所有这些都不需要花一分钱。 + +好的是它与 LibreOffice 捆绑在一起,默认情况下安装在大多数 Linux 发行版中。 + +#### 主要功能概述: + + * 用于制作宣传册/海报的样式和格式工具 + * Calc 数据可视化 + * PDF 文件编辑功能 + * 通过操作图库中的图片来创建相册 + * 灵活的绘图工具类似于 微软 Visio (智能连接器,尺寸线等)的工具 + * 支持 .VSD 文件(打开) + +官网:[LibreOffice Draw][6] + +### 2、Apache OpenOffice Draw + +![][7] + +很多人都知道 OpenOffice(LibreOffice 项目最初就是基于它的),但他们并没有真正意识到 Apache OpenOffice Draw 可以作为微软 Visio 的替代方案。但事实上,它是另一个令人惊奇的开源图表软件工具。与 LibreOffice Draw 不同,它不支持编辑 PDF 文件,但它为任何类型的图表创建提供了绘图工具。 + +这只是个警告。仅当你的系统中已经有 OpenOffice 时才使用此工具。这是因为[安装 OpenOffice][8] 是一件痛苦的事情,而且它已经[不再继续开发][9]。 + +#### 主要功能概述: + + * 快速创建 3D 形状控制器 + * 创建作品的 flash 版本(.swf) + * 样式和格式工具 + * 与微软 Visio 类似的灵活绘图工具(智能连接器、尺寸线等) + +官网:[Apache OpenOffice Draw][10] + +### 3、Dia + +![][11] + +Dia 是另一个有趣的开源工具。它可能不像前面提到的那样处于积极开发之中。但是,如果你正在寻找一个自由而开源的替代微软 Visio 的简单而体面的图表,那么 Dia 可能是你的选择。这个工具可能唯一让你失望的地方就是它的用户界面。除此之外,它还允许你为复杂的图使用强大的工具(但它看起来可能不太好 —— 所以我们建议你用于更简单的图)。 + +#### 主要功能概述: + + * 它可以通过命令行使用 + * 样式和格式工具 + * 用于自定义形状的形状存储库 + * 与微软 Visio 类似的绘图工具(特殊对象、网格线、图层等) + * 跨平台 + +官网:[Dia][12] + +### 4、yED Graph Editor + +[视频](https://youtu.be/OmSTwKw7dX4) + +是最受欢迎的免费的微软 Visio 替代方案之一。如果你对它是一个免费软件而不是开源项目有些担心,你仍然可以通过 web 浏览器免费使用 [yED 的实时编辑器][13]。如果你想用一个非常易于使用的界面快速绘制图表,这是最好的建议之一。 + +#### 主要功能概述: + + * 拖放功能,方便图表制作 + * 支持导入外部数据进行链接 + +官网:[yED Graph Editor][14] + +### 5、Inkscape + +![][15] + +Inkscape 是一个自由开源的矢量图形编辑器。你将拥有创建流程图或数据流程图的基本功能。它不提供高级的图表绘制工具,而是提供创建更简单图表的基本工具。因此,当你希望通过使用图库中的可用符号,在图库连接器工具的帮助下生成基本图时,Inkscape 可能是你的 Visio 替代品。 + +#### 主要功能概述: + + * 连接器工具 + * 灵活的绘图工具 + * 广泛的文件格式兼容性 + +官网:[Inkscape][16] + +### 6、Pencil 项目 + +![][17] + +Pencil 项目是一个令人印象深刻的开源项目,适用于 Windows、Mac 以及 Linux。它具有易于使用的图形界面,使绘图更容易和方便。它有一个很好的内建形状和符号的集合,可以使你的图表看起来很棒。它还内置了 Android 和 iOS UI 模板,可以让你在需要时创建应用程序原型。 + +你也可以将其安装为 Firefox 扩展,但该扩展不能使用项目的最新版本。 + +#### 主要功能概述: + + * 轻松浏览剪贴画(使用 openclipart.org) + * 导出为 ODT 文件/PDF 文件 + * 图表连接工具 + * 跨平台 + +官网:[Pencil 项目][18] + +### 7、Graphviz + +![][19] + +Graphviz 略有不同。它不是绘图工具,而是专用的图形可视化工具。如果你在网络图中需要多个设计来表示一个节点,那么一定要使用这个工具。当然,你不能用这个工具做平面布置图(至少这不容易)。因此,它最适合于网络图、生物信息学、数据库连接和类似的东西。 + +#### 主要功能概述: + + * 支持命令行使用 + * 支持自定义形状和表格节点布局 + * 基本样式和格式设置工具 + +官网:[Graphviz][20] + +### 8、Draw.io + +[视频](https://youtu.be/Z0D96ZikMkc) + +Draw.io 主要是一个基于 Web 的免费图表工具,它的强大的工具几乎可以制作任何类型的图表。你只需要拖放然后连接它们以创建流程图、ER 图或任何相关的。此外,如果你喜欢该工具,则可以尝试[离线桌面版本][21]。 + +#### 主要功能概述: + + * 直接上传到云存储服务 + * 自定义形状 + * 样式和格式工具 + * 跨平台 + +官网:[Draw.io][22] + +### 9、Lucidchart + +![][23] + +Lucidchart 是一个基于 Web 的高级图表工具,它提供了一个具有有限功能的免费订阅。你可以使用免费订阅创建几种类型的图表,并将其导出为图像或 PDF。但是,免费版本不支持数据链接和 Visio 导入/导出功能。如果你不需要数据链接功能,Lucidchart 可以说是一个生成漂亮的图表的非常好的工具。 + +#### 主要功能概述: + + * 可以集成到 Slack、Jira 核心、Confluence + * 能够制作产品模型 + * 导入 Visio 文件 + +官网:[Lucidchart][24] + +### 10、Calligra Flow + +![calligra flow][25] + +Calligra Flow 是 [Calligra 项目][26]的一部分,旨在提供自由开源的软件工具。使用 Calligra flow 你可以轻松地创建网络图、实体关系图、流程图等 + +#### 主要功能概述: + + * 各种模具盒 + * 样式和格式工具 + +官网:[Calligra Flow][27] + +### 总结 + +既然你已经了解到了这些最好的自由开源的 Visio 替代方案,你对它们有什么看法? + +对于你任何方面的需求,它们是否优于 微软 Visio?另外,如果我们错过了你最喜欢的基于 Linux 的替代微软 Visio 的绘图工具,请在下面的评论中告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/visio-alternatives-linux/ + +作者:[Ankush Das][a] +译者:[ZhiW5217](https://github.com/ZhiW5217) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://itsfoss.com/author/ankush/ +[1]:https://products.office.com/en/visio/flowchart-software +[2]:https://itsfoss.com/best-free-open-source-alternatives-microsoft-office/ +[3]:data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs= +[4]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2017/12/visio-alternatives-linux-featured.png +[5]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2017/12/libreoffice-draw-microsoft-visio-alternatives.jpg +[6]:https://www.libreoffice.org/discover/draw/ +[7]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2017/12/apache-open-office-draw.jpg +[8]:https://itsfoss.com/install-openoffice-ubuntu-linux/ +[9]:https://itsfoss.com/openoffice-shutdown/ +[10]:https://www.openoffice.org/product/draw.html +[11]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2017/12/dia-screenshot.jpg +[12]:http://dia-installer.de/ +[13]:https://www.yworks.com/products/yed-live +[14]:https://www.yworks.com/products/yed +[15]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2017/12/inkscape-screenshot.jpg +[16]:https://inkscape.org/en/ +[17]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2017/12/pencil-project.jpg +[18]:http://pencil.evolus.vn/Downloads.html +[19]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2017/12/graphviz.jpg +[20]:http://graphviz.org/ +[21]:https://about.draw.io/integrations/#integrations_offline +[22]:https://about.draw.io/ +[23]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2017/12/lucidchart-visio-alternative.jpg +[24]:https://www.lucidchart.com/ +[25]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2017/12/calligra-flow.jpg +[26]:https://www.calligra.org/ +[27]:https://www.calligra.org/flow/ diff --git a/published/201907/20180406 MX Linux- A Mid-Weight Distro Focused on Simplicity.md b/published/201907/20180406 MX Linux- A Mid-Weight Distro Focused on Simplicity.md new file mode 100644 index 0000000000..4955a1d7cb --- /dev/null +++ b/published/201907/20180406 MX Linux- A Mid-Weight Distro Focused on Simplicity.md @@ -0,0 +1,126 @@ +MX Linux:一款专注于简洁性的中等体量发行版 +====== + +> 这个发行版可以使任何人在 Linux 上如家一般。 + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/mxlinux.png?itok=OLjmCxT9) + +Linux 有着如此多种的发行版。许多发行版为了使自己与众不同而做出了很多改变。另一方面,许多发行版之间的区别又是如此之小,你可能会问为什么有人还愿意不厌其烦的重复别人已经做过的工作呢?也正是基于这一疑惑,让我好奇为什么 [antiX][1] 和 [MEPIS][2]这两个社区要联合推出一个特殊的发行版,考虑到具体情况应该会是一个搭载 Xfce 桌面并基于 antiX 的版本,由 MEPIS 社区承担开发。 + +这一开发中的使用 Xfce 桌面的 antiX 系统是否会基于它之前的发行版呢?毕竟,antiX 旨在提供一个“基于 Debian 稳定版的快速、轻量级、易于安装的非 systemd 的 live CD 发行版”。antiX 所搭载的桌面是 [LXDE][3],能够极好的满足关于轻量化系统的相关要求和特性。那究竟是什么原因使得 antiX 决定构建另一个轻量化发行版呢,仅仅是因为这次换成了 Xfce 吗?好吧,Linux 社区中的任何人都知道,增加了不同风格的好的轻量级发行版是值得一试的(特别是可以使得我们的旧硬件摆脱进入垃圾填埋场的宿命)。当然,LXDE 和 Xfce 并不完全属于同一类别。LXDE 应该被认为是一个真正的轻量级桌面,而 Xfce 应该被认为是一个中等体量的桌面。朋友们,这就是为什么 MX Linux 是 antiX 的一个重要迭代的关键。一个基于 Debian 的中等体量的发行版,它包含你完成工作所需的所有工具。 + +但是在 MX Linux 中有一些直接从 antiX 借用来的非常有用的东西 —— 那就是安装工具。当我初次设置了 VirtualBox 虚拟机来安装 MX Linux 时,我认为安装的系统将是我已经习惯的典型的、非常简单的 Linux 系统。令我非常惊讶的是,MX Linux 使用的 antiX 安装程序打破了以往的痛点,特别是对于那些对尝试 Linux 持观望态度的人来说。 + +因此,甚至在我开始尝试 MX Linux 之前,我就对它有了深刻的印象。让我们来看看是什么让这个发行版的安装如此特别,最后再来看看桌面。 + +你可以从[这里][4]下载 MX Linux 17.1。系统的最低要求是: + + * CD/DVD驱动器(以及能够从该驱动器引导的 BIOS)或 live USB(以及能够从 USB 引导的 BIOS) + * 英特尔 i486 或 AMD 处理器 + * 512 MB 内存 + * 5 GB 硬盘空间 + * 扬声器,AC97 或 HDA-compatible 声卡 + * 作为一个 LiveUSB 使用,需要 4 GB 空间 + +### 安装 + +MX Linux 安装程序使安装 Linux 变得轻而易举。虽然它可能不是外观最现代化的安装工具,但也已经差不多了。安装的要点是从选择磁盘和选择安装类型开始的(图 1)。 + +![install][6] + +*图 1:MX Linux 的安装程序截图之一* + +下一个重要的界面(图 2)要求你设置一个计算机名称、域名和(如果需要的话,为微软网络设置)工作组。 + +![network][8] + +*图 2:设置网络名称* + +配置工作组的能力是第一个真正值得称赞的。这是我记忆中第一款在安装期间提供此选项的发行版。它还应该提示你,MX Linux 提供了开箱即用的共享目录功能。它做到了,而且深藏功与名。它并不完美,但它可以在不需要安装任何额外包的情况下工作(稍后将详细介绍)。 + +最后一个重要的安装界面(需要用户交互)是创建用户帐户和 root 权限的密码(图 3)。 + +![user][9] + +*图 3:设置用户帐户详细信息和 root 用户密码* + +最后一个界面设置完成后,安装将完成并要求重新启动。重启后,你将看到登录屏幕。登录并享受 MX Linux 带来的体验。 + +### 使用 + +Xfce 桌面是一个非常容易上手的界面。默认设置将面板位于屏幕的左边缘(图 4)。 + +![desktop][11] + +*图 4:MX Linux 的默认桌面* + +如果你想将面板移动到更传统的位置,右键单击面板上的空白点,然后单击“面板”>“面板首选项”。在显示的窗口中(图 5),单击样式下拉菜单,在桌面栏、垂直栏或水平栏之间进行选择你想要的模式。 + +![panel][13] + +*图 5:配置 MX Linux 面板* + +桌面栏和垂直选项的区别在于,在桌面栏模式下,面板垂直对齐,就像在垂直模式下一样,但是插件是水平放置的。这意味着你可以创建更宽的面板(用于宽屏布局)。如果选择水平布局,它将默在顶部,然后你必须取消锁定面板,单击关闭,然后(使用面板左侧边缘的拖动手柄)将其拖动到底部。你可以回到面板设置窗口并重新锁定面板。 + +除此之外,使用 Xfce 桌面对于任何级别的用户来说都是无需动脑筋的事情……就是这么简单。你会发现很多涵盖了生产力(LibreOffice、Orage Calendar、PDF-Shuffler)、图像(GIMP)、通信(Firefox、Thunderbird、HexChat)、多媒体(Clementine、guvcview SMTube、VLC媒体播放器)的软件,和一些 MX Linux 专属的工具(称为 MX 工具,涵盖了 live-USB 驱动器制作工具、网络助手、包管理工具、仓库管理工具、live ISO 快照工具等等)。 + +### Samba + +让我们讨论一下如何将文件夹共享到你的网络。正如我所提到的,你不需要安装任何额外的包就可以使其正常工作。只需打开文件管理器,右键单击任何位置,并选择网络上的共享文件夹。系统将提示你输入管理密码(已在安装期间设置)。验证成功之后,Samba 服务器配置工具将打开(图 6)。 + +![sharing][15] + +*图 6:向网络共享一个目录* + +单击“+”按钮配置你的共享。你将被要求指定一个目录,为共享提供一个名称/描述,然后决定该共享是否可写和可见(图 7)。 + +![sharing][17] + +*图 7:在 MX Linux 上配置共享* + +当你单击 Access 选项时,你可以选择是让每个人都访问共享,还是限于特定的用户。问题就出在这里。此时,没有用户可以共享。为什么?因为它们还没有被添加。有两种方法可以把它们添加到共享:从命令行或使用我们已经打开的工具。让我们用一种更为简单的方法。在 Samba 服务器配置工具的主窗口中,单击“首选项” > “Samba 用户”。在弹出的窗口中,单击“添加用户”。 + +将出现一个新窗口(图 8),你需要从下拉框中选择用户,输入 Windows 用户名,并为用户键入/重新键入密码。 + +![Samba][19] + +*图 8:向 Samba 添加用户* + +一旦你单击“确定”,这用户就会被添加,并且基于你的网络的对用户的共享功能也随之启用。创建 Samba 共享从未变得如此容易。 + +### 结论 + +MX Linux 使任何从桌面操作系统转到 Linux 都变得非常简单。尽管有些人可能会觉得桌面界面不太现代,但发行版的主要关注点不是美观,而是简洁。为此,MX Linux 以出色的方式取得了成功。Linux 的这个特色发行版可以让任何人在使用 Linux 的过程中感到宾至如归。尝试这一中等体量的发行版,看看它能否作为你的日常系统。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/4/mx-linux-mid-weight-distro-focused-simplicity + +作者:[JACK WALLEN][a] +译者:[qfzy1233](https://github.com/qfzy1233) +校对:[wxy](https://github.com/wxy) +选题:[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]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/mxlinux_2.jpg?itok=72nWxkGo +[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 diff --git a/published/201907/20180529 Manage your workstation with Ansible- Configure desktop settings.md b/published/201907/20180529 Manage your workstation with Ansible- Configure desktop settings.md new file mode 100644 index 0000000000..f3c8ef2873 --- /dev/null +++ b/published/201907/20180529 Manage your workstation with Ansible- Configure desktop settings.md @@ -0,0 +1,158 @@ +使用 Ansible 管理你的工作站:配置桌面设置 +====== + +> 在本系列第三篇(也是最后一篇)文章中,我们将使用 Ansible 自动化配置 GNOME 桌面设置。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cube_innovation_process_block_container.png?itok=vkPYmSRQ) + +在本系列关于使用 Ansible 配置工作站的[第一篇文章][1]中,我们设置了一个仓库并配置了一些基本的东西。在[第二篇文章][2]中,我们配置了 Ansible 以使其在对仓库进行更改时自动应用设置。在第三篇(也是最后一篇)文章中,我们将使用 Ansible 配置 GNOME 桌面设置。 + +此配置只适用于较新的发行版(例如我将在示例中使用的 Ubuntu 18.04)。较旧版本的 Ubuntu 将无法运行,因为它们附带了一个老版本的 `python-psutils`,对于 Ansible 的 `dconf` 模块无法正常工作。如果你使用的是较新版本的 Linux 发行版,则应该没有问题。 + +在开始之前,确保你已经完成了本系列的第一部分和第二部分,因为第三部分建立在此基础之上的。如果还没有,下载前两篇文章中一直使用的 GitHub [仓库][3],我们将为其添加更多功能。 + +### 设置壁纸和锁屏 + +首先,我们将创建一个任务手册来保存我们的 GNOME 设置。在仓库的根目录中,应该有一个名为 `local.yml` 的文件,添加以下行: + +``` +- include: tasks/gnome.yml +``` + +整个文件应如下所示: + +``` +- hosts: localhost + become: true + pre_tasks: + - name: update repositories + apt: update_cache=yes + changed_when: False + + tasks: + - include: tasks/users.yml + - include: tasks/cron.yml + - include: tasks/packages.yml + - include: tasks/gnome.yml +``` + +基本上,这添加了对名为 `gnome.yml` 文件的引用,它将存储在仓库内的 `tasks` 目录中。我们还没有创建这个文件,现在就来创建它。在 `tasks` 目录中创建 `gnome.yml` 文件,并将以下内容放入: + +``` +- name: Install python-psutil package + apt: name=python-psutil + +- name: Copy wallpaper file + copy: src=files/wallpaper.jpg dest=/home/jay/.wallpaper.jpg owner=jay group=jay mode=600 + +- name: Set GNOME Wallpaper + become_user: jay + dconf: key="/org/gnome/desktop/background/picture-uri" value="'file:///home/jay/.wallpaper.jpg'" +``` + +注意,此代码多次引用我的用户名(`jay`),因此确保使用你机器上的用户名替换每次出现的 `jay`。另外,如果你没有像我一样使用 Ubuntu 18.04,你将必须更改 `apt` 一行来匹配你所选择的发行版的包管理器,并确认 `python-psutil` 包的名称,因为它可能有所不同。 + +在示例任务中,我引用了 `file` 目录下的 `wallpaper.jpg` 文件,此文件必须存在,否则 Ansible 配置将失败。在 `tasks` 目录中,创建一个名为 `files` 的子目录。找到你喜欢的壁纸图片,将其命名为 `wallpaper.jpg`,然后把它放在 `files` 目录中。如果文件是 PNG 图像而不是 JPG,在代码和仓库中更改文件扩展名。如果你觉得没有创意,我在 [GitHub 仓库][3] 中有一个示例壁纸文件,你可以使用它。 + +完成所有这些更改后,将内容提交到 GitHub 仓库,并推送这些更改。总结一下,你应该完成以下工作: + + * 修改 `local.yml` 文件以引用 `tasks/gnome.yml` + * 使用上面提到的内容创建 `tasks/gnome.yml` + * 在 `tasks` 目录中创建一个 `files` 目录,其中有一个名为 `wallpaper.jpg` 的图像文件(或者你选择的任何名称)。 + +完成这些步骤并将更改推送到仓库后,配置应该在下次计划运行期间自动应用。(你可能还记得我们在上一篇文章中对此进行了自动化。)如果你想节省时间,可以使用以下命令立即应用配置: + +``` +sudo ansible-pull -U https://github.com//ansible.git +``` + +如果一切正常,你应该可以看到你的新壁纸。 + +让我们花一点时间来了解新的 GNOME 任务手册的功能。首先,我们添加了一个计划来安装 `python-psutil` 包。如果不添加它,我们就不能使用 `dconf` 模块,因为它需要在修改 GNOME 设置之前安装这个包。接下来,我们使用 `copy` 模块将壁纸文件复制到我们的 `home` 目录,并将生成的文件命名为以点开头的隐藏文件。如果你不希望此文件放在 `home` 目录的根目录中,你可以随时指示此部分将其复制到其它位置 —— 只要你在正确的位置引用它,它仍然可以工作。在下一个计划中,我们使用 `dconf` 模块来更改 GNOME 设置。在这种情况下,我们调整了 `/org/gnome/desktop/background/picture-uri` 键并将其设置为 `file:///home/jay/.wallpaper.jpg`。注意本节中的引号 —— 你必须在 `dconf` 值中使用两个单引号,如果值是一个字符串,还必须包含在双引号内。 + +现在,让我们进一步进行配置,并将背景应用于锁屏。这是现在的 GNOME 任务手册,但增加了两个额外的计划: + +``` +- name: Install python-psutil package + apt: name=python-psutil + +- name: Copy wallpaper file + copy: src=files/wallpaper.jpg dest=/home/jay/.wallpaper.jpg owner=jay group=jay mode=600 + +- name: Set GNOME wallpaper + dconf: key="/org/gnome/desktop/background/picture-uri" value="'file:///home/jay/.wallpaper.jpg'" + +- name: Copy lockscreenfile + copy: src=files/lockscreen.jpg dest=/home/jay/.lockscreen.jpg owner=jay group=jay mode=600 + +- name: Set lock screen background + become_user: jay + dconf: key="/org/gnome/desktop/screensaver/picture-uri" value="'file:///home/jay/.lockscreen.jpg'" +``` + +正如你所看到的,我们做的事情和设置壁纸时差不多。我们添加了两个额外的任务,一个是复制锁屏图像并将其放在我们的 `home` 目录中,另一个是将设置应用于 GNOME 以便使用它。同样,确保将 `jay` 更改为你的用户名,并命名你想要的锁屏图片 `lockscreen.jpg`,并将其复制到 `files` 目录。将这些更改提交到仓库后,在下一次计划的 Ansible 运行期间就会应用新的锁屏。 + +### 应用新的桌面主题 + +设置壁纸和锁屏背景很酷,但是让我们更进一步来应用桌面主题。首先,让我们在我们的任务手册中添加一条指令来安装 `arc` 主题的包。将以下代码添加到 GNOME 任务手册的开头: + +``` +- name: Install arc theme +  apt: name=arc-theme +``` + +然后,在底部,添加以下动作: + +``` +- name: Set GTK theme +  become_user: jay +  dconf: key="/org/gnome/desktop/interface/gtk-theme" value="'Arc'" +``` + +你看到 GNOME 的 GTK 主题在你眼前变化了吗?我们添加了一个动作来通过 `apt` 模块安装 `arc-theme` 包,另一个动作将这个主题应用到 GNOME。 + +### 进行其它定制 + +既然你已经更改了一些 GNOME 设置,你可以随意添加其它定制。你在 GNOME 中调整的任何设置都可以通过这种方式自动完成,设置壁纸和主题只是几个例子。你可能想知道如何找到要更改的设置,以下是一个我用的技巧。 + +首先,通过在你管理的计算机上运行以下命令,获取所有当前 `dconf` 设置的快照: + +``` +dconf dump / > before.txt +``` + +此命令将所有当前更改导出到名为 `before.txt` 的文件中。接下来,手动更改要自动化的设置,并再次获取 `dconf` 设置: + +``` +dconf dump / > after.txt +``` + +现在,你可以使用 `diff` 命令查看两个文件之间的不同之处: + +``` +diff before.txt after.txt +``` + +这应该会给你一个已更改键值的列表。虽然手动更改设置确实违背了自动化的目的,但你实际上正在做的是获取更新首选设置时更改的键,这允许你创建 Ansible 任务以修改这些设置,这样你就再也不需要碰这些设置了。如果你需要还原机器,Ansible 仓库会处理好你的每个定制。如果你有多台计算机,甚至是一组工作站,则只需手动进行一次更改,所有其他工作站都将应用新设置并完全同步。 + +### 最后 + +如果你已经阅读完本系列文章,你应该知道如何设置 Ansible 来自动化工作站。这些示例提供了一个有用的基础,你可以使用这些语法和示例进行其他定制。随着你的进展,你可以继续添加新的修改,这将使你的 Ansible 配置一直增长。 + +我已经用 Ansible 以这种方式自动化了一切,包括我的用户帐户和密码、Vim、tmux 等配置文件、桌面包、SSH 设置、SSH 密钥,基本上我想要自定义的一切都使用了。以本系列文章作为起点,将为你实现工作站的完全自动化铺平道路。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/manage-your-workstation-ansible-part-3 + +作者:[Jay LaCroix][a] +选题:[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/) 荣誉推出 + +[a]:https://opensource.com/users/jlacroix +[1]:https://linux.cn/article-10434-1.html +[2]:https://linux.cn/article-10449-1.html +[3]:https://github.com/jlacroix82/ansible_article.git diff --git a/published/201907/20180620 How To Find The Port Number Of A Service In Linux.md b/published/201907/20180620 How To Find The Port Number Of A Service In Linux.md new file mode 100644 index 0000000000..d3e1f04e62 --- /dev/null +++ b/published/201907/20180620 How To Find The Port Number Of A Service In Linux.md @@ -0,0 +1,191 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11066-1.html) +[#]: subject: (How To Find The Port Number Of A Service In Linux) +[#]: via: (https://www.ostechnix.com/how-to-find-the-port-number-of-a-service-in-linux/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +如何在 Linux 中查找服务的端口号 +====== + +![Find The Port Number Of A Service In Linux OS][1] + +由于某些原因,你可能经常需要查找端口名称和端口号。如果是这样,你很幸运。今天,在这个简短的教程中,我们将看到在 Linux 系统中最简单、最快捷的查找服务端口号的方法。可能有很多方法可以做到,但我目前只知道以下三种方法。请继续阅读。 + +### 在 Linux 中查找服务的端口号 + +#### 方法1:使用 grep 命令 + +要使用 `grep` 命令在 Linux 中查找指定服务的默认端口号,只需运行: + +``` +$ grep /etc/services +``` + +例如,要查找 SSH 服务的默认端口,只需运行: + +``` +$ grep ssh /etc/services +``` + +就这么简单。此命令应该适用于大多数 Linux 发行版。以下是我的 Arch Linux 测试机中的示例输出: + +``` +ssh 22/tcp +ssh 22/udp +ssh 22/sctp +sshell 614/tcp +sshell 614/udp +netconf-ssh 830/tcp +netconf-ssh 830/udp +sdo-ssh 3897/tcp +sdo-ssh 3897/udp +netconf-ch-ssh 4334/tcp +snmpssh 5161/tcp +snmpssh-trap 5162/tcp +tl1-ssh 6252/tcp +tl1-ssh 6252/udp +ssh-mgmt 17235/tcp +ssh-mgmt 17235/udp +``` + +正如你在上面的输出中所看到的,SSH 服务的默认端口号是 22。 + +让我们找到 Apache Web 服务器的端口号。为此,命令是: + +``` +$ grep http /etc/services +# http://www.iana.org/assignments/port-numbers +http 80/tcp www www-http # WorldWideWeb HTTP +http 80/udp www www-http # HyperText Transfer Protocol +http 80/sctp # HyperText Transfer Protocol +https 443/tcp # http protocol over TLS/SSL +https 443/udp # http protocol over TLS/SSL +https 443/sctp # http protocol over TLS/SSL +gss-http 488/tcp +gss-http 488/udp +webcache 8080/tcp http-alt # WWW caching service +webcache 8080/udp http-alt # WWW caching service +[...] +``` + +FTP 端口号是什么?这很简单! + +``` +$ grep ftp /etc/services +ftp-data 20/tcp +ftp-data 20/udp +# 21 is registered to ftp, but also used by fsp +ftp 21/tcp +ftp 21/udp fsp fspd +tftp 69/tcp +[...] +``` + +#### 方法 2:使用 getent 命令 + +如你所见,上面的命令显示指定搜索词 “ssh”、“http” 和 “ftp” 的所有端口名称和数字。这意味着,你将获得与给定搜索词匹配的所有端口名称的相当长的输出。 + +但是,你可以使用 `getent` 命令精确输出结果,如下所示: + +``` +$ getent services ssh +ssh 22/tcp + +$ getent services http +http 80/tcp www www-http + +$ getent services ftp +ftp 21/tcp +``` + +如果你不知道端口名称,但是知道端口号,那么你只需将端口名称替换为数字: + +``` +$ getent services 80 +http 80/tcp +``` + +要显示所有端口名称和端口号,只需运行: + +``` +$ getent services +``` + +#### 方法 3:使用 Whatportis 程序 + +Whatportis 是一个简单的 Python 脚本,来用于查找端口名称和端口号。与上述命令不同,此程序以漂亮的表格形式输出。 + +确保已安装 pip 包管理器。如果没有,请参考以下链接。 + +- [如何使用 pip 管理 Python 包][6] + +安装 pip 后,运行以下命令安装 Whatportis 程序。 + +``` +$ pip install whatportis +``` + +现在,你可以找到与服务关联的端口,如下所示。 + +``` +$ whatportis ssh + +$ whatportis ftp + +$ whatportis http +``` + +我的 CentOS 7 服务器的示例输出: + +![][7] + +*在 Linux 中查找服务的端口号* + +如果你不知道服务的确切名称,请使用 `–like` 标志来显示相关结果。 + +``` +$ whatportis mysql --like +``` + +上述命令帮助你查找与服务关联的端口。你还可以找到与端口号相关联的服务,如下所示。 + +``` +$ whatportis 993 +``` + +你甚至可以以 JSON 格式显示结果。 + +``` +$ whatportis 993 --json +``` + +![][8] + +有关更多详细信息,请参阅 GitHub 仓库。 + +* [Whatportis GitHub 仓库][9] + +就是这些了。你现在知道了如何使用三种简单方法在 Linux 中查找端口名称和端口号。如果你知道任何其他方法/命令,请在下面的评论栏告诉我。我会查看并更相应地更新本指南。 + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-find-the-port-number-of-a-service-in-linux/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2018/06/Find-The-Port-Number-720x340.png +[2]: https://www.ostechnix.com/the-grep-command-tutorial-with-examples-for-beginners/ +[6]: https://www.ostechnix.com/manage-python-packages-using-pip/ +[7]: https://www.ostechnix.com/wp-content/uploads/2018/06/whatportis.png +[8]: https://www.ostechnix.com/wp-content/uploads/2018/06/whatportis-1.png +[9]: https://github.com/ncrocfer/whatportis diff --git a/published/201907/20180629 100 Best Ubuntu Apps.md b/published/201907/20180629 100 Best Ubuntu Apps.md new file mode 100644 index 0000000000..d5c3505d10 --- /dev/null +++ b/published/201907/20180629 100 Best Ubuntu Apps.md @@ -0,0 +1,1208 @@ +100 个最佳 Ubuntu 应用 +====== + +今年早些时候我们发布了一个 [2018 年最好的 20 个 Ubuntu 应用][1]列表,可能对很多用户来说都很有用。现在我们几乎到 2018 年下半年了(LCTT 译注:好吧,我们翻译的有些晚了,顺便打个广告,[LCTT 欢迎你,有志于通过翻译为开源做些贡献的同学!][111]),所以今天我们打算看一下 Ubuntu 上最好的 100 个应用,你可能会觉得有帮助。 + +![100 Best Ubuntu Apps][2] + +很多用户最近从 Microsoft Windows 转换到了 Ubuntu,可能面临着这样一个困境:寻找它们之前使用了数年的操作系统上的应用软件的最好替代应用。Ubuntu 拥有上千个免费使用和开源应用软件,比 Windows 和其它 OS 上的付费软件运行的更好。 + +下列列表归纳了各种分类下很多应用软件的功能特点,因此,你可以找到匹配你的需求的最好的应用。 + +### 1、Google Chrome 浏览器 + +几乎所有 Linux 发行版都默认安装了 Mozilla Firefox 网络浏览器,它是 Google Chrome 的强力竞争对手。但是 Chrome 相对 Firefox 而言有它自己的优点,比如它可以让你直接访问你的 Google 账户,你可以通过它来同步你在其它操作系统和手机上的 Chrome 浏览器的书签、浏览历史、扩展等等。 + +![Chrome][3] + +Google Chrome 为 Linux 集成了最新的 Flash 播放器,其它 Linux 上的浏览器像 Mozilla Firefox 和 Opera 网络浏览器则不是这样。如果你在 Windows 上经常使用 Chrome,那么在 Linux 上也用它是最好的选择。 + +### 2、Steam + +现在在 Linux 上玩游戏已经不是问题了,这在很多年前还是一个遥不可及的梦。在 2013 年,Valve 发布了 Linux 上的 Steam 游戏客户端,此后一切都变了。早期用户犹豫着从 Windows 转到 Linux,只是因为他们不能在 Ubuntu 上玩它们最喜欢的游戏,但是现在已经不是这样了。 + +![Steam][4] + +一些用户可能发现在 Linux 上安装 Steam 有点棘手,但如果能在 Linux 上玩上千的 Steam 游戏这么做就是值得的。一些流行的高端游戏,如《反恐精英:全球攻势》、《Hitman》、《Dota 2》在 Linux 上都能获取,你只需要确保你满足玩这些游戏的最小硬件需求。 + +``` +$ sudo add-apt-repository multiverse +$ sudo apt-get update +$ sudo apt-get install steam +``` + +### 3、WordPress 桌面客户端 + +是的,没错,WordPress 有它专属的 Ubuntu 平台的客户端,你可以用来管理你的 WordPress 站点。你可以在桌面客户端上撰写和设计你的站点而不用转到浏览器。 + +![][5] + +如果你拥有使用 WordPress 建立的站点,那么这个桌面客户端就是你必备的应用,它能够让你在单个窗口内追踪所有的 WordPress 通知。你也可以查看你的站点上的博客数据。桌面客户端可以在 Ubuntu 软件中心中获取,你可以在那里下载和安装。 + +### 4、VLC 媒体播放器 + +VLC 是一个非常流行的跨平台的开源媒体播放器,同样在 Ubuntu 中可以获取。使得 VLC 成为一个最好的媒体播放器的原因是它能够毫无问题地播放世界上任何音频视频格式。 + +![][6] + +VLC 有一个平滑的用户界面,易于使用,除此之外,它提供了很多功能,包括在线视频流、音频和视频自定义等。 + +``` +$ sudo add-apt-repository ppa:videolan/master-daily +$ sudo apt update +$ sudo apt-get install vlc qtwayland5 +``` + +### 5、Atom 文本编辑器 + +由 GitHub 开发的 Atom 是一个自由开源的文本编辑器,它同样能够被用做集成开发环境(IDE)来进行主流编程语言的编码和编辑。Atom 开发者声称它是完全可魔改的 21 世纪文本编辑器。 + +![][7] + +Atom 文本编辑器拥有最佳的用户界面,它是一个富文本编辑器,提供了自动补全、语法高亮,支持扩展与插件。 + +``` +$ sudo add-apt-repository ppa:webupd8team/atom +$ sudo apt-get update +$ sudo apt-get install atom +``` + +### 6、GIMP 图像编辑器 + +GIMP(GNU 图形操作程序)是 Ubuntu 上的自由开源的图像编辑器。无疑它是 Windows 上 Adobe Photoshop 的最好替代品。如果你过去经常用 Adobe Photoshop,会觉得很难习惯 GIMP,但是你可以自定义 GIMP 使它看起来与 Photoshop 非常相似。 + +![][8] + +GIMP 是一个功能丰富的图片编辑器,你可以随时通过安装扩展和插件来使用附加的功能。 + +``` +$ sudo apt-get install gimp +``` + +### 7、Google Play 音乐桌面播放器 + +Google Play 音乐桌面播放器是一个开源的音乐播放器,它是 Google Play 音乐的一个复制品,或者说比它更好。Google 一直少个桌面的音乐客户端,但第三方的应用完美的填充了空白。 + +![][9] + +就像你在上面的截屏里看到的,它的界面在外观和感觉上都是首屈一指的。你只需要登录 Google 账户,之后就会导入你的所有音乐和收藏到桌面客户端里。你可以从它的官方[站点][10]下载安装文件并使用软件中心安装它。 + +### 8、Franz + +Franz 是一个即时消息客户端,它将聊天和信息服务结合到了一个应用中。它是一个现代化的即时消息平台,在单个应用中支持了 Facebook Messenger、WhatsApp、Telegram、微信、Google Hangouts、 Skype。 + +![][11] + +Franz 是一个完备的消息平台,你可以用于商业中管理大量的客户服务。要安装 Franz,你需要从它的[网站][12]下载安装包,在软件中心中打开。 + +### 9、新立得包管理器 + +新立得包管理器是 Ubuntu 上必有工具之一,因为它为我们通常在终端里安装软件的 `apt-get` 命令提供了用户图形界面。它是各种 Linux 发行版中的默认应用商店的强力对手。 + +![][13] + +新立得拥有非常简单的用户图形界面,相比其它的应用商店非常快并易于使用。在左手边你可以浏览不同分类的各种应用,也可以轻松安装和卸载。 + +``` +$ sudo apt-get install synaptic +``` + +### 10、Skype + +Skype 是一个非常流行的跨平台视频电话应用,如今在 Linux 系统可以以 Snap 应用方式获取。Skype 是一个即时通信应用,它提供了视频和音频通话、桌面共享等功能。 + +![][14] + +Skype 有一个优秀的用户图形界面,与 Windows 上的桌面客户端非常相似,易于使用。它对于从 Windows 上转换来的用户来说非常有用。 + +``` +$ sudo snap install skype +``` + +### 11、VirtualBox + +VirtualBox 是由 Oracle 公司开发的跨平台的虚拟化软件应用(LCTT 译注:实际上是由被 Oracle 公司收购的 Sun 公司开发的,包括 Java、Solaris 也是)。如果你喜欢尝试新的操作系统,那么 VirtualBox 是你必备的 Ubuntu 应用。你可以在 Windows 内尝试 Linux、Mac,也可以在 Linux 系统内尝试 Windows 和 Mac。 + +![][15] + +VirtualBox 实际做的是让你在宿机操作系统里可视化地运行访客操作系统。它可以创建虚拟硬盘并在上面安装访客操作系统。你可以在 Ubuntu 软件中心直接下载和安装它。 + +### 12、Unity Tweak 工具 + +Unity Tweak 工具(Gnome Tweak 工具)对于每个 Linux 用户都是必须拥有的,因为它给了用户根据需要自定义桌面的能力。你可以尝试新的 GTK 主题、设置桌面热角、自定义图标集、调整 unity 启动器等等。 + +![][16] + +Unity Tweak 工具对于用户来说可能非常有用,因为它包含了从基础到高级配置的所有内容。 + +``` +$ sudo apt-get install unity-tweak-tool +``` + +### 13、Ubuntu Cleaner + +Ubuntu Cleaner 是一个系统管理工具,其被特别设计用来移除不再使用的包、不需要的应用和清理浏览器缓存。Ubuntu Cleaner 有易于使用的简单用户界面。 + +![][17] + +Ubuntu Cleaner 是 BleachBit 最好的替代品之一,BleachBit 是 Linux 发行版上的相当好的清理工具。 + +``` +$ sudo add-apt-repository ppa:gerardpuig/ppa +$ sudo apt-get update +$ sudo apt-get install ubuntu-cleaner +``` + +### 14、Visual Studio Code + +Visual Studio Code 是一个代码编辑器,你会发现它与你可能曾用过的 Atom 文本编辑器和 Sublime Text 非常相似。Visual Studio Code 被证明是非常好的教育工具,因为它可以对编程中的从 HTML 标签到语法的所有东西做出解释。 + +![][18] + +Visual Studio 自身集成了 Git,它有优秀的用户界面,你会发现它与 Atom Text Editor 和 Sublime Text 非常相似。你可以从 Ubuntu 软件中心下载和安装它。 + +### 15、Corebird + +如果你在找你可以使用 Twitter 的桌面客户端,那 Corebird Twitter 客户端就是你在找的。它被视为 Linux 发行版下可获得的最好的 Twitter 客户端,它提供了与你手机上的 Twitter 应用非常相似的功能。 + +![][19] + +当有人喜欢或者转发你的 tweet 或者给你发消息时,Corebird Twitter 客户端同样会给你通知。你同样可以在这个客户端上添加多个 Twitter 账户。 + +``` +$ sudo snap install corebird +``` + +### 16、Pixbuf + +Pixbuf 是来自 Pixbuf 图片社区中心的一个桌面客户端,可以让你上传、分享和出售你的相片。它支持图片共享,如像 Facebook、Pinterest、Instagram、Twitter 等社交媒体,以及像 Flickr、500px 和 Youpic 等相片服务。 + +![][20] + +Pixbuf 提供了分析等功能,可以让你统计点击量、转发量、照片的回复数、定时发帖、iOS 专有的扩展信息。它同样有移动应用,因此你可以在任何地方连接到你的 Pixbuf 账户。Pixbuf 可以在 Ubuntu 软件中心以 Snap 包的形式获得。 + +### 17、Clementine 音乐播放器 + +Clementine 是一个跨平台的音乐播放器,并且是 Ubuntu 上默认音乐播放器 Rhythmbox 的良好竞争者。它是一个快速而易用的音乐播放器,其用户界面友好。它支持所有主流音频文件格式的回放。 + +![][21] + +除了可以播放本地库中的音乐,你也可以在线听 Spotify、SKY.fm、Soundcloud 等的广播。它也支持其它的功能像智能和动态播放列表,可以从像 Dropbox、Google Drive 这样的云存储中同步音乐。 + +``` +$ sudo add-apt-repository ppa:me-davidsansome/clementine +$ sudo apt-get update +$ sudo apt-get install clementine +``` + +### 18、Blender + +Blender 是一个自由开源的 3D 创建应用软件,你可以用来创建 3D 打印模型、动画电影、视频游戏等。它自身集成了游戏引擎,你可以用来开发和测试视频游戏。 + +![blender][22] + +Blender 拥有赏心悦目的用户界面,易于使用,它包括了内置的渲染引擎、数字雕刻、仿真工具、动画工具,还有很多。考虑到它免费和它的特点,你甚至会认为它可能是 Ubuntu 上最好的应用之一。 + +### 19、Audacity + +Audacity 是一个开源的音频编辑应用,你可以用来记录、编辑音频文件。你可以从各种输入中录入音频,包括麦克风、电子吉它等等。它提供了根据你的需要编辑和裁剪音频的能力。 + +![][23] + +最近 Audacity 发布了 Ubuntu 上的新版本,新特点包括主题改进、放缩命令等。除了这些,它还提供了降噪等音频效果的功能。 + +``` +$ sudo add-apt-repository ppa:ubuntuhandbook1/audacity +$ sudo apt-get update +$ sudo apt-get install audacity +``` + +### 20、Vim + +Vim 是一个集成开发环境,你可以以一个独立应用或 CLI 程序使用它,用于各种像 Python 等主流编程语言的编程。 + +![][24] + +大多数程序员喜欢在 Vim 中编写代码,因为它快速并且是一个可高度定制的集成开发环境。最初你可能觉得有点难用,但你会很快习惯它。 + +``` +$ sudo apt-get install vim +``` + +### 21、Inkscape + +Inkscape 是一个开源和跨平台的矢量图形编辑器,你会觉得它和 Corel Draw 和 Adobe Illustrator 很相似。用它可以创建和编辑矢量图形例如柱形图、徽标、图表、插图等。 + +![][25] + +Inkscape 使用可缩放矢量图形(SVG),这是一个基于 XML 的 W3C 标准格式。它支持各种格式,包括 JPEG、PNG、GIF、PDF、AI(Adobe Illustrator 格式)、VSD 等等。 + +``` +$ sudo add-apt-repository ppa:inkscape.dev/stable +$ sudo apt-get update +$ sudo apt-get install inkscape +``` + +### 22、Shotcut + +Shotcut 是一个 Meltytech, LLC 在 MLT 多媒体框架下开发的自由开源的跨平台视频编辑应用。你会发现它是 Linux 发行版上最强大的视频编辑器之一,它支持所有主要的音频、视频、图片格式。 + +![][26] + +它提供了非线性编辑多轨编辑各种文件格式的视频的能力。它支持 4K 视频分辨率和各种音频、视频过滤、语气生成、音频混合和很多其它的。 + +``` +snap install shotcut -- classic +``` + +### 23、SimpleScreenRecorder + +SimpleScreenRecorder 是 Ubuntu 上的一个免费而轻量级的屏幕录制工具。如果你是 YouTube 创作者或应用开发者,屏幕录制功能非常有用。 + +![][27] + +它可以捕获桌面屏幕的视频/音频记录或直接录制视频游戏。在录制屏幕前,你可以设置视频分辨率、帧率等。它有简单的用户界面,你会发现非常易用。 + +``` +$ sudo add-apt-repository ppa:marten-baert/simplescreenrecorder +$ sudo apt-get update +$ sudo apt-get install simplescreenrecorder +``` + +### 24、Telegram + +Telegram 是一个基于云的即时通信和网络电话平台,近年来非常流行。它是开源和跨平台的,用户可以用来发送消息,共享视频、图片、音频和其它文件。 + +![][28] + +Telegram 中容易注意到的特点是加密聊天、语音信息、机器人、远程视频通话、在线位置和社交登录。在 Telegram 中隐私和安全拥有最高优先级,因此,所有你发送和接收的是端对端加密的。 + +``` +$ sudo snap install telegram-desktop +``` + +### 25、ClamTk + +正如我们知道的,危害 Windows PC 的病毒不能危害 Ubuntu,但是可能被来自包含破坏性文件的 Windows PC 中的邮件所感染。因此,在 Linux 上有一些抗病毒应用是安全的。 + +![][29] + +ClamTk 是一个轻量级的病毒扫描器,可以扫描系统中的文件和文件夹并清理发现的有害文件。ClamTk 可以 Snap 包的形式获得,可以从 Ubuntu 软件中心下载。 + +### 26、MailSpring + +MailSpring 早期名为 Nylas Mail 或 Nylas N1,是开源的邮件客户端。它在电脑本地保存所有的邮件,因此你可以在任何需要的时候访问它。它提供了高级搜索的功能,可以使用“与”和“或”操作,因此你可以基于不同的参数搜索邮件。 + +![][30] + +MailSpring 有着和其它易于上手的邮件客户端同样优秀的用户界面。MailSpring 同样提供了私密性、安全性、日程、通讯录管理、日历等功能特点。 + +### 27、PyCharm + +继 Vim 之后,PyCharm 是我最喜欢的的 Python IDE 之一,因为它有优雅的用户界面,有很多扩展和插件支持。基本上,它有两个版本,一个是自由开源的社区版,另一个是付费的专业版。 + +![][31] + +PyCharm 是可高度自定义的 IDE 并且有很多功能,如错误高亮、代码分析、集成单元测试和 Python 调试器等。PyCharm 对于大多数 Python 程序员和开发者来说是首选 IDE。 + +### 28、咖啡因 + +想象一下你在 Youtube 上看视频或阅读一篇新文章,突然你的 Ubuntu 锁屏了,我知道它很烦人。我们很多人都会遇到这种情况,所以咖啡因是一个阻止 Ubuntu 锁屏或屏幕保护程序的工具。 + +![][32] + +咖啡因指示器是一个轻量级的工具,它添加图标到通知栏,你可以在那里轻松的激活或禁止它。不需要额外的设置。 + +``` +$ sudo add-apt-repository ppa:eugenesan/ppa +$ sudo apt-get update +$ sudo apt-get install caffeine -y +``` + +### 29、Etcher USB 镜像写入器 + +Etcher 是一个由 resin.io 开发的 USB 镜像写入器。它是一个跨平台的应用,可以帮助你将 ZIP、ISO、IMG 格式的镜像文件写入到 USB 存储中。如果你经常尝试新的操作系统,那么 Ethcher 是你必有的简单可靠的工具。 + +![][33] + +Etcher 有干净的用户界面,可以指导你在三步内烧录镜像到 USB 驱动或 SD 卡的过程。步骤包括选择镜像文件、选择 USB 驱动 和最终的烧录(写文件到 USB 驱动)。你可以从它的[官网][34]下载和安装 Etcher。 + +### 30、Neofetch + +Neofetch 是一个酷炫的系统信息工具,通过在终端中运行 `neofetch` 命令,它会给你关于你的系统的所有信息。它酷是因为它可以给你关于桌面环境、内核版本、bash 版本和你正在运行的 GTK 主题的信息。 + +![][35] + +与其它系统信息工具比较,Nefetch 是高度自定义的工具。你可以使用命令行进行各种自定义。 + +``` +$ sudo add-apt-repository ppa:dawidd0811/neofetch +$ sudo apt-get update +$ sudo apt-get update install neofetch +``` + +### 31、Liferea + +Liferea(Linux 订阅阅读器)是一个自由开源的新闻聚合工具,用于在线新闻订阅。使用新的聚合非常快捷和简单,支持各种格式例如 RSS/RDF,Atom 等。 + +![][36] + +Liferea 自带与 TinyTinyRSS 的同步支持,它给了你离线阅读的能力。你会发现,就可靠性和灵活性而言,它是 Linux 上最好的订阅工具之一。 + +``` +$ sudo add-apt-repository ppa:ubuntuhandbook1/apps +$ sudo apt-get update +$ sudo apt-get install liferea +``` + +### 32、Shutter + +在 Ubuntu 中很容易截屏,但当需要编辑截屏时 Shutter 是你必不可少的应用。它帮助你捕获、编辑和轻松的共享截屏。使用 Shutter 的选择工具,你可以选择屏幕的特定区域来截屏。 + +![][37] + +Shutter 是一个功能强大的截图工具,提供了添加截图效果、画线等功能。它同样给你上传截屏到各种图像托管站点的选项。你可以直接在 Ubuntu 软件中心中下载和安装。 + +### 33、Weather + +Weather 是一个小的应用,可以给你关于你的城市或世界上其它位置的实时天气信息。它简单而且轻量级,可以给你最多 7 天的详细天气预报和今明两天的每个小时的细节信息。 + +![][38] + +它集成在 GNOME shell 中,给你关于最近搜索位置的当前天气状态。它有极简的用户界面,在最小硬件需求下运行很顺畅。 + +### 34、Ramme + +Ramme 是一个很酷的非官方的 Instagram 桌面客户端,给你带来 Instagram 移动端的感觉。它是基于 Electron 开发的客户端,所以它复现了 Instagram 应用的功能,并提供了主题自定义的功能。 + +![][39] + +但是由于 Instagram 的 API 限制,你不能使用 Ramme 客户端上传图像,但你可以订阅 Instagram 流、喜欢和评论文章,给好友发消息。你可以从 [Github][40] 下载 Ramme 安装文件。 + +### 35、Thunderbird + +Thunderbird 是一个开源的邮件客户端,是很多 Linux 发行版的默认邮件客户端。尽管在 2017 年与 Mozilla 分道扬镳(LCTT 译注: Thunderbird 现在由 Thunderbird 议会独立决策,只是将财务和法律关系留在 Mozilla 基金会),Thunderbird 仍然是 Linux 平台非常流行的最好的邮件客户端。它自带的功能包括垃圾邮件过滤、IMAP 和 POP 邮件同步、日历支持、通讯录集成和很多其它可以开箱即用的功能。 + +![][41] + +它是一个跨平台的邮件客户端,由社区提供对所有平台提供支持。因其可以高度自定义,你可以改变它的外观和观感。 + +### 36、Pidgin + +Pidgin 是一个即时信息客户端,你能够在单个窗口下登录不同的即时通讯网络。你可以登录到像 Google Talk、XMPP、AIM、Bonjour 等即时通讯。 + +![][42] + +Pidgin 拥有你所期待的即时通信的所有特点,你总是可以通过安装额外的插件来提升其表现。 + +``` +$ sudo apt-get install pidgin +``` + +### 37、Krita + +Krita 是由 KDE 开发的自由开源的数字绘制、编辑和动画的应用。它有优秀的用户界面,每个组件都恰到好处,因此你可以轻松找到你所需要的。 + +![][43] + +它使用 OpenGL 画布,这提升了 Krita 的性能,并且提供了很多功能,如各种绘画工具、动画工具、矢量工具、层和遮罩等很多。可在 Ubuntu 软件中心获取 Krita 并下载。 + +### 38、Dropbox + +Dropbox 是一个出色的云存储客户端,正确安装后,它在 Ubuntu 中运行得非常好。即使 Google Drive 在 Ubuntu 16.04 LTS 和以后的版本中运行得不错,就 Dropbox 提供的特点而言,Dropbox 仍然是 Linux 上的首选云存储工具。 + +![][44] + +它总是在后台运行,可以备份你系统上的新文件到云存储,持续保持你的电脑和云存储间的同步。 + +``` +$ sudo apt-get install nautilus-dropbox +``` + +### 39、Kodi + +Kodi 的前身是人们所熟知的 Xbox 媒体中心(XBMC),它是一个开源的媒体播放器。你可以在线或离线播放音乐、视频、播客、视频游戏等。这个软件最初是为第一代的 Xbox 游戏主机开发的,之后慢慢地移植到了个人电脑上。 + +![][45] + +Kodi 有令人印象深刻的视频界面,快速而强大。它是可高度定制的媒体播放器,你可以通过安装插件,来获取在线流服务,如 Pandora、Spotify、Amazon Prime Video、Netflix 和 YouTube 等等。 + +### 40、Spotify + +Spotify 是最好的在线媒体流站点之一。它提供免费和付费的音乐、播客、视频流服务。早期的 Spotify 不支持 Linux,但现在它有了自己的全功能的 Ubuntu 客户端。 + +![][46] + +与 Google Play 音乐播放器一样,Spotify 是必不可少的媒体播放器。你只需要登录你的 Spotify 账户,就能在任何地方获取你最爱的在线内容。 + +### 41、Brackets + +Brackets 是一个由 Adobe 开发的开源的文本编辑器。它可以用来进行 web 开发和设计,例如 HTML、CSS 和 JavaScript。它带有的实时预览模式是一个很棒的特点,当你在脚本中修改时,你可以获得实时预览效果。 + +![][47] + +它是 Ubuntu 上的现代文本编辑器之一,拥有平滑的用户界面,这将 web 开发任务带到新的水平。它同样提供了行内编辑器的特点,支持流行的扩展像 Emmet、Beautify、Git、File Icons 等等。 + +### 42、Bitwarden + +现今,账户安全是一个严重的问题,我们可以看到用户密码被盗和重要数据受到侵害的安全漏洞在不断增加。推荐你使用 Bitwarden,将你的所有账户和登录密码安全地存在一个地方。 + +![][48] + +Bitwarden 使用 AES-256 加密技术来存储所有的登录细节,只有用户可以访问这些数据。它同样可以帮你创建健壮的密码,因为弱密码容易被黑。 + +### 43、Terminator + +Terminator 是一个开源的终端模拟器,是用 Java 语言开发的。它是一个跨平台的模拟器,允许你在单个窗口有多个终端,在 Linux 默认的终端模拟器中不是这样。 + +![][49] + +Terminator 其它杰出的特点包括自动日志、拖放、垂直和水平的智能滚动等。 + +``` +$ sudo apt-get install terminator +``` + +### 44、Yak Yak + +Yak Yak 是一个开源的非官方的 Google Hangouts 消息的桌面客户端。它可以作为 Microsort Skype 的一个不错的替代品,自身拥有很多让人吃惊的特点。你可以启用桌面通知、设置语言偏好,使用很少的内存和处理能力就可以工作。 + +![][50] + +Yak Yak 拥有你期待的任何即时消息应用的所有特点,例如输入指示、拖放媒体文件、音/视频电话。 + +### 45、Thonny + +Thonny 是一个简单和轻量级的 IDE,尤其是为编程的初学者设计的。如果你是编程初学者,这是你必备的 IDE,因为当用 Python 编程的时候它会帮你学习。 + +![][51] + +Thonny 同样是一个很棒的调试工具,它支持调试过程中的变量值即时显示,除此之外,它还提供了独立的窗口以执行函数调用,简单的用户界面等等。 + +``` +$ sudo apt-get install thonny +``` + +### 46、字体管理器 + +字体管理器是一个轻量级的工具,用于管理、添加、移除你的 Ubuntu 系统上的字体。它是特别为 Gnome 桌面环境构建的,在用户不知道如何在命令行管理字体时会发现这个工具非常有用。 + +![][52] + +这个 Gtk+ 字体管理器不是为专业用户准备的,它有简单的用户界面,你会发现很容易使用。你只需要从网上下载字体文件,并使用字体管理器添加它们。 + +``` +$ sudo add-apt-repository ppa:font-manager/staging +$ sudo apt-get update +$ sudo apt-get install font-manager +``` + +### 47、Atril 文档查看器 + +Atril 是一个简单的文件查看器,支持便携文件格式(PDF)、PostScript(PS)、Encapsulated PostScript(EPS)、DJVU 和 DVI。Atril 与 MATE 桌面环境捆绑在一起,它比大多数 Linux 发行版中默认的文件查看器 Evince 更理想。 + +![][53] + +Atril 用简单和轻量级的用户界面,可高度自定义,提供了搜索、书签、UI 左侧的缩略图等特点。 + +``` +$ sudo apt-get install atril +``` + +### 48、Notepadqq + +如果你曾在 Windows 上用过 Notepad++,并且想在 Linux 上寻找相似的程序,别担心,开发者们已经将它移植到 Linux,名为 Notepadqq。它是一个简单而强大的文本编辑器,你可以在日常使用它,或用于各种语言进行编程。 + +![][54] + +尽管是作为一个简单的文本编辑器,它有一些令人惊奇的特点,例如,你可以设置主题为暗黑或明亮模式、多选、正则搜索和实时高亮。 + +``` +$ sudo add-apt-repository ppa:notpadqq-team/notepadqq +$ sudo apt-get update +$ sudo apt-get install notepadqq +``` + +### 49、Amarok + +Amarok 是在 KDE 项目下开发的一个开源音乐播放器。它有直观的界面,让你感觉在家一样,因此你可以轻易的发现你最喜爱的音乐。除了 Clementine,当你寻找 Ubuntu 上的完美的音乐播放器时,Amarok 是一个很棒的选择。 + +![][55] + +Amarok 上的一些顶尖的特点,包括智能播放列表支持,集成在线服务像 MP3tunes、Last.fm、 Magnatune 等。 + +### 50、Cheese + +Cheese 是 Linux 默认的网络摄像头应用,在视频聊天或即时消息应用中非常有用。除了这些,你还可以用这个应用来照相或拍视频,附带一些迷人的特效。 + +![][56] + +它同样提供闪拍模式,让你快速拍摄多张相片,并提供你共享给你的朋友和家人的选项。Cheese 预装在大多数的 Linux 发行版中,但是你同样可以在软件中心下载它。 + +### 51、MyPaint + +MyPaint 是一个自由开源的光栅图形编辑器,专于数字绘画而不是图像操作和相片处理。它是跨平台的应用,与 Corel Painter 很相似。 + +![][57] + +MyPaint 可能是 Windows 上的 Microsoft Paint 应用的很好的替代品。它有简单的用户界面,快速而强大。MyPaint 可以软件中心下载。 + +### 52、PlayOnLinux + +PlayOnLinux 是 WINE 模拟器的前端,允许你在 Linux 上运行 Windows 应用。你只需要在 WINE 中安装 Windows 应用,之后你就可以轻松的使用 PlayOnLinux 启动应用和游戏了。 + +![][58] + +### 53、Akregator + +Akregator 是在 KDE 项目下为 KDE Plasma 环境开发的默认 RSS 阅读器。它有简单的用户界面,自带了 KDE 的 Konqueror 浏览器,所以你不需要在阅读新闻提要时切换应用。 + +Akregator 同样提供了桌面通知、自动摘要等功能。你会发现在大多数 Linux 发行版中它是最好的提要阅读器。 + +### 54、Brave + +Brave 是一个开源的 web 浏览器,拦截了广告和追踪,所以你可以快速和安全的浏览你的内容。它实际做的是代表你向网站和 Youtube 主播支付了费用。如果你宁可支持网站和 Youtube 主播也不愿意看广告,这个浏览器更适合你。 + +![][60] + +对于那些想要安全浏览,但又不想错过互联网上重要信息的人来说,这是一个新概念,一个不错的浏览器。 + +### 55、Bitcoin Core + +Bitcoin Core 是一个比特币官方的客户端,非常安全和可靠。它持续追踪你的所有比特币交易以保证你的所有交易都是有效的。它可以防止比特币矿工和银行完全掌控你的比特币钱包。 + +![][61] + +Bitcoin Core 同样提供了其它重要的特点,像私钥备份、冷存储、安全通知等。 + +``` +$ sudo add-apt-repository ppa:bitcoin/bitcoin +$ sudo apt-get update +$ sudo apt-get install bitcoin-qt +``` + +### 56、Speedy 重复查找工具 + +Speedy 重复查找工具是一个跨平台的文件查找工具,用来帮助你查找你的系统上的重复文件,清理磁盘空间。它是一个智能工具,可以在整个硬盘上搜索重复文件,它同样提供了智能过滤功能,根据文件类型、扩展或大小帮你找到文件。 + +![][62] + +它有一个简单和整洁的用户界面,易于上手。从软件中心下载完后你就可以开始磁盘空间清理了。 + +### 57、Zulip + +Zulip 是一个自由开源的群聊应用,被 Dropbox 收购了。它是用 Python 写的,用 PostgreSQL 数据库。它被设计和开发为其它如 Slack 和 HipChat 的聊天应用的替代品。 + +![][63] + +Zulip 功能丰富,支持例如拖放文件、群聊、私密聊天、图像预览等。它也集成了 Github、JIRA、Sentry 和上百种其它服务。 + +### 58、Okular + +Okular 是为 KDE 桌面环境开发的跨平台的文件查看器。它是一个简单的文件查看器,支持 Portable Document Format (PDF)、PostScript、DjVu、Microsoft Compiled HTML help 和很多其它文件格式。 + +![][64] + +Okular 是在 Ubuntu 上你应该尝试的最好的文件查看器之一,它提供了 PDF 文件评论、画线、高亮等很多功能。你同样可以从 PDF 文件中提取文本文件。 + +### 59、FocusWriter + +FocusWriter 是一个集中注意力的字处理工具,隐藏了你的桌面屏幕,让你能够专注写作。正如你看到的屏幕截图,整个 Ubuntu 屏幕被隐藏了,只有你和你的字处理工具。但你总是可以进入 Ubuntu 屏幕,当你需要的时候,只需要将光标移动到屏幕的边缘即可。 + +![][65] + +它是一个轻量级的字处理器,支持 TXT、RTF、ODT 文件格式。它同样提供了可完全定制的用户界面,还有定时器、警报、每日目标、声音效果等特点,已经被翻译为 20 种语言。 + +### 60、Guake + +Guake 是为 GNOME 桌面环境准备的酷炫的下拉式终端。当你需要时,Guake 就会闪现,当你任务完成后,它就会消失。你只需要按 F12 按钮来启动或退出,这样启动 Guake 比启动一个新的终端窗口更快。 + +![][66] + +Guake 是一个功能丰富的终端,支持多栏,只需要点击几下就能将你的终端内容保存到文件,并且有完全可定制的用户界面。 + +``` +$ sudo apt-get install guake +``` + +### 61、KDE Connect + +KDE Connect 是 Ubuntu 上的一个很棒的应用,我很想在这篇马拉松文章中将它提早列出来,但是竞争太激烈了。总之 KDE Connect 可以将你的 Android 智能手机的通知直接转到 Ubuntu 桌面来。 + +![][67] + +有了 KDE Connect,你可以做很多事,例如检查手机电池电量,在电脑和 Android 手机间交换文件,剪贴板同步,发送短信,你还可以将你的手机当作无线鼠标或键盘。 + +``` +$ sudo add-apt-repository ppa:webupd8team/indicator-kedeconnect +$ sudo apt-get update +$ sudo apt-get install kdeconnect indicator-kdeconnect +``` + +### 62、CopyQ + +CopyQ 是一个简单但是非常有用的剪贴板管理器,它保存你的系统剪贴板内容,无论你做了什么改变,你都可以在你需要的时候搜索和恢复它。它是一个很棒的工具,支持文本、图像、HTML 和其它格式。 + +![][68] + +CopyQ 自身有很多功能像拖放、复制/拷贝、编辑、移除、排序、创建等。它同样支持集成文本编辑器,如 Vim,所以如果你是程序员,这非常有用。 + +``` +$ sudo add-apt-repository ppa:hluk/copyq +$ sudo apt-get update +$ sudo apt-get install copyq +``` + +### 63、Tilix + +Tilix 是一个功能丰富的高级 GTX3 平铺式终端模拟器。如果你使用 GNOME 桌面环境,那你会爱上 Tilix,因为它遵循了 GNOME 用户界面指导。Tilix 模拟器与大多数 Linux 发行版上默认终端模拟器相比,它给了你切分终端窗口为多个终端面板的功能。 + +![][69] + +Tilix 提供了自定义链接、图片支持、多面板、拖放、固定布局等功能。它同样支持键盘快捷方式,你可以根据你的需要在偏好设置中自定义快捷方式。 + +``` +$ sudo add-apt-repository ppa:webupd8team/terminix +$ sudo apt-get update +$ sudo apt-get install tilix +``` + +### 64、Anbox + +Anbox 是一个 Android 模拟器,可以让你在 Linux 系统中安装和运行 Android 应用。它是自由开源的 Android 模拟器,通过使用 Linux 容器来执行 Android 运行时环境。它使用最新的 Linux 技术 和 Android 发布版,所以你可以运行任何原生的 Android 应用。 + +![][70] + +Anbox 是现代和功能丰富的模拟器之一,提供的功能包括无限制的应用使用,强大的用户界面,与宿主系统无缝集成。 + +首先你需要安装内核模块。 + +``` +$ sudo add-apt-repository ppa:morphis/anbox-support +$ sudo apt-get update +$ sudo apt install anbox-modules-dkms +``` + +然后你可以使用 snap 来安装 Anbox。 + +``` +$ snap install --devmode -- beta anbox +``` + +### 65、OpenShot + +你会发现 OpenShot 是 Linux 发行版中最好的开源的视频编辑器。它是跨平台的视频编辑器,易于使用,性能方面毫不逊色。它支持所有主流的音频、视频、图像格式。 + +![][71] + +OpenShot 有干净的用户界面,功能有拖放、剪切缩放、尺寸缩放、裁剪、快照、实时预览、音频混合和编辑等多种功能。 + +``` +$ sudo add-apt-repository ppa:openshot.developers/ppa +$ sudo apt-get update +$ sudo apt-get install openshot -qt +``` + +### 66、Plank + +如果你在为你的 Ubuntu 桌面寻找一个 Dock 导航栏,那 Plank 应该是一个选择。它是完美的,安装后你不需要任何的修改,除非你想这么做,它有内置的偏好面板,你可以自定义主题、Dock 大小和位置。 + +![][72] + +尽管是一个简单的导航栏,Plank 提供了通过拖放来重新摆放,固定和运行应用图标,透明主题支持等功能。 + +``` +$ sudo add-apt-repository ppa:ricotz/docky +$ sudo apt-get update +$ sudo apt-get install plank +``` + +### 67、Filezilla + +Filezilla 是一个免费和跨平台的 FTP 应用,包括 Filezilla 客户端和服务器。它让你使用 FTP 和加密的 FTP,如 FTPS 和 SFTP 传输文件,支持 IPv6 网络协议。 + +![][73] + +它是一个简单的文件传输应用,支持拖放,支持世界范围的各种语言,多任务的强大用户界面,可以控制和配置传输速度。 + +### 68、Stacer + +Stacer 是一个开源的系统诊断和优化工具,使用 Electron 开发框架开发。它有一个优秀的用户界面,你可以清理缓存内存、启动应用、卸载不需要的应用、掌控后台系统进程。 + +![][74] + +它也可以让你检查磁盘、内存和 CPU 使用情况,给你下载和上传的实时状态。它看起来像 Ubuntu clener 的强力竞争者,但是两者都有独特的特点。 + +``` +$ sudo add-apt-repository ppa:oguzhaninan/stacer +$ sudo apt-get update +$ sudo apt-get install stacer +``` + +### 69、4K 视频下载器 + +4K 视频下载器是一个简单的视频下载工具,你可以用来从 Vimeo、Facebook、YouTube 和其它在线视频流站点下载视频、播放列表、频道。它支持下载 YouTuBe 播放列表和频道,可以采用 MP4、MKV、M4A、3GP 和很多其它音/视频格式。 + +![][75] + +4K 视频下载器不是你想的那么简单,除了正常的视频下载,它支持 3D 和 360 度视频下载。它同样提供应用内代理设置、直连 iTunes 等功能。你可以从[这里][76]下载。 + +### 70、Qalculate + +Qalculate 是一个多用途、跨平台的桌面计算器,简单而强大。它可以用来解决复杂的数学问题和等式、货币汇率转换和很多其它日常计算。 + +![][77] + +它有优秀的用户界面,提供了自定义功能、单位计算、符号计算、四则运算、画图和很多你可以在科学计算器上发现的功能。 + +### 71、Hiri + +Hiri 是一个跨平台的邮件客户端,使用 Python 语言开发的。它有平滑的用户界面,就它的功能和服务而言,是 Micorsoft Outlook 的很好的替代品。这是很棒的邮件客户端,可以用来发送和接收邮件,管理通讯录、日历和任务。 + +![][78] + +它是一个具有丰富特点的邮件客户端,提供的功能有集成的任务管理器、邮件同步、邮件评分、邮件过滤等多种功能。 + +``` +$ sudo snap install hiri +``` + +### 72、Sublime Text + +Sublime Text 是一个跨平台的源代码编辑器,用 C++ 和 Python 写的。它有 Python 语言编程接口(API),支持所有主流的编程语言和标记语言。它是简单轻量级的文本编辑器,可被用作 IDE,包含自动补全、语法高亮、分窗口编辑等功能。 + +![][79] + +这个文本编辑器包括一些额外特点:任意跳转、跳转定义、多选、命令模式和可完全定制的用户界面。 + +``` +$ sudo apt-get install sublime-text +``` + +### 73、TeXstudio + +Texstudio 是一个创建和编辑 LaTex 文件的集成写作环境。它是开源的编辑器,提供了语法高亮、集成的查看器、交互式拼写检查、代码折叠、拖放等特点。 + +![][80] + +它是跨平台的编辑器,有简单轻量级的用户界面,易于使用。它集成了 BibTex 和 BibLatex 目录管理器,同样有集成的 PDF 查看器。你可以从[官网][81]和 Ubuntu 软件中心下载 Texstudio。 + +### 74、QtQR + +QtQR 是一个基于 Qt 的应用,让你在 Ubuntu 中创建和读取二维码。它是用 Python 和 Qt 开发的,有简单和轻量级的用户界面,你可以编码网站地址、邮件、文本、短消息等。你也可以用网络相机解码二维码。 + +![][82] + +如果你经常处理产品销售和服务,QtQR 会证明是有用的工具,我觉得没有能在如此低硬件的要求下能和 QtQR 一样提供类似功能顺畅运行的应用了。 + +``` +$ sudo add-apt-repository ppa: qr-tools-developers/qr-tools-stable +$ sudo apt-get update +$ sudo apt-get install qtqr +``` + +### 75、Kontact + +Kontact 是一个为 KDE 桌面环境开发的集成的个人信息管理器(PIM)。它集成了多个软件到一个集合中,在一个用户界面集成了 KMail、KOrganizer和 KAddressBook,你可以管理所有的邮件、通讯录、日程表等。 + +![][83] + +它可能是 Microsoft Outlook 的非常好的替代品,因为它是快速且高度高配置的消息管理工具。它有很好的用户界面,你会发现很容易上手。 + +``` +$ sudo apt-get install kontact +``` + +### 76、NitroShare + +NitroShare 是一个跨平台、开源的网络文件共享应用。它让你轻松的在局域网的多个操作系统中共享文件。它简单而强大,当在局域网中运行 NitroShare 时,它会自动侦查其它设备。 + +![][84] + +文件传输速度让 NitroShare 成为一个杰出的文件共享应用,它在能够胜任的硬件中能够达到 GB 级的传输速度。没有必要额外配置,安装完成后你就可以开始文件传输。 + +``` +$ sudo apt-add-repository ppa:george-edison55/nitroshare +$ sudo apt-get update +$ sudo apt-get install nitroshare +``` + +### 77、Konversation + +Konversation 是一个为 KDE 桌面环境开发的开源的网络中继聊天(IRC)客户端。它给了你到 Freenode 网络频道的快速入口,你可以为大多数发行版找到支持。 + +![][85] + +它是一个简单的聊天客户端,支持 IPv6 链接、SSL 服务器支持、书签、屏幕通知、UTF-8 检测和另外的主题。它易于使用的 GUI 是高度可配置的。 + +``` +$ sudo apt-get install konversation +``` + +### 78、Discord + +如果你是硬核游戏玩家,经常玩在线游戏,我有一个很棒的应用推荐给你。Discord 是一个免费的网络电话应用,尤其是为在线游戏者们设计的。它是一个跨平台的应用,可用来文字或语音聊天。 + +![][86] + +Discord 是一个非常流行的语音通话应用游戏社区,因为它是完全免费的,它是 Skype、Ventrilo、Teamspeak 的很好的竞争者。它同样提供清晰的语音质量、现代的文本聊天,你可以共享图片、视频和链接。 + +### 79、QuiteRSS + +QuiteRSS是一个开源的 RSS 和 Atom 新闻摘要的聚合应用。它是跨平台的摘要阅读器,用 Qt 和 C++ 写的。它有简单的用户界面,你可以改变为经典或者报纸模式。它集成了 webkit 浏览器,因此,你可以在单个窗口执行所有任务。 + +![][87] + +QuiteRSS 自带了很多功能,像内容过滤、自动规划摘要、导入/导出 OPML、系统托盘集成了很多其它摘要阅读器有的特点。 + +``` +$ sudo apt-get install quiterss +``` + +### 80、MPV Media Player + +MPV 是一个自由开源的媒体播放器,基于 MPlayer 和 MPlayer 2。它有简单的用户界面,用户只需要拖放音/视频文件来播放,因为在 GUI 上没有添加媒体文件的选项。 + +![][88] + +关于 MPV 的一件事是它可以轻松播放 4K 视频,Linux 发行版中的其它媒体播放器可能做不到。它同样给了用户播放在线视频流站点如 YouTube 和 Dailymotion 的能力。 + +``` +$ sudo add-apt-repository ppa:mc3man/mpv-tests +$ sudo apt-get update +$ sudo apt-get install -y mpv +``` + +### 81、Plume Creator + +如果你是一个作家,那么 Plume Creator 是你必不可少的应用,因为你在 Ubuntu 上找不到其它应用像 Plume Creater 这样。写作和编辑故事、章节是繁重的任务,在 Plume Creator 这个令人惊奇的工具的帮助下,将大大帮你简化这个任务。 + +![][89] + +它是一个开源的应用,拥有精简的用户界面,开始你可能觉得困惑,但不久你就会习惯的。它提供的功能有:编辑笔记、摘要、导出 HTML 和 ODT 格式、富文本编辑。 + +``` +$ sudo apt-get install plume-creator +``` + +### 82、Chromium Web 浏览器 + +Chromium 是一个由 Google 开发和发布的开源 Web 浏览器。Chromium 就其外观和特点而言,很容易被误认为是 Chrome。它是轻量级和快速的网络浏览器,拥有最小用户界面。 + +![][90] + +如果你经常在 Windows 上使用 Google Chrome,而想在 Linux 上寻找一个类似的浏览器,那么 Chromium 就是你的最佳选择,你可以登录到你的 Google 账户以访问包括 Gmail 在内的所有 Google 服务。 + +### 83、简单天气指示器 + +简单天气指示器是用 Python 开发的开源天气提示应用。它自动侦查你的位置,并显示你天气信息像温度,下雨的可能性,湿度,风速和可见度。 + +![][91] + +简单天气指示器自带一些可配置项,例如位置检测、温度单位、位置可见度开关等等。它是一个还酷的应用,可以根据你的桌面来调整。 + +### 84、SpeedCrunch + +SpeedCrunch 是一个快速和高精度的科学计算器。它预置了数学函数、用户定义函数、复数和单位转换支持。它有简单的用户界面并易于使用。 + +![][92] + +这个科学计算器有令人吃惊的特点,如结果预览、语法高亮和自动补全。它是跨平台的,并有多语言支持。 + +### 85、Scribus + +Scribus 是一个自由开源的桌面出版应用,允许你创建宣传海报、杂志和图书。它是基于 Qt 工具器的跨平台应用,在 GNU 通用公共许可证下发布。它是一个专业的应用,拥有 CMYK 和 ICC 颜色管理的功能、基于 Python 的脚本引擎,和 PDF 创建功能。 + +![][93] + +Scribus 有相当好的用户界面,易于使用,可以在低配置下轻松使用。在所有的最新的 Linux 发行版的软件中心可以下载它。 + +### 86. Cura + +Cura 是一个由 David Braam 开发的开源的 3D 打印应用。Ultimaker Cura 是 3D 打印世界最流行的软件,世界范围有百万用户在使用。它遵守 3D 打印模型的 3 步:设计、准备、打印。 + +![][94] + +它是功能丰富的 3D 打印应用,为 CAD 插件和扩展提供了无缝支持。它是一款简单易于使用的工具,新手艺术家可以马上开始了。它支持主流的文件格式像 STL、3MF 和 OBJ。 + +### 87、Nomacs + +Nomacs 是一款开源、跨平台的图像浏览器,支持所有主流的图片格式包括 RAW 和 psd 图像。它可以浏览 zip 文件中的图像或者 Microsoft Office 文件并提取到目录。 + +![][95] + +Nomacs 拥有非常简单的用户界面,图像缩略图在顶部,它提供了一些基本的图像操作特点像修改、调整大小、旋转、颜色纠正等。 + +``` +$ sudo add-apt-repository ppa:nomacs/stable +$ sudo apt-get update +$ sudo apt-get install nomacs +``` + +### 88、BitTicker + +BitTicker 是一个 Ubuntu 上的在线的 BTC-USDT 价格接收器。它是一个简单的工具,能够连接到 bittrex.com 市场,提取最新的 BTC-USDT 价格,并在系统托盘显示 Ubuntu 时钟。 + +![][96] + +它是简单但有用的工具,如果你经常有规律的投资比特币并且必须了解价格波动的话。 + +### 89、Organize My Files + +Organize My Files 是一个跨平台的一键点击文件组织工具,它在 Ubuntu 中以 Snap 包的形式获得。它简单而强大,可以帮助你找到未组织的文件,通过简单点击来掌控它们。 + +![][97] + +它有易于理解的用户界面,强大且快速。它提供了很多功能:自动组织、递归组织、智能过滤和多层文件夹组织等。 + +### 90、GnuCash + +GnuCash 是一个金融账户软件,在 GNU 公共证书下自由使用。它是个人和商业账户的理想软件。它有简单的用户界面允许你追踪银行账户、股票、收入和花费。 + +![][98] + +GnuCash 实现了双入口记账系统,基于专业的账户原则来确保帐薄的平衡和报告的精确。 + +### 91、Calibre + +Calibre 是一个跨平台的开源的面向电子书需求的解决方案。它是一个简单的电子书管理器,提供显示、创建、编辑电子书、组织已存在的电子书到虚拟书库、同步和其它更多功能。 + +![][99] + +Calibre 同样可以帮你转换电子书到你需要的格式并发送到你的电子书阅读设备。Calibre 是一个很棒的工具,如果你经常阅读和管理电子书的话。 + +### 92、MATE 词典 + +MATE 词典是一个简单的词典,基本上是为 MATE 桌面环境开发的。你可以仅仅输入字然后这个字典会显示意思和引用。 + +![][100] + +它是简单和轻量级的在线词典,有极简的用户界面。 + +### 93、Converseen + +Converseen 是免费的跨平台的批量图片处理应用,允许你转换、编辑、调整、旋转、裁剪大量图像,而仅仅需要一次鼠标点击。它提供了使用前缀或后缀图像批量重命名和从一个 Windows 图标文件提取图像等功能。 + +![][101] + +它有很好的用户界面,易于使用,即时你是一个新手。它也能够转换整个 PDF 文件为图像集合。 + +### 94、贴片地图编辑器 + +贴片地图编辑器是一个免费的关卡地图编辑器,允许你以正交、等轴、和六角等方向编辑地图。这个工具对于游戏开发者在游戏引擎开发阶段内可能非常有用。 + +![][102] + +它是一个通用的地图编辑器,让你创建升级位置、地图布局、碰撞区域和敌人位置。它保存所有的数据为 tmx 格式。 + +### 95. Qmmp + +Qmmp 是一个自由开源的音频播放器,用 C++ 和 Qt 开发的。它是跨平台的音频播放器,界面与 Winamp 很相似。 它有简单的直观的用户界面,可以用 Winamp 皮肤替代默认的 UI。 + +![][103] + +它提供了自动唱片集封面获取、支持多艺术家,另外的插件和扩展支持和其它与 Winamp 相似的特点。 + +``` +$ sudo add-apt-repository ppa:forkotov02/ppa +$ sudo apt-get update +$ sudo apt-get install qmmp qmmp-q4 qmmp-plugin-pack-qt4 +``` + +### 96、Arora + +Arora 是一个免费开源的 web 浏览器,提供了专有的下载管理器、书签、私密模式、选项卡式浏览。 + +![][104] + +Arora web 浏览器由 Benjamin C. Meyer 开发,它由于它的轻量自然灵活的特点在 Linux 用户间很受欢迎。 + +### 97、XnSketch + +XnSketch 是一个 Ubuntu 上的酷应用,只需要几次点击,就能帮你转换你的图片为卡通或素描图。它展现了 18 个不同的效果,例如:锐化、白描、铅笔画等等。 + +![][105] + +它有优秀的用户界面,易于使用。一些额外的特点包括透明度和边缘锐化调整、对比度、亮度、饱和度调整。 + +### 98、Geany + +Geany 是一个简单而轻量级的文本编辑器,像一个集成开发环境。它是跨平台的文本编辑器,支持所有主流编程语言包括 Python、C++、LaTex、Pascal、C#、etc。 + + +![][106] + +Geany 有个类似于 Notepad++ 编程编辑器的简单用户界面。它提供了 IDE 的功能,如代码导航、自动补完、格式高亮,并支持扩展。 + +``` +$ sudo apt-get install geany +``` + +### 99、Mumble + +Mumble 是又一个 VoIP 应用,与 Discord 类似。Mumble 同样最初是为在线游戏玩家设计的,使用客户端-服务器架构提供了端到端的聊天。在 Mumble 上的声音质量非常好,它提供了端到端的加密来确保私密性。 + +![][107] + +Mumble 是一个开源应用,有简单的用户界面,易于使用。Mumble 在 Ubuntu 软件中心可以下载。 + +``` +$ sudo apt-get install mumble-server +``` + +### 100、Deluge + +Deluge 是一个跨平台的轻量级的 BitTorrent 客户端,能够用来在 Ubuntu 上下载文件。BitTorrent 客户端与很多 Linux 发行版一起发行,但 Deluge 是最好的 BitTorrent 客户端,界面简单、易于使用。 + +![][108] + +Deluge 拥有你可以在其它 BitTorrent 客户端上发现的所有功能,但是一个功能特别突出,它给了用户从其它设备访问客户端的能力,这样你可以远程下载文件了。 + +``` +$ sudo add-apt-repository ppa:deluge-team/ppa +$ sudo apt-get update +$ sudo apt-get install deluge +``` + +所以这些就是 2018 年我为大家选择的 Ubuntu 上最好的 100 个应用了。所有列出的应用都在 Ubuntu 18.04 上测试了,肯定在老版本上也能运行。 + +-------------------------------------------------------------------------------- + +via: https://linuxhint.com/100_best_ubuntu_apps/ + +作者:[Swapnil Tirthakar][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[warmfrog](https://github.com/warmfrog) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://linuxhint.com/author/swapnil/ +[1]:https://linuxhint.com/applications-2018-ubuntu/ +[2]:https://linuxhint.com/wp-content/uploads/2018/06/100-Best-Ubuntu-Apps.png +[3]:https://linuxhint.com/wp-content/uploads/2018/06/Chrome.png +[4]:https://linuxhint.com/wp-content/uploads/2018/06/Steam.png +[5]:https://linuxhint.com/wp-content/uploads/2018/06/Wordpress.png +[6]:https://linuxhint.com/wp-content/uploads/2018/06/VLC.png +[7]:https://linuxhint.com/wp-content/uploads/2018/06/Atom-Text-Editor.png +[8]:https://linuxhint.com/wp-content/uploads/2018/06/GIMP.png +[9]:https://linuxhint.com/wp-content/uploads/2018/06/Google-Play.png +[10]:https://www.googleplaymusicdesktopplayer.com/ +[11]:https://linuxhint.com/wp-content/uploads/2018/06/Franz.png +[12]:https://meetfranz.com/#download +[13]:https://linuxhint.com/wp-content/uploads/2018/06/Synaptic.png +[14]:https://linuxhint.com/wp-content/uploads/2018/06/Skype.png +[15]:https://linuxhint.com/wp-content/uploads/2018/06/VirtualBox.png +[16]:https://linuxhint.com/wp-content/uploads/2018/06/Unity-Tweak-Tool.png +[17]:https://linuxhint.com/wp-content/uploads/2018/06/Ubuntu-Cleaner.png +[18]:https://linuxhint.com/wp-content/uploads/2018/06/Visual-Studio-Code.png +[19]:https://linuxhint.com/wp-content/uploads/2018/06/Corebird.png +[20]:https://linuxhint.com/wp-content/uploads/2018/06/Pixbuf.png +[21]:https://linuxhint.com/wp-content/uploads/2018/06/Clementine.png +[22]:https://linuxhint.com/wp-content/uploads/2016/06/blender.jpg +[23]:https://linuxhint.com/wp-content/uploads/2018/06/Audacity.png +[24]:https://linuxhint.com/wp-content/uploads/2018/06/Vim.png +[25]:https://linuxhint.com/wp-content/uploads/2018/06/Inkscape-1.png +[26]:https://linuxhint.com/wp-content/uploads/2018/06/ShotCut.png +[27]:https://linuxhint.com/wp-content/uploads/2018/06/Simple-Screen-Recorder.png +[28]:https://linuxhint.com/wp-content/uploads/2018/06/Telegram.png +[29]:https://linuxhint.com/wp-content/uploads/2018/06/ClamTk.png +[30]:https://linuxhint.com/wp-content/uploads/2018/06/Mailspring.png +[31]:https://linuxhint.com/wp-content/uploads/2018/06/PyCharm.png +[32]:https://linuxhint.com/wp-content/uploads/2018/06/Caffeine.png +[33]:https://linuxhint.com/wp-content/uploads/2018/06/Etcher.png +[34]:https://etcher.io/ +[35]:https://linuxhint.com/wp-content/uploads/2018/06/Neofetch.png +[36]:https://linuxhint.com/wp-content/uploads/2018/06/Liferea.png +[37]:https://linuxhint.com/wp-content/uploads/2018/06/Shutter.png +[38]:https://linuxhint.com/wp-content/uploads/2018/06/Weather.png +[39]:https://linuxhint.com/wp-content/uploads/2018/06/Ramme.png +[40]:https://github.com/terkelg/ramme/releases +[41]:https://linuxhint.com/wp-content/uploads/2018/06/Thunderbird.png +[42]:https://linuxhint.com/wp-content/uploads/2018/06/Pidgin.png +[43]:https://linuxhint.com/wp-content/uploads/2018/06/Krita.png +[44]:https://linuxhint.com/wp-content/uploads/2018/06/Dropbox.png +[45]:https://linuxhint.com/wp-content/uploads/2018/06/kodi.png +[46]:https://linuxhint.com/wp-content/uploads/2018/06/Spotify.png +[47]:https://linuxhint.com/wp-content/uploads/2018/06/Brackets.png +[48]:https://linuxhint.com/wp-content/uploads/2018/06/Bitwarden.png +[49]:https://linuxhint.com/wp-content/uploads/2018/06/Terminator.png +[50]:https://linuxhint.com/wp-content/uploads/2018/06/Yak-Yak.png +[51]:https://linuxhint.com/wp-content/uploads/2018/06/Thonny.png +[52]:https://linuxhint.com/wp-content/uploads/2018/06/Font-Manager.png +[53]:https://linuxhint.com/wp-content/uploads/2018/06/Atril.png +[54]:https://linuxhint.com/wp-content/uploads/2018/06/Notepadqq.png +[55]:https://linuxhint.com/wp-content/uploads/2018/06/Amarok.png +[56]:https://linuxhint.com/wp-content/uploads/2018/06/Cheese.png +[57]:https://linuxhint.com/wp-content/uploads/2018/06/MyPaint.png +[58]:https://linuxhint.com/wp-content/uploads/2018/06/PlayOnLinux.png +[59]:https://linuxhint.com/wp-content/uploads/2018/06/Akregator.png +[60]:https://linuxhint.com/wp-content/uploads/2018/06/Brave.png +[61]:https://linuxhint.com/wp-content/uploads/2018/06/Bitcoin-Core.png +[62]:https://linuxhint.com/wp-content/uploads/2018/06/Speedy-Duplicate-Finder.png +[63]:https://linuxhint.com/wp-content/uploads/2018/06/Zulip.png +[64]:https://linuxhint.com/wp-content/uploads/2018/06/Okular.png +[65]:https://linuxhint.com/wp-content/uploads/2018/06/Focus-Writer.png +[66]:https://linuxhint.com/wp-content/uploads/2018/06/Guake.png +[67]:https://linuxhint.com/wp-content/uploads/2018/06/KDE-Connect.png +[68]:https://linuxhint.com/wp-content/uploads/2018/06/CopyQ.png +[69]:https://linuxhint.com/wp-content/uploads/2018/06/Tilix.png +[70]:https://linuxhint.com/wp-content/uploads/2018/06/Anbox.png +[71]:https://linuxhint.com/wp-content/uploads/2018/06/OpenShot.png +[72]:https://linuxhint.com/wp-content/uploads/2018/06/Plank.png +[73]:https://linuxhint.com/wp-content/uploads/2018/06/FileZilla.png +[74]:https://linuxhint.com/wp-content/uploads/2018/06/Stacer.png +[75]:https://linuxhint.com/wp-content/uploads/2018/06/4K-Video-Downloader.png +[76]:https://www.4kdownload.com/download +[77]:https://linuxhint.com/wp-content/uploads/2018/06/Qalculate.png +[78]:https://linuxhint.com/wp-content/uploads/2018/06/Hiri.png +[79]:https://linuxhint.com/wp-content/uploads/2018/06/Sublime-text.png +[80]:https://linuxhint.com/wp-content/uploads/2018/06/TeXstudio.png +[81]:https://www.texstudio.org/ +[82]:https://linuxhint.com/wp-content/uploads/2018/06/QtQR.png +[83]:https://linuxhint.com/wp-content/uploads/2018/06/Kontact.png +[84]:https://linuxhint.com/wp-content/uploads/2018/06/Nitro-Share.png +[85]:https://linuxhint.com/wp-content/uploads/2018/06/Konversation.png +[86]:https://linuxhint.com/wp-content/uploads/2018/06/Discord.png +[87]:https://linuxhint.com/wp-content/uploads/2018/06/QuiteRSS.png +[88]:https://linuxhint.com/wp-content/uploads/2018/06/MPU-Media-Player.png +[89]:https://linuxhint.com/wp-content/uploads/2018/06/Plume-Creator.png +[90]:https://linuxhint.com/wp-content/uploads/2018/06/Chromium.png +[91]:https://linuxhint.com/wp-content/uploads/2018/06/Simple-Weather-Indicator.png +[92]:https://linuxhint.com/wp-content/uploads/2018/06/SpeedCrunch.png +[93]:https://linuxhint.com/wp-content/uploads/2018/06/Scribus.png +[94]:https://linuxhint.com/wp-content/uploads/2018/06/Cura.png +[95]:https://linuxhint.com/wp-content/uploads/2018/06/Nomacs.png +[96]:https://linuxhint.com/wp-content/uploads/2018/06/Bit-Ticker-1.png +[97]:https://linuxhint.com/wp-content/uploads/2018/06/Organize-My-Files.png +[98]:https://linuxhint.com/wp-content/uploads/2018/06/GNU-Cash.png +[99]:https://linuxhint.com/wp-content/uploads/2018/06/Calibre.png +[100]:https://linuxhint.com/wp-content/uploads/2018/06/MATE-Dictionary.png +[101]:https://linuxhint.com/wp-content/uploads/2018/06/Converseen.png +[102]:https://linuxhint.com/wp-content/uploads/2018/06/Tiled-Map-Editor.png +[103]:https://linuxhint.com/wp-content/uploads/2018/06/Qmmp.png +[104]:https://linuxhint.com/wp-content/uploads/2018/06/Arora.png +[105]:https://linuxhint.com/wp-content/uploads/2018/06/XnSketch.png +[106]:https://linuxhint.com/wp-content/uploads/2018/06/Geany.png +[107]:https://linuxhint.com/wp-content/uploads/2018/06/Mumble.png +[108]:https://linuxhint.com/wp-content/uploads/2018/06/Deluge.png +[109]:https://twitter.com/linuxhint +[110]:https://twitter.com/SwapTirthakar +[111]:https://linux.cn/lctt/ + + + + + + + + + + + + + + + + + diff --git a/published/201907/20180902 Learning BASIC Like It-s 1983.md b/published/201907/20180902 Learning BASIC Like It-s 1983.md new file mode 100644 index 0000000000..db8caa1f9b --- /dev/null +++ b/published/201907/20180902 Learning BASIC Like It-s 1983.md @@ -0,0 +1,179 @@ +穿越到 1983 年学习 BASIC +====== + +![](https://img.linux.net.cn/data/attachment/album/201907/12/125743p495dqnqdtctqzgp.jpg) + +1983 年时我还没出生,这让我略有一些遗憾。但我特别遗憾的是,是我没有经历过 8 位计算机时代的到来,因为我认为那些初次接触到还相对简单和受限的计算机的人们,拥有超过如今的我们的巨大优势。 + +今天,(几乎)每个人知道如何使用计算机,但是即使是在计算机行业当中,也很少有人能明白任何一台计算机内部的所有内容。现在软件分为[如此多的层次][1],做的是如此不同的事情,没有哪个人能知道哪些是必不可少的。而在 1983 年,家用电脑足够傻大粗,努力一些的人就能了解到一台特定的计算机是如何工作的。那样的一个人可能不会像今天的我觉得操作系统那么神秘,因为如今的操作系统已经在硬件上叠加了太多的抽象层。我希望这些抽象层逐一引入以易于理解;而今天,新的程序员们不得不自上而下、按时间回溯地尝试理解它们。 + +很多著名的程序员,尤其在计算机游戏行业,孩童时期就在苹果 II 和 Commodore 64 这样的 8 位计算机上开始编写游戏,John Romero、Richard Garriott 和 Chris Roberts 都是这样的例子。这好理解。在 8 位计算机时代,很多游戏只能在计算机杂志和[书籍][2]中以印刷的 BASIC 程序清单方式得到。如果你想玩其中一款游戏,就必须手工键入整个程序。不可避免的,你可能遇到一些问题,所以你就得调试你的程序。等到你让它可以工作起来了,你就已经对程序是如何运行的有了足够的了解,你就可以开始自己修改它了。如果你是一个狂热的游戏玩家,你几乎必然会成为一名优秀的程序员。 + +在我的童年时期我也玩电脑游戏。但是我玩的游戏是在 CD-ROM 上的。我有时发现我自己必须得搜索一下如何修复崩溃的安装程序,这可能涉及编辑 Windows 注册表之类的东西。可能是这种小故障的排除让我感觉很棒,所以我才考虑在大学里学习计算机科学。但是在大学中从不教我一些计算机如何工作的或如何控制它们的关键性的东西。 + +当然,现在我可以告诉计算机去干什么。尽管如此,我还是不禁感到,我缺少一些根本的见解 —— 只有那些伴随着更简单的计算机编程而成长的人才有的深刻见解。我不禁在想,如果在上世纪 80 年代初就接触到计算机会是什么样子?它们与今天使用计算机的体验相比有何不同? + +这篇文章将与通常的 Two-Bit History 的文章有一点不同,因为我将为这些问题尝试设想一个答案。 + +### 1983 + +就在上周,你在电视上看到了 [Commodore 64 的广告][3] ,现在 M\*A\*S\*H 播完了(LCTT 译注: 这是一部上世纪 70 年代初的电视剧),星期一晚上你可以找点新的事情做了。这个 Commodore 64 甚至看起来比鲁迪(LCTT 译注:应该是下文中拥有 Apple II 的人)的家人放在他们家地下室的 Apple II 更好。而且,广告中吹嘘说新的计算机会让你的朋友们“挤破”你家的大门。你知道学校里的几个家伙宁愿在你家闲逛,也不愿去鲁迪家里,只要他们能玩 Zork 就行。 + +所以,你得说服你的父母去买一台。你的母亲说,这事可以考虑,只要你不去游戏厅玩街机就给你买一台家庭电脑。虽然不太情愿,但是你还是同意了。而你的父亲则想,他可以用 MultiPlan (LCTT 译注:电子表格程序)跟踪家庭的资金状况,MultiPlan 是他曾听说过的一个电子表格程序,这就是为什么这台计算机被放在客厅的原因。然而,一年后,你仍然是唯一使用它的人。最终,他们同意你把它搬到了你的卧室的桌子上,正好位于你的警察海报下方。 + +(你的姐姐对这个决定表示抗议,但是,在 1983 年电脑这种东西[并不适合女孩][4]。) + +你的父亲在下班路上从 [ComputerLand][5] 那里把它捎了回来。你俩把盒子放置在电视机的旁边,并打开了它。外包装上说“欢迎来到友好的计算机世界”。而二十分钟以后你就不再信这句话了 —— 你俩仍然在尝试把 Commodore 连接到电视机上,并在想电视机的天线电缆到底是 75 欧姆还是 300 欧姆的同轴电缆。但是,最终你把电视机调到了频道 3,看到了一个颗粒状的、紫色的图像。 + +![Commodore 64 启动屏幕][6] + +计算机显示了一个 `READY`。你的爸爸把计算机推向了你,这意思是你是第一个尝试它的人。你小心翼翼地敲击每个字母,键入了 `HELLO`。然而计算机的回应是令人困惑的。 + +![Commodore 64 语法错误][7] + +你尝试输入了一些稍有不同的单词,然而回应总是一样的。你父亲说,你最好仔细读一下手册的其它部分。这绝非易事,[随 Commodore 64 一起提供的手册][8] 是一本小一些的书。但是这不会困住你,因为手册的介绍预示着奇迹。 + +它声称,Commodore 64 有“微型计算机行业中最先进的图画制作器”,能允许“你设计拥有四种不同颜色的图画,就像你在街机视频游戏里看到的一样”。Commodore 64 也有“内置的音乐和声音效果,可以与很多著名的音乐合成器相媲美”。所有的这些工具都置身于你的手边,手册会引导你完成所有这些: + +> 与所有提供的硬件一样重要的是,这本用户指南将提高你对计算机的理解。它无法在这里告诉你有关计算机的所有信息,但是它会向你推荐各种出版物,以获取有关所提出主题的更多详细信息。Commodore 希望你真正喜欢你的新 COMMODORE 64。要想真正得到乐趣,请记住:编程不是一种一天就能学会的东西。通读这个用户指南你要有耐心。 + +那一夜,你在床上通读了整整前三个章节:“安装”、“入门”和“BASIC 编程入门”,在你最终睡着时,手册还打开着放在了胸前。 + +### Commodore BASIC + +现在是星期六早上,你渴望尝试你所学到的新东西。手册里教给你的第一件事是如何更改在显示器上的颜色。你按照操作说明,按下 `CTRL-9` 来进入反色输入模式,然后按住空格键来创建了一个长长的空行。你可以使用 `CTRL-1` 到 `CTRL-8` 在不同的颜色之间交换,这让你的电视机屏幕焕发出了新的力量。 + +![Commodore 64 颜色带][9] + +尽管这很酷,但你觉得这不能算是编程。要对计算机编程,你昨晚已经学会了如何做,你必须以一种称为 BASIC 的语言与计算机交谈。对你来说,BASIC 看起来就像星球大战中的东西一样科幻,但是,到 1983 年时,其实 BASIC 已经快有二十岁了。它是由两位达特茅斯教授 John Kemeny 和 Tom Kurtz 发明的,他们想让社会科学和人文科学中的本科生也可以使用计算机。它被广泛使用在微型计算机上,在大学的数学课上很受欢迎。在比尔盖茨和保罗艾伦为 Altair 编写了微软 BASIC 解释器后,它就成为了微型计算机上的标准。但是这本手册对此没有任何解释,那么多年你都没学过它。 + +手册中建议你尝试的第一个 BASIC 命令是 `PRINT` 命令。你输入了 `PRINT "COMMODORE 64"`,很慢,因为你需要花费一点时间才能在按键 `2` 上面找到引号符号。你单击 `RETURN`,这一次,计算机没有抱怨,完全是按照你告诉它做的,在下一行中显示了 “COMMODORE 64” 。 + +现在你尝试对各种不同的东西使用 `PRINT` 命令:两个数字加在一起,两个数字乘在一起,甚至几个十进制数字。你不再输入 `PRINT` ,而是使用 `?` 代替,因为手册中告诉你 `?` 是 `PRINT` 的一个缩写,通常专业程序员都这么使用。你感觉自己已经像是一个专家了,不过你想起你还没有进行到第三章“BASIC 编程入门”。 + +你很快就开始了。该章节提示你编写你的第一个真正的 BASIC 程序。你输入 `NEW` 并单击 `RETURN`,它给了你一个干净的黑板slate。然后你在其中输入你的程序: + +``` +10 ?"COMMODORE 64" +20 GOTO 10 +``` + +手册里解释说 10 和 20 是行号。它们为计算机排序了语句。它们也允许程序员在某些命令中引用程序的其它行,正像你在这里使用的 `GOTO` 命令一样,它将程序指回到行 10。“这是一个很好的编程习惯”,手册认为,“以 10 的增量来编号行,可以防止你以后需要插入一些语句”。 + +你输入 `RUN`,并凝视充满了 “COMMODORE 64” 的屏幕,它一遍又一遍的重复。 + +![Commodore 64 显示反复打印 "Commodore 64" 的结果][10] + +你不确定这不会引爆你的计算机,过了一秒钟你才想起来应该单击 `RUN/STOP` 按键来打断循环。 + +手册接下来的一些部分向你介绍了变量,它告诉你变量像“在计算机中许多的盒子,它们每个可以容纳一个数字或一个文本字符串”。以一个 `%` 符号结尾的变量是一个整数,与此同时,以一个 `$` 符号结尾的变量是一个字符串。其余的所有变量是一些称为“浮点”变量的东西。手册警告你要小心变量名称,因为计算机仅会识别变量名称的前两个字母,尽管它不限制你想创建的名称有多长。(这并没有特别让你困扰,但是要是在 30 年后来看,这可能会让人们感到太疯狂了) + +你接着学习 `IF... THEN...` 和 `FOR... NEXT...` 结构体。有了这些新的工具,你感觉有能力来解决接下来手册丢给你的重大挑战。“如果你是个有野心的人”,没错,“输入下面的程序,并查看会发生什么。”该程序比你目前为止看到的程序更长、更复杂,但是,你很想知道它做了什么: + +``` +10 REM BOUNCING BALL +20 PRINT "{CLR/HOME}" +25 FOR X = 1 TO 10 : PRINT "{CRSR/DOWN}" : NEXT +30 FOR BL = 1 TO 40 +40 PRINT " ●{CRSR LEFT}";:REM (● is a Shift-Q) +50 FOR TM = 1 TO 5 +60 NEXT TM +70 NEXT BL +75 REM MOVE BALL RIGHT TO LEFT +80 FOR BL = 40 TO 1 STEP -1 +90 PRINT " {CRSR LEFT}{CRSR LEFT}●{CRSR LEFT}"; +100 FOR TM = 1 TO 5 +110 NEXT TM +120 NEXT BL +130 GOTO 20 +``` + +上面的程序充分利用了 Commodore 64 最酷的功能之一。当把不可打印的命令字符作为字符串的一部分传递到 `PRINT` 命令时,它们会执行其操作,而不是被打印到屏幕上。这允许你重新摆放你程序中打印的字符串。(LCTT 译注:上述程序中如 `{CRSR LEFT}` 之类的控制字符执行类似 “在行中向左移动一个位置” 的操作,因此上述程序中利用这些字符操作了一个圆点字符四处移动,如下图。) + +输入上面的程序你花费了很长时间。你犯一些错误,并不得不重新输入一些行。但是,你最终能够按下 `RUN`,并看到了一幅杰作: + +![Commodore 64 反弹球][11] + +你觉得这恐怕是你见过的最酷的事了。不过你几乎转头就忘记了它,因为马上你就学到了 BASIC 的内置函数,像 `RND`(它返回一个随机数字)和 `CHR$`(它返回与一个给定数字代码匹配的字符),这个手册向你展示一个程序,这个程序有名到什么程度呢?直到许多年后,它仍然被当成了一个[短文选集][12]的标题: + +``` +10 PRINT "{CLR/HOME}" +20 PRINT CHR$(205.5 + RND(1)); +40 GOTO 20 +``` + +当运行时,上面的程序会生成一个随机的迷宫: + +![Commodore 64 迷宫程序][13] + +这绝对是你曾经见过最酷的事。 + +### PEEK 和 POKE + +现在你已经看过了 Commodore 64 手册的前四章节,包含那篇 “高级的 BASIC” 的章节,所以你感到十分自豪。在这个星期六早上,你学习到了很多东西。但是这个下午(在赶快吃了点午饭后),你将继续学习一些使这个放在你的客厅中的奇妙机器变得不再神秘的东西。 + +手册中的下一个章节标题是“高级颜色和图像命令”。它从回顾你今天早上首先键入的彩色条开始,并向你展示了如何在一个程序中做同样的事。然后它教给了你如何更改屏幕的背景颜色。 + +为此,你需要使用 BASIC 的 `PEEK` 和 `POKE` 命令。这些命令分别允许你检查和写入一个存储器地址。Commodore 64 有一个主背景颜色和一个边框背景颜色。每个都通过一个特定的内存地址控制。你可以把你喜欢的任何颜色值写入到这些地址,以使用这些背景颜色和边框颜色。 + +手册中解释: + +> 正像变量可以被认为机器中你放置信息的“盒子”一样,你也可以认为在计算机中代表特定内存位置的是一些特殊定义的“盒子”。 +> +> Commodore 64 会查看这些内存位置来了解屏幕的背景和边框应该是什么样的颜色,什么样的字符应该被显示在屏幕上,以及显示在哪里,等等其它任务。 + +你编写了一个程序来遍历所有可用的背景和边界的颜色的组合: + +``` +10 FOR BA = 0 TO 15 +20 FOR BO = 0 TO 15 +30 POKE 53280, BA +40 POKE 53281, BO +50 FOR X = 1 TO 500 : NEXT X +60 NEXT BO : NEXT BA +``` + +虽然 `POKE` 命令以及它的大操作数一开始时看起来很吓人,现在你看到那个数字的实际值其实不是很要紧。显然,你必须得到正确的数字,但是所有的数字代表的是一个“盒子”,Commodore 只是正好存储在地址 53280 处而已。这个盒子有一个特殊的用途:Commodore 使用它来确定屏幕背景应该是什么颜色。 + +![Commodore 64 更改背景颜色][14] + +你认为这简直棒极了。只需要写入到内存中一个专用的盒子,你可以控制一台计算机的基础属性。你不确定 Commodore 64 的电路系统如何读取你写入在内存中的值并更改屏幕的颜色的,但是,你不知道这些也没事。至少你知道结果是怎么样的。 + +### 特殊容器 + +在那个周六,你没有读完整本手册,因为你现在有点精疲力尽了。但是你最终会全部读完它。在这个过程中,你学到更多的 Commodore 64 专用的盒子。有一些盒子你可以写入来控制在屏幕上显示什么——这也是一个盒子,事实上,是控制每一个位置出现的字符。在第六章节 “精灵图形” 中,你学到可以让你定义可以移动和甚至缩放图像的特殊盒子。在第七章节 “创造声音” 中,你学到能写入以便使你的 Commodore 64 歌唱 “Michael Row the Boat Ashore” 的盒子。Commodore 64,事实证明,它和你可能以后学习到的一个称为 API 的关系甚少。控制 Commodore 64 大多涉及写入到电路系统赋予特殊意义的内存地址。 + +多年来,你花费在这些特殊盒子的时光一直伴随着你。甚至几十年后,当你在一个拥有大量的图形或声音 API 的机器上编程时,你知道,隐藏于其背后的,这些 API 最终是写入到这些盒子之类的东西里面的。你有时会好奇那些只使用过 API 的年轻程序员,他们肯定是觉得 API 为他们做到的这一切。可能他们认为这些 API 调用了一些其它隐藏的 API。但是,那些隐藏的 API 调用了什么?你不由得同情这些年轻的程序员们,因为他们一定会非常迷惑。 + +如果你喜欢这篇文章,也喜欢它每两周发布的一篇新文章的话,那么请在 Twitter 上关注 [@TwoBitHistory][15] 或订阅 [RSS 源][16]来确保你知道新的文章发布出来。 + +-------------------------------------------------------------------------------- + +via:https://twobithistory.org/2018/09/02/learning-basic.html + +作者:[Two-Bit History][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://twobithistory.org +[b]: https://github.com/lujun9972 +[1]: https://www.youtube.com/watch?v=kZRE7HIO3vk +[2]: https://en.wikipedia.org/wiki/BASIC_Computer_Games +[3]: https://www.youtube.com/watch?v=ZekAbt2o6Ms +[4]: https://www.npr.org/sections/money/2014/10/21/357629765/when-women-stopped-coding +[5]: https://www.youtube.com/watch?v=MA_XtT3VAVM +[6]: https://twobithistory.org/images/c64_startup.png +[7]: https://twobithistory.org/images/c64_error.png +[8]: ftp://www.zimmers.net/pub/cbm/c64/manuals/C64_Users_Guide.pdf +[9]: https://twobithistory.org/images/c64_colors.png +[10]: https://twobithistory.org/images/c64_print_loop.png +[11]: https://twobithistory.org/images/c64_ball.gif +[12]: http://10print.org/ +[13]: https://twobithistory.org/images/c64_maze.gif +[14]: https://twobithistory.org/images/c64_background.gif +[15]: https://twitter.com/TwoBitHistory +[16]: https://twobithistory.org/feed.xml +[17]: https://twitter.com/TwoBitHistory/status/1030974776821665793?ref_src=twsrc%5Etfw diff --git a/published/201907/20180924 5 ways to play old-school games on a Raspberry Pi.md b/published/201907/20180924 5 ways to play old-school games on a Raspberry Pi.md new file mode 100644 index 0000000000..f9a55eda13 --- /dev/null +++ b/published/201907/20180924 5 ways to play old-school games on a Raspberry Pi.md @@ -0,0 +1,173 @@ +在树莓派上玩怀旧游戏的 5 种方法 +====== + +> 使用这些用于树莓派的开源平台来重温游戏的黄金时代。 + +![](https://d3avoj45mekucs.cloudfront.net/rojakdaily/media/jessica-chua/lifestyle/retro%20gaming%20comeback/retro-video-game-event.jpg) + +他们使它们不像过去那样子了,对吧?我是说,电子游戏。 + +当然,现在的设备更强大了。赛达尔公主Princess Zelda在过去每个边只有 16 个像素,而现在的图像处理能力足够处理她头上的每根头发。今天的处理器打败 1988 年的处理器简直不费吹灰之力。 + +但是你知道缺少什么吗?乐趣。 + +你有数之不尽的游戏,按下一个按钮就可以完成教程任务。可能有故事情节,当然杀死坏蛋也可以不需要故事情节,你需要的只是跳跃和射击。因此,毫不奇怪,树莓派最持久的流行用途之一就是重温上世纪八九十年代的 8 位和 16 位游戏的黄金时代。但从哪里开始呢? + +在树莓派上有几种方法可以玩怀旧游戏。每一种都有自己的优点和缺点,我将在这里讨论这些。 + +### RetroPie + +[RetroPie][1] 可能是树莓派上最受欢迎的复古游戏平台。它是一个可靠的万能选手,是模拟经典桌面和控制台游戏系统的绝佳选择。 + +![](https://retropie.org.uk/wp-content/uploads/2016/04/Amiga_Gameplay_2.png) + +#### 介绍 + +RetroPie 构建在 [Raspbian][2] 上运行。如果你愿意,它也可以安装在现有的 Raspbian 镜像上。它使用 [EmulationStation][3] 作为开源仿真器库(包括 [Libretro][4] 仿真器)的图形前端。 + +不过,你要玩游戏其实并不需要理解上面的任何一个词。 + +#### 它有什么好处 + +入门很容易。你需要做的就是将镜像刻录到 SD 卡,配置你的控制器、复制游戏,然后开始杀死坏蛋。 + +它的庞大用户群意味着有大量的支持和信息,活跃的在线社区也可以求助问题。 + +除了随 RetroPie 镜像一起安装的仿真器之外,还有一个可以从包管理器安装的庞大的仿真器库,并且它一直在增长。RetroPie 还提供了用户友好的菜单系统来管理这些,可以节省你的时间。 + +从 RetroPie 菜单中可以轻松添加 Kodi 和配备了 Chromium 浏览器的 Raspbian 桌面。这意味着你的这套复古游戏装备也适于作为家庭影院、[YouTube][5]、[SoundCloud][6] 以及所有其它“休息室电脑”产品。 + +RetroPie 还有许多其它自定义选项:你可以更改菜单中的图形,为不同的模拟器设置不同的控制手柄配置,使你的树莓派文件系统的所有内容对你的本地 Windows 网络可见等等。 + +RetroPie 建立在 Raspbian 上,这意味着你可以探索这个树莓派最受欢迎的操作系统。你所发现的大多数树莓派项目和教程都是为 Raspbian 编写的,因此可以轻松地自定义和安装新内容。我已经使用我的 RetroPie 装备作为无线桥接器,在上面安装了 MIDI 合成器,自学了一些 Python,更重要的是,所有这些都没有影响它作为游戏机的用途。 + +#### 它有什么不太好的 + +RetroPie 的安装简单和易用性在某种程度上是一把双刃剑。你可以在 RetroPie 上玩了很长时间,而甚至没有学习过哪怕像 `sudo apt-get` 这样简单的东西,但这也意味着你错过了很多树莓派的体验。 + +但不一定必须如此;当你需要时,命令行仍然存在于底层,但是也许用户与 Bash shell 有点隔离,而使它最终并没有看上去那么可怕、另外,RetroPie 的主菜单只能通过控制手柄操作,当你没有接入手柄时,这可能很烦人,因为你一直将该系统用于游戏之外的事情。 + +#### 它适用于谁? + +任何想直接玩一些游戏的人,任何想拥有最大、最好的模拟器库的人,以及任何想在不玩游戏的时候开始探索 Linux 的人。 + +### Recalbox + +[Recalbox][7] 是一个较新的树莓派开源模拟器套件。它还支持其它基于 ARM 的小型计算机。 + +![](https://www.recalbox.com/images/features/4playermodo_hu5438825b9b6d1014226d20d231e650c2_230970_500x0_resize_q75_box.jpeg) + +#### 介绍 + +与 Retropie 一样, Recalbox 基于 EmulationStation 和 Libretro。它的不同之处在于它不是基于 Raspbian 构建的,而是基于它自己的 Linux 发行版:RecalboxOS。 + +#### 它有什么好处 + +Recalbox 的设置比 RetroPie 更容易。你甚至不需要做 SD 卡镜像;只需复制一些文件即可。它还为一些游戏控制器提供开箱即用的支持,可以让你更快地开始游戏。它预装了 Kodi。这是一个现成的游戏和媒体平台。 + +#### 它有什么不太好的 + +Recalbox 比 RetroPie 拥有更少的仿真器、更少的自定义选项和更小的用户社区。 + +你的 Recalbox 装备可能一直用于模拟器和 Kodi,安装成什么样就是什么样。如果你想深入了解 Linux,你可能需要为 Raspbian 提供一个新的 SD 卡。 + +#### 它适用于谁? + +如果你想要绝对简单的复古游戏体验,并且不想玩一些比较少见的游戏平台模拟器,或者你害怕一些技术性工作(也没有兴趣去做),那么 Recalbox 非常适合你。 + +对于大多数读者来说,Recalbox 可能最适合推荐给你那些不太懂技术的朋友或亲戚。它超级简单的设置和几乎没什么选项甚至可以让你免去帮助他们解决问题。 + +### 做个你自己的 + +好,你可能已经注意到 Retropie 和 Recalbox 都是由许多相同的开源组件构建的。那么为什么不自己把它们组合在一起呢? + +#### 介绍 + +无论你想要的是什么,开源软件的本质意味着你可以使用现有的模拟器套件作为起点,或者随意使用它们。 + +#### 它有什么好处 + +如果你想有自己的自定义界面,我想除了亲自动手别无它法。这也是安装在 RetroPie 中没有的仿真器的方法,例如 [BeebEm][8]) 或 [ArcEm][9]。 + +#### 它有什么不太好的 + +嗯,工作量有点大。 + +#### 它适用于谁? + +喜欢鼓捣的人,有动手能力的人,开发者,经验丰富的业余爱好者等。 + +### 原生 RISC OS 游戏体验 + +现在有一匹黑马:[RISC OS][10],它是 ARM 设备的原始操作系统。 + +#### 介绍 + +在 ARM 成为世界上最受欢迎的 CPU 架构之前,它最初是作为 Acorn Archimedes 的处理器而开发的。现在看起来这像是一种被遗忘的野兽,但是那几年,它作为世界上最强大的台式计算机独领风骚了好几年,并且吸引了大量的游戏开发项目。 + +树莓派中的 ARM 处理器是 Archimedes 的曾孙辈的 CPU,所以我们仍然可以在其上安装 RISC OS,只要做一点工作,就可以让这些游戏运行起来。这与我们到上面所介绍的仿真器方式不同,我们是在玩为该操作系统和 CPU 架构开发的游戏。 + +#### 它有什么好处 + +这是 RISC OS 的完美展现,这绝对是操作系统的瑰宝,非常值得一试。 + +事实上,你使用的是和以前几乎相同的操作系统来加载和玩你的游戏,这使得你的复古游戏装备像是一个时间机器一样,这无疑为该项目增添了一些魅力和复古价值。 + +有一些精彩的游戏只在 Archimedes 上发布过。Archimedes 的巨大硬件优势也意味着它通常拥有许多多平台游戏大作的最佳图形和最流畅的游戏体验。这类游戏的版权持有者非常慷慨,可以合法地免费下载它们。 + +#### 它有什么不太好的 + +安装了 RISC OS 之后,它仍然需要一些努力才能让游戏运行起来。这是 [入门指南][11]。 + +对于休息室来说,这绝对不是一个很好的全能选手。没有什么比 [Kodi][12] 更好的了。它有一个网络浏览器 [NetSurf][13],但它在支持现代 Web 方面还需要一些努力。你不会像使用模拟器套件那样得到大量可以玩的游戏。RISC OS Open 对于爱好者来说可以免费下载和使用,而且很多源代码已经开源,尽管由于这个名字,它不是一个 100% 的开源操作系统。 + +#### 它适用于谁? + +这是专为追求新奇的人,绝对怀旧的人,想要探索一个来自上世纪 80 年代的有趣的操作系统的人,怀旧过去的 Acorn 机器的人,以及想要一个完全不同的怀旧游戏项目的人而设计的。 + +### 终端游戏 + +你是否真的需要安装模拟器或者一个异域风情的操作系统才能重温辉煌的日子?为什么不从命令行安装一些原生 Linux 游戏呢? + +#### 介绍 + +有一系列原生的 Linux 游戏经过测试可以在 [树莓派][14] 上运行。 + +#### 它有什么好处 + +你可以使用命令行从程序包安装其中的大部分,然后开始玩。很容易。如果你已经有了一个跑起来的 Raspbian,那么它可能是你运行游戏的最快途径。 + +#### 它有什么不太好的 + +严格来说,这并不是真正的复古游戏。Linux 诞生于 1991 年,过了一段时间才成为了一个游戏平台。这些不是经典的 8 位和 16 位时代的游戏体验;后来有一些移植的游戏或受复古影响的游戏。 + +#### 它适用于谁? + +如果你只是想找点乐子,这没问题。但如果你想重温过去,那就不完全是这样了。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/retro-gaming-raspberry-pi + +作者:[James Mawson][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[canhetingsky](https://github.com/canhetingsky) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dxmjames +[1]: https://retropie.org.uk/ +[2]: https://www.raspbian.org/ +[3]: https://emulationstation.org/ +[4]: https://www.libretro.com/ +[5]: https://www.youtube.com/ +[6]: https://soundcloud.com/ +[7]: https://www.recalbox.com/ +[8]: http://www.mkw.me.uk/beebem/ +[9]: http://arcem.sourceforge.net/ +[10]: https://opensource.com/article/18/7/gentle-intro-risc-os +[11]: https://blog.dxmtechsupport.com.au/playing-badass-acorn-archimedes-games-on-a-raspberry-pi/ +[12]: https://kodi.tv/ +[13]: https://www.netsurf-browser.org/ +[14]: https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 diff --git a/published/201907/20190211 Introducing kids to computational thinking with Python.md b/published/201907/20190211 Introducing kids to computational thinking with Python.md new file mode 100644 index 0000000000..17c062ad8e --- /dev/null +++ b/published/201907/20190211 Introducing kids to computational thinking with Python.md @@ -0,0 +1,72 @@ +[#]: collector: (lujun9972) +[#]: translator: (WangYueScream) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11116-1.html) +[#]: subject: (Introducing kids to computational thinking with Python) +[#]: via: (https://opensource.com/article/19/2/break-down-stereotypes-python) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + + +利用 Python 引导孩子的计算机思维 +======================== + +> 编程可以给低收入家庭的学生提供足够的技能、信心和知识,进而让他们摆脱因为家庭收入低带来的经济和社会地位上的劣势。 + +![](https://img.linux.net.cn/data/attachment/album/201907/17/231228k3t9skntnlst59h9.jpg) + +尽管暑假期间底特律公共图书馆的[帕克曼分部][1]挤满了无聊的孩子并且占用了所有的电脑,图书馆工作人员并不觉得这会是个问题,反而更多是一个机会。他们成立一个名为 [Parkman Coders][2] 的编程社团,社团以 [Qumisha Goss][3] 为首,她是图书管理员,也负责利用 Python 的魔力引导弱势儿童的计算机思维。 + +四年前 [Qumisha Goss][3] 刚发起 Parkman Coders 计划的时候, “Q”(代表她)并不是太懂编程。之后她通过努力成为图书馆里教学和技术方面的专家和树莓派认证讲师。 + +社团最开始采用 [Scratch][4] 教学,但很快学生就对这种图形化的块编程感到乏味,他们觉得这就是个“婴儿玩具”。Q 坦言,“我们意识到是时候需要在课程内容这方面做些改变了,如果是为了维持课程内容对初学者的友好性继续选择 Scratch 教学,这无疑会影响孩子们后期继续保持对编程的关注。”因此,她开始教授孩子们 Python。 + +Q 是在 [Code.org][5] 平台玩地牢骷髅怪物这个关卡的时候第一次接触到 Python。她最开始是通过 《[Python Programming: An Introduction to Computer Science][6]》 和 《[Python for Kids][7]》 这两本书学习的 Python。她也推荐 《[Automate the Boring Stuff with Python][8]》 和 《[Lauren Ipsum: A Story about Computer Science and Other Improbable Things][9]》 这两本书。 + +### 建立一个基于树莓派的创客空间 + +Q 决定使用[树莓派][10]电脑来避免学生可能会因为自己的不当操作对图书馆的电脑造成损害,而且这些电脑因为便携性等问题也不方便用来构建组成一个创客空间。[树莓派][10]的购买价格加上它的灵活性和便携性包括生态圈里面的一些适合教学的自由免费软件,让大家更能感受到她的决策的可行性和可靠性。 + +虽然图书馆发起 [Parkman Coders][2] 社区计划的本意是通过努力创造一个吸引孩子们的学习空间,进而维持图书馆的平和,但社区发展的很快,很受大家欢迎,以至于这座建立于 1921 的大楼的空间,电脑和插座都不够用了。他们最开始是 20 个孩子共享 10 台[树莓派][10]来进行授课,但后来图书馆陆续收到了来自个人和公司比如 Microsoft、4H,和 Detroit Public Library Foundation 的资金援助从而能够购买更多设备以支撑社区的进一步壮大发展。 + +目前,每节课程大概有 40 个孩子参加,而且图书馆也有了足够的[树莓派][10]让参与者人手一台设备甚至还可以送出去一些。鉴于不少 [Parkman Coders][2] 的参与者来自于低收入家庭,图书馆也能提供别人捐赠的 Chromebooks 给他们使用。 + +Q 说,“当孩子们的表现可以证明他们能够很好的使用[树莓派][10]或者 [Microbit][11] 而且定期来参加课程,我们也会提供设备允许他们可以带回家练习。但即便这样也还是会遇到很多问题,比如他们在家无法访问网络或者没有显示器、键盘、鼠标等外设。” + +### 利用 Python 学习生存技能,打破束缚 + +Q 说,“我认为教授孩子们计算机科学的主要目的是让他们学会批判性思考和解决问题的能力。我希望随着孩子们长大成人,不管他们选择在哪个领域继续发展他们的未来,这些经验教训都会一直伴随他们成长。此外,我也希望这个课程能够激发孩子们对创造的自豪感。能够清楚的意识到‘这是我做的’是一种很强烈、很有用的感受。而且一旦孩子们越早能够有这种成功的体验,我相信未来的路上他们都会满怀热情迎接新的挑战而不是逃避。” + +她继续分享道,“在学习编程的过程中,你不得不对单词的拼写和大小写高度警惕。受限于孩子年龄,有时候阅读认知会是个大问题。为了确保课程受众的包容性,我们会在授课过程中大声拼读,同样我们也会极力鼓励孩子们大声说出他们不知道的或者不能正确拼写的单词,以便我们纠正。” + +Q 也会尝试尽力去给需要帮助的孩子们更多的关注。她解释道,“如果我确认有孩子遇到困难不能跟上我们的授课进度,我们会尝试在课下时间安排老师辅导帮助他,但还是会允许他们继续参加编程。我们想帮助到他们而不是让他们因为挫败而沮丧的不再参与进来。” + +最重要的是,[Parkman Coders][2] 计划所追求的是能够帮助每个孩子认识到每个人都会有独特的技能和能力。参与进来的大部分孩子都是非裔美国人,一半是女孩。Q 直言,“我们所生活在的这个世界,我们成长的过程中,伴随着各种各种的社会偏见,这些都常常会限制我们对自己所能达到的成就的准确认知。”她坚信孩子们需要一个没有偏见的空间,“他们可以尝试很多新事物,不会因为担心犯错责骂而束手束脚,可以放心大胆的去求知探索。” + +Q 和 [Parkman Coders][2] 计划所营造的环境氛围能够帮助到参与者摆脱低家庭收入带来的劣势。如果说社区能够发展壮大到今天的规模真有什么独特秘诀的话,那大概就是,Q 解释道,“确保你有一个令人舒适的空间,充满了理解与宽容,这样大家才会被吸引过来。让来的人不忘初心,做好传道受业解惑的准备;当大家参与进来并感觉到充实愉悦,自然而然会想要留下来。” + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/break-down-stereotypes-python + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[WangYueScream](https://github.com/WangYueScream) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://detroitpubliclibrary.org/locations/parkman +[2]: https://www.dplfound.org/single-post/2016/05/15/Parkman-Branch-Coders +[3]: https://www.linkedin.com/in/qumisha-goss-b3bb5470 +[4]: https://scratch.mit.edu/ +[5]: http://Code.org +[6]: https://www.amazon.com/Python-Programming-Introduction-Computer-Science/dp/1887902996 +[7]: https://nostarch.com/pythonforkids +[8]: https://automatetheboringstuff.com/ +[9]: https://nostarch.com/laurenipsum +[10]: https://www.raspberrypi.org/ +[11]: https://microbit.org/guide/ diff --git a/published/201907/20190301 Emacs for (even more of) the win.md b/published/201907/20190301 Emacs for (even more of) the win.md new file mode 100644 index 0000000000..7da7ab6a51 --- /dev/null +++ b/published/201907/20190301 Emacs for (even more of) the win.md @@ -0,0 +1,83 @@ +[#]: collector: (lujun9972) +[#]: translator: (oneforalone) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11046-1.html) +[#]: subject: (Emacs for (even more of) the win) +[#]: via: (https://so.nwalsh.com/2019/03/01/emacs) +[#]: author: (Norman Walsh https://so.nwalsh.com) + +Emacs 的(更多)胜利 +====== + +![](https://img.linux.net.cn/data/attachment/album/201907/02/002550x2ol48004hx6e0od.jpg) + +我天天用 Emacs,但我却从意识到。但是每当我用 Emacs 时,它都给我带来了很多乐趣。 + +> 如果你是个职业作家……Emacs 与其它的编辑器的相比就如皓日与群星一样。不仅更大、更亮,它轻而易举就让其他所有的东西都消失了。 + +我用 [Emacs][1] 已有二十多年了。我用它来写几乎所有的东西(我用 [IntelliJ][2] 编辑 Scala 和 Java )。看邮件的话我是能在 Emacs 里看就在里面看。 + +尽管我用 Emacs 已有数十年,我在新年前后才意识到,在过去十几年里,我对 Emacs 的使用几乎没有什么变化。当然,新的编辑模式出现了,我就会选一两个插件,几年前我确实是用了 [Helm][3],但大多数时候,它只是完成了我需要的所有繁重工作,日复一日,没有抱怨,也没有妨碍我。一方面,这证明了它有多好。另一方面,这是一个邀请,让我深入挖掘,看看我错过了什么。 + +于此同时,我也决定从以下几方面改进我的工作方式: + +* **更好的议程管理** 我在工作中负责几个项目,这些项目有定期和临时的会议;有些我是我主持的,有些我只要参加就可以。 + + 我意识到我对参加会议变得有些敷衍。往会议室里一坐很简单,但实际上我是在阅读电子邮件或处理其他事情。(我强烈反对在会议中“禁止携带笔记本电脑”的这条规定,但这是另一个话题。) + + 敷衍地去参加会议有几个问题。首先,这是对主持会议的人和其他参会者的不尊重。实际上这是不应该这么做的充分理由,但我还有意识到另一个问题:它掩盖了会议的成本。 + + 如果你在开会,但同时回复了一封电子邮件,也许修复了一个 bug,那么这个会议就没什么成本(或没那么多)。如果会议成本低廉,那么会议数量将会更多。 + + 我想要更少、更短的会议。我不想掩盖它们的成本,我想让开会变得很有价值,除非绝对必要,否则就干脆不要开。 + + 有时,开会是绝对有必要的。而且我认为一个简短的会有时候能够很快的解决问题。但是,如果我一天要开十个短会的话,那我觉得还是不要假装取得了什么效果吧。 + + 我决定在我参加的所有的会上做笔记。我并不是说一定要做会议记录,但是我肯定会花上几分钟。这会让我把注意力集中在开会上,而忽略其他事。 + +* **更好的时间管理** 无论是工作的或私人的,我有很多要做和想做的事。我一直在问题列表中跟踪其中的一些,一些在保存的电子邮件线索中(Emacs 和 [Gmail][4] 中,用于一些稍微不同的提醒),还有一些在日历、手机上各种各样的“待办事项列表”和小纸片上。可能还有其他地方。 + + 我决定把它们放在一起。不是说我认为放到一个一致的地方就更好,而是我想完成两件事:首先,把它们都集中在一个地方,我能够更好更全面地了解我在哪里投入了更多的精力;其次,我想养成一个记录、跟踪并保存它们的习惯(习惯指“固定或规律的倾向或做法,尤指难以放弃的倾向或做法”)。 + +* **更好的问责制** 如果你在某些科学或工程领域工作,你就会养成记笔记的习惯。唉,我没有。但我决定这么做。 + + 我对法律上鼓励使用装订页面或用永久记号笔涂抹并不感兴趣。我感兴趣的是养成做记录的习惯。我的目标是有一个地方记下想法和设计草图等。如果我突然有了灵感,或者我想到了一个不在测试套件中的边缘情况,我希望我的直觉是把它写在我的日志中,而不是草草写在一张小纸片上,或者自己觉得自己会记住它。 + +这些决心让我很快或多或少指向了 [Org][6] 模式。Org 模式有一个庞大的、活跃的、忠诚的用户社区。我以前也用过它(顺带一提,我都[写过][7]关于它的文章,在几年前),我花了很长的一段时间(将 [MarkLogic 集成][8]到其中。(这在过去的一两个星期里得到了回报!) + +但我从没正经用过 Org 模式。 + +我现在正在用它。我用了几分钟,我把所有要做的事情都记录下来,我还记了日记。我不确定我争论或列表它的所有功能能有多大价值,你可以通过网页快速地搜索找到很多。 + +如果你用 Emacs,那你也应该用 Org 模式。如果没用过 Emacs,我相信你不会是第一个因 Org 模式而使用 Emacs 的人。Org 模式可以做很多。它需要一点时间来学习方法和快捷键,但我认为这是值得的。(如果你的口袋中有一台 [iOS][9] 设备,我推荐你在路上使用 [beorg][10] 来记录。) + +当然,我想出了如何[将 XML 从其中提取出来][11](“working out” 确实是“用 elisp 来编程”的一种有趣的魔法)然后,如何将它转换回我的博客用的标记(当然,在 Emacs 中按下一个按钮就可以做到)。这是用 Org 模式写的第一篇帖子。这也不会是最后一次。 + +附注:生日快乐,[小博客][12]。 + +-------------------------------------------------------------------------------- + +via: https://so.nwalsh.com/2019/03/01/emacs + +作者:[Norman Walsh][a] +选题:[lujun9972][b] +译者:[oneforalone](https://github.com/oneforalone) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://so.nwalsh.com +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Emacs +[2]: https://en.wikipedia.org/wiki/IntelliJ_IDEA +[3]: https://emacs-helm.github.io/helm/ +[4]: https://en.wikipedia.org/wiki/Gmail +[5]: https://en.wikipedia.org/wiki/Lab_notebook +[6]: https://en.wikipedia.org/wiki/Org-mode +[7]: https://www.balisage.net/Proceedings/vol17/html/Walsh01/BalisageVol17-Walsh01.html +[8]: https://github.com/ndw/ob-ml-marklogic/ +[9]: https://en.wikipedia.org/wiki/IOS +[10]: https://beorgapp.com/ +[11]: https://github.com/ndw/org-to-xml +[12]: https://so.nwalsh.com/2017/03/01/helloWorld diff --git a/published/201907/20190302 Create a Custom System Tray Indicator For Your Tasks on Linux.md b/published/201907/20190302 Create a Custom System Tray Indicator For Your Tasks on Linux.md new file mode 100644 index 0000000000..9940c0e049 --- /dev/null +++ b/published/201907/20190302 Create a Custom System Tray Indicator For Your Tasks on Linux.md @@ -0,0 +1,171 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11061-1.html) +[#]: subject: (Create a Custom System Tray Indicator For Your Tasks on Linux) +[#]: via: (https://fosspost.org/tutorials/custom-system-tray-icon-indicator-linux) +[#]: author: (M.Hanny Sabbagh https://fosspost.org/author/mhsabbagh) + +在 Linux 上为你的任务创建一个自定义的系统托盘指示器 +====== + +系统托盘图标如今仍是一个很神奇的功能。只需要右击图标,然后选择想要的动作,你就可以大幅简化你的生活并且减少日常行为中的大量无用的点击。 + +一说到有用的系统托盘图标,我们很容易就想到 Skype、Dropbox 和 VLC: + +![Create a Custom System Tray Indicator For Your Tasks on Linux][1] + +然而系统托盘图标实际上要更有用得多;你可以根据自己的需求创建自己的系统托盘图标。本指导将会教你通过简单的几个步骤来实现这一目的。 + +### 前置条件 + +我们将要用 Python 来实现一个自定义的系统托盘指示器。Python 可能已经默安装在所有主流的 Linux 发行版中了,因此你只需要确定一下它已经被安装好了(此处使用版本为 2.7)。另外,我们还需要安装好 `gir1.2-appindicator3` 包。该库能够让我们很容易就能创建系统图标指示器。 + +在 Ubuntu/Mint/Debian 上安装: + +``` +sudo apt-get install gir1.2-appindicator3 +``` + +在 Fedora 上安装: + +``` +sudo dnf install libappindicator-gtk3 +``` + +对于其他发行版,只需要搜索包含 “appindicator” 的包就行了。 + +在 GNOME Shell 3.26 开始,系统托盘图标被删除了。你需要安装 [这个扩展][2](或者其他扩展)来为桌面启用该功能。否则你无法看到我们创建的指示器。 + +### 基础代码 + +下面是该指示器的基础代码: + +``` +#!/usr/bin/python +import os +from gi.repository import Gtk as gtk, AppIndicator3 as appindicator +def main(): + indicator = appindicator.Indicator.new("customtray", "semi-starred-symbolic", appindicator.IndicatorCategory.APPLICATION_STATUS) + indicator.set_status(appindicator.IndicatorStatus.ACTIVE) + indicator.set_menu(menu()) + gtk.main() +def menu(): + menu = gtk.Menu() + + command_one = gtk.MenuItem('My Notes') + command_one.connect('activate', note) + menu.append(command_one) + exittray = gtk.MenuItem('Exit Tray') + exittray.connect('activate', quit) + menu.append(exittray) + + menu.show_all() + return menu + +def note(_): + os.system("gedit $HOME/Documents/notes.txt") +def quit(_): + gtk.main_quit() +if __name__ == "__main__": + main() +``` + +我们待会会解释一下代码是怎么工作的。但是现在,让我们将该文本保存为 `tray.py`,然后使用 Python 运行之: + +``` +python tray.py +``` + +我们会看到指示器运行起来了,如下图所示: + +![Create a Custom System Tray Indicator For Your Tasks on Linux 13][3] + +现在,让我们解释一下这个魔法的原理: + + * 前三行代码仅仅用来指明 Python 的路径并且导入需要的库。 + * `def main()` :此为指示器的主函数。该函数的代码用来初始化并创建指示器。 + * `indicator = appindicator.Indicator.new("customtray","semi-starred-symbolic",appindicator.IndicatorCategory.APPLICATION_STATUS)` :这里我们指明创建一个名为 `customtray` 的新指示器。这是指示器的唯一名称,这样系统就不会与其他运行中的指示器搞混了。同时我们使用名为 `semi-starred-symbolic` 的图标作为指示器的默认图标。你可以将之改成任何其他值;比如 `firefox` (如果你希望该指示器使用 FireFox 的图标),或任何其他你想用的图标名。最后与 `APPLICATION_STATUS` 相关的部分是指明指示器类别/范围的常规代码。 + * `indicator.set_status(appindicator.IndicatorStatus.ACTIVE)`:这一行激活指示器。 + * `indicator.set_menu(menu())`:这里说的是我们想使用 `menu()` 函数(我们会在后面定义) 来为我们的指示器创建菜单项。这很重要,可以让你右击指示器后看到一个可以实施行为的列表。 + * `gtk.main()`:运行 GTK 主循环。 + * 在 `menu()` 中我们定义了想要指示器提供的行为或项目。`command_one = gtk.MenuItem('My Notes')` 仅仅使用文本 “My notes” 来初始化第一个菜单项,接下来 `command_one.connect('activate',note)` 将菜单的 `activate` 信号与后面定义的 `note()` 函数相连接;换句话说,我们告诉我们的系统:“当该菜单项被点击,运行 `note()` 函数”。最后,`menu.append(command_one)` 将菜单项添加到列表中。 + * `exittray` 相关的行是为了创建一个退出的菜单项,以便让你在想要的时候关闭指示器。 + * `menu.show_all()` 以及 `return menu` 只是返回菜单项给指示器的常规代码。 + * 在 `note(_)` 下面是点击 “My Notes” 菜单项时需要执行的代码。这里只是 `os.system("gedit $HOME/Documents/notes.txt")` 这一句话;`os.system` 函数允许你在 Python 中运行 shell 命令,因此这里我们写了一行命令来使用 `gedit` 打开家目录下 `Documents` 目录中名为 `notes.txt` 的文件。例如,这个可以称为你今后的日常笔记程序了! + +### 添加你所需要的任务 + +你只需要修改代码中的两块地方: + + 1. 在 `menu()` 中为你想要的任务定义新的菜单项。 + 2. 创建一个新的函数让给该菜单项被点击时执行特定的行为。 + +所以,比如说你想要创建一个新菜单项,在点击后,会使用 VLC 播放硬盘中某个特定的视频/音频文件?要做到这一点,只需要在第 17 行处添加下面三行内容: + +``` +command_two = gtk.MenuItem('Play video/audio') +command_two.connect('activate', play) +menu.append(command_two) +``` + +然后在第 30 行添加下面内容: + +``` +def play(_): + os.system("vlc /home//Videos/somevideo.mp4") +``` + +将` `/home//Videos/somevideo.mp4` 替换成你想要播放的视频/音频文件路径。现在保存该文件然后再次运行该指示器: + +``` +python tray.py +``` + +你将会看到: + +![Create a Custom System Tray Indicator For Your Tasks on Linux 15][4] + +而且当你点击新创建的菜单项时,VLC 会开始播放! + +要创建其他项目/任务,只需要重复上面步骤即可。但是要小心,需要用其他命令来替换 `command_two`,比如 `command_three`,这样在变量之间才不会产生冲突。然后定义新函数,就像 `play(_)` 函数那样。 + +可能性是无穷的;比如我用这种方法来从网上获取数据(使用 urllib2 库)并显示出来。我也用它来在后台使用 `mpg123` 命令播放 mp3 文件,而且我还定义了另一个菜单项来 `killall mpg123` 以随时停止播放音频。比如 Steam 上的 CS:GO 退出很费时间(窗口并不会自动关闭),因此,作为一个变通的方法,我只是最小化窗口然后点击某个自建的菜单项,它会执行 `killall -9 csgo_linux64` 命令。 + +你可以使用这个指示器来做任何事情:升级系统包、运行其他脚本——字面上的任何事情。 + +### 自动启动 + +我们希望系统托盘指示器能在系统启动后自动启动,而不用每次都手工运行。要做到这一点,只需要在自启动应用程序中添加下面命令即可(但是你需要将 `tray.py` 的路径替换成你自己的路径): + +``` +nohup python /home//tray.py & +``` + +下次重启系统,指示器会在系统启动后自动开始工作了! + +### 结论 + +你现在知道了如何为你想要的任务创建自己的系统托盘指示器了。根据每天需要运行的任务的性质和数量,此方法可以节省大量时间。有些人偏爱从命令行创建别名,但是这需要你每次都打开终端窗口或者需要有一个可用的下拉式终端仿真器,而这里,这个系统托盘指示器一直在工作,随时可用。 + +你以前用过这个方法来运行你的任务吗?很想听听你的想法。 + + +-------------------------------------------------------------------------------- + +via: https://fosspost.org/tutorials/custom-system-tray-icon-indicator-linux + +作者:[M.Hanny Sabbagh][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fosspost.org/author/mhsabbagh +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/02/Screenshot-at-2019-02-28-0808.png?resize=407%2C345&ssl=1 (Create a Custom System Tray Indicator For Your Tasks on Linux 12) +[2]: https://extensions.gnome.org/extension/1031/topicons/ +[3]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/03/Screenshot-at-2019-03-02-1041.png?resize=434%2C140&ssl=1 (Create a Custom System Tray Indicator For Your Tasks on Linux 14) +[4]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/03/Screenshot-at-2019-03-02-1141.png?resize=440%2C149&ssl=1 (Create a Custom System Tray Indicator For Your Tasks on Linux 16) diff --git a/published/201907/20190306 ClusterShell - A Nifty Tool To Run Commands On Cluster Nodes In Parallel.md b/published/201907/20190306 ClusterShell - A Nifty Tool To Run Commands On Cluster Nodes In Parallel.md new file mode 100644 index 0000000000..ed9c481007 --- /dev/null +++ b/published/201907/20190306 ClusterShell - A Nifty Tool To Run Commands On Cluster Nodes In Parallel.md @@ -0,0 +1,295 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11147-1.html) +[#]: subject: (ClusterShell – A Nifty Tool To Run Commands On Cluster Nodes In Parallel) +[#]: via: (https://www.2daygeek.com/clustershell-clush-run-commands-on-cluster-nodes-remote-system-in-parallel-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +ClusterShell:一个在集群节点上并行运行命令的好工具 +====== + +![](https://img.linux.net.cn/data/attachment/album/201907/26/053202pgcgg1y1rc5l5mgg.jpg) + +我们过去曾写过两篇如何并行地在多个远程服务器上运行命令的文章:[并行 SSH(PSSH)][1] 和[分布式 Shell(DSH)][2]。今天,我们将讨论相同类型的主题,但它允许我们在集群节点上执行相同的操作。你可能会想,我可以编写一个小的 shell 脚本来实现这个目的,而不是安装这些第三方软件包。 + +当然,你是对的,如果要在十几个远程系统中运行一些命令,那么你不需要使用它。但是,你的脚本需要一些时间来完成此任务,因为它是按顺序运行的。想想你要是在一千多台服务器上运行一些命令会是什么样子?在这种情况下,你的脚本用处不大。此外,完成任务需要很长时间。所以,要克服这种问题和情况,我们需要可以在远程计算机上并行运行命令。 + +为此,我们需要在一个并行应用程序中使用它。我希望这个解释可以解决你对并行实用程序的疑虑。 + +### ClusterShell + +[ClusterShell][3] 是一个事件驱动的开源 Python 库,旨在在服务器场或大型 Linux 集群上并行运行本地或远程命令。(`clush` 即 [ClusterShell][3])。 + +它将处理在 HPC 集群上遇到的常见问题,例如在节点组上操作,使用优化过的执行算法运行分布式命令,以及收集结果和合并相同的输出,或检索返回代码。 + +ClusterShell 可以利用已安装在系统上的现有远程 shell 设施,如 SSH。 + +ClusterShell 的主要目标是通过为开发人员提供轻量级、但可扩展的 Python API 来改进高性能集群的管理。它还提供了 `clush`、`clubak` 和 `cluset`/`nodeset` 等方便的命令行工具,可以让传统的 shell 脚本利用这个库的一些功能。 + +ClusterShell 是用 Python 编写的,它需要 Python(v2.6+ 或 v3.4+)才能在你的系统上运行。 + +### 如何在 Linux 上安装 ClusterShell? + +ClusterShell 包在大多数发行版的官方包管理器中都可用。因此,使用发行版包管理器工具进行安装。 + +对于 Fedora 系统,使用 [DNF 命令][4]来安装 clustershell。 + +``` +$ sudo dnf install clustershell +``` + +如果系统默认是 Python 2,这会安装 Python 2 模块和工具,可以运行以下命令安装 Python 3 开发包。 + +``` +$ sudo dnf install python3-clustershell +``` + +在执行 clustershell 安装之前,请确保你已在系统上启用 [EPEL 存储库][5]。 + +对于 RHEL/CentOS 系统,使用 [YUM 命令][6] 来安装 clustershell。 + +``` +$ sudo yum install clustershell +``` + +如果系统默认是 Python 2,这会安装 Python 2 模块和工具,可以运行以下命令安装 Python 3 开发包。 + +``` +$ sudo yum install python34-clustershell +``` + +对于 openSUSE Leap 系统,使用 [Zypper 命令][7] 来安装 clustershell。 + +``` +$ sudo zypper install clustershell +``` + +如果系统默认是 Python 2,这会安装 Python 2 模块和工具,可以运行以下命令安装 Python 3 开发包。 + +``` +$ sudo zypper install python3-clustershell +``` + +对于 Debian/Ubuntu 系统,使用 [APT-GET 命令][8] 或 [APT 命令][9] 来安装 clustershell。 + +``` +$ sudo apt install clustershell +``` + +### 如何在 Linux 使用 PIP 安装 ClusterShell? + +可以使用 PIP 安装 ClusterShell,因为它是用 Python 编写的。 + +在执行 clustershell 安装之前,请确保你已在系统上启用了 [Python][10] 和 [PIP][11]。 + +``` +$ sudo pip install ClusterShell +``` + +### 如何在 Linux 上使用 ClusterShell? + +与其他实用程序(如 `pssh` 和 `dsh`)相比,它是直接了当的优秀工具。它有很多选项可以在远程并行执行。 + +在开始使用 clustershell 之前,请确保你已启用系统上的[无密码登录][12]。 + +以下配置文件定义了系统范围的默认值。你不需要修改这里的任何东西。 + +``` +$ cat /etc/clustershell/clush.conf +``` + +如果你想要创建一个服务器组,那也可以。默认情况下有一些示例,请根据你的要求执行相同操作。 + +``` +$ cat /etc/clustershell/groups.d/local.cfg +``` + +只需按以下列格式运行 clustershell 命令即可从给定节点获取信息: + +``` +$ clush -w 192.168.1.4,192.168.1.9 cat /proc/version +192.168.1.9: Linux version 4.15.0-45-generic ([email protected]) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 +192.168.1.4: Linux version 3.10.0-957.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Thu Nov 8 23:39:32 UTC 2018 +``` + +选项: + + * `-w:` 你要运行该命令的节点。 + +你可以使用正则表达式而不是使用完整主机名和 IP: + +``` +$ clush -w 192.168.1.[4,9] uname -r +192.168.1.9: 4.15.0-45-generic +192.168.1.4: 3.10.0-957.el7.x86_64 +``` + +或者,如果服务器位于同一 IP 系列中,则可以使用以下格式: + +``` +$ clush -w 192.168.1.[4-9] date +192.168.1.6: Mon Mar 4 21:08:29 IST 2019 +192.168.1.7: Mon Mar 4 21:08:29 IST 2019 +192.168.1.8: Mon Mar 4 21:08:29 IST 2019 +192.168.1.5: Mon Mar 4 09:16:30 CST 2019 +192.168.1.9: Mon Mar 4 21:08:29 IST 2019 +192.168.1.4: Mon Mar 4 09:16:30 CST 2019 +``` + +clustershell 允许我们以批处理模式运行命令。使用以下格式来实现此目的: + +``` +$ clush -w 192.168.1.4,192.168.1.9 -b +Enter 'quit' to leave this interactive mode +Working with nodes: 192.168.1.[4,9] +clush> hostnamectl +--------------- +192.168.1.4 +--------------- + Static hostname: CentOS7.2daygeek.com + Icon name: computer-vm + Chassis: vm + Machine ID: 002f47b82af248f5be1d67b67e03514c + Boot ID: f9b37a073c534dec8b236885e754cb56 + Virtualization: kvm + Operating System: CentOS Linux 7 (Core) + CPE OS Name: cpe:/o:centos:centos:7 + Kernel: Linux 3.10.0-957.el7.x86_64 + Architecture: x86-64 +--------------- +192.168.1.9 +--------------- + Static hostname: Ubuntu18 + Icon name: computer-vm + Chassis: vm + Machine ID: 27f6c2febda84dc881f28fd145077187 + Boot ID: f176f2eb45524d4f906d12e2b5716649 + Virtualization: oracle + Operating System: Ubuntu 18.04.2 LTS + Kernel: Linux 4.15.0-45-generic + Architecture: x86-64 +clush> free -m +--------------- +192.168.1.4 +--------------- + total used free shared buff/cache available +Mem: 1838 641 217 19 978 969 +Swap: 2047 0 2047 +--------------- +192.168.1.9 +--------------- + total used free shared buff/cache available +Mem: 1993 352 1067 1 573 1473 +Swap: 1425 0 1425 +clush> w +--------------- +192.168.1.4 +--------------- + 09:21:14 up 3:21, 3 users, load average: 0.00, 0.01, 0.05 +USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT +daygeek :0 :0 06:02 ?xdm? 1:28 0.30s /usr/libexec/gnome-session-binary --session gnome-classic +daygeek pts/0 :0 06:03 3:17m 0.06s 0.06s bash +daygeek pts/1 192.168.1.6 06:03 52:26 0.10s 0.10s -bash +--------------- +192.168.1.9 +--------------- + 21:13:12 up 3:12, 1 user, load average: 0.08, 0.03, 0.00 +USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT +daygeek pts/0 192.168.1.6 20:42 29:41 0.05s 0.05s -bash +clush> quit +``` + +如果要在一组节点上运行该命令,请使用以下格式: + +``` +$ clush -w @dev uptime +or +$ clush -g dev uptime +or +$ clush --group=dev uptime + +192.168.1.9: 21:10:10 up 3:09, 1 user, load average: 0.09, 0.03, 0.01 +192.168.1.4: 09:18:12 up 3:18, 3 users, load average: 0.01, 0.02, 0.05 +``` + +如果要在多个节点组上运行该命令,请使用以下格式: + +``` +$ clush -w @dev,@uat uptime +or +$ clush -g dev,uat uptime +or +$ clush --group=dev,uat uptime + +192.168.1.7: 07:57:19 up 59 min, 1 user, load average: 0.08, 0.03, 0.00 +192.168.1.9: 20:27:20 up 1:00, 1 user, load average: 0.00, 0.00, 0.00 +192.168.1.5: 08:57:21 up 59 min, 1 user, load average: 0.00, 0.01, 0.05 +``` + +clustershell 允许我们将文件复制到远程计算机。将本地文件或目录复制到同一个远程节点: + +``` +$ clush -w 192.168.1.[4,9] --copy /home/daygeek/passwd-up.sh +``` + +我们可以通过运行以下命令来验证它: + +``` +$ clush -w 192.168.1.[4,9] ls -lh /home/daygeek/passwd-up.sh +192.168.1.4: -rwxr-xr-x. 1 daygeek daygeek 159 Mar 4 09:00 /home/daygeek/passwd-up.sh +192.168.1.9: -rwxr-xr-x 1 daygeek daygeek 159 Mar 4 20:52 /home/daygeek/passwd-up.sh +``` + +将本地文件或目录复制到不同位置的远程节点: + +``` +$ clush -g uat --copy /home/daygeek/passwd-up.sh --dest /tmp +``` + +我们可以通过运行以下命令来验证它: + +``` +$ clush --group=uat ls -lh /tmp/passwd-up.sh +192.168.1.7: -rwxr-xr-x. 1 daygeek daygeek 159 Mar 6 07:44 /tmp/passwd-up.sh +``` + +将文件或目录从远程节点复制到本地系统: + +``` +$ clush -w 192.168.1.7 --rcopy /home/daygeek/Documents/magi.txt --dest /tmp +``` + +我们可以通过运行以下命令来验证它: + +``` +$ ls -lh /tmp/magi.txt.192.168.1.7 +-rw-r--r-- 1 daygeek daygeek 35 Mar 6 20:24 /tmp/magi.txt.192.168.1.7 +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/clustershell-clush-run-commands-on-cluster-nodes-remote-system-in-parallel-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/pssh-parallel-ssh-run-execute-commands-on-multiple-linux-servers/ +[2]: https://www.2daygeek.com/dsh-run-execute-shell-commands-on-multiple-linux-servers-at-once/ +[3]: https://cea-hpc.github.io/clustershell/ +[4]: https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ +[5]: https://www.2daygeek.com/install-enable-epel-repository-on-rhel-centos-scientific-linux-oracle-linux/ +[6]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ +[7]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ +[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/3-methods-to-install-latest-python3-package-on-centos-6-system/ +[11]: https://www.2daygeek.com/install-pip-manage-python-packages-linux/ +[12]: https://www.2daygeek.com/linux-passwordless-ssh-login-using-ssh-keygen/ diff --git a/published/201907/20190320 4 cool terminal multiplexers.md b/published/201907/20190320 4 cool terminal multiplexers.md new file mode 100644 index 0000000000..2b7ba72802 --- /dev/null +++ b/published/201907/20190320 4 cool terminal multiplexers.md @@ -0,0 +1,117 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11054-1.html) +[#]: subject: (4 cool terminal multiplexers) +[#]: via: (https://fedoramagazine.org/4-cool-terminal-multiplexers/) +[#]: author: (Paul W. Frields https://fedoramagazine.org/author/pfrields/) + +4 款很酷的终端复用器 +====== + +![][1] + +Fedora 系统对很多用户来说都很舒适。它有一个令人惊叹的桌面,可以轻松地完成日常任务。而在这光鲜的表面之下是由 Linux 系统提供的支持,而终端是高级用户使用这些底层能力的最简单方法。默认的终端简单且功能有限。但是,*终端复用器*能让你的终端变得非常强大。本文展示了一些流行的终端多路复用器以及如何安装它们。 + +为什么要用它?嗯,首先,它可以让你注销你的系统,而同时*让你的终端会话不受干扰*。退出你的控制台,这样安全,在其他地方旅行时通过远程登录 SSH 继续之前的操作是非常有用的。这里有一些工具可以看下。 + +最古老和最知名的终端多路复用器之一是 `screen`。但是,由于其代码不再维护,本文将重点介绍最近的应用。 (“最近的”是相对而言的,其中一些已存在多年!) + +### Tmux + +`tmux` 是 `screen` 最广泛使用的替代品之一。它有高度可配置的接口。你可以根据需要对 `tmux` 进行编程以启动特定类型的会话。在前面发表的这篇文章中你会发现更多关于 tmux 的信息: + +- [使用 tmux 实现更强大的终端][2] + +已经是 `tmux` 用户?你可能会喜欢[这篇使你的 tmux 会话更有效的文章][3]。 + +要安装 `tmux`,由于你可能已经在终端中,请带上 `sudo` 使用 `dnf`: + +``` +$ sudo dnf install tmux +``` + +要开始学习,请运行 `tmux` 命令。单窗格窗口以你的默认 shell 启动。tmux 使用*修饰键*来表示接下来会发出命令。默认情况下,此键为 `Ctrl+B`。如果输入 `Ctrl+B, C`,你将创建一个带有 shell 的新窗口。 + +提示:使用 `Ctrl+B, ?` 进入帮助模式,会列出你可以使用的所有键。为了简单起见,你先查看 `bind-key -T prefix` 开头的行。这些是你可以在修饰键之后立即使用的键,可以用来配置你的 `tmux` 会话。你可以按 `Ctrl+C` 退出帮助模式回 `tmux`。 + +要完全退出 `tmux`,请使用标准 `exit` 命令或 `Ctrl+D` 退出所有 shell。 + +### Dvtm + +你可能最近在 Fedroa Magzine 上看到过一篇 [dwm,一个动态窗口管理器][4]的文章。像 `dwm` 一样,`dvtm` 用于平铺窗口管理,但是是用在终端中。它的设计坚持 UNIX 的“做好一件事”的理念,在这里是管理终端中的窗口。 + +安装 `dvtm` 也很简单。但是,如果你想要前面提到的注销功能,你还需要 `abduco` 包来处理 dvtm 的会话管理。 + +``` +$ sudo dnf install dvtm abduco +``` + +`dvtm` 已经映射了许多管理终端窗口的按键。默认情况下,它使用 `Ctrl+G` 作为其修饰键。这个按键告诉 `dvtm` 接下来的字符将成为它应该处理的命令。例如, `Ctrl+G, C` 创建一个新窗口,`Ctrl+G, X` 将其关闭。 + +有关使用 `dvtm` 的更多信息,请查看 `dvtm` 的[主页][5],其中包含大量提示和入门信息。 + +### Byobu + +虽然 `byobu` 本身并不是真正的多路复用器 —— 它封装了 `tmux` 甚至更老的 `screen` 来添加功能,但它也值得在这里一提。通过帮助菜单和窗口选项卡,以便更加容易地找到那些功能,`byobu` 使终端复用器更适合初学者。 + +当然它也可以在 Fedora 仓库中找到。要安装它,请使用以下命令: + +``` +$ sudo dnf install byobu +``` + +默认情况下,`byobu` 会在内部运行 `screen`,因此你可能希望运行 `byobu-tmux` 来封装 `tmux`。你可以使用 `F9` 键打开帮助菜单以获取更多信息,来帮助你入门。 + +### Mtm + +`mtm` 是你可以找到的最小的复用器之一。事实上,它只有大约 1000 行代码!如果你处于受限的环境(例如旧硬件、最小容器等)中,你可能会发现它很有用。要开始使用,你需要安装一些包。 + +``` +$ sudo dnf install git ncurses-devel make gcc +``` + +然后克隆 `mtm` 所在的仓库: + +``` +$ git clone https://github.com/deadpixi/mtm.git +``` + +进入 `mtm` 文件夹并构建程序: + +``` +$ make +``` + +你可能会收到一些警告,但完成后,你将会有一个非常小的 `mtm` 程序。使用以下命令运行它: + +``` +$ ./mtm +``` + +你可以在 [GitHub 页面][6]上找到该程序的所有文档。 + +这里只是一些终端复用器。你有想推荐的么?请在下面留下你的评论,享受在终端中创建窗口吧! + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/4-cool-terminal-multiplexers/ + +作者:[Paul W. Frields][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2018/08/tmuxers-4-816x345.jpg +[2]: https://fedoramagazine.org/use-tmux-more-powerful-terminal/ +[3]: https://fedoramagazine.org/4-tips-better-tmux-sessions/ +[4]: https://fedoramagazine.org/lets-try-dwm-dynamic-window-manger/ +[5]: http://www.brain-dump.org/projects/dvtm/#why +[6]: https://github.com/deadpixi/mtm +[7]: https://unsplash.com/photos/48yI_ZyzuLo?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[8]: https://unsplash.com/search/photos/windows?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/201907/20190416 Can schools be agile.md b/published/201907/20190416 Can schools be agile.md new file mode 100644 index 0000000000..1e696ab2cd --- /dev/null +++ b/published/201907/20190416 Can schools be agile.md @@ -0,0 +1,68 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11076-1.html) +[#]: subject: (Can schools be agile?) +[#]: via: (https://opensource.com/open-organization/19/4/education-culture-agile) +[#]: author: (Ben Owens https://opensource.com/users/engineerteacher/users/ke4qqq/users/n8chz/users/don-watkins) + +学校可以变得敏捷吗? +====== +> 我们一定不会希望用商业的方式运作我们的学校 —— 但是更加注重持续改进的教育机构是可以让我们受益的。 + +![][1] + +我们都有过那种感觉一件事情“似曾相识”的经历。在 1980 年代末期我经常会有这种感觉,那时候我刚刚进入工业领域不久。当时正赶上一波组织变革的热潮,美国制造业在尝试各种各样不同的模型,让企业领导、经理人和像我这样的工程师重新思考我们应该如何处理质量、成本、创新以及股东价值这样的问题。我们似乎每一年(有时候更加频繁)都需要通过学习一本书来找到让我们更精简、更扁平、更灵活以及更加能满足顾客需求的“最佳方案”。 + +这里面的很多方法都带来了巨大的改进,我至今仍然赞同它们的核心原则。像 John Kotter、Peter Drucker、Edwards Demming 和 Peter Senge 这样的思想领袖提出的某些思想和策略,还有我们采用的像 Six Sigma 以及在“丰田模式”里可以找到的一些流程优化方法,对我们改进工作都起到了十分关键的作用。 + +但是其他人似乎只是在同样的思想上进行了润色和调整,然后重新包装了一下 —— 所以我才会有那种 *似曾相识* 的感觉。但是当我成为了一名教师之后,我遇到了一个 *没有* 给我那种似曾相识的感觉的地方:教育界。事实上我十分惊讶地发现,在我的这个新职业里,“持续不断的改进”并 *不像* 在我之前的职业里那样重要了(特别是对于像我这种授课老师职级的人来说)。 + +为什么教育机构很少努力营造一种不断改进的文化氛围呢?我能想到几个原因,在这里我列举两个。 + +### 不再做生产线上的元件 + +这种不断改进的文化氛围遇到的第一个阻碍是,教育界普遍不愿意从其它行业借鉴可以为自己所用的思想 —— 特别是来自商界的思想。第二个阻碍是,主导教育界的仍然是一种自上而下的、等级制度森严的领导模式。人们往往只能在小范围内讨论这种系统性的、持续的改进方案,比如包括校长、助理校长、学校监管人(LCTT 译注:美国地方政府下设的一种官职,每个学校监管人管理一定数量的学校,接受学校校长的汇报)等等在内的学校领导和区域领袖。但是一小群人的参与是远远不足以带来整个组织层面的文化改革的。 + +在进一步展开观点之前,我想强调一下,上面所做的概括一定是存在例外情况的(我自己就见到过很多),不过我觉得任何一个教育界的利益相关者都应该会同意以下两点基本假设: + + 1. 为学生提供高质量的、公平的教育和教学系统的工作所涉及到的任何人都应该将持续不断的改进作为思维方式里的重要部分; + 2. 如果学校领导在做决策的时候可以更多地参考那些离学生最近的工作者的意见,那么学生以及学生所在的社区都将更加受益; + +那么教育界人士为什么会倾向于忽视(或者公然地敌视)教育界之外的思想呢? + +比如我过去就曾经提议应该向别的行业借鉴一些思想和灵感来帮助我们更好地迎合学生的需求,并且果然遭到了批评。我经常得到的回应是:“你这是在把我们的学生当成生产线上的元件来对待呀!”但是我们的学生现在就是在被当作生产线上的元件对待,并且已经无以复加了。他们按照被年龄划分的群体考入大学,每天根据刺耳的铃声的指示去上一节又一节孤立的课程,并且由一些武断的、强调同一性而不是个性的考试来评判他们的成绩。 + +很多教育界人士可能不知道,生产线元件这种会让人想到流水线标准化作业的东西已经不是现代制造业里的重要组成部分了。得益于上面提到的不断改进的文化氛围,现代先进制造业已经可以做到在单个顾客产生需求的时候,以合理的价格有针对性地提供她所需要的商品。如果我们的学校也可以采用这种模式,教师们之间就更可能会进行协作,并且可以基于学生即时的需求和兴趣,不断完善每一个学生独特的成长和进步路线,而不受时间、课题或者其它传统规范的限制。 + +我并不是要呼吁大家像经营商业一样经营我们的学校。我所主张的是,用一种清晰而客观的态度去看待任何行业的任何思想,只要它们有可能帮助我们更好地迎合学生个体的需求。不过,如果想有效率地实现这个目标,我们需要仔细研究这个 100 多年来都停滞不前的领导结构。 + +### 把不断改进作为努力的目标 + +有一种说法认为教育和其它行业之间存在着巨大的差异,我虽然赞同这种说法,但同时也相信“重新思考组织和领导结构”这件事情对于任何一个希望对利益相关者负责(并且可以及时作出响应)的主体来说都是适用的。大多数其它行业都已经在重新审视它们传统的、封闭的、等级森严的结构,并且采用可以鼓励员工基于共有的优秀目标发挥自主性的组织结构 —— 这种组织结构对于不断改进来说十分关键。我们的学校和行政区是时候放开眼界了,而不应该拘泥于只听到来自内部的声音,因为它们的用意虽然是好的,但都没有脱离现有的范式。 + +对于任何希望开始或者加速这个转变过程的学校,我推荐一本很好的书:Jim Whitehurst 的《开放组织》(这不应该让你感到意外)。这本书不仅可以帮助我们理解教育者如何创造更加开放、覆盖面更广的领导领导结构 —— 在这样的结构下,互相尊重让人们可以基于实时数据作出更加灵活的决策 —— 并且它所使用的语言风格也和教育者们所习惯使用的奇怪的词汇库非常契合(这种词汇库简直是教育者们第二天性)。任何组织都可以借鉴开放组织的思维提供的实用主义方法让组织成员更加开放:分享想法和资源、拥抱以共同协作为核心的文化、通过快速制作原型来开发创新思维、基于价值(而不是提出者的职级)来评估一个想法,以及创造一种融入到组织 DNA 里的很强的社区观念。通过众包的方式,这样的开放组织不仅可以从组织内部,也能够从组织外部收集想法,创造一种可以让本地化的、以学生为中心的创新蓬勃发展的环境。 + +最重要的事情是:在快速变化的未来,我们在过去所做的事情不一定仍然适用了 —— 认清楚这一点对于创造一个不断改进的文化氛围是十分关键的。对于教育者来说,这意味着我们不能只是简单地依赖在针对工厂模型发展出来的解决方案和实践方式了。我们必须从其它行业(比如说非营利组织、军事、医疗以及商业 —— 没错,甚至是商业)里借鉴数不清的最佳方案,这样至少应该能让我们 *知道* 如何找到让学生受益最大的办法。从教育界传统的陈词滥调里超脱出来,才有机会拥有更广阔的视角。我们可以更好地顾全大局,用更客观地视角看待我们遇到的问题,同时也知道我们在什么方面已经做得很不错。 + +通过有意识地借鉴各路思想 —— 从一年级教师到纽约时报上最新的商业、管理、领导力畅销书 —— 我们可以更好地发掘和运用校内人才,以帮助我们克服阻碍了我们的学校和区域进步的制度里的惰性。 + +坚持不懈地追求不断改进这件事情,不应该只局限于那种努力在一个全球化的、创新的经济环境中争取竞争力的机构,或者是负责运营学校的少数几个人。当机构里的每一个人都能不断思考怎样才能让今天比昨天做得更好的时候,这就是一个拥有优秀的文化氛围的机构。这种非常有注重协作性和创新的文化氛围,正是我们希望在这些负责改变年轻人命运的机构身上看到的。 + +我非常期待,有朝一日我能在学校里感受到这种精神,然后微笑着对自己说:“这种感觉多么似曾相识啊。” + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/19/4/education-culture-agile + +作者:[Ben Owens][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/engineerteacher/users/ke4qqq/users/n8chz/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDUCATION_network.png?itok=ySEHuAQ8 diff --git a/sources/tech/20190501 Looking into Linux modules.md b/published/201907/20190501 Looking into Linux modules.md similarity index 59% rename from sources/tech/20190501 Looking into Linux modules.md rename to published/201907/20190501 Looking into Linux modules.md index cb431874d3..59532ccedb 100644 --- a/sources/tech/20190501 Looking into Linux modules.md +++ b/published/201907/20190501 Looking into Linux modules.md @@ -1,30 +1,30 @@ [#]: collector: (lujun9972) -[#]: translator: (bodhix) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (LazyWolfLin) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11075-1.html) [#]: subject: (Looking into Linux modules) -[#]: via: (https://www.networkworld.com/article/3391362/looking-into-linux-modules.html#tk.rss_all) +[#]: via: (https://www.networkworld.com/article/3391362/looking-into-linux-modules.html) [#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) -Looking into Linux modules +深入学习 Linux 内核模块 ====== -The lsmod command can tell you which kernel modules are currently loaded on your system, along with some interesting details about their use. + +> lsmod 命令能够告诉你当前系统上加载了哪些内核模块,以及关于使用它们的一些有趣的细节。 + ![Rob Oo \(CC BY 2.0\)][1] -### What are Linux modules? +### 什么是 Linux 内核模块? -Kernel modules are chunks of code that are loaded and unloaded into the kernel as needed, thus extending the functionality of the kernel without requiring a reboot. In fact, unless users inquire about modules using commands like **lsmod** , they won't likely know that anything has changed. +内核模块是可以根据需要加载到内核中或从内核中卸载的代码块,因此无需重启就可以扩展内核的功能。事实上,除非用户使用类似 `lsmod` 这样的命令来查询模块信息,否则用户不太可能知道内核发生的任何变化。 -One important thing to understand is that there are _lots_ of modules that will be in use on your Linux system at all times and that a lot of details are available if you're tempted to dive into the details. +需要知道的重要一点是,在你的 Linux 系统上总会有*很多*可用的模块,并且如果你可以深入其中了解到很多细节。 -One of the prime ways that lsmod is used is to examine modules when a system isn't working properly. However, most of the time, modules load as needed and users don't need to be aware of how they are working. +`lsmod` 的主要用途之一是在系统不能正常工作时检查模块。然而,大多数情况下,模块会根据需要加载的,而且用户不需要知道它们如何运作。 -**[ Also see:[Must-know Linux Commands][2] ]** +### 显示内核模块 -### Listing modules - -The easiest way to list modules is with the **lsmod** command. While this command provides a lot of detail, this is the most user-friendly output. +显示内核模块最简单的方法是使用 `lsmod` 命令。虽然这个命令包含了很多细节,但输出却是非常用户友好。 ``` $ lsmod @@ -103,44 +103,40 @@ e1000e 245760 0 floppy 81920 0 ``` -In the output above: +在上面的输出中: - * "Module" shows the name of each module - * "Size" shows the module size (not how much memory it is using) - * "Used by" shows each module's usage count and the referring modules + * `Module` 显示每个模块的名称 + * `Size` 显示每个模块的大小(并不是它们占的内存大小) + * `Used by` 显示每个模块被使用的次数和使用它们的模块 - - -Clearly, that's a _lot_ of modules. The number of modules loaded will depend on your system and distribution and what's running. We can count them like this: +显然,这里有*很多*模块。加载的模块数量取决于你的系统和版本以及正在运行的内容。我们可以这样计数: ``` $ lsmod | wc -l 67 ``` -To see the number of modules available on the system (not just running), try this command: +要查看系统中可用的模块数(不止运行当中的),试试这个命令: ``` $ modprobe -c | wc -l 41272 ``` -### Other commands for examining modules +### 与内核模块相关的其他命令 -Linux provides several commands for listing, loading and unloading, examining, and checking the status of modules. +Linux 提供了几条用于罗列、加载及卸载、测试,以及检查模块状态的命令。 - * depmod -- generates modules.dep and map files - * insmod -- a simple program to insert a module into the Linux Kernel - * lsmod -- show the status of modules in the Linux Kernel - * modinfo -- show information about a Linux Kernel module - * modprobe -- add and remove modules from the Linux Kernel - * rmmod -- a simple program to remove a module from the Linux Kernel + * `depmod` —— 生成 `modules.dep` 和映射文件 + * `insmod` —— 一个往 Linux 内核插入模块的程序 + * `lsmod` —— 显示 Linux 内核中模块状态 + * `modinfo` —— 显示 Linux 内核模块信息 + * `modprobe` —— 添加或移除 Linux 内核模块 + * `rmmod` —— 一个从 Linux 内核移除模块的程序 +### 显示内置的内核模块 - -### Listing modules that are built in - -As mentioned above, the **lsmod** command is the most convenient command for listing modules. There are, however, other ways to examine them. The modules.builtin file lists all modules that are built into the kernel and is used by modprobe when trying to load one of these modules. Note that **$(uname -r)** in the commands below provides the name of the kernel release. +正如前文所说,`lsmod` 命令是显示内核模块最方便的命令。然而,也有其他方式可以显示它们。`modules.builtin` 文件中列出了所有构建在内核中的模块,在 `modprobe` 命令尝试添加文件中的模块时会使用它。注意,以下命令中的 `$(uname -r)` 提供了内核版本的名称。 ``` $ more /lib/modules/$(uname -r)/modules.builtin | head -10 @@ -156,7 +152,7 @@ kernel/fs/configfs/configfs.ko kernel/fs/crypto/fscrypto.ko ``` -You can get some additional detail on a module by using the **modinfo** command, though nothing that qualifies as an easy explanation of what service the module provides. The omitted details from the output below include a lengthy signature. +你可以使用 `modinfo` 获得一个模块的更多细节,虽然没有对模块提供的服务的简单说明。下面输出内容中省略了冗长的签名。 ``` $ modinfo floppy | head -16 @@ -178,35 +174,31 @@ sig_key: sig_hashalgo: md4 ``` -You can load or unload a module using the **modprobe** command. Using a command like the one below, you can locate the kernel object associated with a particular module: +你可以使用 `modprobe` 命令加载或卸载模块。使用下面这条命令,你可以找到特定模块关联的内核对象: ``` $ find /lib/modules/$(uname -r) -name floppy* /lib/modules/5.0.0-13-generic/kernel/drivers/block/floppy.ko ``` -If you needed to load the module, you could use a command like this one: +如果你想要加载模块,你可以使用这个命令: ``` $ sudo modprobe floppy ``` -### Wrap-up +### 总结 -Clearly the loading and unloading of modules is a big deal. It makes Linux systems considerably more flexible and efficient than if they ran with a one-size-fits-all kernel. It also means you can make significant changes — including adding hardware — without rebooting. - -**[ Two-Minute Linux Tips:[Learn how to master a host of Linux commands in these 2-minute video tutorials][3] ]** - -Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. +很明显,内核模块的加载和卸载非常重要。它使得 Linux 系统比使用通用内核运行时更加灵活和高效。这同样意味着你可以进行重大更改而无需重启,例如添加硬件。 -------------------------------------------------------------------------------- -via: https://www.networkworld.com/article/3391362/looking-into-linux-modules.html#tk.rss_all +via: https://www.networkworld.com/article/3391362/looking-into-linux-modules.html 作者:[Sandra Henry-Stocker][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[LazyWolfLin](https://github.com/LazyWolfLin) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/201907/20190505 Blockchain 2.0 - Public Vs Private Blockchain Comparison -Part 7.md b/published/201907/20190505 Blockchain 2.0 - Public Vs Private Blockchain Comparison -Part 7.md new file mode 100644 index 0000000000..6b950bc807 --- /dev/null +++ b/published/201907/20190505 Blockchain 2.0 - Public Vs Private Blockchain Comparison -Part 7.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: (zionfuo) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11080-1.html) +[#]: subject: (Blockchain 2.0 – Public Vs Private Blockchain Comparison [Part 7]) +[#]: via: (https://www.ostechnix.com/blockchain-2-0-public-vs-private-blockchain-comparison/) +[#]: author: (editor https://www.ostechnix.com/author/editor/) + +区块链 2.0:公有链与私有链(七) +====== + +![Public vs Private blockchain][1] + +[区块链 2.0][2]系列的前一篇文章探索了[智能合同的现状][3]。这篇文章旨在揭示可以创建的不同类型的区块链。它们每个都用于非常不同的应用程序,并且根据用例的不同,每个应用程序所遵循的协议也不同。现在,让我们将公有链之于私有链对比一下开源软件之于专有技术。 + +正如我们所知,基于区块链的分布式分类账本的基本三层结构如下: + +![][4] + +*图 1 – 区块链分布式账本的基本结构* + +这里提到的类型之间的差异主要归因于底层区块链其所依赖的协议。该协议规定了参与者的规则和参与的方式。 + +阅读本文时,请记住以下几点事项: + +- 任何平台的产生都是为了解决需求而生。技术应该采取最好的方向。例如,区块链具有巨大的应用价值,其中一些可能需要丢弃在其他情形中看起来很重要的功能。在这方面,**分布式存储**就是最好的例子。 +- 区块链本质上是一个数据库系统,通过时间戳和区块的形式组织数据来跟踪信息。此类区块链的创建者可以选择谁有权产出这些区块并进行修改。 +- 区块链也可以“中心化”,参与的程度可以限定于由“中央权威”认定为符合条件的人。 + +大多数区块链要么是公有的,要么是私有的。广义上说,公有链可以被认为是开源软件的等价物,大多数私有链可以被视为源自公有链的专有平台。下图应该会让大多数人明显地看出基本的区别。 + +![][5] + +*图 2 – 公有链/私有链与开源/专有技术的对比* + +虽然这是最受欢迎的理解。但是这并不是说所有的私有链都是从公有链中衍生出来的。 + +### 公有链 + +公有链可以被视为是一个无需许可的、开放的平台或网络。任何拥有专业知识和计算资源的人都可以参与其中。这将产生以下影响: + +- 任何人都可以加入公有链网络并参与到其中。“参与者” 所需要的只是稳定的网络资源和计算资源。 +- 参与行为包括了读取、写入、验证和提供交易期间的共识。比特币矿工就是很好的例子。作为网络的参与者,矿工会得到比特币作为回报。 +- 平台完全去中心,完全冗余。 +- 由于去中心化,没有一个实体可以完全控制分类账本中记录的数据。所有 (或大多数) 参与者都需要通过验证区块的方式检查数据。 +- 这意味着,一旦信息被验证和记录,就不能轻易改变。即使能改变,也不可能不留下痕迹。 +- 在比特币和莱特币等平台上,参与者的身份仍然是匿名的。设计这些平台的目的是保护和保护用户身份。这主要是由上层协议栈提供的功能。 +- 公有链有比特币、莱特币、以太坊等不同的网络。 +- 广泛的去中心化意味着,在区块链分布式网络实现的交易,获得共识可能需要一段时间,对于旨在每时每刻都在推动大量交易的大型企业来说,吞吐量可能是一个挑战。 +- 开放式参与,使比特币等公有链中的大量参与者,往往会增加对计算设备和能源成本的初始投资。 +- 公有链以设计安全著称。它们的实现依靠以下几点: + - 匿名参与者 + - 多个节点上的分布式和冗余的加密存储 + - 创建和更改数据需要大量的共识 + +### 私有链 + +相比之下,私有链是一个*被许可的区块链**。这意味着: + +- 参与网络的许可受到限制,并由监督网络的所有者或机构主持。这意味着,即使个人能够存储数据并进行交易(例如,发送和接收付款),这些交易的验证和存储也只能由选定的参与者来完成。 +- 参与者一旦获得中心机构的许可,将受到条款的限制。例如,在金融机构运营的私有链网络中,并不是每个客户都可以访问整个区块链的分布式账本,甚至在那些获得许可的客户中吗,也不是每个人都能访问所有的东西。在这种情况下,中心机构将授予访问选择服务的权限。这通常被称为 “**通道**”。 +- 与公有链相比,这种系统具有更大的吞吐量能力,也展示了更快的交易速度,因为区块只需要由少数几个人验证。 + +私有链通常在其协议中没有任何特征。这使得该系统仅与目前使用的大多数基于云的数据库系统一样安全。 + +### 智者的观点 + +需要注意的一点是,它们被命名为公有或私有(或开源、闭源)的事实与底层代码库无关。在这两种情况下,平台所基于的代码或文字基础可能是公开的,也可能不是公开的。R3 是一家 DLT(分布式分类账本**D**istributed **L**edger **T**echnology)公司,领导着由 200 多家跨国机构组成的公有财团。他们的目标是在金融和商业领域进一步发展区块链和相关分布式账本技术。corda 是这一共同努力的产物。R3 将 corda 定义为专门为企业构建的区块链平台。其代码库同样是开源的,鼓励世界各地的开发人员为这个项目做出贡献。然而,考虑到 corda 面临的业务性质和旨在满足的需求,corda 被归类为许可的封闭区块链平台。这意味着企业可以在部署后选择网络的参与者,并通过使用原生可用的智能合约工具选择这些参与者可以访问的信息类型。 + +虽然像比特币和以太坊这样的公有链负责该领域的广泛认知和发展,但仍然可以认为,为企业或商业环境中的特定用例设计的私有链将在短期内引领货币投资。这些都是我们大多数人在不久的将来会看到以实际方式运用起来的平台。 + +请继续阅读本系列中下一篇有关 Hyperledger 项目的文章。 + +- [区块链 2.0:Hyperledger(HLP)项目介绍][6] + +我们正在研究更多有趣的区块链技术话题。敬请期待! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/blockchain-2-0-public-vs-private-blockchain-comparison/ + +作者:[ostechnix][a] +选题:[lujun9972][b] +译者:[zionfuo](https://github.com/zionfuo) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/04/Public-Vs-Private-Blockchain-720x340.png +[2]: https://linux.cn/article-10650-1.html +[3]: https://linux.cn/article-11013-1.html +[4]: http://www.ostechnix.com/wp-content/uploads/2019/04/blockchain-architecture.png +[5]: http://www.ostechnix.com/wp-content/uploads/2019/04/Public-vs-Private-blockchain-comparison.png +[6]: https://www.ostechnix.com/blockchain-2-0-an-introduction-to-hyperledger-project-hlp/ diff --git a/published/201907/20190513 When to be concerned about memory levels on Linux.md b/published/201907/20190513 When to be concerned about memory levels on Linux.md new file mode 100644 index 0000000000..dc63f7089f --- /dev/null +++ b/published/201907/20190513 When to be concerned about memory levels on Linux.md @@ -0,0 +1,118 @@ +[#]: collector: (lujun9972) +[#]: translator: (luuming) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11067-1.html) +[#]: subject: (When to be concerned about memory levels on Linux) +[#]: via: (https://www.networkworld.com/article/3394603/when-to-be-concerned-about-memory-levels-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +何时需要关注 Linux 的内存用量? +====== + +> Linux 上的内存管理很复杂。尽管使用率高但未必存在问题。你也应当关注一些其他的事情。 + +![](https://img.linux.net.cn/data/attachment/album/201907/06/173913n6rjbxwj6bfrjxwx.jpg) + +在 Linux 上用光内存通常并不意味着存在严重的问题。为什么?因为健康的 Linux 系统会在内存中缓存磁盘活动,基本上占用掉了未被使用的内存,这显然是一件好事情。 + +换句话说,它不让内存浪费掉。使用空闲的内存增加磁盘访问速度,并且不占用运行中应用程序的内存。你也能够想到,使用这种内存缓存比起直接访问硬盘驱动器(HDD)快上数百倍,也比明显快于直接访问固态硬盘驱动。内存占满或几乎占满通常意味着系统正在尽可能高效地运行当中 —— 并不是运行中遇到了问题。 + +### 缓存如何工作 + +磁盘缓存简单地意味着系统充分利用未使用的资源(空闲内存)来加速磁盘读取与写入。应用程序不会失去任何东西,并且大多数时间里能够按需求获得更多的内存。此外,磁盘缓存不会导致应用程序转而使用交换分区。反而,用作磁盘缓存的内存空间当被需要时会立即归还,并且磁盘内容会被更新。 + +### 主要和次要的页故障 + +Linux 系统通过分割物理内存来为进程分配空间,将分割成的块称为“页”,并且映射这些页到每个进程的虚拟内存上。不再会用到的页也许会从内存中移除,尽管相关的进程还在运行。当进程需要一个没有被映射或没在内存中页时,故障便会产生。所以,这个“故障fault”并不意味着“错误error”而是“不可用unavailables”,并且故障在内存管理中扮演者一个重要的角色。 + +次要故障意味着在内存中的页未分配给请求的进程,或未在内存管理单元中标记为出现。主要故障意味着页没有保留在内存中。 + +如果你想切身感受一下次要页故障和主要页故障出现的频率,像这样试一下 `ps` 命令。注意我们要的是与页故障和产生它的命令相关的项。输出中省略了很多行。`MINFL` 显示出次要故障的数目,而 `MAJFL` 表示了主要故障的数目。 + +``` +$ ps -eo min_flt,maj_flt,cmd + MINFL MAJFL CMD +230760 150 /usr/lib/systemd/systemd --switched-root --system --deserialize 18 + 0 0 [kthreadd] + 0 0 [rcu_gp] + 0 0 [rcu_par_gp] + 0 0 [kworker/0:0H-kblockd] + ... + 166 20 gpg-agent --homedir /var/lib/fwupd/gnupg --use-standard-socket --daemon + 525 1 /usr/libexec/gvfsd-trash --spawner :1.16 /org/gtk/gvfs/exec_spaw/0 + 4966 4 /usr/libexec/gnome-terminal-server + 3617 0 bash + 0 0 [kworker/1:0H-kblockd] + 927 0 gdm-session-worker [pam/gdm-password] +``` + +汇报单一进程,你可以尝试这样的命令(LCTT 译注:参数里面的 `1` 是要查看的进程的 PID): + +``` +$ ps -o min_flt,maj_flt 1 + MINFL MAJFL +230064 150 +``` + +你也可以添加其他的显示字段,例如进程所有者的 UID 和 GID。 + +``` +$ ps -o min_flt,maj_flt,cmd,args,uid,gid 1 + MINFL MAJFL CMD COMMAND UID GID +230064 150 /usr/lib/systemd/systemd -- /usr/lib/systemd/systemd -- 0 0 +``` + +### 多少才算满? + +一种较好的方法来掌握内存究竟使用了多少是用 `free -m` 命令。`-m` 选项指定了数字的单位是 MiBmebibyte 而不是字节。 + +``` +$ free -m + total used free shared buff/cache available +Mem: 3244 3069 35 49 140 667 +Swap: 3535 0 3535 +``` + +注意 `free`(未使用)的内存可能会不足,而 `available`(可用于启动新的应用)会显示更大的数量。这两者的区别值得我们去关注。可用available意味着它可以在需要时恢复使用,而空闲free意味着现在就能够使用。 + +### 什么时候要担心 + +如果 Linux 系统上的性能表现良好 —— 应用程序响应度高,命令行没有显示出问题 —— 很可能系统状况良好。记住,一些应用也许会出于某种原因而变慢,但它不影响整个系统。 + +过多的硬故障也许表明确实存在问题,但要将其与观察到的性能相比较。 + +一个好的方法是当可用内存接近 0 或者“用作交换swap used”项显著增长或波动时开始担心。如果“可用”项占总内存可用量的百分比合理,那么就无需担心,就像下面的例子那样: + +``` +$ free -m + total used free shared buff/cache available +Mem: 3244 3069 35 49 140 667 +Swap: 3535 0 3535 +``` + +### Linux 性能很复杂 + +抛开这些不说,Linux 系统上的内存可能会变满,并且性能可能会降低。当系统出现问题时不要仅将单一的内存使用报告作为指标。 + +Linux 系统的内存管理很复杂,因为它采取的措施需要确保系统资源得到最好的利用。不要受到一开始内存占满的欺骗,使你认为系统存在问题,但实际上并没有。 + + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3394603/when-to-be-concerned-about-memory-levels-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[LuuMing](https://github.com/LuuMing) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/05/full-swimming-pool-100796221-large.jpg +[2]: https://www.networkworld.com/article/3391029/must-know-linux-commands.html +[3]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/201907/20190518 Best Linux Distributions for Beginners.md b/published/201907/20190518 Best Linux Distributions for Beginners.md new file mode 100644 index 0000000000..e4d374a273 --- /dev/null +++ b/published/201907/20190518 Best Linux Distributions for Beginners.md @@ -0,0 +1,196 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11145-1.html) +[#]: subject: (Best Linux Distributions for Beginners) +[#]: via: (https://itsfoss.com/best-linux-beginners/) +[#]: author: (Aquil Roshan https://itsfoss.com/author/aquil/) + +最适合于初学者的 Linux 发行版 +====== + +> 在本文中,我们将看到**最适合于初学者的 Linux 发行版**。这将有助于 Linux 新用户选择他们的第一个发行版。 + +让我们面对现实,[Linux][1] 可能会给新用户带来巨大的复杂性。但是,带来这种复杂性的并不是 Linux 本身。相反,是“新奇”因素导致了这种情况。并不是怀旧,但我记得第一次使用 Linux 时,我甚至不知道会发生什么。我喜欢它,但最初这对我来说像是逆流游泳一样。 + +不知道从何处着手可能是一个令人沮丧的原因,特别是对于那些在 PC 上运行 Windows 之外的其它系统没有概念的人来说。 + +Linux 不仅仅是一个操作系统,而是一个理念:在这里大家共同成长,也适合于每个人的不同需要。我们已经介绍过: + +* [Windows 用户的最佳 Linux 发行版][2] +* [最佳轻量级 Linux 发行版][3] +* [黑客攻击的最佳 Linux 发行版][4] +* [最佳 Linux 游戏发行版][5] +* [隐私和匿名的最佳 Linux 发行版][6] +* [看起来像 MacOS 的最佳 Linux 发行版][7] + +除此之外,还有一些能够特别满足新人需求的发行版。这里有一些这样的适合初学者的 Linux 发行版。你也可以在视频中观看并[订阅我们的 YouTube 频道][8]以获取更多与 Linux 相关的视频。 + +[视频](https://youtu.be/QC2B2-gCbbI) + +### 最适合于初学者的 Linux 发行版 + +请记住,此列表没有特别的顺序。编制此列表的主要标准是易于安装、开箱即用的硬件和软件、易用性和软件包的可用性。 + +#### 1、Ubuntu + +如果你在互联网上研究过 Linux,那么你很可能遇到过 Ubuntu。Ubuntu 是领先的 Linux 发行版之一,它也是开始 Linux 之旅的完美之选。 + +![][9] + +Ubuntu 被视为人性化的 Linux,这是因为 Ubuntu 在通用可用性上付出了很多努力。Ubuntu 并不要求你在技术方面懂得很多才能使用它。它打破了 “Linux = 命令行麻烦”这一概念。这是 Ubuntu 飙升到今天的主要优势之一。 + +Ubuntu 提供了非常方便的安装程序。这个安装程序以简单的英语(或你想要的任何主要语言)描述安装过程。你甚至可以在实际执行安装过程之前尝试使用 Ubuntu。安装程序提供了简单的选项: + +* 删除旧操作系统以安装 Ubuntu。 +* 与 Windows 或任何其他现有操作系统[一起][10]安装 Ubuntu(每次启动时都会提供要启动的操作系统的选择列表)。 +* 让高级用户自行配置分区。 + +*初学者提示:如果你不确定该怎么做,请选择第二个选项。* + +Ubuntu 的用户界面采用 GNOME。它简单、高效。你可以通过按 Windows 键搜索从应用程序到文件的任何内容。有什么比这更简单的吗? + +没有驱动程序安装问题,因为 Ubuntu 附带硬件检测器,可以检测、下载和安装适用于你的 PC 的最佳驱动程序。此外,安装会附带所有基本软件,如音乐播放器、视频播放器、办公套件和一些消磨时间的游戏。 + +Ubuntu 拥有出色的文档和社区支持。[Ubuntu 论坛][11]和 [Ask Ubuntu][12] 几乎在 Ubuntu 的所有方面都提供了可观的高质量支持。你的一些问题很有可能已经得到了回答,这些答案是适合初学者的。 + +请在[官方网站][13]查看并下载 [Ubuntu][13]。 + +#### 2、Linux Mint Cinnamon + +多年来,Linux Mint 一直是 [Distrowatch][14] 上的**排名第一的** Linux 发行版。我必须说,这是当之无愧的宝座。Linux Mint 是我个人的最爱之一。它优雅、秀气,提供了卓越的计算体验(开箱即用)。 + +![][15] + +Linux Mint 带有 Cinnamon 桌面环境。仍处于熟悉 Linux 软件阶段的 Linux 新用户会发现 Cinnamon 非常有用。所有软件都按类别分组,非常易于访问。虽然这不是一个令人兴奋的功能,但对于不了解 Linux 软件名称的新用户来说,这是一个巨大的好处。 + +Linux Mint 很快,在旧电脑上也运行良好。Linux Mint 建立在坚如磐石的 Ubuntu 基础之上。它使用与 Ubuntu 相同的软件存储库。而对于 Ubuntu 软件存储库,仅在广泛测试后 Ubuntu 才会将软件推送在其中。这意味着用户不必处理某些新软件容易出现的意外崩溃和故障,对于新的 Linux 用户来说这可能是一个真正不可接受的。 + +![][17] + +Windows 7 爱好者如果没有真的升级到微软 Windows 10 的话,那将会发现 Linux Mint 的可爱。 Linux Mint 桌面非常类似于 Windows 7 桌面。类似的工具栏、类似的菜单、类似的托盘图标都绝对会使 Windows 用户感到十分熟悉。 + +就个人而言,我更倾向于向 Linux 世界的新人推荐 Linux Mint,因为 Linux Mint 确实给用户留下了足够的印象,会让他们接受它。对我来说,Linux Mint 应该是面向初学者的 Linux 列表中的首位。 + +请在这里查看 [Linux Mint][18],看看 Cinnamon 版。 + +#### 3、Zorin OS + +大多数计算机用户是 Windows 用户。当 [Windows 用户拿到一个 Linux][2] 时,他必须经历相当多的“去知识过程”。大量的操作已经固定在我们的肌肉记忆当中。例如,每次要启动应用程序时,鼠标都会移动屏幕的左下角(“开始”菜单)。因此,如果我们能够在 Linux 上找到一些可以缓解这些问题的东西,那就成功了一半了。进入 Zorin OS。 + +![][19] + +Zorin OS 是一款基于 Ubuntu 的高度打磨的 Linux 发行版,完全是为 Windows 难民制作的。尽管几乎每个 Linux 发行版都可供任何人使用,但是当桌面看起来太陌生时,有些人可能会不情愿使用。Zorin OS 避开了这个障碍,因为它与 Windows 外观明显相似。 + +对 Linux 新手来说,软件包管理器是一个新概念。这就是为什么 Zorin OS 带有一个巨大的(我的意思是真的很大)预安装软件列表。你需要的任何东西,很有可能都已经安装在 Zorin OS 上了。好像这还不够,[Wine 和 PlayOnLinux][20] 也预先安装好了,所以你也可以在这里运行你喜爱的 Windows 软件和[游戏][21]。 + +![][22] + +Zorin OS 配备了一款名为 “Zorin look changer” 的惊人的主题引擎。它提供了一些重要的自定义选项和预设,可以使你的操作系统看起来像 Windows 7、XP、2000 甚至是 Mac,你会有宾至如归的感觉。 + +![][23] + +正是这些功能使 Zorin OS 成为**适合初学者的最佳 Linux 发行版**。查看 [Zorin OS 网站][24]以了解更多信息和下载该操作系统。 + +#### 4、Elementary OS + +我们已经看过了给 Windows 用户准备的 Linux 发行版,让我们为 MacOS 用户也提供一些东西。Elementary OS 成名非常迅速,现在总是被列入顶级发行列表之中,这一切都归功于其美学本质。其灵感来自于 MacOS,Elementary OS 是最美丽的 Linux 发行版之一。 + +![][25] + +Elementary OS 是又一个基于 Ubuntu 的操作系统,这意味着操作系统本身无疑是稳定的。Elementary OS 带有 Pantheon 桌面环境。你马上就会注意到它与 MacOS 桌面的相似之处。这对于转换到 Linux 的 MacOS 用户来说是一个优势,因为他们会对桌面非常适应,这确实简化了应对此变化的过程。 + +![][26] + +它的菜单简单,可根据用户喜好自定义。该操作系统是零侵入性的,因此你可以真正专注于工作。它附带了非常少量的预安装软件。因此,新用户都不会被庞杂的内容吓跑。但是,嘿,它具备开箱即用所需要的一切。如果需要更多软件,Elementary OS 提供了一个整洁的 AppCenter。它易于访问且简单易用,一切都在一个地方,你可以一键获得所需的所有软件和升级。 + +经验表明,[Elementary OS][28] 真的是一个很棒的软件。绝对值得[试一试][28]。 + +#### 5、Linux Mint Mate + +许多来了解 Linux 的人都希望让旧电脑焕发新生。随着 Windows 10 的普及,几年前许多具有不错配置的计算机已经变得无力应对。在谷歌上快速搜索一下会建议你在这样的电脑上安装 Linux。通过这种方式,你可以让它们在之后一段时间仍旧能保持水准。如果你正在寻找可以运行在旧计算机上的操作系统,Linux Mint Mate 是一个很棒的 Linux 发行版。 + +![][29] + +Linux Mint Mate 非常轻便,资源利用效率高,而仍然是一个漂亮的发行版。它可以在计算能力较弱的计算机上平稳运行。桌面环境没有各种花哨的东西。但它在功能上和任何其他桌面环境相比毫不逊色。这个操作系统是非侵入式的,允许你获得高效的计算体验而不会妨碍你。 + +同样,Linux Mint Mate 基于 Ubuntu,具有巨大而坚实的 Ubuntu 软件存储库的优势。它预装了最少数量的必需软件。提供了简便的驱动程序安装和设置管理。 + +即使你只有 512 MB 的内存和 9 GB 的硬盘空间(当然是越多越好),你也可以运行 Linux Mint Mate。 + +Mate 桌面环境非常简单易用,没有什么费解的地方。对于 Linux 初学者来说,这确实是一个巨大的优势,更有理由 [尝试 Linux Mint Mate][30]。 + +#### 6、Manjaro Linux + +好吧。任何一个 Linux 的老用户都会说,即使只是在大方向上,引导新手接触 Arch Linux 都是一种罪过。但是听我说。 + +Arch 被认为是专家级 Linux,因为它的安装过程非常复杂。Manajro 和 Arch Linux 有着共同的起源,但它们在其他方面存在很大差异。 + +![][31] + +Manajro Linux 具有非常适合初学者的安装程序。许多事情都是自动化的,比如使用“硬件检测”进行驱动程序安装。Manjaro 极大地解决了困扰许多其它 Linux 发行版的硬件驱动程序的麻烦。即使你遇到任何问题,Manjaro 也有很棒的社区支持。 + +Manjaro 拥有自己的软件存储库,其维护了最新的软件。虽然优先向用户提供最新软件,但它是以保证稳定性不会受到损害为前提的。这是 Arch 和 Manjaro 之间的主要区别之一。Manjaro 延迟软件包的发布以确保它们绝对稳定并且不会导致回退。你还可以访问 Manjaro 上的 Arch User Repository(AUR),因此你可以随时获得所需的一切。 + +如果你想了解更多有关 Manjaro 功能的信息,请阅读我的同事 [John 的 Manjaro Linux 经历以及为什么他会被它迷住][32]。 + +![][33] + +Manjaro Linux 有 XFCE、KDE、Gnome、Cinnamon 以及更多桌面环境,请查看[官方网站][34]。 + +要安装上述 6 个操作系统中的任何一个,你需要创建一个可启动的 U 盘。如果你当前正在使用 Windows [请使用本指南][35]。Mac OS 用户可以[遵循本指南][36]。 + +### 你选择哪个最适合初学者的 Linux 发行版? + +Linux 可能会有学习曲线,但这是一件不会让每个人都感到后悔的事情。进一步获得一个 ISO 文件并体验一下 Linux 吧。如果你已经是 Linux 用户,请分享这篇文章,并帮助人们在这个爱的季节爱上 Linux 吧。加油! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/best-linux-beginners/ + +作者:[Aquil Roshan][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/aquil/ +[b]: https://github.com/lujun9972 +[1]: https://www.linux.com/what-is-linux +[2]: https://itsfoss.com/windows-like-linux-distributions/ +[3]: https://itsfoss.com/lightweight-linux-beginners/ +[4]: https://itsfoss.com/linux-hacking-penetration-testing/ +[5]: https://itsfoss.com/linux-gaming-distributions/ +[6]: https://itsfoss.com/privacy-focused-linux-distributions/ +[7]: https://itsfoss.com/macos-like-linux-distros/ +[8]: https://www.youtube.com/c/itsfoss +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/06/ubuntu-18-04-desktop.jpeg?resize=800%2C450&ssl=1 +[10]: https://itsfoss.com/install-ubuntu-1404-dual-boot-mode-windows-8-81-uefi/ +[11]: https://ubuntuforums.org/ +[12]: http://askubuntu.com/ +[13]: https://www.ubuntu.com/ +[14]: https://distrowatch.com/ +[15]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2017/02/LM_Home.jpg?ssl=1 +[16]: https://itsfoss.com/install-visual-studio-code-ubuntu/ +[17]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2017/02/LM_SS.jpg?ssl=1 +[18]: https://linuxmint.com/ +[19]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2017/02/Zorin.jpg?ssl=1 +[20]: https://itsfoss.com/use-windows-applications-linux/ +[21]: https://itsfoss.com/linux-gaming-guide/ +[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2017/02/Zorin-office.jpg?ssl=1 +[23]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2017/02/OSX.jpg?ssl=1 +[24]: https://zorinos.com/ +[25]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2017/02/Pantheon-Desktop.jpg?resize=800%2C500&ssl=1 +[26]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2017/02/Application-Menu.jpg?ssl=1 +[27]: https://itsfoss.com/slack-use-linux/ +[28]: https://elementary.io/ +[29]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2017/02/mate.jpg?ssl=1 +[30]: http://blog.linuxmint.com/?p=3182 +[31]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2017/02/manajro.jpg?ssl=1 +[32]: https://itsfoss.com/why-use-manjaro-linux/ +[33]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2017/02/manjaro-kde.jpg?ssl=1 +[34]: https://manjaro.org/ +[35]: https://www.ubuntu.com/download/desktop/create-a-usb-stick-on-windows +[36]: https://www.ubuntu.com/download/desktop/create-a-usb-stick-on-macos diff --git a/published/201907/20190522 Convert Markdown files to word processor docs using pandoc.md b/published/201907/20190522 Convert Markdown files to word processor docs using pandoc.md new file mode 100644 index 0000000000..381510d7a7 --- /dev/null +++ b/published/201907/20190522 Convert Markdown files to word processor docs using pandoc.md @@ -0,0 +1,129 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11160-1.html) +[#]: subject: (Convert Markdown files to word processor docs using pandoc) +[#]: via: (https://opensource.com/article/19/5/convert-markdown-to-word-pandoc) +[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt/users/jason-van-gumster/users/kikofernandez) + +使用 pandoc 将 Markdown 转换为格式化文档 +====== + +> 生活在普通文本世界么?以下是无需使用文字处理器而创建别人要的格式化文档的方法。 + +![][1] + +如果你生活在[普通文本][2]世界里,总会有人要求你提供格式化文档。我就经常遇到这个问题,特别是在 Day JobTM。虽然我已经给与我合作的开发团队之一介绍了用于撰写和审阅发行说明的 [Docs Like Code][3] 工作流程,但是还有少数人对 GitHub 和使用 [Markdown][4] 没有兴趣,他们更喜欢为特定的专有应用格式化的文档。 + +好消息是,你不会被卡在将未格式化的文本复制粘贴到文字处理器的问题当中。使用 [pandoc][5],你可以快速地给人们他们想要的东西。让我们看看如何使用 pandoc 将文档从 Markdown 转换为 Linux 中的文字处理器格式。 + +请注意,pandoc 也可用于从两种 BSD([NetBSD][7] 和 [FreeBSD][8])到 Chrome OS、MacOS 和 Windows 等的各种操作系统。 + +### 基本转换 + +首先,在你的计算机上[安装 pandoc][9]。然后,打开控制台终端窗口,并导航到包含要转换的文件的目录。 + +输入此命令以创建 ODT 文件(可以使用 [LibreOffice Writer][10] 或 [AbiWord][11] 等字处理器打开): + +``` +pandoc -t odt filename.md -o filename.odt +``` + +记得用实际文件名称替换 `filename`。如果你需要为其他文字处理器(你知道我的意思)创建一个文件,替换命令行的 `odt` 为 `docx`。以下是本文转换为 ODT 文件时的内容: + +![Basic conversion results with pandoc.][12] + +这些转换结果虽然可用,但有点乏味。让我们看看如何为转换后的文档添加更多样式。 + +### 带样式转换 + +`pandoc` 有一个漂亮的功能,使你可以在将带标记的纯文本文件转换为字处理器格式时指定样式模板。在此文件中,你可以编辑文档中的少量样式,包括控制段落、文章标题和副标题、段落标题、说明、基本的表格和超链接的样式。 + +让我们来看看能做什么。 + +#### 创建模板 + +要设置文档样式,你不能只是使用任何一个模板就行。你需要生成 pandoc 称之为引用模板的文件,这是将文本文件转换为文字处理器文档时使用的模板。要创建此文件,请在终端窗口中键入以下内容: + +``` +pandoc -o custom-reference.odt --print-default-data-file reference.odt +``` + +此命令创建一个名为 `custom-reference.odt` 的文件。如果你正在使用其他文字处理程序,请将命令行中的 “odt” 更改为 “docx”。 + +在 LibreOffice Writer 中打开模板文件,然后按 `F11` 打开 LibreOffice Writer 的 “样式” 窗格。虽然 [pandoc 手册][13]建议不要对该文件进行其他更改,但我会在必要时更改页面大小并添加页眉和页脚。 + +#### 使用模板 + +那么,你要如何使用刚刚创建的模板?有两种方法可以做到这一点。 + +最简单的方法是将模板放在家目录的 `.pandoc` 文件夹中,如果该文件夹不存在,则必须先创建该文件夹。当转换文档时,`pandoc` 会使用此模板文件。如果你需要多个模板,请参阅下一节了解如何从多个模板中进行选择。 + +使用模板的另一种方法是在命令行键入以下转换选项: + +``` +pandoc -t odt file-name.md --reference-doc=path-to-your-file/reference.odt -o file-name.odt +``` + +如果你想知道使用自定义模板转换后的文件是什么样的,这是一个示例: + +![A document converted using a pandoc style template.][14] + +#### 选择模板 + +很多人只需要一个 `pandoc` 模板,但是,有些人需要不止一个。 + +例如,在我的日常工作中,我使用了几个模板:一个带有 DRAFT 水印,一个带有表示内部使用的水印,另一个用于文档的最终版本。每种类型的文档都需要不同的模板。 + +如果你有类似的需求,可以像使用单个模板一样创建文件 `custom-reference.odt`,将生成的文件重命名为例如 `custom-reference-draft.odt` 这样的名字,然后在 LibreOffice Writer 中打开它并修改样式。对你需要的每个模板重复此过程。 + +接下来,将文件复制到家目录中。如果你愿意,你甚至可以将它们放在 `.pandoc` 文件夹中。 + +要在转换时选择特定模板,你需要在终端中运行此命令: + +``` +pandoc -t odt file-name.md --reference-doc=path-to-your-file/custom-template.odt -o file-name.odt +``` + +改变 `custom-template.odt` 为你的模板文件名。 + +### 结语 + +为了不用记住我不经常使用的一组选项,我拼凑了一些简单的、非常蹩脚的单行脚本,这些脚本封装了每个模板的选项。例如,我运行脚本 `todraft.sh` 以使用带有 DRAFT 水印的模板创建文字处理器文档。你可能也想要这样做。 + +以下是使用包含 DRAFT 水印的模板的脚本示例: + +``` +pandoc -t odt $1.md -o $1.odt --reference-doc=~/Documents/pandoc-templates/custom-reference-draft.odt +``` + +使用 pandoc 是一种不必放弃命令行生活而以人们要求的格式提供文档的好方法。此工具也不仅适用于 Markdown。我在本文中讨论的内容还可以让你在各种标记语言之间创建和转换文档。有关更多详细信息,请参阅前面链接的 [pandoc 官网][5]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/convert-markdown-to-word-pandoc + +作者:[Scott Nesbitt][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/scottnesbitt/users/jason-van-gumster/users/kikofernandez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb +[2]: https://plaintextproject.online/ +[3]: https://www.docslikecode.com/ +[4]: https://en.wikipedia.org/wiki/Markdown +[5]: https://pandoc.org/ +[6]: /resources/linux +[7]: https://www.netbsd.org/ +[8]: https://www.freebsd.org/ +[9]: https://pandoc.org/installing.html +[10]: https://www.libreoffice.org/discover/writer/ +[11]: https://www.abisource.com/ +[12]: https://opensource.com/sites/default/files/uploads/pandoc-wp-basic-conversion_600_0.png (Basic conversion results with pandoc.) +[13]: https://pandoc.org/MANUAL.html +[14]: https://opensource.com/sites/default/files/uploads/pandoc-wp-conversion-with-tpl_600.png (A document converted using a pandoc style template.) diff --git a/published/201907/20190531 Use Firefox Send with ffsend in Fedora.md b/published/201907/20190531 Use Firefox Send with ffsend in Fedora.md new file mode 100644 index 0000000000..e5c11d0d8d --- /dev/null +++ b/published/201907/20190531 Use Firefox Send with ffsend in Fedora.md @@ -0,0 +1,125 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11042-1.html) +[#]: subject: (Use Firefox Send with ffsend in Fedora) +[#]: via: (https://fedoramagazine.org/use-firefox-send-with-ffsend-in-fedora/) +[#]: author: (Sylvia Sánchez https://fedoramagazine.org/author/lailah/) + +在 Fedora 中利用 ffsend 使用 Firefox Send +====== + +![][1] + +`ffsend` 是 Firefox Send 的命令行客户端。本文将展示 Firefox Send 和 `ffsend` 如何工作。还会详细介绍如何在 Fedora 中安装和使用它。 + +### 什么是 Firefox Send 和 ffsend? + +Firefox Send 是 Mozilla 的一个文件共享工具,它能将加密文件发送给其他用户。你可以在自己的服务器上安装 Send,也可以使用 Mozilla 托管的链接 [send.firefox.com][2]。它最大支持 1GB 的文件,链接会在可配置的下载次数(默认值为 1)或 24 小时后过期,然后会删除发送服务器上的所有文件。此工具仍*处于实验阶段*,因此不应在生产中使用或共享重要或敏感数据。 + +虽然 Firefox Send 本身就是工具,并且可以在 Web 中使用,但 `ffsend` 是一个可以与脚本和参数一起使用的命令行程序。它有多种配置选项,并且可以在后台工作而无需任何人为干预。 + +### 它如何工作? + +`ffsend` 可以上传和下载文件。远程主机可以使用 Firefox 工具或其他 Web 浏览器来下载文件。 Firefox Send 和 `ffsend` 都不需要使用 Firefox。 + +值得一提 `ffsend` 使用了客户端加密。这意味着文件在上传*前*被加密。链接中就有密钥,因此在共享时要小心,因为任何有链接的人都可以下载该文件。作为额外的保护,你可以使用以下参数使用密码保护文件: + +``` +ffsend password URL -p PASSWORD +``` + +### 其他功能 + +还有一些值得一提的其他功能: + +* 链接到期前可配置的下载限制,范围从 1 到 20 次之间 +* 内置解压和归档功能 +* 跟踪共享文件的历史记录 +* 检查或删除共享文件 +* 文件夹也可以按原样共享,也可以作为压缩文件共享 +* 生成 QR 码,便于在手机上下载 + +### 如何在 Fedora 中安装 + +虽然 Fedora Send 可以在 Firefox 中使用而无需安装其他,但你需要安装 CLI 工具才能使用 `ffsend`。此工具在官方仓库中,因此你只需使用 `dnf` 命令,并使用 [sudo][3]。 + +``` +$ sudo dnf install ffsend +``` + +之后,你可以在终端使用 `ffsend`。 + + +### 上传文件 + +上传文件很简单。 + +``` +$ ffsend upload /etc/os-release +Upload complete +Share link: https://send.firefox.com/download/05826227d70b9a4b/#RM_HSBq6kuyeBem8Z013mg +``` + +现在可以使用 “Share link” URL 轻松共享该文件。 + +### 下载文件 + +下载文件和上传一样简单。 + +``` +$ ffsend download https://send.firefox.com/download/05826227d70b9a4b/#RM_HSBq6kuyeBem8Z013mg +Download complete +``` + +在下载之前,检查文件是否存在并获取有关它的信息会有用。`ffsend` 为此提供了 2 个方便的命令。 + +``` +$ ffsend exists https://send.firefox.com/download/88a6324e2a99ebb6/#YRJDh8ZDQsnZL2KZIA-PaQ +Exists: true +Password: false +$ ffsend info https://send.firefox.com/download/88a6324e2a99ebb6/#YRJDh8ZDQsnZL2KZIA-PaQ +ID: 88a6324e2a99ebb6 +Downloads: 0 of 1 +Expiry: 23h59m (86388s +``` + +### 上传历史 + +`ffsend` 还提供了一种查看使用工具上传的历史记录的方法。例如,如果你用脚本上传了大量文件并且想要跟踪每个文件的下载状态,那么这非常有用。 + +``` +$ ffsend history +LINK EXPIRY + 1 https://send.firefox.com/download/#8TJ9QNw 23h59m + 2 https://send.firefox.com/download/KZIA-PaQ 23h54m +``` + +### 删除文件 + +另一个有用的功能是删除文件。 + +``` +ffsend delete https://send.firefox.com/download/2d9faa7f34bb1478/#phITKvaYBjCGSRI8TJ9QNw +``` + +Firefox Send 是一项很棒的服务,`ffsend` 使得它在终端使用起来非常方便。[Gitlab 仓库][4]中有关于 `ffsend` 的更多示例和文档。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/use-firefox-send-with-ffsend-in-fedora/ + +作者:[Sylvia Sánchez][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/lailah/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/04/firefox-send-816x345.png +[2]: http://send.firefox.com/ +[3]: https://fedoramagazine.org/howto-use-sudo/ +[4]: https://gitlab.com/timvisee/ffsend diff --git a/published/201907/20190603 How to set up virtual environments for Python on MacOS.md b/published/201907/20190603 How to set up virtual environments for Python on MacOS.md new file mode 100644 index 0000000000..b86600953b --- /dev/null +++ b/published/201907/20190603 How to set up virtual environments for Python on MacOS.md @@ -0,0 +1,202 @@ +[#]: collector: (lujun9972) +[#]: translator: (runningwater) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11086-1.html) +[#]: subject: (How to set up virtual environments for Python on MacOS) +[#]: via: (https://opensource.com/article/19/6/virtual-environments-python-macos) +[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberg/users/moshez/users/mbbroberg/users/moshez) + +MacOS 系统中如何设置 Python 虚拟环境 +====== + +> 使用 pyenv 和 virtualwrapper 来管理你的虚拟环境,可以避免很多困惑。 + +![][1] + +作为 Python 开发者和 MacOS 用户,拿到新机器首先要做的就是设置 Python 开发环境。下面是最佳实践(虽然我们已经写过 [在 MacOS 上管理 Python 的其它方法][2])。 + +### 预备 + +首先,打开终端,在其冰冷毫无提示的窗口输入 `xcode-select --install` 命令。点击确认后,基本的开发环境就会被配置上。MacOS 上需要此步骤来设置本地开发实用工具库,根据 [OS X Daily][3] 的说法,其包括 ”许多常用的工具、实用程序和编译器,如 make、GCC、clang、perl、svn、git、size、strip、strings、libtool、cpp、what 及许多在 Linux 中系统默认安装的有用命令“。 + +接下来,安装 [Homebrew][4], 执行如下的 Ruby 脚本。 + +``` +ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +``` + +如果你像我一样,对随意就运行的来源于互联网的脚本心存疑虑的话,可以点击上面的脚本去仔细看看其具体功能。 + +一旦安装完成后,就恭喜了,你拥有了一个优秀的包管理工具。自然的,你可能接下来会执行 `brew install python` 或其他的命令。不要这样,哈哈!Homebrew 是为我们提供了一个 Python 的管理版本,但让此工具来管理我们的 Python 环境话,很快会失控的。我们需要 [pyenv][5],一款简单的 Python 版本管理工具,它可以安装运行在 [许多操作系统][6] 上。运行如下命令: + +``` +$ brew install pyenv +``` + +想要每次打开命令提示框时 `pyenv` 都会运行的话,需要把下面的内容加入你的配置文件中(MacOS 中默认为 `.bash_profile`,位于家目录下): + +``` +$ cd ~/ +$ echo 'eval "$(pyenv init -)"' >> .bash_profile +``` + +添加此行内容后,每个终端都会启动 `pyenv` 来管理其 `PATH` 环境变量,并插入你想要运行的 Python 版本(而不是在环境变量里面设置的初始版本。更详细的信息,请阅读 “[如何给 Linux 系统设置 PATH 变量][7]”)。打开新的终端以使修改的 `.bash_profile` 文件生效。 + +在安装你中意的 Python 版本前,需要先安装一些有用的工具,如下示: + +``` +$ brew install zlib sqlite +``` + +`pyenv` 依赖于 [zlib][8] 压缩算法和 [SQLite][9] 数据库,如果未正确配置,往往会[导致构建问题][10]。将这些导出配置命令加入当前的终端窗口执行,确保它们安装完成。 + +``` +$ export LDFLAGS="-L/usr/local/opt/zlib/lib -L/usr/local/opt/sqlite/lib" +$ export CPPFLAGS="-I/usr/local/opt/zlib/include -I/usr/local/opt/sqlite/include" +``` + +现在准备工作已经完成,是时候安装一个适合于现代人的 Python 版本了: + +``` +$ pyenv install 3.7.3 +``` + +去喝杯咖啡吧,挑些豆类,亲自烧烤,然后品尝。说这些的意思是上面的安装过程需要一段时间。 + +### 添加虚拟环境 + +一旦完成,就可以愉快地使用虚拟环境了。如没有接下来的步骤的话,你只能在你所有的工作项目中共享同一个 Python 开发环境。使用虚拟环境来隔离每个项目的依赖关系的管理方式,比起 Python 自身提供的开箱即用功能来说,更加清晰明确和更具有重用性。基于这些原因,把 `virtualenvwrapper` 安装到 Python 环境中吧: + +``` +$ pyenv global 3.7.3 +# Be sure to keep the $() syntax in this command so it can evaluate +$ $(pyenv which python3) -m pip install virtualenvwrapper +``` + +再次打开 `.bash_profile` 文件,把下面内容添加进去,使得每次打开新终端时它都有效: + +``` +# We want to regularly go to our virtual environment directory +$ echo 'export WORKON_HOME=~/.virtualenvs' >> .bash_profile +# If in a given virtual environment, make a virtual environment directory +# If one does not already exist +$ echo 'mkdir -p $WORKON_HOME' >> .bash_profile +# Activate the new virtual environment by calling this script +# Note that $USER will substitute for your current user +$ echo '. ~/.pyenv/versions/3.7.3/bin/virtualenvwrapper.sh' >> .bash_profile +``` + +关掉终端再重新打开(或者运行 `exec /bin/bash -l` 来刷新当前的终端会话),你会看到 `virtualenvwrapper` 正在初始化环境配置: + +``` +$ exec /bin/bash -l +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/premkproject +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/postmkproject +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/initialize +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/premkvirtualenv +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/postmkvirtualenv +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/prermvirtualenv +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/postrmvirtualenv +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/predeactivate +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/postdeactivate +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/preactivate +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/postactivate +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/get_env_details +``` + +从此刻开始,你的所有工作都是在虚拟环境中的,其允许你使用临时环境来安全地开发。使用此工具链,你可以根据工作所需,设置多个项目并在它们之间切换: + +``` +$ mkvirtualenv test1 +Using base prefix '/Users/moshe/.pyenv/versions/3.7.3' +New python executable in /Users/moshe/.virtualenvs/test1/bin/python3 +Also creating executable in /Users/moshe/.virtualenvs/test1/bin/python +Installing setuptools, pip, wheel... +done. +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/test1/bin/predeactivate +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/test1/bin/postdeactivate +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/test1/bin/preactivate +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/test1/bin/postactivate +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/test1/bin/get_env_details +(test1)$ mkvirtualenv test2 +Using base prefix '/Users/moshe/.pyenv/versions/3.7.3' +New python executable in /Users/moshe/.virtualenvs/test2/bin/python3 +Also creating executable in /Users/moshe/.virtualenvs/test2/bin/python +Installing setuptools, pip, wheel... +done. +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/test2/bin/predeactivate +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/test2/bin/postdeactivate +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/test2/bin/preactivate +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/test2/bin/postactivate +virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/test2/bin/get_env_details +(test2)$ ls $WORKON_HOME +get_env_details postmkvirtualenv premkvirtualenv +initialize postrmvirtualenv prermvirtualenv +postactivate preactivate test1 +postdeactivate predeactivate test2 +postmkproject premkproject +(test2)$ workon test1 +(test1)$ +``` + +此处,使用 `deactivate` 命令可以退出当前环境。 + +### 推荐实践 + +你可能已经在比如 `~/src` 这样的目录中添加了长期的项目。当要开始了一个新项目时,进入此目录,为此项目增加子文件夹,然后使用强大的 Bash 解释程序自动根据你的目录名来命令虚拟环境。例如,名称为 “pyfun” 的项目: + +``` +$ mkdir -p ~/src/pyfun && cd ~/src/pyfun +$ mkvirtualenv $(basename $(pwd)) +# we will see the environment initialize +(pyfun)$ workon +pyfun +test1 +test2 +(pyfun)$ deactivate +$ +``` + +当需要处理此项目时,只要进入该目录,输入如下命令重新连接虚拟环境: + +``` +$ cd ~/src/pyfun +(pyfun)$ workon . +``` + +初始化虚拟环境意味着对 Python 版本和所加载的模块的时间点的拷贝。由于依赖关系会发生很大的改变,所以偶尔需要刷新项目的虚拟环境。这种情况,你可以通过删除虚拟环境来安全的执行此操作,源代码是不受影响的,如下所示: + +``` +$ cd ~/src/pyfun +$ rmvirtualenv $(basename $(pwd)) +$ mkvirtualenv $(basename $(pwd)) +``` + +这种使用 `pyenv` 和 `virtualwrapper` 管理虚拟环境的方法可以避免开发环境和运行环境中 Python 版本的不一致出现的苦恼。这是避免混淆的最简单方法 - 尤其是你工作的团队很大的时候。 + +如果你是初学者,正准备配置 Python 环境,可以阅读下 [MacOS 中使用 Python 3][2] 文章。 你们有关于 Python 相关的问题吗,不管是初学者的还是中级使用者的?给我们留下评论信息,我们在下篇文章中会考虑讲解。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/virtual-environments-python-macos + +作者:[Matthew Broberg][a] +选题:[lujun9972][b] +译者:[runningwater](https://github.com/runningwater) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mbbroberg/users/moshez/users/mbbroberg/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python_snake_file_box.jpg?itok=UuDVFLX- +[2]: https://opensource.com/article/19/5/python-3-default-macos +[3]: http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/ +[4]: https://brew.sh/ +[5]: https://github.com/pyenv/pyenv +[6]: https://github.com/pyenv/pyenv/wiki +[7]: https://opensource.com/article/17/6/set-path-linux +[8]: https://zlib.net/ +[9]: https://www.sqlite.org/index.html +[10]: https://github.com/pyenv/pyenv/wiki/common-build-problems#build-failed-error-the-python-zlib-extension-was-not-compiled-missing-the-zlib diff --git a/published/201907/20190604 5G will augment Wi-Fi, not replace it.md b/published/201907/20190604 5G will augment Wi-Fi, not replace it.md new file mode 100644 index 0000000000..1f15466851 --- /dev/null +++ b/published/201907/20190604 5G will augment Wi-Fi, not replace it.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: (GraveAccent) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11098-1.html) +[#]: subject: (5G will augment Wi-Fi, not replace it) +[#]: via: (https://www.networkworld.com/article/3399978/5g-will-augment-wi-fi-not-replace-it.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + + +5G 会增强 Wi-Fi,而不是取代它 +====== +> Aruba 战略和企业发展副总裁 Jeff Lipton 为 5G 炒作增添了一些干货,讨论了它和 Wi-Fi 如何协同工作以及如何最大化两者的价值。 + +![Thinkstock][1] + +如今可以说没有技术主题比 [5G][2] 更热。这是最近 [移动世界大会][3] 节目的一个主题,并且已经在其他活动中占据了主导地位,例如 Enterprise Connect 和我参加的几乎所有供应商活动。 + +一些供应商将 5G 定位为解决所有网络问题的灵丹妙药,并预测它将消除所有其他形式的网络。像这样的观点显然是极端的,但我相信 5G 会对网络行业产生影响,网络工程师应该意识到这一点。 + +为了帮助为 5G 炒作带来一些现实感,我最近采访了一家惠普公司旗下的 Aruba 公司的战略和企业发展副总裁 Jeff Lipton,因为我知道惠普已经深入参与了 5G 和 Wi-Fi 的发展。 + +![Jeff Lipton, VP of strategy and corporate development, Aruba][4] + +### Zeus Kerravala: 5G 被吹捧为“明日之星”。你是这样看的吗? + +**Jeff Lipton:** 接下来的重点是连接“事物”并从这些事物中产生可操作的见解和背景。5G 是服务于这一趋势的技术之一。Wi-Fi 6 是另一个,还有边缘计算、蓝牙低功耗(BLE)、人工智能(AI)和机器学习(ML)。这一切都很重要,全都有自己的用武之地。 + +### 你是否在企业中看到 5G 的风头盖过 Wi-Fi? + +**Lipton:** 与所有蜂窝接入一样,如果你需要宏观区域覆盖macro area coverage和高速切换,使用 5G 是合适的。但对于大多数企业级应用程序而言,它通常不需要这些功能。从性能角度来看,[Wi-Fi 6][5] 和 5G 在大多数指标上大致相等,包括吞吐量、延迟、可靠性和连接密度。它们并不相似的地方在经济方面,Wi-Fi 要好得多。我不认为很多客户愿意用 Wi-Fi 交换 5G,除非他们需要宏观覆盖或高速切换。 + +### Wi-Fi 和 5G 可以共存吗? 企业如何一起使用 5G 和 Wi-Fi? + +**Lipton:** Wi-Fi 和 5G 可以共存并且应该是互补的。5G 架构将蜂窝核心和无线接入网络(RAN)分离。因此,Wi-Fi 可以是企业无线电前端,并与 5G 核心紧密连接。由于 Wi-Fi(特别是 Wi-Fi 6)的经济有利,并且性能非常好,我们设想许多服务提供商会使用 Wi-Fi 作为其 5G 系统的无线电前端,充当其分布式天线(DAS)和小型蜂窝系统的替代方案。 + +> “Wi-Fi 和 5G 可以并且应该是互补的。” — Jeff Lipton + +### 如果一个企业打算完全转向 5G,那将如何实现以及它的实用性如何? + +**Lipton:** 为了将 5G 用于主要的室内访问方式,客户需要升级其网络和几乎所有设备。5G 在室外提供良好的覆盖,但蜂窝信号不能可靠地穿透建筑物,5G 会使这个问题变得更糟,因为它部分依赖于更高频率的无线电。因此,服务提供商需要一种提供室内覆盖的方法。为了提供这种覆盖,他们会部署 DAS 或小型蜂窝系统 —— 由终端客户支付费用。然后,客户将他们的设备直连到这些蜂窝系统,并为每个设备支付服务合同。 + +这种方法存在一些问题。首先,DAS 和小型蜂窝系统比 Wi-Fi 网络贵得多。并且成本不会仅限于网络。每台设备都需要一台 5G 蜂窝调制解调器,批量价格高达数十美元,而终端用户通常需要花费一百多美元。由于目前很少或者没有 MacBook、PC、打印机、AppleTV 有 5G 调制解调器,因此需要对这些设备进行升级。我不相信很多企业会愿意支付这笔额外费用并升级他们的大部分设备以获得尚不明确的好处。 + +### 经济性是 5G 与 Wi-Fi 之争的一个要素吗? + +**Lipton:** 经济性始终是一个要素。让我们将对话集中在室内企业级应用程序上,因为这是一些运营商打算用 5G 定位的用例。我们已经提到升级到 5G 将要求企业部署昂贵的 DAS 或小型蜂窝系统用于室内覆盖,几乎将所有设备升级到包含 5G 调制解调器,并为每个设备支付服务合同。理解 5G 蜂窝网络和 DAS 系统在许可频谱上运行也很重要,这类似于一条私人高速公路。服务提供商为此频谱支付了数十亿美元,这笔费用需要货币化并嵌入服务成本中。因此,从部署和生命周期的角度来看,Wi-Fi 在经济上比 5G 有利。 + +### 5G 与 Wi-Fi 相比有任何安全隐患吗? + +**Lipton:** 一些人认为蜂窝技术比 Wi-Fi 更安全,但事实并非如此。LTE 相对安全,但也有弱点。例如,普渡大学和爱荷华大学的研究人员表示,LTE 容易受到一系列攻击,包括数据拦截和设备跟踪。5G 通过多种认证方法和更好的密钥管理改进了 LTE 安全性。 + +Wi-Fi 的安全性也没有停滞不前而是在继续发展。当然,不遵循最佳实践的 Wi-Fi 实现,例如那些甚至没有基本密码保护的实现,并不是最佳的。但那些配置了适当的访问控制和密码的则是非常安全的。随着新标准 —— 特别是 WPA3 和增强开放Enhanced Open —— Wi-Fi 网络安全性进一步提高。 + +同样重要的是要记住,企业已根据其特定需求对安全性和合规性解决方案进行了大量投资。对于包括 5G 在内的蜂窝网络,企业将失去部署所选安全性和合规性解决方案的能力,以及对流量流的大多数可见性。虽然 5G 的未来版本将通过称为网络切片的功能提供高级别的自定义,但企业仍将失去他们目前需要的和拥有的安全性和合规性定制级别。 + +### 关于 5G 与 Wi-Fi 之间的讨论的补充想法 + +**Lipton:** 围绕 Wi-Fi 与 5G 的争论忽略了这一点。它们都有自己的用武之地,而且它们在很多方面都是互补的。由于需要连接和分析越来越多的东西,Wi-Fi 和 5G 市场都将增长。如果客户需要宏观覆盖或高速切换,并且可以为这些功能支付额外成本,那么 5G 是可行的。 + +5G 也适用于客户需要物理网络分段的某些工业用例。但对于绝大多数企业客户而言,Wi-Fi 将继续像现在一样证明自己作为可靠、安全且经济高效的无线接入技术的价值。 + +**更多关于 802.11ax (Wi-Fi 6):** + + * [为什么 802.11ax 是无线网络的下一件大事][7] + * [FAQ:802.11ax Wi-Fi][8] + * [Wi-Fi 6 (802.11ax) 正在来到你附近的路由器][9] + * [带有 OFDMA 的 Wi-Fi 6 打开了一个全新的无线可能性世界][10] + * [802.11ax 预览:支持 Wi-Fi 6 的接入点和路由器随时可用][11] + + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3399978/5g-will-augment-wi-fi-not-replace-it.html + +作者:[Zeus Kerravala][a] +选题:[lujun9972][b] +译者:[GraveAccent](https://github.com/graveaccent) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/05/wireless_connection_speed_connectivity_bars_cell_tower_5g_by_thinkstock-100796921-large.jpg +[2]: https://www.networkworld.com/article/3203489/what-is-5g-how-is-it-better-than-4g.html +[3]: https://www.networkworld.com/article/3354477/mobile-world-congress-the-time-of-5g-is-almost-here.html +[4]: https://images.idgesg.net/images/article/2019/06/headshot_jlipton_aruba-100798360-small.jpg +[5]: https://www.networkworld.com/article/3215907/why-80211ax-is-the-next-big-thing-in-wi-fi.html +[6]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fcourses%2Fmobile-device-management-big-picture +[7]: https://www.networkworld.com/article/3215907/mobile-wireless/why-80211ax-is-the-next-big-thing-in-wi-fi.html +[8]: https://%20https//www.networkworld.com/article/3048196/mobile-wireless/faq-802-11ax-wi-fi.html +[9]: https://www.networkworld.com/article/3311921/mobile-wireless/wi-fi-6-is-coming-to-a-router-near-you.html +[10]: https://www.networkworld.com/article/3332018/wi-fi/wi-fi-6-with-ofdma-opens-a-world-of-new-wireless-possibilities.html +[11]: https://www.networkworld.com/article/3309439/mobile-wireless/80211ax-preview-access-points-and-routers-that-support-the-wi-fi-6-protocol-on-tap.html +[12]: https://www.facebook.com/NetworkWorld/ +[13]: https://www.linkedin.com/company/network-world diff --git a/published/201907/20190606 Zorin OS Becomes Even More Awesome With Zorin 15 Release.md b/published/201907/20190606 Zorin OS Becomes Even More Awesome With Zorin 15 Release.md new file mode 100644 index 0000000000..28a906fbdb --- /dev/null +++ b/published/201907/20190606 Zorin OS Becomes Even More Awesome With Zorin 15 Release.md @@ -0,0 +1,106 @@ +[#]: collector: (lujun9972) +[#]: translator: (qfzy1233) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11058-1.html) +[#]: subject: (Zorin OS Becomes Even More Awesome With Zorin 15 Release) +[#]: via: (https://itsfoss.com/zorin-os-15-release/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +随着 Zorin 15 的发布,Zorin OS 变得更为强大 +====== + +![](https://img.linux.net.cn/data/attachment/album/201907/05/112128zmz2n2csi6h7y6s2.png) + +长久以来 Zorin OS 一直在 [初学者适用的Linux发行版排行][1] 中占有一席之地。的确,它可能不是最受欢迎的,但是对于从 Windows 阵营转向 Linux 的用户而言,它一定是最好的一个发行版。 + +我还记得,在几年前,我的一位朋友一直坚持让我安装 [Zorin OS][2]。就我个人而言,当时我并不喜欢它的 UI 风格。但是,现如今 Zorin OS 15 发布了,这也让我有了更多的理由安装并将它作为我日常的操作系统。 + +不要担心,在这篇文章里,我会向你介绍你所需要了解的一切。 + +### Zorin 15 中的新特性 + +让我们来看一下最新版本的 Zorin 有哪些主要的改变。Zorin 15 是基于 Ubuntu 18.04.2 的,因此带来了许多性能上的提升。除此之外,也有许多 UI(用户界面)的改进。 + +#### Zorin Connect + +![Zorin Connect][3] + +Zorin OS 15 最主要的一个亮点就是 —— Zorin Connect。如果你使用的是安卓设备,那你一定会喜欢这一功能。类似于 [PushBullet][4](LCTT 译注:PushBullet,子弹推送,一款跨平台推送工具), [Zorin Connect][5] 会提升你的手机和桌面一体化的体验。 + +你可以在桌面上同步智能手机的通知,同时还可以回复它。甚至,你可以回复短信并查看对话。 + +总的来说,你可以体验到以下功能: + + * 在设备间分享文件或链接 + * 将你的手机作为电脑的遥控器 + * 使用手机控制电脑上媒体的播放,并且当有来电接入时自动停止播放 + +正如他们在[官方公告][6]中提到的, 数据的传输仅限于本地网络之间,并且不会有数据被上传到云端服务器。通过以下操作体验 Zorin Connect ,找到:Zorin menu (Zorin 菜单) > System Tools (系统工具) > Zorin Connect。 + +#### 新的桌面主题(包含夜间模式!) + +![Zorin 夜间模式][7] + +一提到 “夜间模式” 我就毫无抵抗力。对我而言,这是Zorin OS 15 自带的最好的功能。 + +当我启用了界面的深色模式时,我的眼睛感到如此舒适,你不想来试试么? + +它不单单是一个深色的主题,而是 UI 更干净直观,并且带有恰到好处的新动画。你可以从 Zorin 内置的外观应用程序里找到所有的相关设置。 + +#### 自适应背景调整 & 深色浅色模式 + +你可以选择让桌面背景根据一天中每小时的环境亮度进行自动调整。此外,如果你想避免蓝光给眼睛带来伤害,你可以使用夜间模式。 + +#### 代办事项应用 + +![Todo][9] + +我一直希望支持这个功能,这样我就不必使用其他 Linux 客户端程序来添加任务。很高兴看到内置的应用程序集成并支持谷歌任务和 Todoist。 + +#### 还有更多么? + +是的!其他主要的变化包括对 Flatpak 的支持,支持平板笔记本二合一电脑的触摸布局,DND 模式,以及一些重新设计的应用程序(设置、Libre Office),以此来给你更好的用户体验。 + +如果你想要了解所有更新和改动的详细信息,你可以查看[官方公告][6]。如果你已经是 Zorin 的用户,你应该已经注意到他们的网站也已经启用了一个全新的外观。 + +### 下载 Zorin OS 15 + +**注释** : 今年的晚些时候将会推出从 Zorin OS 12 直升 15 版本而不需要重新安装的升级包。 + +提示一下,Zorin OS 有三个版本:旗舰版本、核心板和轻量版。 + +如果你想支持开发者和项目,同时解锁 Zorin OS 全部的功能,你可以花 39 美元购买旗舰版本。 + +如果你只是想要一些基本功能,核心版就可以了(你可以免费下载)。如果是这种情况,比如你有一台旧电脑,那么你可以使用轻量版。 + +- [下载 ZORIN OS 15][10] + +你觉得 Zorin 15 怎么样? + +我肯定会尝试一下,将 Zorin OS 作为我的主要操作系统 -(手动狗头)。你呢?你觉得最新的版本怎么样?欢迎在下面的评论中告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/zorin-os-15-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[qfzy1233](https://github.com/qfzy1233) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/best-linux-beginners/ +[2]: https://zorinos.com/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/zorin-connect.jpg +[4]: https://www.pushbullet.com/ +[5]: https://play.google.com/store/apps/details?id=com.zorinos.zorin_connect&hl=en_IN +[6]: https://zoringroup.com/blog/2019/06/05/zorin-os-15-is-here-faster-easier-more-connected/ +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/zorin-dark-mode.jpg +[8]: https://itsfoss.com/necunos-linux-smartphone/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/Todo.jpg +[10]: https://zorinos.com/download/ +[11]: https://itsfoss.com/ubuntu-1404-codenamed-trusty-tahr/ diff --git a/published/201907/20190607 4 tools to help you drive Kubernetes.md b/published/201907/20190607 4 tools to help you drive Kubernetes.md new file mode 100644 index 0000000000..fda732e343 --- /dev/null +++ b/published/201907/20190607 4 tools to help you drive Kubernetes.md @@ -0,0 +1,214 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11101-1.html) +[#]: subject: (4 tools to help you drive Kubernetes) +[#]: via: (https://opensource.com/article/19/6/tools-drive-kubernetes) +[#]: author: (Scott McCarty https://opensource.com/users/fatherlinux/users/fatherlinux/users/fatherlinux/users/fatherlinux) + +帮助你驾驭 Kubernetes 的 4 个工具 +====== + +> 学习如何驾驭 Kubernetes 比如何建造它更重要,这些工具可以帮助你更快上路。 + +![Tools in a workshop][1] + +在本系列的第三篇文章中,[Kubernetes 基础:首先学习如何使用][2],我强调你应该学会使用 Kubernetes,而不是建造它。我还解释说,在 Kubernetes 中,你必须学习最小的一组原语来建模应用程序。我想强调这一点:你需要学习的这组原语是最简单的原语集,你可以通过它们学习如何实现生产级的应用程序部署(即高可用性 [HA]、多容器、多应用程序)。换句话说,学习 Kubernetes 内置的原语集比学习集群软件、集群文件系统、负载平衡器、让人发疯的 Apache 和 Nginx 的配置、路由器、交换机、防火墙和存储后端更容易 —— 这些是你在传统的 IT 环境(虚拟机或裸机)中建模简单的 HA 应用程序所需要的东西。 + +在这第四篇文章中,我将分享一些有助于你学习快速驾驭 Kubernetes 的工具。 + +### 1、Katacoda + +无疑,[Katacoda][3] 是试驾 Kubernetes 集群的最简单方法。只需单击一下,五秒钟后就可以将基于 Web 的终端直接连接到正在运行的 Kubernetes 集群中。这对于使用和学习来说非常棒。我甚至将它用于演示和测试新想法。Katacoda 提供了一个完整的临时环境,在你使用完毕后可以回收利用。 + +![OpenShift Playground][4] + +*[OpenShift Playground][5]* + +![Kubernetes Playground][6] + +*[Kubernetes Playground][7]* + +Katacoda 提供了一个临时的环境和更深入的实验室环境。例如,我最近三四年主讲的 [Linux Container Internals Lab][3] 是在 Katacoda 中构建的。 + +Katacoda 在其主站点上维护了若干 [Kubernetes 和云教程][8]并与 Red Hat 合作以支持了一个 [OpenShift 的专用学习门户][9]。了解一下,它们是极好的学习资源。 + +当你第一次学习驾驶翻斗车时,最好先观察一下其他人的驾驶方式。 + +### 2、Podman generate kube + +`podman generate kube` 命令是一个很棒的子命令,可以帮助用户自然地从运行简单容器的简单容器引擎转换到运行许多容器的集群用例(正如我在[上篇文章][2]中所描述的那样)。[Podman][10] 通过让你启动一个新的容器,然后导出这个可工作的 Kube YAML,并在 Kubernetes 中启动它来实现这一点。看看这个(你可以在 [Katacoda lab][3] 中运行它,它已经有了 Podman 和 OpenShift)。 + +首先,请注意运行容器的语法与 Docker 非常相似: + +``` +podman run -dtn two-pizza quay.io/fatherlinux/two-pizza +``` + +不过这个是其它容器引擎所没有的: + +``` +podman generate kube two-pizza +``` + +输出: + +``` +# Generation of Kubernetes YAML is still under development! +# +# Save the output of this file and use kubectl create -f to import +# it into Kubernetes. +# +# Created with podman-1.3.1 +apiVersion: v1 +kind: Pod +metadata: + creationTimestamp: "2019-06-07T08:08:12Z" + labels: + app: two-pizza + name: two-pizza +spec: + containers: + - command: + - /bin/sh + - -c + - bash -c 'while true; do /usr/bin/nc -l -p 3306 < /srv/hello.txt; done' + env: + - name: PATH + value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + - name: TERM + value: xterm + - name: HOSTNAME + - name: container + value: oci + image: quay.io/fatherlinux/two-pizza:latest + name: two-pizza + resources: {} + securityContext: + allowPrivilegeEscalation: true + capabilities: {} + privileged: false + readOnlyRootFilesystem: false + tty: true + workingDir: / +status: {} +--- +apiVersion: v1 +kind: Service +metadata: + creationTimestamp: "2019-06-07T08:08:12Z" + labels: + app: two-pizza + name: two-pizza +spec: + selector: + app: two-pizza + type: NodePort +status: + loadBalancer: {} +``` + +你现在有了一些可以的工作 Kubernetes YAML,你可以用它作为练习的起点来学习、调整等等。`-s` 标志可以为你创造一项服务。[Brent Baude][11] 甚至致力于[添加卷/持久卷断言][12]等新功能。如果想进一步深入,请在 Brent 的博客文章《[Podman 现在可以轻松过渡到 Kubernetes 和 CRI-O][13]》中了解他的工作。 + +### 3、oc new-app + +`oc new-app` 命令非常强大。它是特定于 OpenShift 的,所以它在默认的 Kubernetes 中不可用,但是当你开始学习 Kubernetes 时它非常有用。让我们从快速命令开始创建一个相当复杂的应用程序: + +``` +oc new-project -n example +oc new-app -f https://raw.githubusercontent.com/openshift/origin/master/examples/quickstarts/cakephp-mysql.json +``` + +使用 `oc new-app`,你可以从 OpenShift 开发人员那里偷取模板,并在开发原语来描述你自己的应用程序时拥有一个已知良好的起点。运行上述命令后,你的 Kubernetes 命名空间(在 OpenShift 中)将由若干新的已定义资源填充。 + +``` +oc get all +``` + +输出: + +``` +NAME READY STATUS RESTARTS AGE +pod/cakephp-mysql-example-1-build 0/1 Completed 0 4m +pod/cakephp-mysql-example-1-gz65l 1/1 Running 0 1m +pod/mysql-1-nkhqn 1/1 Running 0 4m + +NAME DESIRED CURRENT READY AGE +replicationcontroller/cakephp-mysql-example-1 1 1 1 1m +replicationcontroller/mysql-1 1 1 1 4m + +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +service/cakephp-mysql-example ClusterIP 172.30.234.135 8080/TCP 4m +service/mysql ClusterIP 172.30.13.195 3306/TCP 4m + +NAME REVISION DESIRED CURRENT TRIGGERED BY +deploymentconfig.apps.openshift.io/cakephp-mysql-example 1 1 1 config,image(cakephp-mysql-example:latest) +deploymentconfig.apps.openshift.io/mysql 1 1 1 config,image(mysql:5.7) + +NAME TYPE FROM LATEST +buildconfig.build.openshift.io/cakephp-mysql-example Source Git 1 + +NAME TYPE FROM STATUS STARTED DURATION +build.build.openshift.io/cakephp-mysql-example-1 Source Git@47a951e Complete 4 minutes ago 2m27s + +NAME DOCKER REPO TAGS UPDATED +imagestream.image.openshift.io/cakephp-mysql-example docker-registry.default.svc:5000/example/cakephp-mysql-example latest About aminute ago + +NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD +route.route.openshift.io/cakephp-mysql-example cakephp-mysql-example-example.2886795271-80-rhsummit1.environments.katacoda.com cakephp-mysql-example None +``` + +这样做的好处是你可以删除 Pod,观察复制控制器如何重新创建它们,缩放 Pod 等等。你可以使用模板并将其更改为其他应用程序(这是我第一次启动时所做的)。 + +### 4、Visual Studio Code + +我把我最喜欢的放在最后。我的大部分工作都使用 [vi][14],但我从来没有为 Kubernetes 找到一个好的语法高亮器和代码补完插件(如果有的话,请告诉我)。相反,我发现微软的 [VS Code][15] 有一套杀手级的插件,可以完成 Kubernetes 资源的创建并提供样板。 + +![VS Code plugins UI][16] + +首先,安装上图中显示的 Kubernetes 和 YAML 插件。 + +![Autocomplete in VS Code][17] + +然后,你可以从头开始创建新的 YAML 文件,并自动补完 Kubernetes 资源。上面的示例显示了一个服务。 + +![VS Code autocomplete filling in boilerplate for an object][18] + +当你使用自动补完并选择服务资源时,它会填充该对象的一些模板。当你第一次学习使用 Kubernetes 时,这非常棒。你可以构建 Pod、服务、复制控制器、部署等。当你从头开始构建这些文件甚至修改你使用 `podman generate kube` 创建的文件时,这是一个非常好的功能。 + +### 总结 + +这四个工具(如果算上两个插件,则为六个)将帮助你学习驾驭 Kubernetes,而不是构造或装备它。在本系列的最后一篇文章中,我将讨论为什么 Kubernetes 如此适合运行这么多不同的工作负载。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/tools-drive-kubernetes + +作者:[Scott McCarty][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/fatherlinux/users/fatherlinux/users/fatherlinux/users/fatherlinux +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_workshop_blue_mechanic.jpg?itok=4YXkCU-J (Tools in a workshop) +[2]: https://linux.cn/article-11036-1.html +[3]: https://learn.openshift.com/subsystems/container-internals-lab-2-0-part-1 +[4]: https://opensource.com/sites/default/files/uploads/openshift-playground.png (OpenShift Playground) +[5]: https://learn.openshift.com/playgrounds/openshift311/ +[6]: https://opensource.com/sites/default/files/uploads/kubernetes-playground.png (Kubernetes Playground) +[7]: https://katacoda.com/courses/kubernetes/playground +[8]: https://katacoda.com/learn +[9]: http://learn.openshift.com/ +[10]: https://podman.io/ +[11]: https://developers.redhat.com/blog/author/bbaude/ +[12]: https://github.com/containers/libpod/issues/2303 +[13]: https://developers.redhat.com/blog/2019/01/29/podman-kubernetes-yaml/ +[14]: https://en.wikipedia.org/wiki/Vi +[15]: https://code.visualstudio.com/ +[16]: https://opensource.com/sites/default/files/uploads/vscode_-_kubernetes_red_hat_-_plugins.png (VS Code plugins UI) +[17]: https://opensource.com/sites/default/files/uploads/vscode_-_kubernetes_service_-_autocomplete.png (Autocomplete in VS Code) +[18]: https://opensource.com/sites/default/files/uploads/vscode_-_kubernetes_service_-_boiler_plate.png (VS Code autocomplete filling in boilerplate for an object) diff --git a/published/201907/20190607 Free and Open Source Trello Alternative OpenProject 9 Released.md b/published/201907/20190607 Free and Open Source Trello Alternative OpenProject 9 Released.md new file mode 100644 index 0000000000..213044032e --- /dev/null +++ b/published/201907/20190607 Free and Open Source Trello Alternative OpenProject 9 Released.md @@ -0,0 +1,81 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11063-1.html) +[#]: subject: (Free and Open Source Trello Alternative OpenProject 9 Released) +[#]: via: (https://itsfoss.com/openproject-9-release/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +替代 Trello 的 OpenProject 9 发布了 +====== +![](https://img.linux.net.cn/data/attachment/album/201907/06/130201r9g70u01uuvvvvu7.jpg) + +[OpenProject][1] 是一个开源项目协作管理软件。它是 [Trello][2] 和 [Jira][3] 等专有方案的替代品。 + +如果个人使用,你可以免费使用它,并在你自己的服务器上进行设置(并托管它)。这样,你就可以控制数据。 + +当然,如果你是[企业云版的用户][4],那么你可以使用高级功能和更优先的帮助。 + +OpenProject 9 的重点是新的面板视图,包列表视图和工作模板。 + +如果你对此不了解,可以尝试一下。但是,如果你是已有用户 —— 在迁移到 OpenProject 9 之前,你应该知道这些新功能。 + +### OpenProject 9 有什么新功能? + +以下是最新版 OpenProject 的一些主要更改。 + +#### Scrum 和敏捷面板 + +![][5] + +对于企业云版,有了一个新的 [scrum][6] 和[敏捷][7]面板视图。你还可以[看板风格][8]方式展示你的工作,从而更轻松地支持你的敏捷和 scrum 团队。 + +新的面板视图使你可以轻松了解为该任务分配的人员并快速更新状态。你还有不同的面板视图选项,如基本面板、状态面板和版本面板。 + +#### 工作包模板 + +![Work Package Template][9] + +你不必为每个独立的工作包从头开始创建所有内容。而是,你只需保留一个模板,这样你就可以在需要创建新工作包时使用它。这将节省大量时间。 + +#### 新的工作包列表视图 + +![Work Package View][10] + +在工作包列表中,有一个微小的新增功能,可让你查看特定工作的已分配人员的头像。 + +#### “我的”页面的可自定义工作包视图 + +“我的”页面显示你正在处理的内容(以及进度),它不应该一直那么呆板。因此,现在你可以自定义它,甚至可以添加甘特图来可视化你的工作。 + +### 总结 + +有关迁移和安装的详细说明,请参阅[官方的公告帖][12],其中包含了必要的细节。 + +另外,我们很想知道你使用 OpenProject 9 的经历,请在下面的评论栏告诉我们!如果你使用其他一些项目管理软件,请随时向我们和其他 FOSS 读者推荐。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/openproject-9-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.openproject.org/ +[2]: https://trello.com/ +[3]: https://www.atlassian.com/software/jira +[4]: https://www.openproject.org/pricing/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/open-project-9-scrum-agile.jpeg?fit=800%2C517&ssl=1 +[6]: https://en.wikipedia.org/wiki/Scrum_(software_development) +[7]: https://en.wikipedia.org/wiki/Agile_software_development +[8]: https://en.wikipedia.org/wiki/Kanban +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/work-package-template.jpg?ssl=1 +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/work-package-view.jpg?fit=800%2C454&ssl=1 +[12]: https://www.openproject.org/openproject-9-new-scrum-agile-board-view/ diff --git a/published/201907/20190609 How to set ulimit and file descriptors limit on Linux Servers.md b/published/201907/20190609 How to set ulimit and file descriptors limit on Linux Servers.md new file mode 100644 index 0000000000..c2ca6cc0fe --- /dev/null +++ b/published/201907/20190609 How to set ulimit and file descriptors limit on Linux Servers.md @@ -0,0 +1,222 @@ +[#]: collector: (lujun9972) +[#]: translator: (zgj1024) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11077-1.html) +[#]: subject: (How to set ulimit and file descriptors limit on Linux Servers) +[#]: via: (https://www.linuxtechi.com/set-ulimit-file-descriptors-limit-linux-servers/) +[#]: author: (Shashidhar Soppin https://www.linuxtechi.com/author/shashidhar/) + +如何在 Linux 服务器上设置 ulimit 和文件描述符数限制 +====== +
**简介**:在生产环境中遇到打开文件数这类的挑战如今已是司空见惯的事情了。因为许多应用程序是基于 Java 和 Apache 的,安装和配置它们可能会导致打开过多的文件(文件描述符)。如果打开的文件描述符超过了默认设置的限制,就可能会面临访问控制问题,受阻于打开文件的挑战。许多生产环境因此而陷入停滞状态。 + +![](https://img.linux.net.cn/data/attachment/album/201907/09/121422bv6t76nztjxqoprn.jpg) + +幸运的是,在基于 Linux 的服务器上,都有 `ulimit` 命令,通过它可以查看、设置、获取文件打开的状态和配置详情。此命令配备了许多选项,通过这些组合可以设置打开文件的数量。下面逐个命令用示例做了详细说明。 + +### 查看任何 Linux 系统中当前打开文件数的限制 + +要在 Linux 服务器上得到打开文件数的限制,请执行以下命令, + +``` +[root@ubuntu ~]# cat /proc/sys/fs/file-max +146013 +``` + +上面的数字表明用户可以在每个用户登录会话中打开 ‘146013’ 个文件。 + +``` +[root@centos ~]# cat /proc/sys/fs/file-max +149219 +[root@debian ~]# cat /proc/sys/fs/file-max +73906 +``` + +这清楚地表明,各个 Linux 操作系统具有不同的打开文件数限制。这基于各自系统中运行的依赖关系和应用程序。 + +### ulimit 命令 + +顾名思义,`ulimit`(用户限制)用于显示和设置登录用户的资源限制。当我们使用 `-a` 选项运行 `ulimit` 命令时,它将打印登录用户的所有资源限制。现在让我们在 Ubuntu/Debian 和 CentOS 系统上运行 `ulimit -a`, + +#### Ubuntu / Debian 系统 + +``` +shashi@Ubuntu ~}$ ulimit -a +core file size (blocks, -c) 0 +data seg size (kbytes, -d) unlimited +scheduling priority (-e) 0 +file size (blocks, -f) unlimited +pending signals (-i) 5731 +max locked memory (kbytes, -l) 64 +max memory size (kbytes, -m) unlimited +open files (-n) 1024 +pipe size (512 bytes, -p) 8 +POSIX message queues (bytes, -q) 819200 +real-time priority (-r) 0 +stack size (kbytes, -s) 8192 +cpu time (seconds, -t) unlimited +max user processes (-u) 5731 +virtual memory (kbytes, -v) unlimited +file locks (-x) unlimited +``` + +#### CentOS 系统 + +``` +shashi@centos ~}$ ulimit -a +core file size (blocks, -c) 0 +data seg size (kbytes, -d) unlimited +scheduling priority (-e) 0 +file size (blocks, -f) unlimited +pending signals (-i) 5901 +max locked memory (kbytes, -l) 64 +max memory size (kbytes, -m) unlimited +open files (-n) 1024 +pipe size (512 bytes, -p) 8 +POSIX message queues (bytes, -q) 819200 +real-time priority (-r) 0 +stack size (kbytes, -s) 8192 +cpu time (seconds, -t) unlimited +max user processes (-u) 5901 +virtual memory (kbytes, -v) unlimited +file locks (-x) unlimited +``` + +正如我们可以在这里看到的,不同的操作系统具有不同的限制设置。所有这些限制都可以使用 `ulimit` 命令进行配置/更改。 + +要显示单个资源限制,可以在 `ulimit` 命令中传递特定的参数,下面列出了一些参数: + + * `ulimit -n` –> 显示打开文件数限制 + * `ulimit -c` –> 显示核心转储文件大小 + * `umilit -u` –> 显示登录用户的最大用户进程数限制 + * `ulimit -f` –> 显示用户可以拥有的最大文件大小 + * `umilit -m` –> 显示登录用户的最大内存大小 + * `ulimit -v` –> 显示最大内存大小限制 + +使用以下命令检查登录用户打开文件数量的硬限制和软限制: + +``` +shashi@Ubuntu ~}$ ulimit -Hn +1048576 +shashi@Ubuntu ~}$ ulimit -Sn +1024 +``` + +### 如何修复达到最大文件数限制的问题? + +让我们假设我们的 Linux 服务器已经达到了打开文件的最大数量限制,并希望在系统范围扩展该限制,例如,我们希望将 100000 设置为打开文件数量的限制。 + +``` +root@ubuntu~]# sysctl -w fs.file-max=100000 +fs.file-max = 100000 +``` + +上述更改将在下次重启之前有效,因此要使这些更改在重启后仍存在,请编辑文件 `/etc/sysctl.conf` 并添加相同的参数, + +``` +root@ubuntu~]# vi /etc/sysctl.conf +fs.file-max = 100000 +``` + +保存文件并退出。 + +运行下面命令,使上述更改立即生效,而无需注销和重新启动。 + +``` +root@ubuntu~]# sysctl -p +``` + +现在验证新的更改是否生效。 + +``` +root@ubuntu~]# cat /proc/sys/fs/file-max +100000 +``` + +使用以下命令找出当前正在使用的文件描述符数量: + +``` +[root@ansible ~]# more /proc/sys/fs/file-nr +1216 0 100000 +``` + +注意:命令 `sysctl -p` 用于在不重新启动和注销的情况下提交更改。 + +### 通过 limit.conf 文件设置用户级资源限制 + +`/etc/sysctl.conf` 文件用于设置系统范围的资源限制,但如果要为 Oracle、MariaDB 和 Apache 等特定用户设置资源限制,则可以通过 `/etc/security/limits.conf` 文件去实现。 + +示例 `limits.conf` 如下所示, + +``` +root@ubuntu~]# cat /etc/security/limits.conf +``` + +![Limits-conf-linux-part1][1] + +![Limits-conf-linux-part2][2] + +假设我们要为 linuxtechi 用户设置打开文件数量的硬限制和软限制,而对于 oracle 用户设置打开进程数量的硬限制和软限制,编辑文件 `/etc/security/limits.conf` 并添加以下行: + +``` +# hard limit for max opened files for linuxtechi user +linuxtechi hard nofile 4096 +# soft limit for max opened files for linuxtechi user +linuxtechi soft nofile 1024 + +# hard limit for max number of process for oracle user +oracle hard nproc 8096 +# soft limit for max number of process for oracle user +oracle soft nproc 4096 +``` + +保存文件并退出。 + +**注意:** 如果你想对一个组而不是用户进行资源限制,那么也可以通过 `limits.conf` 文件,输入 `@<组名>` 代替用户名,其余项都是相同的,示例如下, + +``` +# hard limit for max opened files for sysadmin group +@sysadmin hard nofile 4096 +# soft limit for max opened files for sysadmin group +@sysadmin soft nofile 1024 +``` + +验证新的更改是否生效: + +``` +~]# su - linuxtechi +~]$ ulimit -n -H +4096 +~]$ ulimit -n -S +1024 + +~]# su - oracle +~]$ ulimit -H -u +8096 +~]$ ulimit -S -u +4096 +``` + +注:其他主要使用的命令是 [lsof][3],可用于找出“当前打开了多少个文件”,这命令对管理员非常有帮助。 + +### 结尾 + +正如在介绍部分提到的,`ulimit` 命令非常强大,可以帮助用户配置并确保应用程序安装更加流畅而没有任何瓶颈。此命令有助于修复基于 Linux 的服务器中的(打开)大量文件的限制。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/set-ulimit-file-descriptors-limit-linux-servers/ + +作者:[Shashidhar Soppin][a] +选题:[lujun9972][b] +译者:[zgj1024](https://github.com/zgj1024) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/shashidhar/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Limits-conf-linux-part1-1024x677.jpg +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Limits-conf-linux-part2-1024x443.jpg +[3]: https://www.linuxtechi.com/lsof-command-examples-linux-geeks/ diff --git a/published/201907/20190610 5 Easy Ways To Free Up Space (Remove Unwanted or Junk Files) on Ubuntu.md b/published/201907/20190610 5 Easy Ways To Free Up Space (Remove Unwanted or Junk Files) on Ubuntu.md new file mode 100644 index 0000000000..530d71d66e --- /dev/null +++ b/published/201907/20190610 5 Easy Ways To Free Up Space (Remove Unwanted or Junk Files) on Ubuntu.md @@ -0,0 +1,162 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11051-1.html) +[#]: subject: (5 Easy Ways To Free Up Space (Remove Unwanted or Junk Files) on Ubuntu) +[#]: via: (https://www.2daygeek.com/linux-remove-delete-unwanted-junk-files-free-up-space-ubuntu-mint-debian/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +5 种在 Ubuntu 上释放空间的简单方法 +====== + +![](https://img.linux.net.cn/data/attachment/album/201907/03/165641h0xy91x9109wz19w.jpg) + +大多数人可能在系统磁盘存储不足的情况下执行释放空间这个操作,也可能在 Linux 系统磁盘存储满了的情况下执行这个操作。 + +它应该被经常执行,来为安装一个新的应用程序和处理其它文件弥补磁盘存储空间。保持可用空间是 Linux 管理员的一个日常任务,以允许磁盘利用率维持在阈值之下。 + +这里有一些我们可以清理我们系统空间的方法。 + +当你有 TB 级存储容量时,可能不需要清理你的系统。但是,如果你空间有限,那么释放磁盘空间就变的不可避免。 + +在这篇文章中,我将向你展示一些最容易的或简单的方法来清理你的 Ubuntu 系统,获得更多空间。 + +### 在 Ubuntu 系统上如何检查可用的空间? + +在你的系统上使用 [df 命令][1] 来检查当前磁盘利用率。 + +``` +$ df -h +Filesystem Size Used Avail Use% Mounted on +udev 975M 0 975M 0% /dev +tmpfs 200M 1.7M 198M 1% /run +/dev/sda1 30G 16G 13G 55% / +tmpfs 997M 0 997M 0% /dev/shm +tmpfs 5.0M 4.0K 5.0M 1% /run/lock +tmpfs 997M 0 997M 0% /sys/fs/cgroup +``` + +图形界面用户可以使用“磁盘利用率分析器工具”来查看当前利用率。 + +![][3] + +#### 1) 移除不再需要的软件包 + +下面的命令移除系统不再需要的依赖库和软件包。这些软件包是自动安装的,以使一个安装的软件包满足依赖关系。同样,它也会移除安装在系统中的 Linux 旧内核。它会移除不再被系统需要的孤儿软件包,但是不会清除它们。 + +``` +$ sudo apt-get autoremove +[sudo] password for daygeek: +Reading package lists... Done +Building dependency tree +Reading state information... Done +The following packages will be REMOVED: + apache2-bin apache2-data apache2-utils galera-3 libaio1 libapr1 libaprutil1 + libaprutil1-dbd-sqlite3 libaprutil1-ldap libconfig-inifiles-perl libdbd-mysql-perl + libdbi-perl libjemalloc1 liblua5.2-0 libmysqlclient20 libopts25 + libterm-readkey-perl mariadb-client-10.1 mariadb-client-core-10.1 mariadb-common + mariadb-server-10.1 mariadb-server-core-10.1 mysql-common sntp socat +0 upgraded, 0 newly installed, 25 to remove and 23 not upgraded. +After this operation, 189 MB disk space will be freed. +Do you want to continue? [Y/n] +``` + +为清除它们,可以与命令一起使用 `--purge` 选项。 + +``` +$ sudo apt-get autoremove --purge +Reading package lists... Done +Building dependency tree +Reading state information... Done +The following packages will be REMOVED: + apache2-bin* apache2-data* apache2-utils* galera-3* libaio1* libapr1* libaprutil1* + libaprutil1-dbd-sqlite3* libaprutil1-ldap* libconfig-inifiles-perl* + libdbd-mysql-perl* libdbi-perl* libjemalloc1* liblua5.2-0* libmysqlclient20* + libopts25* libterm-readkey-perl* mariadb-client-10.1* mariadb-client-core-10.1* + mariadb-common* mariadb-server-10.1* mariadb-server-core-10.1* mysql-common* sntp* + socat* +0 upgraded, 0 newly installed, 25 to remove and 23 not upgraded. +After this operation, 189 MB disk space will be freed. +Do you want to continue? [Y/n] +``` + +#### 2) 清空回收站 + +有可能你的回收站里面有大量的无用数据。它会占用你的系统空间。最好解决方法之一是在你的系统上清理这些无用的数据,以获取一些可用的空间。 + +为清理这些,简单地使用文件管理器来清空你的回收站。 + +![][4] + +#### 3) 清理 APT 缓存文件 + +Ubuntu 使用 [APT 命令][5](高级软件包工具)用于软件包管理,如:安装、移除、搜索等等。 + +一般 Linux 操作系统会在各自的目录下保留下载和安装的软件包的缓冲文件。 + +Ubuntu 也一样,它在你的磁盘上以缓冲的形式保留它下载和安装的每次更新。Ubuntu 在 `/var/cache/apt/archives` 目录中保留 DEB 软件包的缓冲文件。随着时间推移,这些缓存可能快速增长,并在你的系统上占有很多空间。 + +运行下面的命令来检查当前 APT 缓存文件的使用率。 + +``` +$ sudo du -sh /var/cache/apt +147M /var/cache/apt +``` + +下面的命令会清理过时的 deb 软件包。我想说,一点都清理不干净。 + +``` +$ sudo apt-get autoclean +``` + +下面的命令会移除所有在 apt 缓存中的软件包。 + +``` +$ sudo apt-get clean +``` + +#### 4) 卸载不使用的应用程序 + +这需要你来检查在你的系统上安装的软件包和游戏,删除它们,如果你很少使用的话。 + +这可以通过 “Ubuntu 软件中心” 简单地做到。 + +![][6] + +#### 5) 清理缩略图缓存 + +缓存文件夹是程序存储它们可能再次需要的数据的地方,它是为速度保留的,而不是必需保留的。它可以被再次生成或再次下载。假如它真的填满了你的硬盘,那么你可以删除一些东西而不用担心。 + +运行下面的命令来检查当前 APT 缓存的利用率。 + +``` +$ du -sh ~/.cache/thumbnails/ +412K /home/daygeek/.cache/thumbnails/ +``` + +运行下面的命令来从你的系统中永久地删除它们。 + +``` +$ rm -rf ~/.cache/thumbnails/* +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-remove-delete-unwanted-junk-files-free-up-space-ubuntu-mint-debian/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/how-to-check-disk-space-usage-using-df-command/ +[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]: https://www.2daygeek.com/wp-content/uploads/2019/06/remove-delete-Unwanted-Junk-Files-free-up-space-ubuntu-mint-debian-1.jpg +[4]: https://www.2daygeek.com/wp-content/uploads/2019/06/remove-delete-Unwanted-Junk-Files-free-up-space-ubuntu-mint-debian-2.jpg +[5]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[6]: https://www.2daygeek.com/wp-content/uploads/2019/06/remove-delete-Unwanted-Junk-Files-free-up-space-ubuntu-mint-debian-3.jpg diff --git a/published/201907/20190612 BitTorrent Client Deluge 2.0 Released- Here-s What-s New.md b/published/201907/20190612 BitTorrent Client Deluge 2.0 Released- Here-s What-s New.md new file mode 100644 index 0000000000..7f100cfc52 --- /dev/null +++ b/published/201907/20190612 BitTorrent Client Deluge 2.0 Released- Here-s What-s New.md @@ -0,0 +1,75 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11050-1.html) +[#]: subject: (BitTorrent Client Deluge 2.0 Released: Here’s What’s New) +[#]: via: (https://itsfoss.com/deluge-2-release/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +BitTorrent 客户端 Deluge 2.0 发布:新功能介绍 +====== + +你可能已经知道 [Deluge][1] 是[最适合 Linux 用户的 Torrent 客户端][2]之一。然而,最近的稳定版本差不多是两年前的了。 + +尽管它仍在积极开发中,但直到最近才出了一个主要的稳定版本。我们写这篇文章时,最新版本恰好是 2.0.2。所以,如果你还没有下载最新的稳定版本,请尝试一下。 + +不管如何,如果你感兴趣的话,让我们看看有哪些新的功能。 + +### Deluge 2.0 的主要改进 + +新版本引入了多用户支持,这是一个非常需要的功能。除此之外,还有一些性能改进可以更快地加载更多的种子。 + +此外,在 2.0 版本中,Deluge 使用了 Python 3,对 Python 2.7 提供最低支持。即使是用户界面,他们也从 GTK UI 迁移到了 GTK3。 + +根据发行说明,还有一些更重要的补充/改进,包括: + +* 多用户支持。 +* 性能提升,可以更快地加载数千个种子。 +* 一个模拟 GTK/Web UI 的新控制台 UI。 +* GTK UI 迁移到 GTK3,并带有 UI 改进和补充。 +* 磁链预获取功能可以在添加种子时选择文件。 +* 完全支持 libtorrent 1.2。 +* 语言切换支持。 +* 改进了在 ReadTheDocs 托管的文档。 +* AutoAdd 插件取代了内置功能。 + +### 如何安装或升级到 Deluge 2.0 + +![][4] + +对于任何 Linux 发行版,你都应该遵循官方[安装指南][5](使用 PPA 或 PyPi)。但是,如果你要升级,你应该留意发行说明中提到的: + +> “_Deluge 2.0 与 Deluge 1.x 客户端或守护进程不兼容,因此这些也需要升级。如果第三方脚本直接连接到 Deluge 客户端,那么可能也不兼容且需要迁移。_” + +因此,坚持在升级主版本之前备份你的[配置][6]以免数据丢失。而且,如果你是插件作者,那么需要升级它以使其与新版本兼容。 + +直接下载的安装包尚不包含 Windows 和 Mac OS。但是,说明中提到他们正在进行中。 + +除此之外,你可以按照更新后的官方文档中的[安装指南][5]来手动安装它们。 + +### 总结 + +你如何看待最新的稳定版本?你是否将 Deluge 用作 BitTorrent 客户端?或者你是否找到了其他更好的选择? + +请在下面的评论栏告诉我们你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/deluge-2-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://dev.deluge-torrent.org/ +[2]: https://itsfoss.com/best-torrent-ubuntu/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/deluge.jpg?fit=800%2C410&ssl=1 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/Deluge-2-release.png?resize=800%2C450&ssl=1 +[5]: https://deluge.readthedocs.io/en/latest/intro/01-install.html +[6]: https://dev.deluge-torrent.org/wiki/Faq#WheredoesDelugestoreitssettingsconfig diff --git a/published/201907/20190613 IPython is still the heart of Jupyter Notebooks for Python developers.md b/published/201907/20190613 IPython is still the heart of Jupyter Notebooks for Python developers.md new file mode 100644 index 0000000000..c3e147d434 --- /dev/null +++ b/published/201907/20190613 IPython is still the heart of Jupyter Notebooks for Python developers.md @@ -0,0 +1,95 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11064-1.html) +[#]: subject: (IPython is still the heart of Jupyter Notebooks for Python developers) +[#]: via: (https://opensource.com/article/19/6/ipython-still-heart-jupyterlab) +[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberg/users/marcobravo) + +对 Python 开发者而言,IPython 仍然是 Jupyter Notebook 的核心 +====== + +> Jupyter 项目提供的魔法般的开发体验很大程度上得益于它的 IPython 基因。 + +![](https://img.linux.net.cn/data/attachment/album/201907/06/131704z1lsfssamfxrrliq.jpg) + +最近刚刚写过我为什么觉得觉得 Jupyter 项目(特别是 JupyterLab)提供了一种 [魔法般的 Python 开发体验][2]。在研究这些不同项目之间的关联的时候,我回顾了一下 Jupyter 最初从 IPython 分支出来的这段历史。正如 Jupyter 项目的 [大拆分™ 声明][3] 所说: + +> “如果你不明白 Jupyter 是什么,这么说吧,它拥有和 IPython 同样的代码,并且是由同一批人开发的,只不过取了一个新名字、安了一个新家。” + +下面这个注脚进一步说明了这一点: + +> “我从声明中解读出来的信息是,‘Jupyter 和 IPython 非常相似,但是拥有多种语言’,这也可以很好地解释为什么这个项目的名字已经不再需要包含 Python,因为当时它已经支持多种语言了。” + +我明白 Jupyter Notebook 和 IPython 都是从同样的源代码里分支出来的,但是不太清楚 IPython 项目的现状。在大拆分™ 之后它是已经不再被需要了,还是在以另一种方式延续着? + +后来我惊讶地发现,IPython 仍然不断在为 Python 使用者提供价值,它正是 Jupyter 体验的核心部分。下面是 Jupyter 常见问题页面的一段截取: + +> **有什么语言是需要预装的吗?** +> +> 是的,安装 Jupyter Notebook 会首先安装 IPython 内核。这样我们就可以在 notebook 上运行 Python 语言了。 + +现在我明白了,在 JupyterLab(以及 Jupyter Notebook)上编写 Python 程序仍然需要依赖 IPython 内核的持续开发。不仅如此,IPython 还充当了最为强大的默认内核的角色,根据 [这份文档][4],它是其它语言内核之间的枢纽,节省了很多开发时间和精力。 + +现在唯一的问题是,IPython 本身可以做什么呢? + +### IPython 如今的作用 + +IPython 提供了一个强大的、交互性的 Python shell,以及 Jupyter 的内核。安装完成之后,我可以在任何命令行运行 `ipython` 本身,将它当作一个(比默认 Python shell 好太多的)Python shell 来使用: + + +``` +$ ipython +Python 3.7.3 (default, Mar 27 2019, 09:23:15) +Type 'copyright', 'credits' or 'license' for more information +IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help. + +In [1]: import numpy as np +In [2]: example = np.array([5, 20, 3, 4, 0, 2, 12]) +In [3]: average = np.average(example) +In [4]: print(average) +6.571428571428571 +``` + +这就让我们发现了一个更为重要的问题:是 IPython 让 JupyterLab 可以在项目中执行代码,并且支持了一系列被称为 *Magic* 的功能(感谢 Nicholas Reith 在我上一篇文章的评论里提到这点)。 + +### IPython 让魔法成为现实 + +JupyterLab 和其它使用 IPython 的前端工具可以让你感觉像是在最喜欢的 IDE 或者是终端模拟器的环境下工作。我非常喜欢 [点文件][5] 快捷键功能,Magic 也有类似点文件的特征。比如说,可以试一下 [%bookmark][6] 这个命令。我把默认开发文件夹 `~/Develop` 关联到了一个可以在任何时候直接跳转的快捷方式上。 + +![Screenshot of commands from JupyterLab][7] + +`%bookmark`、`%cd`,以及我在前一篇文章里介绍过的 `!` 操作符,都是由 IPython 支持的。正如这篇 [文档][8] 所说: + +> Jupyter 用户你们好:Magic 功能是 IPython 内核提供的专属功能。一个内核是否支持 Magic 功能是由该内核的开发者针对该内核所决定的。 + +### 写在最后 + +作为一个好奇的新手,我之前并不是特别确定 IPython 是否仍然和 Jupyter 生态还有任何联系。现在我对 IPython 的持续开发有了新的认识和,并且意识到它正是 JupyterLab 强大的用户体验的来源。这也是相当有才华的一批贡献者进行最前沿研究的成果,所以如果你在学术论文中使用到了 Jupyter 项目的话别忘了引用他们。为了方便引用,他们还提供了一个 [现成的引文][9]。 + +如果你在考虑参与哪个开源项目的贡献的话,一定不要忘了 IPython 哦。记得看看 [最新发布说明][10],在这里可以找到 Magic 功能的完整列表。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/ipython-still-heart-jupyterlab + +作者:[Matthew Broberg][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mbbroberg/users/marcobravo +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/ilovefs_free_sticker_fsfe_heart.jpg?itok=gLJtaieq (I love Free Software FSFE celebration) +[2]: https://opensource.com/article/19/5/jupyterlab-python-developers-magic +[3]: https://blog.jupyter.org/the-big-split-9d7b88a031a7 +[4]: https://jupyter-client.readthedocs.io/en/latest/kernels.html +[5]: https://en.wikipedia.org/wiki/Hidden_file_and_hidden_directory#Unix_and_Unix-like_environments +[6]: https://ipython.readthedocs.io/en/stable/interactive/magics.html?highlight=magic#magic-bookmark +[7]: https://opensource.com/sites/default/files/uploads/jupyterlab-commands-ipython.png (Screenshot of commands from JupyterLab) +[8]: https://ipython.readthedocs.io/en/stable/interactive/magics.html +[9]: https://ipython.org/citing.html +[10]: https://ipython.readthedocs.io/en/stable/whatsnew/index.html diff --git a/published/201907/20190617 Use ImageGlass to quickly view JPG images as a slideshow.md b/published/201907/20190617 Use ImageGlass to quickly view JPG images as a slideshow.md new file mode 100644 index 0000000000..8d60619efc --- /dev/null +++ b/published/201907/20190617 Use ImageGlass to quickly view JPG images as a slideshow.md @@ -0,0 +1,54 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11141-1.html) +[#]: subject: (Use ImageGlass to quickly view JPG images as a slideshow) +[#]: via: (https://opensource.com/article/19/6/use-imageglass-view-jpg-images-slideshow-windows-10) +[#]: author: (Jeff Macharyas https://opensource.com/users/jeffmacharyas) + +使用 ImageGlass 以幻灯片形式快速查看 JPG 图像 +====== + +> 想要在 Windows 10 中以幻灯片形式逐个查看文件夹中的图像么?开源软件可以做到。 + +![Looking back with binoculars][1] + +欢迎阅读今天的系列文章 “我该如何让它实现?”就我而言,我试图在 Windows 10 上以幻灯片形式查看 JPG 图像的文件夹。像往常一样,我转向开源来解决这个问题。 + +在 Mac 上,以幻灯片形式查看 JPG 图像文件夹只需选择文件夹中的所有图像(`Command-A`),然后按 `Option-Command-Y` 即可。之后,你可以使用箭头键向前翻动。当然,在 Windows 中,你可以通过选择第一个图像,然后单击窗口中黄色的**管理**栏,然后选择**幻灯片**来执行类似的操作。在那里,你可以控制速度,但只能做到:慢、中、快。 + +我希望像在 Windows 中能像 Mac 一样翻下一张图片。自然地,我 Google 搜索了一下并找到了一个方案。我发现了 [ImageGlass][2] 这个开源应用,其许可证是 [GPL 3.0][3],并且它完美地做到了。这是它的样子: + +![Viewing an image in ImageGlass.][4] + +### 关于 ImageGlass + +ImageGlass 是由 Dương Diệu Pháp 开发的,根据他的网站,他是一名越南开发人员,在 Chainstack 负责前端。他与在美国的 [Kevin Routley][5] 协作,后者“为 ImageGlass 开发新功能”。源代码可以在 [GitHub][6] 上找到。 + +ImageGlass 支持最常见的图像格式,包括 JPG、GIF、PNG、WEBP、SVG 和 RAW。用户可以轻松自定义扩展名列表。 + +我遇到的具体问题是需要找到一张用于目录封面的图像。不幸的是,它在一个包含数十张照片的文件夹中。在 ImageGlass 中以幻灯片浏览照片,在我想要的照片前停止,并将其下载到我的项目文件夹中变得很容易。开源再次帮助了我,该应用只花了很短的时间下载和使用。 + +在 2016 年 3 月 10 日,Jason Baker 在他的文章 [9 款 Picasa 的开源替代品][7] 中将 ImageGlass 列为其中之一。如果你有需求,里面还有一些其他有趣的图像相关工具。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/use-imageglass-view-jpg-images-slideshow-windows-10 + +作者:[Jeff Macharyas][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jeffmacharyas +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/look-binoculars-sight-see-review.png?itok=NOw2cm39 (Looking back with binoculars) +[2]: https://imageglass.org/ +[3]: https://github.com/d2phap/ImageGlass/blob/master/LICENSE +[4]: https://opensource.com/sites/default/files/uploads/imageglass-screenshot.png (Viewing an image in ImageGlass.) +[5]: https://github.com/fire-eggs +[6]: https://github.com/d2phap/ImageGlass +[7]: https://opensource.com/alternatives/picasa diff --git a/published/201907/20190618 A beginner-s guide to Linux permissions.md b/published/201907/20190618 A beginner-s guide to Linux permissions.md new file mode 100644 index 0000000000..a8206c14d4 --- /dev/null +++ b/published/201907/20190618 A beginner-s guide to Linux permissions.md @@ -0,0 +1,119 @@ +[#]: collector: (lujun9972) +[#]: translator: (qfzy1233) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11056-1.html) +[#]: subject: (A beginner's guide to Linux permissions) +[#]: via: (https://opensource.com/article/19/6/understanding-linux-permissions) +[#]: author: (Bryant Son https://opensource.com/users/brson/users/greg-p/users/tj) + +Linux 权限入门指南 +====== + +> Linux 安全权限能够指定谁可以对文件或目录执行什么操作。 + +![](https://img.linux.net.cn/data/attachment/album/201907/04/133751argz0pp7hy5gvv7q.jpg) + +与其他系统相比而言 Linux 系统的众多优点中最为主要一个便是 Linux 系统有着更少的安全漏洞和被攻击的隐患。Linux 无疑为用户提供了更为灵活和精细化的文件系统安全权限控制。这可能意味着 Linux 用户理解安全权限是至关重要的。虽然这并不一定是必要的,但是对于初学者来说,理解 Linux 权限的基本知识仍是一个明智之选。 + +### 查看 Linux 安全权限 + +在开始 Linux 权限的相关学习之前,假设我们新建了一个名为 `PermissionDemo` 的目录。使用 `cd` 命令进入这个目录,然后使用 `ls -l` 命令查看 Linux 安全管理权限信息。如果你想以时间为序排列,加上 `-t` 选项 + + +``` +`ls -lt` +``` + +因为这一目录下没有文件,所以这一命令执行不会返回结果。 + +![No output from ls -l command][2] + +要了解关于 `ls` 命令的更多信息,请通过在命令行中输入 `man ls` 来查看命令手册。 + +![ls man page][3] + +现在,让我们创建两个名为 `cat.txt` 和 `dog.txt` 的空白文件;这一步使用 `touch` 命令将更为简便。然后继续使用 `mkdir` 命令创建一个名为 `Pets` 的空目录。我们可以再次使用`ls -l`命令查看这些新文件的权限。 + +![Creating new files and directory][4] + +我们需要留意这个命令输出结果的两个部分。 + +### 谁拥有权限? + +首先要注意的是*谁*具有访问文件/目录的权限。请注意下面红色框中突出显示的部分。第一列是指具有访问权限的*用户*,而第二列是指具有访问权限的*组*。 + +![Output from -ls command][5] + +用户的类型主要有三种:用户、组和其他人(本质上既不是用户也不是组)。还有一个*全部*,意思是几乎所有人。 + +![User types][6] + +由于我们使用 `root` 作为当前用户,所以我们可以访问任何文件或目录,因为 `root` 是超级用户。然而,通常情况并非如此,你可能会被限定使用你的普通用户登录。所有的用户都存储在 `/etc/passwd` 文件中。 + +![/etc/passwd file][7] + +“组“的相关信息保存在 `/etc/group` 文件中。 + +![/etc/passwd file][8] + +### 他们有什么权限? + +我们需要注意的是 `ls -l` 命令输出结果的另一部分与执行权限有关。以上,我们查看了创建的 `dog.txt` 和 `cat.txt` 文件以及 `Pets` 目录的所有者和组权限都属于 `root` 用户。我们可以通过这一信息了解到不同用户组所拥有的相应权限,如下面的红色框中的标示。 + +![Enforcing permissions for different user ownership types][9] + +我们可以把每一行分解成五部分。第一部分标志着它是文件还是目录:文件用 `-`(连字符)标记,目录用 `d` 来标记。接下来的三个部分分别是用户、组和其他人的对应权限。最后一部分是[访问控制列表][10] (ACL)的标志,是记录着特定用户或者用户组对该文件的操作权限的列表。 + +![Different Linux permissions][11] + +Linux 的权限级别可以用字母或数字标识。有三种权限类型: + + * 可读取:`r` 或 `4` + * 可写入:`w` 或 `2` + * 可执行:`x` 或 `1` + +(LCTT 译注:原文此处对应的字母标示 `x` 误写为 `e`,已更正) + +![Privilege types][12] + +每个字母符号(`r`、`w` 或 `x`)表示有该项权限,而 `-` 表示无该项权限。在下面的示例中,文件的所有者可读可写,用户组成员仅可读,其他人可读可执行。转换成数字表示法,对应的是 `645`(如何计算,请参见下图的图示)。 + +![Permission type example][13] + +以下是一些示例: + +![Permission type examples][14] + +完成下面的测试,检查你是否掌握了权限管理相关的知识。 + +![Permission type examples][15] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/understanding-linux-permissions + +作者:[Bryant Son][a] +选题:[lujun9972][b] +译者:[qfzy1233](https://github.com/qfzy1233) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/brson/users/greg-p/users/tj +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/yearbook-haff-rx-linux-file-lead_0.png?itok=-i0NNfDC (Hand putting a Linux file folder into a drawer) +[2]: https://opensource.com/sites/default/files/uploads/1_3.jpg (No output from ls -l command) +[3]: https://opensource.com/sites/default/files/uploads/1_man.jpg (ls man page) +[4]: https://opensource.com/sites/default/files/uploads/2_6.jpg (Creating new files and directory) +[5]: https://opensource.com/sites/default/files/uploads/3_2.jpg (Output from -ls command) +[6]: https://opensource.com/sites/default/files/uploads/4_0.jpg (User types) +[7]: https://opensource.com/sites/default/files/uploads/linuxpermissions_4_passwd.jpg (/etc/passwd file) +[8]: https://opensource.com/sites/default/files/uploads/linuxpermissions_4_group.jpg (/etc/passwd file) +[9]: https://opensource.com/sites/default/files/uploads/linuxpermissions_5.jpg (Enforcing permissions for different user ownership types) +[10]: https://en.wikipedia.org/wiki/Access-control_list +[11]: https://opensource.com/sites/default/files/uploads/linuxpermissions_6.jpg (Different Linux permissions) +[12]: https://opensource.com/sites/default/files/uploads/linuxpermissions_7.jpg (Privilege types) +[13]: https://opensource.com/sites/default/files/uploads/linuxpermissions_8.jpg (Permission type example) +[14]: https://opensource.com/sites/default/files/uploads/linuxpermissions_9.jpg (Permission type examples) +[15]: https://opensource.com/sites/default/files/uploads/linuxpermissions_10.jpg (Permission type examples) diff --git a/published/201907/20190619 Leading in the Python community.md b/published/201907/20190619 Leading in the Python community.md new file mode 100644 index 0000000000..9e75b8db87 --- /dev/null +++ b/published/201907/20190619 Leading in the Python community.md @@ -0,0 +1,70 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11049-1.html) +[#]: subject: (Leading in the Python community) +[#]: via: (https://opensource.com/article/19/6/naomi-ceder-python-software-foundation) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +领导 Python 社区 +====== + +> 对话现任 Python 软件基金会董事会主席 Naomi Ceder。 + +![](https://img.linux.net.cn/data/attachment/album/201907/03/155715vrhkvapiiia9i3zp.jpg) + +和开源软件世界的很多其他领袖一样,[Python 软件基金会][3](PSF)的董事会主席 [Naomi Ceder][2] 通过一种不同寻常的方式走进了 Python 世界。正如她在 2017 年 PyCon España 大会上的 [keynote][4] 的标题所说,她是因为这个编程语言而来,因为这个社区而留下的。在我们和她的一次近期的交流中,她分享了自己成为 Python 社区领袖的历程,并且就“是什么让 Python 如此特别”这个问题提供了一些独到的见解。 + +### 从授课到编程 + +Naomi 的职业生涯是从古典文学开始的。她取得了拉丁文和古希腊文的博士学位,并且辅修了印欧语言学。在一家私立学校教授拉丁语的同时,她开始接触了计算机,学习如何编程、如何拆机进行升级或者维修。1995 年,她开始在 [Yggdrasil Linux][5] 系统上开发开源软件,并且帮助建立了印第安纳州韦恩堡的 [Linux 用户小组][6]。 + +作为一名教师,Naomi 相信在中学教授编程课程是非常重要的,因为等到大多数人上大学的时候,他们已经认为编程和科技相关的职业已经不是自己可以从事的了。她表示,更早地教授相关课程有助于增加科技人才的供给,提高人才的多元化和经验的广度,从而更好地满足行业需求。 + +大约在 2001 年前后,她决定从学习人类语言转向研究计算机语言,并同时教授计算机课程和管理学校的 IT 系统。在 2001 年的 Linux World 大会上听了一整天时任 PSF 主席 Guido Van Rossum (LCTT 译注:也是 Python 创始人)关于 Python 的演讲之后,她对 Python 的热情被点燃了。在那个时候,Python 还只是一门晦涩难懂的语言,但是她是如此喜欢 Python,以至于在她的学校开始使用 Python 记录学生信息、进行系统管理。 + +### 领导 Python 社区 + +Naomi 表示,“社区是 Python 成功背后的关键因素。开源软件的核心思想是分享,很少有人真的喜欢一个人坐在那儿盯着屏幕写代码。真正的满足来源于和别人交流想法,并且共同创造一些东西。” + +她在第一届 [PyCon][7] 大会上发表了演讲,并且从此之后一直是一名参与者和领导者。她组织了一些 趣味相投birds-of-a-feather 讨论会(LCTT 译注:birds-of-a-feather,一种在大会参与者之间进行的基于兴趣的非正式小规模讨论活动)、PyCon 和 PyCon UK 大会的海报展示会、教育峰会,以及 PyCon 大会的西班牙语频道。 + +她同时是 《[The Quick Python Book][9]》一书的作者,并且联合创立了 [Trans*Code][10],“英国唯一一个专注于变性者的问题和机遇的黑客节”(LCTT 译注:黑客节hack event是一种让软件开发、设计、项目管理等相关人员相聚在一起,针对软件项目进行高强度合作的活动)。Naomi 表示,“随着科技能够提供越来越多的机遇,确保传统意义上的边缘化群体能够同等地享受到这些机遇成为了一件更为重要的事情。” + +### 通过 PSF 进行贡献 + +作为 PSF 的董事会主席,Naomi 积极地参与着该组织对 Python 语言和其使用者的支持工作。除了赞助 PyCon 大会的举办之外,PSF 基金会还为世界各地的小型聚会、大型会议和研习会提供资助。2018 年,该组织发放的资助接近 335000 美元,其中大多数款项的金额都在 500 美元到 5000 美元之间。 + +PSF 的短期目标是成为一个由专业人员维护的可持续的、稳定的、成熟的非盈利机构。它的长期目标包括发展可以提供对 Python 开发工作有效支持的各种资源,以及扩展该组织对全世界范围内 Python 教育工作的支持。 + +这些工作都需要来自社区的经济上的支持。Naomi 表示,PSF “最大的资金来源是 PyCon 大会。为了确保 PSF 的可持续性,我们同时也关注使用 Python 的企业的赞助,这是我们增长最快的部分。”会员费是每年 99 美元,并且 [捐款和募捐人][12] 同样也在帮助维持该组织的工作。 + +你可以在 PSF 的 [年度报告][13] 中了解该组织的更多工作情况。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/naomi-ceder-python-software-foundation + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_HighTrust_1110_A.png?itok=EF5Tmcdk (Hands together around the word trust) +[2]: https://www.naomiceder.tech/pages/about/ +[3]: https://www.python.org/psf/ +[4]: https://www.youtube.com/watch?v=ayQK6app_wA +[5]: https://en.wikipedia.org/wiki/Yggdrasil_Linux/GNU/X +[6]: http://fortwaynelinux.org/about +[7]: http://pycon.org/ +[8]: https://twitter.com/pyconcharlas?lang=en +[9]: https://www.manning.com/books/the-quick-python-book-third-edition +[10]: https://www.trans.tech/ +[11]: https://www.python.org/psf/sponsorship/ +[12]: https://www.python.org/psf/donations/ +[13]: https://www.python.org/psf/annual-report/2019/ diff --git a/published/201907/20190621 Three Ways to Lock and Unlock User Account in Linux.md b/published/201907/20190621 Three Ways to Lock and Unlock User Account in Linux.md new file mode 100644 index 0000000000..870285a844 --- /dev/null +++ b/published/201907/20190621 Three Ways to Lock and Unlock User Account in Linux.md @@ -0,0 +1,294 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguagnzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11043-1.html) +[#]: subject: (Three Ways to Lock and Unlock User Account in Linux) +[#]: via: (https://www.2daygeek.com/lock-unlock-disable-enable-user-account-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +在 Linux 中锁定和解锁用户帐户的三种方法 +====== + +![](https://linux.cn/article-11043-1.html) + +如果你已经在你的组织中实施了某种密码策略,你无需看这篇文章了。但是在这种情况下,如果你给账户设置了 24 小时的锁定期,你需要手动解锁用户帐户。 + +本教程将帮助你在 Linux 中手动锁定和解锁用户帐户。 + +这可以通过三种方式使用以下两个 Linux 命令来完成。 + +* `passwd`:用于更新用户的身份验证令牌。这个任务是通过调用 Linux PAM 和 libuser API 来实现。 +* `usermod`:用于修改/更新给定用户的帐户信息。它用于将用户添加到特定的组中等等功能。 + +为了说明这一点,我们选择 `daygeek` 用户帐户。让我们看看,怎么一步步来实现的。 + +请注意,你必须使用你需要锁定或解锁的用户的帐户,而不是我们的帐户。你可以使用 `id` 命令检查给定的用户帐户在系统中是否可用。是的,我的这个帐户在我的系统中是可用的。 + +``` +# id daygeek + +uid=2240(daygeek) gid=2243(daygeek) groups=2243(daygeek),2244(ladmin) +``` + +### 方法1: 如何使用 passwd 命令锁定、解锁和检查 Linux 中给定用户帐户的状态? + +`passwd` 命令是 Linux 管理员经常使用的命令之一。它用于更新 `/etc/shadow` 文件中用户的身份验证令牌。 + +使用 `-l` 开关运行 `passwd` 命令,锁定给定的用户帐户。 + +``` +# passwd -l daygeek + +Locking password for user daygeek. +passwd: Success +``` + +你可以通过 `passwd` 命令或从 `/etc/shadow` 文件中获取给定用户名来检查锁定的帐户状态。 + +使用 `passwd` 命令检查用户帐户锁定状态。 + +``` +# passwd -S daygeek +或 +# passwd --status daygeek + +daygeek LK 2019-05-30 7 90 7 -1 (Password locked.) +``` + +这将输出给定帐户密码状态的简短信息。 + +* `LK`:密码被锁定 +* `NP`:没有设置密码 +* `PS`:密码已设置 + +使用 `/etc/shadow` 文件检查锁定的用户帐户状态。如果帐户已被锁定,密码前面将添加两个感叹号。 + +``` +# grep daygeek /etc/shadow + +daygeek:!!$6$tGvVUhEY$PIkpI43HPaEoRrNJSRpM3H0YWOsqTqXCxtER6rak5PMaAoyQohrXNB0YoFCmAuh406n8XOvBBldvMy9trmIV00:18047:7:90:7::: +``` + +使用 `-u` 开关运行 `passwd` 命令,可以解锁给定的用户帐户。 + +``` +# passwd -u daygeek + +Unlocking password for user daygeek. +passwd: Success +``` + +### 方法2:如何使用 usermod 命令在 Linux 中锁定、解锁和检查给定用户帐户的状态? + +`usermod` 命令也经常被 Linux 管理员使用。`usermod` 命令用于修改/更新给定用户的帐户信息。它用于将用户添加到特定的组中,等等。 + +使用 `-L` 开关运行 `usermod` 命令,锁定给定的用户帐户。 + +``` +# usermod --lock daygeek +或 +# usermod -L daygeek +``` + +你可以通过 `passwd` 命令或从 `/etc/shadow` 文件中获取给定用户名来检查锁定的帐户状态。 + +使用 `passwd` 命令检查用户帐户锁定状态。 + +``` +# passwd -S daygeek +或 +# passwd --status daygeek + +daygeek LK 2019-05-30 7 90 7 -1 (Password locked.) +``` + +这将输出给定帐户密码状态的简短信息。 + +* `LK`:密码被锁定 +* `NP`:没有设置密码 +* `PS`:密码已设置 + +使用 `/etc/shadow` 文件检查锁定的用户帐户状态。如果帐户已被锁定,密码前面将添加两个感叹号。 + +``` +# grep daygeek /etc/shadow + +daygeek:!!$6$tGvVUhEY$PIkpI43HPaEoRrNJSRpM3H0YWOsqTqXCxtER6rak5PMaAoyQohrXNB0YoFCmAuh406n8XOvBBldvMy9trmIV00:18047:7:90:7::: +``` + +使用 `-U` 开关运行 `usermod` 命令以解锁给定的用户帐户。 + +``` +# usermod --unlock daygeek +或 +# usermod -U daygeek +``` + +### 方法-3:如何在 Linux 中使用 usermod 命令禁用、启用对给定用户帐户的 SSH 访问? + +`usermod` 命令也是经常被 Linux 管理员使用的命令。`usermod` 命令用于修改/更新给定用户的帐户信息。它用于将用户添加到特定的组中,等等。 + +替代的,锁定可以通过将 `nologin` shell 分配给给定用户来完成。为此,可以运行以下命令。 + +``` +# usermod -s /sbin/nologin daygeek +``` + +你可以通过从 `/etc/passwd` 文件中给定用户名来检查锁定的用户帐户详细信息。 + +``` +# grep daygeek /etc/passwd + +daygeek:x:2240:2243::/home/daygeek:/sbin/nologin +``` + +我们可以通过分配回原来的 shell 来启用用户的 ssh 访问。 + +``` +# usermod -s /bin/bash daygeek +``` + +### 如何使用 shell 脚本锁定、解锁和检查 Linux 中多个用户帐户的状态? + +如果你想锁定/解锁多个帐户,那么你需要找个脚本。 + +是的,我们可以编写一个小的 shell 脚本来执行这个操作。为此,请使用以下 shell 脚本。 + +创建用户列表。每个用户信息在单独的行中。 + +``` +$ cat user-lists.txt + +u1 +u2 +u3 +u4 +u5 +``` + +使用以下 shell 脚本锁定 Linux中 的多个用户帐户。 + +``` +# user-lock.sh + +#!/bin/bash +for user in `cat user-lists.txt` +do + passwd -l $user +done +``` + +将 `user-lock.sh` 文件设置为可执行权限。 + +``` +# chmod + user-lock.sh +``` + +最后运行脚本来达成目标。 + +``` +# sh user-lock.sh + +Locking password for user u1. +passwd: Success +Locking password for user u2. +passwd: Success +Locking password for user u3. +passwd: Success +Locking password for user u4. +passwd: Success +Locking password for user u5. +passwd: Success +``` + +使用以下 shell 脚本检查锁定的用户帐户。 + +``` +# vi user-lock-status.sh + +#!/bin/bash +for user in `cat user-lists.txt` +do + passwd -S $user +done +``` + +设置 `user-lock-status.sh` 可执行权限。 + +``` +# chmod + user-lock-status.sh +``` + +最后运行脚本来达成目标。 + +``` +# sh user-lock-status.sh + +u1 LK 2019-06-10 0 99999 7 -1 (Password locked.) +u2 LK 2019-06-10 0 99999 7 -1 (Password locked.) +u3 LK 2019-06-10 0 99999 7 -1 (Password locked.) +u4 LK 2019-06-10 0 99999 7 -1 (Password locked.) +u5 LK 2019-06-10 0 99999 7 -1 (Password locked.) +``` + +使用下面的 shell 脚本来解锁多个用户。 + +``` +# user-unlock.sh + +#!/bin/bash +for user in `cat user-lists.txt` +do + passwd -u $user +done +``` + +设置 `user-unlock.sh` 可执行权限。 + +``` +# chmod + user-unlock.sh +``` + +最后运行脚本来达成目标。 + +``` +# sh user-unlock.sh + +Unlocking password for user u1. +passwd: Success +Unlocking password for user u2. +passwd: Success +Unlocking password for user u3. +passwd: Success +Unlocking password for user u4. +passwd: Success +Unlocking password for user u5. +passwd: Success +``` + +运行相同的 shell 脚本 `user-lock-status.sh`,检查这些锁定的用户帐户在 Linux 中是否被解锁。 + +``` +# sh user-lock-status.sh + +u1 PS 2019-06-10 0 99999 7 -1 (Password set, SHA512 crypt.) +u2 PS 2019-06-10 0 99999 7 -1 (Password set, SHA512 crypt.) +u3 PS 2019-06-10 0 99999 7 -1 (Password set, SHA512 crypt.) +u4 PS 2019-06-10 0 99999 7 -1 (Password set, SHA512 crypt.) +u5 PS 2019-06-10 0 99999 7 -1 (Password set, SHA512 crypt.) +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/lock-unlock-disable-enable-user-account-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 diff --git a/published/201907/20190624 With Upgraded Specs, Raspberry Pi 4 Takes Aim at Desktop Segment.md b/published/201907/20190624 With Upgraded Specs, Raspberry Pi 4 Takes Aim at Desktop Segment.md new file mode 100644 index 0000000000..54d28b5d1f --- /dev/null +++ b/published/201907/20190624 With Upgraded Specs, Raspberry Pi 4 Takes Aim at Desktop Segment.md @@ -0,0 +1,102 @@ +[#]: collector: (lujun9972) +[#]: translator: (wahailin) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11039-1.html) +[#]: subject: (With Upgraded Specs, Raspberry Pi 4 Takes Aim at Desktop Segment) +[#]: via: (https://itsfoss.com/raspberry-pi-4/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +升级配置后,树莓派 4 瞄准了桌面市场 +====== + +> 树莓派 4 升级配置后开始发售,其 RAM 配置最高可达 4 GB,并支持双 4k 显示。最新硬件配置下,你可以轻松将其作为桌面使用。起售价格依然和旧有型号一样,为 35 美元。 + +树莓派基金会已经发布了最新版的[树莓派 4B][1] 单板计算机。 + +在升级了几个重要特性后,树莓派 4 成为了 40 美元以下的[单板计算机][2]市场中最强大的产品。 + +![Raspberry Pi 4][3] + +### 树莓派 4 的新特性 + +树莓派 4 开始支持双 4k 显示器设置 —— 如果你对此有所需求的话。除此外,它还配备了更强大的处理器,其搭载的 RAM 最高可达 4 GB,这几乎可以媲美一个中端的便携电脑。 + +本次配置升级使树莓派可以参与[迷你 Linux 机][4]市场的竞争,而依旧 35 美元的起始售价使其比[其它单板计算机][2]更具优势。 + +树莓派 4 发布不久,各大主要的在线商店就几乎销售一空。那么,我们来看看它有哪些新卖点吧。 + +#### 树莓派 4 的核心配置 + +![Raspberry Pi 4 Tech Specs][5] + + * 博通 BCM2711,1.5 GHz 64 位 4 核心 Cortex-A72(ARM v8) + * 顶配 4 GB RAM(可选 RAM 配置为 1 GB,2 GB 和 4 GB) + * 无线网络和蓝牙 5.0 + * 两个 USB 3.0 接口,两个 USB 2.0 接口 + * 40 针 GPIO 引脚(向前兼容) + * 两个 Micro-HDMI 接口(支持 4k 显示) + * USB-C(供电接口) + * 千兆以太网 + +如果你想更深入的了解配置信息,可以参考树莓派网站的[官方技术规格][6]。 + +### 定价和可用性 + +树莓派 4 的板子起始售价为 35 美元,根据可选配置不同(1-4 GB),售价也不同。 + + * 1 GB RAM 树莓派 4 售价:35 美元 + * 2 GB RAM 树莓派 4 售价:45 美元 + * 4 GB RAM 树莓派 4 售价:55 美元 + +根据你所在国家或地区的不同,树莓派 4 有不同的供应商。现有库存即将售罄,如果你想购买一定尽快,否则就要再等上一段时日了,你还可以参考官方页面上的购买信息。 + +- [购买树莓派 4][1] + +请注意,[运行树莓派需要额外的配件][7],这就是为什么官方提供了可选的基础套件,套件中包含了所有必需的支持配件。 + +#### 树莓派 4 桌面套件 + +![Raspberry Pi 4 Desktop Kit][9] + +你可以在购买树莓派 4 时同时购买树莓派 4 的桌面套件:外壳、键盘、鼠标、micro HDMI 线、USB-C 电源、用户指南以及[预装了 Rasbian 的 16 GB microSD 卡][10]。 + +![Raspberry Pi Branded Desktop Kit][11] + +整组套件采用红白颜色设计,看起来很美观(如果你关心外观的话)。你可以在树莓派网站上获取更多的购买信息。 + +- [树莓派 4 桌面套件][12] + +### 树莓派 4 的前景 + +拥有所有这些配置后,树莓派 4 无疑会成为同类产品中最好的之一。同样,相比购买入门级桌面计算机,购买树莓派 4 也会是更好的选择。你可以只花很便宜的价格,就能轻松访问文档、管理电子表格,以及完成更多其它操作。 + +我绝对会考虑购买树莓派 4 作为备用(但强大)的入门级桌面计算机,但不会配备 4k 显示器,但依据文档,树莓派 4 肯定是支持双 4k 显示设置的。 + +你怎么评价最新版的树莓派 4B? 欢迎在评论中说出你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/raspberry-pi-4/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wahailin](https://github.com/wahailin) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.raspberrypi.org/products/raspberry-pi-4-model-b/ +[2]: https://itsfoss.com/raspberry-pi-alternatives/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/raspberry-pi-4.jpeg?resize=800%2C449&ssl=1 +[4]: https://itsfoss.com/linux-based-mini-pc/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/raspberry-pi-4-tech-specs.jpg?ssl=1 +[6]: https://www.raspberrypi.org/products/raspberry-pi-4-model-b/specifications/ +[7]: https://itsfoss.com/things-you-need-to-get-your-raspberry-pi-working/ +[8]: https://itsfoss.com/raspberry-pi-gets-ram-upgrade-in-the-same-price/ +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/raspberry-pi-4-desktop-kit.jpg?resize=800%2C427&ssl=1 +[10]: https://itsfoss.com/tutorial-how-to-install-raspberry-pi-os-raspbian-wheezy/ +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/raspberry-pi-desktop-kit-official.jpg?ssl=1 +[12]: https://www.raspberrypi.org/products/raspberry-pi-4-desktop-kit/ diff --git a/published/201907/20190625 5 tiny Linux distros to try before you die.md b/published/201907/20190625 5 tiny Linux distros to try before you die.md new file mode 100644 index 0000000000..1105ff0e52 --- /dev/null +++ b/published/201907/20190625 5 tiny Linux distros to try before you die.md @@ -0,0 +1,264 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11040-1.html) +[#]: subject: (5 tiny Linux distros to try before you die) +[#]: via: (https://opensource.com/article/19/6/linux-distros-to-try) +[#]: author: (Seth Kenlon https://opensource.com/users/seth/users/marcobravo) + +不容错过的 5 个微型 Linux 发行版 +====== + +> 这些微型 Linux 发行版可以让你的老爷机复活,可以启动一个损坏的系统,或者是确保在公共电脑上进行安全的操作。 + +![](https://img.linux.net.cn/data/attachment/album/201907/01/123700uva8cagcqywwj8jv.jpg) + +可供日常使用的 Linux 发行版比比皆是,不过其中有一些发行版常常被我们忽视,因为它们实在是太小了。但这些微型 Linux 发行版其实是一种非常强大的创新:使用一套完整的操作系统驱动一台只有不到 1 GB 存储空间和 512 MB 内存的计算机,真的是终极的黑客作风。 + +微型发行版的用法有很多种,比如说: + + * 从垃圾桶边挽救回那些又老又慢的电脑。你可以继续使用那些本来已经计划报废的机器,直到它们彻底解体(而不是在刚开始感觉有点儿慢的时候就扔掉)。 + * 使用 U盘启动一个损坏的系统来恢复数据或者修复启动分区。 + * 确保在安全和隐私的操作环境下使用公共电脑。如果使用 U 盘启动酒店大厅或者图书馆里的一台公共电脑,你是可以确定操作环境是安全的。 + +轻量级发行版有很多种,比如说 [Lubuntu][2]、[Peppermint OS][3] 和 [Bodhi][4],但是那些真正微型的发行版又有一些独到之处。下面就是你不容错过的五个微型发行版: + +### Tiny Core + +![Tiny Core Linux][5] + +[Tiny Core Linux][6] 小得近乎不可思议:终端版本只有 11 MB,图形界面版本只有 16 MB。我翻了一下之前收集的旧 U盘,最小的一个是 128 MB 的,也有 Tiny Core 镜像文件的八倍之大呢。 + +Tiny Core 默认包括只包括了基本的操作系统,你需要通过以太网下载需要的应用程序。由于设计得极端精简,甚至安装完整操作系统的应用程序都没有被包含在内(不过需要的话可以从 Tiny Core 的软件仓库下载)。 + +我使用过一个 128 MB 的 U盘在一台只有 512 MB 内存的机器上运行了 Tiny Core,对于一个只有 16 MB 的操作系统来说,效果算是非常棒了。只有在使用网页浏览器的时候速度才会变慢,但这主要是由于大部分现代网站太过复杂,而不是 Tiny Core 的问题。 + +如果不使用图形界面,运行 Tiny Core 就只需要 64 MB 的内存了。 + +#### 安装 + +[下载 Tiny Core][7] 并使用 `dd` 或者 [Etcher][8] 写入 U盘。 + +你只需要点击屏幕底部启动栏上的 **Apps** 图标下载 **tc-install** 或者 **tc-install-GUI** 应用,就可以轻松安装 Tiny Core了。 + +![Tiny Core installer][9] + +安装 Tiny Core 有几种不同的方式。你可以把它安装在一个格式化为 Linux 驱动器的 U盘里(这要求你的电脑支持使用 USB 驱动启动。大多数现代电脑都支持,但是在老一些的电脑上不太常见),或者安装在微软 FAT 文件系统的 U 盘里(这对于大多数不支持从 USB 驱动启动的电脑来说非常管用),或者甚至安装在一个现有 Linux 分区的一个文件夹里。 + +安装过程非常快,完成之后就可以重启计算机,进入到 Tiny Core Linux 系统中啦。 + +#### 应用程序 + +由于系统自带程序基本上只有一个文本编辑器和一个终端,你所要做的第一件事情就应该是安装一些应用程序。底部启动栏上的 **Apps** 图标展示了 Tiny Core 提供的所有软件包。**Apps** 软件仓库同时包含了一些重要的驱动程序,对于使用 WiFi 网卡或者是打印机等等都很有帮助。 + +在安装一个新的应用程序或者实用程序的时候,你可以选择在 Tiny Core 启动的时候就加载软件包,或者是需要的时候才加载。如果选择启动时加载,那么不仅该软件立即就可以使用,并且(不出所料地)下次重启之后也依然可用;如果选择需要时加载,那么在软件包下载完成之后仍然可以马上使用,但是重启之后就不会被自动加载到内存中了。这样可以保持很快的开机速度,并且只占用很少的内存,但同时也意味着每次开机之后,该应用的软件包只有在第一次被使用的时候才会被加载到内存中。 + +可供选择的应用程序同时包括像 office 和图像应用之类的用户端应用,以及像 [Samba][10] 和网站服务器这种的服务端应用。 + +当然了,随着你在 Tiny Core 上添加的应用程序越来越多,它就不那么“微型”了。不过在 Tiny Core 的网站上我们可以看到,即使是包括了所有 WiFi 驱动程序的 **Tiny Core Plus** 镜像文件也只有大约 100 MB,所以“不那么微型”也仍然很可能比 256 MB 要小很多。 + +#### 结论 + +Tiny Core 非常适合性能不佳的老爷机、用来通过网络启动的镜像文件,以及任何更看重应用而不是操作系统的人。Tiny Core 可以作为一个很好的周末工程来实践:从 16 MB 开始一步步搭建操作系统,直到你感觉这个操作系统已经足够满足你的需求了。 + +### SliTaz + +![SliTaz Linux][11] + +[SliTaz Linux][12] 的镜像文件有大约 51 MB 大小,差不多是 Tiny Core 的四倍,但是包含一整套出色的驱动程序和应用程序。事实上,如果事先不知道的话,你可能会以为是通过一个 1 GB 的 Ubuntu 镜像启动的,因为能想到的任何一个基本启动镜像应该有的东西都在这儿:文本编辑器、网页浏览器、绘画工具、表格工具等等。 + +我使用过一个 128 MB 的 U盘 在一个 512 MB 内存的机器上运行了 SliTaz,效果非常不错。浏览复杂网站的时候性能会下降,但是系统包含的轻量级浏览器 [Midori][13] 可以快速加载绝大多数网站。 + +你可以在启动的时候选择进入没有图形界面的 SliTaz,这样在仅仅只有 64 MB 的机器上也可以很好地运行。 + +#### 安装 + +可供下载的 SliTaz 有很多种,因为它的开发者和社区针对可能存在的限制提供了非常多的版本。比如说,有一种低内存版本可以在只有 24 MB 内存的机器上运行;有一种版本使用 Firefox 而不是 Midori;还有一种版本没有包含额外的应用程序,等等。 + +如果你挑花了眼,只想赶紧选择一个版本尝试一下的话,那就 [下载滚动发布版本吧][14]。这个版本有差不多 50 MB 大小,每周都会更新。如果你爱上了 SliTaz,而滚动发布版本又更新得 *过快* 了的话,可以再选择一个更符合你需求的版本。 + +下载好你选择的 SliTaz 镜像文件之后,你就可以用 `dd` 或者 [Etcher][8] 将它写入 U 盘,然后重启。 + +将 SliTaz 安装在 U 盘或者硬盘上需要通过 **TazPanel** 这个应用程序来实现。它会引导你对硬盘进行需要的分区,然后将 SliTaz 安装在你选择的地方。 + +![SliTaz installer][15] + +#### 应用程序 + +SliTaz 的控制中心是 **TazPanel** 这个应用程序。如果你喜欢 OpenSUSE 或者 Mageia (最初被称为 Mandrake),那 TazPanel 对你来说应该不会陌生(至少在核心思想上):包括系统设置、硬件监测、用户和用户组的管理、系统升级、安装应用程序在内的这些功能,都在这一个应用程序内实现。 + +SliTaz 提供的应用程序可以满足大多数基本需求,如果你不是非常在意完成某一项任务必须使用哪一个应用程序的话,那么在 SliTaz 的软件仓库里应该可以找到你想要的应用。如果你有一些特别的需求(比如说想要使用 GIMP 2.10 而不是 GIMP 2.8),那么就需要学习如何生成 SliTaz 软件包了。好消息是,**tazpkg** 命令支持从好几种软件包格式转换过来,包括: + + * Debian 软件包(.deb,.udeb) + * RPM 软件包(.rpm) + * Slackware 软件包(.tgz) + * Puppy 软件包(.sfs,.pet) + * NuTyX 软件包(.cards.tar.xz) + * Arch 和 Alpine Linux 软件包(.apk,.pkg.tar.gz,.pkg.tar.xz) + * OpenWrt 软件包(.ipk,.opk) + * Paldo 软件包(.tar.bz2) + * Void 软件包(.xbps) + * Tiny Core 软件包(.tce,.tcel,.tcem, .tcz) + +#### 结论 + +SliTaz 是一个快速而小巧的 Linux 发行版,并且非常容易上手(因为有一个中心化的控制面板)。由于它的软件包工具支持从其它格式的 Linux 软件包转换成自己的格式,它的应用程序理论上来说是非常丰富的,你可以很容易地使用喜欢的工具搭建自己的工作环境。SliTaz 很小,但是也非常具有杀伤力,正如它的蜘蛛 logo 所暗示的那样。 + +### Porteus + +![Porteus Linux][16] + +[Porteus][17] 提供了不同的桌面环境可供选择,最小的镜像文件大约在 270 MB 左右,最大的有 350 MB。它是微型 Linux 中镜像文件最大的一个,但是这些额外的空间都被用来确保一个非常顺畅的 Linux 桌面环境的体验,以至于你很可能会忘了自己是在使用一个 live 版本。如果将 Porteus 安装到 SSD 或者是在启动的时候加载到内存里的话,你就会得到一个如此天衣无缝地顺畅的环境,以至于不会相信你的操作系统所占用的空间只有不到半个 CD-ROM 的大小。 + +Porteus 的基础镜像文件相对来说比较小,因此被称为是“微型”,但是根据你选择的桌面环境版本,Porteus 有可能会需要 1 GB 之多的内存才可以运行。尽管其它微型 Linux 发行版倾向于通过精简应用程序来节约空间和资源,Porteus 却希望你像普通发行版一样来使用它。忘掉你是在使用一个微型的压缩根文件系统,尽情安装所有你喜欢的应用程序吧。 + +#### 安装 + +可以在 [离你最近的 Porteus 镜像网站][18] 上下载 Porteus,并且从 MATE、LXQT、LXDE、OpenBox、XFCE、Cinnamon 或者 KDE 里选择自己喜欢的桌面环境。如果没有特殊偏好,MATE 或者是 KDE 桌面都是不错的选择,他们可以提供熟悉的桌面环境体验,并且镜像文件又不至于太大。 + +![Porteus installer][19] + +你可以根据 [官方的安装指南][20] 将 Porteus 安装到一个 U盘 或者是内部硬盘里。这两种方式非常相似,都会使用一个不可变的压缩根文件系统。这是一种稳定的、受限制的文件系统,会根据你的使用被修改。你所做的变更和安装的应用程序在重启的时候都会被加载到内存里,从而还原你关机前的使用环境。 + +#### 应用程序 + +应用程序在 Porteus 里被称为“模块”,由 [Slackware 软件包统一管理器][21](USM)提供。USM 的资源涵盖五个不同的 Slackware 软件仓库,所以可供选择的应用还是很丰富的。 + +#### 结论 + +Porteus 可以提供完整的 Linux 使用体验,却只使用了正常 Linux 所需要空间的一小部分。这是一个配备了很多种可供选择的桌面环境和很多应用程序的出色的便携式 Linux 发行版。 + +### Bodhi Linux + +![Bodhi Linux][22] + +[Bodhi Linux][4] 的 ISO 镜像文件有 740 MB 大小,初看之下并不是很“微型”,不过一旦安装完成之后,你就会惊讶于它是多么微型了。Bodhi 在 512 MB 大小的内存上也可以顺畅运行,并且它的桌面环境看起来就像是来自未来一样。Bodhi 使用的是 [Enlightenment][23] 桌面,这是一个精心制作的优美的用户界面,小巧而强悍。 + +不过 Bodhi 并不只是简单地使用 Enlightenment,而是在此基础上增色不少。Bodhi 在配置型应用程序和系统设置面板上都进行了界面处理,避免了 Enlightenment 有时显得过于繁复的选项。Bodhi 替你做了一些很好的默认选择,并且只显示全部选项的一部分。如果你是一个 Enlightenment 狂热分子,那么 Bodhi 这样的做法对你来说可能显得不是很纯粹,但是对于大多数用户来说,Bodhi 这样做可以让人更加专注于 Enlightenment 桌面本身。 + +#### 安装 + +[下载 Bodhi Linux][24],通过 `dd` 或者 [Etcher][8] 写入 U盘,然后重启。 + +Bodhi 安装器可以在 **设置** 页面的 **应用程序** 菜单里找到。安装程序用的是 **Ubiquity**,所以整个过程和安装 Ubuntu 是一样的。如果你没有安装过 Ubuntu 也不必担心,因为这是最好安装的发行版之一了。 + +![Bodhi installer][25] + +#### 应用程序 + +Bodhi 是基于最新的 Ubuntu 长期维护发布版的,所以可供使用的应用程序简直数不胜数。只要是在 Ubuntu 上可以使用的应用,Bohdi 上就同样可以找到。 + +#### 结论 + +Bodhi Linux 相比一个标准的 Ubuntu 来说要小不少,但是相比其它微型 Ubuntu 环境来说又好一些(因为使用了 Enlightenment)。如果你在找一个比大多数发行版更轻量的 Linux 发行版,但是又不想使用 OverlayFS 或者是应用程序模块的话,那么 Bodhi 就是一个不错的选择了。 + +### Puppy Linux + +![Puppy Linux][26] + +早在 Tiny Core、SliTaz、[AntiX][27] 或者是 Porteus 诞生之前,就已经有 [Puppy Linux][28] 了。作为最早的微型 Linux 发行版之一,Puppy 已经历经了十五年风霜,并且无论是对于老爷机还是新用户来说始终都是一个可靠的、可启动的操作系统。 + +为了保证正常运行,Puppy 会在第一次启动之后引导用户完成必要的设置步骤。整个过程涉及很多个窗口,但是一旦完成,你就会对一切功能了如指掌,然后再决定是否需要安装。 + +Puppy 几乎有 300 MB 大小,并且在我测试的 1 GB 内存的机器上并不能正常运行,所以它并不是一个特别微型的 Linux 发行版。尽管如此,它仍然是一个非常棒的 1 GB 以下的操作系统,并且在该类系统里算是非常友好的一个。 + +#### 安装 + +[下载 Puppy Linux][29],然后通过 `dd` 或 [Etcher][8] 写入 U 盘,或者是刻录到 CD 或者 DVD 里,然后重启。 + +![Puppy installer][30] + +Puppy 几乎可以安装在支持任何一种数据格式的载体上。你可以在顶部启动栏里找到 **Puppy Installer** 安装程序,这个程序负责安装 Puppy 以及 Puppy 的应用程序。 + +Puppy 安装器会一步步引导你将系统安装在你提供的任何一种媒介上。Puppy 可以从 U盘、光盘、硬盘,或者甚至是 SD 卡上启动。我曾经在一台没有硬盘、光驱出了故障,并且也无法从 USB 启动的计算机上成功运行了 Puppy。由于 Puppy 支持在任何载体上写入你的配置选项,我甚至可以在一个拥有长期数据存储的外部设备上使用它。 + +#### 应用程序 + +**Puppy 安装器** 这个应用同样被用来在 Puppy 上安装应用。由于 Puppy 是基于 Ubuntu 的,它的软件仓库几乎不会缺少任何一个 Linux 软件包,并且如果真的出现了这种情况的话,你也可以使用 [Flatpak][31]。 + +#### 结论 + +Puppy 是最早的微型 Linux。尽管它已经不是最微型的了,却是目前最易用的一个。 + +### 附赠:Silverblue + +![SilverBlue, not tiny, but tiny-adjacent][32] + +微型 Linux 这个概念是随着时间不断变化的。很久以前,微型 Linux 发行版意味着需要下载到 CD-R 里,从光驱启动,然后将修改写入外部媒介中。后来,你可以从 U 盘启动它,并且有专门用来记录永久修改的空间。现在的微型 Linux 不仅支持上面两种方法,还可以被直接安装在内部驱动或者文件夹里。 + +大家都没有想到 Linux 开创了容器的热潮 —— 容器里应用程序是在半虚拟化的环境中运行的一套独立的 Linux 系统。曾经只是属于喜欢优化硬盘空间或者重新利用老爷机的人们的小众爱好,很快成为了那些想要开发容器但又不想在应用程序上添加太多负载的人的强烈需求。那些在极简化的、不起眼的 Linux 发行版上所付出的辛苦,一夜之间以一种意想不到的方式得到了回报。 + +立足于根文件系统这个概念,Fedora 项目发起的 [Silverblue][33] 试验旨在创造一个不可修改的操作系统。该操作系统主要通过容器的形式来更新系统以及安装应用,系统本身永远不会改变。 + +2.1 GB 的 Silverblue 可不是一个微型 Linux 发行版,但是从某种程度上来说,它是微型 Linux 和容器运动的产物。 + +#### 安装 + +[下载 Silverblue][34],然后通过 `dd` 琥或 [Etcher][8] 写入 U 盘,或者是刻录到 CD 或者 DVD 里,然后重启。 + +启动到 Silverblue 之后,使用 [Anaconda][35](标准的、友好的 Fedora 安装器)将它安装在一个内部硬盘里。 + +![Anaconda installer][36] + +#### 应用程序 + +Silverblue 安装应用的方式和传统意义上不同:它是在基础操作系统之上运行容器。具体来说,它使用 Flatpak 运行 GUI 应用程序,使用 [Toolbox][37] 运行命令。 + +由于 Flatpak 并非像传统的 Fedora RPM 软件包一样常见,Silverblue 也提供了一种可以将 Fedora RPM 软件包转换成 Silverblue 形式的方法:**软件包分层**。 + +#### 结论 + +Silverblue 可能是一个用来尝试前沿科技的有趣实验,或者也可能是桌面操作系统的未来。它之所以被称为微型,只是因为根文件系统的大小不会随着系统升级或者安装应用而改变。不过,透过 Silverblue 来看看对微型 Linux 的迷恋在带领着 Linux 社区和行业往哪个方向走,也是一件挺有意思的事情。对了,走之前不要忘了向 11 MB 大小的微型 Linux 先驱们脱帽致敬。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/linux-distros-to-try + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth/users/marcobravo +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/yearbook-haff-rx-linux-file-lead_0.png?itok=-i0NNfDC (Hand putting a Linux file folder into a drawer) +[2]: http://lubuntu.net +[3]: http://peppermintos.com +[4]: https://www.bodhilinux.com/ +[5]: https://opensource.com/sites/default/files/uploads/tinycore.jpg (Tiny Core Linux) +[6]: http://tinycorelinux.net/ +[7]: http://tinycorelinux.net/welcome.html +[8]: https://www.balena.io/etcher/ +[9]: https://opensource.com/sites/default/files/uploads/tc-install-gui.png (Tiny Core installer) +[10]: https://www.samba.org/ +[11]: https://opensource.com/sites/default/files/uploads/slitaz.jpg (SliTaz Linux) +[12]: http://www.slitaz.org/en/ +[13]: https://github.com/midori-browser/core +[14]: http://slitaz.org/en/get/#rolling +[15]: https://opensource.com/sites/default/files/uploads/slitaz-install.jpg (SliTaz installer) +[16]: https://opensource.com/sites/default/files/uploads/porteus.jpg (Porteus Linux) +[17]: http://www.porteus.org/ +[18]: http://porteus.org/porteus-mirrors.txt +[19]: https://opensource.com/sites/default/files/images/porteus-installer.png (Porteus installer) +[20]: http://www.porteus.org/component/content/article/26-tutorials/general-info-tutorials/114-official-porteus-installation-guide.html +[21]: http://www.porteus.org/tutorials/9-modules/149-usm.html +[22]: https://opensource.com/sites/default/files/uploads/bodhi.jpg (Bodhi Linux) +[23]: https://www.enlightenment.org/ +[24]: https://www.bodhilinux.com/download +[25]: https://opensource.com/sites/default/files/uploads/bodhi-install.jpg (Bodhi installer) +[26]: https://opensource.com/sites/default/files/uploads/puppy.jpg (Puppy Linux) +[27]: https://antixlinux.com/ +[28]: http://puppylinux.com/ +[29]: http://puppylinux.com/index.html#download +[30]: https://opensource.com/sites/default/files/uploads/puppy-install.jpg (Puppy installer) +[31]: https://docs.fedoraproject.org/en-US/fedora-silverblue/getting-started/#flatpak +[32]: https://opensource.com/sites/default/files/uploads/silverblue.jpg (SilverBlue, not tiny, but tiny-adjacent) +[33]: https://silverblue.fedoraproject.org/ +[34]: https://silverblue.fedoraproject.org/download +[35]: https://fedoraproject.org/wiki/Anaconda +[36]: https://opensource.com/sites/default/files/uploads/silverblue-install.jpg (Anaconda installer) +[37]: https://docs.fedoraproject.org/en-US/fedora-silverblue/toolbox/ diff --git a/published/201907/20190625 The innovation delusion.md b/published/201907/20190625 The innovation delusion.md new file mode 100644 index 0000000000..a2eca0f465 --- /dev/null +++ b/published/201907/20190625 The innovation delusion.md @@ -0,0 +1,90 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11106-1.html) +[#]: subject: (The innovation delusion) +[#]: via: (https://opensource.com/open-organization/19/6/innovation-delusion) +[#]: author: (Jim Whitehurst https://opensource.com/users/jwhitehurst/users/jwhitehurst/users/n8chz/users/dhdeans) + +创新的幻觉 +====== + +> 创新是一种混乱的过程,但是关于创新的故事却很有条理。我们不应该把两者搞混了。 + +![](https://img.linux.net.cn/data/attachment/album/201907/16/120302zlyzlzl2d2vh1eyd.jpg) + +如果说 [传统的规划方法已经消亡了][2],为什么这么多机构还在孜孜不倦地运用那些针对工业革命所设计的规划方法呢? + +其中的一个原因是,我们错误地认为创新是可以通过结构化的、线性的过程实现的。我觉得这样做是在混淆关于创新的 **故事** 和创新这个 **过程** 本身 —— 两者是截然不同的东西。 + +创新的过程是混乱和不可预测的,并不遵循井然有序的时间线。过程中充满了重复迭代、突然的改变方向、各式各样的启动和终止、死胡同、失败(但愿是有用的失败),以及很多不可知的变量。创新是混乱的。 + +但是关于创新的故事却让事情显得很简单,从讲述伟大发明的书籍和文章,到我们(简化了整个过程之后)讲述自己在工作上的成功都是这样。想想你在社交媒体上读的帖子里,有多少都只写了最好的、最愉快的部分吧。 + +好故事就是这样。我们把一些原本分散的时间点干净利落地整理到一起,有开头、有发展、也有结尾。尽管我们一路上经历了很多没有把握、恐慌、甚至是绝望的时刻,在故事里这些坎坷却都被抹平了,让事情看起来像是从一开始就注定是成功的。 + +我们不应该把混乱的过程和简化了的故事搞混。否则,我们会错误地认为可以使用在简单线性过程中所使用的同样的方法迎接创新的挑战。换句话说,我们将适用于一种类型的活动(比较偏死记硬背、机械和规则性的任务)的管理技术应用在了并不适用的另一种类型的活动(更加有创造性的、非线性的工作,需要自主性和试验)上。 + +### 一个创新的故事 + +下面这个故事可以很好地说明这一点。这是我 [最喜欢举的例子][2] 之一。 + +在 1970 年代,英国的摩托车行业怎么也想不明白为什么他们在美国的市场份额急剧下降,而本田公司的市场份额却急速攀升。他们雇佣了波士顿咨询公司(刚好是我之前的雇主)帮助他们找出问题所在。波士顿咨询搜集了一些历史数据,回看了二十年的历史事件,总结出了一个井井有条的、线性的故事,可以很好地解释本田公司的成功。 + +[波士顿咨询的结论是][3],本田公司使用了一个巧妙的策略:通过一种可以以更低价格销售的偏小型摩托车进入美国市场,并且借助于他们在日本本土市场发展出来的规模经济,在美国市场使用低价策略发展市场份额,然后等到需求进一步增长的时候,再利用更大的规模经济发展他们在美国的市场份额。在所有人的眼中,本田公司都表现得非常出色,不仅发挥了自己的优势,还非常透彻和精准地理解了新的目标顾客:美国消费者。他们智胜一筹,通过一个执行得很好的计划占领了先机,胜过了竞争对手们。 + +这个故事 **听上去** 很厉害,但是实际情况没有这么简单。 + +没错,本田公司 **确实** 是想进入美国摩托车市场。他们最初是想 [效仿在美国的竞争对手][4],也制造美国人似乎更喜欢的大型摩托车。但是大型摩托车并不是本田公司的强项,他们生产的大型摩托车存在可靠性上的问题。更糟的是,他们的产品和市面上的其它产品没有什么差别,所以并不能脱颖而出。简单来说,他们的产品销售额表现平平。 + +但是在一次奇妙的巧合里,本田公司出访美国的日本代表们带了几辆自己开的摩托车。这些摩托车和本田公司试图在美国市场上销售的摩托车完全不同,它们更为小巧灵活、不那么笨重、更有效率,并且一般来说也更便宜。西尔斯公司(LCTT 译注:美国零售业巨头)注意到了这些小巧的摩托车,并且和日本代表达成了一项协议,让西尔斯公司可以在他们在美国的商店里出售这种被称为“超级幼兽”的新型摩托车。 + +剩下的故事已经载入史册。超级幼兽成为了 [史上最畅销的机动车][5],并且本田公司 [至今仍然在生产超级幼兽][6]。 + +事后看来,将超级幼兽带到美国的一连串事件似乎很有逻辑,近乎无聊了。但是本田公司的成功和“巧妙的计划”没有什么关系,而更应该归功于一些(大多数人不愿意承认的)机缘巧合。 + +### 开放(并且混乱的)创新 + +机构(特别是领导们)喜欢把成功说成是一件计划之内的事情 —— 好像成功人士可以驾驭混乱,并且几乎可以预测未来。但是这些言论都是事后诸葛亮罢了,他们在讲述自己充满偶然性的经历的时候会刻意将无序的事情整理一番,对于毫无确定性的事情也会说“我们就是想要那么做的”。 + +但是正如我前面说的,我们不应该相信这些故事是创新过程的真实还原,也不应该在这种错误的假设的基础之上去构建未来的方案或者实验。 + +试想有另一家摩托车制造商想要复制本田公司在超级幼兽上的成功,就逐字逐句地照搬波士顿咨询总结的故事。由于本田公司成功的 **故事** 听上去是如此有逻辑,并且是线性的,这家新公司也许会假定他们可以通过类似的程序得到同样的结果:制定目标、谋划行动,然后针对可预期的结果进行执行。但是我们知道本田公司并不是真的靠这种“制定、谋划、执行”的方式赢得他们的市场份额的。他们是通过灵活性和一点运气获得成功的 —— 更像是“尝试、学习、修改”。 + +当我们可以真正理解并且接受“创新过程是混乱的”这个事实的时候,我们就可以换种方式思考如何让我们的机构实现创新了。与其将资源浪费在预先制定的计划上,**强迫** 创新以一种线性时间线的方式发生,我们不如去构建一些开放并且敏捷的机构,可以 **在创新发生的时候做出及时的响应**。 + +几年前红帽公司发布一个包含了重大技术升级的产品的新版本的时候,我就看到了这样的方法。[红帽企业级 Linux 5.4 版本][8] 首次完全支持了一种被称为"基于内核的虚拟机"(KVM)的技术。这对于我们来说是一个重大的创新,不仅可以为顾客和合作伙伴带来巨大的价值,也有望为开源社区带来巨大的价值。 + +这项技术正在快速演进。幸运的事,因为我们是一个开放的机构,我们具有足够的适应能力,可以在这项创新发生的时候做出响应,从而帮助我们的顾客和合作伙伴可以更好地利用它。这项技术太重要了,并且竞争格局也太不稳定了,以至于我们没有理由要等到像 6.0 版本这样的里程碑时刻才出手。 + +如果你回看红帽企业级 Linux [已经存档的发行说明][9],你会发现它读起来并不像一个典型的软件创新的故事。一次改变游戏规则的进展突然出现在一个没有预测到的、并不起眼的时刻(5.4 版本),而不是一个事先计划好的重要里程碑时刻(6.0 版本)。事后看来,我们现在知道 KVM 这种“大爆炸”级别的进步是足够担得起 “6.0 版本”这样的里程碑式的名字的。但是创新并不是按照这样的剧本发生的。 + +不要误解我,机构仍然需要保持出色的运转,高效完成执行性的任务。但是 [不同的挑战需要不同的方法去应对][10],我们需要能够更好地建立灵活的机构,以及对 [意想不到和不可知的事情][11] 能够做出更好的响应。 + +一个在计划工作(以及按照计划执行)上做得很出色的公司很可能会得到他们计划要得到的结果。但是如果成功还取决于我们没有预测或者无法预测的的事情,那么仅仅精准地按照计划执行是不是就不够了? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/19/6/innovation-delusion + +作者:[Jim Whitehurst][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jwhitehurst/users/jwhitehurst/users/n8chz/users/dhdeans +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/innovation_lightbulb_gears_devops_ansible.png?itok=TSbmp3_M (gears and lightbulb to represent innovation) +[2]: https://www.youtube.com/watch?v=8MCbJmZQM9c +[3]: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/235319/0532.pdf +[4]: http://www.howardyu.org/the-revolutionary-approach-honda-took-to-rise-above-competition/ +[5]: https://autoweek.com/article/motorcycles/first-ride-honda-super-cub-c125-abs-all-new-and-still-super-cute +[6]: https://www.autoblog.com/2019/02/13/2019-honda-super-cub-first-ride-review/ +[7]: https://opensource.com/open-organization/18/3/try-learn-modify +[8]: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/5.4_release_notes/index +[9]: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/5.0_release_notes/index +[10]: https://opensource.com/open-organization/19/4/managed-enabled-empowered +[11]: https://www.linkedin.com/pulse/how-plan-world-full-unknowns-jim-whitehurst/ diff --git a/published/201907/20190626 Tracking down library injections on Linux.md b/published/201907/20190626 Tracking down library injections on Linux.md new file mode 100644 index 0000000000..706fa09d1a --- /dev/null +++ b/published/201907/20190626 Tracking down library injections on Linux.md @@ -0,0 +1,130 @@ +[#]: collector: (lujun9972) +[#]: translator: (LuuMing) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11079-1.html) +[#]: subject: (Tracking down library injections on Linux) +[#]: via: (https://www.networkworld.com/article/3404621/tracking-down-library-injections-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +追溯 Linux 上的库注入 +====== +> 库注入Library injections在 Linux 上不如 Windows 上常见,但它仍然是一个问题。下来看看它们如何工作的,以及如何鉴别它们。 + +![](https://img.linux.net.cn/data/attachment/album/201907/09/223222gje7l6a2hjhk364a.jpg) + +尽管在 Linux 系统上几乎见不到,但库(Linux 上的共享目标文件)注入仍是一个严峻的威胁。在采访了来自 AT&T 公司 Alien 实验室的 Jaime Blasco 后,我更加意识到了其中一些攻击是多么的易实施。 + +在这篇文章中,我会介绍一种攻击方法和它的几种检测手段。我也会提供一些展示攻击细节的链接和一些检测工具。首先,引入一个小小的背景信息。 + +### 共享库漏洞 + +DLL 和 .so 文件都是允许代码(有时候是数据)被不同的进程共享的共享库文件。公用的代码可以放进一个文件中使得每个需要它的进程可以重新使用而不是多次被重写。这也促进了对公用代码的管理。 + +Linux 进程经常使用这些共享库。(显示共享对象依赖的)`ldd` 命令可以对任何程序文件显示其共享库。这里有一些例子: + +``` +$ ldd /bin/date + linux-vdso.so.1 (0x00007ffc5f179000) + libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f02bea15000) + /lib64/ld-linux-x86-64.so.2 (0x00007f02bec3a000) +$ ldd /bin/netstat + linux-vdso.so.1 (0x00007ffcb67cd000) + libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f45e5d7b000) + libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f45e5b90000) + libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f45e5b1c000) + libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f45e5b16000) + /lib64/ld-linux-x86-64.so.2 (0x00007f45e5dec000) + libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f45e5af5000) +``` + +`linux-vdso.so.1` (在一些系统上也许会有不同的名字)是内核自动映射到每个进程地址空间的文件。它的工作是找到并定位进程所需的其他共享库。 + +对库加载机制加以利用的一种方法是通过使用 `LD_PRELOAD` 环境变量。正如 Jaime Blasco 在他的研究中所解释的那样,“`LD_PRELOAD` 是在进程启动时加载共享库的最简单且最受欢迎的方法。可以将此环境变量配置到共享库的路径,以便在加载其他共享对象之前加载该共享库。” + +为了展示有多简单,我创建了一个极其简单的共享库并且赋值给我的(之前不存在) `LD_PRELOAD` 环境变量。之后我使用 `ldd` 命令查看它对于常用 Linux 命令的影响。 + +``` +$ export LD_PRELOAD=/home/shs/shownum.so +$ ldd /bin/date + linux-vdso.so.1 (0x00007ffe005ce000) + /home/shs/shownum.so (0x00007f1e6b65f000) <== 它在这里 + libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1e6b458000) + /lib64/ld-linux-x86-64.so.2 (0x00007f1e6b682000) +``` + +注意,仅仅将新的库赋给 `LD_PRELOAD` 就影响到了运行的任何程序。 + +通过设置 `LD_PRELOAD` 指定的共享库首先被加载(紧随 linux-vdso.so.1),这些库可以极大程度上改变一个进程。例如,它们可以重定向系统调用到它们自己的资源,或对程序运行的行为方式进行意想不到的更改。 + +### osquery 工具可以检测库注入 + +`osquery` 工具(可以在 [osquery.io][4]下载)提供了一个非常独特的查看 Linux 系统的方式。它基本上将操作系统视作一个高性能的关系数据库。然后,也许你会猜到,这就意味着它可以用来查询并且生成 SQL 表,该表提供了诸如以下的详细信息: + + * 运行中的进程 + * 加载的内核模块 + * 打开的网络链接 + +一个提供了进程信息的内核表叫做 `process_envs`。它提供了各种进程使用环境变量的详细信息。Jaime Blasco 提供了一个相当复杂的查询,可以使用 `osquery` 识别出使用 `LD_PRELOAD` 的进程。 + +注意,这个查询是从 `process_envs` 表中获取数据。攻击 ID(T1055)参考 [Mitre 对攻击方法的解释][5]。 + +``` +SELECT process_envs.pid as source_process_id, process_envs.key as environment_variable_key, process_envs.value as environment_variable_value, processes.name as source_process, processes.path as file_path, processes.cmdline as source_process_commandline, processes.cwd as current_working_directory, 'T1055' as event_attack_id, 'Process Injection' as event_attack_technique, 'Defense Evasion, Privilege Escalation' as event_attack_tactic FROM process_envs join processes USING (pid) WHERE key = 'LD_PRELOAD'; +``` + +注意 `LD_PRELOAD` 环境变量有时是合法使用的。例如,各种安全监控工具可能会使用到它,因为开发人员需要进行故障排除、调试或性能分析。然而,它的使用仍然很少见,应当加以防范。 + +同样值得注意的是 `osquery` 可以交互使用或是作为定期查询的守护进程去运行。了解更多请查阅文章末尾给出的参考。 + +你也能够通过查看用户的环境设置来定位 `LD_PRELOAD` 的使用。如果在用户账户中使用了 `LD_PRELOAD`,你可以使用这样的命令来查看(假定以个人身份登录后): + +``` +$ env | grep PRELOAD +LD_PRELOAD=/home/username/userlib.so +``` + +如果你之前没有听说过 `osquery`,也别太在意。它正在成为一个更受欢迎的工具。事实上就在上周,Linux 基金会宣布打造了新的 [osquery 基金会][6]以支持 osquery 社区。 + +#### 总结 + +尽管库注入是一个严重的威胁,但了解一些优秀的工具来帮助你检测它是否存在是很有帮助的。 + +#### 扩展阅读 + +重要的参考和工具的链接: + + * [用 osquery 追寻 Linux 库注入][7],AT&T Cybersecurity + * [Linux:我的内存怎么了?][8],TrustedSec + * [下载 osquery][4] + * [osquery 模式][9] + * [osqueryd(osquery 守护进程)][10] + * [Mitre 的攻击框架][11] + * [新的 osquery 基金会成立][6] + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3404621/tracking-down-library-injections-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[LuuMing](https://github.com/LuuMing) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/06/dll-injection-100800196-large.jpg +[2]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua +[3]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr +[4]: https://osquery.io/ +[5]: https://attack.mitre.org/techniques/T1055/ +[6]: https://www.linuxfoundation.org/press-release/2019/06/the-linux-foundation-announces-intent-to-form-new-foundation-to-support-osquery-community/ +[7]: https://www.alienvault.com/blogs/labs-research/hunting-for-linux-library-injection-with-osquery +[8]: https://www.trustedsec.com/2018/09/linux-hows-my-memory/ +[9]: https://osquery.io/schema/3.3.2 +[10]: https://osquery.readthedocs.io/en/stable/deployment/configuration/#schedule +[11]: https://attack.mitre.org/ +[12]: https://www.facebook.com/NetworkWorld/ +[13]: https://www.linkedin.com/company/network-world diff --git a/published/201907/20190627 How to use Tig to browse Git logs.md b/published/201907/20190627 How to use Tig to browse Git logs.md new file mode 100644 index 0000000000..53629b1d19 --- /dev/null +++ b/published/201907/20190627 How to use Tig to browse Git logs.md @@ -0,0 +1,202 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11069-1.html) +[#]: subject: (How to use Tig to browse Git logs) +[#]: via: (https://opensource.com/article/19/6/what-tig) +[#]: author: (Olaf Alders https://opensource.com/users/oalders/users/mbbroberg/users/marcobravo) + +如何使用 Tig 浏览 Git 日志 +====== + +> Tig 可不仅仅是 Git 的文本界面。以下是它如何增强你的日常工作流程。 + +![](https://img.linux.net.cn/data/attachment/album/201907/07/111847v1zx3qk5qqhklyjp.png) + +如果你使用 Git 作为你的版本控制系统,你可能已经让自己接受了 Git 是一个复杂的野兽的事实。它是一个很棒的工具,但浏览 Git 仓库可能很麻烦。因此像 [Tig][2] 这样的工具出现了。 + +来自 [Tig 手册页][3]: + +> Tig 是 `git`(1) 的基于 ncurses 的文本界面。它主要用作 Git 仓库浏览器,但也有助于在块级别暂存提交更改,并作为各种 Git 命令的输出分页器。 + +这基本上意味着 Tig 提供了一个可以在终端中运行的基于文本的用户界面。Tig 可以让你轻松浏览你的 Git 日志,但它可以做的远不止让你从最后的提交跳到前一个提交。 + +![Tig screenshot][4] + +这篇快速入门的 Tig 中的许多例子都是直接从其出色的手册页中拿出来的。我强烈建议你阅读它以了解更多信息。 + +### 安装 Tig + +* Fedora 和 RHEL: `sudo dnf install tig` +* Ubuntu 和 Debian: `sudo apt install tig` +* MacOS: `:brew install tig` + +有关更多方式,请参阅官方[安装说明][5]。 + +### 浏览当前分支中的提交 + +如果要浏览分支中的最新提交,请输入: + +``` +tig +``` + +就是这样。这个三字符命令将启动一个浏览器,你可以在其中浏览当前分支中的提交。你可以将其视为 `git log` 的封装器。 + +要浏览这些输出,可以使用向上和向下箭头键从一个提交移动到另一个提交。按回车键将会垂直分割窗口,右侧包含所选提交的内容。你可以继续在左侧的提交历史记录中上下浏览,你的更改将显示在右侧。使用 `k` 和 `j` 可以逐行上下浏览,`-` 和空格键可以在右侧上下翻页。使用 `q` 退出右侧窗格。 + +搜索 `tig` 输出也很简单。使用 `/` (向前)或 `?` (向后)在左右窗格中搜索。 + +![Searching Tig][6] + +这些就足以让你浏览你的提交信息了。这里有很多的键绑定,但单击 `h` 将显示“帮助”菜单,你可以在其中发现其导航和命令选项。你还可以使用 `/` 和 `?` 来搜索“帮助”菜单。使用 `q` 退出帮助。 + +![Tig Help][7] + +### 浏览单个文件的修改 + +由于 Tig 是 `git log` 的封装器,它可以方便地接受可以传递给 `git log` 的相同参数。例如,要浏览单个文件的提交历史记录,请输入: + +``` +tig README.md +``` + +将其与被封装的 Git 命令的输出进行比较,以便更清楚地了解 Tig 如何增强输出。 + +``` +git log README.md +``` + +要在原始 Git 输出中包含补丁,你可以添加 `-p` 选项: + +``` +git log -p README.md +``` + +如果要将提交范围缩小到特定日期范围,请尝试以下操作: + +``` +tig --after="2017-01-01" --before="2018-05-16" -- README.md +``` + +再一次,你可以将其与原始的 Git 版本进行比较: + + +``` +git log --after="2017-01-01" --before="2018-05-16" -- README.md +``` + +### 浏览谁更改了文件 + +有时你想知道谁对文件进行了更改以及原因。命令: + +``` +tig blame README.md +``` + +器本质上是 `git blame` 的封装。正如你所期望的那样,它允许你查看谁是编辑指定行的最后一人,它还允许你查看到引入该行的提交。这有点像 vim 的 `vim-fugitive` 插件提供的 `:Gblame` 命令。 + +### 浏览你的暂存区 + +如果你像我一样,你可能会在你的暂存区做了许多修改。你很容易忘记它们。你可以通过以下方式查看暂存处中的最新项目: + +``` +git stash show -p stash@{0} +``` + +你可以通过以下方式找到第二个最新项目: + +``` +git stash show -p stash@{1} +``` + +以此类推。如果你在需要它们时调用这些命令,那么你会有比我更清晰的记忆。 + +与上面的 Git 命令一样,Tig 可以通过简单的调用轻松增强你的 Git 输出: + +``` +tig stash +``` + +尝试在有暂存的仓库中执行此命令。你将能够浏览*并搜索*你的暂存项,快速浏览你的那些修改。 + +### 浏览你的引用 + +Git ref 是指你提交的东西的哈希值。这包括文件和分支。使用 `tig refs` 命令可以浏览所有的 ref 并深入查看特定提交。 + +``` +tig refs +``` + +完成后,使用 `q` 回到前面的菜单。 + +### 浏览 git 状态 + +如果要查看哪些文件已被暂存,哪些文件未被跟踪,请使用 `tig status`,它是 `git status` 的封装。 + +![Tig status][8] + +### 浏览 git grep + +你可以使用 `grep` 命令在文本文件中搜索表达式。命令 `tig grep` 允许你浏览 `git grep` 的输出。例如: + +``` +tig grep -i foo lib/Bar +``` + +它会让你浏览 `lib/Bar` 目录中以大小写敏感的方式搜索 `foo` 的输出。 + +### 通过标准输入管道输出给 Tig + +如果要将提交 ID 列表传递给 Tig,那么必须使用 `--stdin` 标志,以便 `tig show` 从标准输入读取。否则,`tig show` 会在没有输入的情况下启动(出现空白屏幕)。 + +``` +git rev-list --author=olaf HEAD | tig show --stdin +``` + +### 添加自定义绑定 + +你可以使用 [rc][9] 文件自定义 Tig。以下是如何根据自己的喜好添加一些有用的自定义键绑定的示例。 + +在主目录中创建一个名为 `.tigrc` 的文件。在你喜欢的编辑器中打开 `~/.tigrc` 并添加: + +``` +# 应用选定的暂存内容 +bind stash a !?git stash apply %(stash) + +# 丢弃选定的暂存内容 +bind stash x !?git stash drop %(stash) +``` + +如上所述,运行 `tig stash` 以浏览你的暂存。但是,通过这些绑定,你可以按 `a` 将暂存中的项目应用到仓库,并按 `x` 从暂存中删除项目。请记住,你要在浏览暂存*列表*时,才能执行这些命令。如果你正在浏览暂存*项*,请输入 `q` 退出该视图,然后按 `a` 或 `x` 以获得所需效果。 + +有关更多信息,你可以阅读有关 [Tig 键绑定][10]。 + +### 总结 + +我希望这有助于演示 Tig 如何增强你的日常工作流程。Tig 可以做更强大的事情(比如暂存代码行),但这超出了这篇介绍性文章的范围。这里有足够的让你置身于危险的信息,但还有更多值得探索的地方。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/what-tig + +作者:[Olaf Alders][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/oalders/users/mbbroberg/users/marcobravo +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming) +[2]: https://jonas.github.io/tig/ +[3]: http://manpages.ubuntu.com/manpages/bionic/man1/tig.1.html +[4]: https://opensource.com/sites/default/files/uploads/tig.jpg (Tig screenshot) +[5]: https://jonas.github.io/tig/INSTALL.html +[6]: https://opensource.com/sites/default/files/uploads/tig-search.png (Searching Tig) +[7]: https://opensource.com/sites/default/files/uploads/tig-help.png (Tig Help) +[8]: https://opensource.com/sites/default/files/uploads/tig-status.png (Tig status) +[9]: https://en.wikipedia.org/wiki/Run_commands +[10]: https://github.com/jonas/tig/wiki/Bindings diff --git a/published/201907/20190628 Undo releases Live Recorder 5.0 for Linux debugging.md b/published/201907/20190628 Undo releases Live Recorder 5.0 for Linux debugging.md new file mode 100644 index 0000000000..41aa3fa172 --- /dev/null +++ b/published/201907/20190628 Undo releases Live Recorder 5.0 for Linux debugging.md @@ -0,0 +1,52 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11073-1.html) +[#]: subject: (Undo releases Live Recorder 5.0 for Linux debugging) +[#]: via: (https://www.networkworld.com/article/3405584/undo-releases-live-recorder-5-0-for-linux-debugging.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +Undo 发布用于 Linux 调试的 Live Recorder 5.0 +====== +> 随着 Undo 发布 Live Recorder 5.0,这使得在多进程系统上的调试变得更加轻松。 + +![](https://img.linux.net.cn/data/attachment/album/201907/08/133450i18fp2p011bs5pu6.jpg) + +随着 Undo 发布 Live Recorder 5.0,Linux 调试迈出了一大步。该产品于上个月发布,这使得在多进程系统上的调试变得更加轻松。它基于飞行记录仪技术flight recorder technology,它更加深入进程之中,以深入了解每个进程的情况。这包括内存、线程、程序流,服务调用等。为了实现这一目标,Live Recorder 5.0 的记录、重放和调试功能都得到了增强,能够: + + * 记录进程更改共享内存变量的确切顺序。甚至可以针对特定变量并在任何进程中跳转到最后修改该变量的一行。 + * 通过随机化线程执行来暴露潜在缺陷,以帮助揭示竞态、崩溃和其他多线程缺陷。 + * 记录并重放单个 Kubernetes 和 Docker 容器的执行,以帮助在微服务环境中更快地解决缺陷。 + +Undo Live Recorder 使工程团队能够记录和重放任何软件程序的执行,而无论软件多么复杂。并且可以诊断和修复测试或生产中问题的根本原因。 + +根据你的许可证,Live Recorder 可以在命令行中使用 `live-record` 命令,但有点类似于 `strace`,但它不会打印系统调用和信号,而是创建一个“Undo 录制”。然后你可以调试录制中捕获的失败(远比分析核心转储高效!)。这些录制也可以与其他工作人员共享,并可以使用可逆调试器进行重放,以进一步调查崩溃原因或其他问题。 + +Undo 引擎支持以下 Linux 发行版: + + * Red Hat Enterprise Linux 6.8、6.9、6.10、7.4、7.5、7.6 和 8.0 + * Fedora 28、29 和 30 + * SuSE Linux Enterprise Server 12.3、12.4 和 15 + * Ubuntu 16.04 LTS、18.04 LTS、18.10 和 19.04 + +Undo 是一家快速发展的,有风险投资支持的技术初创公司,它的总部位于旧金山和英国剑桥。他们称 Live Recorder 可以 100% 确定导致任何软件故障的因素 —— 即使在最复杂的软件环境中也是如此。 + +在 [Facebook][2] 和 [LinkedIn][3] 上加入 Network World 社区,评论你想说的话题。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3405584/undo-releases-live-recorder-5-0-for-linux-debugging.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/06/flight_data_recorder-100800552-large.jpg +[2]: https://www.facebook.com/NetworkWorld/ +[3]: https://www.linkedin.com/company/network-world diff --git a/published/201907/20190630 Donald Trump Now Wants to Ban End-to-End Encryption.md b/published/201907/20190630 Donald Trump Now Wants to Ban End-to-End Encryption.md new file mode 100644 index 0000000000..636bb334c3 --- /dev/null +++ b/published/201907/20190630 Donald Trump Now Wants to Ban End-to-End Encryption.md @@ -0,0 +1,51 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11092-1.html) +[#]: subject: (Donald Trump Now Wants to Ban End-to-End Encryption) +[#]: via: (https://news.softpedia.com/news/donald-trump-now-wants-to-ban-end-to-end-encryption-526567.shtml) +[#]: author: (Bogdan Popa https://news.softpedia.com/editors/browse/bogdan-popa) + +美国总统特朗普要禁用端到端加密 +====== + +> 美国官方在开会讨论端到端加密。 + +在[禁止][1]和[解禁][2]华为之后,美国总统唐纳德特朗普现在将目光盯上了端到端加密,据一份新的报告声称,白宫高级官员本周会面讨论了政府可以在这方面采取的第一项动作。 + +[Politico][3] 援引了三位知情人士的话指出,来自几个关键机构的二号官员讨论了针对端到端加密的潜在攻击。 + +“这两条路径是,要么就加密问题发表声明或一般立场,并且[说]他们将继续致力于解决方案,或者要求国会立法,”Politico 援引一位消息人士的话说。 + +虽然美国政府希望终止美国公司开发的软件中的端到端加密功能,但这一提议却招致了美国各机构代表的不同反应。 + +Politico 指出,例如,国土安全部 “内部存在分歧”,因为该机构意识到禁止端到端加密可能产生的安全隐患。 + +### 加密争议 + +推动制定这项针对端到端加密的规定,被视为美国情报机构和执法部门努力获取属于犯罪分子和恐怖分子的设备和数据的决定性步骤。 + +大多数美国公司已经将加密捆绑到他们的产品当中,这包括苹果和谷歌,它阻止了调查人员访问嫌疑人的数据。科技公司将端到端加密定位为一项关键的隐私功能,其中一些人警告说,任何针对它的监管都可能影响到国家安全。 + +特别是苹果公司,它是反对加密监管的最大公司之一。该公司[拒绝解锁圣贝纳迪诺恐怖分子使用的 iPhone][4],解释说侵入该设备会损害所有客户的安全。 + +FBI 最终使用了第三方开发的软件解锁了该设备。 + +-------------------------------------------------------------------------------- + +via: https://news.softpedia.com/news/donald-trump-now-wants-to-ban-end-to-end-encryption-526567.shtml + +作者:[Bogdan Popa][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.softpedia.com/editors/browse/bogdan-popa +[b]: https://github.com/lujun9972 +[1]: https://news.softpedia.com/news/google-bans-huawei-from-using-android-google-play-gmail-other-services-526083.shtml +[2]: https://news.softpedia.com/news/breaking-donald-trump-says-huawei-can-buy-american-products-again-526564.shtml +[3]: https://www.politico.com/story/2019/06/27/trump-officials-weigh-encryption-crackdown-1385306 +[4]: https://news.softpedia.com/news/judge-orders-apple-to-help-the-fbi-hack-san-bernardino-shooter-s-iphone-500517.shtml diff --git a/published/201907/20190701 Ubuntu or Fedora- Which One Should You Use and Why.md b/published/201907/20190701 Ubuntu or Fedora- Which One Should You Use and Why.md new file mode 100644 index 0000000000..e4251ec54e --- /dev/null +++ b/published/201907/20190701 Ubuntu or Fedora- Which One Should You Use and Why.md @@ -0,0 +1,180 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11059-1.html) +[#]: subject: (Ubuntu or Fedora: Which One Should You Use and Why) +[#]: via: (https://itsfoss.com/ubuntu-vs-fedora/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +你应该选择 Ubuntu 还是 Fedora? +====== + +> 选择 Ubuntu 还是 Fedora?它们的区别是什么?哪一个更好?你应该使用哪一个?看看这篇对比 Ubuntu 和 Fedora 的文章吧。 + +[Ubuntu][1] 和 [Fedora][2] 都是最流行的 Linux 发行版之一,在两者之间做出选择实非易事。在这篇文章里,我会对比一下 Ubuntu 和 Fedora 的不同特点,帮助你进行决策。 + +请注意,这篇文章主要是从桌面版的角度进行对比的。Fedora 或者 Ubuntu 针对容器的特殊版本不会被考虑在内。 + +### Ubuntu vs Fedora: 哪一个更好? + +![Ubuntu Vs Fedora][3] + +不同 Linux 发行版之间的区别主要体现在以下几个方面: + + * 基础发行版(Debian、红帽、Arch,或者是从头做起) + * 安装方式 + * 支持的桌面环境 + * 软件包管理、软件支持和更新 + * 硬件支持 + * 开发团队(由企业支持,还是由业余爱好者创建) + * 发布周期 + * 社区和线上支持 + +下面我们来看一下 Ubuntu 和 Fedora 之间的相似之处和不同之处。掌握了这些信息之后,也许就更容易在两者之间做出选择了。 + +#### 安装方式 + +Ubuntu 的 Ubiquity 安装器是最好用的安装器之一。我认为这是让 Ubuntu 如此流行的重要原因之一,因为在 2004 年 Ubuntu 刚刚诞生的时候,安装 Linux 还是一个很庞大的工程。 + +Ubuntu 安装器可以让你在大约 10 分钟左右完成安装。大多数情况下,它还可以识别出机器里安装的 Windows 系统,并且只需要几下点击就可以实现 Ubuntu 和 Windows 的双系统启动。 + +锦上添花的是,在安装 Ubuntu 的过程中你还可以进行系统更新,或者是安装第三方编译码器。 + +![Ubuntu Installer][4] + +Fedora 使用的是 Anaconda 安装器,拥有简单易用的界面,同样简化了安装过程。 + +![Fedora Installer | Image Credit Fedora Magazine][5] + +Fodora 还提供了一个可以在 Windows 操作系统上下载并创建 Fedora live USB 的写入工具。不过我在大约两年前尝试使用它的时候并不成功,最后使用了一个常规的创建 live USB 的软件。 + +根据我的经验,安装 Ubuntu 要比安装 Fedora 容易一些。不过这并不是说安装 Fedora 有多困难,只是 Ubuntu 更简单而已。 + +#### 桌面环境 + +Ubuntu 和 Fedora 默认都使用 GNOME 桌面环境。 + +![GNOME Desktop in Fedora][6] + +Fedora 使用的是原装的 GNOME 桌面,而 Ubuntu 则在此基础上做了个性化调整,让它看起来就像 Ubuntu 之前使用的 Unity 桌面环境。 + +![GNOME desktop customized by Ubuntu][7] + +除了 GNOME,Ubuntu 和 Fedora 都提供了一些其它桌面环境的版本。 + +Ubuntu 有 Kubuntu、Xubuntu、Lubuntu 等版本,分别提供不同的桌面环境。虽然它们都是 Ubuntu 的官方版本,但是却不是由 Canonical 的 Ubuntu 团队直接开发的,而是由另外的团队开发。 + +Fedora 通过 [Fedora Spins][8] 的方式提供了一些不同桌面环境的版本。和 Kubuntu、Lubuntu 等版本不同的是,这些版本并非由独立团队开发,而是由 Fedora 核心团队开发的。 + +#### 软件包管理和可用软件数量 + +Ubuntu 使用 APT 软件包管理器提供软件并进行管理(包括应用程序、库,以及其它所需编解码器),而 Fedora 使用 DNF 软件包管理器。 + +[Ubuntu 拥有庞大的软件仓库][10],能够让你轻松安装数以千计的程序,包括 FOSS(LCTT 译注:Free and Open-Source Software 的缩写,自由开源软件)和非 FOSS 的软件。Fedora 则只专注于提供开源软件。虽然这一点在最近的版本里有所转变,但是 Fedora 的软件仓库在规模上仍然比 Ubuntu 的要逊色一些。 + +一些第三方软件开发者为 Linux 提供像 .exe 文件一样可以点击安装的软件包。在 Ubuntu 里这些软件包是 .deb 格式的,在 Fedora 里是 .rpm 格式的。 + +大多数软件供应商都为 Linux 用户提供 DEB 和 RPM 文件,但是我也经历过供应商只提供 DEB 文件的情况。比如说 SEO 工具 [Screaming Frog][11] 就只提供 DEB 软件包。反过来,一个软件只有 RPM 格式但是没有 DEB 格式这种情况就极其罕见了。 + +#### 硬件支持 + +一般来说,Linux 在 WiFi 适配器和显卡的兼容性上容易出现问题,Ubuntu 和 Fedora 都受此影响。以 Nvidia 为例,它的 [开源驱动程序 Nouveau 经常会引发系统启动时假死机之类的问题][12]。 + +在 Ubuntu 上你可以轻松安装专有驱动程序作为补充。在很多情况下,这样可以获得对硬件更好的支持。 + +![Installing proprietary driver is easier in Ubuntu][13] + +Fedora 则坚持使用开源软件,所以在 Fedora 上安装专有驱动程序就比较困难了。 + +#### 线上支持和用户群 + +Ubuntu 和 Fedora 都通过社区论坛提供了很好的线上支持。Ubuntu 主要有两个论坛:[UbuntuForums][14] 和 [Ask Ubuntu][15]。Fedora 主要的论坛则是 [Ask Fedora][16]。 + +就用户群体而言,Fedora 有着庞大的用户数量。不过 Ubuntu 更为流行,用户数量甚至更为庞大。 + +Ubuntu 的流行催生了很多专注于 Ubuntu 的网站和博客。所以相比 Fedora,你可以得到更多关于 Ubuntu 的故障排除指导和学习材料。 + +#### 发布周期 + +Fedora 每六个月发布一个新版本,每个版本有九个月的支持周期。也就是说,你必须在六个月到九个月之间进行一次系统升级。进行 Fedora 版本升级并不是一件困难的事情,但是需要良好的网络连接。并非所有人都喜欢每九个月进行一次 1.5 GB 的版本升级。 + +Ubuntu 有两种版本:常规发布版本和长期支持(LTS)发布版本。常规版本和 Fedora 比较类似,每隔六个月发布一次,有九个月的支持周期。 + +而长期支持发布版本则每两年发布一次,有五年的支持周期。常规发布版本探索新功能特性和新的软件版本,而长期支持发布版本则支持旧版本软件。对于不喜欢经常改变、青睐稳定性的人来说,这是一个很好的选择。 + +#### 强大的基础发行版 + +Ubuntu 是基于 [Debian][17] 发行版的。Debian 是最大的社区项目之一,并且也是 [自由软件][18] 世界里最受尊敬的项目之一。 + +Fedora 则是红帽公司的一个社区项目。红帽公司是一个专注于 Linux 发行版的公司。Fedora 充当了一个“试验田”的角色(用技术术语来说叫做“上游”),用来在红帽企业级 Linux 发布新功能之前对这些新功能进行试验。 + +#### 在背后支持的企业 + +Ubuntu 和 Fedora 都有来自母公司的支持。Ubuntu 源自 [Canonical][21] 公司,而 Fedora 源自 [红帽公司][22](现在是 [IBM 的一部分][23])。背后企业的支持非常重要,因为可以确保 Linux 发行版良好的维护。 + +有一些发行版是由一群独立的业余爱好者们共同创建的,但是在工作压力之下经常会结束。你也许见过一些还算比较流行的发行版项目仅仅是因为这个原因而终止了。很多这样的发行版由于开发者没有足够的业余时间可以投入到项目上而不得不终止,比如 [Antergos][24] 和 Korora。 + +Ubuntu 和 Fedora 的背后都有基于 Linux 的企业的支持,这让它们比其它独立的发行版更胜一筹。 + +#### Ubuntu vs Fedora:服务端 + +到目前为止,我们在 Ubuntu 和 Fedora 之间的对比主要都集中在桌面端。不过如果不考虑一下服务端的话,对 Linux 的讨论就不能算是完整的。 + +![Ubuntu Server][25] + +Ubuntu 不仅在桌面端很流行,在服务端也有很强的存在感。如果你能够在桌面端熟练使用 Ubuntu,那么也不会对 Ubuntu 服务器版本感到陌生。我就是从使用 Ubuntu 桌面端开始的,现在我的网站都运行在 Ubuntu 服务器上。 + +Fedora 同样有服务端版本,并且也有人在使用。但是大多数系统管理者不会喜欢一个每九个月就需要重启升级的服务器。 + +学习 Fedora 可以更好地帮助你使用红帽企业级 Linux(RHEL)。RHEL 是一个付费产品,你需要购买订阅才可以使用。如果你希望在服务器上运行一个和 Fedora 或者红帽类似的操作系统,我推荐使用 CentOS。[CentOS][26] 同样是红帽公司附属的一个社区项目,但是专注于服务端。 + +### 结论 + +你可以看到,Ubuntu 和 Fedora 有很多相似之处。不过就可用软件数量、驱动安装和线上支持来说,Ubuntu 的确更有优势。**Ubuntu 也因此成为了一个更好的选择,尤其是对于没有经验的 Linux 新手而言。** + +如果你想要熟悉红帽的话,Fedora 是一个很好的开始。如果你对 Linux 有一定经验,或者是只想要使用开源软件,Fedora 就是一个很棒的选择。 + +最终还是需要你自己来决定是使用 Fedora 还是 Ubuntu。我会建议为两个发行版分别创建一个 live USB,并且在虚拟机上体验一下。 + +你对于 Ubuntu vs Fedora 的看法是什么呢?你更喜欢哪一个发行版,为什么?在评论里分享你的看法吧。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-vs-fedora/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://ubuntu.com/ +[2]: https://getfedora.org/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/07/ubuntu-vs-fedora.png?resize=800%2C450&ssl=1 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/03/install-linux-inside-windows-10.jpg?resize=800%2C479&ssl=1 +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/07/fedora-installer.png?resize=800%2C598&ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/gnome-desktop-fedora.png?resize=800%2C450&ssl=1 +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/03/applications_menu.jpg?resize=800%2C450&ssl=1 +[8]: https://spins.fedoraproject.org/ +[9]: https://itsfoss.com/system-76-galago-pro/ +[10]: https://itsfoss.com/ubuntu-repositories/ +[11]: https://www.screamingfrog.co.uk/seo-spider/#download +[12]: https://itsfoss.com/fix-ubuntu-freezing/ +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/software_updates_additional_drivers_nvidia.png?resize=800%2C523&ssl=1 +[14]: https://ubuntuforums.org/ +[15]: https://askubuntu.com/ +[16]: https://ask.fedoraproject.org/ +[17]: https://www.debian.org/ +[18]: https://www.fsf.org/ +[19]: https://en.wikipedia.org/wiki/Upstream_(software_development) +[20]: https://itsfoss.com/manage-startup-applications-ubuntu/ +[21]: https://canonical.com/ +[22]: https://www.redhat.com/en +[23]: https://itsfoss.com/ibm-red-hat-acquisition/ +[24]: https://itsfoss.com/antergos-linux-discontinued/ +[25]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/ubuntu-server.png?resize=800%2C232&ssl=1 +[26]: https://centos.org/ diff --git a/published/201907/20190702 Jupyter and data science in Fedora.md b/published/201907/20190702 Jupyter and data science in Fedora.md new file mode 100644 index 0000000000..00448d68bc --- /dev/null +++ b/published/201907/20190702 Jupyter and data science in Fedora.md @@ -0,0 +1,244 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11072-1.html) +[#]: subject: (Jupyter and data science in Fedora) +[#]: via: (https://fedoramagazine.org/jupyter-and-data-science-in-fedora/) +[#]: author: (Avi Alkalay https://fedoramagazine.org/author/aviram/) + +在 Fedora 上搭建 Jupyter 和数据科学环境 +====== + +![][1] + +在过去,神谕和魔法师被认为拥有发现奥秘的力量,国王和统治者们会借助他们预测未来,或者至少是听取一些建议。如今我们生活在一个痴迷于将一切事情量化的社会里,这份工作就交给数据科学家了。 + +数据科学家通过使用统计模型、数值分析,以及统计学之外的高级算法,结合数据库里已经存在的数据,去发掘、推断和预测尚不存在的数据(有时是关于未来的数据)。这就是为什么我们要做这么多的预测分析和规划分析。 + +下面是一些可以借助数据科学家回答的问题: + + 1. 哪些学生有旷课倾向?每个人旷课的原因分别是什么? + 2. 哪栋房子的售价比合理价格要高或者低?一栋房子的合理价格是多少? + 3. 如何将我们的客户按照潜在的特质进行分组? + 4. 这个孩子的早熟可能会在未来引发什么问题? + 5. 我们的呼叫中心在明天早上 11 点 43 分会接收到多少次呼叫? + 6. 我们的银行是否应该向这位客户发放贷款? + +请注意,这些问题的答案是在任何数据库里都查询不到的,因为它们尚不存在,需要被计算出来才行。这就是我们数据科学家从事的工作。 + +在这篇文章中你会学习如何将 Fedora 系统打造成数据科学家的开发环境和生产系统。其中大多数基本软件都有 RPM 软件包,但是最先进的组件目前只能通过 Python 的 `pip` 工具安装。 + +### Jupyter IDE + +大多数现代数据科学家使用 Python 工作。他们工作中很重要的一部分是 探索性数据分析Exploratory Data Analysis(EDA)。EDA 是一种手动进行的、交互性的过程,包括提取数据、探索数据特征、寻找相关性、通过绘制图形进行数据可视化并理解数据的分布特征,以及实现原型预测模型。 + +Jupyter 是能够完美胜任该工作的一个 web 应用。Jupyter 使用的 Notebook 文件支持富文本,包括渲染精美的数学公式(得益于 [mathjax][2])、代码块和代码输出(包括图形输出)。 + +Notebook 文件的后缀是 `.ipynb`,意思是“交互式 Python Notebook”。 + +#### 搭建并运行 Jupyter + +首先,[使用 sudo][3] 安装 Jupyter 核心软件包: + +``` +$ sudo dnf install python3-notebook mathjax sscg +``` + +你或许需要安装数据科学家常用的一些附加可选模块: + +``` +$ sudo dnf install python3-seaborn python3-lxml python3-basemap python3-scikit-image python3-scikit-learn python3-sympy python3-dask+dataframe python3-nltk +``` + +设置一个用来登录 Notebook 的 web 界面的密码,从而避免使用冗长的令牌。你可以在终端里任何一个位置运行下面的命令: + +``` +$ mkdir -p $HOME/.jupyter +$ jupyter notebook password +``` + +然后输入你的密码,这时会自动创建 `$HOME/.jupyter/jupyter_notebook_config.json` 这个文件,包含了你的密码的加密后版本。 + +接下来,通过使用 SSLby 为 Jupyter 的 web 服务器生成一个自签名的 HTTPS 证书: + +``` +$ cd $HOME/.jupyter; sscg +``` + +配置 Jupyter 的最后一步是编辑 `$HOME/.jupyter/jupyter_notebook_config.json` 这个文件。按照下面的模版编辑该文件: + +``` +{ + "NotebookApp": { + "password": "sha1:abf58...87b", + "ip": "*", + "allow_origin": "*", + "allow_remote_access": true, + "open_browser": false, + "websocket_compression_options": {}, + "certfile": "/home/aviram/.jupyter/service.pem", + "keyfile": "/home/aviram/.jupyter/service-key.pem", + "notebook_dir": "/home/aviram/Notebooks" + } +} +``` + +`/home/aviram/` 应该替换为你的文件夹。`sha1:abf58...87b` 这个部分在你创建完密码之后就已经自动生成了。`service.pem` 和 `service-key.pem` 是 `sscg` 生成的和加密相关的文件。 + +接下来创建一个用来存放 Notebook 文件的文件夹,应该和上面配置里 `notebook_dir` 一致: + +``` +$ mkdir $HOME/Notebooks +``` + +你已经完成了配置。现在可以在系统里的任何一个地方通过以下命令启动 Jupyter Notebook: + +``` +$ jupyter notebook +``` + +或者是将下面这行代码添加到 `$HOME/.bashrc` 文件,创建一个叫做 `jn` 的快捷命令: + +``` +alias jn='jupyter notebook' +``` + +运行 `jn` 命令之后,你可以通过网络内部的任何一个浏览器访问 `` (LCTT 译注:请将域名替换为服务器的域名),就可以看到 Jupyter 的用户界面了,需要使用前面设置的密码登录。你可以尝试键入一些 Python 代码和标记文本,看起来会像下面这样: + +![Jupyter with a simple notebook][4] + +除了 IPython 环境,安装过程还会生成一个由 `terminado` 提供的基于 web 的 Unix 终端。有人觉得这很实用,也有人觉得这样不是很安全。你可以在配置文件里禁用这个功能。 + +### JupyterLab:下一代 Jupyter + +JupyterLab 是下一代的 Jupyter,拥有更好的用户界面和对工作空间更强的操控性。在写这篇文章的时候 JupyterLab 还没有可用的 RPM 软件包,但是你可以使用 `pip` 轻松完成安装: + +``` +$ pip3 install jupyterlab --user +$ jupyter serverextension enable --py jupyterlab +``` + +然后运行 `jupiter notebook` 命令或者 `jn` 快捷命令。访问 `` (LCTT 译注:将域名替换为服务器的域名)就可以使用 JupyterLab 了。 + +### 数据科学家使用的工具 + +在下面这一节里,你将会了解到数据科学家使用的一些工具及其安装方法。除非另作说明,这些工具应该已经有 Fedora 软件包版本,并且已经作为前面组件所需要的软件包而被安装了。 + +#### Numpy + +Numpy 是一个针对 C 语言优化过的高级库,用来处理大型的内存数据集。它支持高级多维矩阵及其运算,并且包含了 `log()`、`exp()`、三角函数等数学函数。 + +#### Pandas + +在我看来,正是 Pandas 成就了 Python 作为数据科学首选平台的地位。Pandas 构建在 Numpy 之上,可以让数据准备和数据呈现工作变得简单很多。你可以把它想象成一个没有用户界面的电子表格程序,但是能够处理的数据集要大得多。Pandas 支持从 SQL 数据库或者 CSV 等格式的文件中提取数据、按列或者按行进行操作、数据筛选,以及通过 Matplotlib 实现数据可视化的一部分功能。 + +#### Matplotlib + +Matplotlib 是一个用来绘制 2D 和 3D 数据图像的库,在图象注解、标签和叠加层方面都提供了相当不错的支持。 + +![matplotlib pair of graphics showing a cost function searching its optimal value through a gradient descent algorithm][5] + +#### Seaborn + +Seaborn 构建在 Matplotlib 之上,它的绘图功能经过了优化,更加适合数据的统计学研究,比如说可以自动显示所绘制数据的近似回归线或者正态分布曲线。 + +![Linear regression visualised with SeaBorn][6] + +#### StatsModels + +[StatsModels][7] 为统计学和经济计量学的数据分析问题(例如线形回归和逻辑回归)提供算法支持,同时提供经典的 [时间序列算法][8] 家族 ARIMA。 + +![Normalized number of passengers across time \(blue\) and ARIMA-predicted number of passengers \(red\)][9] + +#### Scikit-learn + +作为机器学习生态系统的核心部件,[Scikit][10] 为不同类型的问题提供预测算法,包括 [回归问题][11](算法包括 Elasticnet、Gradient Boosting、随机森林等等)、[分类问题][11] 和聚类问题(算法包括 K-means 和 DBSCAN 等等),并且拥有设计精良的 API。Scikit 还定义了一些专门的 Python 类,用来支持数据操作的高级技巧,比如将数据集拆分为训练集和测试集、降维算法、数据准备管道流程等等。 + +#### XGBoost + +XGBoost 是目前可以使用的最先进的回归器和分类器。它并不是 Scikit-learn 的一部分,但是却遵循了 Scikit 的 API。[XGBoost][12] 并没有针对 Fedora 的软件包,但可以使用 `pip` 安装。[使用英伟达显卡可以提升 XGBoost 算法的性能][13],但是这并不能通过 `pip` 软件包来实现。如果你希望使用这个功能,可以针对 CUDA (LCTT 译注:英伟达开发的并行计算平台)自己进行编译。使用下面这个命令安装 XGBoost: + +``` +$ pip3 install xgboost --user +``` + +#### Imbalanced Learn + +[Imbalanced-learn][14] 是一个解决数据欠采样和过采样问题的工具。比如在反欺诈问题中,欺诈数据相对于正常数据来说数量非常小,这个时候就需要对欺诈数据进行数据增强,从而让预测器能够更好地适应数据集。使用 `pip` 安装: + +``` +$ pip3 install imblearn --user +``` + +#### NLTK + +[Natural Language toolkit][15](简称 NLTK)是一个处理人类语言数据的工具,举例来说,它可以被用来开发一个聊天机器人。 + +#### SHAP + +机器学习算法拥有强大的预测能力,但并不能够很好地解释为什么做出这样或那样的预测。[SHAP][16] 可以通过分析训练后的模型来解决这个问题。 + +![Where SHAP fits into the data analysis process][17] + +使用 `pip` 安装: + +``` +$ pip3 install shap --user +``` + +#### Keras + +[Keras][18] 是一个深度学习和神经网络模型的库,使用 `pip` 安装: + +``` +$ sudo dnf install python3-h5py +$ pip3 install keras --user +``` + +#### TensorFlow + +[TensorFlow][19] 是一个非常流行的神经网络模型搭建工具,使用 `pip` 安装: + +``` +$ pip3 install tensorflow --user +``` + +* * * + +_Photo courtesy of [FolsomNatural][20] on [Flickr][21] (CC BY-SA 2.0)._ + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/jupyter-and-data-science-in-fedora/ + +作者:[Avi Alkalay][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/aviram/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/06/jupyter-816x345.jpg +[2]: http://mathjax.org +[3]: https://fedoramagazine.org/howto-use-sudo/ +[4]: https://avi.alkalay.net/articlefiles/2018/07/jupyter-fedora.png +[5]: https://fedoramagazine.org/wp-content/uploads/2019/06/gradient-descent-cost-function-optimization.png +[6]: https://seaborn.pydata.org/_images/regression_marginals.png +[7]: https://www.statsmodels.org/ +[8]: https://www.statsmodels.org/stable/examples/index.html#stats +[9]: https://fedoramagazine.org/wp-content/uploads/2019/06/time-series.png +[10]: https://scikit-learn.org/stable/ +[11]: https://scikit-learn.org/stable/supervised_learning.html#supervised-learning +[12]: https://xgboost.ai +[13]: https://xgboost.readthedocs.io/en/latest/gpu/index.html +[14]: https://imbalanced-learn.readthedocs.io +[15]: https://www.nltk.org +[16]: https://github.com/slundberg/shap +[17]: https://raw.githubusercontent.com/slundberg/shap/master/docs/artwork/shap_diagram.png +[18]: https://keras.io +[19]: https://www.tensorflow.org +[20]: https://www.flickr.com/photos/87249144@N08/ +[21]: https://www.flickr.com/photos/87249144@N08/45871861611/ diff --git a/published/201907/20190702 Make Linux stronger with firewalls.md b/published/201907/20190702 Make Linux stronger with firewalls.md new file mode 100644 index 0000000000..6b455a7c84 --- /dev/null +++ b/published/201907/20190702 Make Linux stronger with firewalls.md @@ -0,0 +1,259 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11093-1.html) +[#]: subject: (Make Linux stronger with firewalls) +[#]: via: (https://opensource.com/article/19/7/make-linux-stronger-firewalls) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +使用防火墙让你的 Linux 更加强大 +====== +> 掌握防火墙的工作原理,以及如何设置防火墙来提高 Linux 的安全性 + +![](https://img.linux.net.cn/data/attachment/album/201907/13/114424m9clibvi0p128fln.jpg) + +所有人都听说过防火墙(哪怕仅仅是在网络犯罪片里看到过相关的情节设定),很多人也知道他们的计算机里很可能正运行着防火墙,但是很少有人明白在必要的时候如何驾驭防火墙。 + +防火墙被用来拦截那些不请自来的网络流量,然而不同网络需要的安全级别也不尽相同。比如说,和在外面一家咖啡馆里使用公共 WiFi 相比,你在家里的时候可以更加信任网络里的其它计算机和设备。你或许希望计算机能够区分可以信任和不可信任的网络,不过最好还是应该学会自己去管理(或者至少是核实)你的安全设置。 + +### 防火墙的工作原理 + +网络里不同设备之间的通信是通过一种叫做端口port的网关实现的。这里的端口指的并不是像 USB 端口 或者 HDMI 端口这样的物理连接。在网络术语中,端口是一个纯粹的虚拟概念,用来表示某种类型的数据到达或离开一台计算机时候所走的路径。其实也可以换个名字来称呼,比如叫“连接”或者“门口”,不过 [早在 1981 年的时候][2] 它们就被称作端口了,这个叫法也沿用至今。其实端口这个东西没有任何特别之处,只是一种用来指代一个可能会发生数据传输的地址的方式。 + +1972 年,发布了一份 [端口号列表][3](那时候的端口被称为“套接字socket”),并且从此演化为一组众所周知的标准端口号,帮助管理特定类型的网络流量。比如说,你每天访问网站的时候都会使用 80 和 443 端口,因为互联网上的绝大多数人都同意(或者是默认)数据从 web 服务器上传输的时候是通过这两个端口的。如果想要验证这一点,你可以在使用浏览器访问网站的时候在 URL 后面加上一个非标准的端口号码。比如说,访问 `example.com:42` 的请求会被拒绝,因为 example.com 在 42 端口上并不提供网站服务。 + +![Navigating to a nonstandard port produces an error][4] + +如果你是通过 80 端口访问同一个网站,就可以(不出所料地)正常访问了。你可以在 URL 后面加上 `:80` 来指定使用 80 端口,不过由于 80 端口是 HTTP 访问的标准端口,所以你的浏览器其实已经默认在使用 80 端口了。 + +当一台计算机(比如说 web 服务器)准备在指定端口接收网络流量的时候,保持该端口向网络流量开放是一种可以接受的(也是必要的)行为。但是不需要接收流量的端口如果也处在开放状态就比较危险了,这就是需要用防火墙解决的问题。 + +#### 安装 firewalld + +有很多种配置防火墙的方式,这篇文章介绍 [firewalld][5]。在桌面环境下它被集成在网络管理器Network Manager里,在终端里则是集成在 `firewall-cmd` 里。很多 Linux 发行版都预装了这些工具。如果你的发行版里没有,你可以把这篇文章当成是管理防火墙的通用性建议,在你所使用的防火墙软件里使用类似的方法,或者你也可以选择安装 `firewalld`。 + +比如说在 Ubuntu 上,你必须启用 universe 软件仓库,关闭默认的 `ufw` 防火墙,然后再安装 `firewalld`: + +``` +$ sudo systemctl disable ufw +$ sudo add-apt-repository universe +$ sudo apt install firewalld +``` + +Fedora、CentOS、RHEL、OpenSUSE,以及其它很多发行版默认就包含了 `firewalld`。 + +无论你使用哪个发行版,如果希望防火墙发挥作用,就必须保持它在开启状态,并且设置成开机自动加载。你应该尽可能减少在防火墙维护工作上所花费的精力。 + +``` +$ sudo systemctl enable --now firewalld +``` + +### 使用网络管理器选择区域 + +或许你每天都会连接到很多不同的网络。在工作的时候使用的是一个网络,在咖啡馆里是另一个,在家里又是另一个。你的计算机可以判断出哪一个网络的使用频率比较高,但是它并不知道哪一个是你信任的网络。 + +一个防火墙的区域zone里包含了端口开放和关闭的预设规则。你可以通过使用区域来选择一个对当前网络最适用的策略。 + +你可以打开网络管理器里的连接编辑器(可以在应用菜单里找到),或者是使用 `nm-connection-editor &` 命令以获取所有可用区域的列表。 + +![Network Manager Connection Editor][6] + +在网络连接列表中,双击你现在所使用的网络。 + +在出现的网络配置窗口中,点击“通用”标签页。 + +在“通用”面板中,点击“防火墙区域”旁边的下拉菜单以获取所有可用区域的列表。 + +![Firewall zones][7] + +也可以使用下面的终端命令以获取同样的列表: + +``` +$ sudo firewall-cmd --get-zones +``` + +每个区域的名称已经可以透露出设计者创建这个区域的意图,不过你也可以使用下面这个终端命令获取任何一个区域的详细信息: + +``` +$ sudo firewall-cmd --zone work --list-all +work +  target: default +  icmp-block-inversion: no +  interfaces: +  sources: +  services: ssh dhcpv6-client +  ports: +  protocols: +  [...] +``` + +在这个例子中,`work` 区域的配置是允许接收 SSH 和 DHCPv6-client 的流量,但是拒绝接收其他任何用户没有明确请求的流量。(换句话说,`work` 区域并不会在你浏览网站的时候拦截 HTTP 响应流量,但是 **会** 拦截一个针对你计算机上 80 端口的 HTTP 请求。) + +你可以依次查看每一个区域,弄清楚它们分别都允许什么样的流量。比较常见的有: + + * `work`:这个区域应该在你非常信任的网络上使用。它允许 SSH、DHCPv6 和 mDNS,并且还可以添加更多允许的项目。该区域非常适合作为一个基础配置,然后在此之上根据日常办公的需求自定义一个工作环境。 + * `public`: 用在你不信任的网络上。这个区域的配置和工作区域是一样的,但是你不应该再继续添加其它任何允许项目。 + * `drop`: 所有传入连接都会被丢弃,并且不会有任何响应。在不彻底关闭网络的条件下,这已经是最接近隐形模式的配置了,因为只允许传出网络连接(不过随便一个端口扫描器就可以通过传出流量检测到你的计算机,所以这个区域并不是一个隐形装置)。如果你在使用公共 WiFi,这个区域可以说是最安全的选择;如果你觉得当前的网络比较危险,这个区域也一定是最好的选择。 + * `block`: 所有传入连接都会被拒绝,但是会返回一个消息说明所请求的端口被禁用了。只有你主动发起的网络连接是被允许的。这是一个友好版的 `drop` 区域,因为虽然还是没有任何一个端口允许传入流量,但是说明了会拒绝接收任何不是本机主动发起的连接。 + * `home`: 在你信任网络里的其它计算机的情况下使用这个区域。该区域只会允许你所选择的传入连接,但是你可以根据需求添加更多的允许项目。 + * `internal`: 和工作区域类似,该区域适用于内部网络,你应该在基本信任网络里的计算机的情况下使用。你可以根据需求开放更多的端口和服务,同时保持和工作区域不同的一套规则。 + * `trusted`: 接受所有的网络连接。适合在故障排除的情况下或者是在你绝对信任的网络上使用。 + +### 为网络指定一个区域 + +你可以为你的任何一个网络连接都指定一个区域,并且对于同一个网络的不同连接方式(比如以太网、WiFi 等等)也可以指定不同的区域。 + +选择你想要的区域,点击“保存”按钮提交修改。 + +![Setting a new zone][8] + +养成为网络连接指定区域的习惯的最好办法是从你最常用的网络开始。为你的家庭网络指定家庭区域,为工作网络指定工作区域,为你最喜欢的图书馆或者咖啡馆的网络指定公关区域。 + +一旦你为所有常用的网络都指定了一个区域,在之后加入新的网络的时候(无论是一个新的咖啡馆还是你朋友家的网络),试图也为它指定一个区域吧。这样可以很好地让你意识到不同的网络的安全性是不一样的,你并不会仅仅因为使用了 Linux 而比任何人更加安全。 + +### 默认区域 + +每次你加入一个新的网络的时候,`firewalld` 并不会提示你进行选择,而是会指定一个默认区域。你可以在终端里输入下面这个命令来获取你的默认区域: + +``` +$ sudo firewall-cmd --get-default +public +``` + +在这个例子里,默认区域是 `public` 区域。你应该保证该区域有非常严格的限制规则,这样在将它指定到未知网络中的时候才比较安全。或者你也可以设置你自己的默认区域。 + +比如说,如果你是一个比较多疑的人,或者需要经常接触不可信任的网络的话,你可以设置一个非常严格的默认区域: + +``` +$ sudo firewall-cmd --set-default-zone drop +success +$ sudo firewall-cmd --get-default +drop +``` + +这样一来,任何你新加入的网络都会被指定使用 `drop` 区域,除非你手动将它制定为另一个没有这么严格的区域。 + +### 通过开放端口和服务实现自定义区域 + +Firewalld 的开发者们并不是想让他们设定的区域能够适应世界上所有不同的网络和所有级别的信任程度。你可以直接使用这些区域,也可以在它们基础上进行个性化配置。 + +你可以根据自己所需要进行的网络活动决定开放或关闭哪些端口,这并不需要对防火墙有多深的理解。 + +#### 预设服务 + +在你的防火墙上添加许可的最简单的方式就是添加预设服务。严格来讲,你的防火墙并不懂什么是“服务”,因为它只知道端口号码和使用协议的类型。不过在标准和传统的基础之上,防火墙可以为你提供一套端口和协议的组合。 + +比如说,如果你是一个 web 开发者并且希望你的计算机对本地网络开放(这样你的同事就可以看到你正在搭建的网站了),可以添加 `http` 和 `https` 服务。如果你是一名游戏玩家,并且在为你的游戏公会运行开源的 [murmur][9] 语音聊天服务器,那么你可以添加 `murmur` 服务。还有其它很多可用的服务,你可以使用下面这个命令查看: + +``` +$ sudo firewall-cmd --get-services + amanda-client amanda-k5-client bacula bacula-client \ + bgp bitcoin bitcoin-rpc ceph cfengine condor-collector \ + ctdb dhcp dhcpv6 dhcpv6-client dns elasticsearch \ + freeipa-ldap freeipa-ldaps ftp [...] +``` + +如果你找到了一个自己需要的服务,可以将它添加到当前的防火墙配置中,比如说: + +``` +$ sudo firewall-cmd --add-service murmur +``` + +这个命令 **在你的默认区域里** 添加了指定服务所需要的所有端口和协议,不过在重启计算机或者防火墙之后就会失效。如果想让你的修改永久有效,可以使用 `--permanent` 标志: + +``` +$ sudo firewall-cmd --add-service murmur --permanent +``` + +你也可以将这个命令用于一个非默认区域: + +``` +$ sudo firewall-cmd --add-service murmur --permanent --zone home +``` + +#### 端口 + +有时候你希望允许的流量并不在 `firewalld` 定义的服务之中。也许你想在一个非标准的端口上运行一个常规服务,或者就是想随意开放一个端口。 + +举例来说,也许你正在运行开源的 [虚拟桌游][10] 软件 [MapTool][11]。由于 MapTool 服务器应该使用哪个端口这件事情并没有一个行业标准,所以你可以自行决定使用哪个端口,然后在防火墙上“开一个洞”,让它允许该端口上的流量。 + +实现方式和添加服务差不多: + +``` +$ sudo firewall-cmd --add-port 51234/tcp +``` + +这个命令 **在你的默认区域** 里将 51234 端口向 TCP 传入连接开放,不过在重启计算机或者防火墙之后就会失效。如果想让你的修改永久有效,可以使用 `--permanent` 标志: + +``` +$ sudo firewall-cmd --add-port 51234/tcp --permanent +``` + +你也可以将这个命令用于一个非默认区域: + +``` +$ sudo firewall-cmd --add-port 51234/tcp --permanent --zone home +``` + +在路由器的防火墙上设置允许流量和在本机上设置的方式是不同的。你的路由器可能会为它的内嵌防火墙提供一个不同的配置界面(原理上是相同的),不过这就超出本文范围了。 + +### 移除端口和服务 + +如果你不再需要某项服务或者某个端口了,并且设置的时候没有使用 `--permanent` 标志的话,那么可以通过重启防火墙来清除修改。 + +如果你已经将修改设置为永久生效了,可以使用 `--remove-port` 或者 `--remove-service` 标志来清除: + +``` +$ sudo firewall-cmd --remove-port 51234/tcp --permanent +``` + +你可以通过在命令中指定一个区域以将端口或者服务从一个非默认区域中移除。 + +``` +$ sudo firewall-cmd --remove-service murmur --permanent --zone home +``` + +### 自定义区域 + +你可以随意使用 `firewalld` 默认提供的这些区域,不过也完全可以创建自己的区域。比如如果希望有一个针对游戏的特别区域,你可以创建一个,然后只有在玩儿游戏的时候切换到该区域。 + +如果想要创建一个新的空白区域,你可以创建一个名为 `game` 的新区域,然后重新加载防火墙规则,这样你的新区域就启用了: + +``` +$ sudo firewall-cmd --new-zone game --permanent +success +$ sudo firewall-cmd --reload +``` + +一旦创建好并且处于启用状态,你就可以通过添加玩游戏时所需要的服务和端口来实现个性化定制了。 + +### 勤勉 + +从今天起开始思考你的防火墙策略吧。不用着急,可以试着慢慢搭建一些合理的默认规则。你也许需要花上一段时间才能习惯于思考防火墙的配置问题,以及弄清楚你使用了哪些网络服务,不过无论是处在什么样的环境里,只要稍加探索你就可以让自己的 Linux 工作站变得更为强大。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/make-linux-stronger-firewalls + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_buildtogether.png?itok=9Tvz64K5 (People working together to build ) +[2]: https://tools.ietf.org/html/rfc793 +[3]: https://tools.ietf.org/html/rfc433 +[4]: https://opensource.com/sites/default/files/uploads/web-port-nonstandard.png (Navigating to a nonstandard port produces an error) +[5]: https://firewalld.org/ +[6]: https://opensource.com/sites/default/files/uploads/nm-connection-editor.png (Network Manager Connection Editor) +[7]: https://opensource.com/sites/default/files/uploads/nm-zone.png (Firewall zones) +[8]: https://opensource.com/sites/default/files/uploads/nm-set.png (Setting a new zone) +[9]: https://www.mumble.com/ +[10]: https://opensource.com/article/18/5/maptool +[11]: https://github.com/RPTools diff --git a/published/201907/20190703 How to Manually Install Security Updates on Debian-Ubuntu.md b/published/201907/20190703 How to Manually Install Security Updates on Debian-Ubuntu.md new file mode 100644 index 0000000000..600598ce4c --- /dev/null +++ b/published/201907/20190703 How to Manually Install Security Updates on Debian-Ubuntu.md @@ -0,0 +1,247 @@ +[#]: collector: (lujun9972) +[#]: translator: (hopefully2333) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11132-1.html) +[#]: subject: (How to Manually Install Security Updates on Debian/Ubuntu?) +[#]: via: (https://www.2daygeek.com/manually-install-security-updates-ubuntu-debian/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +如何在 Debian/Ubuntu 上手动安装安全更新? +====== + +在 Linux 上通过命令行安装一个包程序是一件简单的事。在一行命令中组合使用多个命令能让你更加简单地完成任务。 + +安全更新也同样如此。 + +在这个教程里面,我们会向你展示如何查看可用的安全更新,以及如何在 Ubuntu、LinuxMint 等等这些基于 Debian 的系统中安装它们。 + +有三种方法可以完成这件事,下面会详细地描述这三种方法。 + +作为一个 Linux 管理员,你应该让你的系统保持为最新,这会让你的系统更安全,保护你的系统抵抗意想不到的攻击。 + +如果你因为一些应用的依赖问题不能解决,导致不能给所有的系统进行全部更新。那至少,你应该打上安全补丁来让你的系统 100% 符合要求。 + +### 方法一:如何检查 Debian/Ubuntu 中是否有任何可用的安全更新? + +在进行补丁安装之前,检查可用安全更新列表始终是一个好习惯。它会为你提供将在你的系统中进行更新的软件包的列表。 + +默认情况下,你的系统上应该是已经安装了 `unattended-upgrades` 包的。但是如果你的系统没有装这个包,那么请使用下面的命令来安装它。 + +使用 [APT-GET 命令][1] 或者 [APT 命令][2] 来安装 `unattended-upgrades` 包。 + +``` +$ sudo apt-get install unattended-upgrades +或 +$ sudo apt install unattended-upgrades +``` + +**什么是试运行?** 大多数的 Linux 命令都有一个试运行选项,它会给出实际的输出但不会下载或安装任何东西。 + +为此,你需要在 `unattended-upgrades` 命令中添加 `--dry-run` 选项。 + +``` +$ sudo unattended-upgrade --dry-run -d + +Initial blacklisted packages: +Initial whitelisted packages: +Starting unattended upgrades script +Allowed origins are: o=Ubuntu,a=bionic, o=Ubuntu,a=bionic-security, o=UbuntuESM,a=bionic +Using (^linux-image-[0-9]+\.[0-9\.]+-.*|^linux-headers-[0-9]+\.[0-9\.]+-.*|^linux-image-extra-[0-9]+\.[0-9\.]+-.*|^linux-modules-[0-9]+\.[0-9\.]+-.*|^linux-modules-extra-[0-9]+\.[0-9\.]+-.*|^linux-signed-image-[0-9]+\.[0-9\.]+-.*|^kfreebsd-image-[0-9]+\.[0-9\.]+-.*|^kfreebsd-headers-[0-9]+\.[0-9\.]+-.*|^gnumach-image-[0-9]+\.[0-9\.]+-.*|^.*-modules-[0-9]+\.[0-9\.]+-.*|^.*-kernel-[0-9]+\.[0-9\.]+-.*|^linux-backports-modules-.*-[0-9]+\.[0-9\.]+-.*|^linux-modules-.*-[0-9]+\.[0-9\.]+-.*|^linux-tools-[0-9]+\.[0-9\.]+-.*|^linux-cloud-tools-[0-9]+\.[0-9\.]+-.*) regexp to find kernel packages +Using (^linux-image-4\.15\.0\-51\-generic$|^linux-headers-4\.15\.0\-51\-generic$|^linux-image-extra-4\.15\.0\-51\-generic$|^linux-modules-4\.15\.0\-51\-generic$|^linux-modules-extra-4\.15\.0\-51\-generic$|^linux-signed-image-4\.15\.0\-51\-generic$|^kfreebsd-image-4\.15\.0\-51\-generic$|^kfreebsd-headers-4\.15\.0\-51\-generic$|^gnumach-image-4\.15\.0\-51\-generic$|^.*-modules-4\.15\.0\-51\-generic$|^.*-kernel-4\.15\.0\-51\-generic$|^linux-backports-modules-.*-4\.15\.0\-51\-generic$|^linux-modules-.*-4\.15\.0\-51\-generic$|^linux-tools-4\.15\.0\-51\-generic$|^linux-cloud-tools-4\.15\.0\-51\-generic$) regexp to find running kernel packages +Checking: apt ([]) +adjusting candidate version: apt=1.6.6ubuntu0.1 +Checking: apt-utils ([]) +adjusting candidate version: apt-utils=1.6.6ubuntu0.1 +Checking: bash ([]) +. +. +Checking: xxd ([, ]) +pkgs that look like they should be upgraded: binutils +binutils-common +binutils-x86-64-linux-gnu +cpp +cpp-7 +dbus +dbus-user-session +dbus-x11 +firefox +firefox-locale-en +g++ +g++-7 +gcc +gcc-7 +gcc-7-base +gcc-8-base +libasan4 +libatomic1 +libbinutils +libcc1-0 +libcilkrts5 +libdbus-1-3 +libdbus-1-dev +libgcc-7-dev +libgcc1 +libgfortran4 +libgomp1 +libitm1 +liblsan0 +libmpx2 +libquadmath0 +libstdc++-7-dev +libstdc++6 +libtsan0 +libubsan0 +vim-common +vim-tiny +xxd +``` + +如果在终端里,上面的命令输出说 “No packages found that can be upgraded unattended and no pending auto-removals”,这意味着你的系统已经是最新的了。 + +#### 如何在 Debian/Ubuntu 中安装可用的安全更新? + +如果你在上面的命令输出中获得了任意的软件包更新,就运行下面的命令来安装它们。 + +``` +$ sudo unattended-upgrade -d +``` + +除此之外,你也可以使用 `apt-get` 命令来进行安装。但是这个方法有点棘手,我会建议用户用第一个选项。 + +### 方法二:如何使用 apt-get 命令在 Debian/Ubuntu 中检查是否有可用的安全更新? + +在你的 Debian/Ubuntu 系统中运行下面的命令来查看可用安全更新的列表。 + +``` +$ sudo apt-get -s dist-upgrade | grep "^Inst" | grep -i securi + +Inst libquadmath0 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst libitm1 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst gcc-8-base [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libmpx2:amd64 libgcc1:amd64 libtsan0:amd64 liblsan0:amd64 libgomp1:amd64 libatomic1:amd64 libcc1-0:amd64 libstdc++6:amd64 ] +Inst libgcc1 [1:8.2.0-1ubuntu2~18.04] (1:8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libmpx2:amd64 libtsan0:amd64 liblsan0:amd64 libgomp1:amd64 libatomic1:amd64 libcc1-0:amd64 libstdc++6:amd64 ] +Inst libmpx2 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libtsan0:amd64 liblsan0:amd64 libgomp1:amd64 libatomic1:amd64 libcc1-0:amd64 libstdc++6:amd64 ] +Inst liblsan0 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libtsan0:amd64 libgomp1:amd64 libatomic1:amd64 libcc1-0:amd64 libstdc++6:amd64 ] +Inst libtsan0 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libgomp1:amd64 libatomic1:amd64 libcc1-0:amd64 libstdc++6:amd64 ] +Inst libcc1-0 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libgomp1:amd64 libatomic1:amd64 libstdc++6:amd64 ] +Inst libatomic1 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libgomp1:amd64 libstdc++6:amd64 ] +Inst libgomp1 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libstdc++6:amd64 ] +Inst libstdc++6 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) +Inst libdbus-1-dev [1.12.2-1ubuntu1] (1.12.2-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst dbus-user-session [1.12.2-1ubuntu1] (1.12.2-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst dbus-x11 [1.12.2-1ubuntu1] (1.12.2-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst dbus [1.12.2-1ubuntu1] (1.12.2-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst libdbus-1-3 [1.12.2-1ubuntu1] (1.12.2-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) +Inst xxd [2:8.0.1453-1ubuntu1] (2:8.0.1453-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) +Inst vim-tiny [2:8.0.1453-1ubuntu1] (2:8.0.1453-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst vim-common [2:8.0.1453-1ubuntu1] (2:8.0.1453-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [all]) +Inst binutils-x86-64-linux-gnu [2.30-21ubuntu1~18.04] (2.30-21ubuntu1~18.04.2 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [binutils:amd64 ] +Inst binutils-common [2.30-21ubuntu1~18.04] (2.30-21ubuntu1~18.04.2 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [binutils:amd64 libbinutils:amd64 ] +Inst binutils [2.30-21ubuntu1~18.04] (2.30-21ubuntu1~18.04.2 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libbinutils:amd64 ] +Inst libbinutils [2.30-21ubuntu1~18.04] (2.30-21ubuntu1~18.04.2 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) +Inst libasan4 [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst libubsan0 [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst libcilkrts5 [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst g++-7 [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst gcc-7 [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst libstdc++-7-dev [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst libgcc-7-dev [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst libgfortran4 [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst cpp-7 [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [] +Inst gcc-7-base [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) +Inst cpp [4:7.3.0-3ubuntu2.1] (4:7.4.0-1ubuntu2.3 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) +Inst firefox [67.0.1+build1-0ubuntu0.18.04.1] (67.0.2+build2-0ubuntu0.18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) +Inst firefox-locale-en [67.0.1+build1-0ubuntu0.18.04.1] (67.0.2+build2-0ubuntu0.18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) +Inst gcc [4:7.3.0-3ubuntu2.1] (4:7.4.0-1ubuntu2.3 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) +Inst g++ [4:7.3.0-3ubuntu2.1] (4:7.4.0-1ubuntu2.3 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) +``` + +#### 如何使用 apt-get 命令在 Debian/Ubuntu 系统中安装可用的安全更新? + +如果你在上面命令的输出中发现任何的软件包更新。就运行下面的命令来安装它们。 + +``` +$ sudo apt-get -s dist-upgrade | grep "^Inst" | grep -i securi | awk -F " " {'print $2'} | xargs apt-get install +``` + +除此之外,也可以使用 `apt` 命令来完成。但是这个方法有点棘手,我会建议用户用第一个方式。 + +### 方法三:如何使用 apt 命令在 Debian/Ubuntu 系统中检查是否有可用的安全更新? + +在 Debian/Ubuntu 系统中运行下面的命令来查看可用安全更新的列表。 + +``` +$ sudo apt list --upgradable | grep -e "-security" + +binutils/bionic-updates,bionic-security 2.30-21ubuntu1~18.04.2 amd64 [upgradable from: 2.30-21ubuntu1~18.04] +binutils-common/bionic-updates,bionic-security 2.30-21ubuntu1~18.04.2 amd64 [upgradable from: 2.30-21ubuntu1~18.04] +binutils-x86-64-linux-gnu/bionic-updates,bionic-security 2.30-21ubuntu1~18.04.2 amd64 [upgradable from: 2.30-21ubuntu1~18.04] +cpp/bionic-updates,bionic-security 4:7.4.0-1ubuntu2.3 amd64 [upgradable from: 4:7.3.0-3ubuntu2.1] +cpp-7/bionic-updates,bionic-security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27ubuntu1~18.04] +dbus/bionic-updates,bionic-security 1.12.2-1ubuntu1.1 amd64 [upgradable from: 1.12.2-1ubuntu1] +dbus-user-session/bionic-updates,bionic-security 1.12.2-1ubuntu1.1 amd64 [upgradable from: 1.12.2-1ubuntu1] +dbus-x11/bionic-updates,bionic-security 1.12.2-1ubuntu1.1 amd64 [upgradable from: 1.12.2-1ubuntu1] +firefox/bionic-updates,bionic-security 67.0.2+build2-0ubuntu0.18.04.1 amd64 [upgradable from: 67.0.1+build1-0ubuntu0.18.04.1] +firefox-locale-en/bionic-updates,bionic-security 67.0.2+build2-0ubuntu0.18.04.1 amd64 [upgradable from: 67.0.1+build1-0ubuntu0.18.04.1] +g++/bionic-updates,bionic-security 4:7.4.0-1ubuntu2.3 amd64 [upgradable from: 4:7.3.0-3ubuntu2.1] +g++-7/bionic-updates,bionic-security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27ubuntu1~18.04] +gcc/bionic-updates,bionic-security 4:7.4.0-1ubuntu2.3 amd64 [upgradable from: 4:7.3.0-3ubuntu2.1] +gcc-7/bionic-updates,bionic-security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27ubuntu1~18.04] +gcc-7-base/bionic-updates,bionic-security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27ubuntu1~18.04] +gcc-8-base/bionic-updates,bionic-security 8.3.0-6ubuntu1~18.04.1 amd64 [upgradable from: 8.2.0-1ubuntu2~18.04] +libasan4/bionic-updates,bionic-security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27ubuntu1~18.04] +libatomic1/bionic-updates,bionic-security 8.3.0-6ubuntu1~18.04.1 amd64 [upgradable from: 8.2.0-1ubuntu2~18.04] +libbinutils/bionic-updates,bionic-security 2.30-21ubuntu1~18.04.2 amd64 [upgradable from: 2.30-21ubuntu1~18.04] +libcc1-0/bionic-updates,bionic-security 8.3.0-6ubuntu1~18.04.1 amd64 [upgradable from: 8.2.0-1ubuntu2~18.04] +libcilkrts5/bionic-updates,bionic-security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27ubuntu1~18.04] +libdbus-1-3/bionic-updates,bionic-security 1.12.2-1ubuntu1.1 amd64 [upgradable from: 1.12.2-1ubuntu1] +libdbus-1-dev/bionic-updates,bionic-security 1.12.2-1ubuntu1.1 amd64 [upgradable from: 1.12.2-1ubuntu1] +libgcc-7-dev/bionic-updates,bionic-security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27ubuntu1~18.04] +libgcc1/bionic-updates,bionic-security 1:8.3.0-6ubuntu1~18.04.1 amd64 [upgradable from: 1:8.2.0-1ubuntu2~18.04] +libgfortran4/bionic-updates,bionic-security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27ubuntu1~18.04] +libgomp1/bionic-updates,bionic-security 8.3.0-6ubuntu1~18.04.1 amd64 [upgradable from: 8.2.0-1ubuntu2~18.04] +libitm1/bionic-updates,bionic-security 8.3.0-6ubuntu1~18.04.1 amd64 [upgradable from: 8.2.0-1ubuntu2~18.04] +liblsan0/bionic-updates,bionic-security 8.3.0-6ubuntu1~18.04.1 amd64 [upgradable from: 8.2.0-1ubuntu2~18.04] +libmpx2/bionic-updates,bionic-security 8.3.0-6ubuntu1~18.04.1 amd64 [upgradable from: 8.2.0-1ubuntu2~18.04] +libquadmath0/bionic-updates,bionic-security 8.3.0-6ubuntu1~18.04.1 amd64 [upgradable from: 8.2.0-1ubuntu2~18.04] +libstdc++-7-dev/bionic-updates,bionic-security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27ubuntu1~18.04] +libstdc++6/bionic-updates,bionic-security 8.3.0-6ubuntu1~18.04.1 amd64 [upgradable from: 8.2.0-1ubuntu2~18.04] +libtsan0/bionic-updates,bionic-security 8.3.0-6ubuntu1~18.04.1 amd64 [upgradable from: 8.2.0-1ubuntu2~18.04] +libubsan0/bionic-updates,bionic-security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27ubuntu1~18.04] +vim-common/bionic-updates,bionic-updates,bionic-security,bionic-security 2:8.0.1453-1ubuntu1.1 all [upgradable from: 2:8.0.1453-1ubuntu1] +vim-tiny/bionic-updates,bionic-security 2:8.0.1453-1ubuntu1.1 amd64 [upgradable from: 2:8.0.1453-1ubuntu1] +xxd/bionic-updates,bionic-security 2:8.0.1453-1ubuntu1.1 amd64 [upgradable from: 2:8.0.1453-1ubuntu1] +``` + +#### 如何在 Debian/Ubuntu 系统中使用 apt 命令来安装可用的安全更新? + +如果你在上面命令的输出中发现任何的软件包更新。就运行下面的命令来安装它们。 + +``` +$ sudo apt list --upgradable | grep -e "-security" | awk -F "/" '{print $1}' | xargs apt install +``` + +同样,下面的文件也会告诉你更新包的总数。 + +``` +$ sudo cat /var/lib/update-notifier/updates-available + +190 packages can be updated. +39 updates are security updates. +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/manually-install-security-updates-ubuntu-debian/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[hopefully2333](https://github.com/hopefully2333) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[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/ diff --git a/published/201907/20190703 Parse arguments with Python.md b/published/201907/20190703 Parse arguments with Python.md new file mode 100644 index 0000000000..f4f240a4ae --- /dev/null +++ b/published/201907/20190703 Parse arguments with Python.md @@ -0,0 +1,191 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11144-1.html) +[#]: subject: (Parse arguments with Python) +[#]: via: (https://opensource.com/article/19/7/parse-arguments-python) +[#]: author: (Seth Kenlon https://opensource.com/users/seth/users/notsag) + +使用 Python 解析参数 +====== + +> 使用 argparse 模块像专业人士一样解析参数。 + +![](https://img.linux.net.cn/data/attachment/album/201907/24/210351h99gzcttqmk7c7mx.jpg) + +如果你在使用 [Python][2] 进行开发,你可能会在终端中使用命令,即使只是为了启动 Python 脚本或使用 [pip][3] 安装 Python 模块。命令可能简单而单一: + +``` +$ ls +``` + +命令也可能需要参数: + +``` +$ ls example +``` + +命令也可以有选项或标志: + +``` +$ ls --color example +``` + +有时选项也有参数: + +``` +$ sudo firewall-cmd  --list-all --zone home +``` + +### 参数 + +POSIX shell 会自动将你输入的内容作为命令分成数组。例如,这是一个简单的命令: + +``` +$ ls example +``` + +命令 `ls` 的位置是 `$0`,参数 `example` 位置是 `$1`。 + +你**可以**写一个循环迭代每项。确定它是否是命令、选项还是参数。并据此采取行动。幸运的是,已经有一个名为 [argparse][4] 的模块。 + +### argparse + +argparse 模块很容易集成到 Python 程序中,并有多种便利功能。例如,如果你的用户更改选项的顺序或使用一个不带参数的选项(称为**布尔**,意味着选项可以打开或关闭设置),然后另一个需要参数(例如 `--color red`),argparse 可以处理多种情况。如果你的用户忘记了所需的选项,那么 argparse 模块可以提供友好的错误消息。 + +要在应用中使用 argparse,首先要定义为用户提供的选项。你可以接受几种不同的参数,而语法一致又简单。 + +这是一个简单的例子: + +``` +#!/usr/bin/env python +import argparse +import sys + +def getOptions(args=sys.argv[1:]): +    parser = argparse.ArgumentParser(description="Parses command.") +    parser.add_argument("-i", "--input", help="Your input file.") +    parser.add_argument("-o", "--output", help="Your destination output file.") +    parser.add_argument("-n", "--number", type=int, help="A number.") +    parser.add_argument("-v", "--verbose",dest='verbose',action='store_true', help="Verbose mode.") +    options = parser.parse_args(args) +    return options +``` + +此示例代码创建一个名为 `getOptions` 的函数,并告诉 Python 查看每个可能的参数,前面有一些可识别的字符串(例如 `--input` 或者 `-i`)。 Python 找到的任何选项都将作为 `options` 对象从函数中返回(`options` 是一个任意名称,且没有特殊含义。它只是一个包含函数已解析的所有参数的摘要的数据对象)。 + +默认情况下,Python 将用户给出的任何参数视为字符串。如果需要提取整数(数字),则必须指定选项 `type=int`,如示例代码中的 `--number` 选项。 + +如果你有一个只是关闭和打开功能的参数,那么你必须使用 `boolean` 类型,就像示例代码中的 `--verbose` 标志一样。这种选项只保存 `True` 或 `False`,用户用来指定是否使用标志。如果使用该选项,那么会激活 `stored_true`。 + +当 `getOptions` 函数运行时,你就可以使用 `options` 对象的内容,并让程序根据用户调用命令的方式做出决定。你可以使用测试打印语句查看 `options` 的内容。将其添加到示例文件的底部: + +``` +print(getOptions()) +``` + +然后带上参数运行代码: + +``` +$ python3 ./example.py -i foo -n 4 +Namespace(input='foo', number=4, output=None, verbose=False) +``` + +### 检索值 + +示例代码中的 `options` 对象包含了用户提供的选项后面的值(或派生的布尔值)。例如,在示例代码中,可以通过 `options.number` 来检索 `--number`。 + +``` +options = getOptions(sys.argv[1:]) + +if options.verbose: +    print("Verbose mode on") +else: +    print("Verbose mode off") + +print(options.input) +print(options.output) +print(options.number) + +# 这里插入你的 Python 代码 +``` + +示例中的布尔选项 `--verbose` 是通过测试 `options.verbose` 是否为 `True`(意味着用户使用了 `--verbose` 标志)或 `False`(用户没有使用 `--verbose` 标志),并采取相应的措施。 + +### 帮助和反馈 + +argparse 还包含一个内置的 `--help`(简写 `-h`)选项,它提供了有关如何使用命令的提示。这是从你的代码派生的,因此生成此帮助系统不需要额外的工作: + +``` +$ ./example.py --help +usage: example.py [-h] [-i INPUT] [-o OUTPUT] [-n NUMBER] [-v] + +Parses command. + +optional arguments: +  -h, --help            show this help message and exit +  -i INPUT, --input INPUT +                        Your input file. +  -o OUTPUT, --output OUTPUT +                        Your destination output file. +  -n NUMBER, --number NUMBER +                        A number. +  -v, --verbose         Verbose mode. +``` + +### 像专业人士一样用 Python 解析 + +这是一个简单的示例,来演示如何在 Python 应用中的解析参数以及如何快速有效地记录它的语法。下次编写 Python 脚本时,请使用 argparse 为其提供一些选项。你以后会感到自得,你的命令不会像一个快速的临时脚本,更像是一个“真正的” Unix 命令! + +以下是可用于测试的示例代码: + +``` +#!/usr/bin/env python3 +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved.  This file is offered as-is, +# without any warranty. + +import argparse +import sys + +def getOptions(args=sys.argv[1:]): +    parser = argparse.ArgumentParser(description="Parses command.") +    parser.add_argument("-i", "--input", help="Your input file.") +    parser.add_argument("-o", "--output", help="Your destination output file.") +    parser.add_argument("-n", "--number", type=int, help="A number.") +    parser.add_argument("-v", "--verbose",dest='verbose',action='store_true', help="Verbose mode.") +    options = parser.parse_args(args) +    return options + +options = getOptions(sys.argv[1:]) + +if options.verbose: +    print("Verbose mode on") +else: +    print("Verbose mode off") + +print(options.input) +print(options.output) +print(options.number) +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/parse-arguments-python + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth/users/notsag +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cobol-card-punch-programming-code.png?itok=6W6PUqUi (COBOL punch card) +[2]: https://www.python.org/ +[3]: https://pip.pypa.io/en/stable/installing/ +[4]: https://pypi.org/project/argparse/ diff --git a/published/201907/20190705 Bash Script to Monitor Messages Log (Warning, Error and Critical) on Linux.md b/published/201907/20190705 Bash Script to Monitor Messages Log (Warning, Error and Critical) on Linux.md new file mode 100644 index 0000000000..8f06f3a6a9 --- /dev/null +++ b/published/201907/20190705 Bash Script to Monitor Messages Log (Warning, Error and Critical) on Linux.md @@ -0,0 +1,109 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11171-1.html) +[#]: subject: (Bash Script to Monitor Messages Log (Warning, Error and Critical) on Linux) +[#]: via: (https://www.2daygeek.com/linux-bash-script-to-monitor-messages-log-warning-error-critical-send-email/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +在 Linux 上用 Bash 脚本监控 messages 日志 +====== + +目前市场上有许多开源监控工具可用于监控 Linux 系统的性能。当系统达到指定的阈值限制时,它将发送电子邮件警报。它可以监视 CPU 利用率、内存利用率、交换利用率、磁盘空间利用率等所有内容。 + +如果你只有很少的系统并且想要监视它们,那么编写一个小的 shell 脚本可以使你的任务变得非常简单。 + +在本教程中,我们添加了一个 shell 脚本来监视 Linux 系统上的 messages 日志。 + +我们过去添加了许多有用的 shell 脚本。如果要查看这些内容,请导航至以下链接。 + +- [如何使用 shell 脚本监控系统的日常活动?][1] + +此脚本将检查 `/var/log/messages` 文件中的 “warning“、“error” 和 “critical”,如果发现任何有关的东西,就给指定电子邮件地址发邮件。 + +如果服务器有许多匹配的字符串,我们就不能经常运行这个可能填满收件箱的脚本,我们可以在一天内运行一次。 + +为了解决这个问题,我让脚本以不同的方式触发电子邮件。 + +如果 `/var/log/messages` 文件中昨天的日志中找到任何给定字符串,则脚本将向给定的电子邮件地址发送电子邮件警报。 + +**注意:**你需要更改电子邮件地址,而不是我们的电子邮件地址。 + +``` +# vi /opt/scripts/os-log-alert.sh +``` + +``` +#!/bin/bash +#Set the variable which equal to zero +prev_count=0 + +count=$(grep -i "`date --date='yesterday' '+%b %e'`" /var/log/messages | egrep -wi 'warning|error|critical' | wc -l) + +if [ "$prev_count" -lt "$count" ] ; then + # Send a mail to given email id when errors found in log + SUBJECT="WARNING: Errors found in log on "`date --date='yesterday' '+%b %e'`"" + # This is a temp file, which is created to store the email message. + MESSAGE="/tmp/logs.txt" + TO="2daygeek@gmail.com" + echo "ATTENTION: Errors are found in /var/log/messages. Please Check with Linux admin." >> $MESSAGE + echo "Hostname: `hostname`" >> $MESSAGE + echo -e "\n" >> $MESSAGE + echo "+------------------------------------------------------------------------------------+" >> $MESSAGE + echo "Error messages in the log file as below" >> $MESSAGE + echo "+------------------------------------------------------------------------------------+" >> $MESSAGE + grep -i "`date --date='yesterday' '+%b %e'`" /var/log/messages | awk '{ $3=""; print}' | egrep -wi 'warning|error|critical' >> $MESSAGE + mail -s "$SUBJECT" "$TO" < $MESSAGE + #rm $MESSAGE +fi +``` + +为 `os-log-alert.sh` 文件设置可执行权限。 + +``` +$ chmod +x /opt/scripts/os-log-alert.sh +``` + +最后添加一个 cron 任务来自动执行此操作。它将每天 7 点钟运行。 + +``` +# crontab -e +``` + +``` +0 7 * * * /bin/bash /opt/scripts/os-log-alert.sh +``` + +**注意:**你将在每天 7 点收到昨天日志的电子邮件提醒。 + +**输出:**你将收到类似下面的电子邮件提醒。 + +``` +ATTENTION: Errors are found in /var/log/messages. Please Check with Linux admin. + ++-----------------------------------------------------+ +Error messages in the log file as below ++-----------------------------------------------------+ +Jul 3 02:40:11 ns1 kernel: php-fpm[3175]: segfault at 299 ip 000055dfe7cc7e25 sp 00007ffd799d7d38 error 4 in php-fpm[55dfe7a89000+3a7000] +Jul 3 02:50:14 ns1 kernel: lmtp[8249]: segfault at 20 ip 00007f9cc05295e4 sp 00007ffc57bca1a0 error 4 in libdovecot-storage.so.0.0.0[7f9cc04df000+148000] +Jul 3 15:36:09 ns1 kernel: php-fpm[17846]: segfault at 299 ip 000055dfe7cc7e25 sp 00007ffd799d7d38 error 4 in php-fpm[55dfe7a89000+3a7000] +Jul 3 15:45:54 ns1 pure-ftpd: (?@5.188.62.5) [WARNING] Authentication failed for user [daygeek] +Jul 3 16:25:36 ns1 pure-ftpd: (?@104.140.148.58) [WARNING] Sorry, cleartext sessions and weak ciphers are not accepted on this server.#012Please reconnect using TLS security mechanisms. +Jul 3 16:44:20 ns1 kernel: php-fpm[8979]: segfault at 299 ip 000055dfe7cc7e25 sp 00007ffd799d7d38 error 4 in php-fpm[55dfe7a89000+3a7000] +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-bash-script-to-monitor-messages-log-warning-error-critical-send-email/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/category/shell-script/ diff --git a/published/201907/20190705 Copy and paste at the Linux command line with xclip.md b/published/201907/20190705 Copy and paste at the Linux command line with xclip.md new file mode 100644 index 0000000000..057af5876f --- /dev/null +++ b/published/201907/20190705 Copy and paste at the Linux command line with xclip.md @@ -0,0 +1,96 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11089-1.html) +[#]: subject: (Copy and paste at the Linux command line with xclip) +[#]: via: (https://opensource.com/article/19/7/xclip) +[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) + +使用 xclip 在 Linux 命令行中复制粘贴 +====== +> 了解如何在 Linux 中使用 xclip。 + +![Green paperclips][1] + +在使用 Linux 桌面工作时,你通常如何复制全部或部分文本?你可能会在文本编辑器中打开文件,选择全部或仅选择要复制的文本,然后将其粘贴到其他位置。 + +这样没问题。但是你可以使用 [xclip][2] 在命令行中更有效地完成工作。`xclip` 提供了在终端窗口中运行的命令与 Linux 图形桌面环境中的剪贴板之间的管道。 + +### 安装 xclip + +`xclip` 并不是许多 Linux 发行版的标准套件。要查看它是否已安装在你的计算机上,请打开终端窗口并输入 `which xclip`。如果该命令返回像 `/usr/bin/xclip` 这样的输出,那么你可以开始使用了。否则,你需要安装 `xclip`。 + +为此,请使用你的发行版的包管理器。如果你喜欢冒险,你可以[从 GitHub 获取源代码][2]并自己编译。 + +### 基础使用 + +假设你要将文件的内容复制到剪贴板。在 `xclip` 中可以使用两种方法。输入: + +``` +xclip file_name +``` + +或者 + +``` +xclip -sel clip file_name +``` + +两个命令之间有什么区别(除了第二个命令更长)?第一个命令在你使用鼠标中键粘贴的情况下有效。但是,不是每个人都这样做。许多人习惯使用右键单击菜单或按 `Ctrl+V` 粘贴文本。如果你时其中之一(我就是!),使用 `-sel clip` 选项可确保你可以粘贴要粘贴的内容。 + +### 将 xclip 与其他应用一起使用 + +将文件内容直接复制到剪贴板是个巧妙的技巧。很可能你不会经常这样做。还有其他方法可以使用 `xclip`,其中包括将其与另一个命令行程序结合。 + +结合是用管道(`|`)完成的。管道将一个命令行程序的输出重定向到另一个命令行程序。这样我们就会有更多的可能性,我们来看看其中的三个。 + +假设你是系统管理员,你需要将日志文件的最后 30 行复制到 bug 报告中。在文本编辑器中打开文件,向下滚动到最后,复制和粘贴有一点工作量。为什么不使用 `xclip` 和 [tail][3] 来快速轻松地完成?运行此命令以复制最后 30 行: + + +``` +tail -n 30 logfile.log | xclip -sel clip +``` + +我的写作有相当一部分用于内容管理系统 (CMS) 或者在其他网络中发布。但是,我从不使用 CMS 的 WYSIWYG 编辑器来编写 - 我采用 [Markdown][5] 格式离线编写[纯文本][4]。也就是说,许多编辑器都有 HTML 模式。通过使用此命令,我可以使用 [Pandoc][6] 将 Markdown 格式的文件转换为 HTML 并将其一次性复制到剪贴板: + +``` +pandoc -t html file.md | xclip -sel clip +``` + +在其他地方,粘贴完成。 + +我的两个网站使用 [GitLab Pages][7] 托管。我使用名为 [Certbot][8] 的工具为这些站点生成 HTTPS 证书,每当我更新它时,我需要将每个站点的证书复制到 GitLab。结合 [cat][9] 命令和 xclip 比使用编辑器更快,更有效。例如: + +``` +cat /etc/letsencrypt/live/website/fullchain.pem | xclip -sel clip +``` + +这就是全部可以用 xclip 做的事么?当然不是。我相信你可以找到更多用途来满足你的需求。 + +### 最后总结 + +不是每个人都会使用 `xclip`。没关系。然而,它是一个在你需要它时非常方便的一个小工具。而且,正如我几次发现的那样,你不知道什么时候需要它。等到时候,你会很高兴能用上 `xclip`。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/xclip + +作者:[Scott Nesbitt][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/scottnesbitt +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life_paperclips.png?itok=j48op49T (Green paperclips) +[2]: https://github.com/astrand/xclip +[3]: https://en.wikipedia.org/wiki/Tail_(Unix) +[4]: https://plaintextproject.online +[5]: https://gumroad.com/l/learnmarkdown +[6]: https://pandoc.org +[7]: https://docs.gitlab.com/ee/user/project/pages/ +[8]: https://certbot.eff.org/ +[9]: https://en.wikipedia.org/wiki/Cat_(Unix) diff --git a/published/201907/20190705 Manage your shell environment.md b/published/201907/20190705 Manage your shell environment.md new file mode 100644 index 0000000000..9f7d8d9612 --- /dev/null +++ b/published/201907/20190705 Manage your shell environment.md @@ -0,0 +1,121 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11095-1.html) +[#]: subject: (Manage your shell environment) +[#]: via: (https://fedoramagazine.org/manage-your-shell-environment/) +[#]: author: (Eduard Lucena https://fedoramagazine.org/author/x3mboy/) + +管理你的 shell 环境 +====== + +![][1] + +前段时间,Fedora Magazine 发表了一篇 [介绍 ZSH][2] 的文章,它是 Fedora 默认的 bash shell 的替代品。这一次,我们将着重定制它来更有效地使用它。本文中显示的所有概念也适用于其他 shell,例如 bash。 + +### 别名 + +别名是命令的快捷方式。为那些需要经常执行,但需要很长时间输入的长命令创建快捷方式很有用。语法是: + +``` +$ alias yourAlias='complex command with arguments' +``` + +它们并不总是用来缩短长命令。重要的是,你将它们用于你经常执行的任务。可能的例子: + +``` +$ alias dnfUpgrade='dnf -y upgrade' +``` + +这样,为了进行系统升级,我只需输入 `dnfUpgrade` 而不用输入完整的 `dnf` 命令。 + +在终端中设置别名的问题是,一旦终端会话关闭,别名就会丢失。要永久设置它们,请使用资源文件。 + +### 资源文件 + +资源文件(即 rc 文件)是在会话或进程开始时(每个用户在开启新终端窗口或启动 vim 等新程序时)加载的配置文件。对于 ZSH,资源文件是 `.zshrc`,对于 bash,它是 `.bashrc`。 + +要使别名成为永久别名,你可以将它们放入资源文件中。你可以使用你选择的文本编辑器编辑资源文件。这里使用 vim: + +``` +$ vim $HOME/.zshrc +``` + +或者对于 bash: + +``` +$ vim $HOME/.bashrc +``` + +请注意,资源文件的位置是相对于家目录指定的。这是 ZSH(或 bash)默认为每个用户查找该文件的位置。 + +还有一种是将你的配置放在任何其他文件中,然后读取它: + +``` +$ source /path/to/your/rc/file +``` + +同样,在会话中直接读取它只会将其应用于会话,因此要使其永久化,请将 `source` 命令添加到资源文件中。将文件放在不同位置的优点是你可以随时读取它。这在共享环境中很有用。 + +### 环境变量 + +环境变量是分配了特定名称的值,你可以在脚本和命令中调用它们。它们以美元符号(`$`)开始。其中最常见的是指向主目录的 `$HOME`。 + +顾名思义,环境变量是你环境的一部分。使用以下语法设置变量: + +``` +$ http_proxy="http://your.proxy" +``` + +要使其成为环境变量,请使用以下命令将其导出: + +``` +$ export $http_proxy +``` + +要查看当前设置的所有环境变量,请使用 `env` 命令: + +``` +$ env +``` + +该命令输出会话中可用的所有变量。要演示如何在命令中使用它们,请尝试运行以下 `echo` 命令: + +``` +$ echo $PWD +/home/fedora +$ echo $USER +fedora +``` + +这里发生了变量扩展,即存储在变量中的值在命令中使用。 + +另一个有用的变量是 `$PATH`,它定义了 shell 查找二进制文件的目录。 + +### $PATH 变量 + +有许多对于操作系统很重要的目录或文件夹(在图形环境中调用它们的方式)。某些目录设置为保存可直接在 shell 中使用的二进制文件。这些目录在 `$PATH` 变量中定义。 + +``` +$ echo $PATH +/usr/lib64/qt-3.3/bin:/usr/share/Modules/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/usr/libexec/sdcc:/usr/libexec/sdcc:/usr/bin:/bin:/sbin:/usr/sbin:/opt/FortiClient +``` + +当你希望在 shell 中访问自己的二进制文件(或脚本)时,这会有帮助。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/manage-your-shell-environment/ + +作者:[Eduard Lucena][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/x3mboy/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2018/05/manage-shell-env-816x345.jpg +[2]: https://fedoramagazine.org/set-zsh-fedora-system/ diff --git a/published/201907/20190706 How To Delete A Repository And GPG Key In Ubuntu.md b/published/201907/20190706 How To Delete A Repository And GPG Key In Ubuntu.md new file mode 100644 index 0000000000..896f70428d --- /dev/null +++ b/published/201907/20190706 How To Delete A Repository And GPG Key In Ubuntu.md @@ -0,0 +1,136 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11115-1.html) +[#]: subject: (How To Delete A Repository And GPG Key In Ubuntu) +[#]: via: (https://www.ostechnix.com/how-to-delete-a-repository-and-gpg-key-in-ubuntu/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +如何在 Ubuntu 中删除仓库及其 GPG 密钥 +====== + +![Delete A Repository And GPG Key In Ubuntu][1] + +前几天我们讨论了如何在基于 RPM 和 DEB 的系统中[列出已安装的仓库][2]。今天,我们将学习如何在 Ubuntu 中删除仓库及其 GPG 密钥。对于不知道仓库的人,仓库(简称 repo)是开发人员存储软件包的地方。仓库的软件包经过全面测试,并由 Ubuntu 开发人员专门为每个版本构建。用户可以使用 Apt 包管理器在他们的 Ubuntu 系统上下载和安装这些包。Ubuntu 有四个官方仓库,即 Main、Universe、Restricted 和 Multiverse。 + +除了官方仓库外,还有许多由开发人员(或软件包维护人员)维护的非官方仓库。非官方仓库通常有官方仓库中不可用的包。所有包都由包维护者用一对密钥(公钥和私钥)签名。如你所知,公钥是发给用户的,私钥必须保密。每当你在源列表中添加新的仓库时,如果 Apt 包管理器想要信任新添加的仓库,你还应该添加仓库密钥(公钥)。使用仓库密钥,你可以确保从正确的人那里获得包。到这里希望你对软件仓库和仓库密钥有了一个基本的了解。现在让我们继续看看如果在 Ubuntu 系统中不再需要仓库及其密钥,那么该如何删除它。 + +### 在 Ubuntu 中删除仓库 + +每当使用 `add-apt-repository` 命令添加仓库时,它都将保存在 `/etc/apt/sources.list` 中。 + +要从 Ubuntu 及其衍生版中删除软件仓库,只需打开 `/etc/apt/sources.list` 文件并查找仓库名字并将其删除即可。 + +``` +$ sudo nano /etc/apt/sources.list +``` + +正如你在下面的截图中看到的,我在我的 Ubuntu 系统中添加了 [Oracle Virtualbox][3] 仓库。 + +![][4] + +*virtualbox 仓库* + +要删除此仓库,只需删除该条目即可。保存并关闭文件。 + +如果你已添加 PPA 仓库,请查看 `/etc/apt/sources.list.d/` 目录并删除相应的条目。 + +或者,你可以使用 `add-apt-repository` 命令删除仓库。例如,我要删除 [Systemback][5] 仓库,如下所示。 + +``` +$ sudo add-apt-repository -r ppa:nemh/systemback +``` + +最后,使用以下命令更新软件源列表: + +``` +$ sudo apt update +``` + +### 删除仓库密钥 + +我们使用 `apt-key` 命令添加仓库密钥。首先,让我们使用命令列出添加的密钥: + +``` +$ sudo apt-key list +``` + +此命令将列出所有添加的仓库密钥。 + +``` +/etc/apt/trusted.gpg +-------------------- +pub rsa1024 2010-10-31 [SC] +3820 03C2 C8B7 B4AB 813E 915B 14E4 9429 73C6 2A1B +uid [ unknown] Launchpad PPA for Kendek + + +pub rsa4096 2016-04-22 [SC] +B9F8 D658 297A F3EF C18D 5CDF A2F6 83C5 2980 AECF +uid [ unknown] Oracle Corporation (VirtualBox archive signing key) <[email protected]> +sub rsa4096 2016-04-22 [E] + + +/etc/apt/trusted.gpg.d/ubuntu-keyring-2012-archive.gpg +------------------------------------------------------ +pub rsa4096 2012-05-11 [SC] +790B C727 7767 219C 42C8 6F93 3B4F E6AC C0B2 1F32 +uid [ unknown] Ubuntu Archive Automatic Signing Key (2012) <[email protected]> + + +/etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg +------------------------------------------------------ +pub rsa4096 2012-05-11 [SC] +8439 38DF 228D 22F7 B374 2BC0 D94A A3F0 EFE2 1092 +uid [ unknown] Ubuntu CD Image Automatic Signing Key (2012) <[email protected]> + + +/etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg +------------------------------------------------------ +pub rsa4096 2018-09-17 [SC] +F6EC B376 2474 EDA9 D21B 7022 8719 20D1 991B C93C +uid [ unknown] Ubuntu Archive Automatic Signing Key (2018) <[email protected]> +``` + +正如你在上面的输出中所看到的,那串长的(40 个字符)十六进制值是仓库密钥。如果你希望 APT 包管理器停止信任该密钥,只需使用以下命令将其删除: + +``` +$ sudo apt-key del "3820 03C2 C8B7 B4AB 813E 915B 14E4 9429 73C6 2A1B" +``` + +或者,仅指定最后 8 个字符: + +``` +$ sudo apt-key del 73C62A1B +``` + +完成!仓库密钥已被删除。运行以下命令更新仓库列表: + +``` +$ sudo apt update +``` + +资源: + + * [软件仓库 – Ubuntu 社区 Wiki][6] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-delete-a-repository-and-gpg-key-in-ubuntu/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/07/Delete-a-repository-in-ubuntu-720x340.png +[2]: https://www.ostechnix.com/find-list-installed-repositories-commandline-linux/ +[3]: https://www.ostechnix.com/install-oracle-virtualbox-ubuntu-16-04-headless-server/ +[4]: https://www.ostechnix.com/wp-content/uploads/2019/07/virtualbox-repository.png +[5]: https://www.ostechnix.com/systemback-restore-ubuntu-desktop-and-server-to-previous-state/ +[6]: https://help.ubuntu.com/community/Repositories/Ubuntu diff --git a/published/201907/20190706 How to enable DNS-over-HTTPS (DoH) in Firefox.md b/published/201907/20190706 How to enable DNS-over-HTTPS (DoH) in Firefox.md new file mode 100644 index 0000000000..7a4e915b9e --- /dev/null +++ b/published/201907/20190706 How to enable DNS-over-HTTPS (DoH) in Firefox.md @@ -0,0 +1,95 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11163-1.html) +[#]: subject: (How to enable DNS-over-HTTPS (DoH) in Firefox) +[#]: via: (https://www.zdnet.com/article/how-to-enable-dns-over-https-doh-in-firefox/) +[#]: author: (Catalin Cimpanu https://www.zdnet.com/meet-the-team/us/catalin.cimpanu/) + +如何在 Firefox 中启用 DNS-over-HTTPS(DoH) +====== + +DNS-over-HTTPS(DoH)协议目前是谈论的焦点,Firefox 是唯一支持它的浏览器。但是,Firefox 默认不启用此功能,用户必须经历许多步骤并修改多个设置才能启动并运行 DoH。 + +在开始如何在 Firefox 中启用 DoH 支持的分步教程之前,让我们先描述它的原理。 + +### DNS-over-HTTPS 的工作原理 + +DNS-over-HTTPS 协议通过获取用户在浏览器中输入的域名,并向 DNS 服务器发送查询,以了解托管该站点的 Web 服务器的 IP 地址。 + +这也是正常 DNS 的工作原理。但是,DoH 通过 443 端口的加密 HTTPS 连接接受 DNS 查询将其发送到兼容 DoH 的 DNS 服务器(解析器),而不是在 53 端口上发送纯文本。这样,DoH 就会在常规 HTTPS 流量中隐藏 DNS 查询,因此第三方监听者将无法嗅探流量,并了解用户的 DNS 查询,从而推断他们将要访问的网站。 + +此外,DNS-over-HTTPS 的第二个特性是该协议工作在应用层。应用可以带上内部硬编码的 DoH 兼容的 DNS 解析器列表,从而向它们发送 DoH 查询。这种操作模式绕过了系统级别的默认 DNS 设置,在大多数情况下,这些设置是由本地 Internet 服务提供商(ISP)设置的。这也意味着支持 DoH 的应用可以有效地绕过本地 ISP 流量过滤器并访问可能被本地电信公司或当地政府阻止的内容 —— 这也是 DoH 目前被誉为用户隐私和安全的福音的原因。 + +这是 DoH 在推出后不到两年的时间里获得相当大的普及的原因之一,同时也是一群[英国 ISP 因为 Mozilla 计划支持 DoH 协议而提名它为 2019 年的“互联网恶棍” (Internet Villian)][1]的原因,ISP 认为 DoH 协议会阻碍他们过滤不良流量的努力。(LCTT 译注:后来这一奖项的提名被取消。) + +作为回应,并且由于英国政府阻止访问侵犯版权内容的复杂情况,以及 ISP 自愿阻止访问虐待儿童网站的情况,[Mozilla 已决定不为英国用户默认启用此功能][2]。 + +下面的分步指南将向英国和世界各地的 Firefox 用户展示如何立即启用该功能,而不用等到 Mozilla 将来启用它 —— 如果它会这么做的话。在 Firefox 中有两种启用 DoH 支持的方法。 + +### 方法 1:通过 Firefox 设置 + +**步骤 1:**进入 Firefox 菜单,选择**工具**,然后选择**首选项**。 可选在 URL 栏中输入 `about:preferences`,然后按下回车。这将打开 Firefox 的首选项。 + +**步骤 2:**在**常规**中,向下滚动到**网络设置**,然后按**设置**按钮。 + +![DoH section in Firefox settings][3] + +**步骤3:**在弹出窗口中,向下滚动并选择“**Enable DNS over HTTPS**”,然后配置你需要的 DoH 解析器。你可以使用内置的 Cloudflare 解析器(该公司与 Mozilla [达成协议][4],记录更少的 Firefox 用户数据),或者你可以在[这个列表][4]中选择一个。 + +![DoH section in Firefox settings][6] + +### 方法 2:通过 about:config + +**步骤 1:**在 URL 栏中输入 `about:config`,然后按回车访问 Firefox 的隐藏配置面板。在这里,用户需要启用和修改三个设置。 + +**步骤 2:**第一个设置是 `network.trr.mode`。这打开了 DoH 支持。此设置支持四个值: + +* `0` - 标准 Firefox 安装中的默认值(当前为 5,表示禁用 DoH) +* `1` - 启用 DoH,但 Firefox 依据哪个请求更快返回选择使用 DoH 或者常规 DNS +* `2` - 启用 DoH,常规 DNS 作为备用 +* `3` - 启用 DoH,并禁用常规 DNS +* `5` - 禁用 DoH + +值为 2 工作得最好 + +![DoH in Firefox][7] + +**步骤3:**需要修改的第二个设置是 `network.trr.uri`。这是与 DoH 兼容的 DNS 服务器的 URL,Firefox 将向它发送 DoH DNS 查询。默认情况下,Firefox 使用 Cloudflare 的 DoH服务,地址是:。但是,用户可以使用自己的 DoH 服务器 URL。他们可以从[这个列表][8]中选择其中一个可用的。Mozilla 在 Firefox 中使用 Cloudflare 的原因是因为与这家公司[达成了协议][4],之后 Cloudflare 将收集来自 Firefox 用户的 DoH 查询的非常少的数据。 + +[DoH in Firefox][9] + +**步骤4:**第三个设置是可选的,你可以跳过此设置。 但是如果设置不起作用,你可以使用此作为步骤 3 的备用。该选项名为 `network.trr.bootstrapAddress`,它是一个输入字段,用户可以输入步骤 3 中兼容 DoH 的 DNS 解析器的 IP 地址。对于 Cloudflare,它是 1.1.1.1。 对于 Google 服务,它是 8.8.8.8。 如果你使用了另一个 DoH 解析器的 URL,如果有必要的话,你需要追踪那台服务器的 IP 地址并输入。 + +![DoH in Firefox][10] + +通常,在步骤 3 中输入的 URL 应该足够了。 +设置应该立即生效,但如果它们不起作用,请重新启动 Firefox。 + +文章信息来源:[Mozilla Wiki][11] + + +-------------------------------------------------------------------------------- + +via: https://www.zdnet.com/article/how-to-enable-dns-over-https-doh-in-firefox/ + +作者:[Catalin Cimpanu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.zdnet.com/meet-the-team/us/catalin.cimpanu/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-11068-1.html +[2]: https://www.zdnet.com/article/mozilla-no-plans-to-enable-dns-over-https-by-default-in-the-uk/ +[3]: https://zdnet1.cbsistatic.com/hub/i/2019/07/07/df30c7b0-3a20-4de7-8640-3dea6d249a49/121bd379b6232e1e2a97c35ea8c7764e/doh-settings-1.png +[4]: https://developers.cloudflare.com/1.1.1.1/commitment-to-privacy/privacy-policy/firefox/ +[6]: https://zdnet3.cbsistatic.com/hub/i/2019/07/07/8608af28-2a28-4ff1-952b-9b6d2deb1ea6/b1fc322caaa2c955b1a2fb285daf0e42/doh-settings-2.png +[7]: https://zdnet1.cbsistatic.com/hub/i/2019/07/06/0232b3a7-82c6-4a6f-90c1-faf0c090254c/6db9b36509021c460fcc7fe825bb74c5/doh-1.png +[8]: https://github.com/curl/curl/wiki/DNS-over-HTTPS#publicly-available-servers +[9]: https://zdnet2.cbsistatic.com/hub/i/2019/07/06/4dd1d5c1-6fa7-4f5b-b7cd-b544748edfed/baa7a70ac084861d94a744a57a3147ad/doh-2.png +[10]: https://zdnet1.cbsistatic.com/hub/i/2019/07/06/8ec20a28-673c-4a17-8195-16579398e90a/538fe8420f9b24724aeb4a6c8d4f0f0f/doh-3.png +[11]: https://wiki.mozilla.org/Trusted_Recursive_Resolver diff --git a/published/201907/20190706 Say WHAAAT- Mozilla has Been Nominated for the -Internet Villain- Award in the UK.md b/published/201907/20190706 Say WHAAAT- Mozilla has Been Nominated for the -Internet Villain- Award in the UK.md new file mode 100644 index 0000000000..feddddee95 --- /dev/null +++ b/published/201907/20190706 Say WHAAAT- Mozilla has Been Nominated for the -Internet Villain- Award in the UK.md @@ -0,0 +1,100 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11068-1.html) +[#]: subject: (Say WHAAAT? Mozilla has Been Nominated for the “Internet Villain” Award in the UK) +[#]: via: (https://itsfoss.com/mozilla-internet-villain/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +什么?!Mozilla 被提名英国“互联网恶棍”奖 +====== + +Mozilla Firefox 是目前最流行的浏览器之一。很多用户喜欢它胜过 Chrome 就是因为它鼓励隐私保护,并且可以通过一些选项设置让你的互联网活动尽可能地私密。 + +不过最近推出的功能之一 —— 仍然处于测试阶段的 [DoH (DNS-over-HTTPS)][1] 功能却受到了英国互联网服务提供商行业协会的负面评价。 + +英国互联网服务提供商行业协会Internet Services Providers Association(ISPA)决定将 Mozilla 列入 2019 年“互联网恶棍”奖的最终入围者名单。该奖项将在 ISPA 于 7 月 11 日在伦敦举行的颁奖典礼上进行颁发。 + +![][3] + +### 为什么说 “Mozilla” 是 “互联网恶棍”? + +ISPA 在他们的声明中表示,Mozilla 因为支持了 DoH(DNS-over-HTTPS)而被视为“互联网恶棍”。 + +> [@mozilla][4] 被提名为 [#ISPA][5] 的 [#互联网恶棍][6] 是因为他们试图推行 DNS-over-HTTPS 以绕开英国的内容过滤系统和家长监护模式,破坏了英国 [#互联网][7] 安全准则。 [pic.twitter.com/WeZhLq2uvi][8] +> +> — 英国互联网提供商行业协会 (ISPAUK) (@ISPAUK) [2019 年 7 月 4 日][9] + +![](https://pbs.twimg.com/media/D-n8WlvX4AAnWIW.jpg) + +和 Mozilla 一同被列入最终入围者名单的还有欧盟《版权法第 13 条》和美国总统特朗普。ISPA 在他们的声明里是这样解释的: + +**Mozilla**:因为试图推行 DNS-over-HTTPS 以绕开英国的内容过滤系统和家长监护模式,破坏了英国互联网安全准则。 + +**欧盟《版权法第 13 条》**:因为要求各平台使用“内容识别技术”,威胁到了线上言论自由。 + +**美国总统特朗普**:因为在试图保护其国家安全的过程中,为复杂的全球通信供应链带来了巨大的不确定性。 + +### 什么是 DNS-over-HTTPS? + +你可以将 DoH 理解为,域名解析服务(DNS)的请求通过 HTTPS 连接加密传输。 + +传统意义上的 DNS 请求是不会被加密的,因此你的 DNS 提供商或者是互联网服务提供商(ISP)可以监视或者是控制你的浏览行为。如果没有 DoH,你很容易被 DNS 提供商强制拦截和进行内容过滤,并且你的互联网服务提供商也同样可以做到。 + +然而 DoH 颠覆了这一点,可以让你得到一个私密的浏览体验。 + +你可以研究一下 [Mozilla 是如何开展和 Cloudflare 的合作的][11],并且可以自己配置一下 DoH(如果需要的话)。 + +### DoH 有用吗? + +既有用又没有用。 + +当然了,从事情的一方面来看,DoH 可以帮助用户绕过 DNS 或者互联网服务提供商强制的内容过滤系统。如果说 DoH 有助于满足我们避开互联网审查的需求,那么它是一件好事情。 + +不过从事情的另一方面来看,如果你是一位家长,而你的孩子在 Mozilla Firefox 上使用了 DoH 的话,你就无法 [设置内容过滤器][12] 了。这取决于 [防火墙配置][13] 的好坏。 + +DoH 可能会成为一些人绕过家长监护的手段,这可能不是一件好事。 + +如果我这样的说法有问题,你可以在下面的评论区纠正我。 + +并且,使用 DoH 就意味着你没办法使用本地 host 文件了(如果你正用它作为广告拦截或者是其它用途的话)。 + +### 总结 + +你是如何看待 DoH 的呢?它足够好吗? + +你又是如何看待 ISPA 的决定的呢?你觉得他们这样的声明是不是在鼓励互联网审查和政府对网民的监控呢? + +我个人觉得这个提名决定非常可笑。即使 DoH 并不是所有人都需要的那个终极功能,能够有一种保护个人隐私的选择也总不是件坏事。 + +在下面的评论区里发表你的看法吧。最后我想引用这么一句话: + +> 在谎言遍地的时代,说真话是一种革命行为。(LCTT 译注:引自乔治奥威尔) + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/mozilla-internet-villain/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/DNS_over_HTTPS +[2]: https://www.ispa.org.uk/ispa-announces-finalists-for-2019-internet-heroes-and-villains-trump-and-mozilla-lead-the-way-as-villain-nominees/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/mozilla-internet-villain.jpg?resize=800%2C450&ssl=1 +[4]: https://twitter.com/mozilla?ref_src=twsrc%5Etfw +[5]: https://twitter.com/hashtag/ISPAs?src=hash&ref_src=twsrc%5Etfw +[6]: https://twitter.com/hashtag/InternetVillain?src=hash&ref_src=twsrc%5Etfw +[7]: https://twitter.com/hashtag/internet?src=hash&ref_src=twsrc%5Etfw +[8]: https://t.co/WeZhLq2uvi +[9]: https://twitter.com/ISPAUK/status/1146725374455373824?ref_src=twsrc%5Etfw +[10]: https://itsfoss.com/why-firefox/ +[11]: https://blog.nightly.mozilla.org/2018/06/01/improving-dns-privacy-in-firefox/ +[12]: https://itsfoss.com/how-to-block-porn-by-content-filtering-on-ubuntu/ +[13]: https://itsfoss.com/set-up-firewall-gufw/ diff --git a/published/201907/20190708 10 ways to get started with Linux.md b/published/201907/20190708 10 ways to get started with Linux.md new file mode 100644 index 0000000000..49ba29a574 --- /dev/null +++ b/published/201907/20190708 10 ways to get started with Linux.md @@ -0,0 +1,184 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11124-1.html) +[#]: subject: (10 ways to get started with Linux) +[#]: via: (https://opensource.com/article/19/7/ways-get-started-linux) +[#]: author: (Seth Kenlon https://opensource.com/users/seth/users/don-watkins) + +Linux 入门十法 +====== + +> 想要进入 Linux 之门,试试这十个方法。 + +![](https://img.linux.net.cn/data/attachment/album/201907/20/061809wwkmb51vqookoqq5.jpg) + +文章《[什么是 Linux 用户?][2]》的作者 Anderson Silva 明确表示,现今人们使用 Linux(在某种程度上)就像使用 Windows 一样,只要你对“使用 Linux”这个事情定义得足够广义。尽管如此,如果你的生活中没有太多的使用 Linux 的机会,现在正是以前所未有的方式尝试 Linux 的好时机。 + +以下是 Linux 入门的十种方法。你可以试试其中一个或者全部试试。 + +### 1、加入免费 shell 计划 + +![Free shell screenshot][3] + +有很多人在用不上的服务器上运行 Linux (请记住,“Linux 服务器”可以是从最新的超级计算机到丢弃的、已经用了 12 年的笔记本电脑中的任何一个)。为了充分利用多余的计算机,许多管理员用这些备用的机器提供了免费的 shell 帐户。 + +如果你想要登录到 Linux 终端中学习命令、shell 脚本、Python 以及 Web 开发的基础知识,那么免费的 shell 帐户是一种简单、免费的入门方式。下面是一个可以体验一下的简短列表: + +* [Freeshell.de][4] 是一个自 2002 年以来一直在线服务的公用 Linux 系统。你可以通过 SSH、IPv6 和 OpenSSL 进行访问,以获得 Linux shell 体验,并且可以使用 MySQL 数据库。 +* [Blinkenshell][5] 提供了一个学习 Unix、使用 IRC、托管简单网站和共享文件的 Linux shell。它自 2006 年以来一直在线服务。 +* [SDF 公用 Unix 系统][6]成立于 1987 年,提供了免费的 NetBSD 账户。当然,NetBSD 不是 Linux,但它是开源的 Unix,因此它提供了类似的体验。它也有几个自制应用程序,因此它不但有普通的免费 shell,还提供了老派 BBS。 + +免费 shell 帐户常会受到滥用,因此你表现出的可信程度和积极参与协作的意愿越多,你的体验就越好。你可以通过专门请求或小额捐赠来证明你的诚意,通常可以访问数据库引擎、编译器和高级编程语言。你还可以要求安装其他软件或库,但需经管理员批准。 + +#### 如何使用 + +公用 shell 帐户是尝试真正的 Linux 系统的好方法。你无法获得 root 权限这一事实意味着你可以学习本地软件管理,而无需做更多的维护工作。你可以做很多实际操作,以完成真正的工作,尽管它们对于学习关键任务还不够。 + +### 2、试试 Windows WSL 2 里面的 Linux + +不管你信不信,微软从 2019 年 6 月开始在 Windows 里面带上了 Linux,这意味着你可以从 Windows 运行 Linux 应用程序,这是 [Windows 里的 Linux 子系统][7]的第二版(WSL 2)。虽然它主要针对开发人员,但 Windows 用户可以发现 WSL 2 是一个来自于他们熟悉的桌面上的 Linux 环境,而没有被任何虚拟化占用额外资源。这是一个以进程方式运行在 Windows 机器上的 Linux。现阶段,它仍然是一个新的动向和正在进行中的工作,因此它可能会发生变化。如果你试图用它承担重任,你可能会遇到一两个错误,但是如果你只是想入门 Linux、学习一些命令,并感受在基于文本的环境如何完成工作,那么 WSL 2 可能正是你所需要的。 + +#### 如何使用 + +WSL 还没有明确的用途或目的,但它在 Windows 机器上提供了 Linux 环境。你可以获得 root 访问权限,并可以运行 Linux 发行版和应用程序,因此这是一种简单而无缝的学习方式。但是,即使 WSL *是Linux*,它也不能给你典型的 Linux 体验。它是由 Windows 提供的 Linux,而这不太会是你在现实世界中遇到的情况。WSL 是一个开发和教育工具,但如果你可以使用它,那么你应该试试它。 + +### 3、把 Linux 放到可启动的 U 盘上 + +![Porteus Linux][8] + +便携 Linux 可以安装到 U 盘上随身携带,并用该 U 盘启动你遇到的任何计算机。你可以获得个性化的 Linux 桌面,而无需担心所用于启动的主机上的数据。该计算机上原有的系统不会与你的 Linux 系统相接触,并且你的 Linux 操作系统也不会影响计算机。它非常适合酒店商务中心、图书馆、学校的公共计算机,或者只是给自己一个不时启动 Linux 的借口。 + +与许多其他快速获得的 Linux shell 不同,此方法为你提供了一个完整而强大的 Linux 系统,包括桌面环境,可访问你需要的任何软件以及持久的数据存储。 + +这个系统永远不会改变。你要保存的任何数据都将写入压缩的文件系统中,然后在引导时将其作为覆盖层应用于该系统。这种灵活性允许你选择是以持久模式启动,将所有数据保存回 U 盘;还是以临时模式启动,以便一旦关闭电源,你所做的一切都会消失。换句话说,你可以将其用作不受信任的计算机上的安全信息亭或你信任的计算机上的便携式操作系统。 + +你可以尝试很多 [U 盘发行版][9],有些带有精简的桌面环境,适用于低功耗计算机,而另一些带有完整的桌面环境。我偏爱 [Porteus][10] Linux。在过去的八年里,我每天都把它放在我的钥匙链上,在商务旅行中使用它作为我的主要计算平台,如果在工作场所或家中计算机发生问题,它也会用作工具盘。它是一个可靠而稳定的操作系统,有趣且易于使用。 + +在 Mac 或 Windows 上,下载 [Fedora Media Writer][11] 以创建你下载的任何便携式发行版的可启动 U 盘。 + +#### 如何使用 + +从 U 盘启动一个 “实时 Linux” 可提供完整的 Linux 发行版环境。虽然数据存储与你安装到硬盘驱动器的系统略有不同,但其它的所有内容都与你在 Linux 桌面上所期望的一样。在便携式 Linux 操作系统上你几乎没有什么不能做的,所以在你的钥匙串上挂上一个以解锁你遇到的每台计算机的全部潜力吧。 + +### 4、在线游览 + +![Linux tour screenshot][12] + +Ubuntu 的某个人想到了在浏览器中托管 Ubuntu GNOME 桌面的好主意。如果想要自己尝试一下,可以打开 Web 浏览器并导航到 [tour.ubuntu.com][13]。你可以选择要演示的活动,也可以跳过单个课程并单击 “四处看看Show Yourself Around” 按钮。 + +即使你是 Linux 桌面的新用户,你也可能会发现“四处看看”功能比你想象的更还简单。在线游览中,你可以四处看看,查看可用的应用程序,以及查看典型的默认 Linux 桌面。你不能在 Firefox 中调整设置或启动另一个在线游览(这是我尝试过的第一件事),虽然你可以完成安装应用程序的动作,但你无法启动它们。但是,如果你之前从未使用过 Linux 桌面,并且想要看到各种新奇的东西,那这就是一场旋风之旅。 + +#### 如何使用 + +在线游览真的只是一次旅行。如果你从未见过 Linux 桌面,那么这是一个了解它的情况的机会。这不是一个正式的使用,而是一个吸引过客的展示。 + +### 5、在浏览器中用 JavaScript 运行 Linux + +![JSLinux][14] + +就在不久之前,虚拟化的计算成本还很高,还仅限于使用先进的硬件的用户。而现在虚拟化已被优化到可以由 JavaScript 引擎执行的程度,这要归功于 Fabrice Bellard,它是优秀的开源 [QEMU][15] 机器仿真器和虚拟器的创建者。 + +Bellard 还启动了 JSLinux 项目,该项目允许你在浏览器中运行 Linux 和其他操作系统,这算是闲暇时间的一个乐趣。它仍然是一个实验性项目,但它是一个技术奇迹。打开 Web 浏览器导航到 [JSLinux][16] 页面,你可以启动基于文本的 Linux shell 或精简的图形 Linux 环境。你可以上传和下载文件到 JSLinux 主机上或(在理论上可以)将文件发送到一个网络备份位置,因为 JSLinux 可以通过 VPN 套接字访问互联网(尽管上限速度取决于 VPN 服务)。 + +#### 如何使用 + +你不会在 JSLinux 上正经使用多少时间,这个环境可能太不寻常了,无法学习 Linux 正常工作的广泛课程。但是,如果你厌倦了在一台普通的 PC 上运行 Linux 并想在一个真正独特的平台上试用 Linux,那么 JSLinux 就属于这种。 + +### 6、阅读关于它的书 + +并非每种 Linux 体验都要用到计算机。也许你是那种喜欢在开始新事物之前保持距离先观察和研究的人,或者你可能还不清楚 “Linux” 所包含的内容,或者你喜欢全情投入其中。关于 Linux 如何工作、运行 Linux 的方式以及 Linux 世界中有什么,有很多书可以读。 + +你越熟悉开源世界,就越容易理解常用术语,将城市神话与实际经验区分开来。我们不时会发布[图书清单] [17],但我的最爱之一是 Hazel Russman 的《[The Charm of Linux][18]》。这是一个从不同角度巡览 Linux 的过程,是由一位独立作者在发现 Linux 时兴奋之余写作的。 + +#### 如何使用 + +没有什么能比一本好书更好。这是体验 Linux 的最不传统的方法,但对于喜欢印刷文字的人来说,它既舒适又有效。 + +### 7、弄块树莓派 + +![Raspberry Pi 4][19] + +如果你正在使用[树莓派][20],那么你就正在运行 Linux。Linux 和低功耗计算很容易上手。关于树莓派的好处,除了价格低于 100 美元之外,它的[网站][21]是专为教育而设计的。你可以了解树莓派所能做的一切,当你了解之后,就知道了 Linux 可以为你做些什么。 + +#### 如何使用 + +树莓派被设计为低功耗计算机。这意味着你不能像过去那样做那么多的多任务处理,但这是一种避免不堪重负的方便方法。树莓派是学习 Linux 及其附带的所有可能性的好方法,它是发现环保、小型、简化计算能力的有趣方式。并且一定要关注 Opensource.com 上的[提示][22]、[技巧][23]和[有趣的][24][活动] [25],特别是在每年三月份的树莓派之周的期间。 + +### 8、赶上容器热潮 + +如果你从事于神话般的[云服务][26]的后端工作,那么你已经听说过容器热潮。虽然你可以在 Windows、Azure、Mac 和 Linux 上运行 Docker 和 Kubernetes,但你可能不知道容器本身就是 Linux。云计算应用和基础设施实际上是精简的 Linux 系统,部分虚拟化,部分基于裸机。如果启动容器,则会启动微型的超特定的 Linux 发行版。 + +容器与虚拟机或物理服务器[不同][27]。它们不打算用作通用操作系统。但是,如果你在容器中进行开发,你可以停下来四处打量一下,你将了解到 Linux 系统的结构、保存重要文件的位置以及最常见的命令。你甚至可以[在线尝试容器][28],你可以在我的文章中[深入到 Linux 容器的背后][29]了解它们如何工作的。 + +#### 如何使用 + +根据设计,容器特定于一个单一任务,但它们是 Linux,因此它们非常灵活。你可以如你预期的使用它们,也可以在你的 Linux 实验当中将容器构建到大部分完整系统中。它虽然不提供桌面 Linux 体验,但它是完整的 Linux 体验。 + +### 9、以虚拟机方式安装 Linux + +虚拟化是尝试操作系统的简便方法,[VirtualBox][30] 是一种很好的开源虚拟化方法。VirtualBox 可以在 Windows 和 Mac 上运行,因此你可以将 Linux 安装为虚拟机(VM)并使用它,就好像它只是一个应用程序一样。如果你不习惯安装操作系统,VirtualBox 也是一种尝试 Linux 的非常安全的方式,而不会意外地将其安装覆盖在你通常的操作系统上。 + +#### 如何使用 + +将 Linux 作为虚拟机运行既方便又简单,既可以作为试运行使用,也可以在需要 Linux 环境时进行双启动或重启进入。它功能齐全,因为它使用虚拟硬件,宿主操作系统负责驱动你的外围设备。将 Linux 作为虚拟机运行的唯一缺点主要是心理上的。如果你打算使用 Linux 作为主要操作系统,但最终默认在宿主操作系统上做除了特定于 Linux 的大多数任务,那么虚拟机就会让你失望。否则,虚拟机是现代技术的胜利,在 VirtualBox 中使用 Linux 可以为你提供 Linux 所提供的所有最佳功能。 + +### 10、安装一个 Linux + +![Fedora Silverblue][31] + +如果对上述方式有疑问,那么总会有传统的方式。如果你想给予 Linux 应有的关注,你可以下载 Linux,将安装程序刻录到 U 盘(或 DVD,如果你更喜欢光学介质的话),并将其安装在你的计算机上。Linux 是开源的,所以任何想要花时间打包 Linux 的人都可以分发 Linux,并且可以将所有可用的部分分配到通常称为发行版的内容中。无论问哪一个 Linux 用户什么发行版是“最好的”,你必然都会得到一个不同的答案(主要是因为这个术语“最佳”通常是尚未定义的)。大多数人都认可:你应该使用适合你的 Linux 发行版,这意味着你应该测试一些流行的发行版,并坚持使你的计算机按照你期望的行为行事。这是一种务实和功能性的方法。例如,如果发行版无法识别你的网络摄像头而你希望它可以正常工作,则可以使用一个可识别该网络摄像头的发行版。 + +如果你之前从未安装过操作系统,你会发现大多数 Linux 发行版都包含一个友好且简单的安装程序。只需下载一个发行版(它们以 ISO 文件提供),然后下载 [Fedora Media Writer][11] 来创建一个可启动的安装 U 盘。 + +#### 如何使用 + +安装 Linux 并将其用作操作系统是迈向熟悉它的一步。怎么使用它都可以。你可能会发现一些你从未了解过的所需的必备功能,你可能会比你想象的更多地了解计算机,并且可能会改变你的世界观。你使用一个 Linux 桌面,或者是因为它易于下载和安装,或者是因为你想要削弱公司中某些人的霸主地位,或者只是因为它可以帮助你完成工作。 + +无论你的原因是什么,只需尝试使用上面这些任何(或所有)这些方式。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/ways-get-started-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_Penguin_Image_520x292_12324207_0714_mm_v1a.png?itok=p7cWyQv9 (Penguins gathered together in the Artic) +[2]: https://opensource.com/article/19/6/what-linux-user +[3]: https://opensource.com/sites/default/files/uploads/freeshell.png (Free shell screenshot) +[4]: https://freeshell.de +[5]: https://blinkenshell.org/wiki/Start +[6]: https://sdf.org/ +[7]: https://devblogs.microsoft.com/commandline/wsl-2-is-now-available-in-windows-insiders/ +[8]: https://opensource.com/sites/default/files/uploads/porteus.jpg (Porteus Linux) +[9]: https://linux.cn/article-11040-1.html +[10]: http://porteus.org +[11]: https://getfedora.org/en/workstation/download/ +[12]: https://opensource.com/sites/default/files/uploads/linux_tour.jpg (Linux tour screenshot) +[13]: http://tour.ubuntu.com/en/# +[14]: https://opensource.com/sites/default/files/uploads/jslinux.jpg (JSLinux) +[15]: https://www.qemu.org +[16]: https://bellard.org/jslinux/ +[17]: https://opensource.com/article/19/1/tech-books-new-skils +[18]: http://www.lulu.com/shop/hazel-russman/the-charm-of-linux/paperback/product-21229401.html +[19]: https://opensource.com/sites/default/files/uploads/raspberry-pi-4-case.jpg (Raspberry Pi 4) +[20]: https://opensource.com/resources/raspberry-pi +[21]: https://www.raspberrypi.org/ +[22]: https://opensource.com/article/19/3/raspberry-pi-projects +[23]: https://opensource.com/article/19/3/piflash +[24]: https://opensource.com/article/19/3/gamepad-raspberry-pi +[25]: https://opensource.com/life/16/3/make-music-raspberry-pi-milkytracker +[26]: https://opensource.com/resources/cloud +[27]: https://opensource.com/article/19/6/how-ssh-running-container +[28]: https://linuxcontainers.org/lxd/try-it/ +[29]: https://opensource.com/article/18/11/behind-scenes-linux-containers +[30]: https://virtualbox.org +[31]: https://opensource.com/sites/default/files/uploads/fedora-silverblue.png (Fedora Silverblue) diff --git a/published/201907/20190708 Command line quick tips- Permissions.md b/published/201907/20190708 Command line quick tips- Permissions.md new file mode 100644 index 0000000000..028916247a --- /dev/null +++ b/published/201907/20190708 Command line quick tips- Permissions.md @@ -0,0 +1,126 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11123-1.html) +[#]: subject: (Command line quick tips: Permissions) +[#]: via: (https://fedoramagazine.org/command-line-quick-tips-permissions/) +[#]: author: (Paul W. Frields https://fedoramagazine.org/author/pfrields/) + +命令行快速提示:权限 +====== + +![][1] + +Fedora 与所有基于 Linux 的系统一样,它提供了一组强大的安全特性。其中一个基本特性是文件和文件夹上的*权限*。这些权限保护文件和文件夹免受未经授权的访问。本文将简要介绍这些权限,并向你展示如何使用它们共享对文件夹的访问。 + +### 权限基础 + +Fedora 本质上是一个多用户操作系统,它也有*组*,用户可以是其成员。但是,想象一下一个没有权限概念的多用户系统,不同的登录用户可以随意阅读彼此的内容。你可以想象到这对隐私或安全性并不是很好。 + +Fedora 上的任何文件或文件夹都分配了三组权限。第一组用于拥有文件或文件夹的*用户*,第二组用于拥有它的*组*,第三组用于其他人,即既不是该文件的用户也不是拥有该文件的组中的用户。有时这被称为*全世界*。 + +### 权限意味着什么 + +每组权限都有三种形式:*读*、*写*和*执行*。其中每个都可以用首字母来代替,即 `r`、`w`、`x`。 + +#### 文件权限 + +对于*文件*,权限的含义如下所示: + + * 读(`r`):可以读取文件内容 + * 写(`w`):可以更改文件内容 + * 执行(`x`):可以执行文件 —— 这主要用于打算直接运行的程序或脚本 + +当你对任何文件进行详细信息列表查看时,可以看到这三组权限。尝试查看系统上的 `/etc/services` 文件: + +``` +$ ls -l /etc/services +-rw-r--r--. 1 root root 692241 Apr 9 03:47 /etc/services +``` + +注意列表左侧的权限组。如上所述,这些表明三种用户的权限:拥有该文件的用户,拥有该文件的组以及其他人。用户所有者是 `root`,组所有者是 `root` 组。用户所有者具有对文件的读写权限,`root` 组中的任何人都只能读取该文件。最后,其他任何人也只能读取该文件。(最左边的 `-` 显示这是一个常规文件。) + +顺便说一下,你通常会在许多(但不是所有)系统配置文件上发现这组权限,它们只由系统管理员而不是普通用户更改。通常,普通用户需要读取其内容。 + +#### 文件夹(目录)权限 + +对于文件夹,权限的含义略有不同: + + * 读(`r`):可以读取文件夹内容(例如 `ls` 命令) + * 写(`w`):可以更改文件夹内容(可以在此文件夹中创建或删除文件) + * 执行(`x`):可以搜索文件夹,但无法读取其内容。(这听起来可能很奇怪,但解释起来需要更复杂的文件系统细节,这超出了本文的范围,所以现在就这样吧。) + +看一下 `/etc/grub.d` 文件夹的例子: + +``` +$ ls -ld /etc/grub.d +drwx------. 2 root root 4096 May 23 16:28 /etc/grub.d +``` + +注意最左边的 `d`,它显示这是一个目录或文件夹。权限显示用户所有者(`root`)可以读取、更改和 `cd` 到此文件夹中。但是,没有其他人可以这样做 —— 无论他们是否是 `root` 组的成员。注意,你不能 `cd` 进入该文件夹。 + +``` +$ cd /etc/grub.d +bash: cd: /etc/grub.d: Permission denied +``` + +注意你自己的主目录是如何设置的: + +``` +$ ls -ld $HOME +drwx------. 221 paul paul 28672 Jul 3 14:03 /home/paul +``` + +现在,注意除了作为所有者之外,没有人可以访问此文件夹中的任何内容。这是特意的!你不希望其他人能够在共享系统上读取你的私人内容。 + +### 创建共享文件夹 + +你可以利用此权限功能轻松创建一个文件夹以在组内共享。假设你有一个名为 `finance` 的小组,其中有几个成员需要共享文档。因为这些是用户文档,所以将它们存储在 `/home` 文件夹层次结构中是个好主意。 + +首先,[使用 sudo][2] 创建一个共享文件夹,并将其设置为 `finance` 组所有: + +``` +$ sudo mkdir -p /home/shared/finance +$ sudo chgrp finance /home/shared/finance +``` + +默认情况下,新文件夹具有这些权限。注意任何人都可以读取或搜索它,即使他们无法创建或删除其中的文件: + +``` +drwxr-xr-x. 2 root root 4096 Jul 6 15:35 finance +``` + +对于金融数据来说,这似乎不是一个好主意。接下来,使用 `chmod` 命令更改共享文件夹的模式(权限)。注意,使用 `g` 更改所属组的权限,使用 `o` 更改其他用户的权限。同样,`u` 会更改用户所有者的权限: + +``` +$ sudo chmod g+w,o-rx /home/shared/finance +``` + +生成的权限看起来更好。现在,`finance` 组中的任何人(或用户所有者 `root`)都可以完全访问该文件夹及其内容: + +``` +drwxrwx---. 2 root finance 4096 Jul 6 15:35 finance +``` + +如果其他用户尝试访问共享文件夹,他们将无法执行此操作。太棒了!现在,我们的金融部门可以将文档放在一个共享的地方。 + +### 其他说明 + +还有其他方法可以操作这些权限。例如,你可能希望将此文件夹中的任何文件设置为 `finance` 组所拥有。这需要本文未涉及的其他设置,但请继续关注我们,以了解关于该主题的更多信息。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/command-line-quick-tips-permissions/ + +作者:[Paul W. Frields][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2018/10/commandlinequicktips-816x345.jpg +[2]: https://fedoramagazine.org/howto-use-sudo/ diff --git a/published/201907/20190708 Debian 10 (Buster) Installation Steps with Screenshots.md b/published/201907/20190708 Debian 10 (Buster) Installation Steps with Screenshots.md new file mode 100644 index 0000000000..c593cf7ec9 --- /dev/null +++ b/published/201907/20190708 Debian 10 (Buster) Installation Steps with Screenshots.md @@ -0,0 +1,214 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11083-1.html) +[#]: subject: (Debian 10 (Buster) Installation Steps with Screenshots) +[#]: via: (https://www.linuxtechi.com/debian-10-buster-installation-guide/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +图解 Debian 10(Buster)安装步骤 +====== + +![](https://img.linux.net.cn/data/attachment/album/201907/11/000856swbwnfyknnbn3twk.jpg) + +Debian 项目发布了它的最新稳定版 Debian 10,其代号是 “Buster”,这个发布版将获得 5 年的支持。Debian 10 可用于 32 位和 64 位系统。这个发布版带来很多新的特色,列出下面一些特色: + + * 引入新的 Debian 10 的主题 “FuturePrototype” + * 新版本的电脑桌面环境 GNOME 3.30、Cinnamon 3.8、KDE Plasma 5.14、MATE 1.20、Xfce 4.12 + * 长期支持版内核 4.19.0-4 + * 新的 Python 3 (3.7.2)、Perl 5.28、PHP 7.3 + * iptables 替换为 nftables + * 更新 LibreOffice 6.1、GIMP 2.10.8 + * 更新 OpenJDK 11、MariaDB 10.3 和 Apache 2.4.38 + * 更新 Chromium 73.0、Firefox 60.7 + * 改进 UEFI 支持 + +在这篇文章中,我们将演示如何在你的笔记本电脑和台式电脑上安装 Debian 10 “Buster” 工作站。 + +Debian 10 建议系统要求: + + * 2 GB 内存 + * 2 GHz 双核处理器 + * 10 GB 可用硬盘空间 + * 可启动安装介质(USB / DVD) + * 网络连接(可选) + +让我们跳转到 Debian 10 的安装步骤。 + +### 步骤:1)下载 Debian 10 ISO 文件 + +从它的官方入口网站,下载 Debian 10 ISO 文件, + +- https://www.debian.org/releases/buster/debian-installer/ + +ISO 文件下载完成后刻录它到 USB 或 DVD,使其可用来启动。 + +### 步骤:2)使用安装可启动介质(USB / DVD)启动你的电脑系统 + +重启你将安装 Debian 10 的电脑,转到 BIOS 设置,并设置启动介质为 USB 或 DVD。 用可启动介质启动电脑后,那么我们将看到下面的屏幕。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Choose-Graphical-Install-Debian-10.jpg) + +选择第一个选项 “Graphical Install”。 + +### 步骤:3)选择你的首选语言、位置和键盘布局 + +在这个步骤中,你将被要求选择你的首选语言。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Choose-Language-Debian10-Installation.jpg) + +点击 “Continue”。 + +选择你的首选位置,电脑系统将依照位置自动设置时区。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Select-Location-Debain10-Installation.jpg) + +现在选择适合于你安装设备的键盘布局。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Keyboard-Layout-Debian10-Installation.jpg) + +点击 “Continue” 以继续。 + +### 步骤:4)为 Debian 10 系统设置主机名称和域名 + +设置适合于你的环境的主机名,然后在 “Continue” 上单击,就我而言, 我指定主机名为 “debian10-buster”。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Hostname-During-Debian10-Installation.jpg) + +指定适合于环境的域名,并安装,然后在 “Continue” 上单击。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Domain-Name-During-Debian10-Installation.jpg) + +### 步骤:5)指定 root 用户的密码 + +在下面的屏幕中指定 root 密码,然后在 “Continue” 上单击。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Root-Password-Debian10-Installation.jpg) + +### 步骤:6)创建本地用户和它的密码 + +在这个步骤中,你将被提示指定本地用户具体信息,如完整的姓名、用户名和密码, + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Local-User-FullName-Debian10.jpg) + +在 “Continue” 上单击。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/UserName-LocalUser-Debian10-Installation.jpg) + +在 “Continue” 上单击,并在接下来的窗口中指定密码。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Password-Localuser-Debian10.jpg) + +### 步骤:7)为 Debian 10 选择硬盘分区方案 + +在这个步骤中,为 Debian 10 选择硬盘分区方案,就我而言,我有 40 GB 硬盘可用于操作系统安装。分区方案有两种类型: + + * 向导分区(安装器将自动创建需要的分区) + * 手动分区(正如名字所示,使用这种方式,我们可以手动创建分区方案) + +在这篇教程中,我们将在我 42 GB 硬盘上使用带有 LVM 的向导分区。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Choose-Guided-Partitioning-Scheme-Debain10-Installation.jpg) + +在 “Continue” 上单击来继续, + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Hard-Disk-Debian10-Installation.jpg) + +正如我们所视,我大约有 42 GB 硬盘空间,选择 “Continue”。 + +在接下来的屏幕中,你将被要求选择分区,如果是 Linux 新用户,那么选择第一个选项。假使你想要一个独立的 home 分区,那么选择第二种方案,否则选择第三种方案,它们将为 `/home`、`/var` 和 `/tmp` 创建独立的分区。 + +就我而言,我将通过选择第三种选项来为 `/home`、`/var` 和 `/tmp` 创建独立的分区。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Guided-Separate-Partitions-Debian10-Installation.jpg) + +在接下来的屏幕中,选择 “yes” 来将更改写到磁盘中,配置 LVM ,然后在 “Continue” 上单击。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Write-Changes-Disk-Debian10-Installation.jpg) + +在接下来的屏幕中,将显示分区表,验证分区大小、文件系统类型和挂载点。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Debian10-Partition-Table.jpg) + +在 “Continue” 上单击来继续, + +在接下来的屏幕中,选择 “yes” 来写更改到磁盘中, + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Choose-Yes-Write-Changes-Disk-Debian10-Installation.jpg) + +在 “Continue” 上单击来继续安装, + +### 步骤:7)Debian 10 安装开始 + +在这一步骤中,Debian 10 的安装已经开始,并正在进行中, + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Debian10-Installation-Progress.jpg) + +在安装期间,安装器将提示你扫描 CD/DVD 以配置软件包管理器,选择 “No” ,然后在 “Continue” 上单击。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Scan-DVD-Debian10-Installation.jpg) + +在接下来的屏幕中,如果你想配置基于网络的软件包管理器选择 “yes” ,但是为了使这个方式工作,要确保你的系统连接到了网络,否则选择 “No”。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Network-Mirror-Debian10-Package-Manager.jpg) + +在 “Continue” 上单击来配置基于你本地的软件包管理器,在接下来的几个屏幕中,你将被提示选择本地和 Debian 软件包存储库 URL ,然后你将获得下面的屏幕。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Apt-Config-Debian10-Installation.jpg) + +选择 “No” 来跳过软件包审查步骤,然后在 “Continue” 上单击。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Pkg-Survey-Debian10-Installation.jpg) + +在接下来的窗口中,你将被提示选择电脑桌面环境和其它软件包,就我而言,我选择 “Gnome Desktop” ,“SSH Server” 和 “Standard System utilities”。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Software-Selection-Debian10-Installation.jpg) + +在 “Continue” 上单击来继续安装, + +选择选项 “yes” 来安装 Grub 引导加载程序。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Install-Grub-Bootloader-Debian10-Installation.jpg) + +在 “Continue” 上单击来继续,然后在接下来的窗口中选择将安装引导加载程序的磁盘(`/dev/sda`)。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Install-grub-on-dev-sda-debian10.jpg) + +在 “Continue” 上单击来继续安装,一旦安装完成,安装器将提示我们来重启系统, + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Installation-Completed-Debain10.jpg) + +在 “Continue” 上单击来重启你的系统,不要忘记在 BIOS 设置中更改启动介质,以便系统从我们已经安装 Debian 10 操作系统的硬盘启动。 + +### 步骤:8)启动你新安装的 Debian 10 系统 + +在成功安装后,一旦我们重启系统,我们将获取下面的引导加载程序屏幕。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Bootloader-Screen-Debian10.jpg) + +选择第一个选项 “Debian GNU/Linux” 并敲击回车键。 + +一旦系统启动,使用我在安装期间创建的本地用户和它的密码。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Local-User-Debian10-Login.jpg) + +在成功登录后,将看到如下电脑桌面屏幕, + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Desktop-Screen-Debian10-Buster.jpg) + +这证实 Debian 10 已经成功安装,这就是本文的全部,探索这个令人激动的 Linux 发行版吧,玩得开心 😊 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/debian-10-buster-installation-guide/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 diff --git a/published/201907/20190708 Linux Games Get A Performance Boost for AMD GPUs Thanks to Valve-s New Compiler.md b/published/201907/20190708 Linux Games Get A Performance Boost for AMD GPUs Thanks to Valve-s New Compiler.md new file mode 100644 index 0000000000..c2d310c26c --- /dev/null +++ b/published/201907/20190708 Linux Games Get A Performance Boost for AMD GPUs Thanks to Valve-s New Compiler.md @@ -0,0 +1,75 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11082-1.html) +[#]: subject: (Linux Games Get A Performance Boost for AMD GPUs Thanks to Valve’s New Compiler) +[#]: via: (https://itsfoss.com/linux-games-performance-boost-amd-gpu/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +借助 Valve 的新编译器,Linux 游戏在 AMD GPU 中获得了性能提升 +====== + +Steam 寻求公众反馈以便为 AMD GPU 测试 ACO(一个新的 Mesa [着色器][1]编译器)已经有几天了。 + +目前,AMD 驱动程序使用 LLVM 作为着色器编译器。而 [Mesa][2] 则是一个开源的 [LLVM][3] 的替代品。因此,在这种情况下,Valve 希望支持 AMD 显卡以提高 Linux 游戏在各种 Linux 发行版上的性能。 + +![][4] + +为了提高游戏性能,编译时间至关重要,使用新的 ACO 编译器,它将时间缩短了近 50%。 Valve 在其 [Steam 社区][5]的帖子中解释了更多关于它的信息: + +> AMD OpenGL 和 Vulkan 驱动程序目前使用的着色器编译器是上游 LLVM 项目的一部分。该项目规模庞大,并且有许多不同的目标,游戏着色器的在线编译只是其中之一。这可能会导致不同的开发权衡,其中改进游戏特定功能比其他情况更难,特定于游戏的功能也经常被 LLVM 的开发人员因其他事情破坏。特别是,着色器编译速度就是这样一个例子:它在大多数其他场景中并不是一个关键因素,只能锦上添花。但是对于游戏来说,编译时间是至关重要的,而缓慢的着色器编译可能导致几乎无法播放的顿挫。 + +### Linux 游戏真的有性能提升吗? + +是的,没错。 + +这里的主要亮点是编译时间。如果着色器编译时间急剧减少,理论上应该会改善游戏的性能。 + +而且,根据[最初的基准报告][6],我们确实看到了一些重大改进。 + +![][7] + +当然,游戏中的 FPS 改进并不是很大。但是,它在早期阶段仍然是一个很好的进步。 + +如果你对编译时间的改进感到好奇,下面是结果: + +![][8] + +是的,即使大幅的编译时间减少也不会大幅影响游戏中的 FPS。但是,它仍然是一件大事,因为目前,这是一项正在进行中的工作。所以,我们可以有更多期待。 + +但是,还能做些什么呢? + +好吧,ACO 还没完成。下面是为什么(在 Valve 中提到): + +> 现在,ACO 只处理像素和计算着色器阶段。当其余的阶段实现时,我们预计编译时间将进一步减少。 + +#### 总结 + +尽管我没有配备 AMD GPU,但我很有兴趣看到对 Linux 游戏场景的改进。 + +此外,随着事情进展,我们将期待更多的基准和报告。 + +你怎么看待?请在下面的评论中告诉我们你的想法。如果你有基本报告要分享,请告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/linux-games-performance-boost-amd-gpu/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Shader +[2]: https://en.wikipedia.org/wiki/Mesa_(computer_graphics) +[3]: https://en.wikipedia.org/wiki/LLVM +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/07/Improved-Linux-Gaming.png?resize=800%2C450&ssl=1 +[5]: https://steamcommunity.com/games/221410/announcements/detail/1602634609636894200 +[6]: https://gist.github.com/pendingchaos/aba1e4c238cf039d17089f29a8c6aa63 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/fps-improvement-amd.png?fit=800%2C412&ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/07/compile-time-amd-gpu-linux.png?ssl=1 diff --git a/published/201907/20190709 From BASIC to Ruby- Life lessons from first programming languages on Command Line Heroes.md b/published/201907/20190709 From BASIC to Ruby- Life lessons from first programming languages on Command Line Heroes.md new file mode 100644 index 0000000000..2d80df3e29 --- /dev/null +++ b/published/201907/20190709 From BASIC to Ruby- Life lessons from first programming languages on Command Line Heroes.md @@ -0,0 +1,57 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11097-1.html) +[#]: subject: (From BASIC to Ruby: Life lessons from first programming languages on Command Line Heroes) +[#]: via: (https://opensource.com/19/7/command-line-heroes-ruby-basic) +[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberg) + +从 BASIC 到 Ruby:入门编程语言的体悟 +====== + +> 为什么 BASIC 是一种备受喜爱的入门语言?下一代该如何学习编程? + +![Listen to the Command Line Heroes Podcast][1] + +《[Command Line Heroes][2]》 第三季的第二集今天抵达了,它对我的入门编程的怀旧让我回到了过去。 + +(LCTT 译注:《Command Line Heroes》 是红帽公司制作的播客,讲述了开发人员、程序员、黑客、极客和开源反叛者如何彻底改变技术前景的真实史诗。其第一季制作于 2017 年,邀请到了谷歌、NASA 等重量级企业的技术专家担当嘉宾,讲述操作系统战争风云、美国航天局如何开源等等,涉及开源、操作系统、容器、DevOps、云计算等话题。) + +### 语言会影响可访问性 + +这一集告诉我,BASIC 是计算机的理解力民主化的一次巨大飞跃。我很难想象,在一个不太遥远的、计算机尚且是稀罕之物的时代,是 BASIC 改变了世界。正如 [Saron Yitbarek][3] 提到的那样,“在早些年编程,你几乎得有个博士学位才行。”BASIC 是一个巨大的飞跃,它专注于可用性(适合初学者的命令)和资源共享(单个计算机的分时操作)。它使得编程不在局限于当时的“计算机玩家”(我喜欢这集中的这句话),并帮助了新一代人参与了进来。进入编程领域的壁垒得以下降。 + +### 入门编程语言 + +这一集的核心话题是围绕学习入门语言展开的。关于学习什么编程语言以及如何学习,有很多建议。关于这个问题[在这里][4]已经写了很多。我喜欢听到 Saron 以 Ruby 作为她的介绍的故事,以及它以一种几乎意想不到的方式变得有趣。我有一些类似的经历,因为我在一些项目中用到了 Ruby。它的灵活性让我感到开心。当我(对编程)感到紧张时,正是这种快乐让我重新回到它的身边,并且它有一些能够使语言如此充满情感的强大功能。 + +我第一次体验编程是用 HTML 和 CSS,但我第一个重型编程语言是 Java。我永远不会忘记在课堂的第一天被告知要记住 `public static void main`,但没有告知我关于它意味着什么的任何信息。我们花了很多时间在面向对象编程的上下文环境中探讨它是什么,但它从未像我在 Ruby 中使用 `.each` 迭代列表,或者像在 Python 中用 `import numpy` 做一些数学魔术那样感到兴奋。然后我听说孩子们正在学习如何使用 Python 编写 [Minecraft][5] 或使用像 [Scratch][6] 这样的可视化编程语言,我因此而悟,BASIC 的遗产正在以新的方式存在。 + +我从这一集中获取到的内容: + +* 请记住,没有人出生就是程序员。每个人都没有这样的背景。你并不孤单。 +* 学习一门语言。任何一种都行。如果你有选择的可能,那么请选择能带给你最大乐趣的那个。 +* 不要忘记所有语言都可以构建一些东西。请为人类创造有意义的事物。 + +《Command Line Heroes》整个第三季将涉及编程语言。[请在此处订阅来学习你想要了解的有关编程语言的起源][2],我很乐意在下面的评论中听到你的想法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/19/7/command-line-heroes-ruby-basic + +作者:[Matthew Broberg][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mbbroberg +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/ep1_blog-header-520x292_lgr.png?itok=I8IS1hkt (Listen to the Command Line Heroes Podcast) +[2]: https://www.redhat.com/en/command-line-heroes +[3]: https://twitter.com/saronyitbarek +[4]: https://linux.cn/article-8379-1.html +[5]: https://opensource.com/life/15/5/getting-started-minecraft-pi +[6]: https://opensource.com/education/11/6/how-teach-next-generation-open-source-scratch diff --git a/published/201907/20190709 Pipx - Install And Run Python Applications In Isolated Environments.md b/published/201907/20190709 Pipx - Install And Run Python Applications In Isolated Environments.md new file mode 100644 index 0000000000..1fb5155fc7 --- /dev/null +++ b/published/201907/20190709 Pipx - Install And Run Python Applications In Isolated Environments.md @@ -0,0 +1,180 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11104-1.html) +[#]: subject: (Pipx – Install And Run Python Applications In Isolated Environments) +[#]: via: (https://www.ostechnix.com/pipx-install-and-run-python-applications-in-isolated-environments/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +Pipx:在隔离环境中安装和运行 Python 应用 +====== + +![][1] + +我们始终建议在虚拟环境中安装 Python 应用以避免彼此冲突。Pip 包管理器可以帮助我们在隔离的环境中安装 Python 应用,我们使用两个工具,即 `venv` 和 `virtualenv`。还有一个 Python.org 推荐的名为 [Pipenv][2] 的 Python 包管理器也可以用来安装 Python 应用。与 Pip 不同,Pipenv 默认会自动创建虚拟环境。这意味着你不再需要为项目手动创建虚拟环境。今天,我偶然发现了一个名为 “Pipx” 的类似工具,它是一个自由开源程序,允许你在隔离的虚拟环境中安装和运行 Python 应用。 + +使用 Pipx,我们可以轻松安装 PyPI 中托管的数千个 Python 应用,而不会有太多麻烦。好的是,你可以使用常规用户权限执行所有操作。你不需要成为 “root” 用户或不需要具有 “sudo” 权限。值得一提的是,Pipx 可以从临时环境运行程序,而无需安装它。当你经常测试同一程序的多个版本时,这将非常方便。随 Pipx 一起安装的软件包可以随时列出、升级或卸载。Pipx 是一个跨平台的程序,因此它可以在 Linux、Mac OS 和 Windows 上运行。 + +### 安装 Pipx + +Python 3.6+ 、Pip 和 `venv` 模块是安装 `pipx` 所必需的。确保按照以下指南中的说明安装它们。 + +* [如何使用 Pip 管理 Python 包][3] + +此处,需要 `venv` 来创建虚拟环境。 + +接下来,运行以下命令安装 Pipx。 + +``` +$ python3 -m pip install --user pipx +$ python3 -m userpath append ~/.local/bin +``` + +`pipx` 二进制文件的默认位置是 `~/.local/bin`。你可以使用 `PIPX_BIN_DIR` 环境变量覆盖它。如果要覆盖 `PIPX_BIN_DIR`,只需运行 `userpath append $PIPX_BIN_DIR`,确保它在你的路径中。 + +Pipx 的默认虚拟环境位置是 `~/.local/pipx`。这可以用环境变量 `PIPX_HOME` 覆盖。 + +让我们继续看看如何使用 Pipx 安装 Python 应用。 + +### 使用 Pipx 在隔离环境中安装和运行 Python 应用 + +以下是 Pipx 入门的几个例子 + +#### 安装 Python 包 + +要全局安装 Python 应用,例如 cowsay,请运行: + +``` +$ pipx install cowsay +``` + +此命令将自动创建虚拟环境,在其中安装包并包的可执行文件放在 `$PATH` 中。 + +示例输出: + +``` +installed package cowsay 2.0.3, Python 3.6.8 +These binaries are now globally available +- cowsay +done! ✨ 🌟 ✨ +``` + +![1][4] + +*使用 Pipx 安装 Python 应用* + +让我们测试新安装的 cowsay 程序: + +![1][5] + +在这里,我从官方网站上摘取了这些例子。你可以安装/测试任何其他的 Python 包。 + +#### 列出 Python 包 + +要使用 Pipx 列出所有已安装的应用,请运行: + +``` +$ pipx list +``` + +示例输出: + +``` +venvs are in /home/sk/.local/pipx/venvs +binaries are exposed on your $PATH at /home/sk/.local/bin +package cowsay 2.0.3, Python 3.6.8 +- cowsay +``` + +如果你尚未安装任何软件包,你将看到以下输出: + +``` +nothing has been installed with pipx 😴 +``` + +#### 升级包 + +要升级包,只需执行以下操作: + +``` +$ pipx upgrade cowsay +``` + +要一次性升级所有已安装的软件包,请使用: + +``` +$ pipx upgrade-all +``` + +#### 从临时虚拟环境运行应用 + +有时,你可能希望运行特定的 Python 程序,但并不实际安装它。 + +``` +$ pipx run pycowsay moooo +``` + +![1][6] + +*在临时隔离虚拟环境中运行 Python 应用* + +此命令实际上并不安装指定程序,而是从临时虚拟环境运行它。你可以使用此命令快速测试 Python 应用。 + +你甚至可以直接运行 .py 文件。 + +``` +$ pipx run https://gist.githubusercontent.com/cs01/fa721a17a326e551ede048c5088f9e0f/raw/6bdfbb6e9c1132b1c38fdd2f195d4a24c540c324/pipx-demo.py +pipx is working! +``` + +#### 卸载软件包 + +可以使用以下命令卸载软件包: + +``` +$ pipx uninstall cowsay +``` + +要删除所有已安装的包: + +``` +$ pipx uninstall-all +``` + +#### 获得帮助 + +要查看帮助部分,请运行: + +``` +$ pipx --help +``` + +就是这些了。如果你一直在寻找安全,方便和可靠的程序来安装和运行 Python 应用,Pipx 可能是一个不错的选择。 + +资源: + +* [Pipx 的 GitHub 仓库][7] + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/pipx-install-and-run-python-applications-in-isolated-environments/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/07/pipx-720x340.png +[2]: https://www.ostechnix.com/pipenv-officially-recommended-python-packaging-tool/ +[3]: https://www.ostechnix.com/manage-python-packages-using-pip/ +[4]: https://www.ostechnix.com/wp-content/uploads/2019/07/Install-Python-Applications-Using-Pipx.png +[5]: https://www.ostechnix.com/wp-content/uploads/2019/07/Test-Python-application.png +[6]: https://www.ostechnix.com/wp-content/uploads/2019/07/Run-Python-Applications-In-Isolated-Environments.png +[7]: https://github.com/pipxproject/pipx diff --git a/published/201907/20190709 Sysadmin vs SRE- What-s the difference.md b/published/201907/20190709 Sysadmin vs SRE- What-s the difference.md new file mode 100644 index 0000000000..8bbd02d67a --- /dev/null +++ b/published/201907/20190709 Sysadmin vs SRE- What-s the difference.md @@ -0,0 +1,62 @@ +[#]: collector: (lujun9972) +[#]: translator: (vizv) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11113-1.html) +[#]: subject: (Sysadmin vs SRE: What's the difference?) +[#]: via: (https://opensource.com/article/19/7/sysadmins-vs-sres) +[#]: author: (Vince Power https://opensource.com/users/vincepower/users/craig5/users/dawnparzych/users/penglish) + +系统管理员与网站可靠性工程师(SRE)对比:区别在那儿? +====== + +> 系统管理员和网站可靠性工程师(SRE,下同)对于任何组织来讲都很重要。本篇将介绍下两者的不同之处。 + +![](https://img.linux.net.cn/data/attachment/album/201907/17/214505qgk19kjuvzb2m1m4.jpg) + +在 IT 行业,成为多面手或是专家的争议一直存在。99% 的传统系统管理员都被归到了多面手这类。[网站可靠性工程师][2]site reliability engineer(SRE)的角色则更加专精,并且在如 Google 般有着一定规模的头部公司中对其的需求不断增加。但总的来说这两者对于跑着应用的基础设施有着同样的目标:为应用的消费者提供良好的体验。然而两者的出发点却截然不同。 + +### 系统管理员:中立善良的化身 + +系统管理员一般都是从基础的桌面或网络支持成长过来的,并一路习得大多数系统管理员都会掌握的广泛的技能。此时这些系统管理员会对他们所负责的系统和应用了如指掌。他们会知道一号服务器上的应用每隔一个星期二就需要重启一次,或是九号服务器周三会静默的崩溃。他们会对服务器的监视作出微调以忽略无关紧要的信息,尽管那个被标记为致命fatal的错误信息每个月第三个周日都会显示。 + +总的来讲,系统管理员了解如何照料那些跑着你核心业务的服务器。这些系统管理员已经成长到开始使用自动化工具去处理所有归他们管的服务器上的例行任务。他们虽然喜欢使用模板、黄金镜像golden images、以及标准,但同时也有着足够的灵活度去修改一个服务器上的参数以解决错误,并注释为什么那个服务器的配置与众不同。 + +尽管系统管理员很伟大,但他们也有着一些怪癖。其中一项就是没有他们神圣的授权你永远也获取不了系统的 root 访问权限,另一项则是任何不是出于他们的主意的变更都要在文档中被记录为应用提供方的要求,并仍然需要再次核对。 + +他们所管理的服务器是他们的地盘,没有人可以随意干涉。 + +### SRE:灭霸将为之自豪 + +与成为系统管理员的道路相反,从开发背景和从系统管理员背景成长为 SRE 的可能性相近。SRE 的职位出现的时长与应用开发环境的生命周期相近。 + +随着一个组织的发展而引入的类似于[持续集成][4]和[持续发布][5] (CI/CD) 的 [DevOps][3] 概念,通常会出现技能空缺,以让这些不可变immutable的应用部署到多个环境并随着业务需求进行扩展。这将是 SRE 的舞台。的确,一个系统管理员可以学习额外的工具,但大体上成为一个全职的职位更容易跟的上发展。一个专精的专家更有意义。 + +SRE 使用如[代码即基础设施][6]infrastructure-as-code的概念去制作模板,然后调用它们来部署用以运行应用的环境,并以使用一键完整重现每个应用和它们的环境作为目标。因此会出现这样的情况:测试环境中一号服务器里的一号应用的二进制文件与生产环境中十五号服务器的完全一致,仅环境相关的变量如密码和数据库链接字串有所不同。 + +SRE 也会在配置发生改变时完全销毁一个环境并重新构建它。对于任何系统他们都不带一点感情。每个系统只是个被打了标记和安排了生命周期的数字而已,甚至连例行的对服务器打补丁也要重新部署整个应用栈application stack + +### 总结 + +对于一些情况,尤其是运维一些大型的基于 DevOps 的环境时,一个 SRE 所能提供的用于处理各种规模的业务的专业技能当然更具优势。但每次他们在运气不好走入死胡同时都会去寻求他的系统管理员友人或是 [来自地狱的混蛋运维(BOFH)][7] ,得到他那身经百战的故障排除技能,和那些用于给组织提供价值的丰富经验的帮助。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/sysadmins-vs-sres + +作者:[Vince Power][a] +选题:[lujun9972][b] +译者:[vizv](https://github.com/vizv) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/vincepower/users/craig5/users/dawnparzych/users/penglish +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux11x_cc.png?itok=XMDOouJR (People work on a computer server with devices) +[2]: https://en.wikipedia.org/wiki/Site_Reliability_Engineering +[3]: https://opensource.com/resources/devops +[4]: https://en.wikipedia.org/wiki/Continuous_integration +[5]: https://en.wikipedia.org/wiki/Continuous_delivery +[6]: https://en.wikipedia.org/wiki/Infrastructure_as_code +[7]: http://www.bofharchive.com/BOFH.html diff --git a/published/201907/20190710 32-bit life support- Cross-compiling with GCC.md b/published/201907/20190710 32-bit life support- Cross-compiling with GCC.md new file mode 100644 index 0000000000..df71c9b3cd --- /dev/null +++ b/published/201907/20190710 32-bit life support- Cross-compiling with GCC.md @@ -0,0 +1,178 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11120-1.html) +[#]: subject: (32-bit life support: Cross-compiling with GCC) +[#]: via: (https://opensource.com/article/19/7/cross-compiling-gcc) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +32 位支持:使用 GCC 交叉编译 +====== + +> 使用 GCC 在单一的构建机器上来为不同的 CPU 架构交叉编译二进制文件。 + +![](https://img.linux.net.cn/data/attachment/album/201907/19/054242nwhludz9tm2lwd8t.jpg) + +如果你是一个开发者,要创建二进制软件包,像一个 RPM、DEB、Flatpak 或 Snap 软件包,你不得不为各种不同的目标平台编译代码。典型的编译目标包括 32 位和 64 位的 x86 和 ARM。你可以在不同的物理或虚拟机器上完成你的构建,但这需要你为何几个系统。作为代替,你可以使用 GNU 编译器集合 ([GCC][2]) 来交叉编译,在单一的构建机器上为几个不同的 CPU 架构产生二进制文件。 + +假设你有一个想要交叉编译的简单的掷骰子游戏。在大多数系统上,以 C 语言来编写这个相对简单,出于给添加现实的复杂性的目的,我以 C++ 语言写这个示例,所以程序依赖于一些不在 C 语言中东西 (具体来说就是 `iostream`)。 + +``` +#include +#include + +using namespace std; + +void lose (int c); +void win (int c); +void draw (); + +int main() { + int i; + do { + cout << "Pick a number between 1 and 20: \n"; + cin >> i; + int c = rand ( ) % 21; + if (i > 20) lose (c); + else if (i < c ) lose (c); + else if (i > c ) win (c); + else draw (); + } + while (1==1); + } + +void lose (int c ) + { + cout << "You lose! Computer rolled " << c << "\n"; + } + +void win (int c ) + { + cout << "You win!! Computer rolled " << c << "\n"; + } + +void draw ( ) + { + cout << "What are the chances. You tied. Try again, I dare you! \n"; + } +``` + +在你的系统上使用 `g++` 命令编译它: + +``` +$ g++ dice.cpp -o dice +``` + +然后,运行它来确认其工作: + +``` +$ ./dice +Pick a number between 1 and 20: +[...] +``` + +你可以使用 `file` 命令来查看你刚刚生产的二进制文件的类型: + +``` +$ file ./dice +dice: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically +linked (uses shared libs), for GNU/Linux 5.1.15, not stripped +``` + +同样重要,使用 `ldd` 命令来查看它链接哪些库: + +``` +$ ldd dice +linux-vdso.so.1 => (0x00007ffe0d1dc000) +libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 +(0x00007fce8410e000) +libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 +(0x00007fce83d4f000) +libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 +(0x00007fce83a52000) +/lib64/ld-linux-x86-64.so.2 (0x00007fce84449000) +libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 +(0x00007fce8383c000) +``` + +从这些测试中,你已经确认了两件事:你刚刚运行的二进制文件是 64 位的,并且它链接的是 64 位库。 + +这意味着,为实现 32 位交叉编译,你必需告诉 `g++` 来: + + 1. 产生一个 32 位二进制文件 + 2. 链接 32 位库,而不是 64 位库 + +### 设置你的开发环境 + +为编译成 32 位二进制,你需要在你的系统上安装 32 位的库和头文件。如果你运行一个纯 64 位系统,那么,你没有 32 位的库或头文件,并且需要安装一个基础集合。最起码,你需要 C 和 C++ 库(`glibc` 和 `libstdc++`)以及 GCC 库(`libgcc`)的 32 位版本。这些软件包的名称可能在每个发行版中不同。在 Slackware 系统上,一个纯 64 位的带有 32 位兼容的发行版,可以从 [Alien BOB][3] 提供的 `multilib` 软件包中获得。在 Fedora、CentOS 和 RHEL 系统上: + +``` +$ yum install libstdc++-*.i686 +$ yum install glibc-*.i686 +$ yum install libgcc.i686 +``` + +不管你正在使用什么系统,你同样必须安装一些你工程使用的 32 位库。例如,如果你在你的工程中包含 `yaml-cpp`,那么,在编译工程前,你必需安装 `yaml-cpp` 的 32 位版本,或者,在很多系统上,安装 `yaml-cpp` 的开发软件包(例如,在 Fedora 系统上的 `yaml-cpp-devel`)。 + +一旦这些处理好了,编译是相当简单的: + +``` +$ g++ -m32 dice.cpp -o dice32 -L /usr/lib -march=i686 +``` + +`-m32` 标志告诉 GCC 以 32 位模式编译。`-march=i686` 选项进一步定义来使用哪种最优化类型(参考 `info gcc` 了解选项列表)。`-L` 标志设置你希望 GCC 来链接的库的路径。对于 32 位来说通常是 `/usr/lib`,不过,这依赖于你的系统是如何设置的,它可以是 `/usr/lib32`,甚至 `/opt/usr/lib`,或者任何你知道存放你的 32 位库的地方。 + +在代码编译后,查看你的构建的证据: + +``` +$ file ./dice32 +dice: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), +dynamically linked (uses shared libs) [...] +``` + +接着,当然, `ldd ./dice32` 也会指向你的 32 位库。 + +### 不同的架构 + +在 64 位相同的处理器家族上允许 GCC 做出很多关于如何编译代码的假设来编译 32 位软件。如果你需要为完全不同的处理器编译,你必需安装适当的交叉构建实用程序。安装哪种实用程序取决于你正在编译的东西。这个过程比为相同的 CPU 家族编译更复杂一点。 + +当你为相同处理器家族交叉编译时,你可以期待找到与 32 位库集的相同的 64 位库集,因为你的 Linux 发行版是同时维护这二者的。当为一个完全不同的架构编译时,你可能不得不穷追你的代码所需要的库。你需要的版本可能不在你的发行版的存储库中,因为你的发行版可能不为你的目标系统提供软件包,或者它不在容易到达的位置提供所有的软件包。如果你正在编译的代码是你写的,那么你可能非常清楚它的依赖关系是什么,并清楚在哪里找到它们。如果代码是你下载的,并需要编译,那么你可能不熟悉它的要求。在这种情况下,研究正确编译代码需要什么(它们通常被列在 `README` 或 `INSTALL` 文件中,当然也出现在源文件代码自身之中),然后收集需要的组件。 + +例如,如果你需要为 ARM 编译 C 代码,你必须首先在 Fedora 或 RHEL 上安装 `gcc-arm-linux-gnu`(32 位)或 `gcc-aarch64-linux-gnu`(64 位);或者,在 Ubuntu 上安装 `arm-linux-gnueabi-gcc` 和 `binutils-arm-linux-gnueabi`。这提供你需要用来构建(至少)一个简单的 C 程序的命令和库。此外,你需要你的代码使用的任何库。你可以在惯常的位置(大多数系统上在 `/usr/include`)放置头文件,或者,你可以放置它们在一个你选择的目录,并使用 `-I` 选项将 GCC 指向它。 + +当编译时,不使用标准的 `gcc` 或 `g++` 命令。作为代替,使用你安装的 GCC 实用程序。例如: + +``` +$ arm-linux-gnu-g++ dice.cpp \ + -I/home/seth/src/crossbuild/arm/cpp \ + -o armdice.bin +``` + +验证你构建的内容: + +``` +$ file armdice.bin +armdice.bin: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV) [...] +``` + +### 库和可交付结果 + +这是一个如何使用交叉编译的简单的示例。在真实的生活中,你的源文件代码可能产生的不止于一个二进制文件。虽然你可以手动管理,在这里手动管理可能不是好的正当理由。在我接下来的文章中,我将说明 GNU 自动工具,GNU 自动工具做了使你的代码可移植的大部分工作。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/cross-compiling-gcc + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_osyearbook2016_sysadmin_cc.png?itok=Y1AHCKI4 (Wratchet set tools) +[2]: https://gcc.gnu.org/ +[3]: http://www.slackware.com/~alien/multilib/ diff --git a/published/201907/20190710 How To Find Virtualbox Version From Commandline In Linux.md b/published/201907/20190710 How To Find Virtualbox Version From Commandline In Linux.md new file mode 100644 index 0000000000..02c775ec21 --- /dev/null +++ b/published/201907/20190710 How To Find Virtualbox Version From Commandline In Linux.md @@ -0,0 +1,111 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11099-1.html) +[#]: subject: (How To Find Virtualbox Version From Commandline In Linux) +[#]: via: (https://www.ostechnix.com/how-to-find-virtualbox-version-from-commandline-in-linux/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +在 Linux 中如何从命令行查找 VirtualBox 版本 +====== + +![FInd Virtualbox version from commandline In Linux][1] + +我使用 Oracle VirtualBox 和 [KVM][2] 虚拟化程序[测试不同的 Linux 操作系统][3]。虽然我偶尔使用 KVM,但 Virtualbox 始终是我的首选。不是因为我不喜欢 KVM,而是因为我只是习惯了 VirtualBox。当在我的 Ubuntu 无头服务器上使用 [Virtualbox][4] 时,我需要知道 VirtualBox 的版本。如果它有 GUI,我可以进入 Virtualbox -> About -> Help 轻松找到它。但我的是没有 GUI 的 Ubuntu 服务器。如果你想知道如何在 Linux 中从命令行查找 VirtualBox 版本,可以采用以下几种方法。 + + +### 在 Linux 中从命令行查找 VirtualBox 版本 + +要查找已安装的 VirtualBox 的版本,请打开终端并运行以下命令: + +``` +$ vboxmanage --version +``` + +示例输出: + +``` +5.2.18_Ubuntur123745 +``` + +![][5] + +*在 Linux 中从命令行查找 Virtualbox 版本* + +正如你在上面的输出中看到的,安装的 VirtualBox 的版本是 5.2。 + +查找 VirtualBox 版本的另一种方法是: + +``` +$ vbox-img --version +``` + +示例输出: + +``` +5.2.18_Ubuntur123745 +``` + +或者,你可以使用 `head` 和 `awk` 命令来查找 VirtualBox 版本。 + +``` +$ virtualbox --help | head -n 1 | awk '{print $NF}' +``` + +示例输出: + +``` +5.2.18_Ubuntu +``` + +或者,使用 `echo` 命令结合 `head` 和 `awk` 命令: + +``` +$ echo $(virtualbox --help | head -n 1 | awk '{print $NF}') +``` + +示例输出: + +``` +5.2.18_Ubuntu +``` + +以上命令适用于任何 Linux 发行版。如果你使用的是 Ubuntu,你可以使用 `dpkg` 命令查看 VirtualBox 版本。 + +``` +$ dpkg -l | grep virtualbox | awk '{print $3}' +``` + +示例输出: + +``` +5.2.30-130521~Ubuntu~bionic +5.2.18-dfsg-2~ubuntu18.04.5 +``` + +就是这些了。这些是从 Linux 中的终端查找 Oracle Virtualbox 版本的几种方法。希望这篇文章很有用。 + +参考来自: + + * [AskUbuntu][6] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-find-virtualbox-version-from-commandline-in-linux/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/07/Find-Virtualbox-Version-1-720x340.png +[2]: https://www.ostechnix.com/setup-headless-virtualization-server-using-kvm-ubuntu/ +[3]: https://www.ostechnix.com/test-100-linux-and-unix-operating-systems-online-for-free/ +[4]: https://www.ostechnix.com/install-oracle-virtualbox-ubuntu-16-04-headless-server/ +[5]: https://www.ostechnix.com/wp-content/uploads/2019/07/Find-Virtualbox-Version.png +[6]: https://askubuntu.com/questions/420363/how-do-i-check-virtualbox-version-from-cli diff --git a/published/201907/20190710 Test 200- Linux And Unix Operating Systems Online For Free.md b/published/201907/20190710 Test 200- Linux And Unix Operating Systems Online For Free.md new file mode 100644 index 0000000000..cda9f2c351 --- /dev/null +++ b/published/201907/20190710 Test 200- Linux And Unix Operating Systems Online For Free.md @@ -0,0 +1,256 @@ +[#]: collector: (lujun9972) +[#]: translator: (0x996) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11118-1.html) +[#]: subject: (Test 200+ Linux And Unix Operating Systems Online For Free) +[#]: via: (https://www.ostechnix.com/test-100-linux-and-unix-operating-systems-online-for-free/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +在线试用 200 多种 Linux 和 Unix 操作系统 +====== + +![DistroTest——在线试用200多种Linux和Unix操作系统][1] + +不久前我们介绍过[OSBoxes][2],该网站提供了一系列免费且开箱即用的 Linux 和 Unix 虚拟机。你可以在你的 Linux 系统中下载这些虚拟机并用 VirtualBox 或 VMWare workstation 试用。今天,我偶然发现一个名叫 “DistroTest” 的类似服务。与 OSBoxes 不同之处在于 DistroTest 让你免费试用现场版 Linux 和 Unix 操作系统。你可以在线试用 200 多种 Linux 和 Unix 操作系统而无需在本地安装它们。只要打开该网站,选择你需要的 Linux/Unix 发行版,然后开始试用! + +两个名为 Klemann Andy 和 Forster Tobias 的好心人用 Qemu 在 Debian 上运行了这项网络服务。这里列出的公开发行版在使用上没有任何限制。你可以象使用本地系统一样使用系统的所有功能。你可以安装和卸载软件。你可以测试安装的程序,甚至删除或格式化硬盘,删除系统文件。简而言之,DistroTest让喜欢尝试不同发行版的的人自行决定: + + * 最适合他们的发行版 + * 想要哪种图形界面 + * 他们可以选择哪些配置 + +本文撰写之时,DistroTest 提供了 227 种操作系统的 711 个版本。我已经使用 Linux 很多年,但我从未听说过这里列出的一些发行版。说实话我甚至不知道 Linux 操作系统有如此之多的版本。 + +DistroTest 网站提供的 Linux 发行版的列表如下。(LCTT 译注:其中也包括部分非 Linux 的操作系统如 FreeBSD 和 FreeDOS,或是分区工具如 Gparted) + + * 4mLinux + * AbsoluteLinux + * AlpineLinux + * Antergos + * antiX Linux + * Aptosid + * ArchBang + * ArchLabs + * ArchLinux + * Archman + * ArchStrike + * ArtixLinux + * AryaLinux + * AvLinux + * BackBoxLinux + * BigLinux + * Bio-Linux + * BlackArch + * BlackLab + * BlackPantherOS + * blag + * BlankOn + * Bluestar + * Bodhi + * BunsenLabs + * Caine + * Calculate Linux Desktop + * CentOS 7 + * Chakra + * ChaletOS + * ClearOS + * Clonezilla + * ConnochaetOS + * Cucumber + * Damn Small Linux + * Debian + * Devil-Linux + * Devuan + * DragonFly BSD + * Dragora + * Dyne:bolic + * Edubuntu + * elementaryOS + * Elive Linux + * Emmabuntüs + * Emmabuntüs + * Endless OS + * EnsoOS + * Exe GNU/Linux + * ExTiX + * Fatdog64 + * Fedora + * FerenOS + * FreeBSD + * FreeDOS + * Frugalware + * Frugalware + * G4L + * GeckoLinux + * Gentoo + * GNewSense + * GoboLinux + * Gparted + * GreenieLinux + * GRML + * GuixSD + * Haiku + * Heads + * Kali Linux + * Kanotix + * KaOS + * Knoppix + * Kodachi + * KolibriOS + * Korora + * Kwort + * Linux Lite + * Linux Mint + * LiveRaizo + * LMDE + * LXLE OS + * Macpup + * Mageia + * MakuluLinux + * Manjaro + * MauiLinux + * MenuetOS + * MiniNo + * Modicia + * Musix + * MX Linux + * Nas4Free + * Neptune + * NetBSD + * Netrunner + * NixOs + * NuTyX + * OpenIndiana + * OpenMandriva + * openSUSE + * OracleLinux + * OSGeo live + * OviOS + * Parabola + * Pardus + * Parrot + * Parsix + * PCLinuxOS + * PeachOSI + * Peppermint + * Pinguy + * PinguyOS + * plopLinux + * PointLinux + * Pop!_OS + * PORTEUS + * Puppy Linux + * PureOS + * Q4OS + * QubesOS + * Quirky + * ReactOS + * Redcore + * Rescatux + * RevengeOS + * RoboLinux + * Rockstor + * ROSA + * Runtu + * Sabayon + * SalentOS + * Salix + * ScientificLinux + * Siduction + * Slax + * SliTaz + * Solus + * SolydK + * SparkyLinux + * Springdale + * Stresslinux + * SubgraphOS + * SwagArch (18.03) + * Tails + * Tanglu + * Tiny Core + * Trisquel + * TrueOS + * TurnKey Linux + * Ubuntu及其官方衍生版本 + * Uruk + * VectorLinux + * VineLinux + * VoidLinux + * Voyager + * VyOS + * WattOs + * Zentyal + * Zenwalk + * Zevenet + * Zorin OS + +### 如何使用? + +要试用任何操作系统,点击下面的链接: https://distrotest.net/ + +在这个网站,你会看到可用的操作系统列表。单击你想了解的发行版名称即可。 + +![1][4] + +用 DistroTest 试用 200 多种Linux和Unix操作系统 + +本文中我会试用 Arch Linux。 + +单击发行版链接后,在跳转到的页面单击 “System start” 按钮即可启动所选操作系统。 + +![1][5] + +此现场版操作系统会在新浏览器窗口中启动。你可以通过内建的 noVNC viewer 访问它。请在浏览器中启用/允许 DistroTest 网站的弹出窗口,否则无法看到弹出的 noVNC 窗口。 + +按回车启动现场版系统。 + +![1][6] + +这就是 Arch Linux 现场版系统: + +![1][7] + +你可以免费使用这个系统 1 小时。你可以试用该现场版操作系统、安装应用、卸载应用、删除或修改系统文件、测试配置或脚本。每次关机后,一切都会恢复成默认配置。 + +一旦试用结束,回到 DistroTest 页面并停止你试用的系统。如果你不想启用 DistroTest 页面的弹出窗口,用你本地系统安装的任意 VNC 客户端也可以。VNC 登录信息可在同一页面找到。 + +![1][8] + +DistroTest 服务对两类用户比较实用:想在线试用 Linux/Unix 系统,或是没有喜欢的操作系统现场版 ISO 镜像文件的人。我在 4G 网络上测试的结果一切正常。 + +### 实际上,我没法在这个虚拟机里安装新软件 + +试用期间我注意到的一个问题是这个虚拟机没有联网。除了本地环回接口之外没有其他网络接口。没有联网也没有本地镜像源的情况下我没法下载和安装新软件。我不知道为何网站声称可以安装软件。也许在这点上我遗漏了什么。我在 DistroTest 上能做的只是看看现成的系统,试用现场版而不能安装任何软件。 + +推荐阅读: + + * [免费在线学习和练习 Linux命令!][9] + * [在浏览器中运行 Linux 和其他操作系统][10] + +暂时就这样了。我不知道 DistroTest 团队如何设法托管了这么多操作系统。我肯定这会花不少时间。这的确是件值得称赞的工作。我非常感激项目成员的无私行为。荣誉归于你们。加油! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/test-100-linux-and-unix-operating-systems-online-for-free/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[0x996](https://github.com/0x996) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2018/07/test-Linux-and-Unix-online-686x340.jpg +[2]: https://www.ostechnix.com/osboxes-free-unixlinux-virtual-machines-for-vmware-and-virtualbox/ +[3]: https://distrotest.net/ +[4]: https://www.ostechnix.com/wp-content/uploads/2018/07/Distrotest-5.png +[5]: https://www.ostechnix.com/wp-content/uploads/2018/07/Distrotest-1.png +[6]: https://www.ostechnix.com/wp-content/uploads/2018/07/Distrotest-2.png +[7]: https://www.ostechnix.com/wp-content/uploads/2018/07/Distrotest-3.png +[8]: https://www.ostechnix.com/wp-content/uploads/2018/07/Distrotest-4-1.png +[9]: https://www.ostechnix.com/learn-and-practice-linux-commands-online-for-free/ +[10]: https://www.ostechnix.com/run-linux-operating-systems-browser/ diff --git a/published/201907/20190711 How to install Elasticsearch on MacOS.md b/published/201907/20190711 How to install Elasticsearch on MacOS.md new file mode 100644 index 0000000000..b213d2bcd8 --- /dev/null +++ b/published/201907/20190711 How to install Elasticsearch on MacOS.md @@ -0,0 +1,144 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11125-1.html) +[#]: subject: (How to install Elasticsearch on MacOS) +[#]: via: (https://opensource.com/article/19/7/installing-elasticsearch-macos) +[#]: author: (Lauren Maffeo https://opensource.com/users/lmaffeo/users/don-watkins) + +如何在 MacOS 上安装 Elasticsearch +====== + +> 安装 Elasticsearch 很复杂!以下是如何在 Mac 上安装。 + +![](https://img.linux.net.cn/data/attachment/album/201907/20/064958dnnwvp8wqzqq4fm2.jpg) + +[Elasticsearch][2] 是一个用 Java 开发的开源全文搜索引擎。用户上传 JSON 格式的数据集。然后,Elasticsearch 在向集群索引中的文档添加可搜索的引用之前先保存原始文档。 + +Elasticsearch 创建还不到九年,但它是最受欢迎的企业搜索引擎。Elastic 在 2019 年 6 月 25 日发布了最新的更新版本 7.2.0。 + +[Kibana][3] 是 Elasticsearch 的开源数据可视化工具。此工具可帮助用户在 Elasticsearch 集群的内容索引之上创建可视化。 + +[Sunbursts][4]、[地理空间数据地图][5]、[关系分析][6]和实时数据面板只是其中几个功能。并且由于 Elasticsearch 的机器学习能力,你可以了解哪些属性可能会影响你的数据(如服务器或 IP 地址)并查找异常模式。 + +在上个月的 [DevFest DC][7] 中,Booz Allen Hamilton 的首席数据科学家 [Summer Rankin 博士][8]将 TED Talk 的内容数据集上传到了 Elasticsearch,然后使用 Kibana 快速构建了面板。出于好奇,几天后我去了一个 Elasticsearch 聚会。 + +由于本课程针对的是新手,因此我们从第一步开始:在我们的笔记本上安装 Elastic 和 Kibana。如果没有安装这两个包,我们无法将莎士比亚的文本数据集作为测试 JSON 文件创建可视化了。 + +接下来,我将分享在 MacOS 上下载、安装和运行 Elasticsearch V7.1.1 的分步说明。这是我在 2019 年 6 月中旬参加 Elasticsearch 聚会时的最新版本。 + +### 下载适合 MacOS 的 Elasticsearch + +1、进入 ,你会看到下面的页面: + +![The Elasticsearch download page.][9] + +2、在**下载**区,单击 **MacOS**,将 Elasticsearch TAR 文件(例如,`elasticsearch-7.1.1-darwin-x86_64.tar`)下载到 `Downloads` 文件夹。 +  +3、双击此文件并解压到自己的文件夹中(例如,`elasticsearch-7.1.1`),这其中包含 TAR 中的所有文件。 + +**提示**:如果你希望 Elasticsearch 放在另一个文件夹中,现在可以移动它。 + +### 在 MacOS 命令行中运行 Elasticsearch + +如果你愿意,你可以只用命令行运行 Elasticsearch。只需遵循以下流程: + +1、[打开终端窗口][10]。 + +2、在终端窗口中,输入你的 Elasticsearch 文件夹。例如(如果你移动了程序,请将 `Downloads` 更改为正确的路径): + +``` +$ cd ~Downloads/elasticsearch-1.1.0 +``` + +3、切换到 Elasticsearch 的 `bin` 子文件夹,然后启动该程序。例如: + +``` +$ cd bin +$ ./elasticsearch +``` + +这是我启动 Elasticsearch 1.1.0 时命令行终端显示的一些输出: + +![Terminal output when running Elasticsearch.][11] + +**注意**:默认情况下,Elasticsearch 在前台运行,这可能会导致计算机速度变慢。按 `Ctrl-C` 可以阻止 Elasticsearch 运行。 + +### 使用 GUI 运行 Elasticsearch + +如果你更喜欢点击操作,你可以像这样运行 Elasticsearch: + +1、打开一个新的 **Finder** 窗口。 + +2、在左侧 Finder 栏中选择 `Downloads`(如果你将 Elasticsearch 移动了另一个文件夹,请进入它)。 + +3、打开名为 `elasticsearch-7.1.1` 的文件夹(对于此例)。出现了八个子文件夹。 + +![The elasticsearch/bin menu.][12] + +4、打开 `bin` 子文件夹。如上面的截图所示,此子文件夹中有 20 个文件。 +  +5、单击第一个文件,即 `elasticsearch`。 + +请注意,你可能会收到安全警告,如下所示: + +![The security warning dialog box.][13] + +这时候要打开程序需要: + +1. 在警告对话框中单击 **OK**。 +2. 打开**系统偏好**。 +3. 单击**安全和隐私**,打开如下窗口: + + ![Where you can allow your computer to open the downloaded file.][14] +4. 单击**永远打开**,打开如下所示的确认对话框: + + ![Security confirmation dialog box.][15] +5. 单击**打开**。会打开一个终端窗口并启动 Elasticsearch。 + +启动过程可能需要一段时间,所以让它继续运行。最终,它将完成,你最后将看到类似这样的输出: + +![Launching Elasticsearch in MacOS.][16] + +### 了解更多 + +安装 Elasticsearch 之后,就可以开始探索了! + +该工具的 [Elasticsearch:开始使用][17]指南会根据你的目标指导你。它的介绍视频介绍了在 [Elasticsearch Service][18] 上启动托管集群,执行基本搜索查询,通过创建、读取、更新和删除(CRUD)REST API 等方式操作数据的步骤。 + +本指南还提供文档链接,开发控制台命令,培训订阅以及 Elasticsearch Service 的免费试用版。此试用版允许你在 AWS 和 GCP 上部署 Elastic 和 Kibana 以支持云中的 Elastic 集群。 + +在本文的后续内容中,我们将介绍在 MacOS 上安装 Kibana 所需的步骤。此过程将通过不同的数据可视化将你的 Elasticsearch 查询带到一个新的水平。 敬请关注! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/installing-elasticsearch-macos + +作者:[Lauren Maffeo][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lmaffeo/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/search_find_code_issue_bug_programming.png?itok=XPrh7fa0 (magnifying glass on computer screen) +[2]: https://www.getapp.com/it-management-software/a/qbox-dot-io-hosted-elasticsearch/ +[3]: https://www.elastic.co/products/kibana +[4]: https://en.wikipedia.org/wiki/Pie_chart#Ring +[5]: https://en.wikipedia.org/wiki/Spatial_analysis +[6]: https://en.wikipedia.org/wiki/Correlation_and_dependence +[7]: https://www.devfestdc.org/ +[8]: https://www.summerrankin.com/about +[9]: https://opensource.com/sites/default/files/uploads/wwa1f3_600px_0.png (The Elasticsearch download page.) +[10]: https://support.apple.com/en-ca/guide/terminal/welcome/mac +[11]: https://opensource.com/sites/default/files/uploads/io6t1a_600px.png (Terminal output when running Elasticsearch.) +[12]: https://opensource.com/sites/default/files/uploads/o43yku_600px.png (The elasticsearch/bin menu.) +[13]: https://opensource.com/sites/default/files/uploads/elasticsearch_security_warning_500px.jpg (The security warning dialog box.) +[14]: https://opensource.com/sites/default/files/uploads/the_general_tab_of_the_system_preferences_security_and_privacy_window.jpg (Where you can allow your computer to open the downloaded file.) +[15]: https://opensource.com/sites/default/files/uploads/confirmation_dialog_box.jpg (Security confirmation dialog box.) +[16]: https://opensource.com/sites/default/files/uploads/y5dvtu_600px.png (Launching Elasticsearch in MacOS.) +[17]: https://www.elastic.co/webinars/getting-started-elasticsearch?ultron=%5BB%5D-Elastic-US+CA-Exact&blade=adwords-s&Device=c&thor=elasticsearch&gclid=EAIaIQobChMImdbvlqOP4wIVjI-zCh3P_Q9mEAAYASABEgJuAvD_BwE +[18]: https://info.elastic.co/elasticsearch-service-gaw-v10-nav.html?ultron=%5BB%5D-Elastic-US+CA-Exact&blade=adwords-s&Device=c&thor=elasticsearch%20service&gclid=EAIaIQobChMI_MXHt-SZ4wIVJBh9Ch3wsQfPEAAYASAAEgJo9fD_BwE diff --git a/published/201907/20190711 Type Linux Commands In Capital Letters To Run Them As Sudo User.md b/published/201907/20190711 Type Linux Commands In Capital Letters To Run Them As Sudo User.md new file mode 100644 index 0000000000..f10ae9352f --- /dev/null +++ b/published/201907/20190711 Type Linux Commands In Capital Letters To Run Them As Sudo User.md @@ -0,0 +1,149 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11142-1.html) +[#]: subject: (Type Linux Commands In Capital Letters To Run Them As Sudo User) +[#]: via: (https://www.ostechnix.com/type-linux-commands-in-capital-letters-to-run-them-as-sudo-user/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +用大写字母输入 Linux 命令以将其作为 sudo 用户运行 +====== + +![Type Linux Commands In Capital Letters To Run Them As Sudo User][1] + +我非常喜欢 Linux 社区的原因是他们创建了很多有趣的项目,你很少能在任何其他操作系统中找到它们。不久前,我们看了一个名为 [Hollywood][2] 的有趣项目,它在类 Ubuntu 系统将终端变成了好莱坞技术情景剧的黑客界面。还有一些其他工具,例如 `cowsay`、`fortune`、`sl` 和 `toilet` 等,用来消磨时间自娱自乐!它们可能没有用,但这些程序娱乐性不错并且使用起来很有趣。今天,我偶然发现了另一个名为 `SUDO` 的类似工具。正如名字暗示的那样,你无论何时用大写字母输入 Linux 命令,`SUDO` 程序都会将它们作为 sudo 用户运行!这意味着,你无需在要运行的 Linux 命令前面输入 `sudo`。很酷,不是么? + +### 安装 SUDO + +> 提醒一句: + +> 在安装这个程序(或任何程序)之前,请查看源代码(最后给出的链接),并查看是否包含会损害你的系统的可疑/恶意代码。在 VM 中测试它。如果你喜欢或觉得它很有用,你可以在个人/生产系统中使用它。 + +用 Git 克隆 `SUDO` 仓库: + +``` +$ git clone https://github.com/jthistle/SUDO.git +``` + +此命令将克隆 SUDO GIT 仓库的内容,并将它们保存在当前目录下的 `SUDO` 的目录中。 + +``` +Cloning into 'SUDO'... +remote: Enumerating objects: 42, done. +remote: Counting objects: 100% (42/42), done. +remote: Compressing objects: 100% (29/29), done. +remote: Total 42 (delta 17), reused 30 (delta 12), pack-reused 0 +Unpacking objects: 100% (42/42), done. +``` + +切换到 `SUDO` 目录: + +``` +$ cd SUDO/ +``` + +并使用命令安装它: + +``` +$ ./install.sh +``` + +该命令将在 `~/.bashrc` 文件中添加以下行: + +``` +[...] +# SUDO - shout at bash to su commands +# Distributed under GNU GPLv2, @jthistle on github + +shopt -s expand_aliases + +IFS_=${IFS} +IFS=":" read -ra PATHS <<< "$PATH" + +for i in "${PATHS[@]}"; do + for j in $( ls "$i" ); do + if [ ${j^^} != $j ] && [ $j != "sudo" ]; then + alias ${j^^}="sudo $j" + fi + done +done + +alias SUDO='sudo $(history -p !!)' + +IFS=${IFS_} + +# end SUDO +``` + +它还会备份你的 `~/.bashrc` 并将其保存为 `~/.bashrc.old`。如果有重大错误,你可以恢复它。 + +最后,使用命令更新更改: + +``` +$ source ~/.bashrc +``` + +### 现在,用大写字母中输入 Linux 命令,将它们作为 Sudo 用户运行 + +通常我们像下面那样执行需要 sudo/root 权限的命令。 + +``` +$ sudo mkdir /ostechnix +``` + +对么?没错!上面的命令将在根目录(`/`)中创建名为 `ostechnix` 的目录。让我们使用 `Ctrl + c` 取消。 + +一旦安装了 `SUDO`,你就可以**在不使用 sudo 的情况下输入任何大写 Linux 命令**并运行它们。因此,你可以像下面那样运行上面的命令: + +``` +$ MKDIR /ostechnix +$ TOUCH /ostechnix/test.txt +$ LS /ostechnix +``` + +![][3] + +用大写字母输入 Linux 命令以将其作为 sudo 用户运行 + +请注意**它无法绕过 sudo 密码**。你仍然需要键入 `sudo` 密码才能执行给定的命令。它只会有助于避免在每个命令前面输入 `sudo`。 + +相关阅读: + + * [如何在 Linux 中没有 sudo 密码运行特定命令][4] + * [如何恢复用户的 sudo 权限][5] + * [如何在 Ubuntu 上为用户授予和删除 sudo 权限][6] + * [如何在 Linux 系统中查找所有 sudo 用户][7] + * [如何在终端中输入密码时显示星号][8] + * [如何更改 Linux 中的 sudo 提示符][9] + + +当然,输入 `sudo` 只需几秒钟,所以这不是什么大问题。 我必须告诉这是一个用来消磨时间的有趣且无用的项目。 如果你不喜欢它,那就去学习一些有用的东西吧。 如果你喜欢它,试一试,玩得开心! + +资源: + + * [SUDO GitHub 仓库][10] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/type-linux-commands-in-capital-letters-to-run-them-as-sudo-user/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/07/sudo-720x340.png +[2]: https://www.ostechnix.com/turn-ubuntu-terminal-hollywood-technical-melodrama-hacker-interface/ +[3]: https://www.ostechnix.com/wp-content/uploads/2019/07/SUDO-in-action.gif +[4]: https://www.ostechnix.com/run-particular-commands-without-sudo-password-linux/ +[5]: https://www.ostechnix.com/how-to-restore-sudo-privileges-to-a-user/ +[6]: https://www.ostechnix.com/how-to-grant-and-remove-sudo-privileges-to-users-on-ubuntu/ +[7]: https://www.ostechnix.com/find-sudo-users-linux-system/ +[8]: https://www.ostechnix.com/display-asterisks-type-password-terminal/ +[9]: https://www.ostechnix.com/change-sudo-prompt-linux-unix/ +[10]: https://github.com/jthistle/SUDO diff --git a/published/201907/20190712 MTTR is dead, long live CIRT.md b/published/201907/20190712 MTTR is dead, long live CIRT.md new file mode 100644 index 0000000000..1055d9e832 --- /dev/null +++ b/published/201907/20190712 MTTR is dead, long live CIRT.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11155-1.html) +[#]: subject: (MTTR is dead, long live CIRT) +[#]: via: (https://opensource.com/article/19/7/measure-operational-performance) +[#]: author: (Julie Gunderson https://opensource.com/users/juliegund/users/kearnsjd/users/ophir) + +MTTR 已死,CIRT 长存 +====== + +> 通过关注影响业务的事件,CIRT 是衡量运维绩效的更准确方法。 + +![Green graph of measurements][1] + +IT 运维圈子的玩法正在发生变化,这意味着过去的规则越来越不合理。机构需要适当环境中的准确的、可理解的、且可操作的指标,以衡量运维绩效并推动关键业务转型。 + +越多的客户使用现代工具,他们管理的事件类型的变化越多,将所有这些不同事件粉碎到一个桶中以计算平均解决时间来表示运维绩效的意义就越少,这就是 IT 一直以来在做的事情。 + +### 历史与指标 + +历史表明,在分析信号以防止错误和误解时,背景信息是关键。例如,在 20 世纪 80 年代,瑞典建立了一个分析水听器信号的系统,以提醒他们在瑞典当地水域出现的俄罗斯潜艇。瑞典人使用了他们认为代表一类俄罗斯潜艇的声学特征 —— 但实际上是鲱鱼在遇到潜在捕食者时释放的[气泡声][2]。这种对指标的误解加剧了各国之间的紧张关系,几乎导致了战争。 + +![Funny fish cartoon][3] + +平均解决时间Mean Time To Resolve(MTTR)是运维经理用于获得实现目标洞察力的主要运维绩效指标。这是一项基于系统可靠性工程systems reliability engineering的古老措施。MTTR 已被许多行业采用,包括制造、设施维护以及最近的 IT 运维,它代表了解决在特定时间段内创建的事件所需的平均时间。 + +MTTR 的计算方法是将所有事件(从事件创建时间到解决时间)所需的时间除以事件总数。 + +![MTTR formula][4] + +正如它所说的,MTTR 是 **所有** 事件的平均值。MTTR 将高紧急事件和低紧急事件混为一谈。它还会重复计算每个单独的、未分组的事件,并得出有效的解决时间。它包括了在相同上下文中手动解决和自动解决的事件。它将在创建了几天(或几个月)甚至完全被忽略的事件混合在一起。最后,MTTR 包括每个小的瞬态突发事件(在 120 秒内自动关闭的事件),这些突发事件要么是非问题噪音,要么已由机器快速解决。 + +![Variability in incident types][5] + +MTTR 将所有事件(无论何种类型)抛入一个桶中,将它们全部混合在一起,并计算整个集合中的“平均”解决时间。这种过于简单化的方法导致运维执行方式的的噪音、错误和误导性指示。 + +### 一种衡量绩效的新方法 + +关键事件响应时间Critical Incident Response Time(CIRT)是评估运维绩效的一种更准确的新方法。PagerDuty 创立了 CIRT 的概念,但该方法可供所有人免费使用。 + +CIRT 通过使用以下技术剔除来自信号的噪声,其重点关注最有可能影响业务的事件: + +1. 真正影响(或可能影响)业务的事件很少是低紧急事件,因此要排除所有低紧急事件。 +2. 真正影响业务的事件很少(如果有的话)可以无需人为干预而通过监控工具自动解决,因此要排除未由人工解决的事件。 +3. 在 120 秒内解决的短暂、爆发性和瞬态事件几乎不可能是真正影响业务的事件,因此要排除它们。 +4. 长时间未被注意、提交或忽略(未确认、未解决)的事件很少会对业务造成影响;排除它们。注意:此阈值可以是特定于客户的统计推导数字(例如,高于均值的两个标准差),以避免使用任意数字。 +5. 由单独警报产生的个别未分组事件并不代表较大的业务影响事件。因此,模拟具有非常保守的阈值(例如,两分钟)的事件分组以计算响应时间。 + +应用这些假设对响应时间有什么影响?简而言之,效果非常非常大! + +通过在关键的、影响业务的事件中关注运维绩效,解决时间分布变窄并极大地向左偏移,因为现在它处理类似类型的事件而不是所有事件。 + +由于 MTTR 计算的响应时间长得多、人为地偏差,因此它是运维绩效较差的一个指标。另一方面,CIRT 是一项有意的措施,专注于对业务最重要的事件。 + +与 CIRT 一起使用的另一个关键措施是确认和解决事故的百分比。这很重要,因为它验证 CIRT(或 MTTA / MTTR)是否值得利用。例如,如果 MTTR 结果很低,比如 10 分钟,那听起来不错,但如果只有 42% 的事件得到解决,那么 MTTR 是可疑的。 + +总之,CIRT 和确认、解决事件的百分比形成了一组有价值的指标,可以让你更好地了解运营的执行情况。衡量绩效是提高绩效的第一步,因此这些新措施对于实现机构的可持续、可衡量的改进周期至关重要。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/measure-operational-performance + +作者:[Julie Gunderson][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/juliegund/users/kearnsjd/users/ophir +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_lead-steps-measure.png?itok=DG7rFZPk (Green graph of measurements) +[2]: http://blogfishx.blogspot.com/2014/05/herring-fart-to-communicate.html +[3]: https://opensource.com/sites/default/files/uploads/fish.png (Funny fish cartoon) +[4]: https://opensource.com/sites/default/files/uploads/mttr.png (MTTR formula) +[5]: https://opensource.com/sites/default/files/uploads/incidents.png (Variability in incident types) diff --git a/published/201907/20190712 Make an RGB cube with Python and Scribus.md b/published/201907/20190712 Make an RGB cube with Python and Scribus.md new file mode 100644 index 0000000000..167a8d1d20 --- /dev/null +++ b/published/201907/20190712 Make an RGB cube with Python and Scribus.md @@ -0,0 +1,251 @@ +[#]: collector: "lujun9972" +[#]: translator: "zianglei" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11108-1.html" +[#]: subject: "Make an RGB cube with Python and Scribus" +[#]: via: "https://opensource.com/article/19/7/rgb-cube-python-scribus" +[#]: author: "Greg Pittman https://opensource.com/users/greg-p/users/greg-p" + +使用 Python 和 Scribus 创建一个 RGB 立方体 +====== + +> 使用 Scribus 的 Python 脚本编写器功能,开发一个显示 RGB 色谱的 3D 立方体。 + +![cubes coming together to create a larger cube][1] + +当我决定这个夏天要玩色彩游戏时,我想到通常色彩都是在色轮上描绘的。这些色彩通常都是使用色素而不是光,并且你失去了任何对颜色亮度或光度变化的感觉。 + +作为色轮的替代,我想在立方体表面使用一系列图形来显示 RGB 频谱。色彩的 RGB 值将在具有 X、Y、Z 轴的三维图形上展示。例如,一个平面将会保持 B(蓝色)为 0,其余的坐标轴将显示当我将 R(红色)和 G (绿色)的值从 0 绘制到 255 时发生的情况。 + +事实证明,使用 [Scribus][2] 及其 [Python 脚本编写器][3] 功能实现这一点并不困难。我可以创建 RGB 颜色,使矩形显示颜色,并以 2D 格式排列它们。我决定设置颜色值的间隔为 5,并让矩形按 5 个点(pt)进行绘图。因此,对于每个 2D 图形,我将使用大约 250 种颜色,立方体的一个边有 250 个点(pt),也就是 3.5 英寸。 + +我使用下面这段 Python 代码完成了绿 - 红图的任务: + +```python +x = 300 +y = 300 +r = 0 +g = 0 +b = 0 + +if scribus.newDoc(scribus.PAPER_LETTER, (0,0,0,0),scribus.PORTRAIT, 1,                  scribus.UNIT_POINTS, scribus.NOFACINGPAGES, scribus.FIRSTPAGERIGHT): +    while r < 256: +        while g < 256: +            newcolor = str(r) + '_' + str(g) + '_' + str(b) +            if newcolor == '0_0_0': +                newcolor = 'Black' +            scribus.defineColorRGB(newcolor,r, g, b) +            rect = scribus.createRect(x + g, y, 5, 5) +            scribus.setFillColor(newcolor, rect) +            scribus.setLineColor(newcolor, rect) +            g = g + 5 +        g = 0 +        r = r + 5 +        y = y – 5 +``` + +这个脚本在 `300,300` 位置开始绘制图形,这个位置大约是一个美国信件大小的纸张的水平中心,大概是垂直方向从顶部到底的三分之一位置;这是图像的原点,然后它沿着 X 轴(绿色值)水平构建图形,然后返回到 Y 轴,向上移动 5 个点,然后绘制下一条矩形线。 + +![Red-Green graph][4] + +这看起来很简单;我只需要调整一下数字就可以把立方体的另一面画出来。但这不仅仅是再画两个图,一个是蓝 - 绿色,另一个是红 - 蓝色的问题。我想创建一个展开的立方体,这样我就可以打印、剪开然后折叠它,创建一个 RGB 的 3D 视图。因此,下一部分(向下的页面)的原点(黑色的角落)需要在左上角,其水平方向是绿色,垂直方向是蓝色。 + +“调整数字”最终或多或少变成了试错,从而得到我想要的东西。在创建了第二个图之后,我需要第三个图,它是红 - 蓝色的,原点位于左上角,红色向左递增,蓝色向下递增。 + +下面是最终效果图: + +![First half of RGB cube][5] + +当然,这只是这个立方体的前半部分。我需要做一个类似的形状,除了原点应该是白色(而不是黑色)来表示高值。这是我希望自己更聪明的时候之一,因为我不仅需要做出一个类似的整体形状,还需要以镜像的方式与第一个形状交互(我认为)。有时候,尝试和错误是你唯一的朋友。 + +结果是这样的;我使用了一个单独的脚本,因为在一个美国信件大小的页面上没有足够的空间同时容纳这两个图案。 + +![Second half of RGB cube][6] + +现在,是时候轮到打印机了!在这里,你可以直观了解彩色打印机如何处理 RGB 颜色到 CMYK 颜色的转换以及打印颜色密集空间。 + +接下来,朋友们,是剪切粘贴时间!我可以用胶带,但我不想改变表面的外观,所以我在切割的时候在两边留下了一些空间,这样我就可以把它们粘在里面了。根据我的经验,在复印纸上打印会产生一些不需要的皱纹,所以在我的复印纸原型完成后,我把立方体打印在了更厚的纸上,表面是哑光的。 + +![RGB cubes][7] + +请记住,这只是 RGB 空间边界的一个视图;更准确地说,你必须做出一个可以在中间切片的实心立方体。例如,这是一个实心 RGB 立方体在蓝色 = 120 的切片。 + +![RGB cube slice][8] + +最后,我做这个项目很开心。如果您也想参与其中,这里有两个脚本。 + +这是前半部分: + +```python +#!/usr/bin/env python +# black2rgb.py +""" +Creates one-half of RGB cube with Black at origin +""" + +import scribus + +x = 300 +y = 300 +r = 0 +g = 0 +b = 0 + +if scribus.newDoc(scribus.PAPER_LETTER, (0,0,0,0),scribus.PORTRAIT, 1, scribus.UNIT_POINTS, scribus.NOFACINGPAGES, scribus.FIRSTPAGERIGHT): +    while r < 256: +        while g < 256: +            newcolor = str(r) + '_' + str(g) + '_' + str(b) +            if newcolor == '0_0_0': +                newcolor = 'Black' +            scribus.defineColorRGB(newcolor,r, g, b) +            rect = scribus.createRect(x + g, y, 5, 5) +            scribus.setFillColor(newcolor, rect) +            scribus.setLineColor(newcolor, rect) +            g = g + 5 +        g = 0 +        r = r + 5 +        y = y - 5 +        +    r = 0 +    g = 0 +    y = 305 + +    while b < 256: +        while g < 256: +            newcolor = str(r) + '_' + str(g) + '_' + str(b) +            if newcolor == '0_0_0': +                newcolor = 'Black' +            scribus.defineColorRGB(newcolor,r, g, b) +            rect = scribus.createRect(x + g, y, 5, 5) +            scribus.setFillColor(newcolor, rect) +            scribus.setLineColor(newcolor, rect) +            g = g + 5 +        g = 0 +        b = b + 5 +        y = y + 5 +        +    r = 255 +    g = 0 +    y = 305 +    x = 39 +    b = 0 + +    while b < 256: +        while r >= 0: +            newcolor = str(r) + '_' + str(g) + '_' + str(b) +            if newcolor == '0_0_0': +                newcolor = 'Black' +            scribus.defineColorRGB(newcolor,r, g, b) +            rect = scribus.createRect(x, y, 5, 5) +            scribus.setFillColor(newcolor, rect) +            scribus.setLineColor(newcolor, rect) +            r = r - 5 +            x = x+5 +        b = b + 5 +        x = 39.5 +        r = 255 +        y = y + 5 +        +scribus.setRedraw(True) +scribus.redrawAll() +``` + +后半部分: + + +```python +#!/usr/bin/env python +# white2rgb.py +""" +Creates one-half of RGB cube with White at origin +""" + +import scribus + +x = 300 +y = 300 +r = 255 +g = 255 +b = 255 + +if scribus.newDoc(scribus.PAPER_LETTER, (0,0,0,0),scribus.PORTRAIT, 1, scribus.UNIT_POINTS, scribus.NOFACINGPAGES, scribus.FIRSTPAGERIGHT): +    while g >= 0: +        while r >= 0: +            newcolor = str(r) + '_' + str(g) + '_' + str(b) +            if newcolor == '255_255_255': +                newcolor = 'White' +            scribus.defineColorRGB(newcolor,r, g, b) +            rect = scribus.createRect(x + 255 - r, y, 5, 5) +            scribus.setFillColor(newcolor, rect) +            scribus.setLineColor(newcolor, rect) +            r = r - 5 +        r = 255 +        g = g - 5 +        y = y - 5 +        +    r = 255 +    g = 255 +    y = 305 + +    while b >= 0: +        while r >= 0: +            newcolor = str(r) + '_' + str(g) + '_' + str(b) +            if newcolor == '255_255_255': +                newcolor = 'White' +            scribus.defineColorRGB(newcolor,r, g, b) +            rect = scribus.createRect(x + 255 - r, y, 5, 5) +            scribus.setFillColor(newcolor, rect) +            scribus.setLineColor(newcolor, rect) +            r = r - 5 +        r = 255 +        b = b - 5 +        y = y + 5 +        +    r = 255 +    g = 0 +    y = 305 +    x = 39 +    b = 255 + +    while b >= 0: +        while g < 256: +            newcolor = str(r) + '_' + str(g) + '_' + str(b) +            if newcolor == '255_255_255': +                newcolor = 'White' +            scribus.defineColorRGB(newcolor,r, g, b) +            rect = scribus.createRect(x + g, y, 5, 5) +            scribus.setFillColor(newcolor, rect) +            scribus.setLineColor(newcolor, rect) +            g = g + 5 +        g = 0 +        b = b - 5 +        y = y + 5 +        +scribus.setRedraw(True) +scribus.redrawAll() +``` + +由于我创建了大量的颜色,所以当看到 Scribus 文件比我用它创建的 PDF 文件大得多的时候,我并不感到惊讶。例如,我的 Scribus SLA 文件是 3.0MB,而从中生成的 PDF 只有 70KB。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/rgb-cube-python-scribus + +作者:[Greg Pittman][a] +选题:[lujun9972][b] +译者:[zianglei](https://github.com/zianglei) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux 中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/greg-p/users/greg-p +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cube_innovation_process_block_container.png?itok=vkPYmSRQ "cubes coming together to create a larger cube" +[2]: https://www.scribus.net/ +[3]: https://opensource.com/sites/default/files/ebooks/pythonscriptingwithscribus.pdf +[4]: https://opensource.com/sites/default/files/uploads/redgreengraph.png "Red-Green graph" +[5]: https://opensource.com/sites/default/files/uploads/rgbcubefirsthalf.png "First half of RGB cube" +[6]: https://opensource.com/sites/default/files/uploads/rgbcubesecondhalf.png "Second half of RGB cube" +[7]: https://opensource.com/sites/default/files/uploads/rgbcubecompositephoto.png "RGB cubes" +[8]: https://opensource.com/sites/default/files/uploads/rgbcubeslice.png "RGB cube slice" diff --git a/published/201907/20190713 ElectronMail - a Desktop Client for ProtonMail and Tutanota.md b/published/201907/20190713 ElectronMail - a Desktop Client for ProtonMail and Tutanota.md new file mode 100644 index 0000000000..b59148825d --- /dev/null +++ b/published/201907/20190713 ElectronMail - a Desktop Client for ProtonMail and Tutanota.md @@ -0,0 +1,106 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11128-1.html) +[#]: subject: (ElectronMail – a Desktop Client for ProtonMail and Tutanota) +[#]: via: (https://itsfoss.com/electronmail/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +ElectronMail:ProtonMail 和 Tutanota 的桌面客户端 +====== + +互联网上的大多数人都拥有来自 Google 等大公司的电子邮件帐户,但这些帐户不尊重你的隐私。值得庆幸的是,目前有 [Tutanota][1] 和 [ProtonMail][2] 等具有隐私意识的替代品。问题是并非所有人都有桌面客户端。今天,我们将研究一个为你解决该问题的项目。我们来看看 ElectronMail 吧。 + +> ‘Electron’ 警告! + +> 以下应用是使用 Electron 构建的(也就是名为 ElectronMail 的原因之一)。如果使用 Electron 让你感到不安,请将此视为触发警告。 + +### ElectronMail:Tutanota 和 ProtonMail 的桌面客户端 + +![Electron Mail About][3] + +[ElectronMail][4] 可以简单地视作 ProtonMail 和 Tutanota 的电子邮件客户端。它使用三大技术构建:[Electron][5]、[TypeScript][6] 和 [Angular][7]。它包括以下功能: + +* 针对每个电子邮件提供商提供多帐户支持 +* 加密本地存储 +* 适用于 Linux、Windows、macOS 和 FreeBSD +* 原生通知系统 +* 带有未读消息总数的系统托盘图标 +* 用主密码保护帐户信息 +* 可切换的视图布局 +* 可离线访问电子邮件 +* 电子邮件在本地加密存储 +* 批量导出电子邮件为 EML 文件 +* 全文搜索 +* 内置/预打包的 Web 客户端 +* 可以为每个帐户配置代理 +* 拼写检查 +* 支持双因素身份验证,以提高安全性 + +目前,ElectronMail 仅支持 Tutanota 和 ProtonMail。我觉得他们将来会增加更多。根据 [GitHub 页面][4]:“多电子邮件提供商支持。目前支持 ProtonMail 和 Tutanota。” + +ElectronMail 目前是 MIT 许可证。 + +#### 如何安装 ElectronMail + +目前,有几种方法可以在 Linux 上安装 ElectronMail。对于Arch 和基于 Arch 的发行版,你可以从[Arch 用户仓库][8]安装它。ElectrionMail 还有一个 Snap 包。要安装它,只需输入 `sudo snap install electron-mail` 即可。 + +对于所有其他 Linux 发行版,你可以[下载][9] `.deb` 或 `.rpm` 文件。 + +![Electron Mail Inbox][10] + +你也可以[下载][9]用于 Windows 中的 `.exe` 安装程序或用于 macOS 的 `.dmg` 文件。甚至还有给 FreeBSD 用的文件。 + +#### 删除 ElectronMail + +如果你安装了 ElectronMail 并确定它不适合你,那么[开发者][12]建议采用几个步骤。 **在卸载应用之前,请务必遵循以下步骤。** + +如果你使用了“保持登录”功能,请单击菜单上的“注销”。这将删除本地保存的主密码。卸载 ElectronMail 后也可以删除主密码,但这涉及编辑系统密钥链。 + +你还需要手动删除设置文件夹。在系统托盘中选择应用图标后,单击“打开设置文件夹”可以找到它。 + +![Electron Mail Setting][13] + +### 我对 ElectronMail 的看法 + +我通常不使用电子邮件客户端。事实上,我主要依赖于 Web 客户端。所以,这个应用对我没太大用处。 + +话虽这么说,但是 ElectronMail 看着不错,而且很容易设置。它有大量开箱即用的功能,并且高级功能并不难使用。 + +我遇到的一个问题与搜索有关。根据功能列表,ElectronMail 支持全文搜索。但是,Tutanota 的免费版本仅支持有限的搜索。我想知道 ElectronMail 如何处理这个问题。 + +最后,ElectronMail 只是一个基于 Web Email 的一个 Electron 封装。我宁愿在浏览器中打开它们,而不是将单独的系统资源用于运行 Electron。如果你只[使用 Tutanota,他们有自己官方的 Electron 桌面客户端][14]。你可以尝试一下。 + +我最大的问题是安全性。这是两个非常安全的电子邮件应用的非官方应用。如果有办法捕获你的登录信息或阅读你的电子邮件怎么办?比我聪明的人必须通过源代码才能确定。这始终是一个安全项目的非官方应用的问题。 + +你有没有使用过 ElectronMail?你认为是否值得安装 ElectronMail?你最喜欢的邮件客户端是什么?请在下面的评论中告诉我们。 + +如果你发现这篇文章很有趣,请花一点时间在社交媒体、Hacker News 或 [Reddit][15] 上分享它。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/electronmail/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/tutanota-review/ +[2]: https://itsfoss.com/protonmail/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/electron-mail-about.jpg?resize=800%2C500&ssl=1 +[4]: https://github.com/vladimiry/ElectronMail +[5]: https://electronjs.org/ +[6]: http://www.typescriptlang.org/ +[7]: https://angular.io/ +[8]: https://aur.archlinux.org/packages/electronmail-bin +[9]: https://github.com/vladimiry/ElectronMail/releases +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/electron-mail-inbox.jpg?ssl=1 +[12]: https://github.com/vladimiry +[14]: https://linux.cn/article-10688-1.html +[15]: http://reddit.com/r/linuxusersgroup diff --git a/published/201907/20190714 Excellent- Ubuntu LTS Users Will Now Get the Latest Nvidia Driver Updates -No PPA Needed Anymore.md b/published/201907/20190714 Excellent- Ubuntu LTS Users Will Now Get the Latest Nvidia Driver Updates -No PPA Needed Anymore.md new file mode 100644 index 0000000000..d52412c511 --- /dev/null +++ b/published/201907/20190714 Excellent- Ubuntu LTS Users Will Now Get the Latest Nvidia Driver Updates -No PPA Needed Anymore.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11110-1.html) +[#]: subject: (Excellent! Ubuntu LTS Users Will Now Get the Latest Nvidia Driver Updates [No PPA Needed Anymore]) +[#]: via: (https://itsfoss.com/ubuntu-lts-latest-nvidia-drivers/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +好消息!Ubuntu LTS 用户不需要 PPA 也可以获得最新的 Nvidia 驱动更新 +====== + +> 要在 Ubuntu LTS 上获得的最新 Nvidia 驱动程序,你不必再使用 PPA 了。最新的驱动程序现在将在 Ubuntu LTS 版本的存储库中提供。 + +![][1] + +你可能已经注意到在 Ubuntu 上安装最新和最好的 Nvidia 二进制驱动程序更新的麻烦。 + +默认情况下,Ubuntu 提供开源的 [Nvidia Nouveau 驱动程序][2],这有时会导致 Ubuntu 卡在启动屏幕上。 + +你也可以轻松地[在 Ubuntu 中安装专有的 Nvidia 驱动程序][3]。问题是默认 [Ubuntu 存储库][4]中的 Nvidia 驱动程序不是最新的。为此,几年前 [Ubuntu 引入了一个专门的 PPA][5]以解决这个问题。 + +[使用官方 PPA][6] 仍然是安装闭源图形驱动程序的一个不错的解决方法。但是,它绝对不是最方便的选择。 + +但是,现在,Ubuntu 同意将最新的 Nvidia 驱动程序更新作为 SRU([StableReleaseUpdates][7])的一部分提供。所以,你将在使用 Ubuntu LTS 版本时也拥有 Nvidia 驱动程序了。 + +好吧,这意味着你不再需要在 Ubuntu LTS 版本上单独下载/安装 Nvidia 图形驱动程序。 + +就像你会获得浏览器或核心操作系统更新(或安全更新)的更新包一样,你将获得所需的 Nvidia 二进制驱动程序的更新包。 + +### 这个最新的 Nvidia 显卡驱动程序可靠吗? + +SRU 字面上指的是 Ubuntu(或基于 Ubuntu 的发行版)的稳定更新。因此,要获得最新的图形驱动程序,你应该等待它作为稳定更新释出,而不是选择预先发布的更新程序。 + +当然,没有人能保证它能在所有时间内都正常工作 —— 但安装起来比预先发布的更安全。 + +### 怎样获得最新的 Nvidia 驱动程序? + +![Software Updates Nvidia][8] + +你只需从软件更新选项中的其他驱动程序部分启用“使用 NVIDIA 驱动程序元数据包……”。 + +最初,[The Linux Experiment][10] 通过视频分享了这个消息 —— 然后 Ubuntu 的官方 Twitter 作为公告重新推送了它。你可以观看下面的视频以获取更多详细信息: + +- [https://youtu.be/NFdeWTQIpjo](https://youtu.be/NFdeWTQIpjo) + +### 支持哪些 Ubuntu LTS 版本? + +目前,Ubuntu 18.04 LTS 已经可用了,它也将很快在 Ubuntu 16.04 LTS 上可用(随后的 LTS 也将次第跟上)。 + +### 总结 + +现在你可以安装最新的 Nvidia 二进制驱动程序更新了,你认为这有何帮助? + +如果你已经测试了预先发布的软件包,请在下面的评论中告诉我们你对此的看法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-lts-latest-nvidia-drivers/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/nvidia-ubuntu-logo.png?resize=800%2C450&ssl=1 +[2]: https://nouveau.freedesktop.org/wiki/ +[3]: https://itsfoss.com/install-additional-drivers-ubuntu/ +[4]: https://itsfoss.com/ubuntu-repositories/ +[5]: https://itsfoss.com/ubuntu-official-ppa-graphics/ +[6]: https://itsfoss.com/ppa-guide/ +[7]: https://wiki.ubuntu.com/StableReleaseUpdates +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/07/software-updates-nvidia.jpg?fit=800%2C542&ssl=1 +[9]: https://itsfoss.com/ubuntu-17-04-release-features/ +[10]: https://twitter.com/thelinuxEXP diff --git a/published/201907/20190716 Become a lifelong learner and succeed at work.md b/published/201907/20190716 Become a lifelong learner and succeed at work.md new file mode 100644 index 0000000000..c9906592db --- /dev/null +++ b/published/201907/20190716 Become a lifelong learner and succeed at work.md @@ -0,0 +1,72 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11130-1.html) +[#]: subject: (Become a lifelong learner and succeed at work) +[#]: via: (https://opensource.com/open-organization/19/7/informal-learning-adaptability) +[#]: author: (Colin Willis https://opensource.com/users/colinwillishttps://opensource.com/users/marcobravo) + + +成为终身学习者,并在工作中取得成功 +====== + +> 在具有适应性文化的开放组织中,学习应该一直持续 —— 但不会总是出现在正式场合。我们真的明白它是如何工作的吗? + +![Writing in a notebook][1] + +持续学习是指人们为发展自己而进行的持续的、职业驱动的、有意识的学习过程。对于那些自认是持续学习者的人来说,学习从未停止 —— 这些人从日常经历中看到学习机会。与同事进行辩论、反思反馈、在互联网上寻找问题的解决方案、尝试新事物或冒险都是一个人在工作中可以进行的非正式学习活动的例子。 + +持续学习是开放组织中任何人的核心能力。毕竟,开放的组织是建立在同行相互思考、争论和行动的基础上的。在开放组织的模棱两可、话语驱动的世界中茁壮成长,每天都需要员工具备这些技能。 + +不幸的是,科学文献在传播我们在工作中学习的知识方面、帮助个人欣赏和发展自己的学习能力方面,做得很差。因此,在本文系列中,我将向你介绍非正式学习,并帮助你理解将学习视为一种技能会如何帮助你在任何组织中茁壮成长,尤其是在开放式组织中。 + +### 为什么这么正式? + +迄今为止,对组织中学习的科学研究主要集中在正式学习而不是非正式学习的设计、交付和评估上。 + +投资于员工知识、技能和能力的发展是一个组织保持其相对于竞争对手优势的重要方式。组织通过创建或购买课程、在线课程、研讨会等来使学习机会正规化。这些课程旨在像个人传授与工作相关的内容,就像学校里的班级一样。对于一个组织来说,提供一门课程是一种简单(如果成本高昂的话)的方法,可以确保其员工的技能或知识保持最新。同样,教室环境是研究人员的天然实验室,使得基于培训的研究和工作不仅可能,而且强大。 + +当然,有些东西人们不需要培训来学习;通常,人们通过研究答案、与同事交谈、思考、实验或适应变化来学习。事实上,[最近的评估表明][2] 70% 到 80% 的与工作相关的知识不是在培训中学到的,而是在工作中非正式学到的。这并不是说正规的培训无效;培训可能非常有效,但它是一种精确的干预方式。在工作的大部分方面正式培训一个人是不现实的,尤其是当这些工作变得更加复杂的时候。 + +因此,非正式学习,或者任何发生在结构化学习环境之外的学习,对工作场所来说是极其重要的。事实上,[最近的科学证据][3]表明,非正式学习比正式培训更能预测工作表现。 + +那么,为什么机构和科学界如此关注培训呢? + +### 循环过程 + +除了我前面提到的原因,研究非正式学习可能非常困难。与正式学习不同,非正式学习发生在非结构化环境中,高度依赖于个人,很难或不可能观察到。 + +直到最近,大多数关于非正式学习的研究都集中在定义非正式学习的合格特征和确定非正式学习在理论上是如何与工作经验联系在一起的。研究人员描述了一个[动态的周期性过程][4],通过这个过程,个人可以在组织中非正式地学习。 + +与正式学习一样,非正式学习发生在非结构化环境中,高度依赖于个人,很难或不可能观察。 + +在这个过程中,个人和组织都有创造学习机会的机构。例如,一个人可能对学习某样东西感兴趣,并为此表现出学习行为。组织以向个人提供反馈的形式,可能表明需要学习。这可能是一个糟糕的绩效评估、一个在项目中发表的评论、或者一个不是个人指导的组织环境的更广泛的变化。这些力量在组织环境中(例如,有人尝试了一个新想法,他或她的同事认识到并奖励了这种行为)或者通过在个人的头脑中反思(例如,有人反思了关于他或她的表现的,并决定在学习工作中付出更多的努力)。与培训不同,非正式学习不遵循正式的线性过程。个人可以随时体验过程的任何部分,同时体验过程的多个部分。 + +### 开放组织中的非正式学习 + +具体而言,在开放组织中,既减少了对等级制度的重视程度,又更加注重对参与式文化的重视程度,这两者都推动了这种非正式的学习。简而言之,开放式组织只是为个人和组织环境提供了更多互动和激发学习的机会。此外,想法和变革需要开放式组织中员工给予更广泛的认同 —— 而认同需要对他人的适应性和洞察力的欣赏。 + +也就是说,仅仅增加学习机会并不能保证学习会发生或成功。有人甚至可能会说,开放式组织中常见的模糊性和公开性话语可能会阻止不擅长持续学习的人——同样,随着时间的推移学习的习惯和开放式组织的核心能力——尽可能有效地为组织做出贡献。 + +解决这些问题需要一种以一致的方式跟踪非正式学习。最近,科学界呼吁创造衡量非正式学习的方法,这样就可以进行系统的研究来解决非正式学习的前因后果的问题。我自己的研究集中在这一呼吁上,我花了几年时间发展和完善我们对非正式学习行为的理解,以便可以衡量它们。 + +在本文系列的第二部分,我将重点介绍我最近在一个开放式组织中进行的一项研究的成果,在该研究中,我测试了我对非正式学习行为的研究,并将它们与更广泛的工作环境和个人工作成果联系起来。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/19/7/informal-learning-adaptability + +作者:[Colin Willis][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/colinwillishttps://opensource.com/users/marcobravo +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/notebook-writing-pen.jpg?itok=uA3dCfu_ (Writing in a notebook) +[2]: https://www.groupoe.com/images/Accelerating_On-the-Job-Learning_-_White_Paper.pdf +[3]: https://www.researchgate.net/publication/316490244_Antecedents_and_Outcomes_of_Informal_Learning_Behaviors_a_Meta-Analysis +[4]: https://psycnet.apa.org/record/2008-13469-009 diff --git a/published/201907/20190716 Save and load Python data with JSON.md b/published/201907/20190716 Save and load Python data with JSON.md new file mode 100644 index 0000000000..a716d958c4 --- /dev/null +++ b/published/201907/20190716 Save and load Python data with JSON.md @@ -0,0 +1,128 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11133-1.html) +[#]: subject: (Save and load Python data with JSON) +[#]: via: (https://opensource.com/article/19/7/save-and-load-data-python-json) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +使用 Python 处理 JSON 格式的数据 +====== + +> 如果你不希望从头开始创造一种数据格式来存放数据,JSON 是一个很好的选择。如果你对 Python 有所了解,就更加事半功倍了。下面就来介绍一下如何使用 Python 处理 JSON 数据。 + +![Cloud and databsae incons][1] + +[JSON][2] 的全称是 JavaScript 对象表示法JavaScript Object Notation。这是一种以键值对的形式存储数据的格式,并且很容易解析,因而成为了一种被广泛使用的数据格式。另外,不要因为 JSON 名称而望文生义,JSON 并不仅仅在 JavaScript 中使用,它也可以在其它语言中使用。下文会介绍它是如何在 Python 中使用的。 + +首先我们给出一个 JSON 示例: + +``` +{ + "name":"tux", + "health":"23", + "level":"4" +} +``` + +上面是一个和编程语言无关的原生 JSON 数据。熟悉 Python 的人会看出来这个 JSON 数据跟 Python 中的字典dictionary长得很像。而这两者之间确实非常相似,如果你对 Python 中的列表和字典数据结构有一定的理解,那么 JSON 理解起来也不难。 + +### 使用字典存放数据 + +如果你的应用需要存储一些结构复杂的数据,不妨考虑使用 JSON 格式。对比你可能曾经用过的自定义格式的文本配置文件,JSON 提供了更加结构化的可递归的存储格式。同时,Python 自带的 `json` 模块已经提供了可以将 JSON 数据导入/导出应用时所需的所有解析库。因此,你不需要针对 JSON 自行编写代码进行解析,而其他开发人员在与你的应用进行数据交互的时候也不需要去解析新的数据格式。正是这个原因,JSON 在数据交换时被广泛地采用了。 + +以下是一段在 Python 中使用嵌套字典的代码: + +``` +#!/usr/bin/env python3 + +import json + +# instantiate an empty dict +team = {} + +# add a team member +team['tux'] = {'health': 23, 'level': 4} +team['beastie'] = {'health': 13, 'level': 6} +team['konqi'] = {'health': 18, 'level': 7} +``` + +这段代码声明了一个名为 `team` 的字典,并初始化为一个空字典。 + +如果要给这个字典添加内容,首先需要创建一个键,例如上面示例中的 `tux`、`beastie`、`konqi`,然后为这些键一一提供对应的值。上面示例中的值由一个个包含游戏玩家信息的字典充当。 + +字典是一种可变的变量。字典中的数据可以随时添加、删除或更新。这样的特性使得字典成为了应用程序存储数据的极好选择。 + +### 使用 JSON 格式存储数据 + +如果存放在字典中的数据需要持久存储,这些数据就需要写到文件当中。这个时候就需要用到 Python 中的 `json` 模块了: + +``` +with open('mydata.json', 'w') as f: + json.dump(team, f) +``` + +上面的代码首先创建了一个名为 `mydata.json` 的文件,然后以写模式打开了这个文件,这个被打开的文件以变量 `f` 表示(当然也可以用任何你喜欢的名称,例如 `file`、`output` 等)。而 `json` 模块中的 `dump()` 方法则是用于将一个字典输出到一个文件中。 + +从应用中导出数据就是这么简单,同时这些导出的数据是结构化的、可理解的。现在可以查看导出的数据: + +``` +$ cat mydata.json +{"tux": {"health": 23, "level": 4}, "beastie": {"health": 13, "level": 6}, "konqi": {"health": 18, "level": 7}} +``` + +### 从 JSON 文件中读取数据 + +如果已经将数据以 JSON 格式导出到文件中了,也有可能需要将这些数据读回到应用中去。这个时候,可以使用 Python `json` 模块中的 `load()` 方法: + +``` +#!/usr/bin/env python3 + +import json + +f = open('mydata.json') +team = json.load(f) + +print(team['tux']) +print(team['tux']['health']) +print(team['tux']['level']) + +print(team['beastie']) +print(team['beastie']['health']) +print(team['beastie']['level']) + +# when finished, close the file +f.close() +``` + +这个方法实现了和保存文件大致相反的操作。使用一个变量 `f` 来表示打开了的文件,然后使用 `json` 模块中的 `load()` 方法读取文件中的数据并存放到 `team` 变量中。 + +其中的 `print()` 展示了如何查看读取到的数据。在过于复杂的字典中迭代调用字典键的时候有可能会稍微转不过弯来,但只要熟悉整个数据的结构,就可以慢慢摸索出其中的逻辑。 + +当然,这里使用 `print()` 的方式太不灵活了。你可以将其改写成使用 `for` 循环的形式: + +``` +for i in team.values(): + print(i) +``` + +### 使用 JSON + +如上所述,在 Python 中可以很轻松地处理 JSON 数据。因此只要你的数据符合 JSON 的模式,就可以选择使用 JSON。JSON 非常灵活易用,下次使用 Python 的时候不妨尝试一下。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/save-and-load-data-python-json + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus_cloud_database.png?itok=lhhU42fg (Cloud and databsae incons) +[2]: https://json.org diff --git a/published/201907/20190717 Bond WiFi and Ethernet for easier networking mobility.md b/published/201907/20190717 Bond WiFi and Ethernet for easier networking mobility.md new file mode 100644 index 0000000000..b8528ca1dd --- /dev/null +++ b/published/201907/20190717 Bond WiFi and Ethernet for easier networking mobility.md @@ -0,0 +1,126 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11149-1.html) +[#]: subject: (Bond WiFi and Ethernet for easier networking mobility) +[#]: via: (https://fedoramagazine.org/bond-wifi-and-ethernet-for-easier-networking-mobility/) +[#]: author: (Ben Cotton https://fedoramagazine.org/author/bcotton/) + +绑定 WiFi 和以太网,以使网络间移动更轻松 +====== + +![][1] + +有时一个网络接口是不够的。网络绑定允许将多条网络连接与单个逻辑接口一起工作。你可能因为需要给单条连接更多的带宽而这么做,或者你可能希望在有线和无线网络之间来回切换而不会丢失网络连接。 + +我是后面一种情况。在家工作的好处之一是,当天气晴朗时,在阳光明媚的阳台而不是在室内工作是很愉快的。但每当我这样做时,我都会失去网络连接。IRC、SSH、VPN,一切都断开了,客户端重连至少需要一会。本文介绍了如何在 Fedora 30 笔记本上设置网络绑定,以便从笔记本扩展坞的有线连接无缝切换到 WiFi。 + +在 Linux 中,接口绑定由内核模块 `bonding` 处理。默认情况下,Fedora 没有启用此功能,但它包含在 `kernel-core` 软件包中。这意味着启用接口绑定只需一个命令: + +``` +sudo modprobe bonding +``` + +请注意,这只会在你重启之前生效。要永久启用接口绑定,请在 `/etc/modules-load.d` 目录中创建一个名为 `bonding.conf` 的文件,该文件仅包含单词 `bonding`。 + +现在你已启用绑定,现在可以创建绑定接口了。首先,你必须获取要绑定的接口的名称。要列出可用的接口,请运行: + +``` +sudo nmcli device status +``` + +你将看到如下输出: + +``` +DEVICE TYPE STATE CONNECTION +enp12s0u1 ethernet connected Wired connection 1 +tun0 tun connected tun0 +virbr0 bridge connected virbr0 +wlp2s0 wifi disconnected -- +p2p-dev-wlp2s0 wifi-p2p disconnected -- +enp0s31f6 ethernet unavailable -- +lo loopback unmanaged -- +virbr0-nic tun unmanaged -- +``` + +在本例中,有两个(有线)以太网接口可用。 `enp12s0u1` 在笔记本电脑扩展坞上,你可以通过 `STATE` 列知道它已连接。另一个是 `enp0s31f6`,是笔记本电脑中的内置端口。还有一个名为 `wlp2s0` 的 WiFi 连接。 `enp12s0u1` 和 `wlp2s0` 是我们在这里感兴趣的两个接口。(请注意,阅读本文无需了解网络设备的命名方式,但如果你感兴趣,可以查看 [systemd.net-naming-scheme 手册页][2]。) + +第一步是创建绑定接口: + +``` +sudo nmcli connection add type bond ifname bond0 con-name bond0 +``` + +在此示例中,绑定接口名为 `bond0`。`con-name bond0` 将连接名称设置为 `bond0`。直接这样做会有一个名为 `bond-bond0` 的连接。你还可以将连接名设置得更加人性化,例如 “Docking station bond” 或 “Ben”。 + +下一步是将接口添加到绑定接口: + +``` +sudo nmcli connection add type ethernet ifname enp12s0u1 master bond0 con-name bond-ethernet +sudo nmcli connection add type wifi ifname wlp2s0 master bond0 ssid Cotton con-name bond-wifi +``` + +如上所示,连接名称被设置为[更具描述性][3]。请务必使用系统上相应的接口名称替换 `enp12s0u1` 和 `wlp2s0`。对于 WiFi 接口,请使用你自己的网络名称 (SSID)替换我的 “Cotton”。如果你的 WiFi 连接有密码(这当然会有!),你也需要将其添加到配置中。以下假设你使用 [WPA2-PSK][4] 身份验证 + +``` +sudo nmcli connection modify bond-wifi wifi-sec.key-mgmt wpa-psk +sudo nmcli connection edit bond-wif +``` + +第二条命令将进入交互式编辑器,你可以在其中输入密码,而无需将其记录在 shell 历史记录中。输入以下内容,将 `password` 替换为你的实际密码。 + +``` +set wifi-sec.psk password +save +quit +``` + +现在,你可以启动你的绑定接口以及你创建的辅助接口。 + +``` +sudo nmcli connection up bond0 +sudo nmcli connection up bond-ethernet +sudo nmcli connection up bond-wifi +``` + +你现在应该能够在不丢失网络连接的情况下断开有线或无线连接。 + +### 警告:使用其他 WiFi 网络时 + +在指定的 WiFi 网络间移动时,此配置很有效,但是当远离此网络时,那么绑定中使用的 SSID 就不可用了。从理论上讲,可以为每个使用的 WiFi 连接添加一个接口,但这似乎并不合理。相反,你可以禁用绑定接口: + +``` +sudo nmcli connection down bond0 +``` + +回到定义的 WiFi 网络时,只需按上述方式启动绑定接口即可。 + +### 微调你的绑定 + +默认情况下,绑定接口使用“轮询round-robin”模式。这会在接口上平均分配负载。但是,如果你有有线和无线连接,你可能希望更喜欢有线连接。 `active-backup` 模式能实现此功能。你可以在创建接口时指定模式和主接口,或者之后使用此命令(绑定接口应该关闭): + +``` +sudo nmcli connection modify bond0 +bond.options "mode=active-backup,primary=enp12s0u1" +``` + +[内核文档][5]提供了有关绑定选项的更多信息。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/bond-wifi-and-ethernet-for-easier-networking-mobility/ + +作者:[Ben Cotton][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/bcotton/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/07/networkingmobility-816x345.jpg +[2]: https://www.freedesktop.org/software/systemd/man/systemd.net-naming-scheme.html +[3]: https://en.wikipedia.org/wiki/Master/slave_(technology)#Terminology_concerns +[4]: https://en.wikipedia.org/wiki/Wi-Fi_Protected_Access#Target_users_(authentication_key_distribution) +[5]: https://www.kernel.org/doc/Documentation/networking/bonding.txt diff --git a/published/201907/20190717 How to install Kibana on MacOS.md b/published/201907/20190717 How to install Kibana on MacOS.md new file mode 100644 index 0000000000..a4495adc46 --- /dev/null +++ b/published/201907/20190717 How to install Kibana on MacOS.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11135-1.html) +[#]: subject: (How to install Kibana on MacOS) +[#]: via: (https://opensource.com/article/19/7/installing-kibana-macos) +[#]: author: (Lauren Maffeo https://opensource.com/users/lmaffeo) + +如何在 MacOS 上安装 Kibana +====== + +> Elasticsearch 当安装好了之后,Kibana 插件可以为这个功能强大的搜索工具添加可视化功能。 + +![](https://img.linux.net.cn/data/attachment/album/201907/22/204048vl8t88y6q8988229.jpg) + +在我之前的文章中,我向 Mac 用户介绍了[安装 Elasticsearch][2] 的步骤,这是世界上最受欢迎的企业级搜索引擎。(这里有一篇针对 Linux 用户的[单独文章][3]。)其自然语言处理能力使得 Elasticsearch 在数据集中查找细节方面表现出色。一旦你发现了你需要的数据,如果你已经安装了 [Kibana][4],你可以将它提升到一个新的水平。 + +Kibana 是 Elasticsearch 的开源的数据可视化插件。当你在 Elasticsearch 中找到了数据,Kibana 就会帮助你将其放入折线图、[时间序列查询][5]、地理空间地图等。该工具非常适合于必须展示其研究成果的数据科学家,尤其是那些使用开源数据的人。 + +### 安装 Kibana + +你需要在 Elasticsearch 之外单独安装 Kibana。因为我安装了 Elasticsearch 7.1.1,所以我将安装 Kibana 1.1。版本的匹配非常重要,Kibana 需要针对相同版本的 Elasticsearch 节点运行。 (Kibana 运行在 node.js 上。) + +以下是我为 MacOS 安装 Kibana 7.1.1 时所遵循的步骤: + +1、确保 Elasticsearch 已下载并运行。如果需要,请参阅上一篇文章。 + +**注意**:你至少需要先安装 Elasticsearch 1.4.4 或更高版本才能使用 Kibana。这是因为你需要向 Kibana 提供要连接的 Elasticsearch 实例的 URL 以及你要搜索的 Elasticsearch 索引。通常,最好安装两者的最新版本。 + +2、单击[此处][6]下载 Kibana。你将看到如下的网页,它会提示你在**下载**部分的右上角下载 Kibana for Mac: + +![Download Kibana here.][7] + +3、在你的 `Downloads` 文件夹中,打开 .tar 文件以展开它。此操作将创建一个具有相同名称的文件夹(例如,`kibana-7.1.1-darwin-x86_64`)。 + +4、如果你希望 Kibana 放在另一个文件夹中,请立即移动它。 + +仔细检查 Elasticsearch 是否正在运行,如果没有,请在继续之前启动它。(如果你需要说明,请参阅上一篇文章。) + +### 打开 Kibana 插件 + +Elasticsearch 运行起来后,你现在可以启动 Kibana 了。该过程类似于启动 Elasticsearch: + +1、从 Mac 的 `Downloads` 文件夹(或 Kibana 移动到的新文件夹)里,打开 Kibana 文件夹(即 `~Downloads/kibana-7.1.1-darwin-x86_64`)。 + +2、打开 `bin` 子文件夹。 + +![The Kibana bin folder.][8] + +3、运行 `kibana-plugin`。你可能会遇到上一篇文章中出现的相同安全警告: +   +![Security warning][9] + +通常,如果收到此警告,请按照那篇文章中的说明清除警告并打开 Kibana。请注意,如果我在终端中没有运行 Elasticsearch 的情况下打开该插件,我会收到相同的安全警告。要解决此问题,如上一篇文章中所述,打开 Elasticsearch 并在终端中运行它。使用 GUI 启动 Elasticsearch 也应该打开终端。 + +然后,我右键单击 `kibana-plugin` 并选择“打开”。这个解决方案对我有用,但你可能需要尝试几次。 我的 Elasticsearch 聚会中的几个人在他们的设备上打开 Kibana 时遇到了一些麻烦。 + +### 更改 Kibana 的主机和端口号 + +Kibana 的默认设置将其配置为在 `localhost:5601` 上运行。你需要更新文件(在这个例子的情况下)`~Downloads/kibana-7.1.1-darwin-x86_64/config/kibana.yml` 以在运行 Kibana 之前更改主机或端口号。 + +![The Kibana config directory.][10] + +以下是我的 Elasticsearch 聚会组里配置 Kibana 时终端的样子,因此默认为 `http://localhost:9200`,这是查询 Elasticsearch 实例时使用的 URL: + +![Configuring Kibana's host and port connections.][11] + +### 从命令行运行 Kibana + +打开插件后,可以从命令行或 GUI 运行 Kibana。这是终端连接到 Elasticsearch 后的样子: + +![Kibana running once it's connected to Elasticsearch.][12] + +与 Elasticsearch 一样,Kibana 默认在前台运行。你可以按 `Ctrl-C` 来停止它。 + +### 总结 + +Elasticsearch 和 Kibana 是占用大量存储空间的大型软件包。有这么多人一次下载这两个软件包,当我的Elasticsearch 会员和我下载它们两个时,我平均要下载几分钟。这可能是由于 WiFi 不佳和/或用户数量太多,但如果发生同样的事情,请记住这种可能性。 + +之后,由于我的笔记本电脑存储空间不足,我无法上传我们正在使用的 JSON 文件。我能够按照讲师的可视化进行操作,但无法实时使用 Kibana。因此,在下载 Elasticsearch 和 Kibana 之前,请确保设备上有足够的空间(至少几千兆字节)来上传和使用这些工具搜索文件。 + +要了解有关 Kibana 的更多信息,他们的用户指南[简介][13]是理想的。(你可以根据你正在使用的 Kibana 版本配置该指南。)他们的演示还向你展示了如何[在几分钟内构建仪表板][14],然后进行首次部署。 + +玩得开心! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/installing-kibana-macos + +作者:[Lauren Maffeo][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lmaffeo +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/analytics-graphs-charts.png?itok=sersoqbV (Analytics: Charts and Graphs) +[2]: https://linux.cn/article-11125-1.html +[3]: https://opensource.com/article/19/7/installing-elasticsearch-and-kibana-linux +[4]: https://www.elastic.co/products/kibana +[5]: https://en.wikipedia.org/wiki/Time_series +[6]: https://www.elastic.co/downloads/kibana +[7]: https://opensource.com/sites/default/files/uploads/download_kibana.png (Download Kibana here.) +[8]: https://opensource.com/sites/default/files/uploads/kibana_bin_folder.png (The Kibana bin folder.) +[9]: https://opensource.com/sites/default/files/uploads/security_warning.png (Security warning) +[10]: https://opensource.com/sites/default/files/uploads/kibana_config_directory.png (The Kibana config directory.) +[11]: https://opensource.com/sites/default/files/uploads/kibana_host_port_config.png (Configuring Kibana's host and port connections.) +[12]: https://opensource.com/sites/default/files/uploads/kibana_running.png (Kibana running once it's connected to Elasticsearch.) +[13]: https://www.elastic.co/guide/en/kibana/7.2/introduction.html +[14]: https://www.elastic.co/webinars/getting-started-kibana?baymax=rtp&elektra=docs&storm=top-video&iesrc=ctr diff --git a/published/201907/20190717 Mastering user groups on Linux.md b/published/201907/20190717 Mastering user groups on Linux.md new file mode 100644 index 0000000000..99c57b5d45 --- /dev/null +++ b/published/201907/20190717 Mastering user groups on Linux.md @@ -0,0 +1,219 @@ +[#]: collector: (lujun9972) +[#]: translator: (0x996) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11148-1.html) +[#]: subject: (Mastering user groups on Linux) +[#]: via: (https://www.networkworld.com/article/3409781/mastering-user-groups-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +掌握 Linux 用户组 +====== + +> 在 Linux 系统中管理用户组并不费力,但相关命令可能比你所知的更为灵活。 + +![Scott 97006 \(CC BY 2.0\)][1] + +在 Linux 系统中用户组起着重要作用。用户组提供了一种简单方法供一组用户互相共享文件。用户组也允许系统管理员更加有效地管理用户权限,因为管理员可以将权限分配给用户组而不是逐一分配给单个用户。 + +尽管通常只要在系统中添加用户账户就会创建用户组,关于用户组如何工作以及如何运用用户组还有很多需要了解的。 + +### 一个用户一个用户组? + +Linux 系统中多数用户账户被设为用户名与用户组名相同。用户 `jdoe` 会被赋予一个名为 `jdoe` 的用户组,且成为该新建用户组的唯一成员。如本例所示,该用户的登录名,用户 id 和用户组 id 在新建账户时会被添加到 `/etc/passwd` 和 `/etc/group` 文件中: + +``` +$ sudo useradd jdoe +$ grep jdoe /etc/passwd +jdoe:x:1066:1066:Jane Doe:/home/jdoe:/bin/sh +$ grep jdoe /etc/group +jdoe:x:1066: +``` + +这些文件中的配置使系统得以在文本(`jdoe`)和数字(`1066`)这两种用户 id 形式之间互相转换—— `jdoe` 就是 `1006`,且 `1006` 就是 `jdoe`。 + +分配给每个用户的 UID(用户 id)和 GID(用户组 id)通常是一样的,并且顺序递增。若上例中 Jane Doe 是最近添加的用户,分配给下一个新用户的用户 id 和用户组 id 很可能都是 1067。 + +### GID = UID? + +UID 和 GID 可能不一致。例如,如果你用 `groupadd` 命令添加一个用户组而不指定用户组 id,系统会分配下一个可用的用户组 id(在本例中为 1067)。下一个添加到系统中的用户其 UID 会是 1067 而 GID 则为 1068。 + +你可以避免这个问题,方法是添加用户组的时候指定一个较小的用户组 id 而不是接受默认值。在下面的命令中我们添加一个用户组并提供一个 GID,这个 GID 小于用于用户账户的 GID 取值范围。 + +``` +$ sudo groupadd -g 500 devops +``` + +创建账户时你可以指定一个共享用户组,如果这样对你更合适的话。例如你可能想把新来的开发人员加入同一个 DevOps 用户组而不是一人一个用户组。 + +``` +$ sudo useradd -g staff bennyg +$ grep bennyg /etc/passwd +bennyg:x:1064:50::/home/bennyg:/bin/sh +``` + +### 主要用户组和次要用户组 + +用户组实际上有两种:主要用户组primary group次要用户组secondary group。 + +主要用户组是保存在 `/etc/passwd` 文件中的用户组,该用户组在账户创建时配置。当用户创建一个文件时,用户的主要用户组与此文件关联。 + +``` +$ whoami +jdoe +$ grep jdoe /etc/passwd +jdoe:x:1066:1066:John Doe:/home/jdoe:/bin/bash + ^ + | + +-------- 主要用户组 +$ touch newfile +$ ls -l newfile +-rw-rw-r-- 1 jdoe jdoe 0 Jul 16 15:22 newfile + ^ + | + +-------- 主要用户组 +``` + +用户一旦拥有账户之后被加入的那些用户组是次要用户组。次要用户组成员关系在 `/etc/group` 文件中显示。 + +``` +$ grep devops /etc/group +devops:x:500:shs,jadep + ^ + | + +-------- shs 和 jadep 的次要用户组 +``` + +`/etc/group` 文件给用户组分配组名称(例如 `500` = `devops`)并记录次要用户组成员。 + +### 首选的准则 + +每个用户是他自己的主要用户组成员,并可以成为任意多个次要用户组成员,这样的一种准则允许用户更加容易地将个人文件和需要与同事分享的文件分开。当用户创建一个文件时,用户所属的不同用户组的成员不一定有访问权限。用户必须用 `chgrp` 命令将文件和次要用户组关联起来。 + +### 哪里也不如自己的家目录 + +添加新账户时一个重要的细节是 `useradd` 命令并不一定为新用户添加一个家目录/home家目录。若你只有某些时候想为用户添加家目录,你可以在 `useradd` 命令中加入 `-m` 选项(可以把它想象成“安家”选项)。 + +``` +$ sudo useradd -m -g devops -c "John Doe" jdoe2 +``` + +此命令中的选项如下: + +* `-m` 创建家目录并在其中生成初始文件 +* `-g` 指定用户归属的用户组 +* `-c` 添加账户描述信息(通常是用户的姓名) + +若你希望总是创建家目录,你可以编辑 `/etc/login.defs` 文件来更改默认工作方式。更改或添加 `CREATE_HOME` 变量并将其设置为 `yes`: + +``` +$ grep CREATE_HOME /etc/login.defs +CREATE_HOME yes +``` + +另一种方法是用自己的账户设置别名从而让 `useradd` 一直带有 `-m` 选项。 + +``` +$ alias useradd=’useradd -m’ +``` + +确保将该别名添加到你的 `~/.bashrc` 文件或类似的启动文件中以使其永久生效。 + +### 深入了解 /etc/login.defs + +下面这个命令可列出 `/etc/login.defs` 文件中的全部设置。下面的 `grep` 命令会隐藏所有注释和空行。 + +``` +$ cat /etc/login.defs | grep -v "^#" | grep -v "^$" +MAIL_DIR /var/mail +FAILLOG_ENAB yes +LOG_UNKFAIL_ENAB no +LOG_OK_LOGINS no +SYSLOG_SU_ENAB yes +SYSLOG_SG_ENAB yes +FTMP_FILE /var/log/btmp +SU_NAME su +HUSHLOGIN_FILE .hushlogin +ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games +TTYGROUP tty +TTYPERM 0600 +ERASECHAR 0177 +KILLCHAR 025 +UMASK 022 +PASS_MAX_DAYS 99999 +PASS_MIN_DAYS 0 +PASS_WARN_AGE 7 +UID_MIN 1000 +UID_MAX 60000 +GID_MIN 1000 +GID_MAX 60000 +LOGIN_RETRIES 5 +LOGIN_TIMEOUT 60 +CHFN_RESTRICT rwh +DEFAULT_HOME yes +CREATE_HOME yes <=== +USERGROUPS_ENAB yes +ENCRYPT_METHOD SHA512 +``` + +注意此文件中的各种设置会决定用户 id 的取值范围以及密码使用期限和其他设置(如 umask)。 + +### 如何显示用户所属的用户组 + +出于各种原因用户可能是多个用户组的成员。用户组成员身份给与用户对用户组拥有的文件和目录的访问权限,有时候这种工作方式是至关重要的。要生成某个用户所属用户组的清单,用 `groups` 命令即可。 + +``` +$ groups jdoe +jdoe : jdoe adm admin cdrom sudo dip plugdev lpadmin staff sambashare +``` + +你可以键入不带任何参数的 `groups` 命令来列出你自己的用户组。 + +### 如何添加用户至用户组 + +如果你想添加一个已有用户至别的用户组,你可以仿照下面的命令操作: + +``` +$ sudo usermod -a -G devops jdoe +``` + +你也可以指定逗号分隔的用户组列表来添加一个用户至多个用户组: + +``` +$ sudo usermod -a -G devops,mgrs jdoe +``` + +参数 `-a` 意思是“添加”,`-G` 指定用户组列表。 + +你可以编辑 `/etc/group` 文件将用户名从用户组成员名单中删除,从而将用户从用户组中移除。`usermod` 命令或许也有个选项用于从用户组中删除某个成员。 + +``` +fish:x:16:nemo,dory,shark + | + V +fish:x:16:nemo,dory +``` + +### 提要 + +添加和管理用户组并非特别困难,但长远来看配置账户时的一致性可使这项工作更容易些。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3409781/mastering-user-groups-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[0x996](https://github.com/0x996) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/07/carrots-100801917-large.jpg +[2]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua +[3]: https://www.networkworld.com/article/3391029/must-know-linux-commands.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/201907/20190718 Epic Games Backs Blender Foundation with -1.2m Epic MegaGrants.md b/published/201907/20190718 Epic Games Backs Blender Foundation with -1.2m Epic MegaGrants.md new file mode 100644 index 0000000000..268c9e16ca --- /dev/null +++ b/published/201907/20190718 Epic Games Backs Blender Foundation with -1.2m Epic MegaGrants.md @@ -0,0 +1,98 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11121-1.html) +[#]: subject: (Epic Games Backs Blender Foundation with $1.2m Epic MegaGrants) +[#]: via: (https://itsfoss.com/epic-games-blender-grant/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Epic Games 给予 Blender 基金会 120 万美元的拨款支持 +====== + +[Epic MegaGrants][1] 是 [Epic Games][2] 的一个计划,用于支持游戏开发人员、企业专业人士、内容创建者和工具开发人员使用虚幻引擎Unreal Engine(UE)做出神奇的作品或增强 3D 图形社区的开源功能。 + +作为该计划的一部分,Epic Games 给予 [Blender 基金会][3] 120 万美元拨款以帮助改善他们的发展。如果你还不知道,Blender 是[最好的开源视频编辑][4]之一,特别是以创建专业的 3D 计算机图形而闻名。 + +**Tim Sweeney**(Epic Games 的创始人兼首席执行官)这样评论这笔授予: + +> “开放式工具、库和平台对数字内容生态系统的未来至关重要。……Blender 是艺术社区持久的资源,我们的目标是确保其进步,造福所有创作者。” + +即使这是个好消息,也有人对此不满意。在本文中,我们将看一下得到该拨款后的 Blender 基金会的计划,以及人们对此的看法。 + +### Blender 基金会的改进计划 + +![Image Credit : BlenderNation][5] + +在[新闻稿][6]当中,Blender 基金会提到了如何利用这笔资金以及用于何种目的: + +> “Epic MegaGrant 将在未来三年内逐步交付,并将为 Blender 的专业 Blender 发展计划Professionalizing Blender Development Initiative做出贡献。” + +所以,没错,这笔财务帮助将以现金提供 —— 但是,它要在 3 年内完成。也就是说,我们要期待 Blender 基金会及其软件质量得到重大改进还有很长时间。 + +这是 **Ton Roosendaal**(Blender 基金会的创始人)需要说明的它将如何被利用: + +> “Epic Games 的支持对 Blender 是一个重要里程碑,”Blender 基金会的创始人兼董事长 Ton Roosendaal 说道。“由于这项拨款,我们将对我们的项目组织进行大量投入,以改善支持、协作和代码质量实践。因此,我们期望更多来自该行业的贡献者加入我们的项目。” + +### 为什么人们对此不是很喜欢? + +让我澄清一下,就我个人而言,我不喜欢用 Epic Game 的市场或客户端玩游戏。 + +由于各种原因(功能、隐私等),我更喜欢 [Steam][7] 而不是 Epic Games。 + +Epic Games 被称为游戏社区中的坏人,因为它最近几款游戏专属于其平台 —— 尽管很多人警告用户该平台上的隐私问题。 + +不仅如此,Epic Games 的首席执行官在过去发过这样的推特: + +> 安装 Linux 相当于人们不喜欢美国的政治趋势时就搬到加拿大。 +> +> 不,我们必须为今天的自由而战,如今我们拥有自由。 +> +> - Tim Sweeney(@TimSweeneyEpic)[2018年2月15日][8] + +嗯,这并不直接暗示他讨厌 Linux 或者没有积极推动 Linux 的游戏开发 —— 但是只是因为很多历史情况,人们并不真正信任 Epic Games 的决策。所以,他们并不欣赏与 Blender 基金会的联系(即使这个财务帮助是积极的)。 + +这与财务帮助无关。但是,Epic Games 缺乏良好的声誉(当然是主观的),因此,人们对此的看法是消极的。看看拨款公告后的一些推文: + +> 希望不要走向排它……这可能会破坏你的声誉。 +> +> - Ray(@ Epicshadow1994)[2019年7月15日][9] + +> 我对将来会变成什么样感到怀疑。EPIC 最近一直在采取敌对战术。 +> +> - acrid Heartwood(@acrid_heartwood)[2019年7月15日][10] + +### 总而言之 + +你仍然可以[通过 Lutris 在 Linux 上运行 Epic Games][11],但这是很单薄的非官方尝试。Epic Games 没有表示有兴趣正式支持该项目。 + +所以,很明显不是每个人都信任 Epic Games。因此,这个消息带来了各种消极反应。 + +但是,这笔拨款肯定会帮助 Blender 基金会改善其组织和软件质量。 + +你怎么看待这件事?请在下面的评论中告诉我们您的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/epic-games-blender-grant/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.unrealengine.com/en-US/megagrants +[2]: https://www.epicgames.com/store/en-US/ +[3]: https://www.blender.org/ +[4]: https://itsfoss.com/open-source-video-editors/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/07/epic-games-blender-megagrant.jpg?resize=800%2C450&ssl=1 +[6]: https://www.blender.org/press/epic-games-supports-blender-foundation-with-1-2-million-epic-megagrant/ +[7]: https://itsfoss.com/install-steam-ubuntu-linux/ +[8]: https://twitter.com/TimSweeneyEpic/status/964284402741149698?ref_src=twsrc%5Etfw +[9]: https://twitter.com/Epicshadow1994/status/1150787326626263042?ref_src=twsrc%5Etfw +[10]: https://twitter.com/acrid_heartwood/status/1150789691979030528?ref_src=twsrc%5Etfw +[11]: https://linux.cn/article-10968-1.html diff --git a/published/201907/20190722 How to run virtual machines with virt-manager.md b/published/201907/20190722 How to run virtual machines with virt-manager.md new file mode 100644 index 0000000000..32f1faea08 --- /dev/null +++ b/published/201907/20190722 How to run virtual machines with virt-manager.md @@ -0,0 +1,145 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11151-1.html) +[#]: subject: (How to run virtual machines with virt-manager) +[#]: via: (https://fedoramagazine.org/full-virtualization-system-on-fedora-workstation-30/) +[#]: author: (Marco Sarti https://fedoramagazine.org/author/msarti/) + +如何使用 virt-manager 运行虚拟机 +====== + +![][1] + +在早些年,在同一台笔记本中运行多个操作系统只能双启动。当时,这些操作系统很难同时运行或彼此交互。许多年过去了,在普通的 PC 上,可以通过虚拟化在一个系统中运行另一个系统。 + +最近的 PC 或笔记本(包括价格适中的笔记本电脑)都有硬件虚拟化,可以运行性能接近物理主机的虚拟机。 + +虚拟化因此变得常见,它可以用来测试操作系统、学习新技术、创建自己的家庭云、创建自己的测试环境等等。本文将指导你使用 Fedora 上的 Virt Manager 来设置虚拟机。 + +### 介绍 QEMU/KVM 和 Libvirt + +与所有其他 Linux 系统一样,Fedora 附带了虚拟化扩展支持。它由作为内核模块之一的 KVM(基于内核的虚拟机)提供支持。 + +QEMU 是一个完整的系统仿真器,它可与 KVM 协同工作,允许你使用硬件和外部设备创建虚拟机。 + +最后,[libvirt][2] 能让你管理基础设施的 API 层,即创建和运行虚拟机。 + +这三个技术都是开源的,我们将在 Fedora Workstation 上安装它们。 + +### 安装 + +#### 步骤 1:安装软件包 + +安装是一个相当简单的操作。 Fedora 仓库提供了 “virtualization” 软件包组,其中包含了你需要的所有包。 + +``` +sudo dnf install @virtualization +``` + +#### 步骤 2:编辑 libvirtd 配置 + +默认情况下,系统管理仅限于 root 用户,如果要启用常规用户,那么必须按以下步骤操作。 + +打开 `/etc/libvirt/libvirtd.conf` 进行编辑: + +``` +sudo vi /etc/libvirt/libvirtd.conf +``` + +将 UNIX 域套接字组所有者设置为 libvirt: + +``` +unix_sock_group = "libvirt" +``` + +调整 UNIX 域套接字的读写权限: + +``` +unix_sock_rw_perms = "0770" +``` + +#### 步骤 3:启动并启用 libvirtd 服务 + +``` +sudo systemctl start libvirtd +sudo systemctl enable libvirtd +``` + +#### 步骤 4:将用户添加到组 + +为了管理 libvirt 与普通用户,你必须将用户添加到 `libvirt` 组,否则每次启动 `virt-manager` 时,都会要求你输入 sudo 密码。 + +``` +sudo usermod -a -G libvirt $(whoami) +``` + +这会将当前用户添加到组中。你必须注销并重新登录才能应用更改。 + +### 开始使用 virt-manager + +可以通过命令行 (`virsh`) 或通过 `virt-manager` 图形界面管理 libvirt 系统。如果你想做虚拟机自动化配置,那么命令行非常有用,例如使用 [Ansible][3],但在本文中我们将专注于用户友好的图形界面。 + +`virt-manager` 界面很简单。主窗口显示连接列表,其中包括本地系统连接。 + +连接设置包括虚拟网络和存储定义。你可以定义多个虚拟网络,这些网络可用于在客户端系统之间以及客户端系统和主机之间进行通信。 + +### 创建你的第一个虚拟机 + +要开始创建新虚拟机,请按下主窗口左上角的按钮: + +![][4] + +向导的第一步需要选择安装模式。你可以选择本地安装介质、网络引导/安装或导入现有虚拟磁盘: + +![][5] + +选择本地安装介质,下一步将需要选择 ISO 镜像路径: + +![ ][6] + +随后的两个步骤能让你调整新虚拟机的 CPU、内存和磁盘大小。最后一步将要求你选择网络选项:如果你希望虚拟机通过 NAT 与外部隔离,请选择默认网络。如果你希望从外部访问虚拟机,那么选择桥接。请注意,如果选择桥接,那么虚拟机则无法与主机通信。 + +如果要在启动设置之前查看或更改配置,请选中“安装前自定义配置”: + +![][7] + +虚拟机配置窗口能让你查看和修改硬件配置。你可以添加磁盘、网络接口、更改引导选项等。满意后按“开始安装”: + +![][8] + +此时,你将被重定向到控制台来继续安装操作系统。操作完成后,你可以从控制台访问虚拟机: + +![][9] + +刚刚创建的虚拟机将出现在主窗口的列表中,你还能看到 CPU 和内存占用率的图表: + +![][10] + +libvirt 和 `virt-manager` 是功能强大的工具,它们可以以企业级管理为你的虚拟机提供出色的自定义。如果你需要更简单的东西,请注意 Fedora Workstation [预安装的 GNOME Boxes 已经能够满足基础的虚拟化要求][11]。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/full-virtualization-system-on-fedora-workstation-30/ + +作者:[Marco Sarti][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/msarti/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/07/virt-manager-816x346.jpg +[2]: https://libvirt.org/ +[3]: https://fedoramagazine.org/get-the-latest-ansible-2-8-in-fedora/ +[4]: https://fedoramagazine.org/wp-content/uploads/2019/07/Screenshot-from-2019-07-14-09-41-45.png +[5]: https://fedoramagazine.org/wp-content/uploads/2019/07/Screenshot-from-2019-07-14-09-30-53.png +[6]: https://fedoramagazine.org/wp-content/uploads/2019/07/Screenshot-from-2019-07-14-10-42-39.png +[7]: https://fedoramagazine.org/wp-content/uploads/2019/07/Screenshot-from-2019-07-14-10-43-21.png +[8]: https://fedoramagazine.org/wp-content/uploads/2019/07/Screenshot-from-2019-07-14-10-44-58.png +[9]: https://fedoramagazine.org/wp-content/uploads/2019/07/Screenshot-from-2019-07-14-10-55-35.png +[10]: https://fedoramagazine.org/wp-content/uploads/2019/07/Screenshot-from-2019-07-14-11-09-22.png +[11]: https://fedoramagazine.org/getting-started-with-virtualization-in-gnome-boxes/ diff --git a/published/201907/20190723 Getting help for Linux shell built-ins.md b/published/201907/20190723 Getting help for Linux shell built-ins.md new file mode 100644 index 0000000000..490de661c7 --- /dev/null +++ b/published/201907/20190723 Getting help for Linux shell built-ins.md @@ -0,0 +1,218 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11158-1.html) +[#]: subject: (Getting help for Linux shell built-ins) +[#]: via: (https://www.networkworld.com/article/3410350/getting-help-for-linux-shell-built-ins.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +获取有关 Linux shell 内置命令的帮助 +====== + +> Linux 内置命令属于用户 shell 的一部分,本文将告诉你如何识别它们并获取使用它们的帮助。 + +![](https://img.linux.net.cn/data/attachment/album/201907/28/204915bj1wmhxeargx14lt.jpg) + +Linux 内置命令是内置于 shell 中的命令,很像内置于墙中的书架。与标准 Linux 命令存储在 `/usr/bin` 中的方式不同,你不会找到它们的独立文件,你可能使用过相当多的内置命令,但你不会感觉到它们与 `ls` 和 `pwd` 等命令有何不同。 + +内置命令与其他 Linux 命令一样使用,它们可能要比不属于 shell 的类似命令运行得快一些。Bash 内置命令包括 `alias`、`export` 和 `bg` 等。 + +正如你担心的那样,因为内置命令是特定于 shell 的,所以它们不会提供手册页。使用 `man` 来查看 `bg`,你会看到这样的东西: + +``` +$ man bg +No manual entry for bg +``` + +判断内置命令的另一个提示是当你使用 `which` 命令来识别命令的来源时,Bash 不会响应,表示没有与内置命令关联的文件: + +``` +$ which bg +$ +``` + +另一方面,如果你的 shell 是 `/bin/zsh`,你可能会得到一个更有启发性的响应: + +``` +% which bg +bg: shell built-in command +``` + +bash 提供了额外的帮助信息,但它是通过使用 `help` 命令实现的: + +``` +$ help bg +bg: bg [job_spec ...] + Move jobs to the background. + + Place the jobs identified by each JOB_SPEC in the background, as if they + had been started with `&'. If JOB_SPEC is not present, the shell's notion + of the current job is used. + + Exit Status: + Returns success unless job control is not enabled or an error occurs. +``` + +如果你想要查看 bash 提供的所有内置命令的列表,使用 `compgen -b` 命令。通过管道将命令输出到列中,以获得较好格式的清单。 + +``` +$ compgen -b | column +. compgen exit let return typeset +: complete export local set ulimit +[ compopt false logout shift umask +alias continue fc mapfile shopt unalias +bg declare fg popd source unset +bind dirs getopts printf suspend wait +break disown hash pushd test +builtin echo help pwd times +caller enable history read trap +cd eval jobs readarray true +command exec kill readonly type +``` + +如果你使用 `help` 命令,你将看到一个内置命令列表以及简短描述。但是,这个列表被截断了(以 `help` 命令结尾): + +``` +$ help +GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu) +These shell commands are defined internally. Type `help' to see this list. +Type `help name' to find out more about the function `name'. +Use `info bash' to find out more about the shell in general. +Use `man -k' or `info' to find out more about commands not in this list. + +A star (*) next to a name means that the command is disabled. + + job_spec [&] history [-c] [-d offset] [n] or histo> + (( expression )) if COMMANDS; then COMMANDS; [ elif CO> + . filename [arguments] jobs [-lnprs] [jobspec ...] or jobs -> + : kill [-s sigspec | -n signum | -sigsp> + [ arg... ] let arg [arg ...] + [[ expression ]] local [option] name[=value] ... + alias [-p] [name[=value] ... ] logout [n] + bg [job_spec ...] mapfile [-d delim] [-n count] [-O ori> + bind [-lpsvPSVX] [-m keymap] [-f filen> popd [-n] [+N | -N] + break [n] printf [-v var] format [arguments] + builtin [shell-builtin [arg ...]] pushd [-n] [+N | -N | dir] + caller [expr] pwd [-LP] + case WORD in [PATTERN [| PATTERN]...) > read [-ers] [-a array] [-d delim] [-i> + cd [-L|[-P [-e]] [-@]] [dir] readarray [-d delim] [-n count] [-O o> + command [-pVv] command [arg ...] readonly [-aAf] [name[=value] ...] or> + compgen [-abcdefgjksuv] [-o option] [-> return [n] + complete [-abcdefgjksuv] [-pr] [-DEI] > select NAME [in WORDS ... ;] do COMMA> + compopt [-o|+o option] [-DEI] [name ..> set [-abefhkmnptuvxBCHP] [-o option-n> + continue [n] shift [n] + coproc [NAME] command [redirections] shopt [-pqsu] [-o] [optname ...] + declare [-aAfFgilnrtux] [-p] [name[=va> source filename [arguments] + dirs [-clpv] [+N] [-N] suspend [-f] + disown [-h] [-ar] [jobspec ... | pid . <p>'> test [expr] + echo [-neE] [arg ...] time [-p] pipeline + enable [-a] [-dnps] [-f filename] [nam> times + eval [arg ...] trap [-lp] [[arg] signal_spec ...] + exec [-cl] [-a name] [command [argumen> true + exit [n] type [-afptP] name [name ...] + export [-fn] [name[=value] ...] or exp> typeset [-aAfFgilnrtux] [-p] name[=va> + false ulimit [-SHabcdefiklmnpqrstuvxPT] [li> + fc [-e ename] [-lnr] [first] [last] or> umask [-p] [-S] [mode] + fg [job_spec] unalias [-a] name [name ...] + for NAME [in WORDS ... ] ; do COMMANDS> unset [-f] [-v] [-n] [name ...] + for (( exp1; exp2; exp3 )); do COMMAND> until COMMANDS; do COMMANDS; done + function name { COMMANDS ; } or name (> variables - Names and meanings of som> + getopts optstring name [arg] wait [-fn] [id ...] + hash [-lr] [-p pathname] [-dt] [name .> while COMMANDS; do COMMANDS; done + help [-dms] [pattern ...] { COMMANDS ; } +``` + +从上面的清单中可以看出,`help` 命令本身就是内置的。 + +你可以通过向 `help` 命令提供你感兴趣的内置命令名称来获取关于它们的更多信息,例如 `help dirs`: + +``` +$ help dirs +dirs: dirs [-clpv] [+N] [-N] + Display directory stack. + + Display the list of currently remembered directories. Directories + find their way onto the list with the `pushd' command; you can get + back up through the list with the `popd' command. + + Options: + -c clear the directory stack by deleting all of the elements + -l do not print tilde-prefixed versions of directories relative + to your home directory + -p print the directory stack with one entry per line + -v print the directory stack with one entry per line prefixed + with its position in the stack + + Arguments: + +N Displays the Nth entry counting from the left of the list + shown by dirs when invoked without options, starting with + zero. + + -N Displays the Nth entry counting from the right of the list + shown by dirs when invoked without options, starting with + zero. + + Exit Status: + Returns success unless an invalid option is supplied or an error occurs. +``` + +内置命令提供了每个 shell 的大部分功能。你使用的任何 shell 都有一些内置命令,但是如何获取这些内置命令的信息可能因 shell 而异。例如,对于 `zsh`,你可以使用 `man zshbuiltins` 命令获得其内置命令的描述。 + +``` +$ man zshbuiltins + +ZSHBUILTINS(1) General Commands Manual ZSHBUILTINS(1) + +NAME + zshbuiltins - zsh built-in commands + +SHELL BUILTIN COMMANDS + Some shell builtin commands take options as described in individual en‐ + tries; these are often referred to in the list below as `flags' to avoid + confusion with shell options, which may also have an effect on the behav‐ + iour of builtin commands. In this introductory section, `option' always + has the meaning of an option to a command that should be familiar to most + command line users. +… +``` + +在这个冗长的手册页中,你将找到一个内置命令列表,其中包含有用的描述,如下摘录中所示: + +``` +bg [ job ... ] +job ... & + Put each specified job in the background, or the current job if + none is specified. + +bindkey + See the section `Zle Builtins' in zshzle(1). + +break [ n ] + Exit from an enclosing for, while, until, select or repeat loop. + If an arithmetic expression n is specified, then break n levels + instead of just one. +``` + +### 最后 + +Linux 内置命令对于每个 shell 都很重要,它的操作类似特定于 shell 的命令一样。如果你经常使用不同的 shell,并注意到你经常使用的某些命令似乎不存在或者不能按预期工作,那么它可能是你使用的其他 shell 之一中的内置命令。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3410350/getting-help-for-linux-shell-built-ins.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/07/linux_penguin-100802549-large.jpg +[2]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua +[3]: https://www.networkworld.com/article/3242170/linux/invaluable-tips-and-tricks-for-troubleshooting-linux.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/201907/20190723 How to Create a User Account Without useradd Command in Linux.md b/published/201907/20190723 How to Create a User Account Without useradd Command in Linux.md new file mode 100644 index 0000000000..3bc9a26c39 --- /dev/null +++ b/published/201907/20190723 How to Create a User Account Without useradd Command in Linux.md @@ -0,0 +1,112 @@ +[#]: collector: "lujun9972" +[#]: translator: "hello-wn" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11156-1.html" +[#]: subject: "How to Create a User Account Without useradd Command in Linux?" +[#]: via: "https://www.2daygeek.com/linux-user-account-creation-in-manual-method/" +[#]: author: "Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/" + +在 Linux 中不使用 useradd 命令如何创建用户账号 +======== + +Linux 中有三个命令可以用来创建用户账号。你尝试过在 Linux 中手动创建用户吗?我的意思是不使用上面说的三个命令。 + +如果你不知道怎么做,本文可以手把手教你,并向你展示细节部分。 + +你可能想,这怎么可能?别担心,正如我们多次提到的那样,在 Linux 上任何事都可以搞定。这只是其中一例。 + +是的,我们可以做到的。想了解更多吗? + +- [在 Linux 中创建用户的三种方法][1] +- [在 Linux 中批量创建用户的两种方法][2] + +话不多说,让我们开始吧。 + +首先,我们要找出最后创建的 UID 和 GID 信息。 掌握了这些信息之后,就可以继续下一步。 + +``` +# cat /etc/passwd | tail -1 +tuser1:x:1153:1154:Test User:/home/tuser1:/bin/bash +``` + +根据以上输出,最后创建的用户 UID 是 1153,GID 是 1154。为了试验,我们将在系统中添加 `tuser2` 用户。 + +现在,在`/etc/passwd` 文件中添加一条用户信息。 总共七个字段,你需要添加一些必要信息。 + +``` ++-----------------------------------------------------------------------+ +|username:password:UID:GID:Comments:User Home Directory:User Login Shell| ++-----------------------------------------------------------------------+ + | | | | | | | + 1 2 3 4 5 6 7 +``` + +1. 用户名:这个字段表示用户名称。字符长度必须在 1 到 32 之间。 +2. 密码(`x`):表示存储在 `/etc/shadow` 文件中的加密密码。 +3. 用户 ID:表示用户的 ID(UID),每个用户都有独一无二的 UID。UID 0 保留给 root 用户,UID 1-99 保留给系统用户,UID 100-999 保留给系统账号/组。 +4. 组 ID:表示用户组的 ID(GID),每个用户组都有独一无二的 GID,存储在 `/etc/group` 文件中。 +5. 注释/用户 ID 信息:这个字段表示备注,用于描述用户信息。 +6. 主目录(`/home/$USER`):表示用户的主目录。 +7. shell(`/bin/bash`):表示用户使用的 shell。 + +在文件最后添加用户信息。 + +``` +# vi /etc/passwd + +tuser2:x:1154:1155:Test User2:/home/tuser2:/bin/bash +``` + +你需要创建相同名字的用户组。同样地,在 `/etc/group` 文件中添加用户组信息。 + +``` +# vi /etc/group + +tuser2:x:1155: +``` + +做完以上两步之后,给用户设置一个密码。 + +``` +# passwd tuser2 + +Changing password for user tuser2. +New password: +Retype new password: +passwd: all authentication tokens updated successfully. +``` + +最后,试着登录新创建的用户。 + +``` +# ssh [email protected] + +[email protected]'s password: +Creating directory '/home/tuser2'. + +$ls -la + +total 16 +drwx------. 2 tuser2 tuser2 59 Jun 17 09:46 . +drwxr-xr-x. 15 root root 4096 Jun 17 09:46 .. +-rw-------. 1 tuser2 tuser2 18 Jun 17 09:46 .bash_logout +-rw-------. 1 tuser2 tuser2 193 Jun 17 09:46 .bash_profile +-rw-------. 1 tuser2 tuser2 231 Jun 17 09:46 .bashrc +``` + +------ + +via: https://www.2daygeek.com/linux-user-account-creation-in-manual-method/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[hello-wn](https://github.com/hello-wn) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/linux-user-account-creation-useradd-adduser-newusers/ +[2]: https://www.2daygeek.com/linux-bulk-users-creation-useradd-newusers/ diff --git a/published/201907/20190724 Master the Linux -ls- command.md b/published/201907/20190724 Master the Linux -ls- command.md new file mode 100644 index 0000000000..3744fa3906 --- /dev/null +++ b/published/201907/20190724 Master the Linux -ls- command.md @@ -0,0 +1,328 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11159-1.html) +[#]: subject: (Master the Linux 'ls' command) +[#]: via: (https://opensource.com/article/19/7/master-ls-command) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +精通 Linux 的 ls 命令 +====== + +> Linux 的 ls 命令拥有数量惊人的选项,可以提供有关文件的重要信息。 + +![](https://img.linux.net.cn/data/attachment/album/201907/29/105754ii3874q2ww7lo882.jpg) + +`ls` 命令可以列出一个 [POSIX][2] 系统上的文件。这是一个简单的命令,但它经常被低估,不是它能做什么(因为它确实只做了一件事),而是你该如何优化对它的使用。 + +要知道在最重要的 10 个终端命令中,这个简单的 `ls` 命令可以排进前三,因为 `ls` 不会*只是*列出文件,它还会告诉你有关它们的重要信息。它会告诉你诸如拥有文件或目录的人、每个文件修改的时间、甚至是什么类型的文件。它的附带功能能让你了解你在哪里、附近有些什么,以及你可以用它们做什么。 + +如果你对 `ls` 的体验仅限于你的发行版在 `.bashrc` 中的别名,那么你可能错失了它。 + +### GNU 还是 BSD? + +在了解 `ls` 的隐藏能力之前,你必须确定你正在运行哪个 `ls` 命令。有两个最流行的版本:包含在 GNU coreutils 包中的 GNU 版本,以及 BSD 版本。如果你正在运行 Linux,那么你很可能已经安装了 GNU 版本的 `ls`(LCTT 译注:几乎可以完全确定)。如果你正在运行 BSD 或 MacOS,那么你有的是 BSD 版本。本文会介绍它们的不同之处。 + +你可以使用 `--version` 选项找出你计算机上的版本: + +``` +$ ls --version +``` + +如果它返回有关 GNU coreutils 的信息,那么你拥有的是 GNU 版本。如果它返回一个错误,你可能正在运行的是 BSD 版本(运行 `man ls | head` 以确定)。 + +你还应该调查你的发行版可能具有哪些预设选项。终端命令的自定义通常放在 `$HOME/.bashrc` 或 `$HOME/.bash_aliases` 或 `$HOME/.profile` 中,它们是通过将 `ls` 别名化为更复杂的 `ls` 命令来完成的。例如: + +``` +alias ls='ls --color' +``` + +发行版提供的预设非常有用,但它们确实很难分辨出哪些是 `ls` 本身的特性,哪些是它的附加选项提供的。你要是想要运行 `ls` 命令本身而不是它的别名,你可以用反斜杠“转义”命令: + +``` +$ \ls +``` + +### 分类 + +单独运行 `ls` 会以适合你终端的列数列出文件: + +``` +$ ls ~/example +bunko        jdk-10.0.2 +chapterize   otf2ttf.ff +despacer     overtar.sh +estimate.sh  pandoc-2.7.1 +fop-2.3      safe_yaml +games        tt +``` + +这是有用的信息,但所有这些文件看起来基本相同,没有方便的图标来快速表示出哪个是目录、文本文件或图像等等。 + +使用 `-F`(或 GNU 上的长选项 `--classify`)以在每个条目之后显示标识文件类型的指示符: + +``` +$ ls ~/example +bunko         jdk-10.0.2/ +chapterize*   otf2ttf.ff* +despacer*     overtar.sh* +estimate.sh   pandoc@ +fop-2.3/      pandoc-2.7.1/ +games/        tt* +``` + +使用此选项,终端中列出的项目使用简写符号来按文件类型分类: + +* 斜杠(`/`)表示目录(或“文件夹”)。 +* 星号(`*`)表示可执行文件。这包括二进制文件(编译代码)以及脚本(具有[可执行权限][3]的文本文件)。 +* 符号(`@`)表示符号链接(或“别名”)。 +* 等号(`=`)表示套接字。 +* 在 BSD 上,百分号(`%`)表示涂改whiteout(某些文件系统上的文件删除方法)。 +* 在 GNU 上,尖括号(`>`)表示door([Illumos][4] 和 Solaris上的进程间通信)。 +* 竖线(`|`)表示 [FIFO][5] 管道。 +   +这个选项的一个更简单的版本是 `-p`,它只区分文件和目录。 + +(LCTT 译注:在支持彩色的终端上,使用 `--color` 选项可以以不同的颜色来区分文件类型,但要注意如果将输出导入到管道中,则颜色消失。) + +### 长列表 + +从 `ls` 获取“长列表”的做法是如此常见,以至于许多发行版将 `ll` 别名为 `ls -l`。长列表提供了许多重要的文件属性,例如权限、拥有每个文件的用户、文件所属的组、文件大小(以字节为单位)以及文件上次更改的日期: + +``` +$ ls -l +-rwxrwx---. 1 seth users         455 Mar  2  2017 estimate.sh +-rwxrwxr-x. 1 seth users         662 Apr 29 22:27 factorial +-rwxrwx---. 1 seth users    20697793 Jun 29  2018 fop-2.3-bin.tar.gz +-rwxrwxr-x. 1 seth users        6210 May 22 10:22 geteltorito +-rwxrwx---. 1 seth users         177 Nov 12  2018 html4mutt.sh +[...] +``` + +如果你不想以字节为单位,请添加 `-h` 标志(或 GNU 中的 `--human`)以将文件大小转换为更加人性化的表示方法: + +``` +$ ls --human +-rwxrwx---. 1 seth users    455 Mar  2  2017 estimate.sh +-rwxrwxr-x. 1 seth seth     662 Apr 29 22:27 factorial +-rwxrwx---. 1 seth users    20M Jun 29  2018 fop-2.3-bin.tar.gz +-rwxrwxr-x. 1 seth seth    6.1K May 22 10:22 geteltorito +-rwxrwx---. 1 seth users    177 Nov 12  2018 html4mutt.sh +``` + +要看到更少的信息,你可以带有 `-o` 选项只显示所有者的列,或带有 `-g` 选项只显示所属组的列: + +``` +$ ls -o +-rwxrwx---. 1 seth    455 Mar  2  2017 estimate.sh +-rwxrwxr-x. 1 seth    662 Apr 29 22:27 factorial +-rwxrwx---. 1 seth    20M Jun 29  2018 fop-2.3-bin.tar.gz +-rwxrwxr-x. 1 seth   6.1K May 22 10:22 geteltorito +-rwxrwx---. 1 seth    177 Nov 12  2018 html4mutt.sh +``` + +也可以将两个选项组合使用以显示两者。 + +### 时间和日期格式 + +`ls` 的长列表格式通常如下所示: + +``` +-rwxrwx---. 1 seth users         455 Mar  2  2017 estimate.sh +-rwxrwxr-x. 1 seth users         662 Apr 29 22:27 factorial +-rwxrwx---. 1 seth users    20697793 Jun 29  2018 fop-2.3-bin.tar.gz +-rwxrwxr-x. 1 seth users        6210 May 22 10:22 geteltorito +-rwxrwx---. 1 seth users         177 Nov 12  2018 html4mutt.sh +``` + +月份的名字不便于排序,无论是通过计算还是识别(取决于你的大脑是否倾向于喜欢字符串或整数)。你可以使用 `--time-style` 选项和格式名称更改时间戳的格式。可用格式为: + +* `full-iso`:ISO 完整格式(1970-01-01 21:12:00) +* `long-iso`:ISO 长格式(1970-01-01 21:12) +* `iso`:iso 格式(01-01 21:12) +* `locale`:本地化格式(使用你的区域设置) +* `posix-STYLE`:POSIX 风格(用区域设置定义替换 `STYLE`) + +你还可以使用 `date` 命令的正式表示法创建自定义样式。 + +### 按时间排序 + +通常,`ls` 命令按字母顺序排序。你可以使用 `-t` 选项根据文件的最近更改的时间(最新的文件最先列出)进行排序。 + +例如: + +``` +$ touch foo bar baz +$ ls +bar  baz  foo +$ touch foo +$ ls -t +foo bar baz +``` + +### 列出方式 + +`ls` 的标准输出平衡了可读性和空间效率,但有时你需要按照特定方式排列的文件列表。 + +要以逗号分隔文件列表,请使用 `-m`: + +``` +ls -m ~/example +bar, baz, foo +``` + +要强制每行一个文件,请使用 `-1` 选项(这是数字 1,而不是小写的 L): + +``` +$ ls -1 ~/bin/ +bar +baz +foo +``` + +要按文件扩展名而不是文件名对条目进行排序,请使用 `-X`(这是大写 X): + +``` +$ ls +bar.xfc  baz.txt  foo.asc +$ ls -X +foo.asc  baz.txt  bar.xfc +``` + +### 隐藏杂项 + +在某些 `ls` 列表中有一些你可能不关心的条目。例如,元字符 `.` 和 `..` 分别代表“本目录”和“父目录”。如果你熟悉在终端中如何切换目录,你可能已经知道每个目录都将自己称为 `.`,并将其父目录称为 `..`,因此当你使用 `-a` 选项显示隐藏文件时并不需要它经常提醒你。 + +要显示几乎所有隐藏文件(`.` 和 `..` 除外),请使用 `-A` 选项: + +``` +$ ls -a +. +.. +.android +.atom +.bash_aliases +[...] +$ ls -A +.android +.atom +.bash_aliases +[...] +``` + +有许多优秀的 Unix 工具有保存备份文件的传统,它们会在保存文件的名称后附加一些特殊字符作为备份文件。例如,在 Vim 中,备份会以在文件名后附加 `~` 字符的文件名保存。 + +这些类型的备份文件已经多次使我免于愚蠢的错误,但是经过多年享受它们提供的安全感后,我觉得不需要用视觉证据来证明它们存在。我相信 Linux 应用程序可以生成备份文件(如果它们声称这样做的话),我很乐意相信它们存在 —— 而不用必须看到它们。 + +要隐藏备份文件,请使用 `-B` 或 `--ignore-backups` 隐藏常用备份格式(此选项在 BSD 的 `ls` 中不可用): + +``` +$ ls +bar.xfc  baz.txt  foo.asc~  foo.asc +$ ls -B +bar.xfc  baz.txt  foo.asc +``` + +当然,备份文件仍然存在;它只是过滤掉了,你不必看到它。 + +除非另有配置,GNU Emacs 在文件名的开头和结尾添加哈希字符(`#`)来保存备份文件(`#file#`)。其他应用程序可能使用不同的样式。使用什么模式并不重要,因为你可以使用 `--hide` 选项创建自己的排除项: + +``` +$ ls +bar.xfc  baz.txt  #foo.asc#  foo.asc +$ ls --hide="#*#" +bar.xfc  baz.txt  foo.asc +``` + +### 递归地列出目录 + +除非你在指定目录上运行 `ls`,否则子目录的内容不会与 `ls` 命令一起列出: + +``` +$ ls -F +example/  quux*  xyz.txt +$ ls -R +quux  xyz.txt + +./example: +bar.xfc  baz.txt  #foo.asc#  foo.asc +``` + +### 使用别名使其永久化 + +`ls` 命令可能是 shell 会话期间最常使用的命令。这是你的眼睛和耳朵,为你提供上下文信息和确认命令的结果。虽然有很多选项很有用,但 `ls` 之美的一部分就是简洁:两个字符和回车键,你就知道你到底在哪里以及附近有什么。如果你不得不停下思考(更不用说输入)几个不同的选项,它会变得不那么方便,所以通常情况下,即使最有用的选项也不会用了。 + +解决方案是为你的 `ls` 命令添加别名,以便在使用它时,你可以获得最关心的信息。 + +要在 Bash shell 中为命令创建别名,请在主目录中创建名为 `.bash_aliases` 的文件(必须在开头包含 `.`)。 在此文件中,列出要创建的别名,然后是要为其创建别名的命令。例如: + +``` +alias ls='ls -A -F -B --human --color' +``` + +这一行导致你的 Bash shell 将 `ls` 命令解释为 `ls -A -F -B --human --color`。 + +你不必仅限于重新定义现有命令,还可以创建自己的别名: + +``` +alias ll='ls -l' +alias la='ls -A' +alias lh='ls -h' +``` + +要使别名起作用,shell 必须知道 `.bash_aliases` 配置文件存在。在编辑器中打开 `.bashrc` 文件(如果它不存在则创建它),并包含以下代码块: + +``` +if [ -e $HOME/.bash_aliases ]; then +    source $HOME/.bash_aliases +fi +``` + +每次加载 `.bashrc`(这是一个新的 Bash shell 启动的时候),Bash 会将 `.bash_aliases` 加载到你的环境中。你可以关闭并重新启动 Bash 会话,或者直接强制它执行此操作: + +``` +$ source ~/.bashrc +``` + +如果你忘了你是否有别名命令,`which` 命令可以告诉你: + +``` +$ which ls +alias ls='ls -A -F -B --human --color' +        /usr/bin/ls +``` + +如果你将 `ls` 命令别名为带有选项的 `ls` 命令,则可以通过将反斜杠前缀到 `ls` 前来覆盖你的别名。例如,在示例别名中,使用 `-B` 选项隐藏备份文件,这意味着无法使用 `ls` 命令显示备份文件。 可以覆盖该别名以查看备份文件: + +``` +$ ls +bar  baz  foo +$ \ls +bar  baz  baz~  foo +``` + +### 做一件事,把它做好 + +`ls` 命令有很多选项,其中许多是特定用途的或高度依赖于你所使用的终端。在 GNU 系统上查看 `info ls`,或在 GNU 或 BSD 系统上查看 `man ls` 以了解更多选项。 + +你可能会觉得奇怪的是,一个以每个工具“做一件事,把它做好”的前提而闻名的系统会让其最常见的命令背负 50 个选项。但是 `ls` 只做一件事:它列出文件,而这 50 个选项允许你控制接收列表的方式,`ls` 的这项工作做得非常、*非常*好。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/master-ls-command + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sethhttps://opensource.com/users/sambocettahttps://opensource.com/users/scottnesbitthttps://opensource.com/users/sethhttps://opensource.com/users/marcobravohttps://opensource.com/users/sethhttps://opensource.com/users/don-watkinshttps://opensource.com/users/sethhttps://opensource.com/users/jamesfhttps://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/yearbook-haff-rx-linux-file-lead_0.png?itok=-i0NNfDC (Hand putting a Linux file folder into a drawer) +[2]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[3]: https://opensource.com/article/19/6/understanding-linux-permissions +[4]: https://www.illumos.org/ +[5]: https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics) diff --git a/published/201907/20190724 WPS Office on Linux is a Free Alternative to Microsoft Office.md b/published/201907/20190724 WPS Office on Linux is a Free Alternative to Microsoft Office.md new file mode 100644 index 0000000000..1b74136442 --- /dev/null +++ b/published/201907/20190724 WPS Office on Linux is a Free Alternative to Microsoft Office.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11170-1.html) +[#]: subject: (WPS Office on Linux is a Free Alternative to Microsoft Office) +[#]: via: (https://itsfoss.com/wps-office-linux/) +[#]: author: (Sergiu https://itsfoss.com/author/sergiu/) + +WPS Office:Linux 上的 Microsoft Office 的免费替代品 +====== + +> 如果你在寻找 Linux 上 Microsoft Office 免费替代品,那么 WPS Office 是最佳选择之一。它可以免费使用,并兼容 MS Office 文档格式。 + +[WPS Office][1] 是一个跨平台的办公生产力套件。它轻巧,并且与 Microsoft Office、Google Docs/Sheets/Slide 和 Adobe PDF 完全兼容。 + +对于许多用户而言,WPS Office 足够直观,并且能够满足他们的需求。由于它在外观和兼容性方面与 Microsoft Office 非常相似,因此广受欢迎。 + +![WPS Office 2019 All In One Mode][2] + +WPS office 由中国的金山公司创建。对于 Windows 用户而言,WPS Office 有免费版和高级版。对于 Linux 用户,WPS Office 可通过其[社区项目][3]免费获得。 + +> **非 FOSS 警告!** + +> WPS Office 不是一个开源软件。因为它对于 Linux 用户免费使用,我们已经在这介绍过它,有时我们也会介绍即使不是开源的 Linux 软件。 + +### Linux 上的 WPS Office + +![WPS Office in Linux | Image Credit: Ubuntu Handbook][4] + +WPS Office 有四个主要组件: + + * WPS 文字 + * WPS 演示 + * WPS 表格 + * WPS PDF + +WPS Office 与 MS Office 完全兼容,支持 .doc、.docx、.dotx、.ppt、.pptx、.xls、.xlsx、.docm、.dotm、.xml、.txt、.html、.rtf (等其他),以及它自己的格式(.wps、.wpt)。它还默认包含 Microsoft 字体(以确保兼容性),它可以导出 PDF 并提供超过 10 种语言的拼写检查功能。 + +但是,它在 ODT、ODP 和其他开放文档格式方面表现不佳。 + +三个主要的 WPS Office 应用都有与 Microsoft Office 非常相似的界面,都有相同的 Ribbon UI。尽管存在细微差别,但使用习惯仍然相对一致。你可以使用 WPS Office 轻松克隆任何 Microsoft Office/LibreOffice 文档。 + +![WPS Office Writer][5] + +你可能唯一不喜欢的是一些默认的样式设置(一些标题下面有很多空间等),但这些可以很容易地调整。 + +默认情况下,WPS 以 .docx、.pptx 和 .xlsx 文件类型保存文件。你还可以将文档保存到 **[WPS 云][7]**中并与他人协作。另一个不错的功能是能从[这里][8]下载大量模板。 + +### 在 Linux 上安装 WPS Office + +WPS 为 Linux 发行版提供 DEB 和 RPM 安装程序。如果你使用的是 Debian/Ubuntu 或基于 Fedora 的发行版,那么安装 WPS Office 就简单了。 + +你可以在下载区那下载 Linux 中的 WPS: + +- [下载 WPS Office for Linux][9] + +向下滚动,你将看到最新版本包的链接: + +![WPS Office Download][10] + +下载适合你发行版的文件。只需双击 DEB 或者 RPM 就能[安装它们][11]。这会打开软件中心,你将看到安装选项: + +![WPS Office Install Package][12] + +几秒钟后,应用应该成功安装到你的系统上了! + +你现在可以在“应用程序”菜单中搜索 **WPS**,查找 WPS Office 套件中所有的应用: + +![WPS Applications Menu][13] + +### 你是否使用 WPS Office 或其他软件? + +还有其他 [Microsoft Office 的开源替代方案][14],但它们与 MS Office 的兼容性很差。 + +就个人而言,我更喜欢 LibreOffice,但如果你必须要用到 Microsoft Office,你可以尝试在 Linux 上使用 WPS Office。它看起来和 MS Office 类似,并且与 MS 文档格式具有良好的兼容性。它在 Linux 上是免费的,因此你也不必担心 Office 365 订阅。 + +你在系统上使用什么办公套件?你曾经在 Linux 上使用过 WPS Office 吗?你的体验如何? + +---------------------------------------------------------------------------- + +via: https://itsfoss.com/wps-office-linux/ + +作者:[Sergiu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/sergiu/ +[b]: https://github.com/lujun9972 +[1]: https://www.wps.com/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/wps2019-all-in-one-mode.png?resize=800%2C526&ssl=1 +[3]: http://wps-community.org/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/07/wps-2019-Linux.jpg?resize=800%2C450&ssl=1 +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/07/wps-office-writer.png?resize=800%2C454&ssl=1 +[7]: https://account.wps.com/?cb=https%3A%2F%2Fdrive.wps.com%2F +[8]: https://template.wps.com/ +[9]: http://wps-community.org/downloads +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/wps_office_download.jpg?fit=800%2C413&ssl=1 +[11]: https://itsfoss.com/install-deb-files-ubuntu/ +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/wps_office_install_package.png?fit=800%2C719&ssl=1 +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/07/wps_applications_menu.jpg?fit=800%2C355&ssl=1 +[14]: https://itsfoss.com/best-free-open-source-alternatives-microsoft-office/ diff --git a/published/201907/20190725 How to Enable Canonical Kernel Livepatch Service on Ubuntu LTS System.md b/published/201907/20190725 How to Enable Canonical Kernel Livepatch Service on Ubuntu LTS System.md new file mode 100644 index 0000000000..ebda41f03c --- /dev/null +++ b/published/201907/20190725 How to Enable Canonical Kernel Livepatch Service on Ubuntu LTS System.md @@ -0,0 +1,141 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11152-1.html) +[#]: subject: (How to Enable Canonical Kernel Livepatch Service on Ubuntu LTS System?) +[#]: via: (https://www.2daygeek.com/enable-canonical-kernel-livepatch-service-on-ubuntu-lts-system/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +如何在 Ubuntu LTS 系统上启用 Canonical 的内核实时补丁服务 +====== + +![](https://img.linux.net.cn/data/attachment/album/201907/27/072251d3dij23lndtuutzr.jpg) + +Canonical 在 Ubuntu 14.04 LTS 系统中引入了内核实时补丁服务Kernel Livepatch Service。实时补丁服务允许你安装和应用关键的 Linux 内核安全更新,而无需重新启动系统。这意味着,在应用内核补丁程序后,你无需重新启动系统。而通常情况下,我们需要在安装内核补丁后重启 Linux 服务器才能供系统使用。 + +实时修补非常快。大多数内核修复程序只需要几秒钟。Canonical 的实时补丁服务对于不超过 3 个系统的用户无需任何费用。你可以通过命令行在桌面和服务器中启用 Canonical 实时补丁服务。 + +这个实时补丁系统旨在解决高级和关键的 Linux 内核安全漏洞。 + +有关[支持的系统][1]和其他详细信息,请参阅下表。 + +Ubuntu 版本 | 架构 | 内核版本 | 内核变体 +---|---|---|--- +Ubuntu 18.04 LTS | 64-bit x86 | 4.15 | 仅 GA 通用和低电压内核 +Ubuntu 16.04 LTS | 64-bit x86 | 4.4 | 仅 GA 通用和低电压内核 +Ubuntu 14.04 LTS | 64-bit x86 | 4.4 | 仅 Hardware Enablement 内核 + +**注意**:Ubuntu 14.04 中的 Canonical 实时补丁服务 LTS 要求用户在 Trusty 中运行 Ubuntu v4.4 内核。如果你当前没有运行使用该服务,请重新启动到此内核。 + +为此,请按照以下步骤操作。 + +### 如何获取实时补丁令牌? + +导航到 [Canonical 实时补丁服务页面][2],如果要使用免费服务,请选择“Ubuntu 用户”。它适用于不超过 3 个系统的用户。如果你是 “UA 客户” 或多于 3 个系统,请选择 “Ubuntu customer”。最后,单击 “Get your Livepatch token” 按钮。 + +![][4] + +确保你已经在 “Ubuntu One” 中拥有帐号。否则,可以创建一个新的。 + +登录后,你将获得你的帐户密钥。 + +![][5] + +### 在系统中安装 Snap 守护程序 + +实时补丁系统通过快照包安装。因此,请确保在 Ubuntu 系统上安装了 snapd 守护程序。 + +``` +$ sudo apt update +$ sudo apt install snapd +``` + +### 如何系统中安装和配置实时补丁服务? + +通过运行以下命令安装 `canonical-livepatch` 守护程序。 + +``` +$ sudo snap install canonical-livepatch +canonical-livepatch 9.4.1 from Canonical* installed +``` + +运行以下命令以在 Ubuntu 计算机上启用实时内核补丁程序。 + +``` +$ sudo canonical-livepatch enable xxxxc4xxxx67xxxxbxxxxbxxxxfbxx4e + +Successfully enabled device. Using machine-token: xxxxc4xxxx67xxxxbxxxxbxxxxfbxx4e +``` + +运行以下命令查看实时补丁机器的状态。 + +``` +$ sudo canonical-livepatch status + +client-version: 9.4.1 +architecture: x86_64 +cpu-model: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz +last-check: 2019-07-24T12:30:04+05:30 +boot-time: 2019-07-24T12:11:06+05:30 +uptime: 19m11s +status: +- kernel: 4.15.0-55.60-generic + running: true + livepatch: + checkState: checked + patchState: nothing-to-apply + version: "" + fixes: "" +``` + +使用 `--verbose` 开关运行上述相同的命令,以获取有关实时修补机器的更多信息。 + +``` +$ sudo canonical-livepatch status --verbose +``` + +如果要手动运行补丁程序,请执行以下命令。 + +``` +$ sudo canonical-livepatch refresh + +Before refresh: + +kernel: 4.15.0-55.60-generic +fully-patched: true +version: "" + +After refresh: + +kernel: 4.15.0-55.60-generic +fully-patched: true +version: "" +``` + +`patchState` 会有以下状态之一: + +* `applied`:未发现任何漏洞 +* `nothing-to-apply`:成功找到并修补了漏洞 +* `kernel-upgrade-required`:实时补丁服务无法安装补丁来修复漏洞 + +请注意,安装内核补丁与在系统上升级/安装新内核不同。如果安装了新内核,则必须重新引导系统以激活新内核。 + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/enable-canonical-kernel-livepatch-service-on-ubuntu-lts-system/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://wiki.ubuntu.com/Kernel/Livepatch +[2]: https://auth.livepatch.canonical.com/ +[3]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[4]: https://www.2daygeek.com/wp-content/uploads/2019/07/enable-canonical-livepatch-service-on-ubuntu-lts-system-1.jpg +[5]: https://www.2daygeek.com/wp-content/uploads/2019/07/enable-canonical-livepatch-service-on-ubuntu-lts-system-2.jpg diff --git a/published/201907/20190730 Is This the End of Floppy Disk in Linux- Linus Torvalds Marks Floppy Disks ‘Orphaned.md b/published/201907/20190730 Is This the End of Floppy Disk in Linux- Linus Torvalds Marks Floppy Disks ‘Orphaned.md new file mode 100644 index 0000000000..7a4e3e0404 --- /dev/null +++ b/published/201907/20190730 Is This the End of Floppy Disk in Linux- Linus Torvalds Marks Floppy Disks ‘Orphaned.md @@ -0,0 +1,70 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11167-1.html) +[#]: subject: (Is This the End of Floppy Disk in Linux? Linus Torvalds Marks Floppy Disks ‘Orphaned’) +[#]: via: (https://itsfoss.com/end-of-floppy-disk-in-linux/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Linux 中的软盘走向终结了吗?Torvalds 将软盘的驱动标记为“孤儿” +====== + +> 在 Linux 内核最近的提交当中,Linus Torvalds 将软盘的驱动程序标记为孤儿。这标志着软盘在 Linux 中步入结束了吗? + +有可能你很多年没见过真正的软盘了。如果你正在寻找带软盘驱动器的计算机,可能需要去博物馆里看看。 + +在二十多年前,软盘是用于存储数据和运行操作系统的流行介质。[早期的 Linux 发行版][1]使用软盘进行“分发”。软盘也广泛用于保存和传输数据。 + +你有没有想过为什么许多应用程序中的保存图标看起来像软盘?因为它就是软盘啊!软盘常用于保存数据,因此许多应用程序将其用作保存图标,并且这个传统一直延续至今。 + +![][2] + +今天我为什么要说起软盘?因为 Linus Torvalds 在一个 Linux 内核代码的提交里标记软盘的驱动程序为“孤儿”。 + +### 在 Linux 内核中被标记为“孤儿”的软盘驱动程序 + +正如你可以在 [GitHub 镜像上的提交][3]中看到的那样,开发人员 Jiri 不再使用带有软驱的工作计算机了。而如果没有正确的硬件,Jiri 将无法继续开发。这就是 Torvalds 将其标记为孤儿的原因。 + +> 越来越难以找到可以实际工作的软盘的物理硬件,虽然 Willy 能够对此进行测试,但我认为从实际的硬件角度来看,这个驱动程序几乎已经死了。目前仍然销售的硬件似乎主要是基于 USB 的,根本不使用这种传统的驱动器。 + +![][4] + +### “孤儿”在 Linux 内核中意味着什么? + +“孤儿”意味着没有开发人员能够或愿意支持这部分代码。如果没有其他人出现继续维护和开发它,孤儿模块可能会被弃用并最终删除。 + +### 它没有被立即删除 + +Torvalds 指出,各种虚拟环境模拟器仍在使用软盘驱动器。所以软盘的驱动程序不会被立即丢弃。 + +> 各种 VM 环境中仍然在仿真旧的软盘控制器,因此该驱动程序不会消失,但让我们看看是否有人有兴趣进一步维护它。 + +为什么不永远保持内核中的软盘驱动器支持呢?因为这将构成安全威胁。即使没有真正的计算机使用软盘驱动程序,虚拟机仍然拥有它,这将使虚拟机容易受到攻击。 + +### 一个时代的终结? + +这将是一个时代的结束还是会有其他人出现并承担起在 Linux 中继续维护软盘驱动程序的责任?只有时间会给出答案。 + +在 Linux 内核中,软盘驱动器成为孤儿我不觉得有什么可惜的。 + +在过去的十五年里我没有使用过软盘,我怀疑很多人也是如此。那么你呢?你有没有用过软盘?如果是的话,你最后一次使用它的时间是什么时候? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/end-of-floppy-disk-in-linux/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/earliest-linux-distros/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/floppy-disk-icon-of-saving.png?resize=800%2C300&ssl=1 +[3]: https://github.com/torvalds/linux/commit/47d6a7607443ea43dbc4d0f371bf773540a8f8f4 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/07/End-of-Floppy-in-Linux.png?resize=800%2C450&ssl=1 +[5]: https://itsfoss.com/valve-annouces-linux-based-gaming-operating-system-steamos/ diff --git a/published/201907/20191110 What is DevSecOps.md b/published/201907/20191110 What is DevSecOps.md new file mode 100644 index 0000000000..dc55731146 --- /dev/null +++ b/published/201907/20191110 What is DevSecOps.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (PandaWizard) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11102-1.html) +[#]: subject: (What is DevSecOps?) +[#]: via: (https://opensource.com/article/19/1/what-devsecops) +[#]: author: (Brett Hunoldt https://opensource.com/users/bretthunoldtcom) + +什么是 DevSecOps? +====== + +> DevSecOps 的实践之旅开始于 DevSecOps 增权、赋能和培养。下面就介绍如何开始学习使用 DevSecOps。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/devop.png?itok=Yicb2nnZ) + +> Stephen Streichsbier 说过: DevSecOps 使得组织可以用 DevOps 的速度发布内在安全的软件。 + +DevSecOps 是一场关于 DevOps 概念实践或艺术形式的变革。为了更好理解 DevSecOps,你应该首先理解 DevOps 的含义。 + +DevOps 起源于通过合并开发和运维实践,消除隔离,统一关注点,提升团队和产品的效率和性能。它是一种注重于构建容易维护和易于平常自动运营的产品和服务的新型协作方式。 + +安全在很多团队中都是常见的隔离点。安全的核心关注点是保护团队,而有时这也意味着创建延缓新服务或是新产品发布的障碍或策略,用于保障任何事都能被很好的理解和安全的执行,并且没有给团队带来不必要的风险。 + +因为安全隔离点方面的明显特征和它可能带来的摩擦,开发和运维有时会避开安全要求以满足客观情况。在一些公司,这种隔离形成了一种产品安全完全是安全团队责任的期望,并取决于安全团队去寻找产品的安全缺陷或是可能带来的问题。 + +DevSecOps 看起来是通过给开发或是运维角色加强或是建立安全意识,或是在产品团队中引入一个安全工程师角色,在产品设计中找到安全问题,从而把安全要求汇聚在 Devops 中。 + +这样使得公司能更快发布和更新产品,并且充分相信安全已经嵌入产品中。 + +### 坚固的软件哪里适用 DevSecOps? + +建造坚固的软件是 DevOps 文化的一个层面而不是一个特别的实践,它完善和增强了 DevSecOps 实践。想想一款坚固的软件就像是某些经历过残酷战斗过程的事物。 + +有必要指出坚固的软件并不是 100% 安全可靠的(虽然它可能最终是在某些方面)。然而,它被设计成可以处理大部分被抛过来的问题。 + +践行坚固软件最重要的原则是促进竞争、实践、可控的失败与合作。 + +### 你该如何开始学习 DevSecOps ? + +开始实践 DevSecOps 涉及提升安全需求和在开发过程中尽可能早的阶段进行实践。它最终在公司文化上提升了安全的重要性,使得安全成为所有人的责任,而并不只是安全团队的责任。 + +你可能在团队中听说过“左上升shift left”这个词,如果你把开发周期线扁平化到一条横线上,以包括产品变革的的关键时期:从初始化到设计、建造、测试以及最终的运行,安全的目的就是尽早的参与进来。这使得风险可以在设计中能更好的评估、交流和减轻。“左提升”的含义是指促使安全能在开发周期线上更往左走。 + +这个过程始于三个关键要素: + + * 增权empowerment + * 赋能enablement + * 培养education + +增权,在我看来,是关于释放控制权以及使得团队(在理性分析下)做出独立决定而不用害怕失败或影响。这个过程的唯一告诫信息就是要严格的做出明智的决定(不要比这更低要求)。 + +为了实现增权,商务和行政支持(通过内部销售、展示来建立,通过建立矩阵来展示这项投资的回报)是打破历史障碍和割裂的团队的关键。合并安全人员到开发和运维团队中,提升交流和透明度有助于开始 DevSecOps 之旅。 + +这个整合和移动使得团队只关注单一的结果:打造一个他们共同负责的产品,让开发和安全人员相互依赖合作。这将引领你们共同走向增权。这是产品研发团队的共同责任,并保证每个可分割的产品都保持其安全性。 + +赋能涉及正确的使用掌握在团队手中的工具和资源。这是建立一种通过论坛、维基、信息聚合的知识分享文化。 + +打造一种注重自动化、重复任务应该编码来尽可能减少以后的操作并增强安全性的理念。这种场景不仅仅是提供知识,而是让这种知识能够通过多种渠道和媒介(通过某些工具)可获取,以便它可以被团队或是个人以他喜欢的方式去消化和分享。当团队成员正在编码时一种媒介可能工作的很好,而当他们在进行中时另一种可能更好。让工具简单可用,让团队用上它们。 + +不同的 DevSecOps 团队有不同的喜好,因此允许他们尽可能的保持独立。这是一个微妙的平衡工作,因为你确实希望实现规模经济和产品间共享的能力。在选择中协作和参与,并更新工具方法有助于减少使用中的障碍。 + +最后,也可能是最重要的,DevSecOps 是有关训练和兴趣打造。聚会、社交或是组织中通常的报告会都是让同事们教学和分享他们的知识的很棒的方式。有时,这些会突出其他人可能没有考虑过的共同挑战、顾虑或风险。分享和教学也是一种高效的学习和指导团队的方法。 + +在我个人经验中,每个团队的文化都是独一无二的,因此你不能用一种“普适”的方法。走进你的团队并找到他们想要使用的工具方法。尝试不同的论坛和聚会并找出最适用于你们文化的方式。寻找反馈并询问团队如何工作,他们喜欢什么以及对应的原因。适应和学习,保持乐观,不要停止尝试,你们将会有所收获。 + +- [下载 DevSecOps 的入门手册][1] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/what-devsecops + +作者:[Brett Hunoldt][a] +选题:[lujun9972][b] +译者:[PandaWizard](https://github.com/PandaWizard) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bretthunoldtcom +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/downloads/devsecops diff --git a/published/20190701 Get modular with Python functions.md b/published/20190701 Get modular with Python functions.md new file mode 100644 index 0000000000..37124c8e2b --- /dev/null +++ b/published/20190701 Get modular with Python functions.md @@ -0,0 +1,322 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11295-1.html) +[#]: subject: (Get modular with Python functions) +[#]: via: (https://opensource.com/article/19/7/get-modular-python-functions) +[#]: author: (Seth Kenlon https://opensource.com/users/seth/users/xd-deng/users/nhuntwalker/users/don-watkins) + +使用 Python 函数进行模块化 +====== + +> 使用 Python 函数来最大程度地减少重复任务编码工作量。 + +![](https://img.linux.net.cn/data/attachment/album/201909/01/234309ja7ooanopazo3o2m.jpg) + +你是否对函数、类、方法、库和模块等花哨的编程术语感到困惑?你是否在与变量作用域斗争?无论你是自学成才的还是经过正式培训的程序员,代码的模块化都会令人困惑。但是类和库鼓励模块化代码,因为模块化代码意味着只需构建一个多用途代码块集合,就可以在许多项目中使用它们来减少编码工作量。换句话说,如果你按照本文对 [Python][2] 函数的研究,你将找到更聪明的工作方法,这意味着更少的工作。 + +本文假定你对 Python 很熟(LCTT 译注:稍微熟悉就可以),并且可以编写和运行一个简单的脚本。如果你还没有使用过 Python,请首先阅读我的文章:[Python 简介][3]。 + +### 函数 + +函数是迈向模块化过程中重要的一步,因为它们是形式化的重复方法。如果在你的程序中,有一个任务需要反复执行,那么你可以将代码放入一个函数中,根据需要随时调用该函数。这样,你只需编写一次代码,就可以随意使用它。 + +以下一个简单函数的示例: + +``` +#!/usr/bin/env python3 +import time + +def Timer(): +    print("Time is " + str(time.time() )) +``` + +创建一个名为 `mymodularity` 的目录,并将以上函数代码保存为该目录下的 `timestamp.py`。 + +除了这个函数,在 `mymodularity` 目录中创建一个名为 `__init__.py` 的文件,你可以在文件管理器或 bash shell 中执行此操作: + +``` +$ touch mymodularity/__init__.py +``` + +现在,你已经创建了属于你自己的 Python 库(Python 中称为“模块”),名为 `mymodularity`。它不是一个特别有用的模块,因为它所做的只是导入 `time` 模块并打印一个时间戳,但这只是一个开始。 + +要使用你的函数,像对待任何其他 Python 模块一样对待它。以下是一个小应用,它使用你的 `mymodularity` 软件包来测试 Python `sleep()` 函数的准确性。将此文件保存为 `sleeptest.py`,注意要在 `mymodularity` 文件夹 *之外*,因为如果你将它保存在 `mymodularity` *里面*,那么它将成为你的包中的一个模块,你肯定不希望这样。 + +``` +#!/usr/bin/env python3 + +import time +from mymodularity import timestamp + +print("Testing Python sleep()...") + +# modularity +timestamp.Timer() +time.sleep(3) +timestamp.Timer() +``` + +在这个简单的脚本中,你从 `mymodularity` 包中调用 `timestamp` 模块两次。从包中导入模块时,通常的语法是从包中导入你所需的模块,然后使用 *模块名称 + 一个点 + 要调用的函数名*(例如 `timestamp.Timer()`)。 + +你调用了两次 `Timer()` 函数,所以如果你的 `timestamp` 模块比这个简单的例子复杂些,那么你将节省大量重复代码。 + +保存文件并运行: + +``` +$ python3 ./sleeptest.py +Testing Python sleep()... +Time is 1560711266.1526039 +Time is 1560711269.1557732 +``` + +根据测试,Python 中的 `sleep` 函数非常准确:在三秒钟等待之后,时间戳成功且正确地增加了 3,在微秒单位上差距很小。 + +Python 库的结构看起来可能令人困惑,但其实它并不是什么魔法。Python *被编程* 为一个包含 Python 代码的目录,并附带一个 `__init__.py` 文件,那么这个目录就会被当作一个包,并且 Python 会首先在当前目录中查找可用模块。这就是为什么语句 `from mymodularity import timestamp` 有效的原因:Python 在当前目录查找名为 `mymodularity` 的目录,然后查找 `timestamp.py` 文件。 + +你在这个例子中所做的功能和以下这个非模块化的版本是一样的: + +``` +#!/usr/bin/env python3 + +import time +from mymodularity import timestamp + +print("Testing Python sleep()...") + +# no modularity +print("Time is " + str(time.time() ) ) +time.sleep(3) +print("Time is " + str(time.time() ) ) +``` + +对于这样一个简单的例子,其实没有必要以这种方式编写测试,但是对于编写自己的模块来说,最佳实践是你的代码是通用的,可以将它重用于其他项目。 + +通过在调用函数时传递信息,可以使代码更通用。例如,假设你想要使用模块来测试的不是 *系统* 的 `sleep` 函数,而是 *用户自己实现* 的 `sleep` 函数,更改 `timestamp` 代码,使它接受一个名为 `msg` 的传入变量,它将是一个字符串,控制每次调用 `timestamp` 时如何显示: + +``` +#!/usr/bin/env python3 + +import time + +# 更新代码 +def Timer(msg): +    print(str(msg) + str(time.time() ) ) +``` + +现在函数比以前更抽象了。它仍会打印时间戳,但是它为用户打印的内容 `msg` 还是未定义的。这意味着你需要在调用函数时定义它。 + +`Timer` 函数接受的 `msg` 参数是随便命名的,你可以使用参数 `m`、`message` 或 `text`,或是任何对你来说有意义的名称。重要的是,当调用 `timestamp.Timer` 函数时,它接收一个文本作为其输入,将接收到的任何内容放入 `msg` 变量中,并使用该变量完成任务。 + +以下是一个测试测试用户正确感知时间流逝能力的新程序: + +``` +#!/usr/bin/env python3 + +from mymodularity import timestamp + +print("Press the RETURN key. Count to 3, and press RETURN again.") + +input() +timestamp.Timer("Started timer at ") + +print("Count to 3...") + +input() +timestamp.Timer("You slept until ") +``` + +将你的新程序保存为 `response.py`,运行它: + +``` +$ python3 ./response.py +Press the RETURN key. Count to 3, and press RETURN again. + +Started timer at 1560714482.3772075 +Count to 3... + +You slept until 1560714484.1628013 +``` + +### 函数和所需参数 + +新版本的 `timestamp` 模块现在 *需要* 一个 `msg` 参数。这很重要,因为你的第一个应用程序将无法运行,因为它没有将字符串传递给 `timestamp.Timer` 函数: + +``` +$ python3 ./sleeptest.py +Testing Python sleep()... +Traceback (most recent call last): +  File "./sleeptest.py", line 8, in <module> +    timestamp.Timer() +TypeError: Timer() missing 1 required positional argument: 'msg' +``` + +你能修复你的 `sleeptest.py` 应用程序,以便它能够与更新后的模块一起正确运行吗? + +### 变量和函数 + +通过设计,函数限制了变量的范围。换句话说,如果在函数内创建一个变量,那么这个变量 *只* 在这个函数内起作用。如果你尝试在函数外部使用函数内部出现的变量,就会发生错误。 + +下面是对 `response.py` 应用程序的修改,尝试从 `timestamp.Timer()` 函数外部打印 `msg` 变量: + +``` +#!/usr/bin/env python3 + +from mymodularity import timestamp + +print("Press the RETURN key. Count to 3, and press RETURN again.") + +input() +timestamp.Timer("Started timer at ") + +print("Count to 3...") + +input() +timestamp.Timer("You slept for ") + +print(msg) +``` + +试着运行它,查看错误: + +``` +$ python3 ./response.py +Press the RETURN key. Count to 3, and press RETURN again. + +Started timer at 1560719527.7862902 +Count to 3... + +You slept for 1560719528.135406 +Traceback (most recent call last): +  File "./response.py", line 15, in <module> +    print(msg) +NameError: name 'msg' is not defined +``` + +应用程序返回一个 `NameError` 消息,因为没有定义 `msg`。这看起来令人困惑,因为你编写的代码定义了 `msg`,但你对代码的了解比 Python 更深入。调用函数的代码,不管函数是出现在同一个文件中,还是打包为模块,都不知道函数内部发生了什么。一个函数独立地执行它的计算,并返回你想要它返回的内容。这其中所涉及的任何变量都只是 *本地的*:它们只存在于函数中,并且只存在于函数完成其目的所需时间内。 + +#### Return 语句 + +如果你的应用程序需要函数中特定包含的信息,那么使用 `return` 语句让函数在运行后返回有意义的数据。 + +时间就是金钱,所以修改 `timestamp` 函数,以使其用于一个虚构的收费系统: + +``` +#!/usr/bin/env python3 + +import time + +def Timer(msg): +    print(str(msg) + str(time.time() ) ) +    charge = .02 +    return charge +``` + +现在,`timestamp` 模块每次调用都收费 2 美分,但最重要的是,它返回每次调用时所收取的金额。 + +以下一个如何使用 `return` 语句的演示: + +``` +#!/usr/bin/env python3 + +from mymodularity import timestamp + +print("Press RETURN for the time (costs 2 cents).") +print("Press Q RETURN to quit.") + +total = 0 + +while True: +    kbd = input() +    if kbd.lower() == "q": +        print("You owe $" + str(total) ) +        exit() +    else: +        charge = timestamp.Timer("Time is ") +        total = total+charge +``` + +在这个示例代码中,变量 `charge` 为 `timestamp.Timer()` 函数的返回,它接收函数返回的任何内容。在本例中,函数返回一个数字,因此使用一个名为 `total` 的新变量来跟踪已经进行了多少更改。当应用程序收到要退出的信号时,它会打印总花费: + +``` +$ python3 ./charge.py +Press RETURN for the time (costs 2 cents). +Press Q RETURN to quit. + +Time is 1560722430.345412 + +Time is 1560722430.933996 + +Time is 1560722434.6027434 + +Time is 1560722438.612629 + +Time is 1560722439.3649364 +q +You owe $0.1 +``` + +#### 内联函数 + +函数不必在单独的文件中创建。如果你只是针对一个任务编写一个简短的脚本,那么在同一个文件中编写函数可能更有意义。唯一的区别是你不必导入自己的模块,但函数的工作方式是一样的。以下是时间测试应用程序的最新迭代: + +``` +#!/usr/bin/env python3 + +import time + +total = 0 + +def Timer(msg): +    print(str(msg) + str(time.time() ) ) +    charge = .02 +    return charge + +print("Press RETURN for the time (costs 2 cents).") +print("Press Q RETURN to quit.") + +while True: +    kbd = input() +    if kbd.lower() == "q": +        print("You owe $" + str(total) ) +        exit() +    else: +        charge = Timer("Time is ") +        total = total+charge +``` + +它没有外部依赖(Python 发行版中包含 `time` 模块),产生与模块化版本相同的结果。它的优点是一切都位于一个文件中,缺点是你不能在其他脚本中使用 `Timer()` 函数,除非你手动复制和粘贴它。 + +#### 全局变量 + +在函数外部创建的变量没有限制作用域,因此它被视为 *全局* 变量。 + +全局变量的一个例子是在 `charge.py` 中用于跟踪当前花费的 `total` 变量。`total` 是在函数之外创建的,因此它绑定到应用程序而不是特定函数。 + +应用程序中的函数可以访问全局变量,但要将变量传入导入的模块,你必须像发送 `msg` 变量一样将变量传入模块。 + +全局变量很方便,因为它们似乎随时随地都可用,但也很难跟踪它们,很难知道哪些变量不再需要了但是仍然在系统内存中停留(尽管 Python 有非常好的垃圾收集机制)。 + +但是,全局变量很重要,因为不是所有的变量都可以是函数或类的本地变量。现在你知道了如何向函数传入变量并获得返回,事情就变得容易了。 + +### 总结 + +你已经学到了很多关于函数的知识,所以开始将它们放入你的脚本中 —— 如果它不是作为单独的模块,那么作为代码块,你不必在一个脚本中编写多次。在本系列的下一篇文章中,我将介绍 Python 类。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/get-modular-python-functions + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth/users/xd-deng/users/nhuntwalker/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openstack_python_vim_1.jpg?itok=lHQK5zpm +[2]: https://www.python.org/ +[3]: https://opensource.com/article/17/10/python-10 diff --git a/published/20190705 Learn object-oriented programming with Python.md b/published/20190705 Learn object-oriented programming with Python.md new file mode 100644 index 0000000000..1d2767d601 --- /dev/null +++ b/published/20190705 Learn object-oriented programming with Python.md @@ -0,0 +1,305 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11317-1.html) +[#]: subject: (Learn object-oriented programming with Python) +[#]: via: (https://opensource.com/article/19/7/get-modular-python-classes) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +使用 Python 学习面对对象的编程 +====== + +> 使用 Python 类使你的代码变得更加模块化。 + +![](https://img.linux.net.cn/data/attachment/album/201909/08/091142y2bdbboctw7xdbjq.jpg) + +在我上一篇文章中,我解释了如何通过使用函数、创建模块或者两者一起来[使 Python 代码更加模块化][2]。函数对于避免重复多次使用的代码非常有用,而模块可以确保你在不同的项目中复用代码。但是模块化还有另一种方法:类。 + +如果你已经听过面对对象编程object-oriented programming(OOP)这个术语,那么你可能会对类的用途有一些概念。程序员倾向于将类视为一个虚拟对象,有时与物理世界中的某些东西直接相关,有时则作为某种编程概念的表现形式。无论哪种表示,当你想要在程序中为你或程序的其他部分创建“对象”时,你都可以创建一个类来交互。 + +### 没有类的模板 + +假设你正在编写一个以幻想世界为背景的游戏,并且你需要这个应用程序能够涌现出各种坏蛋来给玩家的生活带来一些刺激。了解了很多关于函数的知识后,你可能会认为这听起来像是函数的一个教科书案例:需要经常重复的代码,但是在调用时可以考虑变量而只编写一次。 + +下面一个纯粹基于函数的敌人生成器实现的例子: + +``` +#!/usr/bin/env python3 + +import random + +def enemy(ancestry,gear): + enemy=ancestry + weapon=gear + hp=random.randrange(0,20) + ac=random.randrange(0,20) + return [enemy,weapon,hp,ac] + +def fight(tgt): + print("You take a swing at the " + tgt[0] + ".") + hit=random.randrange(0,20) + if hit > tgt[3]: + print("You hit the " + tgt[0] + " for " + str(hit) + " damage!") + tgt[2] = tgt[2] - hit + else: + print("You missed.") + + +foe=enemy("troll","great axe") +print("You meet a " + foe[0] + " wielding a " + foe[1]) +print("Type the a key and then RETURN to attack.") + +while True: + action=input() + + if action.lower() == "a": + fight(foe) + + if foe[2] < 1: + print("You killed your foe!") + else: + print("The " + foe[0] + " has " + str(foe[2]) + " HP remaining") +``` + +`enemy` 函数创造了一个具有多个属性的敌人,例如谱系、武器、生命值和防御等级。它返回每个属性的列表,表示敌人全部特征。 + +从某种意义上说,这段代码创建了一个对象,即使它还没有使用类。程序员将这个 `enemy` 称为*对象*,因为该函数的结果(本例中是一个包含字符串和整数的列表)表示游戏中一个单独但复杂的*东西*。也就是说,列表中字符串和整数不是任意的:它们一起描述了一个虚拟对象。 + +在编写描述符集合时,你可以使用变量,以便随时使用它们来生成敌人。这有点像模板。 + +在示例代码中,当需要对象的属性时,会检索相应的列表项。例如,要获取敌人的谱系,代码会查询 `foe[0]`,对于生命值,会查询 `foe[2]`,以此类推。 + +这种方法没有什么不妥,代码按预期运行。你可以添加更多不同类型的敌人,创建一个敌人类型列表,并在敌人创建期间从列表中随机选择,等等,它工作得很好。实际上,[Lua][3] 非常有效地利用这个原理来近似了一个面对对象模型。 + +然而,有时候对象不仅仅是属性列表。 + +### 使用对象 + +在 Python 中,一切都是对象。你在 Python 中创建的任何东西都是某个预定义模板的*实例*。甚至基本的字符串和整数都是 Python `type` 类的衍生物。你可以在这个交互式 Python shell 中见证: + +``` +>>> foo=3 +>>> type(foo) + +>>> foo="bar" +>>> type(foo) + +``` + +当一个对象由一个类定义时,它不仅仅是一个属性的集合,Python 类具有各自的函数。从逻辑上讲,这很方便,因为只涉及某个对象类的操作包含在该对象的类中。 + +在示例代码中,`fight` 的代码是主应用程序的功能。这对于一个简单的游戏来说是可行的,但对于一个复杂的游戏来说,世界中不仅仅有玩家和敌人,还可能有城镇居民、牲畜、建筑物、森林等等,它们都不需要使用战斗功能。将战斗代码放在敌人的类中意味着你的代码更有条理,在一个复杂的应用程序中,这是一个重要的优势。 + +此外,每个类都有特权访问自己的本地变量。例如,敌人的生命值,除了某些功能之外,是不会改变的数据。游戏中的随机蝴蝶不应该意外地将敌人的生命值降低到 0。理想情况下,即使没有类,也不会发生这种情况。但是在具有大量活动部件的复杂应用程序中,确保不需要相互交互的部件永远不会发生这种情况,这是一个非常有用的技巧。 + +Python 类也受垃圾收集的影响。当不再使用类的实例时,它将被移出内存。你可能永远不知道这种情况会什么时候发生,但是你往往知道什么时候它不会发生,因为你的应用程序占用了更多的内存,而且运行速度比较慢。将数据集隔离到类中可以帮助 Python 跟踪哪些数据正在使用,哪些不在需要了。 + +### 优雅的 Python + +下面是一个同样简单的战斗游戏,使用了 `Enemy` 类: + +``` +#!/usr/bin/env python3 + +import random + +class Enemy(): + def __init__(self,ancestry,gear): + self.enemy=ancestry + self.weapon=gear + self.hp=random.randrange(10,20) + self.ac=random.randrange(12,20) + self.alive=True + + def fight(self,tgt): + print("You take a swing at the " + self.enemy + ".") + hit=random.randrange(0,20) + + if self.alive and hit > self.ac: + print("You hit the " + self.enemy + " for " + str(hit) + " damage!") + self.hp = self.hp - hit + print("The " + self.enemy + " has " + str(self.hp) + " HP remaining") + else: + print("You missed.") + + if self.hp < 1: + self.alive=False + +# 游戏开始 +foe=Enemy("troll","great axe") +print("You meet a " + foe.enemy + " wielding a " + foe.weapon) + +# 主函数循环 +while True: + + print("Type the a key and then RETURN to attack.") + + action=input() + + if action.lower() == "a": + foe.fight(foe) + + if foe.alive == False: + print("You have won...this time.") + exit() +``` + +这个版本的游戏将敌人作为一个包含相同属性(谱系、武器、生命值和防御)的对象来处理,并添加一个新的属性来衡量敌人时候已被击败,以及一个战斗功能。 + +类的第一个函数是一个特殊的函数,在 Python 中称为 `init` 或初始化的函数。这类似于其他语言中的[构造器][4],它创建了类的一个实例,你可以通过它的属性和调用类时使用的任何变量来识别它(示例代码中的 `foe`)。 + +### Self 和类实例 + +类的函数接受一种你在类之外看不到的新形式的输入:`self`。如果不包含 `self`,那么当你调用类函数时,Python 无法知道要使用的类的*哪个*实例。这就像在一间充满兽人的房间里说:“我要和兽人战斗”,向一个兽人发起。没有人知道你指的是谁,所有兽人就都上来了。 + +![Image of an Orc, CC-BY-SA by Buch on opengameart.org][5] + +*CC-BY-SA by Buch on opengameart.org* + +类中创建的每个属性都以 `self` 符号作为前缀,该符号将变量标识为类的属性。一旦派生出类的实例,就用表示该实例的变量替换掉 `self` 前缀。使用这个技巧,你可以在一间满是兽人的房间里说:“我要和谱系是 orc 的兽人战斗”,这样来挑战一个兽人。当 orc 听到 “gorblar.orc” 时,它就知道你指的是谁(他自己),所以你得到是一场公平的战斗而不是斗殴。在 Python 中: + +``` +gorblar=Enemy("orc","sword") +print("The " + gorblar.enemy + " has " + str(gorblar.hp) + " remaining.") +``` + +通过检索类属性(`gorblar.enemy` 或 `gorblar.hp` 或你需要的任何对象的任何值)而不是查询 `foe[0]`(在函数示例中)或 `gorblar[0]` 来寻找敌人。 + +### 本地变量 + +如果类中的变量没有以 `self` 关键字作为前缀,那么它就是一个局部变量,就像在函数中一样。例如,无论你做什么,你都无法访问 `Enemy.fight` 类之外的 `hit` 变量: + +``` +>>> print(foe.hit) +Traceback (most recent call last): + File "./enclass.py", line 38, in + print(foe.hit) +AttributeError: 'Enemy' object has no attribute 'hit' + +>>> print(foe.fight.hit) +Traceback (most recent call last): + File "./enclass.py", line 38, in + print(foe.fight.hit) +AttributeError: 'function' object has no attribute 'hit' +``` + +`hit` 变量包含在 Enemy 类中,并且只能“存活”到在战斗中发挥作用。 + +### 更模块化 + +本例使用与主应用程序相同的文本文档中的类。在一个复杂的游戏中,我们更容易将每个类看作是自己独立的应用程序。当多个开发人员处理同一个应用程序时,你会看到这一点:一个开发人员负责一个类,另一个开发人员负责主程序,只要他们彼此沟通这个类必须具有什么属性,就可以并行地开发这两个代码块。 + +要使这个示例游戏模块化,可以把它拆分为两个文件:一个用于主应用程序,另一个用于类。如果它是一个更复杂的应用程序,你可能每个类都有一个文件,或每个逻辑类组有一个文件(例如,用于建筑物的文件,用于自然环境的文件,用于敌人或 NPC 的文件等)。 + +将只包含 `Enemy` 类的一个文件保存为 `enemy.py`,将另一个包含其他内容的文件保存为 `main.py`。 + +以下是 `enemy.py`: + +``` +import random + +class Enemy(): + def __init__(self,ancestry,gear): + self.enemy=ancestry + self.weapon=gear + self.hp=random.randrange(10,20) + self.stg=random.randrange(0,20) + self.ac=random.randrange(0,20) + self.alive=True + + def fight(self,tgt): + print("You take a swing at the " + self.enemy + ".") + hit=random.randrange(0,20) + + if self.alive and hit > self.ac: + print("You hit the " + self.enemy + " for " + str(hit) + " damage!") + self.hp = self.hp - hit + print("The " + self.enemy + " has " + str(self.hp) + " HP remaining") + else: + print("You missed.") + + if self.hp < 1: + self.alive=False +``` + +以下是 `main.py`: + +``` +#!/usr/bin/env python3 + +import enemy as en + +# game start +foe=en.Enemy("troll","great axe") +print("You meet a " + foe.enemy + " wielding a " + foe.weapon) + +# main loop +while True: + + print("Type the a key and then RETURN to attack.") + + action=input() + + if action.lower() == "a": + foe.fight(foe) + + if foe.alive == False: + print("You have won...this time.") + exit() +``` + +导入模块 `enemy.py` 使用了一条特别的语句,引用类文件名称而不用带有 `.py` 扩展名,后跟你选择的命名空间指示符(例如,`import enemy as en`)。这个指示符是在你调用类时在代码中使用的。你需要在导入时添加指示符,例如 `en.Enemy`,而不是只使用 `Enemy()`。 + +所有这些文件名都是任意的,尽管在原则上不要使用罕见的名称。将应用程序的中心命名为 `main.py` 是一个常见约定,和一个充满类的文件通常以小写形式命名,其中的类都以大写字母开头。是否遵循这些约定不会影响应用程序的运行方式,但它确实使经验丰富的 Python 程序员更容易快速理解应用程序的工作方式。 + +在如何构建代码方面有一些灵活性。例如,使用该示例代码,两个文件必须位于同一目录中。如果你只想将类打包为模块,那么必须创建一个名为 `mybad` 的目录,并将你的类移入其中。在 `main.py` 中,你的 `import` 语句稍有变化: + +``` +from mybad import enemy as en +``` + +两种方法都会产生相同的结果,但如果你创建的类足够通用,你认为其他开发人员可以在他们的项目中使用它们,那么后者更好。 + +无论你选择哪种方式,都可以启动游戏的模块化版本: + +``` +$ python3 ./main.py +You meet a troll wielding a great axe +Type the a key and then RETURN to attack. +a +You take a swing at the troll. +You missed. +Type the a key and then RETURN to attack. +a +You take a swing at the troll. +You hit the troll for 8 damage! +The troll has 4 HP remaining +Type the a key and then RETURN to attack. +a +You take a swing at the troll. +You hit the troll for 11 damage! +The troll has -7 HP remaining +You have won...this time. +``` + +游戏启动了,它现在更加模块化了。现在你知道了面对对象的应用程序意味着什么,但最重要的是,当你向兽人发起决斗的时候,你知道是哪一个。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/get-modular-python-classes + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_development_programming.png?itok=M_QDcgz5 (Developing code.) +[2]: https://linux.cn/article-11295-1.html +[3]: https://opensource.com/article/17/4/how-program-games-raspberry-pi +[4]: https://opensource.com/article/19/6/what-java-constructor +[5]: https://opensource.com/sites/default/files/images/orc-buch-opengameart_cc-by-sa.jpg (CC-BY-SA by Buch on opengameart.org) diff --git a/published/20190730 How to manage logs in Linux.md b/published/20190730 How to manage logs in Linux.md new file mode 100644 index 0000000000..b3d448a305 --- /dev/null +++ b/published/20190730 How to manage logs in Linux.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11336-1.html) +[#]: subject: (How to manage logs in Linux) +[#]: via: (https://www.networkworld.com/article/3428361/how-to-manage-logs-in-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如何在 Linux 中管理日志 +====== + +> Linux 系统上的日志文件包含了**很多**信息——比你有时间查看的还要多。以下是一些建议,告诉你如何正确的使用它们……而不是淹没在其中。 + +![Greg Lobinski \(CC BY 2.0\)][1] + +在 Linux 系统上管理日志文件可能非常容易,也可能非常痛苦。这完全取决于你所认为的日志管理是什么。 + +如果你认为是如何确保日志文件不会耗尽你的 Linux 服务器上的所有磁盘空间,那么这个问题通常很简单。Linux 系统上的日志文件会自动翻转,系统将只维护固定数量的翻转日志。即便如此,一眼看去一组上百个文件可能会让人不知所措。在这篇文章中,我们将看看日志轮换是如何工作的,以及一些最相关的日志文件。 + +### 自动日志轮换 + +日志文件是经常轮转的。当前的日志会获得稍微不同的文件名,并建立一个新的日志文件。以系统日志文件为例。对于许多正常的系统 messages 文件来说,这个文件是一个包罗万象的东西。如果你 `cd` 转到 `/var/log` 并查看一下,你可能会看到一系列系统日志文件,如下所示: + +``` +$ ls -l syslog* +-rw-r----- 1 syslog adm 28996 Jul 30 07:40 syslog +-rw-r----- 1 syslog adm 71212 Jul 30 00:00 syslog.1 +-rw-r----- 1 syslog adm 5449 Jul 29 00:00 syslog.2.gz +-rw-r----- 1 syslog adm 6152 Jul 28 00:00 syslog.3.gz +-rw-r----- 1 syslog adm 7031 Jul 27 00:00 syslog.4.gz +-rw-r----- 1 syslog adm 5602 Jul 26 00:00 syslog.5.gz +-rw-r----- 1 syslog adm 5995 Jul 25 00:00 syslog.6.gz +-rw-r----- 1 syslog adm 32924 Jul 24 00:00 syslog.7.gz +``` + +轮换发生在每天午夜,旧的日志文件会保留一周,然后删除最早的系统日志文件。`syslog.7.gz` 文件将被从系统中删除,`syslog.6.gz` 将被重命名为 `syslog.7.gz`。日志文件的其余部分将依次改名,直到 `syslog` 变成 `syslog.1` 并创建一个新的 `syslog` 文件。有些系统日志文件会比其他文件大,但是一般来说,没有一个文件可能会变得非常大,并且你永远不会看到超过八个的文件。这给了你一个多星期的时间来回顾它们收集的任何数据。 + +某种特定日志文件维护的文件数量取决于日志文件本身。有些文件可能有 13 个。请注意 `syslog` 和 `dpkg` 的旧文件是如何压缩以节省空间的。这里的考虑是你对最近的日志最感兴趣,而更旧的日志可以根据需要用 `gunzip` 解压。 + +``` +# ls -t dpkg* +dpkg.log dpkg.log.3.gz dpkg.log.6.gz dpkg.log.9.gz dpkg.log.12.gz +dpkg.log.1 dpkg.log.4.gz dpkg.log.7.gz dpkg.log.10.gz +dpkg.log.2.gz dpkg.log.5.gz dpkg.log.8.gz dpkg.log.11.gz +``` + +日志文件可以根据时间和大小进行轮换。检查日志文件时请记住这一点。 + +尽管默认值适用于大多数 Linux 系统管理员,但如果你愿意,可以对日志文件轮换进行不同的配置。查看这些文件,如 `/etc/rsyslog.conf` 和 `/etc/logrotate.conf`。 + +### 使用日志文件 + +对日志文件的管理也包括时不时的使用它们。使用日志文件的第一步可能包括:习惯每个日志文件可以告诉你有关系统如何工作以及系统可能会遇到哪些问题。从头到尾读取日志文件几乎不是一个好的选择,但是当你想了解你的系统运行的情况或者需要跟踪一个问题时,知道如何从日志文件中获取信息会是有很大的好处。这也表明你对每个文件中存储的信息有一个大致的了解了。例如: + +``` +$ who wtmp | tail -10 显示最近的登录信息 +$ who wtmp | grep shark 显示特定用户的最近登录信息 +$ grep "sudo:" auth.log 查看谁在使用 sudo +$ tail dmesg 查看(最近的)内核日志 +$ tail dpkg.log 查看最近安装和更新的软件包 +$ more ufw.log 查看防火墙活动(假如你使用 ufw) +``` + +你运行的一些命令也会从日志文件中提取信息。例如,如果你想查看系统重新启动的列表,可以使用如下命令: + +``` +$ last reboot +reboot system boot 5.0.0-20-generic Tue Jul 16 13:19 still running +reboot system boot 5.0.0-15-generic Sat May 18 17:26 - 15:19 (21+21:52) +reboot system boot 5.0.0-13-generic Mon Apr 29 10:55 - 15:34 (18+04:39) +``` + +### 使用更高级的日志管理器 + +虽然你可以编写脚本来更容易地在日志文件中找到感兴趣的信息,但是你也应该知道有一些非常复杂的工具可用于日志文件分析。一些可以把来自多个来源的信息联系起来,以便更全面地了解你的网络上发生了什么。它们也可以提供实时监控。这些工具,如 [Solarwinds Log & Event Manager][3] 和 [PRTG 网络监视器][4](包括日志监视)浮现在脑海中。 + +还有一些免费工具可以帮助分析日志文件。其中包括: + + * Logwatch — 用于扫描系统日志中感兴趣的日志行的程序 + * Logcheck — 系统日志分析器和报告器 + +在接下来的文章中,我将提供一些关于这些工具的见解和帮助。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3428361/how-to-manage-logs-in-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/07/logs-100806633-large.jpg +[2]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua +[3]: https://www.esecurityplanet.com/products/solarwinds-log-event-manager-siem.html +[4]: https://www.paessler.com/prtg +[5]: https://www.networkworld.com/article/3242170/linux/invaluable-tips-and-tricks-for-troubleshooting-linux.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/published/201908/20171113 IT disaster recovery- Sysadmins vs. natural disasters - HPE.md b/published/201908/20171113 IT disaster recovery- Sysadmins vs. natural disasters - HPE.md new file mode 100644 index 0000000000..c582a3bd3f --- /dev/null +++ b/published/201908/20171113 IT disaster recovery- Sysadmins vs. natural disasters - HPE.md @@ -0,0 +1,172 @@ +IT 灾备:系统管理员对抗自然灾害 +====== + +![](https://www.hpe.com/content/dam/hpe/insights/articles/2017/11/it-disaster-recovery-sysadmins-vs-natural-disasters/featuredStory/Sysadmins-vs-natural-disasters-1740.jpg.transform/nxt-1043x496-crop/image.jpeg) + +> 面对倾泻的洪水或地震时业务需要继续运转。在飓风卡特里娜、桑迪和其他灾难中幸存下来的系统管理员向在紧急状况下负责 IT 的人们分享真实世界中的建议。 + +说到自然灾害,2017 年可算是多灾多难。(LCTT 译注:本文发表于 2017 年)飓风哈维、厄玛和玛莉亚给休斯顿、波多黎各、弗罗里达和加勒比造成了严重破坏。此外,西部的野火将多处住宅和商业建筑付之一炬。 + +再来一篇关于[有备无患][1]的警示文章 —— 当然其中都是好的建议 —— 是很简单的,但这无法帮助网络管理员应对湿漉漉的烂摊子。那些善意的建议中大多数都假定掌权的人乐于投入资金来实施这些建议。 + +我们对真实世界更感兴趣。不如让我们来充分利用这些坏消息。 + +一个很好的例子:自然灾害的一个后果是老板可能突然愿意给灾备计划投入预算。如同一个纽约地区的系统管理员所言,“[我发现飓风桑迪的最大好处][2]是我们的客户对 IT 投资更有兴趣了,但愿你也能得到更多预算。” + +不过别指望这种意愿持续很久。任何想提议改进基础设施的系统管理员最好趁热打铁。如同另一位飓风桑迪中幸存下来的 IT 专员懊悔地提及那样,“[对 IT 开支最初的兴趣持续到当年为止][3]。到了第二年,任何尚未开工的计划都因为‘预算约束’被搁置了,大约 6 个月之后则完全被遗忘。” + +在管理层忘记恶劣的自然灾害也可能降临到好公司头上之前提醒他们这点会有所帮助。根据商业和家庭安全协会Institute for Business & Home Safety的说法,[自然灾害后歇业的公司中 25% 再也没能重新开业][4]。联邦紧急事务管理署FEMA认为这过于乐观。根据他们的统计,“灾后 [40% 的小公司再也没能重新开门营业][5]。” + +如果你是个系统管理员,你能帮忙挽救你的公司。这里有一些幸存者的最好的主意,这些主意是基于他们从过去几次自然灾害中得到的经验。 + +### 制订一个计划 + +当灯光忽明忽暗,狂风象火车机车一样怒号时,就该启动你的业务持续计划和灾备计划了。 + +有太多的系统管理员报告当暴风雨来临时这两个计划中一个也没有。这并不令人惊讶。2014 年[灾备预备状态委员会][6]Disaster Recovery Preparedness Council发现[世界范围内被调查的公司中有 73% 没有足够的灾备计划][7]。 + +“**足够**”是关键词。正如一个系统管理员 2016 年在 Reddit 上写的那样,“[我们的灾备计划就是一场灾难。][8]我们所有的数据都备份在离这里大约 30 英里的一个存储区域网络SAN。我们没有将数据重新上线的硬件,甚至好几天过去了都没能让核心服务器启动运行起来。我们是个年营收 40 亿美元的公司,却不愿为适当的设备投入几十万美元,或是在数据中心添置几台服务器。当添置硬件的提案被提出的时候,我们的管理层说,‘嗐,碰到这种事情的机会能有多大呢’。” + +同一个帖子中另一个人说得更简洁:“眼下我的灾备计划只能在黑暗潮湿的角落里哭泣,但愿没人在乎损失的任何东西。” + +如果你在哭泣,但愿你至少不是独自流泪。任何灾备计划,即便是 IT 部门制订的灾备计划,必须确定[你能跟别人通讯][10],如同系统管理员 Jim Thompson 从卡特里娜飓风中得到的教训:“确保你有一个与人们通讯的计划。在一场严重的区域性灾难期间,你将无法给身处灾区的任何人打电话。” + +有一个选择可能会让有技术头脑的人感兴趣:[业余电台][11]ham radio。[它在波多黎各发挥了巨大作用][12]。 + +### 列一个愿望清单 + +第一步是承认问题。“许多公司实际上对灾备计划不感兴趣,或是消极对待”,[Micro Focus][14] 的首席架构师 [Joshua Focus][13] 说。“将灾备看作业务持续性的一个方面是种不同的视角。所有公司都要应对业务持续性,所以灾备应被视为业务持续性的一部分。” + +IT 部门需要将其需求书面化以确保适当的灾备和业务持续性计划。即使是你不知道如何着手,或尤其是这种时候,也是如此。正如一个系统管理员所言,“我喜欢有一个‘想法转储’,让所有计划、点子、改进措施毫无保留地提出来。(这)[对一类情况尤其有帮助,即当你提议变更][15],并付诸实施,接着 6 个月之后你警告过的状况就要来临。”现在你做好了一切准备并且可以开始讨论:“如同我们之前在 4 月讨论过的那样……” + +因此,当你的管理层对业务持续性计划回应道“嗐,碰到这种事的机会能有多大呢?”的时候你能做些什么呢?有个系统管理员称这也完全是管理层的正常行为。在这种糟糕的处境下,老练的系统管理员建议用书面形式把这些事情记录下来。记录应清楚表明你告知管理层需要采取的措施,且[他们拒绝采纳建议][16]。“总的来说就是有足够的书面材料能让他们搓成一根绳子上吊,”该系统管理员补充道。 + +如果那也不起作用,恢复一个被洪水淹没的数据中心的相关经验对你[找个新工作][17]是很有帮助的。 + +### 保护有形的基础设施 + +“[我们的办公室是幢摇摇欲坠的建筑][18],”飓风哈维重创休斯顿之后有个系统管理员提到。“我们盲目地进入那幢建筑,现场的基础设施糟透了。正是我们给那幢建筑里带去了最不想要的一滴水,现在基础设施整个都沉在水下了。” + +尽管如此,如果你想让数据中心继续运转——或在暴风雨过后恢复运转 —— 你需要确保该场所不仅能经受住你所在地区那些意料中的灾难,而且能经受住那些意料之外的灾难。一个旧金山的系统管理员知道为什么重要的是确保公司的服务器安置在可以承受里氏 7 级地震的建筑内。一家圣路易斯的公司知道如何应对龙卷风。但你应当为所有可能发生的事情做好准备:加州的龙卷风、密苏里州的地震,或[僵尸末日][19](给你在 IT 预算里增加一把链锯提供了充分理由)。 + +在休斯顿的情况下,[多数数据中心保持运转][20],因为它们是按照抵御暴风雨和洪水的标准建造的。[Data Foundry][21] 的首席技术官 Edward Henigin 说他们公司的数据中心之一,“专门建造的休斯顿 2 号的设计能抵御 5 级飓风的风速。这个场所的公共供电没有中断,我们得以避免切换到后备发电机。” + +那是好消息。坏消息是伴随着超级飓风桑迪于 2012 年登场,如果[你的数据中心没准备好应对洪水][22],你会陷入一个麻烦不断的世界。一个不能正常运转的数据中心 [Datagram][23] 服务的客户包括 Gawker、Gizmodo 和 Buzzfeed 等知名网站。 + +当然,有时候你什么也做不了。正如某个波多黎各圣胡安的系统管理员在飓风厄玛扫过后悲伤地写到,“发电机没油了。服务器机房靠电池在运转但是没有(空调)。[永别了,服务器][24]。”由于 MPLSMultiprotocol Lable Switching 线路亦中断,该系统管理员没法切换到灾备措施:“多么充实的一天。” + +总而言之,IT 专业人士需要了解他们所处的地区,了解他们面临的风险并将他们的服务器安置在能抵御当地自然灾害的数据中心内。 + +### 关于云的争议 + +当暴风雨席卷一切时避免 IT 数据中心失效的最佳方法就是确保灾备数据中心在其他地方。选择地点时需要审慎的决策。你的灾备数据中心不应在会被同一场自然灾害影响到的地域region;你的资源应安置在多个可用区availability zone内。考虑一下主备数据中心位于一场地震中的同一条断层带上,或是主备数据中心易于受互通河道导致的洪灾影响这类情况。 + +有些系统管理员[利用云作为冗余设施][25]。例如,总是用微软 Azure 云存储服务保存副本以确保持久性和高可用性。根据你的选择,Azure 复制功能将你的数据要么拷贝到同一个数据中心要么拷贝到另一个数据中心。多数公有云提供类似的自动备份服务以确保数据安全,不论你的数据中心发生什么情况——除非你的云服务供应商全部设施都在暴风雨的行进路径上。 + +昂贵么?是的。跟业务中断 1、2 天一样昂贵么?并非如此。 + +信不过公有云?可以考虑 colocolocation 服务。有了 colo,你依旧拥有你的硬件,运行你自己的应用,但这些硬件可以远离麻烦。例如飓风哈维期间,一家公司“虚拟地”将它的资源从休斯顿搬到了其位于德克萨斯奥斯汀的 colo。但是那些本地数据中心和 colo 场所需要准备好应对灾难;这点是你选择场所时要考虑的一个因素。举个例子,一个寻找 colo 场所的西雅图系统管理员考虑的“全都是抗震和旱灾应对措施(加固的地基以及补给冷却系统的运水卡车)。” + +### 周围一片黑暗时 + +正如 Forrester Research 的分析师 Rachel Dines 在一份为[灾备期刊][27]所做的调查中报告的那样,宣布的灾难中[最普遍的原因就是断电][26]。尽管你能应对一般情况下的断电,飓风、火灾和洪水的考验会超越设备的极限。 + +某个系统管理员挖苦式的计划是什么呢?“趁 UPS 完蛋之前把你能关的机器关掉,不能关的就让它崩溃咯。然后,[喝个痛快直到供电恢复][28]。” + +在 2016 年德尔塔和西南航空停电事故之后,IT 员工推动的一个更加严肃的计划是由一个有管理的服务供应商为其客户[部署不间断电源][29]:“对于至关重要的部分,在供电中断时我们结合使用简单网络管理协议SNMP信令和 PowerChute 网络关机PowerChute Nrework Shutdown客户端来关闭设备。至于重新开机,那取决于客户。有些是自动启动,有些则需要人工干预。” + +另一种做法是用来自两个供电所的供电线路支持数据中心。例如,[西雅图威斯汀大厦数据中心][30]有来自不同供电所的多路 13.4 千伏供电线路,以及多个 480 伏三相变电箱。 + +预防严重断电的系统不是“通用的”设备。系统管理员应当[为数据中心请求一台定制的柴油发电机][31]。除了按你特定的需求调整,发电机必须能迅速跳至全速运转并承载全部电力负荷而不致影响系统负载性能。” + +这些发电机也必须加以保护。例如,将你的发电机安置在泛洪区的一楼就不是个聪明的主意。位于纽约百老街Broad street的数据中心在超级飓风桑迪期间就是类似情形,备用发电机的燃料油桶在地下室 —— 并且被水淹了。尽管一场[“人力接龙”用容量 5 加仑的水桶将柴油输送到 17 段楼梯之上的发电机][32]使 [Peer 1 Hosting][33] 得以继续运营,但这不是一个切实可行的业务持续计划。 + +正如多数数据中心专家所知那样,如果你有时间 —— 假设一个飓风离你有一天的距离 —— 确保你的发电机正常工作,加满油,准备好当供电线路被刮断时立即开启,不管怎样你之前应当每月测试你的发电机。你之前是那么做的,是吧?是就好! + +### 测试你对备份的信心 + +普通用户几乎从不备份,检查备份是否实际完好的就更少了。系统管理员对此更加了解。 + +有些 [IT 部门在寻求将他们的备份迁移到云端][34]。但有些系统管理员仍对此不买账 —— 他们有很好的理由。最近有人报告,“在用了整整 5 天[从亚马逊 Glacier 恢复了(400 GB)数据][35]之后,我欠了亚马逊将近 200 美元的传输费,并且(我还是)处于未完全恢复状态,还差大约 100 GB 文件。” + +结果是有些系统管理员依然喜欢磁带备份。磁带肯定不够时髦,但正如操作系统专家 Andrew S. Tanenbaum 说的那样,“[永远不要低估一辆装满磁带在高速上飞驰的旅行车的带宽][36]。” + +目前每盘磁带可以存储 10 TB 数据;有的进行中的实验可在磁带上存储高达 200 TB 数据。诸如[线性磁带文件系统][37]Linear Tape File System之类的技术允许你象访问网络硬盘一样读取磁带数据。 + +然而对许多人而言,磁带[绝对是最后选择的手段][38]。没关系,因为备份应该有大量的可选方案。在这种情况下,一个系统管理员说到,“故障时我们会用这些方法(恢复备份):(Windows)服务器层面的 VSS (Volume Shadow Storage)快照,存储区域网络SAN层面的卷快照,以及存储区域网络层面的异地归档快照。但是万一有什么事情发生并摧毁了我们的虚拟机,存储区域网络和备份存储区域网络,我们还是可以取回磁带并恢复数据。” + +当麻烦即将到来时,可使用副本工具如 [Veeam][39],它会为你的服务器创建一个虚拟机副本。若出现故障,副本会自动启动。没有麻烦,没有手忙脚乱,正如某个系统管理员在这个流行的系统管理员帖子中所说,“[我爱你 Veeam][40]。” + +### 网络?什么网络? + +当然,如果员工们无法触及他们的服务,没有任何云、colo 和远程数据中心能帮到你。你不需要一场自然灾害来证明冗余互联网连接的正确性。只需要一台挖断线路的挖掘机或断掉的光缆就能让你在工作中渡过糟糕的一天。 + +“理想状态下”,某个系统管理员明智地观察到,“你应该有[两路互联网接入线路连接到有独立基础设施的两个 ISP][41]。例如,你不希望两个 ISP 都依赖于同一根光缆。你也不希望采用两家本地 ISP,并发现他们的上行带宽都依赖于同一家骨干网运营商。” + +聪明的系统管理员知道他们公司的互联网接入线路[必须是商业级别的][43],带有服务等级协议service-level agreement(SLA),其中包含“修复时间”条款。或者更好的是采用互联网接入专线dedicated Internet access。技术上这与任何其他互联网接入方式没有区别。区别在于互联网接入专线不是一种“尽力而为”的接入方式,而是你会得到明确规定的专供你使用的带宽并附有服务等级协议。这种专线不便宜,但正如一句格言所说的那样,“速度、可靠性、便宜,只能挑两个。”当你的业务跑在这条线路上并且一场暴风雨即将来袭,“可靠性”必须是你挑的两个之一。 + +### 晴空重现之时 + +你没法准备应对所有自然灾害,但你可以为其中很多做好计划。有一个深思熟虑且经过测试的灾备和业务持续计划,并逐字逐句严格执行,当竞争对手溺毙的时候,你的公司可以幸存下来。 + +### 系统管理员对抗自然灾害:给领导者的教训 + + * 你的 IT 员工得说多少次:不要仅仅备份,还得测试备份? + * 没电就没公司。确保你的服务器有足够的应急电源来满足业务需要,并确保它们能正常工作。 + * 如果你的公司在一场自然灾害中幸存下来,或者避开了灾害,明智的系统管理员知道这就是向管理层申请被他们推迟的灾备预算的时候了。因为下次你就未必有这么幸运了。 + + +-------------------------------------------------------------------------------- + +via: https://www.hpe.com/us/en/insights/articles/it-disaster-recovery-sysadmins-vs-natural-disasters-1711.html + +作者:[Steven-J-Vaughan-Nichols][a] +译者:[0x996](https://github.com/0x996) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.hpe.com/us/en/insights/contributors/steven-j-vaughan-nichols.html +[1]:https://www.hpe.com/us/en/insights/articles/what-is-disaster-recovery-really-1704.html +[2]:https://www.reddit.com/r/sysadmin/comments/6wricr/dear_houston_tx_sysadmins/ +[3]:https://www.reddit.com/r/sysadmin/comments/6wricr/dear_houston_tx_sysadmins/dma6gse/ +[4]:https://disastersafety.org/wp-content/uploads/open-for-business-english.pdf +[5]:https://www.fema.gov/protecting-your-businesses +[6]:http://drbenchmark.org/about-us/our-council/ +[7]:https://www.prnewswire.com/news-releases/global-benchmark-study-reveals-73-of-companies-are-unprepared-for-disaster-recovery-248359051.html +[8]:https://www.reddit.com/r/sysadmin/comments/3cob1k/what_does_your_disaster_recovery_plan_look_like/csxh8sn/ +[9]:https://www.hpe.com/us/en/resources/servers/datacenter-trends-challenges.html?jumpid=in_insights~510287587~451research_datacenter~sjvnSysadmin +[10]:http://www.theregister.co.uk/2015/07/12/surviving_hurricane_katrina +[11]:https://theprepared.com/guides/beginners-guide-amateur-ham-radio-preppers/ +[12]:http://www.npr.org/2017/09/29/554600989/amateur-radio-operators-stepped-in-to-help-communications-with-puerto-rico +[13]:http://www8.hp.com/us/en/software/joshua-brusse.html +[14]:https://www.microfocus.com/ +[15]:https://www.reddit.com/r/sysadmin/comments/6wricr/dear_houston_tx_sysadmins/dma87xv/ +[16]:https://www.hpe.com/us/en/insights/articles/my-boss-asked-me-to-do-what-how-to-handle-worrying-work-requests-1710.html +[17]:https://www.hpe.com/us/en/insights/articles/sysadmin-survival-guide-1707.html +[18]:https://www.reddit.com/r/sysadmin/comments/6wk92q/any_houston_admins_executing_their_dr_plans_this/dm8xj0q/ +[19]:https://community.spiceworks.com/how_to/1243-ensure-your-dr-plan-is-ready-for-a-zombie-apocolypse +[20]:http://www.datacenterdynamics.com/content-tracks/security-risk/houston-data-centers-withstand-hurricane-harvey/98867.article +[21]:https://www.datafoundry.com/ +[22]:http://www.datacenterknowledge.com/archives/2012/10/30/major-flooding-nyc-data-centers +[23]:https://datagram.com/ +[24]:https://www.reddit.com/r/sysadmin/comments/6yjb3p/shutting_down_everything_blame_irma/ +[25]:https://www.hpe.com/us/en/insights/articles/everything-you-need-to-know-about-clouds-and-hybrid-it-1701.html +[26]:https://www.drj.com/images/surveys_pdf/forrester/2011Forrester_survey.pdf +[27]:https://www.drj.com +[28]:https://www.reddit.com/r/sysadmin/comments/4x3mmq/datacenter_power_failure_procedures_what_do_yours/d6c71p1/ +[29]:https://www.reddit.com/r/sysadmin/comments/4x3mmq/datacenter_power_failure_procedures_what_do_yours/ +[30]:https://cloudandcolocation.com/datacenters/the-westin-building-seattle-data-center/ +[31]:https://www.techrepublic.com/article/what-to-look-for-in-a-data-center-backup-generator/ +[32]:http://www.datacenterknowledge.com/archives/2012/10/31/peer-1-mobilizes-diesel-bucket-brigade-at-75-broad +[33]:https://www.cogecopeer1.com/ +[34]:https://www.reddit.com/r/sysadmin/comments/7a6m7n/aws_glacier_archival/ +[35]:https://www.reddit.com/r/sysadmin/comments/63mypu/the_dangers_of_cloudberry_and_amazon_glacier_how/ +[36]:https://en.wikiquote.org/wiki/Andrew_S._Tanenbaum +[37]:http://www.snia.org/ltfs +[38]:https://www.reddit.com/r/sysadmin/comments/5visaq/backups_how_many_of_you_still_have_tapes/de2d0qm/ +[39]:https://helpcenter.veeam.com/docs/backup/vsphere/failover.html?ver=95 +[40]:https://www.reddit.com/r/sysadmin/comments/5rttuo/i_love_you_veeam/ +[41]:https://www.reddit.com/r/sysadmin/comments/5rmqfx/ars_surviving_a_cloudbased_disaster_recovery_plan/dd90auv/ +[42]:https://www.hpe.com/us/en/insights/articles/how-do-you-evaluate-cloud-service-agreements-and-slas-very-carefully-1705.html +[43]:http://www.e-vergent.com/what-is-dedicated-internet-access/ diff --git a/published/201908/20171216 Sysadmin 101- Troubleshooting.md b/published/201908/20171216 Sysadmin 101- Troubleshooting.md new file mode 100644 index 0000000000..0beb6eeb67 --- /dev/null +++ b/published/201908/20171216 Sysadmin 101- Troubleshooting.md @@ -0,0 +1,138 @@ +系统管理员入门:排除故障 +====== + +![](https://img.linux.net.cn/data/attachment/album/201908/06/100659pox8xkkr8zek888r.jpg) + +我通常会严格保持此博客的技术性,将观察、意见等内容保持在最低限度。但是,这篇和接下来的几篇文章将介绍刚进入系统管理/SRE/系统工程师/sysops/devops-ops(无论你想称自己是什么)角色的常见的基础知识。 + +请跟我来! + +> “我的网站很慢!” + +我只是随机选择了本文的问题类型,这也可以应用于任何与系统管理员相关的故障排除。我并不是要炫耀那些可以发现最多的信息的最聪明的“金句”。它也不是一个详尽的、一步步指导的、并在最后一个方框中导向“利润”一词的“流程图”。 + +我会通过一些例子展示常规的方法。 + +示例场景仅用于说明本文目的。它们有时会做一些不适用于所有情况的假设,而且肯定会有很多读者在某些时候说“哦,但我觉得你会发现……”。 + +但那可能会让我们错失重点。 + +十多年来,我一直在从事于支持工作,或在支持机构工作,有一件事让我一次又一次地感到震惊,这促使我写下了这篇文章。 + +**有许多技术人员在遇到问题时的本能反应,就是不管三七二十一去尝试可能的解决方案。** + +*“我的网站很慢,所以”,* + +* 我将尝试增大 `MaxClients`/`MaxRequestWorkers`/`worker_connections` +* 我将尝试提升 `innodb_buffer_pool_size`/`effective_cache_size` +* 我打算尝试启用 `mod_gzip`(遗憾的是,这是真实的故事) + +*“我曾经看过这个问题,它是因为某种原因造成的 —— 所以我估计还是这个原因,它应该能解决这个问题。”* + +这浪费了很多时间,并会让你在黑暗中盲目乱撞,胡乱鼓捣。 + +你的 InnoDB 的缓冲池也许达到 100% 的利用率,但这可能只是因为有人运行了一段时间的一次性大型报告导致的。如果没有排除这种情况,那你就是在浪费时间。 + +### 开始之前 + +在这里,我应该说明一下,虽然这些建议同样适用于许多角色,但我是从一般的支持系统管理员的角度来撰写的。在一个成熟的内部组织中,或与规模较大的、规范管理的或“企业级”客户合作时,你通常会对一切都进行检测、测量、绘制、整理(甚至不是文字),并发出警报。那么你的方法也往往会有所不同。让我们在这里先忽略这种情况。 + +如果你没有这种东西,那就随意了。 + +### 澄清问题 + +首先确定实际上是什么问题。“慢”可以是多种形式的。是收到第一个字节的时间吗?从糟糕的 Javascript 加载和每页加载要拉取 15 MB 的静态内容,这是一个完全不同类型的问题。是慢,还是比通常慢?这是两个非常不同的解决方案! + +在你着手做某事之前,确保你知道实际报告和遇到的问题。找到问题的根源通常很困难,但即便找不到也必须找到问题本身。 + +否则,这相当于系统管理员带着一把刀去参加枪战。 + +### 唾手可得 + +首次登录可疑服务器时,你可以查找一些常见的嫌疑对象。事实上,你应该这样做!每当我登录到服务器时,我都会发出一些命令来快速检查一些事情:我们是否发生了页交换(`free` / `vmstat`),磁盘是否繁忙(`top` / `iostat` / `iotop`),是否有丢包(`netstat` / `proc` / `net` / `dev`),是否处于连接数过多的状态(`netstat`),有什么东西占用了 CPU(`top`),谁在这个服务器上(`w` / `who`),syslog 和 `dmesg` 中是否有引人注目的消息? + +如果你从 RAID 控制器得到 2000 条抱怨直写式缓存没有生效的消息,那么继续进行是没有意义的。 + +这用不了半分钟。如果什么都没有引起你的注意 —— 那么继续。 + +### 重现问题 + +如果某处确实存在问题,并且找不到唾手可得的信息。 + +那么采取所有步骤来尝试重现问题。当你可以重现该问题时,你就可以观察它。**当你能观察到时,你就可以解决。**如果在第一步中尚未显现出或覆盖了问题所在,询问报告问题的人需要采取哪些确切步骤来重现问题。 + +对于由太阳耀斑或只能运行在 OS/2 上的客户端引起的问题,重现并不总是可行的。但你的第一个停靠港应该是至少尝试一下!在一开始,你所知道的是“某人认为他们的网站很慢”。对于那些人,他们可能还在用他们的 GPRS 手机,也可能正在安装 Windows 更新。你在这里挖掘得再深也是浪费时间。 + +尝试重现! + +### 检查日志 + +我对于有必要包括这一点感到很难过。但是我曾经看到有人在运行 `tail /var/log/...` 之后几分钟就不看了。大多数 *NIX 工具都特别喜欢记录日志。任何明显的错误都会在大多数应用程序日志中显得非常突出。检查一下。 + +### 缩小范围 + +如果没有明显的问题,但你可以重现所报告的问题,那也很棒。所以,你现在知道网站是慢的。现在你已经把范围缩小到:浏览器的渲染/错误、应用程序代码、DNS 基础设施、路由器、防火墙、网卡(所有的)、以太网电缆、负载均衡器、数据库、缓存层、会话存储、Web 服务器软件、应用程序服务器、内存、CPU、RAID 卡、磁盘等等。 + +根据设置添加一些其他可能的罪魁祸首。它们也可能是 SAN,也不要忘记硬件 WAF!以及…… 你明白我的意思。 + +如果问题是接收到第一个字节的时间,你当然会开始对 Web 服务器去应用上已知的修复程序,就是它响应缓慢,你也觉得几乎就是它,对吧?但是你错了! + +你要回去尝试重现这个问题。只是这一次,你要试图消除尽可能多的潜在问题来源。 + +你可以非常轻松地消除绝大多数可能的罪魁祸首:你能从服务器本地重现问题吗?恭喜,你刚刚节省了自己必须尝试修复 BGP 路由的时间。 + +如果不能,请尝试使用同一网络上的其他计算机。如果可以的话,至少你可以将防火墙移到你的嫌疑人名单上,(但是要注意一下那个交换机!) + +是所有的连接都很慢吗?虽然服务器是 Web 服务器,但并不意味着你不应该尝试使用其他类型的服务进行重现问题。[netcat][1] 在这些场景中非常有用(但是你的 SSH 连接可能会一直有延迟,这可以作为线索)! 如果这也很慢,你至少知道你很可能遇到了网络问题,可以忽略掉整个 Web 软件及其所有组件的问题。用这个知识(我不收 200 美元)再次从顶部开始,按你的方式由内到外地进行! + +即使你可以在本地复现 —— 仍然有很多“因素”留下。让我们排除一些变量。你能用普通文件重现它吗? 如果 `i_am_a_1kb_file.html` 很慢,你就知道它不是数据库、缓存层或 OS 以外的任何东西和 Web 服务器本身的问题。 + +你能用一个需要解释或执行的 `hello_world.(py|php|js|rb..)` 文件重现问题吗?如果可以的话,你已经大大缩小了范围,你可以专注于少数事情。如果 `hello_world` 可以马上工作,你仍然学到了很多东西!你知道了没有任何明显的资源限制、任何满的队列或在任何地方卡住的 IPC 调用,所以这是应用程序正在做的事情或它正在与之通信的事情。 + +所有页面都慢吗?或者只是从第三方加载“实时分数数据”的页面慢? + +**这可以归结为:你仍然可以重现这个问题所涉及的最少量的“因素”是什么?** + +我们的示例是一个缓慢的网站,但这同样适用于几乎所有问题。邮件投递?你能在本地投递吗?能发给自己吗?能发给<常见的服务提供者>吗?使用小的、纯文本的消息进行测试。尝试直到遇到 2MB 拥堵时。使用 STARTTLS 和不使用 STARTTLS 呢?按你的方式由内到外地进行! + +这些步骤中的每一步都只需要几秒钟,远远快于实施大多数“可能的”修复方案。 + +### 隔离观察 + +到目前为止,当你去除特定组件时无法重现问题时,你可能已经偶然发现了问题所在。 + +但如果你还没有,或者你仍然不知道**为什么**:一旦你找到了一种方法来重现问题,你和问题之间的“东西”(某个技术术语)最少,那么就该开始隔离和观察了。 + +请记住,许多服务可以在前台运行和/或启用调试。对于某些类别的问题,执行此操作通常非常有帮助。 + +这也是你的传统武器库发挥作用的地方。`strace`、`lsof`、`netstat`、`GDB`、`iotop`、`valgrind`、语言分析器(cProfile、xdebug、ruby-prof ……)那些类型的工具。 + +一旦你走到这一步,你就很少能摆脱剖析器或调试器了。 + +[strace][2] 通常是一个非常好的起点。 + +你可能会注意到应用程序停留在某个连接到端口 3306 的套接字文件描述符上的特定 `read()` 调用上。你会知道该怎么做。 + +转到 MySQL 并再次从顶部开始。显而易见:“等待某某锁”、死锁、`max_connections` ……进而:是所有查询?还是只写请求?只有某些表?还是只有某些存储引擎?等等…… + +你可能会注意到调用外部 API 资源的 `connect()` 需要五秒钟才能完成,甚至超时。你会知道该怎么做。 + +你可能会注意到,在同一对文件中有 1000 个调用 `fstat()` 和 `open()` 作为循环依赖的一部分。你会知道该怎么做。 + +它可能不是那些特别的东西,但我保证,你会发现一些东西。 + +如果你只是从这一部分学到一点,那也不错;学习使用 `strace` 吧!**真的**学习它,阅读整个手册页。甚至不要跳过历史部分。`man` 每个你还不知道它做了什么的系统调用。98% 的故障排除会话以 `strace` 而终结。 + +--------------------------------------------------------------------- + +via: http://northernmost.org/blog/troubleshooting-101/index.html + +作者:[Erik Ljungstrom][a] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://northernmost.org +[1]:http://nc110.sourceforge.net/ +[2]:https://linux.die.net/man/1/strace diff --git a/published/201908/20180104 How allowing myself to be vulnerable made me a better leader.md b/published/201908/20180104 How allowing myself to be vulnerable made me a better leader.md new file mode 100644 index 0000000000..f52b693856 --- /dev/null +++ b/published/201908/20180104 How allowing myself to be vulnerable made me a better leader.md @@ -0,0 +1,56 @@ +怎样通过示弱增强领导力 +====== +![](https://img.linux.net.cn/data/attachment/album/201908/25/052430b01hc00qrcz99p9w.jpg) + +传统观念中的领导者总是强壮、大胆、果决的。我也确实见过一些拥有这些特点的领导者。但更多时候,领导者也许看起来比传统印象中的领导者要更脆弱些,他们内心有很多这样的疑问:我的决策正确吗?我真的适合这个职位吗?我有没有在做最该做的事情? + +解决这些问题的方法是把问题说出来。把问题憋在心里只会助长它们,一名开明的领导者更倾向于把自己的脆弱之处暴露出来,这样我们才能从有过相同经验的人那里得到慰藉。 + +为了证明这个观点,我来讲一个故事。 + +### 一个扰人的想法 + +假如你在教育领域工作,你会发现发现大家更倾向于创造[一个包容性的环境][1] —— 一个鼓励多样性繁荣发展的环境。长话短说,我一直以来都认为自己是出于营造包容性环境的考量,而进行的“多样性雇佣”,意思就是人事雇佣我看重的是我的性别而非能力,这个想法一直困扰着我。随之而来的开始自我怀疑:我真的是这个岗位的最佳人选吗?还是只是因为我是个女人?许多年来,我都认为公司雇佣我是因为我的能力最好。但如今却发现,对那些雇主们来说,与我的能力相比,他们似乎更关注我的性别。 + +我开解自己:我到底是因为什么被雇佣并不重要,我知道我是这个职位的最佳人选而且我会用实际行动去证明。我工作很努力,达到过预期,也犯过错,也收获了很多,我做了一个老板想要自己雇员做的一切事情。 + +但那个“多样性雇佣”问题的阴影并未因此散去。我无法摆脱它,甚至回避一切与之相关的话题如蛇蝎,最终意识到自己拒绝谈论它意味着我能做的只有直面它。如果我继续回避这个问题,早晚会影响到我的工作,这是我最不希望看到的。 + +### 倾诉心中的困扰 + +直接谈论多样性和包容性这个话题有点尴尬,在进行自我剖析之前有几个问题需要考虑: + + * 我们能够相信我们的同事,能够在他们面前表露脆弱吗? + * 一个团队的领导者在同事面前表露脆弱合适吗? + * 如果我玩脱了呢?会不会影响我的工作? + +于是我和一位主管在午餐时间进行了一场小型的 Q&A 会议,这位主管负责着集团很多领域,并且以正直坦率著称。一位女同事问他,“我是因为多样性才被招进来的吗?”,他停下手头工作花了很长时间和一屋子女性员工解释了这件事,我不想复述他讲话的全部内容,我只说对我触动最大的几句:如果你知道自己能够胜任这个职位,并且面试很顺利,那么不必质疑招聘的结果。每个怀疑自己是因为多样性雇佣进公司的人私下都有自己的问题,你不必重蹈他们的覆辙。 + +完毕。 + +我很希望我能由衷地说我放下这个问题了,但事实上我没有。这问题挥之不去:万一我就是被破格录取的那个呢?万一我就是多样性雇佣的那个呢?我认识到我不能避免地反复思考这些问题。 + +几周后我和这位主管进行了一次一对一谈话,在谈话的末尾,我提到作为一位女性,自己很欣赏他那番对于多样性和包容性的坦率发言。当得知领导很有交流的意愿时,谈论这种话题变得轻松许多。我也向他提出了最初的问题,“我是因为多样性才被雇佣的吗?”,他回答得很干脆:“我们谈论过这个问题。”谈话后我意识到,我急切地想找人谈论这些需要勇气的问题,其实只是因为我需要有一个人的关心、倾听和好言劝说。 + +但正因为我有展露脆弱的勇气——去和那位主管谈论我的问题——我承受我的秘密困扰的能力提高了。我觉得身轻如燕,我开始组织各种对话,主要围绕着内隐偏见及其引起的一系列问题、怎样增加自身的包容性和多样性的表现等。通过这些经历,我发现每个人对于多样性都有不同的认识,如果我只囿于自己的秘密,我不会有机会组织参与这些精彩的对话。 + +我有谈论内心脆弱的勇气,我希望你也有。 + +我们可以谈谈那些影响我们领导力的秘密,这样从任何意义上来说,我们距离成为一位开明的领导就近了一些。那么适当示弱有帮助你成为更好的领导者吗? + +### 作者简介 + +Angela Robertson 是微软的一名高管。她和她的团队对社群互助有着极大热情,并参与开源工作。在加入微软之前,Angela 就职于红帽公司。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/12/how-allowing-myself-be-vulnerable-made-me-better-leader + +作者:[Angela Robertson][a] +译者:[Valoniakim](https://github.com/Valoniakim) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/arobertson98 +[1]:https://opensource.com/open-organization/17/9/building-for-inclusivity diff --git a/published/201908/20180116 Command Line Heroes- Season 1- OS Wars.md b/published/201908/20180116 Command Line Heroes- Season 1- OS Wars.md new file mode 100644 index 0000000000..6858132c13 --- /dev/null +++ b/published/201908/20180116 Command Line Heroes- Season 1- OS Wars.md @@ -0,0 +1,135 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11251-1.html) +[#]: subject: (Command Line Heroes: Season 1: OS Wars) +[#]: via: (https://www.redhat.com/en/command-line-heroes/season-1/os-wars-part-1) +[#]: author: (redhat https://www.redhat.com) + +《代码英雄》第一季(1):操作系统战争(上) +====== + +> 代码英雄讲述了开发人员、程序员、黑客、极客和开源反叛者如何彻底改变技术前景的真实史诗故事。 + +![](https://www.redhat.com/files/webux/img/bandbg/bkgd-clh-ep1-2000x950.png) + +本文是《[代码英雄](https://www.redhat.com/en/command-line-heroes)》系列播客[第一季(1):操作系统战争(上)](https://www.redhat.com/en/command-line-heroes/season-1/os-wars-part-1) 的[音频](https://dts.podtrac.com/redirect.mp3/audio.simplecast.com/f7670e99.mp3)脚本。 + +**Saron Yitbarek:**有些故事如史诗般,惊险万分,在我脑海中似乎出现了星球大战电影开头的爬行文字。你知道的,就像—— + +配音:“第一集,操作系统大战” + +**Saron Yitbarek:**是的,就像那样子。 + +配音:这是一个局势紧张加剧的时期。比尔·盖茨Bill Gates史蒂夫·乔布斯Steve Jobs的帝国发起了一场无可避免的专有软件之战。[00:00:30] 盖茨与 IBM 结成了强大的联盟,而乔布斯则拒绝了对它的硬件和操作系统开放授权。他们争夺统治地位的争斗在一场操作系统战争中席卷了整个银河系。与此同时,这些帝王们所不知道的偏远之地,开源的反叛者们开始集聚。 + +**Saron Yitbarek:**好吧。这也许有点戏剧性,但当我们谈论上世纪八九十年代和 2000 年代的操作系统之争时,这也不算言过其实。*[00:01:00]* 确实曾经发生过一场史诗级的统治之战。史蒂夫·乔布斯和比尔·盖茨确实掌握着数十亿人的命运。掌控了操作系统,你就掌握了绝大多数人使用计算机的方式、互相通讯的方式、获取信息的方式。我可以一直罗列下去,不过你知道我的意思。掌握了操作系统,你就是帝王。 + +我是 Saron Yitbarek,你现在收听的是代码英雄,一款红帽公司原创的博客节目。*[00:01:30]* 你问,什么是代码英雄Command Line Hero?嗯,如果你愿意创造而不仅仅是使用,如果你相信开发者拥有构建美好未来的能力,如果你希望拥有一个大家都有权利表达科技如何塑造生活的世界,那么你,我的朋友,就是一位代码英雄。在本系列节目中,我们将为你带来那些“白码起家”(LCTT 译注:原文是 “from the command line up”,应该是演绎自 “from the ground up”——白手起家)改变技术的程序员故事。*[00:02:00]* 那么我是谁,凭什么指导你踏上这段艰苦的旅程?Saron Yitbarek 是哪根葱?嗯,事实上我觉得我跟你差不多。我是一名面向初学者的开发人员,我做的任何事都依赖于开源软件,我的世界就是如此。通过在博客中讲故事,我可以跳出无聊的日常工作,鸟瞰全景,希望这对你也一样有用。 + +我迫不及待地想知道,开源技术从何而来?我的意思是,我对林纳斯·托瓦兹Linus Torvalds和 Linux^® 的荣耀有一些了解,*[00:02:30]* 我相信你也一样,但是说真的,开源并不是一开始就有的,对吗?如果我想发自内心的感激这些最新、最棒的技术,比如 DevOps 和容器之类的,我感觉我对那些早期的开发者缺乏了解,我有必要了解这些东西来自何处。所以,让我们暂时先不用担心内存泄露和缓冲溢出。我们的旅程将从操作系统之战开始,这是一场波澜壮阔的桌面控制之战。*[00:03:00]* 这场战争亘古未有,因为:首先,在计算机时代,大公司拥有指数级的规模优势;其次,从未有过这么一场控制争夺战是如此变化多端。比尔·盖茨和史蒂夫·乔布斯? 他们也不知道结果会如何,但是到目前为止,这个故事进行到一半的时候,他们所争夺的所有东西都将发生改变、进化,最终上升到云端。 + +*[00:03:30]* 好的,让我们回到 1983 年的秋季。还有六年我才出生。那时候的总统还是罗纳德·里根Ronald Reagan,美国和苏联扬言要把地球拖入核战争之中。在檀香山(火奴鲁鲁)的市政中心正在举办一年一度的苹果公司销售会议。一群苹果公司的员工正在等待史蒂夫·乔布斯上台。他 28 岁,热情洋溢,看起来非常自信。乔布斯很严肃地对着麦克风说他邀请了三个行业专家来就软件进行了一次小组讨论。*[00:04:00]* 然而随后发生的事情你肯定想不到。超级俗气的 80 年代音乐响彻整个房间。一堆多彩灯管照亮了舞台,然后一个播音员的声音响起- + +**配音:**女士们,先生们,现在是麦金塔软件的约会游戏时间。 + +**Saron Yitbarek:**乔布斯的脸上露出一个大大的笑容,台上有三个 CEO 都需要轮流向他示好。这基本上就是 80 年代钻石王老五,不过是科技界的。*[00:04:30]* 两个软件大佬讲完话后,然后就轮到第三个人讲话了。仅此而已不是吗?是的。新面孔比尔·盖茨带着一个大大的遮住了半张脸的方框眼镜。他宣称在 1984 年,微软的一半收入将来自于麦金塔软件。他的这番话引来了观众热情的掌声。*[00:05:00]* 但是他们不知道的是,在一个月后,比尔·盖茨将会宣布发布 Windows 1.0 的计划。你永远也猜不到乔布斯正在跟苹果未来最大的敌人打情骂俏。但微软和苹果即将经历科技史上最糟糕的婚礼。他们会彼此背叛、相互毁灭,但又深深地、痛苦地捆绑在一起。 + +**James Allworth:***[00:05:30]* 我猜从哲学上来讲,一个更理想化、注重用户体验高于一切,是一个一体化的组织,而微软则更务实,更模块化 —— + +**Saron Yitbarek:**这位是 James Allworth。他是一位多产的科技作家,曾在苹果零售的企业团队工作。注意他给出的苹果的定义,一个一体化的组织,那种只对自己负责的公司,一个不想依赖别人的公司,这是关键。 + +**James Allworth:***[00:06:00]* 苹果是一家一体化的公司,它希望专注于令人愉悦的用户体验,这意味着它希望控制整个技术栈以及交付的一切内容:从硬件到操作系统,甚至运行在操作系统上的应用程序。当新的创新、重要的创新刚刚进入市场,而你需要横跨软硬件,并且能够根据自己意愿和软件的革新来改变硬件时,这是一个优势。例如 ——, + +**Saron Yitbarek:***[00:06:30]* 很多人喜欢这种一体化的模式,并因此成为了苹果的铁杆粉丝。还有很多人则选择了微软。让我们回到檀香山的销售会议上,在同一场活动中,乔布斯向观众展示了他即将发布的超级碗广告。你可能已经亲眼见过这则广告了。想想乔治·奥威尔George Orwell的 《一九八四》。在这个冰冷、灰暗的世界里,无意识的机器人正在独裁者的投射凝视下徘徊。*[00:07:00]* 这些机器人就像是 IBM 的用户们。然后,代表苹果公司的漂亮而健美的安娅·梅杰Anya Major穿着鲜艳的衣服跑过大厅。她向着大佬们的屏幕猛地投出大锤,将它砸成了碎片。老大哥的咒语解除了,一个低沉的声音响起,苹果公司要开始介绍麦金塔了。 + +**配音:**这就是为什么现实中的 1984 跟小说《一九八四》不一样了。 + +Saron Yitbarek:是的,现在回顾那则广告,认为苹果是一个致力于解放大众的自由斗士的想法有点过分了。但这件事触动了我的神经。*[00:07:30]* Ken Segal 曾在为苹果制作这则广告的广告公司工作过。在早期,他为史蒂夫·乔布斯做了十多年的广告。 + +**Ken Segal:**1984 这则广告的风险很大。事实上,它的风险太大,以至于苹果公司在看到它的时候都不想播出它。你可能听说了史蒂夫喜欢它,但苹果公司董事会的人并不喜欢它。事实上,他们很愤怒,这么多钱被花在这么一件事情上,以至于他们想解雇广告代理商。*[00:08:00]* 史蒂夫则为我们公司辩护。 + +**Saron Yitbarek:**乔布斯,一如既往地,慧眼识英雄。 + +**Ken Segal:**这则广告在公司内、在业界内都引起了共鸣,成为了苹果产品的代表。无论人们那天是否有在购买电脑,它都带来了一种持续了一年又一年的影响,并有助于定义这家公司的品质:我们是叛军,我们是拿着大锤的人。 + +**Saron Yitbarek:***[00:08:30]* 因此,在争夺数十亿潜在消费者心智的过程中,苹果公司和微软公司的帝王们正在学着把自己塑造成救世主、非凡的英雄、一种对生活方式的选择。但比尔·盖茨知道一些苹果难以理解的事情。那就是在一个相互连接的世界里,没有人,即便是帝王,也不能独自完成任务。 + +*[00:09:00]* 1985 年 6 月 25 日。盖茨给当时的苹果 CEO John Scully 发了一份备忘录。那是一个迷失的年代。乔布斯刚刚被逐出公司,直到 1996 年才回到苹果。也许正是因为乔布斯离开了,盖茨才敢写这份东西。在备忘录中,他鼓励苹果授权制造商分发他们的操作系统。我想读一下备忘录的最后部分,让你们知道这份备忘录是多么的有洞察力。*[00:09:30]* 盖茨写道:“如果没有其他个人电脑制造商的支持,苹果现在不可能让他们的创新技术成为标准。苹果必须开放麦金塔的架构,以获得快速发展和建立标准所需的支持。”换句话说,你们不要再自己玩自己的了。你们必须有与他人合作的意愿。你们必须与开发者合作。 + +*[00:10:00]* 多年后你依然可以看到这条哲学思想,当微软首席执行官史蒂夫·鲍尔默Steve Ballmer上台做主题演讲时,他开始大喊:“开发者,开发者,开发者,开发者,开发者,开发者,开发者,开发者,开发者。”你懂我的意思了吧。微软喜欢开发人员。虽然目前(LCTT 译注:本播客发布于 2018 年初)他们不打算与这些开发人员共享源代码,但是他们确实想建立起整个合作伙伴生态系统。*[00:10:30]* 而当比尔·盖茨建议苹果公司也这么做时,如你可能已经猜到的,这个想法就被苹果公司抛到了九霄云外。他们的关系产生了间隙,五个月后,微软发布了 Windows 1.0。战争开始了。 + +> 开发者,开发者,开发者,开发者,开发者,开发者,开发者,开发者,开发者,开发者,开发者,开发者,开发者,开发者,开发者,开发者,开发者,开发者。 + +*[00:11:00]* 你正在收听的是来自红帽公司的原创播客《代码英雄》。本集是第一集,我们将回到过去,重温操作系统战争的史诗故事,我们将会发现,科技巨头之间的战争是如何为我们今天所生活的开源世界扫清道路的 + +好的,让我们先来个背景故事吧。如果你已经听过了,那么请原谅我,但它很经典。当时是 1979 年,史蒂夫·乔布斯开车去帕洛阿尔托Palo Alto施乐公园研究中心Xerox Park research center。*[00:11:30]* 那里的工程师一直在为他们所谓的图形用户界面开发一系列的元素。也许你听说过。它们有菜单、滚动条、按钮、文件夹和重叠的窗口。这是对计算机界面的一个美丽的新设想。这是前所未有的。作家兼记者 Steve Levy 会谈到它的潜力。 + +**Steven Levy:***[00:12:00]* 对于这个新界面来说,有很多令人激动的地方,它比以前的交互界面更友好,以前用的所谓的命令行 —— 你和电脑之间的交互方式跟现实生活中的交互方式完全不同。鼠标和电脑上的图像让你可以做到像现实生活中的交互一样,你可以像指向现实生活中的东西一样指向电脑上的东西。这让事情变得简单多了。你无需要记住所有那些命令。 + +**Saron Yitbarek:***[00:12:30]* 不过,施乐的高管们并没有意识到他们正坐在金矿上。一如既往地,工程师比主管们更清楚它的价值。因此那些工程师,当被要求向乔布斯展示所有这些东西是如何工作时,有点紧张。然而这是毕竟是高管的命令。乔布斯觉得,用他的话来说,“这个产品天才本来能够让施乐公司垄断整个行业,可是它最终会被公司的经营者毁掉,因为他们对产品的好坏没有概念。”*[00:13:00]* 这话有些苛刻,但是,乔布斯带着一卡车施乐高管错过的想法离开了会议。这几乎包含了他需要革新桌面计算体验的所有东西。1983 年,苹果发布了 Lisa 电脑,1984 年又发布了 Mac 电脑。这些设备的创意是抄袭自施乐公司的。 + +让我感兴趣的是,乔布斯对控诉他偷了图形用户界面的反应。他对此很冷静。他引用毕加索的话:“好的艺术家抄袭,伟大的艺术家偷窃。”他告诉一位记者,“我们总是无耻地窃取伟大的创意。”*[00:13:30]* 伟大的艺术家偷窃,好吧,我的意思是,我们说的并不是严格意义上的“偷窃”。没人拿到了专有的源代码并公然将其集成到他们自己的操作系统中去。这要更温和些,更像是创意的借用。这就难控制的多了,就像乔布斯自己即将学到的那样。传奇的软件奇才、真正的代码英雄 Andy Hertzfeld 就是麦金塔开发团队的最初成员。 + +**Andy Hertzfeld:***[00:14:00]* 是的,微软是我们的第一个麦金塔电脑软件合作伙伴。当时,我们并没有把他们当成是竞争对手。他们是苹果之外,我们第一家交付麦金塔电脑原型的公司。我通常每周都会和微软的技术主管聊一次。他们是第一个尝试我们所编写软件的外部团队。*[00:14:30]* 他们给了我们非常重要的反馈,总的来说,我认为我们的关系非常好。但我也注意到,在我与技术主管的交谈中,他开始问一些系统实现方面的问题,而他本无需知道这些,我觉得,他们想要复制麦金塔电脑。我很早以前就向史蒂夫·乔布斯反馈过这件事,但在 1983 年秋天,这件事达到了高潮。*[00:15:00]* 我们发现,他们在 1983 年 11 月的 COMDEX 上发布了 Windows,但却没有提前告诉我们。对此史蒂夫·乔布斯勃然大怒。他认为那是一种背叛。 + +**Saron Yitbarek:**随着新版 Windows 的发布,很明显,微软从苹果那里学到了苹果从施乐那里学来的所有想法。乔布斯很易怒。他的关于伟大艺术家如何偷窃的毕加索名言被别人学去了,而且恐怕盖茨也正是这么做的。*[00:15:30]* 据报道,当乔布斯怒斥盖茨偷了他们的东西时,盖茨回应道:“史蒂夫,我觉得这更像是我们都有一个叫施乐的富有邻居,我闯进他家偷电视机,却发现你已经偷过了”。苹果最终以窃取 GUI 的外观和风格为名起诉了微软。这个案子持续了好几年,但是在 1993 年,第 9 巡回上诉法院的一名法官最终站在了微软一边。*[00:16:00]* Vaughn Walker 法官宣布外观和风格不受版权保护。这是非常重要的。这一决定让苹果在无法垄断桌面计算的界面。很快,苹果短暂的领先优势消失了。以下是 Steven Levy 的观点。 + +**Steven Levy:**他们之所以失去领先地位,不是因为微软方面窃取了知识产权,而是因为他们无法巩固自己在上世纪 80 年代拥有的更好的操作系统的优势。坦率地说,他们的电脑索价过高。*[00:16:30]* 因此微软从 20 世纪 80 年代中期开始开发 Windows 系统,但直到 1990 年开发出的 Windows 3,我想,它才真正算是一个为黄金时期做好准备的版本,才真正可供大众使用。*[00:17:00]* 从此以后,微软能够将数以亿计的用户迁移到图形界面,而这是苹果无法做到的。虽然苹果公司有一个非常好的操作系统,但是那已经是 1984 年的产品了。 + +**Saron Yitbarek:**现在微软主导着操作系统的战场。他们占据了 90% 的市场份额,并且针对各种各样的个人电脑进行了标准化。操作系统的未来看起来会由微软掌控。此后发生了什么?*[00:17:30]* 1997 年,波士顿 Macworld 博览会上,你看到了一个几近破产的苹果,一个谦逊的多的史蒂夫·乔布斯走上舞台,开始谈论伙伴关系的重要性,特别是他们与微软的新型合作伙伴关系。史蒂夫·乔布斯呼吁双方缓和关系,停止火拼。微软将拥有巨大的市场份额。从表面看,我们可能会认为世界和平了。但当利益如此巨大时,事情就没那么简单了。*[00:18:00]* 就在苹果和微软在数十年的争斗中伤痕累累、最终败退到死角之际,一名 21 岁的芬兰计算机科学专业学生出现了。几乎是偶然地,他彻底改变了一切。 + +我是 Saron Yitbarek,这里是代码英雄。 + +正当某些科技巨头正忙着就专有软件相互攻击时,自由软件和开源软件的新领军者如雨后春笋般涌现。*[00:18:30]* 其中一位优胜者就是理查德·斯托尔曼Richard Stallman。你也许对他的工作很熟悉。他想要有自由软件和自由社会。这就像言论自由一样的自由free,而不是像免费啤酒一样的免费free。早在 80 年代,斯托尔曼就发现,除了昂贵的专有操作系统(如 UNIX)外,就没有其他可行的替代品。因此他决定自己做一个。斯托尔曼的自由软件基金会Free Software Foundation开发了 GNU,当然,它的意思是 “GNU's not UNIX”。它将是一个像 UNIX 一样的操作系统,但不包含所有的 UNIX 代码,而且用户可以自由共享。 + +*[00:19:00]* 为了让你体会到上世纪 80 年代自由软件概念的重要性,从不同角度来说拥有 UNIX 代码的两家公司,AT&T 贝尔实验室AT&T Bell Laboratories以及UNIX 系统实验室UNIX System Laboratories威胁将会起诉任何看过 UNIX 源代码后又创建自己操作系统的人。这些人是次级专利所属。*[00:19:30]* 用这两家公司的话来说,所有这些程序员都在“精神上受到了污染”,因为他们都见过 UNIX 代码。在 UNIX 系统实验室和伯克利软件设计公司Berkeley Software Design之间的一个著名的法庭案例中,有人认为任何功能类似的系统,即使它本身没有使用 UNIX 代码,也侵犯版权。Paul Jones 当时是一名开发人员。他现在是数字图书馆 ibiblio.org 的主管。 + +**Paul Jones:***[00:20:00]* 任何看过代码的人都受到了精神污染是他们的观点。因此几乎所有在安装有与 UNIX 相关操作系统的电脑上工作过的人以及任何在计算机科学部门工作的人都受到精神上的污染。因此,在 USENIX 的一年里,我们都得到了一写带有红色字母的白色小别针,上面写着“精神受到了污染”。我们很喜欢带着这些别针到处走,以表达我们跟着贝尔实验室混,因为我们的精神受到了污染。 + +**Saron Yitbarek:***[00:20:30]* 整个世界都被精神污染了。想要保持纯粹、保持事物的美好和专有的旧哲学正变得越来越不现实。正是在这被污染的现实中,历史上最伟大的代码英雄之一诞生了,他是一个芬兰男孩,名叫林纳斯·托瓦兹Linus Torvalds。如果这是《星球大战》,那么林纳斯·托瓦兹就是我们的卢克·天行者Luke Skywalker。他是赫尔辛基大学一名温文尔雅的研究生。*[00:21:00]* 有才华,但缺乏大志。典型的被逼上梁山的英雄。和其他年轻的英雄一样,他也感到沮丧。他想把 386 处理器整合到他的新电脑中。他对自己的 IBM 兼容电脑上运行的 MS-DOS 操作系统并不感冒,也负担不起 UNIX 软件 5000 美元的价格,而只有 UNIX 才能让他自由地编程。解决方案是托瓦兹在 1991 年春天基于 MINIX 开发了一个名为 Linux 的操作系统内核。他自己的操作系统内核。 + +**Steven Vaughan-Nichols:***[00:21:30]* 林纳斯·托瓦兹真的只是想找点乐子而已。 + +**Saron Yitbarek:**Steven Vaughan-Nichols 是 ZDNet.com 的特约编辑,而且他从科技行业出现以来就一直在写科技行业相关的内容。 + +**Steven Vaughan-Nichols:**当时有几个类似的操作系统。他最关注的是一个名叫 MINIX 的操作系统,MINIX 旨在让学生学习如何构建操作系统。林纳斯看到这些,觉得很有趣,但他想建立自己的操作系统。*[00:22:00]* 所以,它实际上始于赫尔辛基的一个 DIY 项目。一切就这样开始了,基本上就是一个大孩子在玩耍,学习如何做些什么。*[00:22:30]* 但不同之处在于,他足够聪明、足够执着,也足够友好,让所有其他人都参与进来,然后他开始把这个项目进行到底。27 年后,这个项目变得比他想象的要大得多。 + +**Saron Yitbarek:**到 1991 年秋季,托瓦兹发布了 10000 行代码,世界各地的人们开始评头论足,然后进行优化、添加和修改代码。*[00:23:00]* 对于今天的开发人员来说,这似乎很正常,但请记住,在那个时候,像这样的开放协作是对微软、苹果和 IBM 已经做的很好的整个专有系统的道德侮辱。随后这种开放性被奉若神明。托瓦兹将 Linux 置于 GNU 通用公共许可证(GPL)之下。曾经保障斯托尔曼的 GNU 系统自由的许可证现在也将保障 Linux 的自由。Vaughan-Nichols 解释道,这种融入到 GPL 的重要性怎么强调都不过分,它基本上能永远保证软件的自由和开放性。 + +**Steven Vaughan-Nichols:***[00:23:30]* 事实上,根据 Linux 所遵循的许可协议,即 GPL 第 2 版,如果你想贩卖 Linux 或者向全世界展示它,你必须与他人共享代码,所以如果你对其做了一些改进,仅仅给别人使用是不够的。事实上你必须和他们分享所有这些变化的具体细节。然后,如果这些改进足够好,就会被 Linux 所吸收。 + +**Saron Yitbarek:***[00:24:00]* 事实证明,这种公开的方式极具吸引力。埃里克·雷蒙德Eric Raymond 是这场运动的早期传道者之一,他在他那篇著名的文章中写道:“微软和苹果这样的公司一直在试图建造软件大教堂,而 Linux 及类似的软件则提供了一个由不同议程和方法组成的巨大集市,集市比大教堂有趣多了。” + +**tormy Peters:**我认为在那个时候,真正吸引人的是人们终于可以把控自己的世界了。 + +**Saron Yitbarek:**Stormy Peters 是一位行业分析师,也是自由和开源软件的倡导者。 + +**Stormy Peters:***[00:24:30]* 当开源软件第一次出现的时候,所有的操作系统都是专有的。如果不使用专有软件,你甚至不能添加打印机,你不能添加耳机,你不能自己开发一个小型硬件设备,然后让它在你的笔记本电脑上运行。你甚至不能放入 DVD 并复制它,因为你不能改变软件,即使你拥有这张 DVD,你也无法复制它。*[00:25:00]* 你无法控制你购买的硬件/软件系统。你不能从中创造出任何新的、更大的、更好的东西。这就是为什么开源操作系统在一开始就如此重要的原因。我们需要一个开源协作环境,在那里我们可以构建更大更好的东西。 + +**Saron Yitbarek:**请注意,Linux 并不是一个纯粹的平等主义乌托邦。林纳斯·托瓦兹不会批准对内核的所有修改,而是主导了内核的变更。他安排了十几个人来管理内核的不同部分。*[00:25:30]* 这些人也会信任自己下面的人,以此类推,形成信任金字塔。变化可能来自任何地方,但它们都是经过判断和策划的。 + +然而,考虑到到林纳斯的 DIY 项目一开始是多么的简陋和随意,这项成就令人十分惊讶。他完全不知道自己就是这一切中的卢克·天行者。当时他只有 21 岁,一半的时间都在编程。但是当魔盒第一次被打开,人们开始给他反馈。*[00:26:00]* 几十个,然后几百个,成千上万的贡献者。有了这样的众包基础,Linux 很快就开始成长。真的成长得很快。甚至最终引起了微软的注意。他们的首席执行官史蒂夫·鲍尔默Steve Ballmer将 Linux 称为是“一种癌症,从知识产权得角度来看,它传染了接触到得任何东西 ”。Steven Levy 将会描述 Ballmer 的由来。 + +**Steven Levy:***[00:26:30]* 一旦微软真正巩固了它的垄断地位,而且它也确实被联邦法院判定为垄断,他们将会对任何可能对其构成威胁的事情做出强烈反应。因此,既然他们对软件收费,很自然得,他们将自由软件得出现看成是一种癌症。他们试图提出一个知识产权理论,来解释为什么这对消费者不利。 + +**Saron Yitbarek:***[00:27:00]* Linux 在不断传播,微软也开始担心起来。到了 2006 年,Linux 成为仅次于 Windows 的第二大常用操作系统,全球约有 5000 名开发人员在使用它。5000 名开发者。还记得比尔·盖茨给苹果公司的备忘录吗?在那份备忘录中,他向苹果公司的员工们论述了与他人合作的重要性。事实证明,开源将把伙伴关系的概念提升到一个全新的水平,这是比尔·盖茨从未预见到的。 + +*[00:27:30]* 我们一直在谈论操作系统之间的大战,但是到目前为止,并没有怎么提到无名英雄和开发者们。在下次的代码英雄中,情况就不同了。第二集讲的是操作系统大战的第二部分,是关于 Linux 崛起的。业界醒悟过来,认识到了开发人员的重要性。这些开源反叛者变得越来越强大,战场从桌面转移到了服务器领域。*[00:28:00]* 这里有商业间谍活动、新的英雄人物,还有科技史上最不可思议的改变。这一切都在操作系统大战的后半集内达到了高潮。 + +要想免费自动获得新一集的代码英雄,请点击订阅苹果播客、Spotify、谷歌 Play,或其他应用获取该播客。在这一季剩下的时间里,我们将参观最新的战场,相互争斗的版图,这里是下一代的代码英雄留下印记的地方。*[00:28:30]* 更多信息,请访问 https://redhat.com/commandlineheroes 。我是 Saron Yitbarek。下次之前,继续编码。 + +-------------------------------------------------------------------------------- + +via: https://www.redhat.com/en/command-line-heroes/season-1/os-wars-part-1 + +作者:[redhat][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.redhat.com +[b]: https://github.com/lujun9972 diff --git a/published/201908/20180119 Two great uses for the cp command Bash shortcuts.md b/published/201908/20180119 Two great uses for the cp command Bash shortcuts.md new file mode 100644 index 0000000000..1428f65555 --- /dev/null +++ b/published/201908/20180119 Two great uses for the cp command Bash shortcuts.md @@ -0,0 +1,137 @@ +两种 cp 命令的绝佳用法的快捷方式 +=================== + +> 这篇文章是关于如何在使用 cp 命令进行备份以及同步时提高效率。 + +![Two great uses for the cp command: Bash shortcuts ](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/yearbook-haff-rx-linux-file-lead_0.png?itok=-i0NNfDC) + +去年七月,我写了一篇[关于 cp 命令的两种绝佳用法][7]的文章:备份一个文件,以及同步一个文件夹的备份。 + +虽然这些工具确实很好用,但同时,输入这些命令太过于累赘了。为了解决这个问题,我在我的 Bash 启动文件里创建了一些 Bash 快捷方式。现在,我想把这些捷径分享给你们,以便于你们在需要的时候可以拿来用,或者是给那些还不知道怎么使用 Bash 的别名以及函数的用户提供一些思路。 + +### 使用 Bash 别名来更新一个文件夹的副本 + +如果要使用 `cp` 来更新一个文件夹的副本,通常会使用到的命令是: + +``` +cp -r -u -v SOURCE-FOLDER DESTINATION-DIRECTORY +``` + +其中 `-r` 代表“向下递归访问文件夹中的所有文件”,`-u` 代表“更新目标”,`-v` 代表“详细模式”,`SOURCE-FOLDER` 是包含最新文件的文件夹的名称,`DESTINATION-DIRECTORY` 是包含必须同步的`SOURCE-FOLDER` 副本的目录。 + +因为我经常使用 `cp` 命令来复制文件夹,我会很自然地想起使用 `-r` 选项。也许再想地更深入一些,我还可以想起用 `-v` 选项,如果再想得再深一层,我会想起用选项 `-u`(不知道这个选项是代表“更新”还是“同步”还是一些什么其它的)。 + +或者,还可以使用[Bash 的别名功能][8]来将 `cp` 命令以及其后的选项转换成一个更容易记忆的单词,就像这样: + +``` +alias sync='cp -r -u -v' +``` + +如果我将其保存在我的主目录中的 `.bash_aliases` 文件中,然后启动一个新的终端会话,我可以使用该别名了,例如: + +``` +sync Pictures /media/me/4388-E5FE +``` + +可以将我的主目录中的图片文件夹与我的 USB 驱动器中的相同版本同步。 + +不清楚 `sync` 是否已经定义了?你可以在终端里输入 `alias` 这个单词来列出所有正在使用的命令别名。 + +喜欢吗?想要现在就立即使用吗?那就现在打开终端,输入: + +``` +echo "alias sync='cp -r -u -v'" >> ~/.bash_aliases +``` + +然后启动一个新的终端窗口并在命令提示符下键入 `alias`。你应该看到这样的东西: + +``` +me@mymachine~$ alias + +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' +alias egrep='egrep --color=auto' +alias fgrep='fgrep --color=auto' +alias grep='grep --color=auto' +alias gvm='sdk' +alias l='ls -CF' +alias la='ls -A' +alias ll='ls -alF' +alias ls='ls --color=auto' +alias sync='cp -r -u -v' +me@mymachine:~$ +``` + +这里你能看到 `sync` 已经定义了。 + +### 使用 Bash 函数来为备份编号 + +若要使用 `cp` 来备份一个文件,通常使用的命令是: + +``` +cp --force --backup=numbered WORKING-FILE BACKED-UP-FILE +``` + +其中 `--force` 代表“强制制作副本”,`--backup= numbered` 代表“使用数字表示备份的生成”,`WORKING-FILE` 是我们希望保留的当前文件,`BACKED-UP-FILE` 与 `WORKING-FILE` 的名称相同,并附加生成信息。 + +我们不仅需要记得所有 `cp` 的选项,我们还需要记得去重复输入 `WORKING-FILE` 的名字。但当[Bash 的函数功能][9]已经可以帮我们做这一切,为什么我们还要不断地重复这个过程呢?就像这样: + +再一次提醒,你可将下列内容保存入你在家目录下的 `.bash_aliases` 文件里: + +``` +function backup { +    if [ $# -ne 1 ]; then +        echo "Usage: $0 filename" +    elif [ -f $1 ] ; then +        echo "cp --force --backup=numbered $1 $1" +        cp --force --backup=numbered $1 $1 +    else +        echo "$0: $1 is not a file" +    fi +} +``` + +我将此函数称之为 `backup`,因为我的系统上没有任何其他名为 `backup` 的命令,但你可以选择适合的任何名称。 + +第一个 `if` 语句是用于检查是否提供有且只有一个参数,否则,它会用 `echo` 命令来打印出正确的用法。 + +`elif` 语句是用于检查提供的参数所指向的是一个文件,如果是的话,它会用第二个 `echo` 命令来打印所需的 `cp` 的命令(所有的选项都是用全称来表示)并且执行它。 + +如果所提供的参数不是一个文件,文件中的第三个 `echo` 用于打印错误信息。 + +在我的家目录下,如果我执行 `backup` 这个命令,我可以发现目录下多了一个文件名为`checkCounts.sql.~1~` 的文件,如果我再执行一次,便又多了另一个名为 `checkCounts.sql.~2~` 的文件。 + +成功了!就像所想的一样,我可以继续编辑 `checkCounts.sql`,但如果我可以经常地用这个命令来为文件制作快照的话,我可以在我遇到问题的时候回退到最近的版本。 + +也许在未来的某个时间,使用 `git` 作为版本控制系统会是一个好主意。但像上文所介绍的 `backup` 这个简单而又好用的工具,是你在需要使用快照的功能时却还未准备好使用 `git` 的最好工具。 + +### 结论 + +在我的上一篇文章里,我保证我会通过使用脚本,shell 里的函数以及别名功能来简化一些机械性的动作来提高生产效率。 + +在这篇文章里,我已经展示了如何在使用 `cp` 命令同步或者备份文件时运用 shell 函数以及别名功能来简化操作。如果你想要了解更多,可以读一下这两篇文章:[怎样通过使用命令别名功能来减少敲击键盘的次数][10] 以及由我的同事 Greg 和 Seth 写的 [Shell 编程:shift 方法和自定义函数介绍][11]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/1/two-great-uses-cp-command-update + +作者:[Chris Hermansen][a] +译者:[zyk2290](https://github.com/zyk2290) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/clhermansen +[1]:https://opensource.com/users/clhermansen +[2]:https://opensource.com/users/clhermansen +[3]:https://opensource.com/user/37806/feed +[4]:https://opensource.com/article/18/1/two-great-uses-cp-command-update?rate=J_7R7wSPbukG9y8jrqZt3EqANfYtVAwZzzpopYiH3C8 +[5]:https://opensource.com/article/18/1/two-great-uses-cp-command-update#comments +[6]:https://www.flickr.com/photos/internetarchivebookimages/14803082483/in/photolist-oy6EG4-pZR3NZ-i6r3NW-e1tJSX-boBtf7-oeYc7U-o6jFKK-9jNtc3-idt2G9-i7NG1m-ouKjXe-owqviF-92xFBg-ow9e4s-gVVXJN-i1K8Pw-4jybMo-i1rsBr-ouo58Y-ouPRzz-8cGJHK-85Evdk-cru4Ly-rcDWiP-gnaC5B-pAFsuf-hRFPcZ-odvBMz-hRCE7b-mZN3Kt-odHU5a-73dpPp-hUaaAi-owvUMK-otbp7Q-ouySkB-hYAgmJ-owo4UZ-giHgqu-giHpNc-idd9uQ-osAhcf-7vxk63-7vwN65-fQejmk-pTcLgA-otZcmj-fj1aSX-hRzHQk-oyeZfR +[7]:https://opensource.com/article/17/7/two-great-uses-cp-command +[8]:https://opensource.com/article/17/5/introduction-alias-command-line-tool +[9]:https://opensource.com/article/17/1/shell-scripting-shift-method-custom-functions +[10]:https://opensource.com/article/17/5/introduction-alias-command-line-tool +[11]:https://opensource.com/article/17/1/shell-scripting-shift-method-custom-functions +[12]:https://opensource.com/tags/linux +[13]:https://opensource.com/users/clhermansen +[14]:https://opensource.com/users/clhermansen diff --git a/published/201908/20180131 How to test Webhooks when youre developing locally.md b/published/201908/20180131 How to test Webhooks when youre developing locally.md new file mode 100644 index 0000000000..2ac7fb588b --- /dev/null +++ b/published/201908/20180131 How to test Webhooks when youre developing locally.md @@ -0,0 +1,201 @@ +本地开发如何测试 Webhook +=================== + +![](https://img.linux.net.cn/data/attachment/album/201908/11/090540wipp5c65iinyyf63.jpg) + +[Webhook][10] 可用于外部系统通知你的系统发生了某个事件或更新。可能最知名的 [Webhook][10] 类型是支付服务提供商(PSP)通知你的系统支付状态有了更新。 + +它们通常以监听的预定义 URL 的形式出现,例如 `http://example.com/webhooks/payment-update`。同时,另一个系统向该 URL 发送具有特定有效载荷的 POST 请求(例如支付 ID)。一旦请求进入,你就会获得支付 ID,可以通过 PSP 的 API 用这个支付 ID 向它们询问最新状态,然后更新你的数据库。 + +其他例子可以在这个对 Webhook 的出色的解释中找到:[https://sendgrid.com/blog/whats-webhook/][12]。 + +只要系统可通过互联网公开访问(这可能是你的生产环境或可公开访问的临时环境),测试这些 webhook 就相当顺利。而当你在笔记本电脑上或虚拟机内部(例如,Vagrant 虚拟机)进行本地开发时,它就变得困难了。在这些情况下,发送 webhook 的一方无法公开访问你的本地 URL。此外,监视发送的请求也很困难,这可能使开发和调试变得困难。 + +因此,这个例子将解决: + +* 测试来自本地开发环境的 webhook,该环境无法通过互联网访问。从服务器向 webhook 发送数据的服务无法访问它。 +* 监控发送的请求和数据,以及应用程序生成的响应。这样可以更轻松地进行调试,从而缩短开发周期。 + +前置需求: + +* *可选*:如果你使用虚拟机(VM)进行开发,请确保它正在运行,并确保在 VM 中完成后续步骤。 +* 对于本教程,我们假设你定义了一个 vhost:`webhook.example.vagrant`。我在本教程中使用了 Vagrant VM,但你可以自由选择 vhost。 +* 按照这个[安装说明][3]安装 `ngrok`。在 VM 中,我发现它的 Node 版本也很有用:[https://www.npmjs.com/package/ngrok][4],但你可以随意使用其他方法。 + +我假设你没有在你的环境中运行 SSL,但如果你使用了,请将在下面的示例中的端口 80 替换为端口 433,`http://` 替换为 `https://`。 + +### 使 webhook 可测试 + +我们假设以下示例代码。我将使用 PHP,但请将其视作伪代码,因为我留下了一些关键部分(例如 API 密钥、输入验证等)没有编写。 + +第一个文件:`payment.php`。此文件创建一个 `$payment` 对象,将其注册到 PSP。然后它获取客户需要访问的 URL,以便支付并将用户重定向到客户那里。 + +请注意,此示例中的 `webhook.example.vagrant` 是我们为开发设置定义的本地虚拟主机。它无法从外部世界进入。 + +``` + 123, + 'amount' => 25.00, + 'description' => 'Test payment', + 'redirect_url' => 'http://webhook.example.vagrant/redirect.php', + 'webhook_url' => 'http://webhook.example.vagrant/webhook.php', +]; + +$payment = $paymentProvider->createPayment($payment); +header("Location: " . $payment->getPaymentUrl()); +``` + +第二个文件:`webhook.php`。此文件等待 PSP 调用以获得有关更新的通知。 + +``` +getPayment($paymentId); +$status = $paymentInfo->getStatus(); + +// Perform actions in here to update your system +if ($status === 'paid') { + .. +} +elseif ($status === 'cancelled') { + .. +} +``` + +我们的 webhook URL 无法通过互联网访问(请记住它:`webhook.example.vagrant`)。因此,PSP 永远不可能调用文件 `webhook.php`,你的系统将永远不会知道付款状态,这最终导致订单永远不会被运送给客户。 + +幸运的是,`ngrok` 可以解决这个问题。 [ngrok][13] 将自己描述为: + +> ngrok 通过安全隧道将 NAT 和防火墙后面的本地服务器暴露给公共互联网。 + +让我们为我们的项目启动一个基本的隧道。在你的环境中(在你的系统上或在 VM 上)运行以下命令: + +``` +ngrok http -host-header=rewrite webhook.example.vagrant:80 +``` + +> 阅读其文档可以了解更多配置选项:[https://ngrok.com/docs][14]。 + +会出现这样的屏幕: + +![](https://cdn-images-1.medium.com/max/1000/1*BZZE-CvZwHZ3pxsElJMWbA.png) + +*ngrok 输出* + +我们刚刚做了什么?基本上,我们指示 `ngrok` 在端口 80 建立了一个到 `http://webhook.example.vagrant` 的隧道。同一个 URL 也可以通过 `http://39741ffc.ngrok.io` 或 `https://39741ffc.ngrok.io` 访问,它们能被任何知道此 URL 的人通过互联网公开访问。 + +请注意,你可以同时获得 HTTP 和 HTTPS 两个服务。这个文档提供了如何将此限制为 HTTPS 的示例:[https://ngrok.com/docs#bind-tls][16]。 + +那么,我们如何让我们的 webhook 现在工作起来?将 `payment.php` 更新为以下代码: + +``` + 123, + 'amount' => 25.00, + 'description' => 'Test payment', + 'redirect_url' => 'http://webhook.example.vagrant/redirect.php', + 'webhook_url' => 'https://39741ffc.ngrok.io/webhook.php', +]; + +$payment = $paymentProvider->createPayment($payment); +header("Location: " . $payment->getPaymentUrl()); +``` + +现在,我们告诉 PSP 通过 HTTPS 调用此隧道 URL。只要 PSP 通过隧道调用 webhook,`ngrok` 将确保使用未修改的有效负载调用内部 URL。 + +### 如何监控对 webhook 的调用? + +你在上面看到的屏幕截图概述了对隧道主机的调用,这些数据相当有限。幸运的是,`ngrok` 提供了一个非常好的仪表板,允许你检查所有调用: + +![](https://cdn-images-1.medium.com/max/1000/1*qZw9GRTnG1sMgEUmsJPz3g.png) + +我不会深入研究这个问题,因为它是不言自明的,你只要运行它就行了。因此,我将解释如何在 Vagrant 虚拟机上访问它,因为它不是开箱即用的。 + +仪表板将允许你查看所有调用、其状态代码、标头和发送的数据。你将看到应用程序生成的响应。 + +仪表板的另一个优点是它允许你重放某个调用。假设你的 webhook 代码遇到了致命的错误,开始新的付款并等待 webhook 被调用将会很繁琐。重放上一个调用可以使你的开发过程更快。 + +默认情况下,仪表板可在 `http://localhost:4040` 访问。 + +### 虚拟机中的仪表盘 + +为了在 VM 中完成此工作,你必须执行一些额外的步骤: + +首先,确保可以在端口 4040 上访问 VM。然后,在 VM 内创建一个文件已存放此配置: + +``` +web_addr: 0.0.0.0:4040 +``` + +现在,杀死仍在运行的 `ngrok` 进程,并使用稍微调整过的命令启动它: + +``` +ngrok http -config=/path/to/config/ngrok.conf -host-header=rewrite webhook.example.vagrant:80 +``` + +尽管 ID 已经更改,但你将看到类似于上一屏幕截图的屏幕。之前的网址不再有效,但你有了一个新网址。 此外,`Web Interface` URL 已更改: + +![](https://cdn-images-1.medium.com/max/1000/1*3FZq37TF4dmBqRc1R0FMVg.png) + +现在将浏览器指向 `http://webhook.example.vagrant:4040` 以访问仪表板。另外,对 `https://e65642b5.ngrok.io/webhook.php` 做个调用。这可能会导致你的浏览器出错,但仪表板应显示正有一个请求。 + +### 最后的备注 + +上面的例子是伪代码。原因是每个外部系统都以不同的方式使用 webhook。我试图基于一个虚构的 PSP 实现给出一个例子,因为可能很多开发人员在某个时刻肯定会处理付款。 + +请注意,你的 webhook 网址也可能被意图不好的其他人使用。确保验证发送给它的任何输入。 + +更好的的,可以向 URL 添加令牌,该令牌对于每个支付是唯一的。只有你的系统和发送 webhook 的系统才能知道此令牌。 + +祝你测试和调试你的 webhook 顺利! + +注意:我没有在 Docker 上测试过本教程。但是,这个 Docker 容器看起来是一个很好的起点,并包含了明确的说明:[https://github.com/wernight/docker-ngrok][19] 。 + +-------- + +via: https://medium.freecodecamp.org/testing-webhooks-while-using-vagrant-for-development-98b5f3bedb1d + +作者:[Stefan Doorn][a] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://medium.freecodecamp.org/@stefandoorn +[1]:https://unsplash.com/photos/MYTyXb7fgG0?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[2]:https://unsplash.com/?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]:https://ngrok.com/download +[4]:https://www.npmjs.com/package/ngrok +[5]:http://webhook.example.vagrnat/ +[6]:http://39741ffc.ngrok.io/ +[7]:http://39741ffc.ngrok.io/ +[8]:http://webhook.example.vagrant:4040/ +[9]:https://e65642b5.ngrok.io/webhook.php. +[10]:https://sendgrid.com/blog/whats-webhook/ +[11]:http://example.com/webhooks/payment-update%29 +[12]:https://sendgrid.com/blog/whats-webhook/ +[13]:https://ngrok.com/ +[14]:https://ngrok.com/docs +[15]:http://39741ffc.ngrok.io%2C/ +[16]:https://ngrok.com/docs#bind-tls +[17]:http://localhost:4040./ +[18]:https://e65642b5.ngrok.io/webhook.php. +[19]:https://github.com/wernight/docker-ngrok +[20]:https://github.com/stefandoorn +[21]:https://twitter.com/stefan_doorn +[22]:https://www.linkedin.com/in/stefandoorn diff --git a/published/201908/20180622 Use LVM to Upgrade Fedora.md b/published/201908/20180622 Use LVM to Upgrade Fedora.md new file mode 100644 index 0000000000..2c4f9ff474 --- /dev/null +++ b/published/201908/20180622 Use LVM to Upgrade Fedora.md @@ -0,0 +1,214 @@ +使用 LVM 升级 Fedora +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/06/lvm-upgrade-816x345.jpg) + +大多数用户发现使用标准流程升级[从一个 Fedora 版本升级到下一个][1]很简单。但是,Fedora 升级也不可避免地会遇到许多特殊情况。本文介绍了使用 DNF 和逻辑卷管理(LVM)进行升级的一种方法,以便在出现问题时保留可引导备份。这个例子是将 Fedora 26 系统升级到 Fedora 28。 + +此处展示的过程比标准升级过程更复杂。在使用此过程之前,你应该充分掌握 LVM 的工作原理。如果没有适当的技能和细心,你可能会丢失数据和/或被迫重新安装系统!如果你不知道自己在做什么,那么**强烈建议**你坚持只使用得到支持的升级方法。 + +### 准备系统 + +在开始之前,请确保你的现有系统已完全更新。 + +``` +$ sudo dnf update +$ sudo systemctl reboot # 或采用 GUI 方式 +``` + +检查你的根文件系统是否是通过 LVM 挂载的。 + +``` +$ df / +Filesystem 1K-blocks Used Available Use% Mounted on +/dev/mapper/vg_sdg-f26 20511312 14879816 4566536 77% / + +$ sudo lvs +LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert +f22 vg_sdg -wi-ao---- 15.00g +f24_64 vg_sdg -wi-ao---- 20.00g +f26 vg_sdg -wi-ao---- 20.00g +home vg_sdg -wi-ao---- 100.00g +mockcache vg_sdg -wi-ao---- 10.00g +swap vg_sdg -wi-ao---- 4.00g +test vg_sdg -wi-a----- 1.00g +vg_vm vg_sdg -wi-ao---- 20.00g +``` + +如果你在安装 Fedora 时使用了默认值,你可能会发现根文件系统挂载在名为 `root` 的逻辑卷(LV)上。卷组(VG)的名称可能会有所不同。看看根卷的总大小。在该示例中,根文件系统名为 `f26`,大小为 `20G`。 + +接下来,确保 LVM 中有足够的可用空间。 + +``` +$ sudo vgs +VG #PV #LV #SN Attr VSize VFree +vg_sdg 1 8 0 wz--n- 232.39g 42.39g +``` + +该系统有足够的可用空间,可以为升级后的 Fedora 28 的根卷分配 20G 的逻辑卷。如果你使用的是默认安装,则你的 LVM 中将没有可用空间。对 LVM 的一般性管理超出了本文的范围,但这里有一些情形下可能采取的方法: + +1、`/home` 在自己的逻辑卷,而且 `/home` 中有大量空闲空间。 + +你可以从图形界面中注销并切换到文本控制台,以 `root` 用户身份登录。然后你可以卸载 `/home`,并使用 `lvreduce -r` 调整大小并重新分配 `/home` 逻辑卷。你也可以从现场镜像Live image启动(以便不使用 `/home`)并使用 gparted GUI 实用程序进行分区调整。 + +2、大多数 LVM 空间被分配给根卷,该文件系统中有大量可用空间。 + +你可以从现场镜像启动并使用 gparted GUI 实用程序来减少根卷的大小。此时也可以考虑将 `/home` 移动到另外的文件系统,但这超出了本文的范围。 + +3、大多数文件系统已满,但你有个已经不再需要逻辑卷。 + +你可以删除不需要的逻辑卷,释放卷组中的空间以进行此操作。 + +### 创建备份 + +首先,为升级后的系统分配新的逻辑卷。确保为系统的卷组(VG)使用正确的名称。在这个例子中它是 `vg_sdg`。 + +``` +$ sudo lvcreate -L20G -n f28 vg_sdg +Logical volume "f28" created. +``` + +接下来,创建当前根文件系统的快照。此示例创建名为 `f26_s` 的快照卷。 + +``` +$ sync +$ sudo lvcreate -s -L1G -n f26_s vg_sdg/f26 +Using default stripesize 64.00 KiB. +Logical volume "f26_s" created. +``` + +现在可以将快照复制到新逻辑卷。当你替换自己的卷名时,**请确保目标正确**。如果不小心,就会不可撤销地删除了数据。此外,请确保你从根卷的快照复制,**而不是**从你的现在的根卷。 + +``` +$ sudo dd if=/dev/vg_sdg/f26_s of=/dev/vg_sdg/f28 bs=256k +81920+0 records in +81920+0 records out +21474836480 bytes (21 GB, 20 GiB) copied, 149.179 s, 144 MB/s +``` + +给新文件系统一个唯一的 UUID。这不是绝对必要的,但 UUID 应该是唯一的,因此这避免了未来的混淆。以下是在 ext4 根文件系统上的方法: + +``` +$ sudo e2fsck -f /dev/vg_sdg/f28 +$ sudo tune2fs -U random /dev/vg_sdg/f28 +``` + +然后删除不再需要的快照卷: + +``` +$ sudo lvremove vg_sdg/f26_s +Do you really want to remove active logical volume vg_sdg/f26_s? [y/n]: y +Logical volume "f26_s" successfully removed +``` + +如果你单独挂载了 `/home`,你可能希望在此处制作 `/home` 的快照。有时,升级的应用程序会进行与旧版 Fedora 版本不兼容的更改。如果需要,编辑**旧**根文件系统上的 `/etc/fstab` 文件以在 `/home` 上挂载快照。请记住,当快照已满时,它将消失!另外,你可能还希望给 `/home` 做个正常备份。 + +### 配置以使用新的根 + +首先,安装新的逻辑卷并备份现有的 GRUB 设置: + +``` +$ sudo mkdir /mnt/f28 +$ sudo mount /dev/vg_sdg/f28 /mnt/f28 +$ sudo mkdir /mnt/f28/f26 +$ cd /boot/grub2 +$ sudo cp -p grub.cfg grub.cfg.old +``` + +编辑 `grub.conf` 并在第一个菜单项 `menuentry` 之前添加这些,除非你已经有了: + +``` +menuentry 'Old boot menu' { + configfile /grub2/grub.cfg.old +} +``` + +编辑 `grub.conf` 并更改默认菜单项以激活并挂载新的根文件系统。改变这一行: + +``` +linux16 /vmlinuz-4.16.11-100.fc26.x86_64 root=/dev/mapper/vg_sdg-f26 ro rd.lvm.lv=vg_sdg/f26 rd.lvm.lv=vg_sdg/swap rhgb quiet LANG=en_US.UTF-8 +``` + +如你看到的这样。请记住使用你系统上的正确的卷组和逻辑卷条目名称! + +``` +linux16 /vmlinuz-4.16.11-100.fc26.x86_64 root=/dev/mapper/vg_sdg-f28 ro rd.lvm.lv=vg_sdg/f28 rd.lvm.lv=vg_sdg/swap rhgb quiet LANG=en_US.UTF-8 +``` + +编辑 `/mnt/f28/etc/default/grub` 并改变在启动时激活的默认的根卷: + +``` +GRUB_CMDLINE_LINUX="rd.lvm.lv=vg_sdg/f28 rd.lvm.lv=vg_sdg/swap rhgb quiet" +``` + +编辑 `/mnt/f28/etc/fstab`,将挂载的根文件系统从旧的逻辑卷: + +``` +/dev/mapper/vg_sdg-f26 / ext4 defaults 1 1 +``` + +改为新的: + +``` +/dev/mapper/vg_sdg-f28 / ext4 defaults 1 1 +``` + +然后,出于参考的用途,只读挂载旧的根卷: + +``` +/dev/mapper/vg_sdg-f26 /f26 ext4 ro,nodev,noexec 0 0 +``` + +如果你的根文件系统是通过 UUID 挂载的,你需要改变这个方式。如果你的根文件系统是 ext4 你可以这样做: + +``` +$ sudo e2label /dev/vg_sdg/f28 F28 +``` + +现在编辑 `/mnt/f28/etc/fstab` 使用该卷标。改变该根文件系统的挂载行,像这样: + +``` +LABEL=F28 / ext4 defaults 1 1 +``` + +### 重启与升级 + +重新启动,你的系统将使用新的根文件系统。它仍然是 Fedora 26,但是是带有新的逻辑卷名称的副本,并可以进行 `dnf` 系统升级!如果出现任何问题,请使用旧引导菜单引导回到你的工作系统,此过程可避免触及旧系统。 + +``` +$ sudo systemctl reboot # or GUI equivalent +... +$ df / /f26 +Filesystem 1K-blocks Used Available Use% Mounted on +/dev/mapper/vg_sdg-f28 20511312 14903196 4543156 77% / +/dev/mapper/vg_sdg-f26 20511312 14866412 4579940 77% /f26 +``` + +你可能希望验证使用旧的引导菜单确实可以让你回到挂载在旧的根文件系统上的根。 + +现在按照[此维基页面][2]中的说明进行操作。如果系统升级出现任何问题,你还会有一个可以重启回去的工作系统。 + +### 进一步的考虑 + +创建新的逻辑卷并将根卷的快照复制到其中的步骤可以使用通用脚本自动完成。它只需要新的逻辑卷的名称,因为现有根的大小和设备很容易确定。例如,可以输入以下命令: + +``` +$ sudo copyfs / f28 +``` + +提供挂载点以进行复制可以更清楚地了解发生了什么,并且复制其他挂载点(例如 `/home`)可能很有用。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/use-lvm-upgrade-fedora/ + +作者:[Stuart D Gathman][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://fedoramagazine.org/author/sdgathman/ +[1]:https://fedoramagazine.org/upgrading-fedora-27-fedora-28/ +[2]:https://fedoraproject.org/wiki/DNF_system_upgrade diff --git a/published/201908/20180720 A brief history of text-based games and open source.md b/published/201908/20180720 A brief history of text-based games and open source.md new file mode 100644 index 0000000000..bc3026be9f --- /dev/null +++ b/published/201908/20180720 A brief history of text-based games and open source.md @@ -0,0 +1,156 @@ +[#]: collector: (lujun9972) +[#]: translator: (cycoe) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11272-1.html) +[#]: subject: (A brief history of text-based games and open source) +[#]: via: (https://opensource.com/article/18/7/interactive-fiction-tools) +[#]: author: (Jason Mclntosh https://opensource.com/users/jmac) + +互动小说及其开源简史 +====== + +> 了解开源如何促进互动小说的成长和发展。 + +![](https://img.linux.net.cn/data/attachment/album/201908/27/142657ryf4pa2lym6fe6f1.jpg) + +[互动小说技术基金会][1]Interactive Fiction Technology Foundation(IFTF) 是一个非营利组织,致力于保护和改进那些用来生成我们称之为互动小说interactive fiction的数字艺术形式的技术。当 Opensource.com 的一位社区版主提出一篇关于 IFTF、它支持的技术与服务,以及它如何与开源相交织的文章时,我发现这对于我讲了数几十年的开源故事来说是个新颖的视角。互动小说的历史比自由及开源软件Free and Open Source Software(FOSS)运动的历史还要长,但同时也与之密切相关。希望你们能喜欢我在这里的分享。 + +### 定义和历史 + +对于我来说,互动小说这个术语涵盖了读者主要通过文本与之交互的任何视频游戏或数字化艺术作品。这个术语起源于 20 世纪 80 年代,当时由语法解析器驱动的文本冒险游戏确立了什么是家用电脑娱乐,在美国主要以 [魔域][2]、[银河系漫游指南][3] 和 [Infocom][4] 公司的其它佳作为代表。在 20 世纪 90 年代,它的主流商业价值被挖掘殆尽,但在线爱好者社区接过了该传统,继续发布这类游戏和游戏创建工具。 + +在四分之一个世纪之后的今天,互动小说包括了品种繁多并且妙趣橫生的作品,如从充满谜题的文字冒险游戏到衍生改良的超文本类型。定期举办的在线竞赛和节日为品鉴和试玩新作品提供了个好地方---英语互动小说世界每年都会举办一些活动,包括 [Spring Thing][5] 和 [IFComp][6]。后者是自 1995 年以来现代互动小说的核心活动,这也使它成为在同类型活动中持续举办时间最长的游戏展示活动。[IFComp 从 2017 年开始的评选和排名记录][7] 显示了如今基于文本的游戏在形式、风格和主题方面的惊人多样性。 + +(作者注:以上我特指英语,因为可能出于写作方面的技术原因,互动小说社区倾向于按语言进行区分。例如也有 [法语][8] 或 [意大利语][9] 的互动小说年度活动,我就听说过至少一届的中文互动小说节。幸运的是,这些边界易于打破。在我管理 IFComp 的四年中,我们很欢迎来自国际社区的所有英语翻译工作。) + +![“假冒的猴子”游戏截图][11] + +*在解释器 Lectrote 上启动 Emily Short 的“假冒的猴子”新游戏(二者皆为开源软件)。* + +此外由于互动小说专注于文本,它为玩家和作者都提供了最方便的平台。几乎所有能阅读数字化文本的人(包括能通过文字转语音软件等辅助技术阅读的用户)都能玩大部分的互动小说作品。同样,互动小说的创作对所有愿意学习和使用其工具和技术的作家开放。 + +这使我们了解了互动小说与开源的长期关系,以及从它的全盛时期以来,对于艺术形式可用性的积极影响。接下来我将概述当代开源互动小说创建工具,并讨论共享源代码的互动小说作品古老且有点稀奇的传统。 + +### 开源互动小说工具的世界 + +一些开发平台(其中大部分是开源的)可用于创建传统的语法解析器驱动互动小说,其中用户可通过输入命令(如 `向北走`、`拾取提灯`、`收养小猫` 或 `向 Zoe 询问量子机械学`)来与游戏世界交互。20 世纪 90 年代初期出现了几个适于魔改hacker-friendly的语法解析器游戏开发工具,其中目前还在使用的有 [TADS][12]、[Alan][13] 和 [Quest][14],它们都是开源的,并且后两者兼容 FOSS 许可证。 + +其中最出名的是 [Inform][15],1993 年 Graham Nelson 发布了第一个版本,目前由 Nelson 领导的一个团队进行维护。Inform 的源代码是不太寻常的半开源:Inform 6 是前一个主要版本,[它通过 Artistic 许可证开放源码][16]。这其中蕴涵着比我们所看到的更直接的相关性,因为它专有的 Inform 7 将 Inform 6 作为其核心,可以让它在将作品编译为机器码之前,将其 [杰出的自然语言语法][17] (LCTT 译注:此链接已遗失)翻译为其前一代的那种更类似 C 的代码。 + +![inform 7 集成式开发环境截图][19] + +*Inform 7 集成式开发环境,打开了文档以及一个示例项目* + +Inform 游戏运行在虚拟机上,这是 Infocom 时代的遗留产物。当时的发行者为了让同一个游戏可以运行在 Apple II、Commodore 4、Atari 800 以及其它种类的“[家用计算机][20]”上,将虚拟机作为解决方案。这些原本流行的操作系统中只有少数至今仍存在,但 Inform 的虚拟机使得它创建的作品能够通过 Inform 解释器运行在任何的计算机上。这些虚拟机包括相对现代的 [Glulx][21],或者通过对 Infocom 过去的虚拟机进行逆向工程克隆得到的可爱的古董 [Z-machine][22]。现在,流行的跨平台解释器包括如 [lectrote][23] 和 [Gargoyle][24] 等桌面程序,以及如 [Quixe][25] 和 [Parchment][26] 等基于浏览器的程序。以上所有均为开源软件。 + +如其它的流行开源项目一样,如果 Inform 的发展进程随着它的成熟而逐渐变缓,它为我们留下的最重要的财富就是其活跃透明的生态环境。对于 Inform 来说,(这些财富)包括前面提到的解释器、[一套语言扩展][27](通常混合使用 Inform 6 和 Inform 7 写成),当然也包括所有用它们写成并分享于全世界的作品,有的时候也包括那些源代码。(在这篇文章的后半部分我会回到这个话题) + +互动小说创建工具发明于 21 世纪,力求在传统的语法解析器之外探索一种新的玩家交互方式,即创建任何现代 Web 浏览器都能加载的超文本驱动作品。其中的领头羊是 [Twine][28],原本由 Klimas 在 2009 年开发,目前是 [GNU 许可证开源项目][29],有许多贡献者正在积极开发。(事实上,[Twine][30] 的开源软件血统可追溯到 [TiddlyWiki][31],Klimas 的项目最初是从该项目衍生而来的) + +对于互动小说开发来说,Twine 代表着一系列最开放及最可用的方法。由于它天生的 FOSS 属性,它将其输出渲染为一个自包含的网站,不依赖于需要进一步特殊解析的机器码,而是使用开放并且成熟的 HTML、CSS 和 JavaScript 标准。作为一个创建工具,Twine 能够根据创建者的技能等级,展示出与之相匹配的复杂度。拥有很少或没有编程知识的用户能够创建简单但是可玩的互动小说作品,但那些拥有更多编码和设计技能(包括通过开发 Twine 游戏获得的技能提升)的用户能够创建更复杂的项目。这也难怪近几年 Twine 在教育领域的曝光率和流行度有不小的提升。 + +另一些值得注意的开源互动小说开发项目包括由 Ian Millington 开发的以 MIT 许可证发布的 [Undum][32],以及由 Dan Fabulich 和 [Choice of Games][34] 团队开发的 [ChoiceScript][33],两者也专注于将 Web 浏览器作为游戏平台。除了以上专用的开发系统以外,基于 Web 的互动小说也呈现给我们以开源作品的丰富、变幻的生态。比如 Furkle 的 [Twine 扩展工具集][35],以及 Liza Daly 为自己的互动小说游戏创建的名为 [Windrift][36] 的 JavaScript 框架。 + +### 程序、游戏,以及游戏程序 + +Twine 受益于 [一个致力于提供支持的长期 IFTF 计划][37],公众可以为其维护和发展提供资助。IFTF 还直接支持两个长期公共服务:IFComp 和互动小说归档IF Archive,这两个服务都依赖并回馈开源软件和技术。 + +![Harmonia 开场截图][39] + +*由 Liza Daly 开发的“Harmonia”的开场画面,该游戏使用 Windrift 开源互动小说创建框架创建。* + +自 2014 年以来,用于运行 IFComp 网站的基于 Perl 和 JavaScript 的应用程序一直是 [一个共享源代码项目][40],它反映了 [互动小说特有子组件使用的 FOSS 许可证是个大杂烩][41],其中包括那些可以让以语法解析器驱动的竞争项目在 Web 浏览器中运行的各式各样的代码库。在 1992 年上线并 [在 2017 年成为一个 IFTF 项目][43] 的 [互动小说归档][42]IF Archive,是一套完全基于古老且稳定的互联网标准的镜像仓库,只使用了 [一点开源 Pyhon 脚本][44] 用来处理索引。 + +### 最后,也是最有趣的部分,让我们聊聊开源文字游戏 + +互动小说归档的主体 [由游戏组成][45],当然,是那些历经岁月的游戏。它们反映了数十年来不断发展的游戏设计趋势和互动小说工具发展。 + +许多互动小说作品都共享其源代码,要快速找到它们的快速很简单 —— [在 IFDB 中搜索标签 “source available”][46]。IFDB 是另一个长期运行的互动小说社区服务,由 TADS 的创立者 Mike Roberts 私人运营。对更加简单的界面感到舒适的用户,也可以浏览互动小说归档的 [games/source 目录][47],该目录按开发平台和编写语言对内容运行分组(也有很多作品,由于太繁杂或太古老而无法分类,只能浮于顶级目录)。 + +对这些代码共享游戏随机抽取的几个样本,揭示了一个有趣的窘境:与更广阔的开源软件世界不同,互动小说社区缺少一种普遍认同的方式来授权它生成的所有代码。与软件工具(包括我们用来创建互动小说的所有工具)不同的是,从字面意思上讲,交互式小说游戏是一件艺术作品。这意味着,将面向软件的开源许可证用于交互式小说游戏,并不会比将其用于其它像散文或诗歌作品更适合。但同样,互动小说游戏也是一个软件,它展示了创建者希望合法地与世界分享的源代码模式和技术。一个拥有开源意识的互动小说创建者会怎么做呢? + +有些游戏通过将其代码放到公共领域来解决这一问题,或者通过明确的许可证,亦或者如 [42 年前由 Crowther 和 Woods 开发的“冒险之旅Adventure”][48] 一样通过社区发布。一些人试图将其中的不同部分分开,应用他们自己的许可证,允许免费复用游戏公开的业务逻辑,但禁止针对其散文内容的再创作。这是我在开源自己的游戏 [莺巢][49]The Warbler’s Nest 时采取的策略。天知道这是否能在法律上站得住脚,但我当时没有更好的主意。 + +当然,你会发现一些作品对所有部分使用单一的许可证,而不介意反对者。一个突出的例子就是 [Emily Short 的史诗作品“假冒的猴子Counterfeit Monkey”][50],其全部采用 Creative Commons 4.0 许可证发布。[CC 对其应用于代码感到不满][51],但你可以认为 [Inform 7 源码这种不寻常的散文风格特性][52] 至少比传统的软件项目更适合 CC 许可证。 + +### 接下来要做什么呢,冒险者? + +如果你希望开始探索互动小说的世界,这里有几个链接可供你参考: + ++ 如上所述,[IFDB][53] 和[互动小说归档][54]都提供了可浏览的界面,用于浏览超过 40 年价值的互动小说作品。其中大部分可以在 Web 浏览器中玩,但有些需要额外的解释器程序。IFDB 能帮助你找到并安装它们。[IFComp 的年度结果页面][55]展现了另一个视图,帮助你了解最佳的免费和归档可用作品。 ++ [互动小说技术基金会][56]是一个非营利组织,主要帮助并支持 Twine、IFComp 和互动小说归档的发展,以及提升互动小说的无障碍功能、探索互动小说在教育领域中的应用等等。加入其[邮件列表][57],可以接收 IFTF 的每月资讯,浏览其[博客][58],亦或浏览[一些主题商品][59]。 ++ 在今年的早些时候,John Paul Wohlscheid 写了这篇[关于开源互动小说工具][60]的文章。它涵盖了一些这里没有提及的平台,所以如果你还想了解更多,请看一看这篇文章。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/7/interactive-fiction-tools + +作者:[Jason Mclntosh][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[cycoe](https://github.com/cycoe) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/jmac +[1]:http://iftechfoundation.org/ +[2]:https://en.wikipedia.org/wiki/Zork +[3]:https://en.wikipedia.org/wiki/The_Hitchhiker%27s_Guide_to_the_Galaxy_(video_game) +[4]:https://en.wikipedia.org/wiki/Infocom +[5]:http://www.springthing.net/ +[6]:http://ifcomp.org/ +[7]:https://ifcomp.org/comp/2017 +[8]:http://www.fiction-interactive.fr/ +[9]:http://www.oldgamesitalia.net/content/marmellata-davventura-2018 +[10]:/file/403396 +[11]:https://opensource.com/sites/default/files/uploads/monkey.png (counterfeit monkey game screenshot) +[12]:http://tads.org/ +[13]:https://www.alanif.se/ +[14]:http://textadventures.co.uk/quest/ +[15]:http://inform7.com/ +[16]:https://github.com/DavidKinder/Inform6 +[17]:http://inform7.com/learn/man/RB_4_1.html#e307 +[18]:/file/403386 +[19]:https://opensource.com/sites/default/files/uploads/inform.png (inform 7 IDE screenshot) +[20]:https://www.youtube.com/watch?v=bu55q_3YtOY +[21]:http://ifwiki.org/index.php/Glulx +[22]:http://ifwiki.org/index.php/Z-machine +[23]:https://github.com/erkyrath/lectrote +[24]:https://github.com/garglk/garglk/ +[25]:http://eblong.com/zarf/glulx/quixe/ +[26]:https://github.com/curiousdannii/parchment +[27]:https://github.com/i7/extensions +[28]:http://twinery.org/ +[29]:https://github.com/klembot/twinejs +[30]:https://opensource.com/article/18/7/twine-vs-renpy-interactive-fiction +[31]:https://tiddlywiki.com/ +[32]:https://github.com/idmillington/undum +[33]:https://github.com/dfabulich/choicescript +[34]:https://www.choiceofgames.com/ +[35]:https://github.com/furkle +[36]:https://github.com/lizadaly/windrift +[37]:http://iftechfoundation.org/committees/twine/ +[38]:/file/403391 +[39]:https://opensource.com/sites/default/files/uploads/harmonia.png (Harmonia opening screen shot) +[40]:https://github.com/iftechfoundation/ifcomp +[41]:https://github.com/iftechfoundation/ifcomp/blob/master/LICENSE.md +[42]:https://www.ifarchive.org/ +[43]:http://blog.iftechfoundation.org/2017-06-30-iftf-is-adopting-the-if-archive.html +[44]:https://github.com/iftechfoundation/ifarchive-ifmap-py +[45]:https://www.ifarchive.org/indexes/if-archiveXgames +[46]:http://ifdb.tads.org/search?sortby=ratu&searchfor=%22source+available%22 +[47]:https://www.ifarchive.org/indexes/if-archiveXgamesXsource.html +[48]:http://ifdb.tads.org/viewgame?id=fft6pu91j85y4acv +[49]:https://github.com/jmacdotorg/warblers-nest/ +[50]:https://github.com/i7/counterfeit-monkey +[51]:https://creativecommons.org/faq/#can-i-apply-a-creative-commons-license-to-software +[52]:https://github.com/i7/counterfeit-monkey/blob/master/Counterfeit%20Monkey.materials/Extensions/Counterfeit%20Monkey/Liquids.i7x +[53]:http://ifdb.tads.org/ +[54]:https://ifarchive.org/ +[55]:https://ifcomp.org/comp/last_comp +[56]:http://iftechfoundation.org/ +[57]:http://iftechfoundation.org/cgi-bin/mailman/listinfo/friends +[58]:http://blog.iftechfoundation.org/ +[59]:http://blog.iftechfoundation.org/2017-12-20-the-iftf-gift-shop-is-now-open.html +[60]:https://itsfoss.com/create-interactive-fiction/ diff --git a/published/201908/20180727 4 Ways to Customize Xfce and Give it a Modern Look.md b/published/201908/20180727 4 Ways to Customize Xfce and Give it a Modern Look.md new file mode 100644 index 0000000000..ad09ac44cf --- /dev/null +++ b/published/201908/20180727 4 Ways to Customize Xfce and Give it a Modern Look.md @@ -0,0 +1,146 @@ +4 种方式来自定义 Xfce 来给它一个现代化外观 +====== + +> Xfce 是一个非常轻量的桌面环境,但它有一个缺点,它看起来有点老旧。但是你没有必要坚持默认外观。让我们看看你可以自定义 Xfce 的各种方法,来给它一个现代化的、漂亮的外观。 + +![Customize Xfce desktop envirnment][1] + +首先,Xfce 是最[受欢迎的桌面环境][2]之一。作为一个轻量级桌面环境,你可以在非常低的资源上运行 Xfce,并且它仍然能很好地工作。这是为什么很多[轻量级 Linux 发行版][3]默认使用 Xfce 的原因之一。 + +一些人甚至喜欢在高端设备上使用它,说明它的简单性、易用性和非资源依赖性是主要原因。 + +[Xfce][4] 自身很小,而且只提供你需要的东西。令人烦恼的一点是会令人觉得它的外观和感觉很老了。然而,你可以简单地自定义 Xfce 以使其看起来现代化和漂亮,但又不会像 Unity/GNOME 会话那样占用系统资源。 + +### 4 种方式来自定义 Xfce 桌面 + +让我们看看一些方法,我们可以通过这些方法改善你的 Xfce 桌面环境的外观和感觉。 + +默认 Xfce 桌面环境看起来有些像这样: + +![Xfce default screen][5] + +如你所见,默认 Xfce 桌面有点乏味。我们将使用主题、图标包以及更改默认 dock 来使它看起来新鲜和有点惊艳。 + +#### 1. 在 Xfce 中更改主题 + +我们将做的第一件事是从 [xfce-look.org][6] 中找到一款主题。我最喜欢的 Xfce 主题是 [XFCE-D-PRO][7]。 + +你可以从[这里][8]下载主题,并提取到某处。 + +你可以复制提取出的这些主题文件到你的家目录中的 `.theme` 文件夹。如果该文件夹尚不存在,你可以创建一个,同样的道理,图标需要放在一个在家目录中的 `.icons` 文件夹。 + +打开 **设置 > 外观 > 样式** 来选择该主题,注销并重新登录以查看更改。默认的 Adwaita-dark 也是一个不错的主题。 + +![Appearance Xfce][9] + +你可以在 Xfce 上使用各种[好的 GTK 主题][10]。 + +#### 2. 在 Xfce 中更改图标 + +Xfce-look.org 也提供你可以下载的图标主题,提取并放置图标到你的家目录中 `.icons` 目录。在你添加图标主题到 `.icons` 目录中后,转到 **设置 > 外观 > 图标** 来选择这个图标主题。 + +![Moka icon theme][11] + +我已经安装 [Moka 图标集][12] ,它看起来令人惊艳。 + +![Moka theme][13] + +你也可以参考我们[令人惊艳的图标主题][14]列表。 + +##### 可选: 通过 Synaptic 安装主题 + +如果你想避免手工搜索和复制文件,在你的系统中安装 Synaptic 软件包管理器。你可以通过网络来查找最佳的主题和图标集,使用 synaptic 软件包管理器,你可以搜索和安装主题。 + +``` +sudo apt-get install synaptic +``` + +**通过 Synaptic 搜索和安装主题/图标** + +打开 synaptic,并在**搜索**上单击。输入你期望的主题名,接下来,它将显示匹配主题的列表。勾选所有更改所需的附加依赖,并在**应用**上单击。这些操作将下载主题和安装主题。 + +![Arc Theme][15] + +在安装后,你可以打开**外观**选项来选择期望的主题。 + +在我看来,这不是在 Xfce 中安装主题的最佳方法。 + +#### 3. 在 Xfce 中更改桌面背景 + +再强调一次,默认 Xfce 桌面背景也不错。但是你可以把桌面背景更改成与你的图标和主题相匹配的东西。 + +为在 Xfce 中更改桌面背景,在桌面上右击,并单击**桌面设置**。从文件夹选择中选择**背景**,并选择任意一个默认背景或自定义背景。 + +![Changing desktop wallpapers][16] + +#### 4. 在 Xfce 中更改 dock + +默认 dock 也不错,恰如其分。但是,再强调一次,它看来有点平平淡淡。 + +![Docky][17] + +不过,如果你想你的 dock 变得更好,并带有更多一点的自定义选项,你可以安装另一个 dock 。 + +Plank 是一个简单而轻量级的、高度可配置的 dock。 + +为安装 Plank ,使用下面的命令: + +``` +sudo apt-get install plank +``` + +如果 Plank 在默认存储库中没有,你可以从这个 PPA 中安装它。 + +``` +sudo add-apt-repository ppa:ricotz/docky +sudo apt-get update +sudo apt-get install plank +``` + +在你使用 Plank 前,你应该通过右键单击移除默认的 dock,并在**面板设置**下,单击**删除**。 + +在完成后,转到 **附件 > Plank** 来启动 Plank dock 。 + +![Plank][18] + +Plank 从你正在使用的图标主题中选取图标。因此,如果你更改图标主题,你也将在 dock 中看到相关的更改。 + +### 总结 + +XFCE 是一个轻量级、快速和高度可自定义的桌面环境。如果你的系统资源有限,它服务很好,并且你可以简单地自定义它来看起来更好。这是在应用这些步骤后,我的屏幕的外观。 + +![XFCE desktop][19] + +这只是半个小时的努力成果,你可以使用不同的主题/图标自定义使它看起来更好。请随意在评论区分享你自定义的 XFCE 桌面屏幕,以及你正在使用的主题和图标组合。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/customize-xfce/ + +作者:[Ambarish Kumar][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://itsfoss.com/author/ambarish/ +[1]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/07/xfce-customization.jpeg +[2]:https://itsfoss.com/best-linux-desktop-environments/ +[3]:https://itsfoss.com/lightweight-linux-beginners/ +[4]:https://xfce.org/ +[5]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/06/1-1-800x410.jpg +[6]:http://xfce-look.org +[7]:https://www.xfce-look.org/p/1207818/XFCE-D-PRO +[8]:https://www.xfce-look.org/p/1207818/startdownload?file_id=1523730502&file_name=XFCE-D-PRO-1.6.tar.xz&file_type=application/x-xz&file_size=105328&url=https%3A%2F%2Fdl.opendesktop.org%2Fapi%2Ffiles%2Fdownloadfile%2Fid%2F1523730502%2Fs%2F6019b2b57a1452471eac6403ae1522da%2Ft%2F1529360682%2Fu%2F%2FXFCE-D-PRO-1.6.tar.xz +[9]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/07/4.jpg +[10]:https://itsfoss.com/best-gtk-themes/ +[11]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/07/6.jpg +[12]:https://snwh.org/moka +[13]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/07/11-800x547.jpg +[14]:https://itsfoss.com/best-icon-themes-ubuntu-16-04/ +[15]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/07/5-800x531.jpg +[16]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/07/7-800x546.jpg +[17]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/07/8.jpg +[18]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/07/9.jpg +[19]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/07/10-800x447.jpg diff --git a/published/201908/20180928 Quiet log noise with Python and machine learning.md b/published/201908/20180928 Quiet log noise with Python and machine learning.md new file mode 100644 index 0000000000..d6471b3969 --- /dev/null +++ b/published/201908/20180928 Quiet log noise with Python and machine learning.md @@ -0,0 +1,106 @@ +Logreduce:用 Python 和机器学习去除日志噪音 +====== + +> Logreduce 可以通过从大量日志数据中挑选出异常来节省调试时间。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/sound-radio-noise-communication.png?itok=KMNn9QrZ) + +持续集成(CI)作业会生成大量数据。当一个作业失败时,弄清楚出了什么问题可能是一个繁琐的过程,它涉及到调查日志以发现根本原因 —— 这通常只能在全部的作业输出的一小部分中找到。为了更容易地将最相关的数据与其余数据分开,可以使用先前成功运行的作业结果来训练 [Logreduce][1] 机器学习模型,以从失败的运行日志中提取异常。 + +此方法也可以应用于其他用例,例如,从 [Journald][2] 或其他系统级的常规日志文件中提取异常。 + +### 使用机器学习来降低噪音 + +典型的日志文件包含许多标称事件(“基线”)以及与开发人员相关的一些例外事件。基线可能包含随机元素,例如难以检测和删除的时间戳或唯一标识符。要删除基线事件,我们可以使用 [k-最近邻模式识别算法][3](k-NN)。 + +![](https://opensource.com/sites/default/files/uploads/ml-generic-workflow.png) + +日志事件必须转换为可用于 k-NN 回归的数值。使用通用特征提取工具 [HashingVectorizer][4] 可以将该过程应用于任何类型的日志。它散列每个单词并在稀疏矩阵中对每个事件进行编码。为了进一步减少搜索空间,这个标记化过程删除了已知的随机单词,例如日期或 IP 地址。 + +![](https://opensource.com/sites/default/files/uploads/hashing-vectorizer.png) + +训练模型后,k-NN 搜索可以告诉我们每个新事件与基线的距离。 + +![](https://opensource.com/sites/default/files/uploads/kneighbors.png) + +这个 [Jupyter 笔记本][5] 演示了该稀疏矩阵向量的处理和图形。 + +![](https://opensource.com/sites/default/files/uploads/anomaly-detection-with-scikit-learn.png) + +### Logreduce 介绍 + +Logreduce Python 软件透明地实现了这个过程。Logreduce 的最初目标是使用构建数据库来协助分析 [Zuul CI][6] 作业的失败问题,现在它已集成到 [Software Factory 开发车间][7]的作业日志处理中。 + +最简单的是,Logreduce 会比较文件或目录并删除相似的行。Logreduce 为每个源文件构建模型,并使用以下语法输出距离高于定义阈值的任何目标行:`distance | filename:line-number: line-content`。 + +``` +$ logreduce diff /var/log/audit/audit.log.1 /var/log/audit/audit.log +INFO  logreduce.Classifier - Training took 21.982s at 0.364MB/s (1.314kl/s) (8.000 MB - 28.884 kilo-lines) +0.244 | audit.log:19963:        type=USER_AUTH acct="root" exe="/usr/bin/su" hostname=managesf.sftests.com +INFO  logreduce.Classifier - Testing took 18.297s at 0.306MB/s (1.094kl/s) (5.607 MB - 20.015 kilo-lines) +99.99% reduction (from 20015 lines to 1 + +``` + +更高级的 Logreduce 用法可以离线训练模型以便重复使用。可以使用基线的许多变体来拟合 k-NN 搜索树。 + +``` +$ logreduce dir-train audit.clf /var/log/audit/audit.log.* +INFO  logreduce.Classifier - Training took 80.883s at 0.396MB/s (1.397kl/s) (32.001 MB - 112.977 kilo-lines) +DEBUG logreduce.Classifier - audit.clf: written +$ logreduce dir-run audit.clf /var/log/audit/audit.log +``` + +Logreduce 还实现了接口,以发现 Journald 时间范围(天/周/月)和 Zuul CI 作业构建历史的基线。它还可以生成 HTML 报告,该报告在一个简单的界面中将在多个文件中发现的异常进行分组。 + +![](https://opensource.com/sites/default/files/uploads/html-report.png) + +### 管理基线 + +使用 k-NN 回归进行异常检测的关键是拥有一个已知良好基线的数据库,该模型使用数据库来检测偏离太远的日志行。此方法依赖于包含所有标称事件的基线,因为基线中未找到的任何内容都将报告为异常。 + +CI 作业是 k-NN 回归的重要目标,因为作业的输出通常是确定性的,之前的运行结果可以自动用作基线。 Logreduce 具有 Zuul 作业角色,可以将其用作失败的作业发布任务的一部分,以便发布简明报告(而不是完整作业的日志)。只要可以提前构建基线,该原则就可以应用于其他情况。例如,标称系统的 [SoS 报告][8] 可用于查找缺陷部署中的问题。 + +![](https://opensource.com/sites/default/files/uploads/baselines.png) + +### 异常分类服务 + +下一版本的 Logreduce 引入了一种服务器模式,可以将日志处理卸载到外部服务,在外部服务中可以进一步分析该报告。它还支持导入现有报告和请求以分析 Zuul 构建。这些服务以异步方式运行分析,并具有 Web 界面以调整分数并消除误报。 + +![](https://opensource.com/sites/default/files/uploads/classification-interface.png) + +已审核的报告可以作为独立数据集存档,其中包含目标日志文件和记录在一个普通的 JSON 文件中的异常行的分数。 + +### 项目路线图 + +Logreduce 已经能有效使用,但是有很多机会来改进该工具。未来的计划包括: + +* 策划在日志文件中发现的许多带注释的异常,并生成一个公共域数据集以进行进一步研究。日志文件中的异常检测是一个具有挑战性的主题,并且有一个用于测试新模型的通用数据集将有助于识别新的解决方案。 +* 重复使用带注释的异常模型来优化所报告的距离。例如,当用户通过将距离设置为零来将日志行标记为误报时,模型可能会降低未来报告中这些日志行的得分。 +* 对存档异常取指纹特征以检测新报告何时包含已知的异常。因此,该服务可以通知用户该作业遇到已知问题,而不是报告异常的内容。解决问题后,该服务可以自动重新启动该作业。 +* 支持更多基准发现接口,用于 SOS 报告、Jenkins 构建、Travis CI 等目标。 + +如果你有兴趣参与此项目,请通过 #log-classify Freenode IRC 频道与我们联系。欢迎反馈! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/quiet-log-noise-python-and-machine-learning + +作者:[Tristan de Cacqueray][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/tristanc +[1]: https://pypi.org/project/logreduce/ +[2]: http://man7.org/linux/man-pages/man8/systemd-journald.service.8.html +[3]: https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm +[4]: http://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.HashingVectorizer.html +[5]: https://github.com/TristanCacqueray/anomaly-detection-workshop-opendev/blob/master/datasets/notebook/anomaly-detection-with-scikit-learn.ipynb +[6]: https://zuul-ci.org +[7]: https://www.softwarefactory-project.io +[8]: https://sos.readthedocs.io/en/latest/ +[9]: https://www.openstack.org/summit/berlin-2018/summit-schedule/speakers/4307 +[10]: https://www.openstack.org/summit/berlin-2018/ diff --git a/published/201908/20181011 Exploring the Linux kernel- The secrets of Kconfig-kbuild.md b/published/201908/20181011 Exploring the Linux kernel- The secrets of Kconfig-kbuild.md new file mode 100644 index 0000000000..86f0c467f3 --- /dev/null +++ b/published/201908/20181011 Exploring the Linux kernel- The secrets of Kconfig-kbuild.md @@ -0,0 +1,249 @@ +探索 Linux 内核:Kconfig/kbuild 的秘密 +====== + +> 深入理解 Linux 配置/构建系统是如何工作的。 + +![](https://img.linux.net.cn/data/attachment/album/201908/15/093935dvyk5znoaooaooba.jpg) + +自从 Linux 内核代码迁移到 Git 以来,Linux 内核配置/构建系统(也称为 Kconfig/kbuild)已存在很长时间了。然而,作为支持基础设施,它很少成为人们关注的焦点;甚至在日常工作中使用它的内核开发人员也从未真正思考过它。 + +为了探索如何编译 Linux 内核,本文将深入介绍 Kconfig/kbuild 内部的过程,解释如何生成 `.config` 文件和 `vmlinux`/`bzImage` 文件,并介绍一个巧妙的依赖性跟踪技巧。 + +### Kconfig + +构建内核的第一步始终是配置。Kconfig 有助于使 Linux 内核高度模块化和可定制。Kconfig 为用户提供了许多配置目标: + + +| 配置目标 | 解释 | +| ---------------- | --------------------------------------------------------- | +| `config` | 利用命令行程序更新当前配置 | +| `nconfig` | 利用基于 ncurses 菜单的程序更新当前配置 | +| `menuconfig` | 利用基于菜单的程序更新当前配置 | +| `xconfig` | 利用基于 Qt 的前端程序更新当前配置 | +| `gconfig` | 利用基于 GTK+ 的前端程序更新当前配置 | +| `oldconfig` | 基于提供的 `.config` 更新当前配置 | +| `localmodconfig` | 更新当前配置,禁用没有载入的模块 | +| `localyesconfig` | 更新当前配置,转换本地模块到核心 | +| `defconfig` | 带有来自架构提供的 `defconcig` 默认值的新配置 | +| `savedefconfig` | 保存当前配置为 `./defconfig`(最小配置) | +| `allnoconfig` | 所有选项回答为 `no` 的新配置 | +| `allyesconfig` | 所有选项回答为 `yes` 的新配置 | +| `allmodconfig` | 尽可能选择所有模块的新配置 | +| `alldefconfig` | 所有符号(选项)设置为默认值的新配置 | +| `randconfig` | 所有选项随机选择的新配置 | +| `listnewconfig` | 列出新选项 | +| `olddefconfig` | 同 `oldconfig` 一样,但设置新符号(选项)为其默认值而无须提问 | +| `kvmconfig` | 启用支持 KVM 访客内核模块的附加选项 | +| `xenconfig` | 启用支持 xen 的 dom0 和 访客内核模块的附加选项 | +| `tinyconfig` | 配置尽可能小的内核 | + +我认为 `menuconfig` 是这些目标中最受欢迎的。这些目标由不同的主程序host program处理,这些程序由内核提供并在内核构建期间构建。一些目标有 GUI(为了方便用户),而大多数没有。与 Kconfig 相关的工具和源代码主要位于内核源代码中的 `scripts/kconfig/` 下。从 `scripts/kconfig/Makefile` 中可以看到,这里有几个主程序,包括 `conf`、`mconf` 和 `nconf`。除了 `conf` 之外,每个都负责一个基于 GUI 的配置目标,因此,`conf` 处理大多数目标。 + +从逻辑上讲,Kconfig 的基础结构有两部分:一部分实现一种[新语言][1]来定义配置项(参见内核源代码下的 Kconfig 文件),另一部分解析 Kconfig 语言并处理配置操作。 + +大多数配置目标具有大致相同的内部过程(如下所示): + +![](https://opensource.com/sites/default/files/uploads/kconfig_process.png) + +请注意,所有配置项都具有默认值。 + +第一步读取源代码根目录下的 Kconfig 文件,构建初始配置数据库;然后它根据如下优先级读取现有配置文件来更新初始数据库: + +1. `.config` +2. `/lib/modules/$(shell,uname -r)/.config` +3. `/etc/kernel-config` +4. `/boot/config-$(shell,uname -r)` +5. `ARCH_DEFCONFIG` +6. `arch/$(ARCH)/defconfig` + +如果你通过 `menuconfig` 进行基于 GUI 的配置或通过 `oldconfig` 进行基于命令行的配置,则根据你的自定义更新数据库。最后,该配置数据库被转储到 `.config` 文件中。 + +但 `.config` 文件不是内核构建的最终素材;这就是 `syncconfig` 目标存在的原因。`syncconfig`曾经是一个名为 `silentoldconfig` 的配置目标,但它没有做到其旧名称所说的工作,所以它被重命名。此外,因为它是供内部使用的(不适用于用户),所以它已从上述列表中删除。 + +以下是 `syncconfig` 的作用: + +![](https://opensource.com/sites/default/files/uploads/syncconfig.png) + +`syncconfig` 将 `.config` 作为输入并输出许多其他文件,这些文件分为三类: + +* `auto.conf` & `tristate.conf` 用于 makefile 文本处理。例如,你可以在组件的 makefile 中看到这样的语句:`obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o`。 +* `autoconf.h` 用于 C 语言的源文件。 +* `include/config/` 下空的头文件用于 kbuild 期间的配置依赖性跟踪。下面会解释。 + +配置完成后,我们将知道哪些文件和代码片段未编译。 + +### kbuild + +组件式构建,称为*递归 make*,是 GNU `make` 管理大型项目的常用方法。kbuild 是递归 make 的一个很好的例子。通过将源文件划分为不同的模块/组件,每个组件都由其自己的 makefile 管理。当你开始构建时,顶级 makefile 以正确的顺序调用每个组件的 makefile、构建组件,并将它们收集到最终的执行程序中。 + +kbuild 指向到不同类型的 makefile: + +* `Makefile` 位于源代码根目录的顶级 makefile。 +* `.config` 是内核配置文件。 +* `arch/$(ARCH)/Makefile` 是架构的 makefile,它用于补充顶级 makefile。 +* `scripts/Makefile.*` 描述所有的 kbuild makefile 的通用规则。 +* 最后,大约有 500 个 kbuild makefile。 + +顶级 makefile 会将架构 makefile 包含进去,读取 `.config` 文件,下到子目录,在 `scripts/ Makefile.*` 中定义的例程的帮助下,在每个组件的 makefile 上调用 `make`,构建每个中间对象,并将所有的中间对象链接为 `vmlinux`。内核文档 [Documentation/kbuild/makefiles.txt][2] 描述了这些 makefile 的方方面面。 + +作为一个例子,让我们看看如何在 x86-64 上生成 `vmlinux`: + +![vmlinux overview][4] + +(此插图基于 Richard Y. Steven 的[博客][5]。有过更新,并在作者允许的情况下使用。) + +进入 `vmlinux` 的所有 `.o` 文件首先进入它们自己的 `built-in.a`,它通过变量`KBUILD_VMLINUX_INIT`、`KBUILD_VMLINUX_MAIN`、`KBUILD_VMLINUX_LIBS` 表示,然后被收集到 `vmlinux` 文件中。 + +在下面这个简化的 makefile 代码的帮助下,了解如何在 Linux 内核中实现递归 make: + +``` +# In top Makefile +vmlinux: scripts/link-vmlinux.sh $(vmlinux-deps) +                +$(call if_changed,link-vmlinux) + +# Variable assignments +vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) + +export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) +export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt-y) +export KBUILD_VMLINUX_LIBS := $(libs-y1) +export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds + +init-y          := init/ +drivers-y       := drivers/ sound/ firmware/ +net-y           := net/ +libs-y          := lib/ +core-y          := usr/ +virt-y          := virt/ + +# Transform to corresponding built-in.a +init-y          := $(patsubst %/, %/built-in.a, $(init-y)) +core-y          := $(patsubst %/, %/built-in.a, $(core-y)) +drivers-y       := $(patsubst %/, %/built-in.a, $(drivers-y)) +net-y           := $(patsubst %/, %/built-in.a, $(net-y)) +libs-y1         := $(patsubst %/, %/lib.a, $(libs-y)) +libs-y2         := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y))) +virt-y          := $(patsubst %/, %/built-in.a, $(virt-y)) + +# Setup the dependency. vmlinux-deps are all intermediate objects, vmlinux-dirs +# are phony targets, so every time comes to this rule, the recipe of vmlinux-dirs +# will be executed. Refer "4.6 Phony Targets" of `info make` +$(sort $(vmlinux-deps)): $(vmlinux-dirs) ; + +# Variable vmlinux-dirs is the directory part of each built-in.a +vmlinux-dirs    := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ +                     $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ +                     $(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y))) + +# The entry of recursive make +$(vmlinux-dirs): +                $(Q)$(MAKE) $(build)=$@ need-builtin=1 +``` + +递归 make 的配方recipe被扩展开是这样的: + +``` +make -f scripts/Makefile.build obj=init need-builtin=1 +``` + +这意味着 `make` 将进入 `scripts/Makefile.build` 以继续构建每个 `built-in.a`。在`scripts/link-vmlinux.sh` 的帮助下,`vmlinux` 文件最终位于源根目录下。 + +#### vmlinux 与 bzImage 对比 + +许多 Linux 内核开发人员可能不清楚 `vmlinux` 和 `bzImage` 之间的关系。例如,这是他们在 x86-64 中的关系: + +![](https://opensource.com/sites/default/files/uploads/vmlinux-bzimage.png) + +源代码根目录下的 `vmlinux` 被剥离、压缩后,放入 `piggy.S`,然后与其他对等对象链接到 `arch/x86/boot/compressed/vmlinux`。同时,在 `arch/x86/boot` 下生成一个名为 `setup.bin` 的文件。可能有一个可选的第三个文件,它带有重定位信息,具体取决于 `CONFIG_X86_NEED_RELOCS` 的配置。 + +由内核提供的称为 `build` 的宿主程序将这两个(或三个)部分构建到最终的 `bzImage` 文件中。 + +#### 依赖跟踪 + +kbuild 跟踪三种依赖关系: + +1. 所有必备文件(`*.c` 和 `*.h`) +2. 所有必备文件中使用的 `CONFIG_` 选项 +3. 用于编译该目标的命令行依赖项 + +第一个很容易理解,但第二个和第三个呢? 内核开发人员经常会看到如下代码: + +``` +#ifdef CONFIG_SMP +__boot_cpu_id = cpu; +#endif +``` + +当 `CONFIG_SMP` 改变时,这段代码应该重新编译。编译源文件的命令行也很重要,因为不同的命令行可能会导致不同的目标文件。 + +当 `.c` 文件通过 `#include` 指令使用头文件时,你需要编写如下规则: + +``` +main.o: defs.h +        recipe... +``` + +管理大型项目时,需要大量的这些规则;把它们全部写下来会很乏味无聊。幸运的是,大多数现代 C 编译器都可以通过查看源文件中的 `#include` 行来为你编写这些规则。对于 GNU 编译器集合(GCC),只需添加一个命令行参数:`-MD depfile` + +``` +# In scripts/Makefile.lib +c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \ +                 -include $(srctree)/include/linux/compiler_types.h       \ +                 $(__c_flags) $(modkern_cflags)                           \ +                 $(basename_flags) $(modname_flags) +``` + +这将生成一个 `.d` 文件,内容如下: + +``` +init_task.o: init/init_task.c include/linux/kconfig.h \ +  include/generated/autoconf.h include/linux/init_task.h \ +  include/linux/rcupdate.h include/linux/types.h \ +  ... +``` + +然后主程序 [fixdep][6] 通过将 depfile 文件和命令行作为输入来处理其他两个依赖项,然后以 makefile 格式输出一个 `..cmd` 文件,它记录命令行和目标的所有先决条件(包括配置)。 它看起来像这样: + +``` +# The command line used to compile the target +cmd_init/init_task.o := gcc -Wp,-MD,init/.init_task.o.d  -nostdinc ... +... +# The dependency files +deps_init/init_task.o := \ + $(wildcard include/config/posix/timers.h) \ + $(wildcard include/config/arch/task/struct/on/stack.h) \ + $(wildcard include/config/thread/info/in/task.h) \ + ... + include/uapi/linux/types.h \ + arch/x86/include/uapi/asm/types.h \ + include/uapi/asm-generic/types.h \ + ... +``` + +在递归 make 中,`..cmd` 文件将被包含,以提供所有依赖关系信息并帮助决定是否重建目标。 + +这背后的秘密是 `fixdep` 将解析 depfile(`.d` 文件),然后解析里面的所有依赖文件,搜索所有 `CONFIG_` 字符串的文本,将它们转换为相应的空的头文件,并将它们添加到目标的先决条件。每次配置更改时,相应的空的头文件也将更新,因此 kbuild 可以检测到该更改并重建依赖于它的目标。因为还记录了命令行,所以很容易比较最后和当前的编译参数。 + +### 展望未来 + +Kconfig/kbuild 在很长一段时间内没有什么变化,直到新的维护者 Masahiro Yamada 于 2017 年初加入,现在 kbuild 正在再次积极开发中。如果你不久后看到与本文中的内容不同的内容,请不要感到惊讶。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/kbuild-and-kconfig + +作者:[Cao Jin][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/pinocchio +[b]: https://github.com/lujun9972 +[1]: https://github.com/torvalds/linux/blob/master/Documentation/kbuild/kconfig-language.txt +[2]: https://www.mjmwired.net/kernel/Documentation/kbuild/makefiles.txt +[3]: https://opensource.com/file/411516 +[4]: https://opensource.com/sites/default/files/uploads/vmlinux_generation_process.png (vmlinux overview) +[5]: https://blog.csdn.net/richardysteven/article/details/52502734 +[6]: https://github.com/torvalds/linux/blob/master/scripts/basic/fixdep.c diff --git a/published/201908/20181029 Create animated, scalable vector graphic images with MacSVG.md b/published/201908/20181029 Create animated, scalable vector graphic images with MacSVG.md new file mode 100644 index 0000000000..601c64ed31 --- /dev/null +++ b/published/201908/20181029 Create animated, scalable vector graphic images with MacSVG.md @@ -0,0 +1,69 @@ +使用 MacSVG 创建 SVG 动画 +====== + +> 开源 SVG:墙上的魔法字。 + +![](https://img.linux.net.cn/data/attachment/album/201908/18/000809mzl1wb1ww754z455.jpg) + +新巴比伦的摄政王[伯沙撒][1]没有注意到他在盛宴期间神奇地[书写在墙上的文字][2]。但是,如果他在公元前 539 年有一台笔记本电脑和良好的互联网连接,他可能会通过在浏览器上阅读 SVG 来避开那些讨厌的波斯人。 + +出现在网页上的动画文本和对象是建立用户兴趣和参与度的好方法。有几种方法可以实现这一点,例如视频嵌入、动画 GIF 或幻灯片 —— 但你也可以使用[可缩放矢量图形(SVG)][3]。 + +SVG 图像与 JPG 不同,因为它可以缩放而不会丢失其分辨率。矢量图像是由点而不是像素创建的,所以无论它放大到多大,它都不会失去分辨率或像素化。充分利用可缩放的静态图像的一个例子是网站的徽标。 + +### 动起来,动起来 + +你可以使用多种绘图程序创建 SVG 图像,包括开源的 [Inkscape][4] 和 Adobe Illustrator。让你的图像“能动起来”需要更多的努力。幸运的是,有一些开源解决方案甚至可以引起伯沙撒的注意。 + +[MacSVG][5] 是一款可以让你的图像动起来的工具。你可以在 [GitHub][6] 上找到源代码。 + +根据其[官网][5]说,MacSVG 由阿肯色州康威的 Douglas Ward 开发,是一个“用于设计 HTML5 SVG 艺术和动画的开源 Mac OS 应用程序”。 + +我想使用 MacSVG 来创建一个动画签名。我承认我发现这个过程有点令人困惑,并且在我第一次尝试创建一个实际的动画 SVG 图像时失败了。 + +![](https://opensource.com/sites/default/files/uploads/macsvg-screen.png) + +重要的是首先要了解要展示的书法内容实际写的是什么。 + +动画文字背后的属性是 [stroke-dasharray][7]。将该术语分成三个单词有助于解释正在发生的事情:“stroke” 是指用笔(无论是物理的笔还是数字化笔)制作的线条或笔画。“dash” 意味着将笔划分解为一系列折线。“array” 意味着将整个东西生成为数组。这是一个简单的概述,但它可以帮助我理解应该发生什么以及为什么。 + +使用 MacSVG,你可以导入图形(.PNG)并使用钢笔工具描绘书写路径。我使用了草书来表示我的名字。然后,只需应用该属性来让书法动画起来、增加和减少笔划的粗细、改变其颜色等等。完成后,动画的书法将导出为 .SVG 文件,并可以在网络上使用。除书写外,MacSVG 还可用于许多不同类型的 SVG 动画。 + +### 在 WordPress 中书写 + +我准备在我的 [WordPress][8] 网站上传和分享我的 SVG 示例,但我发现 WordPress 不允许进行 SVG 媒体导入。幸运的是,我找到了一个方便的插件:Benbodhi 的 [SVG 支持][9]插件允许快速、轻松地导入我的 SVG,就像我将 JPG 导入媒体库一样。我能够在世界各地向巴比伦人展示我[写在墙上的魔法字][10]。 + +我在 [Brackets][11] 中开源了 SVG 的源代码,结果如下: + +``` + + +Path animation with stroke-dasharrayThis example demonstrates the use of a path element, an animate element, and the stroke-dasharray attribute to simulate drawing. +``` + +你会使用 MacSVG 做什么? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/macsvg-open-source-tool-animation + +作者:[Jeff Macharyas][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rikki-endsley +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Belshazzar +[2]: https://en.wikipedia.org/wiki/Belshazzar%27s_feast +[3]: https://en.wikipedia.org/wiki/Scalable_Vector_Graphics +[4]: https://inkscape.org/ +[5]: https://macsvg.org/ +[6]: https://github.com/dsward2/macSVG +[7]: https://gist.github.com/mbostock/5649592 +[8]: https://macharyas.com/ +[9]: https://wordpress.org/plugins/svg-support/ +[10]: https://macharyas.com/index.php/2018/10/14/open-source-svg/ +[11]: http://brackets.io/ diff --git a/published/201908/20181029 DF-SHOW - A Terminal File Manager Based On An Old DOS Application.md b/published/201908/20181029 DF-SHOW - A Terminal File Manager Based On An Old DOS Application.md new file mode 100644 index 0000000000..0c15bde2ea --- /dev/null +++ b/published/201908/20181029 DF-SHOW - A Terminal File Manager Based On An Old DOS Application.md @@ -0,0 +1,150 @@ +DF-SHOW:一个基于老式 DOS 应用的终端文件管理器 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/10/dfshow-720x340.png) + +如果你曾经使用过老牌的 MS-DOS,你可能已经使用或听说过 DF-EDIT。DF-EDIT,意即 **D**irectory **F**ile **Edit**,它是一个鲜为人知的 DOS 文件管理器,最初由 Larry Kroeker 为 MS-DOS 和 PC-DOS 系统而编写。它用于在 MS-DOS 和 PC-DOS 系统中显示给定目录或文件的内容。今天,我偶然发现了一个名为 DF-SHOW 的类似实用程序(**D**irectory **F**ile **Show**),这是一个类 Unix 操作系统的终端文件管理器。它是鲜为人知的 DF-EDIT 文件管理器的 Unix 重写版本,其基于 1986 年发布的 DF-EDIT 2.3d。DF-SHOW 完全是自由开源的,并在 GPLv3 下发布。 + +DF-SHOW 可以: + +* 列出目录的内容, +* 查看文件, +* 使用你的默认文件编辑器编辑文件, +* 将文件复制到不同位置, +* 重命名文件, +* 删除文件, +* 在 DF-SHOW 界面中创建新目录, +* 更新文件权限,所有者和组, +* 搜索与搜索词匹配的文件, +* 启动可执行文件。 + +### DF-SHOW 用法 + +DF-SHOW 实际上是两个程序的结合,名为 `show` 和 `sf`。 + +#### Show 命令 + +`show` 程序(类似于 `ls` 命令)用于显示目录的内容、创建新目录、重命名和删除文件/文件夹、更新权限、搜索文件等。 + +要查看目录中的内容列表,请使用以下命令: + +``` +$ show +``` + +示例: + +``` +$ show dfshow +``` + +这里,`dfshow` 是一个目录。如果在未指定目录路径的情况下调用 `show` 命令,它将显示当前目录的内容。 + +这是 DF-SHOW 默认界面的样子。 + +![](https://www.ostechnix.com/wp-content/uploads/2018/10/dfshow-1.png) + +如你所见,DF-SHOW 的界面不言自明。 + +在顶部栏上,你会看到可用的选项列表,例如复制、删除、编辑、修改等。 + +完整的可用选项列表如下: + + * `C` opy(复制) + * `D` elete(删除) + * `E` dit(编辑) + * `H` idden(隐藏) + * `M` odify(修改) + * `Q` uit(退出) + * `R` ename(重命名) + * `S` how(显示) + * h `U` nt(文件内搜索) + * e `X` ec(执行) + * `R` un command(运行命令) + * `E` dit file(编辑文件) + * `H` elp(帮助) + * `M` ake dir(创建目录) + * `S` how dir(显示目录) + +在每个选项中,有一个字母以大写粗体标记。只需按下该字母即可执行相应的操作。例如,要重命名文件,只需按 `R` 并键入新名称,然后按回车键重命名所选项目。 + +![](https://www.ostechnix.com/wp-content/uploads/2018/10/dfshow-2.png) + +要显示所有选项或取消操作,只需按 `ESC` 键即可。 + +此外,你将在 DF-SHOW 界面的底部看到一堆功能键,以浏览目录的内容。 + +* `UP` / `DOWN` 箭头或 `F1` / `F2` - 上下移动(一次一行), +* `PgUp` / `PgDn` - 一次移动一页, +* `F3` / `F4` - 立即转到列表的顶部和底部, +* `F5` - 刷新, +* `F6` - 标记/取消标记文件(标记的文件将在它们前面用 `*` 表示), +* `F7` / `F8` - 一次性标记/取消标记所有文件, +* `F9` - 按以下顺序对列表排序 - 日期和时间、名称、大小。 + +按 `h` 了解有关 `show` 命令及其选项的更多详细信息。 + +要退出 DF-SHOW,只需按 `q` 即可。 + +#### SF 命令 + +`sf` (显示文件)用于显示文件的内容。 + +``` +$ sf +``` + +![](https://www.ostechnix.com/wp-content/uploads/2018/10/dfshow-3.png) + +按 `h` 了解更多 `sf` 命令及其选项。要退出,请按 `q`。 + +想试试看?很好,让我们继续在 Linux 系统上安装 DF-SHOW,如下所述。 + +### 安装 DF-SHOW + +DF-SHOW 在 [AUR][1] 中可用,因此你可以使用 AUR 程序(如 [yay][2])在任何基于 Arch 的系统上安装它。 + +``` +$ yay -S dfshow +``` + +在 Ubuntu 及其衍生版上: + +``` +$ sudo add-apt-repository ppa:ian-hawdon/dfshow +$ sudo apt-get update +$ sudo apt-get install dfshow +``` + +在其他 Linux 发行版上,你可以从源代码编译和构建它,如下所示。 + +``` +$ git clone https://github.com/roberthawdon/dfshow +$ cd dfshow +$ ./bootstrap +$ ./configure +$ make +$ sudo make install +``` + +DF-SHOW 项目的作者只重写了 DF-EDIT 实用程序的一些应用程序。由于源代码可以在 GitHub 上免费获得,因此你可以添加更多功能、改进代码并提交或修复错误(如果有的话)。它仍处于 beta 阶段,但功能齐全。 + +你有没试过吗?如果试过,觉得如何?请在下面的评论部分告诉我们你的体验。 + +不管如何,希望这有用。还有更多好东西。敬请关注! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/df-show-a-terminal-file-manager-based-on-an-old-dos-application/ + +作者:[SK][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://aur.archlinux.org/packages/dfshow/ +[2]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ diff --git a/published/201908/20181030 Podman- A more secure way to run containers.md b/published/201908/20181030 Podman- A more secure way to run containers.md new file mode 100644 index 0000000000..50e64225a4 --- /dev/null +++ b/published/201908/20181030 Podman- A more secure way to run containers.md @@ -0,0 +1,128 @@ +Podman:一个更安全的运行容器的方式 +====== + +> Podman 使用传统的 fork/exec 模型(相对于客户端/服务器模型)来运行容器。 + +![](https://img.linux.net.cn/data/attachment/album/201908/23/234924m55sn8zt3b5q8815.jpg) + +在进入本文的主要主题 [Podman][1] 和容器之前,我需要了解一点 Linux 审计功能的技术。 + +### 什么是审计? + +Linux 内核有一个有趣的安全功能,叫做**审计**。它允许管理员在系统上监视安全事件,并将它们记录到`audit.log` 中,该文件可以本地存储或远程存储在另一台机器上,以防止黑客试图掩盖他的踪迹。 + +`/etc/shadow` 文件是一个经常要监控的安全文件,因为向其添加记录可能允许攻击者获得对系统的访问权限。管理员想知道是否有任何进程修改了该文件,你可以通过执行以下命令来执行此操作: + +``` +# auditctl -w /etc/shadow +``` + +现在让我们看看当我修改了 `/etc/shadow` 文件会发生什么: + +``` +# touch /etc/shadow +# ausearch -f /etc/shadow -i -ts recent + +type=PROCTITLE msg=audit(10/10/2018 09:46:03.042:4108) : proctitle=touch /etc/shadow type=SYSCALL msg=audit(10/10/2018 09:46:03.042:4108) : arch=x86_64 syscall=openat success=yes exit=3 a0=0xffffff9c a1=0x7ffdb17f6704 a2=O_WRONLY|O_CREAT|O_NOCTTY| O_NONBLOCK a3=0x1b6 items=2 ppid=2712 pid=3727 auid=dwalsh uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=pts1 ses=3 comm=touch exe=/usr/bin/touch subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)` +``` + +审计记录中有很多信息,但我重点注意到它记录了 root 修改了 `/etc/shadow` 文件,并且该进程的审计 UID(`auid`)的所有者是 `dwalsh`。 + +内核修改了这个文件了么? + +#### 跟踪登录 UID + +登录 UID(`loginuid`),存储在 `/proc/self/loginuid` 中,它是系统上每个进程的 proc 结构的一部分。该字段只能设置一次;设置后,内核将不允许任何进程重置它。 + +当我登录系统时,登录程序会为我的登录过程设置 `loginuid` 字段。 + +我(`dwalsh`)的 UID 是 3267。 + +``` +$ cat /proc/self/loginuid +3267 +``` + +现在,即使我变成了 root,我的登录 UID 仍将保持不变。 + +``` +$ sudo cat /proc/self/loginuid +3267 +``` + +请注意,从初始登录过程 fork 并 exec 的每个进程都会自动继承 `loginuid`。这就是内核知道登录的人是 `dwalsh` 的方式。 + +### 容器 + +现在让我们来看看容器。 + +``` +sudo podman run fedora cat /proc/self/loginuid +3267 +``` + +甚至容器进程也保留了我的 `loginuid`。 现在让我们用 Docker 试试。 + +``` +sudo docker run fedora cat /proc/self/loginuid +4294967295 +``` + +### 为什么不一样? + +Podman 对于容器使用传统的 fork/exec 模型,因此容器进程是 Podman 进程的后代。Docker 使用客户端/服务器模型。我执行的 `docker` 命令是 Docker 客户端工具,它通过客户端/服务器操作与 Docker 守护进程通信。然后 Docker 守护程序创建容器并处理 stdin/stdout 与 Docker 客户端工具的通信。 + +进程的默认 `loginuid`(在设置 `loginuid` 之前)是 `4294967295`(LCTT 译注:2^32 - 1)。由于容器是 Docker 守护程序的后代,而 Docker 守护程序是 init 系统的子代,所以,我们看到 systemd、Docker 守护程序和容器进程全部具有相同的 `loginuid`:`4294967295`,审计系统视其为未设置审计 UID。 + +``` +cat /proc/1/loginuid +4294967295 +``` + +### 怎么会被滥用? + +让我们来看看如果 Docker 启动的容器进程修改 `/etc/shadow` 文件会发生什么。 + +``` +$ sudo docker run --privileged -v /:/host fedora touch /host/etc/shadow +$ sudo ausearch -f /etc/shadow -i type=PROCTITLE msg=audit(10/10/2018 10:27:20.055:4569) : proctitle=/usr/bin/coreutils --coreutils-prog-shebang=touch /usr/bin/touch /host/etc/shadow type=SYSCALL msg=audit(10/10/2018 10:27:20.055:4569) : arch=x86_64 syscall=openat success=yes exit=3 a0=0xffffff9c a1=0x7ffdb6973f50 a2=O_WRONLY|O_CREAT|O_NOCTTY| O_NONBLOCK a3=0x1b6 items=2 ppid=11863 pid=11882 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=touch exe=/usr/bin/coreutils subj=system_u:system_r:spc_t:s0 key=(null) +``` + +在 Docker 情形中,`auid` 是未设置的(`4294967295`);这意味着安全人员可能知道有进程修改了 `/etc/shadow` 文件但身份丢失了。 + +如果该攻击者随后删除了 Docker 容器,那么在系统上谁修改 `/etc/shadow` 文件将没有任何跟踪信息。 + +现在让我们看看相同的场景在 Podman 下的情况。 + +``` +$ sudo podman run --privileged -v /:/host fedora touch /host/etc/shadow +$ sudo ausearch -f /etc/shadow -i type=PROCTITLE msg=audit(10/10/2018 10:23:41.659:4530) : proctitle=/usr/bin/coreutils --coreutils-prog-shebang=touch /usr/bin/touch /host/etc/shadow type=SYSCALL msg=audit(10/10/2018 10:23:41.659:4530) : arch=x86_64 syscall=openat success=yes exit=3 a0=0xffffff9c a1=0x7fffdffd0f34 a2=O_WRONLY|O_CREAT|O_NOCTTY| O_NONBLOCK a3=0x1b6 items=2 ppid=11671 pid=11683 auid=dwalsh uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=3 comm=touch exe=/usr/bin/coreutils subj=unconfined_u:system_r:spc_t:s0 key=(null) +``` + +由于它使用传统的 fork/exec 方式,因此 Podman 正确记录了所有内容。 + +这只是观察 `/etc/shadow` 文件的一个简单示例,但审计系统对于观察系统上的进程非常有用。使用 fork/exec 容器运行时(而不是客户端/服务器容器运行时)来启动容器允许你通过审计日志记录保持更好的安全性。 + +### 最后的想法 + +在启动容器时,与客户端/服务器模型相比,fork/exec 模型还有许多其他不错的功能。例如,systemd 功能包括: + +* `SD_NOTIFY`:如果将 Podman 命令放入 systemd 单元文件中,容器进程可以通过 Podman 返回通知,表明服务已准备好接收任务。这是在客户端/服务器模式下无法完成的事情。 +* 套接字激活:你可以将连接的套接字从 systemd 传递到 Podman,并传递到容器进程以便使用它们。这在客户端/服务器模型中是不可能的。 + +在我看来,其最好的功能是**作为非 root 用户运行 Podman 和容器**。这意味着你永远不会在宿主机上授予用户 root 权限,而在客户端/服务器模型中(如 Docker 使用的),你必须打开以 root 身份运行的特权守护程序的套接字来启动容器。在那里,你将受到守护程序中实现的安全机制与宿主机操作系统中实现的安全机制的支配 —— 这是一个危险的主张。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/podman-more-secure-way-run-containers + +作者:[Daniel J Walsh][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rhatdan +[b]: https://github.com/lujun9972 +[1]: https://podman.io diff --git a/published/201908/20181202 How To Customize The GNOME 3 Desktop.md b/published/201908/20181202 How To Customize The GNOME 3 Desktop.md new file mode 100644 index 0000000000..5e89f068b4 --- /dev/null +++ b/published/201908/20181202 How To Customize The GNOME 3 Desktop.md @@ -0,0 +1,285 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: subject: (How To Customize The GNOME 3 Desktop?) +[#]: via: (https://www.2daygeek.com/how-to-customize-the-gnome-3-desktop/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) +[#]: url: (https://linux.cn/article-11256-1.html) + +如何自定义 GNOME 3 桌面? +====== + +我们收到很多来自用户的电子邮件,要我们写一篇关于 GNOME 3 桌面自定义的文章,但是,我们没有时间来写这个主题。 + +在很长时间内,我一直在我的主要笔记本电脑上使用 Ubuntu 操作系统,并且,渐感无聊,我想测试一些与 Arch Linux 相关的其它的发行版。 + +我比较喜欢 Majaro,我在我的笔记本电脑中安装使用了 GNOME 3 桌面的 Manjaro 18.0 。 + +我按照我想要的自定义我的桌面。所以,我想抓住这个机会来详细撰写这篇文章,以帮助其他人。 + +这篇文章帮助其他人来轻松地自定义他们的桌面。 + +我不打算包括我所有的自定义,并且,我将强制性地添加一个对 Linux 桌面用户来说有用的必要的东西。 + +如果你觉得这篇文章中缺少一些调整,请你在评论区提到缺少的东西。对其它用户来说这是非常有用的 。 + +### 1) 如何在 GNOME 3 桌面中启动活动概述? + +活动概述将显示所有运行的应用程序,或通过单击 `Super` 键 ,或在左上角上单击“活动”按钮来启动/打开窗口。 + +它允许你来启动一个新的应用程序、切换窗口,和在工作空间之间移动窗口。 + +你可以通过选择如下任一操作简单地退出活动概述,如选择一个窗口、应用程序或工作区间,或通过按 `Super` 键或 `Esc` 键。 + +![][2] + +*活动概述屏幕截图* + +### 2) 如何在 GNOME 3 桌面中重新调整窗口大小? + +通过下面的组合键来将启动的窗口最大化、取消最大化,并吸附到屏幕的一侧(左侧或右侧)。 + + * `Super Key+下箭头`:来非最大化窗口。 + * `Super Key+上箭头`:来最大化窗口。 + * `Super Key+右箭头`:来在填充半个屏幕的右侧窗口。 + * `Super Key+作箭头`:来在填充半个屏幕的左侧窗口。 + + +![][3] + +*使用 `Super Key+下箭头` 来取消最大化窗口。* + +![][4] + +*使用 `Super Key+上箭头` 来最大化窗口。* + + +![][5] + +*使用 `Super Key+右箭头` 来在填充半个屏幕的右侧窗口。* + +![][6] + +*使用 `Super Key+左箭头` 来在填充半个屏幕的左侧窗口。* + +这个功能将帮助你可以一次查看两个应用程序,又名,拆分屏幕。 + +![][7] + +### 3) 如何在 GNOME 3 桌面中显示应用程序? + +在 Dash 中,单击“显示应用程序网格”按钮来显示在你的系统上的所有已安装的应用程序。 + +![][8] + +### 4) 如何在 GNOME 3 桌面中的 Dash 中添加应用程序? + +为加速你的日常活动,你可能想要把频繁使用的应用程序添加到 Dash 中,或拖拽应用程序启动器到 Dash 中。 + +它将允许你直接启动你的收藏夹中的应用程序,而不用先去搜索应用程序。为做到这样,在应用程序上简单地右击,并使用选项“添加到收藏夹”。 + +![][9] + +为从 Dash 中移除一个应用程序启动器(收藏的程序),要么从 Dash 中拖拽应用程序到网格按钮,或者在应用程序上简单地右击,并使用选项“从收藏夹中移除”。 + +![][10] + +### 5) 如何在 GNOME 3 桌面中的工作区间之间切换? + +工作区间允许你将窗口组合在一起。它将帮助你恰当地分隔你的工作。如果你正在做多项工作,并且你想对每项工作和相关的事物进行单独地分组,那么,它将是非常便利的,对你来说是一个非常方便和完美的选项。 + +你可以用两种方法切换工作区间,打开活动概述,并从右手边选择一个工作区间,或者使用下面的组合键。 + + * 使用 `Ctrl+Alt+Up` 切换到上一个工作区间。 + * 使用 `Ctrl+Alt+Down` 切换到下一个工作区间。 + +![][11] + +### 6) 如何在 GNOME 3 桌面中的应用程序之间切换 (应用程序切换器) ? + +使用 `Alt+Tab` 或 `Super+Tab` 来在应用程序之间切换。为启动应用程序切换器,使用 `Alt+Tab` 或 `Super+Tab` 。 + +在启动后,只需要按住 `Alt` 或 `Super` 键,按 `Tab` 键来从左到右的依次移动接下来的应用程序。 + +### 7) 如何在 GNOME 3 桌面中添加用户姓名到顶部面板? + +如果你想添加你的用户姓名到顶部面板,那么安装下面的[添加用户姓名到顶部面板][12] GNOME 扩展。 + +![][13] + +### 8) 如何在 GNOME 3 桌面中添加微软 Bing 的桌面背景? + +安装下面的 [Bing 桌面背景更换器][14] GNOME shell 扩展,来每天更改你的桌面背景为微软 Bing 的桌面背景。 + +![][15] + +### 9) 如何在 GNOME 3 桌面中启用夜光? + +夜光应用程序是著名的应用程序之一,它通过在日落后把你的屏幕从蓝光调成暗黄色,来减轻眼睛疲劳。 + +它在智能手机上也可用。相同目标的其它已知应用程序是 flux 和 [redshift][16]。 + +为启用这个特色,导航到**系统设置** >> **设备** >> **显示** ,并打开夜光。 + +![][17] + +在它启用后,状态图标将被放置到顶部面板上。 + +![][18] + +### 10) 如何在 GNOME 3 桌面中显示电池百分比? + +电池百分比将向你精确地显示电池使用情况。为启用这个功能,遵循下面的步骤。 + +启动 GNOME Tweaks >> **顶部栏** >> **电池百分比** ,并打开它。 + +![][19] + +在修改后,你能够在顶部面板上看到电池百分比图标。 + +![][20] + +### 11) 如何在 GNOME 3 桌面中启用鼠标右键单击? + +在 GNOME 3 桌面环境中右键单击是默认禁用的。为启用这个特色,遵循下面的步骤。 + +启动 GNOME Tweaks >> **键盘和鼠标** >> 鼠标点击硬件仿真,并选择“区域”选项。 + +![][21] + +### 12) 如何在 GNOME 3 桌面中启用单击最小化? + +启用单击最小化功能,这将帮助我们最小化打开的窗口,而不必使用最小化选项。 + +``` +$ gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize' +``` + +### 13) 如何在 GNOME 3 桌面中自定义 Dock ? + +如果你想更改你的 Dock,类似于 Deepin 桌面或 Mac 桌面,那么使用下面的一组命令。 + +``` +$ gsettings set org.gnome.shell.extensions.dash-to-dock dock-position BOTTOM +$ gsettings set org.gnome.shell.extensions.dash-to-dock extend-height false +$ gsettings set org.gnome.shell.extensions.dash-to-dock transparency-mode FIXED +$ gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 50 +``` + +![][22] + +### 14) 如何在 GNOME 3桌面中显示桌面? + +默认 `Super 键 + D` 快捷键不能显示你的桌面。为配置这种情况,遵循下面的步骤。 + +设置 >> **设备** >> **键盘** >> 单击在导航下的 **隐藏所有普通窗口** ,然后按 `Super 键 + D` ,最后按`设置`按钮来启用它。 + +![][23] + +### 15) 如何自定义日期和时间格式? + +GNOME 3 默认用 `Sun 04:48` 的格式来显示日期和时间。它并不清晰易懂,如果你想获得以下格式的输出:`Sun Dec 2 4:49 AM` ,遵循下面的步骤。 + +**对于日期修改:** 打开 GNOME Tweaks >> **顶部栏** ,并在时钟下启用“星期”选项。 + +![][24] + +**对于时间修改:** 设置 >> **具体情况** >> **日期和时间** ,然后,在时间格式中选择 `AM/PM` 选项。 + +![][25] + +在修改后,你能够看到与下面相同的日期和时间格式。 + +![][26] + +### 16) 如何在启动程序中永久地禁用不使用的服务? + +就我来说,我不使用 **蓝牙** & **cups(打印机服务)**。因此,在我的笔记本电脑上禁用这些服务。为在基于 Arch 的系统上禁用服务,使用 [Pacman 软件包管理器][27]。 + +对于蓝牙: + +``` +$ sudo systemctl stop bluetooth.service +$ sudo systemctl disable bluetooth.service +$ sudo systemctl mask bluetooth.service +$ systemctl status bluetooth.service +``` + +对于 cups: + +``` +$ sudo systemctl stop org.cups.cupsd.service +$ sudo systemctl disable org.cups.cupsd.service +$ sudo systemctl mask org.cups.cupsd.service +$ systemctl status org.cups.cupsd.service +``` + +最后,使用以下命令验证这些服务是否在启动程序中被禁用。如果你想再次确认这一点,你可以重新启动一次,并检查相同的东西。导航到以下链接来了解更多关于 [systemctl][28] 的用法, + +``` +$ systemctl list-unit-files --type=service | grep enabled +[email protected] enabled +dbus-org.freedesktop.ModemManager1.service enabled +dbus-org.freedesktop.NetworkManager.service enabled +dbus-org.freedesktop.nm-dispatcher.service enabled +display-manager.service enabled +gdm.service enabled +[email protected] enabled +linux-module-cleanup.service enabled +ModemManager.service enabled +NetworkManager-dispatcher.service enabled +NetworkManager-wait-online.service enabled +NetworkManager.service enabled +systemd-fsck-root.service enabled-runtime +tlp-sleep.service enabled +tlp.service enabled +``` + +### 17) 在 GNOME 3 桌面中安装图标和主题? + +有大量的图标和主题可供 GNOME 桌面使用,因此,选择吸引你的 [GTK 主题][29] 和 [图标主题][30]。 + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-customize-the-gnome-3-desktop/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-activities-overview-screenshot.jpg +[3]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-activities-unmaximize-the-window.jpg +[4]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-activities-maximize-the-window.jpg +[5]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-activities-fill-a-window-right-side.jpg +[6]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-activities-fill-a-window-left-side.jpg +[7]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-activities-split-screen.jpg +[8]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-display-applications.jpg +[9]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-add-applications-on-dash.jpg +[10]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-remove-applications-from-dash.jpg +[11]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-workspaces-screenshot.jpg +[12]: https://extensions.gnome.org/extension/1108/add-username-to-top-panel/ +[13]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-add-username-to-top-panel.jpg +[14]: https://extensions.gnome.org/extension/1262/bing-wallpaper-changer/ +[15]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-add-microsoft-bings-wallpaper.jpg +[16]: https://www.2daygeek.com/install-redshift-reduce-prevent-protect-eye-strain-night-linux/ +[17]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-enable-night-light.jpg +[18]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-enable-night-light-1.jpg +[19]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-display-battery-percentage.jpg +[20]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-display-battery-percentage-1.jpg +[21]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-enable-mouse-right-click.jpg +[22]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-dock-customization.jpg +[23]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-enable-show-desktop.jpg +[24]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-customize-date.jpg +[25]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-customize-time.jpg +[26]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-customize-date-time.jpg +[27]: https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/ +[28]: https://www.2daygeek.com/sysvinit-vs-systemd-cheatsheet-systemctl-command-usage/ +[29]: https://www.2daygeek.com/category/gtk-theme/ +[30]: https://www.2daygeek.com/category/icon-theme/ diff --git a/published/201908/20181213 Podman and user namespaces- A marriage made in heaven.md b/published/201908/20181213 Podman and user namespaces- A marriage made in heaven.md new file mode 100644 index 0000000000..ebf5c606a5 --- /dev/null +++ b/published/201908/20181213 Podman and user namespaces- A marriage made in heaven.md @@ -0,0 +1,146 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11268-1.html) +[#]: subject: (Podman and user namespaces: A marriage made in heaven) +[#]: via: (https://opensource.com/article/18/12/podman-and-user-namespaces) +[#]: author: (Daniel J Walsh https://opensource.com/users/rhatdan) + +Podman 和用户名字空间:天作之合 +====== + +> 了解如何使用 Podman 在单独的用户空间运行容器。 + +![](https://img.linux.net.cn/data/attachment/album/201908/25/220204khh9psjo1phllkok.jpg) + +[Podman][1] 是 [libpod][2] 库的一部分,使用户能够管理 pod、容器和容器镜像。在我的上一篇文章中,我写过将 [Podman 作为一种更安全的运行容器的方式][3]。在这里,我将解释如何使用 Podman 在单独的用户命名空间中运行容器。 + +作为分离容器的一个很棒的功能,我一直在思考[用户命名空间][4]user namespace,它主要是由 Red Hat 的 Eric Biederman 开发的。用户命名空间允许你指定用于运行容器的用户标识符(UID)和组标识符(GID)映射。这意味着你可以在容器内以 UID 0 运行,在容器外以 UID 100000 运行。如果容器进程逃逸出了容器,内核会将它们视为以 UID 100000 运行。不仅如此,任何未映射到用户命名空间的 UID 所拥有的文件对象都将被视为 `nobody` 所拥有(UID 是 `65534`, 由 `kernel.overflowuid` 指定),并且不允许容器进程访问,除非该对象可由“其他人”访问(即世界可读/可写)。 + +如果你拥有一个权限为 [660][5] 的属主为“真实” `root` 的文件,而当用户命名空间中的容器进程尝试读取它时,会阻止它们访问它,并且会将该文件视为 `nobody` 所拥有。 + +### 示例 + +以下是它是如何工作的。首先,我在 `root` 拥有的系统中创建一个文件。 + +``` +$ sudo bash -c "echo Test > /tmp/test" +$ sudo chmod 600 /tmp/test +$ sudo ls -l /tmp/test +-rw-------. 1 root root 5 Dec 17 16:40 /tmp/test +``` + +接下来,我将该文件卷挂载到一个使用用户命名空间映射 `0:100000:5000` 运行的容器中。 + +``` +$ sudo podman run -ti -v /tmp/test:/tmp/test:Z --uidmap 0:100000:5000 fedora sh +# id +uid=0(root) gid=0(root) groups=0(root) +# ls -l /tmp/test +-rw-rw----. 1 nobody nobody 8 Nov 30 12:40 /tmp/test +# cat /tmp/test +cat: /tmp/test: Permission denied +``` + +上面的 `--uidmap` 设置告诉 Podman 在容器内映射一系列的 5000 个 UID,从容器外的 UID 100000 开始的范围(100000-104999)映射到容器内 UID 0 开始的范围(0-4999)。在容器内部,如果我的进程以 UID 1 运行,则它在主机上为 100001。 + +由于实际的 `UID=0` 未映射到容器中,因此 `root` 拥有的任何文件都将被视为 `nobody` 所拥有。即使容器内的进程具有 `CAP_DAC_OVERRIDE` 能力,也无法覆盖此种保护。`DAC_OVERRIDE` 能力使得 root 的进程能够读/写系统上的任何文件,即使进程不是 `root` 用户拥有的,也不是全局可读或可写的。 + +用户命名空间的功能与宿主机上的功能不同。它们是命名空间的功能。这意味着我的容器的 root 只在容器内具有功能 —— 实际上只有该范围内的 UID 映射到内用户命名空间。如果容器进程逃逸出了容器,则它将没有任何非映射到用户命名空间的 UID 之外的功能,这包括 `UID=0`。即使进程可能以某种方式进入另一个容器,如果容器使用不同范围的 UID,它们也不具备这些功能。 + +请注意,SELinux 和其他技术还限制了容器进程破开容器时会发生的情况。 + +### 使用 podman top 来显示用户名字空间 + +我们在 `podman top` 中添加了一些功能,允许你检查容器内运行的进程的用户名,并标识它们在宿主机上的真实 UID。 + +让我们首先使用我们的 UID 映射运行一个 `sleep` 容器。 + +``` +$ sudo podman run --uidmap 0:100000:5000 -d fedora sleep 1000 +``` + +现在运行 `podman top`: + +``` +$ sudo podman top --latest user huser +USER   HUSER +root   100000 + +$ ps -ef | grep sleep +100000   21821 21809  0 08:04 ?         00:00:00 /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 1000 +``` + +注意 `podman top` 报告用户进程在容器内以 `root` 身份运行,但在宿主机(`HUSER`)上以 UID 100000 运行。此外,`ps` 命令确认 `sleep` 过程以 UID 100000 运行。 + +现在让我们运行第二个容器,但这次我们将选择一个单独的 UID 映射,从 200000 开始。 + +``` +$ sudo podman run --uidmap 0:200000:5000 -d fedora sleep 1000 +$ sudo podman top --latest user huser +USER   HUSER +root   200000 + +$ ps -ef | grep sleep +100000   21821 21809  0 08:04 ?         00:00:00 /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 1000 +200000   23644 23632  1 08:08 ?         00:00:00 /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 1000 +``` + +请注意,`podman top` 报告第二个容器在容器内以 `root` 身份运行,但在宿主机上是 UID=200000。 + +另请参阅 `ps` 命令,它显示两个 `sleep` 进程都在运行:一个为 100000,另一个为 200000。 + +这意味着在单独的用户命名空间内运行容器可以在进程之间进行传统的 UID 分离,而这从一开始就是 Linux/Unix 的标准安全工具。 + +### 用户名字空间的问题 + +几年来,我一直主张用户命名空间应该作为每个人应该有的安全工具,但几乎没有人使用过。原因是没有任何文件系统支持,也没有一个移动文件系统shifting file system。 + +在容器中,你希望在许多容器之间共享**基本**镜像。上面的每个示例中使用了 Fedora 基本镜像。Fedora 镜像中的大多数文件都由真实的 `UID=0` 拥有。如果我在此镜像上使用用户名称空间 `0:100000:5000` 运行容器,默认情况下它会将所有这些文件视为 `nobody` 所拥有,因此我们需要移动所有这些 UID 以匹配用户名称空间。多年来,我想要一个挂载选项来告诉内核重新映射这些文件 UID 以匹配用户命名空间。上游内核存储开发人员还在继续研究,在此功能上已经取得一些进展,但这是一个难题。 + +由于由 Nalin Dahyabhai 领导的团队开发的自动 [chown][6] 内置于[容器/存储][7]中,Podman 可以在同一镜像上使用不同的用户名称空间。当 Podman 使用容器/存储,并且 Podman 在新的用户命名空间中首次使用一个容器镜像时,容器/存储会 “chown”(如,更改所有权)镜像中的所有文件到用户命名空间中映射的 UID 并创建一个新镜像。可以把它想象成一个 `fedora:0:100000:5000` 镜像。 + +当 Podman 在具有相同 UID 映射的镜像上运行另一个容器时,它使用“预先 chown”的镜像。当我在`0:200000:5000` 上运行第二个容器时,容器/存储会创建第二个镜像,我们称之为 `fedora:0:200000:5000`。 + +请注意,如果你正在执行 `podman build` 或 `podman commit` 并将新创建的镜像推送到容器注册库,Podman 将使用容器/存储来反转该移动,并将推送所有文件属主变回真实 UID=0 的镜像。 + +这可能会导致在新的 UID 映射中创建容器时出现真正的减速,因为 `chown` 可能会很慢,具体取决于镜像中的文件数。此外,在普通的 [OverlayFS][8] 上,镜像中的每个文件都会被复制。普通的 Fedora 镜像最多可能需要 30 秒才能完成 `chown` 并启动容器。 + +幸运的是,Red Hat 内核存储团队(主要是 Vivek Goyal 和 Miklos Szeredi)在内核 4.19 中为 OverlayFS 添加了一项新功能。该功能称为“仅复制元数据”。如果使用 `metacopy=on` 选项来挂载层叠文件系统,则在更改文件属性时,它不会复制较低层的内容;内核会创建新的 inode,其中包含引用指向较低级别数据的属性。如果内容发生变化,它仍会复制内容。如果你想试用它,可以在 Red Hat Enterprise Linux 8 Beta 中使用此功能。 + +这意味着容器 `chown` 可能在两秒钟内发生,并且你不会倍增每个容器的存储空间。 + +这使得像 Podman 这样的工具在不同的用户命名空间中运行容器是可行的,大大提高了系统的安全性。 + +### 前瞻 + +我想向 Podman 添加一个新选项,比如 `--userns=auto`,它会为你运行的每个容器自动选择一个唯一的用户命名空间。这类似于 SELinux 与单独的多类别安全(MCS)标签一起使用的方式。如果设置环境变量 `PODMAN_USERNS=auto`,则甚至不需要设置该选项。 + +Podman 最终允许用户在不同的用户名称空间中运行容器。像 [Buildah][9] 和 [CRI-O][10] 这样的工具也可以利用用户命名空间。但是,对于 CRI-O,Kubernetes 需要了解哪个用户命名空间将运行容器引擎,上游正在开发这个功能。 + +在我的下一篇文章中,我将解释如何在用户命名空间中将 Podman 作为非 root 用户运行。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/12/podman-and-user-namespaces + +作者:[Daniel J Walsh][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rhatdan +[b]: https://github.com/lujun9972 +[1]: https://podman.io/ +[2]: https://github.com/containers/libpod +[3]: https://linux.cn/article-11261-1.html +[4]: http://man7.org/linux/man-pages/man7/user_namespaces.7.html +[5]: https://chmodcommand.com/chmod-660/ +[6]: https://en.wikipedia.org/wiki/Chown +[7]: https://github.com/containers/storage +[8]: https://en.wikipedia.org/wiki/OverlayFS +[9]: https://buildah.io/ +[10]: http://cri-o.io/ diff --git a/published/201908/20181220 Getting started with Prometheus.md b/published/201908/20181220 Getting started with Prometheus.md new file mode 100644 index 0000000000..47a9160dab --- /dev/null +++ b/published/201908/20181220 Getting started with Prometheus.md @@ -0,0 +1,167 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11234-1.html) +[#]: subject: (Getting started with Prometheus) +[#]: via: (https://opensource.com/article/18/12/introduction-prometheus) +[#]: author: (Michael Zamot https://opensource.com/users/mzamot) + +Prometheus 入门 +====== + +> 学习安装 Prometheus 监控和警报系统并编写它的查询。 + +![](https://img.linux.net.cn/data/attachment/album/201908/16/113724zqe12khkdye2mesy.jpg) + +[Prometheus][1] 是一个开源的监控和警报系统,它直接从目标主机上运行的代理程序中抓取指标,并将收集的样本集中存储在其服务器上。也可以使用像 `collectd_exporter` 这样的插件推送指标,尽管这不是 Promethius 的默认行为,但在主机位于防火墙后面或位于安全策略禁止打开端口的某些环境中它可能很有用。 + +Prometheus 是[云原生计算基金会(CNCF)][2]的一个项目。它使用联合模型federation model进行扩展,该模型使得一个 Prometheus 服务器能够抓取另一个 Prometheus 服务器的数据。这允许创建分层拓扑,其中中央系统或更高级别的 Prometheus 服务器可以抓取已从下级实例收集的聚合数据。 + +除 Prometheus 服务器外,其最常见的组件是[警报管理器][3]及其输出器。 + +警报规则可以在 Prometheus 中创建,并配置为向警报管理器发送自定义警报。然后,警报管理器处理和管理这些警报,包括通过电子邮件或第三方服务(如 [PagerDuty][4])等不同机制发送通知。 + +Prometheus 的输出器可以是库、进程、设备或任何其他能将 Prometheus 抓取的指标公开出去的东西。 这些指标可在端点 `/metrics` 中获得,它允许 Prometheus 无需代理直接抓取它们。本文中的教程使用 `node_exporter` 来公开目标主机的硬件和操作系统指标。输出器的输出是明文的、高度可读的,这是 Prometheus 的优势之一。 + +此外,你可以将 Prometheus 作为后端,配置 [Grafana][5] 来提供数据可视化和仪表板功能。 + +### 理解 Prometheus 的配置文件 + +抓取 `/metrics` 的间隔秒数控制了时间序列数据库的粒度。这在配置文件中定义为 `scrape_interval` 参数,默认情况下设置为 60 秒。 + +在 `scrape_configs` 部分中为每个抓取作业设置了目标。每个作业都有自己的名称和一组标签,可以帮助你过滤、分类并更轻松地识别目标。一项作业可以有很多目标。 + +### 安装 Prometheus + +在本教程中,为简单起见,我们将使用 Docker 安装 Prometheus 服务器和 `node_exporter`。Docker 应该已经在你的系统上正确安装和配置。对于更深入、自动化的方法,我推荐 Steve Ovens 的文章《[如何使用 Ansible 与 Prometheus 建立系统监控][6]》。 + +在开始之前,在工作目录中创建 Prometheus 配置文件 `prometheus.yml`,如下所示: + +``` +global: + scrape_interval: 15s + evaluation_interval: 15s + +scrape_configs: + - job_name: 'prometheus' + + static_configs: + - targets: ['localhost:9090'] + + - job_name: 'webservers' + + static_configs: + - targets: [':9100'] +``` + +通过运行以下命令用 Docker 启动 Prometheus: + +``` +$ sudo docker run -d -p 9090:9090 -v +/path/to/prometheus.yml:/etc/prometheus/prometheus.yml +prom/prometheus +``` + +默认情况下,Prometheus 服务器将使用端口 9090。如果此端口已在使用,你可以通过在上一个命令的后面添加参数 `--web.listen-address=":"` 来更改它。 + +在要监视的计算机中,使用以下命令下载并运行 `node_exporter` 容器: + +``` +$ sudo docker run -d -v "/proc:/host/proc" -v "/sys:/host/sys" -v +"/:/rootfs" --net="host" prom/node-exporter --path.procfs +/host/proc --path.sysfs /host/sys --collector.filesystem.ignored- +mount-points "^/(sys|proc|dev|host|etc)($|/)" +``` + +出于本文练习的目的,你可以在同一台机器上安装 `node_exporter` 和 Prometheus。请注意,生产环境中在 Docker 下运行 `node_exporter` 是不明智的 —— 这仅用于测试目的。 + +要验证 `node_exporter` 是否正在运行,请打开浏览器并导航到 `http://:9100/metrics`,这将显示收集到的所有指标;也即是 Prometheus 将要抓取的相同指标。 + +![](https://opensource.com/sites/default/files/uploads/check-node_exporter.png) + +要确认 Prometheus 服务器安装成功,打开浏览器并导航至:。 + +你应该看到了 Prometheus 的界面。单击“Status”,然后单击“Targets”。在 “Status” 下,你应该看到你的机器被列为 “UP”。 + +![](https://opensource.com/sites/default/files/uploads/targets-up.png) + +### 使用 Prometheus 查询 + +现在是时候熟悉一下 [PromQL][7](Prometheus 的查询语法)及其图形化 Web 界面了。转到 Prometheus 服务器上的 `http://localhost:9090/graph`。你将看到一个查询编辑器和两个选项卡:“Graph” 和 “Console”。 + +Prometheus 将所有数据存储为时间序列,使用指标名称标识每个数据。例如,指标 `node_filesystem_avail_bytes` 显示可用的文件系统空间。指标的名称可以在表达式框中使用,以选择具有此名称的所有时间序列并生成即时向量。如果需要,可以使用选择器和标签(一组键值对)过滤这些时间序列,例如: + +``` +node_filesystem_avail_bytes{fstype="ext4"} +``` + +过滤时,你可以匹配“完全相等”(`=`)、“不等于”(`!=`),“正则匹配”(`=~`)和“正则排除匹配”(`!~`)。以下示例说明了这一点: + +要过滤 `node_filesystem_avail_bytes` 以显示 ext4 和 XFS 文件系统: + +``` +node_filesystem_avail_bytes{fstype=~"ext4|xfs"} +``` + +要排除匹配: + +``` +node_filesystem_avail_bytes{fstype!="xfs"} +``` + +你还可以使用方括号得到从当前时间往回的一系列样本。你可以使用 `s` 表示秒,`m` 表示分钟,`h` 表示小时,`d` 表示天,`w` 表示周,而 `y` 表示年。使用时间范围时,返回的向量将是范围向量。 + +例如,以下命令生成从五分钟前到现在的样本: + +``` +node_memory_MemAvailable_bytes[5m] +``` + +Prometheus 还包括了高级查询的功能,例如: + +``` +100 * (1 - avg by(instance)(irate(node_cpu_seconds_total{job='webservers',mode='idle'}[5m]))) +``` + +请注意标签如何用于过滤作业和模式。指标 `node_cpu_seconds_total` 返回一个计数器,`irate()`函数根据范围间隔的最后两个数据点计算每秒的变化率(意味着该范围可以小于五分钟)。要计算 CPU 总体使用率,可以使用 `node_cpu_seconds_total` 指标的空闲(`idle`)模式。处理器的空闲比例与繁忙比例相反,因此从 1 中减去 `irate` 值。要使其为百分比,请将其乘以 100。 + +![](https://opensource.com/sites/default/files/uploads/cpu-usage.png) + +### 了解更多 + +Prometheus 是一个功能强大、可扩展、轻量级、易于使用和部署的监视工具,对于每个系统管理员和开发人员来说都是必不可少的。出于这些原因和其他原因,许多公司正在将 Prometheus 作为其基础设施的一部分。 + +要了解有关 Prometheus 及其功能的更多信息,我建议使用以下资源: + ++ 关于 [PromQL][8] ++ 什么是 [node_exporters 集合][9] ++ [Prometheus 函数][10] ++ [4 个开源监控工具] [11] ++ [现已推出:DevOps 监控工具的开源指南] [12] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/12/introduction-prometheus + +作者:[Michael Zamot][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mzamot +[b]: https://github.com/lujun9972 +[1]: https://prometheus.io/ +[2]: https://www.cncf.io/ +[3]: https://prometheus.io/docs/alerting/alertmanager/ +[4]: https://en.wikipedia.org/wiki/PagerDuty +[5]: https://grafana.com/ +[6]: https://opensource.com/article/18/3/how-use-ansible-set-system-monitoring-prometheus +[7]: https://prometheus.io/docs/prometheus/latest/querying/basics/ +[8]: https://prometheus.io/docs/prometheus/latest/querying/basics/ +[9]: https://github.com/prometheus/node_exporter#collectors +[10]: https://prometheus.io/docs/prometheus/latest/querying/functions/ +[11]: https://opensource.com/article/18/8/open-source-monitoring-tools +[12]: https://opensource.com/article/18/8/now-available-open-source-guide-devops-monitoring-tools diff --git a/published/201908/20181222 How to detect automatically generated emails.md b/published/201908/20181222 How to detect automatically generated emails.md new file mode 100644 index 0000000000..1ce4775088 --- /dev/null +++ b/published/201908/20181222 How to detect automatically generated emails.md @@ -0,0 +1,130 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11200-1.html) +[#]: subject: (How to detect automatically generated emails) +[#]: via: (https://arp242.net/weblog/autoreply.html) +[#]: author: (Martin Tournoij https://arp242.net/) + +如何检测自动生成的电子邮件 +====== + +![](https://img.linux.net.cn/data/attachment/album/201908/08/003503fw0w0pzx2ue6a6a6.jpg) + +当你用电子邮件系统发送自动回复时,你需要注意不要向自动生成的电子邮件发送回复。最好的情况下,你将获得无用的投递失败消息。更可能的是,你会得到一个无限的电子邮件循环和一个混乱的世界。 + +事实证明,可靠地检测自动生成的电子邮件并不总是那么容易。以下是基于为此编写的检测器并使用它扫描大约 100,000 封电子邮件(大量的个人存档和公司存档)的观察结果。 + +### Auto-submitted 信头 + +由 [RFC 3834][1] 定义。 + +这是表示你的邮件是自动回复的“官方”标准。如果存在 `Auto-Submitted` 信头,并且其值不是 `no`,你应该**不**发送回复。 + +### X-Auto-Response-Suppress 信头 + +[由微软][2]定义。 + +此信头由微软 Exchange、Outlook 和其他一些产品使用。许多新闻订阅等都设定了这个。如果 `X-Auto-Response-Suppress` 包含 `DR`(“抑制投递报告”)、`AutoReply`(“禁止 OOF 通知以外的自动回复消息”)或 `All`,你应该**不**发送回复。 + +### List-Id 和 List-Unsubscribe 信头 + +由 [RFC 2919][3] 定义。 + +你通常不希望给邮件列表或新闻订阅发送自动回复。几乎所有的邮件列表和大多数新闻订阅都至少设置了其中一个信头。如果存在这些信头中的任何一个,你应该**不**发送回复。这个信头的值不重要。 + +### Feedback-ID 信头 + +[由谷歌][4]定义。 + +Gmail 使用此信头识别邮件是否是新闻订阅,并使用它为这些新闻订阅的所有者生成统计信息或报告。如果此信头存在,你应该**不**发送回复。这个信头的值不重要。 + +### 非标准方式 + +上述方法定义明确(即使有些是非标准的)。不幸的是,有些电子邮件系统不使用它们中的任何一个 :-( 这里有一些额外的措施。 + +#### Precedence 信头 + +在 [RFC 2076][5] 中没有真正定义,不鼓励使用它(但通常会遇到此信头)。 + +请注意,不建议检查是否存在此信头,因为某些邮件使用 `normal` 和其他一些(少见的)值(尽管这不常见)。 + +我的建议是如果其值不区分大小写地匹配 `bulk`、`auto_reply` 或 `list`,则**不**发送回复。 + +#### 其他不常见的信头 + +这是我遇到的另外的一些(不常见的)信头。如果设置了其中一个,我建议**不**发送自动回复。大多数邮件也设置了上述信头之一,但有些没有(这并不常见)。 + +* `X-MSFBL`:无法真正找到定义(Microsoft 信头?),但我只有自动生成的邮件带有此信头。 +* `X-Loop`:在任何地方都没有真正定义过,有点罕见,但有时有。它通常设置为不应该收到电子邮件的地址,但也会遇到 `X-Loop: yes`。 +* `X-Autoreply`:相当罕见,并且似乎总是具有 `yes` 的值。 + +#### Email 地址 + +检查 `From` 或 `Reply-To` 信头是否包含 `noreply`、`no-reply` 或 `no_reply`(正则表达式:`^no.?reply@`)。 + +#### 只有 HTML 部分 + +如果电子邮件只有 HTML 部分,而没有文本部分,则表明这是一个自动生成的邮件或新闻订阅。几乎所有邮件客户端都设置了文本部分。 + +#### 投递失败消息 + +许多传递失败消息并不能真正表明它们是失败的。一些检查方法: + +* `From` 包含 `mailer-daemon` 或 `Mail Delivery Subsystem` + +#### 特定的邮件库特征 + +许多邮件类库留下了某种痕迹,大多数常规邮件客户端使用自己的数据覆盖它。检查这个似乎工作得相当可靠。 + +* `X-Mailer: Microsoft CDO for Windows 2000`:由某些微软软件设置;我只能在自动生成的邮件中找到它。是的,在 2015 年它仍然在使用。 +* `Message-ID` 信头包含 `.JavaMail.`:我发现了一些(5 个 50k 大小的)常规消息,但不是很多;绝大多数(数千封)邮件是新闻订阅、订单确认等。 +* `^X-Mailer` 以 `PHP` 开头。这应该会同时看到 `X-Mailer: PHP/5.5.0` 和 `X-Mailer: PHPmailer XXX XXX`。与 “JavaMail” 相同。 +* 出现了 `X-Library`;似乎只有 [Indy][6] 设定了这个。 +* `X-Mailer` 以 `wdcollect` 开头。由一些 Plesk 邮件设置。 +* `X-Mailer` 以 `MIME-tools` 开头。 + +### 最后的预防措施:限制回复的数量 + +即使遵循上述所有建议,你仍可能会遇到一个避开所有这些检测的电子邮件程序。这可能非常危险,因为电子邮件系统只是“如果有电子邮件那么发送”,就有可能导致无限的电子邮件循环。 + +出于这个原因,我建议你记录你自动发送的电子邮件,并将此速率限制为在几分钟内最多几封电子邮件。这将打破循环链条。 + +我们使用每五分钟一封电子邮件的设置,但没这么严格的设置可能也会运作良好。 + +### 你需要为自动回复设置什么信头 + +具体细节取决于你发送的邮件类型。这是我们用于自动回复邮件的内容: + +``` +Auto-Submitted: auto-replied +X-Auto-Response-Suppress: All +Precedence: auto_reply +``` + +### 反馈 + +你可以发送电子邮件至 [martin@arp242.net][7] 或 [创建 GitHub 议题][8]以提交反馈、问题等。 + +-------------------------------------------------------------------------------- + +via: https://arp242.net/weblog/autoreply.html + +作者:[Martin Tournoij][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://arp242.net/ +[b]: https://github.com/lujun9972 +[1]: http://tools.ietf.org/html/rfc3834 +[2]: https://msdn.microsoft.com/en-us/library/ee219609(v=EXCHG.80).aspx +[3]: https://tools.ietf.org/html/rfc2919) +[4]: https://support.google.com/mail/answer/6254652?hl=en +[5]: http://www.faqs.org/rfcs/rfc2076.html +[6]: http://www.indyproject.org/index.en.aspx +[7]: mailto:martin@arp242.net +[8]: https://github.com/Carpetsmoker/arp242.net/issues/new diff --git a/published/201908/20190225 How to Install VirtualBox on Ubuntu -Beginner-s Tutorial.md b/published/201908/20190225 How to Install VirtualBox on Ubuntu -Beginner-s Tutorial.md new file mode 100644 index 0000000000..8d83afa0dd --- /dev/null +++ b/published/201908/20190225 How to Install VirtualBox on Ubuntu -Beginner-s Tutorial.md @@ -0,0 +1,164 @@ +[#]: collector: (lujun9972) +[#]: translator: (beamrolling) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11282-1.html) +[#]: subject: (How to Install VirtualBox on Ubuntu [Beginner’s Tutorial]) +[#]: via: (https://itsfoss.com/install-virtualbox-ubuntu) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu 上安装 VirtualBox +====== + +> 本新手教程解释了在 Ubuntu 和其他基于 Debian 的 Linux 发行版上安装 VirtualBox 的各种方法。 + +![](https://img.linux.net.cn/data/attachment/album/201908/30/072113uzitwinnt9betilt.jpg) + +Oracle 公司的自由开源产品 [VirtualBox][1] 是一款出色的虚拟化工具,专门用于桌面操作系统。与另一款虚拟化工具 [Linux 上的 VMWare Workstation][2] 相比起来,我更喜欢它。 + +你可以使用 VirtualBox 等虚拟化软件在虚拟机中安装和使用其他操作系统。 + +例如,你可以[在 Windows 上的 VirtualBox 中安装 Linux][3]。同样地,你也可以[用 VirtualBox 在 Linux 中安装 Windows][4]。 + +你也可以用 VirtualBox 在你当前的 Linux 系统中安装别的 Linux 发行版。事实上,这就是我用它的原因。如果我听说了一个不错的 Linux 发行版,我会在虚拟机上测试它,而不是安装在真实的系统上。当你想要在安装之前尝试一下别的发行版时,用虚拟机会很方便。 + +![Linux installed inside Linux using VirtualBox][5] + +*安装在 Ubuntu 18.04 内的 Ubuntu 18.10* + +在本新手教程中,我将向你展示在 Ubuntu 和其他基于 Debian 的 Linux 发行版上安装 VirtualBox 的各种方法。 + +### 在 Ubuntu 和基于 Debian 的 Linux 发行版上安装 VirtualBox + +这里提出的安装方法也适用于其他基于 Debian 和 Ubuntu 的 Linux 发行版,如 Linux Mint、elementar OS 等。 + +#### 方法 1:从 Ubuntu 仓库安装 VirtualBox + +**优点**:安装简便 + +**缺点**:较旧版本 + +在 Ubuntu 上下载 VirtualBox 最简单的方法可能是从软件中心查找并下载。 + +![VirtualBox in Ubuntu Software Center][6] + +*VirtualBox 在 Ubuntu 软件中心提供* + +你也可以使用这条命令从命令行安装: + +``` +sudo apt install virtualbox +``` + +然而,如果[在安装前检查软件包版本][7],你会看到 Ubuntu 仓库提供的 VirtualBox 版本已经很老了。 + +举个例子,在写下本教程时 VirtualBox 的最新版本是 6.0,但是在软件中心提供的是 5.2。这意味着你无法获得[最新版 VirtualBox ][8]中引入的新功能。 + +#### 方法 2:使用 Oracle 网站上的 Deb 文件安装 VirtualBox + +**优点**:安装简便,最新版本 + +**缺点**:不能更新 + +如果你想要在 Ubuntu 上使用 VirtualBox 的最新版本,最简单的方法就是[使用 Deb 文件][9]。 + +Oracle 为 VirtiualBox 版本提供了开箱即用的二进制文件。如果查看其下载页面,你将看到为 Ubuntu 和其他发行版下载 deb 安装程序的选项。 + +![VirtualBox Linux Download][10] + +你只需要下载 deb 文件并双击它即可安装。就是这么简单。 + +- [下载 virtualbox for Ubuntu](https://www.virtualbox.org/wiki/Linux_Downloads) + +然而,这种方法的问题在于你不能自动更新到最新的 VirtualBox 版本。唯一的办法是移除现有版本,下载最新版本并再次安装。不太方便,是吧? + +#### 方法 3:用 Oracle 的仓库安装 VirtualBox + +**优点**:自动更新 + +**缺点**:安装略微复杂 + +现在介绍的是命令行安装方法,它看起来可能比较复杂,但与前两种方法相比,它更具有优势。你将获得 VirtualBox 的最新版本,并且未来它还将自动更新到更新的版本。我想那就是你想要的。 + +要通过命令行安装 VirtualBox,请在你的仓库列表中添加 Oracle VirtualBox 的仓库。添加 GPG 密钥以便你的系统信任此仓库。现在,当你安装 VirtualBox 时,它会从 Oracle 仓库而不是 Ubuntu 仓库安装。如果发布了新版本,本地 VirtualBox 将跟随一起更新。让我们看看怎么做到这一点: + +首先,添加仓库的密钥。你可以通过这一条命令下载和添加密钥: + +``` +wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - +``` + +> Mint 用户请注意: + +> 下一步只适用于 Ubuntu。如果你使用的是 Linux Mint 或其他基于 Ubuntu 的发行版,请将命令行中的 `$(lsb_release -cs)` 替换成你当前版本所基于的 Ubuntu 版本。例如,Linux Mint 19 系列用户应该使用 bionic,Mint 18 系列用户应该使用 xenial,像这样: + +> ``` +> sudo add-apt-repository “deb [arch=amd64] **bionic** contrib“` +> ``` + +现在用以下命令来将 Oracle VirtualBox 仓库添加到仓库列表中: + +``` +sudo add-apt-repository "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" +``` + +如果你有读过我的文章[检查 Ubuntu 版本][11],你大概知道 `lsb_release -cs` 将打印你的 Ubuntu 系统的代号。 + +**注**:如果你看到 “[add-apt-repository command not found][12]” 错误,你需要下载 `software-properties-common` 包。 + +现在你已经添加了正确的仓库,请通过此仓库刷新可用包列表并安装 VirtualBox: + +``` +sudo apt update && sudo apt install virtualbox-6.0 +``` + +**提示**:一个好方法是输入 `sudo apt install virtualbox-` 并点击 `tab` 键以查看可用于安装的各种 VirtualBox 版本,然后通过补全命令来选择其中一个版本。 + +![Install VirtualBox via terminal][13] + +### 如何从 Ubuntu 中删除 VirtualBox + +现在你已经学会了如何安装 VirtualBox,我还想和你提一下删除它的步骤。 + +如果你是从软件中心安装的,那么删除它最简单的方法是从软件中心下手。你只需要在[已安装的应用程序列表][14]中找到它,然后单击“删除”按钮。 + +另一种方式是使用命令行: + +``` +sudo apt remove virtualbox virtualbox-* +``` + +请注意,这不会删除你用 VirtualBox 安装的操作系统关联的虚拟机和文件。这并不是一件坏事,因为你可能希望以后或在其他系统中使用它们是安全的。 + +### 最后… + +我希望你能在以上方法中选择一种安装 VirtualBox。我还将在另一篇文章中写到如何有效地使用 VirtualBox。目前,如果你有点子、建议或任何问题,请随时在下面发表评论。 + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-virtualbox-ubuntu + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[beamrolling](https://github.com/beamrolling) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.virtualbox.org +[2]: https://itsfoss.com/install-vmware-player-ubuntu-1310/ +[3]: https://itsfoss.com/install-linux-in-virtualbox/ +[4]: https://itsfoss.com/install-windows-10-virtualbox-linux/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/linux-inside-linux-virtualbox.png?resize=800%2C450&ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/virtualbox-ubuntu-software-center.jpg?ssl=1 +[7]: https://itsfoss.com/know-program-version-before-install-ubuntu/ +[8]: https://itsfoss.com/oracle-virtualbox-release/ +[9]: https://itsfoss.com/install-deb-files-ubuntu/ +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/virtualbox-download.jpg?resize=800%2C433&ssl=1 +[11]: https://itsfoss.com/how-to-know-ubuntu-unity-version/ +[12]: https://itsfoss.com/add-apt-repository-command-not-found/ +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/install-virtualbox-ubuntu-terminal.png?resize=800%2C165&ssl=1 +[14]: https://itsfoss.com/list-installed-packages-ubuntu/ diff --git a/published/201908/20190304 How to Install MongoDB on Ubuntu.md b/published/201908/20190304 How to Install MongoDB on Ubuntu.md new file mode 100644 index 0000000000..1ba0edae1f --- /dev/null +++ b/published/201908/20190304 How to Install MongoDB on Ubuntu.md @@ -0,0 +1,235 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11175-1.html) +[#]: subject: (How to Install MongoDB on Ubuntu) +[#]: via: (https://itsfoss.com/install-mongodb-ubuntu) +[#]: author: (Sergiu https://itsfoss.com/author/sergiu/) + +如何在 Ubuntu 上安装 MongoDB +====== + +> 本教程介绍了在 Ubuntu 和基于 Ubuntu 的 Linux 发行版上安装 MongoDB 的两种方法。 + +[MongoDB][1] 是一个越来越流行的自由开源的 NoSQL 数据库,它将数据存储在类似 JSON 的灵活文档集中,这与 SQL 数据库中常见的表格形式形成对比。 + +你很可能发现在现代 Web 应用中使用 MongoDB。它的文档模型使得使用各种编程语言能非常直观地访问和处理它。 + +![mongodb Ubuntu][2] + +在本文中,我将介绍两种在 Ubuntu 上安装 MongoDB 的方法。 + +### 在基于 Ubuntu 的发行版上安装 MongoDB + +1. 使用 Ubuntu 仓库安装 MongoDB。简单但不是最新版本的 MongoDB +2. 使用其官方仓库安装 MongoDB。稍微复杂,但你能得到最新版本的 MongoDB。 + +第一种安装方法更容易,但如果你计划使用官方支持的最新版本,那么我建议使用第二种方法。 + +有些人可能更喜欢使用 snap 包。Ubuntu 软件中心提供了 snap,但我不建议使用它们,因为他们现在已经过期了,因此我这里不会提到。 + +### 方法 1:从 Ubuntu 仓库安装 MongoDB + +这是在系统中安装 MongoDB 的简便方法,你只需输入一个命令即可。 + +#### 安装 MongoDB + +首先,确保你的包是最新的。打开终端并输入: + +``` +sudo apt update && sudo apt upgrade -y +``` + +继续安装 MongoDB: + +``` +sudo apt install mongodb +``` + +这就完成了!MongoDB 现在安装到你的计算机上了。 + +MongoDB 服务应该在安装时自动启动,但要检查服务状态: + +``` +sudo systemctl status mongodb +``` + +![Check if the MongoDB service is running.][3] + +你可以看到该服务是**活动**的。 + +#### 运行 MongoDB + +MongoDB 目前是一个 systemd 服务,因此我们使用 `systemctl` 来检查和修改它的状态,使用以下命令: + +``` +sudo systemctl status mongodb +sudo systemctl stop mongodb +sudo systemctl start mongodb +sudo systemctl restart mongodb +``` + +你也可以修改 MongoDB 是否自动随系统启动(默认:启用): + +``` +sudo systemctl disable mongodb +sudo systemctl enable mongodb +``` + +要开始使用(创建和编辑)数据库,请输入: + +``` +mongo +``` + +这将启动 **mongo shell**。有关查询和选项的详细信息,请查看[手册][4]。 + +**注意:**根据你计划使用 MongoDB 的方式,你可能需要调整防火墙。不过这超出了本篇的内容,并且取决于你的配置。 + +#### 卸载 MongoDB + +如果你从 Ubuntu 仓库安装 MongoDB 并想要卸载它(可能要使用官方支持的方式安装),请输入: + +``` +sudo systemctl stop mongodb +sudo apt purge mongodb +sudo apt autoremove +``` + +这应该会完全卸载 MongoDB。确保**备份**你可能想要保留的任何集合或文档,因为它们将被删除! + +### 方法 2:在 Ubuntu 上安装 MongoDB 社区版 + +这是推荐的安装 MongoDB 的方法,它使用包管理器。你需要多打几条命令,对于 Linux 新手而言,这可能会感到害怕。 + +但没有什么可怕的!我们将一步步说明安装过程。 + +#### 安装 MongoDB + +由 MongoDB Inc. 维护的包称为 `mongodb-org`,而不是 `mongodb`(这是 Ubuntu 仓库中包的名称)。在开始之前,请确保系统上未安装 `mongodb`。因为包之间会发生冲突。让我们开始吧! + +首先,我们必须导入公钥: + +``` +sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 +``` + +现在,你需要在源列表中添加一个新的仓库,以便你可以安装 MongoDB 社区版并获得自动更新: + +``` +echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list +``` + +要安装 `mongodb-org`,我们需要更新我们的包数据库,以便系统知道可用的新包: + +``` +sudo apt update +``` + +现在你可以安装**最新稳定版**的 MongoDB: + +``` +sudo apt install -y mongodb-org +``` + +或者某个**特定版本**(在 `=` 后面修改版本号) + +``` +sudo apt install -y mongodb-org=4.0.6 mongodb-org-server=4.0.6 mongodb-org-shell=4.0.6 mongodb-org-mongos=4.0.6 mongodb-org-tools=4.0.6 +``` + +如果你选择安装特定版本,请确保在所有位置都修改了版本号。如果你修改了 `mongodb-org=4.0.6`,你将安装最新版本。 + +默认情况下,使用包管理器(`apt-get`)更新时,MongoDB 将更新为最新的版本。要阻止这种情况发生(并冻结为已安装的版本),请使用: + +``` +echo "mongodb-org hold" | sudo dpkg --set-selections +echo "mongodb-org-server hold" | sudo dpkg --set-selections +echo "mongodb-org-shell hold" | sudo dpkg --set-selections +echo "mongodb-org-mongos hold" | sudo dpkg --set-selections +echo "mongodb-org-tools hold" | sudo dpkg --set-selections +``` + +你现在已经成功安装了 MongoDB! + +#### 配置 MongoDB + +默认情况下,包管理器将创建 `/var/lib/mongodb` 和 `/var/log/mongodb`,MongoDB 将使用 `mongodb` 用户帐户运行。 + +我不会去更改这些默认设置,因为这超出了本指南的范围。有关详细信息,请查看[手册][5]。 + +`/etc/mongod.conf` 中的设置在启动/重新启动 **mongodb** 服务实例时生效。 + +##### 运行 MongoDB + +要启动 mongodb 的守护进程 `mongod`,请输入: + +``` +sudo service mongod start +``` + +现在你应该验证 `mongod` 进程是否已成功启动。此信息(默认情况下)保存在 `/var/log/mongodb/mongod.log` 中。我们来看看文件的内容: + +``` +sudo cat /var/log/mongodb/mongod.log +``` + +![Check MongoDB logs to see if the process is running properly.][6] + +只要你在某处看到:`[initandlisten] waiting for connections on port 27017`,就说明进程正常运行。 + +**注意**:27017 是 `mongod` 的默认端口。 + +要停止/重启 `mongod`,请输入: + +``` +sudo service mongod stop +sudo service mongod restart +``` + +现在,你可以通过打开 **mongo shell** 来使用 MongoDB: + +``` +mongo +``` + +#### 卸载 MongoDB + +运行以下命令: + +``` +sudo service mongod stop +sudo apt purge mongodb-org* +``` + +要删除**数据库**和**日志文件**(确保**备份**你要保留的内容!): + +``` +sudo rm -r /var/log/mongodb +sudo rm -r /var/lib/mongodb +``` + +### 总结 + +MongoDB 是一个很棒的 NoSQL 数据库,它易于集成到现代项目中。我希望本教程能帮助你在 Ubuntu 上安装它!在下面的评论中告诉我们你计划如何使用 MongoDB。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-mongodb-ubuntu + +作者:[Sergiu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/sergiu/ +[b]: https://github.com/lujun9972 +[1]: https://www.mongodb.com/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/03/mongodb-ubuntu.jpeg?resize=800%2C450&ssl=1 +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/mongodb_check_status.jpg?fit=800%2C574&ssl=1 +[4]: https://docs.mongodb.com/manual/tutorial/getting-started/ +[5]: https://docs.mongodb.com/manual/ +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/mongodb_org_check_logs.jpg?fit=800%2C467&ssl=1 diff --git a/published/201908/20190315 How To Parse And Pretty Print JSON With Linux Commandline Tools.md b/published/201908/20190315 How To Parse And Pretty Print JSON With Linux Commandline Tools.md new file mode 100644 index 0000000000..88ffc6fc24 --- /dev/null +++ b/published/201908/20190315 How To Parse And Pretty Print JSON With Linux Commandline Tools.md @@ -0,0 +1,228 @@ +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11198-1.html" +[#]: subject: "How To Parse And Pretty Print JSON With Linux Commandline Tools" +[#]: via: "https://www.ostechnix.com/how-to-parse-and-pretty-print-json-with-linux-commandline-tools/" +[#]: author: "EDITOR https://www.ostechnix.com/author/editor/" + +如何用 Linux 命令行工具解析和格式化输出 JSON +====== + +![](https://www.ostechnix.com/wp-content/uploads/2019/03/json-720x340.png) + +JSON 是一种轻量级且与语言无关的数据存储格式,易于与大多数编程语言集成,也易于人类理解 —— 当然,如果格式正确的话。JSON 这个词代表 **J**ava **S**cript **O**bject **N**otation,虽然它以 JavaScript 开头,而且主要用于在服务器和浏览器之间交换数据,但现在正在用于许多领域,包括嵌入式系统。在这里,我们将使用 Linux 上的命令行工具解析并格式化打印 JSON。它对于在 shell 脚本中处理大型 JSON 数据或在 shell 脚本中处理 JSON 数据非常有用。 + +### 什么是格式化输出? + +JSON 数据的结构更具人性化。但是在大多数情况下,JSON 数据会存储在一行中,甚至没有行结束字符。 + +显然,这对于手动阅读和编辑不太方便。 + +这是格式化输出pretty print就很有用。这个该名称不言自明:重新格式化 JSON 文本,使人们读起来更清晰。这被称为 **JSON 格式化输出**。 + +### 用 Linux 命令行工具解析和格式化输出 JSON + +可以使用命令行文本处理器解析 JSON 数据,例如 `awk`、`sed` 和 `gerp`。实际上 `JSON.awk` 是一个来做这个的 awk 脚本。但是,也有一些专用工具可用于同一目的。 + +1. `jq` 或 `jshon`,shell 下的 JSON 解析器,它们都非常有用。 +2. Shell 脚本,如 `JSON.sh` 或 `jsonv.sh`,用于在 bash、zsh 或 dash shell 中解析JSON。 +3. `JSON.awk`,JSON 解析器 awk 脚本。 +4. 像 `json.tool` 这样的 Python 模块。 +5. `undercore-cli`,基于 Node.js 和 javascript。 + +在本教程中,我只关注 `jq`,这是一个 shell 下的非常强大的 JSON 解析器,具有高级过滤和脚本编程功能。 + +### JSON 格式化输出 + +JSON 数据可能放在一行上使人难以解读,因此为了使其具有一定的可读性,JSON 格式化输出就可用于此目的的。 + +**示例:**来自 `jsonip.com` 的数据,使用 `curl` 或 `wget` 工具获得 JSON 格式的外部 IP 地址,如下所示。 + +``` +$ wget -cq http://jsonip.com/ -O - +``` + +实际数据看起来类似这样: + +``` +{"ip":"111.222.333.444","about":"/about","Pro!":"http://getjsonip.com"} +``` + +现在使用 `jq` 格式化输出它: + +``` +$ wget -cq http://jsonip.com/ -O - | jq '.' +``` + +通过 `jq` 过滤了该结果之后,它应该看起来类似这样: + +``` +{ + "ip": "111.222.333.444", + "about": "/about", + "Pro!": "http://getjsonip.com" +} +``` + +同样也可以通过 Python `json.tool` 模块做到。示例如下: + +``` +$ cat anything.json | python -m json.tool +``` + +这种基于 Python 的解决方案对于大多数用户来说应该没问题,但是如果没有预安装或无法安装 Python 则不行,比如在嵌入式系统上。 + +然而,`json.tool` Python 模块具有明显的优势,它是跨平台的。因此,你可以在 Windows、Linux 或 Mac OS 上无缝使用它。 + +### 如何用 jq 解析 JSON + +首先,你需要安装 `jq`,它已被大多数 GNU/Linux 发行版选中,并使用各自的软件包安装程序命令进行安装。 + +在 Arch Linux 上: + +``` +$ sudo pacman -S jq +``` + +在 Debian、Ubuntu、Linux Mint 上: + +``` +$ sudo apt-get install jq +``` + +在 Fedora 上: + +``` +$ sudo dnf install jq +``` + +在 openSUSE 上: + +``` +$ sudo zypper install jq +``` + +对于其它操作系统或平台参见[官方的安装指导][1]。 + +#### jq 的基本过滤和标识符功能 + +`jq` 可以从 `STDIN` 或文件中读取 JSON 数据。你可以根据情况使用。 + +单个符号 `.` 是最基本的过滤器。这些过滤器也称为**对象标识符-索引**。`jq` 使用单个 `.` 过滤器基本上相当将输入的 JSON 文件格式化输出。 + +- **单引号**:不必始终使用单引号。但是如果你在一行中组合几个过滤器,那么你必须使用它们。 +- **双引号**:你必须用两个双引号括起任何特殊字符,如 `@`、`#`、`$`,例如 `jq .foo.”@bar”`。 +- **原始数据打印**:不管出于任何原因,如果你只需要最终解析的数据(不包含在双引号内),请使用带有 `-r` 标志的 `jq` 命令,如下所示:`jq -r .foo.bar`。 + +#### 解析特定数据 + +要过滤出 JSON 的特定部分,你需要了解格式化输出的 JSON 文件的数据层次结构。 + +来自维基百科的 JSON 数据示例: + +``` +{ + "firstName": "John", + "lastName": "Smith", + "age": 25, + "address": { + "streetAddress": "21 2nd Street", + "city": "New York", + "state": "NY", + "postalCode": "10021" +}, + "phoneNumber": [ +{ + "type": "home", + "number": "212 555-1234" +}, +{ + "type": "fax", + "number": "646 555-4567" +} +], + "gender": { + "type": "male" + } +} +``` + +我将在本教程中将此 JSON 数据用作示例,将其保存为 `sample.json`。 + +假设我想从 `sample.json` 文件中过滤出地址。所以命令应该是这样的: + +``` +$ jq .address sample.json +``` + +示例输出: + +``` +{ + "streetAddress": "21 2nd Street", + "city": "New York", + "state": "NY", + "postalCode": "10021" +} +``` + +再次,我想要邮政编码,然后我要添加另一个**对象标识符-索引**,即另一个过滤器。 + +``` +$ cat sample.json | jq .address.postalCode +``` + +另请注意,**过滤器区分大小写**,并且你必须使用完全相同的字符串来获取有意义的输出,否则就是 null。 + +#### 从 JSON 数组中解析元素 + +JSON 数组的元素包含在方括号内,这无疑是非常通用的。 + +要解析数组中的元素,你必须使用 `[]` 标识符以及其他对象标识符索引。 + +在此示例 JSON 数据中,电话号码存储在数组中,要从此数组中获取所有内容,你只需使用括号,像这个示例: + +``` +$ jq .phoneNumber[] sample.json +``` + +假设你只想要数组的第一个元素,然后使用从 `0` 开始的数组对象编号,对于第一个项目,使用 `[0]`,对于下一个项目,它应该每步增加 1。 + +``` +$ jq .phoneNumber[0] sample.json +``` + +#### 脚本编程示例 + +假设我只想要家庭电话,而不是整个 JSON 数组数据。这就是用 `jq` 命令脚本编写的方便之处。 + +``` +$ cat sample.json | jq -r '.phoneNumber[] | select(.type == "home") | .number' +``` + +首先,我将一个过滤器的结果传递给另一个,然后使用 `select` 属性选择特定类型的数据,再次将结果传递给另一个过滤器。 + +解释每种类型的 `jq` 过滤器和脚本编程超出了本教程的范围和目的。强烈建议你阅读 `jq` 手册,以便更好地理解下面的内容。 + +资源: + +- https://stedolan.github.io/jq/manual/ +- http://www.compciv.org/recipes/cli/jq-for-parsing-json/ +- https://lzone.de/cheat-sheet/jq + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-parse-and-pretty-print-json-with-linux-commandline-tools/ + +作者:[ostechnix][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[b]: https://github.com/lujun9972 +[1]: https://stedolan.github.io/jq/download/ diff --git a/published/201908/20190318 Let-s try dwm - dynamic window manager.md b/published/201908/20190318 Let-s try dwm - dynamic window manager.md new file mode 100644 index 0000000000..241869a24d --- /dev/null +++ b/published/201908/20190318 Let-s try dwm - dynamic window manager.md @@ -0,0 +1,150 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11235-1.html) +[#]: subject: (Let’s try dwm — dynamic window manager) +[#]: via: (https://fedoramagazine.org/lets-try-dwm-dynamic-window-manger/) +[#]: author: (Adam Šamalík https://fedoramagazine.org/author/asamalik/) + +试试动态窗口管理器 dwm 吧 +====== + +![][1] + +如果你崇尚效率和极简主义,并且正在为你的 Linux 桌面寻找新的窗口管理器,那么你应该尝试一下动态窗口管理器dynamic window manager dwm。以不到 2000 标准行的代码写就的 dwm,是一个速度极快而功能强大,且可高度定制的窗口管理器。 + +你可以在平铺、单片和浮动布局之间动态选择,使用标签将窗口组织到多个工作区,并使用键盘快捷键快速导航。本文将帮助你开始使用 dwm。 + +### 安装 + +要在 Fedora 上安装 dwm,运行: + +``` +$ sudo dnf install dwm dwm-user +``` + +`dwm` 包会安装窗口管理器本身,`dwm-user` 包显著简化了配置,本文稍后将对此进行说明。 + +此外,为了能够在需要时锁定屏幕,我们还将安装 `slock`,这是一个简单的 X 显示锁屏。 + +``` +$ sudo dnf install slock +``` + +当然,你可以根据你的个人喜好使用其它的锁屏。 + +### 快速入门 + +要启动 dwm,在登录屏选择 “dwm-user” 选项。 + +![][2] + +登录后,你将看到一个非常简单的桌面。事实上,顶部唯一的一个面板列出了代表工作空间的 9 个标签和一个代表窗户布局的 `[]=` 符号。 + +#### 启动应用 + +在查看布局之前,首先启动一些应用程序,以便你可以随时使用布局。可以通过按 `Alt+p` 并键入应用程序的名称,然后回车来启动应用程序。还有一个快捷键 `Alt+Shift+Enter` 用于打开终端。 + +现在有一些应用程序正在运行了,请查看布局。 + +#### 布局 + +默认情况下有三种布局:平铺布局,单片布局和浮动布局。 + +平铺布局由条形图上的 `[]=` 表示,它将窗口组织为两个主要区域:左侧为主区域,右侧为堆叠区。你可以按 `Alt+t` 激活平铺布局。 + +![][3] + +平铺布局背后的想法是,主窗口放在主区域中,同时仍然可以看到堆叠区中的其他窗口。你可以根据需要在它们之间快速切换。 + +要在两个区域之间交换窗口,请将鼠标悬停在堆叠区中的一个窗口上,然后按 `Alt+Enter` 将其与主区域中的窗口交换。 + +![][4] + +单片布局由顶部栏上的 `[N]` 表示,可以使你的主窗口占据整个屏幕。你可以按 `Alt+m` 切换到它。 + +最后,浮动布局可让你自由移动和调整窗口大小。它的快捷方式是 `Alt+f`,顶栏上的符号是 `><>`。 + +#### 工作区和标签 + +每个窗口都分配了一个顶部栏中列出的标签(1-9)。要查看特定标签,请使用鼠标单击其编号或按 `Alt+1..9`。你甚至可以使用鼠标右键单击其编号,一次查看多个标签。 + +通过使用鼠标突出显示后,并按 `Alt+Shift+1..9`,窗口可以在不同标签之间移动。 + +### 配置 + +为了使 dwm 尽可能简约,它不使用典型的配置文件。而是你需要修改代表配置的 C 语言头文件,并重新编译它。但是不要担心,在 Fedora 中你只需要简单地编辑主目录中的一个文件,而其他一切都会在后台发生,这要归功于 Fedora 的维护者提供的 `dwm-user` 包。 + +首先,你需要使用类似于以下的命令将文件复制到主目录中: + +``` +$ mkdir ~/.dwm +$ cp /usr/src/dwm-VERSION-RELEASE/config.def.h ~/.dwm/config.h +``` + +你可以通过运行 `man dwm-start` 来获取确切的路径。 + +其次,只需编辑 `~/.dwm/config.h` 文件。例如,让我们配置一个新的快捷方式:通过按 `Alt+Shift+L` 来锁定屏幕。 + +考虑到我们已经安装了本文前面提到的 `slock` 包,我们需要在文件中添加以下两行以使其工作: + +在 `/* commands */` 注释下,添加: + +``` +static const char *slockcmd[] = { "slock", NULL }; +``` + +添加下列行到 `static Key keys[]` 中: + +``` +{ MODKEY|ShiftMask, XK_l, spawn, {.v = slockcmd } }, +``` + +最终,它应该看起来如下: + +``` +... + /* commands */ + static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ + static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL }; + static const char *termcmd[] = { "st", NULL }; + static const char *slockcmd[] = { "slock", NULL }; + + static Key keys[] = { + /* modifier key function argument */ + { MODKEY|ShiftMask, XK_l, spawn, {.v = slockcmd } }, + { MODKEY, XK_p, spawn, {.v = dmenucmd } }, + { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, + ... +``` + +保存文件。 + +最后,按 `Alt+Shift+q` 注销,然后重新登录。`dwm-user` 包提供的脚本将识别你已更改主目录中的`config.h` 文件,并会在登录时重新编译 dwm。因为 dwm 非常小,它快到你甚至都不会注意到它重新编译了。 + +你现在可以尝试按 `Alt+Shift+L` 锁定屏幕,然后输入密码并按回车键再次登录。 + +### 总结 + +如果你崇尚极简主义并想要一个非常快速而功能强大的窗口管理器,dwm 可能正是你一直在寻找的。但是,它可能不适合初学者,你可能需要做许多其他配置才能按照你的喜好进行配置。 + +要了解有关 dwm 的更多信息,请参阅该项目的主页: 。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/lets-try-dwm-dynamic-window-manger/ + +作者:[Adam Šamalík][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/asamalik/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/03/dwm-magazine-image-816x345.png +[2]: https://fedoramagazine.org/wp-content/uploads/2019/03/choosing-dwm-1024x469.png +[3]: https://fedoramagazine.org/wp-content/uploads/2019/03/dwm-desktop-1024x593.png +[4]: https://fedoramagazine.org/wp-content/uploads/2019/03/Screenshot-2019-03-15-at-11.12.32-1024x592.png diff --git a/published/201908/20190429 How To Turn On And Shutdown The Raspberry Pi -Absolute Beginner Tip.md b/published/201908/20190429 How To Turn On And Shutdown The Raspberry Pi -Absolute Beginner Tip.md new file mode 100644 index 0000000000..3afa479e52 --- /dev/null +++ b/published/201908/20190429 How To Turn On And Shutdown The Raspberry Pi -Absolute Beginner Tip.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11245-1.html) +[#]: subject: (How To Turn On And Shutdown The Raspberry Pi [Absolute Beginner Tip]) +[#]: via: (https://itsfoss.com/turn-on-raspberry-pi/) +[#]: author: (Chinmay https://itsfoss.com/author/chinmay/) + +如何打开和关闭树莓派(绝对新手) +====== + +> 这篇短文教你如何打开树莓派以及如何在之后正确关闭它。 + +![](https://img.linux.net.cn/data/attachment/album/201908/19/192825rlrjy3sj77j7j79y.jpg) + +[树莓派][1]是[最流行的 SBC(单板计算机)][2]之一。如果你对这个话题感兴趣,我相信你已经有了一个树莓派。我还建议你使用[其他树莓派配件][3]来开始使用你的设备。 + +你已经准备好打开并开始使用。与桌面和笔记本电脑等传统电脑相比,它有相似以及不同之处。 + +今天,让我们继续学习如何打开和关闭树莓派,因为它并没有真正的“电源按钮”。 + +在本文中,我使用的是树莓派 3B+,但对于所有树莓派变体都是如此。 + +### 如何打开树莓派 + +![Micro USB port for Power][7] + +micro USB 口为树莓派供电,打开它的方式是将电源线插入 micro USB 口。但是开始之前,你应该确保做了以下事情。 + +* 根据官方[指南][8]准备带有 Raspbian 的 micro SD 卡并插入 micro SD 卡插槽。 +* 插入 HDMI 线、USB 键盘和鼠标。 +* 插入以太网线(可选)。 + +成上述操作后,请插入电源线。这会打开树莓派,显示屏将亮起并加载操作系统。 + +如果您将其关闭并且想要再次打开它,则必须从电源插座(首选)或从电路板的电源端口拔下电源线,然后再插上。它没有电源按钮。 + +### 关闭树莓派 + +关闭树莓派非常简单,单击菜单按钮并选择关闭。 + +![Turn off Raspberry Pi graphically][9] + +或者你可以在终端使用 [shutdown 命令][10] + +``` +sudo shutdown now +``` + +`shutdown` 执行后**等待**它完成,接着你可以关闭电源。 + +再说一次,树莓派关闭后,没有真正的办法可以在不关闭再打开电源的情况下打开树莓派。你可以使用 GPIO 打开树莓派,但这需要额外的改装。 + +*注意:Micro USB 口往往是脆弱的,因此请关闭/打开电源,而不是经常拔出插入 micro USB 口。 + +好吧,这就是关于打开和关闭树莓派的所有内容,你打算用它做什么?请在评论中告诉我。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/turn-on-raspberry-pi/ + +作者:[Chinmay][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/chinmay/ +[b]: https://github.com/lujun9972 +[1]: https://www.raspberrypi.org/ +[2]: https://linux.cn/article-10823-1.html +[3]: https://itsfoss.com/things-you-need-to-get-your-raspberry-pi-working/ +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/04/raspberry-pi-3-microusb.png?fit=800%2C532&ssl=1 +[8]: https://www.raspberrypi.org/documentation/installation/installing-images/README.md +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/04/Raspbian-ui-menu.jpg?fit=800%2C492&ssl=1 +[10]: https://linuxhandbook.com/linux-shutdown-command/ diff --git a/published/201908/20190505 Blockchain 2.0 - An Introduction To Hyperledger Project (HLP) -Part 8.md b/published/201908/20190505 Blockchain 2.0 - An Introduction To Hyperledger Project (HLP) -Part 8.md new file mode 100644 index 0000000000..001e909fc1 --- /dev/null +++ b/published/201908/20190505 Blockchain 2.0 - An Introduction To Hyperledger Project (HLP) -Part 8.md @@ -0,0 +1,81 @@ +[#]: collector: (lujun9972) +[#]: translator: (zionfuo) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11275-1.html) +[#]: subject: (Blockchain 2.0 – An Introduction To Hyperledger Project (HLP) [Part 8]) +[#]: via: (https://www.ostechnix.com/blockchain-2-0-an-introduction-to-hyperledger-project-hlp/) +[#]: author: (editor https://www.ostechnix.com/author/editor/) + +区块链 2.0:Hyperledger 项目简介(八) +====== + +![Introduction To Hyperledger Project][1] + +一旦一个新技术平台在积极发展和商业利益方面达到了一定程度的受欢迎程度,全球的主要公司和小型的初创企业都急于抓住这块蛋糕。在当时 Linux 就是这样的一个平台。一旦实现了其应用程序的普及,个人、公司和机构就开始对其表现出兴趣,到 2000 年,Linux 基金会就成立了。 + +Linux 基金会旨在通过赞助他们的开发团队来将 Linux 作为一个平台来标准化和发展。Linux 基金会是一个由软件和 IT 巨头([如微软、甲骨文、三星、思科、 IBM 、英特尔等][7])支持的非营利组织。这不包括为改进该平台而提供服务的数百名个人开发者。多年来,Linux 基金会已经在旗下开展了许多项目。**Hyperledger** 项目是迄今为止发展最快的项目。 + +在将技术推进至可用且有用的方面上,这种联合主导的开发具有很多优势。为大型项目提供开发标准、库和所有后端协议既昂贵又耗费资源,而且不会从中产生丝毫收入。因此,对于公司来说,通过支持这些组织来汇集他们的资源来开发常见的那些 “烦人” 部分是有很意义的,以及随后完成这些标准部分的工作以简单地即插即用和定制他们的产品。除了这种模型的经济性之外,这种合作努力还产生了标准,使其容易使用和集成到优秀的产品和服务中。 + +上述联盟模式,在曾经或当下的创新包括 WiFi(Wi-Fi 联盟)、移动电话等标准。 + +### Hyperledger 项目(HLP)简介 + +Hyperledger 项目(HLP)于 2015 年 12 月由 Linux 基金会启动,目前是其孵化的增长最快的项目之一。它是一个伞式组织umbrella organization,用于合作开发和推进基于[区块链][2]的分布式账本技术 (DLT) 的工具和标准。支持该项目的主要行业参与者包括 IBM、英特尔 和 SAP Ariba [等][3]。HLP 旨在为个人和公司创建框架,以便根据需要创建共享和封闭的区块链,以满足他们自己的需求。其设计原则是开发一个专注于隐私和未来可审计性的全球可部署、可扩展、强大的区块链平台。[^2] 同样要注意的是大多数提出的区块链及其框架。 + +### 开发目标和构造:即插即用 + +虽然面向企业的平台有以太坊联盟之类的产品,但根据定义,HLP 是面向企业的,并得到行业巨头的支持,他们在 HLP 旗下的许多模块中做出贡献并进一步发展。HLP 还孵化开发的周边项目,并这些创意项目推向公众。HLP 的成员贡献了他们自己的力量,例如 IBM 为如何协作开发贡献了他们的 Fabric 平台。该代码库由 IBM 在其项目组内部研发,并开源出来供所有成员使用。 + +这些过程使得 HLP 中的模块具有高度灵活的插件框架,这将支持企业环境中的快速开发和部署。此外,默认情况下,其他对比的平台是开放的免许可链permission-less blockchain或是公有链public blockchain,甚至可以将它们应用到特定应用当中。HLP 模块本身支持该功能。 + +有关公有链和私有链的差异和用例更多地涵盖在[这篇][4]比较文章当中。 + +根据该项目执行董事 Brian Behlendorf 的说法,Hyperledger 项目的使命有四个。 + +分别是: + + 1. 创建企业级 DLT 框架和标准,任何人都可以移植以满足其特定的行业或个人需求。 + 2. 创建一个强大的开源社区来帮助生态系统发展。 + 3. 促进所述的生态系统的行业成员(如成员公司)的参与。 + 4. 为 HLP 社区提供中立且无偏见的基础设施,以收集和分享相关的更新和发展。 + +可以在这里访问[原始文档][5]。 + +### HLP 的架构 + +HLP 由 12 个项目组成,这些项目被归类为独立的模块,每个项目通常都是结构化的,可以独立开发其模块的。在孵化之前,首先对它们的能力和活力进行研究。该组织的任何成员都可以提出附加建议。在项目孵化后,就会进行积极开发,然后才会推出。这些模块之间的互操作性具有很高的优先级,因此这些组之间的定期通信由社区维护。目前,这些项目中有 4 个被归类为活跃项目。被标为活跃意味着它们已经准备好使用,但还没有准备好发布主要版本。这 4 个模块可以说是推动区块链革命的最重要或相当基本的模块。稍后,我们将详细介绍各个模块及其功能。然而,Hyperledger Fabric 平台的简要描述,可以说是其中最受欢迎的。 + +### Hyperledger Fabric + +Hyperledger Fabric 是一个完全开源的、基于区块链的许可 (非公开) DLT 平台,设计时考虑了企业的使用。该平台提供了适合企业环境的功能和结构。它是高度模块化的,允许开发人员在不同的共识协议、链上代码协议([智能合约][6])或身份管理系统等中进行选择。这是一个基于区块链的许可平台,它利用身份管理系统,这意味着参与者将知道彼此在企业环境中的身份。Fabric 允许以各种主流编程语言 (包括 Java、Javascript、Go 等) 开发智能合约(“链码chaincode”,是 Hyperledger 团队使用的术语)。这使得机构和企业可以利用他们在该领域的现有人才,而无需雇佣或重新培训开发人员来开发他们自己的智能合约。与标准订单验证系统相比,Fabric 还使用执行顺序验证execute-order-validate系统来处理智能合约,以提供更好的可靠性,这些系统由提供智能合约功能的其他平台使用。与标准订单验证系统相比,Fabric还使用执行顺序验证系统来处理智能合约,以提供更好的可靠性,这些系统由提供智能合约功能的其他平台使用。Fabric 的其他功能还有可插拔性能、身份管理系统、数据库管理系统、共识平台等,这些功能使它在竞争中保持领先地位。 + +### 结论 + +诸如 Hyperledger Fabric 平台这样的项目能够在主流用例中更快地采用区块链技术。Hyperledger 社区结构本身支持开放治理原则,并且由于所有项目都是作为开源平台引导的,因此这提高了团队在履行承诺时表现出来的安全性和责任感。 + +由于此类项目的主要应用涉及与企业合作及进一步开发平台和标准,因此 Hyperledger 项目目前在其他类似项目前面处于有利地位。 + +[^2]: E. Androulaki et al., “Hyperledger Fabric: A Distributed Operating System for Permissioned Blockchains,” 2018. + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/blockchain-2-0-an-introduction-to-hyperledger-project-hlp/ + +作者:[ostechnix][a] +选题:[lujun9972][b] +译者:[zionfuo](https://github.com/zionfuo) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/04/Introduction-To-Hyperledger-Project-720x340.png +[2]: https://linux.cn/article-10650-1.html +[3]: https://www.hyperledger.org/members +[4]: https://linux.cn/article-11080-1.html +[5]: http://www.hitachi.com/rev/archive/2017/r2017_01/expert/index.html +[6]: https://linux.cn/article-10956-1.html +[7]: https://www.theinquirer.net/inquirer/news/2182438/samsung-takes-seat-intel-ibm-linux-foundation diff --git a/sources/tech/20190510 Check storage performance with dd.md b/published/201908/20190510 Check storage performance with dd.md similarity index 54% rename from sources/tech/20190510 Check storage performance with dd.md rename to published/201908/20190510 Check storage performance with dd.md index 8cdea81f69..a8ba54c657 100644 --- a/sources/tech/20190510 Check storage performance with dd.md +++ b/published/201908/20190510 Check storage performance with dd.md @@ -1,74 +1,64 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11195-1.html) [#]: subject: (Check storage performance with dd) [#]: via: (https://fedoramagazine.org/check-storage-performance-with-dd/) [#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/) -Check storage performance with dd +使用 dd 检查存储性能 ====== ![][1] -This article includes some example commands to show you how to get a _rough_ estimate of hard drive and RAID array performance using the _dd_ command. Accurate measurements would have to take into account things like [write amplification][2] and [system call overhead][3], which this guide does not. For a tool that might give more accurate results, you might want to consider using [hdparm][4]. +本文包含一些示例命令,向你展示如何使用 `dd` 命令*粗略*估计硬盘驱动器和 RAID 阵列的性能。准确的测量必须考虑诸如[写入放大][2]和[系统调用开销][3]之类的事情,本指南不会考虑这些。对于可能提供更准确结果的工具,你可能需要考虑使用 [hdparm][4]。 -To factor out performance issues related to the file system, these examples show how to test the performance of your drives and arrays at the block level by reading and writing directly to/from their block devices. **WARNING** : The _write_ tests will destroy any data on the block devices against which they are run. **Do not run them against any device that contains data you want to keep!** +为了分解与文件系统相关的性能问题,这些示例显示了如何通过直接读取和写入块设备来在块级测试驱动器和阵列的性能。**警告**:*写入*测试将会销毁用来运行测试的块设备上的所有数据。**不要对包含你想要保留的数据的任何设备运行这些测试!** -### Four tests +### 四个测试 -Below are four example dd commands that can be used to test the performance of a block device: +下面是四个示例 `dd` 命令,可用于测试块设备的性能: - 1. One process reading from $MY_DISK: +1、 从 `$MY_DISK` 读取的一个进程: ``` # dd if=$MY_DISK of=/dev/null bs=1MiB count=200 iflag=nocache ``` - 2. One process writing to $MY_DISK: +2、写入到 `$MY_DISK` 的一个进程: ``` # dd if=/dev/zero of=$MY_DISK bs=1MiB count=200 oflag=direct ``` - 3. Two processes reading concurrently from $MY_DISK: +3、从 `$MY_DISK` 并发读取的两个进程: ``` # (dd if=$MY_DISK of=/dev/null bs=1MiB count=200 iflag=nocache &); (dd if=$MY_DISK of=/dev/null bs=1MiB count=200 iflag=nocache skip=200 &) ``` - 4. Two processes writing concurrently to $MY_DISK: +4、 并发写入到 `$MY_DISK` 的两个进程: ``` # (dd if=/dev/zero of=$MY_DISK bs=1MiB count=200 oflag=direct &); (dd if=/dev/zero of=$MY_DISK bs=1MiB count=200 oflag=direct skip=200 &) ``` +- 执行读写测试时,相应的 `iflag=nocache` 和 `oflag=direct` 参数非常重要,因为没有它们,`dd` 命令有时会显示从[内存][5]中传输数据的结果速度,而不是从硬盘。 +- `bs` 和 `count` 参数的值有些随意,我选择的值应足够大,以便在大多数情况下为当前硬件提供合适的平均值。 +- `null` 和 `zero` 设备在读写测试中分别用于目标和源,因为它们足够快,不会成为性能测试中的限制因素。 +- 并发读写测试中第二个 `dd` 命令的 `skip=200` 参数是为了确保 `dd` 的两个副本在硬盘驱动器的不同区域上运行。 +### 16 个示例 +下面是演示,显示针对以下四个块设备中之一运行上述四个测试中的各个结果: -– The _iflag=nocache_ and _oflag=direct_ parameters are important when performing the read and write tests (respectively) because without them the dd command will sometimes show the resulting speed of transferring the data to/from [RAM][5] rather than the hard drive. +1. `MY_DISK=/dev/sda2`(用在示例 1-X 中) +2. `MY_DISK=/dev/sdb2`(用在示例 2-X 中) +3. `MY_DISK=/dev/md/stripped`(用在示例 3-X 中) +4. `MY_DISK=/dev/md/mirrored`(用在示例 4-X 中) -– The values for the _bs_ and _count_ parameters are somewhat arbitrary and what I have chosen should be large enough to provide a decent average in most cases for current hardware. - -– The _null_ and _zero_ devices are used for the destination and source (respectively) in the read and write tests because they are fast enough that they will not be the limiting factor in the performance tests. - -– The _skip=200_ parameter on the second dd command in the concurrent read and write tests is to ensure that the two copies of dd are operating on different areas of the hard drive. - -### 16 examples - -Below are demonstrations showing the results of running each of the above four tests against each of the following four block devices: - - 1. MY_DISK=/dev/sda2 (used in examples 1-X) - 2. MY_DISK=/dev/sdb2 (used in examples 2-X) - 3. MY_DISK=/dev/md/stripped (used in examples 3-X) - 4. MY_DISK=/dev/md/mirrored (used in examples 4-X) - - - -A video demonstration of the these tests being run on a PC is provided at the end of this guide. - -Begin by putting your computer into _rescue_ mode to reduce the chances that disk I/O from background services might randomly affect your test results. **WARNING** : This will shutdown all non-essential programs and services. Be sure to save your work before running these commands. You will need to know your _root_ password to get into rescue mode. The _passwd_ command, when run as the root user, will prompt you to (re)set your root account password. +首先将计算机置于*救援*模式,以减少后台服务的磁盘 I/O 随机影响测试结果的可能性。**警告**:这将关闭所有非必要的程序和服务。在运行这些命令之前,请务必保存你的工作。你需要知道 `root` 密码才能进入救援模式。`passwd` 命令以 `root` 用户身份运行时,将提示你(重新)设置 `root` 帐户密码。 ``` $ sudo -i @@ -77,14 +67,14 @@ $ sudo -i # systemctl rescue ``` -You might also want to temporarily disable logging to disk: +你可能还想暂时禁止将日志记录到磁盘: ``` # sed -r -i.bak 's/^#?Storage=.*/Storage=none/' /etc/systemd/journald.conf # systemctl restart systemd-journald.service ``` -If you have a swap device, it can be temporarily disabled and used to perform the following tests: +如果你有交换设备,可以暂时禁用它并用于执行后面的测试: ``` # swapoff -a @@ -93,7 +83,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th # mdadm --zero-superblock $MY_DEVS ``` -#### Example 1-1 (reading from sda) +#### 示例 1-1 (从 sda 读取) ``` # MY_DISK=$(echo $MY_DEVS | cut -d ' ' -f 1) @@ -106,7 +96,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 1.7003 s, 123 MB/s ``` -#### Example 1-2 (writing to sda) +#### 示例 1-2 (写入到 sda) ``` # MY_DISK=$(echo $MY_DEVS | cut -d ' ' -f 1) @@ -119,7 +109,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 1.67117 s, 125 MB/s ``` -#### Example 1-3 (reading concurrently from sda) +#### 示例 1-3 (从 sda 并发读取) ``` # MY_DISK=$(echo $MY_DEVS | cut -d ' ' -f 1) @@ -135,7 +125,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 3.52614 s, 59.5 MB/s ``` -#### Example 1-4 (writing concurrently to sda) +#### 示例 1-4 (并发写入到 sda) ``` # MY_DISK=$(echo $MY_DEVS | cut -d ' ' -f 1) @@ -150,7 +140,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 3.60872 s, 58.1 MB/s ``` -#### Example 2-1 (reading from sdb) +#### 示例 2-1 (从 sdb 读取) ``` # MY_DISK=$(echo $MY_DEVS | cut -d ' ' -f 2) @@ -163,7 +153,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 1.67285 s, 125 MB/s ``` -#### Example 2-2 (writing to sdb) +#### 示例 2-2 (写入到 sdb) ``` # MY_DISK=$(echo $MY_DEVS | cut -d ' ' -f 2) @@ -176,7 +166,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 1.67198 s, 125 MB/s ``` -#### Example 2-3 (reading concurrently from sdb) +#### 示例 2-3 (从 sdb 并发读取) ``` # MY_DISK=$(echo $MY_DEVS | cut -d ' ' -f 2) @@ -192,7 +182,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 3.57736 s, 58.6 MB/s ``` -#### Example 2-4 (writing concurrently to sdb) +#### 示例 2-4 (并发写入到 sdb) ``` # MY_DISK=$(echo $MY_DEVS | cut -d ' ' -f 2) @@ -208,7 +198,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 3.81475 s, 55.0 MB/s ``` -#### Example 3-1 (reading from RAID0) +#### 示例 3-1 (从 RAID0 读取) ``` # mdadm --create /dev/md/stripped --homehost=any --metadata=1.0 --level=0 --raid-devices=2 $MY_DEVS @@ -222,7 +212,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 0.837419 s, 250 MB/s ``` -#### Example 3-2 (writing to RAID0) +#### 示例 3-2 (写入到 RAID0) ``` # MY_DISK=/dev/md/stripped @@ -235,7 +225,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 0.823648 s, 255 MB/s ``` -#### Example 3-3 (reading concurrently from RAID0) +#### 示例 3-3 (从 RAID0 并发读取) ``` # MY_DISK=/dev/md/stripped @@ -251,7 +241,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 1.80016 s, 116 MB/s ``` -#### Example 3-4 (writing concurrently to RAID0) +#### 示例 3-4 (并发写入到 RAID0) ``` # MY_DISK=/dev/md/stripped @@ -267,7 +257,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 1.81323 s, 116 MB/s ``` -#### Example 4-1 (reading from RAID1) +#### 示例 4-1 (从 RAID1 读取) ``` # mdadm --stop /dev/md/stripped @@ -282,7 +272,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 1.74963 s, 120 MB/s ``` -#### Example 4-2 (writing to RAID1) +#### 示例 4-2 (写入到 RAID1) ``` # MY_DISK=/dev/md/mirrored @@ -295,7 +285,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 1.74625 s, 120 MB/s ``` -#### Example 4-3 (reading concurrently from RAID1) +#### 示例 4-3 (从 RAID1 并发读取) ``` # MY_DISK=/dev/md/mirrored @@ -311,7 +301,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 1.67685 s, 125 MB/s ``` -#### Example 4-4 (writing concurrently to RAID1) +#### 示例 4-4 (并发写入到 RAID1) ``` # MY_DISK=/dev/md/mirrored @@ -327,7 +317,7 @@ If you have a swap device, it can be temporarily disabled and used to perform th 209715200 bytes (210 MB, 200 MiB) copied, 4.1067 s, 51.1 MB/s ``` -#### Restore your swap device and journald configuration +#### 恢复交换设备和日志配置 ``` # mdadm --stop /dev/md/stripped /dev/md/mirrored @@ -339,23 +329,19 @@ If you have a swap device, it can be temporarily disabled and used to perform th # reboot ``` -### Interpreting the results +### 结果解读 -Examples 1-1, 1-2, 2-1, and 2-2 show that each of my drives read and write at about 125 MB/s. +示例 1-1、1-2、2-1 和 2-2 表明我的每个驱动器以大约 125 MB/s 的速度读写。 -Examples 1-3, 1-4, 2-3, and 2-4 show that when two reads or two writes are done in parallel on the same drive, each process gets at about half the drive’s bandwidth (60 MB/s). +示例 1-3、1-4、2-3 和 2-4 表明,当在同一驱动器上并行完成两次读取或写入时,每个进程的驱动器带宽大约为一半(60 MB/s)。 -The 3-x examples show the performance benefit of putting the two drives together in a RAID0 (data stripping) array. The numbers, in all cases, show that the RAID0 array performs about twice as fast as either drive is able to perform on its own. The trade-off is that you are twice as likely to lose everything because each drive only contains half the data. A three-drive array would perform three times as fast as a single drive (all drives being equal) but it would be thrice as likely to suffer a [catastrophic failure][6]. +3-X 示例显示了将两个驱动器放在 RAID0(数据条带化)阵列中的性能优势。在所有情况下,这些数字表明 RAID0 阵列的执行速度是任何一个驱动器能够独立提供的速度的两倍。相应的是,丢失所有内容的可能性也是两倍,因为每个驱动器只包含一半的数据。一个三个驱动器阵列的执行速度是单个驱动器的三倍(所有驱动器规格都相同),但遭受[灾难性故障][6]的可能也是三倍。 -The 4-x examples show that the performance of the RAID1 (data mirroring) array is similar to that of a single disk except for the case where multiple processes are concurrently reading (example 4-3). In the case of multiple processes reading, the performance of the RAID1 array is similar to that of the RAID0 array. This means that you will see a performance benefit with RAID1, but only when processes are reading concurrently. For example, if a process tries to access a large number of files in the background while you are trying to use a web browser or email client in the foreground. The main benefit of RAID1 is that your data is unlikely to be lost [if a drive fails][7]. +4-X 示例显示 RAID1(数据镜像)阵列的性能类似于单个磁盘的性能,除了多个进程同时读取的情况(示例4-3)。在多个进程读取的情况下,RAID1 阵列的性能类似于 RAID0 阵列的性能。这意味着你将看到 RAID1 的性能优势,但仅限于进程同时读取时。例如,当你在前台使用 Web 浏览器或电子邮件客户端时,进程会尝试访问后台中的大量文件。RAID1 的主要好处是,[如果驱动器出现故障][7],你的数据不太可能丢失。 -### Video demo +### 故障排除 -Testing storage throughput using dd - -### Troubleshooting - -If the above tests aren’t performing as you expect, you might have a bad or failing drive. Most modern hard drives have built-in Self-Monitoring, Analysis and Reporting Technology ([SMART][8]). If your drive supports it, the _smartctl_ command can be used to query your hard drive for its internal statistics: +如果上述测试未按预期执行,则可能是驱动器坏了或出现故障。大多数现代硬盘都内置了自我监控、分析和报告技术([SMART][8])。如果你的驱动器支持它,`smartctl` 命令可用于查询你的硬盘驱动器的内部统计信息: ``` # smartctl --health /dev/sda @@ -363,21 +349,21 @@ If the above tests aren’t performing as you expect, you might have a bad or fa # smartctl -x /dev/sda ``` -Another way that you might be able to tune your PC for better performance is by changing your [I/O scheduler][9]. Linux systems support several I/O schedulers and the current default for Fedora systems is the [multiqueue][10] variant of the [deadline][11] scheduler. The default performs very well overall and scales extremely well for large servers with many processors and large disk arrays. There are, however, a few more specialized schedulers that might perform better under certain conditions. +另一种可以调整 PC 以获得更好性能的方法是更改 [I/O 调度程序][9]。Linux 系统支持多个 I/O 调度程序,Fedora 系统的当前默认值是 [deadline][11] 调度程序的 [multiqueue][10] 变体。默认情况下它的整体性能非常好,并且对于具有许多处理器和大型磁盘阵列的大型服务器,其扩展性极为出色。但是,有一些更专业的调度程序在某些条件下可能表现更好。 -To view which I/O scheduler your drives are using, issue the following command: +要查看驱动器正在使用的 I/O 调度程序,请运行以下命令: ``` $ for i in /sys/block/sd?/queue/scheduler; do echo "$i: $(<$i)"; done ``` -You can change the scheduler for a drive by writing the name of the desired scheduler to the /sys/block//queue/scheduler file: +你可以通过将所需调度程序的名称写入 `/sys/block//queue/scheduler` 文件来更改驱动器的调度程序: ``` # echo bfq > /sys/block/sda/queue/scheduler ``` -You can make your changes permanent by creating a [udev rule][12] for your drive. The following example shows how to create a udev rule that will set all [rotational drives][13] to use the [BFQ][14] I/O scheduler: +你可以通过为驱动器创建 [udev 规则][12]来永久更改它。以下示例显示了如何创建将所有的[旋转式驱动器][13]设置为使用 [BFQ][14] I/O 调度程序的 udev 规则: ``` # cat << END > /etc/udev/rules.d/60-ioscheduler-rotational.rules @@ -385,7 +371,7 @@ ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue END ``` -Here is another example that sets all [solid-state drives][15] to use the [NOOP][16] I/O scheduler: +这是另一个设置所有的[固态驱动器][15]使用 [NOOP][16] I/O 调度程序的示例: ``` # cat << END > /etc/udev/rules.d/60-ioscheduler-solid-state.rules @@ -393,11 +379,7 @@ ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue END ``` -Changing your I/O scheduler won’t affect the raw throughput of your devices, but it might make your PC seem more responsive by prioritizing the bandwidth for the foreground tasks over the background tasks or by eliminating unnecessary block reordering. - -* * * - -_Photo by _[ _James Donovan_][17]_ on _[_Unsplash_][18]_._ +更改 I/O 调度程序不会影响设备的原始吞吐量,但通过优先考虑后台任务的带宽或消除不必要的块重新排序,可能会使你的 PC 看起来响应更快。 -------------------------------------------------------------------------------- @@ -405,8 +387,8 @@ via: https://fedoramagazine.org/check-storage-performance-with-dd/ 作者:[Gregory Bartholomew][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/201908/20190611 What is a Linux user.md b/published/201908/20190611 What is a Linux user.md new file mode 100644 index 0000000000..e3cd069b2b --- /dev/null +++ b/published/201908/20190611 What is a Linux user.md @@ -0,0 +1,57 @@ +[#]: collector: "lujun9972" +[#]: translator: "qfzy1233 " +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11231-1.html" +[#]: subject: "What is a Linux user?" +[#]: via: "https://opensource.com/article/19/6/what-linux-user" +[#]: author: "Anderson Silva https://opensource.com/users/ansilva/users/petercheer/users/ansilva/users/greg-p/users/ansilva/users/ansilva/users/bcotton/users/ansilva/users/seth/users/ansilva/users/don-watkins/users/ansilva/users/seth" + +何谓 Linux 用户? +====== + +> “Linux 用户”这一定义已经拓展到了更大的范围,同时也发生了巨大的改变。 + +![](https://img.linux.net.cn/data/attachment/album/201908/15/211706trkbzp8juhbzifia.jpg) + +*编者按: 本文更新于 2019 年 6 月 11 日下午 1:15:19,以更准确地反映作者对 Linux 社区中开放和包容的社区性的看法。* + +再有不到两年,Linux 内核就要迎来它 30 岁的生日了。让我们回想一下!1991 年的时候你在哪里?你出生了吗?那年我 13 岁!在 1991 到 1993 年间只推出了少数几款 Linux 发行版,至少它们中的三个:Slackware、Debian 和 Red Hat 为 Linux 运动发展提供了[支柱][2]。 + +当年获得 Linux 发行版的副本,并在笔记本或服务器上进行安装和配置,和今天相比是很不一样的。当时是十分艰难的!也是令人沮丧的!如果你让能让它运行起来,就是一个了不起的成就!我们不得不与不兼容的硬件、设备上的配置跳线、BIOS 问题以及许多其他问题作斗争。甚至即使硬件是兼容的,很多时候,你仍然需要编译内核、模块和驱动程序才能让它们在你的系统上工作。 + +如果你当时经过过那些,你可能会表示赞同。有些读者甚至称它们为“美好的过往”,因为选择使用 Linux 意味着仅仅是为了让操作系统继续运行,你就必须学习操作系统、计算机体系架构、系统管理、网络,甚至编程。但我并不赞同他们的说法,窃以为:Linux 在 IT 行业带给我们的最让人惊讶的改变就是,它成为了我们每个人技术能力的基础组成部分! + +将近 30 年过去了,无论是桌面和服务器领域 Linux 系统都有了脱胎换骨的变换。你可以在汽车上,在飞机上,家用电器上,智能手机上……几乎任何地方发现 Linux 的影子!你甚至可以购买预装 Linux 的笔记本电脑、台式机和服务器。如果你考虑云计算,企业甚至个人都可以一键部署 Linux 虚拟机,由此可见 Linux 的应用已经变得多么普遍了。 + +考虑到这些,我想问你的问题是:**这个时代如何定义“Linux 用户”?** + +如果你从 System76 或 Dell 为你的父母或祖父母购买一台 Linux 笔记本电脑,为其登录好他们的社交媒体和电子邮件,并告诉他们经常单击“系统升级”,那么他们现在就是 Linux 用户了。如果你是在 Windows 或 MacOS 机器上进行以上操作,那么他们就是 Windows 或 MacOS 用户。令人难以置信的是,与 90 年代不同,现在的 Linux 任何人都可以轻易上手。 + +由于种种原因,这也归因于 web 浏览器成为了桌面计算机上的“杀手级应用程序”。现在,许多用户并不关心他们使用的是什么操作系统,只要他们能够访问到他们的应用程序或服务。 + +你知道有多少人经常使用他们的电话、桌面或笔记本电脑,但不会管理他们系统上的文件、目录和驱动程序?又有多少人不会安装“应用程序商店”没有收录的二进制文件程序?更不要提从头编译应用程序,对我来说,几乎全是这样的。这正是成熟的开源软件和相应的生态对于易用性的改进的动人之处。 + +今天的 Linux 用户不需要像上世纪 90 年代或 21 世纪初的 Linux 用户那样了解、学习甚至查询信息,这并不是一件坏事。过去那种认为 Linux 只适合工科男使用的想法已经一去不复返了。 + +对于那些对计算机、操作系统以及在自由软件上创建、使用和协作的想法感兴趣、好奇、着迷的 Linux 用户来说,Liunx 依旧有研究的空间。如今在 Windows 和 MacOS 上也有同样多的空间留给创造性的开源贡献者。今天,成为 Linux 用户就是成为一名与 Linux 系统同行的人。这是一件很棒的事情。 + +### Linux 用户定义的转变 + +当我开始使用 Linux 时,作为一个 Linux 用户意味着知道操作系统如何以各种方式、形态和形式运行。Linux 在某种程度上已经成熟,这使得“Linux 用户”的定义可以包含更广泛的领域及那些领域里的人们。这可能是显而易见的一点,但重要的还是要说清楚:任何 Linux 用户皆“生”而平等。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/what-linux-user + +作者:[Anderson Silva][a] +选题:[lujun9972][b] +译者:[qfzy1233](https://github.com/qfzy1233) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ansilva/users/petercheer/users/ansilva/users/greg-p/users/ansilva/users/ansilva/users/bcotton/users/ansilva/users/seth/users/ansilva/users/don-watkins/users/ansilva/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_penguin_green.png?itok=ENdVzW22 +[2]: https://en.wikipedia.org/wiki/Linux_distribution#/media/File:Linux_Distribution_Timeline.svg diff --git a/published/201908/20190613 Continuous integration testing for the Linux kernel.md b/published/201908/20190613 Continuous integration testing for the Linux kernel.md new file mode 100644 index 0000000000..38f262eabe --- /dev/null +++ b/published/201908/20190613 Continuous integration testing for the Linux kernel.md @@ -0,0 +1,92 @@ +[#]: collector: (lujun9972) +[#]: translator: (LazyWolfLin) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11176-1.html) +[#]: subject: (Continuous integration testing for the Linux kernel) +[#]: via: (https://opensource.com/article/19/6/continuous-kernel-integration-linux) +[#]: author: (Major Hayden https://opensource.com/users/mhayden) + +Linux 内核的持续集成测试 +====== + +> CKI 团队是如何防止 bug 被合并到 Linux 内核中。 + +![](https://img.linux.net.cn/data/attachment/album/201908/02/112520aidijdddo9wwvbiv.jpg) + +Linux 内核的每个发布版本包含了来自 1,700 个开发者产生的 14,000 个变更集,很显然,这使得 Linux 内核快速迭代的同时也产生了巨大的复杂性问题。内核上 Bug 有小麻烦也有大问题,有时是系统崩溃,有时是数据丢失。 + +随着越来越多的项目对于持续集成(CI)的呼声,[内核持续集成(CKI)][2]小组秉承着一个任务目标:防止 Bug 被合并到内核当中。 + +### Linux 测试问题 + +许多 Linux 发行版只在需要的时候对 Linux 内核进行测试。而这种测试往往只在版本发布时或者用户发现错误时进行。 + +有时候,出现玄学问题时,维护人员需要在包含了数万个补丁的变更中匆忙地寻找哪个补丁导致这个新的玄学 Bug。诊断 Bug 需要专业的硬件设备、一系列的触发器以及内核相关的专业知识。 + +#### CI 和 Linux + +许多现代软件代码库都采用某种自动化 CI 测试机制,能够在提交进入代码存储库之前对其进行测试。这种自动化测试使得维护人员可以通过查看 CI 测试报告来发现软件质量问题以及大多数的错误。一些简单的项目,比如某个 Python 库,附带的大量工具使得整个检查过程更简单。 + +在任何测试之前都需要配置和编译 Linux。而这么做将耗费大量的时间和计算资源。此外,Linux 内核必需在虚拟机或者裸机上启动才能进行测试。而访问某些硬件架构需要额外的开销或者非常慢的仿真。因此,人们必须确定一组能够触发错误或者验证修复的测试集。 + +#### CKI 团队如何运作? + +Red Hat 公司的 CKI 团队当前正追踪来自数个内部内核分支和上游的[稳定内核分支树][3]等内核分支的更改。我们关注每个代码库的两类关键事件: + + 1. 当维护人员合并 PR 或者补丁时,代码库变化后的最终结果。 + 2. 当开发人员通过拼凑或者稳定补丁队列发起变更合并时。 + +当这些事件发生时,自动化工具开始执行,[GitLab CI 管道][4]开始进行测试。一旦管道开始执行 [linting][5] 脚本、合并每一个补丁,并为多种硬件架构编译内核,真正的测试便开始了。我们会在六分钟内完成四种硬件架构的内核编译工作,并且通常会在两个小时或更短的时间内将反馈提交到稳定邮件列表中。(自 2019 年 1 月起)每月执行超过 100,000 次内核测试,并完成了超过 11,000 个 GitLab 管道。 + +每个内核都会在本地硬件架构上启动,其中包含: + +* [aarch64][6]:64 位 [ARM][7],例如 [Cavium(当前是 Marvell)ThunderX][8]。 +* [ppc64/ppc64le][9]:大端和小端的 [IBM POWER][10] 系统。 +* [s390x][11]:[IBM Zseries][12] 大型机 +* [x86_64][13]:[Intel][14] 和 [AMD][15] 工作站、笔记本和服务器。 + +这些内核上运行了包括 [Linux 测试项目(LTP)][16]在内的多个测试,其中包括使用常用测试工具的大量测试。我们 CKI 团队开源了超过 44 个测试并将继续开源更多测试。 + +### 参与其中 + +上游的内核测试工作日渐增多。包括 [Google][17]、Intel、[Linaro][18] 和 [Sony][19] 在内的许多公司为各种内核提供了测试输出。每一项工作都专注于为上游内核以及每个公司的客户群带来价值。 + +如果你或者你的公司想要参与这一工作,请参加在 9 月份在葡萄牙里斯本举办的 [Linux Plumbers Conference 2019][20]。在会议结束后的两天加入我们的 Kernel CI hackfest 活动,并推动快速内核测试的发展。 + +更多详细信息,[请见][21]我在 Texas Linux Fest 2019 上的演讲。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/continuous-kernel-integration-linux + +作者:[Major Hayden][a] +选题:[lujun9972][b] +译者:[LazyWolfLin](https://github.com/LazyWolfLin) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mhayden +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_kernel_clang_vscode.jpg?itok=fozZ4zrr "Linux kernel source code (C) in Visual Studio Code" +[2]: https://cki-project.org/ +[3]: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html +[4]: https://docs.gitlab.com/ee/ci/pipelines.html +[5]: https://en.wikipedia.org/wiki/Lint_(software) +[6]: https://en.wikipedia.org/wiki/ARM_architecture +[7]: https://www.arm.com/ +[8]: https://www.marvell.com/server-processors/thunderx-arm-processors/ +[9]: https://en.wikipedia.org/wiki/Ppc64 +[10]: https://www.ibm.com/it-infrastructure/power +[11]: https://en.wikipedia.org/wiki/Linux_on_z_Systems +[12]: https://www.ibm.com/it-infrastructure/z +[13]: https://en.wikipedia.org/wiki/X86-64 +[14]: https://www.intel.com/ +[15]: https://www.amd.com/ +[16]: https://github.com/linux-test-project/ltp +[17]: https://www.google.com/ +[18]: https://www.linaro.org/ +[19]: https://www.sony.com/ +[20]: https://www.linuxplumbersconf.org/ +[21]: https://docs.google.com/presentation/d/1T0JaRA0wtDU0aTWTyASwwy_ugtzjUcw_ZDmC5KFzw-A/edit?usp=sharing diff --git a/published/201908/20190617 How To Check Linux Package Version Before Installing It.md b/published/201908/20190617 How To Check Linux Package Version Before Installing It.md new file mode 100644 index 0000000000..574b0bb031 --- /dev/null +++ b/published/201908/20190617 How To Check Linux Package Version Before Installing It.md @@ -0,0 +1,275 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11243-1.html) +[#]: subject: (How To Check Linux Package Version Before Installing It) +[#]: via: (https://www.ostechnix.com/how-to-check-linux-package-version-before-installing-it/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +如何在安装之前检查 Linux 软件包的版本? +====== + +![Check Linux Package Version][1] + +大多数人都知道如何在 Linux 中[查找已安装软件包的版本][2],但是,你会如何查找那些还没有安装的软件包的版本呢?很简单!本文将介绍在 Debian 及其衍生品(如 Ubuntu)中,如何在软件包安装之前检查它的版本。对于那些想在安装之前知道软件包版本的人来说,这个小技巧可能会有所帮助。 + +### 在安装之前检查 Linux 软件包版本 + +在基于 DEB 的系统中,即使软件包还没有安装,也有很多方法可以查看他的版本。接下来,我将一一介绍。 + +#### 方法 1 – 使用 Apt + +检查软件包的版本的懒人方法: + +``` +$ apt show +``` + +**示例:** + +``` +$ apt show vim +``` + +**示例输出:** + +``` +Package: vim +Version: 2:8.0.1453-1ubuntu1.1 +Priority: optional +Section: editors +Origin: Ubuntu +Maintainer: Ubuntu Developers <[email protected]> +Original-Maintainer: Debian Vim Maintainers <[email protected]> +Bugs: https://bugs.launchpad.net/ubuntu/+filebug +Installed-Size: 2,852 kB +Provides: editor +Depends: vim-common (= 2:8.0.1453-1ubuntu1.1), vim-runtime (= 2:8.0.1453-1ubuntu1.1), libacl1 (>= 2.2.51-8), libc6 (>= 2.15), libgpm2 (>= 1.20.7), libpython3.6 (>= 3.6.5), libselinux1 (>= 1.32), libtinfo5 (>= 6) +Suggests: ctags, vim-doc, vim-scripts +Homepage: https://vim.sourceforge.io/ +Task: cloud-image, server +Supported: 5y +Download-Size: 1,152 kB +APT-Sources: http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages +Description: Vi IMproved - enhanced vi editor + Vim is an almost compatible version of the UNIX editor Vi. + . + Many new features have been added: multi level undo, syntax + highlighting, command line history, on-line help, filename + completion, block operations, folding, Unicode support, etc. + . + This package contains a version of vim compiled with a rather + standard set of features. This package does not provide a GUI + version of Vim. See the other vim-* packages if you need more + (or less). + +N: There is 1 additional record. Please use the '-a' switch to see it +``` + +正如你在上面的输出中看到的,`apt show` 命令显示了软件包许多重要的细节,例如: + + 1. 包名称, + 2. 版本, + 3. 来源(vim 来自哪里), + 4. 维护者, + 5. 包的主页, + 6. 依赖, + 7. 下载大小, + 8. 简介, + 9. 其他。 + +因此,Ubuntu 仓库中可用的 Vim 版本是 **8.0.1453**。如果我把它安装到我的 Ubuntu 系统上,就会得到这个版本。 + +或者,如果你不想看那么多的内容,那么可以使用 `apt policy` 这个命令: + +``` +$ apt policy vim +vim: + Installed: (none) + Candidate: 2:8.0.1453-1ubuntu1.1 + Version table: + 2:8.0.1453-1ubuntu1.1 500 + 500 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages + 500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages + 2:8.0.1453-1ubuntu1 500 + 500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages +``` + +甚至更短: + +``` +$ apt list vim +Listing... Done +vim/bionic-updates,bionic-security 2:8.0.1453-1ubuntu1.1 amd64 +N: There is 1 additional version. Please use the '-a' switch to see it +``` + +`apt` 是 Ubuntu 最新版本的默认包管理器。因此,这个命令足以找到一个软件包的详细信息,给定的软件包是否安装并不重要。这个命令将简单地列出给定包的版本以及其他详细信息。 + +#### 方法 2 – 使用 Apt-get + +要查看软件包的版本而不安装它,我们可以使用 `apt-get` 命令和 `-s` 选项。 + +``` +$ apt-get -s install vim +``` + +**示例输出:** + +``` +NOTE: This is only a simulation! + apt-get needs root privileges for real execution. + Keep also in mind that locking is deactivated, + so don't depend on the relevance to the real current situation! +Reading package lists... Done +Building dependency tree +Reading state information... Done +Suggested packages: + ctags vim-doc vim-scripts +The following NEW packages will be installed: + vim +0 upgraded, 1 newly installed, 0 to remove and 45 not upgraded. +Inst vim (2:8.0.1453-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) +Conf vim (2:8.0.1453-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) +``` + +这里,`-s` 选项代表 **模拟**。正如你在输出中看到的,它不执行任何操作。相反,它只是模拟执行,好让你知道在安装 Vim 时会发生什么。 + +你可以将 `install` 选项替换为 `upgrade`,以查看升级包时会发生什么。 + +``` +$ apt-get -s upgrade vim +``` + +#### 方法 3 – 使用 Aptitude + +在 Debian 及其衍生品中,`aptitude` 是一个基于 ncurses(LCTT 译注:ncurses 是终端基于文本的字符处理的库)和命令行的前端 APT 包管理器。 + +使用 aptitude 来查看软件包的版本,只需运行: + +``` +$ aptitude versions vim +p 2:8.0.1453-1ubuntu1 bionic 500 +p 2:8.0.1453-1ubuntu1.1 bionic-security,bionic-updates 500 +``` + +你还可以使用模拟选项(`-s`)来查看安装或升级包时会发生什么。 + +``` +$ aptitude -V -s install vim +The following NEW packages will be installed: + vim [2:8.0.1453-1ubuntu1.1] +0 packages upgraded, 1 newly installed, 0 to remove and 45 not upgraded. +Need to get 1,152 kB of archives. After unpacking 2,852 kB will be used. +Would download/install/remove packages. +``` + +这里,`-V` 标志用于显示软件包的详细信息。 + +``` +$ aptitude -V -s upgrade vim +``` + +类似的,只需将 `install` 替换为 `upgrade` 选项,即可查看升级包会发生什么。 + +``` +$ aptitude search vim -F "%c %p %d %V" +``` + +这里, + + * `-F` 用于指定应使用哪种格式来显示输出, + * `%c` – 包的状态(已安装或未安装), + * `%p` – 包的名称, + * `%d` – 包的简介, + * `%V` – 包的版本。 + +当你不知道完整的软件包名称时,这非常有用。这个命令将列出包含给定字符串(即 vim)的所有软件包。 + +以下是上述命令的示例输出: + +``` +[...] +p vim Vi IMproved - enhanced vi editor 2:8.0.1453-1ub +p vim-tlib Some vim utility functions 1.23-1 +p vim-ultisnips snippet solution for Vim 3.1-3 +p vim-vimerl Erlang plugin for Vim 1.4.1+git20120 +p vim-vimerl-syntax Erlang syntax for Vim 1.4.1+git20120 +p vim-vimoutliner script for building an outline editor on top of Vim 0.3.4+pristine +p vim-voom Vim two-pane outliner 5.2-1 +p vim-youcompleteme fast, as-you-type, fuzzy-search code completion engine for Vim 0+20161219+git +``` + +#### 方法 4 – 使用 Apt-cache + +`apt-cache` 命令用于查询基于 Debian 的系统中的 APT 缓存。对于要在 APT 的包缓存上执行很多操作时,它很有用。一个很好的例子是我们可以从[某个仓库或 ppa 中列出已安装的应用程序][3]。 + +不仅是已安装的应用程序,我们还可以找到软件包的版本,即使它没有被安装。例如,以下命令将找到 Vim 的版本: + +``` +$ apt-cache policy vim +``` + +示例输出: + +``` +vim: + Installed: (none) + Candidate: 2:8.0.1453-1ubuntu1.1 + Version table: + 2:8.0.1453-1ubuntu1.1 500 + 500 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages + 500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages + 2:8.0.1453-1ubuntu1 500 + 500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages +``` + +正如你在上面的输出中所看到的,Vim 并没有安装。如果你想安装它,你会知道它的版本是 **8.0.1453**。它还显示 vim 包来自哪个仓库。 + +#### 方法 5 – 使用 Apt-show-versions + +在 Debian 和基于 Debian 的系统中,`apt-show-versions` 命令用于列出已安装和可用软件包的版本。它还显示所有可升级软件包的列表。如果你有一个混合的稳定或测试环境,这是非常方便的。例如,如果你同时启用了稳定和测试仓库,那么你可以轻松地从测试库找到应用程序列表,还可以升级测试库中的所有软件包。 + +默认情况下系统没有安装 `apt-show-versions`,你需要使用以下命令来安装它: + +``` +$ sudo apt-get install apt-show-versions +``` + +安装后,运行以下命令查找软件包的版本,例如 Vim: + +``` +$ apt-show-versions -a vim +vim:amd64 2:8.0.1453-1ubuntu1 bionic archive.ubuntu.com +vim:amd64 2:8.0.1453-1ubuntu1.1 bionic-security security.ubuntu.com +vim:amd64 2:8.0.1453-1ubuntu1.1 bionic-updates archive.ubuntu.com +vim:amd64 not installed +``` + +这里,`-a` 选项打印给定软件包的所有可用版本。 + +如果已经安装了给定的软件包,那么就不需要使用 `-a` 选项。在这种情况下,只需运行: + +``` +$ apt-show-versions vim +``` + +差不多完了。如果你还了解其他方法,在下面的评论中分享,我将检查并更新本指南。 + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-check-linux-package-version-before-installing-it/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/06/Check-Linux-Package-Version-720x340.png +[2]: https://www.ostechnix.com/find-package-version-linux/ +[3]: https://www.ostechnix.com/list-installed-packages-certain-repository-linux/ diff --git a/published/201908/20190705 Enable ‘Tap to click- on Ubuntu Login Screen -Quick Tip.md b/published/201908/20190705 Enable ‘Tap to click- on Ubuntu Login Screen -Quick Tip.md new file mode 100644 index 0000000000..85b9e0ff98 --- /dev/null +++ b/published/201908/20190705 Enable ‘Tap to click- on Ubuntu Login Screen -Quick Tip.md @@ -0,0 +1,98 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11182-1.html) +[#]: subject: (Enable ‘Tap to click’ on Ubuntu Login Screen [Quick Tip]) +[#]: via: (https://itsfoss.com/enable-tap-to-click-on-ubuntu-login-screen/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu 登录屏幕上启用轻击 +====== + +> 轻击tap to click选项在 Ubuntu 18.04 GNOME 桌面的登录屏幕上不起作用。在本教程中,你将学习如何在 Ubuntu 登录屏幕上启用“轻击”。 + +安装 Ubuntu 后我做的第一件事就是确保启用了轻击功能。作为笔记本电脑用户,我更喜欢轻击触摸板进行左键单击。这比使用触摸板上的左键单击按钮更方便。 + +我登录并使用操作系统时可以轻击。但是,如果你在登录屏幕上,轻击不起作用,这是一个烦恼。 + +在 Ubuntu(或使用 GNOME 桌面的其他发行版)的 [GDM 登录屏幕][1]上,你必须单击用户名才能显示密码字段。现在,如果你习惯了轻击,即使你已启用了它并在登录系统后可以使用,它也无法在登录屏幕上运行。 + +这是一个轻微的烦恼,但仍然是一个烦恼。好消息是你可以解决这个烦恼。让我告诉你如何在这个快速提示中做到这一点。 + +### 在 Ubuntu 登录屏幕上启用轻击 + +![][2] + +你必须在这里使用终端和一些命令。我希望你能够适应。 + +[在 Ubuntu 中使用 Ctrl + Alt + T 快捷键打开终端][3]。由于 Ubuntu 18.04 仍在使用 X 显示服务器,因此需要启用它才能连接到 [X 服务器][4]。为此,你可以将 `gdm` 添加到访问控制列表中。 + +首先切换到 `root` 用户。这是必需的,因为你必须稍后切换为 `gdm` 用户,而不能以非 `root` 用户身份执行此操作。 + +``` +sudo -i +``` + +[在 Ubuntu 中没有为 root 用户设置密码][5]。你可以使用管理员用户帐户访问它。因此,当要求输入密码时,请使用你自己的密码。输入密码时,屏幕上不会显示任何输入内容。 + +``` +xhost +SI:localuser:gdm +``` + +这是我的输出: + +``` +xhost +SI:localuser:gdm +localuser:gdm being added to access control list +``` + +现在运行此命令,以便 `gdm` 用户具有正确的轻击设置。 + +``` +gsettings set org.gnome.desktop.peripherals.touchpad tap-to-click true +``` + +如果你看到这样的警告:`(process:6339): dconf-WARNING **: 19:52:21.217: Unable to open /root/.local/share/flatpak/exports/share/dconf/profile/user: Permission denied`。别担心。忽略它就行。 + +[][6] + +这将使你能够轻击登录屏幕。为什么在系统设置中进行更改之前无法使用轻击?这是因为在登录屏幕上,你还没有选择用户名。只有在屏幕上选择用户时才能使用你的帐户。这就是你必须使用用户 `gdm` 并使用它添加正确设置的原因。 + +重新启动 Ubuntu,你会看到现在可以使用轻击来选择你的用户帐户。 + +#### 还原改变 + +如果你因为某些原因不喜欢在 Ubuntu 登录界面轻击,可以还原更改。 + +你必须执行上一节中的所有步骤:切换到 `root`,将 `gdm` 与 X 服务器连接,切换到 `gdm` 用户。但是,你需要运行此命令,而不是上一个命令: + +``` +gsettings set org.gnome.desktop.peripherals.touchpad tap-to-click false +``` + +就是这样。 + +正如我所说,这是一件小事。我的意思是你可以轻松地点击左键而不是轻击。这只是一次单击的问题。但是,当你在几次轻击后被迫使用左键单击时,它会打破操作“连续性”。 + +我希望你喜欢这个快速的小调整。如果你知道其他一些很酷的调整,请与我们分享。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/enable-tap-to-click-on-ubuntu-login-screen/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://wiki.archlinux.org/index.php/GDM +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/07/tap-to-click-on-ubuntu-login.jpg?ssl=1 +[3]: https://itsfoss.com/ubuntu-shortcuts/ +[4]: https://en.wikipedia.org/wiki/X.Org_Server +[5]: https://itsfoss.com/change-password-ubuntu/ +[6]: https://itsfoss.com/change-hostname-ubuntu/ diff --git a/published/201908/20190706 Install NetData Performance Monitoring Tool On Linux.md b/published/201908/20190706 Install NetData Performance Monitoring Tool On Linux.md new file mode 100644 index 0000000000..5a5dc8d958 --- /dev/null +++ b/published/201908/20190706 Install NetData Performance Monitoring Tool On Linux.md @@ -0,0 +1,306 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11173-1.html) +[#]: subject: (Install NetData Performance Monitoring Tool On Linux) +[#]: via: (https://www.ostechnix.com/netdata-real-time-performance-monitoring-tool-linux/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +在 Linux 上安装 NetData 性能监控工具 +====== + +![][1] + +**NetData** 是一个用于系统和应用的分布式实时性能和健康监控工具。它提供了对系统中实时发生的所有事情的全面检测。你可以在高度互动的 Web 仪表板中查看结果。使用 Netdata,你可以清楚地了解现在发生的事情,以及之前系统和应用中发生的事情。你无需成为专家即可在 Linux 系统中部署此工具。NetData 开箱即用,零配置、零依赖。只需安装它然后坐等,之后 NetData 将负责其余部分。 + +它有自己的内置 Web 服务器,以图形形式显示结果。NetData 非常快速高效,安装后可立即开始分析系统性能。它是用 C 编程语言编写的,所以它非常轻量。它占用的单核 CPU 使用率不到 3%,内存占用 10-15MB。我们可以轻松地在任何现有网页上嵌入图表,并且它还有一个插件 API,以便你可以监控任何应用。 + +以下是 Linux 系统中 NetData 的监控列表。 + +* CPU 使用率 +* RAM 使用率 +* 交换内存使用率 +* 内核内存使用率 +* 硬盘及其使用率 +* 网络接口 +* IPtables +* Netfilter +* DDoS 保护 +* 进程 +* 应用 +* NFS 服务器 +* Web 服务器 (Apache 和 Nginx) +* 数据库服务器 (MySQL), +* DHCP 服务器 +* DNS 服务器 +* 电子邮件服务 +* 代理服务器 +* Tomcat +* PHP +* SNP 设备 +* 等等 + +NetData 是自由开源工具,它支持 Linux、FreeBSD 和 Mac OS。 + +### 在 Linux 上安装 NetData + +Netdata 可以安装在任何安装了 Bash 的 Linux 发行版上。 + +最简单的安装 Netdata 的方法是从终端运行以下命令: + +``` +$ bash <(curl -Ss https://my-netdata.io/kickstart-static64.sh) +``` + +这将下载并安装启动和运行 Netdata 所需的一切。 + +有些用户可能不想在没有研究的情况下将某些东西直接注入到 Bash。如果你不喜欢此方法,可以按照以下步骤在系统上安装它。 + +#### 在 Arch Linux 上 + +Arch Linux 默认仓库中提供了最新版本。所以,我们可以使用以下 [pacman][2] 命令安装它: + +``` +$ sudo pacman -S netdata +``` + +#### 在基于 DEB 和基于 RPM 的系统上 + +在基于 DEB (Ubuntu / Debian)或基于 RPM(RHEL / CentOS / Fedora) 系统的默认仓库没有 NetData。我们需要从它的 Git 仓库手动安装 NetData。 + +首先安装所需的依赖项: + +``` +# Debian / Ubuntu +$ sudo apt-get install zlib1g-dev uuid-dev libuv1-dev liblz4-dev libjudy-dev libssl-dev libmnl-dev gcc make git autoconf autoconf-archive autogen automake pkg-config curl + +# Fedora +$ sudo dnf install zlib-devel libuuid-devel libuv-devel lz4-devel Judy-devel openssl-devel libmnl-devel gcc make git autoconf autoconf-archive autogen automake pkgconfig curl findutils + +# CentOS / Red Hat Enterprise Linux +$ sudo yum install epel-release +$ sudo yum install autoconf automake curl gcc git libmnl-devel libuuid-devel openssl-devel libuv-devel lz4-devel Judy-devel lm_sensors make MySQL-python nc pkgconfig python python-psycopg2 PyYAML zlib-devel + +# openSUSE +$ sudo zypper install zlib-devel libuuid-devel libuv-devel liblz4-devel judy-devel openssl-devel libmnl-devel gcc make git autoconf autoconf-archive autogen automake pkgconfig curl findutils +``` + +安装依赖项后,在基于 DEB 或基于 RPM 的系统上安装 NetData,如下所示。 + +Git 克隆 NetData 仓库: + +``` +$ git clone https://github.com/netdata/netdata.git --depth=100 +``` + +上面的命令将在当前工作目录中创建一个名为 `netdata` 的目录。 + +切换到 `netdata` 目录: + +``` +$ cd netdata/ +``` + +最后,使用命令安装并启动 NetData: + +``` +$ sudo ./netdata-installer.sh +``` + +**示例输出:** + +``` +Welcome to netdata! +Nice to see you are giving it a try! + +You are about to build and install netdata to your system. + +It will be installed at these locations: + +- the daemon at /usr/sbin/netdata + - config files at /etc/netdata + - web files at /usr/share/netdata + - plugins at /usr/libexec/netdata + - cache files at /var/cache/netdata + - db files at /var/lib/netdata + - log files at /var/log/netdata + - pid file at /var/run + +This installer allows you to change the installation path. +Press Control-C and run the same command with --help for help. + +Press ENTER to build and install netdata to your system > ## Press ENTER key +``` + +安装完成后,你将在最后看到以下输出: + +``` +------------------------------------------------------------------------------- + +OK. NetData is installed and it is running (listening to *:19999). + +------------------------------------------------------------------------------- + +INFO: Command line options changed. -pidfile, -nd and -ch are deprecated. +If you use custom startup scripts, please run netdata -h to see the +corresponding options and update your scripts. + +Hit http://localhost:19999/ from your browser. + +To stop netdata, just kill it, with: + +killall netdata + +To start it, just run it: + +/usr/sbin/netdata + + +Enjoy! + +Uninstall script generated: ./netdata-uninstaller.sh +``` + +![][3] + +*安装 NetData* + +NetData 已安装并启动。 + +要在其他 Linux 发行版上安装 Netdata,请参阅[官方安装说明页面][4]。 + +### 在防火墙或者路由器上允许 NetData 的默认端口 + +如果你的系统在防火墙或者路由器后面,那么必须允许默认端口 `19999` 以便从任何远程系统访问 NetData 的 web 界面。 + +#### 在 Ubuntu/Debian 中 + +``` +$ sudo ufw allow 19999 +``` + +#### 在 CentOS/RHEL/Fedora 中 + +``` +$ sudo firewall-cmd --permanent --add-port=19999/tcp + +$ sudo firewall-cmd --reload +``` + +### 启动/停止 NetData + +要在使用 Systemd 的系统上启用和启动 Netdata 服务,请运行: + +``` +$ sudo systemctl enable netdata +$ sudo systemctl start netdata +``` + +要停止: + +``` +$ sudo systemctl stop netdata +``` + +要在使用 Init 的系统上启用和启动 Netdata 服务,请运行: + +``` +$ sudo service netdata start +$ sudo chkconfig netdata on +``` + +要停止: + +``` +$ sudo service netdata stop +``` + +### 通过 Web 浏览器访问 NetData + +打开 Web 浏览器,然后打开 `http://127.0.0.1:19999` 或者 `http://localhost:19999/` 或者 `http://ip-address:19999`。你应该看到如下页面。 + +![][5] + +*Netdata 仪表板* + +在仪表板中,你可以找到 Linux 系统的完整统计信息。向下滚动以查看每个部分。 + +你可以随时打开 `http://localhost:19999/netdata.conf` 来下载和/或查看 NetData 默认配置文件。 + +![][6] + +*Netdata 配置文件* + +### 更新 NetData + +在 Arch Linux 中,只需运行以下命令即可更新 NetData。如果仓库中提供了更新版本,那么就会自动安装该版本。 + +``` +$ sudo pacman -Syyu +``` + +在基于 DEB 或 RPM 的系统中,只需进入已克隆它的目录(此例中是 `netdata`)。 + +``` +$ cd netdata +``` + +拉取最新更新: + +``` +$ git pull +``` + +然后,使用命令重新构建并更新它: + +``` +$ sudo ./netdata-installer.sh +``` + +### 卸载 NetData + +进入克隆 NetData 的文件夹。 + +``` +$ cd netdata +``` + +然后,使用命令卸载它: + +``` +$ sudo ./netdata-uninstaller.sh --force +``` + +在 Arch Linux 中,使用以下命令卸载它。 + +``` +$ sudo pacman -Rns netdata +``` + +### 资源 + +* [NetData 网站][7] +* [NetData 的 GitHub 页面][8] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/netdata-real-time-performance-monitoring-tool-linux/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2016/06/Install-netdata-720x340.png +[2]: https://www.ostechnix.com/getting-started-pacman/ +[3]: https://www.ostechnix.com/wp-content/uploads/2016/06/Deepin-Terminal_002-6.png +[4]: https://docs.netdata.cloud/packaging/installer/ +[5]: https://www.ostechnix.com/wp-content/uploads/2016/06/Netdata-dashboard.png +[6]: https://www.ostechnix.com/wp-content/uploads/2016/06/Netdata-config-file.png +[7]: http://netdata.firehol.org/ +[8]: https://github.com/firehol/netdata diff --git a/published/201908/20190709 How to install Elasticsearch and Kibana on Linux.md b/published/201908/20190709 How to install Elasticsearch and Kibana on Linux.md new file mode 100644 index 0000000000..9b0c4c6363 --- /dev/null +++ b/published/201908/20190709 How to install Elasticsearch and Kibana on Linux.md @@ -0,0 +1,183 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11221-1.html) +[#]: subject: (How to install Elasticsearch and Kibana on Linux) +[#]: via: (https://opensource.com/article/19/7/install-elasticsearch-and-kibana-linux) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何在 Linux 上安装 Elasticsearch 和 Kibana +====== + +> 获取我们关于安装两者的简化说明。 + +![5 pengiuns floating on iceburg][1] + +如果你渴望学习基于开源 Lucene 库的著名开源搜索引擎 Elasticsearch,那么没有比在本地安装它更好的方法了。这个过程在 [Elasticsearch 网站][2]中有详细介绍,但如果你是初学者,官方说明就比必要的信息多得多。本文采用一种简化的方法。 + +### 添加 Elasticsearch 仓库 + +首先,将 Elasticsearch 仓库添加到你的系统,以便你可以根据需要安装它并接收更新。如何做取决于你的发行版。在基于 RPM 的系统上,例如 [Fedora][3]、[CentOS] [4]、[Red Hat Enterprise Linux(RHEL)][5] 或 [openSUSE][6],(本文任何地方引用 Fedora 或 RHEL 的也适用于 CentOS 和 openSUSE)在 `/etc/yum.repos.d/` 中创建一个名为 `elasticsearch.repo` 的仓库描述文件: + +``` +$ cat << EOF | sudo tee /etc/yum.repos.d/elasticsearch.repo +[elasticsearch-7.x] +name=Elasticsearch repository for 7.x packages +baseurl=https://artifacts.elastic.co/packages/oss-7.x/yum +gpgcheck=1 +gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch +enabled=1 +autorefresh=1 +type=rpm-md +EOF +``` + +在 Ubuntu 或 Debian 上,不要使用 `add-apt-repository` 工具。由于它自身默认的和 Elasticsearch 仓库提供的不匹配而导致错误。相反,设置这个: + +``` +$ echo "deb https://artifacts.elastic.co/packages/oss-7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list +``` + +在你从该仓库安装之前,导入 GPG 公钥,然后更新: + +``` +$ sudo apt-key adv --keyserver \ +hkp://keyserver.ubuntu.com:80 \ +--recv D27D666CD88E42B4 +$ sudo apt update +``` + +此存储库仅包含 Elasticsearch 的开源功能,在 [Apache 许可证][7]下发布,没有提供订阅版本的额外功能。如果你需要仅限订阅的功能(这些功能是**并不**开源),那么 `baseurl` 必须设置为: + +``` +baseurl=https://artifacts.elastic.co/packages/7.x/yum +``` + +### 安装 Elasticsearch + +你需要安装的软件包的名称取决于你使用的是开源版本还是订阅版本。本文使用开源版本,包名最后有 `-oss` 后缀。如果包名后没有 `-oss`,那么表示你请求的是仅限订阅版本。 + +如果你创建了订阅版本的仓库却尝试安装开源版本,那么就会收到“非指定”的错误。如果你创建了一个开源版本仓库却没有将 `-oss` 添加到包名后,那么你也会收到错误。 + +使用包管理器安装 Elasticsearch。例如,在 Fedora、CentOS 或 RHEL 上运行以下命令: + +``` +$ sudo dnf install elasticsearch-oss +``` + +在 Ubuntu 或 Debian 上,运行: + +``` +$ sudo apt install elasticsearch-oss +``` + +如果你在安装 Elasticsearch 时遇到错误,那么你可能安装的是错误的软件包。如果你想如本文这样使用开源包,那么请确保使用正确的 apt 仓库或在 Yum 配置正确的 `baseurl`。 + +### 启动并启用 Elasticsearch + +安装 Elasticsearch 后,你必须启动并启用它: + +``` +$ sudo systemctl daemon-reload +$ sudo systemctl enable --now elasticsearch.service +``` + +要确认 Elasticsearch 在其默认端口 9200 上运行,请在 Web 浏览器中打开 `localhost:9200`。你可以使用 GUI 浏览器,也可以在终端中执行此操作: + + +``` +$ curl localhost:9200 +{ + + "name" : "fedora30", + "cluster_name" : "elasticsearch", + "cluster_uuid" : "OqSbb16NQB2M0ysynnX1hA", + "version" : { + "number" : "7.2.0", + "build_flavor" : "oss", + "build_type" : "rpm", + "build_hash" : "508c38a", + "build_date" : "2019-06-20T15:54:18.811730Z", + "build_snapshot" : false, + "lucene_version" : "8.0.0", + "minimum_wire_compatibility_version" : "6.8.0", + "minimum_index_compatibility_version" : "6.0.0-beta1" + }, + "tagline" : "You Know, for Search" +} +``` + +### 安装 Kibana + +Kibana 是 Elasticsearch 数据可视化的图形界面。它包含在 Elasticsearch 仓库,因此你可以使用包管理器进行安装。与 Elasticsearch 本身一样,如果你使用的是 Elasticsearch 的开源版本,那么必须将 `-oss` 放到包名最后,订阅版本则不用(两者安装需要匹配): + + +``` +$ sudo dnf install kibana-oss +``` + +在 Ubuntu 或 Debian 上: + +``` +$ sudo apt install kibana-oss +``` + +Kibana 在端口 5601 上运行,因此打开图形化 Web 浏览器并进入 `localhost:5601` 来开始使用 Kibana,如下所示: + +![Kibana running in Firefox.][8] + +### 故障排除 + +如果在安装 Elasticsearch 时出现错误,请尝试手动安装 Java 环境。在 Fedora、CentOS 和 RHEL 上: + +``` +$ sudo dnf install java-openjdk-devel java-openjdk +``` + +在 Ubuntu 上: + +``` +$ sudo apt install default-jdk +``` + +如果所有其他方法都失败,请尝试直接从 Elasticsearch 服务器安装 Elasticsearch RPM: + +``` +$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.2.0-x86_64.rpm{,.sha512} +$ shasum -a 512 -c elasticsearch-oss-7.2.0-x86_64.rpm.sha512 && sudo rpm --install elasticsearch-oss-7.2.0-x86_64.rpm +``` + +在 Ubuntu 或 Debian 上,请使用 DEB 包。 + +如果你无法使用 Web 浏览器访问 Elasticsearch 或 Kibana,那么可能是你的防火墙阻止了这些端口。你可以通过调整防火墙设置来允许这些端口上的流量。例如,如果你运行的是 `firewalld`(Fedora 和 RHEL 上的默认防火墙,并且可以在 Debian 和 Ubuntu 上安装),那么你可以使用 `firewall-cmd`: + +``` +$ sudo firewall-cmd --add-port=9200/tcp --permanent +$ sudo firewall-cmd --add-port=5601/tcp --permanent +$ sudo firewall-cmd --reload +``` + +设置完成了,你可以关注我们接下来的 Elasticsearch 和 Kibana 安装文章。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/install-elasticsearch-and-kibana-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux31x_cc.png?itok=Pvim4U-B (5 pengiuns floating on iceburg) +[2]: https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html +[3]: https://getfedora.org +[4]: https://www.centos.org +[5]: https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux +[6]: https://www.opensuse.org +[7]: http://www.apache.org/licenses/ +[8]: https://opensource.com/sites/default/files/uploads/kibana.jpg (Kibana running in Firefox.) diff --git a/published/201908/20190711 What is a golden image.md b/published/201908/20190711 What is a golden image.md new file mode 100644 index 0000000000..df526a9b36 --- /dev/null +++ b/published/201908/20190711 What is a golden image.md @@ -0,0 +1,77 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11202-1.html) +[#]: subject: (What is a golden image?) +[#]: via: (https://opensource.com/article/19/7/what-golden-image) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +什么是黄金镜像? +====== + +> 正在开发一个将广泛分发的项目吗?了解一下黄金镜像吧,以便在出现问题时轻松恢复到“完美”状态。 + +![](https://img.linux.net.cn/data/attachment/album/201908/08/184231ivv745lukchbrhul.jpg) + +如果你正在从事于质量保证、系统管理或媒体制作(没想到吧),你可能听说过正式版gold master这一术语的某些变体,如黄金镜像golden image母片master image等等。这个术语已经进入了每个参与创建**完美**模具的人的集体意识,然后从该模具中产生许多复制品。母片或黄金镜像就是:一种虚拟模具,你可以从中打造可分发的模型。 + +在媒体制作中,这就是所有人努力开发母片的过程。这个最终产品是独一无二的。它看起来和听起来像是可以看和听的最好的电影或专辑(或其他任何东西)。可以制作和压缩该母片的副本并发送给急切的公众。 + +在软件中,与该术语相关联的也是类似的意思。一旦软件经过编译和一再测试,完美的构建成果就会被声明为**黄金版本**,不允许对它进一步更改,并且所有可分发的副本都是从此母片生成的(当软件是用 CD 或 DVD 分发时,这实际上就是母盘)。 + +在系统管理中,你可能会遇到你的机构所选的操作系统的黄金镜像,其中的重要设置已经就绪,如安装好的虚拟专用网络(VPN)证书、设置好的电子邮件收件服务器的邮件客户端等等。同样,你可能也会在虚拟机(VM)的世界中听到这个术语,其中精心配置了虚拟驱动器的黄金镜像是所有克隆的新虚拟机的源头。 + +### GNOME Boxes + +正式版的概念很简单,但往往忽视将其付诸实践。有时,你的团队很高兴能够达成他们的目标,但没有人停下来考虑将这些成就指定为权威版本。在其他时候,没有简单的机制来做到这一点。 + +黄金镜像等同于部分历史的保存和提前备份计划。一旦你制作了一个完美的模型,无论你正在努力做什么,你都应该为自己保留这项工作,因为它不仅标志着你的进步,而且如果你继续工作时遇到问题,它就会成为一个后备。 + +[GNOME Boxes][2],是随 GNOME 桌面一起提供的虚拟化平台,可以用作简单的演示用途。如果你从未使用过 GNOME Boxes,你可以在 Alan Formy-Duval 的文章 [GNOME Boxes 入门][3]中学习它的基础知识。 + +想象一下,你使用 GNOME Boxes 创建虚拟机,然后将操作系统安装到该 VM 中。现在,你想要制作一个黄金镜像。GNOME Boxes 已经率先摄取了你的安装快照,可以作为更多的操作系统安装的黄金镜像。 + +打开 GNOME Boxes 并在仪表板视图中,右键单击任何虚拟机,然后选择**属性**。在**属性**窗口中,选择**快照**选项卡。由 GNOME Boxes 自动创建的第一个快照是“Just Installed”。顾名思义,这是你最初安装到虚拟机上的操作系统。 + +![The Just Installed snapshot, or initial golden image, in GNOME Boxes.][4] + +如果你的虚拟机变成了你不想要的状态,你可以随时恢复为“Just Installed”镜像。 + +当然,如果你已经为自己调整了环境,那么在安装后恢复操作系统将是一个极大的工程。这就是为什么虚拟机的常见工作流程是:首先安装操作系统,然后根据你的要求或偏好修改它,然后拍摄快照,将该快照声明为配置好的黄金镜像。例如,如果你使用虚拟机进行 [Flatpak][5] 打包,那么在初始安装之后,你可以添加软件和 Flatpak 开发工具,构建工作环境,然后拍摄快照。创建快照后,你可以重命名该虚拟机以指示其真实用途。 + +要重命名虚拟机,请在仪表板视图中右键单击其缩略图,然后选择**属性**。在**属性**窗口中,输入新名称: + +![Renaming your VM image in GNOME Boxes.][6] + +要克隆你的黄金映像,请右键单击 GNOME Boxes 界面中的虚拟机,然后选择**克隆**。 + +![Cloning your golden image in GNOME Boxes.][7] + +你现在可以从黄金映像的最新快照中克隆了。 + +### 黄金镜像 + +很少有学科无法从黄金镜像中受益。无论你是在 [Git][8] 中标记版本、在 Boxes 中拍摄快照、出版原型黑胶唱片、打印书籍以进行审核、设计用于批量生产的丝网印刷、还是制作文字模具,到处都是各种原型。这只是现代技术让我们人类更聪明而不是更努力的另一种方式,因此为你的项目制作一个黄金镜像,并根据需要随时生成克隆吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/what-golden-image + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/origami_star_gold_best_top.jpg?itok=aEc0eutt (Gold star) +[2]: https://wiki.gnome.org/Apps/Boxes +[3]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[4]: https://opensource.com/sites/default/files/uploads/snapshots.jpg (The Just Installed snapshot, or initial golden image.) +[5]: https://opensource.com/business/16/8/flatpak +[6]: https://opensource.com/sites/default/files/uploads/boxes-rename_0.jpg (Renaming your virtual machine in GNOME Boxes.) +[7]: https://opensource.com/sites/default/files/uploads/boxes-clone.jpg (Cloning your golden image in GNOME Boxes.) +[8]: https://git-scm.com diff --git a/published/201908/20190715 Understanding software design patterns.md b/published/201908/20190715 Understanding software design patterns.md new file mode 100644 index 0000000000..0347ad755b --- /dev/null +++ b/published/201908/20190715 Understanding software design patterns.md @@ -0,0 +1,349 @@ +[#]: collector: (lujun9972) +[#]: translator: (arrowfeng) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11208-1.html) +[#]: subject: (Understanding software design patterns) +[#]: via: (https://opensource.com/article/19/7/understanding-software-design-patterns) +[#]: author: (Bryant Son https://opensource.com/users/brsonhttps://opensource.com/users/erezhttps://opensource.com/users/brson) + +理解软件设计模式 +====== +> 设计模式可以帮助消除冗余代码。学习如何利用 Java 使用单例模式、工厂模式和观察者模式。 + +![](https://img.linux.net.cn/data/attachment/album/201908/10/080849ygyqtrw88f2qtzk4.jpg) + +如果你是一名正在致力于计算机科学或者相关学科的程序员或者学生,很快,你将会遇到一条术语 “软件设计模式software design pattern”。根据维基百科,“*[软件设计模式][2]是在平常的软件设计工作中所遭遇的问题的一种通用的、可重复使用的解决方案*”。我对该定义的理解是:当在从事于一个编码项目时,你经常会思考,“嗯,这里貌似是冗余代码,我觉得是否能改变这些代码使之更灵活和便于修改?”因此,你会开始考虑怎样分割那些保持不变的内容和需要经常改变的内容。 + +> **设计模式**是一种通过分割那些保持不变的部分和经常变化的部分,让你的代码更容易修改的方法。 + +不出意外的话,每个从事编程项目的人都可能会有同样的思考。特别是那些工业级别的项目,在那里通常工作着数十甚至数百名开发者;协作过程表明必须有一些标准和规则来使代码更加优雅并适应变化。这就是为什么我们有了 [面向对象编程][3](OOP)和 [软件框架工具][4]。设计模式有点类似于 OOP,但它通过将变化视为自然开发过程的一部分而进一步发展。基本上,设计模式利用了一些 OOP 的思想,比如抽象和接口,但是专注于改变的过程。 + +当你开始开发项目时,你经常会听到这样一个术语*重构*,它意味着*通过改变代码使它变得更优雅和可复用*;这就是设计模式耀眼的地方。当你处理现有代码时(无论是由其他人构建还是你自己过去构建的),了解设计模式可以帮助你以不同的方式看待事物,你将发现问题以及改进代码的方法。 + +有很多种设计模式,其中单例模式、工厂模式和观察者模式三种最受欢迎,在这篇文章中我将会一一介绍它们。 + +### 如何遵循本指南 + +无论你是一位有经验的编程工作者还是一名刚刚接触的新手,我想让这篇教程让每个人都很容易理解。设计模式概念并不容易理解,减少开始旅程时的学习曲线始终是首要任务。因此,除了这篇带有图表和代码片段的文章外,我还创建了一个 [GitHub 仓库][5],你可以克隆仓库并在你的电脑上运行这些代码来实现这三种设计模式。你也可以观看我创建的 [YouTube视频][6]。 + +#### 必要条件 + +如果你只是想了解一般的设计模式思想,则无需克隆示例项目或安装任何工具。但是,如果要运行示例代码,你需要安装以下工具: + + * **Java 开发套件(JDK)**:我强烈建议使用 [OpenJDK][7]。 + * **Apache Maven**:这个简单的项目使用 [Apache Maven][8] 构建;好的是许多 IDE 自带了Maven。 + * **交互式开发编辑器(IDE)**:我使用 [社区版 IntelliJ][9],但是你也可以使用 [Eclipse IDE][10] 或者其他你喜欢的 Java IDE。 + * **Git**:如果你想克隆这个工程,你需要 [Git][11] 客户端。 + +安装好 Git 后运行下列命令克隆这个工程: + +``` +git clone https://github.com/bryantson/OpensourceDotComDemos.git +``` + +然后在你喜欢的 IDE 中,你可以将 TopDesignPatterns 仓库中的代码作为 Apache Maven 项目导入。 + +我使用的是 Java,但你也可以使用支持[抽象原则][12]的任何编程语言来实现设计模式。 + +### 单例模式:避免每次创建一个对象 + +[单例模式][13]singleton pattern是非常流行的设计模式,它的实现相对来说很简单,因为你只需要一个类。然而,许多开发人员争论单例设计模式的是否利大于弊,因为它缺乏明显的好处并且容易被滥用。很少有开发人员直接实现单例;相反,像 Spring Framework 和 Google Guice 等编程框架内置了单例设计模式的特性。 + +但是了解单例模式仍然有巨大的用处。单例模式确保一个类仅创建一次且提供了一个对它的全局访问点。 + +> **单例模式**:确保仅创建一个实例且避免在同一个项目中创建多个实例。 + +下面这幅图展示了典型的类对象创建过程。当客户端请求创建一个对象时,构造函数会创建或者实例化一个对象并调用方法返回这个类给调用者。但是每次请求一个对象都会发生这样的情况:构造函数被调用,一个新的对象被创建并且它返回了一个独一无二的对象。我猜面向对象语言的创建者有每次都创建一个新对象的理由,但是单例过程的支持者说这是冗余的且浪费资源。 + +![Normal class instantiation][14] + +下面这幅图使用单例模式创建对象。这里,构造函数仅当对象首次通过调用预先设计好的 `getInstance()` 方法时才会被调用。这通常通过检查该值是否为 `null` 来完成,并且这个对象被作为私有变量保存在单例类的内部。下次 `getInstance()` 被调用时,这个类会返回第一次被创建的对象。而没有新的对象产生;它只是返回旧的那一个。 + +![Singleton pattern instantiation][15] + +下面这段代码展示了创建单例模式最简单的方法: + +``` +package org.opensource.demo.singleton; + +public class OpensourceSingleton { + + private static OpensourceSingleton uniqueInstance; + + private OpensourceSingleton() { + } + + public static OpensourceSingleton getInstance() { + if (uniqueInstance == null) { + uniqueInstance = new OpensourceSingleton(); + } + return uniqueInstance; + } + +} +``` + +在调用方,这里展示了如何调用单例类来获取对象: + +``` +Opensource newObject = Opensource.getInstance(); +``` + +这段代码很好的验证了单例模式的思想: + + 1. 当 `getInstance()` 被调用时,它通过检查 `null` 值来检查对象是否已经被创建。 + 2. 如果值为 `null`,它会创建一个新对象并把它保存到私有域,返回这个对象给调用者。否则直接返回之前被创建的对象。 + +单例模式实现的主要问题是它忽略了并行进程。当多个进程使用线程同时访问资源时,这个问题就产生了。对于这种情况有对应的解决方案,它被称为*双重检查锁*,用于多线程安全,如下所示: + +``` +package org.opensource.demo.singleton; + +public class ImprovedOpensourceSingleton { + + private volatile static ImprovedOpensourceSingleton uniqueInstance; + + private ImprovedOpensourceSingleton() {} + + public static ImprovedOpensourceSingleton getInstance() { + if (uniqueInstance == null) { + synchronized (ImprovedOpensourceSingleton.class) { + if (uniqueInstance == null) { + uniqueInstance = new ImprovedOpensourceSingleton(); + } + } + } + return uniqueInstance; + } + +} +``` + +再强调一下前面的观点,确保只有在你认为这是一个安全的选择时才直接实现你的单例模式。最好的方法是通过使用一个制作精良的编程框架来利用单例功能。 + +### 工厂模式:将对象创建委派给工厂类以隐藏创建逻辑 + +[工厂模式][16]factory pattern是另一种众所周知的设计模式,但是有一小点复杂。实现工厂模式的方法有很多,而下列的代码示例为最简单的实现方式。为了创建对象,工厂模式定义了一个接口,让它的子类去决定实例化哪一个类。 + +> **工厂模式**:将对象创建委派给工厂类,因此它能隐藏创建逻辑。 + +下列的图片展示了最简单的工厂模式是如何实现的。 + +![Factory pattern][17] + +客户端请求工厂类创建类型为 x 的某个对象,而不是客户端直接调用对象创建。根据其类型,工厂模式决定要创建和返回的对象。 + +在下列代码示例中,`OpensourceFactory` 是工厂类实现,它从调用者那里获取*类型*并根据该输入值决定要创建和返回的对象: + +``` +package org.opensource.demo.factory; + +public class OpensourceFactory { + + public OpensourceJVMServers getServerByVendor(String name) { + if(name.equals("Apache")) { + return new Tomcat(); + } + else if(name.equals("Eclipse")) { + return new Jetty(); + } + else if (name.equals("RedHat")) { + return new WildFly(); + } + else { + return null; + } + } +} +``` + +`OpenSourceJVMServer` 是一个 100% 的抽象类(即接口类),它指示要实现的是什么,而不是怎样实现: + +``` +package org.opensource.demo.factory; + +public interface OpensourceJVMServers { + public void startServer(); + public void stopServer(); + public String getName(); +} +``` + +这是一个 `OpensourceJVMServers` 类的实现示例。当 `RedHat` 被作为类型传递给工厂类,`WildFly` 服务器将被创建: + +``` +package org.opensource.demo.factory; + +public class WildFly implements OpensourceJVMServers { + public void startServer() { + System.out.println("Starting WildFly Server..."); + } + + public void stopServer() { + System.out.println("Shutting Down WildFly Server..."); + } + + public String getName() { + return "WildFly"; + } +} +``` + +### 观察者模式:订阅主题并获取相关更新的通知 + +最后是[观察者模式][20]observer pattern。像单例模式那样,很少有专业的程序员直接实现观察者模式。但是,许多消息队列和数据服务实现都借用了观察者模式的概念。观察者模式在对象之间定义了一对多的依赖关系,当一个对象的状态发生改变时,所有依赖它的对象都将被自动地通知和更新。 + +> **观察者模式**:如果有更新,那么订阅了该话题/主题的客户端将被通知。 + +理解观察者模式的最简单方法是想象一个邮件列表,你可以在其中订阅任何主题,无论是开源、技术、名人、烹饪还是您感兴趣的任何其他内容。每个主题维护者一个它的订阅者列表,在观察者模式中它们相当于观察者。当某一个主题更新时,它所有的订阅者(观察者)都将被通知这次改变。并且订阅者总是能取消某一个主题的订阅。 + +如下图所示,客户端可以订阅不同的主题并添加观察者以获得最新信息的通知。因为观察者不断的监听着这个主题,这个观察者会通知客户端任何发生的改变。 + +![Observer pattern][21] + +让我们来看看观察者模式的代码示例,从主题/话题类开始: + +``` +package org.opensource.demo.observer; + +public interface Topic { + + public void addObserver(Observer observer); + public void deleteObserver(Observer observer); + public void notifyObservers(); +} +``` + +这段代码描述了一个为不同的主题去实现已定义方法的接口。注意一个观察者如何被添加、移除和通知的。 + +这是一个主题的实现示例: + +``` +package org.opensource.demo.observer; + +import java.util.List; +import java.util.ArrayList; + +public class Conference implements Topic { + private List listObservers; + private int totalAttendees; + private int totalSpeakers; + private String nameEvent; + + public Conference() { + listObservers = new ArrayList(); + } + + public void addObserver(Observer observer) { + listObservers.add(observer); + } + + public void deleteObserver(Observer observer) { + int i = listObservers.indexOf(observer); + if (i >= 0) { + listObservers.remove(i); + } + } + + public void notifyObservers() { + for (int i=0, nObservers = listObservers.size(); i < nObservers; ++ i) { + Observer observer = listObservers.get(i); + observer.update(totalAttendees,totalSpeakers,nameEvent); + } + } + + public void setConferenceDetails(int totalAttendees, int totalSpeakers, String nameEvent) { + this.totalAttendees = totalAttendees; + this.totalSpeakers = totalSpeakers; + this.nameEvent = nameEvent; + notifyObservers(); + } +} +``` + +这段代码定义了一个特定主题的实现。当发生改变时,这个实现调用它自己的方法。注意这将获取观察者的数量,它以列表方式存储,并且可以通知和维护观察者。 + +这是一个观察者类: + +``` +package org.opensource.demo.observer; + +public interface Observer { + public void update(int totalAttendees, int totalSpeakers, String nameEvent); +} +``` + +这个类定义了一个接口,不同的观察者可以实现该接口以执行特定的操作。 + +例如,实现了该接口的观察者可以在会议上打印出与会者和发言人的数量: + +``` +package org.opensource.demo.observer; + +public class MonitorConferenceAttendees implements Observer { + private int totalAttendees; + private int totalSpeakers; + private String nameEvent; + private Topic topic; + + public MonitorConferenceAttendees(Topic topic) { + this.topic = topic; + topic.addObserver(this); + } + + public void update(int totalAttendees, int totalSpeakers, String nameEvent) { + this.totalAttendees = totalAttendees; + this.totalSpeakers = totalSpeakers; + this.nameEvent = nameEvent; + printConferenceInfo(); + } + + public void printConferenceInfo() { + System.out.println(this.nameEvent + " has " + totalSpeakers + " speakers and " + totalAttendees + " attendees"); + } +} +``` + +### 接下来 + +现在你已经阅读了这篇对于设计模式的介绍引导,你还可以去寻求了解其他设计模式,例如外观模式,模版模式和装饰器模式。也有一些并发和分布式系统的设计模式如断路器模式和锚定模式。 + +可是,我相信最好的磨砺你的技能的方式首先是通过在你的业余项目或者练习中实现这些设计模式。你甚至可以开始考虑如何在实际项目中应用这些设计模式。接下来,我强烈建议你查看 OOP 的 [SOLID 原则][23]。之后,你就准备好了解其他设计模式。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/understanding-software-design-patterns + +作者:[Bryant Son][a] +选题:[lujun9972][b] +译者:[arrowfeng](https://github.com/arrowfeng) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/brsonhttps://opensource.com/users/erezhttps://opensource.com/users/brson +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003601_05_mech_osyearbook2016_cloud_cc.png?itok=XSV7yR9e (clouds in the sky with blue pattern) +[2]: https://en.wikipedia.org/wiki/Software_design_pattern +[3]: https://en.wikipedia.org/wiki/Object-oriented_programming +[4]: https://en.wikipedia.org/wiki/Software_framework +[5]: https://github.com/bryantson/OpensourceDotComDemos/tree/master/TopDesignPatterns +[6]: https://www.youtube.com/watch?v=VlBXYtLI7kE&feature=youtu.be +[7]: https://openjdk.java.net/ +[8]: https://maven.apache.org/ +[9]: https://www.jetbrains.com/idea/download/#section=mac +[10]: https://www.eclipse.org/ide/ +[11]: https://git-scm.com/ +[12]: https://en.wikipedia.org/wiki/Abstraction_principle_(computer_programming) +[13]: https://en.wikipedia.org/wiki/Singleton_pattern +[14]: https://opensource.com/sites/default/files/uploads/designpatterns1_normalclassinstantiation.jpg (Normal class instantiation) +[15]: https://opensource.com/sites/default/files/uploads/designpatterns2_singletonpattern.jpg (Singleton pattern instantiation) +[16]: https://en.wikipedia.org/wiki/Factory_method_pattern +[17]: https://opensource.com/sites/default/files/uploads/designpatterns3_factorypattern.jpg (Factory pattern) +[18]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[19]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[20]: https://en.wikipedia.org/wiki/Observer_pattern +[21]: https://opensource.com/sites/default/files/uploads/designpatterns4_observerpattern.jpg (Observer pattern) +[22]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+observer +[23]: https://en.wikipedia.org/wiki/SOLID diff --git a/published/201908/20190715 What is POSIX- Richard Stallman explains.md b/published/201908/20190715 What is POSIX- Richard Stallman explains.md new file mode 100644 index 0000000000..916fb50757 --- /dev/null +++ b/published/201908/20190715 What is POSIX- Richard Stallman explains.md @@ -0,0 +1,190 @@ +[#]: collector: (lujun9972) +[#]: translator: (martin2011qi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11222-1.html) +[#]: subject: (What is POSIX? Richard Stallman explains) +[#]: via: (https://opensource.com/article/19/7/what-posix-richard-stallman-explains) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +POSIX 是什么?让我们听听 Richard Stallman 的诠释 +====== + +> 从计算机自由先驱的口中探寻操作系统兼容性标准背后的本质。 + +![](https://img.linux.net.cn/data/attachment/album/201908/13/231737robbwoss7p3p7jwo.jpg) + +[POSIX][2] 是什么?为什么如此重要?你可能在很多的技术类文章中看到这个术语,但往往会在探寻其本质时迷失在技术初始主义techno-initialisms的海洋或是以 X 结尾的行话jargon-that-ends-in-X中。我给 [Richard Stallman][3] 博士(在黑客圈里面常称之为 RMS)发了邮件以探寻这个术语的起源及其背后的概念。 + +Richard Stallman 认为用 “开源” 和 “闭源” 来归类软件是一种错误的方法。Stallman 将程序分类为 尊重自由的freedom-respecting(“自由free” 或 “自由(西语)libre”)和 践踏自由的freedom-trampling(“非自由non-free” 或 “专有proprietary”)。开源讨论通常会为了(用户)实际得到的优势/便利advantages考虑去鼓励某些做法,而非作为道德层面上的约束。 + +Stallman 在由其本人于 1984 年发起的自由软件运动The free software movement表明,不仅仅是这些 优势/便利advantages 受到了威胁。计算机的用户 理应得到deserve 计算机的控制权,因此拒绝被用户控制的程序即是 非正义injustice,理应被拒绝rejected排斥eliminated。对于用户的控制权,程序应当给予用户 [四项基本自由][4]: + + * 自由度 0:无论用户出于何种目的,必须可以按照用户意愿,自由地运行该软件。 + * 自由度 1:用户可以自由地学习并修改该软件,以便按照自己的意愿进行计算。作为前提,用户必须可以访问到该软件的源代码。 + * 自由度 2:用户可以自由地分发该软件的副本,以便可以帮助他人。 + * 自由度 3:用户可以自由地分发该软件修改后的副本。借此,你可以让整个社区受益于你的改进。作为前提,用户必须可以访问到该软件的源代码。 + +### 关于 POSIX + +**Seth:** POSIX 标准是由 [IEEE][5] 发布,用于描述 “可移植操作系统portable operating system” 的文档。只要开发人员编写符合此描述的程序,他们生产的便是符合 POSIX 的程序。在科技行业,我们称之为 “规范specification” 或将其简写为 “spec”。就技术用语而言,这是可以理解的,但我们不禁要问是什么使操作系统 “可移植”? + +**RMS:** 我认为是接口interface应该(在不同系统之间)是可移植的,而非任何一种*系统*。实际上,内部构造不同的各种系统都支持部分的 POSIX 接口规范。 + +**Seth:** 因此,如果两个系统皆具有符合 POSIX 的程序,那么它们便可以彼此假设,从而知道如何相互 “交谈”。我了解到 “POSIX” 这个简称是你想出来的。那你是怎么想出来的呢?它是如何就被 IEEE 采纳了呢? + +**RMS:** IEEE 已经完成了规范的开发,但还没为其想好简练的名称。标题类似是 “可移植操作系统接口”,虽然我已记不清确切的单词。委员会倾向于将 “IEEEIX” 作为简称。而我认为那不太好。发音有点怪 - 听起来像恐怖的尖叫,“Ayeee!” - 所以我觉得人们反而会倾向于称之为 “Unix”。 + +但是,由于 [GNU 并不是 Unix][6]GNU's Not Unix,并且它打算取代之,我不希望人们将 GNU 称为 “Unix 系统”。因此,我提出了人们可能会实际使用的简称。那个时候也没有什么灵感,我就用了一个并不是非常聪明的方式创造了这个简称:我使用了 “可移植操作系统portable operating system” 的首字母缩写,并在末尾添加了 “ix” 作为简称。IEEE 也欣然接受了。 + +**Seth:** POSIX 缩写中的 “操作系统” 是仅涉及 Unix 和类 Unix 的系统(如 GNU)呢?还是意图包含所有操作系统? + +**RMS:** 术语 “操作系统” 抽象地说,涵盖了完全不像 Unix 的系统、完全和 POSIX 规范无关的系统。但是,POSIX 规范适用于大量类 Unix 系统;也只有这样的系统才适合 POSIX 规范。 + +**Seth:** 你是否参与审核或更新当前版本的 POSIX 标准? + +**RMS:** 现在不了。 + +**Seth:** GNU Autotools 工具链可以使应用程序更容易移植,至少在构建和安装时如此。所以可以认为 Autotools 是构建可移植基础设施的重要一环吗? + +**RMS:** 是的,因为即使在遵循 POSIX 的系统中,也存在着诸多差异。而 Autotools 可以使程序更容易适应这些差异。顺带一提,如果有人想助力 Autotools 的开发,可以发邮件联系我。 + +**Seth:** 我想,当 GNU 刚刚开始让人们意识到一个非 Unix 的系统可以从专有的技术中解放出来的时候,关于自由软件如何协作方面,这其间一定存在一些空白区域吧。 + +**RMS:** 我不认为有任何空白或不确定性。我只是照着 BSD 的接口写而已。 + +**Seth:** 一些 GNU 应用程序符合 POSIX 标准,而另一些 GNU 应用程序的 GNU 特定的功能,要么不在 POSIX 规范中,要么缺少该规范要求的功能。对于 GNU 应用程序 POSIX 合规性有多重要? + +**RMS:** 遵循标准对于利于用户的程度很重要。我们不将标准视为权威,而是且将其作为可能有用的指南来遵循。因此,我们谈论的是遵循following标准而不是“遵守complying”。可以参考 GNU 编码标准GNU Coding Standards中的 [非 GNU 标准][7] 段落。 + +我们努力在大多数问题上与标准兼容,因为在大多数的问题上这最有利于用户。但也偶有例外。 + +例如,POSIX 指定某些实用程序以 512 字节为单位测量磁盘空间。我要求委员会将其改为 1K,但被拒绝了,说是有个官僚主义的规则bureaucratic rule强迫选用 512。我不记得有多少人试图争辩说,用户会对这个决定感到满意的。 + +由于 GNU 在用户的自由freedom之后的第二优先级,是用户的便利convenience,我们使 GNU 程序以默认 1K 为单位按块测量磁盘空间。 + +然而,为了防止竞争对手利用这点给 GNU 安上 “不合规noncompliant” 的骂名,我们实现了遵循 POSIX 和 ISO C 的可选模式,这种妥协着实可笑。想要遵循 POSIX,只需设置环境变量 `POSIXLY_CORRECT`,即可使程序符合 POSIX 以 512 字节为单位列出磁盘空间。如果有人知道实际使用 `POSIXLY_CORRECT` 或者 GCC 中对应的 `--pedantic` 会为某些用户提供什么实际好处的话,请务必告诉我。 + +**Seth:** 符合 POSIX 标准的自由软件项目是否更容易移植到其他类 Unix 系统? + +**RMS:** 我认为是这样,但自上世纪 80 年代开始,我决定不再把时间浪费在将软件移植到 GNU 以外的系统上。我开始专注于推进 GNU 系统,使其不必使用任何非自由软件。至于将 GNU 程序移植到非类 GNU 系统就留给想在其他系统上运行它们的人们了。 + +**Seth:** POSIX 对于软件的自由很重要吗? + +**RMS:** 本质上说,(遵不遵循 POSIX)其实没有任何区别。但是,POSIX 和 ISO C 的标准化确实使 GNU 系统更容易迁移,这有助于我们更快地实现从非自由软件中解放用户的目标。这个目标于上世纪 90 年代早期达成,当时Linux成为自由软件,同时也填补了 GNU 中内核的空白。 + +### POSIX 采纳 GNU 的创新 + +我还问过 Stallman 博士,是否有任何 GNU 特定的创新或惯例后来被采纳为 POSIX 标准。他无法回想起具体的例子,但友好地代我向几位开发者发了邮件。 + +开发者 Giacomo Catenazzi,James Youngman,Eric Blake,Arnold Robbins 和 Joshua Judson Rosen 对以前的 POSIX 迭代以及仍在进行中的 POSIX 迭代做出了回应。POSIX 是一个 “活的living” 标准,因此会不断被行业专业人士更新和评审,许多从事 GNU 项目的开发人员提出了对 GNU 特性的包含。 + +为了回顾这些有趣的历史,接下来会罗列一些已经融入 POSIX 的流行的 GNU 特性。 + +#### Make + +一些 GNU **Make** 的特性已经被 POSIX 的 `make` 定义所采用。相关的 [规范][8] 提供了从现有实现中借来的特性的详细归因。 + +#### Diff 和 patch + +[diff][9] 和 [patch][10] 命令都直接从这些工具的 GNU 版本中引进了 `-u` 和 `-U` 选项。 + +#### C 库 + +POSIX 采用了 GNU C 库 **glibc** 的许多特性。血统Lineage一时已难以追溯,但 James Youngman 如是写道: + +> “我非常确定 GCC 首创了许多 ISO C 的特性。例如,**_Noreturn** 是 C11 中的新特性,但 GCC-1.35 便具有此功能(使用 `volatile` 作为声明函数的修饰符)。另外尽管我不确定,GCC-1.35 支持的可变长度数组似乎与现代 C 中的(柔性数组conformant array)非常相似。” + +Giacomo Catenazzi 援引 Open Group 的 [strftime][11] 文章,并指出其归因:“这是基于某版本 GNU libc 的 `strftime()` 的特性。” + +Eric Blake 指出,对于 `getline()` 和各种基于语言环境的 `*_l()` 函数,GNU 绝对是这方面的先驱。 + +Joshua Judson Rosen 补充道,他清楚地记得,在全然不同的操作系统的代码中奇怪地目睹了熟悉的 GNU 式的行为后,对 `getline()` 函数的采用给他留下了深刻的印象。 + +“等等……那不是 GNU 特有的吗?哦,显然已经不再是了。” + +Rosen 向我指出了 [getline 手册页][12] 中写道: + +> `getline()` 和 `getdelim()` 最初都是 GNU 扩展。在 POSIX.1-2008 中被标准化。 + +Eric Blake 向我发送了一份其他扩展的列表,这些扩展可能会在下一个 POSIX 修订版中添加(代号为 Issue 8,大约在 2021 年前后): + + * [ppoll][13] + * [pthread_cond_clockwait et al.][14] + * [posix_spawn_file_actions_addchdir][15] + * [getlocalename_1][16] + * [reallocarray][17] + +### 关于用户空间的扩展 + +POSIX 不仅为开发人员定义了函数和特性,还为用户空间定义了标准行为。 + +#### ls + +`-A` 选项会排除来自 `ls` 命令结果中的符号 `.`(代表当前位置)和 `..`(代表上一级目录)。它被 POSIX 2008 采纳。 + +#### find + +`find` 命令是一个特别的ad hoc [for 循环][18] 工具,也是 [并行parallel][19] 处理的出入口。 + +一些从 GNU 引入到 POSIX 的便捷操作conveniences,包括 `-path` 和 `-perm` 选项。 + +`-path` 选项帮你过滤与文件系统路径模式匹配的搜索结果,并且从 1996 年(根据 `findutil` 的 Git 仓库中最早的记录)GNU 版本的 `find` 便可使用此选项。James Youngman 指出 [HP-UX][20] 也很早就有这个选项,所以究竟是 GNU 还是 HP-UX 做出的这一创新(抑或两者兼而有之)无法考证。 + +`-perm` 选项帮你按文件权限过滤搜索结果。这在 1996 年 GNU 版本的 `find` 中便已存在,随后被纳入 POSIX 标准 “IEEE Std 1003.1,2004 Edition” 中。 + +`xargs` 命令是 `findutils` 软件包的一部分,1996 年的时候就有一个 `-p` 选项会将 `xargs` 置于交互模式(用户将被提示是否继续),随后被纳入 POSIX 标准 “IEEE Std 1003.1, 2004 Edition” 中。 + +#### Awk + +GNU awk(即 `/usr/bin` 目录中的 `gawk` 命令,可能也是符号链接 `awk` 的目标地址)的维护者 Arnold Robbins 说道,`gawk` 和 `mawk`(另一个GPL 的 `awk` 实现)允许 `RS`(记录分隔符)是一个正则表达式,即这时 `RS` 的长度会大于 1。这一特性还不是 POSIX 的特性,但有 [迹象表明它即将会是][21]: + +> NUL 在扩展正则表达式中产生的未定义行为允许 GNU `gawk` 程序未来可以扩展以处理二进制数据。 +> +> 使用多字符 RS 值的未指定行为是为了未来可能的扩展,它是基于用于记录分隔符(RS)的扩展正则表达式的。目前的历史实现为采用该字符串的第一个字符而忽略其他字符。 + +这是一个重大的增强,因为 `RS` 符号定义了记录之间的分隔符。可能是逗号、分号、短划线、或者是任何此类字符,但如果它是字符*序列*,则只会使用第一个字符,除非你使用的是 `gawk` 或 `mawk`。想象一下这种情况,使用省略号(连续的三个点)作为解析 IP 地址文档的分隔记录,只是想获取在每个 IP 地址的每个点处解析的结果。 + +[mawk][22] 首先支持这个功能,但是几年来没有维护者,留下来的火把由 `gawk` 接过。(`mawk` 已然获得了一个新的维护者,可以说是大家薪火传承地将这一特性推向共同的预期值。) + +### POSIX 规范 + +总的来说,Giacomo Catenzzi 指出,“……因为 GNU 的实用程序使用广泛,而且许多其他的选项和行为又对标规范。在 shell 的每次更改中,Bash 都会(作为一等公民)被用作比较。” 当某些东西被纳入 POSIX 规范时,无需提及 GNU 或任何其他影响,你可以简单地认为 POSIX 规范会受到许多方面的影响,GNU 只是其中之一。 + +共识是 POSIX 存在的意义所在。一群技术人员共同努力为了实现共同规范,再分享给数以百计各异的开发人员,经由他们的赋能,从而实现软件的独立性,以及开发人员和用户的自由。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/what-posix-richard-stallman-explains + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[martin2011qi](https://github.com/martin2011qi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/document_free_access_cut_security.png?itok=ocvCv8G2 (Scissors cutting open access to files) +[2]: https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/ +[3]: https://stallman.org/ +[4]: https://www.gnu.org/philosophy/free-sw.en.html +[5]: https://www.ieee.org/ +[6]: http://gnu.org +[7]: https://www.gnu.org/prep/standards/html_node/Non_002dGNU-Standards.html +[8]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html +[9]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/diff.html +[10]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/patch.html +[11]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html +[12]: http://man7.org/linux/man-pages/man3/getline.3.html +[13]: http://austingroupbugs.net/view.php?id=1263 +[14]: http://austingroupbugs.net/view.php?id=1216 +[15]: http://austingroupbugs.net/view.php?id=1208 +[16]: http://austingroupbugs.net/view.php?id=1220 +[17]: http://austingroupbugs.net/view.php?id=1218 +[18]: https://opensource.com/article/19/6/how-write-loop-bash +[19]: https://opensource.com/article/18/5/gnu-parallel +[20]: https://www.hpe.com/us/en/servers/hp-ux.html +[21]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html +[22]: https://invisible-island.net/mawk/ diff --git a/published/201908/20190720 How to Upgrade Debian 9 (Stretch) to Debian 10 (Buster) via Command Line.md b/published/201908/20190720 How to Upgrade Debian 9 (Stretch) to Debian 10 (Buster) via Command Line.md new file mode 100644 index 0000000000..14e36860b6 --- /dev/null +++ b/published/201908/20190720 How to Upgrade Debian 9 (Stretch) to Debian 10 (Buster) via Command Line.md @@ -0,0 +1,161 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11172-1.html) +[#]: subject: (How to Upgrade Debian 9 (Stretch) to Debian 10 (Buster) via Command Line) +[#]: via: (https://www.linuxtechi.com/upgrade-debian-9-to-debian-10-command-line/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +如何通过命令行升级 Debian 9 为 Debian 10 +====== + +我们已经在先前的文章中看到如何安装 [Debian 10(Buster)][1]。今天,我们将学习如何从 Debian 9 升级为 Debian 10,虽然我们已将看到 Debian 10 和它的特色,所以这里我们不会深入介绍。但是可能读者没有机会读到那篇文章,让我们快速了解一下 Debian 10 和它的新功能。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Upgrade-Debian-9-to-Debian-10.jpg) + +在差不多两年的开发后,Debian 团队最终发布一个稳定版本,Debian 10 的代码名称是 Buster。Buster 是一个 LTS (长期支持支持)版本,因此未来将由 Debian 支持 5 年。 + +### Debian 10(Buster)新的特色 + +Debian 10(Buster)回报给大多数 Debian 爱好者大量的新特色。一些特色包括: + + * GNOME 桌面 3.30 + * 默认启用 AppArmor + * 支持 Linux 内核 4.19.0-4 + * 支持 OpenJDk 11.0 + * 从 Nodejs 4 ~ 8 升级到 Nodejs 10.15.2 + * Iptables 替换为 NFTables + +等等。 + +### 从 Debian 9 到 Debian 10 的逐步升级指南 + +在我们开始升级 Debian 10 前,让我们看看升级需要的必备条件: + +#### 步骤 1) Debian 升级必备条件 + + * 一个良好的网络连接 + * root 用户权限 + * 数据备份 + +备份你所有的应用程序代码库、数据文件、用户账号详细信息、配置文件是极其重要的,以便在升级出错时,你可以总是可以还原到先前的版本。 + +#### 步骤 2) 升级 Debian 9 现有的软件包 + +接下来的步骤是升级你所有现有的软件包,因为一些软件包被标志为保留不能升级,从 Debian 9 升级为 Debian 10 有失败或引发一些问题的可能性。所以,我们不冒任何风险,更好地升级软件包。使用下面的代码来升级软件包: + +``` +root@linuxtechi:~$ sudo apt update && sudo apt upgrade -y +``` + +#### 步骤 3) 修改软件包存储库文件 /etc/sources.list + +接下来的步骤是修改软件包存储库文件 `/etc/sources.list`,你需要用文本 `Buster` 替换 `Stretch`。 + +但是,在你更改任何东西前,确保如下创建一个 `sources.list` 文件的备份: + +``` +root@linuxtechi:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak +``` + +现在使用下面的 `sed` 命令来在软件包存储库文件中使用 `buster` 替换 `stretch`,示例如下显示: + +``` +root@linuxtechi:~$ sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list +root@linuxtechi:~$ sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list.d/*.list +``` + +更新后,你需要如下更新软件包存储库索引: + +``` +root@linuxtechi:~$ sudo apt update +``` + +在开始升级你现有的 Debian 操作系统前,让我们使用下面的命令验证当前版本, + +``` +root@linuxtechi:~$ cat /etc/*-release +PRETTY_NAME="Debian GNU/Linux 9 (stretch)" +NAME="Debian GNU/Linux" +VERSION_ID="9" +VERSION="9 (stretch)" +ID=debian +HOME_URL="https://www.debian.org/" +SUPPORT_URL="https://www.debian.org/support" +BUG_REPORT_URL="https://bugs.debian.org/" +root@linuxtechi:~$ +``` + +#### 步骤 4) 从 Debian 9 升级到 Debian 10 + +你做完所有的更改后,是时候从 Debian 9 升级到 Debian 10 了。但是在这之前,再次如下确保更新你的软件包: + +``` +root@linuxtechi:~$ sudo apt update && sudo apt upgrade -y +``` + +在软件包升级期间,你将被提示启动服务,所以选择你较喜欢的选项。 + +一旦你系统的所有软件包升级完成,就升级你的发行版的软件包。使用下面的代码来升级发行版: + +``` +root@linuxtechi:~$ sudo apt dist-upgrade -y +``` + +升级过程可能花费一些时间,取决于你的网络速度。记住在升级过程中,你将被询问一些问题,在软件包升级后是否需要重启服务、你是否需要保留现存的配置文件等。如果你不想进行一些自定义更改,简单地键入 “Y” ,来让升级过程继续。 + +#### 步骤 5) 验证升级 + +一旦升级过程完成,重启你的机器,并使用下面的方法检测版本: + +``` +root@linuxtechi:~$ lsb_release -a +``` + +如果你获得如下输出: + +``` +Distributor ID: Debian +Description: Debian GNU/Linux 10 (buster) +Release: 10 +Codename: buster +root@linuxtechi:~$ +``` + +是的,你已经成功地从 Debian 9 升级到 Debian 10。 + +验证升级的备用方法: + +``` +root@linuxtechi:~$ cat /etc/*-release +PRETTY_NAME="Debian GNU/Linux 10 (buster)" +NAME="Debian GNU/Linux" +VERSION_ID="10" +VERSION="10 (buster)" +VERSION_CODENAME=buster +ID=debian +HOME_URL="https://www.debian.org/" +SUPPORT_URL="https://www.debian.org/support" +BUG_REPORT_URL="https://bugs.debian.org/" +root@linuxtechi:~$ +``` + +### 结束 + +希望上面的逐步指南为你提供了从 Debian 9(Stretch)简单地升级为 Debian 10(Buster)的所有信息。在评论部分,请给予你使用 Debian 10 的反馈、建议、体验。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/upgrade-debian-9-to-debian-10-command-line/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-11083-1.html diff --git a/published/201908/20190724 3 types of metric dashboards for DevOps teams.md b/published/201908/20190724 3 types of metric dashboards for DevOps teams.md new file mode 100644 index 0000000000..8d2f7aebe5 --- /dev/null +++ b/published/201908/20190724 3 types of metric dashboards for DevOps teams.md @@ -0,0 +1,78 @@ +[#]: collector: "lujun9972" +[#]: translator: "hello-wn" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11183-1.html" +[#]: subject: "3 types of metric dashboards for DevOps teams" +[#]: via: "https://opensource.com/article/19/7/dashboards-devops-teams" +[#]: author: "Daniel Oh https://opensource.com/users/daniel-oh" + +DevOps 团队必备的 3 种指标仪表板 +========= + +> 仪表板可以帮助 DevOps 团队观测和监控系统,以提高性能。 + +![](https://img.linux.net.cn/data/attachment/album/201908/04/083434ixlm9lgv8ev8dlyd.jpg) + +指标仪表板帮助 [DevOps][2] 团队监控整个 DevOps 平台,以便实时响应议题issue。在处理生产环境宕机或者应用服务中断等情况时,指标仪表板显得尤为重要。 + +DevOps 仪表板聚合了多个监测工具的指标,为开发和运维团队生成监控报告。它还允许团队跟踪多项指标,例如服务部署时间、程序 bug、报错信息、工作项、待办事项等等。 + +下面三种指标仪表板可以帮助 DevOps 团队监测系统,改善服务性能。 + +### 敏捷项目管理仪表板 + +这种类型的仪表板为 DevOps 团队的工作项提供可视化视图,优化敏捷项目的工作流。有利于提高团队协作效率,对工作进行可视化并提供灵活的视图 —— 就像我们过去在白板上使用便利贴来共享项目进度、议题issue和待办事项一样。 + +- [Kanban boards][3] 允许 DevOps 团队创建卡片、标签、任务和栏目,便于持续交付敏捷项目。 +- [Burndown charts][4] 对指定时间段内未完成的工作或待办事项提供可视化视图,并记录团队当前的效率和轨迹,这些指标通常用于敏捷项目和 DevOps 项目管理。 +- [Jira boards][5] 帮助 DevOps 团队创建议题、计划迭代并生成团队总结。这些灵活的仪表板还能帮助团队综合考虑并确定个人和团队任务的优先级;实时查看、汇报和跟踪正在进行的工作;并提高团队绩效。 +- [GitHub project boards][6] 帮助确定团队任务的优先级。它们还支持拉取请求,因此团队成员可以方便地提交 DevOps 项目相关的信息。 + +### 应用程序监控仪表板 + +开发者负责优化应用和服务的性能,并开发新功能。应用程序监控面板则帮助开发者在持续集成/持续开发CI / CD流程下,加快修复 bug、增强程序健壮性、发布安全修丁的进度。另外,这些可视化仪表板有利于查看请求模式、请求耗时、报错和网络拓扑信息。 + +- [Jaeger][7] 帮助开发人员跟踪请求数量、请求响应时间等。对于分布式网络系统上的云原生应用程序,它还使用 [Istio 服务网格][8]加强了监控和跟踪。 +- [OpenCensus][9] 帮助团队查看运行应用程序的主机上的数据,它还提供了一个可插拔的导出系统,用于将数据导出到数据中心。 + +### DevOps 平台监控面板 + +你可能使用多种技术和工具在云上或本地构建 DevOps 平台,但 Linux 容器管理工具(如 Kubernetes 和 OpenShift )更利于搭建出一个成功的 DevOps 平台。因为 Linux 容器的不可变性和可移植性使得应用程序从开发环境到生产环境的编译、测试和部署变得更快更容易。 + +DevOps 平台监控仪表板帮助运营团队从机器/节点故障和服务报错中收集各种按时序排列的数据,用于编排应用程序容器和基于软件的基础架构,如网络(SDN)和存储(SDS)。这些仪表板还能可视化多维数据格式,方便地查询数据模式。 + +- [Prometheus dashboards][12] 从平台节点或者运行中的容器化应用中收集指标。帮助 DevOps 团队构建基于指标的监控系统和仪表板,监控微服务的客户端/服务器工作负载,及时识别出异常节点故障。 +- [Grafana boards][13] 帮助收集事件驱动的各项指标,包括服务响应持续时间、请求量、客户端/服务器client/server工作负载、网络流量等,并提供了可视化面板。DevOps 团队可以通过多种方式分享指标面板,也可以生成编码的当前监控数据快照分享给其他团队。 + +### 总结 + +这些仪表板提供了可视化的工作流程,能够发现团队协作、应用程序交付和平台状态中的各种问题。它们帮助开发团队增强其在快速应用交付、安全运行和自动化 CI/CD 等领域的能力。 + +------ + +via: https://opensource.com/article/19/7/dashboards-devops-teams + +作者:[Daniel Oh][a] +选题:[lujun9972][b] +译者:[hello-wn](https://github.com/hello-wn) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/daniel-ohhttps://opensource.com/users/daniel-ohhttps://opensource.com/users/heronthecli +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png +[2]: https://opensource.com/resources/devops +[3]: https://opensource.com/article/19/1/productivity-tool-taskboard +[4]: https://openpracticelibrary.com/practice/burndown/ +[5]: https://www.atlassian.com/software/jira +[6]: https://opensource.com/life/15/11/short-introduction-github +[7]: https://www.jaegertracing.io/ +[8]: https://opensource.com/article/19/3/getting-started-jaeger +[9]: https://opencensus.io/ +[10]: https://opensource.com/article/18/11/intro-software-defined-networking +[11]: https://opensource.com/business/14/10/sage-weil-interview-openstack-ceph +[12]: https://opensource.com/article/18/12/introduction-prometheus +[13]: https://opensource.com/article/17/8/linux-grafana + diff --git a/published/201908/20190725 How to transition into a career as a DevOps engineer.md b/published/201908/20190725 How to transition into a career as a DevOps engineer.md new file mode 100644 index 0000000000..0446257826 --- /dev/null +++ b/published/201908/20190725 How to transition into a career as a DevOps engineer.md @@ -0,0 +1,100 @@ +[#]: collector: (lujun9972) +[#]: translator: (beamrolling) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11285-1.html) +[#]: subject: (How to transition into a career as a DevOps engineer) +[#]: via: (https://opensource.com/article/19/7/how-transition-career-devops-engineer) +[#]: author: (Conor Delanbanque https://opensource.com/users/cdelanbanquehttps://opensource.com/users/daniel-ohhttps://opensource.com/users/herontheclihttps://opensource.com/users/marcobravohttps://opensource.com/users/cdelanbanque) + +如何转职为 DevOps 工程师 +====== + +> 无论你是刚毕业的大学生,还是想在职业中寻求进步的经验丰富的 IT 专家,这些提示都可以帮你成为 DevOps 工程师。 + +![](https://img.linux.net.cn/data/attachment/album/201908/30/171751rodhw6wko6fkkwkq.jpg) + +DevOps 工程是一个备受称赞的热门职业。不管你是刚毕业正在找第一份工作,还是在利用之前的行业经验的同时寻求学习新技能的机会,本指南都能帮你通过正确的步骤成为 [DevOps 工程师][2]。 + +### 让自己沉浸其中 + +首先学习 [DevOps][3] 的基本原理、实践以及方法。在使用工具之前,先了解 DevOps 背后的“为什么”。DevOps 工程师的主要目标是在整个软件开发生命周期(SDLC)中提高速度并保持或提高质量,以提供最大的业务价值。阅读文章、观看 YouTube 视频、参加当地小组聚会或者会议 —— 成为热情的 DevOps 社区中的一员,在那里你将从先行者的错误和成功中学习。 + +### 考虑你的背景 + +如果你有从事技术工作的经历,例如软件开发人员、系统工程师、系统管理员、网络运营工程师或者数据库管理员,那么你已经拥有了广泛的见解和有用的经验,它们可以帮助你在未来成为 DevOps 工程师。如果你在完成计算机科学或任何其他 STEM(LCTT 译注:STEM 是科学Science技术Technology工程Engineering数学Math四个学科的首字母缩略字)领域的学业后刚开始职业生涯,那么你将拥有在这个过渡期间需要的一些基本踏脚石。 + +DevOps 工程师的角色涵盖了广泛的职责。以下是企业最有可能使用他们的三种方向: + +* **偏向于开发(Dev)的 DevOps 工程师**,在构建应用中扮演软件开发的角色。他们日常工作的一部分是利用持续集成 / 持续交付(CI/CD)、共享仓库、云和容器,但他们不一定负责构建或实施工具。他们了解基础架构,并且在成熟的环境中,能将自己的代码推向生产环境。 +* **偏向于运维技术(Ops)的 DevOps 工程师**,可以与系统工程师或系统管理员相比较。他们了解软件的开发,但并不会把一天的重心放在构建应用上。相反,他们更有可能支持软件开发团队实现手动流程的自动化,并提高人员和技术系统的效率。这可能意味着分解遗留代码,并用不太繁琐的自动化脚本来运行相同的命令,或者可能意味着安装、配置或维护基础结构和工具。他们确保为任何有需要的团队安装可使用的工具。他们也会通过教团队如何利用 CI / CD 和其他 DevOps 实践来帮助他们。 +* **网站可靠性工程师(SRE)**,就像解决运维和基础设施的软件工程师。SRE 专注于创建可扩展、高可用且可靠的软件系统。 + +在理想的世界中,DevOps 工程师将了解以上所有领域;这在成熟的科技公司中很常见。然而,顶级银行和许多财富 500 强企业的 DevOps 职位通常会偏向开发(Dev)或运营(Ops)。 + +### 要学习的技术 + +DevOps 工程师需要了解各种技术才能有效完成工作。无论你的背景如何,请从作为 DevOps 工程师需要使用和理解的基本技术开始。 + +#### 操作系统 + +操作系统是一切运行的地方,拥有相关的基础知识十分重要。[Linux][4] 是你最有可能每天使用的操作系统,尽管有的组织会使用 Windows 操作系统。要开始使用,你可以在家中安装 Linux,在那里你可以随心所欲地中断,并在此过程中学习。 + +#### 脚本 + +接下来,选择一门语言来学习脚本编程。有很多语言可供选择,包括 Python、Go、Java、Bash、PowerShell、Ruby 和 C / C++。我建议[从 Python 开始][5],因为它相对容易学习和解释,是最受欢迎的语言之一。Python 通常是遵循面向对象编程(OOP)的准则编写的,可用于 Web 开发、软件开发以及创建桌面 GUI 和业务应用程序。 + +#### 云 + +学习了 [Linux][4] 和 [Python][5] 之后,我认为下一个该学习的是云计算。基础设施不再只是“运维小哥”的事情了,因此你需要接触云平台,例如 AWS 云服务、Azure 或者谷歌云平台。我会从 AWS 开始,因为它有大量免费学习工具,可以帮助你降低作为开发人员、运维人员,甚至面向业务的部门的任何障碍。事实上,你可能会被它提供的东西所淹没。考虑从 EC2、S3 和 VPC 开始,然后看看你从其中想学到什么。 + +#### 编程语言 + +如果你对 DevOps 的软件开发充满热情,请继续提高你的编程技能。DevOps 中的一些优秀和常用的编程语言和你用于脚本编程的相同:Python、Go、Java、Bash、PowerShell、Ruby 和 C / C++。你还应该熟悉 Jenkins 和 Git / Github,你将会在 CI / CD 过程中经常使用到它们。 + +#### 容器 + +最后,使用 Docker 和编排平台(如 Kubernetes)等工具开始学习[容器化][6]。网上有大量的免费学习资源,大多数城市都有本地的线下小组,你可以在友好的环境中向有经验的人学习(还有披萨和啤酒哦!)。 + +#### 其他的呢? + +如果你缺乏开发经验,你依然可以通过对自动化的热情,提高效率,与他人协作以及改进自己的工作来[参与 DevOps][3]。我仍然建议学习上述工具,但重点不要放在编程 / 脚本语言上。了解基础架构即服务、平台即服务、云平台和 Linux 会非常有用。你可能会设置工具并学习如何构建具有弹性和容错能力的系统,并在编写代码时利用它们。 + +### 找一份 DevOps 的工作 + +求职过程会有所不同,具体取决于你是否一直从事技术工作,是否正在进入 DevOps 领域,或者是刚开始职业生涯的毕业生。 + +#### 如果你已经从事技术工作 + +如果你正在从一个技术领域转入 DevOps 角色,首先尝试在你当前的公司寻找机会。你能通过和其他的团队一起工作来重新掌握技能吗?尝试跟随其他团队成员,寻求建议,并在不离开当前工作的情况下获得新技能。如果做不到这一点,你可能需要换另一家公司。如果你能从上面列出的一些实践、工具和技术中学习,你将能在面试时展示相关知识从而占据有利位置。关键是要诚实,不要担心失败。大多数招聘主管都明白你并不知道所有的答案;如果你能展示你一直在学习的东西,并解释你愿意学习更多,你应该有机会获得 DevOps 的工作。 + +#### 如果你刚开始职业生涯 + +申请雇用初级 DevOps 工程师的公司的空缺机会。不幸的是,许多公司表示他们希望寻找更富有经验的人,并建议你在获得经验后再申请该职位。这是“我们需要经验丰富的人”的典型,令人沮丧的场景,并且似乎没人愿意给你第一次机会。 + +然而,并不是所有求职经历都那么令人沮丧;一些公司专注于培训和提升刚从大学毕业的学生。例如,我工作的 [MThree][7] 会聘请应届毕业生并且对其进行 8 周的培训。当完成培训后,参与者们可以充分了解到整个 SDLC,并充分了解它在财富 500 强公司环境中的运用方式。毕业生被聘为 MThree 的客户公司的初级 DevOps 工程师 —— MThree 在前 18 - 24 个月内支付全职工资和福利,之后他们将作为直接雇员加入客户。这是弥合从大学到技术职业的间隙的好方法。 + +### 总结 + +转职成 DevOps 工程师的方法有很多种。这是一条非常有益的职业路线,可能会让你保持繁忙和挑战 — 并增加你的收入潜力。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/how-transition-career-devops-engineer + +作者:[Conor Delanbanque][a] +选题:[lujun9972][b] +译者:[beamrolling](https://github.com/beamrolling) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/cdelanbanquehttps://opensource.com/users/daniel-ohhttps://opensource.com/users/herontheclihttps://opensource.com/users/marcobravohttps://opensource.com/users/cdelanbanque +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/hiring_talent_resume_job_career.png?itok=Ci_ulYAH (technical resume for hiring new talent) +[2]: https://opensource.com/article/19/7/devops-vs-sysadmin +[3]: https://opensource.com/resources/devops +[4]: https://opensource.com/resources/linux +[5]: https://opensource.com/resources/python +[6]: https://opensource.com/article/18/8/sysadmins-guide-containers +[7]: https://www.mthreealumni.com/ diff --git a/published/201908/20190725 Introduction to GNU Autotools.md b/published/201908/20190725 Introduction to GNU Autotools.md new file mode 100644 index 0000000000..71cda2d23a --- /dev/null +++ b/published/201908/20190725 Introduction to GNU Autotools.md @@ -0,0 +1,245 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11218-1.html) +[#]: subject: (Introduction to GNU Autotools) +[#]: via: (https://opensource.com/article/19/7/introduction-gnu-autotools) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +GNU Autotools 介绍 +====== + +> 如果你仍未使用过 Autotools,那么这篇文章将改变你递交代码的方式。 + +![](https://img.linux.net.cn/data/attachment/album/201908/13/094739ahql50gx9x10y157.jpg) + +你有没有下载过流行的软件项目的源代码,要求你输入几乎是仪式般的 `./configure; make && make install` 命令序列来构建和安装它?如果是这样,你已经使用过 [GNU Autotools][2] 了。如果你曾经研究过这样的项目所附带的一些文件,你可能会对这种构建系统的显而易见的复杂性感到害怕。 + +好的消息是,GNU Autotools 的设置要比你想象的要简单得多,GNU Autotools 本身可以为你生成这些上千行的配置文件。是的,你可以编写 20 或 30 行安装代码,并免费获得其他 4,000 行。 + +### Autotools 工作方式 + +如果你是初次使用 Linux 的用户,正在寻找有关如何安装应用程序的信息,那么你不必阅读本文!如果你想研究如何构建软件,欢迎阅读它;但如果你只是要安装一个新应用程序,请阅读我在[在 Linux 上安装应用程序][3]的文章。 + +对于开发人员来说,Autotools 是一种管理和打包源代码的快捷方式,以便用户可以编译和安装软件。 Autotools 也得到了主要打包格式(如 DEB 和 RPM)的良好支持,因此软件存储库的维护者可以轻松管理使用 Autotools 构建的项目。 + +Autotools 工作步骤: + +1. 首先,在 `./configure` 步骤中,Autotools 扫描宿主机系统(即当前正在运行的计算机)以发现默认设置。默认设置包括支持库所在的位置,以及新软件应放在系统上的位置。 +2. 接下来,在 `make` 步骤中,Autotools 通常通过将人类可读的源代码转换为机器语言来构建应用程序。 +3. 最后,在 `make install` 步骤中,Autotools 将其构建好的文件复制到计算机上(在配置阶段检测到)的相应位置。 + +这个过程看起来很简单,和你使用 Autotools 的步骤一样。 + +### Autotools 的优势 + +GNU Autotools 是我们大多数人认为理所当然的重要软件。与 [GCC(GNU 编译器集合)][4]一起,Autotools 是支持将自由软件构建和安装到正在运行的系统的脚手架。如果你正在运行 [POSIX][5] 系统,可以毫不保守地说,你的计算机上的操作系统里大多数可运行软件都是这些这样构建的。 + +即使是你的项目是个玩具项目不是操作系统,你可能会认为 Autotools 对你的需求来说太过分了。但是,尽管它的名气很大,Autotools 有许多可能对你有益的小功能,即使你的项目只是一个相对简单的应用程序或一系列脚本。 + +#### 可移植性 + +首先,Autotools 考虑到了可移植性。虽然它无法使你的项目在所有 POSIX 平台上工作(这取决于你,编码的人),但 Autotools 可以确保你标记为要安装的文件安装到已知平台上最合理的位置。而且由于 Autotools,高级用户可以轻松地根据他们自己的系统情况定制和覆盖任何非最佳设定。 + +使用 Autotools,你只要知道需要将文件安装到哪个常规位置就行了。它会处理其他一切。不需要可能破坏未经测试的操作系统的定制安装脚本。 + +#### 打包 + +Autotools 也得到了很好的支持。将一个带有 Autotools 的项目交给一个发行版打包者,无论他们是打包成 RPM、DEB、TGZ 还是其他任何东西,都很简单。打包工具知道 Autotools,因此可能不需要修补、魔改或调整。在许多情况下,将 Autotools 项目结合到流程中甚至可以实现自动化。 + +### 如何使用 Autotools + +要使用 Autotools,必须先安装它。你的发行版可能提供一个单个的软件包来帮助开发人员构建项目,或者它可能为每个组件提供了单独的软件包,因此你可能需要在你的平台上进行一些研究以发现需要安装的软件包。 + +Autotools 的组件是: + + * `automake` + * `autoconf` + * `automake` + * `make` + +虽然你可能需要安装项目所需的编译器(例如 GCC),但 Autotools 可以很好地处理不需要编译的脚本或二进制文件。实际上,Autotools 对于此类项目非常有用,因为它提供了一个 `make uninstall` 脚本,以便于删除。 + +安装了所有组件之后,现在让我们了解一下你的项目文件的组成结构。 + +#### Autotools 项目结构 + +GNU Autotools 有非常具体的预期规范,如果你经常下载和构建源代码,可能大多数都很熟悉。首先,源代码本身应该位于一个名为 `src` 的子目录中。 + +你的项目不必遵循所有这些预期规范,但如果你将文件放在非标准位置(从 Autotools 的角度来看),那么你将不得不稍后在 `Makefile` 中对其进行调整。 + +此外,这些文件是必需的: + + * `NEWS` + * `README` + * `AUTHORS` + * `ChangeLog` + +你不必主动使用这些文件,它们可以是包含所有信息的单个汇总文档(如 `README.md`)的符号链接,但它们必须存在。 + +#### Autotools 配置 + +在你的项目根目录下创建一个名为 `configure.ac` 的文件。`autoconf` 使用此文件来创建用户在构建之前运行的 `configure` shell 脚本。该文件必须至少包含 `AC_INIT` 和 `AC_OUTPUT` [M4 宏][6]。你不需要了解有关 M4 语言的任何信息就可以使用这些宏;它们已经为你编写好了,并且所有与 Autotools 相关的内容都在该文档中定义好了。 + +在你喜欢的文本编辑器中打开该文件。`AC_INIT` 宏可以包括包名称、版本、报告错误的电子邮件地址、项目 URL 以及可选的源 TAR 文件名称等参数。 + +[AC_OUTPUT][7] 宏更简单,不用任何参数。 + +``` +AC_INIT([penguin], [2019.3.6], [[seth@example.com][8]]) +AC_OUTPUT +``` + +如果你此刻运行 `autoconf`,会依据你的 `configure.ac` 文件生成一个 `configure` 脚本,它是可以运行的。但是,也就是能运行而已,因为到目前为止你所做的就是定义项目的元数据,并要求创建一个配置脚本。 + +你必须在 `configure.ac` 文件中调用的下一个宏是创建 [Makefile][9] 的函数。 `Makefile` 会告诉 `make` 命令做什么(通常是如何编译和链接程序)。 + +创建 `Makefile` 的宏是 `AM_INIT_AUTOMAKE`,它不接受任何参数,而 `AC_CONFIG_FILES` 接受的参数是你要输出的文件的名称。 + +最后,你必须添加一个宏来考虑你的项目所需的编译器。你使用的宏显然取决于你的项目。如果你的项目是用 C++ 编写的,那么适当的宏是 `AC_PROG_CXX`,而用 C 编写的项目需要 `AC_PROG_CC`,依此类推,详见 Autoconf 文档中的 [Building Programs and Libraries][10] 部分。 + +例如,我可能会为我的 C++ 程序添加以下内容: + +``` +AC_INIT([penguin], [2019.3.6], [[seth@example.com][8]]) +AC_OUTPUT +AM_INIT_AUTOMAKE +AC_CONFIG_FILES([Makefile]) +AC_PROG_CXX +``` + +保存该文件。现在让我们将目光转到 `Makefile`。 + +#### 生成 Autotools Makefile + +`Makefile` 并不难手写,但 Autotools 可以为你编写一个,而它生成的那个将使用在 `./configure` 步骤中检测到的配置选项,并且它将包含比你考虑要包括或想要自己写的还要多得多的选项。然而,Autotools 并不能检测你的项目构建所需的所有内容,因此你必须在文件 `Makefile.am` 中添加一些细节,然后在构造 `Makefile` 时由 `automake` 使用。 + +`Makefile.am` 使用与 `Makefile` 相同的语法,所以如果你曾经从头开始编写过 `Makefile`,那么这个过程将是熟悉和简单的。通常,`Makefile.am` 文件只需要几个变量定义来指示要构建的文件以及它们的安装位置即可。 + +以 `_PROGRAMS` 结尾的变量标识了要构建的代码(这通常被认为是原语primary目标;这是 `Makefile` 存在的主要意义)。Automake 也会识别其他原语,如 `_SCRIPTS`、`_ DATA`、`_LIBRARIES`,以及构成软件项目的其他常见部分。 + +如果你的应用程序在构建过程中需要实际编译,那么你可以用 `bin_PROGRAMS` 变量将其标记为二进制程序,然后使用该程序名称作为变量前缀引用构建它所需的源代码的任何部分(这些部分可能是将被编译和链接在一起的一个或多个文件): + +``` +bin_PROGRAMS = penguin +penguin_SOURCES = penguin.cpp +``` + +`bin_PROGRAMS` 的目标被安装在 `bindir` 中,它在编译期间可由用户配置。 + +如果你的应用程序不需要实际编译,那么你的项目根本不需要 `bin_PROGRAMS` 变量。例如,如果你的项目是用 Bash、Perl 或类似的解释语言编写的脚本,那么定义一个 `_SCRIPTS` 变量来替代: + +``` +bin_SCRIPTS = bin/penguin +``` + +Automake 期望源代码位于名为 `src` 的目录中,因此如果你的项目使用替代目录结构进行布局,则必须告知 Automake 接受来自外部源的代码: + +``` +AUTOMAKE_OPTIONS = foreign subdir-objects +``` + +最后,你可以在 `Makefile.am` 中创建任何自定义的 `Makefile` 规则,它们将逐字复制到生成的 `Makefile` 中。例如,如果你知道一些源代码中的临时值需要在安装前替换,则可以为该过程创建自定义规则: + +``` +all-am: penguin +        touch bin/penguin.sh +        +penguin: bin/penguin.sh +        @sed "s|__datadir__|@datadir@|" $< >bin/$@ +``` + +一个特别有用的技巧是扩展现有的 `clean` 目标,至少在开发期间是这样的。`make clean` 命令通常会删除除了 Automake 基础结构之外的所有生成的构建文件。它是这样设计的,因为大多数用户很少想要 `make clean` 来删除那些便于构建代码的文件。 + +但是,在开发期间,你可能需要一种方法可靠地将项目返回到相对不受 Autotools 影响的状态。在这种情况下,你可能想要添加: + +``` +clean-local: +        @rm config.status configure config.log +        @rm Makefile +        @rm -r autom4te.cache/ +        @rm aclocal.m4 +        @rm compile install-sh missing Makefile.in +``` + +这里有很多灵活性,如果你还不熟悉 `Makefile`,那么很难知道你的 `Makefile.am` 需要什么。最基本需要的是原语目标,无论是二进制程序还是脚本,以及源代码所在位置的指示(无论是通过 `_SOURCES` 变量还是使用 `AUTOMAKE_OPTIONS` 告诉 Automake 在哪里查找源代码)。 + +一旦定义了这些变量和设置,如下一节所示,你就可以尝试生成构建脚本,并调整缺少的任何内容。 + +#### 生成 Autotools 构建脚本 + +你已经构建了基础结构,现在是时候让 Autotools 做它最擅长的事情:自动化你的项目工具。对于开发人员(你),Autotools 的接口与构建代码的用户的不同。 + +构建者通常使用这个众所周知的顺序: + +``` +$ ./configure +$ make +$ sudo make install +``` + +但是,要使这种咒语起作用,你作为开发人员必须引导构建这些基础结构。首先,运行 `autoreconf` 以生成用户在运行 `make` 之前调用的 `configure` 脚本。使用 `-install` 选项将辅助文件(例如符号链接)引入到 `depcomp`(这是在编译过程中生成依赖项的脚本),以及 `compile` 脚本的副本(一个编译器的包装器,用于说明语法,等等)。 + +``` +$ autoreconf --install +configure.ac:3: installing './compile' +configure.ac:2: installing './install-sh' +configure.ac:2: installing './missing' +``` + +使用此开发构建环境,你可以创建源代码分发包: + +``` +$ make dist +``` + +`dist` 目标是从 Autotools “免费”获得的规则。这是一个内置于 `Makefile` 中的功能,它是通过简单的 `Makefile.am` 配置生成的。该目标可以生成一个 `tar.gz` 存档,其中包含了所有源代码和所有必要的 Autotools 基础设施,以便下载程序包的人员可以构建项目。 + +此时,你应该仔细查看存档文件的内容,以确保它包含你要发送给用户的所有内容。当然,你也应该尝试自己构建: + +``` +$ tar --extract --file penguin-0.0.1.tar.gz +$ cd penguin-0.0.1 +$ ./configure +$ make +$ DESTDIR=/tmp/penguin-test-build make install +``` + +如果你的构建成功,你将找到由 `DESTDIR` 指定的已编译应用程序的本地副本(在此示例的情况下为 `/tmp/penguin-test-build`)。 + +``` +$ /tmp/example-test-build/usr/local/bin/example +hello world from GNU Autotools +``` + +### 去使用 Autotools + +Autotools 是一个很好的脚本集合,可用于可预测的自动发布过程。如果你习惯使用 Python 或 Bash 构建器,这个工具集对你来说可能是新的,但它为你的项目提供的结构和适应性可能值得学习。 + +而 Autotools 也不只是用于代码。Autotools 可用于构建 [Docbook][11] 项目,保持媒体有序(我使用 Autotools 进行音乐发布),文档项目以及其他任何可以从可自定义安装目标中受益的内容。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/introduction-gnu-autotools + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_kernel_clang_vscode.jpg?itok=fozZ4zrr (Linux kernel source code (C) in Visual Studio Code) +[2]: https://www.gnu.org/software/automake/faq/autotools-faq.html +[3]: https://linux.cn/article-9486-1.html +[4]: https://en.wikipedia.org/wiki/GNU_Compiler_Collection +[5]: https://en.wikipedia.org/wiki/POSIX +[6]: https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Initializing-configure.html +[7]: https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Output.html#Output +[8]: mailto:seth@example.com +[9]: https://www.gnu.org/software/make/manual/html_node/Introduction.html +[10]: https://www.gnu.org/software/automake/manual/html_node/Programs.html#Programs +[11]: https://opensource.com/article/17/9/docbook diff --git a/published/201908/20190726 Manage your passwords with Bitwarden and Podman.md b/published/201908/20190726 Manage your passwords with Bitwarden and Podman.md new file mode 100644 index 0000000000..0abb8e1378 --- /dev/null +++ b/published/201908/20190726 Manage your passwords with Bitwarden and Podman.md @@ -0,0 +1,126 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11181-1.html) +[#]: subject: (Manage your passwords with Bitwarden and Podman) +[#]: via: (https://fedoramagazine.org/manage-your-passwords-with-bitwarden-and-podman/) +[#]: author: (Eric Gustavsson https://fedoramagazine.org/author/egustavs/) + +使用 Bitwarden 和 Podman 管理你的密码 +====== + +![][1] + +在过去的一年中,你可能会遇到一些试图向你推销密码管理器的广告。比如 [LastPass][2]、[1Password][3] 或 [Dashlane][4]。密码管理器消除了记住所有网站密码的负担。你不再需要使用重复或容易记住的密码。相反,你只需要记住一个可以解锁所有其他密码的密码。 + +通过使用一个强密码而​​不是许多弱密码,这可以使你更安全。如果你有基于云的密码管理器(例如 LastPass、1Password 或 Dashlane),你还可以跨设备同步密码。不幸的是,这些产品都不是开源的。幸运的是,还有其他开源替代品。 + +### 开源密码管理器 + +替代方案包括 Bitwarden、[LessPass][5] 或 [KeePass][6]。Bitwarden 是一款[开源密码管理器][7],它会将所有密码加密存储在服务器上,它的工作方式与 LastPass、1Password 或 Dashlane 相同。LessPass 有点不同,因为它专注于成为无状态密码管理器。这意味着它根据主密码、网站和用户名生成密码,而不是保存加密的密码。另一方面,KeePass 是一个基于文件的密码管理器,它的插件和应用具有很大的灵活性。 + +这三个应用中的每一个都有其自身的缺点。Bitwarden 将所有东西保存在一个地方,并通过其 API 和网站接口暴露给网络。LessPass 无法保存自定义密码,因为它是无状态的,因此你需要使用它生成的密码。KeePass 是一个基于文件的密码管理器,因此无法在设备之间轻松同步。你可以使用云存储和 [WebDAV][8] 来解决此问题,但是有许多客户端不支持它,如果设备无法正确同步,你可能会遇到文件冲突。 + +本文重点介绍 Bitwarden。 + +### 运行非官方的 Bitwarden 实现 + +有一个名为 [bitwarden_rs][9] 的服务器及其 API 的社区实现。这个实现是完全开源的,因为它可以使用 SQLite 或 MariaDB/MySQL,而不是官方服务器使用的专有 Microsoft SQL Server。 + +有一点重要的是要认识到官方和非官方版本之间存在一些差异。例如,[官方服务器已经由第三方审核][10],而非官方服务器还没有。在实现方面,非官方版本缺少[电子邮件确认和采用 Duo 或邮件码的双因素身份验证][11]。 + +让我们在 SELinux 中运行服务器。根据 bitwarden_rs 的文档,你可以如下构建一个 Podman 命令: + +``` +$ podman run -d \ + --userns=keep-id \ + --name bitwarden \ + -e SIGNUPS_ALLOWED=false \ + -e ROCKET_PORT=8080 \ + -v /home/egustavs/Bitwarden/bw-data/:/data/:Z \ + -p 8080:8080 \ + bitwardenrs/server:latest +``` + +这将下载 bitwarden_rs 镜像并在用户命名空间下的用户容器中运行它。它使用 1024 以上的端口,以便非 root 用户可以绑定它。它还使用 `:Z` 更改卷的 SELinux 上下文,以防止在 `/data` 中的读写权限问题。 + +如果你在某个域下托管它,建议将此服务器放在 Apache 或 Nginx 的反向代理下。这样,你可以使用 80 和 443 端口指向容器的 8080 端口,而无需以 root 身份运行容器。 + +### 在 systemd 下运行 + +Bitwarden 现在运行了,你可能希望保持这种状态。接下来,创建一个使容器保持运行的单元文件,如果它没有响应则自动重新启动,并在系统重启后开始运行。创建文件 `/etc/systemd/system/bitwarden.service`: + +``` +[Unit] +Description=Bitwarden Podman container +Wants=syslog.service + +[Service] +User=egustavs +Group=egustavs +TimeoutStartSec=0 +ExecStart=/usr/bin/podman run 'bitwarden' +ExecStop=-/usr/bin/podman stop -t 10 'bitwarden' +Restart=always +RestartSec=30s +KillMode=none + +[Install] +WantedBy=multi-user.target +``` + +现在使用 [sudo][12] 启用并启动该服务: + +``` +$ sudo systemctl enable bitwarden.service && sudo systemctl start bitwarden.service +$ systemctl status bitwarden.service +bitwarden.service - Bitwarden Podman container + Loaded: loaded (/etc/systemd/system/bitwarden.service; enabled; vendor preset: disabled) + Active: active (running) since Tue 2019-07-09 20:23:16 UTC; 1 day 14h ago + Main PID: 14861 (podman) + Tasks: 44 (limit: 4696) + Memory: 463.4M +``` + +成功了!Bitwarden 现在运行了并将继续运行。 + +### 添加 LetsEncrypt + +如果你有域名,强烈建议你使用类似 LetsEncrypt 的加密证书运行你的 Bitwarden 实例。Certbot 是一个为我们创建 LetsEncrypt 证书的机器人,这里有个[在 Fedora 中操作的指南][13]。 + +生成证书后,你可以按照 [bitwarden_rs 指南中关于 HTTPS 的部分来][14]。只要记得将 `:Z` 附加到 LetsEncrypt 来处理权限,而不用更改端口。 + +* * * + +照片由 [CMDR Shane][15] 拍摄,发表在 [Unsplash][16] 上。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/manage-your-passwords-with-bitwarden-and-podman/ + +作者:[Eric Gustavsson][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/egustavs/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/07/bitwarden-816x345.jpg +[2]: https://www.lastpass.com +[3]: https://1password.com/ +[4]: https://www.dashlane.com/ +[5]: https://lesspass.com/ +[6]: https://keepass.info/ +[7]: https://bitwarden.com/ +[8]: https://en.wikipedia.org/wiki/WebDAV +[9]: https://github.com/dani-garcia/bitwarden_rs/ +[10]: https://blog.bitwarden.com/bitwarden-completes-third-party-security-audit-c1cc81b6d33 +[11]: https://github.com/dani-garcia/bitwarden_rs/wiki#missing-features +[12]: https://fedoramagazine.org/howto-use-sudo/ +[13]: https://certbot.eff.org/instructions +[14]: https://github.com/dani-garcia/bitwarden_rs/wiki/Enabling-HTTPS +[15]: https://unsplash.com/@cmdrshane?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[16]: https://unsplash.com/search/photos/password?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/201908/20190729 Command line quick tips- More about permissions.md b/published/201908/20190729 Command line quick tips- More about permissions.md new file mode 100644 index 0000000000..bbe0b4c66a --- /dev/null +++ b/published/201908/20190729 Command line quick tips- More about permissions.md @@ -0,0 +1,94 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11185-1.html) +[#]: subject: (Command line quick tips: More about permissions) +[#]: via: (https://fedoramagazine.org/command-line-quick-tips-more-about-permissions/) +[#]: author: (Paul W. Frields https://fedoramagazine.org/author/pfrields/) + +命令行快速提示:权限进阶 +====== + +![][1] + +前一篇文章[介绍了 Fedora 系统上有关文件权限的一些基础知识][2]。本部分介绍使用权限管理文件访问和共享的其他方法。它建立在前一篇文章中的知识和示例的基础上,所以如果你还没有阅读过那篇文章,请[查看][2]它。 + +### 符号与八进制 + +在上一篇文章中,你了解到文件有三个不同的权限集。拥有该文件的用户有一个集合,拥有该文件的组的成员有一个集合,然后最终一个集合适用于其他所有人。在长列表(`ls -l`)中这些权限使用符号模式显示在屏幕上。 + +每个集合都有 `r`、`w` 和 `x` 条目,表示特定用户(所有者、组成员或其他)是否可以读取、写入或执行该文件。但是还有另一种表达这些权限的方法:八进制模式。 + +你已经习惯了[十进制][3]编号系统,它有十个不同的值(`0` 到 `9`)。另一方面,八进制系统有八个不同的值(`0` 到 `7`)。在表示权限时,八进制用作速记来显示 `r`、`w` 和 `x` 字段的值。将每个字段视为具有如下值: + + * `r` = 4 + * `w` = 2 + * `x` = 1 + +现在,你可以使用单个八进制值表达任何组合。例如,读取和写入权限(但没有执行权限)的值为 `6`。读取和执行权限的值仅为 `5`。文件的 `rwxr-xr-x` 符号权限的八进制值为 `755`。 + +与符号值类似,你可以使用八进制值使用 `chmod` 命令设置文件权限。以下两个命令对文件设置相同的权限: + +``` +chmod u=rw,g=r,o=r myfile1 +chmod 644 myfile1 +``` + +### 特殊权限位 + +文件上还有几个特殊权限位。这些被称为 `setuid`(或 `suid`)、`setgid`(或 `sgid`),以及粘滞位sticky bit(或阻止删除位delete inhibit)。 将此视为另一组八进制值: + + * `setuid` = 4 + * `setgid` = 2 + * `sticky` = 1 + +**除非**该文件是可执行的,否则 `setuid` 位是被忽略的。如果是可执行的这种情况,则该文件(可能是应用程序或脚本)的运行就像拥有该文件的用户启动的一样。`setuid` 的一个很好的例子是 `/bin/passwd` 实用程序,它允许用户设置或更改密码。此实用程序必须能够写入到不允许普通用户更改的文件中(LCTT 译注:此处是指 `/etc/passwd` 和 `/etc/shadow`)。因此它需要精心编写,由 `root` 用户拥有,并具有 `setuid` 位,以便它可以更改密码相关文件。 + +`setgid` 位对于可执行文件的工作方式类似。该文件将使用拥有它的组的权限运行。但是,`setgid` 对于目录还有一个额外的用途。如果在具有 `setgid` 权限的目录中创建文件,则该文件的组所有者将设置为该目录的组所有者。 + +最后,虽然文件粘滞位没有意义会被忽略,但它对目录很有用。在目录上设置的粘滞位将阻止用户删除其他用户拥有的该目录中的文件。 + +在八进制模式下使用 `chmod` 设置这些位的方法是添加一个值前缀,例如 `4755`,可以将 `setuid` 添加到可执行文件中。在符号模式下,`u` 和 `g` 也可用于设置或删除 `setuid` 和 `setgid`,例如 `u+s,g+s`。粘滞位使用 `o+t` 设置。(其他的组合,如 `o+s` 或 `u+t`,是没有意义的,会被忽略。) + +### 共享与特殊权限 + +回想一下前一篇文章中关于需要共享文件的财务团队的示例。可以想象,特殊权限位有助于更有效地解决问题。原来的解决方案只是创建了一个整个组可以写入的目录: + +``` +drwxrwx---. 2 root finance 4096 Jul 6 15:35 finance +``` + +此目录的一个问题是,`finance` 组成员的用户 `dwayne` 和 `jill` 可以删除彼此的文件。这对于共享空间来说不是最佳选择。它在某些情况下可能有用,但在处理财务记录时可能不会! + +另一个问题是此目录中的文件可能无法真正共享,因为它们将由 `dwayne` 和 `jill` 的默认组拥有 - 很可能用户私有组也命名为 `dwayne` 和 `jill`,而不是 `finance`。 + +解决此问题的更好方法是在文件夹上设置 `setgid` 和粘滞位。这将做两件事:使文件夹中创建的文件自动归 `finance` 组所有,并防止 `dwayne` 和 `jill` 删除彼此的文件。下面这些命令中的任何一个都可以工作: + +``` +sudo chmod 3770 finance +sudo chmod u+rwx,g+rwxs,o+t finance +``` + +该文件的长列表现在显示了所应用的新特殊权限。粘滞位显示为 `T` 而不是 `t`,因为 `finance` 组之外的用户无法搜索该文件夹。 + +``` +drwxrws--T. 2 root finance 4096 Jul 6 15:35 finance +``` + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/command-line-quick-tips-more-about-permissions/ + +作者:[Paul W. Frields][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2018/10/commandlinequicktips-816x345.jpg +[2]: https://linux.cn/article-11123-1.html +[3]: https://en.wikipedia.org/wiki/Decimal diff --git a/published/201908/20190729 Top 8 Things to do after Installing Debian 10 (Buster).md b/published/201908/20190729 Top 8 Things to do after Installing Debian 10 (Buster).md new file mode 100644 index 0000000000..48264d8479 --- /dev/null +++ b/published/201908/20190729 Top 8 Things to do after Installing Debian 10 (Buster).md @@ -0,0 +1,288 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11178-1.html) +[#]: subject: (Top 8 Things to do after Installing Debian 10 (Buster)) +[#]: via: (https://www.linuxtechi.com/things-to-do-after-installing-debian-10/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +Debian 10(Buster)安装后要做的前 8 件事 +====== + +Debian 10 的代号是 Buster,它是来自 Debian 家族的最新 LTS 发布版本,并包含大量的特色功能。因此,如果你已经在你的电脑上安装了 Debian 10,并在思考接下来该做什么,那么,请继续阅读这篇文章直到结尾,因为我们为你提供在安装 Debian 10 后要做的前 8 件事。对于还没有安装 Debian 10 的人们,请阅读这篇指南 [图解 Debian 10 (Buster) 安装步骤][1]。 让我们继续这篇文章。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Things-to-do-after-installing-debian10.jpg) + +### 1) 安装和配置 sudo + +在设置完成 Debian 10 后,你需要做的第一件事是安装 sudo 软件包,因为它能够使你获得管理员权限来安装你需要的软件包。为安装和配置 sudo,请使用下面的命令: + +变成 root 用户,然后使用下面的命令安装 sudo 软件包, + +``` +root@linuxtechi:~$ su - +Password: +root@linuxtechi:~# apt install sudo -y +``` + +添加你的本地用户到 sudo 组,使用下面的 [usermod][2] 命令, + +``` +root@linuxtechi:~# usermod -aG sudo pkumar +root@linuxtechi:~# +``` + +现在验证是否本地用户获得 sudo 权限: + +``` +root@linuxtechi:~$ id +uid=1000(pkumar) gid=1000(pkumar) groups=1000(pkumar),27(sudo) +root@linuxtechi:~$ sudo vi /etc/hosts +[sudo] password for pkumar: +root@linuxtechi:~$ +``` + +### 2) 校正日期和时间 + +在你成功配置 sudo 软件包后,接下来,你需要根据你的位置来校正日期和时间。为了校正日期和时间, + +转到系统 **设置** –> **详细说明** –> **日期和时间** ,然后更改为适合你的位置的时区。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Adjust-date-time-Debian10.jpg) + +一旦时区被更改,你可以看到时钟中的时间自动更改。 + +### 3) 应用所有更新 + +在 Debian 10 安装后,建议安装所有 Debian 10 软件包存储库中可用的更新,执行下面的 `apt` 命令: + +``` +root@linuxtechi:~$ sudo apt update +root@linuxtechi:~$ sudo apt upgrade -y +``` + +**注意:** 如果你是 vi 编辑器的忠实粉丝,那么使用下面的 `apt` 命令安装 `vim`: + +``` +root@linuxtechi:~$ sudo apt install vim -y +``` + +### 4) 安装 Flash 播放器插件 + +默认情况下,Debian 10(Buster)存储库不包含 Flash 插件,因此,用户需要遵循下面的介绍来在他们的系统中查找和安装 flash 播放器。 + +为 Flash 播放器配置存储库: + +``` +root@linuxtechi:~$ echo "deb http://ftp.de.debian.org/debian buster main contrib" | sudo tee -a /etc/apt/sources.list +deb http://ftp.de.debian.org/debian buster main contrib +root@linuxtechi:~ +``` + +现在使用下面的命令更新软件包索引: + +``` +root@linuxtechi:~$ sudo apt update +``` + +使用下面的 `apt` 命令安装 Flash 插件: + +``` +root@linuxtechi:~$ sudo apt install pepperflashplugin-nonfree -y +``` + +一旦软件包被成功安装,接下来,尝试播放 YouTube 中的视频: + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Flash-Player-plugin-Debian10.jpg) + +### 5) 安装软件,如 VLC、Skype、FileZilla 和截图工具 + +如此,现在我们已经启用 Flash 播放器,是时候在我们的 Debian 10 系统中安装所有其它的软件,如 VLC、Skype,Filezilla 和截图工具(flameshot)。 + +#### 安装 VLC 多媒体播放器 + +为在你的系统中安装 VLC 播放器,使用下面的 `apt` 命令: + +``` +root@linuxtechi:~$ sudo apt install vlc -y +``` + +在成功安装 VLC 播放器后,尝试播放你喜欢的视频。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/Debian10-VLC.jpg) + +#### 安装 Skype + +首先,下载最新的 Skype 软件包: + +``` +root@linuxtechi:~$ wget https://go.skype.com/skypeforlinux-64.deb +``` + +接下来,使用 `apt` 命令安装软件包: + +``` +root@linuxtechi:~$ sudo apt install ./skypeforlinux-64.deb +``` + +在成功安装 Skype 后,尝试访问它,并输入你的用户名和密码。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/skype-Debian10.jpg) + +#### 安装 Filezilla + +为在你的系统中安装 Filezilla,使用下面的 `apt` 命令, + +``` +root@linuxtechi:~$ sudo apt install filezilla -y +``` + +一旦 FileZilla 软件包被成功安装,尝试访问它。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/FileZilla-Debian10.jpg) + +#### 安装截图工具(flameshot) + +使用下面的命令来安装截图工具:flameshot, + +``` +root@linuxtechi:~$ sudo apt install flameshot -y +``` + +**注意:** Shutter 工具在 Debian 10 中已被移除。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/flameshoot-debian10.jpg) + +### 6) 启用和启动防火墙 + +总是建议启动防火墙来使你的网络安全。如果你希望在 Debian 10 中启用防火墙, **UFW**(简单的防火墙)是最好的控制防火墙的工具。UFW 在 Debian 存储库中可用,它非常容易安装,如下: + +``` +root@linuxtechi:~$ sudo apt install ufw +``` + +在你安装 UFW 后,接下来的步骤是设置防火墙。因此,设置防火墙,通过拒绝端口来禁用所有的传入流量,并且只允许需要的端口传出,像 ssh、http 和 https。 + +``` +root@linuxtechi:~$ sudo ufw default deny incoming +Default incoming policy changed to 'deny' +(be sure to update your rules accordingly) +root@linuxtechi:~$ sudo ufw default allow outgoing +Default outgoing policy changed to 'allow' +(be sure to update your rules accordingly) +root@linuxtechi:~$ +``` + +允许 SSH 端口: + +``` +root@linuxtechi:~$ sudo ufw allow ssh +Rules updated +Rules updated (v6) +root@linuxtechi:~$ +``` + +假使你在系统中已经安装 Web 服务器,那么使用下面的 `ufw` 命令来在防火墙中允许它们的端口: + +``` +root@linuxtechi:~$ sudo ufw allow 80 +Rules updated +Rules updated (v6) +root@linuxtechi:~$ sudo ufw allow 443 +Rules updated +Rules updated (v6) +root@linuxtechi:~$ +``` + +最后,你可以使用下面的命令启用 UFW: + +``` +root@linuxtechi:~$ sudo ufw enable +Command may disrupt existing ssh connections. Proceed with operation (y|n)? y +Firewall is active and enabled on system startup +root@linuxtechi:~$ +``` + +假使你想检查你的防火墙的状态,你可以使用下面的命令检查它: + +``` +root@linuxtechi:~$ sudo ufw status +``` + +### 7) 安装虚拟化软件(VirtualBox) + +安装 Virtualbox 的第一步是将 Oracle VirtualBox 存储库的公钥导入到你的 Debian 10 系统: + +``` +root@linuxtechi:~$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - +OK +root@linuxtechi:~$ wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - +OK +root@linuxtechi:~$ +``` + +如果导入成功,你将看到一个 “OK” 显示信息。 + +接下来,你需要添加存储库到仓库列表: + +``` +root@linuxtechi:~$ sudo add-apt-repository "deb http://download.virtualbox.org/virtualbox/debian buster contrib" +root@linuxtechi:~$ +``` + +最后,是时候在你的系统中安装 VirtualBox 6.0: + +``` +root@linuxtechi:~$ sudo apt update +root@linuxtechi:~$ sudo apt install virtualbox-6.0 -y +``` + +一旦 VirtualBox 软件包被成功安装,尝试访问它,并开始创建虚拟机。 + +![](https://www.linuxtechi.com/wp-content/uploads/2019/07/VirtualBox6-Debian10-Workstation.jpg) + +### 8) 安装最新的 AMD 驱动程序 + +最后,你也可以安装需要的附加 AMD 显卡驱动程序(如 ATI 专有驱动)和 Nvidia 图形驱动程序。为安装最新的 AMD 驱动程序,首先,我们需要修改 `/etc/apt/sources.list` 文件,在包含 **main** 和 **contrib** 的行中添加 **non-free** 单词,示例如下显示: + +``` +root@linuxtechi:~$ sudo vi /etc/apt/sources.list +``` + +``` +... +deb http://deb.debian.org/debian/ buster main non-free contrib +deb-src http://deb.debian.org/debian/ buster main non-free contrib + +deb http://security.debian.org/debian-security buster/updates main contrib non-free +deb-src http://security.debian.org/debian-security buster/updates main contrib non-free + +deb http://ftp.us.debian.org/debian/ buster-updates main contrib non-free +... +``` + +现在,使用下面的 `apt` 命令来在 Debian 10 系统中安装最新的 AMD 驱动程序。 + +``` +root@linuxtechi:~$ sudo apt update +root@linuxtechi:~$ sudo apt install firmware-linux firmware-linux-nonfree libdrm-amdgpu1 xserver-xorg-video-amdgpu -y +``` + +这就是这篇文章的全部内容,我希望你了解在安装 Debian 10 后应该做什么。请在下面的评论区,分享你的反馈和评论。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/things-to-do-after-installing-debian-10/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-11083-1.html +[2]: https://www.linuxtechi.com/linux-commands-to-manage-local-accounts/ diff --git a/published/201908/20190730 How to create a pull request in GitHub.md b/published/201908/20190730 How to create a pull request in GitHub.md new file mode 100755 index 0000000000..b92280d6a0 --- /dev/null +++ b/published/201908/20190730 How to create a pull request in GitHub.md @@ -0,0 +1,131 @@ +[#]: collector: "lujun9972" +[#]: translator: "furrybear" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11215-1.html" +[#]: subject: "How to create a pull request in GitHub" +[#]: via: "https://opensource.com/article/19/7/create-pull-request-github" +[#]: author: "Kedar Vijay Kulkarni https://opensource.com/users/kkulkarn" + +如何在 Github 上创建一个拉取请求 +====== + +> 学习如何复刻一个仓库,进行更改,并要求维护人员审查并合并它。 + +![a checklist for a team][1] + +你知道如何使用 git 了,你有一个 [GitHub][2] 仓库并且可以向它推送。这一切都很好。但是你如何为他人的 GitHub 项目做出贡献? 这是我在学习 git 和 GitHub 之后想知道的。在本文中,我将解释如何复刻fork一个 git 仓库、进行更改并提交一个拉取请求pull request。 + +当你想要在一个 GitHub 项目上工作时,第一步是复刻一个仓库。 + +![Forking a GitHub repo][3] + +你可以使用[我的演示仓库][4]试一试。 + +当你在这个页面时,单击右上角的 “Fork”(复刻)按钮。这将在你的 GitHub 用户账户下创建我的演示仓库的一个新副本,其 URL 如下: + +``` +https://github.com/<你的用户名>/demo +``` + +这个副本包含了原始仓库中的所有代码、分支和提交。 + +接下来,打开你计算机上的终端并运行命令来克隆clone仓库: + +``` +git clone https://github.com/<你的用户名>/demo +``` + +一旦仓库被克隆后,你需要做两件事: + +1、通过发出命令创建一个新分支 `new_branch` : + +``` +git checkout -b new_branch +``` + +2、使用以下命令为上游仓库创建一个新的远程remote: + +``` +git remote add upstream https://github.com/kedark3/demo +``` + +在这种情况下,“上游仓库”指的是你创建复刻来自的原始仓库。 + +现在你可以更改代码了。以下代码创建一个新分支,进行任意更改,并将其推送到 `new_branch` 分支: + +``` +$ git checkout -b new_branch +Switched to a new branch ‘new_branch’ +$ echo “some test file” > test +$ cat test +Some test file +$ git status +On branch new_branch +No commits yet +Untracked files: +  (use "git add <file>..." to include in what will be committed) +    test +nothing added to commit but untracked files present (use "git add" to track) +$ git add test +$ git commit -S -m "Adding a test file to new_branch" +[new_branch (root-commit) 4265ec8] Adding a test file to new_branch + 1 file changed, 1 insertion(+) + create mode 100644 test +$ git push -u origin new_branch +Enumerating objects: 3, done. +Counting objects: 100% (3/3), done. +Writing objects: 100% (3/3), 918 bytes | 918.00 KiB/s, done. +Total 3 (delta 0), reused 0 (delta 0) +Remote: Create a pull request for ‘new_branch’ on GitHub by visiting: +Remote:   +Remote: + * [new branch]         new_branch -> new_branch +``` + +一旦你将更改推送到您的仓库后, “Compare & pull request”(比较和拉取请求)按钮将出现在GitHub。 + +![GitHub's Compare & Pull Request button][5] + +单击它,你将进入此屏幕: + +![GitHub's Open pull request button][6] + +单击 “Create pull request”(创建拉取请求)按钮打开一个拉取请求。这将允许仓库的维护者们审查你的贡献。然后,如果你的贡献是没问题的,他们可以合并它,或者他们可能会要求你做一些改变。 + +### 精简版 + +总之,如果您想为一个项目做出贡献,最简单的方法是: + + 1. 找到您想要贡献的项目 + 2. 复刻它 + 3. 将其克隆到你的本地系统 + 4. 建立一个新的分支 + 5. 进行你的更改 + 6. 将其推送回你的仓库 + 7. 单击 “Compare & pull request”(比较和拉取请求)按钮 + 8. 单击 “Create pull request”(创建拉取请求)以打开一个新的拉取请求 + +如果审阅者要求更改,请重复步骤 5 和 6,为你的拉取请求添加更多提交。 + +快乐编码! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/create-pull-request-github + +作者:[Kedar Vijay Kulkarni][a] +选题:[lujun9972][b] +译者:[furrybear](https://github.com/furrybear) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/kkulkarnhttps://opensource.com/users/fontanahttps://opensource.com/users/mhanwellhttps://opensource.com/users/mysentimentshttps://opensource.com/users/greg-p +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk "a checklist for a team" +[2]: https://github.com/ +[3]: https://opensource.com/sites/default/files/uploads/forkrepo.png "Forking a GitHub repo" +[4]: https://github.com/kedark3/demo +[5]: https://opensource.com/sites/default/files/uploads/compare-and-pull-request-button.png "GitHub's Compare & Pull Request button" +[6]: https://opensource.com/sites/default/files/uploads/open-a-pull-request_crop.png "GitHub's Open pull request button" diff --git a/published/201908/20190730 OpenHMD- Open Source Project for VR Development.md b/published/201908/20190730 OpenHMD- Open Source Project for VR Development.md new file mode 100644 index 0000000000..1d4ee0c1aa --- /dev/null +++ b/published/201908/20190730 OpenHMD- Open Source Project for VR Development.md @@ -0,0 +1,77 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11193-1.html) +[#]: subject: (OpenHMD: Open Source Project for VR Development) +[#]: via: (https://itsfoss.com/openhmd/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +OpenHMD:用于 VR 开发的开源项目 +====== + +> 在这个时代,有一些开源替代品可满足你的所有计算需求。甚至还有一个 VR 眼镜之类的开源平台。让我们快速看一下 OpenHMD 这个项目。 + +![][5] + +### 什么是 OpenHMD? + +![][1] + +[OpenHMD][2] 是一个为沉浸式技术创建开源 API 及驱动的项目。这类技术包括带内置头部跟踪的头戴式显示器。 + +它目前支持很多系统,包括 Android、FreeBSD、Linux、OpenBSD、mac OS 和 Windows。它支持的[设备][3]包括 Oculus Rift、HTC Vive、DreamWorld DreamGlass、Playstation Move 等。它还支持各种语言,包括 Go、Java、.NET、Perl、Python 和 Rust。 + +OpenHMD 项目是在 [Boost 许可证][4]下发布的。 + +### 新版本中的更多功能和改进功能 + +最近,OpenHMD 项目[发布版本 0.3.0][6],代号为 Djungelvral([Djungelvral][7] 是来自瑞典的盐渍甘草)。它带来了不少变化。 + +这次更新添加了对以下设备的支持: + + * 3Glasses D3 + * Oculus Rift CV1 + * HTC Vive 和 HTC Vive Pro + * NOLO VR + * Windows Mixed Reality HMD 支持 + * Deepoon E2 + * GearVR Gen1 + +OpenHMD 增加了一个通用扭曲着色器。这一新增功能“可以方便地在驱动程序中设置一些变量,为着色器提供有关镜头尺寸、色差、位置和 Quirks 的信息。” + +他们还宣布计划改变构建系统。OpenHMD 增加了对 Meson 的支持,并将在下一个 (0.4) 版本中将删除对 Autotools 的支持。 + +OpenHMD 背后的团队还不得不删除一些功能,因为他们希望他们的系统适合所有人。由于 Windows 和 mac OS 对 HID 头的兼容问题,因此禁用了对 PlayStation VR 的支持。NOLO 有一堆固件版本,很多都会有小改动。OpenHMD 无法测试所有固件版本,因此某些版本可能无法正常工作。他们建议升级到最新的固件版本。最后,几个设备仅提供有限的支持,因此不包含在此版本中。 + +他们预计将加快 OpenHMD 发布周期,以便更快地获得更新的功能并为用户提供更多设备支持。他们优先要做的是“让当前在主干分支中禁用的设备在下次发布补丁时能够试用,同时让支持的头戴式显示器支持位置跟踪。” + +### 最后总结 + +我没有 VR 设备而且从未使用过。我相信它们有很大的潜力,甚至能超越游戏。我很兴奋(但并不惊讶)有一个开源实现会去支持许多设备。我很高兴他们专注于各种各样的设备,而不是专注于一些非品牌的 VR 的努力。 + +我希望 OpenHMD 团队做得不错,并希望他们创建一个平台,让它们成为 VR项目。 + +你曾经使用或看到过 OpenHMD 吗?你有没有使用 VR 进行游戏和其他用途?如果是,你是否用过任何开源硬件或软件?请在下面的评论中告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/openhmd/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/07/openhmd-logo.png?resize=300%2C195&ssl=1 +[2]: http://www.openhmd.net/ +[3]: http://www.openhmd.net/index.php/devices/ +[4]: https://github.com/OpenHMD/OpenHMD/blob/master/LICENSE +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/virtual-reality-development.jpg?ssl=1 +[6]: http://www.openhmd.net/index.php/2019/07/12/openhmd-0-3-0-djungelvral-released/ +[7]: https://www.youtube.com/watch?v=byP5i6LdDXs +[9]: http://reddit.com/r/linuxusersgroup diff --git a/published/201908/20190731 Bash aliases you can-t live without.md b/published/201908/20190731 Bash aliases you can-t live without.md new file mode 100644 index 0000000000..056c8a2006 --- /dev/null +++ b/published/201908/20190731 Bash aliases you can-t live without.md @@ -0,0 +1,421 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11179-1.html) +[#]: subject: (Bash aliases you can’t live without) +[#]: via: (https://opensource.com/article/19/7/bash-aliases) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +不可或缺的 Bash 别名 +====== + +> 厌倦了一遍又一遍地输入相同的长命令?你觉得在命令行上工作效率低吗?Bash 别名可以为你创造一个与众不同的世界。 + +![](https://img.linux.net.cn/data/attachment/album/201908/03/095855ip0h0jpi5u9t3r00.jpg) + +Bash 别名是一种用新的命令补充或覆盖 Bash 命令的方法。Bash 别名使用户可以轻松地在 [POSIX][2] 终端中自定义其体验。它们通常定义在 `$HOME/.bashrc` 或 `$HOME/bash_aliases` 中(它是由 `$HOME/.bashrc` 加载的)。 + +大多数发行版在新用户帐户的默认 `.bashrc` 文件中至少添加了一些流行的别名。这些可以用来简单演示 Bash 别名的语法: + +``` +alias ls='ls -F' +alias ll='ls -lh' +``` + +但并非所有发行版都附带预先添加好的别名。如果你想手动添加别名,则必须将它们加载到当前的 Bash 会话中: + +``` +$ source ~/.bashrc +``` + +否则,你可以关闭终端并重新打开它,以便重新加载其配置文件。 + +通过 Bash 初始化脚本中定义的那些别名,你可以键入 `ll` 而得到 `ls -l` 的结果,当你键入 `ls` 时,得到也不是原来的 [ls][3] 的普通输出。 + +那些别名很棒,但它们只是浅尝辄止。以下是十大 Bash 别名,一旦你试过它们,你会发现再也不能离开它们。 + +### 首先设置 + +在开始之前,创建一个名为 `~/.bash_aliases` 的文件: + +``` +$ touch ~/.bash_aliases +``` + +然后,确认这些代码出现在你的 `~/.bashrc` 文件当中: + +``` +if [ -e $HOME/.bash_aliases ]; then +    source $HOME/.bash_aliases +fi +``` + +如果你想亲自尝试本文中的任何别名,请将它们输入到 `.bash_aliases` 文件当中,然后使用 `source ~/.bashrc` 命令将它们加载到当前 Bash 会话中。 + +### 按文件大小排序 + +如果你一开始使用过 GNOME 中的 Nautilus、MacOS 中的 Finder 或 Windows 中的资源管理器等 GUI 文件管理器,那么你很可能习惯了按文件大小排序文件列表。你也可以在终端上做到这一点,但这条命令不是很简洁。 + +将此别名添加到 GNU 系统上的配置中: + +``` +alias lt='ls --human-readable --size -1 -S --classify' +``` + +此别名将 `lt` 替换为 `ls` 命令,该命令在单个列中显示每个项目的大小,然后按大小对其进行排序,并使用符号表示文件类型。加载新别名,然后试一下: + +``` +$ source ~/.bashrc +$ lt +total 344K +140K configure* + 44K aclocal.m4 + 36K LICENSE + 32K config.status* + 24K Makefile + 24K Makefile.in + 12K config.log +8.0K README.md +4.0K info.slackermedia.Git-portal.json +4.0K git-portal.spec +4.0K flatpak.path.patch +4.0K Makefile.am* +4.0K dot-gitlab.ci.yml +4.0K configure.ac* +   0 autom4te.cache/ +   0 share/ +   0 bin/ +   0 install-sh@ +   0 compile@ +   0 missing@ +   0 COPYING@ +``` + +在 MacOS 或 BSD 上,`ls` 命令没有相同的选项,因此这个别名可以改为: + +``` +alias lt='du -sh * | sort -h' +``` + +这个版本的结果稍有不同: + +``` +$ du -sh * | sort -h +0       compile +0       COPYING +0       install-sh +0       missing +4.0K    configure.ac +4.0K    dot-gitlab.ci.yml +4.0K    flatpak.path.patch +4.0K    git-portal.spec +4.0K    info.slackermedia.Git-portal.json +4.0K    Makefile.am +8.0K    README.md +12K     config.log +16K     bin +24K     Makefile +24K     Makefile.in +32K     config.status +36K     LICENSE +44K     aclocal.m4 +60K     share +140K    configure +476K    autom4te.cache +``` + +实际上,即使在 Linux上,上面这个命令也很有用,因为使用 `ls` 列出的目录和符号链接的大小为 0,这可能不是你真正想要的信息。使用哪个看你自己的喜好。 + +*感谢 Brad Alexander 提供的这个别名的思路。* + +### 只查看挂载的驱动器 + +`mount` 命令过去很简单。只需一个命令,你就可以获得计算机上所有已挂载的文件系统的列表,它经常用于概览连接到工作站有哪些驱动器。在过去看到超过三、四个条目就会令人印象深刻,因为大多数计算机没有那么多的 USB 端口,因此这个结果还是比较好查看的。 + +现在计算机有点复杂,有 LVM、物理驱动器、网络存储和虚拟文件系统,`mount` 的结果就很难一目了然: + +``` +sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel) +proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) +devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=8131024k,nr_inodes=2032756,mode=755) +securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime) +[...] +/dev/nvme0n1p2 on /boot type ext4 (rw,relatime,seclabel) +/dev/nvme0n1p1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro) +[...] +gvfsd-fuse on /run/user/100977/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=100977,group_id=100977) +/dev/sda1 on /run/media/seth/pocket type ext4 (rw,nosuid,nodev,relatime,seclabel,uhelper=udisks2) +/dev/sdc1 on /run/media/seth/trip type ext4 (rw,nosuid,nodev,relatime,seclabel,uhelper=udisks2) +binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime) +``` + +要解决这个问题,试试这个别名: + +``` +alias mnt='mount | awk -F' ' '{ printf "%s\t%s\n",$1,$3; }' | column -t | egrep ^/dev/ | sort' +``` + +此别名使用 `awk` 按列解析 `mount` 的输出,将输出减少到你可能想要查找的内容(挂载了哪些硬盘驱动器,而不是文件系统): + +``` +$ mnt +/dev/mapper/fedora-root  / +/dev/nvme0n1p1           /boot/efi +/dev/nvme0n1p2           /boot +/dev/sda1                /run/media/seth/pocket +/dev/sdc1                /run/media/seth/trip +``` + +在 MacOS 上,`mount` 命令不提供非常详细的输出,因此这个别名可能过度精简了。但是,如果你更喜欢简洁的报告,请尝试以下方法: + +``` +alias mnt='mount | grep -E ^/dev | column -t' +``` + +结果: + +``` +$ mnt +/dev/disk1s1  on  /                (apfs,  local,  journaled) +/dev/disk1s4  on  /private/var/vm  (apfs,  local,  noexec,     journaled,  noatime,  nobrowse) +``` + +### 在你的 grep 历史中查找命令 + +有时你好不容易弄清楚了如何在终端完成某件事,并觉得自己永远不会忘记你刚学到的东西。然后,一个小时过去之后你就完全忘记了你做了什么。 + +搜索 Bash 历史记录是每个人不时要做的事情。如果你确切地知道要搜索的内容,可以使用 `Ctrl + R` 对历史记录进行反向搜索,但有时你无法记住要查找的确切命令。 + +这是使该任务更容易的别名: + +``` +alias gh='history|grep' +``` + +这是如何使用的例子: + +``` +$ gh bash +482 cat ~/.bashrc | grep _alias +498 emacs ~/.bashrc +530 emacs ~/.bash_aliases +531 source ~/.bashrc +``` + +### 按修改时间排序 + +每个星期一都会这样:你坐在你的电脑前开始工作,你打开一个终端,你发现你已经忘记了上周五你在做什么。你需要的是列出最近修改的文件的别名。 + +你可以使用 `ls` 命令创建别名,以帮助你找到上次离开的位置: + +``` +alias left='ls -t -1' +``` + +输出很简单,但如果你愿意,可以使用 `--long` 选项扩展它。这个别名列出的显示如下: + +``` +$ left +demo.jpeg +demo.xcf +design-proposal.md +rejects.txt +brainstorm.txt +query-letter.xml +``` + +### 文件计数 + +如果你需要知道目录中有多少文件,那么该解决方案是 UNIX 命令构造的最典型示例之一:使用 `ls` 命令列出文件,用`-1` 选项将其输出控制为只有一列,然后输出到 `wc`(单词计数)命令的管道,以计算有多少行。 + +这是 UNIX 理念如何允许用户使用小型的系统组件构建自己的解决方案的精彩演示。如果你碰巧每天都要做几次,这个命令组合也要输入很多字母,如果没有使用 `-R` 选项,它就不能用于目录,这会为输出引入新行并导致无用的结果。 + +而这个别名使这个过程变得简单: + +``` +alias count='find . -type f | wc -l' +``` + +这个别名会计算文件,忽略目录,但**不会**忽略目录的内容。如果你有一个包含两个目录的项目文件夹,每个目录包含两个文件,则该别名将返回 4,因为整个项目中有 4 个文件。 + +``` +$ ls +foo   bar +$ count +4 +``` + +### 创建 Python 虚拟环境 + +你用 Python 编程吗? + +你用 Python 编写了很多程序吗? + +如果是这样,那么你就知道创建 Python 虚拟环境至少需要 53 次击键。 + +这个数字里有 49 次是多余的,它很容易被两个名为 `ve` 和 `va` 的新别名所解决: + +``` +alias ve='python3 -m venv ./venv' +alias va='source ./venv/bin/activate' +``` + +运行 `ve` 会创建一个名为 `venv` 的新目录,其中包含 Python 3 的常用虚拟环境文件系统。`va` 别名在当前 shell 中的激活该环境: + +``` +$ cd my-project +$ ve +$ va +(venv) $ +``` + +### 增加一个复制进度条 + +每个人都会吐槽进度条,因为它们似乎总是不合时宜。然而,在内心深处,我们似乎都想要它们。UNIX 的 `cp` 命令没有进度条,但它有一个 `-v` 选项用于显示详细信息,它回显了复制的每个文件名到终端。这是一个相当不错的技巧,但是当你复制一个大文件并且想要了解还有多少文件尚未传输时,它的作用就没那么大了。 + +`pv` 命令可以在复制期间提供进度条,但它并不常用。另一方面,`rsync` 命令包含在几乎所有的 POSIX 系统的默认安装中,并且它被普遍认为是远程和本地复制文件的最智能方法之一。 + +更好的是,它有一个内置的进度条。 + +``` +alias cpv='rsync -ah --info=progress2' +``` + +像使用 `cp` 命令一样使用此别名: + +``` +$ cpv bigfile.flac /run/media/seth/audio/ +          3.83M 6%  213.15MB/s    0:00:00 (xfr#4, to-chk=0/4) +``` + +使用此命令的一个有趣的副作用是 `rsync` 无需 `-r` 标志就可以复制文件和目录,而 `cp` 则需要。 + +### 避免意外删除 + +你不应该使用 `rm` 命令。`rm` 手册甚至这样说: + +> **警告:**如果使用 `rm` 删除文件,通常可以恢复该文件的内容。如果你想要更加确保内容真正无法恢复,请考虑使用 `shred`。 + +如果要删除文件,则应将文件移动到“废纸篓”,就像使用桌面时一样。 + +POSIX 使这很简单,因为垃圾桶是文件系统中可访问的一个实际位置。该位置可能会发生变化,具体取决于你的平台:在 [FreeDesktop][4] 上,“垃圾桶”位于 `~/.local/share/Trash`,而在 MacOS 上则是 `~/.Trash`,但无论如何,它只是一个目录,你可以将文件藏在那个看不见的地方,直到你准备永久删除它们为止。 + +这个简单的别名提供了一种从终端将文件扔进垃圾桶的方法: + +``` +alias tcn='mv --force -t ~/.local/share/Trash ' +``` + +该别名使用一个鲜为人知的 `mv` 标志(`-t`),使你能够提供作为最终移动目标的参数,而忽略了首先列出要移动的文件的通常要求。现在,你可以使用新命令将文件和文件夹移动到系统垃圾桶: + +``` +$ ls +foo  bar +$ tcn foo +$ ls +bar +``` + +现在文件已“消失”,只有在你一头冷汗的时候才意识到你还需要它。此时,你可以从系统垃圾桶中抢救该文件;这肯定可以给 Bash 和 `mv` 开发人员提供一些帮助。 + +**注意:**如果你需要一个具有更好的 FreeDesktop 兼容性的更强大的垃圾桶命令,请参阅 [Trashy][5]。 + +### 简化 Git 工作流 + +每个人都有自己独特的工作流程,但无论如何,通常都会有重复的任务。如果你经常使用 Git,那么你可能会发现自己经常重复的一些操作序列。也许你会发现自己回到主分支并整天一遍又一遍地拉取最新的变化,或者你可能发现自己创建了标签然后将它们推到远端,抑或可能完全是其它的什么东西。 + +无论让你厌倦一遍遍输入的 Git 魔咒是什么,你都可以通过 Bash 别名减轻一些痛苦。很大程度上,由于它能够将参数传递给钩子,Git 拥有着丰富的内省命令,可以让你不必在 Bash 中执行那些丑陋冗长的命令。 + +例如,虽然你可能很难在 Bash 中找到项目的顶级目录(就 Bash 而言,它是一个完全随意的名称,因为计算机的绝对顶级是根目录),但 Git 可以通过简单的查询找到项目的顶级目录。如果你研究过 Git 钩子,你会发现自己能够找到 Bash 一无所知的各种信息,而你可以利用 Bash 别名来利用这些信息。 + +这是一个来查找 Git 项目的顶级目录的别名,无论你当前在哪个项目中工作,都可以将目录改变为顶级目录,切换到主分支,并执行 Git 拉取: + +``` +alias startgit='cd `git rev-parse --show-toplevel` && git checkout master && git pull' +``` + +这种别名绝不是一个普遍有用的别名,但它演示了一个相对简单的别名如何能够消除大量繁琐的导航、命令和等待提示。 + +一个更简单,可能更通用的别名将使你返回到 Git 项目的顶级目录。这个别名非常有用,因为当你在一个项目上工作时,该项目或多或少会成为你的“临时家目录”。它应该像回家一样简单,就像回你真正的家一样,这里有一个别名: + +``` +alias cg='cd `git rev-parse --show-toplevel`' +``` + +现在,命令 `cg` 将你带到 Git 项目的顶部,无论你下潜的目录结构有多深。 + +### 切换目录并同时查看目录内容 + +(据称)曾经一位著名科学家提出过,我们可以通过收集极客输入 `cd` 后跟 `ls` 消耗的能量来解决地球上的许多能量问题。 + +这是一种常见的用法,因为通常当你更改目录时,你都会有查看周围的内容的冲动或需要。 + +但是在你的计算机的目录树中移动并不一定是一个走走停停的过程。 + +这是一个作弊,因为它根本不是别名,但它是探索 Bash 功能的一个很好的借口。虽然别名非常适合快速替换一个命令,但 Bash 也允许你在 `.bashrc` 文件中添加本地函数(或者你加载到 `.bashrc` 中的单独函数文件,就像你的别名文件一样)。 + +为了保持模块化,创建一个名为 `~/.bash_functions` 的新文件,然后让你的 `.bashrc` 加载它: + +``` +if [ -e $HOME/.bash_functions ]; then +    source $HOME/.bash_functions +fi +``` + +在该函数文件中,添加这些代码: + +``` +function cl() { +    DIR="$*"; +        # if no DIR given, go home +        if [ $# -lt 1 ]; then +                DIR=$HOME; +    fi; +    builtin cd "${DIR}" && \ +    # use your preferred ls command +        ls -F --color=auto +} +``` + +将函数加载到 Bash 会话中,然后尝试: + +``` +$ source ~/.bash_functions +$ cl Documents +foo bar baz +$ pwd +/home/seth/Documents +$ cl .. +Desktop  Documents  Downloads +[...] +$ pwd +/home/seth +``` + +函数比别名更灵活,但有了这种灵活性,你就有责任确保代码有意义并达到你的期望。别名是简单的,所以要保持简单而有用。要正式修改 Bash 的行为,请使用保存到 `PATH` 环境变量中某个位置的函数或自定义的 shell 脚本。 + +附注,有一些巧妙的奇技淫巧来实现 `cd` 和 `ls` 序列作为别名,所以如果你足够耐心,那么即使是一个简单的别名也永无止限。 + +### 开始别名化和函数化吧 + +可以定制你的环境使得 Linux 变得如此有趣,提高效率使得 Linux 可以改变生活。开始使用简单的别名,进而使用函数,并在评论中发布你必须拥有的别名! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/bash-aliases + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bash_command_line.png?itok=k4z94W2U (bash logo on green background) +[2]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[3]: https://opensource.com/article/19/7/master-ls-command +[4]: https://www.freedesktop.org/wiki/ +[5]: https://gitlab.com/trashy/trashy diff --git a/published/201908/20190801 5 Free Partition Managers for Linux.md b/published/201908/20190801 5 Free Partition Managers for Linux.md new file mode 100644 index 0000000000..09a078fed0 --- /dev/null +++ b/published/201908/20190801 5 Free Partition Managers for Linux.md @@ -0,0 +1,124 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11196-1.html) +[#]: subject: (5 Free Partition Managers for Linux) +[#]: via: (https://itsfoss.com/partition-managers-linux/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +5 个免费的 Linux 分区管理器 +====== + +> 以下是我们推荐的 Linux 分区工具。它们能让你删除、添加、调整或缩放 Linux 系统上的磁盘分区。 + +通常,你在安装操作系统时决定磁盘分区。但是,如果你需要在安装后的某个时间修改分区,该怎么办?你无法回到系统安装阶段。因此,这就需要分区管理器(或准确地说是磁盘分区管理器)上场了。 + +在大多数情况下,你无需单独安装分区管理器,因为它已预先安装。此外,值得注意的是,你可以选择基于命令行或有 GUI 的分区管理器。 + +**注意!** + +> 磁盘分区是一项有风险的任务。除非绝对必要,否则不要这样做。 +> +> 如果你使用的是基于命令行的分区工具,那么需要学习完成任务的命令。否则,你可能最终会擦除整个磁盘。 + +### Linux 中的 5 个管理磁盘分区的工具 + +![][1] + +下面的列表没有特定的排名顺序。大多数分区工具应该存在于 Linux 发行版的仓库中。 + +#### GParted + +![GParted][2] + +这可能是 Linux 发行版中最流行的基于 GUI 的分区管理器。你可能已在某些发行版中预装它。如果还没有,只需在软件中心搜索它即可完成安装。 + +它会在启动时直接提示你以 root 用户进行身份验证。所以,你根本不需要在这里使用终端。身份验证后,它会分析设备,然后让你调整磁盘分区。如果发生数据丢失或意外删除文件,你还可以找到“尝试数据救援”的选项。 + +- [GParted][3] + +#### GNOME Disks + +![Gnome Disks][4] + +一个基于 GUI 的分区管理器,随 Ubuntu 或任何基于 Ubuntu 的发行版(如 Zorin OS)一起出现。 + +它能让你删除、添加、缩放和微调分区。如果你遇到故障,它甚至可以[在 Ubuntu 中格式化 USB][6] 来帮助你救援机器。 + +你甚至可以借助此工具尝试修复分区。它的选项还包括编辑文件系统、创建分区镜像、还原镜像以及对分区进行基准测试。 + +- [GNOME Disks][7] + +#### KDE Partition Manager + +![Kde Partition Manager][8] + +KDE Partition Manager 应该已经预装在基于 KDE 的 Linux 发行版上了。但是,如果没有,你可以在软件中心搜索并轻松安装它。 + +如果你不是预装的,那么可能会在尝试启动时通知你没有管理权限。没有管理员权限,你无法做任何事情。因此,在这种情况下,请输入以下命令: + +``` +sudo partitionmanager +``` + +它将扫描你的设备,然后你就可以创建、移动、复制、删除和缩放分区。你还可以导入/导出分区表及使用其他许多调整选项。 + +- [KDE Partition Manager][9] + +#### Fdisk(命令行) + +![Fdisk][10] + +[fdisk][11] 是一个命令行程序,它在每个类 Unix 的系统中都有。不要担心,即使它需要你启动终端并输入命令,但这并不是很困难。但是,如果你在使用基于文本的程序时感到困惑,那么你应该继续使用上面提到的 GUI 程序。它们都做同样的事情。 + +要启动 `fdisk`,你必须是 root 用户并指定管理分区的设备。以下是该命令的示例: + +``` +sudo fdisk /dev/sdc +``` + +你可以参考 [Linux 文档项目的维基页面][12]以获取命令列表以及有关其工作原理的更多详细信息。 + +#### GNU Parted(命令行) + +![Gnu Parted][13] + +这是在你 Linux 发行版上预安装的另一个命令行程序。你需要输入下面的命令启动: + +``` +sudo parted +``` + +### 总结 + +我不会忘了说 [QtParted][15] 是分区管理器的替代品之一。但它已经几年没有维护,因此我不建议使用它。 + +你如何看待这里提到的分区管理器?我有错过你最喜欢的吗?让我知道,我将根据你的建议更新这个 Linux 分区管理器列表。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/partition-managers-linux/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/disk-partitioning-tools-linux.jpg?resize=800%2C450&ssl=1 +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/07/g-parted.png?ssl=1 +[3]: https://gparted.org/ +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/gnome-disks.png?ssl=1 +[6]: https://itsfoss.com/format-usb-drive-sd-card-ubuntu/ +[7]: https://wiki.gnome.org/Apps/Disks +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/kde-partition-manager.jpg?resize=800%2C404&ssl=1 +[9]: https://kde.org/applications/system/org.kde.partitionmanager +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/07/fdisk.jpg?fit=800%2C496&ssl=1 +[11]: https://en.wikipedia.org/wiki/Fdisk +[12]: https://www.tldp.org/HOWTO/Partition/fdisk_partitioning.html +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/07/gnu-parted.png?fit=800%2C559&ssl=1 +[15]: http://qtparted.sourceforge.net/ diff --git a/published/201908/20190801 Bash Script to Send a Mail When a New User Account is Created in System.md b/published/201908/20190801 Bash Script to Send a Mail When a New User Account is Created in System.md new file mode 100644 index 0000000000..b030243efe --- /dev/null +++ b/published/201908/20190801 Bash Script to Send a Mail When a New User Account is Created in System.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11199-1.html) +[#]: subject: (Bash Script to Send a Mail When a New User Account is Created in System) +[#]: via: (https://www.2daygeek.com/linux-bash-script-to-monitor-user-creation-send-email/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +在系统创建新用户时发送邮件的 Bash 脚本 +====== + +![](https://img.linux.net.cn/data/attachment/album/201908/07/232807l7x4j7y77555j1j5.jpg) + +目前市场上有许多开源监测工具可用于监控 Linux 系统的性能。当系统到达指定的阈值时,它将发送邮件提醒。 + +它会监控 CPU 利用率、内存利用率、交换内存利用率、磁盘空间利用率等所有内容。但我不认为它们可以选择监控新用户创建活动,并发送提醒。 + +如果没有,这并不重要,因为我们可以编写自己的 bash 脚本来实现这一点。 + +我们过去写了许多有用的 shell 脚本。如果要查看它们,请点击以下链接。 + +* [如何使用 shell 脚本自动化执行日常任务?][1] + +这个脚本做了什么?它监测 `/var/log/secure` 文件,并在系统创建新帐户时提醒管理员。 + +我们不会经常运行此脚本,因为创建用户不经常发生。但是,我打算一天运行一次这个脚本。因此,我们可以获得有关用户创建的综合报告。 + +如果在昨天的 `/var/log/secure` 中找到了 “useradd” 字符串,那么该脚本将向指定的邮箱发送邮件提醒,其中包含了新用户的详细信息。 + +**注意:**你需要更改邮箱而不是使用我们的邮箱。 + +``` +# vi /opt/scripts/new-user.sh +``` + +``` +#!/bin/bash + +#Set the variable which equal to zero +prev_count=0 +count=$(grep -i "`date --date='yesterday' '+%b %e'`" /var/log/secure | egrep -wi 'useradd' | wc -l) + +if [ "$prev_count" -lt "$count" ] ; then + # Send a mail to given email id when errors found in log + SUBJECT="ATTENTION: New User Account is created on server : `date --date='yesterday' '+%b %e'`" + # This is a temp file, which is created to store the email message. + MESSAGE="/tmp/new-user-logs.txt" + TO="2daygeek@gmail.com" + echo "Hostname: `hostname`" >> $MESSAGE + echo -e "\n" >> $MESSAGE + echo "The New User Details are below." >> $MESSAGE + echo "+------------------------------+" >> $MESSAGE + grep -i "`date --date='yesterday' '+%b %e'`" /var/log/secure | egrep -wi 'useradd' | grep -v 'failed adding'| awk '{print $4,$8}' | uniq | sed 's/,/ /' >> $MESSAGE + echo "+------------------------------+" >> $MESSAGE + mail -s "$SUBJECT" "$TO" < $MESSAGE + rm $MESSAGE +fi +``` + +给 `new-user.sh` 添加可执行权限。 + +``` +$ chmod +x /opt/scripts/new-user.sh +``` + +最后添加一个 cron 任务来自动化执行它。它会在每天 7 点运行。 + +``` +# crontab -e + +0 7 * * * /bin/bash /opt/scripts/new-user.sh +``` + +注意:你将在每天 7 点收到一封邮件提醒,但这是昨天的日志。 + +你将会看到类似下面的邮件提醒。 + +``` +# cat /tmp/logs.txt + +Hostname: 2g.server10.com + +The New User Details are below. ++------------------------------+ +2g.server10.com name=magesh +2g.server10.com name=daygeek ++------------------------------+ +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-bash-script-to-monitor-user-creation-send-email/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/category/shell-script/ diff --git a/published/201908/20190802 Linux Smartphone Librem 5 is Available for Preorder.md b/published/201908/20190802 Linux Smartphone Librem 5 is Available for Preorder.md new file mode 100644 index 0000000000..3c9cc4e7f0 --- /dev/null +++ b/published/201908/20190802 Linux Smartphone Librem 5 is Available for Preorder.md @@ -0,0 +1,88 @@ +[#]: collector: (lujun9972) +[#]: translator: (scvoet) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11229-1.html) +[#]: subject: (Linux Smartphone Librem 5 is Available for Preorder) +[#]: via: (https://itsfoss.com/librem-5-available/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +基于 Linux 的智能手机 Librem 5 开启预售 +====== + +Purism 近期[宣布][1]了 [Librem 5 智能手机][2]的最终规格。它不是基于 Android 或 iOS 的,而是基于 [Android 的开源替代品][4]--[PureOS][3]。 + +随着这一消息的宣布,Librem 5 也正式[以 649 美元的价格开启预售][5](这是 7 月 31 日前的早鸟价),在那以后价格将会上涨 50 美元,产品将会于 2019 年第三季度发货。 + +![][6] + +以下是 Purism 博客文章中关于 Librem 5 的信息: + +> 我们认为手机不应该跟踪你,也不应该利用你的数字生活。 + +> Librem 5 意味着你有机会通过自由开源软件、开放式治理和透明度来收回和保护你的私人信息和数字生活。Librem 5 是一个**基于 [PureOS][3] 的手机**,这是一个完全免费、符合道德的**不基于 Android 或 iOS** 的开源操作系统(了解更多关于[为什么这很重要][7]的信息)。 + +> 我们已成功超额完成了众筹计划,我们将会一一去实现我们的承诺。Librem 5 的硬件和软件开发正在[稳步前进][8],它计划在 2019 年的第三季度发行初始版本。你可以用 649 美元的价格预购直到产品发货或正式价格生效。现在附赠外接显示器、键盘和鼠标的套餐也可以预购了。 + +### Librem 5 的配置 + +从它的预览来看,Librem 5 旨在提供更好的隐私保护和安全性。除此之外,它试图避免使用 Google 或 Apple 的服务。 + +虽然这个想法够好,它是如何成为一款低于 700 美元的商用智能手机? + +![Librem 5 智能手机][9] + +让我们来看一下它的配置: + +![Librem 5][10] + +从数据上讲它的配置已经足够高了。不是很好,也不是很差。但是,性能呢?用户体验呢? + +我们并不能够确切地了解到它的信息,除非我们用过它。所以,如果你打算预购,应该要考虑到这一点。 + +### Librem 5 提供终身软件更新支持 + +当然,和同价位的智能手机相比,它的这些配置并不是很优秀。 + +然而,随着他们做出终身软件更新支持的承诺后,它看起来确实像被开源爱好者所钟情的一个好产品。 + +### 其他关键特性 + +Purism 还强调 Librem 5 将成为有史以来第一款以 [Matrix][12] 提供支持的智能手机。这意味着它将支持端到端的分布式加密通讯的短信、电话。 + +除了这些,耳机接口和用户可以自行更换电池使它成为一个可靠的产品。 + +### 总结 + +即使它很难与 Android 或 iOS 智能手机竞争,但多一种选择方式总是好的。Librem 5 不可能成为每个用户都喜欢的智能手机,但如果你是一个开源爱好者,而且正在寻找一款尊重隐私和安全,不使用 Google 和 Apple 服务的简单智能手机,那么这就很适合你。 + +另外,它提供终身的软件更新支持,这让它成为了一个优秀的智能手机。 + +你如何看待 Librem 5?有在考虑预购吗?请在下方的评论中将你的想法告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/librem-5-available/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[Scvoet][c] +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[c]: https://github.com/scvoet +[1]: https://puri.sm/posts/librem-5-smartphone-final-specs-announced/ +[2]: https://itsfoss.com/librem-linux-phone/ +[3]: https://pureos.net/ +[4]: https://itsfoss.com/open-source-alternatives-android/ +[5]: https://shop.puri.sm/shop/librem-5/ +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/librem-5-linux-smartphone.jpg?resize=800%2C450&ssl=1 +[7]: https://puri.sm/products/librem-5/pureos-mobile/ +[8]: https://puri.sm/posts/tag/phones +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/librem-5-smartphone.jpg?ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/07/librem-5-specs.png?ssl=1 +[11]: https://itsfoss.com/linux-games-performance-boost-amd-gpu/ +[12]: http://matrix.org diff --git a/published/201908/20190802 Use Postfix to get email from your Fedora system.md b/published/201908/20190802 Use Postfix to get email from your Fedora system.md new file mode 100644 index 0000000000..f6dce46a4d --- /dev/null +++ b/published/201908/20190802 Use Postfix to get email from your Fedora system.md @@ -0,0 +1,173 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11224-1.html) +[#]: subject: (Use Postfix to get email from your Fedora system) +[#]: via: (https://fedoramagazine.org/use-postfix-to-get-email-from-your-fedora-system/) +[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/) + +使用 Postfix 从 Fedora 系统中获取电子邮件 +====== + +![][1] + +交流是非常重要的。你的电脑可能正试图告诉你一些重要的事情。但是,如果你没有正确配置邮件传输代理([MTA][2]),那么你可能不会收到通知。Postfix 是一个[易于配置且以强大的安全记录而闻名][3]的 MTA。遵循以下步骤,以确保从本地服务发送的电子邮件通知将通过 Postfix MTA 路由到你的互联网电子邮件账户中。 + +### 安装软件包 + +使用 `dnf` 来安装一些必须软件包([你应该配置了 sudo,对吧?][4]): + +``` +$ sudo -i +# dnf install postfix mailx +``` + +如果以前配置了不同的 MTA,那么你可能需要将 Postfix 设置为系统默认。使用 `alternatives` 命令设置系统默认 MTA: + +``` +$ sudo alternatives --config mta +There are 2 programs which provide 'mta'. + Selection Command +*+ 1 /usr/sbin/sendmail.sendmail + 2 /usr/sbin/sendmail.postfix +Enter to keep the current selection[+], or type selection number: 2 +``` + +### 创建一个 password_maps 文件 + +你需要创建一个 Postfix 查询表条目,其中包含你要用于发送电子邮件账户的地址和密码: + +``` +# MY_EMAIL_ADDRESS=glb@gmail.com +# MY_EMAIL_PASSWORD=abcdefghijklmnop +# MY_SMTP_SERVER=smtp.gmail.com +# MY_SMTP_SERVER_PORT=587 +# echo "[$MY_SMTP_SERVER]:$MY_SMTP_SERVER_PORT $MY_EMAIL_ADDRESS:$MY_EMAIL_PASSWORD" >> /etc/postfix/password_maps +# chmod 600 /etc/postfix/password_maps +# unset MY_EMAIL_PASSWORD +# history -c +``` + +如果你使用的是 Gmail 账户,那么你需要为 Postfix 配置一个“应用程序密码”而不是使用你的 Gmail 密码。有关配置应用程序密码的说明,参阅“[使用应用程序密码登录][5]”。 + +接下来,你必须对 Postfix 查询表运行 `postmap` 命令,以创建或更新 Postfix 实际使用的文件的散列版本: + +``` +# postmap /etc/postfix/password_maps +``` + +散列后的版本将具有相同的文件名,但后缀为 `.db`。 + +### 更新 main.cf 文件 + +更新 Postfix 的 `main.cf` 配置文件,以引用刚刚创建 Postfix 查询表。编辑该文件并添加以下行: + +``` +relayhost = smtp.gmail.com:587 +smtp_tls_security_level = verify +smtp_tls_mandatory_ciphers = high +smtp_tls_verify_cert_match = hostname +smtp_sasl_auth_enable = yes +smtp_sasl_security_options = noanonymous +smtp_sasl_password_maps = hash:/etc/postfix/password_maps +``` + +这里假设你使用 Gmail 作为 `relayhost` 设置,但是你可以用正确的主机名和端口替换系统应该将邮件发送到的邮件主机。 + +有关上述配置选项的最新详细信息,参考 man 帮助: + +``` +$ man postconf.5 +``` + +### 启用、启动和测试 Postfix + +更新 `main.cf` 文件后,启用并启动 Postfix 服务: + +``` +# systemctl enable --now postfix.service +``` + +然后,你可以使用 `exit` 命令或 `Ctrl+D` 以 root 身份退出 `sudo` 会话。你现在应该能够使用 `mail` 命令测试你的配置: + +``` +$ echo 'It worked!' | mail -s "Test: $(date)" glb@gmail.com +``` + +### 更新服务 + +如果你安装了像 [logwatch][6]、[mdadm][7]、[fail2ban][8]、[apcupsd][9] 或 [certwatch][10] 这样的服务,你现在可以更新它们的配置,以便它们的电子邮件通知转到你的 Internet 电子邮件地址。 + +另外,你可能希望将发送到本地系统 root 账户的所有电子邮件都转到互联网电子邮件地址中,将以下行添加到系统的 `/etc/alises` 文件中(你需要使用 `sudo` 编辑此文件,或首先切换到 `root` 账户): + +``` +root: glb+root@gmail.com +``` + +现在运行此命令重新读取别名: + +``` +# newaliases +``` + +* 提示: 如果你使用的是 Gmail,那么你可以在用户名和 `@` 符号之间[添加字母数字标记][11],如上所示,以便更轻松地识别和过滤从计算机收到的电子邮件。 + +### 常用命令 + +**查看邮件队列:** + +``` +$ mailq +``` + +**清除队列中的所有电子邮件:** + +``` +# postsuper -d ALL +``` + +**过滤设置,以获得感兴趣的值:** + +``` +$ postconf | grep "^relayhost\|^smtp_" +``` + +**查看 `postfix/smtp` 日志:** + +``` +$ journalctl --no-pager -t postfix/smtp +``` + +**进行配置更改后重新加载 postfix:** + +``` +$ systemctl reload postfix +``` + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/use-postfix-to-get-email-from-your-fedora-system/ + +作者:[Gregory Bartholomew][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/glb/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/07/postfix-816x345.jpg +[2]: https://en.wikipedia.org/wiki/Message_transfer_agent +[3]: https://en.wikipedia.org/wiki/Postfix_(software) +[4]: https://fedoramagazine.org/howto-use-sudo/ +[5]: https://support.google.com/accounts/answer/185833 +[6]: https://src.fedoraproject.org/rpms/logwatch +[7]: https://fedoramagazine.org/mirror-your-system-drive-using-software-raid/ +[8]: https://fedoraproject.org/wiki/Fail2ban_with_FirewallD +[9]: https://src.fedoraproject.org/rpms/apcupsd +[10]: https://www.linux.com/learn/automated-certificate-expiration-checks-centos +[11]: https://gmail.googleblog.com/2008/03/2-hidden-ways-to-get-more-from-your.html +[12]: https://unsplash.com/@sharonmccutcheon?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[13]: https://unsplash.com/search/photos/envelopes?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/201908/20190803 The fastest open source CPU ever, Facebook shares AI algorithms fighting harmful content, and more news.md b/published/201908/20190803 The fastest open source CPU ever, Facebook shares AI algorithms fighting harmful content, and more news.md new file mode 100644 index 0000000000..d721d097c0 --- /dev/null +++ b/published/201908/20190803 The fastest open source CPU ever, Facebook shares AI algorithms fighting harmful content, and more news.md @@ -0,0 +1,80 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11187-1.html) +[#]: subject: (The fastest open source CPU ever, Facebook shares AI algorithms fighting harmful content, and more news) +[#]: via: (https://opensource.com/article/19/8/news-august-3) +[#]: author: (Lauren Maffeo https://opensource.com/users/lmaffeo) + +开源新闻综述:有史以来最快的开源 CPU、Facebook 分享对抗有害内容的 AI 算法 +====== + +> 不要错过最近两周最大的开源新闻。 + +![Weekly news roundup with TV][1] + +在本期开源新闻综述中,我们分享了 Facebook 开源了两种算法来查找有害内容,Apple 在数据传输项目中的新角色以及你应该知道的更多新闻。 + +### Facebook 开源算法用于查找有害内容 + +Facebook 宣布它[开源两种算法][2]用于在该平台上发现儿童剥削、恐怖主义威胁和写实暴力。在 8 月 1 日的博客文章中,Facebook 分享了 PDQ 和 TMK + PDQF 这两种将文件存储为数字哈希的技术,然后将它们与已知的有害内容示例进行比较 - [现在已放在 GitHub 上][3]。 + +该代码是在 Facebook 要尽快将有害内容从平台上移除的压力之下发布的。三月份在新西兰的大规模谋杀案被曝光在 Facebook Live 上,澳大利亚政府[威胁][4]如果视频没有及时删除 Facebook 高管将被处以罚款和入狱。通过发布这些算法的源代码,Facebook 表示希望非营利组织、科技公司和独立开发人员都能帮助他们更快地找到并删除有害内容。 + +### 阿里巴巴发布了最快的开源 CPU + +上个月,阿里巴巴的子公司平头哥半导体公司[发布了其玄铁 91 处理器][5]。它可以用于人工智能、物联网、5G 和自动驾驶汽车等基础设施。它拥有 7.1 Coremark/MHz 的基准,使其成为市场上最快的开源 CPU。 + +平头哥宣布计划在今年 9 月在 GitHub 上提供其优质代码。分析师认为此次发布旨在帮助中国实现其目标,即到 2021 年使用本地供应商满足 40% 的处理器需求。近期美国的关税调整威胁要破坏这一目标,从而造成了对开源计算机组件的需求。 + +### Mattermost 为开源协作应用提供了理由 + +所有开源社区都受益于可以从一个或多个地方彼此进行通信。团队聊天应用程序的世界似乎由 Slack 和 Microsoft Teams 等极少数的强大工具主导。大多数选择都是基于云的和专有产品的;而 Mattermost 采用了不同的方法,销售开源协作应用程序的价值。 + +“人们想要一个开源替代品,因为他们需要信任、灵活性和只有开源才能提供的创新,”Mattermost 的联合创始人兼首席执行官 Ian Tien 说。 + +随着从优步到国防部的客户,Mattermost 走上了一个关键市场:需要开源软件的团队,他们可以信任这些软件并安装在他们自己的服务器上。对于需要协作应用程序在其内部基础架构上运行的企业,Mattermost 填补了 [Atlassian 离开后][6] 的空白。在 Computerworld 的一篇文章中,Matthew Finnegan [探讨][7]了为什么在本地部署的开源聊天工具尚未死亡。 + +### Apple 加入了开源数据传输项目 + +Google、Facebook、Twitter 和微软去年联合创建了数据传输项目Data Transfer Project(DTP)。DTP 被誉为通过自己的数据提升数据安全性和用户代理的一种方式,是一种罕见的技术上的团结展示。本周,Apple 宣布他们也将[加入][8]。 + +DTP 的目标是帮助用户通过开源平台将数据从一个在线服务转移到另一个在线服务。DTP 旨在通过使用 API 和授权工具来取消中间人,以便用户将数据从一个服务转移到另一个服务。这将消除用户下载数据然后将其上传到另一个服务的需要。Apple 加入 DTP 的选择将允许用户将数据传入和传出 iCloud,这可能是隐私权拥护者的一大胜利。 + +#### 其它新闻 + +* [FlexiWAN 的开源 SD-WAN 可在公共测试版中下载] [9] +* [开源的 Windows 计算器应用程序获得了永远置顶模式] [10] +* [通过 Zowe,开源和 DevOps 正在使大型计算机民主化] [11] +* [Mozilla 首次推出 WebThings Gateway 开源路由器固件的实现] [12] +* [更新:向 Mozilla 代码库做成贡献][13] + +*谢谢 Opensource.com 的工作人员和主持人本周的帮助。* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/news-august-3 + +作者:[Lauren Maffeo][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lmaffeo +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/weekly_news_roundup_tv.png?itok=B6PM4S1i (Weekly news roundup with TV) +[2]: https://www.theverge.com/2019/8/1/20750752/facebook-child-exploitation-terrorism-open-source-algorithm-pdq-tmk +[3]: https://github.com/facebook/ThreatExchange/tree/master/hashing/tmk +[4]: https://www.buzzfeed.com/hannahryan/social-media-facebook-livestreaming-laws-christchurch +[5]: https://hexus.net/tech/news/cpu/133229-alibabas-16-core-risc-v-fastest-open-source-cpu-yet/ +[6]: https://lab.getapp.com/atlassian-slack-on-premise-software/ +[7]: https://www.computerworld.com/article/3428679/mattermost-makes-case-for-open-source-as-team-messaging-market-booms.html +[8]: https://www.techspot.com/news/81221-apple-joins-data-transfer-project-open-source-project.html +[9]: https://www.fiercetelecom.com/telecom/flexiwan-s-open-source-sd-wan-available-for-download-public-beta-release +[10]: https://mspoweruser.com/open-source-windows-calculator-app-to-get-always-on-top-mode/ +[11]: https://siliconangle.com/2019/07/29/zowe-open-source-devops-democratizing-mainframe-computer/ +[12]: https://venturebeat.com/2019/07/25/mozilla-debuts-webthings-gateway-open-source-router-firmware-for-turris-omnia/ +[13]: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Introduction diff --git a/published/201908/20190805 4 cool new projects to try in COPR for August 2019.md b/published/201908/20190805 4 cool new projects to try in COPR for August 2019.md new file mode 100644 index 0000000000..741d098f5c --- /dev/null +++ b/published/201908/20190805 4 cool new projects to try in COPR for August 2019.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11206-1.html) +[#]: subject: (4 cool new projects to try in COPR for August 2019) +[#]: via: (https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-august-2019/) +[#]: author: (Dominik Turecek https://fedoramagazine.org/author/dturecek/) + +COPR 仓库中 4 个很酷的新项目(2019.8) +====== + +![][1] + +COPR 是个人软件仓库[集合][2],它不在 Fedora 中。这是因为某些软件不符合轻松打包的标准;或者它可能不符合其他 Fedora 标准,尽管它是自由而开源的。COPR 可以在 Fedora 套件之外提供这些项目。COPR 中的软件不受 Fedora 基础设施的支持,或者是由项目自己背书的。但是,这是一种尝试新的或实验性的软件的一种巧妙的方式。 + +这是 COPR 中一组新的有趣项目。 + +### Duc + +[duc][3] 是磁盘使用率检查和可视化工具的集合。Duc 使用索引数据库来保存系统上文件的大小。索引完成后,你可以通过命令行界面或 GUI 快速查看磁盘使用情况。 + +![][4] + +#### 安装说明 + +该[仓库][5]目前为 EPEL 7、Fedora 29 和 30 提供 duc。要安装 duc,请使用以下命令: + +``` +sudo dnf copr enable terrywang/duc +sudo dnf install duc +``` + +### MuseScore + +[MuseScore][6] 是一个处理音乐符号的软件。使用 MuseScore,你可以使用鼠标、虚拟键盘或 MIDI 控制器创建乐谱。然后,MuseScore 可以播放创建的音乐或将其导出为 PDF、MIDI 或 MusicXML。此外,它还有一个由 MuseScore 用户创建的含有大量乐谱的数据库。 + +![][7] + +#### 安装说明 + +该[仓库][5]目前为 Fedora 29 和 30 提供 MuseScore。要安装 MuseScore,请使用以下命令: + +``` +sudo dnf copr enable jjames/MuseScore +sudo dnf install musescore +``` + +### 动态墙纸编辑器 + +[动态墙纸编辑器][9] 是一个可在 GNOME 中创建和编辑随时间变化的壁纸集合的工具。这可以使用 XML 文件来完成,但是,动态墙纸编辑器通过其图形界面使其变得简单,你可以在其中简单地添加图片、排列图片并设置每张图片的持续时间以及它们之间的过渡。 + +![][10] + +#### 安装说明 + +该[仓库][11]目前为 Fedora 30 和 Rawhide 提供动态墙纸编辑器。要安装它,请使用以下命令: + +``` +sudo dnf copr enable atim/dynamic-wallpaper-editor +sudo dnf install dynamic-wallpaper-editor +``` + +### Manuskript + +[Manuskript][12] 是一个给作者的工具,旨在让创建大型写作项目更容易。它既可以作为编写文本的编辑器,也可以作为组织故事本身、故事人物和单个情节的注释的工具。 + +![][13] + +#### 安装说明 + +该[仓库][14]目前为 Fedora 29、30 和 Rawhide 提供 Manuskript。要安装 Manuskript,请使用以下命令: + +``` +sudo dnf copr enable notsag/manuskript +sudo dnf install manuskript +``` + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-august-2019/ + +作者:[Dominik Turecek][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/dturecek/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2017/08/4-copr-945x400.jpg +[2]: https://copr.fedorainfracloud.org/ +[3]: https://duc.zevv.nl/ +[4]: https://fedoramagazine.org/wp-content/uploads/2019/07/duc.png +[5]: https://copr.fedorainfracloud.org/coprs/terrywang/duc/ +[6]: https://musescore.org/ +[7]: https://fedoramagazine.org/wp-content/uploads/2019/07/musescore-1024x512.png +[8]: https://copr.fedorainfracloud.org/coprs/jjames/MuseScore/ +[9]: https://github.com/maoschanz/dynamic-wallpaper-editor +[10]: https://fedoramagazine.org/wp-content/uploads/2019/07/dynamic-walppaper-editor.png +[11]: https://copr.fedorainfracloud.org/coprs/atim/dynamic-wallpaper-editor/ +[12]: https://www.theologeek.ch/manuskript/ +[13]: https://fedoramagazine.org/wp-content/uploads/2019/07/manuskript-1024x600.png +[14]: https://copr.fedorainfracloud.org/coprs/notsag/manuskript/ diff --git a/published/201908/20190805 Find The Linux Distribution Name, Version And Kernel Details.md b/published/201908/20190805 Find The Linux Distribution Name, Version And Kernel Details.md new file mode 100644 index 0000000000..f133239088 --- /dev/null +++ b/published/201908/20190805 Find The Linux Distribution Name, Version And Kernel Details.md @@ -0,0 +1,182 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11270-1.html) +[#]: subject: (Find The Linux Distribution Name, Version And Kernel Details) +[#]: via: (https://www.ostechnix.com/find-out-the-linux-distribution-name-version-and-kernel-details/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +查找 Linux 发行版名称、版本和内核详细信息 +====== + +![Find The Linux Distribution Name, Version And Kernel Details][1] + +本指南介绍了如何查找 Linux 发行版名称、版本和内核详细信息。如果你的 Linux 系统有 GUI 界面,那么你可以从系统设置中轻松找到这些信息。但在命令行模式下,初学者很难找到这些详情。没有问题!我这里给出了一些命令行方法来查找 Linux 系统信息。可能有很多,但这些方法适用于大多数 Linux 发行版。 + +### 1、查找 Linux 发行版名称、版本 + +有很多方法可以找出 VPS 中运行的操作系统。 + +#### 方法 1: + +打开终端并运行以下命令: + +``` +$ cat /etc/*-release +``` + +CentOS 7 上的示例输出: + +``` +CentOS Linux release 7.0.1406 (Core) +NAME="CentOS Linux" +VERSION="7 (Core)" +ID="centos" +ID_LIKE="rhel fedora" +VERSION_ID="7" +PRETTY_NAME="CentOS Linux 7 (Core)" +ANSI_COLOR="0;31" +CPE_NAME="cpe:/o:centos:centos:7" +HOME_URL="https://www.centos.org/" +BUG_REPORT_URL="https://bugs.centos.org/" + +CentOS Linux release 7.0.1406 (Core) +CentOS Linux release 7.0.1406 (Core) +``` + +Ubuntu 18.04 上的示例输出: + +``` +DISTRIB_ID=Ubuntu +DISTRIB_RELEASE=18.04 +DISTRIB_CODENAME=bionic +DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS" +NAME="Ubuntu" +VERSION="18.04.2 LTS (Bionic Beaver)" +ID=ubuntu +ID_LIKE=debian +PRETTY_NAME="Ubuntu 18.04.2 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 +``` + +#### 方法 2: + +以下命令也能获取你发行版的详细信息。 + +``` +$ cat /etc/issue +``` + +Ubuntu 18.04 上的示例输出: + +``` +Ubuntu 18.04.2 LTS \n \l +``` + +#### 方法 3: + +以下命令能在 Debian 及其衍生版如 Ubuntu、Linux Mint 上获取发行版详细信息。 + +``` +$ lsb_release -a +``` + +示例输出: + +``` +No LSB modules are available. +Distributor ID: Ubuntu +Description: Ubuntu 18.04.2 LTS +Release: 18.04 +Codename: bionic +``` + +### 2、查找 Linux 内核详细信息 + +#### 方法 1: + +要查找 Linux 内核详细信息,请在终端运行以下命令。 + +``` +$ uname -a +``` + +CentOS 7 上的示例输出: + +``` +Linux server.ostechnix.lan 3.10.0-123.9.3.el7.x86_64 #1 SMP Thu Nov 6 15:06:03 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux +``` + +Ubuntu 18.04 上的示例输出: + +``` +Linux ostechnix 4.18.0-25-generic #26~18.04.1-Ubuntu SMP Thu Jun 27 07:28:31 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux +``` + +或者, + +``` +$ uname -mrs +``` + +示例输出: + +``` +Linux 4.18.0-25-generic x86_64 +``` + +这里, + + * `Linux` – 内核名 + * `4.18.0-25-generic` – 内核版本 + * `x86_64` – 系统硬件架构(即 64 位系统) + +有关 `uname` 命令的更多详细信息,请参考手册页。 + +``` +$ man uname +``` + +#### 方法2: + +在终端中,运行以下命令: + +``` +$ cat /proc/version +``` + +CentOS 7 上的示例输出: + +``` +Linux version 3.10.0-123.9.3.el7.x86_64 ([email protected]) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) ) #1 SMP Thu Nov 6 15:06:03 UTC 2014 +``` + +Ubuntu 18.04 上的示例输出: + +``` +Linux version 4.18.0-25-generic ([email protected]) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #26~18.04.1-Ubuntu SMP Thu Jun 27 07:28:31 UTC 2019 +``` + +这些是查找 Linux 发行版的名称、版本和内核详细信息的几种方法。希望你觉得它有用。 + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/find-out-the-linux-distribution-name-version-and-kernel-details/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2015/08/Linux-Distribution-Name-Version-Kernel-720x340.png diff --git a/published/201908/20190805 GameMode - A Tool To Improve Gaming Performance On Linux.md b/published/201908/20190805 GameMode - A Tool To Improve Gaming Performance On Linux.md new file mode 100644 index 0000000000..423a6a06f5 --- /dev/null +++ b/published/201908/20190805 GameMode - A Tool To Improve Gaming Performance On Linux.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11211-1.html) +[#]: subject: (GameMode – A Tool To Improve Gaming Performance On Linux) +[#]: via: (https://www.ostechnix.com/gamemode-a-tool-to-improve-gaming-performance-on-linux/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +GameMode:提高 Linux 游戏性能的工具 +====== + +![Gamemmode improve gaming performance on Linux][1] + +去问一些 Linux 用户为什么他们仍然坚持 Windows 双启动,他们的答案可能是 - “游戏!”。这是真的!幸运的是,开源游戏平台如 [Lutris][2] 和专有游戏平台 Steam 已经为 Linux 平台带来了许多游戏,并且近几年来显著改善了 Linux 的游戏体验。今天,我偶然发现了另一款名为 GameMode 的 Linux 游戏相关开源工具,它能让用户提高 Linux 上的游戏性能。 + +GameMode 基本上是一组守护进程/库,它可以按需优化 Linux 系统的游戏性能。我以为 GameMode 是一个杀死在后台运行的对资源消耗大进程的工具。但它并不是。它实际上只是让 CPU **在用户玩游戏时自动运行在高性能模式下**并帮助 Linux 用户从游戏中获得最佳性能。 + +在玩游戏时,GameMode 通过对宿主机请求临时应用一组优化来显著提升游戏性能。目前,它支持下面这些优化: + +* CPU 调控器, +* I/O 优先级, +* 进程 nice 值 +* 内核调度器(SCHED_ISO), +* 禁止屏幕保护, +* GPU 高性能模式(NVIDIA 和 AMD),GPU 超频(NVIDIA), +* 自定义脚本。 + +GameMode 是由世界领先的游戏发行商 [Feral Interactive][3] 开发的自由开源的系统工具。 + +### 安装 GameMode + +GameMode 适用于许多 Linux 发行版。 + +在 Arch Linux 及其变体上,你可以使用任何 AUR 助手程序,如 [Yay][5] 从 [AUR][4] 安装它。 + +``` +$ yay -S gamemode +``` + +在 Debian、Ubuntu、Linux Mint 和其他基于 Deb 的系统上: + +``` +$ sudo apt install gamemode +``` + +如果 GameMode 不适用于你的系统,你可以按照它的 Github 页面中开发章节下的描述从源码手动编译和安装它。 + +### 激活 GameMode 支持以改善 Linux 上的游戏性能 + +以下是集成支持了 GameMode 的游戏列表,因此我们无需进行任何其他配置即可激活 GameMode 支持。 + + * 古墓丽影:崛起 + * 全面战争传奇:不列颠尼亚王座 + * 全面战争:战锤 2 + * 尘埃 4 + * 全面战争:三国 + +只需运行这些游戏,就会自动启用 GameMode 支持。 + +这里还有将 GameMode 与 GNOME shell 集成的的[扩展][6]。它会在顶部指示 GameMode 何时处于活跃。 + +对于其他游戏,你可能需要手动请求 GameMode 支持,如下所示。 + +``` +gamemoderun ./game +``` + +我不喜欢游戏,并且我已经很多年没玩游戏了。所以,我无法分享一些实际的基准测试。 + +但是,我在 Youtube 上找到了一个简短的[视频教程](https://youtu.be/4gyRyYfyGJw),以便为 Lutris 游戏启用 GameMode 支持。对于那些想要第一次尝试 GameMode 的人来说,这是个不错的开始。 + +通过浏览视频中的评论,我可以说 GameMode 确实提高了 Linux 上的游戏性能。 + +对于更多细节,请参阅 [GameMode 的 GitHub 仓库][7]。 + +相关阅读: + +* [GameHub – 将所有游戏集合在一起的仓库][8] +* [如何在 Linux 中运行 MS-DOS 游戏和程序][9] + +你用过 GameMode 吗?它真的有改善 Linux 上的游戏性能吗?请在下面的评论栏分享你的想法。 + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/gamemode-a-tool-to-improve-gaming-performance-on-linux/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/07/Gamemode-720x340.png +[2]: https://www.ostechnix.com/manage-games-using-lutris-linux/ +[3]: http://www.feralinteractive.com/en/ +[4]: https://aur.archlinux.org/packages/gamemode/ +[5]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ +[6]: https://github.com/gicmo/gamemode-extension +[7]: https://github.com/FeralInteractive/gamemode +[8]: https://www.ostechnix.com/gamehub-an-unified-library-to-put-all-games-under-one-roof/ +[9]: https://www.ostechnix.com/how-to-run-ms-dos-games-and-programs-in-linux/ diff --git a/published/201908/20190805 How To Add ‘New Document- Option In Right Click Context Menu In Ubuntu 18.04.md b/published/201908/20190805 How To Add ‘New Document- Option In Right Click Context Menu In Ubuntu 18.04.md new file mode 100644 index 0000000000..bc993a7595 --- /dev/null +++ b/published/201908/20190805 How To Add ‘New Document- Option In Right Click Context Menu In Ubuntu 18.04.md @@ -0,0 +1,109 @@ +[#]: collector: (lujun9972) +[#]: translator: (scvoet) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11232-1.html) +[#]: subject: (How To Add ‘New Document’ Option In Right Click Context Menu In Ubuntu 18.04) +[#]: via: ((https://www.ostechnix.com/how-to-add-new-document-option-in-right-click-context-menu-in-ubuntu-18-04/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +如何在 Ubuntu 18.04 的右键单击菜单中添加“新建文档”按钮 +====== + +![Add 'New Document' Option In Right Click Context Menu In Ubuntu 18.04 GNOME desktop][1] + +前几天,我在各种在线资源站点上收集关于 [Linux 包管理器][2] 的参考资料。在我想创建一个用于保存笔记的文件,我突然发现我的 Ubuntu 18.04 LTS 桌面并没有“新建文件”的按钮了,它好像离奇失踪了。在谷歌一下后,我发现原来“新建文档”按钮不再被集成在 Ubuntu GNOME 版本中了。庆幸的是,我找到了一个在 Ubuntu 18.04 LTS 桌面的右键单击菜单中添加“新建文档”按钮的简易解决方案。 + +就像你在下方截图中看到的一样,Nautilus 文件管理器的右键单击菜单中并没有“新建文件”按钮。 + +![][3] + +*Ubuntu 18.04 移除了右键点击菜单中的“新建文件”的选项。* + +如果你想添加此按钮,请按照以下步骤进行操作。 + +### 在 Ubuntu 的右键单击菜单中添加“新建文件”按钮 + +首先,你需要确保你的系统中有 `~/Templates` 文件夹。如果没有的话,可以按照下面的命令进行创建。 + +``` +$ mkdir ~/Templates +``` + +然后打开终端应用并使用 `cd` 命令进入 `~/Templates` 文件夹: + +``` +$ cd ~/Templates +``` + +创建一个空文件: + +``` +$ touch Empty\ Document +``` + +或 + +``` +$ touch "Empty Document" +``` + +![][4] + +新打开一个 Nautilus 文件管理器,然后检查一下右键单击菜单中是否成功添加了“新建文档”按钮。 + +![][5] + +*在 Ubuntu 18.04 的右键单击菜单中添加“新建文件”按钮* + +如上图所示,我们重新启用了“新建文件”的按钮。 + +你还可以为不同文件类型添加按钮。 + +``` +$ cd ~/Templates + +$ touch New\ Word\ Document.docx +$ touch New\ PDF\ Document.pdf +$ touch New\ Text\ Document.txt +$ touch New\ PyScript.py +``` + +![][6] + +在“新建文件”子菜单中给不同的文件类型添加按钮 + +注意,所有文件都应该创建在 `~/Templates` 文件夹下。 + +现在,打开 Nautilus 并检查“新建文件” 菜单中是否有相应的新建文件按钮。 + +![][7] + +如果你要从子菜单中删除任一文件类型,只需在 Templates 目录中移除相应的文件即可。 + +``` +$ rm ~/Templates/New\ Word\ Document.docx +``` + +我十分好奇为什么最新的 Ubuntu GNOME 版本将这个常用选项移除了。不过,重新启用这个按钮也十分简单,只需要几分钟。 + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-add-new-document-option-in-right-click-context-menu-in-ubuntu-18-04/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[scvoet](https://github.com/scvoet) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux 中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/07/Add-New-Document-Option-In-Right-Click-Context-Menu-1-720x340.png +[2]: https://www.ostechnix.com/linux-package-managers-compared-appimage-vs-snap-vs-flatpak/ +[3]: https://www.ostechnix.com/wp-content/uploads/2019/07/new-document-option-missing.png +[4]: https://www.ostechnix.com/wp-content/uploads/2019/07/Create-empty-document-in-Templates-directory.png +[5]: https://www.ostechnix.com/wp-content/uploads/2019/07/Add-New-Document-Option-In-Right-Click-Context-Menu-In-Ubuntu.png +[6]: https://www.ostechnix.com/wp-content/uploads/2019/07/Add-options-for-different-files-types.png +[7]: https://www.ostechnix.com/wp-content/uploads/2019/07/Add-New-Document-Option-In-Right-Click-Context-Menu.png diff --git a/published/201908/20190805 How To Find Hardware Specifications On Linux.md b/published/201908/20190805 How To Find Hardware Specifications On Linux.md new file mode 100644 index 0000000000..453b19f74c --- /dev/null +++ b/published/201908/20190805 How To Find Hardware Specifications On Linux.md @@ -0,0 +1,341 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11194-1.html) +[#]: subject: (How To Find Hardware Specifications On Linux) +[#]: via: (https://www.ostechnix.com/getting-hardwaresoftware-specifications-in-linux-mint-ubuntu/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +如何在 Linux 上查找硬件规格 +====== + +![](https://img.linux.net.cn/data/attachment/album/201908/06/111717t1f77n7v3egxhf18.jpg) + +在 Linux 系统上有许多工具可用于查找硬件规格。在这里,我列出了四种最常用的工具,可以获取 Linux 系统的几乎所有硬件(和软件)细节。好在是这些工具在某些 Linux 发行版上默认预装。我在 Ubuntu 18.04 LTS 桌面上测试了这些工具,但是它们也适用于其他 Linux 发行版。 + +### 1、LSHW + +lshw(硬件列表)是一个简单但功能齐全的实用程序,它提供了 Linux 系统上的硬件规格的详细信息。它可以报告确切的内存规格、固件版本、主板规格、CPU 版本和速度、缓存规格、总线速度等。信息可以以纯文本、XML 或 HTML 格式输出。 + +它目前支持 DMI(仅限 x86 和 EFI)、Open Firmware 设备树(仅限 PowerPC)、PCI/AGP、ISA PnP(x86)、CPUID(x86)、IDE/ATA/ATAPI、PCMCIA(仅在 x86 上测试过)、USB 和 SCSI。 + +就像我已经说过的那样,Ubuntu 默认预装了 lshw。如果它未安装在你的 Ubuntu 系统中,请使用以下命令安装它: + +``` +$ sudo apt install lshw lshw-gtk +``` + +在其他 Linux 发行版上,例如 Arch Linux,运行: + +``` +$ sudo pacman -S lshw lshw-gtk +``` + +安装后,运行 `lshw` 以查找系统硬件详细信息: + +``` +$ sudo lshw +``` + +你将看到输出详细的系统硬件。 + +示例输出: + +![][2] + +*使用 lshw 在 Linux 上查找硬件规格* + +请注意,如果你没有以 `sudo` 权限运行 `lshw` 命令,则输出可能不完整或不准确。 + +`lshw` 可以将输出显示为 HTML 页面。为此,请使用: + +``` +$ sudo lshw -html +``` + +同样,我们可以将设备树输出为 XML 和 json 格式,如下所示: + +``` +$ sudo lshw -xml +$ sudo lshw -json +``` + +要输出显示硬件路径的设备树,请使用 `-short` 选项: + +``` +$ sudo lshw -short +``` + +![][3] + +*使用 lshw 显示具有硬件路径的设备树* + +要列出设备的总线信息、详细的 SCSI、USB、IDE 和 PCI 地址,请运行: + +``` +$ sudo lshw -businfo +``` + +默认情况下,`lshw` 显示所有硬件详细信息。你还可以使用类选项查看特定硬件详细信息的硬件信息,例如处理器、内存、显示器等。可以使用 `lshw -short` 或 `lshw -businfo` 找到类选项。 + +要显示特定硬件详细信息,例如处理器,请执行以下操作: + +``` +$ sudo lshw -class processor +``` + +示例输出: + +``` +*-cpu +description: CPU +product: Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz +vendor: Intel Corp. +physical id: 4 +bus info: [email protected] +version: Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz +serial: To Be Filled By O.E.M. +slot: CPU 1 +size: 913MHz +capacity: 2300MHz +width: 64 bits +clock: 100MHz +capabilities: x86-64 fpu fpu_exception wp 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 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 ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm arat pln pts md_clear flush_l1d cpufreq +configuration: cores=2 enabledcores=1 threads=2 +``` + +类似的,你可以得到系统细节: + +``` +$ sudo lshw -class system +``` + +硬盘细节: + +``` +$ sudo lshw -class disk +``` + +网络细节: + +``` +$ sudo lshw -class network +``` + +内存细节: + +``` +$ sudo lshw -class memory +``` + +你也可以像下面这样列出多个设备的细节: + +``` +$ sudo lshw -class storage -class power -class volume +``` + +如果你想要查看带有硬件路径的细节信息,加上 `-short` 选项即可: + +``` +$ sudo lshw -short -class processor +``` + +示例输出: + +``` +H/W path Device Class Description +======================================================= +/0/4 processor Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz +``` + +有时,你可能希望将某些硬件详细信息共享给别人,例如客户支持人员。如果是这样,你可以从输出中删除潜在的敏感信息,如 IP 地址、序列号等,如下所示。 + +``` +$ lshw -sanitize +``` + +#### lshw-gtk GUI 工具 + +如果你对 CLI 不熟悉,可以使用 `lshw-gtk`,这是 `lshw` 命令行工具的图形界面。 + +它可以从终端或 Dash 中打开。 + +要从终端启动它,只需执行以下操作: + +``` +$ sudo lshw-gtk +``` + +这是 `lshw` 工具的默认 GUI 界面。 + +![][4] + +*使用 lshw-gtk 在 Linux 上查找硬件* + +只需双击“Portable Computer”即可进一步展开细节。 + +![][5] + +*使用 lshw-gtk GUI 在 Linux 上查找硬件* + +你可以双击后续的硬件选项卡以获取详细视图。 + +有关更多详细信息,请参阅手册页。 + +``` +$ man lshw +``` + +### 2、Inxi + +Inxi 是我查找 Linux 系统上几乎所有内容的另一个最喜欢的工具。它是一个自由开源的、功能齐全的命令行系统信息工具。它显示了系统硬件、CPU、驱动程序、Xorg、桌面、内核、GCC 版本、进程、RAM 使用情况以及各种其他有用信息。无论是硬盘还是 CPU、主板还是整个系统的完整细节,inxi 都能在几秒钟内更准确地显示它。由于它是 CLI 工具,你可以在桌面或服务器版本中使用它。有关更多详细信息,请参阅以下指南。 + +* [如何使用 inxi 发现系统细节][6] + +### 3、Hardinfo + +Hardinfo 将为你提供 `lshw` 中没有的系统硬件和软件详细信息。 + +HardInfo 可以收集有关系统硬件和操作系统的信息,执行基准测试,并以 HTML 或纯文本格式生成可打印的报告。 + +如果 Ubuntu 中未安装 Hardinfo,请使用以下命令安装: + +``` +$ sudo apt install hardinfo +``` + +安装后,Hardinfo 工具可以从终端或菜单中进行。 + +以下是 Hardinfo 默认界面的外观。 + +![][7] + +*使用 Hardinfo 在 Linux 上查找硬件* + +正如你在上面的屏幕截图中看到的,Hardinfo 的 GUI 简单直观。 + +所有硬件信息分为四个主要组:计算机、设备、网络和基准。每个组都显示特定的硬件详细信息。 + +例如,要查看处理器详细信息,请单击“设备”组下的“处理器”选项。 + +![][8] + +*使用 hardinfo 显示处理器详细信息* + +与 `lshw` 不同,Hardinfo 可帮助你查找基本软件规范,如操作系统详细信息、内核模块、区域设置信息、文件系统使用情况、用户/组和开发工具等。 + +![][9] + +*使用 hardinfo 显示操作系统详细信息* + +Hardinfo 的另一个显着特点是它允许我们做简单的基准测试来测试 CPU 和 FPU 功能以及一些图形用户界面功能。 + +![][10] + +*使用 hardinfo 执行基准测试* + +建议阅读: + +* [Phoronix 测试套件 - 开源测试和基准测试工具][11] +* [UnixBench - 类 Unix 系统的基准套件][12] +* [如何从命令行对 Linux 命令和程序进行基准测试][13] + +我们可以生成整个系统以及各个设备的报告。要生成报告,只需单击菜单栏上的“生成报告”按钮,然后选择要包含在报告中的信息。 + +![][14] + +*使用 hardinfo 生成系统报告* + +Hardinfo 也有几个命令行选项。 + +例如,要生成报告并在终端中显示它,请运行: + +``` +$ hardinfo -r +``` + +列出模块: + +``` +$ hardinfo -l +``` + +更多信息请参考手册: + +``` +$ man hardinfo +``` + +### 4、Sysinfo + +Sysinfo 是 HardInfo 和 lshw-gtk 实用程序的另一个替代品,可用于获取下面列出的硬件和软件信息。 + +* 系统详细信息,如发行版版本、GNOME 版本、内核、gcc 和 Xorg 以及主机名。 +* CPU 详细信息,如供应商标识、型号名称、频率、L2 缓存、型号和标志。 +* 内存详细信息,如系统全部内存、可用内存、交换空间总量和空闲、缓存、活动/非活动的内存。 +* 存储控制器,如 IDE 接口、所有 IDE 设备、SCSI 设备。 +* 硬件详细信息,如主板、图形卡、声卡和网络设备。 + +让我们使用以下命令安装 sysinfo: + +``` +$ sudo apt install sysinfo +``` + +Sysinfo 可以从终端或 Dash 启动。 + +要从终端启动它,请运行: + +``` +$ sysinfo +``` + +这是 Sysinfo 实用程序的默认界面。 + +![][15] + +*sysinfo 界面* + +如你所见,所有硬件(和软件)详细信息都分为五类,即系统、CPU、内存、存储和硬件。单击导航栏上的类别以获取相应的详细信息。 + +![][16] + +*使用 Sysinfo 在 Linux 上查找硬件* + +更多细节可以在手册页上找到。 + +``` +$ man sysinfo +``` + +就这样。就像我已经提到的那样,可以有很多工具可用于显示硬件/软件规范。但是,这四个工具足以找到你的 Linux 发行版的所有软硬件规格信息。 + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/getting-hardwaresoftware-specifications-in-linux-mint-ubuntu/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[2]: https://www.ostechnix.com/wp-content/uploads/2013/01/Find-Hardware-Specifications-On-Linux-using-lshw-1.png +[3]: https://www.ostechnix.com/wp-content/uploads/2013/01/Show-device-tree-with-hardware-path-using-lshw.png +[4]: https://www.ostechnix.com/wp-content/uploads/2013/01/Find-Hardware-Specifications-On-Linux-using-lshw-gtk-1.png +[5]: https://www.ostechnix.com/wp-content/uploads/2013/01/Find-Hardware-Specifications-On-Linux-using-lshw-gtk-2.png +[6]: https://www.ostechnix.com/how-to-find-your-system-details-using-inxi/ +[7]: https://www.ostechnix.com/wp-content/uploads/2013/01/Find-Hardware-Specifications-On-Linux-Using-Hardinfo.png +[8]: https://www.ostechnix.com/wp-content/uploads/2013/01/Show-processor-details-using-hardinfo.png +[9]: https://www.ostechnix.com/wp-content/uploads/2013/01/Show-operating-system-details-using-hardinfo.png +[10]: https://www.ostechnix.com/wp-content/uploads/2013/01/Perform-benchmarks-using-hardinfo.png +[11]: https://www.ostechnix.com/phoronix-test-suite-open-source-testing-benchmarking-tool/ +[12]: https://www.ostechnix.com/unixbench-benchmark-suite-unix-like-systems/ +[13]: https://www.ostechnix.com/how-to-benchmark-linux-commands-and-programs-from-commandline/ +[14]: https://www.ostechnix.com/wp-content/uploads/2013/01/Generate-system-reports-using-hardinfo.png +[15]: https://www.ostechnix.com/wp-content/uploads/2013/01/sysinfo-interface.png +[16]: https://www.ostechnix.com/wp-content/uploads/2013/01/Find-Hardware-Specifications-On-Linux-Using-Sysinfo.png diff --git a/published/201908/20190805 How To Set Up Time Synchronization On Ubuntu.md b/published/201908/20190805 How To Set Up Time Synchronization On Ubuntu.md new file mode 100644 index 0000000000..22254d2f1c --- /dev/null +++ b/published/201908/20190805 How To Set Up Time Synchronization On Ubuntu.md @@ -0,0 +1,240 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11220-1.html) +[#]: subject: (How To Set Up Time Synchronization On Ubuntu) +[#]: via: (https://www.ostechnix.com/how-to-set-up-time-synchronization-on-ubuntu/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +如何在 Ubuntu 上设置时间同步 +====== + +![](https://img.linux.net.cn/data/attachment/album/201908/13/135423xnk7zib00nn2aebv.jpg) + +你可能设置过 [cron 任务][2] 来在特定时间备份重要文件或执行系统相关任务。也许你配置了一个日志服务器在特定时间间隔[轮转日志][3]。但如果你的时钟不同步,这些任务将无法按时执行。这就是要在 Linux 系统上设置正确的时区并保持时钟与互联网同步的原因。本指南介绍如何在 Ubuntu Linux 上设置时间同步。下面的步骤已经在 Ubuntu 18.04 上进行了测试,但是对于使用 systemd 的 `timesyncd` 服务的其他基于 Ubuntu 的系统它们是相同的。 + +### 在 Ubuntu 上设置时间同步 + +通常,我们在安装时设置时区。但是,你可以根据需要更改或设置不同的时区。 + +首先,让我们使用 `date` 命令查看 Ubuntu 系统中的当前时区: + +``` +$ date +``` + +示例输出: + +``` +Tue Jul 30 11:47:39 UTC 2019 +``` + +如上所见,`date` 命令显示实际日期和当前时间。这里,我当前的时区是 **UTC**,代表**协调世界时**。 + +或者,你可以在 `/etc/timezone` 文件中查找当前时区。 + +``` +$ cat /etc/timezone +UTC +``` + +现在,让我们看看时钟是否与互联网同步。只需运行: + +``` +$ timedatectl +``` + +示例输出: + +``` +Local time: Tue 2019-07-30 11:53:58 UTC +Universal time: Tue 2019-07-30 11:53:58 UTC +RTC time: Tue 2019-07-30 11:53:59 +Time zone: Etc/UTC (UTC, +0000) +System clock synchronized: yes +systemd-timesyncd.service active: yes +RTC in local TZ: no +``` + +如你所见,`timedatectl` 命令显示本地时间、世界时、时区以及系统时钟是否与互联网服务器同步,以及 `systemd-timesyncd.service` 是处于活动状态还是非活动状态。就我而言,系统时钟已与互联网时间服务器同步。 + +如果时钟不同步,你会看到下面截图中显示的 `System clock synchronized: no`。 + +![][4] + +*时间同步已禁用。* + +注意:上面的截图是旧截图。这就是你看到不同日期的原因。 + +如果你看到 `System clock synchronized:` 值设置为 `no`,那么 `timesyncd` 服务可能处于非活动状态。因此,只需重启服务并看下是否正常。 + +``` +$ sudo systemctl restart systemd-timesyncd.service +``` + +现在检查 `timesyncd` 服务状态: + +``` +$ sudo systemctl status systemd-timesyncd.service +● systemd-timesyncd.service - Network Time Synchronization +Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled) +Active: active (running) since Tue 2019-07-30 10:50:18 UTC; 1h 11min ago +Docs: man:systemd-timesyncd.service(8) +Main PID: 498 (systemd-timesyn) +Status: "Synchronized to time server [2001:67c:1560:8003::c7]:123 (ntp.ubuntu.com)." +Tasks: 2 (limit: 2319) +CGroup: /system.slice/systemd-timesyncd.service +└─498 /lib/systemd/systemd-timesyncd + +Jul 30 10:50:30 ubuntuserver systemd-timesyncd[498]: Network configuration changed, trying to estab +Jul 30 10:50:31 ubuntuserver systemd-timesyncd[498]: Network configuration changed, trying to estab +Jul 30 10:50:31 ubuntuserver systemd-timesyncd[498]: Network configuration changed, trying to estab +Jul 30 10:50:32 ubuntuserver systemd-timesyncd[498]: Network configuration changed, trying to estab +Jul 30 10:50:32 ubuntuserver systemd-timesyncd[498]: Network configuration changed, trying to estab +Jul 30 10:50:35 ubuntuserver systemd-timesyncd[498]: Network configuration changed, trying to estab +Jul 30 10:50:35 ubuntuserver systemd-timesyncd[498]: Network configuration changed, trying to estab +Jul 30 10:50:35 ubuntuserver systemd-timesyncd[498]: Network configuration changed, trying to estab +Jul 30 10:50:35 ubuntuserver systemd-timesyncd[498]: Network configuration changed, trying to estab +Jul 30 10:51:06 ubuntuserver systemd-timesyncd[498]: Synchronized to time server [2001:67c:1560:800 +``` + +如果此服务已启用并处于活动状态,那么系统时钟应与互联网时间服务器同步。 + +你可以使用命令验证是否启用了时间同步: + +``` +$ timedatectl +``` + +如果仍然不起作用,请运行以下命令以启用时间同步: + +``` +$ sudo timedatectl set-ntp true +``` + +现在,你的系统时钟将与互联网时间服务器同步。 + +#### 使用 timedatectl 命令更改时区 + +如果我想使用 UTC 以外的其他时区怎么办?这很容易! + +首先,使用命令列出可用时区: + +``` +$ timedatectl list-timezones +``` + +你将看到类似于下图的输出。 + +![][5] + +*使用 timedatectl 命令列出时区* + +你可以使用以下命令设置所需的时区(例如,Asia/Shanghai): + +(LCTT 译注:本文原文使用印度时区作为示例,这里为了便于使用,换为中国标准时区 CST。另外,在时区设置中,要注意 CST 这个缩写会代表四个不同的时区,因此建议使用城市和 UTC+8 来说设置。) + +``` +$ sudo timedatectl set-timezone Asia/Shanghai +``` + +使用 `date` 命令再次检查时区是否已真正更改: + +``` +$ date +Tue Jul 30 20:22:33 CST 2019 +``` + +或者,如果需要详细输出,请使用 `timedatectl` 命令: + +``` +$ timedatectl +Local time: Tue 2019-07-30 20:22:35 CST +Universal time: Tue 2019-07-30 12:22:35 UTC +RTC time: Tue 2019-07-30 12:22:36 +Time zone: Asia/Shanghai (CST, +0800) +System clock synchronized: yes +systemd-timesyncd.service active: yes +RTC in local TZ: no +``` + +如你所见,我已将时区从 UTC 更改为 CST(中国标准时间)。 + +要切换回 UTC 时区,只需运行: + +``` +$ sudo timedatectl set-timezone UTC +``` + +#### 使用 tzdata 更改时区 + +在较旧的 Ubuntu 版本中,没有 `timedatectl` 命令。这种情况下,你可以使用 `tzdata`(Time zone data)来设置时间同步。 + +``` +$ sudo dpkg-reconfigure tzdata +``` + +选择你居住的地理区域。对我而言,我选择 **Asia**。选择 OK,然后按回车键。 + +![][6] + +接下来,选择与你的时区对应的城市或地区。这里,我选择了 **Kolkata**(LCTT 译注:中国用户请相应使用 Shanghai 等城市)。 + +![][7] + +最后,你将在终端中看到类似下面的输出。 + +``` +Current default time zone: 'Asia/Shanghai' +Local time is now: Tue Jul 30 21:59:25 CST 2019. +Universal Time is now: Tue Jul 30 13:59:25 UTC 2019. +``` + +#### 在图形模式下配置时区 + +有些用户可能对命令行方式不太满意。如果你是其中之一,那么你可以轻松地在图形模式的系统设置面板中进行设置。 + +点击 Super 键(Windows 键),在 Ubuntu dash 中输入 **settings**,然后点击设置图标。 + +![][8] + +*从 Ubuntu dash 启动系统的设置* + +或者,单击位于 Ubuntu 桌面右上角的向下箭头,然后单击左上角的“设置”图标。 + +![][9] + +*从顶部面板启动系统的设置* + +在下一个窗口中,选择“细节”,然后单击“日期与时间”选项。打开“自动的日期与时间”和“自动的时区”。 + +![][10] + +*在 Ubuntu 中设置自动时区* + +关闭设置窗口就行了!你的系统始终应该与互联网时间服务器同步了。 + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-set-up-time-synchronization-on-ubuntu/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/07/Set-Up-Time-Synchronization-On-Ubuntu-720x340.png +[2]: https://www.ostechnix.com/a-beginners-guide-to-cron-jobs/ +[3]: https://www.ostechnix.com/manage-log-files-using-logrotate-linux/ +[4]: https://www.ostechnix.com/wp-content/uploads/2019/07/timedatectl-command-output-ubuntu.jpeg +[5]: https://www.ostechnix.com/wp-content/uploads/2019/07/List-timezones-using-timedatectl-command.png +[6]: https://www.ostechnix.com/wp-content/uploads/2019/07/configure-time-zone-using-tzdata-1.png +[7]: https://www.ostechnix.com/wp-content/uploads/2019/07/configure-time-zone-using-tzdata-2.png +[8]: https://www.ostechnix.com/wp-content/uploads/2019/07/System-settings-Ubuntu-dash.png +[9]: https://www.ostechnix.com/wp-content/uploads/2019/07/Ubuntu-system-settings.png +[10]: https://www.ostechnix.com/wp-content/uploads/2019/07/Set-automatic-timezone-in-ubuntu.png diff --git a/published/201908/20190805 How To Verify ISO Images In Linux.md b/published/201908/20190805 How To Verify ISO Images In Linux.md new file mode 100644 index 0000000000..80b5a39a57 --- /dev/null +++ b/published/201908/20190805 How To Verify ISO Images In Linux.md @@ -0,0 +1,147 @@ +[#]: collector: "lujun9972" +[#]: translator: "FSSlc" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11212-1.html" +[#]: subject: "How To Verify ISO Images In Linux" +[#]: via: "https://www.ostechnix.com/how-to-verify-iso-images-in-linux/" +[#]: author: "sk https://www.ostechnix.com/author/sk/" + +如何在 Linux 中验证 ISO 镜像 +====== + +![如何在 Linux 中校验 ISO 镜像][1] + +你从喜爱的 Linux 发行版的官方网站或第三方网站下载了它的 ISO 镜像之后,接下来要做什么呢?是[创建可启动介质][2]并开始安装系统吗?并不是,请稍等一下。在开始使用它之前,强烈建议你检查一下你刚下载到本地系统中的 ISO 文件是否是下载镜像站点中 ISO 文件的一个精确拷贝。因为在前几年 [Linux Mint 的网站被攻破了][3],并且攻击者创建了一个包含后门的经过修改的 Linux Mint ISO 文件。 所以验证下载的 Linux ISO 镜像的可靠性和完整性是非常重要的一件事儿。假如你不知道如何在 Linux 中验证 ISO 镜像,本次的简要介绍将给予你帮助,请接着往下看! + +### 在 Linux 中验证 ISO 镜像 + +我们可以使用 ISO 镜像的“校验和”来验证 ISO 镜像。校验和是一系列字母和数字的组合,用来检验下载文件的数据是否有错以及验证其可靠性和完整性。当前存在不同类型的校验和,例如 SHA-0、SHA-1、SHA-2(224、256、384、512)和 MD5。MD5 校验和最为常用,但对于现代的 Linux 发行版,SHA-256 最常被使用。 + +我们将使用名为 `gpg` 和 `sha256` 的两个工具来验证 ISO 镜像的可靠性和完整性。 + +#### 下载校验和及签名 + +针对本篇指南的目的,我将使用 Ubuntu 18.04 LTS 服务器 ISO 镜像来做验证,但对于其他的 Linux 发行版应该也是适用的。 + +在靠近 Ubuntu 下载页的最上端,你将看到一些额外的文件(校验和及签名),正如下面展示的图片那样: + +![Ubuntu 18.04 的校验和及签名][4] + +其中名为 `SHA256SUMS` 的文件包含了这里所有可获取镜像的校验和,而 `SHA256SUMS.gpg` 文件则是这个文件的 GnuPG 签名。在下面的步骤中,我们将使用这个签名文件来 **验证** 校验和文件。 + +下载 Ubuntu 的 ISO 镜像文件以及刚才提到的那两个文件,然后将它们放到同一目录下,例如这里的 `ISO` 目录: + +``` +$ ls ISO/ +SHA256SUMS SHA256SUMS.gpg ubuntu-18.04.2-live-server-amd64.iso +``` + +如你所见,我已经下载了 Ubuntu 18.04.2 LTS 服务器版本的镜像,以及对应的校验和文件和签名文件。 + +#### 下载有效的签名秘钥 + +现在,使用下面的命令来下载正确的签名秘钥: + +``` +$ gpg --keyid-format long --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x46181433FBB75451 0xD94AA3F0EFE21092 +``` + +示例输出如下: + +``` +gpg: key D94AA3F0EFE21092: 57 signatures not checked due to missing keys +gpg: key D94AA3F0EFE21092: public key "Ubuntu CD Image Automatic Signing Key (2012) <[email protected]>" imported +gpg: key 46181433FBB75451: 105 signatures not checked due to missing keys +gpg: key 46181433FBB75451: public key "Ubuntu CD Image Automatic Signing Key <[email protected]>" imported +gpg: no ultimately trusted keys found +gpg: Total number processed: 2 +gpg: imported: 2 +``` + +#### 验证 SHA-256 校验和 + +接下来我们将使用签名来验证校验和文件: + +``` +$ gpg --keyid-format long --verify SHA256SUMS.gpg SHA256SUMS +``` + +下面是示例输出: + +``` +gpg: Signature made Friday 15 February 2019 04:23:33 AM IST +gpg: using DSA key 46181433FBB75451 +gpg: Good signature from "Ubuntu CD Image Automatic Signing Key <[email protected]>" [unknown] +gpg: WARNING: This key is not certified with a trusted signature! +gpg: There is no indication that the signature belongs to the owner. +Primary key fingerprint: C598 6B4F 1257 FFA8 6632 CBA7 4618 1433 FBB7 5451 +gpg: Signature made Friday 15 February 2019 04:23:33 AM IST +gpg: using RSA key D94AA3F0EFE21092 +gpg: Good signature from "Ubuntu CD Image Automatic Signing Key (2012) <[email protected]>" [unknown] +gpg: WARNING: This key is not certified with a trusted signature! +gpg: There is no indication that the signature belongs to the owner. +Primary key fingerprint: 8439 38DF 228D 22F7 B374 2BC0 D94A A3F0 EFE2 1092 +``` + +假如你在输出中看到 `Good signature` 字样,那么该校验和文件便是由 Ubuntu 开发者制作的,并且由秘钥文件的所属者签名认证。 + +#### 检验下载的 ISO 文件 + +下面让我们继续检查下载的 ISO 文件是否和所给的校验和相匹配。为了达到该目的,只需要运行: + +``` +$ sha256sum -c SHA256SUMS 2>&1 | grep OK +ubuntu-18.04.2-live-server-amd64.iso: OK +``` + +假如校验和是匹配的,你将看到 `OK` 字样,这意味着下载的文件是合法的,没有被改变或篡改过。 + +假如你没有获得类似的输出,或者看到不同的输出,则该 ISO 文件可能已经被修改过或者没有被正确地下载。你必须从一个更好的下载源重新下载该文件。 + +某些 Linux 发行版已经在它的下载页面中包含了校验和。例如 Pop!_os 的开发者在他们的下载页面中提供了所有 ISO 镜像的 SHA-256 校验和,这样你就可以快速地验证这些 ISO 镜像。 + +![Pop os 位于其下载页面中的 SHA256 校验和][5] + +在下载完 ISO 镜像文件后,可以使用下面的命令来验证它们: + +``` +$ sha256sum Soft_backup/ISOs/pop-os_18.04_amd64_intel_54.iso +``` + +示例输出如下: + +``` +680e1aa5a76c86843750e8120e2e50c2787973343430956b5cbe275d3ec228a6 Soft_backup/ISOs/pop-os_18.04_amd64_intel_54.iso +``` + +![Pop os 的 SHA256 校验和的值][6] + +在上面的输出中,以 `680elaa` 开头的部分为 SHA-256 校验和的值。请将该值与位于下载页面中提供的 SHA-256 校验和的值进行比较,如果这两个值相同,那说明这个下载的 ISO 文件是合法的,与它的原有状态相比没有经过更改或者篡改。万事俱备,你可以进行下一步了! + +上面的内容便是我们如何在 Linux 中验证一个 ISO 文件的可靠性和完整性的方法。无论你是从官方站点或者第三方站点下载 ISO 文件,我们总是推荐你在使用它们之前做一次简单的快速验证。希望本篇的内容对你有所帮助。 + +参考文献: + +* [https://tutorials.ubuntu.com/tutorial/tutorial-how-to-verify-ubuntu][7] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-verify-iso-images-in-linux/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[FSSlc](https://github.com/FSSlc) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/07/Verify-ISO-Images-In-Linux-720x340.png +[2]: https://www.ostechnix.com/etcher-beauitiful-app-create-bootable-sd-cards-usb-drives/ +[3]: https://blog.linuxmint.com/?p=2994 +[4]: https://www.ostechnix.com/wp-content/uploads/2019/07/Ubuntu-18.04-checksum-and-signature.png +[5]: https://www.ostechnix.com/wp-content/uploads/2019/07/Pop-os-SHA256-sum.png +[6]: https://www.ostechnix.com/wp-content/uploads/2019/07/Pop-os-SHA256-sum-value.png +[7]: https://tutorials.ubuntu.com/tutorial/tutorial-how-to-verify-ubuntu diff --git a/published/201908/20190806 Microsoft finds Russia-backed attacks that exploit IoT devices.md b/published/201908/20190806 Microsoft finds Russia-backed attacks that exploit IoT devices.md new file mode 100644 index 0000000000..22eeb954f7 --- /dev/null +++ b/published/201908/20190806 Microsoft finds Russia-backed attacks that exploit IoT devices.md @@ -0,0 +1,58 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11207-1.html) +[#]: subject: (Microsoft finds Russia-backed attacks that exploit IoT devices) +[#]: via: (https://www.networkworld.com/article/3430356/microsoft-finds-russia-backed-attacks-that-exploit-iot-devices.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +微软发现由俄罗斯背后支持的利用物联网设备进行的攻击 +====== + +> 微软表示,默认密码、未打补丁的设备,物联网设备库存不足是导致俄罗斯的 STRONTIUM 黑客组织发起针对公司的攻击的原因。 + +![Zmeel / Getty Images][1] + +在微软安全响应中心周一发布的博客文章中,该公司称,STRONTIUM 黑客组织对未披露名字的微软客户进行了基于 [IoT][2] 的攻击,安全研究人员相信 STRONTIUM 黑客组织和俄罗斯 GRU 军事情报机构有密切的关系。 + +微软[在博客中说][3],它在 4 月份发现的攻击针对三种特定的物联网设备:一部 VoIP 电话、一部视频解码器和一台打印机(该公司拒绝说明品牌),并将它们用于获得对不特定的公司网络的访问权限。其中两个设备遭到入侵是因为没有更改过制造商的默认密码,而另一个设备则是因为没有应用最新的安全补丁。 + +以这种方式受到攻击的设备成为了安全的网络的后门,允许攻击者自由扫描这些网络以获得进一步的漏洞,并访问其他系统获取更多的信息。攻击者也被发现其在调查受攻击网络上的管理组,试图获得更多访问权限,以及分析本地子网流量以获取其他数据。 + +STRONTIUM,也被称为 Fancy Bear、Pawn Storm、Sofacy 和 APT28,被认为是代表俄罗斯政府进行的一系列恶意网络活动的幕后黑手,其中包括 2016 年对民主党全国委员会的攻击,对世界反兴奋剂机构的攻击,针对记者调查马来西亚航空公司 17 号航班在乌克兰上空被击落的情况,向美国军人的妻子发送捏造的死亡威胁等等。 + +根据 2018 年 7 月特别顾问罗伯特·穆勒办公室发布的起诉书,STRONTIUM 袭击的指挥者是一群俄罗斯军官,所有这些人都被 FBI 通缉与这些罪行有关。 + +微软通知客户发现其遭到了民族国家的攻击,并在过去 12 个月内发送了大约 1,400 条与 STRONTIUM 相关的通知。微软表示,其中大多数(五分之四)是对政府、军队、国防、IT、医药、教育和工程领域的组织的攻击,其余的则是非政府组织、智囊团和其他“政治附属组织”。 + +根据微软团队的说法,漏洞的核心是机构缺乏对其网络上运行的所有设备的充分认识。另外,他们建议对在企业环境中运行的所有 IoT 设备进行编目,为每个设备实施自定义安全策略,在可行的情况下在各自独立的网络上屏蔽物联网设备,并对物联网组件执行定期补丁和配置审核。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3430356/microsoft-finds-russia-backed-attacks-that-exploit-iot-devices.html + +作者:[Jon Gold][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/07/cso_russian_hammer_and_sickle_binary_code_by_zmeel_gettyimages-927363118_2400x1600-100801412-large.jpg +[2]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[3]: https://msrc-blog.microsoft.com/2019/08/05/corporate-iot-a-path-to-intrusion/ +[4]: https://www.networkworld.com/article/3207535/internet-of-things/what-is-the-iot-how-the-internet-of-things-works.html +[5]: https://www.networkworld.com/article/2287045/internet-of-things/wireless-153629-10-most-powerful-internet-of-things-companies.html +[6]: https://www.networkworld.com/article/3270961/internet-of-things/10-hot-iot-startups-to-watch.html +[7]: https://www.networkworld.com/article/3279346/internet-of-things/the-6-ways-to-make-money-in-iot.html +[8]: https://www.networkworld.com/article/3280225/internet-of-things/what-is-digital-twin-technology-and-why-it-matters.html +[9]: https://www.networkworld.com/article/3276313/internet-of-things/blockchain-service-centric-networking-key-to-iot-success.html +[10]: https://www.networkworld.com/article/3269736/internet-of-things/getting-grounded-in-iot-networking-and-security.html +[11]: https://www.networkworld.com/article/3276304/internet-of-things/building-iot-ready-networks-must-become-a-priority.html +[12]: https://www.networkworld.com/article/3243928/internet-of-things/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html +[13]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr +[14]: https://www.facebook.com/NetworkWorld/ +[15]: https://www.linkedin.com/company/network-world diff --git a/published/201908/20190806 Unboxing the Raspberry Pi 4.md b/published/201908/20190806 Unboxing the Raspberry Pi 4.md new file mode 100644 index 0000000000..b4a72adf63 --- /dev/null +++ b/published/201908/20190806 Unboxing the Raspberry Pi 4.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11248-1.html) +[#]: subject: (Unboxing the Raspberry Pi 4) +[#]: via: (https://opensource.com/article/19/8/unboxing-raspberry-pi-4) +[#]: author: (Anderson Silva https://opensource.com/users/ansilvahttps://opensource.com/users/bennuttall) + +树莓派 4 开箱记 +====== + +> 树莓派 4 与其前代产品相比具有令人印象深刻的性能提升,而入门套件使其易于快速启动和运行。 + +![](https://img.linux.net.cn/data/attachment/album/201908/20/091730rl99q2ahycd4sz9h.jpg) + +当树莓派 4 [在 6 月底宣布发布][2]时,我没有迟疑,在发布的同一天就从 [CanaKit][3] 订购了两套树莓派 4 入门套件。1GB RAM 版本有现货,但 4GB 版本要在 7 月 19 日才能发货。由于我想两个都试试,这两个都订购了让它们一起发货。 + +![CanaKit's Raspberry Pi 4 Starter Kit and official accessories][4] + +这是我开箱我的树莓派 4 后所看到的。 + +### 电源 + +树莓派 4 使用 USB-C 连接器供电。虽然 USB-C 电缆现在非常普遍,但你的树莓派 4 [可能不喜欢你的USB-C 线][5](至少对于树莓派 4 的第一版如此)。因此,除非你确切知道自己在做什么,否则我建议你订购含有官方树莓派充电器的入门套件。如果你想尝试手头的充电设备,那么该设备的输入是 100-240V ~ 50/60Hz 0.5A,输出为 5.1V - 3.0A。 + +![Raspberry Pi USB-C charger][6] + +### 键盘和鼠标 + +官方的键盘和鼠标是和入门套件是[分开出售][7]的,总价 25 美元,并不很便宜,因为你的这台树莓派电脑也才只有 35 到 55 美元。但树莓派徽标印在这个键盘上(而不是 Windows 徽标),并且外观相宜。键盘也是 USB 集线器,因此它允许你插入更多设备。我插入了我的 [YubiKey][8] 安全密钥,它运行得非常好。我会把键盘和鼠标分类为“值得拥有”而不是“必须拥有”。你的常规键盘和鼠标应该也可以正常工作。 + +![Official Raspberry Pi keyboard \(with YubiKey plugged in\) and mouse.][9] + +![Raspberry Pi logo on the keyboard][10] + +### Micro-HDMI 电缆 + +可能让一些人惊讶的是,与带有 Mini-HDMI 端口的树莓派 Zero 不同,树莓派 4 配备了 Micro-HDMI。它们不是同一个东西!因此,即使你手头有合适的 USB-C 线缆/电源适配器、鼠标和键盘,也很有可能需要使用 Micro-HDMI 转 HDMI 的线缆(或适配器)来将你的新树莓派接到显示器上。 + +### 外壳 + +树莓派的外壳已经有了很多年,这可能是树莓派基金会销售的第一批“官方”外围设备之一。有些人喜欢它们,而有些人不喜欢。我认为将一个树莓派放在一个盒子里可以更容易携带它,可以避免静电和针脚弯曲。 + +另一方面,把你的树莓派装在盒子里会使电路板过热。这款 CanaKit 入门套件还配备了处理器散热器,这可能有所帮助,因为较新的树莓派已经[以运行相当热而闻名][11]了。 + +![Raspberry Pi 4 case][12] + +### Raspbian 和 NOOBS + +入门套件附带的另一个东西是 microSD 卡,其中预装了树莓派 4 的 [NOOBS][13] 操作系统的正确版本。(我拿到的是 3.19 版,发布于 2019 年 6 月 24 日)。如果你是第一次使用树莓派并且不确定从哪里开始,这可以为你节省大量时间。入门套件中的 microSD 卡容量为 32GB。 + +插入 microSD 卡并连接所有电缆后,只需启动树莓派,引导进入 NOOBS,选择 Raspbian 发行版,然后等待安装。 + +![Raspberry Pi 4 with 4GB of RAM][14] + +我注意到在安装最新的 Raspbian 时有一些改进。(如果它们已经出现了一段时间,请原谅我 —— 自从树莓派 3 出现以来我没有对树莓派进行过全新安装。)其中一个是 Raspbian 会要求你在安装后的首次启动为你的帐户设置一个密码,另一个是它将运行软件更新(假设你有网络连接)。这些都是很大的改进,有助于保持你的树莓派更安全。我很希望能有一天在安装时看到加密 microSD 卡的选项。 + +![Running Raspbian updates at first boot][15] + +![Raspberry Pi 4 setup][16] + +运行非常顺畅! + +### 结语 + +虽然 CanaKit 不是美国唯一授权的树莓派零售商,但我发现它的入门套件的价格物超所值。 + +到目前为止,我对树莓派 4 的性能提升印象深刻。我打算尝试用一整个工作日将它作为我唯一的计算机,我很快就会写一篇关于我探索了多远的后续文章。敬请关注! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/unboxing-raspberry-pi-4 + +作者:[Anderson Silva][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ansilvahttps://opensource.com/users/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberrypi4_board_hardware.jpg?itok=KnFU7NvR (Raspberry Pi 4 board, posterized filter) +[2]: https://opensource.com/article/19/6/raspberry-pi-4 +[3]: https://www.canakit.com/raspberry-pi-4-starter-kit.html +[4]: https://opensource.com/sites/default/files/uploads/raspberrypi4_canakit.jpg (CanaKit's Raspberry Pi 4 Starter Kit and official accessories) +[5]: https://www.techrepublic.com/article/your-new-raspberry-pi-4-wont-power-on-usb-c-cable-problem-now-officially-confirmed/ +[6]: https://opensource.com/sites/default/files/uploads/raspberrypi_usb-c_charger.jpg (Raspberry Pi USB-C charger) +[7]: https://www.canakit.com/official-raspberry-pi-keyboard-mouse.html?defpid=4476 +[8]: https://www.yubico.com/products/yubikey-hardware/ +[9]: https://opensource.com/sites/default/files/uploads/raspberrypi_keyboardmouse.jpg (Official Raspberry Pi keyboard (with YubiKey plugged in) and mouse.) +[10]: https://opensource.com/sites/default/files/uploads/raspberrypi_keyboardlogo.jpg (Raspberry Pi logo on the keyboard) +[11]: https://www.theregister.co.uk/2019/07/22/raspberry_pi_4_too_hot_to_handle/ +[12]: https://opensource.com/sites/default/files/uploads/raspberrypi4_case.jpg (Raspberry Pi 4 case) +[13]: https://www.raspberrypi.org/downloads/noobs/ +[14]: https://opensource.com/sites/default/files/uploads/raspberrypi4_ram.jpg (Raspberry Pi 4 with 4GB of RAM) +[15]: https://opensource.com/sites/default/files/uploads/raspberrypi4_rasbpianupdate.jpg (Running Raspbian updates at first boot) +[16]: https://opensource.com/sites/default/files/uploads/raspberrypi_setup.jpg (Raspberry Pi 4 setup) diff --git a/published/201908/20190808 Find Out How Long Does it Take To Boot Your Linux System.md b/published/201908/20190808 Find Out How Long Does it Take To Boot Your Linux System.md new file mode 100644 index 0000000000..f3202d96af --- /dev/null +++ b/published/201908/20190808 Find Out How Long Does it Take To Boot Your Linux System.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11238-1.html) +[#]: subject: (Find Out How Long Does it Take To Boot Your Linux System) +[#]: via: (https://itsfoss.com/check-boot-time-linux/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +你的 Linux 系统开机时间已经击败了 99% 的电脑 +====== + +当你打开系统电源时,你会等待制造商的徽标出现,屏幕上可能会显示一些消息(以非安全模式启动),然后是 [Grub][1] 屏幕、操作系统加载屏幕以及最后的登录屏。 + +你检查过这花费了多长时间么?也许没有。除非你真的需要知道,否则你不会在意开机时间。 + +但是如果你很想知道你的 Linux 系统需要很长时间才能启动完成呢?使用秒表是一种方法,但在 Linux 中,你有一种更好、更轻松地了解系统启动时间的方法。 + +### 在 Linux 中使用 systemd-analyze 检查启动时间 + +![](https://img.linux.net.cn/data/attachment/album/201908/17/104358s1ho8ug868hso1y8.jpg) + +无论你是否喜欢,[systemd][3] 运行在大多数流行的 Linux 发行版中。systemd 有许多管理 Linux 系统的工具。其中一个就是 `systemd-analyze`。 + +`systemd-analyze` 命令为你提供最近一次启动时运行的服务数量以及消耗时间的详细信息。 + +如果在终端中运行以下命令: + +``` +systemd-analyze +``` + +你将获得总启动时间以及固件、引导加载程序、内核和用户空间所消耗的时间: + +``` +Startup finished in 7.275s (firmware) + 13.136s (loader) + 2.803s (kernel) + 12.488s (userspace) = 35.704s + +graphical.target reached after 12.408s in userspace +``` + +正如你在上面的输出中所看到的,我的系统花了大约 35 秒才进入可以输入密码的页面。我正在使用戴尔 XPS Ubuntu。它使用 SSD 存储,尽管如此,它还需要很长时间才能启动。 + +不是那么令人印象深刻,是吗?为什么不共享你们系统的启动时间?我们来比较吧。 + +你可以使用以下命令将启动时间进一步细分为每个单元: + +``` +systemd-analyze blame +``` + +这将生成大量输出,所有服务按所用时间的降序列出。 + +``` +7.347s plymouth-quit-wait.service +6.198s NetworkManager-wait-online.service +3.602s plymouth-start.service +3.271s plymouth-read-write.service +2.120s apparmor.service +1.503s [email protected] +1.213s motd-news.service + 908ms snapd.service + 861ms keyboard-setup.service + 739ms fwupd.service + 702ms bolt.service + 672ms dev-nvme0n1p3.device + 608ms [email protected]:intel_backlight.service + 539ms snap-core-7270.mount + 504ms snap-midori-451.mount + 463ms snap-screencloud-1.mount + 446ms snapd.seeded.service + 440ms snap-gtk\x2dcommon\x2dthemes-1313.mount + 420ms snap-core18-1066.mount + 416ms snap-scrcpy-133.mount + 412ms snap-gnome\x2dcharacters-296.mount +``` + +#### 额外提示:改善启动时间 + +如果查看此输出,你可以看到网络管理器和 [plymouth][4] 都消耗了大量的启动时间。 + +Plymouth 负责你在 Ubuntu 和其他发行版中在登录页面出现之前的引导页面。网络管理器负责互联网连接,可以关闭它来加快启动时间。不要担心,在你登录后,你可以正常使用 wifi。 + +``` +sudo systemctl disable NetworkManager-wait-online.service +``` + +如果要还原更改,可以使用以下命令: + +``` +sudo systemctl enable NetworkManager-wait-online.service +``` + +请不要在不知道用途的情况下自行禁用各种服务。这可能会产生危险的后果。 + +现在你知道了如何检查 Linux 系统的启动时间,为什么不在评论栏分享你的系统的启动时间? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/check-boot-time-linux/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.gnu.org/software/grub/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/08/linux-boot-time.jpg?resize=800%2C450&ssl=1 +[3]: https://en.wikipedia.org/wiki/Systemd +[4]: https://wiki.archlinux.org/index.php/Plymouth diff --git a/published/201908/20190808 How to manipulate PDFs on Linux.md b/published/201908/20190808 How to manipulate PDFs on Linux.md new file mode 100644 index 0000000000..3357b5581c --- /dev/null +++ b/published/201908/20190808 How to manipulate PDFs on Linux.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11230-1.html) +[#]: subject: (How to manipulate PDFs on Linux) +[#]: via: (https://www.networkworld.com/article/3430781/how-to-manipulate-pdfs-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如何在 Linux 命令行操作 PDF +====== + +> pdftk 命令提供了许多处理 PDF 的命令行操作,包括合并页面、加密文件、添加水印、压缩文件,甚至还有修复 PDF。 + +![](https://img.linux.net.cn/data/attachment/album/201908/15/110119x6sjnjs6s22srnje.jpg) + +虽然 PDF 通常被认为是相当稳定的文件,但在 Linux 和其他系统上你可以做很多处理。包括合并、拆分、旋转、拆分成单页、加密和解密、添加水印、压缩和解压缩,甚至还有修复。 `pdftk` 命令能执行所有甚至更多操作。 + +“pdftk” 代表 “PDF 工具包”(PDF tool kit),这个命令非常易于使用,并且可以很好地操作 PDF。例如,要将独立的文件合并成一个文件,你可以使用以下命令: + +``` +$ pdftk pg1.pdf pg2.pdf pg3.pdf pg4.pdf pg5.pdf cat output OneDoc.pdf +``` + +`OneDoc.pdf` 将包含上面显示的所有五个文档,命令将在几秒钟内运行完毕。请注意,`cat` 选项表示将文件连接在一起,`output` 选项指定新文件的名称。 + +你还可以从 PDF 中提取选定页面来创建单独的 PDF 文件。例如,如果要创建仅包含上面创建的文档的第 1、2、3 和 5 页的新 PDF,那么可以执行以下操作: + +``` +$ pdftk OneDoc.pdf cat 1-3 5 output 4pgs.pdf +``` + +另外,如果你想要第 1、3、4 和 5 页(总计 5 页),我们可以使用以下命令: + +``` +$ pdftk OneDoc.pdf cat 1 3-end output 4pgs.pdf +``` + +你可以选择单独页面或者页面范围,如上例所示。 + +下一个命令将从一个包含奇数页(1、3 等)的文件和一个包含偶数页(2、4 等)的文件创建一个整合文档: + +``` +$ pdftk A=odd.pdf B=even.pdf shuffle A B output collated.pdf +``` + +请注意,`shuffle` 选项使得能够完成整合,并指示文档的使用顺序。另请注意:虽然上面建议用的是奇数/偶数页,但你不限于仅使用两个文件。 + +如果要创建只能由知道密码的收件人打开的加密 PDF,可以使用如下命令: + +``` +$ pdftk prep.pdf output report.pdf user_pw AsK4n0thingGeTn0thing +``` + +选项提供 40(`encrypt_40bit`)和 128(`encrypt_128bit`)位加密。默认情况下使用 128 位加密。 + +你还可以使用 `burst` 选项将 PDF 文件分成单个页面: + +``` +$ pdftk allpgs.pdf burst +$ ls -ltr *.pdf | tail -5 +-rw-rw-r-- 1 shs shs 22933 Aug 8 08:18 pg_0001.pdf +-rw-rw-r-- 1 shs shs 23773 Aug 8 08:18 pg_0002.pdf +-rw-rw-r-- 1 shs shs 23260 Aug 8 08:18 pg_0003.pdf +-rw-rw-r-- 1 shs shs 23435 Aug 8 08:18 pg_0004.pdf +-rw-rw-r-- 1 shs shs 23136 Aug 8 08:18 pg_0005.pdf +``` + +`pdftk` 命令使得合并、拆分、重建、加密 PDF 文件非常容易。要了解更多选项,请查看 [PDF 实验室][3]中的示例页面。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3430781/how-to-manipulate-pdfs-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/08/book-pages-100807709-large.jpg +[3]: https://www.pdflabs.com/docs/pdftk-cli-examples/ +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/201908/20190809 Copying files in Linux.md b/published/201908/20190809 Copying files in Linux.md new file mode 100644 index 0000000000..d657449899 --- /dev/null +++ b/published/201908/20190809 Copying files in Linux.md @@ -0,0 +1,210 @@ +[#]: collector: (lujun9972) +[#]: translator: (tomjlw) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11259-1.html) +[#]: subject: (Copying files in Linux) +[#]: via: (https://opensource.com/article/19/8/copying-files-linux) +[#]: author: (Seth Kenlon https://opensource.com/users/sethhttps://opensource.com/users/scottnesbitthttps://opensource.com/users/greg-p) + +在 Linux 中复制文档 +====== + +> 了解在 Linux 中多种复制文档的方式以及各自的优点。 + +![](https://img.linux.net.cn/data/attachment/album/201908/23/053859f1stcjezllmj28e8.jpg) + +在办公室里复印文档过去需要专门的员工与机器。如今,复制是电脑用户无需多加思考的任务。在电脑里复制数据是如此微不足道的事,以致于你还没有意识到复制就发生了,例如当拖动文档到外部硬盘的时候。 + +数字实体复制起来十分简单已是一个不争的事实,以致于大部分现代电脑用户从未考虑过其它的复制他们工作的方式。无论如何,在 Linux 中复制文档仍有几种不同的方式。每种方法取决于你的目的不同而都有其独到之处。 + +以下是一系列在 Linux、BSD 及 Mac 上复制文件的方式。 + +### 在 GUI 中复制 + +如大多数操作系统一样,如果你想的话,你可以完全用 GUI 来管理文件。 + +#### 拖拽放下 + +最浅显的复制文件的方式可能就是你以前在电脑中复制文件的方式:拖拽并放下。在大多数 Linux 桌面上,从一个本地文件夹拖拽放下到另一个本地文件夹是*移动*文件的默认方式,你可以通过在拖拽文件开始后按住 `Ctrl` 来改变这个行为。 + +你的鼠标指针可能会有一个指示,例如一个加号以显示你在复制模式。 + +![复制一个文件][2] + +注意如果文件是放在远程系统上的,不管它是一个 Web 服务器还是在你自己网络里用文件共享协议访问的另一台电脑,默认动作经常是复制而不是移动文件。 + +#### 右击 + +如果你觉得在你的桌面拖拽文档不够精准或者有点笨拙,或者这么做会让你的手离开键盘太久,你可以经常使用右键菜单来复制文件。这取决于你所用的文件管理器,但通常来说,右键弹出的关联菜单会包括常见的操作。 + +关联菜单的“复制”动作将你的[文件路径][3](即文件在系统的位置)保存在你的剪切板中,这样你可以将你的文件*粘贴*到别处:(LCTT 译注:此处及下面的描述不确切,这里并非复制的文件路径的“字符串”,而是复制了代表文件实体的对象/指针) + +![从右键菜单复制文件][4] + +在这种情况下,你并没有将文件的内容复制到你的剪切版上。取而代之的是你复制了[文件路径][3]。当你粘贴时,你的文件管理器会查看剪贴板上的路径并执行复制命令,将相应路径上的文件粘贴到你准备复制到的路径。 + +### 用命令行复制 + +虽然 GUI 通常是相对熟悉的复制文件方式,用终端复制却更有效率。 + +#### cp + +在终端上等同于在桌面上复制和粘贴文件的最显而易见的方式就是 `cp` 命令。这个命令可以复制文件和目录,也相对直接。它使用熟悉的*来源*和*目的*(必须以这样的顺序)句法,因此复制一个名为 `example.txt` 的文件到你的 `Documents` 目录就像这样: + +``` +$ cp example.txt ~/Documents +``` + +就像当你拖拽文件放在文件夹里一样,这个动作并不会将 `Documents` 替换为 `example.txt`。取而代之的是,`cp` 察觉到 `Documents` 是一个文件夹,就将 `example.txt` 的副本放进去。 + +你同样可以便捷有效地重命名你复制的文档: + +``` +$ cp example.txt ~/Documents/example_copy.txt +``` + +重要的是,它使得你可以在与原文件相同的目录中生成一个副本: + +``` +$ cp example.txt example.txt +cp: 'example.txt' and 'example.txt' are the same file. +$ cp example.txt example_copy.txt +``` + +要复制一个目录,你必须使用 `-r` 选项(代表 `--recursive`,递归)。以这个选项对目录 `nodes` 运行 `cp` 命令,然后会作用到该目录下的所有文件。没有 `-r` 选项,`cp` 不会将目录当成一个可复制的对象: + +``` +$ cp notes/ notes-backup +cp: -r not specified; omitting directory 'notes/' +$ cp -r notes/ notes-backup +``` + +#### cat + +`cat` 命令是最易被误解的命令,但这只是因为它表现了 [POSIX][5] 系统的极致灵活性。在 `cat` 可以做到的所有事情中(包括其原意的连接文件的用途),它也能复制。例如说使用 `cat` 你可以仅用一个命令就[从一个文件创建两个副本][6]。你用 `cp` 无法做到这一点。 + +使用 `cat` 复制文档要注意的是系统解释该行为的方式。当你使用 `cp` 复制文件时,该文件的属性跟着文件一起被复制,这意味着副本的权限和原件一样。 + +``` +$ ls -l -G -g +-rw-r--r--. 1 57368 Jul 25 23:57  foo.jpg +$ cp foo.jpg bar.jpg +-rw-r--r--. 1 57368 Jul 29 13:37  bar.jpg +-rw-r--r--. 1 57368 Jul 25 23:57  foo.jpg +``` + +然而用 `cat` 将一个文件的内容读取至另一个文件是让系统创建了一个新文件。这些新文件取决于你的默认 umask 设置。要了解 umask 更多的知识,请阅读 Alex Juarez 讲述 [umask][7] 以及权限概览的文章。 + +运行 `unmask` 获取当前设置: + +``` +$ umask +0002 +``` + +这个设置代表在该处新创建的文档被给予 `664`(`rw-rw-r--`)权限,因为该 `unmask` 设置的前几位数字没有遮掩任何权限(而且执行位不是文件创建的默认位),并且写入权限被最终位所屏蔽。 + +当你使用 `cat` 复制时,实际上你并没有真正复制文件。你使用 `cat` 读取文件内容并将输出重定向到了一个新文件: + +``` +$ cat foo.jpg > baz.jpg +$ ls -l -G -g +-rw-r--r--. 1 57368 Jul 29 13:37  bar.jpg +-rw-rw-r--. 1 57368 Jul 29 13:42  baz.jpg +-rw-r--r--. 1 57368 Jul 25 23:57  foo.jpg +``` + +如你所见,`cat` 应用系统默认的 umask 设置创建了一个全新的文件。 + +最后,当你只是想复制一个文件时,这些手段无关紧要。但如果你想复制文件并保持默认权限时,你可以用一个命令 `cat` 完成一切。 + +#### rsync + +有着著名的同步源和目的文件的能力,`rsync` 命令是一个复制文件的多才多艺的工具。最为简单的,`rsync` 可以类似于 `cp` 命令一样使用。 + +``` +$ rsync example.txt example_copy.txt +$ ls +example.txt    example_copy.txt +``` + +这个命令真正的威力藏在其能够*不做*不必要的复制的能力里。如果你使用 `rsync` 来将文件复制进目录里,且其已经存在在该目录里,那么 `rsync` 不会做复制操作。在本地这个差别不是很大,但如果你将海量数据复制到远程服务器,这个特性的意义就完全不一样了。 + +甚至在本地中,真正不一样的地方在于它可以分辨具有相同名字但拥有不同数据的文件。如果你曾发现你面对着同一个目录的两个相同副本时,`rsync` 可以将它们同步至一个包含每一个最新修改的目录。这种配置在尚未发现版本控制威力的业界十分常见,同时也作为需要从一个可信来源复制的备份方案。 + +你可以通过创建两个文件夹有意识地模拟这种情况,一个叫做 `example` 另一个叫做 `example_dupe`: + +``` +$ mkdir example example_dupe +``` + +在第一个文件夹里创建文件: + +``` +$ echo "one" > example/foo.txt +``` + +用 `rsync` 同步两个目录。这种做法最常见的选项是 `-a`(代表 “archive”,可以保证符号链接和其它特殊文件保留下来)和 `-v`(代表 “verbose”,向你提供当前命令的进度反馈): + +``` +$ rsync -av example/ example_dupe/ +``` + +两个目录现在包含同样的信息: + +``` +$ cat example/foo.txt +one +$ cat example_dupe/foo.txt +one +``` + +如果你当作源分支的文件发生改变,目的文件也会随之跟新: + +``` +$ echo "two" >> example/foo.txt +$ rsync -av example/  example_dupe/ +$ cat example_dupe/foo.txt +one +two +``` + +注意 `rsync` 命令是用来复制数据的,而不是充当版本管理系统的。例如假设有一个目的文件比源文件多了改变,那个文件仍将被覆盖,因为 `rsync` 比较文件的分歧并假设目的文件总是应该镜像为源文件: + +``` +$ echo "You will never see this note again" > example_dupe/foo.txt +$ rsync -av example/  example_dupe/ +$ cat example_dupe/foo.txt +one +two +``` + +如果没有改变,那么就不会有复制动作发生。 + +`rsync` 命令有许多 `cp` 没有的选项,例如设置目标权限、排除文件、删除没有在两个目录中出现的过时文件,以及更多。可以使用 `rsync` 作为 `cp` 的强力替代或者有效补充。 + +### 许多复制的方式 + +在 POSIX 系统中有许多能够达成同样目的的方式,因此开源的灵活性名副其实。我忘了哪个复制数据的有效方式吗?在评论区分享你的复制神技。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/copying-files-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[tomjlw](https://github.com/tomjlw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sethhttps://opensource.com/users/scottnesbitthttps://opensource.com/users/greg-p +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/documents_papers_file_storage_work.png?itok=YlXpAqAJ (Filing papers and documents) +[2]: https://opensource.com/sites/default/files/uploads/copy-nautilus.jpg (Copying a file.) +[3]: https://opensource.com/article/19/7/understanding-file-paths-and-how-use-them +[4]: https://opensource.com/sites/default/files/uploads/copy-files-menu.jpg (Copying a file from the context menu.) +[5]: https://linux.cn/article-11222-1.html +[6]: https://opensource.com/article/19/2/getting-started-cat-command +[7]: https://opensource.com/article/19/7/linux-permissions-101 diff --git a/published/201908/20190809 Use a drop-down terminal for fast commands in Fedora.md b/published/201908/20190809 Use a drop-down terminal for fast commands in Fedora.md new file mode 100644 index 0000000000..337f193c5b --- /dev/null +++ b/published/201908/20190809 Use a drop-down terminal for fast commands in Fedora.md @@ -0,0 +1,183 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11216-1.html) +[#]: subject: (Use a drop-down terminal for fast commands in Fedora) +[#]: via: (https://fedoramagazine.org/use-a-drop-down-terminal-for-fast-commands-in-fedora/) +[#]: author: (Guilherme Schelp https://fedoramagazine.org/author/schelp/) + +在 Fedora 下使用下拉式终端更快输入命令 +====== + +![][1] + +下拉式终端可以一键打开,并快速输入桌面上的任何命令。通常它会以平滑的方式创建终端,有时会带有下拉效果。本文演示了如何使用 Yakuake、Tilda、Guake 和 GNOME 扩展等下拉式终端来改善和加速日常任务。 + +### Yakuake + +[Yakuake][2] 是一个基于 KDE Konsole 技术的下拉式终端模拟器。它以 GNU GPLv2 条款分发。它包括以下功能: + +* 从屏幕顶部平滑地滚下 +* 标签式界面 +* 尺寸和动画速度可配置 +* 换肤 +* 先进的 D-Bus 接口 + +要安装 Yakuake,请使用以下命令: + +``` +$ sudo dnf install -y yakuake +``` + +#### 启动和配置 + +如果你运行 KDE,请打开系统设置,然后转到“启动和关闭”。将“yakuake”添加到“自动启动”下的程序列表中,如下所示: + +![][3] + +Yakuake 运行时很容易配置,首先在命令行启动该程序: + +``` +$ yakuake & +``` + +随后出现欢迎对话框。如果标准的快捷键和你已经使用的快捷键冲突,你可以设置一个新的。 + +![][4] + +点击菜单按钮,出现如下帮助菜单。接着,选择“配置 Yakuake……”访问配置选项。 + +![][5] + +你可以自定义外观选项,例如透明度、行为(例如当鼠标指针移过它们时聚焦终端)和窗口(如大小和动画)。在窗口选项中,你会发现当你使用两个或更多监视器时最有用的选项之一:“在鼠标所在的屏幕上打开”。 + +#### 使用 Yakuake + +主要的快捷键有: + + * `F12` = 打开/撤回 Yakuake + * `Ctrl+F11` = 全屏模式 + * `Ctrl+)` = 上下分割 + * `Ctrl+(` = 左右分割 + * `Ctrl+Shift+T` = 新会话 + * `Shift+Right` = 下一个会话 + * `Shift+Left` = 上一个会话 + * `Ctrl+Alt+S` = 重命名会话 + +以下是 Yakuake 像[终端多路复用器][6]一样分割会话的示例。使用此功能,你可以在一个会话中运行多个 shell。 + +![][7] + +### Tilda + +[Tilda][8] 是一个下拉式终端,可与其他流行的终端模拟器相媲美,如 GNOME 终端、KDE 的 Konsole、xterm 等等。 + +它具有高度可配置的界面。你甚至可以更改终端大小和动画速度等选项。Tilda 还允许你启用热键,以绑定到各种命令和操作。 + +要安装 Tilda,请运行以下命令: + +``` +$ sudo dnf install -y tilda +``` + +#### 启动和配置 + +大多数用户更喜欢在登录时就在后台运行一个下拉式终端。要设置此选项,请首先转到桌面上的应用启动器,搜索 Tilda,然后将其打开。 + +接下来,打开 Tilda 配置窗口。 选择“隐藏启动 Tilda”,即启动时不会立即显示终端。 + +![][9] + +接下来,你要设置你的桌面自动启动 Tilda。如果你使用的是 KDE,请转到“系统设置 > 启动与关闭 > 自动启动”并“添加一个程序”。 + +![][10] + +如果你正在使用 GNOME,则可以在终端中运行此命令: + +``` +$ ln -s /usr/share/applications/tilda.desktop ~/.config/autostart/ +``` + +当你第一次运行它时,会出现一个向导来设置首选项。如果需要更改设置,请右键单击终端并转到菜单中的“首选项”。 + +![][11] + +你还可以创建多个配置文件,并绑定其他快捷键以在屏幕上的不同位置打开新终端。为此,请运行以下命令: + +``` +$ tilda -C +``` + +每次使用上述命令时,Tilda 都会在名为 `~/.config/tilda/` 文件夹中创建名为 `config_0`、`config_1` 之类的新配置文件。然后,你可以映射组合键以打开具有一组特定选项的新 Tilda 终端。 + +#### 使用 Tilda + +主要快捷键有: + + * `F1` = 拉下终端 Tilda(注意:如果你有多个配置文件,快捷方式是 F1、F2、F3 等) + * `F11` = 全屏模式 + * `F12` = 切换透明模式 + * `Ctrl+Shift+T` = 添加标签 + * `Ctrl+Page Up` = 下一个标签 + * `Ctrl+Page Down` = 上一个标签 + +### GNOME 扩展 + +Drop-down Terminal [GNOME 扩展][12]允许你在 GNOME Shell 中使用这个有用的工具。它易于安装和配置,使你可以快速访问终端会话。 + +#### 安装 + +打开浏览器并转到[此 GNOME 扩展的站点][12]。启用扩展设置为“On”,如下所示: + +![][13] + +然后选择“Install”以在系统上安装扩展。 + +![][14] + +执行此操作后,无需设置任何自动启动选项。只要你登录 GNOME,扩展程序就会自动运行! + +#### 配置 + +安装后,将打开 Drop-down Terminal 配置窗口以设置首选项。例如,可以设置终端大小、动画、透明度和使用滚动条。 + +![][15] + +如果你将来需要更改某些首选项,请运行 `gnome-shell-extension-prefs` 命令并选择“Drop Down Terminal”。 + +#### 使用该扩展 + +快捷键很简单: + + * 反尖号 (通常是 `Tab` 键上面的一个键) = 打开/撤回终端 + * `F12` (可以定制) = 打开/撤回终端 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/use-a-drop-down-terminal-for-fast-commands-in-fedora/ + +作者:[Guilherme Schelp][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/schelp/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/07/dropdown-terminals-816x345.jpg +[2]: https://kde.org/applications/system/org.kde.yakuake +[3]: https://fedoramagazine.org/wp-content/uploads/2019/07/auto_start-1024x723.png +[4]: https://fedoramagazine.org/wp-content/uploads/2019/07/yakuake_config-1024x419.png +[5]: https://fedoramagazine.org/wp-content/uploads/2019/07/yakuake_config_01.png +[6]: https://fedoramagazine.org/4-cool-terminal-multiplexers/ +[7]: https://fedoramagazine.org/wp-content/uploads/2019/07/yakuake_usage.gif +[8]: https://github.com/lanoxx/tilda +[9]: https://fedoramagazine.org/wp-content/uploads/2019/07/tilda_startup.png +[10]: https://fedoramagazine.org/wp-content/uploads/2019/07/tilda_startup_alt.png +[11]: https://fedoramagazine.org/wp-content/uploads/2019/07/tilda_config.png +[12]: https://extensions.gnome.org/extension/442/drop-down-terminal/ +[13]: https://fedoramagazine.org/wp-content/uploads/2019/07/gnome-shell-install_2-1024x455.png +[14]: https://fedoramagazine.org/wp-content/uploads/2019/07/gnome-shell-install_3.png +[15]: https://fedoramagazine.org/wp-content/uploads/2019/07/gnome-shell-install_4.png diff --git a/published/201908/20190811 How to measure the health of an open source community.md b/published/201908/20190811 How to measure the health of an open source community.md new file mode 100644 index 0000000000..68f5c12299 --- /dev/null +++ b/published/201908/20190811 How to measure the health of an open source community.md @@ -0,0 +1,164 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11244-1.html) +[#]: subject: (How to measure the health of an open source community) +[#]: via: (https://opensource.com/article/19/8/measure-project) +[#]: author: (Jon Lawrence https://opensource.com/users/the3rdlaw) + +如何衡量一个开源社区的健康度 +====== + +> 这比较复杂。 + +![](https://img.linux.net.cn/data/attachment/album/201908/19/184719nz3xuazppzu3vwcg.jpg) + +作为一个经常管理软件开发团队的人,多年来我一直关注度量指标。一次次,我发现自己领导团队使用一个又一个的项目平台(例如 Jira、GitLab 和 Rally)生成了大量可测量的数据。从那时起,我已经及时投入了大量时间从记录平台中提取了有用的指标,并采用了一种我们可以理解的格式,然后使用这些指标对开发的许多方面做出更好的选择。 + +今年早些时候,我有幸在 [Linux 基金会][2]遇到了一个名为[开源软件社区健康分析][3]Community Health Analytics for Open Source Software(CHAOSS)的项目。该项目侧重于从各种来源收集和丰富指标,以便开源社区的利益相关者可以衡量他们项目的健康状况。 + +### CHAOSS 介绍 + +随着我对该项目的基本指标和目标越来越熟悉,一个问题在我的脑海中不断翻滚。什么是“健康”的开源项目,由谁来定义? + +特定角色的人认为健康的东西可能另一个角色的人就不会这样认为。似乎可以用 CHAOSS 收集的细粒度数据进行市场细分实验,重点关注对特定角色可能最有意义的背景问题,以及 CHAOSS 收集哪些指标可能有助于回答这些问题。 + +CHAOSS 项目创建并维护了一套开源应用程序和度量标准定义,使得这个实验具有可能性,这包括: + +* 许多基于服务器的应用程序,用于收集、聚合和丰富度量标准(例如 Augur 和 GrimoireLab)。 +* ElasticSearch、Kibana 和 Logstash(ELK)的开源版本。 +* 身份服务、数据分析服务和各种集成库。 + +在我过去的一个程序中,有六个团队从事于不同复杂程度的项目,我们找到了一个简洁的工具,它允许我们从简单(或复杂)的 JQL 语句中创建我们想要的任何类型的指标,然后针对这些指标开发计算。在我们注意到之前,我们仅从 Jira 中就提取了 400 多个指标,而且还有更多指标来自手动的来源。 + +在项目结束时,我们认定这 400 个指标中,大多数指标在*以我们的角色*做出决策时并不重要。最终,只有三个对我们非常重要:“缺陷去除效率”、“已完成的条目与承诺的条目”,以及“每个开发人员的工作进度”。这三个指标最重要,因为它们是我们对自己、客户和团队成员所做出的承诺,因此是最有意义的。 + +带着这些通过经验得到的教训和对什么是健康的开源项目的问题,我跳进了 CHAOSS 社区,开始建立一套角色,以提供一种建设性的方法,从基于角色的角度回答这个问题。 + +CHAOSS 是一个开源项目,我们尝试使用民主共识来运作。因此,我决定使用组成分子constituent这个词而不是利益相关者,因为它更符合我们作为开源贡献者的责任,以创建更具共生性的价值链。 + +虽然创建此组成模型的过程采用了特定的“目标-问题-度量”方法,但有许多方法可以进行细分。CHAOSS 贡献者已经开发了很好的模型,可以按照矢量进行细分,例如项目属性(例如,个人、公司或联盟)和“失败容忍度”。在为 CHAOSS 开发度量定义时,每个模型都会提供建设性的影响。 + +基于这一切,我开始构建一个谁可能关心 CHAOSS 指标的模型,以及每个组成分子在 CHAOSS 的四个重点领域中最关心的问题: + +* [多样性和包容性][4] +* [演化][5] +* [风险][6] +* [价值][7] + +在我们深入研究之前,重要的是要注意 CHAOSS 项目明确地将背景判断留给了实施指标的团队。什么是“有意义的”和“什么是健康的?”的答案预计会因团队和项目而异。CHAOSS 软件的现成仪表板尽可能地关注客观指标。在本文中,我们关注项目创始人、项目维护者和贡献者。 + +### 项目组成分子 + +虽然这绝不是这些组成分子可能认为重要的问题的详尽清单,但这些选择感觉是一个好的起点。以下每个“目标-问题-度量”标准部分与 CHAOSS 项目正在收集和汇总的指标直接相关。 + +现在,进入分析的第 1 部分! + +#### 项目创始人 + +作为**项目创始人**,我**最**关心: + +* 我的项目**对其他人有用吗?**通过以下测量: + * 随着时间推移有多少复刻? + * **指标:**存储库复刻数。 + * 随着时间的推移有多少贡献者? + * **指标:**贡献者数量。 + * 贡献净质量。 + * **指标:**随着时间的推移提交的错误。 + * **指标:**随着时间的回归。 + * 项目的财务状况。 + * **指标:**随着时间的推移的捐赠/收入。 + * **指标:**随着时间的推移的费用。 +* 我的项目对其它人的**可见**程度? + * 有谁知道我的项目?别人认为它很整洁吗? + * **指标:**社交媒体上的提及、分享、喜欢和订阅的数量。 + * 有影响力的人是否了解我的项目? + * **指标:**贡献者的社会影响力。 + * 人们在公共场所对项目有何评价?是正面还是负面? + * **指标:**跨社交媒体渠道的情感(关键字或 NLP)分析。 +* 我的项目**可行性**程度? + * 我们有足够的维护者吗?该数字是随着时间的推移而上升还是下降? + * **指标:**维护者数量。 + * 改变速度如何随时间变化? + * **指标:**代码随时间的变化百分比。 + * **指标:**拉取请求、代码审查和合并之间的时间。 +* 我的项目的[多样化 & 包容性][4]如何? + * 我们是否拥有有效的公开行为准则(CoC)? + * **度量标准:** 检查存储库中的 CoC 文件。 + * 与我的项目相关的活动是否积极包容? + * **指标:**关于活动的票务政策和活动包容性行为的手动报告。 + * 我们的项目在可访问性上做的好不好? + * **指标:**验证发布的文字会议纪要。 + * **指标:**验证会议期间使用的隐藏式字幕。 + * **指标:**验证在演示文稿和项目前端设计中色盲可访问的素材。 +* 我的项目代表了多少[价值][7]? + * 我如何帮助组织了解使用我们的项目将节省多少时间和金钱(劳动力投资) + * **指标:**仓库的议题、提交、拉取请求的数量和估计人工费率。 + * 我如何理解项目创建的下游价值的数量,以及维护我的项目对更广泛的社区的重要性(或不重要)? + * **指标:**依赖我的项目的其他项目数。 + * 为我的项目做出贡献的人有多少机会使用他们学到的东西来找到合适的工作岗位,以及在哪些组织(即生活工资)? + * **指标:**使用或贡献此库的组织数量。 + * **指标:**使用此类项目的开发人员的平均工资。 + * **指标:**与该项目匹配的关键字的职位发布计数。 + +### 项目维护者 + +作为**项目维护者**,我**最**关心: + +* 我是**高效的**维护者吗? + * **指标:**拉取请求在代码审查之前等待的时间。 + * **指标:**代码审查和后续拉取请求之间的时间。 + * **指标:**我的代码审核中有多少被批准? + * **指标:**我的代码评论中有多少被拒绝或返工? + * **指标:**代码审查的评论的情感分析。 +* 我如何让**更多人**帮助我维护这件事? + * **指标:**项目贡献者的社交覆盖面数量。 +* 我们的**代码质量**随着时间的推移变得越来越好吗? + * **指标:**计算随着时间的推移引入的回归数量。 + * **指标:**计算随着时间推移引入的错误数量。 + * **指标:**错误归档、拉取请求、代码审查、合并和发布之间的时间。 + +### 项目开发者和贡献者 + +作为**项目开发者或贡献者**,我**最**关心: + +* 我可以从为这个项目做出贡献中获得哪些有价值的东西,以及实现这个价值需要多长时间? + * **指标:**下游价值。 + * **指标:**提交、代码审查和合并之间的时间。 +* 通过使用我在贡献中学到的东西来增加工作机是否有良好的前景? + * **指标:**生活工资。 +* 这个项目有多受欢迎? + * **指标:**社交媒体帖子、分享和收藏的数量。 +* 社区有影响力的人知道我的项目吗? + * **指标:**创始人、维护者和贡献者的社交范围。 + +通过创建这个列表,我们开始让 CHAOSS 更加丰满了,并且在今年夏天项目中首次发布该指标时,我迫不及待地想看看广泛的开源社区可能有什么其他伟大的想法,以及我们还可以从这些贡献中学到什么(并衡量!)。 + +### 其它角色 + +接下来,你需要了解有关其他角色(例如基金会、企业开源计划办公室、业务风险和法律团队、人力资源等)以及最终用户的目标问题度量集的更多信息。他们关心开源的不同事物。 + +如果你是开源贡献者或组成分子,我们邀请你[来看看这个项目][8]并参与社区活动! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/measure-project + +作者:[Jon Lawrence][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/the3rdlaw +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen) +[2]: https://www.linuxfoundation.org/ +[3]: https://chaoss.community/ +[4]: https://github.com/chaoss/wg-diversity-inclusion +[5]: https://github.com/chaoss/wg-evolution +[6]: https://github.com/chaoss/wg-risk +[7]: https://github.com/chaoss/wg-value +[8]: https://github.com/chaoss/ diff --git a/published/201908/20190812 How Hexdump works.md b/published/201908/20190812 How Hexdump works.md new file mode 100644 index 0000000000..81c499affb --- /dev/null +++ b/published/201908/20190812 How Hexdump works.md @@ -0,0 +1,228 @@ +[#]: collector: (lujun9972) +[#]: translator: (0x996) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11288-1.html) +[#]: subject: (How Hexdump works) +[#]: via: (https://opensource.com/article/19/8/dig-binary-files-hexdump) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Hexdump 如何工作 +====== + +> Hexdump 能帮助你查看二进制文件的内容。让我们来学习 Hexdump 如何工作。 + +![](https://img.linux.net.cn/data/attachment/album/201908/31/111531h9kzcqooluooqoo7.jpg) + +Hexdump 是个用十六进制、十进制、八进制数或 ASCII 码显示二进制文件内容的工具。它是个用于检查的工具,也可用于[数据恢复][2]、逆向工程和编程。 + +### 学习基本用法 + +Hexdump 让你毫不费力地得到输出结果,依你所查看文件的尺寸,输出结果可能会非常多。本文中我们会创建一个 1x1 像素的 PNG 文件。你可以用图像处理应用如 [GIMP][3] 或 [Mtpaint][4] 来创建该文件,或者也可以在终端内用 [ImageMagick][5] 创建。 + +用 ImagiMagick 生成 1x1 像素 PNG 文件的命令如下: + +``` +$ convert -size 1x1 canvas:black pixel.png +``` + +你可以用 `file` 命令确认此文件是 PNG 格式: + +``` +$ file pixel.png +pixel.png: PNG image data, 1 x 1, 1-bit grayscale, non-interlaced +``` + +你可能好奇 `file` 命令是如何判断文件是什么类型。巧的是,那正是 `hexdump` 将要揭示的原理。眼下你可以用你常用的图像查看软件来看看你的单一像素图片(它看上去就像这样:`.`),或者你可以用 `hexdump` 查看文件内部: + +``` +$ hexdump pixel.png +0000000 5089 474e 0a0d 0a1a 0000 0d00 4849 5244 +0000010 0000 0100 0000 0100 0001 0000 3700 f96e +0000020 0024 0000 6704 4d41 0041 b100 0b8f 61fc +0000030 0005 0000 6320 5248 004d 7a00 0026 8000 +0000040 0084 fa00 0000 8000 00e8 7500 0030 ea00 +0000050 0060 3a00 0098 1700 9c70 51ba 003c 0000 +0000060 6202 474b 0044 dd01 138a 00a4 0000 7407 +0000070 4d49 0745 07e3 081a 3539 a487 46b0 0000 +0000080 0a00 4449 5441 d708 6063 0000 0200 0100 +0000090 21e2 33bc 0000 2500 4574 7458 6164 6574 +00000a0 633a 6572 7461 0065 3032 3931 302d 2d37 +00000b0 3532 3254 3a30 3735 353a 2b33 3231 303a +00000c0 ac30 5dcd 00c1 0000 7425 5845 6474 7461 +00000d0 3a65 6f6d 6964 7966 3200 3130 2d39 3730 +00000e0 322d 5435 3032 353a 3a37 3335 312b 3a32 +00000f0 3030 90dd 7de5 0000 0000 4549 444e 42ae +0000100 8260 +0000102 +``` + +透过一个你以前可能从未用过的视角,你所见的是该示例 PNG 文件的内容。它和你在图像查看软件中看到的是完全一样的数据,只是用一种你或许不熟悉的方式编码。 + +### 提取熟悉的字符串 + +尽管默认的数据输出结果看上去毫无意义,那并不意味着其中没有有价值的信息。你可以用 `--canonical` 选项将输出结果,或至少是其中可翻译的部分,翻译成更加熟悉的字符集: + +``` +$ hexdump --canonical foo.png +00000000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 |.PNG........IHDR| +00000010 00 00 00 01 00 00 00 01 01 00 00 00 00 37 6e f9 |.............7n.| +00000020 24 00 00 00 04 67 41 4d 41 00 00 b1 8f 0b fc 61 |$....gAMA......a| +00000030 05 00 00 00 20 63 48 52 4d 00 00 7a 26 00 00 80 |.... cHRM..z&...| +00000040 84 00 00 fa 00 00 00 80 e8 00 00 75 30 00 00 ea |...........u0...| +00000050 60 00 00 3a 98 00 00 17 70 9c ba 51 3c 00 00 00 |`..:....p..Q<...| +00000060 02 62 4b 47 44 00 01 dd 8a 13 a4 00 00 00 07 74 |.bKGD..........t| +00000070 49 4d 45 07 e3 07 1a 08 39 35 87 a4 b0 46 00 00 |IME.....95...F..| +00000080 00 0a 49 44 41 54 08 d7 63 60 00 00 00 02 00 01 |..IDAT..c`......| +00000090 e2 21 bc 33 00 00 00 25 74 45 58 74 64 61 74 65 |.!.3...%tEXtdate| +000000a0 3a 63 72 65 61 74 65 00 32 30 31 39 2d 30 37 2d |:create.2019-07-| +000000b0 32 35 54 32 30 3a 35 37 3a 35 33 2b 31 32 3a 30 |25T20:57:53+12:0| +000000c0 30 ac cd 5d c1 00 00 00 25 74 45 58 74 64 61 74 |0..]....%tEXtdat| +000000d0 65 3a 6d 6f 64 69 66 79 00 32 30 31 39 2d 30 37 |e:modify.2019-07| +000000e0 2d 32 35 54 32 30 3a 35 37 3a 35 33 2b 31 32 3a |-25T20:57:53+12:| +000000f0 30 30 dd 90 e5 7d 00 00 00 00 49 45 4e 44 ae 42 |00...}....IEND.B| +00000100 60 82 |`.| +00000102 +``` + +在右侧的列中,你看到的是和左侧一样的数据,但是以 ASCII 码展现的。如果你仔细看,你可以从中挑选出一些有用的信息,如文件格式(PNG)以及文件创建、修改日期和时间(向文件底部寻找一下)。 + +`file` 命令通过头 8 个字节获取文件类型。程序员会参考 [libpng 规范][6] 来知晓需要查看什么。具体而言,那就是你能在该图像文件的头 8 个字节中看到的字符串 `PNG`。这个事实显而易见,因为它揭示了 `file` 命令是如何知道要报告的文件类型。 + +你也可以控制 `hexdump` 显示多少字节,这在处理大于一个像素的文件时很实用: + +``` +$ hexdump --length 8 pixel.png +0000000 5089 474e 0a0d 0a1a +0000008 +``` + +`hexdump` 不只限于查看 PNG 或图像文件。你也可以用 `hexdump` 查看你日常使用的二进制文件,如 [ls][7]、[rsync][8],或你想检查的任何二进制文件。 + +### 用 hexdump 实现 cat 命令 + +阅读 PNG 规范的时候你可能会注意到头 8 个字节中的数据与 `hexdump` 提供的结果看上去不一样。实际上,那是一样的数据,但以一种不同的转换方式展现出来。所以 `hexdump` 的输出是正确的,但取决于你在寻找的信息,其输出结果对你而言不总是直接了当的。出于这个原因,`hexdump` 有一些选项可供用于定义格式和转化其转储的原始数据。 + +转换选项可以很复杂,所以用无关紧要的东西练习会比较实用。下面这个简易的介绍,通过重新实现 [cat][9] 命令来演示如何格式化 `hexdump` 的输出。首先,对一个文本文件运行 `hexdump` 来查看其原始数据。通常你可以在硬盘上某处找到 [GNU 通用许可证][10]GNU General Public License(GPL)的一份拷贝,也可以用你手头的任何文本文件。你的输出结果可能不同,但下面是如何在你的系统中找到一份 GPL(或至少其部分)的拷贝: + +``` +$ find /usr/share/doc/ -type f -name "COPYING" | tail -1 +/usr/share/doc/libblkid-devel/COPYING +``` + +对其运行 `hexdump`: + +``` +$ hexdump /usr/share/doc/libblkid-devel/COPYING +0000000 6854 7369 6c20 6269 6172 7972 6920 2073 +0000010 7266 6565 7320 666f 7774 7261 3b65 7920 +0000020 756f 6320 6e61 7220 6465 7369 7274 6269 +0000030 7475 2065 7469 6120 646e 6f2f 0a72 6f6d +0000040 6964 7966 6920 2074 6e75 6564 2072 6874 +0000050 2065 6574 6d72 2073 666f 7420 6568 4720 +0000060 554e 4c20 7365 6573 2072 6547 656e 6172 +0000070 206c 7550 6c62 6369 4c0a 6369 6e65 6573 +0000080 6120 2073 7570 6c62 7369 6568 2064 7962 +[...] +``` + +如果该文件输出结果很长,用 `--length`(或短选项 `-n`)来控制输出长度使其易于管理。 + +原始数据对你而言可能没什么意义,但你已经知道如何将其转换为 ASCII 码: + +``` +hexdump --canonical /usr/share/doc/libblkid-devel/COPYING +00000000  54 68 69 73 20 6c 69 62  72 61 72 79 20 69 73 20  |This library is | +00000010  66 72 65 65 20 73 6f 66  74 77 61 72 65 3b 20 79  |free software; y| +00000020  6f 75 20 63 61 6e 20 72  65 64 69 73 74 72 69 62  |ou can redistrib| +00000030  75 74 65 20 69 74 20 61  6e 64 2f 6f 72 0a 6d 6f  |ute it and/or.mo| +00000040  64 69 66 79 20 69 74 20  75 6e 64 65 72 20 74 68  |dify it under th| +00000050  65 20 74 65 72 6d 73 20  6f 66 20 74 68 65 20 47  |e terms of the G| +00000060  4e 55 20 4c 65 73 73 65  72 20 47 65 6e 65 72 61  |NU Lesser Genera| +00000070  6c 20 50 75 62 6c 69 63  0a 4c 69 63 65 6e 73 65  |l Public.License| +[...] +``` + +这个输出结果有帮助但太累赘且难于阅读。要将 `hexdump` 的输出结果转换为其选项不支持的其他格式,可组合使用 `--format`(或 `-e`)和专门的格式代码。用来自定义格式的代码和 `printf` 命令使用的类似,所以如果你熟悉 `printf` 语句,你可能会觉得 `hexdump` 自定义格式不难学会。 + +在 `hexdump` 中,字符串 `%_p` 告诉 `hexdump` 用你系统的默认字符集输出字符。`--format` 选项的所有格式符号必须以*单引号*包括起来: + +``` +$ hexdump -e'"%_p"' /usr/share/doc/libblkid-devel/COPYING +This library is fre* + software; you can redistribute it and/or.modify it under the terms of the GNU Les* +er General Public.License as published by the Fre* + Software Foundation; either.version 2.1 of the License, or (at your option) any later.version..* +The complete text of the license is available in the..* +/Documentation/licenses/COPYING.LGPL-2.1-or-later file.. +``` + +这次的输出好些了,但依然不方便阅读。传统上 UNIX 文本文件假定 80 个字符的输出宽度(因为很久以前显示器一行只能显示 80 个字符)。 + +尽管这个输出结果未被自定义格式限制输出宽度,你可以用附加选项强制 `hexdump` 一次处理 80 字节。具体而言,通过 80 除以 1 这种形式,你可以告诉 `hexdump` 将 80 字节作为一个单元对待: + +``` +$ hexdump -e'80/1 "%_p"' /usr/share/doc/libblkid-devel/COPYING +This library is free software; you can redistribute it and/or.modify it under the terms of the GNU Lesser General Public.License as published by the Free Software Foundation; either.version 2.1 of the License, or (at your option) any later.version...The complete text of the license is available in the.../Documentation/licenses/COPYING.LGPL-2.1-or-later file.. +``` + +现在该文件被分割成 80 字节的块处理,但没有任何换行。你可以用 `\n` 字符自行添加换行,在 UNIX 中它代表换行: + +``` +$ hexdump -e'80/1 "%_p""\n"' +This library is free software; you can redistribute it and/or.modify it under th +e terms of the GNU Lesser General Public.License as published by the Free Softwa +re Foundation; either.version 2.1 of the License, or (at your option) any later. +version...The complete text of the license is available in the.../Documentation/ +licenses/COPYING.LGPL-2.1-or-later file.. +``` + +现在你已经(大致上)用 `hexdump` 自定义格式实现了 `cat` 命令。 + +### 控制输出结果 + +实际上自定义格式是让 `hexdump` 变得有用的方法。现在你已经(至少是原则上)熟悉 `hexdump` 自定义格式,你可以让 `hexdump -n 8` 的输出结果跟 `libpng` 官方规范中描述的 PNG 文件头相匹配了。 + +首先,你知道你希望 `hexdump` 以 8 字节的块来处理 PNG 文件。此外,你可能通过识别这些整数从而知道 PNG 格式规范是以十进制数表述的,根据 `hexdump` 文档,十进制用 `%d` 来表示: + +``` +$ hexdump -n8 -e'8/1 "%d""\n"' pixel.png +13780787113102610 +``` + +你可以在每个整数后面加个空格使输出结果变得完美: + +``` +$ hexdump -n8 -e'8/1 "%d ""\n"' pixel.png +137 80 78 71 13 10 26 10 +``` + +现在输出结果跟 PNG 规范完美匹配了。 + +### 好玩又有用 + +Hexdump 是个迷人的工具,不仅让你更多地领会计算机如何处理和转换信息,而且让你了解文件格式和编译的二进制文件如何工作。日常工作时你可以随机地试着对不同文件运行 `hexdump`。你永远不知道你会发现什么样的信息,或是什么时候具有这种洞察力会很实用。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/dig-binary-files-hexdump + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[0x996](https://github.com/0x996) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0 (Magnifying glass on code) +[2]: https://www.redhat.com/sysadmin/find-lost-files-scalpel +[3]: http://gimp.org +[4]: https://opensource.com/article/17/2/mtpaint-pixel-art-animated-gifs +[5]: https://opensource.com/article/17/8/imagemagick +[6]: http://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html +[7]: https://opensource.com/article/19/7/master-ls-command +[8]: https://opensource.com/article/19/5/advanced-rsync +[9]: https://opensource.com/article/19/2/getting-started-cat-command +[10]: https://en.wikipedia.org/wiki/GNU_General_Public_License diff --git a/published/201908/20190812 How to Get Linux Kernel 5.0 in Ubuntu 18.04 LTS.md b/published/201908/20190812 How to Get Linux Kernel 5.0 in Ubuntu 18.04 LTS.md new file mode 100644 index 0000000000..ac09fa3ab2 --- /dev/null +++ b/published/201908/20190812 How to Get Linux Kernel 5.0 in Ubuntu 18.04 LTS.md @@ -0,0 +1,86 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11236-1.html) +[#]: subject: (How to Get Linux Kernel 5.0 in Ubuntu 18.04 LTS) +[#]: via: (https://itsfoss.com/ubuntu-hwe-kernel/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu 18.04 LTS 中获取 Linux 5.0 内核 +====== + +> 最近发布的 Ubuntu 18.04.3 包括 Linux 5.0 内核中的几个新功能和改进,但默认情况下没有安装。本教程演示了如何在 Ubuntu 18.04 LTS 中获取 Linux 5 内核。 + +![](https://img.linux.net.cn/data/attachment/album/201908/17/101052xday1jyrszbddsfc.jpg) + +[Ubuntu 18.04 的第三个“点发布版”已经发布][2],它带来了新的稳定版本的 GNOME 组件、livepatch 桌面集成和内核 5.0。 + +可是等等!什么是“小数点版本point release”?让我先解释一下。 + +### Ubuntu LTS 小数点版本 + +Ubuntu 18.04 于 2018 年 4 月发布,由于它是一个长期支持 (LTS) 版本,它将一直支持到 2023 年。从那时起,已经有许多 bug 修复、安全更新和软件升级。如果你今天下载 Ubuntu 18.04,你需要在[在安装 Ubuntu 后首先安装这些更新][3]。 + +当然,这不是一种理想情况。这就是 Ubuntu 提供这些“小数点版本”的原因。点发布版包含所有功能和安全更新以及自 LTS 版本首次发布以来添加的 bug 修复。如果你今天下载 Ubuntu,你会得到 Ubuntu 18.04.3 而不是 Ubuntu 18.04。这节省了在新安装的 Ubuntu 系统上下载和安装数百个更新的麻烦。 + +好了!现在你知道“小数点版本”的概念了。你如何升级到这些小数点版本?答案很简单。只需要像平时一样[更新你的 Ubuntu 系统][4],这样你将在最新的小数点版本上了。 + +你可以[查看 Ubuntu 版本][5]来了解正在使用的版本。我检查了一下,因为我用的是 Ubuntu 18.04.3,我以为我的内核会是 5。当我[查看 Linux 内核版本][6]时,它仍然是基本内核 4.15。 + +![Ubuntu Version And Linux Kernel Version Check][7] + +这是为什么?如果 Ubuntu 18.04.3 有 Linux 5.0 内核,为什么它仍然使用 Linux 4.15 内核?这是因为你必须通过选择 LTS 支持栈Enablement Stack(通常称为 HWE)手动请求在 Ubuntu LTS 中安装新内核。 + +### 使用 HWE 在Ubuntu 18.04 中获取 Linux 5.0 内核 + +默认情况下,Ubuntu LTS 将保持在最初发布的 Linux 内核上。[硬件支持栈][9]hardware enablement stack(HWE)为现有的 Ubuntu LTS 版本提供了更新的内核和 xorg 支持。 + +最近发生了一些变化。如果你下载了 Ubuntu 18.04.2 或更新的桌面版本,那么就会为你启用 HWE,默认情况下你将获得新内核以及常规更新。 + +对于服务器版本以及下载了 18.04 和 18.04.1 的人员,你需要安装 HWE 内核。完成后,你将获得 Ubuntu 提供的更新的 LTS 版本内核。 + +要在 Ubuntu 桌面上安装 HWE 内核以及更新的 xorg,你可以在终端中使用此命令: + +``` +sudo apt install --install-recommends linux-generic-hwe-18.04 xserver-xorg-hwe-18.04 +``` + +如果你使用的是 Ubuntu 服务器版,那么就不会有 xorg 选项。所以只需在 Ubutnu 服务器版中安装 HWE 内核: + +``` +sudo apt-get install --install-recommends linux-generic-hwe-18.04 +``` + +完成 HWE 内核的安装后,重启系统。现在你应该拥有更新的 Linux 内核了。 + +### 你在 Ubuntu 18.04 中获取 5.0 内核了么? + +请注意,下载并安装了 Ubuntu 18.04.2 的用户已经启用了 HWE。所以这些用户将能轻松获取 5.0 内核。 + +在 Ubuntu 中启用 HWE 内核遇到困难了么?这完全取决于你。[Linux 5.0 内核][10]有几项性能改进和更好的硬件支持。你将从新内核获益。 + +你怎么看?你会安装 5.0 内核还是宁愿留在 4.15 内核上? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-hwe-kernel/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.youtube.com/channel/UCEU9D6KIShdLeTRyH3IdSvw +[2]: https://ubuntu.com/blog/enhanced-livepatch-desktop-integration-available-with-ubuntu-18-04-3-lts +[3]: https://itsfoss.com/things-to-do-after-installing-ubuntu-18-04/ +[4]: https://itsfoss.com/update-ubuntu/ +[5]: https://itsfoss.com/how-to-know-ubuntu-unity-version/ +[6]: https://itsfoss.com/find-which-kernel-version-is-running-in-ubuntu/ +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/08/ubuntu-version-and-kernel-version-check.png?resize=800%2C300&ssl=1 +[9]: https://wiki.ubuntu.com/Kernel/LTSEnablementStack +[10]: https://itsfoss.com/linux-kernel-5/ diff --git a/published/201908/20190814 How to Reinstall Ubuntu in Dual Boot or Single Boot Mode.md b/published/201908/20190814 How to Reinstall Ubuntu in Dual Boot or Single Boot Mode.md new file mode 100644 index 0000000000..62cd5beb4d --- /dev/null +++ b/published/201908/20190814 How to Reinstall Ubuntu in Dual Boot or Single Boot Mode.md @@ -0,0 +1,95 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11262-1.html) +[#]: subject: (How to Reinstall Ubuntu in Dual Boot or Single Boot Mode) +[#]: via: (https://itsfoss.com/reinstall-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在双启动或单启动模式下重新安装 Ubuntu +====== + +如果你弄坏了你的 Ubuntu 系统,并尝试了很多方法来修复,你最终放弃并采取简单的方法:重新安装 Ubuntu。 + +我们一直遇到这样一种情况,重新安装 Linux 似乎比找出问题并解决来得更好。排查 Linux 故障能教你很多,但你不会总是花费更多时间来修复损坏的系统。 + +据我所知,Ubuntu 中没有像 Windows 那样的系统恢复分区。那么,问题出现了:如何重新安装 Ubuntu?让我告诉你如何重新安装 Ubuntu。 + +**警告!** + +> **磁盘分区始终是一项危险的任务。我强烈建议你在外部磁盘上备份数据。** + +### 如何重新安装 Ubuntu Linux + +![][1] + +以下是重新安装 Ubuntu 的步骤。 + +#### 步骤 1:创建一个 live USB + +首先,在网站上下载 Ubuntu。你可以下载[任何需要的 Ubuntu 版本][2]。 + +- [下载 Ubuntu][3] + +获得 ISO 镜像后,就可以创建 live USB 了。如果 Ubuntu 系统仍然可以使用,那么可以使用 Ubuntu 提供的启动盘创建工具创建它。 + +如果无法使用你的 Ubuntu,那么你可以使用其他系统。你可以参考这篇文章来学习[如何在 Windows 中创建 Ubuntu 的 live USB][4]。 + +#### 步骤 2:重新安装 Ubuntu + +有了 Ubuntu 的 live USB 之后将其插入 USB 端口。重新启动系统。在启动时,按下 `F2`/`F10`/`F12` 之类的键进入 BIOS 设置,并确保已设置 “Boot from Removable Devices/USB”。保存并退出 BIOS。这将启动进入 live USB。 + +进入 live USB 后,选择安装 Ubuntu。你将看到选择语言和键盘布局这些常用选项。你还可以选择下载更新等。 + +![Go ahead with regular installation option][5] + +现在是重要的步骤。你应该看到一个“安装类型Installation Type”页面。你在屏幕上看到的内容在很大程度上取决于 Ubuntu 如何处理系统上的磁盘分区和安装的操作系统。 + +在此步骤中仔细阅读选项及它的细节。注意每个选项的说明。屏幕上的选项可能在不同的系统中看上去不同。 + +![Reinstall Ubuntu option in dual boot mode][7] + +在这里,它发现我的系统上安装了 Ubuntu 18.04.2 和 Windows,它给了我一些选项。 + +第一个选项是擦除 Ubuntu 18.04.2 并重新安装它。它告诉我它将删除我的个人数据,但它没有说删除所有操作系统(即 Windows)。 + +如果你非常幸运或处于单一启动模式,你可能会看到一个“重新安装 UbuntuReinstall Ubuntu”的选项。此选项将保留现有数据,甚至尝试保留已安装的软件。如果你看到这个选项,那么就用它吧。 + +**双启动系统注意** + +> **如果你是双启动 Ubuntu 和 Windows,并且在重新安装中,你的 Ubuntu 系统看不到 Windows,你必须选择 “Something else” 选项并从那里安装 Ubuntu。我已经在[在双启动下安装 Linux 的过程][8]这篇文章中说明了。** + +对我来说,没有重新安装并保留数据的选项,因此我选择了“擦除 Ubuntu 并重新安装Erase Ubuntu and reinstall”。该选项即使在 Windows 的双启动模式下,也将重新安装 Ubuntu。 + +我建议为 `/` 和 `/home` 使用单独分区就是为了重新安装。这样,即使重新安装 Linux,也可以保证 `/home` 分区中的数据安全。我已在此视频中演示过: + +选择重新安装 Ubuntu 后,剩下就是单击下一步。选择你的位置、创建用户账户。 + +![Just go on with the installation options][9] + +以上完成后,你就完成重装 Ubuntu 了。 + +在本教程中,我假设你已经知道我说的东西,因为你之前已经安装过 Ubuntu。如果需要澄清任何一个步骤,请随时在评论栏询问。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/reinstall-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/08/Reinstall-Ubuntu.png?resize=800%2C450&ssl=1 +[2]: https://itsfoss.com/which-ubuntu-install/ +[3]: https://ubuntu.com/download/desktop +[4]: https://itsfoss.com/create-live-usb-of-ubuntu-in-windows/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/08/reinstall-ubuntu-1.jpg?resize=800%2C473&ssl=1 +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/reinstall-ubuntu-dual-boot.jpg?ssl=1 +[8]: https://itsfoss.com/replace-linux-from-dual-boot/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/reinstall-ubuntu-3.jpg?ssl=1 diff --git a/published/201908/20190815 Fix ‘E- The package cache file is corrupted, it has the wrong hash- Error In Ubuntu.md b/published/201908/20190815 Fix ‘E- The package cache file is corrupted, it has the wrong hash- Error In Ubuntu.md new file mode 100644 index 0000000000..3c5a6ef900 --- /dev/null +++ b/published/201908/20190815 Fix ‘E- The package cache file is corrupted, it has the wrong hash- Error In Ubuntu.md @@ -0,0 +1,74 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11254-1.html) +[#]: subject: (Fix ‘E: The package cache file is corrupted, it has the wrong hash’ Error In Ubuntu) +[#]: via: (https://www.ostechnix.com/fix-e-the-package-cache-file-is-corrupted-it-has-the-wrong-hash-error-in-ubuntu/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +修复 Ubuntu 中 “E: The package cache file is corrupted, it has the wrong hash” 错误 +====== + +今天,我尝试更新我的 Ubuntu 18.04 LTS 的仓库列表,但收到了一条错误消息:“**E: The package cache file is corrupted, it has the wrong hash**”。这是我在终端运行的命令以及输出: + +``` +$ sudo apt update +``` + +示例输出: + +``` +Hit:1 http://it-mirrors.evowise.com/ubuntu bionic InRelease +Hit:2 http://it-mirrors.evowise.com/ubuntu bionic-updates InRelease +Hit:3 http://it-mirrors.evowise.com/ubuntu bionic-backports InRelease +Hit:4 http://it-mirrors.evowise.com/ubuntu bionic-security InRelease +Hit:5 http://ppa.launchpad.net/alessandro-strada/ppa/ubuntu bionic InRelease +Hit:7 http://ppa.launchpad.net/leaeasy/dde/ubuntu bionic InRelease +Hit:8 http://ppa.launchpad.net/rvm/smplayer/ubuntu bionic InRelease +Ign:6 https://dl.bintray.com/etcher/debian stable InRelease +Get:9 https://dl.bintray.com/etcher/debian stable Release [3,674 B] +Fetched 3,674 B in 3s (1,196 B/s) +Reading package lists... Done +E: The package cache file is corrupted, it has the wrong hash +``` + +![][2] + +*Ubuntu 中的 “The package cache file is corrupted, it has the wrong hash” 错误* + +经过一番谷歌搜索,我找到了解决此错误的方法。 + +如果你遇到过这个错误,不要惊慌。只需运行下面的命令修复。 + +在运行命令之前,**请再次确认你在最后加入了 `*`**。在命令最后加上 `*` 很重要。如果你没有添加,它会删除 `/var/lib/apt/lists/`*目录,而且无法恢复。我提醒过你了! + +``` +$ sudo rm -rf /var/lib/apt/lists/* +``` + +现在我再次使用下面的命令更新系统: + +``` +$ sudo apt update +``` + +![][3] + +现在好了!希望它有帮助。 + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/fix-e-the-package-cache-file-is-corrupted-it-has-the-wrong-hash-error-in-ubuntu/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[2]: https://www.ostechnix.com/wp-content/uploads/2019/08/The-package-cache-file-is-corrupted.png +[3]: https://www.ostechnix.com/wp-content/uploads/2019/08/apt-update-command-output-in-Ubuntu.png diff --git a/published/201908/20190815 How To Change Linux Console Font Type And Size.md b/published/201908/20190815 How To Change Linux Console Font Type And Size.md new file mode 100644 index 0000000000..0a92a2ebd8 --- /dev/null +++ b/published/201908/20190815 How To Change Linux Console Font Type And Size.md @@ -0,0 +1,135 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11258-1.html) +[#]: subject: (How To Change Linux Console Font Type And Size) +[#]: via: (https://www.ostechnix.com/how-to-change-linux-console-font-type-and-size/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +如何更改 Linux 控制台字体类型和大小 +====== + +![](https://img.linux.net.cn/data/attachment/album/201908/23/041741x6qiajjijupjyjsp.jpg) + +如果你有图形桌面环境,那么就很容易更改文本的字体以及大小。但你如何在没有图形环境的 Ubuntu 无头服务器中做到?别担心!本指南介绍了如何更改 Linux 控制台的字体和大小。这对于那些不喜欢默认字体类型/大小或者喜欢不同字体的人来说非常有用。 + +### 更改 Linux 控制台字体类型和大小 + +如果你还不知道,这就是无头 Ubuntu Linux 服务器控制台的样子。 + +![][2] + +*Ubuntu Linux 控制台* + +据我所知,我们可以[列出已安装的字体][3],但是没有办法可以像在 Linux 桌面终端仿真器中那样更改 Linux 控制台字体类型或大小。 + +但这并不意味着我们无法改变它。我们仍然可以更改控制台字体。 + +如果你正在使用 Debian、Ubuntu 和其他基于 DEB 的系统,你可以使用 `console-setup` 配置文件来设置 `setupcon`,它用于配置控制台的字体和键盘布局。该控制台设置的配置文件位于 `/etc/default/console-setup`。 + +现在,运行以下命令来设置 Linux 控制台的字体。 + +``` +$ sudo dpkg-reconfigure console-setup +``` + +选择要在 Linux 控制台上使用的编码。只需保留默认值,选择 “OK” 并按回车继续。 + +![][4] + +*选择要在 Ubuntu 控制台上设置的编码* + +接下来,在列表中选择受支持的字符集。默认情况下,它是最后一个选项,即在我的系统中 **Guess optimal character set**(猜测最佳字符集)。只需保留默认值,然后按回车键。 + +![][5] + +*在 Ubuntu 中选择字符集* + +接下来选择控制台的字体,然后按回车键。我这里选择 “TerminusBold”。 + +![][6] + +*选择 Linux 控制台的字体* + +这里,我们为 Linux 控制台选择所需的字体大小。 + +![][7] + +*选择 Linux 控制台的字体大小* + +几秒钟后,所选的字体及大小将应用于你的 Linux 控制台。 + +这是在更改字体类型和大小之前,我的 Ubuntu 18.04 LTS 服务器中控制台字体的样子。 + +![][8] + +这是更改之后。 + +![][9] + +如你所见,文本更大、更好,字体类型也不同于默认。 + +你也可以直接编辑 `/etc/default/console-setup`,并根据需要设置字体类型和大小。根据以下示例,我的 Linux 控制台字体类型为 “Terminus Bold”,字体大小为 32。 + +``` +ACTIVE_CONSOLES="/dev/tty[1-6]" +CHARMAP="UTF-8" +CODESET="guess" +FONTFACE="TerminusBold" +FONTSIZE="16x32" +``` + +### 附录:显示控制台字体 + +要显示你的控制台字体,只需输入: + +``` +$ showconsolefont +``` + +此命令将显示字体的字形或字母表。 + +![][11] + +*显示控制台字体* + +如果你的 Linux 发行版没有 `console-setup`,你可以从[这里][12]获取它。 + +在使用 Systemd 的 Linux 发行版上,你可以通过编辑 `/etc/vconsole.conf` 来更改控制台字体。 + +以下是德语键盘的示例配置。 + +``` +$ vi /etc/vconsole.conf + +KEYMAP=de-latin1 +FONT=Lat2-Terminus16 +``` + +希望这篇文章对你有用! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-change-linux-console-font-type-and-size/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[2]: https://www.ostechnix.com/wp-content/uploads/2019/08/Ubuntu-Linux-console.png +[3]: https://www.ostechnix.com/find-installed-fonts-commandline-linux/ +[4]: https://www.ostechnix.com/wp-content/uploads/2019/08/Choose-encoding-to-set-on-the-console.png +[5]: https://www.ostechnix.com/wp-content/uploads/2019/08/Choose-character-set-in-Ubuntu.png +[6]: https://www.ostechnix.com/wp-content/uploads/2019/08/Choose-font-for-Linux-console.png +[7]: https://www.ostechnix.com/wp-content/uploads/2019/08/Choose-font-size-for-Linux-console.png +[8]: https://www.ostechnix.com/wp-content/uploads/2019/08/Linux-console-tty-ubuntu-1.png +[9]: https://www.ostechnix.com/wp-content/uploads/2019/08/Ubuntu-Linux-TTY-console.png +[10]: https://www.ostechnix.com/how-to-switch-between-ttys-without-using-function-keys-in-linux/ +[11]: https://www.ostechnix.com/wp-content/uploads/2019/08/show-console-fonts.png +[12]: https://software.opensuse.org/package/console-setup diff --git a/published/201908/20190815 How To Fix -Kernel driver not installed (rc--1908)- VirtualBox Error In Ubuntu.md b/published/201908/20190815 How To Fix -Kernel driver not installed (rc--1908)- VirtualBox Error In Ubuntu.md new file mode 100644 index 0000000000..0abdba8e6d --- /dev/null +++ b/published/201908/20190815 How To Fix -Kernel driver not installed (rc--1908)- VirtualBox Error In Ubuntu.md @@ -0,0 +1,93 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11283-1.html) +[#]: subject: (How To Fix “Kernel driver not installed (rc=-1908)” VirtualBox Error In Ubuntu) +[#]: via: (https://www.ostechnix.com/how-to-fix-kernel-driver-not-installed-rc-1908-virtualbox-error-in-ubuntu/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +如何在 Ubuntu 中修复 VirtualBox 的 “Kernel driver not installed (rc=-1908)” 错误 +====== + +我使用 Oracle VirtualBox 来测试各种 Linux 和 Unix 发行版。到目前为止,我已经在 VirtualBox 中测试了上百个虚拟机。今天,我在我的 Ubuntu 18.04 桌面上启动了 Ubuntu 18.04 服务器版虚拟机,我收到了以下错误。 + +``` +Kernel driver not installed (rc=-1908) + +The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall virtualbox-dkms package and load the kernel module by executing + +'modprobe vboxdrv' + +as root. + +where: suplibOsInit what: 3 VERR_VM_DRIVER_NOT_INSTALLED (-1908) - The support driver is not installed. On linux, open returned ENOENT. +``` + +![][2] + +*Ubuntu 中的 “Kernel driver not installed (rc=-1908)” 错误* + +我点击了 OK 关闭消息框,然后在后台看到了另一条消息。 + +``` +Failed to open a session for the virtual machine Ubuntu 18.04 LTS Server. + +The virtual machine 'Ubuntu 18.04 LTS Server' has terminated unexpectedly during startup with exit code 1 (0x1). + +Result Code: +NS_ERROR_FAILURE (0x80004005) +Component: +MachineWrap +Interface: +IMachine {85cd948e-a71f-4289-281e-0ca7ad48cd89} +``` + +![][3] + +*启动期间虚拟机意外终止,退出代码为 1(0x1)* + +我不知道该先做什么。我运行以下命令来检查是否有用。 + +``` +$ sudo modprobe vboxdrv +``` + +我收到了这个错误: + +``` +modprobe: FATAL: Module vboxdrv not found in directory /lib/modules/5.0.0-23-generic +``` + +仔细阅读这两个错误消息后,我意识到我应该更新 Virtualbox 程序。 + +如果你在 Ubuntu 及其衍生版(如 Linux Mint)中遇到此错误,你只需使用以下命令重新安装或更新 `virtualbox-dkms` 包: + +``` +$ sudo apt install virtualbox-dkms +``` + +或者,最好更新整个系统: + +``` +$ sudo apt upgrade +``` + +错误消失了,我可以正常在 VirtualBox 中启动虚拟机了。 + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-fix-kernel-driver-not-installed-rc-1908-virtualbox-error-in-ubuntu/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[2]: https://www.ostechnix.com/wp-content/uploads/2019/08/Kernel-driver-not-installed-virtualbox-ubuntu.png +[3]: https://www.ostechnix.com/wp-content/uploads/2019/08/The-virtual-machine-has-terminated-unexpectedly-during-startup-with-exit-code-1-0x1.png +[4]: https://www.ostechnix.com/solve-result-code-ns_error_failure-0x80004005-virtualbox-error-arch-linux/ diff --git a/published/201908/20190815 How To Set up Automatic Security Update (Unattended Upgrades) on Debian-Ubuntu.md b/published/201908/20190815 How To Set up Automatic Security Update (Unattended Upgrades) on Debian-Ubuntu.md new file mode 100644 index 0000000000..486767a090 --- /dev/null +++ b/published/201908/20190815 How To Set up Automatic Security Update (Unattended Upgrades) on Debian-Ubuntu.md @@ -0,0 +1,156 @@ +[#]: collector: (lujun9972) +[#]: translator: (tomjlw) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11252-1.html) +[#]: subject: (How To Set up Automatic Security Update (Unattended Upgrades) on Debian/Ubuntu?) +[#]: via: (https://www.2daygeek.com/automatic-security-update-unattended-upgrades-ubuntu-debian/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +如何在 Debian/Ubuntu 上设置自动安全更新(无人值守更新) +====== + +对于 Linux 管理员来说重要的任务之一是让系统保持最新状态,这可以使得你的系统更加稳健并且可以避免不想要的访问与攻击。 + +在 Linux 上安装软件包是小菜一碟,用相似的方法我们也可以更新安全补丁。 + +这是一个向你展示如何配置系统接收自动安全更新的简单教程。当你运行自动安全包更新而不经审查会给你带来一定风险,但是也有一些好处。 + +如果你不想错过安全补丁,且想要与最新的安全补丁保持同步,那你应该借助无人值守更新机制设置自动安全更新。 + +如果你不想要自动安全更新的话,你可以[在 Debian/Ubuntu 系统上手动安装安全更新][1]。 + +我们有许多可以自动化更新的办法,然而我们将先采用官方的方法之后我们会介绍其它方法。 + +### 如何在 Debian/Ubuntu 上安装无人值守更新包 + +无人值守更新包默认应该已经装在你的系统上。但万一它没被安装,就用下面的命令来安装。 + +使用 [APT-GET 命令][2]和 [APT 命令][3]来安装 `unattended-upgrades` 软件包。 + +``` +$ sudo apt-get install unattended-upgrades +``` + +下方两个文件可以使你自定义该机制: + +``` +/etc/apt/apt.conf.d/50unattended-upgrades +/etc/apt/apt.conf.d/20auto-upgrades +``` + +### 在 50unattended-upgrades 文件中做出必要修改 + +默认情况下只有安全更新需要的最必要的选项被启用。但并不限于此,你可以配置其中的许多选项以使得这个机制更加有用。 + +我修改了一下文件并仅加上被启用的行以方便阐述: + +``` +# vi /etc/apt/apt.conf.d/50unattended-upgrades + +Unattended-Upgrade::Allowed-Origins { + "${distro_id}:${distro_codename}"; + "${distro_id}:${distro_codename}-security"; + "${distro_id}ESM:${distro_codename}"; + }; +Unattended-Upgrade::DevRelease "false"; +``` + +有三个源被启用,细节如下: + + * `${distro_id}:${distro_codename}`:这是必须的,因为安全更新可能会从非安全来源拉取依赖。 + * `${distro_id}:${distro_codename}-security`:这用来从来源得到安全更新。 + * `${distro_id}ESM:${distro_codename}`:这是用来从 ESM(扩展安全维护)获得安全更新。 + +**启用邮件通知:** 如果你想要在每次安全更新后收到邮件通知,那么就修改以下行段(取消其注释并加上你的 email 账号)。 + +从: + +``` +//Unattended-Upgrade::Mail "root"; +``` + +修改为: + +``` +Unattended-Upgrade::Mail "2daygeek@gmail.com"; +``` + +**自动移除不用的依赖:** 你可能需要在每次更新后运行 `sudo apt autoremove` 命令来从系统中移除不用的依赖。 + +我们可以通过修改以下行来自动化这项任务(取消注释并将 `false` 改成 `true`)。 + +从: + +``` +//Unattended-Upgrade::Remove-Unused-Dependencies "false"; +``` + +修改为: + +``` +Unattended-Upgrade::Remove-Unused-Dependencies "true"; +``` + +**启用自动重启:** 你可能需要在安全更新安装至内核后重启你的系统。你可以在以下行做出修改: + +从: + +``` +//Unattended-Upgrade::Automatic-Reboot "false"; +``` + +到:取消注释并将 `false` 改成 `true`以启用自动重启。 + +``` +Unattended-Upgrade::Automatic-Reboot "true"; +``` + +**启用特定时段的自动重启:** 如果自动重启已启用,且你想要在特定时段进行重启,那么做出以下修改。 + +从: + +``` +//Unattended-Upgrade::Automatic-Reboot-Time "02:00"; +``` + +到:取消注释并将时间改成你需要的时间。我将重启设置在早上 5 点。 + +``` +Unattended-Upgrade::Automatic-Reboot-Time "05:00"; +``` + +### 如何启用自动化安全更新? + +现在我们已经配置好了必须的选项,一旦配置好,打开以下文件并确认是否这两个值都已设置好?值不应为0。(1=启用,0=禁止)。 + +``` +# vi /etc/apt/apt.conf.d/20auto-upgrades + +APT::Periodic::Update-Package-Lists "1"; +APT::Periodic::Unattended-Upgrade "1"; +``` + +**详情:** + + * 第一行使 `apt` 每天自动运行 `apt-get update`。 + * 第一行使 `apt` 每天自动安装安全更新。 + + + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/automatic-security-update-unattended-upgrades-ubuntu-debian/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[tomjlw](https://github.com/tomjlw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/manually-install-security-updates-ubuntu-debian/ +[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/ diff --git a/published/201908/20190815 How To Setup Multilingual Input Method On Ubuntu.md b/published/201908/20190815 How To Setup Multilingual Input Method On Ubuntu.md new file mode 100644 index 0000000000..d2795355ee --- /dev/null +++ b/published/201908/20190815 How To Setup Multilingual Input Method On Ubuntu.md @@ -0,0 +1,170 @@ +[#]: collector: (lujun9972) +[#]: translator: (tomjlw) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11255-1.html) +[#]: subject: (How To Setup Multilingual Input Method On Ubuntu) +[#]: via: (https://www.ostechnix.com/how-to-setup-multilingual-input-method-on-ubuntu/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +如何在 Ubuntu 上设置多语言输入法 +====== + +![](https://img.linux.net.cn/data/attachment/album/201908/21/231916g3gxbhybq0zv0q1h.jpg) + +或许你不知道,在印度有数以百计的语言被使用,其中 22 种被印度机构列为官方语言。我的母语不是英语,因此当我需要从英语输入或者翻译到我的母语泰米尔语时我经常使用**谷歌翻译**。嗯,我估计我不再需要依靠谷歌翻译了。我刚发现在 Ubuntu 上输入印度语的好办法。这篇教程解释了如何配置多语言输入法的方法。这个是为 Ubuntu 18.04 LTS 特别打造的,但是它可以在其它类 Ubuntu 系统例如 Linux mint、Elementary OS 上使用。 + +### 在 Ubuntu Linux 上设置多语言输入法 + +通过 **IBus** 的帮助,我们可以轻松在 Ubuntu 及其衍生物上配置多语言输入法。Ibus,代表 **I** ntelligent **I** nput **Bus**(智能输入总线),是一种针对类 Unix 操作系统下多语言输入的输入法框架。它使得我们可以在大多数 GUI 应用例如 LibreOffice 下输入母语。 + +### 在 Ubuntu 上安装 IBus + +在 Ubuntu 上 安装 IBus 包,运行: + +``` +$ sudo apt install ibus-m17n +``` + +Ibus-m17n 包提供了许多印度语和其它国家语言包括阿姆哈拉语,阿拉伯语,阿美尼亚语,阿萨姆语,阿萨巴斯卡语,白俄罗斯语,孟加拉语,缅甸语,中高棉语,占文,**汉语**,克里语,克罗地亚语,捷克语,丹麦语,迪维希语,马尔代夫语,世界语,法语,格鲁吉亚语,古/现代希腊语,古吉拉特语,希伯来语,因纽特语,日语,卡纳达语,克什米尔语,哈萨克语,韩语,老挝语,马来语,马拉地语,尼泊尔语,欧吉布威语,欧瑞亚语,旁遮普语,波斯语,普什图语,俄语,梵语,塞尔维亚语,四川彝文,彝文,西格西卡语,信德语,僧伽罗语,斯洛伐克语,瑞典语,泰语,泰米尔语,泰卢固语,藏语,维吾尔语,乌都语,乌兹别克语,越语及意第绪语。 + +##### 添加输入语言 + +我们可以在系统里的**设置**部分添加语言。点击你的 Ubuntu 桌面右上角的下拉箭头选择底部左下角的设置图标。 + +![][2] + +*从顶部面板启动系统设置* + +从设置部分,点击左侧面板的**区域及语言**选项。再点击右侧**输入来源**标签下的**+**(加号)按钮。 + +![][3] + +*设置部分的区域及语言选项* + +在下个窗口,点击**三个垂直的点**按钮。 + +![][4] + +*在 Ubuntu 里添加输入来源* + +搜寻并选择你想从列表中添加的输入语言。 + +![][5] + +*添加输入语言* + +在本篇教程中,我将加入**泰米尔**语。在选择语言后,点击**添加**按钮。 + +![][6] + +*添加输入来源* + +现在你会看到选中的输入来源已经被添加了。你会在输入来源标签下的区域及语言选项中看到它。 + +![][7] + +*Ubuntu 里的输入来源选项* + +点击输入来源标签下的“管理安装的语言”按钮 + +![][8] + +*在 Ubuntu 里管理安装的语言* + +接下来你会被询问是否想要为选定语言安装翻译包。如果你想的话你可以安装它们。或者仅仅选择“稍后提醒我”按钮。你下次打开的时候会收到统治。 + +![][9] + +*语言支持没完全安装好* + +一旦翻译包安装好,点击**安装/移除语言**按钮。同时确保 IBus 在键盘输入法系统中被选中。 + +![][10] + +*在 Ubuntu 中安装/移除语言* + +从列表中选择你想要的语言并点击采用按钮。 + +![][11] + +*选择输入语言* + +到此为止了。我们已成功在 Ubuntu 18.04 桌面上配置好多语输入方法。同样的,你可以添加尽可能多的输入语言。 + +在添加完所有语言来源后,登出再登陆回去。 + +### 用印度语或者你喜欢的语言输入 + +一旦你添加完所有语言后,你就会从你的 Ubuntu 桌面上的顶端菜单下载栏看到它们。 + +![][12] + +*从 Ubuntu 桌面的顶端栏选择输入语言。* + +你也可以使用键盘上的**徽标键+空格键**在不同语言中切换。 + +![][13] + +*在 Ubuntu 里用**徽标键+空格键**选择输入语言* + +打开任何 GUI 文本编辑器/应用开始打字吧! + +![][14] + +*在 Ubuntu 中用印度语输入* + +### 将 IBus 加入启动应用 + +我们需要让 IBus 在每次重启后自动打开,这样每次你想要用自己喜欢的语言输入的时候就无须手动打开。 + +为此仅须在面板中输入“开机应用”点开开机应用选项。 + +![][15] + +在下个窗口,点击添加,在名字栏输入“Ibus”并在命令栏输入“ibus-daemon”点击添加按钮。 + +![][16] + +*在 Ubuntu 中将 Ibus 添加进开机启动项* + +从现在起 IBus 将在系统启动后自动开始。 + +现在到你的回合了。在什么应用/工具中你用当地的印度语输入?在下方评论区让我们知道它们。 + +参考: + + * [IBus – Ubuntu 社区百科][20] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-setup-multilingual-input-method-on-ubuntu/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[tomjlw](https://github.com/tomjlw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[2]: https://www.ostechnix.com/wp-content/uploads/2019/07/Ubuntu-system-settings.png +[3]: https://www.ostechnix.com/wp-content/uploads/2019/08/Region-language-in-Settings-ubuntu.png +[4]: https://www.ostechnix.com/wp-content/uploads/2019/08/Add-input-source-in-Ubuntu.png +[5]: https://www.ostechnix.com/wp-content/uploads/2019/08/Add-input-language.png +[6]: https://www.ostechnix.com/wp-content/uploads/2019/08/Add-Input-Source-Ubuntu.png +[7]: https://www.ostechnix.com/wp-content/uploads/2019/08/Input-sources-Ubuntu.png +[8]: https://www.ostechnix.com/wp-content/uploads/2019/08/Manage-Installed-Languages.png +[9]: https://www.ostechnix.com/wp-content/uploads/2019/08/The-language-support-is-not-installed-completely.png +[10]: https://www.ostechnix.com/wp-content/uploads/2019/08/Install-Remove-languages.png +[11]: https://www.ostechnix.com/wp-content/uploads/2019/08/Choose-language.png +[12]: https://www.ostechnix.com/wp-content/uploads/2019/08/Choose-input-language-from-top-bar-in-Ubuntu.png +[13]: https://www.ostechnix.com/wp-content/uploads/2019/08/Choose-input-language-using-SuperSpace-keys.png +[14]: https://www.ostechnix.com/wp-content/uploads/2019/08/Setup-Multilingual-Input-Method-On-Ubuntu.png +[15]: https://www.ostechnix.com/wp-content/uploads/2019/08/Launch-startup-applications-in-ubuntu.png +[16]: https://www.ostechnix.com/wp-content/uploads/2019/08/Add-Ibus-to-startup-applications-on-Ubuntu.png +[17]: https://www.ostechnix.com/use-google-translate-commandline-linux/ +[18]: https://www.ostechnix.com/type-indian-rupee-sign-%e2%82%b9-linux/ +[19]: https://www.ostechnix.com/setup-japanese-language-environment-arch-linux/ +[20]: https://help.ubuntu.com/community/ibus diff --git a/published/201908/20190815 SSLH - Share A Same Port For HTTPS And SSH.md b/published/201908/20190815 SSLH - Share A Same Port For HTTPS And SSH.md new file mode 100644 index 0000000000..88bbbfc21a --- /dev/null +++ b/published/201908/20190815 SSLH - Share A Same Port For HTTPS And SSH.md @@ -0,0 +1,205 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11247-1.html) +[#]: subject: (SSLH – Share A Same Port For HTTPS And SSH) +[#]: via: (https://www.ostechnix.com/sslh-share-port-https-ssh/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +SSLH:让 HTTPS 和 SSH 共享同一个端口 +====== + +![SSLH - Share A Same Port For HTTPS And SSH][1] + +一些 ISP 和公司可能已经阻止了大多数端口,并且只允许少数特定端口(如端口 80 和 443)访问来加强其安全性。在这种情况下,我们别无选择,但同一个端口可以用于多个程序,比如 HTTPS 端口 443,很少被阻止。通过 SSL/SSH 多路复用器 SSLH 的帮助,它可以侦听端口 443 上的传入连接。更简单地说,SSLH 允许我们在 Linux 系统上的端口 443 上运行多个程序/服务。因此,你可以同时通过同一个端口同时使用 SSL 和 SSH。如果你遇到大多数端口被防火墙阻止的情况,你可以使用 SSLH 访问远程服务器。这个简短的教程描述了如何在类 Unix 操作系统中使用 SSLH 让 https、ssh 共享相同的端口。 + +### SSLH:让 HTTPS、SSH 共享端口 + +#### 安装 SSLH + +大多数 Linux 发行版上 SSLH 都有软件包,因此你可以使用默认包管理器进行安装。 + +在 Debian、Ubuntu 及其衍生品上运行: + +``` +$ sudo apt-get install sslh +``` + +安装 SSLH 时,将提示你是要将 sslh 作为从 inetd 运行的服务,还是作为独立服务器运行。每种选择都有其自身的优点。如果每天只有少量连接,最好从 inetd 运行 sslh 以节省资源。另一方面,如果有很多连接,sslh 应作为独立服务器运行,以避免为每个传入连接生成新进程。 + +![][2] + +*安装 sslh* + +在 Arch Linux 和 Antergos、Manjaro Linux 等衍生品上,使用 Pacman 进行安装,如下所示: + +``` +$ sudo pacman -S sslh +``` + +在 RHEL、CentOS 上,你需要添加 EPEL 存储库,然后安装 SSLH,如下所示: + +``` +$ sudo yum install epel-release +$ sudo yum install sslh +``` + +在 Fedora: + +``` +$ sudo dnf install sslh +``` + +如果它在默认存储库中不可用,你可以如[这里][3]所述手动编译和安装 SSLH。 + +#### 配置 Apache 或 Nginx Web 服务器 + +如你所知,Apache 和 Nginx Web 服务器默认会监听所有网络接口(即 `0.0.0.0:443`)。我们需要更改此设置以告知 Web 服务器仅侦听 `localhost` 接口(即 `127.0.0.1:443` 或 `localhost:443`)。 + +为此,请编辑 Web 服务器(nginx 或 apache)配置文件并找到以下行: + +``` +listen 443 ssl; +``` + +将其修改为: + +``` +listen 127.0.0.1:443 ssl; +``` + +如果你在 Apache 中使用虚拟主机,请确保你也修改了它。 + +``` +VirtualHost 127.0.0.1:443 +``` + +保存并关闭配置文件。不要重新启动该服务。我们还没有完成。 + +#### 配置 SSLH + +使 Web 服务器仅在本地接口上侦听后,编辑 SSLH 配置文件: + +``` +$ sudo vi /etc/default/sslh +``` + +找到下列行: + +``` +Run=no +``` + +将其修改为: + +``` +Run=yes +``` + +然后,向下滚动一点并修改以下行以允许 SSLH 在所有可用接口上侦听端口 443(例如 `0.0.0.0:443`)。 + +``` +DAEMON_OPTS="--user sslh --listen 0.0.0.0:443 --ssh 127.0.0.1:22 --ssl 127.0.0.1:443 --pidfile /var/run/sslh/sslh.pid" +``` + +这里, + + * `–user sslh`:要求在这个特定的用户身份下运行。 + * `–listen 0.0.0.0:443`:SSLH 监听于所有可用接口的 443 端口。 + * `–sshs 127.0.0.1:22` : 将 SSH 流量路由到本地的 22 端口。 + * `–ssl 127.0.0.1:443` : 将 HTTPS/SSL 流量路由到本地的 443 端口。 + +保存并关闭文件。 + +最后,启用并启动 `sslh` 服务以更新更改。 + +``` +$ sudo systemctl enable sslh +$ sudo systemctl start sslh +``` + +#### 测试 + +检查 SSLH 守护程序是否正在监听 443。 + +``` +$ ps -ef | grep sslh +sslh 2746 1 0 15:51 ? 00:00:00 /usr/sbin/sslh --foreground --user sslh --listen 0.0.0.0 443 --ssh 127.0.0.1 22 --ssl 127.0.0.1 443 --pidfile /var/run/sslh/sslh.pid +sslh 2747 2746 0 15:51 ? 00:00:00 /usr/sbin/sslh --foreground --user sslh --listen 0.0.0.0 443 --ssh 127.0.0.1 22 --ssl 127.0.0.1 443 --pidfile /var/run/sslh/sslh.pid +sk 2754 1432 0 15:51 pts/0 00:00:00 grep --color=auto sslh +``` + +现在,你可以使用端口 443 通过 SSH 访问远程服务器: + +``` +$ ssh -p 443 [email protected] +``` + +示例输出: + +``` +[email protected]'s password: +Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-55-generic x86_64) + +* Documentation: https://help.ubuntu.com +* Management: https://landscape.canonical.com +* Support: https://ubuntu.com/advantage + +System information as of Wed Aug 14 13:11:04 IST 2019 + +System load: 0.23 Processes: 101 +Usage of /: 53.5% of 19.56GB Users logged in: 0 +Memory usage: 9% IP address for enp0s3: 192.168.225.50 +Swap usage: 0% IP address for enp0s8: 192.168.225.51 + +* Keen to learn Istio? It's included in the single-package MicroK8s. + +https://snapcraft.io/microk8s + +61 packages can be updated. +22 updates are security updates. + + +Last login: Wed Aug 14 13:10:33 2019 from 127.0.0.1 +``` + +![][4] + +*通过 SSH 使用 443 端口访问远程系统* + +看见了吗?即使默认的 SSH 端口 22 被阻止,我现在也可以通过 SSH 访问远程服务器。正如你在上面的示例中所看到的,我使用 https 端口 443 进行 SSH 连接。 + +我在我的 Ubuntu 18.04 LTS 服务器上测试了 SSLH,它如上所述工作得很好。我在受保护的局域网中测试了 SSLH,所以我不知道是否有安全问题。如果你在生产环境中使用它,请在下面的评论部分中告诉我们使用 SSLH 的优缺点。 + +有关更多详细信息,请查看下面给出的官方 GitHub 页面。 + +资源: + +* [SSLH GitHub 仓库][12] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/sslh-share-port-https-ssh/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2017/08/SSLH-Share-A-Same-Port-For-HTTPS-And-SSH-1-720x340.jpg +[2]: https://www.ostechnix.com/wp-content/uploads/2017/08/install-sslh.png +[3]: https://github.com/yrutschle/sslh/blob/master/doc/INSTALL.md +[4]: https://www.ostechnix.com/wp-content/uploads/2017/08/Access-remote-systems-via-SSH-using-port-443.png +[5]: https://www.ostechnix.com/how-to-ssh-into-a-particular-directory-on-linux/ +[6]: https://www.ostechnix.com/how-to-create-ssh-alias-in-linux/ +[7]: https://www.ostechnix.com/configure-ssh-key-based-authentication-linux/ +[8]: https://www.ostechnix.com/how-to-stop-ssh-session-from-disconnecting-in-linux/ +[9]: https://www.ostechnix.com/allow-deny-ssh-access-particular-user-group-linux/ +[10]: https://www.ostechnix.com/4-ways-keep-command-running-log-ssh-session/ +[11]: https://www.ostechnix.com/scanssh-fast-ssh-server-open-proxy-scanner/ +[12]: https://github.com/yrutschle/sslh diff --git a/published/201908/20190817 GNOME and KDE team up on the Linux desktop, docs for Nvidia GPUs open up, a powerful new way to scan for firmware vulnerabilities, and more news.md b/published/201908/20190817 GNOME and KDE team up on the Linux desktop, docs for Nvidia GPUs open up, a powerful new way to scan for firmware vulnerabilities, and more news.md new file mode 100644 index 0000000000..b0093ff375 --- /dev/null +++ b/published/201908/20190817 GNOME and KDE team up on the Linux desktop, docs for Nvidia GPUs open up, a powerful new way to scan for firmware vulnerabilities, and more news.md @@ -0,0 +1,81 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11241-1.html) +[#]: subject: (GNOME and KDE team up on the Linux desktop, docs for Nvidia GPUs open up, a powerful new way to scan for firmware vulnerabilities, and more news) +[#]: via: (https://opensource.com/article/19/8/news-august-17) +[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) + +开源新闻综述:GNOME 和 KDE 达成合作、Nvidia 开源 GPU 文档 +====== + +> 不要错过两周以来最大的开源头条新闻。 + +![Weekly news roundup with TV][1] + +在本期开源新闻综述中,我们将介绍两种新的强大数据可视化工具、Nvidia 开源其 GPU 文档、激动人心的新工具、确保自动驾驶汽车的固件安全等等! + +### GNOME 和 KDE 在 Linux 桌面上达成合作伙伴 + +Linux 在桌面计算机上一直处于分裂状态。在最近的一篇[公告][2]中称,“两个主要的 Linux 桌面竞争对手,[GNOME 基金会][3] 和 [KDE][4] 已经同意合作。” + +这两个组织将成为今年 11 月在巴塞罗那举办的 [Linux App Summit(LAS)2019][5] 的赞助商。这一举措在某种程度上似乎是对桌面计算不再是争夺支配地位的最佳场所的回应。无论是什么原因,Linux 桌面的粉丝们都有新的理由希望未来出现一个标准化的 GUI 环境。 + +### 新的开源数据可视化工具 + +这个世界上很少有不是由数据驱动的。除非数据以人们可以互动的形式出现,否则它并不是很好使用。最近开源的两个数据可视化项目正在尝试使数据更有用。 + +第一个工具名为 **Neuroglancer**,由 [Google 的研究团队][6]创建。它“使神经科医生能够在交互式可视化中建立大脑神经通路的 3D 模型。”Neuroglancer 通过使用神经网络追踪大脑中的神经元路径并构建完整的可视化来实现这一点。科学家已经使用了 Neuroglancer(你可以[从 GitHub 取得][7])通过扫描果蝇的大脑来建立一个交互式地图。 + +第二个工具来自一个不太能想到的的来源:澳大利亚信号理事会。这是该国家类似 NSA 的机构,它“开源了[内部数据可视化和分析工具][8]之一。”这个被称为 **[Constellation][9]** 的工具可以“识别复杂数据集中的趋势和模式,并且能够扩展到‘数十亿输入’。”该机构总干事迈克•伯吉斯表示,他希望“这一工具将有助于产生有利于所有澳大利亚人的科学和其他方面的突破。”鉴于它是开源的,它可以使整个世界受益。 + +### Nvidia 开始发布 GPU 文档 + +多年来,图形处理单元(GPU)制造商 Nvidia 并没有做出什么让开源项目轻松开发其产品的驱动程序的努力。现在,该公司通过[发布 GPU 硬件文档][10]向这些项目迈出了一大步。 + +该公司根据 MIT 许可证发布的文档[可在 GitHub 上获取][11]。它涵盖了几个关键领域,如设备初始化、内存时钟/调整和电源状态。据硬件新闻网站 Phoronix 称,开发了 Nvidia GPU 的开源驱动程序的 Nouveau 项目将是率先使用该文档来推动其开发工作的项目之一。 + +### 用于保护固件的新工具 + +似乎每周都有的消息称,移动设备或连接互联网的小设备中出现新漏洞。通常,这些漏洞存在于控制设备的固件中。自动驾驶汽车服务 Cruise [发布了一个开源工具][12],用于在这些漏洞成为问题之前捕获这些漏洞。 + +该工具被称为 [FwAnalzyer][13]。它检查固件代码中是否存在许多潜在问题,包括“识别潜在危险的可执行文件”,并查明“任何错误遗留的调试代码”。Cruise 的工程师 Collin Mulliner 曾帮助开发该工具,他说通过在代码上运行 FwAnalyzer,固件开发人员“现在能够检测并防止各种安全问题。” + +### 其它新闻 + +* [为什么洛杉矶决定将未来寄予开源][14] +* [麻省理工学院出版社发布了关于开源出版软件的综合报告][15] +* [华为推出鸿蒙操作系统,不会放弃 Android 智能手机][16] + +*一如既往地感谢 Opensource.com 的工作人员和主持人本周的帮助。* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/news-august-17 + +作者:[Scott Nesbitt][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/scottnesbitt +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/weekly_news_roundup_tv.png?itok=B6PM4S1i (Weekly news roundup with TV) +[2]: https://www.zdnet.com/article/gnome-and-kde-work-together-on-the-linux-desktop/ +[3]: https://www.gnome.org/ +[4]: https://kde.org/ +[5]: https://linuxappsummit.org/ +[6]: https://www.cbronline.com/news/brain-mapping-google-ai +[7]: https://github.com/google/neuroglancer +[8]: https://www.computerworld.com.au/article/665286/australian-signals-directorate-open-sources-data-analysis-tool/ +[9]: https://www.constellation-app.com/ +[10]: https://www.phoronix.com/scan.php?page=news_item&px=NVIDIA-Open-GPU-Docs +[11]: https://github.com/nvidia/open-gpu-doc +[12]: https://arstechnica.com/information-technology/2019/08/self-driving-car-service-open-sources-new-tool-for-securing-firmware/ +[13]: https://github.com/cruise-automation/fwanalyzer +[14]: https://www.techrepublic.com/article/why-la-decided-to-open-source-its-future/ +[15]: https://news.mit.edu/2019/mit-press-report-open-source-publishing-software-0808 +[16]: https://www.itnews.com.au/news/huawei-unveils-harmony-operating-system-wont-ditch-android-for-smartphones-529432 diff --git a/published/201908/20190817 LiVES Video Editor 3.0 is Here With Significant Improvements.md b/published/201908/20190817 LiVES Video Editor 3.0 is Here With Significant Improvements.md new file mode 100644 index 0000000000..309a394d97 --- /dev/null +++ b/published/201908/20190817 LiVES Video Editor 3.0 is Here With Significant Improvements.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: (scvoet) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11266-1.html) +[#]: subject: (LiVES Video Editor 3.0 is Here With Significant Improvements) +[#]: via: (https://itsfoss.com/lives-video-editor/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +LiVES 视频编辑器 3.0 有了显著的改善 +====== + +我们最近列出了一个[最佳开源视频编辑器][1]的清单。LiVES 是这些开源视频编辑器之一,可以免费使用。 + +即使许多用户还在等待 Windows 版本的发行,但在刚刚发行的 LiVES 视频编辑器 Linux 版本中(最新版本 v3.0.1)进行了一个重大更新,包括了一些新的功能和改进。 + +在这篇文章里,我将会列出新版本中的重要改进,并且我将会提到在 Linux 上安装的步骤。 + +### LiVES 视频编辑器 3.0:新的改进 + +![Zorin OS 中正在加载的 LiVES 视频编辑器][2] + +总的来说,在这次重大更新中 LiVES 视频编辑器旨在提供更加平滑的回放、防止意外崩溃、优化视频录制,以及让在线视频下载器更加实用。 + +下面列出了变化: + +* 如果需要渲染的话,可以静默渲染直到到视频播放完毕。 +* 改进回放插件为 openGL,提供更加平滑的回放。 +* 重新启用了 openGL 回放插件的高级选项。 +* 在所有帧的 VJ/预解码中允许“Enough” +* 重构了在回放时的时基计算的代码(a/v 同步更好)。 +* 彻底修复了外部音频和音频,提高了准确性并减少了 CPU 占用。 +* 进入多音轨模式时自动切换至内部音频。 +* 重新显示效果映射器窗口时,将会正常展示效果状态(on/off)。 +* 解决了音频和视频线程之间的冲突。 +* 现在可以对在线视频下载器,可以对剪辑大小和格式进行修改并添加了更新选项。 +* 对实时效果实例实现了引用计数。 +* 大量重写了主界面,清理代码并改进许多视觉效果。 +* 优化了视频播放器运行时的录制功能。 +* 改进了 projectM 过滤器封装,包括对 SDL2 的支持。 +* 添加了一个选项来逆转多轨合成器中的 Z-order(后层现在可以覆盖上层了)。 +* 增加了对 musl libc 的支持 +* 更新了乌克兰语的翻译 + +如果你不是一位高级视频编辑师,也许会对上面列出的重要更新提不起太大的兴趣。但正是因为这些更新,才使得“LiVES 视频编辑器”成为了最好的开源视频编辑软件。 + +[][3] + +### 在 Linux 上安装 LiVES 视频编辑器 + +LiVES 几乎可以在所有主要的 Linux 发行版中使用。但是,你可能并不能在软件中心找到它的最新版本。所以,如果你想通过这种方式安装,那你就不得不耐心等待了。 + +如果你想要手动安装,可以从它的下载页面获取 Fedora/Open SUSE 的 RPM 安装包。它也适用于其他 Linux 发行版。 + +- [下载 LiVES 视频编辑器][4] + +如果你使用的是 Ubuntu(或其他基于 Ubuntu 的发行版),可以安装由 [Ubuntuhandbook][6] 维护的[非官方 PPA][5]。 + +下面由我来告诉你,你该做些什么: + +1、启动终端后输入以下命令: + +``` +sudo add-apt-repository ppa:ubuntuhandbook1/lives +``` + +系统将提示你输入密码用于确认添加 PPA。 + +2、完成后,你现在可以轻松地更新软件包列表并安装 LiVES 视频编辑器。以下是需要你输入的命令段: + +``` +sudo apt update +sudo apt install life-plugins +``` + +3、现在,它开始下载并安装这个视频编辑器,等待大约一分钟即可完成。 + +### 总结 + +Linux 上有许多[视频编辑器][7]。但它们通常被认为不能用于专业编辑。而我并不是一名专业人士,所以像 LiVES 这样免费的视频编辑器就足以进行简单的编辑了。 + +你认为怎么样呢?你在 Linux 上使用 LiVES 或其他视频编辑器的体验还好吗?在下面的评论中告诉我们你的感觉吧。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/lives-video-editor/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[Scvoet](https://github.com/scvoet) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/open-source-video-editors/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/lives-video-editor-loading.jpg?ssl=1 +[3]: https://itsfoss.com/vidcutter-video-editor-linux/ +[4]: http://lives-video.com/index.php?do=downloads#binaries +[5]: https://itsfoss.com/ppa-guide/ +[6]: http://ubuntuhandbook.org/index.php/2019/08/lives-video-editor-3-0-released-install-ubuntu/ +[7]: https://itsfoss.com/best-video-editing-software-linux/ diff --git a/published/201908/20190820 A guided tour of Linux file system types.md b/published/201908/20190820 A guided tour of Linux file system types.md new file mode 100644 index 0000000000..0914e3b7d1 --- /dev/null +++ b/published/201908/20190820 A guided tour of Linux file system types.md @@ -0,0 +1,86 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11274-1.html) +[#]: subject: (A guided tour of Linux file system types) +[#]: via: (https://www.networkworld.com/article/3432990/a-guided-tour-of-linux-file-system-types.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +Linux 文件系统类型导览 +====== + +> Linux 文件系统多年来在不断发展,让我们来看一下文件系统类型。 + +![](https://img.linux.net.cn/data/attachment/album/201908/27/175516vzrp4j4zevcqr66c.jpg) + +虽然对于普通用户来说可能并不明显,但在过去十年左右的时间里,Linux 文件系统已经发生了显著的变化,这使它们能够更好对抗损坏和性能问题。 + +如今大多数 Linux 系统使用名为 ext4 的文件系统。 “ext” 代表“扩展extended”,“4” 表示这是此文件系统的第 4 代。随着时间的推移添加的功能包括:能够提供越来越大的文件系统(目前大到 1,000,000 TiB)和更大的文件(高达 16 TiB),更抗系统崩溃,更少碎片(将单个文件分散为存在多个位置的块)以提高性能。 + +ext4 文件系统还带来了对性能、可伸缩性和容量的其他改进。实现了元数据和日志校验和以增强可靠性。时间戳现在可以跟踪纳秒级变化,以便更好地对文件打戳(例如,文件创建和最后更新时间)。并且,在时间戳字段中增加了两个位,2038 年的问题(存储日期/时间的字段将从最大值翻转到零)已被推迟到了 400 多年之后(到 2446)。 + +### 文件系统类型 + +要确定 Linux 系统上文件系统的类型,请使用 `df` 命令。下面显示的命令中的 `-T` 选项显示文件系统类型。 `-h` 显示“易读的”磁盘大小。换句话说,调整报告的单位(如 M 和 G),使人们更好地理解。 + +``` +$ df -hT | head -10 +Filesystem Type Size Used Avail Use% Mounted on +udev devtmpfs 2.9G 0 2.9G 0% /dev +tmpfs tmpfs 596M 1.5M 595M 1% /run +/dev/sda1 ext4 110G 50G 55G 48% / +/dev/sdb2 ext4 457G 642M 434G 1% /apps +tmpfs tmpfs 3.0G 0 3.0G 0% /dev/shm +tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock +tmpfs tmpfs 3.0G 0 3.0G 0% /sys/fs/cgroup +/dev/loop0 squashfs 89M 89M 0 100% /snap/core/7270 +/dev/loop2 squashfs 142M 142M 0 100% /snap/hexchat/42 +``` + +请注意,`/`(根)和 `/apps` 的文件系统都是 ext4,而 `/dev` 是 devtmpfs 文件系统(一个由内核填充的自动化设备节点)。其他的文件系统显示为 tmpfs(驻留在内存和/或交换分区中的临时文件系统)和 squashfs(只读压缩文件系统的文件系统,用于快照包)。 + +还有 proc 文件系统,用于存储正在运行的进程的信息。 + +``` +$ df -T /proc +Filesystem Type 1K-blocks Used Available Use% Mounted on +proc proc 0 0 0 - /proc +``` + +当你在整个文件系统中游览时,可能会遇到许多其他文件系统类型。例如,当你移动到目录中并想了解它的文件系统时,可以运行以下命令: + +``` +$ cd /dev/mqueue; df -T . +Filesystem Type 1K-blocks Used Available Use% Mounted on +mqueue mqueue 0 0 0 - /dev/mqueue +$ cd /sys; df -T . +Filesystem Type 1K-blocks Used Available Use% Mounted on +sysfs sysfs 0 0 0 - /sys +$ cd /sys/kernel/security; df -T . +Filesystem Type 1K-blocks Used Available Use% Mounted on +securityfs securityfs 0 0 0 - /sys/kernel/security +``` + +与其他 Linux 命令一样,这里的 `.` 代表整个文件系统的当前位置。 + +这些和其他独特的文件系统提供了一些特殊功能。例如,securityfs 提供支持安全模块的文件系统。 + +Linux 文件系统需要能够抵抗损坏,能够承受系统崩溃并提供快速、可靠的性能。由几代 ext 文件系统和新一代专用文件系统提供的改进使 Linux 系统更易于管理和更可靠。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3432990/a-guided-tour-of-linux-file-system-types.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/08/guided-tour-on-the-flaker_people-in-horse-drawn-carriage_germany-by-andreas-lehner-flickr-100808681-large.jpg +[2]: https://www.facebook.com/NetworkWorld/ +[3]: https://www.linkedin.com/company/network-world diff --git a/published/201908/20190823 How to Delete Lines from a File Using the sed Command.md b/published/201908/20190823 How to Delete Lines from a File Using the sed Command.md new file mode 100644 index 0000000000..e37d9dd215 --- /dev/null +++ b/published/201908/20190823 How to Delete Lines from a File Using the sed Command.md @@ -0,0 +1,404 @@ +[#]: collector: (lujun9972) +[#]: translator: (hello-wn) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11276-1.html) +[#]: subject: (How to Delete Lines from a File Using the sed Command) +[#]: via: (https://www.2daygeek.com/linux-remove-delete-lines-in-file-sed-command/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +如何使用 sed 命令删除文件中的行 +====== + +![](https://img.linux.net.cn/data/attachment/album/201908/28/100204ei6v98sa69hdf3zf.jpg) + +Sed 代表流编辑器Stream Editor,常用于 Linux 中基本的文本处理。`sed` 命令是 Linux 中的重要命令之一,在文件处理方面有着重要作用。可用于删除或移动与给定模式匹配的特定行。 + +它还可以删除文件中的特定行,它能够从文件中删除表达式,文件可以通过指定分隔符(例如逗号、制表符或空格)进行标识。 + +本文列出了 15 个使用范例,它们可以帮助你掌握 `sed` 命令。 + +如果你能理解并且记住这些命令,在你需要使用 `sed` 时,这些命令就能派上用场,帮你节约很多时间。 + +注意:为了方便演示,我在执行 `sed` 命令时,不使用 `-i` 选项(因为这个选项会直接修改文件内容),被移除了行的文件内容将打印到 Linux 终端。 + +但是,如果你想在实际环境中从源文件中删除行,请在 `sed` 命令中使用 `-i` 选项。 + +演示之前,我创建了 `sed-demo.txt` 文件,并添加了以下内容和相应行号以便更好地理解。 + +``` +# cat sed-demo.txt + +1 Linux Operating System +2 Unix Operating System +3 RHEL +4 Red Hat +5 Fedora +6 Arch Linux +7 CentOS +8 Debian +9 Ubuntu +10 openSUSE +``` + +### 1) 如何删除文件的第一行? + +使用以下语法删除文件首行。 + +`N` 表示文件中的第 N 行,`d` 选项在 `sed` 命令中用于删除一行。 + +语法: + +``` +sed 'Nd' file +``` + +使用以下 `sed` 命令删除 `sed-demo.txt` 中的第一行。 + +``` +# sed '1d' sed-demo.txt + +2 Unix Operating System +3 RHEL +4 Red Hat +5 Fedora +6 Arch Linux +7 CentOS +8 Debian +9 Ubuntu +10 openSUSE +``` + +### 2) 如何删除文件的最后一行? + +使用以下语法删除文件最后一行。 + +`$` 符号表示文件的最后一行。 + +使用以下 `sed` 命令删除 `sed-demo.txt` 中的最后一行。 + +``` +# sed '$d' sed-demo.txt + +1 Linux Operating System +2 Unix Operating System +3 RHEL +4 Red Hat +5 Fedora +6 Arch Linux +7 CentOS +8 Debian +9 Ubuntu +``` + +### 3) 如何删除指定行? + +使用以下 `sed` 命令删除 `sed-demo.txt` 中的第 3 行。 + +``` +# sed '3d' sed-demo.txt + +1 Linux Operating System +2 Unix Operating System +4 Red Hat +5 Fedora +6 Arch Linux +7 CentOS +8 Debian +9 Ubuntu +10 openSUSE +``` + +### 4) 如何删除指定范围内的行? + +使用以下 `sed` 命令删除 `sed-demo.txt` 中的第 5 到 7 行。 + +``` +# sed '5,7d' sed-demo.txt + +1 Linux Operating System +2 Unix Operating System +3 RHEL +4 Red Hat +8 Debian +9 Ubuntu +10 openSUSE +``` + +### 5) 如何删除多行内容? + +`sed` 命令能够删除给定行的集合。 + +本例中,下面的 `sed` 命令删除了第 1 行、第 5 行、第 9 行和最后一行。 + +``` +# sed '1d;5d;9d;$d' sed-demo.txt + +2 Unix Operating System +3 RHEL +4 Red Hat +6 Arch Linux +7 CentOS +8 Debian +``` + +### 5a) 如何删除指定范围以外的行? + +使用以下 `sed` 命令删除 `sed-demo.txt` 中第 3 到 6 行范围以外的所有行。 + +``` +# sed '3,6!d' sed-demo.txt + +3 RHEL +4 Red Hat +5 Fedora +6 Arch Linux +``` + +### 6) 如何删除空行? + +使用以下 `sed` 命令删除 `sed-demo.txt` 中的空行。 + +``` +# sed '/^$/d' sed-demo.txt + +1 Linux Operating System +2 Unix Operating System +3 RHEL +4 Red Hat +5 Fedora +6 Arch Linux +7 CentOS +8 Debian +9 Ubuntu +10 openSUSE +``` + +### 7) 如何删除包含某个模式的行? + +使用以下 `sed` 命令删除 `sed-demo.txt` 中匹配到 `System` 模式的行。 + +``` +# sed '/System/d' sed-demo.txt + +3 RHEL +4 Red Hat +5 Fedora +6 Arch Linux +7 CentOS +8 Debian +9 Ubuntu +10 openSUSE +``` + +### 8) 如何删除包含字符串集合中某个字符串的行? + +使用以下 `sed` 命令删除 `sed-demo.txt` 中匹配到 `System` 或 `Linux` 表达式的行。 + +``` +# sed '/System\|Linux/d' sed-demo.txt + +3 RHEL +4 Red Hat +5 Fedora +7 CentOS +8 Debian +9 Ubuntu +10 openSUSE +``` + +### 9) 如何删除以指定字符开头的行? + +为了测试,我创建了 `sed-demo-1.txt` 文件,并添加了以下内容。 + +``` +# cat sed-demo-1.txt + +Linux Operating System +Unix Operating System +RHEL +Red Hat +Fedora +debian +ubuntu +Arch Linux - 1 +2 - Manjaro +3 4 5 6 +``` + +使用以下 `sed` 命令删除以 `R` 字符开头的所有行。 + +``` +# sed '/^R/d' sed-demo-1.txt + +Linux Operating System +Unix Operating System +Fedora +debian +ubuntu +Arch Linux - 1 +2 - Manjaro +3 4 5 6 +``` + +使用以下 `sed` 命令删除 `R` 或者 `F` 字符开头的所有行。 + +``` +# sed '/^[RF]/d' sed-demo-1.txt + +Linux Operating System +Unix Operating System +debian +ubuntu +Arch Linux - 1 +2 - Manjaro +3 4 5 6 +``` + +### 10) 如何删除以指定字符结尾的行? + +使用以下 `sed` 命令删除 `m` 字符结尾的所有行。 + +``` +# sed '/m$/d' sed-demo.txt + +3 RHEL +4 Red Hat +5 Fedora +6 Arch Linux +7 CentOS +8 Debian +9 Ubuntu +10 openSUSE +``` + +使用以下 `sed` 命令删除 `x` 或者 `m` 字符结尾的所有行。 + +``` +# sed '/[xm]$/d' sed-demo.txt + +3 RHEL +4 Red Hat +5 Fedora +7 CentOS +8 Debian +9 Ubuntu +10 openSUSE +``` + +### 11) 如何删除所有大写字母开头的行? + +使用以下 `sed` 命令删除所有大写字母开头的行。 + +``` +# sed '/^[A-Z]/d' sed-demo-1.txt + +debian +ubuntu +2 - Manjaro +3 4 5 6 +``` + +### 12) 如何删除指定范围内匹配模式的行? + +使用以下 `sed` 命令删除第 1 到 6 行中包含 `Linux` 表达式的行。 + +``` +# sed '1,6{/Linux/d;}' sed-demo.txt + +2 Unix Operating System +3 RHEL +4 Red Hat +5 Fedora +7 CentOS +8 Debian +9 Ubuntu +10 openSUSE +``` + +### 13) 如何删除匹配模式的行及其下一行? + +使用以下 `sed` 命令删除包含 `System` 表达式的行以及它的下一行。 + +``` +# sed '/System/{N;d;}' sed-demo.txt + +3 RHEL +4 Red Hat +5 Fedora +6 Arch Linux +7 CentOS +8 Debian +9 Ubuntu +10 openSUSE +``` + +### 14) 如何删除包含数字的行? + +使用以下 `sed` 命令删除所有包含数字的行。 + +``` +# sed '/[0-9]/d' sed-demo-1.txt + +Linux Operating System +Unix Operating System +RHEL +Red Hat +Fedora +debian +ubuntu +``` + +使用以下 `sed` 命令删除所有以数字开头的行。 + +``` +# sed '/^[0-9]/d' sed-demo-1.txt + +Linux Operating System +Unix Operating System +RHEL +Red Hat +Fedora +debian +ubuntu +Arch Linux - 1 +``` + +使用以下 `sed` 命令删除所有以数字结尾的行。 + +``` +# sed '/[0-9]$/d' sed-demo-1.txt + +Linux Operating System +Unix Operating System +RHEL +Red Hat +Fedora +debian +ubuntu +2 - Manjaro +``` + +### 15) 如何删除包含字母的行? + +使用以下 `sed` 命令删除所有包含字母的行。 + +``` +# sed '/[A-Za-z]/d' sed-demo-1.txt + +3 4 5 6 +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-remove-delete-lines-in-file-sed-command/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[hello-wn](https://github.com/hello-wn) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 diff --git a/published/201908/20190823 Managing credentials with KeePassXC.md b/published/201908/20190823 Managing credentials with KeePassXC.md new file mode 100644 index 0000000000..93c6826b7e --- /dev/null +++ b/published/201908/20190823 Managing credentials with KeePassXC.md @@ -0,0 +1,116 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11278-1.html) +[#]: subject: (Managing credentials with KeePassXC) +[#]: via: (https://fedoramagazine.org/managing-credentials-with-keepassxc/) +[#]: author: (Marco Sarti https://fedoramagazine.org/author/msarti/) + +使用 KeePassXC 管理凭据 +====== + +![][1] + +[上一篇文章][2]我们讨论了使用服务器端技术的密码管理工具。这些工具非常有趣而且适合云安装。在本文中,我们将讨论 KeePassXC,这是一个简单的多平台开源软件,它使用本地文件作为数据库。 + +这种密码管理软件的主要优点是简单。无需服务器端技术专业知识,因此可供任何类型的用户使用。 + +### 介绍 KeePassXC + +KeePassXC 是一个开源的跨平台密码管理器:它是作为 KeePassX 的一个分支开始开发的,这是个不错的产品,但开发不是非常活跃。它使用 256 位密钥的 AES 算法将密钥保存在加密数据库中,这使得在云端设备(如 pCloud 或 Dropbox)中保存数据库相当安全。 + +除了密码,KeePassXC 还允许你在加密皮夹中保存各种信息和附件。它还有一个有效的密码生成器,可以帮助用户正确地管理他的凭据。 + +### 安装 + +这个程序在标准的 Fedora 仓库和 Flathub 仓库中都有。不幸的是,在沙箱中运行的程序无法使用浏览器集成,所以我建议通过 dnf 安装程序: + +``` +sudo dnf install keepassxc +``` + +### 创建你的皮夹 + +要创建新数据库,有两个重要步骤: + +* 选择加密设置:默认设置相当安全,增加转换轮次也会增加解密时间。 +* 选择主密钥和额外保护:主密钥必须易于记忆(如果丢失它,你的皮夹就会丢失!)而足够强大,一个至少有 4 个随机单词的密码可能是一个不错的选择。作为额外保护,你可以选择密钥文件(请记住:你必须始终都有它,否则无法打开皮夹)和/或 YubiKey 硬件密钥。 + +![][3] + +![][4] + +数据库文件将保存到文件系统。如果你想与其他计算机/设备共享,可以将它保存在 U 盘或 pCloud 或 Dropbox 等云存储中。当然,如果你选择云存储,建议使用特别强大的主密码,如果有额外保护则更好。 + +### 创建你的第一个条目 + +创建数据库后,你可以开始创建第一个条目。对于 Web 登录,请在“条目”选项卡中输入用户名、密码和 URL。你可以根据个人策略指定凭据的到期日期,也可以通过按右侧的按钮下载网站的 favicon 并将其关联为条目的图标,这是一个很好的功能。 + +![][5] + +![][6] + +KeePassXC 还提供了一个很好的密码/口令生成器,你可以选择长度和复杂度,并检查对暴力攻击的抵抗程度: + +![][7] + +### 浏览器集成 + +KeePassXC 有一个适用于所有主流浏览器的扩展。该扩展允许你填写所有已指定 URL 条目的登录信息。 + +必须在 KeePassXC(工具菜单 -> 设置)上启用浏览器集成,指定你要使用的浏览器: + +![][8] + +安装扩展后,必须与数据库建立连接。要执行此操作,请按扩展按钮,然后按“连接”按钮:如果数据库已打开并解锁,那么扩展程序将创建关联密钥并将其保存在数据库中,该密钥对于浏览器是唯一的,因此我建议对它适当命名: + +![][9] + +当你打开 URL 字段中的登录页并且数据库是解锁的,那么这个扩展程序将为你提供与该页面关联的所有凭据: + +![][10] + +通过这种方式,你可以通过 KeePassXC 获取互联网凭据,而无需将其保存在浏览器中。 + +### SSH 代理集成 + +KeePassXC 的另一个有趣功能是与 SSH 集成。如果你使用 ssh 代理,KeePassXC 能够与之交互并添加你上传的 ssh 密钥到条目中。 + +首先,在常规设置(工具菜单 -> 设置)中,你必须启用 ssh 代理并重启程序: + +![][11] + +此时,你需要以附件方式上传你的 ssh 密钥对到条目中。然后在 “SSH 代理” 选项卡中选择附件下拉列表中的私钥,此时会自动填充公钥。不要忘记选择上面的两个复选框,以便在数据库打开/解锁时将密钥添加到代理,并在数据库关闭/锁定时删除: + +![][12] + +现在打开和解锁数据库,你可以使用皮夹中保存的密钥登录 ssh。 + +唯一的限制是可以添加到代理的最大密钥数:ssh 服务器默认不接受超过 5 次登录尝试,出于安全原因,建议不要增加此值。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/managing-credentials-with-keepassxc/ + +作者:[Marco Sarti][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/msarti/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/08/keepassxc-816x345.png +[2]: https://linux.cn/article-11181-1.html +[3]: https://fedoramagazine.org/wp-content/uploads/2019/08/Screenshot-from-2019-08-17-07-33-27.png +[4]: https://fedoramagazine.org/wp-content/uploads/2019/08/Screenshot-from-2019-08-17-07-48-21.png +[5]: https://fedoramagazine.org/wp-content/uploads/2019/08/Screenshot-from-2019-08-17-08-30-07.png +[6]: https://fedoramagazine.org/wp-content/uploads/2019/08/Screenshot-from-2019-08-17-08-43-11.png +[7]: https://fedoramagazine.org/wp-content/uploads/2019/08/Screenshot-from-2019-08-17-08-49-22.png +[8]: https://fedoramagazine.org/wp-content/uploads/2019/08/Screenshot-from-2019-08-17-09-48-09.png +[9]: https://fedoramagazine.org/wp-content/uploads/2019/08/Screenshot-from-2019-08-17-09-05-57.png +[10]: https://fedoramagazine.org/wp-content/uploads/2019/08/Screenshot-from-2019-08-17-09-13-29.png +[11]: https://fedoramagazine.org/wp-content/uploads/2019/08/Screenshot-from-2019-08-17-09-47-21.png +[12]: https://fedoramagazine.org/wp-content/uploads/2019/08/Screenshot-from-2019-08-17-09-46-35.png diff --git a/published/201908/20190825 Happy birthday to the Linux kernel- What-s your favorite release.md b/published/201908/20190825 Happy birthday to the Linux kernel- What-s your favorite release.md new file mode 100644 index 0000000000..b8ce475557 --- /dev/null +++ b/published/201908/20190825 Happy birthday to the Linux kernel- What-s your favorite release.md @@ -0,0 +1,54 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11271-1.html) +[#]: subject: (Happy birthday to the Linux kernel: What's your favorite release?) +[#]: via: (https://opensource.com/article/19/8/linux-kernel-favorite-release) +[#]: author: (Lauren Pritchett https://opensource.com/users/lauren-pritchett) + +Linux 内核生日快乐 —— 那么你喜欢哪个版本? +====== + +> 自从第一个 Linux 内核发布已经过去 28 年了。自 1991 年以来发布了几十个 Linux 内核版本,你喜欢的是哪个?投个票吧! + +![][1] + +让我们回到 1991 年 8 月,那个创造历史的时间。科技界经历过许多关键时刻,这些时刻仍在影响着我们。在那个 8 月,Tim Berners-Lee 宣布了一个名为万维网World Wide Web的有趣项目,并推出了第一个网站;超级任天堂在美国发布,为所有年龄段的孩子们开启了新的游戏篇章;在赫尔辛基大学,一位名叫 Linus Torvalds 的学生向同好们询问(1991 年 8 月 25 日)了他作为[业余爱好][3]开发的新免费操作系统的反馈。那时 Linux 内核诞生了。 + +如今,我们可以浏览超过 15 亿个网站,在我们的电视机上玩另外五种任天堂游戏机,并维护着六个长期 Linux 内核。以下是我们的一些作者对他们最喜欢的 Linux 内核版本所说的话。 + +“引入模块的那个版本(1.2 吧?)。这是 Linux 迈向成功的未来的重要一步。” - Milan Zamazal + +“2.6.9,因为它是我 2006 年加入 Red Hat 时的版本(在 RHEL4 中)。但我也更钟爱 2.6.18(RHEL5)一点,因为它在大规模部署的、我们最大客户(Telco, FSI)的关键任务工作负载中使用。它还带来了我们最大的技术变革之一:虚拟化(Xen 然后是 KVM)。” - Herve Lemaitre + +“4.10。(虽然我不知道如何衡量这一点)。” - Ivan Bazulic + +“Fedora 30 附带的新内核修复了我的 Thinkpad Yoga 笔记本电脑的挂起问题;挂起功能现在可以完美运行。我是一个笨人,只是忍受这个问题而从未试着提交错误报告,所以我特别感谢这项工作,我知道一定会解决这个问题。” - MáirínDuffy + +“2.6.16 版本将永远在我的心中占有特殊的位置。这是我负责将其转换为在 hertz neverlost gps 系统上运行的第一个内核。我负责这项为那个设备构建内核和根文件系统的工作,对我来说这真的是一个奇迹时刻。我们在初次发布后多次更新了内核,但我想我必须还是推选那个最初版本,不过,我对于它的热爱没有任何技术原因,这纯属感性选择 =)” - Michael McCune + +“我最喜欢的 Linux 内核版本是 2.4.0 系列,它集成了对 USB、LVM 和 ext3 的支持。ext3 是第一个具有日志支持的主流 Linux 文件系统,其从 2.4.15 内核可用。我使用的第一个内核版本是 2.2.13。” - Sean Nelson + +“也许是 2.2.14,因为它是在我安装的第一个 Linux 上运行的版本(Mandrake Linux 7.0,在 2000 IIRC)。它也是我第一个需要重新编译以让我的视频卡或我的调制解调器(记不清了)工作的版本。” - GermánPulido + +“我认为最新的一个!但我有段时间使用实时内核扩展来进行音频制作。” - Mario Torre + +*在 Linux 内核超过 [52 个的版本][2]当中,你最喜欢哪一个?参加我们的调查并在评论中告诉我们原因。* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/linux-kernel-favorite-release + +作者:[Lauren Pritchett][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lauren-pritchetthttps://opensource.com/users/sethhttps://opensource.com/users/luis-ibanezhttps://opensource.com/users/mhayden +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_anniversary_celebreate_tux.jpg?itok=JOE-yXus +[2]: http://phb-crystal-ball.org/ +[3]: http://lkml.iu.edu/hypermail/linux/kernel/1908.3/00457.html diff --git a/published/201908/20190825 How to Install Ansible (Automation Tool) on Debian 10 (Buster).md b/published/201908/20190825 How to Install Ansible (Automation Tool) on Debian 10 (Buster).md new file mode 100644 index 0000000000..be4bbb0a36 --- /dev/null +++ b/published/201908/20190825 How to Install Ansible (Automation Tool) on Debian 10 (Buster).md @@ -0,0 +1,194 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11286-1.html) +[#]: subject: (How to Install Ansible (Automation Tool) on Debian 10 (Buster)) +[#]: via: (https://www.linuxtechi.com/install-ansible-automation-tool-debian10/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +如何在 Debian 10 上安装 Ansible +====== + +在如今的 IT 领域,自动化一个是热门话题,每个组织都开始采用自动化工具,像 Puppet、Ansible、Chef、CFEngine、Foreman 和 Katello。在这些工具中,Ansible 是几乎所有 IT 组织中管理 UNIX 和 Linux 系统的首选。在本文中,我们将演示如何在 Debian 10 Sever 上安装和使用 Ansible。 + +![Ansible-Install-Debian10][2] + +我的实验室环境: + +* Debian 10 – Ansible 服务器/ 控制节点 – 192.168.1.14 +* CentOS 7 – Ansible 主机 (Web 服务器)– 192.168.1.15 +* CentOS 7 – Ansible 主机(DB 服务器)– 192.169.1.17 + +我们还将演示如何使用 Ansible 服务器管理 Linux 服务器 + +### 在 Debian 10 Server 上安装 Ansible + +我假设你的 Debian 10 中有一个拥有 root 或 sudo 权限的用户。在我这里,我有一个名为 `pkumar` 的本地用户,它拥有 sudo 权限。 + +Ansible 2.7 包存在于 Debian 10 的默认仓库中,在命令行中运行以下命令安装 Ansible, + +``` +root@linuxtechi:~$ sudo apt update +root@linuxtechi:~$ sudo apt install ansible -y +``` + +运行以下命令验证 Ansible 版本, + +``` +root@linuxtechi:~$ sudo ansible --version +``` + +![ansible-version](https://www.linuxtechi.com/wp-content/uploads/2019/08/ansible-version.jpg) + +要安装最新版本的 Ansible 2.8,首先我们必须设置 Ansible 仓库。 + +一个接一个地执行以下命令, + +``` +root@linuxtechi:~$ echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu bionic main" | sudo tee -a /etc/apt/sources.list +root@linuxtechi:~$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 +root@linuxtechi:~$ sudo apt update +root@linuxtechi:~$ sudo apt install ansible -y +root@linuxtechi:~$ sudo ansible --version +``` + +![latest-ansible-version](https://www.linuxtechi.com/wp-content/uploads/2019/08/latest-ansible-version.jpg) + +### 使用 Ansible 管理 Linux 服务器 + +请参考以下步骤,使用 Ansible 控制器节点管理 Linux 类的服务器, + +#### 步骤 1:在 Ansible 服务器及其主机之间交换 SSH 密钥 + +在 Ansible 服务器生成 ssh 密钥并在 Ansible 主机之间共享密钥。 + +``` +root@linuxtechi:~$ sudo -i +root@linuxtechi:~# ssh-keygen +root@linuxtechi:~# ssh-copy-id root@linuxtechi +root@linuxtechi:~# ssh-copy-id root@linuxtechi +``` + +#### 步骤 2:创建 Ansible 主机清单 + +安装 Ansible 后会自动创建 `/etc/ansible/hosts`,在此文件中我们可以编辑 Ansible 主机或其客户端。我们还可以在家目录中创建自己的 Ansible 主机清单, + +运行以下命令在我们的家目录中创建 Ansible 主机清单。 + +``` +root@linuxtechi:~$ vi $HOME/hosts +[Web] +192.168.1.15 + +[DB] +192.168.1.17 +``` + +保存并退出文件。 + +注意:在上面的主机文件中,我们也可以使用主机名或 FQDN,但为此我们必须确保 Ansible 主机可以通过主机名或者 FQDN 访问。 + +#### 步骤 3:测试和使用默认的 Ansible 模块 + +Ansible 附带了许多可在 `ansible` 命令中使用的默认模块,示例如下所示。 + +语法: + +``` +# ansible -i -m +``` + +这里: + + * `-i ~/hosts`:包含 Ansible 主机列表 + * `-m`:在之后指定 Ansible 模块,如 ping 和 shell + * ``:我们要运行 Ansible 模块的 Ansible 主机 + +使用 Ansible ping 模块验证 ping 连接, + +``` +root@linuxtechi:~$ sudo ansible -i ~/hosts -m ping all +root@linuxtechi:~$ sudo ansible -i ~/hosts -m ping Web +root@linuxtechi:~$ sudo ansible -i ~/hosts -m ping DB +``` + +命令输出如下所示: + +![Ansible-ping-module-examples](https://www.linuxtechi.com/wp-content/uploads/2019/08/Ansible-ping-module-examples.jpg) + +使用 shell 模块在 Ansible 主机上运行 shell 命令 + +语法: + +``` +ansible -i -m shell -a +``` + +例子: + +``` +root@linuxtechi:~$ sudo ansible -i ~/hosts -m shell -a "uptime" all +192.168.1.17 | CHANGED | rc=0 >> + 01:48:34 up 1:07, 3 users, load average: 0.00, 0.01, 0.05 + +192.168.1.15 | CHANGED | rc=0 >> + 01:48:39 up 1:07, 3 users, load average: 0.00, 0.01, 0.04 + +root@linuxtechi:~$ +root@linuxtechi:~$ sudo ansible -i ~/hosts -m shell -a "uptime ; df -Th / ; uname -r" Web +192.168.1.15 | CHANGED | rc=0 >> + 01:52:03 up 1:11, 3 users, load average: 0.12, 0.07, 0.06 +Filesystem Type Size Used Avail Use% Mounted on +/dev/mapper/centos-root xfs 13G 1017M 12G 8% / +3.10.0-327.el7.x86_64 + +root@linuxtechi:~$ +``` + +上面的命令输出表明我们已成功设置 Ansible 控制器节点。 + +让我们创建一个安装 nginx 的示例剧本,下面的剧本将在所有服务器上安装 nginx,这些服务器是 Web 主机组的一部分,但在这里,我的主机组下只有一台 centos 7 机器。 + +``` +root@linuxtechi:~$ vi nginx.yaml +--- +- hosts: Web + tasks: + - name: Install latest version of nginx on CentOS 7 Server + yum: name=nginx state=latest + - name: start nginx + service: + name: nginx + state: started +``` + +现在使用以下命令执行剧本。 + +``` +root@linuxtechi:~$ sudo ansible-playbook -i ~/hosts nginx.yaml +``` + +上面命令的输出类似下面这样, + +![nginx-installation-playbook-debian10](https://www.linuxtechi.com/wp-content/uploads/2019/08/nginx-installation-playbook-debian10.jpg) + +这表明 Ansible 剧本成功执行了。 + +本文就是这些了,请分享你的反馈和评论。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/install-ansible-automation-tool-debian10/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/08/Ansible-Install-Debian10.jpg diff --git a/published/201908/20190827 A dozen ways to learn Python.md b/published/201908/20190827 A dozen ways to learn Python.md new file mode 100644 index 0000000000..b2fbfb4f5c --- /dev/null +++ b/published/201908/20190827 A dozen ways to learn Python.md @@ -0,0 +1,102 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11280-1.html) +[#]: subject: (A dozen ways to learn Python) +[#]: via: (https://opensource.com/article/19/8/dozen-ways-learn-python) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +学习 Python 的 12 个方式 +====== + +> 这些资源将帮助你入门并熟练掌握 Python。 + +![](https://img.linux.net.cn/data/attachment/album/201908/29/083446r00gdsohb7lwxdxy.jpg) + +Python 是世界上[最受欢迎的][2]编程语言之一,它受到了全世界各地的开发者和创客的欢迎。大多数 Linux 和 MacOS 计算机都预装了某个版本的 Python,现在甚至一些 Windows 计算机供应商也开始安装 Python 了。 + +也许你尚未学会它,想学习但又不知道在哪里入门。这里的 12 个资源将帮助你入门并熟练掌握 Python。 + +### 课程、书籍、文章和文档 + +1、[Python 软件基金会][3]提供了出色的信息和文档,可帮助你迈上编码之旅。请务必查看 [Python 入门指南][4]。它将帮助你得到最新版本的 Python,并提供有关编辑器和开发环境的有用提示。该组织还有可以来进一步指导你的[优秀文档][5]。 + +2、我的 Python 旅程始于[海龟模块][6]。我首先在 Bryson Payne 的《[教你的孩子编码][7]》中找到了关于 Python 和海龟的内容。这本书是一个很好的资源,购买这本书可以让你看到几十个示例程序,这将激发你的编程好奇心。Payne 博士还在 [Udemy][8] 上以相同的名称开设了一门便宜的课程。 + +3、Payne 博士的书激起了我的好奇心,我渴望了解更多。这时我发现了 Al Sweigart 的《[用 Python 自动化无聊的东西][9]》。你可以购买这本书,也可以使用它的在线版本,它与印刷版完全相同且可根据知识共享许可免费获得和分享。Al 的这本书让我学习到了 Python 的基础知识、函数、列表、字典和如何操作字符串等等。这是一本很棒的书,我已经购买了许多本捐赠给了当地图书馆。Al 还提供 [Udemy][10] 课程;使用他的网站上的优惠券代码,只需 10 美元即可参加。 + +4、Eric Matthes 撰写了《[Python 速成][11]》,这是由 No Starch Press 出版的 Python 的逐步介绍(如同上面的两本书)。Matthes 还有一个很棒的[伴侣网站][12],其中包括了如何在你的计算机上设置 Python 以及一个用以简化学习曲线的[速查表][13]。 + +5、[Python for Everybody][14] 是另一个很棒的 Python 学习资源。该网站可以免费访问 [Charles Severance][15] 的 Coursera 和 edX 认证课程的资料。该网站分为入门、课程和素材等部分,其中 17 个课程按从安装到数据可视化的主题进行分类组织。Severance([@drchuck on Twitter][16]),是密歇根大学信息学院的临床教授。 + +6、[Seth Kenlon][17],我们 Opensource.com 的 Python 大师,撰写了大量关于 Python 的文章。Seth 有很多很棒的文章,包括“[用 JSON 保存和加载 Python 数据][18]”,“[用 Python 学习面向对象编程][19]”,“[在 Python 游戏中用 Pygame 放置平台][20]”,等等。 + +### 在设备上使用 Python + +7、最近我对 [Circuit Playground Express][21] 非常感兴趣,这是一个运行 [CircuitPython][22] 的设备,CircuitPython 是为微控制器设计的 Python 编程语言的子集。我发现 Circuit Playground Express 和 CircuitPython 是向学生介绍 Python(以及一般编程)的好方法。它的制造商 Adafruit 有一个很好的[系列教程][23],可以让你快速掌握 CircuitPython。 + +8、[BBC:Microbit][24] 是另一种入门 Python 的好方法。你可以学习如何使用 [MicroPython][25] 对其进行编程,这是另一种用于编程微控制器的 Python 实现。 + +9、学习 Python 的文章如果没有提到[树莓派][26]单板计算机那是不完整的。一旦你有了[舒适][27]而强大的树莓派,你就可以在 Opensource.com 上找到[成吨的][28]使用它的灵感,包括“[7 个值得探索的树莓派项目][29]”,“[在树莓派上复活 Amiga][30]”,和“[如何使用树莓派作为 VPN 服务器][31]”。 + +10、许多学校为学生提供了 iOS 设备以支持他们的教育。在尝试帮助这些学校的老师和学生学习用 Python 编写代码时,我发现了 [Trinket.io][32]。Trinket 允许你在浏览器中编写和执行 Python 3 代码。 Trinket 的 [Python 入门][33]教程将向你展示如何在 iOS 设备上使用 Python。 +   +### 播客 + +11、我喜欢在开车的时候听播客,我在 Kelly Paredes 和 Sean Tibor 的 [Teaching Python][34] 播客上找到了大量的信息。他们的内容很适合教育领域。 + +12、如果你正在寻找一些更通用的东西,我推荐 Michael Kennedy 的 [Talk Python to Me][35] 播客。它提供了有关 Python 及相关技术的最佳信息。 + +你学习 Python 最喜欢的资源是什么?请在评论中分享。 + +计算机编程可能是一个有趣的爱好,正如我以前在 Apple II 计算机上编程时所学到的…… + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/dozen-ways-learn-python + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_code_screen_display.jpg?itok=2HMTzqz0 (Code on a screen) +[2]: https://insights.stackoverflow.com/survey/2019#most-popular-technologies +[3]: https://www.python.org/ +[4]: https://www.python.org/about/gettingstarted/ +[5]: https://docs.python.org/3/ +[6]: https://opensource.com/life/15/8/python-turtle-graphics +[7]: https://opensource.com/education/15/9/review-bryson-payne-teach-your-kids-code +[8]: https://www.udemy.com/teach-your-kids-to-code/ +[9]: https://automatetheboringstuff.com/ +[10]: https://www.udemy.com/automate/?couponCode=PAY_10_DOLLARS +[11]: https://nostarch.com/pythoncrashcourse2e +[12]: https://ehmatthes.github.io/pcc/ +[13]: https://ehmatthes.github.io/pcc/cheatsheets/README.html +[14]: https://www.py4e.com/ +[15]: http://www.dr-chuck.com/dr-chuck/resume/bio.htm +[16]: https://twitter.com/drchuck/ +[17]: https://opensource.com/users/seth +[18]: https://linux.cn/article-11133-1.html +[19]: https://opensource.com/article/19/7/get-modular-python-classes +[20]: https://linux.cn/article-10902-1.html +[21]: https://opensource.com/article/19/7/circuit-playground-express +[22]: https://circuitpython.org/ +[23]: https://learn.adafruit.com/welcome-to-circuitpython +[24]: https://opensource.com/article/19/8/getting-started-bbc-microbit +[25]: https://micropython.org/ +[26]: https://www.raspberrypi.org/ +[27]: https://projects.raspberrypi.org/en/pathways/getting-started-with-raspberry-pi +[28]: https://opensource.com/sitewide-search?search_api_views_fulltext=Raspberry%20Pi +[29]: https://opensource.com/article/19/3/raspberry-pi-projects +[30]: https://opensource.com/article/19/3/amiga-raspberry-pi +[31]: https://opensource.com/article/19/6/raspberry-pi-vpn-server +[32]: https://trinket.io/ +[33]: https://docs.trinket.io/getting-started-with-python#/welcome/where-we-ll-go +[34]: https://www.teachingpython.fm/ +[35]: https://talkpython.fm/ diff --git a/published/201908/20190830 11 surprising ways you use Linux every day.md b/published/201908/20190830 11 surprising ways you use Linux every day.md new file mode 100644 index 0000000000..df3bfb043b --- /dev/null +++ b/published/201908/20190830 11 surprising ways you use Linux every day.md @@ -0,0 +1,108 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11289-1.html) +[#]: subject: (11 surprising ways you use Linux every day) +[#]: via: (https://opensource.com/article/19/8/everyday-tech-runs-linux) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +你可能意识不到的使用 Linux 的 11 种方式 +====== + +> 什么技术运行在 Linux 上?你可能会惊讶于日常生活中使用 Linux 的频率。 + +![](https://img.linux.net.cn/data/attachment/album/201909/01/000003dsqf45rbavr5vzja.jpg) + +现在 Linux 几乎可以运行每样东西,但很多人都没有意识到这一点。有些人可能知道 Linux,可能听说过超级计算机运行着这个操作系统。根据 [Top500][2],Linux 现在驱动着世界上最快的 500 台计算机。你可以转到他们的网站并[搜索“Linux”][3]自己查看一下结果。 + +### NASA 运行在 Linux 之上 + +你可能不知道 Linux 为 NASA(美国国家航空航天局)提供支持。NASA 的 [Pleiades][4] 超级计算机运行着 Linux。由于操作系统的可靠性,国际空间站六年前[从 Windows 切换到了 Linux][5]。NASA 甚至最近给国际空间站部署了三台[运行着 Linux][6] 的“Astrobee”机器人。 + +### 电子书运行在 Linux 之上 + +我读了很多书,我的首选设备是亚马逊 Kindle Paperwhite,它运行 Linux(虽然大多数人完全没有意识到这一点)。如果你使用亚马逊的任何服务,从[亚马逊弹性计算云(Amazon EC2)][7] 到 Fire TV,你就是在 Linux 上运行。当你问 Alexa 现在是什么时候,或者你最喜欢的运动队得分时,你也在使用 Linux,因为 Alexa 由 [Fire OS][8](基于 Android 的操作系统)提供支持。实际上,[Android][9] 是由谷歌开发的用于移动手持设备的 Linux,而且占据了当今移动电话的[76% 的市场][10]。 + +### 电视运行在 Linux 之上 + +如果你有一台 [TiVo][11],那么你也在运行 Linux。如果你是 Roku 用户,那么你也在使用 Linux。[Roku OS][12] 是专为 Roku 设备定制的 Linux 版本。你可以选择使用在 Linux 上运行的 Chromecast 看流媒体。不过,Linux 不只是为机顶盒和流媒体设备提供支持。它也可能运行着你的智能电视。LG 使用 webOS,它是基于 Linux 内核的。Panasonic 使用 Firefox OS,它也是基于 Linux 内核的。三星、菲利普斯以及更多厂商都使用基于 Linux 的操作系统支持其设备。 + +### 智能手表和平板电脑运行在 Linux 之上 + +如果你拥有智能手表,它可能正在运行 Linux。世界各地的学校系统一直在实施[一对一系统][13],让每个孩子都有自己的笔记本电脑。越来越多的机构为学生配备了 Chromebook。这些轻巧的笔记本电脑使用 [Chrome OS][14],它基于 Linux。 + +### 汽车运行在 Linux 之上 + +你驾驶的汽车可能正在运行 Linux。 [汽车级 Linux(AGL)][15] 是一个将 Linux 视为汽车标准代码库的项目,它列入了丰田、马自达、梅赛德斯-奔驰和大众等汽车制造商。你的[车载信息娱乐(IVI)][16]系统也可能运行 Linux。[GENIVI 联盟][17]在其网站称,它开发了“用于集成在集中连接的车辆驾驶舱中的操作系统和中间件的标准方法”。 + +### 游戏运行在 Linux 之上 + +如果你是游戏玩家,那么你可能正在使用 [SteamOS][18],这是一个基于 Linux 的操作系统。此外,如果你使用 Google 的众多服务,那么你也运行在 Linux上。 + +### 社交媒体运行在 Linux 之上 + +当你刷屏和评论时,你可能会意识到这些平台正在做的很多工作。也许 Instagram、Facebook、YouTube 和 Twitter 都在 Linux 上运行并不令人惊讶。 + +此外,社交媒体的新浪潮,去中心化的联合社区的联盟节点,如 [Mastodon][19]、[GNU Social][20]、[Nextcloud][21](类似 Twitter 的微博平台)、[Pixelfed][22](分布式照片共享)和[Peertube][23](分布式视频共享)至少默认情况下在 Linux 上运行。由于开源,它们可以在任何平台上运行,这本身就是一个强大的优先级。 + +### 商业和政务运行在 Linux 之上 + +与五角大楼一样,纽约证券交易所也在 Linux 上运行。美国联邦航空管理局每年处理超过 1600 万次航班,他们在 Linux 上运营。美国国会图书馆、众议院、参议院和白宫都使用 Linux。 + +### 零售运行在 Linux 之上 + +最新航班座位上的娱乐系统很可能在 Linux 上运行。你最喜欢的商店的 POS 机可能正运行在 Linux 上。基于 Linux 的 [Tizen OS][24] 为智能家居和其他智能设备提供支持。许多公共图书馆现在在 [Evergreen][25] 和 [Koha][26] 上托管他们的综合图书馆系统。这两个系统都在 Linux 上运行。 + +### Apple 运行在 Linux 之上 + +如果你是使用 [iCloud][27] 的 iOS 用户,那么你也在使用运行在 Linux 上的系统。Apple 公司的网站在 Linux 上运行。如果你想知道在 Linux 上运行的其他网站,请务必使用 [Netcraft][28] 并检查“该网站运行在什么之上?”的结果。 + +### 路由器运行在 Linux 之上 + +在你家里将你连接到互联网的路由器可能正运行在 Linux 上。如果你当前的路由器没有运行 Linux 而你想改变它,那么这里有一个[优秀的方法][29]。 + +如你所见,Linux 从许多方面为今天的世界提供动力。还有什么运行在 Linux 之上的东西是人们还没有意识到的?请让我们在评论中知道。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/everyday-tech-runs-linux + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/truck_steering_wheel_drive_car_kubernetes.jpg?itok=0TOzve80 (Truck steering wheel and dash) +[2]: https://www.top500.org/ +[3]: https://www.top500.org/statistics/sublist/ +[4]: https://www.nas.nasa.gov/hecc/resources/pleiades.html +[5]: https://www.extremetech.com/extreme/155392-international-space-station-switches-from-windows-to-linux-for-improved-reliability +[6]: https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20180003515.pdf +[7]: https://aws.amazon.com/amazon-linux-ami/ +[8]: https://en.wikipedia.org/wiki/Fire_OS +[9]: https://en.wikipedia.org/wiki/Android_(operating_system) +[10]: https://gs.statcounter.com/os-market-share/mobile/worldwide/ +[11]: https://tivo.pactsafe.io/legal.html#open-source-software +[12]: https://en.wikipedia.org/wiki/Roku +[13]: https://en.wikipedia.org/wiki/One-to-one_computing +[14]: https://en.wikipedia.org/wiki/Chrome_OS +[15]: https://opensource.com/life/16/8/agl-provides-common-open-code-base +[16]: https://opensource.com/business/16/5/interview-alison-chaiken-steven-crumb +[17]: https://www.genivi.org/faq +[18]: https://store.steampowered.com/steamos/ +[19]: https://opensource.com/article/17/4/guide-to-mastodon +[20]: https://www.gnu.org/software/social/ +[21]: https://apps.nextcloud.com/apps/social +[22]: https://pixelfed.org/ +[23]: https://joinpeertube.org/en/ +[24]: https://wiki.tizen.org/Devices +[25]: https://evergreen-ils.org/ +[26]: https://koha-community.org/ +[27]: https://toolbar.netcraft.com/site_report?url=https://www.icloud.com/ +[28]: https://www.netcraft.com/ +[29]: https://opensource.com/life/16/6/why-i-built-my-own-linux-router diff --git a/published/20190805 Is your enterprise software committing security malpractice.md b/published/20190805 Is your enterprise software committing security malpractice.md new file mode 100644 index 0000000000..8418098906 --- /dev/null +++ b/published/20190805 Is your enterprise software committing security malpractice.md @@ -0,0 +1,72 @@ +[#]: collector: (lujun9972) +[#]: translator: (hopefully2333) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11305-1.html) +[#]: subject: (Is your enterprise software committing security malpractice?) +[#]: via: (https://www.networkworld.com/article/3429559/is-your-enterprise-software-committing-security-malpractice.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +你的企业安全软件是否在背后偷传数据? +====== + +> ExtraHop 发现一些企业安全和分析软件正在“私下回拨”,悄悄地将信息上传到客户网络外的服务器上。 + +![Getty Images][1] + +当这个博客专注于微软的一切事情时,我常常抱怨、反对 Windows 10 的间谍活动方面。嗯,显然,这些跟企业安全、分析和硬件管理工具所做的相比,都不算什么。 + +一家叫做 ExtraHop 的分析公司检查了其客户的网络,并发现客户的安全和分析软件悄悄地将信息上传到客户网络外的服务器上。这家公司上周发布了一份[报告来进行警示][2]。 + +ExtraHop 特意选择不对这四个例子中的企业安全工具进行点名,这些工具在没有警告用户或使用者的情况发送了数据。这家公司的一位发言人通过电子邮件告诉我,“ExtraHop 希望关注报告的这个趋势,我们已经多次观察到了这种令人担心的情况。这个严重的问题需要企业的更多关注,而只是关注几个特定的软件会削弱这个严重的问题需要得到更多关注的观点。” + +### 产品在安全提交传输方面玩忽职守,并且偷偷地传输数据到异地 + +[ExtraHop 的报告][6]中称发现了一系列的产品在偷偷地传输数据回自己的服务器上,包括终端安全软件、医院设备管理软件、监控摄像头、金融机构使用的安全分析软件等。报告中同样指出,这些应用涉嫌违反了欧洲的[通用数据隐私法规(GDPR)][7]。 + +在每个案例里,ExtraHop 都提供了这些软件传输数据到异地的证据,在其中一个案例中,一家公司注意到,大约每隔 30 分钟,一台连接了网络的设备就会发送 UDP 数据包给一个已知的恶意 IP 地址。有问题的是一台某国制造的安全摄像头,这个摄像头正在偷偷联系一个和某国有联系的已知的恶意 IP 地址。 + +该摄像头很可能由其办公室的一名员工出于其个人安全的用途独自设置的,这显示出影子 IT 的缺陷。 + +而对于医院设备的管理工具和金融公司的分析工具,这些工具违反了数据安全法,公司面临着法律风险——即使公司不知道这个事。 + +该医院的医疗设备管理产品应该只使用医院的 WiFi 网络,以此来确保患者的数据隐私和 HIPAA 合规。ExtraHop 注意到管理初始设备部署的工作站正在打开加密的 ssl:443 来连接到供应商自己的云存储服务器,这是一个重要的 HIPAA 违规。 + +ExtraHop 指出,尽管这些例子中可能没有任何恶意活动。但它仍然违反了法律规定,管理员需要密切关注他们的网络,以此来监视异常活动的流量。 + +“要明确的是,我们不知道供应商为什么要把数据偷偷传回自己的服务器。这些公司都是受人尊敬的安全和 IT 供应商,并且很有可能,这些数据是由他们的程序框架设计用于合法目的的,或者是错误配置的结果”,报告中说。 + +### 如何减轻数据外传的安全风险 + +为了解决这种安全方面玩忽职守的问题,ExtraHop 建议公司做下面这五件事: + +* 监视供应商的活动:在你的网络上密切注意供应商的非正常活动,无论他们是活跃供应商、以前的供应商,还是评估后的供应商。 +* 监控出口流量:了解出口流量,尤其是来自域控制器等敏感资产的出口流量。当检测到出口流量时,始终将其与核准的应用程序和服务进行匹配。 +* 跟踪部署:在评估过程中,跟踪软件代理的部署。 +* 理解监管方面的考量因素:了解数据跨越政治、地理边界的监管和合规考量因素。 +* 理解合同协议:跟踪数据的使用是否符合供应商合同上的协议。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3429559/is-your-enterprise-software-committing-security-malpractice.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[hopefully2333](https://github.com/hopefully2333) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/03/cybersecurity_eye-with-binary_face-recognition_abstract-eye-100751589-large.jpg +[2]: https://www.extrahop.com/company/press-releases/2019/extrahop-issues-warning-about-phoning-home/ +[3]: https://www.networkworld.com/article/3254185/internet-of-things/tips-for-securing-iot-on-your-network.html#nww-fsb +[4]: https://www.networkworld.com/article/3269184/10-best-practices-to-minimize-iot-security-vulnerabilities#nww-fsb +[5]: https://www.networkworld.com/newsletters/signup.html#nww-fsb +[6]: https://www.extrahop.com/resources/whitepapers/eh-security-advisory-calling-home-success/ +[7]: https://www.csoonline.com/article/3202771/general-data-protection-regulation-gdpr-requirements-deadlines-and-facts.html +[8]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr +[9]: https://www.networkworld.com/article/3269165/internet-of-things/a-corporate-guide-to-addressing-iot-security-concerns.html +[10]: https://www.facebook.com/NetworkWorld/ +[11]: https://www.linkedin.com/company/network-world diff --git a/published/20190810 How to Upgrade Linux Mint 19.1 (Tessa) to Linux Mint 19.2 (Tina).md b/published/20190810 How to Upgrade Linux Mint 19.1 (Tessa) to Linux Mint 19.2 (Tina).md new file mode 100644 index 0000000000..20ea79975d --- /dev/null +++ b/published/20190810 How to Upgrade Linux Mint 19.1 (Tessa) to Linux Mint 19.2 (Tina).md @@ -0,0 +1,237 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11298-1.html) +[#]: subject: (How to Upgrade Linux Mint 19.1 (Tessa) to Linux Mint 19.2 (Tina)?) +[#]: via: (https://www.2daygeek.com/upgrade-linux-mint-19-1-tessa-to-linux-mint-19-2-tina/) +[#]: author: (2daygeek http://www.2daygeek.com/author/2daygeek/) + +如何升级 Linux Mint 19.1 为 Linux Mint 19.2 +====== + +![](https://img.linux.net.cn/data/attachment/album/201909/02/231523na40npunm88z68ka.jpg) + +Linux Mint 19.2 “Tina” 在 2019 年 8 月 2 日发布,它是一个基于 Ubuntu 18.04 LTS (Bionic Beaver) 的长期支持版本。它将被支持到 2023 年。它带来更新的软件和精细的改进和很多新的特色来使你的桌面使用地更舒适。 + +Linux Mint 19.2 特色有 Cinnamon 4.2 、Linux 内核 4.15 和 Ubuntu 18.04 基础软件包。 + +**注意:** 不要忘记备份你的重要数据。如果一些东西出错,在最新的安装后,你可以从备份中恢复数据。 + +备份可以通过 rsnapshot 或 timeshift 完成。 + +Linux Mint 19.2 “Tina” 发布日志可以在下面的链接中找到。 + +* [Linux Mint 19.2 (Tina) 发布日志][1] + +这里有三种方法,能让我们升级为 Linux Mint 19.2 “Tina”。 + + * 使用本地方法升级 Linux Mint 19.2 (Tina) + * 使用 Mintupgrade 实用程序方法升级 Linux Mint 19.2 (Tina) + * 使用 GUI 升级 Linux Mint 19.2 (Tina) + +### 如何从 Linux Mint 19.1 (Tessa) 升级为 Linux Mint 19.2 (Tina)? + +升级 Linux Mint 系统是一项简单轻松的任务。有三种方法可以完成。 + +### 方法-1:使用本地方法升级 Linux Mint 19.2 (Tina) + +这是执行升级 Linux Mint 系统的本地和标准的方法之一。为做到这点,遵循下面的程序步骤。 + +确保你当前 Linux Mint 系统是最新的。使用下面的命令来更新你现在的软件为最新可用版本。 + +#### 步骤-1: + +通过运行下面的命令来刷新存储库索引。 + +``` +$ sudo apt update +``` + +运行下面的命令来在系统上安装可用的更新。 + +``` +$ sudo apt upgrade +``` + +运行下面的命令来在版本中执行可用的次要更新。 + +``` +$ sudo apt full-upgrade +``` + +默认情况下,它将通过上面的命令来移除过时的软件包。但是,我建议你运行下面的命令。 + +``` +$ sudo apt autoremove +$ sudo apt clean +``` + +如果安装一个新的内核,你可能需要重启系统。如果是这样,运行下面的命令。 + +``` +$ sudo shutdown -r now +``` + +最后检查当前安装的版本。 + +``` +$ lsb_release -a + +No LSB modules are available. +Distributor ID: Linux Mint +Description: Linux Mint 19.1 (Tessa) +Release: 19.1 +Codename: Tessa +``` + +#### 步骤-2:更新/修改 /etc/apt/sources.list 文件 + +在重启后,修改 `sources.list` 文件,并从 Linux Mint 19.1 (Tessa) 指向 Linux Mint 19.2 (Tina)。 + +首先,使用 `cp` 命令备份下面的配置文件。 + +``` +$ sudo cp /etc/apt/sources.list /root +$ sudo cp -r /etc/apt/sources.list.d/ /root +``` + +修改 `sources.list` 文件,并指向 Linux Mint 19.2 (Tina)。 + +``` +$ sudo sed -i 's/tessa/tina/g' /etc/apt/sources.list +$ sudo sed -i 's/tessa/tina/g' /etc/apt/sources.list.d/* +``` + +通过运行下面的命令来刷新存储库索引。 + +``` +$ sudo apt update +``` + +运行下面的命令来在系统上安装可用的更新。在升级过程中,你可用需要确认服务重启和配置文件替换,因此,只需遵循屏幕上的指令。 + +升级可能花费一些时间,具体依赖于更新的数量和你的网络速度。 + +``` +$ sudo apt upgrade +``` + +运行下面的命令来执行一次完整的系统升级。 + +``` +$ sudo apt full-upgrade +``` + +默认情况下,上面的命令将移除过时的软件包。但是,我建议你再次运行下面的命令。 + +``` +$ sudo apt autoremove +$ sudo apt clean +``` + +最后重启系统来启动 Linux Mint 19.2 (Tina)。 + +``` +$ sudo shutdown -r now +``` + +升级后的 Linux Mint 版本可以通过运行下面的命令验证。 + +``` +$ lsb_release -a + +No LSB modules are available. +Distributor ID: Linux Mint +Description: Linux Mint 19.2 (Tina) +Release: 19.2 +Codename: Tina +``` + +### 方法-2:使用 Mintupgrade 实用程序升级 Linux Mint 19.2 (Tina) + +这是 Mint 官方实用程序,它允许我们对 Linux Mint 系统执行平滑升级。 + +使用下面的命令来安装 mintupgrade 软件包。 + +``` +$ sudo apt install mintupgrade +``` + +确保你已经安装 mintupgrade 软件包的最新版本。 + +``` +$ apt version mintupgrade +``` + +以一个普通用户来运行下面的命令以模拟一次升级,遵循屏幕上的指令。 + +``` +$ mintupgrade check +``` + +使用下面的命令来下载需要的软件包来升级为 Linux Mint 19.2 (Tina) ,遵循屏幕上的指令。 + +``` +$ mintupgrade download +``` + +运行下面的命令来运用升级,最新屏幕上的指令。 + +``` +$ mintupgrade upgrade +``` + +在成功升级后,重启系统,并检查升级后的版本。 + +``` +$ lsb_release -a + +No LSB modules are available. +Distributor ID: Linux Mint +Description: Linux Mint 19.2 (Tina) +Release: 19.2 +Codename: Tina +``` + +### 方法-3:使用 GUI 升级 Linux Mint 19.2 (Tina) + +或者,我们可以通过 GUI 执行升级。 + +#### 步骤-1: + +通过 Timeshift 创建一个系统快照。如果一些东西出错,你可以简单地恢复你的操作系统到它先前状态。 + +#### 步骤-2: + +打开更新管理器,单击刷新按钮来检查 mintupdate 和 mint-upgrade-info 的任何新版本。如果有这些软件包的更新,应用它们。 + +通过单击 “编辑-> 升级到 Linux Mint 19.2 Tina”来启动系统升级。 + +![][3] + +遵循屏幕上的指令。如果被询问是否保留或替换配置文件,选择替换它们。 + +![][4] + +#### 步骤-3: + +在升级完成后,重启你的电脑。 + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/upgrade-linux-mint-19-1-tessa-to-linux-mint-19-2-tina/ + +作者:[2daygeek][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.2daygeek.com/author/2daygeek/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechnews.com/linux-mint-19-2-tina-released-check-what-is-new-feature/ +[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]: https://www.2daygeek.com/wp-content/uploads/2019/08/linux-mint-19-2-tina-mintupgrade.png +[4]: https://www.2daygeek.com/wp-content/uploads/2019/08/linux-mint-19-2-tina-mintupgrade-1.png diff --git a/published/20190812 Why const Doesn-t Make C Code Faster.md b/published/20190812 Why const Doesn-t Make C Code Faster.md new file mode 100644 index 0000000000..852b62f0c7 --- /dev/null +++ b/published/20190812 Why const Doesn-t Make C Code Faster.md @@ -0,0 +1,404 @@ +[#]: collector: (lujun9972) +[#]: translator: (LazyWolfLin) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11339-1.html) +[#]: subject: (Why const Doesn't Make C Code Faster) +[#]: via: (https://theartofmachinery.com/2019/08/12/c_const_isnt_for_performance.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +为什么 const 无法让 C 代码跑得更快? +====== + +![](https://img.linux.net.cn/data/attachment/album/201909/14/181535lsrt9t93k1c1n0mt.jpg) + +在几个月前的一篇文章里,我曾说过“[有个一个流行的传言,`const` 有助于编译器优化 C 和 C++ 代码][1]”。我觉得我需要解释一下,尤其是曾经我自己也以为这是显然对的。我将会用一些理论并构造一些例子来论证,然后在一个真实的代码库 `Sqlite` 上做一些实验和基准测试。 + +### 一个简单的测试 + +让我们从一个最简单、最明显的例子开始,以前认为这是一个 `const` 让 C 代码跑得更快的例子。首先,假设我们有如下两个函数声明: + +``` +void func(int *x); +void constFunc(const int *x); +``` + +然后假设我们如下两份代码: + +``` +void byArg(int *x) +{ + printf("%d\n", *x); + func(x); + printf("%d\n", *x); +} + +void constByArg(const int *x) +{ + printf("%d\n", *x); + constFunc(x); + printf("%d\n", *x); +} +``` + +调用 `printf()` 时,CPU 会通过指针从 RAM 中取得 `*x` 的值。很显然,`constByArg()` 会稍微快一点,因为编译器知道 `*x` 是常量,因此不需要在调用 `constFunc()` 之后再次获取它的值。它仅是打印相同的东西。没问题吧?让我们来看下 GCC 在如下编译选项下生成的汇编代码: + +``` +$ gcc -S -Wall -O3 test.c +$ view test.s +``` + +以下是函数 `byArg()` 的完整汇编代码: + +``` +byArg: +.LFB23: + .cfi_startproc + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + movl (%rdi), %edx + movq %rdi, %rbx + leaq .LC0(%rip), %rsi + movl $1, %edi + xorl %eax, %eax + call __printf_chk@PLT + movq %rbx, %rdi + call func@PLT # constFoo 中唯一不同的指令 + movl (%rbx), %edx + leaq .LC0(%rip), %rsi + xorl %eax, %eax + movl $1, %edi + popq %rbx + .cfi_def_cfa_offset 8 + jmp __printf_chk@PLT + .cfi_endproc +``` + +函数 `byArg()` 和函数 `constByArg()` 生成的汇编代码中唯一的不同之处是 `constByArg()` 有一句汇编代码 `call constFunc@PLT`,这正是源代码中的调用。关键字 `const` 本身并没有造成任何字面上的不同。 + +好了,这是 GCC 的结果。或许我们需要一个更聪明的编译器。Clang 会有更好的表现吗? + +``` +$ clang -S -Wall -O3 -emit-llvm test.c +$ view test.ll +``` + +这是 `IR` 代码(LCTT 译注:LLVM 的中间语言)。它比汇编代码更加紧凑,所以我可以把两个函数都导出来,让你可以看清楚我所说的“除了调用外,没有任何字面上的不同”是什么意思: + +``` +; Function Attrs: nounwind uwtable +define dso_local void @byArg(i32*) local_unnamed_addr #0 { + %2 = load i32, i32* %0, align 4, !tbaa !2 + %3 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %2) + tail call void @func(i32* %0) #4 + %4 = load i32, i32* %0, align 4, !tbaa !2 + %5 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4) + ret void +} + +; Function Attrs: nounwind uwtable +define dso_local void @constByArg(i32*) local_unnamed_addr #0 { + %2 = load i32, i32* %0, align 4, !tbaa !2 + %3 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %2) + tail call void @constFunc(i32* %0) #4 + %4 = load i32, i32* %0, align 4, !tbaa !2 + %5 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4) + ret void +} +``` + +### 某些有作用的东西 + +接下来是一组 `const` 能够真正产生作用的代码: + +``` +void localVar() +{ + int x = 42; + printf("%d\n", x); + constFunc(&x); + printf("%d\n", x); +} + +void constLocalVar() +{ + const int x = 42; // 对本地变量使用 const + printf("%d\n", x); + constFunc(&x); + printf("%d\n", x); +} +``` + +下面是 `localVar()` 的汇编代码,其中有两条指令在 `constLocalVar()` 中会被优化掉: + +``` +localVar: +.LFB25: + .cfi_startproc + subq $24, %rsp + .cfi_def_cfa_offset 32 + movl $42, %edx + movl $1, %edi + movq %fs:40, %rax + movq %rax, 8(%rsp) + xorl %eax, %eax + leaq .LC0(%rip), %rsi + movl $42, 4(%rsp) + call __printf_chk@PLT + leaq 4(%rsp), %rdi + call constFunc@PLT + movl 4(%rsp), %edx # 在 constLocalVar() 中没有 + xorl %eax, %eax + movl $1, %edi + leaq .LC0(%rip), %rsi # 在 constLocalVar() 中没有 + call __printf_chk@PLT + movq 8(%rsp), %rax + xorq %fs:40, %rax + jne .L9 + addq $24, %rsp + .cfi_remember_state + .cfi_def_cfa_offset 8 + ret +.L9: + .cfi_restore_state + call __stack_chk_fail@PLT + .cfi_endproc +``` + +在 LLVM 生成的 `IR` 代码中更明显一点。在 `constLocalVar()` 中,第二次调用 `printf()` 之前的 `load` 会被优化掉: + +``` +; Function Attrs: nounwind uwtable +define dso_local void @localVar() local_unnamed_addr #0 { + %1 = alloca i32, align 4 + %2 = bitcast i32* %1 to i8* + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %2) #4 + store i32 42, i32* %1, align 4, !tbaa !2 + %3 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 42) + call void @constFunc(i32* nonnull %1) #4 + %4 = load i32, i32* %1, align 4, !tbaa !2 + %5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4) + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %2) #4 + ret void +} +``` + +好吧,现在,`constLocalVar()` 成功的省略了对 `*x` 的重新读取,但是可能你已经注意到一些问题:`localVar()` 和 `constLocalVar()` 在函数体中做了同样的 `constFunc()` 调用。如果编译器能够推断出 `constFunc()` 没有修改 `constLocalVar()` 中的 `*x`,那为什么不能推断出完全一样的函数调用也没有修改 `localVar()` 中的 `*x`? + +这个解释更贴近于为什么 C 语言的 `const` 不能作为优化手段的核心原因。C 语言的 `const` 有两个有效的含义:它可以表示这个变量是某个可能是常数也可能不是常数的数据的一个只读别名,或者它可以表示该变量是真正的常量。如果你移除了一个指向常量的指针的 `const` 属性并写入数据,那结果将是一个未定义行为。另一方面,如果是一个指向非常量值的 `const` 指针,将就没问题。 + +这份 `constFunc()` 的可能实现揭示了这意味着什么: + +``` +// x 是一个指向某个可能是常数也可能不是常数的数据的只读指针 +void constFunc(const int *x) +{ + // local_var 是一个真正的常数 + const int local_var = 42; + + // C 语言规定的未定义行为 + doubleIt((int*)&local_var); + // 谁知道这是不是一个未定义行为呢? + doubleIt((int*)x); +} + +void doubleIt(int *x) +{ + *x *= 2; +} +``` + +`localVar()` 传递给 `constFunc()` 一个指向非 `const` 变量的 `const` 指针。因为这个变量并非常量,`constFunc()` 可以撒个谎并强行修改它而不触发未定义行为。所以,编译器不能断定变量在调用 `constFunc()` 后仍是同样的值。在 `constLocalVar()` 中的变量是真正的常量,因此,编译器可以断定它不会改变 —— 因为在 `constFunc()` 去除变量的 `const` 属性并写入它*将*会是一个未定义行为。 + +第一个例子中的函数 `byArg()` 和 `constByArg()` 是没有可能优化的,因为编译器没有任何方法能知道 `*x` 是否真的是 `const` 常量。 + +> 补充(和题外话):相当多的读者已经正确地指出,使用 `const int *x`,该指针本身不是限定的常量,只是该数据被加个了别名,而 `const int * const extra_const` 是一个“双向”限定为常量的指针。但是因为指针本身的常量与别名数据的常量无关,所以结果是相同的。仅在 `extra_const` 指向使用 `const` 定义的对象时,`*(int*const)extra_const = 0` 才是未定义行为。(实际上,`*(int*)extra_const = 0` 也不会更糟。)因为它们之间的区别可以一句话说明白,一个是完全的 `const` 指针,另外一个可能是也可能不是常量本身的指针,而是一个可能是也可能不是常量的对象的只读别名,我将继续不严谨地引用“常量指针”。(题外话结束) + +但是为什么不一致呢?如果编译器能够推断出 `constLocalVar()` 中调用的 `constFunc()` 不会修改它的参数,那么肯定也能继续在其他 `constFunc()` 的调用上实施相同的优化,是吗?并不。编译器不能假设 `constLocalVar()` 根本没有运行。如果不是这样(例如,它只是代码生成器或者宏的一些未使用的额外输出),`constFunc()` 就能偷偷地修改数据而不触发未定义行为。 + +你可能需要重复阅读几次上述说明和示例,但不要担心,它听起来很荒谬,它确实是正确的。不幸的是,对 `const` 变量进行写入是最糟糕的未定义行为:大多数情况下,编译器无法知道它是否将会是未定义行为。所以,大多数情况下,编译器看见 `const` 时必须假设它未来可能会被移除掉,这意味着编译器不能使用它进行优化。这在实践中是正确的,因为真实的 C 代码会在“深思熟虑”后移除 `const`。 + +简而言之,很多事情都可以阻止编译器使用 `const` 进行优化,包括使用指针从另一内存空间接受数据,或者在堆空间上分配数据。更糟糕的是,在大部分编译器能够使用 `const` 进行优化的情况,它都不是必须的。例如,任何像样的编译器都能推断出下面代码中的 `x` 是一个常量,甚至都不需要 `const`: + +``` +int x = 42, y = 0; +printf("%d %d\n", x, y); +y += x; +printf("%d %d\n", x, y); +``` + +总结,`const` 对优化而言几乎无用,因为: + +1. 除了特殊情况,编译器需要忽略它,因为其他代码可能合法地移除它 +2. 在 #1 以外的大多数例外中,编译器无论如何都能推断出该变量是常量 + +### C++ + +如果你在使用 C++ 那么有另外一个方法让 `const` 能够影响到代码的生成:函数重载。你可以用 `const` 和非 `const` 的参数重载同一个函数,而非 `const` 版本的代码可能可以被优化(由程序员优化而不是编译器),减少某些拷贝或者其他事情。 + +``` +void foo(int *p) +{ + // 需要做更多的数据拷贝 +} + +void foo(const int *p) +{ + // 不需要保护性的拷贝副本 +} + +int main() +{ + const int x = 42; + // const 影响被调用的是哪一个版本的重载函数 + foo(&x); + return 0; +} +``` + +一方面,我不认为这会在实际的 C++ 代码中大量使用。另一方面,为了导致差异,程序员需要假设编译器无法做出,因为它们不受语言保护。 + +### 用 Sqlite3 进行实验 + +有了足够的理论和例子。那么 `const` 在一个真正的代码库中有多大的影响呢?我将会在代码库 `Sqlite`(版本:3.30.0)上做一个测试,因为: + +* 它真正地使用了 `const` +* 它不是一个简单的代码库(超过 20 万行代码) +* 作为一个数据库,它包括了字符串处理、数学计算、日期处理等一系列内容 +* 它能够在绑定 CPU 的情况下进行负载测试 + +此外,作者和贡献者们已经进行了多年的性能优化工作,因此我能确定他们没有错过任何有显著效果的优化。 + +#### 配置 + +我做了两份[源码][2]拷贝,并且正常编译其中一份。而对于另一份拷贝,我插入了这个特殊的预处理代码段,将 `const` 变成一个空操作: + +``` +#define const +``` + +(GNU) `sed` 可以将一些东西添加到每个文件的顶端,比如 `sed -i '1i#define const' *.c *.h`。 + +在编译期间使用脚本生成 `Sqlite` 代码稍微有点复杂。幸运的是当 `const` 代码和非 `const` 代码混合时,编译器会产生了大量的提醒,因此很容易发现它并调整脚本来包含我的反 `const` 代码段。 + +直接比较编译结果毫无意义,因为任意微小的改变就会影响整个内存布局,这可能会改变整个代码中的指针和函数调用。因此,我用每个指令的二进制大小和汇编代码作为识别码(`objdump -d libsqlite3.so.0.8.6`)。举个例子,这个函数: + +``` +000000000005d570 : + 5d570: 4c 8d 05 59 a2 ff ff lea -0x5da7(%rip),%r8 # 577d0 + 5d577: e9 04 fe ff ff jmpq 5d380 + 5d57c: 0f 1f 40 00 nopl 0x0(%rax) +``` + +将会变成这样: + +``` +sqlite3_blob_read 7lea 5jmpq 4nopl +``` + +在编译时,我保留了所有 `Sqlite` 的编译设置。 + +#### 分析编译结果 + +`const` 版本的 `libsqlite3.so` 的大小是 4,740,704 字节,大约比 4,736,712 字节的非 `const` 版本大了 0.1% 。在全部 1374 个导出函数(不包括类似 PLT 里的底层辅助函数)中,一共有 13 个函数的识别码不一致。 + +其中的一些改变是由于插入的预处理代码。举个例子,这里有一个发生了更改的函数(已经删去一些 `Sqlite` 特有的定义): + +``` +#define LARGEST_INT64 (0xffffffff|(((int64_t)0x7fffffff)<<32)) +#define SMALLEST_INT64 (((int64_t)-1) - LARGEST_INT64) + +static int64_t doubleToInt64(double r){ + /* + ** Many compilers we encounter do not define constants for the + ** minimum and maximum 64-bit integers, or they define them + ** inconsistently. And many do not understand the "LL" notation. + ** So we define our own static constants here using nothing + ** larger than a 32-bit integer constant. + */ + static const int64_t maxInt = LARGEST_INT64; + static const int64_t minInt = SMALLEST_INT64; + + if( r<=(double)minInt ){ + return minInt; + }else if( r>=(double)maxInt ){ + return maxInt; + }else{ + return (int64_t)r; + } +} +``` + +删去 `const` 使得这些常量变成了 `static` 变量。我不明白为什么会有不了解 `const` 的人让这些变量加上 `static`。同时删去 `static` 和 `const` 会让 GCC 再次认为它们是常量,而我们将得到同样的编译输出。由于类似这样的局部的 `static const` 变量,使得 13 个函数中有 3 个函数产生假的变化,但我一个都不打算修复它们。 + +`Sqlite` 使用了很多全局变量,而这正是大多数真正的 `const` 优化产生的地方。通常情况下,它们类似于将一个变量比较代替成一个常量比较,或者一个循环在部分展开的一步。([Radare toolkit][3] 可以很方便的找出这些优化措施。)一些变化则令人失望。`sqlite3ParseUri()` 有 487 个指令,但 `const` 产生的唯一区别是进行了这个比较: + +``` +test %al, %al +je +cmp $0x23, %al +je +``` + +并交换了它们的顺序: + +``` +cmp $0x23, %al +je +test %al, %al +je +``` + +#### 基准测试 + +`Sqlite` 自带了一个性能回归测试,因此我尝试每个版本的代码执行一百次,仍然使用默认的 `Sqlite` 编译设置。以秒为单位的测试结果如下: + +| | const | 非 const +---|---|--- +最小值 | 10.658s | 10.803s +中间值 | 11.571s | 11.519s +最大值 | 11.832s | 11.658s +平均值 | 11.531s | 11.492s + +就我个人看来,我没有发现足够的证据来说明这个差异值得关注。我是说,我从整个程序中删去 `const`,所以如果它有明显的差别,那么我希望它是显而易见的。但也许你关心任何微小的差异,因为你正在做一些绝对性能非常重要的事。那让我们试一下统计分析。 + +我喜欢使用类似 Mann-Whitney U 检验这样的东西。它类似于更著名的 T 检验,但对你在机器上计时时产生的复杂随机变量(由于不可预测的上下文切换、页错误等)更加健壮。以下是结果: + +|| const | 非 const| +---|---|--- +N | 100 | 100 +Mean rank | 121.38 | 79.62 + +||| +---|--- +Mann-Whitney U | 2912 +Z | -5.10 +2-sided p value | <10-6 +HL median difference | -0.056s +95% confidence interval | -0.077s – -0.038s + +U 检验已经发现统计意义上具有显著的性能差异。但是,令人惊讶的是,实际上是非 `const` 版本更快——大约 60ms,0.5%。似乎 `const` 启用的少量“优化”不值得额外代码的开销。这不像是 `const` 启用了任何类似于自动矢量化的重要的优化。当然,你的结果可能因为编译器配置、编译器版本或者代码库等等而有所不同,但是我觉得这已经说明了 `const` 是否能够有效地提高 `C` 的性能,我们现在已经看到答案了。 + +### 那么,const 有什么用呢? + +尽管存在缺陷,C/C++ 的 `const` 仍有助于类型安全。特别是,结合 C++ 的移动语义和 `std::unique_pointer`,`const` 可以使指针所有权显式化。在超过十万行代码的 C++ 旧代码库里,指针所有权模糊是一个大难题,我对此深有感触。 + +但是,我以前常常使用 `const` 来实现有意义的类型安全。我曾听说过基于性能上的原因,最好是尽可能多地使用 `const`。我曾听说过当性能很重要时,重构代码并添加更多的 `const` 非常重要,即使以降低代码可读性的方式。**当时觉得这没问题,但后来我才知道这并不对。** + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2019/08/12/c_const_isnt_for_performance.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[LazyWolfLin](https://github.com/LazyWolfLin) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: https://theartofmachinery.com/2019/04/05/d_as_c_replacement.html#const-and-immutable +[2]: https://sqlite.org/src/doc/trunk/README.md +[3]: https://rada.re/r/ diff --git a/published/20190819 Moving files on Linux without mv.md b/published/20190819 Moving files on Linux without mv.md new file mode 100644 index 0000000000..2483018835 --- /dev/null +++ b/published/20190819 Moving files on Linux without mv.md @@ -0,0 +1,178 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11321-1.html) +[#]: subject: (Moving files on Linux without mv) +[#]: via: (https://opensource.com/article/19/8/moving-files-linux-without-mv) +[#]: author: (Seth Kenlon https://opensource.com/users/sethhttps://opensource.com/users/seth) + +在不使用 mv 命令的情况下移动文件 +====== + +> 有时当你需要移动一个文件时,mv 命令似乎不是最佳选项,那么你会如何做呢? + +![](https://img.linux.net.cn/data/attachment/album/201909/09/064313e02mvq28he8fk0mu.jpg) + +不起眼的 `mv` 命令是在你见过的每个 POSIX 系统中都能找到的有用工具之一。它的作用是明确定义的,并且做得很好:将文件从文件系统中的一个位置移动到另一个位置。但是 Linux 非常灵活,还有其他移动文件的办法。使用不同的工具可以完美匹配一些特殊用例,这算一个小优势。 + +在远离 `mv` 之前,先看看这个命令的默认结果。首先,创建一个目录并生成一些权限为 777 的文件: + +``` +$ mkdir example +$ touch example/{foo,bar,baz} +$ for i in example/*; do ls /bin > "${i}"; done +$ chmod 777 example/* +``` + +你可能不会这么认为,但是文件在一个[文件系统][2]中作为条目存在,称为索引节点(通常称为 inode),你可以使用 [ls 命令][3]及其 `--inode` 选项查看一个文件占用的 inode: + +``` +$ ls --inode example/foo +7476868 example/foo +``` + +作为测试,将文件从示例目录移动到当前目录,然后查看文件的属性: + +``` +$ mv example/foo . +$ ls -l -G -g --inode +7476868 -rwxrwxrwx. 1 29545 Aug  2 07:28 foo +``` + +如你所见,原始文件及权限已经被“移动”,但它的 inode 没有变化。 + +这就是 `mv` 工具用来移动的方式:保持 inode 不变(除非文件被移动到不同的文件系统),并保留其所有权和权限。 + +其他工具提供了不同的选项。 + +### 复制和删除 + +在某些系统上,移动操作是真的在做移动:比特从文件系统中的某个位置删除并重新分配给另一个位置。这种行为在很大程度上已经失宠。现在,移动操作要么是属性重新分配(inode 现在指向文件组织中的不同位置),要么是复制和删除操作的组合。这种设计的哲学意图是确保在移动失败时,文件不会碎片化。 + +与 `mv` 不同,`cp` 命令会在文件系统中创建一个全新的数据对象,它有一个新的 inode 位置,并取决于 umask。你可以使用 `cp` 和 `rm`(如果有的话,或者 [trash][4] —— LCTT 译注:它是一个命令行回收站工具)命令来模仿 `mv` 命令。 + +``` +$ cp example/foo . +$ ls -l -G -g --inode +7476869 -rwxrwxr-x. 29545 Aug  2 11:58 foo +$ trash example/foo +``` + +示例中的新 `foo` 文件获得了 755 权限,因为此处的 umask 明确排除了写入权限。 + +``` +$ umask +0002 +``` + +有关 umask 的更多信息,阅读 Alex Juarez 这篇关于[文件权限][5]的文章。 + +### 查看和删除 + +与复制和删除类似,使用 [cat][6](或 `tac`)命令在创建“移动”文件时分配不同的权限。假设当前目录中是一个没有 `foo` 的新测试环境: + +``` +$ cat example/foo > foo +$ ls -l -G -g --inode +7476869 -rw-rw-r--. 29545 Aug 8 12:21 foo +$ trash example/foo +``` + +这次,创建了一个没有事先设置权限的新文件,所以文件最终权限完全取决于 umask 设置,它不会阻止用户和组的权限位(无论 umask 是什么,都不会为新文件授予可执行权限),但它会阻止其他人的写入(值为 2)。所以结果是一个权限是 664 的文件。 + +### Rsync + +`rsync` 命令是一个强大的多功能工具,用于在主机和文件系统位置之间发送文件。此命令有许多可用选项,包括使其目标镜像成为源。 + +你可以使用带有 `--remove-source-files` 选项的 `rsync` 复制,然后删除文件,并可以带上你选择执行同步的任何其他选项(常见的通用选项是 `--archive`): + +``` +$ rsync --archive --remove-source-files example/foo . +$ ls example +bar  baz +$ ls -lGgi +7476870 -rwxrwxrwx. 1 seth users 29545 Aug 8 12:23 foo +``` + +在这里,你可以看到保留了文件权限和所有权,只是更新了时间戳,并删除了源文件。 + +警告:不要将此选项与 `--delete` 混淆,后者会从*目标*目录中删除(源目录中不存在的)文件。误用 `--delete` 会清除很多数据,建议你不要使用此选项,除非是在测试环境中。 + +你可以覆盖其中一些默认值,更改权限和修改设置: + +``` +$ rsync --chmod=666 --times \ + --remove-source-files example/foo . +$ ls example +bar  baz +$ ls -lGgi +7476871 -rw-rw-r--. 1 seth users 29545 Aug 8 12:55 foo +``` + +这里,目标的 umask 会生效,因此 `--chmod=666` 选项会产生一个权限为 644 的文件。 + +好处不仅仅是权限,与简单的 `mv` 命令相比,`rsync` 命令有[很多][7]有用的[选项][8](其中最重要的是 `--exclude` 选项,这样你可以在一个大型移动操作中排除某些项目),这使它成为一个更强大的工具。例如,要在移动文件集合时排除所有备份文件: + +``` +$ rsync --chmod=666 --times \ + --exclude '*~' \ + --remove-source-files example/foo . +``` + +### 使用 install 设置权限 + +`install` 命令是一个专门面向开发人员的复制命令,主要是作为软件编译安装例程的一部分调用。它并不为用户所知(我经常想知道为什么它有这么一个直观的名字,而剩下的包管理器却只能使用缩写和昵称),但是 `install` 实际上是一种将文件放在你想要地方的有用方法。 + +`install` 命令有很多选项,包括 `--backup` 和 `--compare` 命令(以避免*更新*文件的新副本)。 + +与 `cp` 和 `cat` 命令不同,但与 `mv` 完全相同,`install` 命令可以在复制文件的同时而保留其时间戳: + +``` +$ install --preserve-timestamp example/foo . +$ ls -l -G -g --inode +7476869 -rwxr-xr-x. 1 29545 Aug  2 07:28 foo +$ trash example/foo +``` + +在这里,文件被复制到一个新的 inode,但它的 mtime(修改时间)没有改变。但权限被设置为 `install` 的默认值 `755`。 + +你可以使用 `install` 来设置文件的权限,所有者和组: + +``` +$ install --preserve-timestamp \ + --owner=skenlon \ + --group=dialout \ + --mode=666 example/foo . +$ ls -li +7476869 -rw-rw-rw-. 1 skenlon dialout 29545 Aug  2 07:28 foo +$ trash example/foo +``` + +### 移动、复制和删除 + +文件包含数据,而真正重要的文件包含*你的*数据。学会聪明地管理它们是很重要的,现在你有了确保以你想要的方式来处理数据的工具包。 + +你是否有不同的数据管理方式?在评论中告诉我们你的想法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/moving-files-linux-without-mv + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sethhttps://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/yearbook-haff-rx-linux-file-lead_0.png?itok=-i0NNfDC (Hand putting a Linux file folder into a drawer) +[2]: https://opensource.com/article/18/11/partition-format-drive-linux#what-is-a-filesystem +[3]: https://opensource.com/article/19/7/master-ls-command +[4]: https://gitlab.com/trashy +[5]: https://opensource.com/article/19/8/linux-permissions-101#umask +[6]: https://opensource.com/article/19/2/getting-started-cat-command +[7]: https://opensource.com/article/19/5/advanced-rsync +[8]: https://opensource.com/article/17/1/rsync-backup-linux diff --git a/published/20190821 Getting Started with Go on Fedora.md b/published/20190821 Getting Started with Go on Fedora.md new file mode 100644 index 0000000000..25cff871be --- /dev/null +++ b/published/20190821 Getting Started with Go on Fedora.md @@ -0,0 +1,120 @@ +[#]: collector: "lujun9972" +[#]: translator: "hello-wn" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11293-1.html" +[#]: subject: "Getting Started with Go on Fedora" +[#]: via: "https://fedoramagazine.org/getting-started-with-go-on-fedora/" +[#]: author: "Clément Verna https://fedoramagazine.org/author/cverna/" + +在 Fefora 上开启 Go 语言之旅 +====== + +![][1] + +[Go][2] 编程语言于 2009 年首次公开发布,此后被广泛使用。特别是,Go 已经成为云基础设施领域的一种代表性语言,例如 [Kubernetes][3]、[OpenShift][4] 或 [Terraform][5] 等大型项目都使用了 Go。 + +Go 越来越受欢迎的原因是性能好、易于编写高并发的程序、语法简单和编译快。 + +让我们来看看如何在 Fedora 上开始 Go 语言编程吧。 + +### 在 Fedora 上安装 Go + +Fedora 可以通过官方库简单快速地安装 Go 语言。 + +``` +$ sudo dnf install -y golang +$ go version +go version go1.12.7 linux/amd64 +``` + +既然装好了 Go ,让我们来写个简单的程序,编译并运行。 + +### 第一个 Go 程序 + +让我们来用 Go 语言写一波 “Hello, World!”。首先创建 `main.go` 文件,然后输入或者拷贝以下内容。 + +``` +package main + +import "fmt" + +func main() { + fmt.Println("Hello, World!") +} +``` + +运行这个程序很简单。 + +``` +$ go run main.go +Hello, World! +``` + +Go 会在临时目录将 `main.go` 编译成二进制文件并执行,然后删除临时目录。这个命令非常适合在开发过程中快速运行程序,它还凸显了 Go 的编译速度。 + +编译一个可执行程序就像运行它一样简单。 + +``` +$ go build main.go +$ ./main +Hello, World! +``` + +### 使用 Go 的模块 + +Go 1.11 和 1.12 引入了对模块的初步支持。模块可用于管理应用程序的各种依赖包。Go 通过 `go.mod` 和 `go.sum` 这两个文件,显式地定义依赖包的版本。 + +为了演示如何使用模块,让我们为 `hello world` 程序添加一个依赖。 + +在更改代码之前,需要初始化模块。 + +``` +$ go mod init helloworld +go: creating new go.mod: module helloworld +$ ls +go.mod main main.go +``` + +然后按照以下内容修改 `main.go` 文件。 + +``` +package main + +import "github.com/fatih/color" + +func main () { + color.Blue("Hello, World!") +} +``` + +在修改后的 `main.go` 中,不再使用标准库 `fmt` 来打印 “Hello, World!” ,而是使用第三方库打印出有色字体。 + +让我们来跑一下新版的程序吧。 + +``` +$ go run main.go +Hello, World! +``` + +因为程序依赖于 `github.com/fatih/color` 库,它需要在编译前下载所有依赖包。 然后把依赖包都添加到 `go.mod` 中,并将它们的版本号和哈希值记录在 `go.sum` 中。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/getting-started-with-go-on-fedora/ + +作者:[Clément Verna][a] +选题:[lujun9972][b] +译者:[hello-wn](https://github.com/hello-wn) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/cverna/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/08/go-article-816x345.jpg +[2]: https://golang.org/ +[3]: https://kubernetes.io/ +[4]: https://www.openshift.com/ +[5]: https://www.terraform.io/ + diff --git a/published/20190822 How to move a file in Linux.md b/published/20190822 How to move a file in Linux.md new file mode 100644 index 0000000000..db2d2c4157 --- /dev/null +++ b/published/20190822 How to move a file in Linux.md @@ -0,0 +1,269 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11380-1.html) +[#]: subject: (How to move a file in Linux) +[#]: via: (https://opensource.com/article/19/8/moving-files-linux-depth) +[#]: author: (Seth Kenlon https://opensource.com/users/sethhttps://opensource.com/users/doni08521059) + +在 Linux 中如何移动文件 +====== + +> 无论你是刚接触 Linux 的文件移动的新手还是已有丰富的经验,你都可以通过此深入的文章中学到一些东西。 + +![](https://img.linux.net.cn/data/attachment/album/201909/24/162919ygppgeevgrj0ppgv.jpg) + +在 Linux 中移动文件看似比较简单,但是可用的选项却比大多数人想象的要多。本文介绍了初学者如何在 GUI 和命令行中移动文件,还介绍了底层实际上发生了什么,并介绍了许多有一定经验的用户也很少使用的命令行选项。 + +### 移动什么? + +在研究移动文件之前,有必要仔细研究*移动*文件系统对象时实际发生的情况。当文件创建后,会将其分配给一个索引节点inode,这是文件系统中用于数据存储的固定点。你可以使用 [ls][2] 命令看到文件对应的索引节点: + +``` +$ ls --inode example.txt +7344977 example.txt +``` + +移动文件时,实际上并没有将数据从一个索引节点移动到另一个索引节点,只是给文件对象分配了新的名称或文件路径而已。实际上,文件在移动时会保留其权限,因为移动文件不会更改或重新创建文件。(LCTT 译注:在不跨卷、分区和存储器时,移动文件是不会重新创建文件的;反之亦然) + +文件和目录的索引节点并没有暗示这种继承关系,而是由文件系统本身决定的。索引节点的分配是基于文件创建时的顺序分配的,并且完全独立于你组织计算机文件的方式。一个目录“内”的文件的索引节点号可能比其父目录的索引节点号更低或更高。例如: + +``` +$ mkdir foo +$ mv example.txt foo +$ ls --inode +7476865 foo +$ ls --inode foo +7344977 example.txt +``` + +但是,将文件从一个硬盘驱动器移动到另一个硬盘驱动器时,索引节点基本上会更改。发生这种情况是因为必须将新数据写入新文件系统。因此,在 Linux 中,移动和重命名文件的操作实际上是相同的操作。无论你将文件移动到另一个目录还是在同一目录使用新名称,这两个操作均由同一个底层程序执行。 + +本文重点介绍将文件从一个目录移动到另一个目录。 + +### 用鼠标移动文件 + +图形用户界面是大多数人都熟悉的友好的抽象层,位于复杂的二进制数据集合之上。这也是在 Linux 桌面上移动文件的首选方法,也是最直观的方法。从一般意义上来说,如果你习惯使用台式机,那么你可能已经知道如何在硬盘驱动器上移动文件。例如,在 GNOME 桌面上,将文件从一个窗口拖放到另一个窗口时的默认操作是移动文件而不是复制文件,因此这可能是该桌面上最直观的操作之一: + +![Moving a file in GNOME.][3] + +而 KDE Plasma 桌面中的 Dolphin 文件管理器默认情况下会提示用户以执行不同的操作。拖动文件时按住 `Shift` 键可强制执行移动操作: + +![Moving a file in KDE.][4] + +### 在命令行移动文件 + +用于在 Linux、BSD、Illumos、Solaris 和 MacOS 上移动文件的 shell 命令是 `mv`。不言自明,简单的命令 `mv ` 会将源文件移动到指定的目标,源和目标都由[绝对][5]或[相对][6]文件路径定义。如前所述,`mv` 是 [POSIX][7] 用户的常用命令,其有很多不为人知的附加选项,因此,无论你是新手还是有经验的人,本文都会为你带来一些有用的选项。 + +但是,不是所有 `mv` 命令都是由同一个人编写的,因此取决于你的操作系统,你可能拥有 GNU `mv`、BSD `mv` 或 Sun `mv`。命令的选项因其实现而异(BSD `mv` 根本没有长选项),因此请参阅你的 `mv` 手册页以查看支持的内容,或安装你的首选版本(这是开源的奢侈之处)。 + +#### 移动文件 + +要使用 `mv` 将文件从一个文件夹移动到另一个文件夹,请记住语法 `mv `。 例如,要将文件 `example.txt` 移到你的 `Documents` 目录中: + +``` +$ touch example.txt +$ mv example.txt ~/Documents +$ ls ~/Documents +example.txt +``` + +就像你通过将文件拖放到文件夹图标上来移动文件一样,此命令不会将 `Documents` 替换为 `example.txt`。相反,`mv` 会检测到 `Documents` 是一个文件夹,并将 `example.txt` 文件放入其中。 + +你还可以方便地在移动文件时重命名该文件: + +``` +$ touch example.txt +$ mv example.txt ~/Documents/foo.txt +$ ls ~/Documents +foo.txt +``` + +这很重要,这使你不用将文件移动到另一个位置,也可以重命名文件,例如: + +``` +$ touch example.txt +$ mv example.txt foo2.txt +$ ls foo2.txt` +``` + +#### 移动目录 + +不像 [cp][8] 命令,`mv` 命令处理文件和目录没有什么不同,你可以用同样的格式移动目录或文件: + +``` +$ touch file.txt +$ mkdir foo_directory +$ mv file.txt foo_directory +$ mv foo_directory ~/Documents +``` + +#### 安全地移动文件 + +如果你移动一个文件到一个已有同名文件的地方,默认情况下,`mv` 会用你移动的文件替换目标文件。这种行为被称为清除clobbering,有时候这就是你想要的结果,而有时则不是。 + +一些发行版将 `mv` 别名定义为 `mv --interactive`(你也可以[自己写一个][9]),这会提醒你确认是否覆盖。而另外一些发行版没有这样做,那么你可以使用 `--interactive` 或 `-i` 选项来确保当两个文件有一样的名字而发生冲突时让 `mv` 请你来确认。 + +``` +$ mv --interactive example.txt ~/Documents +mv: overwrite '~/Documents/example.txt'? +``` + +如果你不想手动干预,那么可以使用 `--no-clobber` 或 `-n`。该选项会在发生冲突时静默拒绝移动操作。在这个例子当中,一个名为 `example.txt` 的文件以及存在于 `~/Documents`,所以它不会如命令要求从当前目录移走。 + +``` +$ mv --no-clobber example.txt ~/Documents +$ ls +example.txt +``` + +#### 带备份的移动 + +如果你使用 GNU `mv`,有一个备份选项提供了另外一种安全移动的方式。要为任何冲突的目标文件创建备份文件,可以使用 `-b` 选项。 + +``` +$ mv -b example.txt ~/Documents +$ ls ~/Documents +example.txt    example.txt~ +``` + +这个选项可以确保 `mv` 完成移动操作,但是也会保护目录位置的已有文件。 + +另外的 GNU 备份选项是 `--backup`,它带有一个定义了备份文件如何命名的参数。 + +* `existing`:如果在目标位置已经存在了编号备份文件,那么会创建编号备份。否则,会使用 `simple` 方式。 +* `none`:即使设置了 `--backup`,也不会创建备份。当 `mv` 被别名定义为带有备份选项时,这个选项可以覆盖这种行为。 +* `numbered`:给目标文件名附加一个编号。 +* `simple`:给目标文件附加一个 `~`,当你日常使用带有 `--ignore-backups` 选项的 [ls][2] 时,这些文件可以很方便地隐藏起来。 + +简单来说: + +``` +$ mv --backup=numbered example.txt ~/Documents +$ ls ~/Documents +-rw-rw-r--. 1 seth users 128 Aug  1 17:23 example.txt +-rw-rw-r--. 1 seth users 128 Aug  1 17:20 example.txt.~1~ +``` + +可以使用环境变量 `VERSION_CONTROL` 设置默认的备份方案。你可以在 `~/.bashrc` 文件中设置该环境变量,也可以在命令前动态设置: + +``` +$ VERSION_CONTROL=numbered mv --backup example.txt ~/Documents +$ ls ~/Documents +-rw-rw-r--. 1 seth users 128 Aug  1 17:23 example.txt +-rw-rw-r--. 1 seth users 128 Aug  1 17:20 example.txt.~1~ +-rw-rw-r--. 1 seth users 128 Aug  1 17:22 example.txt.~2~ +``` + +`--backup` 选项仍然遵循 `--interactive` 或 `-i` 选项,因此即使它在执行备份之前创建了备份,它仍会提示你覆盖目标文件: + +``` +$ mv --backup=numbered example.txt ~/Documents +mv: overwrite '~/Documents/example.txt'? y +$ ls ~/Documents +-rw-rw-r--. 1 seth users 128 Aug  1 17:24 example.txt +-rw-rw-r--. 1 seth users 128 Aug  1 17:20 example.txt.~1~ +-rw-rw-r--. 1 seth users 128 Aug  1 17:22 example.txt.~2~ +-rw-rw-r--. 1 seth users 128 Aug  1 17:23 example.txt.~3~ +``` + +你可以使用 `--force` 或 `-f` 选项覆盖 `-i`。 + +``` +$ mv --backup=numbered --force example.txt ~/Documents +$ ls ~/Documents +-rw-rw-r--. 1 seth users 128 Aug  1 17:26 example.txt +-rw-rw-r--. 1 seth users 128 Aug  1 17:20 example.txt.~1~ +-rw-rw-r--. 1 seth users 128 Aug  1 17:22 example.txt.~2~ +-rw-rw-r--. 1 seth users 128 Aug  1 17:24 example.txt.~3~ +-rw-rw-r--. 1 seth users 128 Aug  1 17:25 example.txt.~4~ +``` + +`--backup` 选项在 BSD `mv` 中不可用。 + +#### 一次性移动多个文件 + +移动多个文件时,`mv` 会将最终目录视为目标: + +``` +$ mv foo bar baz ~/Documents +$ ls ~/Documents +foo   bar   baz +``` + +如果最后一个项目不是目录,则 `mv` 返回错误: + +``` +$ mv foo bar baz +mv: target 'baz' is not a directory +``` + +GNU `mv` 的语法相当灵活。如果无法把目标目录作为提供给 `mv` 命令的最终参数,请使用 `--target-directory` 或 `-t` 选项: + +``` +$ mv --target-directory=~/Documents foo bar baz +$ ls ~/Documents +foo   bar   baz +``` + +当从某些其他命令的输出构造 `mv` 命令时(例如 `find` 命令、`xargs` 或 [GNU Parallel][10]),这特别有用。 + +#### 基于修改时间移动 + +使用 GNU `mv`,你可以根据要移动的文件是否比要替换的目标文件新来定义移动动作。该方式可以通过 `--update` 或 `-u` 选项使用,在BSD `mv` 中不可用: + +``` +$ ls -l ~/Documents +-rw-rw-r--. 1 seth users 128 Aug  1 17:32 example.txt +$ ls -l +-rw-rw-r--. 1 seth users 128 Aug  1 17:42 example.txt +$ mv --update example.txt ~/Documents +$ ls -l ~/Documents +-rw-rw-r--. 1 seth users 128 Aug  1 17:42 example.txt +$ ls -l +``` + +此结果仅基于文件的修改时间,而不是两个文件的差异,因此请谨慎使用。只需使用 `touch` 命令即可愚弄 `mv`: + +``` +$ cat example.txt +one +$ cat ~/Documents/example.txt +one +two +$ touch example.txt +$ mv --update example.txt ~/Documents +$ cat ~/Documents/example.txt +one +``` + +显然,这不是最智能的更新功能,但是它提供了防止覆盖最新数据的基本保护。 + +### 移动 + +除了 `mv` 命令以外,还有更多的移动数据的方法,但是作为这项任务的默认程序,`mv` 是一个很好的通用选择。现在你知道了有哪些可以使用的选项,可以比以前更智能地使用 `mv` 了。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/moving-files-linux-depth + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sethhttps://opensource.com/users/doni08521059 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/files_documents_paper_folder.png?itok=eIJWac15 (Files in a folder) +[2]: https://opensource.com/article/19/7/master-ls-command +[3]: https://opensource.com/sites/default/files/uploads/gnome-mv.jpg (Moving a file in GNOME.) +[4]: https://opensource.com/sites/default/files/uploads/kde-mv.jpg (Moving a file in KDE.) +[5]: https://opensource.com/article/19/7/understanding-file-paths-and-how-use-them +[6]: https://opensource.com/article/19/7/navigating-filesystem-relative-paths +[7]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[8]: https://opensource.com/article/19/7/copying-files-linux +[9]: https://opensource.com/article/19/7/bash-aliases +[10]: https://opensource.com/article/18/5/gnu-parallel diff --git a/published/20190823 How To Check Your IP Address in Ubuntu -Beginner-s Tip.md b/published/20190823 How To Check Your IP Address in Ubuntu -Beginner-s Tip.md new file mode 100644 index 0000000000..33084aaa52 --- /dev/null +++ b/published/20190823 How To Check Your IP Address in Ubuntu -Beginner-s Tip.md @@ -0,0 +1,112 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11308-1.html) +[#]: subject: (How To Check Your IP Address in Ubuntu [Beginner’s Tip]) +[#]: via: (https://itsfoss.com/check-ip-address-ubuntu/) +[#]: author: (Sergiu https://itsfoss.com/author/sergiu/) + +如何在 Ubuntu 中检查你的 IP 地址 +====== + +不知道你的 IP 地址是什么?以下是在 Ubuntu 和其他 Linux 发行版中检查 IP 地址的几种方法。 + +![][1] + +### 什么是 IP 地址? + +**互联网协议地址**(通常称为 **IP 地址**)是分配给连接到计算机网络的每个设备(使用互联网协议)的数字标签。IP 地址用于识别和定位机器。 + +**IP 地址**在网络中是*唯一的*,使得所有连接设备能够通信。 + +你还应该知道有两种**类型的 IP 地址**:**公有**和**私有**。**公有 IP 地址**是用于互联网通信的地址,这与你用于邮件的物理地址相同。但是,在本地网络(例如使用路由器的家庭)的环境中,会为每个设备分配在该子网内唯一的**私有 IP 地址**。这在本地网络中使用,而不直接暴露公有 IP(路由器用它与互联网通信)。 + +另外还有区分 **IPv4** 和 **IPv6** 协议。**IPv4** 是经典的 IP 格式,它由基本的 4 部分结构组成,四个字节用点分隔(例如 127.0.0.1)。但是,随着设备数量的增加,IPv4 很快就无法提供足够的地址。这就是 **IPv6** 被发明的原因,它使用 **128 位地址**的格式(与 **IPv4** 使用的 **32 位地址**相比)。 + +### 在 Ubuntu 中检查你的 IP 地址(终端方式) + +检查 IP 地址的最快和最简单的方法是使用 `ip` 命令。你可以按以下方式使用此命令: + +``` +ip addr show +``` + +它将同时显示 IPv4 和 IPv6 地址: + +![Display IP Address in Ubuntu Linux][2] + +实际上,你可以进一步缩短这个命令 `ip a`。它会给你完全相同的结果。 + +``` +ip a +``` + +如果你希望获得最少的细节,也可以使用 `hostname`: + +``` +hostname -I +``` + +还有一些[在 Linux 中检查 IP 地址的方法][3],但是这两个命令足以满足这个目的。 + +`ifconfig` 如何? + +老用户可能会想要使用 `ifconfig`(net-tools 软件包的一部分),但该程序已被弃用。一些较新的 Linux 发行版不再包含此软件包,如果你尝试运行它,你将看到 ifconfig 命令未找到的错误。 + +### 在 Ubuntu 中检查你的 IP 地址(GUI 方式) + +如果你对命令行不熟悉,你还可以使用图形方式检查 IP 地址。 + +打开 Ubuntu 应用菜单(在屏幕左下角**显示应用**)并搜索**Settings**,然后单击图标: + +![Applications Menu Settings][5] + +这应该会打开**设置菜单**。进入**网络**: + +![Network Settings Ubuntu][6] + +按下连接旁边的**齿轮图标**会打开一个窗口,其中包含更多设置和有关你网络链接的信息,其中包括你的 IP 地址: + +![IP Address GUI Ubuntu][7] + +### 额外提示:检查你的公共 IP 地址(适用于台式计算机) + +首先,要检查你的**公有 IP 地址**(用于与服务器通信),你可以[使用 curl 命令][8]。打开终端并输入以下命令: + +``` +curl ifconfig.me +``` + +这应该只会返回你的 IP 地址而没有其他多余信息。我建议在分享这个地址时要小心,因为这相当于公布你的个人地址。 + +**注意:** 如果 `curl` 没有安装,只需使用 `sudo apt install curl -y` 来解决问题,然后再试一次。 + +另一种可以查看公共 IP 地址的简单方法是在 Google 中搜索 “ip address”。 + +### 总结 + +在本文中,我介绍了在 Uuntu Linux 中找到 IP 地址的不同方法,并向你概述了 IP 地址的用途以及它们对我们如此重要的原因。 + +我希望你喜欢这篇文章。如果你觉得文章有用,请在评论栏告诉我们! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/check-ip-address-ubuntu/ + +作者:[Sergiu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/sergiu/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/checking-ip-address-ubuntu.png?resize=800%2C450&ssl=1 +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/ip_addr_show.png?fit=800%2C493&ssl=1 +[3]: https://linuxhandbook.com/find-ip-address/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/08/applications_menu_settings.jpg?fit=800%2C309&ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/network_settings_ubuntu.jpg?fit=800%2C591&ssl=1 +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/ip_address_gui_ubuntu.png?fit=800%2C510&ssl=1 +[8]: https://linuxhandbook.com/curl-command-examples/ diff --git a/published/20190823 The Linux kernel- Top 5 innovations.md b/published/20190823 The Linux kernel- Top 5 innovations.md new file mode 100644 index 0000000000..486270ccfd --- /dev/null +++ b/published/20190823 The Linux kernel- Top 5 innovations.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11368-1.html) +[#]: subject: (The Linux kernel: Top 5 innovations) +[#]: via: (https://opensource.com/article/19/8/linux-kernel-top-5-innovations) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Linux 内核的五大创新 +====== + +> 想知道什么是 Linux 内核上真正的(不是那种时髦的)创新吗? + +![](https://img.linux.net.cn/data/attachment/album/201909/21/093858no01oh78v111r3zt.jpg) + +在科技行业,*创新*这个词几乎和*革命*一样到处泛滥,所以很难将那些夸张的东西与真正令人振奋的东西区分开来。Linux 内核被称为创新,但它又被称为现代计算中最大的奇迹,一个微观世界中的庞然大物。 + +撇开营销和模式不谈,Linux 可以说是开源世界中最受欢迎的内核,它在近 30 年的生命时光当中引入了一些真正的规则改变者。 + +### Cgroups(2.6.24) + +早在 2007 年,Paul Menage 和 Rohit Seth 就在内核中添加了深奥的[控制组(cgroups)][2]功能(cgroups 的当前实现是由 Tejun Heo 重写的)。这种新技术最初被用作一种方法,从本质上来说,是为了确保一组特定任务的服务质量。 + +例如,你可以为与你的 WEB 服务相关联的所有任务创建一个控制组定义(cgroup),为例行备份创建另一个 cgroup ,再为一般操作系统需求创建另一个 cgroup。然后,你可以控制每个组的资源百分比,这样你的操作系统和 WEB 服务就可以获得大部分系统资源,而你的备份进程可以访问剩余的资源。 + +然而,cgroups 如今变得这么著名是因其作为驱动云技术的角色:容器。事实上,cgroups 最初被命名为[进程容器][3]。当它们被 [LXC][4]、[CoreOS][5] 和 Docker 等项目采用时,这并不奇怪。 + +就像闸门打开后一样,“容器” 一词就像成为了 Linux 的同义词一样,微服务风格的基于云的“应用”概念很快成为了规范。如今,已经很难摆脱 cgroups 了,它们是如此普遍。每一个大规模的基础设施(如果你运行 Linux 的话,可能还有你的笔记本电脑)都以一种合理的方式使用了 cgroups,这使得你的计算体验比以往任何时候都更加易于管理和灵活。 + +例如,你可能已经在电脑上安装了 [Flathub][6] 或 [Flatpak][7],或者你已经在工作中使用 [Kubernetes][8] 和/或 [OpenShift][9]。不管怎样,如果“容器”这个术语对你来说仍然模糊不清,则可以 [通过 Linux 容器从背后][10]获得对容器的实际理解。 + +### LKMM(4.17) + +2018 年,Jade Alglave、Alan Stern、Andrea Parri、Luc Maranget、Paul McKenney 以及其他几个人的辛勤工作的成果被合并到主线 Linux 内核中,以提供正式的内存模型。Linux 内核内存[一致性]模型(LKMM)子系统是一套描述 Linux 内存一致性模型的工具,同时也产生用于测试的用例(特别命名为 klitmus)。 + +随着系统在物理设计上变得越来越复杂(增加了更多的中央处理器内核,高速缓存和内存增长,等等),它们就越难知道哪个中央处理器需要哪个地址空间,以及何时需要。例如,如果 CPU0 需要将数据写入内存中的共享变量,并且 CPU1 需要读取该值,那么 CPU0 必须在 CPU1 尝试读取之前写入。类似地,如果值是以一种顺序方式写入内存的,那么期望它们也以同样的顺序被读取,而不管哪个或哪些 CPU 正在读取。 + +即使在单个处理器上,内存管理也需要特定的任务顺序。像 `x = y` 这样的简单操作需要处理器从内存中加载 `y` 的值,然后将该值存储在 `x` 中。在处理器从内存中读取值之前,是不能将存储在 `y` 中的值放入 `x` 变量的。此外还有地址依赖:`x[n] = 6` 要求在处理器能够存储值 `6` 之前加载 `n`。 + +LKMM 可以帮助识别和跟踪代码中的这些内存模式。它部分是通过一个名为 `herd` 的工具来实现的,该工具(以逻辑公式的形式)定义了内存模型施加的约束,然后列举了与这些约束一致性的所有可能的结果。 + +### 低延迟补丁(2.6.38) + +很久以前,在 2011 年之前,如果你想[在 Linux 上进行多媒体工作][11],你必须得有一个低延迟内核。这主要适用于[录音][12]时添加了许多实时效果(如对着麦克风唱歌和添加混音,以及在耳机中无延迟地听到你的声音)。有些发行版,如 [Ubuntu Studio][13],可靠地提供了这样一个内核,所以实际上这没有什么障碍,这只不过是当艺术家选择发行版时的一个重要提醒。 + +然而,如果你没有使用 Ubuntu Studio,或者你需要在你的发行版提供之前更新你的内核,你必须跳转到 rt-patches 网页,下载内核补丁,将它们应用到你的内核源代码,编译,然后手动安装。 + +后来,随着内核版本 2.6.38 的发布,这个过程结束了。Linux 内核突然像变魔术一样默认内置了低延迟代码(根据基准测试,延迟至少降低了 10 倍)。不再需要下载补丁,不用编译。一切都很顺利,这都是因为 Mike Galbraith 编写了一个 200 行的小补丁。 + +对于全世界的开源多媒体艺术家来说,这是一个规则改变者。从 2011 年开始事情变得如此美好,到 2016 年我自己做了一个挑战,[在树莓派 v1(型号 B)上建造一个数字音频工作站(DAW)][14],结果发现它运行得出奇地好。 + +### RCU(2.5) + +RCU,即读-拷贝-更新Read-Copy-Update,是计算机科学中定义的一个系统,它允许多个处理器线程从共享内存中读取数据。它通过延迟更新但也将它们标记为已更新来做到这一点,以确保数据读取为最新内容。实际上,这意味着读取与更新同时发生。 + +典型的 RCU 循环有点像这样: + +1. 删除指向数据的指针,以防止其他读操作引用它。 +2. 等待读操作完成它们的关键处理。 +3. 回收内存空间。 + +将更新阶段划分为删除和回收阶段意味着更新程序会立即执行删除,同时推迟回收直到所有活动读取完成(通过阻止它们或注册一个回调以便在完成时调用)。 + +虽然 RCU 的概念不是为 Linux 内核发明的,但它在 Linux 中的实现是该技术的一个定义性的例子。 + +### 合作(0.01) + +对于 Linux 内核创新的问题的最终答案永远是协作。你可以说这是一个好时机,也可以称之为技术优势,称之为黑客能力,或者仅仅称之为开源,但 Linux 内核及其支持的许多项目是协作与合作的光辉范例。 + +它远远超出了内核范畴。各行各业的人都对开源做出了贡献,可以说都是因为 Linux 内核。Linux 曾经是,现在仍然是[自由软件][15]的主要力量,激励人们把他们的代码、艺术、想法或者仅仅是他们自己带到一个全球化的、有生产力的、多样化的人类社区中。 + +### 你最喜欢的创新是什么? + +这个列表偏向于我自己的兴趣:容器、非统一内存访问(NUMA)和多媒体。无疑,列表中肯定缺少你最喜欢的内核创新。在评论中告诉我。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/linux-kernel-top-5-innovations + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_penguin_green.png?itok=ENdVzW22 (Penguin with green background) +[2]: https://en.wikipedia.org/wiki/Cgroups +[3]: https://lkml.org/lkml/2006/10/20/251 +[4]: https://linuxcontainers.org +[5]: https://coreos.com/ +[6]: http://flathub.org +[7]: http://flatpak.org +[8]: http://kubernetes.io +[9]: https://www.redhat.com/sysadmin/learn-openshift-minishift +[10]: https://opensource.com/article/18/11/behind-scenes-linux-containers +[11]: http://slackermedia.info +[12]: https://opensource.com/article/17/6/qtractor-audio +[13]: http://ubuntustudio.org +[14]: https://opensource.com/life/16/3/make-music-raspberry-pi-milkytracker +[15]: http://fsf.org diff --git a/published/20190825 Top 5 IoT networking security mistakes.md b/published/20190825 Top 5 IoT networking security mistakes.md new file mode 100644 index 0000000000..237d81b266 --- /dev/null +++ b/published/20190825 Top 5 IoT networking security mistakes.md @@ -0,0 +1,62 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11299-1.html) +[#]: subject: (Top 5 IoT networking security mistakes) +[#]: via: (https://www.networkworld.com/article/3433476/top-5-iot-networking-security-mistakes.html) +[#]: author: (Fredric Paul https://www.networkworld.com/author/Fredric-Paul/) + +五大物联网网络安全错误 +====== + +> IT 供应商兄弟国际公司分享了五种最常见的物联网安全错误,这是从它们的打印机和多功能设备买家中看到的。 + +![Getty Images][1] + +尽管[兄弟国际公司][2]是许多 IT 产品的供应商,从[机床][3]到[头戴式显示器][4]再到[工业缝纫机][5],但它最知名的产品是打印机。在当今世界,这些打印机不再是独立的设备,而是物联网的组成部分。 + +这也是我为什么对罗伯特•伯内特提供的这份列表感兴趣的原因。伯内特是兄弟公司的总监,负责 B2B 产品和提供解决方案。基本上是该公司负责大客户实施的关键人物。所以他对打印机相关的物联网安全错误非常关注,并且分享了兄弟国际公司对于处理这五大错误的建议。 + +### #5:不控制访问和授权 + +伯内特说:“过去,成本控制是管理谁可以使用机器、何时结束工作背后的推动力。”当然,这在今天也仍然很重要,但他指出安全性正迅速成为管理控制打印和扫描设备的关键因素。这不仅适用于大型企业,也适用于各种规模的企业。 + +### #4:无法定期更新固件 + +让我们来面对这一现实,大多数 IT 专业人员都忙于保持服务器和其他网络基础设施设备的更新,确保其基础设施尽可能的安全高效。“在这日常的流程中,像打印机这样的设备经常被忽视。”但过时的固件可能会使基础设施面临新的威胁。 + +### #3:设备意识不足 + +伯内特说:“正确理解谁在使用什么设备,以及整套设备中所有连接设备的功能是什么,这是至关重要的。使用端口扫描技术、协议分析和其他检测技术检查这些设备应作为你的网络基础设施整体安全审查中的一部分。 他常常提醒人们说:“处理打印设备的方法是:如果没有损坏,就不要修理!”但即使是可靠运行多年的设备也应该成为安全审查的一部分。这是因为旧设备可能无法提供更强大的安全设置,或者可能需要更新其配置才能满足当今更高的安全要求,这其中包括设备的监控/报告功能。 + +### #2:用户培训不足 + +“应该把培训团队在工作过程中管理文档的最佳实践作为强有力的安全计划中的一部分。”伯内特说道,“然而,事实却是,无论你如何努力地去保护物联网设备,人为因素通常是一家企业在保护重要和敏感信息方面最薄弱的环节。像这些简单的事情,如无意中将重要文件留在打印机上供任何人查看,或者将文件扫描到错误的目的地,不仅会给企业带来经济损失和巨大的负面影响,还会影响企业的知识产权、声誉,引起合规性/监管问题。” + +### #1:使用默认密码 + +“只是因为它很方便并不意味着它不重要!”伯内特说,“保护打印机和多功能设备免受未经授权的管理员访问不仅有助于保护敏感的机器配置设置和报告信息,还可以防止访问个人信息,例如,像可能用于网络钓鱼攻击的用户名。” + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3433476/top-5-iot-networking-security-mistakes.html + +作者:[Fredric Paul][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Fredric-Paul/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/iot_security_tablet_conference_digital-100787102-large.jpg +[2]: https://www.brother-usa.com/business +[3]: https://www.brother-usa.com/machinetool/default?src=default +[4]: https://www.brother-usa.com/business/hmd#sort=%40productcatalogsku%20ascending +[5]: https://www.brother-usa.com/business/industrial-sewing +[6]: https://www.networkworld.com/article/2855207/internet-of-things/5-ways-to-prepare-for-internet-of-things-security-threats.html#tk.nww-infsb +[7]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr +[8]: https://www.facebook.com/NetworkWorld/ +[9]: https://www.linkedin.com/company/network-world diff --git a/published/20190826 5 ops tasks to do with Ansible.md b/published/20190826 5 ops tasks to do with Ansible.md new file mode 100644 index 0000000000..de7916b81d --- /dev/null +++ b/published/20190826 5 ops tasks to do with Ansible.md @@ -0,0 +1,95 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11312-1.html) +[#]: subject: (5 ops tasks to do with Ansible) +[#]: via: (https://opensource.com/article/19/8/ops-tasks-ansible) +[#]: author: (Mark Phillips https://opensource.com/users/markphttps://opensource.com/users/adminhttps://opensource.com/users/alsweigarthttps://opensource.com/users/belljennifer43) + +5 个 Ansible 运维任务 +====== + +> 让 DevOps 少一点,OpsDev 多一点。 + +![gears and lightbulb to represent innovation][1] + +在这个 DevOps 世界中,看起来开发(Dev)这一半成为了关注的焦点,而运维(Ops)则是这个关系中被遗忘的另一半。这几乎就好像是领头的开发告诉尾随的运维做什么,几乎所有的“运维”都是开发说要做的。因此,运维被抛到后面,降级到了替补席上。 + +我想看到更多的 OpsDev。因此,让我们来看看 Ansible 在日常的运维中可以帮助你什么。 + +![Job templates][2] + +我选择在 [Ansible Tower][3] 中展示这些方案,因为我认为用户界面 (UI) 可以增色大多数的任务。如果你想模拟测试,你可以在 Tower 的上游开源版本 [AWX][4] 中测试它。 + +### 管理用户 + +在大规模环境中,你的用户将集中在活动目录或 LDAP 等系统中。但我敢打赌,仍然存在许多包含大量的静态用户的全负荷环境。Ansible 可以帮助你将这些分散的环境集中到一起。*社区*已为我们解决了这个问题。看看 [Ansible Galaxy][5] 中的 [users][6] 角色。 + +这个角色的聪明之处在于它允许我们通过*数据*管理用户,而无需更改运行逻辑。 + +![User data][7] + +通过简单的数据结构,我们可以在系统上添加、删除和修改静态用户。这很有用。 + +### 管理 sudo + +提权有[多种形式][8],但最流行的是 [sudo][9]。通过每个 `user`、`group` 等离散文件来管理 sudo 相对容易。但一些人对给予特权感到紧张,并倾向于有时限地给予提权。因此[下面是一种方案][10],它使用简单的 `at` 命令对授权访问设置时间限制。 + +![Managing sudo][11] + +### 管理服务 + +给入门级运维团队提供[菜单][12]以便他们可以重启某些服务不是很好吗?看下面! + +![Managing services][13] + +### 管理磁盘空间 + +这有[一个简单的角色][14],可在特定目录中查找字节大于某个大小的文件。在 Tower 中这么做时,启用[回调][15]有额外的好处。想象一下,你的监控方案发现文件系统已超过 X% 并触发 Tower 中的任务以找出是什么文件导致的。 + +![Managing disk space][16] + +### 调试系统性能问题 + +[这个角色][17]相当简单:它运行一些命令并打印输出。细节在最后输出,让你 —— 系统管理员快速浏览一眼。另外可以使用 [正则表达式][18] 在输出中找到某些条件(比如说 CPU 占用率超过 80%)。 + +![Debugging system performance][19] + +### 总结 + +我已经录制了这五个任务的简短视频。你也可以在 Github 上找到[所有代码][20]! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/ops-tasks-ansible + +作者:[Mark Phillips][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/markphttps://opensource.com/users/adminhttps://opensource.com/users/alsweigarthttps://opensource.com/users/belljennifer43 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/innovation_lightbulb_gears_devops_ansible.png?itok=TSbmp3_M (gears and lightbulb to represent innovation) +[2]: https://opensource.com/sites/default/files/uploads/00_templates.png (Job templates) +[3]: https://www.ansible.com/products/tower +[4]: https://github.com/ansible/awx +[5]: https://galaxy.ansible.com +[6]: https://galaxy.ansible.com/singleplatform-eng/users +[7]: https://opensource.com/sites/default/files/uploads/01_users_data.png (User data) +[8]: https://docs.ansible.com/ansible/latest/plugins/become.html +[9]: https://www.sudo.ws/intro.html +[10]: https://github.com/phips/ansible-demos/tree/master/roles/sudo +[11]: https://opensource.com/sites/default/files/uploads/02_sudo.png (Managing sudo) +[12]: https://docs.ansible.com/ansible-tower/latest/html/userguide/job_templates.html#surveys +[13]: https://opensource.com/sites/default/files/uploads/03_services.png (Managing services) +[14]: https://github.com/phips/ansible-demos/tree/master/roles/disk +[15]: https://docs.ansible.com/ansible-tower/latest/html/userguide/job_templates.html#provisioning-callbacks +[16]: https://opensource.com/sites/default/files/uploads/04_diskspace.png (Managing disk space) +[17]: https://github.com/phips/ansible-demos/tree/master/roles/gather_debug +[18]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#regular-expression-filters +[19]: https://opensource.com/sites/default/files/uploads/05_debug.png (Debugging system performance) +[20]: https://github.com/phips/ansible-demos diff --git a/published/20190826 How to rename a group of files on Linux.md b/published/20190826 How to rename a group of files on Linux.md new file mode 100644 index 0000000000..e80d1bc31d --- /dev/null +++ b/published/20190826 How to rename a group of files on Linux.md @@ -0,0 +1,128 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11300-1.html) +[#]: subject: (How to rename a group of files on Linux) +[#]: via: (https://www.networkworld.com/article/3433865/how-to-rename-a-group-of-files-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如何在 Linux 上重命名一组文件 +====== + +> 要用单个命令重命名一组文件,请使用 rename 命令。它需要使用正则表达式,并且可以在开始前告诉你会有什么更改。 + +![](https://img.linux.net.cn/data/attachment/album/201909/03/005333hfm8yf90m2gm800g.jpg) + +几十年来,Linux 用户一直使用 `mv` 命令重命名文件。它很简单,并且能做到你要做的。但有时你需要重命名一大组文件。在这种情况下,`rename` 命令可以使这个任务更容易。它只需要一些正则表达式的技巧。 + +与 `mv` 命令不同,`rename` 不允许你简单地指定旧名称和新名称。相反,它使用类似于 Perl 中的正则表达式。在下面的例子中,`s` 指定我们将第一个字符串替换为第二个字符串(旧的),从而将 `this.new` 变为 `this.old`。 + +``` +$ rename 's/new/old/' this.new +$ ls this* +this.old +``` + +使用 `mv this.new this.old` 可以更容易地进行更改一个,但是将字符串 `this` 变成通配符 `*`,你可以用一条命令将所有的 `*.new` 文件重命名为 `*.old`: + +``` +$ ls *.new +report.new schedule.new stats.new this.new +$ rename 's/new/old/' *.new +$ ls *.old +report.old schedule.old stats.old this.old +``` + +正如你所料,`rename` 命令不限于更改文件扩展名。如果你需要将名为 `report.*` 的文件更改为 `review.*`,那么可以使用以下命令做到: + +``` +$ rename 's/report/review/' * +``` + +正则表达式中的字符串可以更改文件名的任何部分,无论是文件名还是扩展名。 + +``` +$ rename 's/123/124/' * +$ ls *124* +status.124 report124.txt +``` + +如果你在 `rename` 命令中添加 `-v` 选项,那么该命令将提供一些反馈,以便你可以看到所做的更改,或许会包含你没注意的。这让你注意到并按需还原更改。 + +``` +$ rename -v 's/123/124/' * +status.123 renamed as status.124 +report123.txt renamed as report124.txt +``` + +另一方面,使用 `-n`(或 `--nono`)选项会使 `rename` 命令告诉你将要做的但不会实际做的更改。这可以让你免于执行不不想要的操作,然后再还原更改。 + +``` +$ rename -n 's/old/save/' * +rename(logger.man-old, logger.man-save) +rename(lyrics.txt-old, lyrics.txt-save) +rename(olderfile-, saveerfile-) +rename(oldfile, savefile) +rename(review.old, review.save) +rename(schedule.old, schedule.save) +rename(stats.old, stats.save) +rename(this.old, this.save) +``` + +如果你对这些更改满意,那么就可以运行不带 `-n` 选项的命令来更改文件名。 + +但请注意,正则表达式中的 `.` **不会**被视为句点,而是作为匹配任何字符的通配符。上面和下面的示例中的一些更改可能不是输入命令的人希望的。 + +``` +$ rename -n 's/.old/.save/' * +rename(logger.man-old, logger.man.save) +rename(lyrics.txt-old, lyrics.txt.save) +rename(review.old, review.save) +rename(schedule.old, schedule.save) +rename(stats.old, stats.save) +rename(this.old, this.save) +``` + +为确保句点按照字面意思执行,请在它的前面加一个反斜杠。这将使其不被解释为通配符并匹配任何字符。请注意,进行此更改时,仅选择了 `.old` 文件。 + +``` +$ rename -n 's/\.old/.save/' * +rename(review.old, review.save) +rename(schedule.old, schedule.save) +rename(stats.old, stats.save) +rename(this.old, this.save) +``` + +下面的命令会将文件名中的所有大写字母更改为小写,除了使用 `-n` 选项来确保我们在命令执行之前检查将做的修改。注意在正则表达式中使用了 `y`,这是改变大小写所必需的。 + +``` +$ rename -n 'y/A-Z/a-z/' W* +rename(WARNING_SIGN.pdf, warning_sign.pdf) +rename(Will_Gardner_buttons.pdf, will_gardner_buttons.pdf) +rename(Wingding_Invites.pdf, wingding_invites.pdf) +rename(WOW-buttons.pdf, wow-buttons.pdf) +``` + +在上面的例子中,我们将所有大写字母更改为了小写,但这仅对以大写字母 `W` 开头的文件名。 + +### 总结 + +当你需要重命名大量文件时,`rename` 命令非常有用。请注意不要做比预期更多的更改。请记住,`-n`(或者 `--nono`)选项可以帮助你避免耗时的错误。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3433865/how-to-rename-a-group-of-files-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/08/card-catalog-machester_city_library-100809242-large.jpg +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/20190828 Managing Ansible environments on MacOS with Conda.md b/published/20190828 Managing Ansible environments on MacOS with Conda.md new file mode 100644 index 0000000000..24e8d65fa0 --- /dev/null +++ b/published/20190828 Managing Ansible environments on MacOS with Conda.md @@ -0,0 +1,168 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11356-1.html) +[#]: subject: (Managing Ansible environments on MacOS with Conda) +[#]: via: (https://opensource.com/article/19/8/using-conda-ansible-administration-macos) +[#]: author: (James Farrell https://opensource.com/users/jamesf) + + +使用 Conda 管理 MacOS 上的 Ansible 环境 +===== + +> Conda 将 Ansible 所需的一切都收集到虚拟环境中并将其与其他项目分开。 + +![](https://img.linux.net.cn/data/attachment/album/201909/18/123838m1bcmke570kl6kzm.jpg) + +如果你是一名使用 MacOS 并涉及到 Ansible 管理的 Python 开发人员,你可能希望使用 Conda 包管理器将 Ansible 的工作内容与核心操作系统和其他本地项目分开。 + +Ansible 基于 Python。要让 Ansible 在 MacOS 上工作,Conda 并不是必须要的,但是它确实让你管理 Python 版本和包依赖变得更加容易。这允许你在 MacOS 上使用升级的 Python 版本,并在你的系统中、Ansible 和其他编程项目之间保持 Python 包的依赖性相互独立。 + +在 MacOS 上安装 Ansible 还有其他方法。你可以使用 [Homebrew][2],但是如果你对 Python 开发(或 Ansible 开发)感兴趣,你可能会发现在一个独立 Python 虚拟环境中管理 Ansible 可以减少一些混乱。我觉得这更简单;与其试图将 Python 版本和依赖项加载到系统或 `/usr/local` 目录中 ,还不如使用 Conda 帮助我将 Ansible 所需的一切都收集到一个虚拟环境中,并将其与其他项目完全分开。 + +本文着重于使用 Conda 作为 Python 项目来管理 Ansible,以保持它的干净并与其他项目分开。请继续阅读,并了解如何安装 Conda、创建新的虚拟环境、安装 Ansible 并对其进行测试。 + +### 序幕 + +最近,我想学习 [Ansible][3],所以我需要找到安装它的最佳方法。 + +我通常对在我的日常工作站上安装东西很谨慎。我尤其不喜欢对供应商的默认操作系统安装应用手动更新(这是我多年作为 Unix 系统管理的习惯)。我真的很想使用 Python 3.7,但是 MacOS 的 Python 包是旧的 2.7,我不会安装任何可能干扰核心 MacOS 系统的全局 Python 包。 + +所以,我使用本地 Ubuntu 18.04 虚拟机上开始了我的 Ansible 工作。这提供了真正意义上的的安全隔离,但我很快发现管理它是非常乏味的。所以我着手研究如何在本机 MacOS 上获得一个灵活但独立的 Ansible 系统。 + +由于 Ansible 基于 Python,Conda 似乎是理想的解决方案。 + +### 安装 Conda + +Conda 是一个开源软件,它提供方便的包和环境管理功能。它可以帮助你管理多个版本的 Python、安装软件包依赖关系、执行升级和维护项目隔离。如果你手动管理 Python 虚拟环境,Conda 将有助于简化和管理你的工作。浏览 [Conda 文档][4]可以了解更多细节。 + +我选择了 [Miniconda][5] Python 3.7 安装在我的工作站中,因为我想要最新的 Python 版本。无论选择哪个版本,你都可以使用其他版本的 Python 安装新的虚拟环境。 + +要安装 Conda,请下载 PKG 格式的文件,进行通常的双击,并选择 “Install for me only” 选项。安装在我的系统上占用了大约 158 兆的空间。 + +安装完成后,调出一个终端来查看你有什么了。你应该看到: + + * 在你的家目录中的 `miniconda3` 目录 + * shell 提示符被修改为 `(base)` + * `.bash_profile` 文件更新了一些 Conda 特有的设置内容 + +现在基础已经安装好了,你有了第一个 Python 虚拟环境。运行 Python 版本检查可以证明这一点,你的 `PATH` 将指向新的位置: + +``` +(base) $ which python +/Users/jfarrell/miniconda3/bin/python +(base) $ python --version +Python 3.7.1 +``` + +现在安装了 Conda,下一步是建立一个虚拟环境,然后安装 Ansible 并运行。 + +### 为 Ansible 创建虚拟环境 + +我想将 Ansible 与我的其他 Python 项目分开,所以我创建了一个新的虚拟环境并切换到它: + +``` +(base) $ conda create --name ansible-env --clone base +(base) $ conda activate ansible-env +(ansible-env) $ conda env list +``` + +第一个命令将 Conda 库克隆到一个名为 `ansible-env` 的新虚拟环境中。克隆引入了 Python 3.7 版本和一系列默认的 Python 模块,你可以根据需要添加、删除或升级这些模块。 + +第二个命令将 shell 上下文更改为这个新的环境。它为 Python 及其包含的模块设置了正确的路径。请注意,在 `conda activate ansible-env` 命令后,你的 shell 提示符会发生变化。 + +第三个命令不是必须的;它列出了安装了哪些 Python 模块及其版本和其他数据。 + +你可以随时使用 Conda 的 `activate` 命令切换到另一个虚拟环境。这将带你回到基本环境:`conda base`。 + +### 安装 Ansible + +安装 Ansible 有多种方法,但是使用 Conda 可以将 Ansible 版本和所有需要的依赖项打包在一个地方。Conda 提供了灵活性,既可以将所有内容分开,又可以根据需要添加其他新环境(我将在后面演示)。 + +要安装 Ansible 的相对较新版本,请使用: + +``` +(base) $ conda activate ansible-env +(ansible-env) $ conda install -c conda-forge ansible +``` + +由于 Ansible 不是 Conda 默认通道的一部分,因此 `-c` 用于从备用通道搜索和安装。Ansible 现已安装到 `ansible-env` 虚拟环境中,可以使用了。 + +### 使用 Ansible + +既然你已经安装了 Conda 虚拟环境,就可以使用它了。首先,确保要控制的节点已将工作站的 SSH 密钥安装到正确的用户帐户。 + +调出一个新的 shell 并运行一些基本的 Ansible 命令: + +``` +(base) $ conda activate ansible-env +(ansible-env) $ ansible --version +ansible 2.8.1 + config file = None + configured module search path = ['/Users/jfarrell/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] + ansible python module location = /Users/jfarrell/miniconda3/envs/ansibleTest/lib/python3.7/site-packages/ansible + executable location = /Users/jfarrell/miniconda3/envs/ansibleTest/bin/ansible + python version = 3.7.1 (default, Dec 14 2018, 13:28:58) [Clang 4.0.1 (tags/RELEASE_401/final)] +(ansible-env) $ ansible all -m ping -u ansible +192.168.99.200 | SUCCESS => { + "ansible_facts": { + "discovered_interpreter_python": "/usr/bin/python" + }, + "changed": false, + "ping": "pong" +} +``` + +现在 Ansible 工作了,你可以在控制台中抽身,并从你的 MacOS 工作站中使用它们。 + +### 克隆新的 Ansible 进行 Ansible 开发 + +这部分完全是可选的;只有当你想要额外的虚拟环境来修改 Ansible 或者安全地使用有问题的 Python 模块时,才需要它。你可以通过以下方式将主 Ansible 环境克隆到开发副本中: + +``` +(ansible-env) $ conda create --name ansible-dev --clone ansible-env +(ansible-env) $ conda activte ansible-dev +(ansible-dev) $ +``` + +### 需要注意的问题 + +偶尔你可能遇到使用 Conda 的麻烦。你通常可以通过以下方式删除不良环境: + +``` +$ conda activate base +$ conda remove --name ansible-dev --all +``` + +如果出现无法解决的错误,通常可以通过在 `~/miniconda3/envs` 中找到该环境并删除整个目录来直接删除环境。如果基础环境损坏了,你可以删除整个 `~/miniconda3`,然后从 PKG 文件中重新安装。只要确保保留 `~/miniconda3/envs` ,或使用 Conda 工具导出环境配置并在以后重新创建即可。 + +MacOS 上不包括 `sshpass` 程序。只有当你的 Ansible 工作要求你向 Ansible 提供 SSH 登录密码时,才需要它。你可以在 SourceForge 上找到当前的 [sshpass 源代码][6]。 + +最后,基础的 Conda Python 模块列表可能缺少你工作所需的一些 Python 模块。如果你需要安装一个模块,首选命令是 `conda install package`,但是需要的话也可以使用 `pip`,Conda 会识别安装的模块。 + +### 结论 + +Ansible 是一个强大的自动化工具,值得我们去学习。Conda 是一个简单有效的 Python 虚拟环境管理工具。 + +在你的 MacOS 环境中保持软件安装分离是保持日常工作环境的稳定性和健全性的谨慎方法。Conda 尤其有助于升级你的 Python 版本,将 Ansible 从其他项目中分离出来,并安全地使用 Ansible。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/using-conda-ansible-administration-macos + +作者:[James Farrell][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jamesf +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cicd_continuous_delivery_deployment_gears.png?itok=kVlhiEkc (CICD with gears) +[2]: https://brew.sh/ +[3]: https://docs.ansible.com/?extIdCarryOver=true&sc_cid=701f2000001OH6uAAG +[4]: https://conda.io/projects/conda/en/latest/index.html +[5]: https://docs.conda.io/en/latest/miniconda.html +[6]: https://sourceforge.net/projects/sshpass/ diff --git a/published/20190829 Getting started with HTTPie for API testing.md b/published/20190829 Getting started with HTTPie for API testing.md new file mode 100644 index 0000000000..c85c165df5 --- /dev/null +++ b/published/20190829 Getting started with HTTPie for API testing.md @@ -0,0 +1,334 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11333-1.html) +[#]: subject: (Getting started with HTTPie for API testing) +[#]: via: (https://opensource.com/article/19/8/getting-started-httpie) +[#]: author: (Moshe Zadka https://opensource.com/users/moshezhttps://opensource.com/users/mkalindepauleduhttps://opensource.com/users/jamesf) + +使用 HTTPie 进行 API 测试 +====== + +> 使用 HTTPie 调试 API,这是一个用 Python 写的易用的命令行工具。 + +![](https://img.linux.net.cn/data/attachment/album/201909/12/102919ry1ute1y9h991ftz.jpg) + +[HTTPie][2] 是一个非常易用、易于升级的 HTTP 客户端。它的发音为 “aitch-tee-tee-pie” 并以 `http` 命令运行,它是一个用 Python 编写的来用于访问 Web 的命令行工具。 + +由于这是一篇关于 HTTP 客户端的指导文章,因此你需要一个 HTTP 服务器来试用它。在这里,访问 [httpbin.org][3],它是一个简单的开源 HTTP 请求和响应服务。httpbin.org 网站是一种测试 Web API 的强大方式,并能仔细管理并显示请求和响应内容,不过现在让我们专注于 HTTPie 的强大功能。 + +### Wget 和 cURL 的替代品 + +你可能听说过古老的 [Wget][4] 或稍微新一些的 [cURL][5] 工具,它们允许你从命令行访问 Web。它们是为访问网站而编写的,而 HTTPie 则用于访问 Web API。 + +网站请求发生在计算机和正在阅读并响应它所看到的内容的最终用户之间,这并不太依赖于结构化的响应。但是,API 请求会在两台计算机之间进行*结构化*调用,人并不是该流程内的一部分,像 HTTPie 这样的命令行工具的参数可以有效地处理这个问题。 + +### 安装 HTTPie + +有几种方法可以安装 HTTPie。你可以通过包管理器安装,无论你使用的是 `brew`、`apt`、`yum` 还是 `dnf`。但是,如果你已配置 [virtualenvwrapper][6],那么你可以用自己的方式安装: + + +``` +$ mkvirtualenv httpie +... +(httpie) $ pip install httpie +... +(httpie) $ deactivate +$ alias http=~/.virtualenvs/httpie/bin/http +$ http -b GET https://httpbin.org/get +{ + "args": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Host": "httpbin.org", + "User-Agent": "HTTPie/1.0.2" + }, + "origin": "104.220.242.210, 104.220.242.210", + "url": "https://httpbin.org/get" +} +``` + +通过将 `http` 别名指向为虚拟环境中的命令,即使虚拟环境在非活动状态,你也可以运行它。你可以将 `alias` 命令放在 `.bash_profile` 或 `.bashrc` 中,这样你就可以使用以下命令升级 HTTPie: + + +``` +$ ~/.virtualenvs/httpie/bin/pip install -U pip +``` + +### 使用 HTTPie 查询网站 + +HTTPie 可以简化查询和测试 API。上面使用了一个选项,`-b`(即 `--body`)。没有它,HTTPie 将默认打印整个响应,包括响应头: + +``` +$ http GET https://httpbin.org/get +HTTP/1.1 200 OK +Access-Control-Allow-Credentials: true +Access-Control-Allow-Origin: * +Connection: keep-alive +Content-Encoding: gzip +Content-Length: 177 +Content-Type: application/json +Date: Fri, 09 Aug 2019 20:19:47 GMT +Referrer-Policy: no-referrer-when-downgrade +Server: nginx +X-Content-Type-Options: nosniff +X-Frame-Options: DENY +X-XSS-Protection: 1; mode=block + +{ + "args": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Host": "httpbin.org", + "User-Agent": "HTTPie/1.0.2" + }, + "origin": "104.220.242.210, 104.220.242.210", + "url": "https://httpbin.org/get" +} +``` + +这在调试 API 服务时非常重要,因为大量信息在响应头中发送。例如,查看发送的 cookie 通常很重要。httpbin.org 提供了通过 URL 路径设置 cookie(用于测试目的)的方式。以下设置一个标题为 `opensource`, 值为 `awesome` 的 cookie: + +``` +$ http GET https://httpbin.org/cookies/set/opensource/awesome +HTTP/1.1 302 FOUND +Access-Control-Allow-Credentials: true +Access-Control-Allow-Origin: * +Connection: keep-alive +Content-Length: 223 +Content-Type: text/html; charset=utf-8 +Date: Fri, 09 Aug 2019 20:22:39 GMT +Location: /cookies +Referrer-Policy: no-referrer-when-downgrade +Server: nginx +Set-Cookie: opensource=awesome; Path=/ +X-Content-Type-Options: nosniff +X-Frame-Options: DENY +X-XSS-Protection: 1; mode=block + + +Redirecting... +

Redirecting...

+

You should be redirected automatically to target URL: +/cookies. If not click the link. +``` + +注意 `Set-Cookie: opensource=awesome; Path=/` 的响应头。这表明你预期设置的 cookie 已正确设置,路径为 `/`。另请注意,即使你得到了 `302` 重定向,`http` 也不会遵循它。如果你想要遵循重定向,则需要明确使用 `--follow` 标志请求: + +``` +$ http --follow GET https://httpbin.org/cookies/set/opensource/awesome +HTTP/1.1 200 OK +Access-Control-Allow-Credentials: true +Access-Control-Allow-Origin: * +Connection: keep-alive +Content-Encoding: gzip +Content-Length: 66 +Content-Type: application/json +Date: Sat, 10 Aug 2019 01:33:34 GMT +Referrer-Policy: no-referrer-when-downgrade +Server: nginx +X-Content-Type-Options: nosniff +X-Frame-Options: DENY +X-XSS-Protection: 1; mode=block + +{ + "cookies": { + "opensource": "awesome" + } +} +``` + +但此时你无法看到原来的 `Set-Cookie` 头。为了看到中间响应,你需要使用 `--all`: + + +``` +$ http --headers --all --follow GET https://httpbin.org/cookies/set/opensource/awesome +HTTP/1.1 302 FOUND +Access-Control-Allow-Credentials: true +Access-Control-Allow-Origin: * +Content-Type: text/html; charset=utf-8 +Date: Sat, 10 Aug 2019 01:38:40 GMT +Location: /cookies +Referrer-Policy: no-referrer-when-downgrade +Server: nginx +Set-Cookie: opensource=awesome; Path=/ +X-Content-Type-Options: nosniff +X-Frame-Options: DENY +X-XSS-Protection: 1; mode=block +Content-Length: 223 +Connection: keep-alive + +HTTP/1.1 200 OK +Access-Control-Allow-Credentials: true +Access-Control-Allow-Origin: * +Content-Encoding: gzip +Content-Type: application/json +Date: Sat, 10 Aug 2019 01:38:41 GMT +Referrer-Policy: no-referrer-when-downgrade +Server: nginx +X-Content-Type-Options: nosniff +X-Frame-Options: DENY +X-XSS-Protection: 1; mode=block +Content-Length: 66 +Connection: keep-alive +``` + +打印响应体并不有趣,因为你大多数时候只关心 cookie。如果你想看到中间请求的响应头,而不是最终请求中的响应体,你可以使用: + +``` +$ http --print hb --history-print h --all --follow GET https://httpbin.org/cookies/set/opensource/awesome +HTTP/1.1 302 FOUND +Access-Control-Allow-Credentials: true +Access-Control-Allow-Origin: * +Content-Type: text/html; charset=utf-8 +Date: Sat, 10 Aug 2019 01:40:56 GMT +Location: /cookies +Referrer-Policy: no-referrer-when-downgrade +Server: nginx +Set-Cookie: opensource=awesome; Path=/ +X-Content-Type-Options: nosniff +X-Frame-Options: DENY +X-XSS-Protection: 1; mode=block +Content-Length: 223 +Connection: keep-alive + +HTTP/1.1 200 OK +Access-Control-Allow-Credentials: true +Access-Control-Allow-Origin: * +Content-Encoding: gzip +Content-Type: application/json +Date: Sat, 10 Aug 2019 01:40:56 GMT +Referrer-Policy: no-referrer-when-downgrade +Server: nginx +X-Content-Type-Options: nosniff +X-Frame-Options: DENY +X-XSS-Protection: 1; mode=block +Content-Length: 66 +Connection: keep-alive + +{ + "cookies": { + "opensource": "awesome" + } +} +``` + +你可以使用 `--print` 精确控制打印的内容(`h`:响应头;`b`:响应体),并使用 `--history-print` 覆盖中间请求的打印内容设置。 + +### 使用 HTTPie 下载二进制文件 + +有时响应体并不是文本形式,它需要发送到可被不同应用打开的文件: + +``` +$ http GET https://httpbin.org/image/jpeg +HTTP/1.1 200 OK +Access-Control-Allow-Credentials: true +Access-Control-Allow-Origin: * +Connection: keep-alive +Content-Length: 35588 +Content-Type: image/jpeg +Date: Fri, 09 Aug 2019 20:25:49 GMT +Referrer-Policy: no-referrer-when-downgrade +Server: nginx +X-Content-Type-Options: nosniff +X-Frame-Options: DENY +X-XSS-Protection: 1; mode=block + + ++-----------------------------------------+ +| NOTE: binary data not shown in terminal | ++-----------------------------------------+ +``` + +要得到正确的图片,你需要保存到文件: + +``` +$ http --download GET https://httpbin.org/image/jpeg +HTTP/1.1 200 OK +Access-Control-Allow-Credentials: true +Access-Control-Allow-Origin: * +Connection: keep-alive +Content-Length: 35588 +Content-Type: image/jpeg +Date: Fri, 09 Aug 2019 20:28:13 GMT +Referrer-Policy: no-referrer-when-downgrade +Server: nginx +X-Content-Type-Options: nosniff +X-Frame-Options: DENY +X-XSS-Protection: 1; mode=block + +Downloading 34.75 kB to "jpeg.jpe" +Done. 34.75 kB in 0.00068s (50.05 MB/s) +``` + +试一下!图片很可爱。 + +### 使用 HTTPie 发送自定义请求 + +你可以发送指定的请求头。这对于需要非标准头的自定义 Web API 很有用: + +``` +$ http GET https://httpbin.org/headers X-Open-Source-Com:Awesome +{ + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Host": "httpbin.org", + "User-Agent": "HTTPie/1.0.2", + "X-Open-Source-Com": "Awesome" + } +} +``` + +最后,如果要发送 JSON 字段(尽管可以指定确切的内容),对于许多嵌套较少的输入,你可以使用快捷方式: + + +``` +$ http --body PUT https://httpbin.org/anything open-source=awesome author=moshez +{ + "args": {}, + "data": "{\"open-source\": \"awesome\", \"author\": \"moshez\"}", + "files": {}, + "form": {}, + "headers": { + "Accept": "application/json, */*", + "Accept-Encoding": "gzip, deflate", + "Content-Length": "46", + "Content-Type": "application/json", + "Host": "httpbin.org", + "User-Agent": "HTTPie/1.0.2" + }, + "json": { + "author": "moshez", + "open-source": "awesome" + }, + "method": "PUT", + "origin": "73.162.254.113, 73.162.254.113", + "url": "https://httpbin.org/anything" +} +``` + +下次在调试 Web API 时,无论是你自己的还是别人的,记得放下 cURL,试试 HTTPie 这个命令行工具。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/getting-started-httpie + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshezhttps://opensource.com/users/mkalindepauleduhttps://opensource.com/users/jamesf +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/pie-raspberry-bake-make-food.png?itok=QRV_R8Fa (Raspberry pie with slice missing) +[2]: https://httpie.org/ +[3]: https://github.com/postmanlabs/httpbin +[4]: https://en.wikipedia.org/wiki/Wget +[5]: https://en.wikipedia.org/wiki/CURL +[6]: https://opensource.com/article/19/6/virtual-environments-python-macos diff --git a/published/20190829 Three Ways to Exclude Specific-Certain Packages from Yum Update.md b/published/20190829 Three Ways to Exclude Specific-Certain Packages from Yum Update.md new file mode 100644 index 0000000000..f0d1ba9087 --- /dev/null +++ b/published/20190829 Three Ways to Exclude Specific-Certain Packages from Yum Update.md @@ -0,0 +1,138 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11315-1.html) +[#]: subject: (Three Ways to Exclude Specific/Certain Packages from Yum Update) +[#]: via: (https://www.2daygeek.com/redhat-centos-yum-update-exclude-specific-packages/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +从 Yum 更新中排除特定/某些包的三种方法 +====== + +![](https://img.linux.net.cn/data/attachment/album/201909/07/145817rj7khqkbqwqx7sb9.jpg) + +作为系统更新的一部分,你也许需要在基于 Red Hat 系统中由于应用依赖排除一些软件包。 + +如果是,如何排除?可以采取多少种方式?有三种方式可以做到,我们会在本篇中教你这三种方法。 + +包管理器是一组工具,它允许用户在 Linux 系统中轻松管理包。它能让用户在 Linux 系统中安装、更新/升级、删除、查询、重新安装和搜索软件包。 + +对于基于 Red Hat 的系统,我们使用 [yum 包管理器][1] 和 [rpm 包管理器][2] 进行包管理。 + +### 什么是 yum? + +yum 代表 “Yellowdog Updater, Modified”。Yum 是用于 rpm 系统的自动更新程序和包安装/卸载器。 + +它在安装包时自动解决依赖关系。 + +### 什么是 rpm? + +rpm 代表 “Red Hat Package Manager”,它是一款用于 Red Hat 系统的功能强大的包管理工具。 + +RPM 指的是 `.rpm` 文件格式,它包含已编译的软件和必要的库。 + +你可能有兴趣阅读以下与本主题相关的文章。如果是的话,请进入相应的链接。 + + * [如何检查 Red Hat(RHEL)和 CentOS 系统上的可用安全更新][3] + * [在 Red Hat(RHEL)和 CentOS 系统上安装安全更新的四种方法][4] + * [在 Redhat(RHEL)和 CentOS 系统上检查或列出已安装的安全更新的两种方法][5] + +### 方法 1:手动或临时用 yum 命令排除包 + +我们可以在 yum 中使用 `--exclude` 或 `-x` 开关来阻止 yum 命令获取特定包的更新。 + +我可以说,这是一种临时方法或按需方法。如果你只想将特定包排除一次,那么我们可以使用此方法。 + +以下命令将更新除 kernel 之外的所有软件包。 + +要排除单个包: + +``` +# yum update --exclude=kernel +或者 +# yum update -x 'kernel' +``` + +要排除多个包。以下命令将更新除 kernel 和 php 之外的所有软件包。 + +``` +# yum update --exclude=kernel* --exclude=php* +或者 +# yum update --exclude httpd,php +``` + +### 方法 2:在 yum 命令中永久排除软件包 + +这是永久性方法,如果你经常执行修补程序更新,那么可以使用此方法。 + +为此,请在 `/etc/yum.conf` 中添加相应的软件包以永久禁用软件包更新。 + +添加后,每次运行 `yum update` 命令时都不需要指定这些包。此外,这可以防止任何意外更新这些包。 + +``` +# vi /etc/yum.conf + +[main] +cachedir=/var/cache/yum/$basearch/$releasever +keepcache=0 +debuglevel=2 +logfile=/var/log/yum.log +exactarch=1 +obsoletes=1 +gpgcheck=1 +plugins=1 +installonly_limit=3 +exclude=kernel* php* +``` + +### 方法 3:使用 Yum versionlock 插件排除包 + +这也是与上面类似的永久方法。Yum versionlock 插件允许用户通过 `yum` 命令锁定指定包的更新。 + +为此,请运行以下命令。以下命令将从 `yum update` 中排除 freetype 包。 + +或者,你可以直接在 `/etc/yum/pluginconf.d/versionlock.list` 中添加条目。 + +``` +# yum versionlock add freetype + +Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock +Adding versionlock on: 0:freetype-2.8-12.el7 +versionlock added: 1 +``` + +运行以下命令来检查被 versionlock 插件锁定的软件包列表。 + +``` +# yum versionlock list + +Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock +0:freetype-2.8-12.el7.* +versionlock list done +``` + +运行以下命令清空该列表。 + +``` +# yum versionlock clear +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/redhat-centos-yum-update-exclude-specific-packages/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ +[2]: https://www.2daygeek.com/rpm-command-examples/ +[3]: https://www.2daygeek.com/check-list-view-find-available-security-updates-on-redhat-rhel-centos-system/ +[4]: https://www.2daygeek.com/install-security-updates-on-redhat-rhel-centos-system/ +[5]: https://www.2daygeek.com/check-installed-security-updates-on-redhat-rhel-and-centos-system/ diff --git a/published/20190830 Change your Linux terminal color theme.md b/published/20190830 Change your Linux terminal color theme.md new file mode 100644 index 0000000000..321dc40997 --- /dev/null +++ b/published/20190830 Change your Linux terminal color theme.md @@ -0,0 +1,86 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11310-1.html) +[#]: subject: (Change your Linux terminal color theme) +[#]: via: (https://opensource.com/article/19/8/add-color-linux-terminal) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何更改 Linux 终端颜色主题 +====== + +> 你可以用丰富的选项来定义你的终端主题。 + +![](https://img.linux.net.cn/data/attachment/album/201909/06/070600ztd434ppd99df99d.jpg) + +如果你大部分时间都盯着终端,那么你很自然地希望它看起来能赏心悦目。美与不美,全在观者,自 CRT 串口控制台以来,终端已经经历了很多变迁。因此,你的软件终端窗口有丰富的选项,可以用来定义你看到的主题,不管你如何定义美,这总是件好事。 + +### 设置 + +包括 GNOME、KDE 和 Xfce 在内的流行的软件终端应用,它们都提供了更改其颜色主题的选项。调整主题就像调整应用首选项一样简单。Fedora、RHEL 和 Ubuntu 默认使用 GNOME,因此本文使用该终端作为示例,但对 Konsole、Xfce 终端和许多其他终端的设置流程类似。 + +首先,进入到应用的“首选项”或“设置”面板。在 GNOME 终端中,你可以通过屏幕顶部或窗口右上角的“应用”菜单访问它。 + +在“首选项”中,单击“配置文件” 旁边的加号(“+”)来创建新的主题配置文件。在新配置文件中,单击“颜色”选项卡。 + +![GNOME Terminal preferences][2] + +在“颜色”选项卡中,取消选择“使用系统主题中的颜色”选项,以使窗口的其余部分变为可选状态。最开始,你可以选择内置的颜色方案。这些包括浅色主题,它有明亮的背景和深色的前景文字;还有深色主题,它有深色背景和浅色前景文字。 + +当没有其他设置(例如 `dircolors` 命令的设置)覆盖它们时,“默认颜色”色板将同时定义前景色和背景色。“调色板”设置 `dircolors` 命令定义的颜色。这些颜色由终端以 `LS_COLORS` 环境变量的形式使用,以在 [ls][3] 命令的输出中添加颜色。如果这些颜色不吸引你,请在此更改它们。 + +如果对主题感到满意,请关闭“首选项”窗口。 + +要将终端更改为新的配置文件,请单击“应用”菜单,然后选择“配置文件”。选择新的配置文件,接着享受自定义主题。 + +![GNOME Terminal profile selection][4] + +### 命令选项 + +如果你的终端没有合适的设置窗口,它仍然可以在启动命令中提供颜色选项。xterm 和 rxvt 终端(旧的和启用 Unicode 的变体,有时称为 urxvt 或 rxvt-unicode)都提供了这样的选项,因此即使没有桌面环境和大型 GUI 框架,你仍然可以设置终端模拟器的主题。 + +两个明显的选项是前景色和背景色,分别用 `-fg` 和 `-bg` 定义。每个选项的参数是*颜色名*而不是它的 ANSI 编号。例如: + +``` +$ urxvt -bg black -fg green +``` + +这些会设置默认的前景和背景。如果有任何其他规则会控制特定文件或设备类型的颜色,那么就使用这些颜色。有关如何设置它们的信息,请参阅 [dircolors][5] 命令。 + +你还可以使用 `-cr` 设置文本光标(而不是鼠标光标)的颜色: + +``` +$ urxvt -bg black -fg green -cr teal +``` + +![Setting color in urxvt][6] + +你的终端模拟器可能还有更多选项,如边框颜色(rxvt 中的 `-bd`)、光标闪烁(urxvt 中的 `-bc` 和 `+bc`),甚至背景透明度。请参阅终端的手册页,了解更多的功能。 + +要使用你选择的颜色启动终端,你可以将选项添加到用于启动终端的命令或菜单中(例如,在你的 Fluxbox 菜单文件、`$HOME/.local/share/applications` 目录中的 `.desktop` 或者类似的)。或者,你可以使用 [xrdb][7] 工具来管理与 X 相关的资源(但这超出了本文的范围)。 + +### 家是可定制的地方 + +自定义 Linux 机器并不意味着你需要学习如何编程。你可以而且应该进行小而有意义的更改,来使你的数字家庭感觉更舒适。而且没有比终端更好的起点了! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/add-color-linux-terminal + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/terminal_command_linux_desktop_code.jpg?itok=p5sQ6ODE (Terminal command prompt on orange background) +[2]: https://opensource.com/sites/default/files/uploads/gnome-terminal-preferences.jpg (GNOME Terminal preferences) +[3]: https://opensource.com/article/19/7/master-ls-command +[4]: https://opensource.com/sites/default/files/uploads/gnome-terminal-profile-select.jpg (GNOME Terminal profile selection) +[5]: http://man7.org/linux/man-pages/man1/dircolors.1.html +[6]: https://opensource.com/sites/default/files/uploads/urxvt-color.jpg (Setting color in urxvt) +[7]: https://www.x.org/releases/X11R7.7/doc/man/man1/xrdb.1.xhtml diff --git a/published/20190830 How to Create and Use Swap File on Linux.md b/published/20190830 How to Create and Use Swap File on Linux.md new file mode 100644 index 0000000000..d8db4b5623 --- /dev/null +++ b/published/20190830 How to Create and Use Swap File on Linux.md @@ -0,0 +1,254 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11341-1.html) +[#]: subject: (How to Create and Use Swap File on Linux) +[#]: via: (https://itsfoss.com/create-swap-file-linux/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Linux 上创建和使用交换文件 +====== + +本教程讨论了 Linux 中交换文件的概念,为什么使用它以及它相对于传统交换分区的优势。你将学习如何创建交换文件和调整其大小。 + +### 什么是 Linux 的交换文件? + +交换文件允许 Linux 将磁盘空间模拟为内存。当你的系统开始耗尽内存时,它会使用交换空间将内存的一些内容交换到磁盘空间上。这样释放了内存,为更重要的进程服务。当内存再次空闲时,它会从磁盘交换回数据。我建议[阅读这篇文章,了解 Linux 上的交换空间的更多内容][1]。 + +传统上,交换空间是磁盘上的一个独立分区。安装 Linux 时,只需创建一个单独的分区进行交换。但是这种趋势在最近几年发生了变化。 + +使用交换文件,你不再需要单独的分区。你会根目录下创建一个文件,并告诉你的系统将其用作交换空间就行了。 + +使用专用的交换分区,在许多情况下,调整交换空间的大小是一个可怕而不可能的任务。但是有了交换文件,你可以随意调整它们的大小。 + +最新版本的 Ubuntu 和其他一些 Linux 发行版已经开始 [默认使用交换文件][2]。甚至如果你没有创建交换分区,Ubuntu 也会自己创建一个 1GB 左右的交换文件。 + +让我们看看交换文件的更多信息。 + +![](https://img.linux.net.cn/data/attachment/album/201909/14/190637uggjgsjoogxg3vh0.jpg) + +### 检查 Linux 的交换空间 + +在你开始添加交换空间之前,最好检查一下你的系统中是否已经有了交换空间。 + +你可以用[Linux 上的 free 命令][4]检查它。就我而言,我的[戴尔 XPS][5]有 14GB 的交换容量。 + +``` +free -h + total used free shared buff/cache available +Mem: 7.5G 4.1G 267M 971M 3.1G 2.2G +Swap: 14G 0B 14G +``` + +`free` 命令给出了交换空间的大小,但它并没有告诉你它是真实的交换分区还是交换文件。`swapon` 命令在这方面会更好。 + +``` +swapon --show +NAME TYPE SIZE USED PRIO +/dev/nvme0n1p4 partition 14.9G 0B -2 +``` + +如你所见,我有 14.9GB 的交换空间,它在一个单独的分区上。如果是交换文件,类型应该是 `file` 而不是 `partition`。 + +``` +swapon --show +NAME TYPE SIZE USED PRIO +/swapfile file 2G 0B -2 +``` + +如果你的系统上没有交换空间,它应该显示如下内容: + +``` +free -h + total used free shared buff/cache available +Mem: 7.5G 4.1G 267M 971M 3.1G 2.2G +Swap: 0B 0B 0B +``` + +而 `swapon` 命令不会显示任何输出。 + + +### 在 Linux 上创建交换文件 + +如果你的系统没有交换空间,或者你认为交换空间不足,你可以在 Linux 上创建交换文件。你也可以创建多个交换文件。 + +让我们看看如何在 Linux 上创建交换文件。我在本教程中使用 Ubuntu 18.04,但它也应该适用于其他 Linux 发行版本。 + +#### 步骤 1:创建一个新的交换文件 + +首先,创建一个具有所需交换空间大小的文件。假设我想给我的系统增加 1GB 的交换空间。使用`fallocate` 命令创建大小为 1GB 的文件。 + +``` +sudo fallocate -l 1G /swapfile +``` + +建议只允许 `root` 用户读写该交换文件。当你尝试将此文件用于交换区域时,你甚至会看到类似“不安全权限 0644,建议 0600”的警告。 + +``` +sudo chmod 600 /swapfile +``` + +请注意,交换文件的名称可以是任意的。如果你需要多个交换空间,你可以给它任何合适的名称,如 `swap_file_1`、`swap_file_2` 等。它们只是一个预定义大小的文件。 + +#### 步骤 2:将新文件标记为交换空间 + +你需要告诉 Linux 系统该文件将被用作交换空间。你可以用 [mkswap][7] 工具做到这一点。 + +``` +sudo mkswap /swapfile +``` + +你应该会看到这样的输出: + +``` +Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes) +no label, UUID=7e1faacb-ea93-4c49-a53d-fb40f3ce016a +``` + +#### 步骤 3:启用交换文件 + +现在,你的系统知道文件 `swapfile` 可以用作交换空间。但是还没有完成。你需要启用该交换文件,以便系统可以开始使用该文件作为交换。 + +``` +sudo swapon /swapfile +``` + +现在,如果你检查交换空间,你应该会看到你的 Linux 系统会识别并使用它作为交换空间: + +``` +swapon --show +NAME TYPE SIZE USED PRIO +/swapfile file 1024M 0B -2 +``` + +#### 步骤 4:让改变持久化 + +迄今为止你所做的一切都是暂时的。重新启动系统,所有更改都将消失。 + +你可以通过将新创建的交换文件添加到 `/etc/fstab` 文件来使更改持久化。 + +对 `/etc/fstab` 文件进行任何更改之前,最好先进行备份。 + +``` +sudo cp /etc/fstab /etc/fstab.back +``` + +现在将以下行添加到 `/etc/fstab` 文件的末尾: + +``` +/swapfile none swap sw 0 0 +``` + +你可以使用[命令行文本编辑器][8]手动操作,或者使用以下命令: + +``` +echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab +``` + +现在一切都准备好了。即使在重新启动你的 Linux 系统后,你的交换文件也会被使用。 + +### 调整 swappiness 参数 + +`swappiness` 参数决定了交换空间的使用频率。`swappiness` 值的范围从 0 到 100。较高的值意味着交换空间将被更频繁地使用。 + +Ubuntu 桌面的默认的 `swappiness` 是 60,而服务器的默认 `swappiness` 是 1。你可以使用以下命令检查 `swappiness`: + +``` +cat /proc/sys/vm/swappiness +``` + +为什么服务器应该使用低的 `swappiness` 值?因为交换空间比内存慢,为了获得更好的性能,应该尽可能多地使用内存。在服务器上,性能因素至关重要,因此 `swappiness` 应该尽可能低。 + +你可以使用以下系统命令动态更改 `swappiness`: + +``` +sudo sysctl vm.swappiness=25 +``` + +这种改变只是暂时的。如果要使其永久化,可以编辑 `/etc/sysctl.conf` 文件,并在文件末尾添加`swappiness` 值: + +``` +vm.swappiness=25 +``` + +### 在 Linux 上调整交换空间的大小 + +在 Linux 上有几种方法可以调整交换空间的大小。但是在你看到这一点之前,你应该了解一些关于它的事情。 + +当你要求系统停止将交换文件用于交换空间时,它会将所有数据(确切地说是内存页)传输回内存。所以你应该有足够的空闲内存,然后再停止交换。 + +这就是为什么创建和启用另一个临时交换文件是一个好的做法的原因。这样,当你关闭原来的交换空间时,你的系统将使用临时交换文件。现在你可以调整原来的交换空间的大小。你可以手动删除临时交换文件或留在那里,下次启动时会自动删除(LCTT 译注:存疑?)。 + +如果你有足够的可用内存或者创建了临时交换空间,那就关闭你原来的交换文件。 + +``` +sudo swapoff /swapfile +``` + +现在你可以使用 `fallocate` 命令来更改文件的大小。比方说,你将其大小更改为 2GB: + +``` +sudo fallocate -l 2G /swapfile +``` + +现在再次将文件标记为交换空间: + +``` +sudo mkswap /swapfile +``` + +并再次启用交换文件: + +``` +sudo swapon /swapfile +``` + +你也可以选择同时拥有多个交换文件。 + +### 删除 Linux 中的交换文件 + +你可能有不在 Linux 上使用交换文件的原因。如果你想删除它,该过程类似于你刚才看到的调整交换大小的过程。 + +首先,确保你有足够的空闲内存。现在关闭交换文件: + +``` +sudo swapoff /swapfile +``` + +下一步是从 `/etc/fstab` 文件中删除相应的条目。 + +最后,你可以删除该文件来释放空间: + +``` +sudo rm /swapfile +``` + +### 你用了交换空间了吗? + +我想你现在已经很好地理解了 Linux 中的交换文件概念。现在,你可以根据需要轻松创建交换文件或调整它们的大小。 + +如果你对这个话题有什么要补充的或者有任何疑问,请在下面留下评论。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/create-swap-file-linux/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/swap-size/ +[2]: https://help.ubuntu.com/community/SwapFaq +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/08/swap-file-linux.png?resize=800%2C450&ssl=1 +[4]: https://linuxhandbook.com/free-command/ +[5]: https://itsfoss.com/dell-xps-13-ubuntu-review/ +[6]: https://itsfoss.com/fix-missing-system-settings-ubuntu-1404-quick-tip/ +[7]: http://man7.org/linux/man-pages/man8/mkswap.8.html +[8]: https://itsfoss.com/command-line-text-editors-linux/ +[9]: https://itsfoss.com/replace-linux-from-dual-boot/ diff --git a/published/20190830 git exercises- navigate a repository.md b/published/20190830 git exercises- navigate a repository.md new file mode 100644 index 0000000000..2c7899d172 --- /dev/null +++ b/published/20190830 git exercises- navigate a repository.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11379-1.html) +[#]: subject: (git exercises: navigate a repository) +[#]: via: (https://jvns.ca/blog/2019/08/30/git-exercises--navigate-a-repository/) +[#]: author: (Julia Evans https://jvns.ca/) + +Git 练习:存储库导航 +====== + +我觉得前几天的 [curl 练习][1]进展顺利,所以今天我醒来后,想尝试编写一些 Git 练习。Git 是一大块需要学习的技能,可能要花几个小时才能学会,所以我分解练习的第一个思路是从“导航”一个存储库开始的。 + +我本来打算使用一个玩具测试库,但后来我想,为什么不使用真正的存储库呢?这样更有趣!因此,我们将浏览 Ruby 编程语言的存储库。你无需了解任何 C 即可完成此练习,只需熟悉一下存储库中的文件随时间变化的方式即可。 + +### 克隆存储库 + +开始之前,需要克隆存储库: + +``` +git clone https://github.com/ruby/ruby +``` + +与实际使用的大多数存储库相比,该存储库的最大不同之处在于它没有分支,但是它有很多标签,它们与分支相似,因为它们都只是指向一个提交的指针而已。因此,我们将使用标签而不是分支进行练习。*改变*标签的方式和分支非常不同,但*查看*标签和分支的方式完全相同。 + +### Git SHA 总是引用同一个代码 + +执行这些练习时要记住的最重要的一点是,如本页面所述,像`9e3d9a2a009d2a0281802a84e1c5cc1c887edc71` 这样的 Git SHA 始终引用同一个的代码。下图摘自我与凯蒂·西勒·米勒撰写的一本杂志,名为《[Oh shit, git!][2]》。(她还有一个名为 的很棒的网站,启发了该杂志。) + +![](https://wizardzines.com/zines/oh-shit-git/samples/ohshit-commit.png) + +我们将在练习中大量使用 Git SHA,以使你习惯于使用它们,并帮助你了解它们与标签和分支的对应关系。 + +### 我们将要使用的 Git 子命令 + +所有这些练习仅使用这 5 个 Git 子命令: + +``` +git checkout +git log (--oneline, --author, and -S will be useful) +git diff (--stat will be useful) +git show +git status +``` + +### 练习 + +1. 查看 matz 从 1998 年开始的 Ruby 提交。提交 ID 为 ` 3db12e8b236ac8f88db8eb4690d10e4a3b8dbcd4`。找出当时 Ruby 的代码行数。 +2. 检出当前的 master 分支。 +3. 查看文件 `hash.c` 的历史记录。更改该文件的最后一个提交 ID 是什么? +4. 了解最近 20 年来 `hash.c` 的变化:将 master 分支上的文件与提交 `3db12e8b236ac8f88db8eb4690d10e4a3b8dbcd4` 的文件进行比较。 +5. 查找最近更改了 `hash.c` 的提交,并查看该提交的差异。 +6. 对于每个 Ruby 版本,该存储库都有一堆**标签**。获取所有标签的列表。 +7. 找出在标签 `v1_8_6_187` 和标签 `v1_8_6_188` 之间更改了多少文件。 +8. 查找 2015 年的提交(任何一个提交)并将其检出,简单地查看一下文件,然后返回 master 分支。 +9. 找出标签 `v1_8_6_187` 对应的提交。 +10. 列出目录 `.git/refs/tags`。运行 `cat .git/refs/tags/v1_8_6_187` 来查看其中一个文件的内容。 +11. 找出当前 `HEAD` 对应的提交 ID。 +12. 找出已经对 `test/` 目录进行了多少次提交。 +13. 提交 `65a5162550f58047974793cdc8067a970b2435c0` 和 `9e3d9a2a009d2a0281802a84e1c5cc1c887edc71` 之间的 `lib/telnet.rb` 的差异。该文件更改了几行? +14. 在 Ruby 2.5.1 和 2.5.2 之间进行了多少次提交(标记为 `v2_5_1` 和 `v2_5_3`)(这一步有点棘手,步骤不只一步) +15. “matz”(Ruby 的创建者)作了多少提交? +16. 最近包含 “tkutil” 一词的提交是什么? +17. 检出提交 `e51dca2596db9567bd4d698b18b4d300575d3881` 并创建一个指向该提交的新分支。 +18. 运行 `git reflog` 以查看你到目前为止完成的所有存储库导航操作。 +   +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/08/30/git-exercises--navigate-a-repository/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://jvns.ca/blog/2019/08/27/curl-exercises/ +[2]: https://wizardzines.com/zines/oh-shit-git/ diff --git a/published/20190831 Google opens Android speech transcription and gesture tracking, Twitter-s telemetry tooling, Blender-s growing adoption, and more news.md b/published/20190831 Google opens Android speech transcription and gesture tracking, Twitter-s telemetry tooling, Blender-s growing adoption, and more news.md new file mode 100644 index 0000000000..c6370eb975 --- /dev/null +++ b/published/20190831 Google opens Android speech transcription and gesture tracking, Twitter-s telemetry tooling, Blender-s growing adoption, and more news.md @@ -0,0 +1,88 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11292-1.html) +[#]: subject: (Google opens Android speech transcription and gesture tracking, Twitter's telemetry tooling, Blender's growing adoption, and more news) +[#]: via: (https://opensource.com/19/8/news-august-31) +[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) + +开源新闻综述:谷歌开源 Android 语音转录和手势追踪、Twitter 的遥测工具 +====== + +> 不要错过两周以来最大的开源头条新闻。 + +![Weekly news roundup with TV][1] + +在本期的开源新闻综述中,我们来看看谷歌发布的两个开源软件、Twitter 的最新可观测性工具、动漫工作室对 Blender 的采用在增多等等新闻! + +### 谷歌的开源双响炮 + +搜索引擎巨头谷歌的开发人员最近一直忙于开源。在过去的两周里,他们以开源的方式发布了两个截然不同的软件。 + +第一个是 Android 的语音识别和转录工具 Live Transcribe 的[语音引擎][2],它可以“在移动设备上使用机器学习算法将音频变成实时字幕”。谷歌的声明称,它正在开源 Live Transcribe 以“让所有开发人员可以为长篇对话提供字幕”。你可以[在 GitHub 上][3]浏览或下载 Live Transcribe 的源代码。 + +谷歌还为 Android 和 iOS 开源了[手势跟踪软件][4],它建立在其 [MediaPipe][5] 机器学习框架之上。该软件结合了三种人工智能组件:手掌探测器、“返回 3D 手点”的模型和手势识别器。据谷歌研究人员称,其目标是改善“跨各种技术领域和平台的用户体验”。该软件的源代码和文档[可在 GitHub 上获得][6]。 + +### Twitter 开源 Rezolus 遥测工具 + +当想到网络中断时,我们想到的是影响站点或服务性能的大崩溃或减速。让我们感到惊讶的是性能慢慢被吃掉的小尖峰的重要性。为了更容易地检测这些尖峰,Twitter 开发了一个名为 Rezolus 的工具,该公司[已将其开源][7]。 + +> 我们现有的按分钟采样的遥测技术未能反映出这些异常现象。这是因为相对于该异常发生的长度,较低的采样率掩盖了这些持续时间大约为 10 秒的异常。这使得很难理解正在发生的事情并调整系统以获得更高的性能。 + +Rezolus 旨在检测“非常短暂但有时显著的性能异常”——仅持续几秒钟。Twitter 已经运行了 Rezolus 大约一年,并且一直在使用它收集的内容“与后端服务日志来确定峰值的来源”。 + +如果你对将 Rezolus 添加到可观测性堆栈中的结果感到好奇,请查看 Twitter 的 [GitHub 存储库][8]中的源代码。 + +### 日本的 Khara 动画工作室采用 Blender + +Blender 被认为是开源的动画和视觉效果软件的黄金标准。它被几家制作公司采用,其中最新的是[日本动漫工作室 Khara][9]。 + +Khara 正在使用 Blender 开发 Evangelion: 3.0+1.0,这是基于流行动漫系列《Neon Genesis Evangelion》的电影系列的最新版本。虽然该电影的工作不能在 Blender 中全部完成,但 Khara 的员工“将从 2020 年 6 月开始使用 Blender 进行大部分工作”。为了强调其对 Blender 和开源的承诺,“Khara 宣布它将作为企业会员加入 Blender 基金会的发展基金。“ + +### NSA 分享其固件安全工具 + +继澳大利亚同行[共享他们的一个工具][10]之后,美国国家安全局(NSA)正在[提供][11]的一个项目的成果“可以更好地保护机器免受固件攻击“。这个最新的软件以及其他保护固件的开源工作可以在 [Coreboot Gerrit 存储库][12]下找到。 + +这个名为“具有受保护执行的 SMI 传输监视器”(STM-PE)的软件“将与运行 Coreboot 的 x86 处理器配合使用”以防止固件攻击。根据 NSA 高级网络安全实验室的 Eugene Meyers 的说法,STM-PE 采用低级操作系统代码“并将其置于一个盒子中,以便它只能访问它需要访问的设备系统”。这有助于防止篡改,Meyers 说,“这将提高系统的安全性。” + +### 其它新闻 + +* [Linux 内核中的 exFAT?是的!][13] +* [瓦伦西亚继续支持 Linux 学校发行版][14] +* [西班牙首个开源卫星][15] +* [Western Digital 从开放标准到开源芯片的长途旅行][16] +* [用于自动驾驶汽车多模传感器的 Waymo 开源数据集][17] + +一如既往地感谢 Opensource.com 的工作人员和主持人本周的帮助。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/19/8/news-august-31 + +作者:[Scott Nesbitt][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/scottnesbitt +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/weekly_news_roundup_tv.png?itok=B6PM4S1i (Weekly news roundup with TV) +[2]: https://venturebeat.com/2019/08/16/google-open-sources-live-transcribes-speech-engine/ +[3]: https://github.com/google/live-transcribe-speech-engine +[4]: https://venturebeat.com/2019/08/19/google-open-sources-gesture-tracking-ai-for-mobile-devices/ +[5]: https://github.com/google/mediapipe +[6]: https://github.com/google/mediapipe/blob/master/mediapipe/docs/hand_tracking_mobile_gpu.md +[7]: https://blog.twitter.com/engineering/en_us/topics/open-source/2019/introducing-rezolus.html +[8]: https://github.com/twitter/rezolus +[9]: https://www.neowin.net/news/anime-studio-khara-is-planning-to-use-open-source-blender-software/ +[10]: https://linux.cn/article-11241-1.html +[11]: https://www.cyberscoop.com/nsa-firmware-open-source-coreboot-stm-pe-eugene-myers/ +[12]: https://review.coreboot.org/admin/repos +[13]: https://cloudblogs.microsoft.com/opensource/2019/08/28/exfat-linux-kernel/ +[14]: https://joinup.ec.europa.eu/collection/open-source-observatory-osor/news/120000-lliurex-desktops +[15]: https://hackaday.com/2019/08/15/spains-first-open-source-satellite/ +[16]: https://www.datacenterknowledge.com/open-source/western-digitals-long-trip-open-standards-open-source-chips +[17]: https://venturebeat.com/2019/08/21/waymo-open-sources-data-set-for-autonomous-vehicle-multimodal-sensors/ diff --git a/published/20190901 Different Ways to Configure Static IP Address in RHEL 8.md b/published/20190901 Different Ways to Configure Static IP Address in RHEL 8.md new file mode 100644 index 0000000000..d67e035961 --- /dev/null +++ b/published/20190901 Different Ways to Configure Static IP Address in RHEL 8.md @@ -0,0 +1,237 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11390-1.html) +[#]: subject: (Different Ways to Configure Static IP Address in RHEL 8) +[#]: via: (https://www.linuxtechi.com/configure-static-ip-address-rhel8/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +在 RHEL8 配置静态 IP 地址的不同方法 +====== + +在 Linux 服务器上工作时,在网卡/以太网卡上分配静态 IP 地址是每个 Linux 工程师的常见任务之一。如果一个人在 Linux 服务器上正确配置了静态地址,那么他/她就可以通过网络远程访问它。在本文中,我们将演示在 RHEL 8 服务器网卡上配置静态 IP 地址的不同方法。 + +![](https://img.linux.net.cn/data/attachment/album/201909/25/222737dx94bbl9qbhzlfe4.jpg) + +以下是在网卡上配置静态IP的方法: + + * `nmcli`(命令行工具) + * 网络脚本文件(`ifcfg-*`) + * `nmtui`(基于文本的用户界面) + +### 使用 nmcli 命令行工具配置静态 IP 地址 + +每当我们安装 RHEL 8 服务器时,就会自动安装命令行工具 `nmcli`,它是由网络管理器使用的,可以让我们在以太网卡上配置静态 IP 地址。 + +运行下面的 `ip addr` 命令,列出 RHEL 8 服务器上的以太网卡 + +``` +[root@linuxtechi ~]# ip addr +``` + +正如我们在上面的命令输出中看到的,我们有两个网卡 `enp0s3` 和 `enp0s8`。当前分配给网卡的 IP 地址是通过 DHCP 服务器获得的。 + +假设我们希望在第一个网卡 (`enp0s3`) 上分配静态 IP 地址,具体内容如下: + + * IP 地址 = 192.168.1.4 + * 网络掩码 = 255.255.255.0 + * 网关 = 192.168.1.1 + * DNS = 8.8.8.8 + +依次运行以下 `nmcli` 命令来配置静态 IP, + +使用 `nmcli connection` 命令列出当前活动的以太网卡, + +``` +[root@linuxtechi ~]# nmcli connection +NAME UUID TYPE DEVICE +enp0s3 7c1b8444-cb65-440d-9bf6-ea0ad5e60bae ethernet enp0s3 +virbr0 3020c41f-6b21-4d80-a1a6-7c1bd5867e6c bridge virbr0 +[root@linuxtechi ~]# +``` + +使用下面的 `nmcli` 给 `enp0s3` 分配静态 IP。 + +**命令语法:** + +``` +# nmcli connection modify ipv4.address +``` + +**注意:** 为了简化语句,在 `nmcli` 命令中,我们通常用 `con` 关键字替换 `connection`,并用 `mod` 关键字替换 `modify`。 + +将 IPv4 地址 (192.168.1.4) 分配给 `enp0s3` 网卡上, + +``` +[root@linuxtechi ~]# nmcli con mod enp0s3 ipv4.addresses 192.168.1.4/24 +``` + +使用下面的 `nmcli` 命令设置网关, + +``` +[root@linuxtechi ~]# nmcli con mod enp0s3 ipv4.gateway 192.168.1.1 +``` + +设置手动配置(从 dhcp 到 static), + +``` +[root@linuxtechi ~]# nmcli con mod enp0s3 ipv4.method manual +``` + +设置 DNS 值为 “8.8.8.8”, + +``` +[root@linuxtechi ~]# nmcli con mod enp0s3 ipv4.dns "8.8.8.8" +``` + +要保存上述更改并重新加载,请执行如下 `nmcli` 命令, + +``` +[root@linuxtechi ~]# nmcli con up enp0s3 +Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4) +``` + +以上命令显示网卡 `enp0s3` 已成功配置。我们使用 `nmcli` 命令做的那些更改都将永久保存在文件 `etc/sysconfig/network-scripts/ifcfg-enp0s3` 里。 + +``` +[root@linuxtechi ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3 +``` + +![ifcfg-enp0s3-file-rhel8][2] + +要确认 IP 地址是否分配给了 `enp0s3` 网卡了,请使用以下 IP 命令查看, + +``` +[root@linuxtechi ~]#ip addr show enp0s3 +``` + +### 使用网络脚本文件(ifcfg-*)手动配置静态 IP 地址 + +我们可以使用配置以太网卡的网络脚本或 `ifcfg-*` 文件来配置以太网卡的静态 IP 地址。假设我们想在第二个以太网卡 `enp0s8` 上分配静态 IP 地址: + +* IP 地址 = 192.168.1.91 +* 前缀 = 24 +* 网关 =192.168.1.1 +* DNS1 =4.2.2.2 + + +转到目录 `/etc/sysconfig/network-scripts`,查找文件 `ifcfg-enp0s8`,如果它不存在,则使用以下内容创建它, + +``` +[root@linuxtechi ~]# cd /etc/sysconfig/network-scripts/ +[root@linuxtechi network-scripts]# vi ifcfg-enp0s8 +TYPE="Ethernet" +DEVICE="enp0s8" +BOOTPROTO="static" +ONBOOT="yes" +NAME="enp0s8" +IPADDR="192.168.1.91" +PREFIX="24" +GATEWAY="192.168.1.1" +DNS1="4.2.2.2" +``` + +保存并退出文件,然后重新启动网络管理器服务以使上述更改生效, + +``` +[root@linuxtechi network-scripts]# systemctl restart NetworkManager +``` + +现在使用下面的 `ip` 命令来验证 IP 地址是否分配给网卡, + +``` +[root@linuxtechi ~]# ip add show enp0s8 +3: enp0s8: mtu 1500 qdisc fq_codel state UP group default qlen 1000 + link/ether 08:00:27:7c:bb:cb brd ff:ff:ff:ff:ff:ff + inet 192.168.1.91/24 brd 192.168.1.255 scope global noprefixroute enp0s8 + valid_lft forever preferred_lft forever + inet6 fe80::a00:27ff:fe7c:bbcb/64 scope link + valid_lft forever preferred_lft forever +[root@linuxtechi ~]# +``` + +以上输出内容确认静态 IP 地址已在网卡 `enp0s8` 上成功配置了。 + +### 使用 nmtui 实用程序配置静态 IP 地址 + +`nmtui` 是一个基于文本用户界面的,用于控制网络的管理器,当我们执行 `nmtui` 时,它将打开一个基于文本的用户界面,通过它我们可以添加、修改和删除连接。除此之外,`nmtui` 还可以用来设置系统的主机名。 + +假设我们希望通过以下细节将静态 IP 地址分配给网卡 `enp0s3` , + +* IP 地址 = 10.20.0.72 +* 前缀 = 24 +* 网关 = 10.20.0.1 +* DNS1 = 4.2.2.2 + +运行 `nmtui` 并按照屏幕说明操作,示例如下所示, + +``` +[root@linuxtechi ~]# nmtui +``` + +![nmtui-rhel8][3] + +选择第一个选项 “Edit a connection”,然后选择接口为 “enp0s3”, + +![Choose-interface-nmtui-rhel8][4] + +选择 “Edit”,然后指定 IP 地址、前缀、网关和域名系统服务器 IP, + +![set-ip-nmtui-rhel8][5] + +选择确定,然后点击回车。在下一个窗口中,选择 “Activate a connection”, + +![Activate-option-nmtui-rhel8][6] + +选择 “enp0s3”,选择 “Deactivate” 并点击回车, + +![Deactivate-interface-nmtui-rhel8][7] + +现在选择 “Activate” 并点击回车, + +![Activate-interface-nmtui-rhel8][8] + +选择 “Back”,然后选择 “Quit”, + +![Quit-Option-nmtui-rhel8][9] + +使用下面的 `ip` 命令验证 IP 地址是否已分配给接口 `enp0s3`, + +``` +[root@linuxtechi ~]# ip add show enp0s3 +2: enp0s3: mtu 1500 qdisc fq_codel state UP group default qlen 1000 + link/ether 08:00:27:53:39:4d brd ff:ff:ff:ff:ff:ff + inet 10.20.0.72/24 brd 10.20.0.255 scope global noprefixroute enp0s3 + valid_lft forever preferred_lft forever + inet6 fe80::421d:5abf:58bd:c47e/64 scope link noprefixroute + valid_lft forever preferred_lft forever +[root@linuxtechi ~]# +``` + +以上输出内容显示我们已经使用 `nmtui` 实用程序成功地将静态 IP 地址分配给接口 `enp0s3`。 + +以上就是本教程的全部内容,我们已经介绍了在 RHEL 8 系统上为以太网卡配置 IPv4 地址的三种不同方法。请在下面的评论部分分享反馈和评论。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/configure-static-ip-address-rhel8/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Configure-Static-IP-RHEL8.jpg +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/09/ifcfg-enp0s3-file-rhel8.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/09/nmtui-rhel8.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Choose-interface-nmtui-rhel8.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/09/set-ip-nmtui-rhel8.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Activate-option-nmtui-rhel8.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Deactivate-interface-nmtui-rhel8.jpg +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Activate-interface-nmtui-rhel8.jpg +[9]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Quit-Option-nmtui-rhel8.jpg diff --git a/published/20190902 Why I use Java.md b/published/20190902 Why I use Java.md new file mode 100644 index 0000000000..d4ec8d6570 --- /dev/null +++ b/published/20190902 Why I use Java.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11337-1.html) +[#]: subject: (Why I use Java) +[#]: via: (https://opensource.com/article/19/9/why-i-use-java) +[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) + +我为什么使用 Java +====== + +> 根据你的工作需要,可能有比 Java 更好的语言,但是我还没有看到任何能把我拉走的语言。 + +![](https://img.linux.net.cn/data/attachment/album/201909/13/171223bf7noo4bbnkxbkdk.jpg) + +我记得我是从 1997 年开始使用 Java 的,就在 [Java 1.1 刚刚发布][2]不久之后。从那时起,总的来说,我非常喜欢用 Java 编程;虽然我得承认,这些日子我经常像在 Java 中编写“严肃的代码”一样编写 [Groovy][3] 脚本。 + +来自 [FORTRAN][4]、[PL/1][5]、[Pascal][6] 以及最后的 [C 语言][7] 背景,我发现了许多让我喜欢 Java 的东西。Java 是我[面向对象编程][8]的第一次重要实践经验。到那时,我已经编程了大约 20 年,而且可以说我对什么重要、什么不重要有了一些看法。 + +### 调试是一个关键的语言特性 + +我真的很讨厌浪费时间追踪由我的代码不小心迭代到数组末尾而导致的模糊错误,特别是在 IBM 大型机上的 FORTRAN 编程时代。另一个不时出现的隐晦问题是调用一个子程序时,该子程序带有一个四字节整数参数,而预期有两个字节;在小端架构上,这通常是一个良性的错误,但在大端机器上,前两个字节的值通常并不总是为零。 + +在那种批处理环境中进行调试也非常不便,通过核心转储或插入打印语句进行调试,这些语句本身会移动错误的位置甚至使它们消失。 + +所以我使用 Pascal 的早期体验,先是在 [MTS][9] 上,然后是在 [IBM OS/VS1][10] 上使用相同的 MTS 编译器,让我的生活变得更加轻松。Pascal 的[强类型和静态类型][11]是取得这种胜利的重要组成部分,我使用的每个 Pascal 编译器都会在数组的边界和范围上插入运行时检查,因此错误可以在发生时检测到。当我们在 20 世纪 80 年代早期将大部分工作转移到 Unix 系统时,移植 Pascal 代码是一项简单的任务。 + +### 适量的语法 + +但是对于我所喜欢的 Pascal 来说,我的代码很冗长,而且语法似乎要比代码还要多;例如,使用: + +``` +if ... then begin ... end else ... end +``` + +而不是 C 或类似语言中的: + +``` +if (...) { ... } else { ... } +``` + +另外,有些事情在 Pascal 中很难完成,在 C 中更容易。但是,当我开始越来越多地使用 C 时,我发现自己遇到了我曾经在 FORTRAN 中遇到的同样类型的错误,例如,超出数组边界。在原始的错误点未检测到数组结束,而仅在程序执行后期才会检测到它们的不利影响。幸运的是,我不再生活在那种批处理环境中,并且手头有很好的调试工具。不过,C 对于我来说有点太灵活了。 + +当我遇到 [awk][12] 时,我发现它与 C 相比又是另外一种样子。那时,我的很多工作都涉及转换字段数据并创建报告。我发现用 `awk` 加上其他 Unix 命令行工具,如 `sort`、`sed`、`cut`、`join`、`paste`、`comm` 等等,可以做到事情令人吃惊。从本质上讲,这些工具给了我一个像是基于文本文件的关系数据库管理器,这种文本文件具有列式结构,是我们很多字段数据的保存方式。或者,即便不是这种格式,大部分时候也可以从关系数据库或某种二进制格式导出到列式结构中。 + +`awk` 支持的字符串处理、[正则表达式][13]和[关联数组][14],以及 `awk` 的基本特性(它实际上是一个数据转换管道),非常符合我的需求。当面对二进制数据文件、复杂的数据结构和关键性能需求时,我仍然会转回到 C;但随着我越来越多地使用 `awk`,我发现 C 的非常基础的字符串支持越来越令人沮丧。随着时间的推移,更多的时候我只会在必须时才使用 C,并且在其余的时候里大量使用 `awk`。 + +### Java 的抽象层级合适 + +然后是 Java。它看起来相当不错 —— 相对简洁的语法,让人联想到 C,或者这种相似性至少要比 Pascal 或其他任何早期的语言更为明显。它是强类型的,因此很多编程错误会在编译时被捕获。它似乎并不需要过多的面向对象的知识就能起步,这是一件好事,因为我当时对 [OOP 设计模式][15]毫不熟悉。但即使在刚刚开始,我也喜欢它的简化[继承模型][16]背后的思想。(Java 允许使用提供的接口进行单继承,以在某种程度上丰富范例。) + +它似乎带有丰富的功能库(即“自备电池”的概念),在适当的水平上直接满足了我的需求。最后,我发现自己很快就会想到将数据和行为在对象中组合在一起的想法。这似乎是明确控制数据之间交互的好方法 —— 比大量的参数列表或对全局变量的不受控制的访问要好得多。 + +从那以后,Java 在我的编程工具箱中成为了 Helvetic 军刀。我仍然偶尔会在 `awk` 中编写程序,或者使用 Linux 命令行实用程序(如 `cut`、`sort` 或 `sed`),因为它们显然是解决手头问题的直接方法。我怀疑过去 20 年我可能没写过 50 行的 C 语言代码;Java 完全满足了我的需求。 + +此外,Java 一直在不断改进。首先,它变得更加高效。并且它添加了一些非常有用的功能,例如[可以用 try 来测试资源][17],它可以很好地清理在文件 I/O 期间冗长而有点混乱的错误处理代码;或 [lambda][18],它提供了声明函数并将其作为参数传递的能力,而旧方法需要创建类或接口来“托管”这些函数;或[流][19],它在函数中封装了迭代行为,可以创建以链式函数调用形式实现的高效数据转换管道。 + +### Java 越来越好 + +许多语言设计者研究了从根本上改善 Java 体验的方法。对我来说,其中大部分没有引起我的太多兴趣;再次,这更多地反映了我的典型工作流程,并且(更多地)减少了这些语言带来的功能。但其中一个演化步骤已经成为我的编程工具中不可或缺的一部分:[Groovy][20]。当我遇到一个小问题,需要一个简单的解决方案时,Groovy 已经成为了我的首选。而且,它与 Java 高度兼容。对我来说,Groovy 填补了 Python 为许多其他人所提供的相同用处 —— 它紧凑、DRY(不要重复自己)和具有表达性(列表和词典有完整的语言支持)。我还使用了 [Grails][21],它使用 Groovy 为非常高性能和有用的 Java Web 应用程序提供简化的 Web 框架。 + +### Java 仍然开源吗? + +最近,对 [OpenJDK][22] 越来越多的支持进一步提高了我对 Java 的舒适度。许多公司以各种方式支持 OpenJDK,包括 [AdoptOpenJDK、Amazon 和 Red Hat][23]。在我的一个更大、更长期的项目中,我们使用 AdoptOpenJDK [来在几个桌面平台上生成自定义的运行时环境][24]。 + +有没有比 Java 更好的语言?我确信有,这取决于你的工作需要。但我一直对 Java 非常满意,我还没有遇到任何可能会让我失望的东西。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/why-i-use-java + +作者:[Chris Hermansen][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clhermansen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/java-coffee-beans.jpg?itok=3hkjX5We (Coffee beans) +[2]: https://en.wikipedia.org/wiki/Java_version_history +[3]: https://en.wikipedia.org/wiki/Apache_Groovy +[4]: https://en.wikipedia.org/wiki/Fortran +[5]: https://en.wikipedia.org/wiki/PL/I +[6]: https://en.wikipedia.org/wiki/Pascal_(programming_language) +[7]: https://en.wikipedia.org/wiki/C_(programming_language) +[8]: https://en.wikipedia.org/wiki/Object-oriented_programming +[9]: https://en.wikipedia.org/wiki/Michigan_Terminal_System +[10]: https://en.wikipedia.org/wiki/OS/VS1 +[11]: https://stackoverflow.com/questions/11889602/difference-between-strong-vs-static-typing-and-weak-vs-dynamic-typing +[12]: https://en.wikipedia.org/wiki/AWK +[13]: https://en.wikipedia.org/wiki/Regular_expression +[14]: https://en.wikipedia.org/wiki/Associative_array +[15]: https://opensource.com/article/19/7/understanding-software-design-patterns +[16]: https://www.w3schools.com/java/java_inheritance.asp +[17]: https://www.baeldung.com/java-try-with-resources +[18]: https://www.baeldung.com/java-8-lambda-expressions-tips +[19]: https://www.tutorialspoint.com/java8/java8_streams +[20]: https://groovy-lang.org/ +[21]: https://grails.org/ +[22]: https://openjdk.java.net/ +[23]: https://en.wikipedia.org/wiki/OpenJDK +[24]: https://opensource.com/article/19/4/java-se-11-removing-jnlp diff --git a/published/20190903 5 open source speed-reading applications.md b/published/20190903 5 open source speed-reading applications.md new file mode 100644 index 0000000000..ef922bf1e8 --- /dev/null +++ b/published/20190903 5 open source speed-reading applications.md @@ -0,0 +1,93 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11316-1.html) +[#]: subject: (5 open source speed-reading applications) +[#]: via: (https://opensource.com/article/19/8/speed-reading-open-source) +[#]: author: (Jaouhari Youssef https://opensource.com/users/jaouhari) + +5 个开源的速读应用 +====== + +> 使用这五个应用训练自己更快地阅读文本。 + +![](https://img.linux.net.cn/data/attachment/album/201909/07/151320r39o26onsp3sq1qo.jpg) + +英国散文家和政治家 [Joseph Addison][2] 曾经说过,“读书益智,运动益体。”如今,我们大多数人(如果不是全部)都是通过计算机显示器、电视屏幕、移动设备、街道标志、报纸、杂志上阅读,以及在工作场所和学校阅读论文来训练我们的大脑。 + +鉴于我们每天都会收到大量的书面信息,通过做一些挑战我们经典的阅读习惯并教会我们吸收更多内容和数据的特定练习,来训练我们的大脑以便更快地阅读似乎是有利的。学习这些技能的目的不仅仅是浏览文本,因为没有理解的阅读就是浪费精力。目标是提高你的阅读速度,同时仍然达到高水平的理解。 + +### 阅读和处理输入 + +在深入探讨速读之前,让我们来看看阅读过程。根据法国眼科医生 Louis Emile Javal 的说法,阅读分为三个步骤: + + 1. 固定 + 2. 处理 + 3. [扫视][3]saccade + +在第一步,我们确定文本中的固定点,称为最佳识别点。在第二步中,我们在眼睛固定的同时引入(处理)新信息。最后,我们改变注视点的位置,这是一种称为扫视的操作,此时未获取任何新信息。 + +在实践中,阅读更快的读者之间的主要差异是固定时间短于平均值,更长距离扫视,重读更少。 + +### 阅读练习 + +阅读不是人类的自然过程,因为它是人类生存跨度中一个相当新的发展。第一个书写系统是在大约 5000 年前创建的,它不足以让人们发展成为阅读机器。因此,我们必须运用我们的阅读技巧,在这项沟通的基本任务中变得更加娴熟和高效。 + +第一项练习包括减少默读,也被称为无声语音,这是一种在阅读时内部发音的习惯。它是一个减慢阅读速度的自然过程,因为阅读速度限于语速。减少默读的关键是只说出一些阅读的单词。一种方法是用其他任务来占据内部声音,例如用口香糖。 + +第二个练习包括减少回归,或称为重读。回归是一种懒惰的机制,因为我们的大脑可以随时重读任何材料,从而降低注意力。 + +### 5 个开源应用来训练你的大脑 + +有几个有趣的开源应用可用于锻炼你的阅读速度。 + +一个是 [Gritz][4],它是一个开源文件阅读器,它一次一个地弹出单词,以减少回归。它适用于 Linux、Windows 和 MacOS,并在 GPL 许可证下发布,因此你可以随意使用它。 + +其他选择包括 [Spray Speed-Reader][5],一个用 JavaScript 编写的开源速读应用,以及 [Sprits-it!][6],一个开源 Web 应用,可以快速阅读网页。 + +对于 Android 用户,[Comfort Reader][7] 是一个开源的速读应用。它可以在 [F-droid][8] 和 [Google Play][9] 应用商店中找到。 + +我最喜欢的应用是 [Speedread][10],它是一个简单的终端程序,它可以在最佳阅读点逐字显示文本。要安装它,请在你的设备上克隆 Github 仓库,然后输入相应的命令来选择以喜好的每分钟字数 (WPM)来阅读文档。默认速率为 250 WPM。例如,要以 400 WPM 阅读 `your_text_file.txt`,你应该输入: + +``` +`cat your_text_file.txt | ./speedread -w 400` +``` + +下面是该程序的运行界面: + +![Speedread demo][11] + +由于你可能不会只阅读[纯文本][12],因此可以使用 [Pandoc][13] 将文件从标记格式转换为文本格式。你还可以使用 Android 终端模拟器 [Termux][14] 在 Android 设备上运行 Speedread。 + +### 其他方案 + +对于开源社区来说,构建一个解决方案是一个有趣的项目,它仅为了通过使用特定练习来提高阅读速度,以此改进如默读和重读。我相信这个项目会非常有益,因为在当今信息丰富的环境中,提高阅读速度非常有价值。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/speed-reading-open-source + +作者:[Jaouhari Youssef][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jaouhari +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/books_stack_library_reading.jpg?itok=uulcS8Sw (stack of books) +[2]: https://en.wikipedia.org/wiki/Joseph_Addison +[3]: https://en.wikipedia.org/wiki/Saccade +[4]: https://github.com/jeffkowalski/gritz +[5]: https://github.com/chaimpeck/spray +[6]: https://github.com/the-happy-hippo/sprits-it +[7]: https://github.com/mschlauch/comfortreader +[8]: https://f-droid.org/packages/com.mschlauch.comfortreader/ +[9]: https://play.google.com/store/apps/details?id=com.mschlauch.comfortreader +[10]: https://github.com/pasky/speedread +[11]: https://opensource.com/sites/default/files/uploads/speedread_demo.gif (Speedread demo) +[12]: https://plaintextproject.online/ +[13]: https://opensource.com/article/18/9/intro-pandoc +[14]: https://termux.com/ diff --git a/published/20190903 An introduction to Hyperledger Fabric.md b/published/20190903 An introduction to Hyperledger Fabric.md new file mode 100644 index 0000000000..3bd8f72221 --- /dev/null +++ b/published/20190903 An introduction to Hyperledger Fabric.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11328-1.html) +[#]: subject: (An introduction to Hyperledger Fabric) +[#]: via: (https://opensource.com/article/19/9/introduction-hyperledger-fabric) +[#]: author: (Matt Zand https://opensource.com/users/mattzandhttps://opensource.com/users/ron-mcfarlandhttps://opensource.com/users/wonderchook) + +Hyperledger Fabric 介绍 +====== + +> Hyperledger (超级账本)是一组开源工具,旨在构建一个强大的、业务驱动的区块链框架。 + +![](https://img.linux.net.cn/data/attachment/album/201909/11/105935hm606vso3fclzso6.jpg) + +[Hyperledger][2] (超级账本)是区块链行业中最大的项目之一,它由一组开源工具和多个子项目组成。该项目是由 Linux 基金会主办的一个全球协作项目,其中包括一些不同领域的领导者们,这些领导者们的目标是建立一个强大的、业务驱动的区块链框架。 + +区块链网络主要有三种类型:公共区块链、联盟或联合区块链,以及私有区块链。Hyperledger 是一个区块链框架,旨在帮助公司建立私人或联盟许可的区块链网络,在该网络中,多个组织可以共享控制和操作网络内节点的权限。 + +因为区块链是一个透明的,基于不可变模式的安全的去中心化系统,所以它被认为是传统的供应链行业改变游戏规则的一种解决方案。它可以通过以下方式支持有效的供应链系统: + +* 跟踪整个区块链中的产品 +* 校验和验证区块链中的产品 +* 在供应链参与者之间共享整个区块链的信息 +* 提供可审核性 + +本文通过食品供应链的例子来解释 Hyperledger 区块链是如何改变传统供应链系统的。 + +### 食品行业供应链 + +传统供应链效率低下的主要原因是由于缺乏透明度而导致报告不可靠和竞争上的劣势。 + +在传统的供应链模式中,有关实体的信息对该区块链中的其他人来说并不完全透明,这就导致了不准确的报告和缺乏互操作性问题。电子邮件和印刷文档提供了一些信息,但它们不可能包含完整详细的可见性数据,因为很难在整个供应链中去追踪产品。这也使消费者几乎不可能知道产品的真正价值和来源。 + +食品行业的供应链环境复杂,多个参与者需要协作将货物运送到最终目的地 —— 客户手中。下图显示了食品供应链(多级)网络中的主要参与者。 + +![典型的食品供应链][3] + +该区块链的每个阶段都会引入潜在的安全问题、整合问题和其他低效问题。目前食品供应链中的主要威胁仍然是假冒食品和食品欺诈。 + +基于 Hyperledger 区块链的食品跟踪系统可实现对食品信息全面的可视性和和可追溯性。更重要的是,它以一种不变但可行的方式来记录产品细节,确保食品信息的真实性。最终用户通过在不可变框架上共享产品的详细信息,可以自我验证产品的真实性。 + +### Hyperledger Fabric + +Hyperledger Fabric 是 Hyperledger 项目的基石。它是基于许可的区块链,或者更准确地说是一种分布式分类帐技术(DLT),该技术最初由 IBM 公司和 Digital Asset 创建。分布式分类帐技术被设计为具有不同组件的模块化框架(概述如下)。它也是提供可插入的共识模型的一种灵活的解决方案,尽管它目前仅提供基于投票的许可共识(假设今天的 Hyperledger 网络在部分可信赖的环境中运行)。 + +鉴于此,无需匿名矿工来验证交易,也无需用作激励措施的相关货币。所有的参与者必须经过身份验证才能参与到该区块链进行交易。与以太坊一样,Hyperledger Fabric 支持智能合约,在 Hyperledger 中称为 Chaincodes链码,这些合约描述并执行系统的应用程序逻辑。 + +然而,与以太坊不同,Hyperledger Fabric 不需要昂贵的挖矿计算来提交交易,因此它有助于构建可以在更短的延迟内进行扩展的区块链。 + +Hyperledger Fabric 不同于以太坊或比特币这样的区块链,不仅在于它们类型不同,或者说是它与货币无关,而且它们在内部机制方面也不同。以下是典型的 Hyperledger 网络的关键要素: + +* 账本Ledgers:存储了一系列块,这些块保留了所有状态交易的所有不可变历史记录。 +* 节点Nodes:区块链的逻辑实体。它有三种类型: + * 客户端Clients:是代表用户向网络提交事务的应用程序。 + * 对等体Peers:是提交交易并维护分类帐状态的实体。 + * 排序者Orderers 在客户端和对等体之间创建共享通信渠道,还将区块链交易打包成块发送给遵从的对等体节点。 + +除了这些要素,Hyperledger Fabric 还有以下关键设计功能: + +* 链码Chaincode:类似于其它诸如以太坊的网络中的智能合约。它是用一种更高级的语言编写的程序,在针对分类帐当前状态的数据库执行。 +* 通道Channels:用于在多个网络成员之间共享机密信息的专用通信子网。每笔交易都在一个只有经过身份验证和授权的各方可见的通道上执行。 +* 背书人Endorsers 验证交易,调用链码,并将背书的交易结果返回给调用应用程序。 +* 成员服务提供商Membership Services Providers(MSP)通过颁发和验证证书来提供身份验证和身份验证过程。MSP 确定信任哪些证书颁发机构(CA)去定义信任域的成员,并确定成员可能扮演的特定角色(成员、管理员等)。 + +### 如何验证交易 + +探究一笔交易是如何通过验证的是理解 Hyperledger Fabric 在底层如何工作的好方法。此图显示了在典型的 Hyperledger 网络中处理交易的端到端系统流程: + +![Hyperledger 交易验证流程][4] + +首先,客户端通过向基于 Hyperledger Fabric 的应用程序客户端发送请求来启动交易,该客户端将交易提议提交给背书对等体。这些对等体通过执行由交易指定的链码(使用该状态的本地副本)来模拟该交易,并将结果发送回应用程序。此时,应用程序将交易与背书相结合,并将其广播给排序服务Ordering Service。排序服务检查背书并为每个通道创建一个交易块,然后将其广播给通道中的其它节点,对的体验证该交易并进行提交。 + +Hyperledger Fabric 区块链可以通过透明的、不变的和共享的食品来源数据记录、处理数据,及运输细节等信息将食品供应链中的参与者们连接起来。链码由食品供应链中的授权参与者来调用。所有执行的交易记录都永久保存在分类帐中,所有参与者都可以查看此信息。 + +### Hyperledger Composer + +除了 Fabric 或 Iroha 等区块链框架外,Hyperledger 项目还提供了 Composer、Explorer 和 Cello 等工具。 Hyperledger Composer 提供了一个工具集,可帮助你更轻松地构建区块链应用程序。 它包括: + +* CTO,一种建模语言 +* Playground,一种基于浏览器的开发工具,用于快速测试和部署 +* 命令行界面(CLI)工具 + +Composer 支持 Hyperledger Fabric 的运行时和基础架构,在内部,Composer 的 API 使用底层 Fabric 的 API。Composer 在 Fabric 上运行,这意味着 Composer 生成的业务网络可以部署到 Hyperledger Fabric 执行。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/introduction-hyperledger-fabric + +作者:[Matt Zand][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mattzandhttps://opensource.com/users/ron-mcfarlandhttps://opensource.com/users/wonderchook +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/chain.png?itok=sgAjswFf (Chain image) +[2]: https://www.hyperledger.org/ +[3]: https://opensource.com/sites/default/files/uploads/foodindustrysupplychain.png (Typical food supply chain) +[4]: https://opensource.com/sites/default/files/uploads/hyperledger-fabric-transaction-flow.png (Hyperledger transaction validation flow) +[5]: https://coding-bootcamps.com/ultimate-guide-for-building-a-blockchain-supply-chain-using-hyperledger-fabric-and-composer.html diff --git a/published/20190903 The birth of the Bash shell.md b/published/20190903 The birth of the Bash shell.md new file mode 100644 index 0000000000..8102b01097 --- /dev/null +++ b/published/20190903 The birth of the Bash shell.md @@ -0,0 +1,102 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11314-1.html) +[#]: subject: (The birth of the Bash shell) +[#]: via: (https://opensource.com/19/9/command-line-heroes-bash) +[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberghttps://opensource.com/users/mbbroberghttps://opensource.com/users/mbbroberghttps://opensource.com/users/mbbroberg) + +Bash shell 的诞生 +====== + +> 本周的《代码英雄》播客深入研究了最广泛使用的、已经成为事实标准的脚本语言,它来自于自由软件基金会及其作者的早期灵感。 + +![Listen to the Command Line Heroes Podcast][1] + +对于任何从事于系统管理员方面的人来说,Shell 脚本编程是一门必不可少的技能,而如今人们编写脚本的主要 shell 是 Bash。Bash 是几乎所有的 Linux 发行版和现代 MacOS 版本的默认配置,也很快就会成为 [Windows 终端][2]的原生部分。你可以说 Bash 无处不在。 + +那么它是如何做到这一点的呢?本周的《[代码英雄][3]》播客将通过询问编写那些代码的人来深入研究这个问题。 + +### 肇始于 Unix + +像所有编程方面的东西一样,我们必须追溯到 Unix。shell 的简短历史是这样的:1971 年,Ken Thompson 发布了第一个 Unix shell:Thompson shell。但是,脚本用户所能做的存在严重限制,这意味着严重制约了自动化以及整个 IT 运营领域。 + +这个[奇妙的研究][4]概述了早期尝试脚本的挑战: + +> 类似于它在 Multics 中的前身,这个 shell(`/bin/sh`)是一个在内核外执行的独立用户程序。诸如通配(参数扩展的模式匹配,例如 `*.txt`)之类的概念是在一个名为 `glob` 的单独的实用程序中实现的,就像用于计算条件表达式的 `if` 命令一样。这种分离使 shell 变得更小,才不到 900 行的 C 源代码。 +> +> shell 引入了紧凑的重定向(`<`、`>` 和 `>>`)和管道(`|` 或 `^`)语法,它们已经存在于现代 shell 中。你还可以找到对调用顺序命令(`;`)和异步命令(`&`)的支持。 +> +> Thompson shell 缺少的是编写脚本的能力。它的唯一目的是作为一个交互式 shell(命令解释器)来调用命令和查看结果。 + +随着对终端使用的增长,对自动化的兴趣随之增长。 + +### Bourne shell 前进一步 + +在 Thompson 发布 shell 六年后,1977 年,Stephen Bourne 发布了 Bourne shell,旨在解决Thompson shell 中的脚本限制。(Chet Ramey 是自 1990 年以来 Bash 语言的主要维护者,在这一集的《代码英雄》中讨论了它)。作为 Unix 系统的一部分,这是这个来自贝尔实验室的技术的自然演变。 + +Bourne 打算做什么不同的事情?[研究员 M. Jones][4] 很好地概述了它: + +> Bourne shell 有两个主要目标:作为命令解释器以交互方式执行操作系统的命令,和用于脚本编程(编写可通过 shell 调用的可重用脚本)。除了替换 Thompson shell,Bourne shell 还提供了几个优于其前辈的优势。Bourne 将控制流、循环和变量引入脚本,提供了更具功能性的语言来(以交互式和非交互式)与操作系统交互。该 shell 还允许你使用 shell 脚本作为过滤器,为处理信号提供集成支持,但它缺乏定义函数的能力。最后,它结合了我们今天使用的许多功能,包括命令替换(使用后引号)和 HERE 文档(以在脚本中嵌入保留的字符串文字)。 + +Bourne 在[之前的一篇采访中][5]这样描述它: + +> 最初的 shell (编程语言)不是一种真正的语言;它是一种记录 —— 一种从文件中线性执行命令序列的方法,唯一的控制流的原语是 `GOTO` 到一个标签。Ken Thompson 所编写的这个最初的 shell 的这些限制非常重要。例如,你无法简单地将命令脚本用作过滤器,因为命令文件本身是标准输入。而在过滤器中,标准输入是你从父进程继承的,不是命令文件。 +> +> 最初的 shell 很简单,但随着人们开始使用 Unix 进行应用程序开发和脚本编写,它就太有限了。它没有变量、它没有控制流,而且它的引用能力非常不足。 + +对于脚本编写者来说,这个新 shell 是一个巨大的进步,但前提是你可以使用它。 + +### 以自由软件来重新构思 Bourne Shell + +在此之前,这个占主导地位的 shell 是由贝尔实验室拥有和管理的专有软件。幸运的话,你的大学可能有权访问 Unix shell。但这种限制性访问远非自由软件基金会(FSF)想要实现的世界。 + +Richard Stallman 和一群志同道合的开发人员那时正在编写所有的 Unix 功能,其带有可以在 GNU 许可证下免费获得的许可。其中一个开发人员的任务是制作一个 shell,那位开发人员是 Brian Fox。他对他的任务的讲述十分吸引我。正如他在播客上所说: + +> 它之所以如此具有挑战性,是因为我们必须忠实地模仿 Bourne shell 的所有行为,同时允许扩展它以使其成为一个供人们使用的更好工具。 + +而那时也恰逢人们在讨论 shell 标准是什么的时候。在这一历史背景和将来的竞争前景下,流行的 Bourne shell 被重新构想,并再次重生。 + +### 重新打造 Bourne Shell + +自由软件的使命和竞争这两个催化剂使重制的 Bourne shell(Bash)具有了生命。和之前不同的是,Fox 并没有把 shell 放到自己的名字之后命名,他专注于从 Unix 到自由软件的演变。(虽然 Fox Shell 这个名字看起来要比 Fish shell 更适合作为 fsh 命令 #missedopportunity)。这个命名选择似乎符合他的个性。正如 Fox 在剧集中所说,他甚至对个人的荣耀也不感兴趣;他只是试图帮助编程文化发展。然而,他并不是一个优秀的双关语。 + +而 Bourne 也并没有因为他命名 shell 的文字游戏而感到被轻视。Bourne 讲述了一个故事,有人走到他面前,并在会议上给了他一件 Bash T 恤,而那个人是 Brian Fox。 + +Shell | 发布于 | 创造者 +---|---|--- +Thompson Shell | 1971 | Ken Thompson +Bourne Shell | 1977 | Stephen Bourne +Bourne-Again Shell | 1989 | Brian Fox + +随着时间的推移,Bash 逐渐成长。其他工程师开始使用它并对其设计进行改进。事实上,多年后,Fox 坚定地认为学会放弃控制 Bash 是他一生中最重要的事情之一。随着 Unix 让位于 Linux 和开源软件运动,Bash 成为开源世界的至关重要的脚本语言。这个伟大的项目似乎超出了单一一个人的愿景范围。 + +### 我们能从 shell 中学到什么? + +shell 是一项技术,它是笔记本电脑日常使用中的一个组成部分,你很容易忘记它也需要发明出来。从 Thompson 到 Bourne 再到 Bash,shell 的故事为我们描绘了一些熟悉的结论: + +* 有动力的人可以在正确的使命中取得重大进展。 +* 我们今天所依赖的大部分内容都建立在我们行业中仍然活着的那些传奇人物打下的基础之上。 +* 能够生存下来的软件超越了其原始创作者的愿景。 +   +代码英雄在全部的第三季中讲述了编程语言,并且正在接近它的尾声。[请务必订阅,来了解你想知道的有关编程语言起源的各种内容][3],我很乐意在下面的评论中听到你的 shell 故事。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/19/9/command-line-heroes-bash + +作者:[Matthew Broberg][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mbbroberghttps://opensource.com/users/mbbroberghttps://opensource.com/users/mbbroberghttps://opensource.com/users/mbbroberg +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/commnad_line_hereoes_ep6_blog-header-292x521.png?itok=Bs1RlwoW (Listen to the Command Line Heroes Podcast) +[2]: https://devblogs.microsoft.com/commandline/introducing-windows-terminal/ +[3]: https://www.redhat.com/en/command-line-heroes +[4]: https://developer.ibm.com/tutorials/l-linux-shells/ +[5]: https://www.computerworld.com.au/article/279011/-z_programming_languages_bourne_shell_sh diff --git a/published/20190904 How to build Fedora container images.md b/published/20190904 How to build Fedora container images.md new file mode 100644 index 0000000000..0ab7ed8684 --- /dev/null +++ b/published/20190904 How to build Fedora container images.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11327-1.html) +[#]: subject: (How to build Fedora container images) +[#]: via: (https://fedoramagazine.org/how-to-build-fedora-container-images/) +[#]: author: (Clément Verna https://fedoramagazine.org/author/cverna/) + +如何构建 Fedora 容器镜像 +====== + +![][1] + +随着容器和容器技术的兴起,现在所有主流的 Linux 发行版都提供了容器基础镜像。本文介绍了 Fedora 项目如何构建其基本镜像。同时还展示了如何使用它来创建分层图像。 + +### 基础和分层镜像 + +在看如何构建 Fedora 容器基础镜像base image之前,让我们定义基础镜像和分层镜像layered image。定义基础镜像的简单方法是没有父镜像层的镜像。但这具体意味着什么呢?这意味着基础镜像通常只包含操作系统的根文件系统基础镜像(rootfs)。基础镜像通常提供安装软件以创建分层镜像所需的工具。 + +分层镜像在基础镜像上添加了一组层,以便安装、配置和运行应用。分层镜像在 Dockerfile 中使用 `FROM` 指令引用基础镜像: + +``` +FROM fedora:latest +``` + +### 如何构建基础镜像 + +Fedora 有一整套用于构建容器镜像的工具。[其中包括 podman][2],它不需要以 root 身份运行。 + +#### 构建 rootfs + +基础镜像主要由一个 [tarball][3] 构成。这个 tarball 包含一个 rootfs。有不同的方法来构建此 rootfs。Fedora 项目使用 [kickstart][4] 安装方式以及 [imagefactory][5] 来创建这些 tarball。 + +在创建 Fedora 基础镜像期间使用的 kickstart 文件可以在 Fedora 的构建系统 [Koji][6] 中找到。[Fedora-Container-Base][7] 包重新组合了所有基础镜像的构建版本。如果选择了一个构建版本,那么可以访问所有相关文件,包括 kickstart 文件。查看 [示例][8],文件末尾的 `%packages` 部分定义了要安装的所有软件包。这就是让软件放在基础镜像中的方法。 + +#### 使用 rootfs 构建基础镜像 + +rootfs 完成后,构建基础镜像就很容易了。它只需要一个包含以下指令的 Dockerfile: + +``` +FROM scratch +ADD layer.tar / +CMD ["/bin/bash"] +``` + +这里的重要部分是 `FROM scratch` 指令,它会创建一个空镜像。然后,接下来的指令将 rootfs 添加到镜像,并设置在运行镜像时要执行的默认命令。 + +让我们使用 Koji 内置的 Fedora rootfs 构建一个基础镜像: + +``` +$ curl -o fedora-rootfs.tar.xz https://kojipkgs.fedoraproject.org/packages/Fedora-Container-Base/Rawhide/20190902.n.0/images/Fedora-Container-Base-Rawhide-20190902.n.0.x86_64.tar.xz +$ tar -xJvf fedora-rootfs.tar.xz 51c14619f9dfd8bf109ab021b3113ac598aec88870219ff457ba07bc29f5e6a2/layer.tar +$ mv 51c14619f9dfd8bf109ab021b3113ac598aec88870219ff457ba07bc29f5e6a2/layer.tar layer.tar +$ printf "FROM scratch\nADD layer.tar /\nCMD [\"/bin/bash\"]" > Dockerfile +$ podman build -t my-fedora . +$ podman run -it --rm my-fedora cat /etc/os-release +``` + +需要从下载的存档中提取包含 rootfs 的 `layer.tar` 文件。这在 Fedora 生成的镜像已经可以被容器运行时使用才需要。 + +因此,使用 Fedora 生成的镜像,获得基础镜像会更容易。让我们看看它是如何工作的: + +``` +$ curl -O https://kojipkgs.fedoraproject.org/packages/Fedora-Container-Base/Rawhide/20190902.n.0/images/Fedora-Container-Base-Rawhide-20190902.n.0.x86_64.tar.xz +$ podman load --input Fedora-Container-Base-Rawhide-20190902.n.0.x86_64.tar.xz +$ podman run -it --rm localhost/fedora-container-base-rawhide-20190902.n.0.x86_64:latest cat /etc/os-release +``` + +### 构建分层镜像 + +要构建使用 Fedora 基础镜像的分层镜像,只需在 `FROM` 行指令中指定 `fedora`: + +``` +FROM fedora:latest +``` + +`latest` 标记引用了最新的 Fedora 版本(编写本文时是 Fedora 30)。但是可以使用镜像的标签来使用其他版本。例如,`FROM fedora:31` 将使用 Fedora 31 基础镜像。 + +Fedora 支持将软件作为容器来构建并发布。这意味着你可以维护 Dockerfile 来使其他人可以使用你的软件。关于在 Fedora 中成为容器镜像维护者的更多信息,请查看 [Fedora 容器指南][9]。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/how-to-build-fedora-container-images/ + +作者:[Clément Verna][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/cverna/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/08/fedoracontainers-816x345.jpg +[2]: https://linux.cn/article-10156-1.html +[3]: https://en.wikipedia.org/wiki/Tar_(computing) +[4]: https://en.wikipedia.org/wiki/Kickstart_(Linux) +[5]: http://imgfac.org/ +[6]: https://koji.fedoraproject.org/koji/ +[7]: https://koji.fedoraproject.org/koji/packageinfo?packageID=26387 +[8]: https://kojipkgs.fedoraproject.org//packages/Fedora-Container-Base/30/20190902.0/images/koji-f30-build-37420478-base.ks +[9]: https://docs.fedoraproject.org/en-US/containers/guidelines/guidelines/ diff --git a/published/20190905 How to Change Themes in Linux Mint.md b/published/20190905 How to Change Themes in Linux Mint.md new file mode 100644 index 0000000000..dd2f69b044 --- /dev/null +++ b/published/20190905 How to Change Themes in Linux Mint.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: (qfzy1233) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11359-1.html) +[#]: subject: (How to Change Themes in Linux Mint) +[#]: via: (https://itsfoss.com/install-themes-linux-mint/) +[#]: author: (It's FOSS Community https://itsfoss.com/author/itsfoss/) + +如何在 Linux Mint 中更换主题 +====== + +![](https://img.linux.net.cn/data/attachment/album/201909/19/100317ixxp3y1l7lljl47a.jpg) + +一直以来,使用 Cinnamon 桌面环境的 Linux Mint 都是一种卓越的体验。这也是[为何我喜爱 Linux Mint][1]的主要原因之一。 + +自从 Mint 的开发团队[开始更为严肃的对待设计][2], “桌面主题” 应用便成为了更换新主题、图标、按钮样式、窗口边框以及鼠标指针的重要方式,当然你也可以直接通过它安装新的主题。感兴趣么?让我们开始吧。 + +### 如何在 Linux Mint 中更换主题 + +在菜单中搜索主题并打开主题应用。 + +![Theme Applet provides an easy way of installing and changing themes][3] + +在应用中有一个“添加/删除”按钮,非常简单吧。点击它,我们可以看到按流行程度排序的 Cinnamon Spices(Cinnamon 的官方插件库)的主题。 + +![Installing new themes in Linux Mint Cinnamon][4] + +要安装主题,你所要做的就是点击你喜欢的主题,然后等待它下载。之后,主题将在应用第一页的“Desktop”选项中显示可用。只需双击已安装的主题之一就可以开始使用它。 + +![Changing themes in Linux Mint Cinnamon][5] + +下面是默认的 Linux Mint 外观: + +![Linux Mint Default Theme][6] + +这是在我更换主题之后: + +![Linux Mint with Carta Theme][7] + +所有的主题都可以在 Cinnamon Spices 网站上获得更多的信息和更大的截图,这样你就可以更好地了解你的系统的外观。 + +- [浏览 Cinnamon 主题][8] + +### 在 Linux Mint 中安装第三方主题 + +> “我在另一个网站上看到了这个优异的主题,但 Cinnamon Spices 网站上没有……” + +Cinnamon Spices 集成了许多优秀的主题,但你仍然会发现,你看到的主题并没有被 Cinnamon Spices 官方网站收录。 + +这时你可能会想:如果有别的办法就好了,对么?你可能会认为有(我的意思是……当然啦)。首先,我们可以在其他网站上找到一些很酷的主题。 + +我推荐你去 Cinnamon Look 浏览一下那儿的主题。如果你喜欢什么,就下载吧。 + +- [在 Cinnamon Look 中获取更多主题][9] + +下载了首选主题之后,你现在将得到一个压缩文件,其中包含安装所需的所有内容。提取它并保存到 `~/.themes`。迷糊么? `~` 代表了你的家目录的对应路径:`/home/{YOURUSER}/.themes`。 + +然后跳转到你的家目录。按 `Ctrl+H` 来[显示 Linux 中的隐藏文件][11]。如果没有看到 `.themes` 文件夹,创建一个新文件夹并命名为 `.themes`。记住,文件夹名称开头的点很重要。 + +将提取的主题文件夹从下载目录复制到你的家目录中的 `.themes` 文件夹中。 + +最后,在上面提到的应用中查找已安装的主题。 + +> 注记 +> +> 请记住,主题必须是 Cinnamon 相对应的,即使它是一个从 GNOME 复刻的系统也不行,并不是所有的 GNOME 主题都适用于 Cinnamon。 + +改变主题是 Cinnamon 定制工作的一部分。你还可以[通过更改图标来更改 Linux Mint 的外观][12]。 + +我希望你现在已经知道如何在 Linux Mint 中更改主题了。快去选取你喜欢的主题吧。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-themes-linux-mint/ + +作者:[It's FOSS][a] +选题:[lujun9972][b] +译者:[qfzy1233](https://github.com/qfzy1233) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/itsfoss/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/tiny-features-linux-mint-cinnamon/ +[2]: https://itsfoss.com/linux-mint-new-design/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/install-theme-linux-mint-1.jpg?resize=800%2C625&ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/install-theme-linux-mint-2.jpg?resize=800%2C625&ssl=1 +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/install-theme-linux-mint-3.jpg?resize=800%2C450&ssl=1 +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/linux-mint-default-theme.jpg?resize=800%2C450&ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/linux-mint-carta-theme.jpg?resize=800%2C450&ssl=1 +[8]: https://cinnamon-spices.linuxmint.com/themes +[9]: https://www.cinnamon-look.org/ +[10]: https://itsfoss.com/failed-to-start-session-ubuntu-14-04/ +[11]: https://itsfoss.com/hide-folders-and-show-hidden-files-in-ubuntu-beginner-trick/ +[12]: https://itsfoss.com/install-icon-linux-mint/ diff --git a/published/20190905 How to Get Average CPU and Memory Usage from SAR Reports Using the Bash Script.md b/published/20190905 How to Get Average CPU and Memory Usage from SAR Reports Using the Bash Script.md new file mode 100644 index 0000000000..87c0308360 --- /dev/null +++ b/published/20190905 How to Get Average CPU and Memory Usage from SAR Reports Using the Bash Script.md @@ -0,0 +1,207 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11352-1.html) +[#]: subject: (How to Get Average CPU and Memory Usage from SAR Reports Using the Bash Script) +[#]: via: (https://www.2daygeek.com/linux-get-average-cpu-memory-utilization-from-sar-data-report/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +如何使用 Bash 脚本从 SAR 报告中获取 CPU 和内存使用情况 +====== + +大多数 Linux 管理员使用 [SAR 报告][1]监控系统性能,因为它会收集一周的性能数据。但是,你可以通过更改 `/etc/sysconfig/sysstat` 文件轻松地将其延长到四周。同样,这段时间可以延长一个月以上。如果超过 28,那么日志文件将放在多个目录中,每月一个。 + +要将覆盖期延长至 28 天,请对 `/etc/sysconfig/sysstat` 文件做以下更改。 + +编辑 `sysstat` 文件并将 `HISTORY=7` 更改为 `HISTORY=28`。 + +在本文中,我们添加了三个 bash 脚本,它们可以帮助你在一个地方轻松查看每个数据文件的平均值。 + +我们过去加过许多有用的 shell 脚本。如果你想查看它们,请进入下面的链接。 + +* [如何使用 shell 脚本自动化日常操作][2] + +这些脚本简单明了。出于测试目的,我们仅包括两个性能指标,即 CPU 和内存。你可以修改脚本中的其他性能指标以满足你的需求。 + +### 脚本 1:从 SAR 报告中获取平均 CPU 利用率的 Bash 脚本 + +该 bash 脚本从每个数据文件中收集 CPU 平均值并将其显示在一个页面上。 + +由于是月末,它显示了 2019 年 8 月的 28 天数据。 + +``` +# vi /opt/scripts/sar-cpu-avg.sh + +#!/bin/sh + +echo "+----------------------------------------------------------------------------------+" +echo "|Average: CPU %user %nice %system %iowait %steal %idle |" +echo "+----------------------------------------------------------------------------------+" + +for file in `ls -tr /var/log/sa/sa* | grep -v sar` +do + dat=`sar -f $file | head -n 1 | awk '{print $4}'` + echo -n $dat + sar -f $file | grep -i Average | sed "s/Average://" +done + +echo "+----------------------------------------------------------------------------------+" +``` + +运行脚本后,你将看到如下输出。 + +``` +# sh /opt/scripts/sar-cpu-avg.sh + ++----------------------------------------------------------------------------------+ +|Average: CPU %user %nice %system %iowait %steal %idle | ++----------------------------------------------------------------------------------+ +08/01/2019 all 0.70 0.00 1.19 0.00 0.00 98.10 +08/02/2019 all 1.73 0.00 3.16 0.01 0.00 95.10 +08/03/2019 all 1.73 0.00 3.16 0.01 0.00 95.11 +08/04/2019 all 1.02 0.00 1.80 0.00 0.00 97.18 +08/05/2019 all 0.68 0.00 1.08 0.01 0.00 98.24 +08/06/2019 all 0.71 0.00 1.17 0.00 0.00 98.12 +08/07/2019 all 1.79 0.00 3.17 0.01 0.00 95.03 +08/08/2019 all 1.78 0.00 3.14 0.01 0.00 95.08 +08/09/2019 all 1.07 0.00 1.82 0.00 0.00 97.10 +08/10/2019 all 0.38 0.00 0.50 0.00 0.00 99.12 +. +. +. +08/29/2019 all 1.50 0.00 2.33 0.00 0.00 96.17 +08/30/2019 all 2.32 0.00 3.47 0.01 0.00 94.20 ++----------------------------------------------------------------------------------+ +``` + +### 脚本 2:从 SAR 报告中获取平均内存利用率的 Bash 脚本 + +该 bash 脚本从每个数据文件中收集内存平均值并将其显示在一个页面上。 + +由于是月末,它显示了 2019 年 8 月的 28 天数据。 + +``` +# vi /opt/scripts/sar-memory-avg.sh + +#!/bin/sh + +echo "+-------------------------------------------------------------------------------------------------------------------+" +echo "|Average: kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty |" +echo "+-------------------------------------------------------------------------------------------------------------------+" + +for file in `ls -tr /var/log/sa/sa* | grep -v sar` +do + dat=`sar -f $file | head -n 1 | awk '{print $4}'` + echo -n $dat + sar -r -f $file | grep -i Average | sed "s/Average://" +done + +echo "+-------------------------------------------------------------------------------------------------------------------+" +``` + +运行脚本后,你将看到如下输出。 + +``` +# sh /opt/scripts/sar-memory-avg.sh + ++--------------------------------------------------------------------------------------------------------------------+ +|Average: kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty | ++--------------------------------------------------------------------------------------------------------------------+ +08/01/2019 1492331 2388461 61.55 29888 1152142 1560615 12.72 1693031 380472 6 +08/02/2019 1493126 2387666 61.53 29888 1147811 1569624 12.79 1696387 373346 3 +08/03/2019 1489582 2391210 61.62 29888 1147076 1581711 12.89 1701480 370325 3 +08/04/2019 1490403 2390389 61.60 29888 1148206 1569671 12.79 1697654 373484 4 +08/05/2019 1484506 2396286 61.75 29888 1152409 1563804 12.75 1702424 374628 4 +08/06/2019 1473593 2407199 62.03 29888 1151137 1577491 12.86 1715426 371000 8 +08/07/2019 1467150 2413642 62.19 29888 1155639 1596653 13.01 1716900 372574 13 +08/08/2019 1451366 2429426 62.60 29888 1162253 1604672 13.08 1725931 376998 5 +08/09/2019 1451191 2429601 62.61 29888 1158696 1582192 12.90 1728819 371025 4 +08/10/2019 1450050 2430742 62.64 29888 1160916 1579888 12.88 1729975 370844 5 +. +. +. +08/29/2019 1365699 2515093 64.81 29888 1198832 1593567 12.99 1781733 376157 15 +08/30/2019 1361920 2518872 64.91 29888 1200785 1595105 13.00 1784556 375641 8 ++-------------------------------------------------------------------------------------------------------------------+ +``` + +### 脚本 3:从 SAR 报告中获取 CPU 和内存平均利用率的 Bash 脚本 + +该 bash 脚本从每个数据文件中收集 CPU 和内存平均值并将其显示在一个页面上。 + +该脚本与上面相比稍微不同。它在同一位置同时显示两者(CPU 和内存)平均值,而不是其他数据。 + +``` +# vi /opt/scripts/sar-cpu-mem-avg.sh + +#!/bin/bash + +for file in `ls -tr /var/log/sa/sa* | grep -v sar` +do + sar -f $file | head -n 1 | awk '{print $4}' + echo "-----------" + sar -u -f $file | awk '/Average:/{printf("CPU Average: %.2f%\n"), 100 - $8}' + sar -r -f $file | awk '/Average:/{printf("Memory Average: %.2f%\n"),(($3-$5-$6)/($2+$3)) * 100 }' + printf "\n" +done +``` + +运行脚本后,你将看到如下输出。 + +``` +# sh /opt/scripts/sar-cpu-mem-avg.sh + +08/01/2019 +----------- +CPU Average: 1.90% +Memory Average: 31.09% + +08/02/2019 +----------- +CPU Average: 4.90% +Memory Average: 31.18% + +08/03/2019 +----------- +CPU Average: 4.89% +Memory Average: 31.29% + +08/04/2019 +----------- +CPU Average: 2.82% +Memory Average: 31.24% + +08/05/2019 +----------- +CPU Average: 1.76% +Memory Average: 31.28% +. +. +. +08/29/2019 +----------- +CPU Average: 3.83% +Memory Average: 33.15% + +08/30/2019 +----------- +CPU Average: 5.80% +Memory Average: 33.19% +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-get-average-cpu-memory-utilization-from-sar-data-report/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/sar-system-performance-monitoring-command-tool-linux/ +[2]: https://www.2daygeek.com/category/shell-script/ diff --git a/published/20190905 USB4 gets final approval, offers Ethernet-like speed.md b/published/20190905 USB4 gets final approval, offers Ethernet-like speed.md new file mode 100644 index 0000000000..ade65f4a5e --- /dev/null +++ b/published/20190905 USB4 gets final approval, offers Ethernet-like speed.md @@ -0,0 +1,53 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11330-1.html) +[#]: subject: (USB4 gets final approval, offers Ethernet-like speed) +[#]: via: (https://www.networkworld.com/article/3435113/usb4-gets-final-approval-offers-ethernet-like-speed.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +USB4 规范获得最终批准,像以太网一样快! +====== + +> USB4 会是一个统一的接口,可以淘汰笨重的电缆和超大的插头,并提供满足从笔记本电脑用户到服务器管理员的每个人的吞吐量。 + +![](https://images.idgesg.net/images/article/2019/03/thunderbolt-3_intel-v2-100790083-large.jpg) + +USB 开发者论坛USB Implementers Forum(USB-IF)是通用串行总线(USB)规范开发背后的行业协会,上周宣布了它已经完成了下一代 USB4 的技术规范。 + +USB4 最重要的一个方面(它们在此版本中省略了首字母缩略词和版本号之间的空格)是它将 USB 与 Intel 设计的接口 Thunderbolt 3 融合在了一起。Thunderbolt 尽管有潜力,但在除了笔记本之外并未真正流行起来。出于这个原因,Intel 向 USB 联盟提供了 Thunderbolt 规范。 + +不幸的是,Thunderbolt 3 被列为 USB4 设备的一个可选项,因此有些设备会有,有些则不会。这无疑会让人头疼,希望所有设备制造商都会包括 Thunderbolt 3。 + +USB4 将使用与 USB type-C 相同的外形尺寸,这个小型插头用在所有现代 Android 手机和 Thunderbolt 3 中。它将向后兼容 USB 3.2、USB 2.0 以及 Thunderbolt。因此,几乎任何现有的USB type-C 设备都可以连接到具有 USB4 总线的机器,但将以连接电缆的额定速度运行。 + +### USB4:体积更小,速度更快 + +因为它支持 Thunderbolt 3,所以这种新连接将同时支持数据和显示协议,因此这可能意味着小型 USB-C 端口将取代显示器上庞大的 DVI 端口,而显示器则带有多个 USB4 端口来作为集线器。 + +新标准的主要内容:它提供双通道 40Gbps 传输速度,是当前 USB 3.2 规格的两倍,是 USB 3 的八倍。这是以太网的速度,应该足够给你的高清显示器以及其他数据传输提供充足带宽。 + +USB4 也为视频提供了更好的资源分配,因此如果你使用 USB4 端口同时传输视频和数据,端口将相应地分配带宽。这将允许计算机同时使用外部独立的 GPU(因为有 Thunderbolt 3,它已经上市 )和外部 SSD。 + +这可能会启发各种新的服务器设计,因为大型、笨重的设备,如 GPU 或其他不易放入 1U 或 2U 机箱的卡板,现在可以外部连接并以与内部设备相当的速度运行。 + +当然,我们看到配备了 USB4 端口的电脑还需要一段时间,更别说服务器了。将 USB 3 用于 PC 花费了数年时间,而 USB-C 的采用速度非常缓慢。USB 2 的 U 盘仍然是这些设备的主要市场,并且主板仍然带有 USB 2 端口。 + +尽管如此,USB4 还是有可能成为一个统一的接口,可以摆脱拥有超大插头的笨重电缆,并提供满足从笔记本电脑用户到服务器管理员的每个人的吞吐量。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3435113/usb4-gets-final-approval-offers-ethernet-like-speed.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/20190906 Great News- Firefox 69 Blocks Third-Party Cookies, Autoplay Videos - Cryptominers by Default.md b/published/20190906 Great News- Firefox 69 Blocks Third-Party Cookies, Autoplay Videos - Cryptominers by Default.md new file mode 100644 index 0000000000..9118ebe1ef --- /dev/null +++ b/published/20190906 Great News- Firefox 69 Blocks Third-Party Cookies, Autoplay Videos - Cryptominers by Default.md @@ -0,0 +1,96 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11346-1.html) +[#]: subject: (Great News! Firefox 69 Blocks Third-Party Cookies, Autoplay Videos & Cryptominers by Default) +[#]: via: (https://itsfoss.com/firefox-69/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Firefox 69 默认阻拦第三方 Cookie、自动播放的视频和加密矿工 +====== + +如果你使用的是 [Mozilla Firefox][1] 并且尚未更新到最新版本,那么你将错过许多新的重要功能。 + +### Firefox 69 版本中的一些新功能 + +首先,Mozilla Firefox 69 会默认强制执行更强大的安全和隐私选项。以下是新版本的一些主要亮点。 + +#### Firefox 69 阻拦视频自动播放 + +![][2] + +现在很多网站都提供了自动播放视频。无论是弹出视频还是嵌入在文章中设置为自动播放的视频,默认情况下,Firefox 69 都会阻止它(或者可能会提示你)。 + +这个[阻拦自动播放][3]功能可让用户自动阻止任何视频播放。 + +#### 禁止第三方跟踪 cookie + +默认情况下,作为增强型跟踪保护Enhanced Tracking Protection功能的一部分,它现在将阻止第三方跟踪 Cookie 和加密矿工。这是 Mozilla Firefox 的增强隐私保护功能的非常有用的改变。 + +Cookie 有两种:第一方的和第三方的。第一方 cookie 由网站本身拥有。这些是“好的 cookie”,可以让你保持登录、记住你的密码或输入字段等来改善浏览体验。第三方 cookie 由你访问的网站以外的域所有。广告服务器使用这些 Cookie 来跟踪你,并在你访问的所有网站上跟踪广告。Firefox 69 旨在阻止这些。 + +当它发挥作用时,你将在地址栏中看到盾牌图标。你可以选择为特定网站禁用它。 + +![Firefox Blocking Tracking][4] + +#### 禁止加密矿工消耗你的 CPU + +![][5] + +对加密货币的欲望一直困扰着这个世界。GPU 的价格已经高企,因为专业的加密矿工们使用它们来挖掘加密货币。 + +人们使用工作场所的计算机秘密挖掘加密货币。当我说工作场所时,我不一定是指 IT 公司。就在今年,[人们在乌克兰的一家核电站抓住了偷挖加密货币的活动][6]。 + +不仅如此。如果你访问某些网站,他们会运行脚本并使用你的计算机的 CPU 来挖掘加密货币。这在 IT 术语中被称为 [挖矿攻击][7]cryptojacking。 + +好消息是 Firefox 69 会自动阻止这些加密矿工脚本。因此,网站不再能利用你的系统资源进行挖矿攻击了。 + +#### Firefox 69 带来的更强隐私保护 + +![][8] + +如果你把隐私保护设置得更严格,那么它也会阻止指纹。因此,当你在 Firefox 69 中选择严格的隐私设置时,你不必担心通过[指纹][9]共享计算机的配置信息。 + +在[关于这次发布的官方博客文章][10]中,Mozilla 提到,在此版本中,他们希望默认情况下为 100% 的用户提供保护。 + +#### 性能改进 + +尽管在更新日志中没有提及 Linux,但它提到了在 Windows 10/mac OS 上运行性能、UI 和电池寿命有所改进。如果你发现任何性能改进,请在评论中提及。 + +### 总结 + +除了所有这些之外,还有很多底层的改进。你可以查看[发行说明][11]中的详细信息。 + +Firefox 69 对于关注其隐私的用户来说是一个令人印象深刻的更新。与我们最近对某些[安全电子邮件服务][12]的建议类似,我们建议你更新浏览器以充分受益。新版本已在大多数 Linux 发行版中提供,你只需要更新你的系统即可。 + +如果你对阻止广告和跟踪 Cookie 的浏览器感兴趣,请尝试[开源的 Brave 浏览器][13],他们甚至给你提供了加密货币以让你使用他们的浏览器,你可以使用这些加密货币来奖励你最喜爱的发布商。 + +你觉得这个版本怎么样?请在下面的评论中告诉我们你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/firefox-69/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/why-firefox/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/auto-block-firefox.png?ssl=1 +[3]: https://support.mozilla.org/en-US/kb/block-autoplay +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/firefox-blocking-tracking.png?ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/firefox-shield.png?ssl=1 +[6]: https://thenextweb.com/hardfork/2019/08/22/ukrainian-nuclear-powerplant-mine-cryptocurrency-state-secrets/ +[7]: https://hackernoon.com/cryptojacking-in-2019-is-not-dead-its-evolving-984b97346d16 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/firefox-secure.jpg?ssl=1 +[9]: https://clearcode.cc/blog/device-fingerprinting/ +[10]: https://blog.mozilla.org/blog/2019/09/03/todays-firefox-blocks-third-party-tracking-cookies-and-cryptomining-by-default/ +[11]: https://www.mozilla.org/en-US/firefox/69.0/releasenotes/ +[12]: https://itsfoss.com/secure-private-email-services/ +[13]: https://itsfoss.com/brave-web-browser/ diff --git a/published/20190906 How to change the color of your Linux terminal.md b/published/20190906 How to change the color of your Linux terminal.md new file mode 100644 index 0000000000..df5bd052bd --- /dev/null +++ b/published/20190906 How to change the color of your Linux terminal.md @@ -0,0 +1,200 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11324-1.html) +[#]: subject: (How to change the color of your Linux terminal) +[#]: via: (https://opensource.com/article/19/9/linux-terminal-colors) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何改变你的终端颜色 +====== + +> 使 Linux 变得丰富多彩(或单色)。 + +![](https://img.linux.net.cn/data/attachment/album/201909/10/111118bnvvcy6sntcs1s3t.jpg) + +你可以使用特殊的 ANSI 编码设置为 Linux 终端添加颜色,可以在终端命令或配置文件中动态添加,也可以在终端仿真器中使用现成的主题。无论哪种方式,你都可以黑色屏幕上找回怀旧的绿色或琥珀色文本。本文演示了如何使 Linux 变得丰富多彩(或单色)的方法。 + +### 终端的功能特性 + +现代系统的终端的颜色配置通常默认至少是 xterm-256color,但如果你尝试为终端添加颜色但未成功,则应检查你的 `TERM` 设置。 + +从历史上看,Unix 终端从字面上讲是:用户可以输入命令的共享计算机系统上实际的物理端点(终点)。它们专指通常用于远程发出命令的电传打字机(这也是我们今天在 Linux 中仍然使用 `/dev/tty` 设备的原因)。终端内置了 CRT 显示器,因此用户可以坐在办公室的终端上直接与大型机进行交互。CRT 显示器价格昂贵 —— 无论是制造还是使用控制;比担心抗锯齿和现代计算机专家理所当然认为的漂亮信息,让计算机吐出原始 ASCII 文本更容易。然而,即使在那时,技术的发展也很快,很快人们就会发现,随着新的视频显示终端的设计,他们需要新的功能特性来提供可选功能。 + +例如,1978 年发布的花哨的新 VT100 支持 ANSI 颜色,因此如果用户将终端类型识别为 vt100,则计算机可以提供彩色输出,而基本串行设备可能没有这样的选项。同样的原则适用于今天,它是由 `TERM` [环境变量][2]设定的。你可以使用 `echo` 检查你的 `TERM` 定义: + +``` +$ echo $TERM +xterm-256color +``` + +过时的(但在一些系统上仍然为了向后兼容而维护)`/etc/termcap` 文件定义了终端和打印机的功能特性。现代的版本是 `terminfo`,位于 `/etc` 或 `/usr/share` 中,具体取决于你的发行版。 这些文件列出了不同类型终端中可用的功能特性,其中许多都是由历史上的硬件定义的,如 vt100 到 vt220 的定义,以及 xterm 和 Xfce 等现代软件仿真器。大多数软件并不关心你使用的终端类型; 在极少数情况下,登录到检查兼容功能的服务器时,你可能会收到有关错误的终端类型的警告或错误。如果你的终端设置为功能特性很少的配置文件,但你知道你所使用的仿真器能够支持更多功能特性,那么你可以通过定义 `TERM` 环境变量来更改你的设置。你可以通过在 `~/.bashrc` 配置文件中导出 `TERM` 变量来完成此操作: + +``` +export TERM=xterm-256color +``` + +保存文件并重新载入设置: + +``` +$ source ~/.bashrc +``` + +### ANSI 颜色代码 + +现代终端继承了用于“元”特征的 ANSI 转义序列。这些是特殊的字符序列,终端将其解释为操作而不是字符。例如,此序列将清除屏幕,直到下一个提示符: + +``` +$ printf '\033[2J' +``` + +它不会清除你的历史信息;它只是清除终端仿真器中的屏幕,因此它是一个安全且具有示范性的 ANSI 转义序列。 + +ANSI 还具有设置终端颜色的序列。例如,键入此代码会将后续文本更改为绿色: + +``` +$ printf '\033[32m' +``` + +只要你对相同的计算机使用同一个颜色,就可以使用颜色来帮助你记住你登录的系统。例如,如果你经常通过 SSH 连接到服务器,则可以将服务器的提示符设置为绿色,以帮助你一目了然地将其与本地的提示符区分开来。 要设置绿色提示符,请在提示符前使用 ANSI 代码设置为绿色,并使用代表正常默认颜色的代码结束: + + +``` +export PS1=`printf "\033[32m$ \033[39m"` +``` + +### 前景色和背景色 + +你不仅可以设置文本的颜色。使用 ANSI 代码,你还可以控制文本的背景颜色以及做一些基本的样式。 + +例如,使用 `\033[4m`,你可以为文本加上下划线,或者使用 `\033[5m` 你可以将其设置为闪烁的文本。起初这可能看起来很愚蠢,因为你可能不会将你的终端设置为所有文本带有下划线并整天闪烁, 但它对某些功能很有用。例如,你可以将 shell 脚本生成的紧急错误设置为闪烁(作为对用户的警报),或者你可以为 URL 添加下划线。 + +作为参考,以下是前景色和背景色的代码。前景色在 30 范围内,而背景色在 40 范围内: + +颜色 | 前景色 | 背景色 +---|---|--- +黑色 | \033[30m | \033[40m +红色 | \033[31m | \033[41m +绿色 | \033[32m | \033[42m +橙色 | \033[33m | \033[43m +蓝色 | \033[34m | \033[44m +品红 | \033[35m | \033[45m +青色 | \033[36m | \033[46m +浅灰 | \033[37m | \033[47m +回退到发行版默认值 | \033[39m | \033[49m + +还有一些可用于背景的其他颜色: + +颜色 | 背景色 +---|--- +深灰 | \033[100m +浅红 | \033[101m +浅绿 | \033[102m +黄色 | \033[103m +浅蓝 | \033[104m +浅紫 | \033[105m +蓝绿 | \033[106m +白色 | \033[107m + +### 持久设置 + +在终端会话中设置颜色只是暂时的,相对无条件的。有时效果会持续几行;这是因为这种设置颜色的方法依赖于 `printf` 语句来设置一种模式,该模式仅持续到其他设置覆盖它。 + +终端仿真器通常获取使用哪种颜色的指令的方式来自于 `LS_COLORS` 环境变量的设置,该设置又由 `dircolors` 的设置填充。你可以使用 `echo` 语句查看当前设置: + +``` +$ echo $LS_COLORS +rs=0:di=38;5;33:ln=38;5;51:mh=00:pi=40; +38;5;11:so=38;5;13:do=38;5;5:bd=48;5; +232;38;5;11:cd=48;5;232;38;5;3:or=48; +5;232;38;5;9:mi=01;05;37;41:su=48;5; +196;38;5;15:sg=48;5;11;38;5;16:ca=48;5; +196;38;5;226:tw=48;5;10;38;5;16:ow=48;5; +[...] +``` + +或者你可以直接使用 `dircolors`: + +``` +$ dircolors --print-database +[...] +# image formats +.jpg 01;35 +.jpeg 01;35 +.mjpg 01;35 +.mjpeg 01;35 +.gif 01;35 +.bmp 01;35 +.pbm 01;35 +.tif 01;35 +.tiff 01;35 +[...] +``` + +这看起来很神秘。文件类型后面的第一个数字是属性代码,它有六种选择: + +* 00 无 +* 01 粗体 +* 04 下划线 +* 05 闪烁 +* 07 反白 +* 08 暗色 + +下一个数字是简化形式的颜色代码。你可以通过获取 ANSI 代码的最后一个数字来获取颜色代码(绿色前景为 32,绿色背景为 42;红色为 31 或 41,依此类推)。 + +你的发行版可能全局设置了 `LS_COLORS`,因此系统上的所有用户都会继承相同的颜色。如果你想要一组自定义的颜色,可以使用 `dircolors`。首先,生成颜色设置的本地副本: + +``` +$ dircolors --print-database > ~/.dircolors +``` + +根据需要编辑本地列表。如果你对自己的选择感到满意,请保存文件。你的颜色设置只是一个数据库,不能由 [ls][3] 直接使用,但你可以使用 `dircolors` 获取可用于设置 `LS_COLORS` 的 shellcode: + +``` +$ dircolors --bourne-shell ~/.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; +[...] +export LS_COLORS +``` + +将输出复制并粘贴到 `~/.bashrc` 文件中并重新加载。或者,你可以将该输出直接转储到 `.bashrc` 文件中并重新加载。 + +``` +$ dircolors --bourne-shell ~/.dircolors >> ~/.bashrc +$ source ~/.bashrc +``` + +你也可以在启动时使 Bash 解析 `.dircolors` 而不是手动进行转换。实际上,你可能不会经常改变颜色,所以这可能过于激进,但如果你打算改变你的配色方案,这是一个选择。在 `.bashrc` 文件中,添加以下规则: + +``` +[[ -e $HOME/.dircolors ]] && eval "`dircolors --sh $HOME/.dircolors`" +``` + +如果你的主目录中有 `.dircolors` 文件,Bash 会在启动时对其进行评估并相应地设置 `LS_COLORS`。 + +### 颜色 + +在终端中使用颜色是一种可以为你自己提供特定信息的快速视觉参考的简单方法。但是,你可能不希望过于依赖它们。毕竟,颜色不是通用的,所以如果其他人使用你的系统,他们可能不会像你那样看懂颜色代表的含义。此外,如果你使用各种工具与计算机进行交互,你可能还会发现某些终端或远程连接无法提供你期望的颜色(或根本不提供颜色)。 + +除了上述警示之外,颜色在某些工作流程中可能很有用且很有趣,因此创建一个 `.dircolor` 数据库并根据你的想法对其进行自定义吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/linux-terminal-colors + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/freedos.png?itok=aOBLy7Ky (4 different color terminal windows with code) +[2]: https://opensource.com/article/19/8/what-are-environment-variables +[3]: https://opensource.com/article/19/7/master-ls-command diff --git a/published/20190906 How to put an HTML page on the internet.md b/published/20190906 How to put an HTML page on the internet.md new file mode 100644 index 0000000000..8e5e283364 --- /dev/null +++ b/published/20190906 How to put an HTML page on the internet.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11374-1.html) +[#]: subject: (How to put an HTML page on the internet) +[#]: via: (https://jvns.ca/blog/2019/09/06/how-to-put-an-html-page-on-the-internet/) +[#]: author: (Julia Evans https://jvns.ca/) + +如何在互联网放置 HTML 页面 +====== + +![](https://img.linux.net.cn/data/attachment/album/201909/22/234957mmzoie1imufsuwea.jpg) + +我喜欢互联网的一点是在互联网放置静态页面是如此简单。今天有人问我该怎么做,所以我想我会快速地写下来! + +### 只是一个 HTML 页面 + +我的所有网站都只是静态 HTML 和 CSS。我的网页设计技巧相对不高( 是我自己开发的最复杂的网站),因此保持我所有的网站相对简单意味着我可以做一些改变/修复,而不会花费大量时间。 + +因此,我们将在此文章中采用尽可能简单的方式 —— 只需一个 HTML 页面。 + +### HTML 页面 + +我们要放在互联网上的网站只是一个名为 `index.html` 的文件。你可以在 找到它,它是一个 Github 仓库,其中只包含一个文件。 + +HTML 文件中包含一些 CSS,使其看起来不那么无聊,部分复制自 。 + +### 如何将 HTML 页面放在互联网上 + +有以下几步: + + 1. 注册 [Neocities][1] 帐户 + 2. 将 index.html 复制到你自己 neocities 站点的 index.html 中 + 3. 完成 + +上面的 `index.html` 页面位于 [julia-example-website.neocities.com][2] 中,如果你查看源代码,你将看到它与 github 仓库中的 HTML 相同。 + +我认为这可能是将 HTML 页面放在互联网上的最简单的方法(这是一次回归 Geocities,它是我在 2003 年制作我的第一个网站的方式):)。我也喜欢 Neocities (像 [glitch][3],我也喜欢)它能实验、学习,并有乐趣。 + +### 其他选择 + +这绝不是唯一简单的方式,在你推送 Git 仓库时,Github pages 和 Gitlab pages 以及 Netlify 都将会自动发布站点,并且它们都非常易于使用(只需将它们连接到你的 GitHub 仓库即可)。我个人使用 Git 仓库的方式,因为 Git 不会让我感到紧张,我想知道我实际推送的页面发生了什么更改。但我想你如果第一次只想将 HTML/CSS 制作的站点放到互联网上,那么 Neocities 就是一个非常好的方法。 + +如果你不只是玩,而是要将网站用于真实用途,那么你或许会需要买一个域名,以便你将来可以更改托管服务提供商,但这有点不那么简单。 + +### 这是学习 HTML 的一个很好的起点 + +如果你熟悉在 Git 中编辑文件,同时想练习 HTML/CSS 的话,我认为将它放在网站中是一个有趣的方式!我真的很喜欢它的简单性 —— 实际上这只有一个文件,所以没有其他花哨的东西需要去理解。 + +还有很多方法可以复杂化/扩展它,比如这个博客实际上是用 [Hugo][4] 生成的,它生成了一堆 HTML 文件并放在网络中,但从基础开始总是不错的。 + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/09/06/how-to-put-an-html-page-on-the-internet/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://neocities.org/ +[2]: https://julia-example-website.neocities.org/ +[3]: https://glitch.com +[4]: https://gohugo.io/ diff --git a/published/20190909 Firefox 69 available in Fedora.md b/published/20190909 Firefox 69 available in Fedora.md new file mode 100644 index 0000000000..79249a373f --- /dev/null +++ b/published/20190909 Firefox 69 available in Fedora.md @@ -0,0 +1,63 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11354-1.html) +[#]: subject: (Firefox 69 available in Fedora) +[#]: via: (https://fedoramagazine.org/firefox-69-available-in-fedora/) +[#]: author: (Paul W. Frields https://fedoramagazine.org/author/pfrields/) + +Firefox 69 已可在 Fedora 中获取 +====== + +![][1] + +当你安装 Fedora Workstation 时,你会发现它包括了世界知名的 Firefox 浏览器。 Mozilla 基金会以开发 Firefox 以及其他促进开放、安全和隐私的互联网项目为己任。Firefox 有快速的浏览引擎和大量的隐私功能。 + +开发者社区不断改进和增强 Firefox。最新版本 Firefox 69 于最近发布,你可在稳定版 Fedora 系统(30 及更高版本)中获取它。继续阅读以获得更多详情。 + +### Firefox 69 中的新功能 + +最新版本的 Firefox 包括[增强跟踪保护][2]Enhanced Tracking Protection(ETP)。当你使用带有新(或重置)配置文件的 Firefox 69 时,浏览器会使网站更难以跟踪你的信息或滥用你的计算机资源。 + +例如,不太正直的网站使用脚本让你的系统进行大量计算来产生加密货币,这称为[加密挖矿][3]cryptomining。加密挖矿在你不知情或未经许可的情况下发生,因此是对你的系统的滥用。Firefox 69 中的新标准设置可防止网站遭受此类滥用。 + +Firefox 69 还有其他设置,可防止识别或记录你的浏览器指纹,以供日后使用。这些改进为你提供了额外的保护,免于你的活动被在线追踪。 + +另一个常见的烦恼是在没有提示的情况下播放视频。视频播放也会占用更多的 CPU,你可能不希望未经许可就在你的笔记本上发生这种情况。Firefox 使用[阻止自动播放][4]Block Autoplay这个功能阻止了这种情况的发生。而 Firefox 69 还允许你停止静默开始播放的视频。此功能可防止不必要的突然的噪音。它还解决了更多真正的问题 —— 未经许可使用计算机资源。 + +新版本中还有许多其他新功能。在 [Firefox 发行说明][5]中阅读有关它们的更多信息。 + +### 如何获得更新 + +Firefox 69 存在于稳定版 Fedora 30、预发布版 Fedora 31 和 Rawhide 仓库中。该更新由 Fedora 的 Firefox 包维护者提供。维护人员还确保更新了 Mozilla 的网络安全服务(nss 包)。我们感谢 Mozilla 项目和 Firefox 社区在提供此新版本方面的辛勤工作。 + +如果你使用的是 Fedora 30 或更高版本,请在 Fedora Workstation 上使用*软件中心*,或在任何 Fedora 系统上运行以下命令: + +``` +$ sudo dnf --refresh upgrade firefox +``` + +如果你使用的是 Fedora 29,请[帮助测试更新][6],这样它可以变得稳定,让所有用户可以轻松使用。 + +Firefox 可能会提示你升级个人设置以使用新设置。要使用新功能,你应该这样做。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/firefox-69-available-in-fedora/ + +作者:[Paul W. Frields][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/09/firefox-v69-816x345.jpg +[2]: https://blog.mozilla.org/blog/2019/09/03/todays-firefox-blocks-third-party-tracking-cookies-and-cryptomining-by-default/ +[3]: https://www.webopedia.com/TERM/C/cryptocurrency-mining.html +[4]: https://support.mozilla.org/kb/block-autoplay +[5]: https://www.mozilla.org/en-US/firefox/69.0/releasenotes/ +[6]: https://bodhi.fedoraproject.org/updates/FEDORA-2019-89ae5bb576 diff --git a/published/20190909 How to Install Shutter Screenshot Tool in Ubuntu 19.04.md b/published/20190909 How to Install Shutter Screenshot Tool in Ubuntu 19.04.md new file mode 100644 index 0000000000..fd526ef267 --- /dev/null +++ b/published/20190909 How to Install Shutter Screenshot Tool in Ubuntu 19.04.md @@ -0,0 +1,88 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11335-1.html) +[#]: subject: (How to Install Shutter Screenshot Tool in Ubuntu 19.04) +[#]: via: (https://itsfoss.com/install-shutter-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu 19.04 中安装 Shutter 截图工具 +====== + +Shutter 是我在 [Linux 中最喜欢的截图工具][1]。你可以使用它截图,还可以用它编辑截图或其他图像。它是一个在图像上添加箭头和文本的不错的工具。你也可以使用它在 Ubuntu 或其它你使用的发行版中[调整图像大小][2]。FOSS 上大多数截图教程都使用 Shutter 编辑。 + +![Install Shutter Ubuntu][8] + + +虽然 [Shutter][4] 一直是一款很棒的工具,但它的开发却停滞了。这几年来一直没有新版本的 Shutter。甚至像 [Shutter 中编辑模式被禁用][5]这样的简单 bug 也没有修复。根本没有开发者的消息。 + +也许这就是为什么新版本的 Ubuntu 放弃它的原因。在 Ubuntu 18.04 LTS 之前,你可以在软件中心,或者[启用 universe 仓库][7]来[使用 apt-get 命令][6]安装它。但是从 Ubuntu 18.10 及更高版本开始,你就不能再这样做了。 + +抛开这些缺点,Shutter 是一个很好的工具,我想继续使用它。也许你也是像我这样的 Shutter 粉丝,并且想要使用它。好的方面是你仍然可以在 Ubuntu 19.04 中安装 Shutter,这要归功于非官方 PPA。 + +### 在 Ubuntu 19.04 上安装 Shutter + +![][3] + +我希望你了解 PPA 的概念。如果不了解,我强烈建议阅读我的指南,以了解更多关于[什么是 PPA 以及如何使用它][9]。 + +现在,打开终端并使用以下命令添加新仓库: + +``` +sudo add-apt-repository -y ppa:linuxuprising/shutter +``` + +不需要再使用 `apt update`,因为从 Ubuntu 18.04 开始,仓库会在添加新条目后自动更新。 + +现在使用 `apt` 命令安装 Shutter: + +``` +sudo apt install shutter +``` + +完成。你应该已经安装 Shutter 截图工具。你可从菜单搜索并启动它。 + +### 删除通过非官方 PPA 安装的 Shutter + +最后我以卸载 Shutter 以及删除添加的仓库来结束教程。 + +首先,从系统中删除 Shutter: + +``` +sudo apt remove shutter +``` + +接下来,从你的仓库列表中删除 PPA: + +``` +sudo add-apt-repository --remove ppa:linuxuprising/shutter +``` + +你或许还想了解 [Y PPA Manager][11],这是一款 PPA 图形管理工具。 + +Shutter 是一个很好的工具,我希望它能被积极开发。我希望它的开发人员没问题,他/她可以找一些时间来处理它。或者是时候让其他人分叉并继续让它变得更棒。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-shutter-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/take-screenshot-linux/ +[2]: https://itsfoss.com/resize-images-with-right-click/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/08/shutter-screenshot.jpg?ssl=1 +[4]: http://shutter-project.org/ +[5]: https://itsfoss.com/shutter-edit-button-disabled/ +[6]: https://itsfoss.com/apt-get-linux-guide/ +[7]: https://itsfoss.com/ubuntu-repositories/ +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/Install-Shutter-ubuntu.jpg?resize=800%2C450&ssl=1 +[9]: https://itsfoss.com/ppa-guide/ +[11]: https://itsfoss.com/y-ppa-manager/ diff --git a/published/20190911 How to set up a TFTP server on Fedora.md b/published/20190911 How to set up a TFTP server on Fedora.md new file mode 100644 index 0000000000..bdd7ab6f0d --- /dev/null +++ b/published/20190911 How to set up a TFTP server on Fedora.md @@ -0,0 +1,175 @@ +[#]: collector: (lujun9972) +[#]: translator: (amwps290) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11371-1.html) +[#]: subject: (How to set up a TFTP server on Fedora) +[#]: via: (https://fedoramagazine.org/how-to-set-up-a-tftp-server-on-fedora/) +[#]: author: (Curt Warfield https://fedoramagazine.org/author/rcurtiswarfield/) + +如何在 Fedora 上建立一个 TFTP 服务器 +====== + +![][1] + +TFTP 即简单文本传输协议Trivial File Transfer Protocol,允许用户通过 [UDP][2] 协议在系统之间传输文件。默认情况下,协议使用的是 UDP 的 69 号端口。TFTP 协议广泛用于无盘设备的远程启动。因此,在你的本地网络建立一个 TFTP 服务器,这样你就可以对 [安装好的 Fedora][3] 和其他无盘设备做一些操作,这将非常有趣。 + +TFTP 仅仅能够从远端系统读取数据或者向远端系统写入数据,而没有列出远端服务器上文件的能力。它也没提供用户身份验证。由于安全隐患和缺乏高级功能,TFTP 通常仅用于局域网内部(LAN)。 + +### 安装 TFTP 服务器 + +首先你要做的事就是安装 TFTP 客户端和 TFTP 服务器: + +``` +dnf install tftp-server tftp -y +``` + +上述的这条命令会在 `/usr/lib/systemd/system` 目录下为 [systemd][4] 创建 `tftp.service` 和 `tftp.socket` 文件。 + +``` +/usr/lib/systemd/system/tftp.service +/usr/lib/systemd/system/tftp.socket +``` + +接下来,将这两个文件复制到 `/etc/systemd/system` 目录下,并重新命名。 + +``` +cp /usr/lib/systemd/system/tftp.service /etc/systemd/system/tftp-server.service +cp /usr/lib/systemd/system/tftp.socket /etc/systemd/system/tftp-server.socket +``` + +### 修改文件 + +当你把这些文件复制和重命名后,你就可以去添加一些额外的参数,下面是 `tftp-server.service` 刚开始的样子: + +``` +[Unit] +Description=Tftp Server +Requires=tftp.socket +Documentation=man:in.tftpd + +[Service] +ExecStart=/usr/sbin/in.tftpd -s /var/lib/tftpboot +StandardInput=socket + +[Install] +Also=tftp.socket +``` + +在 `[Unit]` 部分添加如下内容: + +``` +Requires=tftp-server.socket +``` + +修改 `[ExecStart]` 行: + +``` +ExecStart=/usr/sbin/in.tftpd -c -p -s /var/lib/tftpboot +``` + +下面是这些选项的意思: + + * `-c` 选项允许创建新的文件 + * `-p` 选项用于指明在正常系统提供的权限检查之上没有其他额外的权限检查 + * `-s` 建议使用该选项以确保安全性以及与某些引导 ROM 的兼容性,这些引导 ROM 在其请求中不容易包含目录名。 + +默认的上传和下载位置位于 `/var/lib/tftpboot`。 + +下一步,修改 `[Install]` 部分的内容 + +``` +[Install] +WantedBy=multi-user.target +Also=tftp-server.socket +``` + +不要忘记保存你的修改。 + +下面是 `/etc/systemd/system/tftp-server.service` 文件的完整内容: + +``` +[Unit] +Description=Tftp Server +Requires=tftp-server.socket +Documentation=man:in.tftpd + +[Service] +ExecStart=/usr/sbin/in.tftpd -c -p -s /var/lib/tftpboot +StandardInput=socket + +[Install] +WantedBy=multi-user.target +Also=tftp-server.socket +``` + +### 启动 TFTP 服务器 + +重新启动 systemd 守护进程: + +``` +systemctl daemon-reload +``` + +启动服务器: + +``` +systemctl enable --now tftp-server +``` + +要更改 TFTP 服务器允许上传和下载的权限,请使用此命令。注意 TFTP 是一种固有的不安全协议,因此不建议你在与其他人共享的网络上这样做。 + +``` +chmod 777 /var/lib/tftpboot +``` + +配置防火墙让 TFTP 能够使用: + +``` +firewall-cmd --add-service=tftp --perm +firewall-cmd --reload +``` + +### 客户端配置 + +安装 TFTP 客户端 + +``` +yum install tftp -y +``` + +运行 `tftp` 命令连接服务器。下面是一个启用详细信息选项的例子: + +``` +[client@thinclient:~ ]$ tftp 192.168.1.164 +tftp> verbose +Verbose mode on. +tftp> get server.logs +getting from 192.168.1.164:server.logs to server.logs [netascii] +Received 7 bytes in 0.0 seconds [inf bits/sec] +tftp> quit +[client@thinclient:~ ]$ +``` + +记住,因为 TFTP 没有列出服务器上文件的能力,因此,在你使用 `get` 命令之前需要知道文件的具体名称。 + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/how-to-set-up-a-tftp-server-on-fedora/ + +作者:[Curt Warfield][a] +选题:[lujun9972][b] +译者:[amwps290](https://github.com/amwps290) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/rcurtiswarfield/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/09/tftp-server-816x345.jpg +[2]: https://en.wikipedia.org/wiki/User_Datagram_Protocol +[3]: https://docs.fedoraproject.org/en-US/fedora/f30/install-guide/advanced/Network_based_Installations/ +[4]: https://fedoramagazine.org/systemd-getting-a-grip-on-units/ +[5]: https://unsplash.com/@laikanotebooks?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[6]: https://unsplash.com/search/photos/file-folders?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/20190912 Bash Script to Send a Mail About New User Account Creation.md b/published/20190912 Bash Script to Send a Mail About New User Account Creation.md new file mode 100644 index 0000000000..849d7c5597 --- /dev/null +++ b/published/20190912 Bash Script to Send a Mail About New User Account Creation.md @@ -0,0 +1,116 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11362-1.html) +[#]: subject: (Bash Script to Send a Mail About New User Account Creation) +[#]: via: (https://www.2daygeek.com/linux-shell-script-to-monitor-user-creation-send-email/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +用 Bash 脚本发送新用户帐户创建的邮件 +====== + +![](https://img.linux.net.cn/data/attachment/album/201909/20/093308a615tcuiopctvp5t.jpg) + +出于某些原因,你可能需要跟踪 Linux 上的新用户创建信息。同时,你可能需要通过邮件发送详细信息。这或许是审计目标的一部分,或者安全团队出于跟踪目的可能希望对此进行监控。 + +我们可以通过其他方式进行此操作,正如我们在上一篇文章中已经描述的那样。 + +* [在系统中创建新用户帐户时发送邮件的 Bash 脚本][1] + +Linux 有许多开源监控工具可以使用。但我不认为他们有办法跟踪新用户创建过程,并在发生时提醒管理员。 + +那么我们怎样才能做到这一点? + +我们可以编写自己的 Bash 脚本来实现这一目标。我们过去写过许多有用的 shell 脚本。如果你想了解,请进入下面的链接。 + +* [如何使用 shell 脚本自动化日常活动?][2] + +### 这个脚本做了什么? + +这将每天两次(一天的开始和结束)备份 `/etc/passwd` 文件,这将使你能够获取指定日期的新用户创建详细信息。 + +我们需要添加以下两个 cron 任务来复制 `/etc/passwd` 文件。 + +``` +# crontab -e + +1 0 * * * cp /etc/passwd /opt/scripts/passwd-start-$(date +"%Y-%m-%d") +59 23 * * * cp /etc/passwd /opt/scripts/passwd-end-$(date +"%Y-%m-%d") +``` + +它使用 `diff` 命令来检测文件之间的差异,如果发现与昨日有任何差异,脚本将向指定 email 发送新用户详细信息。 + +我们不用经常运行此脚本,因为用户创建不经常发生。但是,我们计划每天运行一次此脚本。 + +这样,你可以获得有关新用户创建的综合报告。 + +**注意:**我们在脚本中使用了我们的电子邮件地址进行演示。因此,我们要求你用自己的电子邮件地址。 + +``` +# vi /opt/scripts/new-user-detail.sh + +#!/bin/bash +mv /opt/scripts/passwd-start-$(date --date='yesterday' '+%Y-%m-%d') /opt/scripts/passwd-start +mv /opt/scripts/passwd-end-$(date --date='yesterday' '+%Y-%m-%d') /opt/scripts/passwd-end +ucount=$(diff /opt/scripts/passwd-start /opt/scripts/passwd-end | grep ">" | cut -d":" -f6 | cut -d"/" -f3 | wc -l) +if [ $ucount -gt 0 ] +then + SUBJECT="ATTENTION: New User Account is created on server : `date --date='yesterday' '+%b %e'`" + MESSAGE="/tmp/new-user-logs.txt" + TO="2daygeek@gmail.com" + echo "Hostname: `hostname`" >> $MESSAGE + echo -e "\n" >> $MESSAGE + echo "The New User Details are below." >> $MESSAGE + echo "+------------------------------+" >> $MESSAGE + diff /opt/scripts/passwd-start /opt/scripts/passwd-end | grep ">" | cut -d":" -f6 | cut -d"/" -f3 >> $MESSAGE + echo "+------------------------------+" >> $MESSAGE + mail -s "$SUBJECT" "$TO" < $MESSAGE + rm $MESSAGE +fi +``` + +给 `new-user-detail.sh` 文件添加可执行权限。 + +``` +$ chmod +x /opt/scripts/new-user-detail.sh +``` + +最后添加一个 cron 任务来自动执行此操作。它在每天早上 7 点运行。 + +``` +# crontab -e + +0 7 * * * /bin/bash /opt/scripts/new-user.sh +``` + +**注意:**你会在每天早上 7 点都会收到一封关于昨日详情的邮件提醒。 + +**输出:**输出与下面的输出相同。 + +``` +# cat /tmp/new-user-logs.txt + +Hostname: CentOS.2daygeek.com + +The New User Details are below. ++------------------------------+ +tuser3 ++------------------------------+ +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-shell-script-to-monitor-user-creation-send-email/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/linux-bash-script-to-monitor-user-creation-send-email/ +[2]: https://www.2daygeek.com/category/shell-script/ diff --git a/published/20190913 An introduction to Virtual Machine Manager.md b/published/20190913 An introduction to Virtual Machine Manager.md new file mode 100644 index 0000000000..aa452f418a --- /dev/null +++ b/published/20190913 An introduction to Virtual Machine Manager.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11364-1.html) +[#]: subject: (An introduction to Virtual Machine Manager) +[#]: via: (https://opensource.com/article/19/9/introduction-virtual-machine-manager) +[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss) + +虚拟机管理器(Virtual Machine Manager)简介 +====== + +> virt-manager 为 Linux 虚拟化提供了全方位的选择。 + +![](https://img.linux.net.cn/data/attachment/album/201909/20/113434dxbbp3ttmxbhmnnm.jpg) + +在我关于 [GNOME Boxes][3] 的[系列文章][2]中,我已经解释了 Linux 用户如何能够在他们的桌面上快速启动虚拟机。当你只需要简单的配置时,Box 可以轻而易举地创建虚拟机。 + +但是,如果你需要在虚拟机中配置更多详细信息,那么你就需要一个工具,为磁盘、网卡(NIC)和其他硬件提供全面的选项。这时就需要 [虚拟机管理器(Virtual Machine Manager)][4](virt-manager)了。如果在应用菜单中没有看到它,你可以从包管理器或命令行安装它: + +* 在 Fedora 上:`sudo dnf install virt-manager` +* 在 Ubuntu 上:`sudo apt install virt-manager` + +安装完成后,你可以从应用菜单或在命令行中输入 `virt-manager` 启动。 + +![Virtual Machine Manager's main screen][5] + +为了演示如何使用 virt-manager 创建虚拟机,我将设置一个 Red Hat Enterprise Linux 8 虚拟机。 + +首先,单击 “文件File” 然后点击 “新建虚拟机New Virtual Machine”。Virt-manager 的开发者已经标记好了每一步(例如,“第 1 步,共 5 步Step 1 of 5”)来使其变得简单。单击 “本地安装介质Local install media” 和 “下一步Forward”。 + +![Step 1 virtual machine creation][6] + +在下个页面中,选择要安装的操作系统的 ISO 文件。(RHEL 8 镜像位于我的下载目录中。)Virt-manager 自动检测操作系统。 + +![Step 2 Choose the ISO File][7] + +在步骤 3 中,你可以指定虚拟机的内存和 CPU。默认值为内存 1,024MB 和一个 CPU。 + +![Step 3 Set CPU and Memory][8] + +我想给 RHEL 充足的配置来运行,我使用的硬件配置也充足,所以我将它们(分别)增加到 4,096MB 和两个 CPU。 + +下一步为虚拟机配置存储。默认设置是 10GB 硬盘。(我保留此设置,但你可以根据需要进行调整。)你还可以选择现有磁盘镜像或在自定义位置创建一个磁盘镜像。 + +![Step 4 Configure VM Storage][9] + +步骤 5 是命名虚拟机并单击“完成Finish”。这相当于创建了一台虚拟机,也就是 GNOME Boxes 中的一个 Box。虽然技术上讲是最后一步,但你有几个选择(如下面的截图所示)。由于 virt-manager 的优点是能够自定义虚拟机,因此在单击“完成Finish”之前,我将选中“在安装前定制配置Customize configuration before install”的复选框。 + +因为我选择了自定义配置,virt-manager 打开了一个有一组设备和设置的页面。这里是重点! + +这里你也可以命名该虚拟机。在左侧列表中,你可以查看各个方面的详细信息,例如 CPU、内存、磁盘、控制器和许多其他项目。例如,我可以单击 “CPU” 来验证我在步骤 3 中所做的更改。 + +![Changing the CPU count][10] + +我也可以确认我设置的内存量。 + +当虚拟机作为服务器运行时,我通常会禁用或删除声卡。为此,请选择 “声卡Sound” 并单击 “移除Remove” 或右键单击 “声卡Sound” 并选择 “移除硬件Remove Hardware”。 + +你还可以使用底部的 “添加硬件Add Hardware” 按钮添加硬件。这会打开 “添加新的虚拟硬件Add New Virtual Hardware” 页面,你可以在其中添加其他存储设备、内存、声卡等。这就像可以访问一个库存充足的(虚拟)计算机硬件仓库。 + +![The Add New Hardware screen][11] + +对 VM 配置感到满意后,单击 “开始安装Begin Installation”,系统将启动并开始从 ISO 安装指定的操作系统。 + +![Begin installing the OS][12] + +完成后,它会重新启动,你的新虚拟机就可以使用了。 + +![Red Hat Enterprise Linux 8 running in VMM][13] + +Virtual Machine Manager 是桌面 Linux 用户的强大工具。它是开源的,是专有和封闭虚拟化产品的绝佳替代品。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/introduction-virtual-machine-manager + +作者:[Alan Formy-Duval][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alanfdoss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming) +[2]: https://opensource.com/sitewide-search?search_api_views_fulltext=GNOME%20Box +[3]: https://wiki.gnome.org/Apps/Boxes +[4]: https://virt-manager.org/ +[5]: https://opensource.com/sites/default/files/1-vmm_main_0.png (Virtual Machine Manager's main screen) +[6]: https://opensource.com/sites/default/files/2-vmm_step1_0.png (Step 1 virtual machine creation) +[7]: https://opensource.com/sites/default/files/3-vmm_step2.png (Step 2 Choose the ISO File) +[8]: https://opensource.com/sites/default/files/4-vmm_step3default.png (Step 3 Set CPU and Memory) +[9]: https://opensource.com/sites/default/files/6-vmm_step4.png (Step 4 Configure VM Storage) +[10]: https://opensource.com/sites/default/files/9-vmm_customizecpu.png (Changing the CPU count) +[11]: https://opensource.com/sites/default/files/11-vmm_addnewhardware.png (The Add New Hardware screen) +[12]: https://opensource.com/sites/default/files/12-vmm_rhelbegininstall.png +[13]: https://opensource.com/sites/default/files/13-vmm_rhelinstalled_0.png (Red Hat Enterprise Linux 8 running in VMM) diff --git a/published/20190913 How to Find and Replace a String in File Using the sed Command in Linux.md b/published/20190913 How to Find and Replace a String in File Using the sed Command in Linux.md new file mode 100644 index 0000000000..d49a5146b9 --- /dev/null +++ b/published/20190913 How to Find and Replace a String in File Using the sed Command in Linux.md @@ -0,0 +1,346 @@ +[#]: collector: (lujun9972) +[#]: translator: (asche910) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11367-1.html) +[#]: subject: (How to Find and Replace a String in File Using the sed Command in Linux) +[#]: via: (https://www.2daygeek.com/linux-sed-to-find-and-replace-string-in-files/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +使用 sed 命令查找和替换文件中的字符串的 16 个示例 +====== + +![](https://img.linux.net.cn/data/attachment/album/201909/20/210723xf884pafyzf9zf4a.jpg) + +当你在使用文本文件时,很可能需要查找和替换文件中的字符串。`sed` 命令主要用于替换一个文件中的文本。在 Linux 中这可以通过使用 `sed` 命令和 `awk` 命令来完成。 + +在本教程中,我们将告诉你使用 `sed` 命令如何做到这一点,然后讨论讨论 `awk` 命令相关的。 + +### sed 命令是什么 + +`sed` 命令表示 Stream Editor(流编辑器),用来在 Linux 上执行基本的文本操作。它可以执行各种功能,如搜索、查找、修改、插入或删除文件。 + +此外,它也可以执行复杂的正则表达式匹配。 + +它可用于以下目的: + +* 查找和替换匹配给定的格式的内容。 +* 在指定行查找和替换匹配给定的格式的内容。 +* 在所有行查找和替换匹配给定的格式的内容。 +* 搜索并同时替换两种不同的模式。 + +本文列出的十五个例子可以帮助你掌握 `sed` 命令。 + +如果要使用 `sed` 命令删除文件中的行,去下面的文章。 + +注意:由于这是一篇演示文章,我们使用不带 `-i` 选项的 `sed` 命令,该选项会在 Linux 终端中删除行并打印文件内容。 + +但是,在实际环境中如果你想删除源文件中的行,使用带 `-i` 选项的 `sed` 命令。 + +常见的 `sed` 替换字符串的语法。 + +``` +sed -i 's/Search_String/Replacement_String/g' Input_File +``` + +首先我们需要了解 `sed` 语法来做到这一点。请参阅有关的细节。 + +* `sed`:这是一个 Linux 命令。 +* `-i`:这是 `sed` 命令的一个选项,它有什么作用?默认情况下,`sed` 打印结果到标准输出。当你使用 `sed` 添加这个选项时,那么它会在适当的位置修改文件。当你添加一个后缀(比如,`-i.bak`)时,就会创建原始文件的备份。 +* `s`:字母 `s` 是一个替换命令。 +* `Search_String`:搜索一个给定的字符串或正则表达式。 +* `Replacement_String`:替换的字符串。 +* `g`:全局替换标志。默认情况下,`sed` 命令替换每一行第一次出现的模式,它不会替换行中的其他的匹配结果。但是,提供了该替换标志时,所有匹配都将被替换。 +* `/`:分界符。 +* `Input_File`:要执行操作的文件名。 + +让我们来看看文件中用sed命令来搜索和转换文本的一些常用例子。 + +我们已经创建了用于演示的以下文件。 + +``` +# cat sed-test.txt + +1 Unix unix unix 23 +2 linux Linux 34 +3 linuxunix UnixLinux +linux /bin/bash CentOS Linux OS +Linux is free and opensource operating system +``` + +### 1) 如何查找和替换一行中“第一次”模式匹配 + +下面的 `sed` 命令用 `linux` 替换文件中的 `unix`。这仅仅改变了每一行模式的第一个实例。 + +``` +# sed 's/unix/linux/' sed-test.txt + +1 Unix linux unix 23 +2 linux Linux 34 +3 linuxlinux UnixLinux +linux /bin/bash CentOS Linux OS +Linux is free and opensource operating system +``` + +### 2) 如何查找和替换每一行中“第 N 次”出现的模式 + +在行中使用`/1`、`/2`……`/n` 等标志来代替相应的匹配。 + +下面的 `sed` 命令在一行中用 `linux` 来替换 `unix` 模式的第二个实例。 + +``` +# sed 's/unix/linux/2' sed-test.txt + +1 Unix unix linux 23 +2 linux Linux 34 +3 linuxunix UnixLinux +linux /bin/bash CentOS Linux OS +Linux is free and opensource operating system +``` + +### 3) 如何搜索和替换一行中所有的模式实例 + +下面的 `sed` 命令用 `linux` 替换 `unix` 格式的所有实例,因为 `g` 是一个全局替换标志。 + +``` +# sed 's/unix/linux/g' sed-test.txt + +1 Unix linux linux 23 +2 linux Linux 34 +3 linuxlinux UnixLinux +linux /bin/bash CentOS Linux OS +Linux is free and opensource operating system +``` + +### 4) 如何查找和替换一行中从“第 N 个”开始的所有匹配的模式实例 + +下面的 `sed` 命令在一行中替换从模式的“第 N 个”开始的匹配实例。 + +``` +# sed 's/unix/linux/2g' sed-test.txt + +1 Unix unix linux 23 +2 linux Linux 34 +3 linuxunix UnixLinux +linux /bin/bash CentOS Linux OS +Linux is free and opensource operating system +``` + +### 5) 在特定的行号搜索和替换模式 + +你可以替换特定行号中的字符串。下面的 `sed` 命令用 `linux` 仅替换第三行的 `unix` 模式。 + +``` +# sed '3 s/unix/linux/' sed-test.txt + +1 Unix unix unix 23 +2 linux Linux 34 +3 linuxlinux UnixLinux +linux /bin/bash CentOS Linux OS +Linux is free and opensource operating system +``` + +### 6) 在特定范围行号间搜索和替换模式 + +你可以指定行号的范围,以替换字符串。 + +下面的 `sed` 命令在 1 到 3 行间用 `linux` 替换 `Unix` 模式。 + +``` +# sed '1,3 s/unix/linux/' sed-test.txt + +1 Unix linux unix 23 +2 linux Linux 34 +3 linuxlinux UnixLinux +linux /bin/bash CentOS Linux OS +Linux is free and opensource operating system +``` + +### 7) 如何查找和修改最后一行的模式 + +下面的 sed 命令允许你只在最后一行替换匹配的字符串。 + +下面的 `sed` 命令只在最后一行用 `Unix` 替换 `Linux` 模式。 + +``` +# sed '$ s/Linux/Unix/' sed-test.txt + +1 Unix unix unix 23 +2 linux Linux 34 +3 linuxunix UnixLinux +linux /bin/bash CentOS Linux OS +Unix is free and opensource operating system +``` + +### 8) 在一行中如何只查找和替换正确的模式匹配 + +你可能已经注意到,子串 `linuxunix` 被替换为在第 6 个示例中的 `linuxlinux`。如果你只想更改正确的匹配词,在搜索串的两端用这个边界符 `\b`。 + +``` +# sed '1,3 s/\bunix\b/linux/' sed-test.txt + +1 Unix linux unix 23 +2 linux Linux 34 +3 linuxunix UnixLinux +linux /bin/bash CentOS Linux OS +Linux is free and opensource operating system +``` + +### 9) 如何以不区分大小写来搜索与替换模式 + +大家都知道,Linux 是区分大小写的。为了与不区分大小写的模式匹配,使用 `I` 标志。 + +``` +# sed 's/unix/linux/gI' sed-test.txt + +1 linux linux linux 23 +2 linux Linux 34 +3 linuxlinux linuxLinux +linux /bin/bash CentOS Linux OS +Linux is free and opensource operating system +``` + +### 10) 如何查找和替换包含分隔符的字符串 + +当你搜索和替换含分隔符的字符串时,我们需要用反斜杠 `\` 来取消转义。 + +在这个例子中,我们将用 `/usr/bin/fish` 来替换 `/bin/bash`。 + +``` +# sed 's/\/bin\/bash/\/usr\/bin\/fish/g' sed-test.txt + +1 Unix unix unix 23 +2 linux Linux 34 +3 linuxunix UnixLinux +linux /usr/bin/fish CentOS Linux OS +Linux is free and opensource operating system +``` + +上述 `sed` 命令按预期工作,但它看起来来很糟糕。 为了简化,大部分的人会用竖线 `|` 作为正则表达式的定位符。 所以,我建议你用它。 + +``` +# sed 's|/bin/bash|/usr/bin/fish/|g' sed-test.txt + +1 Unix unix unix 23 +2 linux Linux 34 +3 linuxunix UnixLinux +linux /usr/bin/fish/ CentOS Linux OS +Linux is free and opensource operating system +``` + +### 11) 如何以给定的模式来查找和替换数字 + +类似地,数字可以用模式来代替。下面的 `sed` 命令以 `[0-9]` 替换所有数字为 `number`。 + +``` +# sed 's/[0-9]/number/g' sed-test.txt + +number Unix unix unix numbernumber +number linux Linux numbernumber +number linuxunix UnixLinux +linux /bin/bash CentOS Linux OS +Linux is free and opensource operating system +``` + +### 12) 如何用模式仅查找和替换两个数字 + +如果你想用模式来代替两位数字,使用下面的 `sed` 命令。 + +``` +# sed 's/\b[0-9]\{2\}\b/number/g' sed-test.txt + +1 Unix unix unix number +2 linux Linux number +3 linuxunix UnixLinux +linux /bin/bash CentOS Linux OS +Linux is free and opensource operating system +``` + +### 13) 如何用 sed 命令仅打印被替换的行 + +如果你想显示仅更改的行,使用下面的 `sed` 命令。 + +* `p` - 它在终端上输出替换的行两次。 +* `-n` - 它抑制由 `p` 标志所产生的重复行。 + +``` +# sed -n 's/Unix/Linux/p' sed-test.txt + +1 Linux unix unix 23 +3 linuxunix LinuxLinux +``` + +### 14) 如何同时运行多个 sed 命令 + +以下 `sed` 命令同时检测和置换两个不同的模式。 + +下面的 `sed` 命令搜索 `linuxunix` 和 `CentOS` 模式,用 `LINUXUNIX` 和 `RHEL8` 一次性更换它们。 + +``` +# sed -e 's/linuxunix/LINUXUNIX/g' -e 's/CentOS/RHEL8/g' sed-test.txt + +1 Unix unix unix 23 +2 linux Linux 34 +3 LINUXUNIX UnixLinux +linux /bin/bash RHEL8 Linux OS +Linux is free and opensource operating system +``` + +下面的 `sed` 命令搜索替换两个不同的模式,并一次性替换为一个字符串。 + +以下 `sed` 的命令搜索 `linuxunix` 和 `CentOS` 模式,用 `Fedora30` 替换它们。 + +``` +# sed -e 's/\(linuxunix\|CentOS\)/Fedora30/g' sed-test.txt + +1 Unix unix unix 23 +2 linux Linux 34 +3 Fedora30 UnixLinux +linux /bin/bash Fedora30 Linux OS +Linux is free and opensource operating system +``` + +### 15) 如果给定的模式匹配,如何查找和替换整个行 + +如果模式匹配,可以使用 `sed` 命令用新行来代替整行。这可以通过使用 `c` 标志来完成。 + +``` +# sed '/OS/ c\ +New Line +' sed-test.txt + +1 Unix unix unix 23 +2 linux Linux 34 +3 linuxunix UnixLinux +New Line +Linux is free and opensource operating system +``` + +### 16) 如何搜索和替换相匹配的模式行 + +在 `sed` 命令中你可以为行指定适合的模式。在匹配该模式的情况下,`sed` 命令搜索要被替换的字符串。 + +下面的 `sed` 命令首先查找具有 `OS` 模式的行,然后用 `ArchLinux` 替换单词 `Linux`。 + +``` +# sed '/OS/ s/Linux/ArchLinux/' sed-test.txt + +1 Unix unix unix 23 +2 linux Linux 34 +3 linuxunix UnixLinux +linux /bin/bash CentOS ArchLinux OS +Linux is free and opensource operating system +``` +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-sed-to-find-and-replace-string-in-files/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[Asche910](https://github.com/asche910) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 diff --git a/published/20190914 GNOME 3.34 Released With New Features - Performance Improvements.md b/published/20190914 GNOME 3.34 Released With New Features - Performance Improvements.md new file mode 100644 index 0000000000..69911195d2 --- /dev/null +++ b/published/20190914 GNOME 3.34 Released With New Features - Performance Improvements.md @@ -0,0 +1,89 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11345-1.html) +[#]: subject: (GNOME 3.34 Released With New Features & Performance Improvements) +[#]: via: (https://itsfoss.com/gnome-3-34-release/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +GNOME 3.34 发布 +====== + +![](https://img.linux.net.cn/data/attachment/album/201909/15/113154i3bcp9p3md3mc3bk.jpg) + +最新版本的 GNOME 代号为“塞萨洛尼基Thessaloniki”。考虑到这个版本经过了 6 个月的开发,这应该是对 [GNOME 3.32][1] 的一次令人印象深刻的升级。 + +在此版本中,有许多新功能和显著的性能改进。除了新功能外,可定制的程度也得到了提升。 + +以下是新的变化: + +### GNOME 3.34 的关键改进 + +你可以观看此视频,了解 GNOME 3.34 中的新功能: + +- [视频](https://img.linux.net.cn/static/video/_-qAjPRr5SGoY.mp4) + +#### 拖放图标到文件夹 + +新的 shell 主题允许你拖放应用程序抽屉中的图标以重新排列它们,或将它们组合到一个文件夹中。你可能已经在 Android 或 iOS 智能手机中使用过此类功能。 + +![You can now drag and drop icons into a folder][2] + +#### 改进的日历管理器 + +改进的日历管理器可以轻松地与第三方服务集成,使你能够直接从 Linux 系统管理日程安排,而无需单独使用其他应用程序。 + +![GNOME Calendar Improvements][3] + +#### 背景选择的设置 + +现在,更容易为主屏幕和锁定屏幕选择自定义背景,因为它在同一屏幕中显示所有可用背景。为你节省至少一次鼠标点击。 + +![It’s easier to select backgrounds now][4] + +#### 重新排列搜索选项 + +搜索选项和结果可以手动重新排列。因此,当你要搜索某些内容时,可以决定哪些内容先出现。 + +#### 响应式设计的“设置”应用 + +设置菜单 UI 现在具有响应性,因此无论你使用何种类型(或尺寸)的设备,都可以轻松访问所有选项。这肯定对 [Linux 智能手机(如 Librem 5)][5] 上的 GNOME 有所帮助。 + +除了所有这些之外,[官方公告][6]还提到到开发人员的有用补充(增加了系统分析器和虚拟化改进): + +> 对于开发人员,GNOME 3.34 在 Sysprof 中包含更多数据源,使应用程序的性能分析更加容易。对 Builder 的多项改进中包括集成的 D-Bus 检查器。 + +![Improved Sysprof tool in GNOME 3.34][7] + +### 如何获得GNOME 3.34? + +虽然新版本已经发布,但它还没有进入 Linux 发行版的官方存储库。所以,我们建议等待它,并在它作为更新包提供时进行升级。不管怎么说,如果你想构建它,你都可以在这里找到[源代码][8]。 + +嗯,就是这样。如果你感兴趣,可以查看[完整版本说明][10]以了解技术细节。 + +你如何看待新的 GNOME 3.34? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/gnome-3-34-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.gnome.org/news/2019/03/gnome-3-32-released/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/icon-grid-drag-gnome.png?ssl=1 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/gnome-calendar-improvements.jpg?ssl=1 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/background-panel-GNOME.png?resize=800%2C555&ssl=1 +[5]: https://itsfoss.com/librem-linux-phone/ +[6]: https://www.gnome.org/press/2019/09/gnome-3-34-released/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/sysprof-gnome.jpg?resize=800%2C493&ssl=1 +[8]: https://download.gnome.org/ +[9]: https://itsfoss.com/fedora-26-release/ +[10]: https://help.gnome.org/misc/release-notes/3.34/ diff --git a/published/20190914 Manjaro Linux Graduates From A Hobby Project To A Professional Project.md b/published/20190914 Manjaro Linux Graduates From A Hobby Project To A Professional Project.md new file mode 100644 index 0000000000..0f5ce59599 --- /dev/null +++ b/published/20190914 Manjaro Linux Graduates From A Hobby Project To A Professional Project.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11349-1.html) +[#]: subject: (Manjaro Linux Graduates From A Hobby Project To A Professional Project) +[#]: via: (https://itsfoss.com/manjaro-linux-business-formation/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Manjaro Linux 从业余爱好项目成长为专业项目 +====== + +> Manjaro 正在走专业化路线。虽然 Manjaro 社区将负责项目的开发和其他相关活动,但该团队已成立了一家公司作为其法人实体处理商业协议和专业服务。 + +Manjaro 是一个相当流行的 Linux 发行版,而它只是由三个人(Bernhard、Jonathan 和 Phili)于 2011 年激情之下创建的项目。现在,它是目前[最好的 Linux 发行版][1]之一,所以它不能真的一直还只是个业余爱好项目了,对吧。 + +嗯,现在有个好消息:Manjaro 已经建立了一家新公司“[Manjaro GmbH & Co. KG]”,以 [Blue Systems][2] 为顾问,以便能够全职雇佣维护人员,并探索未来的商业机会。 + +![][3] + +### 具体有什么变化? + +根据[官方公告][4],Manjaro 项目将保持不变。但是,成立了一家新公司来保护该项目,以允许他们制定法律合同、官方协议和进行其他潜在的商业活动。因此,这使得这个“业余爱好项目”成为了一项专业工作。 + +除此之外,捐赠资金将转给非营利性的[财政托管][5]([CommunityBridge][6] 和 [OpenCollective][7]),让他们来代表项目接受和管理资金。请注意,这些捐赠没有被用于创建这个公司,因此,将资金转移给非营利的财务托管将在确保捐赠的同时也确保透明度。 + +### 这会有何改善? + +随着这个公司的成立,(如开发者所述)新结构将以下列方式帮助 Manjaro: + +* 使开发人员能够全职投入 Manjaro 及其相关项目; +* 在 Linux 相关的比赛和活动中与其他开发人员进行互动; +* 保护 Manjaro 作为一个社区驱动项目的独立性,并保护其品牌; +* 提供更快的安全更新,更有效地响应用户需求; +* 提供在专业层面上作为公司行事的手段。 + +Manjaro 团队还阐明了它将如何继续致力于社区: + +> Manjaro 的使命和目标将与以前一样 —— 支持 Manjaro 的协作开发及其广泛使用。这项工作将继续通过捐赠和赞助来支持,这些捐赠和赞助在任何情况下都不会被这个成立的公司使用。 + +### 关于 Manjaro 公司的更多信息 + +尽管他们提到该项目将独立于公司,但并非所有人都清楚当有了一家具有商业利益的公司时 Manjaro 与“社区”的关系。因此,该团队还在公告中澄清了他们作为一家公司的计划。 + +> Manjaro GmbH & Co.KG 的成立旨在有效地参与商业协议、建立合作伙伴关系并提供专业服务。有了这个,Manjaro 开发者 Bernhard 和 Philip 现在可以全职工作投入到 Manjaro,而 Blue Systems 将担任顾问。 + +> 公司将能够正式签署合同并承担职责和保障,而社区不能承担或承担责任。 + +### 总结 + +因此,通过这一举措以及商业机会,他们计划全职工作并聘请贡献者。 + +当然,现在他们的意思是“业务”(我希望不是作为坏人)。对此公告的大多数反应都是积极的,我们都祝他们好运。虽然有些人可能对具有“商业”利益的“社区”项目持怀疑态度(还记得 [FreeOffice 和 Manjaro 的挫败][9]吗?),但我认为这是一个有趣的举措。 + +你怎么看?请在下面的评论中告诉我们你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/manjaro-linux-business-formation/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/best-linux-distributions/ +[2]: https://www.blue-systems.com/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/manjaro-gmbh.jpg?ssl=1 +[4]: https://forum.manjaro.org/t/manjaro-is-taking-the-next-step/102105 +[5]: https://en.wikipedia.org/wiki/Fiscal_sponsorship +[6]: https://communitybridge.org/ +[7]: https://opencollective.com/ +[8]: https://itsfoss.com/linux-mint-hacked/ +[9]: https://itsfoss.com/libreoffice-freeoffice-manjaro-linux/ diff --git a/published/20190915 Sandboxie-s path to-open source, update on the Pentagon-s open source initiative, open source in Hollywood,-and more.md b/published/20190915 Sandboxie-s path to-open source, update on the Pentagon-s open source initiative, open source in Hollywood,-and more.md new file mode 100644 index 0000000000..e70c9f8832 --- /dev/null +++ b/published/20190915 Sandboxie-s path to-open source, update on the Pentagon-s open source initiative, open source in Hollywood,-and more.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11351-1.html) +[#]: subject: (Sandboxie's path to open source, update on the Pentagon's open source initiative, open source in Hollywood, and more) +[#]: via: (https://opensource.com/article/19/9/news-september-15) +[#]: author: (Lauren Maffeo https://opensource.com/users/lmaffeo) + +开源新闻综述:五角大楼、好莱坞和 Sandboxie 的开源 +====== + +> 不要错过两周以来最大的开源头条新闻。 + +![Weekly news roundup with TV][1] + +在本期我们的开源新闻综述中有 Sandboxie 的开源之路、五角大楼开源计划的进一步变化、好莱坞开源等等! + +### 五角大楼不符合白宫对开源软件的要求 + +2016 年,美国白宫要求每个美国政府机构必须在三年内开放至少 20% 的定制软件。2017 年有一篇关于这一倡议的[有趣文章][5],其中列出了一些令人激动的事情和面临的挑战。 + +根据美国政府问责局(GAO)的说法,[美国五角大楼做的还远远不足][6]。 + +在一篇关于 Nextgov 的文章中,Jack Corrigan 写道,截至 2019 年 7 月,美国五角大楼仅发布了 10% 的代码为开源代码。他们还没有实施的其它白宫任务包括要求制定开源软件政策和定制代码的清单。 + +根据该报告,一些美国政府官员告诉 GAO,他们担心美国政府部门间共享代码的安全风险。他们还承认没有创建衡量开源工作成功的指标。美国五角大楼的首席技术官将五角大楼的规模列为不执行白宫的开源任务的原因。在周二发布的一份报告中,GAO 表示,“在(美国国防部)完全实施其试点计划并确定完成行政管理和预算局(OMB)要求的里程碑之前,该部门将无法达成显著的成本节约和效率的目的。” + +### Sandboxie 在开源的过程中变成了免费软件 + +一家英国安全公司 Sophos Group plc 发布了[其流行的 Sandboxie 工具的免费版本][2],它用作Windows 的隔离操作环境([可在此下载][2])。 + +Sophos 表示,由于 Sandboxie 不是其业务的核心,因此更容易做出的决定就是关闭它。但 Sandboxie 因为无需让用户的操作系统冒风险就可以在安全的环境中运行未知软件而[广受赞誉][3],因此该团队正在投入额外的工作将其作为开源软件发布。这个免费但非开源的中间阶段似乎与当前的系统设计有关,因为它需要激活密钥: + +> Sandboxie 目前使用许可证密钥来激活和授予仅针对付费客户开放的高级功能的访问权限(与使用免费版本的用户相比)。我们修改了代码,并发布了一个不限制任何功能的免费版本的更新版。换句话说,新的免费许可证将可以访问之前仅供付费客户使用的所有功能。 + +受此工具的社区影响,Sophos 的高级领导人宣布发布 Sandboxie 版本 5.31.4,这个不受限制的程序版本将保持免费,直到该工具完全开源。 + +> “Sandboxie 用户群代表了一些最热情、前瞻性和知识渊博的安全社区成员,我们不想让你失望,”[Sophos 的博文说到][4]。“经过深思熟虑后,我们认为让 Sandboxie 走下去的最佳方式是将其交还给用户,将其转换为开源工具。” + +### 志愿者团队致力于查找和数字化无版权书籍 + +1924 年以前在美国出版的所有书籍都是[公有的、可以自由使用/复制的][7]。1964 年及之后出版的图书在出版日期后将保留 95 年的版权。但由于版权漏洞,1923 年至 1964 年间出版的书籍中有高达 75% 可以免费阅读和复制。现在只需要耗时确认那些书是什么。 + +因此,一些图书馆、志愿者和档案管理员们联合起来了解哪些图书没有版权,然后将其数字化并上传到互联网。由于版权续约记录已经数字化,因此很容易判断 1923 年至 1964 年间出版的书籍是否更新了其版权。但是,由于试图提供的是反证,因此寻找缺乏版权更新的难度要大得多。 + +参与者包括纽约公共图书馆(NYPL),它[最近解释了][8]为什么这个耗时的项目是值得的。为了帮助更快地找到更多书籍,NYPL 将许多记录转换为 XML 格式。这样可以更轻松地自动执行查找可以将哪些书籍添加到公共域的过程。 + +### 好莱坞的学院软件基金会获得新成员 + +微软和苹果公司宣布计划以学院软件基金会Academy Software Foundation(ASWF)的高级会员做出贡献。他们将加入[创始董事会成员][9],其它成员还包括 Netflix、Google Cloud、Disney Studios 和 Sony Pictures。 + +学院软件基金会于 2018 年作为[电影艺术与科学学院][10]和[Linux 基金会][11]的联合项目而启动。 + +> 学院软件基金会(ASWF)的使命是提高贡献到内容创作行业的开源软件库的质量和数量;提供一个中立的论坛来协调跨项目的工作;提供通用的构建和测试基础架构;并为个人和组织提供参与推进我们的开源生态系统的明确途径。 + +在第一年内,该基金会构建了 [OpenTimelineIO][12],这是一种开源 API 和交换格式,可帮助工作室团队跨部门协作。OpenTImelineIO 被该[基金会技术咨询委员会][13]去年 7 月正式接受为第五个托管项目。他们现在将它与 [OpenColorIO][14]、[OpenCue][15]、[OpenEXR][16] 和 [OpenVDB] [17] 并列维护。 + +### 其它新闻 + +* [Comcast 将开源网络软件投入生产环境][18] +* [SD Times 本周开源项目:Ballerina][19] +* [美国国防部努力实施开源计划][20] +* [Kong 开源通用服务网格 Kuma][21] +* [Eclipse 推出 Jakarta EE 8][22] + +一如既往地感谢 Opensource.com 的工作人员和主持人本周的帮助。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/news-september-15 + +作者:[Lauren Maffeo][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lmaffeo +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/weekly_news_roundup_tv.png?itok=B6PM4S1i (Weekly news roundup with TV) +[2]: https://www.sandboxie.com/DownloadSandboxie +[3]: https://betanews.com/2019/09/13/sandboxie-free-open-source/ +[4]: https://community.sophos.com/products/sandboxie/f/forum/115109/major-sandboxie-news-sandboxie-is-now-a-free-tool-with-plans-to-transition-it-to-an-open-source-tool/414522 +[5]: https://medium.com/@DefenseDigitalService/code-mil-an-open-source-initiative-at-the-pentagon-5ae4986b79bc +[6]: https://www.nextgov.com/analytics-data/2019/09/pentagon-needs-make-more-software-open-source-watchdog-says/159832/ +[7]: https://www.vice.com/en_us/article/a3534j/libraries-and-archivists-are-scanning-and-uploading-books-that-are-secretly-in-the-public-domain +[8]: https://www.nypl.org/blog/2019/09/01/historical-copyright-records-transparency +[9]: https://variety.com/2019/digital/news/microsoft-apple-academy-software-foundation-1203334675/ +[10]: https://www.oscars.org/ +[11]: http://www.linuxfoundation.org/ +[12]: https://github.com/PixarAnimationStudios/OpenTimelineIO +[13]: https://www.linuxfoundation.org/press-release/2019/07/opentimelineio-joins-aswf/ +[14]: https://opencolorio.org/ +[15]: https://www.opencue.io/ +[16]: https://www.openexr.com/ +[17]: https://www.openvdb.org/ +[18]: https://www.fiercetelecom.com/operators/comcast-puts-open-source-networking-software-into-production +[19]: https://sdtimes.com/os/sd-times-open-source-project-of-the-week-ballerina/ +[20]: https://www.fedscoop.com/open-source-software-dod-struggles/ +[21]: https://sdtimes.com/micro/kong-open-sources-universal-service-mesh-kuma/ +[22]: https://devclass.com/2019/09/11/hey-were-open-source-again-eclipse-unveils-jakarta-ee-8/ diff --git a/published/20190916 How to freeze and lock your Linux system (and why you would want to).md b/published/20190916 How to freeze and lock your Linux system (and why you would want to).md new file mode 100644 index 0000000000..37b0a31311 --- /dev/null +++ b/published/20190916 How to freeze and lock your Linux system (and why you would want to).md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11384-1.html) +[#]: subject: (How to freeze and lock your Linux system (and why you would want to)) +[#]: via: (https://www.networkworld.com/article/3438818/how-to-freeze-and-lock-your-linux-system-and-why-you-would-want-to.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如何冻结和锁定你的 Linux 系统 +====== + +> 冻结终端窗口并锁定屏幕意味着什么 - 以及如何在 Linux 系统上管理这些活动。 + +![](https://img.linux.net.cn/data/attachment/album/201909/24/230938vgxzv3nrakk0wxnw.jpg) + +如何在 Linux 系统上冻结和“解冻”屏幕,很大程度上取决于这些术语的含义。有时“冻结屏幕”可能意味着冻结终端窗口,以便该窗口内的活动停止。有时它意味着锁定屏幕,这样就没人可以在你去拿一杯咖啡时,走到你的系统旁边代替你输入命令了。 + +在这篇文章中,我们将研究如何使用和控制这些操作。 + +### 如何在 Linux 上冻结终端窗口 + +你可以输入 `Ctrl+S`(按住 `Ctrl` 键和 `s` 键)冻结 Linux 系统上的终端窗口。把 `s` 想象成“开始冻结start the freeze”。如果在此操作后继续输入命令,那么你不会看到输入的命令或你希望看到的输出。实际上,命令将堆积在一个队列中,并且只有在通过输入 `Ctrl+Q` 解冻时才会运行。把它想象成“退出冻结quit the freeze”。 + +查看其工作的一种简单方式是使用 `date` 命令,然后输入 `Ctrl+S`。接着再次输入 `date` 命令并等待几分钟后再次输入 `Ctrl+Q`。你会看到这样的情景: + +``` +$ date +Mon 16 Sep 2019 06:47:34 PM EDT +$ date +Mon 16 Sep 2019 06:49:49 PM EDT +``` + +这两次时间显示的差距表示第二次的 `date` 命令直到你解冻窗口时才运行。 + +无论你是坐在计算机屏幕前还是使用 PuTTY 等工具远程运行,终端窗口都可以冻结和解冻。 + +这有一个可以派上用场的小技巧。如果你发现终端窗口似乎处于非活动状态,那么可能是你或其他人无意中输入了 `Ctrl+S`。那么,输入 `Ctrl+Q` 来尝试解决不妨是个不错的办法。 + +### 如何锁定屏幕 + +要在离开办公桌前锁定屏幕,请按住  `Ctrl+Alt+L` 或 `Super+L`(即按住 `Windows` 键和 `L` 键)。屏幕锁定后,你必须输入密码才能重新登录。 + +### Linux 系统上的自动屏幕锁定 + +虽然最佳做法建议你在即将离开办公桌时锁定屏幕,但 Linux 系统通常会在一段时间没有活动后自动锁定。 “消隐”屏幕(使其变暗)并实际锁定屏幕(需要登录才能再次使用)的时间取决于你个人首选项中的设置。 + +要更改使用 GNOME 屏幕保护程序时屏幕变暗所需的时间,请打开设置窗口并选择 “Power” 然后 “Blank screen”。你可以选择 1 到 15 分钟或从不变暗。要选择屏幕变暗后锁定所需时间,请进入设置,选择 “Privacy”,然后选择 “Blank screen”。设置应包括 1、2、3、5 和 30 分钟或一小时。 + +### 如何在命令行锁定屏幕 + +如果你使用的是 GNOME 屏幕保护程序,你还可以使用以下命令从命令行锁定屏幕: + +``` +gnome-screensaver-command -l +``` + +这里是小写的 L,代表“锁定”。 + +### 如何检查锁屏状态 + +你还可以使用 `gnome-screensaver` 命令检查屏幕是否已锁定。使用 `--query` 选项,该命令会告诉你屏幕当前是否已锁定(即处于活动状态)。使用 `--time` 选项,它会告诉你锁定生效的时间。这是一个示例脚本: + +``` +#!/bin/bash + +gnome-screensaver-command --query +gnome-screensaver-command --time +``` + +运行脚本将会输出: + +``` +$ ./check_lockscreen +The screensaver is active +The screensaver has been active for 1013 seconds. +``` + +#### 总结 + +如果你记住了正确的控制方式,那么锁定终端窗口是很简单的。对于屏幕锁定,它的效果取决于你自己的设置,或者你是否习惯使用默认设置。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3438818/how-to-freeze-and-lock-your-linux-system-and-why-you-would-want-to.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/20190916 Linux Plumbers, Appwrite, and more industry trends.md b/published/20190916 Linux Plumbers, Appwrite, and more industry trends.md new file mode 100644 index 0000000000..8ca1e16da6 --- /dev/null +++ b/published/20190916 Linux Plumbers, Appwrite, and more industry trends.md @@ -0,0 +1,92 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11355-1.html) +[#]: subject: (Linux Plumbers, Appwrite, and more industry trends) +[#]: via: (https://opensource.com/article/19/9/conferences-industry-trends) +[#]: author: (Tim Hildred https://opensource.com/users/thildred) + + +每周开源点评:Linux Plumbers、Appwrite +====== + +> 了解每周的开源社区和行业趋势。 + +![Person standing in front of a giant computer screen with numbers, data][1] + +作为采用开源开发模式的企业软件公司的高级产品营销经理,这是我为产品营销人员、经理和其他相关人员发布的有关开源社区、市场和行业趋势的定期更新。以下是本次更新中我最喜欢的五篇文章。 + +### 《在 Linux Plumbers 会议上解决 Linux 具体细节》 + +- [文章地址][2] + +> Linux 的创建者 Linus Torvalds 告诉我,内核维护者峰会Kernel Maintainers Summit是顶级 Linux 内核开发人员的邀请制聚会。但是,虽然你可能认为这是关于规划 Linux 内核的未来的会议,但事实并非如此。“这个维护者峰会真的与众不同,因为它甚至不谈论技术问题。”相反,“全都谈的是关于创建和维护 Linux 内核的过程。” + +**影响**:这就像技术版的 Bilderberg 会议:你们举办的都是各种华丽的流行语会议,而在这里我们做出的才是真正的决定。不过我觉得,可能不太会涉及到私人飞机吧。(LCTT 译注:有关 Bilderberg 请自行搜索) + +### 《微软主办第一个 WSL 会议》 + +- [文章地址][3] + +> [Whitewater Foundry][4] 是一家专注于 [Windows 的 Linux 子系统(WSL)][5]的创业公司,它的创始人 Hayden Barnes [宣布举办 WSLconf 1][6],这是 WSL 的第一次社区会议。该活动将于 2020 年 3 月 10 日至 11 日在华盛顿州雷德蒙市的微软总部 20 号楼举行。会议是合办的。我们已经知道将有来自[Pengwin(Whitewater 的 Linux for Windows)][7]、微软 WSL 和 Canonical 的 Ubuntu on WSL 开发人员的演讲和研讨会。 + +**影响**:微软正在培育社区成长的种子,围绕它越来越多地采用开源软件并作出贡献。这足以让我眼前一亮。 + +### 《Appwrite 简介:面向移动和 Web 开发人员的开源后端服务器》 + +- [文章链接][10] + +> [Appwrite][11] 是一个新的[开源软件][12],用于前端和移动开发人员的端到端的后端服务器,可以让你更快地构建应用程序。[Appwrite][13] 的目标是抽象和简化 REST API 和工具背后的常见开发任务,以帮助开发人员更快地构建高级应用程序。 +> +> 在这篇文章中,我将简要介绍一些主要的 [Appwrite][14] 服务,并解释它们的主要功能以及它们的设计方式,相比从头开始编写所有后端 API,这可以帮助你更快地构建下一个项目。 + +**影响**:随着更多开源中间件变得更易于使用,软件开发越来越容易。Appwrite 声称可将开发时间和成本降低 70%。想象一下这对小型移动开发机构或个人开发者意味着什么。我很好奇他们将如何通过这种方式赚钱。 + +### 《“不只是 IT”:开源技术专家说协作文化是政府转型的关键》 + +- [文章链接][15] + +> AGL(敏捷的政府领导agile government leadership)正在为那些帮助政府更好地为公众工作的人们提供价值支持网络。该组织专注于我非常热衷的事情:DevOps、数字化转型、开源以及许多政府 IT 领导者首选的类似主题。AGL 为我提供了一个社区,可以了解当今最优秀和最聪明的人所做的事情,并与整个行业的同行分享这些知识。 + +**影响**:不管你的政治信仰如何,对政府都很容易愤世嫉俗。我发现令人耳目一新的是,政府也是由一个个实际的人组成的,他们大多在尽力将相关技术应用于公益事业。特别是当该技术是开源的! + +### 《彭博社如何通过 Kubernetes 实现接近 90-95% 的硬件利用率》 + +- [文章链接][16] + +> 2016 年,彭博社采用了 Kubernetes(当时仍处于 alpha 阶段中),自使用该项目的上游代码以来,取得了显著成果。Rybka 说:“借助 Kubernetes,我们能够非常高效地使用我们的硬件,使利用率接近 90% 到 95%。”Kubernetes 中的自动缩放使系统能够更快地满足需求。此外,Kubernetes “为我们提供了标准化我们构建和管理服务的方法的能力,这意味着我们可以花费更多时间专注于实际使用我们支持的开源工具,”数据和分析基础架构主管 Steven Bower 说,“如果我们想要在世界的另一个位置建立一个新的集群,那么这样做真的非常简单。一切都只是代码。配置就是代码。” + +**影响**:没有什么能像利用率统计那样穿过营销的迷雾。我听说过关于 Kube 的一件事是,当人们运行它时,他们不知道用它做什么。像这样的用例可以给他们(和你)一些想要的东西。 + +*我希望你喜欢这个上周重要内容的清单,请下周回来了解有关开源社区、市场和行业趋势的更多信息。* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/conferences-industry-trends + +作者:[Tim Hildred][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/thildred +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) +[2]: https://www.zdnet.com/article/working-on-linuxs-nuts-and-bolts-at-linux-plumbers/ +[3]: https://www.zdnet.com/article/microsoft-hosts-first-windows-subsystem-for-linux-conference/ +[4]: https://github.com/WhitewaterFoundry +[5]: https://docs.microsoft.com/en-us/windows/wsl/install-win10 +[6]: https://www.linkedin.com/feed/update/urn:li:activity:6574754435518599168/ +[7]: https://www.zdnet.com/article/pengwin-a-linux-specifically-for-windows-subsystem-for-linux/ +[8]: https://canonical.com/ +[9]: https://ubuntu.com/ +[10]: https://medium.com/@eldadfux/introducing-appwrite-an-open-source-backend-server-for-mobile-web-developers-4be70731575d +[11]: https://appwrite.io +[12]: https://github.com/appwrite/appwrite +[13]: https://medium.com/@eldadfux/introducing-appwrite-an-open-source-backend-server-for-mobile-web-developers-4be70731575d?source=friends_link&sk=b6a2be384aafd1fa5b1b6ff12906082c +[14]: https://appwrite.io/ +[15]: https://medium.com/agile-government-leadership/more-than-just-it-open-source-technologist-says-collaborative-culture-is-key-to-government-c46d1489f822 +[16]: https://www.cncf.io/blog/2019/09/12/how-bloomberg-achieves-close-to-90-95-hardware-utilization-with-kubernetes/ diff --git a/published/20190917 Getting started with Zsh.md b/published/20190917 Getting started with Zsh.md new file mode 100644 index 0000000000..460ab91c92 --- /dev/null +++ b/published/20190917 Getting started with Zsh.md @@ -0,0 +1,215 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11378-1.html) +[#]: subject: (Getting started with Zsh) +[#]: via: (https://opensource.com/article/19/9/getting-started-zsh) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Zsh 入门 +====== + +> 从 Bash 进阶到 Z-shell,改进你的 shell 体验。 + +![](https://img.linux.net.cn/data/attachment/album/201909/23/163910imr1z1qw1ruo9uqs.jpg) + +Z-shell(Zsh)是一种 Bourne 式的交互式 POSIX shell,以其丰富的创新功能而著称。Z-Shell 用户经常会提及它的许多便利之处,赞誉它对效率的提高和丰富的自定义支持。 + +如果你刚接触 Linux 或 Unix,但你的经验足以让你可以打开终端并运行一些命令的话,那么你可能使用的就是 Bash shell。Bash 可能是最具有代表意义的自由软件 shell,部分是因为它具有的先进的功能,部分是因为它是大多数流行的 Linux 和 Unix 操作系统上的默认 shell。但是,随着使用的次数越多,你可能会开始发现一些细节可能能够做的更好。开源有一个众所周知的地方,那就是选择。所以,许多人选择从 Bash “毕业”到 Z。 + +### Zsh 介绍 + +Shell 只是操作系统的接口。交互式 shell 程序允许你通过称为*标准输入*(stdin)的某个东西键入命令,并通过*标准输出*(stdout)和*标准错误*(stderr)获取输出。有很多种 shell,如 Bash、Csh、Ksh、Tcsh、Dash 和 Zsh。每个都有其开发者所认为最适合于 Shell 的功能。而这些功能的好坏,则取决于最终用户。 + +Zsh 具有交互式制表符补全、自动文件搜索、支持正则表达式、用于定义命令范围的高级速记符,以及丰富的主题引擎等功能。这些功能也包含在你所熟悉的其它 Bourne 式 shell 环境中,这意味着,如果你已经了解并喜欢 Bash,那么你也会熟悉 Zsh,除此以外,它还有更多的功能。你可能会认为它是一种 Bash++。 + +### 安装 Zsh + +用你的包管理器安装 Zsh。 + +在 Fedora、RHEL 和 CentOS 上: + +``` +$ sudo dnf install zsh +``` + +在 Ubuntu 和 Debian 上: + +``` +$ sudo apt install zsh +``` + +在 MacOS 上你可以使用 MacPorts 安装它: + +``` +$ sudo port install zsh +``` + +或使用 Homebrew: + +``` +$ brew install zsh +``` + +在 Windows 上也可以运行 Zsh,但是只能在 Linux 层或类似 Linux 的层之上运行,例如 [Windows 的 Linux 子系统][2](WSL)或 [Cygwin][3]。这类安装超出了本文的范围,因此请参考微软的文档。 + +### 设置 Zsh + +Zsh 不是终端模拟器。它是在终端仿真器中运行的 shell。因此,要启动 Zsh,必须首先启动一个终端窗口,例如 GNOME Terminal、Konsole、Terminal、iTerm2、rxvt 或你喜欢的其它终端。然后,你可以通过键入以下命令启动 Zsh: + +``` +$ zsh +``` + +首次启动 Zsh 时,会要求你选择一些配置选项。这些都可以在以后更改,因此请按 `1` 继续。 + +``` +This is the Z Shell configuration function for new users, zsh-newuser-install. + +(q)  Quit and do nothing. + +(0)  Exit, creating the file ~/.zshrc + +(1)  Continue to the main menu. +``` + +偏好设置分为四类,因此请从顶部开始。 + +1. 第一个类使你可以选择在 shell 历史记录文件中保留多少个命令。默认情况下,它设置为 1,000 行。 +2. Zsh 补全是其最令人兴奋的功能之一。为了简单起见,请考虑使用其默认选项激活它,直到你习惯了它的工作方式。按 `1` 使用默认选项,按 `2` 手动设置选项。 +3. 选择 Emacs 式键绑定或 Vi 式键绑定。Bash 使用 Emacs 式绑定,因此你可能已经习惯了。 +4. 最后,你可以了解(以及设置或取消设置)Zsh 的一些精妙的功能。例如,当你提供不带命令的非可执行路径时,可以通过让 Zsh 来改变目录而无需你使用 `cd` 命令。要激活这些额外选项之一,请输入选项号并输入 `s` 进行设置。请尝试打开所有选项以获得完整的 Zsh 体验。你可以稍后通过编辑 `~/.zshrc` 取消设置它们。 + +要完成配置,请按 `0`。 + +### 使用 Zsh + +刚开始,Zsh 的使用感受就像使用 Bash 一样,这无疑是其众多功能之一。例如,Bash 和 Tcsh 之间就存在严重的差异,因此如果你必须在工作中或在服务器上使用 Bash,而 Zsh 就可以在家里轻松尝试和使用,这样在 Bash 和 Zsh 之间轻松切换就是一种便利。 + +#### 在 Zsh 中改变目录 + +正是这些微小的差异使 Zsh 变得好用。首先,尝试在没有 `cd` 命令的情况下,将目录更改为 `Documents` 文件夹。简直太棒了,难以置信。如果你输入的是目录路径而没有进一步的指令,Zsh 会更改为该目录: + +``` +% Documents +% pwd +/home/seth/Documents +``` + +而这会在 Bash 或任何其他普通 shell 中导致错误。但是 Zsh 却根本不是普通的 shell,而这仅仅才是开始。 + +#### 在 Zsh 中搜索 + +当你想使用普通 shell 程序查找文件时,可以使用 `find` 或 `locate` 命令。最起码,你可以使用 `ls -R` 来递归地列出一组目录。Zsh 内置有允许它在当前目录或任何其他子目录中查找文件的功能。 + +例如,假设你有两个名为 `foo.txt` 的文件。一个位于你的当前目录中,另一个位于名为 `foo` 的子目录中。在 Bash Shell 中,你可以使用以下命令列出当前目录中的文件: + +``` +$ ls +foo.txt +``` + +你可以通过明确指明子目录的路径来列出另一个目录: + +``` +$ ls foo +foo.txt +``` + +要同时列出这两者,你必须使用 `-R` 开关,并结合使用 `grep`: + +``` +$ ls -R | grep foo.txt +foo.txt +foo.txt +``` + +但是在 Zsh 中,你可以使用 `**` 速记符号: + +``` +% ls **/foo.txt +foo.txt +foo.txt +``` + +你可以在任何命令中使用此语法,而不仅限于 `ls`。想象一下在这样的场景中提高的效率:将特定文件类型从一组目录中移动到单个位置、将文本片段串联到一个文件中,或对日志进行抽取。 + +### 使用 Zsh 的制表符补全 + +制表符补全是 Bash 和其他一些 Shell 中的高级用户功能,它变得司空见惯,席卷了 Unix 世界。Unix 用户不再需要在输入冗长而乏味的路径时使用通配符(例如输入 `/h*/s*h/V*/SCS/sc*/comp*/t*/a*/*9/04/LS*boat*v`,比输入 `/home/seth/Videos/SCS/scenes/composite/takes/approved/109/04/LS_boat-port-cargo-mover.mkv` 要容易得多)。相反,他们只要输入足够的唯一字符串即可按 `Tab` 键。例如,如果你知道在系统的根目录下只有一个以 `h` 开头的目录,则可以键入 `/h`,然后单击 `Tab`。快速、简单、高效。它还会确认路径存在;如果 `Tab` 无法完成任何操作,则说明你在错误的位置或输入了错误的路径部分。 + +但是,如果你有许多目录有五个或更多相同的首字母,`Tab` 会坚决拒绝进行补全。尽管在大多数现代终端中,它将(至少会)显示阻止其进行猜测你的意思的文件,但通常需要按两次 `Tab` 键才能显示它们。因此,制表符补全通常会变成来回按下键盘上字母和制表符,以至于你好像在接受钢琴独奏会的训练。 + +Zsh 通过循环可能的补全来解决这个小问题。如果键入 `*ls ~/D` 并按 `Tab`,则 Zsh 首先使用 `Documents` 来完成命令;如果再次按 `Tab`,它将提供 `Downloads`,依此类推,直到找到所需的选项。 + +### Zsh 中的通配符 + +在 Zsh 中,通配符的行为不同于 Bash 中用户所习惯的行为。首先,可以对其进行修改。例如,如果要列出当前目录中的所有文件夹,则可以使用修改后的通配符: + +``` +% ls +dir0   dir1   dir2   file0   file1 +% ls *(/) +dir0   dir1   dir2 +``` + +在此示例中,`(/)` 限定了通配符的结果,因此 Zsh 仅显示目录。要仅列出文件,请使用 `(.)`。要列出符号链接,请使用 `(@)`。要列出可执行文件,请使用 `(*)`。 + +``` +% ls ~/bin/*(*) +fop  exify  tt +``` + +Zsh 不仅仅知道文件类型。它也可以使用相同的通配符修饰符约定根据修改时间列出。例如,如果要查找在过去八个小时内修改的文件,请使用 `mh` 修饰符(即 “modified hours” 的缩写)和小时的负整数: + +``` +% ls ~/Documents/*(mh-8) +cal.org   game.org   home.org +``` + +要查找超过(例如)两天前修改过的文件,修饰符更改为 `md`(即 “modified day” 的缩写),并带上天数的正整数: + +``` +% ls ~/Documents/*(+2) +holiday.org +``` + +通配符修饰符和限定符还可以做很多事情,因此,请阅读 [Zsh 手册页][4],以获取全部详细信息。 + +#### 通配符的副作用 + +要像在 Bash 中使用通配符一样使用它,有时必须在 Zsh 中对通配符进行转义。例如,如果要在 Bash 中将某些文件复制到服务器上,则可以使用如下通配符: + +``` +$ scp IMG_*.JPG seth@example.com:~/www/ph*/*19/09/14 +``` + +这在 Bash 中有效,但是在 Zsh 中会返回错误,因为它在发出 `scp` 命令之前尝试在远程端扩展该变量(通配符)。为避免这种情况,必须转义远程变量(通配符): + +``` +% scp IMG_*.JPG seth@example.com:~/www/ph\*/\*19/09/14 +``` + +当你切换到新的 shell 时,这些小异常可能会使你感到沮丧。使用 Zsh 时会遇到的问题不多(体验过 Zsh 后切换回 Bash 的可能遇到更多),但是当它们发生时,请保持镇定且坦率。严格遵守 POSIX 的情况很少会出错,但是如果失败了,请查找问题以解决并继续。对于许多在工作中困在一个 shell 上而在家中困在另一个 shell 上的用户来说,[hyperpolyglot.org][5] 已被证明其是无价的。 + +在我的下一篇 Zsh 文章中,我将向你展示如何安装主题和插件以定制你的 Z-Shell 甚至 Z-ier。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/getting-started-zsh + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bash_command_line.png?itok=k4z94W2U (bash logo on green background) +[2]: https://devblogs.microsoft.com/commandline/category/bash-on-ubuntu-on-windows/ +[3]: https://www.cygwin.com/ +[4]: https://linux.die.net/man/1/zsh +[5]: http://hyperpolyglot.org/unix-shells diff --git a/published/20190917 How to Check Linux Mint Version Number - Codename.md b/published/20190917 How to Check Linux Mint Version Number - Codename.md new file mode 100644 index 0000000000..5f102dfa89 --- /dev/null +++ b/published/20190917 How to Check Linux Mint Version Number - Codename.md @@ -0,0 +1,139 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11360-1.html) +[#]: subject: (How to Check Linux Mint Version Number & Codename) +[#]: via: (https://itsfoss.com/check-linux-mint-version/) +[#]: author: (Sergiu https://itsfoss.com/author/sergiu/) + +如何查看 Linux Mint 版本号和代号 +====== + +Linux Mint 每两年发布一次主版本(如 Mint 19),每六个月左右发布一次次版本(如 Mint 19.1、19.2 等)。 你可以自己升级 Linux Mint 版本,而次版本也会自动更新。 + +在所有这些版本中,你可能想知道你正在使用的是哪个版本。了解 Linux Mint 版本号可以帮助你确定某个特定软件是否适用于你的系统,或者检查你的系统是否已达到使用寿命。 + +你可能需要 Linux Mint 版本号有多种原因,你也有多种方法可以获取此信息。让我向你展示用图形和命令行的方式获取 Mint 版本信息。 + +* [使用命令行查看 Linux Mint 版本信息][1] +* [使用 GUI(图形用户界面)查看 Linux Mint 版本信息][2] + +### 使用终端查看 Linux Mint 版本号的方法 + +![][3] + +我将介绍几种使用非常简单的命令查看 Linux Mint 版本号和代号的方法。 你可以从 “菜单” 中打开终端,或按 `CTRL+ALT+T`(默认热键)打开。 + +本文中的最后两个命令还会输出你当前的 Linux Mint 版本所基于的 Ubuntu 版本。 + +#### 1、/etc/issue + +从最简单的 CLI 方法开始,你可以打印出 `/etc/issue` 的内容来检查你的版本号和代号: + +``` +[email protected]:~$ cat /etc/issue +Linux Mint 19.2 Tina \n \l +``` + +#### 2、hostnamectl + +![hostnamectl][4] + +这一个命令(`hostnamectl`)打印的信息几乎与“系统信息”中的信息相同。 你可以看到你的操作系统(带有版本号)以及你的内核版本。 + +#### 3、lsb_release + +`lsb_release` 是一个非常简单的 Linux 实用程序,用于查看有关你的发行版本的基本信息: + +``` +[email protected]:~$ lsb_release -a +No LSB modules are available. +Distributor ID: LinuxMint +Description: Linux Mint 19.2 Tina +Release: 19.2 +Codename: tina +``` + +**注:** 我使用 `–a` 标签打印所有参数, 但你也可以使用 `-s` 作为简写格式,`-d` 用于描述等 (用 `man lsb_release` 查看所有选项) + +#### 4、/etc/linuxmint/info + +![/etc/linuxmint/info][5] + +这不是命令,而是 Linux Mint 系统上的文件。只需使用 `cat` 命令将其内容打印到终端,然后查看你的版本号和代号。 + +#### 5、使用 /etc/os-release 命令也可以获取到 Ubuntu 代号 + +![/etc/os-release][7] + +Linux Mint 基于 Ubuntu。每个 Linux Mint 版本都基于不同的 Ubuntu 版本。了解你的 Linux Mint 版本所基于的 Ubuntu 版本有助你在必须要使用 Ubuntu 版本号的情况下使用(比如你需要在 [Linux Mint 中安装最新的 Virtual Box][8]添加仓库时)。 + +`os-release` 则是另一个类似于 `info` 的文件,向你展示 Linux Mint 所基于的 Ubuntu 版本代号。 + +#### 6、使用 /etc/upstream-release/lsb-release 只获取 Ubuntu 的基本信息 + +如果你只想要查看有关 Ubuntu 的基本信息,请输出 `/etc/upstream-release/lsb-release`: + +``` +[email protected]:~$ cat /etc/upstream-release/lsb-release +DISTRIB_ID=Ubuntu +DISTRIB_RELEASE=18.04 +DISTRIB_CODENAME=bionic +DISTRIB_DESCRIPTION="Ubuntu 18.04 LTS" +``` + +特别提示:[你可以使用 uname 命令查看 Linux 内核版本][9]。 + +``` +[email protected]:~$ uname -r +4.15.0-54-generic +``` + +**注:** `-r` 代表 release,你可以使用 `man uname` 查看其他信息。 + +### 使用 GUI 查看 Linux Mint 版本信息 + +如果你对终端和命令行不满意,可以使用图形方法。如你所料,这个非常明了。 + +打开“菜单” (左下角),然后转到“偏好设置 > 系统信息”: + +![Linux Mint 菜单][10] + +或者,在菜单中,你可以搜索“System Info”: + +![Menu Search System Info][11] + +在这里,你可以看到你的操作系统(包括版本号),内核和桌面环境的版本号: + +![System Info][12] + +### 总结 + +我已经介绍了一些不同的方法,用这些方法你可以快速查看你正在使用的 Linux Mint 的版本和代号(以及所基于的 Ubuntu 版本和内核)。我希望这个初学者教程对你有所帮助。请在评论中告诉我们你最喜欢哪个方法! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/check-linux-mint-version/ + +作者:[Sergiu][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/sergiu/ +[b]: https://github.com/lujun9972 +[1]: tmp.pL5Hg3N6Qt#terminal +[2]: tmp.pL5Hg3N6Qt#GUI +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/check-linux-mint-version.png?ssl=1 +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/hostnamectl.jpg?ssl=1 +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/linuxmint_info.jpg?ssl=1 +[6]: https://itsfoss.com/rid-google-chrome-icons-dock-elementary-os-freya/ +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/os_release.jpg?ssl=1 +[8]: https://itsfoss.com/install-virtualbox-ubuntu/ +[9]: https://itsfoss.com/find-which-kernel-version-is-running-in-ubuntu/ +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/linux_mint_menu.jpg?ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/menu_search_system_info.jpg?ssl=1 +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/system_info.png?ssl=1 diff --git a/published/20190918 Amid Epstein Controversy, Richard Stallman is Forced to Resign as FSF President.md b/published/20190918 Amid Epstein Controversy, Richard Stallman is Forced to Resign as FSF President.md new file mode 100644 index 0000000000..e8a658cebc --- /dev/null +++ b/published/20190918 Amid Epstein Controversy, Richard Stallman is Forced to Resign as FSF President.md @@ -0,0 +1,146 @@ +[#]: collector: (lujun9972) +[#]: translator: (name1e5s) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11358-1.html) +[#]: subject: (Amid Epstein Controversy, Richard Stallman is Forced to Resign as FSF President) +[#]: via: (https://itsfoss.com/richard-stallman-controversy/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Richard Stallman 被迫辞去 FSF 主席的职务 +====== + +> Richard Stallman,自由软件基金会的创建者以及主席,已经辞去主席及董事会职务。此前,因为 Stallman 对于爱泼斯坦事件中的受害者的观点,一小撮活动家以及媒体人发起了清除 Stallman 的运动。这份声明就是在这些活动后发生的。阅读全文以获得更多信息。 + +![][1] + +### Stallman 事件的背景概述 + +如果你不知道这次事件发生的前因后果,请看本段的详细信息。 + +[Richard Stallman][2],66岁,是就职于 [MIT][3] 的计算机科学家。他最著名的成就就是在 1983 年发起了[自由软件运动][4]。他也开发了 GNU 项目旗下的部分软件,比如 GCC 和 Emacs。受自由软件运动影响选择使用 GPL 开源协议的项目不计其数。Linux 是其中最出名的项目之一。 + +[Jeffrey Epstein][5](爱泼斯坦),美国亿万富翁,金融大佬。其涉嫌为社会上流精英提供性交易服务(其中有未成年少女)而被指控成为性犯罪者。在受审期间,爱泼斯坦在监狱中自杀身亡。 + +[Marvin Lee Minsky][6],MIT 知名计算机科学家。他在 MIT 建立了人工智能实验室。2016 年,88 岁的 Minsky 逝世。在 Minsky 逝世后,一位名为 Misky 的爱泼斯坦事件受害者声称其在未成年时曾被“诱导”到爱泼斯坦的私人岛屿,与之发生性关系。 + +但是这些与 Richard Stallman 有什么关系?这要从 Stallman 发给 MIT 计算机科学与人工智能实验室(CSAIL)的学生以及附属机构就爱泼斯坦的捐款提出抗议的邮件列表的邮件说起。邮件全文翻译如下: + +> 周五事件的公告对 Marvin Minsky 来说是不公正的。 +> +> “已故的人工智能 ‘先锋’ Marvin Minsky (被控告侵害了爱泼斯坦事件的受害者之一\[2])” +> +> 不公正之处在于 “侵害assulting” 这个用语。“性侵犯sexual assault” 这个用语非常的糢糊,夸大了指控的严重性:宣称某人做了 X 但误导别人,让别人觉得这个人做了 Y,Y 远远比 X 严重。 +> +> 上面引用的指控显然就是夸大。报导声称 Minksy 与爱泼斯坦的女眷harem之一发生了性关系(详见 )。我们假设这是真的(我找不到理由不相信)。 +> +> “侵害assulting” 这个词,意味着他使用了某种暴力。但那篇报道并没有提到这个,只说了他们发生了性关系。 +> +> 我们可以想像很多种情况,但最合理的情况是,她在 Marvin 面前表现的像是完全自愿的。假设她是被爱泼斯坦强迫的,那爱泼斯坦有充足的理由让她对大多数人守口如瓶。 +> +> 从各种的指控夸大事例中,我总结出,在指控时使用“性侵犯sexual assault”是绝对错误的。 +> +> 无论你想要批判什么行为,你都应该使用特定的词汇来描述,以此避免批判的本质的道德模糊性。 + +### “清除 Stallman” 的呼吁 + +‘爱泼斯坦’在美国是颇具争议的‘话题’。Stallman 对该敏感事件做出如此鲁莽的 “知识陈述” 不会有好结果,事实也是如此。 + +一位机器人学工程师从她的朋友那里收到了转发的邮件并发起了一个[清除 Stallman 的活动][7]。她要的不是澄清或者道歉,她只想要清除斯托曼,就算这意味着 “将 MIT 夷为平地” 也在所不惜。 + +> 是,至少 Stallman 没有被控强奸任何人。但这就是我们的最高标准吗?这所声望极高的学院坚持的标准就是这样的吗?如果这是麻省理工学院想要捍卫的、想要代表的标准的话,还不如把这破学校夷为平地… +> +> 如果有必要的话,就把所有人都清除出去,之后从废墟中建立出更好的秩序。 +> +> —— Salem,发起“清除 Stallman“运动的机器人学专业学生 + +Salem 的声讨最初没有被主流媒体重视。但它还是被反对软件行业内的精英崇拜以及性别偏见的积极分子发现了。 + +> [#epstein][8] [#MIT][9] 嗨 记者没有回复我我很生气就自己写了这么个故事。作为 MIT 的校友我还真是高兴啊🙃 +> +> — SZJG (@selamjie) [September 12, 2019][10] + +. + +> 是不是对于性侵儿童的 “杰出混蛋” 我们也可以辩护说 “万一这是你情我愿的” +> +> — Tracy Chou 👩🏻‍💻 (@triketora) [September 13, 2019][11] + +. + +> 多年来我就一直发推说 Richard "RMS" Stallman 这人有多恶心 —— 恋童癖、厌女症、还残障歧视 +> +> 不可避免的是,每次我这样做,都会有老哥检查我的数据来源,然后说 “这都是几年前的事了!他现在变了!” +> +> 变个屁。 +> +> — Sarah Mei (@sarahmei) [September 12, 2019][12] + +下面是 Sage Sharp 开头的一篇关于 Stallman 的行为如何对科技人员产生负面影响的帖子: + +> 👇大家说下 Richard Stallman 对科技从业者的影响吧,尤其是女性。 [例如: 强奸、乱伦、残障歧视、性交易] +> +> [@fsf][13] 有必要永久禁止 Richard Stallman 担任自由软件基金会董事会主席。 +> +> — Sage Sharp (@\_sagesharp\_) [September 16, 2019][14] + +Stallman 一直以来也不是一个圣人。他粗暴,不合时宜、多年来一直在开带有性别歧视的笑话。你可以在[这里][15]和[这里][16]读到。 + +很快这个消息就被 [The Vice][17]、[每日野兽][18],[未来主义][19]等大媒体采访。他们把 Stallman 描绘成爱泼斯坦的捍卫者。在强烈的抗议声中,[GNOME 执行董事威胁要结束 GNOME 和 FSF 之间的关系][20]。 + +最后,Stallman 先是从 MIT 辞职,现在又从 [自由软件基金会][21] 辞职。 + +![][22] + +### 危险的特权? + +我们见识到了,把一个人从他创建并为之工作了三十多年的组织中驱逐出去仅仅需要五天。这甚至还是在 Stallman 没有参与性交易丑闻的情况下。 + +其中一些 “活动家” 过去也曾[针对过 Linux 的作者 Linus Torvalds][23]。Linux 基金会背后的管理层预见到了科技行业激进主义的增长趋势,因此他们制定了[适用于 Linux 内核开发的行为准则][24]并[强制 Torvalds 接受培训以改善他的行为][25]。如果他们没有采取纠正措施,可能 Torvalds 也已经被批倒批臭了。 + +忽视技术支持者的鲁莽行为和性别歧视是不可接受的,但是对于那些遇到不同意某种流行观点的人就进行声讨,施以私刑也是不道德的做法。我不支持 Stallman 和他过去的言论,但我也不能接受他以这种方式(被迫?)辞职。 + +Techrights 对此有一些有趣的评论,你可以在[这里][26]和[这里][27]看到。 + +*你对此事有何看法?请文明分享你的观点和意见。过激评论将不会公布。* + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/richard-stallman-controversy/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[name1e5s](https://github.com/name1e5s) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/stallman-conroversy.png?w=800&ssl=1 +[2]: https://en.wikipedia.org/wiki/Richard_Stallman +[3]: https://en.wikipedia.org/wiki/Massachusetts_Institute_of_Technology +[4]: https://en.wikipedia.org/wiki/Free_software_movement +[5]: https://en.wikipedia.org/wiki/Jeffrey_Epstein +[6]: https://en.wikipedia.org/wiki/Marvin_Minsky +[7]: https://medium.com/@selamie/remove-richard-stallman-fec6ec210794 +[8]: https://twitter.com/hashtag/epstein?src=hash&ref_src=twsrc%5Etfw +[9]: https://twitter.com/hashtag/MIT?src=hash&ref_src=twsrc%5Etfw +[10]: https://twitter.com/selamjie/status/1172244207978897408?ref_src=twsrc%5Etfw +[11]: https://twitter.com/triketora/status/1172443389536555009?ref_src=twsrc%5Etfw +[12]: https://twitter.com/sarahmei/status/1172283772428906496?ref_src=twsrc%5Etfw +[13]: https://twitter.com/fsf?ref_src=twsrc%5Etfw +[14]: https://twitter.com/_sagesharp_/status/1173637138413318144?ref_src=twsrc%5Etfw +[15]: https://geekfeminism.wikia.org/wiki/Richard_Stallman +[16]: https://medium.com/@selamie/remove-richard-stallman-appendix-a-a7e41e784f88 +[17]: https://www.vice.com/en_us/article/9ke3ke/famed-computer-scientist-richard-stallman-described-epstein-victims-as-entirely-willing +[18]: https://www.thedailybeast.com/famed-mit-computer-scientist-richard-stallman-defends-epstein-victims-were-entirely-willing +[19]: https://futurism.com/richard-stallman-epstein-scandal +[20]: https://blog.halon.org.uk/2019/09/gnome-foundation-relationship-gnu-fsf/ +[21]: https://www.fsf.org/news/richard-m-stallman-resigns +[22]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/richard-stallman.png?resize=800%2C94&ssl=1 +[23]: https://www.newyorker.com/science/elements/after-years-of-abusive-e-mails-the-creator-of-linux-steps-aside +[24]: https://itsfoss.com/linux-code-of-conduct/ +[25]: https://itsfoss.com/torvalds-takes-a-break-from-linux/ +[26]: http://techrights.org/2019/09/15/media-attention-has-been-shifted/ +[27]: http://techrights.org/2019/09/16/stallman-removed/ diff --git a/published/20190918 How to remove carriage returns from text files on Linux.md b/published/20190918 How to remove carriage returns from text files on Linux.md new file mode 100644 index 0000000000..2f746068d7 --- /dev/null +++ b/published/20190918 How to remove carriage returns from text files on Linux.md @@ -0,0 +1,111 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11389-1.html) +[#]: subject: (How to remove carriage returns from text files on Linux) +[#]: via: (https://www.networkworld.com/article/3438857/how-to-remove-carriage-returns-from-text-files-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如何在 Linux 中删除文本中的回车字符 +====== + +> 当回车字符(`Ctrl+M`)让你紧张时,别担心。有几种简单的方法消除它们。 + +![](https://img.linux.net.cn/data/attachment/album/201909/25/214211xenk2dqfepx3xemm.jpg) + +“回车”字符可以往回追溯很长一段时间 —— 早在打字机上就有一个机械装置或杠杆将承载纸滚筒的机架移到右边,以便可以重新在左侧输入字母。他们在 Windows 上的文本文件上保留了它,但从未在 Linux 系统上使用过。当你尝试在 Linux 上处理在 Windows 上创建的文件时,这种不兼容性有时会导致问题,但这是一个非常容易解决的问题。 + +如果你使用 `od`(八进制转储octal dump)命令查看文件,那么回车(也用 `Ctrl+M` 代表)字符将显示为八进制的 15。字符 `CRLF` 通常用于表示 Windows 文本文件中的一行结束的回车符和换行符序列。那些注意看八进制转储的会看到 `\r\n`。相比之下,Linux 文本仅以换行符结束。 + +这有一个 `od` 输出的示例,高亮显示了行中的 `CRLF` 字符,以及它的八进制。 + +``` +$ od -bc testfile.txt +0000000 124 150 151 163 040 151 163 040 141 040 164 145 163 164 040 146 + T h i s i s a t e s t f +0000020 151 154 145 040 146 162 157 155 040 127 151 156 144 157 167 163 + i l e f r o m W i n d o w s +0000040 056 015 012 111 164 047 163 040 144 151 146 146 145 162 145 156 <== + . \r \n I t ' s d i f f e r e n <== +0000060 164 040 164 150 141 156 040 141 040 125 156 151 170 040 164 145 + t t h a n a U n i x t e +0000100 170 164 040 146 151 154 145 015 012 167 157 165 154 144 040 142 <== + x t f i l e \r \n w o u l d b <== +``` + +虽然这些字符不是大问题,但是当你想要以某种方式解析文本,并且不希望就它们是否存在进行编码时,这有时候会产生干扰。 + +### 3 种从文本中删除回车符的方法 + +幸运的是,有几种方法可以轻松删除回车符。这有三个选择: + +#### dos2unix + +你可能会在安装时遇到麻烦,但 `dos2unix` 可能是将 Windows 文本转换为 Unix/Linux 文本的最简单方法。一个命令带上一个参数就行了。不需要第二个文件名。该文件会被直接更改。 + +``` +$ dos2unix testfile.txt +dos2unix: converting file testfile.txt to Unix format... +``` + +你应该会发现文件长度减少,具体取决于它包含的行数。包含 100 行的文件可能会缩小 99 个字符,因为只有最后一行不会以 `CRLF` 字符结尾。 + +之前: + +``` +-rw-rw-r-- 1 shs shs 121 Sep 14 19:11 testfile.txt +``` + +之后: + +``` +-rw-rw-r-- 1 shs shs 118 Sep 14 19:12 testfile.txt +``` + +如果你需要转换大量文件,不用每次修复一个。相反,将它们全部放在一个目录中并运行如下命令: + +``` +$ find . -type f -exec dos2unix {} \; +``` + +在此命令中,我们使用 `find` 查找常规文件,然后运行 `dos2unix` 命令一次转换一个。命令中的 `{}` 将被替换为文件名。运行时,你应该处于包含文件的目录中。此命令可能会损坏其他类型的文件,例如除了文本文件外在上下文中包含八进制 15 的文件(如,镜像文件中的字节)。 + +#### sed + +你还可以使用流编辑器 `sed` 来删除回车符。但是,你必须提供第二个文件名。以下是例子: + +``` +$ sed -e “s/^M//” before.txt > after.txt +``` + +一件需要注意的重要的事情是,请不要输入你看到的字符。你必须按下 `Ctrl+V` 后跟 `Ctrl+M` 来输入 `^M`。`s` 是替换命令。斜杠将我们要查找的文本(`Ctrl + M`)和要替换的文本(这里为空)分开。 + +#### vi + +你甚至可以使用 `vi` 删除回车符(`Ctrl+M`),但这里假设你没有打开数百个文件,或许也在做一些其他的修改。你可以键入 `:` 进入命令行,然后输入下面的字符串。与 `sed` 一样,命令中 `^M` 需要通过 `Ctrl+V` 输入 `^`,然后 `Ctrl+M` 插入 `M`。`%s` 是替换操作,斜杠再次将我们要删除的字符和我们想要替换它的文本(空)分开。 `g`(全局)意味在所有行上执行。 + +``` +:%s/^M//g +``` + +### 总结 + +`dos2unix` 命令可能是最容易记住的,也是从文本中删除回车的最可靠的方法。其他选择使用起来有点困难,但它们提供相同的基本功能。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3438857/how-to-remove-carriage-returns-from-text-files-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.flickr.com/photos/kmsiever/5895380540/in/photolist-9YXnf5-cNmpxq-2KEvib-rfecPZ-9snnkJ-2KAcDR-dTxzKW-6WdgaG-6H5i46-2KzTZX-7cnSw7-e3bUdi-a9meh9-Zm3pD-xiFhs-9Hz6YM-ar4DEx-4PXAhw-9wR4jC-cihLcs-asRFJc-9ueXvG-aoWwHq-atwL3T-ai89xS-dgnntH-5en8Te-dMUDd9-aSQVn-dyZqij-cg4SeS-abygkg-f2umXt-Xk129E-4YAeNn-abB6Hb-9313Wk-f9Tot-92Yfva-2KA7Sv-awSCtG-2KDPzb-eoPN6w-FE9oi-5VhaNf-eoQgx7-eoQogA-9ZWoYU-7dTGdG-5B1aSS +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/20190918 Microsoft brings IBM iron to Azure for on-premises migrations.md b/published/20190918 Microsoft brings IBM iron to Azure for on-premises migrations.md new file mode 100644 index 0000000000..4063ab4778 --- /dev/null +++ b/published/20190918 Microsoft brings IBM iron to Azure for on-premises migrations.md @@ -0,0 +1,55 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11375-1.html) +[#]: subject: (Microsoft brings IBM iron to Azure for on-premises migrations) +[#]: via: (https://www.networkworld.com/article/3438904/microsoft-brings-ibm-iron-to-azure-for-on-premises-migrations.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Skytap 和微软将 IBM 机器搬到了 Azure +====== + +> 微软再次证明了其摒弃了“非我发明”这一态度来支持客户。 + +![](https://images.idgesg.net/images/article/2019/05/cso_microsoft_azure_backups_cloud_computing_binary_data_transfer_by_just_super_gettyimages-1003878434_3x2_2400x1600-100796537-large.jpg) + +当微软将 Azure 作为其 Windows 服务器操作系统的云计算版本发布时,它并没有使其成为仅支持 Windows 系统的版本,它还支持 Linux 系统,并且在短短几年内[其 Linux 实例的数量现在已经超过了Windows 实例的数量][1]。 + +很高兴看到微软终于摆脱了这种长期以来非常有害的“非我发明”态度,该公司的最新举动确实令人惊讶。 + +微软与一家名为 Skytap 的公司合作,以在 Azure 云服务上提供 IBM Power9 实例,可以在 Azure 云内运行基于 Power 的系统,该系统将与其已有的 Xeon 和 Epyc 实例一同作为 Azure 的虚拟机(VM)。 + +Skytap 是一家有趣的公司。它由华盛顿大学的三位教授创立,专门研究本地遗留硬件的云迁移,如 IBM System I 或 Sparc 的云迁移。该公司在西雅图拥有一个数据中心,以 IBM 的硬件运行 IBM 的 PowerVM 管理程序,并且对在美国和英格兰的 IBM 数据中心提供主机托管。 + +该公司的座右铭是快速迁移,然后按照自己的节奏进行现代化。因此,它专注于帮助一些企业将遗留系统迁移到云,然后实现应用程序的现代化,这也是它与微软合作的目的。Azure 将通过为企业提供平台来提高传统应用程序的价值,而无需花费巨额费用重写一个新平台。 + +Skytap 提供了预览,可以看到使用 Skytap 上的 DB2 提升和扩展原有的 IBM i 应用程序以及通过 Azure 的物联网中心进行扩展时可能发生的情况。该应用程序无缝衔接新旧架构,并证明了不需要完全重写可靠的 IBM i 应用程序即可从现代云功能中受益。 + +### 迁移到 Azure + +根据协议,微软将把 IBM 的 Power S922 服务器部署在一个未声明的 Azure 区域。这些机器可以运行 PowerVM 管理程序,这些管理程序支持老式 IBM 操作系统以及 Linux 系统。 + +Skytap 首席执行官布拉德·希克Brad Schick在一份声明中说道:“通过先替换旧技术来迁移上云既耗时又冒险。……Skytap 的愿景一直是通过一些小小的改变和较低的风险实现企业系统到云平台的迁移。与微软合作,我们将为各种遗留应用程序迁移到 Azure 提供本地支持,包括那些在 IBM i、AIX 和 Power Linux 上运行的程序。这将使企业能够通过使用 Azure 服务进行现代化来延长传统系统的寿命并增加其价值。” + +随着基于 Power 应用程序的现代化,Skytap 随后将引入 DevOps CI/CD 工具链来加快软件的交付。迁移到 Azure 的 Skytap 上后,客户将能够集成 Azure DevOps,以及 Power 的 CI/CD 工具链,例如 Eradani 和 UrbanCode。 + +这些听起来像是迈出了第一步,但这意味着以后将会实现更多,尤其是在应用程序迁移方面。如果它仅在一个 Azure 区域中,听起来好像它们正在对该项目进行测试和验证,并可能在今年晚些时候或明年进行扩展。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3438904/microsoft-brings-ibm-iron-to-azure-for-on-premises-migrations.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.openwall.com/lists/oss-security/2019/06/27/7 +[2]: https://www.networkworld.com/article/3119362/hybrid-cloud/how-to-make-hybrid-cloud-work.html#tk.nww-fsb +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/20190918 Oracle Unleashes World-s Fastest Database Machine ‘Exadata X8M.md b/published/20190918 Oracle Unleashes World-s Fastest Database Machine ‘Exadata X8M.md new file mode 100644 index 0000000000..8721fea8c8 --- /dev/null +++ b/published/20190918 Oracle Unleashes World-s Fastest Database Machine ‘Exadata X8M.md @@ -0,0 +1,64 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11366-1.html) +[#]: subject: (Oracle Unleashes World’s Fastest Database Machine ‘Exadata X8M’) +[#]: via: (https://opensourceforu.com/2019/09/oracle-unleashes-worlds-fastest-database-machine-exadata-x8m/) +[#]: author: (Longjam Dineshwori https://opensourceforu.com/author/dineshwori-longjam/) + +Oracle 发布全球最快的数据库机器 Exadata X8M +====== + +> Exadata X8M 是第一台具有集成持久内存和 RoCE 的数据库机器。Oracle 还宣布推出 Oracle 零数据丢失恢复设备 X8M(ZDLRA)。 + +![](https://img.linux.net.cn/data/attachment/album/201909/20/191530qiyvvxl8qqcov8xq.jpg) + +Oracle 发布了新的 Exadata 数据库机器 X8M,旨在为数据库基础架构市场树立新的标杆。 + +Exadata X8M 结合了英特尔 Optane DC 持久存储器和通过融合以太网(RoCE)的 100 千兆的远程直接内存访问(RDMA)来消除存储瓶颈,并显著提高性能,其适用于最苛刻的工作负载,如在线事务处理(OLTP)、分析、物联网、欺诈检测和高频交易。 + +“借助 Exadata X8M,我们可以提供内存级的性能,同时为 OLTP 和分析提供共享存储的所有优势,”Oracle 任务关键型数据库技术执行副总裁 Juan Loaiza 说。 + +“使用对共享持久存储器的直接数据库访问将响应时间减少一个数量级,可加速每个 OLTP 应用程序,它是需要实时访问大量数据的应用程序的游戏规则改变者,例如欺诈检测和个性化购物,”官方补充。 + +### 它有什么独特之处? + +Oracle Exadata X8M 使用 RDMA 让数据库直接访问智能存储服务器中的持久内存,从而绕过整个操作系统、IO 和网络软件堆栈。这导致更低的延迟和更高的吞吐量。使用 RDMA 绕过软件堆栈还可以释放存储服务器上的 CPU 资源,以执行更多智能扫描查询来支持分析工作负载。 + +### 更少的存储瓶颈 + +“高性能 OLTP 应用需要高的每秒输入/输出操作(IOPS)和低延迟。直接数据库访问共享持久性内存可将SQL 读取的峰值性能提升至 1600 万 IOPS,比行业领先的 Exadata X8 高出 2.5 倍,“Oracle 在一份声明中表示。 + +此外,Exadata X8M 通过使远程 IO 延迟低于 19 微秒,大大减少了关键数据库 IO 的延迟 —— 这比 Exadata X8 快 10 倍以上。即使对于每秒需要数百万 IO 的工作负载,也可实现这些超低延迟。 + +### 比 AWS 和 Azure 更高效 + +该公司声称,与 Oracle 最快的 Amazon RDS 存储相比,Exadata X8M 的延迟降低了 50 倍,IOPS 提高了 200 倍,容量提高了 15 倍。 + +与 Azure SQL 数据库服务存储相比,Exadata X8M 的延迟降低了 100 倍,IOPS 提高了 150 倍,容量提高了 300 倍。 + +据 Oracle 称,单机架 Exadata X8M 可提供高达 2 倍的 OLTP 读取 IOPS,3 倍的吞吐量和比具有持久性内存的共享存储系统(如 Dell EMC PowerMax 8000 的单机架)低 5 倍的延迟。 + +“通过同时支持更快的 OLTP 查询和更高的分析工作负载吞吐量,Exadata X8M 是融合混合工作负载环境以降低 IT 成本和复杂性的理想平台,”该公司说。 + +### Oracle 零数据丢失恢复设备 X8 + +Oracle 当天还宣布推出 Oracle 零数据丢失恢复设备 X8M(ZDLRA),它使用新的 100Gb RoCE,用于计算和存储服务器之间的高吞吐量内部数据传输。 + +Exadata 和 ZDLRA 客户现在可以在 RoCE 或基于 InfiniBand 的工程系统之间进行选择,以在其架构部署中实现最佳灵活性。 + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/09/oracle-unleashes-worlds-fastest-database-machine-exadata-x8m/ + +作者:[Longjam Dineshwori][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensourceforu.com/author/dineshwori-longjam/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/02/Oracle-Cloud.jpg?resize=350%2C212&ssl=1 diff --git a/published/20190921 How to Remove (Delete) Symbolic Links in Linux.md b/published/20190921 How to Remove (Delete) Symbolic Links in Linux.md new file mode 100644 index 0000000000..bbe57011eb --- /dev/null +++ b/published/20190921 How to Remove (Delete) Symbolic Links in Linux.md @@ -0,0 +1,130 @@ +[#]: collector: (lujun9972) +[#]: translator: (arrowfeng) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11382-1.html) +[#]: subject: (How to Remove (Delete) Symbolic Links in Linux) +[#]: via: (https://www.2daygeek.com/remove-delete-symbolic-link-softlink-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +在 Linux 中怎样移除(删除)符号链接 +====== + +你可能有时需要在 Linux 上创建或者删除符号链接。如果有,你知道该怎样做吗?之前你做过吗?你踩坑没有?如果你踩过坑,那没什么问题。如果还没有,别担心,我们将在这里帮助你。 + +使用 `rm` 和 `unlink` 命令就能完成移除(删除)符号链接的操作。 + +### 什么是符号链接? + +符号链接(symlink)又称软链接,它是一种特殊的文件类型,在 Linux 中该文件指向另一个文件或者目录。它类似于 Windows 中的快捷方式。它能在相同或者不同的文件系统或分区中指向一个文件或着目录。 + +符号链接通常用来链接库文件。它也可用于链接日志文件和挂载的 NFS(网络文件系统)上的文件夹。 + +### 什么是 rm 命令? + +[rm 命令][1] 被用来移除文件和目录。它非常危险,你每次使用 `rm` 命令的时候要非常小心。 + +### 什么是 unlink 命令? + +`unlink` 命令被用来移除特殊的文件。它被作为 GNU Gorutils 的一部分安装了。 + +### 1) 使用 rm 命令怎样移除符号链接文件 + +`rm` 命令是在 Linux 中使用最频繁的命令,它允许我们像下列描述那样去移除符号链接。 + +``` +# rm symlinkfile +``` + +始终将 `rm` 命令与 `-i` 一起使用以了解正在执行的操作。 + +``` +# rm -i symlinkfile1 +rm: remove symbolic link ‘symlinkfile1’? y +``` + +它允许我们一次移除多个符号链接: + +``` +# rm -i symlinkfile2 symlinkfile3 + +rm: remove symbolic link ‘symlinkfile2’? y +rm: remove symbolic link ‘symlinkfile3’? y +``` + +#### 1a) 使用 rm 命令怎样移除符号链接目录 + +这像移除符号链接文件那样。使用下列命令移除符号链接目录。 + +``` +# rm -i symlinkdir + +rm: remove symbolic link ‘symlinkdir’? y +``` + +使用下列命令移除多个符号链接目录。 + +``` +# rm -i symlinkdir1 symlinkdir2 + +rm: remove symbolic link ‘symlinkdir1’? y +rm: remove symbolic link ‘symlinkdir2’? y +``` + +如果你在结尾增加 `/`,这个符号链接目录将不会被删除。如果你加了,你将得到一个错误。 + +``` +# rm -i symlinkdir/ + +rm: cannot remove ‘symlinkdir/’: Is a directory +``` + +你可以增加 `-r` 去处理上述问题。**但如果你增加这个参数,它将会删除目标目录下的内容,并且它不会删除这个符号链接文件。**(LCTT 译注:这可能不是你的原意。) + +``` +# rm -ri symlinkdir/ + +rm: descend into directory ‘symlinkdir/’? y +rm: remove regular file ‘symlinkdir/file4.txt’? y +rm: remove directory ‘symlinkdir/’? y +rm: cannot remove ‘symlinkdir/’: Not a directory +``` + +### 2) 使用 unlink 命令怎样移除符号链接 + +`unlink` 命令删除指定文件。它一次仅接受一个文件。 + +删除符号链接文件: + +``` +# unlink symlinkfile +``` + +删除符号链接目录: + +``` +# unlink symlinkdir2 +``` + +如果你在结尾增加 `/`,你不能使用 `unlink` 命令删除符号链接目录。 + +``` +# unlink symlinkdir3/ + +unlink: cannot unlink ‘symlinkdir3/’: Not a directory +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/remove-delete-symbolic-link-softlink-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[arrowfeng](https://github.com/arrowfeng) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/linux-remove-files-directories-folders-rm-command/ diff --git a/published/20190921 Oracle Autonomous Linux- A Self Updating, Self Patching Linux Distribution for Cloud Computing.md b/published/20190921 Oracle Autonomous Linux- A Self Updating, Self Patching Linux Distribution for Cloud Computing.md new file mode 100644 index 0000000000..5390aee222 --- /dev/null +++ b/published/20190921 Oracle Autonomous Linux- A Self Updating, Self Patching Linux Distribution for Cloud Computing.md @@ -0,0 +1,64 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11370-1.html) +[#]: subject: (Oracle Autonomous Linux: A Self Updating, Self Patching Linux Distribution for Cloud Computing) +[#]: via: (https://itsfoss.com/oracle-autonomous-linux/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +Oracle Autonomous Linux:用于云计算的自我更新、自我修补的 Linux 发行版 +====== + +自动化是 IT 行业的增长趋势,其目的是消除重复任务中的手动干扰。Oracle 通过推出 Oracle Autonomous Linux 向自动化世界迈出了又一步,这无疑将使 IoT 和云计算行业受益。 + +### Oracle Autonomous Linux:减少人工干扰,增多自动化 + +![][1] + +周一,Oracle 联合创始人拉里·埃里森Larry Ellison参加了在旧金山举行的Oracle OpenWorld 全球大会。[他宣布了][2]一个新产品:世界上第一个自治 Linux。这是 Oracle 向第二代云迈进的第二步。第一步是两年前发布的 [Autonomous Database][3]。 + +Oracle Autonomous Linux 的最大特性是降低了维护成本。根据 [Oracle 网站][4] 所述,Autonomous Linux “使用先进的机器学习和自治功能来提供前所未有的成本节省、安全性和可用性,并释放关键的 IT 资源来应对更多的战略计划”。 + +Autonomous Linux 可以无需人工干预就安装更新和补丁。这些自动更新包括 “Linux 内核和关键用户空间库”的补丁。“不需要停机,而且可以免受外部攻击和内部恶意用户的攻击。”它们也可以在系统运行时进行,以减少停机时间。Autonomous Linux 还会自动处理伸缩,以确保满足所有计算需求。 + +埃里森强调了新的自治系统将如何提高安全性。他特别提到了 [Capitol One 数据泄露][5]是由于配置错误而发生的。他说:“一个防止数据被盗的简单规则:将数据放入自治系统。没有人为错误,没有数据丢失。 那是我们与 AWS 之间的最大区别。” + +有趣的是,Oracle 还瞄准了这一新产品以与 IBM 竞争。埃里森说:“如果你付钱给 IBM,可以停了。”所有 Red Hat 应用程序都应该能够在 Autonomous Linux 上运行而无需修改。有趣的是,Oracle Linux 是从 Red Hat Enterprise Linux 的源代码中[构建][6]的。 + +看起来,Oracle Autonomous Linux 不会用于企业市场以外。 + +### 关于 Oracle Autonomous Linux 的思考 + +Oracle 是云服务市场的重要参与者。这种新的 Linux 产品将使其能够与 IBM 竞争。让人感兴趣的是 IBM 的反应会是如何,特别是当他们有来自 Red Hat 的新一批开源智能软件。 + +如果你看一下市场数字,那么对于 IBM 或 Oracle 来说情况都不好。大多数云业务由 [Amazon Web Services、Microsoft Azure 和 Google Cloud Platform][7] 所占据。IBM 和 Oracle 落后于他们。[IBM 收购 Red Hat][8] 试图获得发展。这项新的自主云计划是 Oracle 争取统治地位(或至少试图获得更大的市场份额)的举动。让人感兴趣的是,到底有多少公司因为购买了 Oracle 的系统而在互联网的狂野西部变得更加安全? + +我必须简单提一下:当我第一次阅读该公告时,我的第一反应就是“好吧,我们离天网更近了一步。”如果我们技术性地考虑一下,我们就像是要进入了机器人末日。如果你打算帮我,我计划去购买一些罐头食品。 + +你对 Oracle 的新产品感兴趣吗?你会帮助他们赢得云战争吗?在下面的评论中让我们知道。 + +如果你觉得这篇文章有趣,请花一点时间在社交媒体、Hacker News 或 [Reddit][9] 上分享。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/oracle-autonomous-linux/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/oracle-autonomous-linux.png?resize=800%2C450&ssl=1 +[2]: https://www.zdnet.com/article/oracle-announces-oracle-autonomous-linux/ +[3]: https://www.oracle.com/in/database/what-is-autonomous-database.html +[4]: https://www.oracle.com/corporate/pressrelease/oow19-oracle-autonomous-linux-091619.html +[5]: https://www.zdnet.com/article/100-million-americans-and-6-million-canadians-caught-up-in-capital-one-breach/ +[6]: https://distrowatch.com/table.php?distribution=oracle +[7]: https://www.zdnet.com/article/top-cloud-providers-2019-aws-microsoft-azure-google-cloud-ibm-makes-hybrid-move-salesforce-dominates-saas/ +[8]: https://itsfoss.com/ibm-red-hat-acquisition/ +[9]: https://reddit.com/r/linuxusersgroup diff --git a/scripts/check/common.inc.sh b/scripts/check/common.inc.sh index 2bc0334930..905699a139 100644 --- a/scripts/check/common.inc.sh +++ b/scripts/check/common.inc.sh @@ -10,7 +10,7 @@ export TSL_DIR='translated' # 已翻译 export PUB_DIR='published' # 已发布 # 定义匹配规则 -export CATE_PATTERN='(talk|tech)' # 类别 +export CATE_PATTERN='(talk|tech|news)' # 类别 export FILE_PATTERN='[0-9]{8} [a-zA-Z0-9_.,() -]*\.md' # 文件名 # 获取用于匹配操作的正则表达式 diff --git a/sources/news/20190921 Samsung introduces SSDs it claims will -never die.md b/sources/news/20190921 Samsung introduces SSDs it claims will -never die.md new file mode 100644 index 0000000000..09c1a52d7a --- /dev/null +++ b/sources/news/20190921 Samsung introduces SSDs it claims will -never die.md @@ -0,0 +1,58 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Samsung introduces SSDs it claims will 'never die') +[#]: via: (https://www.networkworld.com/article/3440026/samsung-introduces-ssds-it-claims-will-never-die.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Samsung introduces SSDs it claims will 'never die' +====== +New fail-in-place technology in Samsung's SSDs will allow the chips to gracefully recover from chip failure. +Samsung + +[Solid-state drives][1] (SSDs) operate by writing to cells within the chip, and after so many writes, the cell eventually dies off and can no longer be written to. For that reason, SSDs have more actual capacity than listed. A 1TB drive, for example, has about 1.2TB of capacity, and as chips die off from repeated writes, new ones are brought online to keep the 1TB capacity. + +But that's for gradual wear. Sometimes SSDs just up and die completely, and without warning after a whole chip fails, not just a few cells. So Samsung is trying to address that with a new generation of SSD memory chips with a technology it calls fail-in-place (FIP). + +**Also read: [Inside Hyperconvergence: Combining compute, storage and networking][2]** + +FIP technology allows a drive to cope with a failure by working around the dead chip and allowing the SSD to keep operating and just not using the bad chip. You will have less storage, but in all likelihood that drive will be replaced anyway, so this helps prevent data loss. + +FIP also scans the data for any damage before copying it to the remaining NAND, which would be the first time I've ever seen a SSD with built-in data recovery. + +### Built-in virtualization and machine learning technology + +The new Samsung SSDs come with two other software innovations. The first is built-in virtualization technology, which allows a single SSD to be divided up into up to 64 smaller drives for a virtual environment. + +The second is V-NAND machine learning technology, which helps to "accurately predict and verify cell characteristics, as well as detect any variation among circuit patterns through big data analytics," as Samsung put it. Doing so means much higher levels of performance from the drive. + +As you can imagine, this technology is aimed at enterprises and large-scale data centers, not consumers. All told, Samsung is launching 19 models of these new SSDs called under the names PM1733 and PM1735. + +**[ [Get certified as an Apple Technical Coordinator with this seven-part online course from PluralSight.][3] ]** + +The PM1733 line features six models in a 2.5-inch U.2 form factor, offering storage capacity of between 960GB and 15.63TB, as well as four HHHL card-type drives with capacity ranging from 1.92TB to 30.72TB of storage. Each drive is guaranteed for one drive writes per day (DWPD) for five years. In other words, the warranty is good for writing the equivalent of the drive's total capacity once per day every day for five years. + +The PM1735 drives have lower capacity, maxing out at 12.8TB, but they are far more durable, guaranteeing three DWPD for five years. Both drives support PCI Express 4, which has double the throughput of the widely used PCI Express 3. The PM1735 offers nearly 14 times the sequential performance of a SATA-based SSD, with 8GB/s for read operations and 3.8GB/s for writes. + +Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3440026/samsung-introduces-ssds-it-claims-will-never-die.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3326058/what-is-an-ssd.html +[2]: https://www.idginsiderpro.com/article/3409019/inside-hyperconvergence-combining-compute-storage-and-networking.html +[3]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fapple-certified-technical-trainer-10-11 +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/sources/news/20190924 Global Tech Giants Form Presto Foundation to Tackle Distributed Data Processing at Scale.md b/sources/news/20190924 Global Tech Giants Form Presto Foundation to Tackle Distributed Data Processing at Scale.md new file mode 100644 index 0000000000..f2525fa198 --- /dev/null +++ b/sources/news/20190924 Global Tech Giants Form Presto Foundation to Tackle Distributed Data Processing at Scale.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Global Tech Giants Form Presto Foundation to Tackle Distributed Data Processing at Scale) +[#]: via: (https://opensourceforu.com/2019/09/global-tech-giants-form-presto-foundation-to-tackle-distributed-data-processing-at-scale/) +[#]: author: (Longjam Dineshwori https://opensourceforu.com/author/dineshwori-longjam/) + +Global Tech Giants Form Presto Foundation to Tackle Distributed Data Processing at Scale +====== + + * _**The Foundation aims to make the database search engine “the fastest and most reliable SQL engine for massively distributed data processing.”**_ + * _**Presto’s architecture allows users to query a variety of data sources and move at scale and speed.**_ + + + +![Facebook][1] + +Facebook, Uber, Twitter and Alibaba have joined hands to form a foundation to help Presto, a database search engine and processing tool, scale and diversify its community. + +Under Presto will be now hosted under the Linux Foundation, the U.S.-based non-profit organization announced on Monday. + +The newly established Presto Foundation will operate under a community governance model with representation from each of the founding members. It aims to make the engine “the fastest and most reliable SQL engine for massively distributed data processing.” + +“The Linux Foundation is excited to work with the Presto community, collaborating to solve the increasing problem of massive distributed data processing at internet scale,” said Michael Dolan, VP of Strategic Programs at the Linux Foundation.” + +**Presto can run on large clusters of machines** + +Presto was developed at Facebook in 2012 as a high-performance distributed SQL query engine for large scale data analytics. Presto’s architecture allows users to query a variety of data sources such as Hadoop, S3, Alluxio, MySQL, PostgreSQL, Kafka, MongoDB and move at scale and speed. + +It can query data where it is stored without needing to move the data to a separate system. Its in-memory and distributed query processing results in query latencies of seconds to minutes. + +“Presto has been designed for high performance exabyte-scale data processing on a large number of machines. Its flexible design allows processing data from a wide variety of data sources. From day one Presto has been designed with efficiency, scalability and reliability in mind, and it has been improved over the years to take on additional use cases at Facebook, such as batch and other application specific interactive use cases,” said Nezih Yigitbasi, Engineering Manager of Presto at Facebook. + +Presto is being used by over a thousand Facebook employees for running several million queries and processing petabytes of data per day, according to Kathy Kam, Head of Open Source at Facebook. + +**Expanding community for the benefit of all** + +Facebook released the source code of Presto to developers in 2013 in the hope that other companies would help to drive the future direction of the project. + +“It turns out many other companies were interested and so under The Linux Foundation, we believe the project can engage others and grow the community for the benefit of all,” said Kathy Kam. + +Uber’s data platform architecture uses Presto to extract critical insights from aggregated data. “Uber is honoured to partner with the Linux Foundation and major contributors from the tech community to bring the Presto Foundation to life. Our goal is to help create an open and collaborative community in which Presto developers can thrive,” asserted Brian Hsieh, Head of Open Source at Uber. + +Liang Lin, Senior Director of Alibaba OLAP products, believes that the collaboration would eventually benefit the community as well as Alibaba and its customers. + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/09/global-tech-giants-form-presto-foundation-to-tackle-distributed-data-processing-at-scale/ + +作者:[Longjam Dineshwori][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensourceforu.com/author/dineshwori-longjam/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2016/06/Facebook-Like.jpg?resize=350%2C213&ssl=1 diff --git a/sources/talk/20120911 Doug Bolden, Dunnet (IF).md b/sources/talk/20120911 Doug Bolden, Dunnet (IF).md deleted file mode 100644 index c856dc5be0..0000000000 --- a/sources/talk/20120911 Doug Bolden, Dunnet (IF).md +++ /dev/null @@ -1,52 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Doug Bolden, Dunnet (IF)) -[#]: via: (http://www.wyrmis.com/games/if/dunnet.html) -[#]: author: (W Doug Bolden http://www.wyrmis.com) - -Doug Bolden, Dunnet (IF) -====== - -### Dunnet (IF) - -#### Review - -When I began becoming a semi-serious hobbyist of IF last year, I mostly focused on Infocom, Adventures Unlimited, other Scott Adams based games, and freeware titles. I went on to buy some from Malinche. I picked up _1893_ and _Futureboy_ and (most recnetly) _Treasures of a Slave Kingdom_. I downloaded a lot of free games from various sites. With all of my research and playing, I never once read anything that talked about a game being bundled with Emacs. - -Partially, this is because I am a Vim guy. But I used to use Emacs. Kind of a lot. For probably my first couple of years with Linux. About as long as I have been a diehard Vim fan, now. I just never explored, it seems. - -I booted up Emacs tonight, and my fonts were hosed. Still do not know exactly why. I surfed some menus to find out what was going wrong and came across a menu option called "Adventure" under Games, which I assumed (I know, I know) meant the Crowther and Woods and 1977 variety. When I clicked it tonight, thinking that it has been a few months since I chased a bird around with a cage in a mine so I can fight off giant snakes or something, I was brought up text involving ends of roads and shovels. Trees, if shaken, that kill me with a coconut. This was not the game I thought it was. - -I dug around (or, in purely technical terms, typed "help") and got directed to [this website][1]. Well, here was an IF I had never touched before. Brand spanking new to me. I had planned to play out some _ToaSK_ tonight, but figured that could wait. Besides, I was not quite in the mood for the jocular fun of S. John Ross's commerical IF outing. I needed something a little more direct, and this apparently it. - -Most of the game plays out just like the _Colossal Cave Adventure_ cousins of the oldschool (generally commercial) IF days. There are items you pick. Each does a single task (well, there could be one exception to this, I guess). You collect treasures. Winning is a combination of getting to the end and turning in the treasures. The game slightly tweaks the formula by allowing multiple drop off points for the treasures. Since there is a weight limit, though, you usually have to drop them off at a particular time to avoid getting stuck. At several times, your "item cache" is flushed, so to speak, meaning you have to go back and replay earlier portions to find out how to bring things foward. Damage to items can occur to stop you from being able to play. Replaying is pretty much unavoidable, unless you guess outcomes just right. - -It also inherits many problems from the era it came. There is a twisty maze. I'm not sure how big it is. I just cheated and looked up a walkthrough for the maze portion. I plan on going back and replaying up to the maze bit and mapping it out, though. I was just mentally and physically beat when I played and knew that I was going to have to call it quits on the game for the night or cheat through the maze. I'm glad I cheated, because there are some interesting things after the maze. - -It also has the same sort of stilted syntax and variable levels of description that the original _Adventure_ had. Looking at one item might give you "there is nothing special about that" while looking at another might give you a sentence of flavor text. Several things mentioned in the background do not exist to the parser, which some do. Part of game play is putting up with experimenting. This includes, in cases, a tendency of room descriptions to be written from the perspective of the first time you enter. I know that the Classroom found towards the end of the game does not mention the South exit, either. There are possibly other times this occured that I didn't notice. - -It's final issue, again coming out of the era it was designed, is random death syndrome. This is not too common, but there are a few places where things that have no initially apparent fatal outcome lead to one anyhow. In some ways, this "fatal outcome" is just the game reaching an unwinnable state. For an example of the former, type "shake trees" in the first room. For an example of the latter, send either the lamp, the key, or the shovel through the ftp without switching ftp modes first. At least with the former, there is a sense of exploration in finding out new ways to die. In IF, creative deaths is a form of victory in their own right. - -_Dunnet_ has a couple of differences from most IF. The former difference is minor. There are little odd descriptions throughout the game. "This room is red" or "The towel has a picture of Snoopy one it" or "There is a cliff here" that do not seem to have an immediate effect on the game. Sure, you can jump over the cliff (and die, obviously) but but it still comes off as a bright spot in the standard description matrix. Towards the end, you will be forced to bring back these details. It makes a neat little diversion of looking around and exploring things. Most of the details are cute and/or add to the surreality of the game overall. - -The other big difference, and the one that greatly increased both my annoyance with and my enjoyment of the game, revolves around the two-three computer oriented scenes in the game. You have to type commands into two different computers throughout. One is a VAX and the other is, um, something like a PC (I forget). In both cases, there are clues to be found by knowing your way around the interface. This is a game for computer folk, so most who play it will have a sense of how to type "ls" or "dir" depending on the OS. But not all, will. Beating the game requires a general sense of computer literacy. You must know what types are in ftp. You must know how to determine what type a file is. You must know how to read a text file on a DOS style prompt. You must know something about protocols and etiquette for logging into ftp servers. All this sort of thing. If you do, or are willing to learn (I looked up some of the stuff online) then you can get past this portion with no problem. But this can be like the maze to some people, requiring several replays to get things right. - -The end result is a quirky but fun game that I wish I had known about before because now I have the feeling that my computer is hiding other secrets from me. Glad to have played. Will likely play again to see how many ways I can die. - --------------------------------------------------------------------------------- - -via: http://www.wyrmis.com/games/if/dunnet.html - -作者:[W Doug Bolden][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: http://www.wyrmis.com -[b]: https://github.com/lujun9972 -[1]: http://www.driver-aces.com/ronnie.html diff --git a/sources/talk/20140412 My Lisp Experiences and the Development of GNU Emacs.md b/sources/talk/20140412 My Lisp Experiences and the Development of GNU Emacs.md deleted file mode 100644 index 7be913c3bf..0000000000 --- a/sources/talk/20140412 My Lisp Experiences and the Development of GNU Emacs.md +++ /dev/null @@ -1,111 +0,0 @@ -My Lisp Experiences and the Development of GNU Emacs -====== - -> (Transcript of Richard Stallman's Speech, 28 Oct 2002, at the International Lisp Conference). - -Since none of my usual speeches have anything to do with Lisp, none of them were appropriate for today. So I'm going to have to wing it. Since I've done enough things in my career connected with Lisp I should be able to say something interesting. - -My first experience with Lisp was when I read the Lisp 1.5 manual in high school. That's when I had my mind blown by the idea that there could be a computer language like that. The first time I had a chance to do anything with Lisp was when I was a freshman at Harvard and I wrote a Lisp interpreter for the PDP-11. It was a very small machine — it had something like 8k of memory — and I managed to write the interpreter in a thousand instructions. This gave me some room for a little bit of data. That was before I got to see what real software was like, that did real system jobs. - -I began doing work on a real Lisp implementation with JonL White once I started working at MIT. I got hired at the Artificial Intelligence Lab not by JonL, but by Russ Noftsker, which was most ironic considering what was to come — he must have really regretted that day. - -During the 1970s, before my life became politicized by horrible events, I was just going along making one extension after another for various programs, and most of them did not have anything to do with Lisp. But, along the way, I wrote a text editor, Emacs. The interesting idea about Emacs was that it had a programming language, and the user's editing commands would be written in that interpreted programming language, so that you could load new commands into your editor while you were editing. You could edit the programs you were using and then go on editing with them. So, we had a system that was useful for things other than programming, and yet you could program it while you were using it. I don't know if it was the first one of those, but it certainly was the first editor like that. - -This spirit of building up gigantic, complicated programs to use in your own editing, and then exchanging them with other people, fueled the spirit of free-wheeling cooperation that we had at the AI Lab then. The idea was that you could give a copy of any program you had to someone who wanted a copy of it. We shared programs to whomever wanted to use them, they were human knowledge. So even though there was no organized political thought relating the way we shared software to the design of Emacs, I'm convinced that there was a connection between them, an unconscious connection perhaps. I think that it's the nature of the way we lived at the AI Lab that led to Emacs and made it what it was. - -The original Emacs did not have Lisp in it. The lower level language, the non-interpreted language — was PDP-10 Assembler. The interpreter we wrote in that actually wasn't written for Emacs, it was written for TECO. It was our text editor, and was an extremely ugly programming language, as ugly as could possibly be. The reason was that it wasn't designed to be a programming language, it was designed to be an editor and command language. There were commands like ‘5l’, meaning ‘move five lines’, or ‘i’ and then a string and then an ESC to insert that string. You would type a string that was a series of commands, which was called a command string. You would end it with ESC ESC, and it would get executed. - -Well, people wanted to extend this language with programming facilities, so they added some. For instance, one of the first was a looping construct, which was < >. You would put those around things and it would loop. There were other cryptic commands that could be used to conditionally exit the loop. To make Emacs, we (1) added facilities to have subroutines with names. Before that, it was sort of like Basic, and the subroutines could only have single letters as their names. That was hard to program big programs with, so we added code so they could have longer names. Actually, there were some rather sophisticated facilities; I think that Lisp got its unwind-protect facility from TECO. - -We started putting in rather sophisticated facilities, all with the ugliest syntax you could ever think of, and it worked — people were able to write large programs in it anyway. The obvious lesson was that a language like TECO, which wasn't designed to be a programming language, was the wrong way to go. The language that you build your extensions on shouldn't be thought of as a programming language in afterthought; it should be designed as a programming language. In fact, we discovered that the best programming language for that purpose was Lisp. - -It was Bernie Greenberg, who discovered that it was (2). He wrote a version of Emacs in Multics MacLisp, and he wrote his commands in MacLisp in a straightforward fashion. The editor itself was written entirely in Lisp. Multics Emacs proved to be a great success — programming new editing commands was so convenient that even the secretaries in his office started learning how to use it. They used a manual someone had written which showed how to extend Emacs, but didn't say it was a programming. So the secretaries, who believed they couldn't do programming, weren't scared off. They read the manual, discovered they could do useful things and they learned to program. - -So Bernie saw that an application — a program that does something useful for you — which has Lisp inside it and which you could extend by rewriting the Lisp programs, is actually a very good way for people to learn programming. It gives them a chance to write small programs that are useful for them, which in most arenas you can't possibly do. They can get encouragement for their own practical use — at the stage where it's the hardest — where they don't believe they can program, until they get to the point where they are programmers. - -At that point, people began to wonder how they could get something like this on a platform where they didn't have full service Lisp implementation. Multics MacLisp had a compiler as well as an interpreter — it was a full-fledged Lisp system — but people wanted to implement something like that on other systems where they had not already written a Lisp compiler. Well, if you didn't have the Lisp compiler you couldn't write the whole editor in Lisp — it would be too slow, especially redisplay, if it had to run interpreted Lisp. So we developed a hybrid technique. The idea was to write a Lisp interpreter and the lower level parts of the editor together, so that parts of the editor were built-in Lisp facilities. Those would be whatever parts we felt we had to optimize. This was a technique that we had already consciously practiced in the original Emacs, because there were certain fairly high level features which we re-implemented in machine language, making them into TECO primitives. For instance, there was a TECO primitive to fill a paragraph (actually, to do most of the work of filling a paragraph, because some of the less time-consuming parts of the job would be done at the higher level by a TECO program). You could do the whole job by writing a TECO program, but that was too slow, so we optimized it by putting part of it in machine language. We used the same idea here (in the hybrid technique), that most of the editor would be written in Lisp, but certain parts of it that had to run particularly fast would be written at a lower level. - -Therefore, when I wrote my second implementation of Emacs, I followed the same kind of design. The low level language was not machine language anymore, it was C. C was a good, efficient language for portable programs to run in a Unix-like operating system. There was a Lisp interpreter, but I implemented facilities for special purpose editing jobs directly in C — manipulating editor buffers, inserting leading text, reading and writing files, redisplaying the buffer on the screen, managing editor windows. - -Now, this was not the first Emacs that was written in C and ran on Unix. The first was written by James Gosling, and was referred to as GosMacs. A strange thing happened with him. In the beginning, he seemed to be influenced by the same spirit of sharing and cooperation of the original Emacs. I first released the original Emacs to people at MIT. Someone wanted to port it to run on Twenex — it originally only ran on the Incompatible Timesharing System we used at MIT. They ported it to Twenex, which meant that there were a few hundred installations around the world that could potentially use it. We started distributing it to them, with the rule that “you had to send back all of your improvements” so we could all benefit. No one ever tried to enforce that, but as far as I know people did cooperate. - -Gosling did, at first, seem to participate in this spirit. He wrote in a manual that he called the program Emacs hoping that others in the community would improve it until it was worthy of that name. That's the right approach to take towards a community — to ask them to join in and make the program better. But after that he seemed to change the spirit, and sold it to a company. - -At that time I was working on the GNU system (a free software Unix-like operating system that many people erroneously call “Linux”). There was no free software Emacs editor that ran on Unix. I did, however, have a friend who had participated in developing Gosling's Emacs. Gosling had given him, by email, permission to distribute his own version. He proposed to me that I use that version. Then I discovered that Gosling's Emacs did not have a real Lisp. It had a programming language that was known as ‘mocklisp’, which looks syntactically like Lisp, but didn't have the data structures of Lisp. So programs were not data, and vital elements of Lisp were missing. Its data structures were strings, numbers and a few other specialized things. - -I concluded I couldn't use it and had to replace it all, the first step of which was to write an actual Lisp interpreter. I gradually adapted every part of the editor based on real Lisp data structures, rather than ad hoc data structures, making the data structures of the internals of the editor exposable and manipulable by the user's Lisp programs. - -The one exception was redisplay. For a long time, redisplay was sort of an alternate world. The editor would enter the world of redisplay and things would go on with very special data structures that were not safe for garbage collection, not safe for interruption, and you couldn't run any Lisp programs during that. We've changed that since — it's now possible to run Lisp code during redisplay. It's quite a convenient thing. - -This second Emacs program was ‘free software’ in the modern sense of the term — it was part of an explicit political campaign to make software free. The essence of this campaign was that everybody should be free to do the things we did in the old days at MIT, working together on software and working with whomever wanted to work with us. That is the basis for the free software movement — the experience I had, the life that I've lived at the MIT AI lab — to be working on human knowledge, and not be standing in the way of anybody's further using and further disseminating human knowledge. - -At the time, you could make a computer that was about the same price range as other computers that weren't meant for Lisp, except that it would run Lisp much faster than they would, and with full type checking in every operation as well. Ordinary computers typically forced you to choose between execution speed and good typechecking. So yes, you could have a Lisp compiler and run your programs fast, but when they tried to take `car` of a number, it got nonsensical results and eventually crashed at some point. - -The Lisp machine was able to execute instructions about as fast as those other machines, but each instruction — a car instruction would do data typechecking — so when you tried to get the car of a number in a compiled program, it would give you an immediate error. We built the machine and had a Lisp operating system for it. It was written almost entirely in Lisp, the only exceptions being parts written in the microcode. People became interested in manufacturing them, which meant they should start a company. - -There were two different ideas about what this company should be like. Greenblatt wanted to start what he called a “hacker” company. This meant it would be a company run by hackers and would operate in a way conducive to hackers. Another goal was to maintain the AI Lab culture (3). Unfortunately, Greenblatt didn't have any business experience, so other people in the Lisp machine group said they doubted whether he could succeed. They thought that his plan to avoid outside investment wouldn't work. - -Why did he want to avoid outside investment? Because when a company has outside investors, they take control and they don't let you have any scruples. And eventually, if you have any scruples, they also replace you as the manager. - -So Greenblatt had the idea that he would find a customer who would pay in advance to buy the parts. They would build machines and deliver them; with profits from those parts, they would then be able to buy parts for a few more machines, sell those and then buy parts for a larger number of machines, and so on. The other people in the group thought that this couldn't possibly work. - -Greenblatt then recruited Russell Noftsker, the man who had hired me, who had subsequently left the AI Lab and created a successful company. Russell was believed to have an aptitude for business. He demonstrated this aptitude for business by saying to the other people in the group, “Let's ditch Greenblatt, forget his ideas, and we'll make another company.” Stabbing in the back, clearly a real businessman. Those people decided they would form a company called Symbolics. They would get outside investment, not have scruples, and do everything possible to win. - -But Greenblatt didn't give up. He and the few people loyal to him decided to start Lisp Machines Inc. anyway and go ahead with their plans. And what do you know, they succeeded! They got the first customer and were paid in advance. They built machines and sold them, and built more machines and more machines. They actually succeeded even though they didn't have the help of most of the people in the group. Symbolics also got off to a successful start, so you had two competing Lisp machine companies. When Symbolics saw that LMI was not going to fall flat on its face, they started looking for ways to destroy it. - -Thus, the abandonment of our lab was followed by “war” in our lab. The abandonment happened when Symbolics hired away all the hackers, except me and the few who worked at LMI part-time. Then they invoked a rule and eliminated people who worked part-time for MIT, so they had to leave entirely, which left only me. The AI lab was now helpless. And MIT had made a very foolish arrangement with these two companies. It was a three-way contract where both companies licensed the use of Lisp machine system sources. These companies were required to let MIT use their changes. But it didn't say in the contract that MIT was entitled to put them into the MIT Lisp machine systems that both companies had licensed. Nobody had envisioned that the AI lab's hacker group would be wiped out, but it was. - -So Symbolics came up with a plan (4). They said to the lab, “We will continue making our changes to the system available for you to use, but you can't put it into the MIT Lisp machine system. Instead, we'll give you access to Symbolics' Lisp machine system, and you can run it, but that's all you can do.” - -This, in effect, meant that they demanded that we had to choose a side, and use either the MIT version of the system or the Symbolics version. Whichever choice we made determined which system our improvements went to. If we worked on and improved the Symbolics version, we would be supporting Symbolics alone. If we used and improved the MIT version of the system, we would be doing work available to both companies, but Symbolics saw that we would be supporting LMI because we would be helping them continue to exist. So we were not allowed to be neutral anymore. - -Up until that point, I hadn't taken the side of either company, although it made me miserable to see what had happened to our community and the software. But now, Symbolics had forced the issue. So, in an effort to help keep Lisp Machines Inc. going (5) — I began duplicating all of the improvements Symbolics had made to the Lisp machine system. I wrote the equivalent improvements again myself (i.e., the code was my own). - -After a while (6), I came to the conclusion that it would be best if I didn't even look at their code. When they made a beta announcement that gave the release notes, I would see what the features were and then implement them. By the time they had a real release, I did too. - -In this way, for two years, I prevented them from wiping out Lisp Machines Incorporated, and the two companies went on. But, I didn't want to spend years and years punishing someone, just thwarting an evil deed. I figured they had been punished pretty thoroughly because they were stuck with competition that was not leaving or going to disappear (7). Meanwhile, it was time to start building a new community to replace the one that their actions and others had wiped out. - -The Lisp community in the 70s was not limited to the MIT AI Lab, and the hackers were not all at MIT. The war that Symbolics started was what wiped out MIT, but there were other events going on then. There were people giving up on cooperation, and together this wiped out the community and there wasn't much left. - -Once I stopped punishing Symbolics, I had to figure out what to do next. I had to make a free operating system, that was clear — the only way that people could work together and share was with a free operating system. - -At first, I thought of making a Lisp-based system, but I realized that wouldn't be a good idea technically. To have something like the Lisp machine system, you needed special purpose microcode. That's what made it possible to run programs as fast as other computers would run their programs and still get the benefit of typechecking. Without that, you would be reduced to something like the Lisp compilers for other machines. The programs would be faster, but unstable. Now that's okay if you're running one program on a timesharing system — if one program crashes, that's not a disaster, that's something your program occasionally does. But that didn't make it good for writing the operating system in, so I rejected the idea of making a system like the Lisp machine. - -I decided instead to make a Unix-like operating system that would have Lisp implementations to run as user programs. The kernel wouldn't be written in Lisp, but we'd have Lisp. So the development of that operating system, the GNU operating system, is what led me to write the GNU Emacs. In doing this, I aimed to make the absolute minimal possible Lisp implementation. The size of the programs was a tremendous concern. - -There were people in those days, in 1985, who had one-megabyte machines without virtual memory. They wanted to be able to use GNU Emacs. This meant I had to keep the program as small as possible. - -For instance, at the time the only looping construct was ‘while’, which was extremely simple. There was no way to break out of the ‘while’ statement, you just had to do a catch and a throw, or test a variable that ran the loop. That shows how far I was pushing to keep things small. We didn't have ‘caar’ and ‘cadr’ and so on; “squeeze out everything possible” was the spirit of GNU Emacs, the spirit of Emacs Lisp, from the beginning. - -Obviously, machines are bigger now, and we don't do it that way any more. We put in ‘caar’ and ‘cadr’ and so on, and we might put in another looping construct one of these days. We're willing to extend it some now, but we don't want to extend it to the level of common Lisp. I implemented Common Lisp once on the Lisp machine, and I'm not all that happy with it. One thing I don't like terribly much is keyword arguments (8). They don't seem quite Lispy to me; I'll do it sometimes but I minimize the times when I do that. - -That was not the end of the GNU projects involved with Lisp. Later on around 1995, we were looking into starting a graphical desktop project. It was clear that for the programs on the desktop, we wanted a programming language to write a lot of it in to make it easily extensible, like the editor. The question was what it should be. - -At the time, TCL was being pushed heavily for this purpose. I had a very low opinion of TCL, basically because it wasn't Lisp. It looks a tiny bit like Lisp, but semantically it isn't, and it's not as clean. Then someone showed me an ad where Sun was trying to hire somebody to work on TCL to make it the “de-facto standard extension language” of the world. And I thought, “We've got to stop that from happening.” So we started to make Scheme the standard extensibility language for GNU. Not Common Lisp, because it was too large. The idea was that we would have a Scheme interpreter designed to be linked into applications in the same way TCL was linked into applications. We would then recommend that as the preferred extensibility package for all GNU programs. - -There's an interesting benefit you can get from using such a powerful language as a version of Lisp as your primary extensibility language. You can implement other languages by translating them into your primary language. If your primary language is TCL, you can't very easily implement Lisp by translating it into TCL. But if your primary language is Lisp, it's not that hard to implement other things by translating them. Our idea was that if each extensible application supported Scheme, you could write an implementation of TCL or Python or Perl in Scheme that translates that program into Scheme. Then you could load that into any application and customize it in your favorite language and it would work with other customizations as well. - -As long as the extensibility languages are weak, the users have to use only the language you provided them. Which means that people who love any given language have to compete for the choice of the developers of applications — saying “Please, application developer, put my language into your application, not his language.” Then the users get no choices at all — whichever application they're using comes with one language and they're stuck with [that language]. But when you have a powerful language that can implement others by translating into it, then you give the user a choice of language and we don't have to have a language war anymore. That's what we're hoping ‘Guile’, our scheme interpreter, will do. We had a person working last summer finishing up a translator from Python to Scheme. I don't know if it's entirely finished yet, but for anyone interested in this project, please get in touch. So that's the plan we have for the future. - -I haven't been speaking about free software, but let me briefly tell you a little bit about what that means. Free software does not refer to price; it doesn't mean that you get it for free. (You may have paid for a copy, or gotten a copy gratis.) It means that you have freedom as a user. The crucial thing is that you are free to run the program, free to study what it does, free to change it to suit your needs, free to redistribute the copies of others and free to publish improved, extended versions. This is what free software means. If you are using a non-free program, you have lost crucial freedom, so don't ever do that. - -The purpose of the GNU project is to make it easier for people to reject freedom-trampling, user-dominating, non-free software by providing free software to replace it. For those who don't have the moral courage to reject the non-free software, when that means some practical inconvenience, what we try to do is give a free alternative so that you can move to freedom with less of a mess and less of a sacrifice in practical terms. The less sacrifice the better. We want to make it easier for you to live in freedom, to cooperate. - -This is a matter of the freedom to cooperate. We're used to thinking of freedom and cooperation with society as if they are opposites. But here they're on the same side. With free software you are free to cooperate with other people as well as free to help yourself. With non-free software, somebody is dominating you and keeping people divided. You're not allowed to share with them, you're not free to cooperate or help society, anymore than you're free to help yourself. Divided and helpless is the state of users using non-free software. - -We've produced a tremendous range of free software. We've done what people said we could never do; we have two operating systems of free software. We have many applications and we obviously have a lot farther to go. So we need your help. I would like to ask you to volunteer for the GNU project; help us develop free software for more jobs. Take a look at [http://www.gnu.org/help][1] to find suggestions for how to help. If you want to order things, there's a link to that from the home page. If you want to read about philosophical issues, look in /philosophy. If you're looking for free software to use, look in /directory, which lists about 1900 packages now (which is a fraction of all the free software out there). Please write more and contribute to us. My book of essays, “Free Software and Free Society”, is on sale and can be purchased at [www.gnu.org][2]. Happy hacking! - --------------------------------------------------------------------------------- - -via: https://www.gnu.org/gnu/rms-lisp.html - -作者:[Richard Stallman][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.gnu.org -[1]:https://www.gnu.org/help/ -[2]:http://www.gnu.org/ diff --git a/sources/talk/20170908 Betting on the Web.md b/sources/talk/20170908 Betting on the Web.md deleted file mode 100644 index 84d70e164f..0000000000 --- a/sources/talk/20170908 Betting on the Web.md +++ /dev/null @@ -1,467 +0,0 @@ -[Betting on the Web][27] -============================================================ - -![](https://static.joreteg.com/large_background.jpg) - - _Note: I just spoke at [Coldfront 2017][12] about why I’m such a big proponent of the Web. What follows is essentially that talk as a blog post (I’ll add a link to the video once it is published)._ - - _Also: the Starbucks PWA mentioned in the talk has shipped! 🎉_ - -I’m  _not_  going to tell you what to do. Instead, I’m going to explain why I’ve chosen to bet my whole career on this crazy Web thing. "Betting" sounds a bit haphazard, it’s more calculated than that. It would probably be better described as "investing." - -Investing what? Our time and attention. - -Many of us only have maybe 6 or so  _really_  productive hours per day when we’re capable of being super focused and doing our absolute best work. So how we chose to invest that very limited time is kind of a big deal. Even though I really enjoy programming I rarely do it aimlessly just for the pure joy of it. Ultimately, I’m investing that productive time expecting to get  _some kind of return_  even if it’s just mastering something or solving a difficult problem. - - [### "So what, what’s your point?"][28] - -> > More than most of us realize we are  _constantly_  investing - -Sure, someone may be paying for our time directly but there’s more to it than just trading hours for money. In the long run, what we chose to invest our professional efforts into has other effects: - -**1\. Building Expertise:** We learn as we work and gain valuable experience in the technologies and platform we’re investing in. That expertise impacts our future earning potential and what types of products we’re capable of building. - -**2\. Building Equity:** Hopefully we’re generating equity and adding value to whatever product we’re building. - -**3\. Shaping tomorrow’s job market:** We’re building tomorrow’s legacy code today™. Today’s new hotness is tomorrow’s maintenance burden. In many cases the people that initially build a product or service are not the ones that ultimately maintain it. This means the technology choices we make when building a new product or service, determine whether or not there will be jobs later that require expertise in that particular platform/technology. So, those tech choices  _literally shape tomorrow’s job market!_ - -**4\. Body of knowledge:** As developers, we’re pretty good at sharing what we learn. We blog, we "Stack-Overflow", etc. These things all contribute to the corpus of knowledge available about that given platform which adds significant value by making it easier/faster for others to build things using these tools. - -**5\. Open Source:** We solve problems and share our work. When lots of developers do this it adds  _tremendous value_  to the technologies and platforms these tools are for. The sheer volume of work that we  _don’t have to do_  because we can use someone else’s library that already does it is mind-boggling. Millions and millions of hours of development work are available to us for free with a simple `npm install`. - -**6\. Building apps for users on that platform:** Last but not least, without apps there is no platform. By making more software available to end users, we’re contributing significant value to the platforms that run our apps. - -Looking at that list, the last four items are not about  _us_  at all. They represent other significant long-term impacts. - -> > We often have a broader impact than we realize - -We’re not just investing time into a job, we're also shaping the platform, community, and technologies we use. - -We’re going to come back to this, but hopefully, recognizing that greater impact can help us make better investments. - - [### With all investing comes  _risk_][29] - -We can’t talk about investing without talking about risk. So what are some of the potential risks? - - [### Are we building for the right platform?][30] - -Platform stability is indeed A Thing™. Just ask a Flash developer, Windows Phone developer, or Blackberry developer. Platforms  _can_  go away. - -If we look at those three platforms, what do they have in common? They’re  _closed_  platforms. What I mean is there’s a single controlling interest. When you build for them, you’re building for a specific operating system and coding against a particular implementation as opposed to coding against a set of  _open standards_ . You could argue, that at least to some degree, Flash died because of its "closed-ness". Regardless, one thing is clear from a risk mitigation perspective: open is better than closed. - -the Web is  _incredibly_  open. It would be quite difficult for any one entity to kill it off. - -Now, for Windows Phone/Blackberry it failed due to a lack of interested users... or was it lack of interested developers?? - -![](https://d33wubrfki0l68.cloudfront.net/9c118bc64747a753804bf88f16237bfe1c71905e/8d334/images/2/ballmer.jpg) - -Maybe if Ballmer ☝️ has just yelled "developers"  _one more time_  we’d all have Windows Phones in our pockets right now 😜. - -From a risk mitigation perspective, two things are clear with regard to platform stability: - -1. Having  _many users_  is better than having few users - -2. Having  _more developers_  building for the platform is better than having few developers - -> > There is no bigger more popular open platform than the Web - - [### Are we building the right software?][31] - -Many of us are building apps. Well, we used to build "applications" but that wasn’t nearly cool enough. So now we build "apps" instead 😎. - -What does "app" mean to a user? This is important because I think it’s changed a bit over the years. To a user, I would suggest it basically means: "a thing I put on my phone." - -But for our purposes I want to get a bit more specific. I’d propose that an app is really: - -1. An "ad hoc" user interface - -2. That is local(ish) to the device - -The term "ad hoc" is Latin and translates to **"for this"**. This actually matches pretty closely with what Apple’s marketing campaigns have been teaching the masses: - -> There’s an app **for that** -> -> – Apple - -The point is it helps you  _do_  something. The emphasis is on action. I happen to think this is largely the difference between a "site" and an "app". A news site for example has articles that are resources in and of themselves. Where a news app is software that runs on the device that helps you consume news articles. - -Another way to put it would be that site is more like a book, while an app is a tool. - - [### Should we be building apps at all?!][32] - -Remember when chatbots were supposed to take over the world? Or perhaps we’ll all be walking around with augmented reality glasses and that’s how we’ll interact with the world? - -I’ve heard it said that "the future app is  _no_  app" and virtual assistants will take over everything. - -![](https://d33wubrfki0l68.cloudfront.net/447b9cdc5e549f874d40fcccbdc6a4225d898677/b3dce/images/2/echo.png) - -I’ve had one of these sitting in my living room for a couple of years, but I find it all but useless. It’s just a nice bluetooth speaker that I can yell at to play me music. - -But I find it very interesting that: - -> > Even Alexa has an app! - -Why? Because there’s no screen! As it turns out these "ad hoc visual interfaces" are extremely efficient. - -Sure, I can yell out "Alexa, what’s the weather going to be like today" and I’ll hear a reply with high and low and whether it’s cloudy, rainy, or sunny. But in that same amount of time, I can pull my phone out tap the weather app and before Alexa can finish telling me those 3 pieces of data, I can visually scan the entire week’s worth of data, air quality, sunrise/sunset times, etc. It’s just  _so much more_  efficient as a mechanism for consuming this type of data. - -As a result of that natural efficiency, I believe that having a visual interface is going to continue to be useful for all sorts of things for a long time to come. - -That’s  _not_  to say virtual assistants aren’t useful! Google Assistant on my Pixel is quite useful in part because it can show me answers and can tolerate vagueness in a way that an app with a fixed set of buttons never could. - -But, as is so often the case with new useful tech, rarely does it complete replace everything that came before it, instead, it augments what we already have. - - [### If apps are so great why are we so "apped out"?][33] - -How do we explain that supposed efficiency when there’s data like this? - -* [65% of smartphone users download zero apps per month][13] - -* [More than 75% of app downloads open an app once and never come back][14] - -I think to answer that we have to really look at what isn’t working well. - - [### What sucks about apps?][34] - -1. **Downloading them certainly sucks.** No one wants to open an app store, search for the app they’re trying to find, then wait to download the huge file. These days a 50mb app is pretty small. Facebook for iOS 346MB, Twitter iOS 212MB. - -2. **Updating them sucks.** Every night I plug in my phone I download a whole slew of app updates that I, as a user, **could not possibly care less about**. In addition, many of these apps are things I installed  _once_ and will **never open again, ever!**. I’d love to know the global stats on how much bandwidth has been wasted on app updates for apps that were never opened again. - -3. **Managing them sucks.** Sure, when I first got an iPhone ages ago and could first download apps my home screen was impeccable. Then when we got folders!! Wow... what an amazing development! Now I could finally put all those pesky uninstallable Apple apps in a folder called "💩" and pretend they didn’t exist. But now, my home screen is a bit of a disaster. Sitting there dragging apps around is not my idea of a good time. So eventually things get all cluttered up again. - -The thing I’ve come to realize, is this: - -> > We don’t care how they got there. We only care that they’re  _there_  when we need them. - -For example, I love to go mountain biking and I enjoy tracking my rides with an app called Strava. I get all geared up for my ride, get on my bike and then go, "Oh right, gotta start Strava." So I pull out my phone  _with my gloves on_  and go: "Ok Google, open Strava". - -I  _could not care less_  about where that app was or where it came from when I said that. - -I don’t care if it was already installed, I don’t care if it never existed on my home screen, or if it was generated out of thin air on the spot. - -> > Context is  _everything_ ! - -If I’m at a parking meter, I want the app  _for that_ . If I’m visiting Portland, I want their public transit app. - -But I certainly  _do not_  want it as soon as I’ve left. - -If I’m at a conference, I might want a conference app to see the schedule, post questions to speakers, or whatnot. But wow, talk about something that quickly becomes worthless as soon as that conference is over! - -As it turns out the more "ad hoc" these things are, the better! The more  _disposable_  and  _re-inflatable_  the better! - -Which also reminds me of something that I feel like we often forget. We always assume people want our shiny apps and we measure things like "engagement" and "time spent in the app" when really, and there certainly are exceptions to this such as apps that are essentially entertainment, but often... - -> > People don’t want to use your app. They want  _to be done_  using your app. - - [### Enter PWAs][35] - -I’ve been contracting with Starbucks for the past 18 months. They’ve taken on the ambitious project of essentially re-building a lot of their web stuff in Node.js and React. One of the things I’ve helped them with (and pushed hard for) was to build a PWA (Progressive Web App) that could provide similar functionality as their native apps. Coincidentally it was launched today: [https://preview.starbucks.com][18]! - - - -This gives is a nice real world example: - -* Starbucks iOS: 146MB - -* Starbucks PWA: ~600KB - -The point is there’s a  _tremendous_  size difference. - -It’s 0.4% of the size. To put it differently, I could download the PWA **243 times**in the same amount of time it would take to download the iOS app. Then, of course on iOS it then also still has to install and boot up! - -Personally, I’d have loved it if the app ended up even smaller and there are plans to shrink it further. But even still, they’re  _not even on the same planet_  in terms of file-size! - -Market forces are  _strongly_  aligned with PWAs here: - -* Few app downloads - -* User acquisition is  _hard_ - -* User acquisition is  _expensive_ - -If the goal is to get people to sign up for the rewards program, that type of size difference could very well make the difference of getting someone signed up and using the app experience (via PWA) by the time they reach the front of the line at Starbucks or not. - -User acquisition is hard enough already, the more time and barriers that can be removed from that process, the better. - - [### Quick PWA primer][36] - -As mentioned, PWA stands for "Progressive Web Apps" or, as I like to call them: "Web Apps" 😄 - -Personally I’ve been trying to build what a user would define as an "app" with web technology for  _years_ . But until PWAs came along, as hard as we tried, you couldn’t quite build a  _real app_  with just web tech. Honestly, I kinda hate myself for saying that, but in terms of something that a user would understand as an "app" I’m afraid that statement has probably true until very recently. - -So what’s a PWA? As one of its primary contributors put it: - -> It’s just a website that took all the right vitamins. -> -> – Alex Russell - -It involves a few specific technologies, namely: - -* Service Worker. Which enable true reliability on the web. What I mean by that is I can build an app that as long as you loaded it while you were online, from then on it will  _always_  open, even if you’re not. This puts it on equal footing with other apps. - -* HTTPS. Requires encrypted connections - -* Web App Manifest. A simple JSON file that describes your application. What icons to use is someone adds it to their home screen, what its name is, etc. - -There are plenty of other resources about PWAs on the web. The point for my purposes is: - -> > It is now possible to build PWAs that are  _indistinguishable_  from their native counter parts - -They can be up and running in a fraction of the time whether or not they were already "installed" and unlike "apps" can be saved as an app on the device  _at the user’s discretion!_ - -Essentially they’re really great for creating "ad hoc" experiences that can be "cold started" on a whim nearly as fast as if it were already installed. - -I’ve said it before and I’ll say it again: - -> PWAs are the biggest thing to happen to the mobile web since the iPhone. -> -> – Um... that was me - - [### Let’s talk Internet of things][37] - -I happen to think that PWAs + IoT = ✨ MAGIC ✨. As several smart folks have pointed out. - -The one-app-per-device approach to smart devices probably isn’t particularly smart. - -It doesn’t scale well and it completely fails in terms of "ad hoc"-ness. Sure, if I have a Nest thermostat and Phillips Hue lightbulbs, it’s reasonable to have two apps installed. But even that sucks as soon as I want someone else to be able to use control them. If  _I just let you into my house_ , trust me... I’m perfectly happy to let you flip a light switch, you’re in my house, after all. But for the vast majority of these things there’s no concept of "nearby apps" and, it’s silly for my guest (or a house-sitter) to download an app they don’t actually want, just so I can let them control my lights. - -The whole "nearby apps" thing has so many uses: - -* thermostat - -* lights - -* locks - -* garage doors - -* parking meter - -* setting refrigerator temp - -* conference apps - -Today there are lots of new capabilities being added to the web to enable web apps to interact with physical devices in the real world. Things like WebUSB, WebBluetooth, WebNFC, and efforts like [Physical Web][19]. Even for things like Augmented (and Virtual) reality, the idea of the items we want to interact with having URLs makes so much sense and I can’t imagine a better, more flexible use of those URLs than for them to point to a PWA that lets you interact with that device! - - [### Forward looking statements...][38] - -I’ve been talking about all this in terms of investing. If you’ve ever read any company statement that discusses the future you always see this line explaining that things that are about to be discussed contains "forward looking statements" that may or may not ultimately happen. - -So, here are  _my_  forward looking statements. - - [### 1\. PWA-only startups][39] - -Given the cost (and challenge) of user-acquisition and the quality of app you can build with PWAs these days, I feel like this is inevitable. If you’re trying to get something off the ground, it just isn’t very efficient to spin up  _three whole teams_  to build for iOS, Android, and the Web. - - [### 2\. PWAs listed in App Stores][40] - -So, there’s a problem with "web only" which is that for the good part of a decade we’ve been training users to look for apps in the app store for their given platform. So if you’re already a recognized brand, especially if you already have a native app that you’re trying to replace, it simply isn’t smart for you  _not to exist_  in the app stores. - -So, some of this isn’t all that "forward looking" as it turns out [Microsoft has already committed to listing PWAs in the Windows Store][20], more than once! - -**They haven’t even finished implementing Service Worker in Edge yet!** But they’re already committing hard to PWAs. In addition to post linked above, one of their lead Developer Relations folks, Aaron Gustafson just [wrote an article for A List Apart][21] telling everyone to build PWAs. - -But if you think about it from their perspective, of course they should do that! As I said earlier they’ve struggled to attract developer to build for their mobile phones. In fact, they’ve at times  _paid_  companies to write apps for them simply to make sure apps exist so that users will be able to have apps they want when using a Windows Phone. Remember how I said developer time is a scarce resource and without apps, the platform is worthless? So  _of course_  they should add first class support for PWAs. If you build a PWA like a lot of folks are doing then TADA!!! 🎉 You just made a Windows/Windows Phone app! - -I’m of the opinion that the writing is on the wall for Google to do the same thing. It’s pure speculation, but it certainly seems like they are taking steps that suggest they may be planning on listing PWAs too. Namely that the Chrome folks recently shipped a feature referred to as "WebAPKs" for Chrome stable on Android (yep, everyone). In the past I’ve [explained in more detail][22] why I think this is a big deal. But a shorted version would be that before this change, sure you could save a PWA to your home screen...  _But_ , in reality it was actually a glorified bookmark. That’s what changes with WebAPKs. Instead, when you add a PWA to your home screen it generates and "side loads" an actual `.apk`file on the fly. This allows that PWA to enjoy some privileges that were simply impossible until the operating system recognized it as "an app." For example: - -* You can now mute push notifications for a specific PWA without muting it for all of Chrome. - -* The PWA is listed in the "app tray" that shows all installed apps (previously it was just the home screen). - -* You can see power usage, and permissions granted to the PWA just like any other app. - -* The app developer can now update the icon for the app by publishing an update to the app manifest. Before, there was no way to updated the icon once it had been added. - -* And a slew of other similar benefits... - -If you’ve ever installed an Android app from a source other than the Play Store (or carriers/OEMs store) you know that you have to flip a switch in settings to allow installs from "untrusted sources". So, how then, you might ask, can they generate and install an actual `.apk` file for a PWA without requiring that you change that setting? As it turns out the answer is quite simple: Use a trusted source! - -> > As it turns out WebAPKs are managed through Google Play Services! - -I’m no rocket scientist, but based on their natural business alignment with the web, their promotion of PWAs, the lengths they’ve gone to to grant PWAs equal status on the operating system as native apps, it only seems natural that they’d eventually  _list them in the store_ . - -Additionally, if Google did start listing PWAs in the Play Store both them and Microsoft would be doing it  _leaving Apple sticking out like a sore thumb and looking like the laggard_ . Essentially, app developers would be able to target a  _massive_  number of users on a range of platforms with a single well-built PWA. But, just like developers grew to despise IE for not keeping up with the times and forcing them to jump through extra hoops to support it, the same thing would happen here. Apple does  _not_  want to be the next IE and I’ve already seen many prominent developers suggesting they already are. - -Which bring us to another forward-looking statement: - - [### 3\. PWAs on iOS][41] - -Just a few weeks ago the Safari folks announced that Service Worker is now [officially under development][23]. - - [### 4\. PWAs everywhere][42] - -I really think we’ll start seeing them everywhere: - -* Inside VR/AR/MR experiences - -* Inside chat bots (again, pulling up an ad-hoc interface is so much more efficient). - -* Inside Xbox?! - -As it turns out, if you look at Microsoft’s status page for Edge about Service Worker you see this: - -![](https://d33wubrfki0l68.cloudfront.net/6e28110b29d042e6472c3512748ecb9f541dcb67/a2b7d/images/2/edge.png) - -I hinted at this already, but I also think PWAs pair very nicely with virtual assistants being able to pull up an PWA on a whim without requiring it to already be installed would add tremendous power to the virtual assistant. Incidentally, this also becomes easier if there’s a known "registered" name of a PWA listed in an app store. - -Some other fun use cases: - -* Apparently the new digital menu displays in McDonald’s Restaurants (at least in the U.S.) are actually a web app built with Polymer ([source][15]). I don’t know if there’s a Service Worker or not, but it would make sense for there to be. - -* Sports score boards!? I’m a [independent consultant][16], and someone approached me about potentially using a set of TVs and web apps to build a score keeping system at an arena. Point is, there are so many cool examples! - -The web really is the universal platform! - - [### For those who think PWAs are just a Google thing][43] - -First off, I’m pretty sure Microsoft, Opera, Firefox, and Samsung folks would want to punch you for that. It [simply isn’t true][24] and increasingly we’re seeing a lot more compatibility efforts between browser vendors. - -For example: check out the [Web Platform Tests][25] which is essentially Continuous Integration for web features that are run against new releases of major browsers. Some folks will recall that when Apple first claimed they implemented IndexedDb in Safari, the version they shipped was essentially unusable because it had major shortcomings and bugs. - -Now, with the WPTs, you can drill into these features (to quite some detail) and see whether a given browser passes or fails. No more claiming "we shipped!" but not actually shipping. - - [### What about feature "x" on platform "y" that we need?][44] - -It could well be that you have a need that isn’t yet covered by the web platform. In reality, that list is getting shorter and shorter, also... HAVE YOU ASKED?! Despite what it may feel like, browser vendors eagerly want to know what you’re trying to do that you can’t. If there are missing features, be loud, be nice, but from my experience it’s worth making your desires known. - -Also, it doesn’t take much to wrap a web view and add hooks into the native OS that your JavaScript can call to do things that aren’t  _quite_  possible yet. - -But that also brings me to another point, in terms of investing, as the world’s greatest hockey player said: - -> Skate to where the puck is going, not where it has been. -> -> – Wayne Gretzky - -Based on what I’ve outlined thus far, it could be more risky to building an entire application for a whole other platform that you ultimately may not need than to at least exhaust your options seeing what you can do with the Web first. - -So to line ’em up in terms of PWA support: - -* Chrome: yup - -* Firefox: yup - -* Opera: yup - -* Samsung Internet ([the 3rd largest browser surprise!][17]): yup - -* Microsoft: huge public commitment - -* Safari: at least implementing Service Worker - - [### Ask them add your feature!][45] - -Sure, it may not happen, it may take a long time but  _at least_  try. Remember, developers have a lot more influence over platforms than we typically realize. Make. your. voice. heard. - - [### Side note about React-Native/Expo][46] - -These projects are run by awesome people, the tech is incredibly impressive. If you’re Facebook and you’re trying to consolidate your development efforts, for the same basic reasons as why it makes sense for them to create their on [VM for running PHP][26]. They have realities to deal with at a scale that most of us will never have to deal with. Personally, I’m not Facebook. - -As a side note, I find it interesting that building native apps and having as many people do that as possible, plays nicely into their advertising competition with Google. - -It just so happens that Google is well positioned to capitalize off of people using the Web. Inversely, I’m fairly certain Facebook wouldn’t mind that ad revenue  _not_  going Google. Facebook, seemingly would much rather  _be_  your web, that be part of the Web. - -Anyway, all that aside, for me it’s also about investing well. - -By building a native app you’re volunteering for a 30% app-store tax. Plus, like we covered earlier odds are that no one wants to go download your app. Also, though it seems incredibly unlikely, I feel compelled to point out that in terms of "openness" Apple’s App Store is very clearly  _anything_  but that. Apple could decide one day that they really don’t like how it’s possible to essentially circumvent their normal update/review process when you use Expo. One day they could just decide to reject all React Native apps. I really don’t think they would because of the uproar it would cause. I’m simply pointing out that it’s  _their_  platform and they would have  _every_  right to do so. - - [### So is it all about investing for your own gain?][47] - -So far, I’ve presented all this from kind of a cold, heartless investor perspective: getting the most for your time. - -But, that’s not the whole story is it? - -Life isn’t all about me. Life isn’t all about us. - -I want to invest in platforms that increase opportunities **for others**. Personally, I really hope the next friggin’ Mark Zuckerburg isn’t an ivy-league dude. Wouldn’t it be amazing if instead the next huge success was, I don’t know, perhaps a young woman in Nairobi or something? The thing is, if owning an iPhone is a prerequisite for building apps, it  _dramatically_  decreases the odds of something like that happening. I feel like the Web really is the closest thing we have to a level playing field. - -**I want to invest in and improve  _that_  platform!** - -This quote really struck me and has stayed with me when thinking about these things: - -> If you’re the kind of person who tends to succeed in what you start, -> -> changing what you start could be  _the most extraordinary thing_  you could do. -> -> – Anand Giridharadas - -Thanks for your valuable attention ❤️. I’ve presented the facts as I see them and I’ve done my best not to "should on you." - -Ultimately though, no matter how prepared we are or how much research we’ve done; investing is always a bit of a gamble. - -So I guess the only thing left to say is: - -> > I’m all in. - --------------------------------------------------------------------------------- - -via: https://joreteg.com/blog/betting-on-the-web - -作者:[Joreteg][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://joreteg.com/ -[1]:https://twitter.com/davidbrunelle -[2]:https://twitter.com/intent/tweet?in_reply_to=905931990444244995 -[3]:https://twitter.com/intent/retweet?tweet_id=905931990444244995 -[4]:https://twitter.com/intent/like?tweet_id=905931990444244995 -[5]:https://twitter.com/davidbrunelle/status/905931990444244995/photo/1 -[6]:https://twitter.com/davidbrunelle -[7]:https://twitter.com/Starbucks -[8]:https://t.co/tEUXM8BLgP -[9]:https://twitter.com/davidbrunelle/status/905931990444244995 -[10]:https://twitter.com/davidbrunelle/status/905931990444244995/photo/1 -[11]:https://support.twitter.com/articles/20175256 -[12]:https://2017.coldfront.co/ -[13]:https://qz.com/253618/most-smartphone-users-download-zero-apps-per-month/ -[14]:http://fortune.com/2016/05/19/app-economy/ -[15]:https://twitter.com/AJStacy06/status/857628546507968512 -[16]:http://consulting.joreteg.com/ -[17]:https://medium.com/samsung-internet-dev/think-you-know-the-top-web-browsers-458a0a070175 -[18]:https://preview.starbucks.com/ -[19]:https://google.github.io/physical-web/ -[20]:https://blogs.windows.com/msedgedev/2016/07/08/the-progress-of-web-apps/ -[21]:https://alistapart.com/article/yes-that-web-project-should-be-a-pwa -[22]:https://joreteg.com/blog/installing-web-apps-for-real -[23]:https://webkit.org/status/#specification-service-workers -[24]:https://jakearchibald.github.io/isserviceworkerready/ -[25]:http://wpt.fyi/ -[26]:http://hhvm.com/ -[27]:https://joreteg.com/blog/betting-on-the-web -[28]:https://joreteg.com/blog/betting-on-the-web#quotso-what-whats-your-pointquot -[29]:https://joreteg.com/blog/betting-on-the-web#with-all-investing-comes -[30]:https://joreteg.com/blog/betting-on-the-web#are-we-building-for-the-right-platform -[31]:https://joreteg.com/blog/betting-on-the-web#are-we-building-the-right-software -[32]:https://joreteg.com/blog/betting-on-the-web#should-we-be-building-apps-at-all -[33]:https://joreteg.com/blog/betting-on-the-web#if-apps-are-so-great-why-are-we-so-quotapped-outquot -[34]:https://joreteg.com/blog/betting-on-the-web#what-sucks-about-apps -[35]:https://joreteg.com/blog/betting-on-the-web#enter-pwas -[36]:https://joreteg.com/blog/betting-on-the-web#quick-pwa-primer -[37]:https://joreteg.com/blog/betting-on-the-web#lets-talk-internet-of-things -[38]:https://joreteg.com/blog/betting-on-the-web#forward-looking-statements -[39]:https://joreteg.com/blog/betting-on-the-web#1-pwa-only-startups -[40]:https://joreteg.com/blog/betting-on-the-web#2-pwas-listed-in-app-stores -[41]:https://joreteg.com/blog/betting-on-the-web#3-pwas-on-ios -[42]:https://joreteg.com/blog/betting-on-the-web#4-pwas-everywhere -[43]:https://joreteg.com/blog/betting-on-the-web#for-those-who-think-pwas-are-just-a-google-thing -[44]:https://joreteg.com/blog/betting-on-the-web#what-about-feature-quotxquot-on-platform-quotyquot-that-we-need -[45]:https://joreteg.com/blog/betting-on-the-web#ask-them-add-your-feature -[46]:https://joreteg.com/blog/betting-on-the-web#side-note-about-react-nativeexpo -[47]:https://joreteg.com/blog/betting-on-the-web#so-is-it-all-about-investing-for-your-own-gain diff --git a/sources/talk/20171129 Inside AGL Familiar Open Source Components Ease Learning Curve.md b/sources/talk/20171129 Inside AGL Familiar Open Source Components Ease Learning Curve.md deleted file mode 100644 index 9eee39888a..0000000000 --- a/sources/talk/20171129 Inside AGL Familiar Open Source Components Ease Learning Curve.md +++ /dev/null @@ -1,70 +0,0 @@ -Inside AGL: Familiar Open Source Components Ease Learning Curve -============================================================ - -![Matt Porter](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/porter-elce-agl.png?itok=E-5xG98S "Matt Porter") -Konsulko’s Matt Porter (pictured) and Scott Murray ran through the major components of the AGL’s Unified Code Base at Embedded Linux Conference Europe.[The Linux Foundation][1] - -Among the sessions at the recent [Embedded Linux Conference Europe (ELCE)][5] — 57 of which are [available on YouTube][2] -- are several reports on the Linux Foundation’s [Automotive Grade Linux project][6]. These include [an overview from AGL Community Manager Walt Miner ][3]showing how AGL’s Unified Code Base (UCB) Linux distribution is expanding from in-vehicle infotainment (IVI) to ADAS. There was even a presentation on using AGL to build a remote-controlled robot (see links below). - -Here we look at the “State of AGL: Plumbing and Services,” from Konsulko Group’s CTO Matt Porter and senior staff software engineer Scott Murray. Porter and Murray ran through the components of the current [UCB 4.0 “Daring Dab”][7] and detailed major upstream components and API bindings, many of which will be appear in the Electric Eel release due in Jan. 2018. - -Despite the automotive focus of the AGL stack, most of the components are already familiar to Linux developers. “It looks a lot like a desktop distro,” Porter told the ELCE attendees in Prague. “All these familiar friends.” - -Some of those friends include the underlying Yocto Project “Poky” with OpenEmbedded foundation, which is topped with layers like oe-core, meta-openembedded, and metanetworking. Other components are based on familiar open source software like systemd (application control), Wayland and Weston (graphics), BlueZ (Bluetooth), oFono (telephony), PulseAudio and ALSA (audio), gpsd (location), ConnMan (Internet), and wpa-supplicant (WiFi), among others. - -UCB’s application framework is controlled through a WebSocket interface to the API bindings, thereby enabling apps to talk to each other. There’s also a new W3C widget for an alternative application packaging scheme, as well as support for SmartDeviceLink, a technology developed at Ford that automatically syncs up IVI systems with mobile phones.  - -AGL UCB’s Wayland/Weston graphics layer is augmented with an “IVI shell” that works with the layer manager. “One of the unique requirements of automotive is the ability to separate aspects of the application in the layers,” said Porter. “For example, in a navigation app, the graphics rendering for the map may be completely different than the engine used for the UI decorations. One engine layers to a surface in Wayland to expose the map while the decorations and controls are handled by another layer.” - -For audio, ALSA and PulseAudio are joined by GENIVI AudioManager, which works together with PulseAudio. “We use AudioManager for policy driven audio routing,” explained Porter. “It allows you to write a very complex XML-based policy using a rules engine with audio routing.” - -UCB leans primarily on the well-known [Smack Project][8] for security, and also incorporates Tizen’s [Cynara][9] safe policy-checker service. A Cynara-enabled D-Bus daemon is used to control Cynara security policies. - -Porter and Murray went on to explain AGL’s API binding mechanism, which according to Murray “abstracts the UI from its back-end logic so you can replace it with your own custom UI.” You can re-use application logic with different UI implementations, such as moving from the default Qt to HTML5 or a native toolkit. Application binding requests and responses use JSON via HTTP or WebSocket. Binding calls can be made from applications or from other bindings, thereby enabling “stacking” of bindings. - -Porter and Murray concluded with a detailed description of each binding. These include upstream bindings currently in various stages of development. The first is a Master binding that manages the application lifecycle, including tasks such as install, uninstall, start, and terminate. Other upstream bindings include the WiFi binding and the BlueZ-based Bluetooth binding, which in the future will be upgraded with Bluetooth [PBAP][10] (Phone Book Access Profile). PBAP can connect with contacts databases on your phone, and links to the Telephony binding to replicate caller ID. - -The oFono-based Telephony binding also makes calls to the Bluetooth binding for Bluetooth Hands-Free-Profile (HFP) support. In the future, Telephony binding will add support for sent dial tones, call waiting, call forwarding, and voice modem support. - -Support for AM/FM radio is not well developed in the Linux world, so for its Radio binding, AGL started by supporting [RTL-SDR][11] code for low-end radio dongles. Future plans call for supporting specific automotive tuner devices. - -The MediaPlayer binding is in very early development, and is currently limited to GStreamer based audio playback and control. Future plans call for adding playlist controls, as well as one of the most actively sought features among manufacturers: video playback support. - -Location bindings include the [gpsd][12] based GPS binding, as well as GeoClue and GeoFence. GeoClue, which is built around the [GeoClue][13] D-Bus geolocation service, “overlaps a little with GPS, which uses the same location data,” says Porter. GeoClue also gathers location data from WiFi AP databases, 3G/4G tower info, and the GeoIP database — sources that are useful “if you’re inside or don’t have a good fix,” he added. - -GeoFence depends on the GPS binding, as well. It lets you establish a bounding box, and then track ingress and egress events. GeoFence also tracks “dwell” status, which is determined by arriving at home and staying for 10 minutes. “It then triggers some behavior based on a timeout,” said Porter. Future plans call for a customizable dwell transition time. - -While most of these Upstream bindings are well established, there are also Work in Progress (WIP) bindings that are still in the early stages, including CAN, HomeScreen, and WindowManager bindings. Farther out, there are plans to add speech recognition and text-to-speech bindings, as well as a WWAN modem binding. - -In conclusion, Porter noted: “Like any open source project, we desperately need more developers.” The Automotive Grade Linux project may seem peripheral to some developers, but it offers a nice mix of familiarity — grounded in many widely used open source projects -- along with the excitement of expanding into a new and potentially game changing computing form factor: your automobile. AGL has also demonstrated success — you can now [check out AGL in action in the 2018 Toyota Camry][14], followed in the coming month by most Toyota and Lexus vehicles sold in North America. - -Watch the complete video below: - -[视频][15] - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/event/elce/2017/11/inside-agl-familiar-open-source-components-ease-learning-curve - -作者:[ ERIC BROWN][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/ericstephenbrown -[1]:https://www.linux.com/licenses/category/linux-foundation -[2]:https://www.youtube.com/playlist?list=PLbzoR-pLrL6pISWAq-1cXP4_UZAyRtesk -[3]:https://www.youtube.com/watch?v=kfwEmjSjAzM&index=14&list=PLbzoR-pLrL6pISWAq-1cXP4_UZAyRtesk -[4]:https://www.linux.com/files/images/porter-elce-aglpng -[5]:http://events.linuxfoundation.org/events/embedded-linux-conference-europe -[6]:https://www.automotivelinux.org/ -[7]:https://www.linux.com/blog/2017/8/automotive-grade-linux-moves-ucb-40-launches-virtualization-workgroup -[8]:http://schaufler-ca.com/ -[9]:https://wiki.tizen.org/Security:Cynara -[10]:https://wiki.maemo.org/Bluetooth_PBAP -[11]:https://www.rtl-sdr.com/about-rtl-sdr/ -[12]:http://www.catb.org/gpsd/ -[13]:https://www.freedesktop.org/wiki/Software/GeoClue/ -[14]:https://www.linux.com/blog/event/automotive-linux-summit/2017/6/linux-rolls-out-toyota-and-lexus-vehicles -[15]:https://youtu.be/RgI-g5h1t8I diff --git a/sources/talk/20171222 18 Cyber-Security Trends Organizations Need to Brace for in 2018.md b/sources/talk/20171222 18 Cyber-Security Trends Organizations Need to Brace for in 2018.md deleted file mode 100644 index 09223ccb21..0000000000 --- a/sources/talk/20171222 18 Cyber-Security Trends Organizations Need to Brace for in 2018.md +++ /dev/null @@ -1,116 +0,0 @@ -18 Cyber-Security Trends Organizations Need to Brace for in 2018 -====== - -### 18 Cyber-Security Trends Organizations Need to Brace for in 2018 - -Enterprises, end users and governments faced no shortage of security challenges in 2017. Some of those same challenges will continue into 2018, and there will be new problems to solve as well. Ransomware has been a concern for several years and will likely continue to be a big issue in 2018. The new year is also going to bring the formal introduction of the European Union's General Data Protection Regulation (GDPR), which will impact how organizations manage private information. A key trend that emerged in 2017 was an increasing use of artificial intelligence (AI) to help solve cyber-security challenges, and that's a trend that will continue to accelerate in 2018. What else will the new year bring? In this slide show, eWEEK presents 18 security predictions for the year ahead from 18 security experts. - - -### Africa Emerges as New Area for Threat Actors and Targets - -"In 2018, Africa will emerge as a new focus area for cyber-threats--both targeting organizations based there and attacks originating from the continent. With its growth in technology adoption and operations and rising economy, and its increasing number of local resident threat actors, Africa has the largest potential for net-new impactful cyber events." -Steve Stone, IBM X-Force IRIS - - -### AI vs. AI - -"2018 will see a rise in AI-based attacks as cyber-criminals begin using machine learning to spoof human behaviors. The cyber-security industry will need to tune their own AI tools to better combat the new threats. The cat and mouse game of cybercrime and security innovation will rapidly escalate to include AI-enabled tools on both sides." --Caleb Barlow, vice president of Threat Intelligence, IBM Security - - -### Cyber-Security as a Growth Driver - -"CEOs view cyber-security as one of their top risks, but many also see it as an opportunity to innovate and find new ways to generate revenue. In 2018 and beyond, effective cyber-security measures will support companies that are transforming their security, privacy and continuity controls in an effort to grow their businesses." -Greg Bell, KMPG's Global Cyber Security Practice co-leader - - -### GDPR Means Good Enough Isn't Good Enough - -"Too many professionals share a 'good enough' philosophy that they've adopted from their consumer mindset that they can simply upgrade and patch to comply with the latest security and compliance best practices or regulations. In 2018, with the upcoming enforcement of the EU GDPR 'respond fast' rules, organizations will quickly come to terms, and face fines, with why 'good enough' is not 'good' anymore." -Kris Lovejoy, CEO of BluVector - - -### Consumerization of Cyber-Security - -"2018 will mark the debut of the 'consumerization of cyber-security.' This means consumers will be offered a unified, comprehensive suite of security offerings, including, in addition to antivirus and spyware protection, credit and identify abuse monitoring and identity restoration. This is a big step forward compared to what is available in one package today. McAfee Total Protection, which safeguards consumer identities in addition to providing virus and malware protection, is an early, simplified example of this. Consumers want to feel more secure." -Don Dixon, co-founder and managing director, Trident Capital Cybersecurity - - -### Ransomware Will Continue - -"Ransomware will continue to plague organizations with 'old' attacks 'refreshed' and reused. The threat of ransomware will continue into 2018. This year we've seen ransomware wreak havoc across the globe with both WannaCry and NotPetya hitting the headlines. Threats of this type and on this scale will be a common feature of the next 12 months." -Andrew Avanessian, chief operating officer at Avecto - - -### More Encryption Will Be Needed - -"It will become increasingly clear in the industry that HTTPS does not offer the robust security and end-to-end encryption as is commonly believed, and there will be a push to encrypt data before it is sent over HTTPS." -Darren Guccione, CEO and co-founder, Keeper Security - - -### Denial of Service Will Become Financially Lucrative - -"Denial of service will become as financially lucrative as identity theft. Using stolen identities for new account fraud has been the major revenue driver behind breaches. However, in recent years ransomware attacks have caused as much if not more damage, as increased reliance on distributed applications and cloud services results in massive business damage when information, applications or systems are held hostage by attackers." -John Pescatore. SANS' director of emerging security trends - - -### Goodbye Social Security Number - -"2018 is the turning point for the retirement of the Social Security number. At this point, the vast majority of SSNs are compromised, and we can no longer rely on them--nor should we have previously." -Michael Sutton, CISO, Zscaler - - -### Post-Quantum Cyber-Security Discussion Warms Up the Boardroom - -"The uncertainty of cyber-security in a post-quantum world is percolating some circles, but 2018 is the year the discussions gain momentum in the top levels of business. As security experts grapple with preparing for a post-quantum world, top executives will begin to ask what can be done to ensure all of our connected 'things' remain secure." -Malte Pollmann, CEO of Utimaco - - -### Market Consolidation Is Coming - -"There will be accelerated consolidation of cyber niche markets flooded with too many 'me-too' companies offering extremely similar products and services. As an example, authentication, end-point security and threat intelligence now boast a total of more than 25 competitors. Ultimately, only three to six companies in each niche can survive." -Mike Janke, co-founder of DataTribe - - -### Health Care Will Be a Lucrative Target - -"Health records are highly valued on the black market because they are saturated with Personally Identifiable Information (PII). Health care institutions will continue to be a target as they have tighter allocations for security in their IT budgets. Also, medical devices are hard to update and often run on older operating system versions." -Larry Cashdollar, senior engineer, Security Intelligence Response Team, Akamai - - -### 2018: The Year of Simple Multifactor Authentication for SMBs - -"Unfortunately, effective multifactor authentication (MFA) solutions have remained largely out of reach for the average small- and medium-sized business. Though enterprise multifactor technology is quite mature, it often required complex on-premises solutions and expensive hardware tokens that most small businesses couldn't afford or manage. However, the growth of SaaS and smartphones has introduced new multifactor solutions that are inexpensive and easy for small businesses to use. Next year, many SMBs will adopt these new MFA solutions to secure their more privileged accounts and users. 2018 will be the year of MFA for SMBs." -Corey Nachreiner, CTO at WatchGuard Technologies - - -### Automation Will Improve the IT Skills Gap - -"The security skills gap is widening every year, with no signs of slowing down. To combat the skills gap and assist in the growing adoption of advanced analytics, automation will become an even higher priority for CISOs." -Haiyan Song, senior vice president of Security Markets at Splunk - - -### Industrial Security Gets Overdue Attention - -"The high-profile attacks of 2017 acted as a wake-up call, and many plant managers now worry that they could be next. Plant manufacturers themselves will offer enhanced security. Third-party companies going on their own will stay in a niche market. The industrial security manufacturers themselves will drive a cooperation with the security industry to provide security themselves. This is because there is an awareness thing going on and impending government scrutiny. This is different from what happened in the rest of IT/IoT where security vendors just go to market by themselves as a layer on top of IT (i.e.: an antivirus on top of Windows)." -Renaud Deraison, co-founder and CTO, Tenable - - -### Cryptocurrencies Become the New Playground for Identity Thieves - -"The rising value of cryptocurrencies will lead to greater attention from hackers and bad actors. Next year we'll see more fraud, hacks and money laundering take place across the top cryptocurrency marketplaces. This will lead to a greater focus on identity verification and, ultimately, will result in legislation focused on trader identity." -Stephen Maloney, executive vice president of Business Development & Strategy, Acuant - - -### GDPR Compliance Will Be a Challenge - -"In 2018, three quarters of companies or apps will be ruled out of compliance with GDPR and at least one major corporation will be fined to the highest extent in 2018 to set an example for others. Most companies are preparing internally by performing more security assessments and recruiting a mix of security professionals with privacy expertise and lawyers, but with the deadline quickly approaching, it's clear the bulk of businesses are woefully behind and may not be able to avoid these consequences." -Sanjay Beri, founder and CEO, Netskope - - -### Data Security Solidifies Its Spot in the IT Security Stack - -"Many businesses are stuck in the mindset that security of networks, servers and applications is sufficient to protect their data. However, the barrage of breaches in 2017 highlights a clear disconnect between what organizations think is working and what actually works. In 2018, we expect more businesses to implement data security solutions that complement their existing network security deployments." -Jim Varner, CEO of SecurityFirst - - -### [Eight Cyber-Security Vendors Raise New Funding in November 2017][1] - -Though the pace of funding slowed in November, multiple firms raised new venture capital to develop and improve their cyber-security products. - -Though the pace of funding slowed in November, multiple firms raised new venture capital to develop and improve their cyber-security products. - --------------------------------------------------------------------------------- - -via: http://voip.eweek.com/security/18-cyber-security-trends-organizations-need-to-brace-for-in-2018 - -作者:[Sean Michael Kerner][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://voip.eweek.com/Authors/sean-michael-kerner -[1]:http://voip.eweek.com/security/eight-cyber-security-vendors-raise-new-funding-in-november-2017 diff --git a/sources/talk/20180104 How allowing myself to be vulnerable made me a better leader.md b/sources/talk/20180104 How allowing myself to be vulnerable made me a better leader.md deleted file mode 100644 index 1cd6a22162..0000000000 --- a/sources/talk/20180104 How allowing myself to be vulnerable made me a better leader.md +++ /dev/null @@ -1,64 +0,0 @@ -How allowing myself to be vulnerable made me a better leader -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/leaderscatalysts.jpg?itok=f8CwHiKm) - -Conventional wisdom suggests that leadership is strong, bold, decisive. In my experience, leadership does feel like that some days. - -Some days leadership feels more vulnerable. Doubts creep in: Am I making good decisions? Am I the right person for this job? Am I focusing on the most important things? - -The trick with these moments is to talk about these moments. When we keep them secret, our insecurity only grows. Being an open leader means pushing our vulnerability into the spotlight. Only then can we seek comfort from others who have experienced similar moments. - -To demonstrate how this works, I'll share a story. - -### A nagging question - -If you work in the tech industry, you'll note an obvious focus on creating [an organization that's inclusive][1]--a place for diversity to flourish. Long story short: I thought I was a "diversity hire," someone hired because of my gender, not my ability. Even after more than 15 years in the industry, with all of the focus on diversity in hiring, that possibility got under my skin. Along came the doubts: Was I hired because I was the best person for the job--or because I was a woman? After years of knowing I was hired because I was the best person, the fact that I was female suddenly seemed like it was more interesting to potential employers. - -I rationalized that it didn't matter why I was hired; I knew I was the best person for the job and would prove it. I worked hard, delivered results, made mistakes, learned, and did everything an employer would want from an employee. - -And yet the "diversity hire" question nagged. I couldn't shake it. I avoided the subject like the plague and realized that not talking about it was a signal that I had no choice but to deal with it. If I continued to avoid the subject, it was going to affect my work. And that's the last thing I wanted. - -### Speaking up - -Talking about diversity and inclusion can be awkward. So many factors enter into the decision to open up: - - * Can we trust our co-workers with a vulnerable moment? - * Can a leader of a team be too vulnerable? - * What if I overstep? Do I damage my career? - - - -In my case, I ended up at a lunch Q&A session with an executive who's a leader in many areas of the organization--especially candid conversations. A coworker asked the "Was I a diversity hire?" question. He stopped and spent a significant amount of time talking about this question to a room full of women. I'm not going to recount the entire discussion here; I will share the most salient point: If you know you're qualified for the job and you know the interview went well, don't doubt the outcome. Anyone who questions whether you're a diversity hire has their own questions to answer. You don't have to go on their journey. - -Mic drop. - -I wish I could say that I stopped thinking about this topic. I didn't. The question lingered: What if I am the exception to the rule? What if I was the one diversity hire? I realized that I couldn't avoid the nagging question. - -Because I had the courage to be vulnerable--to go there with my question--I had the burden of my secret question lifted. - -A few weeks later I had a one-on-one with the executive. At the end of conversation, I mentioned that, as a woman, I appreciate his candid conversations about diversity and inclusion. It's easier to talk about these topics when a recognized leader is willing to have the conversation. I also returned to the "Was I a diversity hire? question. He didn't hesitate: We talked. At the end of the conversation, I realized that I was hungry to talk about these things that require bravery; I only needed a nudge and someone who cared enough to talk and listen. - -Because I had the courage to be vulnerable--to go there with my question--I had the burden of my secret question lifted. Feeling physically lighter, I started to have constructive conversations around the questions of implicit bias, what we can do to be inclusive, and what diversity looks like. As I've learned, every person has a different answer when I ask the diversity question. I wouldn't have gotten to have all of these amazing conversations if I'd stayed stuck with my secret. - -I had courage to talk, and I hope you will too. - -Let's talk about these things that hold us back in terms of our ability to lead so we can be more open leaders in every sense of the phrase. Has allowing yourself to be vulnerable made you a better leader? - -### About The Author - -Angela Robertson;Angela Robertson Works As A Senior Manager At Microsoft. She Works With An Amazing Team Of People Passionate About Community Contributions;Engaged In Open Organizations. Before Joining Microsoft;Angela Worked At Red Hat - - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/12/how-allowing-myself-be-vulnerable-made-me-better-leader - -作者:[Angela Robertson][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/arobertson98 -[1]:https://opensource.com/open-organization/17/9/building-for-inclusivity diff --git a/sources/talk/20180117 How technology changes the rules for doing agile.md b/sources/talk/20180117 How technology changes the rules for doing agile.md deleted file mode 100644 index 1b67935509..0000000000 --- a/sources/talk/20180117 How technology changes the rules for doing agile.md +++ /dev/null @@ -1,95 +0,0 @@ -How technology changes the rules for doing agile -====== - -![](https://enterprisersproject.com/sites/default/files/styles/620x350/public/images/CIO%20Containers%20Ecosystem.png?itok=lDTaYXzk) - -More companies are trying agile and [DevOps][1] for a clear reason: Businesses want more speed and more experiments - which lead to innovations and competitive advantage. DevOps helps you gain that speed. But doing DevOps in a small group or startup and doing it at scale are two very different things. Any of us who've worked in a cross-functional group of 10 people, come up with a great solution to a problem, and then tried to apply the same patterns across a team of 100 people know the truth: It often doesn't work. This path has been so hard, in fact, that it has been easy for IT leaders to put off agile methodology for another year. - -But that time is over. If you've tried and stalled, it's time to jump back in. - -Until now, DevOps required customized answers for many organizations - lots of tweaks and elbow grease. But today, [Linux containers ][2]and Kubernetes are fueling standardization of DevOps tools and processes. That standardization will only accelerate. The technology we are using to practice the DevOps way of working has finally caught up with our desire to move faster. - -Linux containers and [Kubernetes][3] are changing the way teams interact. Moreover, on the Kubernetes platform, you can run any application you now run on Linux. What does that mean? You can run a tremendous number of enterprise apps (and handle even previously vexing coordination issues between Windows and Linux.) Finally, containers and Kubernetes will handle almost all of what you'll run tomorrow. They're being future-proofed to handle machine learning, AI, and analytics workloads - the next wave of problem-solving tools. - -**[ See our related article,[4 container adoption patterns: What you need to know. ] ][4]** - -Think about machine learning, for example. Today, people still find the patterns in much of an enterprise's data. When machines find the patterns (think machine learning), your people will be able to act on them faster. With the addition of AI, machines can not only find but also act on patterns. Today, with people doing everything, three weeks is an aggressive software development sprint cycle. With AI, machines can change code multiple times per second. Startups will use that capability - to disrupt you. - -Consider how fast you have to be to compete. If you can't make a leap of faith now to DevOps and a one week cycle, think of what will happen when that startup points its AI-fueled process at you. It's time to move to the DevOps way of working now, or get left behind as your competitors do. - -### How are containers changing how teams work? - -DevOps has frustrated many groups trying to scale this way of working to a bigger group. Many IT (and business) people are suspicious of agile: They've heard it all before - languages, frameworks, and now models (like DevOps), all promising to revolutionize application development and IT process. - -**[ Want DevOps advice from other CIOs? See our comprehensive resource, [DevOps: The IT Leader's Guide][5]. ]** - -It's not easy to "sell" quick development sprints to your stakeholders, either. Imagine if you bought a house this way. You're not going to pay a fixed amount to your builder anymore. Instead, you get something like: "We'll pour the foundation in 4 weeks and it will cost x. Then we'll frame. Then we'll do electrical. But we only know the timing on the foundation right now." People are used to buying homes with a price up front and a schedule. - -The challenge is that building software is not like building a house. The same builder builds thousands of houses that are all the same. Software projects are never the same. This is your first hurdle to get past. - -Dev and operations teams really do work differently: I know because I've worked on both sides. We incent them differently. Developers are rewarded for changing and creating, while operations pros are rewarded for reducing cost and ensuring security. We put them in different groups and generally minimize interaction. And the roles typically attract technical people who think quite differently. This situation sets IT up to fail. You have to be willing to break down these barriers. - -Think of what has traditionally happened. You throw pieces over the wall, then the business throws requirements over the wall because they are operating in "house-buying" mode: "We'll see you in 9 months." Developers build to those requirements and make changes as needed for technical constraints. Then they throw it over the wall to operations to "figure out how to run this." Operations then works diligently to make a slew of changes to align the software with their infrastructure. And what's the end result? - -More often than not, the end result isn't even recognizable to the business when they see it in its final glory. We've watched this pattern play out time and time again in our industry for the better part of two decades. It's time for a change. - -It's Linux containers that truly crack the problem - because containers close the gap between development and operations. They allow both teams to understand and design to all of the critical requirements, but still uniquely fulfill their team's responsibilities. Basically, we take out the telephone game between developers and operations. With containers, we can have smaller operations teams, even teams responsible for millions of applications, but development teams that can change software as quickly as needed. (In larger organizations, the desired pace may be faster than humans can respond on the operations side.) - -With containers, you're separating what is delivered from where it runs. Your operations teams are responsible for the host that will run the containers and the security footprint, and that's all. What does this mean? - -First, it means you can get going on DevOps now, with the team you have. That's right. Keep teams focused on the expertise they already have: With containers, just teach them the bare minimum of the required integration dependencies. - -If you try and retrain everyone, no one will be that good at anything. Containers let teams interact, but alongside a strong boundary, built around each team's strengths. Your devs know what needs to be consumed, but don't need to know how to make it run at scale. Ops teams know the core infrastructure, but don't need to know the minutiae of the app. Also, Ops teams can update apps to address new security implications, before you become the next trending data breach story. - -Teaching a large IT organization of say 30,000 people both ops and devs skills? It would take you a decade. You don't have that kind of time. - -When people talk about "building new, cloud-native apps will get us out of this problem," think critically. You can build cloud-native apps in 10-person teams, but that doesn't scale for a Fortune 1000 company. You can't just build new microservices one by one until you're somehow not reliant on your existing team: You'll end up with a siloed organization. It's an alluring idea, but you can't count on these apps to redefine your business. I haven't met a company that could fund parallel development at this scale and succeed. IT budgets are already constrained; doubling or tripling them for an extended period of time just isn't realistic. - -### When the remarkable happens: Hello, velocity - -Linux containers were made to scale. Once you start to do so, [orchestration tools like Kubernetes come into play][6] - because you'll need to run thousands of containers. Applications won't consist of just a single container, they will depend on many different pieces, all running on containers, all running as a unit. If they don't, your apps won't run well in production. - -Think of how many small gears and levers come together to run your business: The same is true for any application. Developers are responsible for all the pulleys and levers in the application. (You could have an integration nightmare if developers don't own those pieces.) At the same time, your operations team is responsible for all the pulleys and levers that make up your infrastructure, whether on-premises or in the cloud. With Kubernetes as an abstraction, your operations team can give the application the fuel it needs to run - without being experts on all those pieces. - -Developers get to experiment. The operations team keeps infrastructure secure and reliable. This combination opens up the business to take small risks that lead to innovation. Instead of having to make only a couple of bet-the-farm size bets, real experimentation happens inside the company, incrementally and quickly. - -In my experience, this is where the remarkable happens inside organizations: Because people say "How do we change planning to actually take advantage of this ability to experiment?" It forces agile planning. - -For example, KeyBank, which uses a DevOps model, containers, and Kubernetes, now deploys code every day. (Watch this [video][7] in which John Rzeszotarski, director of Continuous Delivery and Feedback at KeyBank, explains the change.) Similarly, Macquarie Bank uses DevOps and containers to put something in production every day. - -Once you push software every day, it changes every aspect of how you plan - and [accelerates the rate of change to the business][8]. "An idea can get to a customer in a day," says Luis Uguina, CDO of Macquarie's banking and financial services group. (See this [case study][9] on Red Hat's work with Macquarie Bank). - -### The right time to build something great - -The Macquarie example demonstrates the power of velocity. How would that change your approach to your business? Remember, Macquarie is not a startup. This is the type of disruptive power that CIOs face, not only from new market entrants but also from established peers. - -The developer freedom also changes the talent equation for CIOs running agile shops. Suddenly, individuals within huge companies (even those not in the hottest industries or geographies) can have great impact. Macquarie uses this dynamic as a recruiting tool, promising developers that all new hires will push something live within the first week. - -At the same time, in this day of cloud-based compute and storage power, we have more infrastructure available than ever. That's fortunate, considering the [leaps that machine learning and AI tools will soon enable][10]. - -This all adds up to this being the right time to build something great. Given the pace of innovation in the market, you need to keep building great things to keep customers loyal. So if you've been waiting to place your bet on DevOps, now is the right time. Containers and Kubernetes have changed the rules - in your favor. - -**Want more wisdom like this, IT leaders? [Sign up for our weekly email newsletter][11].** - --------------------------------------------------------------------------------- - -via: https://enterprisersproject.com/article/2018/1/how-technology-changes-rules-doing-agile - -作者:[Matt Hicks][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/matt-hicks -[1]:https://enterprisersproject.com/tags/devops -[2]:https://www.redhat.com/en/topics/containers?intcmp=701f2000000tjyaAAA -[3]:https://www.redhat.com/en/topics/containers/what-is-kubernetes?intcmp=701f2000000tjyaAAA -[4]:https://enterprisersproject.com/article/2017/8/4-container-adoption-patterns-what-you-need-know?sc_cid=70160000000h0aXAAQ -[5]:https://enterprisersproject.com/devops?sc_cid=70160000000h0aXAAQ -[6]:https://enterprisersproject.com/article/2017/11/how-enterprise-it-uses-kubernetes-tame-container-complexity -[7]:https://www.redhat.com/en/about/videos/john-rzeszotarski-keybank-red-hat-summit-2017?intcmp=701f2000000tjyaAAA -[8]:https://enterprisersproject.com/article/2017/11/dear-cios-stop-beating-yourselves-being-behind-transformation -[9]:https://www.redhat.com/en/resources/macquarie-bank-case-study?intcmp=701f2000000tjyaAAA -[10]:https://enterprisersproject.com/article/2018/1/4-ai-trends-watch -[11]:https://enterprisersproject.com/email-newsletter?intcmp=701f2000000tsjPAAQ diff --git a/sources/talk/20180209 A review of Virtual Labs virtualization solutions for MOOCs - WebLog Pro Olivier Berger.md b/sources/talk/20180209 A review of Virtual Labs virtualization solutions for MOOCs - WebLog Pro Olivier Berger.md deleted file mode 100644 index 0cb3755ca1..0000000000 --- a/sources/talk/20180209 A review of Virtual Labs virtualization solutions for MOOCs - WebLog Pro Olivier Berger.md +++ /dev/null @@ -1,255 +0,0 @@ -A review of Virtual Labs virtualization solutions for MOOCs – WebLog Pro Olivier Berger -====== -### 1 Introduction - -This is a memo that tries to capture some of the experience gained in the [FLIRT project][3] on the topic of Virtual Labs for MOOCs (Massive Open Online Courses). - -In this memo, we try to draw an overview of some benefits and concerns with existing approaches at using virtualization techniques for running Virtual Labs, as distributions of tools made available for distant learners. - -We describe 3 main technical architectures: (1) running Virtual Machine images locally on a virtual machine manager, or (2) displaying the remote execution of similar virtual machines on a IaaS cloud, and (3) the potential of connecting to the remote execution of minimized containers on a remote PaaS cloud. - -We then elaborate on some perspectives for locally running ports of applications to the WebAssembly virtual machine of the modern Web browsers. - -Disclaimer: This memo doesn’t intend to point to extensive literature on the subject, so part of our analysis may be biased by our particular context. - -### 2 Context : MOOCs - -Many MOOCs (Massive Open Online Courses) include a kind of “virtual laboratory” for learners to experiment with tools, as a way to apply the knowledge, practice, and be more active in the learning process. In quite a few (technical) disciplines, this can consist in using a set of standard applications in a professional domain, which represent typical tools that would be used in real life scenarii. - -Our main perspective will be that of a MOOC editor and of MOOC production teams which want to make “virtual labs” available for MOOC participants. - -Such a “virtual lab” would typically contain installations of existing applications, pre-installed and configured, and loaded with scenario data in order to perform a lab. - -The main constraint here is that such labs would typically be fabricated with limited software development expertise and funds[1][4]. Thus we consider here only the assembly of existing “normal” applications and discard the option of developping novel “serious games” and simulator applications for such MOOCs. - -#### 2.1 The FLIRT project - -The [FLIRT project][5] groups a consortium of 19 partners in Industry, SMEs and Academia to work on a collection of MOOCs and SPOCs for professional development in Networks and Telecommunications. Lead by Institut Mines Telecom, it benefits from the funding support of the French “Investissements d’avenir” programme. - -As part of the FLIRT roadmap, we’re leading an “innovation task” focused on Virtual Labs in the context of the Cloud. This memo was produced as part of this task. - -#### 2.2 Some challenges in virtual labs design for distant learning - -Virtual Labs used in distance learning contexts require the use of software applications in autonomy, either running on a personal, or professional computer. In general, the technical skills of participants may be diverse. So much for the quality (bandwith, QoS, filtering, limitations: firewaling) of the hardware and networks they use at home or at work. It’s thus very optimistic to seek for one solution fits all strategy. - -Most of the time there’s a learning curve on getting familiar with the tools which students will have to use, which constitutes as many challenges to overcome for beginners. These tools may not be suited for beginners, but they will still be selected by the trainers as they’re representative of the professional context being taught. - -In theory, this usability challenge should be addressed by devising an adapted pedagogical approach, especially in a context of distance learning, so that learners can practice the labs on their own, without the presence of a tutor or professor. Or some particular prerequisite skills could be required (“please follow System Administration 101 before applying to this course”). - -Unfortunately there are many cases where instructors basically just translate to a distant learning scenario, previous lab resources that had previously been devised for in presence learning. This lets learner faced with many challenges to overcome. The only support resource is often a regular forum on the MOOC’s LMS (Learning Management System). - -My intuition[2][6] is that developing ad-hoc simulators for distant education would probably be more efficient and easy to use for learners. But that would require a too high investment for the designers of the courses. - -In the context of MOOCs which are mainly free to participate to, not much investment is possible in devising ad-hoc lab applications, and instructors have to rely on existing applications, tools and scenarii to deliver a cheap enough environment. Furthermore, technical or licensing constraints[3][7] may lead to selecting lab tools which may not be easy to learn, but have the great advantage or being freely redistributable[4][8]. - -### 3 Virtual Machines for Virtual Labs - -The learners who will try unattended learning in such typical virtual labs will face difficulties in making specialized applications run. They must overcome the technical details of downloading, installing and configuring programs, before even trying to perform a particular pedagogical scenario linked to the matter studied. - -To diminish these difficulties, one traditional approach for implementing labs in MOOCs has been to assemble in advance a Virtual Machine image. This already made image can then be downloaded and run with a virtual machine simulator (like [VirtualBox][9][5][10]). - -The pre-loaded VM will already have everything ready for use, so that the learners don’t have to install anything on their machines. - -An alternative is to let learners download and install the needed software tools themselves, but this leads to so many compatibility issues or technical skill prerequisites, that this is often not advised, and mentioned only as a fallback option. - -#### 3.1 Downloading and installation issues - -Experience shows[2][11] that such virtual machines also bring some issues. Even if installation of every piece of software is no longer required, learners still need to be able to run the VM simulator on a wide range of diverse hardware, OSes and configurations. Even managing to download the VMs, still causes many issues (lack admin privileges, weight vs download speed, memory or CPU load, disk space, screen configurations, firewall filtering, keayboard layout, etc.). - -These problems aren’t generally faced by the majority of learners, but the impacted minority is not marginal either, and they generally will produce a lot of support requests for the MOOC team (usually in the forums), which needs to be anticipated by the community managers. - -The use of VMs is no show stopper for most, but can be a serious problem for a minority of learners, and is then no silver bullet. - -Some general usability issues may also emerge if users aren’t used to the look and feel of the enclosed desktop. For instance, the VM may consist of a GNU/Linux desktop, whereas users would use a Windows or Mac OS system. - -#### 3.2 Fabrication issues for the VM images - -On the MOOC team’s side, the fabrication of a lightweight, fast, tested, license-free and easy to use VM image isn’t necessarily easy. - -Software configurations tend to rot as time passes, and maintenance may not be easy when the later MOOC editions evolutions lead to the need to maintain the virtual lab scenarii years later. - -Ideally, this would require adopting an “industrial” process in building (and testing) the lab VMs, but this requires quite an expertise (system administration, packaging, etc.) that may or not have been anticipated at the time of building the MOOC (unlike video editing competence, for instance). - -Our experiment with the [Vagrant][12] technology [[0][13]] and Debian packaging was interesting in this respect, as it allowed us to use a well managed “script” to precisely control the build of a minimal VM image. - -### 4 Virtual Labs as a Service - -To overcome the difficulties in downloading and running Virtual Machines on one’s local computer, we have started exploring the possibility to run these applications in a kind of Software as a Service (SaaS) context, “on the cloud”. - -But not all applications typically used in MOOC labs are already available for remote execution on the cloud (unless the course deals precisely with managing email in GMail). - -We have then studied the option to use such an approach not for a single application, but for a whole virtual “desktop” which would be available on the cloud. - -#### 4.1 IaaS deployments - -A way to achieve this goal is to deploy Virtual Machine images quite similar to the ones described above, on the cloud, in an Infrastructure as a Service (IaaS) context[6][14], to offer access to remote desktops for every learners. - -There are different technical options to achieve this goal, but a simplified description of the architecture can be seen as just running Virtual Machines on a single IaaS platform instead of on each learner’s computer. Access to the desktop and application interfaces is made possible with the use of Web pages (or other dedicated lightweight clients) which will display a “full screen” display of the remote desktop running for the user on the cloud VM. Under the hood, the remote display of a Linux desktop session is made with technologies like [VNC][15] and [RDP][16] connecting to a [Guacamole][17] server on the remote VM. - -In the context of the FLIRT project, we have made early experiments with such an architecture. We used the CloVER solution by our partner [ProCAN][18] which provides a virtual desktops broker between [OpenEdX][19] and an [OpenStack][20] IaaS public platform. - -The expected benefit is that users don’t have to install anything locally, as the only tool needed locally is a Web browser (displaying a full-screen [HTML5 canvas][21] displaying the remote desktop run by the Guacamole server running on the cloud VM. - -But there are still some issues with such an approach. First, the cost of operating such an infrastructure : Virtual Machines need to be hosted on a IaaS platform, and that cost of operation isn’t null[7][22] for the MOOC editor, compared to the cost of VirtualBox and a VM running on the learner’s side (basically zero for the MOOC editor). - -Another issue, which could be more problematic lies in the need for a reliable connection to the Internet during the whole sequences of lab execution by the learners[8][23]. Even if Guacamole is quite efficient at compressing rendering traffic, some basic connectivity is needed during the whole Lab work sessions, preventing some mobile uses for instance. - -One other potential annoyance is the potential delays for making a VM available to a learner (provisioning a VM), when huge VMs images need to be copied inside the IaaS platform when a learner connects to the Virtual Lab activity for the first time (several minutes delays). This may be worse if the VM image is too big (hence the need for optimization of the content[9][24]). - -However, the fact that all VMs are running on a platform under the control of the MOOC editor allows new kind of features for the MOOC. For instance, learners can submit results of their labs directly to the LMS without the need to upload or copy-paste results manually. This can help monitor progress or perform evaluation or grading. - -The fact that their VMs run on the same platform also allows new kinds of pedagogical scenarii, as VMs of multiple learners can be interconnected, allowing cooperative activities between learners. The VM images may then need to be instrumented and deployed in particular configurations, which may require the use of a dedicated broker like CloVER to manage such scenarii. - -For the records, we have yet to perform a rigorous benchmarking of such a solution in order to evaluate its benefits, or constraints given particular contexts. In FLIRT, our main focus will be in the context of SPOCs for professional training (a bit different a context than public MOOCs). - -Still this approach doesn’t solve the VMs fabrication issues for the MOOC staff. Installing software inside a VM, be it local inside a VirtualBox simulator of over the cloud through a remote desktop display, makes not much difference. This relies mainly on manual operations and may not be well managed in terms of quality of the process (reproducibility, optimization). - -#### 4.2 PaaS deployments using containers - -Some key issues in the IaaS context described above, are the cost of operation of running full VMs, and long provisioning delays. - -We’re experimenting with new options to address these issues, through the use of [Linux containers][25] running on a PaaS (Platform as a Service) platform, instead of full-fleshed Virtual Machines[10][26]. - -The main difference, with containers instead of Virtual Machines, lies in the reduced size of images, and much lower CPU load requirements, as the container remove the need for one layer of virtualization. Also, the deduplication techniques at the heart of some virtual file-systems used by container platforms lead to really fast provisioning, avoiding the need to wait for the labs to start. - -The traditional making of VMs, done by installing packages and taking a snapshot, was affordable for the regular teacher, but involved manual operations. In this respect, one other major benefit of containers is the potential for better industrialization of the virtual lab fabrication, as they are generally not assembled manually. Instead, one uses a “scripting” approach in describing which applications and their dependencies need to be put inside a container image. But this requires new competence from the Lab creators, like learning the [Docker][27] technology (and the [OpenShift][28] PaaS, for instance), which may be quite specialized. Whereas Docker containers tend to become quite popular in Software Development faculty (through the “[devops][29]” hype), they may be a bit new to other field instructors. - -The learning curve to mastering the automation of the whole container-based labs installation needs to be evaluated. There’s a trade-off to consider in adopting technology like Vagrant or Docker: acquiring container/PaaS expertise vs quality of industrialization and optimization. The production of a MOOC should then require careful planning if one has to hire or contract with a PaaS expert for setting up the Virtual Labs. - -We may also expect interesting pedagogical benefits. As containers are lightweight, and platforms allow to “easily” deploy multiple interlinked containers (over dedicated virtual networks), this enables the setup of more realistic scenarii, where each learner may be provided with multiple “nodes” over virtual networks (all running their individual containers). This would be particularly interesting for Computer Networks or Security teaching for instance, where each learner may have access both to client and server nodes, to study client-server protocols, for instance. This is particularly interesting for us in the context of our FLIRT project, where we produce a collection of Computer Networks courses. - -Still, this mode of operation relies on a good connectivity of the learners to the Cloud. In contexts of distance learning in poorly connected contexts, the PaaS architecture doesn’t solve that particular issue compared to the previous IaaS architecture. - -### 5 Future server-less Virtual Labs with WebAssembly - -As we have seen, the IaaS or PaaS based Virtual Labs running on the Cloud offer alternatives to installing local virtual machines on the learner’s computer. But they both require to be connected for the whole duration of the Lab, as the applications would be executed on the remote servers, on the Cloud (either inside VMs or containers). - -We have been thinking of another alternative which could allow the deployment of some Virtual Labs on the local computers of the learners without the hassles of downloading and installing a Virtual Machine manager and VM image. We envision the possibility to use the infrastructure provided by modern Web browsers to allow running the lab’s applications. - -At the time of writing, this architecture is still highly experimental. The main idea is to rebuild the applications needed for the Lab so that they can be run in the “generic” virtual machine present in the modern browsers, the [WebAssembly][30] and Javascript execution engine. - -WebAssembly is a modern language which seeks for maximum portability, and as its name hints, is a kind of assembly language for the Web platform. What is of interest for us is that WebAssembly is portable on most modern Web browsers, making it a very interesting platform for portability. - -Emerging toolchains allow recompiling applications written in languages like C or C++ so that they can be run on the WebAssembly virtual machine in the browser. This is interesting as it doesn’t require modifying the source code of these programs. Of course, there are limitations, in the kind of underlying APIs and libraries compatible with that platform, and on the sandboxing of the WebAssembly execution engine enforced by the Web browser. - -Historically, WebAssembly has been developped so as to allow running games written in C++ for a framework like Unity, in the Web browser. - -In some contexts, for instance for tools with an interactive GUI, and processing data retrieved from files, and which don’t need very specific interaction with the underlying operating system, it seems possible to port these programs to WebAssembly for running them inside the Web browser. - -We have to experiment deeper with this technology to validate its potential for running Virtual Labs in the context of a Web browser. - -We used a similar approach in the past in porting a Relational Database course lab to the Web browser, for standalone execution. A real database would run in the minimal SQLite RDBMS, recompiled to JavaScript[11][31]. Instead of having to download, install and run a VM with a RDBMS, the students would only connect to a Web page, which would load the DBMS in memory, and allow performing the lab SQL queries locally, disconnected from any third party server. - -In a similar manner, we can think for instance, of a Lab scenario where the Internet packet inspector features of the Wireshark tool would run inside the WebAssembly virtual machine, to allow dissecting provided capture files, without having to install Wireshard, directly into the Web browser. - -We expect to publish a report on that last experiment in the future with more details and results. - -### 6 Conclusion - -The most promising architecture for Virtual Lab deployments seems to be the use of containers on a PaaS platform for deploying virtual desktops or virtual application GUIs available in the Web browser. - -This would allow the controlled fabrication of Virtual Labs containing the exact bits needed for learners to practice while minimizing the delays. - -Still the need for always-on connectivity can be a problem. - -Also, the potential for inter-networked containers allowing the kind of multiple nodes and collaborative scenarii we described, would require a lot of expertise to develop, and management platforms for the MOOC operators, which aren’t yet mature. - -We hope to be able to report on our progress in the coming months and years on those aspects. - -### 7 References - - - -[0] -Olivier Berger, J Paul Gibson, Claire Lecocq and Christian Bac “Designing a virtual laboratory for a relational database MOOC”. International Conference on Computer Supported Education, SCITEPRESS, 23-25 may 2015, Lisbonne, Portugal, 2015, vol. 7, pp. 260-268, ISBN 978-989-758-107-6 – [DOI: 10.5220/0005439702600268][1] ([preprint (HTML)][2]) - -### 8 Copyright - - [![Creative Commons License](https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png)][45] - -This work is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][46] - -. - -### Footnotes: - -[1][32] – The FLIRT project also works on business model aspects of MOOC or SPOC production in the context of professional development, but the present memo starts from a minimalitic hypothesis where funding for course production is quite limited. - -[2][33] – research-based evidence needed - -[3][34] – In typical MOOCs which are free to participate, the VM should include only gratis tools, which typically means a GNU/Linux distribution loaded with applications available under free and open source licenses. - -[4][35] – Typically, Free and Open Source software, aka Libre Software - -[5][36] – VirtualBox is portable on many operating systems, making it a very popular solution for such a need - -[6][37] – the IaaS platform could typically be an open cloud for MOOCs or a private cloud for SPOCs (for closer monitoring of student activity or security control reasons). - -[7][38] – Depending of the expected use of the lab by learners, this cost may vary a lot. The size and configuration required for the included software may have an impact (hence the need to minimize the footprint of the VM images). With diminishing costs in general this may not be a show stopper. Refer to marketing figures of commercial IaaS offerings for accurate figures. Attention to additional licensing costs if the OS of the VM isn’t free software, or if other licenses must be provided for every learners. - -[8][39] – The needs for always-on connectivity may not be a problem for professional development SPOCs where learners connect from enterprise networks for instance. It may be detrimental when MOOCs are very popular in southern countries where high bandwidth is both unreliable and expensive. - -[9][40] – In this respect, providing a full Linux desktop inside the VM doesn’t necessarily make sense. Instead, running applications full-screen may be better, avoiding installation of whole desktop environments like Gnome or XFCE… but which has usability consequences. Careful tuning and testing is needed in any case. - -[10][41] – The availability of container based architectures is quite popular in the industry, but has not yet been deployed to a large scale in the context of large public MOOC hosting platforms, to our knowledge, at the time of writing. There are interesting technical challenges which the FLIRT project tries to tackle together with its partner ProCAN. - -[11][42] – See the corresponding paragraph [http://www-inf.it-sudparis.eu/PROSE/csedu2015/#standalone-sql-env][43] in [0][44] - - --------------------------------------------------------------------------------- - -via: https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/ - -作者:[Author;Olivier Berger;Télécom Sudparis][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www-public.tem-tsp.eu -[1]:http://dx.doi.org/10.5220/0005439702600268 -[2]:http://www-inf.it-sudparis.eu/PROSE/csedu2015/ -[3]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#org50fdc1a -[4]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fn.1 -[5]:http://flirtmooc.wixsite.com/flirt-mooc-telecom -[6]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fn.2 -[7]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fn.3 -[8]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fn.4 -[9]:http://virtualbox.org -[10]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fn.5 -[11]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fn.2 -[12]:https://www.vagrantup.com/ -[13]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#orgde5af50 -[14]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fn.6 -[15]:https://en.wikipedia.org/wiki/Virtual_Network_Computing -[16]:https://en.wikipedia.org/wiki/Remote_Desktop_Protocol -[17]:http://guacamole.apache.org/ -[18]:https://www.procan-group.com/ -[19]:https://open.edx.org/ -[20]:http://openstack.org/ -[21]:https://en.wikipedia.org/wiki/Canvas_element -[22]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fn.7 -[23]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fn.8 -[24]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fn.9 -[25]:https://www.redhat.com/en/topics/containers -[26]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fn.10 -[27]:https://en.wikipedia.org/wiki/Docker_(software) -[28]:https://www.openshift.com/ -[29]:https://en.wikipedia.org/wiki/DevOps -[30]:http://webassembly.org/ -[31]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fn.11 -[32]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fnr.1 -[33]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fnr.2 -[34]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fnr.3 -[35]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fnr.4 -[36]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fnr.5 -[37]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fnr.6 -[38]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fnr.7 -[39]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fnr.8 -[40]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fnr.9 -[41]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fnr.10 -[42]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#fnr.11 -[43]:http://www-inf.it-sudparis.eu/PROSE/csedu2015/#standalone-sql-env -[44]:https://www-public.tem-tsp.eu/~berger_o/weblog/a-review-of-virtual-labs-virtualization-solutions-for-moocs/#orgde5af50 -[45]:http://creativecommons.org/licenses/by-nc-sa/4.0/ -[46]:http://creativecommons.org/licenses/by-nc-sa/4.0/ diff --git a/sources/talk/20180604 10 principles of resilience for women in tech.md b/sources/talk/20180604 10 principles of resilience for women in tech.md index 3f451089bb..be1960d0c9 100644 --- a/sources/talk/20180604 10 principles of resilience for women in tech.md +++ b/sources/talk/20180604 10 principles of resilience for women in tech.md @@ -1,93 +1,93 @@ -10 principles of resilience for women in tech -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/diversity-women-meeting-team.png?itok=BdDKxT1w) - -Being a woman in tech is pretty damn cool. For every headline about [what Silicon Valley thinks of women][1], there are tens of thousands of women building, innovating, and managing technology teams around the world. Women are helping build the future despite the hurdles they face, and the community of women and allies growing to support each other is stronger than ever. From [BetterAllies][2] to organizations like [Girls Who Code][3] and communities like the one I met recently at [Red Hat Summit][4], there are more efforts than ever before to create an inclusive community for women in tech. - -But the tech industry has not always been this welcoming, nor is the experience for women always aligned with the aspiration. And so we're feeling the pain. Women in technology roles have dropped from its peak in 1991 at 36% to 25% today, [according to a report by NCWIT][5]. [Harvard Business Review estimates][6] that more than half of the women in tech will eventually leave due to hostile work conditions. Meanwhile, Ernst & Young recently shared [a study][7] and found that merely 11% of high school girls are planning to pursue STEM careers. - -We have much work to do, lest we build a future that is less inclusive than the one we live in today. We need everyone at the table, in the lab, at the conference and in the boardroom. - -I've been interviewing both women and men for more than a year now about their experiences in tech, all as part of [The Chasing Grace Project][8], a documentary series about women in tech. The purpose of the series is to help recruit and retain female talent for the tech industry and to give women a platform to be seen, heard, and acknowledged for their experiences. We believe that compelling story can begin to transform culture. - -### What Chasing Grace taught me - -What I've learned is that no matter the dismal numbers, women want to keep building and they collectively possess a resilience unmatched by anything I've ever seen. And this is inspiring me. I've found a power, a strength, and a beauty in every story I've heard that is the result of resilience. I recently shared with the attendees at the Red Hat Summit Women’s Leadership Luncheon the top 10 principles of resilience I've heard from throughout my interviews so far. I hope that by sharing them here the ideas and concepts can support and inspire you, too. - -#### 1\. Practice optimism - -When taken too far, optimism can give you blind spots. But a healthy dose of optimism allows you to see the best in people and situations and that positive energy comes back to you 100-fold. I haven’t met a woman yet as part of this project who isn’t an optimist. - -#### 2\. Build mental toughness - -I haven’t met a woman yet as part of this project who isn’t an optimist. - -When I recently asked a 32-year-old tech CEO, who is also a single mom of three young girls, what being a CEO required she said _mental toughness_. It really summed up what I’d heard in other words from other women, but it connected with me on another level when she proceeded to tell me how caring for her daughter—who was born with a hole in heart—prepared her for what she would encounter as a tech CEO. Being mentally tough to her means fighting for what you love, persisting like a badass, and building your EQ as well as your IQ. - -#### 3\. Recognize your power - -When I recently asked a 32-year-old tech CEO, who is also a single mom of three young girls, what being a CEO required she said. It really summed up what I’d heard in other words from other women, but it connected with me on another level when she proceeded to tell me how caring for her daughter—who was born with a hole in heart—prepared her for what she would encounter as a tech CEO. Being mentally tough to her means fighting for what you love, persisting like a badass, and building your EQ as well as your IQ. - -Most of the women I’ve interviewed don’t know their own power and so they give it away unknowingly. Too many women have told me that they willingly took on the housekeeping roles on their teams—picking up coffee, donuts, office supplies, and making the team dinner reservations. Usually the only woman on their teams, this put them in a position to be seen as less valuable than their male peers who didn’t readily volunteer for such tasks. All of us, men and women, have innate powers. Identify and know what your powers are and understand how to use them for good. You have so much more power than you realize. Know it, recognize it, use it strategically, and don’t give it away. It’s yours. - -#### 4\. Know your strength - -Not sure whether you can confront your boss about why you haven’t been promoted? You can. You don’t know your strength until you exercise it. Then, you’re unstoppable. Test your strength by pushing your fear aside and see what happens. - -#### 5\. Celebrate vulnerability - -Every single successful women I've interviewed isn't afraid to be vulnerable. She finds her strength in acknowledging where she is vulnerable and she looks to connect with others in that same place. Exposing, sharing, and celebrating each other’s vulnerabilities allows us to tap into something far greater than simply asserting strength; it actually builds strength—mental and emotional muscle. One women with whom we’ve talked shared how starting her own tech company made her feel like she was letting her husband down. She shared with us the details of that conversation with her husband. Honest conversations that share our doubts and our aspirations is what makes women uniquely suited to lead in many cases. Allow yourself to be seen and heard. It’s where we grow and learn. - -#### 6\. Build community - -If it doesn't exist, build it. - -Building community seems like a no-brainer in the world of open source, right? But take a moment to think about how many minorities in tech, especially those outside the collaborative open source community, don’t always feel like part of the community. Many women in tech, for example, have told me they feel alone. Reach out and ask questions or answer questions in community forums, at meetups, and in IRC and Slack. When you see a woman alone at an event, consider engaging with her and inviting her into a conversation. Start a meetup group in your company or community for women in tech. I've been so pleased with the number of companies that host these groups. If it doesn't exists, build it. - -#### 7\. Celebrate victories - -Building community seems like a no-brainer in the world of open source, right? But take a moment to think about how many minorities in tech, especially those outside the collaborative open source community, don’t always feel like part of the community. Many women in tech, for example, have told me they feel alone. Reach out and ask questions or answer questions in community forums, at meetups, and in IRC and Slack. When you see a woman alone at an event, consider engaging with her and inviting her into a conversation. Start a meetup group in your company or community for women in tech. I've been so pleased with the number of companies that host these groups. If it doesn't exists, build it. - -One of my favorite Facebook groups is [TechLadies][9] because of its recurring hashtag #YEPIDIDTHAT. It allows women to share their victories in a supportive community. No matter how big or small, don't let a victory go unrecognized. When you recognize your wins, you own them. They become a part of you and you build on top of each one. - -#### 8\. Be curious - -Being curious in the tech community often means asking questions: How does that work? What language is that written in? How can I make this do that? When I've managed teams over the years, my best employees have always been those who ask a lot of questions, those who are genuinely curious about things. But in this context, I mean be curious when your gut tells you something doesn't seem right. _The energy in the meeting was off. Did he/she just say what I think he said?_ Ask questions. Investigate. Communicate openly and clearly. It's the only way change happens. - -#### 9\. Harness courage - -One women told me a story about a meeting in which the women in the room kept being dismissed and talked over. During the debrief roundtable portion of the meeting, she called it out and asked if others noticed it, too. Being a 20-year tech veteran, she'd witnessed and experienced this many times but she had never summoned the courage to speak up about it. She told me she was incredibly nervous and was texting other women in the room to see if they agreed it should be addressed. She didn't want to be a "troublemaker." But this kind of courage results in an increased understanding by everyone in that room and can translate into other meetings, companies, and across the industry. - -#### 10\. Share your story - -When people connect to compelling story, they begin to change behaviors. - -Share your experience with a friend, a group, a community, or an industry. Be empowered by the experience of sharing your experience. Stories change culture. When people connect to compelling story, they begin to change behaviors. When people act, companies and industries begin to transform. - -Share your experience with a friend, a group, a community, or an industry. Be empowered by the experience of sharing your experience. Stories change culture. When people connect to compelling story, they begin to change behaviors. When people act, companies and industries begin to transform. - -If you would like to support [The Chasing Grace Project][8], email Jennifer Cloer to learn more about how to get involved: [jennifer@wickedflicksproductions.com][10] - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/6/being-woman-tech-10-principles-resilience - -作者:[Jennifer Cloer][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/jennifer-cloer -[1]:http://www.newsweek.com/2015/02/06/what-silicon-valley-thinks-women-302821.html%E2%80%9D -[2]:https://opensource.com/article/17/6/male-allies-tech-industry-needs-you%E2%80%9D -[3]:https://twitter.com/GirlsWhoCode%E2%80%9D -[4]:http://opensource.com/tags/red-hat-summit%E2%80%9D -[5]:https://www.ncwit.org/sites/default/files/resources/womenintech_facts_fullreport_05132016.pdf%E2%80%9D -[6]:Dhttp://www.latimes.com/business/la-fi-women-tech-20150222-story.html%E2%80%9D -[7]:http://www.ey.com/us/en/newsroom/news-releases/ey-news-new-research-reveals-the-differences-between-boys-and-girls-career-and-college-plans-and-an-ongoing-need-to-engage-girls-in-stem%E2%80%9D -[8]:https://www.chasinggracefilm.com/ -[9]:https://www.facebook.com/therealTechLadies/%E2%80%9D -[10]:mailto:jennifer@wickedflicksproductions.com +10 principles of resilience for women in tech +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/diversity-women-meeting-team.png?itok=BdDKxT1w) + +Being a woman in tech is pretty damn cool. For every headline about [what Silicon Valley thinks of women][1], there are tens of thousands of women building, innovating, and managing technology teams around the world. Women are helping build the future despite the hurdles they face, and the community of women and allies growing to support each other is stronger than ever. From [BetterAllies][2] to organizations like [Girls Who Code][3] and communities like the one I met recently at [Red Hat Summit][4], there are more efforts than ever before to create an inclusive community for women in tech. + +But the tech industry has not always been this welcoming, nor is the experience for women always aligned with the aspiration. And so we're feeling the pain. Women in technology roles have dropped from its peak in 1991 at 36% to 25% today, [according to a report by NCWIT][5]. [Harvard Business Review estimates][6] that more than half of the women in tech will eventually leave due to hostile work conditions. Meanwhile, Ernst & Young recently shared [a study][7] and found that merely 11% of high school girls are planning to pursue STEM careers. + +We have much work to do, lest we build a future that is less inclusive than the one we live in today. We need everyone at the table, in the lab, at the conference and in the boardroom. + +I've been interviewing both women and men for more than a year now about their experiences in tech, all as part of [The Chasing Grace Project][8], a documentary series about women in tech. The purpose of the series is to help recruit and retain female talent for the tech industry and to give women a platform to be seen, heard, and acknowledged for their experiences. We believe that compelling story can begin to transform culture. + +### What Chasing Grace taught me + +What I've learned is that no matter the dismal numbers, women want to keep building and they collectively possess a resilience unmatched by anything I've ever seen. And this is inspiring me. I've found a power, a strength, and a beauty in every story I've heard that is the result of resilience. I recently shared with the attendees at the Red Hat Summit Women’s Leadership Luncheon the top 10 principles of resilience I've heard from throughout my interviews so far. I hope that by sharing them here the ideas and concepts can support and inspire you, too. + +#### 1\. Practice optimism + +When taken too far, optimism can give you blind spots. But a healthy dose of optimism allows you to see the best in people and situations and that positive energy comes back to you 100-fold. I haven’t met a woman yet as part of this project who isn’t an optimist. + +#### 2\. Build mental toughness + +I haven’t met a woman yet as part of this project who isn’t an optimist. + +When I recently asked a 32-year-old tech CEO, who is also a single mom of three young girls, what being a CEO required she said _mental toughness_. It really summed up what I’d heard in other words from other women, but it connected with me on another level when she proceeded to tell me how caring for her daughter—who was born with a hole in heart—prepared her for what she would encounter as a tech CEO. Being mentally tough to her means fighting for what you love, persisting like a badass, and building your EQ as well as your IQ. + +#### 3\. Recognize your power + +When I recently asked a 32-year-old tech CEO, who is also a single mom of three young girls, what being a CEO required she said. It really summed up what I’d heard in other words from other women, but it connected with me on another level when she proceeded to tell me how caring for her daughter—who was born with a hole in heart—prepared her for what she would encounter as a tech CEO. Being mentally tough to her means fighting for what you love, persisting like a badass, and building your EQ as well as your IQ. + +Most of the women I’ve interviewed don’t know their own power and so they give it away unknowingly. Too many women have told me that they willingly took on the housekeeping roles on their teams—picking up coffee, donuts, office supplies, and making the team dinner reservations. Usually the only woman on their teams, this put them in a position to be seen as less valuable than their male peers who didn’t readily volunteer for such tasks. All of us, men and women, have innate powers. Identify and know what your powers are and understand how to use them for good. You have so much more power than you realize. Know it, recognize it, use it strategically, and don’t give it away. It’s yours. + +#### 4\. Know your strength + +Not sure whether you can confront your boss about why you haven’t been promoted? You can. You don’t know your strength until you exercise it. Then, you’re unstoppable. Test your strength by pushing your fear aside and see what happens. + +#### 5\. Celebrate vulnerability + +Every single successful women I've interviewed isn't afraid to be vulnerable. She finds her strength in acknowledging where she is vulnerable and she looks to connect with others in that same place. Exposing, sharing, and celebrating each other’s vulnerabilities allows us to tap into something far greater than simply asserting strength; it actually builds strength—mental and emotional muscle. One women with whom we’ve talked shared how starting her own tech company made her feel like she was letting her husband down. She shared with us the details of that conversation with her husband. Honest conversations that share our doubts and our aspirations is what makes women uniquely suited to lead in many cases. Allow yourself to be seen and heard. It’s where we grow and learn. + +#### 6\. Build community + +If it doesn't exist, build it. + +Building community seems like a no-brainer in the world of open source, right? But take a moment to think about how many minorities in tech, especially those outside the collaborative open source community, don’t always feel like part of the community. Many women in tech, for example, have told me they feel alone. Reach out and ask questions or answer questions in community forums, at meetups, and in IRC and Slack. When you see a woman alone at an event, consider engaging with her and inviting her into a conversation. Start a meetup group in your company or community for women in tech. I've been so pleased with the number of companies that host these groups. If it doesn't exists, build it. + +#### 7\. Celebrate victories + +Building community seems like a no-brainer in the world of open source, right? But take a moment to think about how many minorities in tech, especially those outside the collaborative open source community, don’t always feel like part of the community. Many women in tech, for example, have told me they feel alone. Reach out and ask questions or answer questions in community forums, at meetups, and in IRC and Slack. When you see a woman alone at an event, consider engaging with her and inviting her into a conversation. Start a meetup group in your company or community for women in tech. I've been so pleased with the number of companies that host these groups. If it doesn't exists, build it. + +One of my favorite Facebook groups is [TechLadies][9] because of its recurring hashtag #YEPIDIDTHAT. It allows women to share their victories in a supportive community. No matter how big or small, don't let a victory go unrecognized. When you recognize your wins, you own them. They become a part of you and you build on top of each one. + +#### 8\. Be curious + +Being curious in the tech community often means asking questions: How does that work? What language is that written in? How can I make this do that? When I've managed teams over the years, my best employees have always been those who ask a lot of questions, those who are genuinely curious about things. But in this context, I mean be curious when your gut tells you something doesn't seem right. _The energy in the meeting was off. Did he/she just say what I think he said?_ Ask questions. Investigate. Communicate openly and clearly. It's the only way change happens. + +#### 9\. Harness courage + +One women told me a story about a meeting in which the women in the room kept being dismissed and talked over. During the debrief roundtable portion of the meeting, she called it out and asked if others noticed it, too. Being a 20-year tech veteran, she'd witnessed and experienced this many times but she had never summoned the courage to speak up about it. She told me she was incredibly nervous and was texting other women in the room to see if they agreed it should be addressed. She didn't want to be a "troublemaker." But this kind of courage results in an increased understanding by everyone in that room and can translate into other meetings, companies, and across the industry. + +#### 10\. Share your story + +When people connect to compelling story, they begin to change behaviors. + +Share your experience with a friend, a group, a community, or an industry. Be empowered by the experience of sharing your experience. Stories change culture. When people connect to compelling story, they begin to change behaviors. When people act, companies and industries begin to transform. + +Share your experience with a friend, a group, a community, or an industry. Be empowered by the experience of sharing your experience. Stories change culture. When people connect to compelling story, they begin to change behaviors. When people act, companies and industries begin to transform. + +If you would like to support [The Chasing Grace Project][8], email Jennifer Cloer to learn more about how to get involved: [jennifer@wickedflicksproductions.com][10] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/6/being-woman-tech-10-principles-resilience + +作者:[Jennifer Cloer][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/jennifer-cloer +[1]:http://www.newsweek.com/2015/02/06/what-silicon-valley-thinks-women-302821.html%E2%80%9D +[2]:https://opensource.com/article/17/6/male-allies-tech-industry-needs-you%E2%80%9D +[3]:https://twitter.com/GirlsWhoCode%E2%80%9D +[4]:http://opensource.com/tags/red-hat-summit%E2%80%9D +[5]:https://www.ncwit.org/sites/default/files/resources/womenintech_facts_fullreport_05132016.pdf%E2%80%9D +[6]:Dhttp://www.latimes.com/business/la-fi-women-tech-20150222-story.html%E2%80%9D +[7]:http://www.ey.com/us/en/newsroom/news-releases/ey-news-new-research-reveals-the-differences-between-boys-and-girls-career-and-college-plans-and-an-ongoing-need-to-engage-girls-in-stem%E2%80%9D +[8]:https://www.chasinggracefilm.com/ +[9]:https://www.facebook.com/therealTechLadies/%E2%80%9D +[10]:mailto:jennifer@wickedflicksproductions.com diff --git a/sources/talk/20180629 Reflecting on the GPLv3 license for its 11th anniversary.md b/sources/talk/20180629 Reflecting on the GPLv3 license for its 11th anniversary.md deleted file mode 100644 index af352aefe1..0000000000 --- a/sources/talk/20180629 Reflecting on the GPLv3 license for its 11th anniversary.md +++ /dev/null @@ -1,65 +0,0 @@ -Reflecting on the GPLv3 license for its 11th anniversary -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LAW_vaguepatent_520x292.png?itok=_zuxUwyt) - -Last year, I missed the opportunity to write about the 10th anniversary of [GPLv3][1], the third version of the GNU General Public License. GPLv3 was officially released by the Free Software Foundation (FSF) on June 29, 2007—better known in technology history as the date Apple launched the iPhone. Now, one year later, I feel some retrospection on GPLv3 is due. For me, much of what is interesting about GPLv3 goes back somewhat further than 11 years, to the public drafting process in which I was an active participant. - -In 2005, following nearly a decade of enthusiastic self-immersion in free software, yet having had little open source legal experience to speak of, I was hired by Eben Moglen to join the Software Freedom Law Center as counsel. SFLC was then outside counsel to the FSF, and my role was conceived as focusing on the incipient public phase of the GPLv3 drafting process. This opportunity rescued me from a previous career turn that I had found rather dissatisfying. Free and open source software (FOSS) legal matters would come to be my new specialty, one that I found fascinating, gratifying, and intellectually rewarding. My work at SFLC, and particularly the trial by fire that was my work on GPLv3, served as my on-the-job training. - -GPLv3 must be understood as the product of an earlier era of FOSS, the contours of which may be difficult for some to imagine today. By the beginning of the public drafting process in 2006, Linux and open source were no longer practically synonymous, as they might have been for casual observers several years earlier, but the connection was much closer than it is now. - -Reflecting the profound impact that Linux was already having on the technology industry, everyone assumed GPL version 2 was the dominant open source licensing model. We were seeing the final shakeout of a Cambrian explosion of open source (and pseudo-open source) business models. A frothy business-fueled hype surrounded open source (for me most memorably typified by the Open Source Business Conference) that bears little resemblance to the present-day embrace of open source development by the software engineering profession. Microsoft, with its expanding patent portfolio and its competitive opposition to Linux, was commonly seen in the FOSS community as an existential threat, and the [SCO litigation][2] had created a cloud of legal risk around Linux and the GPL that had not quite dissipated. - -That environment necessarily made the drafting of GPLv3 a high-stakes affair, unprecedented in free software history. Lawyers at major technology companies and top law firms scrambled for influence over the license, convinced that GPLv3 was bound to take over and thoroughly reshape open source and all its massive associated business investment. - -A similar mindset existed within the technical community; it can be detected in the fears expressed in the final paragraph of the Linux kernel developers' momentous September 2006 [denunciation][3] of GPLv3. Those of us close to the FSF knew a little better, but I think we assumed the new license would be either an overwhelming success or a resounding failure—where "success" meant something approximating an upgrade of the existing GPLv2 project ecosystem to GPLv3, though perhaps without the kernel. The actual outcome was something in the middle. - -I have no confidence in attempts to measure open source license adoption, which have in recent years typically been used to demonstrate a loss of competitive advantage for copyleft licensing. My own experience, which is admittedly distorted by proximity to Linux and my work at Red Hat, suggests that GPLv3 has enjoyed moderate popularity as a license choice for projects launched since 2007, though most GPLv2 projects that existed before 2007, along with their post-2007 offshoots, remained on the old license. (GPLv3's sibling licenses LGPLv3 and AGPLv3 never gained comparable popularity.) Most of the existing GPLv2 projects (with a few notable exceptions like the kernel and Busybox) were licensed as "GPLv2 or any later version." The technical community decided early on that "GPLv2 or later" was a politically neutral license choice that embraced both GPLv2 and GPLv3; this goes some way to explain why adoption of GPLv3 was somewhat gradual and limited, especially within the Linux community. - -During the GPLv3 drafting process, some expressed concerns about a "balkanized" Linux ecosystem, whether because of the overhead of users having to understand two different, strong copyleft licenses or because of GPLv2/GPLv3 incompatibility. These fears turned out to be entirely unfounded. Within mainstream server and workstation Linux stacks, the two licenses have peacefully coexisted for a decade now. This is partly because such stacks are made up of separate units of strong copyleft scope (see my discussion of [related issues in the container setting][4]). As for incompatibility inside units of strong copyleft scope, here, too, the prevalence of "GPLv2 or later" was seen by the technical community as neatly resolving the theoretical problem, despite the fact that nominal license upgrading of GPLv2-or-later to GPLv3 hardly ever occurred. - -I have alluded to the handwringing that some of us FOSS license geeks have brought to the topic of supposed copyleft decline. GPLv3 has taken its share of abuse from critics as far back as the beginning of the public drafting process, and some, predictably, have drawn a link between GPLv3 in particular and GPL or copyleft disfavor in general. - -I have viewed it somewhat differently: Largely because of its complexity and baroqueness, GPLv3 was a lost opportunity to create a strong copyleft license that would appeal very broadly to modern individual software authors and corporate licensors. I believe individual developers today tend to prefer short, simple, easy to understand, minimalist licenses, the most obvious example of which is the [MIT License][5]. - -Some corporate decisionmakers around open source license selection may naturally share that view, while others may associate some parts of GPLv3, such as the patent provisions or the anti-lockdown requirements, as too risky or incompatible with their business models. The great irony is that the characteristics of GPLv3 that fail to attract these groups are there in part because of conscious attempts to make the license appeal to these same sorts of interests. - -How did GPLv3 come to be so baroque? As I have said, GPLv3 was the product of an earlier time, in which FOSS licenses were viewed as the primary instruments of project governance. (Today, we tend to associate governance with other kinds of legal or quasi-legal tools, such as structuring of nonprofit organizations, rules around project decision making, codes of conduct, and contributor agreements.) - -GPLv3, in its drafting, was the high point of an optimistic view of FOSS licenses as ambitious means of private regulation. This was already true of GPLv2, but GPLv3 took things further by addressing in detail a number of new policy problems—software patents, anti-circumvention laws, device lockdown. That was bound to make the license longer and more complex than GPLv2, as the FSF and SFLC noted apologetically in the first GPLv3 [rationale document][6]. - -But a number of other factors at play in the drafting of GPLv3 unintentionally caused the complexity of the license to grow. Lawyers representing vendors' and commercial users' interests provided useful suggestions for improvements from a legal and commercial perspective, but these often took the form of making simply worded provisions more verbose, arguably without net increases in clarity. Responses to feedback from the technical community, typically identifying loopholes in license provisions, had a similar effect. - -The GPLv3 drafters also famously got entangled in a short-term political crisis—the controversial [Microsoft/Novell deal][7] of 2006—resulting in the permanent addition of new and unusual conditions in the patent section of the license, which arguably served little purpose after 2007 other than to make license compliance harder for conscientious patent-holding vendors. Of course, some of the complexity in GPLv3 was simply the product of well-intended attempts to make compliance easier, especially for community project developers, or to codify FSF interpretive practice. Finally, one can take issue with the style of language used in GPLv3, much of which had a quality of playful parody or mockery of conventional software license legalese; a simpler, straightforward form of phrasing would in many cases have been an improvement. - -The complexity of GPLv3 and the movement towards preferring brevity and simplicity in license drafting and unambitious license policy objectives meant that the substantive text of GPLv3 would have little direct influence on later FOSS legal drafting. But, as I noted with surprise and [delight][8] back in 2012, MPL 2.0 adapted two parts of GPLv3: the 30-day cure and 60-day repose language from the GPLv3 termination provision, and the assurance that downstream upgrading to a later license version adds no new obligations on upstream licensors. - -The GPLv3 cure language has come to have a major impact, particularly over the past year. Following the Software Freedom Conservancy's promulgation, with the FSF's support, of the [Principles of Community-Oriented GPL Enforcement][9], which calls for extending GPLv3 cure opportunities to GPLv2 violations, the Linux Foundation Technical Advisory Board published a [statement][10], endorsed by over a hundred Linux kernel developers, which incorporates verbatim the cure language of GPLv3. This in turn was followed by a Red Hat-led series of [corporate commitments][11] to extend the GPLv3 cure provisions to GPLv2 and LGPLv2.x noncompliance, a campaign to get individual open source developers to extend the same commitment, and an announcement by Red Hat that henceforth GPLv2 and LGPLv2.x projects it leads will use the commitment language directly in project repositories. I discussed these developments in a recent [blog post][12]. - -One lasting contribution of GPLv3 concerns changed expectations for how revisions of widely-used FOSS licenses are done. It is no longer acceptable for such licenses to be revised entirely in private, without opportunity for comment from the community and without efforts to consult key stakeholders. The drafting of MPL 2.0 and, more recently, EPL 2.0 reflects this new norm. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/6/gplv3-anniversary - -作者:[Richard Fontana][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/fontana -[1]:https://www.gnu.org/licenses/gpl-3.0.en.html -[2]:https://en.wikipedia.org/wiki/SCO%E2%80%93Linux_disputes -[3]:https://lwn.net/Articles/200422/ -[4]:https://opensource.com/article/18/1/containers-gpl-and-copyleft -[5]:https://opensource.org/licenses/MIT -[6]:http://gplv3.fsf.org/gpl-rationale-2006-01-16.html -[7]:https://en.wikipedia.org/wiki/Novell#Agreement_with_Microsoft -[8]:https://opensource.com/law/12/1/the-new-mpl -[9]:https://sfconservancy.org/copyleft-compliance/principles.html -[10]:https://www.kernel.org/doc/html/v4.16/process/kernel-enforcement-statement.html -[11]:https://www.redhat.com/en/about/press-releases/technology-industry-leaders-join-forces-increase-predictability-open-source-licensing -[12]:https://www.redhat.com/en/blog/gpl-cooperation-commitment-and-red-hat-projects?source=author&term=26851 diff --git a/sources/talk/20180705 New Training Options Address Demand for Blockchain Skills.md b/sources/talk/20180705 New Training Options Address Demand for Blockchain Skills.md deleted file mode 100644 index dedbf748d6..0000000000 --- a/sources/talk/20180705 New Training Options Address Demand for Blockchain Skills.md +++ /dev/null @@ -1,45 +0,0 @@ -New Training Options Address Demand for Blockchain Skills -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/blockchain-301.png?itok=1EA-Ob6F) - -Blockchain technology is transforming industries and bringing new levels of trust to contracts, payment processing, asset protection, and supply chain management. Blockchain-related jobs are the second-fastest growing in today’s labor market, [according to TechCrunch][1]. But, as in the rapidly expanding field of artificial intelligence, there is a pronounced blockchain skills gap and a need for expert training resources. - -### Blockchain for Business - -A new training option was recently announced from The Linux Foundation. Enrollment is now open for a free training course called[Blockchain: Understanding Its Uses and Implications][2], as well as a [Blockchain for Business][2] professional certificate program. Delivered through the edX training platform, the new course and program provide a way to learn about the impact of blockchain technologies and a means to demonstrate that knowledge. Certification, in particular, can make a difference for anyone looking to work in the blockchain arena. - -“In the span of only a year or two, blockchain has gone from something seen only as related to cryptocurrencies to a necessity for businesses across a wide variety of industries,” [said][3] Linux Foundation General Manager, Training & Certification Clyde Seepersad. “Providing a free introductory course designed not only for technical staff but business professionals will help improve understanding of this important technology, while offering a certificate program through edX will enable professionals from all over the world to clearly demonstrate their expertise.” - -TechCrunch [also reports][4] that venture capital is rapidly flowing toward blockchain-focused startups. And, this new program is designed for business professionals who need to understand the potential – or threat – of blockchain to their company and industry. - -“Professional Certificate programs on edX deliver career-relevant education in a flexible, affordable way, by focusing on the critical skills industry leaders and successful professionals are seeking today,” said Anant Agarwal, edX CEO and MIT Professor. - -### Hyperledger Fabric - -The Linux Foundation is steward to many valuable blockchain resources and includes some notable community members. In fact, a recent New York Times article — “[The People Leading the Blockchain Revolution][5]” — named Brian Behlendorf, Executive Director of The Linux Foundation’s [Hyperledger Project][6], one of the [top influential voices][7] in the blockchain world. - -Hyperledger offers proven paths for gaining credibility and skills in the blockchain space. For example, the project offers a free course titled Introduction to Hyperledger Fabric for Developers. Fabric has emerged as a key open source toolset in the blockchain world. Through the Hyperledger project, you can also take the B9-lab Certified Hyperledger Fabric Developer course. More information on both courses is available [here][8]. - -“As you can imagine, someone needs to do the actual coding when companies move to experiment and replace their legacy systems with blockchain implementations,” states the Hyperledger website. “With training, you could gain serious first-mover advantage.” - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/2018/7/new-training-options-address-demand-blockchain-skills - -作者:[SAM DEAN][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/sam-dean -[1]:https://techcrunch.com/2018/02/14/blockchain-engineers-are-in-demand/ -[2]:https://www.edx.org/course/understanding-blockchain-and-its-implications -[3]:https://www.linuxfoundation.org/press-release/as-demand-skyrockets-for-blockchain-expertise-the-linux-foundation-and-edx-offer-new-introductory-blockchain-course-and-blockchain-for-business-professional-certificate-program/ -[4]:https://techcrunch.com/2018/05/20/with-at-least-1-3-billion-invested-globally-in-2018-vc-funding-for-blockchain-blows-past-2017-totals/ -[5]:https://www.nytimes.com/2018/06/27/business/dealbook/blockchain-stars.html -[6]:https://www.hyperledger.org/ -[7]:https://www.linuxfoundation.org/blog/hyperledgers-brian-behlendorf-named-as-top-blockchain-influencer-by-new-york-times/ -[8]:https://www.hyperledger.org/resources/training diff --git a/sources/talk/20180720 A brief history of text-based games and open source.md b/sources/talk/20180720 A brief history of text-based games and open source.md deleted file mode 100644 index 2b8728fb39..0000000000 --- a/sources/talk/20180720 A brief history of text-based games and open source.md +++ /dev/null @@ -1,142 +0,0 @@ -A brief history of text-based games and open source -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/compass_map_explore_adventure.jpg?itok=ecCoVTrZ) - -The [Interactive Fiction Technology Foundation][1] (IFTF) is a non-profit organization dedicated to the preservation and improvement of technologies enabling the digital art form we call interactive fiction. When a Community Moderator for Opensource.com suggested an article about IFTF, the technologies and services it supports, and how it all intersects with open source, I found it a novel angle to the decades-long story I’ve so often told. The history of IF is longer than—but quite enmeshed with—the modern FOSS movement. I hope you’ll enjoy my sharing it here. - -### Definitions and history - -To me, the term interactive fiction includes any video game or digital artwork whose audience interacts with it primarily through text. The term originated in the 1980s when parser-driven text adventure games—epitomized in the United States by [Zork][2], [The Hitchhiker’s Guide to the Galaxy][3], and the rest of [Infocom][4]’s canon—defined home-computer entertainment. Its mainstream commercial viability had guttered by the 1990s, but online hobbyist communities carried on the tradition, releasing both games and game-creation tools. - -After a quarter century, interactive fiction now comprises a broad and sparkling variety of work, from puzzle-laden text adventures to sprawling and introspective hypertexts. Regular online competitions and festivals provide a great place to peruse and play new work: The English-language IF world enjoys annual events including [Spring Thing][5] and [IFComp][6], the latter a centerpiece of modern IF since 1995—which also makes it the longest-lived continually running game showcase event of its kind in any genre. [IFComp’s crop of judged-and-ranked entries from 2017][7] shows the amazing diversity in form, style, and subject matter that text-based games boast today. - -(I specify "English-language" above because IF communities tend to self-segregate by language, perhaps due to the technology's focus on writing. There are also annual IF events in [French][8] and [Italian][9], for example, and I've heard of at least one Chinese IF festival. Happily, these borders are porous; during the four years I managed IFComp, it has welcomed English-translated work from all international communities.) - -![counterfeit monkey game screenshot][11] - -Starting a new game of Emily Short's "Counterfeit Monkey," running on the interpreter Lectrote (both open source software). - -Also due to its focus on text, IF presents some of the most accessible platforms for both play and authorship. Almost anyone who can read digital text—including users of assistive technology such as text-to-speech software—can play most IF works. Likewise, IF creation is open to all writers willing to learn and work with its tools and techniques. - -This brings us to IF’s long relationship with open source, which has helped enable the art form’s availability since its commercial heyday. I'll provide an overview of contemporary open-source IF creation tools, and then discuss the ancient and sometimes curious tradition of IF works that share their source code. - -### The world of open source IF tools - -A number of development platforms, most of which are open source, are available to create traditional parser-driven IF in which the user types commands—for example, `go north,` `get lamp`, `pet the cat`, or `ask Zoe about quantum mechanics`—to interact with the game’s world. The early 1990s saw the emergence of several hacker-friendly parser-game development kits; those still in use today include [TADS][12], [Alan][13], and [Quest][14]—all open, with the latter two bearing FOSS licenses. - -But by far the most prominent of these is [Inform][15], first released by Graham Nelson in 1993 and now maintained by a team Nelson still leads. Inform source is semi-open, in an unusual fashion: Inform 6, the previous major version, [makes its source available through the Artistic License][16]. This has more immediate relevance than may be obvious, since the otherwise proprietary Inform 7 holds Inform 6 at its core, translating its [remarkable natural-language syntax][17] into its predecessor’s more C-like code before letting it compile the work down into machine code. - -![inform 7 IDE screenshot][19] - -The Inform 7 IDE, loaded up with documentation and a sample project. - -Inform games run on a virtual machine, a relic of the Infocom era when that publisher targeted a VM so that it could write a single game that would run on Apple II, Commodore 64, Atari 800, and other flavors of the "[home computer][20]." Fewer popular operating systems exist today, but Inform’s virtual machines—the relatively modern [Glulx][21] or the charmingly antique [Z-machine][22], a reverse-engineered clone of Infocom’s historical VM—let Inform-created work run on any computer with an Inform interpreter. Currently, popular cross-platform interpreters include desktop programs like [Lectrote][23] and [Gargoyle][24] or browser-based ones like [Quixe][25] and [Parchment][26]. All are open source. - -If the pace of Inform’s development has slowed in its maturity, it remains vital through an active and transparent ecosystem—just like any other popular open source project. In Inform’s case, this includes the aforementioned interpreters, [a collection of language extensions][27] (usually written in a mix of Inform 6 and 7), and of course, all the work created with it and shared with the world, sometimes with source included (I’ll return to that topic later in this article). - -IF creation tools invented in the 21st century tend to explore player interactions outside of the traditional parser, generating hypertext-driven work that any modern web browser can load. Chief among these is [Twine][28], originally developed by Chris Klimas in 2009 and under active development by many contributors today as [a GNU-licensed open source project][29]. (In fact, [Twine][30] can trace its OSS lineage back to [TiddlyWiki][31], the project from which Klimas initially derived it.) - -Twine represents a sort of maximally [open and accessible approach][30] to IF development: Beyond its own FOSS nature, it renders its output as self-contained websites, relying not on machine code requiring further specialized interpretation but the open and well-exercised standards of HTML, CSS, and JavaScript. As a creative tool, Twine can match its own exposed complexity to the creator’s skill level. Users with little or no programming knowledge can create simple but playable IF work, while those with more coding and design skills—including those developing these skills by making Twine games—can develop more sophisticated projects. Little wonder that Twine’s visibility and popularity in educational contexts has grown quite a bit in recent years. - -Other noteworthy open source IF development projects include the MIT-licensed [Undum][32] by Ian Millington, and [ChoiceScript][33] by Dan Fabulich and the [Choice of Games][34] team—both of which also target the web browser as the gameplay platform. Looking beyond strict development systems like these, web-based IF gives us a rich and ever-churning ecosystem of open source work, such as furkle’s [collection of Twine-extending tools][35] and Liza Daly’s [Windrift][36], a JavaScript framework purpose-built for her own IF games. - -### Programs, games, and game-programs - -Twine benefits from [a standing IFTF program dedicated to its support][37], allowing the public to help fund its maintenance and development. IFTF also directly supports two long-time public services, IFComp and the IF Archive, both of which depend upon and contribute back into open software and technologies. - -![Harmonia opening screen shot][39] - -The opening of Liza Daly's "Harmonia," created with the Windrift open source IF-creation framework. - -The Perl- and JavaScript-based application that runs the IFComp’s website has been [a shared-source project][40] since 2014, and it reflects [the stew of FOSS licenses used by its IF-specific sub-components][41], including the various code libraries that allow parser-driven competition entries to run in a web browser. [The IF Archive][42]—online since 1992 and [an IFTF project since 2017][43]—is a set of mirrored repositories based entirely on ancient and stable internet standards, with [a little open source Python script][44] to handle indexing. - -### At last, the fun part: Let's talk about open source text games - -The bulk of the archive [comprises games][45], of course—years and years of games, reflecting decades of evolving game-design trends and IF tool development. - -Lots of IF work shares its source code, and the community’s quick-start solution for finding it is simple: [Search the IFDB for the tag "source available"][46]. (The IFDB is yet another long-running IF community service, run privately by TADS creator Mike Roberts.) Users who are comfortable with a more bare-bones interface may also wish to browse [the `/games/source` directory][47] of the IF Archive, which groups content by development platform and written language (there's also a lot of work either too miscellaneous or too ancient to categorize floating at the top). - -A little bit of random sampling of these code-sharing games reveals an interesting dilemma: Unlike the wider world of open source software, the IF community lacks a generally agreed-upon way of licensing all the code that it generates. Unlike a software tool—including all the tools we use to build IF—an interactive fiction game is a work of art in the most literal sense, meaning that an open source license intended for software would fit it no better than it would any other work of prose or poetry. But then again, an IF game is also a piece of software, and it exhibits source-code patterns and techniques that its creator may legitimately wish to share with the world. What is an open source-aware IF creator to do? - -Some games address this by passing their code into the public domain, either through explicit license or—as in the case of [the original 42-year-old Adventure by Crowther and Woods][48]—through community fiat. Some try to split the difference, rolling their own license that allows for free re-use of a game’s exposed business logic but prohibits the creation of work derived specifically from its prose. This is the tack I took when I opened up the source of my own game, [The Warbler’s Nest][49]. Lord knows how well that’d stand up in court, but I didn’t have any better ideas at the time. - -Naturally, you can find work that simply puts everything under a single common license and never mind the naysayers. A prominent example is [Emily Short’s epic Counterfeit Monkey][50], released in its entirety under a Creative Commons 4.0 license. [CC frowns at its application to code][51], but you could argue that [the strangely prose-like nature of Inform 7 source][52] makes it at least a little more compatible with a CC license than a more traditional software project would be. - -### What now, adventurer? - -If you are eager to start exploring the world of interactive fiction, here are a few links to check out: - - -+ As mentioned above, IFDB and the IF Archive both present browsable interfaces to more than 40 years worth of collected interactive fiction work. Much of this is playable in a web browser, but some require additional interpreter programs. IFDB can help you find and install these. - - IFComp’s annual results pages provide another view into the best of this free and archive-available work. - -+ The Interactive Fiction Technology Foundation is a charitable non-profit organization that helps support Twine, IFComp, and the IF Archive, as well as improve the accessibility of IF, explore IF’s use in education, and more. Join its mailing list to receive IFTF’s monthly newsletter, peruse its blog, and browse some thematic merchandise. - -+ John Paul Wohlscheid wrote this article about open-source IF tools earlier this year. It covers some platforms not mentioned here, so if you’re still hungry for more, have a look. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/7/interactive-fiction-tools - -作者:[Jason Mclntosh][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/jmac -[1]:http://iftechfoundation.org/ -[2]:https://en.wikipedia.org/wiki/Zork -[3]:https://en.wikipedia.org/wiki/The_Hitchhiker%27s_Guide_to_the_Galaxy_(video_game) -[4]:https://en.wikipedia.org/wiki/Infocom -[5]:http://www.springthing.net/ -[6]:http://ifcomp.org/ -[7]:https://ifcomp.org/comp/2017 -[8]:http://www.fiction-interactive.fr/ -[9]:http://www.oldgamesitalia.net/content/marmellata-davventura-2018 -[10]:/file/403396 -[11]:https://opensource.com/sites/default/files/uploads/monkey.png (counterfeit monkey game screenshot) -[12]:http://tads.org/ -[13]:https://www.alanif.se/ -[14]:http://textadventures.co.uk/quest/ -[15]:http://inform7.com/ -[16]:https://github.com/DavidKinder/Inform6 -[17]:http://inform7.com/learn/man/RB_4_1.html#e307 -[18]:/file/403386 -[19]:https://opensource.com/sites/default/files/uploads/inform.png (inform 7 IDE screenshot) -[20]:https://www.youtube.com/watch?v=bu55q_3YtOY -[21]:http://ifwiki.org/index.php/Glulx -[22]:http://ifwiki.org/index.php/Z-machine -[23]:https://github.com/erkyrath/lectrote -[24]:https://github.com/garglk/garglk/ -[25]:http://eblong.com/zarf/glulx/quixe/ -[26]:https://github.com/curiousdannii/parchment -[27]:https://github.com/i7/extensions -[28]:http://twinery.org/ -[29]:https://github.com/klembot/twinejs -[30]:/article/18/7/twine-vs-renpy-interactive-fiction -[31]:https://tiddlywiki.com/ -[32]:https://github.com/idmillington/undum -[33]:https://github.com/dfabulich/choicescript -[34]:https://www.choiceofgames.com/ -[35]:https://github.com/furkle -[36]:https://github.com/lizadaly/windrift -[37]:http://iftechfoundation.org/committees/twine/ -[38]:/file/403391 -[39]:https://opensource.com/sites/default/files/uploads/harmonia.png (Harmonia opening screen shot) -[40]:https://github.com/iftechfoundation/ifcomp -[41]:https://github.com/iftechfoundation/ifcomp/blob/master/LICENSE.md -[42]:https://www.ifarchive.org/ -[43]:http://blog.iftechfoundation.org/2017-06-30-iftf-is-adopting-the-if-archive.html -[44]:https://github.com/iftechfoundation/ifarchive-ifmap-py -[45]:https://www.ifarchive.org/indexes/if-archiveXgames -[46]:http://ifdb.tads.org/search?sortby=ratu&searchfor=%22source+available%22 -[47]:https://www.ifarchive.org/indexes/if-archiveXgamesXsource.html -[48]:http://ifdb.tads.org/viewgame?id=fft6pu91j85y4acv -[49]:https://github.com/jmacdotorg/warblers-nest/ -[50]:https://github.com/i7/counterfeit-monkey -[51]:https://creativecommons.org/faq/#can-i-apply-a-creative-commons-license-to-software -[52]:https://github.com/i7/counterfeit-monkey/blob/master/Counterfeit%20Monkey.materials/Extensions/Counterfeit%20Monkey/Liquids.i7x diff --git a/sources/talk/20180802 How blockchain will influence open source.md b/sources/talk/20180802 How blockchain will influence open source.md deleted file mode 100644 index 707f4fe033..0000000000 --- a/sources/talk/20180802 How blockchain will influence open source.md +++ /dev/null @@ -1,185 +0,0 @@ -How blockchain will influence open source -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/block-quilt-chain.png?itok=mECoDbrc) - -What [Satoshi Nakamoto][1] started as Bitcoin a decade ago has found a lot of followers and turned into a movement for decentralization. For some, blockchain technology is a religion that will have the same impact on humanity as the Internet has had. For others, it is hype and technology suitable only for Ponzi schemes. While blockchain is still evolving and trying to find its place, one thing is for sure: It is a disruptive technology that will fundamentally transform certain industries. And I'm betting open source will be one of them. - -### The open source model - -Open source is a collaborative software development and distribution model that allows people with common interests to gather and produce something that no individual can create on their own. It allows the creation of value that is bigger than the sum of its parts. Open source is enabled by distributed collaboration tools (IRC, email, git, wiki, issue trackers, etc.), distributed and protected by an open source licensing model and often governed by software foundations such as the [Apache Software Foundation][2] (ASF), [Cloud Native Computing Foundation][3] (CNCF), etc. - -One interesting aspect of the open source model is the lack of financial incentives in its core. Some people believe open source work should remain detached from money and remain a free and voluntary activity driven only by intrinsic motivators (such as "common purpose" and "for the greater good”). Others believe open source work should be rewarded directly or indirectly through extrinsic motivators (such as financial incentive). While the idea of open source projects prospering only through voluntary contributions is romantic, in reality, the majority of open source contributions are done through paid development. Yes, we have a lot of voluntary contributions, but these are on a temporary basis from contributors who come and go, or for exceptionally popular projects while they are at their peak. Creating and sustaining open source projects that are useful for enterprises requires developing, documenting, testing, and bug-fixing for prolonged periods, even when the software is no longer shiny and exciting. It is a boring activity that is best motivated through financial incentives. - -### Commercial open source - -Software foundations such as ASF survive on donations and other income streams such as sponsorships, conference fees, etc. But those funds are primarily used to run the foundations, to provide legal protection for the projects, and to ensure there are enough servers to run builds, issue trackers, mailing lists, etc. - -Similarly, CNCF has member fees and other income streams, which are used to run the foundation and provide resources for the projects. These days, most software is not built on laptops; it is run and tested on hundreds of machines on the cloud, and that requires money. Creating marketing campaigns, brand designs, distributing stickers, etc. takes money, and some foundations can assist with that as well. At its core, foundations implement the right processes to interact with users, developers, and control mechanisms and ensure distribution of available financial resources to open source projects for the common good. - -If users of open source projects can donate money and the foundations can distribute it in a fair way, what is missing? - -What is missing is a direct, transparent, trusted, decentralized, automated bidirectional link for transfer of value between the open source producers and the open source consumer. Currently, the link is either unidirectional or indirect: - - * **Unidirectional** : A developer (think of a "developer" as any role that is involved in the production, maintenance, and distribution of software) can use their brain juice and devote time to do a contribution and share that value with all open source users. But there is no reverse link. - - * **Indirect** : If there is a bug that affects a specific user/company, the options are: - - * To have in-house developers to fix the bug and do a pull request. That is ideal, but it not always possible to hire in-house developers who are knowledgeable about hundreds of open source projects used daily. - - * To hire a freelancer specializing in that specific open source project and pay for the services. Ideally, the freelancer is also a committer for the open source project and can directly change the project code quickly. Otherwise, the fix might not ever make it to the project. - - * To approach a company providing services around the open source project. Such companies typically employ open source committers to influence and gain credibility in the community and offer products, expertise, and professional services. - - - - -The third option has been a successful [model][4] for sustaining many open source projects. Whether they provide services (training, consulting, workshops), support, packaging, open core, or SaaS, there are companies that employ hundreds of staff members who work on open source full time. There is a long [list of companies][5] that have managed to build a successful open source business model over the years, and that list is growing steadily. - -The companies that back open source projects play an important role in the ecosystem: They are the catalyst between the open source projects and the users. The ones that add real value do more than just package software nicely; they can identify user needs and technology trends, and they create a full stack and even an ecosystem of open source projects to address these needs. They can take a boring project and support it for years. If there is a missing piece in the stack, they can start an open source project from scratch and build a community around it. They can acquire a closed source software company and open source the projects (here I got a little carried away, but yes, I'm talking about my employer, [Red Hat][6]). - -To summarize, with the commercial open source model, projects are officially or unofficially managed and controlled by a very few individuals or companies that monetize them and give back to the ecosystem by ensuring the project is successful. It is a win-win-win for open source developers, managing companies, and end users. The alternative is inactive projects and expensive closed source software. - -### Self-sustaining, decentralized open source - -For a project to become part of a reputable foundation, it must conform to certain criteria. For example, ASF and CNCF require incubation and graduation processes, respectively, where apart from all the technical and formal requirements, a project must have a healthy number of active committer and users. And that is the essence of forming a sustainable open source project. Having source code on GitHub is not the same thing as having an active open source project. The latter requires committers who write the code and users who use the code, with both groups enforcing each other continuously by exchanging value and forming an ecosystem where everybody benefits. Some project ecosystems might be tiny and short-lived, and some may consist of multiple projects and competing service providers, with very complex interactions lasting for many years. But as long as there is an exchange of value and everybody benefits from it, the project is developed, maintained, and sustained. - -If you look at ASF [Attic][7], you will find projects that have reached their end of life. When a project is no longer technologically fit for its purpose, it is usually its natural end. Similarly, in the ASF [Incubator][8], you will find tons of projects that never graduated but were instead retired. Typically, these projects were not able to build a large enough community because they are too specialized or there are better alternatives available. - -But there are also cases where projects with high potential and superior technology cannot sustain themselves because they cannot form or maintain a functioning ecosystem for the exchange of value. The open source model and the foundations do not provide a framework and mechanisms for developers to get paid for their work or for users to get their requests heard. There isn’t a common value commitment framework for either party. As a result, some projects can sustain themselves only in the context of commercial open source, where a company acts as an intermediary and value adder between developers and users. That adds another constraint and requires a service provider company to sustain some open source projects. Ideally, users should be able to express their interest in a project and developers should be able to show their commitment to the project in a transparent and measurable way, which forms a community with common interest and intent for the exchange of value. - -Imagine there is a model with mechanisms and tools that enable direct interaction between open source users and developers. This includes not only code contributions through pull requests, questions over the mailing lists, GitHub stars, and stickers on laptops, but also other ways that allow users to influence projects' destinies in a richer, more self-controlled and transparent manner. - -This model could include incentives for actions such as: - - * Funding open source projects directly rather than through software foundations - - * Influencing the direction of projects through voting (by token holders) - - * Feature requests driven by user needs - - * On-time pull request merges - - * Bounties for bug hunts - - * Better test coverage incentives - - * Up-to-date documentation rewards - - * Long-term support guarantees - - * Timely security fixes - - * Expert assistance, support, and services - - * Budget for evangelism and promotion of the projects - - * Budget for regular boring activities - - * Fast email and chat assistance - - * Full visibility of the overall project findings, etc. - - - - -If you haven't guessed, I'm talking about using blockchain and [smart contracts][9] to allow such interactions between users and developers—smart contracts that will give power to the hand of token holders to influence projects. - -![blockchain_in_open_source_ecosystem.png][11] - -The usage of blockchain in the open source ecosystem - -Existing channels in the open source ecosystem provide ways for users to influence projects through financial commitments to service providers or other limited means through the foundations. But the addition of blockchain-based technology to the open source ecosystem could open new channels for interaction between users and developers. I'm not saying this will replace the commercial open source model; most companies working with open source do many things that cannot be replaced by smart contracts. But smart contracts can spark a new way of bootstrapping new open source projects, giving a second life to commodity projects that are a burden to maintain. They can motivate developers to apply boring pull requests, write documentation, get tests to pass, etc., providing a direct value exchange channel between users and open source developers. Blockchain can add new channels to help open source projects grow and become self-sustaining in the long term, even when company backing is not feasible. It can create a new complementary model for self-sustaining open source projects—a win-win. - -### Tokenizing open source - -There are already a number of initiatives aiming to tokenize open source. Some focus only on an open source model, and some are more generic but apply to open source development as well: - - * [Gitcoin][12] \- grow open source, one of the most promising ones in this area. - - * [Oscoin][13] \- cryptocurrency for open source - - * [Open collective][14] \- a platform for supporting open source projects. - - * [FundYourselfNow][15] \- Kickstarter and ICOs for projects. - - * [Kauri][16] \- support for open source project documentation. - - * [Liberapay][17] \- a recurrent donations platform. - - * [FundRequest][18] \- a decentralized marketplace for open source collaboration. - - * [CanYa][19] \- recently acquired [Bountysource][20], now the world’s largest open source P2P bounty platform. - - * [OpenGift][21] \- a new model for open source monetization. - - * [Hacken][22] \- a white hat token for hackers. - - * [Coinlancer][23] \- a decentralized job market. - - * [CodeFund][24] \- an open source ad platform. - - * [IssueHunt][25] \- a funding platform for open source maintainers and contributors. - - * [District0x 1Hive][26] \- a crowdfunding and curation platform. - - * [District0x Fixit][27] \- github bug bounties. - - - - -This list is varied and growing rapidly. Some of these projects will disappear, others will pivot, but a few will emerge as the [SourceForge][28], the ASF, the GitHub of the future. That doesn't necessarily mean they'll replace these platforms, but they'll complement them with token models and create a richer open source ecosystem. Every project can pick its distribution model (license), governing model (foundation), and incentive model (token). In all cases, this will pump fresh blood to the open source world. - -### The future is open and decentralized - - * Software is eating the world. - - * Every company is a software company. - - * Open source is where innovation happens. - - - - -Given that, it is clear that open source is too big to fail and too important to be controlled by a few or left to its own destiny. Open source is a shared-resource system that has value to all, and more importantly, it must be managed as such. It is only a matter of time until every company on earth will want to have a stake and a say in the open source world. Unfortunately, we don't have the tools and the habits to do it yet. Such tools would allow anybody to show their appreciation or ignorance of software projects. It would create a direct and faster feedback loop between producers and consumers, between developers and users. It will foster innovation—innovation driven by user needs and expressed through token metrics. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/open-source-tokenomics - -作者:[Bilgin lbryam][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/bibryam -[1]:https://en.wikipedia.org/wiki/Satoshi_Nakamoto -[2]:https://www.apache.org/ -[3]:https://www.cncf.io/ -[4]:https://medium.com/open-consensus/3-oss-business-model-progressions-dafd5837f2d -[5]:https://docs.google.com/spreadsheets/d/17nKMpi_Dh5slCqzLSFBoWMxNvWiwt2R-t4e_l7LPLhU/edit#gid=0 -[6]:http://jobs.redhat.com/ -[7]:https://attic.apache.org/ -[8]:http://incubator.apache.org/ -[9]:https://en.wikipedia.org/wiki/Smart_contract -[10]:/file/404421 -[11]:https://opensource.com/sites/default/files/uploads/blockchain_in_open_source_ecosystem.png (blockchain_in_open_source_ecosystem.png) -[12]:https://gitcoin.co/ -[13]:http://oscoin.io/ -[14]:https://opencollective.com/opensource -[15]:https://www.fundyourselfnow.com/page/about -[16]:https://kauri.io/ -[17]:https://liberapay.com/ -[18]:https://fundrequest.io/ -[19]:https://canya.io/ -[20]:https://www.bountysource.com/ -[21]:https://opengift.io/pub/ -[22]:https://hacken.io/ -[23]:https://www.coinlancer.com/home -[24]:https://codefund.io/ -[25]:https://issuehunt.io/ -[26]:https://blog.district0x.io/district-proposal-spotlight-1hive-283957f57967 -[27]:https://github.com/district0x/district-proposals/issues/177 -[28]:https://sourceforge.net/ diff --git a/sources/talk/20180813 Using D Features to Reimplement Inheritance and Polymorphism.md b/sources/talk/20180813 Using D Features to Reimplement Inheritance and Polymorphism.md new file mode 100644 index 0000000000..eed249b8bf --- /dev/null +++ b/sources/talk/20180813 Using D Features to Reimplement Inheritance and Polymorphism.md @@ -0,0 +1,235 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Using D Features to Reimplement Inheritance and Polymorphism) +[#]: via: (https://theartofmachinery.com/2018/08/13/inheritance_and_polymorphism_2.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +Using D Features to Reimplement Inheritance and Polymorphism +====== + +Some months ago I showed [how inheritance and polymorphism work in compiled languages][1] by reimplementing them with basic structs and function pointers. I wrote that code in D, but it could be translated directly to plain old C. In this post I’ll show how to take advantage of D’s features to make DIY inheritance a bit more ergonomic to use. + +Although [I have used these tricks in real code][2], I’m honestly just writing this because I think it’s neat what D can do, and because it helps explain how high-level features of D can be implemented — using the language itself. + +### `alias this` + +In the original version of the code, the `Run` command inherited from the `Commmand` base class by including a `Command` instance as its first member. `Run` and `Command` were still considered completely different types, so this meant explicit typecasting was needed every time a `Run` instance was polymorphically used as a `Command`. + +The D type system actually allows declaring a struct to be a subtype of another struct (or even of a primitive type) using a feature called “[`alias this`][3]”. Here’s a simple example of how it works: + +``` +struct Base +{ + int x; +} + +struct Derived +{ + // Add an instance of Base as a member like before... + Base _base; + // ...but this time we declare that the member is used for subtyping + alias _base this; +} + +void foo(Base b) +{ + // ... +} + +void main() +{ + Derived d; + + // Derived "inherits" members from Base + d.x = 42; + + // Derived instances can be used where a Base instance is expected + foo(d); +} +``` + +The code above works in the same way as the code in the previous blog post, but `alias this` tells the type system what we’re doing. This allows us to work _with_ the type system more, and do less typecasting. The example showed a `Derived` instance being passed by value as a `Base` instance, but passing by `ref` also works. Unfortunately, D version 2.081 won’t implicitly convert a `Derived*` to a `Base*`, but maybe it’ll be implemented in future. + +Here’s an example of `alias this` being used to implement some slightly more realistic inheritance: + +``` +import io = std.stdio; + +struct Animal +{ + struct VTable + { + void function(Animal* instance) greet; + } + immutable(VTable)* vtable; + + void greet() + { + vtable.greet(&this); + } +} + +struct Penguin +{ + private: + static immutable Animal.VTable vtable = {greet: &greetImpl}; + auto _base = Animal(&vtable); + alias _base this; + + public: + string name; + + this(string name) pure + { + this.name = name; + } + + static void greetImpl(Animal* instance) + { + // We still need one typecast here because the type system can't guarantee this is okay + auto penguin = cast(Penguin*) instance; + io.writef("I'm %s the penguin and I can swim.\n", penguin.name); + } +} + +void main() +{ + auto p = Penguin("Paul"); + + // p inherits members from Animal + p.greet(); + + // and can be passed to functions that work with Animal instances + doThings(p); +} + +void doThings(ref Animal a) +{ + a.greet(); +} +``` + +Unlike the code in the previous blog post, this version uses a vtable, just like the polymorphic inheritance in normal compiled languages. As explained in the previous post, every `Penguin` instance will use the same list of function pointers for its virtual functions. So instead of repeating the function pointers in every instance, we can have one list of function pointers that’s shared across all `Penguin` instances (i.e., a list that’s a `static` member). That’s all the vtable is, but it’s how real-world compiled OOP languages work. + +### Template Mixins + +If we implemented another `Animal` subtype, we’d have to add exactly the same vtable and base member boilerplate as in `Penguin`: + +``` +struct Snake +{ + // This bit is exactly the same as before + private: + static immutable Animal.VTable vtable = {greet: &greetImpl}; + auto _base = Animal(&vtable); + alias _base this; + + public: + + static void greetImpl(Animal* instance) + { + io.writeln("I'm an unfriendly snake. Go away."); + } +} +``` + +D has another feature for dumping this kind of boilerplate code into things: [template mixins][4]. + +``` +mixin template DeriveAnimal() +{ + private: + static immutable Animal.VTable vtable = {greet: &greetImpl}; + auto _base = Animal(&vtable); + alias _base this; +} + +struct Snake +{ + mixin DeriveAnimal; + + static void greetImpl(Animal* instance) + { + io.writeln("I'm an unfriendly snake. Go away."); + } +} +``` + +Actually, template mixins can take parameters, so it’s possible to create a generic `Derive` mixin that inherits from any struct that defines a `VTable` struct. Because template mixins can inject any kind of declaration, including template functions, the `Derive` mixin can even handle more complex things, like the typecast from `Animal*` to the subtype. + +By the way, [the `mixin` statement can also be used to “paste” code into places][5]. It’s like a hygienic version of the C preprocessor, and it’s used below (and also in this [compile-time Brainfuck compiler][6]). + +### `opDispatch()` + +There’s some highly redundant wrapper code inside the definition of `Animal`: + +``` +void greet() +{ + vtable.greet(&this); +} +``` + +If we added another virtual method, we’d have to add another wrapper: + +``` +void eat(Food food) +{ + vtable.eat(&this, food); +} +``` + +But D has `opDispatch()`, which provides a way to automatically add members to a struct. When an `opDispatch()` is defined in a struct, any time the compiler fails to find a member, it tries the `opDispatch()` template function. In other words, it’s a fallback for member lookup. A fallback to a fully generic `return vtable.MEMBER(&this, args)` will effectively fill in all the virtual function dispatchers for us: + +``` +auto opDispatch(string member_name, Args...)(auto ref Args args) +{ + mixin("return vtable." ~ member_name ~ "(&this, args);"); +} +``` + +The downside is that if the `opDispatch()` fails for any reason, the compiler gives up on the member lookup and we get a generic “Error: no property foo for type Animal”. This is confusing if `foo` is actually a valid virtual member but was called with arguments of the wrong type, or something, so `opDispatch()` needs some good error handling (e.g., with [`static assert`][7]). + +### `static foreach` + +An alternative is to use a newer feature of D: [`static foreach`][8]. This is a powerful tool that can create declarations inside a struct (and other places) using a loop. We can directly read a list of members from the `VTable` definition by using some compile-time reflection: + +``` +import std.traits : FieldNameTuple; +static foreach (member; FieldNameTuple!VTable) +{ + mixin("auto " ~ member ~ "(Args...)(auto ref Args args) { return vtable." ~ member ~ "(&this, args); }"); +} +``` + +The advantage in this case is that we’re explicitly creating struct members. Now the compiler can distinguish between a member that shouldn’t exist at all, and a member that exists but isn’t used properly. + +### It’s all just like the C equivalent + +As I said, this is basically just a tour-de-force of ways that D can improve the code from the previous post. However, the original motivation for this blog post was people asking me about tricks I used to implement polymorphic inheritance in bare metal D code, so I’ll finish up by saying this: All this stuff works in [`-betterC`][9] code, and none of it requires extra runtime support. The code in this post implements the same kind of thing as in the [previous post][1]. It’s just expressed in a more compact and less error-prone way. + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2018/08/13/inheritance_and_polymorphism_2.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: /2018/04/02/inheritance_and_polymorphism.html +[2]: https://gitlab.com/sarneaud/xanthe/blob/master/src/game/rigid_body.d#L15 +[3]: https://dlang.org/spec/class.html#alias-this +[4]: https://dlang.org/spec/template-mixin.html +[5]: https://dlang.org/articles/mixin.html +[6]: /2017/12/31/compile_time_brainfuck.html +[7]: https://dlang.org/spec/version.html#StaticAssert +[8]: https://dlang.org/spec/version.html#staticforeach +[9]: https://dlang.org/blog/2018/06/11/dasbetterc-converting-make-c-to-d/ diff --git a/sources/talk/20180816 Debian Turns 25- Here are Some Interesting Facts About Debian Linux.md b/sources/talk/20180816 Debian Turns 25- Here are Some Interesting Facts About Debian Linux.md deleted file mode 100644 index c90262dfee..0000000000 --- a/sources/talk/20180816 Debian Turns 25- Here are Some Interesting Facts About Debian Linux.md +++ /dev/null @@ -1,116 +0,0 @@ -Debian Turns 25! Here are Some Interesting Facts About Debian Linux -====== -One of the oldest Linux distribution still in development, Debian has just turned 25. Let’s have a look at some interesting facts about this awesome FOSS project. - -### 10 Interesting facts about Debian Linux - -![Interesting facts about Debian Linux][1] - -The facts presented here have been collected from various sources available from the internet. They are true to my knowledge, but in case of any error, please remind me to update the article. - -#### 1\. One of the oldest Linux distributions still under active development - -[Debian project][2] was announced on 16th August 1993 by Ian Murdock, Debian Founder. Like Linux creator [Linus Torvalds][3], Ian was a college student when he announced Debian project. - -![](https://farm6.staticflickr.com/5710/20006308374_7f51ae2a5c_z.jpg) - -#### 2\. Some people get tattoo while some name their project after their girlfriend’s name - -The project was named by combining the name of Ian and his then-girlfriend Debra Lynn. Ian and Debra got married and had three children. Debra and Ian got divorced in 2008. - -#### 3\. Ian Murdock: The Maverick behind the creation of Debian project - -![Debian Founder Ian Murdock][4] -Ian Murdock - -[Ian Murdock][5] led the Debian project from August 1993 until March 1996. He shaped Debian into a community project based on the principals of Free Software. The [Debian Manifesto][6] and the [Debian Social Contract][7] are still governing the project. - -He founded a commercial Linux company called [Progeny Linux Systems][8] and worked for a number of Linux related companies such as Sun Microsystems, Linux Foundation and Docker. - -Sadly, [Ian committed suicide in December 2015][9]. His contribution to Debian is certainly invaluable. - -#### 4\. Debian is a community project in the true sense - -Debian is a community based project in true sense. No one ‘owns’ Debian. Debian is being developed by volunteers from all over the world. It is not a commercial project, backed by corporates like many other Linux distributions. - -Debian Linux distribution is composed of Free Software only. It’s one of the few Linux distributions that is true to the spirit of [Free Software][10] and takes proud in being called a GNU/Linux distribution. - -Debian has its non-profit organization called [Software in Public Interest][11] (SPI). Along with Debian, SPI supports many other open source projects financially. - -#### 5\. Debian and its 3 branches - -Debian has three branches or versions: Debian Stable, Debian Unstable (Sid) and Debian Testing. - -Debian Stable, as the name suggests, is the stable branch that has all the software and packages well tested to give you a rock solid stable system. Since it takes time before a well-tested software lands in the stable branch, Debian Stable often contains older versions of programs and hence people joke that Debian Stable means stale. - -[Debian Unstable][12] codenamed Sid is the version where all the development of Debian takes place. This is where the new packages first land or developed. After that, these changes are propagated to the testing version. - -[Debian Testing][13] is the next release after the current stable release. If the current stable release is N, Debian testing would be the N+1 release. The packages from Debian Unstable are tested in this version. After all the new changes are well tested, Debian Testing is then ‘promoted’ as the new Stable version. - -There is no strict release schedule for Debian. - -#### 7\. There was no Debian 1.0 release - -Debian 1.0 was never released. The CD vendor, InfoMagic, accidentally shipped a development release of Debian and entitled it 1.0 in 1996. To prevent confusion between the CD version and the actual Debian release, the Debian Project renamed its next release to “Debian 1.1”. - -#### 8\. Debian releases are codenamed after Toy Story characters - -![Toy Story Characters][14] - -Debian releases are codenamed after the characters from Pixar’s hit animation movie series [Toy Story][15]. - -Debian 1.1 was the first release with a codename. It was named Buzz after the Toy Story character Buzz Lightyear. - -It was in 1996 and [Bruce Perens][16] had taken over leadership of the Project from Ian Murdock. Bruce was working at Pixar at the time. - -This trend continued and all the subsequent releases had codenamed after Toy Story characters. For example, the current stable release is Stretch while the upcoming release has been codenamed Buster. - -The unstable Debian version is codenamed Sid. This character in Toy Story is a kid with emotional problems and he enjoys breaking toys. This is symbolic in the sense that Debian Unstable might break your system with untested packages. - -#### 9\. Debian also has a BSD ditribution - -Debian is not limited to Linux. Debian also has a distribution based on FreeBSD kernel. It is called [Debian GNU/kFreeBSD][17]. - -#### 10\. Google uses Debian - -[Google uses Debian][18] as its in-house development platform. Earlier, Google used a customized version of Ubuntu as its development platform. Recently they opted for Debian based gLinux. - -#### Happy 25th birthday Debian - -![Happy 25th birthday Debian][19] - -I hope you liked these little facts about Debian. Stuff like these are reasons why people love Debian. - -I wish a very happy 25th birthday to Debian. Please continue to be awesome. Cheers :) - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/debian-facts/ - -作者:[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://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/Interesting-facts-about-debian.jpeg -[2]:https://www.debian.org -[3]:https://itsfoss.com/linus-torvalds-facts/ -[4]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/ian-murdock.jpg -[5]:https://en.wikipedia.org/wiki/Ian_Murdock -[6]:https://www.debian.org/doc/manuals/project-history/ap-manifesto.en.html -[7]:https://www.debian.org/social_contract -[8]:https://en.wikipedia.org/wiki/Progeny_Linux_Systems -[9]:https://itsfoss.com/ian-murdock-dies-mysteriously/ -[10]:https://www.fsf.org/ -[11]:https://www.spi-inc.org/ -[12]:https://www.debian.org/releases/sid/ -[13]:https://www.debian.org/releases/testing/ -[14]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/toy-story-characters.jpeg -[15]:https://en.wikipedia.org/wiki/Toy_Story_(franchise) -[16]:https://perens.com/about-bruce-perens/ -[17]:https://wiki.debian.org/Debian_GNU/kFreeBSD -[18]:https://itsfoss.com/goobuntu-glinux-google/ -[19]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/happy-25th-birthday-Debian.jpeg diff --git a/sources/talk/20180904 How blockchain can complement open source.md b/sources/talk/20180904 How blockchain can complement open source.md deleted file mode 100644 index 7712539f3f..0000000000 --- a/sources/talk/20180904 How blockchain can complement open source.md +++ /dev/null @@ -1,95 +0,0 @@ -How blockchain can complement open source -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/block-quilt-chain.png?itok=mECoDbrc) - -[The Cathedral and The Bazaar][1] is a classic open source story, written 20 years ago by Eric Steven Raymond. In the story, Eric describes a new revolutionary software development model where complex software projects are built without (or with a very little) central management. This new model is open source. - -Eric's story compares two models: - - * The classic model (represented by the cathedral), in which software is crafted by a small group of individuals in a closed and controlled environment through slow and stable releases. - * And the new model (represented by the bazaar), in which software is crafted in an open environment where individuals can participate freely but still produce a stable and coherent system. - - - -Some of the reasons open source is so successful can be traced back to the founding principles Eric describes. Releasing early, releasing often, and accepting the fact that many heads are inevitably better than one allows open source projects to tap into the world’s pool of talent (and few companies can match that using the closed source model). - -Two decades after Eric's reflective analysis of the hacker community, we see open source becoming dominant. It is no longer a model only for scratching a developer’s personal itch, but instead, the place where innovation happens. Even the world's [largest][2] software companies are transitioning to this model in order to continue dominating. - -### A barter system - -If we look closely at how the open source model works in practice, we realize that it is a closed system, exclusive only to open source developers and techies. The only way to influence the direction of a project is by joining the open source community, understanding the written and the unwritten rules, learning how to contribute, the coding standards, etc., and doing it yourself. - -This is how the bazaar works, and it is where the barter system analogy comes from. A barter system is a method of exchanging services and goods in return for other services and goods. In the bazaar—where the software is built—that means in order to take something, you must also be a producer yourself and give something back in return. And that is by exchanging your time and knowledge for getting something done. A bazaar is a place where open source developers interact with other open source developers and produce open source software the open source way. - -The barter system is a great step forward and an evolution from the state of self-sufficiency where everybody must be a jack of all trades. The bazaar (open source model) using the barter system allows people with common interests and different skills to gather, collaborate, and create something that no individual can create on their own. The barter system is simple and lacks complex problems of the modern monetary systems, but it also has some limitations, such as: - - * Lack of divisibility: In the absence of a common medium of exchange, a large indivisible commodity/value cannot be exchanged for a smaller commodity/value. For example, if you want to do even a small change in an open source project, you may sometimes still need to go through a high entry barrier. - * Storing value: If a project is important to your company, you may want to have a large investment/commitment in it. But since it is a barter system among open source developers, the only way to have a strong say is by employing many open source committers, and that is not always possible. - * Transferring value: If you have invested in a project (trained employees, hired open source developers) and want to move focus to another project, it is not possible to transfer expertise, reputation, and influence quickly. - * Temporal decoupling: The barter system does not provide a good mechanism for deferred or advance commitments. In the open source world, that means a user cannot express commitment or interest in a project in a measurable way in advance, or continuously for future periods. - - - -Below, we will explore how to address these limitations using the back door to the bazaar. - -### A currency system - -People are hanging at the bazaar for different reasons: Some are there to learn, some are there to scratch a personal developer's itch, and some work for large software farms. Because the only way to have a say in the bazaar is to become part of the open source community and join the barter system, in order to gain credibility in the open source world, many large software companies employ these developers and pay them in monetary value. This represents the use of a currency system to influence the bazaar. Open source is no longer only for scratching the personal developer itch. It also accounts for a significant part of the overall software production worldwide, and there are many who want to have an influence. - -Open source sets the guiding principles through which developers interact and build a coherent system in a distributed way. It dictates how a project is governed, how software is built, and how the output distributed to users. It is an open consensus model for decentralized entities for building quality software together. But the open source model does not cover how open source is subsidized. Whether it is sponsored, directly or indirectly, through intrinsic or extrinsic motivators is irrelevant to the bazaar. - -![](https://opensource.com/sites/default/files/uploads/tokenomics_-_page_4.png) - -Currently, there is no equivalent of the decentralized open source development model for subsidization purposes. The majority of open source subsidization is centralized, where typically one company dominates a project by employing the majority of the open source developers of that project. And to be honest, this is currently the best-case scenario, as it guarantees that the developers will be paid for a long period and the project will continue to flourish. - -There are also exceptions for the project monopoly scenario: For example, some Cloud Native Computing Foundation projects are developed by a large number of competing companies. Also, the Apache Software Foundation aims for their projects not to be dominated by a single vendor by encouraging diverse contributors, but most of the popular projects, in reality, are still single-vendor projects. - -What we are missing is an open and decentralized model that works like the bazaar without a central coordination and ownership, where consumers (open source users) and producers (open source developers) interact with each other, driven by market forces and open source value. In order to complement open source, such a model must also be open and decentralized, and this is why I think the blockchain technology would [fit best here][3]. - -Most of the existing blockchain (and non-blockchain) platforms that aim to subsidize open source development are targeting primarily bug bounties, small and piecemeal tasks. A few also focus on funding new open source projects. But not many aim to provide mechanisms for sustaining continued development of open source projects—basically, a system that would emulate the behavior of an open source service provider company, or open core, open source-based SaaS product company: ensuring developers get continued and predictable incentives and guiding the project development based on the priorities of the incentivizers; i.e., the users. Such a model would address the limitations of the barter system listed above: - - * Allow divisibility: If you want something small fixed, you can pay a small amount rather than the full premium of becoming an open source developer for a project. - * Storing value: You can invest a large amount into a project and ensure both its continued development and that your voice is heard. - * Transferring value: At any point, you can stop investing in the project and move funds into other projects. - * Temporal decoupling: Allow regular recurring payments and subscriptions. - - - -There would be also other benefits, purely from the fact that such a blockchain-based system is transparent and decentralized: to quantify a project’s value/usefulness based on its users’ commitment, open roadmap commitment, decentralized decision making, etc. - -### Conclusion - -On the one hand, we see large companies hiring open source developers and acquiring open source startups and even foundational platforms (such as Microsoft buying GitHub). Many, if not most, long-running successful open source projects are centralized around a single vendor. The significance of open source and its centralization is a fact. - -On the other hand, the challenges around [sustaining open source][4] software are becoming more apparent, and many are investigating this space and its foundational issues more deeply. There are a few projects with high visibility and a large number of contributors, but there are also many other still-important projects that lack enough contributors and maintainers. - -There are [many efforts][3] trying to address the challenges of open source through blockchain. These projects should improve the transparency, decentralization, and subsidization and establish a direct link between open source users and developers. This space is still very young, but it is progressing quickly, and with time, the bazaar is going to have a cryptocurrency system. - -Given enough time and adequate technology, decentralization is happening at many levels: - - * The internet is a decentralized medium that has unlocked the world’s potential for sharing and acquiring knowledge. - * Open source is a decentralized collaboration model that has unlocked the world’s potential for innovation. - * Similarly, blockchain can complement open source and become the decentralized open source subsidization model. - - - -Follow me on [Twitter][5] for other posts in this space. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/9/barter-currency-system - -作者:[Bilgin lbryam][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/bibryam -[1]: http://catb.org/ -[2]: http://oss.cash/ -[3]: https://opensource.com/article/18/8/open-source-tokenomics -[4]: https://www.youtube.com/watch?v=VS6IpvTWwkQ -[5]: http://twitter.com/bibryam diff --git a/sources/talk/20180916 The Rise and Demise of RSS (Old Version).md b/sources/talk/20180916 The Rise and Demise of RSS (Old Version).md new file mode 100644 index 0000000000..b6e1a4fdd9 --- /dev/null +++ b/sources/talk/20180916 The Rise and Demise of RSS (Old Version).md @@ -0,0 +1,278 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The Rise and Demise of RSS (Old Version)) +[#]: via: (https://twobithistory.org/2018/09/16/the-rise-and-demise-of-rss.html) +[#]: author: (Two-Bit History https://twobithistory.org) + +The Rise and Demise of RSS (Old Version) +====== + +_A newer version of this post was published on [December 18th, 2018][1]._ + +There are two stories here. The first is a story about a vision of the web’s future that never quite came to fruition. The second is a story about how a collaborative effort to improve a popular standard devolved into one of the most contentious forks in the history of open-source software development. + +In the late 1990s, in the go-go years between Netscape’s IPO and the Dot-com crash, everyone could see that the web was going to be an even bigger deal than it already was, even if they didn’t know exactly how it was going to get there. One theory was that the web was about to be revolutionized by syndication. The web, originally built to enable a simple transaction between two parties—a client fetching a document from a single host server—would be broken open by new standards that could be used to repackage and redistribute entire websites through a variety of channels. Kevin Werbach, writing for _Release 1.0_, a newsletter influential among investors in the 1990s, predicted that syndication “would evolve into the core model for the Internet economy, allowing businesses and individuals to retain control over their online personae while enjoying the benefits of massive scale and scope.”[1][2] He invited his readers to imagine a future in which fencing aficionados, rather than going directly to an “online sporting goods site” or “fencing equipment retailer,” could buy a new épée directly through e-commerce widgets embedded into their favorite website about fencing.[2][3] Just like in the television world, where big networks syndicate their shows to smaller local stations, syndication on the web would allow businesses and publications to reach consumers through a multitude of intermediary sites. This would mean, as a corollary, that consumers would gain significant control over where and how they interacted with any given business or publication on the web. + +RSS was one of the standards that promised to deliver this syndicated future. To Werbach, RSS was “the leading example of a lightweight syndication protocol.”[3][4] Another contemporaneous article called RSS the first protocol to realize the potential of XML.[4][5] It was going to be a way for both users and content aggregators to create their own customized channels out of everything the web had to offer. And yet, two decades later, RSS [appears to be a dying technology][6], now used chiefly by podcasters and programmers with tech blogs. Moreover, among that latter group, RSS is perhaps used as much for its political symbolism as its actual utility. Though of course some people really do have RSS readers, stubbornly adding an RSS feed to your blog, even in 2018, is a reactionary statement. That little tangerine bubble has become a wistful symbol of defiance against a centralized web increasingly controlled by a handful of corporations, a web that hardly resembles the syndicated web of Werbach’s imagining. + +The future once looked so bright for RSS. What happened? Was its downfall inevitable, or was it precipitated by the bitter infighting that thwarted the development of a single RSS standard? + +### Muddied Water + +RSS was invented twice. This meant it never had an obvious owner, a state of affairs that spawned endless debate and acrimony. But it also suggests that RSS was an important idea whose time had come. + +In 1998, Netscape was struggling to envision a future for itself. Its flagship product, the Netscape Navigator web browser—once preferred by 80% of web users—was quickly losing ground to Internet Explorer. So Netscape decided to compete in a new arena. In May, a team was brought together to start work on what was known internally as “Project 60.”[5][7] Two months later, Netscape announced “My Netscape,” a web portal that would fight it out with other portals like Yahoo, MSN, and Excite. + +The following year, in March, Netscape announced an addition to the My Netscape portal called the “My Netscape Network.” My Netscape users could now customize their My Netscape page so that it contained “channels” featuring the most recent headlines from sites around the web. As long as your favorite website published a special file in a format dictated by Netscape, you could add that website to your My Netscape page, typically by clicking an “Add Channel” button that participating websites were supposed to add to their interfaces. A little box containing a list of linked headlines would then appear. + +![A My Netscape Network Channel][8] + +The special file that participating websites had to publish was an RSS file. In the My Netscape Network announcement, Netscape explained that RSS stood for “RDF Site Summary.”[6][9] This was somewhat of a misnomer. RDF, or the Resource Description Framework, is basically a grammar for describing certain properties of arbitrary resources. (See [my article about the Semantic Web][10] if that sounds really exciting to you.) In 1999, a draft specification for RDF was being considered by the W3C. Though RSS was supposed to be based on RDF, the example RSS document Netscape actually released didn’t use any RDF tags at all, even if it declared the RDF XML namespace. In a document that accompanied the Netscape RSS specification, Dan Libby, one of the specification’s authors, explained that “in this release of MNN, Netscape has intentionally limited the complexity of the RSS format.”[7][11] The specification was given the 0.90 version number, the idea being that subsequent versions would bring RSS more in line with the W3C’s XML specification and the evolving draft of the RDF specification. + +RSS had been cooked up by Libby and another Netscape employee, Ramanathan Guha. Guha previously worked for Apple, where he came up with something called the Meta Content Framework. MCF was a format for representing metadata about anything from web pages to local files. Guha demonstrated its power by developing an application called [HotSauce][12] that visualized relationships between files as a network of nodes suspended in 3D space. After leaving Apple for Netscape, Guha worked with a Netscape consultant named Tim Bray to produce an XML-based version of MCF, which in turn became the foundation for the W3C’s RDF draft.[8][13] It’s no surprise, then, that Guha and Libby were keen to incorporate RDF into RSS. But Libby later wrote that the original vision for an RDF-based RSS was pared back because of time constraints and the perception that RDF was “‘too complex’ for the ‘average user.’”[9][14] + +While Netscape was trying to win eyeballs in what became known as the “portal wars,” elsewhere on the web a new phenomenon known as “weblogging” was being pioneered.[10][15] One of these pioneers was Dave Winer, CEO of a company called UserLand Software, which developed early content management systems that made blogging accessible to people without deep technical fluency. Winer ran his own blog, [Scripting News][16], which today is one of the oldest blogs on the internet. More than a year before Netscape announced My Netscape Network, on December 15th, 1997, Winer published a post announcing that the blog would now be available in XML as well as HTML.[11][17] + +Dave Winer’s XML format became known as the Scripting News format. It was supposedly similar to Microsoft’s Channel Definition Format (a “push technology” standard submitted to the W3C in March, 1997), but I haven’t been able to find a file in the original format to verify that claim.[12][18] Like Netscape’s RSS, it structured the content of Winer’s blog so that it could be understood by other software applications. When Netscape released RSS 0.90, Winer and UserLand Software began to support both formats. But Winer believed that Netscape’s format was “woefully inadequate” and “missing the key thing web writers and readers need.”[13][19] It could only represent a list of links, whereas the Scripting News format could represent a series of paragraphs, each containing one or more links. + +In June, 1999, two months after Netscape’s My Netscape Network announcement, Winer introduced a new version of the Scripting News format, called ScriptingNews 2.0b1. Winer claimed that he decided to move ahead with his own format only after trying but failing to get anyone at Netscape to care about RSS 0.90’s deficiencies.[14][20] The new version of the Scripting News format added several items to the `

` element that brought the Scripting News format to parity with RSS. But the two formats continued to differ in that the Scripting News format, which Winer nicknamed the “fat” syndication format, could include entire paragraphs and not just links. + +Netscape got around to releasing RSS 0.91 the very next month. The updated specification was a major about-face. RSS no longer stood for “RDF Site Summary”; it now stood for “Rich Site Summary.” All the RDF—and there was almost none anyway—was stripped out. Many of the Scripting News tags were incorporated. In the text of the new specification, Libby explained: + +> RDF references removed. RSS was originally conceived as a metadata format providing a summary of a website. Two things have become clear: the first is that providers want more of a syndication format than a metadata format. The structure of an RDF file is very precise and must conform to the RDF data model in order to be valid. This is not easily human-understandable and can make it difficult to create useful RDF files. The second is that few tools are available for RDF generation, validation and processing. For these reasons, we have decided to go with a standard XML approach.[15][21] + +Winer was enormously pleased with RSS 0.91, calling it “even better than I thought it would be.”[16][22] UserLand Software adopted it as a replacement for the existing ScriptingNews 2.0b1 format. For a while, it seemed that RSS finally had a single authoritative specification. + +### The Great Fork + +A year later, the RSS 0.91 specification had become woefully inadequate. There were all sorts of things people were trying to do with RSS that the specification did not address. There were other parts of the specification that seemed unnecessarily constraining—each RSS channel could only contain a maximum of 15 items, for example. + +By that point, RSS had been adopted by several more organizations. Other than Netscape, which seemed to have lost interest after RSS 0.91, the big players were Dave Winer’s UserLand Software; O’Reilly Net, which ran an RSS aggregator called Meerkat; and Moreover.com, which also ran an RSS aggregator focused on news.[17][23] Via mailing list, representatives from these organizations and others regularly discussed how to improve on RSS 0.91. But there were deep disagreements about what those improvements should look like. + +The mailing list in which most of the discussion occurred was called the Syndication mailing list. [An archive of the Syndication mailing list][24] is still available. It is an amazing historical resource. It provides a moment-by-moment account of how those deep disagreements eventually led to a political rupture of the RSS community. + +On one side of the coming rupture was Winer. Winer was impatient to evolve RSS, but he wanted to change it only in relatively conservative ways. In June, 2000, he published his own RSS 0.91 specification on the UserLand website, meant to be a starting point for further development of RSS. It made no significant changes to the 0.91 specification published by Netscape. Winer claimed in a blog post that accompanied his specification that it was only a “cleanup” documenting how RSS was actually being used in the wild, which was needed because the Netscape specification was no longer being maintained.[18][25] In the same post, he argued that RSS had succeeded so far because it was simple, and that by adding namespaces or RDF back to the format—some had suggested this be done in the Syndication mailing list—it “would become vastly more complex, and IMHO, at the content provider level, would buy us almost nothing for the added complexity.” In a message to the Syndication mailing list sent around the same time, Winer suggested that these issues were important enough that they might lead him to create a fork: + +> I’m still pondering how to move RSS forward. I definitely want ICE-like stuff in RSS2, publish and subscribe is at the top of my list, but I am going to fight tooth and nail for simplicity. I love optional elements. I don’t want to go down the namespaces and schema road, or try to make it a dialect of RDF. I understand other people want to do this, and therefore I guess we’re going to get a fork. I have my own opinion about where the other fork will lead, but I’ll keep those to myself for the moment at least.[19][26] + +Arrayed against Winer were several other people, including Rael Dornfest of O’Reilly, Ian Davis (responsible for a search startup called Calaba), and a precocious, 14-year-old Aaron Swartz, who all thought that RSS needed namespaces in order to accommodate the many different things everyone wanted to do with it. On another mailing list hosted by O’Reilly, Davis proposed a namespace-based module system, writing that such a system would “make RSS as extensible as we like rather than packing in new features that over-complicate the spec.”[20][27] The “namespace camp” believed that RSS would soon be used for much more than the syndication of blog posts, so namespaces, rather than being a complication, were the only way to keep RSS from becoming unmanageable as it supported more and more use cases. + +At the root of this disagreement about namespaces was a deeper disagreement about what RSS was even for. Winer had invented his Scripting News format to syndicate the posts he wrote for his blog. Guha and Libby at Netscape had designed RSS and called it “RDF Site Summary” because in their minds it was a way of recreating a site in miniature within Netscape’s online portal. Davis, writing to the Syndication mailing list, explained his view that RSS was “originally conceived as a way of building mini sitemaps,” and that now he and others wanted to expand RSS “to encompass more types of information than simple news headlines and to cater for the new uses of RSS that have emerged over the last 12 months.”[21][28] Winer wrote a prickly reply, stating that his Scripting News format was in fact the original RSS and that it had been meant for a different purpose. Given that the people most involved in the development of RSS disagreed about why RSS had even been created, a fork seems to have been inevitable. + +The fork happened after Dornfest announced a proposed RSS 1.0 specification and formed the RSS-DEV Working Group—which would include Davis, Swartz, and several others but not Winer—to get it ready for publication. In the proposed specification, RSS once again stood for “RDF Site Summary,” because RDF had had been added back in to represent metadata properties of certain RSS elements. The specification acknowledged Winer by name, giving him credit for popularizing RSS through his “evangelism.”[22][29] But it also argued that just adding more elements to RSS without providing for extensibility with a module system—that is, what Winer was suggesting—”sacrifices scalability.” The specification went on to define a module system for RSS based on XML namespaces. + +Winer was furious that the RSS-DEV Working Group had arrogated the “RSS 1.0” name for themselves.[23][30] In another mailing list about decentralization, he described what the RSS-DEV Working Group had done as theft.[24][31] Other members of the Syndication mailing list also felt that the RSS-DEV Working Group should not have used the name “RSS” without unanimous agreement from the community on how to move RSS forward. But the Working Group stuck with the name. Dan Brickley, another member of the RSS-DEV Working Group, defended this decision by arguing that “RSS 1.0 as proposed is solidly grounded in the original RSS vision, which itself had a long heritage going back to MCF (an RDF precursor) and related specs (CDF etc).”[25][32] He essentially felt that the RSS 1.0 effort had a better claim to the RSS name than Winer did, since RDF had originally been a part of RSS. The RSS-DEV Working Group published a final version of their specification in December. That same month, Winer published his own improvement to RSS 0.91, which he called RSS 0.92, on UserLand’s website. RSS 0.92 made several small optional improvements to RSS, among which was the addition of the `` tag soon used by podcasters everywhere. RSS had officially forked. + +It’s not clear to me why a better effort was not made to involve Winer in the RSS-DEV Working Group. He was a prominent contributor to the Syndication mailing list and obviously responsible for much of RSS’ popularity, as the members of the Working Group themselves acknowledged. But Tim O’Reilly, founder and CEO of O’Reilly, explained in a UserLand discussion group that Winer more or less refused to participate: + +> A group of people involved in RSS got together to start thinking about its future evolution. Dave was part of the group. When the consensus of the group turned in a direction he didn’t like, Dave stopped participating, and characterized it as a plot by O’Reilly to take over RSS from him, despite the fact that Rael Dornfest of O’Reilly was only one of about a dozen authors of the proposed RSS 1.0 spec, and that many of those who were part of its development had at least as long a history with RSS as Dave had.[26][33] + +To this, Winer said: + +> I met with Dale [Dougherty] two weeks before the announcement, and he didn’t say anything about it being called RSS 1.0. I spoke on the phone with Rael the Friday before it was announced, again he didn’t say that they were calling it RSS 1.0. The first I found out about it was when it was publicly announced. +> +> Let me ask you a straight question. If it turns out that the plan to call the new spec “RSS 1.0” was done in private, without any heads-up or consultation, or for a chance for the Syndication list members to agree or disagree, not just me, what are you going to do? +> +> UserLand did a lot of work to create and popularize and support RSS. We walked away from that, and let your guys have the name. That’s the top level. If I want to do any further work in Web syndication, I have to use a different name. Why and how did that happen Tim?[27][34] + +I have not been able to find a discussion in the Syndication mailing list about using the RSS 1.0 name prior to the announcement of the RSS 1.0 proposal. + +RSS would fork again in 2003, when several developers frustrated with the bickering in the RSS community sought to create an entirely new format. These developers created Atom, a format that did away with RDF but embraced XML namespaces. Atom would eventually be specified by [a proposed IETF standard][35]. After the introduction of Atom, there were three competing versions of RSS: Winer’s RSS 0.92 (updated to RSS 2.0 in 2002 and renamed “Really Simple Syndication”), the RSS-DEV Working Group’s RSS 1.0, and Atom. + +### Decline + +The proliferation of competing RSS specifications may have hampered RSS in other ways that I’ll discuss shortly. But it did not stop RSS from becoming enormously popular during the 2000s. By 2004, the New York Times had started offering its headlines in RSS and had written an article explaining to the layperson what RSS was and how to use it.[28][36] Google Reader, an RSS aggregator ultimately used by millions, was launched in 2005. By 2013, RSS seemed popular enough that the New York Times, in its obituary for Aaron Swartz, called the technology “ubiquitous.”[29][37] For a while, before a third of the planet had signed up for Facebook, RSS was simply how many people stayed abreast of news on the internet. + +The New York Times published Swartz’ obituary in January, 2013. By that point, though, RSS had actually turned a corner and was well on its way to becoming an obscure technology. Google Reader was shutdown in July, 2013, ostensibly because user numbers had been falling “over the years.”[30][38] This prompted several articles from various outlets declaring that RSS was dead. But people had been declaring that RSS was dead for years, even before Google Reader’s shuttering. Steve Gillmor, writing for TechCrunch in May, 2009, advised that “it’s time to get completely off RSS and switch to Twitter” because “RSS just doesn’t cut it anymore.”[31][39] He pointed out that Twitter was basically a better RSS feed, since it could show you what people thought about an article in addition to the article itself. It allowed you to follow people and not just channels. Gillmor told his readers that it was time to let RSS recede into the background. He ended his article with a verse from Bob Dylan’s “Forever Young.” + +Today, RSS is not dead. But neither is it anywhere near as popular as it once was. Lots of people have offered explanations for why RSS lost its broad appeal. Perhaps the most persuasive explanation is exactly the one offered by Gillmor in 2009. Social networks, just like RSS, provide a feed featuring all the latest news on the internet. Social networks took over from RSS because they were simply better feeds. They also provide more benefits to the companies that own them. Some people have accused Google, for example, of shutting down Google Reader in order to encourage people to use Google+. Google might have been able to monetize Google+ in a way that it could never have monetized Google Reader. Marco Arment, the creator of Instapaper, wrote on his blog in 2013: + +> Google Reader is just the latest casualty of the war that Facebook started, seemingly accidentally: the battle to own everything. While Google did technically “own” Reader and could make some use of the huge amount of news and attention data flowing through it, it conflicted with their far more important Google+ strategy: they need everyone reading and sharing everything through Google+ so they can compete with Facebook for ad-targeting data, ad dollars, growth, and relevance.[32][40] + +So both users and technology companies realized that they got more out of using social networks than they did out of RSS. + +Another theory is that RSS was always too geeky for regular people. Even the New York Times, which seems to have been eager to adopt RSS and promote it to its audience, complained in 2006 that RSS is a “not particularly user friendly” acronym coined by “computer geeks.”[33][41] Before the RSS icon was designed in 2004, websites like the New York Times linked to their RSS feeds using little orange boxes labeled “XML,” which can only have been intimidating.[34][42] The label was perfectly accurate though, because back then clicking the link would take a hapless user to a page full of XML. [This great tweet][43] captures the essence of this explanation for RSS’ demise. Regular people never felt comfortable using RSS; it hadn’t really been designed as a consumer-facing technology and involved too many hurdles; people jumped ship as soon as something better came along. + +RSS might have been able to overcome some of these limitations if it had been further developed. Maybe RSS could have been extended somehow so that friends subscribed to the same channel could syndicate their thoughts about an article to each other. But whereas a company like Facebook was able to “move fast and break things,” the RSS developer community was stuck trying to achieve consensus. The Great RSS Fork only demonstrates how difficult it was to do that. So if we are asking ourselves why RSS is no longer popular, a good first-order explanation is that social networks supplanted it. If we ask ourselves why social networks were able to supplant it, then the answer may be that the people trying to make RSS succeed faced a problem much harder than, say, building Facebook. As Dornfest wrote to the Syndication mailing list at one point, “currently it’s the politics far more than the serialization that’s far from simple.”[35][44] + +So today we are left with centralized silos of information. In a way, we _do_ have the syndicated internet that Kevin Werbach foresaw in 1999. After all, _The Onion_ is a publication that relies on syndication through Facebook and Twitter the same way that Seinfeld relied on syndication to rake in millions after the end of its original run. But syndication on the web only happens through one of a very small number of channels, meaning that none of us “retain control over our online personae” the way that Werbach thought we would. One reason this happened is garden-variety corporate rapaciousness—RSS, an open format, didn’t give technology companies the control over data and eyeballs that they needed to sell ads, so they did not support it. But the more mundane reason is that centralized silos are just easier to design than common standards. Consensus is difficult to achieve and it takes time, but without consensus spurned developers will go off and create competing standards. The lesson here may be that if we want to see a better, more open web, we have to get better at not screwing each other over. + +_If you enjoyed this post, more like it come out every four weeks! Follow [@TwoBitHistory][45] on Twitter or subscribe to the [RSS feed][46] to make sure you know when a new post is out._ + +_Previously on TwoBitHistory…_ + +> New post: This week we're traveling back in time in our DeLorean to see what it was like learning to program on early home computers. +> +> — TwoBitHistory (@TwoBitHistory) [September 2, 2018][47] + + 1. Kevin Werbach, “The Web Goes into Syndication,” Release 1.0, July 22, 1999, 1, accessed September 14, 2018, . [↩︎][48] + + 2. ibid. [↩︎][49] + + 3. Werbach, 8. [↩︎][50] + + 4. Peter Wiggin, “RSS Delivers the XML Promise,” Web Review, October 29, 1999, accessed September 14, 2018, . [↩︎][51] + + 5. Ben Hammersley, RSS and Atom (O’Reilly), 8, accessed September 14, 2018, . [↩︎][52] + + 6. “RSS 0.90 Specification,” RSS Advisory Board, accessed September 14, 2018, . [↩︎][53] + + 7. “My Netscape Network Future Directions,” RSS Advisory Board, accessed September 14, 2018, . [↩︎][54] + + 8. Tim Bray, “The RDF.net Challenge,” Ongoing by Tim Bray, May 21, 2003, accessed September 14, 2018, . [↩︎][55] + + 9. Dan Libby, “RSS: Introducing Myself,” August 24, 2000, RSS-DEV Mailing List, accessed September 14, 2018, . [↩︎][56] + + 10. Alexandra Krasne, “Browser Wars May Become Portal Wars,” CNN, accessed September 14, 2018, . [↩︎][57] + + 11. Dave Winer, “Scripting News in XML,” Scripting News, December 15, 1997, accessed September 14, 2018, . [↩︎][58] + + 12. Joseph Reagle, “RSS History,” 2004, accessed September 14, 2018, . [↩︎][59] + + 13. Dave Winer, “A Faceoff with Netscape,” Scripting News, June 16, 1999, accessed September 14, 2018, . [↩︎][60] + + 14. ibid. [↩︎][61] + + 15. Dan Libby, “RSS 0.91 Specification (Netscape),” RSS Advisory Board, accessed September 14, 2018, . [↩︎][62] + + 16. Dave Winer, “Scripting News: 7/28/1999,” Scripting News, July 28, 1999, accessed September 14, 2018, . [↩︎][63] + + 17. Oliver Willis, “RSS Aggregators?” June 19, 2000, Syndication Mailing List, accessed September 14, 2018, . [↩︎][64] + + 18. Dave Winer, “Scripting News: 07/07/2000,” Scripting News, July 07, 2000, accessed September 14, 2018, . [↩︎][65] + + 19. Dave Winer, “Re: RSS 0.91 Restarted,” June 9, 2000, Syndication Mailing List, accessed September 14, 2018, . [↩︎][66] + + 20. Leigh Dodds, “RSS Modularization,” XML.com, July 5, 2000, accessed September 14, 2018, . [↩︎][67] + + 21. Ian Davis, “Re: [syndication] RSS Modularization Demonstration,” June 28, 2000, Syndication Mailing List, accessed September 14, 2018, . [↩︎][68] + + 22. “RDF Site Summary (RSS) 1.0,” December 09, 2000, accessed September 14, 2018, . [↩︎][69] + + 23. Dave Winer, “Re: [syndication] Re: Thoughts, Questions, and Issues,” August 16, 2000, Syndication Mailing List, accessed September 14, 2018, . [↩︎][70] + + 24. Mark Pilgrim, “History of the RSS Fork,” Dive into Mark, September 5, 2002, accessed September 14, 2018, . [↩︎][71] + + 25. Dan Brickley, “RSS-Classic, RSS 1.0 and a Historical Debt,” November 7, 2000, Syndication Mailing List, accessed September 14, 2018, . [↩︎][72] + + 26. Tim O’Reilly, “Re: Asking Tim,” UserLand, September 20, 2000, accessed September 14, 2018, . [↩︎][73] + + 27. Dave Winer, “Re: Asking Tim,” UserLand, September 20, 2000, accessed September 14, 2018, . [↩︎][74] + + 28. John Quain, “BASICS; Fine-Tuning Your Filter for Online Information,” The New York Times, 2004, accessed September 14, 2018, . [↩︎][75] + + 29. John Schwartz, “Aaron Swartz, Internet Activist, Dies at 26,” The New York Times, January 12, 2013, accessed September 14, 2018, . [↩︎][76] + + 30. “A Second Spring of Cleaning,” Official Google Blog, March 13, 2013, accessed September 14, 2018, . [↩︎][77] + + 31. Steve Gillmor, “Rest in Peace, RSS,” TechCrunch, May 5, 2009, accessed September 14, 2018, . [↩︎][78] + + 32. Marco Arment, “Lockdown,” Marco.org, July 3, 2013, accessed September 14, 2018, . [↩︎][79] + + 33. Bob Tedeschi, “There’s a Popular New Code for Deals: RSS,” The New York Times, January 29, 2006, accessed September 14, 2018, . [↩︎][80] + + 34. “NYTimes.com RSS Feeds,” The New York Times, accessed September 14, 2018, . [↩︎][81] + + 35. Rael Dornfest, “RE: Re: [syndication] RE: RFC: Clearing Confusion for RSS, Agreement for Forward Motion,” May 31, 2001, Syndication Mailing List, accessed September 14, 2018, . [↩︎][82] + + + + +-------------------------------------------------------------------------------- + +via: https://twobithistory.org/2018/09/16/the-rise-and-demise-of-rss.html + +作者:[Two-Bit History][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://twobithistory.org +[b]: https://github.com/lujun9972 +[1]: https://twobithistory.org/2018/12/18/rss.html +[2]: tmp.F599d8dnXW#fn:3 +[3]: tmp.F599d8dnXW#fn:4 +[4]: tmp.F599d8dnXW#fn:5 +[5]: tmp.F599d8dnXW#fn:6 +[6]: https://trends.google.com/trends/explore?date=all&geo=US&q=rss +[7]: tmp.F599d8dnXW#fn:7 +[8]: https://twobithistory.org/images/mnn-channel.gif +[9]: tmp.F599d8dnXW#fn:8 +[10]: https://twobithistory.org/2018/05/27/semantic-web.html +[11]: tmp.F599d8dnXW#fn:9 +[12]: http://web.archive.org/web/19970703020212/http://mcf.research.apple.com:80/hs/screen_shot.html +[13]: tmp.F599d8dnXW#fn:10 +[14]: tmp.F599d8dnXW#fn:11 +[15]: tmp.F599d8dnXW#fn:12 +[16]: http://scripting.com/ +[17]: tmp.F599d8dnXW#fn:13 +[18]: tmp.F599d8dnXW#fn:14 +[19]: tmp.F599d8dnXW#fn:15 +[20]: tmp.F599d8dnXW#fn:16 +[21]: tmp.F599d8dnXW#fn:17 +[22]: tmp.F599d8dnXW#fn:18 +[23]: tmp.F599d8dnXW#fn:19 +[24]: https://groups.yahoo.com/neo/groups/syndication/info +[25]: tmp.F599d8dnXW#fn:20 +[26]: tmp.F599d8dnXW#fn:21 +[27]: tmp.F599d8dnXW#fn:22 +[28]: tmp.F599d8dnXW#fn:23 +[29]: tmp.F599d8dnXW#fn:24 +[30]: tmp.F599d8dnXW#fn:25 +[31]: tmp.F599d8dnXW#fn:26 +[32]: tmp.F599d8dnXW#fn:27 +[33]: tmp.F599d8dnXW#fn:28 +[34]: tmp.F599d8dnXW#fn:29 +[35]: https://tools.ietf.org/html/rfc4287 +[36]: tmp.F599d8dnXW#fn:30 +[37]: tmp.F599d8dnXW#fn:31 +[38]: tmp.F599d8dnXW#fn:32 +[39]: tmp.F599d8dnXW#fn:33 +[40]: tmp.F599d8dnXW#fn:34 +[41]: tmp.F599d8dnXW#fn:35 +[42]: tmp.F599d8dnXW#fn:36 +[43]: https://twitter.com/mgsiegler/status/311992206716203008 +[44]: tmp.F599d8dnXW#fn:37 +[45]: https://twitter.com/TwoBitHistory +[46]: https://twobithistory.org/feed.xml +[47]: https://twitter.com/TwoBitHistory/status/1036295112375115778?ref_src=twsrc%5Etfw +[48]: tmp.F599d8dnXW#fnref:3 +[49]: tmp.F599d8dnXW#fnref:4 +[50]: tmp.F599d8dnXW#fnref:5 +[51]: tmp.F599d8dnXW#fnref:6 +[52]: tmp.F599d8dnXW#fnref:7 +[53]: tmp.F599d8dnXW#fnref:8 +[54]: tmp.F599d8dnXW#fnref:9 +[55]: tmp.F599d8dnXW#fnref:10 +[56]: tmp.F599d8dnXW#fnref:11 +[57]: tmp.F599d8dnXW#fnref:12 +[58]: tmp.F599d8dnXW#fnref:13 +[59]: tmp.F599d8dnXW#fnref:14 +[60]: tmp.F599d8dnXW#fnref:15 +[61]: tmp.F599d8dnXW#fnref:16 +[62]: tmp.F599d8dnXW#fnref:17 +[63]: tmp.F599d8dnXW#fnref:18 +[64]: tmp.F599d8dnXW#fnref:19 +[65]: tmp.F599d8dnXW#fnref:20 +[66]: tmp.F599d8dnXW#fnref:21 +[67]: tmp.F599d8dnXW#fnref:22 +[68]: tmp.F599d8dnXW#fnref:23 +[69]: tmp.F599d8dnXW#fnref:24 +[70]: tmp.F599d8dnXW#fnref:25 +[71]: tmp.F599d8dnXW#fnref:26 +[72]: tmp.F599d8dnXW#fnref:27 +[73]: tmp.F599d8dnXW#fnref:28 +[74]: tmp.F599d8dnXW#fnref:29 +[75]: tmp.F599d8dnXW#fnref:30 +[76]: tmp.F599d8dnXW#fnref:31 +[77]: tmp.F599d8dnXW#fnref:32 +[78]: tmp.F599d8dnXW#fnref:33 +[79]: tmp.F599d8dnXW#fnref:34 +[80]: tmp.F599d8dnXW#fnref:35 +[81]: tmp.F599d8dnXW#fnref:36 +[82]: tmp.F599d8dnXW#fnref:37 diff --git a/sources/talk/20180916 The Rise and Demise of RSS.md b/sources/talk/20180916 The Rise and Demise of RSS.md deleted file mode 100644 index 8511d220d9..0000000000 --- a/sources/talk/20180916 The Rise and Demise of RSS.md +++ /dev/null @@ -1,122 +0,0 @@ -The Rise and Demise of RSS -====== -There are two stories here. The first is a story about a vision of the web’s future that never quite came to fruition. The second is a story about how a collaborative effort to improve a popular standard devolved into one of the most contentious forks in the history of open-source software development. - -In the late 1990s, in the go-go years between Netscape’s IPO and the Dot-com crash, everyone could see that the web was going to be an even bigger deal than it already was, even if they didn’t know exactly how it was going to get there. One theory was that the web was about to be revolutionized by syndication. The web, originally built to enable a simple transaction between two parties—a client fetching a document from a single host server—would be broken open by new standards that could be used to repackage and redistribute entire websites through a variety of channels. Kevin Werbach, writing for Release 1.0, a newsletter influential among investors in the 1990s, predicted that syndication “would evolve into the core model for the Internet economy, allowing businesses and individuals to retain control over their online personae while enjoying the benefits of massive scale and scope.” He invited his readers to imagine a future in which fencing aficionados, rather than going directly to an “online sporting goods site” or “fencing equipment retailer,” could buy a new épée directly through e-commerce widgets embedded into their favorite website about fencing. Just like in the television world, where big networks syndicate their shows to smaller local stations, syndication on the web would allow businesses and publications to reach consumers through a multitude of intermediary sites. This would mean, as a corollary, that consumers would gain significant control over where and how they interacted with any given business or publication on the web. - -RSS was one of the standards that promised to deliver this syndicated future. To Werbach, RSS was “the leading example of a lightweight syndication protocol.” Another contemporaneous article called RSS the first protocol to realize the potential of XML. It was going to be a way for both users and content aggregators to create their own customized channels out of everything the web had to offer. And yet, two decades later, RSS [appears to be a dying technology][1], now used chiefly by podcasters and programmers with tech blogs. Moreover, among that latter group, RSS is perhaps used as much for its political symbolism as its actual utility. Though of course some people really do have RSS readers, stubbornly adding an RSS feed to your blog, even in 2018, is a reactionary statement. That little tangerine bubble has become a wistful symbol of defiance against a centralized web increasingly controlled by a handful of corporations, a web that hardly resembles the syndicated web of Werbach’s imagining. - -The future once looked so bright for RSS. What happened? Was its downfall inevitable, or was it precipitated by the bitter infighting that thwarted the development of a single RSS standard? - -### Muddied Water - -RSS was invented twice. This meant it never had an obvious owner, a state of affairs that spawned endless debate and acrimony. But it also suggests that RSS was an important idea whose time had come. - -In 1998, Netscape was struggling to envision a future for itself. Its flagship product, the Netscape Navigator web browser—once preferred by 80% of web users—was quickly losing ground to Internet Explorer. So Netscape decided to compete in a new arena. In May, a team was brought together to start work on what was known internally as “Project 60.” Two months later, Netscape announced “My Netscape,” a web portal that would fight it out with other portals like Yahoo, MSN, and Excite. - -The following year, in March, Netscape announced an addition to the My Netscape portal called the “My Netscape Network.” My Netscape users could now customize their My Netscape page so that it contained “channels” featuring the most recent headlines from sites around the web. As long as your favorite website published a special file in a format dictated by Netscape, you could add that website to your My Netscape page, typically by clicking an “Add Channel” button that participating websites were supposed to add to their interfaces. A little box containing a list of linked headlines would then appear. - -![A My Netscape Network Channel][2] - -The special file that participating websites had to publish was an RSS file. In the My Netscape Network announcement, Netscape explained that RSS stood for “RDF Site Summary.” This was somewhat of a misnomer. RDF, or the Resource Description Framework, is basically a grammar for describing certain properties of arbitrary resources. (See [my article about the Semantic Web][3] if that sounds really exciting to you.) In 1999, a draft specification for RDF was being considered by the W3C. Though RSS was supposed to be based on RDF, the example RSS document Netscape actually released didn’t use any RDF tags at all, even if it declared the RDF XML namespace. In a document that accompanied the Netscape RSS specification, Dan Libby, one of the specification’s authors, explained that “in this release of MNN, Netscape has intentionally limited the complexity of the RSS format.” The specification was given the 0.90 version number, the idea being that subsequent versions would bring RSS more in line with the W3C’s XML specification and the evolving draft of the RDF specification. - -RSS had been cooked up by Libby and another Netscape employee, Ramanathan Guha. Guha previously worked for Apple, where he came up with something called the Meta Content Framework. MCF was a format for representing metadata about anything from web pages to local files. Guha demonstrated its power by developing an application called [HotSauce][4] that visualized relationships between files as a network of nodes suspended in 3D space. After leaving Apple for Netscape, Guha worked with a Netscape consultant named Tim Bray to produce an XML-based version of MCF, which in turn became the foundation for the W3C’s RDF draft. It’s no surprise, then, that Guha and Libby were keen to incorporate RDF into RSS. But Libby later wrote that the original vision for an RDF-based RSS was pared back because of time constraints and the perception that RDF was “‘too complex’ for the ‘average user.’” - -While Netscape was trying to win eyeballs in what became known as the “portal wars,” elsewhere on the web a new phenomenon known as “weblogging” was being pioneered. One of these pioneers was Dave Winer, CEO of a company called UserLand Software, which developed early content management systems that made blogging accessible to people without deep technical fluency. Winer ran his own blog, [Scripting News][5], which today is one of the oldest blogs on the internet. More than a year before Netscape announced My Netscape Network, on December 15th, 1997, Winer published a post announcing that the blog would now be available in XML as well as HTML. - -Dave Winer’s XML format became known as the Scripting News format. It was supposedly similar to Microsoft’s Channel Definition Format (a “push technology” standard submitted to the W3C in March, 1997), but I haven’t been able to find a file in the original format to verify that claim. Like Netscape’s RSS, it structured the content of Winer’s blog so that it could be understood by other software applications. When Netscape released RSS 0.90, Winer and UserLand Software began to support both formats. But Winer believed that Netscape’s format was “woefully inadequate” and “missing the key thing web writers and readers need.” It could only represent a list of links, whereas the Scripting News format could represent a series of paragraphs, each containing one or more links. - -In June, 1999, two months after Netscape’s My Netscape Network announcement, Winer introduced a new version of the Scripting News format, called ScriptingNews 2.0b1. Winer claimed that he decided to move ahead with his own format only after trying but failing to get anyone at Netscape to care about RSS 0.90’s deficiencies. The new version of the Scripting News format added several items to the `
` element that brought the Scripting News format to parity with RSS. But the two formats continued to differ in that the Scripting News format, which Winer nicknamed the “fat” syndication format, could include entire paragraphs and not just links. - -Netscape got around to releasing RSS 0.91 the very next month. The updated specification was a major about-face. RSS no longer stood for “RDF Site Summary”; it now stood for “Rich Site Summary.” All the RDF—and there was almost none anyway—was stripped out. Many of the Scripting News tags were incorporated. In the text of the new specification, Libby explained: - -> RDF references removed. RSS was originally conceived as a metadata format providing a summary of a website. Two things have become clear: the first is that providers want more of a syndication format than a metadata format. The structure of an RDF file is very precise and must conform to the RDF data model in order to be valid. This is not easily human-understandable and can make it difficult to create useful RDF files. The second is that few tools are available for RDF generation, validation and processing. For these reasons, we have decided to go with a standard XML approach. - -Winer was enormously pleased with RSS 0.91, calling it “even better than I thought it would be.” UserLand Software adopted it as a replacement for the existing ScriptingNews 2.0b1 format. For a while, it seemed that RSS finally had a single authoritative specification. - -### The Great Fork - -A year later, the RSS 0.91 specification had become woefully inadequate. There were all sorts of things people were trying to do with RSS that the specification did not address. There were other parts of the specification that seemed unnecessarily constraining—each RSS channel could only contain a maximum of 15 items, for example. - -By that point, RSS had been adopted by several more organizations. Other than Netscape, which seemed to have lost interest after RSS 0.91, the big players were Dave Winer’s UserLand Software; O’Reilly Net, which ran an RSS aggregator called Meerkat; and Moreover.com, which also ran an RSS aggregator focused on news. Via mailing list, representatives from these organizations and others regularly discussed how to improve on RSS 0.91. But there were deep disagreements about what those improvements should look like. - -The mailing list in which most of the discussion occurred was called the Syndication mailing list. [An archive of the Syndication mailing list][6] is still available. It is an amazing historical resource. It provides a moment-by-moment account of how those deep disagreements eventually led to a political rupture of the RSS community. - -On one side of the coming rupture was Winer. Winer was impatient to evolve RSS, but he wanted to change it only in relatively conservative ways. In June, 2000, he published his own RSS 0.91 specification on the UserLand website, meant to be a starting point for further development of RSS. It made no significant changes to the 0.91 specification published by Netscape. Winer claimed in a blog post that accompanied his specification that it was only a “cleanup” documenting how RSS was actually being used in the wild, which was needed because the Netscape specification was no longer being maintained. In the same post, he argued that RSS had succeeded so far because it was simple, and that by adding namespaces or RDF back to the format—some had suggested this be done in the Syndication mailing list—it “would become vastly more complex, and IMHO, at the content provider level, would buy us almost nothing for the added complexity.” In a message to the Syndication mailing list sent around the same time, Winer suggested that these issues were important enough that they might lead him to create a fork: - -> I’m still pondering how to move RSS forward. I definitely want ICE-like stuff in RSS2, publish and subscribe is at the top of my list, but I am going to fight tooth and nail for simplicity. I love optional elements. I don’t want to go down the namespaces and schema road, or try to make it a dialect of RDF. I understand other people want to do this, and therefore I guess we’re going to get a fork. I have my own opinion about where the other fork will lead, but I’ll keep those to myself for the moment at least. - -Arrayed against Winer were several other people, including Rael Dornfest of O’Reilly, Ian Davis (responsible for a search startup called Calaba), and a precocious, 14-year-old Aaron Swartz, who all thought that RSS needed namespaces in order to accommodate the many different things everyone wanted to do with it. On another mailing list hosted by O’Reilly, Davis proposed a namespace-based module system, writing that such a system would “make RSS as extensible as we like rather than packing in new features that over-complicate the spec.” The “namespace camp” believed that RSS would soon be used for much more than the syndication of blog posts, so namespaces, rather than being a complication, were the only way to keep RSS from becoming unmanageable as it supported more and more use cases. - -At the root of this disagreement about namespaces was a deeper disagreement about what RSS was even for. Winer had invented his Scripting News format to syndicate the posts he wrote for his blog. Guha and Libby at Netscape had designed RSS and called it “RDF Site Summary” because in their minds it was a way of recreating a site in miniature within Netscape’s online portal. Davis, writing to the Syndication mailing list, explained his view that RSS was “originally conceived as a way of building mini sitemaps,” and that now he and others wanted to expand RSS “to encompass more types of information than simple news headlines and to cater for the new uses of RSS that have emerged over the last 12 months.” Winer wrote a prickly reply, stating that his Scripting News format was in fact the original RSS and that it had been meant for a different purpose. Given that the people most involved in the development of RSS disagreed about why RSS had even been created, a fork seems to have been inevitable. - -The fork happened after Dornfest announced a proposed RSS 1.0 specification and formed the RSS-DEV Working Group—which would include Davis, Swartz, and several others but not Winer—to get it ready for publication. In the proposed specification, RSS once again stood for “RDF Site Summary,” because RDF had had been added back in to represent metadata properties of certain RSS elements. The specification acknowledged Winer by name, giving him credit for popularizing RSS through his “evangelism.” But it also argued that just adding more elements to RSS without providing for extensibility with a module system—that is, what Winer was suggesting—”sacrifices scalability.” The specification went on to define a module system for RSS based on XML namespaces. - -Winer was furious that the RSS-DEV Working Group had arrogated the “RSS 1.0” name for themselves. In another mailing list about decentralization, he described what the RSS-DEV Working Group had done as theft. Other members of the Syndication mailing list also felt that the RSS-DEV Working Group should not have used the name “RSS” without unanimous agreement from the community on how to move RSS forward. But the Working Group stuck with the name. Dan Brickley, another member of the RSS-DEV Working Group, defended this decision by arguing that “RSS 1.0 as proposed is solidly grounded in the original RSS vision, which itself had a long heritage going back to MCF (an RDF precursor) and related specs (CDF etc).” He essentially felt that the RSS 1.0 effort had a better claim to the RSS name than Winer did, since RDF had originally been a part of RSS. The RSS-DEV Working Group published a final version of their specification in December. That same month, Winer published his own improvement to RSS 0.91, which he called RSS 0.92, on UserLand’s website. RSS 0.92 made several small optional improvements to RSS, among which was the addition of the `` tag soon used by podcasters everywhere. RSS had officially forked. - -It’s not clear to me why a better effort was not made to involve Winer in the RSS-DEV Working Group. He was a prominent contributor to the Syndication mailing list and obviously responsible for much of RSS’ popularity, as the members of the Working Group themselves acknowledged. But Tim O’Reilly, founder and CEO of O’Reilly, explained in a UserLand discussion group that Winer more or less refused to participate: - -> A group of people involved in RSS got together to start thinking about its future evolution. Dave was part of the group. When the consensus of the group turned in a direction he didn’t like, Dave stopped participating, and characterized it as a plot by O’Reilly to take over RSS from him, despite the fact that Rael Dornfest of O’Reilly was only one of about a dozen authors of the proposed RSS 1.0 spec, and that many of those who were part of its development had at least as long a history with RSS as Dave had. - -To this, Winer said: - -> I met with Dale [Dougherty] two weeks before the announcement, and he didn’t say anything about it being called RSS 1.0. I spoke on the phone with Rael the Friday before it was announced, again he didn’t say that they were calling it RSS 1.0. The first I found out about it was when it was publicly announced. -> -> Let me ask you a straight question. If it turns out that the plan to call the new spec “RSS 1.0” was done in private, without any heads-up or consultation, or for a chance for the Syndication list members to agree or disagree, not just me, what are you going to do? -> -> UserLand did a lot of work to create and popularize and support RSS. We walked away from that, and let your guys have the name. That’s the top level. If I want to do any further work in Web syndication, I have to use a different name. Why and how did that happen Tim? - -I have not been able to find a discussion in the Syndication mailing list about using the RSS 1.0 name prior to the announcement of the RSS 1.0 proposal. - -RSS would fork again in 2003, when several developers frustrated with the bickering in the RSS community sought to create an entirely new format. These developers created Atom, a format that did away with RDF but embraced XML namespaces. Atom would eventually be specified by [a proposed IETF standard][7]. After the introduction of Atom, there were three competing versions of RSS: Winer’s RSS 0.92 (updated to RSS 2.0 in 2002 and renamed “Really Simple Syndication”), the RSS-DEV Working Group’s RSS 1.0, and Atom. - -### Decline - -The proliferation of competing RSS specifications may have hampered RSS in other ways that I’ll discuss shortly. But it did not stop RSS from becoming enormously popular during the 2000s. By 2004, the New York Times had started offering its headlines in RSS and had written an article explaining to the layperson what RSS was and how to use it. Google Reader, an RSS aggregator ultimately used by millions, was launched in 2005. By 2013, RSS seemed popular enough that the New York Times, in its obituary for Aaron Swartz, called the technology “ubiquitous.” For a while, before a third of the planet had signed up for Facebook, RSS was simply how many people stayed abreast of news on the internet. - -The New York Times published Swartz’ obituary in January, 2013. By that point, though, RSS had actually turned a corner and was well on its way to becoming an obscure technology. Google Reader was shutdown in July, 2013, ostensibly because user numbers had been falling “over the years.” This prompted several articles from various outlets declaring that RSS was dead. But people had been declaring that RSS was dead for years, even before Google Reader’s shuttering. Steve Gillmor, writing for TechCrunch in May, 2009, advised that “it’s time to get completely off RSS and switch to Twitter” because “RSS just doesn’t cut it anymore.” He pointed out that Twitter was basically a better RSS feed, since it could show you what people thought about an article in addition to the article itself. It allowed you to follow people and not just channels. Gillmor told his readers that it was time to let RSS recede into the background. He ended his article with a verse from Bob Dylan’s “Forever Young.” - -Today, RSS is not dead. But neither is it anywhere near as popular as it once was. Lots of people have offered explanations for why RSS lost its broad appeal. Perhaps the most persuasive explanation is exactly the one offered by Gillmor in 2009. Social networks, just like RSS, provide a feed featuring all the latest news on the internet. Social networks took over from RSS because they were simply better feeds. They also provide more benefits to the companies that own them. Some people have accused Google, for example, of shutting down Google Reader in order to encourage people to use Google+. Google might have been able to monetize Google+ in a way that it could never have monetized Google Reader. Marco Arment, the creator of Instapaper, wrote on his blog in 2013: - -> Google Reader is just the latest casualty of the war that Facebook started, seemingly accidentally: the battle to own everything. While Google did technically “own” Reader and could make some use of the huge amount of news and attention data flowing through it, it conflicted with their far more important Google+ strategy: they need everyone reading and sharing everything through Google+ so they can compete with Facebook for ad-targeting data, ad dollars, growth, and relevance. - -So both users and technology companies realized that they got more out of using social networks than they did out of RSS. - -Another theory is that RSS was always too geeky for regular people. Even the New York Times, which seems to have been eager to adopt RSS and promote it to its audience, complained in 2006 that RSS is a “not particularly user friendly” acronym coined by “computer geeks.” Before the RSS icon was designed in 2004, websites like the New York Times linked to their RSS feeds using little orange boxes labeled “XML,” which can only have been intimidating. The label was perfectly accurate though, because back then clicking the link would take a hapless user to a page full of XML. [This great tweet][8] captures the essence of this explanation for RSS’ demise. Regular people never felt comfortable using RSS; it hadn’t really been designed as a consumer-facing technology and involved too many hurdles; people jumped ship as soon as something better came along. - -RSS might have been able to overcome some of these limitations if it had been further developed. Maybe RSS could have been extended somehow so that friends subscribed to the same channel could syndicate their thoughts about an article to each other. But whereas a company like Facebook was able to “move fast and break things,” the RSS developer community was stuck trying to achieve consensus. The Great RSS Fork only demonstrates how difficult it was to do that. So if we are asking ourselves why RSS is no longer popular, a good first-order explanation is that social networks supplanted it. If we ask ourselves why social networks were able to supplant it, then the answer may be that the people trying to make RSS succeed faced a problem much harder than, say, building Facebook. As Dornfest wrote to the Syndication mailing list at one point, “currently it’s the politics far more than the serialization that’s far from simple.” - -So today we are left with centralized silos of information. In a way, we do have the syndicated internet that Kevin Werbach foresaw in 1999. After all, The Onion is a publication that relies on syndication through Facebook and Twitter the same way that Seinfeld relied on syndication to rake in millions after the end of its original run. But syndication on the web only happens through one of a very small number of channels, meaning that none of us “retain control over our online personae” the way that Werbach thought we would. One reason this happened is garden-variety corporate rapaciousness—RSS, an open format, didn’t give technology companies the control over data and eyeballs that they needed to sell ads, so they did not support it. But the more mundane reason is that centralized silos are just easier to design than common standards. Consensus is difficult to achieve and it takes time, but without consensus spurned developers will go off and create competing standards. The lesson here may be that if we want to see a better, more open web, we have to get better at not screwing each other over. - -If you enjoyed this post, more like it come out every two weeks! Follow [@TwoBitHistory][9] on Twitter or subscribe to the [RSS feed][10] to make sure you know when a new post is out. - -Previously on TwoBitHistory… - -> New post: This week we're traveling back in time in our DeLorean to see what it was like learning to program on early home computers. -> -> — TwoBitHistory (@TwoBitHistory) [September 2, 2018][11] - --------------------------------------------------------------------------------- - -via: https://twobithistory.org/2018/09/16/the-rise-and-demise-of-rss.html - -作者:[Two-Bit History][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://twobithistory.org -[b]: https://github.com/lujun9972 -[1]: https://trends.google.com/trends/explore?date=all&geo=US&q=rss -[2]: https://twobithistory.org/images/mnn-channel.gif -[3]: https://twobithistory.org/2018/05/27/semantic-web.html -[4]: http://web.archive.org/web/19970703020212/http://mcf.research.apple.com:80/hs/screen_shot.html -[5]: http://scripting.com/ -[6]: https://groups.yahoo.com/neo/groups/syndication/info -[7]: https://tools.ietf.org/html/rfc4287 -[8]: https://twitter.com/mgsiegler/status/311992206716203008 -[9]: https://twitter.com/TwoBitHistory -[10]: https://twobithistory.org/feed.xml -[11]: https://twitter.com/TwoBitHistory/status/1036295112375115778?ref_src=twsrc%5Etfw diff --git a/sources/talk/20181004 Interview With Peter Ganten, CEO of Univention GmbH.md b/sources/talk/20181004 Interview With Peter Ganten, CEO of Univention GmbH.md deleted file mode 100644 index 5a0c1aabdd..0000000000 --- a/sources/talk/20181004 Interview With Peter Ganten, CEO of Univention GmbH.md +++ /dev/null @@ -1,97 +0,0 @@ -Interview With Peter Ganten, CEO of Univention GmbH -====== -I have been asking the Univention team to share the behind-the-scenes story of [**Univention**][1] for a couple of months. Finally, today we got the interview of **Mr. Peter H. Ganten** , CEO of Univention GmbH. Despite his busy schedule, in this interview, he shares what he thinks of the Univention project and its impact on open source ecosystem, what open source developers and companies will need to do to keep thriving and what are the biggest challenges for open source projects. - -**OSTechNix: What’s your background and why have you founded Univention?** - -**Peter Ganten:** I studied physics and psychology. In psychology I was a research assistant and coded evaluation software. I realized how important it is that results have to be disclosed in order to verify or falsify them. The same goes for the code that leads to the results. This brought me into contact with Open Source Software (OSS) and Linux. - -![](https://www.ostechnix.com/wp-content/uploads/2018/10/peter-ganten-interview.jpg) - -I was a kind of technical lab manager and I had the opportunity to try out a lot, which led to my book about Debian. That was still in the New Economy era where the first business models emerged on how to make money with Open Source. When the bubble burst, I had the plan to make OSS a solid business model without venture capital but with Hanseatic business style – seriously, steadily, no bling bling. - -**What were the biggest challenges at the beginning?** - -When I came from the university, the biggest challenge clearly was to gain entrepreneurial and business management knowledge. I quickly learned that it’s not about Open Source software as an end to itself but always about customer value, and the benefits OSS offers its customers. We all had to learn a lot. - -In the beginning, we expected that Linux on the desktop would become established in a similar way as Linux on the server. However, this has not yet been proven true. The replacement has happened with Android and the iPhone. Our conclusion then was to change our offerings towards ID management and enterprise servers. - -**Why does UCS matter? And for whom makes it sense to use it?** - -There is cool OSS in all areas, but many organizations are not capable to combine it all together and make it manageable. For the basic infrastructure (Windows desktops, users, user rights, roles, ID management, apps) we need a central instance to which groupware, CRM etc. is connected. Without Univention this would have to be laboriously assembled and maintained manually. This is possible for very large companies, but far too complex for many other organizations. - -[**UCS**][2] can be used out of the box and is scalable. That’s why it’s becoming more and more popular – more than 10,000 organizations are using UCS already today. - -**Who are your users and most important clients? What do they love most about UCS?** - -The Core Edition is free of charge and used by organizations from all sectors and industries such as associations, micro-enterprises, universities or large organizations with thousands of users. In the enterprise environment, where Long Term Servicing (LTS) and professional support are particularly important, we have organizations ranging in size from 30-50 users to several thousand users. One of the target groups is the education system in Germany. In many large cities and within their school administrations UCS is used, for example, in Cologne, Hannover, Bremen, Kassel and in several federal states. They are looking for manageable IT and apps for schools. That’s what we offer, because we can guarantee these authorities full control over their users’ identities. - -Also, more and more cloud service providers and MSPs want to take UCS to deliver a selection of cloud-based app solutions. - -**Is UCS 100% Open Source? If so, how can you run a profitable business selling it?** - -Yes, UCS is 100% Open Source, every line, the whole code is OSS. You can download and use UCS Core Edition for **FREE!** - -We know that in large, complex organizations, vendor support and liability is needed for LTS, SLAs, and we offer that with our Enterprise subscriptions and consulting services. We don’t offer these in the Core Edition. - -**And what are you giving back to the OS community?** - -A lot. We are involved in the Debian team and co-finance the LTS maintenance for Debian. For important OS components in UCS like [**OpenLDAP**][3], Samba or KVM we co-finance the development or have co-developed them ourselves. We make it all freely available. - -We are also involved on the political level in ensuring that OSS is used. We are engaged, for example, in the [**Free Software Foundation Europe (FSFE)**][4] and the [**German Open Source Business Alliance**][5], of which I am the chairman. We are working hard to make OSS more successful. - -**How can I get started with UCS?** - -It’s easy to get started with the Core Edition, which, like the Enterprise Edition, has an App Center and can be easily installed on your own hardware or as an appliance in a virtual machine. Just [**download Univention ISO**][6] and install it as described in the below link. - -Alternatively, you can try the [**UCS Online Demo**][7] to get a first impression of Univention Corporate Server without actually installing it on your system. - -**What do you think are the biggest challenges for Open Source?** - -There is a certain attitude you can see over and over again even in bigger projects: OSS alone is viewed as an almost mandatory prerequisite for a good, sustainable, secure and trustworthy IT solution – but just having decided to use OSS is no guarantee for success. You have to carry out projects professionally and cooperate with the manufacturers. A danger is that in complex projects people think: “Oh, OSS is free, I just put it all together by myself”. But normally you do not have the know-how to successfully implement complex software solutions. You would never proceed like this with Closed Source. There people think: “Oh, the software costs 3 $ millions, so it’s okay if I have to spend another 300,000 Dollars on consultants.” - -At OSS this is different. If such projects fail and leave burnt ground behind, we have to explain again and again that the failure of such projects is not due to the nature of OSS but to its poor implementation and organization in a specific project: You have to conclude reasonable contracts and involve partners as in the proprietary world, but you’ll gain a better solution. - -Another challenge: We must stay innovative, move forward, attract new people who are enthusiastic about working on projects. That’s sometimes a challenge. For example, there are a number of proprietary cloud services that are good but lead to extremely high dependency. There are approaches to alternatives in OSS, but no suitable business models yet. So it’s hard to find and fund developers. For example, I can think of Evernote and OneNote for which there is no reasonable OSS alternative. - -**And what will the future bring for Univention?** - -I don’t have a crystal ball, but we are extremely optimistic. We see a very high growth potential in the education market. More OSS is being made in the public sector, because we have repeatedly experienced the dead ends that can be reached if we solely rely on Closed Source. - -Overall, we will continue our organic growth at double-digit rates year after year. - -UCS and its core functionalities of identity management, infrastructure management and app center will increasingly be offered and used from the cloud as a managed service. We will support our technology in this direction, e.g., through containers, so that a hypervisor or bare metal is not always necessary for operation. - -**You have been the CEO of Univention for a long time. What keeps you motivated?** - -I have been the CEO of Univention for more than 16 years now. My biggest motivation is to realize that something is moving. That we offer the better way for IT. That the people who go this way with us are excited to work with us. I go home satisfied in the evening (of course not every evening). It’s totally cool to work with the team I have. It motivates and pushes you every time I need it myself. - -I’m a techie and nerd at heart, I enjoy dealing with technology. So I’m totally happy at this place and I’m grateful to the world that I can do whatever I want every day. Not everyone can say that. - -**Who gives you inspiration?** - -My employees, the customers and the Open Source projects. The exchange with other people. - -The motivation behind everything is that we want to make sure that mankind will be able to influence and change the IT that surrounds us today and in the future just the way we want it and we thinks it’s good. We want to make a contribution to this. That is why Univention is there. That is important to us every day. - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/interview-with-peter-ganten-ceo-of-univention-gmbh/ - -作者:[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/introduction-univention-corporate-server/ -[2]: https://www.univention.com/products/ucs/ -[3]: https://www.ostechnix.com/redhat-and-suse-announced-to-withdraw-support-for-openldap/ -[4]: https://fsfe.org/ -[5]: https://osb-alliance.de/ -[6]: https://www.univention.com/downloads/download-ucs/ -[7]: https://www.univention.com/downloads/ucs-online-demo/ diff --git a/sources/talk/20181007 Why it-s Easier to Get a Payrise by Switching Jobs.md b/sources/talk/20181007 Why it-s Easier to Get a Payrise by Switching Jobs.md new file mode 100644 index 0000000000..3baf2f7126 --- /dev/null +++ b/sources/talk/20181007 Why it-s Easier to Get a Payrise by Switching Jobs.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why it's Easier to Get a Payrise by Switching Jobs) +[#]: via: (https://theartofmachinery.com/2018/10/07/payrise_by_switching_jobs.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +Why it's Easier to Get a Payrise by Switching Jobs +====== + +It’s an empirical fact that it’s easier to get a payrise if you’re negotiating a new job than if you’re negotiating within your current job. When I look back over my own career, every time I’ve worked somewhere longer term (over a year), payrises have been a hard struggle. But eventually I’d leave for a new position, and my new pay made all payrises at the previous job irrelevant. These days I make job switching upfront and official: I run my own business and most of my money comes from short contracts. Getting rewarded for new skills or extra work is nowhere near as difficult as before. + +I know I’m not the only one to notice this effect, but I’ve never heard anyone explain why things might be this way. + +Before I give my explanation, let me make a couple of things clear from the start. I’m not going to argue that everyone should quit their jobs. I don’t know your situation, and maybe you’re getting a good deal already. Also, I apply game theory here, but, no, I don’t assume that humans are slaves to simplistic, mechanical laws of behaviour. However, just like music composition, even if humans are free, there are still patterns that matter. If you understand this stuff, you’ll have a career advantage. + +But first, some background. + +### BATNA + +Many geeks think negotiation is like a role-playing game: roll the die, add your charisma score, and if the result is high enough you’re convincing. Geeks who think that way usually have low confidence in their “charisma score”, and they blame that for their struggle with things like asking for payrises. + +Charisma isn’t totally irrelevant, but the good news for geeks is that there’s a nerdy thing that’s much more important for negotiation: BATNA, or Best Alternative To Negotiated Agreement. Despite the jargony name, it’s a very simple idea: it’s about analysing the best outcome for both sides in a negotiation, assuming that at least one side says no to the other. Although most people don’t know it’s called “BATNA”, it’s the core of how any agreement works (or doesn’t work). + +It’s easy to explain with an example. Imagine you buy a couch for $500, but when you take it home, you discover that it doesn’t fit the place you wanted to put it. A silly mistake, but thankfully the shop offers you a full refund if you return it. Just as you’re taking it back to the shop, you meet a stranger who says they want a couch like that, and they offer to buy it. What’s the price? If you ask for $1000,000, the deal won’t happen because their BATNA is that they go to the shop and buy one themselves for $500. If they offer $1 to buy, your BATNA is that you go to the shop and get the $500 refund. You’ll only come to an agreement if the price is something like $500. If transporting the couch to the shop costs significant time and money, you’ll accept less than $500 because your BATNA is worth $500 minus the cost of transport. On the other hand, if the stranger needs to cover up a stained carpet before the landlord does an inspection in half an hour, they’ll be willing to pay a heavy premium because their BATNA is so bad. + +You can’t expect a negotiation to go well unless you’ve considered the BATNA of both sides. + +### Employment and Self-Employment + +Most people of a certain socioeconomic class believe that the ideal, “proper” career is salaried, full-time employment at someone else’s business. Many people in this class never even imagine any other way to make a living, but there are alternatives. In Australia, like other countries, you’re free to register your own business number and then do whatever it is that people will pay for. That includes sitting at a desk and working on software and computer systems, or other work that’s more commonly done as an employee. + +So why is salaried employment so popular? As someone who’s done both kinds of employment, one answer is obvious: stability. You can be (mostly) sure about exactly how much money you’ll make in the next six months when you have a salary. The next obvious answer is simplicity: as long as you meet the minimum bar of “work” done ([whatever “work” means][1]), the company promises to look after you. You don’t have to think about where your next dollar comes from, or about marketing, or insurances, or accounting, or even how to find people to socialise with. + +That sums up the main reasons to like salaried employment (not that they’re bad reasons). I sometimes hear claims about other benefits of salaried employment, but they’re typically things that you can buy. If you’re self-employed and your work isn’t paying you enough to have the same lifestyle as you could under a salary (doing the same work) that means you’re not billing high enough. A lot of people make that mistake when they quit a salaried job for self-employment, but it’s still just a mistake. + +### Asking for that Payrise + +Let’s say you’ve been working as a salaried employee at a company for a while. As a curious, self-motivated person who regularly reads essays by nerds on the internet, you’ve learned a lot in that time. You’ve applied your new skills to your work, and proven yourself to be a much more valuable employee than when you were first hired. Is it time to ask for a payrise? You practise your most charismatic phrasing, and approach your manager with your d20 in hand. The response is that you’re doing great, and they’d love to give you a payrise, but the rules say + + 1. You can’t get a payrise unless you’ve been working for more than N years + 2. You can’t get more than one payrise in N years + 3. That inflation adjustment on your salary counted as a payrise, so you can’t ask for a payrise now + 4. You can’t be paid more than [Peter][2] + 5. We need more time to see if you’re ready, so keep up the great work for another year or so and we’ll consider it then + + + +The thing to realise is that all these rules are completely arbitrary. If the company had a genuine motivation to give you a payrise, the rules would vanish. To see that, try replacing “payrise” with “workload increase”. Software projects are extremely expensive, require skill, and have a high failure rate. Software work therefore carries a non-trivial amount of responsibility, so you might argue that employers should be very conservative about increasing how much involvement someone has in a project. But I’ve never heard an employer say anything like, “Great job on getting that last task completed ahead of schedule, but we need more time to see if you’re ready to increase your workload. Just take a break until the next scheduled task, and if you do well at that one, too, maybe we can start giving you more work to do.” + +If you’re hearing feedback that you’re doing well, but there are various arbitrary reasons you can’t get rewarded for it, that’s a strong sign you’re being paid below market rates. Now, the term “market rates” gets used pretty loosely, so let me be super clear: that means someone else would agree to pay you more if you asked. + +Note that I’m not claiming that your manager is evil. At most larger companies, your manager really can’t do much against the company rules. I’m not writing this to call companies evil, either, because that won’t help you or me to get any payrises. What _will_ help is understanding why companies can afford to make payrises difficult. + +### Getting that Payrise + +You’ve probably seen this coming: it’s all about BATNA, and how you can’t expect your employer to agree to something that’s worse than their BATNA. So, what’s their BATNA? What happens if you ask for a payrise, and they say no? + +Sometimes you see a story online about someone who was burning themselves out working super hard as an obviously vital member of a team. This person asks for a small payrise and gets rejected for some silly reason. Shortly after that, they tell their employer that they have a much bigger offer from another company. Suddenly the reason for rejecting the payrise evaporates, and the employer comes up with a counteroffer, but it’s too late: the worker leaves for a better job. The original employer is left wailing and gnashing their teeth. If only companies appreciated their employees more! + +These stories are like hero stories in the movies. They tickle our sense of justice, but aren’t exactly representative of normal life. The reality is that most employees would just go back to their desks if they’re told, “No.” Sure, they’ll grumble, and they’ll upvote the next “Tech workers are underappreciated!” post on Reddit, but to many companies this is a completely acceptable BATNA. + +In short, the main bargaining chip a salaried employee has is quitting, but that negates the reasons to be a salaried employee in the first place. + +When you’re negotiating a contract with a new potential employer, however, the situation is totally different. Whatever conditions you ask for will be compared against the BATNA of searching for someone else who has your skills. Any reasonable request has a much higher chance of being accepted. + +### The Job Security Tax + +Now, something might be bothering you: despite what I’ve said, people _do_ get payrises. But all I’ve argued is that companies can make payrises difficult, not impossible. Sure, salaried employees might not quit when they’re a little underpaid. (They might not even realise they’re underpaid.) But if the underpayment gets big and obvious enough, maybe they will, so employers have to give out payrises eventually. Occasional payrises also make a good carrot for encouraging employees to keep working harder. + +At the scale of a large company, it’s just a matter of tuning. Payrises can be delayed a little here, and made a bit smaller there, and the company saves money. Go too far, and the employee attrition rate goes up, which is a sign to back off and start paying more again. + +Sure, the employee’s salary will tend to grow as their skills grow, but that growth will be slowed down. How much it is slowed down will depend (long term) on how strongly the employee values job security. It’s a job security tax. + +### What Should You Do? + +As I said before, I’m not going to tell you to quit (or not quit) without knowing what your situation is. + +Perhaps you read this thinking that it sounds nothing like your workplace. If so, you’re lucky to be in one of the better places. You now have solid reasons to appreciate your employer as much as they appreciate you. + +For the rest of you, I guess there are two broad options. Obviously, there’s the one I’m taking: not being a salaried employee. The other option is to understand the job security tax and try to optimise it. If you’re young and single, maybe you don’t need job security so much (at least for now). Even if you have good reasons to want job security (and there are plenty), maybe you can reduce your dependence on it by saving money in an emergency fund, and making sure your friendship group includes people who aren’t your current colleagues. That’s a good idea even if you aren’t planning to quit today — you never know what the future will be like. + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2018/10/07/payrise_by_switching_jobs.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: /2017/09/14/busywork.html +[2]: https://www.youtube.com/watch?v=zBfTrjPSShs diff --git a/sources/talk/20181024 Why it matters that Microsoft released old versions of MS-DOS as open source.md b/sources/talk/20181024 Why it matters that Microsoft released old versions of MS-DOS as open source.md deleted file mode 100644 index 3129e4b6f0..0000000000 --- a/sources/talk/20181024 Why it matters that Microsoft released old versions of MS-DOS as open source.md +++ /dev/null @@ -1,74 +0,0 @@ -Why it matters that Microsoft released old versions of MS-DOS as open source -====== - -Microsoft's release of MS-DOS 1.25 and 2.0 on GitHub adopts an open source license that's compatible with GNU GPL. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/open_business_sign_store.jpg?itok=g4QibRqg) - -One open source software project I work on is the FreeDOS Project. It's a complete, free, DOS-compatible operating system that you can use to play classic DOS games, run legacy business software, or develop embedded systems. Any program that works on MS-DOS should also run on FreeDOS. - -So I took notice when Microsoft recently released the source code to MS-DOS 1.25 and 2.0 via a [GitHub repository][1]. This is a huge step for Microsoft, and I’d like to briefly explain why it is significant. - -### MS-DOS as open source software - -Some open source fans may recall that this is not the first time Microsoft has officially released the MS-DOS source code. On March 25, 2014, Microsoft posted the source code to MS-DOS 1.1 and 2.0 via the [Computer History Museum][2]. Unfortunately, this source code was released under a “look but do not touch” license that limited what you could do with it. According to the license from the 2014 source code release, users were barred from re-using it in other projects and could use it “[solely for non-commercial research, experimentation, and educational purposes.][3]” - -The museum license wasn’t friendly to open source software, and as a result, the MS-DOS source code was ignored. On the FreeDOS Project, we interpreted the “look but do not touch” license as a potential risk to FreeDOS, so we decided developers who had viewed the MS-DOS source code could not contribute to FreeDOS. - -But Microsoft’s recent MS-DOS source code release represents a significant change. This MS-DOS source code uses the MIT License (also called the Expat License). Quoting Microsoft’s [LICENSE.md][4] file on GitHub: - -> ## MS-DOS v1.25 and v2.0 Source Code -> -> Copyright © Microsoft Corporation. -> -> All rights reserved. -> -> MIT License. -> -> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -If that text looks familiar to you, it is because that’s the same text as the MIT License recognized by the [Open Source Initiative][5]. It’s also the same as the Expat License recognized by the [Free Software Foundation][6]. - -The Free Software Foundation (via GNU) says the Expat License is compatible with the [GNU General Public License][7]. Specifically, GNU describes the Expat License as “a lax, permissive non-copyleft free software license, compatible with the GNU GPL. It is sometimes ambiguously referred to as the MIT License.” Also according to GNU, when they say a license is [compatible with the GNU GPL][8], “you can combine code released under the other license [MIT/Expat License] with code released under the GNU GPL in one larger program.” - -Microsoft’s use of the MIT/Expat License for the original MS-DOS source code is significant because the license is not only open source software but free software. - -### What does it mean? - -This is great, but there’s a practical side to the source code release. You might think, “If Microsoft has released the MS-DOS source code under a license compatible with the GNU GPL, will that help FreeDOS?” - -Not really. Here's why: FreeDOS started from an original source code base, independent from MS-DOS. Certain functions and behaviors of MS-DOS were identified and documented in the comprehensive [Interrupt List by Ralf Brown][9], and we provided MS-DOS compatibility in FreeDOS by referencing the Interrupt List. But many significant fundamental technical differences remain between FreeDOS and MS-DOS. For example, FreeDOS uses a completely different memory structure and memory layout. You can’t simply forklift MS-DOS source code into FreeDOS and expect it to work. The code assumptions are quite different. - -There’s also the simple matter that these are very old versions of MS-DOS. For example, MS-DOS 2.0 was the first version to support directories and redirection. But these versions of MS-DOS did not yet include more advanced features, including networking, CDROM support, and ’386 support such as EMM386. These features have been standard in FreeDOS for a long time. - -So the MS-DOS source code release is interesting, but FreeDOS would not be able to reuse this code for any modern features anyway. FreeDOS has already surpassed these versions of MS-DOS in functionality and features. - -### Congratulations - -Still, it’s important to recognize the big step that Microsoft has taken in releasing these versions of MS-DOS as open source software. The new MS-DOS source code release on GitHub does away with the restrictive license from 2014 and adopts a recognized open source software license that is compatible with the GNU GPL. Congratulations to Microsoft for releasing MS-DOS 1.25 and 2.0 under an open source license! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/10/microsoft-open-source-old-versions-ms-dos - -作者:[Jim Hall][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/jim-hall -[b]: https://github.com/lujun9972 -[1]: https://github.com/Microsoft/MS-DOS -[2]: http://www.computerhistory.org/press/ms-source-code.html -[3]: http://www.computerhistory.org/atchm/microsoft-research-license-agreement-msdos-v1-1-v2-0/ -[4]: https://github.com/Microsoft/MS-DOS/blob/master/LICENSE.md -[5]: https://opensource.org/licenses/MIT -[6]: https://directory.fsf.org/wiki/License:Expat -[7]: https://www.gnu.org/licenses/license-list.en.html#Expat -[8]: https://www.gnu.org/licenses/gpl-faq.html#WhatDoesCompatMean -[9]: http://www.cs.cmu.edu/~ralf/files.html diff --git a/sources/talk/20181107 Understanding a -nix Shell by Writing One.md b/sources/talk/20181107 Understanding a -nix Shell by Writing One.md new file mode 100644 index 0000000000..acad742117 --- /dev/null +++ b/sources/talk/20181107 Understanding a -nix Shell by Writing One.md @@ -0,0 +1,412 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Understanding a *nix Shell by Writing One) +[#]: via: (https://theartofmachinery.com/2018/11/07/writing_a_nix_shell.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +Understanding a *nix Shell by Writing One +====== + +A typical *nix shell has a lot of programming-like features, but works quite differently from languages like Python or C++. This can make a lot of shell features — like process management, argument quoting and the `export` keyword — seem like mysterious voodoo. + +But a shell is just a program, so a good way to learn how a shell works is to write one. I’ve written [a simple shell that fits in a few hundred lines of commented D source][1]. Here’s a post that walks through how it works and how you could write one yourself. + +### First (Cheating) Steps + +A shell is a kind of REPL (Read Evaluate Print Loop). At its heart is just a simple loop that reads commands from the input, processes them, and returns a result: + +``` +import std.process; +import io = std.stdio; + +enum kPrompt = "> "; + +void main() +{ + io.write(kPrompt); + foreach (line; io.stdin.byLineCopy()) + { + // "Cheating" by using the existing shell for now + auto result = executeShell(line); + io.write(result.output); + io.write(kPrompt); + } +} + +$ dmd shell.d +$ ./shell +> head /usr/share/dict/words +A +a +aa +aal +aalii +aam +Aani +aardvark +aardwolf +Aaron +> # Press Ctrl+D to quit +> +$ +``` + +If you try out this code out for yourself, you’ll soon notice that you don’t have any nice editing features like tab completion or command history. The popular Bash shell uses a library called [GNU Readline][2] for that. You can get most of the features of Readline when playing with these toy examples just by running them under [rlwrap][3] (probably already in your system’s package manager). + +### DIY Command Execution (First Attempt) + +That first example demonstrated the absolute basic structure of a shell, but it cheated by passing commands directly to the shell already running on the system. Obviously, that doesn’t explain anything about how a real shell processes commands. + +The basic idea, though, is very simple. Nearly everything that gets called a “shell command” (e.g., `ls` or `head` or `grep`) is really just a program on the filesystem. The shell just has to run it. At the operating system level, running a program is done using the `execve` system call (or one of its alternatives). For portability and convenience, the normal way to make a system call is to use one of the wrapper functions in the C library. Let’s try using `execv()`: + +``` +import core.sys.posix.stdio; +import core.sys.posix.unistd; + +import io = std.stdio; +import std.string; + +enum kPrompt = "> "; + +void main() +{ + io.write(kPrompt); + foreach (line; io.stdin.byLineCopy()) + { + runCommand(line); + io.write(kPrompt); + } +} + +void runCommand(string cmd) +{ + // Need to convert D string to null-terminated C string + auto cmdz = cmd.toStringz(); + + // We need to pass execv an array of program arguments + // By convention, the first element is the name of the program + + // C arrays don't carry a length, just the address of the first element. + // execv starts reading memory from the first element, and needs a way to + // know when to stop. Instead of taking a length value as an argument, + // execv expects the array to end with a null as a stopping marker. + + auto argsz = [cmdz, null]; + auto error = execv(cmdz, argsz.ptr); + if (error) + { + perror(cmdz); + } +} +``` + +Here’s a sample run: + +``` +> ls +ls: No such file or directory +> head +head: No such file or directory +> grep +grep: No such file or directory +> ಠ_ಠ +ಠ_ಠ: No such file or directory +> +``` + +Okay, so that’s not working so well. The problem is that that the `execve` call isn’t as smart as a shell: it just literally executes the program it’s told to. In particular, it has no smarts for finding the programs that implement `ls` or `head`. For now, let’s do the finding ourselves, and then give `execve` the full path to the command: + +``` +$ which ls +/bin/ls +$ ./shell +> /bin/ls +shell shell.d shell.o +$ +``` + +This time the `ls` command worked, but our shell quit and we dropped straight back into the system’s shell. What’s going on? Well, `execve` really is a single-purpose call: it doesn’t spawn a new process for running the program separately from the current program, it _replaces_ the current program. (The toy shell actually quit when `ls` started, not when it finished.) Creating a new process is done with a different system call: traditionally `fork`. This isn’t how programming languages normally work, so it might seem like weird and annoying behaviour, but it’s actually really useful. Decoupling process creation from program execution allows a lot of flexibility, as will become clearer later. + +### Fork and Exec + +To keep the shell running, we’ll use the `fork()` C function to create a new process, and then make that new process `execv()` the program that implements the command. (On modern GNU/Linux systems, `fork()` is actually a wrapper around a system call called `clone`, but it still behaves like the classic `fork` system call.) + +`fork()` duplicates the current process. We get a second process that’s running the same program, at the same point, with a copy of everything in memory and all the same open files. Both the original process (parent) and the duplicate (child) keep running normally. Of course, we want the parent process to keep running the shell, and the child to `execv()` the command. The `fork()` function helps us differentiate them by returning zero in the child and a non-zero value in the parent. (This non-zero value is the process ID of the child.) + +Let’s try it out in a new version of the `runCommand()` function: + +``` +int runCommand(string cmd) +{ + // fork() duplicates the process + auto pid = fork(); + // Both the parent and child keep running from here as if nothing happened + // pid will be < 0 if forking failed for some reason + // Otherwise pid == 0 for the child and != 0 for the parent + if (pid < 0) + { + perror("Can't create a new process"); + exit(1); + } + if (pid == 0) + { + // Child process + auto cmdz = cmd.toStringz(); + auto argsz = [cmdz, null]; + execv(cmdz, argsz.ptr); + + // Only get here if exec failed + perror(cmdz); + exit(1); + } + // Parent process + // This toy shell can only run one command at a time + // All the parent does is wait for the child to finish + int status; + wait(&status); + // This is the exit code of the child + // (Conventially zero means okay, non-zero means error) + return WEXITSTATUS(status); +} +``` + +Here it is in action: + +``` +> /bin/ls +shell shell.d shell.o +> /bin/uname +Linux +> +``` + +Progress! But it still doesn’t feel like a real shell if we have to tell it exactly where to find each command. + +### PATH + +If you try using `which` to find the implementations of various commands, you might notice they’re all in the same small set of directories. The list of directories that contains commands is stored in an environment variable called `PATH`. It looks something like this: + +``` +$ echo $PATH +/home/user/bin:/home/user/local/bin:/home/user/.local/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/games/bin +``` + +As you can see, it’s a list of directories separated by colons. If you ask a shell to run `ls`, it’s supposed to search each directory in this list for a program called `ls`. The search should be done in order starting from the first directory, so a personal implementation of `ls` in `/home/user/bin` could override the one in `/bin`. Production-ready shells cache this lookup. + +`PATH` is only used by default. If we type in a path to a program, that program will be used directly. + +Here’s a simple implemention of a smarter conversion of a command name to a C string that points to the executable. It returns a null if the command can’t be found. + +``` +const(char*) findExecutable(string cmd) +{ + if (cmd.canFind('/')) + { + if (exists(cmd)) return cmd.toStringz(); + return null; + } + + foreach (dir; environment["PATH"].splitter(":")) + { + import std.path : buildPath; + auto candidate = buildPath(dir, cmd); + if (exists(candidate)) return candidate.toStringz(); + } + return null; +} +``` + +Here’s what the shell looks like now: + +``` +> ls +shell shell.d shell.o +> uname +Linux +> head shell.d +head shell.d: No such file or directory +> +``` + +### Complex Commands + +That last command failed because the toy shell doesn’t handle program arguments yet, so it tries to find a command literally called “head shell.d”. + +If you look back at the implementation of `runCommand()`, you’ll see that `execv()` takes a C array of arguments, as well as the path to the program to run. All we have to do is process the command to make the array `["head", "shell.d", null]`. Something like this would do it: + +``` +// Key difference: split the command into pieces +auto args = cmd.split(); + +auto cmdz = findExecutable(args[0]); +if (cmdz is null) +{ + io.stderr.writef("%s: No such file or directory\n", args[0]); + // 127 means "Command not found" + // http://tldp.org/LDP/abs/html/exitcodes.html + exit(127); +} +auto argsz = args.map!(toStringz).array; +argsz ~= null; +auto error = execv(cmdz, argsz.ptr); +``` + +That makes simple arguments work, but we quickly get into problems: + +``` +> head -n 5 shell.d +import core.sys.posix.fcntl; +import core.sys.posix.stdio; +import core.sys.posix.stdlib; +import core.sys.posix.sys.wait; +import core.sys.posix.unistd; +> echo asdf +asdf +> echo $HOME +$HOME +> ls *.d +ls: cannot access '*.d': No such file or directory +> ls '/home/user/file with spaces.txt' +ls: cannot access "'/home/user/file": No such file or directory +ls: cannot access 'with': No such file or directory +ls: cannot access "spaces.txt'": No such file or directory +> +``` + +As you might guess by looking at the above, shells like a POSIX Bourne shell (or Bash) do a _lot_ more than just `split()`. Take the `echo $HOME` example. It’s a common idiom to use `echo` for viewing environment variables (like `HOME`), but `echo` itself doesn’t actually do any environment variable handling. A POSIX shell processes a command like `echo $HOME` into an array like `["echo", "/home/user", null]` and passes it to `echo`, which does nothing but reflect its arguments back to the terminal. + +A POSIX shell also handles glob patterns like `*.d`. That’s why glob patterns work with _any_ command in *nix (unlike MS-DOS, for example): the commands don’t even see the globs. + +The command `ls '/home/user/file with spaces.txt'` got split into `["ls", "'/home/user/file", "with", "spaces.txt'", null]`. Any useful shell lets you use quoting and escaping to prevent any processing (like splitting into arguments) that you don’t want. Once again, quotes are completely handled by the shell; commands don’t even see them. Also, unlike most programming languages, everything is a string in shell, so there’s no difference between `head -n 5 shell.d` and `head -n '5' shell.d` — both turn into `["head", "-n", "5", "shell.d", null]`. + +There’s something you might notice from that last example: the shell can’t treat flags like `-n 5` differently from positional arguments like `shell.d` because `execve` only takes a single array of all arguments. So that means argument types are one thing that programs _do_ have to figure out for themselves, which explains [the clichéd inteview question about why quotes won’t help you delete a file called `-`][4] (i.e., the quotes are processed before the `rm` command sees them). + +A POSIX shell supports quite complex constructs like `while` loops and pipelines, but the toy shell only supports simple commands. + +### Tweaking the Child Process + +I said earlier that decoupling `fork` from `exec` allows extra flexibility. Let me give a couple of examples. + +#### I/O Redirection + +A key design principle of Unix is that commands should be agnostic about where their input and output are from, so that user input/output can be replaced with file input/output, or even input/output of other commands. E.g.: + +``` +sort events.txt | head -n 10 > /tmp/top_ten_events.txt +``` + +How does it work? Take the `head` command. The shell forks off a new child process. The child is a duplicate of the parent, so it inherits the same standard input and output. However, the child can replace its own standard input with a pipe shared with the process for `sort`, and replace its own standard output with a file handle for `/tmp/top_ten_events.txt`. After calling `execv()`, the process will become a `head` process that blindly reads/writes to/from whatever standard I/O it has. + +Getting down to the low-level details, *nix systems represent all file handles with so-called “file descriptors”, which are just integers as far as user programs are concerned, but point to data structures inside the operating system kernel. Standard input is file descriptor 0, and standard output is file descriptor 1. Replacing standard output for `head` looks something like this (minus error handling): + +``` +// The fork happens somewhere back here +// Now running in the child process + +// Open the new file (no control over the file descriptor) +auto new_fd = open("/tmp/top_ten_events.txt", O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); +// Copy the open file into file #1 (standard output) +dup2(new_fd, 1); +// Close the spare file descriptor +close(new_fd); + +// The exec happens somewhere down here +``` + +The pipeline works in the same kind of way, except instead of using `open()` to open a file, we use `pipe()` to create _two_ connected file descriptors, and then let `sort` use one, and `head` use the other. + +#### Environment Variables + +If you’ve ever had to deploy something using a command line, there’s a good chance you’ve had to set some of these configuration variables. Each process carries its own set of environment variables, so you can override, say, `AUDIODEV` for one running program without affecting others. The C standard library provides functions for manipulating environment variables, but they’re not actually managed by the operating system kernel — the [C runtime][5] manages them using the same user-space memory that other program variables use. That means they also get copied to child processes on a `fork`. The runtime and the kernel co-operate to preserve them on `execve`. + +There’s no reason we can’t manipulate the environment variables the child process ends up using. POSIX shells support this: just put any variable assignments you want directly in front of the command. + +``` +$ uname +Linux +$ # LD_DEBUG is an environment variable for enabling linker debugging +$ # (Doesn't work on all systems.) +$ LD_DEBUG=statistics uname +12128: +12128: runtime linker statistics: +12128: total startup time in dynamic loader: 2591152 cycles +12128: time needed for relocation: 816752 cycles (31.5%) +12128: number of relocations: 153 +12128: number of relocations from cache: 3 +12128: number of relative relocations: 1304 +12128: time needed to load objects: 1196148 cycles (46.1%) +Linux +$ # LD_DEBUG was only set for uname +$ echo $LD_DEBUG + +$ # Pop quiz: why doesn't this print "bar"? +$ FOO=bar echo $FOO + +$ +``` + +These temporary environment variables are useful and easy to implement. + +### Builtins + +It’s great that the fork/exec pattern lets us reconfigure the child process as much as we like without affecting the parent shell. But some commands _need_ to affect the shell. A good example is the `cd` command for changing the current working directory. It would be pointless if it ran in a child process, changed its own working directory, then just quit, leaving the shell unchanged. + +The simple solution to this problem is builtins. I said that most shell commands are implemented as external programs on the filesystem. Well, some aren’t — they’re handled directly by the shell itself. Before searching PATH for a command implementation, the shell just checks if it has it’s own built-in implementation. A neat way to code this is [the function pointer approach I described in a previous post][6]. + +You can read [a list of Bash builtins in the Advanced Bash-Scripting Guide][7]. Some, like `cd`, are builtins because they’re highly coupled to the shell. Others, like `echo`, have built-in implementations for performance reasons (most systems also have a standalone `echo` program). + +There’s one builtin that confuses a lot of people: `export`. It makes sense if you realise that the POSIX shell scripting language has its own variables that are totally separate from environment variables. A variable assignment is just a shell variable by default, and `export` makes it into an environment variable (when spawning child processes, at least). The difference is that the C runtime doesn’t know anything about shell variables, so they get lost on `execve`. + +``` +$ uname +Linux +$ # Let's try setting LD_DEBUG +$ LD_DEBUG=statistics +$ # It has no effect because that's actually just a shell variable +$ uname +Linux +$ # Let's try making into an environment variable: +$ export LD_DEBUG +$ uname +12128: +12128: runtime linker statistics: +12128: total startup time in dynamic loader: 2591152 cycles +12128: time needed for relocation: 816752 cycles (31.5%) +12128: number of relocations: 153 +12128: number of relocations from cache: 3 +12128: number of relative relocations: 1304 +12128: time needed to load objects: 1196148 cycles (46.1%) +Linux +$ # Now every non-builtin will dump debugging info +$ # Let's stop that for sanity's sake +$ unset LD_DEBUG +$ +``` + +### Putting it Together + +A POSIX-compliant shell does a lot more stuff (like signal handling and job management) but that’s enough to understand how to write an MVP *nix shell. You can see all the pieces together by checking out [the complete working example in my repository][1]. + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2018/11/07/writing_a_nix_shell.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: https://gitlab.com/sarneaud/toyshell +[2]: https://tiswww.case.edu/php/chet/readline/rltop.html +[3]: https://github.com/hanslub42/rlwrap +[4]: https://unix.stackexchange.com/questions/1519/how-do-i-delete-a-file-whose-name-begins-with-hyphen-a-k-a-dash-or-minus +[5]: /2017/06/04/what_is_the_d_runtime.html#what-about-c--does-c-really-have-a-runtime-too +[6]: /2018/04/02/inheritance_and_polymorphism.html +[7]: https://www.tldp.org/LDP/abs/html/internal.html diff --git a/sources/talk/20181205 Unfortunately, Garbage Collection isn-t Enough.md b/sources/talk/20181205 Unfortunately, Garbage Collection isn-t Enough.md new file mode 100644 index 0000000000..0c08320139 --- /dev/null +++ b/sources/talk/20181205 Unfortunately, Garbage Collection isn-t Enough.md @@ -0,0 +1,44 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Unfortunately, Garbage Collection isn't Enough) +[#]: via: (https://theartofmachinery.com/2018/12/05/gc_not_enough.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +Unfortunately, Garbage Collection isn't Enough +====== + +Here’s a little story of some mysterious server failures I had to debug a year ago. The servers would run okay for a while, then eventually start crashing. After that, trying to run practically anything on the machines failed with “No space left on device” errors, but the filesystem only reported a few gigabytes of files on the ~20GB disks. + +The problem turned out to be caused by a log shipper. This was a Ruby app that read in log files, sent the data to a remote server, and deleted the old files. The bug was that the open log files weren’t being explicitly closed. The app was letting Ruby’s automatic garbage collector clean up the `File` objects, instead. Trouble is, `File` objects don’t use much memory, so the log shipper could theoretically keep millions of log files open before a collection was needed. + +*nix filesystems decouple filenames from file data. File data on disk can have multiple filenames pointing to it (i.e., hard links), and the data is only deleted when the last reference is removed. An open file descriptor counts as a reference, so if you delete a file while a program is reading it, the filename disappears from the directory listing, but the file data stays until the program closes it. That’s what was happening with the log shipper. The `du` (“disk usage”) command finds files using directory listings, so it didn’t see the gigabytes of file data for the thousands of log files the shipper had open. Those files only appeared after running `lsof` (“list open files”). + +Of course, the same kind of bug happens with other things. A couple of months ago I had to deal with a Java app that was breaking in production after a few days because it leaked network connections. + +Once upon a time, I wrote most of my code in C and then C++. In those days, I thought manual resource management was enough. How hard could it be? Every `malloc()` needs a `free()`, and every `open()` needs a `close()`. Simple. Except not all programs are simple, so manual resource management became a straitjacket. Then one day I discovered reference counting and garbage collection. I thought that solved all my problems, and I stopped caring about resource management completely. Once again, that was okay for simple programs, but not all programs are simple. + +Relying on garbage collection doesn’t work because it only solves the _memory_ management problem, and complex programs have to deal with a lot more than just memory. There’s a popular meme that responds to that by saying that [memory is 95% of your resource problems][1]. Well, you could say that all resources are 0% of your problems — until you run out of one of them. Then that resource becomes 100% of your problems. + +But that kind of thinking still treats resources as a special case. The deeper problem is that as programs get more complex, everything tends to become a resource. For example, take a calendar program. A complex calendar program allows multiple users to manage multiple, shareable calendars, with events that can be shared across calendars. Any piece of data will eventually have multiple parts of the program depending on it being up-to-date and accurate. So all dynamic data needs an owner, and not just for memory management. As more features are added, more parts of the program will need to update data. If you’re sane, you’ll only allow one part of the program to update data at a time, so the right and responsibility to update data becomes a limited resource, itself. Modelling mutable data with immutable datastructures doesn’t make these problems disappear; it just translates them into a different paradigm. + +Planning the ownership and lifespan of resources is an inescapable part of designing complex software. It’s easier if you exploit some common patterns. One pattern is fungible resources. An example is an immutable string “foo”, which is semantically the same as any other immutable string “foo”. This kind of resource doesn’t need a pre-determined lifespan or ownership. In fact, to keep the system as simple as possible, it’s better to have _no_ pre-determined lifespan or ownership. Another pattern is resources that are non-fungible, but have a deterministic lifespan. This includes network connections, as well as more abstract things like the ownership of a piece of data. It’s sanest to explicitly enforce the lifespan of these things in code. + +Notice that automatic garbage collection is really good for implementing the first pattern, but not the second, while manual resource management techniques (like RAII) are great for implementing the second pattern, but terrible for the first. The two approaches become complements in complex programs. + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2018/12/05/gc_not_enough.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: https://yosefk.com/c++fqa/dtor.html#fqa-11.1 diff --git a/sources/talk/20181218 The Rise and Demise of RSS.md b/sources/talk/20181218 The Rise and Demise of RSS.md index e260070c5c..2dfea2074c 100644 --- a/sources/talk/20181218 The Rise and Demise of RSS.md +++ b/sources/talk/20181218 The Rise and Demise of RSS.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (beamrolling) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/talk/20181220 D in the Browser with Emscripten, LDC and bindbc-sdl (translation).md b/sources/talk/20181220 D in the Browser with Emscripten, LDC and bindbc-sdl (translation).md new file mode 100644 index 0000000000..b4dc33b434 --- /dev/null +++ b/sources/talk/20181220 D in the Browser with Emscripten, LDC and bindbc-sdl (translation).md @@ -0,0 +1,276 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (D in the Browser with Emscripten, LDC and bindbc-sdl (translation)) +[#]: via: (https://theartofmachinery.com/2018/12/20/emscripten_d.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +D in the Browser with Emscripten, LDC and bindbc-sdl (translation) +====== + +Here’s a tutorial about using Emscripten to run D code in a normal web browser. It’s uses a different approach from the [Dscripten game demo][1] and the [dscripten-tools][2] toolchain that’s based on it. + + * Instead of porting the D runtime, it uses a lightweight, runtimeless `-betterC` build. + * It uses Docker to manage the Emscripten installation. + + + +LDC has recently gained support for [compiling directly to WebAssembly][3], but (unlike the Emscripten approach) that doesn’t automatically get you libraries. + +You can find [the complete working code on Github][4]. `./run.sh` starts a shell in a Docker image that contains the development environment. `dub build --build=release` generates the HTML and JavaScript assets and puts them into the `dist/` directory. + +[This tutorial is translated from a Japanese post by outlandkarasu][5], who deserves all the credit for figuring this stuff out. + +### Background + +#### What’s Emscripten? + +[Emscripten][6] is a compiler toolchain for asm.js and WebAssembly that comes with ported versions of the libc and SDL2 C libraries. It can compile regular Linux-based applications in languages like C to code that can run in a browser. + +### How do you use Emscripten with D? + +Emscripten is a toolchain designed for C/C++, but the C/C++ part is just a frontend. The toolchain actually compiles LLVM intermediate representation (IR). You can generate LLVM IR bitcode from D using [LDC][7], so it should be possible to feed that through Emscripten and run D in a browser, just like C/C++. + +#### Gotchas using Emscripten + +Ideally that’s all it would take, but there are some things that require special attention (or trial and error). + + 1. D runtime library features like GC and Phobos can’t be used without an Emscripten port. + 2. It’s not enough to just produce LLVM IR. The code needs to meet Emscripten’s requirements. + * It needs to use ported libraries. + * Pointer sizes and data structure binary layouts need to match. + 3. Emscripten bugs need to be worked around. + * Debug information is particularly problematic. + + + +### Implementation + +#### Plan of attack + +Here’s the plan for making D+Emscripten development work: + + 1. Use `-betterC` and the `@nogc` and `nothrow` attributes to avoid D runtime features. + 2. Use SDL2 functions directly by statically compiling with [`bindbc-sdl`][8]. + 3. Keep on trying. + + + +#### Environment setup + +Emscripten is based on LLVM, clang and various other libraries, and is hard to set up, so I decided to [do the job with Docker][9]. I wrote a Dockerfile that would also add LDC and other tools at `docker build` time: + +``` +FROM trzeci/emscripten-slim:sdk-tag-1.38.21-64bit + +# Install D and tools, and enable them in the shell by adding them to .bashrc +RUN apt-get -y update && \ + apt-get -y install vim sudo curl && \ + sudo -u emscripten /bin/sh -c "curl -fsS https://dlang.org/install.sh | bash -s ldc-1.12.0" && \ + (echo 'source $(~/dlang/install.sh ldc -a)' >> /home/emscripten/.bashrc) + +# dub settings (explained later) +ADD settings.json /var/lib/dub/settings.json +``` + +Docker makes these big toolchains pretty easy :) + +#### Coding + +Here’s a basic demo that displays an image: + +``` +// Import SDL2 and SDL_image +// Both work with Emscripten +import bindbc.sdl; +import bindbc.sdl.image; +import core.stdc.stdio : printf; // printf works in Emscripten, too + +// Function declarations for the main loop +alias em_arg_callback_func = extern(C) void function(void*) @nogc nothrow; +extern(C) void emscripten_set_main_loop_arg(em_arg_callback_func func, void *arg, int fps, int simulate_infinite_loop) @nogc nothrow; +extern(C) void emscripten_cancel_main_loop() @nogc nothrow; + +// Log output +void logError(size_t line = __LINE__)() @nogc nothrow { + printf("%d:%s\n", line, SDL_GetError()); +} + +struct MainLoopArguments { + SDL_Renderer* renderer; + SDL_Texture* texture; +} + +// Language features restricted with @nogc and nothrow +extern(C) int main(int argc, const char** argv) @nogc nothrow { + // Initialise SDL + if(SDL_Init(SDL_INIT_VIDEO) != 0) { + logError(); + return -1; + } + scope(exit) SDL_Quit(); + + // Initialise SDL_image (with PNG support) + if(IMG_Init(IMG_INIT_PNG) != IMG_INIT_PNG) { + logError(); + return -1; + } + scope(exit) IMG_Quit(); + + // Make the window and its renderer + SDL_Window* window; + SDL_Renderer* renderer; + if(SDL_CreateWindowAndRenderer(640, 480, SDL_WINDOW_SHOWN, &window, &renderer) != 0) { + logError(); + return -1; + } + scope(exit) { + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); + } + + // Load image file + auto dman = IMG_Load("images/dman.png"); + if(!dman) { + logError(); + return -1; + } + scope(exit) SDL_FreeSurface(dman); + + // Make a texture from the image + auto texture = SDL_CreateTextureFromSurface(renderer, dman); + if(!texture) { + logError(); + return -1; + } + scope(exit) SDL_DestroyTexture(texture); + + // Start the image main loop + auto arguments = MainLoopArguments(renderer, texture); + emscripten_set_main_loop_arg(&mainLoop, &arguments, 60, 1); + return 0; +} + +extern(C) void mainLoop(void* p) @nogc nothrow { + // Get arguments + auto arguments = cast(MainLoopArguments*) p; + auto renderer = arguments.renderer; + auto texture = arguments.texture; + + // Clear background + SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00); + SDL_RenderClear(renderer); + + // Texture image + SDL_RenderCopy(renderer, texture, null, null); + SDL_RenderPresent(renderer); + + // End of loop iteration + emscripten_cancel_main_loop(); +} +``` + +#### Building + +Now building is the tricky bit. + +##### `dub.json` + +Here’s the `dub.json` I made through trial and error. It runs the whole build from D to WebAssembly. + +``` +{ + "name": "emdman", + "authors": [ + "outland.karasu@gmail.com" + ], + "description": "A minimal emscripten D man demo.", + "copyright": "Copyright © 2018, outland.karasu@gmail.com", + "license": "BSL-1.0", + "dflags-ldc": ["--output-bc", "-betterC"], // Settings for bitcode output + "targetName": "app.bc", + "dependencies": { + "bindbc-sdl": "~>0.4.1" + }, + "subConfigurations": { + "bindbc-sdl": "staticBC" // Statically-linked, betterC build + }, + "versions": ["BindSDL_Image"], // Use SDL_image + + // Run the Emscripten compiler after generating bitcode + // * Disable optimisations + // * Enable WebAssembly + // * Use SDL+SDL_image (with PNG) + // * Set web-only as the environment + // * Embed image file(s) + // * Generate HTML for running in browser + "postBuildCommands": ["emcc -v -O0 -s WASM=1 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='[\"png\"]' -s ENVIRONMENT=web --embed-file images -o dist/index.html app.bc"] +} +``` + +##### Switch to 32b (x86) code generation + +Compiling with 64b “worked” but I got a warning about different data layouts: + +``` +warning: Linking two modules of different data layouts: '/tmp/emscripten_temp_WwvmL5_archive_contents/mulsc3_20989819.c.o' is 'e-p:32:32-i64:64-v128:32:128-n32-S128' whereas '/src/app.bc' is 'e-m:e-i64:64-f80:128-n8:16:32:64-S128' + +warning: Linking two modules of different target triples: /tmp/emscripten_temp_WwvmL5_archive_contents/mulsc3_20989819.c.o' is 'asmjs-unknown-emscripten' whereas '/src/app.bc' is 'x86_64-unknown-linux-gnu' +``` + +Apparently Emscripten is basically for 32b code. Using mismatched pointer sizes sounds like a pretty bad idea, so I added this `/var/lib/dub/settings.json` to the Dockerfile: + +``` +{ + "defaultArchitecture": "x86", // Set code generation to 32b + "defaultCompiler": "ldc" // Use LDC by default +} +``` + +There’s an [open issue for documenting `dub`’s `settings.json`][10]. + +##### Remove debug information + +Emscripten gave the following error when I ran a normal build with `dub`: + +``` +shared:ERROR: Failed to run llvm optimizations: +``` + +It looks like there’s [an issue related to debugging information][11]. I worked around it by using `dub --build=release`. + +### Results + +After lots of trial and error, I finally succeeded in getting my demo to run in a browser. Here’s how it looks: + +![Meet D-Man \(Demo\)][12] + +The Emscripten+D dev environment isn’t as stable as a normal dev environment. For example, rendering didn’t work if I used `SDL_LowerBlit` instead. But here’s D-Man in a browser. + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2018/12/20/emscripten_d.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: https://github.com/Ace17/dscripten +[2]: https://github.com/CyberShadow/dscripten-tools +[3]: https://wiki.dlang.org/Generating_WebAssembly_with_LDC +[4]: https://github.com/outlandkarasu-sandbox/emdman +[5]: https://qiita.com/outlandkarasu@github/items/15e0f4b6d1b2a0eab846 +[6]: http://kripken.github.io/emscripten-site/ +[7]: https://wiki.dlang.org/LDC +[8]: https://github.com/BindBC/bindbc-sdl +[9]: https://hub.docker.com/r/trzeci/emscripten/ +[10]: https://github.com/dlang/dub/issues/1463 +[11]: https://github.com/kripken/emscripten/issues/4078 +[12]: /images/emscripten_d/d-man-browser.png diff --git a/sources/talk/20190105 Why Sorting is O(N log N).md b/sources/talk/20190105 Why Sorting is O(N log N).md new file mode 100644 index 0000000000..34a1d3bf97 --- /dev/null +++ b/sources/talk/20190105 Why Sorting is O(N log N).md @@ -0,0 +1,115 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why Sorting is O(N log N)) +[#]: via: (https://theartofmachinery.com/2019/01/05/sorting_is_nlogn.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +Why Sorting is O(N log N) +====== + +Any decent algorithms textbook will explain how fast sorting algorithms like quicksort and heapsort are, but it doesn’t take crazy maths to prove that they’re as asymptotically fast as you can possibly get. + +### A pedantic note about notation + +Most computer scientists use big-O notation to mean “asymptotically equal, up to a constant scaling factor”, which isn’t quite what it means to other mathematicians. Sorry, I’ll use big-O like in CS textbooks, but at least I won’t mix it with other mathematical notation. + +## Comparison-based sorting + +Let’s look at the special case of algorithms that compare values two at a time (like quicksort and heapsort, and most other popular algorithms). The ideas can be extended to all sorting algorithms later. + +### A simple counting argument for the worst case + +Suppose you have an array of four elements, all different, in random order. Can you sort it by comparing just one pair of elements? Obviously not, but here’s one good reason that proves you can’t: By definition, to sort the array, you need to how to rearrange the elements to put them in order. In other words, you need to know which permutation is needed. How many possible permutations are there? The first element could be moved to one of four places, the second one could go to one of the remaining three, the third element has two options, and the last element has to take the one remaining place. So there are (4 \times 3 \times 2 \times 1 = 4! = 24) possible permutations to choose from, but there are only two possible results from comparing two different things: “BIGGER” and “SMALLER”. If you made a list of all the possible permutations, you might decide that “BIGGER” means you need permutation #8 and “SMALLER” means you need permutation #24, but there’s no way you could know when you need the other 22 permutations. + +With two comparisons, you have (2 \times 2 = 4) possible outputs, which still isn’t enough. You can’t sort every possible shuffled array unless you do at least five comparisons ((2^{5} = 32)). If (W(N)) is the worst-case number of comparisons needed to sort (N) different elements using some algorithm, we can say + +[2^{W(N)} \geq N!] + +Taking a logarithm base 2, + +[W(N) \geq \log_{2}{N!}] + +Asymptotically, (N!) grows like (N^{N}) (see also [Stirling’s formula][1]), so + +[W(N) \succeq \log N^{N} = N\log N] + +And that’s an (O(N\log N)) limit on the worst case just from counting outputs. + +### Average case from information theory + +We can get a stronger result if we extend that counting argument with a little information theory. Here’s how we could use a sorting algorithm as a code for transmitting information: + + 1. I think of a number — say, 15 + 2. I look up permutation #15 from the list of permutations of four elements + 3. I run the sorting algorithm on this permutation and record all the “BIGGER” and “SMALLER” comparison results + 4. I transmit the comparison results to you in binary code + 5. You re-enact my sorting algorithm run, step by step, referring to my list of comparison results as needed + 6. Now that you know how I rearranged my array to make it sorted, you can reverse the permutation to figure out my original array + 7. You look up my original array in the permutation list to figure out I transmitted the number 15 + + + +Okay, it’s a bit strange, but it could be done. That means that sorting algorithms are bound by the same laws as normal encoding schemes, including the theorem proving there’s no universal data compressor. I transmitted one bit per comparison the algorithm does, so, on average, the number of comparisons must be at least the number of bits needed to represent my data, according to information theory. More technically, [the average number of comparisons must be at least the Shannon entropy of my input data, measured in bits][2]. Entropy is a mathematical measure of the information content, or unpredictability, of something. + +If I have an array of (N) elements that could be in any possible order without bias, then entropy is maximised and is (\log_{2}{N!}) bits. That proves that (O(N\log N)) is an optimal average for a comparison-based sort with arbitrary input. + +That’s the theory, but how do real sorting algorithms compare? Below is a plot of the average number of comparisons needed to sort an array. I’ve compared the theoretical optimum against naïve quicksort and the [Ford-Johnson merge-insertion sort][3], which was designed to minimise comparisons (though it’s rarely faster than quicksort overall because there’s more to life than minimising comparisons). Since it was developed in 1959, merge-insertion sort has been tweaked to squeeze a few more comparisons out, but the plot shows it’s already almost optimal. + +![Plot of average number of comparisons needed to sort randomly shuffled arrays of length up to 100. Bottom line is theoretical optimum. Within about 1% is merge-insertion sort. Naïve quicksort is within about 25% of optimum.][4] + +It’s nice when a little theory gives such a tight practical result. + +### Summary so far + +Here’s what’s been proven so far: + + 1. If the array could start in any order, at least (O(N\log N)) comparisons are needed in the worst case + 2. The average number of comparisons must be at least the entropy of the array, which is (O(N\log N)) for random input + + + +Note that #2 allows comparison-based sorting algorithms to be faster than (O(N\log N)) if the input is low entropy (in other words, more predictable). Merge sort is close to (O(N)) if the input contains many sorted subarrays. Insertion sort is close to (O(N)) if the input is an array that was sorted before being perturbed a bit. None of them beat (O(N\log N)) in the worst case unless some array orderings are impossible as inputs. + +## General sorting algorithms + +Comparison-based sorts are an interesting special case in practice, but there’s nothing theoretically special about [`CMP`][5] as opposed to any other instruction on a computer. Both arguments above can be generalised to any sorting algorithm if you note a couple of things: + + 1. Most computer instructions have more than two possible outputs, but still have a limited number + 2. The limited number of outputs means that one instruction can only process a limited amount of entropy + + + +That gives us the same (O(N\log N)) lower bound on the number of instructions. Any physically realisable computer can only process a limited number of instructions at a time, so that’s an (O(N\log N)) lower bound on the time required, as well. + +### But what about “faster” algorithms? + +The most useful practical implication of the general (O(N\log N)) bound is that if you hear about any asymptotically faster algorithm, you know it must be “cheating” somehow. There must be some catch that means it isn’t a general purpose sorting algorithm that scales to arbitrarily large arrays. It might still be a useful algorithm, but it’s a good idea to read the fine print closely. + +A well-known example is radix sort. It’s often called an (O(N)) sorting algorithm, but the catch is that it only works if all the numbers fit into (k) bits, and it’s really (O({kN})). + +What does that mean in practice? Suppose you have an 8-bit machine. You can represent (2^{8} = 256) different numbers in 8 bits, so if you have an array of thousands of numbers, you’re going to have duplicates. That might be okay for some applications, but for others you need to upgrade to at least 16 bits, which can represent (2^{16} = 65,536) numbers distinctly. 32 bits will support (2^{32} = 4,294,967,296) different numbers. As the size of the array goes up, the number of bits needed will tend to go up, too. To represent (N) different numbers distinctly, you’ll need (k \geq \log_{2}N). So, unless you’re okay with lots of duplicates in your array, (O({kN})) is effectively (O(N\log N)). + +The need for (O(N\log N)) of input data in the general case actually proves the overall result by itself. That argument isn’t so interesting in practice because we rarely need to sort billions of integers on a 32-bit machine, and [if anyone’s hit the limits of a 64-bit machine, they haven’t told the rest of us][6]. + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2019/01/05/sorting_is_nlogn.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: http://hyperphysics.phy-astr.gsu.edu/hbase/Math/stirling.html +[2]: https://en.wikipedia.org/wiki/Shannon%27s_source_coding_theorem +[3]: https://en.wikipedia.org/wiki/Merge-insertion_sort +[4]: /images/sorting_is_nlogn/sorting_algorithms_num_comparisons.svg +[5]: https://c9x.me/x86/html/file_module_x86_id_35.html +[6]: https://sortbenchmark.org/ diff --git a/sources/talk/20190108 NSA to Open Source its Reverse Engineering Tool GHIDRA.md b/sources/talk/20190108 NSA to Open Source its Reverse Engineering Tool GHIDRA.md deleted file mode 100644 index 78922f9525..0000000000 --- a/sources/talk/20190108 NSA to Open Source its Reverse Engineering Tool GHIDRA.md +++ /dev/null @@ -1,89 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (NSA to Open Source its Reverse Engineering Tool GHIDRA) -[#]: via: (https://itsfoss.com/nsa-ghidra-open-source) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) - -NSA to Open Source its Reverse Engineering Tool GHIDRA -====== - -GHIDRA – NSA’s reverse engineering tool is getting ready for a free public release this March at the [RSA Conference 2019][1] to be held in San Francisco. - -The National Security Agency (NSA) did not officially announce this – however – a senior NSA advisor, Robert Joyce’s [session description][2] on the official RSA conference website revealed about it before any official statement or announcement. - -Here’s what it mentioned: - -![][3] -Image Credits: [Twitter][4] - -In case the text in the image isn’t properly visible, let me quote the description here: - -> NSA has developed a software reverse engineering framework known as GHIDRA, which will be demonstrated for the first time at RSAC 2019. An interactive GUI capability enables reverse engineers to leverage an integrated set of features that run on a variety of platforms including Windows, Mac OS, and Linux and supports a variety of processor instruction sets. The GHISDRA platform includes all the features expected in high-end commercial tools, with new and expanded functionality NSA uniquely developed. and will be released for free public use at RSA. - -### What is GHIDRA? - -GHIDRA is a software reverse engineering framework developed by [NSA][5] that is in use by the agency for more than a decade. - -Basically, a software reverse engineering tool helps to dig up the source code of a proprietary program which further gives you the ability to detect virus threats or potential bugs. You should read how [reverse engineering][6] works to know more. - -The tool is is written in Java and quite a few people compared it to high-end commercial reverse engineering tools available like [IDA][7]. - -A [Reddit thread][8] involves more detailed discussion where you will find some ex-employees giving good amount of details before the availability of the tool. - -![NSA open source][9] - -### GHIDRA was a secret tool, how do we know about it? - -The existence of the tool was uncovered in a series of leaks by [WikiLeaks][10] as part of [Vault 7 documents of CIA][11]. - -### Is it going to be open source? - -We do think that the reverse engineering tool to be released could be made open source. Even though there is no official confirmation mentioning “open source” – but a lot of people do believe that NSA is definitely targeting the open source community to help improve their tool while also reducing their effort to maintain this tool. - -This way the tool can remain free and the open source community can help improve GHIDRA as well. - -You can also check out the existing [Vault 7 document at WikiLeaks][12] to come up with your prediction. - -### Is NSA doing a good job here? - -The reverse engineering tool is going to be available for Windows, Linux, and Mac OS for free. - -Of course, we care about the Linux platform here – which could be a very good option for people who do not want to or cannot afford a thousand dollar license for a reverse engineering tool with the best-in-class features. - -### Wrapping Up - -If GHIDRA becomes open source and is available for free, it would definitely help a lot of researchers and students and on the other side – the competitors will be forced to adjust their pricing. - -What are your thoughts about it? Is it a good thing? What do you think about the tool going open sources Let us know what you think in the comments below. - -![][13] - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/nsa-ghidra-open-source - -作者:[Ankush Das][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://www.rsaconference.com/events/us19 -[2]: https://www.rsaconference.com/events/us19/agenda/sessions/16608-come-get-your-free-nsa-reverse-engineering-tool -[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/come-get-your-free-nsa.jpg?fit=800%2C337&ssl=1 -[4]: https://twitter.com/0xffff0800/status/1080909700701405184 -[5]: http://nsa.gov -[6]: https://en.wikipedia.org/wiki/Reverse_engineering -[7]: https://en.wikipedia.org/wiki/Interactive_Disassembler -[8]: https://www.reddit.com/r/ReverseEngineering/comments/ace2m3/come_get_your_free_nsa_reverse_engineering_tool/ -[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/nsa-open-source.jpeg?resize=800%2C450&ssl=1 -[10]: https://www.wikileaks.org/ -[11]: https://en.wikipedia.org/wiki/Vault_7 -[12]: https://wikileaks.org/ciav7p1/cms/page_9536070.html -[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/nsa-open-source.jpeg?fit=800%2C450&ssl=1 diff --git a/sources/talk/20190115 The Art of Unix Programming, reformatted.md b/sources/talk/20190115 The Art of Unix Programming, reformatted.md deleted file mode 100644 index 73ffb4c955..0000000000 --- a/sources/talk/20190115 The Art of Unix Programming, reformatted.md +++ /dev/null @@ -1,54 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (The Art of Unix Programming, reformatted) -[#]: via: (https://arp242.net/weblog/the-art-of-unix-programming.html) -[#]: author: (Martin Tournoij https://arp242.net/) - -The Art of Unix Programming, reformatted -====== - -tl;dr: I reformatted Eric S. Raymond’s The Art of Unix Programming for readability; [read it here][1]. - -I recently wanted to look up a quote for an article I was writing, and I was fairly sure I had read it in The Art of Unix Programming. Eric S. Raymond (esr) has [kindly published it online][2], but it’s difficult to search as it’s distributed over many different pages, and the formatting is not exactly conducive for readability. - -I `wget --mirror`’d it to my drive, and started out with a simple [script][3] to join everything to a single page, but eventually ended up rewriting a lot of the HTML from crappy 2003 docbook-generated tagsoup to more modern standards, and I slapped on some CSS to make it more readable. - -The results are fairly nice, and it should work well in any version of any browser (I haven’t tested Internet Explorer and Edge, lacking access to a Windows computer, but I’m reasonably confident it should work without issues; if not, see the bottom of this page on how to get in touch). - -The HTML could be simplified further (so rms can read it too), but dealing with 360k lines of ill-formatted HTML is not exactly my idea of fun, so this will have to do for now. - -The entire page is self-contained. You can save it to your laptop or mobile phone and read it on a plane or whatnot. - -Why spend so much work on an IT book from 2003? I think a substantial part of the book still applies very much today, for all programmers (not just Unix programmers). For example the [Basics of the Unix Philosophy][4] was good advice in 1972, is still good advice in 2019, and will continue to be good advice well in to the future. - -Other parts have aged less gracefully; for example “since 2000, practice has been moving toward use of XML-DocBook as a documentation interchange format” doesn’t really represent the current state of things, and the [Data File Metaformats][5] section mentions XML and INI, but not JSON or YAML (as they weren’t invented until after the book was written) - -I find this adds, rather than detracts. It makes for an interesting window in to past. The downside is that the uninitiated will have a bit of a hard time distinguishing between the good and outdated parts; as a rule of thumb: if it talks about abstract concepts, it probably still applies today. If it talks about specific software, it may be outdated. - -I toyed with the idea of updating or annotating the text, but the license doesn’t allow derivative works, so that’s not going to happen. Perhaps I’ll email esr and ask nicely. Another project, for another weekend :-) - -You can mail me at [martin@arp242.net][6] or [create a GitHub issue][7] for feedback, questions, etc. - --------------------------------------------------------------------------------- - -via: https://arp242.net/weblog/the-art-of-unix-programming.html - -作者:[Martin Tournoij][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://arp242.net/ -[b]: https://github.com/lujun9972 -[1]: https://arp242.net/the-art-of-unix-programming/ -[2]: http://catb.org/~esr/writings/taoup/html/ -[3]: https://arp242.net/the-art-of-unix-programming/fix-taoup.py -[4]: https://arp242.net/the-art-of-unix-programming#ch01s06 -[5]: https://arp242.net/the-art-of-unix-programming/#ch05s02 -[6]: mailto:martin@arp242.net -[7]: https://github.com/Carpetsmoker/arp242.net/issues/new diff --git a/sources/talk/20190211 Introducing kids to computational thinking with Python.md b/sources/talk/20190211 Introducing kids to computational thinking with Python.md deleted file mode 100644 index c877d3c212..0000000000 --- a/sources/talk/20190211 Introducing kids to computational thinking with Python.md +++ /dev/null @@ -1,69 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (WangYueScream ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Introducing kids to computational thinking with Python) -[#]: via: (https://opensource.com/article/19/2/break-down-stereotypes-python) -[#]: author: (Don Watkins https://opensource.com/users/don-watkins) - -Introducing kids to computational thinking with Python -====== -Coding program gives low-income students the skills, confidence, and knowledge to break free from economic and societal disadvantages. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/idea_innovation_kid_education.png?itok=3lRp6gFa) - -When the [Parkman Branch][1] of the Detroit Public Library was flooded with bored children taking up all the computers during summer break, the library saw it not as a problem, rather an opportunity. They started a coding club, the [Parkman Coders][2], led by [Qumisha Goss][3], a librarian who is leveraging the power of Python to introduce disadvantaged children to computational thinking. - -When she started the Parkman Coders program about four years ago, "Q" (as she is known) didn't know much about coding. Since then, she's become a specialist in library instruction and technology and a certified Raspberry Pi instructor. - -The program began by using [Scratch][4], but the students got bored with the block coding interface, which they regarded as "baby stuff." She says, "I knew we need to make a change to something that was still beginner friendly, but that would be more challenging for them to continue to hold their attention." At this point, she started teaching them Python. - -Q first saw Python while playing a game with dungeons and skeleton monsters on [Code.org][5]. She began to learn Python by reading books like [Python Programming: An Introduction to Computer Science][6] and [Python for Kids][7]. She also recommends [Automate the Boring Stuff with Python][8] and [Lauren Ipsum: A Story about Computer Science and Other Improbable Things][9]. - -### Setting up a Raspberry Pi makerspace - -Q decided to use [Raspberry Pi][10] computers to avoid the possibility that the students might be able to hack into the library system's computers, which weren't arranged in a way conducive to a makerspace anyway. The Pi's affordability, plus its flexibility and the included free software, lent more credibility to her decision. - -While the coder program was the library's effort keep the peace and create a learning space that would engage the children, it quickly grew so popular that it ran out of space, computers, and adequate electrical outlets in a building built in 1921. They started with 10 Raspberry Pi computers shared among 20 children, but the library obtained funding from individuals, companies including Microsoft, the 4H, and the Detroit Public Library Foundation to get more equipment and expand the program. - -Currently, about 40 children participate in each session and they have enough Raspberry Pi's for one device per child and some to give away. Many of the Parkman Coders come from low socio-economic backgrounds and don't have a computer at home, so the library provides them with donated Chromebooks. - -Q says, "when kids demonstrate that they have a good understanding of how to use a Raspberry Pi or a [Microbit][11] and have been coming to programs regularly, we give them equipment to take home with them. This process is very challenging, however, because [they may not] have internet access at home [or] all the peripheral things they need like monitors, keyboards, and mice." - -### Learning life skills and breaking stereotypes with Python - -Q says, "I believe that the mainstays of learning computer science are learning critical thinking and problem-solving skills. My hope is that these lessons will stay with the kids as they grow and pursue futures in whatever field they choose. In addition, I'm hoping to inspire some pride in creatorship. It's a very powerful feeling to know 'I made this thing,' and once they've had these successes early, I hope they will approach new challenges with zeal." - -She also says, "in learning to program, you have to learn to be hyper-vigilant about spelling and capitalization, and for some of our kids, reading is an issue. To make sure that the program is inclusive, we spell aloud during our lessons, and we encourage kids to speak up if they don't know a word or can't spell it correctly." - -Q also tries to give extra attention to children who need it. She says, "if I recognize that someone has a more severe problem, we try to get them paired with a tutor at our library outside of program time, but still allow them to come to the program. We want to help them without discouraging them from participating." - -Most importantly, the Parkman Coders program seeks to help every child realize that each has a unique skill set and abilities. Most of the children are African-American and half are girls. Q says, "we live in a world where we grow up with societal stigmas that frequently limit our own belief of what we can accomplish." She believes that children need a nonjudgmental space where "they can try new things, mess up, and discover." - -The environment Q and the Parkman Coders program creates helps the participants break away from economic and societal disadvantages. She says that the secret sauce is to "make sure you have a welcoming space so anyone can come and that your space is forgiving and understanding. Let people come as they are, and be prepared to teach and to learn; when people feel comfortable and engaged, they want to stay." - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/2/break-down-stereotypes-python - -作者:[Don Watkins][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/don-watkins -[b]: https://github.com/lujun9972 -[1]: https://detroitpubliclibrary.org/locations/parkman -[2]: https://www.dplfound.org/single-post/2016/05/15/Parkman-Branch-Coders -[3]: https://www.linkedin.com/in/qumisha-goss-b3bb5470 -[4]: https://scratch.mit.edu/ -[5]: http://Code.org -[6]: https://www.amazon.com/Python-Programming-Introduction-Computer-Science/dp/1887902996 -[7]: https://nostarch.com/pythonforkids -[8]: https://automatetheboringstuff.com/ -[9]: https://nostarch.com/laurenipsum -[10]: https://www.raspberrypi.org/ -[11]: https://microbit.org/guide/ diff --git a/sources/talk/20190223 No- Ubuntu is NOT Replacing Apt with Snap.md b/sources/talk/20190223 No- Ubuntu is NOT Replacing Apt with Snap.md deleted file mode 100644 index bb7dd14943..0000000000 --- a/sources/talk/20190223 No- Ubuntu is NOT Replacing Apt with Snap.md +++ /dev/null @@ -1,76 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (No! Ubuntu is NOT Replacing Apt with Snap) -[#]: via: (https://itsfoss.com/ubuntu-snap-replaces-apt-blueprint/) -[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) - -No! Ubuntu is NOT Replacing Apt with Snap -====== - -Stop believing the rumors that Ubuntu is planning to replace Apt with Snap in the [Ubuntu 19.04 release][1]. These are only rumors. - -![Snap replacing apt rumors][2] - -Don’t get what I am talking about? Let me give you some context. - -There is a ‘blueprint’ on Ubuntu’s launchpad website, titled ‘Replace APT with snap as default package manager’. It talks about replacing Apt (package manager at the heart of Debian) with Snap ( a new packaging system by Ubuntu). - -> Thanks to Snap, the need for APT is disappearing, fast… why don’t we use snap at the system level? - -The post further says “Imagine, for example, being able to run “sudo snap install cosmic” to upgrade to the current release, “sudo snap install –beta disco” (in March) to upgrade to a beta release, or, for that matter, “sudo snap install –edge disco” to upgrade to a pre-beta release. It would make the whole process much easier, and updates could simply be delivered as updates to the corresponding snap, which could then just be pushed to the repositories and there it is. This way, instead of having a separate release updater, it would be possible to A, run all system updates completely and silently in the background to avoid nagging the user (a la Chrome OS), and B, offer release upgrades in the GNOME software store, Mac-style, as banners, so the user can install them easily. It would make the user experience both more consistent and even more user-friendly than it currently is.” - -It might sound good and promising and if you take a look at [this link][3], even you might start believing the rumor. Why? Because at the bottom of the blueprint information, it lists Ubuntu-founder Mark Shuttleworth as the approver. - -![Apt being replaced with Snap blueprint rumor][4]Mark Shuttleworth’s name adds to the confusion - -The rumor got fanned when the Switch to Linux YouTube channel covered it. You can watch the video from around 11:30. - - - -When this ‘news’ was brought to my attention, I reached out to Alan Pope of Canonical and asked him if he or his colleagues at Canonical (Ubuntu’s parent company) could confirm it. - -Alan clarified that the so called blueprint was not associated with official Ubuntu team. It was created as a proposal by some community member not affiliated with Ubuntu. - -> That’s not anything official. Some random community person made it. Anyone can write a blueprint. -> -> Alan Pope, Canonical - -Alan further elaborated that anyone can create such blueprints and tag Mark Shuttleworth or other Ubuntu members in it. Just because Mark’s name was listed as the approver, it doesn’t mean he already approved the idea. - -Canonical has no such plans to replace Apt with Snap. It’s not as simple as the blueprint in question suggests. - -After talking with Alan, I decided to not write about this topic because I don’t want to fan baseless rumors and confuse people. - -Unfortunately, the ‘replace Apt with Snap’ blueprint is still being shared on various Ubuntu and Linux related groups and forums. Alan had to publicly dismiss these rumors in a series of tweets: - -> Seen this [#Ubuntu][5] blueprint being shared around the internet. It's not official, not a thing we're doing. Just because someone made a blueprint, doesn't make it fact. -> -> — Alan Pope 🇪🇺🇬🇧 (@popey) [February 23, 2019][6] - -I don’t want you, the It’s FOSS reader, to fell for such silly rumors so I quickly penned this article. - -If you come across ‘apt being replaced with snap’ discussion, you may tell people that it’s not true and provide them this link as a reference. - - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/ubuntu-snap-replaces-apt-blueprint/ - -作者:[Abhishek Prakash][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/abhishek/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/ubuntu-19-04-release-features/ -[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/snap-replacing-apt.png?resize=800%2C450&ssl=1 -[3]: https://blueprints.launchpad.net/ubuntu/+spec/package-management-default-snap -[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/apt-snap-blueprint.jpg?ssl=1 -[5]: https://twitter.com/hashtag/Ubuntu?src=hash&ref_src=twsrc%5Etfw -[6]: https://twitter.com/popey/status/1099238146393468931?ref_src=twsrc%5Etfw diff --git a/sources/talk/20190228 Why CLAs aren-t good for open source.md b/sources/talk/20190228 Why CLAs aren-t good for open source.md deleted file mode 100644 index ca39619762..0000000000 --- a/sources/talk/20190228 Why CLAs aren-t good for open source.md +++ /dev/null @@ -1,76 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Why CLAs aren't good for open source) -[#]: via: (https://opensource.com/article/19/2/cla-problems) -[#]: author: (Richard Fontana https://opensource.com/users/fontana) - -Why CLAs aren't good for open source -====== -Few legal topics in open source are as controversial as contributor license agreements. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/write-hand_0.jpg?itok=Uw5RJD03) - -Few legal topics in open source are as controversial as [contributor license agreements][1] (CLAs). Unless you count the special historical case of the [Fedora Project Contributor Agreement][2] (which I've always seen as an un-CLA), or, like [Karl Fogel][3], you classify the [DCO][4] as a [type of CLA][5], today Red Hat makes no use of CLAs for the projects it maintains. - -It wasn't always so. Red Hat's earliest projects followed the traditional practice I've called "inbound=outbound," in which contributions to a project are simply provided under the project's open source license with no execution of an external, non-FOSS contract required. But in the early 2000s, Red Hat began experimenting with the use of contributor agreements. Fedora started requiring contributors to sign a CLA based on the widely adapted [Apache ICLA][6], while a Free Software Foundation-derived copyright assignment agreement and a pair of bespoke CLAs were inherited from the Cygnus and JBoss acquisitions, respectively. We even took [a few steps][7] towards adopting an Apache-style CLA across the rapidly growing set of Red Hat-led projects. - -This came to an end, in large part because those of us on the Red Hat legal team heard and understood the concerns and objections raised by Red Hat engineers and the wider technical community. We went on to become de facto leaders of what some have called the anti-CLA movement, marked notably by our [opposition to Project Harmony][8] and our [efforts][9] to get OpenStack to replace its CLA with the DCO. (We [reluctantly][10] sign tolerable upstream project CLAs out of practical necessity.) - -### Why CLAs are problematic - -Our choice not to use CLAs is a reflection of our values as an authentic open source company with deep roots in the free software movement. Over the years, many in the open source community have explained why CLAs, and the very similar mechanism of copyright assignment, are a bad policy for open source. - -One reason is the red tape problem. Normally, open source development is characterized by frictionless contribution, which is enabled by inbound=outbound without imposition of further legal ceremony or process. This makes it relatively easy for new contributors to get involved in a project, allowing more effective growth of contributor communities and driving technical innovation upstream. Frictionless contribution is a key part of the advantage open source development holds over proprietary alternatives. But frictionless contribution is negated by CLAs. Having to sign an unusual legal agreement before a contribution can be accepted creates a bureaucratic hurdle that slows down development and discourages participation. This cost persists despite the growing use of automation by CLA-using projects. - -CLAs also give rise to an asymmetry of legal power among a project's participants, which also discourages the growth of strong contributor and user communities around a project. With Apache-style CLAs, the company or organization leading the project gets special rights that other contributors do not receive, while those other contributors must shoulder certain legal obligations (in addition to the red tape burden) from which the project leader is exempt. The problem of asymmetry is most severe in copyleft projects, but it is present even when the outbound license is permissive. - -When assessing the arguments for and against CLAs, bear in mind that today, as in the past, the vast majority of the open source code in any product originates in projects that follow the inbound=outbound practice. The use of CLAs by a relatively small number of projects causes collateral harm to all the others by signaling that, for some reason, open source licensing is insufficient to handle contributions flowing into a project. - -### The case for CLAs - -Since CLAs continue to be a minority practice and originate from outside open source community culture, I believe that CLA proponents should bear the burden of explaining why they are necessary or beneficial relative to their costs. I suspect that most companies using CLAs are merely emulating peer company behavior without critical examination. CLAs have an understandable, if superficial, appeal to risk-averse lawyers who are predisposed to favor greater formality, paper, and process regardless of the business costs. Still, some arguments in favor of CLAs are often advanced and deserve consideration. - -**Easy relicensing:** If administered appropriately, Apache-style CLAs give the project steward effectively unlimited power to sublicense contributions under terms of the steward's choice. This is sometimes seen as desirable because of the potential need to relicense a project under some other open source license. But the value of easy relicensing has been greatly exaggerated by pointing to a few historical cases involving major relicensing campaigns undertaken by projects with an unusually large number of past contributors (all of which were successful without the use of a CLA). There are benefits in relicensing being hard because it results in stable legal expectations around a project and encourages projects to consult their contributor communities before undertaking significant legal policy changes. In any case, most inbound=outbound open source projects never attempt to relicense during their lifetime, and for the small number that do, relicensing will be relatively painless because typically the number of past contributors to contact will not be large. - -**Provenance tracking:** It is sometimes claimed that CLAs enable a project to rigorously track the provenance of contributions, which purportedly has some legal benefit. It is unclear what is achieved by the use of CLAs in this regard that is not better handled through such non-CLA means as preserving Git commit history. And the DCO would seem to be much better suited to tracking contributions, given that it is normally used on a per-commit basis, while CLAs are signed once per contributor and are administratively separate from code contributions. Moreover, provenance tracking is often described as though it were a benefit for the public, yet I know of no case where a project provides transparent, ready public access to CLA acceptance records. - -**License revocation:** Some CLA advocates warn of the prospect that a contributor may someday attempt to revoke a past license grant. To the extent that the concern is about largely judgment-proof individual contributors with no corporate affiliation, it is not clear why an Apache-style CLA provides more meaningful protection against this outcome compared to the use of an open source license. And, as with so many of the legal risks raised in discussions of open source legal policy, this appears to be a phantom risk. I have heard of only a few purported attempts at license revocation over the years, all of which were resolved quickly when the contributor backed down in the face of community pressure. - -**Unauthorized employee contribution:** This is a special case of the license revocation issue and has recently become a point commonly raised by CLA advocates. When an employee contributes to an upstream project, normally the employer owns the copyrights and patents for which the project needs licenses, and only certain executives are authorized to grant such licenses. Suppose an employee contributed proprietary code to a project without approval from the employer, and the employer later discovers this and demands removal of the contribution or sues the project's users. This risk of unauthorized contributions is thought to be minimized by use of something like the [Apache CCLA][11] with its representations and signature requirement, coupled with some adequate review process to ascertain that the CCLA signer likely was authorized to sign (a step which I suspect is not meaningfully undertaken by most CLA-using companies). - -Based on common sense and common experience, I contend that in nearly all cases today, employee contributions are done with the actual or constructive knowledge and consent of the employer. If there were an atmosphere of high litigation risk surrounding open source software, perhaps this risk should be taken more seriously, but litigation arising out of open source projects remains remarkably uncommon. - -More to the point, I know of no case where an allegation of copyright or patent infringement against an inbound=outbound project, not stemming from an alleged open source license violation, would have been prevented by use of a CLA. Patent risk, in particular, is often cited by CLA proponents when pointing to the risk of unauthorized contributions, but the patent license grants in Apache-style CLAs are, by design, quite narrow in scope. Moreover, corporate contributions to an open source project will typically be few in number, small in size (and thus easily replaceable), and likely to be discarded as time goes on. - -### Alternatives - -If your company does not buy into the anti-CLA case and cannot get comfortable with the simple use of inbound=outbound, there are alternatives to resorting to an asymmetric and administratively burdensome Apache-style CLA requirement. The use of the DCO as a complement to inbound=outbound addresses at least some of the concerns of risk-averse CLA advocates. If you must use a true CLA, there is no need to use the Apache model (let alone a [monstrous derivative][10] of it). Consider the non-specification core of the [Eclipse Contributor Agreement][12]—essentially the DCO wrapped inside a CLA—or the Software Freedom Conservancy's [Selenium CLA][13], which merely ceremonializes an inbound=outbound contribution policy. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/2/cla-problems - -作者:[Richard Fontana][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/fontana -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/article/18/3/cla-vs-dco-whats-difference -[2]: https://opensource.com/law/10/6/new-contributor-agreement-fedora -[3]: https://www.red-bean.com/kfogel/ -[4]: https://developercertificate.org -[5]: https://producingoss.com/en/contributor-agreements.html#developer-certificate-of-origin -[6]: https://www.apache.org/licenses/icla.pdf -[7]: https://www.freeipa.org/page/Why_CLA%3F -[8]: https://opensource.com/law/11/7/trouble-harmony-part-1 -[9]: https://wiki.openstack.org/wiki/OpenStackAndItsCLA -[10]: https://opensource.com/article/19/1/cla-proliferation -[11]: https://www.apache.org/licenses/cla-corporate.txt -[12]: https://www.eclipse.org/legal/ECA.php -[13]: https://docs.google.com/forms/d/e/1FAIpQLSd2FsN12NzjCs450ZmJzkJNulmRC8r8l8NYwVW5KWNX7XDiUw/viewform?hl=en_US&formkey=dFFjXzBzM1VwekFlOWFWMjFFRjJMRFE6MQ#gid=0 diff --git a/sources/talk/20190311 Discuss everything Fedora.md b/sources/talk/20190311 Discuss everything Fedora.md deleted file mode 100644 index 5795fbf3f7..0000000000 --- a/sources/talk/20190311 Discuss everything Fedora.md +++ /dev/null @@ -1,45 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Discuss everything Fedora) -[#]: via: (https://fedoramagazine.org/discuss-everything-fedora/) -[#]: author: (Ryan Lerch https://fedoramagazine.org/introducing-flatpak/) - -Discuss everything Fedora -====== -![](https://fedoramagazine.org/wp-content/uploads/2019/03/fedora-discussion-816x345.jpg) - -Are you interested in how Fedora is being developed? Do you want to get involved, or see what goes into making a release? You want to check out [Fedora Discussion][1]. It is a relatively new place where members of the Fedora Community meet to discuss, ask questions, and interact. Keep reading for more information. - -Note that the Fedora Discussion system is mainly aimed at contributors. If you have questions on using Fedora, check out [Ask Fedora][2] (which is being migrated in the future). - -![][3] - -Fedora Discussion is a forum and discussion site that uses the [Discourse open source discussion platform][4]. - -There are already several categories useful for Fedora users, including [Desktop][5] (covering Fedora Workstation, Fedora Silverblue, KDE, XFCE, and more) and the [Server, Cloud, and IoT][6] category . Additionally, some of the [Fedora Special Interest Groups (SIGs) have discussions as well][7]. Finally, the [Fedora Friends][8] category helps you connect with other Fedora users and Community members by providing discussions about upcoming meetups and hackfests. - - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/discuss-everything-fedora/ - -作者:[Ryan Lerch][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/introducing-flatpak/ -[b]: https://github.com/lujun9972 -[1]: https://discussion.fedoraproject.org/ -[2]: https://ask.fedoraproject.org -[3]: https://fedoramagazine.org/wp-content/uploads/2019/03/discussion-screenshot-1024x663.png -[4]: https://www.discourse.org/about -[5]: https://discussion.fedoraproject.org/c/desktop -[6]: https://discussion.fedoraproject.org/c/server -[7]: https://discussion.fedoraproject.org/c/sigs -[8]: https://discussion.fedoraproject.org/c/friends diff --git a/sources/talk/20190319 Hello World Marketing (or, How I Find Good, Boring Software).md b/sources/talk/20190319 Hello World Marketing (or, How I Find Good, Boring Software).md new file mode 100644 index 0000000000..02f7e3fcac --- /dev/null +++ b/sources/talk/20190319 Hello World Marketing (or, How I Find Good, Boring Software).md @@ -0,0 +1,100 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Hello World Marketing (or, How I Find Good, Boring Software)) +[#]: via: (https://theartofmachinery.com/2019/03/19/hello_world_marketing.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +Hello World Marketing (or, How I Find Good, Boring Software) +====== + +Back in 2001 Joel Spolsky wrote his classic essay [“Good Software Takes Ten Years. Get Used To it”][1]. Nothing much has changed since then: software is still taking around a decade of development to get good, and the industry is still getting used to that fact. Unfortunately, the industry has investors who want to see hockey stick growth rates on software that’s a year old or less. The result is an antipattern I like to call “Hello World Marketing”. Once you start to notice it, you see it everywhere, and it’s a huge red flag when choosing software tools. + + +Of course, by “Hello World”, I’m referring to the programmer’s traditional first program: the one that just displays the message “Hello World”. The aim isn’t to make a useful program; it’s to make a minimal starting point. + +Hello World Marketing is about doing the same thing, but pretending that it’s useful. You’re supposed to be distracted into admiring how neatly a tool solves trivial problems, and forget about features you’ll need in real applications. HWM emphasises what can be done in the first five minutes, and downplays what you might need after several months. HWMed software is optimised for looking good in demos, and sounding exciting in blog posts and presentations. + +For a good example, see Nemil Dalal’s [great series of articles about the early marketing for MongoDB][2]. Notice the heavy use of hackathons, and that a lot of the marketing was about how “SQL looks like COBOL”. Now, I can criticise SQL, too, but if `SELECT` and `WHERE` are serious problems for an application, there are already hundreds of solutions like [SQLAlchemy][3] and [LINQ][4] — solutions that don’t compromise on more advanced features of traditional databases. On the other hand, if you were wondering about those advanced features, you could read vomity-worthy, hand-wavey pieces like “[Living in the post-transactional database future][5]”. + +### How I Find Good, Boring Software + +Obviously, one way to avoid HWM is to stick to software that’s much more than ten years old, and has a good reputation. But sometimes that’s not possible because the tools for a problem only came out during the last decade. Also, sometimes newer tools really do bring new benefits. + +However, it’s much harder to rely on reputation for newer software because “good reputation” often just means “popular”, which often just means “current fad”. Thankfully, there’s a simple and effective trick to avoid being dazzled by hype: just look elsewhere. Instead of looking at the marketing for the core features, look at the things that are usually forgotten. Here are the kinds of things I look at: + +#### Backups and Disaster Recovery + +Backup support is both super important and regularly an afterthought. + +The minimum viable product is full data dump/import functionality, but longer term it’s nice to have things like incremental backups. Some vendors will try to tell you to just copy the data files from disk, but this isn’t guaranteed to give you a consistent snapshot if the software is running live. + +There’s no point backing up data if you can’t restore it, and restoration is the difficult part. Yet many people never test the restoration (until they actually need it). About five years ago I was working with a team that had started using a new, cutting-edge, big-data database. The database looked pretty good, but I suggested we do an end-to-end test of the backup support. We loaded a cluster with one of the multi-terabyte datasets we had, did a backup, wiped the data in the cluster and then tried to restore it. Turns out we were the first people to actually try to restore a dataset of that size — the backup “worked”, but the restoration caused the cluster to crash and burn. We filed a bug report with the original database developers and they fixed it. + +Backup processes that work on small test datasets but fail on large production datasets is a recurring theme. I always recommend testing on production-sized datasets, and testing again as production data grows. + +For batch jobs, a related concept is restartability. If you’re copying large amounts of data from one place to another, and the job gets interrupted in the middle, what happens? Can you keep going from the middle? Alternatively, can you safely retry by starting from the beginning? + +#### Configuration + +A lot of HWMed software can only be configured using a GUI or web UI because that’s what’s obvious and looks good in demos and docs. For one thing, this usually means there’s no good way to back up or restore the configuration. So if a team of people use a shared instance over a year or so, forget about trying to restore it if (or when) it breaks. It’s also much more work to keep multiple deployments consistent (e.g., for dev, testing and prod environments) using separate GUIs. In practice, it just doesn’t happen. + +I prefer a well-commented config file for software I deploy, if nothing else because it can be checked into source control, and I know I can reproduce the deployment using nothing but what’s checked into source control. If something is configured using a UI, I look for a config export/import function. Even then, that feature is often an afterthought, and often imcomplete, so it’s worth testing if it’s possible to deploy the software without ever needing to manually tweak something in the UI. + +There seems to be a recent trend for software to be configured using a REST API instead. Honestly, this is the worst of both config files and GUI-based config, and most of the time people end up using [hacky ways to put the config into a file instead][6]. + +#### Upgrades + +Life would be much easier if everything were static; software upgrade support makes everything more complicated. It’s also not usually shown in demos, so the first upgrade often ends the honeymoon with shiny, new software. + +For HA distributed systems, you’ll need support for graceful shutdown and a certain amount of forward _and_ backwards compatibility (because you’ll have multiple versions running during upgrades). It’s a common mistake to forget about downgrade support. + +Distributed systems are simpler when components have independent replicas that don’t communicate with each other. Anything with clustering (or, worse, consensus algorithms) is often extra tricky to upgrade, and worth testing. + +Things that support horizontal scaling don’t necessarily support rescaling without downtime. This is especially true whenever sharding is involved because live resharding isn’t trivial. + +Here’s a story from a certain popular container app platform. Demos showed how easy it was to launch an app on the platform, and then showed how easy it was to scale it to multiple replicas. What they didn’t show was the upgrade process: When you pushed a new version of your app, the first thing the platform did was _shut down all running instances of it_. Then it would upload the code to a build server and start building it — meaning downtime for however long the build took, plus the time needed to roll out the new version (if it worked). This problem has been fixed in newer releases of the platform. + +#### Security + +Even if software has no built-in access control, all-or-nothing access control is easy to implement (e.g., using a reverse proxy with HTTP basic auth). The harder problem is fine-grained access control. Sometimes you don’t care, but in some environments it makes a big difference to what features you can even use. + +Some immature software has a quick-and-dirty implementation of user-based access control, typically with a GUI for user management. For everything except the core business tool, this isn’t very useful. For human users, every project I’ve worked on has either been with a small team that just shared a single username/password, or with a large team that wanted integration with OpenID Connect, or LDAP, or whatever centralised single-sign-on (SSO) system was used by the organisation. No one wants to manually manage credentials for every tool, every time someone joins or leaves. Similarly, credentials for applications or other non-human users are better generated using an automatable approach — like a config file or API. + +Immature implementations of access control are often missing anything like user groups, but managing permissions at the user level is a time waster. Some SSO integrations only integrate users, not groups, which is a “so close yet so far” when it comes to avoiding permissions busywork. + +#### Others + +I talked about ignoring the hype, but there’s one good signal you can get from the marketing: whether the software is branded as “enterprise” software. Enterprise software is normally bought by someone other than the end user, so it’s usually pleasant to buy but horrible to use. The only exceptions I know of are enterprise versions of normal consumer software, and enterprise software that the buyer will also have to use. Be warned: even if a company sells enterprise software alongside consumer software, there’s no guarantee that they’re just different versions of the same product. Often they’ll be developed by separate teams with different priorities. + +A lot of the stuff in this post can be checked just by skimming through the documentation. If a tool stores data, but the documentation doesn’t mention backups, there probably isn’t any backup suppport. Even if there is and it’s just not documented, that’s not exactly a good sign either. So, sure, documentation quality is worth evaluating by itself. On the other hand, sometimes the documentation is better than the product, so I never trust a tool until I’ve actually tried it out. + +When I first saw Python, I knew that it was a terrible programming language because of the way it used whitespace indentation. Yeah, that was stupid. Later on I learned that 1) the syntax wasn’t a big deal, especially when I’m already indenting C-like languages in the same way, and 2) a lot of practical problems can be solved just by gluing libraries together with a few dozen lines of Python, and that was really useful. We often have strong opinions about syntax that are just prejudice. Syntax can matter, but it’s less important than how the tool integrates with the rest of the system. + +### Weighing Pros and Cons + +You never need to do deep analysis to detect the most overhyped products. Just check a few of these things and they’ll fail spectacularly. + +Even with software that looks solid, I still like to do more tests before entrusting a serious project with it. That’s not because I’m looking for excuses to nitpick and use my favourite tool instead. New tools often really do bring new benefits. But it’s much better to understand the pros and cons of new software, and to use it because the pros outweigh the cons, not because of how slick the Hello World demo is. + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2019/03/19/hello_world_marketing.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: https://www.joelonsoftware.com/2001/07/21/good-software-takes-ten-years-get-used-to-it/ +[2]: https://www.nemil.com/mongo/ +[3]: https://www.sqlalchemy.org/ +[4]: https://msdn.microsoft.com/en-us/library/bb308959.aspx +[5]: https://www.mongodb.com/post/36151042528/post-transactional-future +[6]: /2017/07/15/use_terraform_with_vault.html diff --git a/sources/talk/20190322 How to save time with TiDB.md b/sources/talk/20190322 How to save time with TiDB.md deleted file mode 100644 index 534c04de1f..0000000000 --- a/sources/talk/20190322 How to save time with TiDB.md +++ /dev/null @@ -1,143 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to save time with TiDB) -[#]: via: (https://opensource.com/article/19/3/how-save-time-tidb) -[#]: author: (Morgan Tocker https://opensource.com/users/morgo) - -How to save time with TiDB -====== - -TiDB, an open source-compatible, cloud-based database engine, simplifies many of MySQL database administrators' common tasks. - -![Team checklist][1] - -Last November, I wrote about key [differences between MySQL and TiDB][2], an open source-compatible, cloud-based database engine, from the perspective of scaling both solutions in the cloud. In this follow-up article, I'll dive deeper into the ways [TiDB][3] streamlines and simplifies administration. - -If you come from a MySQL background, you may be used to doing a lot of manual tasks that are either not required or much simpler with TiDB. - -The inspiration for TiDB came from the founders managing sharded MySQL at scale at some of China's largest internet companies. Since requirements for operating a large system at scale are a key concern, I'll look at some typical MySQL database administrator (DBA) tasks and how they translate to TiDB. - -[![TiDB architecture][4]][5] - -In [TiDB's architecture][5]: - - * SQL processing is separated from data storage. The SQL processing (TiDB) and storage (TiKV) components independently scale horizontally. - * PD (Placement Driver) acts as the cluster manager and stores metadata. - * All components natively provide high availability, with PD and TiKV using the [Raft consensus algorithm][6]. - * You can access your data via either MySQL (TiDB) or Spark (TiSpark) protocols. - - - -### Adding/fixing replication slaves - -**tl;dr:** It doesn't happen in the same way as in MySQL. - -Replication and redundancy of data are automatically managed by TiKV. You also don't need to worry about creating initial backups to seed replicas, as _both_ the provisioning and replication are handled for you. - -Replication is also quorum-based using the Raft consensus algorithm, so you don't have to worry about the inconsistency problems surrounding failures that you do with asynchronous replication (the default in MySQL and what many users are using). - -TiDB does support its own binary log, so it can be used for asynchronous replication between clusters. - -### Optimizing slow queries - -**tl;dr:** Still happens in TiDB - -There is no real way out of optimizing slow queries that have been introduced by development teams. - -As a mitigating factor though, if you need to add breathing room to your database's capacity while you work on optimization, the TiDB's architecture allows you to horizontally scale. - -### Upgrades and maintenance - -**tl;dr:** Still required, but generally easier - -Because the TiDB server is stateless, you can roll through an upgrade and deploy new TiDB servers. Then you can remove the older TiDB servers from the load balancer pool, shutting down them once connections have drained. - -Upgrading PD is also quite straightforward since only the PD leader actively answers requests at a time. You can perform a rolling upgrade and upgrade PD's non-leader peers one at a time, and then change the leader before upgrading the final PD server. - -For TiKV, the upgrade is marginally more complex. If you want to remove a node, I recommend first setting it to be a follower on each of the regions where it is currently a leader. After that, you can bring down the node without impacting your application. If the downtime is brief, TiKV will recover with its regional peers from the Raft log. In a longer downtime, it will need to re-copy data. This can all be managed for you, though, if you choose to deploy using Ansible or Kubernetes. - -### Manual sharding - -**tl;dr:** Not required - -Manual sharding is mainly a pain on the part of the application developers, but as a DBA, you might have to get involved if the sharding is naive or has problems such as hotspots (many workloads do) that require re-balancing. - -In TiDB, re-sharding or re-balancing happens automatically in the background. The PD server observes when data regions (TiKV's term for chunks of data in key-value form) get too small, too big, or too frequently accessed. - -You can also explicitly configure PD to store regions on certain TiKV servers. This works really well when combined with MySQL partitioning. - -### Capacity planning - -**tl;dr:** Much easier - -Capacity planning on a MySQL database can be a little bit hard because you need to plan your physical infrastructure requirements two to three years from now. As data grows (and the working set changes), this can be a difficult task. I wouldn't say it completely goes away in the cloud either, since changing a master server's hardware is always hard. - -TiDB splits data into approximately 100MiB chunks that it distributes among TiKV servers. Because this increment is much smaller than a full server, it's much easier to move around and redistribute data. It's also possible to add new servers in smaller increments, which is easier on planning. - -### Scaling - -**tl;dr:** Much easier - -This is related to capacity planning and sharding. When we talk about scaling, many people think about very large _systems,_ but that is not exclusively how I think of the problem: - - * Scaling is being able to start with something very small, without having to make huge investments upfront on the chance it could become very large. - * Scaling is also a people problem. If a system requires too much internal knowledge to operate, it can become hard to grow as an engineering organization. The barrier to entry for new hires can become very high. - - - -Thus, by providing automatic sharding, TiDB can scale much easier. - -### Schema changes (DDL) - -**tl;dr:** Mostly better - -The data definition language (DDL) supported in TiDB is all online, which means it doesn't block other reads or writes to the system. It also doesn't block the replication stream. - -That's the good news, but there are a couple of limitations to be aware of: - - * TiDB does not currently support all DDL operations, such as changing the primary key or some "change data type" operations. - * TiDB does not currently allow you to chain multiple DDL changes in the same command, e.g., _ALTER TABLE t1 ADD INDEX (x), ADD INDEX (y)_. You will need to break these queries up into individual DDL queries. - - - -This is an area that we're looking to improve in [TiDB 3.0][7]. - -### Creating one-off data dumps for the reporting team - -**tl;dr:** May not be required - -DBAs loathe manual tasks that create one-off exports of data to be consumed by another team, perhaps in an analytics tool or data warehouse. - -This is often required when the types of queries that are be executed on the dataset are analytical. TiDB has hybrid transactional/analytical processing (HTAP) capabilities, so in many cases, these queries should work fine. If your analytics team is using Spark, you can also use the [TiSpark][8] connector to allow them to connect directly to TiKV. - -This is another area we are improving with [TiFlash][7], a column store accelerator. We are also working on a plugin system to support external authentication. This will make it easier to manage access by the reporting team. - -### Conclusion - -In this post, I looked at some common MySQL DBA tasks and how they translate to TiDB. If you would like to learn more, check out our [TiDB Academy course][9] designed for MySQL DBAs (it's free!). - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/3/how-save-time-tidb - -作者:[Morgan Tocker][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/morgo -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_todo_clock_time_team.png?itok=1z528Q0y (Team checklist) -[2]: https://opensource.com/article/18/11/key-differences-between-mysql-and-tidb -[3]: https://github.com/pingcap/tidb -[4]: https://opensource.com/sites/default/files/uploads/tidb_architecture.png (TiDB architecture) -[5]: https://pingcap.com/docs/architecture/ -[6]: https://raft.github.io/ -[7]: https://pingcap.com/blog/tidb-3.0-beta-stability-at-scale/ -[8]: https://github.com/pingcap/tispark -[9]: https://pingcap.com/tidb-academy/ diff --git a/sources/talk/20190405 D as a C Replacement.md b/sources/talk/20190405 D as a C Replacement.md new file mode 100644 index 0000000000..36b60bb278 --- /dev/null +++ b/sources/talk/20190405 D as a C Replacement.md @@ -0,0 +1,247 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (D as a C Replacement) +[#]: via: (https://theartofmachinery.com/2019/04/05/d_as_c_replacement.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +D as a C Replacement +====== + +Sircmpwn (the main developer behind the [Sway Wayland compositor][1]) recently wrote a blog post about how he thinks [Rust is not a good C replacement][2]. I don’t know if he’d like the [D programming language][3] either, but it’s become a C replacement for me. + +### My C to D Story + +My story is like a lot of systems programmers’ stories. At one time, C was my go-to language for most programming. One day I realised that most of my C programs kept reimplementing things from C++: dynamic arrays, better strings, polymorphic classes, etc. So I tried using C++ instead, and at first I loved it. RAII and classes and generics made programming fun again. Even better was the promise that if I read all these books on C++, and learned to master things like template metaprogramming, I’d become an almighty god of systems programming and my code would be amazing. But learning more eventually had the opposite effect: (in hindsight) my code actually got worse, and I fell out of love. I remember reading Scott Meyer’s Effective C++ and realising it was really more about _ineffective_ C++ — and that most of my C++ code until then was broken. Let’s face it: C might be fiddly to use, but it has a kind of elegance, and “elegant” is rarely a word you hear when C++ is involved. + +Apparently, a lot of ex-C C++ programmers end up going back to C. In my case, I discovered D. It’s also not perfect, but I use it because it feels to me a lot more like the `C += 1` that C++ was meant to be. Here’s an example that’s very superficial, but I think is representative. Take this simple C program: + +``` +#include + +int main() +{ + printf("1 + 1 = %d!\n", 1 + 1); + return 0; +} +``` + +Here’s a version using the C++ standard library: + +``` +#include + +int main() +{ + std::cout << "1 + 1 = " << 1 + 1 << "!" << std::endl; + return 0; +} +``` + +Here’s an idiomatic D version: + +``` +import std.stdio; + +void main() +{ + writef("1 + 1 = %d!\n", 1 + 1); +} +``` + +As I said, it’s a superficial example, but I think it shows a general difference in philosophy between C++ and D. (If I wanted to make the difference even clearer, I’d use an example that needed `iomanip` in C++.) + +Update: Unlike in C, [D’s format strings can work with custom types][4]. Stefan Rohe has also pointed out that [D supports compile-time checking of format strings][5] using its metaprogramming features — unlike C which does it through built-in compiler special casing that can’t be used with custom code. + +This [article about C++ member function pointers][6] happens to also be a good explanation of the origins of D. It’s a good read if you’re a programming language nerd like me, but here’s my TL;DR for everyone else: C++ member function pointers are supposed to feel like a low-level feature (like normal function pointers are), but the complexity and diversity of implementations means they’re really high level. The complexity of the implementations is because of the subtleties of the rules about what you can do with them. The author explains the implementations from several C++ compilers, including what’s “easily [his] favorite implementation”: the elegantly simple Digital Mars C++ implementation. (“Why doesn’t everyone else do it this way?”) The DMC compiler was written by Walter Bright, who invented D. + +D has classes and templates and other core features of C++, but designed by someone who has spent a heck of a lot of time thinking about the C++ spec and how things could be simpler. Walter once said that his experiences implementing C++ templates made him consider not including them in D at all, until he realised they didn’t need to be so complex. + +Here’s a quick tour of D from the point of view of incrementally improving C. + +### `-betterC` + +D compilers support a `-betterC` switch that disables [the D runtime][7] and all high-level features that depend on it. The example C code above can be translated directly into betterC: + +``` +import core.stdc.stdio; + +extern(C): + +int main() +{ + printf("1 + 1 = %d!\n", 1 + 1); + return 0; +} + +$ dmd -betterC example.d +$ ./example +1 + 1 = 2! +``` + +The resulting binary looks a lot like the equivalent C binary. In fact, if you rewrote a C library in betterC, it could still link to code that had been compiled against the C version, and work without changes. Walter Bright wrote a good article walking through all [the changes needed to convert a real C program to betterC][8]. + +You don’t actually need the `-betterC` switch just to write C-like code in D. It’s only needed in special cases where you simply can’t have the D runtime. But let me point out some of my favourite D features that still work with `-betterC`. + +#### `static assert()` + +This allows verifying some assumption at compile time. + +``` +static assert(kNumInducers < 16); +``` + +Systems code often makes assumptions about alignment or structure size or other things. With `static assert`, it’s possible to not only document these assumptions, but trigger a compilation error if someone breaks them by adding a struct member or something. + +#### Slices + +Typical C code is full of pointer/length pairs, and it’s a common bug for them to go out of sync. Slices are a simple and super-useful abstraction for a range of memory defined by a pointer and length. Instead of code like this: + +``` +buffer_p += offset; +buffer_len -= offset; // Got to update both +``` + +You can use this much-less-bug-prone alternative: + +``` +buffer = buffer[offset..$]; +``` + +A slice is nothing but a pointer/length pair with first-class syntactic support. + +Update: [Walter Bright has written more about pointer/length pair problem in C][9]. + +#### Compile Time Function Evaluation (CTFE) + +[Many functions can be evaluated at compile time.][10] + +``` +long factorial(int n) pure +{ + assert (n >= 0 && n <= 20); + long ret = 1; + foreach (j; 2..n+1) ret *= j; + return ret; +} + +// Statically allocated array +// Size is calculated at compile time +Permutation[factorial(kNumThings)] permutation_table; +``` + +#### `scope` Guards + +Code in one part of a function is often coupled to cleanup code in a later part. Failing to match this code up correctly is another common source of bugs (especially when multiple control flow paths are involved). D’s scope guards make it simple to get this stuff right: + +``` +p = malloc(128); +// free() will be called when the current scope exits +scope (exit) free(p); +// Put whatever if statements, or loops, or early returns you like here +``` + +You can even have multiple scope guards in a scope, or have nested scopes. The cleanup routines will be called when needed, in the right order. + +D also supports RAII using struct destructors. + +#### `const` and `immutable` + +It’s a popular myth that `const` in C and C++ is useful for compiler optimisations. Walter Bright has complained that every time he thought of a new `const`-based optimisation for C++, he eventually discovered it didn’t work in real code. So he made some changes to `const` semantics for D, and added `immutable`. You can read more in the [D `const` FAQ][11]. + +#### `pure` + +Functional purity can be enforced. I’ve written about [some of the benefits of the `pure` keyword before][12]. + +#### `@safe` + +SafeD is a subset of D that forbids risky language features like pointer typecasts and inline assembly. Code marked `@safe` is enforced by the compiler to not use these features, so that risky code can be limited to the small percentage of the application that needs it. You can [read more about SafeD in this article][13]. + +#### Metaprogramming + +Like I hinted earlier, metaprogramming has got a bad reputation among some C++ programmers. But [D has the advantage of making metaprogramming less interesting][14], so D programmers tend to just do it when it’s useful, and not as a fun puzzle. + +D has great support for [compile-time reflection][15]. In most cases, compile-time reflection can solve the same problems as run-time reflection, but with compile-time guarantees. Compile-time reflection can also be used to implement run-time reflection where it’s truly needed. + +Need the names of an enumerated type as an array? + +``` +enum State +{ + stopped, + starting, + running, + stopping, +} + +string[] state_names = [__traits(allMembers, State)]; +``` + +Thanks to D’s metaprogramming, the standard library has many nice, type-safe tools, like this [compile-time checked bit flag enum][16]. + +I’ve written more about [using metaprogramming in `-betterC` code][17]. + +#### No Preprocessor + +Okay, this a non-feature as a feature, but D has no equivalent to C’s preprocessor. All its sane use-cases are replaced with native language features, like [manifest constants][18] and [templates][19]. That includes proper [modules][20] support, which means D can break free of the limitations of that old `#include` hack. + +### Normal D + +C-like D code can be written and compiled as normal D code without the `-betterC` switch. The difference is that normal D code is linked to the D runtime, which supports higher-level features, the most obvious ones being garbage collection and object-oriented classes. Some people have confused the D runtime with something like the Java virtual machine, so I once wrote [an article explaining exactly what it is][7] (spoiler: it’s like the C and C++ runtimes, but with more features). + +Even with the runtime, compiled D is not much different from compiled C++. Sometimes I like to write throwaway code to, say, experiment with a new Linux system call or something. I used to think the best language for that is plain old C, but now I always use D. + +D doesn’t natively support `#include`ing C code, but for nice APIs that don’t have a lot of preprocessor craziness (like most of Linux) I usually just write [ad-hoc bindings][21]. Many popular C libraries have maintained D bindings, which can be found in the [Dub registry][22], or in [the Derelict project][23], or in the newer [BindBC project][24]. There are also tools for automated bindings, including the awesome [dpp tool][25] that brings `#include` support directly to D code. + +Update: This post has got a lot of attention from people who’ve never heard of D before. If you’re interested in learning D, I recommend + + * [The DLang Tour][26] for a quick dive into the language + * [Ali Çehreli’s Programming in D book][27] if you prefer something in-depth + * [The D forum Learn group][28] or [IRC channel][29] to get answers to your questions + + + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2019/04/05/d_as_c_replacement.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: https://swaywm.org/ +[2]: https://drewdevault.com/2019/03/25/Rust-is-not-a-good-C-replacement.html +[3]: https://dlang.org +[4]: https://wiki.dlang.org/Defining_custom_print_format_specifiers +[5]: https://dlang.org/phobos/std_format.html#format +[6]: https://www.codeproject.com/Articles/7150/Member-Function-Pointers-and-the-Fastest-Possible +[7]: /2017/06/04/what_is_the_d_runtime.html +[8]: https://dlang.org/blog/2018/06/11/dasbetterc-converting-make-c-to-d/ +[9]: https://www.digitalmars.com/articles/b44.html +[10]: https://dlang.org/spec/function.html#interpretation +[11]: https://dlang.org/articles/const-faq.html +[12]: /2016/03/28/dirtying_pure_functions_can_be_useful.html +[13]: https://dlang.org/blog/2016/09/28/how-to-write-trusted-code-in-d/ +[14]: https://epi.github.io/2017/03/18/less_fun.html +[15]: https://dlang.org/spec/traits.html +[16]: https://dlang.org/phobos/std_typecons.html#BitFlags +[17]: /2018/08/13/inheritance_and_polymorphism_2.html +[18]: https://dlang.org/spec/enum.html#manifest_constants +[19]: https://tour.dlang.org/tour/en/basics/templates +[20]: https://ddili.org/ders/d.en/modules.html +[21]: https://wiki.dlang.org/Bind_D_to_C +[22]: https://code.dlang.org/ +[23]: https://github.com/DerelictOrg +[24]: https://github.com/BindBC +[25]: https://github.com/atilaneves/dpp +[26]: https://tour.dlang.org/ +[27]: https://ddili.org/ders/d.en/index.html +[28]: https://forum.dlang.org/group/learn +[29]: irc://irc.freenode.net/d diff --git a/sources/talk/20190410 Google partners with Intel, HPE and Lenovo for hybrid cloud.md b/sources/talk/20190410 Google partners with Intel, HPE and Lenovo for hybrid cloud.md deleted file mode 100644 index 5603086a53..0000000000 --- a/sources/talk/20190410 Google partners with Intel, HPE and Lenovo for hybrid cloud.md +++ /dev/null @@ -1,60 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Google partners with Intel, HPE and Lenovo for hybrid cloud) -[#]: via: (https://www.networkworld.com/article/3388062/google-partners-with-intel-hpe-and-lenovo-for-hybrid-cloud.html#tk.rss_all) -[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) - -Google partners with Intel, HPE and Lenovo for hybrid cloud -====== -Google boosted its on-premises and cloud connections with Kubernetes and serverless computing. -![Ilze Lucero \(CC0\)][1] - -Still struggling to get its Google Cloud business out of single-digit marketshare, Google this week introduced new partnerships with Lenovo and Intel to help bolster its hybrid cloud offerings, both built on Google’s Kubernetes container technology. - -At Google’s Next ’19 show this week, Intel and Google said they will collaborate on Google's Anthos, a new reference design based on the second-Generation Xeon Scalable processor introduced last week and an optimized Kubernetes software stack designed to deliver increased workload portability between public and private cloud environments. - -**[ Read also:[What hybrid cloud means in practice][2] | Get regularly scheduled insights: [Sign up for Network World newsletters][3] ]** - -As part the Anthos announcement, Hewlett Packard Enterprise (HPE) said it has validated Anthos on its ProLiant servers, while Lenovo has done the same for its ThinkAgile platform. This solution will enable customers to get a consistent Kubernetes experience between Google Cloud and their on-premises HPE or Lenovo servers. No official word from Dell yet, but they can’t be far behind. - -Users will be able to manage their Kubernetes clusters and enforce policy consistently across environments – either in the public cloud or on-premises. In addition, Anthos delivers a fully integrated stack of hardened components, including OS and container runtimes that are tested and validated by Google, so customers can upgrade their clusters with confidence and minimize downtime. - -### What is Google Anthos? - -Google formally introduced [Anthos][4] at this year’s show. Anthos, formerly Cloud Services Platform, is meant to allow users to run their containerized applications without spending time on building, managing, and operating Kubernetes clusters. It runs both on Google Cloud Platform (GCP) with Google Kubernetes Engine (GKE) and in your data center with GKE On-Prem. Anthos will also let you manage workloads running on third-party clouds such as Amazon Web Services (AWS) and Microsoft Azure. - -Google also announced the beta release of Anthos Migrate, which auto-migrates virtual machines (VM) from on-premises or other clouds directly into containers in GKE with minimal effort. This allows enterprises to migrate their infrastructure in one streamlined motion, without upfront modifications to the original VMs or applications. - -Intel said it will publish the production design as an Intel Select Solution, as well as a developer platform, making it available to anyone who wants it. - -### Serverless environments - -Google isn’t stopping with Kubernetes containers, it’s also pushing ahead with serverless environments. [Cloud Run][5] is Google’s implementation of serverless computing, which is something of a misnomer. You still run your apps on servers; you just aren’t using a dedicated physical server. It is stateless, so resources are not allocated until you actually run or use the application. - -Cloud Run is a fully serverless offering that takes care of all infrastructure management, including the provisioning, configuring, scaling, and managing of servers. It automatically scales up or down within seconds, even down to zero depending on traffic, ensuring you pay only for the resources you actually use. Cloud Run can be used on GKE, offering the option to run side by side with other workloads deployed in the same cluster. - -Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3388062/google-partners-with-intel-hpe-and-lenovo-for-hybrid-cloud.html#tk.rss_all - -作者:[Andy Patrizio][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Andy-Patrizio/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2018/03/cubes_blocks_squares_containers_ilze_lucero_cc0_via_unsplash_1200x800-100752172-large.jpg -[2]: https://www.networkworld.com/article/3249495/what-hybrid-cloud-mean-practice -[3]: https://www.networkworld.com/newsletters/signup.html -[4]: https://cloud.google.com/blog/topics/hybrid-cloud/new-platform-for-managing-applications-in-todays-multi-cloud-world -[5]: https://cloud.google.com/blog/products/serverless/announcing-cloud-run-the-newest-member-of-our-serverless-compute-stack -[6]: https://www.facebook.com/NetworkWorld/ -[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190410 HPE and Nutanix partner for hyperconverged private cloud systems.md b/sources/talk/20190410 HPE and Nutanix partner for hyperconverged private cloud systems.md deleted file mode 100644 index 76f908c68b..0000000000 --- a/sources/talk/20190410 HPE and Nutanix partner for hyperconverged private cloud systems.md +++ /dev/null @@ -1,60 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (HPE and Nutanix partner for hyperconverged private cloud systems) -[#]: via: (https://www.networkworld.com/article/3388297/hpe-and-nutanix-partner-for-hyperconverged-private-cloud-systems.html#tk.rss_all) -[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) - -HPE and Nutanix partner for hyperconverged private cloud systems -====== -Both companies will sell HP ProLiant appliances with Nutanix software but to different markets. -![Hewlett Packard Enterprise][1] - -Hewlett Packard Enterprise (HPE) has partnered with Nutanix to offer Nutanix’s hyperconverged infrastructure (HCI) software available as a managed private cloud service and on HPE-branded appliances. - -As part of the deal, the two companies will be competing against each other in hardware sales, sort of. If you want the consumption model you get through HPE’s GreenLake, where your usage is metered and you pay for only the time you use it (similar to the cloud), then you would get the ProLiant hardware from HPE. - -If you want an appliance model where you buy the hardware outright, like in the traditional sense of server sales, you would get the same ProLiant through Nutanix. - -**[ Read also:[What is hybrid cloud computing?][2] and [Multicloud mania: what to know][3] ]** - -As it is, HPE GreenLake offers multiple cloud offerings to customers, including virtualization courtesy of VMware and Microsoft. With the Nutanix partnership, HPE is adding Nutanix’s free Acropolis hypervisor to its offerings. - -“Customers get to choose an alternative to VMware with this,” said Pradeep Kumar, senior vice president and general manager of HPE’s Pointnext consultancy. “They like the Acropolis license model, since it’s license-free. Then they have choice points so pricing is competitive. Some like VMware, and I think it’s our job to offer them both and they can pick and choose.” - -Kumar added that the whole Nutanix stack is 15 to 18% less with Acropolis than a VMware-powered system, since they save on the hypervisor. - -The HPE-Nutanix partnership offers a fully managed hybrid cloud infrastructure delivered as a service and deployed in customers’ data centers or co-location facility. The managed private cloud service gives enterprises a hyperconverged environment in-house without having to manage the infrastructure themselves and, more importantly, without the burden of ownership. GreenLake operates more like a lease than ownership. - -### HPE GreenLake's private cloud services promise to significantly reduce costs - -HPE is pushing hard on GreenLake, which basically mimics cloud platform pricing models of paying for what you use rather than outright ownership. Kumar said HPE projects the consumption model will account for 30% of HPE’s business in the next few years. - -GreenLake makes some hefty promises. According to Nutanix-commissioned IDC research, customers will achieve a 60% reduction in the five-year cost of operations, while a HPE-commissioned Forrester report found customers benefit from a 30% Capex savings due to eliminated need for overprovisioning and a 90% reduction in support and professional services costs. - -By shifting to an IT as a Service model, HPE claims to provide a 40% increase in productivity by reducing the support load on IT operations staff and to shorten the time to deploy IT projects by 65%. - -The two new offerings from the partnership – HPE GreenLake’s private cloud service running Nutanix software and the HPE-branded appliances integrated with Nutanix software – are expected to be available during the 2019 third quarter, the companies said. - -Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3388297/hpe-and-nutanix-partner-for-hyperconverged-private-cloud-systems.html#tk.rss_all - -作者:[Andy Patrizio][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Andy-Patrizio/ -[b]: https://github.com/lujun9972 -[1]: https://images.techhive.com/images/article/2015/11/hpe_building-100625424-large.jpg -[2]: https://www.networkworld.com/article/3233132/cloud-computing/what-is-hybrid-cloud-computing.html -[3]: https://www.networkworld.com/article/3252775/hybrid-cloud/multicloud-mania-what-to-know.html -[4]: https://www.facebook.com/NetworkWorld/ -[5]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190412 Gov-t warns on VPN security bug in Cisco, Palo Alto, F5, Pulse software.md b/sources/talk/20190412 Gov-t warns on VPN security bug in Cisco, Palo Alto, F5, Pulse software.md deleted file mode 100644 index b5d5c21ee6..0000000000 --- a/sources/talk/20190412 Gov-t warns on VPN security bug in Cisco, Palo Alto, F5, Pulse software.md +++ /dev/null @@ -1,76 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Gov’t warns on VPN security bug in Cisco, Palo Alto, F5, Pulse software) -[#]: via: (https://www.networkworld.com/article/3388646/gov-t-warns-on-vpn-security-bug-in-cisco-palo-alto-f5-pulse-software.html#tk.rss_all) -[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) - -Gov’t warns on VPN security bug in Cisco, Palo Alto, F5, Pulse software -====== -VPN packages from Cisco, Palo Alto, F5 and Pusle may improperly secure tokens and cookies -![Getty Images][1] - -The Department of Homeland Security has issued a warning that some [VPN][2] packages from Cisco, Palo Alto, F5 and Pusle may improperly secure tokens and cookies, allowing nefarious actors an opening to invade and take control over an end user’s system. - -The DHS’s Cybersecurity and Infrastructure Security Agency (CISA) [warning][3] comes on the heels of a notice from Carnegie Mellon's CERT that multiple VPN applications store the authentication and/or session cookies insecurely in memory and/or log files. - -**[Also see:[What to consider when deploying a next generation firewall][4]. Get regularly scheduled insights by [signing up for Network World newsletters][5]]** - -“If an attacker has persistent access to a VPN user's endpoint or exfiltrates the cookie using other methods, they can replay the session and bypass other authentication methods,” [CERT wrote][6]. “An attacker would then have access to the same applications that the user does through their VPN session.” - -According to the CERT warning, the following products and versions store the cookie insecurely in log files: - - * Palo Alto Networks GlobalProtect Agent 4.1.0 for Windows and GlobalProtect Agent 4.1.10 and earlier for macOS0 ([CVE-2019-1573][7]) - * Pulse Secure Connect Secure prior to 8.1R14, 8.2, 8.3R6, and 9.0R2. - - - -The following products and versions store the cookie insecurely in memory: - - * Palo Alto Networks GlobalProtect Agent 4.1.0 for Windows and GlobalProtect Agent 4.1.10 and earlier for macOS0. - * Pulse Secure Connect Secure prior to 8.1R14, 8.2, 8.3R6, and 9.0R2. - * Cisco AnyConnect 4.7.x and prior. - - - -CERT says that Palo Alto Networks GlobalProtect version 4.1.1 [patches][8] this vulnerability. - -In the CERT warning F5 stated it has been aware of the insecure memory storage since 2013 and has not yet been patched. More information can be found [here][9]. F5 also stated it has been aware of the insecure log storage since 2017 and fixed it in version 12.1.3 and 13.1.0 and onwards. More information can be found [here][10]. - -**[[Prepare to become a Certified Information Security Systems Professional with this comprehensive online course from PluralSight. Now offering a 10-day free trial!][11] ]** - -CERT said it is unaware of any patches at the time of publishing for Cisco AnyConnect and Pulse Secure Connect Secure. - -CERT credited the [National Defense ISAC Remote Access Working Group][12] for reporting the vulnerability. - -Join the Network World communities on [Facebook][13] and [LinkedIn][14] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3388646/gov-t-warns-on-vpn-security-bug-in-cisco-palo-alto-f5-pulse-software.html#tk.rss_all - -作者:[Michael Cooney][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Michael-Cooney/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2018/10/broken-chain_metal_link_breach_security-100777433-large.jpg -[2]: https://www.networkworld.com/article/3268744/understanding-virtual-private-networks-and-why-vpns-are-important-to-sd-wan.html -[3]: https://www.us-cert.gov/ncas/current-activity/2019/04/12/Vulnerability-Multiple-VPN-Applications -[4]: https://www.networkworld.com/article/3236448/lan-wan/what-to-consider-when-deploying-a-next-generation-firewall.html -[5]: https://www.networkworld.com/newsletters/signup.html -[6]: https://www.kb.cert.org/vuls/id/192371/ -[7]: https://nvd.nist.gov/vuln/detail/CVE-2019-1573 -[8]: https://securityadvisories.paloaltonetworks.com/Home/Detail/146 -[9]: https://support.f5.com/csp/article/K14969 -[10]: https://support.f5.com/csp/article/K45432295 -[11]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr -[12]: https://ndisac.org/workinggroups/ -[13]: https://www.facebook.com/NetworkWorld/ -[14]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190417 Cisco Talos details exceptionally dangerous DNS hijacking attack.md b/sources/talk/20190417 Cisco Talos details exceptionally dangerous DNS hijacking attack.md deleted file mode 100644 index db534e4457..0000000000 --- a/sources/talk/20190417 Cisco Talos details exceptionally dangerous DNS hijacking attack.md +++ /dev/null @@ -1,130 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Cisco Talos details exceptionally dangerous DNS hijacking attack) -[#]: via: (https://www.networkworld.com/article/3389747/cisco-talos-details-exceptionally-dangerous-dns-hijacking-attack.html#tk.rss_all) -[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) - -Cisco Talos details exceptionally dangerous DNS hijacking attack -====== -Cisco Talos says state-sponsored attackers are battering DNS to gain access to sensitive networks and systems -![Peshkova / Getty][1] - -Security experts at Cisco Talos have released a [report detailing][2] what it calls the “first known case of a domain name registry organization that was compromised for cyber espionage operations.” - -Talos calls ongoing cyber threat campaign “Sea Turtle” and said that state-sponsored attackers are abusing DNS to harvest credentials to gain access to sensitive networks and systems in a way that victims are unable to detect, which displays unique knowledge on how to manipulate DNS, Talos stated. - -**More about DNS:** - - * [DNS in the cloud: Why and why not][3] - * [DNS over HTTPS seeks to make internet use more private][4] - * [How to protect your infrastructure from DNS cache poisoning][5] - * [ICANN housecleaning revokes old DNS security key][6] - - - -By obtaining control of victims’ DNS, the attackers can change or falsify any data on the Internet, illicitly modify DNS name records to point users to actor-controlled servers; users visiting those sites would never know, Talos reported. - -DNS, routinely known as the Internet’s phonebook, is part of the global internet infrastructure that translates between familiar names and the numbers computers need to access a website or send an email. - -### Threat to DNS could spread - -At this point Talos says Sea Turtle isn't compromising organizations in the U.S. - -“While this incident is limited to targeting primarily national security organizations in the Middle East and North Africa, and we do not want to overstate the consequences of this specific campaign, we are concerned that the success of this operation will lead to actors more broadly attacking the global DNS system,” Talos stated. - -Talos reports that the ongoing operation likely began as early as January 2017 and has continued through the first quarter of 2019. “Our investigation revealed that approximately 40 different organizations across 13 different countries were compromised during this campaign,” Talos stated. “We assess with high confidence that this activity is being carried out by an advanced, state-sponsored actor that seeks to obtain persistent access to sensitive networks and systems.” - -**[[Prepare to become a Certified Information Security Systems Professional with this comprehensive online course from PluralSight. Now offering a 10-day free trial!][7] ]** - -Talos says the attackers directing the Sea Turtle campaign show signs of being highly sophisticated and have continued their attacks despite public reports of their activities. In most cases, threat actors typically stop or slow down their activities once their campaigns are publicly revealed suggesting the Sea Turtle actors are unusually brazen and may be difficult to deter going forward, Talos stated. - -In January the Department of Homeland Security (DHS) [issued an alert][8] about this activity, warning that an attacker could redirect user traffic and obtain valid encryption certificates for an organization’s domain names. - -At that time the DHS’s [Cybersecurity and Infrastructure Security Agency][9] said in its [Emergency Directive][9] that it was tracking a series of incidents targeting DNS infrastructure. CISA wrote that it “is aware of multiple executive branch agency domains that were impacted by the tampering campaign and has notified the agencies that maintain them.” - -### DNS hijacking - -CISA said that attackers have managed to intercept and redirect web and mail traffic and could target other networked services. The agency said the attacks start with compromising user credentials of an account that can make changes to DNS records. Then the attacker alters DNS records, like Address, Mail Exchanger, or Name Server records, replacing the legitimate address of the services with an address the attacker controls. - -To achieve their nefarious goals, Talos stated the Sea Turtle accomplices: - - * Use DNS hijacking through the use of actor-controlled name servers. - * Are aggressive in their pursuit targeting DNS registries and a number of registrars, including those that manage country-code top-level domains (ccTLD). - - - * Use Let’s Encrypts, Comodo, Sectigo, and self-signed certificates in their man-in-the-middle (MitM) servers to gain the initial round of credentials. - - - * Steal victim organization’s legitimate SSL certificate and use it on actor-controlled servers. - - - -Such actions also distinguish Sea Turtle from an earlier DNS exploit known as DNSpionage, which [Talos ​reported][10]​ on in November 2018. - -Talos noted “with high confidence” that these operations are distinctly different and independent from the operations performed by [DNSpionage.][11] - -In that report, Talos said a DNSpionage campaign utilized two fake, malicious websites containing job postings that were used to compromise targets via malicious Microsoft Office documents with embedded macros. The malware supported HTTP and DNS communication with the attackers. - -In a separate DNSpionage campaign, the attackers used the same IP address to redirect the DNS of legitimate .gov and private company domains. During each DNS compromise, the actor carefully generated Let's Encrypt certificates for the redirected domains. These certificates provide X.509 certificates for [Transport Layer Security (TLS)][12] free of charge to the user, Talos said. - -The Sea Turtle campaign gained initial access either by exploiting known vulnerabilities or by sending spear-phishing emails. Talos said it believes the attackers have exploited multiple known common vulnerabilities and exposures (CVEs) to either gain initial access or to move laterally within an affected organization. Talos research further shows the following known exploits of Sea Turtle include: - - * CVE-2009-1151​: PHP code injection vulnerability affecting phpMyAdmin - * CVE-2014-6271​: RCE affecting GNU bash system, specifically the SMTP (this was part of the ​Shellshock​ CVEs) - * CVE-2017-3881​: RCE by unauthenticated user with elevated privileges Cisco switches - * CVE-2017-6736​: Remote Code Exploit (RCE) for Cisco integrated Service Router 2811 - * CVE-2017-12617​: RCE affecting Apache web servers running Tomcat - * CVE-2018-0296​: ​Directory​ traversal allowing unauthorized access to Cisco Adaptive Security Appliances (ASAs) and firewalls - * CVE-2018-7600​: RCE for Website built with Drupal, aka “Drupalgeddon” - - - -“As with any initial access involving a sophisticated actor, we believe this list of CVEs to be incomplete,” Talos stated. “The actor in question can leverage known vulnerabilities as they encounter a new threat surface. This list only represents the observed behavior of the actor, not their complete capabilities.” - -Talos says that the Sea Turtle campaign continues to be highly successful for several reasons. “First, the actors employ a unique approach to gain access to the targeted networks. Most traditional security products such as IDS and IPS systems are not designed to monitor and log DNS requests,” Talos stated. “The threat actors were able to achieve this level of success because the DNS domain space system added security into the equation as an afterthought. Had more ccTLDs implemented security features such as registrar locks, attackers would be unable to redirect the targeted domains.” - -Talos said the attackers also used previously undisclosed techniques such as certificate impersonation. “This technique was successful in part because the SSL certificates were created to provide confidentiality, not integrity. The attackers stole organizations’ SSL certificates associated with security appliances such as [Cisco's Adaptive Security Appliance] to obtain VPN credentials, allowing the actors to gain access to the targeted network, and have long-term persistent access, Talos stated. - -### Cisco Talos DNS attack mitigation strategy - -To protect against Sea Turtle, Cisco recommends: - - * Use a registry lock service, which will require an out-of-band message before any changes can occur to an organization's DNS record. - * If your registrar does not offer a registry-lock service, Talos recommends implementing multi-factor authentication, such as ​DUO​, to access your organization's DNS records. - * If you suspect you were targeted by this type of intrusion, Talos recommends instituting a network-wide password reset, preferably from a computer on a trusted network. - * Apply patches, especially on internet-facing machines. Network administrators can monitor passive DNS records on their domains to check for abnormalities. - - - -Join the Network World communities on [Facebook][13] and [LinkedIn][14] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3389747/cisco-talos-details-exceptionally-dangerous-dns-hijacking-attack.html#tk.rss_all - -作者:[Michael Cooney][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Michael-Cooney/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2019/02/man-in-boat-surrounded-by-sharks_risk_fear_decision_attack_threat_by-peshkova-getty-100786972-large.jpg -[2]: https://blog.talosintelligence.com/2019/04/seaturtle.html -[3]: https://www.networkworld.com/article/3273891/hybrid-cloud/dns-in-the-cloud-why-and-why-not.html -[4]: https://www.networkworld.com/article/3322023/internet/dns-over-https-seeks-to-make-internet-use-more-private.html -[5]: https://www.networkworld.com/article/3298160/internet/how-to-protect-your-infrastructure-from-dns-cache-poisoning.html -[6]: https://www.networkworld.com/article/3331606/security/icann-housecleaning-revokes-old-dns-security-key.html -[7]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr -[8]: https://www.networkworld.com/article/3336201/batten-down-the-dns-hatches-as-attackers-strike-feds.html -[9]: https://cyber.dhs.gov/ed/19-01/ -[10]: https://blog.talosintelligence.com/2018/11/dnspionage-campaign-targets-middle-east.html -[11]: https://krebsonsecurity.com/tag/dnspionage/ -[12]: https://www.networkworld.com/article/2303073/lan-wan-what-is-transport-layer-security-protocol.html -[13]: https://www.facebook.com/NetworkWorld/ -[14]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190418 Cisco warns WLAN controller, 9000 series router and IOS-XE users to patch urgent security holes.md b/sources/talk/20190418 Cisco warns WLAN controller, 9000 series router and IOS-XE users to patch urgent security holes.md deleted file mode 100644 index 5abcb3bcba..0000000000 --- a/sources/talk/20190418 Cisco warns WLAN controller, 9000 series router and IOS-XE users to patch urgent security holes.md +++ /dev/null @@ -1,76 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Cisco warns WLAN controller, 9000 series router and IOS/XE users to patch urgent security holes) -[#]: via: (https://www.networkworld.com/article/3390159/cisco-warns-wlan-controller-9000-series-router-and-iosxe-users-to-patch-urgent-security-holes.html#tk.rss_all) -[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) - -Cisco warns WLAN controller, 9000 series router and IOS/XE users to patch urgent security holes -====== -Cisco says unpatched vulnerabilities could lead to DoS attacks, arbitrary code execution, take-over of devices. -![Woolzian / Getty Images][1] - -Cisco this week issued 31 security advisories but directed customer attention to “critical” patches for its IOS and IOS XE Software Cluster Management and IOS software for Cisco ASR 9000 Series routers. A number of other vulnerabilities also need attention if customers are running Cisco Wireless LAN Controllers. - -The [first critical patch][2] has to do with a vulnerability in the Cisco Cluster Management Protocol (CMP) processing code in Cisco IOS and Cisco IOS XE Software that could allow an unauthenticated, remote attacker to send malformed CMP-specific Telnet options while establishing a Telnet session with an affected Cisco device configured to accept Telnet connections. An exploit could allow an attacker to execute arbitrary code and obtain full control of the device or cause a reload of the affected device, Cisco said. - -**[ Also see[What to consider when deploying a next generation firewall][3]. | Get regularly scheduled insights by [signing up for Network World newsletters][4]. ]** - -The problem has a Common Vulnerability Scoring System number of 9.8 out of 10. - -According to Cisco, the Cluster Management Protocol utilizes Telnet internally as a signaling and command protocol between cluster members. The vulnerability is due to the combination of two factors: - - * The failure to restrict the use of CMP-specific Telnet options only to internal, local communications between cluster members and instead accept and process such options over any Telnet connection to an affected device - * The incorrect processing of malformed CMP-specific Telnet options. - - - -Cisco says the vulnerability can be exploited during Telnet session negotiation over either IPv4 or IPv6. This vulnerability can only be exploited through a Telnet session established _to_ the device; sending the malformed options on Telnet sessions _through_ the device will not trigger the vulnerability. - -The company says there are no workarounds for this problem, but disabling Telnet as an allowed protocol for incoming connections would eliminate the exploit vector. Cisco recommends disabling Telnet and using SSH instead. Information on how to do both can be found on the [Cisco Guide to Harden Cisco IOS Devices][5]. For patch information [go here][6]. - -The second critical patch involves a vulnerability in the sysadmin virtual machine (VM) on Cisco’s ASR 9000 carrier class routers running Cisco IOS XR 64-bit Software could let an unauthenticated, remote attacker access internal applications running on the sysadmin VM, Cisco said in the [advisory][7]. This CVSS also has a 9.8 rating. - -**[[Prepare to become a Certified Information Security Systems Professional with this comprehensive online course from PluralSight. Now offering a 10-day free trial!][8] ]** - -Cisco said the vulnerability is due to incorrect isolation of the secondary management interface from internal sysadmin applications. An attacker could exploit this vulnerability by connecting to one of the listening internal applications. A successful exploit could result in unstable conditions, including both denial of service (DoS) and remote unauthenticated access to the device, Cisco stated. - -Cisco has released [free software updates][6] that address the vulnerability described in this advisory. - -Lastly, Cisco wrote that [multiple vulnerabilities][9] in the administrative GUI configuration feature of Cisco Wireless LAN Controller (WLC) Software could let an authenticated, remote attacker cause the device to reload unexpectedly during device configuration when the administrator is using this GUI, causing a DoS condition on an affected device. The attacker would need to have valid administrator credentials on the device for this exploit to work, Cisco stated. - -“These vulnerabilities are due to incomplete input validation for unexpected configuration options that the attacker could submit while accessing the GUI configuration menus. An attacker could exploit these vulnerabilities by authenticating to the device and submitting crafted user input when using the administrative GUI configuration feature,” Cisco stated. - -“These vulnerabilities have a Security Impact Rating (SIR) of High because they could be exploited when the software fix for the Cisco Wireless LAN Controller Cross-Site Request Forgery Vulnerability is not in place,” Cisco stated. “In that case, an unauthenticated attacker who first exploits the cross-site request forgery vulnerability could perform arbitrary commands with the privileges of the administrator user by exploiting the vulnerabilities described in this advisory.” - -Cisco has released [software updates][10] that address these vulnerabilities and said that there are no workarounds. - -Join the Network World communities on [Facebook][11] and [LinkedIn][12] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3390159/cisco-warns-wlan-controller-9000-series-router-and-iosxe-users-to-patch-urgent-security-holes.html#tk.rss_all - -作者:[Michael Cooney][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Michael-Cooney/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2019/02/compromised_data_security_breach_vulnerability_by_woolzian_gettyimages-475563052_2400x1600-100788413-large.jpg -[2]: https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20170317-cmp -[3]: https://www.networkworld.com/article/3236448/lan-wan/what-to-consider-when-deploying-a-next-generation-firewall.html -[4]: https://www.networkworld.com/newsletters/signup.html -[5]: http://www.cisco.com/c/en/us/support/docs/ip/access-lists/13608-21.html -[6]: https://www.cisco.com/c/en/us/about/legal/cloud-and-software/end_user_license_agreement.html -[7]: https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20190417-asr9k-exr -[8]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr -[9]: https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20190417-wlc-iapp -[10]: https://www.cisco.com/c/en/us/support/web/tsd-cisco-worldwide-contacts.html -[11]: https://www.facebook.com/NetworkWorld/ -[12]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190418 Fujitsu completes design of exascale supercomputer, promises to productize it.md b/sources/talk/20190418 Fujitsu completes design of exascale supercomputer, promises to productize it.md deleted file mode 100644 index 59978d555c..0000000000 --- a/sources/talk/20190418 Fujitsu completes design of exascale supercomputer, promises to productize it.md +++ /dev/null @@ -1,58 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Fujitsu completes design of exascale supercomputer, promises to productize it) -[#]: via: (https://www.networkworld.com/article/3389748/fujitsu-completes-design-of-exascale-supercomputer-promises-to-productize-it.html#tk.rss_all) -[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) - -Fujitsu completes design of exascale supercomputer, promises to productize it -====== -Fujitsu hopes to be the first to offer exascale supercomputing using Arm processors. -![Riken Advanced Institute for Computational Science][1] - -Fujitsu and Japanese research institute Riken announced the design for the post-K supercomputer, to be launched in 2021, is complete and that they will productize the design for sale later this year. - -The K supercomputer was a massive system, built by Fujitsu and housed at the Riken Advanced Institute for Computational Science campus in Kobe, Japan, with more than 80,000 nodes and using Sparc64 VIIIfx processors, a derivative of the Sun Microsystems Sparc processor developed under a license agreement that pre-dated Oracle buying out Sun in 2010. - -**[ Also read:[10 of the world's fastest supercomputers][2] ]** - -It was ranked as the top supercomputer when it was launched in June 2011 with a computation speed of over 8 petaflops. And in November 2011, K became the first computer to top 10 petaflops. It was eventually surpassed as the world's fastest supercomputer by the IBM’s Sequoia, but even now, eight years later, it’s still in the top 20 of supercomputers in the world. - -### What's in the Post-K supercomputer? - -The new system, dubbed “Post-K,” will feature an Arm-based processor called A64FX, a high-performance CPU developed by Fujitsu, designed for exascale systems. The chip is based off the Arm8 design, which is popular in smartphones, with 48 cores plus four “assistant” cores and the ability to access up to 32GB of memory per chip. - -A64FX is the first CPU to adopt the Scalable Vector Extension (SVE), an instruction set specifically designed for Arm-based supercomputers. Fujitsu claims A64FX will offer a peak double precision (64-bit) floating point operations performance of over 2.7 teraflops per chip. The system will have one CPU per node and 384 nodes per rack. That comes out to one petaflop per rack. - -Contrast that with Summit, the top supercomputer in the world built by IBM for the Oak Ridge National Laboratory using IBM Power9 processors and Nvidia GPUs. A Summit rack has a peak computer of 864 teraflops. - -Let me put it another way: IBM’s Power processor and Nvidia’s Tesla are about to get pwned by a derivative chip to the one in your iPhone. - -**[[Get certified as an Apple Technical Coordinator with this seven-part online course from PluralSight.][3] ]** - -Fujitsu will productize the Post-K design and sell it as the successor to the Fujitsu Supercomputer PrimeHPC FX100. The company said it is also considering measures such as developing an entry-level model that will be easy to deploy, or supplying these technologies to other vendors. - -Post-K will be installed in the Riken Center for Computational Science (R-CCS), where the K computer is currently located. The system will be one of the first exascale supercomputers in the world, although the U.S. and China are certainly gunning to be first if only for bragging rights. - -Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3389748/fujitsu-completes-design-of-exascale-supercomputer-promises-to-productize-it.html#tk.rss_all - -作者:[Andy Patrizio][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Andy-Patrizio/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2018/06/riken_advanced_institute_for_computational_science_k-computer_supercomputer_1200x800-100762135-large.jpg -[2]: https://www.networkworld.com/article/3236875/embargo-10-of-the-worlds-fastest-supercomputers.html -[3]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fapple-certified-technical-trainer-10-11 -[4]: https://www.facebook.com/NetworkWorld/ -[5]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190419 Intel follows AMD-s lead (again) into single-socket Xeon servers.md b/sources/talk/20190419 Intel follows AMD-s lead (again) into single-socket Xeon servers.md deleted file mode 100644 index 9685591b2c..0000000000 --- a/sources/talk/20190419 Intel follows AMD-s lead (again) into single-socket Xeon servers.md +++ /dev/null @@ -1,61 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Intel follows AMD’s lead (again) into single-socket Xeon servers) -[#]: via: (https://www.networkworld.com/article/3390201/intel-follows-amds-lead-again-into-single-socket-xeon-servers.html#tk.rss_all) -[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) - -Intel follows AMD’s lead (again) into single-socket Xeon servers -====== -Intel's new U series of processors are aimed at the low-end market where one processor is good enough. -![Intel][1] - -I’m really starting to wonder who the leader in x86 really is these days because it seems Intel is borrowing another page out of AMD’s playbook. - -Intel launched a whole lot of new Xeon Scalable processors earlier this month, but they neglected to mention a unique line: the U series of single-socket processors. The folks over at Serve The Home sniffed it out first, and Intel has confirmed the existence of the line, just that they “didn’t broadly promote them.” - -**[ Read also:[Intel makes a play for high-speed fiber networking for data centers][2] ]** - -To backtrack a bit, AMD made a major push for [single-socket servers][3] when it launched the Epyc line of server chips. Epyc comes with up to 32 cores and multithreading, and Intel (and Dell) argued that one 32-core/64-thread processor was enough to handle many loads and a lot cheaper than a two-socket system. - -The new U series isn’t available in the regular Intel [ARK database][4] listing of Xeon Scalable processors, but they do show up if you search. Intel says they are looking into that .There are two processors for now, one with 24 cores and two with 20 cores. - -The 24-core Intel [Xeon Gold 6212U][5] will be a counterpart to the Intel Xeon Platinum 8260, with a 2.4GHz base clock speed and a 3.9GHz turbo clock and the ability to access up to 1TB of memory. The Xeon Gold 6212U will have the same 165W TDP as the 8260 line, but with a single socket that’s 165 fewer watts of power. - -Also, Intel is suggesting a price of about $2,000 for the Intel Xeon Gold 6212U, a big discount over the Xeon Platinum 8260’s $4,702 list price. So, that will translate into much cheaper servers. - -The [Intel Xeon Gold 6210U][6] with 20 cores carries a suggested price of $1,500, has a base clock rate of 2.50GHz with turbo boost to 3.9GHz and a 150 watt TDP. Finally, there is the 20-core Intel [Xeon Gold 6209U][7] with a price of around $1,000 that is identical to the 6210 except its base clock speed is 2.1GHz with a turbo boost of 3.9GHz and a TDP of 125 watts due to its lower clock speed. - -**[[Get certified as an Apple Technical Coordinator with this seven-part online course from PluralSight.][8] ]** - -All of the processors support up to 1TB of DDR4-2933 memory and Intel’s Optane persistent memory. - -In terms of speeds and feeds, AMD has a slight advantage over Intel in the single-socket race, and Epyc 2 is rumored to be approaching completion, which will only further advance AMD’s lead. - -Join the Network World communities on [Facebook][9] and [LinkedIn][10] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3390201/intel-follows-amds-lead-again-into-single-socket-xeon-servers.html#tk.rss_all - -作者:[Andy Patrizio][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Andy-Patrizio/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2018/06/intel_generic_cpu_background-100760187-large.jpg -[2]: https://www.networkworld.com/article/3307852/intel-makes-a-play-for-high-speed-fiber-networking-for-data-centers.html -[3]: https://www.networkworld.com/article/3253626/amd-lands-dell-as-its-latest-epyc-server-processor-customer.html -[4]: https://ark.intel.com/content/www/us/en/ark/products/series/192283/2nd-generation-intel-xeon-scalable-processors.html -[5]: https://ark.intel.com/content/www/us/en/ark/products/192453/intel-xeon-gold-6212u-processor-35-75m-cache-2-40-ghz.html -[6]: https://ark.intel.com/content/www/us/en/ark/products/192452/intel-xeon-gold-6210u-processor-27-5m-cache-2-50-ghz.html -[7]: https://ark.intel.com/content/www/us/en/ark/products/193971/intel-xeon-gold-6209u-processor-27-5m-cache-2-10-ghz.html -[8]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fapple-certified-technical-trainer-10-11 -[9]: https://www.facebook.com/NetworkWorld/ -[10]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190423 Edge computing is in most industries- future.md b/sources/talk/20190423 Edge computing is in most industries- future.md deleted file mode 100644 index 3f5a6d4c00..0000000000 --- a/sources/talk/20190423 Edge computing is in most industries- future.md +++ /dev/null @@ -1,63 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (ninifly ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Edge computing is in most industries’ future) -[#]: via: (https://www.networkworld.com/article/3391016/edge-computing-is-in-most-industries-future.html#tk.rss_all) -[#]: author: (Anne Taylor https://www.networkworld.com/author/Anne-Taylor/) - -Edge computing is in most industries’ future -====== -Nearly every industry can take advantage of edge computing in the journey to speed digital transformation efforts -![iStock][1] - -The growth of edge computing is about to take a huge leap. Right now, companies are generating about 10% of their data outside a traditional data center or cloud. But within the next six years, that will increase to 75%, [according to Gartner][2]. - -That’s largely down to the need to process data emanating from devices, such as Internet of Things (IoT) sensors. Early adopters include: - - * **Manufacturers:** Devices and sensors seem endemic to this industry, so it’s no surprise to see the need to find faster processing methods for the data produced. A recent [_Automation World_][3] survey found that 43% of manufacturers have deployed edge projects. Most popular use cases have included production/manufacturing data analysis and equipment data analytics. - - * **Retailers** : Like most industries deeply affected by the need to digitize operations, retailers are being forced to innovate their customer experiences. To that end, these organizations are “investing aggressively in compute power located closer to the buyer,” [writes Dave Johnson][4], executive vice president of the IT division at Schneider Electric. He cites examples such as augmented-reality mirrors in fitting rooms that offer different clothing options without the consumer having to try on the items, and beacon-based heat maps that show in-store traffic. - - - - * **Healthcare organizations** : As healthcare costs continue to escalate, this industry is ripe for innovation that improves productivity and cost efficiencies. Management consulting firm [McKinsey & Co. has identified][5] at least 11 healthcare use cases that benefit patients, the facility, or both. Two examples: tracking mobile medical devices for nursing efficiency as well as optimization of equipment, and wearable devices that track user exercise and offer wellness advice. - - - -While these are strong use cases, as the edge computing market grows, so too will the number of industries adopting it. - -**Getting the edge on digital transformation** - -Faster processing at the edge fits perfectly into the objectives and goals of digital transformation — improving efficiencies, productivity, speed to market, and the customer experience. Here are just a few of the potential applications and industries that will be changed by edge computing: - -**Agriculture:** Farmers and organizations already use drones to transmit field and climate conditions to watering equipment. Other applications might include monitoring and location tracking of workers, livestock, and equipment to improve productivity, efficiencies, and costs. - -**Energy** : There are multiple potential applications in this sector that could benefit both consumers and providers. For example, smart meters help homeowners better manage energy use while reducing grid operators’ need for manual meter reading. Similarly, sensors on water pipes would detect leaks, while providing real-time consumption data. - -**Financial services** : Banks are adopting interactive ATMs that quickly process data to provide better customer experiences. At the organizational level, transactional data can be more quickly analyzed for fraudulent activity. - -**Logistics** : As consumers demand faster delivery of goods and services, logistics companies will need to transform mapping and routing capabilities to get real-time data, especially in terms of last-mile planning and tracking. That could involve street-, package-, and car-based sensors transmitting data for processing. - -All industries have the potential for transformation, thanks to edge computing. But it will depend on how they address their computing infrastructure. Discover how to overcome any IT obstacles at [APC.com][6]. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3391016/edge-computing-is-in-most-industries-future.html#tk.rss_all - -作者:[Anne Taylor][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Anne-Taylor/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2019/04/istock-1019389496-100794424-large.jpg -[2]: https://www.gartner.com/smarterwithgartner/what-edge-computing-means-for-infrastructure-and-operations-leaders/ -[3]: https://www.automationworld.com/article/technologies/cloud-computing/its-not-edge-vs-cloud-its-both -[4]: https://blog.schneider-electric.com/datacenter/2018/07/10/why-brick-and-mortar-retail-quickly-establishing-leadership-edge-computing/ -[5]: https://www.mckinsey.com/industries/high-tech/our-insights/new-demand-new-markets-what-edge-computing-means-for-hardware-companies -[6]: https://www.apc.com/us/en/solutions/business-solutions/edge-computing.jsp diff --git a/sources/talk/20190424 Cisco- DNSpionage attack adds new tools, morphs tactics.md b/sources/talk/20190424 Cisco- DNSpionage attack adds new tools, morphs tactics.md deleted file mode 100644 index e202384558..0000000000 --- a/sources/talk/20190424 Cisco- DNSpionage attack adds new tools, morphs tactics.md +++ /dev/null @@ -1,97 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Cisco: DNSpionage attack adds new tools, morphs tactics) -[#]: via: (https://www.networkworld.com/article/3390666/cisco-dnspionage-attack-adds-new-tools-morphs-tactics.html#tk.rss_all) -[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) - -Cisco: DNSpionage attack adds new tools, morphs tactics -====== -Cisco's Talos security group says DNSpionage tools have been upgraded to be more stealthy -![Calvin Dexter / Getty Images][1] - -The group behind the Domain Name System attacks known as DNSpionage have upped their dark actions with new tools and malware to focus their attacks and better hide their activities. - -Cisco Talos security researchers, who discovered [DNSpionage][2] in November, this week warned of new exploits and capabilities of the nefarious campaign. - -**More about DNS:** - - * [DNS in the cloud: Why and why not][3] - * [DNS over HTTPS seeks to make internet use more private][4] - * [How to protect your infrastructure from DNS cache poisoning][5] - * [ICANN housecleaning revokes old DNS security key][6] - - - -“The threat actor's ongoing development of DNSpionage malware shows that the attacker continues to find new ways to avoid detection. DNS tunneling is a popular method of exfiltration for some actors and recent examples of DNSpionage show that we must ensure DNS is monitored as closely as an organization's normal proxy or weblogs,” [Talos wrote][7]. “DNS is essentially the phonebook of the internet, and when it is tampered with, it becomes difficult for anyone to discern whether what they are seeing online is legitimate.” - -In Talos’ initial report, researchers said a DNSpionage campaign targeted various businesses in the Middle East as well as United Arab Emirates government domains. It also utilized two malicious websites containing job postings that were used to compromise targets via crafted Microsoft Office documents with embedded macros. The malware supported HTTP and DNS communication with the attackers. - -In a separate DNSpionage campaign, the attackers used the same IP address to redirect the DNS of legitimate .gov and private company domains. During each DNS compromise, the actor carefully generated “Let's Encrypt” certificates for the redirected domains. These certificates provide X.509 certificates for [Transport Layer Security (TLS)][8] free of charge to the user, Talos said. - -This week Cisco said DNSpionage actors have created a new remote administrative tool that supports HTTP and DNS communication with the attackers' command and control (C2). - -“In our previous post concerning DNSpionage, we showed that the malware author used malicious macros embedded in a Microsoft Word document. In the new sample from Lebanon identified at the end of February, the attacker used an Excel document with a similar macro.” - -**[[Prepare to become a Certified Information Security Systems Professional with this comprehensive online course from PluralSight. Now offering a 10-day free trial!][9] ]** - -Talos wrote: “The malware supports HTTP and DNS communication to the C2 server. The HTTP communication is hidden in the comments in the HTML code. This time, however, the C2 server mimics the GitHub platform instead of Wikipedia. While the DNS communication follows the same method we described in our previous article, the developer added some new features in this latest version and, this time, the actor removed the debug mode.” - -Talos added that the domain used for the C2 campaign is “bizarre.” - -“The previous version of DNSpionage attempted to use legitimate-looking domains in an attempt to remain undetected. However, this newer version uses the domain ‘coldfart[.]com,’ which would be easier to spot than other APT campaigns which generally try to blend in with traffic more suitable to enterprise environments. The domain was also hosted in the U.S., which is unusual for any espionage-style attack.” - -Talos researchers said they discovered that DNSpionage added a reconnaissance phase, that ensures the payload is being dropped on specific targets rather than indiscriminately downloaded on every machine. - -This level of attack also returns information about the workstation environment, including platform-specific information, the name of the domain and the local computer, and information concerning the operating system, Talos wrote. This information is key to helping the malware select the victims only and attempts to avoid researchers or sandboxes. Again, it shows the actor's improved abilities, as they now fingerprint the victim. - -This new tactic indicates an improved level of sophistication and is likely in response to the significant amount of public interest in the campaign. - -Talos noted that there have been several other public reports of DNSpionage attacks, and in January, the U.S. Department of Homeland Security issued an [alert][10] warning users about this threat activity. - -“In addition to increased reports of threat activity, we have also discovered new evidence that the threat actors behind the DNSpionage campaign continue to change their tactics, likely in an attempt to improve the efficacy of their operations,” Talos stated. - -In April, Cisco Talos identified an undocumented malware developed in .NET. On the analyzed samples, the malware author left two different internal names in plain text: "DropperBackdoor" and "Karkoff." - -“The malware is lightweight compared to other malware due to its small size and allows remote code execution from the C2 server. There is no obfuscation and the code can be easily disassembled,” Talos wrote. - -The Karkoff malware searches for two specific anti-virus platforms: Avira and Avast and will work around them. - -“The discovery of Karkoff also shows the actor is pivoting and is increasingly attempting to avoid detection while remaining very focused on the Middle Eastern region,” Talos wrote. - -Talos distinguished DNSpionage from another DNS attack method, “[Sea Turtle][11]”, it detailed this month. Sea Turtle involves state-sponsored attackers that are abusing DNS to target organizations and harvest credentials to gain access to sensitive networks and systems in a way that victims are unable to detect. This displays unique knowledge about how to manipulate DNS, Talos stated. - -By obtaining control of victims’ DNS, attackers can change or falsify any data victims receive from the Internet, illicitly modify DNS name records to point users to actor-controlled servers and users visiting those sites would never know, Talos reported. - -“While this incident is limited to targeting primarily national security organizations in the Middle East and North Africa, and we do not want to overstate the consequences of this specific campaign, we are concerned that the success of this operation will lead to actors more broadly attacking the global DNS system,” Talos stated about Sea Turtle. - -Join the Network World communities on [Facebook][12] and [LinkedIn][13] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3390666/cisco-dnspionage-attack-adds-new-tools-morphs-tactics.html#tk.rss_all - -作者:[Michael Cooney][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Michael-Cooney/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2019/02/cyber_attack_threat_danger_breach_hack_security_by_calvindexter_gettyimages-860363294_2400x800-100788395-large.jpg -[2]: https://blog.talosintelligence.com/2018/11/dnspionage-campaign-targets-middle-east.html -[3]: https://www.networkworld.com/article/3273891/hybrid-cloud/dns-in-the-cloud-why-and-why-not.html -[4]: https://www.networkworld.com/article/3322023/internet/dns-over-https-seeks-to-make-internet-use-more-private.html -[5]: https://www.networkworld.com/article/3298160/internet/how-to-protect-your-infrastructure-from-dns-cache-poisoning.html -[6]: https://www.networkworld.com/article/3331606/security/icann-housecleaning-revokes-old-dns-security-key.html -[7]: https://blog.talosintelligence.com/2019/04/dnspionage-brings-out-karkoff.html -[8]: https://www.networkworld.com/article/2303073/lan-wan-what-is-transport-layer-security-protocol.html -[9]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr -[10]: https://www.us-cert.gov/ncas/alerts/AA19-024A -[11]: https://www.networkworld.com/article/3389747/cisco-talos-details-exceptionally-dangerous-dns-hijacking-attack.html -[12]: https://www.facebook.com/NetworkWorld/ -[13]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190424 IoT roundup- VMware, Nokia beef up their IoT.md b/sources/talk/20190424 IoT roundup- VMware, Nokia beef up their IoT.md deleted file mode 100644 index 90f4ebf5f1..0000000000 --- a/sources/talk/20190424 IoT roundup- VMware, Nokia beef up their IoT.md +++ /dev/null @@ -1,69 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (IoT roundup: VMware, Nokia beef up their IoT) -[#]: via: (https://www.networkworld.com/article/3390682/iot-roundup-vmware-nokia-beef-up-their-iot.html#tk.rss_all) -[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) - -IoT roundup: VMware, Nokia beef up their IoT -====== -Everyone wants in on the ground floor of the internet of things, and companies including Nokia, VMware and Silicon Labs are sharpening their offerings in anticipation of further growth. -![Getty Images][1] - -When attempting to understand the world of IoT, it’s easy to get sidetracked by all the fascinating use cases: Automated oil and gas platforms! Connected pet feeders! Internet-enabled toilets! (Is “the Internet of Toilets” a thing yet?) But the most important IoT trend to follow may be the way that major tech vendors are vying to make large portions of the market their own. - -VMware’s play for a significant chunk of the IoT market is called Pulse IoT Center, and the company released version 2.0 of it this week. It follows the pattern set by other big companies getting into IoT: Leveraging their existing technological strengths and applying them to the messier, more heterodox networking environment that IoT represents. - -Unsurprisingly, given that it’s VMware we’re talking about, there’s now a SaaS option, and the company was also eager to talk up that Pulse IoT Center 2.0 has simplified device-onboarding and centralized management features. - -**More about edge networking** - - * [How edge networking and IoT will reshape data centers][2] - * [Edge computing best practices][3] - * [How edge computing can help secure the IoT][4] - - - -That might sound familiar, and for good reason – companies with any kind of a background in network management, from HPE/Aruba to Amazon, have been pushing to promote their system as the best framework for managing a complicated and often decentralized web of IoT devices from a single platform. By rolling features like software updates, onboarding and security into a single-pane-of-glass management console, those companies are hoping to be the organizational base for customers trying to implement IoT. - -Whether they’re successful or not remains to be seen. While major IT companies have been trying to capture market share by competing across multiple verticals, the operational orientation of the IoT also means that non-traditional tech vendors with expertise in particular fields (particularly industrial and automotive) are suddenly major competitors. - -**Nokia spreads the IoT network wide** - -As a giant carrier-equipment vendor, Nokia is an important company in the overall IoT landscape. While some types of enterprise-focused IoT are heavily localized, like connected factory floors or centrally managed office buildings, others are so geographically disparate that carrier networks are the only connectivity medium that makes sense. - -The Finnish company earlier this month broadened its footprint in the IoT space, announcing that it had partnered with Nordic Telecom to create a wide-area network focused on enabling IoT and emergency services. The network, which Nokia is billing as the first mission-critical communications network, operates using LTE technology in the 410-430MHz band – a relatively low frequency, which allows for better propagation and a wide effective range. - -The idea is to provide a high-throughput, low-latency network option to any user on the network, whether it’s an emergency services provider needing high-speed video communication or an energy or industrial company with a low-delay-tolerance application. - -**Silicon Labs packs more onto IoT chips** - -The heart of any IoT implementation remains the SoCs that make devices intelligent in the first place, and Silicon Labs announced that it's building more muscle into its IoT-focused product lineup. - -The Austin-based chipmaker said that version 2 of its Wireless Gecko platform will pack more than double the wireless connectivity range of previous entries, which could seriously ease design requirements for companies planning out IoT deployments. The chipsets support Zigbee, Thread and Bluetooth mesh networking, and are designed for line-powered IoT devices, using Arm Cortex-M33 processors for relatively strong computing capacity and high energy efficiency. - -Chipset advances aren’t the type of thing that will pay off immediately in terms of making IoT devices more capable, but improvements like these make designing IoT endpoints for particular uses that much easier, and new SoCs will begin to filter into line-of-business equipment over time. - -Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3390682/iot-roundup-vmware-nokia-beef-up-their-iot.html#tk.rss_all - -作者:[Jon Gold][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Jon-Gold/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2018/08/nw_iot-news_internet-of-things_smart-city_smart-home5-100768494-large.jpg -[2]: https://www.networkworld.com/article/3291790/data-center/how-edge-networking-and-iot-will-reshape-data-centers.html -[3]: https://www.networkworld.com/article/3331978/lan-wan/edge-computing-best-practices.html -[4]: https://www.networkworld.com/article/3331905/internet-of-things/how-edge-computing-can-help-secure-the-iot.html -[5]: https://www.facebook.com/NetworkWorld/ -[6]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190425 Dell EMC and Cisco renew converged infrastructure alliance.md b/sources/talk/20190425 Dell EMC and Cisco renew converged infrastructure alliance.md deleted file mode 100644 index 8d3ad041db..0000000000 --- a/sources/talk/20190425 Dell EMC and Cisco renew converged infrastructure alliance.md +++ /dev/null @@ -1,52 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Dell EMC and Cisco renew converged infrastructure alliance) -[#]: via: (https://www.networkworld.com/article/3391071/dell-emc-and-cisco-renew-converged-infrastructure-alliance.html#tk.rss_all) -[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) - -Dell EMC and Cisco renew converged infrastructure alliance -====== -Dell EMC and Cisco renewed their agreement to collaborate on converged infrastructure (CI) products for a few more years even though the momentum is elsewhere. -![Dell EMC][1] - -Dell EMC and Cisco have renewed a collaboration on converged infrastructure (CI) products that has run for more than a decade, even as the momentum shifts elsewhere. The news was announced via a [blog post][2] by Pete Manca, senior vice president for solutions engineering at Dell EMC. - -The deal is centered around Dell EMC’s VxBlock product line, which originally started out in 2009 as a joint venture between EMC and Cisco called VCE (Virtual Computing Environment). EMC bought out Cisco’s stake in the venture before Dell bought EMC. - -The devices offered UCS servers and networking from Cisco, EMC storage, and VMware virtualization software in pre-configured, integrated bundles. VCE was retired in favor of new brands, VxBlock, VxRail, and VxRack. The lineup has been pared down to one device, the VxBlock 1000. - -**[ Read also:[How to plan a software-defined data-center network][3] ]** - -“The newly inked agreement entails continued company alignment across multiple organizations: executive, product development, marketing, and sales,” Manca wrote in the blog post. “This means we’ll continue to share product roadmaps and collaborate on strategic development activities, with Cisco investing in a range of Dell EMC sales, marketing and training initiatives to support VxBlock 1000.” - -Dell EMC cites IDC research that it holds a 48% market share in converged systems, nearly 1.5 times that of any other vendor. But IDC's April edition of the Converged Systems Tracker said the CI category is on the downswing. CI sales fell 6.4% year over year, while the market for hyperconverged infrastructure (HCI) grew 57.2% year over year. - -For the unfamiliar, the primary difference between converged and hyperconverged infrastructure is that CI relies on hardware building blocks, while HCI is software-defined and considered more flexible and scalable than CI and operates more like a cloud system with resources spun up and down as needed. - -Despite this, Dell is committed to CI systems. Just last month it announced an update and expansion of the VxBlock 1000, including higher scalability, a broader choice of components, and the option to add new technologies. It featured updated VMware vRealize and vSphere support, the option to consolidate high-value, mission-critical workloads with new storage and data protection options and support for Cisco UCS fabric and servers. - -For customers who prefer to build their own infrastructure solutions, Dell EMC introduced Ready Stack, a portfolio of validated designs with sizing, design, and deployment resources that offer VMware-based IaaS, vSphere on Dell EMC PowerEdge servers and Dell EMC Unity storage, and Microsoft Hyper-V on Dell EMC PowerEdge servers and Dell EMC Unity storage. - -Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3391071/dell-emc-and-cisco-renew-converged-infrastructure-alliance.html#tk.rss_all - -作者:[Andy Patrizio][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Andy-Patrizio/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2019/04/dell-emc-vxblock-1000-100794721-large.jpg -[2]: https://blog.dellemc.com/en-us/dell-technologies-cisco-reaffirm-joint-commitment-converged-infrastructure/ -[3]: https://www.networkworld.com/article/3284352/data-center/how-to-plan-a-software-defined-data-center-network.html -[4]: https://www.facebook.com/NetworkWorld/ -[5]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190426 Profiling D-s Garbage Collection with Bpftrace.md b/sources/talk/20190426 Profiling D-s Garbage Collection with Bpftrace.md new file mode 100644 index 0000000000..ce0a408ae6 --- /dev/null +++ b/sources/talk/20190426 Profiling D-s Garbage Collection with Bpftrace.md @@ -0,0 +1,412 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Profiling D's Garbage Collection with Bpftrace) +[#]: via: (https://theartofmachinery.com/2019/04/26/bpftrace_d_gc.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +Profiling D's Garbage Collection with Bpftrace +====== + +Recently I’ve been playing around with using [`bpftrace`][1] to trace and profile D’s garbage collector. Here are some examples of the cool stuff that’s possible. + +### What is `bpftrace`? + +It’s a high-level debugging tool based on Linux’s eBPF. “eBPF” stands for “extended Berkely packet filter”, but that’s just a historical name and doesn’t mean much today. It’s really a virtual machine (like the [JVM][2]) that sits inside the Linux kernel and runs code in a special eBPF instruction set similar to normal machine code. Users are expected to write short programs in high-level languages (including C and others) that get compiled to eBPF and loaded into the kernel on the fly to do interesting things. + +As you might guess, eBPF is powerful for instrumenting a running kernel, but it also supports instrumenting user-space programs. + +### What you need + +First you need a Linux kernel. Sorry BSD, Mac OS and Windows users. (But some of you can use [DTrace][3].) + +Also, not just any Linux kernel will work. This stuff is relatively new, so you’ll need a modern kernel with BPF-related features enabled. You might need to use the newest (or even testing) version of a distro. Here’s how to check if your kernel meets the requirements: + +``` +$ uname -r +4.19.27-gentoo-r1sub +$ # 4.9+ recommended by bpftrace +$ zgrep CONFIG_UPROBES /proc/config.gz +CONFIG_UPROBES=y +$ # Also need +$ # CONFIG_BPF=y +$ # CONFIG_BPF_SYSCALL=y +$ # CONFIG_BPF_JIT=y +$ # CONFIG_HAVE_EBPF_JIT=y +$ # CONFIG_BPF_EVENTS=y +``` + +Of course, [you also need to install the `bpftrace` tool itself][4]. + +### `bpftrace` D “Hello World” + +Here’s a quick test you can do to make sure you’ve got everything working. First, let’s make a Hello World D binary: + +``` +$ pwd +/tmp/ +$ cat hello.d +import std.stdio; + +void main() +{ + writeln("Hello World"); +} +$ dmd hello.d +$ ./hello +Hello World +$ +``` + +Now let’s `bpftrace` it. `bpftrace` uses a high-level language that’s obviously inspired by AWK. I’ll explain enough to understand the post, but you can also check out the [`bpftrace` reference guide][5] and [one-liner tutorial][6]. The minimum you need to know is that a bpftrace program is a list of `event:name /filter predicate/ { program(); code(); }` blocks that define code snippets to be run on events. + +This time I’m only using Linux uprobes, which trigger on functions in user-space programs. The syntax is `uprobe:/path/to/binary:functionName`. One gotcha is that D “[mangles][7]” (encodes) function names before inserting them into the binary. If we want to trigger on the D code’s `main()` function, we need to use the mangled name: `_Dmain`. (By the way, `nm program | grep ' _D.*functionName'` is one quick trick for finding mangled names.) + +Run this `bpftrace` invocation in a terminal as root user: + +``` +# bpftrace -e 'uprobe:/tmp/hello:_Dmain { printf("D Hello World run with process ID %d\n", pid); }' +Attaching 1 probe... +``` + +While this is running, it’ll print a message every time the D Hello World program is executed by any user in any terminal. Press `Ctrl+C` to quit. + +All `bpftrace` code can be run directly from the command line like in the example above. But to make things easier to read from now on, I’ll make neatly formatted scripts. + +### Tracing some real code + +I’m using [D-Scanner][8], the D code analyser, as an example of a simple but non-trivial D workload. One nice thing about `bpftrace` and uprobes is that no modification of the program is needed. I’m just using a normal build of the `dscanner` tool, and using the [D runtime source code][9] as a codebase to analyse. + +Before using `bpftrace`, let’s try using [the profiling that’s built into the D GC implementation itself][10]: + +``` +$ dscanner --DRT-gcopt=profile:1 --etags +... + Number of collections: 85 + Total GC prep time: 0 milliseconds + Total mark time: 17 milliseconds + Total sweep time: 6 milliseconds + Total page recovery time: 3 milliseconds + Max Pause Time: 1 milliseconds + Grand total GC time: 28 milliseconds +GC summary: 35 MB, 85 GC 28 ms, Pauses 17 ms < 1 ms +``` + +(If you can make a custom build, you can also use [the D runtime GC API to get stats][11].) + +There’s one more gotcha when using `bpftrace` on `dscanner` to trace GC functions: the binary file we specify for the uprobe needs to be the binary file that actually contains the GC functions. That could be the D binary itself, or it could be a shared D runtime library. Try running `ldd /path/to/d_program` to list any linked shared libraries, and if the output contains `druntime`, use that full path when specifying uprobes. My `dscanner` binary doesn’t link to a shared D runtime, so I just use the full path to `dscanner`. (Running `which dscanner` gives `/usr/local/bin/dscanner` for me.) + +Anyway, all the GC functions live in a `gc` module, so their mangled names start with `_D2gc`. Here’s a `bpftrace` invocation that tallies GC function calls. For convenience, it also includes a uretprobe to automatically exit when `main()` returns. The output is sorted to make it a little easier to read. + +``` +# cat dumpgcfuncs.bt +uprobe:/usr/local/bin/dscanner:_D2gc* +{ + @[probe] = count(); +} + +uretprobe:/usr/local/bin/dscanner:_Dmain +{ + exit(); +} +# bpftrace dumpgcfuncs.bt | sort + +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC10freeNoSyncMFNbNiPvZv]: 31 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC10initializeFKCQCd11gcinterface2GCZv]: 1 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC11queryNoSyncMFNbPvZS4core6memory8BlkInfo_]: 44041 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC11removeRangeMFNbNiPvZv]: 2 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC12extendNoSyncMFNbPvmmxC8TypeInfoZm]: 251946 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC14collectNoStackMFNbZv]: 1 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC18fullCollectNoStackMFNbZv]: 1 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC4freeMFNbNiPvZv]: 31 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC5queryMFNbPvZS4core6memory8BlkInfo_]: 47704 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC6__ctorMFZCQBzQBzQBxQCiQBn]: 1 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC6callocMFNbmkxC8TypeInfoZPv]: 80 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC6extendMFNbPvmmxC8TypeInfoZm]: 251946 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC6mallocMFNbmkxC8TypeInfoZPv]: 12423 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC6qallocMFNbmkxC8TypeInfoZS4core6memory8BlkInfo_]: 948995 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC7getAttrMFNbPvZ2goFNbPSQClQClQCjQCu3GcxQBbZk]: 5615 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC7getAttrMFNbPvZk]: 5615 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC8addRangeMFNbNiPvmxC8TypeInfoZv]: 2 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC__T9runLockedS_DQCeQCeQCcQCnQBs10freeNoSyncMFNbNiPvZvS_DQDsQDsQDqQEb8freeTimelS_DQErQErQEpQFa8numFreeslTQCdZQEbMFNbNiKQCrZv]: 31 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC__T9runLockedS_DQCeQCeQCcQCnQBs11queryNoSyncMFNbPvZS4core6memory8BlkInfo_S_DQEmQEmQEkQEv9otherTimelS_DQFmQFmQFkQFv9numOtherslTQDaZQExMFNbKQDmZQDn]: 44041 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC__T9runLockedS_DQCeQCeQCcQCnQBs12extendNoSyncMFNbPvmmxC8TypeInfoZmS_DQEfQEfQEdQEo10extendTimelS_DQFhQFhQFfQFq10numExtendslTQCwTmTmTxQDaZQFdMFNbKQDrKmKmKxQDvZm]: 251946 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC__T9runLockedS_DQCeQCeQCcQCnQBs12mallocNoSyncMFNbmkKmxC8TypeInfoZPvS_DQEgQEgQEeQEp10mallocTimelS_DQFiQFiQFgQFr10numMallocslTmTkTmTxQCzZQFcMFNbKmKkKmKxQDsZQDl]: 961498 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC__T9runLockedS_DQCeQCeQCcQCnQBs18fullCollectNoStackMFNbZ2goFNbPSQEaQEaQDyQEj3GcxZmTQvZQDfMFNbKQBgZm]: 1 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC__T9runLockedS_DQCeQCeQCcQCnQBs7getAttrMFNbPvZ2goFNbPSQDqQDqQDoQDz3GcxQBbZkS_DQEoQEoQEmQEx9otherTimelS_DQFoQFoQFmQFx9numOtherslTQCyTQDlZQFdMFNbKQDoKQEbZk]: 5615 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw15LargeObjectPool10allocPagesMFNbmZm]: 5597 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw15LargeObjectPool13updateOffsetsMFNbmZv]: 10745 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw15LargeObjectPool7getInfoMFNbPvZS4core6memory8BlkInfo_]: 3844 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw15SmallObjectPool7getInfoMFNbPvZS4core6memory8BlkInfo_]: 40197 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw15SmallObjectPool9allocPageMFNbhZPSQChQChQCfQCq4List]: 15022 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx10smallAllocMFNbhKmkZ8tryAllocMFNbZb]: 955967 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx10smallAllocMFNbhKmkZPv]: 955912 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx11ToScanStack4growMFNbZv]: 1 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx11fullcollectMFNbbZm]: 85 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx11removeRangeMFNbNiPvZv]: 1 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx23updateCollectThresholdsMFNbZv]: 84 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx4markMFNbNlPvQcZv]: 253 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx5sweepMFNbZm]: 84 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx7markAllMFNbbZ14__foreachbody3MFNbKSQCm11gcinterface5RangeZi]: 85 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx7markAllMFNbbZv]: 85 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx7newPoolMFNbmbZPSQBtQBtQBrQCc4Pool]: 6 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx7recoverMFNbZm]: 84 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx8addRangeMFNbNiPvQcxC8TypeInfoZv]: 2 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx8bigAllocMFNbmKmkxC8TypeInfoZ15tryAllocNewPoolMFNbZb]: 5 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx8bigAllocMFNbmKmkxC8TypeInfoZ8tryAllocMFNbZb]: 5616 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx8bigAllocMFNbmKmkxC8TypeInfoZPv]: 5586 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx8isMarkedMFNbNlPvZi]: 635 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx9allocPageMFNbhZPSQBuQBuQBsQCd4List]: 15024 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw4Pool10initializeMFNbmbZv]: 6 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw4Pool12freePageBitsMFNbmKxG4mZv]: 16439 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl5protoQo7ProtoGC4termMFZv]: 1 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl5protoQo7ProtoGC6qallocMFNbmkxC8TypeInfoZS4core6memory8BlkInfo_]: 1 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl5protoQo7ProtoGC8addRangeMFNbNiPvmxC8TypeInfoZv]: 1 +@[uprobe:/usr/local/bin/dscanner:_D2gc4impl6manualQp8ManualGC10initializeFKCQBp11gcinterface2GCZv]: 1 +@[uprobe:/usr/local/bin/dscanner:_D2gc9pooltable__T9PoolTableTSQBc4impl12conservativeQBy4PoolZQBr6insertMFNbNiPQBxZb]: 6 +@[uprobe:/usr/local/bin/dscanner:_D2gc9pooltable__T9PoolTableTSQBc4impl12conservativeQBy4PoolZQBr8findPoolMFNaNbNiPvZPQCe]: 302268 +@[uprobe:/usr/local/bin/dscanner:_D2gc9pooltable__T9PoolTableTSQBc4impl12conservativeQBy4PoolZQBr8minimizeMFNaNbNjZAPQCd]: 30 +Attaching 231 probes... +``` + +All these functions are in [`src/gc/`][12], and most of the interesting ones here are in [`src/gc/impl/conservative/`][13]. There are 85 calls to `_D2gc4impl12conservativeQw3Gcx11fullcollectMFNbbZm`, which [`ddemangle`][14] translates to `nothrow ulong gc.impl.conservative.gc.Gcx.fullcollect(bool)`. That matches up with the report from `--DRT-gcopt=profile:1`. + +The heart of the `bpftrace` program is `@[probe] = count();`. `@` prefixes a global variable, in this case a variable with an empty name (allowed by `bpftrace`). We’re using the variable as a map (like an associative array in D), and indexing it with `probe`, a built-in variable containing the name of the uprobe that was triggered. The tally is kept using the magic `count()` function. + +### Garbage collection timings + +How about something more interesting, like generating a profile of collection timings? This time, to get more data, I won’t make `bpftrace` exit as soon as the `dscanner` exits. I’ll keep it running and run `dscanner` 100 times before quitting `bpftrace` with `Ctrl+C`: + +``` +# cat gcprofile.bt +uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx11fullcollectMFNbbZm +{ + @t = nsecs; +} + +uretprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw3Gcx11fullcollectMFNbbZm / @t / +{ + @gc_times = hist(nsecs - @t); +} +# bpftrace gcprofile.bt +Attaching 2 probes... +^C + +@gc_times: +[64K, 128K) 138 |@ | +[128K, 256K) 1367 |@@@@@@@@@@ | +[256K, 512K) 6687 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| +[512K, 1M) 7 | | +[1M, 2M) 301 |@@ | +``` + +Et voila! A log-scale histogram of the `nsecs` timestamp difference between entering and exiting `fullcollect()`. The times are in nanoseconds, so we see that most collections are taking less than half a millisecond, but we have tail cases that take 1-2ms. + +### Function arguments + +`bpftrace` provides `arg0`, `arg1`, `arg2`, etc. built-in variables for accessing the arguments to a traced function. There are a couple of complications with using them with D code, however. + +The first is that (at the binary level) `dmd` makes `extern(D)` functions (i.e., normal D functions) take arguments in the reverse order of `extern(C)` functions (that `bpftrace` is expecting). Suppose you have a simple three-argument function. If it’s using the C calling convention, `bpftrace` will recognise the first argument as `arg0`. If it’s using the D calling convention, however, it’ll be picked up as `arg2`. + +``` +extern(C) void cfunc(int arg0, int arg1, int arg2) +{ + // ... +} + +// (extern(D) is the default) +extern(D) void dfunc(int arg2, int arg1, int arg0) +{ + // ... +} +``` + +If you look at [the D ABI spec][15], you’ll notice that (just like in C++) there can be a couple of hidden arguments if the function is more complex. If `dfunc` above returned a large struct, there can be an extra hidden argument for implementing [copy elision][16], which means the first argument would actually be `arg3`, and `arg0` would be the hidden argument. If `dfunc` were also a member function, it would have a hidden `this` argument, which would bump up the first argument to `arg4`. + +To get the hang of this, you might need to experiment with tracing function calls with known arguments. + +### Allocation sizes + +Let’s get a histogram of the memory allocation request sizes. Looking at the list of GC functions traced earlier, and comparing it with the GC source code, it looks like we need to trace these functions and grab the `size` argument: + +``` +class ConservativeGC : GC +{ + // ... + void *malloc(size_t size, uint bits, const TypeInfo ti) nothrow; + void *calloc(size_t size, uint bits, const TypeInfo ti) nothrow; + BlkInfo qalloc( size_t size, uint bits, const TypeInfo ti) nothrow; + // ... +} +``` + +As class member functions, they have a hidden `this` argument as well. The last one, `qalloc()`, returns a struct, so it also has a hidden argument for copy elision. So `size` is `arg3` for the first two functions, and `arg4` for `qalloc()`. Time to run a trace: + +``` +# cat allocsizeprofile.bt +uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC6mallocMFNbmkxC8TypeInfoZPv, +uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC6callocMFNbmkxC8TypeInfoZPv +{ + @ = hist(arg3); +} + +uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC6qallocMFNbmkxC8TypeInfoZS4core6memory8BlkInfo_ +{ + @ = hist(arg4); +} + +uretprobe:/usr/local/bin/dscanner:_Dmain +{ + exit(); +} +# bpftrace allocsizeprofile.bt +Attaching 4 probes... +@: +[2, 4) 2489 | | +[4, 8) 9324 |@ | +[8, 16) 46527 |@@@@@ | +[16, 32) 206324 |@@@@@@@@@@@@@@@@@@@@@@@ | +[32, 64) 448020 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| +[64, 128) 147053 |@@@@@@@@@@@@@@@@@ | +[128, 256) 88072 |@@@@@@@@@@ | +[256, 512) 2519 | | +[512, 1K) 1830 | | +[1K, 2K) 3749 | | +[2K, 4K) 1668 | | +[4K, 8K) 256 | | +[8K, 16K) 2533 | | +[16K, 32K) 312 | | +[32K, 64K) 239 | | +[64K, 128K) 209 | | +[128K, 256K) 164 | | +[256K, 512K) 124 | | +[512K, 1M) 48 | | +[1M, 2M) 30 | | +[2M, 4M) 7 | | +[4M, 8M) 1 | | +[8M, 16M) 2 | | +``` + +So, we have a lot of small allocations, with a very long tail of larger allocations. Remember, size is on a log scale, so that long tail represents a very skewed distribution. + +### Small allocation hotspots + +Now for something more complex. Suppose we’re profiling our code and looking for low-hanging fruit for reducing the number of memory allocations. Code that makes a lot of small allocations tends to be a good candidate for this kind of refactoring. `bpftrace` lets us grab stack traces, which can be used to see what part of the main program caused an allocation. + +As of writing, there’s one little complication because of a limitation of `bpftrace`’s stack trace handling: it can only show meaningful function symbol names (as opposed to raw memory addresses) if `bpftrace` quits while the target program is still running. There’s [an open bug report for improving this behaviour][17], but in the meantime I just made sure `dscanner` took a long time, and that I shut down `bpftrace` first. + +Here’s how to grab the top three stack traces that lead to small (<16B) memory allocations with `qalloc()`: + +``` +# cat smallallocs.bt +uprobe:/usr/local/bin/dscanner:_D2gc4impl12conservativeQw14ConservativeGC6qallocMFNbmkxC8TypeInfoZS4core6memory8BlkInfo_ +{ + if (arg4 < 16) + { + @[ustack] = count(); + } +} + +END +{ + print(@, 3); + clear(@); +} +# bpftrace smallallocs.bt +Attaching 2 probes... +^C@[ + _D2gc4impl12conservativeQw14ConservativeGC6qallocMFNbmkxC8TypeInfoZS4core6memory8BlkInfo_+0 + _D2rt8lifetime12__arrayAllocFNaNbmxC8TypeInfoxQlZS4core6memory8BlkInfo_+236 + _d_arraysetlengthT+248 + _D8dscanner8analysis25label_var_same_name_check17LabelVarNameCheck9pushScopeMFZv+29 + _D8dscanner8analysis25label_var_same_name_check17LabelVarNameCheck9__mixin175visitMFxC6dparse3ast6ModuleZv+21 + _D8dscanner8analysis3run7analyzeFAyaxC6dparse3ast6ModulexSQCeQBy6config20StaticAnalysisConfigKS7dsymbol11modulecache11ModuleCacheAxS3std12experimental5lexer__T14TokenStructureThVQFpa305_0a20202020737472696e6720636f6d6d656e743b0a20202020737472696e6720747261696c696e67436f6d6d656e743b0a0a20202020696e74206f70436d702873697a655f7420692920636f6e73742070757265206e6f7468726f77204073616665207b0a202020202020202069662028696e646578203c2069292072657475726e202d313b0a202020202020202069662028696e646578203e2069292072657475726e20313b0a202020202020202072657475726e20303b0a202020207d0a0a20202020696e74206f70436d702872656620636f6e737420747970656f66287468697329206f746865722920636f6e73742070757265206e6f7468726f77204073616665207b0a202020202020202072657475726e206f70436d70286f746865722e696e646578293b0a202020207d0aZQYobZCQZv9container6rbtree__T12RedBlackTreeTSQBGiQBGd4base7MessageVQBFza62_20612e6c696e65203c20622e6c696e65207c7c2028612e6c696e65203d3d20622e6c696e6520262620612e636f6c756d6e203c20622e636f6c756d6e2920Vbi1ZQGt+11343 + _D8dscanner8analysis3run7analyzeFAAyaxSQBlQBf6config20StaticAnalysisConfigQBoKS6dparse5lexer11StringCacheKS7dsymbol11modulecache11ModuleCachebZb+337 + _Dmain+3618 + _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv+40 + _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv+32 + _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv+139 + _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv+32 + _d_run_main+463 + main+16 + __libc_start_main+235 + 0x41fd89415541f689 +]: 450 +@[ + _D2gc4impl12conservativeQw14ConservativeGC6qallocMFNbmkxC8TypeInfoZS4core6memory8BlkInfo_+0 + _D2rt8lifetime12__arrayAllocFNaNbmxC8TypeInfoxQlZS4core6memory8BlkInfo_+236 + _d_arrayappendcTX+1944 + _D8dscanner8analysis10unmodified16UnmodifiedFinder9pushScopeMFZv+61 + _D8dscanner8analysis10unmodified16UnmodifiedFinder5visitMFxC6dparse3ast6ModuleZv+21 + _D8dscanner8analysis3run7analyzeFAyaxC6dparse3ast6ModulexSQCeQBy6config20StaticAnalysisConfigKS7dsymbol11modulecache11ModuleCacheAxS3std12experimental5lexer__T14TokenStructureThVQFpa305_0a20202020737472696e6720636f6d6d656e743b0a20202020737472696e6720747261696c696e67436f6d6d656e743b0a0a20202020696e74206f70436d702873697a655f7420692920636f6e73742070757265206e6f7468726f77204073616665207b0a202020202020202069662028696e646578203c2069292072657475726e202d313b0a202020202020202069662028696e646578203e2069292072657475726e20313b0a202020202020202072657475726e20303b0a202020207d0a0a20202020696e74206f70436d702872656620636f6e737420747970656f66287468697329206f746865722920636f6e73742070757265206e6f7468726f77204073616665207b0a202020202020202072657475726e206f70436d70286f746865722e696e646578293b0a202020207d0aZQYobZCQZv9container6rbtree__T12RedBlackTreeTSQBGiQBGd4base7MessageVQBFza62_20612e6c696e65203c20622e6c696e65207c7c2028612e6c696e65203d3d20622e6c696e6520262620612e636f6c756d6e203c20622e636f6c756d6e2920Vbi1ZQGt+11343 + _D8dscanner8analysis3run7analyzeFAAyaxSQBlQBf6config20StaticAnalysisConfigQBoKS6dparse5lexer11StringCacheKS7dsymbol11modulecache11ModuleCachebZb+337 + _Dmain+3618 + _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv+40 + _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv+32 + _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv+139 + _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv+32 + _d_run_main+463 + main+16 + __libc_start_main+235 + 0x41fd89415541f689 +]: 450 +@[ + _D2gc4impl12conservativeQw14ConservativeGC6qallocMFNbmkxC8TypeInfoZS4core6memory8BlkInfo_+0 + _D2rt8lifetime12__arrayAllocFNaNbmxC8TypeInfoxQlZS4core6memory8BlkInfo_+236 + _d_arrayappendcTX+1944 + _D8dscanner8analysis3run7analyzeFAyaxC6dparse3ast6ModulexSQCeQBy6config20StaticAnalysisConfigKS7dsymbol11modulecache11ModuleCacheAxS3std12experimental5lexer__T14TokenStructureThVQFpa305_0a20202020737472696e6720636f6d6d656e743b0a20202020737472696e6720747261696c696e67436f6d6d656e743b0a0a20202020696e74206f70436d702873697a655f7420692920636f6e73742070757265206e6f7468726f77204073616665207b0a202020202020202069662028696e646578203c2069292072657475726e202d313b0a202020202020202069662028696e646578203e2069292072657475726e20313b0a202020202020202072657475726e20303b0a202020207d0a0a20202020696e74206f70436d702872656620636f6e737420747970656f66287468697329206f746865722920636f6e73742070757265206e6f7468726f77204073616665207b0a202020202020202072657475726e206f70436d70286f746865722e696e646578293b0a202020207d0aZQYobZCQZv9container6rbtree__T12RedBlackTreeTSQBGiQBGd4base7MessageVQBFza62_20612e6c696e65203c20622e6c696e65207c7c2028612e6c696e65203d3d20622e6c696e6520262620612e636f6c756d6e203c20622e636f6c756d6e2920Vbi1ZQGt+680 + _D8dscanner8analysis3run7analyzeFAAyaxSQBlQBf6config20StaticAnalysisConfigQBoKS6dparse5lexer11StringCacheKS7dsymbol11modulecache11ModuleCachebZb+337 + _Dmain+3618 + _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv+40 + _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv+32 + _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv+139 + _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv+32 + _d_run_main+463 + main+16 + __libc_start_main+235 + 0x41fd89415541f689 +]: 450 +``` + +It looks like a lot of the small allocations are due to a red-black tree in `ModuleCache`. + +### What’s next? + +I think these examples already show that `bpftrace` is a pretty powerful tool. There’s a lot more that can done, and I highly recommended reading [Brendan Gregg’s eBPF tutorials][18]. + +I used uprobes to trace arbitrary functions in the D runtime. The pro of this is the freedom to do anything, but the cons are that I had to refer to the D runtime source code and manually deal with the D ABI. There’s also no guarantee that a script I write today will work with future versions of the runtime. Linux also supports making well-defined tracepoints in user code using a feature called [USDT][19]. That should let D code export stable tracepoints that can be used without worrying about the D ABI. I might do more experiments in future. + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2019/04/26/bpftrace_d_gc.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: https://github.com/iovisor/bpftrace +[2]: https://en.wikipedia.org/wiki/Java_virtual_machine +[3]: http://dtrace.org/blogs/about/ +[4]: https://github.com/iovisor/bpftrace/blob/master/INSTALL.md +[5]: https://github.com/iovisor/bpftrace/blob/master/docs/reference_guide.md +[6]: https://github.com/iovisor/bpftrace/blob/master/docs/tutorial_one_liners.md +[7]: https://dlang.org/spec/abi.html#name_mangling +[8]: https://github.com/dlang-community/D-Scanner +[9]: https://github.com/dlang/druntime/ +[10]: https://dlang.org/spec/garbage.html#gc_config +[11]: https://dlang.org/phobos/core_memory.html#.GC.stats +[12]: https://github.com/dlang/druntime/tree/v2.081.1/src/gc +[13]: https://github.com/dlang/druntime/tree/v2.081.1/src/gc/impl/conservative +[14]: https://github.com/dlang/tools +[15]: https://dlang.org/spec/abi.html#parameters +[16]: https://en.wikipedia.org/wiki/Copy_elision +[17]: https://github.com/iovisor/bpftrace/issues/246 +[18]: http://www.brendangregg.com/blog/2019-01-01/learn-ebpf-tracing.html +[19]: https://lwn.net/Articles/753601/ diff --git a/sources/talk/20190429 Cisco goes all in on WiFi 6.md b/sources/talk/20190429 Cisco goes all in on WiFi 6.md deleted file mode 100644 index decd25500a..0000000000 --- a/sources/talk/20190429 Cisco goes all in on WiFi 6.md +++ /dev/null @@ -1,87 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Cisco goes all in on WiFi 6) -[#]: via: (https://www.networkworld.com/article/3391919/cisco-goes-all-in-on-wifi-6.html#tk.rss_all) -[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) - -Cisco goes all in on WiFi 6 -====== -Cisco rolls out Catalyst and Meraki WiFi 6-based access points, Catalyst 9000 switch -![undefined / Getty Images][1] - -Cisco has taken the wraps off a family of WiFi 6 access points, roaming technology and developer-community support all to make wireless a solid enterprise equal with the wired world. - -“Best-effort’ wireless for enterprise customers doesn’t cut it any more. There’s been a change in customer expectations that there will be an uninterrupted unplugged experience,” said Scott Harrell, senior vice president and general manager of enterprise networking at Cisco. **“ **It is now a wireless-first world.** ”** - -**More about 802.11ax (Wi-Fi 6)** - - * [Why 802.11ax is the next big thing in wireless][2] - * [FAQ: 802.11ax Wi-Fi][3] - * [Wi-Fi 6 (802.11ax) is coming to a router near you][4] - * [Wi-Fi 6 with OFDMA opens a world of new wireless possibilities][5] - * [802.11ax preview: Access points and routers that support Wi-Fi 6 are on tap][6] - - - -Bringing a wireless-first enterprise world together is one of the drivers behind a new family of WiFi 6-based access points (AP) for Cisco’s Catalyst and Meraki portfolios. WiFi 6 (802.11ax) is designed for high-density public or private environments. But it also will be beneficial in internet of things (IoT) deployments, and in offices that use bandwidth-hogging applications like videoconferencing. - -The Cisco Catalyst 9100 family and Meraki [MR 45/55][7] WiFi-6 access points are built on Cisco silicon and communicate via pre-802.1ax protocols. The silicon in these access points now acts a rich sensor providing IT with insights about what is going on the wireless network in real-time, and that enables faster reactions to problems and security concerns, Harrell said. - -Aside from WiFi 6, the boxes include support for visibility and communications with Zigbee, BLE and Thread protocols. The Catalyst APs support uplink speeds of 2.5 Gbps, in addition to 100 Mbps and 1 Gbps. All speeds are supported on Category 5e cabling for an industry first, as well as 10GBASE-T (IEEE 802.3bz) cabling, Cisco said. - -Wireless traffic aggregates to wired networks so and the wired network must also evolve. Technology like multi-gigabit Ethernet must be driven into the access layer, which in turn drives higher bandwidth needs at the aggregation and core layers, [Harrell said][8]. - -Handling this influx of wireless traffic was part of the reason Cisco also upgraded its iconic Catalyst 6000 with the [Catalyst 9600 this week][9]. The 9600 brings with it support for Cat 6000 features such as support for MPLS, virtual switching and IPv6, while adding or bolstering support for wireless netowrks as well as Intent-based networking (IBN) and security segmentation. The 9600 helps fill out the company’s revamped lineup which includes the 9200 family of access switches, the 9500 aggregation switch and 9800 wireless controller. - -“WiFi doesn’t exist in a vacuum – how it connects to the enterprise and the data center or the Internet is key and in Cisco’s case that key is now the 9600 which has been built to handle the increased traffic,” said Lee Doyle, principal analyst with Doyle Research. - -The new 9600 ties in with the recently [released Catalyst 9800][10], which features 40Gbps to 100Gbps performance, depending on the model, hot-patching to simplify updates and eliminate update-related downtime, Encrypted Traffic Analytics (ETA), policy-based micro- and macro-segmentation and Trustworthy solutions to detect malware on wired or wireless connected devices, Cisco said. - -All Catalyst 9000 family members support other Cisco products such as [DNA Center][11] , which controls automation capabilities, assurance setting, fabric provisioning and policy-based segmentation for enterprise wired and wireless networks. - -The new APs are pre-standard, but other vendors including Aruba, NetGear and others are also selling pre-standard 802.11ax devices. Cisco getting into the market solidifies the validity of this strategy, said Brandon Butler, a senior research analyst with IDC. - -Many experts [expect the standard][12] to be ratified late this year. - -“We expect to see volume shipments of WiFi 6 products by early next year and it being the de facto WiFi standard by 2022.” - -On top of the APs and 9600 switch, Cisco extended its software development community – [DevNet][13] – to offer WiFi 6 learning labs, sandboxes and developer resources. - -The Cisco Catalyst and Meraki access platforms are open and programmable all the way down to the chipset level, allowing applications to take advantage of network programmability, Cisco said. - -Cisco also said it had added more vendors to now include Apple, Samsung, Boingo, Presidio and Intel for its ongoing [OpenRoaming][14] project. OpenRoaming, which is in beta promises to let users move seamlessly between wireless networks and LTE without interruption. - -Join the Network World communities on [Facebook][15] and [LinkedIn][16] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3391919/cisco-goes-all-in-on-wifi-6.html#tk.rss_all - -作者:[Michael Cooney][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Michael-Cooney/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2019/04/cisco_catalyst_wifi_coffee-cup_coffee-beans_-100794990-large.jpg -[2]: https://www.networkworld.com/article/3215907/mobile-wireless/why-80211ax-is-the-next-big-thing-in-wi-fi.html -[3]: https://%20https//www.networkworld.com/article/3048196/mobile-wireless/faq-802-11ax-wi-fi.html -[4]: https://www.networkworld.com/article/3311921/mobile-wireless/wi-fi-6-is-coming-to-a-router-near-you.html -[5]: https://www.networkworld.com/article/3332018/wi-fi/wi-fi-6-with-ofdma-opens-a-world-of-new-wireless-possibilities.html -[6]: https://www.networkworld.com/article/3309439/mobile-wireless/80211ax-preview-access-points-and-routers-that-support-the-wi-fi-6-protocol-on-tap.html -[7]: https://meraki.cisco.com/lib/pdf/meraki_datasheet_MR55.pdf -[8]: https://blogs.cisco.com/news/unplugged-and-uninterrupted -[9]: https://www.networkworld.com/article/3391580/venerable-cisco-catalyst-6000-switches-ousted-by-new-catalyst-9600.html -[10]: https://www.networkworld.com/article/3321000/cisco-links-wireless-wired-worlds-with-new-catalyst-9000-switches.html -[11]: https://www.networkworld.com/article/3280988/cisco/cisco-opens-dna-center-network-control-and-management-software-to-the-devops-masses.html -[12]: https://www.networkworld.com/article/3336263/is-jumping-ahead-to-wi-fi-6-the-right-move.html -[13]: https://developer.cisco.com/wireless/?utm_campaign=colaunch-wireless19&utm_source=pressrelease&utm_medium=ciscopress-wireless-main -[14]: https://www.cisco.com/c/en/us/solutions/enterprise-networks/802-11ax-solution/openroaming.html -[15]: https://www.facebook.com/NetworkWorld/ -[16]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190429 Venerable Cisco Catalyst 6000 switches ousted by new Catalyst 9600.md b/sources/talk/20190429 Venerable Cisco Catalyst 6000 switches ousted by new Catalyst 9600.md deleted file mode 100644 index 965d2a0e51..0000000000 --- a/sources/talk/20190429 Venerable Cisco Catalyst 6000 switches ousted by new Catalyst 9600.md +++ /dev/null @@ -1,86 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Venerable Cisco Catalyst 6000 switches ousted by new Catalyst 9600) -[#]: via: (https://www.networkworld.com/article/3391580/venerable-cisco-catalyst-6000-switches-ousted-by-new-catalyst-9600.html#tk.rss_all) -[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) - -Venerable Cisco Catalyst 6000 switches ousted by new Catalyst 9600 -====== -Cisco introduced Catalyst 9600 switches, that let customers automate, set policy, provide security and gain assurance across wired and wireless networks. -![Martyn Williams][1] - -Few events in the tech industry are truly transformative, but Cisco’s replacement of its core Catalyst 6000 family could be one of those actions for customers and the company. - -Introduced in 1999, [iterations of the Catalyst 6000][2] have nestled into the core of scores of enterprise networks, with the model 6500 becoming the company’s largest selling box ever. - -**Learn about edge networking** - - * [How edge networking and IoT will reshape data centers][3] - * [Edge computing best practices][4] - * [How edge computing can help secure the IoT][5] - - - -It goes without question that migrating these customers alone to the new switch – the Catalyst 9600 which the company introduced today – will be of monumental importance to Cisco as it looks to revamp and continue to dominate large campus-core deployments. The first [Catalyst 9000][6], introduced in June 2017, is already the fastest ramping product line in Cisco’s history. - -“There are at least tens of thousands of Cat 6000s running in campus cores all over the world,” said [Sachin Gupta][7], senior vice president for product management at Cisco. ”It is the Swiss Army knife of switches in term of features, and we have taken great care and over two years developing feature parity and an easy migration path for those users to the Cat 9000.” - -Indeed the 9600 brings with it for Cat 6000 features such as support for MPLS, virtual switching and IPv6, while adding or bolstering support for newer items such as Intent-based networking (IBN), wireless networks and security segmentation. Strategically the 9600 helps fill out the company’s revamped lineup which includes the 9200 family of access switches, the [9500][8] aggregation switch and [9800 wireless controller.][9] - -Some of the nitty-gritty details about the 9600: - - * It is a purpose-built 40 Gigabit and 100 Gigabit Ethernet line of modular switches targeted for the enterprise campus with a wired switching capacity of up to 25.6 Tbps, with up to 6.4 Tbps of bandwidth per slot. - * The switch supports granular port densities that fit diverse campus needs, including nonblocking 40 Gigabit and 100 Gigabit Ethernet Quad Small Form-Factor Pluggable (QSFP+, QSFP28) and 1, 10, and 25 GE Small Form-Factor Pluggable Plus (SFP, SFP+, SFP28). - * It can be configured to support up to 48 nonblocking 100 Gigabit Ethernet QSPF28 ports with the Cisco Catalyst 9600 Series Supervisor Engine 1; Up to 96 nonblocking 40 Gigabit Ethernet QSFP+ ports with the Cisco Catalyst 9600 Series Supervisor Engine 1 and Up to 192 nonblocking 25 Gigabit/10 Gigabit Ethernet SFP28/SFP+ ports with the Cisco Catalyst 9600 Series Supervisor Engine 1. - * It supports advanced routing and infrastructure services (MPLS, Layer 2 and Layer 3 VPNs, Multicast VPN, and Network Address Translation. - * Cisco Software-Defined Access capabilities (such as a host-tracking database, cross-domain connectivity, and VPN Routing and Forwarding [VRF]-aware Locator/ID Separation Protocol; and network system virtualization with Cisco StackWise virtual technology. - - - -The 9600 series runs Cisco’s IOS XE software which now runs across all Catalyst 9000 family members. The software brings with it support for other key products such as Cisco’s [DNA Center][10] which controls automation capabilities, assurance setting, fabric provisioning and policy-based segmentation for enterprise networks. What that means is that with one user interface, DNA Center, customers can automate, set policy, provide security and gain assurance across the entire wired and wireless network fabric, Gupta said. - -“The 9600 is a big deal for Cisco and customers as it brings together the campus core and lets users establish standards access and usage policies across their wired and wireless environments,” said Brandon Butler, a senior research analyst with IDC. “It was important that Cisco add a powerful switch to handle the increasing amounts of traffic wireless and cloud applications are bringing to the network.” - -IOS XE brings with it automated device provisioning and a wide variety of automation features including support for the network configuration protocol NETCONF and RESTCONF using YANG data models. The software offers near-real-time monitoring of the network, leading to quick detection and rectification of failures, Cisco says. - -The software also supports hot patching which provides fixes for critical bugs and security vulnerabilities between regular maintenance releases. This support lets customers add patches without having to wait for the next maintenance release, Cisco says. - -As with the rest of the Catalyst family, the 9600 is available via subscription-based licensing. Cisco says the [base licensing package][11] includes Network Advantage licensing options that are tied to the hardware. The base licensing packages cover switching fundamentals, management automation, troubleshooting, and advanced switching features. These base licenses are perpetual. - -An add-on licensing package includes the Cisco DNA Premier and Cisco DNA Advantage options. The Cisco DNA add-on licenses are available as a subscription. - -IDC’S Butler noted that there are competitors such as Ruckus, Aruba and Extreme that offer switches capable of melding wired and wireless environments. - -The new switch is built for the next two decades of networking, Gupta said. “If any of our competitors though they could just go in and replace the Cat 6k they were misguided.” - -Join the Network World communities on [Facebook][12] and [LinkedIn][13] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3391580/venerable-cisco-catalyst-6000-switches-ousted-by-new-catalyst-9600.html#tk.rss_all - -作者:[Michael Cooney][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Michael-Cooney/ -[b]: https://github.com/lujun9972 -[1]: https://images.techhive.com/images/article/2017/02/170227-mwc-02759-100710709-large.jpg -[2]: https://www.networkworld.com/article/2289826/133715-The-illustrious-history-of-Cisco-s-Catalyst-LAN-switches.html -[3]: https://www.networkworld.com/article/3291790/data-center/how-edge-networking-and-iot-will-reshape-data-centers.html -[4]: https://www.networkworld.com/article/3331978/lan-wan/edge-computing-best-practices.html -[5]: https://www.networkworld.com/article/3331905/internet-of-things/how-edge-computing-can-help-secure-the-iot.html -[6]: https://www.networkworld.com/article/3256264/cisco-ceo-we-are-still-only-on-the-front-end-of-a-new-version-of-the-network.html -[7]: https://blogs.cisco.com/enterprise/looking-forward-catalyst-9600-switch-and-9100-access-point-meraki -[8]: https://www.networkworld.com/article/3202105/cisco-brings-intent-based-networking-to-the-end-to-end-network.html -[9]: https://www.networkworld.com/article/3321000/cisco-links-wireless-wired-worlds-with-new-catalyst-9000-switches.html -[10]: https://www.networkworld.com/article/3280988/cisco/cisco-opens-dna-center-network-control-and-management-software-to-the-devops-masses.html -[11]: https://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst9600/software/release/16-11/release_notes/ol-16-11-9600.html#id_67835 -[12]: https://www.facebook.com/NetworkWorld/ -[13]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190501 Vapor IO provides direct, high-speed connections from the edge to AWS.md b/sources/talk/20190501 Vapor IO provides direct, high-speed connections from the edge to AWS.md deleted file mode 100644 index 0ddef36770..0000000000 --- a/sources/talk/20190501 Vapor IO provides direct, high-speed connections from the edge to AWS.md +++ /dev/null @@ -1,69 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Vapor IO provides direct, high-speed connections from the edge to AWS) -[#]: via: (https://www.networkworld.com/article/3391922/vapor-io-provides-direct-high-speed-connections-from-the-edge-to-aws.html#tk.rss_all) -[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) - -Vapor IO provides direct, high-speed connections from the edge to AWS -====== -With a direct fiber line, latency between the edge and the cloud can be dramatically reduced. -![Vapor IO][1] - -Edge computing startup Vapor IO now offers a direct connection between its edge containers to Amazon Web Services (AWS) via a high-speed fiber network link. - -The company said that connection between its Kinetic Edge containers and AWS will be provided by Crown Castle's Cloud Connect fiber network, which uses Amazon Direct Connect Services. This would help reduce network latency by essentially drawing a straight fiber line from Vapor IO's edge computing data centers to Amazon's cloud computing data centers. - -“When combined with Crown Castle’s high-speed Cloud Connect fiber, the Kinetic Edge lets AWS developers build applications that span the entire continuum from core to edge. By enabling new classes of applications at the edge, we make it possible for any AWS developer to unlock the next generation of real-time, innovative use cases,” wrote Matt Trifiro, chief marketing officer of Vapor IO, in a [blog post][2]. - -**[ Read also:[What is edge computing and how it’s changing the network][3] ]** - -Vapor IO clams that the connection will lower latency by as much as 75%. “Connecting workloads and data at the Kinetic Edge with workloads and data in centralized AWS data centers makes it possible to build edge applications that leverage the full power of AWS,” wrote Trifiro. - -Developers building applications at the Kinetic Edge will have access to the full suite of AWS cloud computing services, including Amazon Simple Storage Service (Amazon S3), Amazon Elastic Cloud Compute (Amazon EC2), Amazon Virtual Private Cloud (Amazon VPC), and Amazon Relational Database Service (Amazon RDS). - -Crown Castle is the largest provider of shared communications infrastructure in the U.S., with 40,000 cell towers and 60,000 miles of fiber, offering 1Gbps to 10Gbps private fiber connectivity between the Kinetic Edge and AWS. - -AWS Direct Connect is a essentially a private connection between Amazon's AWS customers and their the AWS data centers, so customers don’t have to rout their traffic over the public internet and compete with Netflix and YouTube, for example, for bandwidth. - -### How edge computing works - -The structure of [edge computing][3] is the reverse of the standard internet design. Rather than sending all the data up to central servers, as much processing as possible is done at the edge. This is to reduce the sheer volume of data coming upstream and thus reduce latency. - -With things like smart cars, even if 95% of data is eliminated that remaining, 5% can still be a lot, so moving it fast is essential. Vapor IO said it will shuttle workloads to Amazon’s USEAST and USWEST data centers, depending on location. - -This shows how the edge is up-ending the traditional internet design and moving more computing outside the traditional data center, although a connection upstream is still important because it allows for rapid movement of necessary data from the edge to the cloud, where it can be stored or processed. - -**More about edge networking:** - - * [How edge networking and IoT will reshape data centers][4] - * [Edge computing best practices][5] - * [How edge computing can help secure the IoT][6] - - - -Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3391922/vapor-io-provides-direct-high-speed-connections-from-the-edge-to-aws.html#tk.rss_all - -作者:[Andy Patrizio][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Andy-Patrizio/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2018/09/vapor-io-kinetic-edge-data-center-100771510-large.jpg -[2]: https://www.vapor.io/powering-amazon-web-services-at-the-kinetic-edge/ -[3]: https://www.networkworld.com/article/3224893/what-is-edge-computing-and-how-it-s-changing-the-network.html -[4]: https://www.networkworld.com/article/3291790/data-center/how-edge-networking-and-iot-will-reshape-data-centers.html -[5]: https://www.networkworld.com/article/3331978/lan-wan/edge-computing-best-practices.html -[6]: https://www.networkworld.com/article/3331905/internet-of-things/how-edge-computing-can-help-secure-the-iot.html -[7]: https://www.facebook.com/NetworkWorld/ -[8]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190506 Cisco boosts SD-WAN with multicloud-to-branch access system.md b/sources/talk/20190506 Cisco boosts SD-WAN with multicloud-to-branch access system.md deleted file mode 100644 index c676e5effb..0000000000 --- a/sources/talk/20190506 Cisco boosts SD-WAN with multicloud-to-branch access system.md +++ /dev/null @@ -1,89 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Cisco boosts SD-WAN with multicloud-to-branch access system) -[#]: via: (https://www.networkworld.com/article/3393232/cisco-boosts-sd-wan-with-multicloud-to-branch-access-system.html#tk.rss_all) -[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) - -Cisco boosts SD-WAN with multicloud-to-branch access system -====== -Cisco's SD-WAN Cloud onRamp for CoLocation can tie branch offices to private data centers in regional corporate headquarters via colocation facilities for shorter, faster, possibly more secure connections. -![istock][1] - -Cisco is looking to give traditional or legacy wide-area network users another reason to move to the [software-defined WAN world][2]. - -The company has rolled out an integrated hardware/software package called SD-WAN Cloud onRamp for CoLocation that lets customers tie distributed multicloud applications back to a local branch office or local private data center. The idea is that a cloud-to-branch link would be shorter, faster and possibly more secure that tying cloud-based applications directly all the way to the data center. - -**More about SD-WAN** - - * [How to buy SD-WAN technology: Key questions to consider when selecting a supplier][3] - * [How to pick an off-site data-backup method][4] - * [SD-Branch: What it is and why you’ll need it][5] - * [What are the options for security SD-WAN?][6] - - - -“With Cisco SD-WAN Cloud onRamp for CoLocation operating regionally, connections from colocation facilities to branches are set up and configured according to traffic loads (such as video vs web browsing vs email) SLAs (requirements for low latency/jitter), and Quality of Experience for optimizing cloud application performance,” wrote Anand Oswal, senior vice president of engineering, in Cisco’s Enterprise Networking Business in a [blog about the new service][7]. - -According to Oswal, each branch or private data center is equipped with a network interface that provides a secure tunnel to the regional colocation facility. In turn, the Cloud onRamp for CoLocation establishes secure tunnels to SaaS application platforms, multi-cloud platform services, and enterprise data centers, he stated. - -Traffic is securely routed through the Cloud onRamp for CoLocation stack which includes security features such as application-aware firewalls, URL-filtering, intrusion detection/prevention, DNS-layer security, and Advanced Malware Protection (AMP) Threat Grid, as well as other network services such as load-balancing and Wide Area Application Services, Oswal wrote. - -A typical use case for the package is an enterprise that has dozens of distributed branch offices, clustered around major cities, spread over several countries. The goal is to tie each branch to enterprise data center databases, SaaS applications, and multi-cloud services while meeting service level agreements and application quality of experience, Oswal stated. - -“With virtualized Cisco SD-WAN running on regional colocation centers, the branch workforce has access to applications and data residing in AWS, Azure, and Google cloud platforms as well as SaaS providers such as Microsoft 365 and Salesforce—transparently and securely,” Oswal said. “Distributing SD-WAN features over a regional architecture also brings processing power closer to where data is being generated—at the cloud edge.” - -The idea is that paths to designated SaaS applications will be monitored continuously for performance, and the application traffic will be dynamically routed to the best-performing path, without requiring human intervention, Oswal stated. - -For a typical configuration, a region covering a target city uses a colocation IaaS provider that hosts the Cisco Cloud onRamp for CoLocation, which includes: - - * Cisco vManage software that lets customers manage applications and provision, monitor and troubleshooting the WAN. - * [Cisco Cloud Services Platform (CSP) 5000][8] The systems are x86 Linux Kernel-based Virtual Machine (KVM) software and hardware platforms for the data center, regional hub, and colocation Network Functions Virtualization (NFV). The platforms let enterprise IT teams or service providers deploy any Cisco or third-party network virtual service with Cisco’s [Network Services Orchestrator (NSO)][9] or any other northbound management and orchestration system. - * The Cisco [Catalyst 9500 Series][10] aggregation switches. Based on an x86 CPU, the Catalyst 9500 Series is Cisco’s lead purpose-built fixed core and aggregation enterprise switching platform, built for security, IoT, and cloud. The switches come with a 4-core x86, 2.4-GHz CPU, 16-GB DDR4 memory, and 16-GB internal storage. - - - -If the features of the package sound familiar, that’s because the [Cloud onRamp for CoLocation][11] package is the second generation of a similar SD-WAN package offered by Viptela which Cisco [bought in 2017][12]. - -SD-WAN's driving principle is to simplify the way big companies turn up new links to branch offices, better manage the way those links are utilized – for data, voice or video – and potentially save money in the process. - -It's a profoundly hot market with tons of players including [Cisco][13], VMware, Silver Peak, Riverbed, Aryaka, Fortinet, Nokia and Versa. IDC says the SD-WAN infrastructure market will hit $4.5 billion by 2022, growing at a more than 40% yearly clip between now and then. - -[SD-WAN][14] lets networks route traffic based on centrally managed roles and rules, no matter what the entry and exit points of the traffic are, and with full security. For example, if a user in a branch office is working in Office365, SD-WAN can route their traffic directly to the closest cloud data center for that app, improving network responsiveness for the user and lowering bandwidth costs for the business. - -"SD-WAN has been a promised technology for years, but in 2019 it will be a major driver in how networks are built and re-built," Oswal said a Network World [article][15] earlier this year. - -Join the Network World communities on [Facebook][16] and [LinkedIn][17] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3393232/cisco-boosts-sd-wan-with-multicloud-to-branch-access-system.html#tk.rss_all - -作者:[Michael Cooney][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Michael-Cooney/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2018/02/istock-578801262-100750453-large.jpg -[2]: https://www.networkworld.com/article/3209131/what-sdn-is-and-where-its-going.html -[3]: https://www.networkworld.com/article/3323407/sd-wan/how-to-buy-sd-wan-technology-key-questions-to-consider-when-selecting-a-supplier.html -[4]: https://www.networkworld.com/article/3328488/backup-systems-and-services/how-to-pick-an-off-site-data-backup-method.html -[5]: https://www.networkworld.com/article/3250664/lan-wan/sd-branch-what-it-is-and-why-youll-need-it.html -[6]: https://www.networkworld.com/article/3285728/sd-wan/what-are-the-options-for-securing-sd-wan.html?nsdr=true -[7]: https://blogs.cisco.com/enterprise/cisco-sd-wan-cloud-onramp-for-colocation-multicloud -[8]: https://www.cisco.com/c/en/us/products/collateral/switches/cloud-services-platform-5000/nb-06-csp-5k-data-sheet-cte-en.html#ProductOverview -[9]: https://www.cisco.com/go/nso -[10]: https://www.cisco.com/c/en/us/products/collateral/switches/catalyst-9500-series-switches/data_sheet-c78-738978.html -[11]: https://www.networkworld.com/article/3207751/viptela-cloud-onramp-optimizes-cloud-access.html -[12]: https://www.networkworld.com/article/3193784/cisco-grabs-up-sd-wan-player-viptela-for-610m.html?nsdr=true -[13]: https://www.networkworld.com/article/3322937/what-will-be-hot-for-cisco-in-2019.html -[14]: https://www.networkworld.com/article/3031279/sd-wan/sd-wan-what-it-is-and-why-you-ll-use-it-one-day.html -[15]: https://www.networkworld.com/article/3332027/cisco-touts-5-technologies-that-will-change-networking-in-2019.html -[16]: https://www.facebook.com/NetworkWorld/ -[17]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190507 Server shipments to pick up in the second half of 2019.md b/sources/talk/20190507 Server shipments to pick up in the second half of 2019.md deleted file mode 100644 index 8169c594ef..0000000000 --- a/sources/talk/20190507 Server shipments to pick up in the second half of 2019.md +++ /dev/null @@ -1,56 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Server shipments to pick up in the second half of 2019) -[#]: via: (https://www.networkworld.com/article/3393167/server-shipments-to-pick-up-in-the-second-half-of-2019.html#tk.rss_all) -[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) - -Server shipments to pick up in the second half of 2019 -====== -Server sales slowed in anticipation of the new Intel Xeon processors, but they are expected to start up again before the end of the year. -![Thinkstock][1] - -Global server shipments are not expected to return to growth momentum until the third quarter or even the fourth quarter of 2019, according to Taiwan-based tech news site DigiTimes, which cited unnamed server supply chain sources. The one bright spot remains cloud providers like Amazon, Google, and Facebook, which continue their buying binge. - -Normally I’d be reluctant to cite such a questionable source, but given most of the OEMs and ODMs are based in Taiwan and DigiTimes (the article is behind a paywall so I cannot link) has shown it has connections to them, I’m inclined to believe them. - -Quanta Computer chairman Barry Lam told the publication that Quanta's shipments of cloud servers have risen steadily, compared to sharp declines in shipments of enterprise servers. Lam continued that enterprise servers command only 1-2% of the firm's total server shipments. - -**[ Also read:[Gartner: IT spending to drop due to falling equipment prices][2] ]** - -[Server shipments began to slow down in the first quarter][3] thanks in part to the impending arrival of second-generation Xeon Scalable processors from Intel. And since it takes a while to get parts and qualify them, this quarter won’t be much better. - -In its latest quarterly earnings, Intel's data center group (DCG) said sales declined 6% year over year, the first decline of its kind since the first quarter of 2012 and reversing an average growth of over 20% in the past. - -[The Osbourne Effect][4] wasn’t the sole reason. An economic slowdown in China and the trade war, which will add significant tariffs to Chinese-made products, are also hampering sales. - -DigiTimes says Inventec, Intel's largest server motherboard supplier, expects shipments of enterprise server motherboards to further lose steams for the rest of the year, while sales of data center servers are expected to grow 10-15% on year in 2019. - -**[[Get certified as an Apple Technical Coordinator with this seven-part online course from PluralSight.][5] ]** - -It went on to say server shipments may concentrate in the second half or even the fourth quarter of the year, while cloud-based data center servers for the cloud giants will remain positive as demand for edge computing, new artificial intelligence (AI) applications, and the proliferation of 5G applications begin in 2020. - -Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3393167/server-shipments-to-pick-up-in-the-second-half-of-2019.html#tk.rss_all - -作者:[Andy Patrizio][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Andy-Patrizio/ -[b]: https://github.com/lujun9972 -[1]: https://images.techhive.com/images/article/2017/04/2_data_center_servers-100718306-large.jpg -[2]: https://www.networkworld.com/article/3391062/it-spending-to-drop-due-to-falling-equipment-prices-gartner-predicts.html -[3]: https://www.networkworld.com/article/3332144/server-sales-projected-to-slow-while-memory-prices-drop.html -[4]: https://en.wikipedia.org/wiki/Osborne_effect -[5]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fapple-certified-technical-trainer-10-11 -[6]: https://www.facebook.com/NetworkWorld/ -[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190509 Cisco adds AMP to SD-WAN for ISR-ASR routers.md b/sources/talk/20190509 Cisco adds AMP to SD-WAN for ISR-ASR routers.md deleted file mode 100644 index a5ec6212d8..0000000000 --- a/sources/talk/20190509 Cisco adds AMP to SD-WAN for ISR-ASR routers.md +++ /dev/null @@ -1,74 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Cisco adds AMP to SD-WAN for ISR/ASR routers) -[#]: via: (https://www.networkworld.com/article/3394597/cisco-adds-amp-to-sd-wan-for-israsr-routers.html#tk.rss_all) -[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) - -Cisco adds AMP to SD-WAN for ISR/ASR routers -====== -Cisco SD-WAN now sports Advanced Malware Protection on its popular edge routers, adding to their routing, segmentation, security, policy and orchestration capabilities. -![vuk8691 / Getty Images][1] - -Cisco has added support for Advanced Malware Protection (AMP) to its million-plus ISR/ASR edge routers, in an effort to [reinforce branch and core network malware protection][2] at across the SD-WAN. - -Cisco last year added its Viptela SD-WAN technology to the IOS XE version 16.9.1 software that runs its core ISR/ASR routers such as the ISR models 1000, 4000 and ASR 5000, in use by organizations worldwide. Cisco bought Viptela in 2017. - -**More about SD-WAN** - - * [How to buy SD-WAN technology: Key questions to consider when selecting a supplier][3] - * [How to pick an off-site data-backup method][4] - * [SD-Branch: What it is and why you’ll need it][5] - * [What are the options for security SD-WAN?][6] - - - -The release of Cisco IOS XE offered an instant upgrade path for creating cloud-controlled SD-WAN fabrics to connect distributed offices, people, devices and applications operating on the installed base, Cisco said. At the time Cisco said that Cisco SD-WAN on edge routers builds a secure virtual IP fabric by combining routing, segmentation, security, policy and orchestration. - -With the recent release of [IOS-XE SD-WAN 16.11][7], Cisco has brought AMP and other enhancements to its SD-WAN. - -“Together with Cisco Talos [Cisco’s security-intelligence arm], AMP imbues your SD-WAN branch, core and campuses locations with threat intelligence from millions of worldwide users, honeypots, sandboxes, and extensive industry partnerships,” wrote Cisco’s Patrick Vitalone a product marketing manager in a [blog][8] about the security portion of the new software. “In total, AMP identifies more than 1.1 million unique malware samples a day." When AMP in Cisco SD-WAN spots malicious behavior it automatically blocks it, he wrote. - -The idea is to use integrated preventative engines, exploit prevention and intelligent signature-based antivirus to stop malicious attachments and fileless malware before they execute, Vitalone wrote. - -AMP support is added to a menu of security features already included in the SD-WAN software including support for URL filtering, [Cisco Umbrella][9] DNS security, Snort Intrusion Prevention, the ability to segment users across the WAN and embedded platform security, including the [Cisco Trust Anchor][10] module. - -**[[Prepare to become a Certified Information Security Systems Professional with this comprehensive online course from PluralSight. Now offering a 10-day free trial!][11] ]** - -The software also supports [SD-WAN Cloud onRamp for CoLocation][12], which lets customers tie distributed multicloud applications back to a local branch office or local private data center. That way a cloud-to-branch link would be shorter, faster and possibly more secure that tying cloud-based applications directly to the data center. - -“The idea that this kind of security technology is now integrated into Cisco’s SD-WAN offering is a critical for Cisco and customers looking to evaluate SD-WAN offerings,” said Lee Doyle, principal analyst at Doyle Research. - -IOS-XE SD-WAN 16.11 is available now. - -Join the Network World communities on [Facebook][13] and [LinkedIn][14] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3394597/cisco-adds-amp-to-sd-wan-for-israsr-routers.html#tk.rss_all - -作者:[Michael Cooney][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Michael-Cooney/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2018/09/shimizu_island_el_nido_palawan_philippines_by_vuk8691_gettyimages-155385042_1200x800-100773533-large.jpg -[2]: https://www.networkworld.com/article/3285728/what-are-the-options-for-securing-sd-wan.html -[3]: https://www.networkworld.com/article/3323407/sd-wan/how-to-buy-sd-wan-technology-key-questions-to-consider-when-selecting-a-supplier.html -[4]: https://www.networkworld.com/article/3328488/backup-systems-and-services/how-to-pick-an-off-site-data-backup-method.html -[5]: https://www.networkworld.com/article/3250664/lan-wan/sd-branch-what-it-is-and-why-youll-need-it.html -[6]: https://www.networkworld.com/article/3285728/sd-wan/what-are-the-options-for-securing-sd-wan.html?nsdr=true -[7]: https://www.cisco.com/c/en/us/td/docs/routers/sdwan/release/notes/xe-16-11/sd-wan-rel-notes-19-1.html -[8]: https://blogs.cisco.com/enterprise/enabling-amp-in-cisco-sd-wan -[9]: https://www.networkworld.com/article/3167837/cisco-umbrella-cloud-service-shapes-security-for-cloud-mobile-resources.html -[10]: https://www.cisco.com/c/dam/en_us/about/doing_business/trust-center/docs/trustworthy-technologies-datasheet.pdf -[11]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr -[12]: https://www.networkworld.com/article/3393232/cisco-boosts-sd-wan-with-multicloud-to-branch-access-system.html -[13]: https://www.facebook.com/NetworkWorld/ -[14]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190510 Supermicro moves production from China.md b/sources/talk/20190510 Supermicro moves production from China.md deleted file mode 100644 index 21739fa416..0000000000 --- a/sources/talk/20190510 Supermicro moves production from China.md +++ /dev/null @@ -1,58 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Supermicro moves production from China) -[#]: via: (https://www.networkworld.com/article/3394404/supermicro-moves-production-from-china.html#tk.rss_all) -[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) - -Supermicro moves production from China -====== -Supermicro was cleared of any activity related to the Chinese government and secret chips in its motherboards, but it is taking no chances and is moving its facilities. -![Frank Schwichtenberg \(CC BY 4.0\)][1] - -Server maker Supermicro, based in Fremont, California, is reportedly moving production out of China over customer concerns that the Chinese government had secretly inserted chips for spying into its motherboards. - -The claims were made by Bloomberg late last year in a story that cited more than 100 sources in government and private industry, including Apple and Amazon Web Services (AWS). However, Apple CEO Tim Cook and AWS CEO Andy Jassy denied the claims and called for Bloomberg to retract the article. And a few months later, the third-party investigations firm Nardello & Co examined the claims and [cleared Supermicro][2] of any surreptitious activity. - -At first it seemed like Supermicro was weathering the storm, but the story did have a negative impact. Server sales have fallen since the Bloomberg story, and the company is forecasting a near 10% decline in total revenues for the March quarter compared to the previous three months. - -**[ Also read:[Who's developing quantum computers][3] ]** - -And now, Nikkei Asian Review reports that despite the strong rebuttals, some customers remain cautious about the company's products. To address those concerns, Nikkei says Supermicro has told suppliers to [move production out of China][4], citing industry sources familiar with the matter. - -It also has the side benefit of mitigating against the U.S.-China trade war, which is only getting worse. Since the tariffs are on the dollar amount of the product, that can quickly add up even for a low-end system, as Serve The Home noted in [this analysis][5]. - -Supermicro is the world's third-largest server maker by shipments, selling primarily to cloud providers like Amazon and Facebook. It does its own assembly in its Fremont facility but outsources motherboard production to numerous suppliers, mostly China and Taiwan. - -"We have to be more self-reliant [to build in-house manufacturing] without depending only on those outsourcing partners whose production previously has mostly been in China," an executive told Nikkei. - -Nikkei notes that roughly 90% of the motherboards shipped worldwide in 2017 were made in China, but that percentage dropped to less than 50% in 2018, according to Digitimes Research, a tech supply chain specialist based in Taiwan. - -Supermicro just held a groundbreaking ceremony in Taiwan for a 800,000 square foot manufacturing plant in Taiwan and is expanding its San Jose, California, plant as well. So, they must be anxious to be free of China if they are willing to expand in one of the most expensive real estate markets in the world. - -A Supermicro spokesperson said via email, “We have been expanding our manufacturing capacity for many years to meet increasing customer demand. We are currently constructing a new Green Computing Park building in Silicon Valley, where we are the only Tier 1 solutions vendor manufacturing in Silicon Valley, and we proudly broke ground this week on a new manufacturing facility in Taiwan. To support our continued global growth, we look forward to expanding in Europe as well.” - -Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3394404/supermicro-moves-production-from-china.html#tk.rss_all - -作者:[Andy Patrizio][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Andy-Patrizio/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2019/05/supermicro_-_x11sae__cebit_2016_01-100796121-large.jpg -[2]: https://www.networkworld.com/article/3326828/investigator-finds-no-evidence-of-spy-chips-on-super-micro-motherboards.html -[3]: https://www.networkworld.com/article/3275385/who-s-developing-quantum-computers.html -[4]: https://asia.nikkei.com/Economy/Trade-war/Server-maker-Super-Micro-to-ditch-made-in-China-parts-on-spy-fears -[5]: https://www.servethehome.com/how-tariffs-hurt-intel-xeon-d-atom-and-amd-epyc-3000/ -[6]: https://www.facebook.com/NetworkWorld/ -[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190513 Top auto makers rely on cloud providers for IoT.md b/sources/talk/20190513 Top auto makers rely on cloud providers for IoT.md new file mode 100644 index 0000000000..5adf5f65a7 --- /dev/null +++ b/sources/talk/20190513 Top auto makers rely on cloud providers for IoT.md @@ -0,0 +1,53 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Top auto makers rely on cloud providers for IoT) +[#]: via: (https://www.networkworld.com/article/3395137/top-auto-makers-rely-on-cloud-providers-for-iot.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +Top auto makers rely on cloud providers for IoT +====== + +For the companies looking to implement the biggest and most complex [IoT][1] setups in the world, the idea of pairing up with [AWS][2], [Google Cloud][3] or [Azure][4] seems to be one whose time has come. Within the last two months, BMW and Volkswagen have both announced large-scale deals with Microsoft and Amazon, respectively, to help operate their extensive network of operational technology. + +According to Alfonso Velosa, vice president and analyst at Gartner, part of the impetus behind those two deals is that the automotive sector fits in very well with the architecture of the public cloud. Public clouds are great at collecting and processing data from a diverse array of different sources, whether they’re in-vehicle sensors, dealerships, mechanics, production lines or anything else. + +**[ RELATED:[What hybrid cloud means in practice][5]. | Get regularly scheduled insights by [signing up for Network World newsletters][6]. ]** + +“What they’re trying to do is create a broader ecosystem. They think they can leverage the capabilities from these folks,” Velosa said. + +### Cloud providers as IoT partners + +The idea is automated analytics for service and reliability data, manufacturing and a host of other operational functions. And while the full realization of that type of service is still very much a work in progress, it has clear-cut advantages for big companies – a skilled partner handling tricky implementation work, built-in capability for sophisticated analytics and security, and, of course, the ability to scale up in a big way. + +Hence, the structure of the biggest public clouds has upside for many large-scale IoT deployments, not just the ones taking place in the auto industry. The cloud giants have vast infrastructures, with multiple points of presence all over the world. + +To continue reading this article register now + +[Get Free Access][7] + +[Learn More][8] Existing Users [Sign In][7] + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3395137/top-auto-makers-rely-on-cloud-providers-for-iot.html + +作者:[Jon Gold][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[2]: https://www.networkworld.com/article/3324043/aws-does-hybrid-cloud-with-on-prem-hardware-vmware-help.html +[3]: https://www.networkworld.com/article/3388218/cisco-google-reenergize-multicloudhybrid-cloud-joint-development.html +[4]: https://www.networkworld.com/article/3385078/microsoft-introduces-azure-stack-for-hci.html +[5]: https://www.networkworld.com/article/3249495/what-hybrid-cloud-mean-practice +[6]: https://www.networkworld.com/newsletters/signup.html +[7]: javascript:// +[8]: /learn-about-insider/ diff --git a/sources/talk/20190514 Mobility and SD-WAN, Part 1- SD-WAN with 4G LTE is a Reality.md b/sources/talk/20190514 Mobility and SD-WAN, Part 1- SD-WAN with 4G LTE is a Reality.md new file mode 100644 index 0000000000..1ecd68fa41 --- /dev/null +++ b/sources/talk/20190514 Mobility and SD-WAN, Part 1- SD-WAN with 4G LTE is a Reality.md @@ -0,0 +1,64 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Mobility and SD-WAN, Part 1: SD-WAN with 4G LTE is a Reality) +[#]: via: (https://www.networkworld.com/article/3394866/mobility-and-sd-wan-part-1-sd-wan-with-4g-lte-is-a-reality.html) +[#]: author: (Francisca Segovia ) + +Mobility and SD-WAN, Part 1: SD-WAN with 4G LTE is a Reality +====== + +![istock][1] + +Without a doubt, 5G — the fifth generation of mobile wireless technology — is the hottest topic in wireless circles today. You can’t throw a stone without hitting 5G news. While telecommunications providers are in a heated competition to roll out 5G, it’s important to reflect on current 4G LTE (Long Term Evolution) business solutions as a preview of what we have learned and what’s possible. + +This is part one of a two-part blog series that will explore the [SD-WAN][2] journey through the evolution of these wireless technologies. + +### **Mobile SD-WAN is a reality** + +4G LTE commercialization continues to expand. According to [the GSM (Groupe Spéciale Mobile) Association][3], 710 operators have rolled out 4G LTE in 217 countries, reaching 83 percent of the world’s population. The evolution of 4G is transforming the mobile industry and is setting the stage for the advent of 5G. + +Mobile connectivity is increasingly integrated with SD-WAN, along with MPLS and broadband WAN services today. 4G LTE represents a very attractive transport alternative, as a backup or even an active member of the WAN transport mix to connect users to critical business applications. And in some cases, 4G LTE might be the only choice in locations where fixed lines aren’t available or reachable. Furthermore, an SD-WAN can optimize 4G LTE connectivity and bring new levels of performance and availability to mobile-based business use cases by selecting the best path available across several 4G LTE connections. + +### **Increasing application performance and availability with 4G LTE** + +Silver Peak has partnered with [BEC Technologies][4] to create a joint solution that enables customers to incorporate one or more low-cost 4G LTE services into any [Unity EdgeConnect™][5] SD-WAN edge platform deployment. All the capabilities of the EdgeConnect platform are supported across LTE links including packet-based link bonding, dynamic path control, path conditioning along with the optional [Unity Boost™ WAN Optimization][6] performance pack. This ensures always-consistent, always-available application performance even in the event of an outage or degraded service. + +EdgeConnect also incorporates sophisticated NAT traversal technology that eliminates the requirement for provisioning the LTE service with extra-cost static IP addresses. The Silver Peak [Unity Orchestrator™][7] management software enables the prioritization of LTE bandwidth usage based on branch and application requirements – active-active or backup-only. This solution is ideal in retail point-of-sale and other deployment use cases where always-available WAN connectivity is critical for the business. + +### **Automated SD-WAN enables innovative services** + +An example of an innovative mobile SD-WAN service is [swyMed’s DOT Telemedicine Backpack][8] powered by the EdgeConnect [Ultra Small][9] hardware platform. This integrated telemedicine solution enables first responders to connect to doctors and communicate patient vital statistics and real-time video anywhere, any time, greatly improving and expediting care for emergency patients. Using a lifesaving backpack provisioned with two LTE services from different carriers, EdgeConnect continuously monitors the underlying 4G LTE services for packet loss, latency and jitter. In the case of transport failure or brownout, EdgeConnect automatically initiates a sub-second failover so that voice, video and data connections continue without interruption over the remaining active 4G service. By bonding the two LTE links together with the EdgeConnect SD-WAN, swyMed can achieve an aggregate signal quality in excess of 90 percent, bringing mobile telemedicine to areas that would have been impossible in the past due to poor signal strength. + +To learn more about SD-WAN and the unique advantages that SD-WAN provides to enterprises across all industries, visit the [SD-WAN Explained][2] page on our website. + +### **Prepare for the 5G future** + +In summary, the adoption of 4G LTE is a reality. Service providers are taking advantage of the distinct benefits of SD-WAN to offer managed SD-WAN services that leverage 4G LTE. + +As the race for the 5G gains momentum, service providers are sure to look for ways to drive new revenue streams to capitalize on their initial investments. Stay tuned for part 2 of this 2-blog series where I will discuss how SD-WAN is one of the technologies that can help service providers to transition from 4G to 5G and enable the monetization of a new wave of managed 5G services. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3394866/mobility-and-sd-wan-part-1-sd-wan-with-4g-lte-is-a-reality.html + +作者:[Francisca Segovia][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/05/istock-952414660-100796279-large.jpg +[2]: https://www.silver-peak.com/sd-wan/sd-wan-explained +[3]: https://www.gsma.com/futurenetworks/resources/all-ip-statistics/ +[4]: https://www.silver-peak.com/resource-center/edgeconnect-4glte-solution-bec-technologies +[5]: https://www.silver-peak.com/products/unity-edge-connect +[6]: https://www.silver-peak.com/products/unity-boost +[7]: https://www.silver-peak.com/products/unity-orchestrator +[8]: https://www.silver-peak.com/resource-center/mobile-telemedicine-helps-save-lives-streaming-real-time-clinical-data-and-patient +[9]: https://www.silver-peak.com/resource-center/edgeconnect-us-ec-us-specification-sheet diff --git a/sources/talk/20190515 Extreme addresses networked-IoT security.md b/sources/talk/20190515 Extreme addresses networked-IoT security.md new file mode 100644 index 0000000000..1ad756eded --- /dev/null +++ b/sources/talk/20190515 Extreme addresses networked-IoT security.md @@ -0,0 +1,71 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Extreme addresses networked-IoT security) +[#]: via: (https://www.networkworld.com/article/3395539/extreme-addresses-networked-iot-security.html) +[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) + +Extreme addresses networked-IoT security +====== +The ExtremeAI security app features machine learning that can understand typical behavior of IoT devices and alert when it finds anomalies. +![Getty Images][1] + +[Extreme Networks][2] has taken the wraps off a new security application it says will use machine learning and artificial intelligence to help customers effectively monitor, detect and automatically remediate security issues with networked IoT devices. + +The application – ExtremeAI security—features machine-learning technology that can understand typical behavior of IoT devices and automatically trigger alerts when endpoints act in unusual or unexpected ways, Extreme said. + +**More about edge networking** + + * [How edge networking and IoT will reshape data centers][3] + * [Edge computing best practices][4] + * [How edge computing can help secure the IoT][5] + + + +Extreme said that the ExtremeAI Security application can tie into all leading threat intelligence feeds, and had close integration with its existing [Extreme Workflow Composer][6] to enable automatic threat mitigation and remediation. + +The application integrates the company’s ExtremeAnalytics application which lets customers view threats by severity, category, high-risk endpoints and geography. An automated ticketing feature integrates with variety of popular IT tools such as Slack, Jira, and ServiceNow, and the application interoperates with many popular security tools, including existing network taps, the vendor stated. + +There has been an explosion of new endpoints ranging from million-dollar smart MRI machines to five-dollar sensors, which creates a complex and difficult job for network and security administrators, said Abby Strong, vice president of product marketing for Extreme. “We need smarter, secure and more self-healing networks especially where IT cybersecurity resources are stretched to the limit.” + +Extreme is trying to address an issue that is important to enterprise-networking customers: how to get actionable, usable insights as close to real-time as possible, said Rohit Mehra, Vice President of Network Infrastructure at IDC. “Extreme is melding automation, analytics and security that can look at network traffic patterns and allow the system to take action when needed.” + +The ExtremeAI application, which will be available in October, is but one layer of IoT security Extreme offers. Already on the market, its [Defender for IoT][7] package, which includes a Defender application and adapter, lets customers monitor, set policies and isolate IoT devices across an enterprise. + +**[[Prepare to become a Certified Information Security Systems Professional with this comprehensive online course from PluralSight. Now offering a 10-day free trial!][8] ]** + +The Extreme AI and Defender packages are now part of what the company calls Extreme Elements, which is a menu of its new and existing Smart OmniEdge, Automated Campus and Agile Data Center software, hardware and services that customers can order to build a manageable, secure system. + +Aside from the applications, the Elements include Extreme Management Center, the company’s network management software; the company’s x86-based intelligent appliances, including the ExtremeCloud Appliance; and [ExtremeSwitching X465 premium][9], a stackable multi-rate gigabit Ethernet switch. + +The switch and applications are just the beginning of a very busy time for Extreme. In its [3Q earnings cal][10]l this month company CEO Ed Meyercord noted Extreme was in the “early stages of refreshing 70 percent of our products” and seven different products will become generally available this quarter – a record for Extreme, he said. + +Join the Network World communities on [Facebook][11] and [LinkedIn][12] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3395539/extreme-addresses-networked-iot-security.html + +作者:[Michael Cooney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Michael-Cooney/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/iot_security_tablet_conference_digital-100787102-large.jpg +[2]: https://www.networkworld.com/article/3289508/extreme-facing-challenges-girds-for-future-networking-battles.html +[3]: https://www.networkworld.com/article/3291790/data-center/how-edge-networking-and-iot-will-reshape-data-centers.html +[4]: https://www.networkworld.com/article/3331978/lan-wan/edge-computing-best-practices.html +[5]: https://www.networkworld.com/article/3331905/internet-of-things/how-edge-computing-can-help-secure-the-iot.html +[6]: https://www.extremenetworks.com/product/workflow-composer/ +[7]: https://www.extremenetworks.com/product/extreme-defender-for-iot/ +[8]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr +[9]: https://community.extremenetworks.com/extremeswitching-exos-223284/extremexos-30-2-and-smart-omniedge-premium-x465-switches-are-now-available-7823377 +[10]: https://seekingalpha.com/news/3457137-extreme-networks-minus-15-percent-quarterly-miss-light-guidance +[11]: https://www.facebook.com/NetworkWorld/ +[12]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190516 Will 5G be the first carbon-neutral network.md b/sources/talk/20190516 Will 5G be the first carbon-neutral network.md new file mode 100644 index 0000000000..decacfac5d --- /dev/null +++ b/sources/talk/20190516 Will 5G be the first carbon-neutral network.md @@ -0,0 +1,88 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Will 5G be the first carbon-neutral network?) +[#]: via: (https://www.networkworld.com/article/3395465/will-5g-be-the-first-carbon-neutral-network.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +Will 5G be the first carbon-neutral network? +====== +Increased energy consumption in new wireless networks could become ecologically unsustainable. Engineers think they have solutions that apply to 5G, but all is not certain. +![Dushesina/Getty Images][1] + +If wireless networks transfer 1,000 times more data, does that mean they will use 1,000 times more energy? It probably would with the old 4G LTE wireless technologies— LTE doesn’t have much of a sleep-standby. But with 5G, we might have a more energy-efficient option. + +More customers want Earth-friendly options, and engineers are now working on how to achieve it — meaning 5G might introduce the first zero-carbon networks. It’s not all certain, though. + +**[ Related:[What is 5G wireless? And how it will change networking as we know it][2] ]** + +“When the 4G technology for wireless communication was developed, not many people thought about how much energy is consumed in transmitting bits of information,” says Emil Björnson, associate professor of communication systems at Linkoping University, [in an article on the school’s website][3]. + +Standby was never built into 4G, Björnson explains. Reasons include overbuilding — the architects wanted to ensure connections didn’t fail, so they just kept the power up. The downside to that redundancy was that almost the same amount of energy is used whether the system is transmitting data or not. + +“We now know that this is not necessary,” Björnson says. 5G networks don’t use much power during periods of low traffic, and that reduces power consumption. + +Björnson says he knows how to make future-networks — those 5G networks that one day may become the enterprise broadband replacement — super efficient even when there is heavy use. Massive-MIMO (multiple-in, multiple-out) antennas are the answer, he says. That’s hundreds of connected antennas taking advantage of multipath. + +I’ve written before about some of Björnson's Massive-MIMO ideas. He thinks [Massive-MIMO will remove all capacity ceilings from wireless networks][4]. However, he now adds calculations to his research that he claims prove that the Massive-MIMO antenna technology will also reduce power use. He and his group are actively promoting their academic theories in a paper ([pdf][5]). + +**[[Take this mobile device management course from PluralSight and learn how to secure devices in your company without degrading the user experience.][6] ]** + +### Nokia's plan to reduce wireless networks' CO2 emissions + +Björnson's isn’t the only 5G-aimed eco-concept out there. Nokia points out that it isn't just radios transmitting that use electricity. Cooling is actually the main electricity hog, says the telcommunications company, which is one of the world’s principal manufacturers of mobile network equipment. + +Nokia says the global energy cost of Radio Access Networks (RANs) in 2016 (the last year numbers were available), which includes base transceiver stations (BTSs) needed by mobile networks, was around $80 billion. That figure increases with more users coming on stream, something that’s probable. Of the BTS’s electricity use, about 90% “converts to waste heat,” [Harry Kuosa, a marketing executive, writes on Nokia’s blog][7]. And base station sites account for about 80% of a mobile network’s entire energy use, Nokia expands on its website. + +“A thousand-times more traffic that creates a thousand-times higher energy costs is unsustainable,” Nokia says in its [ebook][8] on the subject, “Turning the zero carbon vision into business opportunity,” and it’s why Nokia plans liquid-cooled 5G base stations among other things, including chip improvements. It says the liquid-cooling can reduce CO2 emissions by up to 80%. + +### Will those ideas work? + +Not all agree power consumption can be reduced when implementing 5G, though. Gabriel Brown of Heavy Reading, quotes [in a tweet][9] a China Mobile executive as saying that 5G BTSs will use three times as much power as 4G LTE ones because the higher frequencies used in 5G mean one needs more BTS units to provide the same geographic coverage: For physics reasons, higher frequencies equals shorter range. + +If, as is projected, 5G develops into the new enterprise broadband for the internet of things (IoT), along with associated private networks covering everything else, then these eco- and cost-important questions are going to be salient — and they need answers quickly. 5G will soon be here, and [Gartner estimates that 60% of organizations will adopt it][10]. + +**More about 5G networks:** + + * [How enterprises can prep for 5G networks][11] + * [5G vs 4G: How speed, latency and apps support differ][12] + * [Private 5G networks are coming][13] + * [5G and 6G wireless have security issues][14] + * [How millimeter-wave wireless could help support 5G and IoT][15] + + + +Join the Network World communities on [Facebook][16] and [LinkedIn][17] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3395465/will-5g-be-the-first-carbon-neutral-network.html + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/01/4g-versus-5g_horizon_sunrise-100784230-large.jpg +[2]: https://www.networkworld.com/article/3203489/lan-wan/what-is-5g-wireless-networking-benefits-standards-availability-versus-lte.html +[3]: https://liu.se/en/news-item/okningen-av-mobildata-kraver-energieffektivare-nat +[4]: https://www.networkworld.com/article/3262991/future-wireless-networks-will-have-no-capacity-limits.html +[5]: https://arxiv.org/pdf/1812.01688.pdf +[6]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fcourses%2Fmobile-device-management-big-picture +[7]: https://www.nokia.com/blog/nokia-has-ambitious-plans-reduce-network-power-consumption/ +[8]: https://pages.nokia.com/2364.Zero.Emissions.ebook.html?did=d000000001af&utm_campaign=5g_in_action_&utm_source=twitter&utm_medium=organic&utm_term=0dbf430c-1c94-47d7-8961-edc4f0ba3270 +[9]: https://twitter.com/Gabeuk/status/1099709788676636672?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E1099709788676636672&ref_url=https%3A%2F%2Fwww.lightreading.com%2Fmobile%2F5g%2Fpower-consumption-5g-basestations-are-hungry-hungry-hippos%2Fd%2Fd-id%2F749979 +[10]: https://www.gartner.com/en/newsroom/press-releases/2018-12-18-gartner-survey-reveals-two-thirds-of-organizations-in +[11]: https://www.networkworld.com/article/3306720/mobile-wireless/how-enterprises-can-prep-for-5g.html +[12]: https://www.networkworld.com/article/3330603/mobile-wireless/5g-versus-4g-how-speed-latency-and-application-support-differ.html +[13]: https://www.networkworld.com/article/3319176/mobile-wireless/private-5g-networks-are-coming.html +[14]: https://www.networkworld.com/article/3315626/network-security/5g-and-6g-wireless-technologies-have-security-issues.html +[15]: https://www.networkworld.com/article/3291323/mobile-wireless/millimeter-wave-wireless-could-help-support-5g-and-iot.html +[16]: https://www.facebook.com/NetworkWorld/ +[17]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190517 The modern data center and the rise in open-source IP routing suites.md b/sources/talk/20190517 The modern data center and the rise in open-source IP routing suites.md new file mode 100644 index 0000000000..02063687a0 --- /dev/null +++ b/sources/talk/20190517 The modern data center and the rise in open-source IP routing suites.md @@ -0,0 +1,140 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The modern data center and the rise in open-source IP routing suites) +[#]: via: (https://www.networkworld.com/article/3396136/the-modern-data-center-and-the-rise-in-open-source-ip-routing-suites.html) +[#]: author: (Matt Conran https://www.networkworld.com/author/Matt-Conran/) + +The modern data center and the rise in open-source IP routing suites +====== +Open source enables passionate people to come together and fabricate work of phenomenal quality. This is in contrast to a single vendor doing everything. +![fdecomite \(CC BY 2.0\)][1] + +As the cloud service providers and search engines started with the structuring process of their business, they quickly ran into the problems of managing the networking equipment. Ultimately, after a few rounds of getting the network vendors to understand their problems, these hyperscale network operators revolted. + +Primarily, what the operators were looking for was a level of control in managing their network which the network vendors couldn’t offer. The revolution burned the path that introduced open networking, and network disaggregation to the work of networking. Let us first learn about disaggregation followed by open networking. + +### Disaggregation + +The concept of network disaggregation involves breaking-up of the vertical networking landscape into individual pieces, where each piece can be used in the best way possible. The hardware can be separated from the software, along with open or closed IP routing suites. This enables the network operators to use the best of breed for the hardware, software and the applications. + +**[ Now see[7 free network tools you must have][2]. ]** + +Networking has always been built as an appliance and not as a platform. The mindset is that the network vendor builds an appliance and as a specialized appliance, they will completely control what you can and cannot do on that box. In plain words, they will not enable anything that is not theirs. As a result, they act as gatekeepers and not gate-enablers. + +Network disaggregation empowers the network operators with the ability to lay hands on the features they need when they need them. However, this is impossible in case of non-disaggregated hardware. + +### Disaggregation leads to using best-of-breed + +In the traditional vertically integrated networking market, you’re forced to live with the software because you like the hardware, or vice-versa. But network disaggregation drives different people to develop things that matter to them. This allows multiple groups of people to connect, with each one focused on doing what he or she does the best. Switching silicon manufacturers can provide the best merchant silicon. Routing suites can be provided by those who are the best at that. And the OS vendors can provide the glue that enables all of these to work well together. + +With disaggregation, people are driven to do what they are good at. One company does the hardware, whereas another does the software and other company does the IP routing suites. Hence, today the networking world looks like more of the server world. + +### Open source + +Within this rise of the modern data center, there is another element that is driving network disaggregation; the notion of open source. Open source is “denoting software for which the original source code is made freely available, it may be redistributed and modified.” It enables passionate people to come together and fabricate work of phenomenal quality. This is in contrast to a single vendor doing everything. + +As a matter of fact, the networking world has always been very vendor driven. However, the advent of open source gives the opportunity to like-minded people rather than the vendor controlling the features. This eliminates the element of vendor lock-in, thereby enabling interesting work. Open source allows more than one company to be involved. + +### Open source in the data center + +The traditional enterprise and data center networks were primarily designed by bridging and Spanning Tree Protocol (STP). However, the modern data center is driven by IP routing and the CLOS topology. As a result, you need a strong IP routing suite. + +That was the point where the need for an open-source routing suite surfaced, the suite that can help drive the modern data center. The primary open-source routing suites are [FRRouting (FRR)][3], BIRD, GoBGP and ExaBGP. + +Open-source IP routing protocol suites are slowly but steadily gaining acceptance and are used in data centers of various sizes. Why? It is because they allow a community of developers and users to work on finding solutions to common problems. Open-source IP routing protocol suites equip them to develop the specific features that they need. It also helps the network operators to create simple designs that make sense to them, as opposed to having everything controlled by the vendor. They also enable routing suites to run on compute nodes. Kubernetes among others uses this model of running a routing protocol on a compute node. + +Today many startups are using FRR. Out of all of the IP routing suites, FRR is preferred in the data center as the primary open-source IP routing protocol suite. Some traditional network vendors have even demonstrated the use of FRR on their networking gear. + +There are lots of new features currently being developed for FRR, not just by the developers but also by the network operators. + +### Use cases for open-source routing suites + +When it comes to use-cases, where do IP routing protocol suites sit? First and foremost, if you want to do any type of routing in the disaggregated network world, you need an IP routing suite. + +Some operators are using FRR at the edge of the network as well, thereby receiving full BGP feeds. Many solutions which use Intel’s DPDK for packet forwarding use FRR as the control plane, receiving full BGP feeds. In addition, there are other vendors using FRR as the core IP routing suite for a full leaf and spine data center architecture. You can even get a version of FRR on pfSense which is a free and open source firewall. + +We need to keep in mind that reference implementations are important. Open source allows you to test at scale. But vendors don’t allow you to do that. However, with FRR, we have the ability to spin up virtual machines (VMs) or even containers by using software like Vagrant to test your network. Some vendors do offer software versions, but they are not fully feature-compatible. + +Also, with open source you do not need to wait. This empowers you with flexibility and speed which drives the modern data center. + +### Deep dive on FRRouting (FRR) + +FRR is a Linux foundation project. In a technical Linux sense, FRR is a group of daemons that work together, providing a complete routing suite that includes BGP, IS-IS, LDP, OSPF, BFD, PIM, and RIP. + +Each one of these daemons communicate with the common routing information base (RIB) daemon called Zebra in order to interface with the OS and to resolve conflicts between the multiple routing protocols providing the same information. Interfacing with the OS is used to receive the link up/down events, to add and delete routes etc. + +### FRRouting (FRR) components: Zebra + +Zebra is the RIB of the routing systems. It knows everything about the state of the system relevant to routing and is able to pass and disseminate this information to all the interested parties. + +The RIB in FRR acts just like a traditional RIB. When a route wins, it goes into the Linux kernel data plane where the forwarding occurs. All of the routing protocols run as separate processes and each of them have their source code in FRR. + +For example, when BGP starts up, it needs to know, for instance, what kind of virtual routing and forwarding (VRF) and IP interfaces are available. Zebra collects and passes this information back to the interested daemons. It passes all the relevant information about state of the machine. + +Furthermore, you can also register information with Zebra. For example, if a particular route changes, the daemon can be informed. This can also be used for reverse path forwarding (RPF). FRR doesn't need to do a pull when changes happen on the network. + +There are a myriad of ways through which you can control Linux and the state. Sometimes you have to use options like the Netlink bus and sometimes you may need to read the state in proc file system of Linux. The goal of Zebra is to gather all this data for the upper level protocols. + +### FRR supports remote data planes + +FRR also has the ability to manage the remote data planes. So, what does this mean? Typically, the data forwarding plane and the routing protocols run on the same box. Another model, adopted by Openflow and SDN for example, is one in which the data forwarding plane can be on one box while FRR runs on a different box on behalf of the first box and pushes the computed routing state on the first box. In other words, the data plane and the control plane run on different boxes. + +If you examine the traditional world, it’s like having one large chassis with different line cards with the ability to install routes in those different line cards. FRR operates with the same model which has one control plane and the capability to offer 3 boxes, if needed. It does this via the forwarding plane manager. + +### Forwarding plane manager + +Zebra can either install routes directly into the data plane of the box it is running on or use a forwarding plane manager to install routes on a remote box. When it installs a route, the forwarding plane manager abstracts the data which displays the route and the next hops. It then pushes the data to a remote system where the remote machine processes it and programs the ASIC appropriately. + +After the data is abstracted, you can use whatever protocol you want in order to push the data to the remote machine. You can even include the data in an email. + +### What is holding people back from open source? + +Since last 30 years the networking world meant that you need to go to a vendor to solve a problem. But now with open-source routing suites, such as, FRR, there is a major drift in the mindset as to how you approach troubleshooting. + +This causes the fear of not being able to use it properly because with open source you are the one who has to fix it. This at first can be scary and daunting. But it doesn’t necessarily have to be. Also, to switch to FRR on a traditional network gear, you need the vendor to enable it, but they may be reluctant as they are on competing platforms which can be another road blocker. + +### The future of FRR + +If we examine FRR from the use case perspective of the data center, FRR is feature-complete. Anyone building an IP based data center FRR has everything available. The latest 7.0 release of FRR adds Yang/NetConf, BGP Enhancements and OpenFabric. + +FRR is not just about providing features, boosting the performance or being the same as or better than the traditional network vendor’s software, it is also about simplifying the process for the end user. + +Since the modern data center is focused on automation and ease of use, FRR has made such progress that the vendors have not caught up with. FRR is very automation friendly. For example, FRR takes BGP and makes it automation-friendly without having to change the protocol. It supports BGP unnumbered that is unmatched by any other vendor suite. This is where the vendors are trying to catch up. + +Also, while troubleshooting, FRR shows peer’s and host’s names and not just the IP addresses. This allows you to understand without having spent much time. However, vendors show the peer’s IP addresses which can be daunting when you need to troubleshoot. + +FRR provides the features that you need to run an efficient network and data center. It makes easier to configure and manage the IP routing suite. Vendors just add keep adding features over features whether they are significant or not. Then you need to travel the certification paths that teach you how to twiddle 20 million nobs. How many of those networks are robust and stable? + +FRR is about supporting features that matter and not every imaginable feature. FRR is an open source project that brings like-minded people together, good work that is offered isn’t turned away. As a case in point, FRR has an open source implementation of EIGRP. + +The problem surfaces when you see a bunch of things, you think you need them. But in reality, you should try to keep the network as simple as possible. FRR is laser-focused on the ease of use and simplifying the use rather than implementing features that are mostly not needed to drive the modern data center. + +For more information and to contribute, why not join the [FRR][4] [mailing list group][4]. + +**This article is published as part of the IDG Contributor Network.[Want to Join?][5]** + +Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3396136/the-modern-data-center-and-the-rise-in-open-source-ip-routing-suites.html + +作者:[Matt Conran][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Matt-Conran/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/12/modular_humanoid_polyhedra_connections_structure_building_networking_by_fdecomite_cc_by_2-0_via_flickr_1200x800-100782334-large.jpg +[2]: https://www.networkworld.com/article/2825879/7-free-open-source-network-monitoring-tools.html +[3]: https://frrouting.org/community/7.0-launch.html +[4]: https://frrouting.org/#participate +[5]: /contributor-network/signup.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190521 Enterprise IoT- Companies want solutions in these 4 areas.md b/sources/talk/20190521 Enterprise IoT- Companies want solutions in these 4 areas.md new file mode 100644 index 0000000000..9df4495f05 --- /dev/null +++ b/sources/talk/20190521 Enterprise IoT- Companies want solutions in these 4 areas.md @@ -0,0 +1,119 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Enterprise IoT: Companies want solutions in these 4 areas) +[#]: via: (https://www.networkworld.com/article/3396128/the-state-of-enterprise-iot-companies-want-solutions-for-these-4-areas.html) +[#]: author: (Fredric Paul https://www.networkworld.com/author/Fredric-Paul/) + +Enterprise IoT: Companies want solutions in these 4 areas +====== +Based on customer pain points, PwC identified four areas companies are seeking enterprise solutions for, including energy use and sustainability. +![Jackie Niam / Getty Images][1] + +Internet of things (IoT) vendors and pundits like to crow about the billions and billions of connected devices that make the IoT so ubiquitous and powerful. But how much of that installed base is really relevant to the enterprise? + +To find out, I traded emails with Rob Mesirow, principal at [PwC’s Connected Solutions][2], the firm’s new one-stop-shop of IoT solutions, who suggests that consumer adoption may not paint a true picture of the enterprise opportunities. If you remove the health trackers and the smart thermostats from the market, he suggested, there are very few connected devices left. + +So, I wondered, what is actually happening on the enterprise side of IoT? What kinds of devices are we talking about, and in what kinds of numbers? + +**[ Read also:[Forget 'smart homes,' the new goal is 'autonomous buildings'][3] ]** + +“When people talk about the IoT,” Mesirow told me, “they usually focus on [consumer devices, which far outnumber business devices][4]. Yet [connected buildings currently represent only 12% of global IoT projects][5],” he noted, “and that’s without including wearables and smart home projects.” (Mesirow is talking about buildings that “use various IoT devices, including occupancy sensors that determine when people are present in a room in order to keep lighting and temperature controls at optimal levels, lowering energy costs and aiding sustainability goals. Sensors can also detect water and gas leaks and aid in predictive maintenance for HVAC systems.”) + +### 4 key enterprise IoT opportunities + +More specifically, based on customer pain points, PwC’s Connected Solutions is focusing on a few key opportunities, which Mesirow laid out in a [blog post][6] earlier this year. (Not surprisingly, the opportunities seem tied to [the group’s products][7].) + +“A lot of these solutions came directly from our customers’ request,” he noted. “We pre-qualify our solutions with customers before we build them.” + +Let’s take a look at the top four areas, along with a quick reality check on how important they are and whether the technology is ready for prime time. + +#### **1\. Energy use and sustainability** + +The IoT makes it possible to manage buildings and spaces more efficiently, with savings of 25% or more. Occupancy sensors can tell whether anyone is actually in a room, adjusting lighting and temperature to saving money and conserve energy. + +Connected buildings can also help determine when meeting spaces are available, which can boost occupancy at large businesses and universities by 40% while cutting infrastructure and maintenance costs. Other sensors, meanwhile, can detect water and gas leaks and aid in predictive maintenance for HVAC systems. + +**Reality check:** Obviously, much of this technology is not new, but there’s a real opportunity to make it work better by integrating disparate systems and adding better analytics to the data to make planning more effective. + +#### **2. Asset tracking + +** + +“Businesses can also use the IoT to track their assets,“ Mesirow told me, “which can range from trucks to hotel luggage carts to medical equipment. It can even assist with monitoring trash by alerting appropriate people when dumpsters need to be emptied.” + +Asset trackers can instantly identify the location of all kinds of equipment (saving employee time and productivity), and they can reduce the number of lost, stolen, and misplaced devices and machines as well as provide complete visibility into the location of your assets. + +Such trackers can also save employees from wasting time hunting down the devices and machines they need. For example, PwC noted that during an average hospital shift, more than one-third of nurses spend at least an hour looking for equipment such as blood pressure monitors and insulin pumps. Just as important, location tracking often improves asset optimization, reduced inventory needs, and improved customer experience. + +**Reality check:** Asset tracking offers clear value. The real question is whether a given use case is cost effective or not, as well as how the data gathered will actually be used. Too often, companies spend a lot of money and effort tracking their assets, but don’t do much with the information. + +#### **3\. Security and compliance** + +Connected solutions can create better working environments, Mesirow said. “In a hotel, for example, these smart devices can ensure that air and water quality is up to standards, provide automated pest traps, monitor dumpsters and recycling bins, detect trespassers, determine when someone needs assistance, or discover activity in an unauthorized area. Monitoring the water quality of hotel swimming pools can lower chemical and filtering costs,” he said. + +Mesirow cited an innovative use case where, in response to workers’ complaints about harassment, hotel operators—in conjunction with the [American Hotel and Lodging Association][8]—are giving their employees portable devices that alert security staff when workers request assistance. + +**Reality check:** This seems useful, but the ROI might be difficult to calculate. + +#### **4\. Customer experience** + +According to PwC, “Sensors, facial recognition, analytics, dashboards, and notifications can elevate and even transform the customer experience. … Using connected solutions, you can identify and reward your best customers by offering perks, reduced wait times, and/or shorter lines.” + +Those kinds of personalized customer experiences can potentially boost customer loyalty and increase revenue, Mesirow said, adding that the technology can also make staff deployments more efficient and “enhance safety by identifying trespassers and criminals who are tampering with company property.” + +**Reality check:** Creating a great customer experience is critical for businesses today, and this kind of personalized targeting promises to make it more efficient and effective. However, it has to be done in a way that makes customers comfortable and not creeped out. Privacy concerns are very real, especially when it comes to working with facial recognition and other kinds of surveillance technology. For example, [San Francisco recently banned city agencies from using facial recognition][9], and others may follow. + +**More on IoT:** + + * [What is the IoT? How the internet of things works][10] + * [What is edge computing and how it’s changing the network][11] + * [Most powerful Internet of Things companies][12] + * [10 Hot IoT startups to watch][13] + * [The 6 ways to make money in IoT][14] + * [What is digital twin technology? [and why it matters]][15] + * [Blockchain, service-centric networking key to IoT success][16] + * [Getting grounded in IoT networking and security][17] + * [Building IoT-ready networks must become a priority][18] + * [What is the Industrial IoT? [And why the stakes are so high]][19] + + + +Join the Network World communities on [Facebook][20] and [LinkedIn][21] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3396128/the-state-of-enterprise-iot-companies-want-solutions-for-these-4-areas.html + +作者:[Fredric Paul][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Fredric-Paul/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/iot_internet_of_things_by_jackie_niam_gettyimages-996958260_2400x1600-100788446-large.jpg +[2]: https://digital.pwc.com/content/pwc-digital/en/products/connected-solutions.html#get-connected +[3]: https://www.networkworld.com/article/3309420/forget-smart-homes-the-new-goal-is-autonomous-buildings.html +[4]: https://www.statista.com/statistics/370350/internet-of-things-installed-base-by-category/) +[5]: https://iot-analytics.com/top-10-iot-segments-2018-real-iot-projects/ +[6]: https://www.digitalpulse.pwc.com.au/five-unexpected-ways-internet-of-things/ +[7]: https://digital.pwc.com/content/pwc-digital/en/products/connected-solutions.html +[8]: https://www.ahla.com/ +[9]: https://www.nytimes.com/2019/05/14/us/facial-recognition-ban-san-francisco.html +[10]: https://www.networkworld.com/article/3207535/internet-of-things/what-is-the-iot-how-the-internet-of-things-works.html +[11]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[12]: https://www.networkworld.com/article/2287045/internet-of-things/wireless-153629-10-most-powerful-internet-of-things-companies.html +[13]: https://www.networkworld.com/article/3270961/internet-of-things/10-hot-iot-startups-to-watch.html +[14]: https://www.networkworld.com/article/3279346/internet-of-things/the-6-ways-to-make-money-in-iot.html +[15]: https://www.networkworld.com/article/3280225/internet-of-things/what-is-digital-twin-technology-and-why-it-matters.html +[16]: https://www.networkworld.com/article/3276313/internet-of-things/blockchain-service-centric-networking-key-to-iot-success.html +[17]: https://www.networkworld.com/article/3269736/internet-of-things/getting-grounded-in-iot-networking-and-security.html +[18]: https://www.networkworld.com/article/3276304/internet-of-things/building-iot-ready-networks-must-become-a-priority.html +[19]: https://www.networkworld.com/article/3243928/internet-of-things/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html +[20]: https://www.facebook.com/NetworkWorld/ +[21]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190522 Experts- Enterprise IoT enters the mass-adoption phase.md b/sources/talk/20190522 Experts- Enterprise IoT enters the mass-adoption phase.md new file mode 100644 index 0000000000..86d7bf0efe --- /dev/null +++ b/sources/talk/20190522 Experts- Enterprise IoT enters the mass-adoption phase.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Experts: Enterprise IoT enters the mass-adoption phase) +[#]: via: (https://www.networkworld.com/article/3397317/experts-enterprise-iot-enters-the-mass-adoption-phase.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +Experts: Enterprise IoT enters the mass-adoption phase +====== +Dropping hardware prices, 5G boost business internet-of-things deployments; technical complexity encourages partnerships. +![Avgust01 / Getty Images][1] + +[IoT][2] in general has taken off quickly over the past few years, but experts at the recent IoT World highlighted that the enterprise part of the market has been particularly robust of late – it’s not just an explosion of connected home gadgets anymore. + +Donna Moore, chairwoman of the LoRa Alliance, an industry group that works to develop and scale low-power WAN technology for mass usage, said on a panel that she’s never seen growth this fast in the sector. “I’d say we’re now in the early mass adopters [stage],” she said. + +**More on IoT:** + + * [Most powerful Internet of Things companies][3] + * [10 Hot IoT startups to watch][4] + * [The 6 ways to make money in IoT][5] + * [What is digital twin technology? [and why it matters]][6] + * [Blockchain, service-centric networking key to IoT success][7] + * [Getting grounded in IoT networking and security][8] + * [Building IoT-ready networks must become a priority][9] + * [What is the Industrial IoT? [And why the stakes are so high]][10] + + + +The technology itself has pushed adoption to these heights, said Graham Trickey, head of IoT for the GSMA, a trade organization for mobile network operators. Along with price drops for wireless connectivity modules, the array of upcoming technologies nestling under the umbrella label of [5G][11] could simplify the process of connecting devices to [edge-computing][12] hardware – and the edge to the cloud or [data center][13]. + +“Mobile operators are not just providers of connectivity now, they’re farther up the stack,” he said. Technologies like narrow-band IoT and support for highly demanding applications like telehealth are all set to be part of the final 5G spec. + +### Partnerships needed to deal with IoT complexity** + +** + +That’s not to imply that there aren’t still huge tasks facing both companies trying to implement their own IoT frameworks and the creators of the technology underpinning them. For one thing, IoT tech requires a huge array of different sets of specialized knowledge. + +“That means partnerships, because you need an expert in your [vertical] area to know what you’re looking for, you need an expert in communications, and you might need a systems integrator,” said Trickey. + +Phil Beecher, the president and CEO of the Wi-SUN Alliance (the acronym stands for Smart Ubiquitous Networks, and the group is heavily focused on IoT for the utility sector), concurred with that, arguing that broad ecosystems of different technologies and different partners would be needed. “There’s no one technology that’s going to solve all these problems, no matter how much some parties might push it,” he said. + +One of the central problems – [IoT security][14] – is particularly dear to Beecher’s heart, given the consequences of successful hacks of the electrical grid or other utilities. More than one panelist praised the passage of the EU’s General Data Protection Regulation, saying that it offered concrete guidelines for entities developing IoT tech – a crucial consideration for some companies that may not have a lot of in-house expertise in that area. + +Join the Network World communities on [Facebook][15] and [LinkedIn][16] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3397317/experts-enterprise-iot-enters-the-mass-adoption-phase.html + +作者:[Jon Gold][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/iot_internet_of_things_mobile_connections_by_avgust01_gettyimages-1055659210_2400x1600-100788447-large.jpg +[2]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[3]: https://www.networkworld.com/article/2287045/internet-of-things/wireless-153629-10-most-powerful-internet-of-things-companies.html +[4]: https://www.networkworld.com/article/3270961/internet-of-things/10-hot-iot-startups-to-watch.html +[5]: https://www.networkworld.com/article/3279346/internet-of-things/the-6-ways-to-make-money-in-iot.html +[6]: https://www.networkworld.com/article/3280225/internet-of-things/what-is-digital-twin-technology-and-why-it-matters.html +[7]: https://www.networkworld.com/article/3276313/internet-of-things/blockchain-service-centric-networking-key-to-iot-success.html +[8]: https://www.networkworld.com/article/3269736/internet-of-things/getting-grounded-in-iot-networking-and-security.html +[9]: https://www.networkworld.com/article/3276304/internet-of-things/building-iot-ready-networks-must-become-a-priority.html +[10]: https://www.networkworld.com/article/3243928/internet-of-things/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html +[11]: https://www.networkworld.com/article/3203489/what-is-5g-how-is-it-better-than-4g.html +[12]: https://www.networkworld.com/article/3224893/what-is-edge-computing-and-how-it-s-changing-the-network.html?nsdr=true +[13]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[14]: https://www.networkworld.com/article/3269736/getting-grounded-in-iot-networking-and-security.html +[15]: https://www.facebook.com/NetworkWorld/ +[16]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190522 The Traffic Jam Whopper project may be the coolest-dumbest IoT idea ever.md b/sources/talk/20190522 The Traffic Jam Whopper project may be the coolest-dumbest IoT idea ever.md new file mode 100644 index 0000000000..be8a4833cc --- /dev/null +++ b/sources/talk/20190522 The Traffic Jam Whopper project may be the coolest-dumbest IoT idea ever.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The Traffic Jam Whopper project may be the coolest/dumbest IoT idea ever) +[#]: via: (https://www.networkworld.com/article/3396188/the-traffic-jam-whopper-project-may-be-the-coolestdumbest-iot-idea-ever.html) +[#]: author: (Fredric Paul https://www.networkworld.com/author/Fredric-Paul/) + +The Traffic Jam Whopper project may be the coolest/dumbest IoT idea ever +====== +Burger King uses real-time IoT data to deliver burgers to drivers stuck in traffic — and it seems to be working. +![Mike Mozart \(CC BY 2.0\)][1] + +People love to eat in their cars. That’s why we invented the drive-in and the drive-thru. + +But despite a fast-food outlet on the corner of every major intersection, it turns out we were only scratching the surface of this idea. Burger King is taking this concept to the next logical step with its new IoT-powered Traffic Jam Whopper project. + +I have to admit, when I first heard about this, I thought it was a joke, but apparently the [Traffic Jam Whopper project is totally real][2] and has already passed a month-long test in Mexico City. While the company hasn’t specified a timeline, it plans to roll out the Traffic Jam Whopper project in Los Angeles (where else?) and other traffic-plagued megacities such as São Paulo and Shanghai. + +**[ Also read:[Is IoT in the enterprise about making money or saving money?][3] | Get regularly scheduled insights: [Sign up for Network World newsletters][4] ]** + +### How Burger King's Traffic Jam Whopper project works + +According to [Nations Restaurant News][5], this is how Burger King's Traffic Jam Whopper project works: + +The project uses real-time data to target hungry drivers along congested roads and highways for food delivery by couriers on motorcycles. + +The system leverages push notifications to the Burger King app and personalized messaging on digital billboards positioned along busy roads close to a Burger King restaurant. + +[According to the We Believers agency][6] that put it all together, “By leveraging traffic and drivers’ real-time data [location and speed], we adjusted our billboards’ location and content, displaying information about the remaining time in traffic to order, and personalized updates about deliveries in progress.” The menu is limited to Whopper Combos to speed preparation (though the company plans to offer a wider menu as it works out the kinks). + +**[[Become a Microsoft Office 365 administrator in record time with this quick start course from PluralSight.][7] ]** + +The company said orders in Mexico City were delivered in an average of 15 minutes. Fortunately (or unfortunately, depending on how you look at it) many traffic jams hold drivers captive for far longer than that. + +Once the order is ready, the motorcyclist uses Google maps and GPS technology embedded into the app to locate the car that made the order. The delivery person then weaves through traffic to hand over the Whopper. (Lane-splitting is legal in California, but I have no idea if there are other potential safety or law-enforcement issues involved here. For drivers ordering burgers, at least, the Burger King app supports voice ordering. I also don’t know what happens if traffic somehow clears up before the burger arrives.) + +Here’s a video of the pilot program in Mexico City: + +#### **New technology = > new opportunities** + +Even more amazing, this is not _just_ a publicity stunt. NRN quotes Bruno Cardinali, head of marketing for Burger King Latin America and Caribbean, claiming the project boosted sales during rush hour, when app orders are normally slow: + +“Thanks to The Traffic Jam Whopper campaign, we’ve increased deliveries by 63% in selected locations across the month of April, adding a significant amount of orders per restaurant per day, just during rush hours." + +If nothing else, this project shows that creative thinking really can leverage IoT technology into new businesses. In this case, it’s turning notoriously bad traffic—pretty much required for this process to work—from a problem into an opportunity to generate additional sales during slow periods. + +**More on IoT:** + + * [What is the IoT? How the internet of things works][8] + * [What is edge computing and how it’s changing the network][9] + * [Most powerful Internet of Things companies][10] + * [10 Hot IoT startups to watch][11] + * [The 6 ways to make money in IoT][12] + * [What is digital twin technology? [and why it matters]][13] + * [Blockchain, service-centric networking key to IoT success][14] + * [Getting grounded in IoT networking and security][15] + * [Building IoT-ready networks must become a priority][16] + * [What is the Industrial IoT? [And why the stakes are so high]][17] + + + +Join the Network World communities on [Facebook][18] and [LinkedIn][19] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3396188/the-traffic-jam-whopper-project-may-be-the-coolestdumbest-iot-idea-ever.html + +作者:[Fredric Paul][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Fredric-Paul/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/05/burger-king-gift-card-100797164-large.jpg +[2]: https://abc7news.com/food/burger-king-to-deliver-to-drivers-stuck-in-traffic/5299073/ +[3]: https://www.networkworld.com/article/3343917/the-big-picture-is-iot-in-the-enterprise-about-making-money-or-saving-money.html +[4]: https://www.networkworld.com/newsletters/signup.html +[5]: https://www.nrn.com/technology/tech-tracker-burger-king-deliver-la-motorists-stuck-traffic?cid= +[6]: https://www.youtube.com/watch?v=LXNgEZV7lNg +[7]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fcourses%2Fadministering-office-365-quick-start +[8]: https://www.networkworld.com/article/3207535/internet-of-things/what-is-the-iot-how-the-internet-of-things-works.html +[9]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[10]: https://www.networkworld.com/article/2287045/internet-of-things/wireless-153629-10-most-powerful-internet-of-things-companies.html +[11]: https://www.networkworld.com/article/3270961/internet-of-things/10-hot-iot-startups-to-watch.html +[12]: https://www.networkworld.com/article/3279346/internet-of-things/the-6-ways-to-make-money-in-iot.html +[13]: https://www.networkworld.com/article/3280225/internet-of-things/what-is-digital-twin-technology-and-why-it-matters.html +[14]: https://www.networkworld.com/article/3276313/internet-of-things/blockchain-service-centric-networking-key-to-iot-success.html +[15]: https://www.networkworld.com/article/3269736/internet-of-things/getting-grounded-in-iot-networking-and-security.html +[16]: https://www.networkworld.com/article/3276304/internet-of-things/building-iot-ready-networks-must-become-a-priority.html +[17]: https://www.networkworld.com/article/3243928/internet-of-things/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html +[18]: https://www.facebook.com/NetworkWorld/ +[19]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190523 Benchmarks of forthcoming Epyc 2 processor leaked.md b/sources/talk/20190523 Benchmarks of forthcoming Epyc 2 processor leaked.md new file mode 100644 index 0000000000..61ae9e656b --- /dev/null +++ b/sources/talk/20190523 Benchmarks of forthcoming Epyc 2 processor leaked.md @@ -0,0 +1,55 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Benchmarks of forthcoming Epyc 2 processor leaked) +[#]: via: (https://www.networkworld.com/article/3397081/benchmarks-of-forthcoming-epyc-2-processor-leaked.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Benchmarks of forthcoming Epyc 2 processor leaked +====== +Benchmarks of AMD's second-generation Epyc server briefly found their way online and show the chip is larger but a little slower than the Epyc 7601 on the market now. +![Gordon Mah Ung][1] + +Benchmarks of engineering samples of AMD's second-generation Epyc server, code-named “Rome,” briefly found their way online and show a very beefy chip running a little slower than its predecessor. + +Rome is based on the Zen 2 architecture, believed to be more of an incremental improvement over the prior generation than a major leap. It’s already known that Rome would feature a 64-core, 128-thread design, but that was about all of the details. + +**[ Also read:[Who's developing quantum computers][2] ]** + +The details came courtesy of SiSoftware's Sandra PC analysis and benchmarking tool. It’s very popular and has been used by hobbyists and benchmarkers alike for more than 20 years. New benchmarks are uploaded to the Sandra database all the time, and what I suspect happened is someone running a Rome sample ran the benchmark, not realizing the results would be uploaded to the Sandra database. + +The benchmarks were from two different servers, a Dell PowerEdge R7515 and a Super Micro Super Server. The Dell product number is not on the market, so this would indicate a future server with Rome processors. The entry has since been deleted, but several sites, including the hobbyist site Tom’s Hardware Guide, managed to [take a screenshot][3]. + +According to the entry, the chip is a mid-range processor with a base clock speed of 1.4GHz, jumping up to 2.2GHz in turbo mode, with 16MB of Level 2 cache and 256MB of Level 3 cache, the latter of which is crazy. The first-generation Epyc had just 32MB of L3 cache. + +That’s a little slower than the Epyc 7601 on the market now, but when you double the number of cores in the same space, something’s gotta give, and in this case, it’s electricity. The thermal envelope was not revealed by the benchmark. Previous Epyc processors ranged from 120 watts to 180 watts. + +Sandra ranked the processor at #3 for arithmetic and #5 for multimedia processing, which makes me wonder what on Earth beat the Rome chip. Interestingly, the servers were running Windows 10, not Windows Server 2019. + +**[[Get certified as an Apple Technical Coordinator with this seven-part online course from PluralSight.][4] ]** + +Rome is expected to be officially launched at the massive Computex trade show in Taiwan on May 27 and will begin shipping in the third quarter of the year. + +Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3397081/benchmarks-of-forthcoming-epyc-2-processor-leaked.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/11/rome_2-100779395-large.jpg +[2]: https://www.networkworld.com/article/3275385/who-s-developing-quantum-computers.html +[3]: https://www.tomshardware.co.uk/amd-epyc-rome-processor-data-center,news-60265.html +[4]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fapple-certified-technical-trainer-10-11 +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190523 Edge-based caching and blockchain-nodes speed up data transmission.md b/sources/talk/20190523 Edge-based caching and blockchain-nodes speed up data transmission.md new file mode 100644 index 0000000000..54ddf76db3 --- /dev/null +++ b/sources/talk/20190523 Edge-based caching and blockchain-nodes speed up data transmission.md @@ -0,0 +1,74 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Edge-based caching and blockchain-nodes speed up data transmission) +[#]: via: (https://www.networkworld.com/article/3397105/edge-based-caching-and-blockchain-nodes-speed-up-data-transmission.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +Edge-based caching and blockchain-nodes speed up data transmission +====== +Using a combination of edge-based data caches and blockchain-like distributed networks, Bluzelle claims it can significantly speed up the delivery of data across the globe. +![OlgaSalt / /getty][1] + +The combination of a blockchain-like distributed network, along with the ability to locate data at the edge will massively speed up future networks, such as those used by the internet of things (IoT), claims Bluzelle in announcing what is says is the first decentralized data delivery network (DDN). + +Distributed DDNs will be like content delivery networks (CDNs) that now cache content around the world to speed up the web, but in this case, it will be for data, the Singapore-based company explains. Distributed key-value (blockchain) networks and edge computing built into Bluzelle's system will provide significantly faster delivery than existing caching, the company claims in a press release announcing its product. + +“The future of data delivery can only ever be de-centrally distributed,” says Pavel Bains, CEO and co-founder of Bluzelle. It’s because the world requires instant access to data that’s being created at the edge, he argues. + +“But delivery is hampered by existing technology,” he says. + +**[ Also read:[What is edge computing?][2] and [How edge networking and IoT will reshape data centers][3]. ]** + +Bluzelle says decentralized caching is the logical next step to generalized data caching, used for reducing latency. “Decentralized caching expands the theory of caching,” the company writes in a [report][4] (Dropbox pdf) on its [website][5]. It says the cache must be expanded from simply being located at one unique location. + +“Using a combination of distributed networks, the edge and the cloud, [it’s] thereby increasing the transactional throughput of data,” the company says. + +This kind of thing is particularly important in consumer gaming now, where split-second responses from players around the world make or break a game experience, but it will likely be crucial for the IoT, higher-definition media, artificial intelligence, and virtual reality as they gain more of a role in digitization—including at critical enterprise applications. + +“Currently applications are limited to data caching technologies that require complex configuration and management of 10-plus-year-old technology constrained to a few data centers,” Bains says. “These were not designed to handle the ever-increasing volumes of data.” + +Bains says one of the key selling points of Bluzelle's network is that developers should be able to implement and run networks without having to also physically expand the networks manually. + +“Software developers don’t want to react to where their customers come from. Our architecture is designed to always have the data right where the customer is. This provides a superior consumer experience,” he says. + +Data caches are around now, but Bluzelle claims its system, written in C++ and available on Linux and Docker containers, among other platforms, is faster than others. It further says that if its system and a more traditional cache would connect to the same MySQL database in Virginia, say, their users will get the data three to 16 times faster than a traditional “non-edge-caching” network. Write updates to all Bluzelle nodes around the world takes 875 milliseconds (ms), it says. + +The company has been concentrating its efforts on gaming, and with a test setup in Virginia, it says it was able to deliver data 33 times faster—at 22ms to Singapore—than a normal, cloud-based data cache. That traditional cache (located near the database) took 727ms in the Bluzelle-published test. In a test to Ireland, it claims 16ms over 223ms using a traditional cache. + +An algorithm is partly the reason for the gains, the company explains. It “allows the nodes to make decisions and take actions without the need for masternodes,” the company says. Masternodes are the server-like parts of blockchain systems. + +**More about edge networking** + + * [How edge networking and IoT will reshape data centers][3] + * [Edge computing best practices][6] + * [How edge computing can help secure the IoT][7] + + + +Join the Network World communities on [Facebook][8] and [LinkedIn][9] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3397105/edge-based-caching-and-blockchain-nodes-speed-up-data-transmission.html + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/blockchain_crypotocurrency_bitcoin-by-olgasalt-getty-100787949-large.jpg +[2]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[3]: https://www.networkworld.com/article/3291790/data-center/how-edge-networking-and-iot-will-reshape-data-centers.html +[4]: https://www.dropbox.com/sh/go5bnhdproy1sk5/AAC5MDoafopFS7lXUnmiLAEFa?dl=0&preview=Bluzelle+Report+-+The+Decentralized+Internet+Is+Here.pdf +[5]: https://bluzelle.com/ +[6]: https://www.networkworld.com/article/3331978/lan-wan/edge-computing-best-practices.html +[7]: https://www.networkworld.com/article/3331905/internet-of-things/how-edge-computing-can-help-secure-the-iot.html +[8]: https://www.facebook.com/NetworkWorld/ +[9]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190523 Online performance benchmarks all companies should try to achieve.md b/sources/talk/20190523 Online performance benchmarks all companies should try to achieve.md new file mode 100644 index 0000000000..829fb127f8 --- /dev/null +++ b/sources/talk/20190523 Online performance benchmarks all companies should try to achieve.md @@ -0,0 +1,80 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Online performance benchmarks all companies should try to achieve) +[#]: via: (https://www.networkworld.com/article/3397322/online-performance-benchmarks-all-companies-should-try-to-achieve.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + +Online performance benchmarks all companies should try to achieve +====== +With digital performance more important than ever, companies must ensure their online performance meets customers’ needs. A new ThousandEyes report can help them determine that. +![Thinkstock][1] + +There's no doubt about it: We have entered the experience economy, and digital performance is more important than ever. + +Customer experience is the top brand differentiator, topping price and every other factor. And businesses that provide a poor digital experience will find customers will actively seek a competitor. In fact, recent ZK Research found that in 2018, about two-thirds of millennials changed loyalties to a brand because of a bad experience. (Note: I am an employee of ZK Research.) + +To help companies determine if their online performance is leading, lacking, or on par with some of the top companies, ThousandEyes this week released its [2019 Digital Experience Performance Benchmark Report][2]. This document provides a comparative analysis of web, infrastructure, and network performance from the top 20 U.S. digital retail, travel, and media websites. Although this is a small sampling of companies, those three industries are the most competitive when it comes to using their digital platforms for competitive advantage. The aggregated data from this report can be used as an industry-agnostic performance benchmark that all companies should strive to meet. + +**[ Read also:[IoT providers need to take responsibility for performance][3] ]** + +The methodology of the study was for ThousandEyes to use its own platform to provide an independent view of performance. It uses active monitoring and a global network of monitoring agents to measure application and network layer performance for websites, applications, and services. The company collected data from 36 major cities scattered across the U.S. Six of the locations (Ashburn, Chicago, Dallas, Los Angeles, San Jose, and Seattle) also included vantage points connected to six major broadband ISPs (AT&T, CenturyLink, Charter, Comcast, Cox, and Verizon). This acts as a good proxy for what a user would experience. + +The test involved page load tests against the websites of the major companies in retail, media, and travel and looked at several factors, including DNS response time, round-trip latency, network time (one-way latency), HTTP response time, and page load. The averages and median times can be seen in the table below. Those can be considered the average benchmarks that all companies should try to attain. + +![][4] + +### Choice of content delivery network matters by location + +ThousandEyes' report also looked at how the various services that companies use impacts web performance. For example, the study measured the performance of the content delivery network (CDN) providers in the 36 markets. It found that in Albuquerque, Akamai and Fastly had the most latency, whereas Edgecast had the least. It also found that in Boston, all of the CDN providers were close. Companies can use this type of data to help them select a CDN. Without it, decision makers are essentially guessing and hoping. + +### CDN performance is impacted by ISP + +Another useful set of data was cross-referencing CDN performance by ISP, which lead to some fascinating information. With Comcast, Akamai, Cloudfront, Google and Incapula all had high amounts of latency. Only Edgecast and Fastly offered average latency. On the other hand, all of the CDNs worked great with CenturyLink. This tells a buyer, "If my customer base is largely in Comcast’s footprint, I should look at Edgecast or Fastly or my customers will be impacted." + +### DNS and latency directly impact page load times + +The ThousandEyes study also confirmed some points that many people believe as true but until now had no quantifiable evidence to support it. For example, it's widely accepted that DNS response time and network latency to the CDN edge correlate to web performance; the data in the report now supports that belief. ThousandEyes did some regression analysis and fancy math and found that in general, companies that were in the top quartile of HTTP performance had above-average DNS response time and network performance. There were a few exceptions, but in most cases, this is true. + +Based on all the data, the below are the benchmarks for the three infrastructure metrics gathered and is what businesses, even ones outside the three verticals studied, should hope to achieve to support a high-quality digital experience. + + * DNS response time 25 ms + * Round trip network latency 15 ms + * HTTP response time 250 ms + + + +### Operations teams need to focus on digital performance + +Benchmarking certainly provides value, but the report also offers some recommendations on how operations teams can use the data to improve digital performance. Those include: + + * **Measure site from distributed user vantage points**. There is no single point that will provide a view of digital performance everywhere. Instead, measure from a range of ISPs in different regions and take a multi-layered approach to visibility (application, network and routing). + * **Use internet performance information as a baseline**. Compare your organization's data to the baselines, and if you’re not meeting it in some markets, focus on improvement there. + * **Compare performance to industry peers**. In highly competitive industries, it’s important to understand how you rank versus the competition. Don’t be satisfied with hitting the benchmarks if your key competitors exceed them. + * **Build a strong performance stack.** The data shows that solid DNS and HTTP response times and low latency are correlated to solid page load times. Focus on optimizing those factors and consider them foundational to digital performance. + + + +Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3397322/online-performance-benchmarks-all-companies-should-try-to-achieve.html + +作者:[Zeus Kerravala][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2017/07/racing_speed_runners_internet-speed-100728363-large.jpg +[2]: https://www.thousandeyes.com/research/digital-experience +[3]: https://www.networkworld.com/article/3340318/iot-providers-need-to-take-responsibility-for-performance.html +[4]: https://images.idgesg.net/images/article/2019/05/thousandeyes-100797290-large.jpg +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190523 Study- Most enterprise IoT transactions are unencrypted.md b/sources/talk/20190523 Study- Most enterprise IoT transactions are unencrypted.md new file mode 100644 index 0000000000..51098dad33 --- /dev/null +++ b/sources/talk/20190523 Study- Most enterprise IoT transactions are unencrypted.md @@ -0,0 +1,93 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Study: Most enterprise IoT transactions are unencrypted) +[#]: via: (https://www.networkworld.com/article/3396647/study-most-enterprise-iot-transactions-are-unencrypted.html) +[#]: author: (Tim Greene https://www.networkworld.com/author/Tim-Greene/) + +Study: Most enterprise IoT transactions are unencrypted +====== +A Zscaler report finds 91.5% of IoT communications within enterprises are in plaintext and so susceptible to interference. +![HYWARDS / Getty Images][1] + +Of the millions of enterprise-[IoT][2] transactions examined in a recent study, the vast majority were sent without benefit of encryption, leaving the data vulnerable to theft and tampering. + +The research by cloud-based security provider Zscaler found that about 91.5 percent of transactions by internet of things devices took place over plaintext, while 8.5 percent were encrypted with [SSL][3]. That means if attackers could intercept the unencrypted traffic, they’d be able to read it and possibly alter it, then deliver it as if it had not been changed. + +**[ For more on IoT security, see[our corporate guide to addressing IoT security concerns][4]. | Get regularly scheduled insights by [signing up for Network World newsletters][5]. ]** + +Researchers looked through one month’s worth of enterprise traffic traversing Zscaler’s cloud seeking the digital footprints of IoT devices. It found and analyzed 56 million IoT-device transactions over that time, and identified the type of devices, protocols they used, the servers they communicated with, how often communication went in and out and general IoT traffic patterns. + +The team tried to find out which devices generate the most traffic and the threats they face. It discovered that 1,015 organizations had at least one IoT device. The most common devices were set-top boxes (52 percent), then smart TVs (17 percent), wearables (8 percent), data-collection terminals (8 percent), printers (7 percent), IP cameras and phones (5 percent) and medical devices (1 percent). + +While they represented only 8 percent of the devices, data-collection terminals generated 80 percent of the traffic. + +The breakdown is that 18 percent of the IoT devices use SSL to communicate all the time, and of the remaining 82 percent, half used it part of the time and half never used it. +The study also found cases of plaintext HTTP being used to authenticate devices and to update software and firmware, as well as use of outdated crypto libraries and weak default credentials. + +While IoT devices are common in enterprises, “many of the devices are employee owned, and this is just one of the reasons they are a security concern,” the report says. Without strict policies and enforcement, these devices represent potential vulnerabilities. + +**[[Prepare to become a Certified Information Security Systems Professional with this comprehensive online course from PluralSight. Now offering a 10-day free trial!][6] ]** + +Another reason employee-owned IoT devices are a concern is that many businesses don’t consider them a threat because no data is stored on them. But if the data they gather is transmitted insecurely, it is at risk. + +### 5 tips to protect enterprise IoT + +Zscaler recommends these security precautions: + + * Change default credentials to something more secure. As employees bring in devices, encourage them to use strong passwords and to keep their firmware current. + * Isolate IoT devices on networks and restrict inbound and outbound network traffic. + * Restrict access to IoT devices from external networks and block unnecessary ports from external access. + * Apply regular security and firmware updates to IoT devices, and secure network traffic. + * Deploy tools to gain visibility of shadow-IoT devices already inside the network so they can be protected. + + + +**More on IoT:** + + * [What is edge computing and how it’s changing the network][7] + * [Most powerful Internet of Things companies][8] + * [10 Hot IoT startups to watch][9] + * [The 6 ways to make money in IoT][10] + * [What is digital twin technology? [and why it matters]][11] + * [Blockchain, service-centric networking key to IoT success][12] + * [Getting grounded in IoT networking and security][13] + * [Building IoT-ready networks must become a priority][14] + * [What is the Industrial IoT? [And why the stakes are so high]][15] + + + +Join the Network World communities on [Facebook][16] and [LinkedIn][17] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3396647/study-most-enterprise-iot-transactions-are-unencrypted.html + +作者:[Tim Greene][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Tim-Greene/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/05/network_security_network_traffic_scanning_by_hywards_gettyimages-673891964_2400x1600-100796830-large.jpg +[2]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[3]: https://www.networkworld.com/article/3045953/5-things-you-need-to-know-about-ssl.html +[4]: https://www.networkworld.com/article/3269165/internet-of-things/a-corporate-guide-to-addressing-iot-security-concerns.html +[5]: https://www.networkworld.com/newsletters/signup.html +[6]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr +[7]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[8]: https://www.networkworld.com/article/2287045/internet-of-things/wireless-153629-10-most-powerful-internet-of-things-companies.html +[9]: https://www.networkworld.com/article/3270961/internet-of-things/10-hot-iot-startups-to-watch.html +[10]: https://www.networkworld.com/article/3279346/internet-of-things/the-6-ways-to-make-money-in-iot.html +[11]: https://www.networkworld.com/article/3280225/internet-of-things/what-is-digital-twin-technology-and-why-it-matters.html +[12]: https://www.networkworld.com/article/3276313/internet-of-things/blockchain-service-centric-networking-key-to-iot-success.html +[13]: https://www.networkworld.com/article/3269736/internet-of-things/getting-grounded-in-iot-networking-and-security.html +[14]: https://www.networkworld.com/article/3276304/internet-of-things/building-iot-ready-networks-must-become-a-priority.html +[15]: https://www.networkworld.com/article/3243928/internet-of-things/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html +[16]: https://www.facebook.com/NetworkWorld/ +[17]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190528 Analysing D Code with KLEE.md b/sources/talk/20190528 Analysing D Code with KLEE.md new file mode 100644 index 0000000000..c93f6e2b8d --- /dev/null +++ b/sources/talk/20190528 Analysing D Code with KLEE.md @@ -0,0 +1,680 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Analysing D Code with KLEE) +[#]: via: (https://theartofmachinery.com/2019/05/28/d_and_klee.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +Analysing D Code with KLEE +====== + +[KLEE][1] is symbolic execution engine that can rigorously verify or find bugs in software. It’s designed for C and C++, but it’s just an interpreter for LLVM bitcode combined with theorem prover backends, so it can work with bitcode generated by `ldc2`. One catch is that it needs a compatible bitcode port of the D runtime to run normal D code. I’m still interested in getting KLEE to work with normal D code, but for now I’ve done some experiments with `-betterC` D. + +### How KLEE works + +What makes KLEE special is its support for two kinds of variables: concrete and symbolic. Concrete variables are just like the normal variables in normal code: they have a deterministic value at any given point in the program. On the other hand, symbolic variables contain a bundle of logical constraints instead of values. Take this code: + +``` +int x = klee_int("x"); +klee_assume(x >= 0); +if (x > 42) +{ + doA(x); +} +else +{ + doB(x); + assert (3 * x != 21); +} +``` + +`klee_int("x")` creates a symbolic integer that will be called “`x`” in output reports. Initially it has no contraints and can imply any value that a 32b signed integer can have. `klee_assume(x >= 0)` tells KLEE to add `x >= 0` as a constraint, so now we’re only analysing the code for non-negative 32b signed integers. On hitting the `if`, KLEE checks if both branches are possible. Sure enough, `x > 42` can be true or false even with the constraint `x >= 0`, so KLEE has to _fork_. We now have two processes being interpreted on the VM: one executing `doA()` while `x` holds the constraints `x >= 0, x > 42`, and another executing `doB()` while `x` holds the contraints `x >= 0, x <= 42`. The second process will hit the `assert` statement, and KLEE will try to prove or disprove `3 * x != 21` using the assumptions `x >= 0, x <= 42` — in this case it will disprove it and report a bug with `x = 7` as a crashing example. + +### First steps + +Here’s a toy example just to get things working. Suppose we have a function that makes an assumption for a performance optimisation. Thankfully the assumption is made explicit with `assert` and is documented with a comment. Is the assumption valid? + +``` +int foo(int x) +{ + // 17 is a prime number, so let's use it as a sentinel value for an awesome optimisation + assert (x * x != 17); + // ... + return x; +} +``` + +Here’s a KLEE test rig. The KLEE function declarations and the `main()` entry point need to have `extern(C)` linkage, but anything else can be normal D code as long as it compiles under `-betterC`: + +``` +extern(C): + +int klee_int(const(char*) name); + +int main() +{ + int x = klee_int("x"); + foo(x); + return 0; +} +``` + +It turns out there’s just one (frustrating) complication with running `-betterC` D under KLEE. In D, `assert` is handled specially by the compiler. By default, it throws an `Error`, but for compatibility with KLEE, I’m using the `-checkaction=C` flag. In C, `assert` is usually a macro that translates to code that calls some backend implementation. That implementation isn’t standardised, so of course various C libraries work differently. `ldc2` actually has built-in logic for implementing `-checkaction=C` correctly depending on the C library used. + +KLEE uses a port of [uClibc][2], which translates `assert()` to a four-parameter `__assert()` function, which conflicts with the three-parameter `__assert()` function in other implementations. `ldc2` uses LLVM’s (target) `Triple` type for choosing an `assert()` implementation configuration, but that doesn’t recognise uClibc. As a hacky workaround, I’m telling `ldc2` to compile for Musl, which “tricks” it into using an `__assert_fail()` implementation that KLEE happens to support as well. I’ve opened [an issue report][3]. + +Anyway, if we put all that code above into a file, we can compile it to KLEE-ready bitcode like this: + +``` +ldc2 -g -checkaction=C -mtriple=x86_64-linux-musl -output-bc -betterC -c first.d +``` + +`-g` is optional, but adds debug information that can be useful for later analysis. The KLEE developers recommend disabling compiler optimisations and letting KLEE do its own optimisations instead. + +Now to run KLEE: + +``` +$ klee first.bc +KLEE: output directory is "/tmp/klee-out-1" +KLEE: Using Z3 solver backend +warning: Linking two modules of different target triples: klee_int.bc' is 'x86_64-pc-linux-gnu' whereas 'first.bc' is 'x86_64--linux-musl' + +KLEE: ERROR: first.d:4: ASSERTION FAIL: x * x != 17 +KLEE: NOTE: now ignoring this error at this location + +KLEE: done: total instructions = 35 +KLEE: done: completed paths = 2 +KLEE: done: generated tests = 2 +``` + +Straight away, KLEE has found two execution paths through the program: a happy path, and a path that fails the assertion. Let’s see the results: + +``` +$ ls klee-last/ +assembly.ll +info +messages.txt +run.istats +run.stats +run.stats-journal +test000001.assert.err +test000001.kquery +test000001.ktest +test000002.ktest +warnings.txt +``` + +Here’s the example that triggers the happy path: + +``` +$ ktest-tool klee-last/test000002.ktest +ktest file : 'klee-last/test000002.ktest' +args : ['first.bc'] +num objects: 1 +object 0: name: 'x' +object 0: size: 4 +object 0: data: b'\x00\x00\x00\x00' +object 0: hex : 0x00000000 +object 0: int : 0 +object 0: uint: 0 +object 0: text: .... +``` + +Here’s the example that causes an assertion error: + +``` +$ cat klee-last/test000001.assert.err +Error: ASSERTION FAIL: x * x != 17 +File: first.d +Line: 4 +assembly.ll line: 32 +Stack: + #000000032 in _D5first3fooFiZi () at first.d:4 + #100000055 in main (=1, =94262044506880) at first.d:16 +$ ktest-tool klee-last/test000001.ktest +ktest file : 'klee-last/test000001.ktest' +args : ['first.bc'] +num objects: 1 +object 0: name: 'x' +object 0: size: 4 +object 0: data: b'\xe9&\xd33' +object 0: hex : 0xe926d333 +object 0: int : 869476073 +object 0: uint: 869476073 +object 0: text: .&.3 +``` + +So, KLEE has deduced that when `x` is 869476073, `x * x` does a 32b overflow to 17 and breaks the code. + +It’s overkill for this simple example, but `run.istats` can be opened with [KCachegrind][4] to view things like call graphs and source code coverage. (Unfortunately, coverage stats can be misleading because correct code won’t ever hit boundary check code inserted by the compiler.) + +### MurmurHash preimage + +Here’s a slightly more useful example. D currently uses 32b MurmurHash3 as its standard non-cryptographic hash function. What if we want to find strings that hash to a given special value? In general, we can solve problems like this by asserting that something doesn’t exist (i.e., a string that hashes to a given value) and then challenging the theorem prover to prove us wrong with a counterexample. + +Unfortunately, we can’t just use `hashOf()` directly without the runtime, but we can copy [the hash code from the runtime source][5] into its own module, and then import it into a test rig like this: + +``` +import dhash; + +extern(C): + +void klee_make_symbolic(void* addr, size_t nbytes, const(char*) name); +int klee_assume(ulong condition); + +int main() +{ + // Create a buffer for 8-letter strings and let KLEE manage it symbolically + char[8] s; + klee_make_symbolic(s.ptr, s.sizeof, "s"); + + // Constrain the string to be letters from a to z for convenience + foreach (j; 0..s.length) + { + klee_assume(s[j] > 'a' && s[j] <= 'z'); + } + + assert (dHash(cast(ubyte[])s) != 0xdeadbeef); + return 0; +} +``` + +Here’s how to compile and run it. Because we’re not checking correctness, we can use `-boundscheck=off` for a slight performance boost. It’s also worth enabling KLEE’s optimiser. + +``` +$ ldc2 -g -boundscheck=off -checkaction=C -mtriple=x86_64-linux-musl -output-bc -betterC -c dhash.d dhash_klee.d +$ llvm-link -o dhash_test.bc dhash.bc dhash_klee.bc +$ klee -optimize dhash_test.bc +``` + +It takes just over 4s: + +``` +$ klee-stats klee-last/ +------------------------------------------------------------------------- +| Path | Instrs| Time(s)| ICov(%)| BCov(%)| ICount| TSolver(%)| +------------------------------------------------------------------------- +|klee-last/| 168| 4.37| 87.50| 50.00| 160| 99.95| +------------------------------------------------------------------------- +``` + +And it actually works: + +``` +$ ktest-tool klee-last/test000001.ktest +ktest file : 'klee-last/test000001.ktest' +args : ['dhash_test.bc'] +num objects: 1 +object 0: name: 's' +object 0: size: 8 +object 0: data: b'psgmdxvq' +object 0: hex : 0x7073676d64787671 +object 0: int : 8175854546265273200 +object 0: uint: 8175854546265273200 +object 0: text: psgmdxvq +$ rdmd --eval 'writef("%x\n", hashOf("psgmdxvq"));' +deadbeef +``` + +For comparison, here’s a simple brute force version in plain D: + +``` +import std.stdio; + +void main() +{ + char[8] buffer; + + bool find(size_t idx) + { + if (idx == buffer.length) + { + auto hash = hashOf(buffer[]); + if (hash == 0xdeadbeef) + { + writeln(buffer[]); + return true; + } + return false; + } + + foreach (char c; 'a'..'z') + { + buffer[idx] = c; + auto is_found = find(idx + 1); + if (is_found) return true; + } + + return false; + } + + find(0); +} +``` + +This takes ~17s: + +``` +$ ldc2 -O3 -boundscheck=off hash_brute.d +$ time ./hash_brute +aexkaydh + +real 0m17.398s +user 0m17.397s +sys 0m0.001s +$ rdmd --eval 'writef("%x\n", hashOf("aexkaydh"));' +deadbeef +``` + +The constraint solver implementation is simpler to write, but is still faster because it can automatically do smarter things than calculating hashes of strings from scratch every iteration. + +### Binary search + +Now for an example of testing and debugging. Here’s an implementation of [binary search][6]: + +``` +bool bsearch(const(int)[] haystack, int needle) +{ + while (haystack.length) + { + auto mid_idx = haystack.length / 2; + if (haystack[mid_idx] == needle) return true; + if (haystack[mid_idx] < needle) + { + haystack = haystack[mid_idx..$]; + } + else + { + haystack = haystack[0..mid_idx]; + } + } + return false; +} +``` + +Does it work? Here’s a test rig: + +``` +extern(C): + +void klee_make_symbolic(void* addr, size_t nbytes, const(char*) name); +int klee_range(int begin, int end, const(char*) name); +int klee_assume(ulong condition); + +int main() +{ + // Making an array arr and an x to find in it. + // This time we'll also parameterise the array length. + // We have to apply klee_make_symbolic() to the whole buffer because of limitations in KLEE. + int[8] arr_buffer; + klee_make_symbolic(arr_buffer.ptr, arr_buffer.sizeof, "a"); + int len = klee_range(0, arr_buffer.length+1, "len"); + auto arr = arr_buffer[0..len]; + // Keeping the values in [0, 32) makes the output easier to read. + // (The binary-friendly limit 32 is slightly more efficient than 30.) + int x = klee_range(0, 32, "x"); + foreach (j; 0..arr.length) + { + klee_assume(arr[j] >= 0); + klee_assume(arr[j] < 32); + } + + // Make the array sorted. + // We don't have to actually sort the array. + // We can just tell KLEE to constrain it to be sorted. + foreach (j; 1..arr.length) + { + klee_assume(arr[j - 1] <= arr[j]); + } + + // Test against simple linear search + bool has_x = false; + foreach (a; arr[]) + { + has_x |= a == x; + } + + assert (bsearch(arr, x) == has_x); + + return 0; +} +``` + +When run in KLEE, it keeps running for a long, long time. How do we know it’s doing anything? By default KLEE writes stats every 1s, so we can watch the live progress in another terminal: + +``` +$ watch klee-stats --print-more klee-last/ +Every 2.0s: klee-stats --print-more klee-last/ + +--------------------------------------------------------------------------------------------------------------------- +| Path | Instrs| Time(s)| ICov(%)| BCov(%)| ICount| TSolver(%)| States| maxStates| Mem(MB)| maxMem(MB)| +--------------------------------------------------------------------------------------------------------------------- +|klee-last/| 5834| 637.27| 79.07| 68.75| 172| 100.00| 22| 22| 24.51| 24| +--------------------------------------------------------------------------------------------------------------------- +``` + +`bsearch()` should be pretty fast, so we should see KLEE discovering new states rapidly. But instead it seems to be stuck. [At least one fork of KLEE has heuristics for detecting infinite loops][7], but plain KLEE doesn’t. There are timeout and batching options for making KLEE work better with code that might have infinite loops, but let’s just take another look at the code. In particular, the loop condition: + +``` +while (haystack.length) +{ + // ... +} +``` + +Binary search is supposed to reduce the search space by about half each iteration. `haystack.length` is an unsigned integer, so the loop must terminate as long as it goes down every iteration. Let’s rewrite the code slightly so we can verify if that’s true: + +``` +bool bsearch(const(int)[] haystack, int needle) +{ + while (haystack.length) + { + auto mid_idx = haystack.length / 2; + if (haystack[mid_idx] == needle) return true; + const(int)[] next_haystack; + if (haystack[mid_idx] < needle) + { + next_haystack = haystack[mid_idx..$]; + } + else + { + next_haystack = haystack[0..mid_idx]; + } + // This lets us verify that the search terminates + assert (next_haystack.length < haystack.length); + haystack = next_haystack; + } + return false; +} +``` + +Now KLEE can find the bug! + +``` +$ klee -optimize bsearch.bc +KLEE: output directory is "/tmp/klee-out-2" +KLEE: Using Z3 solver backend +warning: Linking two modules of different target triples: klee_range.bc' is 'x86_64-pc-linux-gnu' whereas 'bsearch.bc' is 'x86_64--linux-musl' + +warning: Linking two modules of different target triples: memset.bc' is 'x86_64-pc-linux-gnu' whereas 'bsearch.bc' is 'x86_64--linux-musl' + +KLEE: ERROR: bsearch.d:18: ASSERTION FAIL: next_haystack.length < haystack.length +KLEE: NOTE: now ignoring this error at this location + +KLEE: done: total instructions = 2281 +KLEE: done: completed paths = 42 +KLEE: done: generated tests = 31 +``` + +Using the failing example as input and stepping through the code, it’s easy to find the problem: + +``` +/// ... +if (haystack[mid_idx] < needle) +{ + // If mid_idx == 0, next_haystack is the same as haystack + // Nothing changes, so the loop keeps repeating + next_haystack = haystack[mid_idx..$]; +} +/// ... +``` + +Thinking about it, the `if` statement already excludes `haystack[mid_idx]` from being `needle`, so there’s no reason to include it in `next_haystack`. Here’s the fix: + +``` +// The +1 matters +next_haystack = haystack[mid_idx+1..$]; +``` + +But is the code correct now? Terminating isn’t enough; it needs to get the right answer, of course. + +``` +$ klee -optimize bsearch.bc +KLEE: output directory is "/tmp/kee-out-3" +KLEE: Using Z3 solver backend +warning: Linking two modules of different target triples: klee_range.bc' is 'x86_64-pc-linux-gnu' whereas 'bsearch.bc' is 'x86_64--linux-musl' + +warning: Linking two modules of different target triples: memset.bc' is 'x86_64-pc-linux-gnu' whereas 'bsearch.bc' is 'x86_64--linux-musl' + +KLEE: done: total instructions = 3152 +KLEE: done: completed paths = 81 +KLEE: done: generated tests = 81 +``` + +In just under 7s, KLEE has verified every possible execution path reachable with arrays of length from 0 to 8. Note, that’s not just coverage of individual code lines, but coverage of full pathways through the code. KLEE hasn’t ruled out stack corruption or integer overflows with large arrays, but I’m pretty confident the code is correct now. + +KLEE has generated test cases that trigger each path, which we can keep and use as a faster-than-7s regression test suite. Trouble is, the output from KLEE loses all type information and isn’t in a convenient format: + +``` +$ ktest-tool klee-last/test000042.ktest +ktest file : 'klee-last/test000042.ktest' +args : ['bsearch.bc'] +num objects: 3 +object 0: name: 'a' +object 0: size: 32 +object 0: data: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +object 0: hex : 0x0000000000000000000000000000000001000000100000000000000000000000 +object 0: text: ................................ +object 1: name: 'x' +object 1: size: 4 +object 1: data: b'\x01\x00\x00\x00' +object 1: hex : 0x01000000 +object 1: int : 1 +object 1: uint: 1 +object 1: text: .... +object 2: name: 'len' +object 2: size: 4 +object 2: data: b'\x06\x00\x00\x00' +object 2: hex : 0x06000000 +object 2: int : 6 +object 2: uint: 6 +object 2: text: .... +``` + +But we can write our own pretty-printing code and put it at the end of the test rig: + +``` +char[256] buffer; +char* output = buffer.ptr; +output += sprintf(output, "TestCase(["); +foreach (a; arr[]) +{ + output += sprintf(output, "%d, ", klee_get_value_i32(a)); +} +sprintf(output, "], %d, %s),\n", klee_get_value_i32(x), klee_get_value_i32(has_x) ? "true".ptr : "false".ptr); +fputs(buffer.ptr, stdout); +``` + +Ugh, that would be just one format call with D’s `%(` array formatting specs. The output needs to be buffered up and printed all at once to stop output from different parallel executions getting mixed up. `klee_get_value_i32()` is needed to get a concrete example from a symbolic variable (remember that a symbolic variable is just a bundle of constraints). + +``` +$ klee -optimize bsearch.bc > tests.d +... +$ # Sure enough, 81 test cases +$ wc -l tests.d +81 tests.d +$ # Look at the first 10 +$ head tests.d +TestCase([], 0, false), +TestCase([0, ], 0, true), +TestCase([16, ], 1, false), +TestCase([0, ], 1, false), +TestCase([0, 0, ], 0, true), +TestCase([0, 0, ], 1, false), +TestCase([1, 16, ], 1, true), +TestCase([0, 0, 0, ], 0, true), +TestCase([16, 16, ], 1, false), +TestCase([1, 16, ], 3, false), +``` + +Nice! An autogenerated regression test suite that’s better than anything I would write by hand. This is my favourite use case for KLEE. + +### Change counting + +One last example: + +In Australia, coins come in 5c, 10c, 20c, 50c, $1 (100c) and $2 (200c) denominations. So you can make 70c using 14 5c coins, or using a 50c coin and a 20c coin. Obviously, fewer coins is usually more convenient. There’s a simple [greedy algorithm][8] to make a small pile of coins that adds up to a given value: just keep adding the biggest coin you can to the pile until you’ve reached the target value. It turns out this trick is optimal — at least for Australian coins. Is it always optimal for any set of coin denominations? + +The hard thing about testing optimality is that you don’t know what the correct optimal values are without a known-good algorithm. Without a constraints solver, I’d compare the output of the greedy algorithm with some obviously correct brute force optimiser, run over all possible cases within some small-enough limit. But with KLEE, we can use a different approach: comparing the greedy solution to a non-deterministic solution. + +The greedy algorithm takes the list of coin denominations and the target value as input, so (like in the previous examples) we make those symbolic. Then we make another symbolic array that represents an assignment of coin counts to each coin denomination. We don’t specify anything about how to generate this assignment, but we constrain it to be a valid assignment that adds up to the target value. It’s [non-deterministic][9]. Then we just assert that the total number of coins in the non-deterministic assignment is at least the number of coins needed by the greedy algorithm, which would be true if the greedy algorithm were universally optimal. Finally we ask KLEE to prove the program correct or incorrect. + +Here’s the code: + +``` +// Greedily break value into coins of values in denominations +// denominations must be in strictly decreasing order +int greedy(const(int[]) denominations, int value, int[] coins_used_output) +{ + int num_coins = 0; + foreach (j; 0..denominations.length) + { + int num_to_use = value / denominations[j]; + coins_used_output[j] = num_to_use; + num_coins += num_to_use; + value = value % denominations[j]; + } + return num_coins; +} + +extern(C): + +void klee_make_symbolic(void* addr, size_t nbytes, const(char*) name); +int klee_int(const(char*) name); +int klee_assume(ulong condition); +int klee_get_value_i32(int expr); + +int main(int argc, char** argv) +{ + enum kNumDenominations = 6; + int[kNumDenominations] denominations, coins_used; + klee_make_symbolic(denominations.ptr, denominations.sizeof, "denominations"); + + // We're testing the algorithm itself, not implementation issues like integer overflow + // Keep values small + foreach (d; denominations) + { + klee_assume(d >= 1); + klee_assume(d <= 1024); + } + // Make the smallest denomination 1 so that all values can be represented + // This is just for simplicity so we can focus on optimality + klee_assume(denominations[$-1] == 1); + + // Greedy algorithm expects values in descending order + foreach (j; 1..denominations.length) + { + klee_assume(denominations[j-1] > denominations[j]); + } + + // What we're going to represent + auto value = klee_int("value"); + + auto num_coins = greedy(denominations[], value, coins_used[]); + + // The non-deterministic assignment + int[kNumDenominations] nd_coins_used; + klee_make_symbolic(nd_coins_used.ptr, nd_coins_used.sizeof, "nd_coins_used"); + + int nd_num_coins = 0, nd_value = 0; + foreach (j; 0..kNumDenominations) + { + klee_assume(nd_coins_used[j] >= 0); + klee_assume(nd_coins_used[j] <= 1024); + nd_num_coins += nd_coins_used[j]; + nd_value += nd_coins_used[j] * denominations[j]; + } + + // Making the assignment valid is 100% up to KLEE + klee_assume(nd_value == value); + + // If we find a counterexample, dump it and fail + if (nd_num_coins < num_coins) + { + import core.stdc.stdio; + + puts("Counterexample found."); + + puts("Denominations:"); + foreach (ref d; denominations) + { + printf("%d ", klee_get_value_i32(d)); + } + printf("\nValue: %d\n", klee_get_value_i32(value)); + + void printAssignment(const ref int[kNumDenominations] coins) + { + foreach (j; 0..kNumDenominations) + { + printf("%d * %dc\n", klee_get_value_i32(coins[j]), klee_get_value_i32(denominations[j])); + } + } + + printf("Greedy \"optimum\": %d\n", klee_get_value_i32(num_coins)); + printAssignment(coins_used); + + printf("Better assignment for %d total coins:\n", klee_get_value_i32(nd_num_coins)); + printAssignment(nd_coins_used); + assert (false); + } + + return 0; +} +``` + +And here’s the counterexample it found after 14s: + +``` +Counterexample found. +Denominations: +129 12 10 3 2 1 +Value: 80 +Greedy "optimum": 9 +0 * 129c +6 * 12c +0 * 10c +2 * 3c +1 * 2c +0 * 1c +Better assignment for 8 total coins: +0 * 129c +0 * 12c +8 * 10c +0 * 3c +0 * 2c +0 * 1c +``` + +Note that this isn’t proven to be the new optimum; it’s just a witness that the greedy algorithm isn’t always optimal. There’s a well-known [dynamic programming][10] [solution][11] that always works. + +### What’s next? + +As I said, I’m interesting in getting this to work with full D code. I’m also interested in using [one of the floating point forks of KLEE][12] on some D because floating point is much harder to test thoroughly than integer and string code. + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2019/05/28/d_and_klee.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: https://klee.github.io/ +[2]: https://www.uclibc.org/ +[3]: https://github.com/ldc-developers/ldc/issues/3078 +[4]: https://kcachegrind.github.io/html/Home.html +[5]: https://github.com/dlang/druntime/blob/4ad638f61a9b4a98d8ed6eb9f9429c0ef6afc8e3/src/core/internal/hash.d#L670 +[6]: https://www.calhoun.io/lets-learn-algorithms-an-intro-to-binary-search/ +[7]: https://github.com/COMSYS/SymbolicLivenessAnalysis +[8]: https://en.wikipedia.org/wiki/Greedy_algorithm +[9]: http://people.clarkson.edu/~alexis/PCMI/Notes/lectureB03.pdf +[10]: https://www.algorithmist.com/index.php/Dynamic_Programming +[11]: https://www.topcoder.com/community/competitive-programming/tutorials/dynamic-programming-from-novice-to-advanced/ +[12]: https://github.com/srg-imperial/klee-float diff --git a/sources/talk/20190528 Managed WAN and the cloud-native SD-WAN.md b/sources/talk/20190528 Managed WAN and the cloud-native SD-WAN.md new file mode 100644 index 0000000000..026b5d8e81 --- /dev/null +++ b/sources/talk/20190528 Managed WAN and the cloud-native SD-WAN.md @@ -0,0 +1,121 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Managed WAN and the cloud-native SD-WAN) +[#]: via: (https://www.networkworld.com/article/3398476/managed-wan-and-the-cloud-native-sd-wan.html) +[#]: author: (Matt Conran https://www.networkworld.com/author/Matt-Conran/) + +Managed WAN and the cloud-native SD-WAN +====== +The motivation for WAN transformation is clear, today organizations require: improved internet access and last mile connectivity, additional bandwidth and a reduction in the WAN costs. +![Gerd Altmann \(CC0\)][1] + +In recent years, a significant number of organizations have transformed their wide area network (WAN). Many of these organizations have some kind of cloud-presence across on-premise data centers and remote site locations. + +The vast majority of organizations that I have consulted with have over 10 locations. And it is common to have headquarters in both the US and Europe, along with remote site locations spanning North America, Europe, and Asia. + +A WAN transformation project requires this diversity to be taken into consideration when choosing the best SD-WAN vendor to satisfy both; networking and security requirements. Fundamentally, SD-WAN is not just about physical connectivity, there are many more related aspects. + +**[ Related:[MPLS explained – What you need to know about multi-protocol label switching][2]** + +### Motivations for transforming the WAN + +The motivation for WAN transformation is clear: Today organizations prefer improved internet access and last mile connectivity, additional bandwidth along with a reduction in the WAN costs. Replacing Multiprotocol Label Switching (MPLS) with SD-WAN has of course been the main driver for the SD-WAN evolution, but it is only a single piece of the jigsaw puzzle. + +Many SD-WAN vendors are quickly brought to their knees when they try to address security and gain direct internet access from remote site locations. The problem is how to ensure optimized cloud access that is secure, has improved visibility and predictable performance without the high costs associated with MPLS? SD-WAN is not just about connecting locations. Primarily, it needs to combine many other important network and security elements into one seamless worldwide experience. + +According to a recent report from [Cato Networks][3] into enterprise IT managers, a staggering 85% will confront use cases in 2019 that are poorly addressed or outright ignored by SD-WAN. Examples includes providing secure, Internet access from any location (50%) and improving visibility into and control over mobile access to cloud applications, such as Office 365 (46%). + +### Issues with traditional SD-WAN vendors + +First and foremost, SD-WAN unable to address the security challenges that arise during the WAN transformation. Such security challenges include protection against malware, ransomware and implementing the necessary security policies. Besides, there is a lack of visibility that is required to police the mobile users and remote site locations accessing resources in the public cloud. + +To combat this, organizations have to purchase additional equipment. There has always been and will always be a high cost associated with buying such security appliances. Furthermore, the additional tools that are needed to protect the remote site locations increase the network complexity and reduce visibility. Let’s us not forget that the variety of physical appliances require talented engineers for design, deployment and maintenance. + +There will often be a single network-cowboy. This means the network and security configuration along with the design essentials are stored in the mind of the engineer, not in a central database from where the knowledge can be accessed if the engineer leaves his or her employment. + +The physical appliance approach to SD-WAN makes it hard, if not impossible, to accommodate for the future. If the current SD-WAN vendors continue to focus just on connecting the devices with the physical appliances, they will have limited ability to accommodate for example, with the future of network IoT devices. With these factors in mind what are the available options to overcome the SD-WAN shortcomings? + +One can opt for a do it yourself (DIY) solution, or a managed service, which can fall into the category of telcos, with the improvements of either co-managed or self-managed service categories. + +### Option 1: The DIY solution + +Firstly DIY, from the experience of trying to stitch together a global network, this is not only costly but also complex and is a very constrained approach to the network transformation. We started with physical appliances decades ago and it was sufficient to an extent. The reason it worked was that it suited the requirements of the time, but our environment has changed since then. Hence, we need to accommodate these changes with the current requirements. + +Even back in those days, we always had a breachable perimeter. The perimeter-approach to networking and security never really worked and it was just a matter of time before the bad actor would penetrate the guarded walls. + +Securing a global network involves more than just firewalling the devices. A solid security perimeter requires URL filtering, anti-malware and IPS to secure the internet traffic. If you try to deploy all these functions in a single device, such as, unified threat management (UTM), you will hit scaling problems. As a result, you will be left with appliance sprawl. + +Back in my early days as an engineer, I recall stitching together a global network with a mixture of security and network appliances from a variety of vendors. It was me and just two others who used to get the job done on time and for a production network, our uptime levels were superior to most. + +However, it involved too many late nights, daily flights to our PoPs and of course the major changes required a forklift. A lot of work had to be done at that time, which made me want to push some or most of the work to a 3rd party. + +### Option 2: The managed service solution + +Today, there is a growing need for the managed service approach to SD-WAN. Notably, it simplifies the network design, deployment and maintenance activities while offloading the complexity, in line with what most CIOs are talking about today. + +Managed service provides a number of benefits, such as the elimination of backhauling to centralized cloud connectors or VPN concentrators. Evidently, backhauling is never favored for a network architect. More than often it will result in increased latency, congested links, internet chokepoints, and last-mile outages. + +Managed service can also authenticate mobile users at the local communication hub and not at a centralized point which would increase the latency. So what options are available when considering a managed service? + +### Telcos: An average service level + +Let’s be honest, telcos have a mixed track record and enterprises rely on them with caution. Essentially, you are building a network with 3rd party appliances and services that put the technical expertise outside of the organization. + +Secondly, the telco must orchestrate, monitor and manage numerous technical domains which are likely to introduce further complexity. As a result, troubleshooting requires close coordination with the suppliers which will have an impact on the customer experience. + +### Time equals money + +To resolve a query could easily take two or three attempts. It’s rare that you will get to the right person straight away. This eventually increases the time to resolve problems. Even for a minor feature change, you have to open tickets. Hence, with telcos, it increases the time required to solve a problem. + +In addition, it takes time to make major network changes such as opening new locations, which could take up to 45 days. In the same report mentioned above, 71% of the respondents are frustrated with the telco customer-service-time to resolve the problems, 73% indicated that deploying new locations requires at least 15 days and 47% claimed that “high bandwidth costs” is the biggest frustration while working with telcos. + +When it comes to lead times for projects, an engineer does not care. Does a project manager care if you have an optimum network design? No, many don’t, most just care about the timeframes. During my career, now spanning 18 years, I have never seen comments from any of my contacts saying “you must adhere to your project manager’s timelines”. + +However, out of the experience, the project managers have their ways and lead times do become a big part of your daily job. So as an engineer, 45-day lead time will certainly hit your brand hard, especially if you are an external consultant. + +There is also a problem with bandwidth costs. Telcos need to charge due to their complexity. There is always going to be a series of problems when working with them. Let’s face it, they offer an average service level. + +### Co-management and self-service management + +What is needed is a service that equips with the visibility and control of DIY to managed services. This, ultimately, opens the door to co-management and self-service management. + +Co-management allows both the telco and enterprise to make changes to the WAN. Then we have the self-service management of WAN that allows the enterprises to have sole access over the aspect of their network. + +However, these are just sticking plasters covering up the flaws. We need a managed service that not only connects locations but also synthesizes the site connectivity, along with security, mobile access, and cloud access. + +### Introducing the cloud-native approach to SD-WAN + +There should be a new style of managed services that combines the best of both worlds. It should offer the uptime, predictability and reach of the best telcos along with the cost structure and versatility of cloud providers. All such requirements can be met by what is known as the cloud-native carrier. + +Therefore, we should be looking for a platform that can connect and secure all the users and resources at scale, no matter where they are positioned. Eventually, such a platform will limit the costs and increase the velocity and agility. + +This is what a cloud-native carrier can offer you. You could say it’s a new kind of managed service, which is what enterprises are now looking for. A cloud-native carrier service brings the best of cloud services to the world of networking. This new style of managed service brings to SD-WAN the global reach, self-service, and agility of the cloud with the ability to easily migrate from MPLS. + +In summary, a cloud-native carrier service will improve global connectivity to on-premises and cloud applications, enable secure branch to internet access, and both securely and optimally integrate cloud datacenters. + +**This article is published as part of the IDG Contributor Network.[Want to Join?][4]** + +Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3398476/managed-wan-and-the-cloud-native-sd-wan.html + +作者:[Matt Conran][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Matt-Conran/ +[b]: https://github.com/lujun9972 +[1]: https://images.techhive.com/images/article/2017/03/network-wan-100713693-large.jpg +[2]: https://www.networkworld.com/article/2297171/sd-wan/network-security-mpls-explained.html +[3]: https://www.catonetworks.com/news/digital-transformation-survey +[4]: /contributor-network/signup.html +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190528 Moving to the Cloud- SD-WAN Matters.md b/sources/talk/20190528 Moving to the Cloud- SD-WAN Matters.md new file mode 100644 index 0000000000..8f6f46b6f2 --- /dev/null +++ b/sources/talk/20190528 Moving to the Cloud- SD-WAN Matters.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Moving to the Cloud? SD-WAN Matters!) +[#]: via: (https://www.networkworld.com/article/3397921/moving-to-the-cloud-sd-wan-matters.html) +[#]: author: (Rami Rammaha https://www.networkworld.com/author/Rami-Rammaha/) + +Moving to the Cloud? SD-WAN Matters! +====== + +![istock][1] + +This is the first in a two-part blog series that will explore how enterprises can realize the full transformation promise of the cloud by shifting to a business first networking model powered by a business-driven [SD-WAN][2]. The focus for this installment will be on automating secure IPsec connectivity and intelligently steering traffic to cloud providers. + +Over the past several years we’ve seen a major shift in data center strategies where enterprise IT organizations are shifting applications and workloads to cloud, whether private or public. More and more, enterprises are leveraging software as-a-service (SaaS) applications and infrastructure as-a-service (IaaS) cloud services from leading providers like [Amazon AWS][3], [Google Cloud][4], [Microsoft Azure][5] and [Oracle Cloud Infrastructure][6]. This represents a dramatic shift in enterprise data traffic patterns as fewer and fewer applications are hosted within the walls of the traditional corporate data center. + +There are several drivers for the shift to IaaS cloud services and SaaS apps, but business agility tops the list for most enterprises. The traditional IT model for provisioning and deprovisioning applications is rigid and inflexible and is no longer able to keep pace with changing business needs. + +According to [LogicMonitor’s Cloud Vision 2020][7] study, more than 80 percent of enterprise workloads will run in the cloud by 2020 with more than 40 percent running on public cloud platforms. This major shift in the application consumption model is having a huge [impact on organizations and infrastructure][8]. A recent article entitled “[How Amazon Web Services is luring banks to the cloud][9],” published by CNBC, reported that some companies already have completely migrated all of their applications and IT workloads to public cloud infrastructures. An interesting fact is that while many enterprises must comply with stringent regulatory compliance mandates such as PCI-DSS or HIPAA, they still have made the move to the cloud. This tells us two things – the maturity of using public cloud services and the trust these organizations have in using them is at an all-time high. Again, it is all about speed and agility – without compromising performance, security and reliability. + +### **Is there a direct correlation between moving to the cloud and adopting SD-WAN?** + +As the cloud enables businesses to move faster, an SD-WAN architecture where top-down business intent is the driver is critical to ensuring success, especially when branch offices are geographically distributed across the globe. Traditional router-centric WAN architectures were never designed to support today’s cloud consumption model for applications in the most efficient way. With a conventional router-centric WAN approach, access to applications residing in the cloud means traversing unnecessary hops, resulting in wasted bandwidth, additional cost, added latency and potentially higher packet loss. In addition, under the existing, traditional WAN model where management tends to be rigid, complex network changes can be lengthy, whether setting up new branches or troubleshooting performance issues. This leads to inefficiencies and a costly operational model. Therefore, enterprises greatly benefit from taking a business-first WAN approach toward achieving greater agility in addition to realizing substantial CAPEX and OPEX savings. + +A business-driven SD-WAN platform is purpose-built to tackle the challenges inherent to the traditional router-centric model and more aptly support today’s cloud consumption model. This means application policies are defined based on business intent, connecting users securely and directly to applications where ever they reside without unnecessary extra hops or security compromises. For example, if the application is hosted in the cloud and is trusted, a business-driven SD-WAN can automatically connect users to it without backhauling traffic to a POP or HQ data center. Now, in general this traffic is usually going across an internet link which, on its own, may not be secure. However, the right SD-WAN platform will have a unified stateful firewall built-in for local internet breakout allowing only branch-initiated sessions to enter the branch and providing the ability to service chain traffic to a cloud-based security service if necessary, before forwarding it to its final destination. If the application is moved and becomes hosted by another provider or perhaps back to a company’s own data center, traffic must be intelligently redirected, wherever the application is being hosted. Without automation and embedded machine learning, dynamic and intelligent traffic steering is impossible. + +### **A closer look at how the Silver Peak EdgeConnect™ SD-WAN edge platform addresses these challenges: ** + +**Automate traffic steering and connectivity to cloud providers** + +An [EdgeConnect][10] virtual instance is easily spun up in any of the [leading cloud providers][11] through their respective marketplaces. For an SD-WAN to intelligently steer traffic to its destination, it requires insights into both HTTP and HTTPS traffic; it must be able to identify apps on the first packet received in order to steer traffic to the right destination in accordance with business intent. This is critical capability because once a TCP connection is NAT’d with a public IP address, it cannot be switched thus it can’t be re-routed once a connection is established. So, the ability of EdgeConnect to identify, classify and automatically steer traffic based on the first packet – and not the second or tenth packet – to the correct destination will assure application SLAs, minimize wasting expensive bandwidth and deliver the highest quality of experience. + +Another critical capability is automatic performance optimization. Irrespective of which link the traffic ends up traversing based on business intent and the unique requirements of the application, EdgeConnect automatically optimizes application performance without human intervention by correcting for out of order packets using Packet Order Correction (POC) or even under high latency conditions that can be related to distance or other issues. This is done using adaptive Forward Error Correction (FEC) and tunnel bonding where a virtual tunnel is created, resulting in a single logical overlay that traffic can be dynamically moved between the different paths as conditions change with each underlay WAN service. In this [lightboard video][12], Dinesh Fernando, a technical marketing engineer at Silver Peak, explains how EdgeConnect automates tunnel creation between sites and cloud providers, how it simplifies data transfers between multi-clouds, and how it improves application performance. + +If your business is global and increasingly dependent on the cloud, the business-driven EdgeConnect SD-WAN edge platform enables seamless multi-cloud connectivity, turning the network into a business accelerant. EdgeConnect delivers: + + 1. A consistent deployment from the branch to the cloud, extending the reach of the SD-WAN into virtual private cloud environments + 2. Multi-cloud flexibility, making it easier to initiate and distribute resources across multiple cloud providers + 3. Investment protection by confidently migrating on premise IT resources to any combination of the leading public cloud platforms, knowing their cloud-hosted instances will be fully supported by EdgeConnect + + + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3397921/moving-to-the-cloud-sd-wan-matters.html + +作者:[Rami Rammaha][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Rami-Rammaha/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/05/istock-899678028-100797709-large.jpg +[2]: https://www.silver-peak.com/sd-wan/sd-wan-explained +[3]: https://www.silver-peak.com/company/tech-partners/cloud/aws +[4]: https://www.silver-peak.com/company/tech-partners/cloud/google-cloud +[5]: https://www.silver-peak.com/company/tech-partners/cloud/microsoft-azure +[6]: https://www.silver-peak.com/company/tech-partners/cloud/oracle-cloud +[7]: https://www.logicmonitor.com/resource/the-future-of-the-cloud-a-cloud-influencers-survey/?utm_medium=pr&utm_source=businesswire&utm_campaign=cloudsurvey +[8]: http://www.networkworld.com/article/3152024/lan-wan/in-the-age-of-digital-transformation-why-sd-wan-plays-a-key-role-in-the-transition.html +[9]: http://www.cnbc.com/2016/11/30/how-amazon-web-services-is-luring-banks-to-the-cloud.html?__source=yahoo%257cfinance%257cheadline%257cheadline%257cstory&par=yahoo&doc=104135637 +[10]: https://www.silver-peak.com/products/unity-edge-connect +[11]: https://www.silver-peak.com/company/tech-partners?strategic_partner_type=69 +[12]: https://www.silver-peak.com/resource-center/automate-connectivity-to-cloud-networking-with-sd-wan diff --git a/sources/talk/20190529 Satellite-based internet possible by year-end, says SpaceX.md b/sources/talk/20190529 Satellite-based internet possible by year-end, says SpaceX.md new file mode 100644 index 0000000000..383fac66ca --- /dev/null +++ b/sources/talk/20190529 Satellite-based internet possible by year-end, says SpaceX.md @@ -0,0 +1,63 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Satellite-based internet possible by year-end, says SpaceX) +[#]: via: (https://www.networkworld.com/article/3398940/space-internet-maybe-end-of-year-says-spacex.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +Satellite-based internet possible by year-end, says SpaceX +====== +Amazon, Tesla-associated SpaceX and OneWeb are emerging as just some of the potential suppliers of a new kind of data-friendly satellite internet service that could bring broadband IoT connectivity to most places on Earth. +![Getty Images][1] + +With SpaceX’s successful launch of an initial array of broadband-internet-carrying satellites last week, and Amazon’s surprising posting of numerous satellite engineering-related job openings on its [job board][2] this month, one might well be asking if the next-generation internet space race is finally getting going. (I first wrote about [OneWeb’s satellite internet plans][3] it was concocting with Airbus four years ago.) + +This new batch of satellite-driven internet systems, if they work and are eventually switched on, could provide broadband to most places, including previously internet-barren locations, such as rural areas. That would be good for high-bandwidth, low-latency remote-internet of things (IoT) and increasingly important edge-server connections for verticals like oil and gas and maritime. [Data could even end up getting stored in compliance-friendly outer space, too][4]. Leaky ground-based connections, also, perhaps a thing of the past. + +Of the principal new internet suppliers, SpaceX has gotten farthest along. That’s in part because it has commercial impetus. It needed to create payload for its numerous rocket projects. The Tesla electric-car-associated company (the two firms share materials science) has not only launched its first tranche of 60 satellites for its own internet constellation, called Starlink, but also successfully launched numerous batches (making up the full constellation of 75 satellites) for Iridium’s replacement, an upgraded constellation called Iridium NEXT. + +[The time of 5G is almost here][5] + +Potential competitor OneWeb launched its first six Airbus-built satellites in February. [It has plans for 900 more][6]. SpaceX has been approved for 4,365 more by the FCC, and Project Kuiper, as Amazon’s space internet project is known, wants to place 3,236 satellites in orbit, according to International Telecommunication Union filings [discovered by _GeekWire_][7] earlier this year. [Startup LeoSat, which I wrote about last year, aims to build an internet backbone constellation][8]. Facebook, too, is exploring [space-delivered internet][9]. + +### Why the move to space? + +Laser technical progress, where data is sent in open, free space, rather than via a restrictive, land-based cable or via traditional radio paths, is partly behind this space-internet rush. “Bits travel faster in free space than in glass-fiber cable,” LeoSat explained last year. Additionally, improving microprocessor tech is also part of the mix. + +One important difference from existing older-generation satellite constellations is that this new generation of internet satellites will be located in low Earth orbit (LEO). Initial Starlink satellites will be placed at about 350 miles above Earth, with later launches deployed at 710 miles. + +There’s an advantage to that. Traditional satellites in geostationary orbit, or GSO, have been deployed about 22,000 miles up. That extra distance versus LEO introduces latency and is one reason earlier generations of Internet satellites are plagued by slow round-trip times. Latency didn’t matter when GSO was introduced in 1964, and commercial satellites, traditionally, have been pitched as one-way video links, such as are used by sporting events for broadcast, and not for data. + +And when will we get to experience these new ISPs? “Starlink is targeted to offer service in the Northern U.S. and Canadian latitudes after six launches,” [SpaceX says on its website][10]. Each launch would deliver about 60 satellites. “SpaceX is targeting two to six launches by the end of this year.” + +Global penetration of the “populated world” could be obtained after 24 launches, it thinks. + +Join the Network World communities on [Facebook][11] and [LinkedIn][12] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3398940/space-internet-maybe-end-of-year-says-spacex.html + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/10/network_iot_world-map_us_globe_nodes_global-100777483-large.jpg +[2]: https://www.amazon.jobs/en/teams/projectkuiper +[3]: https://www.itworld.com/article/2938652/space-based-internet-starts-to-get-serious.html +[4]: https://www.networkworld.com/article/3200242/data-should-be-stored-data-in-space-firm-says.html +[5]: https://www.networkworld.com/article/3354477/mobile-world-congress-the-time-of-5g-is-almost-here.html +[6]: https://www.airbus.com/space/telecommunications-satellites/oneweb-satellites-connection-for-people-all-over-the-globe.html +[7]: https://www.geekwire.com/2019/amazon-lists-scores-jobs-bellevue-project-kuiper-broadband-satellite-operation/ +[8]: https://www.networkworld.com/article/3328645/space-data-backbone-gets-us-approval.html +[9]: https://www.networkworld.com/article/3338081/light-based-computers-to-be-5000-times-faster.html +[10]: https://www.starlink.com/ +[11]: https://www.facebook.com/NetworkWorld/ +[12]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190529 Survey finds SD-WANs are hot, but satisfaction with telcos is not.md b/sources/talk/20190529 Survey finds SD-WANs are hot, but satisfaction with telcos is not.md new file mode 100644 index 0000000000..9b65a6c8dd --- /dev/null +++ b/sources/talk/20190529 Survey finds SD-WANs are hot, but satisfaction with telcos is not.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Survey finds SD-WANs are hot, but satisfaction with telcos is not) +[#]: via: (https://www.networkworld.com/article/3398478/survey-finds-sd-wans-are-hot-but-satisfaction-with-telcos-is-not.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + +Survey finds SD-WANs are hot, but satisfaction with telcos is not +====== +A recent survey of over 400 IT executives by Cato Networks found that legacy telcos might be on the outside looking in for SD-WANs. +![istock][1] + +This week SD-WAN vendor Cato Networks announced the results of its [Telcos and the Future of the WAN in 2019 survey][2]. The study was a mix of companies of all sizes, with 42% being enterprise-class (over 2,500 employees). More than 70% had a network with more than 10 locations, and almost a quarter (24%) had over 100 sites. All of the respondents have a cloud presence, and almost 80% have at least two data centers. The survey had good geographic diversity, with 57% of respondents coming from the U.S. and 24% from Europe. + +Highlights of the survey include the following key findings: + +## **SD-WANs are hot but not a panacea to all networking challenges** + +The survey found that 44% of respondents have already deployed or will deploy an SD-WAN within the next 12 months. This number is up sharply from 25% when Cato ran the survey a year ago. Another 33% are considering SD-WAN but have no immediate plans to deploy. The primary drivers for the evolution of the WAN are improved internet access (46%), increased bandwidth (39%), improved last-mile availability (38%) and reduced WAN costs (37%). It’s good to see cost savings drop to fourth in motivation, since there is so much more to SD-WAN. + +[The time of 5G is almost here][3] + +It’s interesting that the majority of respondents believe SD-WAN alone can’t address all challenges facing the WAN. A whopping 85% stated they would be confronting issues not addressed by SD-WAN alone. This includes secure, local internet breakout, improved visibility, and control over mobile access to cloud apps. This indicates that customers are looking for SD-WAN to be the foundation of the WAN but understand that other technologies need to be deployed as well. + +## **Telco dissatisfaction is high** + +The traditional telco has been a point of frustration for network professionals for years, and the survey spelled that out loud and clear. Prior to being an analyst, I held a number of corporate IT positions and found telcos to be the single most frustrating group of companies to deal with. The problem was, there was no choice. If you need MPLS services, you need a telco. The same can’t be said for SD-WANs, though; businesses have more choices. + +Respondents to the survey ranked telco service as “average.” It’s been well documented that we are now in the customer-experience era and “good enough” service is no longer good enough. Regarding pricing, 54% gave telcos a failing grade. Although price isn’t everything, this will certainly open the door to competitive SD-WAN vendors. Respondents gave the highest marks for overall experience to SaaS providers, followed by cloud computing suppliers. Global telcos scored the lowest of all vendor types. + +A look deeper explains the frustration level. The network is now mission-critical for companies, but 48% stated they are able to reach the support personnel with the right expertise to solve a problem only on a second attempt. No retailer, airline, hotel or other type of company could survive this, but telco customers had no other options for years. + +**[[Prepare to become a Certified Information Security Systems Professional with this comprehensive online course from PluralSight. Now offering a 10-day free trial!][4] ]** + +Another interesting set of data points is the speed at which telcos address customer needs. Digital businesses compete on speed, but telco process is the antithesis of fast. Moves, adds and changes take at least one business day for half of the respondents. Also, 70% indicated that opening a new location takes 15 days, and 38% stated it requires 45 days or more. + +## **Security is now part of SD-WAN** + +The use of broadband, cloud access and other trends raise the bar on security for SD-WAN, and the survey confirmed that respondents are skeptical that SD-WANs could address these issues. Seventy percent believe SD-WANs can’t address malware/ransomware, and 49% don’t think SD-WAN helps with enforcing company policies on mobile users. Because of this, network professionals are forced to buy additional security tools from other vendors, but that can drive up complexity. SD-WAN vendors that have intrinsic security capabilities can use that as a point of differentiation. + +## **Managed services are critical to the growth of SD-WANs** + +The survey found that 75% of respondents are using some kind of managed service provider, versus only 25% using an appliance vendor. This latter number was 32% last year. I’m not surprised by this shift and expect it to continue. Legacy WANs were inefficient but straightforward to deploy. D-WANs are highly agile and more cost-effective, but complexity has gone through the roof. Network engineers need to factor in cloud connectivity, distributed security, application performance, broadband connectivity and other issues. Managed services can help businesses enjoy the benefits of SD-WAN while masking the complexity. + +Despite the desire to use an MSP, respondents don’t want to give up total control. Eighty percent stated they preferred self-service or co-managed models. This further explains the shift away from telcos, since they typically work with fully managed models. + +Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3398478/survey-finds-sd-wans-are-hot-but-satisfaction-with-telcos-is-not.html + +作者:[Zeus Kerravala][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/02/istock-465661573-100750447-large.jpg +[2]: https://www.catonetworks.com/news/digital-transformation-survey/ +[3]: https://www.networkworld.com/article/3354477/mobile-world-congress-the-time-of-5g-is-almost-here.html +[4]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190601 True Hyperconvergence at Scale- HPE Simplivity With Composable Fabric.md b/sources/talk/20190601 True Hyperconvergence at Scale- HPE Simplivity With Composable Fabric.md new file mode 100644 index 0000000000..97eb611ef8 --- /dev/null +++ b/sources/talk/20190601 True Hyperconvergence at Scale- HPE Simplivity With Composable Fabric.md @@ -0,0 +1,28 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (True Hyperconvergence at Scale: HPE Simplivity With Composable Fabric) +[#]: via: (https://www.networkworld.com/article/3399619/true-hyperconvergence-at-scale-hpe-simplivity-with-composable-fabric.html) +[#]: author: (HPE https://www.networkworld.com/author/Michael-Cooney/) + +True Hyperconvergence at Scale: HPE Simplivity With Composable Fabric +====== + +Many hyperconverged solutions only focus on software-defined storage. However, many networking functions and technologies can be consolidated for simplicity and scale in the data center. This video describes how HPE SimpliVity with Composable Fabric gives organizations the power to run any virtual machine anywhere, anytime. Read more about HPE SimpliVity [here][1]. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3399619/true-hyperconvergence-at-scale-hpe-simplivity-with-composable-fabric.html + +作者:[HPE][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Michael-Cooney/ +[b]: https://github.com/lujun9972 +[1]: https://hpe.com/info/simplivity diff --git a/sources/talk/20190602 IoT Roundup- New research on IoT security, Microsoft leans into IoT.md b/sources/talk/20190602 IoT Roundup- New research on IoT security, Microsoft leans into IoT.md new file mode 100644 index 0000000000..6d955c6485 --- /dev/null +++ b/sources/talk/20190602 IoT Roundup- New research on IoT security, Microsoft leans into IoT.md @@ -0,0 +1,71 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (IoT Roundup: New research on IoT security, Microsoft leans into IoT) +[#]: via: (https://www.networkworld.com/article/3398607/iot-roundup-new-research-on-iot-security-microsoft-leans-into-iot.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +IoT Roundup: New research on IoT security, Microsoft leans into IoT +====== +Verizon sets up widely available narrow-band IoT service, while most Americans think IoT manufacturers should ensure their products protect personal information. +As with any technology whose use is expanding at such speed, it can be tough to track exactly what’s going on in the [IoT][1] world – everything from basic usage numbers to customer attitudes to more in-depth slices of the market is constantly changing. Fortunately, the month of May brought several new pieces of research to light, which should help provide at least a partial outline of what’s really happening in IoT. + +### Internet of things polls + +Not all of the news is good. An IPSOS Mori poll performed on behalf of the Internet Society and Consumers International (respectively, an umbrella organization for open development and Internet use and a broad-based consumer advocacy group) found that, despite the skyrocketing numbers of smart devices in circulation around the world, more than half of users in large parts of the western world don’t trust those devices to safeguard their privacy. + +**More on IoT:** + + * [What is the IoT? How the internet of things works][2] + * [What is edge computing and how it’s changing the network][3] + * [Most powerful Internet of Things companies][4] + * [10 Hot IoT startups to watch][5] + * [The 6 ways to make money in IoT][6] + * [What is digital twin technology? [and why it matters]][7] + * [Blockchain, service-centric networking key to IoT success][8] + * [Getting grounded in IoT networking and security][9] + * [Building IoT-ready networks must become a priority][10] + * [What is the Industrial IoT? [And why the stakes are so high]][11] + + + +While almost 70 percent of respondents owned connected devices, 55 percent said they didn’t feel their personal information was adequately protected by manufacturers. A further 28 percent said they had avoided using connected devices – smart home, fitness tracking and similar consumer gadgetry – primarily because they were concerned over privacy issues, and a whopping 85 percent of Americans agreed with the argument that manufacturers had a responsibility to produce devices that protected personal information. + +Those concerns are understandable, according to data from the Ponemon Institute, a tech-research organization. Its survey of corporate risk and security personnel, released in early May, found that there have been few concerted efforts to limit exposure to IoT-based security threats, and that those threats are sharply on the rise when compared to past years, with the percentage of organizations that had experienced a data breach related to unsecured IoT devices rising from 15 percent in fiscal 2017 to 26 percent in fiscal 2019. + +Beyond a lack of organizational wherewithal to address those threats, part of the problem in some verticals is technical. Security vendor Forescout said earlier this month that its research showed 40 percent of all healthcare IT environments had more than 20 different operating systems, and more than 30 percent had more than 100 – hardly an ideal situation for smooth patching and updating. + +To continue reading this article register now + +[Get Free Access][12] + +[Learn More][13] Existing Users [Sign In][12] + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3398607/iot-roundup-new-research-on-iot-security-microsoft-leans-into-iot.html + +作者:[Jon Gold][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[2]: https://www.networkworld.com/article/3207535/internet-of-things/what-is-the-iot-how-the-internet-of-things-works.html +[3]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[4]: https://www.networkworld.com/article/2287045/internet-of-things/wireless-153629-10-most-powerful-internet-of-things-companies.html +[5]: https://www.networkworld.com/article/3270961/internet-of-things/10-hot-iot-startups-to-watch.html +[6]: https://www.networkworld.com/article/3279346/internet-of-things/the-6-ways-to-make-money-in-iot.html +[7]: https://www.networkworld.com/article/3280225/internet-of-things/what-is-digital-twin-technology-and-why-it-matters.html +[8]: https://www.networkworld.com/article/3276313/internet-of-things/blockchain-service-centric-networking-key-to-iot-success.html +[9]: https://www.networkworld.com/article/3269736/internet-of-things/getting-grounded-in-iot-networking-and-security.html +[10]: https://www.networkworld.com/article/3276304/internet-of-things/building-iot-ready-networks-must-become-a-priority.html +[11]: https://www.networkworld.com/article/3243928/internet-of-things/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html +[12]: javascript:// +[13]: /learn-about-insider/ diff --git a/sources/talk/20190603 It-s time for the IoT to -optimize for trust.md b/sources/talk/20190603 It-s time for the IoT to -optimize for trust.md new file mode 100644 index 0000000000..cc5aa9db7c --- /dev/null +++ b/sources/talk/20190603 It-s time for the IoT to -optimize for trust.md @@ -0,0 +1,102 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (It’s time for the IoT to 'optimize for trust') +[#]: via: (https://www.networkworld.com/article/3399817/its-time-for-the-iot-to-optimize-for-trust.html) +[#]: author: (Fredric Paul https://www.networkworld.com/author/Fredric-Paul/) + +It’s time for the IoT to 'optimize for trust' +====== +If we can't trust the internet of things (IoT) to gather accurate data and use it appropriately, IoT adoption and innovation are likely to suffer. +![Bose][1] + +One of the strengths of internet of things (IoT) technology is that it can do so many things well. From smart toothbrushes to predictive maintenance on jetliners, the IoT has more use cases than you can count. The result is that various IoT uses cases require optimization for particular characteristics, from cost to speed to long life, as well as myriad others. + +But in a recent post, "[How the internet of things will change advertising][2]" (which you should definitely read), the always-insightful Stacy Higginbotham tossed in a line that I can’t stop thinking about: “It's crucial that the IoT optimizes for trust." + +**[ Read also: Network World's[corporate guide to addressing IoT security][3] ]** + +### Trust is the IoT's most important attribute + +Higginbotham was talking about optimizing for trust as opposed to clicks, but really, trust is more important than just about any other value in the IoT. It’s more important than bandwidth usage, more important than power usage, more important than cost, more important than reliability, and even more important than security and privacy (though they are obviously related). In fact, trust is the critical factor in almost every aspect of the IoT. + +Don’t believe me? Let’s take a quick look at some recent developments in the field: + +For one thing, IoT devices often don’t take good care of the data they collect from you. Over 90% of data transactions on IoT devices are not fully encrypted, according to a new [study from security company Zscaler][4]. The [problem][5], apparently, is that many companies have large numbers of consumer-grade IoT devices on their networks. In addition, many IoT devices are attached to the companies’ general networks, and if that network is breached, the IoT devices and data may also be compromised. + +In some cases, ownership of IoT data can raise surprisingly serious trust concerns. According to [Kaiser Health News][6], smartphone sleep apps, as well as smart beds and smart mattress pads, gather amazingly personal information: “It knows when you go to sleep. It knows when you toss and turn. It may even be able to tell when you’re having sex.” And while companies such as Sleep Number say they don’t share the data they gather, their written privacy policies clearly state that they _can_. + +### **Lack of trust may lead to new laws** + +In California, meanwhile, "lawmakers are pushing for new privacy rules affecting smart speakers” such as the Amazon Echo. According to the _[LA Times][7]_ , the idea is “to ensure that the devices don’t record private conversations without permission,” requiring a specific opt-in process. Why is this an issue? Because consumers—and their elected representatives—don’t trust that Amazon, or any IoT vendor, will do the right thing with the data it collects from the IoT devices it sells—perhaps because it turns out that thousands of [Amazon employees have been listening in on what Alexa users are][8] saying to their Echo devices. + +The trust issues get even trickier when you consider that Amazon reportedly considered letting Alexa listen to users even without a wake word like “Alexa” or “computer,” and is reportedly working on [wearable devices designed to read human emotions][9] from listening to your voice. + +“The trust has been breached,” said California Assemblyman Jordan Cunningham (R-Templeton) to the _LA Times_. + +As critics of the bill ([AB 1395][10]) point out, the restrictions matter because voice assistants require this data to improve their ability to correctly understand and respond to requests. + +### **Some first steps toward increasing trust** + +Perhaps recognizing that the IoT needs to be optimized for trust so that we are comfortable letting it do its job, Amazon recently introduced a new Alexa voice command: “[Delete what I said today][11].” + +Moves like that, while welcome, will likely not be enough. + +For example, a [new United Nations report][12] suggests that “voice assistants reinforce harmful gender stereotypes” when using female-sounding voices and names like Alexa and Siri. Put simply, “Siri’s ‘female’ obsequiousness—and the servility expressed by so many other digital assistants projected as young women—provides a powerful illustration of gender biases coded into technology products, pervasive in the technology sector and apparent in digital skills education.” I'm not sure IoT vendors are eager—or equipped—to tackle issues like that. + +**More on IoT:** + + * [What is the IoT? How the internet of things works][13] + * [What is edge computing and how it’s changing the network][14] + * [Most powerful Internet of Things companies][15] + * [10 Hot IoT startups to watch][16] + * [The 6 ways to make money in IoT][17] + * [What is digital twin technology? [and why it matters]][18] + * [Blockchain, service-centric networking key to IoT success][19] + * [Getting grounded in IoT networking and security][20] + * [Building IoT-ready networks must become a priority][21] + * [What is the Industrial IoT? [And why the stakes are so high]][22] + + + +Join the Network World communities on [Facebook][23] and [LinkedIn][24] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3399817/its-time-for-the-iot-to-optimize-for-trust.html + +作者:[Fredric Paul][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Fredric-Paul/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/09/bose-sleepbuds-2-100771579-large.jpg +[2]: https://mailchi.mp/iotpodcast/stacey-on-iot-how-iot-changes-advertising?e=6bf9beb394 +[3]: https://www.networkworld.com/article/3269165/internet-of-things/a-corporate-guide-to-addressing-iot-security-concerns.html +[4]: https://www.zscaler.com/blogs/research/iot-traffic-enterprise-rising-so-are-threats +[5]: https://www.csoonline.com/article/3397044/over-90-of-data-transactions-on-iot-devices-are-unencrypted.html +[6]: https://khn.org/news/a-wake-up-call-on-data-collecting-smart-beds-and-sleep-apps/ +[7]: https://www.latimes.com/politics/la-pol-ca-alexa-google-home-privacy-rules-california-20190528-story.html +[8]: https://www.usatoday.com/story/tech/2019/04/11/amazon-employees-listening-alexa-customers/3434732002/ +[9]: https://www.bloomberg.com/news/articles/2019-05-23/amazon-is-working-on-a-wearable-device-that-reads-human-emotions +[10]: https://leginfo.legislature.ca.gov/faces/billTextClient.xhtml?bill_id=201920200AB1395 +[11]: https://venturebeat.com/2019/05/29/amazon-launches-alexa-delete-what-i-said-today-voice-command/ +[12]: https://unesdoc.unesco.org/ark:/48223/pf0000367416.page=1 +[13]: https://www.networkworld.com/article/3207535/internet-of-things/what-is-the-iot-how-the-internet-of-things-works.html +[14]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[15]: https://www.networkworld.com/article/2287045/internet-of-things/wireless-153629-10-most-powerful-internet-of-things-companies.html +[16]: https://www.networkworld.com/article/3270961/internet-of-things/10-hot-iot-startups-to-watch.html +[17]: https://www.networkworld.com/article/3279346/internet-of-things/the-6-ways-to-make-money-in-iot.html +[18]: https://www.networkworld.com/article/3280225/internet-of-things/what-is-digital-twin-technology-and-why-it-matters.html +[19]: https://www.networkworld.com/article/3276313/internet-of-things/blockchain-service-centric-networking-key-to-iot-success.html +[20]: https://www.networkworld.com/article/3269736/internet-of-things/getting-grounded-in-iot-networking-and-security.html +[21]: https://www.networkworld.com/article/3276304/internet-of-things/building-iot-ready-networks-must-become-a-priority.html +[22]: https://www.networkworld.com/article/3243928/internet-of-things/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html +[23]: https://www.facebook.com/NetworkWorld/ +[24]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190604 Data center workloads become more complex despite promises to the contrary.md b/sources/talk/20190604 Data center workloads become more complex despite promises to the contrary.md new file mode 100644 index 0000000000..31d127e77d --- /dev/null +++ b/sources/talk/20190604 Data center workloads become more complex despite promises to the contrary.md @@ -0,0 +1,64 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Data center workloads become more complex despite promises to the contrary) +[#]: via: (https://www.networkworld.com/article/3400086/data-center-workloads-become-more-complex-despite-promises-to-the-contrary.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Data center workloads become more complex despite promises to the contrary +====== +The data center is shouldering a greater burden than ever, despite promises of ease and the cloud. +![gorodenkoff / Getty Images][1] + +Data centers are becoming more complex and still run the majority of workloads despite the promises of simplicity of deployment through automation and hyperconverged infrastructure (HCI), not to mention how the cloud was supposed to take over workloads. + +That’s the finding of the Uptime Institute's latest [annual global data center survey][2] (registration required). The majority of IT loads still run on enterprise data centers even in the face of cloud adoption, putting pressure on administrators to have to manage workloads across the hybrid infrastructure. + +**[ Learn[how server disaggregation can boost data center efficiency][3] | Get regularly scheduled insights: [Sign up for Network World newsletters][4] ]** + +With workloads like artificial intelligence (AI) and machine language coming to the forefront, that means facilities face greater power and cooling challenges, since AI is extremely processor-intensive. That puts strain on data center administrators and power and cooling vendors alike to keep up with the growth in demand. + +On top of it all, everyone is struggling to get enough staff with the right skills. + +### Outages, staffing problems, lack of public cloud visibility among top concerns + +Among the key findings of Uptime's report: + + * The large, privately owned enterprise data center facility still forms the bedrock of corporate IT and is expected to be running half of all workloads in 2021. + * The staffing problem affecting most of the data center sector has only worsened. Sixty-one percent of respondents said they had difficulty retaining or recruiting staff, up from 55% a year earlier. + * Outages continue to cause significant problems for operators. Just over a third (34%) of all respondents had an outage or severe IT service degradation in the past year, while half (50%) had an outage or severe IT service degradation in the past three years. + * Ten percent of all respondents said their most recent significant outage cost more than $1 million. + * A lack of visibility, transparency, and accountability of public cloud services is a major concern for enterprises that have mission-critical applications. A fifth of operators surveyed said they would be more likely to put workloads in a public cloud if there were more visibility. Half of those using public cloud for mission-critical applications also said they do not have adequate visibility. + * Improvements in data center facility energy efficiency have flattened out and even deteriorated slightly in the past two years. The average PUE for 2019 is 1.67. + * Rack power density is rising after a long period of flat or minor increases, causing many to rethink cooling strategies. + * Power loss was the single biggest cause of outages, accounting for one-third of outages. Sixty percent of respondents said their data center’s outage could have been prevented with better management/processes or configuration. + + + +Traditionally data centers are improving their reliability through "rigorous attention to power, infrastructure, connectivity and on-site IT replication," the Uptime report says. The solution, though, is pricy. Data center operators are getting distributed resiliency through active-active data centers where at least two active data centers replicate data to each other. Uptime found up to 40% of those surveyed were using this method. + +The Uptime survey was conducted in March and April of this year, surveying 1,100 end users in more than 50 countries and dividing them into two groups: the IT managers, owners, and operators of data centers and the suppliers, designers, and consultants that service the industry. + +Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3400086/data-center-workloads-become-more-complex-despite-promises-to-the-contrary.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/05/cso_cloud_computing_backups_it_engineer_data_center_server_racks_connections_by_gorodenkoff_gettyimages-943065400_3x2_2400x1600-100796535-large.jpg +[2]: https://uptimeinstitute.com/2019-data-center-industry-survey-results +[3]: https://www.networkworld.com/article/3266624/how-server-disaggregation-could-make-cloud-datacenters-more-efficient.html +[4]: https://www.networkworld.com/newsletters/signup.html +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190604 Moving to the Cloud- SD-WAN Matters- Part 2.md b/sources/talk/20190604 Moving to the Cloud- SD-WAN Matters- Part 2.md new file mode 100644 index 0000000000..2f68bd6f59 --- /dev/null +++ b/sources/talk/20190604 Moving to the Cloud- SD-WAN Matters- Part 2.md @@ -0,0 +1,66 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Moving to the Cloud? SD-WAN Matters! Part 2) +[#]: via: (https://www.networkworld.com/article/3398488/moving-to-the-cloud-sd-wan-matters-part-2.html) +[#]: author: (Rami Rammaha https://www.networkworld.com/author/Rami-Rammaha/) + +Moving to the Cloud? SD-WAN Matters! Part 2 +====== + +![istock][1] + +This is the second installment of the blog series exploring how enterprises can realize the full transformation promise of the cloud by shifting to a business first networking model powered by a business-driven [SD-WAN][2]. The first installment explored automating secure IPsec connectivity and intelligently steering traffic to cloud providers. We also framed the direct correlation between moving to the cloud and adopting an SD-WAN. In this blog, we will expand upon several additional challenges that can be addressed with a business-driven SD-WAN when embracing the cloud: + +### Simplifying and automating security zone-based segmentation + +Securing cloud-first branches requires a robust multi-level approach that addresses following considerations: + + * Restricting outside traffic coming into the branch to sessions exclusively initiated by internal users with a built-in stateful firewall, avoiding appliance sprawl and lowering operational costs; this is referred to as the app whitelist model + * Encrypting communications between end points within the SD-WAN fabric and between branch locations and public cloud instances + * Service chaining traffic to a cloud-hosted security service like [Zscaler][3] for Layer 7 inspection and analytics for internet-bound traffic + * Segmenting traffic spanning the branch, WAN and data center/cloud + * Centralizing policy orchestration and automation of zone-based firewall, VLAN and WAN overlays + + + +A traditional device-centric WAN approach for security segmentation requires the time-consuming manual configuration of routers and/or firewalls on a device-by-device and site-by-site basis. This is not only complex and cumbersome, but it simply can’t scale to 100s or 1000s of sites. Anusha Vaidyanathan, director of product management at Silver Peak, explains how to automate end-to-end zone-based segmentation, emphasizing the advantages of a business-driven approach in this [lightboard video][4]. + +### Delivering the Highest Quality of Experience to IT teams + +The goal for enterprise IT is enabling business agility and increasing operational efficiency. The traditional router-centric WAN approach doesn’t provide the best quality of experience for IT as management and on-going network operations are manual and time consuming, device-centric, cumbersome, error-prone and inefficient. + +A business-driven SD-WAN such as the Silver Peak [Unity EdgeConnect™][5] unified SD-WAN edge platform centralizes the orchestration of business-driven policies. EdgeConnect automation, machine learning and open APIs easily integrate with third-party management tools and real-time visibility tools to deliver the highest quality of experience for IT, enabling them to reclaim nights and weekends. Manav Mishra, vice president of product management at Silver Peak, explains the latest Silver Peak innovations in this [lightboard video][6]. + +As enterprises become increasingly dependent on the cloud and embrace a multi-cloud strategy, they must address a number of new challenges: + + * A centralized approach to securely embracing the cloud and the internet + * How to extend the on-premise data center to a public cloud and migrating workloads between private and public cloud, taking application portability into account + * Deliver consistent high application performance and availability to hosted applications whether they reside in the data center, private or public clouds or are delivered as SaaS services + * A proactive way to quickly resolve complex issues that span the data center and cloud as well as multiple WAN transport services by harnessing the power of advanced visibility and analytics tools + + + +The business-driven EdgeConnect SD-WAN edge platform enables enterprise IT organizations to easily and consistently embrace the public cloud. Unified security and performance capabilities with automation deliver the highest quality of experience for both users and IT while lowering overall WAN expenditures. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3398488/moving-to-the-cloud-sd-wan-matters-part-2.html + +作者:[Rami Rammaha][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Rami-Rammaha/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/05/istock-909772962-100797711-large.jpg +[2]: https://www.silver-peak.com/sd-wan/sd-wan-explained +[3]: https://www.silver-peak.com/company/tech-partners/zscaler +[4]: https://www.silver-peak.com/resource-center/how-to-create-sd-wan-security-zones-in-edgeconnect +[5]: https://www.silver-peak.com/products/unity-edge-connect +[6]: https://www.silver-peak.com/resource-center/how-to-optimize-quality-of-experience-for-it-using-sd-wan diff --git a/sources/talk/20190604 Why Emacs.md b/sources/talk/20190604 Why Emacs.md new file mode 100644 index 0000000000..0d9b12ba1a --- /dev/null +++ b/sources/talk/20190604 Why Emacs.md @@ -0,0 +1,94 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why Emacs) +[#]: via: (https://saurabhkukade.github.io/Why-Emacs/) +[#]: author: (Saurabh Kukade http://saurabhkukade.github.io/) + +Why Emacs +====== +![Image of Emacs][1] + +> “Emacs outshines all other editing software in approximately the same way that the noonday sun does the stars. It is not just bigger and brighter; it simply makes everything else vanish.” + +> -Neal Stephenson, “In the Beginning was the Command Line” + +### Introduction + +This is my first blog post about Emacs. I want to discuss step by step customization of Emacs for beginner. If you’re new to Emacs then you are in the right place, if you’re already familiar with Emacs then that is even better, I assure you that we will get to know many new things in here. + +Before getting into how to customize Emacs and what are the exciting features of Emacs I want to write about “why Emacs”. + +### Why Emacs? + +This was first question crossed my mind when one wise man asked me to try Emacs instead of VIM. Well, I am not writing this article to discuss a battle between two editors VIM and Emacs. That is a another story for another day. But Why Emacs? Well here are some things that justifies that Emacs is powerful and highly customizable. + +### 41 Years! + +Initial release year of Emacs is 1976 that means Emacs is standing and adapting changes from last 41 years. + +41 years of time for a software is huge and that makes Emacs is one of the best Software Engineering product. + +### Lisp (Emacs Lisp) + +If you are lisp programmer (lisper) then I don’t need to explain you. But for those who don’t know Lisp and its dialects like Scheme, Clojure then Lisp (and all dialects of Lips) is powerful programming language and it stands different from other languages because of its unique property of “Homoiconicity”. + +As Emacs is implemented in C and Emacs Lisp (Emacs Lisp is a dialect of the Lisp programming language) it makes Emacs what is because, + + * The simple syntax of Lisp, together with the powerful editing features made possible by that simple syntax, add up to a more convenient programming system than is practical with other languages. Lisp and extensible editors are made for each other. + + * The simplicity of Lisp syntax makes intelligent editing operations easier to implement, while the complexity of other languages discourages their users from implementing similar operations for them. + + + + +### Highly Customizable + +To any programmer, tools gives power and convenience for reading, writing and managing a code. + +Hence, if a tool is programmatic-ally customizable then that makes it even more powerful. + +Emacs has above property and in fact is itself one of best tool known for its flexibility and easy customization. Emacs provides basic commands and key configuration for editing a text. This commands and key-configuration are editable and extensible. + +Beside basic configuration, Emacs is not biased towards any specific language for customization. One can customize Emacs for any programming language or extend easily existing customization. + +Emacs provides the consistent environment for multiple programming languages, email, organizer (via org-mode), a shell/interpreter, note taking, and document writing. + +For customizing you don’t need to learn Emacs-lisp from scratch. You can use existing packages available and that’s it. Installing and managing packages in Emacs is easy, Emacs has in-built package manager for it. + +Customization is very portable, one just need to place a file or directory containing personal customization file(s) in the right place and it’s done for getting personal customization to new place. ## Huge platform Support + +Emacs supports Lisp, Ruby, Python, PHP, Java, Erlang, JavaScript, C, C++, Prolog, Tcl, AWK, PostScript, Clojure, Scala, Perl, Haskell, Elixir all of these languages and more like mysql, pgsql etc. Because of the powerful Lisp core, Emacs is easy to extend to add support for new languages if need to. + +Also one can use the built-in IRC client ERC along with BitlBee to connect to your favorite chat services, or use the Jabber package to hop on any XMPP service. + +### Org-mode + +No matter if you are programmer or not. Org mode is for everyone. Org mode lets you to plan projects and organize schedule. It can be also use for publish notes and documents to different formats, like LaTeX->pdf, html, and markdown. + +In fact, Org-mode is so awesome enough that many non-Emacs users started learn Emacs. + +### Final note + +There are number of reason to argue that Emacs is cool and awesome to use. But I just wanted you to give glimpse of why to try Emacs. In the upcoming post I will be writing step by step information to customize Emacs from scratch to awesome IDE. + +Thank you! + +Please don’t forget to comment your thoughts and suggestions below. + +-------------------------------------------------------------------------------- + +via: https://saurabhkukade.github.io/Why-Emacs/ + +作者:[Saurabh Kukade][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://saurabhkukade.github.io/ +[b]: https://github.com/lujun9972 +[1]: https://saurabhkukade.github.io/img/emacs.jpeg diff --git a/sources/talk/20190606 Cloud adoption drives the evolution of application delivery controllers.md b/sources/talk/20190606 Cloud adoption drives the evolution of application delivery controllers.md new file mode 100644 index 0000000000..d7b22353c4 --- /dev/null +++ b/sources/talk/20190606 Cloud adoption drives the evolution of application delivery controllers.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Cloud adoption drives the evolution of application delivery controllers) +[#]: via: (https://www.networkworld.com/article/3400897/cloud-adoption-drives-the-evolution-of-application-delivery-controllers.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + +Cloud adoption drives the evolution of application delivery controllers +====== +Application delivery controllers (ADCs) are on the precipice of shifting from traditional hardware appliances to software form factors. +![Aramyan / Getty Images / Microsoft][1] + +Migrating to a cloud computing model will obviously have an impact on the infrastructure that’s deployed. This shift has already been seen in the areas of servers, storage, and networking, as those technologies have evolved to a “software-defined” model. And it appears that application delivery controllers (ADCs) are on the precipice of a similar shift. + +In fact, a new ZK Research [study about cloud computing adoption and the impact on ADCs][2] found that, when looking at the deployment model, hardware appliances are the most widely deployed — with 55% having fully deployed or are currently testing and only 15% currently researching hardware. (Note: I am an employee of ZK Research.) + +Juxtapose this with containerized ADCs where only 34% have deployed or are testing but 24% are currently researching and it shows that software in containers will outpace hardware for growth. Not surprisingly, software on bare metal and in virtual machines showed similar although lower, “researching” numbers that support the thesis that the market is undergoing a shift from hardware to software. + +**[ Read also:[How to make hybrid cloud work][3] ]** + +The study, conducted in collaboration with Kemp Technologies, surveyed 203 respondents from the U.K. and U.S. The demographic split was done to understand regional differences. An equal number of mid and large size enterprises were looked at, with 44% being from over 5,000 employees and the other 56% from companies that have 300 to 5,000 people. + +### Incumbency helps but isn’t a fait accompli for future ADC purchases + +The primary tenet of my research has always been that incumbents are threatened when markets transition, and this is something I wanted to investigate in the study. The survey asked whether buyers would consider an alternative as they evolve their applications from legacy (mode 1) to cloud-native (mode 2). The results offer a bit of good news and bad news for the incumbent providers. Only 8% said they would definitely select a new vendor, but 35% said they would not change. That means the other 57% will look at alternatives. This is sensible, as the requirements for cloud ADCs are different than ones that support traditional applications. + +### IT pros want better automation capabilities + +This begs the question as to what features ADC buyers want for a cloud environment versus traditional ones. The survey asked specifically what features would be most appealing in future purchases, and the top response was automation, followed by central management, application analytics, on-demand scaling (which is a form of automation), and visibility. + +The desire to automate was a positive sign for the evolution of buyer mindset. Just a few years ago, the mere mention of automation would have sent IT pros into a panic. The reality is that IT can’t operate effectively without automation, and technology professionals are starting to understand that. + +The reason automation is needed is that manual changes are holding businesses back. The survey asked how the speed of ADC changes impacts the speed at which applications are rolled out, and a whopping 60% said it creates significant or minor delays. In an era of DevOps and continuous innovation, multiple minor delays create a drag on the business and can cause it to fall behind is more agile competitors. + +![][4] + +### ADC upgrades and service provisioning benefit most from automation + +The survey also drilled down on specific ADC tasks to see where automation would have the most impact. Respondents were asked how long certain tasks took, answering in minutes, days, weeks, or months. Shockingly, there wasn’t a single task where the majority said it could be done in minutes. The closest was adding DNS entries for new virtual IP addresses (VIPs) where 46% said they could do that in minutes. + +Upgrading, provisioning new load balancers, and provisioning new VIPs took the longest. Looking ahead, this foreshadows big problems. As the data center gets more disaggregated and distributed, IT will deploy more software-based ADCs in more places. Taking days or weeks or month to perform these functions will cause the organization to fall behind. + +The study clearly shows changes are in the air for the ADC market. For IT pros, I strongly recommend that as the environment shifts to the cloud, it’s prudent to evaluate new vendors. By all means, see what your incumbent vendor has, but look at least at two others that offer software-based solutions. Also, there should be a focus on automating as much as possible, so the primary evaluation criteria for ADCs should be how easy it is to implement automation. + +Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3400897/cloud-adoption-drives-the-evolution-of-application-delivery-controllers.html + +作者:[Zeus Kerravala][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/05/cw_microsoft_sharepoint_vs_onedrive_clouds_and_hands_by_aramyan_gettyimages-909772962_2400x1600-100796932-large.jpg +[2]: https://kemptechnologies.com/research-papers/adc-market-research-study-zeus-kerravala/?utm_source=zkresearch&utm_medium=referral&utm_campaign=zkresearch&utm_term=zkresearch&utm_content=zkresearch +[3]: https://www.networkworld.com/article/3119362/hybrid-cloud/how-to-make-hybrid-cloud-work.html#tk.nww-fsb +[4]: https://images.idgesg.net/images/article/2019/06/adc-survey-zk-research-100798593-large.jpg +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190606 For enterprise storage, persistent memory is here to stay.md b/sources/talk/20190606 For enterprise storage, persistent memory is here to stay.md new file mode 100644 index 0000000000..3da91bb311 --- /dev/null +++ b/sources/talk/20190606 For enterprise storage, persistent memory is here to stay.md @@ -0,0 +1,118 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (For enterprise storage, persistent memory is here to stay) +[#]: via: (https://www.networkworld.com/article/3398988/for-enterprise-storage-persistent-memory-is-here-to-stay.html) +[#]: author: (John Edwards ) + +For enterprise storage, persistent memory is here to stay +====== +Persistent memory – also known as storage class memory – has tantalized data center operators for many years. A new technology promises the key to success. +![Thinkstock][1] + +It's hard to remember a time when semiconductor vendors haven't promised a fast, cost-effective and reliable persistent memory technology to anxious [data center][2] operators. Now, after many years of waiting and disappointment, technology may have finally caught up with the hype to make persistent memory a practical proposition. + +High-capacity persistent memory, also known as storage class memory ([SCM][3]), is fast and directly addressable like dynamic random-access memory (DRAM), yet is able to retain stored data even after its power has been switched off—intentionally or unintentionally. The technology can be used in data centers to replace cheaper, yet far slower traditional persistent storage components, such as [hard disk drives][4] (HDD) and [solid-state drives][5] (SSD). + +**Learn more about enterprise storage** + + * [Why NVMe over Fabric matters][6] + * [What is hyperconvergence?][7] + * [How NVMe is changing enterprise storage][8] + * [Making the right hyperconvergence choice: HCI hardware or software?][9] + + + +Persistent memory can also be used to replace DRAM itself in some situations without imposing a significant speed penalty. In this role, persistent memory can deliver crucial operational benefits, such as lightning-fast database-server restarts during maintenance, power emergencies and other expected and unanticipated reboot situations. + +Many different types of strategic operational applications and databases, particularly those that require low-latency, high durability and strong data consistency, can benefit from persistent memory. The technology also has the potential to accelerate virtual machine (VM) storage and deliver higher performance to multi-node, distributed-cloud applications. + +In a sense, persistent memory marks a rebirth of core memory. "Computers in the ‘50s to ‘70s used magnetic core memory, which was direct access, non-volatile memory," says Doug Wong, a senior member of [Toshiba Memory America's][10] technical staff. "Magnetic core memory was displaced by SRAM and DRAM, which are both volatile semiconductor memories." + +One of the first persistent memory devices to come to market is [Intel’s Optane DC][11]. Other vendors that have released persistent memory products or are planning to do so include [Samsung][12], Toshiba America Memory and [SK Hynix][13]. + +### Persistent memory: performance + reliability + +With persistent memory, data centers have a unique opportunity to gain faster performance and lower latency without enduring massive technology disruption. "It's faster than regular solid-state NAND flash-type storage, but you're also getting the benefit that it’s persistent," says Greg Schulz, a senior advisory analyst at vendor-independent storage advisory firm [StorageIO.][14] "It's the best of both worlds." + +Yet persistent memory offers adopters much more than speedy, reliable storage. In an ideal IT world, all of the data associated with an application would reside within DRAM to achieve maximum performance. "This is currently not practical due to limited DRAM and the fact that DRAM is volatile—data is lost when power fails," observes Scott Nelson, senior vice president and general manager of Toshiba Memory America's memory business unit. + +Persistent memory transports compatible applications to an "always on" status, providing continuous access to large datasets through increased system memory capacity, says Kristie Mann, [Intel's][15] director of marketing for data center memory and storage. She notes that Optane DC can supply data centers with up to three-times more system memory capacity (as much as 36TBs), system restarts in seconds versus minutes, 36% more virtual machines per node, and up to 8-times better performance on [Apache Spark][16], a widely used open-source distributed general-purpose cluster-computing framework. + +System memory currently represents 60% of total platform costs, Mann says. She observes that Optane DC persistent memory provides significant customer value by delivering 1.2x performance/dollar on key customer workloads. "This value will dramatically change memory/storage economics and accelerate the data-centric era," she predicts. + +### Where will persistent memory infiltrate enterprise storage? + +Persistent memory is likely to first enter the IT mainstream with minimal fanfare, serving as a high-performance caching layer for high performance SSDs. "This could be adopted relatively-quickly," Nelson observes. Yet this intermediary role promises to be merely a stepping-stone to increasingly crucial applications. + +Over the next few years, persistent technology will impact data centers serving enterprises across an array of sectors. "Anywhere time is money," Schulz says. "It could be financial services, but it could also be consumer-facing or sales-facing operations." + +Persistent memory supercharges anything data-related that requires extreme speed at extreme scale, observes Andrew Gooding, vice president of engineering at [Aerospike][17], which delivered the first commercially available open database optimized for use with Intel Optane DC. + +Machine learning is just one of many applications that stand to benefit from persistent memory. Gooding notes that ad tech firms, which rely on machine learning to understand consumers' reactions to online advertising campaigns, should find their work made much easier and more effective by persistent memory. "They’re collecting information as users within an ad campaign browse the web," he says. "If they can read and write all that data quickly, they can then apply machine-learning algorithms and tailor specific ads for users in real time." + +Meanwhile, as automakers become increasingly reliant on data insights, persistent memory promises to help them crunch numbers and refine sophisticated new technologies at breakneck speeds. "In the auto industry, manufacturers face massive data challenges in autonomous vehicles, where 20 exabytes of data needs to be processed in real time, and they're using self-training machine-learning algorithms to help with that," Gooding explains. "There are so many fields where huge amounts of data need to be processed quickly with machine-learning techniques—fraud detection, astronomy... the list goes on." + +Intel, like other persistent memory vendors, expects cloud service providers to be eager adopters, targeting various types of in-memory database services. Google, for example, is applying persistent memory to big data workloads on non-relational databases from vendors such as Aerospike and [Redis Labs][18], Mann says. + +High-performance computing (HPC) is yet another area where persistent memory promises to make a tremendous impact. [CERN][19], the European Organization for Nuclear Research, is using Intel's Optane DC to significantly reduce wait times for scientific computing. "The efficiency of their algorithms depends on ... persistent memory, and CERN considers it a major breakthrough that is necessary to the work they are doing," Mann observes. + +### How to prepare storage infrastructure for persistent memory + +Before jumping onto the persistent memory bandwagon, organizations need to carefully scrutinize their IT infrastructure to determine the precise locations of any existing data bottlenecks. This task will be primary application-dependent, Wong notes. "If there is significant performance degradation due to delays associated with access to data stored in non-volatile storage—SSD or HDD—then an SCM tier will improve performance," he explains. Yet some applications will probably not benefit from persistent memory, such as compute-bound applications where CPU performance is the bottleneck. + +Developers may need to reevaluate fundamental parts of their storage and application architectures, Gooding says. "They will need to know how to program with persistent memory," he notes. "How, for example, to make sure writes are flushed to the actual persistent memory device when necessary, as opposed to just sitting in the CPU cache." + +To leverage all of persistent memory's potential benefits, significant changes may also be required in how code is designed. When moving applications from DRAM and flash to persistent memory, developers will need to consider, for instance, what happens when a program crashes and restarts. "Right now, if they write code that leaks memory, that leaked memory is recovered on restart," Gooding explains. With persistent memory, that isn't necessarily the case. "Developers need to make sure the code is designed to reconstruct a consistent state when a program restarts," he notes. "You may not realize how much your designs rely on the traditional combination of fast volatile DRAM and block storage, so it can be tricky to change your code designs for something completely new like persistent memory." + +Older versions of operating systems may also need to be updated to accommodate the new technology, although newer OSes are gradually becoming persistent memory aware, Schulz says. "In other words, if they detect that persistent memory is available, then they know how to utilize that either as a cache, or some other memory." + +Hypervisors, such as [Hyper-V][20] and [VMware][21], now know how to leverage persistent memory to support productivity, performance and rapid restarts. By utilizing persistent memory along with the latest versions of VMware, a whole system can see an uplift in speed and also maximize the number of VMs to fit on a single host, says Ian McClarty, CEO and president of data center operator [PhoenixNAP Global IT Services][22]. "This is a great use case for companies who want to own less hardware or service providers who want to maximize hardware to virtual machine deployments." + +Many key enterprise applications, particularly databases, are also becoming persistent memory aware. SQL Server and [SAP’s][23] flagship [HANA][24] database management platform have both embraced persistent memory. "The SAP HANA platform is commonly used across multiple industries to process data and transactions, and then run advanced analytics ... to deliver real-time insights," Mann observes. + +In terms of timing, enterprises and IT organizations should begin persistent memory planning immediately, Schulz recommends. "You should be talking with your vendors and understanding their roadmap, their plans, for not only supporting this technology, but also in what mode: as storage, as memory." + +Join the Network World communities on [Facebook][25] and [LinkedIn][26] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3398988/for-enterprise-storage-persistent-memory-is-here-to-stay.html + +作者:[John Edwards][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2017/08/file_folder_storage_sharing_thinkstock_477492571_3x2-100732889-large.jpg +[2]: https://www.networkworld.com/article/3353637/the-data-center-is-being-reimagined-not-disappearing.html +[3]: https://www.networkworld.com/article/3026720/the-next-generation-of-storage-disruption-storage-class-memory.html +[4]: https://www.networkworld.com/article/2159948/hard-disk-drives-vs--solid-state-drives--are-ssds-finally-worth-the-money-.html +[5]: https://www.networkworld.com/article/3326058/what-is-an-ssd.html +[6]: https://www.networkworld.com/article/3273583/why-nvme-over-fabric-matters.html +[7]: https://www.networkworld.com/article/3207567/what-is-hyperconvergence +[8]: https://www.networkworld.com/article/3280991/what-is-nvme-and-how-is-it-changing-enterprise-storage.html +[9]: https://www.networkworld.com/article/3318683/making-the-right-hyperconvergence-choice-hci-hardware-or-software +[10]: https://business.toshiba-memory.com/en-us/top.html +[11]: https://www.intel.com/content/www/us/en/architecture-and-technology/optane-dc-persistent-memory.html +[12]: https://www.samsung.com/semiconductor/ +[13]: https://www.skhynix.com/eng/index.jsp +[14]: https://storageio.com/ +[15]: https://www.intel.com/content/www/us/en/homepage.html +[16]: https://spark.apache.org/ +[17]: https://www.aerospike.com/ +[18]: https://redislabs.com/ +[19]: https://home.cern/ +[20]: https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/about/ +[21]: https://www.vmware.com/ +[22]: https://phoenixnap.com/ +[23]: https://www.sap.com/index.html +[24]: https://www.sap.com/products/hana.html +[25]: https://www.facebook.com/NetworkWorld/ +[26]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190606 Self-learning sensor chips won-t need networks.md b/sources/talk/20190606 Self-learning sensor chips won-t need networks.md new file mode 100644 index 0000000000..c5abec5426 --- /dev/null +++ b/sources/talk/20190606 Self-learning sensor chips won-t need networks.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Self-learning sensor chips won’t need networks) +[#]: via: (https://www.networkworld.com/article/3400659/self-learning-sensor-chips-wont-need-networks.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +Self-learning sensor chips won’t need networks +====== +Scientists working on new, machine-learning networks aim to embed everything needed for artificial intelligence (AI) onto a processor, eliminating the need to transfer data to the cloud or computers. +![Jiraroj Praditcharoenkul / Getty Images][1] + +Tiny, intelligent microelectronics should be used to perform as much sensor processing as possible on-chip rather than wasting resources by sending often un-needed, duplicated raw data to the cloud or computers. So say scientists behind new, machine-learning networks that aim to embed everything needed for artificial intelligence (AI) onto a processor. + +“This opens the door for many new applications, starting from real-time evaluation of sensor data,” says [Fraunhofer Institute for Microelectronic Circuits and Systems][2] on its website. No delays sending unnecessary data onwards, along with speedy processing, means theoretically there is zero latency. + +Plus, on-microprocessor, self-learning means the embedded, or sensor, devices can self-calibrate. They can even be “completely reconfigured to perform a totally different task afterwards,” the institute says. “An embedded system with different tasks is possible.” + +**[ Also read:[What is edge computing?][3] and [How edge networking and IoT will reshape data centers][4] ]** + +Much internet of things (IoT) data sent through networks is redundant and wastes resources: a temperature reading taken every 10 minutes, say, when the ambient temperature hasn’t changed, is one example. In fact, one only needs to know when the temperature has changed, and maybe then only when thresholds have been met. + +### Neural network-on-sensor chip + +The commercial German research organization says it’s developing a specific RISC-V microprocessor with a special hardware accelerator designed for a [brain-copying, artificial neural network (ANN) it has developed][5]. The architecture could ultimately be suitable for the condition-monitoring or predictive sensors of the kind we will likely see more of in the industrial internet of things (IIoT). + +Key to Fraunhofer IMS’s [Artificial Intelligence for Embedded Systems (AIfES)][6] is that the self-learning takes place at chip level rather than in the cloud or on a computer, and that it is independent of “connectivity towards a cloud or a powerful and resource-hungry processing entity.” But it still offers a “full AI mechanism, like independent learning,” + +It’s “decentralized AI,” says Fraunhofer IMS. "It’s not focused towards big-data processing.” + +Indeed, with these kinds of systems, no connection is actually required for the raw data, just for the post-analytical results, if indeed needed. Swarming can even replace that. Swarming lets sensors talk to one another, sharing relevant information without even getting a host network involved. + +“It is possible to build a network from small and adaptive systems that share tasks among themselves,” Fraunhofer IMS says. + +Other benefits in decentralized neural networks include that they can be more secure than the cloud. Because all processing takes place on the microprocessor, “no sensitive data needs to be transferred,” Fraunhofer IMS explains. + +### Other edge computing research + +The Fraunhofer researchers aren’t the only academics who believe entire networks become redundant with neuristor, brain-like AI chips. Binghamton University and Georgia Tech are working together on similar edge-oriented tech. + +“The idea is we want to have these chips that can do all the functioning in the chip, rather than messages back and forth with some sort of large server,” Binghamton said on its website when [I wrote about the university's work last year][7]. + +One of the advantages of no major communications linking: Not only don't you have to worry about internet resilience, but also that energy is saved creating the link. Energy efficiency is an ambition in the sensor world — replacing batteries is time consuming, expensive, and sometimes, in the case of remote locations, extremely difficult. + +Memory or storage for swaths of raw data awaiting transfer to be processed at a data center, or similar, doesn’t have to be provided either — it’s been processed at the source, so it can be discarded. + +**More about edge networking:** + + * [How edge networking and IoT will reshape data centers][4] + * [Edge computing best practices][8] + * [How edge computing can help secure the IoT][9] + + + +Join the Network World communities on [Facebook][10] and [LinkedIn][11] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3400659/self-learning-sensor-chips-wont-need-networks.html + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/industry_4-0_industrial_iot_smart_factory_automation_by_jiraroj_praditcharoenkul_gettyimages-902668940_2400x1600-100788458-large.jpg +[2]: https://www.ims.fraunhofer.de/en.html +[3]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[4]: https://www.networkworld.com/article/3291790/data-center/how-edge-networking-and-iot-will-reshape-data-centers.html +[5]: https://www.ims.fraunhofer.de/en/Business_Units_and_Core_Competencies/Electronic_Assistance_Systems/News/AIfES-Artificial_Intelligence_for_Embedded_Systems.html +[6]: https://www.ims.fraunhofer.de/en/Business_Units_and_Core_Competencies/Electronic_Assistance_Systems/technologies/Artificial-Intelligence-for-Embedded-Systems-AIfES.html +[7]: https://www.networkworld.com/article/3326557/edge-chips-could-render-some-networks-useless.html +[8]: https://www.networkworld.com/article/3331978/lan-wan/edge-computing-best-practices.html +[9]: https://www.networkworld.com/article/3331905/internet-of-things/how-edge-computing-can-help-secure-the-iot.html +[10]: https://www.facebook.com/NetworkWorld/ +[11]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190606 What to do when yesterday-s technology won-t meet today-s support needs.md b/sources/talk/20190606 What to do when yesterday-s technology won-t meet today-s support needs.md new file mode 100644 index 0000000000..622537f2f9 --- /dev/null +++ b/sources/talk/20190606 What to do when yesterday-s technology won-t meet today-s support needs.md @@ -0,0 +1,53 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What to do when yesterday’s technology won’t meet today’s support needs) +[#]: via: (https://www.networkworld.com/article/3399875/what-to-do-when-yesterday-s-technology-won-t-meet-today-s-support-needs.html) +[#]: author: (Anand Rajaram ) + +What to do when yesterday’s technology won’t meet today’s support needs +====== + +![iStock][1] + +You probably already know that end user technology is exploding and are feeling the effects of it in your support organization every day. Remember when IT sanctioned and standardized every hardware and software instance in the workplace? Those days are long gone. Today, it’s the driving force of productivity that dictates what will or won’t be used – and that can be hard on a support organization. + +Whatever users need to do their jobs better, faster, more efficiently is what you are seeing come into the workplace. So naturally, that’s what comes into your service desk too. Support organizations see all kinds of [devices, applications, systems, and equipment][2], and it’s adding a great deal of complexity and demand to keep up with. In fact, four of the top five factors causing support ticket volumes to rise are attributed to new and current technology. + +To keep up with the steady [rise of tickets][3] and stay out in front of this surge, support organizations need to take a good, hard look at the processes and technologies they use. Yesterday’s methods won’t cut it. The landscape is simply changing too fast. Supporting today’s users and getting them back to work fast requires an expanding set of skills and tools. + +So where do you start with a new technology project? Just because a technology is new or hyped doesn’t mean it’s right for your organization. It’s important to understand your project goals and the experience you really want to create and match your technology choices to those goals. But don’t go it alone. Talk to your teams. Get intimately familiar with how your support organization works today. Understand your customers’ needs at a deep level. And bring the right people to the table to cover: + + * Business problem analysis: What existing business issue are stakeholders unhappy with? + * The impact of that problem: How does that issue justify making a change? + * Process automation analysis: What area(s) can technology help automate? + * Other solutions: Have you considered any other options besides technology? + + + +With these questions answered, you’re ready to entertain your technology options. Put together your “must-haves” in a requirements document and reach out to potential suppliers. During the initial information-gathering stage, assess if the supplier understands your goals and how their technology helps you meet them. To narrow the field, compare solutions side by side against your goals. Select the top two or three for more in-depth product demos before moving into product evaluations. By the time you’re ready for implementation, you have empirical, practical knowledge of how the solution will perform against your business goals. + +The key takeaway is this: Technology for technology’s sake is just technology. But technology that drives business value is a solution. If you want a solution that drives results for your organization and your customers, it’s worth following a strategic selection process to match your goals with the best technology for the job. + +For more insight, check out the [LogMeIn Rescue][4] and HDI webinar “[Technology and the Service Desk: Expanding Mission, Expanding Skills”][5]. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3399875/what-to-do-when-yesterday-s-technology-won-t-meet-today-s-support-needs.html + +作者:[Anand Rajaram][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/06/istock-1019006240-100798168-large.jpg +[2]: https://www.logmeinrescue.com/resources/datasheets/infographic-mobile-support-are-your-employees-getting-what-they-need?utm_source=idg%20media&utm_medium=display&utm_campaign=native&sfdc= +[3]: https://www.logmeinrescue.com/resources/analyst-reports/the-importance-of-remote-support-in-a-shift-left-world?utm_source=idg%20media&utm_medium=display&utm_campaign=native&sfdc= +[4]: https://www.logmeinrescue.com/?utm_source=idg%20media&utm_medium=display&utm_campaign=native&sfdc= +[5]: https://www.brighttalk.com/webcast/8855/312289?utm_source=LogMeIn7&utm_medium=brighttalk&utm_campaign=312289 diff --git a/sources/talk/20190611 6 ways to make enterprise IoT cost effective.md b/sources/talk/20190611 6 ways to make enterprise IoT cost effective.md new file mode 100644 index 0000000000..492262c617 --- /dev/null +++ b/sources/talk/20190611 6 ways to make enterprise IoT cost effective.md @@ -0,0 +1,89 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (6 ways to make enterprise IoT cost effective) +[#]: via: (https://www.networkworld.com/article/3401082/6-ways-to-make-enterprise-iot-cost-effective.html) +[#]: author: (Fredric Paul https://www.networkworld.com/author/Fredric-Paul/) + +6 ways to make enterprise IoT cost effective +====== +Rob Mesirow, a principal at PwC’s Connected Solutions unit, offers tips for successfully implementing internet of things (IoT) projects without breaking the bank. +![DavidLeshem / Getty][1] + +There’s little question that the internet of things (IoT) holds enormous potential for the enterprise, in everything from asset tracking to compliance. + +But enterprise uses of IoT technology are still evolving, and it’s not yet entirely clear which use cases and practices currently make economic and business sense. So, I was thrilled to trade emails recently with [Rob Mesirow][2], a principal at [PwC’s Connected Solutions][3] unit, about how to make enterprise IoT implementations as cost effective as possible. + +“The IoT isn’t just about technology (hardware, sensors, software, networks, communications, the cloud, analytics, APIs),” Mesirow said, “though tech is obviously essential. It also includes ensuring cybersecurity, managing data governance, upskilling the workforce and creating a receptive workplace culture, building trust in the IoT, developing interoperability, and creating business partnerships and ecosystems—all part of a foundation that’s vital to a successful IoT implementation.” + +**[ Also read:[Enterprise IoT: Companies want solutions in these 4 areas][4] ]** + +Yes, that sounds complicated—and a lot of work for a still-hard-to-quantify return. Fortunately, though, Mesirow offered up some tips on how companies can make their IoT implementations as cost effective as possible. + +### 1\. Don’t wait for better technology + +Mesirow advised against waiting to implement IoT projects until you can deploy emerging technology such as [5G networks][5]. That makes sense, as long as your implementation doesn’t specifically require capabilities available only in the new technology. + +### 2\. Start with the basics, and scale up as needed + +“Companies need to start with the basics—building one app/task at a time—instead of jumping ahead with enterprise-wide implementations and ecosystems,” Mesirow said. + +“There’s no need to start an IoT initiative by tackling a huge, expensive ecosystem. Instead, begin with one manageable use case, and build up and out from there. The IoT can inexpensively automate many everyday tasks to increase effectiveness, employee productivity, and revenue.” + +After you pick the low-hanging fruit, it’s time to become more ambitious. + +“After getting a few successful pilots established, businesses can then scale up as needed, building on the established foundation of business processes, people experience, and technology," Mesirow said, + +### 3\. Make dumb things smart + +Of course, identifying the ripest low-hanging fruit isn’t always easy. + +“Companies need to focus on making dumb things smart, deploying infrastructure that’s not going to break the bank, and providing enterprise customers the opportunity to experience what data intelligence can do for their business,” Mesirow said. “Once they do that, things will take off.” + +### 4\. Leverage lower-cost networks + +“One key to building an IoT inexpensively is to use low-power, low-cost networks (Low-Power Wide-Area Networks (LPWAN)) to provide IoT services, which reduces costs significantly,” Mesirow said. + +Naturally, he mentioned that PwC has three separate platforms with some 80 products that hang off those platforms, which he said cost “a fraction of traditional IoT offerings, with security and privacy built in.” + +Despite the product pitch, though, Mesirow is right to call out the efficiencies involved in using low-cost, low-power networks instead of more expensive existing cellular. + +### 5\. Balance security vs. cost + +Companies need to plan their IoT network with costs vs. security in mind, Mesirow said. “Open-source networks will be less expensive, but there may be security concerns,” he said. + +That’s true, of course, but there may be security concerns in _any_ network, not just open-source solutions. Still, Mesirow’s overall point remains valid: Enterprises need to carefully consider all the trade-offs they’re making in their IoT efforts. + +### 6\. Account for _all_ the value IoT provides + +Finally, Mesirow pointed out that “much of the cost-effectiveness comes from the _value_ the IoT provides,” and its important to consider the return, not just the investment. + +“For example,” Mesirow said, the IoT “increases productivity by enabling the remote monitoring and control of business operations. It saves on energy costs by automatically turning off lights and HVAC when spaces are vacant, and predictive maintenance alerts lead to fewer machine repairs. And geolocation can lead to personalized marketing to customer smartphones, which can increase sales to nearby stores.” + +**[ Now read this:[5 reasons the IoT needs its own networks][6] ]** + +Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3401082/6-ways-to-make-enterprise-iot-cost-effective.html + +作者:[Fredric Paul][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Fredric-Paul/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/money_financial_salary_growth_currency_by-davidleshem-100787975-large.jpg +[2]: https://twitter.com/robmesirow +[3]: https://digital.pwc.com/content/pwc-digital/en/products/connected-solutions.html +[4]: https://www.networkworld.com/article/3396128/the-state-of-enterprise-iot-companies-want-solutions-for-these-4-areas.html +[5]: https://www.networkworld.com/article/3203489/what-is-5g-how-is-it-better-than-4g.html +[6]: https://www.networkworld.com/article/3284506/5-reasons-the-iot-needs-its-own-networks.html +[7]: https://www.facebook.com/NetworkWorld/ +[8]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190611 The carbon footprints of IT shops that train AI models are huge.md b/sources/talk/20190611 The carbon footprints of IT shops that train AI models are huge.md new file mode 100644 index 0000000000..b440b8d65b --- /dev/null +++ b/sources/talk/20190611 The carbon footprints of IT shops that train AI models are huge.md @@ -0,0 +1,68 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The carbon footprints of IT shops that train AI models are huge) +[#]: via: (https://www.networkworld.com/article/3401919/the-carbon-footprints-of-it-shops-that-train-ai-models-are-huge.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +The carbon footprints of IT shops that train AI models are huge +====== +Artificial intelligence (AI) model training can generate five times more carbon dioxide than a car does in a lifetime, researchers at the University of Massachusetts, Amherst find. +![ipopba / Getty Images][1] + +A new research paper from the University of Massachusetts, Amherst looked at the carbon dioxide (CO2) generated over the course of training several common large artificial intelligence (AI) models and found that the process can generate nearly five times the amount as an average American car over its lifetime plus the process of making the car itself. + +The [paper][2] specifically examined the model training process for natural-language processing (NLP), which is how AI handles natural language interactions. The study found that during the training process, more than 626,000 pounds of carbon dioxide is generated. + +This is significant, since AI training is one IT process that has remained firmly on-premises and not moved to the cloud. Very expensive equipment is needed, as is large volumes of data, so the cloud isn’t right work for most AI training, and the report notes this. Plus, IT shops want to keep that kind of IP in house. So, if you are experimenting with AI, that power bill is going to go up. + +**[ Read also:[How to plan a software-defined data-center network][3] ]** + +While the report used carbon dioxide as a measure, that’s still the product of electricity generation. Training involves the use of the most powerful processors, typically Nvidia GPUs, and they are not known for being low-power draws. And as the paper notes, “model training also incurs a substantial cost to the environment due to the energy required to power this hardware for weeks or months at a time.” + +Training is the most processor-intensive portion of AI. It can take days, weeks, or even months to “learn” what the model needs to know. That means power-hungry Nvidia GPUs running at full utilization for the entire time. In this case, how to handle and process natural language questions rather than broken sentences of keywords like your typical Google search. + +The report said training one model with a neural architecture generated 626,155 pounds of CO2. By contrast, one passenger flying round trip between New York and San Francisco would generate 1,984 pounds of CO2, an average American would generate 11,023 pounds in one year, and a car would generate 126,000 pounds over the course of its lifetime. + +### How the researchers calculated the CO2 amounts + +The researchers used four models in the NLP field that have been responsible for the biggest leaps in performance. They are Transformer, ELMo, BERT, and GPT-2. They trained all of the models on a single Nvidia Titan X GPU, with the exception of ELMo which was trained on three Nvidia GTX 1080 Ti GPUs. Each model was trained for a maximum of one day. + +**[[Learn Java from beginning concepts to advanced design patterns in this comprehensive 12-part course!][4] ]** + +They then used the number of training hours listed in the model’s original papers to calculate the total energy consumed over the complete training process. That number was converted into pounds of carbon dioxide equivalent based on the average energy mix in the U.S. + +The big takeaway is that computational costs start out relatively inexpensive, but they mushroom when additional tuning steps were used to increase the model’s final accuracy. A tuning process known as neural architecture search ([NAS][5]) is the worst offender because it does so much processing. NAS is an algorithm that searches for the best neural network architecture. It is seriously advanced AI and requires the most processing time and power. + +The researchers suggest it would be beneficial to directly compare different models to perform a cost-benefit (accuracy) analysis. + +“To address this, when proposing a model that is meant to be re-trained for downstream use, such as re-training on a new domain or fine-tuning on a new task, authors should report training time and computational resources required, as well as model sensitivity to hyperparameters. This will enable direct comparison across models, allowing subsequent consumers of these models to accurately assess whether the required computational resources,” the authors wrote. + +They also say researchers who are cost-constrained should pool resources and avoid the cloud, as cloud compute time is more expensive. In an example, it said a GPU server with eight Nvidia 1080 Ti GPUs and supporting hardware is available for approximately $20,000. To develop the sample models used in their study, that hardware would cost $145,000, plus electricity to run the models, about half the estimated cost to use on-demand cloud GPUs. + +“Unlike money spent on cloud compute, however, that invested in centralized resources would continue to pay off as resources are shared across many projects. A government-funded academic compute cloud would provide equitable access to all researchers,” they wrote. + +Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3401919/the-carbon-footprints-of-it-shops-that-train-ai-models-are-huge.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/05/ai-vendor-relationship-management_artificial-intelligence_hand-on-virtual-screen-100795246-large.jpg +[2]: https://arxiv.org/abs/1906.02243 +[3]: https://www.networkworld.com/article/3284352/data-center/how-to-plan-a-software-defined-data-center-network.html +[4]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fjava +[5]: https://www.oreilly.com/ideas/what-is-neural-architecture-search +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190612 IoT security vs. privacy- Which is a bigger issue.md b/sources/talk/20190612 IoT security vs. privacy- Which is a bigger issue.md new file mode 100644 index 0000000000..2f06f6afc1 --- /dev/null +++ b/sources/talk/20190612 IoT security vs. privacy- Which is a bigger issue.md @@ -0,0 +1,95 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (IoT security vs. privacy: Which is a bigger issue?) +[#]: via: (https://www.networkworld.com/article/3401522/iot-security-vs-privacy-which-is-a-bigger-issue.html) +[#]: author: (Fredric Paul https://www.networkworld.com/author/Fredric-Paul/) + +IoT security vs. privacy: Which is a bigger issue? +====== +When it comes to the internet of things (IoT), security has long been a key concern. But privacy issues could be an even bigger threat. +![Ring][1] + +If you follow the news surrounding the internet of things (IoT), you know that security issues have long been a key concern for IoT consumers, enterprises, and vendors. Those issues are very real, but I’m becoming increasingly convinced that related but fundamentally different _privacy_ vulnerabilities may well be an even bigger threat to the success of the IoT. + +In June alone, we’ve seen a flood of IoT privacy issues inundate the news cycle, and observers are increasingly sounding the alarm that IoT users should be paying attention to what happens to the data collected by IoT devices. + +**[ Also read:[It’s time for the IoT to 'optimize for trust'][2] and [A corporate guide to addressing IoT security][2] ]** + +Predictably, most of the teeth-gnashing has come on the consumer side, but that doesn’t mean enterprises users are immune to the issue. One the one hand, just like consumers, companies are vulnerable to their proprietary information being improperly shared and misused. More immediately, companies may face backlash from their own customers if they are seen as not properly guarding the data they collect via the IoT. Too often, in fact, enterprises shoot themselves in the foot on privacy issues, with practices that range from tone-deaf to exploitative to downright illegal—leading almost [two-thirds (63%) of consumers to describe IoT data collection as “creepy,”][3] while more than half (53%) “distrust connected devices to protect their privacy and handle information in a responsible manner.” + +### Ring becoming the poster child for IoT privacy issues + +As a case in point, let’s look at the case of [Ring, the IoT doorbell company now owned by Amazon][4]. Ring is [reportedly working with police departments to build a video surveillance network in residential neighborhoods][5]. Police in more than 50 cities and towns across the country are apparently offering free or discounted Ring doorbells, and sometimes requiring the recipients to share footage for use in investigations. (While [Ring touts the security benefits][6] of working with law enforcement, it has asked police departments to end the practice of _requiring_ users to hand over footage, as it appears to violate the devices’ terms of service.) + +Many privacy advocates are troubled by this degree of cooperation between police and Ring, but that’s only part of the problem. Last year, for example, [Ring workers in Ukraine reportedly watched customer feeds][7]. Amazingly, though, even that only scratches the surface of the privacy flaps surrounding Ring. + +### Guilty by video? + +According to [Motherboard][8], “Ring is using video captured by its doorbell cameras in Facebook advertisements that ask users to identify and call the cops on a woman whom local police say is a suspected thief.” While the police are apparently appreciative of the “additional eyes that may see this woman and recognize her,” the ad calls the woman a thief even though she has not been charged with a crime, much less convicted! + +Ring may be today’s poster child for IoT privacy issues, but IoT privacy complaints are widespread. In many cases, it comes down to what IoT users—or others nearby—are getting in return for giving up their privacy. According to the [Guardian][9], for example, Google’s Sidewalk Labs smart city project is little more than “surveillance capitalism.” And while car owners may get a discount on auto insurance in return for sharing their driving data, that relationship is hardly set in stone. It may not be long before drivers have to give up their data just to get insurance at all. + +**[[Prepare to become a Certified Information Security Systems Professional with this comprehensive online course from PluralSight. Now offering a 10-day free trial!][10] ]** + +And as the recent [data breach at the U.S. Customs and Border Protection][11] once again demonstrates, private data is “[a genie without a bottle][12].” No matter what legal or technical protections are put in place, the data may always be revealed or used in unforeseen ways. Heck, when you put it all together, it’s enough to make you wonder [whether doorbells really need to be smart][13] at all? + +**Read more about IoT:** + + * [Google’s biggest, craziest ‘moonshot’ yet][14] + * [What is the IoT? How the internet of things works][15] + * [What is edge computing and how it’s changing the network][16] + * [Most powerful internet of things companies][17] + * [10 Hot IoT startups to watch][18] + * [The 6 ways to make money in IoT][19] + * [What is digital twin technology? [and why it matters]][20] + * [Blockchain, service-centric networking key to IoT success][21] + * [Getting grounded in IoT networking and security][22] + * [Building IoT-ready networks must become a priority][23] + * [What is the Industrial IoT? [And why the stakes are so high]][24] + + + +Join the Network World communities on [Facebook][25] and [LinkedIn][26] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3401522/iot-security-vs-privacy-which-is-a-bigger-issue.html + +作者:[Fredric Paul][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Fredric-Paul/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/04/ringvideodoorbellpro-100794084-large.jpg +[2]: https://www.networkworld.com/article/3269165/internet-of-things/a-corporate-guide-to-addressing-iot-security-concerns.html +[3]: https://www.cpomagazine.com/data-privacy/consumers-still-concerned-about-iot-security-and-privacy-issues/ +[4]: https://www.cnbc.com/2018/02/27/amazon-buys-ring-a-former-shark-tank-reject.html +[5]: https://www.cnet.com/features/amazons-helping-police-build-a-surveillance-network-with-ring-doorbells/ +[6]: https://blog.ring.com/2019/02/14/how-rings-neighbors-creates-safer-more-connected-communities/ +[7]: https://www.theinformation.com/go/b7668a689a +[8]: https://www.vice.com/en_us/article/pajm5z/amazon-home-surveillance-company-ring-law-enforcement-advertisements +[9]: https://www.theguardian.com/cities/2019/jun/06/toronto-smart-city-google-project-privacy-concerns +[10]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr +[11]: https://www.washingtonpost.com/technology/2019/06/10/us-customs-border-protection-says-photos-travelers-into-out-country-were-recently-taken-data-breach/?utm_term=.0f3a38aa40ca +[12]: https://smartbear.com/blog/test-and-monitor/data-scientists-are-sexy-and-7-more-surprises-from/ +[13]: https://slate.com/tag/should-this-thing-be-smart +[14]: https://www.networkworld.com/article/3058036/google-s-biggest-craziest-moonshot-yet.html +[15]: https://www.networkworld.com/article/3207535/internet-of-things/what-is-the-iot-how-the-internet-of-things-works.html +[16]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[17]: https://www.networkworld.com/article/2287045/internet-of-things/wireless-153629-10-most-powerful-internet-of-things-companies.html +[18]: https://www.networkworld.com/article/3270961/internet-of-things/10-hot-iot-startups-to-watch.html +[19]: https://www.networkworld.com/article/3279346/internet-of-things/the-6-ways-to-make-money-in-iot.html +[20]: https://www.networkworld.com/article/3280225/internet-of-things/what-is-digital-twin-technology-and-why-it-matters.html +[21]: https://www.networkworld.com/article/3276313/internet-of-things/blockchain-service-centric-networking-key-to-iot-success.html +[22]: https://www.networkworld.com/article/3269736/internet-of-things/getting-grounded-in-iot-networking-and-security.html +[23]: https://www.networkworld.com/article/3276304/internet-of-things/building-iot-ready-networks-must-become-a-priority.html +[24]: https://www.networkworld.com/article/3243928/internet-of-things/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html +[25]: https://www.facebook.com/NetworkWorld/ +[26]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190612 Software Defined Perimeter (SDP)- Creating a new network perimeter.md b/sources/talk/20190612 Software Defined Perimeter (SDP)- Creating a new network perimeter.md new file mode 100644 index 0000000000..88a540e875 --- /dev/null +++ b/sources/talk/20190612 Software Defined Perimeter (SDP)- Creating a new network perimeter.md @@ -0,0 +1,121 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Software Defined Perimeter (SDP): Creating a new network perimeter) +[#]: via: (https://www.networkworld.com/article/3402258/software-defined-perimeter-sdp-creating-a-new-network-perimeter.html) +[#]: author: (Matt Conran https://www.networkworld.com/author/Matt-Conran/) + +Software Defined Perimeter (SDP): Creating a new network perimeter +====== +Considering the way networks work today and the change in traffic patterns; both internal and to the cloud, this limits the effect of the fixed perimeter. +![monsitj / Getty Images][1] + +Networks were initially designed to create internal segments that were separated from the external world by using a fixed perimeter. The internal network was deemed trustworthy, whereas the external was considered hostile. However, this is still the foundation for most networking professionals even though a lot has changed since the inception of the design. + +More often than not the fixed perimeter consists of a number of network and security appliances, thereby creating a service chained stack, resulting in appliance sprawl. Typically, the appliances that a user may need to pass to get to the internal LAN may vary. But generally, the stack would consist of global load balancers, external firewall, DDoS appliance, VPN concentrator, internal firewall and eventually LAN segments. + +The perimeter approach based its design on visibility and accessibility. If an entity external to the network can’t see an internal resource, then access cannot be gained. As a result, external entities were blocked from coming in, yet internal entities were permitted to passage out. However, it worked only to a certain degree. Realistically, the fixed network perimeter will always be breachable; it's just a matter of time. Someone with enough skill will eventually get through. + +**[ Related:[MPLS explained – What you need to know about multi-protocol label switching][2]** + +### Environmental changes – the cloud and mobile workforce + +Considering the way networks work today and the change in traffic patterns; both internal and to the cloud, this limits the effect of the fixed perimeter. Nowadays, we have a very fluid network perimeter with many points of entry. + +Imagine a castle with a portcullis that was used to gain access. To gain entry into the portcullis was easy as we just needed to pass one guard. There was only one way in and one way out. But today, in this digital world, we have so many small doors and ways to enter, all of which need to be individually protected. + +This boils down to the introduction of cloud-based application services and changing the location of the perimeter. Therefore, the existing networking equipment used for the perimeter is topologically ill-located. Nowadays, everything that is important is outside the perimeter, such as, remote access workers, SaaS, IaaS and PaaS-based applications. + +Users require access to the resources in various cloud services regardless of where the resources are located, resulting in complex-to-control multi-cloud environments. Objectively, the users do not and should not care where the applications are located. They just require access to the application. Also, the increased use of mobile workforce that demands anytime and anywhere access from a variety of devices has challenged the enterprises to support this dynamic workforce. + +There is also an increasing number of devices, such as, BYOD, on-site contractors, and partners that will continue to grow internal to the network. This ultimately leads to a world of over-connected networks. + +### Over-connected networks + +Over-connected networks result in complex configurations of network appliances. This results in large and complex policies without any context. + +They provide a level of coarse-grained access to a variety of services where the IP address does not correspond to the actual user. Traditional appliances that use static configurations to limit the incoming and outgoing traffic are commonly based on information in the IP packet and the port number. + +Essentially, there is no notion of policy and explanation of why a given source IP address is on the list. This approach fails to take into consideration any notion of trust and dynamically adjust access in relation to the device, users and application request events. + +### Problems with IP addresses + +Back in the early 1990s, RFC 1597 declared three IP ranges reserved for private use: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. If an end host was configured with one of these addresses, it was considered more secure. However, this assumption of trust was shattered with the passage of time and it still haunts us today. + +Network Address Translation (NAT) also changed things to a great extent. NAT allowed internal trusted hosts to communicate directly with the external untrusted hosts. However, since Transmission Control Protocol (TCP) is bidirectional, it allows the data to be injected by the external hosts while connecting back to the internal hosts. + +Also, there is no contextual information regarding the IP addresses as the sole purpose revolved around connectivity. If you have the IP address of someone, you can connect to them. The authentication was handled higher up in the stack. + +Not only do user’s IP addresses change regularly, but there’s also not a one-to-one correspondence between the users and IP addresses. Anyone can communicate from any IP address they please and also insert themselves between you and the trusted resource. + +Have you ever heard of the 20-year old computer that responds to an internet control message protocol (ICMP) request, yet no one knows where it is? But this would not exist on a zero trust network as the network is dark until the administrator turns the lights on with a whitelist policy rule set. This is contrary to the legacy black policy rule set. You can find more information on zero trust in my course: [Zero Trust Networking: The Big Picture][3]. + +Therefore, we can’t just rely on the IP addresses and expect them to do much more other than connect. As a result, we have to move away from the IP addresses and network location as the proxy for access trust. The network location can longer be the driver of network access levels. It is not fully equipped to decide the trust of a device, user or application. + +### Visibility – a major gap + +When we analyze networking and its flaws, visibility is a major gap in today’s hybrid environments. By and large, enterprise networks are complex beasts. More than often networking pros do not have accurate data or insights into who or what is accessing the network resource. + +I.T does not have the visibility in place to detect, for example, insecure devices, unauthorized users and potentially harmful connections that could propagate malware or perform data exfiltration. + +Also, once you know how network elements connect, how do you ensure that they don’t reconnect through a broader definition of connectivity? For this, you need contextual visibility. You need full visibility into the network to see who, what, when, and how they are connecting with the device. + +### What’s the workaround? + +A new approach is needed that enables the application owners to protect the infrastructure located in a public or private cloud and on-premise data center. This new network architecture is known as [software-defined perimeter][4] (SDP). Back in 2013, Cloud Security Alliance (CSA) launched the SDP initiative, a project designed to develop the architecture for creating more robust networks. + +The principles behind SDPs are not entirely new. Organizations within the DoD and Intelligence Communities (IC) have implemented a similar network architecture that is based on authentication and authorization prior to network access. + +Typically, every internal resource is hidden behind an appliance. And a user must authenticate before visibility of the authorized services is made available and access is granted. + +### Applying the zero trust framework + +SDP is an extension to [zero trust][5] which removes the implicit trust from the network. The concept of SDP started with Google’s BeyondCorp, which is the general direction that the industry is heading to right now. + +Google’s BeyondCorp puts forward the idea that the corporate network does not have any meaning. The trust regarding accessing an application is set by a static network perimeter containing a central appliance. This appliance permits the inbound and outbound access based on a very coarse policy. + +However, access to the application should be based on other parameters such as who the user is, the judgment of the security stance of the device, followed by some continuous assessment of the session. Rationally, only then should access be permitted. + +Let’s face it, the assumption that internal traffic can be trusted is flawed and zero trust assumes that all hosts internal to the network are internet facing, thereby hostile. + +### What is software-defined perimeter (SDP)? + +The SDP aims to deploy perimeter functionality for dynamically provisioned perimeters meant for clouds, hybrid environments, and on-premise data center infrastructures. There is often a dynamic tunnel that automatically gets created during the session. That is a one-to-one mapping between the requesting entity and the trusted resource. The important point to note here is that perimeters are formed not solely to obey a fixed location already design by the network team. + +SDP relies on two major pillars and these are the authentication and authorization stages. SDPs require endpoints to authenticate and be authorized first before obtaining network access to the protected entities. Then, encrypted connections are created in real-time between the requesting systems and application infrastructure. + +Authenticating and authorizing the users and their devices before even allowing a single packet to reach the target service, enforces what's known as least privilege at the network layer. Essentially, the concept of least privilege is for an entity to be granted only the minimum privileges that it needs to get its work done. Within a zero trust network, privilege is more dynamic than it would be in traditional networks since it uses many different attributes of activity to determine the trust score. + +### The dark network + +Connectivity is based on a need-to-know model. Under this model, no DNS information, internal IP addresses or visible ports of internal network infrastructure are transmitted. This is the reason why SDP assets are considered as “dark”. As a result, SDP isolates any concerns about the network and application. The applications and users are considered abstract, be it on-premise or in the cloud, which becomes irrelevant to the assigned policy. + +Access is granted directly between the users and their devices to the application and resource, regardless of the underlying network infrastructure. There simply is no concept of inside and outside of the network. This ultimately removes the network location point as a position of advantage and also eliminates the excessive implicit trust that IP addresses offer. + +**This article is published as part of the IDG Contributor Network.[Want to Join?][6]** + +Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3402258/software-defined-perimeter-sdp-creating-a-new-network-perimeter.html + +作者:[Matt Conran][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Matt-Conran/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/03/sdn_software-defined-network_architecture-100791938-large.jpg +[2]: https://www.networkworld.com/article/2297171/sd-wan/network-security-mpls-explained.html +[3]: http://pluralsight.com/courses/zero-trust-networking-big-picture +[4]: https://network-insight.net/2018/09/software-defined-perimeter-zero-trust/ +[5]: https://network-insight.net/2018/10/zero-trust-networking-ztn-want-ghosted/ +[6]: /contributor-network/signup.html +[7]: https://www.facebook.com/NetworkWorld/ +[8]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190612 When to use 5G, when to use Wi-Fi 6.md b/sources/talk/20190612 When to use 5G, when to use Wi-Fi 6.md new file mode 100644 index 0000000000..a2271052c9 --- /dev/null +++ b/sources/talk/20190612 When to use 5G, when to use Wi-Fi 6.md @@ -0,0 +1,83 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (When to use 5G, when to use Wi-Fi 6) +[#]: via: (https://www.networkworld.com/article/3402316/when-to-use-5g-when-to-use-wi-fi-6.html) +[#]: author: (Lee Doyle ) + +When to use 5G, when to use Wi-Fi 6 +====== +5G is a cellular service, and Wi-Fi 6 is a short-range wireless access technology, and each has attributes that make them useful in specific enterprise roles. +![Thinkstock][1] + +We have seen hype about whether [5G][2] cellular or [Wi-Fi 6][3] will win in the enterprise, but the reality is that the two are largely complementary with an overlap for some use cases, which will make for an interesting competitive environment through the early 2020s. + +### The potential for 5G in enterprises + +The promise of 5G for enterprise users is higher speed connectivity with lower latency. Cellular technology uses licensed spectrum which largely eliminates potential interference that may occur with unlicensed Wi-Fi spectrum. Like current 4G LTE technologies, 5G can be supplied by cellular wireless carriers or built as a private network . + +The architecture for 5G requires many more radio access points and can suffer from poor or no connectivity indoors. So, the typical organization needs to assess its [current 4G and potential 5G service][4] for its PCs, routers and other devices. Deploying indoor microcells, repeaters and distributed antennas can help solve indoor 5G service issues. As with 4G, the best enterprise 5G use case is for truly mobile connectivity such as public safety vehicles and in non-carpeted environments like mining, oil and gas extraction, transportation, farming and some manufacturing. + +In addition to broad mobility, 5G offers advantages in terms of authentication while roaming and speed of deployment as might be needed to provide WAN connectivity to a pop-up office or retail site. 5G will have the capacity to offload traffic in cases of data congestion such as live video. As 5G standards mature, the technology will improve its options for low-power IoT connectivity. + +5G will gradually roll out over the next four to five years starting in large cities and specific geographies; 4G technology will remain prevalent for a number of years. Enterprise users will need new devices, dongles and routers to connect to 5G services. For example, Apple iPhones are not expected to support 5G until 2020, and IoT devices will need specific cellular compatibility to connect to 5G. + +Doyle Research expects the 1Gbps and higher bandwidth promised by 5G will have a significant impact on the SD-WAN market. 4G LTE already enables cellular services to become a primary WAN link. 5G is likely to be cost competitive or cheaper than many wired WAN options such as MPLS or the internet. 5G gives enterprise WAN managers more options to provide increased bandwidth to their branch sites and remote users – potentially displacing MPLS over time. + +### The potential for Wi-Fi 6 in enterprises + +Wi-Fi is nearly ubiquitous for connecting mobile laptops, tablets and other devices to enterprise networks. Wi-Fi 6 (802.11ax) is the latest version of Wi-Fi and brings the promise of increased speed, low latency, improved aggregate bandwidth and advanced traffic management. While it has some similarities with 5G (both are based on orthogonal frequency division multiple access), Wi-Fi 6 is less prone to interference, requires less power (which prolongs device battery life) and has improved spectral efficiency. + +**[[Take this mobile device management course from PluralSight and learn how to secure devices in your company without degrading the user experience.][5] ]** + +As is typical for Wi-Fi, early [vendor-specific versions of Wi-Fi 6][6] are currently available from many manufacturers. The Wi-Fi alliance plans for certification of Wi-Fi 6-standard gear in 2020. Most enterprises will upgrade to Wi-Fi 6 along standard access-point life cycles of three years or so unless they have specific performance/latency requirements that prompt an upgrade sooner. + +Wi-Fi access points continue to be subject to interference, and it can be challenging to design and site APs to provide appropriate coverage. Enterprise LAN managers will continue to need vendor-supplied tools and partners to configure optimal Wi-Fi coverage for their organizations. Wi-Fi 6 solutions must be integrated with wired campus infrastructure. Wi-Fi suppliers need to do a better job at providing unified network management across wireless and wired solutions in the enterprise. + +### Need for wired backhaul + +For both technologies, wireless is combined with wired-network infrastructure to deliver high-speed communications end-to-end. In the enterprise, Wi-Fi is typically paired with wired Ethernet switches for campus and larger branches. Some devices are connected via cable to the switch, others via Wi-Fi – and laptops may use both methods. Wi-Fi access points are connected via Ethernet inside the enterprise and to the WAN or internet by fiber connections. + +The architecture for 5G makes extensive use of fiber optics to connect the distributed radio access network back to the core of the 5G network. Fiber is typically required to provide the high bandwidth needed to connect 5G endpoints to SaaS-based applications, and to provide live video and high-speed internet access. Private 5G networks will also have to meet high-speed wired-connectivity requirements. + +### Handoff issues + +Enterprise IT managers need to be concerned with handoff challenges as phones switch between 5G and Wi-Fi 6. These issues can affect performance and user satisfaction. Several groups are working towards standards to promote better interoperability between Wi-Fi 6 and 5G. As the architectures of Wi-Fi 6 align with 5G, the experience of moving between cellular and Wi-Fi networks should become more seamless. + +### 5G vs Wi-Fi 6 depends on locations, applications and devices + +Wi-Fi 6 and 5G are competitive with each other for specific situations in the enterprise environment that depend on location, application and device type. IT managers should carefully evaluate their current and emerging connectivity requirements. Wi-Fi will continue to dominate indoor environments and cellular wins for broad outdoor coverage. + +Some of the overlap cases occur in stadiums, hospitality and other large event spaces with many users competing for bandwidth. Government applications, including aspect of smart cities, can be applicable to both Wi-Fi and cellular. Health care facilities have many distributed medical devices and users that need connectivity. Large distributed manufacturing environments share similar characteristics. The emerging IoT deployments are perhaps the most interesting “competitive” environment with many overlapping use cases. + +### Recommendations for IT Leaders + +While the wireless technologies enabling them are converging, Wi-Fi 6 and 5G are fundamentally distinct networks – both of which have their role in enterprise connectivity. Enterprise IT leaders should focus on how Wi-Fi and cellular can complement each other, with Wi-Fi continuing as the in-building technology to connect PCs and laptops, offload phone and tablet data, and for some IoT connectivity. + +4G LTE moving to 5G will remain the truly mobile technology for phone and tablet connectivity, an option (via dongle) for PC connections, and increasingly popular for connecting some IoT devices. 5G WAN links will increasingly become standard as a backup for improved SD-WAN reliability and as primary links for remote offices. + +Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3402316/when-to-use-5g-when-to-use-wi-fi-6.html + +作者:[Lee Doyle][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2017/07/wi-fi_wireless_communication_network_abstract_thinkstock_610127984_1200x800-100730107-large.jpg +[2]: https://www.networkworld.com/article/3203489/what-is-5g-how-is-it-better-than-4g.html +[3]: https://www.networkworld.com/article/3215907/why-80211ax-is-the-next-big-thing-in-wi-fi.html +[4]: https://www.networkworld.com/article/3330603/5g-versus-4g-how-speed-latency-and-application-support-differ.html +[5]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fcourses%2Fmobile-device-management-big-picture +[6]: https://www.networkworld.com/article/3309439/80211ax-preview-access-points-and-routers-that-support-the-wi-fi-6-protocol-on-tap.html +[7]: https://www.facebook.com/NetworkWorld/ +[8]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190613 Data centers should sell spare UPS capacity to the grid.md b/sources/talk/20190613 Data centers should sell spare UPS capacity to the grid.md new file mode 100644 index 0000000000..69b4356661 --- /dev/null +++ b/sources/talk/20190613 Data centers should sell spare UPS capacity to the grid.md @@ -0,0 +1,59 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Data centers should sell spare UPS capacity to the grid) +[#]: via: (https://www.networkworld.com/article/3402039/data-centers-should-sell-spare-ups-capacity-to-the-grid.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +Data centers should sell spare UPS capacity to the grid +====== +Distributed Energy is gaining traction, providing an opportunity for data centers to sell excess power in data center UPS batteries to the grid. +![Getty Images][1] + +The energy storage capacity in uninterruptable power supply (UPS) batteries, languishing often dormant in data centers, could provide new revenue streams for those data centers, says Eaton, a major electrical power management company. + +Excess, grid-generated power, created during times of low demand, should be stored on the now-proliferating lithium-backup power systems strewn worldwide in data centers, Eaton says. Then, using an algorithm tied to grid-demand, electricity should be withdrawn as necessary for grid use. It would then be slid back onto the backup batteries when not needed. + +**[ Read also:[How server disaggregation can boost data center efficiency][2] | Get regularly scheduled insights: [Sign up for Network World newsletters][3] ]** + +The concept is called Distributed Energy and has been gaining traction in part because electrical generation is changing—emerging green power, such as wind and solar, being used now at the grid-level have considerations that differ from the now-retiring, fossil-fuel power generation. You can generate solar only in daylight, yet much demand takes place on dark evenings, for example. + +Coal, gas, and oil deliveries have always been, to a great extent, pre-planned, just-in-time, and used for electrical generation in real time. Nowadays, though, fluctuations between supply, storage, and demand are kicking in. Electricity storage on the grid is required. + +Eaton says that by piggy-backing on existing power banks, electricity distribution could be evened out better. The utilities would deliver power more efficiently, despite the peaks and troughs in demand—with the data center UPS, in effect, acting like a quasi-grid-power storage battery bank, or virtual power plant. + +The objective of this UPS use case, called EnergyAware, is to regulate frequency in the grid. That’s related to the tolerances needed to make the grid work—the cycles per second, or hertz, inherent in electrical current can’t deviate too much. Abnormalities happen if there’s a suddent spike in demand but no power on hand to supply the surge. + +### How the Distributed Energy concept works + +The distributed energy resource (DER), which can be added to any existing lithium-ion battery bank, in any building, allows for the consumption of energy, or the distribution of it, based on a Frequency Regulation grid-demand algorithm. It charges or discharges the backup battery, connected to the grid, thus balancing the grid frequency. + +Often, not much power will need to be removed, just “micro-bursts of energy,” explains Sean James, director of Energy Research at Microsoft, in an Eaton-published promotional video. Microsoft Innovation Center in Virginia has been working with Eaton on the project. Those bursts are enough to get the frequency tolerances back on track, but the UPS still functions as designed. + +Eaton says data centers should start participating in energy markets. That could mean bidding, as a producer of power, to those who need to buy it—the electricity market, also known as the grid. Data centers could conceivably even switch on generators to operate the data halls if the price for its battery-stored power was particularly lucrative at certain times. + +“A data center in the future wouldn’t just be a huge load on the grid,” James says. “In the future, you don’t have a data center or a power plant. It’s something in the middle. A data plant,” he says on the Eaton [website][4]. + +Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3402039/data-centers-should-sell-spare-ups-capacity-to-the-grid.html + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/10/business_continuity_server-100777720-large.jpg +[2]: https://www.networkworld.com/article/3266624/how-server-disaggregation-could-make-cloud-datacenters-more-efficient.html +[3]: https://www.networkworld.com/newsletters/signup.html +[4]: https://www.eaton.com/us/en-us/products/backup-power-ups-surge-it-power-distribution/backup-power-ups/dual-purpose-ups-technology.html +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190617 5 transferable higher-education skills.md b/sources/talk/20190617 5 transferable higher-education skills.md new file mode 100644 index 0000000000..db0f584aaf --- /dev/null +++ b/sources/talk/20190617 5 transferable higher-education skills.md @@ -0,0 +1,64 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (5 transferable higher-education skills) +[#]: via: (https://opensource.com/article/19/6/5-transferable-higher-education-skills) +[#]: author: (Stephon Brown https://opensource.com/users/stephb) + +5 transferable higher-education skills +====== +If you're moving from the Ivory Tower to the Matrix, you already have +the foundation for success in the developer role. +![Two hands holding a resume with computer, clock, and desk chair ][1] + +My transition from a higher-education professional into the tech realm was comparable to moving from a pond into an ocean. There was so much to learn, and after learning, there was still so much more to learn! + +Rather than going down the rabbit hole and being overwhelmed by what I did not know, in the last two to three months, I have been able to take comfort in the realization that I was not entirely out of my element as a developer. The skills I acquired during my six years as a university professional gave me the foundation to be successful in the developer role. + +These skills are transferable in any direction you plan to go within or outside tech, and it's valuable to reflect on how they apply to your new position. + +### 1\. Composition and documentation + +Higher education is replete with opportunities to develop skills related to composition and communication. In most cases, clear writing and communication are mandatory requirements for university administrative and teaching positions. Although you may not yet be well-versed in deep technical concepts, learning documentation and writing your progress may be two of the strongest skills you bring as a former higher education administrator. All of those "In response to…" emails will finally come in handy when describing the inner workings of a class or leaving succinct comments for other developers to follow what you have implemented. + +### 2\. Problem-solving and critical thinking + +Whether you've been an adviser who sits with students and painstakingly develops class schedules for graduation or a finance buff who balances government funds, you will not leave critical thinking behind as you transition into a developer role. Although your critical thinking may have seemed specialized for your work, the skill of turning problems into opportunities is not lost when contributing to code. The experience gained while spending long days and nights revising recruitment strategies will be necessary when composing algorithms and creative ways of delivering data. Continue to foster a passion for solving problems, and you will not have any trouble becoming an efficient and skillful developer. + +### 3\. Communication + +Though it may seem to overlap with writing (above), communication spans verbal and written disciplines. When you're interacting with clients and leadership, you may have a leg up over your peers because of your higher-education experience. Being approachable and understanding how to manage interactions are skills that some software practitioners may not have fostered to an impactful level. Although you will experience days of staring at a screen and banging your head against the keyboard, you can rest well in knowing you can describe technical concepts and interact with a wide range of audiences, from clients to peers. + +### 4\. Leadership + +Sitting on that panel; planning that event; leading that workshop. All of those experiences provide you with the grounding to plan and lead smaller projects as a new developer. Leadership is not limited to heading up large and small teams; its essence lies in taking initiative. This can be volunteering to do research on a new feature or do more extensive unit tests for your code. However you use it, your foundation as an educator will allow you to go further in technology development and maintenance. + +### 5\. Research + +You can Google with the best of them. Being able to clearly truncate your query into the idea you are searching for is characteristic of a higher-education professional. Most administrator or educator jobs focus on solving problems in a defined process for qualitative, quantitative, or mixed results; therefore, cultivating your scientific mind is valuable when providing software solutions. Your research skills also open opportunities for branching into data science and machine learning. + +### Bonus: Collaboration + +Being able to reach across various offices and fields for event planning and program implementation fit well within team collaboration—both within your new team and across development teams. This may leak into the project management realm, but being able to plan and divide work between teams and establish accountability will allow you as a new developer to understand the software development lifecycle process a little more intimately because of your past related experience. + +### Summary + +As a developer jumping head-first into technology after years of walking students through the process of navigating higher education, [imposter syndrome][2] has been a constant fear since moving into technology. However, I have been able to take heart in knowing my experience as an educator and an administrator has not gone in vain. If you are like me, be encouraged in knowing that these transferable skills, some of which fall into the soft-skills and other categories, will continue to benefit you as a developer and a professional. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/5-transferable-higher-education-skills + +作者:[Stephon Brown][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/stephb +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/resume_career_document_general.png?itok=JEaFL2XI (Two hands holding a resume with computer, clock, and desk chair ) +[2]: https://en.wikipedia.org/wiki/Impostor_syndrome diff --git a/sources/talk/20190618 17 predictions about 5G networks and devices.md b/sources/talk/20190618 17 predictions about 5G networks and devices.md new file mode 100644 index 0000000000..d8833f9887 --- /dev/null +++ b/sources/talk/20190618 17 predictions about 5G networks and devices.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (17 predictions about 5G networks and devices) +[#]: via: (https://www.networkworld.com/article/3403358/17-predictions-about-5g-networks-and-devices.html) +[#]: author: (Fredric Paul https://www.networkworld.com/author/Fredric-Paul/) + +17 predictions about 5G networks and devices +====== +Not surprisingly, the new Ericsson Mobility Report is bullish on the potential of 5G technology. Here’s a quick look at the most important numbers. +![Vertigo3D / Getty Images][1] + +_“As market after market switches on 5G, we are at a truly momentous point in time. No previous generation of mobile technology has had the potential to drive economic growth to the extent that 5G promises. It goes beyond connecting people to fully realizing the Internet of Things (IoT) and the Fourth Industrial Revolution.”_ —The opening paragraph of the [June 2019 Ericsson Mobility Report][2] + +Almost every significant technology advancement now goes through what [Gartner calls the “hype cycle.”][3] These days, Everyone expects new technologies to be met with gushing optimism and dreamy visions of how it’s going to change the world in the blink of an eye. After a while, we all come to expect the vendors and the press to go overboard with excitement, at least until reality and disappointment set in when things don’t pan out exactly as expected. + +**[ Also read:[The time of 5G is almost here][4] ]** + +Even with all that in mind, though, Ericsson’s whole-hearted embrace of 5G in its Internet Mobility Report is impressive. The optimism is backed up by lots of numbers, but they can be hard to tease out of the 36-document. So, let’s recap some of the most important top-line predictions (with my comments at the end). + +### Worldwide 5G growth projections + + 1. “More than 10 million 5G subscriptions are projected worldwide by the end of 2019.” + 2. “[We] now expect there to be 1.9 billion 5G subscriptions for enhanced mobile broadband by the end of 2024. This will account for over 20 percent of all mobile subscriptions at that time. The peak of LTE subscriptions is projected for 2022, at around 5.3 billion subscriptions, with the number declining slowly thereafter.” + 3. “In 2024, 5G networks will carry 35 percent of mobile data traffic globally.” + 4. “5G can cover up to 65 percent of the world’s population in 2024.” + 5. ”NB-IoT and Cat-M technologies will account for close to 45 percent of cellular IoT connections in 2024.” + 6. “By the end of 2024, nearly 35 percent of cellular IoT connections will be Broadband IoT, with 4G connecting the majority.” But 5G connections will support more advanced use cases. + 7. “Despite challenging 5G timelines, device suppliers are expected to be ready with different band and architecture support in a range of devices during 2019.” + 8. “Spectrum sharing … chipsets are currently in development and are anticipated to be in 5G commercial devices in late 2019." + 9. “[VoLTE][5] is the foundation for enabling voice and communication services on 5G devices. Subscriptions are expected to reach 2.1 billion by the end of 2019. … The number of VoLTE subscriptions is projected to reach 5.9 billion by the end of 2024, accounting for more than 85 percent of combined LTE and 5G subscriptions.” + + + +![][6] + +### Regional 5G projections + + 1. “In North America, … service providers have already launched commercial 5G services, both for fixed wireless access and mobile. … By the end of 2024, we anticipate close to 270 million 5G subscriptions in the region, accounting for more than 60 percent of mobile subscriptions.” + 2. “In Western Europe … The momentum for 5G in the region was highlighted by the first commercial launch in April. By the end of 2024, 5G is expected to account for around 40 percent of mobile subscriptions. + 3. In Central and Eastern Europe, … The first 5G subscriptions are expected in 2019, and will make up 15 percent of subscriptions in 2024.” + 4. “In North East Asia, … the region’s 5G subscription penetration is projected to reach 47 percent [by the end of 2024]. + 5. “[In India,] 5G subscriptions are expected to become available in 2022 and will represent 6 percent of mobile subscriptions at the end of 2024.” + 6. “In the Middle East and North Africa, we anticipate commercial 5G deployments with leading communications service providers during 2019, and significant volumes in 2021. … Around 60 million 5G subscriptions are forecast for the end of 2024, representing 3 percent of total mobile subscriptions.” + 7. “Initial 5G commercial devices are expected in the [South East Asia and Oceania] region during the first half of 2019. By the end of 2024, it is anticipated that almost 12 percent of subscriptions in the region will be for 5G.]” + 8. “In Latin America … the first 5G deployments will be possible in the 3.5GHz band during 2019. Argentina, Brazil, Chile, Colombia, and Mexico are anticipated to be the first countries in the region to deploy 5G, with increased subscription uptake forecast from 2020. By the end of 2024, 5G is set to make up 7 percent of mobile subscriptions.” + + + +### Is 5G really so inevitable? + +Considered individually, these predictions all seem perfectly reasonable. Heck, 10 million 5G subscriptions is only a drop in the global bucket. And rumors are already flying that Apple’s next round of iPhones will include 5G capability. Also, 2024 is still five years in the future, so why wouldn’t the faster connections drive impressive traffic stats? Similarly, North America and North East Asia will experience the fastest 5G penetration. + +But when you look at them all together, these numbers project a sense of 5G inevitability that could well be premature. It will take a _lot_ of spending, by a lot of different parties—carriers, chip makers, equipment vendors, phone manufacturers, and consumers—to make this kind of growth a reality. + +I’m not saying 5G won’t take over the world. I’m just saying that when so many things have to happen in a relatively short time, there are a lot of opportunities for the train to jump the tracks. Don’t be surprised if it takes longer than expected for 5G to turn into the worldwide default standard Ericsson—and everyone else—seems to think it will inevitably become. + +Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3403358/17-predictions-about-5g-networks-and-devices.html + +作者:[Fredric Paul][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Fredric-Paul/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/5g_wireless_technology_network_connections_by_credit-vertigo3d_gettyimages-1043302218_3x2-100787550-large.jpg +[2]: https://www.ericsson.com/assets/local/mobility-report/documents/2019/ericsson-mobility-report-june-2019.pdf +[3]: https://www.gartner.com/en/research/methodologies/gartner-hype-cycle +[4]: https://www.networkworld.com/article/3354477/mobile-world-congress-the-time-of-5g-is-almost-here.html +[5]: https://www.gsma.com/futurenetworks/technology/volte/ +[6]: https://images.idgesg.net/images/article/2019/06/ericsson-mobility-report-june-2019-graph-100799481-large.jpg +[7]: https://www.facebook.com/NetworkWorld/ +[8]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190618 Why your workplace arguments aren-t as effective as you-d like.md b/sources/talk/20190618 Why your workplace arguments aren-t as effective as you-d like.md new file mode 100644 index 0000000000..54a0cca26f --- /dev/null +++ b/sources/talk/20190618 Why your workplace arguments aren-t as effective as you-d like.md @@ -0,0 +1,144 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why your workplace arguments aren't as effective as you'd like) +[#]: via: (https://opensource.com/open-organization/19/6/barriers-productive-arguments) +[#]: author: (Ron McFarland https://opensource.com/users/ron-mcfarland/users/ron-mcfarland) + +Why your workplace arguments aren't as effective as you'd like +====== +Open organizations rely on open conversations. These common barriers to +productive argument often get in the way. +![Arrows pointing different directions][1] + +Transparent, frank, and often contentious arguments are part of life in an open organization. But how can we be sure those conversations are _productive_ —not _destructive_? + +This is the second installment of a two-part series on how to argue and actually achieve something. In the [first article][2], I mentioned what arguments are (and are not), according to author Sinnott-Armstrong in his book _Think Again: How to Reason and Argue._ I also offered some suggestions for making arguments as productive as possible. + +In this article, I'll examine three barriers to productive arguments that Sinnott-Armstrong elaborates in his book: incivility, polarization, and language issues. Finally, I'll explain his suggestions for addressing those barriers. + +### Incivility + +"Incivility" has become a social concern in recent years. Consider this: As a tactic in arguments, incivility _can_ have an effect in certain situations—and that's why it's a common strategy. Sinnott-Armstrong notes that incivility: + + * **Attracts attention:** Incivility draws people's attention in one direction, sometimes to misdirect attention from or outright obscure other issues. It redirects people's attention to shocking statements. Incivility, exaggeration, and extremism can increase the size of an audience. + + * **Energizes:** Sinnott-Armstrong writes that seeing someone being uncivil on a topic of interest can generate energy from a state of powerlessness. + + * **Stimulates memory:** Forgetting shocking statements is difficult; they stick in our memory more easily than statements that are less surprising to us. + + * **Excites the powerless:** The groups most likely to believe and invest in someone being uncivil are those that feel they're powerless and being treated unfairly. + + + + +Unfortunately, incivility as a tactic in arguments has its costs. One such cost is polarization. + +### Polarization + +Sinnott-Armstrong writes about five forms of polarization: + + * **Distance:** If two people's or groups' views are far apart according to some relevant scale, have significant disagreements and little common ground, then they're polarized. + + * **Differences:** If two people or groups have fewer values and beliefs _in common_ than they _don't have in common_ , then they're polarized. + + * **Antagonism:** Groups are more polarized the more they feel hatred, disdain, fear, or other negative emotions toward other people or groups. + + * **Incivility:** Groups tend to be more polarized when they talk more negatively about people of the other groups. + + * **Rigidity:** Groups tend to be more polarized when they treat their values as indisputable and will not compromise. + + * **Gridlock:** Groups tend to be more polarized when they're unable to cooperate and work together toward common goals. + + + + +And I'll add one more form of polarization to Sinnott-Armstrong's list: + + * **Non-disclosure:** Groups tend to be more polarized when one or both of the groups refuses to share valid, verifiable information—or when they distract each other with useless or irrelevant information. One of the ways people polarize is by not talking to each other and withhold information. Similarly, they talk on subjects that distract us from the issue at hand. Some issues are difficult to talk about, but by doing so solutions can be explored. + + + +### Language issues + +Identifying discussion-stoppers like these can help you avoid shutting down a discussion that would otherwise achieve beneficial outcomes. + +Language issues can be argument-stoppers Sinnott-Armstrong says. In particular, he outlines some of the following language-related barriers to productive argument. + + * **Guarding:** Using words like "all" can make a statement unbelievable; words like "sometimes" can make a statement too vague. + + * **Assuring:** Simply stating "trust me, I know what I'm talking about," without offering evidence that this is the case, can impede arguments. + + * **Evaluating:** Offering an evaluation of something—like saying "It is good"―without any supporting reasoning. + + * **Discounting:** This involves anticipating what the another person will say and attempting to weaken it as much as possible by framing an argument in a negative way. (Contrast these two sentences, for example: "Ramona is smart but boring" and "Ramona is boring but smart." The difference is subtle, but you'd probably want to spend less time with Ramona if you heard the first statement about her than if you heard the second.) + + + + +Identifying discussion-stoppers like these can help you avoid shutting down a discussion that would otherwise achieve beneficial outcomes. In addition, Sinnott-Armstrong specifically draws readers' attention to two other language problems that can kill productive debates: vagueness and ambiguity. + + * **Vagueness:** This occurs when a word or sentence is not precise enough and having many ways to interpret its true meaning and intent, which leads to confusion. Consider the sentence "It is big." "It" must be defined if it's not already obvious to everyone in the conversation. And a word like "big" must be clarified through comparison to something that everyone has agreed upon. + + * **Ambiguity:** This occurs when a sentence could have two distinct meanings. For example: "Police killed man with axe." Who was holding the axe, the man or the police? "My neighbor had a friend for dinner." Did your neighbor invite a friend to share a meal—or did she eat her friend? + + + + +### Overcoming barriers + +To help readers avoid these common roadblocks to productive arguments, Sinnott-Armstrong recommends a simple, four-step process for evaluating another person's argument. + + 1. **Observation:** First, observe a stated opinion and its related evidence to determine the precise nature of the claim. This might require you to ask some questions for clarification (you'll remember I employed this technique when arguing with my belligerent uncle, which I described [in the first article of this series][2]). + + 2. **Hypothesis:** Develop some hypothesis about the argument. In this case, the hypothesis should be an inference based on generally acceptable standards (for more on the structure of arguments themselves, also see [the first part of this series][2]). + + 3. **Comparison:** Compare that hypothesis with others and evaluate which is more accurate. More important issues will require you to conduct more comparisons. In other cases, premises are so obvious that no further explanation is required. + + 4. **Conclusion:** From the comparison analysis, reach a conclusion about whether your hypothesis about a competing argument is correct. + + + + +In many cases, the question is not whether a particular claim is _correct_ or _incorrect_ , but whether it is _believable._ So Sinnott-Armstrong also offers a four-step "believability test" for evaluating claims of this type. + + 1. **Expertise:** Does the person presenting the argument have authority in an appropriate field? Being a specialist is one field doesn't necessarily make that person an expert in another. + + 2. **Motive:** Would self-interest or other personal motives compel a person to withhold information or make false statements? To confirm one's statements, it might be wise to seek a totally separate, independent authority for confirmation. + + 3. **Sources:** Are the sources the person offers as evidence of a claim recognized experts? Do those sources have the expertise on the specific issue addressed? + + 4. **Agreement:** Is there agreement among many experts within the same specialty? + + + + +### Let's argue + +If you really want to strengthen your ability to argue, find someone that totally disagrees with you but wants to learn and understand your beliefs. + +When I was a university student, I would usually sit toward the front of the classroom. When I didn't understand something, I would start asking questions for clarification. Everyone else in the class would just sit silently, saying nothing. After class, however, other students would come up to me and thank me for asking those questions—because everyone else in the room was confused, too. + +Clarification is a powerful act—not just in the classroom, but during arguments anywhere. Building an organizational culture in which people feel empowered to ask for clarification is critical for productive arguments (I've [given presentations on this topic][3] before). If members have the courage to clarify premises, and they can do so in an environment where others don't think they're being belligerent, then this might be the key to a successful and productive argument. + +If you really want to strengthen your ability to argue, find someone that totally disagrees with you but wants to learn and understand your beliefs. Then, practice some of Sinnott-Armstrong's suggestions. Arguing productively will enhance [transparency, inclusivity, and collaboration][4] in your organization—leading to a more open culture. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/19/6/barriers-productive-arguments + +作者:[Ron McFarland][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ron-mcfarland/users/ron-mcfarland +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/directions-arrows.png?itok=EE3lFewZ (Arrows pointing different directions) +[2]: https://opensource.com/open-organization/19/5/productive-arguments +[3]: https://www.slideshare.net/RonMcFarland1/argue-successfully-achieve-something +[4]: https://opensource.com/open-organization/resources/open-org-definition diff --git a/sources/talk/20190619 With Tableau, SaaS king Salesforce becomes a hybrid cloud company.md b/sources/talk/20190619 With Tableau, SaaS king Salesforce becomes a hybrid cloud company.md new file mode 100644 index 0000000000..d0d1d24cb6 --- /dev/null +++ b/sources/talk/20190619 With Tableau, SaaS king Salesforce becomes a hybrid cloud company.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (With Tableau, SaaS king Salesforce becomes a hybrid cloud company) +[#]: via: (https://www.networkworld.com/article/3403442/with-tableau-saas-king-salesforce-becomes-a-hybrid-cloud-company.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +With Tableau, SaaS king Salesforce becomes a hybrid cloud company +====== +Once dismissive of software, Salesforce acknowledges the inevitability of the hybrid cloud. +![Martyn Williams/IDGNS][1] + +I remember a time when people at Salesforce events would hand out pins that read “Software” inside a red circle with a slash through it. The High Priest of SaaS (a.k.a. CEO Marc Benioff) was so adamant against installed, on-premises software that his keynotes were always comical. + +Now, Salesforce is prepared to [spend $15.7 billion to acquire Tableau Software][2], the leader in on-premises data analytics. + +On the hell-freezes-over scale, this is up there with Microsoft embracing Linux or Apple PR people returning a phone call. Well, we know at least one of those has happened. + +**[ Also read:[Hybrid Cloud: The time for adoption is upon us][3] | Stay in the know: [Subscribe and get daily newsletter updates][4] ]** + +So, why would a company that is so steeped in the cloud, so anti-on-premises software, make such a massive purchase? + +Partly it is because Benioff and company are finally coming to the same conclusion as most everyone else: The hybrid cloud, a mix of on-premises systems and public cloud, is the wave of the future, and pure cloud plays are in the minority. + +The reality is that data is hybrid and does not sit in a single location, and Salesforce is finally acknowledging this, said Tim Crawford, president of Avoa, a strategic CIO advisory firm. + +“I see the acquisition of Tableau by Salesforce as less about getting into the on-prem game as it is a reality of the world we live in. Salesforce needed a solid analytics tool that went well beyond their existing capability. Tableau was that tool,” he said. + +**[[Become a Microsoft Office 365 administrator in record time with this quick start course from PluralSight.][5] ]** + +Salesforce also understands that they need a better understanding of customers and those data insights that drive customer decisions. That data is both on-prem and in the cloud, Crawford noted. It is in Salesforce, other solutions, and the myriad of Excel spreadsheets spread across employee systems. Tableau crosses the hybrid boundaries and brings a straightforward way to visualize data. + +Salesforce had analytics features as part of its SaaS platform, but it was geared around their own platform, whereas everyone uses Tableau and Tableau supports all manner of analytics. + +“There’s a huge overlap between Tableau customers and Salesforce customers,” Crawford said. “The data is everywhere in the enterprise, not just in Salesforce. Salesforce does a great job with its own data, but Tableau does great with data in a lot of places because it’s not tied to one platform. So, it opens up where the data comes from and the insights you get from the data.” + +Crawford said that once the deal is done and Tableau is under some deeper pockets, the organization may be able to innovate faster or do things they were unable to do prior. That hardly indicates Tableau was struggling, though. It pulled in [$1.16 billion in revenue][6] in 2018. + +Crawford also expects Salesforce to push Tableau to open up new possibilities for customer insights by unlocking customer data inside and outside of Salesforce. One challenge for the two companies is to maintain that neutrality so that they don’t lose the ability to use Tableau for non-customer centric activities. + +“It’s a beautiful way to visualize large sets of data that have nothing to do with customer centricity,” he said. + +Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3403442/with-tableau-saas-king-salesforce-becomes-a-hybrid-cloud-company.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://images.techhive.com/images/article/2015/09/150914-salesforce-dreamforce-2-100614575-large.jpg +[2]: https://www.cio.com/article/3402026/how-salesforces-tableau-acquisition-will-impact-it.html +[3]: http://www.networkworld.com/article/2172875/cloud-computing/hybrid-cloud--the-year-of-adoption-is-upon-us.html +[4]: https://www.networkworld.com/newsletters/signup.html +[5]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fcourses%2Fadministering-office-365-quick-start +[6]: https://www.geekwire.com/2019/tableau-hits-841m-annual-recurring-revenue-41-transition-subscription-model-continues/ +[7]: https://www.facebook.com/NetworkWorld/ +[8]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190620 Carrier services help expand healthcare, with 5G in the offing.md b/sources/talk/20190620 Carrier services help expand healthcare, with 5G in the offing.md new file mode 100644 index 0000000000..072b172fda --- /dev/null +++ b/sources/talk/20190620 Carrier services help expand healthcare, with 5G in the offing.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Carrier services help expand healthcare, with 5G in the offing) +[#]: via: (https://www.networkworld.com/article/3403366/carrier-services-help-expand-healthcare-with-5g-in-the-offing.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +Carrier services help expand healthcare, with 5G in the offing +====== +Many telehealth initiatives tap into wireless networking supplied by service providers that may start offering services such as Citizen's Band and 5G to support remote medical care. +![Thinkstock][1] + +There are connectivity options aplenty for most types of [IoT][2] deployment, but the idea of simply handing the networking part of the equation off to a national licensed wireless carrier could be the best one for certain kinds of deployments in the medical field. + +Telehealth systems, for example, are still a relatively new facet of modern medicine, but they’re already among the most important applications that use carrier networks to deliver care. One such system is operated by the University of Mississippi Medical Center, for the treatment and education of diabetes patients. + +**[More on wireless:[The time of 5G is almost here][3]]** + +**[ Now read[20 hot jobs ambitious IT pros should shoot for][4]. ]** + +Greg Hall is the director of IT at UMMC’s center for telehealth. He said that the remote patient monitoring system is relatively simple by design – diabetes patients receive a tablet computer that they can use to input and track their blood sugar levels, alert clinicians to symptoms like nerve pain or foot sores, and even videoconference with their doctors directly. The tablet connects via Verizon, AT&T or CSpire – depending on who’s got the best coverage in a given area – back to UMMC’s servers. + +According to Hall, there are multiple advantages to using carrier connectivity instead of unlicensed (i.e. purpose-built [Wi-Fi][5] or other technology) to connect patients – some of whom live in remote parts of the state – to their caregivers. + +“We weren’t expecting everyone who uses the service to have Wi-Fi,” he said, “and they can take their tablet with them if they’re traveling.” + +The system serves about 250 patients in Mississippi, up from roughly 175 in the 2015 pilot program that got the effort off the ground. Nor is it strictly limited to diabetes care – Hall said that it’s already been extended to patients suffering from chronic obstructive pulmonary disease, asthma and even used for prenatal care, with further expansion in the offing. + +“The goal of our program isn’t just the monitoring piece, but also the education piece, teaching a person to live with their [condition] and thrive,” he said. + +It hasn’t all been smooth sailing. One issue was caused by the natural foliage of the area, as dense areas of pine trees can cause transmission problems, thanks to their needles being a particularly troublesome length and interfering with 2.5GHz wireless signals. But Hall said that the team has been able to install signal boosters or repeaters to overcome that obstacle. + +Neurologist Dr. Allen Gee’s practice in Wyoming attempts to address a similar issue – far-flung patients with medical needs that might not be addressed by the sparse local-care options. From his main office in Cody, he said, he can cover half the state via telepresence, using a purpose-built system that is based on cellular-data connectivity from TCT, Spectrum and AT&T, as well as remote audiovisual equipment and a link to electronic health records stored in distant locations. That allows him to receive patient data, audio/visual information and even imaging diagnostics remotely. Some specialists in the state are able to fly to those remote locations, others are not. + +While Gee’s preference is to meet with patients in person, that’s just not always possible, he said. + +“Medical specialists don’t get paid for windshield time,” he noted. “Being able to transfer information from an EHR facilitates the process of learning about the patient.” + +### 5G is coming** + +** + +According to Alan Stewart-Brown, vice president at infrastructure management vendor Opengear, there’s a lot to like about current carrier networks for medical use – particularly wide coverage and a lack of interference – but there are bigger things to come. + +“We have customers that have equipment in ambulances for instance, where they’re livestreaming patients’ vital signs to consoles that doctors can monitor,” he said. “They’re using carrier 4G for that right now and it works well enough, but there are limitations, namely latency, which you don’t get on [5G][6].” + +Beyond the simple fact of increased throughput and lower latency, widespread 5G deployments could open a wide array of new possibilities for medical technology, mostly involving real-time, very-high-definition video streaming. These include medical VR, remote surgery and the like. + +“The process you use to do things like real-time video – right now on a 4G network, that may or may not have a delay,” said Stewart-Brown. “Once you can get rid of the delay, the possibilities are endless as to what you can use the technology for.” + +### Citizens band + +Ron Malenfant, chief architect for service provider IoT at Cisco, agreed that the future of 5G for medical IoT is bright, but said that the actual applications of the technology have to be carefully thought out. + +“The use cases need to be worked on,” he said. “The innovative [companies] are starting to say ‘OK, what does 5G mean to me’ and starting to plan use cases.” + +One area that the carriers themselves have been eyeing recently is the CBRS band of radio frequencies, which sits around 3.5GHz. It’s what’s referred to as “lightly licensed” spectrum, in that parts of it are used for things like CB radio and other parts are the domain of the U.S. armed forces, and it could be used to build private networks for institutional users like hospitals, instead of deploying small but expensive 4G cells. The idea is that the institutions would be able to lease those frequencies for their specific area from the carrier directly for private LTE/CBRS networks, and, eventually 5G, Malenfant said. + +There’s also the issue, of course, that there are still a huge amount of unknowns around 5G, which isn’t expected to supplant LTE in the U.S. for at least another year or so. The medical field’s stiff regulatory requirements could also prove a stumbling block for the adoption of newer wireless technology. + +Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3403366/carrier-services-help-expand-healthcare-with-5g-in-the-offing.html + +作者:[Jon Gold][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/07/stethoscope_mobile_healthcare_ipad_tablet_doctor_patient-100765655-large.jpg +[2]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[3]: https://www.networkworld.com/article/3354477/mobile-world-congress-the-time-of-5g-is-almost-here.html +[4]: https://www.networkworld.com/article/3276025/careers/20-hot-jobs-ambitious-it-pros-should-shoot-for.html +[5]: https://www.networkworld.com/article/3238664/80211-wi-fi-standards-and-speeds-explained.html +[6]: https://www.networkworld.com/article/3203489/what-is-5g-how-is-it-better-than-4g.html +[7]: https://www.facebook.com/NetworkWorld/ +[8]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190620 Cracks appear in Intel-s grip on supercomputing.md b/sources/talk/20190620 Cracks appear in Intel-s grip on supercomputing.md new file mode 100644 index 0000000000..5ff550d3fc --- /dev/null +++ b/sources/talk/20190620 Cracks appear in Intel-s grip on supercomputing.md @@ -0,0 +1,63 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Cracks appear in Intel’s grip on supercomputing) +[#]: via: (https://www.networkworld.com/article/3403443/cracks-appear-in-intels-grip-on-supercomputing.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Cracks appear in Intel’s grip on supercomputing +====== +New competitors threaten to take Intel’s dominance in the high-performance computing (HPC) world, and we’re not even talking about AMD (yet). +![Randy Wong/LLNL][1] + +It’s June, so it’s that time again for the twice-yearly Top 500 supercomputer list, where bragging rights are established or, in most cases, reaffirmed. The list constantly shifts as new trends appear, and one of them might be a break in Intel’s dominance. + +[Supercomputers in the top 10 list][2] include a lot of IBM Power-based systems, and almost all run Nvidia GPUs. But there’s more going on than that. + +For starters, an ARM supercomputer has shown up, at #156. [Astra][3] at Sandia National Laboratories is an HPE system running Cavium (now Marvell) ThunderX2 processors. It debuted on the list at #204 last November, but thanks to upgrades, it has moved up the list. It won’t be the last ARM server to show up, either. + +**[ Also see:[10 of the world's fastest supercomputers][2] | Get daily insights: [Sign up for Network World newsletters][4] ]** + +Second is the appearance of four Nvidia DGX servers, with the [DGX SuperPOD][5] ranking the highest at #22. [DGX systems][6] are basically compact GPU boxes with a Xeon just to boot the thing. The GPUs do all the heavy lifting. + +AMD hasn’t shown up yet with the Epyc processors, but it will, given Cray is building them for the government. + +This signals a breaking up of the hold Intel has had on the high-performance computing (HPC) market for a long time, said Ashish Nadkarni, group vice president in IDC's worldwide infrastructure practice. “The Intel hold has already been broken up by all the accelerators in the supercomputing space. The more accelerators they use, the less need they have for Xeons. They can go with other processors that do justice to those accelerators,” he told me. + +With so much work in HPC and artificial intelligence (AI) being done by GPUs, the x86 processor becomes just a boot processor in a way. I wasn’t kidding about the DGX box. It’s got one Xeon and eight Tesla GPUs. And the Xeon is an E5, a midrange part. + +**[[Get certified as an Apple Technical Coordinator with this seven-part online course from PluralSight.][7] ]** + +“They don’t need high-end Xeons in servers any more, although there’s a lot of supercomputers that just use CPUs. The fact is there are so many options now,” said Nadkarni. One example of an all-CPU system is [Frontera][8], a Dell-based system at the Texas Advanced Computing Center in Austin. + +The top two computers, Sierra and Summit, both run IBM Power9 RISC processors, as well as Nvidia GPUs. All told, Nvidia is in 125 of the 500 supercomputers, including five of the top 10, the fastest computer in the world, the fastest in Europe (Piz Daint) and the fastest in Japan (ABCI). + +Lenovo was the top hardware provider, beating out Dell, HPE, and IBM combined. That’s because of its large presence in its native China. Nadkari said Lenovo, which acquired the IBM x86 server business in 2014, has benefitted from the IBM installed base, which has continued wanting the same tech from Lenovo under new ownership. + +Join the Network World communities on [Facebook][9] and [LinkedIn][10] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3403443/cracks-appear-in-intels-grip-on-supercomputing.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/10/sierra875x500-100778404-large.jpg +[2]: https://www.networkworld.com/article/3236875/embargo-10-of-the-worlds-fastest-supercomputers.html +[3]: https://www.top500.org/system/179565 +[4]: https://www.networkworld.com/newsletters/signup.html +[5]: https://www.top500.org/system/179691 +[6]: https://www.networkworld.com/article/3196088/nvidias-new-volta-based-dgx-1-supercomputer-puts-400-servers-in-a-box.html +[7]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fapple-certified-technical-trainer-10-11 +[8]: https://www.networkworld.com/article/3236875/embargo-10-of-the-worlds-fastest-supercomputers.html#slide7 +[9]: https://www.facebook.com/NetworkWorld/ +[10]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190620 Several deals solidify the hybrid cloud-s status as the cloud of choice.md b/sources/talk/20190620 Several deals solidify the hybrid cloud-s status as the cloud of choice.md new file mode 100644 index 0000000000..ade07dcb10 --- /dev/null +++ b/sources/talk/20190620 Several deals solidify the hybrid cloud-s status as the cloud of choice.md @@ -0,0 +1,77 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Several deals solidify the hybrid cloud’s status as the cloud of choice) +[#]: via: (https://www.networkworld.com/article/3403354/several-deals-solidify-the-hybrid-clouds-status-as-the-cloud-of-choice.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Several deals solidify the hybrid cloud’s status as the cloud of choice +====== +On-premises and cloud connections are being built by all the top vendors to bridge legacy and modern systems, creating hybrid cloud environments. +![Getty Images][1] + +The hybrid cloud market is expected to grow from $38.27 billion in 2017 to $97.64 billion by 2023, at a Compound Annual Growth Rate (CAGR) of 17.0% during the forecast period, according to Markets and Markets. + +The research firm said the hybrid cloud is rapidly becoming a leading cloud solution, as it provides various benefits, such as cost, efficiency, agility, mobility, and elasticity. One of the many reasons is the need for interoperability standards between cloud services and existing systems. + +Unless you are a startup company and can be born in the cloud, you have legacy data systems that need to be bridged, which is where the hybrid cloud comes in. + +So, in very short order we’ve seen a bunch of new alliances involving the old and new guard, reiterating that the need for hybrid solutions remains strong. + +**[ Read also:[What hybrid cloud means in practice][2] | Get regularly scheduled insights: [Sign up for Network World newsletters][3] ]** + +### HPE/Google + +In April, the Hewlett Packard Enterprise (HPE) and Google announced a deal where HPE introduced a variety of server solutions for Google Cloud’s Anthos, along with a consumption-based model for the validated HPE on-premises infrastructure that is integrated with Anthos. + +Following up with that, the two just announced a strategic partnership to create a hybrid cloud for containers by combining HPE’s on-premises infrastructure, Cloud Data Services, and GreenLake consumption model with Anthos. This allows for: + + * Bi-directional data mobility for data mobility and consistent data services between on-premises and cloud + * Application workload mobility to move containerized app workloads across on-premises and multi-cloud environments + * Multi-cloud flexibility, offering the choice of HPE Cloud Volumes and Anthos for what works best for the workload + * Unified hybrid management through Anthos, so customers can get a unified and consistent view of their applications and workloads regardless of where they reside + * Charged as a service via HPE GreenLake + + + +### IBM/Cisco + +This is a furthering of an already existing partnership between IBM and Cisco designed to deliver a common and secure developer experience across on-premises and public cloud environments for building modern applications. + +[Cisco said it will support IBM Cloud Private][4], an on-premises container application development platform, on Cisco HyperFlex and HyperFlex Edge hyperconverged infrastructure. This includes support for IBM Cloud Pak for Applications. IBM Cloud Paks deliver enterprise-ready containerized software solutions and developer tools for building apps and then easily moving to any cloud—public or private. + +This architecture delivers a common and secure Kubernetes experience across on-premises (including edge) and public cloud environments. IBM’s Multicloud Manager covers monitoring and management of clusters and container-based applications running from on-premises to the edge, while Cisco’s Virtual Application Centric Infrastructure (ACI) will allow customers to extend their network fabric from on-premises to the IBM Cloud. + +### IBM/Equinix + +Equinix expanded its collaboration with IBM Cloud to bring private and scalable connectivity to global enterprises via Equinix Cloud Exchange Fabric (ECX Fabric). This provides private connectivity to IBM Cloud, including Direct Link Exchange, Direct Link Dedicated and Direct Link Dedicated Hosting, that is secure and scalable. + +ECX Fabric is an on-demand, SDN-enabled interconnection service that allows any business to connect between its own distributed infrastructure and any other company’s distributed infrastructure, including cloud providers. Direct Link provides IBM customers with a connection between their network and IBM Cloud. So ECX Fabric provides IBM customers with a secured and scalable network connection to the IBM Cloud service. + +At the same time, ECX Fabric provides secure connections to other cloud providers, and most customers prefer a multi-vendor approach to avoid vendor lock-in. + +“Each of the partnerships focus on two things: 1) supporting a hybrid-cloud platform for their existing customers by reducing the friction to leveraging each solution and 2) leveraging the unique strength that each company brings. Each of the solutions are unique and would be unlikely to compete directly with other partnerships,” said Tim Crawford, president of Avoa, an IT consultancy. + +Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3403354/several-deals-solidify-the-hybrid-clouds-status-as-the-cloud-of-choice.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/cloud_hand_plus_sign_private-100787051-large.jpg +[2]: https://www.networkworld.com/article/3249495/what-hybrid-cloud-mean-practice +[3]: https://www.networkworld.com/newsletters/signup.html +[4]: https://www.networkworld.com/article/3403363/cisco-connects-with-ibm-in-to-simplify-hybrid-cloud-deployment.html +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190626 Where are all the IoT experts going to come from.md b/sources/talk/20190626 Where are all the IoT experts going to come from.md new file mode 100644 index 0000000000..22a303d2f6 --- /dev/null +++ b/sources/talk/20190626 Where are all the IoT experts going to come from.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Where are all the IoT experts going to come from?) +[#]: via: (https://www.networkworld.com/article/3404489/where-are-all-the-iot-experts-going-to-come-from.html) +[#]: author: (Fredric Paul https://www.networkworld.com/author/Fredric-Paul/) + +Where are all the IoT experts going to come from? +====== +The fast growth of the internet of things (IoT) is creating a need to train cross-functional experts who can combine traditional networking and infrastructure expertise with database and reporting skills. +![Kevin \(CC0\)][1] + +If the internet of things (IoT) is going to fulfill its enormous promise, it’s going to need legions of smart, skilled, _trained_ workers to make everything happen. And right now, it’s not entirely clear where those people are going to come from. + +That’s why I was interested in trading emails with Keith Flynn, senior director of product management, R&D at asset-optimization software company [AspenTech][2], who says that when dealing with the slew of new technologies that fall under the IoT umbrella, you need people who can understand how to configure the technology and interpret the data. Flynn sees a growing need for existing educational institutions to house IoT-specific programs, as well as an opportunity for new IoT-focused private colleges, offering a well -ounded curriculum + +“In the future,” Flynn told me, “IoT projects will differ tremendously from the general data management and automation projects of today. … The future requires a more holistic set of skills and cross-trading capabilities so that we’re all speaking the same language.” + +**[ Also read:  [20 hot jobs ambitious IT pros should shoot for][3] ]** + +With the IoT growing 30% a year, Flynn added, rather than a few specific skills, “everything from traditional deployment skills, like networking and infrastructure, to database and reporting skills and, frankly, even basic data science, need to be understood together and used together.” + +### Calling all IoT consultants + +“The first big opportunity for IoT-educated people is in the consulting field,” Flynn predicted. “As consulting companies adapt or die to the industry trends … having IoT-trained people on staff will help position them for IoT projects and make a claim in the new line of business: IoT consulting.” + +The problem is especially acute for startups and smaller companies. “The bigger the organization, the more likely they have a means to hire different people across different lines of skillsets,” Flynn said. “But for smaller organizations and smaller IoT projects, you need someone who can do both.” + +Both? Or _everything?_ The IoT “requires a combination of all knowledge and skillsets,” Flynn said, noting that “many of the skills aren’t new, they’ve just never been grouped together or taught together before.” + +**[ [Looking to upgrade your career in tech? This comprehensive online course teaches you how.][4] ]** + +### The IoT expert of the future + +True IoT expertise starts with foundational instrumentation and electrical skills, Flynn said, which can help workers implement new wireless transmitters and boost technology for better battery life and power consumption. + +“IT skills, like networking, IP addressing, subnet masks, cellular and satellite are also pivotal IoT needs,” Flynn said. He also sees a need for database management skills and cloud management and security expertise, “especially as things like [advanced process control] APC and sending sensor data directly to databases and data lakes become the norm.” + +### Where will IoT experts come from? + +Flynn said standardized formal education courses would be the best way to make sure that graduates or certificate holders have the right set of skills. He even laid out a sample curriculum: “Start in chronological order with the basics like [Electrical & Instrumentation] E&I and measurement. Then teach networking, and then database administration and cloud courses should follow that. This degree could even be looped into an existing engineering course, and it would probably take two years … to complete the IoT component.” + +While corporate training could also play role, “that’s easier said than done,” Flynn warned. “Those trainings will need to be organization-specific efforts and pushes.” + +Of course, there are already [plenty of online IoT training courses and certificate programs][5]. But, ultimately, the responsibility lies with the workers themselves. + +“Upskilling is incredibly important in this world as tech continues to transform industries,” Flynn said. “If that upskilling push doesn’t come from your employer, then online courses and certifications would be an excellent way to do that for yourself. We just need those courses to be created. ... I could even see organizations partnering with higher-education institutions that offer these courses to give their employees better access to it. Of course, the challenge with an IoT program is that it will need to constantly evolve to keep up with new advancements in tech.” + +**[ For more on IoT, see [tips for securing IoT on your network][6], our list of [the most powerful internet of things companies][7] and learn about the [industrial internet of things][8]. | Get regularly scheduled insights by [signing up for Network World newsletters][9]. ]** + +Join the Network World communities on [Facebook][10] and [LinkedIn][11] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3404489/where-are-all-the-iot-experts-going-to-come-from.html + +作者:[Fredric Paul][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Fredric-Paul/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/07/programmer_certification-skills_code_devops_glasses_student_by-kevin-unsplash-100764315-large.jpg +[2]: https://www.aspentech.com/ +[3]: https://www.networkworld.com/article/3276025/careers/20-hot-jobs-ambitious-it-pros-should-shoot-for.html +[4]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fupgrading-your-technology-career +[5]: https://www.google.com/search?client=firefox-b-1-d&q=iot+training +[6]: https://www.networkworld.com/article/3254185/internet-of-things/tips-for-securing-iot-on-your-network.html#nww-fsb +[7]: https://www.networkworld.com/article/2287045/internet-of-things/wireless-153629-10-most-powerful-internet-of-things-companies.html#nww-fsb +[8]: https://www.networkworld.com/article/3243928/internet-of-things/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html#nww-fsb +[9]: https://www.networkworld.com/newsletters/signup.html#nww-fsb +[10]: https://www.facebook.com/NetworkWorld/ +[11]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190630 Data Still Dominates.md b/sources/talk/20190630 Data Still Dominates.md new file mode 100644 index 0000000000..e9a86acf68 --- /dev/null +++ b/sources/talk/20190630 Data Still Dominates.md @@ -0,0 +1,100 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Data Still Dominates) +[#]: via: (https://theartofmachinery.com/2019/06/30/data_still_dominates.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +Data Still Dominates +====== + +Here’s [a quote from Linus Torvalds in 2006][1]: + +> I’m a huge proponent of designing your code around the data, rather than the other way around, and I think it’s one of the reasons git has been fairly successful… I will, in fact, claim that the difference between a bad programmer and a good one is whether he considers his code or his data structures more important. Bad programmers worry about the code. Good programmers worry about data structures and their relationships. + +Which sounds a lot like [Eric Raymond’s “Rule of Representation” from 2003][2]: + +> Fold knowledge into data, so program logic can be stupid and robust. + +Which was just his summary of ideas like [this one from Rob Pike in 1989][3]: + +> Data dominates. If you’ve chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming. + +Which cites [Fred Brooks from 1975][4]: + +> ### Representation is the Essence of Programming +> +> Beyond craftmanship lies invention, and it is here that lean, spare, fast programs are born. Almost always these are the result of strategic breakthrough rather than tactical cleverness. Sometimes the strategic breakthrough will be a new algorithm, such as the Cooley-Tukey Fast Fourier Transform or the substitution of an n log n sort for an n2 set of comparisons. +> +> Much more often, strategic breakthrough will come from redoing the representation of the data or tables. This is where the heart of your program lies. Show me your flowcharts and conceal your tables, and I shall be continued to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious. + +So, smart people have been saying this again and again for nearly half a century: focus on the data first. But sometimes it feels like the most famous piece of smart programming advice that everyone forgets. + +Let me give some real examples. + +### The Highly Scalable System that Couldn’t + +This system was designed from the start to handle CPU-intensive loads with incredible scalability. Nothing was synchronous. Everything was done with callbacks, task queues and worker pools. + +But there were two problems: The first was that the “CPU-intensive load” turned out not to be that CPU-intensive after all — a single task took a few milliseconds at worst. So most of the architecture was doing more harm than good. The second problem was that although it sounded like a highly scalable distributed system, it wasn’t one — it only ran on one machine. Why? Because all communication between asynchronous components was done using files on the local filesystem, which was now the bottleneck for any scaling. The original design didn’t say much about data at all, except to advocate local files in the name of “simplicity”. Most of the document was about all the extra architecture that was “obviously” needed to handle the “CPU-intensiveness” of the load. + +### The Service-Oriented Architecture that was Still Data-Oriented + +This system followed a microservices design, made up of single-purpose apps with REST-style APIs. One component was a database that stored documents (basically responses to standard forms, and other electronic paperwork). Naturally it exposed an API for basic storage and retrieval, but pretty quickly there was a need for more complex search functionality. The designers felt that adding this search functionality to the existing document API would have gone against the principles of microservices design. They could talk about “search” as being a different kind of service from “get/put”, so their architecture shouldn’t couple them together. Besides, the tool they were planning to use for search indexing was separate from the database itself, so creating a new service made sense for implementation, too. + +In the end, a search API was created containing a search index that was essentially a duplicate of the data in the main database. This data was being updated dynamically, so any component that mutated document data through the main database API had to also update the search API. It’s impossible to do this with REST APIs without race conditions, so the two sets of data kept going out of sync every now and then, anyway. + +Despite what the architecture diagram promised, the two APIs were tightly coupled through their data dependencies. Later on it was recognised that the search index should be an implementation detail of a unified document service, and this made the system much more maintainable. “Do one thing” works at the data level, not the verb level. + +### The Fantastically Modular and Configurable Ball of Mud + +This system was a kind of automated deployment pipeline. The original designers wanted to make a tool that was flexible enough to solve deployment problems across the company. It was written as a set of pluggable components, with a configuration file system that not only configured the components, but acted as a [DSL][5] for programming how the components fitted into the pipeline. + +Fast forward a few years and it’s turned into “that program”. There was a long list of known bugs that no one was ever fixing. No one wanted to touch the code out of fear of breaking things. No one used any of the flexibility of the DSL. Everyone who used the program copy-pasted the same known-working configuration that everyone else used. + +What had gone wrong? Although the original design document used words like “modular”, “decoupled”, “extensible” and “configurable” a lot, it never said anything about data. So, data dependencies between components ended up being handled in an ad-hoc way using a globally shared blob of JSON. Over time, components made more and more undocumented assumptions about what was in or not in the JSON blob. Sure, the DSL allowed rearranging components into any order, but most configurations didn’t work. + +### Lessons + +I chose these three examples because they’re easy to explain, not to pick on others. I once tried to build a website, and failed trying to instead build some cringe-worthy XML database that didn’t even solve the data problems I had. Then there’s the project that turned into a broken mockery of half the functionality of `make`, again because I didn’t think about what I really needed. I wrote a post before based on a time I wrote [a castle-in-the-sky OOP class hierarchy that should have been encoded in data instead][6]. + +Update: + +Apparently many people still thought I wrote this to make fun of others. People who’ve actually worked with me will know I’m much more interested in the things I’m fixing than in blaming the people who did most of the work building them, but, okay, here’s what I think of the engineers involved. + +Honestly, the first example obviously happened because the designer was more interested in bringing a science project to work than in solving the problem at hand. Most of us have done that (mea culpa), but it’s really annoying to our colleagues who’ll probably have to help maintain them when we’re bored of them. If this sounds like you, please don’t get offended; please just stop. (I’d still rather work on the single-node distributed system than anything built around my “XML database”.) + +There’s nothing personal in the second example. Sometimes it feels like everyone is talking about how wonderful it is to split up services, but no one is talking about exactly when not to. People are learning the hard way all the time. + +The third example was actually from some of the smartest people I’ve ever had the chance to work with. + +(End update.) + +“Does this talk about the problems created by data?” turns out to be a pretty useful litmus test for good systems design. It’s also pretty handy for detecting false expert advice. The hard, messy systems design problems are data problems, so false experts love to ignore them. They’ll show you a wonderfully beautiful architecture, but without talking about what kind of data it’s appropriate for, and (crucially) what kind of data it isn’t. + +For example, a false expert might tell you that you should use a pub/sub system because pub/sub systems are loosely coupled, and loosely coupled components are more maintainable. That sounds nice and results in pretty diagrams, but it’s backwards thinking. Pub/sub doesn’t _make_ your components loosely coupled; pub/sub _is_ loosely coupled, which may or may not match your data needs. + +On the flip side, a well-designed data-oriented architecture goes a long way. Functional programming, service meshes, RPCs, design patterns, event loops, whatever, all have their merits, but personally I’ve seen tools like [boring old databases][7] be responsible for a lot more successfully shipped software. + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2019/06/30/data_still_dominates.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: https://lwn.net/Articles/193245/ +[2]: http://www.catb.org/~esr/writings/taoup/html/ch01s06.html +[3]: http://doc.cat-v.org/bell_labs/pikestyle +[4]: https://archive.org/stream/mythicalmanmonth00fred/mythicalmanmonth00fred_djvu.txt +[5]: https://martinfowler.com/books/dsl.html +[6]: https://theartofmachinery.com/2016/06/21/code_vs_data.html +[7]: https://theartofmachinery.com/2017/10/28/rdbs_considered_useful.html diff --git a/sources/talk/20190702 SD-WAN Buyers Should Think Application Performance as well as Resiliency.md b/sources/talk/20190702 SD-WAN Buyers Should Think Application Performance as well as Resiliency.md new file mode 100644 index 0000000000..3bddd4cdc3 --- /dev/null +++ b/sources/talk/20190702 SD-WAN Buyers Should Think Application Performance as well as Resiliency.md @@ -0,0 +1,49 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (SD-WAN Buyers Should Think Application Performance as well as Resiliency) +[#]: via: (https://www.networkworld.com/article/3406456/sd-wan-buyers-should-think-application-performance-as-well-as-resiliency.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + +SD-WAN Buyers Should Think Application Performance as well as Resiliency +====== + +![istock][1] + +As an industry analyst, not since the days of WAN Optimization have I seen a technology gain as much interest as I am seeing with [SD-WANs][2] today. Although full deployments are still limited, nearly every network manager, and often many IT leaders I talk to, are interested in it. The reason for this is two-fold – the WAN has grown in importance for cloud-first enterprises and is badly in need of an overhaul. This hasn’t gone unnoticed by the vendor community as there has been an explosion of companies bringing a broad range of SD-WAN offerings to market. The great news for buyers is that there is no shortage of choices. The bad news is there are too many choices and making the right decision difficult. + +One area of differentiation for SD-WAN vendors is how they handle application performance.  I think of the SD-WAN market as being split into two categories – basic and advanced SD-WANs.  A good analogy is to think of the virtualization market.  There are many vendors that offer hypervisors – in fact there are a number of free ones.  So why do companies pay a premium for VMware? It’s because VMware offers many advanced features and capabilities that make its solution do more than just virtualize servers. + +Similarly, basic SD-WAN solutions do a great job of helping to lower costs and to increase application resiliency through path selection capabilities but do nothing to improve application performance. One myth that needs busting is that all SD-WANs make your applications perform better. That’s simply not true as application availability and performance are two different things. It’s possible to have great performance and poor availability or high availability with lackluster performance.  + +Consider the case where a business runs a hybrid WAN and voice and video traffic is sent over the MPLS connection and broadband is used for other traffic. If the MPLS link becomes congested, but doesn’t go down, most SD-WAN solutions will continue to send video and voice over it, which obviously degrades the performance. If multiple broadband connections are used, the chances of congestion related issues are even more likely.  + +This is an important point for IT professionals to understand. The business justification for SD-WAN was initially built around saving money but if application performance suffers, the entire return on investment (ROI) for the project might as well be tossed out the window.  For many companies, the network is the business, so a poor performing network means equally poor performing applications which results lost productivity, lower revenues and possibly brand damage from customer experience issues.  + +I’ve talked to many organizations that had digital initiatives fail because the network wasn’t transformed. For example, a luxury retailer implemented a tablet program for in store personnel to be able to show merchandise to customers. High end retail is almost wholly impulse purchases so the more inventory that can be shown to a customer, the larger the resulting sales. The WAN that was in place was causing the mobile application to perform poorly causing the digital initiative to have a negative effect. Instead of driving sales, the mobile initiative was chasing customers from the store.  The idea was right but the poor performing WAN caused the project to fail. + +SD-WAN decision makers need to look to suppliers that have specific technologies integrated into it that can act when congestion occurs.  A great example of this is the Silver Peak [Unity EdgeConnect™][3] SD-WAN edge platform with [path conditioning][4], [traffic shaping][5] and sub-second link failover. This ensures the best possible quality for all critical applications, even when an underlying link experiences congestion or an outage, even for [voice and video over broadband][6]. This is a foundational component of advanced SD-WAN providers as they offer the same resiliency and cost benefits as a basic SD-WAN but also ensure application performance remains high.  + +The SD-WAN era is here, and organizations should be aggressive with deployments as it will transform the WAN and make it a digital transformation enabler. Decision makers should choose their provider carefully and ensure the vendor also improves application performance.  Without it, the digital initiatives will likely fail and negate any ROI the company was hoping to realize. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3406456/sd-wan-buyers-should-think-application-performance-as-well-as-resiliency.html + +作者:[Zeus Kerravala][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/07/istock-157647179-100800860-large.jpg +[2]: https://www.silver-peak.com/sd-wan/sd-wan-explained +[3]: https://www.silver-peak.com/products/unity-edge-connect +[4]: https://www.silver-peak.com/products/unity-edge-connect/path-conditioning +[5]: https://www.silver-peak.com/products-solutions/unity/traffic-shaping +[6]: https://www.silver-peak.com/sd-wan/voice-video-over-broadband diff --git a/sources/talk/20190703 An eco-friendly internet of disposable things is coming.md b/sources/talk/20190703 An eco-friendly internet of disposable things is coming.md new file mode 100644 index 0000000000..8d1e827aa8 --- /dev/null +++ b/sources/talk/20190703 An eco-friendly internet of disposable things is coming.md @@ -0,0 +1,92 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (An eco-friendly internet of disposable things is coming) +[#]: via: (https://www.networkworld.com/article/3406462/an-eco-friendly-internet-of-disposable-things-is-coming.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +An eco-friendly internet of disposable things is coming +====== +Researchers are creating a non-hazardous, bacteria-powered miniature battery that can be implanted into shipping labels and packaging to monitor temperature and track packages in real time. +![Thinkstock][1] + +Get ready for a future of disposable of internet of things (IoT) devices, one that will mean everything is connected to networks. It will be particularly useful in logistics, being used in single-use plastics in retail packaging and throw-away shippers’ carboard boxes. + +How it will happen? The answer is when non-hazardous, disposable bio-batteries make it possible. And that moment might be approaching. Researchers say they’re closer to commercializing a bacteria-powered miniature battery that they say will propel the IoDT. + +**[ Learn more: [Download a PDF bundle of five essential articles about IoT in the enterprise][2] ]** + +The “internet of disposable things is a new paradigm for the rapid evolution of wireless sensor networks,” says Seokheun Choi, an associate professor at Binghamton University, [in an article on the school’s website][3]. + +“Current IoDTs are mostly powered by expensive and environmentally hazardous batteries,” he says. Those costs can be significant in any kind of large-scale deployment, he says. And furthermore, with exponential growth, the environmental concerns would escalate rapidly. + +The miniaturized battery that Choi’s team has come up with is uniquely charged through power created by bacteria. It doesn’t have metals and acids in it. And it’s designed specifically to provide energy to sensors and radios in single-use IoT devices. Those could be the kinds of sensors ideal for supply-chain logistics where the container is ultimately going to end up in a landfill, creating a hazard. + +Another use case is real-time analysis of packaged food, with sensors monitoring temperature and location, preventing spoilage and providing safer food handling. For example, a farm product could be tracked for on-time delivery, as well as have its temperature measured, all within the packaging, as it moves from packaging facility to consumer. In the event of a food-borne illness outbreak, say, one can quickly find out where the product originated—which apparently is hard to do now. + +Other use cases could be battery-impregnated shipping labels that send real-time data to the internet. Importantly, in both use cases, packaging can be discarded without added environmental concerns. + +### How the bacteria-powered batteries work + +A slow release of nutrients provide the energy to the bacteria-powered batteries, which the researchers say can last up to eight days. “Slow and continuous reactions” convert the microbial nutrients into “long standing power,” they say in [their paper's abstract][4]. + +“Our biobattery is low-cost, disposable, and environmentally-friendly,” Choi says. + +Origami, the Japanese paper-folding skill used to create objects, was an inspiration for a similar microbial-based battery project the group wrote about last year in a paper. This one is liquid-based and not as long lasting. A bacteria-containing liquid was absorbed along the porous creases in folded paper, creating the paper-delivered power source, perhaps to be used in a shipping label. + +“Low-cost microbial fuel cells (MFCs) can be done efficiently by using a paper substrate and origami techniques,” [the group wrote then][5]. + +Scientists, too, envisage electronics now printed on circuit boards (PCBs) and can be toxic on disposal being printed entirely on eco-friendly paper. Product cycles, such as those found now in mobile devices and likely in future IoT devices, are continually getting tighter—thus PCBs are increasingly being disposed. Solutions are needed, experts say. + +Put the battery in the paper, too, is the argument here. And while you’re at it, get the biodegradation of the used-up biobattery to help break-down the organic-matter paper. + +Ultimately, Choi believes that the power-creating bacteria could even be introduced naturally by the environment—right now it’s added on by the scientists. + +**More on IoT:** + + * [What is the IoT? How the internet of things works][6] + * [What is edge computing and how it’s changing the network][7] + * [Most powerful Internet of Things companies][8] + * [10 Hot IoT startups to watch][9] + * [The 6 ways to make money in IoT][10] + * [What is digital twin technology? [and why it matters]][11] + * [Blockchain, service-centric networking key to IoT success][12] + * [Getting grounded in IoT networking and security][2] + * [Building IoT-ready networks must become a priority][13] + * [What is the Industrial IoT? [And why the stakes are so high]][14] + + + +Join the Network World communities on [Facebook][15] and [LinkedIn][16] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3406462/an-eco-friendly-internet-of-disposable-things-is-coming.html + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://images.techhive.com/images/article/2017/04/green-data-center-intro-100719502-large.jpg +[2]: https://www.networkworld.com/article/3269736/internet-of-things/getting-grounded-in-iot-networking-and-security.html +[3]: https://www.binghamton.edu/news/story/1867/everything-will-connect-to-the-internet-someday-and-this-biobattery-could-h +[4]: https://www.sciencedirect.com/science/article/abs/pii/S0378775319305580 +[5]: https://www.sciencedirect.com/science/article/pii/S0960148117311606 +[6]: https://www.networkworld.com/article/3207535/internet-of-things/what-is-the-iot-how-the-internet-of-things-works.html +[7]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[8]: https://www.networkworld.com/article/2287045/internet-of-things/wireless-153629-10-most-powerful-internet-of-things-companies.html +[9]: https://www.networkworld.com/article/3270961/internet-of-things/10-hot-iot-startups-to-watch.html +[10]: https://www.networkworld.com/article/3279346/internet-of-things/the-6-ways-to-make-money-in-iot.html +[11]: https://www.networkworld.com/article/3280225/internet-of-things/what-is-digital-twin-technology-and-why-it-matters.html +[12]: https://www.networkworld.com/article/3276313/internet-of-things/blockchain-service-centric-networking-key-to-iot-success.html +[13]: https://www.networkworld.com/article/3276304/internet-of-things/building-iot-ready-networks-must-become-a-priority.html +[14]: https://www.networkworld.com/article/3243928/internet-of-things/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html +[15]: https://www.facebook.com/NetworkWorld/ +[16]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190705 Lessons in Vendor Lock-in- Google and Huawei.md b/sources/talk/20190705 Lessons in Vendor Lock-in- Google and Huawei.md new file mode 100644 index 0000000000..fe92b389a9 --- /dev/null +++ b/sources/talk/20190705 Lessons in Vendor Lock-in- Google and Huawei.md @@ -0,0 +1,58 @@ +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " +[#]: subject: "Lessons in Vendor Lock-in: Google and Huawei" +[#]: via: "https://www.linuxjournal.com/content/lessons-vendor-lock-google-and-huawei" +[#]: author: "Kyle Rankin https://www.linuxjournal.com/users/kyle-rankin" + +Lessons in Vendor Lock-in: Google and Huawei +====== +![](https://www.linuxjournal.com/sites/default/files/styles/850x500/public/nodeimage/story/bigstock-Us--China-Trade-War-Boxing-F-252887971_1.jpg?itok=oZBwXDrP) + +What happens when you're locked in to a vendor that's too big to fail, but is on the opposite end of a trade war? + +The story of Google no longer giving Huawei access to Android updates is still developing, so by the time you read this, the situation may have changed. At the moment, Google has granted Huawei a 90-day window whereby it will have access to Android OS updates, the Google Play store and other Google-owned Android assets. After that point, due to trade negotiations between the US and China, Huawei no longer will have that access. + +Whether or not this new policy between Google and Huawei is still in place when this article is published, this article isn't about trade policy or politics. Instead, I'm going to examine this as a new lesson in vendor lock-in that I don't think many have considered before: what happens when the vendor you rely on is forced by its government to stop you from being a customer? + +### Too Big to Fail + +Vendor lock-in isn't new, but until the last decade or so, it generally was thought of by engineers as a bad thing. Companies would take advantage the fact that you used one of their products that was legitimately good to use the rest of their products that may or may not be as good as those from their competitors. People felt the pain of being stuck with inferior products and rebelled. + +These days, a lot of engineers have entered the industry in a world where the new giants of lock-in are still growing and have only flexed their lock-in powers a bit. Many engineers shrug off worries about choosing a solution that requires you to use only products from one vendor, in particular if that vendor is a large enough company. There is an assumption that those companies are too big ever to fail, so why would it matter that you rely on them (as many companies in the cloud do) for every aspect of their technology stack? + +Many people who justify lock-in with companies who are too big to fail point to all of the even more important companies who use that vendor who would have even bigger problems should that vendor have a major bug, outage or go out of business. It would take so much effort to use cross-platform technologies, the thinking goes, when the risk of going all-in with a single vendor seems so small. + +Huawei also probably figured (rightly) that Google and Android were too big to fail. Why worry about the risks of being beholden to a single vendor for your OS when that vendor was used by other large companies and would have even bigger problems if the vendor went away? + +### The Power of Updates + +Google held a particularly interesting and subtle bit of lock-in power over Huawei (and any phone manufacturer who uses Android)—the power of software updates. This form of lock-in isn't new. Microsoft famously used the fact that software updates in Microsoft Office cost money (naturally, as it was selling that software) along with the fact that new versions of Office had this tendency to break backward compatibility with older document formats to encourage everyone to upgrade. The common scenario was that the upper-level folks in the office would get brand-new, cutting-edge computers with the latest version of Office on them. They would start saving new documents and sharing them, and everyone else wouldn't be able to open them. It ended up being easier to upgrade everyone's version of Office than to have the bosses remember to save new documents in old formats every time. + +The main difference with Android is that updates are critical not because of compatibility, but for security. Without OS updates, your phone ultimately will become vulnerable to exploits that attackers continue to find in your software. The Android OS that ships on phones is proprietary and therefore requires permission from Google to get those updates. + +Many people still don't think of the Android OS as proprietary software. Although people talk about the FOSS underpinnings in Android, only people who go to the extra effort of getting a pure-FOSS version of Android, like LineageOS, on their phones actually experience it. The version of Android most people tend to use has a bit of FOSS in the center, surrounded by proprietary Google Apps code. + +It's this Google Apps code that gives Google the kind of powerful leverage over a company like Huawei. With traditional Android releases, Google controls access to OS updates including security updates. All of this software is signed with Google's signing keys. This system is built with security in mind—attackers can't easily build their own OS update to install on your phone—but it also has a convenient side effect of giving Google control over the updates. + +What's more, the Google Apps suite isn't just a convenient way to load Gmail or Google Docs, it also includes the tight integration with your Google account and the Google Play store. Without those hooks, you don't have access to the giant library of applications that everyone expects to use on their phones. As anyone with a LineageOS phone that uses F-Droid can attest, while a large number of applications are available in the F-Droid market, you can't expect to see those same apps as on Google Play. Although you can side-load some Google Play apps, many applications, such as Google Maps, behave differently without a Google account. Note that this control isn't unique to Google. Apple uses similar code-signing features with similar restrictions on its own phones and app updates. + +### Conclusion + +Without access to these OS updates, Huawei now will have to decide whether to create its own LineageOS-style Android fork or a whole new phone OS of its own. In either case, it will have to abandon the Google Play Store ecosystem and use F-Droid-style app repositories, or if it goes 100% alone, it will need to create a completely new app ecosystem. If its engineers planned for this situation, then they likely are working on this plan right now; otherwise, they are all presumably scrambling to address an event that "should never happen". Here's hoping that if you find yourself in a similar case of vendor lock-in with an overseas company that's too big to fail, you never get caught in the middle of a trade war. + +-------------------------------------------------------------------------------- + +via: https://www.linuxjournal.com/content/lessons-vendor-lock-google-and-huawei + +作者:[Kyle Rankin][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxjournal.com/users/kyle-rankin +[b]: https://github.com/lujun9972 diff --git a/sources/talk/20190708 Colocation facilities buck the cloud-data-center trend.md b/sources/talk/20190708 Colocation facilities buck the cloud-data-center trend.md new file mode 100644 index 0000000000..add6ef0093 --- /dev/null +++ b/sources/talk/20190708 Colocation facilities buck the cloud-data-center trend.md @@ -0,0 +1,96 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Colocation facilities buck the cloud-data-center trend) +[#]: via: (https://www.networkworld.com/article/3407756/colocation-facilities-buck-the-cloud-data-center-trend.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Colocation facilities buck the cloud-data-center trend +====== +Lower prices and latency plus easy access to multiple cloud providers make colocation facilities an attractive option compared to building on-site data centers. +![gorodenkoff / Getty Images][1] + +[Data center][2] workloads are moving but not only to the cloud. Increasingly, they are shifting to colocation facilities as an alternative to privately owned data centers. + +### What is colocation? + +A colocation facility or colo is a data center in which a business can rent space for servers and other computing hardware that they purchase but that the colo provider manages. + +[Read about IPv6 and cloud-access security brokers][3] + +The colo company provides the building, cooling, power, bandwidth and physical security. Space is leased by the rack, cabinet, cage or room. Many colos started out as managed services and continue  to offer those specialized services. + +Some prominent providers include Equinix, Digital Reality Trust, CenturyLink, and NTT Communications, and there are several Chinese providers that only serve the China market. Unlike the data centers of cloud vendors like Amazon and Microsoft, these colo facilities are generally in large metropolitan areas. + +“Colos have been around a long time, but their initial use case was Web servers,” said Rick Villars, vice president of data centers and cloud research at IDC. “What’s changed now is the ratio of what’s customer-facing is much greater than in 2000, [with the]  expansion of companies needing to have more assets that are network-facing.” + +### Advantages of colos: Cost, cloud interconnect + +Homegrown data centers are often sized correctly, with either too much capacity or too little, said Jim Poole, vice president of business development at Equinix. “Customers come to us all the time and say, ‘Would you buy my data center? Because I only use 25 percent of it,’” he said. + +Poole said the average capital expenditure for a stand-alone enterprise data center that is not a part of the corporate campus is $9 million. Companies are increasingly realizing that it makes sense to buy the racks of hardware but place it in someone else’s secure facility that handles the power and cooling. “It’s the same argument for doing cloud computing but at the physical-infrastructure level,” he said. + +Mike Satter, vice president for OceanTech, a data-center-decommissioning service provider, says enterprises should absolutely outsource data-center construction or go the colo route. Just as there are contractors who specialize in building houses, there are experts who specialize in data-center design, he said. + +He added that with many data-center closures there is subsequent consolidation. “For every decommissioning we do, that same company is adding to another environment somewhere else. With the new hardware out there now, the servers can do the same work in 20 racks as they did in 80 racks five years ago. That means a reduced footprint and energy cost,” he said. + +Often these closures mean moving to a colo. OceanTech recently decommissioned a private data center for a major media outlet he declined to identify that involved shutting down a data center in New Jersey that held 70 racks of gear. The firm was going to move its apps to the cloud but ended up expanding to a colo facility in New York City. + +### Cloud isn't cheaper than private data centers + +Satter said he’s had conversations with companies that planned to go to the cloud but changed their minds when they saw what it would cost if they later decided to move workloads out. Cloud providers can “kill you with guidelines and costs” because your data is in their infrastructure, and they can set fees that make it expensive to move it to another provider, he said. “The cloud not a money saver.” + +That can drive decisions to keep data in-house or in a colo in order to keep tighter possession of their data. “Early on, when people weren’t hip to the game for how much it cost to move to the cloud, you had decision makers with influence say the cloud sounded good. Now they are realizing it costs a lot more dollars to do that vs. doing something on-prem, on your own,” said Satter. + +Guy Churchward, CEO of Datera, developer of software designed storage platforms for enterprises, has noticed a new trend among CIOs making a cloud vs. private decision for apps based on the lifespan of the app. + +“Organizations don’t know how much resource they need to throw at a task. The cloud makes more sense for [short-term apps],” he said. For applications that will be used for five years or more, it makes more sense to place them in company-controlled facilities, he said. That's because with three-to-five-year hardware-refresh cycles, the hardware lasts the entire lifespan of the app, and the hardware and app can be retired at the same time. + +Another force driving the decision of private data center vs. the cloud is machine learning. Churchward said that’s because machine learning is often done using large amounts of highly sensitive data, so customers wanted data kept securely in house. They also wanted a low-latency loop between their ML apps and the data lake from which they draw. + +### Colos connect to mulitple cloud providers + +Another allure of colocation providers is that they can act as a pipeline between enterprises and multiple cloud providers. So rather than directly connecting to AWS, Azure, etc., businesses can connect to a colo, and that colo acts like a giant switch, connecting them to cloud providers through dedicated, high-speed networks. + +Villars notes the typical corporate data center is either inside corporate HQ or someplace remote, like South Dakota where land was cheap. But the trade-off is that network connectivity to remote locations is often slower and more expensive. + +That’s where a data-center colo providers with a large footprints come in, since they have points of presence in major cities. No one would fault a New York City-based firm for putting its data center in upstate New York or even further away. But when Equinix, DTR, and others all have data centers right in New York City, customers might get faster and sometimes cheaper connections plus lower latency. + +Steve Cretney, vice president and CIO for food distributor Colony Brands, is in the midst of migrating the company to the cloud and moving everything he can from his data center to AWS. Rather than connect directly to AWS, Colony’s Wisconsin headquarters is connected to an Equinix data center in Chicago. + +Going with Equinix provides more and cheaper bandwidth to the cloud than buying direct connectivity on his own. “I effectively moved my data center into Chicago. Now I can compete with a better price on data communication and networks,” he said. + +Cretney estimates that by moving Colony’s networking from a smaller, local provider to Chicago, the company is seeing an annual cost savings of 50 percent for network connectivity that includes telecommunications. + +Also, Colony wants to adopt a mult-cloud-provider strategy to avoid vendor lock-in, and he gets that by using Equinix as his network connection. As the company eventually uses Microsoft Azure and Google Cloud and other providers, Equinex can provide flexible and economic interconnections, he said. + +### **Colos reduce the need for enterprise data-center real estate** + +In 2014, 80 percent of data-centers were owned by enterprises, while colos and the early cloud accounted for 20 percent, said Villars. Today that’s a 50-50 split, and by 2022-2023, IDC projects service providers will own 70 percent of the large-data-center space. + +For the past five years, the amount of new data-center construction by enterprises has been falling steadily at  5 to 10 percent per year, said Villars. “They are not building new ones because they are coming to the realization that being an expert at data-center construction is not something a company has.” + +Enterprises across many sectors are looking at their data-center environment and leveraging things like virtual machines and SSD, thereby compressing the size of their data centers and getting more work done within smaller physical footprints. “So at some point they ask if they are spending appropriately for this space. That’s when they look at colo,” said Villars. + +Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3407756/colocation-facilities-buck-the-cloud-data-center-trend.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/05/cso_cloud_computing_backups_it_engineer_data_center_server_racks_connections_by_gorodenkoff_gettyimages-943065400_3x2_2400x1600-100796535-large.jpg +[2]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[3]: https://www.networkworld.com/article/3391380/does-your-cloud-access-security-broker-support-ipv6-it-should.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190709 Improving IT Operations - Key to Business Success in Digital Transformation.md b/sources/talk/20190709 Improving IT Operations - Key to Business Success in Digital Transformation.md new file mode 100644 index 0000000000..5ce4f7edfe --- /dev/null +++ b/sources/talk/20190709 Improving IT Operations - Key to Business Success in Digital Transformation.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Improving IT Operations – Key to Business Success in Digital Transformation) +[#]: via: (https://www.networkworld.com/article/3407698/improving-it-operations-key-to-business-success-in-digital-transformation.html) +[#]: author: (Rami Rammaha https://www.networkworld.com/author/Rami-Rammaha/) + +Improving IT Operations – Key to Business Success in Digital Transformation +====== + +![Artem Peretiatko][1] + +Forty seven percent of CEOs say they are being “challenged” by their board of directors to show progress in shifting toward a digital business model according to the [Gartner 2018 CIO][2] Agenda Industry Insights Report. By improving IT operations, organizations can progress and even accelerate their digital transformation initiatives efficiently and successfully. The biggest barrier to success is that IT currently spends around 78 percent of their budget and 80 percent of their time just maintaining IT operations, leaving little time and resource left for innovation according to ZK Research[*][3]. + +### **Do you cut the operations budget or invest more in transforming operations? ** + +The Cisco IT Operations Readiness Index 2018 predicted a dramatic change in IT operations as CIOs embrace analytics and automation. The study reported that 88 percent of respondents identify investing in IT operations as key to driving preemptive practices and enhancing customer experience. + +### What does this have to do with the wide area network? + +According to the IT Operations Readiness Index, 73 percent of respondents will collect WAN operational or performance data and 70 percent will analyze WAN data and leverage the results to further automate network operations. However, security is the most data-driven infrastructure today compared to other IT infrastructure functions (i.e. IoT, IP telephony, network infrastructure, data center infrastructure, WAN connectivity, etc.). The big questions are: + + * How do you collect operations data and what data should you collect? + * How do you analyze it? + * How do you then automate IT operations based on the results? + + + +By no means, is this a simple task. IT departments use a combination of data collected internally and by outside vendors to aggregate information used to transform operations and make better business decisions. + +In a recent [survey][4] by Frost & Sullivan, 94 percent of respondents indicated they will deploy a Software-defined Wide Area Network ([SD-WAN][5]) in the next 24 months. SD-WAN addresses the gap that router-centric WAN architectures were not designed to fill. A business-driven SD-WAN, designed from the ground up to support a cloud-first business model, provides significantly more network and application performance visibility, significantly assisting enterprises to realize the transformational promise of a digital business model. In fact, Gartner indicates that 90 percent of WAN edge decisions will be based on SD-WAN by 2023. + +### How an SD-WAN can improve IT operations leading to successful digital transformation + +All SD-WAN solutions are not created alike. One of the key components that organizations need to consider and evaluate is having complete observability across the network and applications through a single pane of glass. Without visibility, IT risks running inefficient operations that will stifle digital transformation initiatives. This real-time visibility must provide: + + * Operational metrics enabling IT/CIO’s to shift from a reactive toward a predictive practice + * A centralized dashboard that allows IT to monitor, in real-time, all aspects of network operations – a dashboard that has flexible knobs to adjust and collect metrics from all WAN edge appliances to accelerate problem resolution + + + +The Silver Peak Unity [EdgeConnect™][6] SD-WAN edge platform provides granular visibility into network and application performance. The EdgeConnect platform ensures the highest quality of experience for both end users and IT. End users enjoy always-consistent, always-available application performance including the highest quality of voice and video, even over broadband. Utilizing the [Unity Orchestrator™][7] comprehensive management dashboard as shown below, IT gains complete observability into the performance attributes of the network and applications in real-time. Customizable widgets provide a wealth of operational data including a health heatmap for every SD-WAN appliance deployed, flow counts, active tunnels, logical topologies, top talkers, alarms, bandwidth consumed by each application and location, application latency and jitter and much more. Furthermore, the platform maintains a week’s worth of data with context allowing IT to playback and see what has transpired at a specific time and location, analogous to a DVR. + +By providing complete observability of the entire WAN, IT spends less time troubleshooting network and application bottlenecks and fielding support/help desk calls day and night, and more time focused on strategic business initiatives. + +![][8] + +This solution brief, “[Simplify SD-WAN Operations with Greater Visibility][9]”, provides additional detail on the capabilities offered in the business-driven EdgeConnect SD-WAN edge platform that enables businesses to accelerate their shift toward a digital business model. + +![][10] + +* ZK Research quote from [Cisco IT Operations Readiness Index 2018][11] + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3407698/improving-it-operations-key-to-business-success-in-digital-transformation.html + +作者:[Rami Rammaha][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Rami-Rammaha/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/07/istock-1096811078_1200x800-100801264-large.jpg +[2]: https://www.gartner.com/smarterwithgartner/is-digital-a-priority-for-your-industry/ +[3]: https://blog.silver-peak.com/improving-it-operations-key-to-business-success-in-digital-transformation#footnote +[4]: https://www.silver-peak.com/sd-wan-edge-survey +[5]: https://www.silver-peak.com/sd-wan +[6]: https://www.silver-peak.com/products/unity-edge-connect +[7]: https://www.silver-peak.com/products/unity-orchestrator +[8]: https://images.idgesg.net/images/article/2019/07/silver-peak-unity-edgeconnect-sdwan-100801265-large.jpg +[9]: https://www.silver-peak.com/resource-center/simplify-sd-wan-operations-greater-visibility +[10]: https://images.idgesg.net/images/article/2019/07/simplify-sd-wan-operations-with-greater-visibility-100801266-large.jpg +[11]: https://s3-us-west-1.amazonaws.com/connectedfutures-prod/wp-content/uploads/2018/11/CF_transforming_IT_operations_report_3-2.pdf diff --git a/sources/talk/20190709 Linux a key player in the edge computing revolution.md b/sources/talk/20190709 Linux a key player in the edge computing revolution.md new file mode 100644 index 0000000000..df1dba9344 --- /dev/null +++ b/sources/talk/20190709 Linux a key player in the edge computing revolution.md @@ -0,0 +1,112 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Linux a key player in the edge computing revolution) +[#]: via: (https://www.networkworld.com/article/3407702/linux-a-key-player-in-the-edge-computing-revolution.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +Linux a key player in the edge computing revolution +====== +Edge computing is augmenting the role that Linux plays in our day-to-day lives. A conversation with Jaromir Coufal from Red Hat helps to define what the edge has become. +![Dominic Smith \(CC BY 2.0\)][1] + +In the past few years, [edge computing][2] has been revolutionizing how some very familiar services are provided to individuals like you and me, as well as how services are managed within major industries. Try to get your arms around what edge computing is today, and you might just discover that your arms aren’t nearly as long or as flexible as you’d imagined. And Linux is playing a major role in this ever-expanding edge. + +One reason why edge computing defies easy definition is that it takes many different forms. As Jaromir Coufal, principal product manager at Red Hat, recently pointed out to me, there is no single edge. Instead, there are lots of edges – depending on what compute features are needed. He suggests that we can think of the edge as something of a continuum of capabilities with the problem being resolved determining where along that particular continuum any edge solution will rest. + +**[ Also read: [What is edge computing?][3] and [How edge networking and IoT will reshape data centers][4] ]** + +Some forms of edge computing include consumer electronics that are used and installed in millions of homes, others that serve tens of thousands of small businesses with operating their facilities, and still others that tie large companies to their remote sites. Key to this elusive definition is the idea that edge computing always involves distributing the workload in such a way that the bulk of the computing work is done remotely from the central core of the business and close to the business problem being addressed. + +Done properly, edge computing can provide services that are both faster and more reliable. Applications running on the edge can be more resilient and run considerably faster because their required data resources are local. In addition, data can be processed or analyzed locally, often requiring only periodic transfer of results to central sites. + +While physical security might be lower at the edge, edge devices often implement security features that allow them to detect 1) manipulation of the device, 2) malicious software, and 3) a physical breach and wipe data. + +### Benefits of edge computing + +Some of the benefits of edge computing include: + + * A quick response to intrusion detection, including the ability for a remote device to detach or self-destruct + * The ability to instantly stop communication when needed + * Constrained functionality and fewer generic entry points + * Rugged and reliable problem resistance + * Making the overall computing system harder to attack because computing is distributed + * Less data-in-transit exposure + + + +Some examples of edge computing devices include those that provide: + + * Video surveillance – watching for activity, reporting only if seen + * Controlling autonomous vehicles + * Production monitoring and control + + + +### Edge computing success story: Chick-fil-A + +One impressive example of highly successful edge computing caught me by surprise. It turns out Chick-fil-A uses edge computing devices to help manage its food preparation services. At Chick-fil-A, edge devices: + + 1. Analyze a fryer’s cleaning and cooking + 2. Aggregate data as a failsafe in case internet connectivity is lost + 3. Help with decision-making about cooking – how much and how long to cook + 4. Enhance business operations + 5. Help automate the complex food cooking and holding decisions so that even newbies get things right + 6. Function even when the connection with the central site is down + + + +As Coufal pointed out, Chick-fil-A runs [Kubernetes][5] at the edge in every one of its restaurants. Their key motivators are low-latency, scale of operations, and continuous business. And it seems to be working extremely well. + +[Chick-fil-A’s hypothesis][6] captures it all: By making smarter kitchen equipment, we can collect more data. By applying data to our restaurant, we can build more intelligent systems. By building more intelligent systems, we can better scale our business. + +### Are you edge-ready? + +There’s no quick answer as to whether your organization is “edge ready.” Many factors determine what kind of services can be deployed on the edge and whether and when those services need to communicate with more central devices. Some of these include: + + * Whether your workload can be functionally distributed + * If it’s OK for devices to have infrequent contact with the central services + * If devices can work properly when cut off from their connection back to central services + * Whether the devices can be secured (e.g., trusted not to provide an entry point) + + + +Implementing an edge computing network will likely take a long time from initial planning to implementation. Still, this kind of technology is taking hold and offers some strong advantages. While edge computing initially took hold 15 or more years ago, the last few years have seen renewed interest thanks to tech advances that have enabled new uses. + +Coufal noted that it's been 15 or more years since edge computing concepts and technologies were first introduced, but renewed interest has come about due to tech advances enabling new uses that require this technology. + +**More about edge computing:** + + * [How edge networking and IoT will reshape data centers][4] + * [Edge computing best practices][7] + * [How edge computing can help secure the IoT][8] + + + +Join the Network World communities on [Facebook][9] and [LinkedIn][10] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3407702/linux-a-key-player-in-the-edge-computing-revolution.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/07/telecom-100801330-large.jpg +[2]: https://www.networkworld.com/article/3224893/what-is-edge-computing-and-how-it-s-changing-the-network.html +[3]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[4]: https://www.networkworld.com/article/3291790/data-center/how-edge-networking-and-iot-will-reshape-data-centers.html +[5]: https://www.infoworld.com/article/3268073/what-is-kubernetes-container-orchestration-explained.html +[6]: https://medium.com/@cfatechblog/edge-computing-at-chick-fil-a-7d67242675e2 +[7]: https://www.networkworld.com/article/3331978/lan-wan/edge-computing-best-practices.html +[8]: https://www.networkworld.com/article/3331905/internet-of-things/how-edge-computing-can-help-secure-the-iot.html +[9]: https://www.facebook.com/NetworkWorld/ +[10]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190711 Smarter IoT concepts reveal creaking networks.md b/sources/talk/20190711 Smarter IoT concepts reveal creaking networks.md new file mode 100644 index 0000000000..86150bc580 --- /dev/null +++ b/sources/talk/20190711 Smarter IoT concepts reveal creaking networks.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Smarter IoT concepts reveal creaking networks) +[#]: via: (https://www.networkworld.com/article/3407852/smarter-iot-concepts-reveal-creaking-networks.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +Smarter IoT concepts reveal creaking networks +====== +Today’s networks don’t meet the needs of emergent internet of things systems. IoT systems need their own modern infrastructure, researchers at the University of Magdeburg say. +![Thinkstock][1] + +The internet of things (IoT) needs its own infrastructure ecosystem — one that doesn't use external clouds at all, researchers at the University of Magdeburg say. + +The computer scientists recently obtained funding from the German government to study how to build a future-generation of revolutionary, emergent IoT systems. They say networks must be fault tolerant, secure, and traverse disparate protocols, which they aren't now. + +**[ Read also: [What is edge computing?][2] and [How edge networking and IoT will reshape data centers][3] ]** + +The researchers say a smarter, unique, and organic infrastructure needs to be developed for the IoT and that simply adapting the IoT to traditional networks won't work. They say services must self-organize and function autonomously and that people must accept the fact that we are using the internet in ways never originally intended.  + +"The internet, as we know it, is based on network architectures of the 70s and 80s, when it was designed for completely different applications,” the researchers say in their [media release][4]. The internet has centralized security, which causes choke points, and and an inherent lack of dynamic controls, which translates to inflexibility in access rights — all of which make it difficult to adapt the IoT to it. + +Device, data, and process management must be integrated into IoT systems, say the group behind the project, called [DoRIoT][5] (Dynamische Laufzeitumgebung für Organisch (dis-)Aggregierende IoT-Prozesse), translated as Dynamic Runtime Environment for Organic dis-Aggregating IoT Processes. + +“In order to close this gap, concepts [will be] developed in the project that transparently realize the access to the data,” says Professor Sebastian Zug of the University of Freiberg, a partner in DoRIoT. “For the application, it should make no difference whether the specific information requirement is answered by a server or an IoT node.” + +### Extreme edge computing + +In other words, servers and nodes, conceptually, should merge. One could argue it’s a form of extreme [edge computing][6], which is when processing and data storage is taken out of traditional, centralized data center environments and placed close to where the resources are required. It reduces latency, among other advantages. + +DoRIoT may take edge computing one step further. Detecting failures ahead of time and seamless migration of devices are wants, too — services can’t fail just because a new kind of device is introduced. + +“The systems [will] benefit from each other, for example, they can share computing power, data and so on,” says Mesut Güneş of Magdeburg’s [Faculty of Computer Science Institute for Intelligent Cooperating Systems][7]. + +“The result is an enormous data pool,” the researchers explain. “Which, in turn, makes it possible to make much more precise statements, for example when predicting climate models, observing traffic flows, or managing large factories in Industry 4.0.” + +[Industry 4.0][8] refers to smart factories that have connected machines autonomously self-managing their own supply chain, production output, and logistics without human intervention. + +Managing risks better than the current internet is one of DoRIoT's goals. The idea is to “guarantee full sovereignty over proprietary data.” To get there, though, one has to eliminate dependency on the cloud and access to data via third parties, they say. + +“This allows companies to be independent of the server infrastructures of external service providers such as Google, Microsoft or Amazon, which are subject to constant changes and even may not be accessible,” they say. + +**More about edge networking** + + * [How edge networking and IoT will reshape data centers][3] + * [Edge computing best practices][9] + * [How edge computing can help secure the IoT][10] + + + +Join the Network World communities on [Facebook][11] and [LinkedIn][12] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3407852/smarter-iot-concepts-reveal-creaking-networks.html + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/02/industry_4-0_industrial_iot_internet_of_things_network_thinkstock_613880008-100749946-large.jpg +[2]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[3]: https://www.networkworld.com/article/3291790/data-center/how-edge-networking-and-iot-will-reshape-data-centers.html +[4]: http://www.ovgu.de/en/University/In+Profile/Key+Profile+Areas/Research/Secure+data+protection+in+the+new+internet+of+things.html +[5]: http://www.doriot.net/ +[6]: https://www.networkworld.com/article/3224893/what-is-edge-computing-and-how-it-s-changing-the-network.html +[7]: http://iks.cs.ovgu.de/iks/en/ICS.html +[8]: https://www.networkworld.com/article/3199671/what-is-industry-4-0.html +[9]: https://www.networkworld.com/article/3331978/lan-wan/edge-computing-best-practices.html +[10]: https://www.networkworld.com/article/3331905/internet-of-things/how-edge-computing-can-help-secure-the-iot.html +[11]: https://www.facebook.com/NetworkWorld/ +[12]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190716 Server hardware makers shift production out of China.md b/sources/talk/20190716 Server hardware makers shift production out of China.md new file mode 100644 index 0000000000..be29283977 --- /dev/null +++ b/sources/talk/20190716 Server hardware makers shift production out of China.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Server hardware makers shift production out of China) +[#]: via: (https://www.networkworld.com/article/3409784/server-hardware-makers-shift-production-out-of-china.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Server hardware makers shift production out of China +====== +Tariffs on Chinese products and unstable U.S./China relations cause server makers to speed up their move out of China. +![Etereuti \(CC0\)][1] + +The supply chain of vendors that build servers and network communication devices is accelerating its shift of production out of China to Taiwan and North America, along with other nations not subject to the trade war between the U.S. and China. + +Last May, the Trump Administration levied tariffs on a number of imported Chinese goods, computer components among them. The tariffs ranged from 10-25%. Consumers were hit hardest, since they are more price sensitive than IT buyers. PC World said the [average laptop price could rise by $120][2] just for the tariffs. + +But since the tariff was based on the value of the product, that means server hardware prices could skyrocket, since servers cost much more than PCs. + +**[ Read also: [HPE’s CEO lays out his technology vision][3] ]** + +### Companies that are moving production out of China + +The Taiwanese tech publication DigiTimes reported (article now locked behind a paywall) that Mitac Computing Technology, a server ODM, reactivated an old production line at Hsinchu Science Park (HSP) in Taiwan at the end of 2018 and restarted another for motherboard SMT process in March 2019. The company plans to establish one more SMT production line prior to the end of 2019. + +It went on to say Mitac plans to produce all of its high-end U.S.-bound servers in Taiwan and is looking to move 30% of its overall server production lines back to Taiwan in the next three years. + +Wiwynn, a cloud computing server subsidiary of Wistron, is primarily assembling its U.S.-bound servers in Mexico and has also recently established a production site in southern Taiwan per clients' requests. + +Taiwan-based server chassis and assembly player AIC recently expanded the number of its factories in Taiwan to four and has been aggressively forming cooperation with its partners to expand its capacity. Many Taiwan-based component suppliers are also expanding their capacity in Taiwan. + +**[ [Get certified as an Apple Technical Coordinator with this seven-part online course from PluralSight.][4] ]** + +Several ODMs, such as Inventec, Wiwynn, Wistron, and Foxconn, all have plants in Mexico, while Quanta Computer has production lines in the U.S. Wiwynn also plans to open manufacturing facilities in eastern U.S. + +“This is not something that just happened overnight, it’s a process that started a few years ago. The tariffs just accelerated the desire of ODMs to do it,” said Ashish Nadkarni, group vice president for infrastructure systems, platforms and technologies at IDC. “Since [President] Trump has come into office there has been saber rattling about China and a trade war. There has also been a focus on margins.” + +He added that component makers are definitely moving out of China to other parts of Asia, like Korea, the Philippines, and Vietnam. + +### HPE, Dell and Lenovo should remain unaffected + +The big three branded server makers are all largely immunized against the tariffs. HP Enterprise, Dell, and Lenovo all have U.S.-based assemblies and their contract manufacturers are in Taiwan, said Nadkarni. So, their costs should remain unaffected by tariffs. + +The tariffs are not affecting sales as much as revenue for hyperscale whitebox vendors is being stressed. Hyperscale companies such as Amazon Web Services (AWS), Microsoft, Google, etc. have contracts with vendors such as Inspur and Super Micro, and if prices fluctuate, that’s not their problem. The hardware vendor is expected to deliver at the agreed cost. + +So margins, already paper thin, can’t be passed on to the customer, unlike the aforementioned laptop example. + +“It’s not the end customers who are affected by it, it’s the vendors who are affected by it. Certain things they can pass on, like component prices. But if the build value goes up, that’s not the customers problem, that’s the vendor’s problem,” said Nadkarni. + +So while it may cost you more to buy a laptop as this trade fracas goes on, it shouldn’t cost more to buy a server. + +Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3409784/server-hardware-makers-shift-production-out-of-china.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/07/asia_china_flag_grunge-stars_pixabay_etereuti-100763424-large.jpg +[2]: https://www.pcworld.com/article/3403405/trump-tariffs-on-chinese-goods-could-cost-you-120-more-for-notebook-pcs-say-dell-hp-and-cta.html +[3]: https://www.networkworld.com/article/3394879/hpe-s-ceo-lays-out-his-technology-vision.html +[4]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fapple-certified-technical-trainer-10-11 +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190717 How edge computing is driving a new era of CDN.md b/sources/talk/20190717 How edge computing is driving a new era of CDN.md new file mode 100644 index 0000000000..643d3aa713 --- /dev/null +++ b/sources/talk/20190717 How edge computing is driving a new era of CDN.md @@ -0,0 +1,107 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How edge computing is driving a new era of CDN) +[#]: via: (https://www.networkworld.com/article/3409027/how-edge-computing-is-driving-a-new-era-of-cdn.html) +[#]: author: (Matt Conran https://www.networkworld.com/author/Matt-Conran/) + +How edge computing is driving a new era of CDN +====== +A CDN is an edge application and an edge application is a superset of what your CDN is doing. +![geralt \(CC0\)][1] + +We are living in a hyperconnected world where anything can now be pushed to the cloud. The idea of having content located in one place, which could be useful from the management’s perspective, is now redundant. Today, the users and data are omnipresent. + +The customer’s expectations have up-surged because of this evolution. There is now an increased expectation of high-quality service and a decrease in customer’s patience. In the past, one could patiently wait 10 hours to download the content. But this is certainly not the scenario at the present time. Nowadays we have high expectations and high-performance requirements but on the other hand, there are concerns as well. The internet is a weird place, with unpredictable asymmetric patterns, buffer bloat and a list of other [performance-related problems][2] that I wrote about on Network Insight. _[Disclaimer: the author is employed by Network Insight.]_ + +Also, the internet is growing at an accelerated rate. By the year 2020, the internet is expected to reach 1.5 Gigabyte of traffic per day per person. In the coming times, the world of the Internet of Things (IoT) driven by objects will far supersede these data figures as well. For example, a connected airplane will generate around 5 Terabytes of data per day. This spiraling level of volume requires a new approach to data management and forces us to re-think how we delivery applications. + +[RELATED: How Notre Dame is going all in with Amazon’s cloud][3] + +Why? Because all this information cannot be processed by a single cloud or an on-premise location. Latency will always be a problem. For example, in virtual reality (VR) anything over 7 milliseconds will cause motion sickness. When decisions are required to be taken in real-time, you cannot send data to the cloud. You can, however, make use of edge computing and a multi-CDN design. + +### Introducing edge computing and multi-CDN + +The rate of cloud adoption, all-things-video, IoT and edge computing are bringing life back to CDNs and multi-CDN designs. Typically, a multi-CDN is an implementation pattern that includes more than one CDN vendor. The traffic direction is performed by using different metrics, whereby traffic can either be load balanced or failed across the different vendors. + +Edge computing moves actions as close as possible to the source. It is the point where the physical world interacts with the digital world. Logically, the decentralized approach of edge computing will not take over the centralized approach. They will be complementary to each other, so that the application can run at its peak level, depending on its position in the network. + +For example, in IoT, saving battery life is crucial. Let’s assume an IoT device can conduct the transaction in 10ms round trip time (RTT), instead of 100ms RTT. As a result, it can use 10 times less battery. + +### The internet, a performance bottleneck + +The internet is designed on the principle that everyone can talk to everyone, thereby providing universal connectivity whether required or not. There has been a number of design changes with network address translation (NAT) being the biggest. However, essentially the role of the internet has remained the same in terms of connectivity, regardless of location. + +With this type of connectivity model, distance is an important determinant for the application’s performance. Users on the other side of the planet will suffer regardless of buffer sizes or other device optimizations. Long RTT is experienced as packets go back and forth before the actual data transmission. Although caching and traffic redirection is being used but limited success has been achieved so far. + +### The principles of application delivery + +When transmission control protocol (TCP) starts, it thinks it is back in the late 1970s. It assumes that all services are on a local area network (LAN) and there is no packet loss. It then starts to work backward from there. Back when it was designed, we didn't have real-time traffic, such as voice and video that is latency and jitter sensitive. + +Ideally, TCP was designed for the ease of use and reliability, not to boost the performance. You actually need to optimize the TCP stack. And this is why CDNs are very good at performing such tasks. For example, if a connection is received from a mobile phone, a CDN will start with the assumption that there is going to be high jitter and packet loss. This allows them to size the TCP window correctly that accurately match network conditions. + +How do you magnify the performance, what options do you have? In a generic sense, many look to lowering the latency. However, with applications, such as video streaming, latency does not tell you if the video is going to buffer. One can only assume that lower latency will lead to less buffering. In such a scenario, measurement-based on throughput is a far better performance metric since will tell you how fast an object will load. + +We have also to consider the page load times. At the network level, it's the time to first byte (TTFB) and ping. However, these mechanisms don’t tell you much about the user experience as everything fits into one packet. Using ping will not inform you about the bandwidth problems. + +And if a web page goes slower by 25% once packet loss exceeds 5% and you are measuring time to the first byte which is the 4th packet - what exactly can you learn? TTFB is comparable to an internet control message protocol (ICMP) request just one layer up the stack. It's good if something is broken but not if there is underperformance issue. + +When you examine the history of TTFB measuring, you will find that it was deployed due to the lack of Real User Monitoring (RUM) measurements. Previously TTFB was as good in approximating how fast something was going to load, but we don't have to approximate anymore as we can measure it with RUM. RUM is measurements from the end-users. An example could be the metrics generated from a webpage that is being served to an actual user. + +Conclusively, TTFB, ping and page load times are not sophisticated measurements. We should prefer RUM time measurements as much as we can. This provides a more accurate picture of the user experience. This is something which has become critical over the last decade. + +Now we are living in a world of RUM which lets us build our network based on what matters to the business users. All CDNs should aim for RUM measurements. For this, they may need to integrate with traffic management systems that intelligently measure on what the end-user really sees. + +### The need for multi-CDN + +Primarily, the reasons one would opt for a multi-CDN environment are availability and performance. No single CDN can be the fastest to everyone and everywhere in the world. It is impossible due to the internet's connectivity model. However, combining the best of two or even more CDN providers will increase the performance. + +A multi-CDN will give a faster performance and higher availability than what can be achieved with a single CDN. A good design is what runs two availability zones. A better design is what runs two availability zones with a single CDN provider. However, superior design is what runs two availability zones in a multi-CDN environment. + +### Edge applications will be the new norm + +It’s not that long ago that there was a transition from the heavy physical monolithic architecture to the agile cloud. But all that really happened was the transition from the physical appliance to a virtual cloud-based appliance. Maybe now is the time that we should ask, is this the future that we really want? + +One of the main issues in introducing edge applications is the mindset. It is challenging to convince yourself or your peers that the infrastructure you have spent all your time working on and investing in is not the best way forward for your business.  + +Although the cloud has created a big buzz, just because you migrate to the cloud does not mean that your applications will run faster. In fact, all you are really doing is abstracting the physical pieces of the architecture and paying someone else to manage it. The cloud has, however, opened the door for the edge application conversation. We have already taken the first step to the cloud and now it's time to make the second move. + +Basically, when you think about edge applications: its simplicity is a programmable CDN. A CDN is an edge application and an edge application is a superset of what your CDN is doing. Edge applications denote cloud computing at the edge. It is a paradigm to distribute the application closer to the source for lower latency, additional resilience, and simplified infrastructure, where you still have control and privacy. + +From an architectural point of view, an edge application provides more resilience than deploying centralized applications. In today's world of high expectations, resilience is a necessity for the continuity of business. Edge applications allow you to collapse the infrastructure into an architecture that is cheaper, simpler and more attentive to the application. The less in the expanse of infrastructure, the more time you can focus on what really matters to your business - the customer. + +### An example of an edge architecture + +An example of edge architecture is within each PoP, every application has its own isolated JavaScript (JS) environment. JavaScript is great for security isolation and the performance guarantees scale. The JavaScript is a dedicated isolated instance that executes the code at the edge. + +Most likely, each JavaScript has its own virtual machine (VM). The sole operation that the VM is performing is the JavaScript runtime engine and the only thing it is running is the customer's code. One could use Google V8 open-source high-performance JavaScript and WebAssembly engine. + +Let’s face it, if you continue building more PoPs, you will hit the law of diminishing returns. When it comes to application such as mobile, you really are maxed out when throwing PoPs to form a solution. So we need to find another solution. + +In the coming times, we are going to witness a trend where most applications will become global, which means edge applications. It certainly makes little sense to place all the application in one location when your users are everywhere else. + +**This article is published as part of the IDG Contributor Network. [Want to Join?][4]** + +Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3409027/how-edge-computing-is-driving-a-new-era-of-cdn.html + +作者:[Matt Conran][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Matt-Conran/ +[b]: https://github.com/lujun9972 +[1]: https://images.techhive.com/images/article/2017/02/network-traffic-100707086-large.jpg +[2]: https://network-insight.net/2016/12/buffers-packet-drops/ +[3]: https://www.networkworld.com/article/3014599/cloud-computing/how-notre-dame-is-going-all-in-with-amazon-s-cloud.html#tk.nww-fsb +[4]: https://www.networkworld.com/contributor-network/signup.html +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190717 Public internet should be all software-defined.md b/sources/talk/20190717 Public internet should be all software-defined.md new file mode 100644 index 0000000000..3b834bea66 --- /dev/null +++ b/sources/talk/20190717 Public internet should be all software-defined.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Public internet should be all software-defined) +[#]: via: (https://www.networkworld.com/article/3409783/public-internet-should-be-all-software-defined.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +Public internet should be all software-defined +====== +Having a programmable public internet will correct inefficiencies in the current system, engineers at NOIA say. +![Thinkstock][1] + +The public internet should migrate to a programmable backbone-as-a-service architecture, says a team of network engineers behind NOIA, a startup promising to revolutionize global traffic. They say the internet will be more efficient if internet protocols and routing technologies are re-worked and then combined with a traffic-trading blockchain. + +It’s “impossible to use internet for modern applications,” the company says on its website. “Almost all global internet companies struggle to ensure uptime and reliable user experience.” + +That’s because modern techniques aren’t being introduced fully, NOIA says. The engineers say algorithms should be implemented to route traffic and that segment routing technology should be adopted. Plus, blockchain should be instigated to trade internet transit capacity. A “programmable internet solves the web’s inefficiencies,” a representative from NOIA told me. + +**[ Read also: [What is IPv6, and why aren’t we there yet?][2] ]** + +### Deprecate the public internet + +NOIA has started introducing a caching, distributed content delivery application to improve website loading times, but it wants to ultimately deprecate the existing internet completely. + +The company currently has 353 active cache nodes around the world, with a total 27 terabytes of storage for that caching system—NOIA clients contribute spare bandwidth and storage. It’s also testing a network backbone using four providers with European and American locations that it says will be the [development environment for its envisaged software-defined and radical internet replacement][3]. + +### The problem with today's internet + +The “internet is a mesh of tangled up cables,” [NOIA says][4]. “Thousands of physically connected networks” are involved. Any configuration alterations in any of the jumble of networks causes issues with the protocols, it explains. The company is referring to Border Gateway Protocol (BGP), which lets routers discover paths to IP addresses through the disparate network. Because BGP only forwards to a neighboring router, it doesn’t manage the entire route. That introduces “severe variability” or unreliability. + +“It is impossible to guarantee service reliability without using overlay networks. Low-latency, performance-critical applications, and games cannot operate on public Internet,” the company says. + +### How a software-defined internet works + +NOIA's idea is to use [IPv6][5], the latest internet protocol. IPv6 features an expanded packet size and allows custom headers. The company then adds segment routing to create Segment Routing over IPv6 (SRv6). That SRv6 combo adds routing information to each data packet sent—a packet-level programmable network, in other words. + +Segment routing, roughly, is an updated internet protocol that lets routers comprehend routing information in packet headers and then perform the routing. Cisco has been using it, too. + +NOIA’s network then adds the SRv6 amalgamation to distributed ledger technology (blockchain) in order to let ISPs and data centers buy and sell the routes—buyers can choose their routes in the exchange, too. + +In addition to trade, blockchain introduces security. It's worth noting that routings aren’t the only internet technologies that could be disrupted due to blockchain. In April I wrote about [organizations that propose moving data storage transactions over to distributed ledgers][6]. They say that will be more secure than anything seen before. [Ethernet’s lack of inherent security could be corrected by smart contract, trackable verifiable transactions][7], say some. And, of course, supply chain, the automotive vertical, and the selling of sensor data overall may emerge as [use-contenders for secure, blockchain in the internet of things][8]. + +In NOIA’s case, with SRv6 blended with distributed ledgers, the encrypted ledger holds the IP addresses, but it is architecturally decentralized—no one controls it. That’s one element of added security, along with the aforementioned trading, provided by the ledger. + +That trading could handle the question of who’s paying for all this. However, NOIA says current internet hardware will be able to understand the segment routings, so no new equipment investments are needed. + +Join the Network World communities on [Facebook][9] and [LinkedIn][10] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3409783/public-internet-should-be-all-software-defined.html + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/05/dns_browser_http_web_internet_thinkstock-100758191-large.jpg +[2]: https://www.networkworld.com/article/3254575/lan-wan/what-is-ipv6-and-why-aren-t-we-there-yet.html +[3]: https://medium.com/noia/development-update-06-20-07-04-2879f9fce3cb +[4]: https://noia.network/ +[5]: https://www.networkworld.com/article/3254575/what-is-ipv6-and-why-aren-t-we-there-yet.html +[6]: https://www.networkworld.com/article/3390722/how-data-storage-will-shift-to-blockchain.html +[7]: https://www.networkworld.com/article/3356496/how-blockchain-will-manage-networks.html +[8]: https://www.networkworld.com/article/3330937/how-blockchain-will-transform-the-iot.html +[9]: https://www.facebook.com/NetworkWorld/ +[10]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190718 Worst DNS attacks and how to mitigate them.md b/sources/talk/20190718 Worst DNS attacks and how to mitigate them.md new file mode 100644 index 0000000000..b490eeeea1 --- /dev/null +++ b/sources/talk/20190718 Worst DNS attacks and how to mitigate them.md @@ -0,0 +1,151 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Worst DNS attacks and how to mitigate them) +[#]: via: (https://www.networkworld.com/article/3409719/worst-dns-attacks-and-how-to-mitigate-them.html) +[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) + +Worst DNS attacks and how to mitigate them +====== +DNS threats, including DNS hijacking, tunneling, phishing, cache poisoning and DDoS attacks, are all on the rise. +![Max Bender \(CC0\)][1] + +The Domain Name System remains under constant attack, and there seems to be no end in sight as threats grow increasingly sophisticated. + +DNS, known as the internet’s phonebook, is part of the global internet infrastructure that translates between familiar names and the numbers computers need to access a website or send an email. While DNS has long been the target of assailants looking to steal all manner of corporate and private information, the threats in the [past year][2] or so indicate a worsening of the situation. + +**More about DNS:** + + * [DNS in the cloud: Why and why not][3] + * [DNS over HTTPS seeks to make internet use more private][4] + * [How to protect your infrastructure from DNS cache poisoning][5] + * [ICANN housecleaning revokes old DNS security key][6] + + + +IDC reports that 82% of companies worldwide have faced a DNS attack over the past year. The research firm recently published its fifth annual [Global DNS Threat Report][7], which is based on a survey IDC conducted on behalf of DNS security vendor EfficientIP of 904 organizations across the world during the first half of 2019. + +According to IDC's research, the average costs associated with a DNS attack rose by 49% compared to a year earlier. In the U.S., the average cost of a DNS attack tops out at more than $1.27 million. Almost half of respondents (48%) report losing more than $500,000 to a DNS attack, and nearly 10% say they lost more than $5 million on each breach. In addition, the majority of U.S. organizations say that it took more than one day to resolve a DNS attack. + +“Worryingly, both in-house and cloud applications were damaged, with growth of over 100% for in-house application downtime, making it now the most prevalent damage suffered,” IDC wrote. "DNS attacks are moving away from pure brute-force to more sophisticated attacks acting from the internal network. This will force organizations to use intelligent mitigation tools to cope with insider threats." + +### Sea Turtle DNS hijacking campaign + +An ongoing DNS hijacking campaign known as Sea Turtle is one example of what's occuring in today's DNS threat landscape. + +This month, [Cisco Talos][8] security researchers said the people behind the Sea Turtle campaign have been busy [revamping their attacks][9] with new infrastructure and going after new victims. + +**[ [Prepare to become a Certified Information Security Systems Professional with this comprehensive online course from PluralSight. Now offering a 10-day free trial!][10] ]** + +In April, Talos released a [report detailing][11] Sea Turtle and calling it the “first known case of a domain name registry organization that was compromised for cyber espionage operations.” Talos says the ongoing DNS threat campaign is a state-sponsored attack that abuses DNS to harvest credentials to gain access to sensitive networks and systems in a way that victims are unable to detect, which displays unique knowledge on how to manipulate DNS. + +By obtaining control of victims’ DNS, the attackers can change or falsify any data on the Internet and illicitly modify DNS name records to point users to actor-controlled servers; users visiting those sites would never know, Talos reports.  + +The hackers behind Sea Turtle appear to have regrouped after the April report from Talos and are redoubling their efforts with new infrastructure – a move Talos researchers find to be unusual: “While many actors will slow down once they are discovered, this group appears to be unusually brazen, and will be unlikely to be deterred going forward,” Talos [wrote][9] in July. + +“Additionally, we discovered a new DNS hijacking technique that we assess with moderate confidence is connected to the actors behind Sea Turtle. This new technique is similar in that the threat actors compromise the name server records and respond to DNS requests with falsified A records,” Talos stated.  + +“This new technique has only been observed in a few highly targeted operations. We also identified a new wave of victims, including a country code top-level domain (ccTLD) registry, which manages the DNS records for every domain [that] uses that particular country code; that access was used to then compromise additional government entities. Unfortunately, unless there are significant changes made to better secure DNS, these sorts of attacks are going to remain prevalent,” Talos wrote. + +### DNSpionage attack upgrades its tools + +Another newer threat to DNS comes in the form of an attack campaign called [DNSpionage][12].  + +DNSpionage initially used two malicious websites containing job postings to compromise targets via crafted Microsoft Office documents with embedded macros. The malware supported HTTP and DNS communication with the attackers. And the attackers are continuing to develop new assault techniques. + +“The threat actor's ongoing development of DNSpionage malware shows that the attacker continues to find new ways to avoid detection. DNS tunneling is a popular method of exfiltration for some actors, and recent examples of DNSpionage show that we must ensure DNS is monitored as closely as an organization's normal proxy or weblogs,” [Talos wrote][13]. “DNS is essentially the phonebook of the internet, and when it is tampered with, it becomes difficult for anyone to discern whether what they are seeing online is legitimate.” + +The DNSpionage campaign targeted various businesses in the Middle East as well as United Arab Emirates government domains. + +“One of the biggest problems with DNS attacks or the lack of protection from them is complacency,” said Craig Williams, director of Talos outreach. Companies think DNS is stable and that they don’t need to worry about it. “But what we are seeing with attacks like DNSpionage and Sea Turtle are kind of the opposite, because attackers have figured out how to use it to their advantage – how to use it to do damage to credentials in a way, in the case of Sea Turtle, that the victim never even knows it happened. And that’s a real potential problem.” + +If you know, for example, your name server has been compromised, then you can force everyone to change their passwords. But if instead they go after the registrar and the registrar points to the bad guy’s name, you never knew it happened because nothing of yours was touched – that’s why these new threats are so nefarious, Williams said. + +“Once attackers start using it publicly, successfully, other bad guys are going to look at it and say, ‘Hey, why don't I use that to harvest a bunch of credentials from the sites I am interested in,’” Williams said. + +### **The DNS IoT risk** + +Another developing risk would be the proliferation of IoT devices.  The Internet Corporation for Assigned Names and Numbers (ICANN) recently wrote a [paper on the risk that IoT brings to DNS][14].  + +“The IoT is a risk to the DNS because various measurement studies suggest that IoT devices could stress the DNS infrastructure in ways that we have not seen before,” ICANN stated.   “For example, a software update for a popular IP-enabled IoT device that causes the device to use the DNS more frequently (e.g., regularly lookup random domain names to check for network availability) could stress the DNS in individual networks when millions of devices automatically install the update at the same time.” + +While this is a programming error from the perspective of individual devices, it could result in a significant attack vector from the perspective of DNS infrastructure operators. Incidents like this have already occurred on a small scale, but they may occur more frequently in the future due to the growth of heterogeneous IoT devices from manufacturers that equip their IoT devices with controllers that use the DNS, ICANN stated. + +ICANN also suggested that IoT botnets will represent an increased threat to DNS operators. “Larger DDoS attacks, partly because IoT bots are more difficult to eradicate. Current botnet sizes are on the order of hundreds of thousands. The most well-known example is the Mirai botnet, which involved 400K (steady-state) to 600K (peak) infected IoT devices.  The Hajime botnet hovers around 400K infected IoT devices, but has not launched any DDoS attacks yet. With the growth of the IoT, these attacks may grow to involve millions of bots and as a result larger DDoS attacks. + +### **DNS security warnings grow** + +The UK's [National Cyber Security Centre (NCSC)][15] issued a warning this month about ongoing DNS attacks, particularly focusing on DNS hijacking. It cited a number of risks associated with the uptick in DNS hijacking including: + +**Creating malicious DNS records.** A malicious DNS record could be used, for example, to create a phishing website that is present within an organization’s familiar domain. This may be used to phish employees or customers. + +**Obtaining SSL certificates.** Domain-validated SSL certificates are issued based on the creation of DNS records; thus an attacker may obtain valid SSL certificates for a domain name, which could be used to create a phishing website intended to look like an authentic website, for example. + +**Transparent proxying.** One serious risk employed recently involves transparently proxying traffic to intercept data. The attacker modifies an organization’s configured domain zone entries (such as “A” or “CNAME” records) to point traffic to their own IP address, which is infrastructure they manage. + +“An organization may lose total control of their domain and often the attackers will change the domain ownership details making it harder to recover,” the NCSC wrote. + +These new threats, as well as other dangers, led the U.S. government to issue a warning earlier this year about DNS attacks on federal agencies.  + +The Department of Homeland Security’s Cybersecurity and Infrastructure Security Agency (CISA) told all federal agencies to bolt down their DNS in the face of a series of global hacking campaigns. + +CISA said in its [Emergency Directive][16] that it was tracking a series of incidents targeting DNS infrastructure. CISA wrote that it “is aware of multiple executive branch agency domains that were impacted by the tampering campaign and has notified the agencies that maintain them.” + +CISA says that attackers have managed to intercept and redirect web and mail traffic and could target other networked services. The agency said the attacks start with compromising user credentials of an account that can make changes to DNS records.  Then the attacker alters DNS records, like Address, Mail Exchanger, or Name Server records, replacing the legitimate address of the services with an address the attacker controls. + +These actions let the attacker direct user traffic to their own infrastructure for manipulation or inspection before passing it on to the legitimate service, should they choose. This creates a risk that persists beyond the period of traffic redirection, CISA stated.  + +“Because the attacker can set DNS record values, they can also obtain valid encryption certificates for an organization’s domain names. This allows the redirected traffic to be decrypted, exposing any user-submitted data. Since the certificate is valid for the domain, end users receive no error warnings,” CISA stated. + +### **Get on the DNSSEC bandwagon** + +“Enterprises that are potential targets – in particular those that capture or expose user and enterprise data through their applications – should heed this advisory by the NSCS and should pressure their DNS and registrar vendors to make DNSSEC and other domain security best practices easy to implement and standardized,” said Kris Beevers, co-founder and CEO of DNS security vendor [NS1][17]. “They can easily implement DNSSEC signing and other domain security best practices with technologies in the market today. At the very least, they should work with their vendors and security teams to audit their implementations.” + +DNSSEC was in the news earlier this year when in response to increased DNS attacks, ICANN called for an intensified community effort to install stronger DNS security technology.  + +Specifically, ICANN wants full deployment of the Domain Name System Security Extensions ([DNSSEC][18]) across all unsecured domain names. DNSSEC adds a layer of security on top of DNS. Full deployment of DNSSEC ensures end users are connecting to the actual web site or other service corresponding to a particular domain name, ICANN said. “Although this will not solve all the security problems of the Internet, it does protect a critical piece of it – the directory lookup – complementing other technologies such as SSL (https:) that protect the ‘conversation’, and provide a platform for yet-to-be-developed security improvements,” ICANN stated. + +DNSSEC technologies have been around since about 2010 but are not widely deployed, with less than 20% of the world’s DNS registrars having deployed it, according to the regional internet address registry for the Asia-Pacific region ([APNIC][19]). + +DNSSEC adoption has been lagging because it was viewed as optional and can require a tradeoff between security and functionality, said NS1's Beevers. + +### **Traditional DNS threats** + +While DNS hijacking may be the front line attack method, other more traditional threats still exist.  + +The IDC/EfficientIP study found most popular DNS threats have changed compared with last year. Phishing (47%) is now more popular than last year’s favorite, DNS-based malware (39%), followed by DDoS attacks (30%), false positive triggering (26%), and lock-up domain attacks (26%). + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3409719/worst-dns-attacks-and-how-to-mitigate-them.html + +作者:[Michael Cooney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Michael-Cooney/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/08/anonymous_faceless_hooded_mand_in_scary_halloween_mask_finger_to_lips_danger_threat_stealth_attack_hacker_hush_silence_warning_by_max_bender_cc0_via_unsplash_1200x800-100766358-large.jpg +[2]: https://www.fireeye.com/blog/threat-research/2019/01/global-dns-hijacking-campaign-dns-record-manipulation-at-scale.html +[3]: https://www.networkworld.com/article/3273891/hybrid-cloud/dns-in-the-cloud-why-and-why-not.html +[4]: https://www.networkworld.com/article/3322023/internet/dns-over-https-seeks-to-make-internet-use-more-private.html +[5]: https://www.networkworld.com/article/3298160/internet/how-to-protect-your-infrastructure-from-dns-cache-poisoning.html +[6]: https://www.networkworld.com/article/3331606/security/icann-housecleaning-revokes-old-dns-security-key.html +[7]: https://www.efficientip.com/resources/idc-dns-threat-report-2019/ +[8]: https://www.talosintelligence.com/ +[9]: https://blog.talosintelligence.com/2019/07/sea-turtle-keeps-on-swimming.html +[10]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr +[11]: https://blog.talosintelligence.com/2019/04/seaturtle.html +[12]: https://www.networkworld.com/article/3390666/cisco-dnspionage-attack-adds-new-tools-morphs-tactics.html +[13]: https://blog.talosintelligence.com/2019/04/dnspionage-brings-out-karkoff.html +[14]: https://www.icann.org/en/system/files/files/sac-105-en.pdf +[15]: https://www.ncsc.gov.uk/news/ongoing-dns-hijacking-and-mitigation-advice +[16]: https://cyber.dhs.gov/ed/19-01/ +[17]: https://ns1.com/ +[18]: https://www.icann.org/resources/pages/dnssec-qaa-2014-01-29-en +[19]: https://www.apnic.net/ diff --git a/sources/talk/20190724 Data centers may soon recycle heat into electricity.md b/sources/talk/20190724 Data centers may soon recycle heat into electricity.md new file mode 100644 index 0000000000..92298e1a01 --- /dev/null +++ b/sources/talk/20190724 Data centers may soon recycle heat into electricity.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Data centers may soon recycle heat into electricity) +[#]: via: (https://www.networkworld.com/article/3410578/data-centers-may-soon-recycle-heat-into-electricity.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +Data centers may soon recycle heat into electricity +====== +Rice University researchers are developing a system that converts waste heat into light and then that light into electricity, which could help data centers reduce computing costs. +![Gordon Mah Ung / IDG][1] + +Waste heat is the scurge of computing. In fact, much of the cost of powering a computer is from creating unwanted heat. That’s because the inefficiencies in electronic circuits, caused by resistance in the materials, generates that heat. The processors, without computing anything, are essentially converting expensively produced electrical energy into waste energy. + +It’s a fundamental problem, and one that hasn’t been going away. But what if you could convert the unwanted heat back into electricity—recycle the heat back into its original energy form? The data center heat, instead of simply disgorging into the atmosphere to be gotten rid of with dubious eco-effects, could actually run more machines. Plus, your cooling costs would be taken care of—there’s nothing to cool because you’ve already grabbed the hot air. + +**[ Read also: [How server disaggregation can boost data center efficiency][2] | Get regularly scheduled insights: [Sign up for Network World newsletters][3] ]** + +Scientists at Rice Univeristy are trying to make that a reality by developing heat scavenging and conversion solutions. + +Currently, the most efficient way to convert heat into electricity is through the use of traditional turbines. + +Turbines “can give you nearly 50% conversion efficiency,” says Chloe Doiron, a graduate student at Rice University and co-lead on the project, in a [news article][4] on the school’s website. Turbines convert the kinetic energy of moving fluids, like steam or combustion gases, into mechanical energy. The moving steam then shifts blades mounted on a shaft, which turns a generator, thus creating the power. + +Not a bad solution. The problem, though, is “those systems are not easy to implement,” the researchers explain. The issue is that turbines are full of moving parts, and they’re big, noisy, and messy. + +### Thermal emitter better than turbines for converting heat to energy + +A better option would be a solid-state, thermal device that could absorb heat at the source and simply convert it, perhaps straight into attached batteries. + +The researchers say a thermal emitter could absorb heat, jam it into tight, easy-to-capture bandwidth and then emit it as light. Cunningly, they would then simply turn the light into electricity, as we see all the time now in solar systems. + +“Thermal photons are just photons emitted from a hot body,” says Rice University professor Junichiro Kono in the article. “If you look at something hot with an infrared camera, you see it glow. The camera is capturing these thermally excited photons.” Indeed, all heated surfaces, to some extent, send out light as thermal radiation. + +The Rice team wants to use a film of aligned carbon nanotubes to do the job. The test system will be structured as an actual solar panel. That’s because solar panels, too, lose energy through heat, so are a good environment in which to work. The concept applies to other inefficient technologies, too. “Anything else that loses energy through heat [would become] far more efficient,” the researchers say. + +Around 20% of industrial energy consumption is unwanted heat, Doiron says. That's a lot of wasted energy. + +### Other heat conversion solutions + +Other heat scavenging devices are making inroads, too. Now-commercially available thermoelectric technology can convert a temperature difference into power, also with no moving parts. They function by exposing a specially made material to heat. [Electrons flow when one part is cold and one is hot][5]. And the University of Utah is working on [silicon for chips that generates electricity][6] as one of two wafers heat up. + +Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3410578/data-centers-may-soon-recycle-heat-into-electricity.html + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/07/flir_20190711t191326-100801627-large.jpg +[2]: https://www.networkworld.com/article/3266624/how-server-disaggregation-could-make-cloud-datacenters-more-efficient.html +[3]: https://www.networkworld.com/newsletters/signup.html +[4]: https://news.rice.edu/2019/07/12/rice-device-channels-heat-into-light/ +[5]: https://www.networkworld.com/article/2861438/how-to-convert-waste-data-center-heat-into-electricity.html +[6]: https://unews.utah.edu/beat-the-heat/ +[7]: https://www.facebook.com/NetworkWorld/ +[8]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190724 Reports- As the IoT grows, so do its threats to DNS.md b/sources/talk/20190724 Reports- As the IoT grows, so do its threats to DNS.md new file mode 100644 index 0000000000..d9647304b9 --- /dev/null +++ b/sources/talk/20190724 Reports- As the IoT grows, so do its threats to DNS.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Reports: As the IoT grows, so do its threats to DNS) +[#]: via: (https://www.networkworld.com/article/3411437/reports-as-the-iot-grows-so-do-its-threats-to-dns.html) +[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) + +Reports: As the IoT grows, so do its threats to DNS +====== +ICANN and IBM's security researchers separately spell out how the growth of the internet of things will increase opportunities for malicious actors to attack the Domain Name System with hyperscale botnets and worm their malware into the cloud. +The internet of things is shaping up to be a more significant threat to the Domain Name System through larger IoT botnets, unintentional adverse effects of IoT-software updates and the continuing development of bot-herding software. + +The Internet Corporation for Assigned Names and Numbers (ICANN) and IBM’s X-Force security researchers have recently issued reports outlining the interplay between DNS and IoT that includes warnings about the pressure IoT botnets will put on the availability of DNS systems. + +**More about DNS:** + + * [DNS in the cloud: Why and why not][1] + * [DNS over HTTPS seeks to make internet use more private][2] + * [How to protect your infrastructure from DNS cache poisoning][3] + * [ICANN housecleaning revokes old DNS security key][4] + + + +ICANN’s Security and Stability Advisory Committee (SSAC) wrote in a [report][5] that “a significant number of IoT devices will likely be IP enabled and will use the DNS to locate the remote services they require to perform their functions. As a result, the DNS will continue to play the same crucial role for the IoT that it has for traditional applications that enable human users to interact with services and content,” ICANN stated. “The  role of  the  DNS  might  become  even  more  crucial  from  a  security  and  stability perspective with IoT devices interacting with people’s physical environment.” + +IoT represents both an opportunity and a risk to the DNS, ICANN stated. “It is an opportunity because the DNS provides functions and data that can help make the IoT more secure, stable, and transparent, which is critical given the IoT's interaction with the physical world. It is a risk because various measurement studies suggest that IoT devices may stress the DNS, for instance, because of complex DDoS attacks carried out by botnets that grow to hundreds of thousands or in the future millions of infected IoT devices within hours,” ICANN stated. + +Unintentional DDoS attacks + +One risk is that the IoT could place new burdens on the DNS. “For example, a software update for a popular IP-enabled IoT device that causes the device to use the DNS more frequently (e.g., regularly lookup random domain names to check for network availability) could stress the DNS in individual networks when millions of devices automatically install the update at the same time,” ICANN stated. + +While this is a programming error from the perspective of individual devices, it could result in a significant attack vector from the perspective of DNS infrastructure operators. Incidents like this have already occurred on a small scale, but they may occur more frequently in the future due to the growth of heterogeneous IoT devices from manufacturers that equip their IoT devices with controllers that use the DNS, ICANN stated. + +Massively larger botnets, threat to clouds + +The report also suggested that the scale of IoT botnets could grow from hundreds of thousands of devices to millions. The best known IoT botnet is Mirai, responsible for DDoS attacks involving 400,000 to 600,000 devices. The Hajime botnet hovers around 400K infected IoT devices but has not launched any DDoS attacks yet. But as the IoT grows, so will the botnets and as a result larger DDoS attacks. + +Cloud-connected IoT devices could endanger cloud resources. “IoT devices connected to cloud architecture could allow Mirai adversaries to gain access to cloud servers. They could infect a server with additional malware dropped by Mirai or expose all IoT devices connected to the server to further compromise,” wrote Charles DeBeck,  a senior cyber threat intelligence strategic analyst with [IBM X-Force Incident Response][6] in a recent report.  + + “As organizations increasingly adopt cloud architecture to scale efficiency and productivity, disruption to a cloud environment could be catastrophic.” + +For enterprises that are rapidly adopting both IoT technology and cloud architecture, insufficient security controls could expose the organization to elevated risk, calling for the security committee to conduct an up-to-date risk assessment, DeBeck stated. + +Attackers continue malware development + +“Since this activity is highly automated, there remains a strong possibility of large-scale infection of IoT devices in the future,” DeBeck stated. “Additionally, threat actors are continuing to expand their targets to include new types of IoT devices and may start looking at industrial IoT devices or connected wearables to increase their footprint and profits.” + +Botnet bad guys are also developing new Mirai variants and IoT botnet malware outside of the Mirai family to target IoT devices, DeBeck stated. + +To continue reading this article register now + +[Get Free Access][7] + +[Learn More][8]   Existing Users [Sign In][7] + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3411437/reports-as-the-iot-grows-so-do-its-threats-to-dns.html + +作者:[Michael Cooney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Michael-Cooney/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3273891/hybrid-cloud/dns-in-the-cloud-why-and-why-not.html +[2]: https://www.networkworld.com/article/3322023/internet/dns-over-https-seeks-to-make-internet-use-more-private.html +[3]: https://www.networkworld.com/article/3298160/internet/how-to-protect-your-infrastructure-from-dns-cache-poisoning.html +[4]: https://www.networkworld.com/article/3331606/security/icann-housecleaning-revokes-old-dns-security-key.html +[5]: https://www.icann.org/en/system/files/files/sac-105-en.pdf +[6]: https://securityintelligence.com/posts/i-cant-believe-mirais-tracking-the-infamous-iot-malware-2/?cm_mmc=OSocial_Twitter-_-Security_Security+Brand+and+Outcomes-_-WW_WW-_-SI+TW+blog&cm_mmca1=000034XK&cm_mmca2=10009814&linkId=70790642 +[7]: javascript:// +[8]: https://www.networkworld.com/learn-about-insider/ diff --git a/sources/talk/20190724 When it comes to the IoT, Wi-Fi has the best security.md b/sources/talk/20190724 When it comes to the IoT, Wi-Fi has the best security.md new file mode 100644 index 0000000000..2b5014dfa8 --- /dev/null +++ b/sources/talk/20190724 When it comes to the IoT, Wi-Fi has the best security.md @@ -0,0 +1,88 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (When it comes to the IoT, Wi-Fi has the best security) +[#]: via: (https://www.networkworld.com/article/3410563/when-it-comes-to-the-iot-wi-fi-has-the-best-security.html) +[#]: author: (Fredric Paul https://www.networkworld.com/author/Fredric-Paul/) + +When it comes to the IoT, Wi-Fi has the best security +====== +It’s easy to dismiss good ol’ Wi-Fi’s role in internet of things networking. But Wi-Fi has more security advantages than other IoT networking choices. +![Ralph Gaithe / Soifer / Getty Images][1] + +When it comes to connecting internet of things (IoT) devices, there is a wide variety of networks to choose from, each with its own set of capabilities, advantages and disadvantages, and ideal use cases. Good ol’ Wi-Fi is often seen as a default networking choice, available in many places, but of limited range and not particularly suited for IoT implementations. + +According to [Aerohive Networks][2], however, Wi-Fi is “evolving to help IT address security complexities and challenges associated with IoT devices.” Aerohive sells cloud-managed networking solutions and was [acquired recently by software-defined networking company Extreme Networks for some $272 million][3]. And Aerohive's director of product marketing, Mathew Edwards, told me via email that Wi-Fi brings a number of security advantages compared to other IoT networking choices. + +It’s not a trivial problem. According to Gartner, in just the last three years, [approximately one in five organizations have been subject to an IoT-based attack][4]. And as more and more IoT devices come on line, the attack surface continues to grow quickly. + +**[ Also read: [Extreme targets cloud services, SD-WAN, Wi-Fi 6 with $210M Aerohive grab][3] and [Smart cities offer window into the evolution of enterprise IoT technology][5] ]** + +### What makes Wi-Fi more secure for IoT? + +What exactly are Wi-Fi’s IoT security benefits? Some of it is simply 20 years of technological maturity, Edwards said. + +“Extending beyond the physical boundaries of organizations, Wi-Fi has always had to be on the front foot when it comes to securely onboarding and monitoring a range of corporate, guest, and BYOD devices, and is now prepared with the next round of connectivity complexities with IoT,” he said. + +Specifically, Edwards said, “Wi-Fi has evolved … to increase the visibility, security, and troubleshooting of edge devices by combining edge security with centralized cloud intelligence.” + +Just as important, though, new Wi-Fi capabilities from a variety of vendors are designed to help identify and isolate IoT devices to integrate them into the wider network while limiting the potential risks. The goal is to incorporate IoT device awareness and protection mechanisms to prevent breaches and attacks through vulnerable headless devices. Edwards cited Aerohive’s work to “securely onboard IoT devices with its PPSK (private pre-shared key) technology, an authentication and encryption method providing 802.1X-equivalent role-based access, without the equivalent management complexities.” + +**[ [Prepare to become a Certified Information Security Systems Professional with this comprehensive online course from PluralSight. Now offering a 10-day free trial!][6] ]** + +### The IoT is already here—and so is Wi-Fi + +Unfortunately, enterprise IoT security is not always a carefully planned and monitored operation. + +“Much like BYOD,” Edwards said, “many organizations are dealing with IoT without them even knowing it.” On the plus side, even as “IoT devices have infiltrated many networks , ... administrators are already leveraging some of the tools to protect against IoT threats without them even realizing it.” + +He noted that customers who have already deployed PPSK to secure guest and BYOD networks can easily extend those capabilities to cover IoT devices such as “smart TVs, projectors, printers, security systems, sensors and more.” + +In addition, Edwards said, “vendors have introduced methods to assign performance and security limits through context-based profiling, which is easily extended to IoT devices once the vendor can utilize signatures to identify an IoT device.” + +Once an IoT device is identified and tagged, Wi-Fi networks can assign it to a particular VLAN, set minimum and maximum data rates, data limits, application access, firewall rules, and other protections. That way, Edwards said, “if the device is lost, stolen, or launches a DDoS attack, the Wi-Fi network can kick it off, restrict it, or quarantine it.” + +### Wi-Fi still isn’t for every IoT deployment + +All that hardly turns Wi-Fi into the perfect IoT network. Relatively high costs and limited range mean it won’t find a place in many large-scale IoT implementations. But Edwards says Wi-Fi’s mature identification and control systems can help enterprises incorporate new IoT-based systems and sensors into their networks with more confidence. + +**More about 802.11ax (Wi-Fi 6)** + + * [Why 802.11ax is the next big thing in wireless][7] + * [FAQ: 802.11ax Wi-Fi][8] + * [Wi-Fi 6 (802.11ax) is coming to a router near you][9] + * [Wi-Fi 6 with OFDMA opens a world of new wireless possibilities][10] + * [802.11ax preview: Access points and routers that support Wi-Fi 6 are on tap][11] + + + +Join the Network World communities on [Facebook][12] and [LinkedIn][13] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3410563/when-it-comes-to-the-iot-wi-fi-has-the-best-security.html + +作者:[Fredric Paul][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Fredric-Paul/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/03/hack-your-own-wi-fi_neon-wi-fi_keyboard_hacker-100791531-large.jpg +[2]: http://www.aerohive.com/ +[3]: https://www.networkworld.com/article/3405440/extreme-targets-cloud-services-sd-wan-wifi-6-with-210m-aerohive-grab.html +[4]: https://www.gartner.com/en/newsroom/press-releases/2018-03-21-gartner-says-worldwide-iot-security-spending-will-reach-1-point-5-billion-in-2018. +[5]: https://www.networkworld.com/article/3409787/smart-cities-offer-window-into-the-evolution-of-enterprise-iot-technology.html +[6]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr +[7]: https://www.networkworld.com/article/3215907/mobile-wireless/why-80211ax-is-the-next-big-thing-in-wi-fi.html +[8]: https://%20https//www.networkworld.com/article/3048196/mobile-wireless/faq-802-11ax-wi-fi.html +[9]: https://www.networkworld.com/article/3311921/mobile-wireless/wi-fi-6-is-coming-to-a-router-near-you.html +[10]: https://www.networkworld.com/article/3332018/wi-fi/wi-fi-6-with-ofdma-opens-a-world-of-new-wireless-possibilities.html +[11]: https://www.networkworld.com/article/3309439/mobile-wireless/80211ax-preview-access-points-and-routers-that-support-the-wi-fi-6-protocol-on-tap.html +[12]: https://www.facebook.com/NetworkWorld/ +[13]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190725 IoT-s role in expanding drone use.md b/sources/talk/20190725 IoT-s role in expanding drone use.md new file mode 100644 index 0000000000..a9281dcf40 --- /dev/null +++ b/sources/talk/20190725 IoT-s role in expanding drone use.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (IoT’s role in expanding drone use) +[#]: via: (https://www.networkworld.com/article/3410564/iots-role-in-expanding-drone-use.html) +[#]: author: (Fredric Paul https://www.networkworld.com/author/Fredric-Paul/) + +IoT’s role in expanding drone use +====== +Collision avoidance technology that uses internet of things (IoT) connectivity, AI, machine learning, and computer vision could be the key to expanding drone applications. +![Thinkstock][1] + +As faithful readers of [TechWatch][2] (love you, Mom) may know, the rollout of many companies’ ambitious drone delivery services has not gone as quickly as promised. Despite recent signs of progress in Australia and the United States—not to mention [clever ideas for burger deliveries to cars stuck in traffic][3]—drone delivery remains a long way from becoming a viable option in the vast majority of use cases. And the problem affects many areas of drone usage, not just the heavily hyped drone delivery applications. + +According to [Grace McKenzie][4], director of operations and controller at [Iris Automation][5], one key restriction to economically viable drone deliveries is that the “skies are not safe enough for many drone use cases.” + +Speaking at a recent [SF New Tech “Internet of Everything” event in San Francisco][6], McKenzie said fear of collisions with manned aircraft is the big reason why the Federal Aviation Association (FAA) and international regulators typically prohibit drones from flying beyond the line of the sight of the remote pilot. Obviously, she added, that restriction greatly constrains where and how drones can make deliveries and is working to keep the market from growing test and pilot programs into full-scale commercial adoption. + +**[ Read also: [No, drone delivery still isn’t ready for prime time][7] | Get regularly scheduled insights: [Sign up for Network World newsletters][8] ]** + +### Detect and avoid technology is critical + +Iris Automation, not surprisingly, is in the business of creating workable collision avoidance systems for drones in an attempt to solve this issue. Variously called “detect and avoid” or “sense and avoid” technologies, these automated solutions are required for “beyond visual line of sight” (BVLOS) drone operations. There are multiple issues in play. + +As explained on Iris’ website, “Drone pilots are skilled aviators, but even they struggle to see and avoid obstacles and aircraft when operating drones at extended range [and] no pilot on board means low situational awareness. This risk is huge, and the potential conflicts can be extremely dangerous.” + +As “a software company with a hardware problem,” McKenzie said, Iris’ systems use artificial intelligence (AI), machine learning, computer vision, and IoT connectivity to identify and focus on the “small group of pixels that could be a risk.” Working together, those technologies are creating an “exponential curve” in detect-and-avoid technology improvements, she added. The result? Drones that “see better than a human pilot,” she claimed. + +### Bigger market and new use cases for drones + +It’s hardly an academic issue. “Not being able to show adequate mitigation of operational risk means regulators are forced to limit drone uses and applications to closed environments,” the company says. + +Solving this problem would open up a wide range of industrial and commercial applications for drones. Far beyond delivering burritos, McKenzie said that with confidence in drone “sense and avoid” capabilities, drones could be used for all kinds of aerial data gathering, from inspecting hydro-electric dams, power lines, and railways to surveying crops to fighting forest fires and conducting search-and-rescue operations. + +Join the Network World communities on [Facebook][9] and [LinkedIn][10] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3410564/iots-role-in-expanding-drone-use.html + +作者:[Fredric Paul][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Fredric-Paul/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/01/drone_delivery_package_future-100745961-large.jpg +[2]: https://www.networkworld.com/blog/techwatch/ +[3]: https://www.networkworld.com/article/3396188/the-traffic-jam-whopper-project-may-be-the-coolestdumbest-iot-idea-ever.html +[4]: https://www.linkedin.com/in/withgracetoo/ +[5]: https://www.irisonboard.com/ +[6]: https://sfnewtech.com/event/iot/ +[7]: https://www.networkworld.com/article/3390677/drone-delivery-not-ready-for-prime-time.html +[8]: https://www.networkworld.com/newsletters/signup.html +[9]: https://www.facebook.com/NetworkWorld/ +[10]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190725 Report- Smart-city IoT isn-t smart enough yet.md b/sources/talk/20190725 Report- Smart-city IoT isn-t smart enough yet.md new file mode 100644 index 0000000000..da6d4ee57a --- /dev/null +++ b/sources/talk/20190725 Report- Smart-city IoT isn-t smart enough yet.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Report: Smart-city IoT isn’t smart enough yet) +[#]: via: (https://www.networkworld.com/article/3411561/report-smart-city-iot-isnt-smart-enough-yet.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +Report: Smart-city IoT isn’t smart enough yet +====== +A report from Forrester Research details vulnerabilities affecting smart-city internet of things (IoT) infrastructure and offers some methods of mitigation. +![Aleksandr Durnov / Getty Images][1] + +Security arrangements for smart-city IoT technology around the world are in an alarming state of disrepair, according to a report from Forrester Research that argues serious changes are needed in order to avoid widespread compromises. + +Much of what’s wrong has to do with a lack of understanding on the part of the people in charge of those systems and a failure to follow well-known security best practices, like centralized management, network visibility and limiting attack-surfaces. + +**More on IoT:** + + * [What is the IoT? How the internet of things works][2] + * [What is edge computing and how it’s changing the network][3] + * [Most powerful Internet of Things companies][4] + * [10 Hot IoT startups to watch][5] + * [The 6 ways to make money in IoT][6] + * [What is digital twin technology? [and why it matters]][7] + * [Blockchain, service-centric networking key to IoT success][8] + * [Getting grounded in IoT networking and security][9] + * [Building IoT-ready networks must become a priority][10] + * [What is the Industrial IoT? [And why the stakes are so high]][11] + + + +Those all pose stiff challenges, according to “Making Smart Cities Safe And Secure,” the Forrester report by Merritt Maxim and Salvatore Schiano. The attack surface for a smart city is, by default, enormous, given the volume of Internet-connected hardware involved. Some device, somewhere, is likely to be vulnerable, and with the devices geographically spread out it’s difficult to secure all types of access to them. + +Worse still, some legacy systems can be downright impossible to manage and update in a safe way. Older technology often contains no provision for live updates, and its vulnerabilities can be severe, according to the report. Physical access to some types of devices also remains a serious challenge. The report gives the example of wastewater treatment plants in remote locations in Australia, which were sabotaged by a contractor who accessed the SCADA systems directly. + +In addition to the risk of compromised control systems, the generalized insecurity of smart city IoT makes the vast amounts of data that it generates highly suspect. Improperly configured devices could collect more information than they’re supposed to, including personally identifiable information, which could violate privacy regulations. Also, the data collected is analyzed to glean useful information about such things as parking patterns, water flow and electricity use, and inaccurate or compromised information can badly undercut the value of smart city technology to a given user. + +“Security teams are just gaining maturity in the IT environment with the necessity for data inventory, classification, and flow mapping, together with thorough risk and privacy impact assessments, to drive appropriate protection,” the report says. “In OT environments, they’re even further behind.” + +Yet, despite the fact that IoT planning and implementation doubled between 2017 and 2018, according to Forrester’s data, comparatively little work has been done on the security front. The report lists 13 cyberattacks on smart-city technology between 2014 and 2019 that had serious consequences, including widespread electricity outages, ransomware infections on hospital computers and emergency-service interruptions. + +Still, there are ways forward, according to Forrester. Careful log monitoring can keep administrators abreast of what’s normal and what’s suspicious on their networks. Asset mapping and centralizing control-plane functionality should make it much more difficult for bad actors to insert malicious devices into a smart-city network or take control of less-secure items. And intelligent alerting – the kind that provides contextual information, differentiating between “this system just got rained on and has poor connectivity” and “someone is tampering with this system” – should help cities be more responsive to security threats when they arise. + +Join the Network World communities on [Facebook][12] and [LinkedIn][13] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3411561/report-smart-city-iot-isnt-smart-enough-yet.html + +作者:[Jon Gold][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/smart_city_smart_cities_iot_internet_of_things_by_aleksandr_durnov_gettyimages-971455374_2400x1600-100788363-large.jpg +[2]: https://www.networkworld.com/article/3207535/internet-of-things/what-is-the-iot-how-the-internet-of-things-works.html +[3]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[4]: https://www.networkworld.com/article/2287045/internet-of-things/wireless-153629-10-most-powerful-internet-of-things-companies.html +[5]: https://www.networkworld.com/article/3270961/internet-of-things/10-hot-iot-startups-to-watch.html +[6]: https://www.networkworld.com/article/3279346/internet-of-things/the-6-ways-to-make-money-in-iot.html +[7]: https://www.networkworld.com/article/3280225/internet-of-things/what-is-digital-twin-technology-and-why-it-matters.html +[8]: https://www.networkworld.com/article/3276313/internet-of-things/blockchain-service-centric-networking-key-to-iot-success.html +[9]: https://www.networkworld.com/article/3269736/internet-of-things/getting-grounded-in-iot-networking-and-security.html +[10]: https://www.networkworld.com/article/3276304/internet-of-things/building-iot-ready-networks-must-become-a-priority.html +[11]: https://www.networkworld.com/article/3243928/internet-of-things/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html +[12]: https://www.facebook.com/NetworkWorld/ +[13]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190725 Storage management a weak area for most enterprises.md b/sources/talk/20190725 Storage management a weak area for most enterprises.md new file mode 100644 index 0000000000..859c1caa32 --- /dev/null +++ b/sources/talk/20190725 Storage management a weak area for most enterprises.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Storage management a weak area for most enterprises) +[#]: via: (https://www.networkworld.com/article/3411400/storage-management-a-weak-area-for-most-enterprises.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Storage management a weak area for most enterprises +====== +Survey finds companies are adopting technology for such things as AI, machine learning, edge computing and IoT, but still use legacy storage that can't handle those workloads. +![Miakievy / Getty Images][1] + +Stop me if you’ve heard this before: Companies are racing to a new technological paradigm but are using yesterday’s tech to do it. + +I know. Shocking. + +A survey of more than 300 storage professionals by storage vendor NGD Systems found only 11% of the companies they talked to would give themselves an “A” grade for their compute and storage capabilities. + +Why? The chief reason given is that while enterprises are rapidly deploying technologies for edge networks, real-time analytics, machine learning, and internet of things (IoT) projects, they are still using legacy storage solutions that are not designed for such data-intensive workloads. More than half — 54% — said their processing of edge applications is a bottleneck, and they want faster and more intelligent storage solutions. + +**[ Read also: [What is NVMe, and how is it changing enterprise storage][2] ]** + +### NVMe SSD use increases, but doesn't solve all needs + +It’s not all bad news. The study, entitled ["The State of Storage and Edge Computing"][3] and conducted by Dimensional Research, found 60% of storage professionals are using NVMe SSDs to speed up the processing of large data sets being generated at the edge. + +However, this has not solved their needs. As artificial intelligence (AI) and other data-intensive deployments increase, data needs to be moved over increasingly longer distances, which causes network bottlenecks and delays analytic results. And edge computing systems tend to have a smaller footprint than a traditional data center, so they are performance constrained. + +The solution is to process the data where it is ingested, in this case, the edge device. Separate the wheat from the chafe and only send relevant data upstream to a data center to be processed. This is called computational storage, processing data where it is stored rather than moving it around. + +According to the survey, 89% of respondents said they expect real value from computational storage. Conveniently, NGD is a vendor of computational storage systems. So, yes, this is a self-serving finding. This happens a lot. That doesn’t mean they don’t have a valid point, though. Processing the data where it lies is the point of edge computing. + +Among the survey’s findings: + + * 55% use edge computing + * 71% use edge computing for real-time analytics + * 61% said the cost of traditional storage solutions continues to plague their applications + * 57% said faster access to storage would improve their compute abilities + + + +The study also found that [NVMe][2] is being adopted very quickly but is being hampered by price. + + * 86% expect storage’s future to rely on NVMe SSDs + * 60% use NVMe SSDs in their work environments + * 63% said NVMe SSDs helped with superior storage speed + * 67% reported budget and cost as issues preventing the use of NVMe SSDs + + + +That last finding is why so many enterprises are hampered in their work. For whatever reason they are using old storage systems rather than new NVMe systems, and it hurts them. + +### GPUs won't improve workload performance + +One interesting finding: 70% of respondents said they are using GPUs to help improve workload performance, but NGD said those are no good. + +“We were not surprised to find that while more than half of respondents are actively using edge computing, more than 70% are using legacy GPUs, which will not reduce the network bandwidth, power and footprint necessary to analyze mass data-sets in real time,” said Nader Salessi, CEO and founder of NGD Systems, in a statement. + +That’s because GPUs lend themselves well to repetitive tasks and parallel processing jobs, while computational storage is very much a serial processing job, with the task constantly changing. So while some processing jobs will benefit from a GPU, a good number will not and the GPU is essentially wasted. + +Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3411400/storage-management-a-weak-area-for-most-enterprises.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/edge_computing_by_miakievy_gettyimages-957694592_2400x1600-100788315-large.jpg +[2]: https://www.networkworld.com/article/3280991/what-is-nvme-and-how-is-it-changing-enterprise-storage.html +[3]: https://ngd.dnastaging.net/brief/NGD_Systems_Storage_Edge_Computing_Survey_Report +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190726 NVMe over Fabrics enterprise storage spec enters final review process.md b/sources/talk/20190726 NVMe over Fabrics enterprise storage spec enters final review process.md new file mode 100644 index 0000000000..f14dcd7d67 --- /dev/null +++ b/sources/talk/20190726 NVMe over Fabrics enterprise storage spec enters final review process.md @@ -0,0 +1,71 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (NVMe over Fabrics enterprise storage spec enters final review process) +[#]: via: (https://www.networkworld.com/article/3411958/nvme-over-fabrics-enterprise-storage-spec-enters-final-review-process.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +NVMe over Fabrics enterprise storage spec enters final review process +====== +The NVMe over Fabric (NVMe-oF) architecture is closer to becoming a formal specification. It's expected improve storage network fabric communications and network performance. +![Gremlin / Getty Images][1] + +NVM Express Inc., the developer of the [NVMe][2] spec for enterprise SSDs, announced that its NVMe-oF architecture has entered a final 45-day review, an important step toward release of a formal specification for enterprise SSD makers. + +NVMe-oF stands for [NVMe over Fabrics][3], a mechanism to transfer data between a host computer and a target SSD or system over a network, such as Ethernet, Fibre Channel (FC), or InfiniBand. NVM Express first released the 1.0 spec of NVMe-oF in 2016, so this is long overdue. + +**[ Read also: [NVMe over Fabrics creates data-center storage disruption][3] ]** + +NVMe has become an important advance in enterprise storage because it allows for intra-network data sharing. Before, when PCI Express-based SSDs first started being used in servers, they could not easily share data with another physical server. The SSD was basically for the machine it was in, and moving data around was difficult. + +With NVMe over Fabrics, it’s possible for one machine to directly reach out to another for data and have it transmitted over a variety of high-speed fabrics rather than just Ethernet. + +### How NVMe-oF 1.1 improves storage network fabric communication + +The NVMe-oF 1.1 architecture is designed to improve storage network fabric communications in several ways: + + * Adds TCP transport supports NVMe-oF on current data center TCP/IP network infrastructure. + * Asynchronous discovery events inform hosts of addition or removal of target ports in a fabric-independent manner. + * Fabric I/O Queue Disconnect enables finer-grain I/O resource management. + * End-to-end (command to response) flow control improves concurrency. + + + +### New enterprise features for NVMe 1.4 + +The organization also announced the release of the NVMe 1.4 base specification with new “enterprise features” described as a further maturation of the protocol. The specification provides important benefits, such as improved quality of service (QoS), faster performance, improvements for high-availability deployments, and scalability optimizations for data centers. + +Among the new features: + + * Rebuild Assist simplifies data recovery and migration scenarios. + * Persistent Event Log enables robust drive history for issue triage and debug at scale. + * NVM Sets and IO Determinism allow for better performance, isolation, and QoS. + * Multipathing enhancements or Asymmetric Namespace Access (ANA) enable optimal and redundant paths to namespaces for high availability and full multi-controller scalability. + * Host Memory Buffer feature reduces latency and SSD design complexity, benefiting client SSDs. + + + +The upgraded NVMe 1.4 base specification and the pending over-fabric spec will be demonstrated at the Flash Memory Summit August 6-8, 2019 in Santa Clara, California. + +Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3411958/nvme-over-fabrics-enterprise-storage-spec-enters-final-review-process.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/big_data_storage_businessman_walks_through_futuristic_data_center_by_gremlin_gettyimages-1098116540_2400x1600-100788347-large.jpg +[2]: https://www.networkworld.com/article/3280991/what-is-nvme-and-how-is-it-changing-enterprise-storage.html +[3]: https://www.networkworld.com/article/3394296/nvme-over-fabrics-creates-data-center-storage-disruption.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20190729 Do you prefer a live demo to be perfect or broken.md b/sources/talk/20190729 Do you prefer a live demo to be perfect or broken.md new file mode 100644 index 0000000000..b4b76aadd6 --- /dev/null +++ b/sources/talk/20190729 Do you prefer a live demo to be perfect or broken.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Do you prefer a live demo to be perfect or broken?) +[#]: via: (https://opensource.com/article/19/7/live-demo-perfect-or-broken) +[#]: author: (Lauren Maffeo https://opensource.com/users/lmaffeohttps://opensource.com/users/don-watkinshttps://opensource.com/users/jamesf) + +Do you prefer a live demo to be perfect or broken? +====== +Do you learn more from flawless demos or ones the presenter de-bugs in +real-time? Let us know by answering our poll. +![video editing dashboard][1] + +At [DevFest DC][2] in June, [Sara Robinson][3], developer advocate at Google Cloud, gave the most seamless live demo I've ever witnessed. + +Sara live-coded a machine model from scratch using TensorFlow and Keras. Then she trained the model live, deployed it to Google's Cloud AI platform, and used the deployed model to make predictions. + +With the exception of perhaps one small hiccup, the whole thing went smoothly, and I learned a lot as an audience member. + +At that evening's reception, I congratulated Sara on the live demo's success and told her I've never seen a live demo go so well. It turns out that this subject was already on her mind; Sara asked this question on Twitter less than two hours before her live demo: + +> Do you prefer watching a live demo where everything works perfectly or one that breaks and the presenter has to de-bug? +> +> — Sara Robinson (@SRobTweets) [June 14, 2019][4] + +Contrary to my preference for flawless demos, two-thirds of Sara's followers prefer to watch de-bugging. The replies to her poll were equally enlightening: + +> I prefer ones that break once or twice, just so you know it's real. "Break" can be something small like a typo or skipping a step. +> +> — Seth Vargo (@sethvargo) [June 14, 2019][5] + +> Broken demos which are fixed in real time seem to get a better reaction from the audience. This was our experience with the All-Demo Super Session at NEXT SF. Audible gasps followed by applause from the audience when the broken demo was fixed in real-time 🤓 +> +> — Jamie Kinney (@jamiekinney) [June 14, 2019][6] + +This made me reconsider my preference for perfection. When I attend live demos at events, I'm looking for tools that I'm unfamiliar with. I want to learn the basics of those tools, then see real-world applications. I don't expect magic, but I do want to see how the tools intend to work so I can gain and retain some knowledge. + +I've gone to several live demos that break. In my experience, this has caught most presenters off-guard; they seemed unfamiliar with the bugs at hand and, in one case, the error derailed the rest of the presentation. In short, it was like this: + +> Hmm, at least when the live demo fails you know it's not a video 😁 +> But I don't like when the presenter start to struggle, when everything becomes silent, it becomes so awkward (especially when I'm the one presenting) +> +> — Sylvain Nouts Ⓥ (@SylvainNouts) [June 14, 2019][7] + +Reading the replies to Sara's thread made me wonder what I'm really after when attending live demos. Is "perfection" what I seek? Or is it presenters who are more skilled at de-bugging in real-time? Upon reflection, I suspect that it's the latter. + +After all, "perfect" code is a lofty (if impossible) concept. Mistakes will happen, and I don't expect them not to. But I _do_ expect conference presenters to know their tools well enough that when things go sideways during live demos, they won't get so flustered that they can't keep going. + +Overall, this reply to Sara resonates with me the most. I attend live demos as a new coder with the goal to learn, and those that veer too far off-course aren't as effective for me: + +> I don’t necessarily prefer a broken demo, but I do think they show a more realistic view. +> That said, when you are newer to coding if the error takes things too far off the rails it can make it challenging to understand the original concept. +> +> — April Bowler (@A_Bowler2) [June 14, 2019][8] + +I don't expect everyone to attend live demos with the same goals and perspective as me. That's why we want to learn what the open source community thinks. + +_Do you prefer for live demos to be perfect? Or do you gain more from watching presenters de-bug in real-time? Do you attend live demos primarily to learn or for other reasons? Let us know by taking our poll or leaving a comment below._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/live-demo-perfect-or-broken + +作者:[Lauren Maffeo][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lmaffeohttps://opensource.com/users/don-watkinshttps://opensource.com/users/jamesf +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/video_editing_folder_music_wave_play.png?itok=-J9rs-My (video editing dashboard) +[2]: https://www.devfestdc.org/ +[3]: https://twitter.com/SRobTweets +[4]: https://twitter.com/SRobTweets/status/1139619990687162368?ref_src=twsrc%5Etfw +[5]: https://twitter.com/sethvargo/status/1139620990546145281?ref_src=twsrc%5Etfw +[6]: https://twitter.com/jamiekinney/status/1139636109585989632?ref_src=twsrc%5Etfw +[7]: https://twitter.com/SylvainNouts/status/1139637154731237376?ref_src=twsrc%5Etfw +[8]: https://twitter.com/A_Bowler2/status/1139648492953976832?ref_src=twsrc%5Etfw diff --git a/sources/talk/20190729 I Used The Web For A Day On A 50 MB Budget - Smashing Magazine.md b/sources/talk/20190729 I Used The Web For A Day On A 50 MB Budget - Smashing Magazine.md new file mode 100644 index 0000000000..b0a7f4a7e0 --- /dev/null +++ b/sources/talk/20190729 I Used The Web For A Day On A 50 MB Budget - Smashing Magazine.md @@ -0,0 +1,538 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (I Used The Web For A Day On A 50 MB Budget — Smashing Magazine) +[#]: via: (https://www.smashingmagazine.com/2019/07/web-on-50mb-budget/) +[#]: author: (Chris Ashton https://www.smashingmagazine.com/author/chrisbashton) + +I Used The Web For A Day On A 50 MB Budget +====== + +Data can be prohibitively expensive, especially in developing countries. Chris Ashton puts himself in the shoes of someone on a tight data budget and offers practical tips for reducing our websites’ data footprint. + +This article is part of a series in which I attempt to use the web under various constraints, representing a given demographic of user. I hope to raise the profile of difficulties faced by real people, which are avoidable if we design and develop in a way that is sympathetic to their needs. + +Last time, I [navigated the web for a day using Internet Explorer 8][7]. This time, I browsed the web for a day on a 50 MB budget. + +### Why 50 MB? + +Many of us are lucky enough to be on mobile plans which allow several gigabytes of data transfer per month. Failing that, we are usually able to connect to home or public WiFi networks that are on fast broadband connections and have effectively unlimited data. + +But there are parts of the world where mobile data is prohibitively expensive, and where there is little or no broadband infrastructure. + +> People often buy data packages of just tens of megabytes at a time, making a gigabyte a relatively large and therefore expensive amount of data to buy. +> — Dan Howdle, consumer telecoms analyst at Cable.co.uk + +Just how expensive are we talking? + +#### The Cost Of Mobile Data + +A 2018 [study by cable.co.uk][8] found that Zimbabwe was the most expensive country in the world for mobile data, where 1 GB cost an average of $75.20, ranging from $12.50 to $138.46. The enormous range in price is due to smaller amounts of data being very expensive, getting proportionally cheaper the bigger the data plan you commit to. You can read the [study methodology][9] for more information. + +Zimbabwe is by no means a one-off. Equatorial Guinea, Saint Helena and the Falkland Islands are next in line, with 1 GB of data costing $65.83, $55.47 and $47.39 respectively. These countries generally have a combination of poor technical infrastructure and low adoption, meaning data is both costly to deliver and doesn’t have the economy of scale to drive costs down. + +Data is expensive in parts of Europe too. A gigabyte of data in Greece will set you back $32.71; in Switzerland, $20.22. For comparison, the same amount of data costs $6.66 in the UK, or $12.37 in the USA. On the other end of the scale, India is the cheapest place in the world for data, at an average cost of $0.26. Kyrgyzstan, Kazakhstan and Ukraine follow at $0.27, $0.49 and $0.51 per GB respectively. + +The speed of mobile networks, too, varies considerably between countries. Perhaps surprisingly, [users experience faster speeds over a mobile network than WiFi][10] in at least 30 countries worldwide, including Australia and France. South Korea has the [fastest mobile download speed][11], averaging 52.4 Mbps, but Iraq has the slowest, averaging 1.6 Mbps download and 0.7 Mbps upload. The USA ranks 40th in the world for mobile download speeds, at around 34 Mbps, and is [at risk of falling further behind][12] as the world moves towards 5G. + +As for mobile network connection type, 84.7% of user connections in the UK are on 4G, compared to 93% in the USA, and 97.5% in South Korea. This compares with less than 50% in Uzbekistan and less than 60% in Algeria, Ecuador, Nepal and Iraq. + +#### The Cost Of Broadband Data + +Meanwhile, a [study of the cost of broadband in 2018][13] shows that a broadband connection in Niger costs $263 ‘per megabit per month’. This metric is a little difficult to comprehend, so here’s an example: if the average cost of broadband packages in a country is $22, and the average download speed offered by the packages is 10 Mbps, then the cost ‘per megabit per month’ would be $2.20. + +It’s an interesting metric, and one that acknowledges that broadband speed is as important a factor as the data cap. A cost of $263 suggests a combination of extremely slow and extremely expensive broadband. For reference, the metric is $1.19 in the UK and $1.26 in the USA. + +What’s perhaps easier to comprehend is the average cost of a broadband package. Note that this study was looking for the cheapest broadband packages on offer, ignoring whether or not these packages had a data cap, so provides a useful ballpark figure rather than the cost of data per se. + +On package cost alone, Mauritania has the most expensive broadband in the world, at an average of $768.16 (a range of $307.26 to $1,368.72). This enormous cost includes building physical lines to the property, since few already exist in Mauritania. At 0.7 Mbps, Mauritania also has one of the slowest broadband networks in the world. + +[Taiwan has the fastest broadband in the world][14], at a mean speed of 85 Mbps. Yemen has the slowest, at 0.38 Mbps. But even countries with good established broadband infrastructure have so-called ‘not-spots’. The United Kingdom is ranked 34th out of 207 countries for broadband speed, but in July 2019 there was [still a school in the UK without broadband][15]. + +The average cost of a broadband package in the UK is $39.58, and in the USA is $67.69. The cheapest average in the world is Ukraine’s, at just $5, although the cheapest broadband deal of them all was found in Kyrgystan ($1.27 — against the country average of $108.22). + +Zimbabwe was the most costly country for mobile data, and the statistics aren’t much better for its broadband, with an average cost of $128.71 and a ‘per megabit per month’ cost of $6.89. + +#### Absolute Cost vs Cost In Real Terms + +All of the costs outlined so far are the absolute costs in USD, based on the exchange rates at the time of the study. These costs have [not been accounted for cost of living][16], meaning that for many countries the cost is actually far higher in real terms. + +I’m going to limit my browsing today to 50 MB, which in Zimbabwe would cost around $3.67 on a mobile data tariff. That may not sound like much, but teachers in Zimbabwe were striking this year because their [salaries had fallen to just $2.50 a day][17]. + +For comparison, $3.67 is around half the [$7.25 minimum wage in the USA][18]. As a Zimbabwean, I’d have to work for around a day and a half to earn the money to buy this 50MB data, compared to just half an hour in the USA. It’s not easy to compare cost of living between countries, but on wages alone the $3.67 cost of 50 MB of data in Zimbabwe would feel like $52 to an American on minimum wage. + +### Setting Up The Experiment + +I launched Chrome and opened the dev tools, where I throttled the network to a slow 3G connection. I wanted to simulate a slow connection like those experienced by users in Uzbekistan, to see what kind of experience websites would give me. I also throttled my CPU to simulate being on a lower end device. + +[![][19]][20]I opted to throttle my network to Slow 3G and my CPU to 6x slowdown. ([Large preview][20]) + +I installed [ModHeader][21] and set the [‘Save-Data’ header][22] to let websites know I want to minimise my data usage. This is also the header set by Chrome for Android’s ‘Lite mode’, which I’ll cover in more detail later. + +I downloaded [TripMode][23]; an application for Mac which gives you control over which apps on your Mac can access the internet. Any other application’s internet access is automatically blocked. + +You can enable/disable individual apps from connecting to the internet with TripMode. I enabled Chrome. ([Large preview][24]) + +How far do I predict my 50 MB budget will take me? With the [average weight of a web page being almost 1.7 MB][25], that suggests I’ve got around 29 pages in my budget, although probably a few more than that if I’m able to stay on the same sites and leverage browser caching. + +Throughout the experiment I will suggest performance tips to speed up the [first contentful paint][26] and perceived loading time of the page. Some of these tips may not affect the amount of data transferred directly, but do generally involve deferring the download of less important resources, which on slow connections may mean the resources are never downloaded and data is saved. + +### The Experiment + +Without any further ado, I loaded google.com, using 402 KB of my budget and spending $0.03 (around 1% of my Zimbabwe budget). + +[![402 KB transferred, 1.1 MB resources, 24 requests][27]][28]402 KB transferred, 1.1 MB resources, 24 requests. ([Large preview][28]) + +All in all, not a bad page size, but I wondered where those 24 network requests were coming from and whether or not the page could be made any lighter. + +#### Google Homepage — DOM + +[![][29]][30]Chrome devtools screenshot of the DOM, where I’ve expanded one inline `style` tag. ([Large preview][30]) + +Looking at the page markup, there are no external stylesheets — all of the CSS is inline. + +##### Performance Tip #1: Inline Critical CSS + +This is good for performance as it saves the browser having to make an additional network request in order to fetch an external stylesheet, so the styles can be parsed and applied immediately for the first contentful paint. There’s a trade-off to be made here, as external stylesheets can be cached but inline ones cannot (unless you [get clever with JavaScript][31]). + +The general advice is for your [critical styles][32] (anything [above-the-fold][33]) to be inline, and for the rest of your styling to be external and loaded asynchronously. Asynchronous loading of CSS can be achieved in [one remarkably clever line of HTML][34]: + +``` + +``` + +The devtools show a prettified version of the DOM. If you want to see what was actually downloaded to the browser, switch to the Sources tab and find the document. + +[![A wall of minified code.][35]][36]Switching to Sources and finding the index shows the ‘raw’ HTML that was delivered to the browser. What a mess! ([Large preview][36]) + +You can see there is a LOT of inline JavaScript here. It’s worth noting that it has been uglified rather than merely minified. + +##### Performance Tip #2: Minify And Uglify Your Assets + +Minification removes unnecessary spaces and characters, but uglification actually ‘mangles’ the code to be shorter. The tell-tale sign is that the code contains short, machine-generated variable names rather than untouched source code. This is good as it means the script is smaller and quicker to download. + +Even so, inline scripts look to be roughly 120 KB of the 210 KB page resource (about half the 60 KB gzipped size). In addition, there are five external JavaScript files amounting to 291 KB of the 402 KB downloaded: + +[![Network tab of DevTools showing the external javascript files][37]][38]Five external JavaScript files in the Network tab of the devtools. ([Large preview][38]) + +This means that JavaScript accounts for about 80 percent of the overall page weight. + +This isn’t useless JavaScript; Google has to have some in order to display suggestions as you type. But I suspect a lot of it is tracking code and advertising setup. + +For comparison, I disabled JavaScript and reloaded the page: + +[![DevTools showing only 5 network requests][39]][40]The disabled JS version of Google search was only 102 KB and had just 5 network requests. ([Large preview][40]) + +The JS-disabled version of Google search is just 102 KB, as opposed to 402 KB. Although Google can’t provide autosuggestions under these conditions, the site is still functional, and I’ve just cut my data usage down to a quarter of what it was. If I really did have to limit my data usage in the long term, one of the first things I’d do is disable JavaScript. [It’s not as bad as it sounds][41]. + +##### Performance Tip #3: Less Is More + +Inlining, uglifying and minifying assets is all well and good, but the best performance comes from not sending down the assets in the first place. + + * Before adding any new features, do you have a [performance budget][42] in place? + * Before adding JavaScript to your site, can your feature be accomplished using plain HTML? (For example, [HTML5 form validation][43]). + * Before pulling a large JavaScript or CSS library into your application, use something like [bundlephobia.com][44] to measure how big it is. Is the convenience worth the weight? Can you accomplish the same thing using vanilla code at a much smaller data size? + + + +#### Analysing The Resource Info + +There’s a lot to unpack here, so let’s get cracking. I’ve only got 50 MB to play with, so I’m going to milk every bit of this page load. Settle in for a short Chrome Devtools tutorial. + +402 KB transferred, but 1.1 MB of resources: what does that actually mean? + +It means 402 KB of content was actually downloaded, but in its compressed form (using a compression algorithm such as [gzip or brotli][45]). The browser then had to do some work to unpack it into something meaningful. The total size of the unpacked data is 1.1 MB. + +This unpacking isn’t free — [there are a few milliseconds of overhead in decompressing the resources][46]. But that’s a negligible overhead compared to sending 1.1MB down the wire. + +##### Performance Tip #4: Compress Text-based Assets + +As a general rule, always compress your assets, using something like gzip. But don’t use compression on your images and other binary files — you should optimize these in advance at source. Compression could actually end up [making them bigger][47]. + +And, if you can, [avoid compressing files that are 1500 bytes or smaller][47]. The smallest TCP packet size is 1500 bytes, so by compressing to, say, 800 bytes, you save nothing, as it’s still transmitted in the same byte packet. Again, the cost is negligible, but wastes some compression CPU time on the server and decompression CPU time on the client. + +Now back to the Network tab in Chrome: let’s dig into those priorities. Notice that resources have priority “Highest” to “Lowest” — these are the browser’s best guess as to what are the more important resources to download. The higher the priority, the sooner the browser will try to download the asset. + +##### Performance Tip #5: Give Resource Hints To The Browser + +The browser will guess at what the highest priority assets are, but you can [provide a resource hint][48] using the `` tag, instructing the browser to download the asset as soon as possible. It’s a good idea to preload fonts, logos and anything else that appears above the fold. + +Let’s talk about caching. I’m going to hold ALT and right-click to change my column headers to unlock some more juicy information. We’re going to check out Cache-Control. + +There are lots of interesting fields tucked away behind ALT. ([Large preview][49]) + +Cache-Control denotes whether or not a resource can be cached, how long it can be cached for, and what rules it should follow around [revalidating][50]. Setting proper cache values is crucial to keeping the data cost of repeat visits down. + +##### Performance Tip #6: Set cache-control Headers On All Cacheable Assets + +Note that the cache-control value begins with a directive of `public` or `private`, followed by an expiration value (e.g. `max-age=31536000`). What does the directive mean, and why the oddly specific `max-age` value? + +[![Screenshot of Google network tab with cache-control column visible][51]][52]A mixture of max-age values and public/private. ([Large preview][52]) + +The value `31536000` is the number of seconds there are in a year, and is the theoretical maximum value allowed by the cache-control specification. It is common to see this value applied to all static assets and effectively means “this resource isn’t going to change”. In practice, [no browser is going to cache for an entire year][53], but it will cache the asset for as long as makes sense. + +To explain the public/private directive, we must explain the two main caches that exist off the server. First, there is the traditional browser cache, where the resource is stored on the user’s machine (the ‘client’). And then there is the CDN cache, which sits between the client and the server; resources are cached at the CDN level to prevent the CDN from requesting the resource from the origin server over and over again. + +A `Cache-Control` directive of `public` allows the resource to be cached in both the client and the CDN. A value of `private` means only the client can cache it; the CDN is not supposed to. This latter value is typically used for pages or assets that exist behind authentication, where it is fine to be cached on the client but we wouldn’t want to leak private information by caching it in the CDN and delivering it to other users. + +[![Screenshot of Google logo cache-control setting: private, max-age=31536000][54]][55]A mixture of max-age values and public/private. ([Large preview][55]) + +One thing that got my attention was that the Google logo has a cache control of “private”. Other images on the page do have a public cache, and I don’t know why the logo would be treated any differently. If you have any ideas, let me know in the comments! + +I refreshed the page and most of the resources were served from cache, apart from the page itself, which as you’ve seen already is `private, max-age=0`, meaning it cannot be cached. This is normal for dynamic web pages where it is important that the user always gets the very latest page when they refresh. + +It was at this point I accidentally clicked on an ‘Explanation’ URL in the devtools, which took me to the [network analysis reference][56], costing me about 5 MB of my budget. Oops. + +### Google Dev Docs + +4.2 MB of this new 5 MB page was down to images; specifically SVGs. The weightiest of these was 186 KB, which isn’t particularly big — there were just so many of them, and they all downloaded at once. + +This is a loooong page. All the images downloaded on page load. ([Large preview][57]) + +That 5 MB page load was 10% of my budget for today. So far I’ve used 5.5 MB, including the no-JavaScript reload of the Google homepage, and spent $0.40. I didn’t even mean to open this page. + +What would have been a better user experience here? + +##### Performance Tip #7: Lazy-load Your Images + +Ordinarily, if I accidentally clicked on a link, I would hit the back button in my browser. I’d have received no benefit whatsoever from downloading those images — what a waste of 4.2 MB! + +Apart from video, where you generally know what you’re getting yourself into, images are by far the biggest culprit to data usage on the web. A [study of the world’s top 500 websites][58] found that images take up to 53% of the average page weight. “This means they have a big impact on page-loading times and subsequently overall performance”. + +Instead of downloading all of the images on page load, it is good practice to lazy-load the images so that only users who are engaged with the page pay the cost of downloading them. Users who choose not to scroll below the fold therefore don’t waste any unnecessary bandwidth downloading images they’ll never see. + +There’s a great [css-tricks.com guide to rolling out lazy-loading for images][59] which offers a good balance between those on good connections, those on poor connections, and those with JavaScript disabled. + +If this page had implemented lazy loading as per the guide above, each of the 38 SVGs would have been represented by a 1 KB placeholder image by default, and only loaded into view on scroll. + +##### Performance Tip #8: Use The Right Format For Your Images + +I thought that Google had missed a trick by not using [WebP][60], which is an image format that is 26% smaller in size compared to PNGs (with no loss in quality) and 25-34% smaller in size compared to JPEGs (and of a comparable quality). I thought I’d have a go at converting SVG to WebP. + +Converting to WebP did bring one of the SVGs down from 186 KB to just 65 KB, but actually, looking at the images side by side, the WebP came out grainy: + +[![Comparison of the two images][61]][62]The SVG (left) is noticeably crisper than the WebP (right). ([Large preview][62]) + +I then tried converting one of the PNGs to WebP, which is supposed to be lossless and should come out smaller. However, the WebP output was *heavier* (127 KB, from 109 KB)! + +[![Comparison of the two images][63]][64]The PNG (left) is a similar quality to the WebP (right) but is smaller at 109 KB compared to 127 KB. ([Large preview][64]) + +This surprised me. WebP isn’t necessarily the silver bullet we think it is, and even Google have neglected to use it on this page. + +So my advice would be: where possible, experiment with different image formats on a per-image basis. The format that keeps the best quality for the smallest size may not be the one you expect. + +Now back to the DOM. I came across this: + +Notice the `async` keyword on the Google analytics script? + +[![Screenshot of performance analysis output of devtools][65]][66]Google analytics has ‘low’ priority. ([Large preview][66]) + +Despite being one of the first things in the head of the document, this was given a low priority, as we’ve explicitly opted out of being a blocking request by using the `async` keyword. + +A blocking request is one that stops the rendering of the page. A ` + + + +``` + +This HTML file must be server for every URL and JavaScript will take care of rendering the correct page. + +So lets go the the `main.go` for a moment and in the `main()` function add the following route: + +``` +router.Handle("GET", "/...", http.FileServer(SPAFileSystem{http.Dir("static")})) + +type SPAFileSystem struct { + fs http.FileSystem +} + +func (spa SPAFileSystem) Open(name string) (http.File, error) { + f, err := spa.fs.Open(name) + if err != nil { + return spa.fs.Open("index.html") + } + return f, nil +} +``` + +We use a custom file system so instead of returning `404 Not Found` for unknown URLs, it serves the `index.html`. + +### Router + +In the `index.html` we loaded two files: `styles.css` and `main.js`. I leave styling to your taste. + +Lets move to `main.js`. Create a `static/main.js` file with the following content: + +``` +import { guard } from './auth.js' +import Router from './router.js' + +let currentPage +const disconnect = new CustomEvent('disconnect') +const router = new Router() + +router.handle('/', guard(view('home'), view('access'))) +router.handle('/callback', view('callback')) +router.handle(/^\/conversations\/([^\/]+)$/, guard(view('conversation'), view('access'))) +router.handle(/^\//, view('not-found')) + +router.install(async result => { + document.body.innerHTML = '' + if (currentPage instanceof Node) { + currentPage.dispatchEvent(disconnect) + } + currentPage = await result + if (currentPage instanceof Node) { + document.body.appendChild(currentPage) + } +}) + +function view(pageName) { + return (...args) => import(`/pages/${pageName}-page.js`) + .then(m => m.default(...args)) +} +``` + +If you are follower of this blog, you already know how this works. That router is the one showed [here][7]. Just download it from [@nicolasparada/router][8] and save it to `static/router.js`. + +We registered four routes. At the root `/` we show the home or access page whether the user is authenticated. At `/callback` we show the callback page. On `/conversations/{conversationID}` we show the conversation or access page whether the user is authenticated and for every other URL, we show a not found page. + +We tell the router to render the result to the document body and dispatch a `disconnect` event to each page before leaving. + +We have each page in a different file and we import them with the new dynamic `import()`. + +### Auth + +`guard()` is a function that given two functions, executes the first one if the user is authenticated, or the sencond one if not. It comes from `auth.js` so lets create a `static/auth.js` file with the following content: + +``` +export function isAuthenticated() { + const token = localStorage.getItem('token') + const expiresAtItem = localStorage.getItem('expires_at') + if (token === null || expiresAtItem === null) { + return false + } + + const expiresAt = new Date(expiresAtItem) + if (isNaN(expiresAt.valueOf()) || expiresAt <= new Date()) { + return false + } + + return true +} + +export function guard(fn1, fn2) { + return (...args) => isAuthenticated() + ? fn1(...args) + : fn2(...args) +} + +export function getAuthUser() { + if (!isAuthenticated()) { + return null + } + + const authUser = localStorage.getItem('auth_user') + if (authUser === null) { + return null + } + + try { + return JSON.parse(authUser) + } catch (_) { + return null + } +} +``` + +`isAuthenticated()` checks for `token` and `expires_at` from localStorage to tell if the user is authenticated. `getAuthUser()` gets the authenticated user from localStorage. + +When we login, we’ll save all the data to localStorage so it will make sense. + +### Access Page + +![access page screenshot][9] + +Lets start with the access page. Create a file `static/pages/access-page.js` with the following content: + +``` +const template = document.createElement('template') +template.innerHTML = ` +

Messenger

+ Access with GitHub +` + +export default function accessPage() { + return template.content +} +``` + +Because the router intercepts all the link clicks to do its navigation, we must prevent the event propagation for this link in particular. + +Clicking on that link will redirect us to the backend, then to GitHub, then to the backend and then to the frontend again; to the callback page. + +### Callback Page + +Create the file `static/pages/callback-page.js` with the following content: + +``` +import http from '../http.js' +import { navigate } from '../router.js' + +export default async function callbackPage() { + const url = new URL(location.toString()) + const token = url.searchParams.get('token') + const expiresAt = url.searchParams.get('expires_at') + + try { + if (token === null || expiresAt === null) { + throw new Error('Invalid URL') + } + + const authUser = await getAuthUser(token) + + localStorage.setItem('auth_user', JSON.stringify(authUser)) + localStorage.setItem('token', token) + localStorage.setItem('expires_at', expiresAt) + } catch (err) { + alert(err.message) + } finally { + navigate('/', true) + } +} + +function getAuthUser(token) { + return http.get('/api/auth_user', { authorization: `Bearer ${token}` }) +} +``` + +The callback page doesn’t render anything. It’s an async function that does a GET request to `/api/auth_user` using the token from the URL query string and saves all the data to localStorage. Then it redirects to `/`. + +### HTTP + +There is an HTTP module. Create a `static/http.js` file with the following content: + +``` +import { isAuthenticated } from './auth.js' + +async function handleResponse(res) { + const body = await res.clone().json().catch(() => res.text()) + + if (res.status === 401) { + localStorage.removeItem('auth_user') + localStorage.removeItem('token') + localStorage.removeItem('expires_at') + } + + if (!res.ok) { + const message = typeof body === 'object' && body !== null && 'message' in body + ? body.message + : typeof body === 'string' && body !== '' + ? body + : res.statusText + throw Object.assign(new Error(message), { + url: res.url, + statusCode: res.status, + statusText: res.statusText, + headers: res.headers, + body, + }) + } + + return body +} + +function getAuthHeader() { + return isAuthenticated() + ? { authorization: `Bearer ${localStorage.getItem('token')}` } + : {} +} + +export default { + get(url, headers) { + return fetch(url, { + headers: Object.assign(getAuthHeader(), headers), + }).then(handleResponse) + }, + + post(url, body, headers) { + const init = { + method: 'POST', + headers: getAuthHeader(), + } + if (typeof body === 'object' && body !== null) { + init.body = JSON.stringify(body) + init.headers['content-type'] = 'application/json; charset=utf-8' + } + Object.assign(init.headers, headers) + return fetch(url, init).then(handleResponse) + }, + + subscribe(url, callback) { + const urlWithToken = new URL(url, location.origin) + if (isAuthenticated()) { + urlWithToken.searchParams.set('token', localStorage.getItem('token')) + } + const eventSource = new EventSource(urlWithToken.toString()) + eventSource.onmessage = ev => { + let data + try { + data = JSON.parse(ev.data) + } catch (err) { + console.error('could not parse message data as JSON:', err) + return + } + callback(data) + } + const unsubscribe = () => { + eventSource.close() + } + return unsubscribe + }, +} +``` + +This module is a wrapper around the [fetch][10] and [EventSource][11] APIs. The most important part is that it adds the JSON web token to the requests. + +### Home Page + +![home page screenshot][12] + +So, when the user login, the home page will be shown. Create a `static/pages/home-page.js` file with the following content: + +``` +import { getAuthUser } from '../auth.js' +import { avatar } from '../shared.js' + +export default function homePage() { + const authUser = getAuthUser() + const template = document.createElement('template') + template.innerHTML = ` +
+
+ ${avatar(authUser)} + ${authUser.username} +
+ +
+ + + ` + const page = template.content + page.getElementById('logout-button').onclick = onLogoutClick + return page +} + +function onLogoutClick() { + localStorage.clear() + location.reload() +} +``` + +For this post, this is the only content we render on the home page. We show the current authenticated user and a logout button. + +When the user clicks to logout, we clear all inside localStorage and do a reload of the page. + +### Avatar + +That `avatar()` function is to show the user’s avatar. Because it’s used in more than one place, I moved it to a `shared.js` file. Create the file `static/shared.js` with the following content: + +``` +export function avatar(user) { + return user.avatarUrl === null + ? `
` + : `${user.username}'s avatar` +} +``` + +We use a small figure with the user’s initial in case the avatar URL is null. + +You can show the initial with a little of CSS using the `attr()` function. + +``` +.avatar[data-initial]::after { + content: attr(data-initial); +} +``` + +### Development Login + +![access page with login form screenshot][13] + +In the previous post we coded a login for development. Lets add a form for that in the access page. Go to `static/pages/access-page.js` and modify it a little. + +``` +import http from '../http.js' + +const template = document.createElement('template') +template.innerHTML = ` +

Messenger

+
+ + +
+ Access with GitHub +` + +export default function accessPage() { + const page = template.content.cloneNode(true) + page.getElementById('login-form').onsubmit = onLoginSubmit + return page +} + +async function onLoginSubmit(ev) { + ev.preventDefault() + + const form = ev.currentTarget + const input = form.querySelector('input') + const submitButton = form.querySelector('button') + + input.disabled = true + submitButton.disabled = true + + try { + const payload = await login(input.value) + input.value = '' + + localStorage.setItem('auth_user', JSON.stringify(payload.authUser)) + localStorage.setItem('token', payload.token) + localStorage.setItem('expires_at', payload.expiresAt) + + location.reload() + } catch (err) { + alert(err.message) + setTimeout(() => { + input.focus() + }, 0) + } finally { + input.disabled = false + submitButton.disabled = false + } +} + +function login(username) { + return http.post('/api/login', { username }) +} +``` + +I added a login form. When the user submits the form. It does a POST requets to `/api/login` with the username. Saves all the data to localStorage and reloads the page. + +Remember to remove this form once you are done with the frontend. + +* * * + +That’s all for this post. In the next one, we’ll continue with the home page to add a form to start conversations and display a list with the latest ones. + +[Souce Code][14] + +-------------------------------------------------------------------------------- + +via: https://nicolasparada.netlify.com/posts/go-messenger-access-page/ + +作者:[Nicolás Parada][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://nicolasparada.netlify.com/ +[b]: https://github.com/lujun9972 +[1]: https://nicolasparada.netlify.com/posts/go-messenger-schema/ +[2]: https://nicolasparada.netlify.com/posts/go-messenger-oauth/ +[3]: https://nicolasparada.netlify.com/posts/go-messenger-conversations/ +[4]: https://nicolasparada.netlify.com/posts/go-messenger-messages/ +[5]: https://nicolasparada.netlify.com/posts/go-messenger-realtime-messages/ +[6]: https://nicolasparada.netlify.com/posts/go-messenger-dev-login/ +[7]: https://nicolasparada.netlify.com/posts/js-router/ +[8]: https://unpkg.com/@nicolasparada/router +[9]: https://nicolasparada.netlify.com/img/go-messenger-access-page/access-page.png +[10]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API +[11]: https://developer.mozilla.org/en-US/docs/Web/API/EventSource +[12]: https://nicolasparada.netlify.com/img/go-messenger-access-page/home-page.png +[13]: https://nicolasparada.netlify.com/img/go-messenger-access-page/access-page-v2.png +[14]: https://github.com/nicolasparada/go-messenger-demo diff --git a/sources/tech/20180719 Building a Messenger App- Home Page.md b/sources/tech/20180719 Building a Messenger App- Home Page.md new file mode 100644 index 0000000000..ddec2c180f --- /dev/null +++ b/sources/tech/20180719 Building a Messenger App- Home Page.md @@ -0,0 +1,255 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Building a Messenger App: Home Page) +[#]: via: (https://nicolasparada.netlify.com/posts/go-messenger-home-page/) +[#]: author: (Nicolás Parada https://nicolasparada.netlify.com/) + +Building a Messenger App: Home Page +====== + +This post is the 8th on a series: + + * [Part 1: Schema][1] + * [Part 2: OAuth][2] + * [Part 3: Conversations][3] + * [Part 4: Messages][4] + * [Part 5: Realtime Messages][5] + * [Part 6: Development Login][6] + * [Part 7: Access Page][7] + + + +Continuing the frontend, let’s finish the home page in this post. We’ll add a form to start conversations and a list with the latest ones. + +### Conversation Form + +![conversation form screenshot][8] + +In the `static/pages/home-page.js` file add some markup in the HTML view. + +``` +
+ +
+``` + +Add that form just below the section in which we displayed the auth user and logout button. + +``` +page.getElementById('conversation-form').onsubmit = onConversationSubmit +``` + +Now we can listen to the “submit” event to create the conversation. + +``` +import http from '../http.js' +import { navigate } from '../router.js' + +async function onConversationSubmit(ev) { + ev.preventDefault() + + const form = ev.currentTarget + const input = form.querySelector('input') + + input.disabled = true + + try { + const conversation = await createConversation(input.value) + input.value = '' + navigate('/conversations/' + conversation.id) + } catch (err) { + if (err.statusCode === 422) { + input.setCustomValidity(err.body.errors.username) + } else { + alert(err.message) + } + setTimeout(() => { + input.focus() + }, 0) + } finally { + input.disabled = false + } +} + +function createConversation(username) { + return http.post('/api/conversations', { username }) +} +``` + +On submit we do a POST request to `/api/conversations` with the username and redirect to the conversation page (for the next post). + +### Conversation List + +![conversation list screenshot][9] + +In the same file, we are going to make the `homePage()` function async to load the conversations first. + +``` +export default async function homePage() { + const conversations = await getConversations().catch(err => { + console.error(err) + return [] + }) + /*...*/ +} + +function getConversations() { + return http.get('/api/conversations') +} +``` + +Then, add a list in the markup to render conversations there. + +``` +
    +``` + +Add it just below the current markup. + +``` +const conversationsOList = page.getElementById('conversations') +for (const conversation of conversations) { + conversationsOList.appendChild(renderConversation(conversation)) +} +``` + +So we can append each conversation to the list. + +``` +import { avatar, escapeHTML } from '../shared.js' + +function renderConversation(conversation) { + const messageContent = escapeHTML(conversation.lastMessage.content) + const messageDate = new Date(conversation.lastMessage.createdAt).toLocaleString() + + const li = document.createElement('li') + li.dataset['id'] = conversation.id + if (conversation.hasUnreadMessages) { + li.classList.add('has-unread-messages') + } + li.innerHTML = ` + +
    + ${avatar(conversation.otherParticipant)} + ${conversation.otherParticipant.username} +
    +
    +

    ${messageContent}

    + +
    +
    + ` + return li +} +``` + +Each conversation item contains a link to the conversation page and displays the other participant info and a preview of the last message. Also, you can use `.hasUnreadMessages` to add a class to the item and do some styling with CSS. Maybe a bolder font or accent the color. + +Note that we’re escaping the message content. That function comes from `static/shared.js`: + +``` +export function escapeHTML(str) { + return str + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') +} +``` + +That prevents displaying as HTML the message the user wrote. If the user happens to write something like: + +``` + +``` + +It would be very annoying because that script will be executed 😅 +So yeah, always remember to escape content from untrusted sources. + +### Messages Subscription + +Last but not least, I want to subscribe to the message stream here. + +``` +const unsubscribe = subscribeToMessages(onMessageArrive) +page.addEventListener('disconnect', unsubscribe) +``` + +Add that line in the `homePage()` function. + +``` +function subscribeToMessages(cb) { + return http.subscribe('/api/messages', cb) +} +``` + +The `subscribe()` function returns a function that once called it closes the underlying connection. That’s why I passed it to the “disconnect” event; so when the user leaves the page, the event stream will be closed. + +``` +async function onMessageArrive(message) { + const conversationLI = document.querySelector(`li[data-id="${message.conversationID}"]`) + if (conversationLI !== null) { + conversationLI.classList.add('has-unread-messages') + conversationLI.querySelector('a > div > p').textContent = message.content + conversationLI.querySelector('a > div > time').textContent = new Date(message.createdAt).toLocaleString() + return + } + + let conversation + try { + conversation = await getConversation(message.conversationID) + conversation.lastMessage = message + } catch (err) { + console.error(err) + return + } + + const conversationsOList = document.getElementById('conversations') + if (conversationsOList === null) { + return + } + + conversationsOList.insertAdjacentElement('afterbegin', renderConversation(conversation)) +} + +function getConversation(id) { + return http.get('/api/conversations/' + id) +} +``` + +Every time a new message arrives, we go and query for the conversation item in the DOM. If found, we add the `has-unread-messages` class to the item, and update the view. If not found, it means the message is from a new conversation created just now. We go and do a GET request to `/api/conversations/{conversationID}` to get the conversation in which the message was created and prepend it to the conversation list. + +* * * + +That covers the home page 😊 +On the next post we’ll code the conversation page. + +[Souce Code][10] + +-------------------------------------------------------------------------------- + +via: https://nicolasparada.netlify.com/posts/go-messenger-home-page/ + +作者:[Nicolás Parada][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://nicolasparada.netlify.com/ +[b]: https://github.com/lujun9972 +[1]: https://nicolasparada.netlify.com/posts/go-messenger-schema/ +[2]: https://nicolasparada.netlify.com/posts/go-messenger-oauth/ +[3]: https://nicolasparada.netlify.com/posts/go-messenger-conversations/ +[4]: https://nicolasparada.netlify.com/posts/go-messenger-messages/ +[5]: https://nicolasparada.netlify.com/posts/go-messenger-realtime-messages/ +[6]: https://nicolasparada.netlify.com/posts/go-messenger-dev-login/ +[7]: https://nicolasparada.netlify.com/posts/go-messenger-access-page/ +[8]: https://nicolasparada.netlify.com/img/go-messenger-home-page/conversation-form.png +[9]: https://nicolasparada.netlify.com/img/go-messenger-home-page/conversation-list.png +[10]: https://github.com/nicolasparada/go-messenger-demo diff --git a/sources/tech/20180720 Building a Messenger App- Conversation Page.md b/sources/tech/20180720 Building a Messenger App- Conversation Page.md new file mode 100644 index 0000000000..c721b48161 --- /dev/null +++ b/sources/tech/20180720 Building a Messenger App- Conversation Page.md @@ -0,0 +1,269 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Building a Messenger App: Conversation Page) +[#]: via: (https://nicolasparada.netlify.com/posts/go-messenger-conversation-page/) +[#]: author: (Nicolás Parada https://nicolasparada.netlify.com/) + +Building a Messenger App: Conversation Page +====== + +This post is the 9th and last in a series: + + * [Part 1: Schema][1] + * [Part 2: OAuth][2] + * [Part 3: Conversations][3] + * [Part 4: Messages][4] + * [Part 5: Realtime Messages][5] + * [Part 6: Development Login][6] + * [Part 7: Access Page][7] + * [Part 8: Home Page][8] + + + +In this post we’ll code the conversation page. This page is the chat between the two users. At the top we’ll show info about the other participant, below, a list of the latest messages and a message form at the bottom. + +### Chat heading + +![chat heading screenshot][9] + +Let’s start by creating the file `static/pages/conversation-page.js` with the following content: + +``` +import http from '../http.js' +import { navigate } from '../router.js' +import { avatar, escapeHTML } from '../shared.js' + +export default async function conversationPage(conversationID) { + let conversation + try { + conversation = await getConversation(conversationID) + } catch (err) { + alert(err.message) + navigate('/', true) + return + } + + const template = document.createElement('template') + template.innerHTML = ` +
    + ← Back + ${avatar(conversation.otherParticipant)} + ${conversation.otherParticipant.username} +
    + + + ` + const page = template.content + return page +} + +function getConversation(id) { + return http.get('/api/conversations/' + id) +} +``` + +This page receives the conversation ID the router extracted from the URL. + +First it does a GET request to `/api/conversations/{conversationID}` to get info about the conversation. In case of error, we show it and redirect back to `/`. Then we render info about the other participant. + +### Conversation List + +![chat heading screenshot][10] + +We’ll fetch the latest messages too to display them. + +``` +let conversation, messages +try { + [conversation, messages] = await Promise.all([ + getConversation(conversationID), + getMessages(conversationID), + ]) +} +``` + +Update the `conversationPage()` function to fetch the messages too. We use `Promise.all()` to do both request at the same time. + +``` +function getMessages(conversationID) { + return http.get(`/api/conversations/${conversationID}/messages`) +} +``` + +A GET request to `/api/conversations/{conversationID}/messages` gets the latest messages of the conversation. + +``` +
      +``` + +Now, add that list to the markup. + +``` +const messagesOList = page.getElementById('messages') +for (const message of messages.reverse()) { + messagesOList.appendChild(renderMessage(message)) +} +``` + +So we can append messages to the list. We show them in reverse order. + +``` +function renderMessage(message) { + const messageContent = escapeHTML(message.content) + const messageDate = new Date(message.createdAt).toLocaleString() + + const li = document.createElement('li') + if (message.mine) { + li.classList.add('owned') + } + li.innerHTML = ` +

      ${messageContent}

      + + ` + return li +} +``` + +Each message item displays the message content itself with its timestamp. Using `.mine` we can append a different class to the item so maybe you can show the message to the right. + +### Message Form + +![chat heading screenshot][11] + +``` +
      + + +
      +``` + +Add that form to the current markup. + +``` +page.getElementById('message-form').onsubmit = messageSubmitter(conversationID) +``` + +Attach an event listener to the “submit” event. + +``` +function messageSubmitter(conversationID) { + return async ev => { + ev.preventDefault() + + const form = ev.currentTarget + const input = form.querySelector('input') + const submitButton = form.querySelector('button') + + input.disabled = true + submitButton.disabled = true + + try { + const message = await createMessage(input.value, conversationID) + input.value = '' + const messagesOList = document.getElementById('messages') + if (messagesOList === null) { + return + } + + messagesOList.appendChild(renderMessage(message)) + } catch (err) { + if (err.statusCode === 422) { + input.setCustomValidity(err.body.errors.content) + } else { + alert(err.message) + } + } finally { + input.disabled = false + submitButton.disabled = false + + setTimeout(() => { + input.focus() + }, 0) + } + } +} + +function createMessage(content, conversationID) { + return http.post(`/api/conversations/${conversationID}/messages`, { content }) +} +``` + +We make use of [partial application][12] to have the conversation ID in the “submit” event handler. It takes the message content from the input and does a POST request to `/api/conversations/{conversationID}/messages` with it. Then prepends the newly created message to the list. + +### Messages Subscription + +To make it realtime we’ll subscribe to the message stream in this page also. + +``` +page.addEventListener('disconnect', subscribeToMessages(messageArriver(conversationID))) +``` + +Add that line in the `conversationPage()` function. + +``` +function subscribeToMessages(cb) { + return http.subscribe('/api/messages', cb) +} + +function messageArriver(conversationID) { + return message => { + if (message.conversationID !== conversationID) { + return + } + + const messagesOList = document.getElementById('messages') + if (messagesOList === null) { + return + + } + messagesOList.appendChild(renderMessage(message)) + readMessages(message.conversationID) + } +} + +function readMessages(conversationID) { + return http.post(`/api/conversations/${conversationID}/read_messages`) +} +``` + +We also make use of partial application to have the conversation ID here. +When a new message arrives, first we check if it’s from this conversation. If it is, we go a prepend a message item to the list and do a POST request to `/api/conversations/{conversationID}/read_messages` to updated the last time the participant read messages. + +* * * + +That concludes this series. The messenger app is now functional. + +~~I’ll add pagination on the conversation and message list, also user searching before sharing the source code. I’ll updated once it’s ready along with a hosted demo 👨‍💻~~ + +[Souce Code][13] • [Demo][14] + +-------------------------------------------------------------------------------- + +via: https://nicolasparada.netlify.com/posts/go-messenger-conversation-page/ + +作者:[Nicolás Parada][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://nicolasparada.netlify.com/ +[b]: https://github.com/lujun9972 +[1]: https://nicolasparada.netlify.com/posts/go-messenger-schema/ +[2]: https://nicolasparada.netlify.com/posts/go-messenger-oauth/ +[3]: https://nicolasparada.netlify.com/posts/go-messenger-conversations/ +[4]: https://nicolasparada.netlify.com/posts/go-messenger-messages/ +[5]: https://nicolasparada.netlify.com/posts/go-messenger-realtime-messages/ +[6]: https://nicolasparada.netlify.com/posts/go-messenger-dev-login/ +[7]: https://nicolasparada.netlify.com/posts/go-messenger-access-page/ +[8]: https://nicolasparada.netlify.com/posts/go-messenger-home-page/ +[9]: https://nicolasparada.netlify.com/img/go-messenger-conversation-page/heading.png +[10]: https://nicolasparada.netlify.com/img/go-messenger-conversation-page/list.png +[11]: https://nicolasparada.netlify.com/img/go-messenger-conversation-page/form.png +[12]: https://en.wikipedia.org/wiki/Partial_application +[13]: https://github.com/nicolasparada/go-messenger-demo +[14]: https://go-messenger-demo.herokuapp.com/ diff --git a/sources/tech/20180725 Best Online Linux Terminals and Online Bash Editors.md b/sources/tech/20180725 Best Online Linux Terminals and Online Bash Editors.md deleted file mode 100644 index 7f430c3d59..0000000000 --- a/sources/tech/20180725 Best Online Linux Terminals and Online Bash Editors.md +++ /dev/null @@ -1,212 +0,0 @@ -Best Online Linux Terminals and Online Bash Editors -====== -No matter whether you want to practice Linux commands or just analyze/test your shell scripts online, there’s always a couple of online Linux terminals and online bash compilers available. - -This is particularly helpful when you are using the Windows operating system. Though you can [install Linux inside Windows using Windows Subsystem for Linux][1], using online Linux terminals are often more convenient for a quick test. - -![Websites that allow to use Linux Terminal online][2] - -But where can you find free Linux console? Which online Linux shell should you use? - -Fret not, to save you the hassle, here, we have compiled a list of the best online Linux terminals and a separate list of best online bash compilers for you to look at. - -**Note:** All of the online terminals support several browsers that include Google Chrome, Mozilla Firefox, Opera and Microsoft Edge. - -### Best Online Linux Terminals To Practice Linux Commands - -In the first part, I’ll list the online Linux terminals. These websites allow you to run the regular Linux commands in a web browser so that you can practice or test them. Some websites may require you to register and login to save your sessions. - -#### 1. JSLinux - -![online linux terminal - jslinux][3] - -JSLinux is more like a complete Linux emulator instead of just offering you the terminal. As the name suggests, it has been entirely written in JavaScript. You get to choose a console-based system or a GUI-based online Linux system. However, in this case, you would want to launch the console-based system to practice Linux commands. To be able to connect your account, you need to sign up first. - -JSLinux also lets you upload files to the virtual machine. At its core, it utilizes [Buildroot][4] (a tool that helps you to build a complete Linux system for an embedded system). - -[Try JSLinux Terminal][5] - -#### 2. Copy.sh - -![copysh online linux terminal][6] - -Copy.sh offers one of the best online Linux terminals which is fast and reliable to test and run Linux commands. - -Copy.sh is also on [GitHub][7] – and it is being actively maintained, which is a good thing. It also supports other Operating Systems, which includes: - - * Windows 98 - * KolibriOS - * FreeDOS - * Windows 1.01 - * Archlinux - - - -[Try Copy.sh Terminal][8] - -#### 3. Webminal - -![webminal online linux terminal][9] - -Webminal is an impressive online Linux terminal – and my personal favorite when it comes to a recommendation for beginners to practice Linux commands online. - -The website offers several lessons to learn from while you type in the commands in the same window. So, you do not need to refer to another site for the lessons and then switch back or split the screen in order to practice commands. It’s all right there – in a single tab on the browser. - -[Try Webminal Terminal][10] - -#### 4. Tutorialspoint Unix Terminal - -![tutorialspoint linux terminal][11] - -You might be aware of Tutorialspoint – which happens to be one of the most popular websites with high quality (yet free) online tutorials for just about any programming language (and more). - -So, for obvious reasons, they provide a free online Linux console for you to practice commands while referring to their site as a resource at the same time. You also get the ability to upload files. It is quite simple but an effective online terminal. Also, it doesn’t stop there, it offers a lot of different online terminals as well in its [Coding Ground][12] page. - -[Try Unix Terminal Online][13] - -#### 5. JS/UIX - -![js uix online linux terminal][14] - -JS/UIX is yet another online Linux terminal which is written entirely in JavaScript without any plug-ins. It contains an online Linux virtual machine, virtual file-system, shell, and so on. - -You can go through its manual page for the list of commands implemented. - -[Try JS/UX Terminal][15] - -#### 6. CB.VU - -![online linux terminal][16] - -If you are in for a treat with FreeBSD 7.1 stable version, cb.vu is a quite simple solution for that. - -Nothing fancy, just try out the Linux commands you want and get the output. Unfortunately, you do not get the ability to upload files here. - -[Try CB.VU Terminal][17] - -#### 7. Linux Containers - -![online linux terminal][18] - -Linux Containers lets you run a demo server with a 30-minute countdown on which acts as one of the best online Linux terminals. In fact, it’s a project sponsored by Canonical. - -[Try Linux LXD][19] - -#### 8. Codeanywhere - -![online linux terminal][20] - -Codeanywhere is a service which offers cross-platform cloud IDEs. However, in order to run a free Linux virtual machine, you just need to sign up and choose the free plan. And, then, proceed to create a new connection while setting up a container with an OS of your choice. Finally, you will have a free Linux console at your disposal. - -[Try Codeanywhere Editor][21] - -### Best Online Bash Editors - -Wait a sec! Are the online Linux terminals not good enough for Bash scripting? They are. But creating bash scripts in terminal editors and then executing them is not as convinient as using an online Bash editor. - -These bash editors allow you to easily write shell scripts online and you can run them to check if it works or not. - -Let’s see here can you run shell scripts online. - -#### Tutorialspoint Bash Compiler - -![online bash compiler][22] - -As mentioned above, Tutorialspoint also offers an online Bash compiler. It is a very simple bash compiler to execute bash shell online. - -[Try Tutorialspoint Bash Compiler][23] - -#### JDOODLE - -![online bash compiler][24] - -Yet another useful online bash editor to test Bash scripts is JDOODLE. It also offers other IDEs, but we’ll focus on bash script execution here. You get to set the command line arguments and the stdin inputs, and would normally get the result of your code. - -[Try JDOODLE Bash Script Online Tester][25] - -#### Paizo.io - -![paizo online bash editor][26] - -Paizo.io is a good bash online editor that you can try for free. To utilize some of its advanced features like task scheduling, you need to first sign up. It also supports real-time collaboration, but that’s still in the experimental phase. - -[Try Paizo.io Bash Editor][27] - -#### ShellCheck - -![shell check bash check][28] - -An interesting Bash editor which lets you find bugs in your shell script. It is available on [GitHub][29] as well. In addition, you can install ShellCheck locally on [supported platforms][30]. - -[Try ShellCheck][31] - -#### Rextester - -![rextester bash editor][32] - -If you only want a dead simple online bash compiler, Rextester should be your choice. It also supports other programming languages. - -[Try Rextester][33] - -#### Learn Shell - -![online bash shell editor][34] - -Just like [Webminal][35], Learnshell provides you with the content (or resource) to learn shell programming and you could also run/try your code at the same time. It covers the basics and a few advanced topics as well. - -[Try Learn Shell Programming][36] - -### Wrapping Up - -Now that you know of the most reliable and fast online Linux terminals & online bash editors, learn, experiment, and play with the code! - -We might have missed any of your favorite online Linux terminals or maybe the best online bash compiler which you happen to use? Let us know your thoughts in the comments below. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/online-linux-terminals/ - -作者:[Ankush Das][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/ankush/ -[1]:https://itsfoss.com/install-bash-on-windows/ -[2]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/online-linux-terminals.jpeg -[3]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/jslinux-online-linux-terminal.jpg -[4]:https://buildroot.org/ -[5]:https://bellard.org/jslinux/ -[6]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/copy-sh-online-linux-terminal.jpg -[7]:https://github.com/copy/v86 -[8]:https://copy.sh/v86/?profile=linux26 -[9]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/webminal.jpg -[10]:http://www.webminal.org/terminal/ -[11]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/coding-ground-tutorialspoint-online-linux-terminal.jpg -[12]:https://www.tutorialspoint.com/codingground.htm -[13]:https://www.tutorialspoint.com/unix_terminal_online.php -[14]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/JS-UIX-online-linux-terminal.jpg -[15]:http://www.masswerk.at/jsuix/index.html -[16]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/cb-vu-online-linux-terminal.jpg -[17]:http://cb.vu/ -[18]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/linux-containers-terminal.jpg -[19]:https://linuxcontainers.org/lxd/try-it/ -[20]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/codeanywhere-terminal.jpg -[21]:https://codeanywhere.com/editor/ -[22]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/tutorialspoint-bash-compiler.jpg -[23]:https://www.tutorialspoint.com/execute_bash_online.php -[24]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/jdoodle-online-bash-editor.jpg -[25]:https://www.jdoodle.com/test-bash-shell-script-online -[26]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/paizo-io-bash-editor.jpg -[27]:https://paiza.io/en/projects/new?language=bash -[28]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/shell-check-bash-analyzer.jpg -[29]:https://github.com/koalaman/shellcheck -[30]:https://github.com/koalaman/shellcheck#user-content-installing -[31]:https://www.shellcheck.net/# -[32]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/rextester-bash-editor.jpg -[33]:http://rextester.com/l/bash_online_compiler -[34]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/learnshell-online-bash-shell.jpg -[35]:http://www.webminal.org/ -[36]:http://www.learnshell.org/ diff --git a/sources/tech/20180725 Put platforms in a Python game with Pygame.md b/sources/tech/20180725 Put platforms in a Python game with Pygame.md deleted file mode 100644 index 74d2536942..0000000000 --- a/sources/tech/20180725 Put platforms in a Python game with Pygame.md +++ /dev/null @@ -1,590 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (robsean) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Put platforms in a Python game with Pygame) -[#]: via: (https://opensource.com/article/18/7/put-platforms-python-game) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) - -Put platforms in a Python game with Pygame -====== -In part six of this series on building a Python game from scratch, create some platforms for your characters to travel. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/header.png?itok=iq8HFoEJ) - -This is part 6 in an ongoing series about creating video games in Python 3 using the Pygame module. Previous articles are: - -+ [Learn how to program in Python by building a simple dice game][24] -+ [Build a game framework with Python using the Pygame module][25] -+ [How to add a player to your Python game][26] -+ [Using Pygame to move your game character around][27] -+ [What's a hero without a villain? How to add one to your Python game][28] - - -A platformer game needs platforms. - -In [Pygame][1], the platforms themselves are sprites, just like your playable sprite. That's important because having platforms that are objects makes it a lot easier for your player sprite to interact with them. - -There are two major steps in creating platforms. First, you must code the objects, and then you must map out where you want the objects to appear. - -### Coding platform objects - -To build a platform object, you create a class called `Platform`. It's a sprite, just like your [`Player`][2] [sprite][2], with many of the same properties. - -Your `Platform` class needs to know a lot of information about what kind of platform you want, where it should appear in the game world, and what image it should contain. A lot of that information might not even exist yet, depending on how much you have planned out your game, but that's all right. Just as you didn't tell your Player sprite how fast to move until the end of the [Movement article][3], you don't have to tell `Platform` everything upfront. - -Near the top of the script you've been writing in this series, create a new class. The first three lines in this code sample are for context, so add the code below the comment: - -``` -import pygame -import sys -import os -## new code below: - -class Platform(pygame.sprite.Sprite): -# x location, y location, img width, img height, img file     -def __init__(self,xloc,yloc,imgw,imgh,img): -    pygame.sprite.Sprite.__init__(self) -    self.image = pygame.image.load(os.path.join('images',img)).convert() -    self.image.convert_alpha() -    self.image.set_colorkey(ALPHA) -    self.rect = self.image.get_rect() -    self.rect.y = yloc -    self.rect.x = xloc -``` - -When called, this class creates an object onscreen in some X and Y location, with some width and height, using some image file for texture. It's very similar to how players or enemies are drawn onscreen. - -### Types of platforms - -The next step is to map out where all your platforms need to appear. - -#### The tile method - -There are a few different ways to implement a platform game world. In the original side-scroller games, such as Mario Super Bros. and Sonic the Hedgehog, the technique was to use "tiles," meaning that there were a few blocks to represent the ground and various platforms, and these blocks were used and reused to make a level. You have only eight or 12 different kinds of blocks, and you line them up onscreen to create the ground, floating platforms, and whatever else your game needs. Some people find this the easier way to make a game since you just have to make (or download) a small set of level assets to create many different levels. The code, however, requires a little more math. - -![Supertux, a tile-based video game][5] - -[SuperTux][6], a tile-based video game. - -#### The hand-painted method - -Another method is to make each and every asset as one whole image. If you enjoy creating assets for your game world, this is a great excuse to spend time in a graphics application, building each and every part of your game world. This method requires less math, because all the platforms are whole, complete objects, and you tell [Python][7] where to place them onscreen. - -Each method has advantages and disadvantages, and the code you must use is slightly different depending on the method you choose. I'll cover both so you can use one or the other, or even a mix of both, in your project. - -### Level mapping - -Mapping out your game world is a vital part of level design and game programming in general. It does involve math, but nothing too difficult, and Python is good at math so it can help some. - -You might find it helpful to design on paper first. Get a sheet of paper and draw a box to represent your game window. Draw platforms in the box, labeling each with its X and Y coordinates, as well as its intended width and height. The actual positions in the box don't have to be exact, as long as you keep the numbers realistic. For instance, if your screen is 720 pixels wide, then you can't fit eight platforms at 100 pixels each all on one screen. - -Of course, not all platforms in your game have to fit in one screen-sized box, because your game will scroll as your player walks through it. So keep drawing your game world to the right of the first screen until the end of the level. - -If you prefer a little more precision, you can use graph paper. This is especially helpful when designing a game with tiles because each grid square can represent one tile. - -![Example of a level map][9] - -Example of a level map. - -#### Coordinates - -You may have learned in school about the [Cartesian coordinate system][10]. What you learned applies to Pygame, except that in Pygame, your game world's coordinates place `0,0` in the top-left corner of your screen instead of in the middle, which is probably what you're used to from Geometry class. - -![Example of coordinates in Pygame][12] - -Example of coordinates in Pygame. - -The X axis starts at 0 on the far left and increases infinitely to the right. The Y axis starts at 0 at the top of the screen and extends down. - -#### Image sizes - -Mapping out a game world is meaningless if you don't know how big your players, enemies, and platforms are. You can find the dimensions of your platforms or tiles in a graphics program. In [Krita][13], for example, click on the **Image** menu and select **Properties**. You can find the dimensions at the very top of the **Properties** window. - -Alternately, you can create a simple Python script to tell you the dimensions of an image. Open a new text file and type this code into it: - -``` -#!/usr/bin/env python3 - -from PIL import Image -import os.path -import sys - -if len(sys.argv) > 1: -    print(sys.argv[1]) -else: -    sys.exit('Syntax: identify.py [filename]') - -pic = sys.argv[1] -dim = Image.open(pic) -X   = dim.size[0] -Y   = dim.size[1] - -print(X,Y) -``` - -Save the text file as `identify.py`. - -To set up this script, you must install an extra set of Python modules that contain the new keywords used in the script: - -``` -$ pip3 install Pillow --user -``` - -Once that is installed, run your script from within your game project directory: - -``` -$ python3 ./identify.py images/ground.png -(1080, 97) -``` - -The image size of the ground platform in this example is 1080 pixels wide and 97 high. - -### Platform blocks - -If you choose to draw each asset individually, you must create several platforms and any other elements you want to insert into your game world, each within its own file. In other words, you should have one file per asset, like this: - -![One image file per object][15] - -One image file per object. - -You can reuse each platform as many times as you want, just make sure that each file only contains one platform. You cannot use a file that contains everything, like this: - -![Your level cannot be one image file][17] - -Your level cannot be one image file. - -You might want your game to look like that when you've finished, but if you create your level in one big file, there is no way to distinguish a platform from the background, so either paint your objects in their own file or crop them from a large file and save individual copies. - -**Note:** As with your other assets, you can use [GIMP][18], Krita, [MyPaint][19], or [Inkscape][20] to create your game assets. - -Platforms appear on the screen at the start of each level, so you must add a `platform` function in your `Level` class. The special case here is the ground platform, which is important enough to be treated as its own platform group. By treating the ground as its own special kind of platform, you can choose whether it scrolls or whether it stands still while other platforms float over the top of it. It's up to you. - -Add these two functions to your `Level` class: - -``` -def ground(lvl,x,y,w,h): -    ground_list = pygame.sprite.Group() -    if lvl == 1: -        ground = Platform(x,y,w,h,'block-ground.png') -        ground_list.add(ground) - -    if lvl == 2: -        print("Level " + str(lvl) ) - -    return ground_list - -def platform( lvl ): -    plat_list = pygame.sprite.Group() -    if lvl == 1: -        plat = Platform(200, worldy-97-128, 285,67,'block-big.png') -        plat_list.add(plat) -        plat = Platform(500, worldy-97-320, 197,54,'block-small.png') -        plat_list.add(plat) -    if lvl == 2: -        print("Level " + str(lvl) ) -        -    return plat_list -``` - -The `ground` function requires an X and Y location so Pygame knows where to place the ground platform. It also requires the width and height of the platform so Pygame knows how far the ground extends in each direction. The function uses your `Platform` class to generate an object onscreen, and then adds that object to the `ground_list` group. - -The `platform` function is essentially the same, except that there are more platforms to list. In this example, there are only two, but you can have as many as you like. After entering one platform, you must add it to the `plat_list` before listing another. If you don't add a platform to the group, then it won't appear in your game. - -> **Tip:** It can be difficult to think of your game world with 0 at the top, since the opposite is what happens in the real world; when figuring out how tall you are, you don't measure yourself from the sky down, you measure yourself from your feet to the top of your head. -> -> If it's easier for you to build your game world from the "ground" up, it might help to express Y-axis values as negatives. For instance, you know that the bottom of your game world is the value of `worldy`. So `worldy` minus the height of the ground (97, in this example) is where your player is normally standing. If your character is 64 pixels tall, then the ground minus 128 is exactly twice as tall as your player. Effectively, a platform placed at 128 pixels is about two stories tall, relative to your player. A platform at -320 is three more stories. And so on. - -As you probably know by now, none of your classes and functions are worth much if you don't use them. Add this code to your setup section (the first line is just for context, so add the last two lines): - -``` -enemy_list  = Level.bad( 1, eloc ) -ground_list = Level.ground( 1,0,worldy-97,1080,97 ) -plat_list   = Level.platform( 1 ) -``` - -And add these lines to your main loop (again, the first line is just for context): - -``` -enemy_list.draw(world)  # refresh enemies -ground_list.draw(world)  # refresh ground -plat_list.draw(world)  # refresh platforms -``` - -### Tiled platforms - -Tiled game worlds are considered easier to make because you just have to draw a few blocks upfront and can use them over and over to create every platform in the game. There are even sets of tiles for you to use on sites like [OpenGameArt.org][21]. - -The `Platform` class is the same as the one provided in the previous sections. - -The `ground` and `platform` in the `Level` class, however, must use loops to calculate how many blocks to use to create each platform. - -If you intend to have one solid ground in your game world, the ground is simple. You just "clone" your ground tile across the whole window. For instance, you could create a list of X and Y values to dictate where each tile should be placed, and then use a loop to take each value and draw one tile. This is just an example, so don't add this to your code: - -``` -# Do not add this to your code -gloc = [0,656,64,656,128,656,192,656,256,656,320,656,384,656] -``` - -If you look carefully, though, you can see all the Y values are always the same, and the X values increase steadily in increments of 64, which is the size of the tiles. That kind of repetition is exactly what computers are good at, so you can use a little bit of math logic to have the computer do all the calculations for you: - -Add this to the setup part of your script: - -``` -gloc = [] -tx   = 64 -ty   = 64 - -i=0 -while i <= (worldx/tx)+tx: -    gloc.append(i*tx) -    i=i+1 - -ground_list = Level.ground( 1,gloc,tx,ty ) -``` - -Now, regardless of the size of your window, Python divides the width of the game world by the width of the tile and creates an array listing each X value. This doesn't calculate the Y value, but that never changes on flat ground anyway. - -To use the array in a function, use a `while` loop that looks at each entry and adds a ground tile at the appropriate location: - -``` -def ground(lvl,gloc,tx,ty): -    ground_list = pygame.sprite.Group() -    i=0 -    if lvl == 1: -        while i < len(gloc): -            ground = Platform(gloc[i],worldy-ty,tx,ty,'tile-ground.png') -            ground_list.add(ground) -            i=i+1 - -    if lvl == 2: -        print("Level " + str(lvl) ) - -    return ground_list -``` - -This is nearly the same code as the `ground` function for the block-style platformer, provided in a previous section above, aside from the `while` loop. - -For moving platforms, the principle is similar, but there are some tricks you can use to make your life easier. - -Rather than mapping every platform by pixels, you can define a platform by its starting pixel (its X value), the height from the ground (its Y value), and how many tiles to draw. That way, you don't have to worry about the width and height of every platform. - -The logic for this trick is a little more complex, so copy this code carefully. There is a `while` loop inside of another `while` loop because this function must look at all three values within each array entry to successfully construct a full platform. In this example, there are only three platforms defined as `ploc.append` statements, but your game probably needs more, so define as many as you need. Of course, some won't appear yet because they're far offscreen, but they'll come into view once you implement scrolling. - -``` -def platform(lvl,tx,ty): -    plat_list = pygame.sprite.Group() -    ploc = [] -    i=0 -    if lvl == 1: -        ploc.append((200,worldy-ty-128,3)) -        ploc.append((300,worldy-ty-256,3)) -        ploc.append((500,worldy-ty-128,4)) -        while i < len(ploc): -            j=0 -            while j <= ploc[i][2]: -                plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'tile.png') -                plat_list.add(plat) -                j=j+1 -            print('run' + str(i) + str(ploc[i])) -            i=i+1 -            -    if lvl == 2: -        print("Level " + str(lvl) ) - -    return plat_list -``` - -To get the platforms to appear in your game world, they must be in your main loop. If you haven't already done so, add these lines to your main loop (again, the first line is just for context): - -``` -        enemy_list.draw(world)  # refresh enemies -        ground_list.draw(world) # refresh ground -        plat_list.draw(world)   # refresh platforms -``` - -Launch your game, and adjust the placement of your platforms as needed. Don't worry that you can't see the platforms that are spawned offscreen; you'll fix that soon. - -Here is the game so far in a picture and in code: - -![Pygame game][23] - -Our Pygame platformer so far. - -``` -    #!/usr/bin/env python3 -# draw a world -# add a player and player control -# add player movement -# add enemy and basic collision -# add platform - -# GNU All-Permissive License -# Copying and distribution of this file, with or without modification, -# are permitted in any medium without royalty provided the copyright -# notice and this notice are preserved.  This file is offered as-is, -# without any warranty. - -import pygame -import sys -import os - -''' -Objects -''' - -class Platform(pygame.sprite.Sprite): -    # x location, y location, img width, img height, img file     -    def __init__(self,xloc,yloc,imgw,imgh,img): -        pygame.sprite.Sprite.__init__(self) -        self.image = pygame.image.load(os.path.join('images',img)).convert() -        self.image.convert_alpha() -        self.rect = self.image.get_rect() -        self.rect.y = yloc -        self.rect.x = xloc - -class Player(pygame.sprite.Sprite): -    ''' -    Spawn a player -    ''' -    def __init__(self): -        pygame.sprite.Sprite.__init__(self) -        self.movex = 0 -        self.movey = 0 -        self.frame = 0 -        self.health = 10 -        self.score = 1 -        self.images = [] -        for i in range(1,9): -            img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() -            img.convert_alpha() -            img.set_colorkey(ALPHA) -            self.images.append(img) -            self.image = self.images[0] -            self.rect  = self.image.get_rect() - -    def control(self,x,y): -        ''' -        control player movement -        ''' -        self.movex += x -        self.movey += y - -    def update(self): -        ''' -        Update sprite position -        ''' - -        self.rect.x = self.rect.x + self.movex -        self.rect.y = self.rect.y + self.movey - -        # moving left -        if self.movex < 0: -            self.frame += 1 -            if self.frame > ani*3: -                self.frame = 0 -            self.image = self.images[self.frame//ani] - -        # moving right -        if self.movex > 0: -            self.frame += 1 -            if self.frame > ani*3: -                self.frame = 0 -            self.image = self.images[(self.frame//ani)+4] - -        # collisions -        enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) -        for enemy in enemy_hit_list: -            self.health -= 1 -            print(self.health) - -        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) -        for g in ground_hit_list: -            self.health -= 1 -            print(self.health) - - -class Enemy(pygame.sprite.Sprite): -    ''' -    Spawn an enemy -    ''' -    def __init__(self,x,y,img): -        pygame.sprite.Sprite.__init__(self) -        self.image = pygame.image.load(os.path.join('images',img)) -        #self.image.convert_alpha() -        #self.image.set_colorkey(ALPHA) -        self.rect = self.image.get_rect() -        self.rect.x = x -        self.rect.y = y -        self.counter = 0 - -    def move(self): -        ''' -        enemy movement -        ''' -        distance = 80 -        speed = 8 - -        if self.counter >= 0 and self.counter <= distance: -            self.rect.x += speed -        elif self.counter >= distance and self.counter <= distance*2: -            self.rect.x -= speed -        else: -            self.counter = 0 - -        self.counter += 1 - -class Level(): -    def bad(lvl,eloc): -        if lvl == 1: -            enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy -            enemy_list = pygame.sprite.Group() # create enemy group -            enemy_list.add(enemy)              # add enemy to group - -        if lvl == 2: -            print("Level " + str(lvl) ) - -        return enemy_list - -    def loot(lvl,lloc): -        print(lvl) - -    def ground(lvl,gloc,tx,ty): -        ground_list = pygame.sprite.Group() -        i=0 -        if lvl == 1: -            while i < len(gloc): -                print("blockgen:" + str(i)) -                ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') -                ground_list.add(ground) -                i=i+1 - -        if lvl == 2: -            print("Level " + str(lvl) ) - -        return ground_list - -''' -Setup -''' -worldx = 960 -worldy = 720 - -fps = 40 # frame rate -ani = 4  # animation cycles -clock = pygame.time.Clock() -pygame.init() -main = True - -BLUE  = (25,25,200) -BLACK = (23,23,23 ) -WHITE = (254,254,254) -ALPHA = (0,255,0) - -world = pygame.display.set_mode([worldx,worldy]) -backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() -backdropbox = world.get_rect() -player = Player() # spawn player -player.rect.x = 0 -player.rect.y = 0 -player_list = pygame.sprite.Group() -player_list.add(player) -steps = 10 # how fast to move - -eloc = [] -eloc = [200,20] -gloc = [] -#gloc = [0,630,64,630,128,630,192,630,256,630,320,630,384,630] -tx = 64 #tile size -ty = 64 #tile size - -i=0 -while i <= (worldx/tx)+tx: -    gloc.append(i*tx) -    i=i+1 -    print("block: " + str(i)) - -enemy_list = Level.bad( 1, eloc ) -ground_list = Level.ground( 1,gloc,tx,ty ) - -''' -Main loop -''' -while main == True: -    for event in pygame.event.get(): -        if event.type == pygame.QUIT: -            pygame.quit(); sys.exit() -            main = False - -        if event.type == pygame.KEYDOWN: -            if event.key == pygame.K_LEFT or event.key == ord('a'): -                player.control(-steps,0) -            if event.key == pygame.K_RIGHT or event.key == ord('d'): -                player.control(steps,0) -            if event.key == pygame.K_UP or event.key == ord('w'): -                print('jump') - -        if event.type == pygame.KEYUP: -            if event.key == pygame.K_LEFT or event.key == ord('a'): -                player.control(steps,0) -            if event.key == pygame.K_RIGHT or event.key == ord('d'): -                player.control(-steps,0) -            if event.key == ord('q'): -                pygame.quit() -                sys.exit() -                main = False - -#    world.fill(BLACK) -    world.blit(backdrop, backdropbox) -    player.update() -    player_list.draw(world) #refresh player position -    enemy_list.draw(world)  # refresh enemies -    ground_list.draw(world)  # refresh enemies -    for e in enemy_list: -        e.move() -    pygame.display.flip() -    clock.tick(fps) -``` - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/7/put-platforms-python-game - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/seth -[b]: https://github.com/lujun9972 -[1]: https://www.pygame.org/news -[2]: https://opensource.com/article/17/12/game-python-add-a-player -[3]: https://opensource.com/article/17/12/game-python-moving-player -[4]: /file/403841 -[5]: https://opensource.com/sites/default/files/uploads/supertux.png (Supertux, a tile-based video game) -[6]: https://www.supertux.org/ -[7]: https://www.python.org/ -[8]: /file/403861 -[9]: https://opensource.com/sites/default/files/uploads/layout.png (Example of a level map) -[10]: https://en.wikipedia.org/wiki/Cartesian_coordinate_system -[11]: /file/403871 -[12]: https://opensource.com/sites/default/files/uploads/pygame_coordinates.png (Example of coordinates in Pygame) -[13]: https://krita.org/en/ -[14]: /file/403876 -[15]: https://opensource.com/sites/default/files/uploads/pygame_floating.png (One image file per object) -[16]: /file/403881 -[17]: https://opensource.com/sites/default/files/uploads/pygame_flattened.png (Your level cannot be one image file) -[18]: https://www.gimp.org/ -[19]: http://mypaint.org/about/ -[20]: https://inkscape.org/en/ -[21]: https://opengameart.org/content/simplified-platformer-pack -[22]: /file/403886 -[23]: https://opensource.com/sites/default/files/uploads/pygame_platforms.jpg (Pygame game) -[24]: Learn how to program in Python by building a simple dice game -[25]: https://opensource.com/article/17/12/game-framework-python -[26]: https://opensource.com/article/17/12/game-python-add-a-player -[27]: https://opensource.com/article/17/12/game-python-moving-player -[28]: https://opensource.com/article/18/5/pygame-enemy - diff --git a/sources/tech/20180727 4 Ways to Customize Xfce and Give it a Modern Look.md b/sources/tech/20180727 4 Ways to Customize Xfce and Give it a Modern Look.md deleted file mode 100644 index c4372724f7..0000000000 --- a/sources/tech/20180727 4 Ways to Customize Xfce and Give it a Modern Look.md +++ /dev/null @@ -1,145 +0,0 @@ -4 Ways to Customize Xfce and Give it a Modern Look -====== -**Brief: Xfce is a great lightweight desktop environment with one drawback. It looks sort of old. But you don’t have to stick with the default looks. Let’s see various ways you can customize Xfce to give it a modern and beautiful look.** - -![Customize Xfce desktop envirnment][1] - -To start with, Xfce is one of the most [popular desktop environments][2]. Being a lightweight DE, you can run Xfce on very low resource and it still works great. This is one of the reasons why many [lightweight Linux distributions][3] use Xfce by default. - -Some people prefer it even on a high-end device stating its simplicity, easy of use and non-resource hungry nature as the main reasons. - -[Xfce][4] is in itself minimal and provides just what you need. The one thing that bothers is its look and feel which feel old. However, you can easily customize Xfce to look modern and beautiful without reaching the limit where a Unity/GNOME session eats up system resources. - -### 4 ways to Customize Xfce desktop - -Let’s see some of the ways by which we can improve the look and feel of your Xfce desktop environment. - -The default Xfce desktop environment looks something like this : - -![Xfce default screen][5] - -As you can see, the default Xfce desktop is kinda boring. We will use some themes, icon packs and change the default dock to make it look fresh and a bit revealing. - -#### 1. Change themes in Xfce - -The first thing we will do is pick up a theme from [xfce-look.org][6]. My favorite Xfce theme is [XFCE-D-PRO][7]. - -You can download the theme from [here][8] and extract it somewhere. - -You can copy this extracted file to **.theme** folder in your home directory. If the folder is not present by default, you can create one and the same goes for icons which needs a **.icons** folder in the home directory. - -Open **Settings > Appearance > Style** to select the theme, log out and login to see the change. Adwaita-dark from default is also a nice one. - -![Appearance Xfce][9] - -You can use any [good GTK theme][10] on Xfce. - -#### 2. Change icons in Xfce - -Xfce-look.org also provides icon themes which you can download, extract and put it in your home directory under **.icons** directory. Once you have added the icon theme in the .icons directory, go to **Settings > Appearance > Icons** to select that icon theme. - -![Moka icon theme][11] - -I have installed [Moka icon set][12] that looks awesome. - -![Moka theme][13] - -You can also refer to our list of [awesome icon themes][14]. - -##### **Optional: Installing themes through Synaptic** - -If you want to avoid the manual search and copying of the files, install Synaptic Manager in your system. You can look for some best themes over web and icon sets, and using synaptic manager you can search and install it. -``` -sudo apt-get install synaptic - -``` - -**Searching and installing theme/icons through Synaptic** - -Open synaptic and click on **Search**. Enter your desired theme, and it will display the list of matching items. Mark all the additional required changes and click on **Apply**. This will download the theme and then install it. - -![Arc Theme][15] - -Once done, you can open the **Appearance** option to select the desired theme. - -In my opinion, this is not the best way to install themes in Xfce. - -#### 3. Change wallpapers in Xfce - -Again, the default Xfce wallpaper is not bad at all. But you can change the wallpaper to something that matches with your icons and themes. - -To change wallpapers in Xfce, right click on the desktop and click on Desktop Settings. You can change the desktop background from your custom collection or the defaults one given. - -Right click on the desktop and click on **Desktop Settings**. Choose **Background** from the folder option, and choose any one of the default backgrounds or a custom one. - -![Changing desktop wallpapers][16] - -#### 4. Change the dock in Xfce - -The default dock is nice and pretty much does what it is for. But again, it looks a bit boring. - -![Docky][17] - -However, if you want your dock to be better and with a little more customization options, you can install another dock. - -Plank is one of the simplest and lightweight docks and is highly configurable. - -To install Plank use the command below: - -`sudo apt-get install plank` - -If Plank is not available in the default repository, you can install it from this PPA. -``` -sudo add-apt-repository ppa:ricotz/docky -sudo apt-get update -sudo apt-get install plank - -``` - -Before you use Plank, you should remove the default dock by right-clicking in it and under Panel Settings, clicking on delete. - -Once done, go to **Accessory > Plank** to launch Plank dock. - -![Plank][18] - -Plank picks up icons from the one you are using. So if you change the icon themes, you’ll see the change is reflected in the dock also. - -### Wrapping Up - -XFCE is a lightweight, fast and highly customizable. If you are limited on system resource, it serves good and you can easily customize it to look better. Here’s how my screen looks after applying these steps. - -![XFCE desktop][19] - -This is just with half an hour of effort. You can make it look much better with different themes/icons customization. Feel free to share your customized XFCE desktop screen in the comments and the combination of themes and icons you are using. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/customize-xfce/ - -作者:[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://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/xfce-customization.jpeg -[2]:https://itsfoss.com/best-linux-desktop-environments/ -[3]:https://itsfoss.com/lightweight-linux-beginners/ -[4]:https://xfce.org/ -[5]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/06/1-1-800x410.jpg -[6]:http://xfce-look.org -[7]:https://www.xfce-look.org/p/1207818/XFCE-D-PRO -[8]:https://www.xfce-look.org/p/1207818/startdownload?file_id=1523730502&file_name=XFCE-D-PRO-1.6.tar.xz&file_type=application/x-xz&file_size=105328&url=https%3A%2F%2Fdl.opendesktop.org%2Fapi%2Ffiles%2Fdownloadfile%2Fid%2F1523730502%2Fs%2F6019b2b57a1452471eac6403ae1522da%2Ft%2F1529360682%2Fu%2F%2FXFCE-D-PRO-1.6.tar.xz -[9]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/4.jpg -[10]:https://itsfoss.com/best-gtk-themes/ -[11]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/6.jpg -[12]:https://snwh.org/moka -[13]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/11-800x547.jpg -[14]:https://itsfoss.com/best-icon-themes-ubuntu-16-04/ -[15]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/5-800x531.jpg -[16]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/7-800x546.jpg -[17]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/8.jpg -[18]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/9.jpg -[19]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/10-800x447.jpg diff --git a/sources/tech/20180802 Top 5 CAD Software Available for Linux in 2018.md b/sources/tech/20180802 Top 5 CAD Software Available for Linux in 2018.md deleted file mode 100644 index ec02690b6e..0000000000 --- a/sources/tech/20180802 Top 5 CAD Software Available for Linux in 2018.md +++ /dev/null @@ -1,143 +0,0 @@ -Top 5 CAD Software Available for Linux in 2018 -====== -[Computer Aided Design (CAD)][1] is an essential part of many streams of engineering. CAD is professionally used is architecture, auto parts design, space shuttle research, aeronautics, bridge construction, interior design, and even clothing and jewelry. - -A number of professional grade CAD software like SolidWorks and Autodesk AutoCAD are not natively supported on the Linux platform. So today we will be having a look at the top CAD software available for Linux. Let’s dive right in. - -### Best CAD Software available for Linux - -![CAD Software for Linux][2] - -Before you see the list of CAD software for Linux, you should keep one thing in mind that not all the applications listed here are open source. We included some non-FOSS CAD software to help average Linux user. - -Installation instructions of Ubuntu-based Linux distributions have been provided. You may check the respective websites to learn the installation procedure for other distributions. - -The list is not any specific order. CAD application at number one should not be considered better than the one at number three and so on. - -#### 1\. FreeCAD - -For 3D Modelling, FreeCAD is an excellent option which is both free (beer and speech) and open source. FreeCAD is built with keeping mechanical engineering and product design as target purpose. FreeCAD is multiplatform and is available on Windows, Mac OS X+ along with Linux. - -![freecad][3] - -Although FreeCAD has been the choice of many Linux users, it should be noted that FreeCAD is still on version 0.17 and therefore, is not suitable for major deployment. But the development has picked up pace recently. - -[FreeCAD][4] - -FreeCAD does not focus on direct 2D drawings and animation of organic shapes but it’s great for design related to mechanical engineering. FreeCAD version 0.15 is available in the Ubuntu repositories. You can install it by running the below command. -``` -sudo apt install freecad - -``` - -To get newer daily builds (0.17 at the moment), open a terminal (ctrl+alt+t) and run the commands below one by one. -``` -sudo add-apt-repository ppa:freecad-maintainers/freecad-daily - -sudo apt update - -sudo apt install freecad-daily - -``` - -#### 2\. LibreCAD - -LibreCAD is a free, opensource, 2D CAD solution. Generally, CAD tends to be a resource-intensive task, and if you have a rather modest hardware, then I’d suggest you go for LibreCAD as it is really lightweight in terms of resource usage. LibreCAD is a great candidate for geometric constructions. - -![librecad][5] -As a 2D tool, LibreCAD is good but it cannot work on 3D models and renderings. It might be unstable at times but it has a dependable autosave which won’t let your work go wasted. - -[LibreCAD][6] - -You can install LibreCAD by running the following command -``` -sudo apt install librecad - -``` - -#### 3\. OpenSCAD - -OpenSCAD is a free 3D CAD software. OpenSCAD is very lightweight and flexible. OpenSCAD is not interactive. You need to ‘program’ the model and OpenSCAD interprets that code to render a visual model. It is a compiler in a sense. You cannot draw the model. You describe the model. - -![openscad][7] - -OpenSCAD is the most complicated tool on this list but once you get to know it, it provides an enjoyable work experience. - -[OpenSCAD][8] - -You can use the following commands to install OpenSCAD. -``` -sudo apt-get install openscad - -``` - -#### 4\. BRL-CAD - -BRL-CAD is one of the oldest CAD tools out there. It also has been loved by Linux/UNIX users as it aligns itself with *nix philosophies of modularity and freedom. - -![BRL-CAD rendering by Sean][9] - -BRL-CAD was started in 1979, and it is still developed actively. Now, BRL-CAD is not AutoCAD but it is still a great choice for transport studies such as thermal and ballistic penetration. BRL-CAD underlies CSG instead of boundary representation. You might need to keep that in mind while opting for BRL-CAD. You can download BRL-CAD from its official website. - -[BRL-CAD][10] - -#### 5\. DraftSight (not open source) - -If You’re used to working on AutoCAD, then DraftSight would be the perfect alternative for you. - -DraftSight is a great CAD tool available on Linux. It has a rather similar workflow to AutoCAD, which makes migrating easier. It even provides a similar look and feel. DrafSight is also compatible with the .dwg file format of AutoCAD. But DrafSight is a 2D CAD software. It does not support 3D CAD as of yet. - -![draftsight][11] - -Although DrafSight is a commercial software with a starting price of $149. A free version is also made available on the[DraftSight website][12]. You can download the .deb package and install it on Ubuntu based distributions. need to register your free copy using your email ID to start using DraftSight. - -[DraftSight][12] - -#### Honorary mentions - - * With a huge growth in cloud computing technologies, cloud CAD solutions like [OnShape][13] have been getting popular day by day. - * [SolveSpace][14] is another open-source project worth mentioning. It supports 3D modeling. - * Siemens NX is an industrial grade CAD solution available on Windows, Mac OS and Linux, but it is ridiculously expensive, so omitted in this list. - * Then you have [LeoCAD][15], which is a CAD software where you use LEGO blocks to build stuff. What you do with this information is up to you. - - - -#### CAD on Linux, in my opinion - -Although gaming on Linux has picked up, I always tell my hardcore gaming friends to stick to Windows. Similarly, if You are an engineering student with CAD in your curriculum, I’d recommend that you use the software that your college prescribes (AutoCAD, SolidEdge, Catia), which generally tend to run on Windows only. - -And for the advanced professionals, these tools are simply not up to the mark when we’re talking about industry standards. - -For those of you thinking about running AutoCAD in WINE, although some older versions of AutoCAD can be installed on WINE, they simply do not perform, with glitches and crashes ruining the experience. - -That being said, I highly respect the work that has been put by the developers of the above-listed software. They have enriched the FOSS world. And it’s great to see software like FreeCAD developing with an accelerated pace in the recent years. - -Well, that’s it for today. Do share your thoughts with us using the comments section below and don’t forget to share this article. Cheers. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/cad-software-linux/ - -作者:[Aquil Roshan][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/aquil/ -[1]:https://en.wikipedia.org/wiki/Computer-aided_design -[2]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/cad-software-linux.jpeg -[3]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/freecad.jpg -[4]:https://www.freecadweb.org/ -[5]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/librecad.jpg -[6]:https://librecad.org/ -[7]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/openscad.jpg -[8]:http://www.openscad.org/ -[9]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/brlcad.jpg -[10]:https://brlcad.org/ -[11]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/07/draftsight.jpg -[12]:https://www.draftsight2018.com/ -[13]:https://www.onshape.com/ -[14]:http://solvespace.com/index.pl -[15]:https://www.leocad.org/ diff --git a/sources/tech/20180902 Learning BASIC Like It-s 1983.md b/sources/tech/20180902 Learning BASIC Like It-s 1983.md deleted file mode 100644 index 5790ef6e88..0000000000 --- a/sources/tech/20180902 Learning BASIC Like It-s 1983.md +++ /dev/null @@ -1,184 +0,0 @@ -Learning BASIC Like It's 1983 -====== -I was not yet alive in 1983. This is something that I occasionally regret. I am especially sorry that I did not experience the 8-bit computer era as it was happening, because I think the people that first encountered computers when they were relatively simple and constrained have a huge advantage over the rest of us. - -Today, (almost) everyone knows how to use a computer, but very few people, even in the computing industry, grasp all of what is going on inside of any single machine. There are now [so many layers of software][1] doing so many different things that one struggles to identify the parts that are essential. In 1983, though, home computers were unsophisticated enough that a diligent person could learn how a particular computer worked through and through. That person is today probably less mystified than I am by all the abstractions that modern operating systems pile on top of the hardware. I expect that these layers of abstractions were easy to understand one by one as they were introduced; today, new programmers have to try to understand them all by working top to bottom and backward in time. - -Many famous programmers, particularly in the video game industry, started programming games in childhood on 8-bit computers like the Apple II and the Commodore 64. John Romero, Richard Garriott, and Chris Roberts are all examples. It’s easy to see how this happened. In the 8-bit computer era, many games were available only as printed BASIC listings in computer magazines and [books][2]. If you wanted to play one of those games, you had to type in the whole program by hand. Inevitably, you would get something wrong, so you would have to debug your program. By the time you got it working, you knew enough about how the program functioned to start modifying it yourself. If you were an avid gamer, you became a good programmer almost by necessity. - -I also played computer games throughout my childhood. But the games I played came on CD-ROMs. I sometimes found myself having to google how to fix a crashing installer, which would involve editing the Windows Registry or something like that. This kind of minor troubleshooting may have made me comfortable enough with computers to consider studying computer science in college. But it never taught me anything crucial about how computers worked or how to control them. - -Now, of course, I tell computers what to do for a living. All the same, I can’t help feeling that I missed out on some fundamental insight afforded only to those that grew up programming simpler computers. What would it have been like to encounter computers for the first time in the early 1980s? How would that have been different from the experience of using a computer today? - -This post is going to be a little different from the usual Two-Bit History post because I’m going to try to imagine an answer to these questions. - -### 1983 - -It was just last week that you saw [the Commodore 64 ad][3] on TV. Now that M*A*S*H was over, you were in the market for something new to do on Monday nights. This Commodore 64 thing looked even better than the Apple II that Rudy’s family had in their basement. Plus, the ad promised that the new computer would soon bring friends “knocking down” your door. You knew several people at school that would rather be hanging out at your house than Rudy’s anyway, if only they could play Zork there. - -So you persuaded your parents to buy one. Your mother said that they would consider it only if having a home computer meant that you stayed away from the arcade. You reluctantly agreed. Your father thought he would start tracking the family’s finances in MultiPlan, the spreadsheet program he had heard about, which is why the computer got put in the living room. A year later, though, you would be the only one still using it. You were finally allowed to put it on the desk in your bedroom, right under your Police poster. - -(Your sister protested this decision, but it was 1983 and computers [weren’t for her][4].) - -Dad picked it up from [ComputerLand][5] on the way home from work. The two of you laid the box down next to the TV and opened it. “WELCOME TO THE WORLD OF FRIENDLY COMPUTING,” said the packaging. Twenty minutes later, you weren’t convinced—the two of you were still trying to connect the Commodore to the TV set and wondering whether the TV’s antenna cable was the 75-ohm or 300-ohm coax type. But eventually you were able to turn your TV to channel 3 and see a grainy, purple image. - -![Commodore 64 startup screen][6] - -`READY`, the computer reported. Your father pushed the computer toward you, indicating that you should be the first to give it a try. `HELLO`, you typed, carefully hunting for each letter. The computer’s response was baffling. - -![Commodore 64 syntax error][7] - -You tried typing in a few different words, but the response was always the same. Your father said that you had better read through the rest of the manual. That would be no mean feat—[the manual that came with the Commodore 64][8] was a small book. But that didn’t bother you, because the introduction to the manual foreshadowed wonders. - -The Commodore 64, it claimed, had “the most advanced picture maker in the microcomputer industry,” which would allow you “to design your own pictures in four different colors, just like the ones you see on arcade type video games.” The Commodore 64 also had “built-in music and sound effects that rival many well known music synthesizers.” All of these tools would be put in your hands, because the manual would walk you through it all: - -> Just as important as all the available hardware is the fact that this USER’S GUIDE will help you develop your understanding of computers. It won’t tell you everything there is to know about computers, but it will refer you to a wide variety of publications for more detailed information about the topics presented. Commodore wants you to really enjoy your new COMMODORE 64. And to have fun, remember: programming is not the kind of thing you can learn in a day. Be patient with yourself as you go through the USER’S GUIDE. - -That night, in bed, you read through the entire first three chapters—”Setup,” “Getting Started,” and “Beginning BASIC Programming”—before finally succumbing to sleep with the manual splayed across your chest. - -### Commodore BASIC - -Now, it’s Saturday morning and you’re eager to try out what you’ve learned. One of the first things the manual teaches you how to do is change the colors on the display. You follow the instructions, pressing `CTRL-9` to enter reverse type mode and then holding down the space bar to create long lines. You swap between colors using `CTRL-1` through `CTRL-8`, reveling in your sudden new power over the TV screen. - -![Commodore 64 color bands][9] - -As cool as this is, you realize it doesn’t count as programming. In order to program the computer, you learned last night, you have to speak to it in a language called BASIC. To you, BASIC seems like something out of Star Wars, but BASIC is, by 1983, almost two decades old. It was invented by two Dartmouth professors, John Kemeny and Tom Kurtz, who wanted to make computing accessible to undergraduates in the social sciences and humanities. It was widely available on minicomputers and popular in college math classes. It then became standard on microcomputers after Bill Gates and Paul Allen wrote the MicroSoft BASIC interpreter for the Altair. But the manual doesn’t explain any of this and you won’t learn it for many years. - -One of the first BASIC commands the manual suggests you try is the `PRINT` command. You type in `PRINT "COMMODORE 64"`, slowly, since it takes you a while to find the quotation mark symbol above the `2` key. You hit `RETURN` and this time, instead of complaining, the computer does exactly what you told it to do and displays “COMMODORE 64” on the next line. - -Now you try using the `PRINT` command on all sorts of different things: two numbers added together, two numbers multiplied together, even several decimal numbers. You stop typing out `PRINT` and instead use `?`, since the manual has advised you that `?` is an abbreviation for `PRINT` often used by expert programmers. You feel like an expert already, but then you remember that you haven’t even made it to chapter three, “Beginning BASIC Programming.” - -You get there soon enough. The chapter begins by prompting you to write your first real BASIC program. You type in `NEW` and hit `RETURN`, which gives you a clean slate. You then type your program in: - -``` -10 ?"COMMODORE 64" -20 GOTO 10 -``` - -The 10 and the 20, the manual explains, are line numbers. They order the statements for the computer. They also allow the programmer to refer to other lines of the program in certain commands, just like you’ve done here with the `GOTO` command, which directs the program back to line 10. “It is good programming practice,” the manual opines, “to number lines in increments of 10—in case you need to insert some statements later on.” - -You type `RUN` and stare as the screen clogs with “COMMODORE 64,” repeated over and over. - -![Commodore 64 showing result of printing "Commodore 64" repeatedly][10] - -You’re not certain that this isn’t going to blow up your computer. It takes you a second to remember that you are supposed to hit the `RUN/STOP` key to break the loop. - -The next few sections of the manual teach you about variables, which the manual tells you are like “a number of boxes within the computer that can each hold a number or a string of text characters.” Variables that end in a `%` symbol are whole numbers, while variables ending in a `$` symbol are strings of characters. All other variables are something called “floating point” variables. The manual warns you to be careful with variable names because only the first two letters of the name are actually recognized by the computer, even though nothing stops you from making a name as long as you want it to be. (This doesn’t particularly bother you, but you could see how 30 years from now this might strike someone as completely insane.) - -You then learn about the `IF... THEN...` and `FOR... NEXT...` constructs. With all these new tools, you feel equipped to tackle the next big challenge the manual throws at you. “If you’re the ambitious type,” it goads, “type in the following program and see what happens.” The program is longer and more complicated than any you have seen so far, but you’re dying to know what it does: - -``` -10 REM BOUNCING BALL -20 PRINT "{CLR/HOME}" -25 FOR X = 1 TO 10 : PRINT "{CRSR/DOWN}" : NEXT -30 FOR BL = 1 TO 40 -40 PRINT " ●{CRSR LEFT}";:REM (● is a Shift-Q) -50 FOR TM = 1 TO 5 -60 NEXT TM -70 NEXT BL -75 REM MOVE BALL RIGHT TO LEFT -80 FOR BL = 40 TO 1 STEP -1 -90 PRINT " {CRSR LEFT}{CRSR LEFT}●{CRSR LEFT}"; -100 FOR TM = 1 TO 5 -110 NEXT TM -120 NEXT BL -130 GOTO 20 -``` - -The program above takes advantage of one of the Commodore 64’s coolest features. Non-printable command characters, when passed to the `PRINT` command as part of a string, just do the action they usually perform instead of printing to the screen. This allows you to replay arbitrary chains of commands by printing strings from within your programs. - -It takes you a long time to type in the above program. You make several mistakes and have to re-enter some of the lines. But eventually you are able to type `RUN` and behold a masterpiece: - -![Commodore 64 bouncing ball][11] - -You think that this is a major contender for the coolest thing you have ever seen. You forget about it almost immediately though, because once you’ve learned about BASIC’s built-in functions like `RND` (which returns a random number) and `CHR$` (which returns the character matching a given number code), the manual shows you a program that many years from now will still be famous enough to be made the title of an [essay anthology][12]: - -``` -10 PRINT "{CLR/HOME}" -20 PRINT CHR$(205.5 + RND(1)); -40 GOTO 20 -``` - -When run, the above program produces a random maze: - -![Commodore 64 maze program][13] - -This is definitely the coolest thing you have ever seen. - -### PEEK and POKE - -You’ve now made it through the first four chapters of the Commodore 64 manual, including the chapter titled “Advanced BASIC,” so you’re feeling pretty proud of yourself. You’ve learned a lot this Saturday morning. But this afternoon (after a quick lunch break), you’re going to learn something that will make this magical machine in your living room much less mysterious. - -The next chapter in the manual is titled “Advanced Color and Graphic Commands.” It starts off by revisiting the colored bars that you were able to type out first thing this morning and shows you how you can do the same thing from a program. It then teaches you how to change the background colors of the screen. - -In order to do this, you need to use the BASIC `PEEK` and `POKE` commands. Those commands allow you to, respectively, examine and write to a memory address. The Commodore 64 has a main background color and a border color. Each is controlled by a specially designated memory address. You can write any color value you would like to those addresses to make the background or border that color. - -The manual explains: - -> Just as variables can be thought of as a representation of “boxes” within the machine where you placed your information, you can also think of some specially defined “boxes” within the computer that represent specific memory locations. -> -> The Commodore 64 looks at these memory locations to see what the screen’s background and border color should be, what characters are to be displayed on the screen—and where—and a host of other tasks. - -You write a program to cycle through all the available combinations of background and border color: - -``` -10 FOR BA = 0 TO 15 -20 FOR BO = 0 TO 15 -30 POKE 53280, BA -40 POKE 53281, BO -50 FOR X = 1 TO 500 : NEXT X -60 NEXT BO : NEXT BA -``` - -While the `POKE` commands, with their big operands, looked intimidating at first, now you see that the actual value of the number doesn’t matter that much. Obviously, you have to get the number right, but all the number represents is a “box” that Commodore just happened to store at address 53280. This box has a special purpose: Commodore uses it to determine what color the screen’s background should be. - -![Commodore 64 changing background colors][14] - -You think this is pretty neat. Just by writing to a special-purpose box in memory, you can control a fundamental property of the computer. You aren’t sure how the Commodore 64’s circuitry takes the value you write in memory and changes the color of the screen, but you’re okay not knowing that. At least you understand everything up to that point. - -### Special Boxes - -You don’t get through the entire manual that Saturday, since you are now starting to run out of steam. But you do eventually read all of it. In the process, you learn about many more of the Commodore 64’s special-purpose boxes. There are boxes you can write to control what is on screen—one box, in fact, for every place a character might appear. In chapter six, “Sprite Graphics,” you learn about the special-purpose boxes that allow you to define images that can be moved around and even scaled up and down. In chapter seven, “Creating Sound,” you learn about the boxes you can write to in order to make your Commodore 64 sing “Michael Row the Boat Ashore.” The Commodore 64, it turns out, has very little in the way of what you would later learn is called an API. Controlling the Commodore 64 mostly involves writing to memory addresses that have been given special meaning by the circuitry. - -The many years you ultimately spend writing to those special boxes stick with you. Even many decades later, when you find yourself programming a machine with an extensive graphics or sound API, you know that, behind the curtain, the API is ultimately writing to those boxes or something like them. You will sometimes wonder about younger programmers that have only ever used APIs, and wonder what they must think the API is doing for them. Maybe they think that the API is calling some other, hidden API. But then what do think that hidden API is calling? You will pity those younger programmers, because they must be very confused indeed. - -If you enjoyed this post, more like it come out every two weeks! Follow [@TwoBitHistory][15] on Twitter or subscribe to the [RSS feed][16] to make sure you know when a new post is out. - -Previously on TwoBitHistory… - -> Have you ever wondered what a 19th-century computer program would look like translated into C? -> -> This week's post: A detailed look at how Ada Lovelace's famous program worked and what it was trying to do. -> -> — TwoBitHistory (@TwoBitHistory) [August 19, 2018][17] - --------------------------------------------------------------------------------- - -via: https://twobithistory.org/2018/09/02/learning-basic.html - -作者:[Two-Bit History][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://twobithistory.org -[b]: https://github.com/lujun9972 -[1]: https://www.youtube.com/watch?v=kZRE7HIO3vk -[2]: https://en.wikipedia.org/wiki/BASIC_Computer_Games -[3]: https://www.youtube.com/watch?v=ZekAbt2o6Ms -[4]: https://www.npr.org/sections/money/2014/10/21/357629765/when-women-stopped-coding -[5]: https://www.youtube.com/watch?v=MA_XtT3VAVM -[6]: https://twobithistory.org/images/c64_startup.png -[7]: https://twobithistory.org/images/c64_error.png -[8]: ftp://www.zimmers.net/pub/cbm/c64/manuals/C64_Users_Guide.pdf -[9]: https://twobithistory.org/images/c64_colors.png -[10]: https://twobithistory.org/images/c64_print_loop.png -[11]: https://twobithistory.org/images/c64_ball.gif -[12]: http://10print.org/ -[13]: https://twobithistory.org/images/c64_maze.gif -[14]: https://twobithistory.org/images/c64_background.gif -[15]: https://twitter.com/TwoBitHistory -[16]: https://twobithistory.org/feed.xml -[17]: https://twitter.com/TwoBitHistory/status/1030974776821665793?ref_src=twsrc%5Etfw diff --git a/sources/tech/20180914 A day in the life of a log message.md b/sources/tech/20180914 A day in the life of a log message.md deleted file mode 100644 index 8d60ec9fe6..0000000000 --- a/sources/tech/20180914 A day in the life of a log message.md +++ /dev/null @@ -1,57 +0,0 @@ -A day in the life of a log message -====== - -Navigating a modern distributed system from the perspective of a log message. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/plane_travel_world_international.png?itok=jG3sYPty) - -Chaotic systems tend to be unpredictable. This is especially evident when architecting something as complex as a distributed system. Left unchecked, this unpredictability can waste boundless amounts of time. This is why every single component of a distributed system, no matter how small, must be designed to fit together in a streamlined way. - -[Kubernetes][1] provides a promising model for abstracting compute resources—but even it must be reconciled with other distributed platforms such as [Apache Kafka][2] to ensure reliable data delivery. If someone were to integrate these two platforms, how would it work? Furthermore, if you were to trace something as simple as a log message through such a system, what would it look like? This article will focus on how a log message from an application running inside [OKD][3], the Origin Community Distribution of Kubernetes that powers Red Hat OpenShift, gets to a data warehouse through Kafka. - -### OKD-defined environment - -Such a journey begins in OKD, since the container platform completely overlays the hardware it abstracts. This means that the log message waits to be written to **stdout** or **stderr** streams by an application residing in a container. From there, the log message is redirected onto the node's filesystem by a container engine such as [CRI-O][4]. - -![](https://opensource.com/sites/default/files/uploads/logmessagepathway.png) - -ithin OpenShift, one or more containers are encapsulated within virtual compute nodes known as pods. In fact, all applications running within OKD are abstracted as pods. This allows the applications to be manipulated in a uniform way. This also greatly simplifies communication between distributed components, since pods are systematically addressable through IP addresses and [load-balanced services][5] . So when the log message is taken from the node's filesystem by a log-collector application, it can easily be delivered to another pod running within OpenShift. - -### Two peas in a pod - -To ensure ubiquitous dispersal of the log message throughout the distributed system, the log collector needs to deliver the log message into a Kafka cluster data hub running within OpenShift. Through Kafka, the log message can be delivered to the consuming applications in a reliable and fault-tolerant way with low latency. However, in order to reap the benefits of Kafka within an OKD-defined environment, Kafka needs to be fully integrated into OKD. - -Running a [Strimzi operator][6] will instantiate all Kafka components as pods and integrate them to run within an OKD environment. This includes Kafka brokers for queuing log messages, Kafka connectors for reading and writing from Kafka brokers, and Zookeeper nodes for managing the Kafka cluster state. Strimzi can also instantiate the log collector to double as a Kafka connector, allowing the log collector to feed the log messages directly into a Kafka broker pod running within OKD. - -### Kafka inside OKD - -When the log-collector pod delivers the log message to a Kafka broker, the collector writes to a single broker partition, appending the message to the end of the partition. One of the advantages of using Kafka is that it decouples the log collector from the log's final destination. Thanks to the decoupling, the log collector doesn't care whether the logs end up in [Elasticsearch][7], Hadoop, Amazon S3, or all of them at the same time. Kafka is well-connected to all infrastructure, so the Kafka connectors can take the log message wherever it needs to go. - -Once written to a Kafka broker's partition, the log message is replicated across the broker partitions within the Kafka cluster. This is a very powerful concept on its own; combined with the self-healing features of the platform, it creates a very resilient distributed system. For example, when a node becomes unavailable, the applications running on the node are almost instantaneously spawned on healthy node(s). So even if a node with the Kafka broker is lost or damaged, the log message is guaranteed to survive as many deaths as it was replicated and a new Kafka broker will quickly take the original's place. - -### Off to storage - -After it is committed to a Kafka topic, the log message waits to be consumed by a Kafka connector sink, which relays the log message to either an analytics engine or logging warehouse. Upon delivery to its final destination, the log message could be studied for anomaly detection, queried for immediate root-cause analysis, or used for other purposes. Either way, the log message is delivered by Kafka to its destination in a safe and reliable manner. - -OKD and Kafka are powerful distributed platforms that are evolving rapidly. It is vital to create systems that can abstract the complicated nature of distributed computing without compromising performance. After all, how can we boast of systemwide efficiency if we cannot simplify the journey of a single log message? - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/9/life-log-message - -作者:[Josef Karásek][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/jkarasek -[1]: https://kubernetes.io/ -[2]: https://kafka.apache.org/ -[3]: https://www.okd.io/ -[4]: http://cri-o.io/ -[5]: https://kubernetes.io/docs/concepts/services-networking/service/ -[6]: http://strimzi.io/ -[7]: https://www.elastic.co/ diff --git a/sources/tech/20180924 5 ways to play old-school games on a Raspberry Pi.md b/sources/tech/20180924 5 ways to play old-school games on a Raspberry Pi.md deleted file mode 100644 index 539ac42082..0000000000 --- a/sources/tech/20180924 5 ways to play old-school games on a Raspberry Pi.md +++ /dev/null @@ -1,169 +0,0 @@ -5 ways to play old-school games on a Raspberry Pi -====== - -Relive the golden age of gaming with these open source platforms for Raspberry Pi. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/arcade_game_gaming.jpg?itok=84Rjk_32) - -They don't make 'em like they used to, do they? Video games, I mean. - -Sure, there's a bit more grunt in the gear now. Princess Zelda used to be 16 pixels in each direction; there's now enough graphics power for every hair on her head. Today's processors could beat up 1988's processors in a cage-fight deathmatch without breaking a sweat. - -But you know what's missing? The fun. - -You've got a squillion and one buttons to learn just to get past the tutorial mission. There's probably a storyline, too. You shouldn't need a backstory to kill bad guys. All you need is jump and shoot. So, it's little wonder that one of the most enduring popular uses for a Raspberry Pi is to relive the 8- and 16-bit golden age of gaming in the '80s and early '90s. But where to start? - -There are a few ways to play old-school games on the Pi. Each has its strengths and weaknesses, which I'll discuss here. - -### Retropie - -[Retropie][1] is probably the most popular retro-gaming platform for the Raspberry Pi. It's a solid all-rounder and a great default option for emulating classic desktop and console gaming systems. - -#### What is it? - -Retropie is built to run on [Raspbian][2]. It can also be installed over an existing Raspbian image if you'd prefer. It uses [EmulationStation][3] as a graphical front-end for a library of open source emulators, including the [Libretro][4] emulators. - -You don't need to understand a word of that to play your games, though. - -#### What's great about it - -It's very easy to get started. All you need to do is burn the image to an SD card, configure your controllers, copy your games over, and start killing bad guys. - -The huge user base means that there is a wealth of support and information out there, and active online communities to turn to for questions. - -In addition to the emulators that come installed with the Retropie image, there's a huge library of emulators you can install from the package manager, and it's growing all the time. Retropie also offers a user-friendly menu system to manage this, saving you time. - -From the Retropie menu, it's easy to add Kodi and the Raspbian desktop, which comes with the Chromium web browser. This means your retro-gaming rig is also good for home theatre, [YouTube][5], [SoundCloud][6], and all those other “lounge room computer” goodies. - -Retropie also has a number of other customization options: You can change the graphics in the menus, set up different control pad configurations for different emulators, make your Raspberry Pi file system visible to your local Windows network—all sorts of stuff. - -Retropie is built on Raspbian, which means you have the Raspberry Pi's most popular operating system to explore. Most Raspberry Pi projects and tutorials you find floating around are written for Raspbian, making it easy to customize and install new things on it. I've used my Retropie rig as a wireless bridge, installed MIDI synthesizers on it, taught myself a bit of Python, and more—all without compromising its use as a gaming machine. - -#### What's not so great about it - -Retropie's simple installation and ease of use is, in a way, a double-edged sword. You can go for a long time with Retropie without ever learning simple stuff like `sudo apt-get`, which means you're missing out on a lot of the Raspberry Pi experience. - -It doesn't have to be this way; the command line is still there under the hood when you want it, but perhaps users are a bit too insulated from a Bash shell that's ultimately a lot less scary than it looks. Retropie's main menu is operable only with a control pad, which can be annoying when you don't have one plugged in because you've been using the system for things other than gaming. - -#### Who's it for? - -Anyone who wants to get straight into some gaming, anyone who wants the biggest and best library of emulators, and anyone who wants a great way to start exploring Linux when they're not playing games. - -### Recalbox - -[Recalbox][7] is a newer open source suite of emulators for the Raspberry Pi. It also supports other ARM-based small-board computers. - -#### What is it? - -Like Retropie, Recalbox is built on EmulationStation and Libretro. Where it differs is that it's not built on Raspbian, but on its own flavor of Linux: RecalboxOS. - -#### What's great about it - -The setup for Recalbox is even easier than for Retropie. You don't even need to image an SD card; simply copy some files over and go. It also has out-of-the-box support for some game controllers, getting you to Level 1 that little bit faster. Kodi comes preinstalled. This is a ready-to-go gaming and media rig. - -#### What's not so great about it - -Recalbox has fewer emulators than Retropie, fewer customization options, and a smaller user community. - -Your Recalbox rig is probably always just going to be for emulators and Kodi, the same as when you installed it. If you feel like getting deeper into Linux, you'll probably want a new SD card for Raspbian. - -#### Who's it for? - -Recalbox is great if you want the absolute easiest retro gaming experience and can happily go without some of the more obscure gaming platforms, or if you are intimidated by the idea of doing anything a bit technical (and have no interest in growing out of that). - -For most opensource.com readers, Recalbox will probably come in most handy to recommend to your not-so-technical friend or relative. Its super-simple setup and overall lack of options might even help you avoid having to help them with it. - -### Roll your own - -Ok, if you've been paying attention, you might have noticed that both Retropie and Recalbox are built from many of the same open source components. So what's to stop you from putting them together yourself? - -#### What is it? - -Whatever you want it to be, baby. The nature of open source software means you could use an existing emulator suite as a starting point, or pilfer from them at will. - -#### What's great about it - -If you have your own custom interface in mind, I guess there's nothing to do but roll your sleeves up and get to it. This is also a way to install emulators that haven't quite found their way into Retropie yet, such as [BeebEm][8] or [ArcEm][9]. - -#### What's not so great about it - -Well, it's a bit of work, isn't it? - -#### Who's it for? - -Hackers, tinkerers, builders, seasoned hobbyists, and such. - -### Native RISC OS gaming - -Now here's a dark horse: [RISC OS][10], the original operating system for ARM devices. - -#### What is it? - -Before ARM went on to become the world's most popular CPU architecture, it was originally built to be the heart of the Acorn Archimedes. That's kind of a forgotten beast nowadays, but for a few years it was light years ahead as the most powerful desktop computer in the world, and it attracted a lot of games development. - -Because the ARM processor in the Pi is the great-grandchild of the one in the Archimedes, we can still install RISC OS on it, and with a little bit of work, get these games running. This is different to the emulator options we've covered so far because we're playing our games on the operating system and CPU architecture for which they were written. - -#### What's great about it - -It's the perfect introduction to RISC OS. This is an absolute gem of an operating system and well worth checking out in its own right. - -The fact that you're using much the same operating system as back in the day to load and play your games makes your retro gaming rig just that little bit more of a time machine. This definitely adds some charm and retro value to the project. - -There are a few superb games that were released only on the Archimedes. The massive hardware advantage of the Archimedes also means that it often had the best graphics and smoothest gameplay of a lot of multi-platform titles. The rights holders to many of these games have been generous enough to make them legally available for free download. - -#### What's not so great about it - -Once you have installed RISC OS, it still takes a bit of elbow grease to get the games working. Here's a [guide to getting started][11]. - -This is definitely not a great all-rounder for the lounge room. There's nothing like [Kodi][12]. There's a web browser, [NetSurf][13], but it's struggling to catch up to the modern web. You won't get the range of titles to play as you would with an emulator suite. RISC OS Open is free for hobbyists to download and use and much of the source code has been made open. But despite the name, it's not a 100% open source operating system. - -#### Who's it for? - -This one's for novelty seekers, absolute retro heads, people who want to explore an interesting operating system from the '80s, people who are nostalgic for Acorn machines from back in the day, and people who want a totally different retro gaming project. - -### Command line gaming - -Do you really need to install an emulator or an exotic operating system just to relive the glory days? Why not just install some native linux games from the command line? - -#### What is it? - -There's a whole range of native Linux games tested to work on the [Raspberry Pi][14]. - -#### What's great about it - -You can install most of these from packages using the command line and start playing. Easy. If you've already got Raspbian up and running, it's probably your fastest path to getting a game running. - -#### What's not so great about it - -This isn't, strictly speaking, actual retro gaming. Linux was born in 1991 and took a while longer to come together as a gaming platform. This isn't quite gaming from the classic 8- and 16-bit era; these are ports and retro-influenced games that were built later. - -#### Who's it for? - -If you're just after a bucket of fun, no problem. But if you're trying to relive the actual era, this isn't quite it. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/9/retro-gaming-raspberry-pi - -作者:[James Mawson][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/dxmjames -[1]: https://retropie.org.uk/ -[2]: https://www.raspbian.org/ -[3]: https://emulationstation.org/ -[4]: https://www.libretro.com/ -[5]: https://www.youtube.com/ -[6]: https://soundcloud.com/ -[7]: https://www.recalbox.com/ -[8]: http://www.mkw.me.uk/beebem/ -[9]: http://arcem.sourceforge.net/ -[10]: https://opensource.com/article/18/7/gentle-intro-risc-os -[11]: https://blog.dxmtechsupport.com.au/playing-badass-acorn-archimedes-games-on-a-raspberry-pi/ -[12]: https://kodi.tv/ -[13]: https://www.netsurf-browser.org/ -[14]: https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 diff --git a/sources/tech/20180928 Quiet log noise with Python and machine learning.md b/sources/tech/20180928 Quiet log noise with Python and machine learning.md deleted file mode 100644 index f1fe2f1b7f..0000000000 --- a/sources/tech/20180928 Quiet log noise with Python and machine learning.md +++ /dev/null @@ -1,110 +0,0 @@ -Quiet log noise with Python and machine learning -====== - -Logreduce saves debugging time by picking out anomalies from mountains of log data. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/sound-radio-noise-communication.png?itok=KMNn9QrZ) - -Continuous integration (CI) jobs can generate massive volumes of data. When a job fails, figuring out what went wrong can be a tedious process that involves investigating logs to discover the root cause—which is often found in a fraction of the total job output. To make it easier to separate the most relevant data from the rest, the [Logreduce][1] machine learning model is trained using previous successful job runs to extract anomalies from failed runs' logs. - -This principle can also be applied to other use cases, for example, extracting anomalies from [Journald][2] or other systemwide regular log files. - -### Using machine learning to reduce noise - -A typical log file contains many nominal events ("baselines") along with a few exceptions that are relevant to the developer. Baselines may contain random elements such as timestamps or unique identifiers that are difficult to detect and remove. To remove the baseline events, we can use a [k-nearest neighbors pattern recognition algorithm][3] (k-NN). - -![](https://opensource.com/sites/default/files/uploads/ml-generic-workflow.png) - -Log events must be converted to numeric values for k-NN regression. Using the generic feature extraction tool [HashingVectorizer][4] enables the process to be applied to any type of log. It hashes each word and encodes each event in a sparse matrix. To further reduce the search space, tokenization removes known random words, such as dates or IP addresses. - -![](https://opensource.com/sites/default/files/uploads/hashing-vectorizer.png) - -Once the model is trained, the k-NN search tells us the distance of each new event from the baseline. - -![](https://opensource.com/sites/default/files/uploads/kneighbors.png) - -This [Jupyter notebook][5] demonstrates the process and graphs the sparse matrix vectors. - -![](https://opensource.com/sites/default/files/uploads/anomaly-detection-with-scikit-learn.png) - -### Introducing Logreduce - -The Logreduce Python software transparently implements this process. Logreduce's initial goal was to assist with [Zuul CI][6] job failure analyses using the build database, and it is now integrated into the [Software Factory][7] development forge's job logs process. - -At its simplest, Logreduce compares files or directories and removes lines that are similar. Logreduce builds a model for each source file and outputs any of the target's lines whose distances are above a defined threshold by using the following syntax: **distance | filename:line-number: line-content**. - -``` -$ logreduce diff /var/log/audit/audit.log.1 /var/log/audit/audit.log -INFO  logreduce.Classifier - Training took 21.982s at 0.364MB/s (1.314kl/s) (8.000 MB - 28.884 kilo-lines) -0.244 | audit.log:19963:        type=USER_AUTH acct="root" exe="/usr/bin/su" hostname=managesf.sftests.com -INFO  logreduce.Classifier - Testing took 18.297s at 0.306MB/s (1.094kl/s) (5.607 MB - 20.015 kilo-lines) -99.99% reduction (from 20015 lines to 1 - -``` - -A more advanced Logreduce use can train a model offline to be reused. Many variants of the baselines can be used to fit the k-NN search tree. - -``` -$ logreduce dir-train audit.clf /var/log/audit/audit.log.* -INFO  logreduce.Classifier - Training took 80.883s at 0.396MB/s (1.397kl/s) (32.001 MB - 112.977 kilo-lines) -DEBUG logreduce.Classifier - audit.clf: written -$ logreduce dir-run audit.clf /var/log/audit/audit.log -``` - -Logreduce also implements interfaces to discover baselines for Journald time ranges (days/weeks/months) and Zuul CI job build histories. It can also generate HTML reports that group anomalies found in multiple files in a simple interface. - -![](https://opensource.com/sites/default/files/uploads/html-report.png) - -### Managing baselines - -The key to using k-NN regression for anomaly detection is to have a database of known good baselines, which the model uses to detect lines that deviate too far. This method relies on the baselines containing all nominal events, as anything that isn't found in the baseline will be reported as anomalous. - -CI jobs are great targets for k-NN regression because the job outputs are often deterministic and previous runs can be automatically used as baselines. Logreduce features Zuul job roles that can be used as part of a failed job post task in order to issue a concise report (instead of the full job's logs). This principle can be applied to other cases, as long as baselines can be constructed in advance. For example, a nominal system's [SoS report][8] can be used to find issues in a defective deployment. - -![](https://opensource.com/sites/default/files/uploads/baselines.png) - -### Anomaly classification service - -The next version of Logreduce introduces a server mode to offload log processing to an external service where reports can be further analyzed. It also supports importing existing reports and requests to analyze a Zuul build. The services run analyses asynchronously and feature a web interface to adjust scores and remove false positives. - -![](https://opensource.com/sites/default/files/uploads/classification-interface.png) - -Reviewed reports can be archived as a standalone dataset with the target log files and the scores for anomalous lines recorded in a flat JSON file. - -### Project roadmap - -Logreduce is already being used effectively, but there are many opportunities for improving the tool. Plans for the future include: - - * Curating many annotated anomalies found in log files and producing a public domain dataset to enable further research. Anomaly detection in log files is a challenging topic, and having a common dataset to test new models would help identify new solutions. - * Reusing the annotated anomalies with the model to refine the distances reported. For example, when users mark lines as false positives by setting their distance to zero, the model could reduce the score of those lines in future reports. - * Fingerprinting archived anomalies to detect when a new report contains an already known anomaly. Thus, instead of reporting the anomaly's content, the service could notify the user that the job hit a known issue. When the issue is fixed, the service could automatically restart the job. - * Supporting more baseline discovery interfaces for targets such as SOS reports, Jenkins builds, Travis CI, and more. - - - -If you are interested in getting involved in this project, please contact us on the **#log-classify** Freenode IRC channel. Feedback is always appreciated! - -Tristan Cacqueray will present [Reduce your log noise using machine learning][9] at the [OpenStack Summit][10], November 13-15 in Berlin. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/9/quiet-log-noise-python-and-machine-learning - -作者:[Tristan de Cacqueray][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/tristanc -[1]: https://pypi.org/project/logreduce/ -[2]: http://man7.org/linux/man-pages/man8/systemd-journald.service.8.html -[3]: https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm -[4]: http://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.HashingVectorizer.html -[5]: https://github.com/TristanCacqueray/anomaly-detection-workshop-opendev/blob/master/datasets/notebook/anomaly-detection-with-scikit-learn.ipynb -[6]: https://zuul-ci.org -[7]: https://www.softwarefactory-project.io -[8]: https://sos.readthedocs.io/en/latest/ -[9]: https://www.openstack.org/summit/berlin-2018/summit-schedule/speakers/4307 -[10]: https://www.openstack.org/summit/berlin-2018/ diff --git a/sources/tech/20181011 Exploring the Linux kernel- The secrets of Kconfig-kbuild.md b/sources/tech/20181011 Exploring the Linux kernel- The secrets of Kconfig-kbuild.md deleted file mode 100644 index 2fd085eda0..0000000000 --- a/sources/tech/20181011 Exploring the Linux kernel- The secrets of Kconfig-kbuild.md +++ /dev/null @@ -1,259 +0,0 @@ -Translating by Jamskr - -Exploring the Linux kernel: The secrets of Kconfig/kbuild -====== -Dive into understanding how the Linux config/build system works. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/compass_map_explore_adventure.jpg?itok=ecCoVTrZ) - -The Linux kernel config/build system, also known as Kconfig/kbuild, has been around for a long time, ever since the Linux kernel code migrated to Git. As supporting infrastructure, however, it is seldom in the spotlight; even kernel developers who use it in their daily work never really think about it. - -To explore how the Linux kernel is compiled, this article will dive into the Kconfig/kbuild internal process, explain how the .config file and the vmlinux/bzImage files are produced, and introduce a smart trick for dependency tracking. - -### Kconfig - -The first step in building a kernel is always configuration. Kconfig helps make the Linux kernel highly modular and customizable. Kconfig offers the user many config targets: -| config | Update current config utilizing a line-oriented program | -| nconfig | Update current config utilizing a ncurses menu-based program | -| menuconfig | Update current config utilizing a menu-based program | -| xconfig | Update current config utilizing a Qt-based frontend | -| gconfig | Update current config utilizing a GTK+ based frontend | -| oldconfig | Update current config utilizing a provided .config as base | -| localmodconfig | Update current config disabling modules not loaded | -| localyesconfig | Update current config converting local mods to core | -| defconfig | New config with default from Arch-supplied defconfig | -| savedefconfig | Save current config as ./defconfig (minimal config) | -| allnoconfig | New config where all options are answered with 'no' | -| allyesconfig | New config where all options are accepted with 'yes' | -| allmodconfig | New config selecting modules when possible | -| alldefconfig | New config with all symbols set to default | -| randconfig | New config with a random answer to all options | -| listnewconfig | List new options | -| olddefconfig | Same as oldconfig but sets new symbols to their default value without prompting | -| kvmconfig | Enable additional options for KVM guest kernel support | -| xenconfig | Enable additional options for xen dom0 and guest kernel support | -| tinyconfig | Configure the tiniest possible kernel | - -I think **menuconfig** is the most popular of these targets. The targets are processed by different host programs, which are provided by the kernel and built during kernel building. Some targets have a GUI (for the user's convenience) while most don't. Kconfig-related tools and source code reside mainly under **scripts/kconfig/** in the kernel source. As we can see from **scripts/kconfig/Makefile** , there are several host programs, including **conf** , **mconf** , and **nconf**. Except for **conf** , each of them is responsible for one of the GUI-based config targets, so, **conf** deals with most of them. - -Logically, Kconfig's infrastructure has two parts: one implements a [new language][1] to define the configuration items (see the Kconfig files under the kernel source), and the other parses the Kconfig language and deals with configuration actions. - -Most of the config targets have roughly the same internal process (shown below): - -![](https://opensource.com/sites/default/files/uploads/kconfig_process.png) - -Note that all configuration items have a default value. - -The first step reads the Kconfig file under source root to construct an initial configuration database; then it updates the initial database by reading an existing configuration file according to this priority: - -> .config -> /lib/modules/$(shell,uname -r)/.config -> /etc/kernel-config -> /boot/config-$(shell,uname -r) -> ARCH_DEFCONFIG -> arch/$(ARCH)/defconfig - -If you are doing GUI-based configuration via **menuconfig** or command-line-based configuration via **oldconfig** , the database is updated according to your customization. Finally, the configuration database is dumped into the .config file. - -But the .config file is not the final fodder for kernel building; this is why the **syncconfig** target exists. **syncconfig** used to be a config target called **silentoldconfig** , but it doesn't do what the old name says, so it was renamed. Also, because it is for internal use (not for users), it was dropped from the list. - -Here is an illustration of what **syncconfig** does: - -![](https://opensource.com/sites/default/files/uploads/syncconfig.png) - -**syncconfig** takes .config as input and outputs many other files, which fall into three categories: - - * **auto.conf & tristate.conf** are used for makefile text processing. For example, you may see statements like this in a component's makefile: - -``` - obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o -``` - - * **autoconf.h** is used in C-language source files. - - * Empty header files under **include/config/** are used for configuration-dependency tracking during kbuild, which is explained below. - - - - -After configuration, we will know which files and code pieces are not compiled. - -### kbuild - -Component-wise building, called _recursive make_ , is a common way for GNU `make` to manage a large project. Kbuild is a good example of recursive make. By dividing source files into different modules/components, each component is managed by its own makefile. When you start building, a top makefile invokes each component's makefile in the proper order, builds the components, and collects them into the final executive. - -Kbuild refers to different kinds of makefiles: - - * **Makefile** is the top makefile located in source root. - * **.config** is the kernel configuration file. - * **arch/$(ARCH)/Makefile** is the arch makefile, which is the supplement to the top makefile. - * **scripts/Makefile.*** describes common rules for all kbuild makefiles. - * Finally, there are about 500 **kbuild makefiles**. - - - -The top makefile includes the arch makefile, reads the .config file, descends into subdirectories, invokes **make** on each component's makefile with the help of routines defined in **scripts/Makefile.*** , builds up each intermediate object, and links all the intermediate objects into vmlinux. Kernel document [Documentation/kbuild/makefiles.txt][2] describes all aspects of these makefiles. - -As an example, let's look at how vmlinux is produced on x86-64: - -![vmlinux overview][4] - -(The illustration is based on Richard Y. Steven's [blog][5]. It was updated and is used with the author's permission.) - -All the **.o** files that go into vmlinux first go into their own **built-in.a** , which is indicated via variables **KBUILD_VMLINUX_INIT** , **KBUILD_VMLINUX_MAIN** , **KBUILD_VMLINUX_LIBS** , then are collected into the vmlinux file. - -Take a look at how recursive make is implemented in the Linux kernel, with the help of simplified makefile code: - -``` - # In top Makefile - vmlinux: scripts/link-vmlinux.sh $(vmlinux-deps) -                 +$(call if_changed,link-vmlinux) - - # Variable assignments - vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) - - export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) - export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt-y) - export KBUILD_VMLINUX_LIBS := $(libs-y1) - export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds - - init-y          := init/ - drivers-y       := drivers/ sound/ firmware/ - net-y           := net/ - libs-y          := lib/ - core-y          := usr/ - virt-y          := virt/ - - # Transform to corresponding built-in.a - init-y          := $(patsubst %/, %/built-in.a, $(init-y)) - core-y          := $(patsubst %/, %/built-in.a, $(core-y)) - drivers-y       := $(patsubst %/, %/built-in.a, $(drivers-y)) - net-y           := $(patsubst %/, %/built-in.a, $(net-y)) - libs-y1         := $(patsubst %/, %/lib.a, $(libs-y)) - libs-y2         := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y))) - virt-y          := $(patsubst %/, %/built-in.a, $(virt-y)) - - # Setup the dependency. vmlinux-deps are all intermediate objects, vmlinux-dirs - # are phony targets, so every time comes to this rule, the recipe of vmlinux-dirs - # will be executed. Refer "4.6 Phony Targets" of `info make` - $(sort $(vmlinux-deps)): $(vmlinux-dirs) ; - - # Variable vmlinux-dirs is the directory part of each built-in.a - vmlinux-dirs    := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ -                      $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ -                      $(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y))) - - # The entry of recursive make - $(vmlinux-dirs): -                 $(Q)$(MAKE) $(build)=$@ need-builtin=1 -``` - -The recursive make recipe is expanded, for example: - -``` - make -f scripts/Makefile.build obj=init need-builtin=1 -``` - -This means **make** will go into **scripts/Makefile.build** to continue the work of building each **built-in.a**. With the help of **scripts/link-vmlinux.sh** , the vmlinux file is finally under source root. - -#### Understanding vmlinux vs. bzImage - -Many Linux kernel developers may not be clear about the relationship between vmlinux and bzImage. For example, here is their relationship in x86-64: - -![](https://opensource.com/sites/default/files/uploads/vmlinux-bzimage.png) - -The source root vmlinux is stripped, compressed, put into **piggy.S** , then linked with other peer objects into **arch/x86/boot/compressed/vmlinux**. Meanwhile, a file called setup.bin is produced under **arch/x86/boot**. There may be an optional third file that has relocation info, depending on the configuration of **CONFIG_X86_NEED_RELOCS**. - -A host program called **build** , provided by the kernel, builds these two (or three) parts into the final bzImage file. - -#### Dependency tracking - -Kbuild tracks three kinds of dependencies: - - 1. All prerequisite files (both * **.c** and * **.h** ) - 2. **CONFIG_** options used in all prerequisite files - 3. Command-line dependencies used to compile the target - - - -The first one is easy to understand, but what about the second and third? Kernel developers often see code pieces like this: - -``` - #ifdef CONFIG_SMP - __boot_cpu_id = cpu; - #endif -``` - -When **CONFIG_SMP** changes, this piece of code should be recompiled. The command line for compiling a source file also matters, because different command lines may result in different object files. - -When a **.c** file uses a header file via a **#include** directive, you need write a rule like this: - -``` - main.o: defs.h -         recipe... -``` - -When managing a large project, you need a lot of these kinds of rules; writing them all would be tedious and boring. Fortunately, most modern C compilers can write these rules for you by looking at the **#include** lines in the source file. For the GNU Compiler Collection (GCC), it is just a matter of adding a command-line parameter: **-MD depfile** - -``` - # In scripts/Makefile.lib - c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \ -                  -include $(srctree)/include/linux/compiler_types.h       \ -                  $(__c_flags) $(modkern_cflags)                           \ -                  $(basename_flags) $(modname_flags) -``` - -This would generate a **.d** file with content like: - -``` - init_task.o: init/init_task.c include/linux/kconfig.h \ -  include/generated/autoconf.h include/linux/init_task.h \ -  include/linux/rcupdate.h include/linux/types.h \ -  ... -``` - -Then the host program **[fixdep][6]** takes care of the other two dependencies by taking the **depfile** and command line as input, then outputting a **. .cmd** file in makefile syntax, which records the command line and all the prerequisites (including the configuration) for a target. It looks like this: - -``` - # The command line used to compile the target - cmd_init/init_task.o := gcc -Wp,-MD,init/.init_task.o.d  -nostdinc ... - ... - # The dependency files - deps_init/init_task.o := \ - $(wildcard include/config/posix/timers.h) \ - $(wildcard include/config/arch/task/struct/on/stack.h) \ - $(wildcard include/config/thread/info/in/task.h) \ - ... -   include/uapi/linux/types.h \ -   arch/x86/include/uapi/asm/types.h \ -   include/uapi/asm-generic/types.h \ -   ... -``` - -A **. .cmd** file will be included during recursive make, providing all the dependency info and helping to decide whether to rebuild a target or not. - -The secret behind this is that **fixdep** will parse the **depfile** ( **.d** file), then parse all the dependency files inside, search the text for all the **CONFIG_** strings, convert them to the corresponding empty header file, and add them to the target's prerequisites. Every time the configuration changes, the corresponding empty header file will be updated, too, so kbuild can detect that change and rebuild the target that depends on it. Because the command line is also recorded, it is easy to compare the last and current compiling parameters. - -### Looking ahead - -Kconfig/kbuild remained the same for a long time until the new maintainer, Masahiro Yamada, joined in early 2017, and now kbuild is under active development again. Don't be surprised if you soon see something different from what's in this article. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/10/kbuild-and-kconfig - -作者:[Cao Jin][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/pinocchio -[b]: https://github.com/lujun9972 -[1]: https://github.com/torvalds/linux/blob/master/Documentation/kbuild/kconfig-language.txt -[2]: https://www.mjmwired.net/kernel/Documentation/kbuild/makefiles.txt -[3]: https://opensource.com/file/411516 -[4]: https://opensource.com/sites/default/files/uploads/vmlinux_generation_process.png (vmlinux overview) -[5]: https://blog.csdn.net/richardysteven/article/details/52502734 -[6]: https://github.com/torvalds/linux/blob/master/scripts/basic/fixdep.c diff --git a/sources/tech/20181011 The First Beta of Haiku is Released After 16 Years of Development.md b/sources/tech/20181011 The First Beta of Haiku is Released After 16 Years of Development.md deleted file mode 100644 index b6daaef053..0000000000 --- a/sources/tech/20181011 The First Beta of Haiku is Released After 16 Years of Development.md +++ /dev/null @@ -1,87 +0,0 @@ -The First Beta of Haiku is Released After 16 Years of Development -====== -There are a number of small operating systems out there that are designed to replicate the past. Haiku is one of those. We will look to see where Haiku came from and what the new release has to offer. - -![Haiku OS desktop screenshot][1]Haiku desktop - -### What is Haiku? - -Haiku’s history begins with the now defunct [Be Inc][2]. Be Inc was founded by former Apple executive [Jean-Louis Gassée][3] after he was ousted by CEO [John Sculley][4]. Gassée wanted to create a new operating system from the ground up. BeOS was created with digital media work in mind and was designed to take advantage of the most modern hardware of the time. Originally, Be Inc attempted to create their own platform encompassing both hardware and software. The result was called the [BeBox][5]. After BeBox failed to sell well, Be turned their attention to BeOS. - -In the 1990s, Apple was looking for a new operating system to replace the aging Classic Mac OS. The two contenders were Gassée’s BeOS and Steve Jobs’ NeXTSTEP. In the end, Apple went with NeXTSTEP. Be tried to license BeOS to hardware makers, but [in at least one case][6] Microsoft threatened to revoke a manufacturer’s Windows license if they sold BeOS machines. Eventually, Be Inc was sold to Palm in 2001 for $11 million. BeOS was subsequently discontinued. - -Following the news of Palm’s purchase, a number of loyal fans decided they wanted to keep the operating system alive. The original name of the project was OpenBeOS, but was changed to Haiku to avoid infringing on Palm’s trademarks. The name is a reference to reference to the [haikus][7] used as error messages by many of the applications. Haiku is completely written from scratch and is compatible with BeOS. - -### Why Haiku? - -According to the project’s website, [Haiku][8] “is a fast, efficient, simple to use, easy to learn, and yet very powerful system for computer users of all levels”. Haiku comes with a kernel that have been customized for performance. Like FreeBSD, there is a “single team writing everything from the kernel, drivers, userland services, toolkit, and graphics stack to the included desktop applications and preflets”. - -### New Features in Haiku Beta Release - -A number of new features have been introduced since the release of Alpha 4.1. (Please note that Haiku is a passion project and all the devs are part-time, so some they can’t spend as much time working on Haiku as they would like.) - -![Haiku OS software][9] -HaikuDepot, Haiku’s package manager - -One of the biggest features is the inclusion of a complete package management system. HaikuDepot allows you to sort through many applications. Many are built specifically for Haiku, but a number have been ported to the platform, such as [LibreOffice][10], [Otter Browser][11], and [Calligra][12]. Interestingly, each Haiku package is [“a special type of compressed filesystem image, which is ‘mounted’ upon installation”][13]. There is also a command line interface for package management named `pkgman`. - -Another big feature is an upgraded browser. Haiku was able to hire a developer to work full-time for a year to improve the performance of WebPositive, the built-in browser. This included an update to a newer version of WebKit. WebPositive will now play Youtube videos properly. - -![Haiku OS WebPositive browser][14] -WebPositive, Haiku’s built-in browser - -Other features include: - - * A completely rewritten network preflet - * User interface cleanup - * Media subsystem improvements, including better streaming support, HDA driver improvements, and FFmpeg decoder plugin improvements - * Native RemoteDesktop improved - * Add EFI bootloader and GPT support - * Updated Ethernet & WiFi drivers - * Updated filesystem drivers - * General system stabilization - * Experimental Bluetooth stack - - - -### Thoughts on Haiku OS - -I have been following Haiku for many years. I’ve installed and played with the nightly builds a dozen times over the last couple of years. I even took some time to start learning one of its programming languages, so that I could write apps. But I got busy with other things. - -I’m very conflicted about it. I like Haiku because it is a neat non-Linux project, but it is only just getting features that everyone else takes for granted, like a package manager. - -If you’ve got a couple of minutes, download the [ISO][15] and install it on the virtual machine of your choice. You just might like it. - -Have you ever used Haiku or BeOS? If so, what are your favorite features? Let us know in the comments below. - -If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][16]. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/haiku-os-release/ - -作者:[John Paul][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/john/ -[b]: https://github.com/lujun9972 -[1]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/10/haiku.jpg -[2]: https://en.wikipedia.org/wiki/Be_Inc. -[3]: https://en.wikipedia.org/wiki/Jean-Louis_Gass%C3%A9e -[4]: https://en.wikipedia.org/wiki/John_Sculley -[5]: https://en.wikipedia.org/wiki/BeBox -[6]: https://birdhouse.org/beos/byte/30-bootloader/ -[7]: https://en.wikipedia.org/wiki/Haiku -[8]: https://www.haiku-os.org/about/ -[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/10/haiku-depot.png -[10]: https://www.libreoffice.org/ -[11]: https://itsfoss.com/otter-browser-review/ -[12]: https://www.calligra.org/ -[13]: https://www.haiku-os.org/get-haiku/release-notes/ -[14]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/10/webpositive.jpg -[15]: https://www.haiku-os.org/get-haiku -[16]: http://reddit.com/r/linuxusersgroup diff --git a/sources/tech/20181029 Create animated, scalable vector graphic images with MacSVG.md b/sources/tech/20181029 Create animated, scalable vector graphic images with MacSVG.md deleted file mode 100644 index df990db3bc..0000000000 --- a/sources/tech/20181029 Create animated, scalable vector graphic images with MacSVG.md +++ /dev/null @@ -1,69 +0,0 @@ -Create animated, scalable vector graphic images with MacSVG -====== - -Open source SVG: The writing is on the wall - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/open_design_paper_plane_2_0.jpg?itok=xKdP-GWE) - -The Neo-Babylonian regent [Belshazzar][1] did not heed [the writing on the wall][2] that magically appeared during his great feast. However, if he had had a laptop and a good internet connection in 539 BC, he might have staved off those pesky Persians by reading the SVG on the browser. - -Animating text and objects on web pages is a great way to build user interest and engagement. There are several ways to achieve this, such as a video embed, an animated GIF, or a slideshow—but you can also use [scalable vector graphics][3] (SVG). - -An SVG image is different from, say, a JPG, because it is scalable without losing its resolution. A vector image is created by points, not dots, so no matter how large it gets, it will not lose its resolution or pixelate. An example of a good use of scalable, static images would be logos on websites. - -### Move it, move it - -You can create SVG images with several drawing programs, including open source [Inkscape][4] and Adobe Illustrator. Getting your images to “do something” requires a bit more effort. Fortunately, there are open source solutions that would get even Belshazzar’s attention. - -[MacSVG][5] is one tool that will get your images moving. You can find the source code on [GitHub][6]. - -Developed by Douglas Ward of Conway, Arkansas, MacSVG is an “open source Mac OS app for designing HTML5 SVG art and animation,” according to its [website][5]. - -I was interested in using MacSVG to create an animated signature. I admit that I found the process a bit confusing and failed at my first attempts to create an actual animated SVG image. - -![](https://opensource.com/sites/default/files/uploads/macsvg-screen.png) - -It is important to first learn what makes “the writing on the wall” actually write. - -The attribute behind the animated writing is [stroke-dasharray][7]. Breaking the term into three words helps explain what is happening: Stroke refers to the line or stroke you would make with a pen, whether physical or digital. Dash means breaking the stroke down into a series of dashes. Array means producing the whole thing into an array. That’s a simple overview, but it helped me understand what was supposed to happen and why. - -With MacSVG, you can import a graphic (.PNG) and use the pen tool to trace the path of the writing. I used a cursive representation of my first name. Then it was just a matter of applying the attributes to animate the writing, increase and decrease the thickness of the stroke, change its color, and so on. Once completed, the animated writing was exported as an .SVG file and was ready for use on the web. MacSVG can be used for many different types of SVG animation in addition to handwriting. - -### The writing is on the WordPress - -I was ready to upload and share my SVG example on my [WordPress][8] site, but I discovered that WordPress does not allow for SVG media imports. Fortunately, I found a handy plugin: Benbodhi’s [SVG Support][9] allowed a quick, easy import of my SVG the same way I would import a JPG to my Media Library. I was able to showcase my [writing on the wall][10] to Babylonians everywhere. - -I opened the source code of my SVG in [Brackets][11], and here are the results: - -``` - - -Path animation with stroke-dasharrayThis example demonstrates the use of a path element, an animate element, and the stroke-dasharray attribute to simulate drawing. -``` - -What would you use MacSVG for? - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/10/macsvg-open-source-tool-animation - -作者:[Jeff Macharyas][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/rikki-endsley -[b]: https://github.com/lujun9972 -[1]: https://en.wikipedia.org/wiki/Belshazzar -[2]: https://en.wikipedia.org/wiki/Belshazzar%27s_feast -[3]: https://en.wikipedia.org/wiki/Scalable_Vector_Graphics -[4]: https://inkscape.org/ -[5]: https://macsvg.org/ -[6]: https://github.com/dsward2/macSVG -[7]: https://gist.github.com/mbostock/5649592 -[8]: https://macharyas.com/ -[9]: https://wordpress.org/plugins/svg-support/ -[10]: https://macharyas.com/index.php/2018/10/14/open-source-svg/ -[11]: http://brackets.io/ diff --git a/sources/tech/20181029 DF-SHOW - A Terminal File Manager Based On An Old DOS Application.md b/sources/tech/20181029 DF-SHOW - A Terminal File Manager Based On An Old DOS Application.md deleted file mode 100644 index f250cca056..0000000000 --- a/sources/tech/20181029 DF-SHOW - A Terminal File Manager Based On An Old DOS Application.md +++ /dev/null @@ -1,162 +0,0 @@ -DF-SHOW – A Terminal File Manager Based On An Old DOS Application -====== -![](https://www.ostechnix.com/wp-content/uploads/2018/10/dfshow-720x340.png) - -If you have worked on good-old MS-DOS, you might have used or heard about **DF-EDIT**. The DF-EDIT, stands for **D** irectory **F** ile **Edit** or, is an obscure DOS file manager, originally written by **Larry Kroeker** for MS-DOS and PC-DOS systems. It is used to display the contents of a given directory or file in MS-DOS and PC-DOS systems. Today, I stumbled upon a similar utility named **DF-SHOW** ( **D** irectory **F** ile **S** how), a terminal file manager for Unix-like operating systems. It is an Unix rewrite of obscure DF-EDIT file manager and is based on DF-EDIT 2.3d release from 1986. DF-SHOW is completely free, open source and released under GPLv3. - -DF-SHOW can be able to, - - * List contents of a directory, - * View files, - * Edit files using your default file editor, - * Copy files to/from different locations, - * Rename files, - * Delete files, - * Create new directories from within the DF-SHOW interface, - * Update file permissions, owners and groups, - * Search files matching a search term, - * Launch executable files. - - - -### DF-SHOW Usage - -DF-SHOW consists of two programs, namely **“show”** and **“sf”**. - -**Show command** - -The “show” program (similar to the `ls` command) is used to display the contents of a directory, create new directories, rename, delete files/folders, update permissions, search files and so on. - -To view the list of contents in a directory, use the following command: - -``` -$ show -``` - -Example: - -``` -$ show dfshow -``` - -Here, dfshow is a directory. If you invoke the “show” command without specifying a directory path, it will display the contents of current directory. - -Here is how DF-SHOW default interface looks like. - -![](https://www.ostechnix.com/wp-content/uploads/2018/10/dfshow-1.png) - -As you can see, DF-SHOW interface is self-explanatory. - -On the top bar, you see the list of available options such as Copy, Delete, Edit, Modify etc. - -Complete list of available options are given below: - - * **C** opy, - * **D** elete, - * **E** dit, - * **H** idden, - * **M** odify, - * **Q** uit, - * **R** ename, - * **S** how, - * h **U** nt, - * e **X** ec, - * **R** un command, - * **E** dit file, - * **H** elp, - * **M** ake dir, - * **Q** uit, - * **S** how dir - - - -In each option, one letter has been capitalized and marked as bold. Just press the capitalized letter to perform the respective operation. For example, to rename a file, just press **R** and type the new name and hit ENTER to rename the selected item. - -![](https://www.ostechnix.com/wp-content/uploads/2018/10/dfshow-2.png) - -To display all options or cancel an operation, just press **ESC** key. - -Also, you will see a bunch of function keys at the bottom of DF-SHOW interface to navigate through the contents of a directory. - - * **UP/DOWN** arrows or **F1/F2** – Move up and down (one line at time), - * **PgUp/Pg/Dn** – Move one page at a time, - * **F3/F4** – Instantly go to Top and bottom of the list, - * **F5** – Refresh, - * **F6** – Mark/Unmark files (Files marked will be indicated with an ***** in front of them), - * **F7/F8** – Mark/Unmark all files at once, - * **F9** – Sort the list by – Date & time, Name, Size., - - - -Press **h** to learn more details about **show** command and its options. - -To exit DF-SHOW, simply press **q**. - -**SF Command** - -The “sf” (show files) is used to display the contents of a file. - -``` -$ sf -``` - -![](https://www.ostechnix.com/wp-content/uploads/2018/10/dfshow-3.png) - -Press **h** to learn more “sf” command and its options. To quit, press **q**. - -Want to give it a try? Great! Go ahead and install DF-SHOW on your Linux system as described below. - -### Installing DF-SHOW - -DF-SHOW is available in [**AUR**][1], so you can install it on any Arch-based system using AUR programs such as [**Yay**][2]. - -``` -$ yay -S dfshow -``` - -On Ubuntu and its derivatives: - -``` -$ sudo add-apt-repository ppa:ian-hawdon/dfshow - -$ sudo apt-get update - -$ sudo apt-get install dfshow -``` - -On other Linux distributions, you can compile and build it from the source as shown below. - -``` -$ git clone https://github.com/roberthawdon/dfshow -$ cd dfshow -$ ./bootstrap -$ ./configure -$ make -$ sudo make install -``` - -The author of DF-SHOW project has only rewritten some of the applications of DF-EDIT utility. Since the source code is freely available on GitHub, you can add more features, improve the code and submit or fix the bugs (if there are any). It is still in alpha stage, but fully functional. - -Have you tried it already? If so, how’d go? Tell us your experience in the comments section below. - -And, that’s all for now. Hope this was useful.More good stuffs to come. - -Stay tuned! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/df-show-a-terminal-file-manager-based-on-an-old-dos-application/ - -作者:[SK][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/sk/ -[b]: https://github.com/lujun9972 -[1]: https://aur.archlinux.org/packages/dfshow/ -[2]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ diff --git a/sources/tech/20181030 Podman- A more secure way to run containers.md b/sources/tech/20181030 Podman- A more secure way to run containers.md deleted file mode 100644 index a6252d87cc..0000000000 --- a/sources/tech/20181030 Podman- A more secure way to run containers.md +++ /dev/null @@ -1,130 +0,0 @@ -Podman: A more secure way to run containers -====== -Podman uses a traditional fork/exec model (vs. a client/server model) for running containers. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security-lock-cloud-safe.png?itok=yj2TFPzq) - -Before I get into the main topic of this article, [Podman][1] and containers, I need to get a little technical about the Linux audit feature. - -### What is audit? - -The Linux kernel has an interesting security feature called **audit**. It allows administrators to watch for security events on a system and have them logged to the audit.log, which can be stored locally or remotely on another machine to prevent a hacker from trying to cover his tracks. - -The **/etc/shadow** file is a common security file to watch, since adding a record to it could allow an attacker to get return access to the system. Administrators want to know if any process modified the file. You can do this by executing the command: - -``` -# auditctl -w /etc/shadow -``` - -Now let's see what happens if I modify the /etc/shadow file: - -``` -# touch /etc/shadow -# ausearch -f /etc/shadow -i -ts recent - -type=PROCTITLE msg=audit(10/10/2018 09:46:03.042:4108) : proctitle=touch /etc/shadow type=SYSCALL msg=audit(10/10/2018 09:46:03.042:4108) : arch=x86_64 syscall=openat success=yes exit=3 a0=0xffffff9c a1=0x7ffdb17f6704 a2=O_WRONLY|O_CREAT|O_NOCTTY| O_NONBLOCK a3=0x1b6 items=2 ppid=2712 pid=3727 auid=dwalsh uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=pts1 ses=3 comm=touch exe=/usr/bin/touch subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)` -``` - -There's a lot of information in the audit record, but I highlighted that it recorded that root modified the /etc/shadow file and the owner of the process' audit UID ( **auid** ) was **dwalsh**. - -Did the kernel do that? - -#### Tracking the login UID - -**loginuid** , stored in **/proc/self/loginuid** , that is part of the proc struct of every process on the system. This field can be set only once; after it is set, the kernel will not allow any process to reset it. - -There is a field called, stored in, that is part of the proc struct of every process on the system. This field can be set only once; after it is set, the kernel will not allow any process to reset it. - -When I log into the system, the login program sets the loginuid field for my login process. - -My UID, dwalsh, is 3267. - -``` -$ cat /proc/self/loginuid -3267 -``` - -Now, even if I become root, my login UID stays the same. - -``` -$ sudo cat /proc/self/loginuid -3267 -``` - -Note that every process that's forked and executed from the initial login process automatically inherits the loginuid. This is how the kernel knew that the person who logged was dwalsh. - -### Containers - -Now let's look at containers. - -``` -sudo podman run fedora cat /proc/self/loginuid -3267 -``` - -Even the container process retains my loginuid. Now let's try with Docker. - -``` -sudo docker run fedora cat /proc/self/loginuid -4294967295 -``` - -### Why the difference? - -Podman uses a traditional fork/exec model for the container, so the container process is an offspring of the Podman process. Docker uses a client/server model. The **docker** command I executed is the Docker client tool, and it communicates with the Docker daemon via a client/server operation. Then the Docker daemon creates the container and handles communications of stdin/stdout back to the Docker client tool. - -The default loginuid of processes (before their loginuid is set) is 4294967295. Since the container is an offspring of the Docker daemon and the Docker daemon is a child of the init system, we see that systemd, Docker daemon, and the container processes all have the same loginuid, 4294967295, which audit refers to as the unset audit UID. - -``` -cat /proc/1/loginuid -4294967295 -``` - -### How can this be abused? - -Let's look at what would happen if a container process launched by Docker modifies the /etc/shadow file. - -``` -$ sudo docker run --privileged -v /:/host fedora touch /host/etc/shadow -$ sudo ausearch -f /etc/shadow -i type=PROCTITLE msg=audit(10/10/2018 10:27:20.055:4569) : proctitle=/usr/bin/coreutils --coreutils-prog-shebang=touch /usr/bin/touch /host/etc/shadow type=SYSCALL msg=audit(10/10/2018 10:27:20.055:4569) : arch=x86_64 syscall=openat success=yes exit=3 a0=0xffffff9c a1=0x7ffdb6973f50 a2=O_WRONLY|O_CREAT|O_NOCTTY| O_NONBLOCK a3=0x1b6 items=2 ppid=11863 pid=11882 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=touch exe=/usr/bin/coreutils subj=system_u:system_r:spc_t:s0 key=(null) -``` - -In the Docker case, the auid is unset (4294967295); this means the security officer might know that a process modified the /etc/shadow file but the identity was lost. - -If that attacker then removed the Docker container, there would be no trace on the system of who modified the /etc/shadow file. - -Now let's look at the exact same scenario with Podman. - -``` -$ sudo podman run --privileged -v /:/host fedora touch /host/etc/shadow -$ sudo ausearch -f /etc/shadow -i type=PROCTITLE msg=audit(10/10/2018 10:23:41.659:4530) : proctitle=/usr/bin/coreutils --coreutils-prog-shebang=touch /usr/bin/touch /host/etc/shadow type=SYSCALL msg=audit(10/10/2018 10:23:41.659:4530) : arch=x86_64 syscall=openat success=yes exit=3 a0=0xffffff9c a1=0x7fffdffd0f34 a2=O_WRONLY|O_CREAT|O_NOCTTY| O_NONBLOCK a3=0x1b6 items=2 ppid=11671 pid=11683 auid=dwalsh uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=3 comm=touch exe=/usr/bin/coreutils subj=unconfined_u:system_r:spc_t:s0 key=(null) -``` - -Everything is recorded correctly with Podman since it uses traditional fork/exec. - -This was just a simple example of watching the /etc/shadow file, but the auditing system is very powerful for watching what processes do on a system. Using a fork/exec container runtime for launching containers (instead of a client/server container runtime) allows you to maintain better security through audit logging. - -### Final thoughts - -There are many other nice features about the fork/exec model versus the client/server model when launching containers. For example, systemd features include: - - * **SD_NOTIFY:** If you put a Podman command into a systemd unit file, the container process can return notice up the stack through Podman that the service is ready to receive tasks. This is something that can't be done in client/server mode. - * **Socket activation:** You can pass down connected sockets from systemd to Podman and onto the container process to use them. This is impossible in the client/server model. - - - -The nicest feature, in my opinion, is **running Podman and containers as a non-root user**. This means you never have give a user root privileges on the host, while in the client/server model (like Docker employs), you must open a socket to a privileged daemon running as root to launch the containers. There you are at the mercy of the security mechanisms implemented in the daemon versus the security mechanisms implemented in the host operating systems—a dangerous proposition. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/10/podman-more-secure-way-run-containers - -作者:[Daniel J Walsh][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/rhatdan -[b]: https://github.com/lujun9972 -[1]: https://podman.io diff --git a/sources/tech/20181105 How to manage storage on Linux with LVM.md b/sources/tech/20181105 How to manage storage on Linux with LVM.md index 9c0ee685d6..36cc8d47a0 100644 --- a/sources/tech/20181105 How to manage storage on Linux with LVM.md +++ b/sources/tech/20181105 How to manage storage on Linux with LVM.md @@ -1,4 +1,3 @@ -[zianglei translating] How to manage storage on Linux with LVM ====== Create, expand, and encrypt storage pools as needed with the Linux LVM utilities. diff --git a/sources/tech/20181111 Some notes on running new software in production.md b/sources/tech/20181111 Some notes on running new software in production.md new file mode 100644 index 0000000000..bfdfb66a44 --- /dev/null +++ b/sources/tech/20181111 Some notes on running new software in production.md @@ -0,0 +1,151 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Some notes on running new software in production) +[#]: via: (https://jvns.ca/blog/2018/11/11/understand-the-software-you-use-in-production/) +[#]: author: (Julia Evans https://jvns.ca/) + +Some notes on running new software in production +====== + +I’m working on a talk for kubecon in December! One of the points I want to get across is the amount of time/investment it takes to use new software in production without causing really serious incidents, and what that’s looked like for us in our use of Kubernetes. + +To start out, this post isn’t blanket advice. There are lots of times when it’s totally fine to just use software and not worry about **how** it works exactly. So let’s start by talking about when it’s important to invest. + +### when it matters: 99.99% + +If you’re running a service with a low SLO like 99% I don’t think it matters that much to understand the software you run in production. You can be down for like 2 hours a month! If something goes wrong, just fix it and it’s fine. + +At 99.99%, it’s different. That’s 45 minutes / year of downtime, and if you find out about a serious issue for the first time in production it could easily take you 20 minutes or to revert the change. That’s half your uptime budget for the year! + +### when it matters: software that you’re using heavily + +Also, even if you’re running a service with a 99.99% SLO, it’s impossible to develop a super deep understanding of every single piece of software you’re using. For example, a web service might use: + + * 100 library dependencies + * the filesystem (so there’s linux filesystem code!) + * the network (linux networking code!) + * a database (like postgres) + * a proxy (like nginx/haproxy) + + + +If you’re only reading like 2 files from disk, you don’t need to do a super deep dive into Linux filesystems internals, you can just read the file from disk. + +What I try to do in practice is identify the components which we rely on the (or have the most unusual use cases for!), and invest time into understanding those. These are usually pretty easy to identify because they’re the ones which will cause the most problems :) + +### when it matters: new software + +Understanding your software especially matters for newer/less mature software projects, because it’s morely likely to have bugs & or just not have matured enough to be used by most people without having to worry. I’ve spent a bunch of time recently with Kubernetes/Envoy which are both relatively new projects, and neither of those are remotely in the category of “oh, it’ll just work, don’t worry about it”. I’ve spent many hours debugging weird surprising edge cases with both of them and learning how to configure them in the right way. + +### a playbook for understanding your software + +The playbook for understanding the software you run in production is pretty simple. Here it is: + + 1. Start using it in production in a non-critical capacity (by sending a small percentage of traffic to it, on a less critical service, etc) + 2. Let that bake for a few weeks. + 3. Run into problems. + 4. Fix the problems. Go to step 3. + + + +Repeat until you feel like you have a good handle on this software’s failure modes and are comfortable running it in a more critical capacity. Let’s talk about that in a little more detail, though: + +### what running into bugs looks like + +For example, I’ve been spending a lot of time with Envoy in the last year. Some of the issues we’ve seen along the way are: (in no particular order) + + * One of the default settings resulted in retry & timeout headers not being respected + * Envoy (as a client) doesn’t support TLS session resumption, so servers with a large amount of Envoy clients get DDOSed by TLS handshakes + * Envoy’s active healthchecking means that you services get healthchecked by every client. This is mostly okay but (again) services with many clients can get overwhelmed by it. + * Having every client independently healthcheck every server interacts somewhat poorly with services which are under heavy load, and can exacerbate performance issues by removing up-but-slow clients from the load balancer rotation. + * Envoy doesn’t retry failed connections by default + * it frequently segfaults when given incorrect configuration + * various issues with it segfaulting because of resource leaks / memory safety issues + * hosts running out of disk space between we didn’t rotate Envoy log files often enough + + + +A lot of these aren’t bugs – they’re just cases where what we expected the default configuration to do one thing, and it did another thing. This happens all the time, and it can result in really serious incidents. Figuring out how to configure a complicated piece of software appropriately takes a lot of time, and you just have to account for that. + +And Envoy is great software! The maintainers are incredibly responsive, they fix bugs quickly and its performance is good. It’s overall been quite stable and it’s done well in production. But just because something is great software doesn’t mean you won’t also run into 10 or 20 relatively serious issues along the way that need to be addressed in one way or another. And it’s helpful to understand those issues **before** putting the software in a really critical place. + +### try to have each incident only once + +My view is that running new software in production inevitably results in incidents. The trick: + + 1. Make sure the incidents aren’t too serious (by making ‘production’ a less critical system first) + 2. Whenever there’s an incident (even if it’s not that serious!!!), spend the time necessary to understand exactly why it happened and how to make sure it doesn’t happen again + + + +My experience so far has been that it’s actually relatively possible to pull off “have every incident only once”. When we investigate issues and implement remediations, usually that issue **never comes back**. The remediation can either be: + + * a configuration change + * reporting a bug upstream and either fixing it ourselves or waiting for a fix + * a workaround (“this software doesn’t work with 10,000 clients? ok, we just won’t use it with in cases where there are that many clients for now!“, “oh, a memory leak? let’s just restart it every hour”) + + + +Knowledge-sharing is really important here too – it’s always unfortunate when one person finds an incident in production, fixes it, but doesn’t explain the issue to the rest of the team so somebody else ends up causing the same incident again later because they didn’t hear about the original incident. + +### Understand what is ok to break and isn’t + +Another huge part of understanding the software I run in production is understanding which parts are OK to break (aka “if this breaks, it won’t result in a production incident”) and which aren’t. This lets me **focus**: I can put big boxes around some components and decide “ok, if this breaks it doesn’t matter, so I won’t pay super close attention to it”. + +For example, with Kubernetes: + +ok to break: + + * any stateless control plane component can crash or be cycled out or go down for 5 minutes at any time. If we had 95% uptime for the kubernetes control plane that would probably be fine, it just needs to be working most of the time. + * kubernetes networking (the system where you give every pod an IP addresses) can break as much as it wants because we decided not to use it to start + + + +not ok: + + * for us, if etcd goes down for 10 minutes, that’s ok. If it goes down for 2 hours, it’s not + * containers not starting or crashing on startup (iam issues, docker not starting containers, bugs in the scheduler, bugs in other controllers) is serious and needs to be looked at immediately + * containers not having access to the resources they need (because of permissions issues, etc) + * pods being terminated unexpectedly by Kubernetes (if you configure kubernetes wrong it can terminate your pods!) + + + +with Envoy, the breakdown is pretty different: + +ok to break: + + * if the envoy control plane goes down for 5 minutes, that’s fine (it’ll keep working with stale data) + * segfaults on startup due to configuration errors are sort of okay because they manifest so early and they’re unlikely to surprise us (if the segfault doesn’t happen the 1st time, it shouldn’t happen the 200th time) + + + +not ok: + + * Envoy crashes / segfaults are not good – if it crashes, network connections don’t happen + * if the control server serves incorrect or incomplete data that’s extremely dangerous and can result in serious production incidents. (so downtime is fine, but serving incorrect data is not!) + + + +Neither of these lists are complete at all, but they’re examples of what I mean by “understand your sofware”. + +### sharing ok to break / not ok lists is useful + +I think these “ok to break” / “not ok” lists are really useful to share, because even if they’re not 100% the same for every user, the lessons are pretty hard won. I’d be curious to hear about your breakdown of what kinds of failures are ok / not ok for software you’re using! + +Figuring out all the failure modes of a new piece of software and how they apply to your situation can take months. (this is is why when you ask your database team “hey can we just use NEW DATABASE” they look at you in such a pained way). So anything we can do to help other people learn faster is amazing +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2018/11/11/understand-the-software-you-use-in-production/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 diff --git a/sources/tech/20181118 An example of how C-- destructors are useful in Envoy.md b/sources/tech/20181118 An example of how C-- destructors are useful in Envoy.md new file mode 100644 index 0000000000..f95f17db01 --- /dev/null +++ b/sources/tech/20181118 An example of how C-- destructors are useful in Envoy.md @@ -0,0 +1,130 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (An example of how C++ destructors are useful in Envoy) +[#]: via: (https://jvns.ca/blog/2018/11/18/c---destructors---really-useful/) +[#]: author: (Julia Evans https://jvns.ca/) + +An example of how C++ destructors are useful in Envoy +====== + +For a while now I’ve been working with a C++ project (Envoy), and sometimes I need to contribute to it, so my C++ skills have gone from “nonexistent” to “really minimal”. I’ve learned what an initializer list is and that a method starting with `~` is a destructor. I almost know what an lvalue and an rvalue are but not quite. + +But the other day when writing some C++ code I figured out something exciting about how to use destructors that I hadn’t realized! (the tl;dr of this post for people who know C++ is “julia finally understands what RAII is and that it is useful” :)) + +### what’s a destructor? + +C++ has objects. When an C++ object goes out of scope, the compiler inserts a call to its destructor. So if you have some code like + +``` +function do_thing() { + Thing x{}; // this calls the Thing constructor + return 2; +} +``` + +there will be a call to x’s destructor at the end of the `do_thing` function. so the code c++ generates looks something like: + + * make new thing + * call the new thing’s destructor + * return 2 + + + +Obviously destructors are way more complicated like this. They need to get called when there are exceptions! And sometimes they get called manually. And for lots of other reasons too. But there are 10 million things to know about C++ and that is not what we’re doing today, we are just talking about one thing. + +### what happens in a destructor? + +A lot of the time memory gets freed, which is how you avoid having memory leaks. But that’s not what we’re talking about in this post! We are talking about something more interesting. + +### the thing we’re interested in: Envoy circuit breakers + +So I’ve been working with Envoy a lot. 3 second Envoy refresher: it’s a HTTP proxy, your application makes requests to Envoy, which then proxies the request to the servers the application wants to talk to. + +One very useful feature Envoy has is this thing called “circuit breakers”. Basically the idea with is that if your application makes 50 billion connections to a service, that will probably overwhelm the service. So Envoy keeps track how many TCP connections you’ve made to a service, and will stop you from making new requests if you hit the limit. The default `max_connection` limit + +### how do you track connection count? + +To maintain a circuit breaker on the number of TCP connections, that means you need to keep an accurate count of how many TCP connections are currently open! How do you do that? Well, the way it works is to maintain a `connections` counter and: + + * every time a connection is opened, increment the counter + * every time a connection is destroyed (because of a reset / timeout / whatever), decrement the counter + * when creating a new connection, check that the `connections` counter is not over the limit + + + +that’s all! And incrementing the counter when creating a new connection is pretty easy. But how do you make sure that the counter gets _decremented_ wheh the connection is destroyed? Connections can be destroyed in a lot of ways (they can time out! they can be closed by Envoy! they can be closed by the server! maybe something else I haven’t thought of could happen!) and it seems very easy to accidentally miss a way of closing them. + +### destructors to the rescue + +The way Envoy solves this problem is to create a connection object (called `ActiveClient` in the HTTP connection pool) for every connection. + +Then it: + + * increments the counter in the constructor ([code][1]) + * decrements the counter in the destructor ([code][2]) + * checks the counter when a new connection is created ([code][3]) + + + +The beauty of this is that now you don’t need to make sure that the counter gets decremented in all the right places, you now just need to organize your code so that the `ActiveClient` object’s destructor gets called when the connection has closed. + +Where does the `ActiveClient` destructor get called in Envoy? Well, Envoy maintains 2 lists of clients (`ready_clients` and `busy_clients`), and when a connection gets closed, Envoy removes the client from those lists. And when it does that, it doesn’t need to do any extra cleanup!! In C++, anytime a object is removed from a list, its destructor is called. So `client.removeFromList(ready_clients_);` takes care of all the cleanup. And there’s no chance of forgetting to decrement the counter!! It will definitely always happen unless you accidentally leave the object on one of these lists, which would be a bug anyway because the connection is closed :) + +### RAII + +This pattern Envoy is using here is an extremely common C++ programming pattern called “resource acquisition is initialization”. I find that name very confusing but that’s what it’s called. basically the way it works is: + + * identify a resource (like “connection”) where a lot of things need to happen when the connection is initialized / finished + * make a class for that connection + * put all the initialization / finishing code in the constructor / destructor + * make sure the object’s destructor method gets called when appropriate! (by removing it from a vector / having it go out of scope) + + + +Previously I knew about using this pattern for kind of obvious things (make sure all the memory gets freed in the destructor, or make sure file descriptors get closed). But I didn’t realize it was also useful for cases that are slightly less obviously a resource like “decrement a counter”. + +The reason this pattern works is because the C++ compiler/standard library does a bunch of work to make sure that destructors get called when you’re done with an object – the compiler inserts destructor calls at the end of each block of code, after exceptions, and many standard library collections make sure destructors are called when you remove an object from a collection. + +### RAII gives you prompt, deterministic, and hard-to-screw-up cleanup of resources + +The exciting thing here is that this programming pattern gives you a way to schedule cleaning up resources that’s: + + * easy to ensure always happens (when the object goes away, it always happens, even if there was an exception!) + * prompt & determinstic (it happens right away and it’s guaranteed to happen!) + + + +### what languages have RAII? + +C++ and Rust have RAII. Probably other languages too. Java, Python, Go, and garbage collected languages in general do not. In a garbage collected language you can often set up destructors to be run when the object is GC’d. But often (like in this case, which the connection count) you want things to be cleaned up **right away** when the object is no longer in use, not some indeterminate period later whenever GC happens to run. + +Python context managers are a related idea, you could do something like: + +``` +with conn_pool.connection() as conn: + do stuff +``` + +### that’s all for now! + +Hopefully this explanation of RAII is interesting and mostly correct. Thanks to Kamal for clarifying some RAII things for me! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2018/11/18/c---destructors---really-useful/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://github.com/envoyproxy/envoy/blob/200b0e41641be46471c2ce3d230aae395fda7ded/source/common/http/http1/conn_pool.cc#L301 +[2]: https://github.com/envoyproxy/envoy/blob/200b0e41641be46471c2ce3d230aae395fda7ded/source/common/http/http1/conn_pool.cc#L315 +[3]: https://github.com/envoyproxy/envoy/blob/200b0e41641be46471c2ce3d230aae395fda7ded/source/common/http/http1/conn_pool.cc#L97 diff --git a/sources/tech/20181202 How To Customize The GNOME 3 Desktop.md b/sources/tech/20181202 How To Customize The GNOME 3 Desktop.md deleted file mode 100644 index 91c16e4e99..0000000000 --- a/sources/tech/20181202 How To Customize The GNOME 3 Desktop.md +++ /dev/null @@ -1,266 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: subject: (How To Customize The GNOME 3 Desktop?) -[#]: via: (https://www.2daygeek.com/how-to-customize-the-gnome-3-desktop/) -[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) -[#]: url: ( ) - -How To Customize The GNOME 3 Desktop? -====== - -We have got many emails from user to write an article about GNOME 3 desktop customization but we don’t get a time to write this topic. - -I was using Ubuntu operating system since long time in my primary laptop and i got bored so, i would like to test some other distro which is related to Arch Linux. - -I prefer to go with Majaro so, i have installed Manjaro 18.0 with GNOME 3 desktop in my laptop. - -I’m customizing my desktop, how i want it. So, i would like to take this opportunity to write up this article in detailed way to help others. - -This article helps others to customize their desktop without headache. - -I’m not going to include all my customization and i will be adding a necessary things which will be mandatory and useful for Linux desktop users. - -If you feel some tweak is missing in this article, i would request you to mention that in comment sections. It will be very helpful for other users. - -### 1) How to Launch Activities Overview in GNOME 3 Desktop? - -The Activities Overview will display all the running applications or launched/opened windows by clicking `Super Key` or by clicking `Activities` button in the topmost left corner. - -It allows you to launch a new applications, switch windows, and move windows between workspaces. - -You can simply exit the Activities Overview by choosing the following any of the one actions like selecting a window, application or workspace, or by pressing the `Super Key` or `Esc Key`. - -Activities Overview Screenshot. -![][2] - -### 2) How to Resize Windows in GNOME 3 Desktop? - -The Launched windows can be maximized, unmaximized and snapped to one side of the screen (Left or Right) by using the following key combinations. - - * `Super Key+Down Arrow:` To unmaximize the window. - * `Super Key+Up Arrow:` To maximize the window. - * `Super Key+Right Arrow:` To fill a window in the right side of the half screen. - * `Super Key+Left Arrow:` To fill a window in the left side of the half screen - - - -Use `Super Key+Down Arrow` to unmaximize the window. -![][3] - -Use `Super Key+Up Arrow` to maximize the window. -![][4] - -Use `Super Key+Right Arrow` to fill a window in the right side of the half screen. -![][5] - -Use `Super Key+Left Arrow` to fill a window in the left side of the half screen. -![][6] - -This feature will help you to view two applications at a time a.k.a splitting screen. -![][7] - -### 3) How to Display Applications in GNOME 3 Desktop? - -Click on the `Show Application Grid` button in the Dash to display all the installed applications on your system. -![][8] - -### 4) How to Add Applications on Dash in GNOME 3 Desktop? - -To speed up your day to day activity you may want to add frequently used application into Dash or Drag the application launcher to the Dash. - -It will allow you to directly launch your favorite applications without searching them. To do so, simply right click on it and use the option `Add to Favorites`. -![][9] - -To remove a application launcher a.k.a favorite from Dash, either drag it from the Dash to the grid button or simply right click on it and use the option `Remove from Favorites`. -![][10] - -### 5) How to Switch Between Workspaces in GNOME 3 Desktop? - -Workspaces allow you to group windows together. It will helps you to segregate your work properly. If you are working on Multiple things and you want to group each work and related things separately then it will be very handy and perfect option for you. - -You can switch workspaces in two ways, Open the Activities Overview and select a workspace from the right-hand side or use the following key combinations. - - * Use `Ctrl+Alt+Up` Switch to the workspace above. - * Use `Ctrl+Alt+Down` Switch to the workspace below. - - - -![][11] - -### 6) How to Switch Between Applications (Application Switcher) in GNOME 3 Desktop? - -Use either `Alt+Tab` or `Super+Tab` to switch between applications. To launch Application Switcher, use either `Alt+Tab` or `Super+Tab`. - -Once launched, just keep holding the Alt or Super key and hit the tab key to move to the next application from left to right order. - -### 7) How to Add UserName to Top Panel in GNOME 3 Desktop? - -If you would like to add your UserName to Top Panel then install the following [Add Username to Top Panel][12] GNOME Extension. -![][13] - -### 8) How to Add Microsoft Bing’s wallpaper in GNOME 3 Desktop? - -Install the following [Bing Wallpaper Changer][14] GNOME shell extension to change your wallpaper every day to Microsoft Bing’s wallpaper. -![][15] - -### 9) How to Enable Night Light in GNOME 3 Desktop? - -Night light app is one of the famous app which reduces strain on the eyes by turning your screen a dim yellow from blue light after sunset. - -It is available in smartphones. The other known apps for the same purpose are flux and **[redshift][16]**. - -To enable this, navigate to **System Settings** >> **Devices** >> **Displays** and turn Nigh Light on. -![][17] - -Once it’s enabled and status icon will be placed on the top panel. -![][18] - -### 10) How to Show the Battery Percentage in GNOME 3 Desktop? - -Battery percentage will show you the exact battery usage. To enable this follow the below steps. - -Start GNOME Tweaks >> **Top Bar** >> **Battery Percentage** and switch it on. -![][19] - -After modification you can able to see the battery percentage icon on the top panel. -![][20] - -### 11) How to Enable Mouse Right Click in GNOME 3 Desktop? - -By default right click is disabled on GNOME 3 desktop environment. To enable this follow the below steps. - -Start GNOME Tweaks >> **Keyboard & Mouse** >> Mouse Click Emulation and select “Area” option. -![][21] - -### 12) How to Enable Minimize On Click in GNOME 3 Desktop? - -Enable one-click minimize feature which will help us to minimize opened window without using minimize option. - -``` -$ gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize' -``` - -### 13) How to Customize Dock in GNOME 3 Desktop? - -If you would like to change your Dock similar to Deepin desktop or Mac then use the following set of commands. - -``` -$ gsettings set org.gnome.shell.extensions.dash-to-dock dock-position BOTTOM -$ gsettings set org.gnome.shell.extensions.dash-to-dock extend-height false -$ gsettings set org.gnome.shell.extensions.dash-to-dock transparency-mode FIXED -$ gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 50 -``` - -![][22] - -### 14) How to Show Desktop in GNOME 3 Desktop? - -By default `Super Key+D` shortcut doesn’t show your desktop. To configure this follow the below steps. - -Settings >> **Devices** >> **Keyboard** >> Click **Hide all normal windows** under Navigation then Press `Super Key+D` finally hit `Set` button to enable it. -![][23] - -### 15) How to Customize Date and Time Format? - -By default GNOME 3 shows date and time with `Sun 04:48`. It’s not clear and if you want to get the output with following format `Sun Dec 2 4:49 AM` follow the below steps. - -**For Date Modification:** Start GNOME Tweaks >> **Top Bar** and enable `Weekday` option under Clock. -![][24] - -**For Time Modification:** Settings >> **Details** >> **Date & Time** then choose `AM/PM` option in the time format. -![][25] - -After modification you can able to see the date and time format same as below. -![][26] - -### 16) How to Permanently Disable Unused Services in Boot? - -In my case, i’m not going to use **Bluetooth** & **cpus a.k.a Printer service**. Hence, disabling these services on my laptop. To disable services on Arch based systems use **[Pacman Package Manager][27]**. -For Bluetooth - -``` -$ sudo systemctl stop bluetooth.service -$ sudo systemctl disable bluetooth.service -$ sudo systemctl mask bluetooth.service -$ systemctl status bluetooth.service -``` - -For cups - -``` -$ sudo systemctl stop org.cups.cupsd.service -$ sudo systemctl disable org.cups.cupsd.service -$ sudo systemctl mask org.cups.cupsd.service -$ systemctl status org.cups.cupsd.service -``` - -Finally verify whether these services are disabled or not in the boot using the following command. If you want to double confirm this, you can reboot once and check the same. Navigate to the following link to know more about **[systemctl][28]** usage, - -``` -$ systemctl list-unit-files --type=service | grep enabled -[email protected] enabled -dbus-org.freedesktop.ModemManager1.service enabled -dbus-org.freedesktop.NetworkManager.service enabled -dbus-org.freedesktop.nm-dispatcher.service enabled -display-manager.service enabled -gdm.service enabled -[email protected] enabled -linux-module-cleanup.service enabled -ModemManager.service enabled -NetworkManager-dispatcher.service enabled -NetworkManager-wait-online.service enabled -NetworkManager.service enabled -systemd-fsck-root.service enabled-runtime -tlp-sleep.service enabled -tlp.service enabled -``` - -### 17) Install Icons & Themes in GNOME 3 Desktop? - -Bunch of Icons and Themes are available for GNOME Desktop so, choose the desired **[GTK Themes][29]** and **[Icons Themes][30]** for you. To configure this further, navigate to the below links which makes your Desktop more elegant. - --------------------------------------------------------------------------------- - -via: https://www.2daygeek.com/how-to-customize-the-gnome-3-desktop/ - -作者:[Magesh Maruthamuthu][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.2daygeek.com/author/magesh/ -[b]: https://github.com/lujun9972 -[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[2]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-activities-overview-screenshot.jpg -[3]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-activities-unmaximize-the-window.jpg -[4]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-activities-maximize-the-window.jpg -[5]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-activities-fill-a-window-right-side.jpg -[6]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-activities-fill-a-window-left-side.jpg -[7]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-activities-split-screen.jpg -[8]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-display-applications.jpg -[9]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-add-applications-on-dash.jpg -[10]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-remove-applications-from-dash.jpg -[11]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-workspaces-screenshot.jpg -[12]: https://extensions.gnome.org/extension/1108/add-username-to-top-panel/ -[13]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-add-username-to-top-panel.jpg -[14]: https://extensions.gnome.org/extension/1262/bing-wallpaper-changer/ -[15]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-add-microsoft-bings-wallpaper.jpg -[16]: https://www.2daygeek.com/install-redshift-reduce-prevent-protect-eye-strain-night-linux/ -[17]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-enable-night-light.jpg -[18]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-enable-night-light-1.jpg -[19]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-display-battery-percentage.jpg -[20]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-display-battery-percentage-1.jpg -[21]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-enable-mouse-right-click.jpg -[22]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-dock-customization.jpg -[23]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-enable-show-desktop.jpg -[24]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-customize-date.jpg -[25]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-customize-time.jpg -[26]: https://www.2daygeek.com/wp-content/uploads/2018/12/how-to-customize-the-gnome-3-desktop-customize-date-time.jpg -[27]: https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/ -[28]: https://www.2daygeek.com/sysvinit-vs-systemd-cheatsheet-systemctl-command-usage/ -[29]: https://www.2daygeek.com/category/gtk-theme/ -[30]: https://www.2daygeek.com/category/icon-theme/ diff --git a/sources/tech/20181209 How do you document a tech project with comics.md b/sources/tech/20181209 How do you document a tech project with comics.md new file mode 100644 index 0000000000..02d4981875 --- /dev/null +++ b/sources/tech/20181209 How do you document a tech project with comics.md @@ -0,0 +1,100 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How do you document a tech project with comics?) +[#]: via: (https://jvns.ca/blog/2018/12/09/how-do-you-document-a-tech-project-with-comics/) +[#]: author: (Julia Evans https://jvns.ca/) + +How do you document a tech project with comics? +====== + +Every so often I get email from people saying basically “hey julia! we have an open source project! we’d like to use comics / zines / art to document our project! Can we hire you?“. + +spoiler: the answer is “no, you can’t hire me” – I don’t do commissions. But I do think this is a cool idea and I’ve often wished I had something more useful to say to people than “no”, so if you’re interested in this, here are some ideas about how to accomplish it! + +### zine != drawing + +First, a terminology distinction. One weird thing I’ve noticed is that people frequently refer to individual tech drawings as “zines”. I think this is due to me communicating poorly somehow, but – drawings are not zines! A zine is a **printed booklet**, like a small maga**zine**. You wouldn’t call a photo of a model in Vogue a magazine! The magazine has like a million pages! An individual drawing is a drawing/comic/graphic/whatever. Just clarifying this because I think it causes a bit of unnecessary confusion. + +### comics without good information are useless + +Usually when folks ask me “hey, could we make a comic explaining X”, it doesn’t seem like they have a clear idea of what information exactly they want to get across, they just have a vague idea that maybe it would be cool to draw some comics. This makes sense – figuring out what information would be useful to tell people is very hard!! It’s 80% of what I spend my time on when making comics. + +You should think about comics the same way as any kind of documentation – start with the information you want to convey, who your target audience is, and how you want to distribute it (twitter? on your website? in person?), and figure out how to illustrate it after :). The information is the main thing, not the art! + +Once you have a clear story about what you want to get across, you can start trying to think about how to represent it using illustrations! + +### focus on concepts that don’t change + +Drawing comics is a much bigger investment than writing documentation (it takes me like 5x longer to convey the same information in a comic than in writing). So use it wisely! Because it’s not that easy to edit, if you’re going to make something a comic you want to focus on concepts that are very unlikely to change. So talk about the core ideas in your project instead of the exact command line arguments it takes! + +Here are a couple of options for how you could use comics/illustrations to document your project! + +### option 1: a single graphic + +One format you might want to try is a single, small graphic explaining what your project is about and why folks might be interested in it. For example: [this zulip comic][1] + +This is a short thing, you could post it on Twitter or print it as a pamphlet to give out. The information content here would probably be basically what’s on your project homepage, but presented in a more fun/exciting way :) + +You can put a pretty small amount of information in a single comic. With that Zulip comic, the things I picked out were: + + * zulip is sort of like slack, but it has threads + * it’s easy to keep track of threads even if the conversation takes place over several days + * you can much more easily selectively catch up with Zulip + * zulip is open source + * there’s an open zulip server you can try out + + + +That’s not a lot of information! It’s 50 words :). So to do this effectively you need to distill your project down to 50 words in a way that’s still useful. It’s not easy! + +### option 2: many comics + +Another approach you can take is to make a more in depth comic / illustration, like [google’s guide to kubernetes][2] or [the children’s illustrated guide to kubernetes][3]. + +To do this, you need a much stronger concept than “uh, I want to explain our project” – you want to have a clear target audience in mind! For example, if I were drawing a set of Docker comics, I’d probably focus on folks who want to use Docker in production. so I’d want to discuss: + + * publishing your containers to a public/private registry + * some best practices for tagging your containers + * how to make sure your hosts don’t run out of disk space from downloading too many containers + * how to use layers to save on disk space / download less stuff + * whether it’s reasonable to run the same containers in production & in dev + + + +That’s totally different from the set of comics I’d write for folks who just want to use Docker to develop locally! + +### option 3: a printed zine + +The main thing that differentiates this from “many comics” is that zines are printed! Because of that, for this to make sense you need to have a place to give out the printed copies! Maybe you’re going present your project at a major conference? Maybe you give workshops about your project and want to give our the zine to folks in the workshop as notes? Maybe you want to mail it to people? + +### how to hire someone to help you + +There are basically 3 ways to hire someone: + + 1. Hire someone who both understands (or can quickly learn) the technology you want to document and can illustrate well. These folks are tricky to find and probably expensive (I certainly wouldn’t do a project like this for less than $10,000 even if I did do commissions), just because programmers can usually charge a pretty high consulting rate. I’d guess that the main failure mode here is that it might be impossible/very hard to find someone, and it might be expensive. + 2. Collaborate with an illustrator to draw it for you. The main failure mode here is that if you don’t give the illustrator clear explanations of your tech to work with, you.. won’t end up with a clear and useful explanation. From what I’ve seen, **most folks underinvest in writing clear explanations for their illustrators** – I’ve seen a few really adorable tech comics that I don’t find useful or clear at all. I’d love to see more people do a better job of this. What’s the point of having an adorable illustration if it doesn’t teach anyone anything? :) + 3. Draw it yourself :). This is what I do, obviously. stick figures are okay! + + + +Most people seem to use method #2 – I’m not actually aware of any tech folks who have done commissioned comics (though I’m sure it’s happened!). I think method #2 is a great option and I’d love to see more folks do it. Paying illustrators is really fun! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2018/12/09/how-do-you-document-a-tech-project-with-comics/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://twitter.com/b0rk/status/986444234365521920 +[2]: https://cloud.google.com/kubernetes-engine/kubernetes-comic/ +[3]: https://thenewstack.io/kubernetes-gets-childrens-book/ diff --git a/sources/tech/20181213 Podman and user namespaces- A marriage made in heaven.md b/sources/tech/20181213 Podman and user namespaces- A marriage made in heaven.md deleted file mode 100644 index adc14c6111..0000000000 --- a/sources/tech/20181213 Podman and user namespaces- A marriage made in heaven.md +++ /dev/null @@ -1,145 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Podman and user namespaces: A marriage made in heaven) -[#]: via: (https://opensource.com/article/18/12/podman-and-user-namespaces) -[#]: author: (Daniel J Walsh https://opensource.com/users/rhatdan) - -Podman and user namespaces: A marriage made in heaven -====== -Learn how to use Podman to run containers in separate user namespaces. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/architecture_structure_planning_design_.png?itok=KL7dIDct) - -[Podman][1], part of the [libpod][2] library, enables users to manage pods, containers, and container images. In my last article, I wrote about [Podman as a more secure way to run containers][3]. Here, I'll explain how to use Podman to run containers in separate user namespaces. - -I have always thought of [user namespace][4], primarily developed by Red Hat's Eric Biederman, as a great feature for separating containers. User namespace allows you to specify a user identifier (UID) and group identifier (GID) mapping to run your containers. This means you can run as UID 0 inside the container and UID 100000 outside the container. If your container processes escape the container, the kernel will treat them as UID 100000. Not only that, but any file object owned by a UID that isn't mapped into the user namespace will be treated as owned by "nobody" (65534, kernel.overflowuid), and the container process will not be allowed access unless the object is accessible by "other" (world readable/writable). - -If you have a file owned by "real" root with permissions [660][5], and the container processes in the user namespace attempt to read it, they will be prevented from accessing it and will see the file as owned by nobody. - -### An example - -Here's how that might work. First, I create a file in my system owned by root. - -``` -$ sudo bash -c "echo Test > /tmp/test" -$ sudo chmod 600 /tmp/test -$ sudo ls -l /tmp/test --rw-------. 1 root root 5 Dec 17 16:40 /tmp/test -``` - -Next, I volume-mount the file into a container running with a user namespace map 0:100000:5000. - -``` -$ sudo podman run -ti -v /tmp/test:/tmp/test:Z --uidmap 0:100000:5000 fedora sh -# id -uid=0(root) gid=0(root) groups=0(root) -# ls -l /tmp/test --rw-rw----. 1 nobody nobody 8 Nov 30 12:40 /tmp/test -# cat /tmp/test -cat: /tmp/test: Permission denied -``` - -The **\--uidmap** setting above tells Podman to map a range of 5000 UIDs inside the container, starting with UID 100000 outside the container (so the range is 100000-104999) to a range starting at UID 0 inside the container (so the range is 0-4999). Inside the container, if my process is running as UID 1, it is 100001 on the host - -Since the real UID=0 is not mapped into the container, any file owned by root will be treated as owned by nobody. Even if the process inside the container has **CAP_DAC_OVERRIDE** , it can't override this protection. **DAC_OVERRIDE** enables root processes to read/write any file on the system, even if the process was not owned by root or world readable or writable. - -User namespace capabilities are not the same as capabilities on the host. They are namespaced capabilities. This means my container root has capabilities only within the container—really only across the range of UIDs that were mapped into the user namespace. If a container process escaped the container, it wouldn't have any capabilities over UIDs not mapped into the user namespace, including UID=0. Even if the processes could somehow enter another container, they would not have those capabilities if the container uses a different range of UIDs. - -Note that SELinux and other technologies also limit what would happen if a container process broke out of the container. - -### Using `podman top` to show user namespaces - -We have added features to **podman top** to allow you to examine the usernames of processes running inside a container and identify their real UIDs on the host. - -Let's start by running a sleep container using our UID mapping. - -``` -$ sudo podman run --uidmap 0:100000:5000 -d fedora sleep 1000 -``` - -Now run **podman top** : - -``` -$ sudo podman top --latest user huser -USER   HUSER -root   100000 - -$ ps -ef | grep sleep -100000   21821 21809  0 08:04 ?         00:00:00 /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 1000 -``` - -Notice **podman top** reports that the user process is running as root inside the container but as UID 100000 on the host (HUSER). Also the **ps** command confirms that the sleep process is running as UID 100000. - -Now let's run a second container, but this time we will choose a separate UID map starting at 200000. - -``` -$ sudo podman run --uidmap 0:200000:5000 -d fedora sleep 1000 -$ sudo podman top --latest user huser -USER   HUSER -root   200000 - -$ ps -ef | grep sleep -100000   21821 21809  0 08:04 ?         00:00:00 /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 1000 -200000   23644 23632  1 08:08 ?         00:00:00 /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 1000 -``` - -Notice that **podman top** reports the second container is running as root inside the container but as UID=200000 on the host. - -Also look at the **ps** command—it shows both sleep processes running: one as 100000 and the other as 200000. - -This means running the containers inside separate user namespaces gives you traditional UID separation between processes, which has been the standard security tool of Linux/Unix from the beginning. - -### Problems with user namespaces - -For several years, I've advocated user namespace as the security tool everyone wants but hardly anyone has used. The reason is there hasn't been any filesystem support or a shifting file system. - -In containers, you want to share the **base** image between lots of containers. The examples above use the Fedora base image in each example. Most of the files in the Fedora image are owned by real UID=0. If I run a container on this image with the user namespace 0:100000:5000, by default it sees all of these files as owned by nobody, so we need to shift all of these UIDs to match the user namespace. For years, I've wanted a mount option to tell the kernel to remap these file UIDs to match the user namespace. Upstream kernel storage developers continue to investigate and make progress on this feature, but it is a difficult problem. - - -Podman can use different user namespaces on the same image because of automatic [chowning][6] built into [containers/storage][7] by a team led by Nalin Dahyabhai. Podman uses containers/storage, and the first time Podman uses a container image in a new user namespace, container/storage "chowns" (i.e., changes ownership for) all files in the image to the UIDs mapped in the user namespace and creates a new image. Think of this as the **fedora:0:100000:5000** image. - -When Podman runs another container on the image with the same UID mappings, it uses the "pre-chowned" image. When I run the second container on 0:200000:5000, containers/storage creates a second image, let's call it **fedora:0:200000:5000**. - -Note if you are doing a **podman build** or **podman commit** and push the newly created image to a container registry, Podman will use container/storage to reverse the shift and push the image with all files chowned back to real UID=0. - -This can cause a real slowdown in creating containers in new UID mappings since the **chown** can be slow depending on the number of files in the image. Also, on a normal [OverlayFS][8], every file in the image gets copied up. The normal Fedora image can take up to 30 seconds to finish the chown and start the container. - -Luckily, the Red Hat kernel storage team, primarily Vivek Goyal and Miklos Szeredi, added a new feature to OverlayFS in kernel 4.19. The feature is called **metadata only copy-up**. If you mount an overlay filesystem with **metacopy=on** as a mount option, it will not copy up the contents of the lower layers when you change file attributes; the kernel creates new inodes that include the attributes with references pointing at the lower-level data. It will still copy up the contents if the content changes. This functionality is available in the Red Hat Enterprise Linux 8 Beta, if you want to try it out. - -This means container chowning can happen in a couple of seconds, and you won't double the storage space for each container. - -This makes running containers with tools like Podman in separate user namespaces viable, greatly increasing the security of the system. - -### Going forward - -I want to add a new flag, like **\--userns=auto** , to Podman that will tell it to automatically pick a unique user namespace for each container you run. This is similar to the way SELinux works with separate multi-category security (MCS) labels. If you set the environment variable **PODMAN_USERNS=auto** , you won't even need to set the flag. - -Podman is finally allowing users to run containers in separate user namespaces. Tools like [Buildah][9] and [CRI-O][10] will also be able to take advantage of user namespaces. For CRI-O, however, Kubernetes needs to understand which user namespace will run the container engine, and the upstream is working on that. - -In my next article, I will explain how to run Podman as non-root in a user namespace. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/12/podman-and-user-namespaces - -作者:[Daniel J Walsh][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/rhatdan -[b]: https://github.com/lujun9972 -[1]: https://podman.io/ -[2]: https://github.com/containers/libpod -[3]: https://opensource.com/article/18/10/podman-more-secure-way-run-containers -[4]: http://man7.org/linux/man-pages/man7/user_namespaces.7.html -[5]: https://chmodcommand.com/chmod-660/ -[6]: https://en.wikipedia.org/wiki/Chown -[7]: https://github.com/containers/storage -[8]: https://en.wikipedia.org/wiki/OverlayFS -[9]: https://buildah.io/ -[10]: http://cri-o.io/ diff --git a/sources/tech/20181215 New talk- High Reliability Infrastructure Migrations.md b/sources/tech/20181215 New talk- High Reliability Infrastructure Migrations.md new file mode 100644 index 0000000000..93755329c7 --- /dev/null +++ b/sources/tech/20181215 New talk- High Reliability Infrastructure Migrations.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (New talk: High Reliability Infrastructure Migrations) +[#]: via: (https://jvns.ca/blog/2018/12/15/new-talk--high-reliability-infrastructure-migrations/) +[#]: author: (Julia Evans https://jvns.ca/) + +New talk: High Reliability Infrastructure Migrations +====== + +On Tuesday I gave a talk at KubeCon called [High Reliability Infrastructure Migrations][1]. The abstract was: + +> For companies with high availability requirements (99.99% uptime or higher), running new software in production comes with a lot of risks. But it’s possible to make significant infrastructure changes while maintaining the availability your customers expect! I’ll give you a toolbox for derisking migrations and making infrastructure changes with confidence, with examples from our Kubernetes & Envoy experience at Stripe. + +### video + +#### slides + +Here are the slides: + +since everyone always asks, I drew them in the Notability app on an iPad. I do this because it’s faster than trying to use regular slides software and I can make better slides. + +### a few notes + +Here are a few links & notes about things I mentioned in the talk + +#### skycfg: write functions, not YAML + +I talked about how my team is working on non-YAML interfaces for configuring Kubernetes. The demo is at [skycfg.fun][2], and it’s [on GitHub here][3]. It’s based on [Starlark][4], a configuration language that’s a subset of Python. + +My coworker [John][5] has promised that he’ll write a blog post about it at some point, and I’m hoping that’s coming soon :) + +#### no haunted forests + +I mentioned a deploy system rewrite we did. John has a great blog post about when rewrites are a good idea and how he approached that rewrite called [no haunted forests][6]. + +#### ignore most kubernetes ecosystem software + +One small point that I made in the talk was that on my team we ignore almost all software in the Kubernetes ecosystem so that we can focus on a few core pieces (Kubernetes & Envoy, plus some small things like kiam). I wanted to mention this because I think often in Kubernetes land it can seem like everyone is using Cool New Things (helm! istio! knative! eep!). I’m sure those projects are great but I find it much simpler to stay focused on the basics and I wanted people to know that it’s okay to do that if that’s what works for your company. + +I think the reality is that actually a lot of folks are still trying to work out how to use this new software in a reliable and secure way. + +#### other talks + +I haven’t watched other Kubecon talks yet, but here are 2 links: + +I heard good things about [this keynote from melanie cebula about kubernetes at airbnb][7], and I’m excited to see [this talk about kubernetes security][8]. The [slides from that security talk look useful][9] + +Also I’m very excited to see Kelsey Hightower’s keynote as always, but that recording isn’t up yet. If you have other Kubecon talks to recommend I’d love to know what they are. + +#### my first work talk I’m happy with + +I usually give talks about debugging tools, or side projects, or how I approach my job at a high level – not on the actual work that I do at my job. What I talked about in this talk is basically what I’ve been learning how to do at work for the last ~2 years. Figuring out how to make big infrastructure changes safely took me a long time (and I’m not done!), and so I hope this talk helps other folks do the same thing. + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2018/12/15/new-talk--high-reliability-infrastructure-migrations/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://www.youtube.com/watch?v=obB2IvCv-K0 +[2]: http://skycfg.fun +[3]: https://github.com/stripe/skycfg +[4]: https://github.com/bazelbuild/starlark +[5]: https://john-millikin.com/ +[6]: https://john-millikin.com/sre-school/no-haunted-forests +[7]: https://www.youtube.com/watch?v=ytu3aUCwlSg&index=127&t=0s&list=PLj6h78yzYM2PZf9eA7bhWnIh_mK1vyOfU +[8]: https://www.youtube.com/watch?v=a03te8xEjUg&index=65&list=PLj6h78yzYM2PZf9eA7bhWnIh_mK1vyOfU&t=0s +[9]: https://schd.ws/hosted_files/kccna18/1c/KubeCon%20NA%20-%20This%20year%2C%20it%27s%20about%20security%20-%2020181211.pdf diff --git a/sources/tech/20181220 Getting started with Prometheus.md b/sources/tech/20181220 Getting started with Prometheus.md deleted file mode 100644 index 79704addb7..0000000000 --- a/sources/tech/20181220 Getting started with Prometheus.md +++ /dev/null @@ -1,166 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Getting started with Prometheus) -[#]: via: (https://opensource.com/article/18/12/introduction-prometheus) -[#]: author: (Michael Zamot https://opensource.com/users/mzamot) - -Getting started with Prometheus -====== -Learn to install and write queries for the Prometheus monitoring and alerting system. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_sysadmin_cloud.png?itok=sUciG0Cn) - -[Prometheus][1] is an open source monitoring and alerting system that directly scrapes metrics from agents running on the target hosts and stores the collected samples centrally on its server. Metrics can also be pushed using plugins like **collectd_exporter** —although this is not Promethius' default behavior, it may be useful in some environments where hosts are behind a firewall or prohibited from opening ports by security policy. - -Prometheus, a project of the [Cloud Native Computing Foundation][2], scales up using a federation model, which enables one Prometheus server to scrape another Prometheus server. This allows creation of a hierarchical topology, where a central system or higher-level Prometheus server can scrape aggregated data already collected from subordinate instances. - -Besides the Prometheus server, its most common components are its [Alertmanager][3] and its exporters. - -Alerting rules can be created within Prometheus and configured to send custom alerts to Alertmanager. Alertmanager then processes and handles these alerts, including sending notifications through different mechanisms like email or third-party services like [PagerDuty][4]. - -Prometheus' exporters can be libraries, processes, devices, or anything else that exposes the metrics that will be scraped by Prometheus. The metrics are available at the endpoint **/metrics** , which allows Prometheus to scrape them directly without needing an agent. The tutorial in this article uses **node_exporter** to expose the target hosts' hardware and operating system metrics. Exporters' outputs are plaintext and highly readable, which is one of Prometheus' strengths. - -In addition, you can configure [Grafana][5] to use Prometheus as a backend to provide data visualization and dashboarding functions. - -### Making sense of Prometheus' configuration file - -The number of seconds between when **/metrics** is scraped controls the granularity of the time-series database. This is defined in the configuration file as the **scrape_interval** parameter, which by default is set to 60 seconds. - -Targets are set for each scrape job in the **scrape_configs** section. Each job has its own name and a set of labels that can help filter, categorize, and make it easier to identify the target. One job can have many targets. - -### Installing Prometheus - -In this tutorial, for simplicity, we will install a Prometheus server and **node_exporter** with docker. Docker should already be installed and configured properly on your system. For a more in-depth, automated method, I recommend Steve Ovens' article [How to use Ansible to set up system monitoring with Prometheus][6]. - -Before starting, create the Prometheus configuration file **prometheus.yml** in your work directory as follows: - -``` -global: -  scrape_interval:      15s -  evaluation_interval: 15s - -scrape_configs: -  - job_name: 'prometheus' - -        static_configs: -        - targets: ['localhost:9090'] - -  - job_name: 'webservers' - -        static_configs: -        - targets: [':9100'] -``` - -Start Prometheus with Docker by running the following command: - -``` -$ sudo docker run -d -p 9090:9090 -v -/path/to/prometheus.yml:/etc/prometheus/prometheus.yml -prom/prometheus -``` - -By default, the Prometheus server will use port 9090. If this port is already in use, you can change it by adding the parameter **\--web.listen-address=" :"** at the end of the previous command. - -In the machine you want to monitor, download and run the **node_exporter** container by using the following command: - -``` -$ sudo docker run -d -v "/proc:/host/proc" -v "/sys:/host/sys" -v -"/:/rootfs" --net="host" prom/node-exporter --path.procfs -/host/proc --path.sysfs /host/sys --collector.filesystem.ignored- -mount-points "^/(sys|proc|dev|host|etc)($|/)" -``` - -For the purposes of this learning exercise, you can install **node_exporter** and Prometheus on the same machine. Please note that it's not wise to run **node_exporter** under Docker in production—this is for testing purposes only. - -To verify that **node_exporter** is running, open your browser and navigate to **http:// :9100/metrics**. All the metrics collected will be displayed; these are the same metrics Prometheus will scrape. - -![](https://opensource.com/sites/default/files/uploads/check-node_exporter.png) - -To verify the Prometheus server installation, open your browser and navigate to . - -You should see the Prometheus interface. Click on **Status** and then **Targets**. Under State, you should see your machines listed as **UP**. - -![](https://opensource.com/sites/default/files/uploads/targets-up.png) - -### Using Prometheus queries - -It's time to get familiar with [PromQL][7], Prometheus' query syntax, and its graphing web interface. Go to **** on your Prometheus server. You will see a query editor and two tabs: Graph and Console. - -Prometheus stores all data as time series, identifying each one with a metric name. For example, the metric **node_filesystem_avail_bytes** shows the available filesystem space. The metric's name can be used in the expression box to select all of the time series with this name and produce an instant vector. If desired, these time series can be filtered using selectors and labels—a set of key-value pairs—for example: - -``` -node_filesystem_avail_bytes{fstype="ext4"} -``` - -When filtering, you can match "exactly equal" ( **=** ), "not equal" ( **!=** ), "regex-match" ( **=~** ), and "do not regex-match" ( **!~** ). The following examples illustrate this: - -To filter **node_filesystem_avail_bytes** to show both ext4 and XFS filesystems: - -``` -node_filesystem_avail_bytes{fstype=~"ext4|xfs"} -``` - -To exclude a match: - -``` -node_filesystem_avail_bytes{fstype!="xfs"} -``` - -You can also get a range of samples back from the current time by using square brackets. You can use **s** to represent seconds, **m** for minutes, **h** for hours, **d** for days, **w** for weeks, and **y** for years. When using time ranges, the vector returned will be a range vector. - -For example, the following command produces the samples from five minutes to the present: - -``` -node_memory_MemAvailable_bytes[5m] -``` - -Prometheus also includes functions to allow advanced queries, such as this: - -``` -100 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated (1 - avg by(instance)(irate(node_cpu_seconds_total{job='webservers',mode='idle'}[5m]))) -``` - -Notice how the labels are used to filter the job and the mode. The metric **node_cpu_seconds_total** returns a counter, and the **irate()** function calculates the per-second rate of change based on the last two data points of the range interval (meaning the range can be smaller than five minutes). To calculate the overall CPU usage, you can use the idle mode of the **node_cpu_seconds_total** metric. The idle percent of a processor is the opposite of a busy processor, so the **irate** value is subtracted from 1. To make it a percentage, multiply it by 100. - -![](https://opensource.com/sites/default/files/uploads/cpu-usage.png) - -### Learn more - -Prometheus is a powerful, scalable, lightweight, and easy to use and deploy monitoring tool that is indispensable for every system administrator and developer. For these and other reasons, many companies are implementing Prometheus as part of their infrastructure. - -To learn more about Prometheus and its functions, I recommend the following resources: - -+ About [PromQL][8] -+ What [node_exporters collects][9] -+ [Prometheus functions][10] -+ [4 open source monitoring tools][11] -+ [Now available: The open source guide to DevOps monitoring tools][12] - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/12/introduction-prometheus - -作者:[Michael Zamot][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/mzamot -[b]: https://github.com/lujun9972 -[1]: https://prometheus.io/ -[2]: https://www.cncf.io/ -[3]: https://prometheus.io/docs/alerting/alertmanager/ -[4]: https://en.wikipedia.org/wiki/PagerDuty -[5]: https://grafana.com/ -[6]: https://opensource.com/article/18/3/how-use-ansible-set-system-monitoring-prometheus -[7]: https://prometheus.io/docs/prometheus/latest/querying/basics/ -[8]: https://prometheus.io/docs/prometheus/latest/querying/basics/ -[9]: https://github.com/prometheus/node_exporter#collectors -[10]: https://prometheus.io/docs/prometheus/latest/querying/functions/ -[11]: https://opensource.com/article/18/8/open-source-monitoring-tools -[12]: https://opensource.com/article/18/8/now-available-open-source-guide-devops-monitoring-tools diff --git a/sources/tech/20181222 How to detect automatically generated emails.md b/sources/tech/20181222 How to detect automatically generated emails.md deleted file mode 100644 index 23b509a77b..0000000000 --- a/sources/tech/20181222 How to detect automatically generated emails.md +++ /dev/null @@ -1,144 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to detect automatically generated emails) -[#]: via: (https://arp242.net/weblog/autoreply.html) -[#]: author: (Martin Tournoij https://arp242.net/) - -How to detect automatically generated emails -====== - -### How to detect automatically generated emails - - -When you send out an auto-reply from an email system you want to take care to not send replies to automatically generated emails. At best, you will get a useless delivery failure. At words, you will get an infinite email loop and a world of chaos. - -Turns out that reliably detecting automatically generated emails is not always easy. Here are my observations based on writing a detector for this and scanning about 100,000 emails with it (extensive personal archive and company archive). - -### Auto-submitted header - -Defined in [RFC 3834][1]. - -This is the ‘official’ standard way to indicate your message is an auto-reply. You should **not** send a reply if `Auto-Submitted` is present and has a value other than `no`. - -### X-Auto-Response-Suppress header - -Defined [by Microsoft][2] - -This header is used by Microsoft Exchange, Outlook, and perhaps some other products. Many newsletters and such also set this. You should **not** send a reply if `X-Auto-Response-Suppress` contains `DR` (“Suppress delivery reports”), `AutoReply` (“Suppress auto-reply messages other than OOF notifications”), or `All`. - -### List-Id and List-Unsubscribe headers - -Defined in [RFC 2919][3] - -You usually don’t want to send auto-replies to mailing lists or news letters. Pretty much all mail lists and most newsletters set at least one of these headers. You should **not** send a reply if either of these headers is present. The value is unimportant. - -### Feedback-ID header - -Defined [by Google][4]. - -Gmail uses this header to identify mail newsletters, and uses it to generate statistics/reports for owners of those newsletters. You should **not** send a reply if this headers is present; the value is unimportant. - -### Non-standard ways - -The above methods are well-defined and clear (even though some are non-standard). Unfortunately some email systems do not use any of them :-( Here are some additional measures. - -#### Precedence header - -Not really defined anywhere, mentioned in [RFC 2076][5] where its use is discouraged (but this header is commonly encountered). - -Note that checking for the existence of this field is not recommended, as some ails use `normal` and some other (obscure) values (this is not very common though). - -My recommendation is to **not** send a reply if the value case-insensitively matches `bulk`, `auto_reply`, or `list`. - -#### Other obscure headers - -A collection of other (somewhat obscure) headers I’ve encountered. I would recommend **not** sending an auto-reply if one of these is set. Most mails also set one of the above headers, but some don’t (but it’s not very common). - - * `X-MSFBL`; can’t really find a definition (Microsoft header?), but I only have auto-generated mails with this header. - - * `X-Loop`; not really defined anywhere, and somewhat rare, but sometimes it’s set. It’s most often set to the address that should not get emails, but `X-Loop: yes` is also encountered. - - * `X-Autoreply`; fairly rare, and always seems to have a value of `yes`. - - - - -#### Email address - -Check if the `From` or `Reply-To` headers contains `noreply`, `no-reply`, or `no_reply` (regex: `^no.?reply@`). - -#### HTML only - -If an email only has a HTML part, but no text part it’s a good indication this is an auto-generated mail or newsletter. Pretty much all mail clients also set a text part. - -#### Delivery failures - -Many delivery failure messages don’t really indicate that they’re failures. Some ways to check this: - - * `From` contains `mailer-daemon` or `Mail Delivery Subsystem` - - - -Many mail libraries leave some sort of footprint, and most regular mail clients override this with their own data. Checking for this seems to work fairly well. - - * `X-Mailer: Microsoft CDO for Windows 2000` – Set by some MS software; I can only find it on autogenerated mails. Yes, it’s still used in 2015. - - * `Message-ID` header contains `.JavaMail.` – I’ve found a few (5 on 50k) regular messages with this, but not many; the vast majority (thousends) of messages are news-letters, order confirmations, etc. - - * `^X-Mailer` starts with `PHP`. This should catch both `X-Mailer: PHP/5.5.0` and `X-Mailer: PHPmailer blah blah`. The same as `JavaMail` applies. - - * `X-Library` presence; only [Indy][6] seems to set this. - - * `X-Mailer` starts with `wdcollect`. Set by some Plesk mails. - - * `X-Mailer` starts with `MIME-tools`. - - - - -### Final precaution: limit the number of replies - -Even when following all of the above advice, you may still encounter an email program that will slip through. This can very dangerous, as email systems that simply `IF email THEN send_email` have the potential to cause infinite email loops. - -For this reason, I recommend keeping track of which emails you’ve sent an autoreply to and rate limiting this to at most n emails in n minutes. This will break the back-and-forth chain. - -We use one email per five minutes, but something less strict will probably also work well. - -### What you need to set on your auto-response - -The specifics for this will vary depending on what sort of mails you’re sending. This is what we use for auto-reply mails: - -``` -Auto-Submitted: auto-replied -X-Auto-Response-Suppress: All -Precedence: auto_reply -``` - -### Feedback - -You can mail me at [martin@arp242.net][7] or [create a GitHub issue][8] for feedback, questions, etc. - --------------------------------------------------------------------------------- - -via: https://arp242.net/weblog/autoreply.html - -作者:[Martin Tournoij][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://arp242.net/ -[b]: https://github.com/lujun9972 -[1]: http://tools.ietf.org/html/rfc3834 -[2]: https://msdn.microsoft.com/en-us/library/ee219609(v=EXCHG.80).aspx -[3]: https://tools.ietf.org/html/rfc2919) -[4]: https://support.google.com/mail/answer/6254652?hl=en -[5]: http://www.faqs.org/rfcs/rfc2076.html -[6]: http://www.indyproject.org/index.en.aspx -[7]: mailto:martin@arp242.net -[8]: https://github.com/Carpetsmoker/arp242.net/issues/new diff --git a/sources/tech/20181227 Linux commands for measuring disk activity.md b/sources/tech/20181227 Linux commands for measuring disk activity.md deleted file mode 100644 index badda327dd..0000000000 --- a/sources/tech/20181227 Linux commands for measuring disk activity.md +++ /dev/null @@ -1,252 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Linux commands for measuring disk activity) -[#]: via: (https://www.networkworld.com/article/3330497/linux/linux-commands-for-measuring-disk-activity.html) -[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) - -Linux commands for measuring disk activity -====== -![](https://images.idgesg.net/images/article/2018/12/tape-measure-100782593-large.jpg) -Linux systems provide a handy suite of commands for helping you see how busy your disks are, not just how full. In this post, we examine five very useful commands for looking into disk activity. Two of the commands (iostat and ioping) may have to be added to your system, and these same two commands require you to use sudo privileges, but all five commands provide useful ways to view disk activity. - -Probably one of the easiest and most obvious of these commands is **dstat**. - -### dtstat - -In spite of the fact that the **dstat** command begins with the letter "d", it provides stats on a lot more than just disk activity. If you want to view just disk activity, you can use the **-d** option. As shown below, you’ll get a continuous list of disk read/write measurements until you stop the display with a ^c. Note that after the first report, each subsequent row in the display will report disk activity in the following time interval, and the default is only one second. - -``` -$ dstat -d --dsk/total- - read writ - 949B 73k - 65k 0 <== first second - 0 24k <== second second - 0 16k - 0 0 ^C -``` - -Including a number after the -d option will set the interval to that number of seconds. - -``` -$ dstat -d 10 --dsk/total- - read writ - 949B 73k - 65k 81M <== first five seconds - 0 21k <== second five second - 0 9011B ^C -``` - -Notice that the reported data may be shown in a number of different units — e.g., M (megabytes), k (kilobytes), and B (bytes). - -Without options, the dstat command is going to show you a lot of other information as well — indicating how the CPU is spending its time, displaying network and paging activity, and reporting on interrupts and context switches. - -``` -$ dstat -You did not select any stats, using -cdngy by default. ---total-cpu-usage-- -dsk/total- -net/total- ---paging-- ---system-- -usr sys idl wai stl| read writ| recv send| in out | int csw - 0 0 100 0 0| 949B 73k| 0 0 | 0 3B| 38 65 - 0 0 100 0 0| 0 0 | 218B 932B| 0 0 | 53 68 - 0 1 99 0 0| 0 16k| 64B 468B| 0 0 | 64 81 ^C -``` - -The dstat command provides valuable insights into overall Linux system performance, pretty much replacing a collection of older tools, such as vmstat, netstat, iostat, and ifstat, with a flexible and powerful command that combines their features. For more insight into the other information that the dstat command can provide, refer to this post on the [dstat][1] command. - -### iostat - -The iostat command helps monitor system input/output device loading by observing the time the devices are active in relation to their average transfer rates. It's sometimes used to evaluate the balance of activity between disks. - -``` -$ iostat -Linux 4.18.0-041800-generic (butterfly) 12/26/2018 _x86_64_ (2 CPU) - -avg-cpu: %user %nice %system %iowait %steal %idle - 0.07 0.01 0.03 0.05 0.00 99.85 - -Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn -loop0 0.00 0.00 0.00 1048 0 -loop1 0.00 0.00 0.00 365 0 -loop2 0.00 0.00 0.00 1056 0 -loop3 0.00 0.01 0.00 16169 0 -loop4 0.00 0.00 0.00 413 0 -loop5 0.00 0.00 0.00 1184 0 -loop6 0.00 0.00 0.00 1062 0 -loop7 0.00 0.00 0.00 5261 0 -sda 1.06 0.89 72.66 2837453 232735080 -sdb 0.00 0.02 0.00 48669 40 -loop8 0.00 0.00 0.00 1053 0 -loop9 0.01 0.01 0.00 18949 0 -loop10 0.00 0.00 0.00 56 0 -loop11 0.00 0.00 0.00 7090 0 -loop12 0.00 0.00 0.00 1160 0 -loop13 0.00 0.00 0.00 108 0 -loop14 0.00 0.00 0.00 3572 0 -loop15 0.01 0.01 0.00 20026 0 -loop16 0.00 0.00 0.00 24 0 -``` - -Of course, all the stats provided on Linux loop devices can clutter the display when you want to focus solely on your disks. The command, however, does provide the **-p** option, which allows you to just look at your disks — as shown in the commands below. - -``` -$ iostat -p sda -Linux 4.18.0-041800-generic (butterfly) 12/26/2018 _x86_64_ (2 CPU) - -avg-cpu: %user %nice %system %iowait %steal %idle - 0.07 0.01 0.03 0.05 0.00 99.85 - -Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn -sda 1.06 0.89 72.54 2843737 232815784 -sda1 1.04 0.88 72.54 2821733 232815784 -``` - -Note that **tps** refers to transfers per second. - -You can also get iostat to provide repeated reports. In the example below, we're getting measurements every five seconds by using the **-d** option. - -``` -$ iostat -p sda -d 5 -Linux 4.18.0-041800-generic (butterfly) 12/26/2018 _x86_64_ (2 CPU) - -Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn -sda 1.06 0.89 72.51 2843749 232834048 -sda1 1.04 0.88 72.51 2821745 232834048 - -Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn -sda 0.80 0.00 11.20 0 56 -sda1 0.80 0.00 11.20 0 56 -``` - -If you prefer to omit the first (stats since boot) report, add a **-y** to your command. - -``` -$ iostat -p sda -d 5 -y -Linux 4.18.0-041800-generic (butterfly) 12/26/2018 _x86_64_ (2 CPU) - -Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn -sda 0.80 0.00 11.20 0 56 -sda1 0.80 0.00 11.20 0 56 -``` - -Next, we look at our second disk drive. - -``` -$ iostat -p sdb -Linux 4.18.0-041800-generic (butterfly) 12/26/2018 _x86_64_ (2 CPU) - -avg-cpu: %user %nice %system %iowait %steal %idle - 0.07 0.01 0.03 0.05 0.00 99.85 - -Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn -sdb 0.00 0.02 0.00 48669 40 -sdb2 0.00 0.00 0.00 4861 40 -sdb1 0.00 0.01 0.00 35344 0 -``` - -### iotop - -The **iotop** command is top-like utility for looking at disk I/O. It gathers I/O usage information provided by the Linux kernel so that you can get an idea which processes are most demanding in terms in disk I/O. In the example below, the loop time has been set to 5 seconds. The display will update itself, overwriting the previous output. - -``` -$ sudo iotop -d 5 -Total DISK READ: 0.00 B/s | Total DISK WRITE: 1585.31 B/s -Current DISK READ: 0.00 B/s | Current DISK WRITE: 12.39 K/s - TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND -32492 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.12 % [kworker/u8:1-ev~_power_efficient] - 208 be/3 root 0.00 B/s 1585.31 B/s 0.00 % 0.11 % [jbd2/sda1-8] - 1 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % init splash - 2 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kthreadd] - 3 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [rcu_gp] - 4 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [rcu_par_gp] - 8 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [mm_percpu_wq] -``` - -### ioping - -The **ioping** command is an altogether different type of tool, but it can report disk latency — how long it takes a disk to respond to requests — and can be helpful in diagnosing disk problems. - -``` -$ sudo ioping /dev/sda1 -4 KiB <<< /dev/sda1 (block device 111.8 GiB): request=1 time=960.2 us (warmup) -4 KiB <<< /dev/sda1 (block device 111.8 GiB): request=2 time=841.5 us -4 KiB <<< /dev/sda1 (block device 111.8 GiB): request=3 time=831.0 us -4 KiB <<< /dev/sda1 (block device 111.8 GiB): request=4 time=1.17 ms -^C ---- /dev/sda1 (block device 111.8 GiB) ioping statistics --- -3 requests completed in 2.84 ms, 12 KiB read, 1.05 k iops, 4.12 MiB/s -generated 4 requests in 3.37 s, 16 KiB, 1 iops, 4.75 KiB/s -min/avg/max/mdev = 831.0 us / 947.9 us / 1.17 ms / 158.0 us -``` - -### atop - -The **atop** command, like **top** provides a lot of information on system performance, including some stats on disk activity. - -``` -ATOP - butterfly 2018/12/26 17:24:19 37d3h13m------ 10ed -PRC | sys 0.03s | user 0.01s | #proc 179 | #zombie 0 | #exit 6 | -CPU | sys 1% | user 0% | irq 0% | idle 199% | wait 0% | -cpu | sys 1% | user 0% | irq 0% | idle 99% | cpu000 w 0% | -CPL | avg1 0.00 | avg5 0.00 | avg15 0.00 | csw 677 | intr 470 | -MEM | tot 5.8G | free 223.4M | cache 4.6G | buff 253.2M | slab 394.4M | -SWP | tot 2.0G | free 2.0G | | vmcom 1.9G | vmlim 4.9G | -DSK | sda | busy 0% | read 0 | write 7 | avio 1.14 ms | -NET | transport | tcpi 4 | tcpo stall 8 | udpi 1 | udpo 0swout 2255 | -NET | network | ipi 10 | ipo 7 | ipfrw 0 | deliv 60.67 ms | -NET | enp0s25 0% | pcki 10 | pcko 8 | si 1 Kbps | so 3 Kbp0.73 ms | - - PID SYSCPU USRCPU VGROW RGROW ST EXC THR S CPUNR CPU CMD 1/1673e4 | - 3357 0.01s 0.00s 672K 824K -- - 1 R 0 0% atop - 3359 0.01s 0.00s 0K 0K NE 0 0 E - 0% - 3361 0.00s 0.01s 0K 0K NE 0 0 E - 0% - 3363 0.01s 0.00s 0K 0K NE 0 0 E - 0% -31357 0.00s 0.00s 0K 0K -- - 1 S 1 0% bash - 3364 0.00s 0.00s 8032K 756K N- - 1 S 1 0% sleep - 2931 0.00s 0.00s 0K 0K -- - 1 I 1 0% kworker/u8:2-e - 3356 0.00s 0.00s 0K 0K -E 0 0 E - 0% - 3360 0.00s 0.00s 0K 0K NE 0 0 E - 0% - 3362 0.00s 0.00s 0K 0K NE 0 0 E - 0% -``` - -If you want to look at _just_ the disk stats, you can easily manage that with a command like this: - -``` -$ atop | grep DSK -$ atop | grep DSK -DSK | sda | busy 0% | read 122901 | write 3318e3 | avio 0.67 ms | -DSK | sdb | busy 0% | read 1168 | write 103 | avio 0.73 ms | -DSK | sda | busy 2% | read 0 | write 92 | avio 2.39 ms | -DSK | sda | busy 2% | read 0 | write 94 | avio 2.47 ms | -DSK | sda | busy 2% | read 0 | write 99 | avio 2.26 ms | -DSK | sda | busy 2% | read 0 | write 94 | avio 2.43 ms | -DSK | sda | busy 2% | read 0 | write 94 | avio 2.43 ms | -DSK | sda | busy 2% | read 0 | write 92 | avio 2.43 ms | -^C -``` - -### Being in the know with disk I/O - -Linux provides enough commands to give you good insights into how hard your disks are working and help you focus on potential problems or slowdowns. Hopefully, one of these commands will tell you just what you need to know when it's time to question disk performance. Occasional use of these commands will help ensure that especially busy or slow disks will be obvious when you need to check them. - -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/3330497/linux/linux-commands-for-measuring-disk-activity.html - -作者:[Sandra Henry-Stocker][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ -[b]: https://github.com/lujun9972 -[1]: https://www.networkworld.com/article/3291616/linux/examining-linux-system-performance-with-dstat.html -[2]: https://www.facebook.com/NetworkWorld/ -[3]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20181228 The office coffee model of concurrent garbage collection.md b/sources/tech/20181228 The office coffee model of concurrent garbage collection.md new file mode 100644 index 0000000000..825eb4b536 --- /dev/null +++ b/sources/tech/20181228 The office coffee model of concurrent garbage collection.md @@ -0,0 +1,62 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The office coffee model of concurrent garbage collection) +[#]: via: (https://dave.cheney.net/2018/12/28/the-office-coffee-model-of-concurrent-garbage-collection) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +The office coffee model of concurrent garbage collection +====== + +Garbage collection is a field with its own terminology. Concepts like like _mutator_ s, _card marking_ , and _write barriers_ create a hurdle to understanding how garbage collectors work. Here’s an analogy to explain the operations of a concurrent garbage collector using everyday items found in the workplace. + +Before we discuss the operation of _concurrent_ garbage collection, let’s introduce the dramatis personae. In offices around the world you’ll find one of these: + +![][1] + +In the workplace coffee is a natural resource. Employees visit the break room and fill their cups as required. That is, until the point someone goes to fill their cup only to discover the pot is _empty_! + +Immediately the office is thrown into chaos. Meeting are called. Investigations are held. The perpetrator who took the last cup without refilling the machine is found and [reprimanded][2]. Despite many passive aggressive notes the situation keeps happening, thus a committee is formed to decide if a larger coffee pot should be requisitioned. Once the coffee maker is again full office productivity slowly returns to normal. + +This is the model of _stop the world_ garbage collection. The various parts of your program proceed through their day consuming memory, or in our analogy coffee, without a care about the next allocation that needs to be made. Eventually one unlucky attempt to allocate memory is made only to find the heap, or the coffee pot, exhausted, triggering a stop the world garbage collection. + +* * * + +Down the road at a more enlightened workplace, management have adopted a different strategy for mitigating their break room’s coffee problems. Their policy is simple: if the pot is more than half full, fill your cup and be on your way. However, if the pot is less than half full, _before_ filling your cup, you must add a little coffee and a little water to the top of the machine. In this way, by the time the next person arrives for their re-up, the level in the pot will hopefully have risen higher than when the first person found it. + +This policy does come at a cost to office productivity. Rather than filling their cup and hoping for the best, each worker may, depending on the aggregate level of consumption in the office, have to spend a little time refilling the percolator and topping up the water. However, this is time spent by a person who was already heading to the break room. It costs a few extra minutes to maintain the coffee machine, but does not impact their officemates who aren’t in need of caffeination. If several people take a break at the same time, they will all find the level in the pot below the half way mark and all proceed to top up the coffee maker–the more consumption, the greater the rate the machine will be refilled, although this takes a little longer as the break room becomes congested. + +This is the model of _concurrent garbage collection_ as practiced by the Go runtime (and probably other language runtimes with concurrent collectors). Rather than each heap allocation proceeding blindly until the heap is exhausted, leading to a long stop the world pause, concurrent collection algorithms spread the work of walking the heap to find memory which is no longer reachable over the parts of the program allocating memory. In this way the parts of the program which allocate memory each pay a small cost–in terms of latency–for those allocations rather than the whole program being forced to halt when the heap is exhausted. + +Lastly, in keeping with the office coffee model, if the rate of coffee consumption in the office is so high that management discovers that their staff are always in the break room trying desperately to refill the coffee machine, it’s time to invest in a machine with a bigger pot–or in garbage collection terms, grow the heap. + +### Related posts: + + 1. [Visualising the Go garbage collector][3] + 2. [A whirlwind tour of Go’s runtime environment variables][4] + 3. [Why is a Goroutine’s stack infinite ?][5] + 4. [Introducing Go 2.0][6] + + + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2018/12/28/the-office-coffee-model-of-concurrent-garbage-collection + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://dave.cheney.net/wp-content/uploads/2018/12/20181204175004_79256.jpg +[2]: https://www.youtube.com/watch?v=ww86iaucd2A +[3]: https://dave.cheney.net/2014/07/11/visualising-the-go-garbage-collector (Visualising the Go garbage collector) +[4]: https://dave.cheney.net/2015/11/29/a-whirlwind-tour-of-gos-runtime-environment-variables (A whirlwind tour of Go’s runtime environment variables) +[5]: https://dave.cheney.net/2013/06/02/why-is-a-goroutines-stack-infinite (Why is a Goroutine’s stack infinite ?) +[6]: https://dave.cheney.net/2016/10/25/introducing-go-2-0 (Introducing Go 2.0) diff --git a/sources/tech/20181229 Some nonparametric statistics math.md b/sources/tech/20181229 Some nonparametric statistics math.md new file mode 100644 index 0000000000..452c295781 --- /dev/null +++ b/sources/tech/20181229 Some nonparametric statistics math.md @@ -0,0 +1,178 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Some nonparametric statistics math) +[#]: via: (https://jvns.ca/blog/2018/12/29/some-initial-nonparametric-statistics-notes/) +[#]: author: (Julia Evans https://jvns.ca/) + +Some nonparametric statistics math +====== + +I’m trying to understand nonparametric statistics a little more formally. This post may not be that intelligible because I’m still pretty confused about nonparametric statistics, there is a lot of math, and I make no attempt to explain any of the math notation. I’m working towards being able to explain this stuff in a much more accessible way but first I would like to understand some of the math! + +There’s some MathJax in this post so the math may or may not render in an RSS reader. + +Some questions I’m interested in: + + * what is nonparametric statistics exactly? + * what guarantees can we make? are there formulas we can use? + * why do methods like the bootstrap method work? + + + +since these notes are from reading a math book and math books are extremely dense this is basically going to be “I read 7 pages of this math book and here are some points I’m confused about” + +### what’s nonparametric statistics? + +Today I’m looking at “all of nonparametric statistics” by Larry Wasserman. He defines nonparametric inference as: + +> a set of modern statistical methods that aim to keep the number of underlying assumptions as weak as possible + +Basically my interpretation of this is that – instead of assuming that your data comes from a specific family of distributions (like the normal distribution) and then trying to estimate the paramters of that distribution, you don’t make many assumptions about the distribution (“this is just some data!!“). Not having to make assumptions is nice! + +There aren’t **no** assumptions though – he says + +> we assume that the distribution $F$ lies in some set $\mathfrak{F}$ called a **statistical model**. For example, when estimating a density $f$, we might assume that $$ f \in \mathfrak{F} = \left\\{ g : \int(g^{\prime\prime}(x))^2dx \leq c^2 \right\\}$$ which is the set of densities that are not “too wiggly”. + +I have not too much intuition for the condition $\int(g^{\prime\prime}(x))^2dx \leq c^2$. I calculated that integral for [the normal distribution on wolfram alpha][1] and got 4, which is a good start. (4 is not infinity!) + +some questions I still have about this definition: + + * what’s an example of a probability density function that _doesn’t_ satisfy that $\int(g^{\prime\prime}(x))^2dx \leq c^2$ condition? (probably something with an infinite number of tiny wiggles, and I don’t think any distribution i’m interested in in practice would have an infinite number of tiny wiggles?) + * why does the density function being “too wiggly” cause problems for nonparametric inference? very unclear as yet. + + + +### we still have to assume independence + +One assumption we **won’t** get away from is that the samples in the data we’re dealing with are independent. Often data in the real world actually isn’t really independent, but I think the what people do a lot of the time is to make a good effort at something approaching independence and then close your eyes and pretend it is? + +### estimating the density function + +Okay! Here’s a useful section! Let’s say that I have 100,000 data points from a distribution. I can draw a histogram like this of those data points: + +![][2] + +If I have 100,000 data points, it’s pretty likely that that histogram is pretty close to the actual distribution. But this is math, so we should be able to make that statement precise, right? + +For example suppose that 5% of the points in my sample are more than 100. Is the probability that a point is greater than 100 **actually** 0.05? The book gives a nice formula for this: + +$$ \mathbb{P}(|\widehat{P}_n(A) - P(A)| > \epsilon ) \leq 2e^{-2n\epsilon^2} $$ + +(by [“Hoeffding’s inequality”][3] which I’ve never heard of before). Fun aside about that inequality: here’s a nice jupyter notebook by henry wallace using it to [identify the most common Boggle words][4]. + +here, in our example: + + * n is 1000 (the number of data points we have) + * $A$ is the set of points more than 100 + * $\widehat{P}_n(A)$ is the empirical probability that a point is more than 100 (0.05) + * $P(A)$ is the actual probability + * $\epsilon$ is how certain we want to be that we’re right + + + +So, what’s the probability that the **real** probability is between 0.04 and 0.06? $\epsilon = 0.01$, so it’s $2e^{-2 \times 100,000 \times (0.01)^2} = 4e^{-9} $ ish (according to wolfram alpha) + +here is a table of how sure we can be: + + * 100,000 data points: 4e-9 (TOTALLY CERTAIN that 4% - 6% of points are more than 100) + * 10,000 data points: 0.27 (27% probability that we’re wrong! that’s… not bad?) + * 1,000 data points: 1.6 (we know the probability we’re wrong is less than.. 160%? that’s not good!) + * 100 data points: lol + + + +so basically, in this case, using this formula: 100,000 data points is AMAZING, 10,000 data points is pretty good, and 1,000 is much less useful. If we have 1000 data points and we see that 5% of them are more than 100, we DEFINITELY CANNOT CONCLUDE that 4% to 6% of points are more than 100. But (using the same formula) we can use $\epsilon = 0.04$ and conclude that with 92% probability 1% to 9% of points are more than 100. So we can still learn some stuff from 1000 data points! + +This intuitively feels pretty reasonable to me – like it makes sense to me that if you have NO IDEA what your distribution that with 100,000 points you’d be able to make quite strong inferences, and that with 1000 you can do a lot less! + +### more data points are exponentially better? + +One thing that I think is really cool about this estimating the density function formula is that how sure you can be of your inferences scales **exponentially** with the size of your dataset (this is the $e^{-n\epsilon^2}$). And also exponentially with the square of how sure you want to be (so wanting to be sure within 0.01 is VERY DIFFERENT than within 0.04). So 100,000 data points isn’t 10x better than 10,000 data points, it’s actually like 10000000000000x better. + +Is that true in other places? If so that seems like a super useful intuition! I still feel pretty uncertain about this, but having some basic intuition about “how much more useful is 10,000 data points than 1,000 data points?“) feels like a really good thing. + +### some math about the bootstrap + +The next chapter is about the bootstrap! Basically the way the bootstrap works is: + + 1. you want to estimate some statistic (like the median) of your distribution + 2. the bootstrap lets you get an estimate and also the variance of that estimate + 3. you do this by repeatedly sampling with replacement from your data and then calculating the statistic you want (like the median) on your samples + + + +I’m not going to go too much into how to implement the bootstrap method because it’s explained in a lot of place on the internet. Let’s talk about the math! + +I think in order to say anything meaningful about bootstrap estimates I need to learn a new term: a **consistent estimator**. + +### What’s a consistent estimator? + +Wikipedia says: + +> In statistics, a **consistent estimator** or **asymptotically consistent estimator** is an estimator — a rule for computing estimates of a parameter $\theta_0$ — having the property that as the number of data points used increases indefinitely, the resulting sequence of estimates converges in probability to $\theta_0$. + +This includes some terms where I forget what they mean (what’s “converges in probability” again?). But this seems like a very good thing! If I’m estimating some parameter (like the median), I would DEFINITELY LIKE IT TO BE TRUE that if I do it with an infinite amount of data then my estimate works. An estimator that is not consistent does not sound very useful! + +### why/when are bootstrap estimators consistent? + +spoiler: I have no idea. The book says the following: + +> Consistency of the boostrap can now be expressed as follows. +> +> **3.19 Theorem**. Suppose that $\mathbb{E}(X_1^2) < \infty$. Let $T_n = g(\overline{X}_n)$ where $g$ is continuously differentiable at $\mu = \mathbb{E}(X_1)$ and that $g\prime(\mu) \neq 0$. Then, +> +> $$ \sup_u | \mathbb{P}_{\widehat{F}_n} \left( \sqrt{n} (T( \widehat{F}_n*) - T( \widehat{F}_n) \leq u \right) - \mathbb{P}_{\widehat{F}} \left( \sqrt{n} (T( \widehat{F}_n) - T( \widehat{F}) \leq u \right) | \rightarrow^\text{a.s.} 0 $$ +> +> **3.21 Theorem**. Suppose that $T(F)$ is Hadamard differentiable with respect to $d(F,G)= sup_x|F(x)-G(x)|$ and that $0 < \int L^2_F(x) dF(x) < \infty$. Then, +> +> $$ \sup_u | \mathbb{P}_{\widehat{F}_n} \left( \sqrt{n} (T( \widehat{F}_n*) - T( \widehat{F}_n) \leq u \right) - \mathbb{P}_{\widehat{F}} \left( \sqrt{n} (T( \widehat{F}_n) - T( \widehat{F}) \leq u \right) | \rightarrow^\text{P} 0 $$ + +things I understand about these theorems: + + * the two formulas they’re concluding are the same, except I think one is about convergence “almost surely” and one about “convergence in probability”. I don’t remember what either of those mean. + * I think for our purposes of doing Regular Boring Things we can replace “Hadamard differentiable” with “differentiable” + * I think they don’t actually show the consistency of the bootstrap, they’re actually about consistency of the bootstrap confidence interval estimate (which is a different thing) + + + +I don’t really understand how they’re related to consistency, and in particular the $\sup_u$ thing is weird, like if you’re looking at $\mathbb{P}(something < u)$, wouldn’t you want to minimize $u$ and not maximize it? Maybe it’s a typo and it should be $\inf_u$? + +it concludes: + +> there is a tendency to treat the bootstrap as a panacea for all problems. But the bootstrap requires regularity conditions to yield valid answers. It should not be applied blindly. + +### this book does not seem to explain why the bootstrap is consistent + +In the appendix (3.7) it gives a sketch of a proof for showing that estimating the **median** using the bootstrap is consistent. I don’t think this book actually gives a proof anywhere that bootstrap estimates in general are consistent, which was pretty surprising to me. It gives a bunch of references to papers. Though I guess bootstrap confidence intervals are the most important thing? + +### that’s all for now + +This is all extremely stream of consciousness and I only spent 2 hours trying to work through this, but some things I think I learned in the last couple hours are: + + 1. maybe having more data is exponentially better? (is this true??) + 2. “consistency” of an estimator is a thing, not all estimators are consistent + 3. understanding when/why nonparametric bootstrap estimators are consistent in general might be very hard (the proof that the bootstrap median estimator is consistent already seems very complicated!) + 4. boostrap confidence intervals are not the same thing as bootstrap estimators. Maybe I’ll learn the difference next! + + + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2018/12/29/some-initial-nonparametric-statistics-notes/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://www.wolframalpha.com/input/?i=integrate+(d%2Fdx(d%2Fdx(exp(-x%5E2))))%5E2++dx+from+x%3D-infinity+to+infinity +[2]: https://jvns.ca/images/nonpar-histogram.png +[3]: https://en.wikipedia.org/wiki/Hoeffding%27s_inequality +[4]: https://nbviewer.jupyter.org/github/henrywallace/games/blob/master/boggle/boggle.ipynb#Estimating-Word-Probabilities diff --git a/sources/tech/20190107 Aliases- To Protect and Serve.md b/sources/tech/20190107 Aliases- To Protect and Serve.md deleted file mode 100644 index 783c59dc41..0000000000 --- a/sources/tech/20190107 Aliases- To Protect and Serve.md +++ /dev/null @@ -1,176 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Aliases: To Protect and Serve) -[#]: via: (https://www.linux.com/blog/learn/2019/1/aliases-protect-and-serve) -[#]: author: (Paul Brown https://www.linux.com/users/bro66) - -Aliases: To Protect and Serve -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/prairie-path_1920.jpg?itok=wRARsM7p) - -Happy 2019! Here in the new year, we’re continuing our series on aliases. By now, you’ve probably read our [first article on aliases][1], and it should be quite clear how they are the easiest way to save yourself a lot of trouble. You already saw, for example, that they helped with muscle-memory, but let's see several other cases in which aliases come in handy. - -### Aliases as Shortcuts - -One of the most beautiful things about Linux's shells is how you can use zillions of options and chain commands together to carry out really sophisticated operations in one fell swoop. All right, maybe beauty is in the eye of the beholder, but let's agree that this feature published practical. - -The downside is that you often come up with recipes that are often hard to remember or cumbersome to type. Say space on your hard disk is at a premium and you want to do some New Year's cleaning. Your first step may be to look for stuff to get rid off in you home directory. One criteria you could apply is to look for stuff you don't use anymore. `ls` can help with that: - -``` -ls -lct -``` - -The instruction above shows the details of each file and directory (`-l`) and also shows when each item was last accessed (`-c`). It then orders the list from most recently accessed to least recently accessed (`-t`). - -Is this hard to remember? You probably don’t use the `-c` and `-t` options every day, so perhaps. In any case, defining an alias like - -``` -alias lt='ls -lct' -``` - -will make it easier. - -Then again, you may want to have the list show the oldest files first: - -``` -alias lo='lt -F | tac' -``` - -![aliases][3] - -Figure 1: The lt and lo aliases in action. - -[Used with permission][4] - -There are a few interesting things going here. First, we are using an alias (`lt`) to create another alias -- which is perfectly okay. Second, we are passing a new parameter to `lt` (which, in turn gets passed to `ls` through the definition of the `lt` alias). - -The `-F` option appends special symbols to the names of items to better differentiate regular files (that get no symbol) from executable files (that get an `*`), files from directories (end in `/`), and all of the above from links, symbolic and otherwise (that end in an `@` symbol). The `-F` option is throwback to the days when terminals where monochrome and there was no other way to easily see the difference between items. You use it here because, when you pipe the output from `lt` through to `tac` you lose the colors from `ls`. - -The third thing to pay attention to is the use of piping. Piping happens when you pass the output from an instruction to another instruction. The second instruction can then use that output as its own input. In many shells (including Bash), you pipe something using the pipe symbol (`|`). - -In this case, you are piping the output from `lt -F` into `tac`. `tac`'s name is a bit of a joke. You may have heard of `cat`, the instruction that was nominally created to con _cat_ enate files together, but that in practice is used to print out the contents of a file to the terminal. `tac` does the same, but prints out the contents it receives in reverse order. Get it? `cat` and `tac`. Developers, you so funny! - -The thing is both `cat` and `tac` can also print out stuff piped over from another instruction, in this case, a list of files ordered chronologically. - -So... after that digression, what comes out of the other end is the list of files and directories of the current directory in inverse order of freshness. - -The final thing you have to bear in mind is that, while `lt` will work the current directory and any other directory... - -``` -# This will work: -lt -# And so will this: -lt /some/other/directory -``` - -... `lo` will only work with the current directory: - -``` -# This will work: -lo -# But this won't: -lo /some/other/directory -``` - -This is because Bash expands aliases into their components. When you type this: - -``` -lt /some/other/directory -``` - -Bash REALLY runs this: - -``` -ls -lct /some/other/directory -``` - -which is a valid Bash command. - -However, if you type this: - -``` -lo /some/other/directory -``` - -Bash tries to run this: - -``` -ls -lct -F | tac /some/other/directory -``` - -which is not a valid instruction, because `tac` mainly because _/some/other/directory_ is a directory, and `cat` and `tac` don't do directories. - -### More Alias Shortcuts - - * `alias lll='ls -R'` prints out the contents of a directory and then drills down and prints out the contents of its subdirectories and the subdirectories of the subdirectories, and so on and so forth. It is a way of seeing everything you have under a directory. - - * `mkdir='mkdir -pv'` let's you make directories within directories all in one go. With the base form of `mkdir`, to make a new directory containing a subdirectory you have to do this: - -``` - mkdir newdir -mkdir newdir/subdir -``` - -Or this: - -``` -mkdir -p newdir/subdir -``` - -while with the alias you would only have to do this: - -``` -mkdir newdir/subdir -``` - -Your new `mkdir` will also tell you what it is doing while is creating new directories. - - - - -### Aliases as Safeguards - -The other thing aliases are good for is as safeguards against erasing or overwriting your files accidentally. At this stage you have probably heard the legendary story about the new Linux user who ran: - -``` -rm -rf / -``` - -as root, and nuked the whole system. Then there's the user who decided that: - -``` -rm -rf /some/directory/ * -``` - -was a good idea and erased the complete contents of their home directory. Notice how easy it is to overlook that space separating the directory path and the `*`. - -Both things can be avoided with the `alias rm='rm -i'` alias. The `-i` option makes `rm` ask the user whether that is what they really want to do and gives you a second chance before wreaking havoc in your file system. - -The same goes for `cp`, which can overwrite a file without telling you anything. Create an alias like `alias cp='cp -i'` and stay safe! - -### Next Time - -We are moving more and more into scripting territory. Next time, we'll take the next logical step and see how combining instructions on the command line gives you really interesting and sophisticated solutions to everyday admin problems. - - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/learn/2019/1/aliases-protect-and-serve - -作者:[Paul Brown][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.linux.com/users/bro66 -[b]: https://github.com/lujun9972 -[1]: https://www.linux.com/blog/learn/2019/1/aliases-protect-and-serve -[2]: https://www.linux.com/files/images/fig01png-0 -[3]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/fig01_0.png?itok=crqTm_va (aliases) -[4]: https://www.linux.com/licenses/category/used-permission diff --git a/sources/tech/20190108 Avoid package names like base, util, or common.md b/sources/tech/20190108 Avoid package names like base, util, or common.md new file mode 100644 index 0000000000..b2c70b0b2e --- /dev/null +++ b/sources/tech/20190108 Avoid package names like base, util, or common.md @@ -0,0 +1,57 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Avoid package names like base, util, or common) +[#]: via: (https://dave.cheney.net/2019/01/08/avoid-package-names-like-base-util-or-common) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +Avoid package names like base, util, or common +====== + +Writing a good Go package starts with its name. Think of your package’s name as an elevator pitch, you have to describe what it does using just one word. + +A common cause of poor package names are _utility packages_. These are packages where helpers and utility code congeal. These packages contain an assortment of unrelated functions, as such their utility is hard to describe in terms of what the package _provides_. This often leads to a package’s name being derived from what the package _contains_ —utilities. + +Package names like `utils` or `helpers` are commonly found in projects which have developed deep package hierarchies and want to share helper functions without introducing import loops. Extracting utility functions to new package breaks the import loop, but as the package stems from a design problem in the project, its name doesn’t reflect its purpose, only its function in breaking the import cycle. + +> [A little] duplication is far cheaper than the wrong abstraction. + +— [Sandy Metz][1] + +My recommendation to improve the name of `utils` or `helpers` packages is to analyse where they are imported and move the relevant functions into the calling package. Even if this results in some code duplication this is preferable to introducing an import dependency between two packages. In the case where utility functions are used in many places, prefer multiple packages, each focused on a single aspect with a correspondingly descriptive name. + +Packages with names like `base` or `common` are often found when functionality common to two or more related facilities, for example common types between a client and server or a server and its mock, has been refactored into a separate package. Instead the solution is to reduce the number of packages by combining client, server, and common code into a single package named after the facility the package provides. + +For example, the `net/http` package does not have `client` and `server` packages, instead it has `client.go` and `server.go` files, each holding their respective types. `transport.go` holds for the common message transport code used by both HTTP clients and servers. + +Name your packages after what they _provide_ , not what they _contain_. + +### Related posts: + + 1. [Simple profiling package moved, updated][2] + 2. [The package level logger anti pattern][3] + 3. [How to include C code in your Go package][4] + 4. [Why I think Go package management is important][5] + + + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2019/01/08/avoid-package-names-like-base-util-or-common + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://www.sandimetz.com/blog/2016/1/20/the-wrong-abstraction +[2]: https://dave.cheney.net/2014/10/22/simple-profiling-package-moved-updated (Simple profiling package moved, updated) +[3]: https://dave.cheney.net/2017/01/23/the-package-level-logger-anti-pattern (The package level logger anti pattern) +[4]: https://dave.cheney.net/2013/09/07/how-to-include-c-code-in-your-go-package (How to include C code in your Go package) +[5]: https://dave.cheney.net/2013/10/10/why-i-think-go-package-management-is-important (Why I think Go package management is important) diff --git a/sources/tech/20190109 GoAccess - A Real-Time Web Server Log Analyzer And Interactive Viewer.md b/sources/tech/20190109 GoAccess - A Real-Time Web Server Log Analyzer And Interactive Viewer.md deleted file mode 100644 index 3bad5ba969..0000000000 --- a/sources/tech/20190109 GoAccess - A Real-Time Web Server Log Analyzer And Interactive Viewer.md +++ /dev/null @@ -1,187 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (GoAccess – A Real-Time Web Server Log Analyzer And Interactive Viewer) -[#]: via: (https://www.2daygeek.com/goaccess-a-real-time-web-server-log-analyzer-and-interactive-viewer/) -[#]: author: (Vinoth Kumar https://www.2daygeek.com/author/vinoth/) - -GoAccess – A Real-Time Web Server Log Analyzer And Interactive Viewer -====== - -Analyzing a log file is a big headache for Linux administrators as it’s capturing a lot of things. - -Most of the newbies and L1 administrators doesn’t know how to analyze this. - -If you have good knowledge to analyze a logs then you will be a legend for NIX system. - -There are many tools available in Linux to analyze the logs easily. - -GoAccess is one of the tool which allow users to analyze web server logs easily. - -We will be going to discuss in details about GoAccess tool in this article. - -### What is GoAccess? - -GoAccess is a real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser. - -GoAccess has minimal requirements, it’s written in C and requires only ncurses. - -It will support Apache, Nginx and Lighttpd logs. It provides fast and valuable HTTP statistics for system administrators that require a visual server report on the fly. - -GoAccess parses the specified web log file and outputs the data to the X terminal and browser. - -GoAccess was designed to be a fast, terminal-based log analyzer. Its core idea is to quickly analyze and view web server statistics in real time without needing to use your browser. - -Terminal output is the default output, it has the capability to generate a complete, self-contained, real-time HTML report, as well as a JSON, and CSV report. - -GoAccess allows any custom log format and the following (Combined Log Format (XLF/ELF) Apache | Nginx & Common Log Format (CLF) Apache) predefined log format options are included, but not limited to. - -### GoAccess Features - - * **`Completely Real Time:`** All the metrics are updated every 200 ms on the terminal and every second on the HTML output. - * **`Track Application Response Time:`** Track the time taken to serve the request. Extremely useful if you want to track pages that are slowing down your site. - * **`Visitors:`** Determine the amount of hits, visitors, bandwidth, and metrics for slowest running requests by the hour, or date. - * **`Metrics per Virtual Host:`** Have multiple Virtual Hosts (Server Blocks)? It features a panel that displays which virtual host is consuming most of the web server resources. - - - -### How to Install GoAccess? - -I would advise users to install GoAccess from distribution official repository with help of Package Manager. It is available in most of the distributions official repository. - -As we know, we will be getting bit outdated package for standard release distribution and rolling release distributions always include latest package. - -If you are running the OS with standard release distributions, i would suggest you to check the alternative options such as PPA or Official GoAccess maintainer repository, etc, to get a latest package. - -For **`Debian/Ubuntu`** systems, use **[APT-GET Command][1]** or **[APT Command][2]** to install GoAccess on your systems. - -``` -# apt install goaccess -``` - -To get a latest GoAccess package, use the below GoAccess official repository. - -``` -$ echo "deb https://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list -$ wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key add - -$ sudo apt-get update -$ sudo apt-get install goaccess -``` - -For **`RHEL/CentOS`** systems, use **[YUM Package Manager][3]** to install GoAccess on your systems. - -``` -# yum install goaccess -``` - -For **`Fedora`** system, use **[DNF Package Manager][4]** to install GoAccess on your system. - -``` -# dnf install goaccess -``` - -For **`ArchLinux/Manjaro`** based systems, use **[Pacman Package Manager][5]** to install GoAccess on your systems. - -``` -# pacman -S goaccess -``` - -For **`openSUSE Leap`** system, use **[Zypper Package Manager][6]** to install GoAccess on your system. - -``` -# zypper install goaccess - -# zypper ar -f obs://server:http - -# zypper ref && zypper in goaccess -``` - -### How to Use GoAccess? - -After successful installation of GoAccess. Just enter the goaccess command and followed by the web server log location to view it. - -``` -# goaccess [options] /path/to/Web Server/access.log - -# goaccess /var/log/apache/2daygeek_access.log -``` - -When you execute the above command, it will ask you to select the **Log Format Configuration**. -![][8] - -I had tested this with Apache access log. The Apache log is splitted in fifteen section. The details are below. The main section shows the summary about the fifteen section. - -The below screenshots included four sessions such as Unique Visitors, Requested files, Static Requests, Not found URLs. -![][9] - -The below screenshots included four sessions such as Visitor Hostnames and IPs, Operating Systems, Browsers, Time Distribution. -![][10] - -The below screenshots included four sessions such as Referrers URLs, Referring Sites, Google’s search engine results, HTTP status codes. -![][11] - -If you would like to generate a html report, use the following format. - -Initially i got an error when i was trying to generate the html report. - -``` -# goaccess 2daygeek_access.log -a > report.html - -GoAccess - version 1.3 - Nov 23 2018 11:28:19 -Config file: No config file used - -Fatal error has occurred -Error occurred at: src/parser.c - parse_log - 2764 -No time format was found on your conf file.Parsing... [0] [0/s] -``` - -It says “No time format was found on your conf file”. To overcome this issue, add the “COMBINED” log format option on it. - -``` -# goaccess -f 2daygeek_access.log --log-format=COMBINED -o 2daygeek.html -Parsing...[0,165] [50,165/s] -``` - -![][12] - -GoAccess allows you to access and analyze the real-time log filtering and parsing. - -``` -# tail -f /var/log/apache/2daygeek_access.log | goaccess - -``` - -For more details navigate to man or help page. - -``` -# man goaccess -or -# goaccess --help -``` - --------------------------------------------------------------------------------- - -via: https://www.2daygeek.com/goaccess-a-real-time-web-server-log-analyzer-and-interactive-viewer/ - -作者:[Vinoth Kumar][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.2daygeek.com/author/vinoth/ -[b]: https://github.com/lujun9972 -[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/ -[7]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[8]: https://www.2daygeek.com/wp-content/uploads/2019/01/goaccess-a-real-time-web-server-log-analyzer-and-interactive-viewer-1.png -[9]: https://www.2daygeek.com/wp-content/uploads/2019/01/goaccess-a-real-time-web-server-log-analyzer-and-interactive-viewer-2.png -[10]: https://www.2daygeek.com/wp-content/uploads/2019/01/goaccess-a-real-time-web-server-log-analyzer-and-interactive-viewer-3.png -[11]: https://www.2daygeek.com/wp-content/uploads/2019/01/goaccess-a-real-time-web-server-log-analyzer-and-interactive-viewer-4.png -[12]: https://www.2daygeek.com/wp-content/uploads/2019/01/goaccess-a-real-time-web-server-log-analyzer-and-interactive-viewer-5.png diff --git a/sources/tech/20190111 Top 5 Linux Distributions for Productivity.md b/sources/tech/20190111 Top 5 Linux Distributions for Productivity.md deleted file mode 100644 index fbd8b9d120..0000000000 --- a/sources/tech/20190111 Top 5 Linux Distributions for Productivity.md +++ /dev/null @@ -1,170 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Top 5 Linux Distributions for Productivity) -[#]: via: (https://www.linux.com/blog/learn/2019/1/top-5-linux-distributions-productivity) -[#]: author: (Jack Wallen https://www.linux.com/users/jlwallen) - -Top 5 Linux Distributions for Productivity -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/productivity_main.jpg?itok=2IKyg_7_) - -I have to confess, this particular topic is a tough one to address. Why? First off, Linux is a productive operating system by design. Thanks to an incredibly reliable and stable platform, getting work done is easy. Second, to gauge effectiveness, you have to consider what type of work you need a productivity boost for. General office work? Development? School? Data mining? Human resources? You see how this question can get somewhat complicated. - -That doesn’t mean, however, that some distributions aren’t able to do a better job of configuring and presenting that underlying operating system into an efficient platform for getting work done. Quite the contrary. Some distributions do a much better job of “getting out of the way,” so you don’t find yourself in a work-related hole, having to dig yourself out and catch up before the end of day. These distributions help strip away the complexity that can be found in Linux, thereby making your workflow painless. - -Let’s take a look at the distros I consider to be your best bet for productivity. To help make sense of this, I’ve divided them into categories of productivity. That task itself was challenging, because everyone’s productivity varies. For the purposes of this list, however, I’ll look at: - - * General Productivity: For those who just need to work efficiently on multiple tasks. - - * Graphic Design: For those that work with the creation and manipulation of graphic images. - - * Development: For those who use their Linux desktops for programming. - - * Administration: For those who need a distribution to facilitate their system administration tasks. - - * Education: For those who need a desktop distribution to make them more productive in an educational environment. - - - - -Yes, there are more categories to be had, many of which can get very niche-y, but these five should fill most of your needs. - -### General Productivity - -For general productivity, you won’t get much more efficient than [Ubuntu][1]. The primary reason for choosing Ubuntu for this category is the seamless integration of apps, services, and desktop. You might be wondering why I didn’t choose Linux Mint for this category? Because Ubuntu now defaults to the GNOME desktop, it gains the added advantage of GNOME Extensions (Figure 1). - -![GNOME Clipboard][3] - -Figure 1: The GNOME Clipboard Indicator extension in action. - -[Used with permission][4] - -These extensions go a very long way to aid in boosting productivity (so Ubuntu gets the nod over Mint). But Ubuntu didn’t just accept a vanilla GNOME desktop. Instead, they tweaked it to make it slightly more efficient and user-friendly, out of the box. And because Ubuntu contains just the right mixture of default, out-of-the-box, apps (that just work), it makes for a nearly perfect platform for productivity. - -Whether you need to write a paper, work on a spreadsheet, code a new app, work on your company website, create marketing images, administer a server or network, or manage human resources from within your company HR tool, Ubuntu has you covered. The Ubuntu desktop distribution also doesn’t require the user to jump through many hoops to get things working … it simply works (and quite well). Finally, thanks to it’s Debian base, Ubuntu makes installing third-party apps incredibly easy. - -Although Ubuntu tends to be the go-to for nearly every list of “top distributions for X,” it’s very hard to argue against this particular distribution topping the list of general productivity distributions. - -### Graphic Design - -If you’re looking to up your graphic design productivity, you can’t go wrong with [Fedora Design Suite][5]. This Fedora respin was created by the team responsible for all Fedora-related art work. Although the default selection of apps isn’t a massive collection of tools, those it does include are geared specifically for the creation and manipulation of images. - -With apps like GIMP, Inkscape, Darktable, Krita, Entangle, Blender, Pitivi, Scribus, and more (Figure 2), you’ll find everything you need to get your image editing jobs done and done well. But Fedora Design Suite doesn’t end there. This desktop platform also includes a bevy of tutorials that cover countless subjects for many of the installed applications. For anyone trying to be as productive as possible, this is some seriously handy information to have at the ready. I will say, however, the tutorial entry in the GNOME Favorites is nothing more than a link to [this page][6]. - -![Fedora Design Suite Favorites][8] - -Figure 2: The Fedora Design Suite Favorites menu includes plenty of tools for getting your graphic design on. - -[Used with permission][4] - -Those that work with a digital camera will certainly appreciate the inclusion of the Entangle app, which allows you to control your DSLR from the desktop. - -### Development - -Nearly all Linux distributions are great platforms for programmers. However, one particular distributions stands out, above the rest, as one of the most productive tools you’ll find for the task. That OS comes from [System76][9] and it’s called [Pop!_OS][10]. Pop!_OS is tailored specifically for creators, but not of the artistic type. Instead, Pop!_OS is geared toward creators who specialize in developing, programming, and making. If you need an environment that is not only perfected suited for your development work, but includes a desktop that’s sure to get out of your way, you won’t find a better option than Pop!_OS (Figure 3). - -What might surprise you (given how “young” this operating system is), is that Pop!_OS is also one of the single most stable GNOME-based platforms you’ll ever use. This means Pop!_OS isn’t just for creators and makers, but anyone looking for a solid operating system. One thing that many users will greatly appreciate with Pop!_OS, is that you can download an ISO specifically for your video hardware. If you have Intel hardware, [download][10] the version for Intel/AMD. If your graphics card is NVIDIA, download that specific release. Either way, you are sure go get a solid platform for which to create your masterpiece. - -![Pop!_OS][12] - -Figure 3: The Pop!_OS take on GNOME Overview. - -[Used with permission][4] - -Interestingly enough, with Pop!_OS, you won’t find much in the way of pre-installed development tools. You won’t find an included IDE, or many other dev tools. You can, however, find all the development tools you need in the Pop Shop. - -### Administration - -If you’re looking to find one of the most productive distributions for admin tasks, look no further than [Debian][13]. Why? Because Debian is not only incredibly reliable, it’s one of those distributions that gets out of your way better than most others. Debian is the perfect combination of ease of use and unlimited possibility. On top of which, because this is the distribution for which so many others are based, you can bet if there’s an admin tool you need for a task, it’s available for Debian. Of course, we’re talking about general admin tasks, which means most of the time you’ll be using a terminal window to SSH into your servers (Figure 4) or a browser to work with web-based GUI tools on your network. Why bother making use of a desktop that’s going to add layers of complexity (such as SELinux in Fedora, or YaST in openSUSE)? Instead, chose simplicity. - -![Debian][15] - -Figure 4: SSH’ing into a remote server on Debian. - -[Used with permission][4] - -And because you can select which desktop you want (from GNOME, Xfce, KDE, Cinnamon, MATE, LXDE), you can be sure to have the interface that best matches your work habits. - -### Education - -If you are a teacher or student, or otherwise involved in education, you need the right tools to be productive. Once upon a time, there existed the likes of Edubuntu. That distribution never failed to be listed in the top of education-related lists. However, that distro hasn’t been updated since it was based on Ubuntu 14.04. Fortunately, there’s a new education-based distribution ready to take that title, based on openSUSE. This spin is called [openSUSE:Education-Li-f-e][16] (Linux For Education - Figure 5), and is based on openSUSE Leap 42.1 (so it is slightly out of date). - -openSUSE:Education-Li-f-e includes tools like: - - * Brain Workshop - A dual n-back brain exercise - - * GCompris - An educational software suite for young children - - * gElemental - A periodic table viewer - - * iGNUit - A general purpose flash card program - - * Little Wizard - Development environment for children based on Pascal - - * Stellarium - An astronomical sky simulator - - * TuxMath - An math tutor game - - * TuxPaint - A drawing program for young children - - * TuxType - An educational typing tutor for children - - * wxMaxima - A cross platform GUI for the computer algebra system - - * Inkscape - Vector graphics program - - * GIMP - Graphic image manipulation program - - * Pencil - GUI prototyping tool - - * Hugin - Panorama photo stitching and HDR merging program - - -![Education][18] - -Figure 5: The openSUSE:Education-Li-f-e distro has plenty of tools to help you be productive in or for school. - -[Used with permission][4] - -Also included with openSUSE:Education-Li-f-e is the [KIWI-LTSP Server][19]. The KIWI-LTSP Server is a flexible, cost effective solution aimed at empowering schools, businesses, and organizations all over the world to easily install and deploy desktop workstations. Although this might not directly aid the student to be more productive, it certainly enables educational institutions be more productive in deploying desktops for students to use. For more information on setting up KIWI-LTSP, check out the openSUSE [KIWI-LTSP quick start guide][20]. - -Learn more about Linux through the free ["Introduction to Linux" ][21]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/learn/2019/1/top-5-linux-distributions-productivity - -作者:[Jack Wallen][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.linux.com/users/jlwallen -[b]: https://github.com/lujun9972 -[1]: https://www.ubuntu.com/ -[2]: /files/images/productivity1jpg -[3]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/productivity_1.jpg?itok=yxez3X1w (GNOME Clipboard) -[4]: /licenses/category/used-permission -[5]: https://labs.fedoraproject.org/en/design-suite/ -[6]: https://fedoraproject.org/wiki/Design_Suite/Tutorials -[7]: /files/images/productivity2jpg -[8]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/productivity_2.jpg?itok=ke0b8qyH (Fedora Design Suite Favorites) -[9]: https://system76.com/ -[10]: https://system76.com/pop -[11]: /files/images/productivity3jpg-0 -[12]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/productivity_3_0.jpg?itok=8UkCUfsD (Pop!_OS) -[13]: https://www.debian.org/ -[14]: /files/images/productivity4jpg -[15]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/productivity_4.jpg?itok=c9yD3Xw2 (Debian) -[16]: https://en.opensuse.org/openSUSE:Education-Li-f-e -[17]: /files/images/productivity5jpg -[18]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/productivity_5.jpg?itok=oAFtV8nT (Education) -[19]: https://en.opensuse.org/Portal:KIWI-LTSP -[20]: https://en.opensuse.org/SDB:KIWI-LTSP_quick_start -[21]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/sources/tech/20190127 Eliminate error handling by eliminating errors.md b/sources/tech/20190127 Eliminate error handling by eliminating errors.md new file mode 100644 index 0000000000..6eac4740eb --- /dev/null +++ b/sources/tech/20190127 Eliminate error handling by eliminating errors.md @@ -0,0 +1,204 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Eliminate error handling by eliminating errors) +[#]: via: (https://dave.cheney.net/2019/01/27/eliminate-error-handling-by-eliminating-errors) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +Eliminate error handling by eliminating errors +====== + +Go 2 aims to improve the overhead of [error handling][1], but do you know what is better than an improved syntax for handling errors? Not needing to handle errors at all. Now, I’m not saying “delete your error handling code”, instead I’m suggesting changing your code so you don’t have as many errors to handle. + +This article draws inspiration from a chapter in John Ousterhout’s, _[A philosophy of Software Design,][2]_ “Define Errors Out of Existence”. I’m going to try to apply his advice to Go. + +* * * + +Here’s a function to count the number of lines in a file, + +``` +func CountLines(r io.Reader) (int, error) { + var ( + br = bufio.NewReader(r) + lines int + err error + ) + + for { + _, err = br.ReadString('\n') + lines++ + if err != nil { + break + } + } + + if err != io.EOF { + return 0, err + } + return lines, nil + } +``` + +We construct a `bufio.Reader`, then sit in a loop calling the `ReadString` method, incrementing a counter until we reach the end of the file, then we return the number of lines read. That’s the code we _wanted_ to write, instead `CountLines` is made more complicated by its error handling. For example, there is this strange construction: + +``` +_, err = br.ReadString('\n') +lines++ +if err != nil { + break +} +``` + +We increment the count of lines _before_ checking the error—​that looks odd. The reason we have to write it this way is `ReadString` will return an error if it encounters an end-of-file—`io.EOF`—before hitting a newline character. This can happen if there is no trailing newline. + +To address this problem, we rearrange the logic to increment the line count, then see if we need to exit the loop.1 + +But we’re not done checking errors yet. `ReadString` will return `io.EOF` when it hits the end of the file. This is expected, `ReadString` needs some way of saying _stop, there is nothing more to read_. So before we return the error to the caller of `CountLine`, we need to check if the error was _not_ `io.EOF`, and in that case propagate it up, otherwise we return `nil` to say that everything worked fine. This is why the final line of the function is not simply + +``` +return lines, err +``` + +I think this is a good example of Russ Cox’s [observation that error handling can obscure the operation of the function][3]. Let’s look at an improved version. + +``` +func CountLines(r io.Reader) (int, error) { + sc := bufio.NewScanner(r) + lines := 0 + + for sc.Scan() { + lines++ + } + + return lines, sc.Err() +} +``` + +This improved version switches from using `bufio.Reader` to `bufio.Scanner`. Under the hood `bufio.Scanner` uses `bufio.Reader` adding a layer of abstraction which helps remove the error handling which obscured the operation of our previous version of `CountLines` 2 + +The method `sc.Scan()` returns `true` if the scanner _has_ matched a line of text and _has not_ encountered an error. So, the body of our `for` loop will be called only when there is a line of text in the scanner’s buffer. This means our revised `CountLines` correctly handles the case where there is no trailing newline, It also correctly handles the case where the file is empty. + +Secondly, as `sc.Scan` returns `false` once an error is encountered, our `for` loop will exit when the end-of-file is reached or an error is encountered. The `bufio.Scanner` type memoises the first error it encounters and we recover that error once we’ve exited the loop using the `sc.Err()` method. + +Lastly, `buffo.Scanner` takes care of handling `io.EOF` and will convert it to a `nil` if the end of file was reached without encountering another error. + +* * * + +My second example is inspired by Rob Pikes’ _[Errors are values][4]_ blog post. + +When dealing with opening, writing and closing files, the error handling is present but not overwhelming as, the operations can be encapsulated in helpers like `ioutil.ReadFile` and `ioutil.WriteFile`. However, when dealing with low level network protocols it often becomes necessary to build the response directly using I/O primitives, thus the error handling can become repetitive. Consider this fragment of a HTTP server which is constructing a HTTP/1.1 response. + +``` +type Header struct { + Key, Value string +} + +type Status struct { + Code int + Reason string +} + +func WriteResponse(w io.Writer, st Status, headers []Header, body io.Reader) error { + _, err := fmt.Fprintf(w, "HTTP/1.1 %d %s\r\n", st.Code, st.Reason) + if err != nil { + return err + } + + for _, h := range headers { + _, err := fmt.Fprintf(w, "%s: %s\r\n", h.Key, h.Value) + if err != nil { + return err + } + } + + if _, err := fmt.Fprint(w, "\r\n"); err != nil { + return err + } + + _, err = io.Copy(w, body) + return err +} +``` + +First we construct the status line using `fmt.Fprintf`, and check the error. Then for each header we write the header key and value, checking the error each time. Lastly we terminate the header section with an additional `\r\n`, check the error, and copy the response body to the client. Finally, although we don’t need to check the error from `io.Copy`, we do need to translate it from the two return value form that `io.Copy` returns into the single return value that `WriteResponse` expects. + +Not only is this a lot of repetitive work, each operation—fundamentally writing bytes to an `io.Writer`—has a different form of error handling. But we can make it easier on ourselves by introducing a small wrapper type. + +``` +type errWriter struct { + io.Writer + err error +} + +func (e *errWriter) Write(buf []byte) (int, error) { + if e.err != nil { + return 0, e.err + } + + var n int + n, e.err = e.Writer.Write(buf) + return n, nil +} +``` + +`errWriter` fulfils the `io.Writer` contract so it can be used to wrap an existing `io.Writer`. `errWriter` passes writes through to its underlying writer until an error is detected. From that point on, it discards any writes and returns the previous error. + +``` +func WriteResponse(w io.Writer, st Status, headers []Header, body io.Reader) error { + ew := &errWriter{Writer: w} + fmt.Fprintf(ew, "HTTP/1.1 %d %s\r\n", st.Code, st.Reason) + + for _, h := range headers { + fmt.Fprintf(ew, "%s: %s\r\n", h.Key, h.Value) + } + + fmt.Fprint(ew, "\r\n") + io.Copy(ew, body) + + return ew.err +} +``` + +Applying `errWriter` to `WriteResponse` dramatically improves the clarity of the code. Each of the operations no longer needs to bracket itself with an error check. Reporting the error is moved to the end of the function by inspecting the `ew.err` field, avoiding the annoying translation from `io.Copy`’s return values. + +* * * + +When you find yourself faced with overbearing error handling, try to extract some of the operations into a helper type. + + 1. This logic _still_ isn’t correct, can you spot the bug? + 2. `bufio.Scanner` can scan for any pattern, by default it looks for newlines. + + + +### Related posts: + + 1. [Error handling vs. exceptions redux][5] + 2. [Stack traces and the errors package][6] + 3. [Subcommand handling in Go][7] + 4. [Constant errors][8] + + + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2019/01/27/eliminate-error-handling-by-eliminating-errors + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling-overview.md +[2]: https://www.amazon.com/Philosophy-Software-Design-John-Ousterhout/dp/1732102201 +[3]: https://www.youtube.com/watch?v=6wIP3rO6On8 +[4]: https://blog.golang.org/errors-are-values +[5]: https://dave.cheney.net/2014/11/04/error-handling-vs-exceptions-redux (Error handling vs. exceptions redux) +[6]: https://dave.cheney.net/2016/06/12/stack-traces-and-the-errors-package (Stack traces and the errors package) +[7]: https://dave.cheney.net/2013/11/07/subcommand-handling-in-go (Subcommand handling in Go) +[8]: https://dave.cheney.net/2016/04/07/constant-errors (Constant errors) diff --git a/sources/tech/20190129 A few early marketing thoughts.md b/sources/tech/20190129 A few early marketing thoughts.md new file mode 100644 index 0000000000..79cc6b1b1d --- /dev/null +++ b/sources/tech/20190129 A few early marketing thoughts.md @@ -0,0 +1,164 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A few early marketing thoughts) +[#]: via: (https://jvns.ca/blog/2019/01/29/marketing-thoughts/) +[#]: author: (Julia Evans https://jvns.ca/) + +A few early marketing thoughts +====== + +At some point last month I said I might write more about business, so here are some very early marketing thoughts for my zine business (!). The question I’m trying to make some progress on in this post is: “how to do marketing in a way that feels good?” + +### what’s the point of marketing? + +Okay! What’s marketing? What’s the point? I think the ideal way marketing works is: + + 1. you somehow tell a person about a thing + 2. you explain somehow why the thing will be useful to them / why it is good + 3. they buy it and they like the thing because it’s what they expected + + + +(or, when you explain it they see that they don’t want it and don’t buy it which is good too!!) + +So basically as far as I can tell good marketing is just explaining what the thing is and why it is good in a clear way. + +### what internet marketing techniques do people use? + +I’ve been thinking a bit about internet marketing techniques I see people using on me recently. Here are a few examples of internet marketing techniques I’ve seen: + + 1. word of mouth (“have you seen this cool new thing?!”) + 2. twitter / instagram marketing (build a twitter/instagram account) + 3. email marketing (“build a mailing list with a bajillion people on it and sell to them”) + 4. email marketing (“tell your existing users about features that they already have that they might want to use”) + 5. social proof marketing (“jane from georgia bought a sweater”), eg fomo.com + 6. cart notifications (“you left this sweater in your cart??! did you mean to buy it? maybe you should buy it!“) + 7. content marketing (which is fine but whenever people refer to my writing as ‘content’ I get grumpy :)) + + + +### you need _some_ way to tell people about your stuff + +Something that is definitely true about marketing is that you need some way to tell new people about the thing you are doing. So for me when I’m thinking about running a business it’s less about “should i do marketing” and more like “well obviously i have to do marketing, how do i do it in a way that i feel good about?” + +### what’s up with email marketing? + +I feel like every single piece of internet marketing advice I read says “you need a mailing list”. This is advice that I haven’t really taken to heart – technically I have 2 mailing lists: + + 1. the RSS feed for this blog, which sends out new blog posts to a mailing list for folks who don’t use RSS (which 3000 of you get) + 2. ’s list, for comics / new zine announcements (780 people subscribe to that! thank you!) + + + +but definitely neither of them is a Machine For Making Sales and I’ve put in almost no efforts in that direction yet. + +here are a few things I’ve noticed about marketing mailing lists: + + * most marketing mailing lists are boring but some marketing mailing lists are actually interesting! For example I kind of like [amy hoy][1]’s emails. + * Someone told me recently that they have 200,000 people on their mailing list (?!!) which made the “a mailing list is a machine for making money” concept make a lot more sense to me. I wonder if people who make a lot of money from their mailing lists all have huge 10k+ person mailing lists like this? + + + +### what works for me: twitter + +Right now for my zines business I’d guess maybe 70% of my sales come from Twitter. The main thing I do is tweet pages from zines I’m working on (for example: yesterday’s [comic about ss][2]). The comics are usually good and fun so invariably they get tons of retweets, which means that I end up with lots of followers, which means that when I later put up the zine for sale lots of people will buy it. + +And of course people don’t _have_ to buy the zines, I post most of what ends up in my zines on twitter for free, so it feels like a nice way to do it. Everybody wins, I think. + +(side note: when I started getting tons of new followers from my comics I was actually super worried that it would make my experience of Twitter way worse. That hasn’t happened! the new followers all seem totally reasonable and I still get a lot of really interesting twitter replies which is wonderful ❤) + +I don’t try to hack/optimize this really: I just post comics when I make them and I try to make them good. + +### a small Twitter innovation: putting my website on the comics + +Here’s one small marketing change that I made that I think makes sense! + +In the past, I didn’t put anything about how to buy my comics on the comics I posted on Twitter, just my Twitter username. Like this: + +![][3] + +After a while, I realized people were asking me all the time “hey, can I buy a book/collection? where do these come from? how do I get more?“! I think a marketing secret is “people actually want to buy things that are good, it is useful to tell people where they can buy things that are good”. + +So just recently I’ve started adding my website and a note about my current project on the comics I post on Twitter. It doesn’t say much: just “❤ these comics? buy a collection! wizardzines.com” and “page 11 of my upcoming bite size networking zine”. Here’s what it looks like: + +![][4] + +I feel like this strikes a pretty good balance between “julia you need to tell people what you’re doing otherwise how are they supposed to buy things from you” and “omg too many sales pitches everywhere”? I’ve only started doing this recently so we’ll see how it goes. + +### should I work on a mailing list? + +It seems like the same thing that works on twitter would work by email if I wanted to put in the time (email people comics! when a zine comes out, email them about the zine and they can buy it if they want!). + +One thing I LOVE about Twitter though is that people always reply to the comics I post with their own tips and tricks that they love and I often learn something new. I feel like email would be nowhere near as fun :) + +But I still think this is a pretty good idea: keeping up with twitter can be time consuming and I bet a lot of people would like to get occasional email with programming drawings. (would you?) + +One thing I’m not sure about is – a lot of marketing mailing lists seem to use somewhat aggressive techniques to get new emails (a lot of popups on a website, or adding everyone who signs up to their service / buys a thing to a marketing list) and while I’m basically fine with that (unsubscribing is easy!), I’m not sure that it’s what I’d want to do, and maybe less aggressive techniques will work just as well? We’ll see. + +### should I track conversion rates? + +A piece of marketing advice I assume people give a lot is “be data driven, figure out what things convert the best, etc”. I don’t do this almost at all – gumroad used to tell me that most of my sales came from Twitter which was good to know, but right now I have basically no idea how it works. + +Doing a bunch of work to track conversion rates feels bad to me: it seems like it would be really easy to go down a dumb rabbit hole of “oh, let’s try to increase conversion by 5%” instead of just focusing on making really good and cool things. + +My guess is that what will work best for me for a while is to have some data that tells me in broad strokes how the business works (like “about 70% of sales come from twitter”) and just leave it at that. + +### should I do advertising? + +I had a conversation with Kamal about this post that went: + + * julia: “hmm, maybe I should talk about ads?” + * julia: “wait, are ads marketing?” + * kamal: “yes ads are marketing” + + + +So, ads! I don’t know anything about advertising except that you can advertise on Facebook or Twitter or Google. Some non-ethical questions I have about advertising: + + * how do you choose what keywords to advertise on? + * are there actually cheap keywords, like is ‘file descriptors’ cheap? + * how much do you need to pay per click? (for some weird linux keywords, google estimated 20 cents a click?) + * can you use ads effectively for something that costs $10? + + + +This seems nontrivial to learn about and I don’t think I’m going to try soon. + +### other marketing things + +a few other things I’ve thought about: + + * I learned about “social proof marketing” sites like fomo.com yesterday which makes popups on your site like “someone bought COOL THING 3 hours ago”. This seems like it has some utility (people are actually buying things from me all the time, maybe that’s useful to share somehow?) but those popups feel a bit cheap to me and I don’t really think it’s something I’d want to do right now. + * similarly a lot of sites like to inject these popups like “HELLO PLEASE SIGN UP FOR OUR MAILING LIST”. similar thoughts. I’ve been putting an email signup link in the footer which seems like a good balance between discoverable and annoying. As an example of a popup which isn’t too intrusive, though: nate berkopec has [one on his site][5] which feels really reasonable! (scroll to the bottom to see it) + + + +Maybe marketing is all about “make your things discoverable without being annoying”? :) + +### that’s all! + +Hopefully some of this was interesting! Obviously the most important thing in all of this is to make cool things that are useful to people, but I think cool useful writing does not actually sell itself! + +If you have thoughts about what kinds of marketing have worked well for you / you’ve felt good about I would love to hear them! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/01/29/marketing-thoughts/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://stackingthebricks.com/ +[2]: https://twitter.com/b0rk/status/1090058524137345025 +[3]: https://jvns.ca/images/kill.jpeg +[4]: https://jvns.ca/images/ss.jpeg +[5]: https://www.speedshop.co/2019/01/10/three-activerecord-mistakes.html diff --git a/sources/tech/20190129 Create an online store with this Java-based framework.md b/sources/tech/20190129 Create an online store with this Java-based framework.md deleted file mode 100644 index b72a8551de..0000000000 --- a/sources/tech/20190129 Create an online store with this Java-based framework.md +++ /dev/null @@ -1,235 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Create an online store with this Java-based framework) -[#]: via: (https://opensource.com/article/19/1/scipio-erp) -[#]: author: (Paul Piper https://opensource.com/users/madppiper) - -Create an online store with this Java-based framework -====== -Scipio ERP comes with a large range of applications and functionality. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_whitehurst_money.png?itok=ls-SOzM0) - -So you want to sell products or services online, but either can't find a fitting software or think customization would be too costly? [Scipio ERP][1] may just be what you are looking for. - -Scipio ERP is a Java-based open source e-commerce framework that comes with a large range of applications and functionality. The project was forked from [Apache OFBiz][2] in 2014 with a clear focus on better customization and a more modern appeal. The e-commerce component is quite extensive and works in a multi-store setup, internationally, and with a wide range of product configurations, and it's also compatible with modern HTML frameworks. The software also provides standard applications for many other business cases, such as accounting, warehouse management, or sales force automation. It's all highly standardized and therefore easy to customize, which is great if you are looking for more than a virtual cart. - -The system makes it very easy to keep up with modern web standards, too. All screens are constructed using the system's "[templating toolkit][3]," an easy-to-learn macro set that separates HTML from all applications. Because of it, every application is already standardized to the core. Sounds confusing? It really isn't—it all looks a lot like HTML, but you write a lot less of it. - -### Initial setup - -Before you get started, make sure you have Java 1.8 (or greater) SDK and a Git client installed. Got it? Great! Next, check out the master branch from GitHub: - -``` -git clone https://github.com/ilscipio/scipio-erp.git -cd scipio-erp -git checkout master -``` - -To set up the system, simply run **./install.sh** and select either option from the command line. Throughout development, it is best to stick to an **installation for development** (Option 1), which will also install a range of demo data. For professional installations, you can modify the initial config data ("seed data") so it will automatically set up the company and catalog data for you. By default, the system will run with an internal database, but it [can also be configured][4] with a wide range of relational databases such as PostgreSQL and MariaDB. - -![Setup wizard][6] - -Follow the setup wizard to complete your initial configuration, - -Start the system with **./start.sh** and head over to **** to complete the configuration. If you installed with demo data, you can log in with username **admin** and password **scipio**. During the setup wizard, you can set up a company profile, accounting, a warehouse, your product catalog, your online store, and additional user profiles. Keep the website entries on the product store configuration screen for now. The system allows you to run multiple webstores with different underlying code; unless you want to do that, it is easiest to stick to the defaults. - -Congratulations, you just installed Scipio ERP! Play around with the screens for a minute or two to get a feel for the functionality. - -### Shortcuts - -Before you jump into the customization, here are a few handy commands that will help you along the way: - - * Create a shop-override: **./ant create-component-shop-override** - * Create a new component: **./ant create-component** - * Create a new theme component: **./ant create-theme** - * Create admin user: **./ant create-admin-user-login** - * Various other utility functions: **./ant -p** - * Utility to install & update add-ons: **./git-addons help** - - - -Also, make a mental note of the following locations: - - * Scripts to run Scipio as a service: **/tools/scripts/** - * Log output directory: **/runtime/logs** - * Admin application: **** - * E-commerce application: **** - - - -Last, Scipio ERP structures all code in the following five major directories: - - * Framework: framework-related sources, the application server, generic screens, and configurations - * Applications: core applications - * Addons: third-party extensions - * Themes: modifies the look and feel - * Hot-deploy: your own components - - - -Aside from a few configurations, you will be working within the hot-deploy and themes directories. - -### Webstore customizations - -To really make the system your own, start thinking about [components][7]. Components are a modular approach to override, extend, and add to the system. Think of components as self-contained web modules that capture information on databases ([entity][8]), functions ([services][9]), screens ([views][10]), [events and actions][11], and web applications. Thanks to components, you can add your own code while remaining compatible with the original sources. - -Run **./ant create-component-shop-override** and follow the steps to create your webstore component. A new directory will be created inside of the hot-deploy directory, which extends and overrides the original e-commerce application. - -![component directory structure][13] - -A typical component directory structure. - -Your component will have the following directory structure: - - * config: configurations - * data: seed data - * entitydef: database table definitions - * script: Groovy script location - * servicedef: service definitions - * src: Java classes - * webapp: your web application - * widget: screen definitions - - - -Additionally, the **ivy.xml** file allows you to add Maven libraries to the build process and the **ofbiz-component.xml** file defines the overall component and web application structure. Apart from the obvious, you will also find a **controller.xml** file inside the web apps' **WEB-INF** directory. This allows you to define request entries and connect them to events and screens. For screens alone, you can also use the built-in CMS functionality, but stick to the core mechanics first. Familiarize yourself with **/applications/shop/** before introducing changes. - -#### Adding custom screens - -Remember the [templating toolkit][3]? You will find it used on every screen. Think of it as a set of easy-to-learn macros that structure all content. Here's an example: - -``` -<@section title="Title"> -    <@heading id="slider">Slider -    <@row> -        <@cell columns=6> -            <@slider id="" class="" controls=true indicator=true> -                <@slide link="#" image="https://placehold.it/800x300">Just some content… -                <@slide title="This is a title" link="#" image="https://placehold.it/800x300"> -            -        -        <@cell columns=6>Second column -    - -``` - -Not too difficult, right? Meanwhile, themes contain the HTML definitions and styles. This hands the power over to your front-end developers, who can define the output of each macro and otherwise stick to their own build tools for development. - -Let's give it a quick try. First, define a request on your own webstore. You will modify the code for this. A built-in CMS is also available at **** , which allows you to create new templates and screens in a much more efficient way. It is fully compatible with the templating toolkit and comes with example templates that can be adopted to your preferences. But since we are trying to understand the system here, let's go with the more complicated way first. - -Open the **[controller.xml][14]** file inside of your shop's webapp directory. The controller keeps track of request events and performs actions accordingly. The following will create a new request under **/shop/test** : - -``` - - -      -      - -``` - -You can define multiple responses and, if you want, you could use an event or a service call inside the request to determine which response you may want to use. I opted for a response of type "view." A view is a rendered response; other types are request-redirects, forwards, and alike. The system comes with various renderers and allows you to determine the output later; to do so, add the following: - -``` - - -``` - -Replace **my-component** with your own component name. Then you can define your very first screen by adding the following inside the tags within the **widget/CommonScreens.xml** file: - -``` - -       
      -            -            -            -                -                    -                        -                    -                -            -       
      -   
      -``` - -Screens are actually quite modular and consist of multiple elements ([widgets, actions, and decorators][15]). For the sake of simplicity, leave this as it is for now, and complete the new webpage by adding your very first templating toolkit file. For that, create a new **webapp/mycomponent/test/test.ftl** file and add the following: - -``` -<@alert type="info">Success! -``` - -![Custom screen][17] - -A custom screen. - -Open **** and marvel at your own accomplishments. - -#### Custom themes - -Modify the look and feel of the shop by creating your very own theme. All themes can be found as components inside of the themes folder. Run **./ant create-theme** to add your own. - -![theme component layout][19] - -A typical theme component layout. - -Here's a list of the most important directories and files: - - * Theme configuration: **data/*ThemeData.xml** - * Theme-specific wrapping HTML: **includes/*.ftl** - * Templating Toolkit HTML definition: **includes/themeTemplate.ftl** - * CSS class definition: **includes/themeStyles.ftl** - * CSS framework: **webapp/theme-title/*** - - - -Take a quick look at the Metro theme in the toolkit; it uses the Foundation CSS framework and makes use of all the things above. Afterwards, set up your own theme inside your newly constructed **webapp/theme-title** directory and start developing. The Foundation-shop theme is a very simple shop-specific theme implementation that you can use as a basis for your own work. - -Voila! You have set up your own online store and are ready to customize! - -![Finished Scipio ERP shop][21] - -A finished shop based on Scipio ERP. - -### What's next? - -Scipio ERP is a powerful framework that simplifies the development of complex e-commerce applications. For a more complete understanding, check out the project [documentation][7], try the [online demo][22], or [join the community][23]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/1/scipio-erp - -作者:[Paul Piper][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/madppiper -[b]: https://github.com/lujun9972 -[1]: https://www.scipioerp.com -[2]: https://ofbiz.apache.org/ -[3]: https://www.scipioerp.com/community/developer/freemarker-macros/ -[4]: https://www.scipioerp.com/community/developer/installation-configuration/configuration/#database-configuration -[5]: /file/419711 -[6]: https://opensource.com/sites/default/files/uploads/setup_step5_sm.jpg (Setup wizard) -[7]: https://www.scipioerp.com/community/developer/architecture/components/ -[8]: https://www.scipioerp.com/community/developer/entities/ -[9]: https://www.scipioerp.com/community/developer/services/ -[10]: https://www.scipioerp.com/community/developer/views-requests/ -[11]: https://www.scipioerp.com/community/developer/events-actions/ -[12]: /file/419716 -[13]: https://opensource.com/sites/default/files/uploads/component_structure.jpg (component directory structure) -[14]: https://www.scipioerp.com/community/developer/views-requests/request-controller/ -[15]: https://www.scipioerp.com/community/developer/views-requests/screen-widgets-decorators/ -[16]: /file/419721 -[17]: https://opensource.com/sites/default/files/uploads/success_screen_sm.jpg (Custom screen) -[18]: /file/419726 -[19]: https://opensource.com/sites/default/files/uploads/theme_structure.jpg (theme component layout) -[20]: /file/419731 -[21]: https://opensource.com/sites/default/files/uploads/finished_shop_1_sm.jpg (Finished Scipio ERP shop) -[22]: https://www.scipioerp.com/demo/ -[23]: https://forum.scipioerp.com/ diff --git a/sources/tech/20190129 You shouldn-t name your variables after their types for the same reason you wouldn-t name your pets -dog- or -cat.md b/sources/tech/20190129 You shouldn-t name your variables after their types for the same reason you wouldn-t name your pets -dog- or -cat.md new file mode 100644 index 0000000000..75ad9e93c6 --- /dev/null +++ b/sources/tech/20190129 You shouldn-t name your variables after their types for the same reason you wouldn-t name your pets -dog- or -cat.md @@ -0,0 +1,83 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (You shouldn’t name your variables after their types for the same reason you wouldn’t name your pets “dog” or “cat”) +[#]: via: (https://dave.cheney.net/2019/01/29/you-shouldnt-name-your-variables-after-their-types-for-the-same-reason-you-wouldnt-name-your-pets-dog-or-cat) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +You shouldn’t name your variables after their types for the same reason you wouldn’t name your pets “dog” or “cat” +====== + +The name of a variable should describe its contents, not the _type_ of the contents. Consider this example: + +``` +var usersMap map[string]*User +``` + +What are some good properties of this declaration? We can see that it’s a map, and it has something to do with the `*User` type, so that’s probably good. But `usersMap` _is_ a map and Go, being a statically typed language, won’t let us accidentally use a map where a different type is required, so the `Map` suffix as a safety precaution is redundant. + +Now, consider what happens if we declare other variables using this pattern: + +``` +var ( + companiesMap map[string]*Company + productsMap map[string]*Products +) +``` + +Now we have three map type variables in scope, `usersMap`, `companiesMap`, and `productsMap`, all mapping `string`s to different `struct` types. We know they are maps, and we also know that their declarations prevent us from using one in place of another—​the compiler will throw an error if we try to use `companiesMap` where the code is expecting a `map[string]*User`. In this situation it’s clear that the `Map` suffix does not improve the clarity of the code, its just extra boilerplate to type. + +My suggestion is avoid any suffix that resembles the _type_ of the variable. Said another way, if `users` isn’t descriptive enough, then `usersMap` won’t be either. + +This advice also applies to function parameters. For example: + +``` +type Config struct { + // +} + +func WriteConfig(w io.Writer, config *Config) +``` + +Naming the `*Config` parameter `config` is redundant. We know it’s a pointer to a `Config`, it says so right there in the declaration. Instead consider if `conf` will do, or maybe just `c` if the lifetime of the variable is short enough. + +This advice is more than just a desire for brevity. If there is more that one `*Config` in scope at any one time, calling them `config1` and `config2` is less descriptive than calling them `original` and `updated` . The latter are less likely to be accidentally transposed—something the compiler won’t catch—while the former differ only in a one character suffix. + +Finally, don’t let package names steal good variable names. The name of an imported identifier includes its package name. For example the `Context` type in the `context` package will be known as `context.Context` when imported into another package . This makes it impossible to use `context` as a variable or type, unless of course you rename the import, but that’s throwing good after bad. This is why the local declaration for `context.Context` types is traditionally `ctx`. eg. + +``` +func WriteLog(ctx context.Context, message string) +``` + +* * * + +A variable’s name should be independent of its type. You shouldn’t name your variables after their types for the same reason you wouldn’t name your pets “dog” or “cat”. You shouldn’t include the name of your type in the name of your variable for the same reason. + +### Related posts: + + 1. [On declaring variables][1] + 2. [Go, without package scoped variables][2] + 3. [A whirlwind tour of Go’s runtime environment variables][3] + 4. [Declaration scopes in Go][4] + + + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2019/01/29/you-shouldnt-name-your-variables-after-their-types-for-the-same-reason-you-wouldnt-name-your-pets-dog-or-cat + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://dave.cheney.net/2014/05/24/on-declaring-variables (On declaring variables) +[2]: https://dave.cheney.net/2017/06/11/go-without-package-scoped-variables (Go, without package scoped variables) +[3]: https://dave.cheney.net/2015/11/29/a-whirlwind-tour-of-gos-runtime-environment-variables (A whirlwind tour of Go’s runtime environment variables) +[4]: https://dave.cheney.net/2016/12/15/declaration-scopes-in-go (Declaration scopes in Go) diff --git a/sources/tech/20190217 Organizing this blog into categories.md b/sources/tech/20190217 Organizing this blog into categories.md new file mode 100644 index 0000000000..e8a03f1bdd --- /dev/null +++ b/sources/tech/20190217 Organizing this blog into categories.md @@ -0,0 +1,155 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Organizing this blog into categories) +[#]: via: (https://jvns.ca/blog/2019/02/17/organizing-this-blog-into-categories/) +[#]: author: (Julia Evans https://jvns.ca/) + +Organizing this blog into categories +====== + +Today I organized the front page of this blog ([jvns.ca][1]) into CATEGORIES! Now it is actually possible to make some sense of what is on here!! There are 28 categories (computer networking! learning! “how things work”! career stuff! many more!) I am so excited about this. + +How it works: Every post is in only 1 category. Obviously the categories aren’t “perfect” (there is a “how things work” category and a “kubernetes” category and a “networking” category, and so for a “how container networking works in kubernetes” I need to just pick one) but I think it’s really nice and I’m hoping that it’ll make the blog easier for folks to navigate. + +If you’re interested in more of the story of how I’m thinking about this: I’ve been a little dissatisfied for a long time with how this blog is organized. Here’s where I started, in 2013, with a pretty classic blog layout (this is Octopress, which was a Jekyll Wordpress-lookalike theme that was cool back then and which served me very well for a long time): + +![][2] + +### problem with “show the 5 most recent posts”: you don’t know what the person’s writing is about! + +This is a super common way to organize a blog: on the homepage of your blog, you display maybe the 5 most recent posts, and then maybe have a “previous” link. + +The thing I find tricky about this (as a blog reader) is that + + 1. it’s hard to hunt through their back catalog to find cool things they’ve written + 2. it’s SO HARD to get an overall sense for the body of a person’s work by reading 1 blog post at a time + + + +### next attempt: show every post in chronological order + +My next attempt at blog organization was to show every post on the homepage in chronological order. This was inspired by [Dan Luu’s blog][3], which takes a super minimal approach. I switched to this (according to the internet archive) sometime in early 2016. Here’s what it looked like (with some CSS issues :)) + +![][4] + +The reason I like this “show every post in chronological order” approach more is that when I discover a new blog, I like to obsessively binge read through the whole thing to see all the cool stuff the person has written. [Rachel by the bay][5] also organizes her writing this way, and when I found her blog I was like OMG WOW THIS IS AMAZING I MUST READ ALL OF THIS NOW and being able to look through all the entries quickly and start reading ones that caught my eye was SO FUN. + +[Will Larson’s blog][6] also has a “list of all posts” page which I find useful because it’s a good blog, and sometimes I want to refer back to something he wrote months ago and can’t remember what it was called, and being able to scan through all the titles makes it easier to do that. + +I was pretty happy with this and that’s how it’s been for the last 3 years. + +### problem: a chronological list of 390 posts still kind of sucks + +As of today, I have 390 posts here (360,000 words! that’s, like, 4 300-page books! eep!). This is objectively a lot of writing and I would like people new to the blog to be able to navigate it and actually have some idea what’s going on. + +And this blog is not actually just a totally disorganized group of words! I have a lot of specific interests: I’ve written probably 30 posts about computer networking, 15ish on ML/statistics, 20ish career posts, etc. And when I write a new Kubernetes post or whatever, it’s usually at least sort of related to some ongoing train of thought I have about Kubernetes. And it’s totally obvious to _me_ what other posts that post is related to, but obviously to a new person it’s not at all clear what the trains of thought are in this blog. + +### solution for now: assign every post 1 (just 1) category + +My new plan is to assign every post a single category. I got this idea from [Itamar Turner-Trauring’s site][7]. + +Here are the initial categories: + + * Cool computer tools / features / ideas + * Computer networking + * How a computer thing works + * Kubernetes / containers + * Zines / comics + * On writing comics / zines + * Conferences + * Organizing conferences + * Businesses / marketing + * Statistics / machine learning / data analysis + * Year in review + * Infrastructure / operations engineering + * Career / work + * Working with others / communication + * Remote work + * Talks transcripts / podcasts + * On blogging / speaking + * On learning + * Rust + * Linux debugging / tracing tools + * Debugging stories + * Fan posts about awesome work by other people + * Inclusion + * rbspy + * Performance + * Open source + * Linux systems stuff + * Recurse Center (my daily posts during my RC batch) + + + +I guess you can tell this is a systems-y blog because there are 8 different systems-y categories (kubernetes, infrastructure, linux debugging tools, rust, debugging stories, performance, and linux systems stuff, how a computer thing works) :). + +But it was nice to see that I also have this huge career / work category! And that category is pretty meaningful to me, it includes a lot of things that I struggled with and were hard for me to learn. And I get to put all my machine learning posts together, which is an area I worked in for 3 years and am still super interested in and every so often learn a new thing about! + +### How I assign the categories: a big text file + +I came up with a scheme for assigning the categories that I thought was really fun! I knew immediately that coming up with categories in advance would be impossible (how was I supposed to know that “fan posts about awesome work by other people” was a substantial category?) + +So instead, I took kind of a Marie Kondo approach: I wrote a script to just dump all the titles of every blog post into a text file, and then I just used vim to organize them roughly into similar sections. Seeing everything in one place (a la marie kondo) really helped me see the patterns and figure out what some categories were. + +[Here’s the final result of that text file][8]. I think having a lightweight way of organizing the posts all in one file made a huge difference and that it would have been impossible for me to seen the patterns otherwise. + +### How I implemented it: a hugo taxonomy + +Once I had that big text file, I wrote [a janky python script][9] to assign the categories in that text file to the actual posts. + +I use Hugo for this blog, and so I also needed to tell Hugo about the categories. This blog already technically has tags (though they’re woefully underused, I didn’t want to delete them). I use Hugo, and it turns out that in Hugo you can define arbitrary taxonomies. So I defined a new taxonomy for these sections (right now it’s called, unimaginitively, `juliasections`). + +The details of how I did this are pretty boring but [here’s the hugo template that makes it display on the homepage][10]. I used this [Hugo documentation page on taxonomies a lot][11]. + +### organizing my site is cool! reverse chronology maybe isn’t the best possible thing! + +Amy Hoy has this interesting article called [how the blog broke the web][12] about how the rise of blog software made people adopt a site format that maybe didn’t serve what they were writing the best. + +I don’t personally feel that mad about the blog / reverse chronology organization: I like blogging! I think it was nice for the first 6 years or whatever to be able to just write things that I think are cool without thinking about where they “fit”. It’s worked really well for me. + +But today, 360,000 words in, I think it makes sense to add a little more structure :). + +### what it looks like now! + +Here’s what the new front page organization looks like! These are the blogging / learning / rust sections! I think it’s cool how you can see the evolution of some of my thinking (I sure have written a lot of posts about asking questions :)). + +![][13] + +### I ❤ the personal website + +This is also part of why I love having a personal website that I can organize any way I want: for both of my main sites ([jvns.ca][1] and now [wizardzines.com][14]) I have total control over how they appear! And I can evolve them over time at my own pace if I decide something a little different will work better for me. I’ve gone from a jekyll blog to octopress to a custom-designed octopress blog to Hugo and made a ton of little changes over time. It’s so nice. + +I think it’s fun that these 3 screenshots are each 3 years apart – what I wanted in 2013 is not the same as 2016 is not the same as 2019! This is okay! + +And I really love seeing how other people choose to organize their personal sites! Please keep making cool different personal sites. + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/02/17/organizing-this-blog-into-categories/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://jvns.ca +[2]: https://jvns.ca/images/website-2013.png +[3]: https://danluu.com +[4]: https://jvns.ca/images/website-2016.png +[5]: https://rachelbythebay.com/w/ +[6]: https://lethain.com/all-posts/ +[7]: https://codewithoutrules.com/worklife/ +[8]: https://github.com/jvns/jvns.ca/blob/2f7b2723994628a5348069dd87b3df68c2f0285c/scripts/titles.txt +[9]: https://github.com/jvns/jvns.ca/blob/2f7b2723994628a5348069dd87b3df68c2f0285c/scripts/parse_titles.py +[10]: https://github.com/jvns/jvns.ca/blob/25d239a3ba36c1bae1d055d2b7d50a4f1d0489ef/themes/orange/layouts/index.html#L39-L59 +[11]: https://gohugo.io/templates/taxonomy-templates/ +[12]: https://stackingthebricks.com/how-blogs-broke-the-web/ +[13]: https://jvns.ca/images/website-2019.png +[14]: https://wizardzines.com diff --git a/sources/tech/20190218 Talk, then code.md b/sources/tech/20190218 Talk, then code.md new file mode 100644 index 0000000000..18ed81e43c --- /dev/null +++ b/sources/tech/20190218 Talk, then code.md @@ -0,0 +1,64 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Talk, then code) +[#]: via: (https://dave.cheney.net/2019/02/18/talk-then-code) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +Talk, then code +====== + +The open source projects that I contribute to follow a philosophy which I describe as _talk, then code_. I think this is generally a good way to develop software and I want to spend a little time talking about the benefits of this methodology. + +### Avoiding hurt feelings + +The most important reason for discussing the change you want to make is it avoids hurt feelings. Often I see a contributor work hard in isolation on a pull request only to find their work is rejected. This can be for a bunch of reasons; the PR is too large, the PR doesn’t follow the local style, the PR fixes an issue which wasn’t important to the project or was recently fixed indirectly, and many more. + +The underlying cause of all these issues is a lack of communication. The goal of the _talk, then code_ philosophy is not to impede or frustrate, but to ensure that a feature lands correctly the first time, without incurring significant maintenance debt, and neither the author of the change, or the reviewer, has to carry the emotional burden of dealing with hurt feelings when a change appears out of the blue with an implicit “well, I’ve done the work, all you have to do is merge it, right?” + +### What does discussion look like? + +Every new feature or bug fix should be discussed with the maintainer(s) of the project before work commences. It’s fine to experiment privately, but do not send a change without discussing it first. + +The definition of _talk_ for simple changes can be as little as a design sketch in a GitHub issue. If your PR fixes a bug, you should link to the bug it fixes. If there isn’t one, you should raise a bug and wait for the maintainers to acknowledge it before sending a PR. This might seem a little backward–who wouldn’t want a bug fixed–but consider the bug could be a misunderstanding in how the software works or it could be a symptom of a larger problem that needs further investigation. + +For more complicated changes, especially feature requests, I recommend that a design document be circulated and agreed upon before sending code. This doesn’t have to be a full blown document, a sketch in an issue may be sufficient, but the key is to reach agreement using words, before locking it in stone with code. + +In all cases you shouldn’t proceed to send code until there is a positive agreement from the maintainer that the approach is one they are happy with. A pull request is for life, not just for Christmas. + +### Code review, not design by committee + +A code review is not the place for arguments about design. This is for two reasons. First, most code review tools are not suitable for long comment threads, GitHub’s PR interface is very bad at this, Gerrit is better, but few have a team of admins to maintain a Gerrit instance. More importantly, disagreements at the code review stage suggests there wasn’t agreement on how the change should be implemented. + +* * * + +Talk about what you want to code, then code what you talked about. Please don’t do it the other way around. + +### Related posts: + + 1. [How to include C code in your Go package][1] + 2. [Let’s talk about logging][2] + 3. [The value of TDD][3] + 4. [Suggestions for contributing to an Open Source project][4] + + + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2019/02/18/talk-then-code + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://dave.cheney.net/2013/09/07/how-to-include-c-code-in-your-go-package (How to include C code in your Go package) +[2]: https://dave.cheney.net/2015/11/05/lets-talk-about-logging (Let’s talk about logging) +[3]: https://dave.cheney.net/2016/04/11/the-value-of-tdd (The value of TDD) +[4]: https://dave.cheney.net/2016/03/12/suggestions-for-contributing-to-an-open-source-project (Suggestions for contributing to an Open Source project) diff --git a/sources/tech/20190219 5 Good Open Source Speech Recognition-Speech-to-Text Systems.md b/sources/tech/20190219 5 Good Open Source Speech Recognition-Speech-to-Text Systems.md deleted file mode 100644 index c7609f5022..0000000000 --- a/sources/tech/20190219 5 Good Open Source Speech Recognition-Speech-to-Text Systems.md +++ /dev/null @@ -1,131 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (5 Good Open Source Speech Recognition/Speech-to-Text Systems) -[#]: via: (https://fosspost.org/lists/open-source-speech-recognition-speech-to-text) -[#]: author: (Simon James https://fosspost.org/author/simonjames) - -5 Good Open Source Speech Recognition/Speech-to-Text Systems -====== - -![](https://i0.wp.com/fosspost.org/wp-content/uploads/2019/02/open-source-speech-recognition-speech-to-text.png?resize=1237%2C527&ssl=1) - -A speech-to-text (STT) system is as its name implies; A way of transforming the spoken words via sound into textual files that can be used later for any purpose. - -Speech-to-text technology is extremely useful. It can be used for a lot of applications such as a automation of transcription, writing books/texts using your own sound only, enabling complicated analyses on information using the generated textual files and a lot of other things. - -In the past, the speech-to-text technology was dominated by proprietary software and libraries; Open source alternatives didn’t exist or existed with extreme limitations and no community around. This is changing, today there are a lot of open source speech-to-text tools and libraries that you can use right now. - -Here we list 5 of them. - -### Open Source Speech Recognition Libraries - -#### Project DeepSpeech - -![5 Good Open Source Speech Recognition/Speech-to-Text Systems 15 open source speech recognition][1] - -This project is made by Mozilla; The organization behind the Firefox browser. It’s a 100% free and open source speech-to-text library that also implies the machine learning technology using TensorFlow framework to fulfill its mission. - -In other words, you can use it to build training models yourself to enhance the underlying speech-to-text technology and get better results, or even to bring it to other languages if you want. You can also easily integrate it to your other machine learning projects that you are having on TensorFlow. Sadly it sounds like the project is currently only supporting English by default. - -It’s also available in many languages such as Python (3.6); Which allows you to have it working in seconds: - -``` -pip3 install deepspeech -deepspeech --model models/output_graph.pbmm --alphabet models/alphabet.txt --lm models/lm.binary --trie models/trie --audio my_audio_file.wav -``` - -You can also install it using npm: - -``` -npm install deepspeech -``` - -For more information, refer to the [project’s homepage][2]. - -#### Kaldi - -![5 Good Open Source Speech Recognition/Speech-to-Text Systems 17 open source speech recognition][3] - -Kaldi is an open source speech recognition software written in C++, and is released under the Apache public license. It works on Windows, macOS and Linux. Its development started back in 2009. - -Kaldi’s main features over some other speech recognition software is that it’s extendable and modular; The community is providing tons of 3rd-party modules that you can use for your tasks. Kaldi also supports deep neural networks, and offers an [excellent documentation on its website][4]. - -While the code is mainly written in C++, it’s “wrapped” by Bash and Python scripts. So if you are looking just for the basic usage of converting speech to text, then you’ll find it easy to accomplish that via either Python or Bash. - -[Project’s homepage][5]. - -#### Julius - -![5 Good Open Source Speech Recognition/Speech-to-Text Systems 19 open source speech recognition][6] - -Probably one of the oldest speech recognition software ever; It’s development started in 1991 at the University of Kyoto, and then its ownership was transferred to an independent project team in 2005. - -Julius main features include its ability to perform real-time STT processes, low memory usage (Less than 64MB for 20000 words), ability to produce N-best/Word-graph output, ability to work as a server unit and a lot more. This software was mainly built for academic and research purposes. It is written in C, and works on Linux, Windows, macOS and even Android (on smartphones). - -Currently it supports both English and Japanese languages only. The software is probably availbale to install easily in your Linux distribution’s repository; Just search for julius package in your package manager. The latest version was [released][7] around one and half months ago. - -[Project’s homepage][8]. - -#### Wav2Letter++ - -![5 Good Open Source Speech Recognition/Speech-to-Text Systems 21 open source speech recognition][9] - -If you are looking for something modern, then this one is for you. Wav2Letter++ is an open source speech recognition software that was released by Facebook’s AI Research Team just 2 months ago. The code is released under the BSD license. - -Facebook is [describing][10] its library as “the fastest state-of-the-art speech recognition system available”. The concepts on which this tool is built makes it optimized for performance by default; Facebook’s also-new machine learning library [FlashLight][11] is used as the underlying core of Wav2Letter++. - -Wav2Letter++ needs you first to build a training model for the language you desire by yourself in order to train the algorithms on it. No pre-built support of any language (including English) is available; It’s just a machine-learning-driven tool to convert speech to text. It was written in C++, hence the name (Wav2Letter++). - -[Project’s homepage][12]. - -#### DeepSpeech2 - -![5 Good Open Source Speech Recognition/Speech-to-Text Systems 23 open source speech recognition][13] - -Researchers at the Chinese giant Baidu are also working on their own speech-to-text engine, called DeepSpeech2. It’s an end-to-end open source engine that uses the “PaddlePaddle” deep learning framework for converting both English & Mandarin Chinese languages speeches into text. The code is released under BSD license. - -The engine can be trained on any model and for any language you desire. The models are not released with the code; You’ll have to build them yourself, just like the other software. DeepSpeech2’s source code is written in Python; So it should be easy for you to get familiar with it if that’s the language you use. - -[Project’s homepage][14]. - -### Conclusion - -The speech recognition category is still mainly dominated by proprietary software giants like Google and IBM (which do provide their own closed-source commercial services for this), but the open source alternatives are promising. Those 5 open source speech recognition engines should get you going in building your application, all of them are still under heavy development by time. In few years, we expect open source to become the norm for those technologies just like in the other industries. - -If you have any other recommendations for this list, or comments in general, we’d love to hear them below! - -** - -Shares - - --------------------------------------------------------------------------------- - -via: https://fosspost.org/lists/open-source-speech-recognition-speech-to-text - -作者:[Simon James][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fosspost.org/author/simonjames -[b]: https://github.com/lujun9972 -[1]: https://i0.wp.com/fosspost.org/wp-content/uploads/2019/02/hero_speech-machine-learning2.png?resize=820%2C280&ssl=1 (5 Good Open Source Speech Recognition/Speech-to-Text Systems 16 open source speech recognition) -[2]: https://github.com/mozilla/DeepSpeech -[3]: https://i0.wp.com/fosspost.org/wp-content/uploads/2019/02/Screenshot-at-2019-02-19-1134.png?resize=591%2C138&ssl=1 (5 Good Open Source Speech Recognition/Speech-to-Text Systems 18 open source speech recognition) -[4]: http://kaldi-asr.org/doc/index.html -[5]: http://kaldi-asr.org -[6]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/02/mic_web.png?resize=385%2C100&ssl=1 (5 Good Open Source Speech Recognition/Speech-to-Text Systems 20 open source speech recognition) -[7]: https://github.com/julius-speech/julius/releases -[8]: https://github.com/julius-speech/julius -[9]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/02/fully_convolutional_ASR.png?resize=850%2C177&ssl=1 (5 Good Open Source Speech Recognition/Speech-to-Text Systems 22 open source speech recognition) -[10]: https://code.fb.com/ai-research/wav2letter/ -[11]: https://github.com/facebookresearch/flashlight -[12]: https://github.com/facebookresearch/wav2letter -[13]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/02/ds2.png?resize=850%2C313&ssl=1 (5 Good Open Source Speech Recognition/Speech-to-Text Systems 24 open source speech recognition) -[14]: https://github.com/PaddlePaddle/DeepSpeech diff --git a/sources/tech/20190225 How to Install VirtualBox on Ubuntu -Beginner-s Tutorial.md b/sources/tech/20190225 How to Install VirtualBox on Ubuntu -Beginner-s Tutorial.md deleted file mode 100644 index 4ba0580ece..0000000000 --- a/sources/tech/20190225 How to Install VirtualBox on Ubuntu -Beginner-s Tutorial.md +++ /dev/null @@ -1,156 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to Install VirtualBox on Ubuntu [Beginner’s Tutorial]) -[#]: via: (https://itsfoss.com/install-virtualbox-ubuntu) -[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) - -How to Install VirtualBox on Ubuntu [Beginner’s Tutorial] -====== - -**This beginner’s tutorial explains various ways to install VirtualBox on Ubuntu and other Debian-based Linux distributions.** - -Oracle’s free and open source offering [VirtualBox][1] is an excellent virtualization tool, specially for desktop operating systems. I prefer using it over [VMWare Workstation in Linux][2], another virtualization tool. - -You can use virtualization software like VirtualBox for installing and using another operating system within a virtual machine. - -For example, you can [install Linux on VirtualBox inside Windows][3]. Similarly, you can also [install Windows inside Linux using VirtualBox][4]. - -You can also use VirtualBox for installing another Linux distribution in your current Linux system. Actually, this is what I use it for. If I hear about a nice Linux distribution, instead of installing it on a real system, I test it on a virtual machine. It’s more convenient when you just want to try out a distribution before making a decision about installing it on your actual machine. - -![Linux installed inside Linux using VirtualBox][5]Ubuntu 18.10 installed inside Ubuntu 18.04 - -In this beginner’s tutorial, I’ll show you various ways of installing Oracle VirtualBox on Ubuntu and other Debian-based distributions. - -### Installing VirtualBox on Ubuntu and Debian based Linux distributions - -The installation methods mentioned here should also work for other Debian and Ubuntu-based Linux distributions such as Linux Mint, elementary OS etc. - -#### Method 1: Install VirtualBox from Ubuntu Repository - -**Pros** : Easy installation - -**Cons** : Installs older version - -The easiest way to install VirtualBox on Ubuntu would be to search for it in the Software Center and install it from there. - -![VirtualBox in Ubuntu Software Center][6]VirtualBox is available in Ubuntu Software Center - -You can also install it from the command line using the command: - -``` -sudo apt install virtualbox -``` - -However, if you [check the package version before installing it][7], you’ll see that the VirtualBox provided by Ubuntu’s repository is quite old. - -For example, the current VirtualBox version at the time of writing this tutorial is 6.0 but the one in Software Center is 5.2. This means you won’t get the newer features introduced in the [latest version of VirtualBox][8]. - -#### Method 2: Install VirtualBox using Deb file from Oracle’s website - -**Pros** : Easily install the latest version - -**Cons** : Can’t upgrade to newer version - -If you want to use the latest version of VirtualBox on Ubuntu, the easiest way would be to [use the deb file][9]. - -Oracle provides read to use binary files for VirtualBox releases. If you look at its download page, you’ll see the option to download the deb installer files for Ubuntu and other distributions. - -![VirtualBox Linux Download][10] - -You just have to download this deb file and double click on it to install it. It’s as simple as that. - -However, the problem with this method is that you won’t get automatically updated to the newer VirtualBox releases. The only way is to remove the existing version, download the newer version and install it again. That’s not very convenient, is it? - -#### Method 3: Install VirualBox using Oracle’s repository - -**Pros** : Automatically updates with system updates - -**Cons** : Slightly complicated installation - -Now this is the command line method and it may seem complicated to you but it has advantages over the previous two methods. You’ll get the latest version of VirtualBox and it will be automatically updated to the future releases. That’s what you would want, I presume. - -To install VirtualBox using command line, you add the Oracle VirtualBox’s repository in your list of repositories. You add its GPG key so that your system trusts this repository. Now when you install VirtualBox, it will be installed from Oracle’s repository instead of Ubuntu’s repository. If there is a new version released, VirtualBox install will be updated along with the system updates. Let’s see how to do that. - -First, add the key for the repository. You can download and add the key using this single command. - -``` -wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - -``` - -``` -Important for Mint users - -The next step will work for Ubuntu only. If you are using Linux Mint or some other distribution based on Ubuntu, replace $(lsb_release -cs) in the command with the Ubuntu version your current version is based on. For example, Linux Mint 19 series users should use bionic and Mint 18 series users should use xenial. Something like this - -sudo add-apt-repository “deb [arch=amd64] **bionic** contrib“ -``` - -Now add the Oracle VirtualBox repository in the list of repositories using this command: - -``` -sudo add-apt-repository "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" -``` - -If you have read my article on [checking Ubuntu version][11], you probably know that ‘lsb_release -cs’ will print the codename of your Ubuntu system. - -**Note** : If you see [add-apt-repository command not found][12] error, you’ll have to install software-properties-common package. - -Now that you have the correct repository added, refresh the list of available packages through these repositories and install VirtualBox. - -``` -sudo apt update && sudo apt install virtualbox-6.0 -``` - -**Tip** : A good idea would be to type sudo apt install **virtualbox–** and hit tab to see the various VirtualBox versions available for installation and then select one of them by typing it completely. - -![Install VirtualBox via terminal][13] - -### How to remove VirtualBox from Ubuntu - -Now that you have learned to install VirtualBox, I would also mention the steps to remove it. - -If you installed it from the Software Center, the easiest way to remove the application is from the Software Center itself. You just have to find it in the [list of installed applications][14] and click the Remove button. - -Another ways is to use the command line. - -``` -sudo apt remove virtualbox virtualbox-* -``` - -Note that this will not remove the virtual machines and the files associated with the operating systems you installed using VirtualBox. That’s not entirely a bad thing because you may want to keep them safe to use it later or in some other system. - -**In the end…** - -I hope you were able to pick one of the methods to install VirtualBox. I’ll also write about using it effectively in another article. For the moment, if you have and tips or suggestions or any questions, feel free to leave a comment below. - - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/install-virtualbox-ubuntu - -作者:[Abhishek Prakash][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/abhishek/ -[b]: https://github.com/lujun9972 -[1]: https://www.virtualbox.org -[2]: https://itsfoss.com/install-vmware-player-ubuntu-1310/ -[3]: https://itsfoss.com/install-linux-in-virtualbox/ -[4]: https://itsfoss.com/install-windows-10-virtualbox-linux/ -[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/linux-inside-linux-virtualbox.png?resize=800%2C450&ssl=1 -[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/virtualbox-ubuntu-software-center.jpg?ssl=1 -[7]: https://itsfoss.com/know-program-version-before-install-ubuntu/ -[8]: https://itsfoss.com/oracle-virtualbox-release/ -[9]: https://itsfoss.com/install-deb-files-ubuntu/ -[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/virtualbox-download.jpg?resize=800%2C433&ssl=1 -[11]: https://itsfoss.com/how-to-know-ubuntu-unity-version/ -[12]: https://itsfoss.com/add-apt-repository-command-not-found/ -[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/install-virtualbox-ubuntu-terminal.png?resize=800%2C165&ssl=1 -[14]: https://itsfoss.com/list-installed-packages-ubuntu/ diff --git a/sources/tech/20190301 Emacs for (even more of) the win.md b/sources/tech/20190301 Emacs for (even more of) the win.md deleted file mode 100644 index c1697f3cae..0000000000 --- a/sources/tech/20190301 Emacs for (even more of) the win.md +++ /dev/null @@ -1,84 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Emacs for (even more of) the win) -[#]: via: (https://so.nwalsh.com/2019/03/01/emacs) -[#]: author: (Norman Walsh https://so.nwalsh.com) - -Emacs for (even more of) the win -====== - -I use Emacs every day. I rarely notice it. But when I do, it usually brings me joy. - ->If you are a professional writer…Emacs outshines all other editing software in approximately the same way that the noonday sun does the stars. It is not just bigger and brighter; it simply makes everything else vanish. - -I’ve been using [Emacs][1] for well over twenty years. I use it for writing almost anything and everything (I edit Scala and Java in [IntelliJ][2]). I read my email in it. If it can be done in Emacs, that’s where I prefer to do it. - -Although I’ve used Emacs for literally decades, I realized around the new year that very little about my use of Emacs had changed in the past decade or more. New editing modes had come along, of course, I’d picked up a package or two, and I did adopt [Helm][3] a few years ago, but mostly it just did all the heavy lifting that I required of it, day in and day out without complaining or getting in my way. On the one hand, that’s a testament to how good it is. On the other hand, that’s an invitation to dig in and see what I’ve missed. - -At about the same time, I resolved to improve several aspects of my work life: - - * **Better meeting management.** I’m lead on a couple of projects at work and those projects have meetings, both regularly scheduled and ad hoc; some of them I run, some of them, I only attend. - -I realized I’d become sloppy about my participation in meetings. It’s all too easy sit in a room where there’s a meeting going on but actually read email and work on other items. (I strongly oppose the “no laptops” rule in meetings, but that’s a topic for another day.) - -There are a couple of problems with sloppy participation. First, it’s disrespectful to the person who convened the meeting and the other participants. That’s actually sufficient reason not to do it, but I think there’s another problem: it disguises the cost of meetings. - -If you’re in a meeting but also answering your email and maybe fixing a bug, then that meeting didn’t cost anything (or as much). If meetings are cheap, then there will be more of them. - -I want fewer, shorter meetings. I don’t want to disguise their cost, I want them to be perceived as damned expensive and to be avoided unless absolutely necessary. - -Sometimes, they are absolutely necessary. And I appreciate that a quick meeting can sometimes resolve an issue quickly. But if I have ten short meetings a day, let’s not pretend that I’m getting anything else productive accomplished. - -I resolved to take notes at all the meetings I attend. I’m not offering to take minutes, necessarily, but I am taking minutes of a sort. It keeps me focused on the meeting and not catching up on other things. - - * **Better time management.** There are lots and lots of things that I need or want to do, both professionally and personally. I’ve historically kept track off some of them in issue lists, some in saved email threads (in Emacs and [Gmail][4], for slightly different types of reminders), in my calendar, on “todo lists” of various sorts on my phone, and on little scraps of paper. And probably other places as well. - -I resolved to keep them all in one place. Not because I think there’s one place that’s uniformly best or better, but because I hope to accomplish two things. First, by having them all in one place, I hope to be able to develop a better and more holistic view of where I’m putting my energies. Second, because I want to develop a habitn. “A settled or regular tendency or practice, especially one that is hard to give up.” of recording, tracking, and preserving them. - - * **Better accountability.** If you work in certain science or engineering disciplines, you will have developed the habit of keeping a [lab notebook][5]. Alas, I did not. But I resolved to do so. - -I’m not interested in the legal aspects that encourage bound pages or scribing only in permanent marker. What I’m interested in is developing the habit of keeping a record. My goal is to have a place to jot down ideas and design sketches and the like. If I have sudden inspiration or if I think of an edge case that isn’t in the test suite, I want my instinct to be to write it in my journal instead of scribbling it on a scrap of paper or promising myself that I’ll remember it. - - - - -This confluence of resolutions led me quickly and more-or-less directly to [Org][6]. There is a large, active, and loyal community of Org users. I’ve played with it in the past (I even [wrote about it][7], at least in passing, a couple of years ago) and I tinkered long enough to [integrate MarkLogic][8] into it. (Boy has that paid off in the last week or two!) - -But I never used it. - -I am now using it. I take minutes in it, I record all of my todo items in it, and I keep a journal in it. I’m not sure there’s much value in me attempting to wax eloquent about it or enumerate all its features, you’ll find plenty of either with a quick web search. - -If you use Emacs, you should be using Org. If you don’t use Emacs, I’m confident you wouldn’t be the first person who started because of Org. It does a lot. It takes a little time to learn your way around and remember the shortcuts, but I think it’s worth it. (And if you carry an [iOS][9] device in your pocket, I recommend [beorg][10] for recording items while you’re on the go.) - -Naturally, I worked out how to [get XML out of it][11]⊕“Worked out” sure is a funny way to spell “hacked together in elisp.”. And from there, how to turn it back into the markup my weblog expects (and do so at the push of a button in Emacs, of course). So this is the first posting written in Org. It won’t be the last. - -P.S. Happy birthday [little weblog][12]. - --------------------------------------------------------------------------------- - -via: https://so.nwalsh.com/2019/03/01/emacs - -作者:[Norman Walsh][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://so.nwalsh.com -[b]: https://github.com/lujun9972 -[1]: https://en.wikipedia.org/wiki/Emacs -[2]: https://en.wikipedia.org/wiki/IntelliJ_IDEA -[3]: https://emacs-helm.github.io/helm/ -[4]: https://en.wikipedia.org/wiki/Gmail -[5]: https://en.wikipedia.org/wiki/Lab_notebook -[6]: https://en.wikipedia.org/wiki/Org-mode -[7]: https://www.balisage.net/Proceedings/vol17/html/Walsh01/BalisageVol17-Walsh01.html -[8]: https://github.com/ndw/ob-ml-marklogic/ -[9]: https://en.wikipedia.org/wiki/IOS -[10]: https://beorgapp.com/ -[11]: https://github.com/ndw/org-to-xml -[12]: https://so.nwalsh.com/2017/03/01/helloWorld diff --git a/sources/tech/20190302 Create a Custom System Tray Indicator For Your Tasks on Linux.md b/sources/tech/20190302 Create a Custom System Tray Indicator For Your Tasks on Linux.md deleted file mode 100644 index d9d42b7a2f..0000000000 --- a/sources/tech/20190302 Create a Custom System Tray Indicator For Your Tasks on Linux.md +++ /dev/null @@ -1,187 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (lujun9972) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Create a Custom System Tray Indicator For Your Tasks on Linux) -[#]: via: (https://fosspost.org/tutorials/custom-system-tray-icon-indicator-linux) -[#]: author: (M.Hanny Sabbagh https://fosspost.org/author/mhsabbagh) - -Create a Custom System Tray Indicator For Your Tasks on Linux -====== - -System Tray icons are still considered to be an amazing functionality today. By just right-clicking on the icon, and then selecting which actions you would like to take, you may ease your life a lot and save many unnecessary clicks on daily basis. - -When talking about useful system tray icons, examples like Skype, Dropbox and VLC do come to mind: - -![Create a Custom System Tray Indicator For Your Tasks on Linux 11][1] - -However, system tray icons can actually be quite a lot more useful; By simply building one yourself for your own needs. In this tutorial, we’ll explain how to do that for you in very simple steps. - -### Prerequisites - -We are going to build a custom system tray indicator using Python. Python is probably installed by default on all the major Linux distributions, so just check it’s there (version 2.7). Additionally, we’ll need the gir1.2-appindicator3 package installed. It’s the library allowing us to easily create system tray indicators. - -To install it on Ubuntu/Mint/Debian: - -``` -sudo apt-get install gir1.2-appindicator3 -``` - -On Fedora: - -``` -sudo dnf install libappindicator-gtk3 -``` - -For other distributions, just search for any packages containing appindicator. - -On GNOME Shell, system tray icons are removed starting from 3.26. You’ll need to install the [following extension][2] (Or possibly other extensions) to re-enable the feature on your desktop. Otherwise, you won’t be able to see the indicator we are going to create here. - -### Basic Code - -Here’s the basic code of the indicator: - -``` -#!/usr/bin/python -import os -from gi.repository import Gtk as gtk, AppIndicator3 as appindicator - -def main(): - indicator = appindicator.Indicator.new("customtray", "semi-starred-symbolic", appindicator.IndicatorCategory.APPLICATION_STATUS) - indicator.set_status(appindicator.IndicatorStatus.ACTIVE) - indicator.set_menu(menu()) - gtk.main() - -def menu(): - menu = gtk.Menu() - - command_one = gtk.MenuItem('My Notes') - command_one.connect('activate', note) - menu.append(command_one) - - exittray = gtk.MenuItem('Exit Tray') - exittray.connect('activate', quit) - menu.append(exittray) - - menu.show_all() - return menu - -def note(_): - os.system("gedit $HOME/Documents/notes.txt") - -def quit(_): - gtk.main_quit() - -if __name__ == "__main__": - main() -``` - -We’ll explain how the code works later. But for know, just save it in a text file under the name tray.py, and run it using Python: - -``` -python tray.py -``` - -You’ll see the indicator working as follows: - -![Create a Custom System Tray Indicator For Your Tasks on Linux 13][3] - -Now, to explain how we did the magic: - - * The first 3 lines of the code are nothing more than just specifying the Python path and importing the libraries we are going to use in our indicator. - - * def main() : This is the main function of the indicator. Under it we write the code to initialize and build the indicator. - - * indicator = appindicator.Indicator.new(“customtray”, “semi-starred-symbolic”, appindicator.IndicatorCategory.APPLICATION_STATUS) : Here we are specially creating a new indicator and calling it `customtray` . This is the special name of the indicator so that the system doesn’t mix it with other indicators that may be running. Also, we used the `semi-starred-symbolic` icon name as the default icon for our indicator. You could possibly change thing to any other things; Say `firefox` (if you want to see Firefox icon being used for the indicator), or any other icon name you would like. The last part regarding the `APPLICATION_STATUS` is just ordinary code for the categorization/scope of that indicator. - - * `indicator.set_status(appindicator.IndicatorStatus.ACTIVE)` : This line just turns the indicator on. - - * `indicator.set_menu(menu())` : Here, we are saying that we want to use the `menu()` function (which we’ll define later) for creating the menu items of our indicator. This is important so that when you click on the indicator, you can see a list of possible actions to take. - - * `gtk.main()` : Just run the main GTK loop. - - * Under `menu()` you’ll see that we are creating the actions/items we want to provide using our indicator. `command_one = gtk.MenuItem(‘My Notes’)` simply initializes the first menu item with the text “My notes”, and then `command_one.connect(‘activate’, note)` connects the `activate` signal of that menu item to the `note()` function defined later; In other words, we are telling our system here: “When this menu item is clicked, run the note() function”. Finally, `menu.append(command_one)` adds that menu item to the list. - - * The lines regarding `exittray` are just for creating an exit menu item to close the indicator any time you want. - - * `menu.show_all()` and `return menu` are just ordinary codes for returning the menu list to the indicator. - - * Under `note(_)` you’ll see the code that must be executed when the “My Notes” menu item is clicked. Here, we just wrote `os.system(“gedit $HOME/Documents/notes.txt”)` ; The `os.system` function is a function that allows us to run shell commands from inside Python, so here we wrote a command to open a file called `notes.txt` under the `Documents` folder in our home directory using the `gedit` editor. This for example can be your daily notes taking program from now on! - -### Adding your Needed Tasks - -There are only 2 things you need to touch in the code: - - 1. Define a new menu item under `menu()` for your desired task. - - 2. Create a new function to run a specific action when that menu item is clicked. - - -So, let’s say that you want to create a new menu item, which when clicked, plays a specific video/audio file on your hard disk using VLC? To do it, simply add the following 3 lines in line 17: - -``` -command_two = gtk.MenuItem('Play video/audio') -command_two.connect('activate', play) -menu.append(command_two) -``` - -And the following lines in line 30: - -``` -def play(_): - os.system("vlc /home//Videos/somevideo.mp4") -``` - -Replace /home//Videos/somevideo.mp4 with the path to the video/audio file you want. Now save the file and run the indicator again: - -``` -python tray.py -``` - -This is how you’ll see it now: - -![Create a Custom System Tray Indicator For Your Tasks on Linux 15][4] - -And when you click on the newly-created menu item, VLC will start playing! - -To create other items/tasks, simply redo the steps again. Just be careful to replace command_two with another name, like command_three, so that no clash between variables happen. And then define new separate functions like what we did with the play(_) function. - -The possibilities are endless from here; I am using this way for example to fetch some data from the web (using the urllib2 library) and display them for me any time. I am also using it for playing an mp3 file in the background using the mpg123 command, and I am defining another menu item to killall mpg123 to stop playing that audio whenever I want. CS:GO on Steam for example takes a huge time to exit (the window doesn’t close automatically), so as a workaround for this, I simply minimize the window and click on a menu item that I created which will execute killall -9 csgo_linux64. - -You can use this indicator for anything: Updating your system packages, possibly running some other scripts any time you want.. Literally anything. - -### Autostart on Boot - -We want our system tray indicator to start automatically on boot, we don’t want to run it manually each time. To do that, simply add the following command to your startup applications (after you replace the path to the tray.py file with yours): - -``` -nohup python /home//tray.py & -``` - -The very next time you reboot your system, the indicator will start working automatically after boot! - -### Conclusion - -You now know how to create your own system tray indicator for any task that you may want. This method should save you a lot of time depending on the nature and number of tasks you need to run on daily basis. Some users may prefer creating aliases from the command line, but this will require you to always open the terminal window or have a drop-down terminal emulator available, while here, the system tray indicator is always working and available for you. - -Have you used this method to run your tasks before? Would love to hear your thoughts. - - --------------------------------------------------------------------------------- - -via: https://fosspost.org/tutorials/custom-system-tray-icon-indicator-linux - -作者:[M.Hanny Sabbagh][a] -选题:[lujun9972][b] -译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fosspost.org/author/mhsabbagh -[b]: https://github.com/lujun9972 -[1]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/02/Screenshot-at-2019-02-28-0808.png?resize=407%2C345&ssl=1 (Create a Custom System Tray Indicator For Your Tasks on Linux 12) -[2]: https://extensions.gnome.org/extension/1031/topicons/ -[3]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/03/Screenshot-at-2019-03-02-1041.png?resize=434%2C140&ssl=1 (Create a Custom System Tray Indicator For Your Tasks on Linux 14) -[4]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/03/Screenshot-at-2019-03-02-1141.png?resize=440%2C149&ssl=1 (Create a Custom System Tray Indicator For Your Tasks on Linux 16) diff --git a/sources/tech/20190304 How to Install MongoDB on Ubuntu.md b/sources/tech/20190304 How to Install MongoDB on Ubuntu.md deleted file mode 100644 index 30d588ddba..0000000000 --- a/sources/tech/20190304 How to Install MongoDB on Ubuntu.md +++ /dev/null @@ -1,238 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (An-DJ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to Install MongoDB on Ubuntu) -[#]: via: (https://itsfoss.com/install-mongodb-ubuntu) -[#]: author: (Sergiu https://itsfoss.com/author/sergiu/) - -How to Install MongoDB on Ubuntu -====== - -**This tutorial presents two ways to install MongoDB on Ubuntu and Ubuntu-based Linux distributions.** - -[MongoDB][1] is an increasingly popular free and open-source NoSQL database that stores data in collections of JSON-like, flexible documents, in contrast to the usual table approach you’ll find in SQL databases. - -You are most likely to find MongoDB used in modern web applications. Its document model makes it very intuitive to access and handle with various programming languages. - -![mongodb Ubuntu][2] - -In this article, I’ll cover two ways you can install MongoDB on your Ubuntu system. - -### Installing MongoDB on Ubuntu based Distributions - - 1. Install MongoDB using Ubuntu’s repository. Easy but not the latest version of MongoDB - 2. Install MongoDB using its official repository. Slightly complicated but you get the latest version of MongoDB. - - - -The first installation method is easier, but I recommend the second method if you plan on using the latest release with official support. - -Some people might prefer using snap packages. There are snaps available in the Ubuntu Software Center, but I wouldn’t recommend using them; they’re outdated at the moment and I won’t be covering that. - -#### Method 1. Install MongoDB from Ubuntu Repository - -This is the easy way to install MongoDB on your system, you only need to type in a simple command. - -##### Installing MongoDB - -First, make sure your packages are up-to-date. Open up a terminal and type: - -``` -sudo apt update && sudo apt upgrade -y -``` - -Go ahead and install MongoDB with: - -``` -sudo apt install mongodb -``` - -That’s it! MongoDB is now installed on your machine. - -The MongoDB service should automatically be started on install, but to check the status type - -``` -sudo systemctl status mongodb -``` - -![Check if the MongoDB service is running.][3] - -You can see that the service is **active**. - -##### Running MongoDB - -MongoDB is currently a systemd service, so we’ll use **systemctl** to check and modify it’s state, using the following commands: - -``` -sudo systemctl status mongodb -sudo systemctl stop mongodb -sudo systemctl start mongodb -sudo systemctl restart mongodb -``` - -You can also change if MongoDB automatically starts when the system starts up ( **default** : enabled): - -``` -sudo systemctl disable mongodb -sudo systemctl enable mongodb -``` - -To start working with (creating and editing) databases, type: - -``` -mongo -``` - -This will start up the **mongo shell**. Please check out the [manual][4] for detailed information on the available queries and options. - -**Note:** Depending on how you plan to use MongoDB, you might need to adjust your Firewall. That’s unfortunately more involved than what I can cover here and depends on your configuration. - -##### Uninstall MongoDB - -If you installed MongoDB from the Ubuntu Repository and want to uninstall it (maybe to install using the officially supported way), type: - -``` -sudo systemctl stop mongodb -sudo apt purge mongodb -sudo apt autoremove -``` - -This should completely get rid of your MongoDB install. Make sure to **backup** any collections or documents you might want to keep since they will be wiped out! - -#### Method 2. Install MongoDB Community Edition on Ubuntu - -This is the way the recommended way to install MongoDB, using the package manager. You’ll have to type a few more commands and it might be intimidating if you are newer to the Linux world. - -But there’s nothing to be afraid of! We’ll go through the installation process step by step. - -##### Installing MongoDB - -The package maintained by MongoDB Inc. is called **mongodb-org** , not **mongodb** (this is the name of the package in the Ubuntu Repository). Make sure **mongodb** is not installed on your system before applying this steps. The packages will conflict. Let’s get to it! - -First, we’ll have to import the public key: - -``` -sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 -``` - -Now, you need to add a new repository in your sources list so that you can install MongoDB Community Edition and also get automatic updates: - -``` -echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list -``` - -To be able to install **mongodb-org** , we’ll have to update our package database so that your system is aware of the new packages available: - -``` -sudo apt update -``` - -Now you can ether install the **latest stable version** of MongoDB: - -``` -sudo apt install -y mongodb-org -``` - -or a **specific version** (change the version number after **equal** sign) - -``` -sudo apt install -y mongodb-org=4.0.6 mongodb-org-server=4.0.6 mongodb-org-shell=4.0.6 mongodb-org-mongos=4.0.6 mongodb-org-tools=4.0.6 -``` - -If you choose to install a specific version, make sure you change the version number everywhere. If you only change it in the **mongodb-org=4.0.6** part, the latest version will be installed. - -By default, when updating using the package manager ( **apt-get** ), MongoDB will be updated to the newest updated version. To stop that from happening (and freezing to the installed version), use: - -``` -echo "mongodb-org hold" | sudo dpkg --set-selections -echo "mongodb-org-server hold" | sudo dpkg --set-selections -echo "mongodb-org-shell hold" | sudo dpkg --set-selections -echo "mongodb-org-mongos hold" | sudo dpkg --set-selections -echo "mongodb-org-tools hold" | sudo dpkg --set-selections -``` - -You have now successfully installed MongoDB! - -##### Configuring MongoDB - -By default, the package manager will create **/var/lib/mongodb** and **/var/log/mongodb** and MongoDB will run using the **mongodb** user account. - -I won’t go into changing these default settings since that is beyond the scope of this guide. You can check out the [manual][5] for detailed information. - -The settings in **/etc/mongod.conf** are applied when starting/restarting the **mongodb** service instance. - -##### Running MongoDB - -To start the mongodb daemon **mongod** , type: - -``` -sudo service mongod start -``` - -Now you should verify that the **mongod** process started successfully. This information is stored (by default) at **/var/log/mongodb/mongod.log**. Let’s check the contents of that file: - -``` -sudo cat /var/log/mongodb/mongod.log -``` - -![Check MongoDB logs to see if the process is running properly.][6] - -As long as you get this: **[initandlisten] waiting for connections on port 27017** somewhere in there, the process is running properly. - -**Note: 27017** is the default port of **mongod.** - -To stop/restart **mongod** enter: - -``` -sudo service mongod stop -sudo service mongod restart -``` - -Now, you can use MongoDB by opening the **mongo shell** : - -``` -mongo -``` - -##### Uninstall MongoDB - -Run the following commands - -``` -sudo service mongod stop -sudo apt purge mongodb-org* -``` - -To remove the **databases** and **log files** (make sure to **backup** what you want to keep!): - -``` -sudo rm -r /var/log/mongodb -sudo rm -r /var/lib/mongodb -``` - -**Wrapping Up** - -MongoDB is a great NoSQL database, easy to integrate into modern projects. I hope this tutorial helped you to set it up on your Ubuntu machine! Let us know how you plan on using MongoDB in the comments below. - - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/install-mongodb-ubuntu - -作者:[Sergiu][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/sergiu/ -[b]: https://github.com/lujun9972 -[1]: https://www.mongodb.com/ -[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/03/mongodb-ubuntu.jpeg?resize=800%2C450&ssl=1 -[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/mongodb_check_status.jpg?fit=800%2C574&ssl=1 -[4]: https://docs.mongodb.com/manual/tutorial/getting-started/ -[5]: https://docs.mongodb.com/manual/ -[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/mongodb_org_check_logs.jpg?fit=800%2C467&ssl=1 diff --git a/sources/tech/20190306 ClusterShell - A Nifty Tool To Run Commands On Cluster Nodes In Parallel.md b/sources/tech/20190306 ClusterShell - A Nifty Tool To Run Commands On Cluster Nodes In Parallel.md deleted file mode 100644 index 8f69143d36..0000000000 --- a/sources/tech/20190306 ClusterShell - A Nifty Tool To Run Commands On Cluster Nodes In Parallel.md +++ /dev/null @@ -1,309 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (ClusterShell – A Nifty Tool To Run Commands On Cluster Nodes In Parallel) -[#]: via: (https://www.2daygeek.com/clustershell-clush-run-commands-on-cluster-nodes-remote-system-in-parallel-linux/) -[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) - -ClusterShell – A Nifty Tool To Run Commands On Cluster Nodes In Parallel -====== - -We had written two articles in the past to run commands on multiple remote server in parallel. - -These are **[Parallel SSH (PSSH)][1]** or **[Distributed Shell (DSH)][2]**. - -Today also, we are going to discuss about the same kind of topic but it allows us to perform the same on cluster nodes as well. - -You may think, i can write a small shell script to archive this instead of installing these third party packages. - -Of course you are right and if you are going to run some commands in 10-15 remote systems then you don’t need to use this. - -However, the scripts take some time to complete this task as it’s running in a sequential order. - -Think about if you would like to run some commands on 1000+ servers what will be the options? - -In this case your script won’t help you. Also, it would take good amount of time to complete a task. - -So, to overcome this kind of issue and situation. We need to run the command in parallel on remote machines. - -For that, we need use in one of the Parallel applications. I hope this explanation might fulfilled your doubts about parallel utilities. - -### What Is ClusterShell? - -clush stands for [ClusterShell][3]. ClusterShell is an event-driven open source Python library, designed to run local or distant commands in parallel on server farms or on large Linux clusters. - -It will take care of common issues encountered on HPC clusters, such as operating on groups of nodes, running distributed commands using optimized execution algorithms, as well as gathering results and merging identical outputs, or retrieving return codes. - -ClusterShell takes advantage of existing remote shell facilities already installed on your systems, like SSH. - -ClusterShell’s primary goal is to improve the administration of high- performance clusters by providing a lightweight but scalable Python API for developers. It also provides clush, clubak and cluset/nodeset, convenient command-line tools that allow traditional shell scripts to benefit from some of the library features. - -ClusterShell’s written in Python and it requires Python (v2.6+ or v3.4+) to run on your system. - -### How To Install ClusterShell On Linux? - -ClusterShell package is available in most of the distribution official package manager. So, use the distribution package manager tool to install it. - -For **`Fedora`** system, use **[DNF Command][4]** to install clustershell. - -``` -$ sudo dnf install clustershell -``` - -Python 2 module and tools are installed and if it’s default on your system then run the following command to install Python 3 development on Fedora System. - -``` -$ sudo dnf install python3-clustershell -``` - -Make sure you should have enabled the **[EPEL repository][5]** on your system before performing clustershell installation. - -For **`RHEL/CentOS`** systems, use **[YUM Command][6]** to install clustershell. - -``` -$ sudo yum install clustershell -``` - -Python 2 module and tools are installed and if it’s default on your system then run the following command to install Python 3 development on CentOS/RHEL System. - -``` -$ sudo yum install python34-clustershell -``` - -For **`openSUSE Leap`** system, use **[Zypper Command][7]** to install clustershell. - -``` -$ sudo zypper install clustershell -``` - -Python 2 module and tools are installed and if it’s default on your system then run the following command to install Python 3 development on OpenSUSE System. - -``` -$ sudo zypper install python3-clustershell -``` - -For **`Debian/Ubuntu`** systems, use **[APT-GET Command][8]** or **[APT Command][9]** to install clustershell. - -``` -$ sudo apt install clustershell -``` - -### How To Install ClusterShell In Linux Using PIP? - -Use PIP to install ClusterShell because it’s written in Python. - -Make sure you should have enabled the **[Python][10]** and **[PIP][11]** on your system before performing clustershell installation. - -``` -$ sudo pip install ClusterShell -``` - -### How To Use ClusterShell On Linux? - -It’s straight forward and awesome tool compared with other utilities such as pssh and dsh. It has so many options to perform the remote execution in parallel. - -Make sure you should have enabled the **[password less login][12]** on your system before start using clustershell. - -The following configuration file defines system-wide default values. You no need to modify anything here. - -``` -$ cat /etc/clustershell/clush.conf -``` - -If you would like to create a servers group. Here you can go. By default some examples were available so, do the same for your requirements. - -``` -$ cat /etc/clustershell/groups.d/local.cfg -``` - -Just run the clustershell command in the following format to get the information from the given nodes. - -``` -$ clush -w 192.168.1.4,192.168.1.9 cat /proc/version -192.168.1.9: Linux version 4.15.0-45-generic ([email protected]) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 -192.168.1.4: Linux version 3.10.0-957.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Thu Nov 8 23:39:32 UTC 2018 -``` - -**Option:** - - * **`-w:`** nodes where to run the command. - - - -You can use the regular expressions instead of using full hostname and IPs. - -``` -$ clush -w 192.168.1.[4,9] uname -r -192.168.1.9: 4.15.0-45-generic -192.168.1.4: 3.10.0-957.el7.x86_64 -``` - -Alternatively you can use the following format if you have the servers in the same IP series. - -``` -$ clush -w 192.168.1.[4-9] date -192.168.1.6: Mon Mar 4 21:08:29 IST 2019 -192.168.1.7: Mon Mar 4 21:08:29 IST 2019 -192.168.1.8: Mon Mar 4 21:08:29 IST 2019 -192.168.1.5: Mon Mar 4 09:16:30 CST 2019 -192.168.1.9: Mon Mar 4 21:08:29 IST 2019 -192.168.1.4: Mon Mar 4 09:16:30 CST 2019 -``` - -clustershell allow us to run the command in batch mode. Use the following format to achieve this. - -``` -$ clush -w 192.168.1.4,192.168.1.9 -b -Enter 'quit' to leave this interactive mode -Working with nodes: 192.168.1.[4,9] -clush> hostnamectl ---------------- -192.168.1.4 ---------------- - Static hostname: CentOS7.2daygeek.com - Icon name: computer-vm - Chassis: vm - Machine ID: 002f47b82af248f5be1d67b67e03514c - Boot ID: f9b37a073c534dec8b236885e754cb56 - Virtualization: kvm - Operating System: CentOS Linux 7 (Core) - CPE OS Name: cpe:/o:centos:centos:7 - Kernel: Linux 3.10.0-957.el7.x86_64 - Architecture: x86-64 ---------------- -192.168.1.9 ---------------- - Static hostname: Ubuntu18 - Icon name: computer-vm - Chassis: vm - Machine ID: 27f6c2febda84dc881f28fd145077187 - Boot ID: f176f2eb45524d4f906d12e2b5716649 - Virtualization: oracle - Operating System: Ubuntu 18.04.2 LTS - Kernel: Linux 4.15.0-45-generic - Architecture: x86-64 -clush> free -m ---------------- -192.168.1.4 ---------------- - total used free shared buff/cache available -Mem: 1838 641 217 19 978 969 -Swap: 2047 0 2047 ---------------- -192.168.1.9 ---------------- - total used free shared buff/cache available -Mem: 1993 352 1067 1 573 1473 -Swap: 1425 0 1425 -clush> w ---------------- -192.168.1.4 ---------------- - 09:21:14 up 3:21, 3 users, load average: 0.00, 0.01, 0.05 -USER TTY FROM [email protected] IDLE JCPU PCPU WHAT -daygeek :0 :0 06:02 ?xdm? 1:28 0.30s /usr/libexec/gnome-session-binary --session gnome-classic -daygeek pts/0 :0 06:03 3:17m 0.06s 0.06s bash -daygeek pts/1 192.168.1.6 06:03 52:26 0.10s 0.10s -bash ---------------- -192.168.1.9 ---------------- - 21:13:12 up 3:12, 1 user, load average: 0.08, 0.03, 0.00 -USER TTY FROM [email protected] IDLE JCPU PCPU WHAT -daygeek pts/0 192.168.1.6 20:42 29:41 0.05s 0.05s -bash -clush> quit -``` - -If you would like to run the command on a group of nodes then use the following format. - -``` -$ clush -w @dev uptime -or -$ clush -g dev uptime -or -$ clush --group=dev uptime - -192.168.1.9: 21:10:10 up 3:09, 1 user, load average: 0.09, 0.03, 0.01 -192.168.1.4: 09:18:12 up 3:18, 3 users, load average: 0.01, 0.02, 0.05 -``` - -If you would like to run the command on more than one group of nodes then use the following format. - -``` -$ clush -w @dev,@uat uptime -or -$ clush -g dev,uat uptime -or -$ clush --group=dev,uat uptime - -192.168.1.7: 07:57:19 up 59 min, 1 user, load average: 0.08, 0.03, 0.00 -192.168.1.9: 20:27:20 up 1:00, 1 user, load average: 0.00, 0.00, 0.00 -192.168.1.5: 08:57:21 up 59 min, 1 user, load average: 0.00, 0.01, 0.05 -``` - -clustershell allow us to copy a file to remote machines. To copy local file or directory to the remote nodes in the same location. - -``` -$ clush -w 192.168.1.[4,9] --copy /home/daygeek/passwd-up.sh -``` - -We can verify the same by running the following command. - -``` -$ clush -w 192.168.1.[4,9] ls -lh /home/daygeek/passwd-up.sh -192.168.1.4: -rwxr-xr-x. 1 daygeek daygeek 159 Mar 4 09:00 /home/daygeek/passwd-up.sh -192.168.1.9: -rwxr-xr-x 1 daygeek daygeek 159 Mar 4 20:52 /home/daygeek/passwd-up.sh -``` - -To copy local file or directory to the remote nodes in the different location. - -``` -$ clush -g uat --copy /home/daygeek/passwd-up.sh --dest /tmp -``` - -We can verify the same by running the following command. - -``` -$ clush --group=uat ls -lh /tmp/passwd-up.sh -192.168.1.7: -rwxr-xr-x. 1 daygeek daygeek 159 Mar 6 07:44 /tmp/passwd-up.sh -``` - -To copy file or directory from remote nodes to local system. - -``` -$ clush -w 192.168.1.7 --rcopy /home/daygeek/Documents/magi.txt --dest /tmp -``` - -We can verify the same by running the following command. - -``` -$ ls -lh /tmp/magi.txt.192.168.1.7 --rw-r--r-- 1 daygeek daygeek 35 Mar 6 20:24 /tmp/magi.txt.192.168.1.7 -``` - --------------------------------------------------------------------------------- - -via: https://www.2daygeek.com/clustershell-clush-run-commands-on-cluster-nodes-remote-system-in-parallel-linux/ - -作者:[Magesh Maruthamuthu][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.2daygeek.com/author/magesh/ -[b]: https://github.com/lujun9972 -[1]: https://www.2daygeek.com/pssh-parallel-ssh-run-execute-commands-on-multiple-linux-servers/ -[2]: https://www.2daygeek.com/dsh-run-execute-shell-commands-on-multiple-linux-servers-at-once/ -[3]: https://cea-hpc.github.io/clustershell/ -[4]: https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ -[5]: https://www.2daygeek.com/install-enable-epel-repository-on-rhel-centos-scientific-linux-oracle-linux/ -[6]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ -[7]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ -[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/3-methods-to-install-latest-python3-package-on-centos-6-system/ -[11]: https://www.2daygeek.com/install-pip-manage-python-packages-linux/ -[12]: https://www.2daygeek.com/linux-passwordless-ssh-login-using-ssh-keygen/ diff --git a/sources/tech/20190315 How To Parse And Pretty Print JSON With Linux Commandline Tools.md b/sources/tech/20190315 How To Parse And Pretty Print JSON With Linux Commandline Tools.md deleted file mode 100644 index 16e9c70627..0000000000 --- a/sources/tech/20190315 How To Parse And Pretty Print JSON With Linux Commandline Tools.md +++ /dev/null @@ -1,264 +0,0 @@ -[#]: collector: "lujun9972" -[#]: translator: "zhangxiangping " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " -[#]: subject: "How To Parse And Pretty Print JSON With Linux Commandline Tools" -[#]: via: "https://www.ostechnix.com/how-to-parse-and-pretty-print-json-with-linux-commandline-tools/" -[#]: author: "EDITOR https://www.ostechnix.com/author/editor/" - -How To Parse And Pretty Print JSON With Linux Commandline Tools -====== - -**JSON** is a lightweight and language independent data storage format, easy to integrate with most programming languages and also easy to understand by humans, of course when properly formatted. The word JSON stands for **J** ava **S** cript **O** bject **N** otation, though it starts with JavaScript, and primarily used to exchange data between server and browser, but now being used in many fields including embedded systems. Here we’re going to parse and pretty print JSON with command line tools on Linux. It’s extremely useful for handling large JSON data in a shell scripts, or manipulating JSON data in a shell script. - -### What is pretty printing? - -The JSON data is structured to be somewhat more human readable. However in most cases, JSON data is stored in a single line, even without a line ending character. - -Obviously that’s not very convenient for reading and editing manually. - -That’s when pretty print is useful. The name is quite self explanatory, re-formatting the JSON text to be more legible by humans. This is known as **JSON pretty printing**. - -### Parse And Pretty Print JSON With Linux Commandline Tools - -JSON data could be parsed with command line text processors like **awk** , **sed** and **gerp**. In fact JSON.awk is an awk script to do that. However there are some dedicated tools for the same purpose. - - 1. **jq** or **jshon** , JSON parser for shell, both of them are quite useful. - - 2. Shell scripts like **JSON.sh** or **jsonv.sh** to parse JSON in bash, zsh or dash shell. - - 3. **JSON.awk** , JSON parser awk script. - - 4. Python modules like **json.tool**. - - 5. **underscore-cli** , Node.js and javascript based. - - - - -In this tutorial I’m focusing only on **jq** , which is quite powerful JSON parser for shells with advanced filtering and scripting capability. - -### JSON pretty printing - -JSON data could be in one and nearly illegible for humans, so to make it somewhat readable, JSON pretty printing is here. - -**Example:** A data from **jsonip.com** , to get external IP address in JSON format, use **curl** or **wget** tools like below. - -``` -$ wget -cq http://jsonip.com/ -O - -``` - -The actual data looks like this: - -``` -{"ip":"111.222.333.444","about":"/about","Pro!":"http://getjsonip.com"} -``` - -Now pretty print it with jq: - -``` -$ wget -cq http://jsonip.com/ -O - | jq '.' -``` - -This should look like below, after filtering the result with jq. - -``` -{ - - "ip": "111.222.333.444", - - "about": "/about", - - "Pro!": "http://getjsonip.com" - -} -``` - -The Same thing could be done with python **json.tool** module. Here is an example: - -``` -$ cat anything.json | python -m json.tool -``` - -This Python based solution should be fine for most users, but it’s not that useful where Python is not pre-installed or could not be installed, like on embedded systems. - -However the json.tool python module has a distinct advantage, it’s cross platform. So, you can use it seamlessly on Windows, Linux or mac OS. - - -### How to parse JSON with jq - -First, you need to install jq, it’s already picked up by most GNU/Linux distributions, install it with their respective package installer commands. - -On Arch Linux: - -``` -$ sudo pacman -S jq -``` - -On Debian, Ubuntu, Linux Mint: - -``` -$ sudo apt-get install jq -``` - -On Fedora: - -``` -$ sudo dnf install jq -``` - -On openSUSE: - -``` -$ sudo zypper install jq -``` - -For other OS or platforms, see the [official installation instructions][1]. - -**Basic filters and identifiers of jq** - -jq could read the JSON data either from **stdin** or a **file**. You’ve to use both depending on the situation. - -The single symbol of **.** is the most basic filter. These filters are also called as **object identifier-index**. Using a single **.** along with jq basically pretty prints the input JSON file. - -**Single quotes** – You don’t have to use the single quote always. But if you’re combining several filters in a single line, then you must use them. - -**Double quotes** – You’ve to enclose any special character like **@** , **#** , **$** within two double quotes, like this example, **jq .foo.”@bar”** - -**Raw data print** – For any reason, if you need only the final parsed data, not enclosed within a double quote, use the -r flag with the jq command, like this. **– jq -r .foo.bar**. - -**Parsing specific data** - -To filter out a specific part of JSON, you’ve to look into the pretty printed JSON file’s data hierarchy. - -An example of JSON data, from Wikipedia: - -``` -{ - - "firstName": "John", - - "lastName": "Smith", - - "age": 25, - - "address": { - - "streetAddress": "21 2nd Street", - - "city": "New York", - - "state": "NY", - - "postalCode": "10021" - -}, - - "phoneNumber": [ - -{ - - "type": "home", - - "number": "212 555-1234" - -}, - -{ - - "type": "fax", - - "number": "646 555-4567" - -} - -], - - "gender": { - - "type": "male" - - } - -} -``` - -I’m going to use this JSON data as an example in this tutorial, saved this as **sample.json**. - -Let’s say I want to filter out the address from sample.json file. So the command should be like: - -``` -$ jq .address sample.json -``` - -**Sample output:** - -``` -{ - - "streetAddress": "21 2nd Street", - - "city": "New York", - - "state": "NY", - - "postalCode": "10021" - -} -``` - -Again let’s say I want the postal code, then I’ve to add another **object identifier-index** , i.e. another filter. - -``` -$ cat sample.json | jq .address.postalCode -``` - -Also note that the **filters are case sensitive** and you’ve to use the exact same string to get something meaningful output instead of null. - -**Parsing elements from JSON array** - -Elements of JSON array are enclosed within square brackets, undoubtedly quite versatile to use. - -To parse elements from a array, you’ve to use the **[]identifier** along with other object identifier-index. - -In this sample JSON data, the phone numbers are stored inside an array, to get all the contents from this array, you’ve to use only the brackets, like this example. - -``` -$ jq .phoneNumber[] sample.json -``` - -Let’s say you just want the first element of the array, then use the array object numbers starting for 0, for the first item, use **[0]** , for the next items, it should be incremented by one each step. - -``` -$ jq .phoneNumber[0] sample.json -``` - -**Scripting examples** - -Let’s say I want only the the number for home, not entire JSON array data. Here’s when scripting within jq command comes handy. - -``` -$ cat sample.json | jq -r '.phoneNumber[] | select(.type == "home") | .number' -``` - -Here first I’m piping the results of one filer to another, then using the select attribute to select a particular type of data, again piping the result to another filter. - -Explaining every type of jq filters and scripting is beyond the scope and purpose of this tutorial. It’s highly suggested to read the JQ manual for better understanding given below. - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-parse-and-pretty-print-json-with-linux-commandline-tools/ - -作者:[EDITOR][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/editor/ -[b]: https://github.com/lujun9972 -[1]: https://stedolan.github.io/jq/download/ diff --git a/sources/tech/20190315 New zine- Bite Size Networking.md b/sources/tech/20190315 New zine- Bite Size Networking.md new file mode 100644 index 0000000000..cd47c5619a --- /dev/null +++ b/sources/tech/20190315 New zine- Bite Size Networking.md @@ -0,0 +1,100 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (New zine: Bite Size Networking!) +[#]: via: (https://jvns.ca/blog/2019/03/15/new-zine--bite-size-networking-/) +[#]: author: (Julia Evans https://jvns.ca/) + +New zine: Bite Size Networking! +====== + +Last week I released a new zine: Bite Size Networking! It’s the third zine in the “bite size” series: + + 1. [Bite Size Linux][1] + 2. [Bite Size Command Line][2] + 3. [Bite Size Networking][3] + + + +You can get it for $10 at ! (or $150/$250/$600 for the corporate rate). + +Here’s the cover and table of contents! + +[![][4]][5] + +A few people have asked for a 3-pack with all 3 “bite size” zines which is coming soon! + +### why this zine? + +In last few years I’ve been doing a lot of networking at work, and along the way I’ve gone from “uh, what even is tcpdump” to “yes I can just type in `sudo tcpdump -c 200 -n port 443 -i lo`” without even thinking twice about it. As usual this zine is the resource I wish I had 4 years ago. There are so many things it took me a long time to figure out how to do like: + + * inspect SSL certificates + * make DNS queries + * figure out what server is using that port + * find out whether the firewall is causing you problems or not + * capture / search network traffic on a machine + + + +and as often happens with computers none of them are really that hard!! But the man pages for the tols you need to do these things are Very Long and as usual don’t differentiate between “everybody always uses this option and you 10000% need to know it” and “you will never use this option it does not matter”. So I spent a long time staring sadly at the tcpdump man page. + +the pitch for this zine is: + +> It’s Thursday afternoon and your users are reporting SSL errors in production and you don’t know why. Or a HTTP header isn’t being set correctly and it’s breaking the site. Or you just got a notification that your site’s SSL certificate is expiring in 2 days. Or you need to update DNS to point to a new server. Or a server suddenly isn’t able to connect to a service. And networking maybe isn’t your full time job, but you still need to get the problem fixed. + +Kamal (my partner) proofreads all my zines and we hit an exciting milestone with this one: this is the first zine where he was like “wow, I really did not know a lot of the stuff in this zine”. This is of course because I’ve spent a lot more time than him debugging weird networking things, and when you practice something you get better at it :) + +### a couple of example pages + +Here are a couple of example pages, to give you an idea of what’s in the zine: + +![][6] ![][7] + +### next thing to get better at: getting feedback! + +One thing I’ve realized that while I get a ton of help from people while writing these zines (I read probably a thousand tweets from people suggesting ideas for things to include in the zine), I don’t get as much feedback from people about the final product as I’d like! + +I often hear positive things (“I love them!”, “thank you so much!”, “this helped me in my job!”) but I’d really love to hear more about which bits specifically helped the most and what didn’t make as much sense or what you would have liked to see more of. So I’ll probably be asking a few questions about that to people who buy this zine! + +### selling zines is going well + +When I made the switch about a year ago from “every zine I release is free” to “the old zines are free but all the new ones are not free” it felt scary! It’s been startlingly totally fine and a very positive thing. Sales have been really good, people take the work more seriously, I can spend more time on them, and I think the quality has gone up. + +And I’ve been doing occasional [giveaways][8] for people who can’t afford a $10 zine, which feels like a nice way to handle “some people legitimately can’t afford $10 and I would like to get them information too”. + +### what’s next? + +I’m not sure yet! A few options: + + * kubernetes + * more about linux concepts (bite size linux part II) + * how to do statistics using simulations + * something else! + + + +We’ll see what I feel most inspired by :) + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/03/15/new-zine--bite-size-networking-/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://wizardzines.com/zines/bite-size-linux/ +[2]: https://wizardzines.com/zines/bite-size-command-line/ +[3]: https://wizardzines.com/zines/bite-size-networking/ +[4]: https://jvns.ca/images/bite-size-networking-cover.png +[5]: https://gum.co/bite-size-networking +[6]: https://jvns.ca/images/ngrep.png +[7]: https://jvns.ca/images/ping.png +[8]: https://twitter.com/b0rk/status/1104368319816220674 diff --git a/sources/tech/20190318 Let-s try dwm - dynamic window manager.md b/sources/tech/20190318 Let-s try dwm - dynamic window manager.md deleted file mode 100644 index 48f44a33cb..0000000000 --- a/sources/tech/20190318 Let-s try dwm - dynamic window manager.md +++ /dev/null @@ -1,150 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Let’s try dwm — dynamic window manager) -[#]: via: (https://fedoramagazine.org/lets-try-dwm-dynamic-window-manger/) -[#]: author: (Adam Šamalík https://fedoramagazine.org/author/asamalik/) - -Let’s try dwm — dynamic window manager -====== - -![][1] - -If you like efficiency and minimalism, and are looking for a new window manager for your Linux desktop, you should try _dwm_ — dynamic window manager. Written in under 2000 standard lines of code, dwm is extremely fast yet powerful and highly customizable window manager. - -You can dynamically choose between tiling, monocle and floating layouts, organize your windows into multiple workspaces using tags, and quickly navigate through using keyboard shortcuts. This article helps you get started using dwm. - -## **Installation** - -To install dwm on Fedora, run: - -``` -$ sudo dnf install dwm dwm-user -``` - -The _dwm_ package installs the window manager itself, and the _dwm-user_ package significantly simplifies configuration which will be explained later in this article. - -Additionally, to be able to lock the screen when needed, we’ll also install _slock_ — a simple X display locker. - -``` -$ sudo dnf install slock -``` - -However, you can use a different one based on your personal preference. - -## **Quick start** - -To start dwm, choose the _dwm-user_ option on the login screen. - -![][2] - -After you log in, you’ll see a very simple desktop. In fact, the only thing there will be a bar at the top listing our nine tags that represent workspaces and a _[]=_ symbol that represents the layout of your windows. - -### Launching applications - -Before looking into the layouts, first launch some applications so you can play with the layouts as you go. Apps can be started by pressing _Alt+p_ and typing the name of the app followed by _Enter_. There’s also a shortcut _Alt+Shift+Enter_ for opening a terminal. - -Now that some apps are running, have a look at the layouts. - -### Layouts - -There are three layouts available by default: the tiling layout, the monocle layout, and the floating layout. - -The tiling layout, represented by _[]=_ on the bar, organizes windows into two main areas: master on the left, and stack on the right. You can activate the tiling layout by pressing _Alt+t._ - -![][3] - -The idea behind the tiling layout is that you have your primary window in the master area while still seeing the other ones in the stack. You can quickly switch between them as needed. - -To swap windows between the two areas, hover your mouse over one in the stack area and press _Alt+Enter_ to swap it with the one in the master area. - -![][4] - -The monocle layout, represented by _[N]_ on the top bar, makes your primary window take the whole screen. You can switch to it by pressing _Alt+m_. - -Finally, the floating layout lets you move and resize your windows freely. The shortcut for it is _Alt+f_ and the symbol on the top bar is _> <>_. - -### Workspaces and tags - -Each window is assigned to a tag (1-9) listed at the top bar. To view a specific tag, either click on its number using your mouse or press _Alt+1..9._ You can even view multiple tags at once by clicking on their number using the secondary mouse button. - -Windows can be moved between different tags by highlighting them using your mouse, and pressing _Alt+Shift+1..9._ - -## **Configuration** - -To make dwm as minimalistic as possible, it doesn’t use typical configuration files. Instead, you modify a C header file representing the configuration, and recompile it. But don’t worry, in Fedora it’s as simple as just editing one file in your home directory and everything else happens in the background thanks to the _dwm-user_ package provided by the maintainer in Fedora. - -First, you need to copy the file into your home directory using a command similar to the following: - -``` -$ mkdir ~/.dwm -$ cp /usr/src/dwm-VERSION-RELEASE/config.def.h ~/.dwm/config.h -``` - -You can get the exact path by running _man dwm-start._ - -Second, just edit the _~/.dwm/config.h_ file. As an example, let’s configure a new shortcut to lock the screen by pressing _Alt+Shift+L_. - -Considering we’ve installed the _slock_ package mentioned earlier in this post, we need to add the following two lines into the file to make it work: - -Under the _/* commands */_ comment, add: - -``` -static const char *slockcmd[] = { "slock", NULL }; -``` - -And the following line into _static Key keys[]_ : - -``` -{ MODKEY|ShiftMask, XK_l, spawn, {.v = slockcmd } }, -``` - -In the end, it should look like as follows: (added lines are highlighted) - -``` -... - /* commands */ - static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ - static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL }; - static const char *termcmd[] = { "st", NULL }; - static const char *slockcmd[] = { "slock", NULL }; - - static Key keys[] = { - /* modifier key function argument */ - { MODKEY|ShiftMask, XK_l, spawn, {.v = slockcmd } }, - { MODKEY, XK_p, spawn, {.v = dmenucmd } }, - { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, - ... -``` - -Save the file. - -Finally, just log out by pressing _Alt+Shift+q_ and log in again. The scripts provided by the _dwm-user_ package will recognize that you have changed the _config.h_ file in your home directory and recompile dwm on login. And becuse dwm is so tiny, it’s fast enough you won’t even notice it. - -You can try locking your screen now by pressing _Alt+Shift+L_ , and then logging back in again by typing your password and pressing enter. - -## **Conclusion** - -If you like minimalism and want a very fast yet powerful window manager, dwm might be just what you’ve been looking for. However, it probably isn’t for beginners. There might be a lot of additional configuration you’ll need to do in order to make it just as you like it. - -To learn more about dwm, see the project’s homepage at . - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/lets-try-dwm-dynamic-window-manger/ - -作者:[Adam Šamalík][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/asamalik/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2019/03/dwm-magazine-image-816x345.png -[2]: https://fedoramagazine.org/wp-content/uploads/2019/03/choosing-dwm-1024x469.png -[3]: https://fedoramagazine.org/wp-content/uploads/2019/03/dwm-desktop-1024x593.png -[4]: https://fedoramagazine.org/wp-content/uploads/2019/03/Screenshot-2019-03-15-at-11.12.32-1024x592.png diff --git a/sources/tech/20190319 Blockchain 2.0- Blockchain In Real Estate -Part 4.md b/sources/tech/20190319 Blockchain 2.0- Blockchain In Real Estate -Part 4.md deleted file mode 100644 index 56f8b8d8c1..0000000000 --- a/sources/tech/20190319 Blockchain 2.0- Blockchain In Real Estate -Part 4.md +++ /dev/null @@ -1,50 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (sanfusu) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Blockchain 2.0: Blockchain In Real Estate [Part 4]) -[#]: via: (https://www.ostechnix.com/blockchain-2-0-blockchain-in-real-estate/) -[#]: author: (EDITOR https://www.ostechnix.com/author/editor/) - -Blockchain 2.0: Blockchain In Real Estate [Part 4] -====== - -![](https://www.ostechnix.com/wp-content/uploads/2019/03/Blockchain-In-Real-Estate-720x340.png) - -### Blockchain 2.0: Smart‘er’ Real Estate - -The [**previous article**][1] of this series explored the features of blockchain which will enable institutions to transform and interlace **traditional banking** and **financing systems** with it. This part will explore – **Blockchain in real estate**. The real estate industry is ripe for a revolution. It’s among the most actively traded most significant asset classes known to man. However, filled with regulatory hurdles and numerous possibilities of fraud and deceit, it’s also one of the toughest to participate in. The distributed ledger capabilities of the blockchain utilizing an appropriate consensus algorithm are touted as the way forward for the industry which is traditionally regarded as conservative in its attitude to change. - -Real estate has always been a very conservative industry in terms of its myriad operations. Somewhat rightfully so as well. A major economic crisis such as the 2008 financial crisis or the great depression from the early half of the 20th century managed to destroy the industry and its participants. However, like most products of economic value, the real estate industry is resilient and this resilience is rooted in its conservative nature. - -The global real estate market comprises an asset class worth **$228 trillion dollars** [1]. Give or take. Other investment assets such as stocks, bonds, and shares combined are only worth **$170 trillion**. Obviously, any and all transactions implemented in such an industry is naturally carefully planned and meticulously executed, for the most part. For the most part, because real estate is also notorious for numerous instances of fraud and devastating loses which ensue them. The industry because of the very conservative nature of its operations is also tough to navigate. It’s heavily regulated with complex laws creating an intertwined web of nuances that are just too difficult for an average person to understand fully. This makes entry and participation near impossible for most people. If you’ve ever been involved in one such deal, you’ll know how heavy and long the paper trail was. - -This hard reality is now set to change, albeit a slow and gradual transformation. The very reasons the industry has stuck to its hardy tested roots all this while can finally give way to its modern-day counterpart. The backbone of the real estate industry has always been its paper records. Land deeds, titles, agreements, rental insurance, proofs, and declarations etc., are just the tip of the iceberg here. If you’ve noticed the pattern here, this should be obvious, the distributed ledger technology that is blockchain, fits in perfectly with the needs here. Forget paper records, conventional database systems are also points of major failure. They can be modified by multiple participants, is not tamper proof or un-hackable, has a complicated set of ever-changing regulatory parameters making auditing and verifying data a nightmare. The blockchain perfectly solves all of these issues and more. - -Starting with a trivial albeit an important example to show just how bad the current record management practices are in the real estate sector, consider the **Title Insurance business** [2], [3]. Title Insurance is used to hedge against the possibility of the land’s titles and ownership records being inadmissible and hence unenforceable. An insurance product such as this is also referred to as an indemnity cover. It is by law required in many cases that properties have title insurance, especially when dealing with property that has changed hands multiple times over the years. Mortgage firms might insist on the same as well when they back real estate deals. The fact that a product of this kind has existed since the 1850s and that it does business worth at least **$1.5 trillion a year in the US alone** is a testament to the statement at the start. A revolution in terms of how these records are maintained is imperative to have in this situation and the blockchain provides a sustainable solution. Title fraud averages around $100k per case on average as per the **American Land Title Association** and 25% of all titles involved in transactions have an issue regarding their documents[4]. The blockchain allows for setting up an immutable permanent database that will track the property itself, recording each and every transaction or investment that has gone into it. Such a ledger system will make life easier for everyone involved in the real estate industry including one-time home buyers and make financial products such as Title Insurance basically irrelevant. Converting a physical asset such as real estate to a digital asset like this is unconventional and is extant only in theory at the moment. However, such a change is imminent sooner rather than later[5]. - -Among the areas in which blockchain will have the most impact within real estate is as highlighted above in maintaining a transparent and secure title management system for properties. A blockchain based record of the property can contain information about the property, its location, history of ownership, and any related public record of the same[6]. This will permit closing real estate deals fast and obliviates the need for 3rd party monitoring and oversight. Tasks such as real estate appraisal and tax calculations become matters of tangible objective parameters rather than subjective measures and guesses because of reliable historical data which is publicly verifiable. **UBITQUITY** is one such platform that offers customized blockchain-based solutions to enterprise customers. The platform allows customers to keep track of all property details, payment records, mortgage records and even allows running smart contracts that’ll take care of taxation and leasing automatically[7]. - -This brings us to the second biggest opportunity and use case of blockchains in real estate. Since the sector is highly regulated by numerous 3rd parties apart from the counterparties involved in the trade, due-diligence and financial evaluations can be significantly time-consuming. These processes are predominantly carried out using offline channels and paperwork needs to travel for days before a final evaluation report comes out. This is especially true for corporate real estate deals and forms a bulk of the total billable hours charged by consultants. In case the transaction is backed by a mortgage, duplication of these processes is unavoidable. Once combined with digital identities for the people and institutions involved along with the property, the current inefficiencies can be avoided altogether and transactions can take place in a matter of seconds. The tenants, investors, institutions involved, consultants etc., could individually validate the data and arrive at a critical consensus thereby validating the property records for perpetuity[8]. This increases the accuracy of verification manifold. Real estate giant **RE/MAX** has recently announced a partnership with service provider **XYO Network Partners** for building a national database of real estate listings in Mexico. They hope to one day create one of the largest (as of yet) decentralized real estate title registry in the world[9]. - -However, another significant and arguably a very democratic change that the blockchain can bring about is with respect to investing in real estate. Unlike other investment asset classes where even small household investors can potentially participate, real estate often requires large hands-down payments to participate. Companies such as **ATLANT** and **BitOfProperty** tokenize the book value of a property and convert them into equivalents of a cryptocurrency. These tokens are then put for sale on their exchanges similar to how stocks and shares are traded. Any cash flow that the real estate property generates afterward is credited or debited to the token owners depending on their “share” in the property[4]. - -However, even with all of that said, Blockchain technology is still in very early stages of adoption in the real estate sector and current regulations are not exactly defined for it to be either[8]. Concepts such as distributed applications, distributed anonymous organizations, smart contracts etc., are unheard of in the legal domain in many countries. A complete overhaul of existing regulations and guidelines once all the stakeholders are well educated on the intricacies of the blockchain is the most pragmatic way forward. Again, it’ll be a slow and gradual change to go through, however a much-needed one nonetheless. The next article of the series will look at how **“Smart Contracts”** , such as those implemented by companies such as UBITQUITY and XYO are created and executed in the blockchain. - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/blockchain-2-0-blockchain-in-real-estate/ - -作者:[EDITOR][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/editor/ -[b]: https://github.com/lujun9972 -[1]: https://www.ostechnix.com/blockchain-2-0-redefining-financial-services/ diff --git a/sources/tech/20190320 4 cool terminal multiplexers.md b/sources/tech/20190320 4 cool terminal multiplexers.md deleted file mode 100644 index e8650b4f56..0000000000 --- a/sources/tech/20190320 4 cool terminal multiplexers.md +++ /dev/null @@ -1,121 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (4 cool terminal multiplexers) -[#]: via: (https://fedoramagazine.org/4-cool-terminal-multiplexers/) -[#]: author: (Paul W. Frields https://fedoramagazine.org/author/pfrields/) - -4 cool terminal multiplexers -====== - -![][1] - -The Fedora OS is comfortable and easy for lots of users. It has a stunning desktop that makes it easy to get everyday tasks done. Under the hood is all the power of a Linux system, and the terminal is the easiest way for power users to harness it. By default terminals are simple and somewhat limited. However, a _terminal multiplexer_ allows you to turn your terminal into an even more incredible powerhouse. This article shows off some popular terminal multiplexers and how to install them. - -Why would you want to use one? Well, for one thing, it lets you logout of your system while _leaving your terminal session undisturbed_. It’s incredibly useful to logout of your console, secure it, travel somewhere else, then remotely login with SSH and continue where you left off. Here are some utilities to check out. - -One of the oldest and most well-known terminal multiplexers is _screen._ However, because the code is no longer maintained, this article focuses on more recent apps. (“Recent” is relative — some of these have been around for years!) - -### Tmux - -The _tmux_ utility is one of the most widely used replacements for _screen._ It has a highly configurable interface. You can program tmux to start up specific kinds of sessions based on your needs. You’ll find a lot more about tmux in this article published earlier: - -> [Use tmux for a more powerful terminal][2] - -Already a tmux user? You might like [this additional article on making your tmux sessions more effective][3]. - -To install tmux, use the _sudo_ command along with _dnf_ , since you’re probably in a terminal already: - -``` -$ sudo dnf install tmux -``` - -To start learning, run the _tmux_ command. A single pane window starts with your default shell. Tmux uses a _modifier key_ to signal that a command is coming next. This key is **Ctrl+B** by default. If you enter **Ctrl+B, C** you’ll create a new window with a shell in it. - -Here’s a hint: Use **Ctrl+B, ?** to enter a help mode that lists all the keys you can use. To keep things simple, look for the lines starting with _bind-key -T prefix_ at first. These are keys you can use right after the modifier key to configure your tmux session. You can hit **Ctrl+C** to exit the help mode back to tmux. - -To completely exit tmux, use the standard _exit_ command or _Ctrl+D_ keystroke to exit all the shells. - -### Dvtm - -You might have recently seen the Magazine article on [dwm, a dynamic window manager][4]. Like dwm, _dvtm_ is for tiling window management — but in a terminal. It’s designed to adhere to the legacy UNIX philosophy of “do one thing well” — in this case managing windows in a terminal. - -Installing dvtm is easy as well. However, if you want the logout functionality mentioned earlier, you’ll also need the _abduco_ package which handles session management for dvtm. - -``` -$ sudo dnf install dvtm abduco -``` - -The dvtm utility has many keystrokes already mapped to allow you to manage windows in the terminal. By default, it uses **Ctrl+G** as its modifier key. This keystroke tells dvtm that the following character is going to be a command it should process. For instance, **Ctrl+G, C** creates a new window and **Ctrl+G, X** removes it. - -For more information on using dvtm, check out the dvtm [home page][5] which includes numerous tips and get-started information. - -### Byobu - -While _byobu_ isn’t truly a multiplexer on its own — it wraps _tmux_ or even the older _screen_ to add functions — it’s worth covering here too. Byobu makes terminal multiplexers better for novices, by adding a help menu and window tabs that are slightly easier to navigate. - -Of course it’s available in the Fedora repos as well. To install, use this command: - -``` -$ sudo dnf install byobu -``` - -By default the _byobu_ command runs _screen_ underneath, so you might want to run _byobu-tmux_ to wrap _tmux_ instead. You can then use the **F9** key to open up a help menu for more information to help you get started. - -### Mtm - -The _mtm_ utility is one of the smallest multiplexers you’ll find. In fact, it’s only about 1000 lines of code! You might find it helpful if you’re in a limited environment such as old hardware, a minimal container, and so forth. To get started, you’ll need a couple packages. - -``` -$ sudo dnf install git ncurses-devel make gcc -``` - -Then clone the repository where mtm lives: - -``` -$ git clone https://github.com/deadpixi/mtm.git -``` - -Change directory into the _mtm_ folder and build the program: - -``` -$ make -``` - -You might receive a few warnings, but when you’re done, you’ll have the very small _mtm_ utility. Run it with this command: - -``` -$ ./mtm -``` - -You can find all the documentation for the utility [on its GitHub page][6]. - -These are just some of the terminal multiplexers out there. Got one you’d like to recommend? Leave a comment below with your tips and enjoy building windows in your terminal! - -* * * - -_Photo by _[ _Michael_][7]_ on [Unsplash][8]._ - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/4-cool-terminal-multiplexers/ - -作者:[Paul W. Frields][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/pfrields/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2018/08/tmuxers-4-816x345.jpg -[2]: https://fedoramagazine.org/use-tmux-more-powerful-terminal/ -[3]: https://fedoramagazine.org/4-tips-better-tmux-sessions/ -[4]: https://fedoramagazine.org/lets-try-dwm-dynamic-window-manger/ -[5]: http://www.brain-dump.org/projects/dvtm/#why -[6]: https://github.com/deadpixi/mtm -[7]: https://unsplash.com/photos/48yI_ZyzuLo?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText -[8]: https://unsplash.com/search/photos/windows?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/sources/tech/20190326 Why are monoidal categories interesting.md b/sources/tech/20190326 Why are monoidal categories interesting.md new file mode 100644 index 0000000000..37aaef753a --- /dev/null +++ b/sources/tech/20190326 Why are monoidal categories interesting.md @@ -0,0 +1,134 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why are monoidal categories interesting?) +[#]: via: (https://jvns.ca/blog/2019/03/26/what-are-monoidal-categories/) +[#]: author: (Julia Evans https://jvns.ca/) + +Why are monoidal categories interesting? +====== + +Hello! Someone on Twitter asked a question about tensor categories recently and I remembered “oh, I know something about that!! These are a cool thing!“. Monoidal categories are also called “tensor categories” and I think that term feels a little more concrete: one of the biggest examples of a tensor category is the category of vector spaces with the tensor product as the way you combine vectors / functions. “Monoidal” means “has an associative binary operation with an identity”, and with vector spaces the tensor product is the “associative binary operation” it’s referring to. So I’m going to mostly use “tensor categories” in this post instead. + +So here’s a quick stab at explaining why tensor categories are cool. I’m going to make a lot of oversimplifications which I figure is better than trying to explain category theory from the ground up. I’m not a category theorist (though I spent 2 years in grad school doing a bunch of category theory) and I will almost certainly say wrong things about category theory. + +In this post I’m going to try to talk about [Seven Sketches in Compositionality: An Invitation to Applied Category Theory][1] using mostly plain English. + +### tensor categories aren’t monads + +If you have been around functional programming for a bit, you might see the word “monoid” and “categories” and wonder “oh, is julia writing about monads, like in Haskell”? I am not!! + +There is a sentence “monads are a monoid in the category of endofunctors” which includes both the word “monoid” and “category” but that is not what I am talking about at all. We’re not going to talk about types or Haskell or monads or anything. + +#### tensor categories are about proving (or defining) things with pictures + +Here’s what I think is a really nice example from this [“seven sketches in compositionality”](() PDF (on page 47): + +![][2] + +The idea here is that you have 3 inequalities + + 1. `t <= v + w` + 2. `w + u <= x + z` + 3. `v + x <= y`, + + + +and you want to prove that `t + u <= y + z`. + +You can do this algebraically pretty easily. + +But in this diagram they’ve done something really different! They’ve sort of drawn the inequalities as boxes with lines coming out of them for each variable, and then you can see that you end up with a `t` and a `u` on the left and a `y` and a `z` on the right, and so maybe that means that `t + u <= y + z`. + +The first time I saw something like this in a math class I felt like – what? what is happening? you can’t just draw PICTURES to prove things?!! And of course you can’t _just_ draw pictures to prove things. + +What’s actually happening in pictures like this is that when you put 2 things next to each other in the picture (like `t` and `u`), that actually represents the “tensor product” of `t` and `u`. In this case the “tensor product” is defined to be addition. And the tensor product (addition in this case) has some special properties – + + 1. it’s associative + 2. if `a <= b` and `c <= d` then `a + c <= b + d` + + + +so saying that this picture proves that `t + u <= y + z` **actually** means that you can read a proof off the diagram in a straightforward way: + +``` + t + u +<= (v + w) + u += v + (w + u) +<= v + (x + z) += (v + x) + z +<= y + z +``` + +So all the things that “look like they would work” according to the picture actually do work in practice because our tensor product thing is associative and because addition works nicely with the `<=` relationship. The book explains all this in a lot more detail. + +### draw vector spaces with “string diagrams” + +Proving this simple inequality is kind of boring though! We want to do something more interesting, so let’s talk about vector spaces! Here’s a diagram that includes some vector spaces (U1, U2, V1, V2) and some functions (f,g) between them. + +![][3] + +Again, here what it means to have U1 stacked on top of U2 is that we’re taking a tensor product of U1 and U2. And the tensor product is associative, so there’s no ambiguity if we stack 3 or 4 vector spaces together! + +This is all explained in a lot more detail in this nice blog post called [introduction to string diagrams][4] (which I took that picture from). + +### define the trace of a matrix with a picture + +So far this is pretty boring! But in a [follow up blog post][5], they talk about something more outrageous: you can (using vector space duality) take the lines in one of these diagrams and move them **backwards** and make loops. So that lets us define the trace of a function `f : V -> V` like this: + +![][6] + +This is a really outrageous thing! We’ve said, hey, we have a function and we want to get a number in return right? Okay, let’s just… draw a circle around it so that there are no lines left coming out of it, and then that will be a number! That seems a lot more natural and prettier than the usual way of defining the trace of a matrix (“sum up the numbers on the diagonal”)! + +When I first saw this I thought it was super cool that just drawing a circle is actually a legitimate way of defining a mathematical concept! + +### how are tensor category diagrams different from regular category theory diagrams? + +If you see “tensor categories let you prove things with pictures” you might think “well, the whole point of category theory is to prove things with pictures, so what?“. I think there are a few things that are different in tensor category diagrams: + + 1. with string diagrams, the lines are objects and the boxes are functions which is the opposite of how usual category theory diagrams are + 2. putting things next to each other in the diagram has a specific meaning (“take the tensor product of those 2 things”) where as in usual category theory diagrams it doesn’t. being able to combine things in this way is powerful! + 3. half circles have a specific meaning (“take the dual”) + 4. you can use specific elements of a (eg vector space) in a diagram which usually you wouldn’t do in a category theory diagram (the objects would be the whole vector space, not one element of that vector space) + + + +### what does this have to do with programming? + +Even though this is usually a programming blog I don’t know whether this particular thing really has anything to do with programming, I just remembered I thought it was cool. I wrote my [master’s thesis][7] (which i will link to even though it’s not very readable) on topological quantum computing which involves a bunch of monoidal categories. + +Some of the diagrams in this post are sort of why I got interested in that area in the first place – I thought it was really cool that you could formally define / prove things with pictures. And useful things, like the trace of a matrix! + +### edit: some ways this might be related to programming + +Someone pointed me to a couple of twitter threads (coincidentally from this week!!) that relate tensor categories & diagrammatic methods to programming: + + 1. [this thread from @KenScambler][8] (“My best kept secret* is that string & wiring diagrams–plucked straight out of applied category theory–are _fabulous_ for software and system design.) + 2. [this other thread by him of 31 interesting related things to this topic][9] + + + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/03/26/what-are-monoidal-categories/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://arxiv.org/pdf/1803.05316.pdf +[2]: https://jvns.ca/images/monoidal-preorder.png +[3]: https://jvns.ca/images/tensor-vector.png +[4]: https://qchu.wordpress.com/2012/11/05/introduction-to-string-diagrams/ +[5]: https://qchu.wordpress.com/2012/11/06/string-diagrams-duality-and-trace/ +[6]: https://jvns.ca/images/trace.png +[7]: https://github.com/jvns/masters-thesis/raw/master/thesis.pdf +[8]: https://twitter.com/KenScambler/status/1108738366529400832 +[9]: https://twitter.com/KenScambler/status/1109474342822244353 diff --git a/sources/tech/20190327 HPE introduces hybrid cloud consulting business.md b/sources/tech/20190327 HPE introduces hybrid cloud consulting business.md deleted file mode 100644 index f1d9d3564f..0000000000 --- a/sources/tech/20190327 HPE introduces hybrid cloud consulting business.md +++ /dev/null @@ -1,59 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (HPE introduces hybrid cloud consulting business) -[#]: via: (https://www.networkworld.com/article/3384919/hpe-introduces-hybrid-cloud-consulting-business.html#tk.rss_all) -[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) - -HPE introduces hybrid cloud consulting business -====== - -### HPE's Right Mix Advisor is designed to find a balance between on-premises and cloud systems. - -![Hewlett Packard Enterprise][1] - -Hybrid cloud is pretty much the de facto way to go, with only a few firms adopting a pure cloud play to replace their data center and only suicidal firms refusing to go to the cloud. But picking the right balance between on-premises and the cloud is tricky, and a mistake can be costly. - -Enter Right Mix Advisor from Hewlett Packard Enterprise, a combination of consulting from HPE's Pointnext division and software tools. It draws on quite a bit of recent acquisitions. Another part of Right Mix Advisor is a British cloud consultancy RedPixie, Amazon Web Services (AWS) specialists Cloud Technology Partners, and automated discovery capabilities from an Irish startup iQuate. - -Right Mix Advisor gathers data points from the company’s entire enterprise, ranging from configuration management database systems (CMDBs), such as ServiceNow, to external sources, such as cloud providers. HPE says that in a recent customer engagement it scanned 9 million IP addresses across six data centers. - -**[ Read also:[What is hybrid cloud computing][2]. | Learn [what you need to know about multi-cloud][3]. | Get regularly scheduled insights by [signing up for Network World newsletters][4]. ]** - -HPE Pointnext consultants then work with the client’s IT teams to analyze the data to determine the optimal configuration for workload placement. Pointnext has become HPE’s main consulting outfit following its divestiture of EDS, which it acquired in 2008 but spun off in a merger with CSC to form DXC Consulting. Pointnext now has 25,000 consultants in 88 countries. - -In a typical engagement, HPE claims it can deliver a concrete action plan within weeks, whereas previously businesses may have needed months to come to a conclusion using a manual processes. HPE has found migrating the right workloads to the right mix of hybrid cloud can typically result in 40 percent total cost of ownership savings*. * - -Although HPE has thrown its weight behind AWS, that doesn’t mean it doesn’t support competitors. Erik Vogel, vice president of hybrid IT for HPE Pointnext, notes in the blog post announcing Right Mix Advisor that target environments could be Microsoft Azure or Azure Stack, AWS, Google or Ali Cloud. - -“New service providers are popping up every day, and we see the big public cloud providers constantly producing new services and pricing models. As a result, the calculus for determining your right mix is constantly changing. If Azure, for example, offers a new service capability or a 10 percent pricing discount and it makes sense to leverage it, you want to be able to move an application seamlessly into that new environment,” he wrote. - -Key to Right Mix Advisor is app migration, and Pointnext follows the 50/30/20 rule: About 50 percent of apps are suitable for migration to the cloud, and for about 30 percent, migration is not a good choice for migration to be worth the effort. The remaining 20 percent should be retired. - -“With HPE Right Mix Advisor, you can identify that 50 percent,” he wrote. “Rather than hand you a laundry list of 10,000 apps to start migrating, HPE Right Mix Advisor hones in on what’s most impactful right now to meet your business goals – the 10 things you can do on Monday morning that you can be confident will really help your business.” - -HPE has already done some pilot projects with the Right Mix service and expects to expand it to include channel partners. - -Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3384919/hpe-introduces-hybrid-cloud-consulting-business.html#tk.rss_all - -作者:[Andy Patrizio][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Andy-Patrizio/ -[b]: https://github.com/lujun9972 -[1]: https://images.techhive.com/images/article/2015/11/hpe_building-100625424-large.jpg -[2]: https://www.networkworld.com/article/3233132/cloud-computing/what-is-hybrid-cloud-computing.html -[3]: https://www.networkworld.com/article/3252775/hybrid-cloud/multicloud-mania-what-to-know.html -[4]: https://www.networkworld.com/newsletters/signup.html -[5]: https://www.facebook.com/NetworkWorld/ -[6]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20190328 Cisco warns of two security patches that don-t work, issues 17 new ones for IOS flaws.md b/sources/tech/20190328 Cisco warns of two security patches that don-t work, issues 17 new ones for IOS flaws.md deleted file mode 100644 index 27370bf294..0000000000 --- a/sources/tech/20190328 Cisco warns of two security patches that don-t work, issues 17 new ones for IOS flaws.md +++ /dev/null @@ -1,72 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Cisco warns of two security patches that don’t work, issues 17 new ones for IOS flaws) -[#]: via: (https://www.networkworld.com/article/3384742/cisco-warns-of-two-security-patches-that-dont-work-issues-17-new-ones-for-ios-flaws.html#tk.rss_all) -[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) - -Cisco warns of two security patches that don’t work, issues 17 new ones for IOS flaws -====== - -### Cisco is issuing 17 new fixes for security problems with IOS and IOS/XE software that runs most of its routers and switches, while it has no patch yet to replace flawed patches to RV320 and RV 325 routers. - -![Marisa9 / Getty][1] - -Cisco has dropped [17 Security advisories describing 19 vulnerabilities][2] in the software that runs most of its routers and switches, IOS and IOS/XE. - -The company also announced that two previously issued patches for its RV320 and RV325 Dual Gigabit WAN VPN Routers were “incomplete” and would need to be redone and reissued. - -**[ Also see[What to consider when deploying a next generation firewall][3]. | Get regularly scheduled insights by [signing up for Network World newsletters][4]. ]** - -Cisco rates both those router vulnerabilities as “High” and describes the problems like this: - - * [One vulnerability][5] is due to improper validation of user-supplied input. An attacker could exploit this vulnerability by sending malicious HTTP POST requests to the web-based management interface of an affected device. A successful exploit could allow the attacker to execute arbitrary commands on the underlying Linux shell as _root_. - * The [second exposure][6] is due to improper access controls for URLs. An attacker could exploit this vulnerability by connecting to an affected device via HTTP or HTTPS and requesting specific URLs. A successful exploit could allow the attacker to download the router configuration or detailed diagnostic information. - - - -Cisco said firmware updates that address these vulnerabilities are not available and no workarounds exist, but is working on a complete fix for both. - -On the IOS front, the company said six of the vulnerabilities affect both Cisco IOS Software and Cisco IOS XE Software, one of the vulnerabilities affects just Cisco IOS software and ten of the vulnerabilities affect just Cisco IOS XE software. Some of the security bugs, which are all rated as “High”, include: - - * [A vulnerability][7] in the web UI of Cisco IOS XE Software could let an unauthenticated, remote attacker access sensitive configuration information. - * [A vulnerability][8] in Cisco IOS XE Software could let an authenticated, local attacker inject arbitrary commands that are executed with elevated privileges. The vulnerability is due to insufficient input validation of commands supplied by the user. An attacker could exploit this vulnerability by authenticating to a device and submitting crafted input to the affected commands. - * [A weakness][9] in the ingress traffic validation of Cisco IOS XE Software for Cisco Aggregation Services Router (ASR) 900 Route Switch Processor 3 could let an unauthenticated, adjacent attacker trigger a reload of an affected device, resulting in a denial of service (DoS) condition, Cisco said. The vulnerability exists because the software insufficiently validates ingress traffic on the ASIC used on the RSP3 platform. An attacker could exploit this vulnerability by sending a malformed OSPF version 2 message to an affected device. - * A problem in the [authorization subsystem][10] of Cisco IOS XE Software could allow an authenticated but unprivileged (level 1), remote attacker to run privileged Cisco IOS commands by using the web UI. The vulnerability is due to improper validation of user privileges of web UI users. An attacker could exploit this vulnerability by submitting a malicious payload to a specific endpoint in the web UI, Cisco said. - * A vulnerability in the [Cluster Management Protocol][11] (CMP) processing code in Cisco IOS Software and Cisco IOS XE Software could allow an unauthenticated, adjacent attacker to trigger a DoS condition on an affected device. The vulnerability is due to insufficient input validation when processing CMP management packets, Cisco said. - - - -Cisco has released free software updates that address the vulnerabilities described in these advisories and [directs users to their software agreements][12] to find out how they can download the fixes. - -Join the Network World communities on [Facebook][13] and [LinkedIn][14] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3384742/cisco-warns-of-two-security-patches-that-dont-work-issues-17-new-ones-for-ios-flaws.html#tk.rss_all - -作者:[Michael Cooney][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Michael-Cooney/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2019/02/woman-with-hands-over-face_mistake_oops_embarrassed_shy-by-marisa9-getty-100787990-large.jpg -[2]: https://tools.cisco.com/security/center/viewErp.x?alertId=ERP-71135 -[3]: https://www.networkworld.com/article/3236448/lan-wan/what-to-consider-when-deploying-a-next-generation-firewall.html -[4]: https://www.networkworld.com/newsletters/signup.html -[5]: https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20190123-rv-inject -[6]: https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20190123-rv-info -[7]: https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20190327-xeid -[8]: https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20190327-xecmd -[9]: https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20190327-rsp3-ospf -[10]: https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20190327-iosxe-privesc -[11]: https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20190327-cmp-dos -[12]: https://www.cisco.com/c/en/us/about/legal/cloud-and-software/end_user_license_agreement.html -[13]: https://www.facebook.com/NetworkWorld/ -[14]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20190329 How to manage your Linux environment.md b/sources/tech/20190329 How to manage your Linux environment.md deleted file mode 100644 index 2c4ca113e3..0000000000 --- a/sources/tech/20190329 How to manage your Linux environment.md +++ /dev/null @@ -1,177 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to manage your Linux environment) -[#]: via: (https://www.networkworld.com/article/3385516/how-to-manage-your-linux-environment.html#tk.rss_all) -[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) - -How to manage your Linux environment -====== - -### Linux user environments help you find the command you need and get a lot done without needing details about how the system is configured. Where the settings come from and how they can be modified is another matter. - -![IIP Photo Archive \(CC BY 2.0\)][1] - -The configuration of your user account on a Linux system simplifies your use of the system in a multitude of ways. You can run commands without knowing where they're located. You can reuse previously run commands without worrying how the system is keeping track of them. You can look at your email, view man pages, and get back to your home directory easily no matter where you might have wandered off to in the file system. And, when needed, you can tweak your account settings so that it works even more to your liking. - -Linux environment settings come from a series of files — some are system-wide (meaning they affect all user accounts) and some are configured in files that are sitting in your home directory. The system-wide settings take effect when you log in and local ones take effect right afterwards, so the changes that you make in your account will override system-wide settings. For bash users, these files include these system files: - -``` -/etc/environment -/etc/bash.bashrc -/etc/profile -``` - -And some of these local files: - -``` -~/.bashrc -~/.profile -- not read if ~/.bash_profile or ~/.bash_login -~/.bash_profile -~/.bash_login -``` - -You can modify any of the local four that exist, since they sit in your home directory and belong to you. - -**[ Two-Minute Linux Tips:[Learn how to master a host of Linux commands in these 2-minute video tutorials][2] ]** - -### Viewing your Linux environment settings - -To view your environment settings, use the **env** command. Your output will likely look similar to this: - -``` -$ env -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=01;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:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31: -*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31: -*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31: -*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=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;35:*.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;35:*.xwd=01;35:*.yuv=01;35: -*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36: -*.m4a=00;36:*.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:*.spf=00;36: -SSH_CONNECTION=192.168.0.21 34975 192.168.0.11 22 -LESSCLOSE=/usr/bin/lesspipe %s %s -LANG=en_US.UTF-8 -OLDPWD=/home/shs -XDG_SESSION_ID=2253 -USER=shs -PWD=/home/shs -HOME=/home/shs -SSH_CLIENT=192.168.0.21 34975 22 -XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop -SSH_TTY=/dev/pts/0 -MAIL=/var/mail/shs -TERM=xterm -SHELL=/bin/bash -SHLVL=1 -LOGNAME=shs -DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus -XDG_RUNTIME_DIR=/run/user/1000 -PATH=/home/shs/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin -LESSOPEN=| /usr/bin/lesspipe %s -_=/usr/bin/env -``` - -While you're likely to get a _lot_ of output, the first big section shown above deals with the colors that are used on the command line to identify various file types. When you see something like ***.tar=01;31:** , this tells you that tar files will be displayed in a file listing in red, while ***.jpg=01;35:** tells you that jpg files will show up in purple. These colors are meant to make it easy to pick out certain files from a file listing. You can learn more about these colors are defined and how to customize them at [Customizing your colors on the Linux command line][3]. - -One easy way to turn colors off when you prefer a simpler display is to use a command such as this one: - -``` -$ ls -l --color=never -``` - -That command could easily be turned into an alias: - -``` -$ alias ll2='ls -l --color=never' -``` - -You can also display individual settings using the **echo** command. In this command, we display the number of commands that will be remembered in our history buffer: - -``` -$ echo $HISTSIZE -1000 -``` - -Your last location in the file system will be remembered if you've moved. - -``` -PWD=/home/shs -OLDPWD=/tmp -``` - -### Making changes - -You can make changes to environment settings with a command like this, but add a line lsuch as "HISTSIZE=1234" in your ~/.bashrc file if you want to retain this setting. - -``` -$ export HISTSIZE=1234 -``` - -### What it means to "export" a variable - -Exporting a variable makes the setting available to your shell and possible subshells. By default, user-defined variables are local and are not exported to new processes such as subshells and scripts. The export command makes variables available to functions to child processes. - -### Adding and removing variables - -You can create new variables and make them available to you on the command line and subshells quite easily. However, these variables will not survive your logging out and then back in again unless you also add them to ~/.bashrc or a similar file. - -``` -$ export MSG="Hello, World!" -``` - -You can unset a variable if you need by using the **unset** command: - -``` -$ unset MSG -``` - -If the variable is defined locally, you can easily set it back up by sourcing your startup file(s). For example: - -``` -$ echo $MSG -Hello, World! -$ unset $MSG -$ echo $MSG - -$ . ~/.bashrc -$ echo $MSG -Hello, World! -``` - -### Wrap-up - -User accounts are set up with an appropriate set of startup files for creating a userful user environment, but both individual users and sysadmins can change the default settings by editing their personal setup files (users) or the files from which many of the settings originate (sysadmins). - -Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3385516/how-to-manage-your-linux-environment.html#tk.rss_all - -作者:[Sandra Henry-Stocker][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2019/03/environment-rocks-leaves-100792229-large.jpg -[2]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua -[3]: https://www.networkworld.com/article/3269587/customizing-your-text-colors-on-the-linux-command-line.html -[4]: https://www.facebook.com/NetworkWorld/ -[5]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20190331 How to build a mobile particulate matter sensor with a Raspberry Pi.md b/sources/tech/20190331 How to build a mobile particulate matter sensor with a Raspberry Pi.md deleted file mode 100644 index 7eea0bd556..0000000000 --- a/sources/tech/20190331 How to build a mobile particulate matter sensor with a Raspberry Pi.md +++ /dev/null @@ -1,126 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to build a mobile particulate matter sensor with a Raspberry Pi) -[#]: via: (https://opensource.com/article/19/3/mobile-particulate-matter-sensor) -[#]: author: (Stephan Tetzel https://opensource.com/users/stephan) - -How to build a mobile particulate matter sensor with a Raspberry Pi -====== - -Monitor your air quality with a Raspberry Pi, a cheap sensor, and an inexpensive display. - -![Team communication, chat][1] - -About a year ago, I wrote about [measuring air quality][2] using a Raspberry Pi and a cheap sensor. We've been using this project in our school and privately for a few years now. However, it has one disadvantage: It is not portable because it depends on a WLAN network or a wired network connection to work. You can't even access the sensor's measurements if the Raspberry Pi and the smartphone or computer are not on the same network. - -To overcome this limitation, we added a small screen to the Raspberry Pi so we can read the values directly from the device. Here's how we set up and configured a screen for our mobile fine particulate matter sensor. - -### Setting up the screen for the Raspberry Pi - -There is a wide range of Raspberry Pi displays available from [Amazon][3], AliExpress, and other sources. They range from ePaper screens to LCDs with touch function. We chose an inexpensive [3.5″ LCD][4] with touch and a resolution of 320×480 pixels that can be plugged directly into the Raspberry Pi's GPIO pins. It's also nice that a 3.5″ display is about the same size as a Raspberry Pi. - -The first time you turn on the screen and start the Raspberry Pi, the screen will remain white because the driver is missing. You have to install [the appropriate drivers][5] for the display first. Log in with SSH and execute the following commands: - -``` -$ rm -rf LCD-show -$ git clone -$ chmod -R 755 LCD-show -$ cd LCD-show/ -``` - -Execute the appropriate command for your screen to install the drivers. For example, this is the command for our model MPI3501 screen: - -``` -$ sudo ./LCD35-show -``` - -This command installs the appropriate drivers and restarts the Raspberry Pi. - -### Installing PIXEL desktop and setting up autostart - -Here is what we want our project to do: If the Raspberry Pi boots up, we want to display a small website with our air quality measurements. - -First, install the Raspberry Pi's [PIXEL desktop environment][6]: - -``` -$ sudo apt install raspberrypi-ui-mods -``` - -Then install the Chromium browser to display the website: - -``` -$ sudo apt install chromium-browser -``` - -Autologin is required for the measured values to be displayed directly after startup; otherwise, you will just see the login screen. However, autologin is not configured for the "pi" user by default. You can configure autologin with the **raspi-config** tool: - -``` -$ sudo raspi-config -``` - -In the menu, select: **3 Boot Options → B1 Desktop / CLI → B4 Desktop Autologin**. - -There is a step missing to start Chromium with our website right after boot. Create the folder **/home/pi/.config/lxsession/LXDE-pi/** : - -``` -$ mkdir -p /home/pi/config/lxsession/LXDE-pi/ -``` - -Then create the **autostart** file in this folder: - -``` -$ nano /home/pi/.config/lxsession/LXDE-pi/autostart -``` - -and paste the following code: - -``` -#@unclutter -@xset s off -@xset -dpms -@xset s noblank - -# Open Chromium in Full Screen Mode -@chromium-browser --incognito --kiosk -``` - -If you want to hide the mouse pointer, you have to install the package **unclutter** and remove the comment character at the beginning of the **autostart** file: - -``` -$ sudo apt install unclutter -``` - -![Mobile particulate matter sensor][7] - -I've made a few small changes to the code in the last year. So, if you set up the air quality project before, make sure to re-download the script and files for the AQI website using the instructions in the [original article][2]. - -By adding the touch screen, you now have a mobile particulate matter sensor! We use it at our school to check the quality of the air in the classrooms or to do comparative measurements. With this setup, you are no longer dependent on a network connection or WLAN. You can use the small measuring station everywhere—you can even use it with a power bank to be independent of the power grid. - -* * * - -_This article originally appeared on[Open School Solutions][8] and is republished with permission._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/3/mobile-particulate-matter-sensor - -作者:[Stephan Tetzel][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/stephan -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/talk_chat_team_mobile_desktop.png?itok=d7sRtKfQ (Team communication, chat) -[2]: https://opensource.com/article/18/3/how-measure-particulate-matter-raspberry-pi -[3]: https://www.amazon.com/gp/search/ref=as_li_qf_sp_sr_tl?ie=UTF8&tag=openschoolsol-20&keywords=lcd%20raspberry&index=aps&camp=1789&creative=9325&linkCode=ur2&linkId=51d6d7676e10d6c7db203c4a8b3b529a -[4]: https://amzn.to/2CcvgpC -[5]: https://github.com/goodtft/LCD-show -[6]: https://opensource.com/article/17/1/try-raspberry-pis-pixel-os-your-pc -[7]: https://opensource.com/sites/default/files/uploads/mobile-aqi-sensor.jpg (Mobile particulate matter sensor) -[8]: https://openschoolsolutions.org/mobile-particulate-matter-sensor/ diff --git a/sources/tech/20190401 Build and host a website with Git.md b/sources/tech/20190401 Build and host a website with Git.md deleted file mode 100644 index 32a07d3490..0000000000 --- a/sources/tech/20190401 Build and host a website with Git.md +++ /dev/null @@ -1,226 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Build and host a website with Git) -[#]: via: (https://opensource.com/article/19/4/building-hosting-website-git) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) - -Build and host a website with Git -====== -Publishing your own website is easy if you let Git help you out. Learn -how in the first article in our series about little-known Git uses. -![web development and design, desktop and browser][1] - -[Git][2] is one of those rare applications that has managed to encapsulate so much of modern computing into one program that it ends up serving as the computational engine for many other applications. While it's best-known for tracking source code changes in software development, it has many other uses that can make your life easier and more organized. In this series leading up to Git's 14th anniversary on April 7, we'll share seven little-known ways to use Git. - -Creating a website used to be both sublimely simple and a form of black magic all at once. Back in the old days of Web 1.0 (that's not what anyone actually called it), you could just open up any website, view its source code, and reverse engineer the HTML—with all its inline styling and table-based layout—and you felt like a programmer after an afternoon or two. But there was still the matter of getting the page you created on the internet, which meant dealing with servers and FTP and webroot directories and file permissions. While the modern web has become far more complex since then, self-publication can be just as easy (or easier!) if you let Git help you out. - -### Create a website with Hugo - -[Hugo][3] is an open source static site generator. Static sites are what the web used to be built on (if you go back far enough, it was _all_ the web was). There are several advantages to static sites: they're relatively easy to write because you don't have to code them, they're relatively secure because there's no code executed on the pages, and they can be quite fast because there's no processing aside from transferring whatever you have on the page. - -Hugo isn't the only static site generator out there. [Grav][4], [Pico][5], [Jekyll][6], [Podwrite][7], and many others provide an easy way to create a full-featured website with minimal maintenance. Hugo happens to be one with GitLab integration built in, which means you can generate and host your website with a free GitLab account. - -Hugo has some pretty big fans, too. For instance, if you've ever gone to the Let's Encrypt website, then you've used a site built with Hugo. - -![Let's Encrypt website][8] - -#### Install Hugo - -Hugo is cross-platform, and you can find installation instructions for MacOS, Windows, Linux, OpenBSD, and FreeBSD in [Hugo's getting started resources][9]. - -If you're on Linux or BSD, it's easiest to install Hugo from a software repository or ports tree. The exact command varies depending on what your distribution provides, but on Fedora you would enter: - -``` -$ sudo dnf install hugo -``` - -Confirm you have installed it correctly by opening a terminal and typing: - -``` -$ hugo help -``` - -This prints all the options available for the **hugo** command. If you don't see that, you may have installed Hugo incorrectly or need to [add the command to your path][10]. - -#### Create your site - -To build a Hugo site, you must have a specific directory structure, which Hugo will generate for you by entering: - -``` -$ hugo new site mysite -``` - -You now have a directory called **mysite** , and it contains the default directories you need to build a Hugo website. - -Git is your interface to get your site on the internet, so change directory to your new **mysite** folder and initialize it as a Git repository: - -``` -$ cd mysite -$ git init . -``` - -Hugo is pretty Git-friendly, so you can even use Git to install a theme for your site. Unless you plan on developing the theme you're installing, you can use the **\--depth** option to clone the latest state of the theme's source: - -``` -$ git clone --depth 1 \ - -themes/mero -``` - - -Now create some content for your site: - -``` -$ hugo new posts/hello.md -``` - -Use your favorite text editor to edit the **hello.md** file in the **content/posts** directory. Hugo accepts Markdown files and converts them to themed HTML files at publication, so your content must be in [Markdown format][11]. - -If you want to include images in your post, create a folder called **images** in the **static** directory. Place your images into this folder and reference them in your markup using the absolute path starting with **/images**. For example: - -``` -![A picture of a thing](/images/thing.jpeg) -``` - -#### Choose a theme - -You can find more themes at [themes.gohugo.io][12], but it's best to stay with a basic theme while testing. The canonical Hugo test theme is [Ananke][13]. Some themes have complex dependencies, and others don't render pages the way you might expect without complex configuration. The Mero theme used in this example comes bundled with a detailed **config.toml** configuration file, but (for the sake of simplicity) I'll provide just the basics here. Open the file called **config.toml** in a text editor and add three configuration parameters: - -``` - -languageCode = "en-us" -title = "My website on the web" -theme = "mero" - -[params] - author = "Seth Kenlon" - description = "My hugo demo" -``` - -#### Preview your site - -You don't have to put anything on the internet until you're ready to publish it. While you work, you can preview your site by launching the local-only web server that ships with Hugo. - -``` -$ hugo server --buildDrafts --disableFastRender -``` - -Open a web browser and navigate to **** to see your work in progress. - -### Publish with Git to GitLab - -To publish and host your site on GitLab, create a repository for the contents of your site. - -To create a repository in GitLab, click on the **New Project** button in your GitLab Projects page. Create an empty repository called **yourGitLabUsername.gitlab.io** , replacing **yourGitLabUsername** with your GitLab user name or group name. You must use this scheme as the name of your project. If you want to add a custom domain later, you can. - -Do not include a license or a README file (because you've started a project locally, adding these now would make pushing your data to GitLab more complex, and you can always add them later). - -Once you've created the empty repository on GitLab, add it as the remote location for the local copy of your Hugo site, which is already a Git repository: - -``` -$ git remote add origin git@gitlab.com:skenlon/mysite.git -``` - -Create a GitLab site configuration file called **.gitlab-ci.yml** and enter these options: - -``` -image: monachus/hugo - -variables: - GIT_SUBMODULE_STRATEGY: recursive - -pages: - script: - - hugo - artifacts: - paths: - - public - only: - - master -``` - -The **image** parameter defines a containerized image that will serve your site. The other parameters are instructions telling GitLab's servers what actions to execute when you push new code to your remote repository. For more information on GitLab's CI/CD (Continuous Integration and Delivery) options, see the [CI/CD section of GitLab's docs][14]. - -#### Set the excludes - -Your Git repository is configured, the commands to build your site on GitLab's servers are set, and your site ready to publish. For your first Git commit, you must take a few extra precautions so you're not version-controlling files you don't intend to version-control. - -First, add the **/public** directory that Hugo creates when building your site to your **.gitignore** file. You don't need to manage the finished site in Git; all you need to track are your source Hugo files. - -``` -$ echo "/public" >> .gitignore -``` - -You can't maintain a Git repository within a Git repository without creating a Git submodule. For the sake of keeping this simple, move the embedded **.git** directory so that the theme is just a theme. - -Note that you _must_ add your theme files to your Git repository so GitLab will have access to the theme. Without committing your theme files, your site cannot successfully build. - -``` -$ mv themes/mero/.git ~/.local/share/Trash/files/ -``` - -Alternately, use a **trash** command such as [Trashy][15]: - -``` -$ trash themes/mero/.git -``` - -Now you can add all the contents of your local project directory to Git and push it to GitLab: - -``` -$ git add . -$ git commit -m 'hugo init' -$ git push -u origin HEAD -``` - -### Go live with GitLab - -Once your code has been pushed to GitLab, take a look at your project page. An icon indicates GitLab is processing your build. It might take several minutes the first time you push your code, so be patient. However, don't be _too_ patient, because the icon doesn't always update reliably. - -![GitLab processing your build][16] - -While you're waiting for GitLab to assemble your site, go to your project settings and find the **Pages** panel. Once your site is ready, its URL will be provided for you. The URL is **yourGitLabUsername.gitlab.io/yourProjectName**. Navigate to that address to view the fruits of your labor. - -![Previewing Hugo site][17] - -If your site fails to assemble correctly, GitLab provides insight into the CI/CD pipeline logs. Review the error message for an indication of what went wrong. - -### Git and the web - -Hugo (or Jekyll or similar tools) is just one way to leverage Git as your web publishing tool. With server-side Git hooks, you can design your own Git-to-web pipeline with minimal scripting. With the community edition of GitLab, you can self-host your own GitLab instance or you can use an alternative like [Gitolite][18] or [Gitea][19] and use this article as inspiration for a custom solution. Have fun! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/4/building-hosting-website-git - -作者:[Seth Kenlon (Red Hat, Community Moderator)][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh (web development and design, desktop and browser) -[2]: https://git-scm.com/ -[3]: http://gohugo.io -[4]: http://getgrav.org -[5]: http://picocms.org/ -[6]: https://jekyllrb.com -[7]: http://slackermedia.info/podwrite/ -[8]: https://opensource.com/sites/default/files/uploads/letsencrypt-site.jpg (Let's Encrypt website) -[9]: https://gohugo.io/getting-started/installing -[10]: https://opensource.com/article/17/6/set-path-linux -[11]: https://commonmark.org/help/ -[12]: https://themes.gohugo.io/ -[13]: https://themes.gohugo.io/gohugo-theme-ananke/ -[14]: https://docs.gitlab.com/ee/ci/#overview -[15]: http://slackermedia.info/trashy -[16]: https://opensource.com/sites/default/files/uploads/hugo-gitlab-cicd.jpg (GitLab processing your build) -[17]: https://opensource.com/sites/default/files/uploads/hugo-demo-site.jpg (Previewing Hugo site) -[18]: http://gitolite.com -[19]: http://gitea.io diff --git a/sources/tech/20190402 Announcing the release of Fedora 30 Beta.md b/sources/tech/20190402 Announcing the release of Fedora 30 Beta.md deleted file mode 100644 index 19b5926e27..0000000000 --- a/sources/tech/20190402 Announcing the release of Fedora 30 Beta.md +++ /dev/null @@ -1,90 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Announcing the release of Fedora 30 Beta) -[#]: via: (https://fedoramagazine.org/announcing-the-release-of-fedora-30-beta/) -[#]: author: (Ben Cotton https://fedoramagazine.org/author/bcotton/) - -Announcing the release of Fedora 30 Beta -====== - -![][1] - -The Fedora Project is pleased to announce the immediate availability of Fedora 30 Beta, the next big step on our journey to the exciting Fedora 30 release. - -Download the prerelease from our Get Fedora site: - - * [Get Fedora 30 Beta Workstation][2] - * [Get Fedora 30 Beta Server][3] - * [Get Fedora 30 Beta Silverblue][4] - - - -Or, check out one of our popular variants, including KDE Plasma, Xfce, and other desktop environments, as well as images for ARM devices like the Raspberry Pi 2 and 3: - - * [Get Fedora 30 Beta Spins][5] - * [Get Fedora 30 Beta Labs][6] - * [Get Fedora 30 Beta ARM][7] - - - -### Beta Release Highlights - -#### New desktop environment options - -Fedora 30 Beta includes two new options for desktop environment. [DeepinDE][8] and [Pantheon Desktop][9] join GNOME, KDE Plasma, Xfce, and others as options for users to customize their Fedora experience. - -#### DNF performance improvements - -All dnf repository metadata for Fedora 30 Beta is compressed with the zchunk format in addition to xz or gzip. zchunk is a new compression format designed to allow for highly efficient deltas. When Fedora’s metadata is compressed using zchunk, dnf will download only the differences between any earlier copies of the metadata and the current version. - -#### GNOME 3.32 - -Fedora 30 Workstation Beta includes GNOME 3.32, the latest version of the popular desktop environment. GNOME 3.32 features updated visual style, including the user interface, the icons, and the desktop itself. For a full list of GNOME 3.32 highlights, see the [release notes][10]. - -#### Other updates - -Fedora 30 Beta also includes updated versions of many popular packages like Golang, the Bash shell, the GNU C Library, Python, and Perl. For a full list, see the [Change set][11] on the Fedora Wiki. In addition, many Python 2 packages are removed in preparation for Python 2 end-of-life on 2020-01-01. - -#### Testing needed - -Since this is a Beta release, we expect that you may encounter bugs or missing features. To report issues encountered during testing, contact the Fedora QA team via the mailing list or in #fedora-qa on Freenode. As testing progresses, common issues are tracked on the [Common F30 Bugs page][12]. - -For tips on reporting a bug effectively, read [how to file a bug][13]. - -#### What is the Beta Release? - -A Beta release is code-complete and bears a very strong resemblance to the final release. If you take the time to download and try out the Beta, you can check and make sure the things that are important to you are working. Every bug you find and report doesn’t just help you, it improves the experience of millions of Fedora users worldwide! Together, we can make Fedora rock-solid. We have a culture of coordinating new features and pushing fixes upstream as much as we can. Your feedback improves not only Fedora, but Linux and free software as a whole. - -#### More information - -For more detailed information about what’s new on Fedora 30 Beta release, you can consult the [Fedora 30 Change set][11]. It contains more technical information about the new packages and improvements shipped with this release. - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/announcing-the-release-of-fedora-30-beta/ - -作者:[Ben Cotton][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/bcotton/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2019/03/f30-beta-816x345.jpg -[2]: https://getfedora.org/workstation/prerelease/ -[3]: https://getfedora.org/server/prerelease/ -[4]: https://silverblue.fedoraproject.org/download -[5]: https://spins.fedoraproject.org/prerelease -[6]: https://labs.fedoraproject.org/prerelease -[7]: https://arm.fedoraproject.org/prerelease -[8]: https://www.deepin.org/en/dde/ -[9]: https://www.fosslinux.com/4652/pantheon-everything-you-need-to-know-about-the-elementary-os-desktop.htm -[10]: https://help.gnome.org/misc/release-notes/3.32/ -[11]: https://fedoraproject.org/wiki/Releases/30/ChangeSet -[12]: https://fedoraproject.org/wiki/Common_F30_bugs -[13]: https://docs.fedoraproject.org/en-US/quick-docs/howto-file-a-bug/ diff --git a/sources/tech/20190402 Manage your daily schedule with Git.md b/sources/tech/20190402 Manage your daily schedule with Git.md deleted file mode 100644 index 8f5d7d89bb..0000000000 --- a/sources/tech/20190402 Manage your daily schedule with Git.md +++ /dev/null @@ -1,240 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Manage your daily schedule with Git) -[#]: via: (https://opensource.com/article/19/4/calendar-git) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) - -Manage your daily schedule with Git -====== -Treat time like source code and maintain your calendar with the help of -Git. -![website design image][1] - -[Git][2] is one of those rare applications that has managed to encapsulate so much of modern computing into one program that it ends up serving as the computational engine for many other applications. While it's best-known for tracking source code changes in software development, it has many other uses that can make your life easier and more organized. In this series leading up to Git's 14th anniversary on April 7, we'll share seven little-known ways to use Git. Today, we'll look at using Git to keep track of your calendar. - -### Keep track of your schedule with Git - -What if time itself was but source code that could be managed and version controlled? While proving or disproving such a theory is probably beyond the scope of this article, it happens that you can treat time like source code and manage your daily schedule with the help of Git. - -The reigning champion for calendaring is the [CalDAV][3] protocol, which drives popular open source calendaring applications like [NextCloud][4] as well as popular closed source ones. There's nothing wrong with CalDAV (commenters, take heed). But it's not for everyone, and besides there's nothing less inspiring than a mono-culture. - -Because I have no interest in becoming invested in largely GUI-dependent CalDAV clients (although if you're looking for a good terminal CalDAV viewer, see [khal][5]), I started investigating text-based alternatives. Text-based calendaring has all the usual benefits of working in [plaintext][6]. It's lightweight, it's highly portable, and as long as it's structured, it's easy to parse and beautify (whatever _beauty_ means to you). - -And best of all, it's exactly what Git was designed to manage. - -### Org mode not in a scary way - -If you don't impose structure on your plaintext, it quickly falls into a pandemonium of off-the-cuff thoughts and devil-may-care notation. Luckily, a markup syntax exists for calendaring, and it's contained in the venerable productivity Emacs mode, [Org mode][7] (which, admit it, you've been meaning to start using anyway). - -The amazing thing about Org mode that many people don't realize is [you don't need to know or even use Emacs][8] to take advantage of conventions established by Org mode. You get a lot of great features if you _do_ use Emacs, but if Emacs intimidates you, then you can implement a Git-based Org-mode calendaring system without so much as installing Emacs. - -The only part of Org mode that you need to know is its syntax. Org-mode syntax is low-maintenance and fairly intuitive. The biggest difference in calendaring with Org mode instead of a GUI calendaring app is the workflow: instead of going to a calendar and finding the day you want to schedule a task, you create a list of tasks and then assign each one a day and time. - -Lists in Org mode use asterisks (*) as bullets. Here's my gaming task list: **** - -``` -* Gaming -** Build Stardrifter character -** Read Stardrifter rules -** Stardrifter playtest - -** Blue Planet @ Mike's - -** Run Rappan Athuk -*** Purchase hard copy -*** Skim Rappan Athuk -*** Build Rappan Athuk maps in maptool -*** Sort Rappan Athuk tokens -``` - -If you're familiar with [CommonMark][9] or Markdown, you'll notice that instead of using whitespace to create a subtask, Org mode favors the more explicit use of additional bullets. Whatever your background with lists, this is an intuitive and easy way to build a list, and it obviously is not inherently tied to Emacs (although using Emacs provides you with shortcuts so you can rearrange your list quickly). - -To turn your list into scheduled tasks or events in a calendar, go back through and add the keywords **SCHEDULED** and, optionally, **:CATEGORY:**. - -``` -* Gaming -:CATEGORY: Game -** Build Stardrifter character -SCHEDULED: <2019-03-22 18:00-19:00> -** Read Stardrifter rules -SCHEDULED: <2019-03-22 19:00-21:00> -** Stardrifter playtest -SCHEDULED: <2019-03-25 0900-1300> -** Blue Planet @ Mike's -SCHEDULED: <2019-03-18 18:00-23:00 +1w> - -and so on... -``` - -The **SCHEDULED** keyword marks the entry as an event that you expect to be notified about and the optional **:CATEGORY:** keyword is an arbitrary tagging system for your own use (and in Emacs, you can color-code entries according to category). - -For a repeating event, you can use notation such as **+1w** to create a weekly event or **+2w** for a fortnightly event, and so on. - -All the fancy markup available for Org mode is [documented][10], so don't hesitate to find more tricks to help it fit your needs. - -### Put it into Git - -Without Git, your Org-mode appointments are just a file on your local machine. It's the 21st century, though, so you at least need your calendar on your mobile phone, if not on all of your personal computers. You can use Git to publish your calendar for yourself and others. - -First, create a directory for your **.org** files. I store mine in **~/cal**. - -``` -$ mkdir ~/cal -``` - -Change into your directory and make it a Git repository: - -``` -$ cd cal -$ git init -``` - -Move your **.org** file to your local Git repo. In practice, I maintain one **.org** file per category. - -``` -$ mv ~/*.org ~/cal -$ ls -Game.org Meal.org Seth.org Work.org -``` - -Stage and commit your files: - -``` -$ git add *.org -$ git commit -m 'cal init' -``` - -### Create a Git remote - -To make your calendar available from anywhere, you must have a Git repository on the internet. Your calendar is plaintext, so any Git repository will do. You can put your calendar on [GitLab][11] or any other public Git hosting service (even proprietary ones), and as long as your host allows it, you can even mark the repository as private. If you don't want to post your calendar to a server you don't control, it's easy to host a Git repository yourself, either using a bare repository for a single user or using a frontend service like [Gitolite][12] or [Gitea][13]. - -In the interest of simplicity, I'll assume a self-hosted bare Git repository. You can create a bare remote repository on any server you have SSH access to with one Git command: -``` -$ ssh -p 22122 [seth@example.com][14] -[remote]$ mkdir cal.git -[remote]$ cd cal.git -[remote]$ git init --bare -[remote]$ exit -``` - -This bare repository can serve as your calendar's home on the internet. - -Set it as the remote source for your local (on your computer, not your server) Git repository: - -``` -$ git remote add origin seth@example.com:/home/seth/cal.git -``` - -And then push your calendar data to the server: - -``` -$ git push -u origin HEAD -``` - -With your calendar in a Git repository, it's available to you on any device running Git. That means you can make updates and changes to your schedule and push your changes upstream so it updates everywhere. - -I use this method to keep my calendar in sync between my work laptop and my home workstation. Since I use Emacs every day for most of the day, being able to view and edit my calendar in Emacs is a major convenience. The same is true for most people with a mobile device, so the next step is to set up an Org-mode calendaring system on a mobile. - -### Mobile Git - -Since your calendar data is in plaintext, strictly speaking, you can "use" it on any device that can read a text file. That's part of the beauty of this system; you're never without, at the very least, your raw data. But to integrate your calendar on a mobile device the way you'd expect a modern calendar to work, you need two components: a mobile Git client and a mobile Org-mode viewer. - -#### Git client for mobile - -[MGit][15] is a good Git client for Android. There are Git clients for iOS, as well. - -Once you've installed MGit (or a similar Git client), you must clone your calendar repository so your phone has a copy. To access your server from your mobile device, you must set up an SSH key for authentication. MGit can generate and store a key for you, which you must add to your server's **~/.ssh/authorized_keys** file or to your SSH keys in the settings of your hosted Git account. - -You must do this manually. MGit does not have an interface to log into your server or hosted Git account. If you do not do this, your mobile device cannot access your server to access your calendar data. - -I did it by copying the key file I generated in MGit to my laptop over [KDE Connect][16] (but you can do the same over Bluetooth, or with an SD card reader, or a USB cable, depending on your preferred method of accessing data on your phone). I copied the key (a file called **calkey** to my server with this command: - -``` -$ cat calkey | ssh seth@example.com "cat >> /home/seth/.ssh/authorized_keys" -``` - -You may have a different way of doing it, but if you ever set your server up for passwordless login, this is exactly the same process. If you're using a hosted Git service like GitLab, you must copy and paste the contents of your key file into your user account's SSH Key panel. - -![Adding key file data to GitLab][17] - -Once that's done, your mobile device can authorize to your server, but it still needs to know where to go to find your calendar data. Different apps may use different notation, but MGit uses plain old Git-over-SSH. That means if you're using a non-standard SSH port, you must specify the SSH port to use: - -``` -$ git clone ssh://seth@example.com:22122//home/seth/git/cal.git -``` - -![Specifying SSH port in MGit][18] - -If you use a different app, it may use a different syntax that allows you to provide a port in a special field or drop the **ssh://** prefix. Refer to the app documentation if you experience issues. - -Clone the repository to your phone. - -![Cloned repositories][19] - -Few Git apps are set to automatically update the repository. There are a few apps you can use to automate pulls, or you can set up Git hooks to push updates from your server—but I won't get into that here. For now, after you make an update to your calendar, be sure to pull new changes manually in MGit (or if you change events on your phone, push the changes to your server). - -![MGit push/pull settings][20] - -#### Mobile calendar - -There are a few different apps that provide frontends for Org mode on a mobile device. [Orgzly][21] is a great open source Android app that provides an interface for Org mode's greatest features, from the Agenda mode to the TODO lists. Install and launch it. - -From the Main menu, choose Setting Sync Repositories and select the directory containing your calendar files (i.e., the Git repository you cloned from your server). - -Give Orgzly a moment to import the data, then use Orgzly's [hamburger][22] menu to select the Agenda view. - -![Orgzly's agenda view][23] - -In Orgzly's Settings Reminders menu, you can choose which event types trigger a notification on your phone. You can get notifications for **SCHEDULED** tasks, **DEADLINE** tasks, or anything with an event time assigned to it. If you use your phone as your taskmaster, you'll never miss an event with Org mode and Orgzly. - -![Orgzly notification][24] - -Orgzly isn't just a parser. You can edit and update events, and even mark events **DONE**. - -![Orgzly to-do list][25] - -### Designed for and by you - -The important thing to understand about using Org mode and Git is that both applications are highly flexible, and it's expected that you'll customize how and what they do so they will adapt to your needs. If something in this article is an affront to how you organize your life or manage your weekly schedule, but you like other parts of what this proposal offers, then throw out the part you don't like. You can use Org mode in Emacs if you want, or you can just use it as calendar markup. You can set your phone to pull Git data right off your computer at the end of the day instead of a server on the internet, or you can configure your computer to sync calendars whenever your phone is plugged in, or you can manage it daily as you load up your phone with all the stuff you need for the workday. It's up to you, and that's the most significant thing about Git, about Org mode, and about open source. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/4/calendar-git - -作者:[Seth Kenlon (Red Hat, Community Moderator)][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web-design-monitor-website.png?itok=yUK7_qR0 (website design image) -[2]: https://git-scm.com/ -[3]: https://tools.ietf.org/html/rfc4791 -[4]: http://nextcloud.com -[5]: https://github.com/pimutils/khal -[6]: https://plaintextproject.online/ -[7]: https://orgmode.org -[8]: https://opensource.com/article/19/1/productivity-tool-org-mode -[9]: https://commonmark.org/ -[10]: https://orgmode.org/manual/ -[11]: http://gitlab.com -[12]: http://gitolite.com/gitolite/index.html -[13]: https://gitea.io/en-us/ -[14]: mailto:seth@example.com -[15]: https://f-droid.org/en/packages/com.manichord.mgit -[16]: https://community.kde.org/KDEConnect -[17]: https://opensource.com/sites/default/files/uploads/gitlab-add-key.jpg (Adding key file data to GitLab) -[18]: https://opensource.com/sites/default/files/uploads/mgit-0.jpg (Specifying SSH port in MGit) -[19]: https://opensource.com/sites/default/files/uploads/mgit-1.jpg (Cloned repositories) -[20]: https://opensource.com/sites/default/files/uploads/mgit-2.jpg (MGit push/pull settings) -[21]: https://f-droid.org/en/packages/com.orgzly/ -[22]: https://en.wikipedia.org/wiki/Hamburger_button -[23]: https://opensource.com/sites/default/files/uploads/orgzly-agenda.jpg (Orgzly's agenda view) -[24]: https://opensource.com/sites/default/files/uploads/orgzly-cal-notify.jpg (Orgzly notification) -[25]: https://opensource.com/sites/default/files/uploads/orgzly-cal-todo.jpg (Orgzly to-do list) diff --git a/sources/tech/20190403 How to rebase to Fedora 30 Beta on Silverblue.md b/sources/tech/20190403 How to rebase to Fedora 30 Beta on Silverblue.md deleted file mode 100644 index 892afff5d6..0000000000 --- a/sources/tech/20190403 How to rebase to Fedora 30 Beta on Silverblue.md +++ /dev/null @@ -1,70 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to rebase to Fedora 30 Beta on Silverblue) -[#]: via: (https://fedoramagazine.org/how-to-rebase-to-fedora-30-beta-on-silverblue/) -[#]: author: (Michal Konečný https://fedoramagazine.org/author/zlopez/) - -How to rebase to Fedora 30 Beta on Silverblue -====== - -![][1] - -Silverblue is [an operating system for your desktop built on Fedora][2]. It’s excellent for daily use, development, and container-based workflows. It offers [numerous advantages][3] such as being able to roll back in case of any problems. If you want to test Fedora 30 on your Silverblue system, this article tells you how. It not only shows you what to do, but also how to revert back if anything unforeseen happens. - -### Switching to Fedora 30 branch - -Switching to Fedora 30 on Silverblue is easy. First, check if the _30_ branch is available, which should be true now: - -``` -ostree remote refs fedora-workstation -``` - -You should see the following in the output: - -``` -fedora-workstation:fedora/30/x86_64/silverblue -``` - -Next, import the GPG key for the Fedora 30 branch. Without this step, you won’t be able to rebase. - -``` -sudo ostree remote gpg-import fedora-workstation -k /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-30-primary -``` - -Next, rebase your system to the Fedora 30 branch. - -``` -rpm-ostree rebase fedora-workstation:fedora/30/x86_64/silverblue -``` - -Finally, the last thing to do is restart your computer and boot to Fedora 30. - -### How to revert things back - -Remember that Fedora 30’s still in beta testing phase, so there could still be some issues. If anything bad happens — for instance, if you can’t boot to Fedora 30 at all — it’s easy to go back. Just pick the previous entry in GRUB, and your system will start in its previous state before switching to Fedora 30. To make this change permanent, use the following command: - -``` -rpm-ostree rollback -``` - -That’s it. Now you know how to rebase to Fedora 30 and back. So why not test it today? 🙂 - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/how-to-rebase-to-fedora-30-beta-on-silverblue/ - -作者:[Michal Konečný][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/zlopez/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2019/03/silverblue-f30beta-816x345.jpg -[2]: https://docs.fedoraproject.org/en-US/fedora-silverblue/ -[3]: https://fedoramagazine.org/give-fedora-silverblue-a-test-drive/ diff --git a/sources/tech/20190403 Use Git as the backend for chat.md b/sources/tech/20190403 Use Git as the backend for chat.md deleted file mode 100644 index e564bbc6e7..0000000000 --- a/sources/tech/20190403 Use Git as the backend for chat.md +++ /dev/null @@ -1,141 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Use Git as the backend for chat) -[#]: via: (https://opensource.com/article/19/4/git-based-chat) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) - -Use Git as the backend for chat -====== -GIC is a prototype chat application that showcases a novel way to use Git. -![Team communication, chat][1] - -[Git][2] is one of those rare applications that has managed to encapsulate so much of modern computing into one program that it ends up serving as the computational engine for many other applications. While it's best-known for tracking source code changes in software development, it has many other uses that can make your life easier and more organized. In this series leading up to Git's 14th anniversary on April 7, we'll share seven little-known ways to use Git. Today, we'll look at GIC, a Git-based chat application - -### Meet GIC - -While the authors of Git probably expected frontends to be created for Git, they undoubtedly never expected Git would become the backend for, say, a chat client. Yet, that's exactly what developer Ephi Gabay did with his experimental proof-of-concept [GIC][3]: a chat client written in [Node.js][4] using Git as its backend database. - -GIC is by no means intended for production use. It's purely a programming exercise, but it's one that demonstrates the flexibility of open source technology. What's astonishing is that the client consists of just 300 lines of code, excluding the Node libraries and Git itself. And that's one of the best things about the chat client and about open source; the ability to build upon existing work. Seeing is believing, so you should give GIC a look for yourself. - -### Get set up - -GIC uses Git as its engine, so you need an empty Git repository to serve as its chatroom and logger. The repository can be hosted anywhere, as long as you and anyone who needs access to the chat service has access to it. For instance, you can set up a Git repository on a free Git hosting service like GitLab and grant chat users contributor access to the Git repository. (They must be able to make commits to the repository, because each chat message is a literal commit.) - -If you're hosting it yourself, create a centrally located bare repository. Each user in the chat must have an account on the server where the bare repository is located. You can create accounts specific to Git with Git hosting software like [Gitolite][5] or [Gitea][6], or you can give them individual user accounts on your server, possibly using **git-shell** to restrict their access to Git. - -Performance is best on a self-hosted instance. Whether you host your own or you use a hosting service, the Git repository you create must have an active branch, or GIC won't be able to make commits as users chat because there is no Git HEAD. The easiest way to ensure that a branch is initialized and active is to commit a README or license file upon creation. If you don't do that, you can create and commit one after the fact: - -``` -$ echo "chat logs" > README -$ git add README -$ git commit -m 'just creating a HEAD ref' -$ git push -u origin HEAD -``` - -### Install GIC - -Since GIC is based on Git and written in Node.js, you must first install Git, Node.js, and the Node package manager, npm (which should be bundled with Node). The command to install these differs depending on your Linux or BSD distribution, but here's an example command on Fedora: - -``` -$ sudo dnf install git nodejs -``` - -If you're not running Linux or BSD, follow the installation instructions on [git-scm.com][7] and [nodejs.org][8]. - -There's no install process, as such, for GIC. Each user (Alice and Bob, in this example) must clone the repository to their hard drive: - -``` -$ git cone https://github.com/ephigabay/GIC GIC -``` - -Change directory into the GIC directory and install the Node.js dependencies with **npm** : - -``` -$ cd GIC -$ npm install -``` - -Wait for the Node modules to download and install. - -### Configure GIC - -The only configuration GIC requires is the location of your Git chat repository. Edit the **config.js** file: - -``` -module.exports = { -gitRepo: '[seth@example.com][9]:/home/gitchat/chatdemo.git', -messageCheckInterval: 500, -branchesCheckInterval: 5000 -}; -``` - - -Test your connection to the Git repository before trying GIC, just to make sure your configuration is sane: - -``` -$ git clone --quiet seth@example.com:/home/gitchat/chatdemo.git > /dev/null -``` - -Assuming you receive no errors, you're ready to start chatting. - -### Chat with Git - -From within the GIC directory, start the chat client: - -``` -$ npm start -``` - -When the client first launches, it must clone the chat repository. Since it's nearly an empty repository, it won't take long. Type your message and press Enter to send a message. - -![GIC][10] - -A Git-based chat client. What will they think of next? - -As the greeting message says, a branch in Git serves as a chatroom or channel in GIC. There's no way to create a new branch from within the GIC UI, but if you create one in another terminal session or in a web UI, it shows up immediately in GIC. It wouldn't take much to patch some IRC-style commands into GIC. - -After chatting for a while, take a look at your Git repository. Since the chat happens in Git, the repository itself is also a chat log: - -``` -$ git log --pretty=format:"%p %cn %s" -4387984 Seth Kenlon Hey Chani, did you submit a talk for All Things Open this year? -36369bb Chani No I didn't get a chance. Did you? -[...] -``` - -### Exit GIC - -Not since Vim has there been an application as difficult to stop as GIC. You see, there is no way to stop GIC. It will continue to run until it is killed. When you're ready to stop GIC, open another terminal tab or window and issue this command: - -``` -$ kill `pgrep npm` -``` - -GIC is a novelty. It's a great example of how an open source ecosystem encourages and enables creativity and exploration and challenges us to look at applications from different angles. Try GIC out. Maybe it will give you ideas. At the very least, it's a great excuse to spend an afternoon with Git. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/4/git-based-chat - -作者:[Seth Kenlon (Red Hat, Community Moderator)][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/talk_chat_team_mobile_desktop.png?itok=d7sRtKfQ (Team communication, chat) -[2]: https://git-scm.com/ -[3]: https://github.com/ephigabay/GIC -[4]: https://nodejs.org/en/ -[5]: http://gitolite.com -[6]: http://gitea.io -[7]: http://git-scm.com -[8]: http://nodejs.org -[9]: mailto:seth@example.com -[10]: https://opensource.com/sites/default/files/uploads/gic.jpg (GIC) diff --git a/sources/tech/20190404 How writers can get work done better with Git.md b/sources/tech/20190404 How writers can get work done better with Git.md new file mode 100644 index 0000000000..1da47fd69f --- /dev/null +++ b/sources/tech/20190404 How writers can get work done better with Git.md @@ -0,0 +1,266 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How writers can get work done better with Git) +[#]: via: (https://opensource.com/article/19/4/write-git) +[#]: author: (Seth Kenlon https://opensource.com/users/sethhttps://opensource.com/users/noreplyhttps://opensource.com/users/seth) + +How writers can get work done better with Git +====== +If you're a writer, you could probably benefit from using Git. Learn how +in our series about little-known uses of Git. +![Writing Hand][1] + +[Git][2] is one of those rare applications that has managed to encapsulate so much of modern computing into one program that it ends up serving as the computational engine for many other applications. While it's best-known for tracking source code changes in software development, it has many other uses that can make your life easier and more organized. In this series leading up to Git's 14th anniversary on April 7, we'll share seven little-known ways to use Git. Today, we'll look at ways writers can use Git to get work done. + +### Git for writers + +Some people write fiction; others write academic papers, poetry, screenplays, technical manuals, or articles about open source. Many do a little of each. The common thread is that if you're a writer, you could probably benefit from using Git. While Git is famously a highly technical tool used by computer programmers, it's ideal for the modern author, and this article will demonstrate how it can change the way you write—and why you'd want it to. + +Before talking about Git, though, it's important to talk about what _copy_ (or _content_ , for the digital age) really is, and why it's different from your delivery _medium_. It's the 21 st century, and the tool of choice for most writers is a computer. While computers are deceptively good at combining processes like copy editing and layout, writers are (re)discovering that separating content from style is a good idea, after all. That means you should be writing on a computer like it's a typewriter, not a word processor. In computer lingo, that means writing in _plaintext_. + +### Writing in plaintext + +It used to be a safe assumption that you knew what market you were writing for. You wrote content for a book, or a website, or a software manual. These days, though, the market's flattened: you might decide to use content you write for a website in a printed book project, and the printed book might release an EPUB version later. And in the case of digital editions of your content, the person reading your content is in ultimate control: they may read your words on the website where you published them, or they might click on Firefox's excellent [Reader View][3], or they might print to physical paper, or they could dump the web page to a text file with Lynx, or they may not see your content at all because they use a screen reader. + +It makes sense to write your words as words, leaving the delivery to the publishers. Even if you are also your own publisher, treating your words as a kind of source code for your writing is a smarter and more efficient way to work, because when it comes time to publish, you can use the same source (your plaintext) to generate output appropriate to your target (PDF for print, EPUB for e-books, HTML for websites, and so on). + +Writing in plaintext not only means you don't have to worry about layout or how your text is styled, but you also no longer require specialized tools. Anything that can produce text becomes a valid "word processor" for you, whether it's a basic notepad app on your mobile or tablet, the text editor that came bundled with your computer, or a free editor you download from the internet. You can write on practically any device, no matter where you are or what you're doing, and the text you produce integrates perfectly with your project, no modification required. + +And, conveniently, Git specializes in managing plaintext. + +### The Atom editor + +When you write in plaintext, a word processor is overkill. Using a text editor is easier because text editors don't try to "helpfully" restructure your input. It lets you type the words in your head onto the screen, no interference. Better still, text editors are often designed around a plugin architecture, such that the application itself is woefully basic (it edits text), but you can build an environment around it to meet your every need. + +A great example of this design philosophy is the [Atom][4] editor. It's a cross-platform text editor with built-in Git integration. If you're new to working in plaintext and new to Git, Atom is the easiest way to get started. + +#### Install Git and Atom + +First, make sure you have Git installed on your system. If you run Linux or BSD, Git is available in your software repository or ports tree. The command you use will vary depending on your distribution; on Fedora, for instance: + + +``` +`$ sudo dnf install git` +``` + +You can also download and install Git for [Mac][5] and [Windows][6]. + +You won't need to use Git directly, because Atom serves as your Git interface. Installing Atom is the next step. + +If you're on Linux, install Atom from your software repository through your software installer or the appropriate command, such as: + + +``` +`$ sudo dnf install atom` +``` + +Atom does not currently build on BSD. However, there are very good alternatives available, such as [GNU Emacs][7]. For Mac and Windows users, you can find installers on the [Atom website][4]. + +Once your installs are done, launch the Atom editor. + +#### A quick tour + +If you're going to live in plaintext and Git, you need to get comfortable with your editor. Atom's user interface may be more dynamic than what you are used to. You can think of it more like Firefox or Chrome than as a word processor, in fact, because it has tabs and panels that can be opened and closed as they are needed, and it even has add-ons that you can install and configure. It's not practical to try to cover all of Atom's many features, but you can at least get familiar with what's possible. + +When Atom opens, it displays a welcome screen. If nothing else, this screen is a good introduction to Atom's tabbed interface. You can close the welcome screens by clicking the "close" icons on the tabs at the top of the Atom window and create a new file using **File > New File**. + +Working in plaintext is a little different than working in a word processor, so here are some tips for writing content in a way that a human can connect with and that Git and computers can parse, track, and convert. + +#### Write in Markdown + +These days, when people talk about plaintext, mostly they mean Markdown. Markdown is more of a style than a format, meaning that it intends to provide a predictable structure to your text so computers can detect natural patterns and convert the text intelligently. Markdown has many definitions, but the best technical definition and cheatsheet is on [CommonMark's website][8]. + + +``` +# Chapter 1 + +This is a paragraph with an *italic* word and a **bold** word in it. +And it can even reference an image. + +![An image will render here.](drawing.jpg) +``` + +As you can tell from the example, Markdown isn't meant to read or feel like code, but it can be treated as code. If you follow the expectations of Markdown defined by CommonMark, then you can reliably convert, with just one click of a button, your writing from Markdown to .docx, .epub, .html, MediaWiki, .odt, .pdf, .rtf, and a dozen other formats _without_ loss of formatting. + +You can think of Markdown a little like a word processor's styles. If you've ever written for a publisher with a set of styles that govern what chapter titles and section headings look like, this is basically the same thing, except that instead of selecting a style from a drop-down menu, you're adding little notations to your text. These notations look natural to any modern reader who's used to "txt speak," but are swapped out with fancy text stylings when the text is rendered. It is, in fact, what word processors secretly do behind the scenes. The word processor shows bold text, but if you could see the code generated to make your text bold, it would be a lot like Markdown (actually it's the far more complex XML). With Markdown, that barrier is removed, which looks scarier on the one hand, but on the other hand, you can write Markdown on literally anything that generates text without losing any formatting information. + +The popular file extension for Markdown files is .md. If you're on a platform that doesn't know what a .md file is, you can associate the extension to Atom manually or else just use the universal .txt extension. The file extension doesn't change the nature of the file; it just changes how your computer decides what to do with it. Atom and some platforms are smart enough to know that a file is plaintext no matter what extension you give it. + +#### Live preview + +Atom features the **Markdown Preview** plugin, which shows you both the plain Markdown you're writing and the way it will (commonly) render. + +![Atom's preview screen][9] + +To activate this preview pane, select **Packages > Markdown Preview > Toggle Preview** or press **Ctrl+Shift+M**. + +This view provides you with the best of both worlds. You get to write without the burden of styling your text, but you also get to see a common example of what your text will look like, at least in a typical digital format. Of course, the point is that you can't control how your text is ultimately rendered, so don't be tempted to adjust your Markdown to force your render preview to look a certain way. + +#### One sentence per line + +Your high school writing teacher doesn't ever have to see your Markdown. + +It won't come naturally at first, but maintaining one sentence per line makes more sense in the digital world. Markdown ignores single line breaks (when you've pressed the Return or Enter key) and only creates a new paragraph after a single blank line. + +![Writing in Atom][10] + +The advantage of writing one sentence per line is that your work is easier to track. That is, if you've changed one word at the start of a paragraph, then it's easy for Atom, Git, or any application to highlight that change in a meaningful way if the change is limited to one line rather than one word in a long paragraph. In other words, a change to one sentence should only affect that sentence, not the whole paragraph. + +You might be thinking, "many word processors track changes, too, and they can highlight a single word that's changed." But those revision trackers are bound to the interface of that word processor, which means you can't look through revisions without being in front of that word processor. In a plaintext workflow, you can review revisions in plaintext, which means you can make or approve edits no matter what you have on hand, as long as that device can deal with plaintext (and most of them can). + +Writers admittedly don't usually think in terms of line numbers, but it's a useful tool for computers, and ultimately a great reference point in general. Atom numbers the lines of your text document by default. A _line_ is only a line once you have pressed the Enter or Return key. + +![Writing in Atom][11] + +If a line has a dot instead of a number, that means it's part of the previous line wrapped for you because it couldn't fit on your screen. + +#### Theme it + +If you're a visual person, you might be very particular about the way your writing environment looks. Even if you are writing in plain Markdown, it doesn't mean you have to write in a programmer's font or in a dark window that makes you look like a coder. The simplest way to modify what Atom looks like is to use [theme packages][12]. It's conventional for theme designers to differentiate dark themes from light themes, so you can search with the keyword Dark or Light, depending on what you want. + +To install a theme, select **Edit > Preferences**. This opens a new tab in the Atom interface. Yes, tabs are used for your working documents _and_ for configuration and control panels. In the **Settings** tab, click on the **Install** category. + +In the **Install** panel, search for the name of the theme you want to install. Click the **Themes** button on the right of the search field to search only for themes. Once you've found your theme, click its **Install** button. + +![Atom's themes][13] + +To use a theme you've installed or to customize a theme to your preference, navigate to the **Themes** category in your **Settings** tab. Pick the theme you want to use from the drop-down menu. The changes take place immediately, so you can see exactly how the theme affects your environment. + +You can also change your working font in the **Editor** category of the **Settings** tab. Atom defaults to monospace fonts, which are generally preferred by programmers. But you can use any font on your system, whether it's serif or sans or gothic or cursive. Whatever you want to spend your day staring at, it's entirely up to you. + +On a related note, by default Atom draws a vertical marker down its screen as a guide for people writing code. Programmers often don't want to write long lines of code, so this vertical line is a reminder to them to simplify things. The vertical line is meaningless to writers, though, and you can remove it by disabling the **wrap-guide** package. + +To disable the **wrap-guide** package, select the **Packages** category in the **Settings** tab and search for **wrap-guide**. When you've found the package, click its **Disable** button. + +#### Dynamic structure + +When creating a long document, I find that writing one chapter per file makes more sense than writing an entire book in a single file. Furthermore, I don't name my chapters in the obvious syntax **chapter-1.md** or **1.example.md** , but by chapter titles or keywords, such as **example.md**. To provide myself guidance in the future about how the book is meant to be assembled, I maintain a file called **toc.md** (for "Table of Contents") where I list the (current) order of my chapters. + +I do this because, no matter how convinced I am that chapter 6 just couldn't possibly happen before chapter 1, there's rarely a time that I don't swap the order of one or two chapters or sections before I'm finished with a book. I find that keeping it dynamic from the start helps me avoid renaming confusion, and it also helps me treat the material less rigidly. + +### Git in Atom + +Two things every writer has in common is that they're writing for keeps and their writing is a journey. You don't sit down to write and finish with a final draft; by definition, you have a first draft. And that draft goes through revisions, each of which you carefully save in duplicate and triplicate just in case one of your files turns up corrupted. Eventually, you get to what you call a final draft, but more than likely you'll be going back to it one day, either to resurrect the good parts or to fix the bad. + +The most exciting feature in Atom is its strong Git integration. Without ever leaving Atom, you can interact with all of the major features of Git, tracking and updating your project, rolling back changes you don't like, integrating changes from a collaborator, and more. The best way to learn it is to step through it, so here's how to use Git within the Atom interface from the beginning to the end of a writing project. + +First thing first: Reveal the Git panel by selecting **View > Toggle Git Tab**. This causes a new tab to open on the right side of Atom's interface. There's not much to see yet, so just keep it open for now. + +#### Starting a Git project + +You can think of Git as being bound to a folder. Any folder outside a Git directory doesn't know about Git, and Git doesn't know about it. Folders and files within a Git directory are ignored until you grant Git permission to keep track of them. + +You can create a Git project by creating a new project folder in Atom. Select **File > Add Project Folder** and create a new folder on your system. The folder you create appears in the left **Project Panel** of your Atom window. + +#### Git add + +Right-click on your new project folder and select **New File** to create a new file in your project folder. If you have files you want to import into your new project, right-click on the folder and select **Show in File Manager** to open the folder in your system's file viewer (Dolphin or Nautilus on Linux, Finder on Mac, Explorer on Windows), and then drag-and-drop your files. + +With a project file (either the empty one you created or one you've imported) open in Atom, click the **Create Repository** button in the **Git** tab. In the pop-up dialog box, click **Init** to initialize your project directory as a local Git repository. Git adds a **.git** directory (invisible in your system's file manager, but visible to you in Atom) to your project folder. Don't be fooled by this: The **.git** directory is for Git to manage, not you, so you'll generally stay out of it. But seeing it in Atom is a good reminder that you're working in a project actively managed by Git; in other words, revision history is available when you see a **.git** directory. + +In your empty file, write some stuff. You're a writer, so type some words. It can be any set of words you please, but remember the writing tips above. + +Press **Ctrl+S** to save your file and it will appear in the **Unstaged Changes** section of the **Git** tab. That means the file exists in your project folder but has not yet been committed over to Git's purview. Allow Git to keep track of your file by clicking on the **Stage All** button in the top-right of the **Git** tab. If you've used a word processor with revision history, you can think of this step as permitting Git to record changes. + +#### Git commit + +Your file is now staged. All that means is Git is aware that the file exists and is aware that it has been changed since the last time Git was made aware of it. + +A Git commit sends your file into Git's internal and eternal archives. If you're used to word processors, this is similar to naming a revision. To create a commit, enter some descriptive text in the **Commit** message box at the bottom of the **Git** tab. You can be vague or cheeky, but it's more useful if you enter useful information for your future self so that you know why the revision was made. + +The first time you make a commit, you must create a branch. Git branches are a little like alternate realities, allowing you to switch from one timeline to another to make changes that you may or may not want to keep forever. If you end up liking the changes, you can merge one experimental branch into another, thereby unifying different versions of your project. It's an advanced process that's not worth learning upfront, but you still need an active branch, so you have to create one for your first commit. + +Click on the **Branch** icon at the very bottom of the **Git** tab to create a new branch. + +![Creating a branch][14] + +It's customary to name your first branch **master**. You don't have to; you can name it **firstdraft** or whatever you like, but adhering to the local customs can sometimes make talking about Git (and looking up answers to questions) a little easier because you'll know that when someone mentions **master** , they really mean **master** and not **firstdraft** or whatever you called your branch. + +On some versions of Atom, the UI may not update to reflect that you've created a new branch. Don't worry; the branch will be created (and the UI updated) once you make your commit. Press the **Commit** button, whether it reads **Create detached commit** or **Commit to master**. + +Once you've made a commit, the state of your file is preserved forever in Git's memory. + +#### History and Git diff + +A natural question is how often you should make a commit. There's no one right answer to that. Saving a file with **Ctrl+S** and committing to Git are two separate processes, so you will continue to do both. You'll probably want to make commits whenever you feel like you've done something significant or are about to try out a crazy new idea that you may want to back out of. + +To get a feel for what impact a commit has on your workflow, remove some text from your test document and add some text to the top and bottom. Make another commit. Do this a few times until you have a small history at the bottom of your **Git** tab, then click on a commit to view it in Atom. + +![Viewing differences][15] + +When viewing a past commit, you see three elements: + + 1. Text in green was added to a document when the commit was made. + 2. Text in red was removed from the document when the commit was made. + 3. All other text was untouched. + + + +#### Remote backup + +One of the advantages of using Git is that, by design, it is distributed, meaning you can commit your work to your local repository and push your changes out to any number of servers for backup. You can also pull changes in from those servers so that whatever device you happen to be working on always has the latest changes. + +For this to work, you must have an account on a Git server. There are several free hosting services out there, including GitHub, the company that produces Atom but oddly is not open source, and GitLab, which is open source. Preferring open source to proprietary, I'll use GitLab in this example. + +If you don't already have a GitLab account, sign up for one and start a new project. The project name doesn't have to match your project folder in Atom, but it probably makes sense if it does. You can leave your project private, in which case only you and anyone you give explicit permissions to can access it, or you can make it public if you want it to be available to anyone on the internet who stumbles upon it. + +Do not add a README to the project. + +Once the project is created, it provides you with instructions on how to set up the repository. This is great information if you decide to use Git in a terminal or with a separate GUI, but Atom's workflow is different. + +Click the **Clone** button in the top-right of the GitLab interface. This reveals the address you must use to access the Git repository. Copy the **SSH** address (not the **https** address). + +In Atom, click on your project's **.git** directory and open the **config**. Add these configuration lines to the file, adjusting the **seth/example.git** part of the **url** value to match your unique address. + +* * * + + +``` +[remote "origin"] +url = [git@gitlab.com][16]:seth/example.git +fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] +remote = origin +merge = refs/heads/master +``` + +At the bottom of the **Git** tab, a new button has appeared, labeled **Fetch**. Since your server is brand new and therefore has no data for you to fetch, right-click on the button and select **Push**. This pushes your changes to your Gitlab account, and now your project is backed up on a Git server. + +Pushing changes to a server is something you can do after each commit. It provides immediate offsite backup and, since the amount of data is usually minimal, it's practically as fast as a local save. + +### Writing and Git + +Git is a complex system, useful for more than just revision tracking and backups. It enables asynchronous collaboration and encourages experimentation. This article has covered the basics, but there are many more articles—and entire books—on Git and how to use it to make your work more efficient, more resilient, and more dynamic. It all starts with using Git for small tasks. The more you use it, the more questions you'll find yourself asking, and eventually the more tricks you'll learn. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/write-git + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sethhttps://opensource.com/users/noreplyhttps://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/write-hand_0.jpg?itok=Uw5RJD03 (Writing Hand) +[2]: https://git-scm.com/ +[3]: https://support.mozilla.org/en-US/kb/firefox-reader-view-clutter-free-web-pages +[4]: http://atom.io +[5]: https://git-scm.com/download/mac +[6]: https://git-scm.com/download/win +[7]: http://gnu.org/software/emacs +[8]: https://commonmark.org/help/ +[9]: https://opensource.com/sites/default/files/uploads/atom-preview.jpg (Atom's preview screen) +[10]: https://opensource.com/sites/default/files/uploads/atom-para.jpg (Writing in Atom) +[11]: https://opensource.com/sites/default/files/uploads/atom-linebreak.jpg (Writing in Atom) +[12]: https://atom.io/themes +[13]: https://opensource.com/sites/default/files/uploads/atom-theme.jpg (Atom's themes) +[14]: https://opensource.com/sites/default/files/uploads/atom-branch.jpg (Creating a branch) +[15]: https://opensource.com/sites/default/files/uploads/git-diff.jpg (Viewing differences) +[16]: mailto:git@gitlab.com diff --git a/sources/tech/20190404 Running LEDs in reverse could cool computers.md b/sources/tech/20190404 Running LEDs in reverse could cool computers.md deleted file mode 100644 index 2eb3c66c6b..0000000000 --- a/sources/tech/20190404 Running LEDs in reverse could cool computers.md +++ /dev/null @@ -1,68 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Running LEDs in reverse could cool computers) -[#]: via: (https://www.networkworld.com/article/3386876/running-leds-in-reverse-could-cool-computers.html#tk.rss_all) -[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) - -Running LEDs in reverse could cool computers -====== - -### The miniaturization of electronics is reaching its limits in part because of heat management. Many are now aggressively trying to solve the problem. A kind of reverse-running LED is one avenue being explored. - -![monsitj / Getty Images][1] - -The quest to find more efficient methods for cooling computers is almost as high on scientists’ agendas as the desire to discover better battery chemistries. - -More cooling is crucial for reducing costs. It would also allow for more powerful processing to take place in smaller spaces, where limited processing should be crunching numbers instead of making wasteful heat. It would stop heat-caused breakdowns, thereby creating longevity in components, and it would promote eco-friendly data centers — less heat means less impact on the environment. - -Removing heat from microprocessors is one angle scientists have been exploring, and they think they have come up with a simple, but unusual and counter-intuitive solution. They say that running a variant of a Light Emitting Diode (LED) with its electrodes reversed forces the component to act as if it were at an unusually low temperature. Placing it next to warmer electronics, then, with a nanoscale gap introduced, causes the LED to suck out the heat. - -**[ Read also:[IDC’s top 10 data center predictions][2] | Get regularly scheduled insights: [Sign up for Network World newsletters][3] ]** - -“Once the LED is reverse biased, it began acting as a very low temperature object, absorbing photons,” says Edgar Meyhofer, professor of mechanical engineering at University of Michigan, in a [press release][4] announcing the breakthrough. “At the same time, the gap prevents heat from traveling back, resulting in a cooling effect.” - -The researchers say the LED and the adjacent electrical device (in this case a calorimeter, usually used for measuring heat energy) have to be extremely close. They say they’ve been able to demonstrate cooling of six watts per meter-squared. That’s about the power of sunshine on the earth’s surface, they explain. - -Internet of things (IoT) devices and smartphones could be among those electronics that would ultimately benefit from the LED modification. Both kinds of devices require increasing computing power to be squashed into smaller spaces. - -“Removing the heat from the microprocessor is beginning to limit how much power can be squeezed into a given space,” the University of Michigan announcement says. - -### Materials Science and cooling computers - -[I’ve written before about new forms of computer cooling][5]. Exotic materials, derived from Materials Science, are among ideas being explored. Sodium bismuthide (Na3Bi) could be used in transistor design, the U.S. Department of Energy’s Lawrence Berkeley National Laboratory says. The new substance carries a charge and is importantly tunable; however, it doesn’t need to be chilled as superconductors currently do. - -In fact, that’s a problem with superconductors. They unfortunately need more cooling than most electronics — electrical resistance with the technology is expelled through extreme cooling. - -Separately, [researchers in Germany at the University of Konstanz][6] say they soon will have superconductor-driven computers without waste heat. They plan to use electron spin — a new physical dimension in electrons that could create efficiency gains. The method “significantly reduces the energy consumption of computing centers,” the university said in a press release last year. - -Another way to reduce heat could be [to replace traditional heatsinks with spirals and mazes][7] embedded on microprocessors. Miniscule channels printed on the chip itself could provide paths for coolant to travel, again separately, scientists from Binghamton University say. - -“The miniaturization of the semiconductor technology is approaching its physical limits,” the University of Konstanz says. Heat management is very much on scientists’ agenda now. It’s “one of the big challenges in miniaturization." - -Join the Network World communities on [Facebook][8] and [LinkedIn][9] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3386876/running-leds-in-reverse-could-cool-computers.html#tk.rss_all - -作者:[Patrick Nelson][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Patrick-Nelson/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2019/02/big_data_center_server_racks_storage_binary_analytics_by_monsitj_gettyimages-944444446_3x2-100787357-large.jpg -[2]: https://www.networkworld.com/article/3242807/data-center/top-10-data-center-predictions-idc.html#nww-fsb -[3]: https://www.networkworld.com/newsletters/signup.html#nww-fsb -[4]: https://news.umich.edu/running-an-led-in-reverse-could-cool-future-computers/ -[5]: https://www.networkworld.com/article/3326831/computers-could-soon-run-cold-no-heat-generated.html -[6]: https://www.uni-konstanz.de/en/university/news-and-media/current-announcements/news/news-in-detail/Supercomputer-ohne-Abwaerme/ -[7]: https://www.networkworld.com/article/3322956/chip-cooling-breakthrough-will-reduce-data-center-power-costs.html -[8]: https://www.facebook.com/NetworkWorld/ -[9]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20190408 A beginner-s guide to building DevOps pipelines with open source tools.md b/sources/tech/20190408 A beginner-s guide to building DevOps pipelines with open source tools.md deleted file mode 100644 index 2110c17606..0000000000 --- a/sources/tech/20190408 A beginner-s guide to building DevOps pipelines with open source tools.md +++ /dev/null @@ -1,352 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (A beginner's guide to building DevOps pipelines with open source tools) -[#]: via: (https://opensource.com/article/19/4/devops-pipeline) -[#]: author: (Bryant Son https://opensource.com/users/brson/users/milindsingh/users/milindsingh/users/dscripter) - -A beginner's guide to building DevOps pipelines with open source tools -====== -If you're new to DevOps, check out this five-step process for building -your first pipeline. -![Shaking hands, networking][1] - -DevOps has become the default answer to fixing software development processes that are slow, siloed, or otherwise dysfunctional. But that doesn't mean very much when you're new to DevOps and aren't sure where to begin. This article explores what a DevOps pipeline is and offers a five-step process to create one. While this tutorial is not comprehensive, it should give you a foundation to start on and expand later. But first, a story. - -### My DevOps journey - -I used to work for the cloud team at Citi Group, developing an Infrastructure-as-a-Service (IaaS) web application to manage Citi's cloud infrastructure, but I was always interested in figuring out ways to make the development pipeline more efficient and bring positive cultural change to the development team. I found my answer in a book recommended by Greg Lavender, who was the CTO of Citi's cloud architecture and infrastructure engineering, called _[The Phoenix Project][2]_. The book reads like a novel while it explains DevOps principles. - -A table at the back of the book shows how often different companies deploy to the release environment: - -Company | Deployment Frequency ----|--- -Amazon | 23,000 per day -Google | 5,500 per day -Netflix | 500 per day -Facebook | 1 per day -Twitter | 3 per week -Typical enterprise | 1 every 9 months - -How are the frequency rates of Amazon, Google, and Netflix even possible? It's because these companies have figured out how to make a nearly perfect DevOps pipeline. - -This definitely wasn't the case before we implemented DevOps at Citi. Back then, my team had different staged environments, but deployments to the development server were very manual. All developers had access to just one development server based on IBM WebSphere Application Server Community Edition. The problem was the server went down whenever multiple users simultaneously tried to make deployments, so the developers had to let each other know whenever they were about to make a deployment, which was quite a pain. In addition, there were problems with low code test coverages, cumbersome manual deployment processes, and no way to track code deployments with a defined task or a user story. - -I realized something had to be done, and I found a colleague who felt the same way. We decided to collaborate to build an initial DevOps pipeline—he set up a virtual machine and a Tomcat application server while I worked on Jenkins, integrating with Atlassian Jira and BitBucket, and code testing coverages. This side project was hugely successful: we almost fully automated the development pipeline, we achieved nearly 100% uptime on our development server, we could track and improve code testing coverage, and the Git branch could be associated with the deployment and Jira task. And most of the tools we used to construct our DevOps pipeline were open source. - -I now realize how rudimentary our DevOps pipeline was, as we didn't take advantage of advanced configurations like Jenkins files or Ansible. However, this simple process worked well, maybe due to the [Pareto][3] principle (also known as the 80/20 rule). - -### A brief introduction to DevOps and the CI/CD pipeline - -If you ask several people, "What is DevOps? you'll probably get several different answers. DevOps, like agile, has evolved to encompass many different disciplines, but most people will agree on a few things: DevOps is a software development practice or a software development lifecycle (SDLC) and its central tenet is cultural change, where developers and non-developers all breathe in an environment where formerly manual things are automated; everyone does what they are best at; the number of deployments per period increases; throughput increases; and flexibility improves. - -While having the right software tools is not the only thing you need to achieve a DevOps environment, some tools are necessary. A key one is continuous integration and continuous deployment (CI/CD). This pipeline is where the environments have different stages (e.g., DEV, INT, TST, QA, UAT, STG, PROD), manual things are automated, and developers can achieve high-quality code, flexibility, and numerous deployments. - -This article describes a five-step approach to creating a DevOps pipeline, like the one in the following diagram, using open source tools. - -![Complete DevOps pipeline][4] - -Without further ado, let's get started. - -### Step 1: CI/CD framework - -The first thing you need is a CI/CD tool. Jenkins, an open source, Java-based CI/CD tool based on the MIT License, is the tool that popularized the DevOps movement and has become the de facto standard. - -So, what is Jenkins? Imagine it as some sort of a magical universal remote control that can talk to many many different services and tools and orchestrate them. On its own, a CI/CD tool like Jenkins is useless, but it becomes more powerful as it plugs into different tools and services. - -Jenkins is just one of many open source CI/CD tools that you can leverage to build a DevOps pipeline. - -Name | License ----|--- -[Jenkins][5] | Creative Commons and MIT -[Travis CI][6] | MIT -[CruiseControl][7] | BSD -[Buildbot][8] | GPL -[Apache Gump][9] | Apache 2.0 -[Cabie][10] | GNU - -Here's what a DevOps process looks like with a CI/CD tool. - -![CI/CD tool][11] - -You have a CI/CD tool running in your localhost, but there is not much you can do at the moment. Let's follow the next step of DevOps journey. - -### Step 2: Source control management - -The best (and probably the easiest) way to verify that your CI/CD tool can perform some magic is by integrating with a source control management (SCM) tool. Why do you need source control? Suppose you are developing an application. Whenever you build an application, you are programming—whether you are using Java, Python, C++, Go, Ruby, JavaScript, or any of the gazillion programming languages out there. The programming codes you write are called source codes. In the beginning, especially when you are working alone, it's probably OK to put everything in your local directory. But when the project gets bigger and you invite others to collaborate, you need a way to avoid merge conflicts while effectively sharing the code modifications. You also need a way to recover a previous version—and the process of making a backup and copying-and-pasting gets old. You (and your teammates) want something better. - -This is where SCM becomes almost a necessity. A SCM tool helps by storing your code in repositories, versioning your code, and coordinating among project members. - -Although there are many SCM tools out there, Git is the standard and rightly so. I highly recommend using Git, but there are other open source options if you prefer. - -Name | License ----|--- -[Git][12] | GPLv2 & LGPL v2.1 -[Subversion][13] | Apache 2.0 -[Concurrent Versions System][14] (CVS) | GNU -[Vesta][15] | LGPL -[Mercurial][16] | GNU GPL v2+ - -Here's what the DevOps pipeline looks like with the addition of SCM. - -![Source control management][17] - -The CI/CD tool can automate the tasks of checking in and checking out source code and collaborating across members. Not bad? But how can you make this into a working application so billions of people can use and appreciate it? - -### Step 3: Build automation tool - -Excellent! You can check out the code and commit your changes to the source control, and you can invite your friends to collaborate on the source control development. But you haven't yet built an application. To make it a web application, it has to be compiled and put into a deployable package format or run as an executable. (Note that an interpreted programming language like JavaScript or PHP doesn't need to be compiled.) - -Enter the build automation tool. No matter which build tool you decide to use, all build automation tools have a shared goal: to build the source code into some desired format and to automate the task of cleaning, compiling, testing, and deploying to a certain location. The build tools will differ depending on your programming language, but here are some common open source options to consider. - -Name | License | Programming Language ----|---|--- -[Maven][18] | Apache 2.0 | Java -[Ant][19] | Apache 2.0 | Java -[Gradle][20] | Apache 2.0 | Java -[Bazel][21] | Apache 2.0 | Java -[Make][22] | GNU | N/A -[Grunt][23] | MIT | JavaScript -[Gulp][24] | MIT | JavaScript -[Buildr][25] | Apache | Ruby -[Rake][26] | MIT | Ruby -[A-A-P][27] | GNU | Python -[SCons][28] | MIT | Python -[BitBake][29] | GPLv2 | Python -[Cake][30] | MIT | C# -[ASDF][31] | Expat (MIT) | LISP -[Cabal][32] | BSD | Haskell - -Awesome! You can put your build automation tool configuration files into your source control management and let your CI/CD tool build it. - -![Build automation tool][33] - -Everything is good, right? But where can you deploy it? - -### Step 4: Web application server - -So far, you have a packaged file that might be executable or deployable. For any application to be truly useful, it has to provide some kind of a service or an interface, but you need a vessel to host your application. - -For a web application, a web application server is that vessel. An application server offers an environment where the programming logic inside the deployable package can be detected, render the interface, and offer the web services by opening sockets to the outside world. You need an HTTP server as well as some other environment (like a virtual machine) to install your application server. For now, let's assume you will learn about this along the way (although I will discuss containers below). - -There are a number of open source web application servers available. - -Name | License | Programming Language ----|---|--- -[Tomcat][34] | Apache 2.0 | Java -[Jetty][35] | Apache 2.0 | Java -[WildFly][36] | GNU Lesser Public | Java -[GlassFish][37] | CDDL & GNU Less Public | Java -[Django][38] | 3-Clause BSD | Python -[Tornado][39] | Apache 2.0 | Python -[Gunicorn][40] | MIT | Python -[Python Paste][41] | MIT | Python -[Rails][42] | MIT | Ruby -[Node.js][43] | MIT | Javascript - -Now the DevOps pipeline is almost usable. Good job! - -![Web application server][44] - -Although it's possible to stop here and integrate further on your own, code quality is an important thing for an application developer to be concerned about. - -### Step 5: Code testing coverage - -Implementing code test pieces can be another cumbersome requirement, but developers need to catch any errors in an application early on and improve the code quality to ensure end users are satisfied. Luckily, there are many open source tools available to test your code and suggest ways to improve its quality. Even better, most CI/CD tools can plug into these tools and automate the process. - -There are two parts to code testing: _code testing frameworks_ that help write and run the tests, and _code quality suggestion tools_ that help improve code quality. - -#### Code test frameworks - -Name | License | Programming Language ----|---|--- -[JUnit][45] | Eclipse Public License | Java -[EasyMock][46] | Apache | Java -[Mockito][47] | MIT | Java -[PowerMock][48] | Apache 2.0 | Java -[Pytest][49] | MIT | Python -[Hypothesis][50] | Mozilla | Python -[Tox][51] | MIT | Python - -#### Code quality suggestion tools - -Name | License | Programming Language ----|---|--- -[Cobertura][52] | GNU | Java -[CodeCover][53] | Eclipse Public (EPL) | Java -[Coverage.py][54] | Apache 2.0 | Python -[Emma][55] | Common Public License | Java -[JaCoCo][56] | Eclipse Public License | Java -[Hypothesis][50] | Mozilla | Python -[Tox][51] | MIT | Python -[Jasmine][57] | MIT | JavaScript -[Karma][58] | MIT | JavaScript -[Mocha][59] | MIT | JavaScript -[Jest][60] | MIT | JavaScript - -Note that most of the tools and frameworks mentioned above are written for Java, Python, and JavaScript, since C++ and C# are proprietary programming languages (although GCC is open source). - -Now that you've implemented code testing coverage tools, your DevOps pipeline should resemble the DevOps pipeline diagram shown at the beginning of this tutorial. - -### Optional steps - -#### Containers - -As I mentioned above, you can host your application server on a virtual machine or a server, but containers are a popular solution. - -[What are][61] [containers][61]? The short explanation is that a VM needs the huge footprint of an operating system, which overwhelms the application size, while a container just needs a few libraries and configurations to run the application. There are clearly still important uses for a VM, but a container is a lightweight solution for hosting an application, including an application server. - -Although there are other options for containers, Docker and Kubernetes are the most popular. - -Name | License ----|--- -[Docker][62] | Apache 2.0 -[Kubernetes][63] | Apache 2.0 - -To learn more, check out these other [Opensource.com][64] articles about Docker and Kubernetes: - - * [What Is Docker?][65] - * [An introduction to Docker][66] - * [What is Kubernetes?][67] - * [From 0 to Kubernetes][68] - - - -#### Middleware automation tools - -Our DevOps pipeline mostly focused on collaboratively building and deploying an application, but there are many other things you can do with DevOps tools. One of them is leveraging Infrastructure as Code (IaC) tools, which are also known as middleware automation tools. These tools help automate the installation, management, and other tasks for middleware software. For example, an automation tool can pull applications, like a web application server, database, and monitoring tool, with the right configurations and deploy them to the application server. - -Here are several open source middleware automation tools to consider: - -Name | License ----|--- -[Ansible][69] | GNU Public -[SaltStack][70] | Apache 2.0 -[Chef][71] | Apache 2.0 -[Puppet][72] | Apache or GPL - -For more on middleware automation tools, check out these other [Opensource.com][64] articles: - - * [A quickstart guide to Ansible][73] - * [Automating deployment strategies with Ansible][74] - * [Top 5 configuration management tools][75] - - - -### Where can you go from here? - -This is just the tip of the iceberg for what a complete DevOps pipeline can look like. Start with a CI/CD tool and explore what else you can automate to make your team's job easier. Also, look into [open source communication tools][76] that can help your team work better together. - -For more insight, here are some very good introductory articles about DevOps: - - * [What is DevOps][77] - * [5 things to master to be a DevOps engineer][78] - * [DevOps is for everyone][79] - * [Getting started with predictive analytics in DevOps][80] - - - -Integrating DevOps with open source agile tools is also a good idea: - - * [What is agile?][81] - * [4 steps to becoming an awesome agile developer][82] - - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/4/devops-pipeline - -作者:[Bryant Son (Red Hat, Community Moderator)][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/brson/users/milindsingh/users/milindsingh/users/dscripter -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/network_team_career_hand.png?itok=_ztl2lk_ (Shaking hands, networking) -[2]: https://www.amazon.com/dp/B078Y98RG8/ -[3]: https://en.wikipedia.org/wiki/Pareto_principle -[4]: https://opensource.com/sites/default/files/uploads/1_finaldevopspipeline.jpg (Complete DevOps pipeline) -[5]: https://github.com/jenkinsci/jenkins -[6]: https://github.com/travis-ci/travis-ci -[7]: http://cruisecontrol.sourceforge.net -[8]: https://github.com/buildbot/buildbot -[9]: https://gump.apache.org -[10]: http://cabie.tigris.org -[11]: https://opensource.com/sites/default/files/uploads/2_runningjenkins.jpg (CI/CD tool) -[12]: https://git-scm.com -[13]: https://subversion.apache.org -[14]: http://savannah.nongnu.org/projects/cvs -[15]: http://www.vestasys.org -[16]: https://www.mercurial-scm.org -[17]: https://opensource.com/sites/default/files/uploads/3_sourcecontrolmanagement.jpg (Source control management) -[18]: https://maven.apache.org -[19]: https://ant.apache.org -[20]: https://gradle.org/ -[21]: https://bazel.build -[22]: https://www.gnu.org/software/make -[23]: https://gruntjs.com -[24]: https://gulpjs.com -[25]: http://buildr.apache.org -[26]: https://github.com/ruby/rake -[27]: http://www.a-a-p.org -[28]: https://www.scons.org -[29]: https://www.yoctoproject.org/software-item/bitbake -[30]: https://github.com/cake-build/cake -[31]: https://common-lisp.net/project/asdf -[32]: https://www.haskell.org/cabal -[33]: https://opensource.com/sites/default/files/uploads/4_buildtools.jpg (Build automation tool) -[34]: https://tomcat.apache.org -[35]: https://www.eclipse.org/jetty/ -[36]: http://wildfly.org -[37]: https://javaee.github.io/glassfish -[38]: https://www.djangoproject.com/ -[39]: http://www.tornadoweb.org/en/stable -[40]: https://gunicorn.org -[41]: https://github.com/cdent/paste -[42]: https://rubyonrails.org -[43]: https://nodejs.org/en -[44]: https://opensource.com/sites/default/files/uploads/5_applicationserver.jpg (Web application server) -[45]: https://junit.org/junit5 -[46]: http://easymock.org -[47]: https://site.mockito.org -[48]: https://github.com/powermock/powermock -[49]: https://docs.pytest.org -[50]: https://hypothesis.works -[51]: https://github.com/tox-dev/tox -[52]: http://cobertura.github.io/cobertura -[53]: http://codecover.org/ -[54]: https://github.com/nedbat/coveragepy -[55]: http://emma.sourceforge.net -[56]: https://github.com/jacoco/jacoco -[57]: https://jasmine.github.io -[58]: https://github.com/karma-runner/karma -[59]: https://github.com/mochajs/mocha -[60]: https://jestjs.io -[61]: /resources/what-are-linux-containers -[62]: https://www.docker.com -[63]: https://kubernetes.io -[64]: http://Opensource.com -[65]: https://opensource.com/resources/what-docker -[66]: https://opensource.com/business/15/1/introduction-docker -[67]: https://opensource.com/resources/what-is-kubernetes -[68]: https://opensource.com/article/17/11/kubernetes-lightning-talk -[69]: https://www.ansible.com -[70]: https://www.saltstack.com -[71]: https://www.chef.io -[72]: https://puppet.com -[73]: https://opensource.com/article/19/2/quickstart-guide-ansible -[74]: https://opensource.com/article/19/1/automating-deployment-strategies-ansible -[75]: https://opensource.com/article/18/12/configuration-management-tools -[76]: https://opensource.com/alternatives/slack -[77]: https://opensource.com/resources/devops -[78]: https://opensource.com/article/19/2/master-devops-engineer -[79]: https://opensource.com/article/18/11/how-non-engineer-got-devops -[80]: https://opensource.com/article/19/1/getting-started-predictive-analytics-devops -[81]: https://opensource.com/article/18/10/what-agile -[82]: https://opensource.com/article/19/2/steps-agile-developer diff --git a/sources/tech/20190409 5 Linux rookie mistakes.md b/sources/tech/20190409 5 Linux rookie mistakes.md deleted file mode 100644 index 2e2c25a9cf..0000000000 --- a/sources/tech/20190409 5 Linux rookie mistakes.md +++ /dev/null @@ -1,54 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (5 Linux rookie mistakes) -[#]: via: (https://opensource.com/article/19/4/linux-rookie-mistakes) -[#]: author: (Jen Wike Huger https://opensource.com/users/jen-wike/users/bcotton/users/petercheer/users/greg-p/users/greg-p) - -5 Linux rookie mistakes -====== -Linux enthusiasts share some of the biggest mistakes they made. -![magnifying glass on computer screen, finding a bug in the code][1] - -It's smart to learn new skills throughout your life—it keeps your mind nimble and makes you more competitive in the job market. But some skills are harder to learn than others, especially those where small rookie mistakes can cost you a lot of time and trouble when you're trying to fix them. - -Take learning [Linux][2], for example. If you're used to working in a Windows or MacOS graphical interface, moving to Linux, with its unfamiliar commands typed into a terminal, can have a big learning curve. But the rewards are worth it, as the millions and millions of people who have gone before you have proven. - -That said, the journey won't be without pitfalls. We asked some of Linux enthusiasts to think back to when they first started using Linux and tell us about the biggest mistakes they made. - -"Don't go into [any sort of command line interface (CLI) work] with an expectation that commands work in rational or consistent ways, as that is likely to lead to frustration. This is not due to poor design choices—though it can feel like it when you're banging your head against the proverbial desk—but instead reflects the fact that these systems have evolved and been added onto through generations of software and OS evolution. Go with the flow, write down or memorize the commands you need, and (try not to) get frustrated when [things aren't what you'd expect][3]." _—[Gina Likins][4]_ - -"As easy as it might be to just copy and paste commands to make the thing go, read the command first and at least have a general understanding of the actions that are about to be performed. Especially if there is a pipe command. Double especially if there is more than one. There are a lot of destructive commands that look innocuous until you realize what they can do (e.g., **rm** , **dd** ), and you don't want to accidentally destroy things. (Ask me how I know.)" _—[Katie McLaughlin][5]_ - -"Early on in my Linux journey, I wasn't as aware of the importance of knowing where you are in the filesystem. I was deleting some file in what I thought was my home directory, and I entered **sudo rm -rf *** and deleted all of the boot files on my system. Now, I frequently use **pwd** to ensure that I am where I think I am before issuing such commands. Fortunately for me, I was able to boot my wounded laptop with a USB drive and recover my files." _—[Don Watkins][6]_ - -"Do not reset permissions on the entire file system to [777][7] because you think 'permissions are hard to understand' and you want an application to have access to something." _—[Matthew Helmke][8]_ - -"I was removing a package from my system, and I did not check what other packages it was dependent upon. I just let it remove whatever it wanted and ended up causing some of my important programs to crash and become unavailable." _—[Kedar Vijay Kulkarni][9]_ - -What mistakes have you made while learning to use Linux? Share them in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/4/linux-rookie-mistakes - -作者:[Jen Wike Huger (Red Hat)][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/jen-wike/users/bcotton/users/petercheer/users/greg-p/users/greg-p -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mistake_bug_fix_find_error.png?itok=PZaz3dga (magnifying glass on computer screen, finding a bug in the code) -[2]: https://opensource.com/resources/linux -[3]: https://lintqueen.com/2017/07/02/learning-while-frustrated/ -[4]: https://opensource.com/users/lintqueen -[5]: https://opensource.com/users/glasnt -[6]: https://opensource.com/users/don-watkins -[7]: https://www.maketecheasier.com/file-permissions-what-does-chmod-777-means/ -[8]: https://twitter.com/matthewhelmke -[9]: https://opensource.com/users/kkulkarn diff --git a/sources/tech/20190409 5 open source mobile apps.md b/sources/tech/20190409 5 open source mobile apps.md deleted file mode 100644 index 679c1a92fc..0000000000 --- a/sources/tech/20190409 5 open source mobile apps.md +++ /dev/null @@ -1,131 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (fuzheng1998 ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (5 open source mobile apps) -[#]: via: (https://opensource.com/article/19/4/mobile-apps) -[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen/users/bcotton/users/clhermansen/users/bcotton/users/clhermansen) - -5 open source mobile apps -====== -You can count on these apps to meet your needs for productivity, -communication, and entertainment. -![][1] - -Like most people in the world, I'm rarely further than an arm's reach from my smartphone. My Android device provides a seemingly limitless number of communication, productivity, and entertainment services thanks to the open source mobile apps I've installed from Google Play and F-Droid. - -​​​​​​Of the many open source apps on my phone, the following five are the ones I consistently turn to whether I want to listen to music; connect with friends, family, and colleagues; or get work done on the go. - -### MPDroid - -_An Android controller for the Music Player Daemon (MPD)_ - -![MPDroid][2] - -MPD is a great way to get music from little music server computers out to the big black stereo boxes. It talks straight to ALSA and therefore to the Digital-to-Analog Converter ([DAC][3]) via the ALSA hardware interface, and it can be controlled over my network—but by what? Well, it turns out that MPDroid is a great MPD controller. It manages my music database, displays album art, handles playlists, and supports internet radio. And it's open source, so if something doesn't work… - -MPDroid is available on [Google Play][4] and [F-Droid][5]. - -### RadioDroid - -_An Android internet radio tuner that I use standalone and with Chromecast_ - -** - -** - -** - -_![RadioDroid][6]_ - -RadioDroid is to internet radio as MPDroid is to managing my music database; essentially, RadioDroid is a frontend to [Internet-Radio.com][7]. Moreover, RadioDroid can be enjoyed by plugging headphones into the Android device, by connecting the Android device directly to the stereo via the headphone jack or USB, or by using its Chromecast capability with a compatible device. It's a fine way to check the weather in Finland, listen to the Spanish top 40, or hear the latest news from down under. - -RadioDroid is available on [Google Play][8] and [F-Droid][9]. - -### Signal - -_A secure messaging client for Android, iOS, and desktop_ - -** - -** - -** - -_![Signal][10]_ - -If you like WhatsApp but are bothered by its [getting-closer-every-day][11] relationship to Facebook, Signal should be your next thing. The only problem with Signal is convincing your contacts they're better off replacing WhatsApp with Signal. But other than that, it has a similar interface; great voice and video calling; great encryption; decent anonymity; and it's supported by a foundation that doesn't plan to monetize your use of the software. What's not to like? - -Signal is available for [Android][12], [iOS][13], and [desktop][14]. - -### ConnectBot - -_Android SSH client_ - -** - -** - -** - -_![ConnectBot][15]_ - -Sometimes I'm far away from my computer, but I need to log into the server to do something. [ConnectBot][16] is a great solution for moving SSH sessions onto my phone. - -ConnectBot is available on [Google Play][17]. - -### Termux - -_Android terminal emulator with many familiar utilities_ - -** - -** - -** - -_![Termux][18]_ - -Have you ever needed to run an **awk** script on your phone? [Termux][19] is your solution. If you need to do terminal-type stuff, and you don't want to maintain an SSH connection to a remote computer the whole time, bring the files over to your phone with ConnectBot, quit the session, do your stuff in Termux, and send the results back with ConnectBot. - -Termux is available on [Google Play][20] and [F-Droid][21]. - -* * * - -What are your favorite open source mobile apps for work or fun? Please share them in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/4/mobile-apps - -作者:[Chris Hermansen (Community Moderator)][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/clhermansen/users/bcotton/users/clhermansen/users/bcotton/users/clhermansen -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003588_01_rd3os.combacktoschoolserieshe_rh_041x_0.png?itok=tfg6_I78 -[2]: https://opensource.com/sites/default/files/uploads/mpdroid.jpg (MPDroid) -[3]: https://opensource.com/article/17/4/fun-new-gadget -[4]: https://play.google.com/store/apps/details?id=com.namelessdev.mpdroid&hl=en_US -[5]: https://f-droid.org/en/packages/com.namelessdev.mpdroid/ -[6]: https://opensource.com/sites/default/files/uploads/radiodroid.png (RadioDroid) -[7]: https://www.internet-radio.com/ -[8]: https://play.google.com/store/apps/details?id=net.programmierecke.radiodroid2 -[9]: https://f-droid.org/en/packages/net.programmierecke.radiodroid2/ -[10]: https://opensource.com/sites/default/files/uploads/signal.png (Signal) -[11]: https://opensource.com/article/19/3/open-messenger-client -[12]: https://play.google.com/store/apps/details?id=org.thoughtcrime.securesms -[13]: https://itunes.apple.com/us/app/signal-private-messenger/id874139669?mt=8 -[14]: https://signal.org/download/ -[15]: https://opensource.com/sites/default/files/uploads/connectbot.png (ConnectBot) -[16]: https://connectbot.org/ -[17]: https://play.google.com/store/apps/details?id=org.connectbot -[18]: https://opensource.com/sites/default/files/uploads/termux.jpg (Termux) -[19]: https://termux.com/ -[20]: https://play.google.com/store/apps/details?id=com.termux -[21]: https://f-droid.org/packages/com.termux/ diff --git a/sources/tech/20190409 The Microsoft-BMW IoT Open Manufacturing Platform might not be so open.md b/sources/tech/20190409 The Microsoft-BMW IoT Open Manufacturing Platform might not be so open.md deleted file mode 100644 index c74f61efe4..0000000000 --- a/sources/tech/20190409 The Microsoft-BMW IoT Open Manufacturing Platform might not be so open.md +++ /dev/null @@ -1,69 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (The Microsoft/BMW IoT Open Manufacturing Platform might not be so open) -[#]: via: (https://www.networkworld.com/article/3387642/the-microsoftbmw-iot-open-manufacturing-platform-might-not-be-so-open.html#tk.rss_all) -[#]: author: (Fredric Paul https://www.networkworld.com/author/Fredric-Paul/) - -The Microsoft/BMW IoT Open Manufacturing Platform might not be so open -====== -The new industrial IoT Open Manufacturing Platform from Microsoft and BMW runs only on Microsoft Azure. That could be an issue. -![Martyn Williams][1] - -Last week at [Hannover Messe][2], Microsoft and German carmaker BMW announced a partnership to build a hardware and software technology framework and reference architecture for the industrial internet of things (IoT), and foster a community to spread these smart-factory solutions across the automotive and manufacturing industries. - -The stated goal of the [Open Manufacturing Platform (OMP)][3]? According to the press release, it's “to drive open industrial IoT development and help grow a community to build future [Industry 4.0][4] solutions.” To make that a reality, the companies said that by the end of 2019, they plan to attract four to six partners — including manufacturers and suppliers from both inside and outside the automotive industry — and to have rolled out at least 15 use cases operating in actual production environments. - -**[ Read also:[An inside look at an IIoT-powered smart factory][5] | Get regularly scheduled insights: [Sign up for Network World newsletters][6] ]** - -### Complex and proprietary is bad for IoT - -It sounds like a great idea, right? As the companies rightly point out, many of today’s industrial IoT solutions rely on “complex, proprietary systems that create data silos and slow productivity.” Who wouldn’t want to “standardize data models that enable analytics and machine learning scenarios” and “accelerate future industrial IoT developments, shorten time to value, and drive production efficiencies while addressing common industrial challenges”? - -But before you get too excited, let’s talk about a key word in the effort: open. As Scott Guthrie, executive vice president of Microsoft Cloud + AI Group, said in a statement, "Our commitment to building an open community will create new opportunities for collaboration across the entire manufacturing value chain." - -### The Open Manufacturing Platform is open only to Microsoft Azure - -However, that will happen as long as all that collaboration occurs in Microsoft Azure. I’m not saying Azure isn’t up to the task, but it’s hardly the only (or even the leading) cloud platform interested in the industrial IoT. Putting everything in Azure might be an issue to those potential OMP partners. It’s an “open” question as to how many companies already invested in Amazon Web Services (AWS) or the Google Cloud Platform (GCP) will be willing to make the switch or go multi-cloud just to take advantage of the OMP. - -My guess is that Microsoft and BMW won’t have too much trouble meeting their initial goals for the OMP. It shouldn’t be that hard to get a handful of existing Azure customers to come up with 15 use cases leveraging advances in analytics, artificial intelligence (AI), and digital feedback loops. (As an example, the companies cited the autonomous transport systems in BMW’s factory in Regensburg, Germany, part of the more than 3,000 machines, robots and transport systems connected with the BMW Group’s IoT platform, which — naturally — is built on Microsoft Azure's cloud.) - -### Will non-Azure users jump on board the OMP? - -The question is whether tying all this to a single cloud provider will affect the effort to attract enough new companies — including companies not currently using Azure — to establish a truly viable open platform? - -Perhaps [Stacey Higginbotham at Stacy on IoT put it best][7]: - -> “What they really launched is a reference design for manufacturers to work from.” - -That’s not nothing, of course, but it’s a lot less ambitious than building a new industrial IoT platform. And it may not easily fulfill the vision of a community working together to create shared solutions that benefit everyone. - -**[ Now read this:[Why are IoT platforms so darn confusing?][8] ]** - -Join the Network World communities on [Facebook][9] and [LinkedIn][10] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3387642/the-microsoftbmw-iot-open-manufacturing-platform-might-not-be-so-open.html#tk.rss_all - -作者:[Fredric Paul][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Fredric-Paul/ -[b]: https://github.com/lujun9972 -[1]: https://images.techhive.com/images/article/2017/01/20170107_105344-100702818-large.jpg -[2]: https://www.hannovermesse.de/home -[3]: https://www.prnewswire.co.uk/news-releases/microsoft-and-the-bmw-group-launch-the-open-manufacturing-platform-859672858.html -[4]: https://en.wikipedia.org/wiki/Industry_4.0 -[5]: https://www.networkworld.com/article/3384378/an-inside-look-at-tempo-automations-iiot-powered-smart-factory.html -[6]: https://www.networkworld.com/newsletters/signup.html -[7]: https://mailchi.mp/iotpodcast/stacey-on-iot-industrial-iot-reminds-me-of-apples-ecosystem?e=6bf9beb394 -[8]: https://www.networkworld.com/article/3336166/why-are-iot-platforms-so-darn-confusing.html -[9]: https://www.facebook.com/NetworkWorld/ -[10]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20190409 Working with variables on Linux.md b/sources/tech/20190409 Working with variables on Linux.md deleted file mode 100644 index da4fec5ea9..0000000000 --- a/sources/tech/20190409 Working with variables on Linux.md +++ /dev/null @@ -1,267 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Working with variables on Linux) -[#]: via: (https://www.networkworld.com/article/3387154/working-with-variables-on-linux.html#tk.rss_all) -[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) - -Working with variables on Linux -====== -Variables often look like $var, but they also look like $1, $*, $? and $$. Let's take a look at what all these $ values can tell you. -![Mike Lawrence \(CC BY 2.0\)][1] - -A lot of important values are stored on Linux systems in what we call “variables,” but there are actually several types of variables and some interesting commands that can help you work with them. In a previous post, we looked at [environment variables][2] and where they are defined. In this post, we're going to look at variables that are used on the command line and within scripts. - -### User variables - -While it's quite easy to set up a variable on the command line, there are a few interesting tricks. To set up a variable, all you need to do is something like this: - -``` -$ myvar=11 -$ myvar2="eleven" -``` - -To display the values, you simply do this: - -``` -$ echo $myvar -11 -$ echo $myvar2 -eleven -``` - -You can also work with your variables. For example, to increment a numeric variable, you could use any of these commands: - -``` -$ myvar=$((myvar+1)) -$ echo $myvar -12 -$ ((myvar=myvar+1)) -$ echo $myvar -13 -$ ((myvar+=1)) -$ echo $myvar -14 -$ ((myvar++)) -$ echo $myvar -15 -$ let "myvar=myvar+1" -$ echo $myvar -16 -$ let "myvar+=1" -$ echo $myvar -17 -$ let "myvar++" -$ echo $myvar -18 -``` - -With some of these, you can add more than 1 to a variable's value. For example: - -``` -$ myvar0=0 -$ ((myvar0++)) -$ echo $myvar0 -1 -$ ((myvar0+=10)) -$ echo $myvar0 -11 -``` - -With all these choices, you'll probably find at least one that is easy to remember and convenient to use. - -You can also _unset_ a variable — basically undefining it. - -``` -$ unset myvar -$ echo $myvar -``` - -Another interesting option is that you can set up a variable and make it **read-only**. In other words, once set to read-only, its value cannot be changed (at least not without some very tricky command line wizardry). That means you can't unset it either. - -``` -$ readonly myvar3=1 -$ echo $myvar3 -1 -$ ((myvar3++)) --bash: myvar3: readonly variable -$ unset myvar3 --bash: unset: myvar3: cannot unset: readonly variable -``` - -You can use any of those setting and incrementing options for assigning and manipulating variables within scripts, but there are also some very useful _internal variables_ for working within scripts. Note that you can't reassign their values or increment them. - -### Internal variables - -There are quite a few variables that can be used within scripts to evaluate arguments and display information about the script itself. - - * $1, $2, $3 etc. represent the first, second, third, etc. arguments to the script. - * $# represents the number of arguments. - * $* represents the string of arguments. - * $0 represents the name of the script itself. - * $? represents the return code of the previously run command (0=success). - * $$ shows the process ID for the script. - * $PPID shows the process ID for your shell (the parent process for the script). - - - -Some of these variables also work on the command line but show related information: - - * $0 shows the name of the shell you're using (e.g., -bash). - * $$ shows the process ID for your shell. - * $PPID shows the process ID for your shell's parent process (for me, this is sshd). - - - -If we throw all of these variables into a script just to see the results, we might do this: - -``` -#!/bin/bash - -echo $0 -echo $1 -echo $2 -echo $# -echo $* -echo $? -echo $$ -echo $PPID -``` - -When we call this script, we'll see something like this: - -``` -$ tryme one two three -/home/shs/bin/tryme <== script name -one <== first argument -two <== second argument -3 <== number of arguments -one two three <== all arguments -0 <== return code from previous echo command -10410 <== script's process ID -10109 <== parent process's ID -``` - -If we check the process ID of the shell once the script is done running, we can see that it matches the PPID displayed within the script: - -``` -$ echo $$ -10109 <== shell's process ID -``` - -Of course, we're more likely to use these variables in considerably more useful ways than simply displaying their values. Let's check out some ways we might do this. - -Checking to see if arguments have been provided: - -``` -if [ $# == 0 ]; then - echo "$0 filename" - exit 1 -fi -``` - -Checking to see if a particular process is running: - -``` -ps -ef | grep apache2 > /dev/null -if [ $? != 0 ]; then - echo Apache is not running - exit -fi -``` - -Verifying that a file exists before trying to access it: - -``` -if [ $# -lt 2 ]; then - echo "Usage: $0 lines filename" - exit 1 -fi - -if [ ! -f $2 ]; then - echo "Error: File $2 not found" - exit 2 -else - head -$1 $2 -fi -``` - -And in this little script, we check if the correct number of arguments have been provided, if the first argument is numeric, and if the second argument is an existing file. - -``` -#!/bin/bash - -if [ $# -lt 2 ]; then - echo "Usage: $0 lines filename" - exit 1 -fi - -if [[ $1 != [0-9]* ]]; then - echo "Error: $1 is not numeric" - exit 2 -fi - -if [ ! -f $2 ]; then - echo "Error: File $2 not found" - exit 3 -else - echo top of file - head -$1 $2 -fi -``` - -### Renaming variables - -When writing a complicated script, it's often useful to assign names to the script's arguments rather than continuing to refer to them as $1, $2, and so on. By the 35th line, someone reading your script might have forgotten what $2 represents. It will be a lot easier on that person if you assign an important parameter's value to $filename or $numlines. - -``` -#!/bin/bash - -if [ $# -lt 2 ]; then - echo "Usage: $0 lines filename" - exit 1 -else - numlines=$1 - filename=$2 -fi - -if [[ $numlines != [0-9]* ]]; then - echo "Error: $numlines is not numeric" - exit 2 -fi - -if [ ! -f $ filename]; then - echo "Error: File $filename not found" - exit 3 -else - echo top of file - head -$numlines $filename -fi -``` - -Of course, this example script does nothing more than run the head command to show the top X lines in a file, but it is meant to show how internal parameters can be used within scripts to help ensure the script runs well or fails with at least some clarity. - -**[ Watch Sandra Henry-Stocker's Two-Minute Linux Tips[to learn how to master a host of Linux commands][3] ]** - -Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3387154/working-with-variables-on-linux.html#tk.rss_all - -作者:[Sandra Henry-Stocker][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2019/04/variable-key-keyboard-100793080-large.jpg -[2]: https://www.networkworld.com/article/3385516/how-to-manage-your-linux-environment.html -[3]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua -[4]: https://www.facebook.com/NetworkWorld/ -[5]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20190410 How we built a Linux desktop app with Electron.md b/sources/tech/20190410 How we built a Linux desktop app with Electron.md deleted file mode 100644 index eb11c65614..0000000000 --- a/sources/tech/20190410 How we built a Linux desktop app with Electron.md +++ /dev/null @@ -1,101 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How we built a Linux desktop app with Electron) -[#]: via: (https://opensource.com/article/19/4/linux-desktop-electron) -[#]: author: (Nils Ganther https://opensource.com/users/nils-ganther) - -How we built a Linux desktop app with Electron -====== -A story of building an open source email service that runs natively on -Linux desktops, thanks to the Electron framework. -![document sending][1] - -[Tutanota][2] is a secure, open source email service that's been available as an app for the browser, iOS, and Android. The client code is published under GPLv3 and the Android app is available on [F-Droid][3] to enable everyone to use a completely Google-free version. - -Because Tutanota focuses on open source and develops on Linux clients, we wanted to release a desktop app for Linux and other platforms. Being a small team, we quickly ruled out building native apps for Linux, Windows, and MacOS and decided to adapt our app using [Electron][4]. - -Electron is the go-to choice for anyone who wants to ship visually consistent, cross-platform applications, fast—especially if there's already a web app that needs to be freed from the shackles of the browser API. Tutanota is exactly such a case. - -Tutanota is based on [SystemJS][5] and [Mithril][6] and aims to offer simple, secure email communications for everybody. As such, it has to provide a lot of the standard features users expect from any email client. - -Some of these features, like basic push notifications, search for text and contacts, and support for two-factor authentication are easy to offer in the browser thanks to modern APIs and standards. Other features (such as automatic backups or IMAP support without involving our servers) need less-restricted access to system resources, which is exactly what the Electron framework provides. - -While some criticize Electron as "just a basic wrapper," it has obvious benefits: - - * Electron enables you to adapt a web app quickly for Linux, Windows, and MacOS desktops. In fact, most Linux desktop apps are built with Electron. - * Electron enables you to easily bring the desktop client to feature parity with the web app. - * Once you've published the desktop app, you can use free development capacity to add desktop-specific features that enhance usability and security. - * And last but certainly not least, it's a great way to make the app feel native and integrated into the user's system while maintaining its identity. - - - -### Meeting users' needs - -At Tutanota, we do not rely on big investor money, rather we are a community-driven project. We grow our team organically based on the increasing number of users upgrading to our freemium service's paid plans. Listening to what users want is not only important to us, it is essential to our success. - -Offering a desktop client was users' [most-wanted feature][7] in Tutanota, and we are proud that we can now offer free beta desktop clients to all of our users. (We also implemented another highly requested feature—[search on encrypted data][8]—but that's a topic for another time.) - -We liked the idea of providing users with signed versions of Tutanota and enabling functions that are impossible in the browser, such as push notifications via a background process. Now we plan to add more desktop-specific features, such as IMAP support without depending on our servers to act as a proxy, automatic backups, and offline availability. - -We chose Electron because its combination of Chromium and Node.js promised to be the best fit for our small development team, as it required only minimal changes to our web app. It was particularly helpful to use the browser APIs for everything as we got started, slowly replacing those components with more native versions as we progressed. This approach was especially handy with attachment downloads and notifications. - -### Tuning security - -We were aware that some people cite security problems with Electron, but we found Electron's options for fine-tuning access in the web app quite satisfactory. You can use resources like the Electron's [security documentation][9] and Luca Carettoni's [Electron Security Checklist][10] to help prevent catastrophic mishaps with untrusted content in your web app. - -### Achieving feature parity - -The Tutanota web client was built from the start with a solid protocol for interprocess communication. We utilize web workers to keep user interface (UI) rendering responsive while encrypting and requesting data. This came in handy when we started implementing our mobile apps, which use the same protocol to communicate between the native part and the web view. - -That's why when we started building the desktop clients, a lot of bindings for things like native push notifications, opening mailboxes, and working with the filesystem were already there, so only the native (node) side had to be implemented. - -Another convenience was our build process using the [Babel transpiler][11], which allows us to write the entire codebase in modern ES6 JavaScript and mix-and-match utility modules between the different environments. This enabled us to speedily adapt the code for the Electron-based desktop apps. However, we encountered some challenges. - -### Overcoming challenges - -While Electron allows us to integrate with the different platforms' desktop environments pretty easily, you can't underestimate the time investment to get things just right! In the end, it was these little things that took up much more time than we expected but were also crucial to finish the desktop client project. - -The places where platform-specific code was necessary caused most of the friction: - - * Window management and the tray, for example, are still handled in subtly different ways on the three platforms. - * Registering Tutanota as the default mail program and setting up autostart required diving into the Windows Registry while making sure to prompt the user for admin access in a [UAC][12]-compatible way. - * We needed to use Electron's API for shortcuts and menus to offer even standard features like copy, paste, undo, and redo. - - - -This process was complicated a bit by users' expectations of certain, sometimes not directly compatible behavior of the apps on different platforms. Making the three versions feel native required some iteration and even some modest additions to the web app to offer a text search similar to the one in the browser. - -### Wrapping up - -Our experience with Electron was largely positive, and we completed the project in less than four months. Despite some rather time-consuming features, we were surprised about the ease with which we could ship a beta version of the [Tutanota desktop client for Linux][13]. If you're interested, you can dive into the source code on [GitHub][14]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/4/linux-desktop-electron - -作者:[Nils Ganther][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/nils-ganther -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_paper_envelope_document.png?itok=uPj_kouJ (document sending) -[2]: https://tutanota.com/ -[3]: https://f-droid.org/en/packages/de.tutao.tutanota/ -[4]: https://electronjs.org/ -[5]: https://github.com/systemjs/systemjs -[6]: https://mithril.js.org/ -[7]: https://tutanota.uservoice.com/forums/237921-general/filters/top?status_id=1177482 -[8]: https://tutanota.com/blog/posts/first-search-encrypted-data/ -[9]: https://electronjs.org/docs/tutorial/security -[10]: https://www.blackhat.com/docs/us-17/thursday/us-17-Carettoni-Electronegativity-A-Study-Of-Electron-Security-wp.pdf -[11]: https://babeljs.io/ -[12]: https://en.wikipedia.org/wiki/User_Account_Control -[13]: https://tutanota.com/blog/posts/desktop-clients/ -[14]: https://www.github.com/tutao/tutanota diff --git a/sources/tech/20190411 Be your own certificate authority.md b/sources/tech/20190411 Be your own certificate authority.md deleted file mode 100644 index f6ea26aba4..0000000000 --- a/sources/tech/20190411 Be your own certificate authority.md +++ /dev/null @@ -1,135 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Be your own certificate authority) -[#]: via: (https://opensource.com/article/19/4/certificate-authority) -[#]: author: (Moshe Zadka https://opensource.com/users/moshez/users/elenajon123) - -Be your own certificate authority -====== -Create a simple, internal CA for your microservice architecture or -integration testing. -![][1] - -The Transport Layer Security ([TLS][2]) model, which is sometimes referred to by the older name SSL, is based on the concept of [certificate authorities][3] (CAs). These authorities are trusted by browsers and operating systems and, in turn, _sign_ servers' certificates to validate their ownership. - -However, for an intranet, a microservice architecture, or integration testing, it is sometimes useful to have a _local CA_ : one that is trusted only internally and, in turn, signs local servers' certificates. - -This especially makes sense for integration tests. Getting certificates can be a burden because the servers will be up for minutes. But having an "ignore certificate" option in the code could allow it to be activated in production, leading to a security catastrophe. - -A CA certificate is not much different from a regular server certificate; what matters is that it is trusted by local code. For example, in the **requests** library, this can be done by setting the **REQUESTS_CA_BUNDLE** variable to a directory containing this certificate. - -In the example of creating a certificate for integration tests, there is no need for a _long-lived_ certificate: if your integration tests take more than a day, you have already failed. - -So, calculate **yesterday** and **tomorrow** as the validity interval: - - -``` ->>> import datetime ->>> one_day = datetime.timedelta(days=1) ->>> today = datetime.date.today() ->>> yesterday = today - one_day ->>> tomorrow = today - one_day -``` - -Now you are ready to create a simple CA certificate. You need to generate a private key, create a public key, set up the "parameters" of the CA, and then self-sign the certificate: a CA certificate is _always_ self-signed. Finally, write out both the certificate file as well as the private key file. - - -``` -from cryptography.hazmat.primitives.asymmetric import rsa -from cryptography.hazmat.primitives import hashes, serialization -from cryptography import x509 -from cryptography.x509.oid import NameOID - -private_key = rsa.generate_private_key( -public_exponent=65537, -key_size=2048, -backend=default_backend() -) -public_key = private_key.public_key() -builder = x509.CertificateBuilder() -builder = builder.subject_name(x509.Name([ -x509.NameAttribute(NameOID.COMMON_NAME, 'Simple Test CA'), -])) -builder = builder.issuer_name(x509.Name([ -x509.NameAttribute(NameOID.COMMON_NAME, 'Simple Test CA'), -])) -builder = builder.not_valid_before(yesterday) -builder = builder.not_valid_after(tomorrow) -builder = builder.serial_number(x509.random_serial_number()) -builder = builder.public_key(public_key) -builder = builder.add_extension( -x509.BasicConstraints(ca=True, path_length=None), -critical=True) -certificate = builder.sign( -private_key=private_key, algorithm=hashes.SHA256(), -backend=default_backend() -) -private_bytes = private_key.private_bytes( -encoding=serialization.Encoding.PEM, -format=serialization.PrivateFormat.TraditionalOpenSSL, -encryption_algorithm=serialization.NoEncrption()) -public_bytes = certificate.public_bytes( -encoding=serialization.Encoding.PEM) -with open("ca.pem", "wb") as fout: -fout.write(private_bytes + public_bytes) -with open("ca.crt", "wb") as fout: -fout.write(public_bytes) -``` - -In general, a real CA will expect a [certificate signing request][4] (CSR) to sign a certificate. However, when you are your own CA, you can make your own rules! Just go ahead and sign what you want. - -Continuing with the integration test example, you can create the private keys and sign the corresponding public keys right then. Notice **COMMON_NAME** needs to be the "server name" in the **https** URL. If you've configured name lookup, the needed server will respond on **service.test.local**. - - -``` -service_private_key = rsa.generate_private_key( -public_exponent=65537, -key_size=2048, -backend=default_backend() -) -service_public_key = service_private_key.public_key() -builder = x509.CertificateBuilder() -builder = builder.subject_name(x509.Name([ -x509.NameAttribute(NameOID.COMMON_NAME, 'service.test.local') -])) -builder = builder.not_valid_before(yesterday) -builder = builder.not_valid_after(tomorrow) -builder = builder.public_key(public_key) -certificate = builder.sign( -private_key=private_key, algorithm=hashes.SHA256(), -backend=default_backend() -) -private_bytes = service_private_key.private_bytes( -encoding=serialization.Encoding.PEM, -format=serialization.PrivateFormat.TraditionalOpenSSL, -encryption_algorithm=serialization.NoEncrption()) -public_bytes = certificate.public_bytes( -encoding=serialization.Encoding.PEM) -with open("service.pem", "wb") as fout: -fout.write(private_bytes + public_bytes) -``` - -Now the **service.pem** file has a private key and a certificate that is "valid": it has been signed by your local CA. The file is in a format that can be given to, say, Nginx, HAProxy, or most other HTTPS servers. - -By applying this logic to testing scripts, it's easy to create servers that look like authentic HTTPS servers, as long as the client is configured to trust the right CA. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/4/certificate-authority - -作者:[Moshe Zadka (Community Moderator)][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/moshez/users/elenajon123 -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_commun_4604_02_mech_connections_rhcz0.5x.png?itok=YPPU4dMj -[2]: https://en.wikipedia.org/wiki/Transport_Layer_Security -[3]: https://en.wikipedia.org/wiki/Certificate_authority -[4]: https://en.wikipedia.org/wiki/Certificate_signing_request diff --git a/sources/tech/20190415 Kubernetes on Fedora IoT with k3s.md b/sources/tech/20190415 Kubernetes on Fedora IoT with k3s.md deleted file mode 100644 index 5650e80aee..0000000000 --- a/sources/tech/20190415 Kubernetes on Fedora IoT with k3s.md +++ /dev/null @@ -1,211 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Kubernetes on Fedora IoT with k3s) -[#]: via: (https://fedoramagazine.org/kubernetes-on-fedora-iot-with-k3s/) -[#]: author: (Lennart Jern https://fedoramagazine.org/author/lennartj/) - -Kubernetes on Fedora IoT with k3s -====== - -![][1] - -Fedora IoT is an upcoming Fedora edition targeted at the Internet of Things. It was introduced last year on Fedora Magazine in the article [How to turn on an LED with Fedora IoT][2]. Since then, it has continued to improve together with Fedora Silverblue to provide an immutable base operating system aimed at container-focused workflows. - -Kubernetes is an immensely popular container orchestration system. It is perhaps most commonly used on powerful hardware handling huge workloads. However, it can also be used on lightweight devices such as the Raspberry Pi 3. Read on to find out how. - -### Why Kubernetes? - -While Kubernetes is all the rage in the cloud, it may not be immediately obvious to run it on a small single board computer. But there are certainly reasons for doing it. First of all it is a great way to learn and get familiar with Kubernetes without the need for expensive hardware. Second, because of its popularity, there are [tons of applications][3] that comes pre-packaged for running in Kubernetes clusters. Not to mention the large community to provide help if you ever get stuck. - -Last but not least, container orchestration may actually make things easier, even at the small scale in a home lab. This may not be apparent when tackling the the learning curve, but these skills will help when dealing with any cluster in the future. It doesn’t matter if it’s a single node Raspberry Pi cluster or a large scale machine learning farm. - -#### K3s – a lightweight Kubernetes - -A “normal” installation of Kubernetes (if such a thing can be said to exist) is a bit on the heavy side for IoT. The recommendation is a minimum of 2 GB RAM per machine! However, there are plenty of alternatives, and one of the newcomers is [k3s][4] – a lightweight Kubernetes distribution. - -K3s is quite special in that it has replaced etcd with SQLite for its key-value storage needs. Another thing to note is that k3s ships as a single binary instead of one per component. This diminishes the memory footprint and simplifies the installation. Thanks to the above, k3s should be able to run k3s with just 512 MB of RAM, perfect for a small single board computer! - -### What you will need - - 1. Fedora IoT in a virtual machine or on a physical device. See the excellent getting started guide [here][5]. One machine is enough but two will allow you to test adding more nodes to the cluster. - 2. [Configure the firewall][6] to allow traffic on ports 6443 and 8472. Or simply disable it for this experiment by running “systemctl stop firewalld”. - - - -### Install k3s - -Installing k3s is very easy. Simply run the installation script: - -``` -curl -sfL https://get.k3s.io | sh - -``` - -This will download, install and start up k3s. After installation, get a list of nodes from the server by running the following command: - -``` -kubectl get nodes -``` - -Note that there are several options that can be passed to the installation script through environment variables. These can be found in the [documentation][7]. And of course, there is nothing stopping you from installing k3s manually by downloading the binary directly. - -While great for experimenting and learning, a single node cluster is not much of a cluster. Luckily, adding another node is no harder than setting up the first one. Just pass two environment variables to the installation script to make it find the first node and avoid running the server part of k3s - -``` -curl -sfL https://get.k3s.io | K3S_URL=https://example-url:6443 \ - K3S_TOKEN=XXX sh - -``` - -The example-url above should be replaced by the IP address or fully qualified domain name of the first node. On that node the token (represented by XXX) is found in the file /var/lib/rancher/k3s/server/node-token. - -### Deploy some containers - -Now that we have a Kubernetes cluster, what can we actually do with it? Let’s start by deploying a simple web server. - -``` -kubectl create deployment my-server --image nginx -``` - -This will create a [Deployment][8] named “my-server” from the container image “nginx” (defaulting to docker hub as registry and the latest tag). You can see the Pod created by running the following command. - -``` -kubectl get pods -``` - -In order to access the nginx server running in the pod, first expose the Deployment through a [Service][9]. The following command will create a Service with the same name as the deployment. - -``` -kubectl expose deployment my-server --port 80 -``` - -The Service works as a kind of load balancer and DNS record for the Pods. For instance, when running a second Pod, we will be able to _curl_ the nginx server just by specifying _my-server_ (the name of the Service). See the example below for how to do this. - -``` -# Start a pod and run bash interactively in it -kubectl run debug --generator=run-pod/v1 --image=fedora -it -- bash -# Wait for the bash prompt to appear -curl my-server -# You should get the "Welcome to nginx!" page as output -``` - -### Ingress controller and external IP - -By default, a Service only get a ClusterIP (only accessible inside the cluster), but you can also request an external IP for the service by setting its type to [LoadBalancer][10]. However, not all applications require their own IP address. Instead, it is often possible to share one IP address among many services by routing requests based on the host header or path. You can accomplish this in Kubernetes with an [Ingress][11], and this is what we will do. Ingresses also provide additional features such as TLS encryption of the traffic without having to modify your application. - -Kubernetes needs an ingress controller to make the Ingress resources work and k3s includes [Traefik][12] for this purpose. It also includes a simple service load balancer that makes it possible to get an external IP for a Service in the cluster. The [documentation][13] describes the service like this: - -> k3s includes a basic service load balancer that uses available host ports. If you try to create a load balancer that listens on port 80, for example, it will try to find a free host in the cluster for port 80. If no port is available the load balancer will stay in Pending. -> -> k3s README - -The ingress controller is already exposed with this load balancer service. You can find the IP address that it is using with the following command. - -``` -$ kubectl get svc --all-namespaces -NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE - default kubernetes ClusterIP 10.43.0.1 443/TCP 33d - default my-server ClusterIP 10.43.174.38 80/TCP 30m - kube-system kube-dns ClusterIP 10.43.0.10 53/UDP,53/TCP,9153/TCP 33d - kube-system traefik LoadBalancer 10.43.145.104 10.0.0.8 80:31596/TCP,443:31539/TCP 33d -``` - -Look for the Service named traefik. In the above example the IP we are interested in is 10.0.0.8. - -### Route incoming requests - -Let’s create an Ingress that routes requests to our web server based on the host header. This example uses [xip.io][14] to avoid having to set up DNS records. It works by including the IP adress as a subdomain, to use any subdomain of 10.0.0.8.xip.io to reach the IP 10.0.0.8. In other words, my-server.10.0.0.8.xip.io is used to reach the ingress controller in the cluster. You can try this right now (with your own IP instead of 10.0.0.8). Without an ingress in place you should reach the “default backend” which is just a page showing “404 page not found”. - -We can tell the ingress controller to route requests to our web server Service with the following Ingress. - -``` -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: my-server -spec: - rules: - - host: my-server.10.0.0.8.xip.io - http: - paths: - - path: / - backend: - serviceName: my-server - servicePort: 80 -``` - -Save the above snippet in a file named _my-ingress.yaml_ and add it to the cluster by running this command: - -``` -kubectl apply -f my-ingress.yaml -``` - -You should now be able to reach the default nginx welcoming page on the fully qualified domain name you chose. In my example this would be my-server.10.0.0.8.xip.io. The ingress controller is routing the requests based on the information in the Ingress. A request to my-server.10.0.0.8.xip.io will be routed to the Service and port defined as backend in the Ingress (my-server and 80 in this case). - -### What about IoT then? - -Imagine the following scenario. You have dozens of devices spread out around your home or farm. It is a heterogeneous collection of IoT devices with various hardware capabilities, sensors and actuators. Maybe some of them have cameras, weather or light sensors. Others may be hooked up to control the ventilation, lights, blinds or blink LEDs. - -In this scenario, you want to gather data from all the sensors, maybe process and analyze it before you finally use it to make decisions and control the actuators. In addition to this, you may want to visualize what’s going on by setting up a dashboard. So how can Kubernetes help us manage something like this? How can we make sure that Pods run on suitable devices? - -The simple answer is labels. You can label the nodes according to capabilities, like this: - -``` -kubectl label nodes = -# Example -kubectl label nodes node2 camera=available -``` - -Once they are labeled, it is easy to select suitable nodes for your workload with [nodeSelectors][15]. The final piece to the puzzle, if you want to run your Pods on _all_ suitable nodes is to use [DaemonSets][16] instead of Deployments. In other words, create one DaemonSet for each data collecting application that uses some unique sensor and use nodeSelectors to make sure they only run on nodes with the proper hardware. - -The service discovery feature that allows Pods to find each other simply by Service name makes it quite easy to handle these kinds of distributed systems. You don’t need to know or configure IP addresses or custom ports for the applications. Instead, they can easily find each other through named Services in the cluster. - -#### Utilize spare resources - -With the cluster up and running, collecting data and controlling your lights and climate control you may feel that you are finished. However, there are still plenty of compute resources in the cluster that could be used for other projects. This is where Kubernetes really shines. - -You shouldn’t have to worry about where exactly those resources are or calculate if there is enough memory to fit an extra application here or there. This is exactly what orchestration solves! You can easily deploy more applications in the cluster and let Kubernetes figure out where (or if) they will fit. - -Why not run your own [NextCloud][17] instance? Or maybe [gitea][18]? You could also set up a CI/CD pipeline for all those IoT containers. After all, why would you build and cross compile them on your main computer if you can do it natively in the cluster? - -The point here is that Kubernetes makes it easier to make use of the “hidden” resources that you often end up with otherwise. Kubernetes handles scheduling of Pods in the cluster based on available resources and fault tolerance so that you don’t have to. However, in order to help Kubernetes make reasonable decisions you should definitely add [resource requests][19] to your workloads. - -### Summary - -While Kubernetes, or container orchestration in general, may not usually be associated with IoT, it certainly makes a lot of sense to have an orchestrator when you are dealing with distributed systems. Not only does is allow you to handle a diverse and heterogeneous fleet of devices in a unified way, but it also simplifies communication between them. In addition, Kubernetes makes it easier to utilize spare resources. - -Container technology made it possible to build applications that could “run anywhere”. Now Kubernetes makes it easier to manage the “anywhere” part. And as an immutable base to build it all on, we have Fedora IoT. - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/kubernetes-on-fedora-iot-with-k3s/ - -作者:[Lennart Jern][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/lennartj/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2019/04/k3s-1-816x345.png -[2]: https://fedoramagazine.org/turnon-led-fedora-iot/ -[3]: https://hub.helm.sh/ -[4]: https://k3s.io -[5]: https://docs.fedoraproject.org/en-US/iot/getting-started/ -[6]: https://github.com/rancher/k3s#open-ports--network-security -[7]: https://github.com/rancher/k3s#systemd -[8]: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/ -[9]: https://kubernetes.io/docs/concepts/services-networking/service/ -[10]: https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer -[11]: https://kubernetes.io/docs/concepts/services-networking/ingress/ -[12]: https://traefik.io/ -[13]: https://github.com/rancher/k3s/blob/master/README.md#service-load-balancer -[14]: http://xip.io/ -[15]: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ -[16]: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/ -[17]: https://nextcloud.com/ -[18]: https://gitea.io/en-us/ -[19]: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/ diff --git a/sources/tech/20190416 Can schools be agile.md b/sources/tech/20190416 Can schools be agile.md deleted file mode 100644 index 065b313c05..0000000000 --- a/sources/tech/20190416 Can schools be agile.md +++ /dev/null @@ -1,79 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Can schools be agile?) -[#]: via: (https://opensource.com/open-organization/19/4/education-culture-agile) -[#]: author: (Ben Owens https://opensource.com/users/engineerteacher/users/ke4qqq/users/n8chz/users/don-watkins) - -Can schools be agile? -====== -We certainly don't need to run our schools like businesses—but we could -benefit from educational organizations more focused on continuous -improvement. -![][1] - -We've all had those _deja vu_ moments that make us think "I've seen this before!" I experienced them often in the late 1980s, when I first began my career in industry. I was caught up in a wave of organizational change, where the U.S. manufacturing sector was experimenting with various models that asked leaders, managers, and engineers like me to rethink how we approached things like quality, cost, innovation, and shareholder value. It seems as if every year (sometimes, more frequently) we'd study yet another book to identify the "best practices" necessary for making us leaner, flatter, more nimble, and more responsive to the needs of the customer. - -Many of the approaches were so transformational that their core principles still resonate with me today. Specific ideas and methods from thought leaders such as John Kotter, Peter Drucker, Edwards Demming, and Peter Senge were truly pivotal for our ability to rethink our work, as were the adoption of process improvement methods such as Six Sigma and those embodied in the "Toyota Way." - -But others seemed to simply repackage these same ideas with a sexy new twist—hence my _deja vu_. - -And yet when I began my career as a teacher, I encountered a context that _didn't_ give me that feeling: education. In fact, I was surprised to find that "getting better all the time" was _not_ the same high priority in my new profession that it was in my old one (particularly at the level of my role as a classroom teacher). - -Why aren't more educational organizations working to create cultures of continuous improvement? I can think of several reasons, but let me address two. - -### Widgets no more - -The first barrier to a culture of continuous improvement is education's general reticence to look at other professions for ideas it can adapt and adopt—especially ideas from the business community. The second is education's predominant leadership model, which remains predominantly top-down and rooted in hierarchy. Conversations about systemic, continuous improvement tend to be the purview of a relatively small group of school or district leaders: principals, assistant principals, superintendents, and the like. But widespread organizational culture change can't occur if only one small group is involved in it. - -Before unpacking these points a bit further, I'd like to emphasize that there are certainly exceptions to the above generalization (many I have seen first hand) and that there are two basic assumptions that I think any education stakeholder should be able to agree with: - - 1. Continuous improvement must be an essential mindset for _anyone_ involved in the work of providing high-quality and equitable teaching and learning systems for students, and - 2. Decisions by leaders of our schools will more greatly benefit students and the communities in which they live when those decisions are informed and influenced by those who work closest with students. - - - -So why a tendency to ignore (or be outright hostile toward) ideas that come from outside the education space? - -I, for example, have certainly faced criticism in the past for suggesting that we look to other professions for ideas and inspiration that can help us better meet the needs of students. A common refrain is something like: "You're trying to treat our students like widgets!" But how could our students be treated any more like widgets than they already are? They matriculate through school in age-based cohorts, going from siloed class to class each day by the sound of a shrill bell, and receive grades based on arbitrary tests that emphasize sameness over individuality. - -What I'm advocating is a clear-eyed and objective look at any idea from any sector with potential to help us better meet the needs of individual students, not that we somehow run our schools like businesses. - -It may be news to many inside of education, but widgets—abstract units of production that evoke the idea of assembly line standardization—are not a significant part of the modern manufacturing sector. Thanks to the culture of continuous improvement described above, modern, advanced manufacturing delivers just what the individual customer wants, at a competitive price, exactly when she wants it. If we adapted this model to our schools, teachers would be more likely to collaborate and constantly refine their unique paths of growth for all students based on just-in-time needs and desires—regardless of the time, subject, or any other traditional norm. - -What I'm advocating is a clear-eyed and objective look at any idea from any sector with potential to help us better meet the needs of individual students, not that we somehow run our schools like businesses. In order for this to happen effectively, however, we need to scrutinize a leadership structure that has frankly remained stagnant for over 100 years. - -### Toward continuous improvement - -While I certainly appreciate the argument that education is an animal significantly different from other professions, I also believe that rethinking an organizational and leadership structure is an applicable exercise for any entity wanting to remain responsible (and responsive) to the needs of its stakeholders. Most other professions have taken a hard look at their traditional, closed, hierarchical structures and moved to ones that encourage collective autonomy per shared goals of excellence—organizational elements essential for continuous improvement. It's time our schools and districts do the same by expanding their horizon beyond sources that, while well intended, are developed from a lens of the current paradigm. - -Not surprisingly, a go-to resource I recommend to any school wanting to begin or accelerate this process is _The Open Organization_ by Jim Whitehurst. Not only does the book provide a window into how educators can create more open, inclusive leadership structures—where mutual respect enables nimble decisions to be made per real-time data—but it does so in language easily adaptable to the rather strange lexicon that's second nature to educators. Open organization thinking provides pragmatic ways any organization can empower members to be more open: sharing ideas and resources, embracing a culture of collaborative participation as a top priority, developing an innovation mindset through rapid prototyping, valuing ideas based on merit rather than the rank of the person proposing them, and building a strong sense of community that's baked into the organization's DNA. Such an open organization crowd-sources ideas from both inside and outside its formal structure and creates the type of environment that enables localized, student-centered innovations to thrive. - -We simply can't rely on solutions and practices we developed in a factory-model paradigm. - -Here's the bottom line: Essential to a culture of continuous improvement is recognizing that what we've done in the past may not be suitable in a rapidly changing future. For educators, that means we simply can't rely on solutions and practices we developed in a factory-model paradigm. We must acknowledge countless examples of best practices from other sectors—such as non-profits, the military, the medical profession, and yes, even business—that can at least _inform_ how we rethink what we do in the best interest of students. By moving beyond the traditionally sanctioned "eduspeak" world, we create opportunities for considering perspectives. We can better see the forest for the trees, taking a more objective look at the problems we face, as well as acknowledging what we do very well. - -Intentionally considering ideas from all sources—from first year classroom teachers to the latest NYT Business & Management Leadership bestseller—offers us a powerful way to engage existing talent within our schools to help overcome the institutionalized inertia that has prevented more positive change from taking hold in our schools and districts. - -Relentlessly pursuing methods of continuous improvement should not be a behavior confined to organizations fighting to remain competitive in a global, innovation economy, nor should it be left to a select few charged with the operation of our schools. When everyone in an organization is always thinking about what they can do differently _today_ to improve what they did _yesterday_ , then you have an organization living a culture of excellence. That's the kind of radically collaborative and innovative culture we should especially expect for organizations focused on changing the lives of young people. - -I'm eagerly awaiting the day when I enter a school, recognize that spirit, and smile to myself as I say, "I've seen this before." - -Experiential learning using open source is fraught with opportunities for disaster. - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/19/4/education-culture-agile - -作者:[Ben Owens][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/engineerteacher/users/ke4qqq/users/n8chz/users/don-watkins -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDUCATION_network.png?itok=ySEHuAQ8 diff --git a/sources/tech/20190417 Inter-process communication in Linux- Sockets and signals.md b/sources/tech/20190417 Inter-process communication in Linux- Sockets and signals.md deleted file mode 100644 index 3d306d35af..0000000000 --- a/sources/tech/20190417 Inter-process communication in Linux- Sockets and signals.md +++ /dev/null @@ -1,388 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (FSSlc) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Inter-process communication in Linux: Sockets and signals) -[#]: via: (https://opensource.com/article/19/4/interprocess-communication-linux-networking) -[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu) - -Inter-process communication in Linux: Sockets and signals -====== - -Learn how processes synchronize with each other in Linux. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mesh_networking_dots_connected.png?itok=ovINTRR3) - -This is the third and final article in a series about [interprocess communication][1] (IPC) in Linux. The [first article][2] focused on IPC through shared storage (files and memory segments), and the [second article][3] does the same for basic channels: pipes (named and unnamed) and message queues. This article moves from IPC at the high end (sockets) to IPC at the low end (signals). Code examples flesh out the details. - -### Sockets - -Just as pipes come in two flavors (named and unnamed), so do sockets. IPC sockets (aka Unix domain sockets) enable channel-based communication for processes on the same physical device (host), whereas network sockets enable this kind of IPC for processes that can run on different hosts, thereby bringing networking into play. Network sockets need support from an underlying protocol such as TCP (Transmission Control Protocol) or the lower-level UDP (User Datagram Protocol). - -By contrast, IPC sockets rely upon the local system kernel to support communication; in particular, IPC sockets communicate using a local file as a socket address. Despite these implementation differences, the IPC socket and network socket APIs are the same in the essentials. The forthcoming example covers network sockets, but the sample server and client programs can run on the same machine because the server uses network address localhost (127.0.0.1), the address for the local machine on the local machine. - -Sockets configured as streams (discussed below) are bidirectional, and control follows a client/server pattern: the client initiates the conversation by trying to connect to a server, which tries to accept the connection. If everything works, requests from the client and responses from the server then can flow through the channel until this is closed on either end, thereby breaking the connection. - -An iterative server, which is suited for development only, handles connected clients one at a time to completion: the first client is handled from start to finish, then the second, and so on. The downside is that the handling of a particular client may hang, which then starves all the clients waiting behind. A production-grade server would be concurrent, typically using some mix of multi-processing and multi-threading. For example, the Nginx web server on my desktop machine has a pool of four worker processes that can handle client requests concurrently. The following code example keeps the clutter to a minimum by using an iterative server; the focus thus remains on the basic API, not on concurrency. - -Finally, the socket API has evolved significantly over time as various POSIX refinements have emerged. The current sample code for server and client is deliberately simple but underscores the bidirectional aspect of a stream-based socket connection. Here's a summary of the flow of control, with the server started in a terminal then the client started in a separate terminal: - - * The server awaits client connections and, given a successful connection, reads the bytes from the client. - - * To underscore the two-way conversation, the server echoes back to the client the bytes received from the client. These bytes are ASCII character codes, which make up book titles. - - * The client writes book titles to the server process and then reads the same titles echoed from the server. Both the server and the client print the titles to the screen. Here is the server's output, essentially the same as the client's: - -``` -Listening on port 9876 for clients... -War and Peace -Pride and Prejudice -The Sound and the Fury -``` - - - - -#### Example 1. The socket server - -``` -#include -#include -#include -#include -#include -#include -#include -#include -#include "sock.h" - -void report(const char* msg, int terminate) { -  perror(msg); -  if (terminate) exit(-1); /* failure */ -} - -int main() { -  int fd = socket(AF_INET,     /* network versus AF_LOCAL */ -                  SOCK_STREAM, /* reliable, bidirectional, arbitrary payload size */ -                  0);          /* system picks underlying protocol (TCP) */ -  if (fd < 0) report("socket", 1); /* terminate */ - -  /* bind the server's local address in memory */ -  struct sockaddr_in saddr; -  memset(&saddr, 0, sizeof(saddr));          /* clear the bytes */ -  saddr.sin_family = AF_INET;                /* versus AF_LOCAL */ -  saddr.sin_addr.s_addr = htonl(INADDR_ANY); /* host-to-network endian */ -  saddr.sin_port = htons(PortNumber);        /* for listening */ - -  if (bind(fd, (struct sockaddr *) &saddr, sizeof(saddr)) < 0) -    report("bind", 1); /* terminate */ - -  /* listen to the socket */ -  if (listen(fd, MaxConnects) < 0) /* listen for clients, up to MaxConnects */ -    report("listen", 1); /* terminate */ - -  fprintf(stderr, "Listening on port %i for clients...\n", PortNumber); -  /* a server traditionally listens indefinitely */ -  while (1) { -    struct sockaddr_in caddr; /* client address */ -    int len = sizeof(caddr);  /* address length could change */ - -    int client_fd = accept(fd, (struct sockaddr*) &caddr, &len);  /* accept blocks */ -    if (client_fd < 0) { -      report("accept", 0); /* don't terminate, though there's a problem */ -      continue; -    } - -    /* read from client */ -    int i; -    for (i = 0; i < ConversationLen; i++) { -      char buffer[BuffSize + 1]; -      memset(buffer, '\0', sizeof(buffer)); -      int count = read(client_fd, buffer, sizeof(buffer)); -      if (count > 0) { -        puts(buffer); -        write(client_fd, buffer, sizeof(buffer)); /* echo as confirmation */ -      } -    } -    close(client_fd); /* break connection */ -  }  /* while(1) */ -  return 0; -} -``` - -The server program above performs the classic four-step to ready itself for client requests and then to accept individual requests. Each step is named after a system function that the server calls: - - 1. **socket(…)** : get a file descriptor for the socket connection - 2. **bind(…)** : bind the socket to an address on the server's host - 3. **listen(…)** : listen for client requests - 4. **accept(…)** : accept a particular client request - - - -The **socket** call in full is: - -``` -int sockfd = socket(AF_INET,      /* versus AF_LOCAL */ -                    SOCK_STREAM,  /* reliable, bidirectional */ -                    0);           /* system picks protocol (TCP) */ -``` - -The first argument specifies a network socket as opposed to an IPC socket. There are several options for the second argument, but **SOCK_STREAM** and **SOCK_DGRAM** (datagram) are likely the most used. A stream-based socket supports a reliable channel in which lost or altered messages are reported; the channel is bidirectional, and the payloads from one side to the other can be arbitrary in size. By contrast, a datagram-based socket is unreliable (best try), unidirectional, and requires fixed-sized payloads. The third argument to **socket** specifies the protocol. For the stream-based socket in play here, there is a single choice, which the zero represents: TCP. Because a successful call to **socket** returns the familiar file descriptor, a socket is written and read with the same syntax as, for example, a local file. - -The **bind** call is the most complicated, as it reflects various refinements in the socket API. The point of interest is that this call binds the socket to a memory address on the server machine. However, the **listen** call is straightforward: - -``` -if (listen(fd, MaxConnects) < 0) -``` - -The first argument is the socket's file descriptor and the second specifies how many client connections can be accommodated before the server issues a connection refused error on an attempted connection. ( **MaxConnects** is set to 8 in the header file sock.h.) - -The **accept** call defaults to a blocking wait: the server does nothing until a client attempts to connect and then proceeds. The **accept** function returns **-1** to indicate an error. If the call succeeds, it returns another file descriptor—for a read/write socket in contrast to the accepting socket referenced by the first argument in the **accept** call. The server uses the read/write socket to read requests from the client and to write responses back. The accepting socket is used only to accept client connections. - -By design, a server runs indefinitely. Accordingly, the server can be terminated with a **Ctrl+C** from the command line. - -#### Example 2. The socket client - -``` -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "sock.h" - -const char* books[] = {"War and Peace", -                       "Pride and Prejudice", -                       "The Sound and the Fury"}; - -void report(const char* msg, int terminate) { -  perror(msg); -  if (terminate) exit(-1); /* failure */ -} - -int main() { -  /* fd for the socket */ -  int sockfd = socket(AF_INET,      /* versus AF_LOCAL */ -                      SOCK_STREAM,  /* reliable, bidirectional */ -                      0);           /* system picks protocol (TCP) */ -  if (sockfd < 0) report("socket", 1); /* terminate */ - -  /* get the address of the host */ -  struct hostent* hptr = gethostbyname(Host); /* localhost: 127.0.0.1 */ -  if (!hptr) report("gethostbyname", 1); /* is hptr NULL? */ -  if (hptr->h_addrtype != AF_INET)       /* versus AF_LOCAL */ -    report("bad address family", 1); - -  /* connect to the server: configure server's address 1st */ -  struct sockaddr_in saddr; -  memset(&saddr, 0, sizeof(saddr)); -  saddr.sin_family = AF_INET; -  saddr.sin_addr.s_addr = -     ((struct in_addr*) hptr->h_addr_list[0])->s_addr; -  saddr.sin_port = htons(PortNumber); /* port number in big-endian */ - -  if (connect(sockfd, (struct sockaddr*) &saddr, sizeof(saddr)) < 0) -    report("connect", 1); - -  /* Write some stuff and read the echoes. */ -  puts("Connect to server, about to write some stuff..."); -  int i; -  for (i = 0; i < ConversationLen; i++) { -    if (write(sockfd, books[i], strlen(books[i])) > 0) { -      /* get confirmation echoed from server and print */ -      char buffer[BuffSize + 1]; -      memset(buffer, '\0', sizeof(buffer)); -      if (read(sockfd, buffer, sizeof(buffer)) > 0) -        puts(buffer); -    } -  } -  puts("Client done, about to exit..."); -  close(sockfd); /* close the connection */ -  return 0; -} -``` - -The client program's setup code is similar to the server's. The principal difference between the two is that the client neither listens nor accepts, but instead connects: - -``` -if (connect(sockfd, (struct sockaddr*) &saddr, sizeof(saddr)) < 0) -``` - -The **connect** call might fail for several reasons; for example, the client has the wrong server address or too many clients are already connected to the server. If the **connect** operation succeeds, the client writes requests and then reads the echoed responses in a **for** loop. After the conversation, both the server and the client **close** the read/write socket, although a close operation on either side is sufficient to close the connection. The client exits thereafter but, as noted earlier, the server remains open for business. - -The socket example, with request messages echoed back to the client, hints at the possibilities of arbitrarily rich conversations between the server and the client. Perhaps this is the chief appeal of sockets. It is common on modern systems for client applications (e.g., a database client) to communicate with a server through a socket. As noted earlier, local IPC sockets and network sockets differ only in a few implementation details; in general, IPC sockets have lower overhead and better performance. The communication API is essentially the same for both. - -### Signals - -A signal interrupts an executing program and, in this sense, communicates with it. Most signals can be either ignored (blocked) or handled (through designated code), with **SIGSTOP** (pause) and **SIGKILL** (terminate immediately) as the two notable exceptions. Symbolic constants such as **SIGKILL** have integer values, in this case, 9. - -Signals can arise in user interaction. For example, a user hits **Ctrl+C** from the command line to terminate a program started from the command-line; **Ctrl+C** generates a **SIGTERM** signal. **SIGTERM** for terminate, unlike **SIGKILL** , can be either blocked or handled. One process also can signal another, thereby making signals an IPC mechanism. - -Consider how a multi-processing application such as the Nginx web server might be shut down gracefully from another process. The **kill** function: - -``` -int kill(pid_t pid, int signum); /* declaration */ -``` - -can be used by one process to terminate another process or group of processes. If the first argument to function **kill** is greater than zero, this argument is treated as the pid (process ID) of the targeted process; if the argument is zero, the argument identifies the group of processes to which the signal sender belongs. - -The second argument to **kill** is either a standard signal number (e.g., **SIGTERM** or **SIGKILL** ) or 0, which makes the call to **signal** a query about whether the pid in the first argument is indeed valid. The graceful shutdown of a multi-processing application thus could be accomplished by sending a terminate signal—a call to the **kill** function with **SIGTERM** as the second argument—to the group of processes that make up the application. (The Nginx master process could terminate the worker processes with a call to **kill** and then exit itself.) The **kill** function, like so many library functions, houses power and flexibility in a simple invocation syntax. - -#### Example 3. The graceful shutdown of a multi-processing system - -``` -#include -#include -#include -#include -#include - -void graceful(int signum) { -  printf("\tChild confirming received signal: %i\n", signum); -  puts("\tChild about to terminate gracefully..."); -  sleep(1); -  puts("\tChild terminating now..."); -  _exit(0); /* fast-track notification of parent */ -} - -void set_handler() { -  struct sigaction current; -  sigemptyset(¤t.sa_mask);         /* clear the signal set */ -  current.sa_flags = 0;                  /* enables setting sa_handler, not sa_action */ -  current.sa_handler = graceful;         /* specify a handler */ -  sigaction(SIGTERM, ¤t, NULL);    /* register the handler */ -} - -void child_code() { -  set_handler(); - -  while (1) {   /** loop until interrupted **/ -    sleep(1); -    puts("\tChild just woke up, but going back to sleep."); -  } -} - -void parent_code(pid_t cpid) { -  puts("Parent sleeping for a time..."); -  sleep(5); - -  /* Try to terminate child. */ -  if (-1 == kill(cpid, SIGTERM)) { -    perror("kill"); -    exit(-1); -  } -  wait(NULL); /** wait for child to terminate **/ -  puts("My child terminated, about to exit myself..."); -} - -int main() { -  pid_t pid = fork(); -  if (pid < 0) { -    perror("fork"); -    return -1; /* error */ -  } -  if (0 == pid) -    child_code(); -  else -    parent_code(pid); -  return 0;  /* normal */ -} -``` - -The shutdown program above simulates the graceful shutdown of a multi-processing system, in this case, a simple one consisting of a parent process and a single child process. The simulation works as follows: - - * The parent process tries to fork a child. If the fork succeeds, each process executes its own code: the child executes the function **child_code** , and the parent executes the function **parent_code**. - * The child process goes into a potentially infinite loop in which the child sleeps for a second, prints a message, goes back to sleep, and so on. It is precisely a **SIGTERM** signal from the parent that causes the child to execute the signal-handling callback function **graceful**. The signal thus breaks the child process out of its loop and sets up the graceful termination of both the child and the parent. The child prints a message before terminating. - * The parent process, after forking the child, sleeps for five seconds so that the child can execute for a while; of course, the child mostly sleeps in this simulation. The parent then calls the **kill** function with **SIGTERM** as the second argument, waits for the child to terminate, and then exits. - - - -Here is the output from a sample run: - -``` -% ./shutdown -Parent sleeping for a time... -        Child just woke up, but going back to sleep. -        Child just woke up, but going back to sleep. -        Child just woke up, but going back to sleep. -        Child just woke up, but going back to sleep. -        Child confirming received signal: 15  ## SIGTERM is 15 -        Child about to terminate gracefully... -        Child terminating now... -My child terminated, about to exit myself... -``` - -For the signal handling, the example uses the **sigaction** library function (POSIX recommended) rather than the legacy **signal** function, which has portability issues. Here are the code segments of chief interest: - - * If the call to **fork** succeeds, the parent executes the **parent_code** function and the child executes the **child_code** function. The parent waits for five seconds before signaling the child: - -``` - puts("Parent sleeping for a time..."); -sleep(5); -if (-1 == kill(cpid, SIGTERM)) { -...sleepkillcpidSIGTERM... -``` - -If the **kill** call succeeds, the parent does a **wait** on the child's termination to prevent the child from becoming a permanent zombie; after the wait, the parent exits. - - * The **child_code** function first calls **set_handler** and then goes into its potentially infinite sleeping loop. Here is the **set_handler** function for review: - -``` - void set_handler() { -  struct sigaction current;            /* current setup */ -  sigemptyset(¤t.sa_mask);       /* clear the signal set */ -  current.sa_flags = 0;                /* for setting sa_handler, not sa_action */ -  current.sa_handler = graceful;       /* specify a handler */ -  sigaction(SIGTERM, ¤t, NULL);  /* register the handler */ -} -``` - -The first three lines are preparation. The fourth statement sets the handler to the function **graceful** , which prints some messages before calling **_exit** to terminate. The fifth and last statement then registers the handler with the system through the call to **sigaction**. The first argument to **sigaction** is **SIGTERM** for terminate, the second is the current **sigaction** setup, and the last argument ( **NULL** in this case) can be used to save a previous **sigaction** setup, perhaps for later use. - - - - -Using signals for IPC is indeed a minimalist approach, but a tried-and-true one at that. IPC through signals clearly belongs in the IPC toolbox. - -### Wrapping up this series - -These three articles on IPC have covered the following mechanisms through code examples: - - * Shared files - * Shared memory (with semaphores) - * Pipes (named and unnamed) - * Message queues - * Sockets - * Signals - - - -Even today, when thread-centric languages such as Java, C#, and Go have become so popular, IPC remains appealing because concurrency through multi-processing has an obvious advantage over multi-threading: every process, by default, has its own address space, which rules out memory-based race conditions in multi-processing unless the IPC mechanism of shared memory is brought into play. (Shared memory must be locked in both multi-processing and multi-threading for safe concurrency.) Anyone who has written even an elementary multi-threading program with communication via shared variables knows how challenging it can be to write thread-safe yet clear, efficient code. Multi-processing with single-threaded processes remains a viable—indeed, quite appealing—way to take advantage of today's multi-processor machines without the inherent risk of memory-based race conditions. - -There is no simple answer, of course, to the question of which among the IPC mechanisms is the best. Each involves a trade-off typical in programming: simplicity versus functionality. Signals, for example, are a relatively simple IPC mechanism but do not support rich conversations among processes. If such a conversion is needed, then one of the other choices is more appropriate. Shared files with locking is reasonably straightforward, but shared files may not perform well enough if processes need to share massive data streams; pipes or even sockets, with more complicated APIs, might be a better choice. Let the problem at hand guide the choice. - -Although the sample code ([available on my website][4]) is all in C, other programming languages often provide thin wrappers around these IPC mechanisms. The code examples are short and simple enough, I hope, to encourage you to experiment. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/4/interprocess-communication-linux-networking - -作者:[Marty Kalin][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/mkalindepauledu -[b]: https://github.com/lujun9972 -[1]: https://en.wikipedia.org/wiki/Inter-process_communication -[2]: https://opensource.com/article/19/4/interprocess-communication-ipc-linux-part-1 -[3]: https://opensource.com/article/19/4/interprocess-communication-ipc-linux-part-2 -[4]: http://condor.depaul.edu/mkalin diff --git a/sources/tech/20190422 4 open source apps for plant-based diets.md b/sources/tech/20190422 4 open source apps for plant-based diets.md deleted file mode 100644 index 6d77b66eea..0000000000 --- a/sources/tech/20190422 4 open source apps for plant-based diets.md +++ /dev/null @@ -1,68 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (4 open source apps for plant-based diets) -[#]: via: (https://opensource.com/article/19/4/apps-plant-based-diets) -[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) - -4 open source apps for plant-based diets -====== -These apps make it easier for vegetarians and vegans—and omnivores who -want to eat healthier—to find food they can eat. -![][1] - -Reducing your consumption of meat, dairy, and processed foods is better for the planet and better for your health. Changing your diet can be difficult, but several open source Android applications can help you switch to a more plant-based diet. Whether you are taking part in [Meatless Monday][2], following Mark Bittman's [Vegan Before 6:00][3] guidelines, or switching entirely to a [whole-food, plant-based diet][4], these apps can aid you on your journey by helping you figure out what to eat, discover vegan- and vegetarian-friendly restaurants, and easily communicate your dietary preferences to others. All of these apps are open source and available from the [F-Droid repository][5]. - -### Daily Dozen - -![Daily Dozen app][6] - -The [Daily Dozen][7] app provides a checklist of items that Michael Greger, MD, FACLM, recommends as part of a healthy diet and lifestyle. Dr. Greger recommends consuming a whole-food, plant-based diet consisting of diverse foods and supported by daily exercise. This app lets you keep track of how many servings of each type of food you have eaten, how many servings of water (or other approved beverage, such as tea) you drank, and if you exercised each day. Each category of food provides serving sizes and lists of foods that fall under that category; for example, the Cruciferous Vegetable category includes bok choy, broccoli, brussels sprouts, and many other suggestions. - -### Food Restrictions - -![Food Restrictions app][8] - -[Food Restrictions][9] is a simple app that can help you communicate your dietary restrictions to others, even if those people do not speak your language. Users can enter their food restrictions for seven different categories: chicken, beef, pork, fish, cheese, milk, and peppers. There is an "I don't eat" and an "I'm allergic" option for each of those categories. The "don't eat" option shows the icon with a red X over it. The "allergic" option displays the X and a small skull icon. The same information can be displayed using text instead of icons, but the text is only available in English and Portuguese. There is also an option for displaying a text message that says the user is vegetarian or vegan, which summarizes those dietary restrictions more succinctly and more accurately than the pick-and-choose options. The vegan text clearly mentions not eating eggs and honey, which are not options in the pick-and-choose method. However, just like the text version of the pick-and-choose option, these sentences are only available in English and Portuguese. - -### OpenFoodFacts - -![Open Food Facts app][10] - -Avoiding unwanted ingredients when buying groceries can be frustrating, but [OpenFoodFacts][11] can help make the process easier. This app lets you scan the barcodes on products to get a report about the ingredients in a product and how healthy the product is. A product can still be very unhealthy even if it meets the criteria to be a vegan product. Having both the ingredients list and the nutrition facts lets you make informed choices when shopping. The only drawback for this app is that the data is user contributed, so not every product is available, but you can contribute new items, if you want to give back to the project. - -### OpenVegeMap - -![OpenVegeMap app][12] - -Find vegan and vegetarian restaurants in your neighborhood with the [OpenVegeMap][13] app. This app lets you search by either using your phone's current location or by entering an address. Restaurants are classified as Vegan only, Vegan friendly, Vegetarian only, Vegetarian friendly, Non-vegetarian, and Unknown. The app uses data from [OpenStreetMap][14] and user-contributed information about the restaurants, so be sure to double-check to make sure the information provided is up-to-date and accurate. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/4/apps-plant-based-diets - -作者:[Joshua Allen Holm ][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/holmja -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003588_01_rd3os.combacktoschoolserieshe_rh_041x_0.png?itok=tfg6_I78 -[2]: https://www.meatlessmonday.com/ -[3]: https://www.amazon.com/dp/0385344740/ -[4]: https://nutritionstudies.org/whole-food-plant-based-diet-guide/ -[5]: https://f-droid.org/ -[6]: https://opensource.com/sites/default/files/uploads/daily_dozen.png (Daily Dozen app) -[7]: https://f-droid.org/en/packages/org.nutritionfacts.dailydozen/ -[8]: https://opensource.com/sites/default/files/uploads/food_restrictions.png (Food Restrictions app) -[9]: https://f-droid.org/en/packages/br.com.frs.foodrestrictions/ -[10]: https://opensource.com/sites/default/files/uploads/openfoodfacts.png (Open Food Facts app) -[11]: https://f-droid.org/en/packages/openfoodfacts.github.scrachx.openfood/ -[12]: https://opensource.com/sites/default/files/uploads/openvegmap.png (OpenVegeMap app) -[13]: https://f-droid.org/en/packages/pro.rudloff.openvegemap/ -[14]: https://www.openstreetmap.org/ diff --git a/sources/tech/20190423 Epic Games Store is Now Available on Linux Thanks to Lutris.md b/sources/tech/20190423 Epic Games Store is Now Available on Linux Thanks to Lutris.md deleted file mode 100644 index b8432c522e..0000000000 --- a/sources/tech/20190423 Epic Games Store is Now Available on Linux Thanks to Lutris.md +++ /dev/null @@ -1,135 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Epic Games Store is Now Available on Linux Thanks to Lutris) -[#]: via: (https://itsfoss.com/epic-games-lutris-linux/) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) - -Epic Games Store is Now Available on Linux Thanks to Lutris -====== - -_**Brief: Open Source gaming platform Lutris now enables you to use Epic Games Store on Linux. We tried it on Ubuntu 19.04 and here’s our experience with it.**_ - -[Gaming on Linux][1] just keeps getting better. Want to [play Windows games on Linux][2], Steam’s new [in-progress feature][3] enables you to do that. - -Steam might be new in the field of Windows games on Linux but Lutris has been doing it for years. - -[Lutris][4] is an open source gaming platform for Linux where it provides installers for game clients like Origin, Steam, Blizzard.net app and so on. It utilizes Wine to run stuff that isn’t natively supported on Linux. - -Lutris has recently announced that you can now use Epic Games Store using Lutris. - -### Lutris brings Epic Games to Linux - -![Epic Games Store Lutris Linux][5] - -[Epic Games Store][6] is a digital video game distribution platform like Steam. It only supports Windows and macOS for the moment. - -The Lutris team worked hard to bring Epic Games Store to Linux via Lutris. Even though I’m not a big fan of Epic Games Store, it was good to know about the support for Linux via Lutris: - -> Good news! [@EpicGames][7] Store is now fully functional under Linux if you use Lutris to install it! No issues observed whatsoever. [@TimSweeneyEpic][8] will probably like this 😊 [pic.twitter.com/7mt9fXt7TH][9] -> -> — Lutris Gaming (@LutrisGaming) [April 17, 2019][10] - -As an avid gamer and Linux user, I immediately jumped upon this news and installed Lutris to run Epic Games on it. - -**Note:** _I used[Ubuntu 19.04][11] to test Epic Games store for Linux._ - -### Using Epic Games Store for Linux using Lutris - -To install Epic Games Store on your Linux system, make sure that you have [Lutris][4] installed with its pre-requisites Wine and Python 3. So, first [install Wine on Ubuntu][12] or whichever Linux you are using and then [download Lutris from its website][13]. - -[][14] - -Suggested read Ubuntu Mate Will Be Default OS On Entroware Laptops - -#### Installing Epic Games Store - -Once the installation of Lutris is successful, simply launch it. - -While I tried this, I encountered an error (nothing happened when I tried to launch it using the GUI). However, when I typed in “ **lutris** ” on the terminal to launch it otherwise, I noticed an error that looked like this: - -![][15] - -Thanks to Abhishek, I learned that this is a common issue (you can check that on [GitHub][16]). - -So, to fix it, all I had to do was – type in a command in the terminal: - -``` -export LC_ALL=C -``` - -Just copy it and enter it in your terminal if you face the same issue. And, then, you will be able to open Lutris. - -**Note:** _You’ll have to enter this command every time you launch Lutris. So better to add it to your .bashrc or list of environment variable._ - -Once that is done, simply launch it and search for “ **Epic Games Store** ” as shown in the image below: - -![Epic Games Store in Lutris][17] - -Here, I have it installed already, so you will get the option to “Install” it and then it will automatically ask you to install the required packages that it needs. You just have to proceed in order to successfully install it. That’s it – no rocket science involved. - -#### Playing a Game on Epic Games Store - -![Epic Games Store][18] - -Now that we have Epic Games store via Lutris on Linux, simply launch it and log in to your account to get started. - -But, does it really work? - -_Yes, the Epic Games Store does work._ **But, all the games don’t.** - -Well, I haven’t tried everything, but I grabbed a free game (Transistor – a turn-based ARPG game) to check if that works. - -![Transistor – Epic Games Store][19] - -Unfortunately, it didn’t. It says that it is “Running” when I launch it but then again, nothing happens. - -As of now, I’m not aware of any solutions to that – so I’ll try to keep you guys updated if I find a fix. - -[][20] - -Suggested read Alpha Version Of New Skype Client For Linux Is Out Now - -**Wrapping Up** - -It’s good to see the gaming scene improve on Linux thanks to the solutions like Lutris for users. However, there’s still a lot of work to be done. - -For a game to run hassle-free on Linux is still a challenge. There can be issues like this which I encountered or similar. But, it’s going in the right direction – even if it has issues. - -What do you think of Epic Games Store on Linux via Lutris? Have you tried it yet? Let us know your thoughts in the comments below. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/epic-games-lutris-linux/ - -作者:[Ankush Das][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/linux-gaming-guide/ -[2]: https://itsfoss.com/steam-play/ -[3]: https://itsfoss.com/steam-play-proton/ -[4]: https://lutris.net/ -[5]: https://itsfoss.com/wp-content/uploads/2019/04/epic-games-store-lutris-linux-800x450.png -[6]: https://www.epicgames.com/store/en-US/ -[7]: https://twitter.com/EpicGames?ref_src=twsrc%5Etfw -[8]: https://twitter.com/TimSweeneyEpic?ref_src=twsrc%5Etfw -[9]: https://t.co/7mt9fXt7TH -[10]: https://twitter.com/LutrisGaming/status/1118552969816018948?ref_src=twsrc%5Etfw -[11]: https://itsfoss.com/ubuntu-19-04-release-features/ -[12]: https://itsfoss.com/install-latest-wine/ -[13]: https://lutris.net/downloads/ -[14]: https://itsfoss.com/ubuntu-mate-entroware/ -[15]: https://itsfoss.com/wp-content/uploads/2019/04/lutris-error.jpg -[16]: https://github.com/lutris/lutris/issues/660 -[17]: https://itsfoss.com/wp-content/uploads/2019/04/lutris-epic-games-store-800x520.jpg -[18]: https://itsfoss.com/wp-content/uploads/2019/04/epic-games-store-800x450.jpg -[19]: https://itsfoss.com/wp-content/uploads/2019/04/transistor-game-epic-games-store-800x410.jpg -[20]: https://itsfoss.com/skpe-alpha-linux/ diff --git a/sources/tech/20190427 Monitoring CPU and GPU Temperatures on Linux.md b/sources/tech/20190427 Monitoring CPU and GPU Temperatures on Linux.md deleted file mode 100644 index 89f942ce66..0000000000 --- a/sources/tech/20190427 Monitoring CPU and GPU Temperatures on Linux.md +++ /dev/null @@ -1,166 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Monitoring CPU and GPU Temperatures on Linux) -[#]: via: (https://itsfoss.com/monitor-cpu-gpu-temp-linux/) -[#]: author: (It's FOSS Community https://itsfoss.com/author/itsfoss/) - -Monitoring CPU and GPU Temperatures on Linux -====== - -_**Brief: This articles discusses two simple ways of monitoring CPU and GPU temperatures in Linux command line.**_ - -Because of **[Steam][1]** (including _[Steam Play][2]_ , aka _Proton_ ) and other developments, **GNU/Linux** is becoming the gaming platform of choice for more and more computer users everyday. A good number of users are also going for **GNU/Linux** when it comes to other resource-consuming computing tasks such as [video editing][3] or graphic design ( _Kdenlive_ and _[Blender][4]_ are good examples of programs for these). - -Whether you are one of those users or otherwise, you are bound to have wondered how hot your computer’s CPU and GPU can get (even more so if you do overclocking). If that is the case, keep reading. We will be looking at a couple of very simple commands to monitor CPU and GPU temps. - -My setup includes a [Slimbook Kymera][5] and two displays (a TV set and a PC monitor) which allows me to use one for playing games and the other to keep an eye on the temperatures. Also, since I use [Zorin OS][6] I will be focusing on **Ubuntu** and **Ubuntu** derivatives. - -To monitor the behaviour of both CPU and GPU we will be making use of the useful `watch` command to have dynamic readings every certain number of seconds. - -![][7] - -### Monitoring CPU Temperature in Linux - -For CPU temps, we will combine `watch` with the `sensors` command. An interesting article about a [gui version of this tool has already been covered on It’s FOSS][8]. However, we will use the terminal version here: - -``` -watch -n 2 sensors -``` - -`watch` guarantees that the readings will be updated every 2 seconds (and this value can — of course — be changed to what best fit your needs): - -``` -Every 2,0s: sensors - -iwlwifi-virtual-0 -Adapter: Virtual device -temp1: +39.0°C - -acpitz-virtual-0 -Adapter: Virtual device -temp1: +27.8°C (crit = +119.0°C) -temp2: +29.8°C (crit = +119.0°C) - -coretemp-isa-0000 -Adapter: ISA adapter -Package id 0: +37.0°C (high = +82.0°C, crit = +100.0°C) -Core 0: +35.0°C (high = +82.0°C, crit = +100.0°C) -Core 1: +35.0°C (high = +82.0°C, crit = +100.0°C) -Core 2: +33.0°C (high = +82.0°C, crit = +100.0°C) -Core 3: +36.0°C (high = +82.0°C, crit = +100.0°C) -Core 4: +37.0°C (high = +82.0°C, crit = +100.0°C) -Core 5: +35.0°C (high = +82.0°C, crit = +100.0°C) -``` - -Amongst other things, we get the following information: - - * We have 5 cores in use at the moment (with the current highest temperature being 37.0ºC). - * Values higher than 82.0ºC are considered high. - * A value over 100.0ºC is deemed critical. - - - -[][9] - -Suggested read Top 10 Command Line Games For Linux - -The values above lead us to the conclusion that the computer’s workload is very light at the moment. - -### Monitoring GPU Temperature in Linux - -Let us turn to the graphics card now. I have never used an **AMD** dedicated graphics card, so I will be focusing on **Nvidia** ones. The first thing to do is download the appropriate, current driver through [additional drivers in Ubuntu][10]. - -On **Ubuntu** (and its forks such as **Zorin** or **Linux Mint** ), going to _Software & Updates_ > _Additional Drivers_ and selecting the most recent one normally suffices. Additionally, you can add/enable the official _ppa_ for graphics cards (either through the command line or via _Software & Updates_ > _Other Software_ ). After installing the driver you will have at your disposal the _Nvidia X Server_ gui application along with the command line utility _nvidia-smi_ (Nvidia System Management Interface). So we will use `watch` and `nvidia-smi`: - -``` -watch -n 2 nvidia-smi -``` - -And — the same as for the CPU — we will get updated readings every two seconds: - -``` -Every 2,0s: nvidia-smi - -Fri Apr 19 20:45:30 2019 -+-----------------------------------------------------------------------------+ -| Nvidia-SMI 418.56 Driver Version: 418.56 CUDA Version: 10.1 | -|-------------------------------+----------------------+----------------------+ -| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | -| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | -|===============================+======================+======================| -| 0 GeForce GTX 106... Off | 00000000:01:00.0 On | N/A | -| 0% 54C P8 10W / 120W | 433MiB / 6077MiB | 4% Default | -+-------------------------------+----------------------+----------------------+ - -+-----------------------------------------------------------------------------+ -| Processes: GPU Memory | -| GPU PID Type Process name Usage | -|=============================================================================| -| 0 1557 G /usr/lib/xorg/Xorg 190MiB | -| 0 1820 G /usr/bin/gnome-shell 174MiB | -| 0 7820 G ...equest-channel-token=303407235874180773 65MiB | -+-----------------------------------------------------------------------------+ -``` - -The chart gives the following information about the graphics card: - - * it is using the open source driver version 418.56. - * the current temperature of the card is 54.0ºC — with the fan at 0% of its capacity. - * the power consumption is very low: only 10W. - * out of 6 GB of vram (video random access memory), it is only using 433 MB. - * the used vram is being taken by three processes whose IDs are — respectively — 1557, 1820 and 7820. - - - -[][11] - -Suggested read Googler: Now You Can Google From Linux Terminal! - -Most of these facts/values show that — clearly — we are not playing any resource-consuming games or dealing with heavy workloads. Should we started playing a game, processing a video — or the like —, the values would start to go up. - -#### Conclusion - -Althoug there are gui tools, I find these two commands very handy to check on your hardware in real time. - -What do you make of them? You can learn more about the utilities involved by reading their man pages. - -Do you have other preferences? Share them with us in the comments, ;). - -Halof!!! (Have a lot of fun!!!). - -![avatar][12] - -### Alejandro Egea-Abellán - -It’s FOSS Community Contributor - -I developed a liking for electronics, linguistics, herpetology and computers (particularly GNU/Linux and FOSS). I am LPIC-2 certified and currently work as a technical consultant and Moodle administrator in the Department for Lifelong Learning at the Ministry of Education in Murcia, Spain. I am a firm believer in lifelong learning, the sharing of knowledge and computer-user freedom. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/monitor-cpu-gpu-temp-linux/ - -作者:[It's FOSS Community][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/itsfoss/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/install-steam-ubuntu-linux/ -[2]: https://itsfoss.com/steam-play-proton/ -[3]: https://itsfoss.com/best-video-editing-software-linux/ -[4]: https://www.blender.org/ -[5]: https://slimbook.es/ -[6]: https://zorinos.com/ -[7]: https://itsfoss.com/wp-content/uploads/2019/04/monitor-cpu-gpu-temperature-linux-800x450.png -[8]: https://itsfoss.com/check-laptop-cpu-temperature-ubuntu/ -[9]: https://itsfoss.com/best-command-line-games-linux/ -[10]: https://itsfoss.com/install-additional-drivers-ubuntu/ -[11]: https://itsfoss.com/review-googler-linux/ -[12]: https://itsfoss.com/wp-content/uploads/2019/04/EGEA-ABELLAN-Alejandro.jpg diff --git a/sources/tech/20190428 Installing Budgie Desktop on Ubuntu -Quick Guide.md b/sources/tech/20190428 Installing Budgie Desktop on Ubuntu -Quick Guide.md deleted file mode 100644 index 11659592fb..0000000000 --- a/sources/tech/20190428 Installing Budgie Desktop on Ubuntu -Quick Guide.md +++ /dev/null @@ -1,116 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Installing Budgie Desktop on Ubuntu [Quick Guide]) -[#]: via: (https://itsfoss.com/install-budgie-ubuntu/) -[#]: author: (Atharva Lele https://itsfoss.com/author/atharva/) - -Installing Budgie Desktop on Ubuntu [Quick Guide] -====== - -_**Brief: Learn how to install Budgie desktop on Ubuntu in this step-by-step tutorial.**_ - -Among all the [various Ubuntu versions][1], [Ubuntu Budgie][2] is the most underrated one. It looks elegant and it’s not heavy on resources. - -Read this [Ubuntu Budgie review][3] or simply watch this video to see what Ubuntu Budgie 18.04 looks like. - -[Subscribe to our YouTube channel for more Linux Videos][4] - -If you like [Budgie desktop][5] but you are using some other version of Ubuntu such as the default Ubuntu with GNOME desktop, I have good news for you. You can install Budgie on your current Ubuntu system and switch the desktop environments. - -In this post, I’m going to tell you exactly how to do that. But first, a little introduction to Budgie for those who are unaware about it. - -Budgie desktop environment is developed mainly by [Solus Linux team.][6] It is designed with focus on elegance and modern usage. Budgie is available for all major Linux distributions for users to try and experience this new desktop environment. Budgie is pretty mature by now and provides a great desktop experience. - -Warning - -Installing multiple desktops on the same system MAY result in conflicts and you may see some issue like missing icons in the panel or multiple icons of the same program. - -You may not see any issue at all as well. It’s your call if you want to try different desktop. - -### Install Budgie on Ubuntu - -This method is not tested on Linux Mint, so I recommend that you not follow this guide for Mint. - -For those on Ubuntu, Budgie is now a part of the Ubuntu repositories by default. Hence, we don’t need to add any PPAs in order to get Budgie. - -To install Budgie, simply run this command in terminal. We’ll first make sure that the system is fully updated. - -``` -sudo apt update && sudo apt upgrade -sudo apt install ubuntu-budgie-desktop -``` - -When everything is done downloading, you will get a prompt to choose your display manager. Select ‘lightdm’ to get the full Budgie experience. - -![Select lightdm][7] - -After the installation is complete, reboot your computer. You will be then greeted by the Budgie login screen. Enter your password to go into the homescreen. - -![Budgie Desktop Home][8] - -### Switching to other desktop environments - -![Budgie login screen][9] - -You can click the Budgie icon next to your name to get options for login. From there you can select between the installed Desktop Environments (DEs). In my case, I see Budgie and the default Ubuntu (GNOME) DEs. - -![Select your DE][10] - -Hence whenever you feel like logging into GNOME, you can do so using this menu. - -[][11] - -Suggested read Get Rid of 'snapd returned status code 400: Bad Request' Error in Ubuntu - -### How to Remove Budgie - -If you don’t like Budgie or just want to go back to your regular old Ubuntu, you can switch back to your regular desktop as described in the above section. - -However, if you really want to remove Budgie and its component, you can follow the following commands to get back to a clean slate. - -_**Switch to some other desktop environments before using these commands:**_ - -``` -sudo apt remove ubuntu-budgie-desktop ubuntu-budgie* lightdm -sudo apt autoremove -sudo apt install --reinstall gdm3 -``` - -After running all the commands successfully, reboot your computer. - -Now, you will be back to GNOME or whichever desktop environment you had. - -**What you think of Budgie?** - -Budgie is one of the [best desktop environments for Linux][12]. Hope this short guide helped you install the awesome Budgie desktop on your Ubuntu system. - -If you did install Budgie, what do you like about it the most? Let us know in the comments below. And as usual, any questions or suggestions are always welcome. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/install-budgie-ubuntu/ - -作者:[Atharva Lele][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/atharva/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/which-ubuntu-install/ -[2]: https://ubuntubudgie.org/ -[3]: https://itsfoss.com/ubuntu-budgie-18-review/ -[4]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 -[5]: https://github.com/solus-project/budgie-desktop -[6]: https://getsol.us/home/ -[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/04/budgie_install_select_dm.png?fit=800%2C559&ssl=1 -[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/04/budgie_homescreen.jpg?fit=800%2C500&ssl=1 -[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/04/budgie_install_lockscreen.png?fit=800%2C403&ssl=1 -[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/04/budgie_install_lockscreen_select_de.png?fit=800%2C403&ssl=1 -[11]: https://itsfoss.com/snapd-error-ubuntu/ -[12]: https://itsfoss.com/best-linux-desktop-environments/ diff --git a/sources/tech/20190429 How To Turn On And Shutdown The Raspberry Pi -Absolute Beginner Tip.md b/sources/tech/20190429 How To Turn On And Shutdown The Raspberry Pi -Absolute Beginner Tip.md deleted file mode 100644 index ce667a1dff..0000000000 --- a/sources/tech/20190429 How To Turn On And Shutdown The Raspberry Pi -Absolute Beginner Tip.md +++ /dev/null @@ -1,111 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How To Turn On And Shutdown The Raspberry Pi [Absolute Beginner Tip]) -[#]: via: (https://itsfoss.com/turn-on-raspberry-pi/) -[#]: author: (Chinmay https://itsfoss.com/author/chinmay/) - -How To Turn On And Shutdown The Raspberry Pi [Absolute Beginner Tip] -====== - -_**Brief: This quick tip teaches you how to turn on Raspberry Pi and how to shut it down properly afterwards.**_ - -The [Raspberry Pi][1] is one of the [most popular SBC (Single-Board-Computer)][2]. If you are interested in this topic, I believe that you’ve finally got a Pi device. I also advise to get all the [additional Raspberry Pi accessories][3] to get started with your device. - -You’re ready to turn it on and start to tinker around with it. It has it’s own similarities and differences compared to traditional computers like desktops and laptops. - -Today, let’s go ahead and learn how to turn on and shutdown a Raspberry Pi as it doesn’t really feature a ‘power button’ of sorts. - -For this article I’m using a Raspberry Pi 3B+, but it’s the same for all the Raspberry Pi variants. - -Bestseller No. 1 - -[][4] - -[CanaKit Raspberry Pi 3 B+ (B Plus) Starter Kit (32 GB EVO+ Edition, Premium Black Case)][4] - -CanaKit - Personal Computers - -$79.99 [][5] - -Bestseller No. 2 - -[][6] - -[CanaKit Raspberry Pi 3 B+ (B Plus) with Premium Clear Case and 2.5A Power Supply][6] - -CanaKit - Personal Computers - -$54.99 [][5] - -### Turn on Raspberry Pi - -![Micro USB port for Power][7] - -The micro USB port powers the Raspberry Pi, the way you turn it on is by plugging in the power cable into the micro USB port. But, before you do that you should make sure that you have done the following things. - - * Preparing the micro SD card with Raspbian according to the official [guide][8] and inserting into the micro SD card slot. - * Plugging in the HDMI cable, USB keyboard and a Mouse. - * Plugging in the Ethernet Cable(Optional). - - - -Once you have done the above, plug in the power cable. This turns on the Raspberry Pi and the display will light up and load the Operating System. - -Bestseller No. 1 - -[][4] - -[CanaKit Raspberry Pi 3 B+ (B Plus) Starter Kit (32 GB EVO+ Edition, Premium Black Case)][4] - -CanaKit - Personal Computers - -$79.99 [][5] - -### Shutting Down the Pi - -Shutting down the Pi is pretty straight forward, click the menu button and choose shutdown. - -![Turn off Raspberry Pi graphically][9] - -Alternatively, you can use the [shutdown command][10] in the terminal: - -``` -sudo shutdown now -``` - -Once the shutdown process has started **wait** till it completely finishes and then you can cut the power to it. Once the Pi shuts down, there is no real way to turn the Pi back on without turning off and turning on the power. You could the GPIO’s to turn on the Pi from the shutdown state but it’ll require additional modding. - -[][2] - -Suggested read 12 Single Board Computers: Alternative to Raspberry Pi - -_Note: Micro USB ports tend to be fragile, hence turn-off/on the power at source instead of frequently unplugging and plugging into the micro USB port._ - -Well, that’s about all you should know about turning on and shutting down the Pi, what do you plan to use it for? Let me know in the comments. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/turn-on-raspberry-pi/ - -作者:[Chinmay][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/chinmay/ -[b]: https://github.com/lujun9972 -[1]: https://www.raspberrypi.org/ -[2]: https://itsfoss.com/raspberry-pi-alternatives/ -[3]: https://itsfoss.com/things-you-need-to-get-your-raspberry-pi-working/ -[4]: https://www.amazon.com/CanaKit-Raspberry-Starter-Premium-Black/dp/B07BCC8PK7?SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B07BCC8PK7&keywords=raspberry%20pi%20kit (CanaKit Raspberry Pi 3 B+ (B Plus) Starter Kit (32 GB EVO+ Edition, Premium Black Case)) -[5]: https://www.amazon.com/gp/prime/?tag=chmod7mediate-20 (Amazon Prime) -[6]: https://www.amazon.com/CanaKit-Raspberry-Premium-Clear-Supply/dp/B07BC7BMHY?SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B07BC7BMHY&keywords=raspberry%20pi%20kit (CanaKit Raspberry Pi 3 B+ (B Plus) with Premium Clear Case and 2.5A Power Supply) -[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/04/raspberry-pi-3-microusb.png?fit=800%2C532&ssl=1 -[8]: https://www.raspberrypi.org/documentation/installation/installing-images/README.md -[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/04/Raspbian-ui-menu.jpg?fit=800%2C492&ssl=1 -[10]: https://linuxhandbook.com/linux-shutdown-command/ diff --git a/sources/tech/20190430 The Awesome Fedora 30 is Here- Check Out the New Features.md b/sources/tech/20190430 The Awesome Fedora 30 is Here- Check Out the New Features.md deleted file mode 100644 index 3d158c7031..0000000000 --- a/sources/tech/20190430 The Awesome Fedora 30 is Here- Check Out the New Features.md +++ /dev/null @@ -1,115 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (The Awesome Fedora 30 is Here! Check Out the New Features) -[#]: via: (https://itsfoss.com/fedora-30/) -[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) - -The Awesome Fedora 30 is Here! Check Out the New Features -====== - -The latest and greatest release of Fedora is here. Fedora 30 brings some visual as well as performance improvements. - -Fedora releases a new version every six months and each release is supported for thirteen months. - -Before you decide to download or upgrade Fedora, let’s first see what’s new in Fedora 30. - -### New Features in Fedora 30 - -![Fedora 30 Release][1] - -Here’s what’s new in the latest release of Fedora. - -#### GNOME 3.32 gives a brand new look, features and performance improvement - -A lot of visual improvements is brought by the latest release of GNOME. - -GNOME 3.32 has refreshed new icons and UI and it almost looks like a brand new version of GNOME. - -![Gnome 3.32 icons | Image Credit][2] - -GNOME 3.32 also brings several other features like fractional scaling, permission control for each application, granular control on Night Light intensity among many other changes. - -GNOME 3.32 also brings some performance improvements. You’ll see faster file and app searches and a smoother scrolling. - -#### Improved performance for DNF - -Fedora 30 will see a faster [DNF][3] (the default package manager for Fedora) thanks to the [zchunk][4] compression algorithm. - -The zchunk algorithm splits the file into independent chunks. This helps in dealing with ‘delta’ or changes as you download only the changed chunks while downloading the new version of a file. - -With zcunk, dnf will only download the difference between the metadata of the current version and the earlier versions. - -#### Fedora 30 brings two new desktop environments into the fold - -Fedora already offers several desktop environment choices. Fedora 30 extends the offering with [elementary OS][5]‘ Pantheon desktop environment and Deepin Linux’ [DeepinDE][6]. - -So now you can enjoy the looks and feel of elementary OS and Deepin Linux in Fedora. How cool is that! - -#### Linux Kernel 5 - -Fedora 29 has Linux Kernel 5.0.9 version that has improved support for hardware and some performance improvements. You may check out the [features of Linux kernel 5.0 in this article][7]. - -[][8] - -Suggested read The Featureful Release of Nextcloud 14 Has Two New Security Features - -#### Updated software - -You’ll also get newer versions of software. Some of the major ones are: - - * GCC 9.0.1 - * [Bash Shell 5.0][9] - * GNU C Library 2.29 - * Ruby 2.6 - * Golang 1.12 - * Mesa 19.0.2 - - - * Vagrant 2.2 - * JDK12 - * PHP 7.3 - * Fish 3.0 - * Erlang 21 - * Python 3.7.3 - - - -### Getting Fedora 30 - -If you are already using Fedora 29 then you can upgrade to the latest release from your current install. You may follow this guide to learn [how to upgrade a Fedora version][10]. - -Fedora 29 users will still get the updates for seven more months so if you don’t feel like upgrading, you may skip it for now. Fedora 28 users have no choice because Fedora 28 reached end of life next month which means there will be no security or maintenance update anymore. Upgrading to a newer version is no longer a choice. - -You always has the option to download the ISO of Fedora 30 and install it afresh. You can download Fedora from its official website. It’s only available for 64-bit systems and the ISO is 1.9 GB in size. - -[Download Fedora 30 Workstation][11] - -What do you think of Fedora 30? Are you planning to upgrade or at least try it out? Do share your thoughts in the comment section. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/fedora-30/ - -作者:[Abhishek Prakash][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/abhishek/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/wp-content/uploads/2019/04/fedora-30-release-800x450.png -[2]: https://itsfoss.com/wp-content/uploads/2019/04/gnome-3-32-icons.png -[3]: https://fedoraproject.org/wiki/DNF?rd=Dnf -[4]: https://github.com/zchunk/zchunk -[5]: https://itsfoss.com/elementary-os-juno-features/ -[6]: https://www.deepin.org/en/dde/ -[7]: https://itsfoss.com/linux-kernel-5/ -[8]: https://itsfoss.com/nextcloud-14-release/ -[9]: https://itsfoss.com/bash-5-release/ -[10]: https://itsfoss.com/upgrade-fedora-version/ -[11]: https://getfedora.org/en/workstation/ diff --git a/sources/tech/20190501 3 apps to manage personal finances in Fedora.md b/sources/tech/20190501 3 apps to manage personal finances in Fedora.md deleted file mode 100644 index afa5eb889f..0000000000 --- a/sources/tech/20190501 3 apps to manage personal finances in Fedora.md +++ /dev/null @@ -1,73 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (3 apps to manage personal finances in Fedora) -[#]: via: (https://fedoramagazine.org/3-apps-to-manage-personal-finances-in-fedora/) -[#]: author: (Paul W. Frields https://fedoramagazine.org/author/pfrields/) - -3 apps to manage personal finances in Fedora -====== - -![][1] - -There are numerous services available on the web for managing your personal finances. Although they may be convenient, they also often mean leaving your most valuable personal data with a company you can’t monitor. Some people are comfortable with this level of trust. - -Whether you are or not, you might be interested in an app you can maintain on your own system. This means your data never has to leave your own computer if you don’t want. One of these three apps might be what you’re looking for. - -### HomeBank - -HomeBank is a fully featured way to manage multiple accounts. It’s easy to set up and keep updated. It has multiple ways to categorize and graph income and liabilities so you can see where your money goes. It’s available through the official Fedora repositories. - -![A simple account set up in HomeBank with a few transactions.][2] - -To install HomeBank, open the _Software_ app, search for _HomeBank_ , and select the app. Then click _Install_ to add it to your system. HomeBank is also available via a Flatpak. - -### KMyMoney - -The KMyMoney app is a mature app that has been around for a long while. It has a robust set of features to help you manage multiple accounts, including assets, liabilities, taxes, and more. KMyMoney includes a full set of tools for managing investments and making forecasts. It also sports a huge set of reports for seeing how your money is doing. - -![A subset of the many reports available in KMyMoney.][3] - -To install, use a software center app, or use the command line: - -``` -$ sudo dnf install kmymoney -``` - -### GnuCash - -One of the most venerable free GUI apps for personal finance is GnuCash. GnuCash is not just for personal finances. It also has functions for managing income, assets, and liabilities for a business. That doesn’t mean you can’t use it for managing just your own accounts. Check out [the online tutorial and guide][4] to get started. - -![Checking account records shown in GnuCash.][5] - -Open the _Software_ app, search for _GnuCash_ , and select the app. Then click _Install_ to add it to your system. Or use _dnf install_ as above to install the _gnucash_ package. - -It’s now available via Flathub which makes installation easy. If you don’t have Flathub support, check out [this article on the Fedora Magazine][6] for how to use it. Then you can also use the _flatpak install GnuCash_ command with a terminal. - -* * * - -*Photo by _[_Fabian Blank_][7]_ on *[ _Unsplash_][8]. - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/3-apps-to-manage-personal-finances-in-fedora/ - -作者:[Paul W. Frields][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/pfrields/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2019/04/personal-finance-3-apps-816x345.jpg -[2]: https://fedoramagazine.org/wp-content/uploads/2019/04/Screenshot-from-2019-04-28-16-16-16-1024x637.png -[3]: https://fedoramagazine.org/wp-content/uploads/2019/04/Screenshot-from-2019-04-28-16-27-10-1-1024x649.png -[4]: https://www.gnucash.org/viewdoc.phtml?rev=3&lang=C&doc=guide -[5]: https://fedoramagazine.org/wp-content/uploads/2019/04/Screenshot-from-2019-04-28-16-41-27-1024x631.png -[6]: https://fedoramagazine.org/install-flathub-apps-fedora/ -[7]: https://unsplash.com/photos/pElSkGRA2NU?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText -[8]: https://unsplash.com/search/photos/money?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/sources/tech/20190501 Monitor and Manage Docker Containers with Portainer.io (GUI tool) - Part-1.md b/sources/tech/20190501 Monitor and Manage Docker Containers with Portainer.io (GUI tool) - Part-1.md new file mode 100644 index 0000000000..27bf04eb05 --- /dev/null +++ b/sources/tech/20190501 Monitor and Manage Docker Containers with Portainer.io (GUI tool) - Part-1.md @@ -0,0 +1,247 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Monitor and Manage Docker Containers with Portainer.io (GUI tool) – Part-1) +[#]: via: (https://www.linuxtechi.com/monitor-manage-docker-containers-portainer-part1/) +[#]: author: (Shashidhar Soppin https://www.linuxtechi.com/author/shashidhar/) + +Monitor and Manage Docker Containers with Portainer.io (GUI tool) – Part-1 +====== + +As **Docker** usage and adoption is growing faster and faster, monitoring **Docker container** images is becoming more challenging. As multiple Docker container images are getting created day-by-day, monitoring them is very important. There are already some in built tools and technologies, but configuring them is little complex. As micro-services based architecture is becoming the de-facto standard in coming days, learning such tool adds one more arsenal to your tool-set. + +Based on the above scenarios, there was in need of one light weight and robust tool requirement was growing. So Portainer.io addressed this. “ **Portainer.io** “,(Latest version is 1.20.2) the tool is very light weight(with 2-3 commands only one can configure it) and has become popular among Docker users. + +**This tool has advantages over other tools; some of these are as below** , + + * Light weight (requires only 2-3 commands to be required to run to install this tool) {Also installation image is only around 26-30MB of size) + * Robust and easy to use + * Can be used for Docker monitor and Build + * This tool provides us a detailed overview of your Docker environments + * This tool allows us to manage your containers, images, networks and volumes. + * Portainer is simple to deploy – this requires just one Docker command (can be run from anywhere.) + * Complete Docker-container environment can be monitored easily + + + +**Portainer is also equipped with** , + + * Community support + * Enterprise support + * Has professional services available(along with partner OEM services) + + + +**Functionality and features of Portainer tool are,** + + 1. It comes-up with nice Dashboard, easy to use and monitor. + 2. Many in-built templates for ease of operation and creation + 3. Support of services (OEM, Enterprise level) + 4. Monitoring of Containers, Images, Networks, Volume and configuration at almost real-time. + 5. Also includes Docker-Swarm monitoring + 6. User management with many fancy capabilities + + + +**Read Also :[How to Install Docker CE on Ubuntu 16.04 / 18.04 LTS System][1]** + +### How to install and configure Portainer.io on Ubuntu Linux / RHEL / CentOS + +**Note:** This installation is done on Ubuntu 18.04 but the installation on RHEL & CentOS would be same. We are assuming Docker CE is already installed on your system. + +``` +root@linuxtechi:~$ lsb_release -a +No LSB modules are available. +Distributor ID: Ubuntu +Description: Ubuntu 18.04 LTS +Release: 18.04 +Codename: bionic +root@linuxtechi:~$ +``` + +Create the Volume for portainer + +``` +root@linuxtechi:~$ sudo docker volume create portainer_data +portainer_data +root@linuxtechi:~$ +``` + +Launch and start Portainer Container using the beneath docker command, + +``` +root@linuxtechi:~$ sudo docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer +Unable to find image 'portainer/portainer:latest' locally +latest: Pulling from portainer/portainer +d1e017099d17: Pull complete +0b1e707a06d2: Pull complete +Digest: sha256:d6cc2c20c0af38d8d557ab994c419c799a10fe825e4aa57fea2e2e507a13747d +Status: Downloaded newer image for portainer/portainer:latest +35286de9f2e21d197309575bb52b5599fec24d4f373cc27210d98abc60244107 +root@linuxtechi:~$ +``` + +Once the complete installation is done, use the ip of host or Docker using port 9000 of the Docker engine where portainer is running using your browser. + +**Note:** If OS firewall is enabled on your Docker host then make sure 9000 port is allowed else its GUI will not come up. + +In my case, IP address of my Docker Host / Engine is “192.168.1.16” so URL will be, + + + +[![Portainer-Login-User-Name-Password][2]][3] + +Please make sure that you enter 8-character passwords. Let the admin be the user as it is and then click “Create user”. + +Now the following screen appears, in this select “Local” rectangle box. + +[![Connect-Portainer-Local-Docker][4]][5] + +Click on “Connect” + +Nice GUI with admin as user home screen appears as below, + +[![Portainer-io-Docker-Monitor-Dashboard][6]][7] + +Now Portainer is ready to launch and manage your Docker containers and it can also be used for containers monitoring. + +### Bring-up container image on Portainer tool + +[![Portainer-Endpoints][8]][9] + +Now check the present status, there are two container images are already running, if you create one more that appears instantly. + +From your command line kick-start one or two containers as below, + +``` +root@linuxtechi:~$ sudo docker run --name test -it debian +Unable to find image 'debian:latest' locally +latest: Pulling from library/debian +e79bb959ec00: Pull complete +Digest: sha256:724b0fbbda7fda6372ffed586670573c59e07a48c86d606bab05db118abe0ef5 +Status: Downloaded newer image for debian:latest +root@linuxtechi:/# +``` + +Now click Refresh button (Are you sure message appears, click “continue” on this) in Portainer GUI, you will now see 3 container images as highlighted below, + +[![Portainer-io-new-container-image][10]][11] + +Click on the “ **containers** ” (in which it is red circled above), next window appears with “ **Dashboard Endpoint summary** ” + +[![Portainer-io-Docker-Container-Dash][12]][13] + +In this page, click on “ **Containers** ” as highlighted in red color. Now you are ready to monitor your container image. + +### Simple Docker container image monitoring + +From the above step, it appears that a fancy and nice looking “Container List” page appears as below, + +[![Portainer-Container-List][14]][15] + +All the container images can be controlled from here (stop, start, etc) + +**1)** Now from this page, stop the earlier started {“test” container (this was the debian image that we started earlier)} + +To do this select the check box in front of this image and click stop button from above, + +[![Stop-Container-Portainer-io-dashboard][16]][17] + +From the command line option, you will see that this image has been stopped or exited now, + +``` +root@linuxtechi:~$ sudo docker container ls -a +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +d45902e717c0 debian "bash" 21 minutes ago Exited (0) 49 seconds ago test +08b96eddbae9 centos:7 "/bin/bash" About an hour ago Exited (137) 9 minutes ago mycontainer2 +35286de9f2e2 portainer/portainer "/portainer" 2 hours ago Up About an hour 0.0.0.0:9000->9000/tcp compassionate_benz +root@linuxtechi:~$ +``` + +**2)** Now start the stopped containers (test & mycontainer2) from Portainer GUI, + +Select the check box in front of stopped containers, and the click on Start + +[![Start-Containers-Portainer-GUI][18]][19] + +You will get a quick window saying, “ **Container successfully started** ” and with running state + +[![Conatiner-Started-successfully-Portainer-GUI][20]][21] + +### Various other options and features are explored as below step-by-step + +**1)** Click on “ **Images** ” which is highlighted, you will get the below window, + +[![Docker-Container-Images-Portainer-GUI][22]][23] + +This is the list of container images that are available but some may not running. These images can be imported, exported or uploaded to various locations, below screen shot shows the same, + +[![Upload-Docker-Container-Image-Portainer-GUI][24]][25] + +**2)** Click on “ **volumes”** which is highlighted, you will get the below window, + +[![Volume-list-Portainer-io-gui][26]][27] + +**3)** Volumes can be added easily with following option, click on add volume button, below window appears, + +Provide the name as “ **myvol** ” in the name box and click on “ **create the volume** ” button. + +[![Volume-Creation-Portainer-io-gui][28]][29] + +The newly created volume appears as below, (with unused state) + +[![Volume-unused-Portainer-io-gui][30]][31] + +#### Conclusion: + +As from the above installation steps, configuration and playing around with various options you can see how easy and fancy looking is Portainer.io tool is. This provides multiple features and options to explore on building, monitoring docker container. As explained this is very light weight tool, so doesn’t add any overload to host system. Next set-of options will be explored in part-2 of this series. + +Read Also: **[Monitor and Manage Docker Containers with Portainer.io (GUI tool) – Part-2][32]** + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/monitor-manage-docker-containers-portainer-part1/ + +作者:[Shashidhar Soppin][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/shashidhar/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/how-to-setup-docker-on-ubuntu-server-16-04/ +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Portainer-Login-User-Name-Password-1024x681.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Portainer-Login-User-Name-Password.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Connect-Portainer-Local-Docker-1024x538.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Connect-Portainer-Local-Docker.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Portainer-io-Docker-Monitor-Dashboard-1024x544.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Portainer-io-Docker-Monitor-Dashboard.jpg +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Portainer-Endpoints-1024x252.jpg +[9]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Portainer-Endpoints.jpg +[10]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Portainer-io-new-container-image-1024x544.jpg +[11]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Portainer-io-new-container-image.jpg +[12]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Portainer-io-Docker-Container-Dash-1024x544.jpg +[13]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Portainer-io-Docker-Container-Dash.jpg +[14]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Portainer-Container-List-1024x538.jpg +[15]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Portainer-Container-List.jpg +[16]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Stop-Container-Portainer-io-dashboard-1024x447.jpg +[17]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Stop-Container-Portainer-io-dashboard.jpg +[18]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Start-Containers-Portainer-GUI-1024x449.jpg +[19]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Start-Containers-Portainer-GUI.jpg +[20]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Conatiner-Started-successfully-Portainer-GUI-1024x538.jpg +[21]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Conatiner-Started-successfully-Portainer-GUI.jpg +[22]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Docker-Container-Images-Portainer-GUI-1024x544.jpg +[23]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Docker-Container-Images-Portainer-GUI.jpg +[24]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Upload-Docker-Container-Image-Portainer-GUI-1024x544.jpg +[25]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Upload-Docker-Container-Image-Portainer-GUI.jpg +[26]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Volume-list-Portainer-io-gui-1024x544.jpg +[27]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Volume-list-Portainer-io-gui.jpg +[28]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Volume-Creation-Portainer-io-gui-1024x544.jpg +[29]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Volume-Creation-Portainer-io-gui.jpg +[30]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Volume-unused-Portainer-io-gui-1024x544.jpg +[31]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Volume-unused-Portainer-io-gui.jpg +[32]: https://www.linuxtechi.com/monitor-manage-docker-containers-portainer-io-part-2/ diff --git a/sources/tech/20190503 API evolution the right way.md b/sources/tech/20190503 API evolution the right way.md deleted file mode 100644 index 087c71eead..0000000000 --- a/sources/tech/20190503 API evolution the right way.md +++ /dev/null @@ -1,735 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (MjSeven) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (API evolution the right way) -[#]: via: (https://opensource.com/article/19/5/api-evolution-right-way) -[#]: author: (A. Jesse https://opensource.com/users/emptysquare) - -API evolution the right way -====== -Ten covenants that responsible library authors keep with their users. -![Browser of things][1] - -Imagine you are a creator deity, designing a body for a creature. In your benevolence, you wish for the creature to evolve over time: first, because it must respond to changes in its environment, and second, because your wisdom grows and you think of better designs for the beast. It shouldn't remain in the same body forever! - -![Serpents][2] - -The creature, however, might be relying on features of its present anatomy. You can't add wings or change its scales without warning. It needs an orderly process to adapt its lifestyle to its new body. How can you, as a responsible designer in charge of this creature's natural history, gently coax it toward ever greater improvements? - -It's the same for responsible library maintainers. We keep our promises to the people who depend on our code: we release bugfixes and useful new features. We sometimes delete features if that's beneficial for the library's future. We continue to innovate, but we don't break the code of people who use our library. How can we fulfill all those goals at once? - -### Add useful features - -Your library shouldn't stay the same for eternity: you should add features that make your library better for your users. For example, if you have a Reptile class and it would be useful to have wings for flying, go for it. - - -``` -class Reptile: -@property -def teeth(self): -return 'sharp fangs' - -# If wings are useful, add them! -@property -def wings(self): -return 'majestic wings' -``` - -But beware, features come with risk. Consider the following feature in the Python standard library, and see what went wrong with it. - - -``` -bool(datetime.time(9, 30)) == True -bool(datetime.time(0, 0)) == False -``` - -This is peculiar: converting any time object to a boolean yields True, except for midnight. (Worse, the rules for timezone-aware times are even stranger.) - -I've been writing Python for more than a decade but I didn't discover this rule until last week. What kind of bugs can this odd behavior cause in users' code? - -Consider a calendar application with a function that creates events. If an event has an end time, the function requires it to also have a start time. - - -``` -def create_event(day, -start_time=None, -end_time=None): -if end_time and not start_time: -raise ValueError("Can't pass end_time without start_time") - -# The coven meets from midnight until 4am. -create_event(datetime.date.today(), -datetime.time(0, 0), -datetime.time(4, 0)) -``` - -Unfortunately for witches, an event starting at midnight fails this validation. A careful programmer who knows about the quirk at midnight can write this function correctly, of course. - - -``` -def create_event(day, -start_time=None, -end_time=None): -if end_time is not None and start_time is None: -raise ValueError("Can't pass end_time without start_time") -``` - -But this subtlety is worrisome. If a library creator wanted to make an API that bites users, a "feature" like the boolean conversion of midnight works nicely. - -![Man being chased by an alligator][3] - -The responsible creator's goal, however, is to make your library easy to use correctly. - -This feature was written by Tim Peters when he first made the datetime module in 2002. Even founding Pythonistas like Tim make mistakes. [The quirk was removed][4], and all times are True now. - - -``` -# Python 3.5 and later. - -bool(datetime.time(9, 30)) == True -bool(datetime.time(0, 0)) == True -``` - -Programmers who didn't know about the oddity of midnight are saved from obscure bugs, but it makes me nervous to think about any code that relies on the weird old behavior and didn't notice the change. It would have been better if this bad feature were never implemented at all. This leads us to the first promise of any library maintainer: - -#### First covenant: Avoid bad features - -The most painful change to make is when you have to delete a feature. One way to avoid bad features is to add few features in general! Make no public method, class, function, or property without a good reason. Thus: - -#### Second covenant: Minimize features - -Features are like children: conceived in a moment of passion, they must be supported for years. Don't do anything silly just because you can. Don't add feathers to a snake! - -![Serpents with and without feathers][5] - -But of course, there are plenty of occasions when users need something from your library that it does not yet offer. How do you choose the right feature to give them? Here's another cautionary tale. - -### A cautionary tale from asyncio - -As you may know, when you call a coroutine function, it returns a coroutine object: - - -``` -async def my_coroutine(): -pass - -print(my_coroutine()) - -[/code] [code]`` -``` - -Your code must "await" this object to run the coroutine. It's easy to forget this, so asyncio's developers wanted a "debug mode" that catches this mistake. Whenever a coroutine is destroyed without being awaited, the debug mode prints a warning with a traceback to the line where it was created. - -When Yury Selivanov implemented the debug mode, he added as its foundation a "coroutine wrapper" feature. The wrapper is a function that takes in a coroutine and returns anything at all. Yury used it to install the warning logic on each coroutine, but someone else could use it to turn coroutines into the string "hi!" - - -``` -import sys - -def my_wrapper(coro): -return 'hi!' - -sys.set_coroutine_wrapper(my_wrapper) - -async def my_coroutine(): -pass - -print(my_coroutine()) - -[/code] [code]`hi!` -``` - -That is one hell of a customization. It changes the very meaning of "async." Calling set_coroutine_wrapper once will globally and permanently change all coroutine functions. It is, [as Nathaniel Smith wrote][6], "a problematic API" that is prone to misuse and had to be removed. The asyncio developers could have avoided the pain of deleting the feature if they'd better shaped it to its purpose. Responsible creators must keep this in mind: - -#### Third covenant: Keep features narrow - -Luckily, Yury had the good judgment to mark this feature provisional, so asyncio users knew not to rely on it. Nathaniel was free to replace **set_coroutine_wrapper** with a narrower feature that only customized the traceback depth. - - -``` -import sys - -sys.set_coroutine_origin_tracking_depth(2) - -async def my_coroutine(): -pass - -print(my_coroutine()) - -[/code] [code] - - - -RuntimeWarning:'my_coroutine' was never awaited - -Coroutine created at (most recent call last) -File "script.py", line 8, in -print(my_coroutine()) -``` - -This is much better. There's no more global setting that can change coroutines' type, so asyncio users need not code as defensively. Deities should all be as farsighted as Yury. - -#### Fourth covenant: Mark experimental features "provisional" - -If you have merely a hunch that your creature wants horns and a quadruple-forked tongue, introduce the features but mark them "provisional." - -![Serpent with horns][7] - -You might discover that the horns are extraneous but the quadruple-forked tongue is useful after all. In the next release of your library, you can delete the former and mark the latter official. - -### Deleting features - -No matter how wisely we guide our creature's evolution, there may come a time when it's best to delete an official feature. For example, you might have created a lizard, and now you choose to delete its legs. Perhaps you want to transform this awkward creature into a sleek and modern python. - -![Lizard transformed to snake][8] - -There are two main reasons to delete features. First, you might discover a feature was a bad idea, through user feedback or your own growing wisdom. That was the case with the quirky behavior of midnight. Or, the feature might have been well-adapted to your library's environment at first, but the ecology changes. Perhaps another deity invents mammals. Your creature wants to squeeze into the mammals' little burrows and eat the tasty mammal filling, so it has to lose its legs. - -![A mouse][9] - -Similarly, the Python standard library deletes features in response to changes in the language itself. Consider asyncio's Lock. It has been awaitable ever since "await" was added as a keyword: - - -``` -lock = asyncio.Lock() - -async def critical_section(): -await lock -try: -print('holding lock') -finally: -lock.release() -``` - -But now, we can do "async with lock." - - -``` -lock = asyncio.Lock() - -async def critical_section(): -async with lock: -print('holding lock') -``` - -The new style is much better! It's short and less prone to mistakes in a big function with other try-except blocks. Since "there should be one and preferably only one obvious way to do it," [the old syntax is deprecated in Python 3.7][10] and it will be banned soon. - -It's inevitable that ecological change will have this effect on your code, too, so learn to delete features gently. Before you do so, consider the cost or benefit of deleting it. Responsible maintainers are reluctant to make their users change a large amount of their code or change their logic. (Remember how painful it was when Python 3 removed the "u" string prefix, before it was added back.) If the code changes are mechanical, however, like a simple search-and-replace, or if the feature is dangerous, it may be worth deleting. - -#### Whether to delete a feature - -![Balance scales][11] - -Con | Pro ----|--- -Code must change | Change is mechanical -Logic must change | Feature is dangerous - -In the case of our hungry lizard, we decide to delete its legs so it can slither into a mouse's hole and eat it. How do we go about this? We could just delete the **walk** method, changing code from this: - - -``` -class Reptile: -def walk(self): -print('step step step') -``` - -to this: - - -``` -class Reptile: -def slither(self): -print('slide slide slide') -``` - -That's not a good idea; the creature is accustomed to walking! Or, in terms of a library, your users have code that relies on the existing method. When they upgrade to the latest version of your library, their code will break. - - -``` -# User's code. Oops! -Reptile.walk() -``` - -Therefore, responsible creators make this promise: - -#### Fifth covenant: Delete features gently - -There are a few steps involved in deleting a feature gently. Starting with a lizard that walks with its legs, you first add the new method, "slither." Next, deprecate the old method. - - -``` -import warnings - -class Reptile: -def walk(self): -warnings.warn( -"walk is deprecated, use slither", -DeprecationWarning, stacklevel=2) -print('step step step') - -def slither(self): -print('slide slide slide') -``` - -The Python warnings module is quite powerful. By default it prints warnings to stderr, only once per code location, but you can silence warnings or turn them into exceptions, among other options. - -As soon as you add this warning to your library, PyCharm and other IDEs render the deprecated method with a strikethrough. Users know right away that the method is due for deletion. - -`Reptile().walk()` - -What happens when they run their code with the upgraded library? - - -``` -$ python3 script.py - -DeprecationWarning: walk is deprecated, use slither -script.py:14: Reptile().walk() - -step step step -``` - -By default, they see a warning on stderr, but the script succeeds and prints "step step step." The warning's traceback shows what line of the user's code must be fixed. (That's what the "stacklevel" argument does: it shows the call site that users need to change, not the line in your library where the warning is generated.) Notice that the error message is instructive, it describes what a library user must do to migrate to the new version. - -Your users will want to test their code and prove they call no deprecated library methods. Warnings alone won't make unit tests fail, but exceptions will. Python has a command-line option to turn deprecation warnings into exceptions. - - -``` -> python3 -Werror::DeprecationWarning script.py - -Traceback (most recent call last): -File "script.py", line 14, in -Reptile().walk() -File "script.py", line 8, in walk -DeprecationWarning, stacklevel=2) -DeprecationWarning: walk is deprecated, use slither -``` - -Now, "step step step" is not printed, because the script terminates with an error. - -So, once you've released a version of your library that warns about the deprecated "walk" method, you can delete it safely in the next release. Right? - -Consider what your library's users might have in their projects' requirements. - - -``` -# User's requirements.txt has a dependency on the reptile package. -reptile -``` - -The next time they deploy their code, they'll install the latest version of your library. If they haven't yet handled all deprecations, then their code will break, because it still depends on "walk." You need to be gentler than this. There are three more promises you must keep to your users: maintain a changelog, choose a version scheme, and write an upgrade guide. - -#### Sixth covenant: Maintain a changelog - -Your library must have a changelog; its main purpose is to announce when a feature that your users rely on is deprecated or deleted. - -#### Changes in Version 1.1 - -**New features** - - * New function Reptile.slither() - - - -**Deprecations** - - * Reptile.walk() is deprecated and will be removed in version 2.0, use slither() - - ---- - -Responsible creators use version numbers to express how a library has changed so users can make informed decisions about upgrading. A "version scheme" is a language for communicating the pace of change. - -#### Seventh covenant: Choose a version scheme - -There are two schemes in widespread use, [semantic versioning][12] and time-based versioning. I recommend semantic versioning for nearly any library. The Python flavor thereof is defined in [PEP 440][13], and tools like **pip** understand semantic version numbers. - -If you choose semantic versioning for your library, you can delete its legs gently with version numbers like: - -> 1.0: First "stable" release, with walk() -> 1.1: Add slither(), deprecate walk() -> 2.0: Delete walk() - -Your users should depend on a range of your library's versions, like so: - - -``` -# User's requirements.txt. -reptile>=1,<2 -``` - -This allows them to upgrade automatically within a major release, receiving bugfixes and potentially raising some deprecation warnings, but not upgrading to the _next_ major release and risking a change that breaks their code. - -If you follow time-based versioning, your releases might be numbered thus: - -> 2017.06.0: A release in June 2017 -> 2018.11.0: Add slither(), deprecate walk() -> 2019.04.0: Delete walk() - -And users can depend on your library like: - - -``` -# User's requirements.txt for time-based version. -reptile==2018.11.* -``` - -This is terrific, but how do your users know your versioning scheme and how to test their code for deprecations? You have to advise them how to upgrade. - -#### Eighth covenant: Write an upgrade guide - -Here's how a responsible library creator might guide users: - -#### Upgrading to 2.0 - -**Migrate from Deprecated APIs** - -See the changelog for deprecated features. - -**Enable Deprecation Warnings** - -Upgrade to 1.1 and test your code with: - -`python -Werror::DeprecationWarning` - -​​​​​​Now it's safe to upgrade. - ---- - -You must teach users how to handle deprecation warnings by showing them the command line options. Not all Python programmers know this—I certainly have to look up the syntax each time. And take note, you must _release_ a version that prints warnings from each deprecated API so users can test with that version before upgrading again. In this example, version 1.1 is the bridge release. It allows your users to rewrite their code incrementally, fixing each deprecation warning separately until they have entirely migrated to the latest API. They can test changes to their code and changes in your library, independently from each other, and isolate the cause of bugs. - -If you chose semantic versioning, this transitional period lasts until the next major release, from 1.x to 2.0, or from 2.x to 3.0, and so on. The gentle way to delete a creature's legs is to give it at least one version in which to adjust its lifestyle. Don't remove the legs all at once! - -![A skink][14] - -Version numbers, deprecation warnings, the changelog, and the upgrade guide work together to gently evolve your library without breaking the covenant with your users. The [Twisted project's Compatibility Policy][15] explains this beautifully: - -> "The First One's Always Free" -> -> Any application which runs without warnings may be upgraded one minor version of Twisted. -> -> In other words, any application which runs its tests without triggering any warnings from Twisted should be able to have its Twisted version upgraded at least once with no ill effects except the possible production of new warnings. - -Now, we creator deities have gained the wisdom and power to add features by adding methods and to delete them gently. We can also add features by adding parameters, but this brings a new level of difficulty. Are you ready? - -### Adding parameters - -Imagine that you just gave your snake-like creature a pair of wings. Now you must allow it the choice whether to move by slithering or flying. Currently its "move" function takes one parameter. - - -``` -# Your library code. -def move(direction): -print(f'slither {direction}') - -# A user's application. -move('north') -``` - -You want to add a "mode" parameter, but this breaks your users' code if they upgrade, because they pass only one argument. - - -``` -# Your library code. -def move(direction, mode): -assert mode in ('slither', 'fly') -print(f'{mode} {direction}') - -# A user's application. Error! -move('north') -``` - -A truly wise creator promises not to break users' code this way. - -#### Ninth covenant: Add parameters compatibly - -To keep this covenant, add each new parameter with a default value that preserves the original behavior. - - -``` -# Your library code. -def move(direction, mode='slither'): -assert mode in ('slither', 'fly') -print(f'{mode} {direction}') - -# A user's application. -move('north') -``` - -Over time, parameters are the natural history of your function's evolution. They're listed oldest first, each with a default value. Library users can pass keyword arguments to opt into specific new behaviors and accept the defaults for all others. - - -``` -# Your library code. -def move(direction, -mode='slither', -turbo=False, -extra_sinuous=False, -hail_lyft=False): -# ... - -# A user's application. -move('north', extra_sinuous=True) -``` - -There is a danger, however, that a user might write code like this: - - -``` -# A user's application, poorly-written. -move('north', 'slither', False, True) -``` - -What happens if, in the next major version of your library, you get rid of one of the parameters, like "turbo"? - - -``` -# Your library code, next major version. "turbo" is deleted. -def move(direction, -mode='slither', -extra_sinuous=False, -hail_lyft=False): -# ... - -# A user's application, poorly-written. -move('north', 'slither', False, True) -``` - -The user's code still compiles, and this is a bad thing. The code stopped moving extra-sinuously and started hailing a Lyft, which was not the intention. I trust that you can predict what I'll say next: Deleting a parameter requires several steps. First, of course, deprecate the "turbo" parameter. I like a technique like this one, which detects whether any user's code relies on this parameter. - - -``` -# Your library code. -_turbo_default = object() - -def move(direction, -mode='slither', -turbo=_turbo_default, -extra_sinuous=False, -hail_lyft=False): -if turbo is not _turbo_default: -warnings.warn( -"'turbo' is deprecated", -DeprecationWarning, -stacklevel=2) -else: -# The old default. -turbo = False -``` - -But your users might not notice the warning. Warnings are not very loud: they can be suppressed or lost in log files. Users might heedlessly upgrade to the next major version of your library, the version that deletes "turbo." Their code will run without error and silently do the wrong thing! As the Zen of Python says, "Errors should never pass silently." Indeed, reptiles hear poorly, so you must correct them very loudly when they make mistakes. - -![Woman riding an alligator][16] - -The best way to protect your users is with Python 3's star syntax, which requires callers to pass keyword arguments. - - -``` -# Your library code. -# All arguments after "*" must be passed by keyword. -def move(direction, -*, -mode='slither', -turbo=False, -extra_sinuous=False, -hail_lyft=False): -# ... - -# A user's application, poorly-written. -# Error! Can't use positional args, keyword args required. -move('north', 'slither', False, True) -``` - -With the star in place, this is the only syntax allowed: - - -``` -# A user's application. -move('north', extra_sinuous=True) -``` - -Now when you delete "turbo," you can be certain any user code that relies on it will fail loudly. If your library also supports Python 2, there's no shame in that; you can simulate the star syntax thus ([credit to Brett Slatkin][17]): - - -``` -# Your library code, Python 2 compatible. -def move(direction, **kwargs): -mode = kwargs.pop('mode', 'slither') -turbo = kwargs.pop('turbo', False) -sinuous = kwargs.pop('extra_sinuous', False) -lyft = kwargs.pop('hail_lyft', False) - -if kwargs: -raise TypeError('Unexpected kwargs: %r' -% kwargs) - -# ... -``` - -Requiring keyword arguments is a wise choice, but it requires foresight. If you allow an argument to be passed positionally, you cannot convert it to keyword-only in a later release. So, add the star now. You can observe in the asyncio API that it uses the star pervasively in constructors, methods, and functions. Even though "Lock" only takes one optional parameter so far, the asyncio developers added the star right away. This is providential. - - -``` -# In asyncio. -class Lock: -def __init__(self, *, loop=None): -# ... -``` - -Now we've gained the wisdom to change methods and parameters while keeping our covenant with users. The time has come to try the most challenging kind of evolution: changing behavior without changing either methods or parameters. - -### Changing behavior - -Let's say your creature is a rattlesnake, and you want to teach it a new behavior. - -![Rattlesnake][18] - -Sidewinding! The creature's body will appear the same, but its behavior will change. How can we prepare it for this step of its evolution? - -![][19] - -Image by HCA [[CC BY-SA 4.0][20]], [via Wikimedia Commons][21], modified by Opensource.com - -A responsible creator can learn from the following example in the Python standard library, when behavior changed without a new function or parameters. Once upon a time, the os.stat function was introduced to get file statistics, like the creation time. At first, times were always integers. - - -``` ->>> os.stat('file.txt').st_ctime -1540817862 -``` - -One day, the core developers decided to use floats for os.stat times to give sub-second precision. But they worried that existing user code wasn't ready for the change. They created a setting in Python 2.3, "stat_float_times," that was false by default. A user could set it to True to opt into floating-point timestamps. - - -``` ->>> # Python 2.3. ->>> os.stat_float_times(True) ->>> os.stat('file.txt').st_ctime -1540817862.598021 -``` - -Starting in Python 2.5, float times became the default, so any new code written for 2.5 and later could ignore the setting and expect floats. Of course, you could set it to False to keep the old behavior or set it to True to ensure the new behavior in all Python versions, and prepare your code for the day when stat_float_times is deleted. - -Ages passed. In Python 3.1, the setting was deprecated to prepare people for the distant future and finally, after its decades-long journey, [the setting was removed][22]. Float times are now the only option. It's a long road, but responsible deities are patient because we know this gradual process has a good chance of saving users from unexpected behavior changes. - -#### Tenth covenant: Change behavior gradually - -Here are the steps: - - * Add a flag to opt into the new behavior, default False, warn if it's False - * Change default to True, deprecate flag entirely - * Remove the flag - - - -If you follow semantic versioning, the versions might be like so: - -Library version | Library API | User code ----|---|--- -| | -1.0 | No flag | Expect old behavior -1.1 | Add flag, default False, -warn if it's False | Set flag True, -handle new behavior -2.0 | Change default to True, -deprecate flag entirely | Handle new behavior -3.0 | Remove flag | Handle new behavior - -You need _two_ major releases to complete the maneuver. If you had gone straight from "Add flag, default False, warn if it's False" to "Remove flag" without the intervening release, your users' code would be unable to upgrade. User code written correctly for 1.1, which sets the flag to True and handles the new behavior, must be able to upgrade to the next release with no ill effect except new warnings, but if the flag were deleted in the next release, that code would break. A responsible deity never violates the Twisted policy: "The First One's Always Free." - -### The responsible creator - -![Demeter][23] - -Our 10 covenants belong loosely in three categories: - -**Evolve cautiously** - - 1. Avoid bad features - 2. Minimize features - 3. Keep features narrow - 4. Mark experimental features "provisional" - 5. Delete features gently - - - -**Record history rigorously** - - 1. Maintain a changelog - 2. Choose a version scheme - 3. Write an upgrade guide - - - -**Change slowly and loudly** - - 1. Add parameters compatibly - 2. Change behavior gradually - - - -If you keep these covenants with your creature, you'll be a responsible creator deity. Your creature's body can evolve over time, forever improving and adapting to changes in its environment but without sudden changes the creature isn't prepared for. If you maintain a library, keep these promises to your users and you can innovate your library without breaking the code of the people who rely on you. - -* * * - -_This article originally appeared on[A. Jesse Jiryu Davis's blog][24] and is republished with permission._ - -Illustration credits: - - * [The World's Progress, The Delphian Society, 1913][25] - * [Essay Towards a Natural History of Serpents, Charles Owen, 1742][26] - * [On the batrachia and reptilia of Costa Rica: With notes on the herpetology and ichthyology of Nicaragua and Peru, Edward Drinker Cope, 1875][27] - * [Natural History, Richard Lydekker et. al., 1897][28] - * [Mes Prisons, Silvio Pellico, 1843][29] - * [Tierfotoagentur / m.blue-shadow][30] - * [Los Angeles Public Library, 1930][31] - - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/5/api-evolution-right-way - -作者:[A. Jesse][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/emptysquare -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_desktop_website_checklist_metrics.png?itok=OKKbl1UR (Browser of things) -[2]: https://opensource.com/sites/default/files/uploads/praise-the-creator.jpg (Serpents) -[3]: https://opensource.com/sites/default/files/uploads/bite.jpg (Man being chased by an alligator) -[4]: https://bugs.python.org/issue13936 -[5]: https://opensource.com/sites/default/files/uploads/feathers.jpg (Serpents with and without feathers) -[6]: https://bugs.python.org/issue32591 -[7]: https://opensource.com/sites/default/files/uploads/horns.jpg (Serpent with horns) -[8]: https://opensource.com/sites/default/files/uploads/lizard-to-snake.jpg (Lizard transformed to snake) -[9]: https://opensource.com/sites/default/files/uploads/mammal.jpg (A mouse) -[10]: https://bugs.python.org/issue32253 -[11]: https://opensource.com/sites/default/files/uploads/scale.jpg (Balance scales) -[12]: https://semver.org -[13]: https://www.python.org/dev/peps/pep-0440/ -[14]: https://opensource.com/sites/default/files/uploads/skink.jpg (A skink) -[15]: https://twistedmatrix.com/documents/current/core/development/policy/compatibility-policy.html -[16]: https://opensource.com/sites/default/files/uploads/loudly.jpg (Woman riding an alligator) -[17]: http://www.informit.com/articles/article.aspx?p=2314818 -[18]: https://opensource.com/sites/default/files/uploads/rattlesnake.jpg (Rattlesnake) -[19]: https://opensource.com/sites/default/files/articles/neonate_sidewinder_sidewinding_with_tracks_unlabeled.png -[20]: https://creativecommons.org/licenses/by-sa/4.0 -[21]: https://commons.wikimedia.org/wiki/File:Neonate_sidewinder_sidewinding_with_tracks_unlabeled.jpg -[22]: https://bugs.python.org/issue31827 -[23]: https://opensource.com/sites/default/files/uploads/demeter.jpg (Demeter) -[24]: https://emptysqua.re/blog/api-evolution-the-right-way/ -[25]: https://www.gutenberg.org/files/42224/42224-h/42224-h.htm -[26]: https://publicdomainreview.org/product-att/artist/charles-owen/ -[27]: https://archive.org/details/onbatrachiarepti00cope/page/n3 -[28]: https://www.flickr.com/photos/internetarchivebookimages/20556001490 -[29]: https://www.oldbookillustrations.com/illustrations/stationery/ -[30]: https://www.alamy.com/mediacomp/ImageDetails.aspx?ref=D7Y61W -[31]: https://www.vintag.es/2013/06/riding-alligator-c-1930s.html diff --git a/sources/tech/20190503 Check your spelling at the command line with Ispell.md b/sources/tech/20190503 Check your spelling at the command line with Ispell.md deleted file mode 100644 index 3ddcad1024..0000000000 --- a/sources/tech/20190503 Check your spelling at the command line with Ispell.md +++ /dev/null @@ -1,81 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Check your spelling at the command line with Ispell) -[#]: via: (https://opensource.com/article/19/5/spelling-command-line-ispell) -[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) - -Check your spelling at the command line with Ispell -====== -Ispell helps you stamp out typos in plain text files written in more -than 50 languages. -![Command line prompt][1] - -Good spelling is a skill. A skill that takes time to learn and to master. That said, there are people who never quite pick that skill up—I know a couple or three outstanding writers who can't spell to save their lives. - -Even if you spell well, the occasional typo creeps in. That's especially true if you're quickly banging on your keyboard to meet a deadline. Regardless of your spelling chops, it's always a good idea to run what you've written through a spelling checker. - -I do most of my writing in [plain text][2] and often use a command line spelling checker called [Aspell][3] to do the deed. Aspell isn't the only game in town. You might also want to check out the venerable [Ispell][4]. - -### Getting started - -Ispell's been around, in various forms, since 1971. Don't let its age fool you. Ispell is still a peppy application that you can use effectively in the 21st century. - -Before doing anything else, check whether or not Ispell is installed on your computer by cracking open a terminal window and typing **which ispell**. If it isn't installed, fire up your distribution's package manager and install Ispell from there. - -Don't forget to install dictionaries for the languages you work in, too. My only language is English, so I just need to worry about grabbing the US and British English dictionaries. You're not limited to my mother (and only) tongue. Ispell has [dictionaries for over 50 languages][5]. - -![Installing Ispell dictionaries][6] - -### Using Ispell - -If you haven't guessed already, Ispell only works with text files. That includes ones marked up with HTML, LaTeX, and [nroff or troff][7]. More on this in a few moments. - -To get to work, open a terminal window and navigate to the directory containing the file where you want to run a spelling check. Type **ispell** followed by the file's name and then press Enter. - -![Checking spelling with Ispell][8] - -Ispell highlights the first word it doesn't recognize. If the word is misspelled, Ispell usually offers one or more alternatives. Press **R** and then the number beside the correct choice. In the screen capture above, I'd press **R** and **0** to fix the error. - -If, on the other hand, the word is correctly spelled, press **A** to move to the next misspelled word. - -Keep doing that until you reach the end of the file. Ispell saves your changes, creates a backup of the file you just checked (with the extension _.bak_ ), and shuts down. - -### A few other options - -This example illustrates basic Ispell usage. The program has a [number of options][9], some of which you _might_ use and others you _might never_ use. Let's take a quick peek at some of the ones I regularly use. - -A few paragraphs ago, I mentioned that Ispell works with certain markup languages. You need to tell it a file's format. When starting Ispell, add **-t** for a TeX or LaTeX file, **-H** for an HTML file, or **-n** for a groff or troff file. For example, if you enter **ispell -t myReport.tex** , Ispell ignores all markup. - -If you don't want the backup file that Ispell creates after checking a file, add **-x** to the command line—for example, **ispell -x myFile.txt**. - -What happens if Ispell runs into a word that's spelled correctly but isn't in its dictionary, like a proper name? You can add that word to a personal word list by pressing **I**. This saves the word to a file called _.ispell_default_ in the root of your _/home_ directory. - -Those are the options I find most useful when working with Ispell, but check out [Ispell's man page][9] for descriptions of all its options. - -Is Ispell any better or faster than Aspell or any other command line spelling checker? I have to say it's no worse than any of them, nor is it any slower. Ispell's not for everyone. It might not be for you. But it is good to have options, isn't it? - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/5/spelling-command-line-ispell - -作者:[Scott Nesbitt ][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/scottnesbitt -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg (Command line prompt) -[2]: https://plaintextproject.online -[3]: https://opensource.com/article/18/2/how-check-spelling-linux-command-line-aspell -[4]: https://www.cs.hmc.edu/~geoff/ispell.html -[5]: https://www.cs.hmc.edu/~geoff/ispell-dictionaries.html -[6]: https://opensource.com/sites/default/files/uploads/ispell-install-dictionaries.png (Installing Ispell dictionaries) -[7]: https://opensource.com/article/18/2/how-format-academic-papers-linux-groff-me -[8]: https://opensource.com/sites/default/files/uploads/ispell-checking.png (Checking spelling with Ispell) -[9]: https://www.cs.hmc.edu/~geoff/ispell-man.html diff --git a/sources/tech/20190504 Add methods retroactively in Python with singledispatch.md b/sources/tech/20190504 Add methods retroactively in Python with singledispatch.md deleted file mode 100644 index 022b06aa52..0000000000 --- a/sources/tech/20190504 Add methods retroactively in Python with singledispatch.md +++ /dev/null @@ -1,106 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Add methods retroactively in Python with singledispatch) -[#]: via: (https://opensource.com/article/19/5/python-singledispatch) -[#]: author: (Moshe Zadka https://opensource.com/users/moshez) - -Add methods retroactively in Python with singledispatch -====== -Learn more about solving common Python problems in our series covering -seven PyPI libraries. -![][1] - -Python is one of the most [popular programming languages][2] in use today—and for good reasons: it's open source, it has a wide range of uses (such as web programming, business applications, games, scientific programming, and much more), and it has a vibrant and dedicated community supporting it. This community is the reason we have such a large, diverse range of software packages available in the [Python Package Index][3] (PyPI) to extend and improve Python and solve the inevitable glitches that crop up. - -In this series, we'll look at seven PyPI libraries that can help you solve common Python problems. Today, we'll examine [**singledispatch**][4], a library that allows you to add methods to Python libraries retroactively. - -### singledispatch - -Imagine you have a "shapes" library with a **Circle** class, a **Square** class, etc. - -A **Circle** has a **radius** , a **Square** has a **side** , and a **Rectangle** has **height** and **width**. Our library already exists; we do not want to change it. - -However, we do want to add an **area** calculation to our library. If we didn't share this library with anyone else, we could just add an **area** method so we could call **shape.area()** and not worry about what the shape is. - -While it is possible to reach into a class and add a method, this is a bad idea: nobody expects their class to grow new methods, and things might break in weird ways. - -Instead, the **singledispatch** function in **functools** can come to our rescue. - - -``` -@singledispatch -def get_area(shape): -raise NotImplementedError("cannot calculate area for unknown shape", -shape) -``` - -The "base" implementation for the **get_area** function fails. This makes sure that if we get a new shape, we will fail cleanly instead of returning a nonsense result. - - -``` -@get_area.register(Square) -def _get_area_square(shape): -return shape.side ** 2 -@get_area.register(Circle) -def _get_area_circle(shape): -return math.pi * (shape.radius ** 2) -``` - -One nice thing about doing things this way is that if someone writes a _new_ shape that is intended to play well with our code, they can implement **get_area** themselves. - - -``` -from area_calculator import get_area - -@attr.s(auto_attribs=True, frozen=True) -class Ellipse: -horizontal_axis: float -vertical_axis: float - -@get_area.register(Ellipse) -def _get_area_ellipse(shape): -return math.pi * shape.horizontal_axis * shape.vertical_axis -``` - -_Calling_ **get_area** is straightforward. - - -``` -`print(get_area(shape))` -``` - -This means we can change a function that has a long **if isintance()/elif isinstance()** chain to work this way, without changing the interface. The next time you are tempted to check **if isinstance** , try using **singledispatch**! - -In the next article in this series, we'll look at **tox** , a tool for automating tests on Python code. - -#### Review the previous articles in this series: - - * [Cython][5] - * [Black][6] - * [attrs][7] - - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/5/python-singledispatch - -作者:[Moshe Zadka ][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/moshez -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV -[2]: https://opensource.com/article/18/5/numbers-python-community-trends -[3]: https://pypi.org/ -[4]: https://pypi.org/project/singledispatch/ -[5]: https://opensource.com/article/19/4/7-python-problems-solved-cython -[6]: https://opensource.com/article/19/4/python-problems-solved-black -[7]: https://opensource.com/article/19/4/python-problems-solved-attrs diff --git a/sources/tech/20190504 Fedora 30 Workstation Installation Guide with Screenshots.md b/sources/tech/20190504 Fedora 30 Workstation Installation Guide with Screenshots.md new file mode 100644 index 0000000000..9e0ebd4381 --- /dev/null +++ b/sources/tech/20190504 Fedora 30 Workstation Installation Guide with Screenshots.md @@ -0,0 +1,207 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Fedora 30 Workstation Installation Guide with Screenshots) +[#]: via: (https://www.linuxtechi.com/fedora-30-workstation-installation-guide/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +Fedora 30 Workstation Installation Guide with Screenshots +====== + +If you are a **Fedora distribution** lover and always try the things at Fedora Workstation and Servers, then it is good news for you as Fedora has released its latest OS edition as **Fedora 30** for the Workstation and Server. One of the important updates in Fedora 30 from its previous release is that it has introduced **Fedora CoreOS** as a replacement of Fedora Atomic host. + +Some other noticeable updates in Fedora 30 are listed beneath: + + * Updated Desktop Gnome 3.32 + * New Linux Kernel 5.0.9 + * Updated Bash Version 5.0, PHP 7.3 & GCC 9 + * Updated Python 3.7.3, JDK12, Ruby 2.6 Mesa 19.0.2 and Golang 1.12 + * Improved DNF (Default Package Manager) + + + +In this article we will walk through the Fedora 30 workstation Installation steps for laptop or desktop. + +**Following are the minimum system requirement for Fedora 30 workstation,** + + * 1GHz Processor (Recommended 2 GHz Dual Core processor) + * 2 GB RAM + * 15 GB unallocated Hard Disk + * Bootable Media (USB / DVD) + * nternet Connection (Optional) + + + +Let’s Jump into Installation steps, + +### Step:1) Download Fedora 30 Workstation ISO File + +Download the Fedora 30 Workstation ISO file on your system from its Official Web Site + + + +Once the ISO file is downloaded, then burn it either in USB drive or DVD and make it bootable. + +### Step:2) Boot Your Target System with Bootable media (USB Drive or DVD) + +Reboot your target machine (i.e. machine where you want to install Fedora 30), Set the boot medium as USB or DVD from Bios settings so system boots up with bootable media. + +### Step:3) Choose Start Fedora-Workstation-30 Live + +When the system boots up with bootable media then we will get the following screen, to begin with installation on your system’s hard disk, choose “ **Start Fedora-Workstation-30 Live** “, + + + +### Step:4) Select Install to Hard Drive Option + +Select “ **Install to Hard Drive** ” option to install Fedora 30 on your system’s hard disk, you can also try Fedora on your system without installing it, for that select “ **Try Fedora** ” Option + + + +### Step:5) Choose appropriate language for your Fedora 30 Installation + +In this step choose your language which will be used during Fedora 30 Installation, + + + +Click on Continue + +### Step:6) Choose Installation destination and partition Scheme + +In the next window we will be present the following screen, here we will choose our installation destination, means on which hard disk we will do installation + + + +In the next screen we will see the local available hard disk, select the disk that suits your installation and then choose how you want to create partitions on it from storage configuration tab. + +If you choose “ **Automatic** ” partition scheme, then installer will create the necessary partition for your system automatically but if you want to create your own customize partition scheme then choose “ **Custom** ” option, + + + +Click on Done + +In this article I will demonstrate how to create [**LVM**][1] based custom partitions, in my case I have around 40 GB unallocated hard drive, so I will be creating following partitions on it, + + * /boot = 2 GB (ext4 file system) + * /home = 15 GB (ext4 file system) + * /var = 10 GB (ext4 file system) + * / = 10 GB (ext4 file system) + * Swap = 2 GB + + + + + +Select “ **LVM** ” as partitioning scheme and then click on plus (+) symbol, + +Specify the mount point as /boot and partition size as 2 GB and then click on “Add mount point” + + + + + +Now create next partition as /home of size 15 GB, Click on + symbol + + + +Click on “ **Add mount point** ” + + + +If you might have noticed, /home partition is created as LVM partition under default Volume Group, if you wish to change default Volume Group name then click on “ **Modify** ” option from Volume Group Tab, + +Mention the Volume Group name you want to set and then click on Save. Now onward all the LVM partition will be part of fedora30 volume group. + + + +Similarly create the next two partitions **/var** and **/** of size 10 GB respectively, + +**/var partition:** + + + +**/ (slash) partition:** + + + +Now create the last partition as swap of size 2 GB, + + + +In the next window, click on Done + + + +In the next screen, choose “ **Accept Changes** ” + + + +Now we will get Installation Summary window, here you can also change the time zone that suits to your installation and then click on “ **Begin Installation** ” + + + +### Step:7) Fedora 30 Installation started + +In this step we can see Fedora 30 Installation has been started and it is in progress, + + + +Once the Installation is completed, you will be prompted to restart your system + + + +Click on Quit and reboot your system. + +Don’t forget the Change boot medium from Bios settings so your system boots up with hard disk. + +### Step:8) Welcome message and login Screen after reboot + +When we first time reboot Fedora 30 system after the successful installation, we will get below welcome screen, + + + +Click on Next + +In the next screen you can Sync your online accounts or else you can skip, + + + +In the next window you will be required to specify the local account (user name) and its password, later this account will be used to login to the system + + + + + +Click on Next + +And finally, we will get below screen which confirms that we are ready to use Fedora 30, + + + +Click on “ **Start Using Fedora** ” + + + +Above Gnome Desktop Screen confirms that we have successfully installed Fedora 30 Workstation, now explore it and have fun 😊 + +In Fedora 30 workstation, if you want to install any packages or software from command line use DNF command. + +Read More On: **[26 DNF Command Examples for Package Management in Fedora Linux][2]** + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/fedora-30-workstation-installation-guide/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/lvm-good-way-to-utilize-disks-space/ +[2]: https://www.linuxtechi.com/dnf-command-examples-rpm-management-fedora-linux/ diff --git a/sources/tech/20190504 Using the force at the Linux command line.md b/sources/tech/20190504 Using the force at the Linux command line.md deleted file mode 100644 index b4a937797c..0000000000 --- a/sources/tech/20190504 Using the force at the Linux command line.md +++ /dev/null @@ -1,240 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (Moelf) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Using the force at the Linux command line) -[#]: via: (https://opensource.com/article/19/5/may-the-force-linux) -[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss) - -Using the force at the Linux command line -====== -Like the Jedi Force, -f is powerful, potentially destructive, and very -helpful when you know how to use it. -![Fireworks][1] - -Sometime in recent history, sci-fi nerds began an annual celebration of everything [_Star Wars_ on May the 4th][2], a pun on the Jedi blessing, "May the Force be with you." Although most Linux users are probably not Jedi, they still have ways to use the force. Of course, the movie might not have been quite as exciting if Yoda simply told Luke to type **man X-Wing fighter** or **man force**. Or if he'd said, "RTFM" (Read the Force Manual, of course). - -Many Linux commands have an **-f** option, which stands for, you guessed it, force! Sometimes when you execute a command, it fails or prompts you for additional input. This may be an effort to protect the files you are trying to change or inform the user that a device is busy or a file already exists. - -If you don't want to be bothered by prompts or don't care about errors, use the force! - -Be aware that using a command's force option to override these protections is, generally, destructive. Therefore, the user needs to pay close attention and be sure that they know what they are doing. Using the force can have consequences! - -Following are four Linux commands with a force option and a brief description of how and why you might want to use it. - -### cp - -The **cp** command is short for copy—it's used to copy (or duplicate) a file or directory. The [man page][3] describes the force option for **cp** as: - - -``` --f, --force -if an existing destination file cannot be opened, remove it -and try again -``` - -This example is for when you are working with read-only files: - - -``` -[alan@workstation ~]$ ls -l -total 8 --rw-rw---- 1 alan alan 13 May 1 12:24 Hoth --r--r----- 1 alan alan 14 May 1 12:23 Naboo -[alan@workstation ~]$ cat Hoth Naboo -Icy Planet - -Green Planet -``` - -If you want to copy a file called _Hoth_ to _Naboo_ , the **cp** command will not allow it since _Naboo_ is read-only: - - -``` -[alan@workstation ~]$ cp Hoth Naboo -cp: cannot create regular file 'Naboo': Permission denied -``` - -But by using the force, **cp** will not prompt. The contents and permissions of _Hoth_ will immediately be copied to _Naboo_ : - - -``` -[alan@workstation ~]$ cp -f Hoth Naboo -[alan@workstation ~]$ cat Hoth Naboo -Icy Planet - -Icy Planet - -[alan@workstation ~]$ ls -l -total 8 --rw-rw---- 1 alan alan 12 May 1 12:32 Hoth --rw-rw---- 1 alan alan 12 May 1 12:38 Naboo -``` - -Oh no! I hope they have winter gear on Naboo. - -### ln - -The **ln** command is used to make links between files. The [man page][4] describes the force option for **ln** as: - - -``` --f, --force -remove existing destination files -``` - -Suppose Princess Leia is maintaining a Java application server and she has a directory where all Java versions are stored. Here is an example: - - -``` -leia@workstation:/usr/lib/java$ ls -lt -total 28 -lrwxrwxrwx 1 leia leia 12 Mar 5 2018 jdk -> jdk1.8.0_162 -drwxr-xr-x 8 leia leia 4096 Mar 5 2018 jdk1.8.0_162 -drwxr-xr-x 8 leia leia 4096 Aug 28 2017 jdk1.8.0_144 -``` - -As you can see, there are several versions of the Java Development Kit (JDK) and a symbolic link pointing to the latest one. She uses a script with the following commands to install new JDK versions. However, it won't work without a force option or unless the root user runs it: - - -``` -tar xvzmf jdk1.8.0_181.tar.gz -C jdk1.8.0_181/ -ln -vs jdk1.8.0_181 jdk -``` - -The **tar** command will extract the .gz file to the specified directory, but the **ln** command will fail to upgrade the link because one already exists. The result will be that the link no longer points to the latest JDK: - - -``` -leia@workstation:/usr/lib/java$ ln -vs jdk1.8.0_181 jdk -ln: failed to create symbolic link 'jdk/jdk1.8.0_181': File exists -leia@workstation:/usr/lib/java$ ls -lt -total 28 -drwxr-x--- 2 leia leia 4096 May 1 15:44 jdk1.8.0_181 -lrwxrwxrwx 1 leia leia 12 Mar 5 2018 jdk -> jdk1.8.0_162 -drwxr-xr-x 8 leia leia 4096 Mar 5 2018 jdk1.8.0_162 -drwxr-xr-x 8 leia leia 4096 Aug 28 2017 jdk1.8.0_144 -``` - -She can force **ln** to update the link correctly by passing the force option and one other, **-n**. The **-n** is needed because the link points to a directory. Now, the link again points to the latest JDK: - - -``` -leia@workstation:/usr/lib/java$ ln -vsnf jdk1.8.0_181 jdk -'jdk' -> 'jdk1.8.0_181' -leia@workstation:/usr/lib/java$ ls -lt -total 28 -lrwxrwxrwx 1 leia leia 12 May 1 16:13 jdk -> jdk1.8.0_181 -drwxr-x--- 2 leia leia 4096 May 1 15:44 jdk1.8.0_181 -drwxr-xr-x 8 leia leia 4096 Mar 5 2018 jdk1.8.0_162 -drwxr-xr-x 8 leia leia 4096 Aug 28 2017 jdk1.8.0_144 -``` - -A Java application can be configured to find the JDK with the path **/usr/lib/java/jdk** instead of having to change it every time Java is updated. - -### rm - -The **rm** command is short for "remove" (which we often call delete, since some other operating systems have a **del** command for this action). The [man page][5] describes the force option for **rm** as: - - -``` --f, --force -ignore nonexistent files and arguments, never prompt -``` - -If you try to delete a read-only file, you will be prompted by **rm** : - - -``` -[alan@workstation ~]$ ls -l -total 4 --r--r----- 1 alan alan 16 May 1 11:38 B-wing -[alan@workstation ~]$ rm B-wing -rm: remove write-protected regular file 'B-wing'? -``` - -You must type either **y** or **n** to answer the prompt and allow the **rm** command to proceed. If you use the force option, **rm** will not prompt you and will immediately delete the file: - - -``` -[alan@workstation ~]$ rm -f B-wing -[alan@workstation ~]$ ls -l -total 0 -[alan@workstation ~]$ -``` - -The most common use of force with **rm** is to delete a directory. The **-r** (recursive) option tells **rm** to remove a directory. When combined with the force option, it will remove the directory and all its contents without prompting. - -The **rm** command with certain options can be disastrous. Over the years, online forums have filled with jokes and horror stories of users completely wiping their systems. This notorious usage is **rm -rf ***. This will immediately delete all files and directories without any prompt wherever it is used. - -### userdel - -The **userdel** command is short for user delete, which will delete a user. The [man page][6] describes the force option for **userdel** as: - - -``` --f, --force -This option forces the removal of the user account, even if the -user is still logged in. It also forces userdel to remove the -user's home directory and mail spool, even if another user uses -the same home directory or if the mail spool is not owned by the -specified user. If USERGROUPS_ENAB is defined to yes in -/etc/login.defs and if a group exists with the same name as the -deleted user, then this group will be removed, even if it is -still the primary group of another user. - -Note: This option is dangerous and may leave your system in an -inconsistent state. -``` - -When Obi-Wan reached the castle on Mustafar, he knew what had to be done. He had to delete Darth's user account—but Darth was still logged in. - - -``` -[root@workstation ~]# ps -fu darth -UID PID PPID C STIME TTY TIME CMD -darth 7663 7655 0 13:28 pts/3 00:00:00 -bash -[root@workstation ~]# userdel darth -userdel: user darth is currently used by process 7663 -``` - -Since Darth is currently logged in, Obi-Wan has to use the force option to **userdel**. This will delete the user account even though it's logged in. - - -``` -[root@workstation ~]# userdel -f darth -userdel: user darth is currently used by process 7663 -[root@workstation ~]# finger darth -finger: darth: no such user. -[root@workstation ~]# ps -fu darth -error: user name does not exist -``` - -As you can see, the **finger** and **ps** commands confirm the user Darth has been deleted. - -### Using force in shell scripts - -Many other commands have a force option. One place force is very useful is in shell scripts. Since we use scripts in cron jobs and other automated operations, avoiding any prompts is crucial, or else these automated processes will not complete. - -I hope the four examples I shared above help you understand how certain circumstances may require the use of force. You should have a strong understanding of the force option when used at the command line or in creating automation scripts. It's misuse can have devastating effects—sometimes across your infrastructure, and not only on a single machine. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/5/may-the-force-linux - -作者:[Alan Formy-Duval ][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/alanfdoss -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fireworks_light_art_design.jpg?itok=hfx9i4By (Fireworks) -[2]: https://www.starwars.com/star-wars-day -[3]: http://man7.org/linux/man-pages/man1/cp.1.html -[4]: http://man7.org/linux/man-pages/man1/ln.1.html -[5]: http://man7.org/linux/man-pages/man1/rm.1.html -[6]: http://man7.org/linux/man-pages/man8/userdel.8.html diff --git a/sources/tech/20190505 Blockchain 2.0 - An Introduction To Hyperledger Project (HLP) -Part 8.md b/sources/tech/20190505 Blockchain 2.0 - An Introduction To Hyperledger Project (HLP) -Part 8.md deleted file mode 100644 index bb1d187ea4..0000000000 --- a/sources/tech/20190505 Blockchain 2.0 - An Introduction To Hyperledger Project (HLP) -Part 8.md +++ /dev/null @@ -1,88 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Blockchain 2.0 – An Introduction To Hyperledger Project (HLP) [Part 8]) -[#]: via: (https://www.ostechnix.com/blockchain-2-0-an-introduction-to-hyperledger-project-hlp/) -[#]: author: (editor https://www.ostechnix.com/author/editor/) - -Blockchain 2.0 – An Introduction To Hyperledger Project (HLP) [Part 8] -====== - -![Introduction To Hyperledger Project][1] - -Once a new technology platform reaches a threshold level of popularity in terms of active development and commercial interests, major global companies and smaller start-ups alike rush to catch a slice of the pie. **Linux** was one such platform back in the day. Once the ubiquity of its applications was realized individuals, firms, and institutions started displaying their interest in it and by 2000 the **Linux foundation** was formed. - -The Linux foundation aims to standardize and develop Linux as a platform by sponsoring their development team. The Linux Foundation is a non-profit organization that is supported by software and IT behemoths such as Microsoft, Oracle, Samsung, Cisco, IBM, Intel among others[1]. This is excluding the hundreds of individual developers who offer their services for the betterment of the platform. Over the years the Linux foundation has taken many projects under its roof. The **Hyperledger Project** is their fastest growing one till date. - -Such consortium led development have a lot of advantages when it comes to furthering tech into usable useful forms. Developing the standards, libraries and all the back-end protocols for large scale projects are expensive and resource intensive without a shred of income generating from it. Hence, it makes sense for companies to pool in their resources to develop the common “boring” parts by supporting such organizations and later upon completing work on these standard parts to simply plug & play and customize their products afterwards. Apart from the economics of the model, such collaborative efforts also yield standards allowing for easier use and integration into aspiring products and services. - -Other major innovations that were once or are currently being developed following the said consortium model include standards for WiFi (The Wi-Fi alliance), Mobile Telephony etc. - -### Introduction to Hyperledger Project (HLP) - -The Hyperledger project was launched in December 2015 by the Linux foundation as is currently among the fastest growing project they’ve incubated. It’s an umbrella organization for collaborative efforts into developing and advancing tools & standards for [**blockchain**][2] based distributed ledger technologies(DLT). Major industry players supporting the project include **IBM** , **Intel** and **SAP Ariba** among [**others**][3]. The HLP aims to create frameworks for individuals and companies to create shared as well as closed blockchains as required to further their own requirements. The design principles include a strong tilt toward developing a globally deployable, scalable, robust platform with a focus on privacy, and future auditability[2]. It is also important to note that most of the blockchains proposed and the frame. - -### Development goals and structure: Making it plug & play - -Although enterprise facing platforms exist from the likes of the Ethereum alliance, HLP is by definition business facing and supported by industry behemoths who contribute and further development in the many modules that come under the HLP banner. The HLP incubates projects in development after their induction into the cause and after finishing work on it and correcting the knick-knacks rolls it out for the public. Members of the Hyperledger project contribute their own work such as how IBM contributed their Fabric platform for collaborative development. The codebase is absorbed and developed in house by the group in the project and rolled out for all members equally for their use. - -Such processes make the modules in HLP highly flexible plug-in frameworks which will support rapid development and roll-outs in enterprise settings. Furthermore, other comparable platforms are open **permission-less blockchains** or rather **public chains** by default and even though it is possible to adapt them to specific applications, HLP modules support the feature natively. - -The differences and use cases of public & private blockchains are covered more [**here**][4] in this comparative primer on the same. - -The Hyperledger project’s mission is four-fold according to **Brian Behlendorf** , the executive director of the project. - -They are: - - 1. To create an enterprise grade DLT framework and standards which anyone can port to suit their specific industrial or personal needs. - 2. To give rise to a robust open source community to aid the ecosystem. - 3. To promote and further participation of industry members of the said ecosystem such as member firms. - 4. To host a neutral unbiased infrastructure for the HLP community to gather and share updates and developments regarding the same. - - - -The original document can be accessed [**here**][5]****. - -### Structure of the HLP - -The **HLP consists of 12 projects** that are classified as independent modules, each usually structured and working independently to develop their module. These are first studied for their capabilities and viability before being incubated. Proposals for additions can be made by any member of the organization. After the project is incubated active development ensues after which it is rolled out. The interoperability between these modules are given a high priority, hence regular communication between these groups are maintained by the community. Currently 4 of these projects are categorized as active. The active tag implies these are ready for use but not ready for a major release yet. These 4 are arguably the most significant or rather fundamental modules to furthering the blockchain revolution. We’ll look at the individual modules and their functionalities at a later time in detail. However, a brief description of a the Hyperledger Fabric platform, arguably the most popular among them follows. - -### Hyperledger Fabric - -The **Hyperledger Fabric** [2] is a fully open-source, permissioned (non-public) blockchain-based DLT platform that is designed keeping enterprise uses in mind. The platform provides features and is structured to fit the enterprise environment. It is highly modular allowing its developers to choose from different consensus protocols, **chain code protocols ([smart contracts][6])** , or identity management systems etc., as they go along. **It is a permissioned blockchain based platform** that’s makes use of an identity management system, meaning participants will be aware of each other’s identities which is required in an enterprise setting. Fabric allows for smart contract ( _ **“chaincode”, is the term that the Hyperledger team uses**_ ) development in a variety of mainstream programming languages including **Java** , **Javascript** , **Go** etc. This allows institutions and enterprises to make use of their existing talent in the area without hiring or re-training developers to develop their own smart contracts. Fabric also uses an execute-order-validate system to handle smart contracts for better reliability compared to the standard order-validate system that is used by other platforms providing smart contract functionality. Pluggable performance, identity management systems, DBMS, Consensus platforms etc. are other features of Fabric that keeps it miles ahead of its competition. - -### Conclusion - -Projects such as the Hyperledger Fabric platforms enable a faster rate of adoption of blockchain technology in mainstream use-cases. The Hyperledger community structure itself supports open governance principles and since all the projects are led as open source platforms, this improves the security and accountability that the teams exhibit in pushing out commitments. - -Since major applications of such projects involve working with enterprises to further development of platforms and standards, the Hyperledger project is currently at a great position with respect to comparable projects by others. - -**References:** - - * **[1][Samsung takes a seat with Intel and IBM at the Linux Foundation | TheINQUIRER][7]** - * **[2] E. Androulaki et al., “Hyperledger Fabric: A Distributed Operating System for Permissioned Blockchains,” 2018.** - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/blockchain-2-0-an-introduction-to-hyperledger-project-hlp/ - -作者:[editor][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/editor/ -[b]: https://github.com/lujun9972 -[1]: https://www.ostechnix.com/wp-content/uploads/2019/04/Introduction-To-Hyperledger-Project-720x340.png -[2]: https://www.ostechnix.com/blockchain-2-0-an-introduction/ -[3]: https://www.hyperledger.org/members -[4]: https://www.ostechnix.com/blockchain-2-0-public-vs-private-blockchain-comparison/ -[5]: http://www.hitachi.com/rev/archive/2017/r2017_01/expert/index.html -[6]: https://www.ostechnix.com/blockchain-2-0-explaining-smart-contracts-and-its-types/ -[7]: https://www.theinquirer.net/inquirer/news/2182438/samsung-takes-seat-intel-ibm-linux-foundation diff --git a/sources/tech/20190505 Blockchain 2.0 - Public Vs Private Blockchain Comparison -Part 7.md b/sources/tech/20190505 Blockchain 2.0 - Public Vs Private Blockchain Comparison -Part 7.md deleted file mode 100644 index a954e8514e..0000000000 --- a/sources/tech/20190505 Blockchain 2.0 - Public Vs Private Blockchain Comparison -Part 7.md +++ /dev/null @@ -1,106 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Blockchain 2.0 – Public Vs Private Blockchain Comparison [Part 7]) -[#]: via: (https://www.ostechnix.com/blockchain-2-0-public-vs-private-blockchain-comparison/) -[#]: author: (editor https://www.ostechnix.com/author/editor/) - -Blockchain 2.0 – Public Vs Private Blockchain Comparison [Part 7] -====== - -![Public vs Private blockchain][1] - -The previous part of the [**Blockchain 2.0**][2] series explored the [**the state of Smart contracts**][3] now. This post intends to throw some light on the different types of blockchains that can be created. Each of these are used for vastly different applications and depending on the use cases, the protocol followed by each of these differ. Now let us go ahead and learn about **Public vs Private blockchain comparison** with Open source and proprietary technology. - -The fundamental three-layer structure of a blockchain based distributed ledger as we know is as follows: - -![][4] - -Figure 1 – Fundamental structure of Blockchain-based ledgers - -The differences between the types mentioned here is attributable primarily to the protocol that rests on the underlying blockchain. The protocol dictates rules for the participants and the behavior of the blockchain in response to the said participation. - -Remember to keep the following things in mind while reading through this article: - - * Platforms such as these are always created to solve a use-case requirement. There is no one direction that the technology should take that is best. Blockchains for instance have tremendous applications and some of these might require dropping features that seem significant in other settings. **Decentralized storage** is a major example in this regard. - * Blockchains are basically database systems keeping track of information by timestamping and organizing data in the form of blocks. Creators of such blockchains can choose who has the right to make these blocks and perform alterations. - * Blockchains can be “centralized” as well, and participation in varying extents can be limited to those who this “central authority” deems eligible. - - - -Most blockchains are either **public** or **private**. Broadly speaking, public blockchains can be considered as being the equivalent of open source software and most private blockchains can be seen as proprietary platforms deriving from the public ones. The figure below should make the basic difference obvious to most of you. - -![][5] - -Figure 2 – Public vs Private blockchain comparison with Open source and Proprietary Technology - -This is not to say that all private blockchains are derived from open public ones. The most popular ones however usually are though. - -### Public Blockchains - -A public blockchain can be considered as a **permission-less platform** or **network**. Anyone with the knowhow and computing resources can participate in it. This will have the following implications: - - * Anyone can join and participate in a public blockchain network. All the “participant” needs is a stable internet connection along with computing resources. - * Participation will include reading, writing, verifying, and providing consensus during transactions. An example for participating individuals would be **Bitcoin miners**. In exchange for participating in the network the miners are paid back in Bitcoins in this case. - * The platform is decentralized completely and fully redundant. - * Because of the decentralized nature, no one entity has complete control over the data recorded in the ledger. To validate a block all (or most) participants need to vet the data. - * This means that once information is verified and recorded, it cannot be altered easily. Even if it is, its impossible to not leave marks. - * The identity of participants remains anonymous by design in platforms such as **BITCOIN** and **LITECOIN**. These platforms by design aim for protecting and securing user identities. This is primarily a feature provided by the overlying protocol stack. - * Examples for public blockchain networks are **BITCOIN** , **LITECOIN** , **ETHEREUM** etc. - * Extensive decentralizations mean that gaining consensus on transactions might take a while compared to what is typically possible over blockchain ledger networks and throughput can be a challenge for large enterprises aiming for pushing a very high number of transactions every instant. - * The open participation and often the high number of such participants in open chains such as bitcoin add up to considerable initial investments in computing equipment and energy costs. - - - -### Private Blockchain - -In contrast, a private blockchain is a **permissioned blockchain**. Meaning: - - * Permission to participate in the network is restricted and is presided over by the owner or institution overseeing the network. Meaning even though an individual will be able to store data and transact (send and receive payments for example), the validation and storage of these transactions will be done only by select participants. - * Participation even once permission is given by the central authority will be limited by terms. For instance, in case of a private blockchain network run by a financial institution, not every customer will have access to the entire blockchain ledger, and even among those with the permission, not everyone will be able to access everything. Permissions to access select services will be given by the central figure in this case. This is often referred to as **“channeling”**. - * Such systems have significantly larger throughput capabilities and also showcase much faster transaction speeds compared to their public counterparts because a block of information only needs to be validated by a select few. - * Security by design is something the public blockchains are renowned for. They achieve this -by: - * Anonymizing participants, - * Distributed & redundant but encrypted storage on multiple nodes, - * Mass consensus required for creating and altering data. - - - -Private blockchains usually don’t feature any of these in their protocol. This makes the system only as secure as most cloud-based database systems currently in use. - -### A note for the wise - -An important point to note is this, the fact that they’re named public or private (or open or closed) has nothing to do with the underlying code base. The code or the literal foundations on which the platforms are based on may or may not be publicly available and or developed in either of these cases. **R3** is a **DLT** ( **D** istributed **L** edger **T** echnology) company that leads a public consortium of over 200 multinational institutions. Their aim is to further development of blockchain and related distributed ledger technology in the domain of finance and commerce. **Corda** is the product of this joint effort. R3 defines corda as a blockchain platform that is built specially for businesses. The codebase for the same is open source and developers all over the world are encouraged to contribute to the project. However, given its business facing nature and the needs it is meant to address, corda would be categorized as a permissioned closed blockchain platform. Meaning businesses can choose the participants of the network once it is deployed and choose the kind of information these participants can access through the use of natively available smart contract tools. - -While it is a reality that public platforms like Bitcoin and Ethereum are responsible for the widespread awareness and development going on in the space, it can still be argued that private blockchains designed for specific use cases in enterprise or business settings is what will lead monetary investments in the short run. These are the platforms most of us will see implemented the near future in practical ways. - -Read the next guide about Hyperledger project in this series. - - * [**Blockchain 2.0 – An Introduction To Hyperledger Project (HLP)**][6] - - - -We are working on many interesting topics on Blockchain technology. Stay tuned! - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/blockchain-2-0-public-vs-private-blockchain-comparison/ - -作者:[editor][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/editor/ -[b]: https://github.com/lujun9972 -[1]: https://www.ostechnix.com/wp-content/uploads/2019/04/Public-Vs-Private-Blockchain-720x340.png -[2]: https://www.ostechnix.com/blockchain-2-0-an-introduction/ -[3]: https://www.ostechnix.com/blockchain-2-0-ongoing-projects-the-state-of-smart-contracts-now/ -[4]: http://www.ostechnix.com/wp-content/uploads/2019/04/blockchain-architecture.png -[5]: http://www.ostechnix.com/wp-content/uploads/2019/04/Public-vs-Private-blockchain-comparison.png -[6]: https://www.ostechnix.com/blockchain-2-0-an-introduction-to-hyperledger-project-hlp/ diff --git a/sources/tech/20190505 Blockchain 2.0 - What Is Ethereum -Part 9.md b/sources/tech/20190505 Blockchain 2.0 - What Is Ethereum -Part 9.md deleted file mode 100644 index a4669a2eb0..0000000000 --- a/sources/tech/20190505 Blockchain 2.0 - What Is Ethereum -Part 9.md +++ /dev/null @@ -1,83 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Blockchain 2.0 – What Is Ethereum [Part 9]) -[#]: via: (https://www.ostechnix.com/blockchain-2-0-what-is-ethereum/) -[#]: author: (editor https://www.ostechnix.com/author/editor/) - -Blockchain 2.0 – What Is Ethereum [Part 9] -====== - -![Ethereum][1] - -In the previous guide of this series, we discussed about [**Hyperledger Project (HLP)**][2], a fastest growing product developed by **Linux Foundation**. In this guide, we are going to discuss about what is **Ethereum** and its features in detail. Many researchers opine that the future of the internet will be based on principles of decentralized computing. Decentralized computing was in fact among one of the broader objectives of having the internet in the first place. However, the internet took another turn owing to differences in computing capabilities available. While modern server capabilities make the case for server-side processing and execution, lack of decent mobile networks in large parts of the world make the case for the same on the client side. Modern smartphones now have **SoCs** (system on a chip or system on chip) capable of handling many such operations on the client side itself, however, limitations owing to retrieving and storing data securely still pushes developers to have server-side computing and data management. Hence, a bottleneck in regards to data transfer capabilities is currently observed. - -All of that might soon change because of advancements in distributed data storage and program execution platforms. [**The blockchain**][3], for the first time in the history of the internet, basically allows for secure data management and program execution on a distributed network of users as opposed to central servers. - -**Ethereum** is one such blockchain platform that gives developers access to frameworks and tools used to build and run applications on such a decentralized network. Though more popularly known in general for its cryptocurrency, Ethereum is more than just **ethers** (the cryptocurrency). It’s a full **Turing complete programming language** that is designed to develop and deploy **DApps** or **Distributed APPlications** [1]. We’ll look at DApps in more detail in one of the upcoming posts. - -Ethereum is an open-source, supports by default a public (non-permissioned) blockchain, and features an extensive smart contract platform **(Solidity)** underneath. Ethereum provides a virtual computing environment called the **Ethereum virtual machine** to run applications and [**smart contracts**][4] as well[2]. The Ethereum virtual machine runs on thousands of participating nodes all over the world, meaning the application data while being secure, is almost impossible to be tampered with or lost. - -### Getting behind Ethereum: What sets it apart - -In 2017, a 30 plus group of the who’s who of the tech and financial world got together to leverage the Ethereum blockchain’s capabilities. Thus, the **Ethereum Enterprise Alliance (EEA)** was formed by a long list of supporting members including _Microsoft_ , _JP Morgan_ , _Cisco Systems_ , _Deloitte_ , and _Accenture_. JP Morgan already has **Quorum** , a decentralized computing platform for financial services based on Ethereum currently in operation, while Microsoft has Ethereum based cloud services it markets through its Azure cloud business[3]. - -### What is ether and how is it related to Ethereum - -Ethereum creator **Vitalik Buterin** understood the true value of a decentralized processing platform and the underlying blockchain tech that powered bitcoin. He failed to gain majority agreement for his idea of proposing that Bitcoin should be developed to support running distributed applications (DApps) and programs (now referred to as smart contracts). - -Hence in 2013, he proposed the idea of Ethereum in a white paper he published. The original white paper is still maintained and available for readers **[here][5]**. The idea was to develop a blockchain based platform to run smart contracts and applications designed to run on nodes and user devices instead of servers. - -The Ethereum system is often mistaken to just mean the cryptocurrency ether, however, it has to be reiterated that Ethereum is a full stack platform for developing applications and executing them as well and has been so since inception whereas bitcoin isn’t. **Ether is currently the second biggest cryptocurrency** by market capitalization and trades at an average of $170 per ether at the time of writing this article[4]. - -### Features and technicalities of the platform[5] - - * As we’ve already mentioned, the cryptocurrency called ether is simply one of the things the platform features. The purpose of the system is more than taking care of financial transactions. In fact, the key difference between the Ethereum platform and Bitcoin is in their scripting capabilities. Ethereum is developed in a Turing complete programming language which means it has scripting and application capabilities similar to other major programming languages. Developers require this feature to create DApps and complex smart contracts on the platform, a feature that bitcoin misses on. - * The “mining” process of ether is more stringent and complex. While specialized ASICs may be used to mine bitcoin, the basic hashing algorithm used by Ethereum **(EThash)** reduces the advantage that ASICs have in this regard. - * The transaction fees itself to be paid as an incentive to miners and node operators for running the network is calculated using a computational token called **Gas**. Gas improves the system’s resilience and resistance to external hacks and attacks by requiring the initiator of the transaction to pay ethers proportionate to the number of computational resources that are required to carry out that transaction. This is in contrast to other platforms such as Bitcoin where the transaction fee is measured in tandem with the transaction size. As such, the average transaction costs in Ethereum is radically less than Bitcoin. This also implies that running applications running on the Ethereum virtual machine will require a fee depending straight up on the computational problems that the application is meant to solve. Basically, the more complex an execution, the more the fee. - * The block time for Ethereum is estimated to be around _**10-15 seconds**_. The block time is the average time that is required to timestamp and create a block on the blockchain network. Compared to the 10+ minutes the same transaction will take on the bitcoin network, it becomes apparent that _**Ethereum is much faster**_ with respect to transactions and verification of blocks. - * _It is also interesting to note that there is no hard cap on the amount of ether that can be mined or the rate at which ether can be mined leading to less radical system design than bitcoin._ - - - -### Conclusion - -While Ethereum is comparable and far outpaces similar platforms, the platform itself lacked a definite path for development until the Ethereum enterprise alliance started pushing it. While the definite push for enterprise developments are made by the Ethereum platform, it has to be noted that Ethereum also caters to small-time developers and individuals as well. As such developing the platform for end users and enterprises leave a lot of specific functionality out of the loop for Ethereum. Also, the blockchain model proposed and developed by the Ethereum foundation is a public model whereas the one proposed by projects such as the Hyperledger project is private and permissioned. - -While only time can tell which platform among the ones put forward by Ethereum, Hyperledger, and R3 Corda among others will find the most fans in real-world use cases, such systems do prove the validity behind the claim of a blockchain powered future. - -**References:** - - * [1] [**Gabriel Nicholas, “Ethereum Is Coding’s New Wild West | WIRED,” Wired , 2017**][6]. - * [2] [**What is Ethereum? — Ethereum Homestead 0.1 documentation**][7]. - * [3] [**Ethereum, a Virtual Currency, Enables Transactions That Rival Bitcoin’s – The New York Times**][8]. - * [4] [**Cryptocurrency Market Capitalizations | CoinMarketCap**][9]. - * [5] [**Introduction — Ethereum Homestead 0.1 documentation**][10]. - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/blockchain-2-0-what-is-ethereum/ - -作者:[editor][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/editor/ -[b]: https://github.com/lujun9972 -[1]: https://www.ostechnix.com/wp-content/uploads/2019/04/Ethereum-720x340.png -[2]: https://www.ostechnix.com/blockchain-2-0-an-introduction-to-hyperledger-project-hlp/ -[3]: https://www.ostechnix.com/blockchain-2-0-an-introduction/ -[4]: https://www.ostechnix.com/blockchain-2-0-explaining-smart-contracts-and-its-types/ -[5]: https://github.com/ethereum/wiki/wiki/White-Paper -[6]: https://www.wired.com/story/ethereum-is-codings-new-wild-west/ -[7]: http://www.ethdocs.org/en/latest/introduction/what-is-ethereum.html#ethereum-virtual-machine -[8]: https://www.nytimes.com/2016/03/28/business/dealbook/ethereum-a-virtual-currency-enables-transactions-that-rival-bitcoins.html -[9]: https://coinmarketcap.com/ -[10]: http://www.ethdocs.org/en/latest/introduction/index.html diff --git a/sources/tech/20190505 Duc - A Collection Of Tools To Inspect And Visualize Disk Usage.md b/sources/tech/20190505 Duc - A Collection Of Tools To Inspect And Visualize Disk Usage.md deleted file mode 100644 index edba21d327..0000000000 --- a/sources/tech/20190505 Duc - A Collection Of Tools To Inspect And Visualize Disk Usage.md +++ /dev/null @@ -1,261 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Duc – A Collection Of Tools To Inspect And Visualize Disk Usage) -[#]: via: (https://www.ostechnix.com/duc-a-collection-of-tools-to-inspect-and-visualize-disk-usage/) -[#]: author: (sk https://www.ostechnix.com/author/sk/) - -Duc – A Collection Of Tools To Inspect And Visualize Disk Usage -====== - -![Duc - A Collection Of Tools To Inspect And Visualize Disk Usage][1] - -**Duc** is a collection of tools that can be used to index, inspect and visualize disk usage on Unix-like operating systems. Don’t think of it as a simple CLI tool that merely displays a fancy graph of your disk usage. It is built to scale quite well on huge filesystems. Duc has been tested on systems that consisted of more than 500 million files and several petabytes of storage without any problems. - -Duc is quite fast and versatile tool. It stores your disk usage in an optimized database, so you can quickly find where your bytes are as soon as the index is completed. In addition, it comes with various user interfaces and back-ends to access the database and draw the graphs. - -Here is the list of currently supported user interfaces (UI): - - 1. Command line interface (ls), - 2. Ncurses console interface (ui), - 3. X11 GUI (duc gui), - 4. OpenGL GUI (duc gui). - - - -List of supported database back-ends: - - * Tokyocabinet, - * Leveldb, - * Sqlite3. - - - -Duc uses **Tokyocabinet** as default database backend. - -### Install Duc - -Duc is available in the default repositories of Debian and its derivatives such as Ubuntu. So installing Duc on DEB-based systems is a piece of cake. - -``` -$ sudo apt-get install duc -``` - -On other Linux distributions, you may need to manually compile and install Duc from source as shown below. - -Download latest duc source .tgz file from the [**releases**][2] page on github. As of writing this guide, the latest version was **1.4.4**. - -``` -$ wget https://github.com/zevv/duc/releases/download/1.4.4/duc-1.4.4.tar.gz -``` - -Then run the following commands one by one to install DUC. - -``` -$ tar -xzf duc-1.4.4.tar.gz -$ cd duc-1.4.4 -$ ./configure -$ make -$ sudo make install -``` - -### Duc Usage - -The typical usage of duc is: - -``` -$ duc -``` - -You can view the list of general options and sub-commands by running the following command: - -``` -$ duc help -``` - -You can also know the the usage of a specific subcommand as below. - -``` -$ duc help -``` - -To view the extensive list of all commands and their options, simply run: - -``` -$ duc help --all -``` - -Let us now se some practical use cases of duc utility. - -### Create Index (database) - -First of all, you need to create an index file (database) of your filesystem. To create an index file, use “duc index” command. - -For example, to create an index of your **/home** directory, simply run: - -``` -$ duc index /home -``` - -The above command will create the index of your /home/ directory and save it in **$HOME/.duc.db** file. If you have added new files/directories in the /home directory in future, just re-run the above command at any time later to rebuild the index. - -### Query Index - -Duc has various sub-commands to query and explore the index. - -To view the list of available indexes, run: - -``` -$ duc info -``` - -**Sample output:** - -``` -Date Time Files Dirs Size Path -2019-04-09 15:45:55 3.5K 305 654.6M /home -``` - -As you see in the above output, I have already indexed the /home directory. - -To list all files and directories in the current working directory, you can do: - -``` -$ duc ls -``` - -To list files/directories in a specific directory, for example **/home/sk/Downloads** , just pass the path as argument like below. - -``` -$ duc ls /home/sk/Downloads -``` - -Similarly, run **“duc ui”** command to open a **ncurses** based console user interface for exploring the file system usage and run **“duc gui”** to start a **graphical (X11)** interface to explore the file system. - -To know more about a sub-command usage, simply refer the help section. - -``` -$ duc help ls -``` - -The above command will display the help section of “ls” subcommand. - -### Visualize Disk Usage - -In the previous section, we have seen how to list files and directories using duc subcommands. In addition, you can even show the file sizes in a fancy graph. - -To show the graph of a given path, use “ls” subcommand like below. - -``` -$ duc ls -Fg /home/sk -``` - -Sample output: - -![][3] - -Visualize disk usage using “duc ls” command - -As you see in the above output, the “ls” subcommand queries the duc database and lists the inclusive size of all -files and directories of the given path i.e **/home/sk/** in this case. - -Here, the **“-F”** option is used to append file type indicator (one of */) to entries and the **“-g”** option is used to draw graph with relative size for each entry. - -Please note that if no path is given, the current working directory is explored. - -You can use **-R** option to view the disk usage result in [**tree**][4] structure. - -``` -$ duc ls -R /home/sk -``` - -![][5] - -Visualize disk usage in tree structure - -To query the duc database and open a **ncurses** based console user interface for exploring the disk usage of given path, use **“ui”** subcommand like below. - -``` -$ duc ui /home/sk -``` - -![][6] - -Similarly, we use **“gui”** subcommand to query the duc database and start a **graphical (X11)** interface to explore the disk usage of the given path: - -``` -$ duc gui /home/sk -``` - -![][7] - -Like I already mentioned earlier, we can learn more about a subcommand usage like below. - -``` -$ duc help -``` - -I covered the basic usage part only. Refer man pages for more details about “duc” tool. - -``` -$ man duc -``` - -* * * - -**Related read:** - - * [**Filelight – Visualize Disk Usage On Your Linux System**][8] - * [**Some Good Alternatives To ‘du’ Command**][9] - * [**How To Check Disk Space Usage In Linux Using Ncdu**][10] - * [**Agedu – Find Out Wasted Disk Space In Linux**][11] - * [**How To Find The Size Of A Directory In Linux**][12] - * [**The df Command Tutorial With Examples For Beginners**][13] - - - -* * * - -### Conclusion - -Duc is simple yet useful disk usage viewer. If you want to quickly and easily know which files/directories are eating up your disk space, Duc might be a good choice. What are you waiting for? Go get this tool already, scan your filesystem and get rid of unused files/directories. - -And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! - -Cheers! - -**Resource:** - - * [**Duc website**][14] - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/duc-a-collection-of-tools-to-inspect-and-visualize-disk-usage/ - -作者:[sk][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/sk/ -[b]: https://github.com/lujun9972 -[1]: https://www.ostechnix.com/wp-content/uploads/2019/04/duc-720x340.png -[2]: https://github.com/zevv/duc/releases -[3]: http://www.ostechnix.com/wp-content/uploads/2019/04/duc-1-1.png -[4]: https://www.ostechnix.com/view-directory-tree-structure-linux/ -[5]: http://www.ostechnix.com/wp-content/uploads/2019/04/duc-2.png -[6]: http://www.ostechnix.com/wp-content/uploads/2019/04/duc-3.png -[7]: http://www.ostechnix.com/wp-content/uploads/2019/04/duc-4.png -[8]: https://www.ostechnix.com/filelight-visualize-disk-usage-on-your-linux-system/ -[9]: https://www.ostechnix.com/some-good-alternatives-to-du-command/ -[10]: https://www.ostechnix.com/check-disk-space-usage-linux-using-ncdu/ -[11]: https://www.ostechnix.com/agedu-find-out-wasted-disk-space-in-linux/ -[12]: https://www.ostechnix.com/find-size-directory-linux/ -[13]: https://www.ostechnix.com/the-df-command-tutorial-with-examples-for-beginners/ -[14]: https://duc.zevv.nl/ diff --git a/sources/tech/20190507 Prefer table driven tests.md b/sources/tech/20190507 Prefer table driven tests.md new file mode 100644 index 0000000000..0a41860207 --- /dev/null +++ b/sources/tech/20190507 Prefer table driven tests.md @@ -0,0 +1,521 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Prefer table driven tests) +[#]: via: (https://dave.cheney.net/2019/05/07/prefer-table-driven-tests) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +Prefer table driven tests +====== + +I’m a big fan of testing, specifically [unit testing][1] and TDD ([done correctly][2], of course). A practice that has grown around Go projects is the idea of a table driven test. This post explores the how and why of writing a table driven test. + +Let’s say we have a function that splits strings: + +``` +// Split slices s into all substrings separated by sep and +// returns a slice of the substrings between those separators. +func Split(s, sep string) []string { + var result []string + i := strings.Index(s, sep) + for i > -1 { + result = append(result, s[:i]) + s = s[i+len(sep):] + i = strings.Index(s, sep) + } + return append(result, s) +} +``` + +In Go, unit tests are just regular Go functions (with a few rules) so we write a unit test for this function starting with a file in the same directory, with the same package name, `strings`. + +``` +package split + +import ( + "reflect" + "testing" +) + +func TestSplit(t *testing.T) { + got := Split("a/b/c", "/") + want := []string{"a", "b", "c"} + if !reflect.DeepEqual(want, got) { + t.Fatalf("expected: %v, got: %v", want, got) + } +} +``` + +Tests are just regular Go functions with a few rules: + + 1. The name of the test function must start with `Test`. + 2. The test function must take one argument of type `*testing.T`. A `*testing.T` is a type injected by the testing package itself, to provide ways to print, skip, and fail the test. + + + +In our test we call `Split` with some inputs, then compare it to the result we expected. + +### Code coverage + +The next question is, what is the coverage of this package? Luckily the go tool has a built in branch coverage. We can invoke it like this: + +``` +% go test -coverprofile=c.out +PASS +coverage: 100.0% of statements +ok split 0.010s +``` + +Which tells us we have 100% branch coverage, which isn’t really surprising, there’s only one branch in this code. + +If we want to dig in to the coverage report the go tool has several options to print the coverage report. We can use `go tool cover -func` to break down the coverage per function: + +``` +% go tool cover -func=c.out +split/split.go:8: Split 100.0% +total: (statements) 100.0% +``` + +Which isn’t that exciting as we only have one function in this package, but I’m sure you’ll find more exciting packages to test. + +#### Spray some .bashrc on that + +This pair of commands is so useful for me I have a shell alias which runs the test coverage and the report in one command: + +``` +cover () { + local t=$(mktemp -t cover) + go test $COVERFLAGS -coverprofile=$t $@ \ + && go tool cover -func=$t \ + && unlink $t +} +``` + +### Going beyond 100% coverage + +So, we wrote one test case, got 100% coverage, but this isn’t really the end of the story. We have good branch coverage but we probably need to test some of the boundary conditions. For example, what happens if we try to split it on comma? + +``` +func TestSplitWrongSep(t *testing.T) { + got := Split("a/b/c", ",") + want := []string{"a/b/c"} + if !reflect.DeepEqual(want, got) { + t.Fatalf("expected: %v, got: %v", want, got) + } +} +``` + +Or, what happens if there are no separators in the source string? + +``` +func TestSplitNoSep(t *testing.T) { + got := Split("abc", "/") + want := []string{"abc"} + if !reflect.DeepEqual(want, got) { + t.Fatalf("expected: %v, got: %v", want, got) + } +} +``` + +We’re starting build a set of test cases that exercise boundary conditions. This is good. + +### Introducing table driven tests + +However the there is a lot of duplication in our tests. For each test case only the input, the expected output, and name of the test case change. Everything else is boilerplate. What we’d like to to set up all the inputs and expected outputs and feel them to a single test harness. This is a great time to introduce table driven testing. + +``` +func TestSplit(t *testing.T) { + type test struct { + input string + sep string + want []string + } + + tests := []test{ + {input: "a/b/c", sep: "/", want: []string{"a", "b", "c"}}, + {input: "a/b/c", sep: ",", want: []string{"a/b/c"}}, + {input: "abc", sep: "/", want: []string{"abc"}}, + } + + for _, tc := range tests { + got := Split(tc.input, tc.sep) + if !reflect.DeepEqual(tc.want, got) { + t.Fatalf("expected: %v, got: %v", tc.want, got) + } + } +} +``` + +We declare a structure to hold our test inputs and expected outputs. This is our table. The `tests` structure is usually a local declaration because we want to reuse this name for other tests in this package. + +In fact, we don’t even need to give the type a name, we can use an anonymous struct literal to reduce the boilerplate like this: + +``` +func TestSplit(t *testing.T) { + tests := []struct { + input string + sep string + want []string + }{ + {input: "a/b/c", sep: "/", want: []string{"a", "b", "c"}}, + {input: "a/b/c", sep: ",", want: []string{"a/b/c"}}, + {input: "abc", sep: "/", want: []string{"abc"}}, + } + + for _, tc := range tests { + got := Split(tc.input, tc.sep) + if !reflect.DeepEqual(tc.want, got) { + t.Fatalf("expected: %v, got: %v", tc.want, got) + } + } +} +``` + +Now, adding a new test is a straight forward matter; simply add another line the `tests` structure. For example, what will happen if our input string has a trailing separator? + +``` +{input: "a/b/c", sep: "/", want: []string{"a", "b", "c"}}, +{input: "a/b/c", sep: ",", want: []string{"a/b/c"}}, +{input: "abc", sep: "/", want: []string{"abc"}}, +{input: "a/b/c/", sep: "/", want: []string{"a", "b", "c"}}, // trailing sep +``` + +But, when we run `go test`, we get + +``` +% go test +--- FAIL: TestSplit (0.00s) + split_test.go:24: expected: [a b c], got: [a b c ] +``` + +Putting aside the test failure, there are a few problems to talk about. + +The first is by rewriting each test from a function to a row in a table we’ve lost the name of the failing test. We added a comment in the test file to call out this case, but we don’t have access to that comment in the `go test` output. + +There are a few ways to resolve this. You’ll see a mix of styles in use in Go code bases because the table testing idiom is evolving as people continue to experiment with the form. + +### Enumerating test cases + +As tests are stored in a slice we can print out the index of the test case in the failure message: + +``` +func TestSplit(t *testing.T) { + tests := []struct { + input string + sep . string + want []string + }{ + {input: "a/b/c", sep: "/", want: []string{"a", "b", "c"}}, + {input: "a/b/c", sep: ",", want: []string{"a/b/c"}}, + {input: "abc", sep: "/", want: []string{"abc"}}, + {input: "a/b/c/", sep: "/", want: []string{"a", "b", "c"}}, + } + + for i, tc := range tests { + got := Split(tc.input, tc.sep) + if !reflect.DeepEqual(tc.want, got) { + t.Fatalf("test %d: expected: %v, got: %v", i+1, tc.want, got) + } + } +} +``` + +Now when we run `go test` we get this + +``` +% go test +--- FAIL: TestSplit (0.00s) + split_test.go:24: test 4: expected: [a b c], got: [a b c ] +``` + +Which is a little better. Now we know that the fourth test is failing, although we have to do a little bit of fudging because slice indexing—​and range iteration—​is zero based. This requires consistency across your test cases; if some use zero base reporting and others use one based, it’s going to be confusing. And, if the list of test cases is long, it could be difficult to count braces to figure out exactly which fixture constitutes test case number four. + +### Give your test cases names + +Another common pattern is to include a name field in the test fixture. + +``` +func TestSplit(t *testing.T) { + tests := []struct { + name string + input string + sep string + want []string + }{ + {name: "simple", input: "a/b/c", sep: "/", want: []string{"a", "b", "c"}}, + {name: "wrong sep", input: "a/b/c", sep: ",", want: []string{"a/b/c"}}, + {name: "no sep", input: "abc", sep: "/", want: []string{"abc"}}, + {name: "trailing sep", input: "a/b/c/", sep: "/", want: []string{"a", "b", "c"}}, + } + + for _, tc := range tests { + got := Split(tc.input, tc.sep) + if !reflect.DeepEqual(tc.want, got) { + t.Fatalf("%s: expected: %v, got: %v", tc.name, tc.want, got) + } + } +} +``` + +Now when the test fails we have a descriptive name for what the test was doing. We no longer have to try to figure it out from the output—​also, now have a string we can search on. + +``` +% go test +--- FAIL: TestSplit (0.00s) + split_test.go:25: trailing sep: expected: [a b c], got: [a b c ] +``` + +We can dry this up even more using a map literal syntax: + +``` +func TestSplit(t *testing.T) { + tests := map[string]struct { + input string + sep string + want []string + }{ + "simple": {input: "a/b/c", sep: "/", want: []string{"a", "b", "c"}}, + "wrong sep": {input: "a/b/c", sep: ",", want: []string{"a/b/c"}}, + "no sep": {input: "abc", sep: "/", want: []string{"abc"}}, + "trailing sep": {input: "a/b/c/", sep: "/", want: []string{"a", "b", "c"}}, + } + + for name, tc := range tests { + got := Split(tc.input, tc.sep) + if !reflect.DeepEqual(tc.want, got) { + t.Fatalf("%s: expected: %v, got: %v", name, tc.want, got) + } + } +} +``` + +Using a map literal syntax we define our test cases not as a slice of structs, but as map of test names to test fixtures. There’s also a side benefit of using a map that is going to potentially improve the utility of our tests. + +Map iteration order is _undefined_ 1 This means each time we run `go test`, our tests are going to be potentially run in a different order. + +This is super useful for spotting conditions where test pass when run in statement order, but not otherwise. If you find that happens you probably have some global state that is being mutated by one test with subsequent tests depending on that modification. + +### Introducing sub tests + +Before we fix the failing test there are a few other issues to address in our table driven test harness. + +The first is we’re calling `t.Fatalf` when one of the test cases fails. This means after the first failing test case we stop testing the other cases. Because test cases are run in an undefined order, if there is a test failure, it would be nice to know if it was the only failure or just the first. + +The testing package would do this for us if we go to the effort to write out each test case as its own function, but that’s quite verbose. The good news is since Go 1.7 a new feature was added that lets us do this easily for table driven tests. They’re called [sub tests][3]. + +``` +func TestSplit(t *testing.T) { + tests := map[string]struct { + input string + sep string + want []string + }{ + "simple": {input: "a/b/c", sep: "/", want: []string{"a", "b", "c"}}, + "wrong sep": {input: "a/b/c", sep: ",", want: []string{"a/b/c"}}, + "no sep": {input: "abc", sep: "/", want: []string{"abc"}}, + "trailing sep": {input: "a/b/c/", sep: "/", want: []string{"a", "b", "c"}}, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + got := Split(tc.input, tc.sep) + if !reflect.DeepEqual(tc.want, got) { + t.Fatalf("expected: %v, got: %v", tc.want, got) + } + }) + } +} +``` + +As each sub test now has a name we get that name automatically printed out in any test runs. + +``` +% go test +--- FAIL: TestSplit (0.00s) + --- FAIL: TestSplit/trailing_sep (0.00s) + split_test.go:25: expected: [a b c], got: [a b c ] +``` + +Each subtest is its own anonymous function, therefore we can use `t.Fatalf`, `t.Skipf`, and all the other `testing.T`helpers, while retaining the compactness of a table driven test. + +#### Individual sub test cases can be executed directly + +Because sub tests have a name, you can run a selection of sub tests by name using the `go test -run` flag. + +``` +% go test -run=.*/trailing -v +=== RUN TestSplit +=== RUN TestSplit/trailing_sep +--- FAIL: TestSplit (0.00s) + --- FAIL: TestSplit/trailing_sep (0.00s) + split_test.go:25: expected: [a b c], got: [a b c ] +``` + +### Comparing what we got with what we wanted + +Now we’re ready to fix the test case. Let’s look at the error. + +``` +--- FAIL: TestSplit (0.00s) + --- FAIL: TestSplit/trailing_sep (0.00s) + split_test.go:25: expected: [a b c], got: [a b c ] +``` + +Can you spot the problem? Clearly the slices are different, that’s what `reflect.DeepEqual` is upset about. But spotting the actual difference isn’t easy, you have to spot that extra space after `c`. This might look simple in this simple example, but it is any thing but when you’re comparing two complicated deeply nested gRPC structures. + +We can improve the output if we switch to the `%#v` syntax to view the value as a Go(ish) declaration: + +``` +got := Split(tc.input, tc.sep) +if !reflect.DeepEqual(tc.want, got) { + t.Fatalf("expected: %#v, got: %#v", tc.want, got) +} +``` + +Now when we run our test it’s clear that the problem is there is an extra blank element in the slice. + +``` +% go test +--- FAIL: TestSplit (0.00s) + --- FAIL: TestSplit/trailing_sep (0.00s) + split_test.go:25: expected: []string{"a", "b", "c"}, got: []string{"a", "b", "c", ""} +``` + +But before we go to fix our test failure I want to talk a little bit more about choosing the right way to present test failures. Our `Split` function is simple, it takes a primitive string and returns a slice of strings, but what if it worked with structs, or worse, pointers to structs? + +Here is an example where `%#v` does not work as well: + +``` +func main() { + type T struct { + I int + } + x := []*T{{1}, {2}, {3}} + y := []*T{{1}, {2}, {4}} + fmt.Printf("%v %v\n", x, y) + fmt.Printf("%#v %#v\n", x, y) +} +``` + +The first `fmt.Printf`prints the unhelpful, but expected slice of addresses; `[0xc000096000 0xc000096008 0xc000096010] [0xc000096018 0xc000096020 0xc000096028]`. However our `%#v` version doesn’t fare any better, printing a slice of addresses cast to `*main.T`;`[]*main.T{(*main.T)(0xc000096000), (*main.T)(0xc000096008), (*main.T)(0xc000096010)} []*main.T{(*main.T)(0xc000096018), (*main.T)(0xc000096020), (*main.T)(0xc000096028)}` + +Because of the limitations in using any `fmt.Printf` verb, I want to introduce the [go-cmp][4] library from Google. + +The goal of the cmp library is it is specifically to compare two values. This is similar to `reflect.DeepEqual`, but it has more capabilities. Using the cmp pacakge you can, of course, write: + +``` +func main() { + type T struct { + I int + } + x := []*T{{1}, {2}, {3}} + y := []*T{{1}, {2}, {4}} + fmt.Println(cmp.Equal(x, y)) // false +} +``` + +But far more useful for us with our test function is the `cmp.Diff` function which will produce a textual description of what is different between the two values, recursively. + +``` +func main() { + type T struct { + I int + } + x := []*T{{1}, {2}, {3}} + y := []*T{{1}, {2}, {4}} + diff := cmp.Diff(x, y) + fmt.Printf(diff) +} +``` + +Which instead produces: + +``` +% go run +{[]*main.T}[2].I: + -: 3 + +: 4 +``` + +Telling us that at element 2 of the slice of `T`s the `I`field was expected to be 3, but was actually 4. + +Putting this all together we have our table driven go-cmp test + +``` +func TestSplit(t *testing.T) { + tests := map[string]struct { + input string + sep string + want []string + }{ + "simple": {input: "a/b/c", sep: "/", want: []string{"a", "b", "c"}}, + "wrong sep": {input: "a/b/c", sep: ",", want: []string{"a/b/c"}}, + "no sep": {input: "abc", sep: "/", want: []string{"abc"}}, + "trailing sep": {input: "a/b/c/", sep: "/", want: []string{"a", "b", "c"}}, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + got := Split(tc.input, tc.sep) + diff := cmp.Diff(tc.want, got) + if diff != "" { + t.Fatalf(diff) + } + }) + } +} +``` + +Running this we get + +``` +% go test +--- FAIL: TestSplit (0.00s) + --- FAIL: TestSplit/trailing_sep (0.00s) + split_test.go:27: {[]string}[?->3]: + -: + +: "" +FAIL +exit status 1 +FAIL split 0.006s +``` + +Using `cmp.Diff` our test harness isn’t just telling us that what we got and what we wanted were different. Our test is telling us that the strings are different lengths, the third index in the fixture shouldn’t exist, but the actual output we got an empty string, “”. From here fixing the test failure is straight forward. + + 1. Please don’t email me to argue that map iteration order is _random_. [It’s not][5]. + + + +#### Related posts: + + 1. [Writing table driven tests in Go][6] + 2. [Internets of Interest #7: Ian Cooper on Test Driven Development][7] + 3. [Automatically run your package’s tests with inotifywait][8] + 4. [How to write benchmarks in Go][9] + + + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2019/05/07/prefer-table-driven-tests + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://dave.cheney.net/2019/04/03/absolute-unit-test +[2]: https://www.youtube.com/watch?v=EZ05e7EMOLM +[3]: https://blog.golang.org/subtests +[4]: https://github.com/google/go-cmp +[5]: https://golang.org/ref/spec#For_statements +[6]: https://dave.cheney.net/2013/06/09/writing-table-driven-tests-in-go (Writing table driven tests in Go) +[7]: https://dave.cheney.net/2018/10/15/internets-of-interest-7-ian-cooper-on-test-driven-development (Internets of Interest #7: Ian Cooper on Test Driven Development) +[8]: https://dave.cheney.net/2016/06/21/automatically-run-your-packages-tests-with-inotifywait (Automatically run your package’s tests with inotifywait) +[9]: https://dave.cheney.net/2013/06/30/how-to-write-benchmarks-in-go (How to write benchmarks in Go) diff --git a/sources/tech/20190508 Why startups should release their code as open source.md b/sources/tech/20190508 Why startups should release their code as open source.md deleted file mode 100644 index f877964b5f..0000000000 --- a/sources/tech/20190508 Why startups should release their code as open source.md +++ /dev/null @@ -1,79 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Why startups should release their code as open source) -[#]: via: (https://opensource.com/article/19/5/startups-release-code) -[#]: author: (Clément Flipo https://opensource.com/users/cl%C3%A9ment-flipo) - -Why startups should release their code as open source -====== -Dokit wondered whether giving away its knowledge as open source was a -bad business decision, but that choice has been the foundation of its -success. -![open source button on keyboard][1] - -It's always hard to recall exactly how a project started, but sometimes that can help you understand that project more clearly. When I think about it, our platform for creating user guides and documentation, [Dokit][2], came straight out of my childhood. Growing up in a house where my toys were Meccano and model airplane kits, the idea of making things, taking individual pieces and putting them together to create a new whole, was always a fundamental part of what it meant to play. My father worked for a DIY company, so there were always signs of building, repair, and instruction manuals around the house. When I was young, my parents sent me to join the Boy Scouts, where we made tables, tents and mud ovens, which helped foster my enjoyment of shared learning that I later found in the open source movement. - -The art of repairing things and recycling products that I learned in childhood became part of what I did for a job. Then it became my ambition to take the reassuring feel of learning how to make and do and repair at home or in a group—but put it online. That inspired Dokit's creation. - -### The first months - -It hasn't always been easy, but since founding our company in 2017, I've realized that the biggest and most worthwhile goals are generally always difficult. If we were to achieve our plan to revolutionize the way [old-fashioned manuals and user guides are created and published][3], and maximize our impact in what we knew all along would be a niche market, we knew that a guiding mission was crucial to how we organized everything else. It was from there that we reached our first big decision: to [quickly launch a proof of concept using an existing open source framework][4], MediaWiki, and from there to release all of our code as open source. - -In retrospect, this decision was made easier by the fact that [MediaWiki][5] was already up and running. With 15,000 developers already active around the world and on a platform that included 90% of the features we needed to meet our minimum viable product (MVP), things would have no doubt been harder without support from the engine that made its name by powering Wikipedia. Confluence, a documentation platform in use by many enterprises, offers some good features, but in the end, it was an easy choice between the two. - -Placing our faith in the community, we put the first version of our platform straight onto GitHub. The excitement of watching the world's makers start using our platform, even before we'd done any real advertising, felt like an early indication that we were on the right track. Although the [maker and Fablab movements][6] encourage users to share instructions, and even sets out this expectation in the [Fablab charter][7] (as stated by MIT), in reality, there is a lack of real documentation. - -The first and most significant reason people like using our platform is that it responds to the very real problem of poor documentation inside an otherwise great movement—one that we knew could be even better. To us, it felt a bit like we were repairing a gap in the community of makers and DIY. Within a year of our launch, Fablabs, [Wikifab][8], [Open Source Ecology][9], [Les Petits Debrouillards][10], [Ademe][11], and [Low-Tech Lab][12] had installed our tool on their servers for creating step-by-step tutorials. - -Before even putting out a press release, one of our users, Wikifab, began to get praise in national media as "[the Wikipedia of DIY][13]." In just two years, we've seen hundreds of communities launched on their own Dokits, ranging from the fun to the funny to the more formal product guides. Again, the power of the community is the force we want to harness, and it's constantly amazing to see projects—ranging from wind turbines to pet feeders—develop engaging product manuals using the platform we started. - -### Opening up open source - -Looking back at such a successful first two years, it's clear to us that our choice to use open source was fundamental to how we got where we are as fast as we did. The ability to gather feedback in open source is second-to-none. If a piece of code didn't work, [someone could tell us right away][14]. Why wait on appointments with consultants if you can learn along with those who are already using the service you created? - -The level of engagement from the community also revealed the potential (including the potential interest) in our market. [Paris has a good and growing community of developers][15], but open source took us from a pool of a few thousand locally, and brought us to millions of developers all around the world who could become a part of what we were trying to make happen. The open availability of our code also proved reassuring to our users and customers who felt safe that, even if our company went away, the code wouldn't. - -If that was most of what we thought might happen as a result of using open source, there were also surprises along the way. By adopting an open method, we found ourselves gaining customers, reputation, and perfectly targeted advertising that we didn't have to pay for out of our limited startup budget. We found that the availability of our code helped improve our recruitment process because we were able to test candidates using our code before we made hires, and this also helped simplify the onboarding journey for those we did hire. - -In what we see as a mixture of embarrassment and solidarity, the totally public nature of developers creating code in an open setting also helped drive up quality. People can share feedback with one another, but the public nature of the work also seems to encourage people to do their best. In the spirit of constant improvement and of continually building and rebuilding how Dokit works, supporting the community is something that we know we'd like to do more of and get better at in future. - -### Where to next? - -Even with the faith we've always had in what we were doing, and seeing the great product manuals that have been developed using our software, it never stops being exciting to see our project grow, and we're certain that the future has good things in store. - -In the early days, we found ourselves living a lot under the fear of distributing our knowledge for free. In reality, it was the opposite—open source gave us the ability to very rapidly build a startup that was sustainable from the beginning. Dokit is a platform designed to give its users the confidence to build, assemble, repair, and create entirely new inventions with the support of a community. In hindsight, we found we were doing the same thing by using open source to build a platform. - -Just like when doing a repair or assembling a physical product, it's only when you have confidence in your methods that things truly begin to feel right. Now, at the beginning of our third year, we're starting to see growing global interest as the industry responds to [new generations of customers who want to use, reuse, and assemble products][16] that respond to changing homes and lifestyles. By providing the support of an online community, we think we're helping to create circumstances in which people feel more confident in doing things for themselves. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/5/startups-release-code - -作者:[Clément Flipo][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/cl%C3%A9ment-flipo -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/button_push_open_keyboard_file_organize.png?itok=KlAsk1gx (open source button on keyboard) -[2]: https://dokit.io/ -[3]: https://dokit.io/9-reasons-to-stop-writing-your-user-manuals-or-work-instructions-with-word-processors/ -[4]: https://medium.com/@gofloaters/5-cheap-ways-to-build-your-mvp-71d6170d5250 -[5]: https://en.wikipedia.org/wiki/MediaWiki -[6]: https://en.wikipedia.org/wiki/Maker_culture -[7]: http://fab.cba.mit.edu/about/charter/ -[8]: https://wikifab.org/ -[9]: https://www.opensourceecology.org/ -[10]: http://www.lespetitsdebrouillards.org/ -[11]: https://www.ademe.fr/en -[12]: http://lowtechlab.org/ -[13]: https://www.20minutes.fr/magazine/economie-collaborative-mag/2428995-20160919-pour-construire-leurs-meubles-eux-memes-ils-creent-le-wikipedia-du-bricolage -[14]: https://opensource.guide/how-to-contribute/ -[15]: https://www.rudebaguette.com/2013/03/here-are-the-details-on-the-new-developer-school-that-xavier-niel-is-launching-tomorrow/?lang=en -[16]: https://www.inc.com/ari-zoldan/why-now-is-the-best-time-to-start-a-diy-home-based.html diff --git a/sources/tech/20190509 5 essential values for the DevOps mindset.md b/sources/tech/20190509 5 essential values for the DevOps mindset.md deleted file mode 100644 index 4746d2ffaa..0000000000 --- a/sources/tech/20190509 5 essential values for the DevOps mindset.md +++ /dev/null @@ -1,85 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (5 essential values for the DevOps mindset) -[#]: via: (https://opensource.com/article/19/5/values-devops-mindset) -[#]: author: (Brent Aaron Reed https://opensource.com/users/brentaaronreed/users/wpschaub/users/wpschaub/users/wpschaub/users/cobiacomm/users/marcobravo/users/brentaaronreed) - -5 essential values for the DevOps mindset -====== -People and process take more time but are more important than any -technology "silver bullet" in solving business problems. -![human head, brain outlined with computer hardware background][1] - -Many IT professionals today struggle with adapting to change and disruption. Are you struggling with just trying to keep the lights on, so to speak? Do you feel overwhelmed? This is not uncommon. Today, the status quo is not enough, so IT constantly tries to re-invent itself. - -With over 30 years of combined IT experience, we have witnessed how important people and relationships are to IT's ability to be effective and help the business thrive. However, most of the time, our conversations about IT solutions start with technology rather than people and process. The propensity to look for a "silver bullet" to address business and IT challenges is far too common. But you can't just buy innovation, DevOps, or effective teams and ways of working; they need to be nurtured, supported, and guided. - -With disruption so prevalent and there being such a critical demand for speed of change, we need both discipline and guardrails. The five essential values for the DevOps mindset, described below, will support the practices that will get us there. These values are not new ideas; they are refactored as we've learned from our experience. Some of the values may be interchangeable, they are flexible, and they guide overall principles that support (like a pillar) these five values. - -![5 essential values for the DevOps mindset][2] - -### 1\. Feedback from stakeholders is essential - -How do we know if we are creating more value for us than for our stakeholders? We need persistent quality data to analyze, inform, and drive better decisions. Relevant information from trusted sources is vital for any business to thrive. We need to listen to and understand what our stakeholders are saying—and not saying—and we need to implement changes in a way that enables us to adjust our thinking—and our processes and technologies—and adapt them as needed to delight our stakeholders. Too often, we see little change, or lots of change for the wrong reasons, because of incorrect information (data). Therefore, aligning change to our stakeholders' feedback is an essential value and helps us focus on what is most important to making our company successful. - -> Focus on our stakeholders and their feedback rather than simply changing for the sake of change. - -### 2\. Improve beyond the limits of today's processes - -We want our products and services to continuously delight our customers—our most important stakeholders—therefore, we need to improve continually. This is not only about quality; it could also mean costs, availability, relevance, and many other goals and factors. Creating repeatable processes or utilizing a common framework is great—they can improve governance and a host of other issues—however, that should not be our end goal. As we look for ways to improve, we must adjust our processes, complemented by the right tech and tools. There may be reasons to throw out a "so-called" framework because not doing so could add waste—or worse, simply "cargo culting" (doing something with of no value or purpose). - -> Strive to always innovate and improve beyond repeatable processes and frameworks. - -### 3\. No new silos to break down silos - -Silos and DevOps are incompatible. We see this all the time: an IT director brings in so-called "experts" to implement agile and DevOps, and what do they do? These "experts" create a new problem on top of the existing problem, which is another silo added to an IT department and a business riddled with silos. Creating "DevOps" titles goes against the very principles of agile and DevOps, which are based on the concept of breaking down silos. In both agile and DevOps, teamwork is essential, and if you don't work in a self-organizing team, you're doing neither of them. - -> Inspire and share collaboratively instead of becoming a hero or creating a silo. - -### 4\. Knowing your customer means cross-organization collaboration - -No part of the business is an independent entity because they all have stakeholders, and the primary stakeholder is always the customer. "The customer is always right" (or the king, as I like to say). The point is, without the customer, there really is no business, and to stay in business today, we need to "differentiate" from our competitors. We also need to know how our customers feel about us and what they want from us. Knowing what the customer wants is imperative and requires timely feedback to ensure the business addresses these primary stakeholders' needs and concerns quickly and responsibly. - -![Minimize time spent with build-measure-learn process][3] - -Whether it comes from an idea, a concept, an assumption, or direct stakeholder feedback, we need to identify and measure the feature or service our product delivers by using the explore, build, test, deliver lifecycle. Fundamentally, this means that we need to be "plugged into" our organization across the organization. There are no borders in continuous innovation, learning, and DevOps. Thus when we measure across the enterprise, we can understand the whole and take actionable, meaningful steps to improve. - -> Measure performance across the organization, not just in a line of business. - -### 5\. Inspire adoption through enthusiasm - -Not everyone is driven to learn, adapt, and change; however, just like smiles can be infectious, so can learning and wanting to be part of a culture of change. Adapting and evolving within a culture of learning provides a natural mechanism for a group of people to learn and pass on information (i.e., cultural transmission). Learning styles, attitudes, methods, and processes continually evolve so we can improve upon them. The next step is to apply what was learned and improved and share the information with colleagues. Learning does not happen automatically; it takes effort, evaluation, discipline, awareness, and especially communication; unfortunately these are things that tools and automation alone will not provide. Review your processes, automation, tool strategies, and implementation work, make it transparent, and collaborate with your colleagues on reuse and improvement. - -> Promote a culture of learning through lean quality deliverables, not just tools and automation. - -### Summary - -![Continuous goals of DevOps mindset][4] - -As our companies adopt DevOps, we continue to champion these five values over any book, website, or automation software. It takes time to adopt this mindset, and this is very different than what we used to do as sysadmins. It's a wholly new way of working that will take many years to mature. Do these principles align with your own? Share them in the comments or on our website, [Agents of chaos][5]. - -* * * - -Can you really do DevOps without sharing scripts or code? DevOps manifesto proponents value cross-... - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/5/values-devops-mindset - -作者:[Brent Aaron Reed][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/brentaaronreed/users/wpschaub/users/wpschaub/users/wpschaub/users/cobiacomm/users/marcobravo/users/brentaaronreed -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_data.png?itok=RH6NA32X (human head, brain outlined with computer hardware background) -[2]: https://opensource.com/sites/default/files/uploads/devops_mindset_values.png (5 essential values for the DevOps mindset) -[3]: https://opensource.com/sites/default/files/uploads/devops_mindset_minimze-time.jpg (Minimize time spent with build-measure-learn process) -[4]: https://opensource.com/sites/default/files/uploads/devops_mindset_continuous.png (Continuous goals of DevOps mindset) -[5]: http://agents-of-chaos.org diff --git a/sources/tech/20190509 Red Hat Enterprise Linux (RHEL) 8 Installation Steps with Screenshots.md b/sources/tech/20190509 Red Hat Enterprise Linux (RHEL) 8 Installation Steps with Screenshots.md new file mode 100644 index 0000000000..0b2d9e55c6 --- /dev/null +++ b/sources/tech/20190509 Red Hat Enterprise Linux (RHEL) 8 Installation Steps with Screenshots.md @@ -0,0 +1,256 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Red Hat Enterprise Linux (RHEL) 8 Installation Steps with Screenshots) +[#]: via: (https://www.linuxtechi.com/rhel-8-installation-steps-screenshots/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +Red Hat Enterprise Linux (RHEL) 8 Installation Steps with Screenshots +====== + +Red Hat has released its most awaited OS **RHEL 8** on 7th May 2019. RHEL 8 is based on **Fedora 28** distribution and Linux **kernel version 4.18**. One of the important key features in RHEL 8 is that it has introduced “ **Application Streams** ” which allows developers tools, frameworks and languages to be updated frequently without impacting the core resources of base OS. In other words, application streams will help to segregate the users space packages from OS Kernel Space. + +Apart from this, there are many new features which are noticed in RHEL 8 like: + + * XFS File system supports copy-on-write of file extents + * Introduction of Stratis filesystem, Buildah, Podman, and Skopeo + * Yum utility is based on DNF + * Chrony replace NTP. + * Cockpit is the default Web Console tool for Server management. + * OpenSSL 1.1.1 & TLS 1.3 support + * PHP 7.2 + * iptables replaced by nftables + + + +### Minimum System Requirements for RHEL 8: + + * 4 GB RAM + * 20 GB unallocated disk space + * 64-bit x86 or ARM System + + + +**Note:** RHEL 8 supports the following architectures: + + * AMD or Intel x86 64-bit + * 64-bit ARM + * IBM Power Systems, Little Endian & IBM Z + + + +In this article we will demonstrate how to install RHEL 8 step by step with screenshots. + +### RHEL 8 Installation Steps with Screenshots + +### Step:1) Download RHEL 8.0 ISO file + +Download RHEL 8 iso file from its official web site, + + + +I am assuming you have the active subscription if not then register yourself for evaluation and then download ISO file + +### Step:2) Create Installation bootable media (USB or DVD) + +Once you have downloaded RHEL 8 ISO file, make it bootable by burning it either into a USB drive or DVD. Reboot the target system where you want to install RHEL 8 and then go to its bios settings and set the boot medium as USB or DVD, + +### Step:3) Choose “Install Red Hat Enterprise Linux 8.0” option + +When the system boots up with installation media (USB or DVD), we will get the following screen, choose “ **Install Red Hat Enterprise Linux 8.0** ” and hit enter, + + + +### Step:4) Choose your preferred language for RHEL 8 installation + +In this step, you need to choose a language that you want to use for RHEL 8 installation, so make a selection that suits to your setup. + + + +Click on Continue + +### Step:5) Preparing RHEL 8 Installation + +In this step we will decide the installation destination for RHEL 8, apart from this we can configure the followings: + + * Time Zone + * Kdump (enabled/disabled) + * Software Selection (Packages) + * Networking and Hostname + * Security Policies & System purpose + + + + + +By default, installer will automatically pick time zone and will enable the **kdump** , if wish to change the time zone then click on “ **Time & Date**” option and set your preferred time zone and then click on Done. + + + +To configure IP address and Hostname click on “ **Network & Hostname**” option from installation summary screen, + +If your system is connected to any switch or modem, then it will try to get IP from DHCP server otherwise we can configure IP manually. + +Mention the hostname that you want to set and then click on “ **Apply”**. Once you are done with IP address and hostname configuration click on “Done” + + + +To define the installation disk and partition scheme for RHEL 8, click on “ **Installation Destination** ” option, + + + +Click on Done + +As we can see I have around 60 GB free disk space on sda drive, I will be creating following customize lvm based partitions on this disk, + + * /boot = 2GB (xfs file system) + * / = 20 GB (xfs file system) + * /var = 10 GB (xfs file system) + * /home = 15 GB (xfs file system) + * /tmp = 5 GB (xfs file system) + * Swap = 2 GB (xfs file system) + + + +**Note:** If you don’t want to create manual partitions then select “ **Automatic** ” option from Storage Configuration Tab + + + +Let’s create our first partition as /boot of size 2 GB, Select LVM as mount point partitioning scheme and then click on + “plus” symbol, + + + +Click on “ **Add mount point** ” + + + +To create next partition as / of size 20 GB, click on + symbol and specify the details as shown below, + + + +Click on “Add mount point” + + + +As we can see installer has created the Volume group as “ **rhel_rhel8** “, if you want to change this name then click on Modify option and specify the desired name and then click on Save + + + +Now onward all partitions will be part of Volume Group “ **VolGrp** ” + +Similarly create next three partitions **/home** , **/var** and **/tmp** of size 15GB, 10 GB and 5 GB respectively + +**/home partition:** + + + +**/var partition:** + + + +**/tmp partition:** + + + +Now finally create last partition as swap of size of 2 GB, + + + +Click on “Add mount point” + +Once you are done with partition creations, click on Done on Next screen, example is shown below + + + +In the next window, choose “ **Accept Changes** ” + + + +### Step:6) Select Software Packages and Choose Security Policy and System purpose + +After accepting the changes in above step, we will be redirected to installation summary window. + +By default, installer will select “ **Server with GUI”** as software packages and if you want to change it then click on “ **Software Selection** ” option and choose your preferred “ **Basic Environment** ” + + + +Click on Done + +If you want to set the security policies during the installation, the choose the required profile from Security polices option else you can leave as it is. + +From “ **System Purpose** ” option specify the Role, Red Hat Service Level Agreement and Usage. Though You can leave this option as it is. + + + +Click on Done to proceed further. + +### Step:7) Choose “Begin Installation” option to start installation + +From the Installation summary window click on “Begin Installation” option to start the installation, + + + +As we can see below RHEL 8 Installation is started & is in progress + + + +Set the root password, + + + +Specify the local user details like its Full Name, user name and its password, + + + +Once the installation is completed, installer will prompt us to reboot the system, + + + +Click on “Reboot” to restart your system and don’t forget to change boot medium from bios settings so that system boots up with hard disk. + +### Step:8) Initial Setup after installation + +When the system is rebooted first time after the successful installation then we will get below window there we need to accept the license (EULA), + + + +Click on Done, + +In the next Screen click on “ **Finish Configuration** ” + + + +### Step:8) Login Screen of RHEL 8 Server after Installation + +As we have installed RHEL 8 Server with GUI, so we will get below login screen, use the same user name and password that we created during the installation + + + +After the login we will get couple of Welcome Screen and follow the screen instructions and then finally we will get the following screen, + + + +Click on “Start Using Red Hat Enterprise Linux” + + + +This confirms that we have successfully installed RHEL 8, that’s all from this article. We will be writing articles on RHEL 8 in the coming future till then please do share your feedback and comments on this article. + +Read Also :** [How to Setup Local Yum/DNF Repository on RHEL 8 Server Using DVD or ISO File][1]** + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/rhel-8-installation-steps-screenshots/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/setup-local-yum-dnf-repository-rhel-8/ diff --git a/sources/tech/20190510 Learn to change history with git rebase.md b/sources/tech/20190510 Learn to change history with git rebase.md index cf8f9351d9..4d46fef81f 100644 --- a/sources/tech/20190510 Learn to change history with git rebase.md +++ b/sources/tech/20190510 Learn to change history with git rebase.md @@ -1,5 +1,8 @@ +Translating by Scoutydren.... + + [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (Scoutydren) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20190512 How to Setup Local Yum-DNF Repository on RHEL 8 Server Using DVD or ISO File.md b/sources/tech/20190512 How to Setup Local Yum-DNF Repository on RHEL 8 Server Using DVD or ISO File.md new file mode 100644 index 0000000000..c136a83deb --- /dev/null +++ b/sources/tech/20190512 How to Setup Local Yum-DNF Repository on RHEL 8 Server Using DVD or ISO File.md @@ -0,0 +1,164 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Setup Local Yum/DNF Repository on RHEL 8 Server Using DVD or ISO File) +[#]: via: (https://www.linuxtechi.com/setup-local-yum-dnf-repository-rhel-8/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +How to Setup Local Yum/DNF Repository on RHEL 8 Server Using DVD or ISO File +====== + +Recently Red Hat has released its most awaited operating system “ **RHEL 8** “, in case you have installed RHEL 8 Server on your system and wondering how to setup local yum or dnf repository using installation DVD or ISO file then refer below steps and procedure. + + + +In RHEL 8, we have two package repositories: + + * BaseOS + * Application Stream + + + +BaseOS repository have all underlying OS packages where as Application Stream repository have all application related packages, developer tools and databases etc. Using Application stream repository, we can have multiple of versions of same application and Database. + +### Step:1) Mount RHEL 8 ISO file / Installation DVD + +To mount RHEL 8 ISO file inside your RHEL 8 server use the beneath mount command, + +``` +[root@linuxtechi ~]# mount -o loop rhel-8.0-x86_64-dvd.iso /opt/ +``` + +**Note:** I am assuming you have already copied RHEL 8 ISO file inside your system, + +In case you have RHEL 8 installation DVD, then use below mount command to mount it, + +``` +[root@linuxtechi ~]# mount /dev/sr0 /opt +``` + +### Step:2) Copy media.repo file from mounted directory to /etc/yum.repos.d/ + +In our case RHEL 8 Installation DVD or ISO file is mounted under /opt folder, use cp command to copy media.repo file to /etc/yum.repos.d/ directory, + +``` +[root@linuxtechi ~]# cp -v /opt/media.repo /etc/yum.repos.d/rhel8.repo +'/opt/media.repo' -> '/etc/yum.repos.d/rhel8.repo' +[root@linuxtechi ~]# +``` + +Set “644” permission on “ **/etc/yum.repos.d/rhel8.repo** ” + +``` +[root@linuxtechi ~]# chmod 644 /etc/yum.repos.d/rhel8.repo +[root@linuxtechi ~]# +``` + +### Step:3) Add repository entries in “/etc/yum.repos.d/rhel8.repo” file + +By default, **rhel8.repo** file will have following content, + + + +Edit rhel8.repo file and add the following contents, + +``` +[root@linuxtechi ~]# vi /etc/yum.repos.d/rhel8.repo +[InstallMedia-BaseOS] +name=Red Hat Enterprise Linux 8 - BaseOS +metadata_expire=-1 +gpgcheck=1 +enabled=1 +baseurl=file:///opt/BaseOS/ +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release + +[InstallMedia-AppStream] +name=Red Hat Enterprise Linux 8 - AppStream +metadata_expire=-1 +gpgcheck=1 +enabled=1 +baseurl=file:///opt/AppStream/ +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +``` + +rhel8.repo should look like above once we add the content, In case you have mounted the Installation DVD or ISO on different folder then change the location and folder name in base url line for both repositories and rest of parameter leave as it is. + +### Step:4) Clean Yum / DNF and Subscription Manager Cache + +Use the following command to clear yum or dnf and subscription manager cache, + +``` +root@linuxtechi ~]# dnf clean all +[root@linuxtechi ~]# subscription-manager clean +All local data removed +[root@linuxtechi ~]# +``` + +### Step:5) Verify whether Yum / DNF is getting packages from Local Repo + +Use dnf or yum repolist command to verify whether these commands are getting packages from Local repositories or not. + +``` +[root@linuxtechi ~]# dnf repolist +Updating Subscription Management repositories. +Unable to read consumer identity +This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. +Last metadata expiration check: 1:32:44 ago on Sat 11 May 2019 08:48:24 AM BST. +repo id repo name status +InstallMedia-AppStream Red Hat Enterprise Linux 8 - AppStream 4,672 +InstallMedia-BaseOS Red Hat Enterprise Linux 8 - BaseOS 1,658 +[root@linuxtechi ~]# +``` + +**Note :** You can use either dnf or yum command, if you use yum command then its request is redirecting to DNF itself because in RHEL 8 yum is based on DNF command. + +If you have noticed the above command output carefully, we are getting warning message “ **This system is not registered to Red Hat Subscription Management**. **You can use subscription-manager to register”** , if you want to suppress or prevent this message while running dnf / yum command then edit the file “/etc/yum/pluginconf.d/subscription-manager.conf”, changed the parameter “enabled=1” to “enabled=0” + +``` +[root@linuxtechi ~]# vi /etc/yum/pluginconf.d/subscription-manager.conf +[main] +enabled=0 +``` + +save and exit the file. + +### Step:6) Installing packages using DNF / Yum + +Let’s assume we want to install nginx web server then run below dnf command, + +``` +[root@linuxtechi ~]# dnf install nginx +``` + +![][1] + +Similarly if you want to install **LEMP** stack on your RHEL 8 system use the following dnf command, + +``` +[root@linuxtechi ~]# dnf install nginx mariadb php -y +``` + +[![][2]][3] + +This confirms that we have successfully configured Local yum / dnf repository on our RHEL 8 server using Installation DVD or ISO file. + +In case these steps help you technically, please do share your feedback and comments. + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/setup-local-yum-dnf-repository-rhel-8/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/wp-content/uploads/2019/05/dnf-install-nginx-rhel8-1024x376.jpg +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/05/LEMP-Stack-Install-RHEL8-1024x540.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/05/LEMP-Stack-Install-RHEL8.jpg diff --git a/sources/tech/20190513 How To Check Whether The Given Package Is Installed Or Not On Debian-Ubuntu System.md b/sources/tech/20190513 How To Check Whether The Given Package Is Installed Or Not On Debian-Ubuntu System.md deleted file mode 100644 index dfc3e62dce..0000000000 --- a/sources/tech/20190513 How To Check Whether The Given Package Is Installed Or Not On Debian-Ubuntu System.md +++ /dev/null @@ -1,141 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How To Check Whether The Given Package Is Installed Or Not On Debian/Ubuntu System?) -[#]: via: (https://www.2daygeek.com/how-to-check-whether-the-given-package-is-installed-or-not-on-ubuntu-debian-system/) -[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) - -How To Check Whether The Given Package Is Installed Or Not On Debian/Ubuntu System? -====== - -We have recently published an article about bulk package installation. - -While doing that, i was struggled to get the installed package information and did a small google search and found few methods about it. - -I would like to share it in our website so, that it will be helpful for others too. - -There are numerous ways we can achieve this. - -I have add seven ways to achieve this. However, you can choose the preferred method for you. - -Those methods are listed below. - - * **`apt-cache Command:`** apt-cache command is used to query the APT cache or package metadata. - * **`apt Command:`** APT is a powerful command-line tool for installing, downloading, removing, searching and managing packages on Debian based systems. - * **`dpkg-query Command:`** dpkg-query is a tool to query the dpkg database. - * **`dpkg Command:`** dpkg is a package manager for Debian based systems. - * **`which Command:`** The which command returns the full path of the executable that would have been executed when the command had been entered in terminal. - * **`whereis Command:`** The whereis command used to search the binary, source, and man page files for a given command. - * **`locate Command:`** locate command works faster than the find command because it uses updatedb database, whereas the find command searches in the real system. - - - -### Method-1 : How To Check Whether The Given Package Is Installed Or Not On Ubuntu System Using apt-cache Command? - -apt-cache command is used to query the APT cache or package metadata from APT’s internal database. - -It will search and display an information about the given package. It shows whether the package is installed or not, installed package version, source repository information. - -The below output clearly showing that `nano` package has already installed in the system. Since installed part is showing the installed version of nano package. - -``` -# apt-cache policy nano -nano: - Installed: 2.9.3-2 - Candidate: 2.9.3-2 - Version table: - *** 2.9.3-2 500 - 500 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 Packages - 100 /var/lib/dpkg/status -``` - -### Method-2 : How To Check Whether The Given Package Is Installed Or Not On Ubuntu System Using apt Command? - -APT is a powerful command-line tool for installing, downloading, removing, searching and managing as well as querying information about packages as a low-level access to all features of the libapt-pkg library. It’s contains some less used command-line utilities related to package management. - -``` -# apt -qq list nano -nano/bionic,now 2.9.3-2 amd64 [installed] -``` - -### Method-3 : How To Check Whether The Given Package Is Installed Or Not On Ubuntu System Using dpkg-query Command? - -dpkg-query is a tool to show information about packages listed in the dpkg database. - -In the below output first column showing `ii`. It means, the given package has already installed in the system. - -``` -# dpkg-query --list | grep -i nano -ii nano 2.9.3-2 amd64 small, friendly text editor inspired by Pico -``` - -### Method-4 : How To Check Whether The Given Package Is Installed Or Not On Ubuntu System Using dpkg Command? - -DPKG stands for Debian Package is a tool to install, build, remove and manage Debian packages, but unlike other package management systems, it cannot automatically download and install packages or their dependencies. - -In the below output first column showing `ii`. It means, the given package has already installed in the system. - -``` -# dpkg -l | grep -i nano -ii nano 2.9.3-2 amd64 small, friendly text editor inspired by Pico -``` - -### Method-5 : How To Check Whether The Given Package Is Installed Or Not On Ubuntu System Using which Command? - -The which command returns the full path of the executable that would have been executed when the command had been entered in terminal. - -It’s very useful when you want to create a desktop shortcut or symbolic link for executable files. - -Which command searches the directories listed in the current user’s PATH environment variable not for all the users. I mean, when you are logged in your own account and you can’t able to search for root user file or directory. - -If the following output shows the given package binary or executable file location then the given package has already installed in the system. If not, the package is not installed in system. - -``` -# which nano -/bin/nano -``` - -### Method-6 : How To Check Whether The Given Package Is Installed Or Not On Ubuntu System Using whereis Command? - -The whereis command used to search the binary, source, and man page files for a given command. - -If the following output shows the given package binary or executable file location then the given package has already installed in the system. If not, the package is not installed in system. - -``` -# whereis nano -nano: /bin/nano /usr/share/nano /usr/share/man/man1/nano.1.gz /usr/share/info/nano.info.gz -``` - -### Method-7 : How To Check Whether The Given Package Is Installed Or Not On Ubuntu System Using locate Command? - -locate command works faster than the find command because it uses updatedb database, whereas the find command searches in the real system. - -It uses a database rather than hunting individual directory paths to get a given file. - -locate command doesn’t pre-installed in most of the distributions so, use your distribution package manager to install it. - -The database is updated regularly through cron. Even, we can update it manually. - -If the following output shows the given package binary or executable file location then the given package has already installed in the system. If not, the package is not installed in system. - -``` -# locate --basename '\nano' -/usr/bin/nano -/usr/share/nano -/usr/share/doc/nano -``` --------------------------------------------------------------------------------- - -via: https://www.2daygeek.com/how-to-check-whether-the-given-package-is-installed-or-not-on-ubuntu-debian-system/ - -作者:[Magesh Maruthamuthu][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.2daygeek.com/author/magesh/ -[b]: https://github.com/lujun9972 diff --git a/sources/tech/20190513 Manage business documents with OpenAS2 on Fedora.md b/sources/tech/20190513 Manage business documents with OpenAS2 on Fedora.md new file mode 100644 index 0000000000..c8e82151ef --- /dev/null +++ b/sources/tech/20190513 Manage business documents with OpenAS2 on Fedora.md @@ -0,0 +1,153 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Manage business documents with OpenAS2 on Fedora) +[#]: via: (https://fedoramagazine.org/manage-business-documents-with-openas2-on-fedora/) +[#]: author: (Stuart D Gathman https://fedoramagazine.org/author/sdgathman/) + +Manage business documents with OpenAS2 on Fedora +====== + +![][1] + +Business documents often require special handling. Enter Electronic Document Interchange, or **EDI**. EDI is more than simply transferring files using email or http (or ftp), because these are documents like orders and invoices. When you send an invoice, you want to be sure that: + +1\. It goes to the right destination, and is not intercepted by competitors. +2\. Your invoice cannot be forged by a 3rd party. +3\. Your customer can’t claim in court that they never got the invoice. + +The first two goals can be accomplished by HTTPS or email with S/MIME, and in some situations, a simple HTTPS POST to a web API is sufficient. What EDI adds is the last part. + +This article does not cover the messy topic of formats for the files exchanged. Even when using a standardized format like ANSI or EDIFACT, it is ultimately up to the business partners. It is not uncommon for business partners to use an ad-hoc CSV file format. This article shows you how to configure Fedora to send and receive in an EDI setup. + +### Centralized EDI + +The traditional solution is to use a Value Added Network, or **VAN**. The VAN is a central hub that transfers documents between their customers. Most importantly, it keeps a secure record of the documents exchanged that can be used as evidence in disputes. The VAN can use different transfer protocols for each of its customers + +### AS Protocols and MDN + +The AS protocols are a specification for adding a digital signature with optional encryption to an electronic document. What it adds over HTTPS or S/MIME is the Message Disposition Notification, or **MDN**. The MDN is a signed and dated response that says, in essence, “We got your invoice.” It uses a secure hash to identify the specific document received. This addresses point #3 without involving a third party. + +The [AS2 protocol][2] uses HTTP or HTTPS for transport. Other AS protocols target [FTP][3] and [SMTP][4]. AS2 is used by companies big and small to avoid depending on (and paying) a VAN. + +### OpenAS2 + +OpenAS2 is an open source Java implemention of the AS2 protocol. It is available in Fedora since 28, and installed with: + +``` +$ sudo dnf install openas2 +$ cd /etc/openas2 +``` + +Configuration is done with a text editor, and the config files are in XML. The first order of business before starting OpenAS2 is to change the factory passwords. + +Edit _/etc/openas2/config.xml_ and search for _ChangeMe_. Change those passwords. The default password on the certificate store is _testas2_ , but that doesn’t matter much as anyone who can read the certificate store can read _config.xml_ and get the password. + +### What to share with AS2 partners + +There are 3 things you will exchange with an AS2 peer. + +#### AS2 ID + +Don’t bother looking up the official AS2 standard for legal AS2 IDs. While OpenAS2 implements the standard, your partners will likely be using a proprietary product which doesn’t. While AS2 allows much longer IDs, many implementations break with more than 16 characters. Using otherwise legal AS2 ID chars like ‘:’ that can appear as path separators on a proprietary OS is also a problem. Restrict your AS2 ID to upper and lower case alpha, digits, and ‘_’ with no more than 16 characters. + +#### SSL certificate + +For real use, you will want to generate a certificate with SHA256 and RSA. OpenAS2 ships with two factory certs to play with. Don’t use these for anything real, obviously. The certificate file is in PKCS12 format. Java ships with _keytool_ which can maintain your PKCS12 “keystore,” as Java calls it. This article skips using _openssl_ to generate keys and certificates. Simply note that _sudo keytool -list -keystore as2_certs.p12_ will list the two factory practice certs. + +#### AS2 URL + +This is an HTTP URL that will access your OpenAS2 instance. HTTPS is also supported, but is redundant. To use it you have to uncomment the https module configuration in _config.xml_ , and supply a certificate signed by a public CA. This requires another article and is entirely unnecessary here. + +By default, OpenAS2 listens on 10080 for HTTP and 10443 for HTTPS. OpenAS2 can talk to itself, so it ships with two partnerships using __ as the AS2 URL. If you don’t find this a convincing demo, and can install a second instance (on a VM, for instance), you can use private IPs for the AS2 URLs. Or install [Cjdns][5] to get IPv6 mesh addresses that can be used anywhere, resulting in AS2 URLs like _http://[fcbf:fc54:e597:7354:8250:2b2e:95e6:d6ba]:10080_. + +Most businesses will also want a list of IPs to add to their firewall. This is actually [bad practice][6]. An AS2 server has the same security risk as a web server, meaning you should isolate it in a VM or container. Also, the difficulty of keeping mutual lists of IPs up to date grows with the list of partners. The AS2 server rejects requests not signed by a configured partner. + +### OpenAS2 Partners + +With that in mind, open _partnerships.xml_ in your editor. At the top is a list of “partners.” Each partner has a name (referenced by the partnerships below as “sender” or “receiver”), AS2 ID, certificate, and email. You need a partner definition for yourself and those you exchange documents with. You can define multiple partners for yourself. OpenAS2 ships with two partners, OpenAS2A and OpenAS2B, which you’ll use to send a test document. + +### OpenAS2 Partnerships + +Next is a list of “partnerships,” one for each direction. Each partnership configuration includes the sender, receiver, and the AS2 URL used to send the documents. By default, partnerships use synchronous MDN. The MDN is returned on the same HTTP transaction. You could uncomment the _as2_receipt_option_ for asynchronous MDN, which is sent some time later. Use synchronous MDN whenever possible, as tracking pending MDNs adds complexity to your application. + +The other partnership options select encryption, signature hash, and other protocol options. A fully implemented AS2 receiver can handle any combination of options, but AS2 partners may have incomplete implementations or policy requirements. For example, DES3 is a comparatively weak encryption algorithm, and may not be acceptable. It is the default because it is almost universally implemented. + +If you went to the trouble to set up a second physical or virtual machine for this test, designate one as OpenAS2A and the other as OpenAS2B. Modify the _as2_url_ on the OpenAS2A-to-OpenAS2B partnership to use the IP (or hostname) of OpenAS2B, and vice versa for the OpenAS2B-to-OpenAS2A partnership. Unless they are using the FedoraWorkstation firewall profile, on both machines you’ll need: + +``` +# sudo firewall-cmd --zone=public --add-port=10080/tcp +``` + +Now start the _openas2_ service (on both machines if needed): + +``` +# sudo systemctl start openas2 +``` + +### Resetting the MDN password + +This initializes the MDN log database with the factory password, not the one you changed it to. This is a packaging bug to be fixed in the next release. To avoid frustration, here’s how to change the h2 database password: + +``` +$ sudo systemctl stop openas2 +$ cat >h2passwd <<'DONE' +#!/bin/bash +AS2DIR="/var/lib/openas2" +java -cp "$AS2DIR"/lib/h2* org.h2.tools.Shell \ + -url jdbc:h2:"$AS2DIR"/db/openas2 \ + -user sa -password "$1" <testdoc <<'DONE' +This is not a real EDI format, but is nevertheless a document. +DONE +$ sudo chown openas2 testdoc +$ sudo mv testdoc /var/spool/openas2/toOpenAS2B +$ sudo journalctl -f -u openas2 +... log output of sending file, Control-C to stop following log +^C +``` + +OpenAS2 does not send a document until it is writable by the _openas2_ user or group. As a consequence, your actual business application will copy, or generate in place, the document. Then it changes the group or permissions to send it on its way, to avoid sending a partial document. + +Now, on the OpenAS2B machine, _/var/spool/openas2/OpenAS2A_OID-OpenAS2B_OID/inbox_ shows the message received. That should get you started! + +* * * + +_Photo by _[ _Beatriz Pérez Moya_][7]_ on _[_Unsplash_][8]_._ + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/manage-business-documents-with-openas2-on-fedora/ + +作者:[Stuart D Gathman][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/sdgathman/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/05/openas2-816x345.jpg +[2]: https://en.wikipedia.org/wiki/AS2 +[3]: https://en.wikipedia.org/wiki/AS3_(networking) +[4]: https://en.wikipedia.org/wiki/AS1_(networking) +[5]: https://fedoramagazine.org/decentralize-common-fedora-apps-cjdns/ +[6]: https://www.ld.com/as2-part-2-best-practices/ +[7]: https://unsplash.com/photos/XN4T2PVUUgk?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[8]: https://unsplash.com/search/photos/documents?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/sources/tech/20190514 Why bother writing tests at all.md b/sources/tech/20190514 Why bother writing tests at all.md new file mode 100644 index 0000000000..2b80dbaf40 --- /dev/null +++ b/sources/tech/20190514 Why bother writing tests at all.md @@ -0,0 +1,93 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why bother writing tests at all?) +[#]: via: (https://dave.cheney.net/2019/05/14/why-bother-writing-tests-at-all) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +Why bother writing tests at all? +====== + +In previous posts and presentations I talked about [how to test][1], and [when to test][2]. To conclude this series of I’m going to ask the question, _why test at all?_ + +### Even if you don’t, someone _will_ test your software + +I’m sure no-one reading this post thinks that software should be delivered without being tested first. Even if that were true, your customers are going to test it, or at least use it. If nothing else, it would be good to discover any issues with the code before your customers do. If not for the reputation of your company, at least for your professional pride. + +So, if we agree that software should be tested, the question becomes: _who_ should do that testing? + +### The majority of testing should be performed by development teams + +I argue that the majority of the testing should be done by development groups. Moreover, testing should be automated, and thus the majority of these tests should be unit style tests. + +To be clear, I am _not_ saying you shouldn’t write integration, functional, or end to end tests. I’m also _not_ saying that you shouldn’t have a QA group, or integration test engineers. However at a recent software conference, in a room of over 1,000 engineers, nobody raised their hand when I asked if they considered themselves in a pure quality assurance role. + +You might argue that the audience was self selecting, that QA engineers did not feel a software conference was relevant–or welcoming–to them. However, I think this proves my point, the days of [one developer to one test engineer][3] are gone and not coming back. + +If development teams aren’t writing the majority of tests, who is? + +### Manual testing should not be the majority of your testing because manual testing is O(n) + +Thus, if individual contributors are expected to test the software they write, why do we need to automate it? Why is a manual testing plan not good enough? + +Manual testing of software or manual verification of a defect is not sufficient because it does not scale. As the number of manual tests grows, engineers are tempted to skip them or only execute the scenarios they _think_ are could be affected. Manual testing is expensive in terms of time, thus dollars, and it is boring. 99.9% of the tests that passed last time are _expected_ to pass again. Manual testing is looking for a needle in a haystack, except you don’t stop when you find the first needle. + +This means that your first response when given a bug to fix or a feature to implement should be to write a failing test. This doesn’t need to be a unit test, but it should be an automated test. Once you’ve fixed the bug, or added the feature, now have the test case to prove it worked–and you can check them in together. + +### Tests are the critical component that ensure you can always ship your master branch + +As a development team, you are judged on your ability to deliver working software to the business. No, seriously, the business could care less about OOP vs FP, CI/CD, table tennis or limited run La Croix. + +Your super power is, at any time, anyone on the team should be confident that the master branch of your code is shippable. This means at any time they can deliver a release of your software to the business and the business can recoup its investment in your development R&D. + +I cannot emphasise this enough. If you want the non technical parts of the business to believe you are heros, you must never create a situation where you say “well, we can’t release right now because we’re in the middle of an important refactoring. It’ll be a few weeks. We hope.” + +Again, I’m not saying you cannot refactor, but at every stage your product must be shippable. Your tests have to pass. It may not have all the desired features, but the features that are there should work as described on the tin. + +### Tests lock in behaviour + +Your tests are the contract about what your software does and does not do. Unit tests should lock in the behaviour of the package’s API. Integration tests do the same for complex interactions. Tests describe, in code, what the program promises to do. + +If there is a unit test for each input permutation, you have defined the contract for what the code will do _in code_ , not documentation. This is a contract anyone on your team can assert by simply running the tests. At any stage you _know_ with a high degree of confidence that the behaviour people relied on before your change continues to function after your change. + +### Tests give you confidence to change someone else’s code + +Lastly, and this is the biggest one, for programmers working on a piece of code that has been through many hands. Tests give you the confidence to make changes. + +Even though we’ve never met, something I know about you, the reader, is you will eventually leave your current employer. Maybe you’ll be moving on to a new role, or perhaps a promotion, perhaps you’ll move cities, or follow your partner overseas. Whatever the reason, the succession of the maintenance of programs you write is key. + +If people cannot maintain our code then as you and I move from job to job we’ll leave behind programs which cannot be maintained. This goes beyond advocacy for a language or tool. Programs which cannot be changed, programs which are too hard to onboard new developers, or programs which feel like career digression to work on them will reach only one end state–they are a dead end. They represent a balance sheet loss for the business. They will be replaced. + +If you worry about who will maintain your code after you’re gone, write good tests. + +#### Related posts: + + 1. [Writing table driven tests in Go][4] + 2. [Prefer table driven tests][5] + 3. [Automatically run your package’s tests with inotifywait][6] + 4. [The value of TDD][7] + + + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2019/05/14/why-bother-writing-tests-at-all + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://dave.cheney.net/2019/05/07/prefer-table-driven-tests +[2]: https://dave.cheney.net/paste/absolute-unit-test-london-gophers.pdf +[3]: https://docs.microsoft.com/en-us/azure/devops/learn/devops-at-microsoft/evolving-test-practices-microsoft +[4]: https://dave.cheney.net/2013/06/09/writing-table-driven-tests-in-go (Writing table driven tests in Go) +[5]: https://dave.cheney.net/2019/05/07/prefer-table-driven-tests (Prefer table driven tests) +[6]: https://dave.cheney.net/2016/06/21/automatically-run-your-packages-tests-with-inotifywait (Automatically run your package’s tests with inotifywait) +[7]: https://dave.cheney.net/2016/04/11/the-value-of-tdd (The value of TDD) diff --git a/sources/tech/20190515 How to manage access control lists with Ansible.md b/sources/tech/20190515 How to manage access control lists with Ansible.md new file mode 100644 index 0000000000..692dd70599 --- /dev/null +++ b/sources/tech/20190515 How to manage access control lists with Ansible.md @@ -0,0 +1,139 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to manage access control lists with Ansible) +[#]: via: (https://opensource.com/article/19/5/manage-access-control-lists-ansible) +[#]: author: (Taz Brown https://opensource.com/users/heronthecli) + +How to manage access control lists with Ansible +====== +Automating ACL management with Ansible's ACL module is a smart way to +strengthen your security strategy. +![Data container block with hexagons][1] + +Imagine you're a new DevOps engineer in a growing agile environment, and recently your company has experienced phenomenal growth. To support expansion, the company increased hiring by 25% over the last quarter and added 5,000 more servers and network devices to its infrastructure. The company now has over 13,000 users, and you need a tool to scale the existing infrastructure and manage your large number of users and their thousands of files and directories. The company decided to adopt [Ansible][2] company-wide to manage [access control lists (ACLs)][3] and answer the call of effectively managing files and directories and permissions. + +Ansible can be used for a multitude of administration and maintenance tasks and, as a DevOps engineer or administrator, it's likely you've been tasked with using it to manage ACLs. + +### About managing ACLs + +ACLs allow regular users to share their files and directories selectively with other users and groups. With ACLs, a user can grant others the ability to read, write, and execute files and directories without leaving those filesystem elements open. + +ACLs are set and removed at the command line using the **setfacl** utility. The command is usually followed by the name of a file or directory. To set permissions, you would use the Linux command **setfacl -m d ⭕rx ** (e.g., **setfacl -m d ⭕rx Music/**). To view the current permissions on a directory, you would use the command **getfacl ** (e.g., **getfacl Music/** ). To remove an ACL from a file or directory, you would type the command, **# setfacl -x ** (to remove only the specified ACL from the file/directory) or **# setfacl -b ** (to remove all ACLs from the file/directory). + +Only the owner assigned to the file or directory can set ACLs. (It's important to understand this before you, as the admin, take on Ansible to manage your ACLs.) There are also default ACLs, which control directory access; if a file inside a directory has no ACL, then the default ACL is applied. + + +``` +sudo setfacl -m d⭕rx Music +getfacl Music/ +# file: Music/ +# owner: root +# group: root +user::rwx +group::--- +other::--- +default:user::rwx +default:group::--- +default:other::r-x +``` + +### Enter Ansible + +So how can Ansible, in all its wisdom, tackle the task of applying permissions to users, files, directories, and more? Ansible can play nicely with ACLs, just as it does with a lot of features, utilities, APIs, etc. Ansible has an out-of-the-box [ACL module][3] that allows you to create playbooks/roles around granting a user access to a file, removing ACLs for users on a specific file, setting default ACLs for users on files, or obtaining ACLs on particular files. + +Anytime you are administering ACLs, you should use the best practice of "least privilege," meaning you should give a user access only to what they need to perform their role or execute a task, and no more. Restraint and minimizing the attack surface are critical. The more access extended, the higher the risk of unauthorized access to company assets. + +Here's an example Ansible playbook: + +![Ansible playbook][4] + +As an admin, automating ACL management demands that your Ansible playbooks can scale across your infrastructure to increase speed, improve efficiency, and reduce the time it takes to achieve your goals. There will be times when you need to determine the ACL for a specific file. This is essentially the same as using **getfacl ** in Linux. If you want to determine the ACLs of many, specific files, start with a playbook that looks like this: + + +``` +\--- +\- hosts: all +tasks: +\- name: obtain the acl for a specific file +acl: +path: /etc/logrotate.d +user_nfsv4_acls: true +register: acl_info +``` + +You can use the following playbook to set permissions on files/directories: + +![Ansible playbook][5] + +This playbook grants user access to a file: + + +``` +\- hosts: +become: yes +gather_facts: no +tasks: +\- name: Grant user Shirley read access to a file +acl: +path: /etc/foo.conf +entity: shirley +etype: user +permissions: r +state: present +``` + +And this playbook grants user access to a directory: + + +``` +\--- +\- hosts: all +become: yes +gather_facts: no +tasks: +\- name: setting permissions on directory and user +acl: +path: /path/to/scripts/directory +entity: "{{ item }}" +etype: user +permissions: rwx +state: present +loop: +\- www-data +\- root +``` + +### Security realized? + +Applying ACLs to files and users is a practice you should take seriously in your role as a DevOps engineer. Security best practices and formal compliance often get little or no attention. When you allow access to files with sensitive data, you are always risking that the data will be tampered with, stolen, or deleted. Therefore, data protection must be a focal point in your security strategy. Ansible can be part of your security automation strategy, as demonstrated here, and your ACL application is as good a place to start as any. + +Automating your security practices will, of course, go beyond just managing ACLs; it might also involve [SELinux][6] configuration, cryptography, security, and compliance. Remember that Ansible also allows you to define your systems for security, whether it's locking down users and groups (e.g., managing ACLs), setting firewall rules, or applying custom security policies. + +Your security strategy should start with a baseline plan. As a DevOps engineer or admin, you should examine the current security strategy (or the lack thereof), then chart your plan for automating security in your environment. + +### Conclusion + +Using Ansible to manage your ACLs as part of your overall security automation strategy depends on the size of both the company you work for and the infrastructure you manage. Permissions, users, and files can quickly get out of control, potentially placing your security in peril and putting the company in a position you definitely don't want to it be. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/manage-access-control-lists-ansible + +作者:[Taz Brown ][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/heronthecli +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_container_block.png?itok=S8MbXEYw (Data container block with hexagons) +[2]: https://opensource.com/article/19/2/quickstart-guide-ansible +[3]: https://docs.ansible.com/ansible/latest/modules/acl_module.html +[4]: https://opensource.com/sites/default/files/images/acl.yml_.png (Ansible playbook) +[5]: https://opensource.com/sites/default/files/images/set_filedir_permissions.png (Ansible playbook) +[6]: https://opensource.com/article/18/8/cheat-sheet-selinux diff --git a/sources/tech/20190516 Create flexible web content with a headless management system.md b/sources/tech/20190516 Create flexible web content with a headless management system.md new file mode 100644 index 0000000000..df58e96d0d --- /dev/null +++ b/sources/tech/20190516 Create flexible web content with a headless management system.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Create flexible web content with a headless management system) +[#]: via: (https://opensource.com/article/19/5/headless-cms) +[#]: author: (Sam Bocetta https://opensource.com/users/sambocetta) + +Create flexible web content with a headless management system +====== +Get the versatility and freedom to deliver content however you think is +best. +![Browser of things][1] + +In recent years, we’ve witnessed an explosion in the number of technological devices that deliver web-based content to users. Smartphones, tablets, smartwatches, and more—all with progressively advancing technical capabilities and support for an ever-widening list of operating systems and web browsers—swarm anew onto the market each year. + +What does this trend have to do with web development and headless versus traditional Content Management Systems (CMS)? Quite a lot. + +### CMS creates the internet + +A CMS is an application or set of computer programs used to manage digital content like images, videos, blog posts—essentially anything you would post on a website. An obvious example of a CMS is [WordPress][2]. + +The word "manage" is used broadly here. It can refer to creating, editing, or updating any kind of digital content on a website, as well as indexing the site to make it easily searchable. + +So, a CMS essentially separates the content displayed on a website from how that content is displayed. It also allows you, the website administrator, to set permissions on who can access, edit, modify, or otherwise manage that content. + +Suppose you want to post a new blog entry, update or correct something in an old post, write on your Facebook page, share a social media link to a video or article, or embed a video, music file, or pre-written set of text into a page on your website. If you have ever done anything like this, you have made use of CMS features. + +### Traditional CMS architecture: Benefits and flaws + +There are two major components that make up a CMS: the Content Management Application (CMA) and the Content Delivery Application (CDA). The CMA pertains to the front-end portion of the website. This is what allows authors or other content managers to edit and create content without help from a web developer. The CDA pertains to the back end portion of a website. By organizing and compiling content to make website content updates possible, it automates the function of a website administrator. + +Traditionally, these two pieces are joined into a single unit as a "coupled" CMS architecture. A **coupled CMS** uses a specific front-end delivery system (CMA) built into the application itself. The term "coupled" comes from the fact that the front-end framework—the templates and layout of the pages and how those pages respond to being opened in certain browsers—is coupled to the website’s content. In other words, in a coupled CMS architecture the Content Management Application (CMA) and Content Delivery Application (CDA) are inseparably merged. + +#### Benefits of the traditional CMS + +Coupled architecture does offer advantages, mainly in simplicity and ease of use for those who are not technically sophisticated. This fact explains why a platform like WordPress, which retains a traditional CMS setup, [remains so popular][3] for those who create websites or blogs. + +Further simplifying the web development process [are website builder applications][4], such as [Wix][5] and [Squarespace][6], which allow you to build drag-and-drop websites. The most popular of these builders use open source libraries but are themselves closed source. These sites allow almost anyone who can find the internet to put a website together without wading through the relatively short weeds of a CMS environment. While builder applications were [the object of derision][7] not so long ago amongst many in the open source community—mainly because they tended to give websites a generic and pre-packaged look and feel—they have grown increasingly functional and variegated. + +#### Security is an issue + +However, for all but the simplest web apps, a traditional CMS architecture results in inflexible technology. Modifying a static website or web app with a traditional CMS requires tremendous time and effort to produce updates, patches, and installations, preventing developers from keeping up with the growing number of devices and browsers. + +Furthermore, coupled CMSs have two built-in security flaws: + +**Risk #1** : Since content management and delivery are bound together, hackers who breach your website through the front end automatically gain access to the back-end database. This lack of separation between data and its presentation increases the likelihood that data will be stolen. Depending on the kind of user data stored on your website’s servers, a large-scale theft could be catastrophic. + +**Risk #2** : The risk of successful [Distributed Denial of Service][8] (DDoS) attacks increases without a separate system for delivering content to your website. DDoS attacks flood content delivery networks with so many traffic requests that they become overwhelmed and go offline. If your content delivery network is separated from your actual web servers, attackers will be less able to bring down your site. + +To avoid these problems, developers have introduced headless and decoupled CMSs. + +### Comparing headless and decoupled CMSs + +The "head" of a CMS is a catch-all term for the Content Delivery Application. Therefore, a CMS without one—and so with no way of delivering content to a user—is called "headless." + +This lack of an established delivery method gives headless CMSs enormous versatility. Without a CDA there is no pre-established delivery method, so developers can design separate frameworks as the need arises. The problem of constantly patching your website, web apps, and other code to guarantee compatibility disappears. + +Another option, a **decoupled CMS** , includes many of the same features and benefits as a headless CMS, but there is one crucial difference. Where a headless CMS leaves it entirely to the developer to deliver and present content to their users, a decoupled CMS offers pre-established delivery tools that developers can either take or leave. Decoupled CMSs thus offer both the simplicity of the traditional CMS and the versatility of the headless ones. + +In short, a decoupled CMS is sometimes called a **hybrid CMS ****since it's a hybrid of the coupled and headless designs. Decoupled CMSs are not a new concept. As far back as 2015, PHP core repository developer David Buchmann was [calling on devs][9] to decouple their CMSs to meet a wider set of challenges. + +### Security improvements with a headless CMS + +Perhaps the most important point to make about headless versus decoupled content management architectures, and how they both differ from traditional architecture, is the added security benefit. In both the headless and decoupled designs, content and user data are located on a separate back-end system protected by a firewall. The user can’t access the content management application itself. + +However, it's important to keep in mind that the major consequence of this change in architectures is that since the architecture is fragmented, developers have to fill in the gaps and design content delivery and presentation mechanisms on their own. This means that whether you opt to go headless or decoupled, your developer needs to understand security. While separating content management and content delivery gives hackers one fewer vector through which to attack, this isn’t a security benefit in itself. The burden will be on your devs to properly secure your resulting CDA. + +A firewall protecting the back end provides a [crucial layer of security][10]. Headless and decoupled architectures can distribute your content among multiple databases, so if you take advantage of this possibility you can lower the chance of successful DDoS attacks even further. Open source headless CMS can also benefit from the installation of a [Linux VPN][11] or Linux kernel firewall management tool like [iptables][12]. All of these options combine to provide the added security developers need to create no matter what kind of CDA or back end setup they choose. + +Benefits aside, keep in mind that headless CMS platforms are a fairly new tech. Before making the switch to headless or decoupled, consider whether the host you’re using can support your added security so that you can host your application behind network security systems to block attempts at unauthorized access. If they cannot, a host change might be in order. When evaluating new hosts, also consider any existing contracts or security and compliance restrictions in place (GDPR, CCPA, etc.) which could cause migration troubles. + +### Open source options + +As you can see, headless architecture offers designers the versatility and freedom to deliver content however they think best. This spirit of freedom fits naturally with the open source paradigm in software design, in which all source code is available to public view and may be taken and modified by anyone for any reason. + +There are a number of open source headless CMS platforms that allow developers to do just that: [Mura,][13] [dotCMS][14], and [Cockpit CMS][15] to name a few. For a deeper dive into the world of open source headless CMS platforms, [check out this article][16]. + +### Final thoughts + +For web designers and developers, the idea of a headless CMS marks a significant rethinking of how sites are built and delivered. Moving to this architecture is a great way to future-proof your website against changing preferences and whatever tricks future hackers may cook up, while at the same time creating a seamless user experience no matter what device or browser is used. You might also take a look at [this guide][17] for UX tips on designing your website in a way that meshes with headless and decoupled architectures. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/headless-cms + +作者:[Sam Bocetta][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sambocetta +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_desktop_website_checklist_metrics.png?itok=OKKbl1UR (Browser of things) +[2]: https://wordpress.org/ +[3]: https://kinsta.com/wordpress-market-share/ +[4]: https://hostingcanada.org/website-builders/ +[5]: https://www.wix.com/ +[6]: https://www.squarespace.com +[7]: https://arstechnica.com/information-technology/2016/11/wordpress-and-wix-trade-shots-over-alleged-theft-of-open-source-code/ +[8]: https://www.cloudflare.com/learning/ddos/what-is-a-ddos-attack/ +[9]: https://opensource.com/business/15/3/decoupling-your-cms +[10]: https://www.hostpapa.com/blog/security/why-your-small-business-needs-a-firewall/ +[11]: https://surfshark.com/download/linux +[12]: https://www.linode.com/docs/security/firewalls/control-network-traffic-with-iptables/ +[13]: https://www.getmura.com/ +[14]: https://dotcms.com/ +[15]: https://getcockpit.com/ +[16]: https://www.cmswire.com/web-cms/13-headless-cmss-to-put-on-your-radar/ +[17]: https://medium.com/@mat_walker/tips-for-content-modelling-with-the-headless-cms-contentful-7e886a911962 diff --git a/sources/tech/20190516 Monitor and Manage Docker Containers with Portainer.io (GUI tool) - Part-2.md b/sources/tech/20190516 Monitor and Manage Docker Containers with Portainer.io (GUI tool) - Part-2.md new file mode 100644 index 0000000000..58a9459a41 --- /dev/null +++ b/sources/tech/20190516 Monitor and Manage Docker Containers with Portainer.io (GUI tool) - Part-2.md @@ -0,0 +1,244 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Monitor and Manage Docker Containers with Portainer.io (GUI tool) – Part-2) +[#]: via: (https://www.linuxtechi.com/monitor-manage-docker-containers-portainer-io-part-2/) +[#]: author: (Shashidhar Soppin https://www.linuxtechi.com/author/shashidhar/) + +Monitor and Manage Docker Containers with Portainer.io (GUI tool) – Part-2 +====== + +As a continuation of Part-1, this part-2 has remaining features of Portainer covered and as explained below. + +### Monitoring docker container images + +``` +root@linuxtechi ~}$ docker ps -a +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +9ab9aa72f015 ubuntu "/bin/bash" 14 seconds ago Exited (0) 12 seconds ago suspicious_shannon +305369d3b2bb centos "/bin/bash" 24 seconds ago Exited (0) 22 seconds ago admiring_mestorf +9a669f3dc4f6 portainer/portainer "/portainer" 7 minutes ago Up 7 minutes 0.0.0.0:9000->9000/tcp trusting_keller +``` + +Including the portainer(which is a docker container image), all the exited and present running docker images are displayed. Below screenshot from Portainer GUI displays the same. + +[![Docker_status][1]][2] + +### Monitoring events + +Click on the “Events” option from the portainer webpage as shown below. + +Various events that are generated and created based on docker-container activity, are captured and displayed in this page + +[![Container-Events-Poratiner-GUI][3]][4] + +Now to check and validate how the “ **Events** ” section works. Create a new docker-container image redis as explained below, check the docker ps –a status at docker command-line. + +``` +root@linuxtechi ~}$ docker ps -a +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +cdbfbef59c31 redis "docker-entrypoint.s…" About a minute ago Up About a minute 6379/tcp angry_varahamihira +9ab9aa72f015 ubuntu "/bin/bash" 10 minutes ago Exited (0) 10 minutes ago suspicious_shannon +305369d3b2bb centos "/bin/bash" 11 minutes ago Exited (0) 11 minutes ago admiring_mestorf +9a669f3dc4f6 portainer/portainer "/portainer" 17 minutes ago Up 17 minutes 0.0.0.0:9000->9000/tcp trusting_keller +``` + +Click the “Event List” on the top to refresh the events list, + +[![events_updated][5]][6] + +Now the event’s page also updated with this change, + +### Host status + +Below is the screenshot of the portainer displaying the host status. This is a simple window showing-up. This shows the basic info like “CPU”, “hostname”, “OS info” etc of the host linux machine. Instead of logging- into the host command-line, this page provides very useful info on for quick glance. + +[![Host-names-Portainer][7]][8] + +### Dashboard in Portainer + +Until now we have seen various features of portainer based under “ **Local”** section. Now jump on to the “ **Dashboard** ” section of the selected Docker Container image. + +When “ **EndPoint** ” option is clicked in the GUI of Portainer, the following window appears, + +[![End_Point_Settings][9]][10] + +This Dashboard has many statuses and options, for a host container image. + +**1) Stacks:** Clicking on this option, provides status of any stacks if any. Since there are no stacks, this displays zero. + +**2) Images:** Clicking on this option provides host of container images that are available. This option will display all the live and exited container images + +[![Docker-Container-Images-Portainer][11]][12] + +For example create one more “ **Nginx”** container and refresh this list to see the updates. + +``` +root@linuxtechi ~}$ sudo docker run nginx +Unable to find image 'nginx:latest' locally +latest: Pulling from library/nginx +27833a3ba0a5: Pull complete +ea005e36e544: Pull complete +d172c7f0578d: Pull complete +Digest: sha256:e71b1bf4281f25533cf15e6e5f9be4dac74d2328152edf7ecde23abc54e16c1c +Status: Downloaded newer image for nginx:latest +``` + +The following is the image after refresh, + +[![Nginx_Image_creation][13]][14] + +Once the Nginx image is stopped/killed and docker container image will be moved to unused status. + +**Note** :-One can see all the image details here are very clear with memory usage, creation date and time. As compared to command-line option, maintaining and monitoring containers from here it will be very easy. + +**3) Networks:** this option is used for network operations. Like assigning IP address, creating subnets, providing IP address range, access control (admin and normal user) . The following window provides the details of various options possible. Based on your need these options can be explored further. + +[![Conatiner-Network-Portainer][15]][16] + +Once all the various networking parameters are entered, “ **create network** ” button is clicked for creating the network. + +**4) Container:** (click on container) This option will provide the container status. This list will provide details on live and not running container statuses. This output is similar to docker ps command option. + +[![Containers-Status-Portainer][17]][18] + +From this window only the containers can be stopped and started as need arises by checking the check box and selecting the above buttons. One example is provided as below, + +Example, Both “CentOS” and “Ubuntu” containers which are in stopped state, they are started now by selecting check boxes and hitting “Start” button. + +[![start_containers1][19]][20] + +[![start_containers2][21]][22] + +**Note:** Since both are Linux container images, they will not be started. Portainer tries to start and stops later. Try “Nginx” instead and you can see it coming to “running”status. + +[![start_containers3][23]][24] + +**5) Volume:** Described in Part-I of Portainer Article + +### Setting option in Portainer + +Until now we have seen various features of portainer based under “ **Local”** section. Now jump on to the “ **Setting”** section of the selected Docker Container image. + +When “Settings” option is clicked in the GUI of Portainer, the following further configuration options are available, + +**1) Extensions** : This is a simple Portainer CE subscription process. The details and uses can be seen from the attached window. This is mainly used for maintaining the license and subscription of the respective version. + +[![Extensions][25]][26] + +**2) Users:** This option is used for adding “users” with or without administrative privileges. Following example provides the same. + +Enter the selected user name “shashi” in this case and your choice of password and hit “ **Create User** ” button below. + +[![create_user_portainer][27]][28] + +[![create_user2_portainer][29]][30] + +[![Internal-user-Portainer][31]][32] + +Similarly the just now created user “shashi” can be removed by selecting the check box and hitting remove button. + +[![user_remove_portainer][33]][34] + +**3) Endpoints:** this option is used for Endpoint management. Endpoints can be added and removed as shown in the attached windows. + +[![Endpoint-Portainer-GUI][35]][36] + +The new endpoint “shashi” is created using the various default parameters as shown below, + +[![Endpoint2-Portainer-GUI][37]][38] + +Similarly this endpoint can be removed by clicking the check box and hitting remove button. + +**4) Registries:** this option is used for registry management. As docker hub has registry of various images, this feature can be used for similar purposes. + +[![Registry-Portainer-GUI][39]][40] + +With the default options the “shashi-registry” can be created. + +[![Registry2-Portainer-GUI][41]][42] + +Similarly this can be removed if not required. + +**5) Settings:** This option is used for the following various options, + + * Setting-up snapshot interval + * For using custom logo + * To create external templates + * Security features like- Disable and enable bin mounts for non-admins, Disable/enable privileges for non-admins, Enabling host management features + + + +Following screenshot shows some options enabled and disabled for demonstration purposes. Once all done hit on “Save Settings” button to save all these options. + +[![Portainer-GUI-Settings][43]][44] + +Now one more option pops-up on “Authentication settings” for LDAP, Internal or OAuth extension as shown below” + +[![Authentication-Portainer-GUI-Settings][45]][46] + +Based on what level of security features we want for our environment, respective option is chosen. + +That’s all from this article, I hope these Portainer GUI articles helps you to manage and monitor containers more efficiently. Please do share your feedback and comments. + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/monitor-manage-docker-containers-portainer-io-part-2/ + +作者:[Shashidhar Soppin][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/shashidhar/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Docker_status-1024x423.jpg +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Docker_status.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Events-1024x404.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Events.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/05/events_updated-1024x414.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/05/events_updated.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Host_names-1024x408.jpg +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Host_names.jpg +[9]: https://www.linuxtechi.com/wp-content/uploads/2019/05/End_Point_Settings-1024x471.jpg +[10]: https://www.linuxtechi.com/wp-content/uploads/2019/05/End_Point_Settings.jpg +[11]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Images-1024x398.jpg +[12]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Images.jpg +[13]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Nginx_Image_creation-1024x439.jpg +[14]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Nginx_Image_creation.jpg +[15]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Network-1024x463.jpg +[16]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Network.jpg +[17]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Containers-1024x364.jpg +[18]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Containers.jpg +[19]: https://www.linuxtechi.com/wp-content/uploads/2019/05/start_containers1-1024x432.jpg +[20]: https://www.linuxtechi.com/wp-content/uploads/2019/05/start_containers1.jpg +[21]: https://www.linuxtechi.com/wp-content/uploads/2019/05/start_containers2-1024x307.jpg +[22]: https://www.linuxtechi.com/wp-content/uploads/2019/05/start_containers2.jpg +[23]: https://www.linuxtechi.com/wp-content/uploads/2019/05/start_containers3-1024x435.jpg +[24]: https://www.linuxtechi.com/wp-content/uploads/2019/05/start_containers3.jpg +[25]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Extensions-1024x421.jpg +[26]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Extensions.jpg +[27]: https://www.linuxtechi.com/wp-content/uploads/2019/05/create_user-1024x350.jpg +[28]: https://www.linuxtechi.com/wp-content/uploads/2019/05/create_user.jpg +[29]: https://www.linuxtechi.com/wp-content/uploads/2019/05/create_user2-1024x372.jpg +[30]: https://www.linuxtechi.com/wp-content/uploads/2019/05/create_user2.jpg +[31]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Internal-user-Portainer-1024x257.jpg +[32]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Internal-user-Portainer.jpg +[33]: https://www.linuxtechi.com/wp-content/uploads/2019/05/user_remove-1024x318.jpg +[34]: https://www.linuxtechi.com/wp-content/uploads/2019/05/user_remove.jpg +[35]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Endpoint-1024x349.jpg +[36]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Endpoint.jpg +[37]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Endpoint2-1024x379.jpg +[38]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Endpoint2.jpg +[39]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Registry-1024x420.jpg +[40]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Registry.jpg +[41]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Registry2-1024x409.jpg +[42]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Registry2.jpg +[43]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Portainer-GUI-Settings-1024x418.jpg +[44]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Portainer-GUI-Settings.jpg +[45]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Authentication-Portainer-GUI-Settings-1024x344.jpg +[46]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Authentication-Portainer-GUI-Settings.jpg diff --git a/sources/tech/20190516 Querying 10 years of GitHub data with GHTorrent and Libraries.io.md b/sources/tech/20190516 Querying 10 years of GitHub data with GHTorrent and Libraries.io.md deleted file mode 100644 index c7ec1de513..0000000000 --- a/sources/tech/20190516 Querying 10 years of GitHub data with GHTorrent and Libraries.io.md +++ /dev/null @@ -1,164 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Querying 10 years of GitHub data with GHTorrent and Libraries.io) -[#]: via: (https://opensource.com/article/19/5/chaossearch-github-ghtorrent) -[#]: author: (Pete Cheslock https://opensource.com/users/petecheslock/users/ghaff/users/payalsingh/users/davidmstokes) - -Querying 10 years of GitHub data with GHTorrent and Libraries.io -====== -There is a way to explore GitHub data without any local infrastructure -using open source datasets. -![magnifying glass on computer screen][1] - -I’m always on the lookout for new datasets that we can use to show off the power of my team's work. [**CHAOS** SEARCH][2] turns your [Amazon S3][3] object storage data into a fully searchable [Elasticsearch][4]-like cluster. With the Elasticsearch API or tools like [Kibana][5], you can then query whatever data you find. - -I was excited when I found the [GHTorrent][6] project to explore. GHTorrent aims to build an offline version of all data available through the GitHub APIs. If datasets are your thing, this is a project worth checking out or even consider [donating one of your GitHub API keys][7]. - -### Accessing GHTorrent data - -There are many ways to gain access to and use [GHTorrent’s data][8], which is available in [NDJSON][9]** **format. This project does a great job making the data available in multiple forms, including[CSV][10] for restoring into a [MySQL][11] database, [MongoDB][12] dumps of all objects, and Google Big Query** **(free) for exporting data directly into Google’s object storage. There is one caveat: this dataset has a nearly complete dataset from 2008 to 2017 but is not as complete from 2017 to today. That will impact our ability to query with certainty, but it is still an exciting amount of information. - -I chose Google Big Query to avoid running any database myself, so I was quickly able to download a full corpus of data including users and projects. **CHAOS** SEARCH can natively analyze the NDJSON format, so after uploading the data to Amazon S3 I was able to index it in just a few minutes. The **CHAOS** SEARCH platform doesn’t require users to set up index schemas or define mappings for their data, so it discovered all of the fields—strings, integers, etc.—itself. - -With my data fully indexed and ready for search and aggregation, I wanted to dive in and see what insights we can learn, like which software languages are the most popular for GitHub projects. - -(A note on formatting: this is a valid JSON query that we won't format correctly here to avoid scroll fatigue. To properly format it, you can copy it locally and send to a command-line utility like [jq][13].) - - -``` -`{"aggs":{"2":{"date_histogram":{"field":"root.created_at","interval":"1M","time_zone":"America/New_York","min_doc_count":1}}},"size":0,"_source":{"excludes":[]},"stored_fields":["*"],"script_fields":{},"docvalue_fields":["root.created_at","root.updated_at"],"query":{"bool":{"must":[],"filter":[{"match_all":{}}],"should":[],"must_not":[{"match_phrase":{"root.language":{"query":""}}}]}}}` -``` - -This result is of little surprise to anyone who’s followed the state of open source languages over recent years. - -![Which software languages are the most popular on GitHub.][14] - -[JavaScript][15] is still the reigning champion, and while some believe JavaScript is on its way out, it remains the 800-pound gorilla and is likely to remain that way for some time. [Java][16] faces similar rumors and this data shows that it's a major part of the open source ecosystem. - -Given the popularity of projects like [Docker][17] and [Kubernetes][18], you might be wondering, “What about Go ([Golang][19])?” This is a good time for a reminder that the GitHub dataset discussed here contains some gaps, most significantly after 2017, which is about when I saw Golang projects popping up everywhere. I hope to repeat this search with a complete GitHub dataset and see if it changes the rankings at all. - -Now let's explore the rate of project creation. (Reminder: this is valid JSON consolidated for readability.) - - -``` -`{"aggs":{"2":{"date_histogram":{"field":"root.created_at","interval":"1M","time_zone":"America/New_York","min_doc_count":1}}},"size":0,"_source":{"excludes":[]},"stored_fields":["*"],"script_fields":{},"docvalue_fields":["root.created_at","root.updated_at"],"query":{"bool":{"must":[],"filter":[{"match_all":{}}],"should":[],"must_not":[{"match_phrase":{"root.language":{"query":""}}}]}}}` -``` - -Seeing the rate at which new projects are created would be fun impressive as well, with tremendous growth starting around 2012: - -![The rate at which new projects are created on GitHub.][20] - -Now that I knew the rate of projects created as well as the most popular languages used to create these projects, I wanted to find out what open source licenses these projects chose. Unfortunately, this data doesn’t exist in the GitHub projects dataset, but the fantastic team over at [Tidelift][21] publishes a detailed list of GitHub projects, licenses used, and other details regarding the state of open source software in their [Libraries.io][22][ data][23]. Ingesting this dataset into **CHAOS** SEARCH took just minutes, letting me see which open source software licenses are the most popular on GitHub: - -(Reminder: this is valid JSON consolidated for readability.) - - -``` -`{"aggs":{"2":{"terms":{"field":"Repository License","size":10,"order":{"_count":"desc"}}}},"size":0,"_source":{"excludes":[]},"stored_fields":["*"],"script_fields":{},"docvalue_fields":["Created Timestamp","Last synced Timestamp","Latest Release Publish Timestamp","Updated Timestamp"],"query":{"bool":{"must":[],"filter":[{"match_all":{}}],"should":[],"must_not":[{"match_phrase":{"Repository License":{"query":""}}}]}}}` -``` - -The results show some significant outliers: - -![Which open source software licenses are the most popular on GitHub.][24] - -As you can see, the [MIT license][25] and the [Apache 2.0 license][26] by far outweighs most of the other open source licenses used for these projects, while [various BSD and GPL licenses][27] follow far behind. I can’t say that I’m surprised by these results given GitHub’s open model. I would guess that users, not companies, create most projects and that they use the MIT license to make it simple for other people to use, share, and contribute. That Apache 2.0** **licensing is right behind also makes sense, given just how many companies want to ensure their trademarks are respected and have an open source component to their businesses. - -Now that I identified the most popular licenses, I was curious to see the least used ones. By adjusting my last query, I reversed the top 10 into the bottom 10 and was able to find just two projects using the [University of Illinois—NCSA Open Source License][28]. I had never heard of this license before, but it’s pretty close to Apache 2.0. It’s interesting to see just how many different software licenses are in use across all GitHub projects. - -![The University of Illinois/NCSA open source license.][29] - -The University of Illinois/NCSA open source license. - -After that, I dove into a specific language (JavaScript) to see the most popular license used there. (Reminder: this is valid JSON consolidated for readability.) - - -``` -`{"aggs":{"2":{"terms":{"field":"Repository License","size":10,"order":{"_count":"desc"}}}},"size":0,"_source":{"excludes":[]},"stored_fields":["*"],"script_fields":{},"docvalue_fields":["Created Timestamp","Last synced Timestamp","Latest Release Publish Timestamp","Updated Timestamp"],"query":{"bool":{"must":[{"match_phrase":{"Repository Language":{"query":"JavaScript"}}}],"filter":[{"match_all":{}}],"should":[],"must_not":[{"match_phrase":{"Repository License":{"query":""}}}]}}}` -``` - -There were some surprises in this output. - -![The most popular open source licenses used for GitHub JavaScript projects.][30] - -Even though the default license for [NPM][31] modules when created with **npm init **is the one from [Internet Systems Consortium (ISC)][32], you can see that a considerable number of these projects use MIT as well as Apache 2.0 for their open source license. - -Since the Libraries.io dataset is rich in open source project content, and since the GHTorrent data is missing the last few years’ data (and thus missing any details about Golang projects), I decided to run a similar query to see how Golang projects license their code. - -(Reminder: this is valid JSON consolidated for readability.) - - -``` -`{"aggs":{"2":{"terms":{"field":"Repository License","size":10,"order":{"_count":"desc"}}}},"size":0,"_source":{"excludes":[]},"stored_fields":["*"],"script_fields":{},"docvalue_fields":["Created Timestamp","Last synced Timestamp","Latest Release Publish Timestamp","Updated Timestamp"],"query":{"bool":{"must":[{"match_phrase":{"Repository Language":{"query":"Go"}}}],"filter":[{"match_all":{}}],"should":[],"must_not":[{"match_phrase":{"Repository License":{"query":""}}}]}}}` -``` - -The results were quite different than Javascript. - -![How Golang projects license their GitHub code.][33] - -Golang offers a stunning reversal from JavaScript—nearly three times as many Golang projects are licensed with Apache 2.0 over MIT. While it’s hard precisely explain why this is the case, over the last few years there’s been massive growth in Golang, especially among companies building projects and software offerings, both open source and commercially. - -As we learned above, many of these companies want to enforce their trademarks, thus the move to the Apache 2.0 license makes sense. - -#### Conclusion - -In the end, I found some interesting results by diving into the GitHub users and projects data dump. Some of these I definitely would have guessed, but a few results were surprises to me as well, especially the outliers like the rarely-used NCSA license. - -All in all, you can see how quickly and easily the **CHAOS** SEARCH platform lets us find complicated answers to interesting questions. I dove into this dataset and received deep analytics without having to run any databases myself, and even stored the data inexpensively on Amazon S3—so there’s little maintenance involved. Now I can ask any other questions regarding the data anytime I want. - -What other questions are you asking your data, and what data sets do you use? Let me know in the comments or on Twitter [@petecheslock][34]. - -_A version of this article was originally posted on[ **CHAOS** SEARCH][35]._ - -* * * - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/5/chaossearch-github-ghtorrent - -作者:[Pete Cheslock][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/petecheslock/users/ghaff/users/payalsingh/users/davidmstokes -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/search_find_code_issue_bug_programming.png?itok=XPrh7fa0 (magnifying glass on computer screen) -[2]: https://chaossearch.io/ -[3]: https://aws.amazon.com/s3/ -[4]: https://www.elastic.co/ -[5]: https://www.elastic.co/products/kibana -[6]: http://ghtorrent.org -[7]: http://ghtorrent.org/services.html -[8]: http://ghtorrent.org/downloads.html -[9]: http://ndjson.org -[10]: https://en.wikipedia.org/wiki/Comma-separated_values -[11]: https://en.wikipedia.org/wiki/MySQL -[12]: https://www.mongodb.com/ -[13]: https://stedolan.github.io/jq/ -[14]: https://opensource.com/sites/default/files/uploads/github-1_500.png (Which software languages are the most popular on GitHub.) -[15]: https://en.wikipedia.org/wiki/JavaScript -[16]: /resources/java -[17]: /resources/what-docker -[18]: /resources/what-is-kubernetes -[19]: https://golang.org/ -[20]: https://opensource.com/sites/default/files/uploads/github-2_500.png (The rate at which new projects are created on GitHub.) -[21]: https://tidelift.com -[22]: http://libraries.io/ -[23]: https://libraries.io/data -[24]: https://opensource.com/sites/default/files/uploads/github-3_500.png (Which open source software licenses are the most popular on GitHub.) -[25]: https://opensource.org/licenses/MIT -[26]: https://opensource.org/licenses/Apache-2.0 -[27]: https://opensource.org/licenses -[28]: https://tldrlegal.com/license/university-of-illinois---ncsa-open-source-license-(ncsa) -[29]: https://opensource.com/sites/default/files/uploads/github-4_500_0.png (The University of Illinois/NCSA open source license.) -[30]: https://opensource.com/sites/default/files/uploads/github-5_500_0.png (The most popular open source licenses used for GitHub JavaScript projects.) -[31]: https://www.npmjs.com/ -[32]: https://en.wikipedia.org/wiki/ISC_license -[33]: https://opensource.com/sites/default/files/uploads/github-6_500.png (How Golang projects license their GitHub code.) -[34]: https://twitter.com/petecheslock -[35]: https://chaossearch.io/blog/where-are-the-github-users-part-1/ diff --git a/sources/tech/20190516 System76-s secret sauce for success.md b/sources/tech/20190516 System76-s secret sauce for success.md new file mode 100644 index 0000000000..9409de535f --- /dev/null +++ b/sources/tech/20190516 System76-s secret sauce for success.md @@ -0,0 +1,71 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (System76's secret sauce for success) +[#]: via: (https://opensource.com/article/19/5/system76-secret-sauce) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins/users/don-watkins) + +System76's secret sauce for success +====== +Linux computer maker's approach to community-informed software and +hardware development embodies the open source way. +![][1] + +In [_The Open Organization_][2], Jim Whitehurst says, "show passion for the purpose of your organization and constantly drive interest in it. People are drawn to and generally, want to follow passionate people." Carl Richell, the founder and CEO of Linux hardware maker [System76][3], pours that secret sauce to propel his company in the world of open hardware, Linux, and open source. + +Carl demonstrates quiet confidence and engages the team at System76 in a way that empowers their creative synergy. During a recent visit to System76's Denver factory, I could immediately tell that the employees love what they do, what they produce, and their interaction with each other and their customers, and Carl sets that example. They are as they [describe themselves][4]: a diverse team of creators, makers, and builders; a small company innovating the next big things; and a group of extremely hard-core nerds. + +### A revolutionary approach + +In 2005, Carl had a vision, which began as talk over some beers, to produce desktop and laptop computers that come installed with Linux. He's transformed that idea into a highly successful company founded on the [belief][5] that "the computer and operating system are the most powerful and versatile tools ever created." And by producing the best tools, System76 can inspire the curious to make their greatest discovery or complete their greatest project. + +![System 76 founder and CEO Carl Richell][6] + +Carl Richell's enthusiasm was obvious at System 76's [Thelio launch event][7]. + +System76 lives up to its name, which was inspired by the American Revolution of 1776. The company views itself as a leader in the open source revolution, granting people freedom and independence from proprietary hardware and software. + +But the revolution does not end there; it continues with the company's business practices and diverse environment that aims to close the gender gap in technology leadership. Eight of the company's 28 employees are women, including vice president of marketing Louisa Bisio, creative manager Kate Hazen, purchasing manager May Liu, head of technical support Emma Marshall, and manufacturing control and logistics manager Sarah Zinger. + +### Community-informed design + +The staff members' passion and ingenuity for making the Linux experience enjoyable for customers creates an outstanding culture. Because the company believes the Linux desktop deserves a dedicated PC manufacturer, in 2018, it brought manufacturing in-house. This allows System76's engineers to make design changes more quickly, based on their frequent interactions with Linux users to learn about their needs and wants. It also opens up its parts and process to the public, including publishing design files under GPL on [GitHub][8], consistent with its commitment to openness and open source. + +For example, when System76 decided to create its own version of Linux, [Pop!_OS][9], it hosted online meetings to discuss and learn what features and software its customers wanted. This decision to work closely with the community has been instrumental in making Pop!_OS successful. + +System76 again turned to the community when it began developing [Thelio][10], its new line of desktop computers. Marketing VP Louisa Bisio says, "Taking a similar approach to open hardware has been great. We started in-house design in 2016, prototyping different desktop designs. Then we moved from prototyping acrylic to sheet metal. Then the first few prototypes of Thelio were presented to our [Superfan][11] attendees in 2017, and their feedback was really important in adjusting the desktop designs and progressing Thelio iterations forward." + +Thelio is the product of research and development focusing on high-quality components and design. It features a unique cabling layout, innovative airflow within the computer case, and the Thelio Io open hardware SATA controller. Many of System76's customers use platforms like [CUDA][12] to do their work; to support them, System76 works backward and pulls out proprietary functionality, piece by piece, until everything is open. + +### Open roads ahead + +Manufacturing open laptops are on the long-range roadmap, but the company is actively working on an open motherboard and maintaining Pop!_OS and System76 drivers, which are open. This commitment to openness, customer-driven design, and culture give System 76 a unique place in computer manufacturing. All of this stems from founder Carl Richell and his philosophy "that technology should be open and accessible to everyone." [As Carl says][13], "open hardware benefits all of us. It's how we further advance technology and make it more available to everyone." + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/system76-secret-sauce + +作者:[Don Watkins ][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bubblehands_fromRHT_520_0612LL.png?itok=_iQ2dO3S +[2]: https://www.amazon.com/Open-Organization-Igniting-Passion-Performance/dp/1511392460 +[3]: https://system76.com/ +[4]: https://system76.com/about +[5]: https://system76.com/pop +[6]: https://opensource.com/sites/default/files/uploads/carl_richell.jpg (System 76 founder and CEO Carl Richell) +[7]: https://trevgstudios.smugmug.com/System76/121418-Thelio-Press-Event/i-w6XNmKS +[8]: https://github.com/system76 +[9]: https://opensource.com/article/18/1/behind-scenes-popos-linux +[10]: https://system76.com/desktops +[11]: https://system76.com/superfan +[12]: https://en.wikipedia.org/wiki/CUDA +[13]: https://opensource.com/article/19/4/system76-hardware diff --git a/sources/tech/20190517 Announcing Enarx for running sensitive workloads.md b/sources/tech/20190517 Announcing Enarx for running sensitive workloads.md new file mode 100644 index 0000000000..81d021f7d7 --- /dev/null +++ b/sources/tech/20190517 Announcing Enarx for running sensitive workloads.md @@ -0,0 +1,83 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Announcing Enarx for running sensitive workloads) +[#]: via: (https://opensource.com/article/19/5/enarx-security) +[#]: author: (Mike Bursell https://opensource.com/users/mikecamel/users/wgarry155) + +Announcing Enarx for running sensitive workloads +====== +Enarx leverages the capabilities of a TEE to change the trust model for +your application. +![cubes coming together to create a larger cube][1] + +Running software is something that most of us do without thinking about it. We run in "on premises"—our own machines—or we run it in the cloud - on somebody else's machines. We don't always think about what those differences mean, or about what assumptions we're making about the securtiy of the data that's being processed, or even of the software that's doing that processing. Specifically, when you run software (a "workload") on a system (a "host") on the cloud or on your own premises, there are lots and lots of layers. You often don't see those layers, but they're there. + +Here's an example of the layers that you might see in a standard cloud virtualisation architecture. The different colours represent different entities that "own" different layers or sets of layers. + +![Layers in a standard cloud virtualisation architecture][2] + +Here's a similar diagram depicting a standard cloud container architecture. As before, each different colour represents a different "owner" of a layer or set of layers. + +![Standard cloud container architecture][3] + +These owners may be of very different types, from hardware vendors to OEMs to cloud service providers (CSPs) to middleware vendors to operating system vendors to application vendors to you, the workload owner. And for each workload that you run, on each host, the exact list of layers is likely to be different. And even when they're the same, the versions of the layers instances may be different, whether it's a different BIOS version, a different bootloader, a different kernel version, or whatever else. + +Now, in many contexts, you might not worry about this, and your CSP goes out of its way to abstract these layers and their version details away from you. But this is a security article, for security people, and that means that anybody who's reading this probably does care. + +The reason we care is not just the different versions and the different layers, but the number of different things—and different entities—that we need to trust if we're going to be happy running any sort of sensitive workload on these types of stacks. I need to trust every single layer, and the owner of every single layer, not only to do what they say they will do, but also not to be compromised. This is a _big_ stretch when it comes to running my sensitive workloads. + +### What's Enarx? + +Enarx is a new project that is trying to address this problem of having to trust all of those layers. A few of us at Red Hat have been working on it for a few months now. My colleague Nathaniel McCallum demoed an early incarnation of it at [Red Hat Summit 2019][4] in Boston, and we're ready to start announcing it to the world. We have code, we have a demo, we have a GitHub repository, we have a logo: what more could a project want? Well, people—but we'll get to that. + +![Enarx logo][5] + +With Enarx, we made the decision that we wanted to allow people running workloads to be able to reduce the number of layers—and owners—that they need to trust to the absolute minimum. We plan to use trusted execution environments ("TEEs"—see "[Oh, how I love my TEE (or do I?)][6]") to provide an architecture that looks a little more like this: + +![Enarx architecture][7] + +In a world like this, you have to trust the CPU and firmware, and you need to trust some middleware—of which Enarx is part—but you don't need to trust all of the other layers, because we will leverage the capabilities of the TEE to ensure the integrity and confidentiality of your application. The Enarx project will provide attestation of the TEE, so that you know you're running on a true and trusted TEE, and will provide open source, auditable code to help you trust the layer directly beneath your application. + +The initial code is out there—working on AMD's SEV TEE at the momen—and enough of it works now that we're ready to tell you about it. + +Making sure that your application meets your own security requirements is down to you. :-) + +### How do I find out more? + +The easiest way to learn more is to visit the [Enarx GitHub][8]. + +We'll be adding more information there—it's currently just code—but bear with us: there are only a few of us on the project at the moment. A blog is on the list of things we'd like to have, but we wanted to get things started. + +We'd love to have people in the community getting involved in the project. It's currently quite low-level and requires quite a lot of knowledge to get running, but we'll work on that. You will need some specific hardware to make it work, of course. Oh, and if you're an early boot or a low-level KVM hacker, we're _particularly_ interested in hearing from you. + +I will, of course, respond to comments on this article. + +* * * + +_This article was originally published on[Alice, Eve, and Bob][9] and is reprinted with the author's permission._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/enarx-security + +作者:[Mike Bursell ][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mikecamel/users/wgarry155 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cube_innovation_process_block_container.png?itok=vkPYmSRQ (cubes coming together to create a larger cube) +[2]: https://opensource.com/sites/default/files/uploads/classic-cloud-virt-arch-1.png (Layers in a standard cloud virtualisation architecture) +[3]: https://opensource.com/sites/default/files/uploads/cloud-container-arch.png (Standard cloud container architecture) +[4]: https://www.redhat.com/en/summit/2019 +[5]: https://opensource.com/sites/default/files/uploads/enarx.png (Enarx logo) +[6]: https://aliceevebob.com/2019/02/26/oh-how-i-love-my-tee-or-do-i/ +[7]: https://opensource.com/sites/default/files/uploads/reduced-arch.png (Enarx architecture) +[8]: https://github.com/enarx +[9]: https://aliceevebob.com/2019/05/07/announcing-enarx/ diff --git a/sources/tech/20190519 The three Rs of remote work.md b/sources/tech/20190519 The three Rs of remote work.md new file mode 100644 index 0000000000..f40f8b652e --- /dev/null +++ b/sources/tech/20190519 The three Rs of remote work.md @@ -0,0 +1,65 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The three Rs of remote work) +[#]: via: (https://dave.cheney.net/2019/05/19/the-three-rs-of-remote-work) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +The three Rs of remote work +====== + +I started working remotely in 2012. Since then I’ve worked for big companies and small, organisations with outstanding remote working cultures, and others that probably would have difficulty spelling the word without predictive text. I broadly classify my experiences into three tiers; + +### Little r remote + +The first kind of remote work I call _little r_ remote. + +Your company has an office, but it’s not convenient or you don’t want to work from there. It could be the commute is too long, or its in the next town over, or perhaps a short plane flight away. Sometimes you might go into the office for a day or two a week, and should something serious arise you could join your co-workers onsite for an extended period of time. + +If you often hear people say they are going to work from home to get some work done, that’s little r remote. + +### Big R remote + +The next category I call _Big R_ remote. Big R remote differs mainly from little r remote by the tyranny of distance. It’s not impossible to visit your co-workers in person, but it is inconvenient. Meeting face to face requires a day’s flying. Passports and boarder crossings are frequently involved. The expense and distance necessitates week long sprints and commensurate periods of jetlag recuperation. + +Because of timezone differences meetings must be prearranged and periods of overlap closely guarded. Communication becomes less spontaneous and care must be taken to avoid committing to unsustainable working hours. + +### Gothic ℜ remote + +The final category is basically Big R remote working on hard mode. Everything that was hard about Big R remote, timezone, travel schedules, public holidays, daylight savings, video call latency, cultural and language barriers is multiplied for each remote worker. + +In person meetings are so rare that without a focus on written asynchronous communication progress can repeatedly stall for days, if not weeks, as miscommunication leads to disillusionment and loss of trust. + +In my experience, for knowledge workers, little r remote work offers many benefits over [the open office hell scape][1] du jour. Big R remote takes a serious commitment by all parties and if you are the first employee in that category you will bare most of the cost to making Big R remote work for you. + +Gothic ℜ remote working should probably be avoided unless all those involved have many years of working in that style _and_ the employer is committed to restructuring the company as a remote first organisation. It is not possible to succeed in a Gothic ℜ remote role without a culture of written communication and asynchronous decision making mandated, _and consistently enforced,_ by the leaders of the company. + +#### Related posts: + + 1. [How to dial remote SSL/TLS services in Go][2] + 2. [How does the go build command work ?][3] + 3. [Why Slack is inappropriate for open source communications][4] + 4. [The office coffee model of concurrent garbage collection][5] + + + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2019/05/19/the-three-rs-of-remote-work + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://twitter.com/davecheney/status/761693088666357760 +[2]: https://dave.cheney.net/2010/10/05/how-to-dial-remote-ssltls-services-in-go (How to dial remote SSL/TLS services in Go) +[3]: https://dave.cheney.net/2013/10/15/how-does-the-go-build-command-work (How does the go build command work ?) +[4]: https://dave.cheney.net/2017/04/11/why-slack-is-inappropriate-for-open-source-communications (Why Slack is inappropriate for open source communications) +[5]: https://dave.cheney.net/2018/12/28/the-office-coffee-model-of-concurrent-garbage-collection (The office coffee model of concurrent garbage collection) diff --git a/sources/tech/20190520 Blockchain 2.0 - Explaining Distributed Computing And Distributed Applications -Part 11.md b/sources/tech/20190520 Blockchain 2.0 - Explaining Distributed Computing And Distributed Applications -Part 11.md new file mode 100644 index 0000000000..c34effe6be --- /dev/null +++ b/sources/tech/20190520 Blockchain 2.0 - Explaining Distributed Computing And Distributed Applications -Part 11.md @@ -0,0 +1,88 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Blockchain 2.0 – Explaining Distributed Computing And Distributed Applications [Part 11]) +[#]: via: (https://www.ostechnix.com/blockchain-2-0-explaining-distributed-computing-and-distributed-applications/) +[#]: author: (editor https://www.ostechnix.com/author/editor/) + +Blockchain 2.0 – Explaining Distributed Computing And Distributed Applications [Part 11] +====== + +![Explaining Distributed Computing And Distributed Applications][1] + +### How DApps serve the purpose of [Blockchain 2.0][2] + +**Blockchain 1.0** was about introducing the “blockchain” into the list of modern buzzwords along with the advent of **bitcoin**. Multiple white papers detailing bitcoin’s underlying blockchain network specified the use of the blockchain for other uses as well. Although most of the said uses was around the basic concept of using the blockchain as a **decentralized medium** for storage, a use that stems from this property is utilizing it for carrying out **Distributed computing** on top of this layer. + +**DApps** or **Distributed Applications** are computer programs that are stored and run on a distributed storage system such as the [**Ethereum**][3] blockchain for instance. To understand how DApps function and how they’re different from traditional applications on your desktop or phone, we’ll need to delve into what distributed computing is. This post will explore some fundamental concepts of distributed computing and the role of blockchains in executing the said objective. Furthermore, well also look at a few applications or DApps, in blockchain lingo, to get a hang of things. + +### What is Distributed Computing? + +We’re assuming many readers are familiar with multi-threaded applications and multi-threading in general. Multi-threading is the reason why processor manufacturers are forever hell bent on increasing the core count on their products. Fundamentally speaking, some applications such as video rendering software suites are capable of dividing their work (in this case rendering effects and video styles) into multiple chunks and parallelly get them processed from a supporting computing system. This reduces the lead time on getting the work done and is generally more efficient in terms of time, money and energy usage. Applications such as some games however, cannot make use of this system since processing and responses need to be obtained real time based on user inputs rather than via planned execution. Nonetheless, the fact that more processing power may be exploited from existing hardware using these computing methods remains true and significant. + +Even supercomputers are basically a bunch of powerful CPUs all tied up together in a circuit to enable faster processing as mentioned above. The average core count on flagship CPUs from the lead manufacturers AMD and Intel have in fact gone up in the last few years, because increasing core count has recently been the only method to claim better processing and claim upgrades to their product lines. This information notwithstanding, the fact remains that distributed computing and related concepts of parallel computing are the only legitimate ways to improve processing capabilities in the near future. There are minor differences between distributed and parallel computing models as well, however that is beyond the scope off this post. + +Another method to get many computers executing programs simultaneously is to connect them through the internet and have a cloud-based program to be implemented in parts by all of the participating systems. This is the basic fundamental behind distributed applications. + +For a more detailed account and primer regarding what and how parallel computing works, interested readers may visit [this][4] webpage. For a more detailed study of the topic, for people who have a background in computer science, you may refer to [this][5] website and the accompanying book. + +### What are DApps or Distributed Applications + +Application that can make use of the capabilities offered by a distributed computing system is called a **distributed application**. The execution and structure of such an application’s back end needs to be carefully designed in order to be compatible with the system. + +The blockchain presents an opportunity to store data in a distributed system of participating nodes. Stepping up from this opportunity we can logically build systems and applications running on such a network (think about how you used to download files via the Torrent protocol). + +Such decentralized applications present a lot of benefits over conventional applications that typically run from a central server. Some highlights are: + + * DApps run on a network of such participating nodes and any user request is parsed through such network nodes to provide the user with the requested functionality. _**Program is executed on the network instead of a single computer or a server**_. + * DApps will have codified methods of filtering through requests and executing them so as to always be fair and transparent when users interact with it. To create a new block of data in the chain, the same has to be approved via a **consensus algorithm** by the participating nodes. This fundamental idea of peer to peer approval applies for DApps as well. This essentially means that DApps cannot by extension of this principle provide different outputs to the same query or input. All users will be given the same priority unless it is explicitly mentioned and all users will receive similar results from the DApp as well. This will prove to be important in developing better industry practices for insurance and finance companies for instance. A DApp that specializes in microlending, for instance, cannot differentiate and offer different interest rates for different borrowers other than their credit history. This also means that all users will eventually end up paying for their required operations uniformly depending on the computational complexity of the task they passed on to the application. For instance, combing through 10000 entries of data will cost proportionately more than combing through say 100. The payment or incentivisation system might be different for different applications and blockchain protocols though. + * Most DApps are by default redundant and fail safe. If you’re using a service which is run on a central server, a failure from the server end will freeze the application. Think of a service such as PayPal for instance. If the PayPal server in your immediate region fails due to some reason and somehow the central server cannot re route your request, your payment will not go through. However, even in case multiple participating nodes in the blockchain dies, you will still find the application live and running provided at least one node is live. This presents a use case for applications which are by definition supposed to be live all the time. Emergency services, insurance, communications etc., are some key areas where investors hope such DApps will bring in much needed reliability. + * DApps are usually cost-effective owing to them not requiring a central server to be maintained for their functionality. Once they become mainstream, the mean computing cost of running tasks on the same is also supposed to decrease. + * DApps will as mentioned exist till eternity at least until one participant is live on the chain. This essentially means that DApps cannot be censored or hacked into bowing and shutting down. + + + +The above list of features seems very few, however, combine that with all the other capabilities of the blockchain, the advancement of wireless network access, and, the increasing capabilities of millions of smartphones and here we have in our hands nothing less than a paradigm shift in how the apps that we rely on work. + +We will look deeper into how DApps function and how you can make your own DApps on the Ethereum blockchain in a proceeding post. To give you an idea of the DApp environment right now, we present 4 carefully chosen examples that are fairly advanced and popular. + +##### 1\. BITCOIN (or any Cryptocurrency) + +We’re very sure that readers did not expect BITCOIN to be one among a list of applications in this post. The point we’re trying to make here however, is that any cryptocurrency currently running on a blockchain backbone can be termed as a DApp. Cryptocurrencies are in fact the most popular DApp format out there and a revolutionary one at that too. + +##### 2\. [MELON][6] + +We’ve talked about how asset management can be an easier task utilizing blockchain and [**smart contracts**][7]. **Melon** is a company that aims to provide its users with usable relevant tools to manage and maximize their returns from the assets they own. They specialize in cryptographic assets as of now with plans to turn to real digitized assets in the future. + +##### 3\. [Request][8] + +**Request** is primarily a ledger system that handles financial transactions, invoicing, and taxation among other things. Working with other compatible databases and systems it is also capable of verifying payer data and statistics. Large corporations which typically have a significant number of defaulting customers will find it easier to handle their operations with a system such as this. + +##### 4\. [CryptoKitties][9] + +Known the world over as the video game that broke the Ethereum blockchain, **CryptoKitties** is a video game that runs on the Ethereum blockchain. The video game identifies each user individually by building your own digital profiles and gives you unique **virtual cats** in return. The game went viral and due to the sheer number of users it actually managed to slow down the Ethereum blockchain and its transaction capabilities. Transactions took longer than usual with users having to pay significantly extra money for simple transactions even. Concerns regarding scalability of the Ethereum blockchain have been raised by several stakeholders since then. + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/blockchain-2-0-explaining-distributed-computing-and-distributed-applications/ + +作者:[editor][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/05/Distributed-Computing-720x340.png +[2]: https://www.ostechnix.com/blockchain-2-0-an-introduction/ +[3]: https://www.ostechnix.com/blockchain-2-0-what-is-ethereum/ +[4]: https://www.techopedia.com/definition/7/distributed-computing-system +[5]: https://www.distributed-systems.net/index.php/books/distributed-systems-3rd-edition-2017/ +[6]: https://melonport.com/ +[7]: https://www.ostechnix.com/blockchain-2-0-explaining-smart-contracts-and-its-types/ +[8]: https://request.network/en/use-cases/ +[9]: https://www.cryptokitties.co/ diff --git a/sources/tech/20190520 How To Map Oracle ASM Disk Against Physical Disk And LUNs In Linux.md b/sources/tech/20190520 How To Map Oracle ASM Disk Against Physical Disk And LUNs In Linux.md new file mode 100644 index 0000000000..4e9df8a0ff --- /dev/null +++ b/sources/tech/20190520 How To Map Oracle ASM Disk Against Physical Disk And LUNs In Linux.md @@ -0,0 +1,229 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How To Map Oracle ASM Disk Against Physical Disk And LUNs In Linux?) +[#]: via: (https://www.2daygeek.com/shell-script-map-oracle-asm-disks-physical-disk-lun-in-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +How To Map Oracle ASM Disk Against Physical Disk And LUNs In Linux? +====== + +You might already know about ASM, Device Mapper Multipathing (DM-Multipathing) if you are working quit long time as a Linux administrator. + +There are multiple ways to check these information. However, you will be getting part of the information when you use the default commands. + +It doesn’t show you all together in the single output. + +If you want to check all together in the single output then we need to write a small shell script to achieve this. + +We have added two shell script to get those information and you can use which one is suitable for you. + +Major and Minor numbers can be used to match the physical devices in Linux system. + +This tutorial helps you to find which ASM disk maps to which Linux partition or DM Device. + +If you want to **[manage Oracle ASM disks][1]** (such as start, enable, stop, list, query and etc) then navigate to following URL. + +### What Is ASMLib? + +ASMLib is an optional support library for the Automatic Storage Management feature of the Oracle Database. + +Automatic Storage Management (ASM) simplifies database administration and greatly reduces kernel resource usage (e.g. the number of open file descriptors). + +It eliminates the need for the DBA to directly manage potentially thousands of Oracle database files, requiring only the management of groups of disks allocated to the Oracle Database. + +ASMLib allows an Oracle Database using ASM more efficient and capable access to the disk groups it is using. + +### What Is Device Mapper Multipathing (DM-Multipathing)? + +Device Mapper Multipathing or DM-multipathing is a Linux host-side native multipath tool, which allows us to configure multiple I/O paths between server nodes and storage arrays into a single device by utilizing device-mapper. + +### Method-1 : Shell Script To Map ASM Disks To Physical Devices? + +In this shell script we are using for loop to achieve the results. + +Also, we are not using any ASM related commands. + +``` +# vi asm_disk_mapping.sh + +#!/bin/bash + +ls -lh /dev/oracleasm/disks > /tmp/asmdisks1.txt + +for ASMdisk in `cat /tmp/asmdisks1.txt | tail -n +2 | awk '{print $10}'` + +do + +minor=$(grep -i "$ASMdisk" /tmp/asmdisks1.txt | awk '{print $6}') + +major=$(grep -i "$ASMdisk" /tmp/asmdisks1.txt | awk '{print $5}' | cut -d"," -f1) + +phy_disk=$(ls -l /dev/* | grep ^b | grep "$major, *$minor" | awk '{print $10}') + +echo "ASM disk $ASMdisk is associated on $phy_disk [$major, $minor]" + +done +``` + +Set an executable permission to port_scan.sh file. + +``` +$ chmod +x asm_disk_mapping.sh +``` + +Finally run the script to achieve this. + +``` +# sh asm_disk_mapping.sh + +ASM disk MP4E6D_DATA01 is associated on /dev/dm-1 +3600a0123456789012345567890234q11 [253, 1] +ASM disk MP4E6E_DATA02 is associated on /dev/dm-2 +3600a0123456789012345567890234q12 [253, 2] +ASM disk MP4E6F_DATA03 is associated on /dev/dm-3 +3600a0123456789012345567890234q13 [253, 3] +ASM disk MP4E70_DATA04 is associated on /dev/dm-4 +3600a0123456789012345567890234q14 [253, 4] +ASM disk MP4E71_DATA05 is associated on /dev/dm-5 +3600a0123456789012345567890234q15 [253, 5] +ASM disk MP4E72_DATA06 is associated on /dev/dm-6 +3600a0123456789012345567890234q16 [253, 6] +ASM disk MP4E73_DATA07 is associated on /dev/dm-7 +3600a0123456789012345567890234q17 [253, 7] +``` + +### Method-2 : Shell Script To Map ASM Disks To Physical Devices? + +In this shell script we are using while loop to achieve the results. + +Also, we are using ASM related commands. + +``` +# vi asm_disk_mapping_1.sh + +#!/bin/bash + +/etc/init.d/oracleasm listdisks > /tmp/asmdisks.txt + +while read -r ASM_disk + +do + +major="$(/etc/init.d/oracleasm querydisk -d $ASM_disk | awk -F[ '{ print $2 }'| awk -F] '{ print $1 }' | cut -d"," -f1)" + +minor="$(/etc/init.d/oracleasm querydisk -d $ASM_disk | awk -F[ '{ print $2 }'| awk -F] '{ print $1 }' | cut -d"," -f2)" + +phy_disk="$(ls -l /dev/* | grep ^b | grep "$major, *$minor" | awk '{ print $10 }')" + +echo "ASM disk $ASM_disk is associated on $phy_disk [$major, $minor]" + +done < /tmp/asmdisks.txt +``` + +Set an executable permission to port_scan.sh file. + +``` +$ chmod +x asm_disk_mapping_1.sh +``` + +Finally run the script to achieve this. + +``` +# sh asm_disk_mapping_1.sh + +ASM disk MP4E6D_DATA01 is associated on /dev/dm-1 +3600a0123456789012345567890234q11 [253, 1] +ASM disk MP4E6E_DATA02 is associated on /dev/dm-2 +3600a0123456789012345567890234q12 [253, 2] +ASM disk MP4E6F_DATA03 is associated on /dev/dm-3 +3600a0123456789012345567890234q13 [253, 3] +ASM disk MP4E70_DATA04 is associated on /dev/dm-4 +3600a0123456789012345567890234q14 [253, 4] +ASM disk MP4E71_DATA05 is associated on /dev/dm-5 +3600a0123456789012345567890234q15 [253, 5] +ASM disk MP4E72_DATA06 is associated on /dev/dm-6 +3600a0123456789012345567890234q16 [253, 6] +ASM disk MP4E73_DATA07 is associated on /dev/dm-7 +3600a0123456789012345567890234q17 [253, 7] +``` + +### How To List Oracle ASM Disks? + +If you would like to list only Oracle ASM disk then use the below command to List available/created Oracle ASM disks in Linux. + +``` +# oracleasm listdisks + +ASM_Disk1 +ASM_Disk2 +ASM_Disk3 +ASM_Disk4 +ASM_Disk5 +ASM_Disk6 +ASM_Disk7 +``` + +### How To List Oracle ASM Disks Against Major And Minor Number? + +If you would like to map Oracle ASM disks against major and minor number then use the below commands to List available/created Oracle ASM disks in Linux. + +``` +# for ASMdisk in `oracleasm listdisks`; do /etc/init.d/oracleasm querydisk -d $ASMdisk; done + +Disk "ASM_Disk1" is a valid Disk on device [253, 1] +Disk "ASM_Disk2" is a valid Disk on device [253, 2] +Disk "ASM_Disk3" is a valid Disk on device [253, 3] +Disk "ASM_Disk4" is a valid Disk on device [253, 4] +Disk "ASM_Disk5" is a valid Disk on device [253, 5] +Disk "ASM_Disk6" is a valid Disk on device [253, 6] +Disk "ASM_Disk7" is a valid Disk on device [253, 7] +``` + +Alternatively, we can get the same results using the ls command. + +``` +# ls -lh /dev/oracleasm/disks + +total 0 +brw-rw---- 1 oracle oinstall 253, 1 May 19 14:44 ASM_Disk1 +brw-rw---- 1 oracle oinstall 253, 2 May 19 14:44 ASM_Disk2 +brw-rw---- 1 oracle oinstall 253, 3 May 19 14:44 ASM_Disk3 +brw-rw---- 1 oracle oinstall 253, 4 May 19 14:44 ASM_Disk4 +brw-rw---- 1 oracle oinstall 253, 5 May 19 14:44 ASM_Disk5 +brw-rw---- 1 oracle oinstall 253, 6 May 19 14:44 ASM_Disk6 +brw-rw---- 1 oracle oinstall 253, 7 May 19 14:44 ASM_Disk7 +``` + +### How To List Physical Disks Against LUNs? + +If you would like to map physical disks against LUNs then use the below command. + +``` +# multipath -ll | grep NETAPP + +3600a0123456789012345567890234q11 dm-1 NETAPP,LUN C-Mode +3600a0123456789012345567890234q12 dm-2 NETAPP,LUN C-Mode +3600a0123456789012345567890234q13 dm-3 NETAPP,LUN C-Mode +3600a0123456789012345567890234q14 dm-4 NETAPP,LUN C-Mode +3600a0123456789012345567890234q15 dm-5 NETAPP,LUN C-Mode +3600a0123456789012345567890234q16 dm-6 NETAPP,LUN C-Mode +3600a0123456789012345567890234q17 dm-7 NETAPP,LUN C-Mode +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/shell-script-map-oracle-asm-disks-physical-disk-lun-in-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/start-stop-restart-enable-reload-oracleasm-service-linux-create-scan-list-query-rename-delete-configure-oracleasm-disk/ diff --git a/sources/tech/20190521 How to Disable IPv6 on Ubuntu Linux.md b/sources/tech/20190521 How to Disable IPv6 on Ubuntu Linux.md new file mode 100644 index 0000000000..4420b034e6 --- /dev/null +++ b/sources/tech/20190521 How to Disable IPv6 on Ubuntu Linux.md @@ -0,0 +1,219 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Disable IPv6 on Ubuntu Linux) +[#]: via: (https://itsfoss.com/disable-ipv6-ubuntu-linux/) +[#]: author: (Sergiu https://itsfoss.com/author/sergiu/) + +How to Disable IPv6 on Ubuntu Linux +====== + +Are you looking for a way to **disable IPv6** connections on your Ubuntu machine? In this article, I’ll teach you exactly how to do it and why you would consider this option. I’ll also show you how to **enable or re-enable IPv6** in case you change your mind. + +### What is IPv6 and why would you want to disable IPv6 on Ubuntu? + +**[Internet Protocol version 6][1]** [(][1] **[IPv6][1]**[)][1] is the most recent version of the Internet Protocol (IP), the communications protocol that provides an identification and location system for computers on networks and routes traffic across the Internet. It was developed in 1998 to replace the **IPv4** protocol. + +**IPv6** aims to improve security and performance, while also making sure we don’t run out of addresses. It assigns unique addresses globally to every device, storing them in **128-bits** , compared to just 32-bits used by IPv4. + +![Disable IPv6 Ubuntu][2] + +Although the goal is for IPv4 to be replaced by IPv6, there is still a long way to go. Less than **30%** of the sites on the Internet makes IPv6 connectivity available to users (tracked by Google [here][3]). IPv6 can also cause [problems with some applications at time][4]. + +Since **VPNs** provide global services, the fact that IPv6 uses globally routed addresses (uniquely assigned) and that there (still) are ISPs that don’t offer IPv6 support shifts this feature lower down their priority list. This way, they can focus on what matters the most for VPN users: security. + +Another possible reason you might want to disable IPv6 on your system is not wanting to expose yourself to various threats. Although IPv6 itself is safer than IPv4, the risks I am referring to are of another nature. If you aren’t actively using IPv6 and its features, [having IPv6 enabled leaves you vulnerable to various attacks][5], offering the hacker another possible exploitable tool. + +On the same note, configuring basic network rules is not enough. You have to pay the same level of attention to tweaking your IPv6 configuration as you do for IPv4. This can prove to be quite a hassle to do (and also to maintain). With IPv6 comes a suite of problems different to those of IPv4 (many of which can be referenced online, given the age of this protocol), giving your system another layer of complexity. + +[][6] + +Suggested read How To Remove Drive Icons From Unity Launcher In Ubuntu 14.04 [Beginner Tips] + +### Disabling IPv6 on Ubuntu [For Advanced Users Only] + +In this section, I’ll be covering how you can disable IPv6 protocol on your Ubuntu machine. Open up a terminal ( **default:** CTRL+ALT+T) and let’s get to it! + +**Note:** _For most of the commands you are going to input in the terminal_ _you are going to need root privileges ( **sudo** )._ + +Warning! + +If you are a regular desktop Linux user and prefer a stable working system, please avoid this tutorial. This is for advanced users who know what they are doing and why they are doing so. + +#### 1\. Disable IPv6 using Sysctl + +First of all, you can **check** if you have IPv6 enabled with: + +``` +ip a +``` + +You should see an IPv6 address if it is enabled (the name of your internet card might be different): + +![IPv6 Address Ubuntu][7] + +You have see the sysctl command in the tutorial about [restarting network in Ubuntu][8]. We are going to use it here as well. To **disable IPv6** you only have to input 3 commands: + +``` +sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 +sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 +sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1 +``` + +You can check if it worked using: + +``` +ip a +``` + +You should see no IPv6 entry: + +![IPv6 Disabled Ubuntu][9] + +However, this only **temporarily disables IPv6**. The next time your system boots, IPv6 will be enabled again. + +One method to make this option persist is modifying **/etc/sysctl.conf**. I’ll be using vim to edit the file, but you can use any editor you like. Make sure you have **administrator rights** (use **sudo** ): + +![Sysctl Configuration][10] + +Add the following lines to the file: + +``` +net.ipv6.conf.all.disable_ipv6=1 +net.ipv6.conf.default.disable_ipv6=1 +net.ipv6.conf.lo.disable_ipv6=1 +``` + +For the settings to take effect use: + +``` +sudo sysctl -p +``` + +If IPv6 is still enabled after rebooting, you must create (with root privileges) the file **/etc/rc.local** and fill it with: + +``` +#!/bin/bash +# /etc/rc.local + +/etc/sysctl.d +/etc/init.d/procps restart + +exit 0 +``` + +Now use [chmod command][11] to make the file executable: + +``` +sudo chmod 755 /etc/rc.local +``` + +What this will do is manually read (during the boot time) the kernel parameters from your sysctl configuration file. + +[][12] + +Suggested read 3 Ways to Check Linux Kernel Version in Command Line + +#### 2\. Disable IPv6 using GRUB + +An alternative method is to configure **GRUB** to pass kernel parameters at boot time. You’ll have to edit **/etc/default/grub**. Once again, make sure you have administrator privileges: + +![GRUB Configuration][13] + +Now you need to modify **GRUB_CMDLINE_LINUX_DEFAULT** and **GRUB_CMDLINE_LINUX** to disable IPv6 on boot: + +``` +GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ipv6.disable=1" +GRUB_CMDLINE_LINUX="ipv6.disable=1" +``` + +Save the file and run: + +``` +sudo update-grub +``` + +The settings should now persist on reboot. + +### Re-enabling IPv6 on Ubuntu + +To re-enable IPv6, you’ll have to undo the changes you made. To enable IPv6 until reboot, enter: + +``` +sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 +sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0 +sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0 +``` + +Otherwise, if you modified **/etc/sysctl.conf** you can either remove the lines you added or change them to: + +``` +net.ipv6.conf.all.disable_ipv6=0 +net.ipv6.conf.default.disable_ipv6=0 +net.ipv6.conf.lo.disable_ipv6=0 +``` + +You can optionally reload these values: + +``` +sudo sysctl -p +``` + +You should once again see a IPv6 address: + +![IPv6 Reenabled in Ubuntu][14] + +Optionally, you can remove **/etc/rc.local** : + +``` +sudo rm /etc/rc.local +``` + +If you modified the kernel parameters in **/etc/default/grub** , go ahead and delete the added options: + +``` +GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" +GRUB_CMDLINE_LINUX="" +``` + +Now do: + +``` +sudo update-grub +``` + +**Wrapping Up** + +In this guide I provided you ways in which you can **disable IPv6** on Linux, as well as giving you an idea about what IPv6 is and why you would want to disable it. + +Did you find this article useful? Do you disable IPv6 connectivity? Let us know in the comment section! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/disable-ipv6-ubuntu-linux/ + +作者:[Sergiu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/sergiu/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/IPv6 +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/disable_ipv6_ubuntu.png?fit=800%2C450&ssl=1 +[3]: https://www.google.com/intl/en/ipv6/statistics.html +[4]: https://whatismyipaddress.com/ipv6-issues +[5]: https://www.internetsociety.org/blog/2015/01/ipv6-security-myth-1-im-not-running-ipv6-so-i-dont-have-to-worry/ +[6]: https://itsfoss.com/remove-drive-icons-from-unity-launcher-in-ubuntu/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/ipv6_address_ubuntu.png?fit=800%2C517&ssl=1 +[8]: https://itsfoss.com/restart-network-ubuntu/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/05/ipv6_disabled_ubuntu.png?fit=800%2C442&ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/05/sysctl_configuration.jpg?fit=800%2C554&ssl=1 +[11]: https://linuxhandbook.com/chmod-command/ +[12]: https://itsfoss.com/find-which-kernel-version-is-running-in-ubuntu/ +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/grub_configuration-1.jpg?fit=800%2C565&ssl=1 +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/ipv6_address_ubuntu-1.png?fit=800%2C517&ssl=1 diff --git a/sources/tech/20190521 I don-t know how CPUs work so I simulated one in code.md b/sources/tech/20190521 I don-t know how CPUs work so I simulated one in code.md new file mode 100644 index 0000000000..3b9be98d2f --- /dev/null +++ b/sources/tech/20190521 I don-t know how CPUs work so I simulated one in code.md @@ -0,0 +1,174 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (I don't know how CPUs work so I simulated one in code) +[#]: via: (https://djhworld.github.io/post/2019/05/21/i-dont-know-how-cpus-work-so-i-simulated-one-in-code/) +[#]: author: (daniel harper https://djhworld.github.io) + +I don't know how CPUs work so I simulated one in code +====== + +![][1] + +A few months ago it dawned on me that I didn’t really understand how computers work under the hood. I still don’t understand how modern computers work. + +However, after making my way through [But How Do It Know?][2] by J. Clark Scott, a book which describes the bits of a simple 8-bit computer from the NAND gates, through to the registers, RAM, bits of the CPU, ALU and I/O, I got a hankering to implement it in code. + +While I’m not that interested in the physics of the circuitry, the book just about skims the surface of those waters and gives a neat overview of the wiring and how bits move around the system without the requisite electrical engineering knowledge. For me though I can’t get comfortable with book descriptions, I have to see things in action and learn from my inevitable mistakes, which led me to chart a course on the rough seas of writing a circuit in code and getting a bit weepy about it. + +The fruits of my voyage can be seen in [simple-computer][3]; a simple computer that’s simple and computes things. + +[![][4]][5] [![][6]][7] [![][8]][9] +Example programs + +It is quite a neat little thing, the CPU code is implemented [as a horrific splurge of gates turning on and off][10] but it works, I’ve [unit tested it][11], and we all know unit tests are irrefutable proof that something works. + +It handles [keyboard inputs][12], and renders text [to a display][13] using a painstakingly crafted set of glyphs for a professional font I’ve named “Daniel Code Pro”. The only cheat bit is to get the keyboard input and display output working I had to hook up go channels to speak to the outside world via [GLFW][14], but the rest of it is a simulated circuit. + +I even wrote a [crude assembler][15] which was eye opening to say the least. It’s not perfect. Actually it’s a bit crap, but it highlighted to me the problems that other people have already solved many, many years ago and I think I’m a better person for it. Or worse, depending who you ask. + +### But why you do that? + +> “I’ve seen thirteen year old children do this in Minecraft, come back to me when you’ve built a REAL CPU out of telegraph relays” + +My mental model of computing is stuck in beginner computer science textbooks, and the CPU that powers the [gameboy emulator I wrote back in 2013][16] is really nothing like the CPUs that are running today. Even saying that, the emulator is just a state machine, it doesn’t describe the stuff at the logic gate level. You can implement most of it using just a `switch` statement and storing the state of the registers. + +So I’m trying to get a better understanding of this stuff because I don’t know what L1/L2 caches are, I don’t know what pipelining means, I’m not entirely sure I understand the Meltdown and Spectre vulnerability papers. Someone told me they were optimising their code to make use of CPU caches, I don’t know how to verify that other than taking their word for it. I’m not really sure what all the x86 instructions mean. I don’t understand how people off-load work to a GPU or TPU. I don’t know what a TPU is. I don’t know how to make use of SIMD instructions. + +But all that is built on a foundation of knowledge you need to earn your stripes for, so I ain’t gonna get there without reading the map first. Which means getting back to basics and getting my hands dirty with something simple. The “Scott Computer” described in the book is simple. That’s the reason. + +### Great Scott! It’s alive! + +The Scott computer is an 8-bit processor attached to 256 bytes of RAM, all connected via an 8-bit system bus. It has 4 general purpose registers and can execute [17 machine instructions][17]. Someone built a visual simulator [for the web here][18], which is really cool, I dread to think how long it took to track all the wiring states! + +[![][19]][20] +A diagram outlining all the components that make up the Scott CPU +Copyright © 2009 - 2016 by Siegbert Filbinger and John Clark Scott. + +The book takes you on a journey from the humble NAND gate, onto a Bit of memory, onto a register and then keeps layering on components until you end up with something resembling the above. I really recommend reading it, even if you are already familiar with the concepts because it’s quite a good overview. I don’t recommend the Kindle version though because the diagrams are sometimes hard to zoom in and decipher on a screen. A perennial problem for the Kindle in my experience. + +The only thing that’s different about my computer is I upgraded it to 16-bit to have more memory to play with, as storing even just the glyphs for the [ASCII table][21] would have dwarfed most of the 8-bit machine described in the book, with not much room left for useful code. + +### My development journey + +During development it really was just a case of reading the text, scouring the diagrams and then attempting to translate that using a general purpose programming language code and definitely not using something that’s designed for integrated circuit development. The reason why I wrote it in Go, is well, I know a bit of Go. Naysayers might chime in and say, you blithering idiot! I can’t believe you didn’t spend all your time learning [VHDL][22] or [Verilog][23] or [LogSim][24] or whatever but I’d already written my bits and bytes and NANDs by that point, I was in too deep. Maybe I’ll learn them next and weep about my time wasted, but that’s my cross to bear. + +In the grand scheme of things most of the computer is just passing around a bunch of booleans, so any boolean friendly language will do the job. + +Applying a schema to those booleans is what helps you (the programmer) derive its meaning, and the biggest decision anyone needs to make is decide what [endianness][25] your system is going to use and make sure all the components transfer things to and from the bus in the right order. + +This was an absolute pain in the backside to implement. From the offset I opted for little endian but when testing the ALU my hair took a beating trying to work out why the numbers were coming out wrong. Many, many print statements took place on this one. + +Development did take a while, maybe about a month or two during some of my free time, but once the CPU was done and successfully able to execute 2 + 2 = 5, I was happy. + +Well, until the book discussed the I/O features, with designs for a simple keyboard and display interface so you can get things in and out of the machine. Well I’ve already gotten this far, no point in leaving it in a half finished state. I set myself a goal of being able to type something on a keyboard and render the letters on a display. + +### Peripherals + +The peripherals use the [adapter pattern][26] to act as a hardware interface between the CPU and the outside world. It’s probably not a huge leap to guess this was what the software design pattern took inspiration from. + +![][27] +How the I/O adapters connect to a GLFW window + +With this separation of concerns it was actually pretty simple to hook the other end of the keyboard and display to a window managed by GLFW. In fact I just pulled most of the code from my [emulator][28] and reshaped it a bit, using go channels to act as the signals in and out of the machine. + +### Bringing it to life + +![][29] + +This was probably the most tricky part, or at least the most cumbersome. Writing assembly with such a limited instruction set sucks. Writing assembly using a crude assembler I wrote sucks even more because you can’t shake your fist at someone other than yourself. + +The biggest problem was juggling the 4 registers and keeping track of them, pulling and putting stuff in memory as a temporary store. Whilst doing this I remembered the Gameboy CPU having a stack pointer register so you could push and pop state. Unfortunately this computer doesn’t have such a luxury, so I was mostly moving stuff in and out of memory on a bespoke basis. + +The only pseudo instruction I took the time to implement was `CALL` to help calling functions, this allows you to run a function and then return to the point after the function was called. Without that stack though you can only call one level deep. + +Also as the machine does not support interrupts, you have to implement awful polling code for functions like getting keyboard state. The book does discuss the steps needed to implement interrupts, but it would involve a lot more wiring. + +But anyway enough of the moaning, I ended up writing [four programs][30] and most of them make use of some shared code for drawing fonts, getting keyboard input etc. Not exactly operating system material but it did make me appreciate some of the services a simple operating system might provide. + +It wasn’t easy though, the trickiest part of the text-writer program was getting the maths right to work out when to go to a newline, or what happens when you hit the enter key. + +``` +main-getInput: + CALL ROUTINE-io-pollKeyboard + CALL ROUTINE-io-drawFontCharacter + JMP main-getInput +``` + +The main loop for the text-writer program + +I didn’t get round to implementing the backspace key either, or any of the modifier keys. Made me appreciate how much work must go in to making text editors and how tedious that probably is. + +### On reflection + +This was a fun and very rewarding project for me. In the midst of programming in the assembly language I’d largely forgotten about the NAND, AND and OR gates firing underneath. I’d ascended into the layers of abstraction above. + +While the CPU in the is very simple and a long way from what’s sitting in my laptop, I think this project has taught me a lot, namely: + + * How bits move around between all components using a bus + * How a simple ALU works + * What a simple Fetch-Decode-Execute cycle looks like + * That a machine without a stack pointer register + concept of a stack sucks + * That a machine without interrupts sucks + * What an assembler is and does + * How a peripherals communicate with a simple CPU + * How simple fonts work and an approach to rendering them on a display + * What a simple operating system might start to look like + + + +So what’s next? The book said that no-one has built a computer like this since 1952, meaning I’ve got 67 years of material to brush up on, so that should keep me occupied for a while. I see the [x86 manual is 4800 pages long][31], enough for some fun, light reading at bedtime. + +Maybe I’ll have a brief dalliance with operating system stuff, a flirtation with the C language, a regrettable evening attempting to [solder up a PiDP-11 kit][32] then probably call it quits. I dunno, we’ll see. + +With all seriousness though I think I’m going to start looking into RISC based stuff next, maybe RISC-V, but probably start with early RISC processors to get an understanding of the lineage. Modern CPUs have a lot more features like caches and stuff so I want to understand them as well. A lot of stuff out there to learn. + +Do I need to know any of this stuff in my day job? Probably helps, but not really, but I’m enjoying it, so whatever, thanks for reading xxxx + +-------------------------------------------------------------------------------- + +via: https://djhworld.github.io/post/2019/05/21/i-dont-know-how-cpus-work-so-i-simulated-one-in-code/ + +作者:[daniel harper][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://djhworld.github.io +[b]: https://github.com/lujun9972 +[1]: https://djhworld.github.io/img/simple-computer/text-writer.gif (Hello World) +[2]: http://buthowdoitknow.com/ +[3]: https://github.com/djhworld/simple-computer +[4]: https://djhworld.github.io/img/simple-computer/ascii1.png (ASCII) +[5]: https://djhworld.github.io/img/simple-computer/ascii.png +[6]: https://djhworld.github.io/img/simple-computer/brush1.png (brush) +[7]: https://djhworld.github.io/img/simple-computer/brush.png +[8]: https://djhworld.github.io/img/simple-computer/text-writer1.png (doing the typesin') +[9]: https://djhworld.github.io/img/simple-computer/text-writer.png +[10]: https://github.com/djhworld/simple-computer/blob/master/cpu/cpu.go#L763 +[11]: https://github.com/djhworld/simple-computer/blob/master/cpu/cpu_test.go +[12]: https://github.com/djhworld/simple-computer/blob/master/io/keyboard.go#L20 +[13]: https://github.com/djhworld/simple-computer/blob/master/io/display.go#L13 +[14]: https://github.com/djhworld/simple-computer/blob/master/cmd/simulator/glfw_io.go +[15]: https://github.com/djhworld/simple-computer/blob/master/asm/assembler.go +[16]: https://github.com/djhworld/gomeboycolor +[17]: https://github.com/djhworld/simple-computer#instructions +[18]: http://www.buthowdoitknow.com/but_how_do_it_know_cpu_model.html +[19]: https://djhworld.github.io/img/simple-computer/scott-cpu.png (The Scott CPU) +[20]: https://djhworld.github.io/img/simple-computer/scott-cpu.png +[21]: https://github.com/djhworld/simple-computer/blob/master/_programs/ascii.asm#L27 +[22]: https://en.wikipedia.org/wiki/VHDL +[23]: https://en.wikipedia.org/wiki/Verilog +[24]: http://www.cburch.com/logisim/ +[25]: https://en.wikipedia.org/wiki/Endianness +[26]: https://en.wikipedia.org/wiki/Adapter_pattern +[27]: https://djhworld.github.io/img/simple-computer/io.png (i couldn't be bothered to do the corners around the CPU for the system bus) +[28]: https://github.com/djhworld/gomeboycolor-glfw +[29]: https://djhworld.github.io/img/simple-computer/brush.gif (brush.bin) +[30]: https://github.com/djhworld/simple-computer/blob/master/_programs/README.md +[31]: https://software.intel.com/sites/default/files/managed/39/c5/325462-sdm-vol-1-2abcd-3abcd.pdf +[32]: https://obsolescence.wixsite.com/obsolescence/pidp-11 diff --git a/sources/tech/20190522 Damn- Antergos Linux has been Discontinued.md b/sources/tech/20190522 Damn- Antergos Linux has been Discontinued.md new file mode 100644 index 0000000000..38c11508bf --- /dev/null +++ b/sources/tech/20190522 Damn- Antergos Linux has been Discontinued.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Damn! Antergos Linux has been Discontinued) +[#]: via: (https://itsfoss.com/antergos-linux-discontinued/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Damn! Antergos Linux has been Discontinued +====== + +_**Beginner-friendly Arch Linux based distribution Antergos has announced that the project is being discontinued.**_ + +Arch Linux has always been considered a no-go zone for the beginners. Antergos challenged this status quo and made Arch Linux accessible to everyone by providing easier installation method. People who wouldn’t dare [installing Arch Linux][1], opted for Antergos. + +![Antergos provided easy access to Arch with its easy to use GUI tools][2] + +The project started in 2012-13 and started gaining popularity around 2014. I used Antergos, liked it and covered it here on It’s FOSS and perhaps (slightly) contributed to its popularity. In last five years, Antergos was downloaded close to a million times. + +But for past year or so, I felt that this project was stagnating. Antergos hardly made any news. Neither the forum nor the social media handles were active. The community around Antergos grew thinner though a few dedicated users still remain. + +### The end of Antergos Linux project + +![][3] + +On May 21, 2019, Antergos [announced][4] its discontinuation. Lack of free time cited as the main reason behind this decision. + +> Today, we are announcing the end of this project. As many of you probably noticed over the past several months, we no longer have enough free time to properly maintain Antergos. We came to this decision because we believe that continuing to neglect the project would be a huge disservice to the community. +> +> Antergos Team + +Antergos developers also mentioned that since the project’s code still works, it’s an opportunity for interested developers to take what they find useful and start their own projects. + +#### What happens to Existing Antergos users? + +If you are an Antergos user, you don’t have to worry a lot. It’s not that your system will be unusable from today. Your system will continue to get updates directly from Arch Linux. + +Antergos team plans to release an update to remove the Antergos repositories from your system along with any Antergos-specific packages that no longer serve a purpose as the project is ending. After that any packages installed from the Antergos repo that are in the AUR will begin to receive updates from [AUR][5]. + +[][6] + +Suggested read Peppermint 8 Released. Download Now! + +The Antergos forum and wiki will be functional but only for some time. + +If you think using an ‘unmaintained’ project is not a good idea, you should switch your distribution. The most appropriate choice would be [Manjaro Linux][7]. + +Manjaro Linux started around the same time as Antergos. Both Antergos and Manjaro were sort of competitors as both of them tried to make Arch Linux accessible for everyone. + +Manjaro gained a huge userbase in the last few years and its community is thriving. If you want to remain in Arch domain but don’t want to install Arch Linux itself, Manjaro is the best choice for you. + +Just note that Manjaro Linux doesn’t provide all the updates immediately as Arch or Antergos. It is a rolling release but with stability in mind. So the updates are tested first. + +#### Inevitable fate for smaller distributions? + +_Here’s my opinion on the discontinuation on Antergos and other similar open source projects._ + +Antergos was a niche distribution. It had a smaller but dedicated userbase. The developers cited lack of free time as the main reason for their decision. However, I believe that lack of motivation plays a bigger role in such cases. + +What motivates the people behind a project? They start it mostly as a side project and if the project is good, they start gaining users. This growth of userbase drives their motivation to work on the project. + +If the userbase starts declining or gets stagnated, the motivation takes a hit. + +If the userbase keeps on growing, the motivation increases but only to a certain point. More users require more effort in various tasks around the project. Keeping the wiki and forum along with social media itself is a challenging part, leave aside the actual code development. The situation becomes overwhelming. + +When a project grows in considerable size, project owners have two choices. First choice is to form a community of volunteers and start delegating tasks that could be delegated. Having volunteers dedicated to project is not easy but it can surely be achieved as Debian and Manjaro have done it already. + +[][8] + +Suggested read Lightweight Distribution Linux Lite 4.0 Released With Brand New Look + +Second choice is to create some revenue generation channel around the project. The additional revenue may ‘justify’ those extra hours and in some cases, it could drive the developer to work full time on the project. [elementary OS][9] is trying to achieve something similar by developing an ecosystem of ‘payable apps’ in their software center. + +You may argue that money should not be a factor in Free and Open Source Software culture but the unfortunate truth is that money is always a factor, in every aspect of our life. I am not saying that a project should be purely driven by money but a project must be sustainable in every aspect. + +We have see how other smaller but moderately popular Linux distributions like Korora has been discontinued due to lack of free time. [Solus creator Ikey Doherty had to leave the project][10] to focus on his personal life. Developing and maintaining a successful open source project is not an easy task. + +That’s just my opinion. Please feel free to disagree with it and voice your opinion in the comment section. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/antergos-linux-discontinued/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/install-arch-linux/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2015/08/Installing_Antergos_Linux_7.png?ssl=1 +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/05/antergos-linux-dead.jpg?resize=800%2C450&ssl=1 +[4]: https://antergos.com/blog/antergos-linux-project-ends/ +[5]: https://itsfoss.com/best-aur-helpers/ +[6]: https://itsfoss.com/peppermint-8-released/ +[7]: https://manjaro.org/ +[8]: https://itsfoss.com/linux-lite-4/ +[9]: https://elementary.io/ +[10]: https://itsfoss.com/ikey-leaves-solus/ diff --git a/sources/tech/20190522 How to Download and Use Ansible Galaxy Roles in Ansible Playbook.md b/sources/tech/20190522 How to Download and Use Ansible Galaxy Roles in Ansible Playbook.md new file mode 100644 index 0000000000..3bb9e39184 --- /dev/null +++ b/sources/tech/20190522 How to Download and Use Ansible Galaxy Roles in Ansible Playbook.md @@ -0,0 +1,193 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Download and Use Ansible Galaxy Roles in Ansible Playbook) +[#]: via: (https://www.linuxtechi.com/use-ansible-galaxy-roles-ansible-playbook/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +How to Download and Use Ansible Galaxy Roles in Ansible Playbook +====== + +**Ansible** is tool of choice these days if you must manage multiple devices, be it Linux, Windows, Mac, Network Devices, VMware and lot more. What makes Ansible popular is its agent less feature and granular control. If you have worked with python or have experience with **yaml** , you will feel at home with Ansible. To see how you can install [Ansible][1] click here. + + + +Ansible core modules will let you manage almost anything should you wish to write playbooks, however often there is someone who has already written a role for a problem you are trying to solve. Let’s take an example, you wish to manage NTP clients on the Linux machines, you have 2 choices either write a role which can be applied to the nodes or use **ansible-galaxy** to download an existing role someone has already written/tested for you. Ansible galaxy has roles for almost all the domains and these caters different problems. You can visit to get an idea on domains and popular roles it has. Each role published on galaxy repository is thoroughly tested and has been rated by the users, so you get an idea on how other people who have used it liked it. + +To keep moving with the NTP idea, here is how you can search and install an NTP role from galaxy. + +Firstly, lets run ansible-galaxy with the help flag to check what options does it give us + +``` +[root@linuxtechi ~]# ansible-galaxy --help +``` + +![ansible-galaxy-help][2] + +As you can see from the output above there are some interesting options been shown, since we are looking for a role to manage ntp clients lets try the search option to see how good it is finding what we are looking for. + +``` +[root@linuxtechi ~]# ansible-galaxy search ntp +``` + +Here is the truncated output of the command above. + +![ansible-galaxy-search][3] + +It found 341 matches based on our search, as you can see from the output above many of these roles are not even related to NTP which means our search needs some refinement however, it has managed to pull some NTP roles, lets dig deeper to see what these roles are. But before that let me tell you the naming convention being followed here. The name of a role is always preceded by the author name so that it is easy to segregate roles with the same name. So, if you have written an NTP role and have published it to galaxy repo, it does not get mixed up with someone else repo with the same name. + +With that out of the way, lets continue with our job of installing a NTP role for our Linux machines. Let’s try **bennojoy.ntp** for this example, but before using this we need to figure out couple of things, is this role compatible with the version of ansible I am running. Also, what is the license status of this role. To figure out these, let’s run below ansible-galaxy command, + +``` +[root@linuxtechi ~]# ansible-galaxy info bennojoy.ntp +``` + +![ansible-galaxy-info][4] + +ok so this says the minimum version is 1.4 and the license is BSD, lets download it + +``` +[root@linuxtechi ~]# ansible-galaxy install bennojoy.ntp +- downloading role 'ntp', owned by bennojoy +- downloading role from https://github.com/bennojoy/ntp/archive/master.tar.gz +- extracting bennojoy.ntp to /etc/ansible/roles/bennojoy.ntp +- bennojoy.ntp (master) was installed successfully +[root@linuxtechi ~]# ansible-galaxy list +- bennojoy.ntp, master +[root@linuxtechi ~]# +``` + +Let’s find the newly installed role. + +``` +[root@linuxtechi ~]# cd /etc/ansible/roles/bennojoy.ntp/ +[root@linuxtechi bennojoy.ntp]# ls -l +total 4 +drwxr-xr-x. 2 root root 21 May 21 22:38 defaults +drwxr-xr-x. 2 root root 21 May 21 22:38 handlers +drwxr-xr-x. 2 root root 48 May 21 22:38 meta +-rw-rw-r--. 1 root root 1328 Apr 20 2016 README.md +drwxr-xr-x. 2 root root 21 May 21 22:38 tasks +drwxr-xr-x. 2 root root 24 May 21 22:38 templates +drwxr-xr-x. 2 root root 55 May 21 22:38 vars +[root@linuxtechi bennojoy.ntp]# +``` + +I am going to run this newly downloaded role on my Elasticsearch CentOS node. Here is my hosts file + +``` +[root@linuxtechi ~]# cat hosts +[CentOS] +elastic7-01 ansible_host=192.168.1.15 ansibel_port=22 ansible_user=linuxtechi +[root@linuxtechi ~]# +``` + +Let’s try to ping the node using below ansible ping module, + +``` +[root@linuxtechi ~]# ansible -m ping -i hosts elastic7-01 +elastic7-01 | SUCCESS => { + "changed": false, + "ping": "pong" +} +[root@linuxtechi ~]# +``` + +Here is what the current ntp.conf looks like on elastic node. + +``` +[root@linuxtechi ~]# head -30 /etc/ntp.conf +``` + +![Current-ntp-conf][5] + +Since I am in India, lets add server **in.pool.ntp.org** to ntp.conf. I would have to edit the variables in default directory of the role. + +``` +[root@linuxtechi ~]# vi /etc/ansible/roles/bennojoy.ntp/defaults/main.yml +``` + +Change NTP server address in “ntp_server” parameter, after updating it should look like below. + +![Update-ansible-ntp-role][6] + +The last thing now is to create my playbook which would call this role. + +``` +[root@linuxtechi ~]# vi ntpsite.yaml +--- + - name: Configure NTP on CentOS/RHEL/Debian System + become: true + hosts: all + roles: + - {role: bennojoy.ntp} +``` + +save and exit the file + +We are ready to run this role now, use below command to run ntp playbook, + +``` +[root@linuxtechi ~]# ansible-playbook -i hosts ntpsite.yaml +``` + +Output of above ntp ansible playbook should be something like below, + +![ansible-playbook-output][7] + +Let’s check updated file now. go to elastic node and view the contents of ntp.conf file + +``` +[root@linuxtechi ~]# cat /etc/ntp.conf +#Ansible managed + +driftfile /var/lib/ntp/drift +server in.pool.ntp.org + +restrict -4 default kod notrap nomodify nopeer noquery +restrict -6 default kod notrap nomodify nopeer noquery +restrict 127.0.0.1 +[root@linuxtechi ~]# +``` + +Just in case you do not find a role fulfilling your requirement ansible-galaxy can help you create a directory structure for your custom roles. This helps your playbooks along with the variables, handlers, templates etc assembled in a standardized file structure. Let’s create our own role, its always a good practice to let ansible-galaxy create the structure for you. + +``` +[root@linuxtechi ~]# ansible-galaxy init pk.backup +- pk.backup was created successfully +[root@linuxtechi ~]# +``` + +Verify the structure of your role using the tree command, + +![createing-roles-ansible-galaxy][8] + +Let me quickly explain what each of these directories and files are for, each of these serves a purpose. + +The very first one is the **defaults** directory which contains the files containing variables with takes the lowest precedence, if the same variables are assigned in var directory it will be take precedence over default. The **handlers** directory hosts the handlers. The **file** and **templates** keep any files your role may need to copy and **jinja templates** to be used in playbooks respectively. The **tasks** directory is where your playbooks containing the tasks are kept. The var directory consists of all the files that hosts the variables used in role. The test directory consists of a sample inventory and test playbooks which can be used to test the role. The **meta directory** consists of any dependencies on other roles along with the authorship information. + +Finally, **README.md** file simply consists of some general information like description and minimum version of ansible this role is compatible with. + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/use-ansible-galaxy-roles-ansible-playbook/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/install-and-use-ansible-in-centos-7/ +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/05/ansible-galaxy-help-1024x294.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/05/ansible-galaxy-search-1024x552.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/05/ansible-galaxy-info-1024x557.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Current-ntp-conf.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/05/Update-ansible-ntp-role.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/05/ansible-playbook-output-1024x376.jpg +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/05/createing-roles-ansible-galaxy.jpg diff --git a/sources/tech/20190523 Hardware bootstrapping with Ansible.md b/sources/tech/20190523 Hardware bootstrapping with Ansible.md new file mode 100644 index 0000000000..94842453cc --- /dev/null +++ b/sources/tech/20190523 Hardware bootstrapping with Ansible.md @@ -0,0 +1,223 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Hardware bootstrapping with Ansible) +[#]: via: (https://opensource.com/article/19/5/hardware-bootstrapping-ansible) +[#]: author: (Mark Phillips https://opensource.com/users/markp/users/feeble/users/markp) + +Hardware bootstrapping with Ansible +====== + +![computer servers processing data][1] + +At a recent [Ansible London Meetup][2], I got chatting with somebody about automated hardware builds. _"It's all cloud now!"_ I hear you say. Ah, but for many large organisations it's not—they still have massive data centres full of hardware. Almost regularly somebody pops up on our internal mail list and asks, *"can Ansible do hardware provisioning?" *Well yes, you can provision hardware with Ansible… + +### Requirements + +Bootstrapping hardware is mostly about network services. Before we do any operating system (OS) installing then, we must set up some services. We will need: + + * DHCP + * PXE + * TFTP + * Operating system media + * Web server + + + +### Setup + +Besides the DHCP configuration, everything else in this article is handled by the Ansible plays included in [this repository][3]. + +#### DHCP server + +I'm writing here on the assumption you can control your DHCP configuration. If you don't have access to your DHCP server, you'll need to ask the owner to set two options. DHCP option 67 needs to be set to **pxelinux.0** and **next-server** (which is option 66—but you may not need to know that; often a DHCP server will have a field/option for 'next server') needs to be set to the IP address of your TFTP server. + +If you can own the DHCP server, I'd suggest using dnsmasq. It's small and simple. I will not cover configuring it here, but look at [the man page][4] and the **\--enable-tftp** option. + +#### TFTP + +The **next-server** setting for our DHCP server, above, will point to a machine serving [TFTP][5]. Here I've used a [CentOS Linux][6] virtual machine, as it only takes one package (syslinux-tftpboot) and a service to start to have TFTP up and running. We'll stick with the default path, **/var/lib/tftpboot**. + +#### PXE + +If you're not already familiar with PXE, you might like to take a quick look at [the Wikipedia page][7]. For this article I'll keep it short—we will serve some files over TFTP, which DHCP guides our hardware to. + +You'll want **images/pxeboot/{initrd.img,vmlinuz}** from the OS distribution media for pxeboot. These need to be copied to **/var/lib/tftpboot/pxeboot**. The referenced Ansible plays **do not do this step, **so you need to copy them over yourself. + +We'll also need to serve the OS installation files. There are two approaches to this: 1) install, via HTTP, from the internet or 2) install, again via HTTP, from a local server. For my testing, since I'm on a private LAN (and I guess you are too), the fastest installation method is the second. The easiest way to prepare this is to mount the DVD image and rsync the `images`, **`Packages` **and `repodata` directories to your webserver location. The referenced Ansible plays will install **httpd** but won't copy over these files, so don't forget to do that after running [the play][8]. For this article, we'll once again stick with defaults for simplicity—so files need to be copied to Apache's standard docroot, **/var/www/html**. + +#### Directories + +We should end up with directory structures like this: + +##### PXE/TFTP + + +``` +[root@c7 ~]# tree /var/lib/tftpboot/pxe{b*,l*cfg} +/var/lib/tftpboot/pxeboot +└── 6 +├── initrd.img +└── vmlinuz +``` + +##### httpd + + +``` +[root@c7 ~]# tree -d /var/www/html/ +/var/www/html/ +├── 6 -> centos/6 +├── 7 -> centos/7 +├── centos +│ ├── 6 +│ │ └── os +│ │ └── x86_64 +│ │ ├── images +│ │ │ └── pxeboot +│ │ ├── Packages +│ │ └── repodata +│ └── 7 +│ └── os +│ └── x86_64 +│ ├── images +│ │ └── pxeboot +│ ├── Packages +│ └── repodata +└── ks +``` + +You'll notice my web setup appears a little less simple than the words above! I've pasted my actual structure to give you some ideas. The hardware I'm using is really old, and even getting CentOS 7 to work was horrible (if you're interested, it's due to the lack of [cciss][9] drivers for the HP Smart Array controller—yes, [there is an answer][10], but it takes a lot of faffing to make work), so all examples are of CentOS 6. I also wanted a flexible setup that could install many versions. Here I've done that using symlinks—this arrangement will work just fine for RHEL too, for example. The basic structure is present though—note the images, Packages and repodata directories. + +These paths relate directly to [the PXE menu][11] file we'll serve up and [the kickstart file][12] too. + +#### If you don't have DHCP + +If you can't manage your own DHCP server or the owners of your infrastructure can't help, there is another option. In the past, I've used [iPXE][13] to create a boot image that I've loaded as virtual media. A lot of out-of-band/lights-out-management (LOM) interfaces on modern hardware support this functionality. You can make a custom embedded PXE menu in seconds with iPXE. I won't cover that here, but if it turns out to be a problem for you, then drop me a line [on Twitter][14] and I'll look at doing a follow-up blog post if enough people request it. + +### Installing hardware + +We've got our structure in place now, and we can [kickstart][15] a server. Before we do, we have to add some configuration to the TFTP setup to enable a given piece of hardware to pick up the PXE boot menu. + +It's here we come across a small chicken/egg problem. We need a host's MAC address to create a link to the specific piece of hardware we want to kickstart. If the hardware is already running and we can access it with Ansible, that's great—we have a way of finding out the boot interface MAC address via the setup module (see [the reinstall play][16]). If it's a new piece of tin, however, we need to get the MAC address and tell our setup what to do with it. This probably means some manual intervention—booting the server and looking at a screen or maybe getting the MAC from a manifest or such like. Whichever way you get hold of it, we can tell our play about it via the inventory. + +Let's put a custom variable into our simple INI format [inventory file][17], but run a play to set up TFTP… + + +``` +(pip)iMac:ansible-hw-bootstrap$ ansible-inventory --host hp.box +{ +"ilo_ip": "192.168.1.68", +"ilo_password": "administrator" +} +(pip)iMac:ansible-hw-bootstrap$ ansible-playbook plays/install.yml + +PLAY [kickstart] ******************************************************************************************************* + +TASK [Host inventory entry has a MAC address] ************************************************************************** +failed: [ks.box] (item=hp.box) => { +"assertion": "hostvars[item]['mac'] is defined", +"changed": false, +"evaluated_to": false, +"item": "hp.box", +"msg": "Assertion failed" +} + +PLAY RECAP ************************************************************************************************************* +ks.box : ok=0 changed=0 unreachable=0 failed=1 +``` + +Uh oh, play failed. It [contains a check][18] that the host we're about to install actually has a MAC address added. Let's fix that and run the play again… + + +``` +(pip)iMac:ansible-hw-bootstrap$ ansible-inventory --host hp.box +{ +"ilo_ip": "192.168.1.68", +"ilo_password": "administrator", +"mac": "00:AA:BB:CC:DD:EE" +} +(pip)iMac:ansible-hw-bootstrap$ ansible-playbook plays/install.yml + +PLAY [kickstart] ******************************************************************************************************* + +TASK [Host inventory entry has a MAC address] ************************************************************************** +ok: [ks.box] => (item=hp.box) => { +"changed": false, +"item": "hp.box", +"msg": "All assertions passed" +} + +TASK [Set PXE menu to install] ***************************************************************************************** +ok: [ks.box] => (item=hp.box) + +TASK [Reboot target host for PXE boot] ********************************************************************************* +skipping: [ks.box] => (item=hp.box) + +PLAY RECAP ************************************************************************************************************* +ks.box : ok=2 changed=0 unreachable=0 failed=0 +``` + +That worked! What did it do? Looking at the pxelinux.cfg directory under our TFTP root, we can see a symlink… + + +``` +[root@c7 pxelinux.cfg]# pwd +/var/lib/tftpboot/pxelinux.cfg +[root@c7 pxelinux.cfg]# l +total 12 +drwxr-xr-x. 2 root root 65 May 13 14:23 ./ +drwxr-xr-x. 4 root root 4096 May 2 22:13 ../ +-r--r--r--. 1 root root 515 May 2 12:22 00README +lrwxrwxrwx. 1 root root 7 May 13 14:12 01-00-aa-bb-cc-dd-ee -> install +-rw-r--r--. 1 root root 682 May 2 22:07 install +``` + +The **install** file is symlinked to a file named after our MAC address. This is the key, useful piece. It will ensure our hardware with MAC address **00-aa-bb-cc-dd-ee** is served a PXE menu when it boots from its network card. + +So let's boot our machine. + +Usefully, Ansible has some [remote management modules][19]. We're working with an HP server here, so we can use the [hpilo_boot][20] module to save us from having to interact directly with the LOM web interface. + +Let's run the reinstall play on a booted server… + +The neat thing about the **hpilo_boot** module, you'll notice, is it sets the boot medium to be the network. When the installation completes, the server restarts and boots from its hard drive. The eagle-eyed amongst you will have spotted the critical problem with this—what happens if the server boots to its network card again? It will pick up the PXE menu and promptly reinstall itself. I would suggest removing the symlink as a "belt and braces" step then. I will leave that as an exercise for you, dear reader. Hint: I would make the new server do a 'phone home' on boot, to somewhere, which runs a clean-up job. Since you wouldn't need the console open, as I had here to demonstrate what's going on in the background, a 'phone home' job would also give a nice indication that the process completed. Ansible, [naturally][21]. Good luck! + +If you've any thoughts or comments on this process, please let me know. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/hardware-bootstrapping-ansible + +作者:[Mark Phillips][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/markp/users/feeble/users/markp +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/server_data_system_admin.png?itok=q6HCfNQ8 (computer servers processing data) +[2]: https://www.meetup.com/Ansible-London/ +[3]: https://github.com/phips/ansible-hw-bootstrap +[4]: http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html +[5]: https://en.m.wikipedia.org/wiki/Trivial_File_Transfer_Protocol +[6]: https://www.centos.org +[7]: https://en.m.wikipedia.org/wiki/Preboot_Execution_Environment +[8]: https://github.com/phips/ansible-hw-bootstrap/blob/master/plays/kickstart.yml +[9]: https://linux.die.net/man/4/cciss +[10]: https://serverfault.com/questions/611182/centos-7-x64-and-hp-proliant-dl360-g5-scsi-controller-compatibility +[11]: https://github.com/phips/ansible-hw-bootstrap/blob/master/roles/kickstart/templates/pxe_install.j2#L10 +[12]: https://github.com/phips/ansible-hw-bootstrap/blob/master/roles/kickstart/templates/local6.ks.j2#L3 +[13]: https://ipxe.org +[14]: https://twitter.com/thismarkp +[15]: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/installation_guide/ch-kickstart2 +[16]: https://github.com/phips/ansible-hw-bootstrap/blob/master/plays/reinstall.yml +[17]: https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html +[18]: https://github.com/phips/ansible-hw-bootstrap/blob/master/plays/install.yml#L9 +[19]: https://docs.ansible.com/ansible/latest/modules/list_of_remote_management_modules.html +[20]: https://docs.ansible.com/ansible/latest/modules/hpilo_boot_module.html#hpilo-boot-module +[21]: https://github.com/phips/ansible-demos/tree/master/roles/phone_home diff --git a/sources/tech/20190523 Run your blog on GitHub Pages with Python.md b/sources/tech/20190523 Run your blog on GitHub Pages with Python.md new file mode 100644 index 0000000000..1e3634a327 --- /dev/null +++ b/sources/tech/20190523 Run your blog on GitHub Pages with Python.md @@ -0,0 +1,235 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Run your blog on GitHub Pages with Python) +[#]: via: (https://opensource.com/article/19/5/run-your-blog-github-pages-python) +[#]: author: (Erik O'Shaughnessy https://opensource.com/users/jnyjny/users/jasperzanjani/users/jasperzanjani/users/jasperzanjani/users/jnyjny/users/jasperzanjani) + +Run your blog on GitHub Pages with Python +====== +Create a blog with Pelican, a Python-based blogging platform that works +well with GitHub. +![Raspberry Pi and Python][1] + +[GitHub][2] is a hugely popular web service for source code control that uses [Git][3] to synchronize local files with copies kept on GitHub's servers so you can easily share and back up your work. + +In addition to providing a user interface for code repositories, GitHub also enables users to [publish web pages][4] directly from a repository. The website generation package GitHub recommends is [Jekyll][5], written in Ruby. Since I'm a bigger fan of [Python][6], I prefer [Pelican][7], a Python-based blogging platform that works well with GitHub. + +Pelican and Jekyll both transform content written in [Markdown][8] or [reStructuredText][9] into HTML to generate static websites, and both generators support themes that allow unlimited customization. + +In this article, I'll describe how to install Pelican, set up your GitHub repository, run a quickstart helper, write some Markdown files, and publish your first page. I'll assume that you have a [GitHub account][10], are comfortable with [basic Git commands][11], and want to publish a blog using Pelican. + +### Install Pelican and create the repo + +First things first, Pelican (and **ghp-import** ) must be installed on your local machine. This is super easy with [pip][12], the Python package installation tool (you have pip right?): + + +``` +`$ pip install pelican ghp-import` +``` + +Next, open a browser and create a new repository on GitHub for your sweet new blog. Name it as follows (substituting your GitHub username for here and throughout this tutorial): + + +``` +`https://GitHub.com/username/username.github.io` +``` + +Leave it empty; we will fill it with compelling blog content in a moment. + +Using a command line (you command line right?), clone your empty Git repository to your local machine: + + +``` +$ git clone blog +$ cd blog +``` + +### That one weird trick… + +Here's a not-super-obvious trick about publishing web content on GitHub. For user pages (pages hosted in repos named _username.github.io_ ), the content is served from the **master** branch. + +I strongly prefer not to keep all the Pelican configuration files and raw Markdown files in **master** , rather just the web content. So I keep the Pelican configuration and the raw content in a separate branch I like to call **content**. (You can call it whatever you want, but the following instructions will call it **content**.) I like this structure since I can throw away all the files in **master** and re-populate it with the **content** branch. + + +``` +$ git checkout -b content +Switched to a new branch 'content' +``` + +### Configure Pelican + +Now it's time for content configuration. Pelican provides a great initialization tool called **pelican-quickstart** that will ask you a series of questions about your blog. + + +``` +$ pelican-quickstart +Welcome to pelican-quickstart v3.7.1. + +This script will help you create a new Pelican-based website. + +Please answer the following questions so this script can generate the files +needed by Pelican. + +> Where do you want to create your new web site? [.] +> What will be the title of this web site? Super blog +> Who will be the author of this web site? username +> What will be the default language of this web site? [en] +> Do you want to specify a URL prefix? e.g., (Y/n) n +> Do you want to enable article pagination? (Y/n) +> How many articles per page do you want? [10] +> What is your time zone? [Europe/Paris] US/Central +> Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n) y +> Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n) y +> Do you want to upload your website using FTP? (y/N) n +> Do you want to upload your website using SSH? (y/N) n +> Do you want to upload your website using Dropbox? (y/N) n +> Do you want to upload your website using S3? (y/N) n +> Do you want to upload your website using Rackspace Cloud Files? (y/N) n +> Do you want to upload your website using GitHub Pages? (y/N) y +> Is this your personal page (username.github.io)? (y/N) y +Done. Your new project is available at /Users/username/blog +``` + +You can take the defaults on every question except: + + * Website title, which should be unique and special + * Website author, which can be a personal username or your full name + * Time zone, which may not be in Paris + * Upload to GitHub Pages, which is a "y" in our case + + + +After answering all the questions, Pelican leaves the following in the current directory: + + +``` +$ ls +Makefile content/ develop_server.sh* +fabfile.py output/ pelicanconf.py +publishconf.py +``` + +You can check out the [Pelican docs][13] to find out how to use those files, but we're all about getting things done _right now_. No, I haven't read the docs yet either. + +### Forge on + +Add all the Pelican-generated files to the **content** branch of the local Git repo, commit the changes, and push the local changes to the remote repo hosted on GitHub by entering: + + +``` +$ git add . +$ git commit -m 'initial pelican commit to content' +$ git push origin content +``` + +This isn't super exciting, but it will be handy if we need to revert edits to one of these files. + +### Finally getting somewhere + +OK, now you can get bloggy! All of your blog posts, photos, images, PDFs, etc., will live in the **content** directory, which is initially empty. To begin creating a first post and an About page with a photo, enter: + + +``` +$ cd content +$ mkdir pages images +$ cp /Users/username/SecretStash/HotPhotoOfMe.jpg images +$ touch first-post.md +$ touch pages/about.md +``` + +Next, open the empty file **first-post.md** in your favorite text editor and add the following: + + +``` +title: First Post on My Sweet New Blog +date: +author: Your Name Here + +# I am On My Way To Internet Fame and Fortune! + +This is my first post on my new blog. While not super informative it +should convey my sense of excitement and eagerness to engage with you, +the reader! +``` + +The first three lines contain metadata that Pelican uses to organize things. There are lots of different metadata you can put there; again, the docs are your best bet for learning more about the options. + +Now, open the empty file **pages/about.md** and add this text: + + +``` +title: About +date: + +![So Schmexy][my_sweet_photo] + +Hi, I am and I wrote this epic collection of Interweb +wisdom. In days of yore, much of this would have been deemed sorcery +and I would probably have been burned at the stake. + +😆 + +[my_sweet_photo]: {filename}/images/HotPhotoOfMe.jpg +``` + +You now have three new pieces of web content in your content directory. Of the content branch. That's a lot of content. + +### Publish + +Don't worry; the payoff is coming! + +All that's left to do is: + + * Run Pelican to generate the static HTML files in **output** : [code]`$ pelican content -o output -s publishconf.py` +``` +* Use **ghp-import** to add the contents of the **output** directory to the **master** branch: [code]`$ ghp-import -m "Generate Pelican site" --no-jekyll -b master output` +``` + * Push the local master branch to the remote repo: [code]`$ git push origin master` +``` + * Commit and push the new content to the **content** branch: [code] $ git add content +$ git commit -m 'added a first post, a photo and an about page' +$ git push origin content +``` + + + +### OMG, I did it! + +Now the exciting part is here, when you get to view what you've published for everyone to see! Open your browser and enter: + + +``` +`https://username.github.io` +``` + +Congratulations on your new blog, self-published on GitHub! You can follow this pattern whenever you want to add more pages or articles. Happy blogging. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/run-your-blog-github-pages-python + +作者:[Erik O'Shaughnessy][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jnyjny/users/jasperzanjani/users/jasperzanjani/users/jasperzanjani/users/jnyjny/users/jasperzanjani +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/getting_started_with_python.png?itok=MFEKm3gl (Raspberry Pi and Python) +[2]: https://github.com/ +[3]: https://git-scm.com +[4]: https://help.github.com/en/categories/github-pages-basics +[5]: https://jekyllrb.com +[6]: https://python.org +[7]: https://blog.getpelican.com +[8]: https://guides.github.com/features/mastering-markdown +[9]: http://docutils.sourceforge.net/docs/user/rst/quickref.html +[10]: https://github.com/join?source=header-home +[11]: https://git-scm.com/docs +[12]: https://pip.pypa.io/en/stable/ +[13]: https://docs.getpelican.com diff --git a/sources/tech/20190523 Testing a Go-based S2I builder image.md b/sources/tech/20190523 Testing a Go-based S2I builder image.md new file mode 100644 index 0000000000..a6facd515d --- /dev/null +++ b/sources/tech/20190523 Testing a Go-based S2I builder image.md @@ -0,0 +1,222 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Testing a Go-based S2I builder image) +[#]: via: (https://opensource.com/article/19/5/source-image-golang-part-3) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) + +Testing a Go-based S2I builder image +====== +In the third article in this series on Source-to-Image for Golang +applications, build your application image and take it out for a spin. +![gopher illustrations][1] + +In the first two articles in this series, we explored the general [requirements of a Source To Image (S2I) system][2] and [prepared an environment][3] specifically for a Go (Golang) application. Now let's give it a spin. + +### Building the builder image + +Once the Dockerfile and Source-to-Image (S2I) scripts are ready, the Golang builder image can be created with the **docker build** command: + + +``` +`docker build -t golang-builder .` +``` + +This will produce a builder image named **golang-builder** with the context of our current directory. + +### Building the application image + +The golang-builder image is not much use without an application to build. For this exercise, we will build a simple **hello-world** application. + +#### GoHelloWorld + +Let's meet our test app, [GoHelloWorld][4]. Download the latest [version of Go][5] if you want to follow along. There are two important (for this exercise) files in this repository: + + +``` +// goHelloWorld.go +package main + +import "fmt" + +func main() { +fmt.Println("Hello World!") +} +``` + +This is a very basic app, but it will work fine for testing the builder image. We also have a basic test for GoHelloWorld: + + +``` +// goHelloWorld_test.go +package main + +import "testing" + +func TestMain(t *testing.T) { +t.Log("Hello World!") +} +``` + +#### Build the application image + +Building the application image entails running the **s2i build** command with arguments for the repository containing the code to build (or **.** to build with code from the current directory), the name of the builder image to use, and the name of the resulting application image to create. + + +``` +`$ s2i build https://github.com/clcollins/goHelloWorld.git golang-builder go-hello-world` +``` + +To build from a local directory on a filesystem, replace the Git URL with a period to represent the current directory. For example: + + +``` +`$ s2i build . golang-builder go-hello-world` +``` + +_Note:_ If a Git repository is initialized in the current directory, S2I will fetch the code from the repository URL rather than using the local code. This results in local, uncommitted changes not being used when building the image (if you're unfamiliar with what I mean by "uncommitted changes," brush up on your [Git terminology over here][6]). Directories that are not Git-initialized repositories behave as expected. + +#### Run the application image + +Once the application image is built, it can be tested by running it with the **Docker** command. Source-to-Image has replaced the **CMD** in the image with the run script created earlier so it will execute the **/go/src/app/app** binary created during the build process: + + +``` +$ docker run go-hello-world +Hello World! +``` + +Success! We now have a compiled Go application inside a Docker image created by passing the contents of a Git repo to S2I and without needing a special Dockerfile for our application. + +The application image we just built includes not only the application, but also its source code, test code, the S2I scripts, Golang libraries, and _much of the Debian Linux distribution_ (because the Golang image is based on the Debian base image). The resulting image is not small: + + +``` +$ docker images | grep go-hello-world +go-hello-world latest 75a70c79a12f 4 minutes ago 789 MB +``` + +For applications written in languages that are interpreted at runtime and depend on linked libraries, like Ruby or Python, having all the source code and operating system are necessary to run. The build images will be pretty large as a result, but at least we know it will be able to run. With these languages, we could stop here with our S2I builds. + +There is the option, however, to more explicitly define the production requirements for the application. + +Since the resulting application image would be the same image that would run the production app, I want to assure the required ports, volumes, and environment variables are added to the Dockerfile for the builder image. By writing these in a declarative way, our app is closer to the [Twelve-Factor App][7] recommended practice. For example, if we were to use the builder image to create application images for a Ruby on Rails application running [Puma][8], we would want to open a port to access the webserver. We should add the line **PORT 3000** in the builder Dockerfile so it can be inherited by all the images generated from it. + +But for the Go app, we can do better. + +### Build a runtime image + +Since our builder image created a statically compiled Go binary with our application, we can create a final "runtime" image containing _only_ the binary and none of the other cruft. + +Once the application image is created, the compiled GoHelloWorld app can be extracted and put into a new, empty image using the save-artifacts script. + +#### Runtime files + +Only the application binary and a Dockerfile are required to create the runtime image. + +##### Application binary + +Inside of the application image, the save-artifacts script is written to stream a tar archive of the app binary to stdout. We can check the files included in the tar archive created by save-artifacts with the **-vt** flags for tar: + + +``` +$ docker run go-hello-world /usr/libexec/s2i/save-artifacts | tar -tvf - +-rwxr-xr-x 1001/root 1997502 2019-05-03 18:20 app +``` + +If this results in errors along the lines of "This does not appear to be a tar archive," the save-artifacts script is probably outputting other data in addition to the tar stream, as mentioned above. We must make sure to suppress all output other than the tar stream. + +If everything looks OK, we can use **save-artifacts** to copy the binary out of the application image: + + +``` +`$ docker run go-hello-world /usr/libexec/s2i/save-artifacts | tar -xf -` +``` + +This will copy the app file into the current directory, ready to be added to its own image. + +##### Dockerfile + +The Dockerfile is extremely simple, with only three lines. The **FROM scratch** source denotes that it uses an empty, blank parent image. The rest of the Dockerfile specifies copying the app binary into **/app** in the image and using that binary as the image **ENTRYPOINT** : + + +``` +FROM scratch +COPY app /app +ENTRYPOINT ["/app"] +``` + +Save this Dockerfile as **Dockerfile-runtime**. + +Why **ENTRYPOINT** and not **CMD**? We could do either, but since there is nothing else in the image (no filesystem, no shell), we couldn't run anything else anyway. + +#### Building the runtime image + +With the Dockerfile and binary ready to go, we can build the new runtime image: + + +``` +`$ docker build -f Dockerfile-runtime -t go-hello-world:slim .` +``` + +The new runtime image is considerably smaller—just 2MB! + + +``` +$ docker images | grep -e 'go-hello-world *slim' +go-hello-world slim 4bd091c43816 3 minutes ago 2 MB +``` + +We can test that it still works as expected with **docker run** : + + +``` +$ docker run go-hello-world:slim +Hello World! +``` + +### Bootstrapping s2i with s2i create + +While we hand-created all the S2I files in this example, the **s2i** command has a sub-command to help scaffold all the files we might need for a Source-to-Image build: **s2i create**. + +Using the **s2i create** command, we can generate a new project, creatively named **go-hello-world-2** in the **./ghw2** directory: + + +``` +$ s2i create go-hello-world-2 ./ghw2 +$ ls ./ghw2/ +Dockerfile Makefile README.md s2i test +``` + +The **create** sub-command creates a placeholder Dockerfile, a README.md with information about how to use Source-to-Image, some example S2I scripts, a basic test framework, and a Makefile. The Makefile is a great way to automate building and testing the Source-to-Image builder image. Out of the box, running **make** will build our image, and it can be extended to do more. For example, we could add steps to build a base application image, run tests, or generate a runtime Dockerfile. + +### Conclusion + +In this tutorial, we have learned how to use Source-to-Image to build a custom Golang builder image, create an application image using **s2i build** , and extract the application binary to create a super-slim runtime image. + +In a future extension to this series, I would like to look at how to use the builder image we created with [OKD][9] to automatically deploy our Golang apps with **buildConfigs** , **imageStreams** , and **deploymentConfigs**. Please let me know in the comments if you are interested in me continuing the series, and thanks for reading. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/source-image-golang-part-3 + +作者:[Chris Collins][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clcollins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/go-golang.png?itok=OAW9BXny (gopher illustrations) +[2]: https://opensource.com/article/19/5/source-image-golang-part-1 +[3]: https://opensource.com/article/19/5/source-image-golang-part-2 +[4]: https://github.com/clcollins/goHelloWorld.git +[5]: https://golang.org/doc/install +[6]: /article/19/2/git-terminology +[7]: https://12factor.net/ +[8]: http://puma.io/ +[9]: https://okd.io/ diff --git a/sources/tech/20190524 Choosing the right model for maintaining and enhancing your IoT project.md b/sources/tech/20190524 Choosing the right model for maintaining and enhancing your IoT project.md new file mode 100644 index 0000000000..06b8fd6de3 --- /dev/null +++ b/sources/tech/20190524 Choosing the right model for maintaining and enhancing your IoT project.md @@ -0,0 +1,96 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Choosing the right model for maintaining and enhancing your IoT project) +[#]: via: (https://opensource.com/article/19/5/model-choose-embedded-iot-development) +[#]: author: (Drew Moseley https://opensource.com/users/drewmoseley) + +Choosing the right model for maintaining and enhancing your IoT project +====== +Learn more about these two models: Centralized Golden Master and +Distributed Build System +![][1] + +In today's connected embedded device market, driven by the [Internet of things (IoT)][2], a large share of devices in development are based on Linux of one form or another. The prevalence of low-cost boards with ready-made Linux distributions is a key driver in this. Acquiring hardware, building your custom code, connecting the devices to other hardware peripherals and the internet as well as device management using commercial cloud providers has never been easier. A developer or development team can quickly prototype a new application and get the devices in the hands of potential users. This is a good thing and results in many interesting new applications, as well as many questionable ones. + +When planning a system design for beyond the prototyping phase, things get a little more complex. In this post, we want to consider mechanisms for developing and maintaining your base [operating system (OS) image][3]. There are many tools to help with this but we won't be discussing individual tools; of interest here is the underlying model for maintaining and enhancing this image and how it will make your life better or worse. + +There are two primary models for generating these images: + + 1. Centralized Golden Master + 2. Distributed Build System + + + +These categories mirror the driving models for [Source Code Management (SCM)][4] systems, and many of the arguments regarding centralized vs. distributed are applicable when discussing OS images. + +### Centralized Golden Master + +Hobbyist and maker projects primarily use the Centralized Golden Master method of creating and maintaining application images. This fact gives this model the benefit of speed and familiarity, allowing developers to quickly set up such a system and get it running. The speed comes from the fact that many device manufacturers provide canned images for their off-the-shelf hardware. For example, boards from such families as the [BeagleBone][5] and [Raspberry Pi][6] offer ready-to-use OS images and [flashing][7]. Relying on these images means having your system up and running in just a few mouse clicks. The familiarity is due to the fact that these images are generally based on a desktop distro many device developers have already used, such as [Debian][8]. Years of using Linux can then directly transfer to the embedded design, including the fact that the packaging utilities remain largely the same, and it is simple for designers to get the extra software packages they need. + +There are a few downsides of such an approach. The first is that the [golden master image][9] is generally a choke point, resulting in lost developer productivity after the prototyping stage since everyone must wait for their turn to access the latest image and make their changes. In the SCM realm, this practice is equivalent to a centralized system with individual [file locking][10]. Only the developer with the lock can work on any given file. + +![Development flow with the Centralized Golden Master model.][11] + +The second downside with this approach is image reproducibility. This issue is usually managed by manually logging into the target systems, installing packages using the native package manager, configuring applications and dot files, and then modifying the system configuration files in place. Once this process is completed, the disk is imaged using the **dd** utility, or an equivalent, and then distributed. + +Again, this approach creates a minefield of potential issues. For example, network-based package feeds may cease to exist, and the base software provided by the vendor image may change. Scripting can help mitigate these issues. However, these scripts tend to be fragile and break when changes are made to configuration file formats or the vendor's base software packages. + +The final issue that arises with this development model is reliance on third parties. If the hardware vendor's image changes don't work for your design, you may need to invest significant time to adapt. To make matters even more complicated, as mentioned before, the hardware vendors often based their images on an upstream project such as Debian or Ubuntu. This situation introduces even more third parties who can affect your design. + +### Distributed Build System + +This method of creating and maintaining an image for your application relies on the generation of target images separate from the target hardware. The developer workflow here is similar to standard software development using an SCM system; the image is fully buildable by tooling and each developer can work independently. Changes to the system are made via edits to metadata files (scripting, recipes, configuration files, etc) and then the tooling is rerun to generate an updated image. These metadata files are then managed using an SCM system. Individual developers can merge the latest changes into their working copies to produce their development images. In this case, no golden master image is needed and developers can avoid the associated bottleneck. + +Release images are then produced by a build system using standard SCM techniques to pull changes from all the developers. + +![Development flow with the Distributed Build System model.][12] + +Working in this fashion allows the size of your development team to increase without reducing productivity of individual developers. All engineers can work independently of the others. Additionally, this build setup ensures that your builds can be reproduced. Using standard SCM workflows can ensure that, at any future time, you can regenerate a specific build allowing for long term maintenance, even if upstream providers are no longer available. Similar to working with distributed SCM tools however, there is additional policy that needs to be in place to enable reproducible, release candidate images. Individual developers have their own copies of the source and can build their own test images but for a proper release engineering effort, development teams will need to establish merging and branching standards and ensure that all changes targeted for release eventually get merged into a well-defined branch. Many upstream projects already have well-defined processes for this kind of release strategy (for instance, using *-stable and *-next branches). + +The primary downside of this approach is the lack of familiarity. For example, adding a package to the image normally requires creating a recipe of some kind and then updating the definitions so that the package binaries are included in the image. This is very different from running apt while logged into a running system. The learning curve of these systems can be daunting but the results are more predictable and scalable and are likely a better choice when considering a design for a product that will be mass produced. + +Dedicated build systems such as [OpenEmbedded][13] and [Buildroot][14] use this model as do distro packaging tools such as [debootstrap][15] and [multistrap][16]. Newer tools such as [Isar][17], [debos][18], and [ELBE][19] also use this basic model. Choices abound, and it is worth the investment to learn one or more of these packages for your designs. The long term maintainability and reproducibility of these systems will reduce risk in your design by allowing you to generate reproducible builds, track all the source code, and remove your dependency on third-party providers continued existence. + +#### Conclusion + +To be clear, the distributed model does suffer some of the same issues as mentioned for the Golden Master Model; especially the reliance on third parties. This is a consequence of using systems designed by others and cannot be completely avoided unless you choose a completely roll-your-own approach which comes with a significant cost in development and maintenance. + +For prototyping and proof-of-concept level design, and a team of just a few developers, the Golden Master Model may well be the right choice given restrictions in time and budget that are present at this stage of development. For low volume, high touch designs, this may be an acceptable trade-off for production use. + +For general production use, the benefits in terms of team size scalability, image reproducibility and developer productivity greatly outweigh the learning curve and overhead of systems implementing the distributed model. Support from board and chip vendors is also widely available in these systems reducing the upfront costs of developing with them. For your next product, I strongly recommend starting the design with a serious consideration of the model being used to generate the base OS image. If you choose to prototype with the golden master model with the intention of migrating to the distributed model, make sure to build sufficient time in your schedule for this effort; the estimates will vary widely depending on the specific tooling you choose as well as the scope of the requirements and the out-of-the-box availability of software packages your code relies on. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/model-choose-embedded-iot-development + +作者:[Drew Moseley][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/drewmoseley +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LAW-Internet_construction_9401467_520x292_0512_dc.png?itok=RPkPPtDe +[2]: https://en.wikipedia.org/wiki/Internet_of_things +[3]: https://en.wikipedia.org/wiki/System_image +[4]: https://en.wikipedia.org/wiki/Version_control +[5]: http://beagleboard.org/ +[6]: https://www.raspberrypi.org/ +[7]: https://en.wikipedia.org/wiki/Flash_memory +[8]: https://www.debian.org/ +[9]: https://en.wikipedia.org/wiki/Software_release_life_cycle#RTM +[10]: https://en.wikipedia.org/wiki/File_locking +[11]: https://opensource.com/sites/default/files/uploads/cgm1_500.png (Development flow with the Centralized Golden Master model.) +[12]: https://opensource.com/sites/default/files/uploads/cgm2_500.png (Development flow with the Distributed Build System model.) +[13]: https://www.openembedded.org/ +[14]: https://buildroot.org/ +[15]: https://wiki.debian.org/Debootstrap +[16]: https://wiki.debian.org/Multistrap +[17]: https://github.com/ilbers/isar +[18]: https://github.com/go-debos/debos +[19]: https://elbe-rfs.org/ diff --git a/sources/tech/20190524 Dual booting Windows and Linux using UEFI.md b/sources/tech/20190524 Dual booting Windows and Linux using UEFI.md new file mode 100644 index 0000000000..b281b6036b --- /dev/null +++ b/sources/tech/20190524 Dual booting Windows and Linux using UEFI.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Dual booting Windows and Linux using UEFI) +[#]: via: (https://opensource.com/article/19/5/dual-booting-windows-linux-uefi) +[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss/users/ckrzen) + +Dual booting Windows and Linux using UEFI +====== +A quick rundown of setting up Linux and Windows to dual boot on the same +machine, using the Unified Extensible Firmware Interface (UEFI). +![Linux keys on the keyboard for a desktop computer][1] + +Rather than doing a step-by-step how-to guide to configuring your system to dual boot, I’ll highlight the important points. As an example, I will refer to my new laptop that I purchased a few months ago. I first installed [Ubuntu Linux][2] onto the entire hard drive, which destroyed the pre-installed [Windows 10][3] installation. After a few months, I decided to install a different Linux distribution, and so also decided to re-install Windows 10 alongside [Fedora Linux][4] in a dual boot configuration. I’ll highlight some essential facts to get started. + +### Firmware + +Dual booting is not just a matter of software. Or, it is, but it involves changing your firmware, which among other things tells your machine how to begin the boot process. Here are some firmware-related issues to keep in mind. + +#### UEFI vs. BIOS + +Before attempting to install, make sure your firmware configuration is optimal. Most computers sold today have a new type of firmware known as [Unified Extensible Firmware Interface (UEFI)][5], which has pretty much replaced the other firmware known as [Basic Input Output System (BIOS)][6], which is often included through the mode many providers call Legacy Boot. + +I had no need for BIOS, so I chose UEFI mode. + +#### Secure Boot + +One other important setting is Secure Boot. This feature detects whether the boot path has been tampered with, and stops unapproved operating systems from booting. For now, I disabled this option to ensure that I could install Fedora Linux. According to the Fedora Project Wiki [Features/Secure Boot ][7] Fedora Linux will work with it enabled. This may be different for other Linux distributions —I plan to revisit this setting in the future. + +In short, if you find that you cannot install your Linux OS with this setting active, disable Secure Boot and try again. + +### Partitioning the boot drive + +If you choose to dual boot and have both operating systems on the same drive, you have to break it into partitions. Even if you dual boot using two different drives, most Linux installations are best broken into a few basic partitions for a variety of reasons. Here are some options to consider. + +#### GPT vs MBR + +If you decide to manually partition your boot drive in advance, I recommend using the [GUID Partition Table (GPT)][8] rather than the older [Master Boot Record (MBR)][9]. Among the reasons for this change, there are two specific limitations of MBR that GPT doesn’t have: + + * MBR can hold up to 15 partitions, while GPT can hold up to 128. + * MBR only supports up to 2 terabytes, while GPT uses 64-bit addresses which allows it to support disks up to 8 million terabytes. + + + +If you have shopped for hard drives recently, then you know that many of today’s drives exceed the 2 terabyte limit. + +#### The EFI system partition + +If you are doing a fresh installation or using a new drive, there are probably no partitions to begin with. In this case, the OS installer will create the first one, which is the [EFI System Partition (ESP)][10]. If you choose to manually partition your drive using a tool such as [gdisk][11], you will need to create this partition with several parameters. Based on the existing ESP, I set the size to around 500MB and assigned it the ef00 (EFI System) partition type. The UEFI specification requires the format to be FAT32/msdos, most likely because it is supportable by a wide range of operating systems. + +![Partitions][12] + +### Operating System Installation + +Once you accomplish the first two tasks, you can install your operating systems. While I focus on Windows 10 and Fedora Linux here, the process is fairly similar when installing other combinations as well. + +#### Windows 10 + +I started the Windows 10 installation and created a 20 Gigabyte Windows partition. Since I had previously installed Linux on my laptop, the drive had an ESP, which I chose to keep. I deleted all existing Linux and swap partitions to start fresh, and then started my Windows installation. The Windows installer automatically created another small partition—16 Megabytes—called the [Microsoft Reserved Partition (MSR)][13]. Roughly 400 Gigabytes of unallocated space remained on the 512GB boot drive once this was finished. + +I then proceeded with and completed the Windows 10 installation process. I then rebooted into Windows to make sure it was working, created my user account, set up wi-fi, and completed other tasks that need to be done on a first-time OS installation. + +#### Fedora Linux + +I next moved to install Linux. I started the process, and when it reached the disk configuration steps, I made sure not to change the Windows NTFS and MSR partitions. I also did not change the EPS, but I did set its mount point to **/boot/efi**. I then created the usual ext4 formatted partitions, **/** (root), **/boot** , and **/home**. The last partition I created was Linux **swap**. + +As with Windows, I continued and completed the Linux installation, and then rebooted. To my delight, at boot time the [GRand][14] [Unified Boot Loader (GRUB)][14] menu provided the choice to select either Windows or Linux, which meant I did not have to do any additional configuration. I selected Linux and completed the usual steps such as creating my user account. + +### Conclusion + +Overall, the process was painless. In past years, there has been some difficulty navigating the changes from UEFI to BIOS, plus the introduction of features such as Secure Boot. I believe that we have now made it past these hurdles and can reliably set up multi-boot systems. + +I don’t miss the [Linux LOader (LILO)][15] anymore! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/dual-booting-windows-linux-uefi + +作者:[Alan Formy-Duval][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alanfdoss/users/ckrzen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_keyboard_desktop.png?itok=I2nGw78_ (Linux keys on the keyboard for a desktop computer) +[2]: https://www.ubuntu.com +[3]: https://www.microsoft.com/en-us/windows +[4]: https://getfedora.org +[5]: https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface +[6]: https://en.wikipedia.org/wiki/BIOS +[7]: https://fedoraproject.org/wiki/Features/SecureBoot +[8]: https://en.wikipedia.org/wiki/GUID_Partition_Table +[9]: https://en.wikipedia.org/wiki/Master_boot_record +[10]: https://en.wikipedia.org/wiki/EFI_system_partition +[11]: https://sourceforge.net/projects/gptfdisk/ +[12]: /sites/default/files/u216961/gdisk_screenshot_s.png +[13]: https://en.wikipedia.org/wiki/Microsoft_Reserved_Partition +[14]: https://en.wikipedia.org/wiki/GNU_GRUB +[15]: https://en.wikipedia.org/wiki/LILO_(boot_loader) diff --git a/sources/tech/20190527 4 open source mobile apps for Nextcloud.md b/sources/tech/20190527 4 open source mobile apps for Nextcloud.md new file mode 100644 index 0000000000..c97817e3c1 --- /dev/null +++ b/sources/tech/20190527 4 open source mobile apps for Nextcloud.md @@ -0,0 +1,140 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (4 open source mobile apps for Nextcloud) +[#]: via: (https://opensource.com/article/19/5/mobile-apps-nextcloud) +[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) + +4 open source mobile apps for Nextcloud +====== +Increase Nextcloud's value by turning it into an on-the-go information +hub. +![][1] + +I've been using [Nextcloud][2] (and before that, ownCloud), an open source alternative to file syncing and storage services like Dropbox and Google Drive, for many years. It's been both reliable and useful, and it respects my privacy. + +While Nextcloud is great at both syncing and storage, it's much more than a place to dump your files. Thanks to applications that you can fold into Nextcloud, it becomes more of an information hub than a storage space. + +While I usually interact with Nextcloud using the desktop client or in a browser, I'm not always at my computer (or any computer that I trust). So it's important that I can work with Nextcloud using my [LineageOS][3]-powered smartphone or tablet. + +To do that, I use several open source apps that work with Nextcloud. Let's take a look at four of them. + +As you've probably guessed, this article looks at the Android version of those apps. I grabbed mine from [F-Droid][4], although you get them from other Android app markets. You might be able to get some or all of them from Apple's App Store if you're an iOS person. + +### Working with files and folders + +The obvious app to start with is the [Nextcloud sync client][5]. This little app links your phone or tablet to your Nextcloud account. + +![Nextcloud mobile app][6] + +Using the app, you can: + + * Create folders + * Upload one or more files + * Sync files between your device and server + * Rename or remove files + * Make files available offline + + + +You can also tap a file to view or edit it. If your device doesn't have an app that can open the file, then you're out of luck. You can still download it to your phone or tablet though. + +### Reading news feeds + +Remember all the whining that went on when Google pulled the plug on Google Reader in 2013? This despite Google giving users several months to find an alternative. And, yes, there are alternatives. One of them, believe it or not, is Nextcloud. + +Nextcloud has a built-in RSS reader. All you need to do to get started is upload an [OPML][7] file containing your feeds or manually add a site's RSS feed to Nextcloud. + +Going mobile is easy, too, with the Nextcloud [News Reader app][8]. + +![Nextcloud News app][9] + +Unless you configure the app to sync when you start it up, you'll need to swipe down from the top of the app to load updates to your feeds. Depending on how many feeds you have, and how many unread items are in those feeds, syncing takes anywhere from a few seconds to half a minute. + +From there, tap an item to read it in the News app. + +![Nextcloud News app][10] + +You can also add feeds or open what you're reading in your device's default web browser. + +### Reading and writing notes + +I don't use Nextcloud's [Notes][11] app all that often (I'm more of a [Standard Notes][12] person). That said, you might find the Notes app comes in handy. + +How? By giving you a lightweight way to take [plain text][13] notes on your mobile device. The Notes app syncs any notes you have in your Nextcloud account and displays them in chronological order—newest or last-edited notes first. + +![Nextcloud Notes app][14] + +Tap a note to read or edit it. You can also create a note by tapping the **+** button, then typing what you need to type. + +![Nextcloud Notes app][15] + +There's no formatting, although you can add markup (like Markdown) to the note. Once you're done editing, the app syncs your note with Nextcloud. + +### Accessing your bookmarks + +Nextcloud has a decent bookmarking tool, and its [Bookmarks][16] app makes it easy to work with the tool on your phone or tablet. + +![Nextcloud Bookmarks app][17] + +Like the Notes app, Bookmarks displays your bookmarks in chronological order, with the newest appearing first in the list. + +If you tagged your bookmarks in Nextcloud, you can swipe left in the app to see a list of those tags rather than a long list of bookmarks. Tap a tag to view the bookmarks under it. + +![Nextcloud Bookmarks app][18] + +From there, just tap a bookmark. It opens in your device's default browser. + +You can also add a bookmark within the app. To do that, tap the **+** menu and add the bookmark. + +![Nextcloud Bookmarks app][19] + +You can include: + + * The URL + * A title for the bookmark + * A description + * One or more tags + + + +### Is that all? + +Definitely not. There are apps for [Nextcloud Deck][20] (a personal kanban tool) and [Nextcloud Talk][21] (a voice and video chat app). There are also a number of third-party apps that work with Nextcloud. Just do a search for _Nextcloud_ or _ownCloud_ in your favorite app store to track them down. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/mobile-apps-nextcloud + +作者:[Scott Nesbitt][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/scottnesbitt +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_BUS_cloudagenda_20140341_jehb.png?itok=1NGs3_n4 +[2]: https://nextcloud.com/ +[3]: https://lineageos.org/ +[4]: https://opensource.com/life/15/1/going-open-source-android-f-droid +[5]: https://f-droid.org/en/packages/com.nextcloud.client/ +[6]: https://opensource.com/sites/default/files/uploads/nextcloud-app.png (Nextcloud mobile app) +[7]: http://en.wikipedia.org/wiki/OPML +[8]: https://f-droid.org/en/packages/de.luhmer.owncloudnewsreader/ +[9]: https://opensource.com/sites/default/files/uploads/nextcloud-news.png (Nextcloud News app) +[10]: https://opensource.com/sites/default/files/uploads/nextcloud-news-reading.png (Nextcloud News app) +[11]: https://f-droid.org/en/packages/it.niedermann.owncloud.notes +[12]: https://opensource.com/article/18/12/taking-notes-standard-notes +[13]: https://plaintextproject.online +[14]: https://opensource.com/sites/default/files/uploads/nextcloud-notes.png (Nextcloud Notes app) +[15]: https://opensource.com/sites/default/files/uploads/nextcloud-notes-add.png (Nextcloud Notes app) +[16]: https://f-droid.org/en/packages/org.schabi.nxbookmarks/ +[17]: https://opensource.com/sites/default/files/uploads/nextcloud-bookmarks.png (Nextcloud Bookmarks app) +[18]: https://opensource.com/sites/default/files/uploads/nextcloud-bookmarks-tags.png (Nextcloud Bookmarks app) +[19]: https://opensource.com/sites/default/files/uploads/nextcloud-bookmarks-add.png (Nextcloud Bookmarks app) +[20]: https://f-droid.org/en/packages/it.niedermann.nextcloud.deck +[21]: https://f-droid.org/en/packages/com.nextcloud.talk2 diff --git a/sources/tech/20190527 Blockchain 2.0 - Introduction To Hyperledger Sawtooth -Part 12.md b/sources/tech/20190527 Blockchain 2.0 - Introduction To Hyperledger Sawtooth -Part 12.md new file mode 100644 index 0000000000..8ab4b5b0b8 --- /dev/null +++ b/sources/tech/20190527 Blockchain 2.0 - Introduction To Hyperledger Sawtooth -Part 12.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Blockchain 2.0 – Introduction To Hyperledger Sawtooth [Part 12]) +[#]: via: (https://www.ostechnix.com/blockchain-2-0-introduction-to-hyperledger-sawtooth/) +[#]: author: (editor https://www.ostechnix.com/author/editor/) + +Blockchain 2.0 – Introduction To Hyperledger Sawtooth [Part 12] +====== + +![Introduction To Hyperledger Sawtooth][1] + +After having discussed the [**Hyperledger Fabric**][2] project in detail on this blog, its time we moved on to the next project of interest at the Hyperledger camp. **Hyperledger Sawtooth** is Intel’s contribution to the [**Blockchain**][3] consortium mission to develop enterprise ready modular distributed ledgers and applications. Sawtooth is another attempt at creating an easy to roll out blockchain ledger for businesses keeping their resource constraints and security requirements in mind. While platforms such as [**Ethereum**][4] will in theory offer similar functionality when placed in capable hands, Sawtooth readily provides a lot of customizability and is built from the ground up for specific enterprise level use cases. + +The Hyperledger project page has an introductory video detailing the Sawtooth architecture and platform. We’re attaching it here for readers to get a quick round-up about the product. + +Moving to the intricacies of the Sawtooth project, there are **five primary and significant differences** between Sawtooth and its alternatives. The post from now and on will explore these differences and at the end will mention an example real world use case for Hyperledger Sawtooth in managing supply chains. + +### Distinction 1: The consensus algorithm – PoET + +This is perhaps amongst the most notable and significant changes that Sawtooth brings to the fore. While exploring all the different consensus algorithms that exist for blockchain platforms these days is out of the scope of this post, what is to be noted is that Sawtooth uses a **Proof Of Elapsed Time** (POET) based consensus algorithm. Such a system for validating transactions and blocks on the blockchain is considered to be resources efficient unlike other computation heavy systems which use the likes of **Proof of work** or **Proof of stake** algorithms. + +POET is designed to utilize the security and tamper proof features of modern processors with reference implementations utilizing **Intel’s trusted execution environment** (TEE) architecture on its modern CPUs. The fact that the execution of the validating program takes use of a TEE along with a **“lottery”** system that is implemented to choose the **validator** or **node** to fulfill the request makes the process of creating blocks on the Sawtooth architecture secure and resource efficient at the same time. + +The POET algorithm basically elects a validator randomly based on a stochastic process. The probability of a particular node being selected depends on a host of pointers one of which depends on the amount of computing resources the said node has contributed to the ledger so far. The chosen validator then proceeds to timestamp the said block of data and shares it with the permissioned nodes in the network so that there remains a reliable record of the blockchains immutability. This method of electing the “validator” node was developed by **Intel** and so far, has been shown to exhibit zero bias and or error in executing its function. + +### Distinction 2: A fully separated level of abstraction between the application level and core system + +As mentioned, the Sawtooth platform takes modularity to the next level. Here in the reference implementation that is shared by the [**Hyperledger project**][5] foundation, the core system that enables users to create a distributed ledger, and, the application run-time environment (the virtual environment where applications developed to run on the blockchain otherwise known as [**smart contracts**][6] or **chaincode** ) are separated by a full level of abstraction. This essentially means that developers can separately code applications in any programming language of their choice instead of having to conform to and follow platform specific languages. The Sawtooth platform provides support for the following contract languages out of the box: **Java** , **Python** , **C++** , **Go** , **JavaScript** and **Rust**. This distinction between the core system and application levels are obtained by defining a custom transaction family for each application that is developed on the platform. + +A transaction family contains the following: + + * **A transaction processor** : basically, your applications logic or business logic. + * **Data model** : a system that defines and handles data storage and processing at the system level. + * **Client-side handler** to handle the end user side of your application. + + + +Multiple low-level transaction families such as this may be defined in a permissioned blockchain and used in a modular fashion throughout the network. For instance, if a consortium of banks chose to implement it, they could come together and define common functionalities or rules for their applications and then plug and play the transaction families they need in their respective systems without having to develop everything on their own. + +### Distinction 3: SETH + +It is without doubt that a blockchain future would for sure have Ethereum as one of the key players. People at the Hyperledger foundation know this well. The **Hyperledger Burrow project** is in fact meant to address the existence of entities working on multiple platforms by providing a way for developers to use Ethereum blockchain specifications to build custom distributed applications using the **EVM** (Ethereum virtual machine). + +Basically speaking, Burrow lets you customize and deploy Ethereum based [**DApps**][7] (written in **solidity** ) in non-public blockchains (the kind developed for use at the Hyperledger foundation). The Burrow and Sawtooth projects teamed up and created **SETH**. **Sawtooth-Ethereum Integration project** (SETH) is meant to add Ethereum (solidity) smart contract functionality and compatibility to Sawtooth based distributed ledger networks. A much-less known agenda to SETH is the fact that applications (DApps) and smart contracts written for EVM can now be easily ported to Sawtooth. + +### Distinction 4: ACID principle and ability to batch process + +A rather path breaking feature of Sawtooth is its ability to batch transactions together and then package them into a block. The blocks and transactions will still be subject to the **ACID** principle ( **A** tomicity, **C** onsistency, **I** solation and **D** urability). The implication of these two facts are highlighted using an example as follows. + +Let’s say you have **6 transactions** to be packaged into **two blocks (4+2)**. Block A has 4 transactions which individually needs to succeed in order for the next block of 2 transactions to be timestamped and validated. Assuming they succeed, the next block of 2 transactions is processed and assuming even they are successful the entire package of 6 transactions are deemed successful and the overall business logic is deemed successful. For instance, assume you’re selling a car. Different transactions at the ends of the buyer (block A) and the seller (block B) will need be completed in order for the trade to be deemed valid. Ownership is transferred only if both the sides are successful in carrying out their individual transactions. + +Such a feature will improve accountability on individual ends by separating responsibilities and improve the recognizability of faults and errors by the same principle. The ACID principle is implemented by coding for a custom transaction processor and defining a transaction family that will store data in the said block structure. + +### Distinction 5: Parallel transaction execution + +Blockchain platforms usually follow a serial **first come first serve route** to executing transactions and follow a queueing system for the same. Sawtooth provides support for both **serial** and **parallel execution** of transactions. Parallel transaction processing offers significant performance gains for even faster transactions by reducing overall transaction latencies. More faster transactions will be processed along with slower and bigger transactions at the same time on the platform instead of transactions of all types to be kept waiting. + +The methodology followed to implement the parallel transaction paradigm efficiently takes care of the double spending problems and errors due to multiple changes being made to the same state by defining a custom scheduler for the network which can identity processes and their predecessors. + +Real world use case: Supply Chain Management using Sawtooth applied with IoT + +The Sawtooth **official website** lists seafood traceability as an example use case for the Sawtooth platform. The basic template is applicable for almost all supply chain related use cases. + +![][8] + +Figure 1 From the Hyperledger Sawtooth Official Website + +Traditional supply chain management solutions in this space work majorly through manual record keeping which leaves room for massive frauds, errors, and significant quality control issues. IoT has been cited as a solution to overcome such issues with supply chains in day to day use. Inexpensive GPS enabled RFID-tags can be attached to fresh catch or produce as the case may be and can be scanned for updating at the individual processing centres automatically. Buyers or middle men can verify and or track the information easily using a client on their mobile device to know the route their dinner has taken before arriving on their plates. + +While tracking seafood seems to be a first world problem in countries like India, the change an IoT enabled system can bring to public delivery systems in developing countries can be a welcome change. The application is available for demo at this **[link][9]** and users are encouraged to fiddle with it and adopt it to suit their needs. + +**Reference:** + + * [**The Official Hyperledger Sawtooth Docs**][10] + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/blockchain-2-0-introduction-to-hyperledger-sawtooth/ + +作者:[editor][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/05/Hyperledger-Sawtooth-720x340.png +[2]: https://www.ostechnix.com/blockchain-2-0-introduction-to-hyperledger-fabric/ +[3]: https://www.ostechnix.com/blockchain-2-0-an-introduction/ +[4]: https://www.ostechnix.com/blockchain-2-0-what-is-ethereum/ +[5]: https://www.ostechnix.com/blockchain-2-0-an-introduction-to-hyperledger-project-hlp/ +[6]: https://www.ostechnix.com/blockchain-2-0-explaining-smart-contracts-and-its-types/ +[7]: https://www.ostechnix.com/blockchain-2-0-explaining-distributed-computing-and-distributed-applications/ +[8]: http://www.ostechnix.com/wp-content/uploads/2019/05/Sawtooth.png +[9]: https://sawtooth.hyperledger.org/examples/seafood.html +[10]: https://sawtooth.hyperledger.org/docs/core/releases/1.0/contents.html diff --git a/sources/tech/20190527 How To Enable Or Disable SSH Access For A Particular User Or Group In Linux.md b/sources/tech/20190527 How To Enable Or Disable SSH Access For A Particular User Or Group In Linux.md new file mode 100644 index 0000000000..a717d05ed8 --- /dev/null +++ b/sources/tech/20190527 How To Enable Or Disable SSH Access For A Particular User Or Group In Linux.md @@ -0,0 +1,300 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How To Enable Or Disable SSH Access For A Particular User Or Group In Linux?) +[#]: via: (https://www.2daygeek.com/allow-deny-enable-disable-ssh-access-user-group-in-linux/) +[#]: author: (2daygeek http://www.2daygeek.com/author/2daygeek/) + +How To Enable Or Disable SSH Access For A Particular User Or Group In Linux? +====== + +As per your organization standard policy, you may need to allow only the list of users that are allowed to access the Linux system. + +Or you may need to allow only few groups, which are allowed to access the Linux system. + +How to achieve this? What is the best way? How to achieve this in a simple way? + +Yes, there are many ways are available to perform this. + +However, we need to go with simple and easy method. + +If so, it can be done by making the necessary changes in `/etc/ssh/sshd_config` file. + +In this article we will show you, how to perform this in details. + +Why are we doing this? due to security reason. Navigate to the following URL to know more about **[openSSH][1]** usage. + +### What Is SSH? + +openssh stands for OpenBSD Secure Shell. Secure Shell (ssh) is a free open source networking tool which allow us to access remote system over an unsecured network using Secure Shell (SSH) protocol. + +It’s a client-server architecture. It handles user authentication, encryption, transferring files between computers and tunneling. + +These can be accomplished via traditional tools such as telnet or rcp, these are insecure and use transfer password in cleartext format while performing any action. + +### How To Allow A User To Access SSH In Linux? + +We can allow/enable the ssh access for a particular user or list of the users using the following method. + +If you would like to allow more than one user then you have to add the users with space in the same line. + +To do so, just append the following value into `/etc/ssh/sshd_config` file. In this example, we are going to allow ssh access for `user3`. + +``` +# echo "AllowUsers user3" >> /etc/ssh/sshd_config +``` + +You can double check this by running the following command. + +``` +# cat /etc/ssh/sshd_config | grep -i allowusers +AllowUsers user3 +``` + +That’s it. Just bounce the ssh service and see the magic. + +``` +# systemctl restart sshd + +# service restart sshd +``` + +Simple open a new terminal or session and try to access the Linux system with different user. Yes, `user2` isn’t allowed for SSH login and will be getting an error message as shown below. + +``` +# ssh [email protected] +[email protected]'s password: +Permission denied, please try again. +``` + +Output: + +``` +Mar 29 02:00:35 CentOS7 sshd[4900]: User user2 from 192.168.1.6 not allowed because not listed in AllowUsers +Mar 29 02:00:35 CentOS7 sshd[4900]: input_userauth_request: invalid user user2 [preauth] +Mar 29 02:00:40 CentOS7 unix_chkpwd[4902]: password check failed for user (user2) +Mar 29 02:00:40 CentOS7 sshd[4900]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.1.6 user=user2 +Mar 29 02:00:43 CentOS7 sshd[4900]: Failed password for invalid user user2 from 192.168.1.6 port 42568 ssh2 +``` + +At the same time `user3` is allowed to login into the system because it’s in allowed users list. + +``` +# ssh [email protected] +[email protected]'s password: +[[email protected] ~]$ +``` + +Output: + +``` +Mar 29 02:01:13 CentOS7 sshd[4939]: Accepted password for user3 from 192.168.1.6 port 42590 ssh2 +Mar 29 02:01:13 CentOS7 sshd[4939]: pam_unix(sshd:session): session opened for user user3 by (uid=0) +``` + +### How To Deny Users To Access SSH In Linux? + +We can deny/disable the ssh access for a particular user or list of the users using the following method. + +If you would like to disable more than one user then you have to add the users with space in the same line. + +To do so, just append the following value into `/etc/ssh/sshd_config` file. In this example, we are going to disable ssh access for `user1`. + +``` +# echo "DenyUsers user1" >> /etc/ssh/sshd_config +``` + +You can double check this by running the following command. + +``` +# cat /etc/ssh/sshd_config | grep -i denyusers +DenyUsers user1 +``` + +That’s it. Just bounce the ssh service and see the magic. + +``` +# systemctl restart sshd + +# service restart sshd +``` + +Simple open a new terminal or session and try to access the Linux system with Deny user. Yes, `user1` is in denyusers list. So, you will be getting an error message as shown below when you are try to login. + +``` +# ssh [email protected] +[email protected]'s password: +Permission denied, please try again. +``` + +Output: + +``` +Mar 29 01:53:42 CentOS7 sshd[4753]: User user1 from 192.168.1.6 not allowed because listed in DenyUsers +Mar 29 01:53:42 CentOS7 sshd[4753]: input_userauth_request: invalid user user1 [preauth] +Mar 29 01:53:46 CentOS7 unix_chkpwd[4755]: password check failed for user (user1) +Mar 29 01:53:46 CentOS7 sshd[4753]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.1.6 user=user1 +Mar 29 01:53:48 CentOS7 sshd[4753]: Failed password for invalid user user1 from 192.168.1.6 port 42522 ssh2 +``` + +### How To Allow Groups To Access SSH In Linux? + +We can allow/enable the ssh access for a particular group or groups using the following method. + +If you would like to allow more than one group then you have to add the groups with space in the same line. + +To do so, just append the following value into `/etc/ssh/sshd_config` file. In this example, we are going to disable ssh access for `2g-admin` group. + +``` +# echo "AllowGroups 2g-admin" >> /etc/ssh/sshd_config +``` + +You can double check this by running the following command. + +``` +# cat /etc/ssh/sshd_config | grep -i allowgroups +AllowGroups 2g-admin +``` + +Run the following command to know the list of the users are belongs to this group. + +``` +# getent group 2g-admin +2g-admin:x:1005:user1,user2,user3 +``` + +That’s it. Just bounce the ssh service and see the magic. + +``` +# systemctl restart sshd + +# service restart sshd +``` + +Yes, `user3` is allowed to login into the system because user3 is belongs to `2g-admin` group. + +``` +# ssh [email protected] +[email protected]'s password: +[[email protected] ~]$ +``` + +Output: + +``` +Mar 29 02:10:21 CentOS7 sshd[5165]: Accepted password for user1 from 192.168.1.6 port 42640 ssh2 +Mar 29 02:10:22 CentOS7 sshd[5165]: pam_unix(sshd:session): session opened for user user1 by (uid=0) +``` + +Yes, `user2` is allowed to login into the system because user2 is belongs to `2g-admin` group. + +``` +# ssh [email protected] +[email protected]'s password: +[[email protected] ~]$ +``` + +Output: + +``` +Mar 29 02:10:38 CentOS7 sshd[5225]: Accepted password for user2 from 192.168.1.6 port 42642 ssh2 +Mar 29 02:10:38 CentOS7 sshd[5225]: pam_unix(sshd:session): session opened for user user2 by (uid=0) +``` + +When you are try to login into the system with other users which are not part of this group then you will be getting an error message as shown below. + +``` +# ssh [email protected] +[email protected]'s password: +Permission denied, please try again. +``` + +Output: + +``` +Mar 29 02:12:36 CentOS7 sshd[5306]: User ladmin from 192.168.1.6 not allowed because none of user's groups are listed in AllowGroups +Mar 29 02:12:36 CentOS7 sshd[5306]: input_userauth_request: invalid user ladmin [preauth] +Mar 29 02:12:56 CentOS7 unix_chkpwd[5310]: password check failed for user (ladmin) +Mar 29 02:12:56 CentOS7 sshd[5306]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.1.6 user=ladmin +Mar 29 02:12:58 CentOS7 sshd[5306]: Failed password for invalid user ladmin from 192.168.1.6 port 42674 ssh2 +``` + +### How To Deny Group To Access SSH In Linux? + +We can deny/disable the ssh access for a particular group or groups using the following method. + +If you would like to disable more than one group then you need to add the group with space in the same line. + +To do so, just append the following value into `/etc/ssh/sshd_config` file. + +``` +# echo "DenyGroups 2g-admin" >> /etc/ssh/sshd_config +``` + +You can double check this by running the following command. + +``` +# # cat /etc/ssh/sshd_config | grep -i denygroups +DenyGroups 2g-admin + +# getent group 2g-admin +2g-admin:x:1005:user1,user2,user3 +``` + +That’s it. Just bounce the ssh service and see the magic. + +``` +# systemctl restart sshd + +# service restart sshd +``` + +Yes `user3` isn’t allowed to login into the system because it’s not part of `2g-admin` group. It’s in Denygroups. + +``` +# ssh [email protected] +[email protected]'s password: +Permission denied, please try again. +``` + +Output: + +``` +Mar 29 02:17:32 CentOS7 sshd[5400]: User user1 from 192.168.1.6 not allowed because a group is listed in DenyGroups +Mar 29 02:17:32 CentOS7 sshd[5400]: input_userauth_request: invalid user user1 [preauth] +Mar 29 02:17:38 CentOS7 unix_chkpwd[5402]: password check failed for user (user1) +Mar 29 02:17:38 CentOS7 sshd[5400]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.1.6 user=user1 +Mar 29 02:17:41 CentOS7 sshd[5400]: Failed password for invalid user user1 from 192.168.1.6 port 42710 ssh2 +``` + +Anyone can login into the system except `2g-admin` group. Hence, `ladmin` user is allowed to login into the system. + +``` +# ssh [email protected] +[email protected]'s password: +[[email protected] ~]$ +``` + +Output: + +``` +Mar 29 02:19:13 CentOS7 sshd[5432]: Accepted password for ladmin from 192.168.1.6 port 42716 ssh2 +Mar 29 02:19:13 CentOS7 sshd[5432]: pam_unix(sshd:session): session opened for user ladmin by (uid=0) +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/allow-deny-enable-disable-ssh-access-user-group-in-linux/ + +作者:[2daygeek][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.2daygeek.com/author/2daygeek/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/category/ssh-tutorials/ diff --git a/sources/tech/20190528 A Quick Look at Elvish Shell.md b/sources/tech/20190528 A Quick Look at Elvish Shell.md new file mode 100644 index 0000000000..ba2eb640fd --- /dev/null +++ b/sources/tech/20190528 A Quick Look at Elvish Shell.md @@ -0,0 +1,106 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A Quick Look at Elvish Shell) +[#]: via: (https://itsfoss.com/elvish-shell/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +A Quick Look at Elvish Shell +====== + +Everyone who comes to this site has some knowledge (no matter how slight) of the Bash shell that comes default of so many systems. There have been several attempts to create shells that solve some of the shortcomings of Bash that have appeared over the years. One such shell is Elvish, which we will look at today. + +### What is Elvish Shell? + +![Pipelines In Elvish][1] + +[Elvish][2] is more than just a shell. It is [also][3] “an expressive programming language”. It has a number of interesting features including: + + * Written in Go + * Built-in file manager, inspired by the [Ranger file manager][4] (`Ctrl + N`) + * Searchable command history (`Ctrl + R`) + * History of directories visited (`Ctrl + L`) + * Powerful pipelines that support structured data, such as lists, maps, and functions + * Includes a “standard set of control structures: conditional control with `if`, loops with `for` and `while`, and exception handling with `try`“ + * Support for [third-party modules via a package manager to extend Elvish][5] + * Licensed under the BSD 2-Clause license + + + +“Why is it named Elvish?” I hear you shout. Well, according to [their website][6], they chose their current name because: + +> In roguelikes, items made by the elves have a reputation of high quality. These are usually called elven items, but “elvish” was chosen because it ends with “sh”, a long tradition of Unix shells. It also rhymes with fish, one of the shells that influenced the philosophy of Elvish. + +### How to Install Elvish Shell + +Elvish is available in several mainstream distributions. + +Note that the software is very young. The most recent version is 0.12. According to the project’s [GitHub page][3]: “Despite its pre-1.0 status, it is already suitable for most daily interactive use.” + +![Elvish Control Structures][7] + +#### Debian and Ubuntu + +Elvish packages were introduced into Debian Buster and Ubuntu 17.10. Unfortunately, those packages are out of date and you will need to use a [PPA][8] to install the latest version. You will need to use the following commands: + +``` +sudo add-apt-repository ppa:zhsj/elvish +sudo apt update +sudo apt install elvish +``` + +#### Fedora + +Elvish is not available in the main Fedora repos. You will need to add the [FZUG Repository][9] to install Evlish. To do so, you will need to use these commands: + +``` +sudo dnf config-manager --add-repo=http://repo.fdzh.org/FZUG/FZUG.repol +sudo dnf install elvish +``` + +#### Arch + +Elvish is available in the [Arch User Repository][10]. + +I believe you know [how to change shell in Linux][11] so after installing you can switch to Elvish to use it. + +### Final Thoughts on Elvish Shell + +Personally, I have no reason to install Elvish on any of my systems. I can get most of its features by installing a couple of small command line programs or using already installed programs. + +For example, the search past commands feature already exists in Bash and it works pretty well. If you want to improve your ability to search past commands, I would recommend installing [fzf][12] instead. Fzf uses fuzzy search, so you don’t need to remember the exact command you are looking for. Fzf also allows you to preview and open files. + +I do think that the fact that Elvish is also a programming language is neat, but I’ll stick with Bash shell scripting until Elvish matures a little more. + +Have you every used Elvish? Do you think it would be worthwhile to install Elvish? What is your favorite Bash replacement? Please let us know in the comments below. + +If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][13]. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/elvish-shell/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/pipelines-in-elvish.png?fit=800%2C421&ssl=1 +[2]: https://elv.sh/ +[3]: https://github.com/elves/elvish +[4]: https://ranger.github.io/ +[5]: https://github.com/elves/awesome-elvish +[6]: https://elv.sh/ref/name.html +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/Elvish-control-structures.png?fit=800%2C425&ssl=1 +[8]: https://launchpad.net/%7Ezhsj/+archive/ubuntu/elvish +[9]: https://github.com/FZUG/repo/wiki/Add-FZUG-Repository +[10]: https://aur.archlinux.org/packages/elvish/ +[11]: https://linuxhandbook.com/change-shell-linux/ +[12]: https://github.com/junegunn/fzf +[13]: http://reddit.com/r/linuxusersgroup diff --git a/sources/tech/20190529 Packit - packaging in Fedora with minimal effort.md b/sources/tech/20190529 Packit - packaging in Fedora with minimal effort.md new file mode 100644 index 0000000000..ad431547da --- /dev/null +++ b/sources/tech/20190529 Packit - packaging in Fedora with minimal effort.md @@ -0,0 +1,244 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Packit – packaging in Fedora with minimal effort) +[#]: via: (https://fedoramagazine.org/packit-packaging-in-fedora-with-minimal-effort/) +[#]: author: (Petr Hracek https://fedoramagazine.org/author/phracek/) + +Packit – packaging in Fedora with minimal effort +====== + +![][1] + +### What is packit + +Packit ([https://packit.dev/)][2] is a CLI tool that helps you auto-maintain your upstream projects into the Fedora operating system. But what does it really mean? + +As a developer, you might want to update your package in Fedora. If you’ve done it in the past, you know it’s no easy task. If you haven’t let me reiterate: it’s no easy task. + +And this is exactly where packit can help: once you have your package in Fedora, you can maintain your SPEC file upstream and, with just one additional configuration file, packit will help you update your package in Fedora when you update your source code upstream. + +Furthermore, packit can synchronize downstream changes to a SPEC file back into the upstream repository. This could be useful if the SPEC file of your package is changed in Fedora repositories and you would like to synchronize it into your upstream project. + +Packit also provides a way to build an SRPM package based on an upstream repository checkout, which can be used for building RPM packages in COPR. + +Last but not least, packit provides a status command. This command provides information about upstream and downstream repositories, like pull requests, release and more others. + +Packit provides also another two commands: _build_ and _create-update_. + +The command _packit build_ performs a production build of your project in Fedora build system – koji. You can Fedora version you want to build against using an option _–dist-git-branch_. The command _packit create-updates_ creates a Bodhi update for the specific branch using the option — _dist-git-branch_. + +### Installation + +You can install packit on Fedora using dnf: + +``` +sudo dnf install -y packit +``` + +### Configuration + +For demonstration use case, I have selected the upstream repository of **colin** ([https://github.com/user-cont/colin)][3]. Colin is a tool to check generic rules and best-practices for containers, dockerfiles, and container images. + +First of all, clone **colin** git repository: + +``` +$ git clone https://github.com/user-cont/colin.git +$ cd colin +``` + +Packit expects to run in the root of your git repository. + +Packit ([https://github.com/packit-service/packit/)][4] needs information about your project, which has to be stored in the upstream repository in the _.packit.yaml_ file (). + +See colin’s packit configuration file: + +``` +$ cat .packit.yaml +specfile_path: colin.spec +synced_files: + -.packit.yaml + - colin.spec +upstream_project_name: colin +downstream_package_name: colin +``` + +What do the values mean? + + * _specfile_path_ – a relative path to a spec file within the upstream repository (mandatory) + * _synced_files_ – a list of relative paths to files in the upstream repo which are meant to be copied to dist-git during an update + * _upstream_project_name_ – name of the upstream repository (e.g. in PyPI); this is used in %prep section + * _downstream_package_name_ – name of the package in Fedora (mandatory) + + + +For more information see the packit configuration documentation () + +### What can packit do? + +Prerequisite for using packit is that you are in a working directory of a git checkout of your upstream project. + +Before running any packit command, you need to do several actions. These actions are mandatory for filing a PR into the upstream or downstream repositories and to have access into the Fedora dist-git repositories. + +Export GitHub token taken from : + +``` +$ export GITHUB_TOKEN= +``` + +Obtain your Kerberos ticket needed for Fedora Account System (FAS) : + +``` +$ kinit @FEDORAPROJECT.ORG +``` + +Export your Pagure API keys taken from : + +``` +$ export PAGURE_USER_TOKEN= +``` + +Packit also needs a fork token to create a pull request. The token is taken from + +Do it by running: + +``` +$ export PAGURE_FORK_TOKEN= +``` + +Or store these tokens in the **~/.config/packit.yaml** file: + +``` +$ cat ~/.config/packit.yaml + +github_token: +pagure_user_token: +pagure_fork_token: +``` + +#### Propose a new upstream release in Fedora + +The command for this first use case is called _**propose-update**_ (). The command creates a new pull request in Fedora dist-git repository using a selected or the latest upstream release. + +``` +$ packit propose-update + +INFO: Running 'anitya' versioneer +Version in upstream registries is '0.3.1'. +Version in spec file is '0.3.0'. +WARNING Version in spec file is outdated +Picking version of the latest release from the upstream registry. +Checking out upstream version 0.3.1 +Using 'master' dist-git branch +Copying /home/vagrant/colin/colin.spec to /tmp/tmptfwr123c/colin.spec. +Archive colin-0.3.0.tar.gz found in lookaside cache (skipping upload). +INFO: Downloading file from URL https://files.pythonhosted.org/packages/source/c/colin/colin-0.3.0.tar.gz +100%[=============================>] 3.18M eta 00:00:00 +Downloaded archive: '/tmp/tmptfwr123c/colin-0.3.0.tar.gz' +About to upload to lookaside cache +won't be doing kinit, no credentials provided +PR created: https://src.fedoraproject.org/rpms/colin/pull-request/14 +``` + +Once the command finishes, you can see a PR in the Fedora Pagure instance which is based on the latest upstream release. Once you review it, it can be merged. + +![][5] + +#### Sync downstream changes back to the upstream repository + +Another use case is to sync downstream changes into the upstream project repository. + +The command for this purpose is called _**sync-from-downstream**_ (). Files synced into the upstream repository are mentioned in the _packit.yaml_ configuration file under the _synced_files_ value. + +``` +$ packit sync-from-downstream + +upstream active branch master +using "master" dist-git branch +Copying /tmp/tmplvxqtvbb/colin.spec to /home/vagrant/colin/colin.spec. +Creating remote fork-ssh with URL git@github.com:phracek/colin.git. +Pushing to remote fork-ssh using branch master-downstream-sync. +PR created: https://github.com/user-cont/colin/pull/229 +``` + +As soon as packit finishes, you can see the latest changes taken from the Fedora dist-git repository in the upstream repository. This can be useful, e.g. when Release Engineering performs mass-rebuilds and they update your SPEC file in the Fedora dist-git repository. + +![][6] + +#### Get the status of your upstream project + +If you are a developer, you may want to get all the information about the latest releases, tags, pull requests, etc. from the upstream and the downstream repository. Packit provides the _**status**_ command for this purpose. + +``` +$ packit status +Downstream PRs: + ID Title URL +---- -------------------------------- --------------------------------------------------------- + 14 Update to upstream release 0.3.1 https://src.fedoraproject.org//rpms/colin/pull-request/14 + 12 Upstream pr: 226 https://src.fedoraproject.org//rpms/colin/pull-request/12 + 11 Upstream pr: 226 https://src.fedoraproject.org//rpms/colin/pull-request/11 + 8 Upstream pr: 226 https://src.fedoraproject.org//rpms/colin/pull-request/8 + +Dist-git versions: +f27: 0.2.0 +f28: 0.2.0 +f29: 0.2.0 +f30: 0.2.0 +master: 0.2.0 + +GitHub upstream releases: +0.3.1 +0.3.0 +0.2.1 +0.2.0 +0.1.0 + +Latest builds: +f27: colin-0.2.0-1.fc27 +f28: colin-0.3.1-1.fc28 +f29: colin-0.3.1-1.fc29 +f30: colin-0.3.1-2.fc30 + +Latest bodhi updates: +Update Karma status +------------------ ------- -------- +colin-0.3.1-1.fc29 1 stable +colin-0.3.1-1.fc28 1 stable +colin-0.3.0-2.fc28 0 obsolete +``` + +#### Create an SRPM + +The last packit use case is to generate an SRPM package based on a git checkout of your upstream project. The packit command for SRPM generation is _**srpm**_. + +``` +$ packit srpm +Version in spec file is '0.3.1.37.g00bb80e'. +SRPM: /home/phracek/work/colin/colin-0.3.1.37.g00bb80e-1.fc29.src.rpm +``` + +### Packit as a service + +In the summer, the people behind packit would like to introduce packit as a service (). In this case, the packit GitHub application will be installed into the upstream repository and packit will perform all the actions automatically, based on the events it receives from GitHub or fedmsg. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/packit-packaging-in-fedora-with-minimal-effort/ + +作者:[Petr Hracek][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/phracek/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/05/packit3-816x345.png +[2]: https://packit.dev/ +[3]: https://github.com/user-cont/colin +[4]: https://github.com/packit-service/packit/ +[5]: https://fedoramagazine.org/wp-content/uploads/2019/05/colin_pr-1024x781.png +[6]: https://fedoramagazine.org/wp-content/uploads/2019/05/colin_upstream_pr-1-1024x677.png diff --git a/sources/tech/20190530 Creating a Source-to-Image build pipeline in OKD.md b/sources/tech/20190530 Creating a Source-to-Image build pipeline in OKD.md new file mode 100644 index 0000000000..713d117cb3 --- /dev/null +++ b/sources/tech/20190530 Creating a Source-to-Image build pipeline in OKD.md @@ -0,0 +1,484 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Creating a Source-to-Image build pipeline in OKD) +[#]: via: (https://opensource.com/article/19/5/creating-source-image-build-pipeline-okd) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) + +Creating a Source-to-Image build pipeline in OKD +====== +S2I is an ideal way to build and compile Go applications in a repeatable +way, and it just gets better when paired with OKD BuildConfigs. +![][1] + +In the first three articles in this series, we explored the general [requirements][2] of a Source-to-Image (S2I) system and [prepared][3] and [tested][4] an environment specifically for a Go (Golang) application. This S2I build is perfect for local development or maintaining a builder image with a code pipeline, but if you have access to an [OKD][5] or OpenShift cluster (or [Minishift][6]), you can set up the entire workflow using OKD BuildConfigs, not only to build and maintain the builder image but also to use the builder image to create the application image and subsequent runtime image automatically. This way, the images can be rebuilt automatically when downstream images change and can trigger OKD deploymentConfigs to redeploy applications running from these images. + +### Step 1: Build the builder image in OKD + +As in local S2I usage, the first step is to create the builder image to build the GoHelloWorld test application that we can reuse to compile other Go-based applications. This first build step will be a Docker build, just like before, that pulls the Dockerfile and S2I scripts from a Git repository to build the image. Therefore, those files must be committed and available in a public Git repo (or you can use the companion [GitHub repo][7] for this article). + +_Note:_ OKD BuildConfigs do not require that source Git repos are public. To use a private repo, you must set up deploy keys and link the keys to a builder service account. This is not difficult, but for simplicity's sake, this exercise will use a public repository. + +#### Create an image stream for the builder image + +The BuildConfig will create a builder image for us to compile the GoHelloWorld app, but first, we need a place to store the image. In OKD, that place is an image stream. + +An [image stream][8] and its tags are like a manifest or list of related images and image tags. It serves as an abstraction layer that allows you to reference an image, even if the image changes. Think of it as a collection of aliases that reference specific images and, as images are updated, automatically points to the new image version. The image stream is nothing except these aliases—just metadata about real images stored in a registry. + +An image stream can be created with the **oc create imagestream ** command, or it can be created from a YAML file with **oc create -f **. Either way, a brand-new image stream is a small placeholder object that is empty until it is populated with image references, either manually (who wants to do things manually?) or with a BuildConfig. + +Our golang-builder image stream looks like this: + + +``` +# imageStream-golang-builder.yaml +\--- +apiVersion: image.openshift.io/v1 +kind: ImageStream +metadata: +generation: 1 +name: golang-builder +spec: +lookupPolicy: +local: false +``` + +Other than a name, and a (mostly) empty spec, there is nothing really there. + +_Note:_ The **lookupPolicy** has to do with allowing Kubernetes-native components to resolve image stream references since image streams are OKD-native and not a part of the Kubernetes core. This topic is out of scope for this article, but you can read more about how it works in OKD's documentation [Using Image Streams with Kubernetes Resources][9]. + +Create an image stream for the builder image and its progeny. + + +``` +$ oc create -f imageStream-golangBuilder.yaml + +# Check the ImageStream +$ oc get imagestream golang-builder +NAME DOCKER REPO TAGS UPDATED +imagestream.image.openshift.io/golang-builder docker-registry.default.svc:5000/golang-builder/golang-builder +``` + +Note that the newly created image stream has no tags and has never been updated. + +#### Create a BuildConfig for the builder image + +In OKD, a [BuildConfig][10] describes how to build container images from a specific source and triggers for when they build. Don't be thrown off by the language—just as you might say you build and re-build the same image from a Dockerfile, but in reality, you have built multiple images, a BuildConfig builds and rebuilds the same image, but in reality, it creates multiple images. (And suddenly the reason for image streams becomes much clearer!) + +Our builder image BuildConfig describes how to build and re-build our builder image(s). The BuildConfig's core is made up of four important parts: + + 1. Build source + 2. Build strategy + 3. Build output + 4. Build triggers + + + +The _build source_ (predictably) describes where the thing that runs the build comes from. The builds described by the golang-builder BuildConfig will use the Dockerfile and S2I scripts we created previously and, using the Git-type build source, clone a Git repository to get the files to do the builds. + + +``` +source: +type: Git +git: +ref: master +uri: +``` + +The _build strategy_ describes what the build will do with the source files from the build source. The golang-builder BuildConfig mimics the **docker build** we used previously to build our local builder image by using the Docker-type build strategy. + + +``` +strategy: +type: Docker +dockerStrategy: {} +``` + +The **dockerStrategy** build type tells OKD to build a Docker image from the Dockerfile contained in the source specified by the build source. + +The _build output_ tells the BuildConfig what to do with the resulting image. In this case, we specify the image stream we created above and a tag to give to the image. As with our local build, we're tagging it with **golang-builder:1.12** as a reference to the Go version inherited from the parent image. + + +``` +output: +to: +kind: ImageStreamTag +name: golang-builder:1.12 +``` + +Finally, the BuildConfig defines a set of _build triggers_ —events that will cause the image to be rebuilt automatically. For this BuildConfig, a change to the BuildConfig configuration or an update to the upstream image (golang:1.12) will trigger a new build. + + +``` +triggers: +\- type: ConfigChange +\- imageChange: +type: ImageChange +``` + +Using the [builder image BuildConfig][11] from the GitHub repo as a reference (or just using that file), create a BuildConfig YAML file and use it to create the BuildConfig. + + +``` +$ oc create -f buildConfig-golang-builder.yaml + +# Check the BuildConfig +$ oc get bc golang-builder +NAME TYPE FROM LATEST +golang-builder Docker Git@master 1 +``` + +Because the BuildConfig included the "ImageChange" trigger, it immediately kicks off a new build. You can check that the build was created with the **oc get builds** command. + + +``` +# Check the Builds +$ oc get builds +NAME TYPE FROM STATUS STARTED DURATION +golang-builder-1 Docker Git@8eff001 Complete About a minute ago 13s +``` + +While the build is running and after it has completed, you can view its logs with **oc logs -f ** and see the Docker build output as you would locally. + + +``` +$ oc logs -f golang-builder-1-build +Step 1/11 : FROM docker.io/golang:1.12 +\---> 7ced090ee82e +Step 2/11 : LABEL maintainer "Chris Collins <[collins.christopher@gmail.com][12]>" +\---> 7ad989b765e4 +Step 3/11 : ENV CGO_ENABLED 0 GOOS linux GOCACHE /tmp STI_SCRIPTS_PATH /usr/libexec/s2i SOURCE_DIR /go/src/app +\---> 2cee2ce6757d + +<...> +``` + +If you did not include any build triggers (or did not have them in the right place), your build may not start automatically. You can manually kick off a new build with the **oc start-build** command. + + +``` +$ oc start-build golang-builder + +# Or, if you want to automatically tail the build log +$ oc start-build golang-builder --follow +``` + +When the build completes, the resulting image is tagged and pushed to the integrated image registry and the image stream is updated with the new image's information. Check the image stream with the **oc get imagestream** command to see that the new tag exists. + + +``` +$ oc get imagestream golang-builder +NAME DOCKER REPO TAGS UPDATED +golang-builder docker-registry.default.svc:5000/golang-builder/golang-builder 1.12 33 seconds ago +``` + +### Step 2: Build the application image in OKD + +Now that we have a builder image for our Golang applications created and stored within OKD, we can use this builder image to compile all of our Go apps. First on the block is the example GoHelloWorld app from our [local build example][4]. GoHelloWorld is a simple Go app that just outputs **Hello World!** when it's run. + +Just as we did in the local example with the **s2i build** command, we can tell OKD to use our builder image and S2I to build the application image for GoHelloWorld, compiling the Go binary from the source code in the [GoHelloWorld GitHub repository][13]. This can be done with a BuildConfig with a **sourceStrategy** build. + +#### Create an image stream for the application image + +First things first, we need to create an image stream to manage the image created by the BuildConfig. The image stream is just like the golang-builder image stream, just with a different name. Create it with **oc create is** or using a YAML file from the [GitHub repo][7]. + + +``` +$ oc create -f imageStream-goHelloWorld-appimage.yaml +imagestream.image.openshift.io/go-hello-world-appimage created +``` + +#### Create a BuildConfig for the application image + +Just as we did with the builder image BuildConfig, this BuildConfig will use the Git source option to clone our source code from the GoHelloWorld repository. + + +``` +source: +type: Git +git: +uri: +``` + +Instead of using a DockerStrategy build to create an image from a Dockerfile, this BuildConfig will use the sourceStrategy definition to build the image using S2I. + + +``` +strategy: +type: Source +sourceStrategy: +from: +kind: ImageStreamTag +name: golang-builder:1.12 +``` + +Note the **from:** hash in sourceStrategy. This tells OKD to use the **golang-builder:1.12** image we created previously for the S2I build. + +The BuildConfig will output to the new **appimage** image stream we created, and we'll include config- and image-change triggers to kick off new builds automatically if anything updates. + + +``` +output: +to: +kind: ImageStreamTag +name: go-hello-world-appimage:1.0 +triggers: +\- type: ConfigChange +\- imageChange: +type: ImageChange +``` + +Once again, create a BuildConfig or use the one from the GitHub repo. + + +``` +`$ oc create -f buildConfig-goHelloWorld-appimage.yaml` +``` + +The new build shows up alongside the golang-builder build and, because image-change triggers are specified, the build starts immediately. + + +``` +$ oc get builds +NAME TYPE FROM STATUS STARTED DURATION +golang-builder-1 Docker Git@8eff001 Complete 8 minutes ago 13s +go-hello-world-appimage-1 Source Git@99699a6 Running 44 seconds ago +``` + +If you want to watch the build logs, use the **oc logs -f** command. Once the application image build completes, it is pushed to the image stream we specified, then the new image stream tag is created. + + +``` +$ oc get is go-hello-world-appimage +NAME DOCKER REPO TAGS UPDATED +go-hello-world-appimage docker-registry.default.svc:5000/golang-builder/go-hello-world-appimage 1.0 10 minutes ago +``` + +Success! The GoHelloWorld app was cloned from source into a new image and compiled and tested using our S2I scripts. We can use the image as-is but, as with our local S2I builds, we can do better and create an image with just the new Go binary in it. + +### Step 3: Build the runtime image in OKD + +Now that the application image has been created with a compiled Go binary for the GoHelloWorld app, we can use something called chain builds to mimic when we extracted the binary from our local application image and created a new runtime image with just the binary in it. + +#### Create an image stream for the runtime image + +Once again, the first step is to create an image stream image for the new runtime image. + + +``` +# Create the ImageStream +$ oc create -f imageStream-goHelloWorld.yaml +imagestream.image.openshift.io/go-hello-world created + +# Get the ImageStream +$ oc get imagestream go-hello-world +NAME DOCKER REPO TAGS UPDATED +go-hello-world docker-registry.default.svc:5000/golang-builder/go-hello-world +``` + +#### Chain builds + +Chain builds are when one or more BuildConfigs are used to compile software or assemble artifacts for an application, and those artifacts are saved and used by a subsequent BuildConfig to generate a runtime image without re-compiling the code. + +![Chain Build workflow][14] + +Chain build workflow + +#### Create a BuildConfig for the runtime image + +The runtime BuildConfig uses the DockerStrategy build to build the image from a Dockerfile—the same thing we did with the builder image BuildConfig. This time, however, the source is not a Git source, but a Dockerfile source. + +What is the Dockerfile source? It's an inline Dockerfile! Instead of cloning a repo with a Dockerfile in it and building that, we specify the Dockerfile in the BuildConfig. This is especially appropriate with our runtime Dockerfile because it's just three lines long. + + +``` +source: +type: Dockerfile +dockerfile: |- +FROM scratch +COPY app /app +ENTRYPOINT ["/app"] +images: +\- from: +kind: ImageStreamTag +name: go-hello-world-appimage:1.0 +paths: +\- sourcePath: /go/src/app/app +destinationDir: "." +``` + +Note that the Dockerfile in the Dockerfile source definition above is the same as the Dockerfile we used in the [third article][4] in this series when we built the slim GoHelloWorld image locally using the binary we extracted with the S2I **save-artifacts** script. + +Something else to note: **scratch** is a reserved word in Dockerfiles. Unlike other **FROM** statements, it does not define an _actual_ image, but rather that the first layer of this image will be nothing. It is defined with **kind: DockerImage** but does not have a registry or group/namespace/project string. Learn more about this behavior in this excellent [container best practices][15] reference. + +The **images** section of the Dockerfile source describes the source of the artifact(s) to be used in the build; in this case, from the appimage generated earlier. The **paths** subsection describes where to get the binary (i.e., in the **/go/src/app** directory of the app image, get the **app** binary) and where to save it (i.e., in the current working directory of the build itself: **"."** ). This allows the **COPY app /app** to grab the binary from the current working directory and add it to **/app** in the runtime image. + +_Note:_ **paths** is an array of source and the destination path _pairs_. Each entry in the list consists of a source and destination. In the example above, there is just one entry because there is just a single binary to copy. + +The Docker strategy is then used to build the inline Dockerfile. + + +``` +strategy: +type: Docker +dockerStrategy: {} +``` + +Once again, it is output to the image stream created earlier and includes build triggers to automatically kick off new builds. + + +``` +output: +to: +kind: ImageStreamTag +name: go-hello-world:1.0 +triggers: +\- type: ConfigChange +\- imageChange: +type: ImageChange +``` + +Create a BuildConfig YAML or use the runtime BuildConfig from the GitHub repo. + + +``` +$ oc create -f buildConfig-goHelloWorld.yaml +buildconfig.build.openshift.io/go-hello-world created +``` + +If you watch the logs, you'll notice the first step is **FROM scratch** , which confirms we're adding the compiled binary to a blank image. + + +``` +$ oc logs -f pod/go-hello-world-1-build +Step 1/5 : FROM scratch +\---> +Step 2/5 : COPY app /app +\---> 9e70e6c710f8 +Removing intermediate container 4d0bd9cef0a7 +Step 3/5 : ENTRYPOINT /app +\---> Running in 7a2dfeba28ca +\---> d697577910fc + +<...> +``` + +Once the build is completed, check the image stream tag to validate that the new image was pushed to the registry and image stream was updated. + + +``` +$ oc get imagestream go-hello-world +NAME DOCKER REPO TAGS UPDATED +go-hello-world docker-registry.default.svc:5000/golang-builder/go-hello-world 1.0 4 minutes ago +``` + +Make a note of the **DOCKER REPO** string for the image. It will be used in the next section to run the image. + +### Did we create a tiny, binary-only image? + +Finally, let's validate that we did, indeed, build a tiny image with just the binary. + +Check out the image details. First, get the image's name from the image stream. + + +``` +$ oc describe imagestream go-hello-world +Name: go-hello-world +Namespace: golang-builder +Created: 42 minutes ago +Labels: +Annotations: +Docker Pull Spec: docker-registry.default.svc:5000/golang-builder/go-hello-world +Image Lookup: local=false +Unique Images: 1 +Tags: 1 + +1.0 +no spec tag + +* docker-registry.default.svc:5000/golang-builder/go-hello-world@sha256:eb11e0147a2917312f5e0e9da71109f0cb80760e945fdc1e2db6424b91bc9053 +13 minutes ago +``` + +The image is listed at the bottom, described with the SHA hash (e.g., **sha256:eb11e0147a2917312f5e0e9da71109f0cb80760e945fdc1e2db6424b91bc9053** ; yours will be different). + +Get the details of the image using the hash. + + +``` +$ oc describe image sha256:eb11e0147a2917312f5e0e9da71109f0cb80760e945fdc1e2db6424b91bc9053 +Docker Image: docker-registry.default.svc:5000/golang-builder/go-hello-world@sha256:eb11e0147a2917312f5e0e9da71109f0cb80760e945fdc1e2db6424b91bc9053 +Name: sha256:eb11e0147a2917312f5e0e9da71109f0cb80760e945fdc1e2db6424b91bc9053 +Created: 15 minutes ago +Annotations: image.openshift.io/dockerLayersOrder=ascending +image.openshift.io/manifestBlobStored=true +openshift.io/image.managed=true +Image Size: 1.026MB +Image Created: 15 minutes ago +Author: +Arch: amd64 +Entrypoint: /app +Working Dir: +User: +Exposes Ports: +Docker Labels: io.openshift.build.name=go-hello-world-1 +io.openshift.build.namespace=golang-builder +Environment: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +OPENSHIFT_BUILD_NAME=go-hello-world-1 +OPENSHIFT_BUILD_NAMESPACE=golang-builder +``` + +Notice the image size, 1.026MB, is exactly as we want. The image is a scratch image with just the binary inside it! + +### Run a pod with the runtime image + +Using the runtime image we just created, let's create a pod on-demand and run it and validate that it still works. + +This almost never happens in Kubernetes/OKD, but we will run a pod, just a pod, by itself. + + +``` +$ oc run -it go-hello-world --image=docker-registry.default.svc:5000/golang-builder/go-hello-world:1.0 --restart=Never +Hello World! +``` + +Everything is working as expected—the image runs and outputs "Hello World!" just as it did in the previous, local S2I builds. + +By creating this workflow in OKD, we can use the golang-builder S2I image for any Go application. This builder image is in place and built for any other applications, and it will auto-update and rebuild itself anytime the upstream golang:1.12 image changes. + +New apps can be built automatically using the S2I build by creating a chain build strategy in OKD with an appimage BuildConfig to compile the source and the runtime BuildConfig to create the final image. Using the build triggers, any change to the source code in the Git repo will trigger a rebuild through the entire pipeline, rebuilding the appimage and the runtime image automatically. + +This is a great way to maintain updated images for any application. Paired with an OKD deploymentConfig with an image build trigger, long-running applications (e.g., webapps) will be automatically redeployed when new code is committed. + +Source-to-Image is an ideal way to develop builder images to build and compile Go applications in a repeatable way, and it just gets better when paired with OKD BuildConfigs. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/creating-source-image-build-pipeline-okd + +作者:[Chris Collins][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clcollins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/blocks_building.png?itok=eMOT-ire +[2]: https://opensource.com/article/19/5/source-image-golang-part-1 +[3]: https://opensource.com/article/19/5/source-image-golang-part-2 +[4]: https://opensource.com/article/19/5/source-image-golang-part-3 +[5]: https://www.okd.io/ +[6]: https://github.com/minishift/minishift +[7]: https://github.com/clcollins/golang-s2i.git +[8]: https://docs.okd.io/latest/architecture/core_concepts/builds_and_image_streams.html#image-streams +[9]: https://docs.okd.io/latest/dev_guide/managing_images.html#using-is-with-k8s +[10]: https://docs.okd.io/latest/dev_guide/builds/index.html#defining-a-buildconfig +[11]: https://github.com/clcollins/golang-s2i/blob/master/okd/buildConfig-golang-builder.yaml +[12]: mailto:collins.christopher@gmail.com +[13]: https://github.com/clcollins/goHelloWorld.git +[14]: https://opensource.com/sites/default/files/uploads/chainingbuilds.png (Chain Build workflow) +[15]: http://docs.projectatomic.io/container-best-practices/#_from_scratch diff --git a/sources/tech/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md b/sources/tech/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md new file mode 100644 index 0000000000..e3a533b3b2 --- /dev/null +++ b/sources/tech/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md @@ -0,0 +1,200 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server) +[#]: via: (https://www.linuxtechi.com/install-lemp-stack-fedora-30-server/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server +====== + +In this article, we’ll be looking at how to install **LEMP** stack on Fedora 30 Server. LEMP Stands for: + + * L -> Linux + * E -> Nginx + * M -> Maria DB + * P -> PHP + + + +I am assuming **[Fedora 30][1]** is already installed on your system. + +![LEMP-Stack-Fedora30][2] + +LEMP is a collection of powerful software setup that is installed on a Linux server to help in developing popular development platforms to build websites, LEMP is a variation of LAMP wherein instead of **Apache** , **EngineX (Nginx)** is used as well as **MariaDB** used in place of **MySQL**. This how-to guide is a collection of separate guides to install Nginx, Maria DB and PHP. + +### Install Nginx, PHP 7.3 and PHP-FPM on Fedora 30 Server + +Let’s take a look at how to install Nginx and PHP along with PHP FPM on Fedora 30 Server. + +### Step 1) Switch to root user + +First step in installing Nginx in your system is to switch to root user. Use the following command : + +``` +root@linuxtechi ~]$ sudo -i +[sudo] password for pkumar: +[root@linuxtechi ~]# +``` + +### Step 2) Install Nginx, PHP 7.3 and PHP FPM using dnf command + +Install Nginx using the following dnf command: + +``` +[root@linuxtechi ~]# dnf install nginx php php-fpm php-common -y +``` + +### Step 3) Install Additional PHP modules + +The default installation of PHP only comes with the basic and the most needed modules installed. If you need additional modules like GD, XML support for PHP, command line interface Zend OPCache features etc, you can always choose your packages and install everything in one go. See the sample command below: + +``` +[root@linuxtechi ~]# sudo dnf install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml -y +``` + +### Step 4) Start & Enable Nginx and PHP-fpm Service + +Start and enable Nginx service using the following command + +``` +[root@linuxtechi ~]# systemctl start nginx && systemctl enable nginx +Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service. +[root@linuxtechi ~]# +``` + +Use the following command to start and enable PHP-FPM service + +``` +[root@linuxtechi ~]# systemctl start php-fpm && systemctl enable php-fpm +Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service. +[root@linuxtechi ~]# +``` + +**Verify Nginx (Web Server) and PHP installation,** + +**Note:** In case OS firewall is enabled and running on your Fedora 30 system, then allow 80 and 443 ports using beneath commands, + +``` +[root@linuxtechi ~]# firewall-cmd --permanent --add-service=http +success +[root@linuxtechi ~]# +[root@linuxtechi ~]# firewall-cmd --permanent --add-service=https +success +[root@linuxtechi ~]# firewall-cmd --reload +success +[root@linuxtechi ~]# +``` + +Open the web browser, type the following URL: http:// + +[![Test-Page-HTTP-Server-Fedora-30][3]][4] + +Above screen confirms that NGINX is installed successfully. + +Now let’s verify PHP installation, create a test php page(info.php) using the beneath command, + +``` +[root@linuxtechi ~]# echo "" > /usr/share/nginx/html/info.php +[root@linuxtechi ~]# +``` + +Type the following URL in the web browser, + +http:///info.php + +[![Php-info-page-fedora30][5]][6] + +Above page confirms that PHP 7.3.5 has been installed successfully. Now let’s install MariaDB database server. + +### Install MariaDB on Fedora 30 + +MariaDB is a great replacement for MySQL DB as it is works much similar to MySQL and also compatible with MySQL steps too. Let’s look at the steps to install MariaDB on Fedora 30 Server + +### Step 1) Switch to Root User + +First step in installing MariaDB in your system is to switch to root user or you can use a local user who has root privilege. Use the following command below: + +``` +[root@linuxtechi ~]# sudo -i +[root@linuxtechi ~]# +``` + +### Step 2) Install latest version of MariaDB (10.3) using dnf command + +Use the following command to install MariaDB on Fedora 30 Server + +``` +[root@linuxtechi ~]# dnf install mariadb-server -y +``` + +### Step 3) Start and enable MariaDB Service + +Once the mariadb is installed successfully in step 2), next step is to start the MariaDB service. Use the following command: + +``` +[root@linuxtechi ~]# systemctl start mariadb.service ; systemctl enable mariadb.service +``` + +### Step 4) Secure MariaDB Installation + +When we install MariaDB server, so by default there is no root password, also anonymous users are created in database. So, to secure MariaDB installation, run the beneath “mysql_secure_installation” command + +``` +[root@linuxtechi ~]# mysql_secure_installation +``` + +Next you will be prompted with some question, just answer the questions as shown below: + +![Secure-MariaDB-Installation-Part1][7] + +![Secure-MariaDB-Installation-Part2][8] + +### Step 5) Test MariaDB Installation + +Once you have installed, you can always test if MariaDB is successfully installed on the server. Use the following command: + +``` +[root@linuxtechi ~]# mysql -u root -p +Enter password: +``` + +Next you will be prompted for a password. Enter the password same password that you have set during MariaDB secure installation, then you can see the MariaDB welcome screen. + +``` +Welcome to the MariaDB monitor. Commands end with ; or \g. +Your MariaDB connection id is 17 +Server version: 10.3.12-MariaDB MariaDB Server + +Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. + +Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. + +MariaDB [(none)]> +``` + +And finally, we’ve completed everything to install LEMP (Linux, Nginx, MariaDB and PHP) on your server successfully. Please post all your comments and suggestions in the feedback section below and we’ll respond back at the earliest. + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/install-lemp-stack-fedora-30-server/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/fedora-30-workstation-installation-guide/ +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/06/LEMP-Stack-Fedora30.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Test-Page-HTTP-Server-Fedora-30-1024x732.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Test-Page-HTTP-Server-Fedora-30.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Php-info-page-fedora30-1024x732.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Php-info-page-fedora30.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Secure-MariaDB-Installation-Part1.jpg +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Secure-MariaDB-Installation-Part2.jpg diff --git a/sources/tech/20190604 Aging in the open- How this community changed us.md b/sources/tech/20190604 Aging in the open- How this community changed us.md new file mode 100644 index 0000000000..a03d49eca2 --- /dev/null +++ b/sources/tech/20190604 Aging in the open- How this community changed us.md @@ -0,0 +1,135 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Aging in the open: How this community changed us) +[#]: via: (https://opensource.com/open-organization/19/6/four-year-celebration) +[#]: author: (Bryan Behrenshausen https://opensource.com/users/bbehrens) + +Aging in the open: How this community changed us +====== +Our community dedicated to exploring open organizational culture and +design turns four years old this week. +![Browser window with birthday hats and a cake][1] + +A community will always surprise you. + +That's not an easy statement for someone like me to digest. I'm not one for surprises. I revel in predictability. I thrive on consistency. + +A passionate and dedicated community offers few of these comforts. Participating in something like [the open organization community at Opensource.com][2]—which [turns four years old this week][3]—means acquiescing to dynamism, to constant change. Every day brings novelty. Every correspondence is packed with possibility. Every interaction reveals undisclosed pathways. + +To [a certain type of person][4] (me again), it can be downright terrifying. + +But that unrelenting and genuine surprise is the [very source of a community's richness][5], its sheer abundance. If a community is the nucleus of all those reactions that catalyze innovations and breakthroughs, then unpredictability and serendipity are its fuel. I've learned to appreciate it—more accurately, perhaps, to stand in awe of it. Four years ago, when the Opensource.com team heeded [Jim Whitehurst's call][6] to build a space for others to "share your thoughts and opinions… on how you think we can all lead and work better in the future" (see the final page of _The Open Organization_ ), we had little more than a mandate, a platform, and a vision. We'd be an open organization [committed to studying, learning from, and propagating open organizations][7]. The rest was a surprise—or rather, a series of surprises: + + * [Hundreds of articles, reviews, guides, and tutorials][2] on infusing open principles into organizations of all sizes across industries + * [A book series][8] spanning five volumes (with [another currently in production][9]) + * A detailed, comprehensive, community-maintained [definition of the "open organization" concept][10] + * A [robust maturity model][11] for anyone seeking to understand how that definition might (or might not) support their own work + + + +All of that—everything you see there, [and more][12]—is the work of a community that never stopped conversing, never ceased creating, never failed to outsmart itself. No one could have predicted it. No one could have [planned for it][13]. We simply do our best to keep up with it. + +And after four years the work continues, more focused and impassioned than ever. Remaining involved with this bunch of writers, educators, consultants, coaches, leaders, and mentors—all united by their belief that openness is the surest source of hope for organizations struggling to address the challenges of our age—has made me appreciate the power of the utterly surprising. I'm even getting a little more comfortable with it. + +That's been its gift to me. But the gifts it has given each of its participants have been equally special. + +As we celebrate four years of challenges, collaboration, and camaraderie this week, let's recount those surprising gifts by hearing from some of the members: + +* * * + +Four years of the open organization community—congratulations to all! + +My first thought was to look at the five most-read articles over the past four years. Here they are: + + * [5 laws every aspiring DevOps engineer should know][14] + * [What value do you bring to your company?][15] + * [8 answers to management questions from an open point of view][16] + * [What to do when you're feeling underutilized][17] + * [What's the point of DevOps?][18] + + + +All great articles. And then I started to think: Of all the great content over the past four years, which articles have impacted me the most? + +I remembered reading several great articles about meetings and how to make them more effective. So I typed "opensource.com meetings" into my search engine, and these two wonderful articles were at the top of the results list: + + * [The secret to better one-on-one meetings][19] + * [Time to rethink your team's approach to meetings][20] + + + +Articles like that have inspired my favorite open organization management principle, which I've tried to apply and has made a huge difference: All meetings are optional. + +**—Jeff Mackanic, senior director, Marketing, Red Hat** + +* * * + +Being a member of the "open community" has reminded me of the power of getting things done via values and shared purpose without command and control—something that seems more important than ever in today's fragmented and often abusive management world, and at a time when truth and transparency themselves are under attack. + +Four years is a long journey for this kind of initiative—but there's still so much to learn and understand about what makes "open" work and what it will take to accelerate the embrace of its principles more widely through different domains of work and society. Congratulations on all you, your colleagues, partners, and other members of the community have done thus far! + +**—Brook Manville, Principal, Brook Manville LLC, author of _A Company of Citizens_ and co-author of _The Harvard Business Review Leader's Handbook_** + +* * * + +The Open Organization Ambassador program has, in the last four years, become an inspired community of experts. We have defined what it means to be a truly open organization. We've written books, guides, articles, and other resources for learning about, understanding, and implementing open principles. We've done this while bringing open principles to other communities, and we've done this together. + +For me, personally and professionally, the togetherness is the best part of this endeavor. I have learned so much from my colleagues. I'm absolutely ecstatic to be one of the idealists and activists in this community—committed to making our workplaces more equitable and open. + +**—Laura Hilliger, co-founder, We Are Open Co-Op, and[Open Organization Ambassador][21]** + +* * * + +Finding the open organization community opened me up to knowing that there are others out there who thought as I did. I wasn't alone. My ideas on leadership and the workplace were not crazy. This sense of belonging increased once I joined the Ambassador team. Our monthly meetings are never long enough. I don't like when we have to hang up because each session is full of laughter, sharpening each other, idea exchange, and joy. Humans seek community. We search for people who share values and ideals as we do but who also push back and help us expand. This is the gift of the open organization community—expansion, growth, and lifelong friendships. Thank you to all of those who contribute their time, intellect, content, and whole self to this awesome think tank that is changing the shape of how we organize to solve problems! + +**—Jen Kelchner, founder and Chief Change Architect, LDR21, and[Open Organization Ambassador][21]** + +* * * + +Happy fourth birthday, open organization community! Thank you for being an ever-present reminder in my life that being open is better than being closed, that listening is more fruitful than telling, and that together we can achieve more. + +**—Michael Doyle, professional coach and[Open Organization Ambassador][21]** + +* * * + +Wow, what a journey it's been exploring the world of open organizations. We're seeing more interest now than ever before. It's amazing to see what this community has done and I'm excited to see what the future holds for open organizations and open leadership. + +**—Jason Hibbets, senior community architect, Red Hat** + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/19/6/four-year-celebration + +作者:[Bryan Behrenshausen][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bbehrens +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/happy_birthday_anniversary_celebrate_hats_cake.jpg?itok=Zfsv6DE_ (Browser window with birthday hats and a cake) +[2]: https://opensource.com/open-organization +[3]: https://opensource.com/open-organization/15/5/introducing-open-organization +[4]: https://opensource.com/open-organization/18/11/design-communities-personality-types +[5]: https://opensource.com/open-organization/18/1/why-build-community-1 +[6]: https://www.redhat.com/en/explore/the-open-organization-book +[7]: https://opensource.com/open-organization/resources/ambassadors-program +[8]: https://opensource.com/open-organization/resources/book-series +[9]: https://opensource.com/open-organization/19/5/educators-guide-project +[10]: https://opensource.com/open-organization/resources/open-org-definition +[11]: https://opensource.com/open-organization/resources/open-org-maturity-model +[12]: https://opensource.com/open-organization/resources +[13]: https://opensource.com/open-organization/19/2/3-misconceptions-agile +[14]: https://opensource.com/open-organization/17/5/5-devops-laws +[15]: https://opensource.com/open-organization/15/7/what-value-do-you-bring-your-company +[16]: https://opensource.com/open-organization/16/5/open-questions-and-answers-about-open-management +[17]: https://opensource.com/open-organization/17/4/feeling-underutilized +[18]: https://opensource.com/open-organization/17/5/what-is-the-point-of-DevOps +[19]: https://opensource.com/open-organization/18/5/open-one-on-one-meetings-guide +[20]: https://opensource.com/open-organization/18/3/open-approaches-meetings +[21]: https://opensource.com/open-organization/resources/meet-ambassadors diff --git a/sources/tech/20190604 Create a CentOS homelab in an hour.md b/sources/tech/20190604 Create a CentOS homelab in an hour.md new file mode 100644 index 0000000000..039af752db --- /dev/null +++ b/sources/tech/20190604 Create a CentOS homelab in an hour.md @@ -0,0 +1,224 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Create a CentOS homelab in an hour) +[#]: via: (https://opensource.com/article/19/6/create-centos-homelab-hour) +[#]: author: (Bob Murphy https://opensource.com/users/murph) + +Create a CentOS homelab in an hour +====== +Set up a self-sustained set of basic Linux servers with nothing more +than a system with virtualization software, a CentOS ISO, and about an +hour of your time. +![metrics and data shown on a computer screen][1] + +When working on new Linux skills (or, as I was, studying for a Linux certification), it is helpful to have a few virtual machines (VMs) available on your laptop so you can do some learning on the go. + +But what happens if you are working somewhere without a good internet connection and you want to work on a web server? What about using other software that you don't already have installed? If you were depending on downloading it from the distribution's repositories, you may be out of luck. With a bit of preparation, you can set up a [homelab][2] that will allow you to install anything you need wherever you are, with or without a network connection. + +The requirements are: + + * A downloaded ISO file of the Linux distribution you intend to use (for example, CentOS, Red Hat, etc.) + * A host computer with virtualization. I use [Fedora][3] with [KVM][4] and [virt-manager][5], but any Linux will work similarly. You could even use Windows or Mac with virtualization, with some difference in implementation + * About an hour of time + + + +### 1\. Create a VM for your repo host + +Use virt-manager to create a VM with modest specs; 1GB RAM, one CPU, and 16GB of disk space are plenty. + +Install [CentOS 7][6] on the VM. + +![Installing a CentOS homelab][7] + +Select your language and continue. + +Click _Installation Destination_ , select your local disk, mark the _Automatically Configure Partitioning_ checkbox, and click *Done *in the upper-left corner. + +Under _Software Selection_ , select _Infrastructure Server_ , mark the _FTP Server_ checkbox, and click _Done_. + +![Installing a CentOS homelab][8] + +Select _Network and Host Name_ , enable Ethernet in the upper-right, then click _Done_ in the upper-left corner. + +Click _Begin Installation_ to start installing the OS. + +You must create a root password, then you can create a user with a password as it installs. + +### 2\. Start the FTP service + +The next step is to start and set the FTP service to run and allow it through the firewall. + +Log in with your root password, then start the FTP server: + + +``` +`systemctl start vsftpd` +``` + +Enable it to work on every start: + + +``` +`systemctl enable vsftpd` +``` + +Set the port as allowed through the firewall: + + +``` +`firewall-cmd --add-service=ftp --perm` +``` + +Enable this change immediately: + + +``` +`firewall-cmd --reload` +``` + +Get your IP address: + + +``` +`ip a` +``` + +(it's probably **eth0** ). You'll need it in a minute. + +### 3\. Copy the files for your local repository + +Mount the CD you installed from to your VM through your virtualization software. + +Create a directory for the CD to be mounted to temporarily: + + +``` +`mkdir /root/temp` +``` + +Mount the install CD: + + +``` +`mount /dev/cdrom /root/temp` +``` + +Copy all the files to the FTP server directory: + + +``` +`rsync -avhP /root/temp/ /var/ftp/pub/` +``` + +### 4\. Point the server to the local repository + +Red Hat-based systems use files that end in **.repo** to identify where to get updates and new software. Those files can be found at + + +``` +`cd /etc/yum.repos.d` +``` + +You need to get rid of the repo files that point your server to look to the CentOS repositories on the internet. I prefer to copy them to root's home directory to get them out of the way: + + +``` +`mv * ~` +``` + +Then create a new repo file to point to your server. Use your favorite text editor to create a file named **network.repo** with the following lines (substituting the IP address you got in step 2 for _< your IP>_), then save it: + + +``` +[network] +name=network +baseurl=/pub +gpgcheck=0 +``` + +When that's done, we can test it out with the following: + + +``` +`yum clean all; yum install ftp` +``` + +If your FTP client installs as expected from the "network" repository, your local repo is set up! + +![Installing a CentOS homelab][9] + +### 5\. Install a new VM with the repository you set up + +Go back to the virtual machine manager, and create another VM—but this time, select _Network Install_ with a URL of: + + +``` +`ftp://192.168.122./pub` +``` + +If you're using a different host OS or virtualization manager, install your VM similarly as before, and skip to the next section. + +### 6\. Set the new VM to use your existing network repository + +You can copy the repo file from your existing server to use here. + +As in the first server example, enter: + + +``` +cd /etc/yum.repos.d +mv * ~ +``` + +Then: + + +``` +`scp root@192.168.122.:/etc/yum.repos.d/network.repo /etc/yum.repos.d` +``` + +Now you should be ready to work with your new VM and get all your software from your local repository. + +Test this again: + + +``` +`yum clean all; yum install screen` +``` + +This will install your software from your local repo server. + +This setup, which gives you independence from the network with the ability to install software, can create a much more dependable environment for expanding your skills on the road. + +* * * + +_Bob Murphy will present this topic as well as an introduction to[GNU Screen][10] at [Southeast Linux Fest][11], June 15-16 in Charlotte, N.C._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/create-centos-homelab-hour + +作者:[Bob Murphy][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/murph +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen) +[2]: https://opensource.com/article/19/3/home-lab +[3]: https://getfedora.org/ +[4]: https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine +[5]: https://virt-manager.org/ +[6]: https://www.centos.org/download/ +[7]: https://opensource.com/sites/default/files/uploads/homelab-3b_0.png (Installing a CentOS homelab) +[8]: https://opensource.com/sites/default/files/uploads/homelab-5b.png (Installing a CentOS homelab) +[9]: https://opensource.com/sites/default/files/uploads/homelab-14b.png (Installing a CentOS homelab) +[10]: https://opensource.com/article/17/3/introduction-gnu-screen +[11]: https://southeastlinuxfest.org/ diff --git a/sources/tech/20190604 ExamSnap Guide- 6 Excellent Resources for Microsoft 98-366- Networking Fundamentals Exam.md b/sources/tech/20190604 ExamSnap Guide- 6 Excellent Resources for Microsoft 98-366- Networking Fundamentals Exam.md new file mode 100644 index 0000000000..97414f530f --- /dev/null +++ b/sources/tech/20190604 ExamSnap Guide- 6 Excellent Resources for Microsoft 98-366- Networking Fundamentals Exam.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (ExamSnap Guide: 6 Excellent Resources for Microsoft 98-366: Networking Fundamentals Exam) +[#]: via: (https://www.2daygeek.com/examsnap-guide-6-excellent-resources-for-microsoft-98-366-networking-fundamentals-exam/) +[#]: author: (2daygeek http://www.2daygeek.com/author/2daygeek/) + +ExamSnap Guide: 6 Excellent Resources for Microsoft 98-366: Networking Fundamentals Exam +====== + +The Microsoft 98-366 exam is almost similar to the CompTIA Network+ certification test when it comes to its content. + +It is also known as Networking Fundamentals, and its purpose is to assess your knowledge of switches, routers, OSI models, wide area and local area networks, wireless networking, and IP addressing. + +Those who pass the exam earn the MTA (Microsoft Technology Associate) certificate. This certifications an ideal entry-level credential to help you begin your IT career. + +### 6 Resources for Microsoft MTA 98-366 Exam + +Using approved training materials is the best method to prepare for your certification exam. Most candidates are fond of shortcuts and often use PDFs and brain dumps to prepare for the test. + +It is important to note that these materials need additional study methods. They will not help you gain better knowledge that is meant to make you perform better at work. + +When you take your time to master the course contents of a certification exam, you are not only getting ready for the test but also developing your skills, expertise, and knowledge in the topics covered there. + + * **[ExamSnap][1]** + + + +Another important point to note is that you shouldn’t rely only on brain dumps. Microsoft can withhold or withdraw your certification if it is discovered that you have cheated. + +This may also result in the situation when a person is not allowed to earn the credentials any more. Thus, use only verified platforms such as Examsnap. + +Most people tend to believe that there is no way they can get discovered. However, you need to know that Microsoft has been offering professional certification exams for years and they know what they are doing. + +Now when we have established the importance of using legal materials to prepare for your certification exam, we need to highlight the top resources you can use to prepare for the Microsoft 98-366 test. + +### 1\. Microsoft Video Academy + +The MVA (Microsoft Video Academy) provides you with introductory lessons on the 98-366 certification exam.This is not sufficient for your study although it is a great way to begin your preparation for the test. The materials in the video do not cover everything you need to know before taking the exam. + +In fact, it is introductory series that is meant to lay down the foundation for your study. You will have to explore other materials for you to get an in-depth knowledge of the topics. + +These videos are available without payment, so you can easily access them and use whenever you want. + + * [Microsoft Certification Overview][2] + + + +### 2\. Examsnap + +If you have been looking for material that can help you prepare for the Microsoft Networking Fundamentals exam, look no further because you will know about Examsnap now. + +It is an online platform that provides you with exam dumps and video series of various certification courses. All you need to do is to register on the website and pay a fee for you to be able to access various tools that will help you prepare for the test. + +Examsnap will enable you to pass your exams with confidence by providing you with the most accurate and comprehensive preparation materials on the Internet. The platform also has training courses to help you improve your study. + +Before making any payment on the site, you can complete the trial course to establish whether the site is suitable for your exam preparation needs. + +### 3\. Exam 98-366: MTA Networking Fundamentals + +This is a study resource that is a book. It provides you with a comprehensive approach to the various topics. It is important for you to note that this study guide is critical to your success. + +It offers you more detailed material than the introductory lectures by the MVA. It is advisable that you do not focus on the sample questions in each part when using this book. + +You should not concentrate on the sample questions because they are not so informative. You can make up for this shortcoming by checking out other practice test options. Overall, this book is a top resource that will contribute greatly to your certification exam success. + +### 4\. Measure-Up + +Measure-Up is the official Microsoft practice test provider whereby you can access different materials. You can get a lab and hands-on practice with networking software tools, which are very beneficial for your preparation. The site also has study questions that you can purchase. + +### 5\. U-Certify + +The U-Certify platform is a reputable organization that offers video courses that are considered to be more understandable than those offered by the MVA. In addition to video courses, the site presents flashcards at the end of the videos. + +You can also access a series of practice tests, which contain several hundreds of study questions on the platform. There are more contents in videos and tests that you can access the moment you subscribe. Depending on what you are looking for, you can choose to buy the tests or the videos. + +### 6\. Networking Essentials – Wiki + +There are several posts that are linked to the Networking Essentials page on Wiki, and you can be sure that these articles are greatly detailed with information that will be helpful for your exam preparation. + +It is important to note that they are not meant to be studied as the only resource materials. You should only use them as additional means for the purpose of getting more information on specific topics but not as an individual study tool. + +### Conclusion + +You may not be able to access all the top resources available. However, you can access some of them. In addition to the resources mentioned, there are also some others that are very good. Visit the Microsoft official website to get the list of reliable resource platforms you can use. Study and be well-prepared for the 98-366 certification exam! + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/examsnap-guide-6-excellent-resources-for-microsoft-98-366-networking-fundamentals-exam/ + +作者:[2daygeek][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.2daygeek.com/author/2daygeek/ +[b]: https://github.com/lujun9972 +[1]: https://www.examsnap.com/ +[2]: https://www.microsoft.com/en-us/learning/certification-overview.aspx diff --git a/sources/tech/20190604 Four Ways To Install Security Updates On Red Hat (RHEL) And CentOS Systems.md b/sources/tech/20190604 Four Ways To Install Security Updates On Red Hat (RHEL) And CentOS Systems.md new file mode 100644 index 0000000000..ebe841dbcb --- /dev/null +++ b/sources/tech/20190604 Four Ways To Install Security Updates On Red Hat (RHEL) And CentOS Systems.md @@ -0,0 +1,174 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Four Ways To Install Security Updates On Red Hat (RHEL) And CentOS Systems?) +[#]: via: (https://www.2daygeek.com/install-security-updates-on-redhat-rhel-centos-system/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +Four Ways To Install Security Updates On Red Hat (RHEL) And CentOS Systems? +====== + +Patching of the Linux server is one of important and routine task of Linux admin. + +Keeping the system with latest patch level is must. It protects your system against unnecessary attack. + +There are three kind of erratas available in the RHEL/CentOS repository, these are Security, Bug Fix and Product Enhancement. + +Now, you have two options to handle this. + +Either install only security updates or all the errata packages. + +We have already written an article in the past **[to check available security updates?][1]**. + +Also, **[check the installed security updates on your system][2]** using this link. + +You can navigate to the above link, if you would like to verify available security updates before installing them. + +In this article, we will show your, how to install security updates in multiple ways on RHEL and CentOS system. + +### 1) How To Install Entire Errata Updates In Red Hat And CentOS System? + +Run the following command to download and apply all available security updates on your system. + +Make a note, this command will install the last available version of any package with at least one security errata. + +Also, install non-security erratas if they provide a more updated version of the package. + +``` +# yum update --security + +Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock +RHEL7-Server-DVD | 4.3 kB 00:00:00 +rhel-7-server-rpms | 2.0 kB 00:00:00 +--> 1:grub2-tools-extra-2.02-0.76.el7.1.x86_64 from rhel-7-server-rpms removed (updateinfo) +--> nss-pem-1.0.3-5.el7_6.1.x86_64 from rhel-7-server-rpms removed (updateinfo) +. +35 package(s) needed (+0 related) for security, out of 115 available +Resolving Dependencies +--> Running transaction check +---> Package NetworkManager.x86_64 1:1.12.0-6.el7 will be updated +---> Package NetworkManager.x86_64 1:1.12.0-10.el7_6 will be an update +``` + +Once you ran the above command, it will check all the available updates and its dependency satisfaction. + +``` +--> Finished Dependency Resolution +--> Running transaction check +---> Package kernel.x86_64 0:3.10.0-514.26.1.el7 will be erased +---> Package kernel-devel.x86_64 0:3.10.0-514.26.1.el7 will be erased +--> Finished Dependency Resolution + +Dependencies Resolved +===================================================================================================================================================================== +Package Arch Version Repository Size +===================================================================================================================================================================== +Installing: +kernel x86_64 3.10.0-957.10.1.el7 rhel-7-server-rpms 48 M +kernel-devel x86_64 3.10.0-957.10.1.el7 rhel-7-server-rpms 17 M +Updating: +NetworkManager x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms 1.7 M +NetworkManager-adsl x86_64 1:1.12.0-10.el7_6 rhel-7-server-rpms 157 k +. +Removing: +kernel x86_64 3.10.0-514.26.1.el7 @rhel-7-server-rpms 148 M +kernel-devel x86_64 3.10.0-514.26.1.el7 @rhel-7-server-rpms 34 M +``` + +If these dependencies were satisfied, which finally gives you a total summary about it. + +The transaction summary shows, how many packages will be getting Installed, upgraded and removed from the system. + +``` +Transaction Summary +===================================================================================================================================================================== +Install 2 Packages +Upgrade 33 Packages +Remove 2 Packages + +Total download size: 124 M +Is this ok [y/d/N]: +``` + +### How To Install Only Security Updates In Red Hat And CentOS System? + +Run the following command to install only the packages that have a security errata. + +``` +# yum update-minimal --security + +Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock +rhel-7-server-rpms | 2.0 kB 00:00:00 +Resolving Dependencies +--> Running transaction check +---> Package NetworkManager.x86_64 1:1.12.0-6.el7 will be updated +---> Package NetworkManager.x86_64 1:1.12.0-8.el7_6 will be an update +. +--> Finished Dependency Resolution +--> Running transaction check +---> Package kernel.x86_64 0:3.10.0-514.26.1.el7 will be erased +---> Package kernel-devel.x86_64 0:3.10.0-514.26.1.el7 will be erased +--> Finished Dependency Resolution + +Dependencies Resolved +===================================================================================================================================================================== +Package Arch Version Repository Size +===================================================================================================================================================================== +Installing: +kernel x86_64 3.10.0-957.10.1.el7 rhel-7-server-rpms 48 M +kernel-devel x86_64 3.10.0-957.10.1.el7 rhel-7-server-rpms 17 M +Updating: +NetworkManager x86_64 1:1.12.0-8.el7_6 rhel-7-server-rpms 1.7 M +NetworkManager-adsl x86_64 1:1.12.0-8.el7_6 rhel-7-server-rpms 157 k +. +Removing: +kernel x86_64 3.10.0-514.26.1.el7 @rhel-7-server-rpms 148 M +kernel-devel x86_64 3.10.0-514.26.1.el7 @rhel-7-server-rpms 34 M + +Transaction Summary +===================================================================================================================================================================== +Install 2 Packages +Upgrade 33 Packages +Remove 2 Packages + +Total download size: 124 M +Is this ok [y/d/N]: +``` + +### How To Install Security Update Using CVE reference In Red Hat And CentOS System? + +If you would like to install a security update using a CVE reference, run the following command. + +``` +# yum update --cve + +# yum update --cve CVE-2008-0947 +``` + +### How To Install Security Update Using Specific Advisory In Red Hat And CentOS System? + +Run the following command, if you want to apply only a specific advisory. + +``` +# yum update --advisory= + +# yum update --advisory=RHSA-2014:0159 +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/install-security-updates-on-redhat-rhel-centos-system/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/check-list-view-find-available-security-updates-on-redhat-rhel-centos-system/ +[2]: https://www.2daygeek.com/check-installed-security-updates-on-redhat-rhel-and-centos-system/ diff --git a/sources/tech/20190604 Linux Shell Script To Monitor CPU Utilization And Send Email.md b/sources/tech/20190604 Linux Shell Script To Monitor CPU Utilization And Send Email.md new file mode 100644 index 0000000000..f1cb86573b --- /dev/null +++ b/sources/tech/20190604 Linux Shell Script To Monitor CPU Utilization And Send Email.md @@ -0,0 +1,178 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Linux Shell Script To Monitor CPU Utilization And Send Email) +[#]: via: (https://www.2daygeek.com/linux-shell-script-to-monitor-cpu-utilization-usage-and-send-email/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +Linux Shell Script To Monitor CPU Utilization And Send Email +====== + +There are many opensource monitoring tools are available to monitor Linux systems performance. + +It will send an email alert when the system reaches the given threshold limit. + +It monitors everything such as CPU utilization, Memory utilization, swap utilization, disk space utilization and much more. + +If you only have few systems and want to monitor them then writing a small shell script can achieve this. + +In this tutorial we have added two shell script to monitor CPU utilization on Linux system. + +When the system reaches the given threshold then it will trigger a mail to corresponding email id. + +### Method-1 : Linux Shell Script To Monitor CPU Utilization And Send an Email + +If you want to only get CPU utilization percentage through mail when the system reaches the given threshold, use the following script. + +This is very simple and straightforward and one line script. + +It will trigger an email when your system reaches `80%` CPU utilization. + +``` +*/5 * * * * /usr/bin/cat /proc/loadavg | awk '{print $1}' | awk '{ if($1 > 80) printf("Current CPU Utilization is: %.2f%\n"), $0;}' | mail -s "High CPU Alert" [email protected] +``` + +**Note:** You need to change the email id instead of ours. Also, you can change the CPU utilization threshold value as per your requirement. + +**Output:** You will be getting an email alert similar to below. + +``` +Current CPU Utilization is: 80.40% +``` + +We had added many useful shell scripts in the past. If you want to check those, navigate to the below link. + + * **[How to automate day to day activities using shell scripts?][1]** + + + +### Method-2 : Linux Shell Script To Monitor CPU Utilization And Send an Email + +If you want to get more information about the CPU utilization in the mail alert. + +Then use the following script, which includes top CPU utilization process details based on the top Command and ps Command. + +This will inconstantly gives you an idea what is going on your system. + +It will trigger an email when your system reaches `80%` CPU utilization. + +**Note:** You need to change the email id instead of ours. Also, you can change the CPU utilization threshold value as per your requirement. + +``` +# vi /opt/scripts/cpu-alert.sh + +#!/bin/bash +cpuuse=$(cat /proc/loadavg | awk '{print $1}') + +if [ "$cpuuse" > 80 ]; then + +SUBJECT="ATTENTION: CPU Load Is High on $(hostname) at $(date)" + +MESSAGE="/tmp/Mail.out" + +TO="[email protected]" + + echo "CPU Current Usage is: $cpuuse%" >> $MESSAGE + + echo "" >> $MESSAGE + + echo "+------------------------------------------------------------------+" >> $MESSAGE + + echo "Top CPU Process Using top command" >> $MESSAGE + + echo "+------------------------------------------------------------------+" >> $MESSAGE + + echo "$(top -bn1 | head -20)" >> $MESSAGE + + echo "" >> $MESSAGE + + echo "+------------------------------------------------------------------+" >> $MESSAGE + + echo "Top CPU Process Using ps command" >> $MESSAGE + + echo "+------------------------------------------------------------------+" >> $MESSAGE + + echo "$(ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10)" >> $MESSAGE + + mail -s "$SUBJECT" "$TO" < $MESSAGE + + rm /tmp/Mail.out + + fi +``` + +Finally add a **[cronjob][2]** to automate this. It will run every 5 minutes. + +``` +# crontab -e +*/10 * * * * /bin/bash /opt/scripts/cpu-alert.sh +``` + +**Note:** You will be getting an email alert 5 mins later since the script has scheduled to run every 5 minutes (But it's not exactly 5 mins and it depends the timing). + +Say for example. If your system reaches the limit at 8.25 then you will get an email alert in another 5 mins. Hope it's clear now. + +**Output:** You will be getting an email alert similar to below. + +``` +CPU Current Usage is: 80.51% + ++------------------------------------------------------------------+ +Top CPU Process Using top command ++------------------------------------------------------------------+ +top - 13:23:01 up 1:43, 1 user, load average: 2.58, 2.58, 1.51 +Tasks: 306 total, 3 running, 303 sleeping, 0 stopped, 0 zombie +%Cpu0 : 6.2 us, 6.2 sy, 0.0 ni, 87.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu1 : 18.8 us, 0.0 sy, 0.0 ni, 81.2 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu2 : 50.0 us, 37.5 sy, 0.0 ni, 12.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu3 : 5.9 us, 5.9 sy, 0.0 ni, 88.2 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu4 : 0.0 us, 5.9 sy, 0.0 ni, 94.1 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu5 : 29.4 us, 23.5 sy, 0.0 ni, 47.1 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu6 : 0.0 us, 5.9 sy, 0.0 ni, 94.1 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu7 : 5.9 us, 0.0 sy, 0.0 ni, 94.1 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +KiB Mem : 16248588 total, 223436 free, 5816924 used, 10208228 buff/cache +KiB Swap: 17873388 total, 17871340 free, 2048 used. 7440884 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 8867 daygeek 20 2743884 440420 360952 R 100.0 2.7 1:07.25 /usr/lib/virtualbox/VirtualBoxVM --comment CentOS7 --startvm 002f47b8-2af2-48f5-be1d-67b67e03514c --no-startvm-errormsgbox + 9119 daygeek 20 36136 784 R 46.7 0.0 0:00.07 /usr/bin/CROND -n + 1057 daygeek 20 889808 487692 461692 S 13.3 3.0 4:21.12 /usr/lib/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -nolisten tcp -background none -noreset -keeptty -verbose 3 + 3098 daygeek 20 1929012 351412 120532 S 13.3 2.2 16:42.51 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 9236 -prefMapSize 184485 -parentBuildID 20190521202118 -greomni /us+ + 1 root 20 188820 10144 7708 S 6.7 0.1 0:06.92 /sbin/init + 818 gdm 20 199836 25120 15876 S 6.7 0.2 0:01.85 /usr/lib/Xorg vt1 -displayfd 3 -auth /run/user/120/gdm/Xauthority -nolisten tcp -background none -noreset -keeptty -verbose 3 + 1170 daygeek 9 -11 2676516 16516 12520 S 6.7 0.1 1:28.30 /usr/bin/pulseaudio --daemonize=no + 8271 root 20 I 6.7 0:00.21 [kworker/u16:4-i915] + 9117 daygeek 20 13528 4036 3144 R 6.7 0.0 0:00.01 top -bn1 + ++------------------------------------------------------------------+ +Top CPU Process Using ps command ++------------------------------------------------------------------+ +%CPU PID USER COMMAND + 8.8 8522 daygeek /usr/lib/virtualbox/VirtualBox +86.2 8867 daygeek /usr/lib/virtualbox/VirtualBoxVM --comment CentOS7 --startvm 002f47b8-2af2-48f5-be1d-67b67e03514c --no-startvm-errormsgbox +76.1 8921 daygeek /usr/lib/virtualbox/VirtualBoxVM --comment Ubuntu-18.04 --startvm e8c32dbb-8b01-41b0-977a-bf28b9db1117 --no-startvm-errormsgbox + 5.5 8080 daygeek /usr/bin/nautilus --gapplication-service + 4.7 4575 daygeek /usr/lib/firefox/firefox -contentproc -childID 12 -isForBrowser -prefsLen 9375 -prefMapSize 184485 -parentBuildID 20190521202118 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1525 true tab + 4.4 3511 daygeek /usr/lib/firefox/firefox -contentproc -childID 8 -isForBrowser -prefsLen 9308 -prefMapSize 184485 -parentBuildID 20190521202118 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1525 true tab + 4.4 3190 daygeek /usr/lib/firefox/firefox -contentproc -childID 7 -isForBrowser -prefsLen 9237 -prefMapSize 184485 -parentBuildID 20190521202118 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1525 true tab + 4.4 1612 daygeek /usr/lib/firefox/firefox -contentproc -childID 1 -isForBrowser -prefsLen 1 -prefMapSize 184485 -parentBuildID 20190521202118 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1525 true tab + 4.2 3565 daygeek /usr/bin/../lib/notepadqq/notepadqq-bin +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-shell-script-to-monitor-cpu-utilization-usage-and-send-email/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/category/shell-script/ +[2]: https://www.2daygeek.com/crontab-cronjob-to-schedule-jobs-in-linux/ diff --git a/sources/tech/20190605 Tweaking the look of Fedora Workstation with themes.md b/sources/tech/20190605 Tweaking the look of Fedora Workstation with themes.md new file mode 100644 index 0000000000..441415925f --- /dev/null +++ b/sources/tech/20190605 Tweaking the look of Fedora Workstation with themes.md @@ -0,0 +1,140 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Tweaking the look of Fedora Workstation with themes) +[#]: via: (https://fedoramagazine.org/tweaking-the-look-of-fedora-workstation-with-themes/) +[#]: author: (Ryan Lerch https://fedoramagazine.org/author/ryanlerch/) + +Tweaking the look of Fedora Workstation with themes +====== + +![][1] + +Changing the theme of a desktop environment is a common way to customize your daily experience with Fedora Workstation. This article discusses the 4 different types of visual themes you can change and how to change to a new theme. Additionally, this article will cover how to install new themes from both the Fedora repositories and 3rd party theme sources. + +### Theme Types + +When changing the theme of Fedora Workstation, there are 4 different themes that can be changed independently of each other. This allows a user to mix and match the theme types to customize their desktop in a multitude of combinations. The 4 theme types are the **Application** (GTK) theme, the **shell** theme, the **icon** theme, and the **cursor** theme. + +#### Application (GTK) themes + +As the name suggests, Application themes change the styling of the applications that are displayed on a user’s desktop. Application themes control the style of the window borders and the window titlebar. Additionally, they also control the style of the widgets in the windows — like dropdowns, text inputs, and buttons. One point to note is that an application theme does not change the icons that are displayed in an application — this is achieved using the icon theme. + +![Two application windows with two different application themes. The default Adwaita theme on the left, the Adapta theme on the right.][2] + +Application themes are also known as GTK themes, as GTK ( **G** IMP **T** ool **k** it) is the underlying technology that is used to render the windows and user interface widgets in those windows on Fedora Workstation. + +#### Shell Themes + +Shell themes change the appearance of the GNOME Shell. The GNOME Shell is the technology that displays the top bar (and the associated widgets like drop downs), as well as the overview screen and the applications list it contains. + +![Comparison of two Shell themes, with the Fedora Workstation default on top, and the Adapta shell theme on the bottom.][3] + +#### Icon Themes + +As the name suggests, icon themes change the icons used in the desktop. Changing the icon theme will change the icons displayed both in the Shell, and in applications. + +![Comparison of two icon themes, with the Fedora 30 Workstation default Adwaita on the left, and the Yaru icon theme on the right][4] + +One important item to note with icon themes is that all icon themes will not have customized icons for all application icons. Consequently, changing the icon theme will not change all the icons in the applications list in the overview. + +![Comparison of two icon themes, with the Fedora 30 Workstation default Adwaita on the top, and the Yaru icon theme on the bottom][5] + +#### Cursor Theme + +The cursor theme allows a user to change how the mouse pointer is displayed. Most cursor themes change all the common cursors, including the pointer, drag handles and the loading cursor. + +![Comparison of multiple cursors of two different cursor themes. Fedora 30 default is on the left, the Breeze Snow theme on the right.][6] + +### Changing the themes + +Changing themes on Fedora Workstation is a simple process. To change all 4 types of themes, use the **Tweaks** application. Tweaks is a tool used to change a range of different options in Fedora Workstation. It is not installed by default, and is installed using the Software application: + +![][7] + +Alternatively, install Tweaks from the command line with the command: + +``` +sudo dnf install gnome-tweak-tool +``` + +In addition to Tweaks, to change the Shell theme, the **User Themes** GNOME Shell Extension needs to be installed and enabled. [Check out this post for more details on installing extensions][8]. + +Next, launch Tweaks, and switch to the Appearance pane. The Themes section in the Appearance pane allows the changing of the multiple theme types. Simply choose the theme from the dropdown, and the new theme will apply automatically. + +![][9] + +### Installing themes + +Armed with the knowledge of the types of themes, and how to change themes, it is time to install some themes. Broadly speaking, there are two ways to install new themes to your Fedora Workstation — installing theme packages from the Fedora repositories, or manually installing a theme. One point to note when installing themes, is that you may need to close and re-open the Tweaks application to make a newly installed theme appear in the dropdowns. + +#### Installing from the Fedora repositories + +The Fedora repositories contain a small selection of additional themes that once installed are available to we chosen in Tweaks. Theme packages are not available in the Software application, and have to be searched for and installed via the command line. Most theme packages have a consistent naming structure, so listing available themes is pretty easy. + +To find Application (GTK) themes use the command: + +``` +dnf search gtk | grep theme +``` + +To find Shell themes: + +``` +dnf search shell-theme +``` + +Icon themes: + +``` +dnf search icon-theme +``` + +Cursor themes: + +``` +dnf search cursor-theme +``` + +Once you have found a theme to install, install the theme using dnf. For example: + +``` +sudo dnf install numix-gtk-theme +``` + +#### Installing themes manually + +For a wider range of themes, there are a plethora of places on the internet to find new themes to use on Fedora Workstation. Two popular places to find themes are [OpenDesktop][10] and [GNOMELook][11]. + +Typically when downloading themes from these sites, the themes are encapsulated in an archive like a tar.gz or zip file. In most cases, to install these themes, simply extract the contents into the correct directory, and the theme will appear in Tweaks. Note too, that themes can be installed either globally (must be done using sudo) so all users on the system can use them, or can be installed just for the current user. + +For Application (GTK) themes, and GNOME Shell themes, extract the archive to the **.themes/** directory in your home directory. To install for all users, extract to **/usr/share/themes/** + +For Icon and Cursor themes, extract the archive to the **.icons/** directory in your home directory. To install for all users, extract to **/usr/share/icons/** + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/tweaking-the-look-of-fedora-workstation-with-themes/ + +作者:[Ryan Lerch][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/ryanlerch/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/06/themes.png-816x345.jpg +[2]: https://fedoramagazine.org/wp-content/uploads/2019/06/application-theme-1024x514.jpg +[3]: https://fedoramagazine.org/wp-content/uploads/2019/06/overview-theme-1024x649.jpg +[4]: https://fedoramagazine.org/wp-content/uploads/2019/06/icon-theme-application-1024x441.jpg +[5]: https://fedoramagazine.org/wp-content/uploads/2019/06/overview-icons-1024x637.jpg +[6]: https://fedoramagazine.org/wp-content/uploads/2019/06/cursortheme-1024x467.jpg +[7]: https://fedoramagazine.org/wp-content/uploads/2019/06/tweaks-in-software-1024x725.png +[8]: https://fedoramagazine.org/install-extensions-via-software-application/ +[9]: https://fedoramagazine.org/wp-content/uploads/2019/06/tweaks-choose-themes.png +[10]: https://www.opendesktop.org/ +[11]: https://www.gnome-look.org/ diff --git a/sources/tech/20190606 Examples of blameless culture outside of DevOps.md b/sources/tech/20190606 Examples of blameless culture outside of DevOps.md new file mode 100644 index 0000000000..b78722f3ef --- /dev/null +++ b/sources/tech/20190606 Examples of blameless culture outside of DevOps.md @@ -0,0 +1,65 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Examples of blameless culture outside of DevOps) +[#]: via: (https://opensource.com/article/19/6/everyday-blameless) +[#]: author: (Patrick Housley https://opensource.com/users/patrickhousley) + +Examples of blameless culture outside of DevOps +====== +Is blameless culture just a matter of postmortems and top-down change? +Or are there things individuals can do to promote it? +![people in different locations who are part of the same team][1] + +A blameless culture is not a new concept in the technology industry. In fact, in 2012, [John Allspaw][2] wrote about how [Etsy uses blameless postmortems][3] to dive to the heart of problems when they arise. Other technology giants, like Google, have also worked hard to implement a blameless culture. But what is a blameless culture? Is it just a matter of postmortems? Does it take a culture change to make blameless a reality? And what about flagrant misconduct? + +### Exploring blameless culture + +In 2009, [Mike Rother][4] wrote an [award-winning book][5] on the culture of Toyota, in which he broke down how the automaker became so successful in the 20th century when most other car manufacturers were either stagnant or losing ground. Books on Toyota were nothing new, but how Mike approached Toyota's success was unique. Instead of focusing on the processes and procedures Toyota implements, he explains in exquisite detail the company's culture, including its focus on blameless failure and continuous improvement. + +Mike explains that Toyota, in the face of failure, focuses on the system where the failure occurred instead of who is at fault. Furthermore, the company treats failure as a learning opportunity, not a chance to chastise the operator. This is the very definition of a blameless culture and one that the technology field can still learn much from. + +### It's not a culture shift + +It shouldn't take an executive initiative to attain blamelessness. It's not so much the company's culture that we need to change, but our attitudes towards fault and failure. Sure, the company's culture should change, but, even in a blameless culture, some people still have the undying urge to point fingers and call others out for their shortcomings. + +I was once contracted to work with a company on developing and improving its digital footprint. This company employed its own developers, and, as you might imagine, there was tension at times. If a bug was found in production, the search began immediately for the person responsible. I think it's just human nature to want to find someone to blame. But there is a better way, and it will take practice. + +### Blamelessness at the microscale + +When I talk about implementing blamelessness, I'm not talking about doing it at the scale of companies and organizations. That's too large for most of us. Instead, focus your attention on the smallest scale: the code commit, review, and pull request. Focus on your actions and the actions of your peers and those you lead. You may find that you have the biggest impact in this area. + +How often do you or one of your peers get a bug report, dig in to find out what is wrong, and stop once you determine who made the breaking change? Do you immediately assume that a pull request or code commit needs to be reverted? Do you contact that individual and tell them what they broke and which commit it was? If this is happening within your team, you're the furthest from blamelessness you could be. But it can be remedied. + +Obviously, when you find a bug, you need to understand what broke, where, and who did it. But don't stop there. Attempt to fix the issue. The chances are high that patching the code will be a faster resolution than trying to figure out which code to back out. Too many times, I have seen people try to back out code only to find that they broke something else. + +If you're not confident that you can fix the issue, politely ask the individual who made the breaking change to assist. Yes, assist! My mom always said, "you can catch more flies with honey than vinegar." You will typically get a more positive response if you ask people for help instead of pointing out what they broke. + +Finally, once you have a fix, make sure to ask the individual who caused the bug to review your change. This isn't about rubbing it in their face. Remember that failure represents a learning opportunity, and the person who created the failure will learn if they have a chance to review the fix you created. Furthermore, that individual may have unique details and reasoning that suggests your change may fix the immediate issue but may not solve the original problem. + +### Catch flagrant misconduct and abuse sooner + +A blameless culture doesn't provide blanket protection if someone is knowingly attempting to do wrong. That also doesn't mean the system is not faulty. Remember how Toyota focuses on the system where failure occurs? If an individual can knowingly create havoc within the software they are working on, they should be held accountable—but so should the system. + +When reviewing failure, no matter how small, always ask, "How could we have caught this sooner?" Chances are you could improve some part of your software development lifecycle (SDLC) to make failures less likely to happen. Maybe you need to add more tests. Or run your tests more often. Whatever the solution, remember that fixing the bug is only part of a complete fix. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/everyday-blameless + +作者:[Patrick Housley][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/patrickhousley +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/connection_people_team_collaboration.png?itok=0_vQT8xV (people in different locations who are part of the same team) +[2]: https://twitter.com/allspaw +[3]: https://codeascraft.com/2012/05/22/blameless-postmortems/ +[4]: http://www-personal.umich.edu/~mrother/Homepage.html +[5]: https://en.wikipedia.org/wiki/Toyota_Kata diff --git a/sources/tech/20190606 Why hypothesis-driven development is key to DevOps.md b/sources/tech/20190606 Why hypothesis-driven development is key to DevOps.md new file mode 100644 index 0000000000..766393dc3f --- /dev/null +++ b/sources/tech/20190606 Why hypothesis-driven development is key to DevOps.md @@ -0,0 +1,152 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why hypothesis-driven development is key to DevOps) +[#]: via: (https://opensource.com/article/19/6/why-hypothesis-driven-development-devops) +[#]: author: (Brent Aaron Reed https://opensource.com/users/brentaaronreed/users/wpschaub) + +Why hypothesis-driven development is key to DevOps +====== +A hypothesis-driven development mindset harvests the core value of +feature flags: experimentation in production. +![gears and lightbulb to represent innovation][1] + +The definition of DevOps, offered by [Donovan Brown][2] * _is_ "The union of **people** , **process** , and **products** to enable continuous delivery of **value** to our customers.*" It accentuates the importance of continuous delivery of value. Let's discuss how experimentation is at the heart of modern development practices. + +![][3] + +### Reflecting on the past + +Before we get into hypothesis-driven development, let's quickly review how we deliver value using waterfall, agile, deployment rings, and feature flags. + +In the days of _**waterfall**_ , we had predictable and process-driven delivery. However, we only delivered value towards the end of the development lifecycle, often failing late as the solution drifted from the original requirements, or our killer features were outdated by the time we finally shipped. + +![][4] + +Here, we have one release X and eight features, which are all deployed and exposed to the patiently waiting user. We are continuously delivering value—but with a typical release cadence of six months to two years, _the value of the features declines as the world continues to move on_. It worked well enough when there was time to plan and a lower expectation to react to more immediate needs. + +The introduction of _**agile**_ allowed us to create and respond to change so we could continuously deliver working software, sense, learn, and respond. + +![][5] + +Now, we have three releases: X.1, X.2, and X.3. After the X.1 release, we improved feature 3 based on feedback and re-deployed it in release X.3. This is a simple example of delivering features more often, focused on working software, and responding to user feedback. _We are on the path of continuous delivery, focused on our key stakeholders: our users._ + +Using _**deployment rings**_ and/or _**feature flags**_ , we can decouple release deployment and feature exposure, down to the individual user, to control the exposure—the blast radius—of features. We can conduct experiments; progressively expose, test, enable, and hide features; fine-tune releases, and continuously pivot on learnings and feedback. + +When we add feature flags to the previous workflow, we can toggle features to be ON (enabled and exposed) or OFF (hidden). + +![][6] + +Here, feature flags for features 2, 4, and 8 are OFF, which results in the user being exposed to fewer of the features. All features have been deployed but are not exposed (yet). _We can fine-tune the features (value) of each release after deploying to production._ + +_**Ring-based deployment**_ limits the impact (blast) on users while we gradually deploy and evaluate one or more features through observation. Rings allow us to deploy features progressively and have multiple releases (v1, v1.1, and v1.2) running in parallel. + +![Ring-based deployment][7] + +Exposing features in the canary and early-adopter rings enables us to evaluate features without the risk of an all-or-nothing big-bang deployment. + +_**Feature flags**_ decouple release deployment and feature exposure. You "flip the flag" to expose a new feature, perform an emergency rollback by resetting the flag, use rules to hide features, and allow users to toggle preview features. + +![Toggling feature flags on/off][8] + +When you combine deployment rings and feature flags, you can progressively deploy a release through rings and use feature flags to fine-tune the deployed release. + +> See [deploying new releases: Feature flags or rings][9], [what's the cost of feature flags][10], and [breaking down walls between people, process, and products][11] for discussions on feature flags, deployment rings, and related topics. + +### Adding hypothesis-driven development to the mix + +_**Hypothesis-driven development**_ is based on a series of experiments to validate or disprove a hypothesis in a [complex problem domain][12] where we have unknown-unknowns. We want to find viable ideas or fail fast. Instead of developing a monolithic solution and performing a big-bang release, we iterate through hypotheses, evaluating how features perform and, most importantly, how and if customers use them. + +> **Template:** _**We believe**_ {customer/business segment} _**wants**_ {product/feature/service} _**because**_ {value proposition}. +> +> **Example:** _**We believe**_ that users _**want**_ to be able to select different themes _**because**_ it will result in improved user satisfaction. We expect 50% or more users to select a non-default theme and to see a 5% increase in user engagement. + +Every experiment must be based on a hypothesis, have a measurable conclusion, and contribute to feature and overall product learning. For each experiment, consider these steps: + + * Observe your user + * Define a hypothesis and an experiment to assess the hypothesis + * Define clear success criteria (e.g., a 5% increase in user engagement) + * Run the experiment + * Evaluate the results and either accept or reject the hypothesis + * Repeat + + + +Let's have another look at our sample release with eight hypothetical features. + +![][13] + +When we deploy each feature, we can observe user behavior and feedback, and prove or disprove the hypothesis that motivated the deployment. As you can see, the experiment fails for features 2 and 6, allowing us to fail-fast and remove them from the solution. _**We do not want to carry waste that is not delivering value or delighting our users!**_ The experiment for feature 3 is inconclusive, so we adapt the feature, repeat the experiment, and perform A/B testing in Release X.2. Based on observations, we identify the variant feature 3.2 as the winner and re-deploy in release X.3. _**We only expose the features that passed the experiment and satisfy the users.**_ + +### Hypothesis-driven development lights up progressive exposure + +When we combine hypothesis-driven development with progressive exposure strategies, we can vertically slice our solution, incrementally delivering on our long-term vision. With each slice, we progressively expose experiments, enable features that delight our users and hide those that did not make the cut. + +But there is more. When we embrace hypothesis-driven development, we can learn how technology works together, or not, and what our customers need and want. We also complement the test-driven development (TDD) principle. TDD encourages us to write the test first (hypothesis), then confirm our features are correct (experiment), and succeed or fail the test (evaluate). _**It is all about quality and delighting our users** , as outlined in principles 1, 3, and 7_ of the [Agile Manifesto][14]: + + * Our highest priority is to satisfy the customers through early and continuous delivery of value. + * Deliver software often, from a couple of weeks to a couple of months, with a preference to the shorter timescale. + * Working software is the primary measure of progress. + + + +More importantly, we introduce a new mindset that breaks down the walls between development, business, and operations to view, design, develop, deliver, and observe our solution in an iterative series of experiments, adopting features based on scientific analysis, user behavior, and feedback in production. We can evolve our solutions in thin slices through observation and learning in production, a luxury that other engineering disciplines, such as aerospace or civil engineering, can only dream of. + +The good news is that hypothesis-driven development supports the empirical process theory and its three pillars: **Transparency** , **Inspection** , and **Adaption**. + +![][15] + +But there is more. Based on lean principles, we must pivot or persevere after we measure and inspect the feedback. Using feature toggles in conjunction with hypothesis-driven development, we get the best of both worlds, as well as the ability to use A|B testing to make decisions on feedback, such as likes/dislikes and value/waste. + +### Remember: + +Hypothesis-driven development: + + * Is about a series of experiments to confirm or disprove a hypothesis. Identify value! + * Delivers a measurable conclusion and enables continued learning. + * Enables continuous feedback from the key stakeholder—the user—to understand the unknown-unknowns! + * Enables us to understand the evolving landscape into which we progressively expose value. + + + +Progressive exposure: + + * Is not an excuse to hide non-production-ready code. _**Always ship quality!**_ + * Is about deploying a release of features through rings in production. _**Limit blast radius!**_ + * Is about enabling or disabling features in production. _**Fine-tune release values!**_ + * Relies on circuit breakers to protect the infrastructure from implications of progressive exposure. _**Observe, sense, act!**_ + + + +What have you learned about progressive exposure strategies and hypothesis-driven development? We look forward to your candid feedback. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/why-hypothesis-driven-development-devops + +作者:[Brent Aaron Reed][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/brentaaronreed/users/wpschaub +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/innovation_lightbulb_gears_devops_ansible.png?itok=TSbmp3_M (gears and lightbulb to represent innovation) +[2]: http://donovanbrown.com/post/what-is-devops +[3]: https://opensource.com/sites/default/files/hypo-1_copy.png +[4]: https://opensource.com/sites/default/files/uploads/hyp0-2-trans.png +[5]: https://opensource.com/sites/default/files/uploads/hypo-3-trans.png +[6]: https://opensource.com/sites/default/files/uploads/hypo-4_0.png +[7]: https://opensource.com/sites/default/files/uploads/hypo-6-trans.png +[8]: https://opensource.com/sites/default/files/uploads/hypo-7-trans.png +[9]: https://opensource.com/article/18/2/feature-flags-ring-deployment-model +[10]: https://opensource.com/article/18/7/does-progressive-exposure-really-come-cost +[11]: https://opensource.com/article/19/3/breaking-down-walls-between-people-process-and-products +[12]: https://en.wikipedia.org/wiki/Cynefin_framework +[13]: https://opensource.com/sites/default/files/uploads/hypo-5-trans.png +[14]: https://agilemanifesto.org/principles.html +[15]: https://opensource.com/sites/default/files/uploads/adapt-transparent-inspect.png diff --git a/sources/tech/20190607 An Introduction to Kubernetes Secrets and ConfigMaps.md b/sources/tech/20190607 An Introduction to Kubernetes Secrets and ConfigMaps.md new file mode 100644 index 0000000000..7d28e67ea4 --- /dev/null +++ b/sources/tech/20190607 An Introduction to Kubernetes Secrets and ConfigMaps.md @@ -0,0 +1,608 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (An Introduction to Kubernetes Secrets and ConfigMaps) +[#]: via: (https://opensource.com/article/19/6/introduction-kubernetes-secrets-and-configmaps) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) + +An Introduction to Kubernetes Secrets and ConfigMaps +====== +Kubernetes Secrets and ConfigMaps separate the configuration of +individual container instances from the container image, reducing +overhead and adding flexibility. +![Kubernetes][1] + +Kubernetes has two types of objects that can inject configuration data into a container when it starts up: Secrets and ConfigMaps. Secrets and ConfigMaps behave similarly in [Kubernetes][2], both in how they are created and because they can be exposed inside a container as mounted files or volumes or environment variables. + +To explore Secrets and ConfigMaps, consider the following scenario: + +> You're running the [official MariaDB container image][3] in Kubernetes and must do some configuration to get the container to run. The image requires an environment variable to be set for **MYSQL_ROOT_PASSWORD** , **MYSQL_ALLOW_EMPTY_PASSWORD** , or **MYSQL_RANDOM_ROOT_PASSWORD** to initialize the database. It also allows for extensions to the MySQL configuration file **my.cnf** by placing custom config files in **/etc/mysql/conf.d**. + +You could build a custom image, setting the environment variables and copying the configuration files into it to create a bespoke container image. However, it is considered a best practice to create and use generic images and add configuration to the containers created from them, instead. This is a perfect use-case for ConfigMaps and Secrets. The **MYSQL_ROOT_PASSWORD** can be set in a Secret and added to the container as an environment variable, and the configuration files can be stored in a ConfigMap and mounted into the container as a file on startup. + +Let's try it out! + +### But first: A quick note about Kubectl + +Make sure that your version of the **kubectl** client command is the same or newer than the Kubernetes cluster version in use. + +An error along the lines of: + + +``` +`error: SchemaError(io.k8s.api.admissionregistration.v1beta1.ServiceReference): invalid object doesn't have additional properties` +``` + +may mean the client version is too old and needs to be upgraded. The [Kubernetes Documentation for Installing Kubectl][4] has instructions for installing the latest client on various platforms. + +If you're using Docker for Mac, it also installs its own version of **kubectl** , and that may be the issue. You can install a current client with **brew install** , replacing the symlink to the client shipped by Docker: + + +``` +$ rm /usr/local/bin/kubectl +$ brew link --overwrite kubernetes-cli +``` + +The newer **kubectl** client should continue to work with Docker's Kubernetes version. + +### Secrets + +Secrets are a Kubernetes object intended for storing a small amount of sensitive data. It is worth noting that Secrets are stored base64-encoded within Kubernetes, so they are not wildly secure. Make sure to have appropriate [role-based access controls][5] (RBAC) to protect access to Secrets. Even so, extremely sensitive Secrets data should probably be stored using something like [HashiCorp Vault][6]. For the root password of a MariaDB database, however, base64 encoding is just fine. + +#### Create a Secret manually + +To create the Secret containing the **MYSQL_ROOT_PASSWORD** , choose a password and convert it to base64: + + +``` +# The root password will be "KubernetesRocks!" +$ echo -n 'KubernetesRocks!' | base64 +S3ViZXJuZXRlc1JvY2tzIQ== +``` + +Make a note of the encoded string. You need it to create the YAML file for the Secret: + + +``` +apiVersion: v1 +kind: Secret +metadata: +name: mariadb-root-password +type: Opaque +data: +password: S3ViZXJuZXRlc1JvY2tzIQ== +``` + +Save that file as **mysql-secret.yaml** and create the Secret in Kubernetes with the **kubectl apply** command: + + +``` +$ kubectl apply -f mysql-secret.yaml +secret/mariadb-root-password created +``` + +#### View the newly created Secret + +Now that you've created the Secret, use **kubectl describe** to see it: + + +``` +$ kubectl describe secret mariadb-root-password +Name: mariadb-root-password +Namespace: secrets-and-configmaps +Labels: +Annotations: +Type: Opaque + +Data +==== +password: 16 bytes +``` + +Note that the **Data** field contains the key you set in the YAML: **password**. The value assigned to that key is the password you created, but it is not shown in the output. Instead, the value's size is shown in its place, in this case, 16 bytes. + +You can also use the **kubectl edit secret ** command to view and edit the Secret. If you edit the Secret, you'll see something like this: + + +``` +# Please edit the object below. Lines beginning with a '#' will be ignored, +# and an empty file will abort the edit. If an error occurs while saving this file will be +# reopened with the relevant failures. +# +apiVersion: v1 +data: +password: S3ViZXJuZXRlc1JvY2tzIQ== +kind: Secret +metadata: +annotations: +kubectl.kubernetes.io/last-applied-configuration: | +{"apiVersion":"v1","data":{"password":"S3ViZXJuZXRlc1JvY2tzIQ=="},"kind":"Secret","metadata":{"annotations":{},"name":"mariadb-root-password","namespace":"secrets-and-configmaps"},"type":"Opaque"} +creationTimestamp: 2019-05-29T12:06:09Z +name: mariadb-root-password +namespace: secrets-and-configmaps +resourceVersion: "85154772" +selfLink: /api/v1/namespaces/secrets-and-configmaps/secrets/mariadb-root-password +uid: 2542dadb-820a-11e9-ae24-005056a1db05 +type: Opaque +``` + +Again, the **data** field with the **password** key is visible, and this time you can see the base64-encoded Secret. + +#### Decode the Secret + +Let's say you need to view the Secret in plain text, for example, to verify that the Secret was created with the correct content. You can do this by decoding it. + +It is easy to decode the Secret by extracting the value and piping it to base64. In this case, you will use the output format **-o jsonpath= ** to extract only the Secret value using a JSONPath template. + + +``` +# Returns the base64 encoded secret string +$ kubectl get secret mariadb-root-password -o jsonpath='{.data.password}' +S3ViZXJuZXRlc1JvY2tzIQ== + +# Pipe it to `base64 --decode -` to decode: +$ kubectl get secret mariadb-root-password -o jsonpath='{.data.password}' | base64 --decode - +KubernetesRocks! +``` + +#### Another way to create Secrets + +You can also create Secrets directly using the **kubectl create secret** command. The MariaDB image permits setting up a regular database user with a password by setting the **MYSQL_USER** and **MYSQL_PASSWORD** environment variables. A Secret can hold more than one key/value pair, so you can create a single Secret to hold both strings. As a bonus, by using **kubectl create secret** , you can let Kubernetes mess with base64 so that you don't have to. + + +``` +$ kubectl create secret generic mariadb-user-creds \ +\--from-literal=MYSQL_USER=kubeuser\ +\--from-literal=MYSQL_PASSWORD=kube-still-rocks +secret/mariadb-user-creds created +``` + +Note the **\--from-literal** , which sets the key name and the value all in one. You can pass as many **\--from-literal** arguments as you need to create one or more key/value pairs in the Secret. + +Validate that the username and password were created and stored correctly with the **kubectl get secrets** command: + + +``` +# Get the username +$ kubectl get secret mariadb-user-creds -o jsonpath='{.data.MYSQL_USER}' | base64 --decode - +kubeuser + +# Get the password +$ kubectl get secret mariadb-user-creds -o jsonpath='{.data.MYSQL_PASSWORD}' | base64 --decode - +kube-still-rocks +``` + +### ConfigMaps + +ConfigMaps are similar to Secrets. They can be created and shared in the containers in the same ways. The only big difference between them is the base64-encoding obfuscation. ConfigMaps are intended for non-sensitive data—configuration data—like config files and environment variables and are a great way to create customized running services from generic container images. + +#### Create a ConfigMap + +ConfigMaps can be created in the same ways as Secrets. You can write a YAML representation of the ConfigMap manually and load it into Kubernetes, or you can use the **kubectl create configmap** command to create it from the command line. The following example creates a ConfigMap using the latter method but, instead of passing literal strings (as with **\--from-literal= =** in the Secret above), it creates a ConfigMap from an existing file—a MySQL config intended for **/etc/mysql/conf.d** in the container. This config file overrides the **max_allowed_packet** setting that MariaDB sets to 16M by default. + +First, create a file named **max_allowed_packet.cnf** with the following content: + + +``` +[mysqld] +max_allowed_packet = 64M +``` + +This will override the default setting in the **my.cnf** file and set **max_allowed_packet** to 64M. + +Once the file is created, you can create a ConfigMap named **mariadb-config** using the **kubectl create configmap** command that contains the file: + + +``` +$ kubectl create configmap mariadb-config --from-file=max_allowed_packet.cnf +configmap/mariadb-config created +``` + +Just like Secrets, ConfigMaps store one or more key/value pairs in their Data hash of the object. By default, using **\--from-file= ** (as above) will store the contents of the file as the value, and the name of the file will be stored as the key. This is convenient from an organization viewpoint. However, the key name can be explicitly set, too. For example, if you used **\--from-file=max-packet=max_allowed_packet.cnf** when you created the ConfigMap, the key would be **max-packet** rather than the file name. If you had multiple files to store in the ConfigMap, you could add each of them with an additional **\--from-file= ** argument. + +#### View the new ConfigMap and read the data + +As mentioned, ConfigMaps are not meant to store sensitive data, so the data is not encoded when the ConfigMap is created. This makes it easy to view and validate the data and edit it directly. + +First, validate that the ConfigMap was, indeed, created: + + +``` +$ kubectl get configmap mariadb-config +NAME DATA AGE +mariadb-config 1 9m +``` + +The contents of the ConfigMap can be viewed with the **kubectl describe** command. Note that the full contents of the file are visible and that the key name is, in fact, the file name, **max_allowed_packet.cnf**. + + +``` +$ kubectl describe cm mariadb-config +Name: mariadb-config +Namespace: secrets-and-configmaps +Labels: +Annotations: + +Data +==== +max_allowed_packet.cnf: +\---- +[mysqld] +max_allowed_packet = 64M + +Events: +``` + +A ConfigMap can be edited live within Kubernetes with the **kubectl edit** command. Doing so will open a buffer with the default editor showing the contents of the ConfigMap as YAML. When changes are saved, they will immediately be live in Kubernetes. While not really the _best_ practice, it can be handy for testing things in development. + +Say you want a **max_allowed_packet** value of 32M instead of the default 16M or the 64M in the **max_allowed_packet.cnf** file. Use **kubectl edit configmap mariadb-config** to edit the value: + + +``` +$ kubectl edit configmap mariadb-config + +# Please edit the object below. Lines beginning with a '#' will be ignored, +# and an empty file will abort the edit. If an error occurs while saving this file will be +# reopened with the relevant failures. +# +apiVersion: v1 + +data: +max_allowed_packet.cnf: | +[mysqld] +max_allowed_packet = 32M +kind: ConfigMap +metadata: +creationTimestamp: 2019-05-30T12:02:22Z +name: mariadb-config +namespace: secrets-and-configmaps +resourceVersion: "85609912" +selfLink: /api/v1/namespaces/secrets-and-configmaps/configmaps/mariadb-config +uid: c83ccfae-82d2-11e9-832f-005056a1102f +``` + +After saving the change, verify the data has been updated: + + +``` +# Note the '.' in max_allowed_packet.cnf needs to be escaped +$ kubectl get configmap mariadb-config -o "jsonpath={.data['max_allowed_packet\\.cnf']}" + +[mysqld] +max_allowed_packet = 32M +``` + +### Using Secrets and ConfigMaps + +Secrets and ConfigMaps can be mounted as environment variables or as files within a container. For the MariaDB container, you will need to mount the Secrets as environment variables and the ConfigMap as a file. First, though, you need to write a Deployment for MariaDB so that you have something to work with. Create a file named **mariadb-deployment.yaml** with the following: + + +``` +apiVersion: apps/v1 +kind: Deployment +metadata: +labels: +app: mariadb +name: mariadb-deployment +spec: +replicas: 1 +selector: +matchLabels: +app: mariadb +template: +metadata: +labels: +app: mariadb +spec: +containers: +\- name: mariadb +image: docker.io/mariadb:10.4 +ports: +\- containerPort: 3306 +protocol: TCP +volumeMounts: +\- mountPath: /var/lib/mysql +name: mariadb-volume-1 +volumes: +\- emptyDir: {} +name: mariadb-volume-1 +``` + +This is a bare-bones Kubernetes Deployment of the official MariaDB 10.4 image from Docker Hub. Now, add your Secrets and ConfigMap. + +#### Add the Secrets to the Deployment as environment variables + +You have two Secrets that need to be added to the Deployment: + + 1. **mariadb-root-password** (with one key/value pair) + 2. **mariadb-user-creds** (with two key/value pairs) + + + +For the **mariadb-root-password** Secret, specify the Secret and the key you want by adding an **env** list/array to the container spec in the Deployment and setting the environment variable value to the value of the key in your Secret. In this case, the list contains only a single entry, for the variable **MYSQL_ROOT_PASSWORD**. + + +``` +env: +\- name: MYSQL_ROOT_PASSWORD +valueFrom: +secretKeyRef: +name: mariadb-root-password +key: password +``` + +Note that the name of the object is the name of the environment variable that is added to the container. The **valueFrom** field defines **secretKeyRef** as the source from which the environment variable will be set; i.e., it will use the value from the **password** key in the **mariadb-root-password** Secret you set earlier. + +Add this section to the definition for the **mariadb** container in the **mariadb-deployment.yaml** file. It should look something like this: + + +``` +spec: +containers: +\- name: mariadb +image: docker.io/mariadb:10.4 +env: +\- name: MYSQL_ROOT_PASSWORD +valueFrom: +secretKeyRef: +name: mariadb-root-password +key: password +ports: +\- containerPort: 3306 +protocol: TCP +volumeMounts: +\- mountPath: /var/lib/mysql +name: mariadb-volume-1 +``` + +In this way, you have explicitly set the variable to the value of a specific key from your Secret. This method can also be used with ConfigMaps by using **configMapRef** instead of **secretKeyRef**. + +You can also set environment variables from _all_ key/value pairs in a Secret or ConfigMap to automatically use the key name as the environment variable name and the key's value as the environment variable's value. By using **envFrom** rather than **env** in the container spec, you can set the **MYSQL_USER** and **MYSQL_PASSWORD** from the **mariadb-user-creds** Secret you created earlier, all in one go: + + +``` +envFrom: +\- secretRef: +name: mariadb-user-creds +``` + +**envFrom** is a list of sources for Kubernetes to take environment variables. Use **secretRef** again, this time to specify **mariadb-user-creds** as the source of the environment variables. That's it! All the keys and values in the Secret will be added as environment variables in the container. + +The container spec should now look like this: + + +``` +spec: +containers: +\- name: mariadb +image: docker.io/mariadb:10.4 +env: +\- name: MYSQL_ROOT_PASSWORD +valueFrom: +secretKeyRef: +name: mariadb-root-password +key: password +envFrom: +\- secretRef: +name: mariadb-user-creds +ports: +\- containerPort: 3306 +protocol: TCP +volumeMounts: +\- mountPath: /var/lib/mysql +name: mariadb-volume-1 +``` + +_Note:_ You could have just added the **mysql-root-password** Secret to the **envFrom** list and let it be parsed as well, as long as the **password** key was named **MYSQL_ROOT_PASSWORD** instead. There is no way to manually specify the environment variable name with **envFrom** as with **env**. + +#### Add the max_allowed_packet.cnf file to the Deployment as a volumeMount + +As mentioned, both **env** and **envFrom** can be used to share ConfigMap key/value pairs with a container as well. However, in the case of the **mariadb-config** ConfigMap, your entire file is stored as the value to your key, and the file needs to exist in the container's filesystem for MariaDB to be able to use it. Luckily, both Secrets and ConfigMaps can be the source of Kubernetes "volumes" and mounted into the containers instead of using a filesystem or block device as the volume to be mounted. + +The **mariadb-deployment.yaml** already has a volume and volumeMount specified, an **emptyDir** (effectively a temporary or ephemeral) volume mounted to **/var/lib/mysql** to store the MariaDB data: + + +``` +<...> + +volumeMounts: +\- mountPath: /var/lib/mysql +name: mariadb-volume-1 + +<...> + +volumes: +\- emptyDir: {} +name: mariadb-volume-1 + +<...> +``` + +_Note:_ This is not a production configuration. When the Pod restarts, the data in the **emptyDir** volume is lost. This is primarily used for development or when the contents of the volume don't need to be persistent. + +You can add your ConfigMap as a source by adding it to the volume list and then adding a volumeMount for it to the container definition: + + +``` +<...> + +volumeMounts: +\- mountPath: /var/lib/mysql +name: mariadb-volume-1 +\- mountPath: /etc/mysql/conf.d +name: mariadb-config + +<...> + +volumes: +\- emptyDir: {} +name: mariadb-volume-1 +\- configMap: +name: mariadb-config +items: +\- key: max_allowed_packet.cnf +path: max_allowed_packet.cnf +name: mariadb-config-volume + +<...> +``` + +The **volumeMount** is pretty self-explanatory—create a volume mount for the **mariadb-config-volume** (specified in the **volumes** list below it) to the path **/etc/mysql/conf.d**. + +Then, in the **volumes** list, **configMap** tells Kubernetes to use the **mariadb-config** ConfigMap, taking the contents of the key **max_allowed_packet.cnf** and mounting it to the path **max_allowed_packed.cnf**. The name of the volume is **mariadb-config-volume** , which was referenced in the **volumeMounts** above. + +_Note:_ The **path** from the **configMap** is the name of a file that will contain the contents of the key's value. In this case, your key was a file name, too, but it doesn't have to be. Note also that **items** is a list, so multiple keys can be referenced and their values mounted as files. These files will all be created in the **mountPath** of the **volumeMount** specified above: **/etc/mysql/conf.d**. + +### Create a MariaDB instance from the Deployment + +At this point, you should have enough to create a MariaDB instance. You have two Secrets, one holding the **MYSQL_ROOT_PASSWORD** and another storing the **MYSQL_USER** , and the **MYSQL_PASSWORD** environment variables to be added to the container. You also have a ConfigMap holding the contents of a MySQL config file that overrides the **max_allowed_packed** value from its default setting. + +You also have a **mariadb-deployment.yaml** file that describes a Kubernetes deployment of a Pod with a MariaDB container and adds the Secrets as environment variables and the ConfigMap as a volume-mounted file in the container. It should look like this: + + +``` +apiVersion: apps/v1 +kind: Deployment +metadata: +labels: +app: mariadb +name: mariadb-deployment +spec: +replicas: 1 +selector: +matchLabels: +app: mariadb +template: +metadata: +labels: +app: mariadb +spec: +containers: +\- image: docker.io/mariadb:10.4 +name: mariadb +env: +\- name: MYSQL_ROOT_PASSWORD +valueFrom: +secretKeyRef: +name: mariadb-root-password +key: password +envFrom: +\- secretRef: +name: mariadb-user-creds +ports: +\- containerPort: 3306 +protocol: TCP +volumeMounts: +\- mountPath: /var/lib/mysql +name: mariadb-volume-1 +\- mountPath: /etc/mysql/conf.d +name: mariadb-config-volume +volumes: +\- emptyDir: {} +name: mariadb-volume-1 +\- configMap: +name: mariadb-config +items: +\- key: max_allowed_packet.cnf +path: max_allowed_packet.cnf +name: mariadb-config-volume +``` + +#### Create the MariaDB instance + +Create a new MariaDB instance from the YAML file with the **kubectl create** command: + + +``` +$ kubectl create -f mariadb-deployment.yaml +deployment.apps/mariadb-deployment created +``` + +Once the deployment has been created, use the **kubectl get** command to view the running MariaDB pod: + + +``` +$ kubectl get pods +NAME READY STATUS RESTARTS AGE +mariadb-deployment-5465c6655c-7jfqm 1/1 Running 0 3m +``` + +Make a note of the Pod name (in this example, it's **mariadb-deployment-5465c6655c-7jfqm** ). Note that the Pod name will differ from this example. + +#### Verify the instance is using the Secrets and ConfigMap + +Use the **kubectl exec** command (with your Pod name) to validate that the Secrets and ConfigMaps are in use. For example, check that the environment variables are exposed in the container: + + +``` +$ kubectl exec -it mariadb-deployment-5465c6655c-7jfqm env |grep MYSQL +MYSQL_PASSWORD=kube-still-rocks +MYSQL_USER=kubeuser +MYSQL_ROOT_PASSWORD=KubernetesRocks! +``` + +Success! All three environment variables—the one using the **env** setup to specify the Secret, and two using **envFrom** to mount all the values from the Secret—are available in the container for MariaDB to use. + +Spot check that the **max_allowed_packet.cnf** file was created in **/etc/mysql/conf.d** and that it contains the expected content: + + +``` +$ kubectl exec -it mariadb-deployment-5465c6655c-7jfqm ls /etc/mysql/conf.d +max_allowed_packet.cnf + +$ kubectl exec -it mariadb-deployment-5465c6655c-7jfqm cat /etc/mysql/conf.d/max_allowed_packet.cnf +[mysqld] +max_allowed_packet = 32M +``` + +Finally, validate that MariaDB used the environment variable to set the root user password and read the **max_allowed_packet.cnf** file to set the **max_allowed_packet** configuration variable. Use the **kubectl exec** command again, this time to get a shell inside the running container and use it to run some **mysql** commands: + + +``` +$ kubectl exec -it mariadb-deployment-5465c6655c-7jfqm / +bin/sh + +# Check that the root password was set correctly +$ mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e 'show databases;' ++--------------------+ +| Database | ++--------------------+ +| information_schema | +| mysql | +| performance_schema | ++--------------------+ + +# Check that the max_allowed_packet.cnf was parsed +$ mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "SHOW VARIABLES LIKE 'max_allowed_packet';" ++--------------------+----------+ +| Variable_name | Value | ++--------------------+----------+ +| max_allowed_packet | 33554432 | ++--------------------+----------+ +``` + +### Advantages of Secrets and ConfigMaps + +This exercise explained how to create Kubernetes Secrets and ConfigMaps and how to use those Secrets and ConfigMaps by adding them as environment variables or files inside of a running container instance. This makes it easy to keep the configuration of individual instances of containers separate from the container image. By separating the configuration data, overhead is reduced to maintaining only a single image for a specific type of instance while retaining the flexibility to create instances with a wide variety of configurations. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/introduction-kubernetes-secrets-and-configmaps + +作者:[Chris Collins][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clcollins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/kubernetes.png?itok=PqDGb6W7 (Kubernetes) +[2]: https://opensource.com/resources/what-is-kubernetes +[3]: https://hub.docker.com/_/mariadb +[4]: https://kubernetes.io/docs/tasks/tools/install-kubectl/ +[5]: https://kubernetes.io/docs/reference/access-authn-authz/rbac/ +[6]: https://www.vaultproject.io/ diff --git a/sources/tech/20190610 Blockchain 2.0 - EOS.IO Is Building Infrastructure For Developing DApps -Part 13.md b/sources/tech/20190610 Blockchain 2.0 - EOS.IO Is Building Infrastructure For Developing DApps -Part 13.md new file mode 100644 index 0000000000..a44ceeb105 --- /dev/null +++ b/sources/tech/20190610 Blockchain 2.0 - EOS.IO Is Building Infrastructure For Developing DApps -Part 13.md @@ -0,0 +1,88 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Blockchain 2.0 – EOS.IO Is Building Infrastructure For Developing DApps [Part 13]) +[#]: via: (https://www.ostechnix.com/blockchain-2-0-eos-io-is-building-infrastructure-for-developing-dapps/) +[#]: author: (editor https://www.ostechnix.com/author/editor/) + +Blockchain 2.0 – EOS.IO Is Building Infrastructure For Developing DApps [Part 13] +====== + +![Building infrastructure for Developing DApps][1] + +When a blockchain startup makes over **$4 billion** through an ICO without having a product or service to show for it, that is newsworthy. It becomes clear at this point that people invested these billions on this project because it seemed to promise a lot. This post will seek to demystify this mystical and seemingly powerful platform. + +**EOS.IO** is a [**blockchain**][2] platform that aims to develop standardized infrastructure including an application protocol and operating system for developing DApps ([ **distributed applications**][3]). **Block.one** the lead developer and investor in the project envisions **EOS.IO as the world’s’ first distributed operating system** providing a developing environment for decentralized applications. The system is meant to mirror a real computer by simulating hardware such as its CPUs, GPUs, and even RAM, apart from the obvious storage solutions courtesy of the blockchain database system. + +### Who is block.one? + +Block.one is the company behind EOS.IO. They developed the platform from the ground up based on a white paper published on GitHub. Block.one also spearheaded the yearlong “continuous” ICO that eventually made them a whopping $4 billion. They have one of the best teams of backers and advisors any company in the blockchain space can hope for with partnerships from **Bitmain** , **Louis Bacon** and **Alan Howard** among others. Not to mention **Peter Thiel** being one of the lead investors in the company. The expectations from their purported platform the EOS.IO and their crypto VC fund **EOS.VC** are high indeed. + +### What is EOS.IO? + +It is difficult to arrive at a short description for EOS.IO. The platform aims to position itself as a world wide computer with virtually simulated resources, hence creating a virtual environment for distributed applications to be built and run. The team behind EOS.IO aims achieve the following by directly quoting [**Ethereum**][4] as competition. + + * Increase transaction throughput to millions per second, + + * Reduce transaction costs to insignificant sums or remove them altogether. + + + + +Though EOS.IO is not anywhere near solving any of these problems, the platform has a few capabilities that make it noteworthy as an alternative to Ethereum for DApp enthusiasts and developers. + + 1. **Scalability** : EOS.IO uses a different consensus algorithm for handling blocks called **DPoS**. We’ve described it briefly below. The DPoS system basically allows the system to handle far more requests at better speeds than Ethereum is capable of with its **PoW** algorithm. The claim is that because they’ll be able to handle such massive throughputs they’ll be able to afford transactions at insignificant or even zero charges if need be. + 2. **Governance capabilities** : The consensus algorithm allows EOS.IO to dynamically understand malicious user (or node) behaviour to penalize or deactivate the user. The elected delegate feature of the delegated proof of stake system also ensures faster amendments to the rules that govern the network and its users. + 3. **Parallel processing** : Touted to another major feature. This will basically allow programs on the EOS.IO blockchain to utilize multiple computers or processors or even computing resources such as GPUs to parallelly processes large chunks of data and blocks. This is not yet seen in a roll out ready form. (This however is not a unique feature of EOS.IO. [**Hyperledger Sawtooth**][5] and Burrow for instance support the same at the moment). + 4. **Self-sufficiency** : The system has a built-in grievance system along with well defined incentive and penal systems for providing feedback for acceptable and non-acceptable behaviour. This means that the platform has a governance system without actually having a central governing body. + + + +All or at least most of the selling points of the system is based on the consensus algorithm it follows, DPoS. We explore more about the same below. + +### What is the delegated Proof of Stake (DPoS) consensus algorithm? + +As far as blockchains are concerned consensus algorithms are what gives them the strength and the selling point they need. However, as a general rule of thumb, as the “openness” and immutability of the ledger increases so does the computational power that is required to run it. For instance, if a blockchain intends to be secure against intrusion, be safe and immutable with respect to data, while being accessible to a lot of users, it will use up a lot of computing power in creating and maintaining itself. Think of it as a number lock. A 6-digit pin code is safer than a 3-digit pin code, but the latter will be easier and faster to open, now consider a million of these locks but with limited manpower to open them, and you get the scale at which blockchains operate and how much these consensus algorithms matter. + +In fact, this is a major area where competing platforms differ from each other. Hyperledger Sawtooth uses a proof of elapsed time algorithm (PoET), while ethereum uses a slightly modified proof of work (PoW) algorithm. Each of these have their own pros and cons which we will cover in a detailed post later on. However, for now, to be noted is that EOS.IO uses a delegated proof of stake mechanism for attesting and validating blocks under it. This has the following implications for users. + +Only one node can actively change the status of data written on the blockchain. In the case of a DPoS based system, this validator node is selected as part of a delegation by all the token holders of the blockchain. Every token holder gets to vote and have a say in who should be a validator. The weight the vote carries is usually proportional to the number of tokens the user carries. This is seen as a democratic way to ensure centralized accountability in terms of running the network. Furthermore, the validator is given additional monetary incentives to keep the network running smoothly and without friction. In case a validator or delegate member who is elected appears to be malicious, the system automatically votes out the said node member. + +DPoS system is efficient as it requires fewer computing resources to cast a vote and select a leader to validate. Further, it incentivizes good behaviour and penalizes bad ones leading to self-correction and maintenance of the blockchain. **The average transaction time for PoW vs DPoS is 10 minutes vs 10 seconds**. The downside to this paradigm being centralized operations, weighted voting systems, lack of redundancy, and possible malicious behaviour from the validator. + +To understand the difference between PoW and DPoS, imagine this: Let’s say your network has 100 participants out of which 10 are capable of handling validator duties and you need to choose one to do the same. In PoW, you give each of them a tough problem to solve to know who’s the fastest and smartest. You give the validator position to the winner and reward them for the same. In the DPoS system, the rest of the members vote for the person they think should hold the position. This is a simple matter of choosing based on arithmetic performance data based on the past. The node with the most votes win, and if the winner tries to do something fishy, the same electorate votes him out for the next transaction. + +### So does Ethereum lose out? + +While EOS.IO has miles to go before it even steps into the same ballpark as Ethereum with respect to the market cap and user base, EOS.IO targets specific shortfalls with Ethereum and solves them. We conclude this post by summarising some findings based on a 2017 [**paper**][6] written and published by **Ian Grigg**. + + 1. The consensus algorithm used in the Ethereum (proof of work) platform uses far more computing resources and time to process transactions. This is true even for small block sizes. This limits its scaling potential and throughput. A meagre 15 transactions per second globally is no match for the over 2000 that payments network Visa manages. If the platform is to be adopted on a global scale based on a large scale roll out this is not acceptable. + + 2. The reliance on proprietary languages, tool kits and protocols (including **Solidity** for instance) limits developer capability. Interoperability between platforms is also severely hurt due to this fact. + + 3. This is rather subjective, however, the fact that Ethereum foundation refuses to acknowledge even the need for governance on the platform instead choosing to intervene on an ad-hoc manner when things turn sour on the network is not seen by many industry watchers as a sustainable model to be emulated in the future. + + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/blockchain-2-0-eos-io-is-building-infrastructure-for-developing-dapps/ + +作者:[editor][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/05/Developing-DApps-720x340.png +[2]: https://www.ostechnix.com/blockchain-2-0-an-introduction/ +[3]: https://www.ostechnix.com/blockchain-2-0-explaining-distributed-computing-and-distributed-applications/ +[4]: https://www.ostechnix.com/blockchain-2-0-what-is-ethereum/ +[5]: https://www.ostechnix.com/blockchain-2-0-introduction-to-hyperledger-sawtooth/ +[6]: http://iang.org/papers/EOS_An_Introduction.pdf diff --git a/sources/tech/20190610 Constant Time.md b/sources/tech/20190610 Constant Time.md new file mode 100644 index 0000000000..f19207fb58 --- /dev/null +++ b/sources/tech/20190610 Constant Time.md @@ -0,0 +1,281 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Constant Time) +[#]: via: (https://dave.cheney.net/2019/06/10/constant-time) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +Constant Time +====== + +This essay is a derived from my [dotGo 2019 presentation][1] about my favourite feature in Go. + +* * * + +Many years ago Rob Pike remarked, + +> “Numbers are just numbers, you’ll never see `0x80ULL` in a `.go` source file”. + +—Rob Pike, [The Go Programming Language][2] + +Beyond this pithy observation lies the fascinating world of Go’s constants. Something that is perhaps taken for granted because, as Rob noted, is Go numbers–constants–just work. +In this post I intend to show you a few things that perhaps you didn’t know about Go’s `const` keyword. + +## What’s so great about constants? + +To kick things off, why are constants good? Three things spring to mind: + + * _Immutability_. Constants are one of the few ways we have in Go to express immutability to the compiler. + * _Clarity_. Constants give us a way to extract magic numbers from our code, giving them names and semantic meaning. + * _Performance_. The ability to express to the compiler that something will not change is key as it unlocks optimisations such as constant folding, constant propagation, branch and dead code elimination. + + + +But these are generic use cases for constants, they apply to any language. Let’s talk about some of the properties of Go’s constants. + +### A Challenge + +To introduce the power of Go’s constants let’s try a little challenge: declare a _constant_ whose value is the number of bits in the natural machine word. + +We can’t use `unsafe.SizeOf` as it is not a constant expression. We could use a build tag and laboriously record the natural word size of each Go platform, or we could do something like this: + +``` +const uintSize = 32 << (^uint(0) >> 32 & 1) +``` + +There are many versions of this expression in Go codebases. They all work roughly the same way. If we’re on a 64 bit platform then the exclusive or of the number zero–all zero bits–is a number with all bits set, sixty four of them to be exact. + +``` +1111111111111111111111111111111111111111111111111111111111111111 +``` + +If we shift that value thirty two bits to the right, we get another value with thirty two ones in it. + +``` +0000000000000000000000000000000011111111111111111111111111111111 +``` + +Anding that with a number with one bit in the final position give us, the same thing, `1`, + +``` +0000000000000000000000000000000011111111111111111111111111111111 & 1 = 1 +``` + +Finally we shift the number thirty two one place to the right, giving us 641. + +``` +32 << 1 = 64 +``` + +This expression is an example of a _constant expression_. All of these operations happen at compile time and the result of the expression is itself a constant. If you look in the in runtime package, in particular the garbage collector, you’ll see how constant expressions are used to set up complex invariants based on the word size of the machine the code is compiled on. + +So, this is a neat party trick, but most compilers will do this kind of constant folding at compile time for you. Let’s step it up a notch. + +## Constants are values + +In Go, constants are values and each value has a type. In Go, user defined types can declare their own methods. Thus, a constant value can have a method set. If you’re surprised by this, let me show you an example that you probably use every day. + +``` +const timeout = 500 * time.Millisecond +fmt.Println("The timeout is", timeout) // 500ms +``` + +In the example the untyped literal constant `500` is multiplied by `time.Millisecond`, itself a constant of type `time.Duration`. The rule for assignments in Go are, unless otherwise declared, the type on the left hand side of the assignment operator is inferred from the type on the right.`500` is an untyped constant so it is converted to a `time.Duration` then multiplied with the constant `time.Millisecond`. + +Thus `timeout` is a constant of type `time.Duration` which holds the value `500000000`. +Why then does `fmt.Println` print `500ms`, not `500000000`? + +The answer is `time.Duration` has a `String` method. Thus any `time.Duration` value, even a constant, knows how to pretty print itself. + +Now we know that constant values are typed, and because types can declare methods, we can derive that _constant values can fulfil interfaces_. In fact we just saw an example of this. `fmt.Println` doesn’t assert that a value has a `String` method, it asserts the value implements the `Stringer` interface. + +Let’s talk a little about how we can use this property to make our Go code better, and to do that I’m going to take a brief digression into the Singleton pattern. + +## Singletons + +I’m generally not a fan of the singleton pattern, in Go or any language. Singletons complicate testing and create unnecessary coupling between packages. I feel the singleton pattern is often used _not_ to create a singular instance of a thing, but instead to create a place to coordinate registration. `net/http.DefaultServeMux` is a good example of this pattern. + +``` +package http + +// DefaultServeMux is the default ServeMux used by Serve. +var DefaultServeMux = &defaultServeMux + +var defaultServeMux ServeMux +``` + +There is nothing singular about `http.defaultServerMux`, nothing prevents you from creating another `ServeMux`. In fact the `http` package provides a helper that will create as many `ServeMux`‘s as you want. + +``` +// NewServeMux allocates and returns a new ServeMux. +func NewServeMux() *ServeMux { return new(ServeMux) } +``` + +`http.DefaultServeMux` is not a singleton. Never the less there is a case for things which are truely singletons because they can only represent a single thing. A good example of this are the file descriptors of a process; 0, 1, and 2 which represent stdin, stdout, and stderr respectively. + +It doesn’t matter what names you give them, `1` is always stdout, and there can only ever be one file descriptor `1`. Thus these two operations are identical: + +``` +fmt.Fprintf(os.Stdout, "Hello dotGo\n") +syscall.Write(1, []byte("Hello dotGo\n")) +``` + +So let’s look at how the `os` package defines `Stdin`, `Stdout`, and `Stderr`: + +``` +package os + +var ( + Stdin = NewFile(uintptr(syscall.Stdin), "/dev/stdin") + Stdout = NewFile(uintptr(syscall.Stdout), "/dev/stdout") + Stderr = NewFile(uintptr(syscall.Stderr), "/dev/stderr") +) +``` + +There are a few problems with this declaration. Firstly their type is `*os.File` not the respective `io.Reader` or `io.Writer` interfaces. People have long complained that this makes replacing them with alternatives problematic. However the notion of replacing these variables is precisely the point of this digression. Can you safely change the value of `os.Stdout` once your program is running without causing a data race? + +I argue that, in the general case, you cannot. In general, if something is unsafe to do, as programmers we shouldn’t let our users think that it is safe, [lest they begin to depend on that behaviour][3]. + +Could we change the definition of `os.Stdout` and friends so that they retain the observable behaviour of reading and writing, but remain immutable? It turns out, we can do this easily with constants. + +``` +type readfd int + +func (r readfd) Read(buf []byte) (int, error) { + return syscall.Read(int(r), buf) +} + +type writefd int + +func (w writefd) Write(buf []byte) (int, error) { + return syscall.Write(int(w), buf) +} + +const ( + Stdin = readfd(0) + Stdout = writefd(1) + Stderr = writefd(2) +) + +func main() { + fmt.Fprintf(Stdout, "Hello world") +} +``` + +In fact this change causes only one compilation failure in the standard library.2 + +## Sentinel error values + +Another case of things which look like constants but really aren’t, are sentinel error values. `io.EOF`, `sql.ErrNoRows`, `crypto/x509.ErrUnsupportedAlgorithm`, and so on are all examples of sentinel error values. They all fall into a category of _expected_ errors, and because they are expected, you’re expected to check for them. + +To compare the error you have with the one you were expecting, you need to import the package that defines that error. Because, by definition, sentinel errors are exported public variables, any code that imports, for example, the `io` package could change the value of `io.EOF`. + +``` +package nelson + +import "io" + +func init() { + io.EOF = nil // haha! +} +``` + +I’ll say that again. If I know the name of `io.EOF` I can import the package that declares it, which I must if I want to compare it to my error, and thus I could change `io.EOF`‘s value. Historically convention and a bit of dumb luck discourages people from writing code that does this, but technically there is nothing to prevent you from doing so. + +Replacing `io.EOF` is probably going to be detected almost immediately. But replacing a less frequently used sentinel error may cause some interesting side effects: + +``` +package innocent + +import "crypto/rsa" + +func init() { + rsa.ErrVerification = nil // 🤔 +} +``` + +If you were hoping the race detector will spot this subterfuge, I suggest you talk to the folks writing testing frameworks who replace `os.Stdout` without it triggering the race detector. + +## Fungibility + +I want to digress for a moment to talk about _the_ most important property of constants. Constants aren’t just immutable, its not enough that we cannot overwrite their declaration, +Constants are _fungible_. This is a tremendously important property that doesn’t get nearly enough attention. + +Fungible means identical. Money is a great example of fungibility. If you were to lend me 10 bucks, and I later pay you back, the fact that you gave me a 10 dollar note and I returned to you 10 one dollar bills, with respect to its operation as a financial instrument, is irrelevant. Things which are fungible are by definition equal and equality is a powerful property we can leverage for our programs. + +``` +var myEOF = errors.New("EOF") // io/io.go line 38 +fmt.Println(myEOF == io.EOF) // false +``` + +Putting aside the effect of malicious actors in your code base the key design challenge with sentinel errors is they behave like _singletons_ , not _constants_. Even if we follow the exact procedure used by the `io` package to create our own EOF value, `myEOF` and `io.EOF` are not equal. `myEOF` and `io.EOF` are not fungible, they cannot be interchanged. Programs can spot the difference. + +When you combine the lack of immutability, the lack of fungibility, the lack of equality, you have a set of weird behaviours stemming from the fact that sentinel error values in Go are not constant expressions. But what if they were? + +## Constant errors + +Ideally a sentinel error value should behave as a constant. It should be immutable and fungible. Let’s recap how the built in `error` interface works in Go. + +``` +type error interface { + Error() string +} +``` + +Any type with an `Error() string` method fulfils the `error` interface. This includes user defined types, it includes types derived from primitives like string, and it includes constant strings. With that background, consider this error implementation: + +``` +type Error string + +func (e Error) Error() string { + return string(e) +} +``` + +We can use this error type as a constant expression: + +``` +const err = Error("EOF") +``` + +Unlike `errors.errorString`, which is a struct, a compact struct literal initialiser is not a constant expression and cannot be used. + +``` +const err2 = errors.errorString{"EOF"} // doesn't compile +``` + +As constants of this `Error` type are not variables, they are immutable. + +``` +const err = Error("EOF") +err = Error("not EOF") // doesn't compile +``` + +Additionally, two constant strings are always equal if their contents are equal: + +``` +const str1 = "EOF" +const str2 = "EOF" +fmt.Println(str1 == str2) // true +``` + +which means two constants of a type derived from string with the same contents are also equal. + +``` +type Error string + +const err1 = Error("EOF") +const err2 = Error("EOF") + fmt.Println(err1 == err2) // true``` + +``` +Said another way, equal constant `Error` values are the same, in the way that the literal constant `1` is the same as every other literal constant `1`. + +Now we have all the pieces we need to make sentinel errors, like `io.EOF`, and `rsa.ErrVerfication`, immutable, fungible, constant expressions. +``` + + % git diff + diff --git a/src/io/io.go b/src/io/io.go + inde \ No newline at end of file diff --git a/sources/tech/20190610 Tmux Command Examples To Manage Multiple Terminal Sessions.md b/sources/tech/20190610 Tmux Command Examples To Manage Multiple Terminal Sessions.md new file mode 100644 index 0000000000..d9ed871a10 --- /dev/null +++ b/sources/tech/20190610 Tmux Command Examples To Manage Multiple Terminal Sessions.md @@ -0,0 +1,296 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Tmux Command Examples To Manage Multiple Terminal Sessions) +[#]: via: (https://www.ostechnix.com/tmux-command-examples-to-manage-multiple-terminal-sessions/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +Tmux Command Examples To Manage Multiple Terminal Sessions +====== + +![tmux command examples][1] + +We’ve already learned to use [**GNU Screen**][2] to manage multiple Terminal sessions. Today, we will see yet another well-known command-line utility named **“Tmux”** to manage Terminal sessions. Similar to GNU Screen, Tmux is also a Terminal multiplexer that allows us to create number of terminal sessions and run more than one programs or processes at the same time inside a single Terminal window. Tmux is free, open source and cross-platform program that supports Linux, OpenBSD, FreeBSD, NetBSD and Mac OS X. In this guide, we will discuss most-commonly used Tmux commands in Linux. + +### Installing Tmux in Linux + +Tmux is available in the official repositories of most Linux distributions. + +On Arch Linux and its variants, run the following command to install it. + +``` +$ sudo pacman -S tmux +``` + +On Debian, Ubuntu, Linux Mint: + +``` +$ sudo apt-get install tmux +``` + +On Fedora: + +``` +$ sudo dnf install tmux +``` + +On RHEL and CentOS: + +``` +$ sudo yum install tmux +``` + +On SUSE/openSUSE: + +``` +$ sudo zypper install tmux +``` + +Well, we have just installed Tmux. Let us go ahead and see some examples to learn how to use Tmux. + +### Tmux Command Examples To Manage Multiple Terminal Sessions + +The default prefix shortcut to all commands in Tmux is **Ctrl+b**. Just remember this keyboard shortcut when using Tmux. + +* * * + +**Note:** The default prefix to all **Screen** commands is **Ctrl+a**. + +* * * + +##### Creating Tmux sessions + +To create a new Tmux session and attach to it, run the following command from the Terminal: + +``` +tmux +``` + +Or, + +``` +tmux new +``` + +Once you are inside the Tmux session, you will see a **green bar at the bottom** as shown in the screenshot below. + +![][3] + +New Tmux session + +It is very handy to verify whether you’re inside a Tmux session or not. + +##### Detaching from Tmux sessions + +To detach from a current Tmux session, just press **Ctrl+b** and **d**. You don’t need to press this both Keyboard shortcut at a time. First press “Ctrl+b” and then press “d”. + +Once you’re detached from a session, you will see an output something like below. + +``` +[detached (from session 0)] +``` + +##### Creating named sessions + +If you use multiple sessions, you might get confused which programs are running on which sessions. In such cases, you can just create named sessions. For example if you wanted to perform some activities related to web server in a session, just create the Tmux session with a custom name, for example **“webserver”** (or any name of your choice). + +``` +tmux new -s webserver +``` + +Here is the new named Tmux session. + +![][4] + +Tmux session with a custom name + +As you can see in the above screenshot, the name of the Tmux session is **webserver**. This way you can easily identify which program is running on which session. + +To detach, simply press **Ctrl+b** and **d**. + +##### List Tmux sessions + +To view the list of open Tmux sessions, run: + +``` +tmux ls +``` + +Sample output: + +![][5] + +List Tmux sessions + +As you can see, I have two open Tmux sessions. + +##### Creating detached sessions + +Sometimes, you might want to simply create a session and don’t want to attach to it automatically. + +To create a new detached session named **“ostechnix”** , run: + +``` +tmux new -s ostechnix -d +``` + +The above command will create a new Tmux session called “ostechnix”, but won’t attach to it. + +You can verify if the session is created using “tmux ls” command: + +![][6] + +Create detached Tmux sessions + +##### Attaching to Tmux sessions + +You can attach to the last created session by running this command: + +``` +tmux attach +``` + +Or, + +``` +tmux a +``` + +If you want to attach to any specific named session, for example “ostechnix”, run: + +``` +tmux attach -t ostechnix +``` + +Or, shortly: + +``` +tmux a -t ostechnix +``` + +##### Kill Tmux sessions + +When you’re done and no longer required a Tmux session, you can kill it at any time with command: + +``` +tmux kill-session -t ostechnix +``` + +To kill when attached, press **Ctrl+b** and **x**. Hit “y” to kill the session. + +You can verify if the session is closed with “tmux ls” command. + +To Kill Tmux server along with all Tmux sessions, run: + +``` +tmux kill-server +``` + +Be careful! This will terminate all Tmux sessions even if there are any running jobs inside the sessions without any warning. + +When there were no running Tmux sessions, you will see the following output: + +``` +$ tmux ls +no server running on /tmp/tmux-1000/default +``` + +##### Split Tmux Session Windows + +Tmux has an option to split a single Tmux session window into multiple smaller windows called **Tmux panes**. This way we can run different programs on each pane and interact with all of them simultaneously. Each pane can be resized, moved and closed without affecting the other panes. We can split a Tmux window either horizontally or vertically or both at once. + +**Split panes horizontally** + +To split a pane horizontally, press **Ctrl+b** and **”** (single quotation mark). + +![][7] + +Split Tmux pane horizontally + +Use the same key combination to split the panes further. + +**Split panes vertically** + +To split a pane vertically, press **Ctrl+b** and **%**. + +![][8] + +Split Tmux panes vertically + +**Split panes horizontally and vertically** + +We can also split a pane horizontally and vertically at the same time. Take a look at the following screenshot. + +![][9] + +Split Tmux panes + +First, I did a horizontal split by pressing **Ctrl+b “** and then split the lower pane vertically by pressing **Ctrl+b %**. + +As you see in the above screenshot, I am running three different programs on each pane. + +**Switch between panes** + +To switch between panes, press **Ctrl+b** and **Arrow keys (Left, Right, Up, Down)**. + +**Send commands to all panes** + +In the previous example, we run three different commands on each pane. However, it is also possible to run send the same commands to all panes at once. + +To do so, press **Ctrl+b** and type the following command and hit ENTER: + +``` +:setw synchronize-panes +``` + +Now type any command on any pane. You will see that the same command is reflected on all panes. + +**Swap panes** + +To swap panes, press **Ctrl+b** and **o**. + +**Show pane numbers** + +Press **Ctrl+b** and **q** to show pane numbers. + +**Kill panes** + +To kill a pane, simply type **exit** and ENTER key. Alternatively, press **Ctrl+b** and **x**. You will see a confirmation message. Just press **“y”** to close the pane. + +![][10] + +Kill Tmux panes + +At this stage, you will get a basic idea of Tmux and how to use it to manage multiple Terminal sessions. For more details, refer man pages. + +``` +$ man tmux +``` + +Both GNU Screen and Tmux utilities can be very helpful when managing servers remotely via SSH. Learn Screen and Tmux commands thoroughly to manage your remote servers like a pro. + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/tmux-command-examples-to-manage-multiple-terminal-sessions/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/06/Tmux-720x340.png +[2]: https://www.ostechnix.com/screen-command-examples-to-manage-multiple-terminal-sessions/ +[3]: https://www.ostechnix.com/wp-content/uploads/2019/06/Tmux-session.png +[4]: https://www.ostechnix.com/wp-content/uploads/2019/06/Named-Tmux-session.png +[5]: https://www.ostechnix.com/wp-content/uploads/2019/06/List-Tmux-sessions.png +[6]: https://www.ostechnix.com/wp-content/uploads/2019/06/Create-detached-sessions.png +[7]: https://www.ostechnix.com/wp-content/uploads/2019/06/Horizontal-split.png +[8]: https://www.ostechnix.com/wp-content/uploads/2019/06/Vertical-split.png +[9]: https://www.ostechnix.com/wp-content/uploads/2019/06/Split-Panes.png +[10]: https://www.ostechnix.com/wp-content/uploads/2019/06/Kill-panes.png diff --git a/sources/tech/20190611 Cisco software to make networks smarter, safer, more manageable.md b/sources/tech/20190611 Cisco software to make networks smarter, safer, more manageable.md new file mode 100644 index 0000000000..7bdf5361ab --- /dev/null +++ b/sources/tech/20190611 Cisco software to make networks smarter, safer, more manageable.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Cisco software to make networks smarter, safer, more manageable) +[#]: via: (https://www.networkworld.com/article/3401523/cisco-software-to-make-networks-smarter-safer-more-manageable.html) +[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) + +Cisco software to make networks smarter, safer, more manageable +====== +Cisco software announced at Cisco Live embraces AI to help customers set consistent network and security policies across their domains and improve intent-based networking. +![bigstock][1] + +SAN DIEGO—Cisco injected a number of new technologies into its key networking control-point software that makes it easier to stretch networking from the data center to the cloud while making the whole environment smarter and easier to manage. + +At the company’s annual Cisco Live customer event here it rolled out software that lets customers more easily meld typically siloed domains across the enterprise and cloud to the wide area network. The software enables what Cisco calls multidomain integration that lets customers set policies to apply uniform access controls to users, devices and applications regardless of where they connect to the network, the company said. + +**More about SD-WAN** + + * [How to buy SD-WAN technology: Key questions to consider when selecting a supplier][2] + * [How to pick an off-site data-backup method][3] + * [SD-Branch: What it is and why you’ll need it][4] + * [What are the options for security SD-WAN?][5] + + + +The company also unveiled Cisco AI Network Analytics, a software package that uses [AI and machine learning techniques][6] to learn network traffic and security patterns that can help customers spot and fix problems proactively across the enterprise. + +All of the new software runs on Cisco’s DNA Center platform which is rapidly becoming an ever-more crucial component to the company’s intent-based networking plans. DNA Center has always been important since its introduction two years ago as it features automation capabilities, assurance setting, fabric provisioning and policy-based segmentation for enterprise networks. + +Beyond device management and configuration, Cisco DNA Center gives IT teams the ability to control access through policies using Software-Defined Access (SD-Access), automatically provision through Cisco DNA Automation, virtualize devices through Cisco Network Functions Virtualization (NFV), and lower security risks through segmentation and Encrypted Traffic Analysis. But experts say these software enhancements take it to a new level. + +“You can call it the rise of DNA Center and it’s important because it lets customers manage and control their entire network from one place – similar to what VMware does with its vCenter,” said Zeus Kerravala, founder and principal analyst with ZK Research. vCenter is VMware’s centralized platform for controlling its vSphere virtualized environments. + +“Cisco will likely roll more and more functionality into DNA Center in the future making it stronger,” Kerravala said. + +**[[Become a Microsoft Office 365 administrator in record time with this quick start course from PluralSight.][7] ]** + +Together the new software and DNA Center will help customers set consistent policies across their domains and collaborate with others for the benefit of the entire network. Customers can define a policy once, apply it everywhere, and monitor it systematically to ensure it is realizing its business intent, said Prashanth Shenoy, Cisco vice president of marketing for Enterprise Network and Mobility. It will help customers segment their networks to reduce congestion, improve security and compliance and contain network problems, he said. + +“In the campus, Cisco’s SD-Access solution uses this technology to group users and devices within the segments it creates according to their access privileges. Similarly, Cisco ACI creates groups of similar applications in the data center,” Shenoy said. “When integrated, SD-Access and ACI exchange their groupings and provide each other an awareness into their access policies. With this knowledge, each of the domains can map user groups with applications, jointly enforce policies, and block unauthorized access to applications.” + +In the Cisco world it basically means there now can be a unification of its central domain network controllers and they can work together and let customers drive policies across domains. + +Cisco also said that security capabilities can be spread across domains. + +Cisco Advanced Malware Protection (AMP) prevents breaches, monitors malicious behavior and detects and removes malware. Security constructs built into Cisco SD-WAN, and the recently announced SD-WAN onRamp for CoLocation, provide a full security stack that applies protection consistently from user to branch to clouds. Cisco Stealthwatch and Stealthwatch Cloud detect threats across the private network, public clouds, and in encrypted traffic. + +Analysts said Cisco’s latest efforts are an attempt to simplify what are fast becoming complex networks with tons of new devices and applications to support. + +Cisco’s initial efforts were product specific, but its latest announcements cross products and domains, said Lee Doyle principal analyst with Doyle Research. “Cisco is making a strong push to make its networks easier to use, manage and program.” + +That same strategy is behind the new AI Analytics program. + +“Trying to manually analyze and troubleshoot the traffic flowing through thousands of APs, switches and routers is a near impossible task, even for the most sophisticated NetOps team. In a wireless environment, onboarding and interference errors can crop up randomly and intermittently, making it even more difficult to determine probable causes,” said Anand Oswal, senior vice president, engineering for Cisco’s Enterprise Networking Business. + +Cisco has been integrating AI/ML into many operational and security components, with Cisco DNA Center the focal point for insights and actions, Oswal wrote in a [blog][8] about the AI announcement. AI Network Analytics collects massive amounts of network data from Cisco DNA Centers at participating customer sites, encrypts and anonymizes the data to ensure privacy, and collates all of it into the Cisco Worldwide Data Platform. In this cloud, the aggregated data is analyzed with deep machine learning to reveal patterns and anomalies such as: + + * Highly personalized network baselines with multiple levels of granularity that define “normal” for a given network, site, building and SSID. + + * Sudden changes in onboarding times for Wi-Fi devices, by individual APs, floor, building, campus +``` + +``` + and branch. + + * Simultaneous connectivity failures with numerous clients at a specific location + + * Changes in SaaS and Cloud application performance via SD-WAN direct internet connections or [Cloud OnRamps][9]. + + * Pattern-matching capabilities of ML will be used to spot anomalies in network behavior that might otherwise be missed. + + + + +“The intelligence of its large base of customers can help Cisco to derive important insights about how users can better manage their networks and solve problems and the power of MI/AI technology will continue to improve over time,” Doyle said. + +Join the Network World communities on [Facebook][10] and [LinkedIn][11] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3401523/cisco-software-to-make-networks-smarter-safer-more-manageable.html + +作者:[Michael Cooney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Michael-Cooney/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/11/intelligentnetwork-100780636-large.jpg +[2]: https://www.networkworld.com/article/3323407/sd-wan/how-to-buy-sd-wan-technology-key-questions-to-consider-when-selecting-a-supplier.html +[3]: https://www.networkworld.com/article/3328488/backup-systems-and-services/how-to-pick-an-off-site-data-backup-method.html +[4]: https://www.networkworld.com/article/3250664/lan-wan/sd-branch-what-it-is-and-why-youll-need-it.html +[5]: https://www.networkworld.com/article/3285728/sd-wan/what-are-the-options-for-securing-sd-wan.html?nsdr=true +[6]: https://www.networkworld.com/article/3400382/cisco-will-use-aiml-to-boost-intent-based-networking.html +[7]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fcourses%2Fadministering-office-365-quick-start +[8]: https://blogs.cisco.com/analytics-automation/cisco-ai-network-analytics-making-networks-smarter-simpler-and-more-secure +[9]: https://www.networkworld.com/article/3393232/cisco-boosts-sd-wan-with-multicloud-to-branch-access-system.html +[10]: https://www.facebook.com/NetworkWorld/ +[11]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20190611 How To Find Linux System Details Using inxi.md b/sources/tech/20190611 How To Find Linux System Details Using inxi.md new file mode 100644 index 0000000000..4fc24fd137 --- /dev/null +++ b/sources/tech/20190611 How To Find Linux System Details Using inxi.md @@ -0,0 +1,608 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How To Find Linux System Details Using inxi) +[#]: via: (https://www.ostechnix.com/how-to-find-your-system-details-using-inxi/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +How To Find Linux System Details Using inxi +====== + +![find Linux system details using inxi][1] + +**Inxi** is a free, open source, and full featured command line system information tool. It shows system hardware, CPU, drivers, Xorg, Desktop, Kernel, GCC version(s), Processes, RAM usage, and a wide variety of other useful information. Be it a hard disk or CPU, mother board or the complete detail of the entire system, inxi will display it more accurately in seconds. Since it is CLI tool, you can use it in Desktop or server edition. Inxi is available in the default repositories of most Linux distributions and some BSD systems. + +### Install inxi + +**On Arch Linux and derivatives:** + +To install inxi in Arch Linux or its derivatives like Antergos, and Manajaro Linux, run: + +``` +$ sudo pacman -S inxi +``` + +Just in case if Inxi is not available in the default repositories, try to install it from AUR (It varies year to year) using any AUR helper programs. + +Using [**Yay**][2]: + +``` +$ yay -S inxi +``` + +**On Debian / Ubuntu and derivatives:** + +``` +$ sudo apt-get install inxi +``` + +**On Fedora / RHEL / CentOS / Scientific Linux:** + +inxi is available in the Fedora default repositories. So, just run the following command to install it straight away. + +``` +$ sudo dnf install inxi +``` + +In RHEL and its clones like CentOS and Scientific Linux, you need to add the EPEL repository and then install inxi. + +To install EPEL repository, just run: + +``` +$ sudo yum install epel-release +``` + +After installing EPEL repository, install inxi using command: + +``` +$ sudo yum install inxi +``` + +**On SUSE/openSUSE:** + +``` +$ sudo zypper install inxi +``` + +### Find Linux System Details Using inxi + +inxi will require some additional programs to operate properly. They will be installed along with inxi. However, in case if they are not installed automatically, you need to find and install them. + +To list all required programs, run: + +``` +$ inxi --recommends +``` + +If you see any missing programs, then install them before start using inxi. + +Now, let us see how to use it to reveal the Linux system details. inxi usage is pretty simple and straight forward. + +Open up your Terminal and run the following command to print a short summary of CPU, memory, hard drive and kernel information: + +``` +$ inxi +``` + +**Sample output:** + +``` +CPU: Dual Core Intel Core i3-2350M (-MT MCP-) speed/min/max: 798/800/2300 MHz +Kernel: 5.1.2-arch1-1-ARCH x86_64 Up: 1h 31m Mem: 2800.5/7884.2 MiB (35.5%) +Storage: 465.76 GiB (80.8% used) Procs: 163 Shell: bash 5.0.7 inxi: 3.0.34 +``` + +![][3] + +Find Linux System Details Using inxi + +As you can see, Inxi displays the following details of my Arch Linux desktop: + + 1. CPU type, + 2. CPU speed, + 3. Kernel details, + 4. Uptime, + 5. Memory details (Total and used memory), + 6. Hard disk size along with current usage, + 7. Procs, + 8. Default shell details, + 9. Inxi version. + + + +To display full summary, use **“-F”** switch as shown below. + +``` +$ inxi -F +``` + +**Sample output:** + +``` +System: Host: sk Kernel: 5.1.2-arch1-1-ARCH x86_64 bits: 64 Desktop: Deepin 15.10.1 Distro: Arch Linux +Machine: Type: Portable System: Dell product: Inspiron N5050 v: N/A serial: + Mobo: Dell model: 01HXXJ v: A05 serial: BIOS: Dell v: A05 date: 08/03/2012 +Battery: ID-1: BAT0 charge: 39.0 Wh condition: 39.0/48.8 Wh (80%) +CPU: Topology: Dual Core model: Intel Core i3-2350M bits: 64 type: MT MCP L2 cache: 3072 KiB + Speed: 798 MHz min/max: 800/2300 MHz Core speeds (MHz): 1: 798 2: 798 3: 798 4: 798 +Graphics: Device-1: Intel 2nd Generation Core Processor Family Integrated Graphics driver: i915 v: kernel + Display: x11 server: X.Org 1.20.4 driver: modesetting unloaded: vesa resolution: 1366x768~60Hz + Message: Unable to show advanced data. Required tool glxinfo missing. +Audio: Device-1: Intel 6 Series/C200 Series Family High Definition Audio driver: snd_hda_intel + Sound Server: ALSA v: k5.1.2-arch1-1-ARCH +Network: Device-1: Realtek RTL810xE PCI Express Fast Ethernet driver: r8169 + IF: enp5s0 state: down mac: 45:c8:gh:89:b6:45 + Device-2: Qualcomm Atheros AR9285 Wireless Network Adapter driver: ath9k + IF: wlp9s0 state: up mac: c3:11:96:22:87:3g + Device-3: Qualcomm Atheros AR3011 Bluetooth type: USB driver: btusb +Drives: Local Storage: total: 465.76 GiB used: 376.31 GiB (80.8%) + ID-1: /dev/sda vendor: Seagate model: ST9500325AS size: 465.76 GiB +Partition: ID-1: / size: 456.26 GiB used: 376.25 GiB (82.5%) fs: ext4 dev: /dev/sda2 + ID-2: /boot size: 92.8 MiB used: 62.9 MiB (67.7%) fs: ext4 dev: /dev/sda1 + ID-3: swap-1 size: 2.00 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/sda3 +Sensors: System Temperatures: cpu: 58.0 C mobo: N/A + Fan Speeds (RPM): cpu: 3445 +Info: Processes: 169 Uptime: 1h 38m Memory: 7.70 GiB used: 2.94 GiB (38.2%) Shell: bash inxi: 3.0.34 +``` + +Inxi used on IRC automatically filters out your network device MAC address, WAN and LAN IP, your /home username directory in partitions, and a few other items in order to maintain basic privacy and security. You can also trigger this filtering with the **-z** option like below. + +``` +$ inxi -Fz +``` + +To override the IRC filter, use the **-Z** option. + +``` +$ inxi -FZ +``` + +This can be useful in debugging network connection issues online in a private chat, for example. Please be very careful while using -Z option. It will display your MAC addresses. You shouldn’t share the results got with -Z option in public forums. + +##### Displaying device-specific details + +When running inxi without any options, you will get basic details of your system, such as CPU, Memory, Kernel, Uptime, harddisk etc. + +You can, of course, narrow down the result to show specific device details using various options. Inxi has numerous options (both uppercase and lowercase). + +First, we will see example commands for all uppercase options in alphabetical order. Some commands may require root/sudo privileges to get actual data. + +####### **Uppercase options** + +**1\. Display Audio/Sound card details** + +To show your audio and sound card(s) information with sound card driver, use **-A** option. + +``` +$ inxi -A +Audio: Device-1: Intel 6 Series/C200 Series Family High Definition Audio driver: snd_hda_intel + Sound Server: ALSA v: k5.1.2-arch1-1-ARCH +``` + +**2\. Display Battery details** + +To show battery details of your system with current charge and condition, use **-B** option. + +``` +$ inxi -B +Battery: ID-1: BAT0 charge: 39.0 Wh condition: 39.0/48.8 Wh (80%) +``` + +**3\. Display CPU details** + +To show complete CPU details including no of cores, CPU model, CPU cache, CPU clock speed, CPU min/max speed etc., use **-C** option. + +``` +$ inxi -C +CPU: Topology: Dual Core model: Intel Core i3-2350M bits: 64 type: MT MCP L2 cache: 3072 KiB + Speed: 798 MHz min/max: 800/2300 MHz Core speeds (MHz): 1: 798 2: 798 3: 798 4: 798 +``` + +**4\. Display hard disk details** + +To show information about your hard drive, such as Disk type, vendor, device ID, model, disk size, total disk space, used percentage etc., use **-D** option. + +``` +$ inxi -D +Drives: Local Storage: total: 465.76 GiB used: 376.31 GiB (80.8%) + ID-1: /dev/sda vendor: Seagate model: ST9500325AS size: 465.76 GiB +``` + +**5\. Disply Graphics details** + +To show details about the graphics card, including details of grahics card, driver, vendor, display server, resolution etc., use **-G** option. + +``` +$ inxi -G +Graphics: Device-1: Intel 2nd Generation Core Processor Family Integrated Graphics driver: i915 v: kernel + Display: x11 server: X.Org 1.20.4 driver: modesetting unloaded: vesa resolution: 1366x768~60Hz + Message: Unable to show advanced data. Required tool glxinfo missing. +``` + +**6\. Display details about processes, uptime, memory, inxi version** + +To show information about no of processes, total uptime, total memory with used memory, Shell details and inxi version etc., use **-I** option. + +``` +$ inxi -I +Info: Processes: 170 Uptime: 5h 47m Memory: 7.70 GiB used: 3.27 GiB (42.4%) Shell: bash inxi: 3.0.34 +``` + +**7\. Display Motherboard details** + +To show information about your machine details, manufacturer, motherboard, BIOS, use **-M** option. + +``` +$ inxi -M +Machine: Type: Portable System: Dell product: Inspiron N5050 v: N/A serial: + Mobo: Dell model: 034ygt v: A018 serial: BIOS: Dell v: A001 date: 09/04/2015 +``` + +**8\. Display network card details** + +To show information about your network card, including vendor, card driver and no of network interfaces etc., use **-N** option. + +``` +$ inxi -N +Network: Device-1: Realtek RTL810xE PCI Express Fast Ethernet driver: r8169 + Device-2: Qualcomm Atheros AR9285 Wireless Network Adapter driver: ath9k + Device-3: Qualcomm Atheros AR3011 Bluetooth type: USB driver: btusb +``` + +If you want to show the advanced details of the network cards, such as MAC address, speed and state of nic, use **-n** option. + +``` +$ inxi -n +``` + +Please careful sharing this details on public forum. + +**9\. Display Partition details** + +To display basic partition information, use **-P** option. + +``` +$ inxi -P +Partition: ID-1: / size: 456.26 GiB used: 376.25 GiB (82.5%) fs: ext4 dev: /dev/sda2 + ID-2: /boot size: 92.8 MiB used: 62.9 MiB (67.7%) fs: ext4 dev: /dev/sda1 + ID-3: swap-1 size: 2.00 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/sda3 +``` + +To show full partition information including mount points, use **-p** option. + +``` +$ inxi -p +``` + +**10\. Display RAID details** + +To show RAID info, use **-R** option. + +``` +$ inxi -R +``` + +**11\. Display system details** + +To show Linux system information such as hostname, kernel, DE, OS version etc., use **-S** option. + +``` +$ inxi -S +System: Host: sk Kernel: 5.1.2-arch1-1-ARCH x86_64 bits: 64 Desktop: Deepin 15.10.1 Distro: Arch Linux +``` + +**12\. Displaying weather details** + +Inixi is not just for finding hardware details. It is useful for getting other stuffs too. + +For example, you can display the weather details of a given location. To do so, run inxi with **-W** option like below. + +``` +$ inxi -W 95623,us +Weather: Temperature: 21.1 C (70 F) Conditions: Scattered clouds Current Time: Tue 11 Jun 2019 04:34:35 AM PDT + Source: WeatherBit.io +``` + +Please note that you should use only ASCII letters in city/state/country names to get valid results. + +####### Lowercase options + +**1\. Display basic system details** + +To show only the basic summary of your system details, use **-b** option. + +``` +$ inxi -b +``` + +Alternatively, you can use this command: + +Both servers the same purpose. + +``` +$ inxi -v 2 +``` + +**2\. Set color scheme** + +We can set different color schemes for inxi output using **-c** option. Yu can set color scheme number from **0** to **42**. If no scheme number is supplied, **0** is assumed. + +Here is inxi output with and without **-c** option. + +![][4] + +inxi output without color scheme + +As you can see, when we run inxi with -c option, the color scheme is disabled. The -c option is useful to turnoff colored output when redirecting clean output without escape codes to a text file. + +Similarly, we can use other color scheme values. + +``` +$ inxi -c10 + +$ inxi -c42 +``` + +**3\. Display optical drive details** + +We can show the optical drive data details along with local hard drive details using **-d** option. + +``` +$ inxi -d +Drives: Local Storage: total: 465.76 GiB used: 376.31 GiB (80.8%) + ID-1: /dev/sda vendor: Seagate model: ST9500325AS size: 465.76 GiB + Optical-1: /dev/sr0 vendor: PLDS model: DVD+-RW DS-8A8SH dev-links: cdrom + Features: speed: 24 multisession: yes audio: yes dvd: yes rw: cd-r,cd-rw,dvd-r,dvd-ram +``` + +**4\. Display all CPU flags** + +To show all CPU flags used, run: + +``` +$ inxi -f +``` + +**5\. Display IP details** + +To show WAN and local ip address along network card details such as device vendor, driver, mac, state etc., use **-i** option. + +``` +$ inxi -i +``` + +**6\. Display partition labels** + +If you have set labels for the partitions, you can view them using **-l** option. + +``` +$ inxi -l +``` + +You can also view the labels of all partitions along with mountpoints using command: + +``` +$ inxi -pl +``` + +**7\. Display Memory details** + +We can display memory details such as total size of installed RAM, how much memory is used, no of available DIMM slots, total size of supported RAM, how much RAM is currently installed in each slots etc., using **-m** option. + +``` +$ sudo inxi -m +[sudo] password for sk: +Memory: RAM: total: 7.70 GiB used: 2.26 GiB (29.3%) + Array-1: capacity: 16 GiB slots: 2 EC: None + Device-1: DIMM_A size: 4 GiB speed: 1067 MT/s + Device-2: DIMM_B size: 4 GiB speed: 1067 MT/s +``` + +**8\. Display unmounted partition details** + +To show unmounted partition details, use **-o** option. + +``` +$ inxi -o +``` + +If there were no unmounted partitions in your system, you will see an output something like below. + +``` +Unmounted: Message: No unmounted partitions found. +``` + +**9\. Display list of repositories** + +To display the the list of repositories in your system, use **-r** option. + +``` +$ inxi -r +``` + +**Sample output:** + +``` +Repos: Active apt sources in file: /etc/apt/sources.list +deb http://in.archive.ubuntu.com/ubuntu/ xenial main restricted +deb http://in.archive.ubuntu.com/ubuntu/ xenial-updates main restricted +deb http://in.archive.ubuntu.com/ubuntu/ xenial universe +deb http://in.archive.ubuntu.com/ubuntu/ xenial-updates universe +deb http://in.archive.ubuntu.com/ubuntu/ xenial multiverse +deb http://in.archive.ubuntu.com/ubuntu/ xenial-updates multiverse +deb http://in.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse +deb http://security.ubuntu.com/ubuntu xenial-security main restricted +deb http://security.ubuntu.com/ubuntu xenial-security universe +deb http://security.ubuntu.com/ubuntu xenial-security multiverse +``` + +* * * + +**Suggested read:** + + * [**How To Find The List Of Installed Repositories From Commandline In Linux**][5] + + + +* * * + +**10\. Show system temperature, fan speed details** + +Inxi is capable to find motherboard/CPU/GPU temperatures and fan speed. + +``` +$ inxi -s +Sensors: System Temperatures: cpu: 60.0 C mobo: N/A + Fan Speeds (RPM): cpu: 3456 +``` + +Please note that Inxi requires sensors to find the system temperature. Make sure **lm_sensors** is installed and correctly configured in your system. For more details about lm_sensors, check the following guide. + + * [**How To View CPU Temperature On Linux**][6] + + + +**11\. Display details about processes** + +To show the list processes top 5 processes which are consuming most CPU and Memory, simply run: + +``` +$ inxi -t +Processes: CPU top: 5 + 1: cpu: 14.3% command: firefox pid: 15989 + 2: cpu: 10.5% command: firefox pid: 13487 + 3: cpu: 7.1% command: firefox pid: 15062 + 4: cpu: 3.1% command: xorg pid: 13493 + 5: cpu: 3.0% command: firefox pid: 14954 + System RAM: total: 7.70 GiB used: 2.99 GiB (38.8%) + Memory top: 5 + 1: mem: 1115.8 MiB (14.1%) command: firefox pid: 15989 + 2: mem: 606.6 MiB (7.6%) command: firefox pid: 13487 + 3: mem: 339.3 MiB (4.3%) command: firefox pid: 13630 + 4: mem: 303.1 MiB (3.8%) command: firefox pid: 18617 + 5: mem: 260.1 MiB (3.2%) command: firefox pid: 15062 +``` + +We can also sort this output by either CPU usage or Memory usage. + +For instance, to find the which top 5 processes are consuming most memory, use the following command: + +``` +$ inxi -t m +Processes: System RAM: total: 7.70 GiB used: 2.73 GiB (35.4%) + Memory top: 5 + 1: mem: 966.1 MiB (12.2%) command: firefox pid: 15989 + 2: mem: 468.2 MiB (5.9%) command: firefox pid: 13487 + 3: mem: 347.9 MiB (4.4%) command: firefox pid: 13708 + 4: mem: 306.7 MiB (3.8%) command: firefox pid: 13630 + 5: mem: 247.2 MiB (3.1%) command: firefox pid: 15062 +``` + +To sort the top 5 processes based on CPU usage, run: + +``` +$ inxi -t c +Processes: CPU top: 5 + 1: cpu: 14.9% command: firefox pid: 15989 + 2: cpu: 10.6% command: firefox pid: 13487 + 3: cpu: 7.0% command: firefox pid: 15062 + 4: cpu: 3.1% command: xorg pid: 13493 + 5: cpu: 2.9% command: firefox pid: 14954 +``` + +Bydefault, Inxi will display the top 5 processes. You can change the number of processes, for example 10, like below. + +``` +$ inxi -t cm10 +Processes: CPU top: 10 + 1: cpu: 14.9% command: firefox pid: 15989 + 2: cpu: 10.6% command: firefox pid: 13487 + 3: cpu: 7.0% command: firefox pid: 15062 + 4: cpu: 3.1% command: xorg pid: 13493 + 5: cpu: 2.9% command: firefox pid: 14954 + 6: cpu: 2.8% command: firefox pid: 13630 + 7: cpu: 1.8% command: firefox pid: 18325 + 8: cpu: 1.4% command: firefox pid: 18617 + 9: cpu: 1.3% command: firefox pid: 13708 + 10: cpu: 0.8% command: firefox pid: 14427 + System RAM: total: 7.70 GiB used: 2.92 GiB (37.9%) + Memory top: 10 + 1: mem: 1160.9 MiB (14.7%) command: firefox pid: 15989 + 2: mem: 475.1 MiB (6.0%) command: firefox pid: 13487 + 3: mem: 353.4 MiB (4.4%) command: firefox pid: 13708 + 4: mem: 308.0 MiB (3.9%) command: firefox pid: 13630 + 5: mem: 269.6 MiB (3.4%) command: firefox pid: 15062 + 6: mem: 249.3 MiB (3.1%) command: firefox pid: 14427 + 7: mem: 238.5 MiB (3.0%) command: firefox pid: 14954 + 8: mem: 208.2 MiB (2.6%) command: firefox pid: 18325 + 9: mem: 194.0 MiB (2.4%) command: firefox pid: 18617 + 10: mem: 143.6 MiB (1.8%) command: firefox pid: 23960 +``` + +The above command will display the top 10 processes that consumes the most CPU and Memory. + +To display only top10 based on memory usage, run: + +``` +$ inxi -t m10 +``` + +**12\. Display partition UUID details** + +To show partition UUIDs ( **U** niversally **U** nique **Id** entifier), use **-u** option. + +``` +$ inxi -u +``` + +There are much more options are yet to be covered. But, these are just enough to get almost all details of your Linux box. + +For more details and options, refer the man page. + +``` +$ man inxi +``` + +* * * + +**Related read:** + + * **[Neofetch – Display your Linux system’s information][7]** + + + +* * * + +The primary purpose of Inxi tool is to use in IRC or forum support. If you are looking for any help via a forum or website where someone is asking the specification of your system, just run this command, and copy/paste the output. + +**Resources:** + + * [**Inxi GitHub Repository**][8] + * [**Inxi home page**][9] + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-find-your-system-details-using-inxi/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2016/08/inxi-520x245-1-720x340.png +[2]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ +[3]: http://www.ostechnix.com/wp-content/uploads/2016/08/Find-Linux-System-Details-Using-inxi.png +[4]: http://www.ostechnix.com/wp-content/uploads/2016/08/inxi-output-without-color-scheme.png +[5]: https://www.ostechnix.com/find-list-installed-repositories-commandline-linux/ +[6]: https://www.ostechnix.com/view-cpu-temperature-linux/ +[7]: http://www.ostechnix.com/neofetch-display-linux-systems-information/ +[8]: https://github.com/smxi/inxi +[9]: http://smxi.org/docs/inxi.htm diff --git a/sources/tech/20190611 Step by Step Zorin OS 15 Installation Guide with Screenshots.md b/sources/tech/20190611 Step by Step Zorin OS 15 Installation Guide with Screenshots.md new file mode 100644 index 0000000000..79d0b9e1a5 --- /dev/null +++ b/sources/tech/20190611 Step by Step Zorin OS 15 Installation Guide with Screenshots.md @@ -0,0 +1,204 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Step by Step Zorin OS 15 Installation Guide with Screenshots) +[#]: via: (https://www.linuxtechi.com/zorin-os-15-installation-guide-screenshots/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +Step by Step Zorin OS 15 Installation Guide with Screenshots +====== + +Good News for all the Zorin users out there! Zorin has launched its latest version (Zorin OS 15) of its Ubuntu based Linux distro. This version is based on Ubuntu 18.04.2, since its launch in July 2009, it is estimated that this popular distribution has reached more than 17 million downloads. Zorin is renowned for creating a distribution for beginner level users and the all new Zorin OS 15 comes packed with a lot of goodies that surely will make Zorin OS lovers happy. Let’s see some of the major enhancements made in the latest version. + +### New Features of Zorin OS 15 + +Zorin OS has always amazed users with different set of features when every version is released Zorin OS 15 is no exception as it comes with a lot of new features as outlined below: + +**Enhanced User Experience** + +The moment you look at the Zorin OS 15, you will ask whether it is a Linux distro because it looks more like a Windows OS. According to Zorin, it wanted Windows users to get ported to Linux in a more user-friendly manner. And it features a Windows like Start menu, quick app launchers, a traditional task bar section, system tray etc. + +**Zorin Connect** + +Another major highlight of Zorin OS 15 is the ability to integrate your Android Smartphones seamlessly with your desktop using the Zorin Connect application. With your phone connected, you can share music, videos and other files between your phone and desktop. You can even use your phone as a mouse to control the desktop. You can also easily control the media playback in your desktop from your phone itself. Quickly reply to all your messages and notifications sent to your phone from your desktop. + +**New GTK Theme** + +Zorin OS 15 ships with an all new GTK Theme that has been exclusively built for this distro and the theme is available in 6 different colors along with the hugely popular dark theme. Another highlight is that the OS automatically detects the time of the day and changes the desktop theme accordingly. Say for example, during sunset it switches to a dark theme whereas in the morning it switches to bright theme automatically. + +**Other New Features:** + +Zorin OS 15 comes packed with a lot of new features including: + + * Compatible with Thunderbolt 3.0 devices + * Supports color emojis + * Comes with an upgraded Linux Kernel 4.18 + * Customized settings available for application menu and task bar + * System font changed to Inter + * Supports renaming bulk files + + + +### Minimum system requirements for Zorin OS 15 (Core): + + * Dual Core 64-bit (1GHZ) + * 2 GB RAM + * 10 GB free disk space + * Internet Connection Optional + * Display (800×600) + + + +### Step by Step Guide to Install Zorin OS 15 (Core) + +Before you start installing Zorin OS 15, ensure you have a copy of the Zorin OS 15 downloaded in your system. If not download then refer official website of [Zorin OS 15][1]. Remember this Linux distribution is available in 4 versions including: + + * Ultimate (Paid Version) + * Core (Free Version) + * Lite (Free Version) + * Education (Free Version) + + + +Note: In this article I will demonstrate Zorin OS 15 Core Installation Steps + +### Step 1) Create Zorin OS 15 Bootable USB Disk + +Once you have downloaded Zorin OS 15, copy the ISO into an USB disk and create a bootable disk. Change our system settings to boot using an USB disk and restart your system. Once you restart your system, you will see the screen as shown below. Click “ **Install or Try Zorin OS** ” + + + +### Step 2) Choose Install Zorin OS + +In the next screen, you will be shown option to whether install Zorin OS 15 or to try Zorin OS. Click “ **Install Zorin OS** ” to continue the installation process. + + + +### Step 3) Choose Keyboard Layout + +Next step is to choose your keyboard layout. By default, English (US) is selected and if you want to choose a different language, then choose it and click “ **Continue** ” + + + +### Step 4) Download Updates and Other Software + +In the next screen, you will be asked whether you need to download updates while you are installing Zorin OS and install other 3rd party applications. In case your system is connected to internet then you can select both of these options, but by doing so your installation time increases considerably, or if you don’t want to install updates and third party software during the installation then untick both these options and click “Continue” + + + +### Step 5) Choose Zorin OS 15 Installation Method + +If you are new to Linux and want fresh installation and don’t want to customize partitions, then better choose option “ **Erase disk and install Zorin OS** ” + +If you want to create customize partitions for Zorin OS then choose “ **Something else** “, In this tutorial I will demonstrate how to create customize partition scheme for Zorin OS 15 installation, + +So, choose “ **Something else** ” option and then click on Continue + + + + + +As we can see we have around 42 GB disk available for Zorin OS, We will be creating following partitions, + + * /boot = 2 GB (ext4 file system) + * /home = 20 GB (ext4 file system) + * / = 10 GB (ext4 file system) + * /var = 7 GB (ext4 file system) + * Swap = 2 GB (ext4 file system) + + + +To start creating partitions, first click on “ **New Partition Table** ” and it will show it is going to create empty partition table, click on continue + + + +In the next screen we will see that we have now 42 GB free space on disk (/dev/sda), so let’s create our first partition as /boot, + +Select the free space, then click on + symbol and then specify the partition size as 2048 MB, file system type as ext4 and mount point as /boot, + + + +Click on OK + +Now create our next partition /home of size 20 GB (20480 MB), + + + +Similarly create our next two partition / and /var of size 10 and 7 GB respectively, + + + + + +Let’s create our last partition as swap of size 2 GB + + + +Click on OK + +Choose “ **Install Now** ” option in next window, + + + +In next window, choose “Continue” to write changes to disk and to proceed with installation + + + +### Step 6) Choose Your Preferred Location + +In the next screen, you will be asked to choose your location and click “Continue” + + + +### Step 7) Provide User Credentials + +In the next screen, you’ll be asked to enter the user credentials including your name, computer name, + +Username and password. Once you are done, click “Continue” to proceed with the installation process. + + + +### Step 8) Installing Zorin OS 15 + +Once you click continue, you can see that the Zorin OS 15 starts installing and it may take some time to complete the installation process. + + + +### Step 9) Restart your system after Successful Installation + +Once the installation process is completed, it will ask to restart your computer. Hit “ **Restart Now** ” + + + +### Step 10) Login to Zorin OS 15 + +Once the system restarts, you will be asked to login into the system using the login credentials provided earlier. + +Note: Don’t forget to change the boot medium from bios so that system boots up with disk. + + + +### Step 11) Zorin OS 15 Welcome Screen + +Once your login is successful, you can see the Zorin OS 15 welcome screen. Now you can start exploring all the incredible features of Zorin OS 15. + + + +That’s all from this tutorial, please do share feedback and comments. + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/zorin-os-15-installation-guide-screenshots/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://zorinos.com/download/ diff --git a/sources/tech/20190612 How to write a loop in Bash.md b/sources/tech/20190612 How to write a loop in Bash.md new file mode 100644 index 0000000000..f63bff9cd3 --- /dev/null +++ b/sources/tech/20190612 How to write a loop in Bash.md @@ -0,0 +1,282 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to write a loop in Bash) +[#]: via: (https://opensource.com/article/19/6/how-write-loop-bash) +[#]: author: (Seth Kenlon https://opensource.com/users/seth/users/goncasousa/users/howtopamm/users/howtopamm/users/seth/users/wavesailor/users/seth) + +How to write a loop in Bash +====== +Automatically perform a set of actions on multiple files with for loops +and find commands. +![bash logo on green background][1] + +A common reason people want to learn the Unix shell is to unlock the power of batch processing. If you want to perform some set of actions on many files, one of the ways to do that is by constructing a command that iterates over those files. In programming terminology, this is called _execution control,_ and one of the most common examples of it is the **for** loop. + +A **for** loop is a recipe detailing what actions you want your computer to take _for_ each data object (such as a file) you specify. + +### The classic for loop + +An easy loop to try is one that analyzes a collection of files. This probably isn't a useful loop on its own, but it's a safe way to prove to yourself that you have the ability to handle each file in a directory individually. First, create a simple test environment by creating a directory and placing some copies of some files into it. Any file will do initially, but later examples require graphic files (such as JPEG, PNG, or similar). You can create the folder and copy files into it using a file manager or in the terminal: + + +``` +$ mkdir example +$ cp ~/Pictures/vacation/*.{png,jpg} example +``` + +Change directory to your new folder, then list the files in it to confirm that your test environment is what you expect: + + +``` +$ cd example +$ ls -1 +cat.jpg +design_maori.png +otago.jpg +waterfall.png +``` + +The syntax to loop through each file individually in a loop is: create a variable ( **f** for file, for example). Then define the data set you want the variable to cycle through. In this case, cycle through all files in the current directory using the ***** wildcard character (the ***** wildcard matches _everything_ ). Then terminate this introductory clause with a semicolon ( **;** ). + + +``` +`$ for f in * ;` +``` + +Depending on your preference, you can choose to press **Return** here. The shell won't try to execute the loop until it is syntactically complete. + +Next, define what you want to happen with each iteration of the loop. For simplicity, use the **file** command to get a little bit of data about each file, represented by the **f** variable (but prepended with a **$** to tell the shell to swap out the value of the variable for whatever the variable currently contains): + + +``` +`do file $f ;` +``` + +Terminate the clause with another semi-colon and close the loop: + + +``` +`done` +``` + +Press **Return** to start the shell cycling through _everything_ in the current directory. The **for** loop assigns each file, one by one, to the variable **f** and runs your command: + + +``` +$ for f in * ; do +> file $f ; +> done +cat.jpg: JPEG image data, EXIF standard 2.2 +design_maori.png: PNG image data, 4608 x 2592, 8-bit/color RGB, non-interlaced +otago.jpg: JPEG image data, EXIF standard 2.2 +waterfall.png: PNG image data, 4608 x 2592, 8-bit/color RGB, non-interlaced +``` + +You can also write it this way: + + +``` +$ for f in *; do file $f; done +cat.jpg: JPEG image data, EXIF standard 2.2 +design_maori.png: PNG image data, 4608 x 2592, 8-bit/color RGB, non-interlaced +otago.jpg: JPEG image data, EXIF standard 2.2 +waterfall.png: PNG image data, 4608 x 2592, 8-bit/color RGB, non-interlaced +``` + +Both the multi-line and single-line formats are the same to your shell and produce the exact same results. + +### A practical example + +Here's a practical example of how a loop can be useful for everyday computing. Assume you have a collection of vacation photos you want to send to friends. Your photo files are huge, making them too large to email and inconvenient to upload to your [photo-sharing service][2]. You want to create smaller web-versions of your photos, but you have 100 photos and don't want to spend the time reducing each photo, one by one. + +First, install the **ImageMagick** command using your package manager on Linux, BSD, or Mac. For instance, on Fedora and RHEL: + + +``` +`$ sudo dnf install ImageMagick` +``` + +On Ubuntu or Debian: + + +``` +`$ sudo apt install ImageMagick` +``` + +On BSD, use **ports** or [pkgsrc][3]. On Mac, use [Homebrew][4] or [MacPorts][5]. + +Once you install ImageMagick, you have a set of new commands to operate on photos. + +Create a destination directory for the files you're about to create: + + +``` +`$ mkdir tmp` +``` + +To reduce each photo to 33% of its original size, try this loop: + + +``` +`$ for f in * ; do convert $f -scale 33% tmp/$f ; done` +``` + +Then look in the **tmp** folder to see your scaled photos. + +You can use any number of commands within a loop, so if you need to perform complex actions on a batch of files, you can place your whole workflow between the **do** and **done** statements of a **for** loop. For example, suppose you want to copy each processed photo straight to a shared photo directory on your web host and remove the photo file from your local system: + + +``` +$ for f in * ; do +convert $f -scale 33% tmp/$f +scp -i seth_web tmp/$f [seth@example.com][6]:~/public_html +trash tmp/$f ; +done +``` + +For each file processed by the **for** loop, your computer automatically runs three commands. This means if you process just 10 photos this way, you save yourself 30 commands and probably at least as many minutes. + +### Limiting your loop + +A loop doesn't always have to look at every file. You might want to process only the JPEG files in your example directory: + + +``` +$ for f in *.jpg ; do convert $f -scale 33% tmp/$f ; done +$ ls -m tmp +cat.jpg, otago.jpg +``` + +Or, instead of processing files, you may need to repeat an action a specific number of times. A **for** loop's variable is defined by whatever data you provide it, so you can create a loop that iterates over numbers instead of files: + + +``` +$ for n in {0..4}; do echo $n ; done +0 +1 +2 +3 +4 +``` + +### More looping + +You now know enough to create your own loops. Until you're comfortable with looping, use them on _copies_ of the files you want to process and, as often as possible, use commands with built-in safeguards to prevent you from clobbering your data and making irreparable mistakes, like accidentally renaming an entire directory of files to the same name, each overwriting the other. + +For advanced **for** loop topics, read on. + +### Not all shells are Bash + +The **for** keyword is built into the Bash shell. Many similar shells use the same keyword and syntax, but some shells, like [tcsh][7], use a different keyword, like **foreach** , instead. + +In tcsh, the syntax is similar in spirit but more strict than Bash. In the following code sample, do not type the string **foreach?** in lines 2 and 3. It is a secondary prompt alerting you that you are still in the process of building your loop. + + +``` +$ foreach f (*) +foreach? file $f +foreach? end +cat.jpg: JPEG image data, EXIF standard 2.2 +design_maori.png: PNG image data, 4608 x 2592, 8-bit/color RGB, non-interlaced +otago.jpg: JPEG image data, EXIF standard 2.2 +waterfall.png: PNG image data, 4608 x 2592, 8-bit/color RGB, non-interlaced +``` + +In tcsh, both **foreach** and **end** must appear alone on separate lines, so you cannot create a **for** loop on one line as you can with Bash and similar shells. + +### For loops with the find command + +In theory, you could find a shell that doesn't provide a **for** loop function, or you may just prefer to use a different command with added features. + +The **find** command is another way to implement the functionality of a **for** loop, as it offers several ways to define the scope of which files to include in your loop as well as options for [Parallel][8] processing. + +The **find** command is meant to help you find files on your hard drives. Its syntax is simple: you provide the path of the location you want to search, and **find** finds all files and directories: + + +``` +$ find . +. +./cat.jpg +./design_maori.png +./otago.jpg +./waterfall.png +``` + +You can filter the search results by adding some portion of the name: + + +``` +$ find . -name "*jpg" +./cat.jpg +./otago.jpg +``` + +The great thing about **find** is that each file it finds can be fed into a loop using the **-exec** flag. For instance, to scale down only the PNG photos in your example directory: + + +``` +$ find . -name "*png" -exec convert {} -scale 33% tmp/{} \; +$ ls -m tmp +design_maori.png, waterfall.png +``` + +In the **-exec** clause, the bracket characters **{}** stand in for whatever item **find** is processing (in other words, any file ending in PNG that has been located, one at a time). The **-exec** clause must be terminated with a semicolon, but Bash usually tries to use the semicolon for itself. You "escape" the semicolon with a backslash ( **\;** ) so that **find** knows to treat that semicolon as its terminating character. + +The **find** command is very good at what it does, and it can be too good sometimes. For instance, if you reuse it to find PNG files for another photo process, you will get a few errors: + + +``` +$ find . -name "*png" -exec convert {} -flip -flop tmp/{} \; +convert: unable to open image `tmp/./tmp/design_maori.png': +No such file or directory @ error/blob.c/OpenBlob/2643. +... +``` + +It seems that **find** has located all the PNG files—not only the ones in your current directory ( **.** ) but also those that you processed before and placed in your **tmp** subdirectory. In some cases, you may want **find** to search the current directory plus all other directories within it (and all directories in _those_ ). It can be a powerful recursive processing tool, especially in complex file structures (like directories of music artists containing directories of albums filled with music files), but you can limit this with the **-maxdepth** option. + +To find only PNG files in the current directory (excluding subdirectories): + + +``` +`$ find . -maxdepth 1 -name "*png"` +``` + +To find and process files in the current directory plus an additional level of subdirectories, increment the maximum depth by 1: + + +``` +`$ find . -maxdepth 2 -name "*png"` +``` + +Its default is to descend into all subdirectories. + +### Looping for fun and profit + +The more you use loops, the more time and effort you save, and the bigger the tasks you can tackle. You're just one user, but with a well-thought-out loop, you can make your computer do the hard work. + +You can and should treat looping like any other command, keeping it close at hand for when you need to repeat a single action or two on several files. However, it's also a legitimate gateway to serious programming, so if you have to accomplish a complex task on any number of files, take a moment out of your day to plan out your workflow. If you can achieve your goal on one file, then wrapping that repeatable process in a **for** loop is relatively simple, and the only "programming" required is an understanding of how variables work and enough organization to separate unprocessed from processed files. With a little practice, you can move from a Linux user to a Linux user who knows how to write a loop, so get out there and make your computer work for you! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/how-write-loop-bash + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth/users/goncasousa/users/howtopamm/users/howtopamm/users/seth/users/wavesailor/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bash_command_line.png?itok=k4z94W2U (bash logo on green background) +[2]: http://nextcloud.com +[3]: http://pkgsrc.org +[4]: http://brew.sh +[5]: https://www.macports.org +[6]: mailto:seth@example.com +[7]: https://en.wikipedia.org/wiki/Tcsh +[8]: https://opensource.com/article/18/5/gnu-parallel diff --git a/sources/tech/20190612 The bits and bytes of PKI.md b/sources/tech/20190612 The bits and bytes of PKI.md new file mode 100644 index 0000000000..3cf9bd9c41 --- /dev/null +++ b/sources/tech/20190612 The bits and bytes of PKI.md @@ -0,0 +1,284 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The bits and bytes of PKI) +[#]: via: (https://opensource.com/article/19/6/bits-and-bytes-pki) +[#]: author: (Alex Wood https://opensource.com/users/awood) + +The bits and bytes of PKI +====== +Take a look under the public key infrastructure's hood to get a better +understanding of its format. +![Computer keyboard typing][1] + +In two previous articles— _[An introduction to cryptography and public key infrastructure][2]_ and _[How do private keys work in PKI and cryptography?][3]_ —I discussed cryptography and public key infrastructure (PKI) in a general way. I talked about how digital bundles called _certificates_ store public keys and identifying information. These bundles contain a lot of complexity, and it's useful to have a basic understanding of the format for when you need to look under the hood. + +### Abstract art + +Keys, certificate signing requests, certificates, and other PKI artifacts define themselves in a data description language called [Abstract Syntax Notation One][4] (ASN.1). ASN.1 defines a series of simple data types (integers, strings, dates, etc.) along with some structured types (sequences, sets). By using those types as building blocks, we can create surprisingly complex data formats. + +ASN.1 contains plenty of pitfalls for the unwary, however. For example, it has two different ways of representing dates: GeneralizedTime ([ISO 8601][5] format) and UTCTime (which uses a two-digit year). Strings introduce even more confusion. We have IA5String for ASCII strings and UTF8String for Unicode strings. ASN.1 also defines several other string types, from the exotic [T61String][6] and [TeletexString][7] to the more innocuous sounding—but probably not what you wanted—PrintableString (only a small subset of ASCII) and UniversalString (encoded in [UTF-32][8]). If you're writing or reading ASN.1 data, I recommend referencing the [specification][9]. + +ASN.1 has another data type worth special mention: the object identifier (OID). OIDs are a series of integers. Commonly they are shown with periods delimiting them. Each integer represents a node in what is basically a "tree of things." For example, [1.3.6.1.4.1.2312][10] is the OID for my employer, Red Hat, where "1" is the node for the International Organization for Standardization (ISO), "3" is for ISO-identified organizations, "6" is for the US Department of Defense (which, for historical reasons, is the parent to the next node), "1" is for the internet, "4" is for private organizations, "1" is for enterprises, and finally "2312," which is Red Hat's own. + +More commonly, OIDs are regularly used to identify specific algorithms in PKI objects. If you have a digital signature, it's not much use if you don't know what type of signature it is. The signature algorithm "sha256WithRSAEncryption" has the OID "1.2.840.113549.1.1.11," for example. + +### ASN.1 at work + +Suppose we own a factory that produces flying brooms, and we need to store some data about every broom. Our brooms have a model name, a serial number, and a series of inspections that have been made to ensure flight-worthiness. We could store this information using ASN.1 like so: + + +``` +BroomInfo ::= SEQUENCE { +model UTF8String, +serialNumber INTEGER, +inspections SEQUENCE OF InspectionInfo +} + +InspectionInfo ::= SEQUENCE { +inspectorName UTF8String, +inspectionDate GeneralizedTime +} +``` + +The example above defines the model name as a UTF8-encoded string, the serial number as an integer, and our inspections as a series of InspectionInfo items. Then we see that each InspectionInfo item comprises two pieces of data: the inspector's name and the time of the inspection. + +An actual instance of BroomInfo data would look something like this in ASN.1's value assignment syntax: + + +``` +broom BroomInfo ::= { +model "Nimbus 2000", +serialNumber 1066, +inspections { +{ +inspectorName "Harry", +inspectionDate "201901011200Z" +} +{ +inspectorName "Hagrid", +inspectionDate "201902011200Z" +} +} +} +``` + +Don't worry too much about the particulars of the syntax; for the average developer, having a basic grasp of how the pieces fit together is sufficient. + +Now let's look at a real example from [RFC 8017][11] that I have abbreviated somewhat for clarity: + + +``` +RSAPrivateKey ::= SEQUENCE { +version Version, +modulus INTEGER, -- n +publicExponent INTEGER, -- e +privateExponent INTEGER, -- d +prime1 INTEGER, -- p +prime2 INTEGER, -- q +exponent1 INTEGER, -- d mod (p-1) +exponent2 INTEGER, -- d mod (q-1) +coefficient INTEGER, -- (inverse of q) mod p +otherPrimeInfos OtherPrimeInfos OPTIONAL +} + +Version ::= INTEGER { two-prime(0), multi(1) } +(CONSTRAINED BY +{-- version must be multi if otherPrimeInfos present --}) + +OtherPrimeInfos ::= SEQUENCE SIZE(1..MAX) OF OtherPrimeInfo + +OtherPrimeInfo ::= SEQUENCE { +prime INTEGER, -- ri +exponent INTEGER, -- di +coefficient INTEGER -- ti +} +``` + +The ASN.1 above defines the PKCS #1 format used to store RSA keys. Looking at this, we can see the RSAPrivateKey sequence starts with a version type (either 0 or 1) followed by a bunch of integers and then an optional type called OtherPrimeInfos. The OtherPrimeInfos sequence contains one or more pieces of OtherPrimeInfo. And each OtherPrimeInfo is just a sequence of integers. + +Let's look at an actual instance by asking OpenSSL to generate an RSA key and then pipe it into [asn1parse][12], which will print it out in a more human-friendly format. (By the way, the **genrsa** command I'm using here has been superseded by **genpkey** ; we'll see why a little later.) + + +``` +% openssl genrsa 4096 2> /dev/null | openssl asn1parse +0:d=0 hl=4 l=2344 cons: SEQUENCE +4:d=1 hl=2 l= 1 prim: INTEGER :00 +7:d=1 hl=4 l= 513 prim: INTEGER :B80B0C2443... +524:d=1 hl=2 l= 3 prim: INTEGER :010001 +529:d=1 hl=4 l= 512 prim: INTEGER :59C609C626... +1045:d=1 hl=4 l= 257 prim: INTEGER :E8FC43002D... +1306:d=1 hl=4 l= 257 prim: INTEGER :CA39222DD2... +1567:d=1 hl=4 l= 256 prim: INTEGER :25F6CD181F... +1827:d=1 hl=4 l= 256 prim: INTEGER :38CCE374CB... +2087:d=1 hl=4 l= 257 prim: INTEGER :C80430E810... +``` + +Recall that RSA uses a modulus, _n_ ; a public exponent, _e_ ; and a private exponent, _d_. Now let's look at the sequence. First, we see the version set to 0 for a two-prime RSA key (what **genrsa** generates), an integer for the modulus, _n_ , and then 0x010001 for the public exponent, _e_. If we convert to decimal, we'll see our public exponent is 65537, a number [commonly][13] used as an RSA public exponent. Following the public exponent, we see the integer for the private exponent, _e_ , and then some other integers that are used to speed up decryption and signing. Explaining how this optimization works is beyond the scope of this article, but if you like math, there's a [good video on the subject][14]. + +What about that other stuff on the left side of the output? What does "h=4" and "l=513" mean? We'll cover that shortly. + +### DERangement + +We've seen the "abstract" part of Abstract Syntax Notation One, but how does this data get encoded and stored? For that, we turn to a binary format called Distinguished Encoding Rules (DER) defined in the [X.690][15] specification. DER is a stricter version of its parent, Basic Encoding Rules (BER), in that for any given data, there is only one way to encode it. If we're going to be digitally signing data, it makes things a lot easier if there is only one possible encoding that needs to be signed instead of dozens of functionally equivalent representations. + +DER uses a [tag-length-value][16] (TLV) structure. The encoding of a piece of data begins with an identifier octet defining the data's type. ("Octet" is used rather than "byte" since the standard is very old and some early architectures didn't use 8 bits for a byte.) Next are the octets that encode the length of the data, and finally, there is the data. The data can be another TLV series. The left side of the **asn1parse** output makes a little more sense now. The first number indicates the absolute offset from the beginning. The "d=" tells us the depth of that item in the structure. The first line is a sequence, which we descend into on the next line (the depth _d_ goes from 0 to 1) whereupon **asn1parse** begins enumerating all the elements in that sequence. The "hl=" is the header length (the sum of the identifier and length octets), and the "l=" tells us the length of that particular piece of data. + +How is header length determined? It's the sum of the identifier byte and the bytes encoding the length. In our example, the top sequence is 2344 octets long. If it were less than 128 octets, the length would be encoded in a single octet in the "short form": bit 8 would be a zero and bits 7 to 1 would hold the length value ( **2 7-1=127**). A value of 2344 needs more space, so the "long" form is used. The first octet has bit 8 set to one, and bits 7 to 1 contain the length of the length. In our case, a value of 2344 can be encoded in two octets (0x0928). Combined with the first "length of the length" octet, we have three octets total. Add the one identifier octet, and that gives us our total header length of four. + +As a side exercise, let's consider the largest value we could possibly encode. We've seen that we have up to 127 octets to encode a length. At 8 bits per octet, we have a total of 1008 bits to use, so we can hold a number equal to **2 1008-1**. That would equate to a content length of **2.743062*10 279** yottabytes, staggeringly more than the estimated **10 80** atoms in the observable universe. If you're interested in all the details, I recommend reading "[A Layman's Guide to a Subset of ASN.1, BER, and DER][17]." + +What about "cons" and "prim"? Those indicate whether the value is encoded with "constructed" or "primitive" encoding. Primitive encoding is used for simple types like "INTEGER" or "BOOLEAN," while constructed encoding is used for structured types like "SEQUENCE" or "SET." The actual difference between the two encoding methods is whether bit 6 in the identifier octet is a zero or one. If it's a one, the parser knows that the content octets are also DER-encoded and it can descend. + +### PEM pals + +While useful in a lot of cases, a binary format won't pass muster if we need to display the data as text. Before the [MIME][18] standard existed, attachment support was spotty. Commonly, if you wanted to attach data, you put it in the body of the email, and since SMTP only supported ASCII, that meant converting your binary data (like the DER of your public key, for example) into ASCII characters. + +Thus, the PEM format emerged. PEM stands for "Privacy-Enhanced Email" and was an early standard for transmitting and storing PKI data. The standard never caught on, but the format it defined for storage did. PEM-encoded objects are just DER objects that are [base64][19]-encoded and wrapped at 64 characters per line. To describe the type of object, a header and footer surround the base64 string. You'll see **\-----BEGIN CERTIFICATE-----** or **\-----BEGIN PRIVATE KEY-----** , for example. + +Often you'll see files with the ".pem" extension. I don't find this suffix useful. The file could contain a certificate, a key, a certificate signing request, or several other possibilities. Imagine going to a sushi restaurant and seeing a menu that described every item as "fish and rice"! Instead, I prefer more informative extensions like ".crt", ".key", and ".csr". + +### The PKCS zoo + +Earlier, I showed an example of a PKCS #1-formatted RSA key. As you might expect, formats for storing certificates and signing requests also exist in various IETF RFCs. For example, PKCS #8 can be used to store private keys for many different algorithms (including RSA!). Here's some of the ASN.1 from [RFC 5208][20] for PKCS #8. (RFC 5208 has been obsoleted by RFC 5958, but I feel that the ASN.1 in RFC 5208 is easier to understand.) + + +``` +PrivateKeyInfo ::= SEQUENCE { +version Version, +privateKeyAlgorithm PrivateKeyAlgorithmIdentifier, +privateKey PrivateKey, +attributes [0] IMPLICIT Attributes OPTIONAL } + +Version ::= INTEGER + +PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier + +PrivateKey ::= OCTET STRING + +Attributes ::= SET OF Attribute +``` + +If you store your RSA private key in a PKCS #8, the PrivateKey element will actually be a DER-encoded PKCS #1! Let's prove it. Remember earlier when I used **genrsa** to generate a PKCS #1? OpenSSL can generate a PKCS #8 with the **genpkey** command, and you can specify RSA as the algorithm to use. + + +``` +% openssl genpkey -algorithm RSA | openssl asn1parse +0:d=0 hl=4 l= 629 cons: SEQUENCE +4:d=1 hl=2 l= 1 prim: INTEGER :00 +7:d=1 hl=2 l= 13 cons: SEQUENCE +9:d=2 hl=2 l= 9 prim: OBJECT :rsaEncryption +20:d=2 hl=2 l= 0 prim: NULL +22:d=1 hl=4 l= 607 prim: OCTET STRING [HEX DUMP]:3082025B... +``` + +You may have spotted the "OBJECT" in the output and guessed that was related to OIDs. You'd be correct. The OID "1.2.840.113549.1.1.1" is assigned to RSA encryption. OpenSSL has a built-in list of common OIDs and translates them into a human-readable form for you. + + +``` +% openssl genpkey -algorithm RSA | openssl asn1parse -strparse 22 +0:d=0 hl=4 l= 604 cons: SEQUENCE +4:d=1 hl=2 l= 1 prim: INTEGER :00 +7:d=1 hl=3 l= 129 prim: INTEGER :CA6720E706... +139:d=1 hl=2 l= 3 prim: INTEGER :010001 +144:d=1 hl=3 l= 128 prim: INTEGER :05D0BEBE44... +275:d=1 hl=2 l= 65 prim: INTEGER :F215DC6B77... +342:d=1 hl=2 l= 65 prim: INTEGER :D6095CED7E... +409:d=1 hl=2 l= 64 prim: INTEGER :402C7562F3... +475:d=1 hl=2 l= 64 prim: INTEGER :06D0097B2D... +541:d=1 hl=2 l= 65 prim: INTEGER :AB266E8E51... +``` + +In the second command, I've told **asn1parse** via the **-strparse** argument to move to octet 22 and begin parsing the content's octets there as an ASN.1 object. We can clearly see that the PKCS #8's PrivateKey looks just like the PKCS #1 that we examined earlier. + +You should favor using the **genpkey** command. PKCS #8 has some features that PKCS #1 does not: PKCS #8 can store private keys for multiple different algorithms (PKCS #1 is RSA-specific), and it provides a mechanism to encrypt the private key using a passphrase and a symmetric cipher. + +Encrypted PKCS #8 objects use a different ASN.1 syntax that I'm not going to dive into, but let's take a look at an actual example and see if anything stands out. Encrypting a private key with **genpkey** requires that you specify the symmetric encryption algorithm to use. I'll use AES-256-CBC for this example and a password of "hello" (the "pass:" prefix is the way of telling OpenSSL that the password is coming in from the command line). + + +``` +% openssl genpkey -algorithm RSA -aes-256-cbc -pass pass:hello | openssl asn1parse +0:d=0 hl=4 l= 733 cons: SEQUENCE +4:d=1 hl=2 l= 87 cons: SEQUENCE +6:d=2 hl=2 l= 9 prim: OBJECT :PBES2 +17:d=2 hl=2 l= 74 cons: SEQUENCE +19:d=3 hl=2 l= 41 cons: SEQUENCE +21:d=4 hl=2 l= 9 prim: OBJECT :PBKDF2 +32:d=4 hl=2 l= 28 cons: SEQUENCE +34:d=5 hl=2 l= 8 prim: OCTET STRING [HEX DUMP]:17E6FE554E85810A +44:d=5 hl=2 l= 2 prim: INTEGER :0800 +48:d=5 hl=2 l= 12 cons: SEQUENCE +50:d=6 hl=2 l= 8 prim: OBJECT :hmacWithSHA256 +60:d=6 hl=2 l= 0 prim: NULL +62:d=3 hl=2 l= 29 cons: SEQUENCE +64:d=4 hl=2 l= 9 prim: OBJECT :aes-256-cbc +75:d=4 hl=2 l= 16 prim: OCTET STRING [HEX DUMP]:91E9536C39... +93:d=1 hl=4 l= 640 prim: OCTET STRING [HEX DUMP]:98007B264F... + +% openssl genpkey -algorithm RSA -aes-256-cbc -pass pass:hello | head -n 1 +\-----BEGIN ENCRYPTED PRIVATE KEY----- +``` + +There are a couple of interesting items here. We see our encryption algorithm is recorded with an OID starting at octet 64. There's an OID for "PBES2" (Password-Based Encryption Scheme 2), which defines a standard process for encryption and decryption, and an OID for "PBKDF2" (Password-Based Key Derivation Function 2), which defines a standard process for creating encryption keys from passwords. Helpfully, OpenSSL uses the header "ENCRYPTED PRIVATE KEY" in the PEM output. + +OpenSSL will let you encrypt a PKCS #1, but it's done in a non-standard way via a series of headers inserted into the PEM: + + +``` +% openssl genrsa -aes256 -passout pass:hello 4096 +\-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-256-CBC,5B2C64DC05B7C0471A278C76562FD776 +... +``` + +### In conclusion + +There's a final PKCS format you need to know about: [PKCS #12][21]. The PKCS #12 format allows for storing multiple objects all in one file. If you have a certificate and its corresponding key or a chain of certificates, you can store them together in one PKCS #12 file. Individual entries in the file can be protected with password-based encryption. + +Beyond the PKCS formats, there are other storage methods such as the Java-specific JKS format and the NSS library from Mozilla, which uses file-based databases (SQLite or Berkeley DB, depending on the version). Luckily, the PKCS formats are a lingua franca that can serve as a start or reference if you need to deal with other formats. + +If this all seems confusing, that's because it is. Unfortunately, the PKI ecosystem has a lot of sharp edges between tools that generate enigmatic error messages (looking at you, OpenSSL) and standards that have grown and evolved over the past 35 years. Having a basic understanding of how PKI objects are stored is critical if you're doing any application development that will be accessed over SSL/TLS. + +I hope this article has shed a little light on the subject and might save you from spending fruitless hours in the PKI wilderness. + +* * * + +_The author would like to thank Hubert Kario for providing a technical review._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/bits-and-bytes-pki + +作者:[Alex Wood][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/awood +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/keyboaord_enter_writing_documentation.jpg?itok=kKrnXc5h (Computer keyboard typing) +[2]: https://opensource.com/article/18/5/cryptography-pki +[3]: https://opensource.com/article/18/7/private-keys +[4]: https://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One +[5]: https://en.wikipedia.org/wiki/ISO_8601 +[6]: https://en.wikipedia.org/wiki/ITU_T.61 +[7]: https://en.wikipedia.org/wiki/Teletex +[8]: https://en.wikipedia.org/wiki/UTF-32 +[9]: https://www.itu.int/itu-t/recommendations/rec.aspx?rec=X.680 +[10]: https://www.alvestrand.no/objectid/1.3.6.1.4.1.2312.html +[11]: https://tools.ietf.org/html/rfc8017 +[12]: https://linux.die.net/man/1/asn1parse +[13]: https://www.johndcook.com/blog/2018/12/12/rsa-exponent/ +[14]: https://www.youtube.com/watch?v=NcPdiPrY_g8 +[15]: https://en.wikipedia.org/wiki/X.690 +[16]: https://en.wikipedia.org/wiki/Type-length-value +[17]: http://luca.ntop.org/Teaching/Appunti/asn1.html +[18]: https://www.theguardian.com/technology/2012/mar/26/ather-of-the-email-attachment +[19]: https://en.wikipedia.org/wiki/Base64 +[20]: https://tools.ietf.org/html/rfc5208 +[21]: https://tools.ietf.org/html/rfc7292 diff --git a/sources/tech/20190612 Why --1-, -7-, -11--.map(parseInt) returns -1, NaN, 3- in Javascript.md b/sources/tech/20190612 Why --1-, -7-, -11--.map(parseInt) returns -1, NaN, 3- in Javascript.md new file mode 100644 index 0000000000..4e892a4610 --- /dev/null +++ b/sources/tech/20190612 Why --1-, -7-, -11--.map(parseInt) returns -1, NaN, 3- in Javascript.md @@ -0,0 +1,205 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why ['1', '7', '11'].map(parseInt) returns [1, NaN, 3] in Javascript) +[#]: via: (https://medium.com/dailyjs/parseint-mystery-7c4368ef7b21) +[#]: author: (Eric Tong https://medium.com/@erictongs) + +Why ['1', '7', '11'].map(parseInt) returns [1, NaN, 3] in Javascript +====== +![][1]![][2]??? + +**Javascript is weird.** Don’t believe me? Try converting an array of strings into integers using map and parseInt. Fire up your console (F12 on Chrome), paste in the following, and press enter (or run the pen below). + +``` +['1', '7', '11'].map(parseInt); +``` + +Instead of giving us an array of integers `[1, 7, 11]`, we end up with `[1, NaN, 3]`. What? To find out what on earth is going on, we’ll first have to talk about some Javascript concepts. If you’d like a TLDR, I’ve included a quick summary at the end of this story. + +### Truthiness & Falsiness + +Here’s a simple if-else statement in Javascript: + +``` +if (true) { + // this always runs +} else { + // this never runs +} +``` + +In this case, the condition of the if-else statement is true, so the if-block is always executed and the else-block is ignored. This is a trivial example because true is a boolean. What if we put a non-boolean as the condition? + +``` +if ("hello world") { + // will this run? + console.log("Condition is truthy"); +} else { + // or this? + console.log("Condition is falsy"); +} +``` + +Try running this code in your developer’s console (F12 on Chrome). You should find that the if-block runs. This is because the string object `"hello world"` is truthy. + +Every Javascript object is either **truthy** or **falsy**. When placed in a boolean context, such as an if-else statement, objects are treated as true or false based on their truthiness. So which objects are truthy and which are falsy? Here’s a simple rule to follow: + +**All values are truthy except for:** `false` **,** `0` **,** `""` **(empty string),** `null` **,** `undefined` **, and** `NaN` **.** + +Confusingly, this means that the string `"false"`, the string `"0"`, an empty object `{}`, and an empty array `[]` are all truthy. You can double check this by passing an object into the Boolean function (e.g. `Boolean("0");`). + +For our purposes, it is enough to remember that `0` is falsy. + +### Radix + +``` +0 1 2 3 4 5 6 7 8 9 10 +``` + +When we count from zero to nine, we have different symbols for each of the numbers (0–9). However, once we reach ten, we need two different symbols (1 and 0) to represent the number. This is because our decimal counting system has a radix (or base) of ten. + +Radix is the smallest number which can only be represented by more than one symbol. **Different counting systems have different radixes, and so, the same digits can refer to different numbers in counting systems.** + +``` +DECIMAL BINARY HEXADECIMAL +RADIX=10 RADIX=2 RADIX=16 +0 0 0 +1 1 1 +2 10 + 2 +3 +11 3 +4 100 4 +5 101 5 +6 110 6 +7 111 7 +8 1000 8 +9 1001 9 +10 1010 A +11 1011 B +12 1100 C +13 1101 D +14 1110 E +15 1111 F +16 10000 10 +17 10001 +11 +``` + +For example, looking at the table above, we see that the same digits 11 can mean different numbers in different counting systems. If the radix is 2, then it refers to the number 3. If the radix is 16, then it refers to the number 17. + +You may have noticed that in our example, parseInt returned 3 when the input is 11, which corresponds to the Binary column in the table above. + +### Function arguments + +Functions in Javascript can be called with any number of arguments, even if they do not equal the number of declared function parameters. Missing arguments are treated as undefined and extra arguments are ignored (but stored in the array-like [arguments object][3]). + +``` +function foo(x, y) { + console.log(x); + console.log(y); +} +foo(1, 2); // logs 1, 2 +foo(1); // logs 1, undefined +foo(1, 2, 3); // logs 1, 2 +``` + +### map() + +We’re almost there! + +Map is a method in the Array prototype that returns a new array of the results of passing each element of the original array into a function. For example, the following code multiplies each element in the array by 3: + +``` +function multiplyBy3(x) { + return x * 3; +} +const result = [1, 2, 3, 4, 5].map(multiplyBy3);console.log(result); // logs [3, 6, 9, 12, 15]; +``` + +Now, let’s say I want to log each element using `map()` (with no return statements). I should be able to pass `console.log` as an argument into `map()`… right? + +``` +[1, 2, 3, 4, 5].map(console.log); +``` + +![][4]![][5] + +Something very strange is going on. Instead of logging just the value, each `console.log` call also logged the index and full array. + +``` +[1, 2, 3, 4, 5].map(console.log);// The above is equivalent to[1, 2, 3, 4, 5].map( + (val, index, array) => console.log(val, index, array) +); +// and not equivalent to[1, 2, 3, 4, 5].map( + val => console.log(val) +); +``` + +When a function is passed into `map()`, for each iteration, **three arguments are passed into the function** : `currentValue`, `currentIndex`, and the full `array`. That is why three entries are logged for each iteration. + +We now have all the pieces we need to solve this mystery. + +### Bringing it together + +ParseInt takes two arguments: `string` and `radix`. If the radix provided is falsy, then by default, radix is set to 10. + +``` +parseInt('11'); => 11 +parseInt('11', 2); => 3 +parseInt('11', 16); => 17 +parseInt('11', undefined); => 11 (radix is falsy) +parseInt('11', 0); => 11 (radix is falsy) +``` + +Now let’s run our example step-by-step. + +``` +['1', '7', '11'].map(parseInt); => [1, NaN, 3]// First iteration: val = '1', index = 0, array = ['1', '7', '11']parseInt('1', 0, ['1', '7', '11']); => 1 +``` + +Since 0 is falsy, the radix is set to the default value 10. `parseInt()` only takes two arguments, so the third argument `['1', '7', '11']` is ignored. The string `'1'` in radix 10 refers to the number 1. + +``` +// Second iteration: val = '7', index = 1, array = ['1', '7', '11']parseInt('7', 1, ['1', '7', '11']); => NaN +``` + +In a radix 1 system, the symbol `'7'` does not exist. As with the first iteration, the last argument is ignored. So, `parseInt()` returns `NaN`. + +``` +// Third iteration: val = '11', index = 2, array = ['1', '7', '11']parseInt('11', 2, ['1', '7', '11']); => 3 +``` + +In a radix 2 (binary) system, the symbol `'11'` refers to the number 3. The last argument is ignored. + +### Summary (TLDR) + +`['1', '7', '11'].map(parseInt)` doesn’t work as intended because `map` passes three arguments into `parseInt()` on each iteration. The second argument `index` is passed into parseInt as a `radix` parameter. So, each string in the array is parsed using a different radix. `'7'` is parsed as radix 1, which is `NaN`, `'11'` is parsed as radix 2, which is 3. `'1'` is parsed as the default radix 10, because its index 0 is falsy. + +And so, the following code will work as intended: + +``` +['1', '7', '11'].map(numStr => parseInt(numStr)); +``` + +-------------------------------------------------------------------------------- + +via: https://medium.com/dailyjs/parseint-mystery-7c4368ef7b21 + +作者:[Eric Tong][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://medium.com/@erictongs +[b]: https://github.com/lujun9972 +[1]: https://miro.medium.com/max/60/1*uq5ZTlw6HLRRqbHaPYYL0g.png?q=20 +[2]: https://miro.medium.com/max/1400/1*uq5ZTlw6HLRRqbHaPYYL0g.png +[3]: https://javascriptweblog.wordpress.com/2011/01/18/javascripts-arguments-object-and-beyond/ +[4]: https://miro.medium.com/max/60/1*rbrCQ_aNOft_OjayDtL6xg.png?q=20 +[5]: https://miro.medium.com/max/1400/1*rbrCQ_aNOft_OjayDtL6xg.png diff --git a/sources/tech/20190612 Why use GraphQL.md b/sources/tech/20190612 Why use GraphQL.md new file mode 100644 index 0000000000..ad0d3a0056 --- /dev/null +++ b/sources/tech/20190612 Why use GraphQL.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why use GraphQL?) +[#]: via: (https://opensource.com/article/19/6/why-use-graphql) +[#]: author: (Zach Lendon https://opensource.com/users/zachlendon/users/goncasousa/users/patrickhousley) + +Why use GraphQL? +====== +Here's why GraphQL is gaining ground on standard REST API technology. +![][1] + +[GraphQL][2], as I wrote [previously][3], is a next-generation API technology that is transforming both how client applications communicate with backend systems and how backend systems are designed. + +As a result of the support that began with the organization that founded it, Facebook, and continues with the backing of other technology giants such as Github, Twitter, and AirBnB, GraphQL's place as a linchpin technology for application systems seems secure; both now and long into the future. + +### GraphQL's ascent + +The rise in importance of mobile application performance and organizational agility has provided booster rockets for GraphQL's ascent to the top of modern enterprise architectures. + +Given that [REST][4] is a wildly popular architectural style that already allows mechanisms for data interaction, what advantages does this new technology provide over [REST][4]? The ‘QL’ in GraphQL stands for query language, and that is a great place to start. + +The ease at which different client applications within an organization can query only the data they need with GraphQL usurps alternative REST approaches and delivers real-world application performance boosts. With traditional [REST][4] API endpoints, client applications interrogate a server resource, and receive a response containing all the data that matches the request. If a successful response from a [REST][4] API endpoint returns 35 fields, the client application receives 35 fields + +### Fetching problems + +[REST][4] APIs traditionally provide no clean way for client applications to retrieve or update only the data they care about. This is often described as the “over-fetching” problem. With the prevalence of mobile applications in people’s day to day lives, the over-fetching problem has real world consequences. Every request a mobile application needs to make, every byte it has to send and receive, has an increasingly negative performance impact for end users. Users with slower data connections are particularly affected by suboptimal API design choices. Customers who experience poor performance using mobile applications are more likely to not purchase products and use services. Inefficient API designs cost companies money. + +“Over-fetching” isn’t alone - it has a partner in crime - “under-fetching”. Endpoints that, by default, return only a portion of the data a client actually needs require clients to make additional calls to satisfy their data needs - which requires additional HTTP requests. Because of the over and under fetching problems and their impact on client application performance, an API technology that facilitates efficient fetching has a chance to catch fire in the marketplace - and GraphQL has boldly jumped in and filled that void. + +### REST's response + +[REST][4] API designers, not willing to go down without a fight, have attempted to counter the mobile application performance problem through a mix of: + + * “include” and “exclude” query parameters, allowing client applications to specify which fields they want through a potentially long query format. + * “Composite” services, which combine multiple endpoints in a way that allow client applications to be more efficient in the number of requests they make and the data they receive. + + + +While these patterns are a valiant attempt by the [REST][4] API community to address challenges mobile clients face, they fall short in a few key regards, namely: + + * Include and exclude query key/value pairs quickly get messy, in particular for deeper object graphs that require a nested dot notation syntax (or similar) to target data to include and exclude. Additionally, debugging issues with the query string in this model often requires manually breaking up a URL. + * Server implementations for include and exclude queries are often custom, as there is no standard way for server-based applications to handle the use of include and exclude queries, just as there is no standard way for include and exclude queries to be defined. + * The rise of composite services creates more tightly coupled back-end and front-end systems, requiring increasing coordination to deliver projects and turning once agile projects back to waterfall. This coordination and coupling has the painful side effect of slowing organizational agility. Additionally, composite services are by definition, not RESTful. + + + +### GraphQL's genesis + +For Facebook, GraphQL’s genesis was a response to pain felt and experiences learned from an HTML5-based version of their flagship mobile application back in 2011-2012. Understanding that improved performance was paramount, Facebook engineers realized that they needed a new API design to ensure peak performance. Likely taking the above [REST][4] limitations into consideration, and with needing to support different needs of a number of API clients, one can begin to understand the early seeds of what led co-creators Lee Byron and Dan Schaeffer, Facebook employees at the time, to create what has become known as GraphQL. + +With what is often a single GraphQL endpoint, through the GraphQL query language, client applications are able to reduce, often significantly, the number of network calls they need to make, and ensure that they only are retrieving the data they need. In many ways, this harkens back to earlier models of web programming, where client application code would directly query back-end systems - some might remember writing SQL queries with JSTL on JSPs 10-15 years ago for example! + +The biggest difference now is with GraphQL, we have a specification that is implemented across a variety of client and server languages and libraries. And with GraphQL being an API technology, we have decoupled the back-end and front-end application systems by introducing an intermediary GraphQL application layer that provides a mechanism to access organizational data in a manner that aligns with an organization’s business domain(s). + +Beyond solving technical challenges experienced by software engineering teams, GraphQL has also been a boost to organizational agility, in particular in the enterprise. GraphQL-enabled organizational agility increases are commonly attributable to the following: + + * Rather than creating new endpoints when 1 or more new fields are needed by clients, GraphQL API designers and developers are able to include those fields in existing graph implementations, exposing new capabilities in a fashion that requires less development effort and less change across application systems. + * By encouraging API design teams to focus more on defining their object graph and be less focused on what client applications are delivering, the speed at which front-end and back-end software teams deliver solutions for customers has increasingly decoupled. + + + +### Considerations before adoption + +Despite GraphQL’s compelling benefits, GraphQL is not without its implementation challenges. A few examples include: + + * Caching mechanisms around [REST][4] APIs are much more mature. + * The patterns used to build APIs using [REST][4] are much more well established. + * While engineers may be more attracted to newer technologies like GraphQL, the talent pool in the marketplace is much broader for building [REST][4]-based solutions vs. GraphQL. + + + +### Conclusion + +By providing both a boost to performance and organizational agility, GraphQL's adoption by companies has skyrocketed in the past few years. It does, however, have some maturing to do in comparison to the RESTful ecosystem of API design. + +One of the great benefits of GraphQL is that it’s not designed as a wholesale replacement for alternative API solutions. Instead, GraphQL can be implemented to complement or enhance existing APIs. As a result, companies are encouraged to explore incrementally adopting GraphQL where it makes the most sense for them - where they find it has the greatest positive impact on application performance and organizational agility. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/why-use-graphql + +作者:[Zach Lendon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/zachlendon/users/goncasousa/users/patrickhousley +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_graph_stats_blue.png?itok=OKCc_60D +[2]: https://graphql.org/ +[3]: https://opensource.com/article/19/6/what-is-graphql +[4]: https://en.wikipedia.org/wiki/Representational_state_transfer diff --git a/sources/tech/20190614 A data-centric approach to patching systems with Ansible.md b/sources/tech/20190614 A data-centric approach to patching systems with Ansible.md new file mode 100644 index 0000000000..ade27106f3 --- /dev/null +++ b/sources/tech/20190614 A data-centric approach to patching systems with Ansible.md @@ -0,0 +1,141 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A data-centric approach to patching systems with Ansible) +[#]: via: (https://opensource.com/article/19/6/patching-systems-ansible) +[#]: author: (Mark Phillips https://opensource.com/users/markp/users/markp) + +A data-centric approach to patching systems with Ansible +====== +Use data and variables in Ansible to control selective patching. +![metrics and data shown on a computer screen][1] + +When you're patching Linux machines these days, I could forgive you for asking, "How hard can it be?" Sure, a **yum update -y** will sort it for you in a flash. + +![Animation of updating Linux][2] + +But for those of us working with more than a handful of machines, it's not that simple. Sometimes an update can create unintended consequences across many machines, and you're left wondering how to put things back the way they were. Or you might think, "Should I have applied the critical patch on its own and saved myself a lot of pain?" + +Faced with these sorts of challenges in the past led me to build a way to cherry-pick the updates needed and automate their application. + +### A flexible idea + +Here's an overview of the process: + +![Overview of the Ansible patch process][3] + +This system doesn't permit machines to have direct access to vendor patches. Instead, they're selectively subscribed to repositories. Repositories contain only the patches that are required––although I'd encourage you to give this careful consideration so you don't end up with a proliferation (another management overhead you'll not thank yourself for creating). + +Now patching a machine comes down to 1) The repositories it's subscribed to and 2) Getting the "thumbs up" to patch. By using variables to control both subscription and permission to patch, we don't need to tamper with the logic (the plays); we only need to alter the data. + +Here is an [example Ansible role][4] that fulfills both requirements. It manages repository subscriptions and has a simple variable that controls running the patch command. + + +``` +\--- +# tasks file for patching + +\- name: Include OS version specific differences +include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml" + +\- name: Ensure Yum repositories are configured +template: +src: template.repo.j2 +dest: "/etc/yum.repos.d/{{ item.label }}.repo" +owner: root +group: root +mode: 0644 +when: patching_repos is defined +loop: "{{ patching_repos }}" +notify: patching-clean-metadata + +\- meta: flush_handlers + +\- name: Ensure OS shipped yum repo configs are absent +file: +path: "/etc/yum.repos.d/{{ patching_default_repo_def }}" +state: absent + +# add flexibility of repos here +\- name: Patch this host +shell: 'yum update -y' +args: +warn: false +when: patchme|bool +register: result +changed_when: "'No packages marked for update' not in result.stdout" +``` + +### Scenarios + +In our fictitious, large, globally dispersed environment (of four hosts), we have: + + * Two web servers + * Two database servers + * An application comprising one of each server type + + + +OK, so this number of machines isn't "enterprise-scale," but remove the counts and imagine the environment as multiple, tiered, geographically dispersed applications. We want to patch elements of the stack across server types, application stacks, geographies, or the whole estate. + +![Example patch groups][5] + +Using only changes to variables, can we achieve that flexibility? Sort of. Ansible's [default behavior][6] for hashes is to overwrite. In our example, the **patching_repos** variable for the **db1** and **web1** hosts are overwritten because of their later occurrence in our inventory. Hmm, a bit of a pickle. There are two ways to manage this: + + 1. Multiple inventory files + 2. [Change the variable behavior][7] + + + +I chose number one because it maintains clarity. Once you start merging variables, it's hard to find where a hash appears and how it's put together. Using the default behavior maintains clarity, and it's the method I'd encourage you to stick with for your own sanity. + +### Get on with it then + +Let's run the play, focusing only on the database servers. + +Did you notice the final step— **Patch this host** —says **skipping**? That's because we didn't set [the controlling variable][8] to do the patching. What we have done is set up the repository subscriptions to be ready. + +So let's run the play again, limiting it to the web servers and tell it to do the patching. I ran this example with verbose output so you can see the yum updates happening. + +Patching an application stack requires another inventory file, as mentioned above. Let's rerun the play. + +Patching hosts in the European geography is the same scenario as the application stack, so another inventory file is required. + +Now that all the repository subscriptions are configured, let's just patch the whole estate. Note the **app1** and **emea** groups don't need the inventory here––they were only being used to separate the repository definition and setup. Now, **yum update -y** patches everything. If you didn't want to capture those repositories, they could be configured as **enabled=0**. + +### Conclusion + +The flexibility comes from how we group our hosts. Because of default hash behavior, we need to think about overlaps—the easiest way, to my mind at least, is with separate inventories. + +With regard to repository setup, I'm sure you've already said to yourself, "Ah, but the cherry-picking isn't that simple!" There is additional overhead in this model to download patches, test that they work together, and bundle them with dependencies in a repository. With complementary tools, you could automate the process, and in a large-scale environment, you'd have to. + +Part of me is drawn to just applying full patch sets as a simpler and easier way to go; skip the cherry-picking part and apply a full set of patches to a "standard build." I've seen this approach applied to both Unix and Windows estates with enforced quarterly updates. + +I’d be interested in hearing your experiences of patching regimes, and the approach proposed here, in the comments below or [via Twitter][9]. + +Many companies still have massive data centres full of hardware. Here's how Ansible can help. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/patching-systems-ansible + +作者:[Mark Phillips][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/markp/users/markp +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen) +[2]: https://opensource.com/sites/default/files/uploads/quick_update.gif (Animation of updating Linux) +[3]: https://opensource.com/sites/default/files/uploads/patch_process.png (Overview of the Ansible patch process) +[4]: https://github.com/phips/ansible-patching/blob/master/roles/patching/tasks/main.yml +[5]: https://opensource.com/sites/default/files/uploads/patch_groups.png (Example patch groups) +[6]: https://docs.ansible.com/ansible/2.3/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable +[7]: https://docs.ansible.com/ansible/2.3/intro_configuration.html#sts=hash_behaviour +[8]: https://github.com/phips/ansible-patching/blob/master/roles/patching/defaults/main.yml#L4 +[9]: https://twitter.com/thismarkp diff --git a/sources/tech/20190614 Learning by teaching, and speaking, in open source.md b/sources/tech/20190614 Learning by teaching, and speaking, in open source.md new file mode 100644 index 0000000000..b2bd11f7b4 --- /dev/null +++ b/sources/tech/20190614 Learning by teaching, and speaking, in open source.md @@ -0,0 +1,75 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Learning by teaching, and speaking, in open source) +[#]: via: (https://opensource.com/article/19/6/conference-proposal-tips) +[#]: author: (Lauren Maffeo https://opensource.com/users/lmaffeo) + +Learning by teaching, and speaking, in open source +====== +Want to speak at an open source conference? Here are a few tips to get +started. +![photo of microphone][1] + +_"Everything good, everything magical happens between the months of June and August."_ + +When Jenny Han wrote these words, I doubt she had the open source community in mind. Yet, for our group of dispersed nomads, the summer brings a wave of conferences that allow us to connect in person. + +From [OSCON][2] in Portland to [Drupal GovCon][3] in Bethesda, and [Open Source Summit North America][4] in San Diego, there’s no shortage of ways to match faces with Twitter avatars. After months of working on open source projects via Slack and Google Hangouts, the face time that these summer conferences offer is invaluable. + +The knowledge attendees gain at open source conferences serves as the spark for new contributions. And speaking from experience, the best way to gain value from these conferences is for you to _speak_ at them. + +But, does the thought of speaking give you chills? Hear me out before closing your browser. + +Last August, I arrived at the Vancouver Convention Centre to give a lightning talk and speak on a panel at [Open Source Summit North America 2018][5]. It’s no exaggeration to say that this conference—and applying to speak at it—transformed my career. Nine months later, I’ve: + + * Become a Community Moderator for Opensource.com + * Spoken at two additional open source conferences ([All Things Open][6] and [DrupalCon North America][7]) + * Made my first GitHub pull request + * Taken "Intro to Python" and written my first lines of code in [React][8] + * Taken the first steps towards writing a book proposal + + + +I don’t discount how much time, effort, and money are [involved in conference speaking][9]. Regardless, I can say with certainty that nothing else has grown my career so drastically. In the process, I met strangers who quickly became friends and unofficial mentors. Their feedback, advice, and connections have helped me grow in ways that I hadn’t envisioned this time last year. + +Had I not boarded that flight to Canada, I would not be where I am today. + +So, have I convinced you to take the first step? It’s easier than you think. If you want to [apply to speak at an open source conference][10] but are stuck on what to discuss, ask yourself this question: **What do I want to learn?** + +You don’t have to be an expert on the topics that you pitch. You don’t have to know everything about JavaScript, [ML][11], or Linux to [write conference proposals][12] on these topics. + +Here’s what you _do_ need: A willingness to do the work of teaching yourself these topics. And like any self-directed task, you’ll be most willing to do this work if you're invested in the subject. + +As summer conference season draws closer, soak up all the knowledge you can. Then, ask yourself what you want to learn more about, and apply to speak about those subjects at fall/winter open source events. + +After all, one of the most effective ways to learn is by [teaching a topic to someone else][13]. So, what will the open source community learn from you? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/conference-proposal-tips + +作者:[Lauren Maffeo][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lmaffeo +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/microphone_speak.png?itok=wW6elbl5 (photo of microphone) +[2]: https://conferences.oreilly.com/oscon/oscon-or +[3]: https://www.drupalgovcon.org +[4]: https://events.linuxfoundation.org/events/open-source-summit-north-america-2019/ +[5]: https://events.linuxfoundation.org/events/open-source-summit-north-america-2018/ +[6]: https://allthingsopen.org +[7]: https://lab.getapp.com/bias-in-ai-drupalcon-debrief/ +[8]: https://reactjs.org +[9]: https://twitter.com/venikunche/status/1130868572098572291 +[10]: https://opensource.com/article/19/1/public-speaking-resolutions +[11]: https://en.wikipedia.org/wiki/ML_(programming_language) +[12]: https://dev.to/aspittel/public-speaking-as-a-developer-2ihj +[13]: https://opensource.com/article/19/5/learn-python-teaching diff --git a/sources/tech/20190614 What is a Java constructor.md b/sources/tech/20190614 What is a Java constructor.md new file mode 100644 index 0000000000..66cd30110d --- /dev/null +++ b/sources/tech/20190614 What is a Java constructor.md @@ -0,0 +1,158 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What is a Java constructor?) +[#]: via: (https://opensource.com/article/19/6/what-java-constructor) +[#]: author: (Seth Kenlon https://opensource.com/users/seth/users/ashleykoree) + +What is a Java constructor? +====== +Constructors are powerful components of programming. Use them to unlock +the full potential of Java. +![][1] + +Java is (disputably) the undisputed heavyweight in open source, cross-platform programming. While there are many [great][2] [cross-platform][2] [frameworks][3], few are as unified and direct as [Java][4]. + +Of course, Java is also a pretty complex language with subtleties and conventions all its own. One of the most common questions about Java relates to **constructors** : What are they and what are they used for? + +Put succinctly: a constructor is an action performed upon the creation of a new **object** in Java. When your Java application creates an instance of a class you have written, it checks for a constructor. If a constructor exists, Java runs the code in the constructor while creating the instance. That's a lot of technical terms crammed into a few sentences, but it becomes clearer when you see it in action, so make sure you have [Java installed][5] and get ready for a demo. + +### Life without constructors + +If you're writing Java code, you're already using constructors, even though you may not know it. All classes in Java have a constructor because even if you haven't created one, Java does it for you when the code is compiled. For the sake of demonstration, though, ignore the hidden constructor that Java provides (because a default constructor adds no extra features), and take a look at life without an explicit constructor. + +Suppose you're writing a simple Java dice-roller application because you want to produce a pseudo-random number for a game. + +First, you might create your dice class to represent a physical die. Knowing that you play a lot of [Dungeons and Dragons][6], you decide to create a 20-sided die. In this sample code, the variable **dice** is the integer 20, representing the maximum possible die roll (a 20-sided die cannot roll more than 20). The variable **roll** is a placeholder for what will eventually be a random number, and **rand** serves as the random seed. + + +``` +import java.util.Random; + +public class DiceRoller { +private int dice = 20; +private int roll; +private [Random][7] rand = new [Random][7](); +``` + +Next, create a function in the **DiceRoller** class to execute the steps the computer must take to emulate a die roll: Take an integer from **rand** and assign it to the **roll** variable, add 1 to account for the fact that Java starts counting at 0 but a 20-sided die has no 0 value, then print the results. + + +``` +public void Roller() { +roll = rand.nextInt(dice); +roll += 1; +[System][8].out.println (roll); +} +``` + +Finally, spawn an instance of the **DiceRoller** class and invoke its primary function, **Roller** : + + +``` +// main loop +public static void main ([String][9][] args) { +[System][8].out.printf("You rolled a "); + +DiceRoller App = new DiceRoller(); +App.Roller(); +} +} +``` + +As long as you have a Java development environment installed (such as [OpenJDK][10]), you can run your application from a terminal: + + +``` +$ java dice.java +You rolled a 12 +``` + +In this example, there is no explicit constructor. It's a perfectly valid and legal Java application, but it's a little limited. For instance, if you set your game of Dungeons and Dragons aside for the evening to play some Yahtzee, you would need 6-sided dice. In this simple example, it wouldn't be that much trouble to change the code, but that's not a realistic option in complex code. One way you could solve this problem is with a constructor. + +### Constructors in action + +The **DiceRoller** class in this example project represents a virtual dice factory: When it's called, it creates a virtual die that is then "rolled." However, by writing a custom constructor, you can make your Dice Roller application ask what kind of die you'd like to emulate. + +Most of the code is the same, with the exception of a constructor accepting some number of sides. This number doesn't exist yet, but it will be created later. + + +``` +import java.util.Random; + +public class DiceRoller { +private int dice; +private int roll; +private [Random][7] rand = new [Random][7](); + +// constructor +public DiceRoller(int sides) { +dice = sides; +} +``` + +The function emulating a roll remains unchanged: + + +``` +public void Roller() { +roll = rand.nextInt(dice); +roll += 1; +[System][8].out.println (roll); +} +``` + +The main block of code feeds whatever arguments you provide when running the application. Were this a complex application, you would parse the arguments carefully and check for unexpected results, but for this sample, the only precaution taken is converting the argument string to an integer type: + + +``` +public static void main ([String][9][] args) { +[System][8].out.printf("You rolled a "); +DiceRoller App = new DiceRoller( [Integer][11].parseInt(args[0]) ); +App.Roller(); +} +} +``` + +Launch the application and provide the number of sides you want your die to have: + + +``` +$ java dice.java 20 +You rolled a 10 +$ java dice.java 6 +You rolled a 2 +$ java dice.java 100 +You rolled a 44 +``` + +The constructor has accepted your input, so when the class instance is created, it is created with the **sides** variable set to whatever number the user dictates. + +Constructors are powerful components of programming. Practice using them to unlock the full potential of Java. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/what-java-constructor + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth/users/ashleykoree +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/build_structure_tech_program_code_construction.png?itok=nVsiLuag +[2]: https://opensource.com/resources/python +[3]: https://opensource.com/article/17/4/pyqt-versus-wxpython +[4]: https://opensource.com/resources/java +[5]: https://openjdk.java.net/install/index.html +[6]: https://opensource.com/article/19/5/free-rpg-day +[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+random +[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[9]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[10]: https://openjdk.java.net/ +[11]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+integer diff --git a/sources/tech/20190617 How to Use VLAN tagged NIC (Ethernet Card) on CentOS and RHEL Servers.md b/sources/tech/20190617 How to Use VLAN tagged NIC (Ethernet Card) on CentOS and RHEL Servers.md new file mode 100644 index 0000000000..1a6f5988e9 --- /dev/null +++ b/sources/tech/20190617 How to Use VLAN tagged NIC (Ethernet Card) on CentOS and RHEL Servers.md @@ -0,0 +1,173 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Use VLAN tagged NIC (Ethernet Card) on CentOS and RHEL Servers) +[#]: via: (https://www.linuxtechi.com/vlan-tagged-nic-ethernet-card-centos-rhel-servers/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +How to Use VLAN tagged NIC (Ethernet Card) on CentOS and RHEL Servers +====== + +There are some scenarios where we want to assign multiple IPs from different **VLAN** on the same Ethernet card (nic) on Linux servers ( **CentOS** / **RHEL** ). This can be done by enabling VLAN tagged interface. But for this to happen first we must make sure multiple VLANs are attached to port on switch or in other words we can say we should configure trunk port by adding multiple VLANs on switch. + + + +Let’s assume we have a Linux Server, there we have two Ethernet cards (enp0s3 & enp0s8), first NIC ( **enp0s3** ) will be used for data traffic and second NIC ( **enp0s8** ) will be used for control / management traffic. For Data traffic I will using multiple VLANs (or will assign multiple IPs from different VLANs on data traffic ethernet card). + +I am assuming the port from switch which is connected to my server data NIC is configured as trunk port by mapping the multiple VLANs to it. + +Following are the VLANs which is mapped to data traffic Ethernet Card (NIC): + + * VLAN ID (200), VLAN N/W = 172.168.10.0/24 + * VLAN ID (300), VLAN N/W = 172.168.20.0/24 + + + +To use VLAN tagged interface on CentOS 7 / RHEL 7 / CentOS 8 /RHEL 8 systems, [kernel module][1] **8021q** must be loaded. + +Use the following command to load the kernel module “8021q” + +``` +[root@linuxtechi ~]# lsmod | grep -i 8021q +[root@linuxtechi ~]# modprobe --first-time 8021q +[root@linuxtechi ~]# lsmod | grep -i 8021q +8021q 29022 0 +garp 14384 1 8021q +mrp 18542 1 8021q +[root@linuxtechi ~]# +``` + +Use below modinfo command to display information about kernel module “8021q” + +``` +[root@linuxtechi ~]# modinfo 8021q +filename: /lib/modules/3.10.0-327.el7.x86_64/kernel/net/8021q/8021q.ko +version: 1.8 +license: GPL +alias: rtnl-link-vlan +rhelversion: 7.2 +srcversion: 2E63BD725D9DC11C7DA6190 +depends: mrp,garp +intree: Y +vermagic: 3.10.0-327.el7.x86_64 SMP mod_unload modversions +signer: CentOS Linux kernel signing key +sig_key: 79:AD:88:6A:11:3C:A0:22:35:26:33:6C:0F:82:5B:8A:94:29:6A:B3 +sig_hashalgo: sha256 +[root@linuxtechi ~]# +``` + +Now tagged (or mapped) the VLANs 200 and 300 to NIC enp0s3 using the [ip command][2] + +``` +[root@linuxtechi ~]# ip link add link enp0s3 name enp0s3.200 type vlan id 200 +``` + +Bring up the interface using below ip command: + +``` +[root@linuxtechi ~]# ip link set dev enp0s3.200 up +``` + +Similarly mapped the VLAN 300 to NIC enp0s3 + +``` +[root@linuxtechi ~]# ip link add link enp0s3 name enp0s3.300 type vlan id 300 +[root@linuxtechi ~]# ip link set dev enp0s3.300 up +[root@linuxtechi ~]# +``` + +Now view the tagged interface status using ip command: + +[![tagged-interface-ip-command][3]][4] + +Now we can assign the IP address to tagged interface from their respective VLANs using beneath ip command, + +``` +[root@linuxtechi ~]# ip addr add 172.168.10.51/24 dev enp0s3.200 +[root@linuxtechi ~]# ip addr add 172.168.20.51/24 dev enp0s3.300 +``` + +Use below ip command to see whether IP is assigned to tagged interface or not. + +![ip-address-tagged-nic][5] + +All the above changes via ip commands will not be persistent across the reboot. These tagged interfaces will not be available after reboot and after network service restart + +So, to make tagged interfaces persistent across the reboot then use interface **ifcfg files** + +Edit interface (enp0s3) file “ **/etc/sysconfig/network-scripts/ifcfg-enp0s3** ” and add the following content, + +Note: Replace the interface name that suits to your env, + +``` +[root@linuxtechi ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3 +TYPE=Ethernet +DEVICE=enp0s3 +BOOTPROTO=none +ONBOOT=yes +``` + +Save & exit the file + +Create tagged interface file for VLAN id 200 as “ **/etc/sysconfig/network-scripts/ifcfg-enp0s3.200** ” and add the following contents to it. + +``` +[root@linuxtechi ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3.200 +DEVICE=enp0s3.200 +BOOTPROTO=none +ONBOOT=yes +IPADDR=172.168.10.51 +PREFIX=24 +NETWORK=172.168.10.0 +VLAN=yes +``` + +Save & exit the file + +Similarly create interface file for VLAN id 300 as “/etc/sysconfig/network-scripts/ifcfg-enp0s3.300” and add the following contents to it + +``` +[root@linuxtechi ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3.300 +DEVICE=enp0s3.300 +BOOTPROTO=none +ONBOOT=yes +IPADDR=172.168.20.51 +PREFIX=24 +NETWORK=172.168.20.0 +VLAN=yes +``` + +Save and exit file and then restart network services using the beneath command, + +``` +[root@linuxtechi ~]# systemctl restart network +[root@linuxtechi ~]# +``` + +Now verify whether tagged interface are configured and up & running using the ip command, + +![tagged-interface-status-ip-command-linux-server][6] + +That’s all from this article, I hope you got an idea how to configure and enable VLAN tagged interface on CentOS 7 / 8 and RHEL 7 /8 Severs. Please do share your feedback and comments. + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/vlan-tagged-nic-ethernet-card-centos-rhel-servers/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/how-to-manage-kernel-modules-in-linux/ +[2]: https://www.linuxtechi.com/ip-command-examples-for-linux-users/ +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/06/tagged-interface-ip-command-1024x444.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/06/tagged-interface-ip-command.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/06/ip-address-tagged-nic-1024x343.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/06/tagged-interface-status-ip-command-linux-server-1024x656.jpg diff --git a/sources/tech/20190617 KIT Scenarist is a Powerful Tool for Creating Screenplays.md b/sources/tech/20190617 KIT Scenarist is a Powerful Tool for Creating Screenplays.md new file mode 100644 index 0000000000..65f492420d --- /dev/null +++ b/sources/tech/20190617 KIT Scenarist is a Powerful Tool for Creating Screenplays.md @@ -0,0 +1,101 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (KIT Scenarist is a Powerful Tool for Creating Screenplays) +[#]: via: (https://itsfoss.com/kit-scenarist/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +KIT Scenarist is a Powerful Tool for Creating Screenplays +====== + +Did you ever wish that there was an open source tool for all your screenplay writing needs? Well, you are in luck. Today, we will be looking at an application that will do just that. Today, we will be looking at KIT Scenarist. + +### KIT Scenarist: An Open Source tool for writing screenplays + +[KIT Scenarist][1] is a program designed to be your one-stop-shop to create the next great screenplay. KIT Scenarist’s tools are split up into four modules: Research, Cards, Script, and Statistics. When you load KIT Scenarist for the first time after installing it, you will be asked if you want to enable each of these modules. You can also disable any of the modules from the setting menu. + +![Scenarist][2] + +The Research module gives you a place to store your story ideas, as well as, ideas and information for both characters and locations. You can also add images for a character or location to give you inspiration. + +The Cards module shows you the scenes that you have written or sketched out like cards on a cord board. You can drag these scenes around on the board to rearrange them. You can also jump to a certain scene or mark a scene as done. + +The Script module is where the actual writing takes place. It has a widget that tells you approximately how long your screenplay will take to perform. Like a word processor, you can tell KIT Scenarist what parts of the script are the actions, character, dialogue, etc and it will format it correctly. + +![Scenarist Research module][3] + +The Statistics module gives you all kinds of reports and graphs about your screenplay. The scene report shows how long each act is and what characters are in it. The location report shows how much time is spent at each location and in which acts. The cast report shows how many scenes each character is in and how much dialogue they have. There is even a report that lists all of the dialogue for each character. + +[][4] + +Suggested read Tilix: Advanced Tiling Terminal Emulator for Power Users + +Like all well-designed apps, KIT Scenarist has both a light and dark theme. The dark theme is the default. + +![Scenarist Statistics module][5] + +KIT Scenarist stores your projects in `.kitsp` files. These files are essentially SQLite database files with a different extension. This means that if you ever run into issues with KIT Scenarist, you can retrieve your information with an SQLite viewer. + +This application also allows you to import scripts from a wide range of script writing applications. You can import the following file formats: Final Draft Screenplay (.fdx), Final Draft Template (.fdxt), Trelby Screenplay (.trelby), [Fountain Text][6] (.foundation), Celtx Project (.celtx), .odt, . doc and .docx. You can export your outline and script to .docx, .pdf, .fdx. or .Fountain. + +The desktop version of KIT Scenarist is free, but they also have a couple of [Pro options][7]. They have a cloud service to collaborate with others or sync your work to other devices. The cloud service costs $4.99 for a month or $52.90 for a year. They have other subscription lengths. KIT Scenarist is available in the iOS app store or the Google Play store, but cost money there. Finally, if you are an organization who wants to use KIT Scenarist but it is missing a feature you want, they will add it if you finance the work. + +![Scenarist Cards module][8] + +### How to Install Scenarist + +Currently, the only repo that Scenarist is available for downloading is the [Arch User Repository][9]. (Arch rulez :D) + +Otherwise, you have to [download][10] a package installer from the website. They have packages available for Linux (both .deb and .rpm), Windows, and macOS. As I stated above, there are also versions available for both Android and iOS, but they are not free. You can find the source code of KIT Scenarist on GitHub. + +[KIT Scenarist on GitHub][11] + +If KIT Scenarist won’t start on your Linux system, try installing the `libxcb-xinerama0` package. + +![Scenarist Script][12] + +### Final Thoughts on KIT Scenarist + +KIT Scenarist offers the full script writing experience. All your information is stored in one place, so you don’t need to look everywhere for your information. It does everything. Now, the creator just needs to add a feature to submit your script directly to the person who will make you the next famous playwright. + +[][13] + +Suggested read Bookworm: A Simple yet Magnificent eBook Reader for Linux + +If KIT Scenarist looks too overwhelming and you want to try something simpler, I would recommend trying [Trelby][14]. If you are into writing, you may read my list of [useful open source tools for writers][15]. + +Have you every used KIT Scenarist? What is your favorite open source screenwriting tool? Please let us know in the comments below. + +If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][16]. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/kit-scenarist/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://kitscenarist.ru/en/index.html +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/scenarist-about.png?fit=800%2C469&ssl=1 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/scenarist-research.png?fit=800%2C371&ssl=1 +[4]: https://itsfoss.com/tilix-terminal-emulator/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/scenarist-statistics.png?fit=800%2C467&ssl=1 +[6]: https://www.fountain.io/ +[7]: https://kitscenarist.ru/en/pricing.html +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/scenarist-cards.png?fit=800%2C470&ssl=1 +[9]: https://aur.archlinux.org/packages/scenarist +[10]: https://kitscenarist.ru/en/download.html +[11]: https://github.com/dimkanovikov/kitscenarist +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/scenarist-script.png?fit=800%2C468&ssl=1 +[13]: https://itsfoss.com/bookworm-ebook-reader-linux/ +[14]: https://www.trelby.org/ +[15]: https://itsfoss.com/open-source-tools-writers/ +[16]: http://reddit.com/r/linuxusersgroup diff --git a/sources/tech/20190618 Cylon - The Arch Linux Maintenance Program For Newbies.md b/sources/tech/20190618 Cylon - The Arch Linux Maintenance Program For Newbies.md new file mode 100644 index 0000000000..6843910f91 --- /dev/null +++ b/sources/tech/20190618 Cylon - The Arch Linux Maintenance Program For Newbies.md @@ -0,0 +1,257 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Cylon – The Arch Linux Maintenance Program For Newbies) +[#]: via: (https://www.ostechnix.com/cylon-arch-linux-maintenance-program/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +Cylon – The Arch Linux Maintenance Program For Newbies +====== + +![Cylon is an Arch Linux Maintenance Program][1] + +Recently switched to Arch Linux as your daily driver? Great! I’ve got a good news for you. Meet **Cylon** , a maintenance program for Arch Linux and derivatives. It is a menu-driven **Bash** script which provides updates, maintenance, backups and system checks for Arch Linux and its derivatives such as Manjaro Linux etc. Cylon is mainly a CLI program, and also has a basic dialog GUI. In this guide, we will see how to install and use Cylon in Arch Linux. + +### Cylon – The Arch Linux Maintenance Program + +##### Install Cylon + +Cylon is available in the [**AUR**][2]. You can install it using any AUR helpers, for example [**Yay**][3]. + +``` +$ yay -S cylon +``` + +##### Usage + +Please note that Cylon _**will not install all tools**_ by default. Some functions require various dependencies packages to be installed. There are three dependencies and the rest are optional dependencies. The optional dependencies are left to user discretion. When you perform a function, it will display the missing packages if there are any. All missing packages will be shown as **n/a** (not available) in menus. You need to install the missing packages by yourself before using such functions. + +To launch Cylon, type _**cylon**_ in the Terminal: + +``` +$ cylon +``` + +Sample output from my Arch linux system: + +![][4] + +Default interface of Cylon, the Arch Linux maintenance program + +You can also launch Cylon from the Menu. It usually found under **Applications > System Tools**. + +As you see in the above screenshot, there are **14** menu entries in Cylon main menu to perform different functions. To go to each entry, type the respective number. Also, as you see in the screenshot, there is **n/a** besides the 2 and 3 menu entries which means **auracle** and [**Trizen**][5] are not installed. You need to install them first before performing those functions. + +Let us see what each menu entry does. + +**1\. Pacman** + +Under [**Pacman**][6] section, you can do various package management operations such as install, update, upgrade, verify, remove packages, display package information, view Arch Linux news feed and many. Just type a number to perform the respective action. + +![][7] + +You can go back to main menu by typing the number **21**. + +**2. auracle +** + +The **auracle** is an AUR helper program that can be used to perform various AUR actions such as install, update, download, search, remove AUR packages in your Arch linux box. + +**3\. trizen** + +It is same as above section. + +**4\. System Update** + +As the name says, this section is dedicated to perform Arch Linux update. Here you can update both the official and AUR packages. Cylon gives you the following four options in this section. + + 1. Update Arch Main Repos only, + 2. Update AUR only, + 3. Update All repos, + 4. No Update and exit. + + + +![][8] + +**5\. System Maintenance** + +In this section, you can do the following maintenance tasks. + + 1. Failed Systemd Services and status, + 2. Check Journalctl log for Errors, + 3. Check Journalctl for fstrim SSD trim, + 4. Analyze system boot-up performance, + 5. Check for Broken Symlinks, + 6. Find files where no group or User corresponds to file’s numeric ID, + 7. lostfiles, + 8. Diskspace usage, + 9. Find 200 of the biggest files, + 10. Find inodes usage, + 11. Old configuration files scan, + 12. Print sensors information, + 13. Clean journal files, + 14. Delete core dumps /var/lib/systemd/coredump/, + 15. Delete files, + 16. bleachbit n/a, + 17. rmlint n/a, + 18. List All Open Files, + 19. DMI table decoder, + 20. Return. + + + +The non-installed packages will be shown with letters n/a besides that applications. You need to install them first before choosing that particular action. + +** **Recommended Download** – [**Free Video: “Penetration Testing Methodologies Training Course (a $99 value!) FREE”**][9] + +**6\. System backup** + +This section provides backup utilities such as **rsync** to backup your Arch Linux system. Also, there is a custom backup options which allows you to manually backup files/folders to a user-specified location. + +![][10] + +**7\. System Security** + +Cylon provides various security tools including the following: + + 1. ccrypt – Encrypt/decrypt files, + 2. clamav – Antivirus, + 3. rkhunter – RootKit hunter scan, + 4. lynis – System audit tool, + 5. Password generator, + 6. List the password aging info of a user, + 7. Audit SUID/SGID Files. + + + +Remember you need to install them yourself in order to use them. Cylon will not help you to install the missing packages. + +**8\. Network Maintenance** + +This section is for network related functions. Here, you can: + + 1. See wifi link quality continuously on screen, + 2. Use speedtest-cli -testing internet bandwidth, + 3. Check if website up with netcat and ping, + 4. Display all interfaces which are currently available, + 5. Display kernal routing table, + 6. Check the status of UFW, Uncomplicated Firewall, + 7. Network Time Synchronization status check, + 8. traceroute print route packets trace to network host, + 9. tracepath traces path to a network host, + 10. View all open ports + + + +**9\. xterm terminal** + +Here, you can launch xterm terminal at output folder path in new window. + +**10\. View/Edit config file** + +View and edit the configuration files if necessary. + +**11\. System information** + +This is most useful feature of Cylon utlity. This section provides your Arch Linux system’s information such as, + + * Uptime, + * Kernel details, + * OS architecture, + * Username, + * Default Shell, + * Screen resolution, + * CPU, + * RAM (used/total), + * Editor variable, + * Location of pacman cache folder, + * Hold packages, + * Number of orphan packages, + * Total number of installed packages, + * Number of all explicitly installed packages, + * All foreign installed packages, + * All foreign explicitly installed packages, + * All packages installed as dependencies, + * Top 5 largest packages, + * 5 newest updated packages, + * Packages Installed size by repositories. + + + +![][11] + +**12\. Cylon information** + +It will display the information about Cylon program. It also performs the dependencies installation check and display the list of installed non-installed dependencies. + +![][12] + +**13\. Weather** + +It displays the 3 day weather forecast by **wttr.in** utility. + +* * * + +**Related Read:** + + * **[How To Check Weather Details From Command Line In Linux][13]** + + + +* * * + +**14\. Exit** + +Type **14** to exit Cylon. + +For more details, type **cylon -h** in the Terminal to print cylon information. + +* * * + +**Recommended read:** + + * [**Cylon-deb : The Debian Linux Maintenance Program**][14] + + + +* * * + +Cylon script offers a lot of tools and features to maintain your Arch Linux system. If you’re new to Arch Linux, give it a try and see if it helps. + +**Resource:** + + * [**Cylon GitHub page**][15] + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/cylon-arch-linux-maintenance-program/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2017/06/Cylon-The-Arch-Linux-Maintenance-Program-720x340.png +[2]: https://aur.archlinux.org/packages/cylon/ +[3]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ +[4]: http://www.ostechnix.com/wp-content/uploads/2017/06/cylon-interface.png +[5]: https://www.ostechnix.com/trizen-lightweight-aur-package-manager-arch-based-systems/ +[6]: https://www.ostechnix.com/getting-started-pacman/ +[7]: http://www.ostechnix.com/wp-content/uploads/2017/06/Cylon-pacman.png +[8]: http://www.ostechnix.com/wp-content/uploads/2017/06/Cylon-system-update.png +[9]: https://ostechnix.tradepub.com/free/w_cybf03/prgm.cgi +[10]: http://www.ostechnix.com/wp-content/uploads/2017/06/Cylon-system-backup.png +[11]: http://www.ostechnix.com/wp-content/uploads/2017/06/Cylon-system-information.png +[12]: http://www.ostechnix.com/wp-content/uploads/2017/06/Cylon-information.png +[13]: https://www.ostechnix.com/check-weather-details-command-line-linux/ +[14]: https://www.ostechnix.com/cylon-deb-debian-linux-maintenance-program/ +[15]: https://github.com/gavinlyonsrepo/cylon diff --git a/sources/tech/20190618 How to use MapTool to build an interactive dungeon RPG.md b/sources/tech/20190618 How to use MapTool to build an interactive dungeon RPG.md new file mode 100644 index 0000000000..94aaf47de2 --- /dev/null +++ b/sources/tech/20190618 How to use MapTool to build an interactive dungeon RPG.md @@ -0,0 +1,231 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to use MapTool to build an interactive dungeon RPG) +[#]: via: (https://opensource.com/article/19/6/how-use-maptools) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +How to use MapTool to build an interactive dungeon RPG +====== +By using MapTool, most of a game master's work is done well before a +role-playing game begins. +![][1] + +In my previous article on MapTool, I explained how to download, install, and configure your own private, [open source virtual tabletop][2] so you and your friends can play a role-playing game (RPG) together. [MapTool][3] is a complex application with lots of features, and this article demonstrates how a game master (GM) can make the most of it. + +### Update JavaFX + +MapTool requires JavaFX, but Java maintainers recently stopped bundling it in Java downloads. This means that, even if you have Java installed, you might not have JavaFX installed. + +Some Linux distributions have a JavaFX package available, so if you try to run MapTool and get an error about JavaFX, download the latest self-contained version: + + * For [Ubuntu and other Debian-based systems][4] + * For [Fedora and Red Hat-based systems][5] + + + +### Build a campaign + +The top-level file in MapTool is a campaign (.cmpgn) file. A campaign can contain all of the maps required by the game you're running. As your players progress through the campaign, everyone changes to the appropriate map and plays. + +For that to go smoothly, you must do a little prep work. + +First, you need the digital equivalents of miniatures: _tokens_ in MapTool terminology. Tokens are available from various sites, but the most prolific is [immortalnights.com/tokensite][6]. If you're still just trying out virtual tabletops and aren't ready to invest in digital art yet, you can get a stunning collection of starter tokens from immortalnights.com for $0. + +You can add starter content to MapTool quickly and easily using its built-in resource importer. Go to the **File** menu and select **Add Resource to Library**. + +In the **Add Resource to Library** dialogue box, select the RPTools tab, located at the bottom-left. This lists all the free art packs available from the RPTools server, tokens and maps alike. Click to download and import. + +![Add Resource to Library dialogue][7] + +You can import assets you already have on your computer by selecting files from the file system, using the same dialogue box. + +MapTool resources appear in the Library panel. If your MapTool window has no Library panel, select **Library** in the **Window** menu to add one. + +### Gather your maps + +The next step in preparing for your game is to gather maps. Depending on what you're playing, that might mean you need to draw your maps, purchase a map pack, or just open a map bundled with a game module. If all you need is a generic dungeon, you can also download free maps from within MapTool's **Add Resource to Library**. + +If you have a set of maps you intend to use often, you can import them as resources. If you are building a campaign you intend to use just once, you can quickly add any PNG or JPEG file as a **New Map** in the **Map** menu. + +![Creating a new map][8] + +Set the **Background** to a texture that roughly matches your map or to a neutral color. + +Set the **Map** to your map graphics file. + +Give your new map a unique **Name**. The map name is visible to your players, so keep it free of spoilers. + +To switch between maps, click the **Select Map** button in the top-right corner of the MapTool window, and choose the map name in the drop-down menu that appears. + +![Select a map][9] + +Before you let your players loose on your map, you still have some important prep work to do. + +### Adjust the grid size + +Since most RPGs govern how far players can move during their turn, especially during combat, game maps are designed to a specific scale. The most common scale is one map square for every five feet. Most maps you download already have a grid drawn on them; if you're designing a map, you should draw on graph paper to keep your scale consistent. Whether your map graphic has a grid or not, MapTool doesn't know about it, but you can adjust the digital grid overlay so that your player tokens are constrained into squares along the grid. + +MapTool doesn't show the grid by default, so go to the **Map** menu and select **Adjust grid**. This displays MapTool's grid lines, and your goal is to make MapTool's grid line up with the grid drawn onto your map graphic. If your map graphic doesn't have a grid, it may indicate its scale; a common scale is one inch per five feet, and you can usually assume 72 pixels is one inch (on a 72 DPI screen). While adjusting the grid, you can change the color of the grid lines for your own reference. Set the cell size in pixels. Click and drag to align MapTool's grid to your map's grid. + +![Adjusting the grid][10] + +If your map has no grid and you want the grid to remain visible after you adjust it, go to the **View** menu and select **Show Grid**. + +### Add players and NPCs + +To add a player character (PC), non-player character (NPC), or monster to your map, find an appropriate token in your **Library** panel, then drag and drop one onto your map. In the **New Token** dialogue box that appears, give the token a name and set it as an NPC or a PC, then click the OK button. + +![Adding a player character to the map][11] + +Once a token is on the map, try moving it to see how its movements are constrained to the grid you've designated. Make sure **Interaction Tools** , located in the toolbar just under the **File** menu, is selected. + +![A token moving within the grid][12] + +Each token added to a map has its own set of properties, including the direction it's facing, a light source, player ownership, conditions (such as incapacitated, prone, dead, and so on), and even class attributes. You can set as many or as few of these as you want, but at the very least you should right-click on each token and assign it ownership. Your players must be logged into your MapTool server for tokens to be assigned to them, but you can assign yourself NPCs and monsters in advance. + +The right-click menu provides access to all important token-related functions, including setting which direction it's facing, setting a health bar and health value, a copy and paste function (enabling you and your players to move tokens from map to map), and much more. + +![The token menu unlocks great, arcane power][13] + +### Activate fog-of-war effects + +If you're using maps exclusively to coordinate combat, you may not need a fog-of-war effect. But if you're using maps to help your players visualize a dungeon they're exploring, you probably don't want them to see the whole map before they've made significant moves, like opening locked doors or braving a decaying bridge over a pit of hot lava. + +The fog-of-war effect is an invaluable tool for the GM, and it's essential to set it up early so that your players don't accidentally get a sneak peek at all the horrors your dungeon holds for them. + +To activate fog-of-war on a map, go to the **Map** and select **Fog-of-War**. This blackens the entire screen for your players, so your next step is to reveal some portion of the map so that your players aren't faced with total darkness when they switch to the map. Fog-of-war is a subtractive process; it starts 100% dark, and as the players progress, you reveal new portions of the map using fog-of-war drawing tools available in the **FOG** toolbar, just under the **View** menu. + +You can reveal sections of the map in rectangle blocks, ovals, polygons, diamonds, and freehand shapes. Once you've selected the shape, click and release on the map, drag to define an area to reveal, and then click again. + +![Fog-of-war as experienced by a playe][14] + +If you're accidentally overzealous with what you reveal, you have two ways to reverse what you've done: You can manually draw new fog, or you can reset all fog. The quicker method is to reset all fog with **Ctrl+Shift+A**. The more elegant solution is to press **Shift** , then click and release, draw an area of fog, and then click again. Instead of exposing an area of the map, it restores fog. + +### Add lighting effects + +Fog-of-war mimics the natural phenomenon of not being able to see areas of the world other than where you are, but lighting effects mimic the visibility player characters might experience in light and dark. For games like Pathfinder and Dungeons and Dragons 5e, visibility is governed by light sources matched against light conditions. + +First, activate lighting by clicking on the **Map** menu, selecting **Vision** , and then choosing either Daylight or Night. Now lighting effects are active, but none of your players have light sources, so they have no visibility. + +To assign light sources to players, right-click on the appropriate token and choose **Light Source**. Definitions exist for the D20 system (candle, lantern, torch, and so on) and in generic measurements. + +With lighting effects active, players can expose portions of fog-of-war as their light sources get closer to unexposed fog. That's a great effect, but it doesn't make much sense when players can illuminate the next room right through a solid wall. To prevent that, you have to help MapTool differentiate between empty space and solid objects. + +#### Define solid objects + +Defining walls and other solid objects through which light should not pass is easier than it sounds. MapTool's **Vision Blocking Layer** (VBL) tools are basic and built to minimize prep time. There are several basic shapes available, including a basic rectangle and an oval. Draw these shapes over all the solid walls, doors, pillars, and other obstructions, and you have instant rudimentary physics. + +![Setting up obstructions][15] + +Now your players can move around the map with light sources without seeing what lurks in the shadows of a nearby pillar or behind an innocent-looking door… until it's too late! + +![Lighting effects][16] + +### Track initiative + +Eventually, your players are going to stumble on something that wants to kill them, and that means combat. In most RPG systems, combat is played in rounds, with the order of turns decided by an _initiative_ roll. During combat, each player (in order of their initiative roll, from greatest to lowest) tries to defeat their foe, ideally dealing enough damage until their foe is left with no health points (HP). It's usually the most paperwork a GM has to do during a game because it involves tracking whose turn it is, how much damage each monster has taken, what amount of damage each monster's attack deals, what special abilities each monster has, and more. Luckily, MapTool can help with that—and better yet, you can extend it with a custom macro to do even more. + +MapTool's basic initiative panel helps you keep track of whose turn it is and how many rounds have transpired so far. To view the initiative panel, go to the **Window** menu and select **Initiative**. + +To add characters to the initiative order, right-click a token and select **Add To Initiative**. As you add each, the token and its label appear in the initiative panel in the order that you add them. If you make a mistake or someone holds their action and changes the initiative order, click and drag the tokens in the initiative panel to reorder them. + +During combat, click the **Next** button in the top-left of the initiative panel to progress to the next character. As long as you use the **Next** button, the **Round** counter increments, helping you track how many rounds the combat has lasted (which is helpful when you have spells or effects that last only for a specific number of rounds). + +Tracking combat order is helpful, but it's even better to track health points. Your players should be tracking their own health, but since everyone's staring at the same screen, it doesn't hurt to track it publicly in one place. An HP property and a graphical health bar (which you can activate) are assigned to each token, so that's all the infrastructure you need to track HP in MapTool, but doing it manually takes a lot of clicking around. Since MapTool can be extended with macros, it's trivial to bring all these components together for a smooth GM experience. + +The first step is to activate graphical health bars for your tokens. To do this, right-click on each token and select **Edit**. In the **Edit Token** dialog box, click on the **State** tab and deselect the radio button next to **Hide**. + +![Don't hide the health bar][17] + +Do this for each token whose health you want to expose. + +#### Write a macro + +Macros have access to all token properties, so each token's HP can be tracked by reading and writing whatever value exists in the token's HP property. The graphical health bar, however, bases its state on a percentage, so for the health bars to be meaningful, your tokens also must have some value that represents 100% of its HP. + +Go to the **Edit** menu and select **Campaign Properties** to globally add properties to tokens. In the **Campaign Properties** window, select the **Token Properties** tab and then click the **Basic** category in the left column. Under ***@HP** , add ***@MaxHP** and click the **Update** button. Click the **OK** button to close the window. + +![Adding a property to all tokens][18] + +Now right-click a token and select **Edit**. In the **Edit Token** window, select the **State** tab and enter a value for the token's maximum HP (from the player's character sheet). + +To create a new macro, reveal the **Campaign** panel in the **Window** menu. + +In the **Campaign** panel, right-click and select **Add New Macro**. A button labeled **New** appears in the panel. Right-click on the **New** button and select **Edit**. + +Enter this code in the macro editor window: + + +``` +[h:status = input( +"hpAmount|0|Points", +"hpType|Damage,Healing|Damage or heal?|RADIO|SELECT=0")] +[h:abort(status)] + +[if(hpType == 0),CODE: { +[h:HP = HP - hpAmount] +[h:bar.Health = HP / MaxHP] +[r:token.name] takes [r:hpAmount] damage.}; +{ +[h:diff = MaxHP - HP] +[h:HP = min(HP+hpAmount, MaxHP)] +[h:bar.Health = HP / MaxHP] +[r:token.name] gains [r:min(diff,hpAmount)] HP. };] +``` + +You can find full documentation of functions available in MapTool macros and their syntax from the [RPTools wiki][19]. + +In the **Details** tab, enable **Include Label** and **Apply to Selected Tokens** , and leave all other values at their default. Give your macro a better name than **New** , such as **HPTracker** , then click **Apply** and **OK**. + +![Macro editing][20] + +Your campaign now has a new ability! + +Select a token and click your **HPTracker** button. Enter the number of points to deduct from the token, click **OK** , and watch the health bar change to reflect the token's new state. + +It may seem like a simple change, but in the heat of battle, this is a GM's greatest weapon. + +### During the game + +There's obviously a lot you can do with MapTool, but with a little prep work, most of your work is done well before you start playing. You can even create a template campaign by creating an empty campaign with only the macros and settings you want, so all you have to do is import maps and stat out tokens. + +During the game, your workflow is mostly about revealing areas from fog-of-war and managing combat. The players can manage their own tokens, and your prep work takes care of everything else. + +MapTool makes digital gaming easy and fun, and most importantly, it keeps it open source and self-contained. Level-up today by learning MapTool and using it for your games. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/how-use-maptools + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/dice-keys_0.jpg?itok=PGEs3ZXa +[2]: https://opensource.com/article/18/5/maptool +[3]: https://github.com/RPTools/maptool +[4]: https://github.com/RPTools/maptool/releases +[5]: https://klaatu.fedorapeople.org/RPTools/maptool/ +[6]: https://immortalnights.com/tokensite/ +[7]: https://opensource.com/sites/default/files/uploads/maptool-resources.png (Add Resource to Library dialogue) +[8]: https://opensource.com/sites/default/files/uploads/map-properties.png (Creating a new map) +[9]: https://opensource.com/sites/default/files/uploads/map-select.jpg (Select a map) +[10]: https://opensource.com/sites/default/files/uploads/grid-adjust.jpg (Adjusting the grid) +[11]: https://opensource.com/sites/default/files/uploads/token-new.png (Adding a player character to the map) +[12]: https://opensource.com/sites/default/files/uploads/token-move.jpg (A token moving within the grid) +[13]: https://opensource.com/sites/default/files/uploads/token-menu.jpg (The token menu unlocks great, arcane power) +[14]: https://opensource.com/sites/default/files/uploads/fog-of-war.jpg (Fog-of-war as experienced by a playe) +[15]: https://opensource.com/sites/default/files/uploads/vbl.jpg (Setting up obstructions) +[16]: https://opensource.com/sites/default/files/uploads/map-light.jpg (Lighting effects) +[17]: https://opensource.com/sites/default/files/uploads/token-edit.jpg (Don't hide the health bar) +[18]: https://opensource.com/sites/default/files/uploads/campaign-properties.jpg (Adding a property to all tokens) +[19]: https://lmwcs.com/rptools/wiki/Main_Page +[20]: https://opensource.com/sites/default/files/uploads/macro-detail.jpg (Macro editing) diff --git a/sources/tech/20190619 11 Free and Open Source Video Editing Software.md b/sources/tech/20190619 11 Free and Open Source Video Editing Software.md new file mode 100644 index 0000000000..57ad8a5358 --- /dev/null +++ b/sources/tech/20190619 11 Free and Open Source Video Editing Software.md @@ -0,0 +1,327 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (11 Free and Open Source Video Editing Software) +[#]: via: (https://itsfoss.com/open-source-video-editors/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +11 Free and Open Source Video Editing Software +====== + +We’ve already covered the [top video editors for Linux][1]. That list contained some non-open source software as well. This made us write this article to feature only open source video editors. We’ve also mentioned what platforms are supported by these software so that this list is helpful even if you are not using Linux. + +### Top Free and Open Source Video Editors + +![Best Open Source Video Editors][2] + +Just for your information, this list is not a ranking and the editors listed here are not in any specific order. I have not mentioned the installation procedure but you can find that information on the website of each project. + +#### 1\. Kdenlive + +![][3] + +**Key Features** : + + * Multi-track Video Editing + * All kinds of audio/video format supported with the help of FFmpeg libraries + * 2D Title maker + * Customizable Interface and shortcuts + * Proxy editing to make things faster + * Automatic backup + * Timeline preview + * Keyframeable effects + * Audiometer, Histogram, Waveform, etc. + + + +**Platforms available on:** Linux, macOS and Windows. + +Kdenlive is an open source video editor (and free) available for Windows, Mac OSX, and Linux distros. + +If you are on a Mac, you will have to manually compile and install it. However, if you are on Windows, you can download the EXE file and should have no issues installing it. + +[Kdenlive][4] + +#### 2\. LiVES + +![][5] + +**Key Features:** + + * Frame and sample accurate editing + * Edit video in real-time + * Can be controlled using MIDI, keyboard, Joystic + * Multi-track support + * VJ keyboard control during playback + * Plugins supported + * Compatible with various effects frameworks: projectM, LADSPA audio, and so on. + + + +**Platforms available on:** Linux and macOS. Support for Windows will be added soon. + +LiVES is an interesting open source video editor. You can find the code on [GitHub][6]. It is currently available for **Linux and macOS Leopard**. It will soon be available for Windows (hopefully by the end of 2019). + +[LiVES][7] + +#### 3\. OpenShot + +![][8] + +**Key Features:** + + * Almost all video/audio formats supported + * Key frame animation framework + * Multi-track support + * Desktop integration (drag and drop support) + * Video transition with real-time previews + * 3D animated titles and effects + * Advanced timeline with drag/drop support, panning, scrolling, zooming, and snapping. + + + +**Platforms available on:** Linux, macOS and Windows. + +OpenShot is a quite popular video editor and it is open source as well. Unlike others, OpenShot offers a DMG installer for Mac OSX. So, you don’t have to compile and install it manually. + +If you are a fan of open source solutions and you own a Mac, OpenShot seems like a very good option. + +[OpenShot][9] + +#### 4\. VidCutter + +![][10] + +**Key Features:** + + * Keyframes viewer + * Cut, Split, and add different clips + * Major audio/video formats supported + + + +[][11] + +Suggested read Install Windows Like Desktop Widgets In Ubuntu Linux With Screenlets + +**Platforms available on:** Linux, macOS and Windows. + +VidCutter is an open source video editor for basic tasks. It does not offer a plethora of features – but it works for all the common tasks like clipping or cutting. It’s under active development as well. + +For Linux, it is available on Flathub as well. And, for Windows and Mac OS, you do get EXE and DMG file packages in the latest releases. + +[VidCutter][12] + +#### 5\. Shotcut + +![][13] + +**Key Features:** + + * Supports almost all major audio/video formats with the help of FFmpeg libraries. + * Multiple dockable/undockable panels + * Intuitive UI + * JACK transport sync + * Stereo, mono, and 5.1 surround support + * Waveform, Histogram, etc. + * Easy to use with dual monitors + * Portable version available + + + +**Platforms available on:** Linux, macOS and Windows. + +Shotcut is yet another popular open source video editor available across multiple platforms. It features a nice interface to work on. + +When considering the features, it offers almost everything that you would ever need (from color correction to adding transitions). Also, it provides a portable version for Windows – which is an impressive thing. + +[Shotcut][14] + +#### 6\. Flowblade + +![][15] + +**Key Features:** + + * Advanced timeline control + * Multi-track editing + * [G’mic][16] tool + * All major audio/video formats supported with the help of FFMpeg libraries + + + +**Platforms available on:** Linux + +Flowblade is an intuitive open source video editor available only for Linux. Yes, it is a bummer that we do not have cross-platform support for this. + +However, if you are using a Linux distro, you can either download the .deb file and get it installed or use the source code on GitHub. + +[Flowblade][17] + +#### 7\. Avidemux + +![][18] + +**Key Features:** + + * Trim + * Cut + * Filter support + * Major video format supported + + + +**Platforms available on:** Linux, BSD, macOS and Windows. + +If you are looking for a basic cross-platform open source video editor – this will be one of our recommendations. You just get the ability to cut, save, add a filter, and perform some other basic editing tasks. Their official [SourceForge page][19] might look like it has been abandoned, but it is in active development. + +[Avidemux][19] + +#### 8\. Pitivi + +![][20] + +**Key Features:** + + * All major video formats supported using [GStreamer Multimedia Framework][21] + * Advanced timeline independent of frame rate + * Animated effects and transitions + * Audio waveforms + * Real-time trimming previews + + + +**Platforms available on:** Linux + +Yet another open source video editor that is available only for Linux. The UI is user-friendly and the features offered will help you perform some advanced edits as well. + +You can install it using Flatpak or look for the source code on their official website. It should be available in the repositories of most distributions as well. + +[Pitivi][22] + +#### 9\. Blender + +![][23] + +**Key Features:** + + * VFX + * Modeling tools + * Animation and Rigging tools + * Draw in 2D or 3D + + + +[][24] + +Suggested read 4 Best Modern Open Source Text Editors For Coding in Linux + +**Platforms available on:** Linux, macOS and Windows. + +Blender is an advanced 3D creation suite. And, it is surprising that you get all those powerful abilities for free (and while being open source). + +Of course, Blender is not a solution for every user – however, it is definitely one of the best open source tool available for Windows, macOS, and Linux. You can also find it on [Steam][25] to install it. + +[Blender][26] + +#### 10\. Cinelerra + +![][27] + +**Key Features:** + + * Advanced timeline + * Motion tracking support + * Video stabilization + * Audio mastering + * Color correction + + + +**Platforms available on:** Linux + +Cinelerra is a quite popular open source video editor. However, it has several branches to it (in other words – different versions). I am not sure if that is a good thing – but you get different features (and ability) on each of them. + +Cinelerra GG, CV, CVE, and HV are those variants catering to users with different preferences. Personally, I would recommend to check out [Cinelerra GG][28]. + +[Cinelerra][29] + +#### 11\. NATRON + +![][30] + +**Key Features:** + + * VFX + * Powerful Tracker + * Keying tools for production needs + * Shadertoy and G’mic tools + * OpenFX plugin support + + + +**Platforms available on** : Linux, macOS and Windows. + +If you are into VFX and motion graphics, NATRON is a good alternative to Blender. Of course, in order to compare them for your usage, you will have to give it a try yourself. + +You do have the installer available for Windows and the dmg package for Mac. So, it is quite easy to get it installed. You can always head to its [GitHub page][31] for more information. + +[Natron][32] + +**Wrapping Up** + +So, now that you know about some of the most popular open source video editors available out there – what do you think about them? + +Are they good enough for professional requirements? Or, did we miss any of your favorite open source video editor that deserved the mention? + +I am not an expert video editor and have only experience with simple editing tasks to create YouTube videos. If you are an experienced and professional video editor, I would like to hear your opinion on how good are these open source video editors for the experts. + +Let us know your thoughts in the comments below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/open-source-video-editors/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/best-video-editing-software-linux/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/best-open-source-video-editors-800x450.png?resize=800%2C450&ssl=1 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/06/kdenlive-free-video-editor-on-ubuntu.jpg?ssl=1 +[4]: https://kdenlive.org/en/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/lives-video-editor.jpg?fit=800%2C600&ssl=1 +[6]: https://github.com/salsaman/LiVES +[7]: http://lives-video.com/ +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/06/openshot-free-video-editor-on-ubuntu.jpg?ssl=1 +[9]: https://www.openshot.org/ +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/vidcutter.jpg?fit=800%2C585&ssl=1 +[11]: https://itsfoss.com/install-windows-desktop-widgets-linux/ +[12]: https://github.com/ozmartian/vidcutter +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/06/shotcut-video-editor-linux.jpg?resize=800%2C503&ssl=1 +[14]: https://shotcut.org/ +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/06/flowblade-movie-editor-on-ubuntu.jpg?ssl=1 +[16]: https://gmic.eu/ +[17]: https://jliljebl.github.io/flowblade/index.html +[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/avidemux.jpg?resize=800%2C697&ssl=1 +[19]: http://avidemux.sourceforge.net/ +[20]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/pitvi.jpg?resize=800%2C464&ssl=1 +[21]: https://en.wikipedia.org/wiki/GStreamer +[22]: http://www.pitivi.org/ +[23]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/06/blender-running-on-ubuntu-16.04.jpg?ssl=1 +[24]: https://itsfoss.com/best-modern-open-source-code-editors-for-linux/ +[25]: https://store.steampowered.com/app/365670/Blender/ +[26]: https://www.blender.org/ +[27]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/06/cinelerra-screenshot.jpeg?ssl=1 +[28]: https://www.cinelerra-gg.org/ +[29]: http://cinelerra.org/ +[30]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/natron.jpg?fit=800%2C481&ssl=1 +[31]: https://github.com/NatronGitHub/Natron +[32]: https://natrongithub.github.io/ diff --git a/sources/tech/20190619 Getting started with OpenSSL- Cryptography basics.md b/sources/tech/20190619 Getting started with OpenSSL- Cryptography basics.md new file mode 100644 index 0000000000..0f3da1b13e --- /dev/null +++ b/sources/tech/20190619 Getting started with OpenSSL- Cryptography basics.md @@ -0,0 +1,342 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Getting started with OpenSSL: Cryptography basics) +[#]: via: (https://opensource.com/article/19/6/cryptography-basics-openssl-part-1) +[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu/users/akritiko/users/clhermansen) + +Getting started with OpenSSL: Cryptography basics +====== +Need a primer on cryptography basics, especially regarding OpenSSL? Read +on. +![A lock on the side of a building][1] + +This article is the first of two on cryptography basics using [OpenSSL][2], a production-grade library and toolkit popular on Linux and other systems. (To install the most recent version of OpenSSL, see [here][3].) OpenSSL utilities are available at the command line, and programs can call functions from the OpenSSL libraries. The sample program for this article is in C, the source language for the OpenSSL libraries. + +The two articles in this series cover—collectively—cryptographic hashes, digital signatures, encryption and decryption, and digital certificates. You can find the code and command-line examples in a ZIP file from [my website][4]. + +Let’s start with a review of the SSL in the OpenSSL name. + +### A quick history + +[Secure Socket Layer (SSL)][5] is a cryptographic protocol that [Netscape][6] released in 1995. This protocol layer can sit atop HTTP, thereby providing the _S_ for _secure_ in HTTPS. The SSL protocol provides various security services, including two that are central in HTTPS: + + * Peer authentication (aka mutual challenge): Each side of a connection authenticates the identity of the other side. If Alice and Bob are to exchange messages over SSL, then each first authenticates the identity of the other. + * Confidentiality: A sender encrypts messages before sending these over a channel. The receiver then decrypts each received message. This process safeguards network conversations. Even if eavesdropper Eve intercepts an encrypted message from Alice to Bob (a _man-in-the-middle_ attack), Eve finds it computationally infeasible to decrypt this message. + + + +These two key SSL services, in turn, are tied to others that get less attention. For example, SSL supports message integrity, which assures that a received message is the same as the one sent. This feature is implemented with hash functions, which likewise come with the OpenSSL toolkit. + +SSL is versioned (e.g., SSLv2 and SSLv3), and in 1999 Transport Layer Security (TLS) emerged as a similar protocol based upon SSLv3. TLSv1 and SSLv3 are alike, but not enough so to work together. Nonetheless, it is common to refer to SSL/TLS as if they are one and the same protocol. For example, OpenSSL functions often have SSL in the name even when TLS rather than SSL is in play. Furthermore, calling OpenSSL command-line utilities begins with the term **openssl**. + +The documentation for OpenSSL is spotty beyond the **man** pages, which become unwieldy given how big the OpenSSL toolkit is. Command-line and code examples are one way to bring the main topics into focus together. Let’s start with a familiar example—accessing a web site with HTTPS—and use this example to pick apart the cryptographic pieces of interest. + +### An HTTPS client + +The **client** program shown here connects over HTTPS to Google: + + +``` +/* compilation: gcc -o client client.c -lssl -lcrypto */ + +#include <stdio.h> + +#include <stdlib.h> + +#include <openssl/bio.h> /* BasicInput/Output streams */ + +#include <openssl/err.h> /* errors */ + +#include <openssl/ssl.h> /* core library */ + +#define BuffSize 1024 + +void report_and_exit(const char* msg) { +  [perror][7](msg); +  ERR_print_errors_fp(stderr); +  [exit][8](-1); +} + +void init_ssl() { +  SSL_load_error_strings(); +  SSL_library_init(); +} + +void cleanup(SSL_CTX* ctx, BIO* bio) { +  SSL_CTX_free(ctx); +  BIO_free_all(bio); +} + +void secure_connect(const char* hostname) { +  char name[BuffSize]; +  char request[BuffSize]; +  char response[BuffSize]; + +  const SSL_METHOD* method = TLSv1_2_client_method(); +  if (NULL == method) report_and_exit("TLSv1_2_client_method..."); + +  SSL_CTX* ctx = SSL_CTX_new(method); +  if (NULL == ctx) report_and_exit("SSL_CTX_new..."); + +  BIO* bio = BIO_new_ssl_connect(ctx); +  if (NULL == bio) report_and_exit("BIO_new_ssl_connect..."); + +  SSL* ssl = NULL; + +  /* link bio channel, SSL session, and server endpoint */ + +  [sprintf][9](name, "%s:%s", hostname, "https"); +  BIO_get_ssl(bio, &ssl); /* session */ +  SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); /* robustness */ +  BIO_set_conn_hostname(bio, name); /* prepare to connect */ + +  /* try to connect */ +  if (BIO_do_connect(bio) <= 0) { +    cleanup(ctx, bio); +    report_and_exit("BIO_do_connect..."); +  } + +  /* verify truststore, check cert */ +  if (!SSL_CTX_load_verify_locations(ctx, +                                      "/etc/ssl/certs/ca-certificates.crt", /* truststore */ +                                      "/etc/ssl/certs/")) /* more truststore */ +    report_and_exit("SSL_CTX_load_verify_locations..."); + +  long verify_flag = SSL_get_verify_result(ssl); +  if (verify_flag != X509_V_OK) +    [fprintf][10](stderr, +            "##### Certificate verification error (%i) but continuing...\n", +            (int) verify_flag); + +  /* now fetch the homepage as sample data */ +  [sprintf][9](request, +          "GET / HTTP/1.1\x0D\x0AHost: %s\x0D\x0A\x43onnection: Close\x0D\x0A\x0D\x0A", +          hostname); +  BIO_puts(bio, request); + +  /* read HTTP response from server and print to stdout */ +  while (1) { +    [memset][11](response, '\0', sizeof(response)); +    int n = BIO_read(bio, response, BuffSize); +    if (n <= 0) break; /* 0 is end-of-stream, < 0 is an error */ +  [puts][12](response); +  } + +  cleanup(ctx, bio); +} + +int main() { +  init_ssl(); + +  const char* hostname = "www.google.com:443"; +  [fprintf][10](stderr, "Trying an HTTPS connection to %s...\n", hostname); +  secure_connect(hostname); + +return 0; +} +``` + +This program can be compiled and executed from the command line (note the lowercase L in **-lssl** and **-lcrypto**): + +**gcc** **-o** **client client.c -lssl** **-lcrypto** + +This program tries to open a secure connection to the web site [www.google.com][13]. As part of the TLS handshake with the Google web server, the **client** program receives one or more digital certificates, which the program tries (but, on my system, fails) to verify. Nonetheless, the **client** program goes on to fetch the Google homepage through the secure channel. This program depends on the security artifacts mentioned earlier, although only a digital certificate stands out in the code. The other artifacts remain behind the scenes and are clarified later in detail. + +Generally, a client program in C or C++ that opened an HTTP (non-secure) channel would use constructs such as a _file descriptor_ for a _network socket_, which is an endpoint in a connection between two processes (e.g., the client program and the Google web server). A file descriptor, in turn, is a non-negative integer value that identifies, within a program, any file-like construct that the program opens. Such a program also would use a structure to specify details about the web server’s address. + +None of these relatively low-level constructs occurs in the client program, as the OpenSSL library wraps the socket infrastructure and address specification in high-level security constructs. The result is a straightforward API. Here’s a first look at the security details in the example **client** program. + + * The program begins by loading the relevant OpenSSL libraries, with my function **init_ssl** making two calls into OpenSSL: + +**SSL_library_init(); SSL_load_error_strings();** + + * The next initialization step tries to get a security _context_, a framework of information required to establish and maintain a secure channel to the web server. **TLS 1.2** is used in the example, as shown in this call to an OpenSSL library function: + +**const SSL_METHOD* method = TLSv1_2_client_method(); /* TLS 1.2 */** + +If the call succeeds, then the **method** pointer is passed to the library function that creates the context of type **SSL_CTX**: + +**SSL_CTX*** **ctx** **= SSL_CTX_new(method);** + +The **client** program checks for errors on each of these critical library calls, and then the program terminates if either call fails. + + * Two other OpenSSL artifacts now come into play: a security session of type **SSL**, which manages the secure connection from start to finish; and a secured stream of type **BIO** (Basic Input/Output), which is used to communicate with the web server. The **BIO** stream is generated with this call: + +**BIO* bio = BIO_new_ssl_connect(ctx);** + +Note that the all-important context is the argument. The **BIO** type is the OpenSSL wrapper for the **FILE** type in C. This wrapper secures the input and output streams between the **client** program and Google's web server. + + * With the **SSL_CTX** and **BIO** in hand, the program then links these together in an **SSL** session. Three library calls do the work: + +**BIO_get_ssl(bio, &ssl); /* get a TLS session */** + +**SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); /* for robustness */** + +**BIO_set_conn_hostname(bio, name); /* prepare to connect to Google */** + +The secure connection itself is established through this call: + +**BIO_do_connect(bio);** + +If this last call does not succeed, the **client** program terminates; otherwise, the connection is ready to support a confidential conversation between the **client** program and the Google web server. + + + + +During the handshake with the web server, the **client** program receives one or more digital certificates that authenticate the server’s identity. However, the **client** program does not send a certificate of its own, which means that the authentication is one-way. (Web servers typically are configured _not_ to expect a client certificate.) Despite the failed verification of the web server’s certificate, the **client** program continues by fetching the Google homepage through the secure channel to the web server. + +Why does the attempt to verify a Google certificate fail? A typical OpenSSL installation has the directory **/etc/ssl/certs**, which includes the **ca-certificates.crt** file. The directory and the file together contain digital certificates that OpenSSL trusts out of the box and accordingly constitute a _truststore_. The truststore can be updated as needed, in particular, to include newly trusted certificates and to remove ones no longer trusted. + +The client program receives three certificates from the Google web server, but the OpenSSL truststore on my machine does not contain exact matches. As presently written, the **client** program does not pursue the matter by, for example, verifying the digital signature on a Google certificate (a signature that vouches for the certificate). If that signature were trusted, then the certificate containing it should be trusted as well. Nonetheless, the client program goes on to fetch and then to print Google’s homepage. The next section gets into more detail. + +### The hidden security pieces in the client program + +Let’s start with the visible security artifact in the client example—the digital certificate—and consider how other security artifacts relate to it. The dominant layout standard for a digital certificate is X509, and a production-grade certificate is issued by a certificate authority (CA) such as [Verisign][14]. + +A digital certificate contains various pieces of information (e.g., activation and expiration dates, and a domain name for the owner), including the issuer’s identity and _digital signature_, which is an encrypted _cryptographic hash_ value. A certificate also has an unencrypted hash value that serves as its identifying _fingerprint_. + +A hash value results from mapping an arbitrary number of bits to a fixed-length digest. What the bits represent (an accounting report, a novel, or maybe a digital movie) is irrelevant. For example, the Message Digest version 5 (MD5) hash algorithm maps input bits of whatever length to a 128-bit hash value, whereas the SHA1 (Secure Hash Algorithm version 1) algorithm maps input bits to a 160-bit value. Different input bits result in different—indeed, statistically unique—hash values. The next article goes into further detail and focuses on what makes a hash function _cryptographic_. + +Digital certificates differ in type (e.g., _root_, _intermediate_, and _end-entity_ certificates) and form a hierarchy that reflects these types. As the name suggests, a _root_ certificate sits atop the hierarchy, and the certificates under it inherit whatever trust the root certificate has. The OpenSSL libraries and most modern programming languages have an X509 type together with functions that deal with such certificates. The certificate from Google has an X509 format, and the **client** program checks whether this certificate is **X509_V_OK**. + +X509 certificates are based upon public-key infrastructure (PKI), which includes algorithms—RSA is the dominant one—for generating _key pairs_: a public key and its paired private key. A public key is an identity: [Amazon’s][15] public key identifies it, and my public key identifies me. A private key is meant to be kept secret by its owner. + +The keys in a pair have standard uses. A public key can be used to encrypt a message, and the private key from the same pair can then be used to decrypt the message. A private key also can be used to sign a document or other electronic artifact (e.g., a program or an email), and the public key from the pair can then be used to verify the signature. The following two examples fill in some details. + +In the first example, Alice distributes her public key to the world, including Bob. Bob then encrypts a message with Alice’s public key, sending the encrypted message to Alice. The message encrypted with Alice’s public key is decrypted with her private key, which (by assumption) she alone has, like so: + + +``` +             +------------------+ encrypted msg  +-------------------+ +Bob's msg--->|Alice's public key|--------------->|Alice's private key|---> Bob's msg +             +------------------+                +-------------------+ +``` + +Decrypting the message without Alice’s private key is possible in principle, but infeasible in practice given a sound cryptographic key-pair system such as RSA. + +Now, for the second example, consider signing a document to certify its authenticity. The signature algorithm uses a private key from a pair to process a cryptographic hash of the document to be signed: + + +``` +                    +-------------------+ +Hash of document--->|Alice's private key|--->Alice's digital signature of the document +                    +-------------------+ +``` + +Assume that Alice digitally signs a contract sent to Bob. Bob then can use Alice’s public key from the key pair to verify the signature: + + +``` +                                             +------------------+ +Alice's digital signature of the document--->|Alice's public key|--->verified or not +                                             +------------------+ +``` + +It is infeasible to forge Alice’s signature without Alice’s private key: hence, it is in Alice’s interest to keep her private key secret. + +None of these security pieces, except for digital certificates, is explicit in the **client** program. The next article fills in the details with examples that use the OpenSSL utilities and library functions. + +### OpenSSL from the command line + +In the meantime, let’s take a look at OpenSSL command-line utilities: in particular, a utility to inspect the certificates from a web server during the TLS handshake. Invoking the OpenSSL utilities begins with the **openssl** command and then adds a combination of arguments and flags to specify the desired operation. + +Consider this command: + +**openssl list-cipher-algorithms** + +The output is a list of associated algorithms that make up a _cipher suite_. Here’s the start of the list, with comments to clarify the acronyms: + + +``` +AES-128-CBC ## Advanced Encryption Standard, Cipher Block Chaining +AES-128-CBC-HMAC-SHA1 ## Hash-based Message Authentication Code with SHA1 hashes +AES-128-CBC-HMAC-SHA256 ## ditto, but SHA256 rather than SHA1 +... +``` + +The next command, using the argument **s_client**, opens a secure connection to **[www.google.com][13]** and prints screens full of information about this connection: + +**openssl s_client -connect [www.google.com:443][16] -showcerts** + +The port number 443 is the standard one used by web servers for receiving HTTPS rather than HTTP connections. (For HTTP, the standard port is 80.) The network address **[www.google.com:443][16]** also occurs in the **client** program's code. If the attempted connection succeeds, the three digital certificates from Google are displayed together with information about the secure session, the cipher suite in play, and related items. For example, here is a slice of output from near the start, which announces that a _certificate chain_ is forthcoming. The encoding for the certificates is base64: + + +``` +Certificate chain + 0 s:/C=US/ST=California/L=Mountain View/O=Google LLC/CN=www.google.com + i:/C=US/O=Google Trust Services/CN=Google Internet Authority G3 +\-----BEGIN CERTIFICATE----- +MIIEijCCA3KgAwIBAgIQdCea9tmy/T6rK/dDD1isujANBgkqhkiG9w0BAQsFADBU +MQswCQYDVQQGEwJVUzEeMBwGA1UEChMVR29vZ2xlIFRydXN0IFNlcnZpY2VzMSUw +... +``` + +A major web site such as Google usually sends multiple certificates for authentication. + +The output ends with summary information about the TLS session, including specifics on the cipher suite: + + +``` +SSL-Session: +    Protocol : TLSv1.2 +    Cipher : ECDHE-RSA-AES128-GCM-SHA256 +    Session-ID: A2BBF0E4991E6BBBC318774EEE37CFCB23095CC7640FFC752448D07C7F438573 +... +``` + +The protocol **TLS 1.2** is used in the **client** program, and the **Session-ID** uniquely identifies the connection between the **openssl** utility and the Google web server. The **Cipher** entry can be parsed as follows: + + * **ECDHE** (Elliptic Curve Diffie Hellman Ephemeral) is an effective and efficient algorithm for managing the TLS handshake. In particular, ECDHE solves the _key-distribution problem_ by ensuring that both parties in a connection (e.g., the client program and the Google web server) use the same encryption/decryption key, which is known as the _session key_. The follow-up article digs into the details. + + * **RSA** (Rivest Shamir Adleman) is the dominant public-key cryptosystem and named after the three academics who first described the system in the late 1970s. The key-pairs in play are generated with the RSA algorithm. + + * **AES128** (Advanced Encryption Standard) is a _block cipher_ that encrypts and decrypts blocks of bits. (The alternative is a _stream cipher_, which encrypts and decrypts bits one at a time.) The cipher is _symmetric_ in that the same key is used to encrypt and to decrypt, which raises the key-distribution problem in the first place. AES supports key sizes of 128 (used here), 192, and 256 bits: the larger the key, the better the protection. + +Key sizes for symmetric cryptosystems such as AES are, in general, smaller than those for asymmetric (key-pair based) systems such as RSA. For example, a 1024-bit RSA key is relatively small, whereas a 256-bit key is currently the largest for AES. + + * **GCM** (Galois Counter Mode) handles the repeated application of a cipher (in this case, AES128) during a secured conversation. AES128 blocks are only 128-bits in size, and a secure conversation is likely to consist of multiple AES128 blocks from one side to the other. GCM is efficient and commonly paired with AES128. + + * **SHA256** (Secure Hash Algorithm 256 bits) is the cryptographic hash algorithm in play. The hash values produced are 256 bits in size, although even larger values are possible with SHA. + + + + +Cipher suites are in continual development. Not so long ago, for example, Google used the RC4 stream cipher (Ron’s Cipher version 4 after Ron Rivest from RSA). RC4 now has known vulnerabilities, which presumably accounts, at least in part, for Google’s switch to AES128. + +### Wrapping up + +This first look at OpenSSL, through a secure C web client and various command-line examples, has brought to the fore a handful of topics in need of more clarification. [The next article gets into the details][17], starting with cryptographic hashes and ending with a fuller discussion of how digital certificates address the key distribution challenge. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/cryptography-basics-openssl-part-1 + +作者:[Marty Kalin][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mkalindepauledu/users/akritiko/users/clhermansen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_3reasons.png?itok=k6F3-BqA (A lock on the side of a building) +[2]: https://www.openssl.org/ +[3]: https://www.howtoforge.com/tutorial/how-to-install-openssl-from-source-on-linux/ +[4]: http://condor.depaul.edu/mkalin +[5]: https://en.wikipedia.org/wiki/Transport_Layer_Security +[6]: https://en.wikipedia.org/wiki/Netscape +[7]: http://www.opengroup.org/onlinepubs/009695399/functions/perror.html +[8]: http://www.opengroup.org/onlinepubs/009695399/functions/exit.html +[9]: http://www.opengroup.org/onlinepubs/009695399/functions/sprintf.html +[10]: http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html +[11]: http://www.opengroup.org/onlinepubs/009695399/functions/memset.html +[12]: http://www.opengroup.org/onlinepubs/009695399/functions/puts.html +[13]: http://www.google.com +[14]: https://www.verisign.com +[15]: https://www.amazon.com +[16]: http://www.google.com:443 +[17]: https://opensource.com/article/19/6/cryptography-basics-openssl-part-2 diff --git a/sources/tech/20190620 How to SSH into a running container.md b/sources/tech/20190620 How to SSH into a running container.md new file mode 100644 index 0000000000..f0b4cdafc2 --- /dev/null +++ b/sources/tech/20190620 How to SSH into a running container.md @@ -0,0 +1,185 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to SSH into a running container) +[#]: via: (https://opensource.com/article/19/6/how-ssh-running-container) +[#]: author: (Seth Kenlon https://opensource.com/users/seth/users/bcotton) + +How to SSH into a running container +====== +SSH is probably not the best way to run commands in a container; try +this instead. +![cubes coming together to create a larger cube][1] + +Containers have shifted the way we think about virtualization. You may remember the days (or you may still be living them) when a virtual machine was the full stack, from virtualized BIOS, operating system, and kernel up to each virtualized network interface controller (NIC). You logged into the virtual box just as you would your own workstation. It was a very direct and simple analogy. + +And then containers came along, [starting with LXC][2] and culminating in the Open Container Initiative ([OCI][3]), and that's when things got complicated. + +### Idempotency + +In the world of containers, the "virtual machine" is only mostly virtual. Everything that doesn't need to be virtualized is borrowed from the host machine. Furthermore, the container itself is usually meant to be ephemeral and idempotent, so it stores no persistent data, and its state is defined by configuration files on the host machine. + +If you're used to the old ways of virtual machines, then you naturally expect to log into a virtual machine in order to interact with it. But containers are ephemeral, so anything you do in a container is forgotten, by design, should the container need to be restarted or respawned. + +The commands controlling your container infrastructure (such as **oc, crictl**, **lxc**, and **docker**) provide an interface to run important commands to restart services, view logs, confirm the existence and permissions modes of an important file, and so on. You should use the tools provided by your container infrastructure to interact with your application, or else edit configuration files and relaunch. That's what containers are designed to do. + +For instance, the open source forum software [Discourse][4] is officially distributed as a container image. The Discourse software is _stateless_, so its installation is self-contained within **/var/discourse**. As long as you have a backup of **/var/discourse**, you can always restore the forum by relaunching the container. The container holds no persistent data, and its configuration file is **/var/discourse/containers/app.yml**. + +Were you to log into the container and edit any of the files it contains, all changes would be lost if the container had to be restarted. + +LXC containers you're building from scratch are more flexible, with configuration files (in a location defined by you) passed to the container when you launch it. + +A build system like [Jenkins][5] usually has a default configuration file, such as **jenkins.yaml**, providing instructions for a base container image that exists only to build and run tests on source code. After the builds are done, the container goes away. + +Now that you know you don't need SSH to interact with your containers, here's an overview of what tools are available (and some notes about using SSH in spite of all the fancy tools that make it redundant). + +### OpenShift web console + +[OpenShift 4][6] offers an open source toolchain for container creation and maintenance, including an interactive web console. + +When you log into your web console, navigate to your project overview and click the **Applications** tab for a list of pods. Select a (running) pod to open the application's **Details** panel. + +![Pod details in OpenShift][7] + +Click the **Terminal** tab at the top of the **Details** panel to open an interactive shell in your container. + +![A terminal in a running container][8] + +If you prefer a browser-based experience for Kubernetes management, you can learn more through interactive lessons available at [learn.openshift.com][9]. + +### OpenShift oc + +If you prefer a command-line interface experience, you can use the **oc** command to interact with containers from the terminal. + +First, get a list of running pods (or refer to the web console for a list of active pods). To get that list, enter: + + +``` +`$ oc get pods` +``` + +You can view the logs of a resource (a pod, build, or container). By default, **oc logs** returns the logs from the first container in the pod you specify. To select a single container, add the **\--container** option: + + +``` +`$ oc logs --follow=true example-1-e1337 --container app` +``` + +You can also view logs from all containers in a pod with: + + +``` +`$ oc logs --follow=true example-1-e1337 --all-containers` +``` + +#### Execute commands + +You can execute commands remotely with: + + +``` +$ oc exec example-1-e1337 --container app hostname +        example.local +``` + +This is similar to running SSH non-interactively: you get to run the command you want to run without an interactive shell taking over your environment. + +#### Remote shell + +You can attach to a running container. This still does _not_ open a shell in the container, but it does run commands directly. For example: + + +``` +`$ oc attach example-1-e1337 --container app` +``` + +If you need a true interactive shell in a container, you can open a remote shell with the **oc rsh** command as long as the container includes a shell. By default, **oc rsh** launches **/bin/sh**: + + +``` +`$ oc rsh example-1-e1337 --container app` +``` + +### Kubernetes + +If you're using Kubernetes directly, you can use the **kubetcl** **exec** command to run a Bash shell in your pod. + +First, confirm that your pod is running: + + +``` +`$ kubectl get pods` +``` + +As long as the pod containing your application is listed, you can use the **exec** command to launch a shell in the container. Using the name **example-pod** as the pod name, enter: + + +``` +$ kubectl exec --stdin=false --tty=false +  example-pod -- /bin/bash +[root@example.local][10]:/# ls +bin   core etc   lib    root  srv +boot  dev  home  lib64  sbin  tmp  var +``` + +### Docker + +The **docker** command is similar to **kubectl**. With the **dockerd** daemon running, get the name of the running container (you may have to use **sudo** to escalate privileges if you're not in the appropriate group): + + +``` +$ docker ps +CONTAINER ID    IMAGE       COMMAND      NAME +678ac5cca78e    centos     "/bin/bash"   example-centos +``` + +Using the container name, you can run a command in the container: + + +``` +$ docker exec example/centos cat /etc/os-release +CentOS Linux release 7.6 +NAME="CentOS Linux" +VERSION="7" +ID="centos" +ID_LIKE="rhel fedora" +VERSION_ID="7" +[...] +``` + +Or you can launch a Bash shell for an interactive session: + + +``` +`$ docker exec -it example-centos /bin/bash` +``` + +### Containers and appliances + +The important thing to remember when dealing with the cloud is that containers are essentially runtimes rather than virtual machines. While they have much in common with a Linux system (because they _are_ a Linux system!), they rarely translate directly to the commands and workflow you may have developed on your Linux workstation. However, like appliances, containers have an interface to help you develop, maintain, and monitor them, so get familiar with the front-end commands and services until you're happily interacting with them just as easily as ****you interact with virtual (or bare-metal) machines. Soon, you'll wonder why everything isn't developed to be ephemeral. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/how-ssh-running-container + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth/users/bcotton +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cube_innovation_process_block_container.png?itok=vkPYmSRQ (cubes coming together to create a larger cube) +[2]: https://opensource.com/article/18/11/behind-scenes-linux-containers +[3]: https://www.opencontainers.org/ +[4]: http://discourse.org +[5]: http://jenkins.io +[6]: https://www.openshift.com/learn/get-started +[7]: https://opensource.com/sites/default/files/uploads/openshift-pod-access.jpg (Pod details in OpenShift) +[8]: https://opensource.com/sites/default/files/uploads/openshift-pod-terminal.jpg (A terminal in a running container) +[9]: http://learn.openshift.com +[10]: mailto:root@example.local diff --git a/sources/tech/20190620 How to use OpenSSL- Hashes, digital signatures, and more.md b/sources/tech/20190620 How to use OpenSSL- Hashes, digital signatures, and more.md new file mode 100644 index 0000000000..724c97bc01 --- /dev/null +++ b/sources/tech/20190620 How to use OpenSSL- Hashes, digital signatures, and more.md @@ -0,0 +1,337 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to use OpenSSL: Hashes, digital signatures, and more) +[#]: via: (https://opensource.com/article/19/6/cryptography-basics-openssl-part-2) +[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu) + +How to use OpenSSL: Hashes, digital signatures, and more +====== +Dig deeper into the details of cryptography with OpenSSL: Hashes, +digital signatures, digital certificates, and more +![A person working.][1] + +The [first article in this series][2] introduced hashes, encryption/decryption, digital signatures, and digital certificates through the OpenSSL libraries and command-line utilities. This second article drills down into the details. Let’s begin with hashes, which are ubiquitous in computing, and consider what makes a hash function _cryptographic_. + +### Cryptographic hashes + +The download page for the OpenSSL source code () contains a table with recent versions. Each version comes with two hash values: 160-bit SHA1 and 256-bit SHA256. These values can be used to verify that the downloaded file matches the original in the repository: The downloader recomputes the hash values locally on the downloaded file and then compares the results against the originals. Modern systems have utilities for computing such hashes. Linux, for instance, has **md5sum** and **sha256sum**. OpenSSL itself provides similar command-line utilities. + +Hashes are used in many areas of computing. For example, the Bitcoin blockchain uses SHA256 hash values as block identifiers. To mine a Bitcoin is to generate a SHA256 hash value that falls below a specified threshold, which means a hash value with at least N leading zeroes. (The value of N can go up or down depending on how productive the mining is at a particular time.) As a point of interest, today’s miners are hardware clusters designed for generating SHA256 hashes in parallel. During a peak time in 2018, Bitcoin miners worldwide generated about 75 million terahashes per second—yet another incomprehensible number. + +Network protocols use hash values as well—often under the name **checksum**—to support message integrity; that is, to assure that a received message is the same as the one sent. The message sender computes the message’s checksum and sends the results along with the message. The receiver recomputes the checksum when the message arrives. If the sent and the recomputed checksum do not match, then something happened to the message in transit, or to the sent checksum, or to both. In this case, the message and its checksum should be sent again, or at least an error condition should be raised. (Low-level network protocols such as UDP do not bother with checksums.) + +Other examples of hashes are familiar. Consider a website that requires users to authenticate with a password, which the user enters in their browser. Their password is then sent, encrypted, from the browser to the server via an HTTPS connection to the server. Once the password arrives at the server, it's decrypted for a database table lookup. + +What should be stored in this lookup table? Storing the passwords themselves is risky. It’s far less risky is to store a hash generated from a password, perhaps with some _salt_ (extra bits) added to taste before the hash value is computed. Your password may be sent to the web server, but the site can assure you that the password is not stored there. + +Hash values also occur in various areas of security. For example, hash-based message authentication code ([HMAC][3]) uses a hash value and a secret cryptographic key to authenticate a message sent over a network. HMAC codes, which are lightweight and easy to use in programs, are popular in web services. An X509 digital certificate includes a hash value known as the _fingerprint_, which can facilitate certificate verification. An in-memory truststore could be implemented as a lookup table keyed on such fingerprints—as a _hash map_, which supports constant-time lookups. The fingerprint from an incoming certificate can be compared against the truststore keys for a match. + +What special property should a _cryptographic hash function_ have? It should be _one-way_, which means very difficult to invert. A cryptographic hash function should be relatively straightforward to compute, but computing its inverse—the function that maps the hash value back to the input bitstring—should be computationally intractable. Here is a depiction, with **chf** as a cryptographic hash function and my password **foobar** as the sample input: + + +``` +        +---+ +foobar—>|chf|—>hash value ## straightforward +        +--–+ +``` + +By contrast, the inverse operation is infeasible: + + +``` +            +-----------+ +hash value—>|chf inverse|—>foobar ## intractable +            +-----------+ +``` + +Recall, for example, the SHA256 hash function. For an input bitstring of any length N > 0, this function generates a fixed-length hash value of 256 bits; hence, this hash value does not reveal even the input bitstring’s length N, let alone the value of each bit in the string. By the way, SHA256 is not susceptible to a [_length extension attack_][4]. The only effective way to reverse engineer a computed SHA256 hash value back to the input bitstring is through a brute-force search, which means trying every possible input bitstring until a match with the target hash value is found. Such a search is infeasible on a sound cryptographic hash function such as SHA256. + +Now, a final review point is in order. Cryptographic hash values are statistically rather than unconditionally unique, which means that it is unlikely but not impossible for two different input bitstrings to yield the same hash value—a _collision_. The [_birthday problem_][5] offers a nicely counter-intuitive example of collisions. There is extensive research on various hash algorithms’ _collision resistance_. For example, MD5 (128-bit hash values) has a breakdown in collision resistance after roughly 221 hashes. For SHA1 (160-bit hash values), the breakdown starts at about 261 hashes. + +A good estimate of the breakdown in collision resistance for SHA256 is not yet in hand. This fact is not surprising. SHA256 has a range of 2256 distinct hash values, a number whose decimal representation has a whopping 78 digits! So, can collisions occur with SHA256 hashing? Of course, but they are extremely unlikely. + +In the command-line examples that follow, two input files are used as bitstring sources: **hashIn1.txt** and **hashIn2.txt**. The first file contains **abc** and the second contains **1a2b3c**. + +These files contain text for readability, but binary files could be used instead. + +Using the Linux **sha256sum** utility on these two files at the command line—with the percent sign (**%**) as the prompt—produces the following hash values (in hex): + + +``` +% sha256sum hashIn1.txt +9e83e05bbf9b5db17ac0deec3b7ce6cba983f6dc50531c7a919f28d5fb3696c3 hashIn1.txt + +% sha256sum hashIn2.txt +3eaac518777682bf4e8840dd012c0b104c2e16009083877675f00e995906ed13 hashIn2.txt +``` + +The OpenSSL hashing counterparts yield the same results, as expected: + + +``` +% openssl dgst -sha256 hashIn1.txt +SHA256(hashIn1.txt)= 9e83e05bbf9b5db17ac0deec3b7ce6cba983f6dc50531c7a919f28d5fb3696c3 + +% openssl dgst -sha256 hashIn2.txt +SHA256(hashIn2.txt)= 3eaac518777682bf4e8840dd012c0b104c2e16009083877675f00e995906ed13 +``` + +This examination of cryptographic hash functions sets up a closer look at digital signatures and their relationship to key pairs. + +### Digital signatures + +As the name suggests, a digital signature can be attached to a document or some other electronic artifact (e.g., a program) to vouch for its authenticity. Such a signature is thus analogous to a hand-written signature on a paper document. To verify the digital signature is to confirm two things. First, that the vouched-for artifact has not changed since the signature was attached because it is based, in part, on a cryptographic _hash_ of the document. Second, that the signature belongs to the person (e.g., Alice) who alone has access to the private key in a pair. By the way, digitally signing code (source or compiled) has become a common practice among programmers. + +Let’s walk through how a digital signature is created. As mentioned before, there is no digital signature without a public and private key pair. When using OpenSSL to create these keys, there are two separate commands: one to create a private key, and another to extract the matching public key from the private one. These key pairs are encoded in base64, and their sizes can be specified during this process. + +The private key consists of numeric values, two of which (a _modulus_ and an _exponent_) make up the public key. Although the private key file contains the public key, the extracted public key does _not_ reveal the value of the corresponding private key. + +The resulting file with the private key thus contains the full key pair. Extracting the public key into its own file is practical because the two keys have distinct uses, but this extraction also minimizes the danger that the private key might be publicized by accident. + +Next, the pair’s private key is used to process a hash value for the target artifact (e.g., an email), thereby creating the signature. On the other end, the receiver’s system uses the pair’s public key to verify the signature attached to the artifact. + +Now for an example. To begin, generate a 2048-bit RSA key pair with OpenSSL: + +**openssl genpkey -out privkey.pem -algorithm rsa 2048** + +We can drop the **-algorithm rsa** flag in this example because **genpkey** defaults to the type RSA. The file’s name (**privkey.pem**) is arbitrary, but the Privacy Enhanced Mail (PEM) extension **pem** is customary for the default PEM format. (OpenSSL has commands to convert among formats if needed.) If a larger key size (e.g., 4096) is in order, then the last argument of **2048** could be changed to **4096**. These sizes are always powers of two. + +Here’s a slice of the resulting **privkey.pem** file, which is in base64: + + +``` +\-----BEGIN PRIVATE KEY----- +MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBANnlAh4jSKgcNj/Z +JF4J4WdhkljP2R+TXVGuKVRtPkGAiLWE4BDbgsyKVLfs2EdjKL1U+/qtfhYsqhkK +… +\-----END PRIVATE KEY----- +``` + +The next command then extracts the pair’s public key from the private one: + +**openssl rsa -in privkey.pem -outform PEM -pubout -out pubkey.pem** + +The resulting **pubkey.pem** file is small enough to show here in full: + + +``` +\-----BEGIN PUBLIC KEY----- +MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDZ5QIeI0ioHDY/2SReCeFnYZJY +z9kfk11RrilUbT5BgIi1hOAQ24LMilS37NhHYyi9VPv6rX4WLKoZCmkeYaWk/TR5 +4nbH1E/AkniwRoXpeh5VncwWMuMsL5qPWGY8fuuTE27GhwqBiKQGBOmU+MYlZonO +O0xnAKpAvysMy7G7qQIDAQAB +\-----END PUBLIC KEY----- +``` + +Now, with the key pair at hand, the digital signing is easy—in this case with the source file **client.c** as the artifact to be signed: + +**openssl dgst -sha256 -sign privkey.pem -out sign.sha256 client.c** + +The digest for the **client.c** source file is SHA256, and the private key resides in the **privkey.pem** file created earlier. The resulting binary signature file is **sign.sha256**, an arbitrary name. To get a readable (if base64) version of this file, the follow-up command is: + +**openssl enc -base64 -in sign.sha256 -out sign.sha256.base64** + +The file **sign.sha256.base64** now contains: + + +``` +h+e+3UPx++KKSlWKIk34fQ1g91XKHOGFRmjc0ZHPEyyjP6/lJ05SfjpAJxAPm075 +VNfFwysvqRGmL0jkp/TTdwnDTwt756Ej4X3OwAVeYM7i5DCcjVsQf5+h7JycHKlM +o/Jd3kUIWUkZ8+Lk0ZwzNzhKJu6LM5KWtL+MhJ2DpVc= +``` + +Or, the executable file **client** could be signed instead, and the resulting base64-encoded signature would differ as expected: + + +``` +VMVImPgVLKHxVBapJ8DgLNJUKb98GbXgehRPD8o0ImADhLqlEKVy0HKRm/51m9IX +xRAN7DoL4Q3uuVmWWi749Vampong/uT5qjgVNTnRt9jON112fzchgEoMb8CHNsCT +XIMdyaPtnJZdLALw6rwMM55MoLamSc6M/MV1OrJnk/g= +``` + +The final step in this process is to verify the digital signature with the public key. The hash used to sign the artifact (in this case, the executable **client** program) should be recomputed as an essential step in the verification since the verification process should indicate whether the artifact has changed since being signed. + +There are two OpenSSL commands used for this purpose. The first decodes the base64 signature: + +**openssl enc -base64 -d -in sign.sha256.base64 -out sign.sha256** + +The second verifies the signature: + +**openssl dgst -sha256 -verify pubkey.pem -signature sign.sha256 client** + +The output from this second command is, as it should be: + + +``` +`Verified OK` +``` + +To understand what happens when verification fails, a short but useful exercise is to replace the executable **client** file in the last OpenSSL command with the source file **client.c** and then try to verify. Another exercise is to change the **client** program, however slightly, and try again. + +### Digital certificates + +A digital certificate brings together the pieces analyzed so far: hash values, key pairs, digital signatures, and encryption/decryption. The first step toward a production-grade certificate is to create a certificate signing request (CSR), which is then sent to a certificate authority (CA). To do this for the example with OpenSSL, run: + +**openssl req -out myserver.csr -new -newkey rsa:4096 -nodes -keyout myserverkey.pem** + +This example generates a CSR document and stores the document in the file **myserver.csr** (base64 text). The purpose here is this: the CSR document requests that the CA vouch for the identity associated with the specified domain name—the common name (CN) in CA-speak. + +A new key pair also is generated by this command, although an existing pair could be used. Note that the use of **server** in names such as **myserver.csr** and **myserverkey.pem** hints at the typical use of digital certificates: as vouchers for the identity of a web server associated with a domain such as [www.google.com][6]. + +The same command, however, creates a CSR regardless of how the digital certificate might be used. It also starts an interactive question/answer session that prompts for relevant information about the domain name to link with the requester’s digital certificate. This interactive session can be short-circuited by providing the essentials as part of the command, with backslashes as continuations across line breaks. The **-subj** flag introduces the required information: + + +``` +% openssl req -new +-newkey rsa:2048 -nodes -keyout privkeyDC.pem +-out myserver.csr +-subj "/C=US/ST=Illinois/L=Chicago/O=Faulty Consulting/OU=IT/CN=myserver.com" +``` + +The resulting CSR document can be inspected and verified before being sent to a CA. This process creates the digital certificate with the desired format (e.g., X509), signature, validity dates, and so on: + +**openssl req -text -in myserver.csr -noout -verify** + +Here’s a slice of the output: + + +``` +verify OK +Certificate Request: +Data: +Version: 0 (0x0) +Subject: C=US, ST=Illinois, L=Chicago, O=Faulty Consulting, OU=IT, CN=myserver.com +Subject Public Key Info: +Public Key Algorithm: rsaEncryption +Public-Key: (2048 bit) +Modulus: +00:ba:36:fb:57:17:65:bc:40:30:96:1b:6e🇩🇪73: +… +Exponent: 65537 (0x10001) +Attributes: +a0:00 +Signature Algorithm: sha256WithRSAEncryption +… +``` + +### A self-signed certificate + +During the development of an HTTPS web site, it is convenient to have a digital certificate on hand without going through the CA process. A self-signed certificate fills the bill during the HTTPS handshake’s authentication phase, although any modern browser warns that such a certificate is worthless. Continuing the example, the OpenSSL command for a self-signed certificate—valid for a year and with an RSA public key—is: + +**openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:4096 -keyout myserver.pem -out myserver.crt** + +The OpenSSL command below presents a readable version of the generated certificate: + +**openssl x509 -in myserver.crt -text -noout** + +Here’s part of the output for the self-signed certificate: + + +``` +Certificate: +Data: +Version: 3 (0x2) +Serial Number: 13951598013130016090 (0xc19e087965a9055a) +Signature Algorithm: sha256WithRSAEncryption +Issuer: C=US, ST=Illinois, L=Chicago, O=Faulty Consulting, OU=IT, CN=myserver.com +Validity +Not Before: Apr 11 17:22:18 2019 GMT +Not After : Apr 10 17:22:18 2020 GMT +Subject: C=US, ST=Illinois, L=Chicago, O=Faulty Consulting, OU=IT, CN=myserver.com +Subject Public Key Info: +Public Key Algorithm: rsaEncryption +Public-Key: (4096 bit) +Modulus: +00:ba:36:fb:57:17:65:bc:40:30:96:1b:6e🇩🇪73: +… +Exponent: 65537 (0x10001) +X509v3 extensions: +X509v3 Subject Key Identifier: +3A:32:EF:3D:EB:DF:65:E5:A8:96:D7:D7:16:2C:1B:29:AF:46:C4:91 +X509v3 Authority Key Identifier: +keyid:3A:32:EF:3D:EB:DF:65:E5:A8:96:D7:D7:16:2C:1B:29:AF:46:C4:91 + +        X509v3 Basic Constraints: +            CA:TRUE +Signature Algorithm: sha256WithRSAEncryption +     3a:eb:8d:09:53:3b:5c:2e:48:ed:14:ce:f9:20:01:4e:90:c9: +     ... +``` + +As mentioned earlier, an RSA private key contains values from which the public key is generated. However, a given public key does _not_ give away the matching private key. For an introduction to the underlying mathematics, see . + +There is an important correspondence between a digital certificate and the key pair used to generate the certificate, even if the certificate is only self-signed: + + * The digital certificate contains the _exponent_ and _modulus_ values that make up the public key. These values are part of the key pair in the originally-generated PEM file, in this case, the file **myserver.pem**. + * The exponent is almost always 65,537 (as in this case) and so can be ignored. + * The modulus from the key pair should match the modulus from the digital certificate. + + + +The modulus is a large value and, for readability, can be hashed. Here are two OpenSSL commands that check for the same modulus, thereby confirming that the digital certificate is based upon the key pair in the PEM file: + + +``` +% openssl x509 -noout -modulus -in myserver.crt | openssl sha1 ## modulus from CRT +(stdin)= 364d21d5e53a59d482395b1885aa2c3a5d2e3769 + +% openssl rsa -noout -modulus -in myserver.pem | openssl sha1 ## modulus from PEM +(stdin)= 364d21d5e53a59d482395b1885aa2c3a5d2e3769 +``` + +The resulting hash values match, thereby confirming that the digital certificate is based upon the specified key pair. + +### Back to the key distribution problem + +Let’s return to an issue raised at the end of Part 1: the TLS handshake between the **client** program and the Google web server. There are various handshake protocols, and even the Diffie-Hellman version at work in the **client** example offers wiggle room. Nonetheless, the **client** example follows a common pattern. + +To start, during the TLS handshake, the **client** program and the web server agree on a cipher suite, which consists of the algorithms to use. In this case, the suite is **ECDHE-RSA-AES128-GCM-SHA256**. + +The two elements of interest now are the RSA key-pair algorithm and the AES128 block cipher used for encrypting and decrypting messages if the handshake succeeds. Regarding encryption/decryption, this process comes in two flavors: symmetric and asymmetric. In the symmetric flavor, the _same_ key is used to encrypt and decrypt, which raises the _key distribution problem_ in the first place: How is the key to be distributed securely to both parties? In the asymmetric flavor, one key is used to encrypt (in this case, the RSA public key) but a different key is used to decrypt (in this case, the RSA private key from the same pair). + +The **client** program has the Google web server’s public key from an authenticating certificate, and the web server has the private key from the same pair. Accordingly, the **client** program can send an encrypted message to the web server, which alone can readily decrypt this message. + +In the TLS situation, the symmetric approach has two significant advantages: + + * In the interaction between the **client** program and the Google web server, the authentication is one-way. The Google web server sends three certificates to the **client** program, but the **client** program does not send a certificate to the web server; hence, the web server has no public key from the client and can’t encrypt messages to the client. + * Symmetric encryption/decryption with AES128 is nearly a _thousand times faster_ than the asymmetric alternative using RSA keys. + + + +The TLS handshake combines the two flavors of encryption/decryption in a clever way. During the handshake, the **client** program generates random bits known as the pre-master secret (PMS). Then the **client** program encrypts the PMS with the server’s public key and sends the encrypted PMS to the server, which in turn decrypts the PMS message with its private key from the RSA pair: + + +``` +              +-------------------+ encrypted PMS  +--------------------+ +client PMS--->|server’s public key|--------------->|server’s private key|--->server PMS +              +-------------------+                +--------------------+ +``` + +At the end of this process, the **client** program and the Google web server now have the same PMS bits. Each side uses these bits to generate a _master secret_ and, in short order, a symmetric encryption/decryption key known as the _session key_. There are now two distinct but identical session keys, one on each side of the connection. In the **client** example, the session key is of the AES128 variety. Once generated on both the **client** program’s and Google web server’s sides, the session key on each side keeps the conversation between the two sides confidential. A handshake protocol such as Diffie-Hellman allows the entire PMS process to be repeated if either side (e.g., the **client** program) or the other (in this case, the Google web server) calls for a restart of the handshake. + +### Wrapping up + +The OpenSSL operations illustrated at the command line are available, too, through the API for the underlying libraries. These two articles have emphasized the utilities to keep the examples short and to focus on the cryptographic topics. If you have an interest in security issues, OpenSSL is a fine place to start—and to stay. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/cryptography-basics-openssl-part-2 + +作者:[Marty Kalin][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mkalindepauledu +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_os_rh2x.png?itok=jbRfXinl (A person working.) +[2]: https://opensource.com/article/19/6/cryptography-basics-openssl-part-1 +[3]: https://en.wikipedia.org/wiki/HMAC +[4]: https://en.wikipedia.org/wiki/Length_extension_attack +[5]: https://en.wikipedia.org/wiki/Birthday_problem +[6]: http://www.google.com diff --git a/sources/tech/20190620 You can-t buy DevOps.md b/sources/tech/20190620 You can-t buy DevOps.md new file mode 100644 index 0000000000..36717058a0 --- /dev/null +++ b/sources/tech/20190620 You can-t buy DevOps.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (You can't buy DevOps) +[#]: via: (https://opensource.com/article/19/6/you-cant-buy-devops) +[#]: author: (Julie Gunderson https://opensource.com/users/juliegund) + +You can't buy DevOps +====== +But plenty of people are happy to sell it to you. Here's why it's not +for sale. +![Coffee shop photo][1] + +![DevOps price tag graphic][2] + +Making a move to [DevOps][3] can be a daunting undertaking, with many organizations not knowing the right place to start. I recently had some fun taking a few "DevOps assessments" to see what solutions they offered. I varied my answers—from an organization that fully embraces DevOps to one at the beginning of the journey. Some of the assessments provided real value, linking me back to articles on culture and methodologies, while others merely offered me a tool promising to bring all my DevOps dreams into reality. + +Tools are absolutely essential to the DevOps journey; for instance, tools can continuously deliver, automate, or monitor your environment. However, **DevOps is not a product**, and tools alone will not enable the processes necessary to realize the full value of DevOps. People are what matter most; you can't do DevOps without building the people, mindset, and culture first. + +### Don't 'win' at DevOps; become a champion + +As a DevOps advocate at PagerDuty, I am proud to be a part of an organization with a strong commitment to DevOps methodologies, well beyond just "checking the boxes" of tool adoption. + +I recently had a conversation with PagerDuty CEO Jennifer Tejada about being a winner versus a champion. She talked about how winning is fantastic—you get a trophy, a title, or maybe even a few million dollars (if it's the lottery). However, in the big picture, winning is all about short-term goals, while being a champion means focusing on long-term successes or outcomes. This got me thinking about how to apply this principle to organizations embracing DevOps. + +One of my favorite examples of DevOps tooling is XebiaLabs' [Periodic Table of DevOps Tools][4]: + +[![Periodic Table of DevOps][5]][4] + +(Click table for interactive version.) + +The table shows that numerous tools fit into DevOps. However, too many times, I have heard about organizations "transforming to DevOps" by purchasing tools. While tooling is an essential part of the DevOps journey, a tool alone does not create a DevOps environment. You have to consider all the factors that make a DevOps team function well: collaboration, breaking down silos, defined processes, ownership, and automation, along with continuous improvement/continuous delivery. + +Deciding to purchase tooling is a great step in the right direction; what is more important is to define the "why" or the end goal behind decisions first. Which brings us back to the mentality of a champion; look at Olympic gold medalist Michael Phelps, for example. Phelps is the most decorated Olympian of all time and holds 39 world records. To achieve these accomplishments, Phelps didn't stop at one, two, or even 20 wins; he aimed to be a champion. This was all done through commitment, practice, and focusing on the desired end state. + +### DevOps defined + +There are hundreds of definitions for DevOps, but almost everyone can agree on the core tenet outlined in the [State of DevOps Report][6]: + +> "DevOps is a set of principles aimed at building culture and processes to help teams work more efficiently and deliver better software faster." + +You can't change culture and processes with a credit card. Tooling can enable an organization to collaborate better or automate or continuously deliver; however, without the right mindset and adoption, a tool's full capability may not be achievable. + +For example, one of my former colleagues heard how amazing Slack is for teams transforming to DevOps by opening up channels for collaboration. He convinced his manager that Slack would solve all of their communication woes. However, six months into the Slack adoption, most teams were still using Skype, including the manager. Slack ended up being more of a place to talk about brewing beer than a tool to bring the product to market faster. The issue was not Slack; it was the lack of buy-in from the team and organization and knowledge around the product's full functionality. + +Purchasing a tool can definitely be a win for a team, but purchasing a tool is not purchasing DevOps. Making tooling and best practices work for the team and achieving short- and long-term goals are where our conversation around being a champion comes up. This brings us back to the why, the overall and far-reaching goal for the team or organization. Once you identify the goal, how do you get buy-in from key stakeholders? After you achieve buy-in, how do you implement the solution? + +### Organizational change + +#### + +[![Change management comic by Randy Glasbergen][7]][8] + +Change is hard for many organizations and individuals; moreover, meaningful change does not happen overnight. It is important to understand how people and organizations process change. In the [Kotter 8-Step Process for Leading Change][9], it's about articulating the need for a change, creating urgency around the why, then starting small and finding and developing internal champions, _before_ trying to prove wins or, in this case, purchasing a tool. + +If people in an organization are not aware of a problem or that there's a better way of operating, it will be hard to get the buy-in necessary and motivate team members to adopt new ideas and take action. People may be perfectly content with the current state; perhaps the processes in place are adequate or, at a minimum, the current state is a known factor. However, for the overall team to function well and achieve its shared goal in a faster, more agile way, new mechanisms must be put into place first. + +![Kotter 8-Step Process for Leading Change][10] + +### How to be a DevOps champion + +Being a champion in the DevOps world means going beyond the win and delving deeper into the team/organizational structure and culture, thereby identifying outlying issues beyond tools, and then working with others to embrace the right change that leads to defined results. Go back to the beginning and define the end goal. Here are a few sample questions you can ask to get started: + + * What are your core values? + * Why are you trying to become a more agile company or team? + * What obstacles is your team or organization facing? + * What will the tool or process accomplish? + * How are people communicating and collaborating? + * Are there silos and why? + * How are you championing the customer? + * Are employees empowered? + + + +After defining the end state, find other like-minded individuals to be part of your champion team, and don't lose sight of what you are trying to accomplish. When making any change, make sure to start small, e.g., with one team or a test environment. By starting small and building on the wins, internal champions will start creating themselves. + +Remember, companies are happy and eager to try to sell you DevOps, but at the end of the day, DevOps is not a product. It is a fully embraced methodology and mindset of automation, collaboration, people, and processes. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/you-cant-buy-devops + +作者:[Julie Gunderson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/juliegund +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee-shop-devops.png?itok=CPefJZJL (Coffee shop photo) +[2]: https://opensource.com/sites/default/files/uploads/devops-pricetag.jpg (DevOps price tag graphic) +[3]: https://opensource.com/resources/devops +[4]: https://xebialabs.com/periodic-table-of-devops-tools/ +[5]: https://opensource.com/sites/default/files/uploads/periodic-table-of-devops-tools.png (Periodic Table of DevOps) +[6]: https://puppet.com/resources/whitepaper/state-of-devops-report +[7]: https://opensource.com/sites/default/files/uploads/cartoon.png (Change management comic by Randy Glasbergen) +[8]: https://images.app.goo.gl/JiMaWAenNkLcmkZJ9 +[9]: https://www.kotterinc.com/8-steps-process-for-leading-change/ +[10]: https://opensource.com/sites/default/files/uploads/kotter-process.png (Kotter 8-Step Process for Leading Change) diff --git a/sources/tech/20190621 7 infrastructure performance and scaling tools you should be using.md b/sources/tech/20190621 7 infrastructure performance and scaling tools you should be using.md new file mode 100644 index 0000000000..3a9003ae9c --- /dev/null +++ b/sources/tech/20190621 7 infrastructure performance and scaling tools you should be using.md @@ -0,0 +1,94 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (7 infrastructure performance and scaling tools you should be using) +[#]: via: (https://opensource.com/article/19/6/performance-scaling-tools) +[#]: author: (Pradeep SurisettyPeter Portante https://opensource.com/users/psuriset/users/aakarsh/users/portante/users/anaga) + +7 infrastructure performance and scaling tools you should be using +====== +These open source tools will help you feel confident in your +infrastructure's performance as it scales up. +![Several images of graphs.][1] + +[Sysadmins][2], [site reliability engineers][3] (SREs), and cloud operators all too often struggle to feel confident in their infrastructure as it scales up. Also too often, they think the only way to solve their challenges is to write a tool for in-house use. Fortunately, there are options. There are many open source tools available to test an infrastructure's performance. Here are my favorites. + +### Pbench + +Pbench is a performance testing harness to make executing benchmarks and performance tools easier and more convenient. In short, it: + + * Excels at running micro-benchmarks on large scales of hosts (bare-metal, virtual machines, containers, etc.) while automating a potentially large set of benchmark parameters + * Focuses on installing, configuring, and executing benchmark code and performance tools and not on provisioning or orchestrating the testbed (e.g., OpenStack, RHEV, RHEL, Docker, etc.) + * Is designed to work in concert with provisioning tools like BrowBeat or Ansible playbooks + + + +Pbench's [documentation][4] includes installation and user guides, and the code is [maintained on GitHub][5], where the team welcomes contributions and issues. + +### Ripsaw + +Baselining is a critical aspect of infrastructure reliability. Ripsaw is a performance benchmark Operator for launching workloads on Kubernetes. It deploys as a Kuberentes Operator that then deploys common workloads, including specific applications (e.g., Couchbase) or general performance tests (e.g., Uperf) to measure and establish a performance baseline. + +Ripsaw is [maintained on GitHub][6]. You can also find its maintainers on the [Kubernetes Slack][7], where they are active contributors. + +### OpenShift Scale + +The collection of tools in OpenShift Scale, OpenShift's open source solution for performance testing, do everything from spinning up OpenShift on OpenStack installations (TripleO Install and ShiftStack Install), installing on Amazon Web Services (AWS), or providing containerized tooling, like running Pbench on your cluster or doing cluster limits testing, network tests, storage tests, metric tests with Prometheus, logging, and concurrent build testing. + +Scale's CI suite is flexible enough to both add workloads and include your workloads when deploying to Azure or anywhere else you might run. You can see the full suite of tools [on GitHub][8]. + +### Browbeat + +[Browbeat][9] calls itself "a performance tuning and analysis tool for OpenStack." You can use it to analyze and tune the deployment of your workloads. It also automates the deployment of standard monitoring and data analysis tools like Grafana and Graphite. Browbeat is [maintained on GitHub][10]. + +### Smallfile + +Smallfile is a filesystem workload generator targeted for scale-out, distributed storage. It has been used to test a number of open filesystem technologies, including GlusterFS, CephFS, Network File System (NFS), Server Message Block (SMB), and OpenStack Cinder volumes. It is [maintained on GitHub][11]. + +### Ceph Benchmarking Tool + +Ceph Benchmarking Tool (CBT) is a testing harness that can automate tasks for testing [Ceph][12] cluster performance. It records system metrics with collectl, and it can collect more information with tools including perf, blktrace, and valgrind. CBT can also do advanced testing that includes automated object storage daemon outages, erasure-coded pools, and cache-tier configurations. + +Contributors have extended CBT to use [Pbench monitoring tools and Ansible][13] and to run the [Smallfile benchmark][14]. A separate Grafana visualization dashboard uses Elasticsearch data generated by [Automated Ceph Test][15]. + +### satperf + +Satellite-performance (satperf) is a set of Ansible playbooks and helper scripts to deploy Satellite 6 environments and measure the performance of selected actions, such as concurrent registrations, remote execution, Puppet operations, repository synchronizations and promotions, and more. You can find Satperf [on GitHub][16]. + +### Conclusion + +Sysadmins, SREs, and cloud operators face a wide variety of challenges as they work to scale their infrastructure, but luckily there is also a wide variety of tools to help them get past those common issues. Any of these seven tools should help you get started testing your infrastructure's performance as it scales. + +Are there other open source performance and scaling tools that should be on this list? Add your favorites in the comments. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/performance-scaling-tools + +作者:[Pradeep SurisettyPeter Portante][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/psuriset/users/aakarsh/users/portante/users/anaga +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/containers_scale_performance.jpg?itok=R7jyMeQf (Several images of graphs.) +[2]: /16/12/yearbook-10-open-source-sysadmin-tools +[3]: /article/19/5/life-performance-engineer +[4]: https://distributed-system-analysis.github.io/pbench/ +[5]: https://github.com/distributed-system-analysis/pbench +[6]: https://github.com/cloud-bulldozer/ripsaw +[7]: https://github.com/cloud-bulldozer/ripsaw#community +[8]: https://github.com/openshift-scale +[9]: https://browbeatproject.org/ +[10]: https://github.com/cloud-bulldozer/browbeat +[11]: https://github.com/distributed-system-analysis/smallfile +[12]: https://ceph.com/ +[13]: https://github.com/acalhounRH/cbt +[14]: https://nuget.pkg.github.com/bengland2/cbt/tree/smallfile +[15]: https://github.com/acalhounRH/automated_ceph_test +[16]: https://github.com/redhat-performance/satperf diff --git a/sources/tech/20190621 The state of open source translation tools for contributors to your project.md b/sources/tech/20190621 The state of open source translation tools for contributors to your project.md new file mode 100644 index 0000000000..07bac654fc --- /dev/null +++ b/sources/tech/20190621 The state of open source translation tools for contributors to your project.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The state of open source translation tools for contributors to your project) +[#]: via: (https://opensource.com/article/19/6/translation-platforms-matter) +[#]: author: (Jean-Baptiste Holcroft https://opensource.com/users/jibec/users/jibec) + +The state of open source translation tools for contributors to your project +====== +There are almost 100 languages with more than 10 million speakers. How +many of your active contributors speak one? +![Team of people around the world][1] + +In the world of free software, many people speak English: It is the **one** language. English helps us cross borders to meet others. However, this language is also a barrier for the majority of people. + +Some master it while others don't. Complex English terms are, in general, a barrier to the understanding and propagation of knowledge. Whenever you use an uncommon English word, ask yourself about your real mastery of what you are explaining, and the unintentional barriers you build in the process. + +_“If you talk to a man in a language he understands, that goes to his head. If you talk to him in his language, that goes to his heart.”_ — Nelson Mandela + +We are 7 billion humans, and less than 400 million of us are English natives. The wonders done day after day by free/libre open source contributors deserve to reach the hearts of the [6.6 billion people][2] for whom English is not their mother tongue. In this day and age, we have the technology to help translate all types of content: websites, documentation, software, and even sounds and images. Even if I do not translate of all of these media personally, I do not know of any real limits. The only prerequisite for getting this content translated is both the willingness of the creators and the collective will of the users, customers, and—in the case of free software—the contributors. + +### Why successful translation requires real tooling + +Some projects are stuck in the stone ages and require translators to use [Git][3], [Mercurial][4], or other development tools. These tools don’t meet the needs of translation communities. Let’s help these projects evolve, as discussed in the section "A call for action." + +Other projects have integrated translation platforms, which are key tools for linguistic diversity and existence. These tools understand the needs of translators and serve as a bridge to the development world. They make translation contribution easy, and keep those doing the translations motivated over time. + +This aspect is important: There are almost 100 languages with more than 10 million speakers. Do you really believe that your project can have an active contributor for each of these languages? Unless you are a huge organization, like Mozilla or LibreOffice, there is no chance. The translators who help you also help two, ten, or a hundred other projects. They need tools to be effective, such as [translation memories][5], progress reports, alerts, ways to collaborate, and knowing that what they do is useful. + +### Translation platforms are in trouble + +However, the translation platforms distributed as free software are disappearing in favor of closed platforms. These platforms set their rules and efforts according to what will bring them the most profit. + +Linguistic and cultural diversity does not bring money: It opens doors and allows local development. It emancipates populations and can ensure the survival of certain cultures and languages. In the 21st century, is your culture really alive if it does not exist in cyberspace? + +The short history of translation platforms is not pretty: + + * In 2011, Transifex ceased to be open when they decided to no longer publish their source code. + * Since September 2017, the [Pootle][6] project seems to have stalled. + * In October 2018, the [Zanata][7] project shut down because it had not succeeded in building a community of technical contributors capable of taking over when corporate funding was halted. + + + +In particular, the [Fedora Project][8]—which I work closely with—has ridden the roller coaster from Transifex to Zanata and is now facing another move and more challenges. + +Two significant platforms remain: + + * [Pontoon][9]: Dedicated to the Mozilla use case (large community, common project). + * [Weblate][10]: A generic platform created by developer [Michal Čihař][11] (a generic purpose platform). + + + +These two tools are of high quality and are technically up-to-date, but Mozilla’s Pontoon is not designed to appeal to the greatest number of people. This project is dedicated to the specific challenges Mozilla faces.  + +### A call for action + +There is an urgent need for large communities to share resources to perpetuate Weblate as free software and promote its adoption. Support is also needed for other tools, such as [po4a][12], the [Translate Toolkit][13], and even our old friend [gettext][14]. Will we accept a sword of Damocles hanging over our heads? Will we continue to consume years of free work without giving a cent in return? Or will we take the lead in bringing security to our communities? + +**What you can do as a contributor**: Promote Weblate as an open source translation platform, and help your beloved project use it. [Hosting is free for open source projects][15]. + +**What you can do as a developer**: Make sure all of your project’s content can be translated into any language. Think about this issue from the beginning, as all tools don’t provide the same internationalization features. + +**What you can do as an entity with a budget**: Whether you’re a company or just part of the community, pay for the support, hosting, or development of the tools you use. Even if the amount is symbolic, doing this will lower the risks. In particular, [here is the info for Weblate][16]. (Note: I’m not involved with the Weblate project other than bug reports and translation.) + +**What to do if you’re a language enthusiast**: Contact me to help create an open source language organization to promote our tools and their usage, and find money to fund them. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/translation-platforms-matter + +作者:[Jean-Baptiste Holcroft][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jibec/users/jibec +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team_global_people_gis_location.png?itok=Rl2IKo12 (Team of people around the world) +[2]: https://www.ethnologue.com/statistics/size +[3]: https://git-scm.com +[4]: https://www.mercurial-scm.org +[5]: https://en.wikipedia.org/wiki/Translation_memory +[6]: http://pootle.translatehouse.org +[7]: http://zanata.org +[8]: https://getfedora.org +[9]: https://github.com/mozilla/pontoon/ +[10]: https://weblate.org +[11]: https://cihar.com +[12]: https://po4a.org +[13]: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/ +[14]: https://www.gnu.org/software/gettext/ +[15]: http://hosted.weblate.org/ +[16]: https://weblate.org/en/hosting/ diff --git a/sources/tech/20190623 What does debugging a program look like.md b/sources/tech/20190623 What does debugging a program look like.md new file mode 100644 index 0000000000..7cc7c1432e --- /dev/null +++ b/sources/tech/20190623 What does debugging a program look like.md @@ -0,0 +1,184 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What does debugging a program look like?) +[#]: via: (https://jvns.ca/blog/2019/06/23/a-few-debugging-resources/) +[#]: author: (Julia Evans https://jvns.ca/) + +What does debugging a program look like? +====== + +I was debugging with a friend who’s a relatively new programmer yesterday, and showed them a few debugging tips. Then I was thinking about how to teach debugging this morning, and [mentioned on Twitter][1] that I’d never seen a really good guide to debugging your code. (there are a ton of really great replies by Anne Ogborn to that tweet if you are interested in debugging tips) + +As usual, I got a lot of helpful answers and now I have a few ideas about how to teach debugging skills / describe the process of debugging. + +### a couple of debugging resources + +I was hoping for more links to debugging books/guides, but here are the 2 recommendations I got: + +**“Debugging” by David Agans**: Several people recommended the book [Debugging][2], which looks like a nice and fairly short book that explains a debugging strategy. I haven’t read it yet (though I ordered it to see if I should be recommending it) and the rules laid out in the book (“understand the system”, “make it fail”, “quit thinking and look”, “divide and conquer”, “change one thing at a time”, “keep an audit trail”, “check the plug”, “get a fresh view”, and “if you didn’t fix it, it ain’t fixed”) seem extremely resaonable :). He also has a charming [debugging poster][3]. + +**“How to debug” by John Regehr**: [How to Debug][4] is a very good blog post based on Regehr’s experience teaching a university embedded systems course. Lots of good advice. He also has a [blog post reviewing 4 books about debugging][5], including Agans’ book. + +### reproduce your bug (but how do you do that?) + +The rest of this post is going to be an attempt to aggregate different ideas about debugging people tweeted at me. + +Somewhat obviously, everybody agrees that being able to consistently reproduce a bug is important if you want to figure out what’s going on. I have an intuitive sense for how to do this but I’m not sure how to **explain** how to go from “I saw this bug twice” to “I can consistently reproduce this bug on demand on my laptop”, and I wonder whether the techniques you use to do this depend on the domain (backend web dev, frontend, mobile, games, C++ programs, embedded etc). + +### reproduce your bug _quickly_ + +Everybody also agrees that it’s extremely useful be able to reproduce the bug quickly (if it takes you 3 minutes to check if every change helped, iterating is VERY SLOW). + +A few suggested approaches: + + * for something that requires clicking on a bunch of things in a browser to reproduce, recording what you clicked on with [Selenium][6] and getting Selenium to replay the UI interactions (suggested [here][7]) + * writing a unit test that reproduces the bug (if you can). bonus: you can add this to your test suite later if it makes sense + * writing a script / finding a command line incantation that does it (like `curl MY_APP.local/whatever`) + + + +### accept that it’s probably your code’s fault + +Sometimes I see a problem and I’m like “oh, library X has a bug”, “oh, it’s DNS”, “oh, SOME OTHER THING THAT IS NOT MY CODE is broken”. And sometimes it’s not my code! But in general between an established library and my code that I wrote last month, usually it’s my code that I wrote last month that’s the problem :). + +### start doing experiments + +@act_gardner gave a [nice, short explanation of what you have to do after you reproduce your bug][8] + +> I try to encourage people to first fully understand the bug - What’s happening? What do you expect to happen? When does it happen? When does it not happen? Then apply their mental model of the system to guess at what could be breaking and come up with experiments. +> +> Experiments could be changing or removing code, making API calls from a REPL, trying new inputs, poking at memory values with a debugger or print statements. + +I think the loop here may be: + + * make guess about one aspect about what might be happening (“this variable is set to X where it should be Y”, “the server is being sent the wrong request”, “this code is never running at all”) + * do experiment to check that guess + * repeat until you understand what’s going on + + + +### change one thing at a time + +Everybody definitely agrees that it is important to change one thing a time when doing an experiment to verify an assumption. + +### check your assumptions + +A lot of debugging is realizing that something you were **sure** was true (“wait this request is going to the new server, right, not the old one???“) is actually… not true. I made an attempt to [list some common incorrect assumptions][9]. Here are some examples: + + * this variable is set to X (“that filename is definitely right”) + * that variable’s value can’t possibly have changed between X and Y + * this code was doing the right thing before + * this function does X + * I’m editing the right file + * there can’t be any typos in that line I wrote it is just 1 line of code + * the documentation is correct + * the code I’m looking at is being executed at some point + * these two pieces of code execute sequentially and not in parallel + * the code does the same thing when compiled in debug / release mode (or with -O2 and without, or…) + * the compiler is not buggy (though this is last on purpose, the compiler is only very rarely to blame :)) + + + +### weird methods to get information + +There are a lot of normal ways to do experiments to check your assumptions / guesses about what the code is doing (print out variable values, use a debugger, etc). Sometimes, though, you’re in a more difficult environment where you can’t print things out and don’t have access to a debugger (or it’s inconvenient to do those things, maybe because there are too many events). Some ways to cope: + + * [adding sounds on mobile][10]: “In the mobile world, I live on this advice. Xcode can play a sound when you hit a breakpoint (and continue without stopping). I place them certain places in the code, and listen for buzzing Tink to indicate tight loops or Morse/Pop pairs to catch unbalanced events” (also [this tweet][11]) + * there’s a very cool talk about [using XCode to play sound for iOS debugging here][12] + * [adding LEDs][13]: “When I did embedded dev ages ago on grids of transputers, we wired up an LED to an unused pin on each chip. It was surprisingly effective for diagnosing parallelism issues.” + * [string][14]: “My networks prof told me about a hack he saw at Xerox in the early days of Ethernet: a tap in the coax with an amp and motor and piece of string. The busier the network was, the faster the string twirled.” + * [peep][15] is a “network auralizer” that translates what’s happening on your system into sounds. I spent 10 minutes trying to get it to compile and failed so far but it looks very fun and I want to try it!! + + + +The point here is that information is the most important thing and you need to do whatever’s necessary to get information. + +### write your code so it’s easier to debug + +Another point a few people brought up is that you can improve your program to make it easier to debug. tef has a nice post about this: [Write code that’s easy to delete, and easy to debug too.][16] here. I thought this was very true: + +> Debuggable code isn’t necessarily clean, and code that’s littered with checks or error handling rarely makes for pleasant reading. + +I think one interpretation of “easy to debug” is “every single time there’s an error, the program reports to you exactly what happened in an easy to understand way”. Whenever my program has a problem and says sometihng “error: failure to connect to SOME_IP port 443: connection timeout” I’m like THANK YOU THAT IS THE KIND OF THING I WANTED TO KNOW and I can check if I need to fix a firewall thing or if I got the wrong IP for some reason or what. + +One simple example of this recently: I was making a request to a server I wrote and the reponse I got was “upstream connect error or disconnect/reset before headers”. This is an nginx error which basically in this case boiled down to “your program crashed before it sent anything in response to the request”. Figuring out the cause of the crash was pretty easy, but having better error handling (returning an error instead of crashing) would have saved me a little time because instead of having to go check the cause of the crash, I could have just read the error message and figured out what was going on right away. + +### error messages are better than silently failing + +To get closer to the dream of “every single time there’s an error, the program reports to you exactly what happened in an easy to understand way” you also need to be disciplined about immediately returning an error message instead of silently writing incorrect data / passing a nonsense value to another function which will do WHO KNOWS WHAT with it and cause you a gigantic headache. This means adding code like this: + +``` +if UNEXPECTED_THING: + raise "oh no THING happened" +``` + +This isn’t easy to get right (it’s not always obvious where you should be raising errors!“) but it really helps a lot. + +### failure: print out a stack of errors, not just one error. + +Related to returning helpful errors that make it easy to debug: Rust has a really incredible error handling library [called failure][17] which basicaly lets you return a chain of errors instead of just one error, so you can print out a stack of errors like: + +``` +"error starting server process" caused by +"error initializing logging backend" caused by +"connection failure: timeout connecting to 1.2.3.4 port 1234". +``` + +This is SO MUCH MORE useful than just `connection failure: timeout connecting to 1.2.3.4 port 1234` by itself because it tells you the significance of 1.2.3.4 (it’s something to do with the logging backend!). And I think it’s also more useful than `connection failure: timeout connecting to 1.2.3.4 port 1234` with a stack trace, because it summarizes at a high level the parts that went wrong instead of making you read all the lines in the stack trace (some of which might not be relevant!). + +tools like this in other languages: + + * Go: the idiom to do this seems to be to just concatenate your stack of errors together as a big string so you get “error: thing one: error: thing two : error: thing three” which works okay but is definitely a lot less structured than `failure`’s system + * Java: I hear you can give exceptions causes but haven’t used that myself + * Python 3: you can use `raise ... from` which sets the `__cause__` attribute on the exception and then your exceptions will be separated by `The above exception was the direct cause of the following exception:..` + + + +If you know how to do this in other languages I’d be interested to hear! + +### understand what the error messages mean + +One sub debugging skill that I take for granted a lot of the time is understanding what error messages mean! I came across this nice graphic explaining [common Python errors and what they mean][18], which breaks down things like `NameError`, `IOError`, etc. + +I think a reason interpreting error messages is hard is that understanding a new error message might mean learning a new concept – `NameError` can mean “Your code uses a variable outside the scope where it’s defined”, but to really understand that you need to understand what variable scope is! I ran into this a lot when learning Rust – the Rust compiler would be like “you have a weird lifetime error” and I’d like be “ugh ok Rust I get it I will go actually learn about how lifetimes work now!“. + +And a lot of the time error messages are caused by a problem very different from the text of the message, like how “upstream connect error or disconnect/reset before headers” might mean “julia, your server crashed!“. The skill of understanding what error messages mean is often not transferable when you switch to a new area (if I started writing a lot of React or something tomorrow, I would probably have no idea what any of the error messages meant!). So this definitely isn’t just an issue for beginner programmers. + +### that’s all for now! + +I feel like the big thing I’m missing when talking about debugging skills is a stronger understanding of where people get stuck with debugging – it’s easy to say “well, you need to reproduce the problem, then make a more minimal reproduction, then start coming up with guesses and verifying them, and improve your mental model of the system, and then figure it out, then fix the problem and hopefully write a test to make it not come back”, but – where are people actually getting stuck in practice? What are the hardest parts? I have some sense of what the hardest parts usually are for me but I’m still not sure what the hardest parts usually are for someone newer to debugging their code. + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/06/23/a-few-debugging-resources/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://twitter.com/b0rk/status/1142825259546140673 +[2]: http://debuggingrules.com/ +[3]: http://debuggingrules.com/?page_id=40 +[4]: https://blog.regehr.org/archives/199 +[5]: https://blog.regehr.org/archives/849 +[6]: https://www.seleniumhq.org/ +[7]: https://twitter.com/AnnieTheObscure/status/1142843984642899968 +[8]: https://twitter.com/act_gardner/status/1142838587437830144 +[9]: https://twitter.com/b0rk/status/1142812831420768257 +[10]: https://twitter.com/cocoaphony/status/1142847665690030080 +[11]: https://twitter.com/AnnieTheObscure/status/1142842421954244608 +[12]: https://qnoid.com/2013/06/08/Sound-Debugging.html +[13]: https://twitter.com/wombatnation/status/1142887843963867136 +[14]: https://twitter.com/irvingreid/status/1142887472441040896 +[15]: http://peep.sourceforge.net/intro.html +[16]: https://programmingisterrible.com/post/173883533613/code-to-debug +[17]: https://github.com/rust-lang-nursery/failure +[18]: https://pythonforbiologists.com/29-common-beginner-errors-on-one-page/ diff --git a/sources/tech/20190624 Book Review- A Byte of Vim.md b/sources/tech/20190624 Book Review- A Byte of Vim.md new file mode 100644 index 0000000000..e221a3bc6f --- /dev/null +++ b/sources/tech/20190624 Book Review- A Byte of Vim.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Book Review: A Byte of Vim) +[#]: via: (https://itsfoss.com/book-review-a-byte-of-vim/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +Book Review: A Byte of Vim +====== + +[Vim][1] is a tool that is both simple and very powerful. Most new users will be intimidated by it because it doesn’t ‘work’ like regular graphical text editors. The ‘unusual’ keyboard shortcuts makes people wonder about [how to save and exit Vim][2]. But once you master Vim, there is nothing like it. + +There are numerous [Vim resources available online][3]. We have covered some Vim tricks on It’s FOSS as well. Apart from online resources, plenty of books have been dedicated to this editor as well. Today, we will look at one of such book that is designed to make Vim easy for most users to understand. The book we will be discussing is [A Byte of Vim][4] by [Swaroop C H][5]. + +The author [Swaroop C H][6] has worked in computing for over a decade. He previously worked at Yahoo and Adobe. Out of college, he made money by selling Linux CDs. He started a number of businesses, including an iPod charger named ion. He is currently an engineering manager for the AI team at [Helpshift][7]. + +### A Byte of Vim + +![][8] + +Like all good books, A Byte of Vim starts by talking about what Vim is: “a computer program used for writing any kind of text”. He does on to say, “What makes Vim special is that it is one of those few software which is both simple and powerful.” + +Before diving into telling how to use Vim, Swaroop tells the reader how to install Vim for Windows, Mac, Linux, and BSD. Once the installation is complete, he runs you through how to launch Vim and how to create your first file. + +Next, Swaroop discusses the different modes of Vim and how to navigate around your document using Vim’s keyboard shortcuts. This is followed by the basics of editing a document with Vim, including the Vim version of cut/copy/paste and undo/redo. + +Once the editing basics are covered, Swaroop talks about using Vim to edit multiple parts of a single document. You can also multiple tabs and windows to edit multiple documents at the same time. + +[][9] + +Suggested read  Bring Your Old Computer Back to Life With 4MLinux + +The book also covers extending the functionality of Vim through scripting and installing plugins. There are two ways to using scripts in Vim, use Vim’s built-in scripting language or using a programming language like Python or Perl to access Vim’s internals. There are five types of Vim plugins that can be written or downloaded: vimrc, global plugin, filetype plugin, syntax highlighting plugin, and compiler plugin. + +In a separate section, Swaroop C H covers the features of Vim that make it good for programming. These features include syntax highlighting, smart indentation, support for shell commands, omnicompletion, and the ability to be used as an IDE. + +#### Getting the ‘A Byte of Vim’ book and contributing to it + +A Byte of Book is licensed under [Creative Commons 4.0][10]. You can read an online version of the book for free on [the author’s website][4]. You can also download a [PDF][11], [Epub][12], or [Mobi][13] for free. + +[Get A Byte of Vim for FREE][4] + +If you prefer reading a [hard copy][14], you have that option, as well. + +Please note that the _**original version of A Byte of Vim was written in 2008**_ and converted to PDf. Unfortunately, Swaroop C H lost the original source files and he is working to convert the book to [Markdown][15]. If you would like to help, please visit the [book’s GitHub page][16]. + +Preview | Product | Price | +---|---|---|--- +![Mastering Vim Quickly: From WTF to OMG in no time][17] ![Mastering Vim Quickly: From WTF to OMG in no time][17] | [Mastering Vim Quickly: From WTF to OMG in no time][18] | $34.00[][19] | [Buy on Amazon][20] + +#### Conclusion + +When I first stared into the angry maw that is Vim, I did not have a clue what to do. I wish that I had known about A Byte of Vim then. This book is a good resource for anyone learning about Linux, especially if you are getting into the command line. + +Have you read [A Byte of Vim][4] by Swaroop C H? If yes, how do you find it? If not, what is your favorite book on an open source topic? Let us know in the comments below. + +[][21] + +Suggested read  Iridium Browser: A Browser for the Privacy Conscious + +If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][22]. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/book-review-a-byte-of-vim/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://www.vim.org/ +[2]: https://itsfoss.com/how-to-exit-vim/ +[3]: https://linuxhandbook.com/basic-vim-commands/ +[4]: https://vim.swaroopch.com/ +[5]: https://swaroopch.com/ +[6]: https://swaroopch.com/about/ +[7]: https://www.helpshift.com/ +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/Byte-of-vim-book.png?resize=800%2C450&ssl=1 +[9]: https://itsfoss.com/4mlinux-review/ +[10]: https://creativecommons.org/licenses/by/4.0/ +[11]: https://www.gitbook.com/download/pdf/book/swaroopch/byte-of-vim +[12]: https://www.gitbook.com/download/epub/book/swaroopch/byte-of-vim +[13]: https://www.gitbook.com/download/mobi/book/swaroopch/byte-of-vim +[14]: https://swaroopch.com/buybook/ +[15]: https://itsfoss.com/best-markdown-editors-linux/ +[16]: https://github.com/swaroopch/byte-of-vim#status-incomplete +[17]: https://i2.wp.com/images-na.ssl-images-amazon.com/images/I/41itW8furUL._SL160_.jpg?ssl=1 +[18]: https://www.amazon.com/Mastering-Vim-Quickly-WTF-time/dp/1983325740?SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=1983325740 (Mastering Vim Quickly: From WTF to OMG in no time) +[19]: https://www.amazon.com/gp/prime/?tag=chmod7mediate-20 (Amazon Prime) +[20]: https://www.amazon.com/Mastering-Vim-Quickly-WTF-time/dp/1983325740?SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=1983325740 (Buy on Amazon) +[21]: https://itsfoss.com/iridium-browser-review/ +[22]: http://reddit.com/r/linuxusersgroup diff --git a/sources/tech/20190624 Check your password security with Have I Been Pwned- and pass.md b/sources/tech/20190624 Check your password security with Have I Been Pwned- and pass.md new file mode 100644 index 0000000000..d4557725ba --- /dev/null +++ b/sources/tech/20190624 Check your password security with Have I Been Pwned- and pass.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Check your password security with Have I Been Pwned? and pass) +[#]: via: (https://opensource.com/article/19/6/check-passwords) +[#]: author: (Brian "bex" Exelbierd https://opensource.com/users/bexelbie/users/jason-baker/users/admin/users/mtsouk) + +Check your password security with Have I Been Pwned? and pass +====== +Periodically checking for password compromise is an excellent way to +help ward off most attackers in most threat models. +![Password lock][1] + +Password security involves a broad set of practices, and not all of them are appropriate or possible for everyone. Therefore, the best strategy is to develop a threat model by thinking through your most significant risks—who and what you are protecting against—then model your security approach on the activities that are most effective against those specific threats. The Electronic Frontier Foundation (EFF) has a [great series on threat modeling][2] that I encourage everyone to read. + +In my threat model, I am very concerned about the security of my passwords against (among other things) [dictionary attacks][3], in which an attacker uses a list of likely or known passwords to try to break into a system. One way to stop dictionary attacks is to have your service provider rate-limit or deny login attempts after a certain number of failures. Another way is not to use passwords in the "known passwords" dataset. + +### Check password security with HIBP + +[Troy Hunt][4] created [Have I Been Pwned?][5] (HIBP) to notify people when their information is found in leaked data dumps and breaches. If you haven't already registered, you should, as the mere act of registering exposes nothing. Troy has built a collection of over 550 million real-world passwords from this data. These are passwords that real people used and were exposed by data that was stolen or accidentally made public. + +The site _does not_ publish the plaintext password list, but it doesn't have to. By definition, this data is already out there. If you've ever reused a password or used a "common" password, then you are at risk because someone is building a dictionary of these passwords to try right now. + +Recently, Firefox and HIBP announced they are [teaming up][6] to make breach searches easier. And the National Institutes of Standards and Technology (NIST) recommends that you [check passwords][7] against those known to be compromised and change them if they are found. HIBP supports this via a password-checking feature that is exposed via an API, so it is easy to use. + +Now, it would be a bad idea to send the website a full list of your passwords. While I trust [HaveIBeenPwned.com][5], it could be compromised one day. Instead, the site uses a process called [k-Anonymity][8] that allows you to check your passwords without exposing them. This is a three-step process. First, let's review the steps, and then we can use the **pass-pwned** plugin to do it for us: + + 1. Create a hash value of your password. A hash value is just a way of turning arbitrary data—your password—into a fixed data representation—the hash value. A cryptographic hash function is collision-resistant, meaning it creates a unique hash value for every input. The algorithm used for the hash is a one-way transformation, which makes it hard to know the input value if you only have the hash value. For example, using the SHA-1 algorithm that HIBP uses, the password **hunter2** becomes **F3BBBD66A63D4BF1747940578EC3D0103530E21D**. + 2. Send the first five characters (**F3BBB** in our example) to the site, and the site will send back a list of all the hash values that start with those five characters. This way, the site can't know which hash values you are interested in. The k-Anonymity process ensures there is so much statistical noise that it is hard for a compromised site to determine which password you inquired about. For example, our query returns a list of 527 potential matches from HIBP. + 3. Search through the list of results to see if your hash is there. If it is, your password has been compromised. If it isn't, the password isn't in a publicly known data breach. HIBP returns a bonus in its data: a count of how many times the password has been seen in data breaches. Astoundingly, **hunter2** has been seen 17,043 times! + + + +### Check password security with pass + +I use [**pass**][9], a [GNU Privacy Guard][10]-based password manager. It has many extensions, which are available on the [**pass** website][11] and as a separately maintained [awesome-style list][12]. One of these extensions is [**pass-pwned**][13], which will check your passwords with HIBP. Both **pass** and **pass-pwned** are packaged for Fedora 29, 30, and Rawhide. You can install the extension with: + + +``` +`sudo dnf install pass pass-pwned` +``` + +or you can follow the manual instructions on their respective websites. + +If you're just getting started with **pass**, read [Managing passwords the open source way][14] for a great overview. + +The following will quickly set up **pass** and check a stored password. This example assumes you already have a GPG key. + + +``` +# Setup a pass password store +$ pass init <GPG key email> + +# Add the password, "hunter2" to the store +$ pass insert awesome-site.com + +# Install the pass-pwned extension +# Download the bash script from the upstream and then review it +$ mkdir ~/.password-store/.extensions +$ wget -O ~/.password-store/.extensions/pwned.bash +$ vim ~/.password-store/.extensions/pwned.bash + +# If everything is OK, set it executable and enable pass extensions +$ chmod u+x ~/.password-store/.extensions/pwned.bash +$ echo 'export PASSWORD_STORE_ENABLE_EXTENSIONS="true"' >> ~/.bash_profile +$ source ~/.bash_profile + +# Check the password +$ pass pwned awesome-site.com +Password found in haveibeenpwned 17043 times + +# Change this password to something randomly generated and verify it +$ pass generate -i awesoem-site.com +The generated password for awesome-site.com is: +<REDACTED> +$ pass pwned awesome-site.com +Password not found in haveibeenpwned +``` + +Congratulations, your password is now more secure than it was before! You can also [use wildcards to check multiple passwords][15] at once. + +Periodically checking for password compromise is an excellent way to help ward off most attackers in most threat models. If your password management system doesn't make it this easy, you may want to upgrade to something like **pass**. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/check-passwords + +作者:[Brian "bex" Exelbierd][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bexelbie/users/jason-baker/users/admin/users/mtsouk +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/password.jpg?itok=ec6z6YgZ (Password lock) +[2]: https://ssd.eff.org/en/module/your-security-plan +[3]: https://en.wikipedia.org/wiki/Dictionary_attack +[4]: https://www.troyhunt.com/ +[5]: https://haveibeenpwned.com/ +[6]: https://www.troyhunt.com/were-baking-have-i-been-pwned-into-firefox-and-1password/ +[7]: https://pages.nist.gov/800-63-FAQ/#q-b5 +[8]: https://blog.cloudflare.com/validating-leaked-passwords-with-k-anonymity/ +[9]: https://www.passwordstore.org/ +[10]: https://gnupg.org/ +[11]: https://www.passwordstore.org/#extensions +[12]: https://github.com/tijn/awesome-password-store +[13]: https://github.com/alzeih/pass-pwned +[14]: https://opensource.com/life/14/7/managing-passwords-open-source-way +[15]: https://github.com/alzeih/pass-pwned/issues/3 diff --git a/sources/tech/20190624 How to Install and Configure KVM on RHEL 8.md b/sources/tech/20190624 How to Install and Configure KVM on RHEL 8.md new file mode 100644 index 0000000000..3021561dd8 --- /dev/null +++ b/sources/tech/20190624 How to Install and Configure KVM on RHEL 8.md @@ -0,0 +1,256 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Install and Configure KVM on RHEL 8) +[#]: via: (https://www.linuxtechi.com/install-configure-kvm-on-rhel-8/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +How to Install and Configure KVM on RHEL 8 +====== + +**KVM** is an open source virtualization technology which converts your Linux machine into a type-1 bare-metal hypervisor that allows you to run multiple virtual machines (VMs) or guest VMs + + + +KVM stands for **Kernel based Virtual machine**, as the name suggests KVM is a kernel module, once it is loaded into the kernel , then your Linux machine will start working as a KVM hypervisor. In this article we will demonstrate how to install KVM on RHEL 8 system but before start installing KVM on your RHEL 8 system first we have to make sure that your system’s processor supports hardware virtualization extensions like **Intel VT** or **AMD-V** and enabled it from BIOS. + +**RHEL 8 KVM Lab Details:** + + * OS = RHEL 8 + * Hostname = rhel8-kvm + * Ethernet Cards = ens32 –  192.168.1.4 & ens36 – 192.168..1.12 + * RAM = 4 GB + * CPU = 2 + * Disk = 40 GB Free Space (/var/libvirtd) + + + +Let’s Jump into the KVM installation steps + +### Step:1) Verify Hardware Virtualization is enabled or not + +Open the terminal and execute the beneath egrep command + +``` +[root@linuxtechi ~]# egrep -c '(vmx|svm)' /proc/cpuinfo +2 +[root@linuxtechi ~]# +``` + +If output of above egrep command is equal to 1 or more than 1 then this confirms that hardware virtualization is enabled and supported. + +Alternate way to check whether hardware virtualization is enabled or not , execute the beneath command, + +``` +[root@linuxtechi ~]# lscpu | grep Virtualization: +Virtualization: VT-x +[root@linuxtechi opt]# +``` + +If there is no output in above command then it confirms that Virtualization is not enabled from BIOS. + +**Note:** To enable hardware virtualization reboot your system, go to bios settings and then look for Intel VT or AMD virtualization option and enable one of this option which which suits to your system architecture. + +### Step:2) Install KVM and its dependent packages using dnf + +Run the following dnf command to install KVM and its dependent packages, + +``` +[root@linuxtechi ~]# dnf install qemu-kvm qemu-img libvirt virt-install libvirt-client virt-manager -y +``` + +Once above packages has been installed successfully, then run the below command to confirm whether KVM module has been loaded into the kernel or not, + +``` +root@linuxtechi ~]# lsmod | grep -i kvm +kvm_intel 245760 0 +kvm 745472 1 kvm_intel +irqbypass 16384 1 kvm +[root@linuxtechi ~]# +``` + +### Step:3) Enable and Start libvirtd service + +Run the following systemctl command to enable and start libvirtd service, + +``` +[root@linuxtechi ~]# systemctl enable libvirtd +[root@linuxtechi ~]# systemctl start libvirtd +``` + +### Step:4) Create Network bridge and attach Interface to it  + +In RHEL 8, network scripts are deprecated, We have to use Network Manager (nmcli / nmtui) to configure network and network bridges. + +I have two Ethernet cards on my server, ens36 will attached to bridge br0 and ens32 will be used for management . + +``` +[root@linuxtechi ~]# nmcli connection show +NAME UUID TYPE DEVICE +ens32 1d21959d-e2ea-4129-bb89-163486c8d7bc ethernet ens32 +ens36 1af408b6-c98e-47ce-bca7-5141b721f8d4 ethernet ens36 +virbr0 d0f05de4-4b3b-4710-b904-2524b5ad11bf bridge virbr0 +[root@linuxtechi ~]# +``` + +Delete the existing connection of interface “ens36” + +``` +[root@linuxtechi ~]# nmcli connection delete ens36 +Connection 'ens36' (1af408b6-c98e-47ce-bca7-5141b721f8d4) successfully deleted. +[root@linuxtechi ~]# +``` + +Create a Network Bridge with name “**br0**” using mcli command, + +``` +[root@linuxtechi ~]# nmcli connection add type bridge autoconnect yes con-name br0 ifname br0 +Connection 'br0' (62c14e9d-3e72-41c2-8ecf-d17978ad02da) successfully added. +[root@linuxtechi ~]# +``` + +Assign the same IP of ens36 to the bridge interface using following nmcli commands, + +``` +[root@linuxtechi ~]# nmcli connection modify br0 ipv4.addresses 192.168.1.12/24 ipv4.method manual +[root@linuxtechi ~]# nmcli connection modify br0 ipv4.gateway 192.168.1.1 +[root@linuxtechi ~]# nmcli connection modify br0 ipv4.dns 192.168.1.1 +``` + +Add ens36 interface as bridge salve to the network bridge br0, + +``` +[root@linuxtechi ~]# nmcli connection add type bridge-slave autoconnect yes con-name ens36 ifname ens36 master br0 +Connection 'ens36' (0c2065bc-ad39-47a7-9a3e-85c80cd73c94) successfully added. +[root@linuxtechi ~]# +``` + +Now bring up the network bridge using beneath nmcli command, + +``` +[root@linuxtechi ~]# nmcli connection up br0 +Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/9) +[root@linuxtechi ~]# +``` + +Verify the connections using following command, + +``` +[root@linuxtechi ~]# nmcli connection show +NAME UUID TYPE DEVICE +br0 00bcff8f-af85-49ad-9196-974de2d9d9d1 bridge br0 +ens32 1d21959d-e2ea-4129-bb89-163486c8d7bc ethernet ens32 +ens36 eaef13c9-c24e-4a3f-ae85-21bf0610471e ethernet ens36 +virbr0 d0f05de4-4b3b-4710-b904-2524b5ad11bf bridge virbr0 +[root@linuxtechi ~]# +``` + +View the bridge (br0) details and status using ip command, + +![rhel-8-bridge-details][1] + +**Note:** If you want to use network-scripts in RHEL 8 system then install network-scripts packages, + +``` +~ ]# dnf install network-scripts -y +``` + +### Step:5) Creating and Managing KVM Virtual Machines + +In RHEL 8 there are different ways to create and manage KVM virtual machines, + + * virt-manager (GUI) + * Command Line tools (**virt-install** & **virsh**) + + + +During the KVM installation we have already installed virt-manager and virt-install packages. + +### Creating Virtual Machines using virt-manager GUI tool: + +Run the virt-manager command from command line or Access virt-manager from RHEL 8 Desktop + +[![Access-Virt-Manager-RHEL8][2]][3] + +Click on Monitor Icon to create a new guest VM (Virtual Machine), + +Choose Local Installation Media as ISO, + +[![Choose-ISO-KVM-RHEL8][4]][5] + +Click on forward, + +In the next screen, browse the OS installation ISO file , in my case i have placed Ubuntu 18.04 LTS server ISO file under /opt folder, + +[![Installation-ISO-File-RHEL8-KVM][6]][7] + +click on Forward to Proceed further, + +In the next window you will be prompted to specify RAM and vCPU for your virtual machine, so specify the values that suits your installation and then click on Forward, + +[![Specify-RAM-CPU-KVM-RHEL8][8]][9] + +In next window specify disk size for your Virtual Machine and the click on Forward, in my case i am giving disk space for my VM as 20 GB, + +[![Disk-Image-RHEL8-KVM-VM][10]][11] + +In the next window, specify the name of VM and choose the Network that you want to attach to VM’s Ethernet card, as we had created network bridge “br0” for vms networking, so choose bridge“br0”. + +[![Network-Selection-KVM-RHEL8][12]][13] + +Click on Finish to proceed with VM creation and its OS installation, + +[![OS-Installation-KVM-VM-RHEL8][14]][15] + +Follow the screen Instructions and complete the Installation. + +**Creating KVM Virtual Machine from Command Line** + +if you are fan of command line then there is a command line tool for you called “**virt-install**” to create virtual machines. Once the Virtual machines are provisioned then vms can be managed via command line tool “[virsh][16]“. + +Let’s assume we want to create CentOS 7 VM using virt-install, i have already placed CentOS 7 ISO file under /opt folder, + +Execute beneath command to provision a VM + +``` +[root@linuxtechi ~]# virt-install -n CentOS7-Server --description "CentOS 7 Virtual Machine" --os-type=Linux --os-variant=rhel7 --ram=1096 --vcpus=1 --disk path=/var/lib/libvirt/images/centos7-server.img,bus=virtio,size=20 --network bridge:br0 --graphics none --location /opt/CentOS-7-x86_64-DVD-1511.iso --extra-args console=ttyS0 +``` + +Output of command would be something like below, + +![Virt-Install-KVM-RHEL8][17] + +Follow screen instructions to complete CentOS 7 Installation. That’s all from this tutorial, i hope these steps helped you to setup KVM on your RHEL 8 system, please do share your feedback and comments. + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/install-configure-kvm-on-rhel-8/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/wp-content/uploads/2019/06/rhel-8-bridge-details-1024x628.jpg +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Access-Virt-Manager-RHEL8-1024x471.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Access-Virt-Manager-RHEL8.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Choose-ISO-KVM-RHEL8-1024x479.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Choose-ISO-KVM-RHEL8.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Installation-ISO-File-RHEL8-KVM-1024x477.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Installation-ISO-File-RHEL8-KVM.jpg +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Specify-RAM-CPU-KVM-RHEL8-1024x478.jpg +[9]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Specify-RAM-CPU-KVM-RHEL8.jpg +[10]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Disk-Image-RHEL8-KVM-VM-1024x483.jpg +[11]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Disk-Image-RHEL8-KVM-VM.jpg +[12]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Network-Selection-KVM-RHEL8-1024x482.jpg +[13]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Network-Selection-KVM-RHEL8.jpg +[14]: https://www.linuxtechi.com/wp-content/uploads/2019/06/OS-Installation-KVM-VM-RHEL8-1024x479.jpg +[15]: https://www.linuxtechi.com/wp-content/uploads/2019/06/OS-Installation-KVM-VM-RHEL8.jpg +[16]: https://www.linuxtechi.com/create-revert-delete-kvm-virtual-machine-snapshot-virsh-command/ +[17]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Virt-Install-KVM-RHEL8.jpg diff --git a/sources/tech/20190624 Linux Package Managers Compared - AppImage vs Snap vs Flatpak.md b/sources/tech/20190624 Linux Package Managers Compared - AppImage vs Snap vs Flatpak.md new file mode 100644 index 0000000000..df5686d0a5 --- /dev/null +++ b/sources/tech/20190624 Linux Package Managers Compared - AppImage vs Snap vs Flatpak.md @@ -0,0 +1,222 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Linux Package Managers Compared – AppImage vs Snap vs Flatpak) +[#]: via: (https://www.ostechnix.com/linux-package-managers-compared-appimage-vs-snap-vs-flatpak/) +[#]: author: (editor https://www.ostechnix.com/author/editor/) + +Linux Package Managers Compared – AppImage vs Snap vs Flatpak +====== + +![3 Linux Package Managers Compared][1] + +**Package managers** provide a way of packaging, distributing, installing, and maintaining apps in an operating system. With modern desktop, server and IoT applications of the Linux operating system and the hundreds of different distros that exist, it becomes necessary to move away from platform specific packaging methods to platform agnostic ones. This post explores 3 such tools, namely **AppImage** , **Snap** and **Flatpak** , that each aim to be the future of software deployment and management in Linux. At the end we summarize a few key findings. + +### 1\. AppImage + +**AppImage** follows a concept called **“One app = one file”**. This is to be understood as an AppImage being a regular independent “file” containing one application with everything it needs to run in the said file. Once made executable, the AppImage can be run like any application in a computer by simply double-clicking it in the users file system.[1] + +It is a format for creating portable software for Linux without requiring the user to install the said application. The format allows the original developers of the software (upstream developers) to create a platform and distribution independent (also called a distribution-agnostic binary) version of their application that will basically run on any flavor of Linux. + +AppImage has been around for a long time. **Klik** , a predecessor of AppImage was created by **Simon Peter** in 2004. The project was shut down in 2011 after not having passed the beta stage. A project named **PortableLinuxApps** was created by Simon around the same time and the format was picked up by a few portals offering software for Linux users. The project was renamed again in 2013 to its current name AppImage and a repository has been maintained in GitHub (project [link][2]) with all the latest changes to the same since 2018.[2][3] + +Written primarily in **C** and donning the **MIT license** since 2013, AppImage is currently developed by **The AppImage project**. It is a very convenient way to use applications as demonstrated by the following features: + + 1. AppImages can run on virtually any Linux system. As mentioned before applications derive a lot of functionality from the operating system and a few common libraries. This is a common practice in the software world since if something is already done, there is no point in doing it again if you can pick and choose which parts from the same to use. The problem is that many Linux distros might not have all the files a particular application requires to run since it is left to the developers of that particular distro to include the necessary packages. Hence developers need to separately include the dependencies of the application for each Linux distro they are publishing their app for. Using the AppImage format developers can choose to include all the libraries and files that they cannot possibly hope the target operating system to have as part of the AppImage file. Hence the same AppImage format file can work on different operating systems and machines without needing granular control. + 2. The one app one file philosophy means that user experience is simple and elegant in that users need only download and execute one file that will serve their needs for using the application. + 3. **No requirement of root access**. System administrators will require people to have root access to stop them from messing with computers and their default setup. This also means that people with no root access or super user privileges cannot install the apps they need as they please. The practice is common in a public setting (such as library or university computers or on enterprise systems). The AppImage file does not require users to “install” anything and hence users need only download the said file and **make it executable** to start using it. This removes the access dilemmas that system administrators have and makes their job easier without sacrificing user experience. + 4. **No effect on core operating system**. The AppImage-application format allows using applications with their full functionality without needing to change or even access most system files. Meaning whatever the applications do, the core operating system setup and files remain untouched. + 5. An AppImage can be made by a developer for a particular version of their application. Any updated version is made as a different AppImage. Hence users if need be can **test multiple versions of the same application** by running different instances using different AppImages. This is an invaluable feature when you need to test your applications from an end-user POV to notice differences. + 6. Take your applications where you go. As mentioned previously AppImages are archived files of all the files that an application requires and can be used without installing or even bothering about the distribution the system uses. Hence if you have a set of apps that you use regularly you may even mount a few AppImage files on a thumb drive and take it with you to use on multiple computers running multiple different distros without worrying whether they’ll work or not. + + + +Furthermore, the **AppImageKit** allows users from all backgrounds to build their own AppImages from applications they already have or for applications that are not provided an AppImage by their upstream developer. + +The package manager is platform independent but focuses primarily on software distribution to end users on their desktops with a dedicated daemon **AppImaged** for integrating the AppImage formats into respective desktop environments. AppImage is supported natively now by a variety of distros such as Ubuntu, Debian, openSUSE, CentOS, Fedora etc. and others may set it up as per their needs. AppImages can also be run on servers with limited functionality via the CLI tools included. + +To know more about AppImages, go to the official [**AppImage documentation**][3] page. + +* * * + +**Suggested read:** + + * [**Search Linux Applications On AppImage, Flathub And Snapcraft Platforms**][4] + + + +* * * + +### 2\. Snappy + +**Snappy** is a software deployment and package management system like AppImage or any other package manager for that instance. It is originally designed for the now defunct **Ubuntu Touch** Operating system. Snappy lets developers create software packages for use in a variety of Linux based distributions. The initial intention behind creating Snappy and deploying **“snaps”** on Ubuntu based systems is to obtain a unified single format that could be used in everything from IoT devices to full-fledged computer systems that ran some version of Ubuntu and in a larger sense Linux itself.[4] + +The lead developer behind the project is **Canonical** , the same company that pilots the Ubuntu project. Ubuntu had native snap support from version 16.04 LTS with more and more distros supporting it out of the box or via a simple setup these days. If you use Arch or Debian or openSUSE you’ll find it easy to install support for the package manager using simple commands in the terminal as explained later in this section. This is also made possible by making the necessary snap platform files available on the respective repos.[5] + +Snappy has the following important components that make up the entire package manager system.[6] + + * **Snap** – is the file format of the packages themselves. Individual applications that are deployed using Snappy are called “Snaps”. Any application may be packaged using the tools provided to make a snap that is intended to run on a different system running Linux. Snap, similar to AppImage is an all-inclusive file and contains all dependencies the application needs to run without assuming them to part of the target system. + * **Snapcraft** – is the tool that lets developers make snaps of their applications. It is basically a command that is part of the snap system as well as a framework that will let you build your own snaps. + * **Snapd** – is the background daemon that maintains all the snaps that are installed in your system. It integrates into the desktop environment and manages all the files and processes related to working with snaps. The snapd daemon also checks for updates normally **4 times a day** unless set otherwise. + * [**Snap Store**][5] – is an online gallery of sorts that lets developers upload their snaps into the repository. Snap store is also an application discovery medium for users and will let users see and experience the application library before downloading and installing them. + + + +The snapd component is written primarily in **C** and **Golang** whereas the Snapcraft framework is built using **Python**. Although both the modules use the GPLv3 license it is to be noted that snapd has proprietary code from Canonical for its server-side operations with just the client side being published under the GPL license. This is a major point of contention with developers since this involves developers signing a CLA form to participate in snap development.[7] + +Going deeper into the finer details of the Snappy package manager the following may be noted: + + 1. Snaps as noted before are all inclusive and contain all the necessary files (dependencies) that the application needs to run. Hence, developers need not to make different snaps for the different distros that they target. Being mindful of the runtimes is all that’s necessary if base runtimes are excluded from the snap. + 2. Snappy packages are meant to support transactional updates. Such a transactional update is atomic and fully reversible, meaning you can use the application while its being updated and that if an update does not behave the way its supposed to, you can reverse the same with no other effects whatsoever. The concept is also called as **delta programming** in which only changes to the application are transmitted as an update instead of the whole package. An Ubuntu derivative called **Ubuntu Core** actually promises the snappy update protocol to the OS itself.[8] + 3. A key point of difference between snaps and AppImages, is how they handle version differences. Using AppImages different versions of the application will have different AppImages allowing you to concurrently use 2 or more different versions of the same application at the same time. However, using snaps means conforming to the transactional or delta update system. While this means faster updates, it keeps you from running two instances of the same application at the same time. If you need to use the old version of an app you’ll need to reverse or uninstall the new version. Snappy does support a feature called [**“parallel install”**][6] which will let users accomplish similar goals, however, it is still in an experimental stage and cannot be considered to be a stable implementation. Snappy also makes use of channels meaning you can use the beta or the nightly build of an app and the stable version at the same time.[9] + 4. Extensive support from major Linux distros and major developers including Google, Mozilla, Microsoft, etc.[4] + 5. Snapd the desktop integration tool supports taking **“snapshots”** of the current state of all the installed snaps in the system. This will let users save the current configuration state of all the applications that are installed via the Snappy package manager and let users revert to that state whenever they desire so. The same feature can also be set to automatically take snapshots at a frequency deemed necessary by the user. Snapshots can be created using the **snap save command** in the snapd framework.[10] + 6. Snaps are designed to be sandboxed during operation. This provides a much-required layer of security and isolation to users. Users need not worry about snap-based applications messing with the rest of the software on their computer. Sandboxing is implemented using three levels of isolation viz, **classic** , **strict** and **devmode**. Each level of isolation allows the app different levels of access within the file system and computer.[11] + + + +On the flip side of things, snaps are widely criticized for being centered around **Canonical’s modus operandi**. Most of the commits to the project are by Canonical employees or contractors and other contributors are required to sign a release form (CLA). The sandboxing feature, a very important one indeed from a security standpoint, is flawed in that the sandboxing actually requires certain other core services to run (such as Mir) while applications running the X11 desktop won’t support the said isolation, hence making the said security feature irrelevant. Questionable press releases and other marketing efforts from Canonical and the “central” and closed app repository are also widely criticized aspects of Snappy. Furthermore, the file sizes of the different snaps are also **comparatively very large** compared to the app sizes of the packages made using AppImage.[7] + +For more details, check [**Snap official documentation**][7]. + +* * * + +**Related read:** + + * [**Install Snap packages in Arch Linux, and Fedora**][8] + + + +* * * + +### 3\. Flatpak + +Like the Snap/Snappy listed above, **Flatpak** is also a software deployment tool that aims to ease software distribution and use in Linux. Flatpak was previously known as **“xdg-app”** and was based on concept proposed by **Lennart Poettering** in 2004. The idea was to contain applications in a secure virtual sandbox allowing for using applications **without the need of root privileges** and without compromising on the systems security. **Alex** started tinkering with Klik (thought to be a former version of AppImage) and wanted to implement the concept better. **Alexander Larsson** who at the time was working with Red Hat wrote an implementation called xdg-app in 2015 that acted as a pre-cursor to the current Flatpak format. + +Flatpak officially came out in 2016 with backing from Red Hat, Endless Computers and Collabora. **Flathub** is the official repository of all Flatpak application packages. At its surface Flatpak like the other is a framework for building and packaging distribution agnostic applications for Linux. It simply requires the developers to conform to a few desktop environment guidelines in order for the application to be successfully integrated into the Flatpak environment. + +Targeted primarily at the three popular desktop implementations **FreeDesktop** , **KDE** , and **GNOME** , the Flatpak framework itself is written in **C** and works on a **LGPL** license. The maintenance repository can be accessed via the GitHub link **[here][9]**. + +A few features of Flatpak that make it stand apart are mentioned below. Notice that features Flatpak shares with AppImage and Snappy are omitted here. + + * Deep integration into popular Linux desktop environments such as GNOME & KDE so that users can simply use Flatpaks using Graphical software management tools instead of resorting to the terminal. Flatpak can be installed from the default repositories of major desktop environments now and once the apps themselves are set-up they can be used and provide features similar to normal desktop applications.[12][13] + * **Forward-compatibility** – Flatpaks are built from the ground up keeping the operating systems core kernel and runtimes in mind. Hence, even if you upgrade or update your distro the Flatpaks you have should still work unless there is a core update. This is especially crucial for people who prefer staying on rolling betas or development versions of their distros. For such people, since the kinks of the OS itself isn’t ironed out usually, the Flatpak application will run seamlessly without having to depend on the OS files or libraries for its operation.[13] + * **Sandboxing using Bubblewrap** – snaps are also by default sandboxed in that they run in isolation from the rest of the applications running while you’re using your computer. However, Flatpaks fully seal the application from accessing OS files and user files during its operation by default. This essentially means that system administrators can be certain that Flatpaks that are installed in their systems cannot exploit the computer and the files it contains whereas for end users this will mean that in order to access a few specific functions or user data root permission is required.[14] + * Flatpak supports decentralized distribution of application natively however the team behind Flatpak still maintains a central online repository of apps/Flatpaks called **Flathub**. Users may in fact configure Flatpak to use multiple remote repositories as they see necessary. As opposed to snap you can have multiple repositories.[13] + * Modular access through the sandbox. Although this capability comes at a great potential cost to the integrity of the system, Flatpak framework allows for channels to be created through the sandbox for exchange of specific information from within the sandbox to the host system or vice versa. The channel is in this case referred to as a portal. A con to this feature is discussed later in the section.[14] + + + +One of the most criticized aspects of Flatpak however is it’s the sandbox feature itself. Sandboxing is how package managers such as Snappy and Flatpak implement important security features. Sandboxing essentially isolates the application from everything else in the system only allowing for user defined exchange of information from within the sandbox to outside. The flaw with the concept being that the sandbox cannot be inherently impregnable. Data has to be eventually transferred between the two domains and simple Linux commands can simply get rid of the sandbox restriction meaning that malicious applications might potentially jump out of the said sandbox.[15] + +This combined with the worse than expected commitment to rolling out security updates for Flatpak has resulted in widespread criticism of the team’s tall claim of providing a secure framework. The blog (named **flatkill** ) linked at the end of this guide in fact mentions a couple of exploits that were not addressed by the Flatpak team as soon as they should’ve been.[15] + +For more details, I suggest you to read [**Flatpak official documentation**][10]. + +* * * + +**Related read:** + + * [**A Beginners Guide To Flatpak**][11] + + + +* * * + +### AppImage vs Snap vs Flatpak + +The table attached below summarizes all the above findings into a concise and technical comparison of the three frameworks. + +**Feature** | **AppImage** | **Snappy** | **Flatpak** +---|---|---|--- +**Unique feature** | Not an appstore or repository, its simply put a packaging format for software distribution. | Led by Canonical (Same company as Ubuntu), features central app repository and active contribution from Canonical. | Features an app store called FlatHub, however, individuals may still host packages and distribute it. +**Target system** | Desktops and Servers. | Desktops, Servers, IoT devices, Embedded devices etc. | Desktops and limited function on servers. +**Libraries/Dependencies** | Base system. Runtimes optional, Libraries and other dependencies packaged. | Base system or via Plugins or can be packaged. | GNOME, KDE, Freedesktop bundled or custom bundled. +**Developers** | Community Driven led by Simon Peter. | Corporate driven by Canonical Ltd. | Community driven by flatpak team supported by enterprise. +**Written in** | C. | Golang, C and Python. | C. +**Initial release** | 2004. | 2014. | 2015. +**Sandboxing** | Can be implemented. | 3 modes – strict, classic, and devmode with varying confinement capabilities. Runs in isolation. | Isolated but Uses system files to run applications by default. +**Sandboxing Platform** | Firejail, AppArmor, Bubblewrap. | AppArmor. | Bubblewrap. +**App Installation** | Not necessary. Will act as self mounted disc. | Installation using snapd. | Installed using flatpak client tools. +**App Execution** | Can be run after setting executing bit. | Using desktop integrated snap tools. Runs isolated with user defined resources. | Needs to be executed using flatpak command if CLI is used. +**User Privileges** | Can be run w/o root user access. | Can be run w/o root user access. | Selectively required. +**Hosting Applications** | Can be hosted anywhere by anybody. | Has to be hosted with Canonical servers which are proprietary. | Can be hosted anywhere by anybody. +**Portable Execution from non system locations** | Yes. | No. | Yes, after flatpak client is configured. +**Central Repository** | AppImageHub. | Snap Store. | Flathub. +**Running multiple versions of the app** | Possible, any number of versions simultaneously. | One version of the app in one channel. Has to be separately configured for more. | Yes. +**Updating applications** | Using CLI command AppImageUpdate or via an updater tool built into the AppImage. | Requires snapd installed. Supports delta updating, will automatically update. | Required flatpak installed. Update Using flatpak update command. +**Package sizes on disk** | Application remains archived. | Application remains archived. | Client side is uncompressed. + +Here is a long tabular comparison of AppImage vs. Snap vs. Flatpak features. Please note that the comparison is made from an AppImage perspective. + + * [**https://github.com/AppImage/AppImageKit/wiki/Similar-projects#comparison**][12] + + + +### Conclusion + +While all three of these platforms have a lot in common with each other and aim to be platform agnostic in approach, they offer different levels of competencies in a few areas. While Snaps can run on a variety of devices including embedded ones, AppImages and Flatpaks are built with the desktop user in mind. AppImages of popular applications on the other had have superior packaging sizes and portability whereas Flatpak really shines with its forward compatibility when its used in a set it and forget it system. + +If there are any flaws in this guide, please let us know in the comment section below. We will update the guide accordingly. + +**References:** + + * **[1]** [**Concepts — AppImage documentation**][13] + * **[2]** [**Slashdot – Point-and-klik Linux Software Installation**][14] + * **[3]** [**History of AppImage project**][15] + * **[4][Snapcraft – Snaps are universal Linux packages][16]** + * **[5][Installing snapd – Snap documentation][17]** + * **[6][Snap documentation][7]** + * **[7][On Snappy and Flatpak: business as usual in the Canonical propaganda department][18]** + * **[8][Snap Updates are getting smaller, here’s why][19]** + * **[9][What Are Linux Snap Packages? Why Use Them?][20]** + * **[10][Snapshots – Snap documentation][21]** + * **[11][Snap confinement – Snap documentation][22]** + * **[12][Desktop Integration – Flatpak documentation][23]** + * **[13][Introduction to Flatpak – Flatpak documentation][24]** + * **[14][Sandbox Permissions – Flatpak documentation][25]** + * **[15][Flatpak – a security nightmare][26]** + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/linux-package-managers-compared-appimage-vs-snap-vs-flatpak/ + +作者:[editor][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/06/Linux-Package-Managers-Compared-1-720x340.png +[2]: https://github.com/AppImage/AppImageKit/blob/master/README.md +[3]: https://docs.appimage.org/ +[4]: https://www.ostechnix.com/search-linux-applications-on-appimage-flathub-and-snapcraft-platforms/ +[5]: https://snapcraft.io/store +[6]: https://blog.ubuntu.com/2019/06/20/parallel-installs-test-and-run-multiple-instances-of-snaps +[7]: https://docs.snapcraft.io/ +[8]: https://www.ostechnix.com/install-snap-packages-arch-linux-fedora/ +[9]: https://github.com/flatpak/flatpak +[10]: http://docs.flatpak.org/en/latest/index.html +[11]: https://www.ostechnix.com/flatpak-new-framework-desktop-applications-linux/ +[12]: https://github.com/AppImage/AppImageKit/wiki/Similar-projects#comparison +[13]: https://docs.appimage.org/introduction/concepts.html#one-app-one-file. +[14]: https://linux.slashdot.org/story/05/01/15/1815210/point-and-klik-linux-software-installation +[15]: https://github.com/AppImage/AppImageKit/wiki/History#timeline. +[16]: https://snapcraft.io/# +[17]: https://docs.snapcraft.io/installing-snapd +[18]: https://www.happyassassin.net/2016/06/16/on-snappy-and-flatpak-business-as-usual-in-the-canonical-propaganda-department/ +[19]: https://blog.ubuntu.com/2017/08/01/snap-updates-are-getting-smaller-heres-why +[20]: https://www.feliciano.tech/blog/what-are-linux-snap-packages-why-use-them/ +[21]: https://docs.snapcraft.io/snapshots +[22]: https://docs.snapcraft.io/snap-confinement +[23]: http://docs.flatpak.org/en/latest/desktop-integration.html?highlight=desktop%20integration +[24]: http://docs.flatpak.org/en/latest/introduction.html +[25]: http://docs.flatpak.org/en/latest/sandbox-permissions.html?highlight=sandboxing +[26]: https://flatkill.org/ diff --git a/sources/tech/20190625 The cost of JavaScript in 2019 - V8.md b/sources/tech/20190625 The cost of JavaScript in 2019 - V8.md new file mode 100644 index 0000000000..e21eefd5ad --- /dev/null +++ b/sources/tech/20190625 The cost of JavaScript in 2019 - V8.md @@ -0,0 +1,178 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The cost of JavaScript in 2019 · V8) +[#]: via: (https://v8.dev/blog/cost-of-javascript-2019) +[#]: author: (Addy Osmani https://twitter.com/addyosmani) + +The cost of JavaScript in 2019 · V8 +====== +**Note:** If you prefer watching a presentation over reading articles, then enjoy the video below! If not, skip the video and read on. + +[“The cost of JavaScript”][1] as presented by Addy Osmani at #PerfMatters Conference 2019. + +One large change to [the cost of JavaScript][2] over the last few years has been an improvement in how fast browsers can parse and compile script. **In 2019, the dominant costs of processing scripts are now download and CPU execution time.** + +User interaction can be delayed if the browser’s main thread is busy executing JavaScript, so optimizing bottlenecks with script execution time and network can be impactful. + +### Actionable high-level guidance # + +What does this mean for web developers? Parse & compile costs are **no longer as slow** as we once thought. The three things to focus on for JavaScript bundles are: + + * **Improve download time** + * Keep your JavaScript bundles small, especially for mobile devices. Small bundles improve download speeds, lower memory usage, and reduce CPU costs. + * Avoid having just a single large bundle; if a bundle exceeds ~50–100 kB, split it up into separate smaller bundles. (With HTTP/2 multiplexing, multiple request and response messages can be in flight at the same time, reducing the overhead of additional requests.) + * On mobile you’ll want to ship much less especially because of network speeds, but also to keep plain memory usage low. + * **Improve execution time** + * Avoid [Long Tasks][3] that can keep the main thread busy and can push out how soon pages are interactive. Post-download, script execution time is now a dominant cost. + * **Avoid large inline scripts** (as they’re still parsed and compiled on the main thread). A good rule of thumb is: if the script is over 1 kB, avoid inlining it (also because 1 kB is when [code caching][4] kicks in for external scripts). + + + +### Why does download and execution time matter? # + +Why is it important to optimize download and execution times? Download times are critical for low-end networks. Despite the growth in 4G (and even 5G) across the world, our [effective connection types][5] remain inconsistent with many of us running into speeds that feel like 3G (or worse) when we’re on the go. + +JavaScript execution time is important for phones with slow CPUs. Due to differences in CPU, GPU, and thermal throttling, there are huge disparities between the performance of high-end and low-end phones. This matters for the performance of JavaScript, as execution is CPU-bound. + +In fact, of the total time a page spends loading in a browser like Chrome, anywhere up to 30% of that time can be spent in JavaScript execution. Below is a page load from a site with a pretty typical workload (Reddit.com) on a high-end desktop machine:![][6]JavaScript processing represents 10–30% of time spent in V8 during page load. + +On mobile, it takes 3–4× longer for a median phone (Moto G4) to execute Reddit’s JavaScript compared to a high-end device (Pixel 3), and over 6× as long on a low-end device (the <$100 Alcatel 1X):![][7]The cost of Reddit’s JavaScript across a few different device classes (low-end, average, and high-end) + +**Note:** Reddit has different experiences for desktop and mobile web, and so the MacBook Pro results cannot be compared to the other results. + +When you’re trying to optimize JavaScript execution time, keep an eye out for [Long Tasks][8] that might be monopolizing the UI thread for long periods of time. These can block critical tasks from executing even if the page looks visually ready. Break these up into smaller tasks. By splitting up your code and prioritizing the order in which it is loaded, you can get pages interactive faster and hopefully have lower input latency.![][9]Long tasks monopolize the main thread. You should break them up. + +### What has V8 done to improve parse/compile? # + +Raw JavaScript parsing speed in V8 has increased 2× since Chrome 60. At the same time, raw parse (and compile) cost has become less visible/important due to other optimization work in Chrome that parallelizes it. + +V8 has reduced the amount of parsing and compilation work on the main thread by an average of 40% (e.g. 46% on Facebook, 62% on Pinterest) with the highest improvement being 81% (YouTube), by parsing and compiling on a worker thread. This is in addition to the existing off-main-thread streaming parse/compile.![][10]V8 parse times across different versions + +We can also visualize the CPU time impact of these changes across different versions of V8 across Chrome releases. In the same amount of time it took Chrome 61 to parse Facebook’s JS, Chrome 75 can now parse both Facebook’s JS AND 6 times Twitter’s JS.![][11]In the time it took Chrome 61 to parse Facebook’s JS, Chrome 75 can now parse both Facebook’s JS and 6 times Twitter’s JS. + +Let’s dive into how these changes were unlocked. In short, script resources can be streaming-parsed and-compiled on a worker thread, meaning: + + * V8 can parse+compile JavaScript without blocking the main thread. + * Streaming starts once the full HTML parser encounters a ` +``` + +_editor_url_  is a link to document editors. + +A button to open each file for viewing: + +``` + +``` + +Now we need to add a div with  _id_ , in which the document editor will be opened: + +``` +
      +``` + +To open the editor, we have to call a function: + +``` + +``` + +There are two arguments for the DocEditor function: id of the element where the editors will be opened and a JSON with the editors’ settings. +In this example, the following mandatory parameters are used: + + * _documentType_ is identified by its format (.docx, .xlsx, .pptx for texts, spreadsheets and presentations accordingly) + * _document.url_ is the link to the file you are going to open. + * _editorConfig.mode_. + + + +We can also add _title_ that will be displayed in the editors. + +So, now we have everything to view docs in our Python app. + +**3\. How to edit docs in ONLYOFFICE within the Python App** +First of all, add the “Edit” button: + +``` + +``` + +Then create a new function that will open files for editing. It is similar to the View function. +Now we have 3 functions: + +``` + +``` + +_destroyEditor_  is called to close an open editor. +As you might notice, the _editorConfig_ parameter is absent from the _edit()_ function, because it has by default the value * {“mode”: “edit”}.* + +Now we have everything to open docs for co-editing in your Python app. + +**4\. How to co-edit docs in ONLYOFFICE within the Python App** +Co-editing is implemented by using the same document.key for the same document in the editors’ settings. Without this key, the editors will create the editing session each time you open the file. + +Set unique keys for each doc to make users connect to the same editing session for co-editing. The format of the key should be the following:  _filename + “_key”_. The next step is to add it to all of the configs where document is present. + +``` +document: { +url: "host_url" + '/' + filepath, +title: filename, +key: filename + '_key' +}, +``` + +**5\. How to save docs in ONLYOFFICE within the Python App** +Every time we change and save the file, ONLYOFFICE stores all its versions. Let’s see closely how it works. After we close the editor, Document Server builds the file version to be saved and sends the request to callbackUrl address. This request contains document.key and the link to the just built file. +document.key is used to find the old version of the file and replace it with the new one. As we do not have any database here, we just send the filename using callbackUrl. +Specify _callbackUrl_ parameter in the setting in _editorConfig.callbackUrl_ and add it to the _edit()method_: + +``` +function edit(filename) { +const filepath = 'files/' + filename; +if (editor) { +editor.destroyEditor() +} +editor = new DocsAPI.DocEditor("editor", +{ +documentType: get_file_type(filepath), +document: { +url: "host_url" + '/' + filepath, +title: filename, +key: filename + '_key' +} +, +editorConfig: { +mode: 'edit', +callbackUrl: "host_url" + '/callback' + '&filename=' + filename // add file name as a request parameter +} +}); +} +``` + +Write a method that will save file after getting the POST request to* /callback* address: + +``` +@post("/callback") # processing post requests for /callback +def callback(): +if request.json['status'] == 2: +file = requests.get(request.json['url']).content +with open('files/' + request.query['filename'], 'wb') as f: +f.write(file) +return "{\"error\":0}" +``` + +* # status 2*  is the built file. + +When we close the editor, the new version of the file will be saved to storage. + +**6\. How to manage users in ONLYOFFICE within the Python App** +If there are users in your app, and you need to see who exactly is editing a doc, write their identifiers (id and name) in the editors’ configuration. +Add the ability to select a user in the interface: + +``` + +``` + +If you add the call of the function *pick_user()*at the beginning of the tag _<script>_, it will initialize, in the function itself, the variables responsible for the id and the user name. + +``` +function pick_user() { +const user_selector = document.getElementById("user_selector"); +this.current_user_name = user_selector.options[user_selector.selectedIndex].text; +this.current_user_id = user_selector.options[user_selector.selectedIndex].value; +} +``` + +Make use of _editorConfig.user.id_ and  _editorConfig.user.name_ to configure user’s settings. Add these parameters to the editors’ configuration in the file editing function. + +``` +function edit(filename) { +const filepath = 'files/' + filename; +if (editor) { +editor.destroyEditor() +} +editor = new DocsAPI.DocEditor("editor", +{ +documentType: get_file_type(filepath), +document: { +url: "host_url" + '/' + filepath, +title: filename +}, +editorConfig: { +mode: 'edit', +callbackUrl: "host_url" + '/callback' + '?filename=' + filename, +user: { +id: this.current_user_id, +name: this.current_user_name +} +} +}); +} +``` + +Using this approach, you can integrate ONLYOFFICE editors into your app written in Python and get all the necessary tools for working and collaborating on docs. For more integration examples (Java, Node.js, PHP, Ruby), please, refer to the official [_API documentation_][5]. + +**By: Maria Pashkina** + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/09/integrate-online-documents-editors-into-a-python-web-app-using-onlyoffice/ + +作者:[Aashima Sharma][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensourceforu.com/author/aashima-sharma/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2016/09/Typist-composing-text-in-laptop.jpg?resize=696%2C420&ssl=1 (Typist composing text in laptop) +[2]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2016/09/Typist-composing-text-in-laptop.jpg?fit=900%2C543&ssl=1 +[3]: https://www.onlyoffice.com/en/ +[4]: https://www.onlyoffice.com/en/developer-edition.aspx +[5]: https://api.onlyoffice.com/editors/basic diff --git a/sources/tech/20190924 Mutation testing by example- Failure as experimentation.md b/sources/tech/20190924 Mutation testing by example- Failure as experimentation.md new file mode 100644 index 0000000000..607e4e489c --- /dev/null +++ b/sources/tech/20190924 Mutation testing by example- Failure as experimentation.md @@ -0,0 +1,188 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Mutation testing by example: Failure as experimentation) +[#]: via: (https://opensource.com/article/19/9/mutation-testing-example-failure-experimentation) +[#]: author: (Alex Bunardzic https://opensource.com/users/alex-bunardzichttps://opensource.com/users/jocunddew) + +Mutation testing by example: Failure as experimentation +====== +Develop the logic for an automated cat door that opens during daylight +hours and locks during the night, and follow along with the .NET +xUnit.net testing framework. +![Digital hand surrounding by objects, bike, light bulb, graphs][1] + +In the [first article][2] in this series, I demonstrated how to use planned failure to ensure expected outcomes in your code. In this second article, I'll continue developing my example project—an automated cat door that opens during daylight hours and locks during the night. + +As a reminder, you can follow along using the .NET xUnit.net testing framework by following the [instructions here][3]. + +### What about the daylight hours? + +Recall that test-driven development (TDD) centers on a healthy amount of unit tests. + +The first article implemented logic that fulfills the expectations of the **Given7pmReturnNighttime** unit test. But you're not done yet. Now you need to describe the expectations of what happens when the current time is greater than 7am. Here is the new unit test, called **Given7amReturnDaylight**: + + +``` +       [Fact] +       public void Given7amReturnDaylight() +       { +           var expected = "Daylight"; +           var actual = dayOrNightUtility.GetDayOrNight(); +           Assert.Equal(expected, actual); +       } +``` + +The new unit test now fails (it is very desirable to fail as early as possible!): + + +``` +Starting test execution, please wait... +[Xunit.net 00:00:01.23] unittest.UnitTest1.Given7amReturnDaylight [FAIL] +Failed unittest.UnitTest1.Given7amReturnDaylight +[...] +``` + +It was expecting to receive the string value "Daylight" but instead received the string value "Nighttime." + +### Analyze the failed test case + +Upon closer inspection, it seems that the code has trapped itself. It turns out that the implementation of the **GetDayOrNight** method is not testable! + +Take a look at the core challenge we have ourselves in: + + 1. **GetDayOrNight relies on hidden input. ** +The value of **dayOrNight** is dependent upon the hidden input (it obtains the value for the time of day from the built-in system clock). + 2. **GetDayOrNight contains non-deterministic behavior. ** +The value of the time of day obtained from the system clock is non-deterministic. It depends on the point in time when you run the code, which we must consider unpredictable. + 3. **Low quality of the GetDayOrNight API.** +This API is tightly coupled to the concrete data source (system **DateTime**). + 4. **GetDayOrNight violates the single responsibility principle.** +You have implemented a method that consumes and processes information at the same time. It is a good practice that a method should be responsible for performing a single duty. + 5. **GetDayOrNight has more than one reason to change.** +It is possible to imagine a scenario where the internal source of time may change. Also, it is quite easy to imagine that the processing logic will change. These disparate reasons for changing must be isolated from each other. + 6. **The API signature of GetDayOrNight is not sufficient when it comes to trying to understand its behavior.** +It is very desirable to be able to understand what type of behavior to expect from an API by simply looking at its signature. + 7. **GetDayOrNight depends on global shared mutable state.** +Shared mutable state is to be avoided at all costs! + 8. **The behavior of the GetDayOrNight method cannot be predicted even after reading the source code.** +That is a scary proposition. It should always be very clear from reading the source code what kind of behavior can be predicted once the system is operational. + + + +### The principles behind what failed + +Whenever you're faced with an engineering problem, it is advisable to use the time-tested strategy of _divide and conquer_. In this case, following the principle of _separation of concerns_ is the way to go. + +> **separation of concerns** (**SoC**) is a design principle for separating a computer program into distinct sections, so that each section addresses a separate concern. A concern is a set of information that affects the code of a computer program. A concern can be as general as the details of the hardware the code is being optimized for, or as specific as the name of a class to instantiate. A program that embodies SoC well is called a modular program. +> +> ([source][4]) + +The **GetDayOrNight** method should be concerned only with deciding whether the date and time value means daylight or nighttime. It should not be concerned with finding the source of that value. That concern should be left to the calling client. + +You must leave it to the calling client to take care of obtaining the current time. This approach aligns with another valuable engineering principle—_inversion of control_. Martin Fowler explores this concept in [detail, here][5]. + +> One important characteristic of a framework is that the methods defined by the user to tailor the framework will often be called from within the framework itself, rather than from the user's application code. The framework often plays the role of the main program in coordinating and sequencing application activity. This inversion of control gives frameworks the power to serve as extensible skeletons. The methods supplied by the user tailor the generic algorithms defined in the framework for a particular application. +> +> \-- [Ralph Johnson and Brian Foote][6] + +### Refactoring the test case + +So the code needs refactoring. Get rid of the dependency on the internal clock (the **DateTime** system utility): + + +``` +` DateTime time = new DateTime();` +``` + +Delete the above line (which should be line 7 in your file). Refactor your code further by adding an input parameter **DateTime** time to the **GetDayOrNight** method. + +Here's the refactored class **DayOrNightUtility.cs**: + + +``` +using System; + +namespace app { +   public class DayOrNightUtility { +       public string GetDayOrNight(DateTime time) { +           string dayOrNight = "Nighttime"; +           if(time.Hour >= 7 && time.Hour < 19) { +               dayOrNight = "Daylight"; +           } +           return dayOrNight; +       } +   } +} +``` + +Refactoring the code requires the unit tests to change. You need to prepare values for the **nightHour** and the **dayHour** and pass those values into the **GetDayOrNight** method. Here are the refactored unit tests: + + +``` +using System; +using Xunit; +using app; + +namespace unittest +{ +   public class UnitTest1 +   { +       DayOrNightUtility dayOrNightUtility = [new][7] DayOrNightUtility(); +       DateTime nightHour = [new][7] DateTime(2019, 08, 03, 19, 00, 00); +       DateTime dayHour = [new][7] DateTime(2019, 08, 03, 07, 00, 00); + +       [Fact] +       public void Given7pmReturnNighttime() +       { +           var expected = "Nighttime"; +           var actual = dayOrNightUtility.GetDayOrNight(nightHour); +           Assert.Equal(expected, actual); +       } + +       [Fact] +       public void Given7amReturnDaylight() +       { +           var expected = "Daylight"; +           var actual = dayOrNightUtility.GetDayOrNight(dayHour); +           Assert.Equal(expected, actual); +       } + +   } +} +``` + +### Lessons learned + +Before moving forward with this simple scenario, take a look back and review the lessons in this exercise. + +It is easy to create a trap inadvertently by implementing code that is untestable. On the surface, such code may appear to be functioning correctly. However, following test-driven development (TDD) practice—describing the expectations first and only then prescribing the implementation—revealed serious problems in the code. + +This shows that TDD is the ideal methodology for ensuring code does not get too messy. TDD points out problem areas, such as the absence of single responsibility and the presence of hidden inputs. Also, TDD assists in removing non-deterministic code and replacing it with fully testable code that behaves deterministically. + +Finally, TDD helped deliver code that is easy to read and logic that's easy to follow. + +In the next article in this series, I'll demonstrate how to use the logic created during this exercise to implement functioning code and how further testing can make it even better. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/mutation-testing-example-failure-experimentation + +作者:[Alex Bunardzic][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alex-bunardzichttps://opensource.com/users/jocunddew +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003588_01_rd3os.combacktoschoolseriesk12_rh_021x_0.png?itok=fvorN0e- (Digital hand surrounding by objects, bike, light bulb, graphs) +[2]: https://opensource.com/article/19/9/mutation-testing-example-part-1-how-leverage-failure +[3]: https://opensource.com/article/19/8/mutation-testing-evolution-tdd +[4]: https://en.wikipedia.org/wiki/Separation_of_concerns +[5]: https://martinfowler.com/bliki/InversionOfControl.html +[6]: http://www.laputan.org/drc/drc.html +[7]: http://www.google.com/search?q=new+msdn.microsoft.com diff --git a/sources/tech/20190925 Essential Accessories for Intel NUC Mini PC.md b/sources/tech/20190925 Essential Accessories for Intel NUC Mini PC.md new file mode 100644 index 0000000000..a389db6d38 --- /dev/null +++ b/sources/tech/20190925 Essential Accessories for Intel NUC Mini PC.md @@ -0,0 +1,118 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Essential Accessories for Intel NUC Mini PC) +[#]: via: (https://itsfoss.com/intel-nuc-essential-accessories/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Essential Accessories for Intel NUC Mini PC +====== + +I bought a [barebone Intel NUC mini PC][1] a few weeks back. I [installed Linux on it][2] and I am totally enjoying it. This tiny fanless gadget replaces that bulky CPU of the desktop computer. + +Intel NUC mostly comes in barebone format which means it doesn’t have any RAM, hard disk and obviously no operating system. Many [Linux-based mini PCs][3] customize the Intel NUC and sell them to end users by adding disk, RAM and operating systems. + +Needless to say that it doesn’t come with keyboard, mouse or screen just like most other desktop computers out there. + +[Intel NUC][4] is an excellent device and if you are looking to buy a desktop computer, I highly recommend it. And if you are considering to get Intel NUC, here are a few accessories you should have in order to start using the NUC as your computer. + +### Essential Intel NUC accessories + +![][5] + +_The Amazon links in the article are affiliate links. Please read our [affiliate policy][6]._ + +#### The peripheral devices: monitor, keyboard and mouse + +This is a no-brainer. You need to have a screen, keyboard and mouse to use a computer. You’ll need a monitor with HDMI connection and USB or wireless keyboard-mouse. If you have these things already, you are good to go. + +If you are looking for recommendations, I suggest LG IPS LED monitor. I have two of them in 22 inch model and I am happy with the sharp visuals it provides. + +These monitors have a simple stand that doesn’t move. If you want a monitor that can move up and down and rotate in portrait mode, try [HP EliteDisplay monitors][7]. + +![HP EliteDisplay Monitor][8] + +I connect all three monitors at the same time in a multi-monitor setup. One monitor connects to the given HDMI port. Two monitors connect to thunderbolt port via a [thunderbolt to HDMI splitter from Club 3D][9]. + +You may also opt for the ultrawide monitors. I don’t have a personal experience with them. + +#### A/C power cord + +This will be a surprise for you When you get your NUC, you’ll notice that though it has power adapter, it’s not complete with the plug. + +![][10] + +Since different countries have different plug points, Intel decided to simply drop it from the NUC kit. I am using the power cord of an old dead laptop but if you don’t have one, chances are that you may have to get one for yourself. + +#### RAM + +Intel NUC has two RAM slots and it can support up to 32 GB of RAM. Since I have the core i3 processor, I opted from [8GB DDR4 RAM from Crucial][11] that costs around $33. + +![][12] + +8 GB RAM is fine for most cases but if you have core i7 processor, you may opt for a [16 GB RAM][13] one that costs almost $67. You can double it up and get the maximum 32 GB. The choice is all yours. + +#### Hard disk [Important] + +Intel NUC supports both 2.5 drive and M.2 SSD and you can use both at the same time to get more storage. + +The 2.5 inches slot can hold both SSD and HDD. I strongly recommend to opt for SSD because it’s way faster than HDD. A [480 GB 2.5][14] costs $60. Which is a fair price in my opinion. + +![][15] + +The 2.5″ drive is limited with the standard SATA interface speed of 6Gb/sec. The M.2 slot could be faster depending upon whether you are choosing a NVMe SSD or not. The NVMe (non volatile memory express) SSDs are up to 4 times faster than the normal SSDs (also called SATA SSD). But they may also be slightly more expensive than SATA M2 SSD. + +While buying the M.2 SSD, check the product image. It should be mentioned on the image of the disk itself whether it’s a NVMe or SATA SSD. [Samsung EVO is a cost effective NVMe M.2 SSD][16] that you may consider. + +![Make sure that your are buying the faster NVMe M2 SSD][17] + +A SATA SSD in both M.2 slot and 2.5″ slot has the same speed. This is why if you don’t want to opt for the expensive NVMe SSD, I suggest you go for the 2.5″ SATA SSD and keep the M.2 slot free for future upgrades. + +#### Other supporting accessories + +You’ll need HDMI cable to connect your monitor. If you are buying a new monitor, you should usually get a cable with it. + +You may need a screw driver if you are going to use the M.2 slot. Intel NUC is an excellent device and you can unscrew the bottom panel just by rotating the four pods simply by your hands. You’ll have to open the device in order to place the RAM and disk. + +![Intel NUC with Security Cable | Image Credit Intel][18] + +NUC also has the antitheft key lock hole that you can use with security cables. Keeping computers secure with cables is a recommended security practices in a business environment. Investing a [few dollars in the security cable][19] could save you hundreds of dollars. + +**What accessories do you use?** + +That’s the Intel NUC accessories I use and I suggest. How about you? If you own a NUC, what accessories you use and recommend to other NUC users? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/intel-nuc-essential-accessories/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.amazon.com/Intel-NUC-Mainstream-Kit-NUC8i3BEH/dp/B07GX4X4PW?psc=1&SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B07GX4X4PW (barebone Intel NUC mini PC) +[2]: https://itsfoss.com/install-linux-on-intel-nuc/ +[3]: https://itsfoss.com/linux-based-mini-pc/ +[4]: https://www.intel.in/content/www/in/en/products/boards-kits/nuc.html +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/intel-nuc-accessories.png?ssl=1 +[6]: https://itsfoss.com/affiliate-policy/ +[7]: https://www.amazon.com/HP-EliteDisplay-21-5-Inch-1FH45AA-ABA/dp/B075L4VKQF?SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B075L4VKQF (HP EliteDisplay monitors) +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/hp-elitedisplay-monitor.png?ssl=1 +[9]: https://www.amazon.com/Club3D-CSV-1546-USB-C-Multi-Monitor-Splitter/dp/B06Y2FX13G?SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B06Y2FX13G (thunderbolt to HDMI splitter from Club 3D) +[10]: https://itsfoss.com/wp-content/uploads/2019/09/ac-power-cord-3-pongs.webp +[11]: https://www.amazon.com/Crucial-Single-PC4-19200-SODIMM-260-Pin/dp/B01BIWKP58?psc=1&SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B01BIWKP58 (8GB DDR4 RAM from Crucial) +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/crucial-ram.jpg?ssl=1 +[13]: https://www.amazon.com/Crucial-Single-PC4-19200-SODIMM-260-Pin/dp/B019FRBHZ0?psc=1&SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B019FRBHZ0 (16 GB RAM) +[14]: https://www.amazon.com/Green-480GB-Internal-SSD-WDS480G2G0A/dp/B01M3POPK3?psc=1&SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B01M3POPK3 (480 GB 2.5) +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/wd-green-ssd.png?ssl=1 +[16]: https://www.amazon.com/Samsung-970-EVO-500GB-MZ-V7E500BW/dp/B07BN4NJ2J?psc=1&SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B07BN4NJ2J (Samsung EVO is a cost effective NVMe M.2 SSD) +[17]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/samsung-evo-nvme.jpg?ssl=1 +[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/intel-nuc-security-cable.jpg?ssl=1 +[19]: https://www.amazon.com/Kensington-Combination-Laptops-Devices-K64673AM/dp/B005J7Y99W?psc=1&SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B005J7Y99W (few dollars in the security cable) diff --git a/translated/talk/20180117 How technology changes the rules for doing agile.md b/translated/talk/20180117 How technology changes the rules for doing agile.md new file mode 100644 index 0000000000..4c5b66f133 --- /dev/null +++ b/translated/talk/20180117 How technology changes the rules for doing agile.md @@ -0,0 +1,97 @@ +技术如何改变敏捷的规则 +====== + +![](https://enterprisersproject.com/sites/default/files/styles/620x350/public/images/CIO%20Containers%20Ecosystem.png?itok=lDTaYXzk) + +越来越多的企业正因为一个非常明显的原因开始尝试敏捷和[DevOps][1]: 企业需要通过更快的速度和更多的实验为创新和竞争性提供优势。而DevOps将帮助我们得到所需的创新速度。但是,在小团队或初创企业中实践DevOps与进行大规模实践完全是两码事。我们都明白这样的一个事实,那就是在10人的跨职能团队中能够很好地解决问题的方案,当将相同的模式应用到100人的团队中时就可能无法奏效。这条道路是如此艰难,以至于IT领导者很容易将敏捷方法的推行再推迟一年。 + +但那样的时代已经结束了。如果你已经尝试过,但是没有成功,那么现在是时候重新开始了。 + +直到现在,DevOps需要为许多组织提供个性化的解决方案,因此往往需要进行大量的调整以及付出额外的工作。但在今天,[Linux容器][2]和Kubernetes正在推动DevOps工具和过程的标准化。而这样的标准化将会加速整个软件开发过程。因此,我们用来实践DevOps工作方式的技术最终能够满足我们加快软件开发速度的愿望。 + +Linux容器和[Kubernetes][3]正在改变团队交互的方式。此外,你可以在Kubernetes平台上运行任何能够在Linux运行的应用程序。这意味着什么呢?你可以运行大量的企业及应用程序(甚至可以解决以前令人烦恼的Windows和Linux之间的协调问题)。最后,容器和Kubernetes将能够满足未来所有运行内容的需求。它们正在经受着未来的考验,以应对机器学习、人工智能和分析工作等下一代解决问题工具。 + +**[ 参考相关文章,[4 container adoption patterns: What you need to know. ] ][4]** + +让我们以机器学习为例来思考一下。今天,人们可以在大量的企业数据中找到一些模式。当机器发现这些模式时(想想机器学习),你的员工就能更快地采取行动。随着人工智能的加入,机器不仅可以发现模式,还可以对模式进行操作。如今,三个星期已经成为了一个积极的软件开发冲刺周期。有了人工智能,机器每秒可以多次修改代码。创业公司会利用这种能力来“打扰你”。 + +考虑一下你需要多快才能参与到竞争当中。如果你对于无法对于DevOps和每周一个迭代周期充满信心,那么考虑一下当那个创业公司将AI驱动的过程指向你时会发生什么?现在是时候转向DevOps的工作方式了,否认就会像你的竞争对手一样被甩在后面。 + +### 容器技术如何改变团队的工作? + +DevOps使得许多试图将这种工作方式扩展到更大范围的团队感到沮丧。即使许多IT(和业务)人员之前都听说过敏捷相关的语言、框架、模型(如DevOps)等承诺将会彻底应用程序开发和IT过程的全部相关内容,但他们还是对此持怀疑态度。 + +**[ 想要获取来自其他CIO们的建议吗?不放参考下我们的综述性资源, [DevOps: The IT Leader's Guide][5]. ]** + +向你的涉众“推销”快速开发冲刺也不是一件容易的事情。想象一下,如果你以这种方式买了一栋房子:你将不再需要向开发商支付固定的金额,而是会得到这样的信息:“我们将在4周内浇筑完地基,其成本是X,之后再搭建房屋框架和铺设电路,但是我们现在只能够知道地基完成的时间表。”人们已经习惯了买房子的时候有一个预先的价格和交付时间表。 + +挑战在于构建软件与构建房屋不同。同一个建筑商往往建造了成千上万个完全相同的房子,而软件项目从来都各不相同。这是你要克服的第一个障碍。 + +开发和运维团队的工作方式确实不同,我之所以知道这一点是因为我曾经从事过这两方面的工作。企业往往会用不同的方式来激励他们,开发人员会因为更改和创建而获得奖励,而运维专家则会因降低成本和确保安全性而获得奖励。我们会把他们分成不同的小组,并且尽量减少互动。而这些角色通常会吸引那些思维方式完全不同的技术人员。但是这样的解决方案注定会失败,你必须打破横亘在开发和运维之间的藩篱。 + +想想传统情况下会发生什么。业务会把需求扔过墙,这是因为他们在“买房”模式下运作,并且说上一句“我们9个月后见。”开发人员根据这些需求进行开发,并根据技术约束的需要进行更改。然后,他们把它扔过墙传递给运维人员,并说一句“搞清楚如何运行这个软件”。然后,运维人员勤就会奋地进行大量更改,使软件与基础设施保持一致。然而,最终的结果是什么呢? + +通常情况下,当业务人员看到需求实现的最终结果时甚至根本辨认不出。在过去20年的大部分时间里,我们一次又一次地目睹了这种模式在软件行业中上演。而现在,是时候改变了。 + +Linux容器能够真正地解决这样的问题,这是因为容器缩小了开发和运维之间的间隙。容器技术允许两个团队共同理解和设计所有的关键需求,但仍然独立地履行各自团队的职责。基本上,我们去掉了开发人员和运维人员之间的电话游戏。 + +因为容器技术,我们可以使得运维团队的规模更小,但依旧能够承担起数百万应用程序的运维工作,并且能够使得开发团队可以更加快速地根据需要更改软件。(在较大的组织中,所需的速度可能比运维人员的响应速度更快。) + +使用容器,您可以将所需要交付的内容与它运行的位置分开。你的运维团队只需要负责运行容器的主机和安全的内存占用,仅此而已。这意味着什么呢? + +首先,这意味着你现在可以和团队一起实践DevOps了。没错,只需要让团队专注于他们已经拥有的专业知识,而对于容器,只需让团队了解所需集成依赖关系的必要知识即可。 + +如果你想要重新训练每个人,往往会收效甚微。容器技术允许团队之间进行交互,但同时也会为每个团队提供一个围绕该团队优势而构建的强大边界。开发人员会知道需要消耗什么,但不需要知道如何使其大规模运行。运维团队了解核心基础设施,但不需要了解应用程序的细节。此外,运维团队也可以通过更新应用程序来解决新的安全问题,以免你成为下一个数据泄露的热门话题。 + +想要为一个大型IT组织,比如30000人的团队教授运维和开发技能?那或许需要花费你十年的时间,而你可能并没有那么多时间。 + +当人们谈论“构建新的云原生应用程序将帮助我们摆脱这个问题”时,请批判性地进行思考。你可以在10个人的团队中构建云原生应用程序,但这对《财富》杂志前1000强的企业而言或许并不适用。除非你不再需要依赖现有的团队,否则你无法一个接一个地构建新的微服务:你最终将得到一个竖井式的组织。这是一个诱人的想法,但你不能指望这些应用程序来重新定义你的业务。我还没见过哪家公司能在如此大规模的并行开发中获得成功。IT预算已经受到限制;在很长一段时间内将预算翻倍甚至三倍是不现实的。 + +### 当奇迹发生时: 你好, 速度 + +Linux容器就是为扩容而生的。一旦你开始这样做,[Kubernetes之类的编制工具就会发挥作用][6],这是因为你将需要运行数千个容器。应用程序将不仅仅由一个容器组成,它们将依赖于许多不同的部分,所有的部分都会作为一个单元运行在容器上。如果不这样做,你的应用程序将无法在生产环境中很好地运行。 + +思考一下有多少小滑轮和杠杆组合在一起来支撑你的业务,对于任何应用程序都是如此。开发人员负责应用程序中的所有滑轮和杠杆。(如果开发人员没有这些组件,您可能会在集成时做噩梦。)与此同时,无论是在线下还是在云上,运维团队都会负责构成基础设施的所有滑轮和杠杆。做一个较为抽象的比喻,使用Kubernetes,你的运维团队就可以为应用程序提供运行所需的燃料,但又不必成为所有方面的专家。 + +开发人员进行实验,运维团队则保持基础设施的安全和可靠。这样的组合使得企业敢于承担小风险,从而实现创新。不同于打几个孤注一掷的赌,公司中真正的实验往往是循序渐进的和快速的。 + +从个人经验来看,这就是组织内部发生的显著变化:因为人们说:“我们如何通过改变计划来真正地利用这种能力进行实验?”它强制执行敏捷计划。 + +举个例子,使用DevOps模型、容器和Kubernetes的KeyBank如今每天都会部署代码。(观看视频[7],其中主导了KeyBank持续交付和反馈的John Rzeszotarski将解释这一变化。)类似地,Macquarie银行也借助DevOps和容器技术每天将一些东西投入生产环境。 + +一旦你每天都推出软件,它就会改变你计划的每一个方面,并且会[加速业务的变化速度][8]。Macquarie银行和金融服务集团的CDO,Luis Uguina表示:“创意可以在一天内触达客户。”(参见[9]对Red Hat与Macquarie银行合作的案例研究)。 + +### 是时候去创造一些伟大的东西了 + +Macquarie的例子说明了速度的力量。这将如何改变你的经营方式?记住,Macquarie不是一家初创企业。这是CIO们所面临的颠覆性力量,它不仅来自新的市场进入者,也来自老牌同行。 + +开发人员的自由还改变了运营敏捷商店的CIO们的人才方程式。突然之间,大公司里的个体(即使不是在最热门的行业或地区)也可以产生巨大的影响。Macquarie利用这一变动作为招聘工具,并向开发人员承诺,所有新招聘的员工将会在第一周内推出新产品。 + +与此同时,在这个基于云的计算和存储能力的时代,我们比以往任何时候都拥有更多可用的基础设施。考虑到[机器学习和人工智能工具将很快实现的飞跃][10],这是幸运的。 + +所有这些都说明现在正是打造伟大事业的好时机。考虑到市场创新的速度,你需要不断地创造伟大的东西来保持客户的忠诚度。因此,如果你一直在等待将赌注押在DevOps上,那么现在就是正确的时机。容器技术和Kubernetes改变了规则,并且对你有利。 + +**想要获取更多这样的智慧吗, IT领导者? [订阅每周邮件][11].** + +-------------------------------------------------------------------------------- + +via: https://enterprisersproject.com/article/2018/1/how-technology-changes-rules-doing-agile + +作者:[Matt Hicks][a] +译者:[JayFrank](https://github.com/JayFrank) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://enterprisersproject.com/user/matt-hicks +[1]:https://enterprisersproject.com/tags/devops +[2]:https://www.redhat.com/en/topics/containers?intcmp=701f2000000tjyaAAA +[3]:https://www.redhat.com/en/topics/containers/what-is-kubernetes?intcmp=701f2000000tjyaAAA +[4]:https://enterprisersproject.com/article/2017/8/4-container-adoption-patterns-what-you-need-know?sc_cid=70160000000h0aXAAQ +[5]:https://enterprisersproject.com/devops?sc_cid=70160000000h0aXAAQ +[6]:https://enterprisersproject.com/article/2017/11/how-enterprise-it-uses-kubernetes-tame-container-complexity +[7]:https://www.redhat.com/en/about/videos/john-rzeszotarski-keybank-red-hat-summit-2017?intcmp=701f2000000tjyaAAA +[8]:https://enterprisersproject.com/article/2017/11/dear-cios-stop-beating-yourselves-being-behind-transformation +[9]:https://www.redhat.com/en/resources/macquarie-bank-case-study?intcmp=701f2000000tjyaAAA +[10]:https://enterprisersproject.com/article/2018/1/4-ai-trends-watch +[11]:https://enterprisersproject.com/email-newsletter?intcmp=701f2000000tsjPAAQ diff --git a/translated/tech/20140510 Managing Digital Files (e.g., Photographs) in Files and Folders.md b/translated/tech/20140510 Managing Digital Files (e.g., Photographs) in Files and Folders.md new file mode 100644 index 0000000000..8455eb1d6d --- /dev/null +++ b/translated/tech/20140510 Managing Digital Files (e.g., Photographs) in Files and Folders.md @@ -0,0 +1,611 @@ + + + + +数码文件与文件夹收纳术(以照片为例) +====== +更新 2014-05-14:增加了一些具体实例 + +更新 2015-03-16:根据照片的 GPS 坐标过滤图片 + +更新 2016-08-29:以新的 `filetags--filter` (LCTT译注:文件标签过滤器)替换已经过时的 `show-sel.sh` 脚本(LCTT译注:show-sel 为 show firmware System Event Log records 即硬件系统事件及日志显示) + +更新 2017-08-28: geeqier 视频缩略图的邮件评论 + +每当度假或去哪游玩时我就会化身为一个富有激情的摄影师。所以,过去的几年中我积累了许多的 [JPEG][1] 文件。这篇文章中我会介绍我是如何避免[vendor lock-in][2](LCTT译注:vendor lock-in 供应商锁定,原为经济学术语,这里引申为避免过于依赖某一服务平台)造成受限于那些临时性的解决方案及数据丢失。相反,我更倾向于使用那些可以让我投入时间和精力打理并能长久使用的解决方案。 + +这一(相当长的)攻略 **并不仅仅适用于图像文件** :我将进一步阐述像是文件夹结构,文件的命名规则,等等许多领域的事情。因此,这些规范适用于我所能接触到的所以类型的文件。 + +在我开始传授我的方法之前,我们应该先就我将要介绍方法的达成一个共识,那就是我们是否有相同的需求。如果你对[raw 图像格式][3]十分推崇,将照片存储在云端或其他你信赖的地方(对我而言可能不会),那么你可能不会认同这篇文章将要描述的方式了。请根据你的情况来灵活做出选择。 + +### 我的需求 + +对于 **将照片(或视频)从我的数码相机中导出到电脑里**,我仅仅将 SD 卡茶道我的电脑里并调用 fetch-workflow 软件。这一步也完成了 **图像软件的预处理** 适用于我提出的文件命名规范(下文会具体论述)同时也可以将图片旋转至正常的方向(而不是横着)。 + +这些文件将会被存入到我的摄影收藏文件夹 `$HOME/tmp/digicam/`。 在这一文件夹中我希望能完成以下的操作 **浏览图像和视频文件** 以便于 **整理排序/删除,重命名,添加/移除标签,以及将一系列相关的文件移动到相应的文件夹中**。 + +在完成这些以后,我将会**浏览包含图像/电影文件集的文件夹**。在极少数情况下,我希望**在独立的图像处理工具**中打开一个图像文件,比如[GIMP][4]。如果仅是为了**旋转JPEG文件**,我想找到一个快速的方法,不需要图像处理工具,这是旋转JPEG图像[无损的方式][5]。 + +我的数码相机支持用[GPS][6]坐标标记图像。因此,我需要一个方法来**可视化GPS坐标的单个文件以及一组文件**显示我走过的路径。 + +我想安利的另一个好功能是:假设你在威尼斯度假时拍了几百张照片。每一个都很漂亮,所以你每张都舍不得删除。另一方面,你可能想要一组更小的照片,送给家里的朋友。而且,为了不让他们过于嫉妒,他们可能只希望看到20多张照片。因此,我希望能够**定义并显示一组特定的照片**。 + +就独立性和**避免锁定效应**而言,我不想使用那种一旦公司停止产品或服务就无法使用的工具。出于同样的原因,由于我是一个注重隐私的人,**我不想使用任何基于云的服务**。为了让自己对新的可能性保持开放的心态,我不希望仅在一个特定的操作系统平台上倾注全部的精力。**基本的东西必须在任何平台上可用**(查看、导航、……)。但是**全套需求必须在GNU/Linux上运行**且我选择Debian GNU/Linux。 + +在我传授当前针对上述大量需求的解决方案之前,我必须解释一下我的一般文件夹结构和文件命名约定,我也使用它来命名数码照片。但首先,你必须考虑一个重要的事实: + +#### iPhoto, Picasa, 诸如此类应被认为是有害的 + +管理照片集合的软件工具确实提供了相当酷的功能。他们提供了一个良好的用户界面,并试图为你提供各种需求的舒适的工作流程。 + +这些软件的功能和我的个人需求之间的差异很大。它们几乎对所有东西都使用专有的存储格式:图像文件、元数据等等。这是一个大问题,当你打算在几年内换一个不同的软件。相信我:总有一天你会因为多种原因而改变。 + +如果你现在正打算更换 相应的工具,你将会意识到iPhoto或Picasa确实分别存储原始图像文件和你对它们所做的所有操作。旋转图像,向图像文件添加描述,标签,裁剪,等等,如果你不能导出并重新导入到新工具,那么**所有的东西都将永远丢失**。而无损的进行转换和迁移几乎是不可能的。 + +我不想在一个锁住我工作的工具上投入任何精力。**我也拒绝把自己锁在任何专有工具上**。我是一个过来人,希望你们吸取我的经验。 + +这就是我在文件名中保留时间戳、图像描述或标记的原因。文件名是永久性的,除非我手动更改它们。当我把照片备份或复制到u盘或其他操作系统时,它们不会丢失。每个人都能读懂。任何未来的系统都能够处理它们。 + +### 我的文件命名约定 + +我所有的文件都与一个特定的日期或时间有关,根据所采用的[ISO 8601][7]规范,我采用的是**日期-标记**或**时间-标记** +带有日期戳和两个标签的示例文件名:`2014-05-09 42号项目的预算 -- 金融公司.csv` + +带有时间戳(甚至包括可选秒)和两个标签的示例文件名:`2014-05-09T22.19.58 Susan展示她的新鞋子 -- 家庭衣物.jpg` + +由于冒号不适用于Windows[文件系统NTFS][8],所以我必须使用已采用的ISO时间戳。因此,我用点代替冒号,以便将小时与分钟区别开来。 + +如果是**时间或日期持续时间**,我将两个日期或时间戳用两个负号分开:`2014-05-09—2014-05-13爵士音乐节Graz—folder 旅游音乐.pdf`。 + +文件名中的时间/日期戳的优点是,除非我手动更改它们,否则它们保持不变。当通过某些不处理这些元数据的软件进行处理时,包含在文件内容本身中的元数据(如[Exif][9])往往会丢失。此外,使用这样的日期/时间戳启动文件名可以确保文件按时间顺序显示,而不是按字母顺序显示。字母表是一种[完全人工的排序顺序][10],对于用户定位文件通常不太实用。 + +当我想将**tags**关联到文件名时,我将它们放在原始文件名和[文件名扩展名][11]之间,中间用空格、两个减号和一个额外的空格分隔"`--`"。我的标签是小写的英文单词,不包含空格或特殊字符。有时,我可能会使用`quantifiedself`或`usergenerated`等连接词。我[倾向于选择一般类别][12],而不是太过具体的描述标签。我用这一方式在Twitter [hashtags][13]上重用标记、文件名、文件夹名、书签、诸如此类的博客条目等等。 + +标签作为文件名的一部分有几个优点。通过使用常用的桌面搜索引擎,你可以在标签的帮助下定位文件。文件名称中的标签不能因为在不同的存储介质上复制而丢失。当系统使用与文件名不同的存储位置如:元数据数据库、[dot-files][14]、[备用数据流][15]等,通常会发生这种情况 + +当然,在一般的文件和文件夹名称中,**请避免使用特殊字符**,umlauts,冒号等。尤其是在不同操作系统平台之间同步文件时。 + +我的**文件夹名命名约定**与文件的相应规范相同。 + +注意:由于[Memacs][17]的[filenametimestamp][16]-module的聪明之处,所有带有日期/时间戳的文件和文件夹都在同一时间/天出现在我的组织模式日历(agenda)上。这样,我就能很好地了解当天发生了什么,包括我拍的所有照片。 + +### 我的一般文件夹结构 + +在本节中,我将描述主文件夹中最重要的文件夹。注意:这可能在将来的被移动到一个独立的页面。或许不是。让我们等着瞧:-) +很多东西只有在一定的时间内才会引起人们的兴趣。这些内容包括快速浏览其内容的下载、解压缩文件以检查包含的文件、一些有趣的小内容等等。对于**临时的东西**,我有 `$HOME/tmp/ ` 子层次结构。新照片放在`$HOME/tmp/digicam/`中。我从CD、DVD或USB记忆棒临时复制的东西放在`$HOME/tmp/fromcd/`中。每当软件工具需要用户文件夹层次结构中的临时数据时,我就使用` $HOME/tmp/Tools/ `作为起点。我经常使用的文件夹是`$HOME/tmp/2del/`:`2del`的意思是“随时可以删除”。例如,我所有的浏览器都使用这个文件夹作为默认的下载文件夹。如果我需要在机器上腾出空间,我首先查看这个`2del`-文件夹,用于删除内容。 + +与上面描述的临时文件相比,我当然也想将文件**保存更长的时间**。这些文件被移动到我的`$HOME/archive/`子层次结构中。它有几个子文件夹备份,web /下载我想保留,二进制文件我要存档,索引文件的可移动媒体(CD, DVD,记忆棒、外部硬盘驱动器),和一个文件夹用来存档(和寻找一个合适的的目标文件夹)在不久的将来。有时,我太忙或没有耐心的时候将文件妥善整理。是的,那就是我,我甚至有一个名为`现在不要整理我`的文件夹。这对你而言是否很怪?:-) + +我的归档中最重要的子层次结构是 `$HOME/archive/events_memories/ `及其子文件夹` 2014/ `、` 2013/ `、` 2012/ `等等。正如你可能已经猜到的,每个年份有一个**子文件夹**。其中每个文件中都有单个文件和文件夹。这些文件是根据我在前一节中描述的文件名约定命名的。文件夹名称符合“YYYY-MM-DD”[ISO 8601][7] 日期标签开头,后面跟着一个具有描述性的名称,如`$HOME/archive/events_memories/2014/2014-05-08 Business marathon with /`。在这些与日期相关的文件夹中,我保存着各种与特定事件相关的文件:照片、(扫描的)pdf文件、文本文件等等。 + +对于**共享数据**,我设置一个`$HOME/share/`子层次结构。这是我的Dropbox文件夹,我用各种各样的方法(比如[unison][18])来分享数据。我也在我的设备之间共享数据:家里的Mac Mini,家里的GNU/Linux笔记本,Android手机,root-server(我的个人云),工作时的windows笔记本。我不想在这里详细说明我的同步设置。如果你想了解相关的设置,可以参考另一篇相关的文章。:-) + +在我的` $HOME/ templates_tags / `子层次结构中,我保存了各种**模板文件** ([LaTeX][19], 脚本,…),剪辑和**logos**,等等。 + +我的**Org-mode**文件,主要是保存在`$ HOME /org/`。我练习保持记忆,并没有解释我有多喜欢 [Emacs/Org-mode][20]以及这我从中获益多少。你可能读过或听过我详细描述我用它做的很棒的事情。具体可以在我的博客上查找[我的' emacs '标签][21],在twitter上查找[hashtag ' #orgmode '][22]。 + +以上就是我最重要的文件夹子层次结构设置方式。 + +### 我的工作流程 + +Tataaaa,在你了解了我的文件夹结构和文件名约定之后,下面是我当前的工作流程和工具,我使用它们来满足我前面描述的需求。 +请注意,**你必须知道你在做什么**。我这里的示例及文件夹路径和更多只**适用我的机器或我的设置的文件夹路径。**你必须采用**相应的路径、文件名等**来满足你的需求! + +#### 工作流程:将文件从SD卡移动到笔记本电脑,旋转人像图像,并重命名文件 + +当我想把数据从我的数码相机移到我的GNU/Linux笔记本上时,我拿出它的mini sd存储卡,把它放在我的笔记本上。然后它会自动挂载在` /media/digicam `上。 + +然后,调用[getdigicamdata]。它做了如下几件事:它将文件从SD卡移动到一个临时文件夹中进行处理。原始文件名会转换为小写字符。使用[jhead][24]旋转所有人像照片。同样使用jhead,我从Exif头时间戳生成文件名称时间戳。使用[date2name][25],我将时间戳添加到电影文件中。处理完所有这些文件后,它们将被移动到新的digicam文件的目标文件夹:$HOME/tmp/digicam/tmp/~。 + +#### 工作流程:文件夹索引、查看、重命名、删除图像文件 + +为了快速浏览我的图像和电影文件,我更喜欢在GNU/Linux上使用[geeqie][26]。这是一个相当轻量级的图像浏览器,它具有其他文件浏览器所缺少的一大优势:我可以通过键盘快捷方式调用的外部脚本/工具。通过这种方式,我可以通过任意的外部命令扩展图像浏览器的特性。 + +基本的图像管理功能是内置在geeqie:索引我的文件夹层次结构,在窗口模式或全屏查看图像(快捷键' f '),重命名文件名,删除文件,显示Exif元数据(快捷键` Ctrl-e `)。 + +在OS X上,我使用[Xee][27]。与geeqie不同,它不能通过外部命令进行扩展。不过,基本的导航、查看和重命名功能也是可用的。 + +#### 工作流:添加和删除标签 + +我创建了一个名为[filetags][28]的Python脚本,用于向单个文件以及一组文件添加和删除标记。 + +对于数码照片,我使用标签,例如,`specialL`用于我认为适合桌面背景的风景图片,`specialP`用于我想展示给其他人的人像照片,`sel`用于筛选,等等。 + +##### 使用geeqie初始设置文件标签 + +向geeqie添加文件标签是一个手动步骤:`编辑>首选项>配置编辑器…`然后创建一个带有`New`的附加条目。在这里,你可以定义一个新的桌面文件,如下所示: + +add-tags.desktop +``` +[Desktop Entry] +Name=filetags +GenericName=filetags +Comment= +Exec=/home/vk/src/misc/vk-filetags-interactive-adding-wrapper-with-gnome-terminal.sh %F +Icon= +Terminal=true +Type=Application +Categories=Application;Graphics; +hidden=false +MimeType=image/*;video/*;image/mpo;image/thm +Categories=X-Geeqie; + +``` + +包装器脚本的`vk-filetags-interactive-adding-wrapper-with-gnome-terminal.sh `是必须的,因为我想要弹出一个新的终端,以便添加标签到我的文件: + +vk-filetags-interactive-adding-wrapper-with-gnome-terminal.sh +``` +#!/bin/sh + +/usr/bin/gnome-terminal \ + --geometry=85x15+330+5 \ + --tab-with-profile=big \ + --hide-menubar \ + -x /home/vk/src/filetags/filetags.py --interactive "${@}" + +#end + +``` + +在geeqie中,你可以在` Edit > Preferences > Preferences…>键盘`。我将`t`与`filetags`命令相关联。 + +标签脚本还能够从单个文件或一组文件中删除标记。它基本上使用与上面相同的方法。唯一的区别是文件标签脚本额外的`--remove`参数: + +remove-tags.desktop +``` +[Desktop Entry] +Name=filetags-remove +GenericName=filetags-remove +Comment= +Exec=/home/vk/src/misc/vk-filetags-interactive-removing-wrapper-with-gnome-terminal.sh %F +Icon= +Terminal=true +Type=Application +Categories=Application;Graphics; +hidden=false +MimeType=image/*;video/*;image/mpo;image/thm +Categories=X-Geeqie; + +``` + +vk-filetags-interactive-removing-wrapper-with-gnome-terminal.sh +``` +#!/bin/sh + +/usr/bin/gnome-terminal \ + --geometry=85x15+330+5 \ + --tab-with-profile=big \ + --hide-menubar \ + -x /home/vk/src/filetags/filetags.py --interactive --remove "${@}" + +#end + +``` + +为了删除标签,我为`T`参数创建了一个键盘快捷方式。 + +##### 在geeqie中使用文件标签 + +当我在geeqie文件浏览器中浏览图像文件时,我选择要标记的文件(一到多个)并按`t`。然后,一个小窗口弹出,要求我提供一个或多个标签。在与` Return `确认后,这些标签被添加到文件名中。 + +删除标签也是一样:选择多个文件,按下`T`,输入要删除的标签,然后用`Return`确认。就是这样。几乎没有[更简单的方法来添加或删除标签到文件][29]。 + +#### 工作流:使用appendfilename重命名高级文件 + +##### 不使用 appendfilename + +重命名一组大型文件可能是一个冗长乏味的过程。对于`2014-04-20T17.09.11_p1100386.jpg`这样的原始文件名,在文件名中添加描述的过程相当烦人。你将按`Ctrl-r`(重命名)在geeqie打开文件重命名对话框。默认情况下,原始名称(没有文件扩展名的文件名称)被标记。因此,如果不希望删除/覆盖文件名(但要追加),则必须按下光标键` `。然后,光标放在基本名称和扩展名之间。输入你的描述(不要忘记初始空格字符),并用`Return`进行确认。 + +##### 在geeqie使中用appendfilename + +使用[appendfilename][30],我的过程得到了简化,可以获得将文本附加到文件名的最佳用户体验:当我在geeqie中按下` a ` (append)时,会弹出一个对话框窗口,询问文本。在`Return`确认后,输入的文本将放置在时间戳和可选标记之间。 + +例如,当我在`2014-04-20T17.09.11_p1100386.jpg`上按下`a`,然后在`Graz`中键入`Pick-nick in Graz`时,文件名变为`2014-04-20T17.09.11_p1100386 Pick-nick in Graz.jpg`。当我再次按下`a`并输入`with Susan`时,文件名变为`2014-04-20T17.09.11_p1100386 Pick-nick in Graz with Susan.jpg`。当文件名也获得标记时,附加的文本将附加在标记分隔符之前。 + +这样,我就不必担心覆盖时间戳或标记。重命名的过程对我来说变得更加有趣! + +最好的部分是:当我想要将相同的文本添加到多个选定的文件中时,也可以使用appendfilename。 + +##### 使用geeqie初始appendfilename + +添加一个额外的编辑器到geeqie: ` Edit > Preferences > Configure editor…>New`。然后输入桌面文件定义: + +appendfilename.desktop +``` +[Desktop Entry] +Name=appendfilename +GenericName=appendfilename +Comment= +Exec=/home/vk/src/misc/vk-appendfilename-interactive-wrapper-with-gnome-terminal.sh %F +Icon= +Terminal=true +Type=Application +Categories=Application;Graphics; +hidden=false +MimeType=image/*;video/*;image/mpo;image/thm +Categories=X-Geeqie; + +``` + +同样,我也使用了一个包装脚本,它将为我打开一个新的终端: + +vk-appendfilename-interactive-wrapper-with-gnome-terminal.sh +``` +#!/bin/sh + +/usr/bin/gnome-terminal \ + --geometry=90x5+330+5 \ + --tab-with-profile=big \ + --hide-menubar \ + -x /home/vk/src/appendfilename/appendfilename.py "${@}" + +#end + +``` + +#### 工作流程:播放电影文件 + +在GNU/Linux上,我使用[mplayer][31]回放视频文件。由于geeqie本身不播放电影文件,所以我必须创建一个设置,以便在mplayer中打开电影文件。 + +##### 在geeqie中初始化mplayer的设置 + +我已经使用[xdg-open][32]将电影文件扩展名关联到mplayer。因此,我只需要为geeqie创建一个通用的“open”命令,使用xdg-open打开任何文件及其关联的应用程序。 + +再次访问` Edit > Preferences > Configure editor…`在geeqie中添加`open`的条目: + +open.desktop +``` +[Desktop Entry] +Name=open +GenericName=open +Comment= +Exec=/usr/bin/xdg-open %F +Icon= +Terminal=true +Type=Application +hidden=false +NOMimeType=*; +MimeType=image/*;video/* +Categories=X-Geeqie; + +``` + +当你还将快捷方式`o`(见上文)与geeqie关联时,你就能够打开与其关联的应用程序的视频文件(和其他文件)。 + +##### 使用xdg-open打开电影文件(和其他文件) + +在上面的设置过程之后,当你的geeqie光标位于文件上方时,你只需按下`o`即可。就是如此简洁。 + +#### 工作流:在外部图像编辑器中打开 + +我不太希望能够在GIMP中快速编辑图像文件。因此,我添加了一个快捷方式`g`,并将其与外部编辑器“GNU图像处理程序”(GIMP)关联起来,geeqie已经默认创建了该程序 + +这样,只需按下`g`就可以打开GIMP中的当前图像。 + +#### 工作流程:移动到存档文件夹 + +现在我已经在我的文件名中添加了注释,我想将单个文件移动到`$HOME/archive/events_memories/2014/`,或者将一组文件移动到这个文件夹中的新文件夹中,如`$HOME/archive/events_memories/2014/2014-05-08 business marathon after show - party`。 + +通常的方法是选择一个或多个文件,并将它们移动到具有快捷方式`Ctrl-m`的文件夹中。 + +何等繁复无趣之至! + +因此,我(再次)编写了一个Python脚本,它为我完成了这项工作:[move2archive][33](简而言之:` m2a `需要一个或多个文件作为命令行参数。然后,出现一个对话框,我可以在其中输入一个可选文件夹名。当我不输入任何东西,但按`Return`,文件被移动到相应年份的文件夹。当我输入一个类似`business marathon after show - party`的文件夹名称时,第一个图像文件的日期戳被附加到该文件夹(`$HOME/archive/events_memories/2014/2014-05-08 business marathon after show - party`),得到的文件夹是(`$HOME/archive/events_memories/2014/2014-05-08 Business-Marathon After-Show-Party`),并移动文件。 + +再一次:我在geeqie中,选择一个或多个文件,按`m`(移动),或者只按`Return`(没有特殊的子文件夹),或者输入一个描述性文本,这是要创建的子文件夹的名称(可选不带日期戳)。 + +**没有一个图像管理工具像我的geeqie一样通过快捷键快速且有趣的使用 appendfilename和move2archive完成工作。** + +##### 在geeqie里初始化m2a的相关设置 + +同样,向geeqie添加`m2a`是一个手动步骤:“编辑>首选项>配置编辑器……”然后创建一个带有“New”的附加条目。在这里,你可以定义一个新的桌面文件,如下所示: + +m2a.desktop +``` +[Desktop Entry] +Name=move2archive +GenericName=move2archive +Comment=Moving one or more files to my archive folder +Exec=/home/vk/src/misc/vk-m2a-interactive-wrapper-with-gnome-terminal.sh %F +Icon= +Terminal=true +Type=Application +Categories=Application;Graphics; +hidden=false +MimeType=image/*;video/*;image/mpo;image/thm +Categories=X-Geeqie; + +``` +包装器脚本的`vk-m2a-interactive-wrapper-with-gnome-terminal.sh `是必要的,因为我想要弹出一个新的终端窗口,以便我的文件进入我指定的目标文件夹: + +vk-m2a-interactive-wrapper-with-gnome-terminal.sh +``` +#!/bin/sh + +/usr/bin/gnome-terminal \ + --geometry=157x56+330+5 \ + --tab-with-profile=big \ + --hide-menubar \ + -x /home/vk/src/m2a/m2a.py --pauseonexit "${@}" + +#end + +``` + +在geeqie中,你可以在`Edit > Preferences > Preferences ... > Keyboard`将`m`与`m2a`命令相关联。 + +#### 工作流程:旋转图像(无损) + +通常,我的数码相机会自动将人像照片标记为人像照片。然而,在某些特定的情况下(比如从主题上方拍照),我的相机会出错。在那些**罕见的情况下**,我必须手动修正方向。 + +你必须知道,JPEG文件格式是一种有损格式,应该只用于照片,而不是计算机生成的东西,如屏幕截图或图表。以傻瓜方式旋转JPEG图像文件通常会解压/可视化图像文件,旋转生成新的图像,然后重新编码结果。这将导致生成的图像[比原始图像质量差得多][5]。 + +因此,你应该使用无损方法来旋转JPEG图像文件。 + +再一次,我添加了一个“外部编辑器”到geeqie:`Edit > Preferences > Configure Editors ... > New`。在这里,我添加了两个条目:一个用于旋转270度(即逆时针旋转90度),另一个用于使用[exiftran][34]旋转90度(逆时针旋转90度): + +rotate-270.desktop +``` +[Desktop Entry] +Version=1.0 +Type=Application +Name=Losslessly rotate JPEG image counterclockwise + +# call the helper script +TryExec=exiftran +Exec=exiftran -p -2 -i -g %f + +# Desktop files that are usable only in Geeqie should be marked like this: +Categories=X-Geeqie; +OnlyShowIn=X-Geeqie; + +# Show in menu "Edit/Orientation" +X-Geeqie-Menu-Path=EditMenu/OrientationMenu + +MimeType=image/jpeg; + +``` + +rotate-90.desktop +``` +[Desktop Entry] +Version=1.0 +Type=Application +Name=Losslessly rotate JPEG image clockwise + +# call the helper script +TryExec=exiftran +Exec=exiftran -p -9 -i -g %f + +# Desktop files that are usable only in Geeqie should be marked like this: +Categories=X-Geeqie; +OnlyShowIn=X-Geeqie; + +# Show in menu "Edit/Orientation" +X-Geeqie-Menu-Path=EditMenu/OrientationMenu + +# It can be made verbose +# X-Geeqie-Verbose=true + +MimeType=image/jpeg; + +``` + +我为“[”(逆时针方向)和“]”(逆时针方向)创建了geeqie快捷键。 + +#### 工作流程:可视化GPS坐标 + +我的数码相机有一个GPS传感器,它在JPEG文件的Exif元数据中存储当前的地理位置。位置数据以[WGS 84][35]格式存储,如“47,58,26.73;16、23、55.51”(纬度;经度)。这一方式可读性较差,从我所期望的意义上讲:要么是地图,要么是位置名称。因此,我向geeqie添加了一些功能,这样我就可以在[OpenStreetMap][36]上看到单个图像文件的位置: `Edit > Preferences > Configure Editors ... > New` + +photolocation.desktop +``` +[Desktop Entry] +Name=vkphotolocation +GenericName=vkphotolocation +Comment= +Exec=/home/vk/src/misc/vkphotolocation.sh %F +Icon= +Terminal=true +Type=Application +Categories=Application;Graphics; +hidden=false +MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/x-bmp;image/x-gray;image/x-icb;image/x-ico;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-xbitmap;image/x-xpixmap;image/x-pcx;image/svg+xml;image/svg+xml-compressed;image/vnd.wap.wbmp; + +``` + +这就调用了我的名为`vkphotolocation.sh`的包装脚本,它使用[ExifTool][37]让[Marble][38]能够读取和可视化的适当格式并提取坐标: + +vkphotolocation.sh +``` +#!/bin/sh + +IMAGEFILE="${1}" +IMAGEFILEBASENAME=`basename ${IMAGEFILE}` + +COORDINATES=`exiftool -c %.6f "${IMAGEFILE}" | awk '/GPS Position/ { print $4 " " $6 }'` + +if [ "x${COORDINATES}" = "x" ]; then + zenity --info --title="${IMAGEFILEBASENAME}" --text="No GPS-location found in the image file." +else + /usr/bin/marble --latlon "${COORDINATES}" --distance 0.5 +fi + +#end + +``` + +映射到键盘快捷键“G”,我可以快速地得到**单个图像文件的映射位置位置**。 + +当我想将多个JPEG图像文件的**位置可视化为路径**时,我使用[GpsPrune][39]。我无法派生出GpsPrune将一组文件作为命令行参数的方法。正因为如此,我必须手动启动GpsPrune,`选择一组文件或一个文件夹>添加照片`。 + +通过这种方式,我可以为OpenStreetMap地图上的每个JPEG位置获得一个点(如果配置为这样)。通过单击这样一个点,我可以得到相应图像的详细信息。 + +如果你恰好在国外拍摄照片,可视化GPS位置对**在文件名中添加描述**大有帮助! + +#### 工作流程:根据GPS坐标过滤照片 + +这并非我的工作流程。为了完整起见,我列出该工作流对应工具的特性。我想做的就是从一大堆图片中寻找那些在一定区域内(范围或点+距离)的照片。 + +到目前为止,我只找到了[DigiKam][40],它能够[根据矩形区域进行过滤][41]。如果你知道其他工具,请将其添加到下面的评论或写一封电子邮件。 + +#### 工作流:显示给定集合的子集 + +如上面的需求所述,我希望能够在一个文件夹中定义一组子文件,以便将这个小集合呈现给其他人。 + +工作流程非常简单:我向选择的文件添加一个标记(通过` t ` /filetags)。为此,我使用标记`sel`,它是“selection”的缩写。在标记了一组文件之后,我可以按下` s `,它与一个脚本相关联,该脚本只显示标记为` sel `的文件。 + +当然,这也适用于任何标签或标签组合。因此,用同样的方法,你可以得到一个适当的概述,你的婚礼上的所有照片都标记着“教堂”和“戒指”。 + +很棒的功能,不是吗?:-) + +##### 根据标签和geeqie初始设置文件标签 + +你必须定义一个额外的“外部编辑器”:`Edit > Preferences > Configure Editors ... > New`: + +filter-tags.desktop +``` +[Desktop Entry] +Name=filetag-filter +GenericName=filetag-filter +Comment= +Exec=/home/vk/src/misc/vk-filetag-filter-wrapper-with-gnome-terminal.sh +Icon= +Terminal=true +Type=Application +Categories=Application;Graphics; +hidden=false +MimeType=image/*;video/*;image/mpo;image/thm +Categories=X-Geeqie; + +``` + +再次调用我编写的包装脚本: + +vk-filetag-filter-wrapper-with-gnome-terminal.sh +``` +#!/bin/sh + +/usr/bin/gnome-terminal \ + --geometry=85x15+330+5 \ + --hide-menubar \ + -x /home/vk/src/filetags/filetags.py --filter + +#end + +``` + +带参数`--filter`的`filetags`基本上完成的是:用户被要求输入一个或多个标签。然后,当前文件夹中所有匹配的文件都能使用[符号链接][42]都链接到` $HOME/.filetags_tagfilter/ `。然后,启动一个新的geeqie实例,显示链接的文件。 + +在退出这个新的geeqie实例之后,你将从该实例调用了选择过程中看到旧的geeqie实例。 + +#### 用一个真实的案例来总结 + +Wow, 这是一篇很长的博客文章。难怪你可能已经忘了之前的概述。总结一下我在geeqie(扩展了标准功能集)中可以做的事情,我有一个很酷的总结: + +快捷功能 `m` m2a `o` 打开(针对非图像文件) `a` 在文件名里添加字段 `t` 文件标签(添加) `T` 文件标签(删除) `s` 文件标签(排序) `g` gimp `G` 显示GPS信息 `[` 无损的逆时针旋转 `]` 无损的顺时针旋转 `Ctrl-e` EXIF图像信息 `f` 全屏显示 + +一些针对文件名的(包括它的路径)及我用来操作组件的示例: +``` + /this/is/a/folder/2014-04-20T17.09 Pick-nick in Graz -- food graz.jpg + [ m2a ] [ date2name ] [ appendfilename ] [filetags] + +``` +在示例中,我按照以下步骤将照片从相机保存到存档:我将SD存储卡放入计算机的SD卡读卡器中。然后我运行[getdigicamdata.sh][23]。完成之后,我在geeqie中打开`$HOME/tmp/digicam/tmp/`。我浏览了一下照片,把那些不成功的删除了。如果有一个图像的方向错误,我用`[`or`]`纠正它。 + +在第二步中,我向我认为值得评论的文件添加描述(` a `)。每当我想添加标签时,我也这样做:我快速地标记所有应该共享标签的文件(` Ctrl ` \+鼠标点击),并使用[filetags][28] (` t `)进行标记。 + +要组合来自给定事件的文件,我选中相应的文件,将它们移动到年度归档文件夹中的“event-folder”,并通过在[move2archive][33] (`m `)中键入事件描述,其余的(非特殊的文件夹)由move2archive (`m `)直接移动到年度归档中,而不需要声明事件描述。 + +为了完成我的工作流程,我删除了SD卡上的所有文件,把它从操作系统上弹出,然后把它放回我的数码相机里。 + +以上。 + +因为这种工作流程几乎不需要任何开销,所以评论、标记和归档照片不再是一项乏味的工作。 + +### 最后 + +所以,这是一个详细描述我关于照片和电影的工作流程的叙述。你可能已经发现了我可能感兴趣的其他东西。所以请不要犹豫,请使用下面的链接留下评论或电子邮件。 +我也希望得到反馈,如果我的工作流程适用于你。并且:如果你已经发布了你的工作流程或者找到了其他人工作流程的描述,也请留下评论! +及时行乐,莫让错误的工具或低效的方法浪费了我们的人生! + +### 其他工具 + +阅读关于[本文中关于 gThumb 的部分][43]. + +当你觉得你以上文中所叙述的符合你的需求时,请根据相关的建议来选择对应的工具。 + +### 邮件回复 + +> Date: Sat, 26 Aug 2017 22:05:09 +0200 + +> 你好卡尔, +我喜欢你的文章,喜欢和memacs一起工作,当然还有orgmode,但是我对python不是很熟悉……在你的博客文章“管理数码照片”,你写了关于打开视频与[Geeqie][26]。是的,但是我在浏览器里看不到任何视频缩略图。你有什么建议吗? + +> 谢谢你,托马斯 + + + +你好托马斯, + +谢谢你的美言。当有人发现我的工作对他/她的生活有用时,我总是感觉很棒。 +不幸的是,大多数时候,我从未听到过这些。 +是的,我有时使用Geeqie来可视化文件夹,这些文件夹不仅包含图像文件,还包含电影文件。在这些情况下,我没有看到任何视频的缩略图。你说得对,有很多文件浏览器可以显示视频的预览图像。 +坦白地说,我从来没有想过视频缩略图,我也不怀念它们。在我的首选项和搜索引擎上做了一个快速的研究,并没有发现在Geeqie中启用视频预览的相关方法。所以这里要说声抱歉。 + + + +-------------------------------------------------------------------------------- + +via: http://karl-voit.at/managing-digital-photographs/ + +作者:[Karl Voit][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://karl-voit.at +[1]:https://en.wikipedia.org/wiki/Jpeg +[2]:http://en.wikipedia.org/wiki/Vendor_lock-in +[3]:https://en.wikipedia.org/wiki/Raw_image_format +[4]:http://www.gimp.org/ +[5]:http://petapixel.com/2012/08/14/why-you-should-always-rotate-original-jpeg-photos-losslessly/ +[6]:https://en.wikipedia.org/wiki/Gps +[7]:https://en.wikipedia.org/wiki/Iso_date +[8]:https://en.wikipedia.org/wiki/Ntfs +[9]:https://en.wikipedia.org/wiki/Exif +[10]:http://www.isisinform.com/reinventing-knowledge-the-medieval-controversy-of-alphabetical-order/ +[11]:https://en.wikipedia.org/wiki/File_name_extension +[12]:http://karl-voit.at/tagstore/en/papers.shtml +[13]:https://en.wikipedia.org/wiki/Hashtag +[14]:https://en.wikipedia.org/wiki/Dot-file +[15]:https://en.wikipedia.org/wiki/NTFS#Alternate_data_streams_.28ADS.29 +[16]:https://github.com/novoid/Memacs/blob/master/docs/memacs_filenametimestamps.org +[17]:https://github.com/novoid/Memacs +[18]:http://www.cis.upenn.edu/~bcpierce/unison/ +[19]:https://github.com/novoid/LaTeX-KOMA-template +[20]:http://orgmode.org/ +[21]:http://karl-voit.at/tags/emacs +[22]:https://twitter.com/search?q%3D%2523orgmode&src%3Dtypd +[23]:https://github.com/novoid/getdigicamdata.sh +[24]:http://www.sentex.net/%3Ccode%3Emwandel/jhead/ +[25]:https://github.com/novoid/date2name +[26]:http://geeqie.sourceforge.net/ +[27]:http://xee.c3.cx/ +[28]:https://github.com/novoid/filetag +[29]:http://karl-voit.at/tagstore/ +[30]:https://github.com/novoid/appendfilename +[31]:http://www.mplayerhq.hu +[32]:https://wiki.archlinux.org/index.php/xdg-open +[33]:https://github.com/novoid/move2archive +[34]:http://manpages.ubuntu.com/manpages/raring/man1/exiftran.1.html +[35]:https://en.wikipedia.org/wiki/WGS84#A_new_World_Geodetic_System:_WGS_84 +[36]:http://www.openstreetmap.org/ +[37]:http://www.sno.phy.queensu.ca/~phil/exiftool/ +[38]:http://userbase.kde.org/Marble/Tracking +[39]:http://activityworkshop.net/software/gpsprune/ +[40]:https://en.wikipedia.org/wiki/DigiKam +[41]:https://docs.kde.org/development/en/extragear-graphics/digikam/using-kapp.html#idp7659904 +[42]:https://en.wikipedia.org/wiki/Symbolic_link +[43]:http://karl-voit.at/2017/02/19/gthumb diff --git a/translated/tech/20190505 Blockchain 2.0 - What Is Ethereum -Part 9.md b/translated/tech/20190505 Blockchain 2.0 - What Is Ethereum -Part 9.md new file mode 100644 index 0000000000..b80271af21 --- /dev/null +++ b/translated/tech/20190505 Blockchain 2.0 - What Is Ethereum -Part 9.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Blockchain 2.0 – What Is Ethereum [Part 9]) +[#]: via: (https://www.ostechnix.com/blockchain-2-0-what-is-ethereum/) +[#]: author: (editor https://www.ostechnix.com/author/editor/) + +区块链 2.0 :以太坊(九) +====== + +![Ethereum][1] + +在本系列的上一指南中,我们讨论了 [Hyperledger 项目(HLP)][2],这是一个由 Linux 基金会开发的增长最快的产品。在本指南中,我们将详细讨论什么是“以太坊Ethereum”及其功能。许多研究人员认为,互联网的未来将基于去中心化计算decentralized computing的原理。实际上,去中心化计算是互联网放在首位的更广泛目标之一。但是,由于可用的计算能力不同,互联网发生了另一次变化。尽管现代服务器功能使服务器端处理和执行成为可能,但在世界上大部分地区缺乏像样的移动网络使客户端也是如此。现在,现代智能手机具有 SoC(片上系统),在客户端本身上也能够处理许多此类操作,但是,由于安全地检索和存储数据而受到的限制仍然迫使开发人员进行服务器端计算和数据管理。因此,当前可以观察到数据传输能力的瓶颈。 + +由于分布式数据存储和程序执行平台的进步,所有这些可能很快就会改变。[区块链][3]允许在分布式用户网络(而不是中央服务器)上进行安全的数据管理和程序执行,这在互联网历史上基本上是第一次。 + +以太坊就是一个这样的区块链平台,使开发人员可以访问用于在这样的去中心化网络上构建和运行应用程序的框架和工具。尽管它以其加密货币而广为人知,以太坊不只是以太币ether(加密货币)。这是一种完整的图灵完备Turing complete编程语言,旨在开发和部署 DApp(即分布式应用Distributed APPlication) [^1]。我们会在接下来的一篇文章中详细介绍 DApp。 + +以太坊是开源的,默认情况下是一个公共(非许可)区块链,并具有一个大范围的智能合约平台底层(Solidity)。以太坊提供了一个称为“以太坊虚拟机(EVM)”的虚拟计算环境,以运行应用程序和[智能合约][4] [^2]。 以太坊虚拟机在世界各地成千上万个参与节点上运行,这意味着应用程序数据在保证安全的同时,几乎不可能被篡改或丢失。 + +### 以太坊的背后:什么使之不同 + +在 2017 年,为了推广以太坊区块链的功能的利用,30 多个技术和金融领域的名人聚集在一起。因此,“以太坊企业联盟Ethereum Enterprise Alliance”(EEA)由众多支持成员组成,包括微软、摩根大通、思科、德勤和埃森哲。摩根大通已经拥有 Quorum,这是一个基于以太坊的去中心化金融服务计算平台,目前正在运营中;而微软拥有通过其 Azure 云业务销售的基于以太坊的云服务[^3]。 + +### 什么是以太币,它和以太坊有什么关系 + +以太坊的创建者维塔利克·布特林Vitalik Buterin深谙去中心化处理平台的真正价值以及为比特币提供动力的底层区块链技术。他提议比特币应该开发以支持运行分布式应用程序(DApp)和程序(现在称为智能合约)的想法,未能获得多数同意。 + +因此,他在 2013 年发表的白皮书中提出了以太坊的想法。原始白皮书仍在维护中,读者可从[此处][5]获得。这个想法是开发一个基于区块链的平台来运行智能合约和应用程序,这些合约和应用程序设计为在节点和用户设备而非服务器上运行。 + +以太坊系统经常被误认为就是加密货币以太币,但是,必须重申,以太坊是一个用于开发和执行应用程序的全栈平台,自成立以来一直如此,而比特币并非如此。**以太网目前是按市值计算的第二大加密货币**,在撰写本文时,其平均交易价格为每个以太币 170 美元 [^4]。 + +### 该平台的功能和技术特性 [^5] + +* 正如我们已经提到的,称为以太币的加密货币只是该平台功能之一。该系统的目的不仅仅是处理金融交易。 实际上,以太坊平台和比特币之间的主要区别在于它们的脚本功能。以太坊是以图灵完备的编程语言开发的,这意味着它具有类似于其他主要编程语言的脚本和应用程序功能。开发人员需要此功能才能在平台上创建 DApp 和复杂的智能合约,而该功能是比特币缺失的。 +* 以太币的“挖矿”过程更加严格和复杂。尽管可以使用专用的 ASIC 来开采比特币,但以太坊使用的基本哈希算法(EThash)降低了 ASIC 在这方面的优势。 +* 为激励矿工和节点运营者运行网络而支付的交易费用本身是使用称为 “燃料Gas”的计算令牌来计算的。通过要求交易的发起者支付与执行交易所需的计算资源数量成比例的以太币,燃料提高了系统的弹性以及对外部黑客和攻击的抵抗力。这与其他平台(例如比特币)相反,在该平台上,交易费用与交易规模一并衡量。因此,以太坊的平均交易成本从根本上低于比特币。这也意味着在以太坊虚拟机上运行的应用程序需要付费,具体取决于应用程序要解决的计算问题。基本上,执行越复杂,费用就越高。 +* 以太坊的出块时间估计约为 10 - 15 秒。出块时间是在区块链网络上打时间戳和创建区块所需的平均时间。与将在比特币网络上进行同样的交易要花费 10 分钟以上的时间相比,很明显,就交易和区块验证而言,以太坊要快得多。 +* *有趣的是,对可开采的以太币数量或开采速度没有硬性限制,这导致其系统设计不像比特币那么激进*。 + +### 总结 + +尽管与以太坊相比,它远远超过了类似的平台,但在以太坊企业联盟开始推动之前,该平台本身尚缺乏明确的发展道路。虽然以太坊平台确实推动了企业发展,但必须注意,以太坊还可以满足小型开发商和个人的需求。 这样一来,为最终用户和企业开发的平台就为以太坊遗漏了许多特定功能。另外,以太坊基金会提出和开发的区块链模型是一种公共模型,而 Hyperledger 项目等项目提出的模型是私有的和需要许可的。 + +虽然只有时间才能证明以太坊、Hyperledger 和 R3 Corda 等平台中,哪一个平台会在现实场景中找到最多粉丝,但此类系统确实证明了以区块链为动力的未来主张的正确性。 + +[^1]: [Gabriel Nicholas, “Ethereum Is Coding’s New Wild West | WIRED,” Wired , 2017][6]. +[^2]: [What is Ethereum? — Ethereum Homestead 0.1 documentation][7]. +[^3]: [Ethereum, a Virtual Currency, Enables Transactions That Rival Bitcoin’s – The New York Times][8]. +[^4]: [Cryptocurrency Market Capitalizations | CoinMarketCap][9]. +[^5]: [Introduction — Ethereum Homestead 0.1 documentation][10]. + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/blockchain-2-0-what-is-ethereum/ + +作者:[editor][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/wp-content/uploads/2019/04/Ethereum-720x340.png +[2]: https://www.ostechnix.com/blockchain-2-0-an-introduction-to-hyperledger-project-hlp/ +[3]: https://www.ostechnix.com/blockchain-2-0-an-introduction/ +[4]: https://www.ostechnix.com/blockchain-2-0-explaining-smart-contracts-and-its-types/ +[5]: https://github.com/ethereum/wiki/wiki/White-Paper +[6]: https://www.wired.com/story/ethereum-is-codings-new-wild-west/ +[7]: http://www.ethdocs.org/en/latest/introduction/what-is-ethereum.html#ethereum-virtual-machine +[8]: https://www.nytimes.com/2016/03/28/business/dealbook/ethereum-a-virtual-currency-enables-transactions-that-rival-bitcoins.html +[9]: https://coinmarketcap.com/ +[10]: http://www.ethdocs.org/en/latest/introduction/index.html diff --git a/translated/tech/20190909 How to Setup Multi Node Elastic Stack Cluster on RHEL 8 - CentOS 8.md b/translated/tech/20190909 How to Setup Multi Node Elastic Stack Cluster on RHEL 8 - CentOS 8.md new file mode 100644 index 0000000000..a6ae6cf537 --- /dev/null +++ b/translated/tech/20190909 How to Setup Multi Node Elastic Stack Cluster on RHEL 8 - CentOS 8.md @@ -0,0 +1,488 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Setup Multi Node Elastic Stack Cluster on RHEL 8 / CentOS 8) +[#]: via: (https://www.linuxtechi.com/setup-multinode-elastic-stack-cluster-rhel8-centos8/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +如何在 RHEL 8 /CentOS 8 上建立多节点 Elastic stack 集群 +====== + + +Elastic stack 俗称 **ELK stack**,是一组开源产品,如 **Elasticsearch**、**Logstash**和**Kibana**。Elastic Stack 由 Elastic 公司开发和维护。使用 Elastic stack,可以将系统日志发送到 Logstash,它是一个数据收集引擎,接受来自可能任何来源的日志或数据,并对日志进行格式化,然后将日志转发到 Elasticsearch ,用于 **分析**、**索引**、**搜索**和**存储**,最后使用 Kibana 表示为可视化数据,使用 Kibana,我们还可以基于用户的查询创建交互式图表。 + + +[![Elastic-Stack-Cluster-RHEL8-CentOS8][1]][2] + + +在本文中,我们将演示如何在 RHEL 8 / CentOS 8 服务器上设置多节点 elastic stack 集群。以下是我的 Elastic Stack 集群的详细信息: + +### Elasticsearch: + + * 三台服务器,最小化安装 RHEL 8 / CentOS 8 + * IPs & 主机名 – 192.168.56.40 (elasticsearch1.linuxtechi. local), 192.168.56.50 (elasticsearch2.linuxtechi. local), 192.168.56.60 (elasticsearch3.linuxtechi. local) + + +### Logstash: + + * 两台服务器,最小化安装 RHEL 8 / CentOS 8 + * IPs & 主机 – 192.168.56.20 (logstash1.linuxtechi. local) , 192.168.56.30 (logstash2.linuxtechi. local) + + + +### Kibana: + + * 一台服务器,最小化安装 RHEL 8 / CentOS 8 + * 主机名 – kibana.linuxtechi.local + * IP – 192.168.56.10 + + + +### Filebeat: + + * 一台服务器,最小化安装 CentOS 7 + * IP &主机名 – 192.168.56.70 (web-server) + + + +让我们从设置 Elasticsearch 集群开始, + +#### 设置3个节点 Elasticsearch 集群 + +正如我已经说过的,设置 Elasticsearch 集群的节点,登录到每个节点,设置主机名并配置 yum/dnf 库。 + +使用命令 hostnamectl 设置各个节点上的主机名, + +``` +[root@linuxtechi ~]# hostnamectl set-hostname "elasticsearch1.linuxtechi. local" +[root@linuxtechi ~]# exec bash +[root@linuxtechi ~]# +[root@linuxtechi ~]# hostnamectl set-hostname "elasticsearch2.linuxtechi. local" +[root@linuxtechi ~]# exec bash +[root@linuxtechi ~]# +[root@linuxtechi ~]# hostnamectl set-hostname "elasticsearch3.linuxtechi. local" +[root@linuxtechi ~]# exec bash +[root@linuxtechi ~]# +``` + +对于 CentOS 8 系统,我们不需要配置任何操作系统包库,对于 RHEL 8服务器,如果您订阅了,然后用红帽订阅以获得包存储库就可以了。如果您想为操作系统包配置本地 yum/dnf 存储库,请参考以下网址: + +[How to Setup Local Yum/DNF Repository on RHEL 8 Server Using DVD or ISO File][3] + +在所有节点上配置 Elasticsearch 包存储库,在 /etc/yum.repo.d/ 文件夹下创建一个包含以下内容的 elastic.repo 文件 + +``` +~]# vi /etc/yum.repos.d/elastic.repo +[elasticsearch-7.x] +name=Elasticsearch repository for 7.x packages +baseurl=https://artifacts.elastic.co/packages/7.x/yum +gpgcheck=1 +gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch +enabled=1 +autorefresh=1 +type=rpm-md +``` + +保存 & 退出文件 + +在所有三个节点上使用 rpm 命令导入 Elastic 公共签名密钥 + +``` +~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch +``` + +在所有三个节点的 /etc/hosts 文件中添加以下行: + +``` +192.168.56.40 elasticsearch1.linuxtechi.local +192.168.56.50 elasticsearch2.linuxtechi.local +192.168.56.60 elasticsearch3.linuxtechi.local +``` + +使用 yum/dnf 命令在所有三个节点上安装 Java, + +``` +[root@linuxtechi ~]# dnf install java-openjdk -y +[root@linuxtechi ~]# dnf install java-openjdk -y +[root@linuxtechi ~]# dnf install java-openjdk -y +``` + +使用 dnf 命令在所有三个节点上安装 Elasticsearch, + +``` +[root@linuxtechi ~]# dnf install elasticsearch -y +[root@linuxtechi ~]# dnf install elasticsearch -y +[root@linuxtechi ~]# dnf install elasticsearch -y +``` + +**注意:** 如果操作系统防火墙已启用并在每个 Elasticsearch 节点中运行,则使用 firewall-cmd 命令允许以下端口开放, + +``` +~]# firewall-cmd --permanent --add-port=9300/tcp +~]# firewall-cmd --permanent --add-port=9200/tcp +~]# firewall-cmd --reload +``` + +配置 Elasticsearch, 在所有节点上编辑文件 **/etc/elasticsearch/elasticsearch.yml** 并加入以下内容, + +``` +~]# vim /etc/elasticsearch/elasticsearch.yml +………………………………………… +cluster.name: opn-cluster +node.name: elasticsearch1.linuxtechi.local +network.host: 192.168.56.40 +http.port: 9200 +discovery.seed_hosts: ["elasticsearch1.linuxtechi.local", "elasticsearch2.linuxtechi.local", "elasticsearch3.linuxtechi.local"] +cluster.initial_master_nodes: ["elasticsearch1.linuxtechi.local", "elasticsearch2.linuxtechi.local", "elasticsearch3.linuxtechi.local"] +…………………………………………… +``` + +**注意:** 在每个节点上,在 node.name 中填写正确的主机名,在 network.host 中填写正确的 IP 地址,其他参数将保持不变。 + +现在使用 systemctl 命令在所有三个节点上启动并启用 Elasticsearch 服务, + +``` +~]# systemctl daemon-reload +~]# systemctl enable elasticsearch.service +~]# systemctl start elasticsearch.service +``` + +使用下面 'ss' 命令验证 elasticsearch 节点是否开始监听9200端口, + +``` +[root@linuxtechi ~]# ss -tunlp | grep 9200 +tcp LISTEN 0 128 [::ffff:192.168.56.40]:9200 *:* users:(("java",pid=2734,fd=256)) +[root@linuxtechi ~]# +``` + +使用以下 curl 命令验证 Elasticsearch 群集状态 + +``` +[root@linuxtechi ~]# curl http://elasticsearch1.linuxtechi.local:9200 +[root@linuxtechi ~]# curl -X GET http://elasticsearch2.linuxtechi.local:9200/_cluster/health?pretty +``` + +命令的输出如下所示, + +![Elasticsearch-cluster-status-rhel8][1] + +以上输出表明我们已经成功创建了3节点的 Elasticsearch 集群,集群的状态也是绿色的。 + +**注意:** 如果您想修改 JVM 堆大小,那么您已经编辑了文件 “**/etc/elasticsearch/jvm.options**”,并根据您的环境更改以下参数, + + * -Xms1g + * -Xmx1g + + + +现在让我们转到 Logstash 节点, + +#### 安装和配置 Logstash + +在两个 Logstash 节点上执行以下步骤, + +登录到两个节点使用 hostnamectl 命令设置主机名, + +``` +[root@linuxtechi ~]# hostnamectl set-hostname "logstash1.linuxtechi.local" +[root@linuxtechi ~]# exec bash +[root@linuxtechi ~]# +[root@linuxtechi ~]# hostnamectl set-hostname "logstash2.linuxtechi.local" +[root@linuxtechi ~]# exec bash +[root@linuxtechi ~]# +``` + +在两个 logstash 节点的 /etc/hosts 文件中添加以下条目 + +``` +~]# vi /etc/hosts +192.168.56.40 elasticsearch1.linuxtechi.local +192.168.56.50 elasticsearch2.linuxtechi.local +192.168.56.60 elasticsearch3.linuxtechi.local +``` + +保存并退出文件 + + +在两个节点上配置 Logstash 存储库,在文件夹/ete/yum.repo.d/下创建一个包含以下内容的文件 **logstash.repo**, + +``` +~]# vi /etc/yum.repos.d/logstash.repo +[elasticsearch-7.x] +name=Elasticsearch repository for 7.x packages +baseurl=https://artifacts.elastic.co/packages/7.x/yum +gpgcheck=1 +gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch +enabled=1 +autorefresh=1 +type=rpm-md +``` + +保存并退出文件,运行 rpm 命令导入签名密钥 + +``` +~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch +``` + +使用 dnf 命令在两个节点上安装 Java OpenJDK, + +``` +~]# dnf install java-openjdk -y +``` + +从两个节点运行 dnf 命令来安装 logstash, + +``` +[root@linuxtechi ~]# dnf install logstash -y +[root@linuxtechi ~]# dnf install logstash -y +``` + +现在配置logstash,在两个 logstash 节点上执行以下步骤, + +创建一个 logstash conf 文件,首先我们在 “/etc/logstash/conf.d/” 下复制 logstash 示例文件 + +``` +# cd /etc/logstash/ +# cp logstash-sample.conf conf.d/logstash.conf +``` + +编辑 conf 文件并更新以下内容, + +``` +# vi conf.d/logstash.conf + +input { + beats { + port => 5044 + } +} + +output { + elasticsearch { + hosts => ["http://elasticsearch1.linuxtechi.local:9200", "http://elasticsearch2.linuxtechi.local:9200", "http://elasticsearch3.linuxtechi.local:9200"] + index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}" + #user => "elastic" + #password => "changeme" + } +} +``` + +输出部分,在主机参数中指定所有三个 Elasticsearch 节点的 FQDN,其他参数保持不变。 + +使用 firewall-cmd 命令在操作系统防火墙中允许 logstash 端口 “5044”, + +``` +~ # firewall-cmd --permanent --add-port=5044/tcp +~ # firewall-cmd –reload +``` + +现在,在每个节点上运行以下 systemctl 命令,启动并启用 Logstash 服务 + +``` +~]# systemctl start logstash +~]# systemctl eanble logstash +``` +使用 ss 命令验证 logstash 服务是否开始监听 5044 端口, + +``` +[root@linuxtechi ~]# ss -tunlp | grep 5044 +tcp LISTEN 0 128 *:5044 *:* users:(("java",pid=2416,fd=96)) +[root@linuxtechi ~]# +``` + +以上输出表明 logstash 已成功安装和配置。让我们转到 Kibana 安装。 + +#### 安装和配置 Kibana + +登录 Kibana 节点,使用 **hostnamectl** 命令设置主机名, + +``` +[root@linuxtechi ~]# hostnamectl set-hostname "kibana.linuxtechi.local" +[root@linuxtechi ~]# exec bash +[root@linuxtechi ~]# +``` + +编辑 /etc/hosts 文件并添加以下行 + + +``` +192.168.56.40 elasticsearch1.linuxtechi.local +192.168.56.50 elasticsearch2.linuxtechi.local +192.168.56.60 elasticsearch3.linuxtechi.local +``` + +使用以下命令设置 Kibana 存储库, + +``` +[root@linuxtechi ~]# vi /etc/yum.repos.d/kibana.repo +[elasticsearch-7.x] +name=Elasticsearch repository for 7.x packages +baseurl=https://artifacts.elastic.co/packages/7.x/yum +gpgcheck=1 +gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch +enabled=1 +autorefresh=1 +type=rpm-md + +[root@linuxtechi ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch +``` + +执行 dnf 命令安装kibana, + +``` +[root@linuxtechi ~]# yum install kibana -y +``` + +通过编辑 “**/etc/kibana/kibana.yml**” 文件,配置 Kibana + +``` +[root@linuxtechi ~]# vim /etc/kibana/kibana.yml +………… +server.host: "kibana.linuxtechi.local" +server.name: "kibana.linuxtechi.local" +elasticsearch.hosts: ["http://elasticsearch1.linuxtechi.local:9200", "http://elasticsearch2.linuxtechi.local:9200", "http://elasticsearch3.linuxtechi.local:9200"] +………… +``` + +启动并且启用 kibana 服务 + + +``` +[root@linuxtechi ~]# systemctl start kibana +[root@linuxtechi ~]# systemctl enable kibana +``` + +在系统防火墙上允许 Kibana 端口 ‘5601‘ + +``` +[root@linuxtechi ~]# firewall-cmd --permanent --add-port=5601/tcp +success +[root@linuxtechi ~]# firewall-cmd --reload +success +[root@linuxtechi ~]# +``` +使用以下 URL 访问 Kibana 界面 + + + +[![Kibana-Dashboard-rhel8][1]][4] + +从 面板上,我们可以检查 Elastic Stack 集群的状态 + +[![Stack-Monitoring-Overview-RHEL8][1]][5] + + +这证明我们已经在 RHEL 8 /CentOS 8 上成功地安装并设置了多节点 Elastic Stack 集群。 + + + +现在让我们通过 filebeat 从其他 Linux 服务器发送一些日志到 logstash 节点中,在我的例子中,我有一个 CentOS 7服务器,我将通过 filebeat 将该服务器的所有重要日志推送到 logstash 。 + + +登录到 CentOS 7 服务器使用 rpm 命令安装 filebeat 包, + +``` +[root@linuxtechi ~]# rpm -ivh https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.3.1-x86_64.rpm +Retrieving https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.3.1-x86_64.rpm +Preparing... ################################# [100%] +Updating / installing... + 1:filebeat-7.3.1-1 ################################# [100%] +[root@linuxtechi ~]# +``` + +编辑 /etc/hosts 文件并添加以下内容, + +``` +192.168.56.20 logstash1.linuxtechi.local +192.168.56.30 logstash2.linuxtechi.local +``` + + +现在配置 filebeat,以便它可以使用负载平衡技术向 logstash 节点发送日志,编辑文件 **/etc/filebeat/filebeat.yml**,并添加以下参数, + + +在 “**filebeat.inputs:**”部分将“**enabled: false**”更改为“**enabled: true**”,并在“**paths**”参数下指定我们可以发送到 logstash 的日志文件的位置,在 Elasticsearch 输出部分注释掉“**output.elasticsearch**”和**host**参数。在 Logstash 输出部分,删除“**output.logstash:**” 和 “**hosts:**” 的注释,并在 hosts 参数和 “**loadbalance: true**” 中添加 logstash 节点。 + +``` +[root@linuxtechi ~]# vi /etc/filebeat/filebeat.yml +………………………. +filebeat.inputs: +- type: log + enabled: true + paths: + - /var/log/messages + - /var/log/dmesg + - /var/log/maillog + - /var/log/boot.log +#output.elasticsearch: + # hosts: ["localhost:9200"] + +output.logstash: + hosts: ["logstash1.linuxtechi.local:5044", "logstash2.linuxtechi.local:5044"] + loadbalance: true +……………………………………… +``` + +使用下面的2个 systemctl 命令 启动并启用 filebeat 服务 + +``` +[root@linuxtechi ~]# systemctl start filebeat +[root@linuxtechi ~]# systemctl enable filebeat +``` + +现在转到 Kibana 用户界面,验证新索引是否可见, + +从左侧栏中选择管理选项,然后单击 Elasticsearch 下的索引管理, + +[![Elasticsearch-index-management-Kibana][1]][6] + +正如我们上面看到的,索引现在是可见的,让我们创建索引模型, + + +点击 Kibana 部分的 “索引模型”,它将提示我们创建一个新模型,点击 **Create Index Pattern** ,并将模式名称指定为 **filebeat** + +[![Define-Index-Pattern-Kibana-RHEL8][1]][7] + + +点击下一步 + +选择 **Timestamp** 作为索引模型的时间过滤器,然后单击 “Create index pattern” + +[![Time-Filter-Index-Pattern-Kibana-RHEL8][1]][8] + +[![filebeat-index-pattern-overview-Kibana][1]][9] + +现在单击查看实时 filebeat 索引模型, + +[![Discover-Kibana-REHL8][1]][10] + + +这表明 Filebeat 代理已配置成功,我们能够在 Kibana 仪表盘上看到实时日志。 + +以上就是本文的全部内容,对这些帮助您在 RHEL 8 / CentOS 8 系统上设置 Elastic Stack集群的步骤,请不要犹豫分享您的反馈和意见, + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/setup-multinode-elastic-stack-cluster-rhel8-centos8/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Elastic-Stack-Cluster-RHEL8-CentOS8.jpg +[3]: https://www.linuxtechi.com/setup-local-yum-dnf-repository-rhel-8/ +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Kibana-Dashboard-rhel8.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Stack-Monitoring-Overview-RHEL8.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Elasticsearch-index-management-Kibana.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Define-Index-Pattern-Kibana-RHEL8.jpg +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Time-Filter-Index-Pattern-Kibana-RHEL8.jpg +[9]: https://www.linuxtechi.com/wp-content/uploads/2019/09/filebeat-index-pattern-overview-Kibana.jpg +[10]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Discover-Kibana-REHL8.jpg diff --git a/translated/tech/20190916 How to start developing with .NET.md b/translated/tech/20190916 How to start developing with .NET.md new file mode 100644 index 0000000000..b6581815de --- /dev/null +++ b/translated/tech/20190916 How to start developing with .NET.md @@ -0,0 +1,170 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to start developing with .NET) +[#]: via: (https://opensource.com/article/19/9/getting-started-net) +[#]: author: (Seth Kenlon https://opensource.com/users/sethhttps://opensource.com/users/alex-bunardzichttps://opensource.com/users/alex-bunardzic) + +如何开始使用 .NET 进行开发 +====== +了解 .NET 开发平台启动和运行的基础知识。 +![Coding on a computer][1] + +.NET 框架由 Microsoft 于 2000 年发布。该平台的开源实现 [Mono][2] 在 21 世纪初成为了争议的焦点,因为微软拥有 .NET 技术的多项专利,并且可能使用这些专利来结束 Mono。幸运的是,在 2014 年,微软宣布 .NET 开发平台从此成为 MIT 许可下的开源平台,并在 2016 年收购了开发 Mono 的 Xamarin 公司。 + +.NET 和 Mono 已经同时可用于 C#、F#、GTK+、Visual Basic、Vala 等的跨平台编程环境。使用 .NET 和 Mono 创建的程序已经应用于 Linux、BSD、Windows、MacOS、Android,甚至一些游戏机。你可以使用 .NET 或 Mono 来开发 .NET 应用。它们都是开源的,并且都有活跃和充满活力的社区。本文重点介绍 Microsoft .NET 环境实现。 + +### 如何安装 .NET + +.NET 下载被分为多个包:一个仅包含 .NET 运行时,另一个包含了 .NET Core 和运行时 .NET SDK。根据架构和操作系统版本,这些包可能有多个版本。要开始使用 .NET 进行开发,你必须[安装 SDK][3]。它为您提供了 [dotnet][4] 终端或 PowerShell 命令,你可以使用它们来创建和生成项目。 + +#### Linux + +要在 Linux 上安装 .NET,首先将 Microsoft Linux 软件仓库添加到你的计算机。 + +在 Fedora 上: + + +``` +$ sudo rpm --import +$ sudo wget -q -O /etc/yum.repos.d/microsoft-prod.repo +``` + +在 Ubuntu 上: + + +``` +$ wget -q -O packages-microsoft-prod.deb +$ sudo dpkg -i packages-microsoft-prod.deb +``` + +接下来,使用包管理器安装 SDK,将 **<X.Y>** 替换为当前版本的 .NET 版本: + +在 Fedora 上: + + +``` +`$ sudo dnf install dotnet-sdk-` +``` + +在 Ubuntu 上: + + +``` +$ sudo apt install apt-transport-https +$ sudo apt update +$ sudo apt install dotnet-sdk-<X.Y> +``` + +下载并安装所有包后,打开终端并输入下面命令确认安装: + + +``` +$ dotnet --version +X.Y.Z +``` + +#### Windows + +如果你使用的是 Microsoft Windows,那么你可能已经安装了 .NET 运行时。但是,要开发 .NET 应用,你还必须安装 .NET Core SDK。 + + +首先,[下载安装程序][3]。请认准下载 .NET Core 进行跨平台开发(.NET Framework 仅适用于 Windows)。下载 **.exe** 文件后,双击该文件启动安装向导,然后单击两下进行安装:接受许可证并允许安装继续。 + +![Installing dotnet on Windows][5] + +然后,从左下角的“应用程序”菜单中打开 PowerShell。在 PowerShell 中,输入测试命令: + + +``` +`PS C:\Users\osdc> dotnet` +``` + +如果你看到有关 dotnet 安装的信息,那么说明 .NET 已正确安装。 + +#### MacOS + +如果你使用的是 Apple Mac,请下载 **.pkg**形式的 [Mac 安装程序][3]。下载并双击 **.pkg** 文件,然后单击安装程序。你可能需要授予安装程序权限,因为该软件包并非来自 App Store。 + +下载并安装所有软件包后,请打开终端并输入以下命令来确认安装: + + +``` +$ dotnet --version +X.Y.Z +``` + +### Hello .NET + +**dotnet** 命令提供了一个用 .NET 编写的 “hello world ” 示例程序。或者,更准确地说,该命令提供了示例应用。 + +首先,使用 **dotnet** 命令以及 **new** 和 **console** 参数创建一个控制台应用的项目目录及所需的代码基础结构。使用 **-o** 选项指定项目名称: + + +``` +`$ dotnet new console -o hellodotnet` +``` + +这将在当前目录中创建一个名为 **hellodotnet** 的目录。进入你的项目目录并看一下: + + +``` +$ cd hellodotnet +$ dir +hellodotnet.csproj  obj  Program.cs +``` + +**Program.cs** 是一个空的 C# 文件,它包含了一个简单的 Hello World 程序。在文本编辑器中打开浏览。微软的 Visual Studio Code 是一个使用 dotnet 编写的跨平台的开源应用,虽然它不是一个糟糕的文本编辑器,但它会收集用户的大量数据(在它的二进制发行版的许可证中授予了自己权限)。如果要尝试使用 Visual Studio Code,请考虑使用 [VSCodium][6],它是使用 Visual Studio Code 的 MIT 许可的源码构建的版本,而_没有_远程收集(请阅读[文档][7]来禁止此构建中的其他形式追踪)。或者,只需使用现有的你最喜欢的文本编辑器或 IDE。 + +新控制台应用中的样板代码为: + + +``` +using System; + +namespace hellodotnet +{ +    class Program +    { +        static void Main(string[] args) +        { +            Console.WriteLine("Hello World!"); +        } +    } +} +``` + +要运行该程序,请使用 **dotnet run** 命令: + + +``` +$ dotnet run +Hello World! +``` + +这是 .NET 和 **dotnet** 命令的基本工作流程。这里有完整的 [.NET C# 指南][8],并且都是与 .NET 相关的内容。关于 .NET 实战示例,请关注 [Alex Bunardzic][9] 在 opensource.com 中的变异测试文章。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/getting-started-net + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[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/sethhttps://opensource.com/users/alex-bunardzichttps://opensource.com/users/alex-bunardzic +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: https://www.monodevelop.com/ +[3]: https://dotnet.microsoft.com/download +[4]: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet?tabs=netcore21 +[5]: https://opensource.com/sites/default/files/uploads/dotnet-windows-install.jpg (Installing dotnet on Windows) +[6]: https://vscodium.com/ +[7]: https://github.com/VSCodium/vscodium/blob/master/DOCS.md +[8]: https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/intro-to-csharp/ +[9]: https://opensource.com/users/alex-bunardzic (View user profile.)