From 9ff02f2feca744d47cfcaeca2a86eea1956b90d1 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 23 Nov 2017 23:35:23 +0800 Subject: [PATCH 001/344] 2017-11-23 23:35 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2017-11-23 23:35 第一段 --- .../tech/20170530 How to Improve a Legacy Codebase.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sources/tech/20170530 How to Improve a Legacy Codebase.md b/sources/tech/20170530 How to Improve a Legacy Codebase.md index cff5e70538..7e2b257949 100644 --- a/sources/tech/20170530 How to Improve a Legacy Codebase.md +++ b/sources/tech/20170530 How to Improve a Legacy Codebase.md @@ -1,17 +1,24 @@ Translating by aiwhj # How to Improve a Legacy Codebase - +# 如何改善遗留的代码库 It happens at least once in the lifetime of every programmer, project manager or teamleader. You get handed a steaming pile of manure, if you’re lucky only a few million lines worth, the original programmers have long ago left for sunnier places and the documentation - if there is any to begin with - is hopelessly out of sync with what is presently keeping the company afloat. -Your job: get us out of this mess. +它在每一个程序员,项目管理员,团队领导的一生中都会发生至少一次。原来的程序员离开了这个地方,只留下了文档,和一坨几百万行屎一样的代码。一旦接管这些代码,想要跟上公司的进度简直让人绝望。 +Your job: get us out of this mess. +你的任务:让大家摆脱这个混乱的局面 + +当你的第一反应过去之后,你开始去熟悉这个项目,公司的管理层都在关注着,项目只能成功,然而,看了一遍之后却发现了许多的错误。该怎么做呢? After your first instinctive response (run for the hills) has passed you start on the project knowing full well that the eyes of the company senior leadership are on you. Failure is not an option. And yet, by the looks of what you’ve been given failure is very much in the cards. So what to do? +幸运(不幸)的是我已经遇到好几次这种情况了,我和我的小伙伴发现将这坨热气腾腾的屎变成一个健康可维护的项目是很值得的。下面这些是我使用的一些小技巧: I’ve been (un)fortunate enough to be in this situation several times and me and a small band of friends have found that it is a lucrative business to be able to take these steaming piles of misery and to turn them into healthy maintainable projects. Here are some of the tricks that we employ: ### Backup +### 备份 +在你去做任何事情之前备份与之相关的所有东西。这样可以确保不会丢失任何信息,这些信息可能会在一些地方很重要, Before you start to do anything at all make a backup of  _everything_  that might be relevant. This to make sure that no information is lost that might be of crucial importance somewhere down the line. All it takes is a silly question that you can’t answer to eat up a day or more once the change has been made. Especially configuration data is susceptible to this kind of problem, it is usually not versioned and you’re lucky if it is taken along in the periodic back-up scheme. So better safe than sorry, copy everything to a very safe place and never ever touch that unless it is in read-only mode. ### Important pre-requisite, make sure you have a build process and that it actually produces what runs in production From ebc5b78f4a40097896978289b83af7ce37982612 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 28 Nov 2017 23:04:59 +0800 Subject: [PATCH 002/344] PRF&PUB:20171110 File better bugs with coredumpctl.md @geekpi --- ...71110 File better bugs with coredumpctl.md | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) rename {translated/tech => published}/20171110 File better bugs with coredumpctl.md (50%) diff --git a/translated/tech/20171110 File better bugs with coredumpctl.md b/published/20171110 File better bugs with coredumpctl.md similarity index 50% rename from translated/tech/20171110 File better bugs with coredumpctl.md rename to published/20171110 File better bugs with coredumpctl.md index 06d7d700f7..e06604ef3f 100644 --- a/translated/tech/20171110 File better bugs with coredumpctl.md +++ b/published/20171110 File better bugs with coredumpctl.md @@ -1,34 +1,35 @@ -# [用 coredumpctl 更好地记录 bug][1] +用 coredumpctl 更好地记录 bug +=========== ![](https://fedoramagazine.org/wp-content/uploads/2017/11/coredump.png-945x400.jpg) -一个不幸的事实是,所有的软件都有 bug,一些 bug 会导致系统崩溃。当它出现的时候,它经常会在磁盘上留下一个名为 _core dump_ 的数据文件。该文件包含有关系统崩溃时的相关数据,可能有助于确定发生崩溃的原因。通常开发者要求有显示导致崩溃的指令流的 _backtrace_ 形式的数据。开发人员可以使用它来修复 bug 并改进系统。如果系统崩溃,以下是如何轻松生成 backtrace 的方法。 +一个不幸的事实是,所有的软件都有 bug,一些 bug 会导致系统崩溃。当它出现的时候,它经常会在磁盘上留下一个被称为“核心转储core dump”的数据文件。该文件包含有关系统崩溃时的相关数据,可能有助于确定发生崩溃的原因。通常开发者要求提供 “回溯backtrace” 形式的数据,以显示导致崩溃的指令流。开发人员可以使用它来修复 bug 以改进系统。如果系统发生了崩溃,以下是如何轻松生成 回溯backtrace 的方法。 -### 开始使用 coredumpctl +### 从使用 coredumpctl 开始 -大多数 Fedora 系统使用[自动错误报告工具 (ABRT)][2]来自动捕获崩溃文件并记录 bug。但是,如果你禁用了此服务或删除了该软件包,则此方法可能会有所帮助。 +大多数 Fedora 系统使用[自动错误报告工具(ABRT)][2]来自动捕获崩溃文件并记录 bug。但是,如果你禁用了此服务或删除了该软件包,则此方法可能会有所帮助。 -如果你遇到系统崩溃,请首先确保你运行的是最新的软件。更新通常包含修复程序,这些更新通常含有已经发现的会导致严重错误和崩溃的错误的修复。当你更新后,请尝试重新创建导致错误的情况。 +如果你遇到系统崩溃,请首先确保你运行的是最新的软件。更新通常包含修复程序,这些更新通常含有已经发现的会导致严重错误和崩溃的错误的修复。当你更新后,请尝试重现导致错误的情况。 -如果崩溃仍然发生,或者你已经在运行最新的软件,那么可以使用有用的 _coredumpctl_。此程序可帮助查找和处理崩溃。要查看系统上所有核心转储列表,请运行以下命令: +如果崩溃仍然发生,或者你已经在运行最新的软件,那么可以使用有用的 `coredumpctl` 工具。此程序可帮助查找和处理崩溃。要查看系统上所有核心转储列表,请运行以下命令: ``` coredumpctl list ``` -如果你看到比预期长的列表,请不要感到惊讶。有时系统组件在后台默默地崩溃,并自行恢复。现在快速查找转储的简单方法是使用 _-since_ 选项: +如果你看到比预期长的列表,请不要感到惊讶。有时系统组件在后台默默地崩溃,并自行恢复。快速查找今天的转储的简单方法是使用 `-since` 选项: ``` coredumpctl list --since=today ``` -_PID_ 列包含用于标识转储的进程 ID。请注意这个数字,因为你会之后再用到它。或者,如果你不想记住它,使用下面的命令将它赋值给一个变量: +“PID” 列包含用于标识转储的进程 ID。请注意这个数字,因为你会之后再用到它。或者,如果你不想记住它,使用下面的命令将它赋值给一个变量: ``` MYPID= ``` -要查看关于核心转储的信息,请使用此命令(使用 _$MYPID_ 变量或替换 PID 编号): +要查看关于核心转储的信息,请使用此命令(使用 `$MYPID` 变量或替换 PID 编号): ``` coredumpctl info $MYPID @@ -36,42 +37,42 @@ coredumpctl info $MYPID ### 安装 debuginfo 包 -在核心转储中的数据以及原始代码中的指令之间调试符号转义。这个符号数据可能相当大。因此,符号以 _debuginfo_ 软件包的形式与大多数用户使用的 Fedora 系统分开安装。要确定你必须安装哪些 debuginfo 包,请先运行以下命令: +在核心转储中的数据以及原始代码中的指令之间调试符号转义。这个符号数据可能相当大。与大多数用户运行在 Fedora 系统上的软件包不同,符号以 “debuginfo” 软件包的形式安装。要确定你必须安装哪些 debuginfo 包,请先运行以下命令: ``` coredumpctl gdb $MYPID ``` -这可能会在屏幕上显示大量信息。最后一行可能会告诉你使用 _dnf_ 安装更多的 debuginfo 软件包。[用 sudo ][3]运行该命令: +这可能会在屏幕上显示大量信息。最后一行可能会告诉你使用 `dnf` 安装更多的 debuginfo 软件包。[用 sudo ][3]运行该命令以安装: ``` sudo dnf debuginfo-install  ``` -然后再次尝试 _coredumpctl gdb $MYPID_ 命令。**你可能需要重复执行此操作**,因为其他符号会在 trace 中展开。 +然后再次尝试 `coredumpctl gdb $MYPID` 命令。**你可能需要重复执行此操作**,因为其他符号会在回溯中展开。 -### 捕获 backtrace +### 捕获回溯 -运行以下命令以在调试器中记录信息: +在调试器中运行以下命令以记录信息: ``` set logging file mybacktrace.txt set logging on ``` -你可能会发现关闭分页有帮助。对于长的 backtrace,这可以节省时间。 +你可能会发现关闭分页有帮助。对于长的回溯,这可以节省时间。 ``` set pagination off ``` -现在运行 backtrace: +现在运行回溯: ``` thread apply all bt full ``` -现在你可以输入 _quit_ 来退出调试器。_mybacktrace.txt_ 包含可附加到 bug 或问题的追踪信息。或者,如果你正在与某人实时合作,则可以将文本上传到 pastebin。无论哪种方式,你现在可以向开发人员提供更多的帮助来解决问题。 +现在你可以输入 `quit` 来退出调试器。`mybacktrace.txt` 包含可附加到 bug 或问题的追踪信息。或者,如果你正在与某人实时合作,则可以将文本上传到 pastebin。无论哪种方式,你现在可以向开发人员提供更多的帮助来解决问题。 --------------------------------- @@ -85,9 +86,9 @@ Paul W. Frields 自 1997 年以来一直是 Linux 用户和爱好者,并于 20 via: https://fedoramagazine.org/file-better-bugs-coredumpctl/ -作者:[Paul W. Frields ][a] +作者:[Paul W. Frields][a] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 8003cf12b90de8a930edc9bf74d2b3a0cde6bca7 Mon Sep 17 00:00:00 2001 From: Cwndmiao Date: Tue, 28 Nov 2017 23:33:08 +0800 Subject: [PATCH 003/344] translated "20141028 When Does Your OS Run.md" --- .../tech/20141028 When Does Your OS Run.md | 55 ------------------- .../tech/20141028 When Does Your OS Run.md | 53 ++++++++++++++++++ 2 files changed, 53 insertions(+), 55 deletions(-) delete mode 100644 sources/tech/20141028 When Does Your OS Run.md create mode 100644 translated/tech/20141028 When Does Your OS Run.md diff --git a/sources/tech/20141028 When Does Your OS Run.md b/sources/tech/20141028 When Does Your OS Run.md deleted file mode 100644 index 0545ab579d..0000000000 --- a/sources/tech/20141028 When Does Your OS Run.md +++ /dev/null @@ -1,55 +0,0 @@ -Translating by Cwndmiao - -When Does Your OS Run? -============================================================ - - -Here’s a question: in the time it takes you to read this sentence, has your OS been  _running_ ? Or was it only your browser? Or were they perhaps both idle, just waiting for you to  _do something already_ ? - -These questions are simple but they cut through the essence of how software works. To answer them accurately we need a good mental model of OS behavior, which in turn informs performance, security, and troubleshooting decisions. We’ll build such a model in this post series using Linux as the primary OS, with guest appearances by OS X and Windows. I’ll link to the Linux kernel sources for those who want to delve deeper. - -The fundamental axiom here is that  _at any given moment, exactly one task is active on a CPU_ . The task is normally a program, like your browser or music player, or it could be an operating system thread, but it is one task. Not two or more. Never zero, either. One. Always. - -This sounds like trouble. For what if, say, your music player hogs the CPU and doesn’t let any other tasks run? You would not be able to open a tool to kill it, and even mouse clicks would be futile as the OS wouldn’t process them. You could be stuck blaring “What does the fox say?” and incite a workplace riot. - -That’s where interrupts come in. Much as the nervous system interrupts the brain to bring in external stimuli – a loud noise, a touch on the shoulder – the [chipset][1] in a computer’s motherboard interrupts the CPU to deliver news of outside events – key presses, the arrival of network packets, the completion of a hard drive read, and so on. Hardware peripherals, the interrupt controller on the motherboard, and the CPU itself all work together to implement these interruptions, called interrupts for short. - -Interrupts are also essential in tracking that which we hold dearest: time. During the [boot process][2] the kernel programs a hardware timer to issue timer interrupts at a periodic interval, for example every 10 milliseconds. When the timer goes off, the kernel gets a shot at the CPU to update system statistics and take stock of things: has the current program been running for too long? Has a TCP timeout expired? Interrupts give the kernel a chance to both ponder these questions and take appropriate actions. It’s as if you set periodic alarms throughout the day and used them as checkpoints: should I be doing what I’m doing right now? Is there anything more pressing? One day you find ten years have got behind you. - -These periodic hijackings of the CPU by the kernel are called ticks, so interrupts quite literally make your OS tick. But there’s more: interrupts are also used to handle some software events like integer overflows and page faults, which involve no external hardware. Interrupts are the most frequent and crucial entry point into the OS kernel. They’re not some oddity for the EE people to worry about, they’re  _the_  mechanism whereby your OS runs. - -Enough talk, let’s see some action. Below is a network card interrupt in an Intel Core i5 system. The diagrams now have image maps, so you can click on juicy bits for more information. For example, each device links to its Linux driver. - -![](http://duartes.org/gustavo/blog/img/os/hardware-interrupt.png) - - - -Let’s take a look at this. First off, since there are many sources of interrupts, it wouldn’t be very helpful if the hardware simply told the CPU “hey, something happened!” and left it at that. The suspense would be unbearable. So each device is assigned an interrupt request line, or IRQ, during power up. These IRQs are in turn mapped into interrupt vectors, a number between 0 and 255, by the interrupt controller. By the time an interrupt reaches the CPU it has a nice, well-defined number insulated from the vagaries of hardware. - -The CPU in turn has a pointer to what’s essentially an array of 255 functions, supplied by the kernel, where each function is the handler for that particular interrupt vector. We’ll look at this array, the Interrupt Descriptor Table (IDT), in more detail later on. - -Whenever an interrupt arrives, the CPU uses its vector as an index into the IDT and runs the appropriate handler. This happens as a special function call that takes place in the context of the currently running task, allowing the OS to respond to external events quickly and with minimal overhead. So web servers out there indirectly  _call a function in your CPU_  when they send you data, which is either pretty cool or terrifying. Below we show a situation where a CPU is busy running a Vim command when an interrupt arrives: - -![](http://duartes.org/gustavo/blog/img/os/vim-interrupted.png) - -Notice how the interrupt’s arrival causes a switch to kernel mode and [ring zero][3] but it  _does not change the active task_ . It’s as if Vim made a magic function call straight into the kernel, but Vim is  _still there_ , its [address space][4] intact, waiting for that call to return. - -Exciting stuff! Alas, I need to keep this post-sized, so let’s finish up for now. I understand we have not answered the opening question and have in fact opened up new questions, but you now suspect ticks were taking place while you read that sentence. We’ll find the answers as we flesh out our model of dynamic OS behavior, and the browser scenario will become clear. If you have questions, especially as the posts come out, fire away and I’ll try to answer them in the posts themselves or as comments. Next installment is tomorrow on [RSS][5] and [Twitter][6]. - --------------------------------------------------------------------------------- - -via: http://duartes.org/gustavo/blog/post/when-does-your-os-run/ - -作者:[gustavo ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://duartes.org/gustavo/blog/about/ -[1]:http://duartes.org/gustavo/blog/post/motherboard-chipsets-memory-map -[2]:http://duartes.org/gustavo/blog/post/kernel-boot-process -[3]:http://duartes.org/gustavo/blog/post/cpu-rings-privilege-and-protection -[4]:http://duartes.org/gustavo/blog/post/anatomy-of-a-program-in-memory -[5]:http://feeds.feedburner.com/GustavoDuarte -[6]:http://twitter.com/food4hackers diff --git a/translated/tech/20141028 When Does Your OS Run.md b/translated/tech/20141028 When Does Your OS Run.md new file mode 100644 index 0000000000..893dd9fb48 --- /dev/null +++ b/translated/tech/20141028 When Does Your OS Run.md @@ -0,0 +1,53 @@ +操作系统何时运行? +============================================================ + + +请各位思考以下问题:在你阅读本文的这段时间内,计算机中的操作系统在运行吗?又或者仅仅是 Web 浏览器在运行?又或者他们也许均处于空闲状态,等待着你的指示? + +这些问题并不复杂,但他们深入涉及到系统软件工作的本质。为了准确回答这些问题,我们需要透彻理解操作系统的行为模型,包括性能、安全和除错等方面。在该系列文章中,我们将以 Linux 为主举例来帮助你建立操作系统的行为模型,OS X 和 Windows 在必要的时候也会有所涉及。对那些深度探索者,我会在适当的时候给出 Linux 内核源码的链接。 + +这里有一个基本认知,就是,在任意给定时刻,某个 CPU 上仅有一个任务处于活动状态。大多数情形下这个任务是某个用户程序,例如你的 Web 浏览器或音乐播放器,但他也可能是一个操作系统线程。可以确信的是,他是一个任务,不是两个或更多,也不是零个,对,永远是一个。 + +这听上去可能会有些问题。比如,你的音乐播放器是否会独占 CPU 而阻止其他任务运行?从而使你不能打开任务管理工具去杀死音乐播放器,甚至让鼠标点击也失效,因为操作系统没有机会去处理这些事件。你可能会奋而喊出,“他究竟在搞什么鬼?”,并引发骚乱。 + +此时便轮到中断大显身手了。中断就好比,一声巨响或一次拍肩后,神经系统通知大脑去感知外部刺激一般。计算机主板上的芯片组同样会中断 CPU 运行以传递新的外部事件,例如键盘上的某个键被按下、网络数据包的到达、一次硬盘读的完成,等等。硬件外设、主板上的中断控制器和 CPU 本身,他们共同协作实现了中断机制。 + +中断对于簿记我们最珍视的资源--时间也至关重要。计算机启动过程中,操作系统内核会设置一个硬件计时器以让其产生周期性计时中断,例如每隔 10 毫秒触发一次。每当计时中断到来,内核便会收到通知以更新系统统计信息和盘点如下事项:当前用户程序是否已运行了足够长时间?是否有某个 TCP 定时器超时了?中断给予了内核一个处理这些问题并采取合适措施的机会。这就好像你给自己设置了整天的周期闹铃并把他们用作检查点:我是否应该去做我正在进行的工作?是否存在更紧急的事项?直到你发现 10 年时间已逝去。。。 + +这些内核对 CPU 周期性的劫持被称为滴答,也就是说,是中断让操作系统经历了滴答的过程。不止如此,中断也被用作处理一些软件事件,如整数溢出和页错误,其中未涉及外部硬件。中断是进入操作系统内核最频繁也是最重要的入口。对于学习电子工程的人而言,这些并无古怪,他们是操作系统赖以运行的机制。 + +说到这里,让我们再来看一些实际情形。下图示意了 Intel Core i5 系统中的一个网卡中断。图片现在设置了超链,你可以点击他们以获取更为详细的信息,例如每个设备均被链接到了对应的 Linux 驱动源码。 + +![](http://duartes.org/gustavo/blog/img/os/hardware-interrupt.png) + + + +让我们来仔细研究下。首先,由于系统中存在众多中断源,如果硬件只是通知 CPU “嘿,这里发生了一些事情”然后什么也不做,则不太行得通。这会带来难以忍受的冗长等待。因此,计算机上电时,每个设备都被授予了一根中断线,或者称为 IRQ。这些 IRQ 然后被系统中的中断控制器映射成值介于 0 到 255 之间的中断向量。等到中断到达 CPU,他便具备了一个定义良好的数值,异于硬件的某些其他诡异行为。 + +相应地,CPU 中还存有一个由内核维护的指针,指向一个包含 255 个函数指针的数组,其中每个函数被用来处理某个特定的中断向量。后文中,我们将继续深入探讨这个数组,他也被称作中断描述符表(IDT)。 + +每当中断到来,CPU 会用中断向量的值去索引中断描述符表,并执行相应处理函数。这相当于,在当前正在执行任务的上下文中,发生了一个特殊函数调用,从而允许操作系统以较小开销快速对外部事件作出反应。考虑下述场景,Web 服务器在发送数据时,CPU 却间接调用了操作系统函数,这听上去要么很炫酷要么令人惊恐。下图展示了 Vim 编辑器运行过程中一个中断到来的情形。 + +![](http://duartes.org/gustavo/blog/img/os/vim-interrupted.png) + +此处请留意,中断的到来是如何触发 CPU 到 Ring 0 内核模式的切换而未有改变当前活跃的任务。这看上去就像,Vim 编辑器直接面向操作系统内核产生了一次神奇的函数调用,但 Vim 还在那里,他的地址空间原封未动,等待着执行流返回。 + +这很令人振奋,不是么?不过让我们暂且告一段落吧,我需要合理控制篇幅。我知道还没有回答完这个开放式问题,甚至还实质上翻开了新的问题,但你至少知道了在你读这个句子的同时滴答正在发生。我们将在充实了对操作系统动态行为模型的理解之后再回来寻求问题的答案,对 Web 浏览器情形的理解也会变得清晰。如果你仍有问题,尤其是在这篇文章公诸于众后,请尽管提出。我将会在文章或后续评论中回答他们。下篇文章将于明天在 RSS 和 Twitter 上发布。 + +-------------------------------------------------------------------------------- + +via: http://duartes.org/gustavo/blog/post/when-does-your-os-run/ + +作者:[gustavo ][a] +译者:[Cwndmiao](https://github.com/Cwndmiao) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://duartes.org/gustavo/blog/about/ +[1]:http://duartes.org/gustavo/blog/post/motherboard-chipsets-memory-map +[2]:http://duartes.org/gustavo/blog/post/kernel-boot-process +[3]:http://duartes.org/gustavo/blog/post/cpu-rings-privilege-and-protection +[4]:http://duartes.org/gustavo/blog/post/anatomy-of-a-program-in-memory +[5]:http://feeds.feedburner.com/GustavoDuarte +[6]:http://twitter.com/food4hackers From d49ef83e87992c74b0235cf116259861d335755b Mon Sep 17 00:00:00 2001 From: Chao-zhi Liu Date: Wed, 29 Nov 2017 00:51:46 +0800 Subject: [PATCH 004/344] Update and rename sources/talk/20170119 Be a force for good in your community.md to translated/talk/20170119 Be a force for good in your community.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译完成 --- ...9 Be a force for good in your community.md | 130 ------------------ ...9 Be a force for good in your community.md | 128 +++++++++++++++++ 2 files changed, 128 insertions(+), 130 deletions(-) delete mode 100644 sources/talk/20170119 Be a force for good in your community.md create mode 100644 translated/talk/20170119 Be a force for good in your community.md diff --git a/sources/talk/20170119 Be a force for good in your community.md b/sources/talk/20170119 Be a force for good in your community.md deleted file mode 100644 index 22c43d8470..0000000000 --- a/sources/talk/20170119 Be a force for good in your community.md +++ /dev/null @@ -1,130 +0,0 @@ -Translating by chao-zhi - -Be a force for good in your community -============================================================ - ->Find out how to give the gift of an out, learn about the power of positive intent, and more. - - ![Be a force for good in your community](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/people_remote_teams_world.png?itok=wI-GW8zX "Be a force for good in your community") - ->Image by : opensource.com - -Passionate debate is among the hallmark traits of open source communities and open organizations. On our best days, these debates are energetic and constructive. They are heated, yet moderated with humor and goodwill. All parties remain focused on facts, on the shared purpose of collaborative problem-solving, and driving continuous improvement. And for many of us, they're just plain fun. - -On our worst days, these debates devolve into rehashing the same old arguments on the same old topics. Or we turn on one another, delivering insults—passive-aggressive or outright nasty, depending on our style—and eroding the passion, trust, and productivity of our communities. - -We've all been there, watching and feeling helpless, as a community conversation begins to turn toxic. Yet, as [DeLisa Alexander recently shared][1], there are so many ways that each and every one of us can be a force for good in our communities. - -In the first article of this "open culture" series, I will share a few strategies for how you can intervene, in that crucial moment, and steer everyone to a more positive and productive place. - -### Don't call people out. Call them up. - -Recently, I had lunch with my friend and colleague, [Mark Rumbles][2]. Over the years, we've collaborated on a number of projects that support open culture and leadership at Red Hat. On this day, Mark asked me how I was holding up, as he saw I'd recently intervened in a mailing list conversation when I saw the debate was getting ugly. - -Fortunately, the dust had long since settled, and in fact I'd almost forgotten about the conversation. Nevertheless, it led us to talk about the challenges of open and frank debate in a community that has thousands of members. - ->One of the biggest ways we can be a force for good in our communities is to respond to conflict in a way that compels everyone to elevate their behavior, rather than escalate it. - -Mark said something that struck me as rather insightful. He said, "You know, as a community, we are really good at calling each other out. But what I'd like to see us do more of is calling each other _up_." - -Mark is absolutely right. One of the biggest ways we can be a force for good in our communities is to respond to conflict in a way that compels everyone to elevate their behavior, rather than escalate it. - -### Assume positive intent - -We can start by making a simple assumption when we observe poor behavior in a heated conversation: It's entirely possible that there are positive intentions somewhere in the mix. - -This is admittedly not an easy thing to do. When I see signs that a debate is turning nasty, I pause and ask myself what Steven Covey calls The Humanizing Question: - -"Why would a reasonable, rational, and decent person do something like this?" - -Now, if this is one of your "usual suspects"—a community member with a propensity toward negative behavior--perhaps your first thought is, "Um, what if this person _isn't_ reasonable, rational, or decent?" - -Stay with me, now. I'm not suggesting that you engage in some touchy-feely form of self-delusion. It's called The Humanizing Question not only because asking it humanizes the other person, but also because it humanizes _you_. - -And that, in turn, helps you respond or intervene from the most productive possible place. - -### Seek to understand the reasons for community dissent - -When I ask myself why a reasonable, rational, and decent person might do something like this, time and again, it comes down to the same few reasons: - -* They don't feel heard. -* They don't feel respected. -* They don't feel understood. - -One easy positive intention we can apply to almost any poor behavior, then, is that the person wants to be heard, respected, or understood. That's pretty reasonable, I suppose. - -By standing in this more objective and compassionate place, we can see that their behavior is _almost certainly _**_not_**_ going to help them get what they want, _and that the community will suffer as a result . . . without our help. - -For me, that inspires a desire to help everyone get "unstuck" from this ugly place we're in. - -Before I intervene, though, I ask myself a follow-up question: _What other positive intentions might be driving this behavior?_ - -Examples that readily jump to mind include: - -* They are worried that we're missing something important, or we're making a mistake, and no one else seems to see it. -* They want to feel valued for their contributions. -* They are burned out, because of overworking in the community or things happening in their personal life. -* They are tired of something being broken and frustrated that no one else seems to see the damage or inconvenience that creates. -* ...and so on and so forth. - -With that, I have a rich supply of positive intent that I can ascribe to their behavior. I'm ready to reach out and offer them some help, in the form of an out. - -### Give the gift of an out - -What is an out? Think of it as an escape hatch. It's a way to exit the conversation, or abandon the poor behavior and resume behaving like a decent person, without losing face. It's calling someone up, rather than calling them out. - -You've probably experienced this, as some point in your life, when _you_ were behaving poorly in a conversation, ranting and hollering and generally raising a fuss about something or another, and someone graciously offered _you_ a way out. Perhaps they chose not to "take the bait" by responding to your unkind choice of words, and instead, said something that demonstrated they believed you were a reasonable, rational, and decent human being with positive intentions, such as: - -> _So, uh, what I'm hearing is that you're really worried about this, and you're frustrated because it seems like no one is listening. Or maybe you're concerned that we're missing the significance of it. Is that about right?_ - -And here's the thing: Even if that wasn't entirely true (perhaps you had less-than-noble intentions), in that moment, you probably grabbed ahold of that life preserver they handed you, and gladly accepted the opportunity to reframe your poor behavior. You almost certainly pivoted and moved to a more productive place, likely without even recognizing it. - -Perhaps you said something like, "Well, it's not that exactly, but I just worry that we're headed down the wrong path here, and I get what you're saying that as community, we can't solve every problem at the same time, but if we don't solve this one soon, bad things are going to happen…" - -In the end, the conversation almost certainly began to move to a more productive place, or you all agreed to disagree. - -We all have the opportunity to offer an upset person a safe way out of that destructive place they're operating from. Here's how. - -### Bad behavior or bad actor? - -If the person is particularly agitated, they may not hear or accept the first out you hand them. That's okay. Most likely, their lizard brain--that prehistoric amygdala that was once critical for human survival—has taken over, and they need a few more moments to recognize you're not a threat. Just keep gently but firmly treating them as if they _were_ a rational, reasonable, decent human being, and watch what happens. - -In my experience, these community interventions end in one of three ways: - -Most often, the person actually _is_ a reasonable person, and soon enough, they gratefully and graciously accept the out. In the process, everyone breaks out of the black vs. white, "win or lose" mindset. People begin to think up creative alternatives and "win-win" outcomes that benefit everyone. - ->Why would a reasonable, rational, and decent person do something like this? - -Occasionally, the person is not particularly reasonable, rational, or decent by nature, but when treated with such consistent, tireless, patient generosity and kindness (by you), they are shamed into retreating from the conversation. This sounds like, "Well, I think I've said all I have to say. Thanks for hearing me out." Or, for less enlightened types, "Well, I'm tired of this conversation. Let's drop it." (Yes, please. Thank you.) - -Less often, the person is what's known as a _bad actor_, or in community management circles, a pot-stirrer. These folks do exist, and they thrive on drama. Guess what? By consistently engaging in a kind, generous, community-calming way, and entirely ignoring all attempts to escalate the situation, you effectively shift the conversation into an area that holds little interest for them. They have no choice but to abandon it. Winners all around. - -That's the power of assuming positive intent. By responding to angry and hostile words with grace and dignity, you can diffuse a flamewar, untangle and solve tricky problems, and quite possibly make a new friend or two in the process. - -Am I successful every time I apply this principle? Heck, no. But I never regret the choice to assume positive intent. And I can vividly recall a few unfortunate occasions when I assumed negative intent and responded in a way that further contributed to the problem. - -Now it's your turn. I'd love to hear about some strategies and principles you apply, to be a force for good when conversations get heated in your community. Share your thoughts in the comments below. - -Next time, we'll explore more ways to be a force for good in your community, and I'll share some tips for handling "Mr. Grumpy." - --------------------------------------------------------------------------------- - -作者简介: - -![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/headshot-square_0.jpg?itok=FS97b9YD) - -Rebecca Fernandez is a Principal Employment Branding + Communications Specialist at Red Hat, a contributor to The Open Organization book, and the maintainer of the Open Decision Framework. She is interested in open source and the intersection of the open source way with business management models. Twitter: @ruhbehka - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/17/1/force-for-good-community - -作者:[Rebecca Fernandez][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/rebecca -[1]:https://opensource.com/business/15/5/5-ways-promote-inclusive-environment -[2]:https://twitter.com/leadership_365 diff --git a/translated/talk/20170119 Be a force for good in your community.md b/translated/talk/20170119 Be a force for good in your community.md new file mode 100644 index 0000000000..035409c4c1 --- /dev/null +++ b/translated/talk/20170119 Be a force for good in your community.md @@ -0,0 +1,128 @@ +成为你所在社区的美好力量 +============================================================ + +>明白如何传递美好,了解积极意愿的力量,以及更多。 + + ![Be a force for good in your community](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/people_remote_teams_world.png?itok=wI-GW8zX "Be a force for good in your community") + +>图片来自:opensource.com + +激烈的争论是开源社区和开放组织的标志特征之一。在我们最好的日子里,这些争论充满活力和建设性。他们面红耳赤的背后其实是幽默和善意。各方实事求是,共同解决问题,推动持续改进。对我们中的许多人来说,他们只是单纯的娱乐而已。 + +然而在我们最糟糕的日子里,这些争论演变成了对旧话题的反复争吵。或者我们用各种方式来传递伤害和相互攻击,或是使用卑劣的手段,而这些侵蚀着我们社区的激情、信任和生产力。 + +我们茫然四顾,束手无策,因为社区的对话开始变得有毒。然而,正如 [DeLisa Alexander最近的分享][1],我们每个人都有很多方法可以成为我们社区的一种力量。 + +在这个“开源文化”系列的第一篇文章中,我将分享一些策略,教你如何在这个关键时刻进行干预,引导每个人走向更积极、更有效率的方向。 + +### 不要将人推开,而是将人推向前方 + +最近,我和我的朋友和同事 [Mark Rumbles][2] 一起吃午饭。多年来,我们在许多支持开源文化和引领 Red Hat 的项目中合作。在这一天,马克问我是怎么坚持的,当我看到辩论变得越来越丑陋的时候,他看到我最近介入了一个邮件列表的对话。 + +幸运的是,这事早已尘埃落定,事实上我几乎忘记了谈话的内容。然而,它让我们开始讨论如何在一个拥有数千名成员的社区里,公开和坦率的辩论。 + +>在我们的社区里,我们成为一种美好力量的最好的方法之一就是:在回应冲突时,以一种迫使每个人提升他们的行为,而不是使冲突升级的方式。 + +Mark 说了一些让我印象深刻的话。他说:“你知道,作为一个社区,我们真的很擅长将人推开。但我想看到的是,我们更多的是互相扶持 _向前_ 。” + +Mark 是绝对正确的。在我们的社区里,我们成为一种美好力量的最好的方法之一就是:在回应冲突时,以一种迫使每个人提升他们的行为,而不是使冲突升级的方式。 + +### 积极意愿假想 + +我们可以从一个简单的假想开始,当我们在一个激烈的对话中观察到不良行为时:完全有可能该不良行为其实有着积极意愿。 + +诚然,这不是一件容易的事情。当我看到一场辩论正在变得肮脏的迹象时,我停下来问自己,史蒂芬·科维(Steven Covey)所说的人性化问题是什么: + +“为什么一个理性、正直的人会做这样的事情?” + +现在,如果他是你的一个“普通的观察对象”——一个有消极行为倾向的社区成员——也许你的第一个想法是,“嗯,也许这个人是个不靠谱,不理智的人” + +回过头来说。我并不是说你让你自欺欺人。这其实就是人性化的问题,不仅是因为它让你理解别人的立场,它还让你变得人性化。 + +而这反过来又能帮助你做出反应,或者从最有效率的地方进行干预。 + +### 寻求了解社区异议的原因 + +当我再一次问自己为什么一个理性的、正直的人可能会做这样的事情时,归结为几个原因: + +* 他认为没人聆听他 +* 他认为没人尊重他 +* 他认为没人理解他 + +一个简单的积极意愿假想,我们可以适用于几乎所有的不良行为,其实就是那个人想要被聆听,被尊重,或被理解。我想这是相当合理的。 + +通过站在这个更客观、更有同情心的角度,我们可以看到他们的行为几乎肯定 **_不_** 会帮助他们得到他们想要的东西,而社区也会因此而受到影响。如果没有我们的帮助的话。 + +对我来说,这激发了一个愿望:帮助每个人从我们所处的这个丑陋的地方“摆脱困境”。 + +在我介入之前,我问自己一个后续的问题:是否有其他积极的意图可能会驱使这种行为 + +容易想到的例子包括: + +* 他们担心我们错过了一些重要的东西,或者我们犯了一个错误,没有人能看到它。 +* 他们想为自己的贡献感到有价值。 +* 他们精疲力竭,因为在社区里工作过度或者在他们的个人生活中发生了一些事情。 +* 他们讨厌一些东西被破坏,并感到沮丧,因为没有人能看到造成的伤害或不便。 +* ……诸如此类。 + +有了这些,我就有了丰富的积极的意图假想,我可以为他们的行为找到原因。我准备伸出援助之手,向他们提供一些帮助。 + +### 传递美好,挣脱泥潭 + +什么是 an out?(类似与佛家“解脱法门”的意思)把它想象成一个逃跑的门。这是一种退出对话的方式,或者放弃不良的行为,恢复表现得像一个体面的人,而不是丢面子。是叫某人振作向上,而不是叫他走开。 + +你可能经历过这样的事情,在你的生活中,当 _你_ 在一次谈话中表现不佳时,咆哮着,大喊大叫,对某事大惊小怪,而有人慷慨地给 _你_ 提供了一个台阶下。也许他们选择不去和你“抬杠”,相反,他们说了一些表明他们相信你是一个理性、正直的人,他们采用积极意愿假想,比如: + +> _所以,嗯,我听到的是你真的很担心,你很沮丧,因为似乎没有人在听。或者你担心我们忽略了它的重要性。是这样对吧?_ + +于是乎:即使这不是完全正确的(也许你的意图不那么高尚),在那一刻,你可能抓住了他们提供给你的台阶,并欣然接受了重新定义你的不良行为的机会。你几乎可以肯定地转向一个更富有成效的角度,甚至你自己可能都没有意识到。 + +也许你这样说,“哦,虽然不完全是这样,但我只是担心,我们这样会走向歧途,我明白你说的,作为社区,我们不能同时解决所有问题,但如果我们不尽快解决这个问题,会有更多不好的事情要发生……” + +最后,谈话几乎可以肯定地开始转移到一个更有效率的方向。 + +我们都有机会让一个沮丧的人挣脱泥潭,而这就是方法。 + +### 坏行为还是坏人? + +如果这个人特别激动,他们可能不会听到或者接受你给出的第一台阶。没关系。最可能的是,他们迟钝的大脑已经被史前曾经对人类生存至关重要的杏仁核接管了,他们需要更多的时间来认识到你并不是一个威胁。只是需要你保持温和的态度,坚定地对待他们,就好像他们 _曾经是_ 一个理性、正直的人,看看会发生什么。 + +根据我的经验,这些社区干预以三种方式结束: + +大多数情况下,这个人实际上 _是_ 一个理性的人,很快,他们就感激地接受了这个事实。在这个过程中,每个人都跳出了“黑与白”,“赢或输”的心态。人们开始思考创造性的选择和“双赢”的结果,每个人都将受益。 + +> 为什么一个理性、正直的人会做这样的事呢? + +有时候,这个人天生不是特别理性或正直的,但当他被你以如此一致的、不知疲倦的、耐心的慷慨和善良的对待的时候,他们就会羞愧地从谈话中撤退。这听起来像是,“嗯,我想我已经说了所有要说的了。谢谢你听我的意见”。或者,对于不那么开明的人来说,“嗯,我厌倦了这种谈话。让我们结束吧。”(好的,谢谢)。 + +更少的情况是,这个人是一个“_坏人_”,或者在社区管理圈子里,是一个“搅屎棍”。这些人确实存在,而且他们在演戏方面很有发展。你猜怎么着?通过持续地以一种友善、慷慨、以社区为中心的方式,完全无视所有试图使局势升级的尝试,你有效地将谈话变成了一个对他们没有兴趣的领域。他们别无选择,只能放弃它。你成为赢家。 + +这就是积极意愿假想的力量。通过对愤怒和充满敌意的言辞做出回应,优雅而有尊严地回应,你就能化解一场战争,理清混乱,解决棘手的问题,而且在这个过程中很有可能会交到一个新朋友。 + +我每次应用这个原则都成功吗?见鬼,不。但我从不后悔选择了积极意愿。但是我能生动的回想起,当我采用消极意愿假想时,将问题变得更糟糕的场景。 + +现在轮到你了。我很乐意听到你提出的一些策略和原则,当你的社区里的对话变得激烈的时候,要成为一股好力量。在下面的评论中分享你的想法。 + +下次,我们将探索更多的方法,在你的社区里成为一个美好力量,我将分享一些处理“坏脾气先生”的技巧。 + +-------------------------------------------------------------------------------- + +作者简介: + +![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/headshot-square_0.jpg?itok=FS97b9YD) + +丽贝卡·费尔南德斯(Rebecca Fernandez)是红帽公司(Red Hat)的首席就业品牌 + 通讯专家,是《开源组织》书籍的贡献者,也是开源决策框架的维护者。她的兴趣是开源和业务管理模型的开源方式。Twitter:@ruhbehka + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/17/1/force-for-good-community + +作者:[Rebecca Fernandez][a] +译者:[chao-zhi](https://github.com/chao-zhi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/rebecca +[1]:https://opensource.com/business/15/5/5-ways-promote-inclusive-environment +[2]:https://twitter.com/leadership_365 From e6c7090529181b0071775907dbf79b1b3500936f Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 29 Nov 2017 05:02:44 +0800 Subject: [PATCH 005/344] PRF:20171003 Streams a new general purpose data structure in Redis.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 部分校对 --- ... a new general purpose data structure in Redis.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/translated/tech/20171003 Streams a new general purpose data structure in Redis.md b/translated/tech/20171003 Streams a new general purpose data structure in Redis.md index bb21a1bd93..39da54d0cf 100644 --- a/translated/tech/20171003 Streams a new general purpose data structure in Redis.md +++ b/translated/tech/20171003 Streams a new general purpose data structure in Redis.md @@ -1,15 +1,13 @@ -[Streams:Redis中新的一个通用数据结构][1] +streams:一个新的 Redis 通用数据结构 ================================== +直到几个月以前,对于我来说,在消息传递的环境中,streams 只是一个有趣且相对简单的概念。在 Kafka 流行这个概念之后,我主要研究它们在 Disque 实例中的用途。Disque 是一个将会转化为 Redis 4.2 的模块的消息队列。后来我发现 Disque 全都是 AP 消息,它将在不需要客户端过多参与的情况下实现容错和保证送达,因此,我认为 streams 的概念在那种情况下并不适用。 -直到几个月以前,对于我来说,在消息传递的环境中,streams 只是一个有趣且相对简单的概念。在 Kafka 概念普及之后,我主要研究他们在 Disque 实例中的效能。Disque 是一个将被转化到 Redis 4.2 模块中的消息队列。后来我明白 Disque 将是关于 AP 消息的全部,它将在不需要客户端过多参与的情况下实现容错和保证送达,因此,我认为 streams 的概念在那种情况下并不适用。 +但是,在 Redis 中有一个问题,那就是缺省情况下导出数据结构并不轻松。它在 Redis 列表、排序集和发布/订阅(Pub/Sub)能力上有某些缺陷。你可以合适地使用这些工具去模拟一个消息或事件的序列,而有所权衡。排序集是大量耗费内存的,不能自然的模拟一次又一次的相同消息的传递,客户端不能阻塞新消息。因为一个排序集并不是一个序列化的数据结构,它是一个根据它们量的变化而移动的元素集:它不是很像时间系列一样的东西。列表有另外的问题,它在某些特定的用例中产生类似的适用性问题:你无法浏览列表中部是什么,因为在那种情况下,访问时间是线性的。此外,没有任何的指定输出功能,列表上的阻塞操作仅为单个客户端提供单个元素。列表中没有固定的元素标识,也就是说,不能指定从哪个元素开始给我提供内容。对于一到多的工作负载,这里有发布/订阅,它在大多数情况下是非常好的,但是,对于某些不想“即发即弃”的东西:保留一个历史是很重要的,而不是断开之后重新获得消息,也因为某些消息列表,像时间系列,在用范围查询浏览时,是非常重要的:在这 10 秒范围内我的温度读数是多少? -但是,在 Redis 中有一个问题,那就是从缺省导出数据结构并不轻松。它在 Redis 列表、排序集和发布/订阅(Pub/Sub)能力上有某些缺陷,你可以权衡差异,友好地使用这些工具去模拟一个消息或事件的序列。排序集是大量耗费内存的,不能用相同的消息模型一次又一次的传递,客户端不能阻塞新消息。因为一个排序集并不是一个序列化的数据结构,它是一个根据他们量的变化而变化的元素集:它不是像时间系列一样很适合的东西。列表有另外的问题,它在某些用户案例中产生适用性问题:你无法浏览列表中是什么,因为在那种情况下,访问时间是线性的。此外,没有任何输出,列表上的阻塞操作仅为单个客户端提供单个元素。比如说:从那个元素开始给我提供内容,列表中也没有固定的元素标识。对于一到多的工作负载,这里有发布/订阅,它在大多数情况下是非常好的,但是,对于某些不想“即发即弃”的东西:去保留一个历史是很重要的,而不是断开之后重新获得消息,也因为某些消息列表,像时间系列,在用范围查询浏览时,是非常重要的:在这 10 秒范围内我的温度读数是多少? +这有一种方法可以尝试处理上面的问题,我计划对排序集进行通用化,并列入一个唯一的、更灵活的数据结构,然而,我的设计尝试最终以生成一个比当前的数据结构更加矫揉造作的结果而结束。一个关于 Redis 数据结构导出的更好的想法是,让它更像天然的计算机科学的数据结构,而不是,“Salvatore 发明的 API”。因此,在最后我停止了我的尝试,并且说,“ok,这是我们目前能提供的”,或许,我将为发布/订阅增加一些历史信息,或者将来对列表访问增加一些更灵活的方式。然而,每次在会议上有用户对我说“你如何在 Redis 中模拟时间系列” 或者类似的问题时,我的脸就绿了。 -这有一种方法可以尝试处理上面的问题,计划对排序集进行通用化,并列入一个唯一的更灵活的数据结构,然而,我的设计尝试最终以生成一个相对当前的人造的数据结构的结果结束,一个关于 Redis 数据结构导出的更好的想法是,让它更像天然的计算机科学的数据结构。而不是, “Salvatore 发明的 API”。因此,在最后我停止了我的尝试,并且说,“ok,这是我们目前能提供的”,或许,我将为发布/订阅增加一些历史,或者将来对列表访问增加一些更灵活的方式。然而,每次在会议上有用户对我说“你如何在 Redis 中模拟时间系列” 或者类似的问题时,我的脸变绿了。 - -起源 -======= +### 起源 在将 Redis 4.0 中的模块介绍完之后,用户开始去看他们自己怎么去修复这些问题。他们之一,Timothy Downs,通过 IRC 写信给我: From 5e88cdfea6b7ac7b67dfefd848b544f00c295aa5 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 29 Nov 2017 05:42:35 +0800 Subject: [PATCH 006/344] PRF&PUB:20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md @geekpi https://linux.cn/article-9090-1.html --- ... THE SOFTWARE CONTAINERIZATION MOVEMENT.md | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) rename {translated/tech => published}/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md (73%) diff --git a/translated/tech/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md b/published/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md similarity index 73% rename from translated/tech/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md rename to published/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md index cd2ce76527..9069b01ed9 100644 --- a/translated/tech/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md +++ b/published/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md @@ -1,27 +1,27 @@ -介绍 MOBY 项目:推进软件容器化运动的一个新的开源项目 +介绍 Moby 项目:推进软件容器化运动的一个新的开源项目 ============================================================ ![Moby Project](https://i0.wp.com/blog.docker.com/wp-content/uploads/1-2.png?resize=763%2C275&ssl=1) -自从 Docker 四年前将软件容器推向民主化以来,整个生态系统都围绕着容器化而发展,在这段压缩的时期,它经历了两个不同的增长阶段。在这每一个阶段,生产容器系统的模式已经演变成适应用户群体以及项目的规模和需求和不断增长的贡献者生态系统。 +自从 Docker 四年前将软件容器推向大众化以来,整个生态系统都围绕着容器化而发展,在这段这么短的时期内,它经历了两个不同的增长阶段。在这每一个阶段,生产容器系统的模式已经随着项目和不断增长的容器生态系统而演变适应用户群体的规模和需求。 -Moby 是一个新的开源项目,旨在推进软件容器化运动,帮助生态系统将容器作为主流。它提供了一个组件库,一个将它们组装到定制的基于容器的系统的框架,以及所有容器爱好者进行实验和交换想法的地方。 +Moby 是一个新的开源项目,旨在推进软件容器化运动,帮助生态系统将容器作为主流。它提供了一个组件库,一个将它们组装到定制的基于容器的系统的框架,也是所有容器爱好者进行实验和交换想法的地方。 让我们来回顾一下我们如何走到今天。在 2013-2014 年,开拓者开始使用容器,并在一个单一的开源代码库,Docker 和其他一些项目中进行协作,以帮助工具成熟。 ![Docker Open Source](https://i0.wp.com/blog.docker.com/wp-content/uploads/2-2.png?resize=975%2C548&ssl=1) -然后在 2015-2016 年,云原生应用中大量采用容器用于生产环境。在这个阶段,用户社区已经发展到支持成千上万个部署,由数百个生态系统项目和成千上万的贡献者支持。正是在这个阶段,Docker 将其生产模式演变为基于开放式组件的方法。这样,它使我们能够增加创新和合作的方面。 +然后在 2015-2016 年,云原生应用中大量采用容器用于生产环境。在这个阶段,用户社区已经发展到支持成千上万个部署,由数百个生态系统项目和成千上万的贡献者支持。正是在这个阶段,Docker 将其产品模式演变为基于开放式组件的方法。这样,它使我们能够增加创新和合作的方面。 -涌现出来的新独立的 Docker 组件项目帮助刺激了合作伙伴生态系统和用户社区的发展。在此期间,我们从 Docker 代码库中提取并快速创新组件,以便系统制造商可以在构建自己的容器系统时独立重用它们:[runc][7]、[HyperKit][8]、[VPNKit][9]、[SwarmKit][10]、[InfraKit][11]、[containerd][12] 等。 +涌现出来的新独立的 Docker 组件项目帮助促进了合作伙伴生态系统和用户社区的发展。在此期间,我们从 Docker 代码库中提取并快速创新组件,以便系统制造商可以在构建自己的容器系统时独立重用它们:[runc][7]、[HyperKit][8]、[VPNKit][9]、[SwarmKit][10]、[InfraKit][11]、[containerd][12] 等。 ![Docker Open Components](https://i1.wp.com/blog.docker.com/wp-content/uploads/3-2.png?resize=975%2C548&ssl=1) -站在容器浪潮的最前沿,我们看到 2017 年出现的一个趋势是容器将成为主流,传播到计算、服务器、数据中心、云、桌面、物联网和移动的各个领域。每个行业和垂直市场、金融、医疗、政府、旅游、制造。以及每一个使用案例,现代网络应用、传统服务器应用、机器学习、工业控制系统、机器人技术。容器生态系统中许多新进入者的共同点是,它们建立专门的系统,针对特定的基础设施、行业或使用案例。 +站在容器浪潮的最前沿,我们看到 2017 年出现的一个趋势是容器将成为主流,传播到计算、服务器、数据中心、云、桌面、物联网和移动的各个领域。每个行业和垂直市场,金融、医疗、政府、旅游、制造。以及每一个使用案例,现代网络应用、传统服务器应用、机器学习、工业控制系统、机器人技术。容器生态系统中许多新进入者的共同点是,它们建立专门的系统,针对特定的基础设施、行业或使用案例。 -作为一家公司,Docker 使用开源作为我们的创新实验室,而与整个生态系统合作。Docker 的成功取决于容器生态系统的成功:如果生态系统成功,我们就成功了。因此,我们一直在计划下一阶段的容器生态系统增长:什么样的生产模式将帮助我们扩大集容器生态系统,实现容器成为主流的承诺? +作为一家公司,Docker 使用开源作为我们的创新实验室,而与整个生态系统合作。Docker 的成功取决于容器生态系统的成功:如果生态系统成功,我们就成功了。因此,我们一直在计划下一阶段的容器生态系统增长:什么样的产品模式将帮助我们扩大容器生态系统,以实现容器成为主流的承诺? -去年,我们的客户开始在 Linux 以外的许多平台上要求有 Docker:Mac 和 Windows 桌面、Windows Server、云平台(如亚马逊网络服务(AWS)、Microsoft Azure 或 Google 云平台),并且我们专门为这些平台创建了[许多 Docker 版本][13]。为了在一个相对较短的时间与更小的团队,以可扩展的方式构建和发布这些专业版本,而不必重新发明轮子,很明显,我们需要一个新的方法。我们需要我们的团队不仅在组件上进行协作,而且还在组件组合上进行协作,这借用[来自汽车行业的想法][14],其中组件被重用于构建完全不同的汽车。 +去年,我们的客户开始在 Linux 以外的许多平台上要求有 Docker:Mac 和 Windows 桌面、Windows Server、云平台(如亚马逊网络服务(AWS)、Microsoft Azure 或 Google 云平台),并且我们专门为这些平台创建了[许多 Docker 版本][13]。为了在一个相对较短的时间和更小的团队中,以可扩展的方式构建和发布这些专业版本,而不必重新发明轮子,很明显,我们需要一个新的方式。我们需要我们的团队不仅在组件上进行协作,而且还在组件组合上进行协作,这借用[来自汽车行业的想法][14],其中组件被重用于构建完全不同的汽车。 ![Docker production model](https://i1.wp.com/blog.docker.com/wp-content/uploads/4-2.png?resize=975%2C548&ssl=1) @@ -29,15 +29,13 @@ Moby 是一个新的开源项目,旨在推进软件容器化运动,帮助生 ![Moby Project](https://i0.wp.com/blog.docker.com/wp-content/uploads/5-2.png?resize=975%2C548&ssl=1) -为了实现这种新的合作高度,今天我们宣布推出软件容器化运动的新开源项目 Moby。它是提供了数十个组件的“乐高集”,一个将它们组合成定制容器系统的框架,以及所有容器爱好者进行试验和交换意见的场所。可以把 Moby 认为是容器系统的“乐高俱乐部”。 +为了实现这种新的合作高度,今天(2017 年 4 月 18 日)我们宣布推出软件容器化运动的新开源项目 Moby。它是提供了数十个组件的“乐高组件”,一个将它们组合成定制容器系统的框架,以及所有容器爱好者进行试验和交换意见的场所。可以把 Moby 认为是容器系统的“乐高俱乐部”。 -Moby包括: - -1. 容器化后端组件**库**(例如,底层构建器、日志记录设备、卷管理、网络、镜像管理、containerd、SwarmKit 等) +Moby 包括: +1. 容器化后端组件**库**(例如,低层构建器、日志记录设备、卷管理、网络、镜像管理、containerd、SwarmKit 等) 2. 将组件组合到独立容器平台中的**框架**,以及为这些组件构建、测试和部署构件的工具。 - -3. 一个名为 **Moby Origin** 的引用组件,它是 Docker 容器平台的开放基础,以及使用 Moby 库或其他项目的各种组件的容器系统示例。 +3. 一个名为 “Moby Origin” 的引用组件,它是 Docker 容器平台的开放基础,以及使用 Moby 库或其他项目的各种组件的容器系统示例。 Moby 专为系统构建者而设计,他们想要构建自己的基于容器的系统,而不是可以使用 Docker 或其他容器平台的应用程序开发人员。Moby 的参与者可以从源自 Docker 的组件库中进行选择,或者可以选择将“自己的组件”(BYOC)打包为容器,以便在所有组件之间进行混合和匹配以创建定制的容器系统。 @@ -49,9 +47,9 @@ Docker 将 Moby 作为一个开放的研发实验室来试验、开发新的组 via: https://blog.docker.com/2017/04/introducing-the-moby-project/ -作者:[Solomon Hykes ][a] +作者:[Solomon Hykes][a] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 8eebb504cc4c9f1d9d34ba86c648446de948084e Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 29 Nov 2017 06:43:34 +0800 Subject: [PATCH 007/344] PRF&PUB:20171017 Image Processing on Linux.md @XYenChi https://linux.cn/article-9091-1.html --- .../20171017 Image Processing on Linux.md | 96 +++++++++++++++++++ .../20171017 Image Processing on Linux.md | 94 ------------------ 2 files changed, 96 insertions(+), 94 deletions(-) create mode 100644 published/20171017 Image Processing on Linux.md delete mode 100644 translated/tech/20171017 Image Processing on Linux.md diff --git a/published/20171017 Image Processing on Linux.md b/published/20171017 Image Processing on Linux.md new file mode 100644 index 0000000000..32ef1a2acd --- /dev/null +++ b/published/20171017 Image Processing on Linux.md @@ -0,0 +1,96 @@ +Linux 上的科学图像处理 +============================================================ + +在显示你的数据和工作方面我发现了几个科学软件,但是我不会涉及太多方面。因此在这篇文章中,我将谈到一款叫 ImageJ 的热门图像处理软件。特别的,我会介绍 [Fiji][4],这是一款绑定了一系列用于科学图像处理插件的 ImageJ 软件。 + +Fiji 这个名字是一个循环缩略词,很像 GNU 。代表着 “Fiji Is Just ImageJ”。 ImageJ 是科学研究领域进行图像分析的实用工具 —— 例如你可以用它来辨认航拍风景图中树的种类。 ImageJ 能划分物品种类。它以插件架构制成,海量插件可供选择以提升使用灵活度。 + +首先是安装 ImageJ (或 Fiji)。大多数的 ImageJ 发行版都可有该软件包。你愿意的话,可以以这种方式安装它,然后根据你的研究安装所需的独立插件。另一种选择是安装 Fiji 的同时获取最常用的插件。不幸的是,大多数 Linux 发行版的软件中心不会有可用的 Fiji 安装包。幸而,官网上的简单安装文件是可以使用的。这是一个 zip 文件,包含了运行 Fiji 需要的所有文件目录。第一次启动时,你只会看到一个列出了菜单项的工具栏。(图 1) + +![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif1.png) + +*图 1. 第一次打开 Fiji 有一个最小化的界面。* + +如果你没有备好图片来练习使用 ImageJ ,Fiji 安装包包含了一些示例图片。点击“File”->“Open Samples”的下拉菜单选项(图 2)。这些示例包含了许多你可能有兴趣做的任务。 + +![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif2.jpg) + +*图 2. 案例图片可供学习使用 ImageJ。* + +如果你安装了 Fiji,而不是单纯的 ImageJ ,那么大量插件也会被安装。首先要注意的是自动更新器插件。每次打开 ImageJ ,该插件将联网检验 ImageJ 和已安装插件的更新。 + +所有已安装的插件都在“插件”菜单项中可选。一旦你安装了很多插件,列表会变得冗杂,所以需要精简你选择的插件。你想手动更新的话,点击“Help”->“Update Fiji” 菜单项强制检测并获取可用更新的列表(图 3)。 + +![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif3.png) + +*图 3. 强制手动检测可用更新。* + +那么,现在,用 Fiji/ImageJ 可以做什么呢?举一例,统计图片中的物品数。你可以通过点击“File”->“Open Samples”->“Embryos”来载入示例。 + +![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif4.jpg) + +*图 4. 用 ImageJ 算出图中的物品数。* + +第一步给图片设定比例,这样你可以告诉 ImageJ 如何判别物品。首先,选择在工具栏选择线条按钮。然后选择“Analyze”->“Set Scale”,然后就会设置比例尺包含的像素点个数(图 5)。你可以设置“known distance ”为 100,单元为“um”。 + +![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif5.png) + +*图 5. 很多图片分析任务需要对图片设定一个范围。* + +接下来的步骤是简化图片内的信息。点击“Image”->“Type”->“8-bit”来减少信息量到 8 比特灰度图片。要分隔独立物体点击“Process”->“Binary”->“Make Binary”以自动设置图片门限。(图 6)。 + +![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif6.png) + +*图 6. 有些工具可以自动完成像门限一样的任务。* + +图片内的物品计数前,你需要移除像比例尺之类的人工操作。可以用矩形选择工具来选中它并点击“Edit”->“Clear”来完成这项操作。现在你可以分析图片看看这里是啥物体。 + +确保图中没有区域被选中,点击“Analyze”->“Analyze Particles”来弹出窗口来选择最小尺寸,这决定了最后的图片会展示什么(图 7)。 + +![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif7.png) + +*图 7. 你可以通过确定最小尺寸生成一个缩减过的图片。 * + +图 8 在总结窗口展示了一个概览。每个最小点也有独立的细节窗口。 + +![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif8.png) + +*图 8. 包含了已知最小点总览清单的输出结果。* + +当你有一个分析程序可以工作于给定图片类型,你通常需要将相同的步骤应用到一系列图片当中。这可能数以千计,你当然不会想对每张图片手动重复操作。这时候,你可以集中必要步骤到宏,这样它们可以被应用多次。点击插件->“Macros”->“Record”,弹出一个新的窗口记录你随后的所有命令。所有步骤完成,你可以将之保存为一个宏文件,并且通过点击“Plugins”->“Macros”->“Run”来在其它图片上重复运行。 + +如果你有非常特定的工作步骤,你可以简单地打开宏文件并手动编辑它,因为它是一个简单的文本文件。事实上有一套完整的宏语言可供你更加充分地控制图片处理过程。 + +然而,如果你有真的有非常多的系列图片需要处理,这也将是冗长乏味的工作。这种情况下,前往“Process”->“Batch”->“Macro”,会弹出一个你可以设置批量处理工作的新窗口(图 9)。 + +![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif9.png) + +*图 9. 对批量输入的图片用单一命令运行宏。* + +这个窗口中,你能选择应用哪个宏文件、输入图片所在的源目录和你想写入输出图片的输出目录。也可以设置输出文件格式,及通过文件名筛选输入图片中需要使用的。万事具备之后,点击窗口下方的的“Process”按钮开始批量操作。 + +若这是会重复多次的工作,你可以点击窗口底部的“Save”按钮保存批量处理到一个文本文件。点击也在窗口底部的“Open”按钮重新加载相同的工作。这个功能可以使得研究中最冗余部分自动化,这样你就可以在重点放在实际的科学研究中。 + +考虑到单单是 ImageJ 主页就有超过 500 个插件和超过 300 种宏可供使用,简短起见,我只能在这篇短文中提出最基本的话题。幸运的是,还有很多专业领域的教程可供使用,项目主页上还有关于 ImageJ 核心的非常棒的文档。如果你觉得这个工具对研究有用,你研究的专业领域也会有很多信息指引你。 + +-------------------------------------------------------------------------------- + +作者简介: + +Joey Bernard 有物理学和计算机科学的相关背景。这对他在新不伦瑞克大学当计算研究顾问的日常工作大有裨益。他也教计算物理和并行程序规划。 + +-------------------------------- + +via: https://www.linuxjournal.com/content/image-processing-linux + +作者:[Joey Bernard][a] +译者:[XYenChi](https://github.com/XYenChi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linuxjournal.com/users/joey-bernard +[1]:https://www.linuxjournal.com/tag/science +[2]:https://www.linuxjournal.com/tag/statistics +[3]:https://www.linuxjournal.com/users/joey-bernard +[4]:https://imagej.net/Fiji diff --git a/translated/tech/20171017 Image Processing on Linux.md b/translated/tech/20171017 Image Processing on Linux.md deleted file mode 100644 index d02c2f3bd4..0000000000 --- a/translated/tech/20171017 Image Processing on Linux.md +++ /dev/null @@ -1,94 +0,0 @@ -Linux上的图像处理 -============================================================ - - -我发现了很多生成图像表示你的数据和工作的系统软件,但是我不能写太多其他东西。因此在这篇文章中,包含了一款叫 ImageJ 的热门图像处理软件。特别的,我注意到了 [Fiji][4], 一例绑定了科学性图像处理的系列插件的 ImageJ 版本。 - -Fiji这个名字是一个循环缩略词,很像 GNU 。代表着 "Fiji Is Just ImageJ"。 ImageJ 是科学研究领域进行图像分析的实用工具——例如你可以用它来辨认航拍风景图中树的种类。 ImageJ 能划分物品种类。它以插件架构制成,海量插件供选择以提升使用灵活度。 - -首先是安装 ImageJ (或 Fiji). 大多数的 ImageJ 发行版都可使用软件包。你愿意的话,可以以这种方式安装它然后为你的研究安装所需的独立插件。另一种选择是安装 Fiji 的同时获取最常用的插件。不幸的是,大多数 Linux 发行版的软件中心不会有可用的 Fiji 安装包。幸而,官网上的简单安装文件是可以使用的。包含了运行 Fiji 需要的所有文件目录。第一次启动时,会给一个有菜单项列表的工具栏。(图1) - -![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif1.png) - -图 1\.第一次打开 Fiji 有一个最小化的界面。 - -如果你没有备好图片来练习使用 ImageJ ,Fiji 安装包包含了一些示例图片。点击文件->打开示例图片的下拉菜单选项(图2)。这些案例包含了许多你可能有兴趣做的任务。 - -![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif2.jpg) - -图 2\. 案例图片可供学习使用 ImageJ。 - -安装了 Fiji,而不是单纯的 ImageJ ,大量插件也会被安装。首先要注意的是自动更新插件。每次打开 ImageJ ,该插件联网检验 ImageJ 和已安装插件的更新。所有已安装的插件都在插件菜单项中可选。一旦你安装了很多插件,列表会变得冗杂,所以需要精简你的插件选项。你想手动更新的话,点击帮助->更新 Fiji 菜单项强制检测获取可用更新列表(图3)。 - -![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif3.png) - -图 3\. 强制手动检测可用更新。 - -那么,Now,用 Fiji/ImageJ 可以做什么呢?举一例,图片中的物品数。你可以通过点击文件->打开示例->胚芽来载入一例。 - -![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif4.jpg) - -图 4\. 用 ImageJ算出图中的物品数。 - -第一步设定图片的范围这样你可以告诉 ImageJ 如何判别物品。首先,选择在工具栏选择线条按钮。然后选择分析->设定范围,然后就会设置范围内包含的像素点个数(图 5)。你可以设置已知距离为100,单元为“um”。 - -![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif5.png) - -图 5\. 很多图片分析任务需要对图片设定一个范围。 - -接下来的步骤是简化图片内的信息。点击图片->类型->8比特来减少信息量到8比特灰度图片。点击处理->二进制->图片定界, 以分隔独立物体。点击处理->二进制->设置二进制来自动给图片定界(图 6)。 - -![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif6.png) - -图 6\. 有些像开关一样完成自动任务的工具。 - -图片内的物品计数前,你需要移除像范围轮廓之类的人工操作。可以用三角选择工具来选中它并点击编辑->清空来完成这项操作。现在你可以分析图片看看这里是啥物体。 - -确保图中没有区域被选中,点击分析->分析最小粒子弹出窗口来选择最小尺寸,这决定了最后的图片会展示什么(图7)。 - -![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif7.png) - -图 7\.你可以通过确定最小尺寸生成一个缩减过的图片。 - -图 8 在总结窗口展示了一个概览。每个最小点也有独立的细节窗口。 - -![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif8.png) - -图 8\. 包含了已知最小点总览清单的输出结果。 - -只要你有一个分析程序来给定图片类型,相同的程序往往需要被应用到一系列图片当中。可能数以千计,你当然不会想对每张图片手动重复操作。这时候,你可以集中必要步骤到宏这样它们可以被应用多次。点击插件->宏- >记录弹出一个新的窗口记录你随后的所有命令。所有步骤一完成,你可以将之保存为一个宏文件并且通过点击插件->宏->运行来在其他图片上重复运行。 - -如果你有特定的工作步骤,你可以轻易打开宏文件并手动编辑它,因为它是一个简单的文本文件。事实上有一套完整的宏语言可供你更加充分地控制图片处理过程。 - -然而,如果你有真的非常多的系列图片需要处理,这也将是冗长乏味的工作。这种情况下,前往过程->批量->宏弹出一个新窗口你可以批量处理工作(图9)。 - -![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12172fijif9.png) - -图 9\. 在批量输出图片时用简单命令运行宏。 - -这个窗口中,你能选择应用哪个宏文件,输入图片所在的源目录和你想写入输出图片的输出目录。也可以设置输出文件格式及通过文件名筛选输入图片中需要使用的。万事具备,点击窗口下方的的处理按钮开始批量操作。 - -若这是会重复多次的工作,你可以点击窗口底部的保存按钮保存批量处理到一个文本文件。点击也在窗口底部的开始按钮重载相同的工作。所有的应用都使得研究中最冗余部分自动化,这样你就可以在重点放在实际的科学研究中。 -考虑到单单是 ImageJ 主页就有超过500个插件和超过300种宏可供使用,简短起见,我只能在这篇短文中提出最基本的话题。幸运的是,有很多专业领域的教程可供使用,项目主页上还有关于 ImageJ 核心的非常棒的文档。如果觉得这个工具对研究有用,你研究的专业领域也会有很多信息指引你。 - --------------------------------------------------------------------------------- - -作者简介: - -Joey Bernard 有物理学和计算机科学的相关背景。这对他在新不伦瑞克大学当计算研究顾问的日常工作大有裨益。他也教计算物理和并行程序规划。 - --------------------------------- - -via: https://www.linuxjournal.com/content/image-processing-linux - -作者:[Joey Bernard][a] -译者:[XYenChi](https://github.com/XYenChi) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linuxjournal.com/users/joey-bernard -[1]:https://www.linuxjournal.com/tag/science -[2]:https://www.linuxjournal.com/tag/statistics -[3]:https://www.linuxjournal.com/users/joey-bernard -[4]:https://imagej.net/Fiji From 55c5d78f9675ac9884d4412b48a047d115caab5d Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 29 Nov 2017 08:44:55 +0800 Subject: [PATCH 008/344] translated --- ... Proxy Models in Container Environments.md | 90 ------------------- ... Proxy Models in Container Environments.md | 86 ++++++++++++++++++ 2 files changed, 86 insertions(+), 90 deletions(-) delete mode 100644 sources/tech/20171014 Proxy Models in Container Environments.md create mode 100644 translated/tech/20171014 Proxy Models in Container Environments.md diff --git a/sources/tech/20171014 Proxy Models in Container Environments.md b/sources/tech/20171014 Proxy Models in Container Environments.md deleted file mode 100644 index fa57b306a8..0000000000 --- a/sources/tech/20171014 Proxy Models in Container Environments.md +++ /dev/null @@ -1,90 +0,0 @@ -translating---geekpi - - -Proxy Models in Container Environments -============================================================ - -### Most of us are familiar with how proxies work, but is it any different in a container-based environment? See what's changed. - -Inline, side-arm, reverse, and forward. These used to be the terms we used to describe the architectural placement of proxies in the network. - -Today, containers use some of the same terminology, but they are introducing new ones. That’s an opportunity for me to extemporaneously expound* on my favorite of all topics: the proxy. - -One of the primary drivers of cloud (once we all got past the pipedream of cost containment) has been scalability. Scale has challenged agility (and sometimes won) in various surveys over the past five years as the number one benefit organizations seek by deploying apps in cloud computing environments. - -That’s in part because in a digital economy (in which we now operate), apps have become the digital equivalent of brick-and-mortar “open/closed” signs and the manifestation of digital customer assistance. Slow, unresponsive apps have the same effect as turning out the lights or understaffing the store. - -Apps need to be available and responsive to meet demand. Scale is the technical response to achieving that business goal. Cloud not only provides the ability to scale, but offers the ability to scale  _automatically_ . To do that requires a load balancer. Because that’s how we scale apps – with proxies that load balance traffic/requests. - -Containers are no different with respect to expectations around scale. Containers must scale – and scale automatically – and that means the use of load balancers (proxies). - -If you’re using native capabilities, you’re doing primitive load balancing based on TCP/UDP. Generally speaking, container-based proxy implementations aren’t fluent in HTTP or other application layer protocols and don’t offer capabilities beyond plain old load balancing ([POLB][1]). That’s often good enough, as container scale operates on a cloned, horizontal premise – to scale an app, add another copy and distribute requests across it. Layer 7 (HTTP) routing capabilities are found at the ingress (in [ingress controllers][2] and API gateways) and are used as much (or more) for app routing as they are to scale applications. - -In some cases, however, this is not enough. If you want (or need) more application-centric scale or the ability to insert additional services, you’ll graduate to more robust offerings that can provide programmability or application-centric scalability or both. - -To do that means [plugging-in proxies][3]. The container orchestration environment you’re working in largely determines the deployment model of the proxy in terms of whether it’s a reverse proxy or a forward proxy. Just to keep things interesting, there’s also a third model – sidecar – that is the foundation of scalability supported by emerging service mesh implementations. - -### Reverse Proxy - - [![Image title](https://devcentral.f5.com/Portals/0/Users/038/38/38/unavailable_is_closed_thumb.png?ver=2017-09-12-082119-957 "Image title")][4] - -A reverse proxy is closest to a traditional model in which a virtual server accepts all incoming requests and distributes them across a pool (farm, cluster) of resources. - -There is one proxy per ‘application’. Any client that wants to connect to the application is instead connected to the proxy, which then chooses and forwards the request to an appropriate instance. If the green app wants to communicate with the blue app, it sends a request to the blue proxy, which determines which of the two instances of the blue app should respond to the request. - -In this model, the proxy is only concerned with the app it is managing. The blue proxy doesn’t care about the instances associated with the orange proxy, and vice-versa. - -### Forward Proxy - - [![Image title](https://devcentral.f5.com/Portals/0/Users/038/38/38/per-node_forward_proxy_thumb.jpg?ver=2017-09-14-072422-213)][5] - -This mode more closely models that of a traditional outbound firewall. - -In this model, each container **node** has an associated proxy. If a client wants to connect to a particular application or service, it is instead connected to the proxy local to the container node where the client is running. The proxy then chooses an appropriate instance of that application and forwards the client's request. - -Both the orange and the blue app connect to the same proxy associated with its node. The proxy then determines which instance of the requested app instance should respond. - -In this model, every proxy must know about every application to ensure it can forward requests to the appropriate instance. - -### Sidecar Proxy - - [![Image title](https://devcentral.f5.com/Portals/0/Users/038/38/38/per-pod_sidecar_proxy_thumb.jpg?ver=2017-09-14-072425-620)][6] - -This mode is also referred to as a service mesh router. In this model, each **container **has its own proxy. - -If a client wants to connect to an application, it instead connects to the sidecar proxy, which chooses an appropriate instance of that application and forwards the client's request. This behavior is the same as a  _forward proxy _ model. - -The difference between a sidecar and forward proxy is that sidecar proxies do not need to modify the container orchestration environment. For example, in order to plug-in a forward proxy to k8s, you need both the proxy  _and _ a replacement for kube-proxy. Sidecar proxies do not require this modification because it is the app that automatically connects to its “sidecar” proxy instead of being routed through the proxy. - -### Summary - -Each model has its advantages and disadvantages. All three share a reliance on environmental data (telemetry and changes in configuration) as well as the need to integrate into the ecosystem. Some models are pre-determined by the environment you choose, so careful consideration as to future needs – service insertion, security, networking complexity – need to be evaluated before settling on a model. - -We’re still in early days with respect to containers and their growth in the enterprise. As they continue to stretch into production environments it’s important to understand the needs of the applications delivered by containerized environments and how their proxy models differ in implementation. - -*It was extemporaneous when I wrote it down. Now, not so much. - - --------------------------------------------------------------------------------- - -via: https://dzone.com/articles/proxy-models-in-container-environments - -作者:[Lori MacVittie ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://dzone.com/users/307701/lmacvittie.html -[1]:https://f5.com/about-us/blog/articles/go-beyond-polb-plain-old-load-balancing -[2]:https://f5.com/about-us/blog/articles/ingress-controllers-new-name-familiar-function-27388 -[3]:http://clouddocs.f5.com/products/asp/v1.0/ -[4]:https://devcentral.f5.com/Portals/0/Users/038/38/38/unavailable_is_closed.png?ver=2017-09-12-082118-160 -[5]:https://devcentral.f5.com/Portals/0/Users/038/38/38/per-node_forward_proxy.jpg?ver=2017-09-14-072419-667 -[6]:https://devcentral.f5.com/Portals/0/Users/038/38/38/per-pod_sidecar_proxy.jpg?ver=2017-09-14-072424-073 -[7]:https://dzone.com/users/307701/lmacvittie.html -[8]:https://dzone.com/users/307701/lmacvittie.html -[9]:https://dzone.com/articles/proxy-models-in-container-environments# -[10]:https://dzone.com/cloud-computing-tutorials-tools-news -[11]:https://dzone.com/articles/proxy-models-in-container-environments# -[12]:https://dzone.com/go?i=243221&u=https%3A%2F%2Fget.platform9.com%2Fjzlp-kubernetes-deployment-models-the-ultimate-guide%2F diff --git a/translated/tech/20171014 Proxy Models in Container Environments.md b/translated/tech/20171014 Proxy Models in Container Environments.md new file mode 100644 index 0000000000..4e5b329d68 --- /dev/null +++ b/translated/tech/20171014 Proxy Models in Container Environments.md @@ -0,0 +1,86 @@ +容器环境中的代理模型 +============================================================ + +### 我们大多数人都熟悉代理如何工作,但在基于容器的环境中有什么不同?看看有什么改变。 + +内联,side-arm,反向和前向。这些曾经是我们用来描述网络代理架构布局的术语。 + +如今,容器使用一些相同的术语,但它们正在引入新的东西。这对我是个机会来阐述我最爱的所有主题:代理。 + +云的主要驱动之一(我们曾经有过成果控制的白日梦)就是可扩展性。在过去五年中,扩展在各种调查中面临着敏捷性的挑战(有时甚至获胜),因为这是机构在云计算环境中部署应用的最大追求。 + +这在一定程度上是因为在数字经济 (我们现在运营的) 中,应用已经成为数字等同于实体店的“开放/关闭”的标志和数字客户援助的体现。缓慢、无响应的应用程序等同于把灯关闭或者商店人员不足。 + +应用程序需要可用且响应满足需求。扩展是实现这一业务目标的技术响应。云不仅提供了扩展的能力,而且还提供了_自动_扩展的能力。要做到这一点,需要一个负载均衡器。因为这就是我们扩展应用程序的方式 - 使用代理负载均衡流量/请求。 + +容器在扩展上与预期没有什么不同。容器必须进行扩展 - 并自动扩展 - 这意味着使用负载均衡器(代理)。 + +如果你使用的是本机,则你正在基于 TCP/UDP 进行基本的负载平衡。一般来说,基于容器的代理实现在 HTTP 或其他应用层协议中不流畅,除了一般的旧的负载均衡([POLB][1])之外,不提供其他功能。这通常足够好,因为容器扩展是在一个克隆的水平预置环境中进行的 - 要扩展一个应用程序,添加另一个副本并在其上分发请求。在入口处(在[入口控制器][2]和 API 网关中)可以找到第 7 层(HTTP)路由功能,并且可以使用尽可能多(或更多)的应用程序路由来扩展应用程序。 + +然而,在某些情况下,这还不够。如果你希望(或需要)更多以应用程序为中心的扩展或插入其他服务的能力,那么你将获得更健壮的产品,可提供可编程性或以应用程序为中心的可伸缩性,或者两者兼而有之。 + +这意味着[插入代理][3]。你正在使用的容器编排环境在很大程度上决定了代理的部署模型,无论它是反向代理还是前向代理。为了让事情有趣,还有第三个模型 - sidecar - 这是由新兴的服务网格实现支持的可扩展性的基础。 + +### 反向代理 + + [![Image title](https://devcentral.f5.com/Portals/0/Users/038/38/38/unavailable_is_closed_thumb.png?ver=2017-09-12-082119-957 "Image title")][4] + +反向代理最接近于传统模型,在这种模型中,虚拟服务器接受所有传入请求,并将其分发到资源池(服务器中心,集群)中。 + +每个“应用程序”有一个代理。任何想要连接到应用程序的客户端连接到代理,代理然后选择并转发请求到适当的实例。如果绿色应用想要与蓝色应用通信,它会向蓝色代理发送请求,蓝色代理会确定蓝色应用的两个实例中的哪一个应该响应该请求。 + +在这个模型中,代理只关心它正在管理的应用程序。蓝色代理不关心与橙色代理关联的实例,反之亦然。 + +### 前向代理 + + [![Image title](https://devcentral.f5.com/Portals/0/Users/038/38/38/per-node_forward_proxy_thumb.jpg?ver=2017-09-14-072422-213)][5] + +这种模式更接近传统出站防火墙的模式。 + +在这个模型中,每个容器 **节点** 都有一个关联的代理。如果客户端想要连接到特定的应用程序或服务,它将连接到正在运行的客户端所在的容器节点的本地代理。代理然后选择一个适当的应用实例,并转发客户端的请求。 + +橙色和蓝色的应用连接到与其节点相关的同一个代理。代理然后确定所请求的应用实例的哪个实例应该响应。 + +在这个模型中,每个代理必须知道每个应用,以确保它可以将请求转发给适当的实例。 + +### sidecar 代理 + + [![Image title](https://devcentral.f5.com/Portals/0/Users/038/38/38/per-pod_sidecar_proxy_thumb.jpg?ver=2017-09-14-072425-620)][6] + +这种模型也被称为服务网格路由。在这个模型中,每个**容器**都有自己的代理。 + +如果客户想要连接到一个应用,它将连接到 sidecar 代理,它会选择一个合适的应用程序实例并转发客户端的请求。此行为与_前向代理_模型相同。 + +sidecar 和前向代理之间的区别在于,sidecar 代理不需要修改容器编排环境。例如,为了插入一个前向代理到 k8s,你需要代理_和_一个 kube-proxy 的替代。sidecar 代理不需要此修改,因为应用会自动连接到 “sidecar” 代理而不是通过代理路由。 + +### 总结 + +每种模式都有其优点和缺点。三者共同依赖环境数据(远程监控和配置变化),以及融入生态系统的需求。有些模型是根据你选择的环境预先确定的,因此需要仔细考虑将来的需求 - 服务插入、安全性、网络复杂性 - 在建立模型之前需要进行评估。 + +在容器及其在企业中的发展方面,我们还处于早期阶段。随着它们继续延伸到生产环境中,了解容器化环境发布的应用程序的需求以及它们在代理模型实现上的差异是非常重要的。 + +我是急性写下这篇文章的。现在就这么多。 + +-------------------------------------------------------------------------------- + +via: https://dzone.com/articles/proxy-models-in-container-environments + +作者:[Lori MacVittie ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://dzone.com/users/307701/lmacvittie.html +[1]:https://f5.com/about-us/blog/articles/go-beyond-polb-plain-old-load-balancing +[2]:https://f5.com/about-us/blog/articles/ingress-controllers-new-name-familiar-function-27388 +[3]:http://clouddocs.f5.com/products/asp/v1.0/ +[4]:https://devcentral.f5.com/Portals/0/Users/038/38/38/unavailable_is_closed.png?ver=2017-09-12-082118-160 +[5]:https://devcentral.f5.com/Portals/0/Users/038/38/38/per-node_forward_proxy.jpg?ver=2017-09-14-072419-667 +[6]:https://devcentral.f5.com/Portals/0/Users/038/38/38/per-pod_sidecar_proxy.jpg?ver=2017-09-14-072424-073 +[7]:https://dzone.com/users/307701/lmacvittie.html +[8]:https://dzone.com/users/307701/lmacvittie.html +[9]:https://dzone.com/articles/proxy-models-in-container-environments# +[10]:https://dzone.com/cloud-computing-tutorials-tools-news +[11]:https://dzone.com/articles/proxy-models-in-container-environments# +[12]:https://dzone.com/go?i=243221&u=https%3A%2F%2Fget.platform9.com%2Fjzlp-kubernetes-deployment-models-the-ultimate-guide%2F From 738adc3cc828827e3af8a728cd9744cafab149fd Mon Sep 17 00:00:00 2001 From: DarkSun Date: Wed, 29 Nov 2017 11:15:42 +0800 Subject: [PATCH 009/344] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=AF=95=20?= =?UTF-8?q?20171117=20how=20to=20easily=20remember=20linux=20commands.md?= =?UTF-8?q?=20(#6366)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * translated * 翻译完毕 --- ...7 How to Easily Remember Linux Commands.md | 126 ------------------ ...7 How to Easily Remember Linux Commands.md | 74 ++++++++++ 2 files changed, 74 insertions(+), 126 deletions(-) delete mode 100644 sources/tech/20171117 How to Easily Remember Linux Commands.md create mode 100644 translated/tech/20171117 How to Easily Remember Linux Commands.md diff --git a/sources/tech/20171117 How to Easily Remember Linux Commands.md b/sources/tech/20171117 How to Easily Remember Linux Commands.md deleted file mode 100644 index fe69efb128..0000000000 --- a/sources/tech/20171117 How to Easily Remember Linux Commands.md +++ /dev/null @@ -1,126 +0,0 @@ -translating by darksun -# How to Easily Remember Linux Commands - -![](https://www.maketecheasier.com/assets/uploads/2017/10/rc-feat.jpg) - - -The command line can be daunting for new Linux users. Part of that is -remembering the multitude of commands available. After all, in order to use -the command line effectively, you need to know the commands. - -Unfortunately, there's no getting around the fact that you need to learn the -commands, but there are some tools that can help you out when you're getting -started. - -## History - -![Linux Bash History Commands](https://www.maketecheasier.com/assets/uploads/2017/10/rc-bash-history.jpg) - -The first thing you can use to remember commands that you've already used is -your own command line history. Most [Linux shells](https://www.maketecheasier.com/remember-linux-commands/), including -the most common default, Bash, create a history file that lists your past -commands. For Bash, you can find it at "/home//.bash_history." - -It's a plain text file, so you can open it in any text editor and loop back -through or even search. - -## Apropos - -There's actually a command that helps you find _other_ commands. It 's called -"apropos," and it helps you find the appropriate command to complete the -action you search or. For example, if you need to know the command to list the -contents of a directory, you can run the following command: - -[code] - - apropos "list directory" -[/code] - -![Linux Apropos](https://www.maketecheasier.com/assets/uploads/2017/10/rc-apropos.jpg) - -There's a catch, though. It's very literal. Add an "s" to "directory," and try -again. - -[code] - - apropos "list directories" -[/code] - -It doesn't work. What `apropos` does is search through a list of commands and -the accompanying descriptions. If your search doesn't match the description, -it won't pick up the command as a result. - -There is something else you can do. By using the `-a` flag, you can add -together search terms in a more flexible way. Try this command: - -[code] - - apropos "match pattern" -[/code] - -![Linux Apropos -a Flag](https://www.maketecheasier.com/assets/uploads/2017/10/rc-apropos-a.jpg) - -You'd think it'd turn up something, like -[grep](https://www.maketecheasier.com/remember-linux-commands/)? Instead, you -get nothing. Again, apropos is being too literal. Now, try separating the -words and using the `-a` flag. - -[code] - - apropos "match" -a "pattern" -[/code] - -Suddenly, you have many of the results that you'd expect. - -apropos is a great tool, but you always need to be aware of its quirks. - -## ZSH - -![Linux ZSH -Autocomplete](https://www.maketecheasier.com/assets/uploads/2017/10/rc- -zsh.jpg)![Linux ZSH -Autocomplete](https://www.maketecheasier.com/assets/uploads/2017/10/rc- -zsh.jpg) - -ZSH isn't really a tool for remembering commands. It's actually an alternative -shell. You can substitute [ZSH](https://www.maketecheasier.com/remember-linux- -commands/) for Bash and use it as your command line shell. ZSH -includes an autocorrect feature that catches you if you enter in a command -wrong or misspell something. If you enable it, it'll ask you if you meant -something close. You can continue to use the command line as you normally -would with ZSH, but you get an extra safety net and some other really nice -features, too. The easiest way to get the most of ZSH is with [Oh-My- -ZSH](https://www.maketecheasier.com/remember-linux-commands/). - -## Cheat Sheet - -The last, and probably simplest, option is to use a [cheat sheet](https://www.maketecheasier.com/remember-linux-commands/). There are plenty available online like [this -one](https://www.maketecheasier.com/remember-linux-commands/) that you can use to look up commands quickly. - -![linux-commandline-cheatsheet](https://www.maketecheasier.com/assets/uploads/2013/10/linux-commandline-cheatsheet.gif) - -You can actually even find them in image form and set one as your desktop -wallpaper for quick reference. - -This isn't the best solution for actually remembering the commands, but when -you're starting out, it can save you from doing a search online every time you -don't remember a command. - -Rely on these methods when you're learning, and eventually you'll find -yourself referring to them less and less. No one remembers everything, so -don't feel bad if you occasionally forget or run into something you haven't -seen before. That's what these resources and, of course, the Internet are -there for. - - --------------------------------------------------------------------------------- - -via: https://www.maketecheasier.com/remember-linux-commands/ - -作者:[Nick Congleton][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - diff --git a/translated/tech/20171117 How to Easily Remember Linux Commands.md b/translated/tech/20171117 How to Easily Remember Linux Commands.md new file mode 100644 index 0000000000..8e4483cd20 --- /dev/null +++ b/translated/tech/20171117 How to Easily Remember Linux Commands.md @@ -0,0 +1,74 @@ +# How to Easily Remember Linux Commands + +![](https://www.maketecheasier.com/assets/uploads/2017/10/rc-feat.jpg) + + +Linux 新手往往对命令行心存畏惧。部分原因是因为需要记忆大量的命令。毕竟掌握命令是高效使用命令行的前提。 +不幸的是,学习这些命令并无捷径,然而在你开始学习命令之初,有些工具还是可以帮到你的。 +## History + +![Linux Bash History 命令](https://www.maketecheasier.com/assets/uploads/2017/10/rc-bash-history.jpg) + +首先要介绍的是命令行工具 history。它能帮你记住那些你曾经用过的命令。大多数 [Linux shells](https://www.maketecheasier.com/remember-linux-commands/),包括应用最广泛的 Bash,都会创建一个历史文件来包含那些你输入过的命令。如果你用的是 Bash,这个历史文件就是 "/home//.bash_history"。 +这个历史文件是纯文本格式的,你可以用任意的文本编辑器打开来浏览和搜索。 +## Apropos + +确实存在有一个命令可以帮你找到其他命令。这个命令就是 "apropos",它能帮你找出合适的命令来完成你搜索的操作。比如,假设你需要知道哪个命令可以列出目录的内容,你可以运行下面命令: + +```shell + apropos "list directory" +``` + +![Linux Apropos](https://www.maketecheasier.com/assets/uploads/2017/10/rc-apropos.jpg) + +这就搜索出结果了。非常直接。给 "directory" 加上 "s" 后再试一下。 + +```shell + apropos "list directories" +``` + +这次没用了。`apropos` 所作的其实就是搜索一系列命令的描述。描述不匹配的命令不会纳入结果中。 +还有其他的用法。通过 `-a` 标志,你可以以更灵活的方式来增加搜索关键字。试试这条命令: + +```shell + apropos "match pattern" +``` + +![Linux Apropos -a Flag](https://www.maketecheasier.com/assets/uploads/2017/10/rc-apropos-a.jpg) + +你会觉得应该会有一些匹配的内容出现,比如 [grep](https://www.maketecheasier.com/remember-linux-commands/) 对吗? +然而,实际上并没有匹配出任何结果。再说一次,apropos 只会根据字面内容进行搜索。 +现在让我们试着用 `-a` 标志来把单词分割开来。 + +```shell + apropos "match" -a "pattern" +``` + +这一下,你可以看到很多期望的结果了。 +apropos 是一个很棒的工具,不过你需要留意它的缺陷。 +## ZSH + +![Linux ZSH Autocomplete](https://www.maketecheasier.com/assets/uploads/2017/10/rc-zsh.jpg) + +ZSH 其实并不是用于记忆命令的工具。它其实是一种 shell。你可以用 [ZSH](https://www.maketecheasier.com/remember-linux-commands/) 来替代 Bash 作为你的命令行 shell。ZSH 包含了自动纠错机制,能在你输入命令的时候给你予提示。 +开启该功能后,它会提示你相近的选择想面。在 ZSH 中你可以像往常一样使用命令行,同时你还能享受到极度安全的网络以及其他一些非常好用的特性。充分利用 ZSH 的最简单方法就是使用 [Oh-My-ZSH](https://www.maketecheasier.com/remember-linux-commands/)。 +## Cheat Sheet + +最后,也可能是最间的方法就是使用 [cheat sheet](https://www.maketecheasier.com/remember-linux-commands/)。 +有很多在线的 cheat sheet,比如[这个](https://www.maketecheasier.com/remember-linux-commands/) 可以帮助你快速查询命令。 +![linux-commandline-cheatsheet](https://www.maketecheasier.com/assets/uploads/2013/10/linux-commandline-cheatsheet.gif) + +为了快速查询,你可以寻找图片格式的 cheat sheet 然后将它设置为你的桌面墙纸。 +这并不是记忆命令的最好方法,但是这么做可以帮你节省在线搜索遗忘命令的时间。 +在学习时依赖这些方法,最终你会发现你会越来越少地使用这些工具。 +没有人能够记住所有的事情,因此偶尔遗忘掉某些东西或者遇到某些没有见过的东西也很正常。这也是这些工具以及因特网存在的意义。 + +-------------------------------------------------------------------------------- + +via: https://www.maketecheasier.com/remember-linux-commands/ + +作者:[Nick Congleton][a] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From cca9f7ac67127bac0d32f31df2ab8ad0ba4b53ca Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 29 Nov 2017 11:18:33 +0800 Subject: [PATCH 010/344] =?UTF-8?q?=E9=80=89=E9=A2=98:=20tmate=20=E2=80=93?= =?UTF-8?q?=20Instantly=20Share=20Your=20Terminal=20Session=20To=20Anyone?= =?UTF-8?q?=20In=20Seconds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...our Terminal Session To Anyone In Seconds.md | 612 ++++++++++++++++++ 1 file changed, 612 insertions(+) create mode 100644 sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md diff --git a/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md b/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md new file mode 100644 index 0000000000..efa99115b8 --- /dev/null +++ b/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md @@ -0,0 +1,612 @@ +::: {#wrapper} +::: {.mobile-title-logo-in-header} +[![2daygeek.com](https://www.2daygeek.com/wp-content/uploads/2015/12/2day-geek-new-logo-final.png)](https://www.2daygeek.com/ "2daygeek.com | Home page"){.custom-logo-link} +::: + +::: {.ham__navbar-toggler-two .collapsed title="Menu" aria-expanded="false"} +::: {.ham__navbar-span-wrapper} +[]{.line .line-1} []{.line .line-2} []{.line .line-3} +::: +::: + +::: {.nav-text} +::: + +::: {.nav-wrap .container} +-
+ +
+ + + +- [[LINUX + DISTRO'S](https://www.2daygeek.com/category/linux-distributions/)]{#menu-item-6808} +- [[LINUX + COMMAND'S](https://www.2daygeek.com/category/linux-commands/)]{#menu-item-6806} +- [[WEBSERVER](https://www.2daygeek.com/category/webserver/)]{#menu-item-9582} +- [[MONITORING + TOOLS](https://www.2daygeek.com/category/monitoring-tools/)]{#menu-item-6809} +- [[PACKAGE + MANAGEMENT](https://www.2daygeek.com/category/package-management/)]{#menu-item-6883} +- [[REPOSITORY](https://www.2daygeek.com/category/repository/)]{#menu-item-6811} +- [[CLOUD + STORAGE](https://www.2daygeek.com/category/free-cloud-storage/)]{#menu-item-6986} +- [[HACKING](https://gbhackers.com/)]{#menu-item-14871} + - [[Tutorials](https://gbhackers.com/)]{#menu-item-14872} +::: + +::: {.nav-text} +::: + +::: {.topbar-toggle-down} +::: + +::: {.nav-wrap .container} +- [[HOME](https://www.2daygeek.com/)]{#menu-item-293} +- [[LINUX NEWS](http://linuxnews.2daygeek.com/)]{#menu-item-10920} +- [[ABOUT US](https://www.2daygeek.com/about-us/)]{#menu-item-294} +- [[CONTACT US](https://www.2daygeek.com/contact-us/)]{#menu-item-295} +- [[DISCLAIMER](https://www.2daygeek.com/disclaimer/)]{#menu-item-296} +- [[PRIVACY + POLICY](https://www.2daygeek.com/privacy-policy/)]{#menu-item-3676} +- [[SUPPORT + US](https://www.2daygeek.com/support-us/)]{#menu-item-2729} +- [[OS + TWEAK](https://www.2daygeek.com/category/os-tweaks/)]{#menu-item-8366} +- [[ICONS](https://www.2daygeek.com/category/icon-theme/)]{#menu-item-12012} +- [[THEMES](https://www.2daygeek.com/category/gtk-theme/)]{#menu-item-12013} +::: + +::: {#topbar-header-search .container} +::: {.container-inner} +::: {.toggle-search} +::: + +::: {.search-expand} +::: {.search-expand-inner} +
+ +
+::: +::: +::: +::: + +::: {.container .group} +::: {.container-inner} +::: {.group .pad .central-header-zone} +::: {.logo-tagline-group} +[![2daygeek.com](https://www.2daygeek.com/wp-content/uploads/2015/12/2day-geek-new-logo-final.png)](https://www.2daygeek.com/ "2daygeek.com | Home page"){.custom-logo-link} +::: + +::: {#header-widgets} +::: {style="float:left;border:solid 0px;height:90px;width:728px;"} +[]{.underline} +::: +::: +::: + +::: {.nav-text} +::: + +::: {.nav-wrap .container} +- [LINUX + DISTRO'S](https://www.2daygeek.com/category/linux-distributions/) +- [LINUX COMMAND'S](https://www.2daygeek.com/category/linux-commands/) +- [WEBSERVER](https://www.2daygeek.com/category/webserver/) +- [MONITORING + TOOLS](https://www.2daygeek.com/category/monitoring-tools/) +- [PACKAGE + MANAGEMENT](https://www.2daygeek.com/category/package-management/) +- [REPOSITORY](https://www.2daygeek.com/category/repository/) +- [CLOUD + STORAGE](https://www.2daygeek.com/category/free-cloud-storage/) +- [HACKING](https://gbhackers.com/) + - [Tutorials](https://gbhackers.com/) +::: +::: +::: + +::: {#page .container} +::: {.container-inner} +::: {.main} +::: {.main-inner .group} +::: {.section .content} +::: {.page-title .pad .group} +- [Apps](https://www.2daygeek.com/category/apps/) +::: + +::: {.pad .group} +::: {.post-inner .group} +tmate -- Instantly Share Your Terminal Session To Anyone In Seconds {#tmate-instantly-share-your-terminal-session-to-anyone-in-seconds .post-title .entry-title} +=================================================================== + +by [ [[Magesh +Maruthamuthu](https://www.2daygeek.com/author/magesh/ "Posts by Magesh Maruthamuthu")]{.fn} +]{.vcard .author} · [Published : November 28, 2017 \|\| Last Updated: +November 28, 2017]{.published} + +::: {.clear} +::: + +::: {.entry .themeform} +::: {.entry-inner} +::: {style="float:left;margin:10px 10px 10px 0;"} +[]{.underline} +::: + +A while ago, we wrote about +[teleconsole](https://www.2daygeek.com/teleconsole-share-terminal-session-instantly-to-anyone-in-seconds/) +which is used to share terminal instantly to anyone (whoever you +trusting). Today also we are going to discuss about same kind of +application called tmate. + +Why you want tmate application? this will help you to get help from your +friends when you need. + +#### What Is tmate? + +[tmate](https://tmate.io/) stands for teammates, it's a fork of tmux, +and uses the same configurations such as keybindings, color schemes etc. +It's a terminal multiplexer with instant terminal sharing. it enables a +number of terminals to be created, accessed, and controlled from a +single screen, that can be shared with another mates. + +You can detach the session by leaving the job running in background and +re-attach the session when you want to view the status. tmate provides +an instant pairing solution, allowing you to share a terminal with one +or several teammates. + +A status line at the bottom of the screen shows information on the +current session, such as ssh command to share with your mate. + +#### How tmate works? + +- When launching tmate, an ssh connection is established to tmate.io + (backend servers maintained by tmate developers) in the background + through libssh. +- The server (tmate.io) ssh key signatures are verified during the DH + exchange. +- The client is authenticated with local ssh keys. +- Once connection is established, a 150 bits (non guessable random + characters) session token is generated by local tmux server. +- teammates can connect to tmate.io using the SSH session ID provided + by user + +#### Prerequisites for tmate + +Generate SSH key as a prerequisites since tmate.io server authenticate +client machine through local ssh keys. Make a note, every system should +have SSH key. + + $ ssh-keygen -t rsa + Generating public/private rsa key pair. + Enter file in which to save the key (/home/magi/.ssh/id_rsa): + Enter passphrase (empty for no passphrase): + Enter same passphrase again: + Your identification has been saved in /home/magi/.ssh/id_rsa. + Your public key has been saved in /home/magi/.ssh/id_rsa.pub. + The key fingerprint is: + SHA256:3ima5FuwKbWyyyNrlR/DeBucoyRfdOtlUmb5D214NC8 [email protected] + The key's randomart image is: + +---[RSA 2048]----+ + | | + | | + | . | + | . . = o | + | *ooS= . + o | + | . [email protected]*o.o.+ E .| + | =o==B++o = . | + | o.+*o+.. . | + | ..o+o=. | + +----[SHA256]-----+ + +#### How to Install tmate + +tmate is available in few of the distribution official repository that +can be installed through package manager. + +For **`Debian/Ubuntu`**, use [APT-GET +Command](https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/) +or [APT +Command](https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/)to +install tmate. + +::: {style="float:left;margin:10px 10px 10px 0;"} +[]{.underline} +::: + + $ sudo apt-get install software-properties-common + $ sudo add-apt-repository ppa:tmate.io/archive + $ sudo apt-get update + $ sudo apt-get install tmate + +Also, you can install tmate package from distribution official +repository. + + $ sudo apt-get install tmate + +For **`Fedora`**, use [DNF +Command](https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/) +to install tmate. + + $ sudo dnf install tmate + +For **`Arch Linux`** based systems, use []()[Yaourt +Command](https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/) +or []()[Packer +Command](https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/) +to install tmate from AUR repository. + + $ yaourt -S tmate + or + $ packer -S tmate + +For **`openSUSE`**, use [Zypper +Command](https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/) +to install tmate. + + $ sudo zypper in tmate + +#### How To Use tmate + +After successfully installed, open your terminal and fire the following +command which will open the new session for you and in the bottom of the +screen you can able to see the SSH session ID. + + $ tmate + +[![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter +.size-full .wp-image-15269 width="1051" +height="643"}![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter +.size-full .wp-image-15269 width="1051" +height="643"}](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-1.png) + +Make a note, the SSH session ID will disappear after a few seconds, so +don't worry you can get those details using following command. + +::: {style="float:none;margin:10px 0 10px 0;text-align:center;"} +[]{.underline} +::: + + $ tmate show-messages + +The tmate show-messages command allows you to see tmate's log messages, +including the ssh connection string.\ +[![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter +.size-full .wp-image-15270 width="1051" +height="643"}![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter +.size-full .wp-image-15270 width="1051" +height="643"}](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-2.png) + +Now, share your SSH session ID to your friends or coworkers and allow +them to view the terminal session. Not only SSH session ID, +alternatively you can share web URL as well, also you can share either +read only sessions or read-write sessions? + +#### How to connect session through SSH + +Just run the SSH session ID which you got from your friend on terminal. +It's like similar to below. + + $ ssh session: ssh [email protected] + +[![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter +.size-full .wp-image-15273 width="869" +height="625"}![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter +.size-full .wp-image-15273 width="869" +height="625"}](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-4.png) + +#### How to connect session through Web URL + +Open the browser and access the URL which you got from your friend. It's +like similar to below.\ +[![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter +.size-full .wp-image-15274 width="1024" +height="708"}![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter +.size-full .wp-image-15274 width="1024" +height="708"}](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-3.png) + +::: {style="float:none;margin:10px 0 10px 0;text-align:center;"} +::: + +Just type `exit` to exit from the session. + +::: {style="float:none;margin:10px 0 10px 0;text-align:center;"} +::: + + [Source System Output] + [exited] + + [Remote System Output] + [server exited] + Connection to sg2.tmate.io closed by remote host. + Connection to sg2.tmate.io closed. + +::: {style="float:none;margin:10px 0 10px 0;text-align:center;"} +[]{.underline} +::: + +::: {style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"} +::: +::: + +::: {.clear} +::: +::: +::: + +::: {.clear} +::: + +Tags: [Application](https://www.2daygeek.com/tag/application/)[Instant +terminal +sharing](https://www.2daygeek.com/tag/instant-terminal-sharing/)[Linux](https://www.2daygeek.com/tag/linux/)[tmate](https://www.2daygeek.com/tag/tmate/) + +::: {.author-bio} +::: {.bio-avatar} +![](https://www.2daygeek.com/wp-content/plugins/lazy-load/images/1x1.trans.gif){.avatar +.avatar-128 .photo width="128" height="128" +srcset="https://secure.gravatar.com/avatar/d487bef1de15143a7b80a40396e96118?s=256&d=mm&r=g 2x"} + +![](https://secure.gravatar.com/avatar/d487bef1de15143a7b80a40396e96118?s=128&d=mm&r=g){.avatar +.avatar-128 .photo width="128" height="128" +srcset="https://secure.gravatar.com/avatar/d487bef1de15143a7b80a40396e96118?s=256&d=mm&r=g 2x"} +::: + +Magesh Maruthamuthu + +Love to play with all Linux distribution + +::: {.clear} +::: +::: + +- - [**Previous story** How To Empty a File, Delete N Lines From a + File, Remove Matching String From a File, And Remove Empty/Blank + Lines From a File In + Linux?](https://www.2daygeek.com/empty-a-file-delete-contents-lines-from-a-file-remove-matching-string-from-a-file-remove-empty-blank-lines-from-a-file/) + +#### You may also like\... {#you-may-also-like... .heading} + +- ::: {.post-thumbnail} + ![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.attachment-thumb-medium + .size-thumb-medium .wp-post-image width="520" height="245"} + ![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.attachment-thumb-medium + .size-thumb-medium .wp-post-image width="520" height="245"} + ::: + + ::: {.related-inner} + #### [wikipedia2text -- A Command Line Tool For Querying The Wikipedia Article](https://www.2daygeek.com/wikipedia2text-wiki-cli-access-query-read-wikipedia-page-article-in-linux-command-line/ "wikipedia2text – A Command Line Tool For Querying The Wikipedia Article") {#wikipedia2text-a-command-line-tool-for-querying-the-wikipedia-article .post-title .entry-title} + + ::: {.post-meta .group} + October 17, 2017 + ::: + ::: + +- ::: {.post-thumbnail} + ![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.attachment-thumb-medium + .size-thumb-medium .wp-post-image width="520" height="245"} + ![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.attachment-thumb-medium + .size-thumb-medium .wp-post-image width="520" height="245"} + ::: + + ::: {.related-inner} + #### [RTV (Reddit Terminal Viewer) -- A Simple Terminal Viewer For Reddit](https://www.2daygeek.com/rtv-reddit-terminal-viewer-a-simple-terminal-viewer-for-reddit/ "RTV (Reddit Terminal Viewer) – A Simple Terminal Viewer For Reddit") {#rtv-reddit-terminal-viewer-a-simple-terminal-viewer-for-reddit .post-title .entry-title} + + ::: {.post-meta .group} + October 13, 2017 + ::: + ::: + +- ::: {.post-thumbnail} + ![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.attachment-thumb-medium + .size-thumb-medium .wp-post-image width="520" height="245"} + ![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.attachment-thumb-medium + .size-thumb-medium .wp-post-image width="520" height="245"} + ::: + + ::: {.related-inner} + #### [Teleconsole -- A Tool To Share Your Terminal Session Instantly To Anyone In Seconds](https://www.2daygeek.com/teleconsole-share-terminal-session-instantly-to-anyone-in-seconds/ "Teleconsole – A Tool To Share Your Terminal Session Instantly To Anyone In Seconds") {#teleconsole-a-tool-to-share-your-terminal-session-instantly-to-anyone-in-seconds .post-title .entry-title} + + ::: {.post-meta .group} + November 6, 2017 + ::: + ::: + +::: {#disqus_thread} +::: +::: +::: + +::: {.sidebar .s1 .collapsed data-position="right" data-layout="col-2cl" data-sb-id="s1"} +[]{.sidebar-toggle} + +::: {.sidebar-content} +::: {.sidebar-top .group} +Follow: + +- [](https://www.facebook.com/2daygeek "Facebook"){.social-tooltip} +- [](https://www.twitter.com/2daygeek "Twitter"){.social-tooltip} +- [](https://www.google.com/+2daygeeks "Google+"){.social-tooltip} +- [](https://www.linkedin.com/company/2daygeek "Linkein"){.social-tooltip} +- [](javascript:void(0) "Pinterest"){.social-tooltip} +- [](http://2daygeek.tumblr.com/ "Tumblr"){.social-tooltip} +::: + +::: {#text-8 .widget .widget_text} +### -- Click Here To Get Offers -- {#click-here-to-get-offers .widget-title} + +::: {.textwidget} +[]{.underline} +::: +::: + +::: {#text-10 .widget .widget_text} +### -- For Better Offers -- {#for-better-offers .widget-title} + +::: {.textwidget} +::: +::: + +::: {#text-12 .widget .widget_text} +### -Unmatched Offers For Linux Users- {#unmatched-offers-for-linux-users- .widget-title} + +::: {.textwidget} +::: +::: + +::: {#wp_subscribe-3 .widget .wp_subscribe} +::: {#wp-subscribe .wp-subscribe-wrap .wp-subscribe .wp-subscribe-1 data-thanks_page="0" data-thanks_page_url="" data-thanks_page_new_window="0"} +#### Get Latest LINUX Tips {#get-latest-linux-tips .title} + +::: {.wp-subscribe-loader} +::: + +Thank you for subscribing. + +Something went wrong. + +::: {.clear} +::: +::: +::: + +::: {#text-3 .widget .widget_text} +::: {.textwidget} +::: +::: + +::: {#text-6 .widget .widget_text} +::: {.textwidget} +::: {#google_translate_element} +::: +::: +::: + +::: {#text-5 .widget .widget_text} +### Follow us {#follow-us .widget-title} + +::: {.textwidget} +::: {.g-page data-href="//plus.google.com/107364365185869631781" data-layout="landscape" data-rel="publisher"} +::: +::: +::: +::: +::: +::: +::: +::: +::: + +::: {#footer-bottom .section .container} +::: {.container-inner} +[](#){#back-to-top} + +::: {.pad .group} +::: {.grid .one-half} +::: {#copyright} +2daygeek.com © 2017. All Rights Reserved. +::: + +::: {#credit style=""} +[2daygeek](https://www.2daygeek.com) :- Linux Tips & Tricks, Linux +How-to Guides & Tutorials is licensed under a [(cc) +BY-NC](https://creativecommons.org/licenses/by-nc/4.0/) +::: +::: + +::: {.grid .one-half .last} +- [](https://www.facebook.com/2daygeek "Facebook"){.social-tooltip} +- [](https://www.twitter.com/2daygeek "Twitter"){.social-tooltip} +- [](https://www.google.com/+2daygeeks "Google+"){.social-tooltip} +- [](https://www.linkedin.com/company/2daygeek "Linkein"){.social-tooltip} +- [](javascript:void(0) "Pinterest"){.social-tooltip} +- [](http://2daygeek.tumblr.com/ "Tumblr"){.social-tooltip} +::: +::: +::: +::: +::: + +::: {#crestashareicon .cresta-share-icon .sameColors .first_style .show-count-active} +::: {#facebook-cresta .sbutton .crestaShadow .facebook-cresta-share .float} +[](https://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.2daygeek.com%2Ftmate-instantly-share-your-terminal-session-to-anyone-in-seconds%2F&t=tmate+%E2%80%93++Instantly+Share+Your+Terminal+Session+To+Anyone+In+Seconds "Share to Facebook") +::: + +::: {#twitter-cresta .sbutton .crestaShadow .twitter-cresta-share .float .withCount} +[](https://twitter.com/share?text=tmate+%E2%80%93++Instantly+Share+Your+Terminal+Session+To+Anyone+In+Seconds&url=https%3A%2F%2Fwww.2daygeek.com%2Ftmate-instantly-share-your-terminal-session-to-anyone-in-seconds%2F&via=2daygeek "Share to Twitter") +::: + +::: {#googleplus-cresta .sbutton .crestaShadow .googleplus-cresta-share .float} +[](https://plus.google.com/share?url=https%3A%2F%2Fwww.2daygeek.com%2Ftmate-instantly-share-your-terminal-session-to-anyone-in-seconds%2F "Share to Google Plus") +::: + +::: {#linkedin-cresta .sbutton .crestaShadow .linkedin-cresta-share .float} +[](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.2daygeek.com%2Ftmate-instantly-share-your-terminal-session-to-anyone-in-seconds%2F&title=tmate+%E2%80%93++Instantly+Share+Your+Terminal+Session+To+Anyone+In+Seconds&source=https://www.2daygeek.com/ "Share to LinkedIn") +::: + +::: {#pinterest-cresta .sbutton .crestaShadow .pinterest-cresta-share .float} +[](https://pinterest.com/pin/create/bookmarklet/?url=https%3A%2F%2Fwww.2daygeek.com%2Ftmate-instantly-share-your-terminal-session-to-anyone-in-seconds%2F&media=https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds.png&description=tmate+%E2%80%93++Instantly+Share+Your+Terminal+Session+To+Anyone+In+Seconds "Share to Pinterest") +::: + +::: {#total-shares .sbutton} +[]{#total-count .cresta-the-total-count}[Shares]{.cresta-the-total-text} +::: + +::: {style="clear: both;"} +::: +::: + +::: {#spu-bg} +::: + +::: {#spu-main} +[Close](#){#spu-close} + +::: {#spu-title} +Please support the site +::: + +::: {#spu-msg-cont} +::: {#spu-msg} +By clicking any of these buttons you help our site to get better + +::: {.spu-button .spu-twitter} +[Follow Me](https://twitter.com/2daygeek){.twitter-follow-button} +::: + +::: {.spu-button .spu-facebook} +::: {#fb-root} +::: + +::: {.fb-like data-href="https://www.facebook.com/2daygeek" data-send="false" data-width="450" data-show-faces="true" data-layout="button_count"} +::: +::: + +::: {.spu-button .spu-google} +::: {.g-plusone data-callback="googleCB" data-onendinteraction="closeGoogle" data-recommendations="false" data-annotation="bubble" data-size="medium" data-href="https://www.google.com/+2daygeeks"} +::: +::: +::: + +::: {.step-clear} +::: +::: + +[]{#spu-timer} + +::: {#spu-bottom} +::: +::: + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds/ + +作者:[ ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + From bd08677cff363066d8616e6a0cb0a2507fd249be Mon Sep 17 00:00:00 2001 From: Ezio Date: Wed, 29 Nov 2017 11:25:25 +0800 Subject: [PATCH 011/344] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...7 How to Easily Remember Linux Commands.md | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/translated/tech/20171117 How to Easily Remember Linux Commands.md b/translated/tech/20171117 How to Easily Remember Linux Commands.md index 8e4483cd20..16f4182e80 100644 --- a/translated/tech/20171117 How to Easily Remember Linux Commands.md +++ b/translated/tech/20171117 How to Easily Remember Linux Commands.md @@ -9,7 +9,7 @@ Linux 新手往往对命令行心存畏惧。部分原因是因为需要记忆 ![Linux Bash History 命令](https://www.maketecheasier.com/assets/uploads/2017/10/rc-bash-history.jpg) -首先要介绍的是命令行工具 history。它能帮你记住那些你曾经用过的命令。大多数 [Linux shells](https://www.maketecheasier.com/remember-linux-commands/),包括应用最广泛的 Bash,都会创建一个历史文件来包含那些你输入过的命令。如果你用的是 Bash,这个历史文件就是 "/home//.bash_history"。 +首先要介绍的是命令行工具 history。它能帮你记住那些你曾经用过的命令。大多数 [Linux shells][1],包括应用最广泛的 Bash,都会创建一个历史文件来包含那些你输入过的命令。如果你用的是 Bash,这个历史文件就是 "/home//.bash_history"。 这个历史文件是纯文本格式的,你可以用任意的文本编辑器打开来浏览和搜索。 ## Apropos @@ -36,7 +36,7 @@ Linux 新手往往对命令行心存畏惧。部分原因是因为需要记忆 ![Linux Apropos -a Flag](https://www.maketecheasier.com/assets/uploads/2017/10/rc-apropos-a.jpg) -你会觉得应该会有一些匹配的内容出现,比如 [grep](https://www.maketecheasier.com/remember-linux-commands/) 对吗? +你会觉得应该会有一些匹配的内容出现,比如 [grep][2] 对吗? 然而,实际上并没有匹配出任何结果。再说一次,apropos 只会根据字面内容进行搜索。 现在让我们试着用 `-a` 标志来把单词分割开来。 @@ -50,12 +50,12 @@ apropos 是一个很棒的工具,不过你需要留意它的缺陷。 ![Linux ZSH Autocomplete](https://www.maketecheasier.com/assets/uploads/2017/10/rc-zsh.jpg) -ZSH 其实并不是用于记忆命令的工具。它其实是一种 shell。你可以用 [ZSH](https://www.maketecheasier.com/remember-linux-commands/) 来替代 Bash 作为你的命令行 shell。ZSH 包含了自动纠错机制,能在你输入命令的时候给你予提示。 -开启该功能后,它会提示你相近的选择想面。在 ZSH 中你可以像往常一样使用命令行,同时你还能享受到极度安全的网络以及其他一些非常好用的特性。充分利用 ZSH 的最简单方法就是使用 [Oh-My-ZSH](https://www.maketecheasier.com/remember-linux-commands/)。 +ZSH 其实并不是用于记忆命令的工具。它其实是一种 shell。你可以用 [ZSH][3] 来替代 Bash 作为你的命令行 shell。ZSH 包含了自动纠错机制,能在你输入命令的时候给你予提示。 +开启该功能后,它会提示你相近的选择想面。在 ZSH 中你可以像往常一样使用命令行,同时你还能享受到极度安全的网络以及其他一些非常好用的特性。充分利用 ZSH 的最简单方法就是使用 [Oh-My-ZSH][4]。 ## Cheat Sheet -最后,也可能是最间的方法就是使用 [cheat sheet](https://www.maketecheasier.com/remember-linux-commands/)。 -有很多在线的 cheat sheet,比如[这个](https://www.maketecheasier.com/remember-linux-commands/) 可以帮助你快速查询命令。 +最后,也可能是最间的方法就是使用 [cheat sheet][5]。 +有很多在线的 cheat sheet,比如[这个][6] 可以帮助你快速查询命令。 ![linux-commandline-cheatsheet](https://www.maketecheasier.com/assets/uploads/2013/10/linux-commandline-cheatsheet.gif) 为了快速查询,你可以寻找图片格式的 cheat sheet 然后将它设置为你的桌面墙纸。 @@ -72,3 +72,11 @@ via: https://www.maketecheasier.com/remember-linux-commands/ 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.maketecheasier.com/author/nickcongleton/ +[1]: https://www.maketecheasier.com/alternative-linux-shells/ +[2]: https://www.maketecheasier.com/what-is-grep-and-uses/ +[3]: https://www.maketecheasier.com/understanding-the-different-shell-in-linux-zsh-shell/ +[4]: https://github.com/robbyrussell/oh-my-zsh +[5]: https://www.maketecheasier.com/premium/cheatsheet/linux-command-line/ +[6]: https://www.cheatography.com/davechild/cheat-sheets/linux-command-line/ From 6522cd36e2e8f2f058de0db3efb630f9e7a79233 Mon Sep 17 00:00:00 2001 From: Yixun Xu Date: Wed, 29 Nov 2017 00:14:42 -0500 Subject: [PATCH 012/344] =?UTF-8?q?yixunx=E8=AE=A4=E9=A2=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...170809 Designing a Microservices Architecture for Failure.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20170809 Designing a Microservices Architecture for Failure.md b/sources/tech/20170809 Designing a Microservices Architecture for Failure.md index e1124c229c..3325aaf8da 100644 --- a/sources/tech/20170809 Designing a Microservices Architecture for Failure.md +++ b/sources/tech/20170809 Designing a Microservices Architecture for Failure.md @@ -1,3 +1,5 @@ +yixunx翻译中 + Designing a Microservices Architecture for Failure ============================================================  From 571380a4670e688cf47d64355835418b45d7b841 Mon Sep 17 00:00:00 2001 From: HankChow Date: Wed, 29 Nov 2017 15:16:07 +0800 Subject: [PATCH 013/344] HankChow translating --- ...Measure Twice Compute Once with Xen Linux TPM 2.0 and TXT.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171010 In Device We Trust Measure Twice Compute Once with Xen Linux TPM 2.0 and TXT.md b/sources/tech/20171010 In Device We Trust Measure Twice Compute Once with Xen Linux TPM 2.0 and TXT.md index 20c14074c6..bc3e800452 100644 --- a/sources/tech/20171010 In Device We Trust Measure Twice Compute Once with Xen Linux TPM 2.0 and TXT.md +++ b/sources/tech/20171010 In Device We Trust Measure Twice Compute Once with Xen Linux TPM 2.0 and TXT.md @@ -1,3 +1,5 @@ +HankChow Translating + In Device We Trust: Measure Twice, Compute Once with Xen, Linux, TPM 2.0 and TXT ============================================================ From cd0d02a9aae43381e4cbdccd387e977fed8563fd Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 29 Nov 2017 15:29:20 +0800 Subject: [PATCH 014/344] PRF:20171117 How to Easily Remember Linux Commands.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @lujun9972 恭喜你,完成了第一篇翻译!可以参照我的校对了解格式惯例。 另外,其实以后有选题建议,可以将 URL 发 issue 给 项目,或者QQ 发给 选题-vim 。 --- ...7 How to Easily Remember Linux Commands.md | 62 +++++++++++-------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/translated/tech/20171117 How to Easily Remember Linux Commands.md b/translated/tech/20171117 How to Easily Remember Linux Commands.md index 16f4182e80..c408beb6e9 100644 --- a/translated/tech/20171117 How to Easily Remember Linux Commands.md +++ b/translated/tech/20171117 How to Easily Remember Linux Commands.md @@ -1,67 +1,77 @@ -# How to Easily Remember Linux Commands +如何轻松记住 Linux 命令 +================= ![](https://www.maketecheasier.com/assets/uploads/2017/10/rc-feat.jpg) +Linux 新手往往对命令行心存畏惧。部分原因是因为需要记忆大量的命令,毕竟掌握命令是高效使用命令行的前提。 -Linux 新手往往对命令行心存畏惧。部分原因是因为需要记忆大量的命令。毕竟掌握命令是高效使用命令行的前提。 不幸的是,学习这些命令并无捷径,然而在你开始学习命令之初,有些工具还是可以帮到你的。 -## History + +### history ![Linux Bash History 命令](https://www.maketecheasier.com/assets/uploads/2017/10/rc-bash-history.jpg) -首先要介绍的是命令行工具 history。它能帮你记住那些你曾经用过的命令。大多数 [Linux shells][1],包括应用最广泛的 Bash,都会创建一个历史文件来包含那些你输入过的命令。如果你用的是 Bash,这个历史文件就是 "/home//.bash_history"。 -这个历史文件是纯文本格式的,你可以用任意的文本编辑器打开来浏览和搜索。 -## Apropos +首先要介绍的是命令行工具 `history`,它能帮你记住那些你曾经用过的命令。包括应用最广泛的 Bash 在内的大多数 [Linux shell][1],都会创建一个历史文件来包含那些你输入过的命令。如果你用的是 Bash,这个历史文件就是 `/home//.bash_history`。 -确实存在有一个命令可以帮你找到其他命令。这个命令就是 "apropos",它能帮你找出合适的命令来完成你搜索的操作。比如,假设你需要知道哪个命令可以列出目录的内容,你可以运行下面命令: +这个历史文件是纯文本格式的,你可以用任意的文本编辑器打开来浏览和搜索。 + +### apropos + +确实存在一个可以帮你找到其他命令的命令。这个命令就是 `apropos`,它能帮你找出合适的命令来完成你的搜索。比如,假设你需要知道哪个命令可以列出目录的内容,你可以运行下面命令: ```shell - apropos "list directory" +apropos "list directory" ``` ![Linux Apropos](https://www.maketecheasier.com/assets/uploads/2017/10/rc-apropos.jpg) -这就搜索出结果了。非常直接。给 "directory" 加上 "s" 后再试一下。 +这就搜索出结果了,非常直接。给 “directory” 加上复数后再试一下。 ```shell - apropos "list directories" +apropos "list directories" ``` 这次没用了。`apropos` 所作的其实就是搜索一系列命令的描述。描述不匹配的命令不会纳入结果中。 + 还有其他的用法。通过 `-a` 标志,你可以以更灵活的方式来增加搜索关键字。试试这条命令: ```shell - apropos "match pattern" +apropos "match pattern" ``` ![Linux Apropos -a Flag](https://www.maketecheasier.com/assets/uploads/2017/10/rc-apropos-a.jpg) -你会觉得应该会有一些匹配的内容出现,比如 [grep][2] 对吗? -然而,实际上并没有匹配出任何结果。再说一次,apropos 只会根据字面内容进行搜索。 -现在让我们试着用 `-a` 标志来把单词分割开来。 +你会觉得应该会有一些匹配的内容出现,比如 [grep][2] 对吗? 然而,实际上并没有匹配出任何结果。再说一次,apropos 只会根据字面内容进行搜索。 + +现在让我们试着用 `-a` 标志来把单词分割开来。(LCTT 译注:该选项的意思是“and”,即多个关键字都存在,但是不需要正好是连在一起的字符串。) ```shell - apropos "match" -a "pattern" +apropos "match" -a "pattern" ``` 这一下,你可以看到很多期望的结果了。 -apropos 是一个很棒的工具,不过你需要留意它的缺陷。 -## ZSH + +`apropos` 是一个很棒的工具,不过你需要留意它的缺陷。 + +### ZSH ![Linux ZSH Autocomplete](https://www.maketecheasier.com/assets/uploads/2017/10/rc-zsh.jpg) -ZSH 其实并不是用于记忆命令的工具。它其实是一种 shell。你可以用 [ZSH][3] 来替代 Bash 作为你的命令行 shell。ZSH 包含了自动纠错机制,能在你输入命令的时候给你予提示。 -开启该功能后,它会提示你相近的选择想面。在 ZSH 中你可以像往常一样使用命令行,同时你还能享受到极度安全的网络以及其他一些非常好用的特性。充分利用 ZSH 的最简单方法就是使用 [Oh-My-ZSH][4]。 -## Cheat Sheet +ZSH 其实并不是用于记忆命令的工具。它其实是一种 shell。你可以用 [ZSH][3] 来替代 Bash 作为你的命令行 shell。ZSH 包含了自动纠错机制,能在你输入命令的时候给你予提示。开启该功能后,它会提示你相近的选择。在 ZSH 中你可以像往常一样使用命令行,同时你还能享受到极度安全的网络以及其他一些非常好用的特性。充分利用 ZSH 的最简单方法就是使用 [Oh-My-ZSH][4]。 + +### 速记表 + +最后,也可能是最间的方法就是使用 [速记表][5]。 + +有很多在线的速记表,比如[这个][6] 可以帮助你快速查询命令。 -最后,也可能是最间的方法就是使用 [cheat sheet][5]。 -有很多在线的 cheat sheet,比如[这个][6] 可以帮助你快速查询命令。 ![linux-commandline-cheatsheet](https://www.maketecheasier.com/assets/uploads/2013/10/linux-commandline-cheatsheet.gif) -为了快速查询,你可以寻找图片格式的 cheat sheet 然后将它设置为你的桌面墙纸。 +为了快速查询,你可以寻找图片格式的速记表,然后将它设置为你的桌面墙纸。 + 这并不是记忆命令的最好方法,但是这么做可以帮你节省在线搜索遗忘命令的时间。 -在学习时依赖这些方法,最终你会发现你会越来越少地使用这些工具。 -没有人能够记住所有的事情,因此偶尔遗忘掉某些东西或者遇到某些没有见过的东西也很正常。这也是这些工具以及因特网存在的意义。 + +在学习时依赖这些方法,最终你会发现你会越来越少地使用这些工具。没有人能够记住所有的事情,因此偶尔遗忘掉某些东西或者遇到某些没有见过的东西也很正常。这也是这些工具以及因特网存在的意义。 -------------------------------------------------------------------------------- @@ -69,7 +79,7 @@ via: https://www.maketecheasier.com/remember-linux-commands/ 作者:[Nick Congleton][a] 译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From c8ca9f3cece6aefeac6acf4ca9fb9466d44f5fc6 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 29 Nov 2017 15:29:52 +0800 Subject: [PATCH 015/344] PUB:20171117 How to Easily Remember Linux Commands.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @lujun9972 文章地址:https://linux.cn/article-9093-1.html 你的 LCTT 专页地址: https://linux.cn/lctt/lujun9972 --- .../20171117 How to Easily Remember Linux Commands.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171117 How to Easily Remember Linux Commands.md (100%) diff --git a/translated/tech/20171117 How to Easily Remember Linux Commands.md b/published/20171117 How to Easily Remember Linux Commands.md similarity index 100% rename from translated/tech/20171117 How to Easily Remember Linux Commands.md rename to published/20171117 How to Easily Remember Linux Commands.md From 1287cc2b185c4e37a9e159b3d1844e94a4b9f199 Mon Sep 17 00:00:00 2001 From: Ezio Date: Wed, 29 Nov 2017 15:35:19 +0800 Subject: [PATCH 016/344] =?UTF-8?q?20171129-1=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0171120 Mark McIntyre How Do You Fedora.md | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 sources/tech/20171120 Mark McIntyre How Do You Fedora.md diff --git a/sources/tech/20171120 Mark McIntyre How Do You Fedora.md b/sources/tech/20171120 Mark McIntyre How Do You Fedora.md new file mode 100644 index 0000000000..0788c67817 --- /dev/null +++ b/sources/tech/20171120 Mark McIntyre How Do You Fedora.md @@ -0,0 +1,74 @@ +# [Mark McIntyre: How Do You Fedora?][1] + + +![](https://fedoramagazine.org/wp-content/uploads/2017/11/mock-couch-945w-945x400.jpg) + +We recently interviewed Mark McIntyre on how he uses Fedora. This is [part of a series][2] on the Fedora Magazine. The series profiles Fedora users and how they use Fedora to get things done. Contact us on the [feedback form][3] to express your interest in becoming a interviewee. + +### Who is Mark McIntyre? + +Mark McIntyre is a geek by birth and Linux by choice. “I started coding at the early age of 13 learning BASIC on my own and finding the excitement of programming which led me down a path of becoming a professional coder,” he says. McIntyre and his niece are big fans of pizza. “My niece and I started a quest last fall to try as many of the pizza joints in Knoxville. You can read about our progress at [https://knox-pizza-quest.blogspot.com/][4]” Mark is also an amateur photographer and [publishes his images][5] on Flickr. + +![](https://fedoramagazine.org/wp-content/uploads/2017/11/31456893222_553b3cac4d_k-1024x575.jpg) + +Mark has a diverse background as a developer. He has worked with Visual Basic for Applications, LotusScript, Oracle’s PL/SQL, Tcl/Tk and Python with Django as the framework. His strongest skill is Python which he uses in his current job as a systems engineer. “I am using Python on a regular basis. As my job is morphing into more of an automation engineer, that became more frequent.” + +McIntyre is a self-described nerd and loves sci-fi movies, but his favorite movie falls out of that genre. “As much as I am a nerd and love the Star Trek and Star Wars and related movies, the movie Glory is probably my favorite of all time.” He also mentioned that Serenity was a fantastic follow-up to a great TV series. + +Mark values humility, knowledge and graciousness in others. He appreciates people who act based on understanding the situation that other people are in. “If you add a decision to serve another, you have the basis for someone you’d want to be around instead of someone who you have to tolerate.” + +McIntyre works for [Scripps Networks Interactive][6], which is the parent company for HGTV, Food Network, Travel Channel, DIY, GAC, and several other cable channels. “Currently, I function as a systems engineer for the non-linear video content, which is all the media purposed for online consumption.” He supports a few development teams who write applications to publish the linear video from cable TV into the online formats such as Amazon and Hulu. The systems include both on-premise and cloud systems. Mark also develops automation tools for deploying these applications primarily to a cloud infrastructure. + +### The Fedora community + +Mark describes the Fedora community as an active community filled with people who enjoy life as Fedora users. “From designers to packagers, this group is still very active and feels alive.” McIntyre continues, “That gives me a sense of confidence in the operating system.” + +He started frequenting the #fedora channel on IRC around 2002: “Back then, Wi-Fi functionality was still done a lot by hand in starting the adapter and configuring the modules.” In order to get his Wi-Fi working he had to recompile the Fedora kernel. Shortly after, he started helping others in the #fedora channel. + +McIntyre encourages others to get involved in the Fedora Community. “There are many different areas of opportunity in which to be involved. Front-end design, testing deployments, development, packaging of applications, and new technology implementation.” He recommends picking an area of interest and asking questions of that group. “There are many opportunities available to jump in to contribute.” + +He credits a fellow community member with helping him get started: “Ben Williams was very helpful in my first encounters with Fedora, helping me with some of my first installation rough patches in the #fedora support channel.” Ben also encouraged Mark to become an [Ambassador][7]. + +### What hardware and software? + +McIntyre uses Fedora Linux on all his laptops and desktops. On servers he chooses CentOS, due to the longer support lifecycle. His current desktop is self-built and equipped with an Intel Core i5 processor, 32 GB of RAM and 2 TB of disk space. “I have a 4K monitor attached which gives me plenty of room for viewing all my applications at once.” His current work laptop is a Dell Inspiron 2-in-1 13-inch laptop with 16 GB RAM and a 525 GB m.2 SSD. + +![](https://fedoramagazine.org/wp-content/uploads/2017/11/Screenshot-from-2017-10-26-08-51-41-1024x640.png) + +Mark currently runs Fedora 26 on any box he setup in the past few months. When it comes to new versions he likes to avoid the rush when the version is officially released. “I usually try to get the latest version as soon as it goes gold, with the exception of one of my workstations running the next version’s beta when it is closer to release.” He usually upgrades in place: “The in-place upgrade using  _dnf system-upgrade_  works very well these days.” + +To handle his photography, McIntyre uses [GIMP][8] and [Darktable][9], along with a few other photo viewing and quick editing packages. When not using web-based email, he uses [Geary][10] along with [GNOME Calendar][11]. Mark’s IRC client of choice is [HexChat][12] connecting to a [ZNC bouncer][13]running on a Fedora Server instance. His department’s communication is handled via Slack. + +“I have never really been a big IDE fan, so I spend time in [vim][14] for most of my editing.” Occasionally, he opens up a simple text editor like [gedit][15] or [xed][16]. Mark uses [GPaste][17] for  copying and pasting. “I have become a big fan of [Tilix][18] for my terminal choice.” McIntyre manages the podcasts he likes with [Rhythmbox][19], and uses [Epiphany][20] for quick web lookups. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/mark-mcintyre-fedora/ + +作者:[Charles Profitt][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://fedoramagazine.org/author/cprofitt/ +[1]:https://fedoramagazine.org/mark-mcintyre-fedora/ +[2]:https://fedoramagazine.org/tag/how-do-you-fedora/ +[3]:https://fedoramagazine.org/submit-an-idea-or-tip/ +[4]:https://knox-pizza-quest.blogspot.com/ +[5]:https://www.flickr.com/photos/mockgeek/ +[6]:http://www.scrippsnetworksinteractive.com/ +[7]:https://fedoraproject.org/wiki/Ambassadors +[8]:https://www.gimp.org/ +[9]:http://www.darktable.org/ +[10]:https://wiki.gnome.org/Apps/Geary +[11]:https://wiki.gnome.org/Apps/Calendar +[12]:https://hexchat.github.io/ +[13]:https://wiki.znc.in/ZNC +[14]:http://www.vim.org/ +[15]:https://wiki.gnome.org/Apps/Gedit +[16]:https://github.com/linuxmint/xed +[17]:https://github.com/Keruspe/GPaste +[18]:https://fedoramagazine.org/try-tilix-new-terminal-emulator-fedora/ +[19]:https://wiki.gnome.org/Apps/Rhythmbox +[20]:https://wiki.gnome.org/Apps/Web From 07bdfd105551fa2f1f610640eb43356e74db92be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E8=8D=A3=E5=8D=87?= Date: Wed, 29 Nov 2017 15:42:39 +0800 Subject: [PATCH 017/344] Update 20171120 Mark McIntyre How Do You Fedora.md translating --- sources/tech/20171120 Mark McIntyre How Do You Fedora.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171120 Mark McIntyre How Do You Fedora.md b/sources/tech/20171120 Mark McIntyre How Do You Fedora.md index 0788c67817..bfd19e1eda 100644 --- a/sources/tech/20171120 Mark McIntyre How Do You Fedora.md +++ b/sources/tech/20171120 Mark McIntyre How Do You Fedora.md @@ -1,3 +1,4 @@ +translating by zrszrszrs # [Mark McIntyre: How Do You Fedora?][1] From 2a28e099bf212b6538e201f5aabe576b17961c24 Mon Sep 17 00:00:00 2001 From: Ezio Date: Wed, 29 Nov 2017 15:52:28 +0800 Subject: [PATCH 018/344] =?UTF-8?q?20171129-2=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...and Certification Are Key for SysAdmins.md | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md diff --git a/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md b/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md new file mode 100644 index 0000000000..e1237760b0 --- /dev/null +++ b/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md @@ -0,0 +1,67 @@ +Open Source Cloud Skills and Certification Are Key for SysAdmins +============================================================ + + +![os jobs](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/open-house-sysadmin.jpg?itok=i5FHc3lu "os jobs") +Sysadmins with open source skills and certification can command higher pay, according to the 2017 Open Source Jobs Report.[Creative Commons Zero][1] + +System administrator is one of the most common positions employers are looking to fill among 53 percent of respondents to the [2017 Open Source Jobs Report][3]. Consequently, sysadmins with skills in engineering can command higher salaries, as these positions are among the hardest to fill, the report finds. + +Sysadmins are generally responsible for installing, supporting, and maintaining servers or other computer systems, and planning for and responding to service outages and other problems. + +Overall, this year’s report finds the skills most in demand are open source cloud (47 percent), application development (44 percent), Big Data (43 percent) and both DevOps and security (42 percent). + +The report also finds that 58 percent of hiring managers are planning to hire more open source professionals, and 67 percent say hiring of open source professionals will increase more than in other areas of the business. This represents a two-point increase over last year among employers who said open source hiring would be their top field of recruitment. + +At the same time, 89 percent of hiring managers report it is difficult to find open source talent. + +### Why get certified + +The desire for sysadmins is incentivizing hiring managers to offer formal training and/or certifications in the discipline in 53 percent of organizations, compared to 47 percent last year, the Open Source Jobs Report finds. + +IT professionals interested in sysadmin positions should consider Linux certifications. Searches on several of the more well-known job posting sites reveal that the [CompTIA Linux+][4]certification is the top certification for entry-level Linux sysadmin, while [Red Hat Certified Engineer (RHCE)][5] and [Red Hat Certified System Administrator (RHCSA)][6] are the main certifications for higher-level positions. + +In 2016, a sysadmin commanded a salary of $79,583, a change of -0.8 percent from the previous year, according to Dice’s [2017 Tech Salary Survey][7]. The systems architect position paid $125,946, a year-over-year change of -4.7 percent. Yet, the survey observes that “Highly skilled technology professionals remain in the most demand, especially those candidates proficient in the technologies needed to support industry transformation and growth.” + +When it comes to open source skills, HBase (an open-source distributed database), ranked as one that garners among the highest pay for tech pros in the Dice survey. In the networking and database category, the OpenVMS operating system ranked as another high-paying skill. + +### The sysadmin role + +One of a sysadmin’s responsibilities is to be available 24/7 when a problem occurs. The position calls for a mindset that is about “zero-blame, lean, iterative improvement in process or technology,’’ and one that is open to change, writes Paul English, a board member for the League of Professional System Administrators, a non-profit professional association for the advancement of the practice of system administration, in  [opensource.com][8]. He adds that being a sysadmin means “it’s almost a foregone conclusion that you’ll work with open source software like Linux, BSD, and even open source Solaris.” + +Today’s sysadmins will more often work with software rather than hardware, and should be prepared to write small scripts, according to English. + +### Outlook for 2018 + +Expect to see sysadmins among the tech professionals many employers in North America will be hiring in 2018, according to [Robert Half’s 2018 Salary Guide for Technology Professionals][9]. Increasingly, soft skills and leadership qualities are also highly valued. + +“Good listening and critical-thinking skills, which are essential to understanding and resolving customers’ issues and concerns, are important for almost any IT role today, but especially for help desk and desktop support professionals,’’ the report states. + +This jibes with some of the essential skills needed at various stages of the sysadmin position, including strong analytical skills and an ability to solve problems quickly, according to [The Linux Foundation][10]. + +Other skills sysadmins should have as they move up the ladder are: interest in structured approaches to system configuration management; experience in resolving security issues; experience with user identity management; ability to communicate in non-technical terms to non-technical people; and ability to modify system to meet new security requirements. + + _[Download ][11]the full 2017 Open Source Jobs Report now._ + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/open-source-cloud-skills-and-certification-are-key-sysadmins + +作者:[ ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[1]:https://www.linux.com/licenses/category/creative-commons-zero +[2]:https://www.linux.com/files/images/open-house-sysadminjpg +[3]:https://www.linuxfoundation.org/blog/2017-jobs-report-highlights-demand-open-source-skills/ +[4]:https://certification.comptia.org/certifications/linux?tracking=getCertified/certifications/linux.aspx +[5]:https://www.redhat.com/en/services/certification/rhce +[6]:https://www.redhat.com/en/services/certification/rhcsa +[7]:http://marketing.dice.com/pdf/Dice_TechSalarySurvey_2017.pdf?aliId=105832232 +[8]:https://opensource.com/article/17/7/truth-about-sysadmins +[9]:https://www.roberthalf.com/salary-guide/technology +[10]:https://www.linux.com/learn/10-essential-skills-novice-junior-and-senior-sysadmins%20%20 +[11]:http://bit.ly/2017OSSjobsreport From add78733cecbb411156c8eb13c6118587932ac41 Mon Sep 17 00:00:00 2001 From: Ezio Date: Wed, 29 Nov 2017 15:56:31 +0800 Subject: [PATCH 019/344] =?UTF-8?q?20171129-3=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...71124 An introduction to the Django ORM.md | 196 ++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 sources/tech/20171124 An introduction to the Django ORM.md diff --git a/sources/tech/20171124 An introduction to the Django ORM.md b/sources/tech/20171124 An introduction to the Django ORM.md new file mode 100644 index 0000000000..727df3f7b0 --- /dev/null +++ b/sources/tech/20171124 An introduction to the Django ORM.md @@ -0,0 +1,196 @@ +An introduction to the Django ORM +============================================================ + +### Learn how to use the Python web framework's object-relational mapper to interact with your database, just like you would with SQL. + + +![Getting to know the Django ORM](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web-spider-frame-framework.png?itok=Rl2AG2Dc "Getting to know the Django ORM") +Image by : [Christian Holmér][10]. Modified by Opensource.com. [CC BY-SA 4.0][11] + +You might have heard of [Django][12], the Python web framework for "perfectionists with deadlines." It's that one with the [cute pony][13]. + +One of the most powerful features of Django is its Object-Relational Mapper (ORM), which enables you to interact with your database, like you would with SQL. In fact, Django's ORM is just a pythonical way to create SQL to query and manipulate your database and get results in a pythonic fashion. Well, I say  _just_  a way, but it's actually really clever engineering that takes advantage of some of the more complex parts of Python to make developers' lives easier. + +Before we start looking into how the ORM works, we need a database to manipulate. As with any relational database, we need to define a bunch of tables and their relationships (i.e., the way they relate to each other). Let's use something familiar. For example, say we want to model a blog that has blog posts and authors. An author has a name. An author can have many blog posts. A blog post can have many authors and has a title, content, and a published date. + +In Django-ville, this concept of posts and authors could be called our Blog app. In this context, an app is a self-contained set of models and views that describes the behavior and functionality of our blog. Packaged in the right way, many Django projects could use our Blog app. In our project, the Blog could just be one app. We might also have a Forum app, for example. But we'll stick with the original scope of our Blog app. + +Here's a `models.py` prepared for this tutorial: + +``` +from django.db import models + +class Author(models.Model): +    name = models.CharField(max_length=100) + +    def __str__(self): +        return self.name + +class Post(models.Model): +    title = models.CharField(max_length=100) +    content = models.TextField() +    published_date = models.DateTimeField(blank=True, null=True) +    author = models.ManyToManyField(Author, related_name="posts") + +    def __str__(self): +        return self.title +``` + +More Python Resources + +* [What is Python?][1] + +* [Top Python IDEs][2] + +* [Top Python GUI frameworks][3] + +* [Latest Python content][4] + +* [More developer resources][5] + +Now this might look a bit daunting, so let's break it down. We have two models: Author and Post. Each has a name or title. The post has a big text field for content and a `DateTimeField` for the publication date and time. Post also has a `ManyToManyField`, which links posts and authors together. + +Most tutorials start from scratch—but that's not what's going to happen in practice. In reality, you're going to be given a bunch of existing code like the `model.py` above, and you have to work out what it all means. + +So it's now your task to go into the application and take a look around. There are a few ways to do this. You could log in to [Django admin][14], a web-based backend that has all the apps listed and the ways to manipulate them. We'll get back to that; here we're interested in the ORM. + +We can access the ORM by running `python manage.py shell` from the main directory of our Django project. + +``` +/srv/web/django/ $ python manage.py shell + +Python 3.6.3 (default, Nov  9 2017, 15:58:30) +[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.38)] on darwin +Type "help", "copyright", "credits" or "license" for more information. +(InteractiveConsole) +>>> +``` + +This will bring us into an interactive console. The [`shell` command][15] did a lot of setup for us, including importing our settings and configuring the Django environment. While we've launched the shell, we can't access our Blog model until we import it. + +``` +>>> from blog.models import * +``` + +This imports all the blog models so we can play with our blog posts and authors. + +For starters, let's get a list of all the authors. + +``` +>>> Author.objects.all() +``` + +What we'll get from this command is a `QuerySet` of results, which lists all our Author objects. We also won't fill our entire console, because if there are a lot of results, Django will automatically truncate the printed results. + +``` +>>> Author.objects.all() +, + , '...(remaining elements truncated)...'] +``` + +We can select a single author using `get` instead of `all`. But we need a bit more information to `get` a single record. In relational databases, tables have a primary key field that has a unique identifier for each and every record in a table; however, author names are not unique. Many people [share the same name][16], so it's not a good unique constraint. A way to get around this is to have a sequence (1, 2, 3...) or a universal unique identifier (UUID) as the primary key. But since these aren't nicely useable by humans, we can manipulate our Author objects by using `name`. + +``` +>>> Author.objects.get(name="VM (Vicky) Brasseur") + +``` + +This time, we have a single object that we can interact with, instead of a `QuerySet` list. We can interact with this object pythonically, using any of the table columns as attributes to look at the object. + +``` +>>> vmb = Author.objects.get(name="VM (Vicky) Brasseur") +>>> vmb.name +u'VM (Vicky) Brasseur' +``` + +And this is where the cool stuff happens. Normally in relational databases, if we want to show information for other tables, we'd need to write a `LEFT JOIN`, or other table-coupling functions, making sure that our foreign keys match up between tables. Django takes care of that for us. + +In our model, authors write many posts, so our Author object can check what posts the author has made. + +``` +>>> vmb.posts.all() +QuerySet[, + , + , + '...(remaining elements truncated)...'] +``` + +We can manipulate `QuerySets` using normal pythonic list manipulations. + +``` +>>> for post in vmb.posts.all(): +...   print(post.title) +... +7 tips for nailing your job interview +5 tips for getting the biggest bang for your cover letter buck +Quit making these 10 common resume mistakes +``` + +To do more complex querying, we can use filters instead of getting everything. Here is where it gets tricky. In SQL, you have options such as `like`, `contains`, and other filtering objects. You can do all these things in the ORM, too, but it has a special way of doing them: by using implicitly (rather than explicitly) defined functions. + +If I call a function `do_thing()` in my Python script, I'd expect somewhere there would be a matching `def do_thing`. This is an explicit functional definition. However, in the ORM, you can call a function that  _isn't explicitly defined_ . Before, we were using `name` to match on a name. But, if we wanted to do a substring search, we can use `name__contains`. + +``` +>>> Author.objects.filter(name__contains="Vic") +QuerySet[] +``` + +Now, a small note about the double underscore (`__`). These are  _very_  Python. You may have seen `__main__` or `__repr__` in your travels in Pythonland. These are sometimes referred to as `dunder methods`, a shortening of "double underscore." There are only a few non-alphanumeric characters that can be used in object names in Python; underscore is one of them. These are used in the ORM as an explicit separator of different parts of the filter key name. Under the hood, the string is split by these underscores, and the tokens are processed separately. `name__contains` gets changed into `attribute: name, filter: contains`. In other programming languages, you may use arrows instead, such as `name->contains` in PHP. Don't let dunders scare you, they're just pythonic helpers! (And if you squint, you could say they look like little snakes, little pythons that want to help you with your code.) + +The ORM is extremely powerful and very pythonic. But what about that Django admin site I mentioned above? + +### [django-admin.png][6] + +![Django Admin](https://opensource.com/sites/default/files/u128651/django-admin.png "Django Admin") + +One of the brilliant user-accessibility features of Django is its admin interface. If you define your models, you get a nice web-based editing portal, for free. + +And what powers this? The ORM. + +### [django-admin-author.png][7] + +![Authors list in Django Admin](https://opensource.com/sites/default/files/u128651/django-admin-author.png "Authors list in Django Admin") + +That's right! Given the code used to create the original models, Django turned that into a web-based portal, which is powered using the same raw functions we used earlier. By default, the admin is basic, but it's just a matter of adding more definitions in your model to change how the admin looks. For example, those `__str__` methods from earlier? We use those to define what an Author object looks like (in this case, just the name of the author). With a bit of work, you can make an interface that feels like a full content management system that allows your users to edit their own content with ease (for example, adding fields and filters for marking a post "published"). + +If you'd like to know more, the [Django Girls tutorial][17] section about [the ORM][18] has a detailed walkthrough. There's also copious documentation on the [Django project website][19]. + +-------------------------------------------------------------------------------- + +作者简介: + +Katie McLaughlin - Katie has worn many different hats over the years. She has previously been a software developer for many languages, systems administrator for multiple operating systems, and speaker on many different topics. When she's not changing the world, she enjoys making cooking, tapestries, and seeing just how well various application stacks handle emoji. + +------------------------ + +via: https://opensource.com/article/17/11/django-orm + +作者:[Katie McLaughlin Feed ][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/glasnt +[1]:https://opensource.com/resources/python?intcmp=7016000000127cYAAQ +[2]:https://opensource.com/resources/python/ides?intcmp=7016000000127cYAAQ +[3]:https://opensource.com/resources/python/gui-frameworks?intcmp=7016000000127cYAAQ +[4]:https://opensource.com/tags/python?intcmp=7016000000127cYAAQ +[5]:https://developers.redhat.com/?intcmp=7016000000127cYAAQ +[6]:https://opensource.com/file/377811 +[7]:https://opensource.com/file/377816 +[8]:https://opensource.com/article/17/11/django-orm?rate=iwO0q67yiUUPweMIMoyLbbYyhK5RTOOzEtyiNkJ0eBE +[9]:https://opensource.com/user/41661/feed +[10]:https://www.flickr.com/people/crsan/ +[11]:https://creativecommons.org/licenses/by-sa/4.0/ +[12]:https://www.djangoproject.com/ +[13]:http://www.djangopony.com/ +[14]:https://docs.djangoproject.com/en/1.11/ref/contrib/admin/ +[15]:https://docs.djangoproject.com/en/1.11/ref/django-admin/#shell +[16]:https://2016.katieconf.xyz/ +[17]:https://djangogirls.org/ +[18]:https://tutorial.djangogirls.org/en/django_orm/ +[19]:https://docs.djangoproject.com/en/1.11/topics/db/ +[20]:https://opensource.com/users/glasnt +[21]:https://opensource.com/users/glasnt +[22]:https://opensource.com/article/17/11/django-orm#comments From fa299e0b50b31eba6df09a0ab22a07a11057ef60 Mon Sep 17 00:00:00 2001 From: Ezio Date: Wed, 29 Nov 2017 15:58:41 +0800 Subject: [PATCH 020/344] =?UTF-8?q?20171129-4=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...layer introduction part 1 the bio layer.md | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 sources/tech/20171029 A block layer introduction part 1 the bio layer.md diff --git a/sources/tech/20171029 A block layer introduction part 1 the bio layer.md b/sources/tech/20171029 A block layer introduction part 1 the bio layer.md new file mode 100644 index 0000000000..b01269ff63 --- /dev/null +++ b/sources/tech/20171029 A block layer introduction part 1 the bio layer.md @@ -0,0 +1,37 @@ +A block layer introduction part 1: the bio layer +============================================================ + +### A block layer introduction part 1: the bio layer + +In reply to: [A block layer introduction part 1: the bio layer][1] by amarao +Parent article: [A block layer introduction part 1: the bio layer][2]Hi, +the problem you describe here is not directly related to the block layer. It is probably a driver bug, possible a SCSI-layer bug, but definitely not a block-layer problem. +Reporting bugs against Linux is, unfortunately, a bit of a hit-and-miss affair. Some developers refused to touch bugzilla, some love it, and some (like me) only use it begrudgingly. +The alternative is to send email. For that you need to choose the right list and maybe the right developer, and you need to catch them when they are in a good mood or aren't too busy or not on holidays. Some people will make an effort to respond to everything, others are completely unpredictable - and that is for me who usually sends a patch with any bug report. If you just have a bug that you barely understand yourself, your expected response rate is probably lower. Sad, but true. + +Lots of bugs do get responded to and dealt with, but lots do not. + +I don't think it is fair to say that nobody cares, but it probably is true that nobody sees it as being as important as you do. If you want a solution, then you need to drive it. One way to drive it is to spend money on a consultant or with a support contract from a distributor. I suspect that isn't possible in your situation. Another way is to learn how the code works and find a solution yourself. Lots of people do that, but again it might not be an option for you. Another way is to keep raising the issue on different relevant forums until you get a response. Persistence can bear fruit. You would need to be prepared to perform whatever testing is asked of you, possibly including building a new kernel to test. + +If you are able to reproduce this problem on a recent kernel (4.12 or later) I suggest that you email a report to +linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, and me (neilb@suse.com) (note that you do not need to subscribe to these lists to send mail, just send it). Describe the hardware and how to trigger the problem. +Include the stack trace of any process in "D" state. You can get this with +cat /proc/$PID/stack +where "$PID" is the pid of the process. + +Be sure to avoid complaining or saying how this has been broken for years and how it is grossly inadequate. Nobody cares about that. We do care about bugs and generally want to fix them. So just report the relevant facts. +Try to include all facts in the mail rather than via links to somewhere else. Sometimes links are necessary, but in the case of your script, it is 8 lines long so just include it in the email (and avoid descriptions like "fuckup"; just call it "broken" or similar). Also make sure your email isn't sent as HTML. We like just plain text. HTML is rejected by all @vger.kernel.org mailing lists. You might need to configure your email program to not send HTML. + +-------------------------------------------------------------------------------- + +via: https://lwn.net/Articles/737655/ + +作者:[ neilbrown][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://lwn.net/Articles/737655/ +[1]:https://lwn.net/Articles/737588/ +[2]:https://lwn.net/Articles/736534/ From 93cd509799a98651e57c93becc74be65b8636f61 Mon Sep 17 00:00:00 2001 From: Ezio Date: Wed, 29 Nov 2017 16:01:36 +0800 Subject: [PATCH 021/344] =?UTF-8?q?20171129-5=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...20 Containers and Kubernetes Whats next.md | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 sources/tech/20171120 Containers and Kubernetes Whats next.md diff --git a/sources/tech/20171120 Containers and Kubernetes Whats next.md b/sources/tech/20171120 Containers and Kubernetes Whats next.md new file mode 100644 index 0000000000..52f3364d31 --- /dev/null +++ b/sources/tech/20171120 Containers and Kubernetes Whats next.md @@ -0,0 +1,97 @@ +Containers and Kubernetes: What's next? +============================================================ + +### What's ahead for container orchestration and Kubernetes? Here's an expert peek + +![CIO_Big Data Decisions_2](https://enterprisersproject.com/sites/default/files/styles/620x350/public/images/CIO_Big%20Data%20Decisions_2.png?itok=Y5zMHxf8 "CIO_Big Data Decisions_2") + +If you want a basic idea of where containers are headed in the near future, follow the money. There’s a lot of it: 451 Research projects that the overall market for containers will hit roughly [$2.7 billion in 2020][4], a 3.5-fold increase from the $762 million spent on container-related technology in 2016. + +There’s an obvious fundamental factor behind such big numbers: Rapidly increasing containerization. The parallel trend: As container adoption grows, so will container  _orchestration_  adoption. + +As recent survey data from  [_The New Stack_][5]  indicates, container adoption is the most significant catalyst of orchestration adoption: 60 percent of respondents who’ve deployed containers broadly in production report they’re also using Kubernetes widely in production. Another 19 percent of respondents with broad container deployments in production were in the initial stages of broad Kubernetes adoption. Meanwhile, just 5 percent of those in the initial phases of deploying containers in production environments were using Kubernetes broadly – but 58 percent said they were preparing to do so. It’s a chicken-and-egg relationship. + + +Most experts agree that an orchestration tool is essential to the scalable [long-term management of containers][6] – and corresponding developments in the marketplace. “The next trends in container orchestration are all focused on broadening adoption,” says Alex Robinson, software engineer at [Cockroach Labs][7]. + +This is a quickly shifting landscape, one that is just starting to realize its future potential. So we checked in with Robinson and other practitioners to get their boots-on-the-ground perspective on what’s next in container orchestration – and for Kubernetes itself. + +### **Container orchestration shifts to mainstream** + +We’re at the precipice common to most major technology shifts, where we transition from the careful steps of early adoption to cliff-diving into commonplace use. That will create new demand for the plain-vanilla requirements that make mainstream adoption easier, especially in large enterprises. + +“The gold rush phase of early innovation has slowed down and given way to a much stronger focus on stability and usability,” Robinson says. “This means we'll see fewer major announcements of new orchestration systems, and more security options, management tools, and features that make it easier to take advantage of the flexibility already inherent in the major orchestration systems.” + +### **Reduced complexity** + +On a related front, expect an intensifying effort to cut back on the complexity that some organizations face when taking their first plunge into container orchestration. As we’ve covered before, deploying a container might be “easy,” but [managing containers long-term ][8]requires more care. + +“Today, container orchestration is too complex for many users to take full advantage,” says My Karlsson, developer at [Codemill AB][9]. “New users are often struggling just to get single or small-size container configurations running in isolation, especially when applications are not originally designed for it. There are plenty of opportunities to simplify the orchestration of non-trivial applications and make the technology more accessible.” + +### **Increasing focus on hybrid cloud and multi-cloud** + +As adoption of containers and container orchestration grows, more organizations will scale from a starting point of, say, running non-critical workloads in a single environment to more [complex use cases][10] across multiple environments. For many companies, that will mean managing containerized applications (and particularly containerized microservices) across [hybrid cloud][11] and [multi-cloud][12] environments, often globally. + +"Containers and Kubernetes have made hybrid cloud and application portability a reality,” says [Brian Gracely][13], director of [Red Hat][14] OpenShift product strategy. “Combined with the Open Service Broker, we expect to see an explosion of new applications that combine private and public cloud resources." + +“I believe that federation will get a push, enabling much-wanted features such as seamless multi-region and multi-cloud deployments,” says Carlos Sanchez, senior software engineer at [CloudBees][15].  + +**[ Want CIO wisdom on hybrid cloud and multi-cloud strategy? See our related resource, **[**Hybrid Cloud: The IT leader's guide**][16]**. ]** + +### **Continued consolidation of platforms and tools** + +Technology consolidation is common trend; container orchestration is no exception. + +“As containerization goes mainstream, engineers are consolidating on a very small number of technologies to run their [microservices and] containers and Kubernetes will become the dominant container orchestration platform, far outstripping other platforms,” says Ben Newton, analytics lead at [Sumo Logic][17]. “Companies will adopt Kubernetes to drive a cloud-neutral approach as Kubernetes provides a reasonably clear path to reduce dependence on [specific] cloud ecosystems.**”** + +### **Speaking of Kubernetes, what’s next?** + +"Kubernetes is here for the long haul, and the community driving it is doing great job – but there's lots ahead,” says Gadi Naor, CTO and co-founder of [Alcide][18]. Our experts shared several predictions specific to [the increasingly popular Kubernetes platform][19]:  + + **_Gadi Naor at Alcide:_**  “Operators will continue to evolve and mature, to a point where applications running on Kubernetes will become fully self-managed. Deploying and monitoring microservices on top of Kubernetes with [OpenTracing][20] and service mesh frameworks such as [istio][21] will help shape new possibilities.” + + **_Brian Gracely at Red Hat:_**  “Kubernetes continues to expand in terms of the types of applications it can support. When you can run traditional applications, cloud-native applications, big data applications, and HPC or GPU-centric applications on the same platform, it unlocks a ton of architectural flexibility.” + + **_Ben Newton at Sumo Logic: _ “**As Kubernetes becomes more dominant, I would expect to see more normalization of the operational mechanisms – particularly integrations into third-party management and monitoring platforms.” + + **_Carlos Sanchez at CloudBees: _** “In the immediate future there is the ability to run without Docker, using other runtimes...to remove any lock-in. [Editor’s note: [CRI-O][22], for example, offers this ability.] “Also, [look for] storage improvements to support enterprise features like data snapshotting and online volume resizing.” + + + **_Alex Robinson at Cockroach Labs: _ “**One of the bigger developments happening in the Kubernetes community right now is the increased focus on managing [stateful applications][23]. Managing state in Kubernetes right now is very difficult if you aren't running in a cloud that offers remote persistent disks, but there's work being done on multiple fronts [both inside Kubernetes and by external vendors] to improve this.” + +-------------------------------------------------------------------------------- + +via: https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next + +作者:[Kevin Casey ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://enterprisersproject.com/user/kevin-casey +[1]:https://enterprisersproject.com/article/2017/11/kubernetes-numbers-10-compelling-stats +[2]:https://enterprisersproject.com/article/2017/11/how-enterprise-it-uses-kubernetes-tame-container-complexity +[3]:https://enterprisersproject.com/article/2017/11/5-kubernetes-success-tips-start-smart?sc_cid=70160000000h0aXAAQ +[4]:https://451research.com/images/Marketing/press_releases/Application-container-market-will-reach-2-7bn-in-2020_final_graphic.pdf +[5]:https://thenewstack.io/ +[6]:https://enterprisersproject.com/article/2017/10/microservices-and-containers-6-management-tips-long-haul +[7]:https://www.cockroachlabs.com/ +[8]:https://enterprisersproject.com/article/2017/10/microservices-and-containers-6-management-tips-long-haul +[9]:https://codemill.se/ +[10]:https://www.redhat.com/en/challenges/integration?intcmp=701f2000000tjyaAAA +[11]:https://enterprisersproject.com/hybrid-cloud +[12]:https://enterprisersproject.com/article/2017/7/multi-cloud-vs-hybrid-cloud-whats-difference +[13]:https://enterprisersproject.com/user/brian-gracely +[14]:https://www.redhat.com/en +[15]:https://www.cloudbees.com/ +[16]:https://enterprisersproject.com/hybrid-cloud?sc_cid=70160000000h0aXAAQ +[17]:https://www.sumologic.com/ +[18]:http://alcide.io/ +[19]:https://enterprisersproject.com/article/2017/10/how-explain-kubernetes-plain-english +[20]:http://opentracing.io/ +[21]:https://istio.io/ +[22]:http://cri-o.io/ +[23]:https://opensource.com/article/17/2/stateful-applications +[24]:https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next?rate=PBQHhF4zPRHcq2KybE1bQgMkS2bzmNzcW2RXSVItmw8 +[25]:https://enterprisersproject.com/user/kevin-casey From 213c281d59eae115d94dce92fd465804cf6e7239 Mon Sep 17 00:00:00 2001 From: Ezio Date: Wed, 29 Nov 2017 16:04:24 +0800 Subject: [PATCH 022/344] =?UTF-8?q?20171129-6=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...lder and Other Image Loading Techniques.md | 239 ++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 sources/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md diff --git a/sources/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md b/sources/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md new file mode 100644 index 0000000000..964eca9356 --- /dev/null +++ b/sources/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md @@ -0,0 +1,239 @@ +How to use SVG as a Placeholder, and Other Image Loading Techniques +============================================================ + +![](https://cdn-images-1.medium.com/max/1563/0*zJGl1vKLttcJGIL4.jpg) +Generating SVGs from images can be used for placeholders. Keep reading! + +I’m passionate about image performance optimisation and making images load fast on the web. One of the most interesting areas of exploration is placeholders: what to show when the image hasn’t loaded yet. + +During the last days I have come across some loading techniques that use SVG, and I would like to describe them in this post. + +In this post we will go through these topics: + +* Overview of different types of placeholders + +* SVG-based placeholders (edges, shapes and silhouettes) + +* Automating the process. + +### Overview of different types of placeholders + +In the past [I have written about placeholders and lazy-load of images][28], and also [talked about it][29]. When doing lazy-loading of images it’s a good idea to think about what to render as a placeholder, since it can have a big impact in user’s perceived performance. In the past I described several options: + + +![](https://cdn-images-1.medium.com/max/1563/0*jlMM144vAhH-0bEn.png) + +Several strategies to fill the area of an image before it loads. + +* Keeping the space empty for the image: In a world of responsive design, this prevents content from jumping around. Those layout changes are bad from a user’s experience point of view, but also for performance. The browser is forced to do layout re calculations every time it fetches the dimensions of an image, leaving space for it. + +* Placeholder: Imagine that we are displaying a user’s profile image. We might want to display a silhouette in the background. This is shown while the main image is loaded, but also when that request failed or when the user didn’t set any profile picture at all. These images are usually vector-based, and due to their small size are a good candidate to be inlined. + +* Solid colour: Take a colour from the image and use it as the background colour for the placeholder. This can be the dominant colour, the most vibrant… The idea is that it is based on the image you are loading and should help making the transition between no image to image loaded smoother. + +* Blurry image: Also called blur-up technique. You render a tiny version of the image and then transition to the full one. The initial image is tiny both in pixels and kBs. To remove artifacts the image is scaled up and blurred. I have written previously about this on [How Medium does progressive image loading][1], [Using WebP to create tiny preview images][2], and [More examples of Progressive Image Loading][3] . + +Turns out there are many other variations and lots of smart people are developing other techniques to create placeholders. + +One of them is having gradients instead of solid colours. The gradients can create a more accurate preview of the final image, with very little overhead (increase in payload). + + +![](https://cdn-images-1.medium.com/max/1250/0*ecPkBAl69ayvRctn.jpg) +Using gradients as backgrounds. Screenshot from Gradify, which is not online anymore. Code [on GitHub][4]. + +Another technique is using SVGs based on the image, which is getting some traction with recent experiments and hacks. + +### SVG-based placeholders + +We know SVGs are ideal for vector images. In most cases we want to load a bitmap one, so the question is how to vectorise an image. Some options are using edges, shapes and areas. + +#### Edges + +In [a previous post][30] I explained how to find out the edges of an image and create an animation. My initial goal was to try to draw regions, vectorising the image, but I didn’t know how to do it. I realised that using the edges could also be innovative and I decided to animate them creating a “drawing” effect. + +[Drawing images using edge detection and SVG animation +Back in the days SVG was barely used and supported. Some time after we started using them as an alternative to classic…medium.com][31][][32] + +#### Shapes + +SVG can also be used to draw areas from the image instead of edges/borders. In a way, we would vectorise a bitmap image to create a placeholder. + +Back in the days I tried to do something similar with triangles. You can see the result in my talks [at CSSConf][33] and [Render Conf][34]. + + +The codepen above is a proof of concept of a SVG-based placeholder composed of 245 triangles. The generation of the triangles is based on [Delaunay triangulation][35] using [Possan’s polyserver][36]. As expected, the more triangles the SVG uses, the bigger the file size. + +#### Primitive and SQIP, a SVG-based LQIP technique + +Tobias Baldauf has been working on another Low-Quality Image Placeholder technique using SVGs called [SQIP][37]. Before digging into SQIP itself I will give an overview of [Primitive][38], a library on which SQIP is based. + +Primitive is quite fascinating and I definitely recommend you to check it out. It converts a bitmap image into a SVG composed of overlapping shapes. Its small size makes it suitable for inlining it straight into the page. One less roundtrip, and a meaningful placeholder within the initial HTML payload. + +Primitive generates an image based on shapes like triangles, rectangles and circles (and a few others). In every step it adds a new one. The more steps, the resulting image looks closer to the original one. If your output is SVG it also means the size of the output code will be larger. + +In order to understand how Primitive works, I ran it through a couple of images. I generated SVGs for the artwork using 10 shapes and 100 shapes: + + ** 此处有Canvas,请手动处理 ** + +![](https://cdn-images-1.medium.com/max/625/1*y4sr9twkh_WyZh6h0yH98Q.png) + + +![](https://cdn-images-1.medium.com/max/625/1*cqyhYnx83LYvhGdmg2dFDw.png) + +![](https://cdn-images-1.medium.com/max/625/1*qQP5160gPKQdysh0gFnNfw.jpeg) +Processing [this picture][5] using Primitive, using [10 shapes][6] and [100 shapes][7]. + + +![](https://cdn-images-1.medium.com/max/625/1*PWZLlC4lrLO4CVv1GwR7qA.png) + + + +![](https://cdn-images-1.medium.com/max/625/1*khnga22ldJKOZ2z45Srh8A.png) + + +![](https://cdn-images-1.medium.com/max/625/1*N-20rR7YGFXiDSqIeIyOjA.jpeg) +Processing [this picture][8] using Primitive, using [10 shapes][9] and [100 shapes][10]. + +When using 10 shapes the images we start getting a grasp of the original image. In the context of image placeholders there is potential to use this SVG as the placeholder. Actually, the code for the SVG with 10 shapes is really small, around 1030 bytes, which goes down to ~640 bytes when passing the output through SVGO. + +``` + +``` + +The images generated with 100 shapes are larger, as expected, weighting ~5kB after SVGO (8kB before). They have a great level of detail with a still small payload. The decision of how many triangles to use will depend largely on the type of image (eg contrast, amount of colours, complexity) and level of detail. + +It would be possible to create a script similar to [cpeg-dssim][39] that tweaks the amount of shapes used until a [structural similarity][40] threshold is met (or a maximum number of shapes in the worst case). + +These resulting SVGs are great also to use as background images. Being size-constrained and vector-based they are a good candidate for hero images and large backgrounds that otherwise would show artifacts. + +#### SQIP + +In [Tobias’ own words][41]: + +> SQIP is an attempt to find a balance between these two extremes: it makes use of [Primitive][42] to generate a SVG consisting of several simple shapes that approximate the main features visible inside the image, optimizes the SVG using [SVGO][43] and adds a Gaussian Blur filter to it. This produces a SVG placeholder which weighs in at only ~800–1000 bytes, looks smooth on all screens and provides an visual cue of image contents to come. + +The result is similar to using a tiny placeholder image for the blur-up technique (what [Medium][44] and [other sites][45] do). The difference is that instead of using a bitmap image, eg JPG or WebP, the placeholder is SVG. + +If we run SQIP against the original images we’ll get this: + + +![](https://cdn-images-1.medium.com/max/938/0*yUY1ZFP27vFYgj_o.png) + + + +![](https://cdn-images-1.medium.com/max/938/0*DKoZP7DXFvUZJ34E.png) +The output images using SQIP for [the first picture][11] and [the second one][12]. + +The output SVG is ~900 bytes, and inspecting the code we can spot the `feGaussianBlur` filter applied to the group of shapes: + +``` + +``` + +SQIP can also output an image tag with the SVG contents Base 64 encoded: + +``` + +``` + +#### Silhouettes + +We just had a look at using SVGs for edges and primitive shapes. Another possibility is to vectorise the images “tracing” them. [Mikael Ainalem][47] shared [a codepen][48] a few days ago showing how to use a 2-colour silhouette as a placeholder. The result is really pretty: + + +![](https://cdn-images-1.medium.com/max/1250/1*r6HbVnBkISCQp_UVKjOJKQ.gif) + +The SVGs in this case were hand drawn, but the technique quickly spawned integrations with tools to automate the process. + +* [Gatsby][13], a static site generator using React supports these traced SVGs now. It uses [a JS PORT of potrace][14] to vectorise the images. + +* [Craft 3 CMS][15], which also added support for silhouettes. It uses [a PHP port of potrace][16]. + + +* [image-trace-loader][17], a Webpack loader that uses potrace to process the images. + + +It’s also interesting to see a comparison of the output between Emil’s webpack loader (based on potrace) and Mikael’s hand-drawn SVGs. + + +I assume the output generated by potrace is using the default options. However, it’s possible to tweak them. Check [the options for image-trace-loader][49], which are pretty much [the ones passed down to potrace][50]. + +### Summary + +We have seen different tools and techniques to generate SVGs from images and use them as placeholders. The same way [WebP is a fantastic format for thumbnails][51], SVG is also an interesting format to use in placeholders. We can control the level of detail (and thus, size), it’s highly compressible and easy to manipulate with CSS and JS. + +#### Extra Resources + +This post made it to [the top of Hacker News][52]. I’m very grateful for that, and for all the links to other resources that have been shared in the comments on that page. Here are a few of them! + +* [Geometrize][18] is a port of Primitive written in Haxe. There is also [a JS implementation][19] that you can try out directly [on your browser][20]. + +* [Primitive.js][21], which is a port of Primitive in JS. Also, [primitive.nextgen][22], which is a port of the Primitive desktop app using Primitive.js and Electron. + +* There are a couple of Twitter accounts where you can see examples of images generated with Primitive and Geometrize. Check out [@PrimitivePic][23] and [@Geometrizer][24]. + +* [imagetracerjs][25], which is a raster image tracer and vectorizer written in JavaScript. There are also ports for [Java][26] and [Android][27]. + +-------------------------------------------------------------------------------- + +via: https://medium.freecodecamp.org/using-svg-as-placeholders-more-image-loading-techniques-bed1b810ab2c + +作者:[ José M. Pérez][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://medium.freecodecamp.org/@jmperezperez?source=post_header_lockup +[1]:https://medium.com/@jmperezperez/how-medium-does-progressive-image-loading-fd1e4dc1ee3d +[2]:https://medium.com/@jmperezperez/using-webp-to-create-tiny-preview-images-3e9b924f28d6 +[3]:https://medium.com/@jmperezperez/more-examples-of-progressive-image-loading-f258be9f440b +[4]:https://github.com/fraser-hemp/gradify +[5]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-281184-square.jpg +[6]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-281184-square-10.svg +[7]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-281184-square-100.svg +[8]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-618463-square.jpg +[9]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-618463-square-10.svg +[10]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-618463-square-100.svg +[11]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-281184-square-sqip.svg +[12]:https://jmperezperez.com/svg-placeholders/%28/assets/images/posts/svg-placeholders/pexels-photo-618463-square-sqip.svg +[13]:https://www.gatsbyjs.org/ +[14]:https://www.npmjs.com/package/potrace +[15]:https://craftcms.com/ +[16]:https://github.com/nystudio107/craft3-imageoptimize/blob/master/src/lib/Potracio.php +[17]:https://github.com/EmilTholin/image-trace-loader +[18]:https://github.com/Tw1ddle/geometrize-haxe +[19]:https://github.com/Tw1ddle/geometrize-haxe-web +[20]:http://www.samcodes.co.uk/project/geometrize-haxe-web/ +[21]:https://github.com/ondras/primitive.js +[22]:https://github.com/cielito-lindo-productions/primitive.nextgen +[23]:https://twitter.com/PrimitivePic +[24]:https://twitter.com/Geometrizer +[25]:https://github.com/jankovicsandras/imagetracerjs +[26]:https://github.com/jankovicsandras/imagetracerjava +[27]:https://github.com/jankovicsandras/imagetracerandroid +[28]:https://medium.com/@jmperezperez/lazy-loading-images-on-the-web-to-improve-loading-time-and-saving-bandwidth-ec988b710290 +[29]:https://www.youtube.com/watch?v=szmVNOnkwoU +[30]:https://medium.com/@jmperezperez/drawing-images-using-edge-detection-and-svg-animation-16a1a3676d3 +[31]:https://medium.com/@jmperezperez/drawing-images-using-edge-detection-and-svg-animation-16a1a3676d3 +[32]:https://medium.com/@jmperezperez/drawing-images-using-edge-detection-and-svg-animation-16a1a3676d3 +[33]:https://jmperezperez.com/cssconfau16/#/45 +[34]:https://jmperezperez.com/renderconf17/#/46 +[35]:https://en.wikipedia.org/wiki/Delaunay_triangulation +[36]:https://github.com/possan/polyserver +[37]:https://github.com/technopagan/sqip +[38]:https://github.com/fogleman/primitive +[39]:https://github.com/technopagan/cjpeg-dssim +[40]:https://en.wikipedia.org/wiki/Structural_similarity +[41]:https://github.com/technopagan/sqip +[42]:https://github.com/fogleman/primitive +[43]:https://github.com/svg/svgo +[44]:https://medium.com/@jmperezperez/how-medium-does-progressive-image-loading-fd1e4dc1ee3d +[45]:https://medium.com/@jmperezperez/more-examples-of-progressive-image-loading-f258be9f440b +[46]:http://www.w3.org/2000/svg +[47]:https://twitter.com/mikaelainalem +[48]:https://codepen.io/ainalem/full/aLKxjm/ +[49]:https://github.com/EmilTholin/image-trace-loader#options +[50]:https://www.npmjs.com/package/potrace#parameters +[51]:https://medium.com/@jmperezperez/using-webp-to-create-tiny-preview-images-3e9b924f28d6 +[52]:https://news.ycombinator.com/item?id=15696596 From 4b02b899106fa4240a91fde19069df16d82ab206 Mon Sep 17 00:00:00 2001 From: Ezio Date: Wed, 29 Nov 2017 16:07:44 +0800 Subject: [PATCH 023/344] =?UTF-8?q?20171129-7=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Could Be Your New Favorite Container OS.md | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md diff --git a/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md new file mode 100644 index 0000000000..9b8a98a9dd --- /dev/null +++ b/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md @@ -0,0 +1,147 @@ +Photon Could Be Your New Favorite Container OS +============================================================ + + +![Photon OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon-linux.jpg?itok=jUFHPR_c "Photon OS") +Jack Wallen says Photon OS is an outstanding platform, geared specifically for containers.[Creative Commons Zero][5]Pixabay + +Containers are all the rage, and with good reason. [As discussed previously][13], containers allow you to quickly and easily deploy new services and applications onto your network, without requiring too much in the way of added system resources. Containers are more cost-effective than using dedicated hardware or virtual machines, and they’re easier to update and reuse. + +Best of all, containers love Linux (and vice versa). Without much trouble or time, you can get a Linux server up and running with [Docker][14] and deploying containers. But, which Linux distribution is best suited for the deployment of your containers? There are a _lot_  of options. You could go with a standard Ubuntu Server platform (which makes installing Docker and deploying containers incredibly easy), or you could opt for a lighter weight distribution — one geared specifically for the purpose of deploying containers. + +One such distribution is [Photon][15]. This particular platform was created in 2005 by [VMware][16]; it includes the Docker daemon and works with container frameworks, such as Mesos and Kubernetes. Photon is optimized to work with [VMware vSphere][17], but it can be used on bare metal, [Microsoft Azure][18], [Google Compute Engine][19], [Amazon Elastic Compute Cloud][20], or [VirtualBox][21]. + +Photon manages to stay slim by only installing what is absolutely necessary to run the Docker daemon. In the end, the distribution comes in around 300 MB. This is just enough Linux make it all work. The key features to Photon are: + +* Kernel tuned for performance. + +* Kernel is hardened according to the [Kernel Self-Protection Project][6] (KSPP). + +* All installed packages are built with hardened security flags. + +* Operating system boots with validated trust. + +* Photon management daemon manages firewall, network, packages, and users on remote Photon OS machines. + +* Support for persistent volumes. + +* [Project Lightwave][7] integration. + +* Timely security patches and updates. + +Photon can be used via [ISO][22], [OVA][23], [Amazon Machine Image][24], [Google Compute Engine image][25], and [Azure VHD][26]. I’ll show you how to install Photon on VirtualBox, using an ISO image. The installation takes about five minutes and, in the end, you’ll have a virtual machine, ready to deploy containers. + +### Creating the virtual machine + +Before you deploy that first container, you have to create the virtual machine and install Photon. To do this, open up VirtualBox and click the New button. Walk through the Create Virtual Machine wizard (giving Photon the necessary resources, based on the usage you predict the container server will need). Once you’ve created the virtual machine, you need to first make a change to the settings. Select the newly created virtual machine (in the left pane of the VirtualBox main window) and then click Settings. In the resulting window, click on Network (from the left navigation). + +In the Networking window (Figure 1), you need to change the Attached to drop-down to Bridged Adapter. This will ensure your Photon server is reachable from your network. Once you’ve made that change, click OK. + +### [photon_0.jpg][8] + +![change settings](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_0.jpg?itok=Q0yhOhsZ "change settings") +Figure 1: Changing the VirtualBox network settings for Photon.[Used with permission][1] + +Select your Photon virtual machine from the left navigation and then click Start. You will be prompted to locate and attach the IOS image. Once you’ve done that, Photon will boot up and prompt you to hit Enter to begin the installation. The installation is ncurses based (there is no GUI), but it’s incredibly simple. + +In the next screen (Figure 2), you will be asked if you want to do a Minimal, Full, or OSTree Server. I opted to go the Full route. Select whichever option you require and hit enter. + +### [photon_1.jpg][9] + +![installation type](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_1.jpg?itok=OdnMVpaA "installation type") +Figure 2: Selecting your installation type.[Used with permission][2] + +In the next window, select the disk that will house Photon. Since we’re installing this as a virtual machine, there will be only one disk listed (Figure 3). Tab down to Auto and hit Enter on your keyboard. The installation will then require you to type (and verify) an administrator password. Once you’ve done that, the installation will begin and finish in less than five minutes. + +### [photon_2.jpg][10] + +![Photon ](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_2.jpg?itok=QL1Rs-PH "Photon") +Figure 3: Selecting your hard disk for the Photon installation.[Used with permission][3] + +Once the installation completes, reboot the virtual machine and log in with the username root and the password you created during installation. You are ready to start working. + +Before you begin using Docker on Photon, you’ll want to upgrade the platform. Photon uses the _yum_ package manager, so login as root and issue the command  _yum update_ .If there are any updates available, you’ll be asked to okay the process (Figure 4). + +### [photon_3.jpg][11] + +![Updating](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_3.jpg?itok=vjqrspE2 "Updating") +Figure 4: Updating Photon.[Used with permission][4] + +Usage + +As I mentioned, Photon comes with everything you need to deploy containers or even create a Kubernetes cluster. However, out of the box, there are a few things you’ll need to do. The first thing is to enable the Docker daemon to run at start. To do this, issue the commands: + +``` +systemctl start docker + +systemctl enable docker +``` + +Now we need to create a standard user, so we’re not running the docker command as root. To do this, issue the following commands: + +``` +useradd -m USERNAME + +passwd USERNAME +``` + +Where USERNAME is the name of the user to add. + +Next we need to add the new user to the  _docker_ group with the command: + +``` +usermod -a -G docker USERNAME +``` + +Where USERNAME is the name of the user just created. + +Log out as the root user and log back in as the newly created user. You can now work with the  _docker _ command without having to make use of  _sudo_  or switching to the root user. Pull down an image from Docker Hub and start deploying containers. + +### An outstanding container platform + +Photon is, without a doubt, an outstanding platform, geared specifically for containers. Do note that Photon is an open source project, so there is no paid support to be had. If you find yourself having trouble with Photon, hop on over to the [Issues tab in the Photon Project’s Github page][27], where you can read and post about issues. And if you’re interested in forking Photon, you’ll find the source code on the project’s [official Github page][28]. + +Give Photon a try and see if it doesn’t make deploying Docker containers and/or Kubernetes clusters significantly easier. + + _Learn more about Linux through the free ["Introduction to Linux" ][29]course from The Linux Foundation and edX._ + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2017/11/photon-could-be-your-new-favorite-container-os + +作者:[JACK WALLEN ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/jlwallen +[1]:https://www.linux.com/licenses/category/used-permission +[2]:https://www.linux.com/licenses/category/used-permission +[3]:https://www.linux.com/licenses/category/used-permission +[4]:https://www.linux.com/licenses/category/used-permission +[5]:https://www.linux.com/licenses/category/creative-commons-zero +[6]:https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project +[7]:http://vmware.github.io/lightwave/ +[8]:https://www.linux.com/files/images/photon0jpg +[9]:https://www.linux.com/files/images/photon1jpg +[10]:https://www.linux.com/files/images/photon2jpg +[11]:https://www.linux.com/files/images/photon3jpg +[12]:https://www.linux.com/files/images/photon-linuxjpg +[13]:https://www.linux.com/learn/intro-to-linux/2017/11/how-install-and-use-docker-linux +[14]:https://www.docker.com/ +[15]:https://vmware.github.io/photon/ +[16]:https://www.vmware.com/ +[17]:https://www.vmware.com/products/vsphere.html +[18]:https://azure.microsoft.com/ +[19]:https://cloud.google.com/compute/ +[20]:https://aws.amazon.com/ec2/ +[21]:https://www.virtualbox.org/ +[22]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[23]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[24]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[25]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[26]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[27]:https://github.com/vmware/photon/issues +[28]:https://github.com/vmware/photon +[29]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From 732e994c3f5e03e607e5138cace15c3435ac6a3c Mon Sep 17 00:00:00 2001 From: Ezio Date: Wed, 29 Nov 2017 16:09:21 +0800 Subject: [PATCH 024/344] =?UTF-8?q?20171129-8=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Install Android File Transfer for Linux.md | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 sources/tech/20171124 How to Install Android File Transfer for Linux.md diff --git a/sources/tech/20171124 How to Install Android File Transfer for Linux.md b/sources/tech/20171124 How to Install Android File Transfer for Linux.md new file mode 100644 index 0000000000..b5078c2e01 --- /dev/null +++ b/sources/tech/20171124 How to Install Android File Transfer for Linux.md @@ -0,0 +1,79 @@ +# How to Install Android File Transfer for Linux + +If you’re struggling to mount your Android phone on Ubuntu you might want to give [Android File Transfer for Linux][4] a try. + +Effectively it’s a clone of Google’s [Android File Transfer][6] app for macOS. It’s built with Qt, and has a super simple UI that makes it easy to transfer files and folders to and from your Android smartphone and your Ubuntu machine. + +Now, chances are a few of you will be scratching your head wondering what this app does that Nautilus, the default file manager in Ubuntu, doesn’t — and the answer is nothing. + +When I connect my Nexus 5X (and remember to select the [MTP][7] option) to my Ubuntu machine I can browse, open and manage it using Nautilus, just like my phone was a regular USB drive thanks to [GVfs][8]: + + [![Nautilus MTP integration with a Nexus 5X](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg)][9] + +But  _some_  people experience issues with this, and other MTP implementations, such as directories not loading, directory creation that doesn’t “stick”, and issues using their device inside a media player. + +And it’s for those people whom Android File Transfer for Linux is designed. Consider it an alternative to other methods of mounting MTP devices on Linux. If what you use currently works a-ok, you probably don’t need to try this out (unless you really like trying things out). + +![Android File Transfer Linux App](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/android-file-transfer-for-linux-750x662.jpg) + +The app features: + +* A straightforward user interface + +* Drag and drop support (Linux to Phone) + +* Batch downloading (Phone to Linux) + +* Transfer progress dialogs + +* FUSE wrapper + +* No file size limits + +* Optional CLI tool + +### Install Android File Transfer on Ubuntu + +That’s enough waffle about this alternative way to mount your Android phone, on to the nitty gritty of installing it. + +Helpfully there’s a [PPA available][10] which provides builds for Ubuntu 14.04 LTS, 16.04 LTS and Ubuntu 17.10. + +To add the PPA to your list of software sources run this command: + +``` +sudo add-apt-repository ppa:samoilov-lex/aftl-stable +``` + +Then, to install Android File Transfer for Linux on Ubuntu, run: + +``` +sudo apt-get update && sudo apt install android-file-transfer +``` + +That’s pretty much it. + +You’ll find a launcher for the app in your app menu. + +Before launching it do make make sure that no other devices (such as Nautilus) mount your phone first. If anything is using it the app will report “no MTP device found”. To fix, unmount your device from Nautilus (or whichever app is using it) then relaunch Android File Transfer. + +-------------------------------------------------------------------------------- + +via: http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux + +作者:[ JOEY SNEDDON ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://plus.google.com/117485690627814051450/?rel=author +[1]:https://plus.google.com/117485690627814051450/?rel=author +[2]:http://www.omgubuntu.co.uk/category/app +[3]:http://www.omgubuntu.co.uk/category/download +[4]:https://github.com/whoozle/android-file-transfer-linux +[5]:http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux +[6]:http://android.com/filetransfer?linkid=14270770 +[7]:https://en.wikipedia.org/wiki/Media_Transfer_Protocol +[8]:https://en.wikipedia.org/wiki/GVfs +[9]:http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg +[10]:https://launchpad.net/~samoilov-lex/+archive/ubuntu/aftl-stable From 06f7c43697cd398809b82932b90223acee2b4cc3 Mon Sep 17 00:00:00 2001 From: Ezio Date: Wed, 29 Nov 2017 16:11:36 +0800 Subject: [PATCH 025/344] =?UTF-8?q?20171129-9=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20171124 How do groups work on Linux.md | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 sources/tech/20171124 How do groups work on Linux.md diff --git a/sources/tech/20171124 How do groups work on Linux.md b/sources/tech/20171124 How do groups work on Linux.md new file mode 100644 index 0000000000..bc1833b0d6 --- /dev/null +++ b/sources/tech/20171124 How do groups work on Linux.md @@ -0,0 +1,141 @@ +How do groups work on Linux? +============================================================ + +Hello! Last week, I thought I knew how users and groups worked on Linux. Here is what I thought: + +1. Every process belongs to a user (like `julia`) + +2. When a process tries to read a file owned by a group, Linux a) checks if the user `julia` can access the file, and b) checks which groups `julia` belongs to, and whether any of those groups owns & can access that file + +3. If either of those is true (or if the ‘any’ bits are set right) then the process can access the file + +So, for example, if a process is owned by the `julia` user and `julia` is in the `awesome` group, then the process would be allowed to read this file. + +``` +r--r--r-- 1 root awesome 6872 Sep 24 11:09 file.txt + +``` + +I had not thought carefully about this, but if pressed I would have said that it probably checks the `/etc/group` file at runtime to see what groups you’re in. + +### that is not how groups work + +I found out at work last week that, no, what I describe above is not how groups work. In particular Linux does **not** check which groups a process’s user belongs to every time that process tries to access a file. + +Here is how groups actually work! I learned this by reading Chapter 9 (“Process Credentials”) of [The Linux Programming Interface][1] which is an incredible book. As soon as I realized that I did not understand how users and groups worked, I opened up the table of contents with absolute confidence that it would tell me what’s up, and I was right. + +### how users and groups checks are done + +They key new insight for me was pretty simple! The chapter starts out by saying that user and group IDs are **attributes of the process**: + +* real user ID and group ID; + +* effective user ID and group ID; + +* saved set-user-ID and saved set-group-ID; + +* file-system user ID and group ID (Linux-specific); and + +* supplementary group IDs. + +This means that the way Linux **actually** does group checks to see a process can read a file is: + +* look at the process’s group IDs & supplementary group IDs (from the attributes on the process, **not** by looking them up in `/etc/group`) + +* look at the group on the file + +* see if they match + +Generally when doing access control checks it uses the **effective** user/group ID, not the real user/group ID. Technically when accessing a file it actually uses the **file-system** ids but those are usually the same as the effective uid/gid. + +### Adding a user to a group doesn’t put existing processes in that group + +Here’s another fun example that follows from this: if I create a new `panda` group and add myself (bork) to it, then run `groups` to check my group memberships – I’m not in the panda group! + +``` +bork@kiwi~> sudo addgroup panda +Adding group `panda' (GID 1001) ... +Done. +bork@kiwi~> sudo adduser bork panda +Adding user `bork' to group `panda' ... +Adding user bork to group panda +Done. +bork@kiwi~> groups +bork adm cdrom sudo dip plugdev lpadmin sambashare docker lxd + +``` + +no `panda` in that list! To double check, let’s try making a file owned by the `panda`group and see if I can access it: + +``` +$ touch panda-file.txt +$ sudo chown root:panda panda-file.txt +$ sudo chmod 660 panda-file.txt +$ cat panda-file.txt +cat: panda-file.txt: Permission denied + +``` + +Sure enough, I can’t access `panda-file.txt`. No big surprise there. My shell didn’t have the `panda` group as a supplementary GID before, and running `adduser bork panda` didn’t do anything to change that. + +### how do you get your groups in the first place? + +So this raises kind of a confusing question, right – if processes have groups baked into them, how do you get assigned your groups in the first place? Obviously you can’t assign yourself more groups (that would defeat the purpose of access control). + +It’s relatively clear how processes I **execute** from my shell (bash/fish) get their groups – my shell runs as me, and it has a bunch of group IDs on it. Processes I execute from my shell are forked from the shell so they get the same groups as the shell had. + +So there needs to be some “first” process that has your groups set on it, and all the other processes you set inherit their groups from that. That process is called your **login shell** and it’s run by the `login` program (`/bin/login`) on my laptop. `login` runs as root and calls a C function called `initgroups` to set up your groups (by reading `/etc/group`). It’s allowed to set up your groups because it runs as root. + +### let’s try logging in again! + +So! Let’s say I am running in a shell, and I want to refresh my groups! From what we’ve learned about how groups are initialized, I should be able to run `login` to refresh my groups and start a new login shell! + +Let’s try it: + +``` +$ sudo login bork +$ groups +bork adm cdrom sudo dip plugdev lpadmin sambashare docker lxd panda +$ cat panda-file.txt # it works! I can access the file owned by `panda` now! + +``` + +Sure enough, it works! Now the new shell that `login` spawned is part of the `panda` group! Awesome! This won’t affect any other shells I already have running. If I really want the new `panda` group everywhere, I need to restart my login session completely, which means quitting my window manager and logging in again. + +### newgrp + +Somebody on Twitter told me that if you want to start a new shell with a new group that you’ve been added to, you can use `newgrp`. Like this: + +``` +sudo addgroup panda +sudo adduser bork panda +newgrp panda # starts a new shell, and you don't have to be root to run it! + +``` + +You can accomplish the same(ish) thing with `sg panda bash` which will start a `bash` shell that runs with the `panda` group. + +### setuid sets the effective user ID + +I’ve also always been a little vague about what it means for a process to run as “setuid root”. It turns out that setuid sets the effective user ID! So if I (`julia`) run a setuid root process (like `passwd`), then the **real** user ID will be set to `julia`, and the **effective** user ID will be set to `root`. + +`passwd` needs to run as root, but it can look at its real user ID to see that `julia`started the process, and prevent `julia` from editing any passwords except for `julia`’s password. + +### that’s all! + +There are a bunch more details about all the edge cases and exactly how everything works in The Linux Programming Interface so I will not get into all the details here. That book is amazing. Everything I talked about in this post is from Chapter 9, which is a 17-page chapter inside a 1300-page book. + +The thing I love most about that book is that reading 17 pages about how users and groups work is really approachable, self-contained, super useful, and I don’t have to tackle all 1300 pages of it at once to learn helpful things :) + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/11/20/groups/ + +作者:[Julia Evans ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/ +[1]:http://man7.org/tlpi/ From 599f9b1ba493cab1d2d460ccc95c336f4a6da938 Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Wed, 29 Nov 2017 16:21:41 +0800 Subject: [PATCH 026/344] Translated by qhwdw Translated by qhwdw --- ...Source Code... and Remove it Afterwards.md | 514 ++++++++++++++++++ 1 file changed, 514 insertions(+) create mode 100644 translated/tech/20171006 How to Install Software from Source Code... and Remove it Afterwards.md diff --git a/translated/tech/20171006 How to Install Software from Source Code... and Remove it Afterwards.md b/translated/tech/20171006 How to Install Software from Source Code... and Remove it Afterwards.md new file mode 100644 index 0000000000..9673771438 --- /dev/null +++ b/translated/tech/20171006 How to Install Software from Source Code... and Remove it Afterwards.md @@ -0,0 +1,514 @@ +怎么用源代码安装软件 … 以及如何卸载它 +============================================================ + +![How to install software from source code](https://itsfoss.com/wp-content/uploads/2017/10/install-software-from-source-code-linux-800x450.jpg) + + _简介:这篇文章详细介绍了在 Linux 中怎么用源代码安装程序,以及怎么去卸载源代码安装的程序。_ + +你的 Linux 分发版的其中一个最大的优点就是它的包管理器和相关的软件库。正是因为它们,你才可以去下载所需的工具和资源,以及在你的计算机上完全自动化地安装一个新软件。 + +但是,尽管他们付出了很多的努力,包维护者仍然没法做到处理好每个用到的依赖,也不可能将所有的可用软件都打包进去。因此,仍然存在需要你自已去编译和安装一个新软件的情形。对于我来说,到目前为止,最主要的原因是,当我需要去运行一个特定的版本时我还要编译一些软件。或者,我想去修改源代码或使用一些想要的编译选项。 + +如果你也属于后一种情况,那你已经知道你应该做什么了。但是,对于绝大多数的 Linux 用户来说,第一次从源代码中编译和安装一个软件看上去像是一个入门的仪式:它让很多人感到恐惧;但是,如果你能克服困难,你将可能进入一个全新的世界,并且,如果你做到了,那么你将成为社区中享有特权的一部分人。 + +[Suggested readHow To Install And Remove Software In Ubuntu [Complete Guide]][8] + +### A. 在 Linux 中从源代码开始安装软件 + +这正是我们要做的。因为这篇文章的需要,我要在我的系统上安装 [NodeJS][9] 8.1.1。它是个完全真实的版本。这个版本在 Debian 仓库中不可用: + +``` +sh$ apt-cache madison nodejs | grep amd64 + nodejs | 6.11.1~dfsg-1 | http://deb.debian.org/debian experimental/main amd64 Packages + nodejs | 4.8.2~dfsg-1 | http://ftp.fr.debian.org/debian stretch/main amd64 Packages + nodejs | 4.8.2~dfsg-1~bpo8+1 | http://ftp.fr.debian.org/debian jessie-backports/main amd64 Packages + nodejs | 0.10.29~dfsg-2 | http://ftp.fr.debian.org/debian jessie/main amd64 Packages + nodejs | 0.10.29~dfsg-1~bpo70+1 | http://ftp.fr.debian.org/debian wheezy-backports/main amd64 Packages +``` + +### 第 1 步:从 GitHub 上获取源代码 + +像大多数开源项目一样,NodeJS 的源代码可以在 GitHub:[https://github.com/nodejs/node][10] 上找到。 + +所以,我们直接开始吧。 + +![The NodeJS official GitHub repository](https://itsfoss.com/wp-content/uploads/2017/07/nodejs-github-account.png) + +如果你不熟悉 [GitHub][11]、[git][12] 或者提到的其它的包含这个软件源代码的 [版本管理系统][13],以及多年来对该软件的所有修改的历史,最终找到该软件的最早版本。对于开发者来说,保持它的历史版本有很多好处。对现在的我来说,其中一个好处是可以得到任何一个给定时间点的项目源代码。更准确地说,当我希望的 8.1.1 版发布时,我可以像他们一样第一时间得到源代码。即便他们有很多的修改。 + +![Choose the v8.1.1 tag in the NodeJS GitHub repository](https://itsfoss.com/wp-content/uploads/2017/07/nodejs-github-choose-revision-tag.png) + +在 GitHub 上,你可以使用 “branch” 按钮导航到这个软件的不同版本。[在 Git 中 “Branch” 和 “tags” 相关的一些概念][14]。总的来说,开发者创建 “branch” 和 “tags” 在项目历史中对重要事件保持跟踪,就像当她们启用一个新特性或者发布一个新版本。在这里先不详细介绍了,所有你想知道的都可以看 _tagged_ 的 “v8.1.1” 版本。 + +![The NodeJS GitHub repository as it was at the time the v8.1.1 tag was created](https://itsfoss.com/wp-content/uploads/2017/07/nodejs-github-revision-811.png) + +在选择了 “v8.1.1” 标签后,页面被刷新,最显著的变化是标签现在作为 URL 的一部分出现。另外,你可能会注意到文件改变数据也不同。在源代码树上,你可以看到现在已经创建了 v8.1.1 标签。在某种意义上,你也可以认为像 git 这样的版本管理工具是一个时光穿梭机,允许你返回进入到以前的项目历史中。 + +![NodeJS GitHub repository download as a ZIP button](https://itsfoss.com/wp-content/uploads/2017/07/nodejs-github-revision-download-zip.png) + +在这个时候,我们可以下载 NodeJS 8.1.1 的源代码。你不要错过大的蓝色按钮,建议下载一个项目的 ZIP 压缩包。对于我来说,为讲解的目的,我从命令行中下载并解压这个 ZIP 压缩包。但是,如果你更喜欢使用一个 [GUI][15] 工具,不用担心,你可以这样做: + +``` +wget https://github.com/nodejs/node/archive/v8.1.1.zip +unzip v8.1.1.zip +cd node-8.1.1/ +``` + +下载一个 ZIP 包它做的很好,但是如果你希望去做 “like a pro”,我建议你直接使用 `git` 工具去下载源代码。它一点也不复杂 — 并且如果你是第一次使用一个工具,它将是一个很好的开端,你以后将经常用到它: + +``` +# first ensure git is installed on your system +sh$ sudo apt-get install git +# Make a shallow clone the NodeJS repository at v8.1.1 +sh$ git clone --depth 1 \ + --branch v8.1.1 \ + https://github.com/nodejs/node +sh$ cd node/ +``` + +顺便说一下,如果你想发布任何项目,正好可以考虑把这篇文章的第一部分做为一个总体介绍。后面,为了帮你排除常问题,我们将更详细地解释基于 Debian 和基于 ReadHat 的发布。 + +不管怎样,在你使用 `git` 或者作为一个 ZIP 压缩包下载了源代码后,你现在应该在当前的目录下提取源代码文件: + +``` +sh$ ls +android-configure BUILDING.md common.gypi doc Makefile src +AUTHORS CHANGELOG.md configure GOVERNANCE.md node.gyp test +benchmark CODE_OF_CONDUCT.md CONTRIBUTING.md lib node.gypi tools +BSDmakefile COLLABORATOR_GUIDE.md deps LICENSE README.md vcbuild.bat +``` + +### 第 2 步:理解程序的构建系统 + +构建系统就是我们通常所说的 "编译源代码”, 其实,编译只是从源代码中生成一个可使用的软件的其中一个阶段。一个构建系统是一套工具,在具体的实践中,为了完全构建一个软件,仅仅需要发出几个命令就可以自动并清晰地完成这些不同的任务。 + +虽然概念很简单,实际上编译做了很多事情。因为不同的项目或者编程语言可能要求不一样,或者是因为编程体验,或者因为支持的平台、或者因为历史的原因,或者 … 或者 … 选择或创建其它的构建系统的原因有很多。所有的这些都说明可用的不同的解决方案有很多。 + +NodeJS 使用一个 [GNU 风格的构建系统][16]。在开源社区中这是一个很流行的选择。一旦开始,将进入一段精彩的旅程。 + +写出和调优一个构建系统是一个非常复杂的任务。但是,作为 “终端用户” 来说, GNU 风格的构建系统使用两个工具来构建它们:`configure` 和 `make`。 + +`configure` 文件是项目专用的脚本,为了确保项目可以被构建,它将检查目标系统配置和可用功能,最后使用当前平台专用的脚本来处理构建工作。 + +一个典型的 `configure` 作业的重要部分是去构建 `Makefile`。这个文件包含有效构建项目所需的指令。 + +([`make` 工具][17]),另一方面,一个 POSIX 工具可用于任何类 Unix 系统。它将读取项目专用的 `Makefile` 然后执行所需的操作去构建和安装你的程序。 + +但是,在 Linux 的世界中,你仍然有一些原因去定制你自己专用的构建。 + +``` +./configure --help +``` + +`configure -help` 命令将展示所有你可用的配置选项。再强调一下,它是项目专用的。说实话,有时候,在你完全理解每个配置选项的作用之前,你需要深入到项目中去好好研究。 + +但是,这里至少有一个标准的 GNU 自动化工具选项,它就是众所周知的 `--prefix` 选项。它与文件系统的层次结构有关,它是你软件要安装的位置。 + +[Suggested read8 Vim Tips And Tricks That Will Make You A Pro User][18] + +### 第 3 步:文件系统层次化标准(FHS) + +大部分典型的 Linux 分发版的文件系统层次结构都遵从 [文件系统层次化标准(FHS)][19]。 + +这个标准说明了你的系统中各种目录的用途,比如,`/usr`、`/tmp`、`/var` 等等。 + +当使用 GNU 自动化工具 _和大多数其它的构建系统_ 时,它的默认安装位置都在你的系统的 `/usr/local` 目录中。依据 FHS 中 _“/usr/local 层级是为系统管理员安装软件的位置使用的,它在系统软件更新时是覆盖安全的。它可以被用于一个主机组中,在 /usr 中找不到的、可共享的程序和数据”_ ,因此,它是一个非常好的选择。 + +`/usr/local` 层次以某种方式复制了 root 目录,并且你可以在 `/usr/local/bin` 这里找到可执行程序,在 `/usr/local/lib` 中是库,在 `/usr/local/share` 中是架构依赖文件,等等。 + +使用 `/usr/local` 树作为你定制安装的软件位置的唯一问题是,你的软件将在这里混杂在一起。尤其是你安装了多个软件之后,将很难去准确地跟踪 `/usr/local/bin` 和 `/usr/local/lib` 到底属于哪个软件。它虽然不足以在你的系统上产生问题。毕竟,`/usr/bin` 是很混乱的。但是,它在你想去手工卸载已安装的软件时会将成为一个问题。 + +去解决这个问题,我通常喜欢安装定制的软件到 `/opt` 子目录下。再次引用 FHS: + + _“`/opt` 是为安装应用程序插件软件包而保留的。一个包安装在 `/opt` 下必须在 `/opt/` 或者 `/opt/` 目录中独立定位到它的静态文件,`` 处是所说的那个软件名的名字,而 `` 处是提供者的 LANANA 注册名字。”_(译者注:LANANA 是指 The Linux Assigned Names And Numbers Authority,http://www.lanana.org/ ) + +因此,我们将在 `/opt` 下创建一个子目录,用于我们定制的 NodeJS 的安装。并且,如果有一天我想去卸载它,我只是很简单地去删除那个目录: + +``` +sh$ sudo mkdir /opt/node-v8.1.1 +sh$ sudo ln -sT node-v8.1.1 /opt/node +# What is the purpose of the symbolic link above? +# Read the article till the end--then try to answer that +# question in the comment section! + +sh$ ./configure --prefix=/opt/node-v8.1.1 +sh$ make -j9 && echo ok +# -j9 means run up to 9 parallel tasks to build the software. +# As a rule of thumb, use -j(N+1) where N is the number of cores +# of your system. That will maximize the CPU usage (one task per +# CPU thread/core + a provision of one extra task when a process +# is blocked by an I/O operation. +``` + +在你运行完成 `make` 命令之后,如果有任何的除了 “ok” 以外的信息,将意味着在构建过程中有错误。比如,我们使用一个 `-j` 选项去运行一个并行构建,在构建系统的大量输出过程中,检索错误信息并不是件很容易的事。 + +在这种情况下,只能是重新开始 `make`,并且不要使用 `-j` 选项。这样错误将会出现在输出信息的最后面: + +``` +sh$ make +``` + +最终,编译结束后,你可以运行这个命令去安装你的软件: + +``` +sh$ sudo make install +``` + +然后测试它: + +``` +sh$ /opt/node/bin/node --version +v8.1.1 +``` + +### B. 如果在源代码安装的过程中出现错误怎么办? + +我上面介绍的是大多数的文档丰富的项目在“构建指令”页面上你所看到的。但是,本文的目标是让你从源代码开始去编译你的第一个软件,它可能要花一些时间去研究一些常见的问题。因此,我将再次重新开始一遍整个过程,但是,这次是在一个最新的、最小化安装的 Debian 9.0 和 CentOS 7.0 系统上。因此,你可能看到很多的错误和我怎么去解决它。 + +### 从 Debian 9.0 中 “Stretch” 开始 + +``` +itsfoss@debian:~$ git clone --depth 1 \ + --branch v8.1.1 \ + https://github.com/nodejs/node +-bash: git: command not found +``` + +这个问题非常容易去诊断和解决。仅仅是去安装这个 `git` 包: + +``` +itsfoss@debian:~$ sudo apt-get install git +``` + +``` +itsfoss@debian:~$ git clone --depth 1 \ + --branch v8.1.1 \ + https://github.com/nodejs/node && echo ok +[...] +ok +``` + +``` +itsfoss@debian:~/node$ sudo mkdir /opt/node-v8.1.1 +itsfoss@debian:~/node$ sudo ln -sT node-v8.1.1 /opt/node +``` + +现在没有问题了。 + +``` +itsfoss@debian:~/node$ ./configure --prefix=/opt/node-v8.1.1/ +WARNING: failed to autodetect C++ compiler version (CXX=g++) +WARNING: failed to autodetect C compiler version (CC=gcc) +Node.js configure error: No acceptable C compiler found! + Please make sure you have a C compiler installed on your system and/or + consider adjusting the CC environment variable if you installed + it in a non-standard prefix. +``` + +很显然,编译一个项目,你需要一个编译器。NodeJS 是使用 [C++ language][20] 写的,我们需要一个 C++ [编译器][21]。在这里我将安装 `g++`,它就是为这个目的写的 GNU C++ 编译器: + +``` +itsfoss@debian:~/node$ sudo apt-get install g++ +itsfoss@debian:~/node$ ./configure --prefix=/opt/node-v8.1.1/ && echo ok +[...] +ok +``` + +``` +itsfoss@debian:~/node$ make -j9 && echo ok +-bash: make: command not found +``` + +还差一个其它工具。同样的症状。同样的解决方案: + +``` +itsfoss@debian:~/node$ sudo apt-get install make +itsfoss@debian:~/node$ make -j9 && echo ok +[...] +ok +``` + +``` +itsfoss@debian:~/node$ sudo make install +[...] +itsfoss@debian:~/node$ /opt/node/bin/node --version +v8.1.1 +``` + +成功! + +请注意:我将安装各种工具一步一步去展示怎么去诊断编译问题,以及展示怎么去解决这些问题。但是,如果你搜索关于这个主题的更多文档,或者读其它的教程,你将发现,很多分发版有一个 “meta-packages”,它像一个伞一样去安装一系列的或者全部的常用工具用于编译软件。在基于 Debian 的系统上,你或许遇到过 [构建要素][22] 包,它就是这种用作。在基于 Red Hat 的分发版中,它将是  _“开发工具”_ 组。 + +### 在 CentOS 7.0 上 + +``` +[itsfoss@centos ~]$ git clone --depth 1 \ + --branch v8.1.1 \ + https://github.com/nodejs/node +-bash: git: command not found +``` + +命令没有找到?可以用 `yum` 包管理器去安装它: + +``` +[itsfoss@centos ~]$ sudo yum install git +``` + +``` +[itsfoss@centos ~]$ git clone --depth 1 \ + --branch v8.1.1 \ + https://github.com/nodejs/node && echo ok +[...] +ok +``` + +``` +[itsfoss@centos ~]$ sudo mkdir /opt/node-v8.1.1 +[itsfoss@centos ~]$ sudo ln -sT node-v8.1.1 /opt/node +``` + +``` +[itsfoss@centos ~]$ cd node +[itsfoss@centos node]$ ./configure --prefix=/opt/node-v8.1.1/ +WARNING: failed to autodetect C++ compiler version (CXX=g++) +WARNING: failed to autodetect C compiler version (CC=gcc) +Node.js configure error: No acceptable C compiler found! + + Please make sure you have a C compiler installed on your system and/or + consider adjusting the CC environment variable if you installed + it in a non-standard prefix. +``` + +你知道的:NodeJS 是使用 C++ 语言写的,但是,我的系统缺少合适的编译器。Yum 可以帮到你。因为,我不是一个合格的 CentOS 用户,在因特网上准确地找到包含 g++ 编译器的包的名字是很困难的。这个页面会指导我:[https://superuser.com/questions/590808/yum-install-gcc-g-doesnt-work-anymore-in-centos-6-4][23] + +``` +[itsfoss@centos node]$ sudo yum install gcc-c++ +[itsfoss@centos node]$ ./configure --prefix=/opt/node-v8.1.1/ && echo ok +[...] +ok +``` + +``` +[itsfoss@centos node]$ make -j9 && echo ok +[...] +ok +``` + +``` +[itsfoss@centos node]$ sudo make install && echo ok +[...] +ok +``` + +``` +[itsfoss@centos node]$ /opt/node/bin/node --version +v8.1.1 +``` + +再次成功! + +### C. 从源代码中对要安装的软件做一些改变 + +你从源代码中安装一个软件,可能是因为你的分发仓库中没有一个可用的特定版本。或者因为你想去 _修改_ 那个程序。也可能是修复一个 bug 或者增加一个特性。毕竟,开源软件这些都可以做到。因此,我将抓住这个机会,让你亲自体验怎么去编译你自己的软件。 + +在这里,我将在 NodeJS 源代码上生成一个主要的改变。然后,我们将看到我们的改变将被纳入到软件的编译版本中: + +用你喜欢的 [文本编辑器][24](如,vim、nano、gedit、 … )打开文件 `node/src/node.cc`。然后,尝试找到如下的代码片段: + +``` + if (debug_options.ParseOption(argv[0], arg)) { + // Done, consumed by DebugOptions::ParseOption(). + } else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) { + printf("%s\n", NODE_VERSION); + exit(0); + } else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) { + PrintHelp(); + exit(0); + } +``` + +它在 [文件的 3830 行][25] 附近。然后,修改包含 `printf` 的行,将它替换成如下内容: + +``` + printf("%s (compiled by myself)\n", NODE_VERSION); +``` + +然后,返回到你的终端。在继续之前,_为了对强大的 Git 支持有更多的了解_,你可以去检查一下,你修改是文件是否正确: + +``` +diff --git a/src/node.cc b/src/node.cc +index bbce1022..a5618b57 100644 +--- a/src/node.cc ++++ b/src/node.cc +@@ -3828,7 +3828,7 @@ static void ParseArgs(int* argc, + if (debug_options.ParseOption(argv[0], arg)) { + // Done, consumed by DebugOptions::ParseOption(). + } else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) { +- printf("%s\n", NODE_VERSION); ++ printf("%s (compiled by myself)\n", NODE_VERSION); + exit(0); + } else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) { + PrintHelp(); +``` + +在你改变的行之前,你将看到一个 “-” (减号标志)。而在改变之后的行前面有一个 “+” (加号标志)。 + +现在可以去重新编译并重新安装你的软件了: + +``` +make -j9 && sudo make install && echo ok +[...] +ok +``` + +这个时候,可能失败的唯一原因就是你改变代码时的输入错误。如果就是这种情况,在文本编辑器中重新打开 `node/src/node.cc` 文件并修复错误。 + +一旦你管理的一个编译和安装的新修改版本的 NodeJS,将可以去检查你的修改是否包含到软件中: + +``` +itsfoss@debian:~/node$ /opt/node/bin/node --version +v8.1.1 (compiled by myself) +``` + +恭喜你!你生成了开源程序中你的第一个改变! + +### D. 让 shell 定位到定制构建的软件 + +到目前为止,你可能注意到,我通常启动我新编译的 NodeJS 软件是通过指定一个到二进制文件的绝对路径。 + +``` +/opt/node/bin/node +``` + +这是可以正常工作的。但是,这样太麻烦。实际上有两种办法可以去解决这个问题。但是,去理解它们,你必须首先明白,你的 shell 定位可执行文件是进入到通过在[环境变量][26]`PATH` 中指定的目录去查找的。 + +``` +itsfoss@debian:~/node$ echo $PATH +/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games +``` + +在 Debian 系统上,如果你不指定一个精确的目录做为命令名字的一部分,shell 将首先在 `/usr/local/bin` 中查找可执行程序,如果没有找到,然后进入 `/usr/bin` 中查找,如果没有找到,然后进入 `/bin`查找,如果没有找到,然后进入 `/usr/local/games` 查找,如果没有找到,然后进入 `/usr/games` 查找,如果没有找到,那么,shell 将报告一个错误,_“command not found”_。 + +由此,我们可以知道有两种方法去确保命令可以被 shell 访问到:通过将它增加到已经配置好的 `PATH` 目录中,或者将包含可执行程序的目录添加到 `PATH` 中。 + +### 从 /usr/local/bin 中添加一个链接 + +仅从 `/opt/node/bin` 中 _拷贝_ 节点二进制可执行文件到 `/usr/local/bin` 是将是一个错误的做法。因为,如果这么做,可执行程序将无法定位到在 `/opt/node/` 中的其它需要的组件。(常见的做法是软件在它自己的位置去定位它所需要的资源文件) + +因此,传统的做法是去使用一个符号链接: + +``` +itsfoss@debian:~/node$ sudo ln -sT /opt/node/bin/node /usr/local/bin/node +itsfoss@debian:~/node$ which -a node || echo not found +/usr/local/bin/node +itsfoss@debian:~/node$ node --version +v8.1.1 (compiled by myself) +``` + +这一个简单而有效的解决办法,尤其是,如果一个软件包是由好几个众所周知的可执行程序组成的,因为,你将为每个用户调用命令创建一个符号链接。例如,如果你熟悉 NodeJS,你知道应用的 `npm` 组件,也是 `/usr/local/bin` 中的符号链接。这只是,我让你做了一个练习。 + +### 修改 PATH + +首先,如果你尝试前面的解决方案,先移除前面创建的节点符号链接,去从一个干净的状态开始: + +``` +itsfoss@debian:~/node$ sudo rm /usr/local/bin/node +itsfoss@debian:~/node$ which -a node || echo not found +not found +``` + +现在,这里有一个不可思议的命令去改变你的 `PATH`: + +``` +itsfoss@debian:~/node$ export PATH="/opt/node/bin:${PATH}" +itsfoss@debian:~/node$ echo $PATH +/opt/node/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games +``` + +简单说就是,我用前面的内容替换了环境变量 `PATH` 中原先的内容,但是通过一个 `/opt/node/bin` 的前缀。因此,你可以想像一下,shell 将先进入到 `/opt/node/bin` 目录中查找可执行程序。我们也可以使用 `which` 命令去确认一下: + +``` +itsfoss@debian:~/node$ which -a node || echo not found +/opt/node/bin/node +itsfoss@debian:~/node$ node --version +v8.1.1 (compiled by myself) +``` + +鉴于 “link” 解决方案是永久的,只要创建到 `/usr/local/bin`的符号链接就行了,而对 `PATH` 的改变仅对进入到当前的 shell 生效。你可以自己做一些研究,如何做到对 `PATH` 的永久改变。给你一个提示,可以将它写到你的 “profile” 中。如果你找到这个解决方案,不要犹豫,通过下面的评论区共享给其它的读者! + +### E. 怎么去卸载刚才从源代码中安装的软件 + +因为我们定制编译的 NodeJS 软件全部在 `/opt/node-v8.1.1` 目录中,卸载它不需要做太多的工作,仅使用 `rm` 命令去删除那个目录即可: + +``` +sudo rm -rf /opt/node-v8.1.1 +``` + +注意:`sudo` 和 `rm -rf` 是 “非常危险的鸡尾酒!”,一定要在按下 “enter” 键之前多检查几次你的命令。你不会得到任何的确认信息,并且如果你删除了错误的目录它是不可恢复的 … + +然后,如果你修改了你的 `PATH`,你可以去恢复这些改变。它一点也不复杂。 + +如果你从 `/usr/local/bin` 创建了一个符号链接,你应该去删除它们: + +``` +itsfoss@debian:~/node$ sudo find /usr/local/bin \ + -type l \ + -ilname "/opt/node/*" \ + -print -delete +/usr/local/bin/node +``` + +### 等等? 依赖地狱在哪里? + +一个最终结论是,如果你读过有关的编译定制软件的文档,你可能听到关于 [依赖地狱][27] 的说法。那是在你能够成功编译一个软件之前,对那种烦人情况的一个呢称,你必须首先编译一个前提条件所需要的库,它又可能要求其它的库,而这些库有可能与你的系统上已经安装的其它软件不兼容。 + +作为你的分发版的包维护者的工作的一部分,去真正地解决那些依赖关系,确保你的系统上的各种软件都使用了可兼容的库,并且按正确的顺序去安装。 + +在这篇文章中,我特意选择了 NodeJS 去安装,是因为它几乎没有依赖。我说 “几乎” 是因为,实际上,它  _有_  依赖。但是,这些源代码的依赖已经预置到项目的源仓库中(在 `node/deps` 子目录下),因此,在你动手编译之前,你不用手动去下载和安装它们。 + +如果你有兴趣了解更多关于那个问题的知识和学习怎么去处理它。请在下面的评论区告诉我,它将是更高级别的文章的好主题! + +-------------------------------------------------------------------------------- + +作者简介: + +充满激情的工程师,职业是教师,我的目标是:热心分享我所教的内容,并让我的学生自己培养它们的技能。你也可以在我的网站上联系到我。 + +-------------------- + +via: https://itsfoss.com/install-software-from-source-code/ + +作者:[Sylvain Leroux ][a] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://itsfoss.com/author/sylvain/ +[1]:https://itsfoss.com/author/sylvain/ +[2]:https://itsfoss.com/install-software-from-source-code/#comments +[3]:https://www.facebook.com/share.php?u=https%3A%2F%2Fitsfoss.com%2Finstall-software-from-source-code%2F%3Futm_source%3Dfacebook%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare +[4]:https://twitter.com/share?original_referer=/&text=How+to+Install+Software+from+Source+Code%E2%80%A6+and+Remove+it+Afterwards&url=https://itsfoss.com/install-software-from-source-code/%3Futm_source%3Dtwitter%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare&via=Yes_I_Know_IT +[5]:https://plus.google.com/share?url=https%3A%2F%2Fitsfoss.com%2Finstall-software-from-source-code%2F%3Futm_source%3DgooglePlus%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare +[6]:https://www.linkedin.com/cws/share?url=https%3A%2F%2Fitsfoss.com%2Finstall-software-from-source-code%2F%3Futm_source%3DlinkedIn%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare +[7]:https://www.reddit.com/submit?url=https://itsfoss.com/install-software-from-source-code/&title=How+to+Install+Software+from+Source+Code%E2%80%A6+and+Remove+it+Afterwards +[8]:https://itsfoss.com/remove-install-software-ubuntu/ +[9]:https://nodejs.org/en/ +[10]:https://github.com/nodejs/node +[11]:https://en.wikipedia.org/wiki/GitHub +[12]:https://en.wikipedia.org/wiki/Git +[13]:https://en.wikipedia.org/wiki/Version_control +[14]:https://stackoverflow.com/questions/1457103/how-is-a-tag-different-from-a-branch-which-should-i-use-here +[15]:https://en.wikipedia.org/wiki/Graphical_user_interface +[16]:https://en.wikipedia.org/wiki/GNU_Build_System +[17]:https://en.wikipedia.org/wiki/Make_%28software +[18]:https://itsfoss.com/pro-vim-tips/ +[19]:http://www.pathname.com/fhs/ +[20]:https://en.wikipedia.org/wiki/C%2B%2B +[21]:https://en.wikipedia.org/wiki/Compiler +[22]:https://packages.debian.org/sid/build-essential +[23]:https://superuser.com/questions/590808/yum-install-gcc-g-doesnt-work-anymore-in-centos-6-4 +[24]:https://en.wikipedia.org/wiki/List_of_text_editors +[25]:https://github.com/nodejs/node/blob/v8.1.1/src/node.cc#L3830 +[26]:https://en.wikipedia.org/wiki/Environment_variable +[27]:https://en.wikipedia.org/wiki/Dependency_hell From e836e73d07085bc87cf73ce593dd5f5a483acc13 Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Wed, 29 Nov 2017 16:22:11 +0800 Subject: [PATCH 027/344] Translated by qhwdw Translated by qhwdw --- ...Source Code... and Remove it Afterwards.md | 517 ------------------ 1 file changed, 517 deletions(-) delete mode 100644 sources/tech/20171006 How to Install Software from Source Code... and Remove it Afterwards.md diff --git a/sources/tech/20171006 How to Install Software from Source Code... and Remove it Afterwards.md b/sources/tech/20171006 How to Install Software from Source Code... and Remove it Afterwards.md deleted file mode 100644 index d2b16a0b18..0000000000 --- a/sources/tech/20171006 How to Install Software from Source Code... and Remove it Afterwards.md +++ /dev/null @@ -1,517 +0,0 @@ -Translating by qhwdw -How to Install Software from Source Code… and Remove it Afterwards -============================================================ - -![How to install software from source code](https://itsfoss.com/wp-content/uploads/2017/10/install-software-from-source-code-linux-800x450.jpg) - - _Brief: This detailed guide explains how to install a program from source code in Linux and how to remove the software installed from the source code._ - -One of the greatest strength of your Linux distribution is its package manager and the associated software repository. With them, you have all the necessary tools and resources to download and install a new software on your computer in a completely automated manner. - -But despite all their efforts, the package maintainers cannot handle each and every use cases. Nor can they package all the software available out there. So there are still situations where you will have to compile and install a new software by yourself. As of myself, the most common reason, by far, I have to compile some software is when I need to run a very specific version. Or because I want to modify the source code or use some fancy compilation options. - -If your needs belong to that latter category, there are chances you already know what you do. But for the vast majority of Linux users, compiling and installing a software from the sources for the first time might look like an initiation ceremony: somewhat frightening; but with the promise to enter a new world of possibilities and to be part of a privileged community if you overcome that. - -[Suggested readHow To Install And Remove Software In Ubuntu [Complete Guide]][8] - -### A. Installing software from source code in Linux - -And that’s exactly what we will do here. For the purpose of that article, let’s say I need to install [NodeJS][9] 8.1.1 on my system. That version exactly. A version which is not available from the Debian repository: - -``` -sh$ apt-cache madison nodejs | grep amd64 - nodejs | 6.11.1~dfsg-1 | http://deb.debian.org/debian experimental/main amd64 Packages - nodejs | 4.8.2~dfsg-1 | http://ftp.fr.debian.org/debian stretch/main amd64 Packages - nodejs | 4.8.2~dfsg-1~bpo8+1 | http://ftp.fr.debian.org/debian jessie-backports/main amd64 Packages - nodejs | 0.10.29~dfsg-2 | http://ftp.fr.debian.org/debian jessie/main amd64 Packages - nodejs | 0.10.29~dfsg-1~bpo70+1 | http://ftp.fr.debian.org/debian wheezy-backports/main amd64 Packages -``` - -### Step 1: Getting the source code from GitHub - -Like many open-source projects, the sources of NodeJS can be found on GitHub: [https://github.com/nodejs/node][10] - -So, let’s go directly there. - -![The NodeJS official GitHub repository](https://itsfoss.com/wp-content/uploads/2017/07/nodejs-github-account.png) - -If you’re not familiar with [GitHub][11], [git][12] or any other [version control system][13] worth mentioning the repository contains the current source for the software, as well as a history of all the modifications made through the years to that software. Eventually up to the very first line written for that project. For the developers, keeping that history has many advantages. For us today, the main one is we will be able to get the sources from for the project as they were at any given point in time. More precisely, I will be able to get the sources as they were when the 8.1.1 version I want was released. Even if there were many modifications since then. - -![Choose the v8.1.1 tag in the NodeJS GitHub repository](https://itsfoss.com/wp-content/uploads/2017/07/nodejs-github-choose-revision-tag.png) - -On GitHub, you can use the “branch” button to navigate between different versions of the software. [“Branch” and “tags” are somewhat related concepts in Git][14]. Basically, the developers create “branch” and “tags” to keep track of important events in the project history, like when they start working on a new feature or when they publish a release. I will not go into the details here, all you need to know is I’m looking for the version  _tagged_  “v8.1.1” - -![The NodeJS GitHub repository as it was at the time the v8.1.1 tag was created](https://itsfoss.com/wp-content/uploads/2017/07/nodejs-github-revision-811.png) - -After having chosen on the “v8.1.1” tag, the page is refreshed, the most obvious change being the tag now appears as part of the URL. In addition, you will notice the file change date are different too. The source tree you are now seeing is the one that existed at the time the v8.1.1 tag was created. In some sense, you can think of a version control tool like git as a time travel machine, allowing you to go back and forth into a project history. - -![NodeJS GitHub repository download as a ZIP button](https://itsfoss.com/wp-content/uploads/2017/07/nodejs-github-revision-download-zip.png) - -At this point, we can download the sources of NodeJS 8.1.1\. You can’t miss the big blue button suggesting to download the ZIP archive of the project. As of myself, I will download and extract the ZIP from the command line for the sake of the explanation. But if you prefer using a [GUI][15] tool, don’t hesitate to do that instead: - -``` -wget https://github.com/nodejs/node/archive/v8.1.1.zip -unzip v8.1.1.zip -cd node-8.1.1/ -``` - -Downloading the ZIP archive works great. But if you want to do it “like a pro”, I would suggest using directly the `git` tool to download the sources. It is not complicated at all— and it will be a nice first contact with a tool you will often encounter: - -``` -# first ensure git is installed on your system -sh$ sudo apt-get install git -# Make a shallow clone the NodeJS repository at v8.1.1 -sh$ git clone --depth 1 \ - --branch v8.1.1 \ - https://github.com/nodejs/node -sh$ cd node/ -``` - -By the way, if you have any issue, just consider that first part of this article as a general introduction. Later I have more detailed explanations for Debian- and ReadHat-based distributions in order to help you troubleshoot common issues. - -Anyway, whenever you downloaded the source using `git` or as a ZIP archive, you should now have exactly the same source files in the current directory: - -``` -sh$ ls -android-configure BUILDING.md common.gypi doc Makefile src -AUTHORS CHANGELOG.md configure GOVERNANCE.md node.gyp test -benchmark CODE_OF_CONDUCT.md CONTRIBUTING.md lib node.gypi tools -BSDmakefile COLLABORATOR_GUIDE.md deps LICENSE README.md vcbuild.bat -``` - -### Step 2: Understanding the Build System of the program - -We usually talk about “compiling the sources”, but the compilation is only one of the phases required to produce a working software from its source. A build system is a set of tool and practices used to automate and articulate those different tasks in order to build entirely the software just by issuing few commands. - -If the concept is simple, the reality is somewhat more complicated. Because different projects or programming language may have different requirements. Or because of the programmer’s tastes. Or the supported platforms. Or for historical reason. Or… or.. there is an almost endless list of reasons to choose or create another build system. All that to say there are many different solutions used out there. - -NodeJS uses a [GNU-style build system][16]. This is a popular choice in the open source community. And once again, a good way to start your journey. - -Writing and tuning a build system is a pretty complex task. But for the “end user”, GNU-style build systems resume themselves in using two tools: `configure` and `make`. - -The `configure` file is a project-specific script that will check the destination system configuration and available feature in order to ensure the project can be built, eventually dealing with the specificities of the current platform. - -An important part of a typical `configure` job is to build the `Makefile`. That is the file containing the instructions required to effectively build the project. - -The [`make` tool][17]), on the other hand, is a POSIX tool available on any Unix-like system. It will read the project-specific `Makefile` and perform the required operations to build and install your program. - -But, as always in the Linux world, you still have some latency to customize the build for your specific needs. - -``` -./configure --help -``` - -The `configure -help` command will show you all the available configuration options. Once again, this is very project-specific. And to be honest, it is sometimes required to dig into the project before fully understand the meaning of each and every configure option. - -But there is at least one standard GNU Autotools option that you must know: the `--prefix` option. This has to do with the file system hierarchy and the place your software will be installed. - -[Suggested read8 Vim Tips And Tricks That Will Make You A Pro User][18] - -### Step 3: The FHS - -The Linux file system hierarchy on a typical distribution mostly comply with the [Filesystem Hierarchy Standard (FHS)][19] - -That standard explains the purpose of the various directories of your system: `/usr`, `/tmp`, `/var` and so on. - -When using the GNU Autotools— and most other build systems— the default installation location for your new software will be `/usr/local`. Which is a good choice as according to the FSH  _“The /usr/local hierarchy is for use by the system administrator when installing software locally? It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable amongst a group of hosts, but not found in /usr.”_ - -The `/usr/local` hierarchy somehow replicates the root directory, and you will find there `/usr/local/bin` for the executable programs, `/usr/local/lib` for the libraries, `/usr/local/share` for architecture independent files and so on. - -The only issue when using the `/usr/local` tree for custom software installation is the files for all your software will be mixed there. Especially, after having installed a couple of software, it will be hard to track to which file exactly of `/usr/local/bin` and `/usr/local/lib` belongs to which software. That will not cause any issue to the system though. After all, `/usr/bin` is just about the same mess. But that will become an issue the day you will want to remove a manually installed software. - -To solve that issue, I usually prefer installing custom software in the `/opt`sub-tree instead. Once again, to quote the FHS: - -_”/opt is reserved for the installation of add-on application software packages. - -A package to be installed in /opt must locate its static files in a separate /opt/ or /opt/ directory tree, where is a name that describes the software package and is the provider’s LANANA registered name.”_ - -So we will create a sub-directory of `/opt` specifically for our custom NodeJS installation. And if someday I want to remove that software, I will simply have to remove that directory: - -``` -sh$ sudo mkdir /opt/node-v8.1.1 -sh$ sudo ln -sT node-v8.1.1 /opt/node -# What is the purpose of the symbolic link above? -# Read the article till the end--then try to answer that -# question in the comment section! - -sh$ ./configure --prefix=/opt/node-v8.1.1 -sh$ make -j9 && echo ok -# -j9 means run up to 9 parallel tasks to build the software. -# As a rule of thumb, use -j(N+1) where N is the number of cores -# of your system. That will maximize the CPU usage (one task per -# CPU thread/core + a provision of one extra task when a process -# is blocked by an I/O operation. -``` - -Anything but “ok” after the `make` command has completed would mean there was an error during the build process. As we ran a parallel build because of the `-j` option, it is not always easy to retrieve the error message given the large volume of output produced by the build system. - -In the case of issue, just restart `make`, but without the `-j` option this time. And the error should appear near the end of the output: - -``` -sh$ make -``` - -Finally, once the compilation has gone to the end, you can install your software to its location by running the command: - -``` -sh$ sudo make install -``` - -And test it: - -``` -sh$ /opt/node/bin/node --version -v8.1.1 -``` - -### B. What if things go wrong while installing from source code? - -What I’ve explained above is mostly what you can see on the “build instruction” page of a well-documented project. But given this article goal is to let you compile your first software from sources, it might worth taking the time to investigate some common issues. So, I will do the whole procedure again, but this time from a fresh and minimal Debian 9.0 and CentOS 7.0 systems. So you can see the error I encountered and how I solved them. - -### From Debian 9.0 “Stretch” - -``` -itsfoss@debian:~$ git clone --depth 1 \ - --branch v8.1.1 \ - https://github.com/nodejs/node --bash: git: command not found -``` - -This problem is quite easy to diagnosis and solve. Just install the `git` package: - -``` -itsfoss@debian:~$ sudo apt-get install git -``` - -``` -itsfoss@debian:~$ git clone --depth 1 \ - --branch v8.1.1 \ - https://github.com/nodejs/node && echo ok -[...] -ok -``` - -``` -itsfoss@debian:~/node$ sudo mkdir /opt/node-v8.1.1 -itsfoss@debian:~/node$ sudo ln -sT node-v8.1.1 /opt/node -``` - -No problem here. - -``` -itsfoss@debian:~/node$ ./configure --prefix=/opt/node-v8.1.1/ -WARNING: failed to autodetect C++ compiler version (CXX=g++) -WARNING: failed to autodetect C compiler version (CC=gcc) -Node.js configure error: No acceptable C compiler found! - Please make sure you have a C compiler installed on your system and/or - consider adjusting the CC environment variable if you installed - it in a non-standard prefix. -``` - -Obviously, to compile a project, you need a compiler. NodeJS being written using the [C++ language][20], we need a C++ [compiler][21]. Here I will install `g++`, the GNU C++ compiler for that purpose: - -``` -itsfoss@debian:~/node$ sudo apt-get install g++ -itsfoss@debian:~/node$ ./configure --prefix=/opt/node-v8.1.1/ && echo ok -[...] -ok -``` - -``` -itsfoss@debian:~/node$ make -j9 && echo ok --bash: make: command not found -``` - -One other missing tool. Same symptoms. Same solution: - -``` -itsfoss@debian:~/node$ sudo apt-get install make -itsfoss@debian:~/node$ make -j9 && echo ok -[...] -ok -``` - -``` -itsfoss@debian:~/node$ sudo make install -[...] -itsfoss@debian:~/node$ /opt/node/bin/node --version -v8.1.1 -``` - -Success! - -Please notice: I’ve installed the various tools one by one to show how to diagnosis the compilation issues and to show you the typical solution to solve those issues. But if you search more about that topic or read other tutorials, you will discover that most distributions have “meta-packages” acting as an umbrella to install some or all the typical tools used for compiling a software. On Debian-based systems, you will probably encounter the [build-essentials][22]package for that purpose. And on Red-Hat-based distributions, that will be the  _“Development Tools”_  group. - -### From CentOS 7.0 - -``` -[itsfoss@centos ~]$ git clone --depth 1 \ - --branch v8.1.1 \ - https://github.com/nodejs/node --bash: git: command not found -``` - -Command not found? Just install it using the `yum` package manager: - -``` -[itsfoss@centos ~]$ sudo yum install git -``` - -``` -[itsfoss@centos ~]$ git clone --depth 1 \ - --branch v8.1.1 \ - https://github.com/nodejs/node && echo ok -[...] -ok -``` - -``` -[itsfoss@centos ~]$ sudo mkdir /opt/node-v8.1.1 -[itsfoss@centos ~]$ sudo ln -sT node-v8.1.1 /opt/node -``` - -``` -[itsfoss@centos ~]$ cd node -[itsfoss@centos node]$ ./configure --prefix=/opt/node-v8.1.1/ -WARNING: failed to autodetect C++ compiler version (CXX=g++) -WARNING: failed to autodetect C compiler version (CC=gcc) -Node.js configure error: No acceptable C compiler found! - - Please make sure you have a C compiler installed on your system and/or - consider adjusting the CC environment variable if you installed - it in a non-standard prefix. -``` - -You guess it: NodeJS is written using the C++ language, but my system lacks the corresponding compiler. Yum to the rescue. As I’m not a regular CentOS user, I actually had to search on the Internet the exact name of the package containing the g++ compiler. Leading me to that page: [https://superuser.com/questions/590808/yum-install-gcc-g-doesnt-work-anymore-in-centos-6-4][23] - -``` -[itsfoss@centos node]$ sudo yum install gcc-c++ -[itsfoss@centos node]$ ./configure --prefix=/opt/node-v8.1.1/ && echo ok -[...] -ok -``` - -``` -[itsfoss@centos node]$ make -j9 && echo ok -[...] -ok -``` - -``` -[itsfoss@centos node]$ sudo make install && echo ok -[...] -ok -``` - -``` -[itsfoss@centos node]$ /opt/node/bin/node --version -v8.1.1 -``` - -Success. Again. - -### C. Making changes to the software installed from source code - -You may install a software from the source because you need a very specific version not available in your distribution repository. Or because you want to  _modify_  that program. Either to fix a bug or add a feature. After all, open-source is all about that. So I will take that opportunity to give you a taste of the power you have at hand now you are able to compile your own software. - -Here, we will make a minor change to the sources of NodeJS. And we will see if our change will be incorporated into the compiled version of the software: - -Open the file `node/src/node.cc` in your favorite [text editor][24] (vim, nano, gedit, … ). And try to locate that fragment of code: - -``` - if (debug_options.ParseOption(argv[0], arg)) { - // Done, consumed by DebugOptions::ParseOption(). - } else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) { - printf("%s\n", NODE_VERSION); - exit(0); - } else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) { - PrintHelp(); - exit(0); - } -``` - -It is around [line 3830 of the file][25]. Then modify the line containing `printf` to match that one instead: - -``` - printf("%s (compiled by myself)\n", NODE_VERSION); -``` - -Then head back to your terminal. Before going further— and to give you some more insight of the power behind git— you can check if you’ve modified the right file: - -``` -diff --git a/src/node.cc b/src/node.cc -index bbce1022..a5618b57 100644 ---- a/src/node.cc -+++ b/src/node.cc -@@ -3828,7 +3828,7 @@ static void ParseArgs(int* argc, - if (debug_options.ParseOption(argv[0], arg)) { - // Done, consumed by DebugOptions::ParseOption(). - } else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) { -- printf("%s\n", NODE_VERSION); -+ printf("%s (compiled by myself)\n", NODE_VERSION); - exit(0); - } else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) { - PrintHelp(); -``` - -You should see a “-” (minus sign) before the line as it was before you changed it. And a “+” (plus sign) before the line after your changes. - -It is now time to recompile and re-install your software: - -``` -make -j9 && sudo make install && echo ok -[...] -ok -``` - -This times, the only reason it might fail is that you’ve made a typo while changing the code. If this is the case, re-open the `node/src/node.cc` file in your text editor and fix the mistake. - -Once you’ve managed to compile and install that new modified NodeJS version, you will be able to check if your modifications were actually incorporated into the software: - -``` -itsfoss@debian:~/node$ /opt/node/bin/node --version -v8.1.1 (compiled by myself) -``` - -Congratulations! You’ve made your first change to an open-source program! - -### D. Let the shell locate our custom build software - -You may have noticed until now, I always launched my newly compiled NodeJS software by specifying the absolute path to the binary file. - -``` -/opt/node/bin/node -``` - -It works. But this is annoying, to say the least. There are actually two common ways of fixing that. But to understand them, you must first know your shell locates the executable files by looking for them only into the directories specified by the `PATH` [environment variable][26]. - -``` -itsfoss@debian:~/node$ echo $PATH -/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games -``` - -Here, on that Debian system, if you do not specify explicitly any directory as part of a command name, the shell will first look for that executable programs into `/usr/local/bin`, then if not found into `/usr/bin`, then if not found into `/bin` then if not found into `/usr/local/games` then if not found into `/usr/games`, then if not found … the shell will report an error  _“command not found”_ . - -Given that, we have two way to make a command accessible to the shell: by adding it to one of the already configured `PATH` directories. Or by adding the directory containing our executable file to the `PATH`. - -### Adding a link from /usr/local/bin - -Just  _copying_  the node binary executable from `/opt/node/bin` to `/usr/local/bin` would be a bad idea since by doing so, the executable program would no longer be able to locate the other required components belonging to `/opt/node/` (it’s a common practice for a software to locate its resource files relative to its own location). - -So, the traditional way of doing that is by using a symbolic link: - -``` -itsfoss@debian:~/node$ sudo ln -sT /opt/node/bin/node /usr/local/bin/node -itsfoss@debian:~/node$ which -a node || echo not found -/usr/local/bin/node -itsfoss@debian:~/node$ node --version -v8.1.1 (compiled by myself) -``` - -This is a simple and effective solution, especially if a software package is made of just few well known executable programs— since you have to create a symbolic link for each and every user-invokable commands. For example, if you’re familiar with NodeJS, you know the `npm` companion application I should symlink from `/usr/local/bin` too. But I let that to you as an exercise. - -### Modifying the PATH - -First, if you tried the preceding solution, remove the node symbolic link created previously to start from a clear state: - -``` -itsfoss@debian:~/node$ sudo rm /usr/local/bin/node -itsfoss@debian:~/node$ which -a node || echo not found -not found -``` - -And now, here is the magic command to change your `PATH`: - -``` -itsfoss@debian:~/node$ export PATH="/opt/node/bin:${PATH}" -itsfoss@debian:~/node$ echo $PATH -/opt/node/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games -``` - -Simply said, I replaced the content of the `PATH` environment variable by its previous content, but prefixed by `/opt/node/bin`. So, as you can imagine it now, the shell will look first into the `/opt/node/bin` directory for executable programs. We can confirm that using the `which` command: - -``` -itsfoss@debian:~/node$ which -a node || echo not found -/opt/node/bin/node -itsfoss@debian:~/node$ node --version -v8.1.1 (compiled by myself) -``` - -Whereas the “link” solution is permanent as soon as you’ve created the symbolic link into `/usr/local/bin`, the `PATH` change is effective only into the current shell. I let you do some researches by yourself to know how to make changes of the `PATH` permanents. As a hint, it has to do with your “profile”. If you find the solution, don’t hesitate to share that with the other readers by using the comment section below! - -### E. How to remove that newly installed software from source code - -Since our custom compiled NodeJS software sits completely in the `/opt/node-v8.1.1` directory, removing that software is not more work than using the `rm` command to remove that directory: - -``` -sudo rm -rf /opt/node-v8.1.1 -``` - -BEWARE: `sudo` and `rm -rf` are a dangerous cocktail! Always check your command twice before pressing the “enter” key. You won’t have any confirmation message and no undelete if you remove the wrong directory… - -Then, if you’ve modified your `PATH`, you will have to revert those changes. Which is not complicated at all. - -And if you’ve created links from `/usr/local/bin` you will have to remove them all: - -``` -itsfoss@debian:~/node$ sudo find /usr/local/bin \ - -type l \ - -ilname "/opt/node/*" \ - -print -delete -/usr/local/bin/node -``` - -### Wait? Where was the Dependency Hell? - -As a final comment, if you read about compiling your own custom software, you might have heard about the [dependency hell][27]. This is a nickname for that annoying situation where before being able to successfully compile a software, you must first compile a pre-requisite library, which in its turn requires another library that might in its turn be incompatible with some other software you’ve already installed. - -Part of the job of the package maintainers of your distribution is to actually resolve that dependency hell and to ensure the various software of your system are using compatible libraries and are installed in the right order. - -In that article, I chose on purpose to install NodeJS as it virtually doesn’t have dependencies. I said “virtually” because, in fact, it  _has_  dependencies. But the source code of those dependencies are present in the source repository of the project (in the `node/deps` subdirectory), so you don’t have to download and install them manually before hand. - -But if you’re interested in understanding more about that problem and learn how to deal with it, let me know that using the comment section below: that would be a great topic for a more advanced article! - --------------------------------------------------------------------------------- - -作者简介: - -Engineer by Passion, Teacher by Vocation. My goals : to share my enthusiasm for what I teach and prepare my students to develop their skills by themselves. You can find me on my website as well. - --------------------- - -via: https://itsfoss.com/install-software-from-source-code/ - -作者:[Sylvain Leroux ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://itsfoss.com/author/sylvain/ -[1]:https://itsfoss.com/author/sylvain/ -[2]:https://itsfoss.com/install-software-from-source-code/#comments -[3]:https://www.facebook.com/share.php?u=https%3A%2F%2Fitsfoss.com%2Finstall-software-from-source-code%2F%3Futm_source%3Dfacebook%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare -[4]:https://twitter.com/share?original_referer=/&text=How+to+Install+Software+from+Source+Code%E2%80%A6+and+Remove+it+Afterwards&url=https://itsfoss.com/install-software-from-source-code/%3Futm_source%3Dtwitter%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare&via=Yes_I_Know_IT -[5]:https://plus.google.com/share?url=https%3A%2F%2Fitsfoss.com%2Finstall-software-from-source-code%2F%3Futm_source%3DgooglePlus%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare -[6]:https://www.linkedin.com/cws/share?url=https%3A%2F%2Fitsfoss.com%2Finstall-software-from-source-code%2F%3Futm_source%3DlinkedIn%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare -[7]:https://www.reddit.com/submit?url=https://itsfoss.com/install-software-from-source-code/&title=How+to+Install+Software+from+Source+Code%E2%80%A6+and+Remove+it+Afterwards -[8]:https://itsfoss.com/remove-install-software-ubuntu/ -[9]:https://nodejs.org/en/ -[10]:https://github.com/nodejs/node -[11]:https://en.wikipedia.org/wiki/GitHub -[12]:https://en.wikipedia.org/wiki/Git -[13]:https://en.wikipedia.org/wiki/Version_control -[14]:https://stackoverflow.com/questions/1457103/how-is-a-tag-different-from-a-branch-which-should-i-use-here -[15]:https://en.wikipedia.org/wiki/Graphical_user_interface -[16]:https://en.wikipedia.org/wiki/GNU_Build_System -[17]:https://en.wikipedia.org/wiki/Make_%28software -[18]:https://itsfoss.com/pro-vim-tips/ -[19]:http://www.pathname.com/fhs/ -[20]:https://en.wikipedia.org/wiki/C%2B%2B -[21]:https://en.wikipedia.org/wiki/Compiler -[22]:https://packages.debian.org/sid/build-essential -[23]:https://superuser.com/questions/590808/yum-install-gcc-g-doesnt-work-anymore-in-centos-6-4 -[24]:https://en.wikipedia.org/wiki/List_of_text_editors -[25]:https://github.com/nodejs/node/blob/v8.1.1/src/node.cc#L3830 -[26]:https://en.wikipedia.org/wiki/Environment_variable -[27]:https://en.wikipedia.org/wiki/Dependency_hell From 9d3d033ea5d0e98e24d737ebca3be67533f68980 Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Wed, 29 Nov 2017 16:26:16 +0800 Subject: [PATCH 028/344] Translating by qhwdw Translating by qhwdw --- sources/tech/20171124 An introduction to the Django ORM.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171124 An introduction to the Django ORM.md b/sources/tech/20171124 An introduction to the Django ORM.md index 727df3f7b0..4a183ce6c1 100644 --- a/sources/tech/20171124 An introduction to the Django ORM.md +++ b/sources/tech/20171124 An introduction to the Django ORM.md @@ -1,3 +1,4 @@ +Translating by qhwdw An introduction to the Django ORM ============================================================ From 6ad3174ef81a3d86d3d30308987b4ee454858f1d Mon Sep 17 00:00:00 2001 From: kimii <2545489745@qq.com> Date: Wed, 29 Nov 2017 16:38:02 +0800 Subject: [PATCH 029/344] Delete 20161216 Kprobes Event Tracing on ARMv8.md --- ...20161216 Kprobes Event Tracing on ARMv8.md | 334 ------------------ 1 file changed, 334 deletions(-) delete mode 100644 sources/tech/20161216 Kprobes Event Tracing on ARMv8.md diff --git a/sources/tech/20161216 Kprobes Event Tracing on ARMv8.md b/sources/tech/20161216 Kprobes Event Tracing on ARMv8.md deleted file mode 100644 index e27290531c..0000000000 --- a/sources/tech/20161216 Kprobes Event Tracing on ARMv8.md +++ /dev/null @@ -1,334 +0,0 @@ -Translating by kimii -# Kprobes Event Tracing on ARMv8 - -![core-dump](http://www.linaro.org/wp-content/uploads/2016/02/core-dump.png) - -### Introduction - -Kprobes is a kernel feature that allows instrumenting the kernel by setting arbitrary breakpoints that call out to developer-supplied routines before and after the breakpointed instruction is executed (or simulated). See the kprobes documentation[[1]][2] for more information. Basic kprobes functionality is selected withCONFIG_KPROBES. Kprobes support was added to mainline for arm64 in the v4.8 release. - -In this article we describe the use of kprobes on arm64 using the debugfs event tracing interfaces from the command line to collect dynamic trace events. This feature has been available for some time on several architectures (including arm32), and is now available on arm64\. The feature allows use of kprobes without having to write any code. - -### Types of Probes - -The kprobes subsystem provides three different types of dynamic probes described below. - -### Kprobes - -The basic probe is a software breakpoint kprobes inserts in place of the instruction you are probing, saving the original instruction for eventual single-stepping (or simulation) when the probe point is hit. - -### Kretprobes - -Kretprobes is a part of kprobes that allows intercepting a returning function instead of having to set a probe (or possibly several probes) at the return points. This feature is selected whenever kprobes is selected, for supported architectures (including ARMv8). - -### Jprobes - -Jprobes allows intercepting a call into a function by supplying an intermediary function with the same calling signature, which will be called first. Jprobes is a programming interface only and cannot be used through the debugfs event tracing subsystem. As such we will not be discussing jprobes further here. Consult the kprobes documentation if you wish to use jprobes. - -### Invoking Kprobes - -Kprobes provides a set of APIs which can be called from kernel code to set up probe points and register functions to be called when probe points are hit. Kprobes is also accessible without adding code to the kernel, by writing to specific event tracing debugfs files to set the probe address and information to be recorded in the trace log when the probe is hit. The latter is the focus of what this document will be talking about. Lastly kprobes can be accessed through the perf command. - -### Kprobes API - -The kernel developer can write functions in the kernel (often done in a dedicated debug module) to set probe points and take whatever action is desired right before and right after the probed instruction is executed. This is well documented in kprobes.txt. - -### Event Tracing - -The event tracing subsystem has its own documentation[[2]][3] which might be worth a read to understand the background of event tracing in general. The event tracing subsystem serves as a foundation for both tracepoints and kprobes event tracing. The event tracing documentation focuses on tracepoints, so bear that in mind when consulting that documentation. Kprobes differs from tracepoints in that there is no predefined list of tracepoints but instead arbitrary dynamically created probe points that trigger the collection of trace event information. The event tracing subsystem is controlled and monitored through a set of debugfs files. Event tracing (CONFIG_EVENT_TRACING) will be selected automatically when needed by something like the kprobe event tracing subsystem. - -#### Kprobes Events - -With the kprobes event tracing subsystem the user can specify information to be reported at arbitrary breakpoints in the kernel, determined simply by specifying the address of any existing probeable instruction along with formatting information. When that breakpoint is encountered during execution kprobes passes the requested information to the common parts of the event tracing subsystem which formats and appends the data to the trace log, much like how tracepoints works. Kprobes uses a similar but mostly separate collection of debugfs files to control and display trace event information. This feature is selected withCONFIG_KPROBE_EVENT. The kprobetrace documentation[[3]][4] provides the essential information on how to use kprobes event tracing and should be consulted to understand details about the examples presented below. - -### Kprobes and Perf - -The perf tools provide another command line interface to kprobes. In particular “perf probe” allows probe points to be specified by source file and line number, in addition to function name plus offset, and address. The perf interface is really a wrapper for using the debugfs interface for kprobes. - -### Arm64 Kprobes - -All of the above aspects of kprobes are now implemented for arm64, in practice there are some differences from other architectures though: - -* Register name arguments are, of course, architecture specific and can be found in the ARM ARM. - -* Not all instruction types can currently be probed. Currently unprobeable instructions include mrs/msr(except DAIF read), exception generation instructions, eret, and hint (except for the nop variant). In these cases it is simplest to just probe a nearby instruction instead. These instructions are blacklisted from probing because the changes they cause to processor state are unsafe to do during kprobe single-stepping or instruction simulation, because the single-stepping context kprobes constructs is inconsistent with what the instruction needs, or because the instruction can’t tolerate the additional processing time and exception handling in kprobes (ldx/stx). -* An attempt is made to identify instructions within a ldx/stx sequence and prevent probing, however it is theoretically possible for this check to fail resulting in allowing a probed atomic sequence which can never succeed. Be careful when probing around atomic code sequences. -* Note that because of the details of Linux ARM64 calling conventions it is not possible to reliably duplicate the stack frame for the probed function and for that reason no attempt is made to do so with jprobes, unlike the majority of other architectures supporting jprobes. The reason for this is that there is insufficient information for the callee to know for certain the amount of the stack that is needed. - -* Note that the stack pointer information recorded from a probe will reflect the particular stack pointer in use at the time the probe was hit, be it the kernel stack pointer or the interrupt stack pointer. -* There is a list of kernel functions which cannot be probed, usually because they are called as part of kprobes processing. Part of this list is architecture-specific and also includes things like exception entry code. - -### Using Kprobes Event Tracing - -One common use case for kprobes is instrumenting function entry and/or exit. It is particularly easy to install probes for this since one can just use the function name for the probe address. Kprobes event tracing will look up the symbol name and determine the address. The ARMv8 calling standard defines where the function arguments and return values can be found, and these can be printed out as part of the kprobe event processing. - -### Example: Function entry probing - -Instrumenting a USB ethernet driver reset function: - -``` -_$ pwd -/sys/kernel/debug/tracing -$ cat > kprobe_events < events/kprobes/enable_ -``` - -At this point a trace event will be recorded every time the driver’s _ax8872_reset()_ function is called. The event will display the pointer to the _usbnet_ structure passed in via X0 (as per the ARMv8 calling standard) as this function’s only argument. After plugging in a USB dongle requiring this ethernet driver we see the following trace information: - -``` -_$ cat trace -# tracer: nop -# -# entries-in-buffer/entries-written: 1/1   #P:8 -# -#                           _—–=> irqs-off -#                          / _—-=> need-resched -#                         | / _—=> hardirq/softirq -#                         || / _–=> preempt-depth -#                         ||| / delay -#        TASK-PID   CPU#  |||| TIMESTAMP  FUNCTION -#           | |    |   ||||    |      | -kworker/0:0-4             [000] d… 10972.102939:   p_ax88772_reset_0: -(ax88772_reset+0x0/0x230)   arg1=0xffff800064824c80_ -``` - -Here we can see the value of the pointer argument passed in to our probed function. Since we did not use the optional labelling features of kprobes event tracing the information we requested is automatically labeled_arg1_.  Note that this refers to the first value in the list of values we requested that kprobes log for this probe, not the actual position of the argument to the function. In this case it also just happens to be the first argument to the function we’ve probed. - -### Example: Function entry and return probing - -The kretprobe feature is used specifically to probe a function return. At function entry the kprobes subsystem will be called and will set up a hook to be called at function return, where it will record the requested event information. For the most common case the return information, typically in the X0 register, is quite useful. The return value in %x0 can also be referred to as _$retval_. The following example also demonstrates how to provide a human-readable label to be displayed with the information of interest. - -Example of instrumenting the kernel __do_fork()_ function to record arguments and results using a kprobe and a kretprobe: - -``` -_$ cd /sys/kernel/debug/tracing -$ cat > kprobe_events < events/kprobes/enable_ -``` - -At this point every call to _do_fork() will produce two kprobe events recorded into the “_trace_” file, one reporting the calling argument values and one reporting the return value. The return value shall be labeled “_pid_” in the trace file. Here are the contents of the trace file after three fork syscalls have been made: - -``` -_$ cat trace -# tracer: nop -# -# entries-in-buffer/entries-written: 6/6   #P:8 -# -#                              _—–=> irqs-off -#                             / _—-=> need-resched -#                            | / _—=> hardirq/softirq -#                            || / _–=> preempt-depth -#                            ||| /     delay -#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION -#              | |       |   ||||       |         | -              bash-1671  [001] d…   204.946007: p__do_fork_0: (_do_fork+0x0/0x3e4) arg1=0x1200011 arg2=0x0 arg3=0x0 arg4=0x0 arg5=0xffff78b690d0 arg6=0x0 -              bash-1671  [001] d..1   204.946391: r__do_fork_0: (SyS_clone+0x18/0x20 <- _do_fork) pid=0x724 -              bash-1671  [001] d…   208.845749: p__do_fork_0: (_do_fork+0x0/0x3e4) arg1=0x1200011 arg2=0x0 arg3=0x0 arg4=0x0 arg5=0xffff78b690d0 arg6=0x0 -              bash-1671  [001] d..1   208.846127: r__do_fork_0: (SyS_clone+0x18/0x20 <- _do_fork) pid=0x725 -              bash-1671  [001] d…   214.401604: p__do_fork_0: (_do_fork+0x0/0x3e4) arg1=0x1200011 arg2=0x0 arg3=0x0 arg4=0x0 arg5=0xffff78b690d0 arg6=0x0 -              bash-1671  [001] d..1   214.401975: r__do_fork_0: (SyS_clone+0x18/0x20 <- _do_fork) pid=0x726_ -``` - -### Example: Dereferencing pointer arguments - -For pointer values the kprobe event processing subsystem also allows dereferencing and printing of desired memory contents, for various base data types. It is necessary to manually calculate the offset into structures in order to display a desired field. - -Instrumenting the `_do_wait()` function: - -``` -_$ cat > kprobe_events < events/kprobes/enable_ -``` - -Note that the argument labels used in the first probe are optional and can be used to more clearly identify the information recorded in the trace log. The signed offset and parentheses indicate that the register argument is a pointer to memory contents to be recorded in the trace log. The “_:u32_” indicates that the memory location contains an unsigned four-byte wide datum (an enum and an int in a locally defined structure in this case). - -The probe labels (after the colon) are optional and will be used to identify the probe in the log. The label must be unique for each probe. If unspecified a useful label will be automatically generated from a nearby symbol name, as has been shown in earlier examples. - -Also note the “_$retval_” argument could just be specified as “_%x0_“. - -Here are the contents of the “_trace_” file after two fork syscalls have been made: - -``` -_$ cat trace -# tracer: nop -# -# entries-in-buffer/entries-written: 4/4   #P:8 -# -#                              _—–=> irqs-off -#                             / _—-=> need-resched -#                            | / _—=> hardirq/softirq -#                            || / _–=> preempt-depth -#                            ||| /     delay -#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION -#              | |       |   ||||       |         | -             bash-1702  [001] d…   175.342074: wait_p: (do_wait+0x0/0x260) wo_type=0x3 wo_flags=0xe -             bash-1702  [002] d..1   175.347236: wait_r: (SyS_wait4+0x74/0xe4 <- do_wait) arg1=0x757 -             bash-1702  [002] d…   175.347337: wait_p: (do_wait+0x0/0x260) wo_type=0x3 wo_flags=0xf -             bash-1702  [002] d..1   175.347349: wait_r: (SyS_wait4+0x74/0xe4 <- do_wait) arg1=0xfffffffffffffff6_ -``` - -### Example: Probing arbitrary instruction addresses - -In previous examples we have inserted probes for function entry and exit, however it is possible to probe an arbitrary instruction (with a few exceptions). If we are placing a probe inside a C function the first step is to look at the assembler version of the code to identify where we want to place the probe. One way to do this is to use gdb on the vmlinux file and display the instructions in the function where you wish to place the probe. An example of doing this for the _module_alloc_ function in arch/arm64/kernel/modules.c follows. In this case, because gdb seems to prefer using the weak symbol definition and it’s associated stub code for this function, we get the symbol value from System.map instead: - -``` -_$ grep module_alloc System.map -ffff2000080951c4 T module_alloc -ffff200008297770 T kasan_module_alloc_ -``` - -In this example we’re using cross-development tools and we invoke gdb on our host system to examine the instructions comprising our function of interest: - -``` -_$ ${CROSS_COMPILE}gdb vmlinux -(gdb) x/30i 0xffff2000080951c4 -        0xffff2000080951c4 :    sub    sp, sp, #0x30 -        0xffff2000080951c8 :    adrp    x3, 0xffff200008d70000 -        0xffff2000080951cc :    add    x3, x3, #0x0 -        0xffff2000080951d0 :    mov    x5, #0x713             // #1811 -        0xffff2000080951d4 :    mov    w4, #0xc0              // #192 -        0xffff2000080951d8 : -              mov    x2, #0xfffffffff8000000    // #-134217728 -        0xffff2000080951dc :    stp    x29, x30, [sp,#16]         0xffff2000080951e0 :    add    x29, sp, #0x10 -        0xffff2000080951e4 :    movk    x5, #0xc8, lsl #48 -        0xffff2000080951e8 :    movk    w4, #0x240, lsl #16 -        0xffff2000080951ec :    str    x30, [sp]         0xffff2000080951f0 :    mov    w7, #0xffffffff        // #-1 -        0xffff2000080951f4 :    mov    x6, #0x0               // #0 -        0xffff2000080951f8 :    add    x2, x3, x2 -        0xffff2000080951fc :    mov    x1, #0x8000            // #32768 -        0xffff200008095200 :    stp    x19, x20, [sp,#32]         0xffff200008095204 :    mov    x20, x0 -        0xffff200008095208 :    bl    0xffff2000082737a8 <__vmalloc_node_range> -        0xffff20000809520c :    mov    x19, x0 -        0xffff200008095210 :    cbz    x0, 0xffff200008095234 -        0xffff200008095214 :    mov    x1, x20 -        0xffff200008095218 :    bl    0xffff200008297770 -        0xffff20000809521c :    tbnz    w0, #31, 0xffff20000809524c -        0xffff200008095220 :    mov    sp, x29 -        0xffff200008095224 :    mov    x0, x19 -        0xffff200008095228 :    ldp    x19, x20, [sp,#16]         0xffff20000809522c :    ldp    x29, x30, [sp],#32 -        0xffff200008095230 :    ret -        0xffff200008095234 :    mov    sp, x29 -        0xffff200008095238 :    mov    x19, #0x0               // #0_ -``` - -In this case we are going to display the result from the following source line in this function: - -``` -_p = __vmalloc_node_range(size, MODULE_ALIGN, VMALLOC_START, -VMALLOC_END, GFP_KERNEL, PAGE_KERNEL_EXEC, 0, -NUMA_NO_NODE, __builtin_return_address(0));_ -``` - -…and also the return value from the function call in this line: - -``` -_if (p && (kasan_module_alloc(p, size) < 0)) {_ -``` - -We can identify these in the assembler code from the call to the external functions. To display these values we will place probes at 0xffff20000809520c _and _0xffff20000809521c on our target system: - -``` -_$ cat > kprobe_events < events/kprobes/enable_ -``` - -Now after plugging an ethernet adapter dongle into the USB port we see the following written into the trace log: - -``` -_$ cat trace -# tracer: nop -# -# entries-in-buffer/entries-written: 12/12   #P:8 -# -#                           _—–=> irqs-off -#                          / _—-=> need-resched -#                         | / _—=> hardirq/softirq -#                         || / _–=> preempt-depth -#                         ||| / delay -#        TASK-PID   CPU#  |||| TIMESTAMP  FUNCTION -#           | |    |   ||||    |      | -      systemd-udevd-2082  [000] d… 77.200991: p_0xffff20000809520c: (module_alloc+0x48/0x98) arg1=0xffff200001188000 -      systemd-udevd-2082  [000] d… 77.201059: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0 -      systemd-udevd-2082  [000] d… 77.201115: p_0xffff20000809520c: (module_alloc+0x48/0x98) arg1=0xffff200001198000 -      systemd-udevd-2082  [000] d… 77.201157: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0 -      systemd-udevd-2082  [000] d… 77.227456: p_0xffff20000809520c: (module_alloc+0x48/0x98) arg1=0xffff2000011a0000 -      systemd-udevd-2082  [000] d… 77.227522: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0 -      systemd-udevd-2082  [000] d… 77.227579: p_0xffff20000809520c: (module_alloc+0x48/0x98) arg1=0xffff2000011b0000 -      systemd-udevd-2082  [000] d… 77.227635: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0 -      modprobe-2097  [002] d… 78.030643: p_0xffff20000809520c: (module_alloc+0x48/0x98) arg1=0xffff2000011b8000 -      modprobe-2097  [002] d… 78.030761: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0 -      modprobe-2097  [002] d… 78.031132: p_0xffff20000809520c: (module_alloc+0x48/0x98) arg1=0xffff200001270000 -      modprobe-2097  [002] d… 78.031187: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0_ -``` - -One more feature of the kprobes event system is recording of statistics information, which can be found inkprobe_profile.  After the above trace the contents of that file are: - -``` -_$ cat kprobe_profile - p_0xffff20000809520c                                    6            0 -p_0xffff20000809521c                                    6            0_ -``` - -This indicates that there have been a total of 8 hits each of the two breakpoints we set, which of course is consistent with the trace log data.  More kprobe_profile features are described in the kprobetrace documentation. - -There is also the ability to further filter kprobes events.  The debugfs files used to control this are listed in the kprobetrace documentation while the details of their contents are (mostly) described in the trace events documentation. - -### Conclusion - -Linux on ARMv8 now is on parity with other architectures supporting the kprobes feature. Work is being done by others to also add uprobes and systemtap support. These features/tools and other already completed features (e.g.: perf, coresight) allow the Linux ARMv8 user to debug and test performance as they would on other, older architectures. - -* * * - -Bibliography - -[[1]][5] Jim Keniston, Prasanna S. Panchamukhi, Masami Hiramatsu. “Kernel Probes (Kprobes).” _GitHub_. GitHub, Inc., 15 Aug. 2016\. Web. 13 Dec. 2016. - -[[2]][6] Ts’o, Theodore, Li Zefan, and Tom Zanussi. “Event Tracing.” _GitHub_. GitHub, Inc., 3 Mar. 2016\. Web. 13 Dec. 2016. - -[[3]][7] Hiramatsu, Masami. “Kprobe-based Event Tracing.” _GitHub_. GitHub, Inc., 18 Aug. 2016\. Web. 13 Dec. 2016. - - ----------------- - -作者简介 : [David Long][8]David works as an engineer in the Linaro Kernel - Core Development team. Before coming to Linaro he spent several years in the commercial and defense industries doing both embedded realtime work, and software development tools for Unix. That was followed by a dozen years at Digital (aka Compaq) doing Unix standards, C compiler, and runtime library work. After that David went to a series of startups doing embedded Linux and Android, embedded custom OS's, and Xen virtualization. He has experience with MIPS, Alpha, and ARM platforms (amongst others). He has used most flavors of Unix starting in 1979 with Bell Labs V6, and has been a long-time Linux user and advocate. He has also occasionally been known to debug a device driver with a soldering iron and digital oscilloscope. - --------------------------------------------------------------------------------- - -via: http://www.linaro.org/blog/kprobes-event-tracing-armv8/ - -作者:[ David Long][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://www.linaro.org/author/david-long/ -[1]:http://www.linaro.org/blog/kprobes-event-tracing-armv8/# -[2]:https://github.com/torvalds/linux/blob/master/Documentation/kprobes.txt -[3]:https://github.com/torvalds/linux/blob/master/Documentation/trace/events.txt -[4]:https://github.com/torvalds/linux/blob/master/Documentation/trace/kprobetrace.txt -[5]:https://github.com/torvalds/linux/blob/master/Documentation/kprobes.txt -[6]:https://github.com/torvalds/linux/blob/master/Documentation/trace/events.txt -[7]:https://github.com/torvalds/linux/blob/master/Documentation/trace/kprobetrace.txt -[8]:http://www.linaro.org/author/david-long/ -[9]:http://www.linaro.org/blog/kprobes-event-tracing-armv8/#comments -[10]:http://www.linaro.org/blog/kprobes-event-tracing-armv8/# -[11]:http://www.linaro.org/tag/arm64/ -[12]:http://www.linaro.org/tag/armv8/ -[13]:http://www.linaro.org/tag/jprobes/ -[14]:http://www.linaro.org/tag/kernel/ -[15]:http://www.linaro.org/tag/kprobes/ -[16]:http://www.linaro.org/tag/kretprobes/ -[17]:http://www.linaro.org/tag/perf/ -[18]:http://www.linaro.org/tag/tracing/ From 63bee82a62550370735f7533990982ce53a4e92e Mon Sep 17 00:00:00 2001 From: kimii <2545489745@qq.com> Date: Wed, 29 Nov 2017 16:40:41 +0800 Subject: [PATCH 030/344] Create 20161216 Kprobes Event Tracing on ARMv8.md --- translated/tech/20161216 Kprobes Event Tracing on ARMv8.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 translated/tech/20161216 Kprobes Event Tracing on ARMv8.md diff --git a/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md b/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md @@ -0,0 +1 @@ + From aecccb2848d15cb8959862d35b93411ab199638a Mon Sep 17 00:00:00 2001 From: cmn <2545489745@qq.com> Date: Wed, 29 Nov 2017 16:43:38 +0800 Subject: [PATCH 031/344] upload translate --- ...20161216 Kprobes Event Tracing on ARMv8.md | 336 ++++++++++++++++++ 1 file changed, 336 insertions(+) diff --git a/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md b/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md index 8b13789179..d4edaf76bd 100644 --- a/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md +++ b/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md @@ -1 +1,337 @@ +# Kprobes Event Tracing on ARMv8 + +![core-dump](http://www.linaro.org/wp-content/uploads/2016/02/core-dump.png) + +### 介绍 + +Kprobes 是一种内核功能,它允许通过在执行(或模拟)断点指令之前和之后,设置调用开发者提供例程的任意断点来检测内核。可参见 kprobes 文档[[1]][2] 获取更多信息。基本的 kprobes 功能可使用 CONFIG_KPROBEES 来选择。在 arm64 的 v4.8 发行版中, kprobes 支持被添加到主线。 + +在这篇文章中,我们将介绍 kprobes 在 arm64 上的使用,通过在命令行中使用 debugfs 事件追踪接口来收集动态追踪事件。这个功能在一些架构(包括 arm32)上可用已经有段时间,现在在 arm64 上也能使用了。这个功能允许使用 kprobes 而无需编写任何代码。 + +### 探针类型 + +Kprbes 子系统提供了三种不同类型的动态探针,如下所述。 + +### Kprobes + +基本探针是 kprobes 插入的一个软件断点,用以替代你正在探测的指令,当探测点被击中时,它为最终的单步执行(或模拟)保存下原始指令。 + +### Kretprobes + +Kretprobes 是 kprobes 的一部分,它允许拦截返回函数,而不必在返回点设置一个探针(或者可能有多个)。对于支持的架构(包括 ARMv8),只要选择 kprobes,就可以选择此功能。 + +### Jprobes + +Jprobes 允许通过提供一个具有相同调用签名(call signature)的中间函数来拦截对一个函数的调用,这里中间函数将被首先调用。Jprobes 只是一个编程接口,它不能通过 debugfs 事件追踪子系统来使用。因此,我们将不会在这里进一步讨论 jprobes。如果你想使用 jprobes,请参考 kprobes 文档。 + +### 调用 Kprobes + +Kprobes 提供一系列能从内核代码中调用的 API 来设置探测点和当探测点被击中时调用的注册函数。在不往内核中添加代码的情况下,Kprobes 也是可用的,这是通过写入特定事件追踪的 debugfs 文件来实现的,需要在文件中设置探针地址和信息,以便在探针被击中时记录到追踪日志中。后者是本文将要讨论的重点。最后 Kprobes 可以通过 perl 命令来使用。 + +### Kprobes API + +内核开发人员可以在内核中编写函数(通常在专用的调试模块中完成)来设置探测点,并且在探测指令执行前和执行后立即执行任何所需操作。这在 kprobes.txt 中有很好的解释。 + +### 事件追踪 + +事件追踪子系统有自己的自己的文档[[2]][3],对于了解一般追踪事件的背景可能值得一读。事件追踪子系统是追踪点(tracepoints)和 kprobes 事件追踪的基础。事件追踪文档重点关注追踪点,所以请在查阅文档时记住这一点。Kprobes 与追踪点不同的是没有预定义的追踪点列表,而是采用动态创建的用于触发追踪事件信息收集的任意探测点。事件追踪子系统通过一系列 debugfs 文件来控制和监视。事件追踪(CONFIG_EVENT_TRACING)将在被如 kprobe 事件追踪子系统等需要时自动选择。 + +#### Kprobes 事件 + +使用 kprobes 事件追踪子系统,用户可以在内核任意断点处指定要报告的信息,只需要指定任意现有可探测指令的地址以及格式化信息即可确定。在执行过程中遇到断点时,kprobes 将所请求的信息传递给事件追踪子系统的公共部分,这些部分将数据格式化并追加到追踪日志中,就像追踪点的工作方式一样。Kprobes 使用一个类似的但是大部分是独立的 debugfs 文件来控制和显示追踪事件信息。该功能可使用 CONFIG_KPROBE_EVENT 来选择。Kprobetrace文档[[3]][4] 提供了如何使用 kprobes 事件追踪的基本信息,并且应当被参考用以了解以下介绍示例的详细信息。 + +### Kprobes 和 Perf + +Perf 工具为 Kprobes 提供了另一个命令行接口。特别地,“perf probe” 允许探测点除了由函数名加偏移量和地址指定外,还可由源文件和行号指定。Perf 接口实际上是使用 kprobes 的 debugfs 接口的封装器。 + +### Arm64 Kprobes + +上述所有 kprobes 的方面现在都在 arm64 上得到实现,然而实际上与其它架构上的有一些不同: + +* 注册名称参数当然是依架构而特定的,并且可以在 ARM ARM 中找到。 + +* 目前不是所有的指令类型都可被探测。当前不可探测的指令包括 mrs/msr(除了 DAIF 读),异常生成指令,eret 和 hint(除了 nop 变体)。在这些情况下,只探测一个附近的指令来代替是最简单的。这些指令在探测的黑名单里是因为在 kprobes 单步执行或者指令模拟时它们对处理器状态造成的改变是不安全的,这是由于 kprobes 构造的单步执行上下文和指令所需要的不一致,或者是由于指令不能容忍在 kprobes 中额外的处理时间和异常处理(ldx/stx)。 + +* 试图识别在 ldx/stx 序列中的指令并且防止探测,但是理论上这种检查可能会失败,导致允许探测到的原子序列永远不会成功。当探测原子代码序列附近时应该小心。 + +* 注意由于 linux ARM64 调用约定的具体信息,为探测函数可靠地复制栈帧是不可能的,基于此不要试图用 jprobes 这样做,这一点与支持 jprobes 的大多数其它架构不同。这样的原因是被调用者没有足够的信息来确定需要的栈数量。 + +* 注意当探针被击中时,一个探针记录的栈指针信息将反映出使用中的特定栈指针,它是内核栈指针或者中断栈指针。 + +* 有一组内核函数是不能被探测的,通常因为它们作为 kprobes 处理的一部分被调用。这组函数的一部分是依架构特定的,并且也包含如异常入口代码等。 + +### 使用 Kprobes 事件追踪 + +Kprobes 一个常用的例子是检测函数入口和/或出口。因为只需要使用函数名来作为探针地址,它安装探针特别简单。Kprobes 事件追踪将查看符号名称并且确定地址。ARMv8 调用标准定义了函数参数和返回值的位置,并且这些可以作为 kprobes 事件处理的一部分被打印出来。 + +### 例子: 函数入口探测 + +检测 USB 以太网驱动程序复位功能: + +``` +_$ pwd +/sys/kernel/debug/tracing +$ cat > kprobe_events < events/kprobes/enable_ +``` + +此时每次驱动器的 *ax8872_reset()* 函数被调用,追踪事件都将会被记录。这个事件将显示指向通过 作为此函数的唯一参数的 X0(按照 ARMv8 调用标准)传入的 _usbnet_ 结构的指针。插入需要以太网驱动程序的USB加密狗后,我们看见以下追踪信息: + +``` +_$ cat trace +# tracer: nop +# +# entries-in-buffer/entries-written: 1/1 #P:8 +# +# _—–=> irqs-off +# / _—-=> need-resched +# | / _—=> hardirq/softirq +# || / _–=> preempt-depth +# ||| / delay +# TASK-PID CPU# |||| TIMESTAMP FUNCTION +# | | | |||| | | +kworker/0:0-4 [000] d… 10972.102939: p_ax88772_reset_0: +(ax88772_reset+0x0/0x230) arg1=0xffff800064824c80_ +``` + +这里我们可以看见传入到我们的探测函数的指针参数的值。由于我们没有使用 kprobes 事件追踪的可选标签功能,我们需要的信息自动被标注为 _arg1_。注意这个指向我们需要 kprobes 记录这个探针的一组值的第一个,而不是函数参数的实际位置。在这个例子中它也只是碰巧是我们探测函数的第一个参数。 + +### 例子: 函数入口和返回探测 + +Kretprobe 功能专门用于探测函数返回。在函数入口 kprobes 子系统将会被调用并且建立钩子以便在函数返回时调用,钩子将记录需求事件信息。对最常见情况,返回信息通常在 X0 寄存器中,这是非常有用的。在 %x0 中返回值也可以被称为 _$retval_。以下例子也演示了如何提供一个可读的标签来展示有趣的信息。 + +使用 kprobes 和 kretprobe 检测内核 *_do_fork()* 函数来记录参数和结果的例子: + +``` +_$ cd /sys/kernel/debug/tracing +$ cat > kprobe_events < events/kprobes/enable_ +``` + +此时每次对 _do_fork() 的调用都会产生两个记录到 “_trace_” 文件的 kprobe 事件,一个报告调用参数值,另一个报告返回值。返回值在 trace 文件中将被标记为“_pid_”。这里是三次 fork 系统调用执行后的 trace 文件的内容: + +``` +_$ cat trace +# tracer: nop +# +# entries-in-buffer/entries-written: 6/6 #P:8 +# +# _—–=> irqs-off +# / _—-=> need-resched +# | / _—=> hardirq/softirq +# || / _–=> preempt-depth +# ||| / delay +# TASK-PID CPU# |||| TIMESTAMP FUNCTION +# | | | |||| | | + bash-1671 [001] d… 204.946007: p__do_fork_0: (_do_fork+0x0/0x3e4) arg1=0x1200011 arg2=0x0 arg3=0x0 arg4=0x0 arg5=0xffff78b690d0 arg6=0x0 + bash-1671 [001] d..1 204.946391: r__do_fork_0: (SyS_clone+0x18/0x20 <- _do_fork) pid=0x724 + bash-1671 [001] d… 208.845749: p__do_fork_0: (_do_fork+0x0/0x3e4) arg1=0x1200011 arg2=0x0 arg3=0x0 arg4=0x0 arg5=0xffff78b690d0 arg6=0x0 + bash-1671 [001] d..1 208.846127: r__do_fork_0: (SyS_clone+0x18/0x20 <- _do_fork) pid=0x725 + bash-1671 [001] d… 214.401604: p__do_fork_0: (_do_fork+0x0/0x3e4) arg1=0x1200011 arg2=0x0 arg3=0x0 arg4=0x0 arg5=0xffff78b690d0 arg6=0x0 + bash-1671 [001] d..1 214.401975: r__do_fork_0: (SyS_clone+0x18/0x20 <- _do_fork) pid=0x726_ +``` + +### 例子: 解引用指针参数 + +对于指针值,kprobes 事件处理子系统也允许解引用和打印所需的内存内容,适用于各种基本数据类型。为了展示所需字段,手动计算结构的偏移量是必要的。 + +检测 `_do_wait()` 函数: + +``` +_$ cat > kprobe_events < events/kprobes/enable_ +``` + +注意在第一个探针中使用的参数标签是可选的,并且可用于更清晰地识别记录在追踪日志中的信息。带符号的偏移量和括号表明了寄存器参数是指向记录在追踪日志中的内存内容的指针。“_:u32_”表明了内存位置包含一个无符号的4字节宽的数据(在这个例子中指局部定义的结构中的一个 emum 和一个 int) + +探针标签(冒号后)是可选的,并且将用来识别日志中的探针。对每个探针来说标签必须是独一无二的。如果没有指定,将从附近的符号名称自动生成一个有用的标签,如前面的例子所示。 + +也要注意“_$retval_”参数可以只是指定为“_%x0_”。 + +这里是两次 fork 系统调用执行后的 “_trace_” 文件的内容: + +``` +_$ cat trace +# tracer: nop +# +# entries-in-buffer/entries-written: 4/4 #P:8 +# +# _—–=> irqs-off +# / _—-=> need-resched +# | / _—=> hardirq/softirq +# || / _–=> preempt-depth +# ||| / delay +# TASK-PID CPU# |||| TIMESTAMP FUNCTION +# | | | |||| | | + bash-1702 [001] d… 175.342074: wait_p: (do_wait+0x0/0x260) wo_type=0x3 wo_flags=0xe + bash-1702 [002] d..1 175.347236: wait_r: (SyS_wait4+0x74/0xe4 <- do_wait) arg1=0x757 + bash-1702 [002] d… 175.347337: wait_p: (do_wait+0x0/0x260) wo_type=0x3 wo_flags=0xf + bash-1702 [002] d..1 175.347349: wait_r: (SyS_wait4+0x74/0xe4 <- do_wait) arg1=0xfffffffffffffff6_ +``` + +### 例子: 探测任意指令地址 + +在前面的例子中,我们已经为函数的入口和出口插入探针,然而探测一个任意指令(除少数例外)是可能的。如果我们正在 C 函数中放置一个探针,第一步是查看代码的汇编版本以确定我们要放置探针的位置。一种方法是在 vmlinux 文件上使用 gdb,并在要放置探针的函数中展示指令。下面是一个在 arch/arm64/kernel/modules.c 中 _module_alloc_ 函数执行此操作的示例。在这种情况下,因为 gdb 似乎更喜欢使用弱符号定义,并且它是与这个函数关联的存根代码,所以我们从 System.map 中来获取符号值: + +``` +_$ grep module_alloc System.map +ffff2000080951c4 T module_alloc +ffff200008297770 T kasan_module_alloc_ +``` + +在这个例子中我们使用了交叉开发工具,并且在我们的主机系统上调用 gdb 来检查指令包含我们感兴趣函数。 + +``` +_$ ${CROSS_COMPILE}gdb vmlinux +(gdb) x/30i 0xffff2000080951c4 + 0xffff2000080951c4 : sub sp, sp, #0x30 + 0xffff2000080951c8 : adrp x3, 0xffff200008d70000 + 0xffff2000080951cc : add x3, x3, #0x0 + 0xffff2000080951d0 : mov x5, #0x713 // #1811 + 0xffff2000080951d4 : mov w4, #0xc0 // #192 + 0xffff2000080951d8 : + mov x2, #0xfffffffff8000000 // #-134217728 + 0xffff2000080951dc : stp x29, x30, [sp,#16] 0xffff2000080951e0 : add x29, sp, #0x10 + 0xffff2000080951e4 : movk x5, #0xc8, lsl #48 + 0xffff2000080951e8 : movk w4, #0x240, lsl #16 + 0xffff2000080951ec : str x30, [sp] 0xffff2000080951f0 : mov w7, #0xffffffff // #-1 + 0xffff2000080951f4 : mov x6, #0x0 // #0 + 0xffff2000080951f8 : add x2, x3, x2 + 0xffff2000080951fc : mov x1, #0x8000 // #32768 + 0xffff200008095200 : stp x19, x20, [sp,#32] 0xffff200008095204 : mov x20, x0 + 0xffff200008095208 : bl 0xffff2000082737a8 <__vmalloc_node_range> + 0xffff20000809520c : mov x19, x0 + 0xffff200008095210 : cbz x0, 0xffff200008095234 + 0xffff200008095214 : mov x1, x20 + 0xffff200008095218 : bl 0xffff200008297770 + 0xffff20000809521c : tbnz w0, #31, 0xffff20000809524c + 0xffff200008095220 : mov sp, x29 + 0xffff200008095224 : mov x0, x19 + 0xffff200008095228 : ldp x19, x20, [sp,#16] 0xffff20000809522c : ldp x29, x30, [sp],#32 + 0xffff200008095230 : ret + 0xffff200008095234 : mov sp, x29 + 0xffff200008095238 : mov x19, #0x0 // #0_ +``` + +在这种情况下,我们将在此函数中显示以下源代码行的结果: + +``` +_p = __vmalloc_node_range(size, MODULE_ALIGN, VMALLOC_START, +VMALLOC_END, GFP_KERNEL, PAGE_KERNEL_EXEC, 0, +NUMA_NO_NODE, __builtin_return_address(0));_ +``` + +…以及在此代码行的函数调用的返回值: + +``` +_if (p && (kasan_module_alloc(p, size) < 0)) {_ +``` + +我们可以在从调用外部函数的汇编代码中识别这些。为了展示这些值,我们将在目标系统上的0xffff20000809520c 和 0xffff20000809521c 处放置探针。 + +``` +_$ cat > kprobe_events < events/kprobes/enable_ +``` + +现在将一个以太网适配器加密狗插入到 USB 端口后,我们看到以下写入追踪日志的内容: + +``` +_$ cat trace +# tracer: nop +# +# entries-in-buffer/entries-written: 12/12 #P:8 +# +# _—–=> irqs-off +# / _—-=> need-resched +# | / _—=> hardirq/softirq +# || / _–=> preempt-depth +# ||| / delay +# TASK-PID CPU# |||| TIMESTAMP FUNCTION +# | | | |||| | | + systemd-udevd-2082 [000] d… 77.200991: p_0xffff20000809520c: (module_alloc+0x48/0x98) arg1=0xffff200001188000 + systemd-udevd-2082 [000] d… 77.201059: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0 + systemd-udevd-2082 [000] d… 77.201115: p_0xffff20000809520c: (module_alloc+0x48/0x98) arg1=0xffff200001198000 + systemd-udevd-2082 [000] d… 77.201157: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0 + systemd-udevd-2082 [000] d… 77.227456: p_0xffff20000809520c: (module_alloc+0x48/0x98) arg1=0xffff2000011a0000 + systemd-udevd-2082 [000] d… 77.227522: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0 + systemd-udevd-2082 [000] d… 77.227579: p_0xffff20000809520c: (module_alloc+0x48/0x98) arg1=0xffff2000011b0000 + systemd-udevd-2082 [000] d… 77.227635: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0 + modprobe-2097 [002] d… 78.030643: p_0xffff20000809520c: (module_alloc+0x48/0x98) arg1=0xffff2000011b8000 + modprobe-2097 [002] d… 78.030761: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0 + modprobe-2097 [002] d… 78.031132: p_0xffff20000809520c: (module_alloc+0x48/0x98) arg1=0xffff200001270000 + modprobe-2097 [002] d… 78.031187: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0_ +``` + +Kprobes 事件系统的另一个功能是记录统计信息,这可在 inkprobe_profile 中找到。在以上追踪后,该文件的内容为: + +``` +_$ cat kprobe_profile + p_0xffff20000809520c 6 0 +p_0xffff20000809521c 6 0_ +``` + +这表明我们设置的两处断点每个共发生了 8 次击中,这当然与追踪日志数据是一致的。在 kprobetrace 文档中有更多 kprobe_profile 的功能描述。 + +也可以进一步过滤 kprobes 事件。用来控制这点的 debugfs 文件在 kprobetrace 文档中被列出,然而他们内容的详细信息大多在 trace events 文档中被描述。 + +### 总结 + +现在,Linux ARMv8 对支持 kprobes 功能也和其它架构相当。有人正在做添加 uprobes 和 systemtap 支持的工作。这些功能/工具和其他已经完成的功能(如: perf, coresight)允许 Linux ARMv8 用户像在其它更老的架构上一样调试和测试性能。 + +* * * + +参考文献 + +[[1]][5] Jim Keniston, Prasanna S. Panchamukhi, Masami Hiramatsu. “Kernel Probes (Kprobes).” _GitHub_. GitHub, Inc., 15 Aug. 2016\. Web. 13 Dec. 2016. + +[[2]][6] Ts’o, Theodore, Li Zefan, and Tom Zanussi. “Event Tracing.” _GitHub_. GitHub, Inc., 3 Mar. 2016\. Web. 13 Dec. 2016. + +[[3]][7] Hiramatsu, Masami. “Kprobe-based Event Tracing.” _GitHub_. GitHub, Inc., 18 Aug. 2016\. Web. 13 Dec. 2016. + + +---------------- + +作者简介 : [David Long][8] David在 Linaro Kernel - Core Development 团队中担任工程师。 在加入 Linaro 之前,他在商业和国防行业工作了数年,既做嵌入式实时工作又为Unix提供软件开发工具。之后,在 Digital(又名 Compaq)公司工作了十几年,负责 Unix 标准,C 编译器和运行时库的工作。之后 David 又去了一系列初创公司做嵌入式 Linux 和安卓系统,嵌入式定制操作系统和 Xen 虚拟化。他拥有 MIPS,Alpha 和 ARM 平台的经验(等等)。他使用过从 1979 年贝尔实验室 V6 开始的大部分Unix操作系统,并且长期以来一直是 Linux 用户和倡导者。他偶尔也因使用烙铁和数字示波器调试设备驱动而知名。 + +-------------------------------------------------------------------------------- + +via: http://www.linaro.org/blog/kprobes-event-tracing-armv8/ + +作者:[ David Long][a] +译者:[kimii](https://github.com/kimii) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://www.linaro.org/author/david-long/ +[1]:http://www.linaro.org/blog/kprobes-event-tracing-armv8/# +[2]:https://github.com/torvalds/linux/blob/master/Documentation/kprobes.txt +[3]:https://github.com/torvalds/linux/blob/master/Documentation/trace/events.txt +[4]:https://github.com/torvalds/linux/blob/master/Documentation/trace/kprobetrace.txt +[5]:https://github.com/torvalds/linux/blob/master/Documentation/kprobes.txt +[6]:https://github.com/torvalds/linux/blob/master/Documentation/trace/events.txt +[7]:https://github.com/torvalds/linux/blob/master/Documentation/trace/kprobetrace.txt +[8]:http://www.linaro.org/author/david-long/ +[9]:http://www.linaro.org/blog/kprobes-event-tracing-armv8/#comments +[10]:http://www.linaro.org/blog/kprobes-event-tracing-armv8/# +[11]:http://www.linaro.org/tag/arm64/ +[12]:http://www.linaro.org/tag/armv8/ +[13]:http://www.linaro.org/tag/jprobes/ +[14]:http://www.linaro.org/tag/kernel/ +[15]:http://www.linaro.org/tag/kprobes/ +[16]:http://www.linaro.org/tag/kretprobes/ +[17]:http://www.linaro.org/tag/perf/ +[18]:http://www.linaro.org/tag/tracing/ From dbd2f1ef5eb0acb09fe4083307f9988606bf2516 Mon Sep 17 00:00:00 2001 From: HankChow Date: Wed, 29 Nov 2017 16:48:57 +0800 Subject: [PATCH 032/344] HankChow translating --- sources/tech/20171124 How do groups work on Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171124 How do groups work on Linux.md b/sources/tech/20171124 How do groups work on Linux.md index bc1833b0d6..3e9c386e01 100644 --- a/sources/tech/20171124 How do groups work on Linux.md +++ b/sources/tech/20171124 How do groups work on Linux.md @@ -1,3 +1,5 @@ +HankChow Translating + How do groups work on Linux? ============================================================ From f863dfbcd9801da5b49fe1fd356dc14871080b1a Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 29 Nov 2017 17:35:54 +0800 Subject: [PATCH 033/344] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...our Terminal Session To Anyone In Seconds.md | 597 +++--------------- 1 file changed, 85 insertions(+), 512 deletions(-) diff --git a/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md b/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md index efa99115b8..b4747d8a65 100644 --- a/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md +++ b/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md @@ -1,150 +1,15 @@ -::: {#wrapper} -::: {.mobile-title-logo-in-header} -[![2daygeek.com](https://www.2daygeek.com/wp-content/uploads/2015/12/2day-geek-new-logo-final.png)](https://www.2daygeek.com/ "2daygeek.com | Home page"){.custom-logo-link} -::: - -::: {.ham__navbar-toggler-two .collapsed title="Menu" aria-expanded="false"} -::: {.ham__navbar-span-wrapper} -[]{.line .line-1} []{.line .line-2} []{.line .line-3} -::: -::: - -::: {.nav-text} -::: - -::: {.nav-wrap .container} --
- -
- - - -- [[LINUX - DISTRO'S](https://www.2daygeek.com/category/linux-distributions/)]{#menu-item-6808} -- [[LINUX - COMMAND'S](https://www.2daygeek.com/category/linux-commands/)]{#menu-item-6806} -- [[WEBSERVER](https://www.2daygeek.com/category/webserver/)]{#menu-item-9582} -- [[MONITORING - TOOLS](https://www.2daygeek.com/category/monitoring-tools/)]{#menu-item-6809} -- [[PACKAGE - MANAGEMENT](https://www.2daygeek.com/category/package-management/)]{#menu-item-6883} -- [[REPOSITORY](https://www.2daygeek.com/category/repository/)]{#menu-item-6811} -- [[CLOUD - STORAGE](https://www.2daygeek.com/category/free-cloud-storage/)]{#menu-item-6986} -- [[HACKING](https://gbhackers.com/)]{#menu-item-14871} - - [[Tutorials](https://gbhackers.com/)]{#menu-item-14872} -::: - -::: {.nav-text} -::: - -::: {.topbar-toggle-down} -::: - -::: {.nav-wrap .container} -- [[HOME](https://www.2daygeek.com/)]{#menu-item-293} -- [[LINUX NEWS](http://linuxnews.2daygeek.com/)]{#menu-item-10920} -- [[ABOUT US](https://www.2daygeek.com/about-us/)]{#menu-item-294} -- [[CONTACT US](https://www.2daygeek.com/contact-us/)]{#menu-item-295} -- [[DISCLAIMER](https://www.2daygeek.com/disclaimer/)]{#menu-item-296} -- [[PRIVACY - POLICY](https://www.2daygeek.com/privacy-policy/)]{#menu-item-3676} -- [[SUPPORT - US](https://www.2daygeek.com/support-us/)]{#menu-item-2729} -- [[OS - TWEAK](https://www.2daygeek.com/category/os-tweaks/)]{#menu-item-8366} -- [[ICONS](https://www.2daygeek.com/category/icon-theme/)]{#menu-item-12012} -- [[THEMES](https://www.2daygeek.com/category/gtk-theme/)]{#menu-item-12013} -::: - -::: {#topbar-header-search .container} -::: {.container-inner} -::: {.toggle-search} -::: - -::: {.search-expand} -::: {.search-expand-inner} -
- -
-::: -::: -::: -::: - -::: {.container .group} -::: {.container-inner} -::: {.group .pad .central-header-zone} -::: {.logo-tagline-group} -[![2daygeek.com](https://www.2daygeek.com/wp-content/uploads/2015/12/2day-geek-new-logo-final.png)](https://www.2daygeek.com/ "2daygeek.com | Home page"){.custom-logo-link} -::: - -::: {#header-widgets} -::: {style="float:left;border:solid 0px;height:90px;width:728px;"} -[]{.underline} -::: -::: -::: - -::: {.nav-text} -::: - -::: {.nav-wrap .container} -- [LINUX - DISTRO'S](https://www.2daygeek.com/category/linux-distributions/) -- [LINUX COMMAND'S](https://www.2daygeek.com/category/linux-commands/) -- [WEBSERVER](https://www.2daygeek.com/category/webserver/) -- [MONITORING - TOOLS](https://www.2daygeek.com/category/monitoring-tools/) -- [PACKAGE - MANAGEMENT](https://www.2daygeek.com/category/package-management/) -- [REPOSITORY](https://www.2daygeek.com/category/repository/) -- [CLOUD - STORAGE](https://www.2daygeek.com/category/free-cloud-storage/) -- [HACKING](https://gbhackers.com/) - - [Tutorials](https://gbhackers.com/) -::: -::: -::: - -::: {#page .container} -::: {.container-inner} -::: {.main} -::: {.main-inner .group} -::: {.section .content} -::: {.page-title .pad .group} -- [Apps](https://www.2daygeek.com/category/apps/) -::: - -::: {.pad .group} -::: {.post-inner .group} -tmate -- Instantly Share Your Terminal Session To Anyone In Seconds {#tmate-instantly-share-your-terminal-session-to-anyone-in-seconds .post-title .entry-title} -=================================================================== - -by [ [[Magesh -Maruthamuthu](https://www.2daygeek.com/author/magesh/ "Posts by Magesh Maruthamuthu")]{.fn} -]{.vcard .author} · [Published : November 28, 2017 \|\| Last Updated: -November 28, 2017]{.published} - -::: {.clear} -::: - -::: {.entry .themeform} -::: {.entry-inner} -::: {style="float:left;margin:10px 10px 10px 0;"} -[]{.underline} -::: +tmate -- Instantly Share Your Terminal Session To Anyone In Seconds +================= A while ago, we wrote about [teleconsole](https://www.2daygeek.com/teleconsole-share-terminal-session-instantly-to-anyone-in-seconds/) -which is used to share terminal instantly to anyone (whoever you -trusting). Today also we are going to discuss about same kind of +which is used to share terminal instantly to anyone (whoever you trusting). Today also we are going to discuss about same kind of application called tmate. Why you want tmate application? this will help you to get help from your friends when you need. -#### What Is tmate? +### What Is tmate? [tmate](https://tmate.io/) stands for teammates, it's a fork of tmux, and uses the same configurations such as keybindings, color schemes etc. @@ -160,7 +25,7 @@ or several teammates. A status line at the bottom of the screen shows information on the current session, such as ssh command to share with your mate. -#### How tmate works? +### How tmate works? - When launching tmate, an ssh connection is established to tmate.io (backend servers maintained by tmate developers) in the background @@ -173,438 +38,146 @@ current session, such as ssh command to share with your mate. - teammates can connect to tmate.io using the SSH session ID provided by user -#### Prerequisites for tmate +### Prerequisites for tmate Generate SSH key as a prerequisites since tmate.io server authenticate client machine through local ssh keys. Make a note, every system should have SSH key. +```shell +$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key (/home/magi/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in /home/magi/.ssh/id_rsa. +Your public key has been saved in /home/magi/.ssh/id_rsa.pub. +The key fingerprint is: +SHA256:3ima5FuwKbWyyyNrlR/DeBucoyRfdOtlUmb5D214NC8 [email protected] +The key's randomart image is: ++---[RSA 2048]----+ +| | +| | +| . | +| . . = o | +| *ooS= . + o | +| . [email protected]*o.o.+ E .| +| =o==B++o = . | +| o.+*o+.. . | +| ..o+o=. | ++----[SHA256]-----+ +``` - $ ssh-keygen -t rsa - Generating public/private rsa key pair. - Enter file in which to save the key (/home/magi/.ssh/id_rsa): - Enter passphrase (empty for no passphrase): - Enter same passphrase again: - Your identification has been saved in /home/magi/.ssh/id_rsa. - Your public key has been saved in /home/magi/.ssh/id_rsa.pub. - The key fingerprint is: - SHA256:3ima5FuwKbWyyyNrlR/DeBucoyRfdOtlUmb5D214NC8 [email protected] - The key's randomart image is: - +---[RSA 2048]----+ - | | - | | - | . | - | . . = o | - | *ooS= . + o | - | . [email protected]*o.o.+ E .| - | =o==B++o = . | - | o.+*o+.. . | - | ..o+o=. | - +----[SHA256]-----+ - -#### How to Install tmate +### How to Install tmate tmate is available in few of the distribution official repository that can be installed through package manager. -For **`Debian/Ubuntu`**, use [APT-GET -Command](https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/) -or [APT -Command](https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/)to -install tmate. +For **`Debian/Ubuntu`**, use [APT-GET Command](https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/) +or [APT Command](https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/)to install tmate. -::: {style="float:left;margin:10px 10px 10px 0;"} -[]{.underline} -::: +```shell +$ sudo apt-get install software-properties-common +$ sudo add-apt-repository ppa:tmate.io/archive +$ sudo apt-get update +$ sudo apt-get install tmate +``` - $ sudo apt-get install software-properties-common - $ sudo add-apt-repository ppa:tmate.io/archive - $ sudo apt-get update - $ sudo apt-get install tmate +Also, you can install tmate package from distribution official repository. -Also, you can install tmate package from distribution official -repository. +```shell +$ sudo apt-get install tmate +``` - $ sudo apt-get install tmate - -For **`Fedora`**, use [DNF -Command](https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/) +For **`Fedora`**, use [DNF Command](https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/) to install tmate. - $ sudo dnf install tmate +```shell +$ sudo dnf install tmate +``` -For **`Arch Linux`** based systems, use []()[Yaourt -Command](https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/) -or []()[Packer -Command](https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/) +For **`Arch Linux`** based systems, use []()[Yaourt Command](https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/) +or []()[Packer Command](https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/) to install tmate from AUR repository. - $ yaourt -S tmate - or - $ packer -S tmate +```shell +$ yaourt -S tmate +``` +or -For **`openSUSE`**, use [Zypper -Command](https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/) +```shell +$ packer -S tmate +``` + +For **`openSUSE`**, use [Zypper Command](https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/) to install tmate. - $ sudo zypper in tmate +```shell +$ sudo zypper in tmate +``` -#### How To Use tmate +### How To Use tmate After successfully installed, open your terminal and fire the following command which will open the new session for you and in the bottom of the screen you can able to see the SSH session ID. - $ tmate +```shell +$ tmate +``` -[![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter -.size-full .wp-image-15269 width="1051" -height="643"}![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter -.size-full .wp-image-15269 width="1051" -height="643"}](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-1.png) +[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-1.png) Make a note, the SSH session ID will disappear after a few seconds, so don't worry you can get those details using following command. -::: {style="float:none;margin:10px 0 10px 0;text-align:center;"} -[]{.underline} -::: - - $ tmate show-messages +```shell +$ tmate show-messages +``` The tmate show-messages command allows you to see tmate's log messages, including the ssh connection string.\ -[![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter -.size-full .wp-image-15270 width="1051" -height="643"}![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter -.size-full .wp-image-15270 width="1051" -height="643"}](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-2.png) +[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-2.png) Now, share your SSH session ID to your friends or coworkers and allow them to view the terminal session. Not only SSH session ID, alternatively you can share web URL as well, also you can share either read only sessions or read-write sessions? -#### How to connect session through SSH +### How to connect session through SSH Just run the SSH session ID which you got from your friend on terminal. It's like similar to below. - $ ssh session: ssh [email protected] +```shell +$ ssh session: ssh [email protected] +``` -[![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter -.size-full .wp-image-15273 width="869" -height="625"}![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter -.size-full .wp-image-15273 width="869" -height="625"}](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-4.png) +[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-4.png) -#### How to connect session through Web URL +### How to connect session through Web URL Open the browser and access the URL which you got from your friend. It's like similar to below.\ -[![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter -.size-full .wp-image-15274 width="1024" -height="708"}![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.aligncenter -.size-full .wp-image-15274 width="1024" -height="708"}](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-3.png) +[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-3.png) -::: {style="float:none;margin:10px 0 10px 0;text-align:center;"} -::: Just type `exit` to exit from the session. -::: {style="float:none;margin:10px 0 10px 0;text-align:center;"} -::: +``` +[Source System Output] +[exited] - [Source System Output] - [exited] - - [Remote System Output] - [server exited] - Connection to sg2.tmate.io closed by remote host. - Connection to sg2.tmate.io closed. - -::: {style="float:none;margin:10px 0 10px 0;text-align:center;"} -[]{.underline} -::: - -::: {style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"} -::: -::: - -::: {.clear} -::: -::: -::: - -::: {.clear} -::: - -Tags: [Application](https://www.2daygeek.com/tag/application/)[Instant -terminal -sharing](https://www.2daygeek.com/tag/instant-terminal-sharing/)[Linux](https://www.2daygeek.com/tag/linux/)[tmate](https://www.2daygeek.com/tag/tmate/) - -::: {.author-bio} -::: {.bio-avatar} -![](https://www.2daygeek.com/wp-content/plugins/lazy-load/images/1x1.trans.gif){.avatar -.avatar-128 .photo width="128" height="128" -srcset="https://secure.gravatar.com/avatar/d487bef1de15143a7b80a40396e96118?s=256&d=mm&r=g 2x"} - -![](https://secure.gravatar.com/avatar/d487bef1de15143a7b80a40396e96118?s=128&d=mm&r=g){.avatar -.avatar-128 .photo width="128" height="128" -srcset="https://secure.gravatar.com/avatar/d487bef1de15143a7b80a40396e96118?s=256&d=mm&r=g 2x"} -::: - -Magesh Maruthamuthu - -Love to play with all Linux distribution - -::: {.clear} -::: -::: - -- - [**Previous story** How To Empty a File, Delete N Lines From a - File, Remove Matching String From a File, And Remove Empty/Blank - Lines From a File In - Linux?](https://www.2daygeek.com/empty-a-file-delete-contents-lines-from-a-file-remove-matching-string-from-a-file-remove-empty-blank-lines-from-a-file/) - -#### You may also like\... {#you-may-also-like... .heading} - -- ::: {.post-thumbnail} - ![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.attachment-thumb-medium - .size-thumb-medium .wp-post-image width="520" height="245"} - ![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.attachment-thumb-medium - .size-thumb-medium .wp-post-image width="520" height="245"} - ::: - - ::: {.related-inner} - #### [wikipedia2text -- A Command Line Tool For Querying The Wikipedia Article](https://www.2daygeek.com/wikipedia2text-wiki-cli-access-query-read-wikipedia-page-article-in-linux-command-line/ "wikipedia2text – A Command Line Tool For Querying The Wikipedia Article") {#wikipedia2text-a-command-line-tool-for-querying-the-wikipedia-article .post-title .entry-title} - - ::: {.post-meta .group} - October 17, 2017 - ::: - ::: - -- ::: {.post-thumbnail} - ![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.attachment-thumb-medium - .size-thumb-medium .wp-post-image width="520" height="245"} - ![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.attachment-thumb-medium - .size-thumb-medium .wp-post-image width="520" height="245"} - ::: - - ::: {.related-inner} - #### [RTV (Reddit Terminal Viewer) -- A Simple Terminal Viewer For Reddit](https://www.2daygeek.com/rtv-reddit-terminal-viewer-a-simple-terminal-viewer-for-reddit/ "RTV (Reddit Terminal Viewer) – A Simple Terminal Viewer For Reddit") {#rtv-reddit-terminal-viewer-a-simple-terminal-viewer-for-reddit .post-title .entry-title} - - ::: {.post-meta .group} - October 13, 2017 - ::: - ::: - -- ::: {.post-thumbnail} - ![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.attachment-thumb-medium - .size-thumb-medium .wp-post-image width="520" height="245"} - ![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7){.attachment-thumb-medium - .size-thumb-medium .wp-post-image width="520" height="245"} - ::: - - ::: {.related-inner} - #### [Teleconsole -- A Tool To Share Your Terminal Session Instantly To Anyone In Seconds](https://www.2daygeek.com/teleconsole-share-terminal-session-instantly-to-anyone-in-seconds/ "Teleconsole – A Tool To Share Your Terminal Session Instantly To Anyone In Seconds") {#teleconsole-a-tool-to-share-your-terminal-session-instantly-to-anyone-in-seconds .post-title .entry-title} - - ::: {.post-meta .group} - November 6, 2017 - ::: - ::: - -::: {#disqus_thread} -::: -::: -::: - -::: {.sidebar .s1 .collapsed data-position="right" data-layout="col-2cl" data-sb-id="s1"} -[]{.sidebar-toggle} - -::: {.sidebar-content} -::: {.sidebar-top .group} -Follow: - -- [](https://www.facebook.com/2daygeek "Facebook"){.social-tooltip} -- [](https://www.twitter.com/2daygeek "Twitter"){.social-tooltip} -- [](https://www.google.com/+2daygeeks "Google+"){.social-tooltip} -- [](https://www.linkedin.com/company/2daygeek "Linkein"){.social-tooltip} -- [](javascript:void(0) "Pinterest"){.social-tooltip} -- [](http://2daygeek.tumblr.com/ "Tumblr"){.social-tooltip} -::: - -::: {#text-8 .widget .widget_text} -### -- Click Here To Get Offers -- {#click-here-to-get-offers .widget-title} - -::: {.textwidget} -[]{.underline} -::: -::: - -::: {#text-10 .widget .widget_text} -### -- For Better Offers -- {#for-better-offers .widget-title} - -::: {.textwidget} -::: -::: - -::: {#text-12 .widget .widget_text} -### -Unmatched Offers For Linux Users- {#unmatched-offers-for-linux-users- .widget-title} - -::: {.textwidget} -::: -::: - -::: {#wp_subscribe-3 .widget .wp_subscribe} -::: {#wp-subscribe .wp-subscribe-wrap .wp-subscribe .wp-subscribe-1 data-thanks_page="0" data-thanks_page_url="" data-thanks_page_new_window="0"} -#### Get Latest LINUX Tips {#get-latest-linux-tips .title} - -::: {.wp-subscribe-loader} -::: - -Thank you for subscribing. - -Something went wrong. - -::: {.clear} -::: -::: -::: - -::: {#text-3 .widget .widget_text} -::: {.textwidget} -::: -::: - -::: {#text-6 .widget .widget_text} -::: {.textwidget} -::: {#google_translate_element} -::: -::: -::: - -::: {#text-5 .widget .widget_text} -### Follow us {#follow-us .widget-title} - -::: {.textwidget} -::: {.g-page data-href="//plus.google.com/107364365185869631781" data-layout="landscape" data-rel="publisher"} -::: -::: -::: -::: -::: -::: -::: -::: -::: - -::: {#footer-bottom .section .container} -::: {.container-inner} -[](#){#back-to-top} - -::: {.pad .group} -::: {.grid .one-half} -::: {#copyright} -2daygeek.com © 2017. All Rights Reserved. -::: - -::: {#credit style=""} -[2daygeek](https://www.2daygeek.com) :- Linux Tips & Tricks, Linux -How-to Guides & Tutorials is licensed under a [(cc) -BY-NC](https://creativecommons.org/licenses/by-nc/4.0/) -::: -::: - -::: {.grid .one-half .last} -- [](https://www.facebook.com/2daygeek "Facebook"){.social-tooltip} -- [](https://www.twitter.com/2daygeek "Twitter"){.social-tooltip} -- [](https://www.google.com/+2daygeeks "Google+"){.social-tooltip} -- [](https://www.linkedin.com/company/2daygeek "Linkein"){.social-tooltip} -- [](javascript:void(0) "Pinterest"){.social-tooltip} -- [](http://2daygeek.tumblr.com/ "Tumblr"){.social-tooltip} -::: -::: -::: -::: -::: - -::: {#crestashareicon .cresta-share-icon .sameColors .first_style .show-count-active} -::: {#facebook-cresta .sbutton .crestaShadow .facebook-cresta-share .float} -[](https://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.2daygeek.com%2Ftmate-instantly-share-your-terminal-session-to-anyone-in-seconds%2F&t=tmate+%E2%80%93++Instantly+Share+Your+Terminal+Session+To+Anyone+In+Seconds "Share to Facebook") -::: - -::: {#twitter-cresta .sbutton .crestaShadow .twitter-cresta-share .float .withCount} -[](https://twitter.com/share?text=tmate+%E2%80%93++Instantly+Share+Your+Terminal+Session+To+Anyone+In+Seconds&url=https%3A%2F%2Fwww.2daygeek.com%2Ftmate-instantly-share-your-terminal-session-to-anyone-in-seconds%2F&via=2daygeek "Share to Twitter") -::: - -::: {#googleplus-cresta .sbutton .crestaShadow .googleplus-cresta-share .float} -[](https://plus.google.com/share?url=https%3A%2F%2Fwww.2daygeek.com%2Ftmate-instantly-share-your-terminal-session-to-anyone-in-seconds%2F "Share to Google Plus") -::: - -::: {#linkedin-cresta .sbutton .crestaShadow .linkedin-cresta-share .float} -[](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.2daygeek.com%2Ftmate-instantly-share-your-terminal-session-to-anyone-in-seconds%2F&title=tmate+%E2%80%93++Instantly+Share+Your+Terminal+Session+To+Anyone+In+Seconds&source=https://www.2daygeek.com/ "Share to LinkedIn") -::: - -::: {#pinterest-cresta .sbutton .crestaShadow .pinterest-cresta-share .float} -[](https://pinterest.com/pin/create/bookmarklet/?url=https%3A%2F%2Fwww.2daygeek.com%2Ftmate-instantly-share-your-terminal-session-to-anyone-in-seconds%2F&media=https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds.png&description=tmate+%E2%80%93++Instantly+Share+Your+Terminal+Session+To+Anyone+In+Seconds "Share to Pinterest") -::: - -::: {#total-shares .sbutton} -[]{#total-count .cresta-the-total-count}[Shares]{.cresta-the-total-text} -::: - -::: {style="clear: both;"} -::: -::: - -::: {#spu-bg} -::: - -::: {#spu-main} -[Close](#){#spu-close} - -::: {#spu-title} -Please support the site -::: - -::: {#spu-msg-cont} -::: {#spu-msg} -By clicking any of these buttons you help our site to get better - -::: {.spu-button .spu-twitter} -[Follow Me](https://twitter.com/2daygeek){.twitter-follow-button} -::: - -::: {.spu-button .spu-facebook} -::: {#fb-root} -::: - -::: {.fb-like data-href="https://www.facebook.com/2daygeek" data-send="false" data-width="450" data-show-faces="true" data-layout="button_count"} -::: -::: - -::: {.spu-button .spu-google} -::: {.g-plusone data-callback="googleCB" data-onendinteraction="closeGoogle" data-recommendations="false" data-annotation="bubble" data-size="medium" data-href="https://www.google.com/+2daygeeks"} -::: -::: -::: - -::: {.step-clear} -::: -::: - -[]{#spu-timer} - -::: {#spu-bottom} -::: -::: +[Remote System Output] +[server exited] +Connection to sg2.tmate.io closed by remote host. +Connection to sg2.tmate.io closed. +``` -------------------------------------------------------------------------------- via: https://www.2daygeek.com/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds/ -作者:[ ][a] +作者:[ Magesh Maruthamuthu ][a] 译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) From 0d433d8d60be8594dcfe4f692f0d47bce348678a Mon Sep 17 00:00:00 2001 From: wenwensnow <963555237@qq.com> Date: Wed, 29 Nov 2017 17:40:53 +0800 Subject: [PATCH 034/344] Update 20171124 How to Install Android File Transfer for Linux.md --- .../20171124 How to Install Android File Transfer for Linux.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171124 How to Install Android File Transfer for Linux.md b/sources/tech/20171124 How to Install Android File Transfer for Linux.md index b5078c2e01..4a9e04b49a 100644 --- a/sources/tech/20171124 How to Install Android File Transfer for Linux.md +++ b/sources/tech/20171124 How to Install Android File Transfer for Linux.md @@ -1,3 +1,4 @@ +Translating by wenwensnow # How to Install Android File Transfer for Linux If you’re struggling to mount your Android phone on Ubuntu you might want to give [Android File Transfer for Linux][4] a try. From f9691b39881f2f9707b7fc43c71a2015d4d8109f Mon Sep 17 00:00:00 2001 From: keyld Date: Wed, 29 Nov 2017 17:53:44 +0800 Subject: [PATCH 035/344] KeyLD translating --- .../20171124 Photon Could Be Your New Favorite Container OS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md index 9b8a98a9dd..147a2266cc 100644 --- a/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md +++ b/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md @@ -1,3 +1,5 @@ +KeyLD Translating + Photon Could Be Your New Favorite Container OS ============================================================ From a45c0b813662fdea0f67954d0964f7747aac0fa0 Mon Sep 17 00:00:00 2001 From: wangy325 Date: Wed, 29 Nov 2017 18:08:10 +0800 Subject: [PATCH 036/344] wangy325 translating --- ...rce Cloud Skills and Certification Are Key for SysAdmins.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md b/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md index e1237760b0..27379cbe40 100644 --- a/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md +++ b/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md @@ -1,3 +1,6 @@ +translating by wangy325... + + Open Source Cloud Skills and Certification Are Key for SysAdmins ============================================================ From d410a07fa5881d08dd4a13f80dab53ed2ee1da93 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 29 Nov 2017 18:44:30 +0800 Subject: [PATCH 037/344] translating by darksun --- ... Instantly Share Your Terminal Session To Anyone In Seconds.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md b/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md index b4747d8a65..6ed960de15 100644 --- a/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md +++ b/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md @@ -1,3 +1,4 @@ +translating by darksun tmate -- Instantly Share Your Terminal Session To Anyone In Seconds ================= From f1a182bf5b92d5d7fc053722a42e96bd116e3fd1 Mon Sep 17 00:00:00 2001 From: vpainter <934564727@qq.com> Date: Wed, 29 Nov 2017 22:06:45 +0800 Subject: [PATCH 038/344] voidpainter is translating voidpainter is translating --- sources/tech/20170908 Betting on the Web.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20170908 Betting on the Web.md b/sources/tech/20170908 Betting on the Web.md index 84d70e164f..80d0002a80 100644 --- a/sources/tech/20170908 Betting on the Web.md +++ b/sources/tech/20170908 Betting on the Web.md @@ -1,3 +1,5 @@ +voidpainter is translating +--- [Betting on the Web][27] ============================================================ From 02c74d0989f14d0ee27779c369b513b43eb3d984 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 29 Nov 2017 22:31:32 +0800 Subject: [PATCH 039/344] PRF:20141028 When Does Your OS Run.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @Cwndmiao 翻译的很好! --- .../tech/20141028 When Does Your OS Run.md | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/translated/tech/20141028 When Does Your OS Run.md b/translated/tech/20141028 When Does Your OS Run.md index 893dd9fb48..80ec1340c8 100644 --- a/translated/tech/20141028 When Does Your OS Run.md +++ b/translated/tech/20141028 When Does Your OS Run.md @@ -1,46 +1,50 @@ 操作系统何时运行? ============================================================ +请各位思考以下问题:在你阅读本文的这段时间内,计算机中的操作系统在**运行**吗?又或者仅仅是 Web 浏览器在运行?又或者它们也许均处于空闲状态,等待着你的指示? -请各位思考以下问题:在你阅读本文的这段时间内,计算机中的操作系统在运行吗?又或者仅仅是 Web 浏览器在运行?又或者他们也许均处于空闲状态,等待着你的指示? +这些问题并不复杂,但它们深入涉及到系统软件工作的本质。为了准确回答这些问题,我们需要透彻理解操作系统的行为模型,包括性能、安全和除错等方面。在该系列文章中,我们将以 Linux 为主举例来帮助你建立操作系统的行为模型,OS X 和 Windows 在必要的时候也会有所涉及。对那些深度探索者,我会在适当的时候给出 Linux 内核源码的链接。 -这些问题并不复杂,但他们深入涉及到系统软件工作的本质。为了准确回答这些问题,我们需要透彻理解操作系统的行为模型,包括性能、安全和除错等方面。在该系列文章中,我们将以 Linux 为主举例来帮助你建立操作系统的行为模型,OS X 和 Windows 在必要的时候也会有所涉及。对那些深度探索者,我会在适当的时候给出 Linux 内核源码的链接。 +这里有一个基本认知,就是,在任意给定时刻,某个 CPU 上仅有一个任务处于活动状态。大多数情形下这个任务是某个用户程序,例如你的 Web 浏览器或音乐播放器,但它也可能是一个操作系统线程。可以确信的是,它是**一个任务**,不是两个或更多,也不是零个,对,**永远**是一个。 -这里有一个基本认知,就是,在任意给定时刻,某个 CPU 上仅有一个任务处于活动状态。大多数情形下这个任务是某个用户程序,例如你的 Web 浏览器或音乐播放器,但他也可能是一个操作系统线程。可以确信的是,他是一个任务,不是两个或更多,也不是零个,对,永远是一个。 +这听上去可能会有些问题。比如,你的音乐播放器是否会独占 CPU 而阻止其它任务运行?从而使你不能打开任务管理工具去杀死音乐播放器,甚至让鼠标点击也失效,因为操作系统没有机会去处理这些事件。你可能会愤而喊出,“它究竟在搞什么鬼?”,并引发骚乱。 -这听上去可能会有些问题。比如,你的音乐播放器是否会独占 CPU 而阻止其他任务运行?从而使你不能打开任务管理工具去杀死音乐播放器,甚至让鼠标点击也失效,因为操作系统没有机会去处理这些事件。你可能会奋而喊出,“他究竟在搞什么鬼?”,并引发骚乱。 +此时便轮到**中断**大显身手了。中断就好比,一声巨响或一次拍肩后,神经系统通知大脑去感知外部刺激一般。计算机主板上的[芯片组][1]同样会中断 CPU 运行以传递新的外部事件,例如键盘上的某个键被按下、网络数据包的到达、一次硬盘读取的完成,等等。硬件外设、主板上的中断控制器和 CPU 本身,它们共同协作实现了中断机制。 -此时便轮到中断大显身手了。中断就好比,一声巨响或一次拍肩后,神经系统通知大脑去感知外部刺激一般。计算机主板上的芯片组同样会中断 CPU 运行以传递新的外部事件,例如键盘上的某个键被按下、网络数据包的到达、一次硬盘读的完成,等等。硬件外设、主板上的中断控制器和 CPU 本身,他们共同协作实现了中断机制。 +中断对于记录我们最珍视的资源——时间——也至关重要。计算机[启动过程][2]中,操作系统内核会设置一个硬件计时器以让其产生周期性**计时中断**,例如每隔 10 毫秒触发一次。每当计时中断到来,内核便会收到通知以更新系统统计信息和盘点如下事项:当前用户程序是否已运行了足够长时间?是否有某个 TCP 定时器超时了?中断给予了内核一个处理这些问题并采取合适措施的机会。这就好像你给自己设置了整天的周期闹铃并把它们用作检查点:我是否应该去做我正在进行的工作?是否存在更紧急的事项?直到你发现 10 年时间已逝去…… -中断对于簿记我们最珍视的资源--时间也至关重要。计算机启动过程中,操作系统内核会设置一个硬件计时器以让其产生周期性计时中断,例如每隔 10 毫秒触发一次。每当计时中断到来,内核便会收到通知以更新系统统计信息和盘点如下事项:当前用户程序是否已运行了足够长时间?是否有某个 TCP 定时器超时了?中断给予了内核一个处理这些问题并采取合适措施的机会。这就好像你给自己设置了整天的周期闹铃并把他们用作检查点:我是否应该去做我正在进行的工作?是否存在更紧急的事项?直到你发现 10 年时间已逝去。。。 +这些内核对 CPU 周期性的劫持被称为滴答tick,也就是说,是中断让你的操作系统滴答了一下。不止如此,中断也被用作处理一些软件事件,如整数溢出和页错误,其中未涉及外部硬件。**中断是进入操作系统内核最频繁也是最重要的入口**。对于学习电子工程的人而言,这些并无古怪,它们是操作系统赖以运行的机制。 -这些内核对 CPU 周期性的劫持被称为滴答,也就是说,是中断让操作系统经历了滴答的过程。不止如此,中断也被用作处理一些软件事件,如整数溢出和页错误,其中未涉及外部硬件。中断是进入操作系统内核最频繁也是最重要的入口。对于学习电子工程的人而言,这些并无古怪,他们是操作系统赖以运行的机制。 - -说到这里,让我们再来看一些实际情形。下图示意了 Intel Core i5 系统中的一个网卡中断。图片现在设置了超链,你可以点击他们以获取更为详细的信息,例如每个设备均被链接到了对应的 Linux 驱动源码。 +说到这里,让我们再来看一些实际情形。下图示意了 Intel Core i5 系统中的一个网卡中断。图片中的部分元素设置了超链,你可以点击它们以获取更为详细的信息,例如每个设备均被链接到了对应的 Linux 驱动源码。 ![](http://duartes.org/gustavo/blog/img/os/hardware-interrupt.png) - +链接如下: -让我们来仔细研究下。首先,由于系统中存在众多中断源,如果硬件只是通知 CPU “嘿,这里发生了一些事情”然后什么也不做,则不太行得通。这会带来难以忍受的冗长等待。因此,计算机上电时,每个设备都被授予了一根中断线,或者称为 IRQ。这些 IRQ 然后被系统中的中断控制器映射成值介于 0 到 255 之间的中断向量。等到中断到达 CPU,他便具备了一个定义良好的数值,异于硬件的某些其他诡异行为。 +- network card : https://github.com/torvalds/linux/blob/v3.17/drivers/net/ethernet/intel/e1000e/netdev.c +- USB keyboard : https://github.com/torvalds/linux/blob/v3.16/drivers/hid/usbhid/usbkbd.c +- I/O APIC : https://github.com/torvalds/linux/blob/v3.16/arch/x86/kernel/apic/io_apic.c +- HPET : https://github.com/torvalds/linux/blob/v3.17/arch/x86/kernel/hpet.c -相应地,CPU 中还存有一个由内核维护的指针,指向一个包含 255 个函数指针的数组,其中每个函数被用来处理某个特定的中断向量。后文中,我们将继续深入探讨这个数组,他也被称作中断描述符表(IDT)。 +让我们来仔细研究下。首先,由于系统中存在众多中断源,如果硬件只是通知 CPU “嘿,这里发生了一些事情”然后什么也不做,则不太行得通。这会带来难以忍受的冗长等待。因此,计算机上电时,每个设备都被授予了一根**中断线**,或者称为 IRQ。这些 IRQ 然后被系统中的中断控制器映射成值介于 0 到 255 之间的**中断向量**。等到中断到达 CPU,它便具备了一个完好定义的数值,异于硬件的某些其它诡异行为。 + +相应地,CPU 中还存有一个由内核维护的指针,指向一个包含 255 个函数指针的数组,其中每个函数被用来处理某个特定的中断向量。后文中,我们将继续深入探讨这个数组,它也被称作**中断描述符表**(IDT)。 每当中断到来,CPU 会用中断向量的值去索引中断描述符表,并执行相应处理函数。这相当于,在当前正在执行任务的上下文中,发生了一个特殊函数调用,从而允许操作系统以较小开销快速对外部事件作出反应。考虑下述场景,Web 服务器在发送数据时,CPU 却间接调用了操作系统函数,这听上去要么很炫酷要么令人惊恐。下图展示了 Vim 编辑器运行过程中一个中断到来的情形。 ![](http://duartes.org/gustavo/blog/img/os/vim-interrupted.png) -此处请留意,中断的到来是如何触发 CPU 到 Ring 0 内核模式的切换而未有改变当前活跃的任务。这看上去就像,Vim 编辑器直接面向操作系统内核产生了一次神奇的函数调用,但 Vim 还在那里,他的地址空间原封未动,等待着执行流返回。 +此处请留意,中断的到来是如何触发 CPU 到 [Ring 0][3] 内核模式的切换而未有改变当前活跃的任务。这看上去就像,Vim 编辑器直接面向操作系统内核产生了一次神奇的函数调用,但 Vim 还在那里,它的[地址空间][4]原封未动,等待着执行流返回。 -这很令人振奋,不是么?不过让我们暂且告一段落吧,我需要合理控制篇幅。我知道还没有回答完这个开放式问题,甚至还实质上翻开了新的问题,但你至少知道了在你读这个句子的同时滴答正在发生。我们将在充实了对操作系统动态行为模型的理解之后再回来寻求问题的答案,对 Web 浏览器情形的理解也会变得清晰。如果你仍有问题,尤其是在这篇文章公诸于众后,请尽管提出。我将会在文章或后续评论中回答他们。下篇文章将于明天在 RSS 和 Twitter 上发布。 +这很令人振奋,不是么?不过让我们暂且告一段落吧,我需要合理控制篇幅。我知道还没有回答完这个开放式问题,甚至还实质上翻开了新的问题,但你至少知道了在你读这个句子的同时**滴答**正在发生。我们将在充实了对操作系统动态行为模型的理解之后再回来寻求问题的答案,对 Web 浏览器情形的理解也会变得清晰。如果你仍有问题,尤其是在这篇文章公诸于众后,请尽管提出。我将会在文章或后续评论中回答它们。下篇文章将于明天在 RSS 和 Twitter 上发布。 -------------------------------------------------------------------------------- via: http://duartes.org/gustavo/blog/post/when-does-your-os-run/ -作者:[gustavo ][a] +作者:[gustavo][a] 译者:[Cwndmiao](https://github.com/Cwndmiao) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 703c66f461c3867f08199cd268f5f4f6daebc458 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 29 Nov 2017 22:32:29 +0800 Subject: [PATCH 040/344] PUB:20141028 When Does Your OS Run.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @Cwndmiao 恭喜你完成了第一篇翻译,文章发布地址: https://linux.cn/article-9095-1.html ,你的 LCTT 专页地址: https://linux.cn/lctt/Cwndmiao --- {translated/tech => published}/20141028 When Does Your OS Run.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20141028 When Does Your OS Run.md (100%) diff --git a/translated/tech/20141028 When Does Your OS Run.md b/published/20141028 When Does Your OS Run.md similarity index 100% rename from translated/tech/20141028 When Does Your OS Run.md rename to published/20141028 When Does Your OS Run.md From c91e776663a06931d6a282d99710d77485f73516 Mon Sep 17 00:00:00 2001 From: yunfengHe Date: Thu, 30 Nov 2017 00:01:15 +0800 Subject: [PATCH 041/344] yunfengHe apply for translation --- sources/tech/20171120 Containers and Kubernetes Whats next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171120 Containers and Kubernetes Whats next.md b/sources/tech/20171120 Containers and Kubernetes Whats next.md index 52f3364d31..ff9d2bf08a 100644 --- a/sources/tech/20171120 Containers and Kubernetes Whats next.md +++ b/sources/tech/20171120 Containers and Kubernetes Whats next.md @@ -1,3 +1,4 @@ +Yunfeng applying for translation. Containers and Kubernetes: What's next? ============================================================ From 72c02857ab5e52ba2e24bb227a6b11f8ebde46f0 Mon Sep 17 00:00:00 2001 From: yunfengHe Date: Thu, 30 Nov 2017 00:04:05 +0800 Subject: [PATCH 042/344] Yunfeng Translating --- sources/tech/20171120 Containers and Kubernetes Whats next.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20171120 Containers and Kubernetes Whats next.md b/sources/tech/20171120 Containers and Kubernetes Whats next.md index ff9d2bf08a..b73ccb21c2 100644 --- a/sources/tech/20171120 Containers and Kubernetes Whats next.md +++ b/sources/tech/20171120 Containers and Kubernetes Whats next.md @@ -1,4 +1,4 @@ -Yunfeng applying for translation. +YunfengHe Translating Containers and Kubernetes: What's next? ============================================================ From 148c5365cde7b334eda51d2429b71684ed8e3850 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 30 Nov 2017 00:35:17 +0800 Subject: [PATCH 043/344] translated --- ...our Terminal Session To Anyone In Seconds.md | 116 +++++++----------- 1 file changed, 43 insertions(+), 73 deletions(-) diff --git a/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md b/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md index 6ed960de15..2f6d6fe3c7 100644 --- a/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md +++ b/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md @@ -1,49 +1,31 @@ -translating by darksun -tmate -- Instantly Share Your Terminal Session To Anyone In Seconds +tmate -- 秒级分享你的终端会话 ================= -A while ago, we wrote about -[teleconsole](https://www.2daygeek.com/teleconsole-share-terminal-session-instantly-to-anyone-in-seconds/) -which is used to share terminal instantly to anyone (whoever you trusting). Today also we are going to discuss about same kind of -application called tmate. +不久前,我们写过一篇关于 [teleconsole](https://www.2daygeek.com/teleconsole-share-terminal-session-instantly-to-anyone-in-seconds/) 的介绍,该工具可用于快速分享终端给任何人(任何你信任的人)。今天我们要聊一聊另一款类似的应用,名叫 `tmate`。 -Why you want tmate application? this will help you to get help from your -friends when you need. +`tmate` 有什么用? 它可以让你在需要帮助时向你的朋友们求助。 -### What Is tmate? +### 什么是 tmate? -[tmate](https://tmate.io/) stands for teammates, it's a fork of tmux, -and uses the same configurations such as keybindings, color schemes etc. -It's a terminal multiplexer with instant terminal sharing. it enables a -number of terminals to be created, accessed, and controlled from a -single screen, that can be shared with another mates. +[tmate](https://tmate.io/) 的意思是 `teammates`, 它是 tmux 的一个分支,并且使用相同的配置信息(例如快捷键配置,配色方案等). +它是一个终端多路复用器,同时具有即时分享终端的能力。它允许在单个屏幕中创建并操控多个终端,同时这些终端还能与其他同事分享。 -You can detach the session by leaving the job running in background and -re-attach the session when you want to view the status. tmate provides -an instant pairing solution, allowing you to share a terminal with one -or several teammates. +你可以分离会话,让作业在后台运行,然后在想要查看状态时重新连接会话. `tmate` 提供了一个即时配对的方案, 让你可以与一个或多个队友共享一个终端. -A status line at the bottom of the screen shows information on the -current session, such as ssh command to share with your mate. +在屏幕的地步有一个状态栏,显示了当前会话的一些诸如 ssh 命令之类的共享信息. -### How tmate works? +### tmate 是怎么工作的? -- When launching tmate, an ssh connection is established to tmate.io - (backend servers maintained by tmate developers) in the background - through libssh. -- The server (tmate.io) ssh key signatures are verified during the DH - exchange. -- The client is authenticated with local ssh keys. -- Once connection is established, a 150 bits (non guessable random - characters) session token is generated by local tmux server. -- teammates can connect to tmate.io using the SSH session ID provided - by user +- 运行 `tmate` 时, 会通过 `libssh` 在后台创建一个连接到 tmate.io (由 tmate 开发者维护的后台服务器)的ssh 连接. +- 服务器 (tmate.io) 的 ssh 密钥前面通过 DH 交换进行校验. +- 客户端通过本地 ssh 密钥进行认证. +- 连接创建后, 本地 tmux 服务器会生成一个 150 位(不可猜测的随机字符)会话令牌. +- 队友能通过用户提供的 SSH 会话 ID 连接到 tmate.io. -### Prerequisites for tmate +### 使用 tmate 的必备条件 -Generate SSH key as a prerequisites since tmate.io server authenticate -client machine through local ssh keys. Make a note, every system should -have SSH key. +由于 `tmate.io` 服务器需要通过本地 ssh 密钥来认证客户机,因此其中一个必备条件就是生成 SSH 密钥 key. +记住, 每个系统都要有自己的 SSH 密钥. ```shell $ ssh-keygen -t rsa Generating public/private rsa key pair. @@ -68,13 +50,12 @@ The key's randomart image is: +----[SHA256]-----+ ``` -### How to Install tmate +### 如何安装 tmate -tmate is available in few of the distribution official repository that -can be installed through package manager. +`tmate` 已经包含在某些发行版的官方仓库中,可以通过包管理器来安装. -For **`Debian/Ubuntu`**, use [APT-GET Command](https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/) -or [APT Command](https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/)to install tmate. +对于 **`Debian/Ubuntu`**, 可以使用 [APT-GET 命令](https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/) +或者 [APT 命令](https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/)to 来安装. ```shell $ sudo apt-get install software-properties-common @@ -83,86 +64,75 @@ $ sudo apt-get update $ sudo apt-get install tmate ``` -Also, you can install tmate package from distribution official repository. +你也可以从官方仓库中安装 tmate. ```shell $ sudo apt-get install tmate ``` -For **`Fedora`**, use [DNF Command](https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/) -to install tmate. +对于 **`Fedora`**, 使用 [DNF 命令](https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/) 来安装. ```shell $ sudo dnf install tmate ``` -For **`Arch Linux`** based systems, use []()[Yaourt Command](https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/) -or []()[Packer Command](https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/) -to install tmate from AUR repository. +对于基于 **`Arch Linux`** 的系统, 使用 []()[Yaourt 命令](https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/) +或 []()[Packer 命令](https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/) 来从 AUR 仓库中安装. ```shell $ yaourt -S tmate ``` -or +或 ```shell $ packer -S tmate ``` -For **`openSUSE`**, use [Zypper Command](https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/) -to install tmate. +对于 **`openSUSE`**, 使用 [Zypper 命令](https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/) 来安装. ```shell $ sudo zypper in tmate ``` -### How To Use tmate +### 如何使用 tmate -After successfully installed, open your terminal and fire the following -command which will open the new session for you and in the bottom of the -screen you can able to see the SSH session ID. +成功安装后, 打开终端然后输入下面命令,就会打开一个新的会话,在屏幕底部,你能看到 SSH 会话的 ID. ```shell $ tmate ``` -[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-1.png) +![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-1.png) -Make a note, the SSH session ID will disappear after a few seconds, so -don't worry you can get those details using following command. +要注意的是, SSH 会话 ID 会在几秒后消失, 不过不要紧,你可以通过下面命令获取到这些详细信息. ```shell $ tmate show-messages ``` -The tmate show-messages command allows you to see tmate's log messages, -including the ssh connection string.\ -[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-2.png) +`tmate` 的 `show-messages` 命令会显示 tmate 的 log 信息,其中包含了 ssh 连接内容。 +![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-2.png) -Now, share your SSH session ID to your friends or coworkers and allow -them to view the terminal session. Not only SSH session ID, -alternatively you can share web URL as well, also you can share either -read only sessions or read-write sessions? +现在, 分享你的 SSH 会话 ID 给你的朋友或同事从而允许他们观看终端会话. 除了 SSH 会话 ID 以外,你也可以分享 web URL。 +另外你还可以选择分享的是只读会话还是可读写会话。 -### How to connect session through SSH +### 如何通过 SSH 连接会话 -Just run the SSH session ID which you got from your friend on terminal. -It's like similar to below. +只需要在终端上运行你从朋友那得到的 SSH 终端 ID 就行了. 类似下面这样。 ```shell -$ ssh session: ssh [email protected] +$ ssh session: ssh 3KuRj95sEZRHkpPtc2y6jcokP@sg2.tmate.io ``` -[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-4.png) +![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-4.png) -### How to connect session through Web URL +### 如何通过 Web URL 连接会话 -Open the browser and access the URL which you got from your friend. It's -like similar to below.\ -[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-3.png) +打开浏览器然后访问朋友给你的 URL 就行了. 像下面这样. +![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-3.png) -Just type `exit` to exit from the session. +只需要输入 `exit` 就能退出会话了. ``` [Source System Output] From 377921624b9e6869d583a5950141ce187b900b87 Mon Sep 17 00:00:00 2001 From: Yixun Xu Date: Wed, 29 Nov 2017 11:50:56 -0500 Subject: [PATCH 044/344] cancel request --- ...170809 Designing a Microservices Architecture for Failure.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/sources/tech/20170809 Designing a Microservices Architecture for Failure.md b/sources/tech/20170809 Designing a Microservices Architecture for Failure.md index 3325aaf8da..e1124c229c 100644 --- a/sources/tech/20170809 Designing a Microservices Architecture for Failure.md +++ b/sources/tech/20170809 Designing a Microservices Architecture for Failure.md @@ -1,5 +1,3 @@ -yixunx翻译中 - Designing a Microservices Architecture for Failure ============================================================  From c8c90fbd44f2899f39b3aa7e337a268effb70c48 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 30 Nov 2017 00:55:31 +0800 Subject: [PATCH 045/344] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=87=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...our Terminal Session To Anyone In Seconds.md | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md b/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md index 2f6d6fe3c7..2c9bde95aa 100644 --- a/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md +++ b/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md @@ -3,37 +3,37 @@ tmate -- 秒级分享你的终端会话 不久前,我们写过一篇关于 [teleconsole](https://www.2daygeek.com/teleconsole-share-terminal-session-instantly-to-anyone-in-seconds/) 的介绍,该工具可用于快速分享终端给任何人(任何你信任的人)。今天我们要聊一聊另一款类似的应用,名叫 `tmate`。 -`tmate` 有什么用? 它可以让你在需要帮助时向你的朋友们求助。 +`tmate` 有什么用?它可以让你在需要帮助时向你的朋友们求助。 -### 什么是 tmate? +### 什么是 tmate? -[tmate](https://tmate.io/) 的意思是 `teammates`, 它是 tmux 的一个分支,并且使用相同的配置信息(例如快捷键配置,配色方案等). -它是一个终端多路复用器,同时具有即时分享终端的能力。它允许在单个屏幕中创建并操控多个终端,同时这些终端还能与其他同事分享。 +[tmate](https://tmate.io/) 的意思是 `teammates`,它是 tmux 的一个分支,并且使用相同的配置信息(例如快捷键配置,配色方案等)。 +它是一个终端多路复用器,同时具有即时分享终端的能力。它允许在单个屏幕中创建并操控多个终端,同时这些终端还能与其他同事分享。 -你可以分离会话,让作业在后台运行,然后在想要查看状态时重新连接会话. `tmate` 提供了一个即时配对的方案, 让你可以与一个或多个队友共享一个终端. +你可以分离会话,让作业在后台运行,然后在想要查看状态时重新连接会话. `tmate` 提供了一个即时配对的方案,让你可以与一个或多个队友共享一个终端。 -在屏幕的地步有一个状态栏,显示了当前会话的一些诸如 ssh 命令之类的共享信息. +在屏幕的地步有一个状态栏,显示了当前会话的一些诸如 ssh 命令之类的共享信息。 -### tmate 是怎么工作的? +### tmate 是怎么工作的? -- 运行 `tmate` 时, 会通过 `libssh` 在后台创建一个连接到 tmate.io (由 tmate 开发者维护的后台服务器)的ssh 连接. -- 服务器 (tmate.io) 的 ssh 密钥前面通过 DH 交换进行校验. -- 客户端通过本地 ssh 密钥进行认证. -- 连接创建后, 本地 tmux 服务器会生成一个 150 位(不可猜测的随机字符)会话令牌. -- 队友能通过用户提供的 SSH 会话 ID 连接到 tmate.io. +- 运行 `tmate` 时,会通过 `libssh` 在后台创建一个连接到 tmate.io (由 tmate 开发者维护的后台服务器)的ssh 连接。 +- 服务器 (tmate.io) 的 ssh 密钥前面通过 DH 交换进行校验。 +- 客户端通过本地 ssh 密钥进行认证。 +- 连接创建后,本地 tmux 服务器会生成一个 150 位(不可猜测的随机字符)会话令牌。 +- 队友能通过用户提供的 SSH 会话 ID 连接到 tmate.io。 ### 使用 tmate 的必备条件 -由于 `tmate.io` 服务器需要通过本地 ssh 密钥来认证客户机,因此其中一个必备条件就是生成 SSH 密钥 key. -记住, 每个系统都要有自己的 SSH 密钥. +由于 `tmate.io` 服务器需要通过本地 ssh 密钥来认证客户机,因此其中一个必备条件就是生成 SSH 密钥 key。 +记住,每个系统都要有自己的 SSH 密钥。 ```shell $ ssh-keygen -t rsa -Generating public/private rsa key pair. +Generating public/private rsa key pair。 Enter file in which to save the key (/home/magi/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: -Your identification has been saved in /home/magi/.ssh/id_rsa. -Your public key has been saved in /home/magi/.ssh/id_rsa.pub. +Your identification has been saved in /home/magi/.ssh/id_rsa。 +Your public key has been saved in /home/magi/.ssh/id_rsa.pub。 The key fingerprint is: SHA256:3ima5FuwKbWyyyNrlR/DeBucoyRfdOtlUmb5D214NC8 [email protected] The key's randomart image is: @@ -42,7 +42,7 @@ The key's randomart image is: | | | . | | . . = o | -| *ooS= . + o | +| *ooS= 。 o | | . [email protected]*o.o.+ E .| | =o==B++o = . | | o.+*o+.. . | @@ -52,10 +52,10 @@ The key's randomart image is: ### 如何安装 tmate -`tmate` 已经包含在某些发行版的官方仓库中,可以通过包管理器来安装. +`tmate` 已经包含在某些发行版的官方仓库中,可以通过包管理器来安装。 -对于 **`Debian/Ubuntu`**, 可以使用 [APT-GET 命令](https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/) -或者 [APT 命令](https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/)to 来安装. +对于 **`Debian/Ubuntu`**,可以使用 [APT-GET 命令](https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/) +或者 [APT 命令](https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/)to 来安装。 ```shell $ sudo apt-get install software-properties-common @@ -64,20 +64,20 @@ $ sudo apt-get update $ sudo apt-get install tmate ``` -你也可以从官方仓库中安装 tmate. +你也可以从官方仓库中安装 tmate。 ```shell $ sudo apt-get install tmate ``` -对于 **`Fedora`**, 使用 [DNF 命令](https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/) 来安装. +对于 **`Fedora`**,使用 [DNF 命令](https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/) 来安装。 ```shell $ sudo dnf install tmate ``` -对于基于 **`Arch Linux`** 的系统, 使用 []()[Yaourt 命令](https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/) -或 []()[Packer 命令](https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/) 来从 AUR 仓库中安装. +对于基于 **`Arch Linux`** 的系统,使用 []()[Yaourt 命令](https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/) +或 []()[Packer 命令](https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/) 来从 AUR 仓库中安装。 ```shell $ yaourt -S tmate @@ -88,7 +88,7 @@ $ yaourt -S tmate $ packer -S tmate ``` -对于 **`openSUSE`**, 使用 [Zypper 命令](https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/) 来安装. +对于 **`openSUSE`**,使用 [Zypper 命令](https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/) 来安装。 ```shell $ sudo zypper in tmate @@ -96,24 +96,24 @@ $ sudo zypper in tmate ### 如何使用 tmate -成功安装后, 打开终端然后输入下面命令,就会打开一个新的会话,在屏幕底部,你能看到 SSH 会话的 ID. +成功安装后,打开终端然后输入下面命令,就会打开一个新的会话,在屏幕底部,你能看到 SSH 会话的 ID。 ```shell $ tmate ``` -![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-1.png) +![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-1.png) -要注意的是, SSH 会话 ID 会在几秒后消失, 不过不要紧,你可以通过下面命令获取到这些详细信息. +要注意的是,SSH 会话 ID 会在几秒后消失,不过不要紧,你可以通过下面命令获取到这些详细信息。 ```shell $ tmate show-messages ``` -`tmate` 的 `show-messages` 命令会显示 tmate 的 log 信息,其中包含了 ssh 连接内容。 -![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-2.png) +`tmate` 的 `show-messages` 命令会显示 tmate 的 log 信息,其中包含了 ssh 连接内容。 +![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-2.png) -现在, 分享你的 SSH 会话 ID 给你的朋友或同事从而允许他们观看终端会话. 除了 SSH 会话 ID 以外,你也可以分享 web URL。 +现在,分享你的 SSH 会话 ID 给你的朋友或同事从而允许他们观看终端会话. 除了 SSH 会话 ID 以外,你也可以分享 web URL。 另外你还可以选择分享的是只读会话还是可读写会话。 ### 如何通过 SSH 连接会话 @@ -124,15 +124,15 @@ $ tmate show-messages $ ssh session: ssh 3KuRj95sEZRHkpPtc2y6jcokP@sg2.tmate.io ``` -![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-4.png) +![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-4.png) ### 如何通过 Web URL 连接会话 -打开浏览器然后访问朋友给你的 URL 就行了. 像下面这样. -![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-3.png) +打开浏览器然后访问朋友给你的 URL 就行了. 像下面这样。 +![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-3.png) -只需要输入 `exit` 就能退出会话了. +只需要输入 `exit` 就能退出会话了。 ``` [Source System Output] @@ -140,8 +140,8 @@ $ ssh session: ssh 3KuRj95sEZRHkpPtc2y6jcokP@sg2.tmate.io [Remote System Output] [server exited] -Connection to sg2.tmate.io closed by remote host. -Connection to sg2.tmate.io closed. +Connection to sg2.tmate.io closed by remote host。 +Connection to sg2.tmate.io closed。 ``` -------------------------------------------------------------------------------- From a09bf08dc0ffc95921809d90325c004e89a4358d Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 30 Nov 2017 01:03:51 +0800 Subject: [PATCH 046/344] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Instantly Share Your Terminal Session To Anyone In Seconds.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources => translated}/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md (100%) diff --git a/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md b/translated/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md similarity index 100% rename from sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md rename to translated/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md From e9a0ae4b402c4eeab109ebc487cb9d0800a8aa9d Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 30 Nov 2017 01:11:52 +0800 Subject: [PATCH 047/344] =?UTF-8?q?update=20=E8=AF=91=E8=80=85=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Instantly Share Your Terminal Session To Anyone In Seconds.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md b/translated/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md index 2c9bde95aa..16b239f0c8 100644 --- a/translated/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md +++ b/translated/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md @@ -149,7 +149,7 @@ Connection to sg2.tmate.io closed。 via: https://www.2daygeek.com/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds/ 作者:[ Magesh Maruthamuthu ][a] -译者:[译者ID](https://github.com/译者ID) +译者:[lujun9972](https://github.com/lujun9972) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 16b3c6ab24fae8a34e051f29d3b01043035f9067 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 30 Nov 2017 08:15:08 +0800 Subject: [PATCH 048/344] =?UTF-8?q?=E5=88=A0=E9=99=A4=EF=BC=8C=E5=B7=B2?= =?UTF-8?q?=E6=9C=89=E8=AF=91=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Microservices Architecture for Failure.md | 213 ------------------ 1 file changed, 213 deletions(-) delete mode 100644 sources/tech/20170809 Designing a Microservices Architecture for Failure.md diff --git a/sources/tech/20170809 Designing a Microservices Architecture for Failure.md b/sources/tech/20170809 Designing a Microservices Architecture for Failure.md deleted file mode 100644 index e1124c229c..0000000000 --- a/sources/tech/20170809 Designing a Microservices Architecture for Failure.md +++ /dev/null @@ -1,213 +0,0 @@ -Designing a Microservices Architecture for Failure -============================================================  - - -A Microservices architecture makes it possible to **isolate failures**through well-defined service boundaries. But like in every distributed system, there is a **higher chance** for network, hardware or application level issues. As a consequence of service dependencies, any component can be temporarily unavailable for their consumers. To minimize the impact of partial outages we need to build fault tolerant services that can **gracefully** respond to certain types of outages. - -This article introduces the most common techniques and architecture patterns to build and operate a **highly available microservices** system based on [RisingStack’s Node.js Consulting & Development experience][3]. - - _If you are not familiar with the patterns in this article, it doesn’t necessarily mean that you do something wrong. Building a reliable system always comes with an extra cost._ - -### The Risk of the Microservices Architecture - -The microservices architecture moves application logic to services and uses a network layer to communicate between them. Communicating over a network instead of in-memory calls brings extra latency and complexity to the system which requires cooperation between multiple physical and logical components. The increased complexity of the distributed system leads to a higher chance of particular **network failures**. - -One of the biggest advantage of a microservices architecture over a monolithic one is that teams can independently design, develop and deploy their services. They have full ownership over their service's lifecycle. It also means that teams have no control over their service dependencies as it's more likely managed by a different team. With a microservices architecture, we need to keep in mind that provider **services can be temporarily unavailable** by broken releases, configurations, and other changes as they are controlled by someone else and components move independently from each other. - -### Graceful Service Degradation - -One of the best advantages of a microservices architecture is that you can isolate failures and achieve graceful service degradation as components fail separately. For example, during an outage customers in a photo sharing application maybe cannot upload a new picture, but they can still browse, edit and share their existing photos. - -![Microservices fail separately in theory](https://blog-assets.risingstack.com/2017/08/microservices-fail-separately-in-theory.png) - - _Microservices fail separately (in theory)_ - -In most of the cases, it's hard to implement this kind of graceful service degradation as applications in a distributed system depend on each other, and you need to apply several failover logics  _(some of them will be covered by this article later)_  to prepare for temporary glitches and outages. - -![Microservices Depend on Each Other](https://blog-assets.risingstack.com/2017/08/Microservices-depend-on-each-other.png) - - _Services depend on each other and fail together without failover logics._ - -### Change management - -Google’s site reliability team has found that roughly **70% of the outages are caused by changes** in a live system. When you change something in your service - you deploy a new version of your code or change some configuration - there is always a chance for failure or the introduction of a new bug. - -In a microservices architecture, services depend on each other. This is why you should minimize failures and limit their negative effect. To deal with issues from changes, you can implement change management strategies and **automatic rollouts**. - -For example, when you deploy new code, or you change some configuration, you should apply these changes to a subset of your instances gradually, monitor them and even automatically revert the deployment if you see that it has a negative effect on your key metrics. - -![Microservices Change Management](https://blog-assets.risingstack.com/2017/08/microservices-change-management.png) - - _Change Management - Rolling Deployment_ - -Another solution could be that you run two production environments. You always deploy to only one of them, and you only point your load balancer to the new one after you verified that the new version works as it is expected. This is called blue-green, or red-black deployment. - -**Reverting code is not a bad thing.** You shouldn’t leave broken code in production and then think about what went wrong. Always revert your changes when it’s necessary. The sooner the better. - -#### Want to learn more about building reliable mircoservices architectures? - -##### Check out our upcoming trainings! - -[MICROSERVICES TRAININGS ][4] - -### Health-check and Load Balancing - -Instances continuously start, restart and stop because of failures, deployments or autoscaling. It makes them temporarily or permanently unavailable. To avoid issues, your load balancer should **skip unhealthy instances** from the routing as they cannot serve your customers' or sub-systems' need. - -Application instance health can be determined via external observation. You can do it with repeatedly calling a `GET /health`endpoint or via self-reporting. Modern **service discovery** solutions continuously collect health information from instances and configure the load-balancer to route traffic only to healthy components. - -### Self-healing - -Self-healing can help to recover an application. We can talk about self-healing when an application can **do the necessary steps** to recover from a broken state. In most of the cases, it is implemented by an external system that watches the instances health and restarts them when they are in a broken state for a longer period. Self-healing can be very useful in most of the cases, however, in certain situations it **can cause trouble** by continuously restarting the application. This might happen when your application cannot give positive health status because it is overloaded or its database connection times out. - -Implementing an advanced self-healing solution which is prepared for a delicate situation - like a lost database connection - can be tricky. In this case, you need to add extra logic to your application to handle edge cases and let the external system know that the instance is not needed to restart immediately. - -### Failover Caching - -Services usually fail because of network issues and changes in our system. However, most of these outages are temporary thanks to self-healing and advanced load-balancing we should find a solution to make our service work during these glitches. This is where **failover caching** can help and provide the necessary data to our application. - -Failover caches usually use **two different expiration dates**; a shorter that tells how long you can use the cache in a normal situation, and a longer one that says how long can you use the cached data during failure. - -![Microservices Failover Caching](https://blog-assets.risingstack.com/2017/08/microservices-failover-caching.png) - - _Failover Caching_ - -It’s important to mention that you can only use failover caching when it serves **the outdated data better than nothing**. - -To set cache and failover cache, you can use standard response headers in HTTP. - -For example, with the `max-age` header you can specify the maximum amount of time a resource will be considered fresh. With the `stale-if-error` header, you can determine how long should the resource be served from a cache in the case of a failure. - -Modern CDNs and load balancers provide various caching and failover behaviors, but you can also create a shared library for your company that contains standard reliability solutions. - -### Retry Logic - -There are certain situations when we cannot cache our data or we want to make changes to it, but our operations eventually fail. In these cases, we can **retry our action** as we can expect that the resource will recover after some time or our load-balancer sends our request to a healthy instance. - -You should be careful with adding retry logic to your applications and clients, as a larger amount of **retries can make things even worse** or even prevent the application from recovering. - -In distributed system, a microservices system retry can trigger multiple other requests or retries and start a **cascading effect**. To minimize the impact of retries, you should limit the number of them and use an exponential backoff algorithm to continually increase the delay between retries until you reach the maximum limit. - -As a retry is initiated by the client  _(browser, other microservices, etc.)_ and the client doesn't know that the operation failed before or after handling the request, you should prepare your application to handle **idempotency**. For example, when you retry a purchase operation, you shouldn't double charge the customer. Using a unique **idempotency-key** for each of your transactions can help to handle retries. - -### Rate Limiters and Load Shedders - -Rate limiting is the technique of defining how many requests can be received or processed by a particular customer or application during a timeframe. With rate limiting, for example, you can filter out customers and microservices who are responsible for **traffic peaks**, or you can ensure that your application doesn’t overload until autoscaling can’t come to rescue. - -You can also hold back lower-priority traffic to give enough resources to critical transactions. - -![Microservices Rate Limiter](https://blog-assets.risingstack.com/2017/08/microservices-rate-limiter.png) - - _A rate limiter can hold back traffic peaks_ - -A different type of rate limiter is called the  _concurrent request limiter_ . It can be useful when you have expensive endpoints that shouldn’t be called more than a specified times, while you still want to serve traffic. - -A  _fleet usage load shedder_  can ensure that there are always enough resources available to **serve critical transactions**. It keeps some resources for high priority requests and doesn’t allow for low priority transactions to use all of them. A load shedder makes its decisions based on the whole state of the system, rather than based on a single user’s request bucket size. Load shedders **help your system to recover**, since they keep the core functionalities working while you have an ongoing incident. - -To read more about rate limiters and load shredders, I recommend checking out [Stripe’s article][5]. - -### Fail Fast and Independently - -In a microservices architecture we want to prepare our services **to fail fast and separately**. To isolate issues on service level, we can use the  _bulkhead pattern_ . You can read more about bulkheads later in this blog post. - -We also want our components to **fail fast** as we don't want to wait for broken instances until they timeout. Nothing is more disappointing than a hanging request and an unresponsive UI. It's not just wasting resources but also screwing up the user experience. Our services are calling each other in a chain, so we should pay an extra attention to prevent hanging operations before these delays sum up. - -The first idea that would come to your mind would be applying fine grade timeouts for each service calls. The problem with this approach is that you cannot really know what's a good timeout value as there are certain situations when network glitches and other issues happen that only affect one-two operations. In this case, you probably don’t want to reject those requests if there’s only a few of them timeouts. - -We can say that achieving the fail fast paradigm in microservices by **using timeouts is an anti-pattern** and you should avoid it. Instead of timeouts, you can apply the  _circuit-breaker_  pattern that depends on the success / fail statistics of operations. - -#### Want to learn more about building reliable mircoservices architectures? - -##### Check out our upcoming trainings! - -[MICROSERVICES TRAININGS ][6] - -### Bulkheads - -Bulkhead is used in the industry to **partition** a ship **into sections**, so that sections can be sealed off if there is a hull breach. - -The concept of bulkheads can be applied in software development to **segregate resources**. - -By applying the bulkheads pattern, we can **protect limited resources** from being exhausted. For example, we can use two connection pools instead of a shared on if we have two kinds of operations that communicate with the same database instance where we have limited number of connections. As a result of this client - resource separation, the operation that timeouts or overuses the pool won't bring all of the other operations down. - -One of the main reasons why Titanic sunk was that its bulkheads had a design failure, and the water could pour over the top of the bulkheads via the deck above and flood the entire hull. - -![Titanic Microservices Bulkheads](https://blog-assets.risingstack.com/2017/08/titanic-bulkhead-microservices.png) - - _Bulkheads in Titanic (they didn't work)_ - -### Circuit Breakers - -To limit the duration of operations, we can use timeouts. Timeouts can prevent hanging operations and keep the system responsive. However, using static, fine tuned timeouts in microservices communication is an **anti-pattern** as we’re in a highly dynamic environment where it's almost impossible to come up with the right timing limitations that work well in every case. - -Instead of using small and transaction-specific static timeouts, we can use circuit breakers to deal with errors. Circuit breakers are named after the real world electronic component because their behavior is identical. You can **protect resources** and **help them to recover** with circuit breakers. They can be very useful in a distributed system where a repetitive failure can lead to a snowball effect and bring the whole system down. - -A circuit breaker opens when a particular type of **error occurs multiple times** in a short period. An open circuit breaker prevents further requests to be made - like the real one prevents electrons from flowing. Circuit breakers usually close after a certain amount of time, giving enough space for underlying services to recover. - -Keep in mind that not all errors should trigger a circuit breaker. For example, you probably want to skip client side issues like requests with `4xx` response codes, but include `5xx` server-side failures. Some circuit breakers can have a half-open state as well. In this state, the service sends the first request to check system availability, while letting the other requests to fail. If this first request succeeds, it restores the circuit breaker to a closed state and lets the traffic flow. Otherwise, it keeps it open. - -![Microservices Circuit Breakers](https://blog-assets.risingstack.com/2017/08/microservices-circuit-breakers.png) - - _Circuit Breaker_ - -### Testing for Failures - -You should continually **test your system against common issues** to make sure that your services can **survive various failures**. You should test for failures frequently to keep your team prepared for incidents. - -For testing, you can use an external service that identifies groups of instances and randomly terminates one of the instances in this group. With this, you can prepare for a single instance failure, but you can even shut down entire regions to simulate a cloud provider outage. - -One of the most popular testing solutions is the [ChaosMonkey][7]resiliency tool by Netflix. - -### Outro - -Implementing and running a reliable service is not easy. It takes a lot of effort from your side and also costs money to your company. - -Reliability has many levels and aspects, so it is important to find the best solution for your team. You should make reliability a factor in your business decision processes and allocate enough budget and time for it. - -### Key Takeways - -* Dynamic environments and distributed systems - like microservices - lead to a higher chance of failures. - -* Services should fail separately, achieve graceful degradation to improve user experience. - -* 70% of the outages are caused by changes, reverting code is not a bad thing. - -* Fail fast and independently. Teams have no control over their service dependencies. - -* Architectural patterns and techniques like caching, bulkheads, circuit breakers and rate-limiters help to build reliable microservices. - -To learn more about running a reliable service check out our free [Node.js Monitoring, Alerting & Reliability 101 e-book][8]. In case you need help with implementing a microservices system, reach out to us at [@RisingStack][9] on Twitter, or enroll in our upcoming [Building Microservices with Node.js][10]. - - -------------- - -作者简介 - -[Péter Márton][2] - -CTO at RisingStack, microservices and brewing beer with Node.js - -[https://twitter.com/slashdotpeter][1] - --------------------------------------------------------------------------------- - -via: https://blog.risingstack.com/designing-microservices-architecture-for-failure/ - -作者:[ Péter Márton][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://blog.risingstack.com/author/peter-marton/ -[1]:https://twitter.com/slashdotpeter -[2]:https://blog.risingstack.com/author/peter-marton/ -[3]:https://risingstack.com/ -[4]:https://blog.risingstack.com/training-building-microservices-node-js/?utm_source=rsblog&utm_medium=roadblock-new&utm_content=/designing-microservices-architecture-for-failure/ -[5]:https://stripe.com/blog/rate-limiters -[6]:https://blog.risingstack.com/training-building-microservices-node-js/?utm_source=rsblog&utm_medium=roadblock-new -[7]:https://github.com/Netflix/chaosmonkey -[8]:https://trace.risingstack.com/monitoring-ebook -[9]:https://twitter.com/RisingStack -[10]:https://blog.risingstack.com/training-building-microservices-node-js/ -[11]:https://blog.risingstack.com/author/peter-marton/ From 6935eca303bd177890f54defbb484c5c98d652a1 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 30 Nov 2017 08:17:28 +0800 Subject: [PATCH 049/344] =?UTF-8?q?=E5=88=A0=E9=99=A4=EF=BC=8C=E8=BF=87?= =?UTF-8?q?=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20170201 GOOGLE CHROME–ONE YEAR IN.md | 290 ------------------ 1 file changed, 290 deletions(-) delete mode 100644 sources/talk/20170201 GOOGLE CHROME–ONE YEAR IN.md diff --git a/sources/talk/20170201 GOOGLE CHROME–ONE YEAR IN.md b/sources/talk/20170201 GOOGLE CHROME–ONE YEAR IN.md deleted file mode 100644 index 3a567251da..0000000000 --- a/sources/talk/20170201 GOOGLE CHROME–ONE YEAR IN.md +++ /dev/null @@ -1,290 +0,0 @@ -GOOGLE CHROME–ONE YEAR IN -======================================== - - -Four weeks ago, emailed notice of a free massage credit revealed that I’ve been at Google for a year. Time flies when you’re [drinking from a firehose][3]. - -When I mentioned my anniversary, friends and colleagues from other companies asked what I’ve learned while working on Chrome over the last year. This rambling post is an attempt to answer that question. - -### NON-MASKABLE INTERRUPTS - -While I _started_ at Google just over a year ago, I haven’t actually _worked_ there for a full year yet. My second son (Nate) was born a few weeks early, arriving ten workdays after my first day of work. - -I took full advantage of Google’s very generous twelve weeks of paternity leave, taking a few weeks after we brought Nate home, and the balance as spring turned to summer. In a year, we went from having an enormous infant to an enormous toddler who’s taking his first steps and trying to emulate everything his 3 year-old brother (Noah) does. - - ![Baby at the hospital](https://textplain.files.wordpress.com/2017/01/image55.png?w=318&h=468 "New Release") - - ![First birthday cake](https://textplain.files.wordpress.com/2017/01/image56.png?w=484&h=466) - -I mention this because it’s had a huge impact on my work over the last year—_much_ more than I’d naively expected. - -When Noah was born, I’d been at Telerik for [almost a year][4], and I’d been hacking on Fiddler alone for nearly a decade. I took a short paternity leave, and my coding hours shifted somewhat (I started writing code late at night between bottle feeds), but otherwise my work wasn’t significantly impacted. - -As I pondered joining Google Chrome’s security team, I expected pretty much the same—a bit less sleep, a bit of scheduling awkwardness, but I figured things would fall into a good routine in a few months. - -Things turned out somewhat differently. - -Perhaps sensing that my life had become too easy, fate decided that 2016 was the year I’d get sick. _Constantly_. (Our theory is that Noah was bringing home germs from pre-school; he got sick a bunch too, but recovered quickly each time.) I was sick more days in 2016 than I was in the prior decade, including a month-long illness in the spring. _That_ ended with a bout of pneumonia that concluded with a doctor-mandated seven days away from the office. As I coughed my brains out on the sofa at home, I derived some consolation in thinking about Google’s generous life insurance package. But for the most part, my illnesses were minor—enough to keep me awake at night and coughing all day, but otherwise able to work. - -Mathematically, you might expect two kids to be twice as much work as one, but in our experience, it hasn’t worked out that way. Instead, it varies between 80% (when the kids happily play together) to 400% (when they’re colliding like atoms in a runaway nuclear reactor). Thanks to my wife’s heroic efforts, we found a workable _daytime _routine. The nights, however, have been unexpectedly difficult. Big brother Noah is at an age where he usually sleeps through the night, but he’s sure to wake me up every morning at 6:30am sharp. Fortunately, Nate has been a pretty good sleeper, but even now, at just over a year old, he usually still wakes up and requires attention twice a night or so. - -I can’t_ remember _the last time I had eight hours of sleep in a row. And that’s been _extremely _challenging… because I can’t remember _much else_ either. Learning new things when you don’t remember them the next day is a brutal, frustrating process. - -When Noah was a baby, I could simply sleep in after a long night. Even if I didn’t get enough sleep, it wouldn’t really matter—I’d been coding in C# on Fiddler for a decade, and deadlines were few and far between. If all else failed, I’d just avoid working on any especially gnarly code and spend the day handling support requests, updating graphics, or doing other simple and straightforward grunt work from my backlog. - -Things are much different on Chrome. - -### ROLES - -When I first started talking to the Chrome Security team about coming aboard, it was for a role on the Developer Advocacy team. I’d be driving HTTPS adoption across the web and working with big sites to unblock their migrations in any way I could. I’d already been doing the first half of that for fun (delivering [talks][5] at conferences like Codemash and [Velocity][6]), and I’d previously spent eight years as a Security Program Manager for the Internet Explorer team. I had _tons _of relevant experience. Easy peasy. - -I interviewed for the Developer Advocate role. The hiring committee kicked back my packet and said I should interview as a Technical Program Manager instead. - -I interviewed as a Technical Program Manager. The hiring committee kicked back my packet and said I should interview as a Developer Advocate instead. - -The Chrome team resolved the deadlock by hiring me as a Senior Software Engineer (SWE). - -I was initially _very _nervous about this, having not written any significant C++ code in over a decade—except for one [in-place replacement][7] of IE9’s caching logic which I’d coded as a PM because I couldn’t find a developer to do the work. But eventually I started believing in my own pep talk: _“I mean, how hard could it be, right? I’ve been troubleshooting code in web browsers for almost two decades now. I’m not a complete dummy. I’ll ramp up. It’ll be rough, but it’ll work out. Hell, I started writing Fiddler not knowing either C# nor HTTP, and _that _turned out pretty good. I’ll buy some books and get caught up. There’s no way that Google would have just hired me as a C++ developer without asking me any C++ coding questions if it wasn’t going to all be okay. Right? Right?!?”_ - -### THE FIREHOSE - -I knew I had a lot to learn, and fast, but it took me a while to realize just how much else I didn’t know. - -Google’s primary development platform is Linux, an OS that I would install every few years, play with for a day, then forget about. My new laptop was a Mac, a platform I’d used a bit more, but still one for which I was about a twentieth as proficient as I was on Windows. The Chrome Windows team made a half-hearted attempt to get me to join their merry band, but warned me honestly that some of the tooling wasn’t quite as good as it was on Linux and it’d probably be harder for me to get help. So I tried to avoid Windows for the first few months, ordering a puny Windows machine that took around four times longer to build Chrome than my obscenely powerful Linux box (with its 48 logical cores). After a few months, I gave up on trying to avoid Windows and started using it as my primary platform. I was more productive, but incredibly slow builds remained a problem for a few months. Everyone told me to just order _another_ obscenely powerful box to put next to my Linux one, but it felt wrong to have hardware at my desk that collectively cost more than my first car—especially when, at Microsoft, I bought all my own hardware. I eventually mentioned my cost/productivity dilemma to a manager, who noted I was getting paid a Google engineer’s salary and then politely asked me if I was just really terrible at math. I ordered a beastly Windows machine and now my builds scream. (To the extent that _any_ C++ builds can scream, of course. At Telerik, I was horrified when a full build of Fiddler slowed to a full 5 seconds on my puny Windows machine; my typical Chrome build today still takes about 15 minutes.) - -Beyond learning different operating systems, I’d never used Google’s apps before (Docs/Sheets/Slides); luckily, I found these easy to pick up, although I still haven’t fully figured out how Google Drive file organization works. Google Docs, in particular, is so good that I’ve pretty much given up on Microsoft Word (which headed downhill after the 2010 version). Google Keep is a low-powered alternative to OneNote (which is, as far as I can tell, banned because it syncs to Microsoft servers) and I haven’t managed to get it to work well for my needs. Google Plus still hasn’t figured out how to support pasting of images via CTRL+V, a baffling limitation for something meant to compete in the space… hell, even _Microsoft Yammer _supports that, for gods sake. The only real downside to the web apps is that tab/window management on modern browsers is still a very much unsolved problem (but more on that in a bit). - -But these speedbumps all pale in comparison to Gmail. Oh, Gmail. As a program manager at Microsoft, pretty much your _entire life _is in your inbox. After twelve years with Outlook and Exchange, switching to Gmail was a train wreck. “_What do you mean, there aren’t folders? How do I mark this message as low priority? Where’s the button to format text with strikethrough? What do you mean, I can’t drag an email to my calendar? What the hell does this Archive thing do? Where’s that message I was just looking at? Hell, where did my Gmail tab even go—it got lost in a pile of sixty other tabs across four top-level Chrome windows. WTH??? How does anyone get anything done?”_ - -### COMMUNICATION AND REMOTE WORK - -While Telerik had an office in Austin, I didn’t interact with other employees very often, and when I did they were usually in other offices. I thought I had a handle on remote work, but I really didn’t. Working with a remote team on a daily basis is just _different_. - -With communication happening over mail, IRC, Hangouts, bugs, document markup comments, GVC (video conferencing), G+, and discussion lists, it was often hard to [figure out which mechanisms to use][8], let alone which recipients to target. Undocumented pitfalls abounded (many discussion groups were essentially abandoned while others were unexpectedly broad; turning on chat history was deemed a “no-no” for document retention reasons). - -It often it took a bit of research to even understand who various communication participants were and how they related to the projects at hand. - -After years of email culture at Microsoft, I grew accustomed to a particular style of email, and Google’s is just _different._ Mail threads were long, with frequent additions of new recipients and many terse remarks. Many times, I’d reply privately to someone on a side thread, with a clarifying question, or suggesting a counterpoint to something they said. The response was often “_Hey, this just went to me. Mind adding on the main thread?_” - -I’m working remotely, with peers around the world, so real-time communication with my team is essential. Some Chrome subteams use Hangouts, but the Security team largely uses IRC. - -[ - ![XKCD comic on IRC](https://textplain.files.wordpress.com/2017/01/image30.png?w=1320&h=560 "https://xkcd.com/1782/") -][9] - -Now, I’ve been chatting with people online since BBSes were a thing (I’ve got a five digit ICQ number somewhere), but my knowledge of IRC was limited to the fact that it was a common way of taking over suckers’ machines with buffer overflows in the ‘90s. My new teammates tried to explain how to IRC repeatedly: “_Oh, it’s easy, you just get this console IRC client. No, no, you don’t run it on your own workstation, that’d be crazy. You wouldn’t have history! You provision a persistent remote VM on a machine in Google’s cloud, then SSH to that, then you run screens and then you run your IRC client in that. Easy peasy._” - -Getting onto IRC remained on my “TODO” list for five months before I finally said “F- it”, installed [HexChat][10] on my Windows box, disabled automatic sleep, and called it done. It’s worked fairly well. - -### GOOGLE DEVELOPER TOOLING - -When an engineer first joins Google, they start with a week or two of technical training on the Google infrastructure. I’ve worked in software development for nearly two decades, and I’ve never even dreamed of the development environment Google engineers get to use. I felt like Charlie Bucket on his tour of Willa Wonka’s Chocolate Factory—astonished by the amazing and unbelievable goodies available at any turn. The computing infrastructure was something out of Star Trek, the development tools were slick and amazing, the _process_ was jaw-dropping. - -While I was doing a “hello world” coding exercise in Google’s environment, a former colleague from the IE team pinged me on Hangouts chat, probably because he’d seen my tweets about feeling like an imposter as a SWE.  He sent me a link to click, which I did. Code from Google’s core advertising engine appeared in my browser. Google’s engineers have access to nearly all of the code across the whole company. This alone was astonishing—in contrast, I’d initially joined the IE team so I could get access to the networking code to figure out why the Office Online team’s website wasn’t working. “Neat, I can see everything!” I typed back. “Push the Analyze button” he instructed. I did, and some sort of automated analyzer emitted a report identifying a few dozen performance bugs in the code. “Wow, that’s amazing!” I gushed. “Now, push the Fix button” he instructed. “Uh, this isn’t some sort of security red team exercise, right?” I asked. He assured me that it wasn’t. I pushed the button. The code changed to fix some unnecessary object copies. “Amazing!” I effused. “Click Submit” he instructed. I did, and watched as the system compiled the code in the cloud, determined which tests to run, and ran them. Later that afternoon, an owner of the code in the affected folder typed LGTM (Googlers approve changes by typing the acronym for Looks Good To Me) on the change list I had submitted, and my change was live in production later that day. I was, in a word, gobsmacked. That night, I searched the entire codebase for [misuse][11] of an IE cache control token and proposed fixes for the instances I found. I also narcissistically searched for my own name and found a bunch of references to blog posts I’d written about assorted web development topics. - -Unfortunately for Chrome Engineers, the introduction to Google’s infrastructure is followed by a major letdown—because Chromium is open-source, the Chrome team itself doesn’t get to take advantage of most of Google’s internal goodies. Development of Chrome instead resembles C++ development at most major companies, albeit with an automatically deployed toolchain and enhancements like a web-based code review tool and some super-useful scripts. The most amazing of these is called [bisect-builds][12], and it allows a developer to very quickly discover what build of Chrome introduced a particular bug. You just give it a “known good” build number and a “known bad” build number and it  automatically downloads and runs the minimal number of builds to perform a binary search for the build that introduced a given bug: - - ![Console showing bisect builds running](https://textplain.files.wordpress.com/2017/01/image31.png?w=1320&h=514 "Binary searching for regressions") - -Firefox has [a similar system][13], but I’d’ve killed for something like this back when I was reproducing and reducing bugs in IE. While it’s easy to understand how the system functions, it works so well that it feels like magic. Other useful scripts include the presubmit checks that run on each change list before you submit them for code review—they find and flag various style violations and other problems. - -Compilation itself typically uses a local compiler; on Windows, we use the MSVC command line compiler from Visual Studio 2015 Update 3, although work is underway to switch over to [Clang][14]. Compilation and linking all of Chrome takes quite some time, although on my new beastly dev boxes it’s not _too_ bad. Googlers do have one special perk—we can use Goma (a distributed compiler system that runs on Google’s amazing internal cloud) but I haven’t taken advantage of that so far. - -For bug tracking, Chrome recently moved to [Monorail][15], a straightforward web-based bug tracking system. It works fairly well, although it is somewhat more cumbersome than it needs to be and would be much improved with [a few tweaks][16]. Monorail is open-source, but I haven’t committed to it myself yet. - -For code review, Chrome presently uses [Rietveld][17], a web-based system, but this is slated to change in the near(ish) future. Like Monorail, it’s pretty straightforward although it would benefit from some minor usability tweaks; I committed one trivial change myself, but the pending migration to a different system means that it isn’t likely to see further improvements. - -As an open-source project, Chromium has quite a bit of public [documentation for developers][18], including [Design Documents][19]. Unfortunately, Chrome moves so fast that many of the design documents are out-of-date, and it’s not always obvious what’s current and what was replaced long ago. The team does _value_ engineers’ investment in the documents, however, and various efforts are underway to update the documents and reduce Chrome’s overall architectural complexity. I expect these will be ongoing battles forever, just like in any significant active project. - -### WHAT I’VE DONE - -“That’s all well and good,” my reader asks, “but _what have you done_ in the last year?” - -### I WROTE SOME CODE - -My first check in to Chrome [landed][20] in February; it was a simple adjustment to limit Public-Key-Pins to 60 days. Assorted other checkins trickled in through the spring before I went on paternity leave. The most _fun_ fix I did cleaned up a tiny [UX glitch][21] that sat unnoticed in Chrome for almost a decade; it was mostly interesting because it was a minor thing that I’d tripped over for years, including back in IE. (The root cause was arguably that MSDN documentation about DWM lied; I fixed the bug in Chrome, sent the fix to IE, and asked MSDN to fix their docs). - -I fixed a number of [minor][22] [security][23] [bugs][24], and lately I’ve been working on [UX issues][25] related to Chrome’s HTTPS user-experience. Back in 2005, I wrote [a blog post][26] complaining about websites using HTTPS incorrectly, and now, just over a decade later, Chrome and Firefox are launching UI changes to warn users when a site is collecting sensitive information on pages which are Not Secure; I’m delighted to have a small part in those changes. - -Having written a handful of Internet Explorer Extensions in the past, I was excited to discover the joy of writing Chrome extensions. Chrome extensions are fun, simple, and powerful, and there’s none of the complexity and crashes of COM. - -[ - ![My 3 Chrome Extensions](https://textplain.files.wordpress.com/2017/01/image201.png?w=1288&h=650 "My 3 Chrome Extensions") -][27] - -My first and most significant extension is the moarTLS Analyzer– it’s related to my HTTPS work at Google and it’s proven very useful in discovering sites that could improve their security. I [blogged about it][28] and the process of [developing it][29] last year. - -Because I run several different Chrome instances on my PC (and they update daily or weekly), I found myself constantly needing to look up the Chrome version number for bug reports and the like. I wrote a tiny extension that shows the version number in a button on the toolbar (so it’s captured in screenshots too!): - - ![Show Chrome Version screenshot](https://textplain.files.wordpress.com/2017/02/image.png?w=886&h=326 "Show Chrome Version") - -More than once, I spent an hour or so trying to reproduce and reduce a bug that had been filed against Chrome. When I found out the cause, I’d jubilently add my notes to the issue in the Monorail bug tracker, click “Save changes” and discover that someone more familiar with the space had beaten me to the punch and figured it out while I’d had the bug open on my screen. Adding an “Issue has been updated” alert to the bug tracker itself seemed like the right way to go, but it would require some changes that I wasn’t able to commit on my own. So, instead I built an extension that provides such alerts within the page until the [feature][30] can be added to the tracker itself. - -Each of these extensions was a joy to write. - -### I FILED SOME BUGS - -I’m a diligent self-hoster, and I run Chrome Canary builds on all of my devices. I submit crash reports and [file bugs][31] with as much information as I can. My proudest moment was in helping narrow down a bizarre and intermittent problem users had with Chrome on Windows 10, where Chrome tabs would crash on every startup until you rebooted the OS. My [blog post][32] explains the full story, and encourages others to file bugs as they encounter them. - -### I TRIAGED MORE BUGS - -I’ve been developing software for Windows for just over two decades, and inevitably I’ve learned quite a bit about it, including the undocumented bits. That’s given me a leg up in understanding bugs in the Windows code. Some of the most fun include issues in Drag and Drop, like this [gem][33] of a bug that means that you can’t drop files from Chrome to most applications in Windows. More meaningful [bugs][34] [relate][35] [to][36] [problems][37] with Windows’ Mark-of-the-Web security feature (about which I’ve [blogged][38] [about][39] [several][40] times). - -### I TOOK SHERIFF ROTATIONS - -Google teams have the notion of sheriffs—a rotating assignment that ensures that important tasks (like triaging incoming security bugs) always has a defined owner, without overwhelming any single person. Each Sheriff has a term of ~1 week where they take on additional duties beyond their day-to-day coding, designing, testing, etc. - -The Sheriff system has some real benefits—perhaps the most important of which is creating a broad swath of people experienced and qualified in making triage decisions around security vulnerabilities. The alternative is to leave such tasks to a single owner, rapidly increasing their [bus factor][41] and thus the risk to the project. (I know this from first-hand experience. After IE8 shipped, I was on my way out the door to join another team. Then IE’s Security PM left, leaving a gaping hole that I felt obliged to stay around to fill. It worked out okay for me and the team, but it was tense all around.) - -I’m on two sheriff rotations: [Enamel][42] (my subteam) and the broader Chrome Security Sheriff. - -The Enamel rotation’s tasks are akin to what I used to do as a Program Manager at Microsoft—triage incoming bugs, respond to questions in the [Help Forums][43], and generally act as a point of contact for my immediate team. - -In contrast, the Security Sheriff rotation is more work, and somewhat more exciting. The Security Sheriff’s [duties][44] include triaging all bugs of type “Security”, assigning priority, severity, and finding an owner for each. Most security bugs are automatically reported by [our fuzzers][45] (a tireless robot army!), but we also get reports from the public and from Chrome team members and [Project Zero][46] too. - -At Microsoft, incoming security bug reports were first received and evaluated by the Microsoft Security Response Center (MSRC); valid reports were passed along to the IE team after some level of analysis and reproduction was undertaken. In general, all communication was done through MSRC, and the turnaround cycle on bugs was _typically _on the order of weeks to months. - -In contrast, anyone can [file a security bug][47] against Chrome, and every week lots of people do. One reason for that is that Chrome has a [Vulnerability Rewards program][48] which pays out up to $100K for reports of vulnerabilities in Chrome and Chrome OS. Chrome paid out just under $1M USD in bounties [last year][49]. This is an _awesome _incentive for researchers to responsibly disclose bugs directly to us, and the bounties are _much _higher than those of nearly any other project. - -In his “[Hacker Quantified Security][50]” talk at the O’Reilly Security conference, HackerOne CTO and Cofounder Alex Rice showed the following chart of bounty payout size for vulnerabilities when explaining why he was using a Chromebook. Apologies for the blurry photo, but the line at the top shows Chrome OS, with the 90th percentile line miles below as severity rises to Critical: - -[ - ![Vulnerability rewards by percentile. Chrome is WAY off the chart.](https://textplain.files.wordpress.com/2017/01/image_thumb6.png?w=962&h=622 "Chrome Vulnerability Rewards are Yuuuuge") -][51] - -With a top bounty of $100000 for an exploit or exploit chain that fully compromises a Chromebook, researchers are much more likely to send their bugs to us than to try to find a buyer on the black market. - -Bug bounties are great, except when they’re not. Unfortunately, many filers don’t bother to read the [Chrome Security FAQ][52] which explains what constitutes a security vulnerability and the great many things that do not. Nearly every week, we have at least one person (and often more) file a bug noting “_I can use the Developer Tools to read my own password out of a webpage. Can I have a bounty?_” or “_If I install malware on my PC, I can see what happens inside Chrome” _or variations of these. - -Because we take security bug reports very seriously, we often spend a lot of time on what seem like garbage filings to verify that there’s not just some sort of communication problem. This exposes one downside of the sheriff process—the lack of continuity from week to week. - -In the fall, we had one bug reporter file a new issue every week that was just a collection of security related terms (XSS! CSRF! UAF! EoP! Dangling Pointer! Script Injection!) lightly wrapped in prose, including screenshots, snippets from websites, console output from developer tools, and the like. Each week, the sheriff would investigate, ask for more information, and engage in a fruitless back and forth with the filer trying to figure out what claim was being made. Eventually I caught on to what was happening and started monitoring the sheriff’s queue, triaging the new findings directly and sparing the sheriff of the week. But even today we still catch folks who lookup old bug reports (usually Won’t Fixed issues), copy/paste the content into new bugs, and file them into the queue. It’s frustrating, but coming from a closed bug database, I’d choose the openness of the Chrome bug database every time. - -Getting ready for my first Sherriff rotation, I started watching the incoming queue a few months earlier and felt ready for my first rotation in September. Day One was quiet, with a few small issues found by fuzzers and one or two junk reports from the public which I triaged away with pointers to the “_Why isn’t a vulnerability_” entries in the Security FAQ. I spent the rest of the day writing a fix for a lower-priority security [bug][53] that had been filed a month before. A pretty successful day, I thought. - -Day Two was more interesting. Scanning the queue, I saw a few more fuzzer issues and [one external report][54] whose text started with “Here is a Chrome OS exploit chain.” The report was about two pages long, and had a forty-two page PDF attachment explaining the four exploits the finder had used to take over a fully-patched Chromebook. - - ![Star Wars trench run photo](https://textplain.files.wordpress.com/2017/02/image1.png?w=478&h=244 "Defenses can't keep up!") - -Watching Luke’s X-wing take out the Death Star in Star Wars was no more exciting than reading the PDF’s tale of how a single byte memory overwrite in the DNS resolver code could weave its way through the many-layered security features of the Chromebook and achieve a full compromise. It was like the most amazing magic trick you’ve ever seen. - -I hopped over to IRC. “So, do we see full compromises of Chrome OS every week?” I asked innocently. - -“No. Why?” came the reply from several corners. I pasted in the bug link and a few moments later the replies started flowing in “OMG. Amazing!” Even guys from Project Zero were impressed, and they’re magicians who build exploits like this (usually for other products) all the time. The researcher had found one small bug and a variety of neglected components that were thought to be unreachable and put together a deadly chain. - -The first patches were out for code review that evening, and by the next day, we’d reached out to the open-source owner of the DNS component with the 1-byte overwrite bug so he could release patches for the other projects using his code. Within a few days, fixes to other components landed and had been ported to all of the supported versions of Chrome OS. Two weeks later, the Chrome Vulnerability rewards team added the [reward-100000][55] tag, the only bug so far to be so marked. Four weeks after that, I had to hold my tongue when Alex mentioned that “no one’s ever claimed that $100000 bounty” during his “Hacker Quantified Security” talk. Just under 90 days from filing, the bug was unrestricted and made available for public viewing. - -The remainder of my first Sheriff rotation was considerably less exciting, although still interesting. I spent some time looking through the components the researcher had abused in his exploit chain and filed a few bugs. Ultimately, the most risky component he used was removed entirely. - -### OUTREACH AND BLOGGING - -Beyond working on the Enamel team (focused on Chrome’s security UI surface), I also work on the “MoarTLS” project, designed to help encourage and assist the web as a whole in moving to HTTPS. This takes a number of forms—I help maintain the [HTTPS on Top Sites Report Card][56], I do consultations and HTTPS Audits with major sites as they enable HTTPS on their sites. I discover, reduce, and file bugs on Chrome’s and other browsers’ support of features like Upgrade-Insecure-Requests. I publish a [running list of articles][57] on why and how sites should enable TLS. I hassle teams all over Google (and the web in general) to enable HTTPS on every single hyperlink they emit. I responsibly disclosed security bugs in a number of products and sites, including [a vulnerability][58] in Hillary Clinton’s fundraising emails. I worked to send a notification to many many many thousands of sites collecting user information non-securely, warning them of the [UI changes in Chrome 56][59]. - -When I applied to Google for the Developer Advocate role, I expected I’d be delivering public talks _constantly_, but as a SWE I’ve only given a few talks, including my  [Migrating to HTTPS talk][60] at the first O’Reilly Security Conference. I had a lot of fun at that conference, catching up with old friends from the security community (mostly ex-Microsofties). I also went to my first [Chrome Dev Summit][61], where I didn’t have a public talk (my colleagues did) but I did get to talk to some major companies about deploying HTTPS. - -I also blogged [quite a bit][62]. At Microsoft, I started blogging because I got tired of repeating myself, and because our Exchange server and document retention policies had started making it hard or impossible to find old responses—I figured “Well, if I publish everything on the web, Google will find it, and Internet Archive will back it up.” - -I’ve kept blogging since leaving Microsoft, and I’m happy that I have even though my reader count numbers are much lower than they were at Microsoft. I’ve managed to mostly avoid trouble, although my posts are not entirely uncontroversial. At Microsoft, they wouldn’t let me publish [this post][63] (because it was too frank); in my first month at Google, I got a phone call at home (during the first portion of my paternity leave) from a Google Director complaining that I’d written [something][64] that was too harsh about a change Microsoft had made. But for the most part, my blogging seems not to ruffle too many feathers. - -### TIDBITS - -* Food at Google is generally _really _good; I’m at a satellite office in Austin, so the selection is much smaller than on the main campuses, but the rotating menu is fairly broad and always has at least three major options. And the breakfasts! I gained about 15 pounds in my first few months, but my pneumonia took it off and I’ve restrained my intake since I came back. -* At Microsoft, I always sneered at companies offering free food (“I’m an adult professional. I can pay for my lunch.”), but it’s definitely convenient to not have to hassle with payments. And until the government closes the loophole, it’s a way to increase employees’ compensation without getting taxed. -* For the first three months, I was impressed and slightly annoyed that all of the snack options in Google’s micro-kitchens are healthy (e.g. fruit)—probably a good thing, since I sit about twenty feet from one. Then I saw someone open a drawer and pull out some M&Ms, and I learned the secret—all of the junk food is in drawers. The selection is impressive and ranges from the popular to the high end. -* Google makes heavy use of the “open-office concept.” I think this makes sense for some teams, but it’s not at all awesome for me. I’d gladly take a 10% salary cut for a private office. I doubt I’m alone. -* Coworkers at Google range from very smart to insanely off-the-scales-smart. Yet, almost all of them are humble, approachable, and kind. -* Google, like Microsoft, offers gift matching for charities. This is an awesome perk, and one I aim to max out every year. I’m awed by people who go [far][1] beyond that. -* **Window Management – **I mentioned earlier that one downside of web-based tools is that it’s hard to even _find _the right tab when I’ve got dozens of open tabs that I’m flipping between. The [Quick Tabs extension][2] is one great mitigation; it shows your tabs in a searchable, most-recently-used list in a convenient dropdown: - -[ - ![QuickTabs Extension](https://textplain.files.wordpress.com/2017/01/image59.png?w=526&h=376 "A Searchable MRU of open tabs. Yes please!") -][65] - -Another trick that I learned just this month is that you can instruct Chrome to open a site in “App” mode, where it runs in its own top-level window (with no other tabs), showing the site’s icon as the icon in the Windows taskbar. It’s easy: - -On Windows, run chrome.exe –app=https://mail.google.com - -While on OS X, run open -n -b com.google.Chrome –args –app=’[https://news.google.com][66]‘ - -_Tip: The easy way to create a shortcut to a the current page in app mode is to click the Chrome Menu > More Tools > Add to {shelf/desktop} and tick the Open as Window checkbox._ - -I now have [SlickRun][67] MagicWords set up for **mail**, **calendar**, and my other critical applications. - --------------------------------------------------------------------------------- - -via: https://textslashplain.com/2017/02/01/google-chrome-one-year-in/ - -作者:[ericlaw][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://textslashplain.com/author/ericlaw1979/ -[1]:https://www.jefftk.com/p/leaving-google-joining-wave -[2]:https://chrome.google.com/webstore/detail/quick-tabs/jnjfeinjfmenlddahdjdmgpbokiacbbb -[3]:https://textslashplain.com/2015/12/23/my-next-adventure/ -[4]:http://sdtimes.com/telerik-acquires-fiddler-debugger-along-with-its-creator/ -[5]:https://bayden.com/dl/Codemash2015-ericlaw-https-in-2015.pptx -[6]:https://conferences.oreilly.com/velocity/devops-web-performance-2015/public/content/2015/04/16-https-stands-for-user-experience -[7]:https://textslashplain.com/2015/04/09/on-appreciation/ -[8]:https://xkcd.com/1254/ -[9]:http://m.xkcd.com/1782/ -[10]:https://hexchat.github.io/ -[11]:https://blogs.msdn.microsoft.com/ieinternals/2009/07/20/internet-explorers-cache-control-extensions/ -[12]:https://www.chromium.org/developers/bisect-builds-py -[13]:https://mozilla.github.io/mozregression/ -[14]:https://chromium.googlesource.com/chromium/src/+/lkgr/docs/clang.md -[15]:https://bugs.chromium.org/p/monorail/adminIntro -[16]:https://bugs.chromium.org/p/monorail/issues/list?can=2&q=reporter%3Aelawrence -[17]:https://en.wikipedia.org/wiki/Rietveld_(software) -[18]:https://www.chromium.org/developers -[19]:https://www.chromium.org/developers/design-documents -[20]:https://codereview.chromium.org/1733973004/ -[21]:https://codereview.chromium.org/2244263002/ -[22]:https://codereview.chromium.org/2323273003/ -[23]:https://codereview.chromium.org/2368593002/ -[24]:https://codereview.chromium.org/2347923002/ -[25]:https://codereview.chromium.org/search?closed=1&owner=elawrence&reviewer=&cc=&repo_guid=&base=&project=&private=1&commit=1&created_before=&created_after=&modified_before=&modified_after=&order=&format=html&keys_only=False&with_messages=False&cursor=&limit=30 -[26]:https://blogs.msdn.microsoft.com/ie/2005/04/20/tls-and-ssl-in-the-real-world/ -[27]:https://chrome.google.com/webstore/search/bayden?hl=en-US&_category=extensions -[28]:https://textslashplain.com/2016/03/17/seek-and-destroy-non-secure-references-using-the-moartls-analyzer/ -[29]:https://textslashplain.com/2016/03/18/building-the-moartls-analyzer/ -[30]:https://bugs.chromium.org/p/monorail/issues/detail?id=1739 -[31]:https://bugs.chromium.org/p/chromium/issues/list?can=1&q=reporter%3Ame&colspec=ID+Pri+M+Stars+ReleaseBlock+Component+Status+Owner+Summary+OS+Modified&x=m&y=releaseblock&cells=ids -[32]:https://textslashplain.com/2016/08/18/file-the-bug/ -[33]:https://bugs.chromium.org/p/chromium/issues/detail?id=540547 -[34]:https://bugs.chromium.org/p/chromium/issues/detail?id=601538 -[35]:https://bugs.chromium.org/p/chromium/issues/detail?id=595844#c6 -[36]:https://bugs.chromium.org/p/chromium/issues/detail?id=629637 -[37]:https://bugs.chromium.org/p/chromium/issues/detail?id=591343 -[38]:https://textslashplain.com/2016/04/04/downloads-and-the-mark-of-the-web/ -[39]:https://blogs.msdn.microsoft.com/ieinternals/2011/03/23/understanding-local-machine-zone-lockdown/ -[40]:https://blogs.msdn.microsoft.com/ieinternals/2012/06/19/enhanced-protected-mode-and-local-files/ -[41]:https://en.wikipedia.org/wiki/Bus_factor -[42]:https://www.chromium.org/Home/chromium-security/enamel -[43]:https://productforums.google.com/forum/#!forum/chrome -[44]:https://www.chromium.org/Home/chromium-security/security-sheriff -[45]:https://blog.chromium.org/2012/04/fuzzing-for-security.html -[46]:https://en.wikipedia.org/wiki/Project_Zero_(Google) -[47]:https://bugs.chromium.org/p/chromium/issues/entry?template=Security%20Bug -[48]:https://www.google.com/about/appsecurity/chrome-rewards/ -[49]:https://security.googleblog.com/2017/01/vulnerability-rewards-program-2016-year.html -[50]:https://conferences.oreilly.com/security/network-data-security-ny/public/schedule/detail/53296 -[51]:https://textplain.files.wordpress.com/2017/01/image58.png -[52]:https://dev.chromium.org/Home/chromium-security/security-faq -[53]:https://bugs.chromium.org/p/chromium/issues/detail?id=639126#c11 -[54]:https://bugs.chromium.org/p/chromium/issues/detail?id=648971 -[55]:https://bugs.chromium.org/p/chromium/issues/list?can=1&q=label%3Areward-100000&colspec=ID+Pri+M+Stars+ReleaseBlock+Component+Status+Owner+Summary+OS+Modified&x=m&y=releaseblock&cells=ids -[56]:https://www.google.com/transparencyreport/https/grid/?hl=en -[57]:https://whytls.com/ -[58]:https://textslashplain.com/2016/09/22/use-https-for-all-inbound-links/ -[59]:https://security.googleblog.com/2016/09/moving-towards-more-secure-web.html -[60]:https://www.safaribooksonline.com/library/view/the-oreilly-security/9781491960035/video287622.html -[61]:https://developer.chrome.com/devsummit/ -[62]:https://textslashplain.com/2016/ -[63]:https://blogs.msdn.microsoft.com/ieinternals/2013/10/16/strict-p3p-validation/ -[64]:https://textslashplain.com/2016/01/20/putting-users-first/ -[65]:https://chrome.google.com/webstore/detail/quick-tabs/jnjfeinjfmenlddahdjdmgpbokiacbbb -[66]:https://news.google.com/ -[67]:https://bayden.com/slickrun/ From 2090f9d9dd5f0b1956c50ee079851e169bb68d16 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 30 Nov 2017 08:46:12 +0800 Subject: [PATCH 050/344] translated --- ...ng network connections on Linux systems.md | 62 +++++++++---------- 1 file changed, 30 insertions(+), 32 deletions(-) rename {sources => translated}/tech/20171009 Examining network connections on Linux systems.md (62%) diff --git a/sources/tech/20171009 Examining network connections on Linux systems.md b/translated/tech/20171009 Examining network connections on Linux systems.md similarity index 62% rename from sources/tech/20171009 Examining network connections on Linux systems.md rename to translated/tech/20171009 Examining network connections on Linux systems.md index 1a9c617503..7fc95738e9 100644 --- a/sources/tech/20171009 Examining network connections on Linux systems.md +++ b/translated/tech/20171009 Examining network connections on Linux systems.md @@ -1,24 +1,21 @@ -translating---geekpi - - -Examining network connections on Linux systems +检查 Linux 系统上的网络连接 ============================================================ -### Linux systems provide a lot of useful commands for reviewing network configuration and connections. Here's a look at a few, including ifquery, ifup, ifdown and ifconfig. +### Linux 系统提供了许多有用的命令来检查网络配置和连接。下面来看几个,包括 ifquery、ifup、ifdown 和 ifconfig。 -There are a lot of commands available on Linux for looking at network settings and connections. In today's post, we're going to run through some very handy commands and see how they work. +Linux 上有许多可用于查看网络设置和连接的命令。在今天的文章中,我们将会通过一些非常方便的命令来看看它们是如何工作的。 -### ifquery command +### ifquery 命令 -One very useful command is the **ifquery** command. This command should give you a quick list of network interfaces. However, you might only see something like this —showing only the loopback interface: +一个非常有用的命令是 **ifquery**。这个命令应该会显示一个网络接口列表。但是,你可能只会看到类似这样的内容 - 仅显示回环接口: ``` $ ifquery --list lo ``` -If this is the case, your **/etc/network/interfaces** file doesn't include information on network interfaces except for the loopback interface. You can add lines like the last two in the example below — assuming DHCP is used to assign addresses — if you'd like it to be more useful. +如果是这种情况,那么你的 **/etc/network/interfaces** 不包括除了回环接口之外的网络接口信息。在下面的例子中,假设你使用 DHCP 来分配地址,且如果你希望它更有用的话,你可以添加例子最后的两行。 ``` # interfaces(5) file used by ifup(8) and ifdown(8) @@ -28,15 +25,16 @@ auto eth0 iface eth0 inet dhcp ``` -### ifup and ifdown commands +### ifup 和 ifdown 命令 + +可以使用相关的 **ifup** 和 **ifdown** 命令来打开网络连接并根据需要将其关闭,只要该文件具有所需的描述性数据即可。请记住,“if” 在这里意思是“接口” (interface),这与 **ifconfig** 命令中的一样,而不是“如果我只有一个大脑” (if I only had a brain) 中的 “if”。 -The related **ifup** and **ifdown** commands can be used to bring network connections up and shut them down as needed provided this file has the required descriptive data. Just keep in mind that "if" means "interface" in these commands just as it does in the **ifconfig** command, not "if" as in "if I only had a brain". -### ifconfig command +### ifconfig 命令 -The **ifconfig** command, on the other hand, doesn't read the /etc/network/interfaces file at all and still provides quite a bit of useful information on network interfaces -- configuration data along with packet counts that tell you how busy each interface has been. The ifconfig command can also be used to shut down and restart network interfaces (e.g., ifconfig eth0 down). +另外,**ifconfig** 命令完全不读取 /etc/network/interfaces,但是在网络接口上仍然提供了相当多的有用信息 - 配置数据以及数据包计数可以告诉你每个接口有多忙。ifconfig 命令也可用于关闭和重新启动网络接口(例如:ifconfig eth0 down)。 ``` $ ifconfig eth0 @@ -51,13 +49,13 @@ eth0 Link encap:Ethernet HWaddr 00:1e:4f:c8:43:fc Interrupt:21 Memory:fe9e0000-fea00000 ``` -The RX and TX packet counts in this output are extremely low. In addition, no errors or packet collisions have been reported. The **uptime** command will likely confirm that this system has only recently been rebooted. +输出中的 RX 和 TX 数据包计数很低。此外,没有报告错误或数据包冲突。**uptime** 命令可能会确认此系统最近才重新启动。 -The broadcast (Bcast) and network mask (Mask) addresses shown above indicate that the system is operating on a Class C equivalent network (the default) so local addresses will range from 192.168.0.1 to 192.168.0.254. +上面显示的广播 (Bcast) 和网络掩码 (Mask) 地址表明系统运行在 C 类等效网络(默认)上,所以本地地址范围从 192.168.0.1 到 192.168.0.254。 -### netstat command +### netstat 命令 -The **netstat** command provides information on routing and network connections. The **netstat -rn** command displays the system's routing table. +**netstat** 命令提供有关路由和网络连接的信息。**netstat -rn** 命令显示系统的路由表。 @@ -70,7 +68,7 @@ Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 ``` -That **169.254.0.0** entry in the above output is only necessary if you are using or planning to use link-local communications. You can comment out the related lines in the **/etc/network/if-up.d/avahi-autoipd** file like this if this is not the case: +上面输出中的 **169.254.0.0** 条目仅在你正在使用或计划使用本地链路通信时才有必要。如果不是这样的话,你可以在 **/etc/network/if-up.d/avahi-autoipd** 中注释掉相关的行: ``` $ tail -12 /etc/network/if-up.d/avahi-autoipd @@ -87,9 +85,9 @@ $ tail -12 /etc/network/if-up.d/avahi-autoipd #fi ``` -### netstat -a command +### netstat -a 命令 -The **netstat -a** command will display  **_all_**  network connections. To limit this to listening and established connections (generally much more useful), use the **netstat -at** command instead. +**netstat -a** 命令将显示 **_所有_** 网络连接。为了将其限制为正在监听和已建立的连接(通常更有用),请改用 **netstat -at** 命令。 ``` $ netstat -at @@ -105,9 +103,9 @@ tcp6 0 0 ip6-localhost:ipp [::]:* LISTEN tcp6 0 0 ip6-localhost:smtp [::]:* LISTEN ``` -### netstat -rn command +### netstat -rn 命令 -The **netstat -rn** command displays the system's routing table. The 192.168.0.1 address is the local gateway (Flags=UG). +**netstat -rn** 展示系统的路由表。192.168.0.1 是本地网关 (Flags=UG)。 ``` $ netstat -rn @@ -117,9 +115,9 @@ Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 ``` -### host command +### host 命令 -The **host** command works a lot like **nslookup** by looking up the remote system's IP address, but also provides the system's mail handler. +**host** 命令就像 **nslookup** 一样,用来查询远程系统的 IP 地址,但是还提供系统的邮箱处理地址。 ``` $ host world.std.com @@ -127,9 +125,9 @@ world.std.com has address 192.74.137.5 world.std.com mail is handled by 10 smtp.theworld.com. ``` -### nslookup command +### nslookup 命令 -The **nslookup** also provides information on the system (in this case, the local system) that is providing DNS lookup services. +**nslookup** 还提供系统中(本例中是本地系统)提供 DNS 查询服务的信息。 ``` $ nslookup world.std.com @@ -141,9 +139,9 @@ Name: world.std.com Address: 192.74.137.5 ``` -### dig command +### dig 命令 -The **dig** command provides quitea lot of information on connecting to a remote system -- including the name server we are communicating with and how long the query takes to respond and is often used for troubleshooting. +**dig** 命令提供了很多有关连接到远程系统的信息 - 包括与我们通信的名称服务器以及查询需要多长时间进行响应,并经常用于故障排除。 ``` $ dig world.std.com @@ -168,9 +166,9 @@ world.std.com. 78146 IN A 192.74.137.5 ;; MSG SIZE rcvd: 58 ``` -### nmap command +### nmap 命令 -The **nmap** command is most frequently used to probe remote systems, but can also be used to report on the services being offered by the local system. In the output below, we can see that ssh is available for logins, that smtp is servicing email, that a web site is active, and that an ipp print service is running. +**nmap** 经常用于探查远程系统,但是同样也用于报告本地系统提供的服务。在下面的输出中,我们可以看到登录可以使用 ssh、smtp 用于电子邮箱、web 站点也是启用的,并且 ipp 打印服务正在运行。 ``` $ nmap localhost @@ -188,14 +186,14 @@ PORT STATE SERVICE Nmap done: 1 IP address (1 host up) scanned in 0.09 seconds ``` -Linux systems provide a lot of useful commands for reviewing their network configuration and connections. If you run out of commands to explore, keep in mind that **apropos network** might point you toward even more. +Linux 系统提供了很多有用的命令用于查看网络配置和连接。如果你都探索完了,请记住 **apropos network** 或许会让你了解更多。 -------------------------------------------------------------------------------- via: https://www.networkworld.com/article/3230519/linux/examining-network-connections-on-linux-systems.html 作者:[Sandra Henry-Stocker][a] -译者:[译者ID](https://github.com/译者ID) +译者:[geekpi](https://github.com/geekpi) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 307f383e2328dc15288fd1071d4bbbfc8f8800ea Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 30 Nov 2017 08:48:45 +0800 Subject: [PATCH 051/344] translatig --- .../20171029 A block layer introduction part 1 the bio layer.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171029 A block layer introduction part 1 the bio layer.md b/sources/tech/20171029 A block layer introduction part 1 the bio layer.md index b01269ff63..065a3720b4 100644 --- a/sources/tech/20171029 A block layer introduction part 1 the bio layer.md +++ b/sources/tech/20171029 A block layer introduction part 1 the bio layer.md @@ -1,3 +1,5 @@ +translating---geekpi + A block layer introduction part 1: the bio layer ============================================================ From 23a67548f11caf6bd087a15cead354b5586355f8 Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Thu, 30 Nov 2017 10:27:36 +0800 Subject: [PATCH 052/344] Translated by qhwdw Translated by qhwdw --- ...71124 An introduction to the Django ORM.md | 196 ++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 translated/tech/20171124 An introduction to the Django ORM.md diff --git a/translated/tech/20171124 An introduction to the Django ORM.md b/translated/tech/20171124 An introduction to the Django ORM.md new file mode 100644 index 0000000000..789640441b --- /dev/null +++ b/translated/tech/20171124 An introduction to the Django ORM.md @@ -0,0 +1,196 @@ +Django ORM 简介 +============================================================ + +### 学习怎么去使用 Python 的 web 框架中的对象关系映射与你的数据库交互,就像你使用 SQL 一样。 + + +![Getting to know the Django ORM](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web-spider-frame-framework.png?itok=Rl2AG2Dc "Getting to know the Django ORM") +Image by : [Christian Holmér][10]. Modified by Opensource.com. [CC BY-SA 4.0][11] + +你可能听说过 [Django][12],它是一个被称为“完美主义者的最后期限” 的 Python web 框架。它是一匹 [可爱的小矮马][13]。 + +Django 的其中一个强大的功能是它的对象关系映射(ORM),它允许你去和你的数据库交互,就像你使用 SQL 一样。事实上,Django 的 ORM 就是创建 SQL 去查询和维护数据库的一个 Python 的方法,并且在一个 Python 方法中获取结果。 我说 _就是_ 一种方法,但实际上,它是一项非常聪明的工程,它利用了 Python 中比较复杂的部分,使得开发过程更容易。 + +在我们开始去了解 ORM 是怎么工作的之前,我们需要一个去操作的数据库。和任何一个关系型数据库一样,我们需要去定义一堆表和它们的关系(即,它们相互之间联系起来的方式)。让我们使用我们熟悉的东西。比如说,我们需要去建立一个有博客文章和作者的博客。每个作者有一个名字。一位作者可以有很多的博客文章。一篇博客文章可以有很多的作者、标题、内容和发布日期。 + +在 Django-ville 中,这个文章和作者的概念可以被称为博客应用。在这个语境中,一个应用是一个自包含一系列描述我们的博客行为和功能的模型和视图。用正确的方式打包,以便于其它的 Django 项目可以使用我们的博客应用。在我们的项目中,博客正是其中的一个应用。比如,我们也可以有一个论坛应用。但是,我们仍然坚持我们的博客应用的原有范围。 + +这是为这个教程事先准备的 `models.py`: + +``` +from django.db import models + +class Author(models.Model): +    name = models.CharField(max_length=100) + +    def __str__(self): +        return self.name + +class Post(models.Model): +    title = models.CharField(max_length=100) +    content = models.TextField() +    published_date = models.DateTimeField(blank=True, null=True) +    author = models.ManyToManyField(Author, related_name="posts") + +    def __str__(self): +        return self.title +``` + +更多的 Python 资源 + +* [Python 是什么?][1] + +* [最好的 Python IDEs][2] + +* [最好的 Python GUI 框架][3] + +* [最新的 Python 内容][4] + +* [更多的开发者资源][5] + +现在,看上去似乎有点令人恐惧,因此,我们把它分解来看。我们有两个模型:作者和文章。它们都有名字或者标题。文章为内容设置一个大文本框,以及为发布的时间和日期设置一个 `DateTimeField`。文章也有一个 `ManyToManyField`,它同时链接到文章和作者。 + +大多数的教程都是从 scratch—but 开始的,但是,在实践中并不会发生这种情况。实际上,它会提供给你一堆已存在的代码,就像上面的 `model.py` 一样,而你必须去搞清楚它们是做什么的。 + +因此,现在你的任务是去进入到应用程序中去了解它。做到这一点有几种方法,你可以登入到 [Django admin][14],一个 Web 后端,它有全部列出的应用和操作它们的方法。我们先退出它,现在我们感兴趣的东西是 ORM。 + +我们可以在 Django 项目的主目录中运行 `python manage.py shell` 去访问 ORM。 + +``` +/srv/web/django/ $ python manage.py shell + +Python 3.6.3 (default, Nov  9 2017, 15:58:30) +[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.38)] on darwin +Type "help", "copyright", "credits" or "license" for more information. +(InteractiveConsole) +>>> +``` + +这将带我们进入到交互式控制台。[`shell` 命令][15] 为我们做了很多设置,包括导入我们的设置和配置 Django 环境。虽然我们启动了 shell,但是,在我们导入它之前,我们并不能访问我们的博客模型。 + +``` +>>> from blog.models import * +``` + +它导入了全部的博客模型,因此,我们可以玩我们的博客了。 + +首先,我们列出所有的作者。 + +``` +>>> Author.objects.all() +``` + +我们将从这个命令取得结果,它是一个 `QuerySet`,它列出了所有我们的作者对象。它不会充满我们的整个控制台,因为,如果有很多查询结果,Django 将自动截断输出结果。 + +``` +>>> Author.objects.all() +, + , '...(remaining elements truncated)...'] +``` + +我们可以使用 `get` 代替 `all` 去检索单个作者。但是,我们需要一些更多的信息去 `get` 一个单个记录。在关系型数据库中,表有一个主键,它唯一标识了表中的每个记录,但是,作者名并不唯一。许多人都 [重名][16],因此,它不是唯一约束的一个好的选择。解决这个问题的一个方法是使用一个序列(1、2、3...)或者一个通用唯一标识符(UUID)作为主键。但是,因为它对人类并不可用,我们可以通过使用 `name` 来操作我们的作者对象。 + +``` +>>> Author.objects.get(name="VM (Vicky) Brasseur") + +``` + +到现在为止,我们已经有了一个我们可以交互的对象,而不是一个 `QuerySet` 列表。我们现在可以与这个 Python 对象进行交互了,使用任意一个表列做为属性去查看对象。 + +``` +>>> vmb = Author.objects.get(name="VM (Vicky) Brasseur") +>>> vmb.name +u'VM (Vicky) Brasseur' +``` + +然后,很酷的事件发生了。通常在关系型数据库中,如果我们希望去展示其它表的信息,我们需要去写一个 `LEFT JOIN`,或者其它的表耦合函数,并确保它们之间有匹配的外键。而 Django 可以为我们做到这些。 + +在我们的模型中,由于作者写了很多的文章,因此,我们的作者对象可以检查它自己的文章。 + +``` +>>> vmb.posts.all() +QuerySet[, + , + , + '...(remaining elements truncated)...'] +``` + +We can manipulate `QuerySets` using normal pythonic list manipulations. + +``` +>>> for post in vmb.posts.all(): +...   print(post.title) +... +7 tips for nailing your job interview +5 tips for getting the biggest bang for your cover letter buck +Quit making these 10 common resume mistakes +``` + +去实现更复杂的查询,我们可以使用过滤得到我们想要的内容。这是非常微妙的。在 SQL 中,你可以有一些选项,比如,`like`、`contains`、和其它的过滤对象。在 ORM 中这些事情也可以做到。但是,是通过 _特别的_ 方式实现的:是通过使用一个隐式(而不是显式)定义的函数实现的。 + +如果在我的 Python 脚本中调用了一个函数 `do_thing()`,我期望在某个地方有一个匹配 `def do_thing`。这是一个显式的函数定义。然而,在 ORM 中,你可以调用一个 _不显式定义的_ 函数。之前,我们使用 `name` 去匹配一个名字。但是,如果我们想做一个子串搜索,我们可以使用 `name__contains`。 + +``` +>>> Author.objects.filter(name__contains="Vic") +QuerySet[] +``` + +现在,关于双下划线(`__`)我有一个小小的提示。这些是 Python _特有的_。在 Python 的世界里,你可以看到如 `__main__` 或者 `__repr__`。这些有时被称为 `dunder methods`,是 “双下划线” 的缩写。这里仅有几个非字母数字字符可以被用于 Python 中的对象名字;下划线是其中的一个。这些在 ORM 中被用于不同的过滤关键字的显式分隔。在底层,字符串被这些下划线分割。并且这个标记是分开处理的。`name__contains` 被替换成 `attribute: name, filter: contains`。在其它编程语言中,你可以使用箭头代替,比如,在 PHP 中是 `name->contains`。不要被双下划线吓着你,正好相反,它们是 Python 的好帮手(并且如果你斜着看,你就会发现它看起来像一条小蛇,想去帮你写代码的小蟒蛇)。 + +ORM 是非常强大并且是 Python 特有的。不过,在 Django 的管理网站上我提到过上面的内容。 + +### [django-admin.png][6] + +![Django Admin](https://opensource.com/sites/default/files/u128651/django-admin.png "Django Admin") + +Django 的其中一个非常精彩的用户可访问特性是它的管理界面,如果你定义你的模型,你将看到一个非常好用的基于 web 的编辑门户,而且它是免费的。 + +ORM,有多强大? + +### [django-admin-author.png][7] + +![Authors list in Django Admin](https://opensource.com/sites/default/files/u128651/django-admin-author.png "Authors list in Django Admin") + +好吧!给你一些代码去创建最初的模型,Django 转到基于 web 的门户,它是非常强大的,它可以使用我们前面用过的同样的原生函数。默认情况下,这个管理门户只有基本的东西,但这只是在你的模型中添加一些定义去改变外观的问题。例如,在早期的这些 `__str__` 方法中,我们使用这些去定义作者对象应该有什么?(在这种情况中,比如,作者的名字),做了一些工作后,你可以创建一个界面,让它看起来像一个内容管理系统,以允许你的用户去编辑他们的内容。(例如,为一个标记为 “已发布” 的文章,增加一些输入框和过滤)。 + +如果你想去了解更多内容,[Django 美女的教程][17] 中关于 [the ORM][18] 的节有详细的介绍。在 [Django project website][19] 上也有丰富的文档。 + +-------------------------------------------------------------------------------- + +作者简介: + +Katie McLaughlin - Katie 在过去的这几年有许多不同的头衔,她以前是使用多种语言的一位软件开发人员,多种操作系统的系统管理员,和多个不同话题的演讲者。当她不改变 “世界” 的时候,她也去享受烹饪、挂毯艺术,和去研究各种应用程序栈怎么去处理 emoji。 + +------------------------ + +via: https://opensource.com/article/17/11/django-orm + +作者:[Katie McLaughlin Feed ][a] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/glasnt +[1]:https://opensource.com/resources/python?intcmp=7016000000127cYAAQ +[2]:https://opensource.com/resources/python/ides?intcmp=7016000000127cYAAQ +[3]:https://opensource.com/resources/python/gui-frameworks?intcmp=7016000000127cYAAQ +[4]:https://opensource.com/tags/python?intcmp=7016000000127cYAAQ +[5]:https://developers.redhat.com/?intcmp=7016000000127cYAAQ +[6]:https://opensource.com/file/377811 +[7]:https://opensource.com/file/377816 +[8]:https://opensource.com/article/17/11/django-orm?rate=iwO0q67yiUUPweMIMoyLbbYyhK5RTOOzEtyiNkJ0eBE +[9]:https://opensource.com/user/41661/feed +[10]:https://www.flickr.com/people/crsan/ +[11]:https://creativecommons.org/licenses/by-sa/4.0/ +[12]:https://www.djangoproject.com/ +[13]:http://www.djangopony.com/ +[14]:https://docs.djangoproject.com/en/1.11/ref/contrib/admin/ +[15]:https://docs.djangoproject.com/en/1.11/ref/django-admin/#shell +[16]:https://2016.katieconf.xyz/ +[17]:https://djangogirls.org/ +[18]:https://tutorial.djangogirls.org/en/django_orm/ +[19]:https://docs.djangoproject.com/en/1.11/topics/db/ +[20]:https://opensource.com/users/glasnt +[21]:https://opensource.com/users/glasnt +[22]:https://opensource.com/article/17/11/django-orm#comments From eeee8dda6c8e4a51b8103d013e279e0b1f3a45fb Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Thu, 30 Nov 2017 10:28:34 +0800 Subject: [PATCH 053/344] Translated by qhwdw Translated by qhwdw --- ...71124 An introduction to the Django ORM.md | 197 ------------------ 1 file changed, 197 deletions(-) delete mode 100644 sources/tech/20171124 An introduction to the Django ORM.md diff --git a/sources/tech/20171124 An introduction to the Django ORM.md b/sources/tech/20171124 An introduction to the Django ORM.md deleted file mode 100644 index 4a183ce6c1..0000000000 --- a/sources/tech/20171124 An introduction to the Django ORM.md +++ /dev/null @@ -1,197 +0,0 @@ -Translating by qhwdw -An introduction to the Django ORM -============================================================ - -### Learn how to use the Python web framework's object-relational mapper to interact with your database, just like you would with SQL. - - -![Getting to know the Django ORM](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web-spider-frame-framework.png?itok=Rl2AG2Dc "Getting to know the Django ORM") -Image by : [Christian Holmér][10]. Modified by Opensource.com. [CC BY-SA 4.0][11] - -You might have heard of [Django][12], the Python web framework for "perfectionists with deadlines." It's that one with the [cute pony][13]. - -One of the most powerful features of Django is its Object-Relational Mapper (ORM), which enables you to interact with your database, like you would with SQL. In fact, Django's ORM is just a pythonical way to create SQL to query and manipulate your database and get results in a pythonic fashion. Well, I say  _just_  a way, but it's actually really clever engineering that takes advantage of some of the more complex parts of Python to make developers' lives easier. - -Before we start looking into how the ORM works, we need a database to manipulate. As with any relational database, we need to define a bunch of tables and their relationships (i.e., the way they relate to each other). Let's use something familiar. For example, say we want to model a blog that has blog posts and authors. An author has a name. An author can have many blog posts. A blog post can have many authors and has a title, content, and a published date. - -In Django-ville, this concept of posts and authors could be called our Blog app. In this context, an app is a self-contained set of models and views that describes the behavior and functionality of our blog. Packaged in the right way, many Django projects could use our Blog app. In our project, the Blog could just be one app. We might also have a Forum app, for example. But we'll stick with the original scope of our Blog app. - -Here's a `models.py` prepared for this tutorial: - -``` -from django.db import models - -class Author(models.Model): -    name = models.CharField(max_length=100) - -    def __str__(self): -        return self.name - -class Post(models.Model): -    title = models.CharField(max_length=100) -    content = models.TextField() -    published_date = models.DateTimeField(blank=True, null=True) -    author = models.ManyToManyField(Author, related_name="posts") - -    def __str__(self): -        return self.title -``` - -More Python Resources - -* [What is Python?][1] - -* [Top Python IDEs][2] - -* [Top Python GUI frameworks][3] - -* [Latest Python content][4] - -* [More developer resources][5] - -Now this might look a bit daunting, so let's break it down. We have two models: Author and Post. Each has a name or title. The post has a big text field for content and a `DateTimeField` for the publication date and time. Post also has a `ManyToManyField`, which links posts and authors together. - -Most tutorials start from scratch—but that's not what's going to happen in practice. In reality, you're going to be given a bunch of existing code like the `model.py` above, and you have to work out what it all means. - -So it's now your task to go into the application and take a look around. There are a few ways to do this. You could log in to [Django admin][14], a web-based backend that has all the apps listed and the ways to manipulate them. We'll get back to that; here we're interested in the ORM. - -We can access the ORM by running `python manage.py shell` from the main directory of our Django project. - -``` -/srv/web/django/ $ python manage.py shell - -Python 3.6.3 (default, Nov  9 2017, 15:58:30) -[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.38)] on darwin -Type "help", "copyright", "credits" or "license" for more information. -(InteractiveConsole) ->>> -``` - -This will bring us into an interactive console. The [`shell` command][15] did a lot of setup for us, including importing our settings and configuring the Django environment. While we've launched the shell, we can't access our Blog model until we import it. - -``` ->>> from blog.models import * -``` - -This imports all the blog models so we can play with our blog posts and authors. - -For starters, let's get a list of all the authors. - -``` ->>> Author.objects.all() -``` - -What we'll get from this command is a `QuerySet` of results, which lists all our Author objects. We also won't fill our entire console, because if there are a lot of results, Django will automatically truncate the printed results. - -``` ->>> Author.objects.all() -, - , '...(remaining elements truncated)...'] -``` - -We can select a single author using `get` instead of `all`. But we need a bit more information to `get` a single record. In relational databases, tables have a primary key field that has a unique identifier for each and every record in a table; however, author names are not unique. Many people [share the same name][16], so it's not a good unique constraint. A way to get around this is to have a sequence (1, 2, 3...) or a universal unique identifier (UUID) as the primary key. But since these aren't nicely useable by humans, we can manipulate our Author objects by using `name`. - -``` ->>> Author.objects.get(name="VM (Vicky) Brasseur") - -``` - -This time, we have a single object that we can interact with, instead of a `QuerySet` list. We can interact with this object pythonically, using any of the table columns as attributes to look at the object. - -``` ->>> vmb = Author.objects.get(name="VM (Vicky) Brasseur") ->>> vmb.name -u'VM (Vicky) Brasseur' -``` - -And this is where the cool stuff happens. Normally in relational databases, if we want to show information for other tables, we'd need to write a `LEFT JOIN`, or other table-coupling functions, making sure that our foreign keys match up between tables. Django takes care of that for us. - -In our model, authors write many posts, so our Author object can check what posts the author has made. - -``` ->>> vmb.posts.all() -QuerySet[, - , - , - '...(remaining elements truncated)...'] -``` - -We can manipulate `QuerySets` using normal pythonic list manipulations. - -``` ->>> for post in vmb.posts.all(): -...   print(post.title) -... -7 tips for nailing your job interview -5 tips for getting the biggest bang for your cover letter buck -Quit making these 10 common resume mistakes -``` - -To do more complex querying, we can use filters instead of getting everything. Here is where it gets tricky. In SQL, you have options such as `like`, `contains`, and other filtering objects. You can do all these things in the ORM, too, but it has a special way of doing them: by using implicitly (rather than explicitly) defined functions. - -If I call a function `do_thing()` in my Python script, I'd expect somewhere there would be a matching `def do_thing`. This is an explicit functional definition. However, in the ORM, you can call a function that  _isn't explicitly defined_ . Before, we were using `name` to match on a name. But, if we wanted to do a substring search, we can use `name__contains`. - -``` ->>> Author.objects.filter(name__contains="Vic") -QuerySet[] -``` - -Now, a small note about the double underscore (`__`). These are  _very_  Python. You may have seen `__main__` or `__repr__` in your travels in Pythonland. These are sometimes referred to as `dunder methods`, a shortening of "double underscore." There are only a few non-alphanumeric characters that can be used in object names in Python; underscore is one of them. These are used in the ORM as an explicit separator of different parts of the filter key name. Under the hood, the string is split by these underscores, and the tokens are processed separately. `name__contains` gets changed into `attribute: name, filter: contains`. In other programming languages, you may use arrows instead, such as `name->contains` in PHP. Don't let dunders scare you, they're just pythonic helpers! (And if you squint, you could say they look like little snakes, little pythons that want to help you with your code.) - -The ORM is extremely powerful and very pythonic. But what about that Django admin site I mentioned above? - -### [django-admin.png][6] - -![Django Admin](https://opensource.com/sites/default/files/u128651/django-admin.png "Django Admin") - -One of the brilliant user-accessibility features of Django is its admin interface. If you define your models, you get a nice web-based editing portal, for free. - -And what powers this? The ORM. - -### [django-admin-author.png][7] - -![Authors list in Django Admin](https://opensource.com/sites/default/files/u128651/django-admin-author.png "Authors list in Django Admin") - -That's right! Given the code used to create the original models, Django turned that into a web-based portal, which is powered using the same raw functions we used earlier. By default, the admin is basic, but it's just a matter of adding more definitions in your model to change how the admin looks. For example, those `__str__` methods from earlier? We use those to define what an Author object looks like (in this case, just the name of the author). With a bit of work, you can make an interface that feels like a full content management system that allows your users to edit their own content with ease (for example, adding fields and filters for marking a post "published"). - -If you'd like to know more, the [Django Girls tutorial][17] section about [the ORM][18] has a detailed walkthrough. There's also copious documentation on the [Django project website][19]. - --------------------------------------------------------------------------------- - -作者简介: - -Katie McLaughlin - Katie has worn many different hats over the years. She has previously been a software developer for many languages, systems administrator for multiple operating systems, and speaker on many different topics. When she's not changing the world, she enjoys making cooking, tapestries, and seeing just how well various application stacks handle emoji. - ------------------------- - -via: https://opensource.com/article/17/11/django-orm - -作者:[Katie McLaughlin Feed ][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/glasnt -[1]:https://opensource.com/resources/python?intcmp=7016000000127cYAAQ -[2]:https://opensource.com/resources/python/ides?intcmp=7016000000127cYAAQ -[3]:https://opensource.com/resources/python/gui-frameworks?intcmp=7016000000127cYAAQ -[4]:https://opensource.com/tags/python?intcmp=7016000000127cYAAQ -[5]:https://developers.redhat.com/?intcmp=7016000000127cYAAQ -[6]:https://opensource.com/file/377811 -[7]:https://opensource.com/file/377816 -[8]:https://opensource.com/article/17/11/django-orm?rate=iwO0q67yiUUPweMIMoyLbbYyhK5RTOOzEtyiNkJ0eBE -[9]:https://opensource.com/user/41661/feed -[10]:https://www.flickr.com/people/crsan/ -[11]:https://creativecommons.org/licenses/by-sa/4.0/ -[12]:https://www.djangoproject.com/ -[13]:http://www.djangopony.com/ -[14]:https://docs.djangoproject.com/en/1.11/ref/contrib/admin/ -[15]:https://docs.djangoproject.com/en/1.11/ref/django-admin/#shell -[16]:https://2016.katieconf.xyz/ -[17]:https://djangogirls.org/ -[18]:https://tutorial.djangogirls.org/en/django_orm/ -[19]:https://docs.djangoproject.com/en/1.11/topics/db/ -[20]:https://opensource.com/users/glasnt -[21]:https://opensource.com/users/glasnt -[22]:https://opensource.com/article/17/11/django-orm#comments From ce91ad9cffab81cd11d7a24aaaed84fe7c8e741e Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Thu, 30 Nov 2017 10:33:42 +0800 Subject: [PATCH 054/344] Translating by qhwdw Translating by qhwdw --- ...se SVG as a Placeholder and Other Image Loading Techniques.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md b/sources/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md index 964eca9356..20731a03e4 100644 --- a/sources/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md +++ b/sources/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md @@ -1,3 +1,4 @@ +Translating by qhwdw How to use SVG as a Placeholder, and Other Image Loading Techniques ============================================================ From 58bb05599a0228d803a64f496a1c0bc2d54a1a29 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 30 Nov 2017 12:23:03 +0800 Subject: [PATCH 055/344] =?UTF-8?q?PRF:20171128=20tmate=20=E2=80=93=20Inst?= =?UTF-8?q?antly=20Share=20Your=20Terminal=20Session=20To=20Anyone=20In=20?= =?UTF-8?q?Seconds.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @lujun9972 --- ...our Terminal Session To Anyone In Seconds.md | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/translated/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md b/translated/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md index 16b239f0c8..c44add76f4 100644 --- a/translated/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md +++ b/translated/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md @@ -1,4 +1,4 @@ -tmate -- 秒级分享你的终端会话 +tmate:秒级分享你的终端会话 ================= 不久前,我们写过一篇关于 [teleconsole](https://www.2daygeek.com/teleconsole-share-terminal-session-instantly-to-anyone-in-seconds/) 的介绍,该工具可用于快速分享终端给任何人(任何你信任的人)。今天我们要聊一聊另一款类似的应用,名叫 `tmate`。 @@ -7,17 +7,16 @@ tmate -- 秒级分享你的终端会话 ### 什么是 tmate? -[tmate](https://tmate.io/) 的意思是 `teammates`,它是 tmux 的一个分支,并且使用相同的配置信息(例如快捷键配置,配色方案等)。 -它是一个终端多路复用器,同时具有即时分享终端的能力。它允许在单个屏幕中创建并操控多个终端,同时这些终端还能与其他同事分享。 +[tmate](https://tmate.io/) 的意思是 `teammates`,它是 tmux 的一个分支,并且使用相同的配置信息(例如快捷键配置,配色方案等)。它是一个终端多路复用器,同时具有即时分享终端的能力。它允许在单个屏幕中创建并操控多个终端,同时这些终端还能与其他同事分享。 -你可以分离会话,让作业在后台运行,然后在想要查看状态时重新连接会话. `tmate` 提供了一个即时配对的方案,让你可以与一个或多个队友共享一个终端。 +你可以分离会话,让作业在后台运行,然后在想要查看状态时重新连接会话。`tmate` 提供了一个即时配对的方案,让你可以与一个或多个队友共享一个终端。 在屏幕的地步有一个状态栏,显示了当前会话的一些诸如 ssh 命令之类的共享信息。 ### tmate 是怎么工作的? -- 运行 `tmate` 时,会通过 `libssh` 在后台创建一个连接到 tmate.io (由 tmate 开发者维护的后台服务器)的ssh 连接。 -- 服务器 (tmate.io) 的 ssh 密钥前面通过 DH 交换进行校验。 +- 运行 `tmate` 时,会通过 `libssh` 在后台创建一个连接到 tmate.io (由 tmate 开发者维护的后台服务器)的 ssh 连接。 +- tmate.io 服务器的 ssh 密钥通过 DH 交换进行校验。 - 客户端通过本地 ssh 密钥进行认证。 - 连接创建后,本地 tmux 服务器会生成一个 150 位(不可猜测的随机字符)会话令牌。 - 队友能通过用户提供的 SSH 会话 ID 连接到 tmate.io。 @@ -26,24 +25,25 @@ tmate -- 秒级分享你的终端会话 由于 `tmate.io` 服务器需要通过本地 ssh 密钥来认证客户机,因此其中一个必备条件就是生成 SSH 密钥 key。 记住,每个系统都要有自己的 SSH 密钥。 + ```shell $ ssh-keygen -t rsa -Generating public/private rsa key pair。 +Generating public/private rsa key pair. Enter file in which to save the key (/home/magi/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: -Your identification has been saved in /home/magi/.ssh/id_rsa。 -Your public key has been saved in /home/magi/.ssh/id_rsa.pub。 +Your identification has been saved in /home/magi/.ssh/id_rsa. +Your public key has been saved in /home/magi/.ssh/id_rsa.pub. The key fingerprint is: -SHA256:3ima5FuwKbWyyyNrlR/DeBucoyRfdOtlUmb5D214NC8 [email protected] +SHA256:3ima5FuwKbWyyyNrlR/DeBucoyRfdOtlUmb5D214NC8 magi@magi-VirtualBox The key's randomart image is: +---[RSA 2048]----+ | | | | | . | | . . = o | -| *ooS= 。 o | -| . [email protected]*o.o.+ E .| +| *ooS= . + o | +| . =.@*o.o.+ E .| | =o==B++o = . | | o.+*o+.. . | | ..o+o=. | @@ -54,8 +54,7 @@ The key's randomart image is: `tmate` 已经包含在某些发行版的官方仓库中,可以通过包管理器来安装。 -对于 **`Debian/Ubuntu`**,可以使用 [APT-GET 命令](https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/) -或者 [APT 命令](https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/)to 来安装。 +对于 Debian/Ubuntu,可以使用 [APT-GET 命令](https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/)或者 [APT 命令](https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/)to 来安装。 ```shell $ sudo apt-get install software-properties-common @@ -70,14 +69,13 @@ $ sudo apt-get install tmate $ sudo apt-get install tmate ``` -对于 **`Fedora`**,使用 [DNF 命令](https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/) 来安装。 +对于 Fedora,使用 [DNF 命令](https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/) 来安装。 ```shell $ sudo dnf install tmate ``` -对于基于 **`Arch Linux`** 的系统,使用 []()[Yaourt 命令](https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/) -或 []()[Packer 命令](https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/) 来从 AUR 仓库中安装。 +对于基于 Arch Linux 的系统,使用 []()[Yaourt 命令](https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/)或 []()[Packer 命令](https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/) 来从 AUR 仓库中安装。 ```shell $ yaourt -S tmate @@ -88,7 +86,7 @@ $ yaourt -S tmate $ packer -S tmate ``` -对于 **`openSUSE`**,使用 [Zypper 命令](https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/) 来安装。 +对于 openSUSE,使用 [Zypper 命令](https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/) 来安装。 ```shell $ sudo zypper in tmate @@ -102,7 +100,7 @@ $ sudo zypper in tmate $ tmate ``` -![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-1.png) +![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-1.png) 要注意的是,SSH 会话 ID 会在几秒后消失,不过不要紧,你可以通过下面命令获取到这些详细信息。 @@ -110,26 +108,29 @@ $ tmate $ tmate show-messages ``` -`tmate` 的 `show-messages` 命令会显示 tmate 的 log 信息,其中包含了 ssh 连接内容。 -![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-2.png) +`tmate` 的 `show-messages` 命令会显示 tmate 的日志信息,其中包含了该 ssh 连接内容。 + +![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-2.png) + +现在,分享你的 SSH 会话 ID 给你的朋友或同事从而允许他们观看终端会话。除了 SSH 会话 ID 以外,你也可以分享 web URL。 -现在,分享你的 SSH 会话 ID 给你的朋友或同事从而允许他们观看终端会话. 除了 SSH 会话 ID 以外,你也可以分享 web URL。 另外你还可以选择分享的是只读会话还是可读写会话。 ### 如何通过 SSH 连接会话 -只需要在终端上运行你从朋友那得到的 SSH 终端 ID 就行了. 类似下面这样。 +只需要在终端上运行你从朋友那得到的 SSH 终端 ID 就行了。类似下面这样。 ```shell $ ssh session: ssh 3KuRj95sEZRHkpPtc2y6jcokP@sg2.tmate.io ``` -![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-4.png) +![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-4.png) ### 如何通过 Web URL 连接会话 -打开浏览器然后访问朋友给你的 URL 就行了. 像下面这样。 -![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-3.png) +打开浏览器然后访问朋友给你的 URL 就行了。像下面这样。 + +![](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-3.png) 只需要输入 `exit` 就能退出会话了。 @@ -148,9 +149,9 @@ Connection to sg2.tmate.io closed。 via: https://www.2daygeek.com/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds/ -作者:[ Magesh Maruthamuthu ][a] +作者:[Magesh Maruthamuthu][a] 译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 914f1be572cc9bbef6093c73c9edc984a6a2099c Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 30 Nov 2017 12:23:17 +0800 Subject: [PATCH 056/344] =?UTF-8?q?PUB:20171128=20tmate=20=E2=80=93=20Inst?= =?UTF-8?q?antly=20Share=20Your=20Terminal=20Session=20To=20Anyone=20In=20?= =?UTF-8?q?Seconds.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @lujun9972 明天发布 --- ... Instantly Share Your Terminal Session To Anyone In Seconds.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md (100%) diff --git a/translated/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md b/published/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md similarity index 100% rename from translated/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md rename to published/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md From de57490d6e709d17f2786d60a9f967158857e663 Mon Sep 17 00:00:00 2001 From: zpl1025 Date: Thu, 30 Nov 2017 12:56:13 +0800 Subject: [PATCH 057/344] [translated] 20170215 How to take screenshots on Linux using Scrot --- ...o take screenshots on Linux using Scrot.md | 331 ------------------ ...o take screenshots on Linux using Scrot.md | 330 +++++++++++++++++ 2 files changed, 330 insertions(+), 331 deletions(-) delete mode 100644 sources/tech/20170215 How to take screenshots on Linux using Scrot.md create mode 100644 translated/tech/20170215 How to take screenshots on Linux using Scrot.md diff --git a/sources/tech/20170215 How to take screenshots on Linux using Scrot.md b/sources/tech/20170215 How to take screenshots on Linux using Scrot.md deleted file mode 100644 index 11d9ac5a95..0000000000 --- a/sources/tech/20170215 How to take screenshots on Linux using Scrot.md +++ /dev/null @@ -1,331 +0,0 @@ -zpl1025 -How to take screenshots on Linux using Scrot -============================================================ - -### On this page - -1. [About Scrot][12] -2. [Scrot Installation][13] -3. [Scrot Usage/Features][14] - 1. [Get the application version][1] - 2. [Capturing current window][2] - 3. [Selecting a window][3] - 4. [Include window border in screenshots][4] - 5. [Delay in taking screenshots][5] - 6. [Countdown before screenshot][6] - 7. [Image quality][7] - 8. [Generating thumbnails][8] - 9. [Join multiple displays shots][9] - 10. [Executing operations on saved images][10] - 11. [Special strings][11] -4. [Conclusion][15] - -Recently, we discussed about the [gnome-screenshot][17] utility, which is a good screen grabbing tool. But if you are looking for an even better command line utility for taking screenshots, then you must give Scrot a try. This tool has some extra features that are currently not available in gnome-screenshot. In this tutorial, we will explain Scrot using easy to understand examples. - -Please note that all the examples mentioned in this tutorial have been tested on Ubuntu 16.04 LTS, and the scrot version we have used is 0.8. - -### About Scrot - -[Scrot][18] (**SCR**eensh**OT**) is a screenshot capturing utility that uses the imlib2 library to acquire and save images. Developed by Tom Gilbert, it's written in C programming language and is licensed under the BSD License. - -### Scrot Installation - -The scrot tool may be pre-installed on your Ubuntu system, but if that's not the case, then you can install it using the following command: - -sudo apt-get install scrot - -Once the tool is installed, you can launch it by using the following command: - -scrot [options] [filename] - -**Note**: The parameters in [] are optional. - -### Scrot Usage/Features - -In this section, we will discuss how the Scrot tool can be used and what all features it provides. - -When the tool is run without any command line options, it captures the whole screen. - -[ - ![Using Scrot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/scrot.png) -][19] - -By default, the captured file is saved with a date-stamped filename in the current directory, although you can also explicitly specify the name of the captured image when the command is run. For example: - -scrot [image-name].png - -### Get the application version - -If you want, you can check the version of scrot using the -v command line option. - -scrot -v - -Here is an example: - -[ - ![Get scrot version](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/version.png) -][20] - -### Capturing current window - -Using the utility, you can limit the screenshot to the currently focused window. This feature can be accessed using the -u command line option. - -scrot -u - -For example, here's my desktop when I executed the above command on the command line: - -[ - ![capture window in scrot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/desktop.png) -][21] - -And here's the screenshot captured by scrot:  - -[ - ![Screenshot captured by scrot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/active.png) -][22] - -### Selecting a window - -The utility allows you to capture any window by clicking on it using the mouse. This feature can be accessed using the -s option. - -scrot -s - -For example, as you can see in the screenshot below, I have a screen with two terminal windows overlapping each other. On the top window, I run the aforementioned command. - -[ - ![select window](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/select1.png) -][23] - -Now suppose, I want to capture the bottom terminal window. For that, I will just click on that window once the command is executed - the command execution won't complete until you click somewhere on the screen. - -Here's the screenshot captured after clicking on that terminal: - -[ - ![window screenshot captured](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/select2.png) -][24] - -**Note**: As you can see in the above snapshot, whatever area the bottom window is covering has been captured, even if that includes an overlapping portion of the top window. - -### Include window border in screenshots - -The -u command line option we discussed earlier doesn't include the window border in screenshots. However, you can include the border of the window if you want. This feature can be accessed using the -b option (in conjunction with the -u option of course). - -scrot -ub - -Here is an example screenshot: - -[ - ![include window border in screenshot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/border-new.png) -][25] - -**Note**: Including window border also adds some of the background area to the screenshot. - -### Delay in taking screenshots - -You can introduce a time delay while taking screenshots. For this, you have to assign a numeric value to the --delay or -d command line option. - -scrot --delay [NUM] - -scrot --delay 5 - -Here is an example: - -[ - ![delay taking screenshot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/delay.png) -][26] - -In this case, scrot will wait for 5 seconds and then take the screenshot. - -### Countdown before screenshot - -The tool also allows you to display countdown while using delay option. This feature can be accessed using the -c command line option. - -scrot –delay [NUM] -c - -scrot -d 5 -c - -Here is an example screenshot: - -[ - ![example delayed screenshot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/countdown.png) -][27] - -### Image quality - -Using the tool, you can adjust the quality of the screenshot image at the scale of 1-100\. High value means high size and low compression. Default value is 75, although effect differs depending on the file format chosen. - -This feature can be accessed using --quality or -q option, but you have to assign a numeric value to this option ranging from 1-100. - -scrot –quality [NUM] - -scrot –quality 10 - -Here is an example snapshot: - -[ - ![snapshot quality](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/img-quality.jpg) -][28] - -So you can see that the quality of the image degrades a lot as the -q option is assigned value closer to 1. - -### Generating thumbnails - -The scrot utility also allows you to generate thumbnail of the screenshot. This feature can be accessed using the --thumb option. This option requires a NUM value, which is basically the percentage of the original screenshot size. - -scrot --thumb NUM - -scrot --thumb 50 - -**Note**: The --thumb option makes sure that the screenshot is captured and saved in original size as well. - -For example, here is the original screenshot captured in my case: - -[ - ![Original screenshot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/orig.png) -][29] - -And following is the thumbnail saved: - -[ - ![thumbnail of the screenshot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/thmb.png) -][30] - -### Join multiple displays shots - -In case your machine has multiple displays attached to it, scrot allows you to grab and join screenshots of these displays. This feature can be accessed using the -m command line option.  - -scrot -m - -Here is an example snapshot: - -[ - ![Join screenshots](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/multiple.png) -][31] - -### Executing operations on saved images - -Using the tool, we can execute various operations on saved images - for example, open the screenshot in an image editor like gThumb. This feature can be accessed using the -e command line option. Here's an example: - -scrot abc.png -e ‘gthumb abc.png’ - -Here, gthumb is an image editor which will automatically launch after we run the command. - -Following is the snapshot of the command: - -[ - ![Execute commands on screenshots](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/exec1.png) -][32] - -And here is the output of the above command: - -[ - ![esample screenshot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/exec2.png) -][33] - -So you can see that the scrot command grabbed the screenshot and then launched the gThumb image editor with the captured image as argument. - -If you don’t specify a filename to your screenshot, then the snapshot will be saved with a date-stamped filename in your current directory - this, as we've already mentioned in the beginning, is the default behaviour of scrot. - -Here's an -e command line option example where scrot uses the default name for the screenshot:  - -scrot -e ‘gthumb $n’ - -[ - ![scrot running gthumb](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/exec3.png) -][34] - -It's worth mentioning that $n is a special string, which provides access to the screenshot name. For more details on special strings, head to the next section. - -### Special strings - -The -e (or the --exec ) and filename parameters can take format specifiers when used with scrot. There are two types of format specifiers. First type is characters preceded by ‘%’ that are used for date and time formats, while the second type is internal to scrot and are prefixed by ‘$’ - -Several specifiers which are recognised by the --exec and filename parameters are discussed below. - -**$f** – provides access to screenshot path (including filename). - -For example, - -scrot ashu.jpg -e ‘mv $f ~/Pictures/Scrot/ashish/’ - -Here is an example snapshot: - -[ - ![example](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/f.png) -][35] - -If you will not specify a filename, then scrot will by-default save the snapshot in a date stamped file format. This is the by-default date-stamped file format used in scrot : %yy-%mm-%dd-%hhmmss_$wx$h_scrot.png. - -**$n** – provides snapshot name. Here is an example snapshot: - -[ - ![scrot $n variable](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/n.png) -][36] - -**$s** – gives access to the size of screenshot. This feature, for example, can be accessed in the following way. - -scrot abc.jpg -e ‘echo $s’ - -Here is an example snapshot - -[ - ![scrot $s variable](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/s.png) -][37] - -Similarly, you can use the other special strings **$p**, **$w**, **$h**, **$t**, **$$** and **\n** that provide access to image pixel size, image width, image height, image format, $ symbol, and give access to new line respectively. You can, for example, use these strings in the way similar to the **$s** example we have discussed above. - -### Conclusion - -The utility is easy to install on Ubuntu systems, which is good for beginners. Scrot also provides some advanced features such as special strings that can be used in scripting by professionals. Needless to say, there is a slight learning curve associated in case you want to use them. - - ![](https://www.howtoforge.com/images/pdficon_small.png) - [vie][16] - --------------------------------------------------------------------------------- - -via: https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/ - -作者:[Himanshu Arora][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/ -[1]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#get-the-applicationnbspversion -[2]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#capturing-current-window -[3]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#selecting-a-window -[4]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#includenbspwindow-border-in-screenshots -[5]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#delay-in-taking-screenshots -[6]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#countdown-before-screenshot -[7]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#image-quality -[8]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#generating-thumbnails -[9]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#join-multiple-displays-shots -[10]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#executing-operations-on-saved-images -[11]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#special-strings -[12]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#about-scrot -[13]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#scrot-installation -[14]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#scrot-usagefeatures -[15]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#conclusion -[16]:https://www.howtoforge.com/subscription/ -[17]:https://www.howtoforge.com/tutorial/taking-screenshots-in-linux-using-gnome-screenshot/ -[18]:https://en.wikipedia.org/wiki/Scrot -[19]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/scrot.png -[20]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/version.png -[21]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/desktop.png -[22]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/active.png -[23]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/select1.png -[24]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/select2.png -[25]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/border-new.png -[26]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/delay.png -[27]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/countdown.png -[28]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/img-quality.jpg -[29]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/orig.png -[30]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/thmb.png -[31]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/multiple.png -[32]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/exec1.png -[33]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/exec2.png -[34]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/exec3.png -[35]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/f.png -[36]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/n.png -[37]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/s.png diff --git a/translated/tech/20170215 How to take screenshots on Linux using Scrot.md b/translated/tech/20170215 How to take screenshots on Linux using Scrot.md new file mode 100644 index 0000000000..1ddefb37eb --- /dev/null +++ b/translated/tech/20170215 How to take screenshots on Linux using Scrot.md @@ -0,0 +1,330 @@ +如何在 Linux 系统里用 Scrot 截屏 +============================================================ + +### 文章主要内容 + +1. [关于 Scrot][12] +2. [安装 Scrot][13] +3. [Scrot 的使用和特点][14] + 1. [获取程序版本][1] + 2. [抓取当前窗口][2] + 3. [抓取选定窗口][3] + 4. [在截屏时包含窗口边框][4] + 5. [延时截屏][5] + 6. [截屏前倒数][6] + 7. [图片质量][7] + 8. [生成缩略图][8] + 9. [拼接多显示器截屏][9] + 10. [在保存截图后执行操作][10] + 11. [特殊字符串][11] +4. [结论][15] + +最近,我们介绍过 [gnome-screenshot][17] 工具,这是一个很优秀的屏幕抓取工具。但如果你想找一个在命令行运行的更好用的截屏工具,你一定要试试 Scrot。这个工具有一些 gnome-screenshot 没有的独特功能。在这片文章里,我们会通过简单易懂的例子来详细介绍 Scrot。 + +请注意一下,这篇文章里的所有例子都在 Ubuntu 16.04 LTS 上测试过,我们用的 scrot 版本是 0.8。 + +### 关于 Scrot + +[Scrot][18] (**SCR**eensh**OT**) 是一个屏幕抓取工具,使用 imlib2 库来获取和保存图片。由 Tom Gilbert 用 C 语言开发完成,通过 BSD 协议授权。 + +### 安装 Scrot + +scort 工具可能在你的 Ubuntu 系统里预装了,不过如果没有的话,你可以用下面的命令安装: + +sudo apt-get install scrot + +安装完成后,你可以通过下面的命令来使用: + +scrot [options] [filename] + +**注意**:方括号里的参数是可选的。 + +### Scrot 的使用和特点 + +在这个小节里,我们会介绍如何使用 Scrot 工具,以及它的所有功能。 + +如果不带任何选项执行命令,它会抓取整个屏幕。 + +[ + ![使用 Scrot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/scrot.png) +][19] + +默认情况下,抓取的截图会用带时间戳的文件名保存到当前目录下,不过你也可以在运行命令时指定截图文件名。比如: + +scrot [image-name].png + +### 获取程序版本 + +你想的话,可以用 -v 选项来查看 scrot 的版本。 + +scrot -v + +这是例子: + +[ + ![获取 scrot 版本](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/version.png) +][20] + +### 抓取当前窗口 + +这个工具可以限制抓取当前的焦点窗口。这个功能可以通过 -u 选项打开。 + +scrot -u + +例如,这是我在命令行执行上边命令时的桌面: + +[ + ![用 scrot 截取窗口](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/desktop.png) +][21] + +这是另一张用 scrot 抓取的截图: + +[ + ![用 scrot 抓取的图片](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/active.png) +][22] + +### 抓取选定窗口 + +这个工具还可以让你抓取任意用鼠标点击的窗口。这个功能可以用 -s 选项打开。 + +scrot -s + +例如,在下面的截图里你可以看到,我有两个互相重叠的终端窗口。我在上层的窗口里执行上面的命令。 + +[ + ![选择窗口](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/select1.png) +][23] + +现在假如我想抓取下层的终端窗口。这样我只要在执行命令后点击窗口就可以了 - 在你用鼠标点击之前,命令的执行不会结束。 + +这是我点击了下层终端窗口后的截图: + +[ + ![窗口截图](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/select2.png) +][24] + +**注意**:你可以在上面的截图里看到,下层终端窗口的整个显示区域都被抓去下来了,甚至包括了上层窗口的部分叠加内容。 + +### 在截屏时包含窗口边框 + +我们之前介绍的 -u 选项在截屏时不会包含窗口边框。不过,需要的话你也可以在截屏时包含窗口边框。这个功能可以通过 -b 选项打开(当然要和 -u 选项一起)。 + +scrot -ub + +下面是示例截图: + +[ + ![截屏时包含窗口边框](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/border-new.png) +][25] + +**注意**:截屏时包含窗口边框同时也会增加一点额外的背景。 + +### 延时截屏 + +你可以在开始截屏时增加一点延时。需要在 --delay 或 -d 选项后设定一个时间值参数。 + +scrot --delay [NUM] + +scrot --delay 5 + +例如: + +[ + ![延时截屏](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/delay.png) +][26] + +在这例子里,scrot 会等待 5 秒再截屏。 + +### 截屏前倒数 + +这个工具也可以在你使用延时功能后显示一个倒计时。这个功能可以通过 -c 选项打开。 + +scrot –delay [NUM] -c + +scrot -d 5 -c + +下面是示例截图: + +[ + ![延时截屏示例](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/countdown.png) +][27] + +### 图片质量 + +你可以使用这个工具来调整截图的图片质量,范围是 1-100 之间。较大的值意味着更大的文件大小以及更低的压缩率。默认值是 75,不过最终效果根据选择的文件类型也会有一些差异。 + +这个功能可以通过 --quality 或 -q 选项打开,但是你必须提供一个 1-100 之间的数值作为参数。 + +scrot –quality [NUM] + +scrot –quality 10 + +下面是示例截图: + +[ + ![截屏质量](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/img-quality.jpg) +][28] + +你可以看到,-q 选项的参数更靠近 1 让图片质量下降了很多。 + +### 生成缩略图 + +scort 工具还可以生成截屏的缩略图。这个功能可以通过 --thumb 选项打开。这个选项也需要一个 NUM 数值作为参数,基本上是指定原图大小的百分比。 + +scrot --thumb NUM + +scrot --thumb 50 + +**注意**:加上 --thumb 选项也会同时保存原始截图文件。 + +例如,下面是我测试的原始截图: + +[ + ![原始截图](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/orig.png) +][29] + +下面是保存的缩略图: + +[ + ![截图缩略图](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/thmb.png) +][30] + +### 拼接多显示器截屏 + +如果你的电脑接了多个显示设备,你可以用 scort 抓取并拼接这些显示设备的截图。这个功能可以通过 -m 选项打开。 + +scrot -m + +下面是示例截图: + +[ + ![拼接截屏](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/multiple.png) +][31] + +### 在保存截图后执行操作 + +使用这个工具,你可以在保存截图后执行各种操作 - 例如,用像 gThumb 这样的图片编辑器打开截图。这个功能可以通过 -e 选项打开。下面是例子: + +scrot abc.png -e ‘gthumb abc.png’ + +这个命令里的 gthumb 是一个图片编辑器,上面的命令在执行后会自动打开。 + +下面是命令的截图: + +[ + ![截屏后执行命令](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/exec1.png) +][32] + +这个是上面命令执行后的效果: + +[ + ![示例截图](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/exec2.png) +][33] + +你可以看到 scrot 抓取了屏幕截图,然后再启动了 gThumb 图片编辑器打开刚才保存的截图图片。 + +如果你截图时没有指定文件名,截图将会用带有时间戳的文件名保存到当前目录 - 这是 scrot 的默认设定,我们前面已经说过。 + +下面是一个使用默认名字并且加上 -e 选项来截图的例子: + +scrot -e ‘gthumb $n’ + +[ + ![scrot 截屏后运行 gthumb](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/exec3.png) +][34] + +有个地方要注意的是 $n 是一个特殊字符串,用来获取当前截图的文件名。关于特殊字符串的更多细节,请继续看下个小节。 + +### 特殊字符串 + +scrot 的 -e(或 --exec)选项和文件名参数可以使用格式说明符。有两种类型格式。第一种是以 '%' 加字母组成,用来表示日期和时间,第二种以 '$' 开头,scrot 内部使用。 + +下面介绍几个 --exec 和文件名参数接受的说明符。 + +**$f** – 让你可以使用截图的全路径(包括文件名)。 + +例如 + +scrot ashu.jpg -e ‘mv $f ~/Pictures/Scrot/ashish/’ + +下面是示例截图: + +[ + ![示例](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/f.png) +][35] + +如果你没有指定文件名,scrot 默认会用日期格式的文件名保存截图。这个是 scrot 的默认文件名格式:%yy-%mm-%dd-%hhmmss_$wx$h_scrot.png。 + +**$n** – 提供截图文件名。下面是示例截图: + +[ + ![scrot $n variable](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/n.png) +][36] + +**$s** – 获取截图的文件大小。这个功能可以像下面这样使用。 + +scrot abc.jpg -e ‘echo $s’ + +下面是示例截图: + +[ + ![scrot $s 变量](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/s.png) +][37] + +类似的,你也可以使用其他格式字符串 **$p**, **$w**, **$h**, **$t**, **$$** 以及 **\n** 来分别获取图片像素大小,图像宽度,图像高度,图像格式,输入 $ 字符,以及换行。你可以像上面介绍的 **$s** 格式那样使用这些字符串。 + +### 结论 + +这个应用能轻松地安装在 Ubuntu 系统上,对初学者比较友好。scrot 也提供了一些高级功能,比如支持格式化字符串,方便专业用户用脚本处理。当然,如果你想用起来的话有一点轻微的学习曲线。 + + ![](https://www.howtoforge.com/images/pdficon_small.png) + [vie][16] + +-------------------------------------------------------------------------------- + +via: https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/ + +作者:[Himanshu Arora][a] +译者:[zpl1025](https://github.com/zpl1025) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/ +[1]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#get-the-applicationnbspversion +[2]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#capturing-current-window +[3]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#selecting-a-window +[4]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#includenbspwindow-border-in-screenshots +[5]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#delay-in-taking-screenshots +[6]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#countdown-before-screenshot +[7]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#image-quality +[8]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#generating-thumbnails +[9]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#join-multiple-displays-shots +[10]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#executing-operations-on-saved-images +[11]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#special-strings +[12]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#about-scrot +[13]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#scrot-installation +[14]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#scrot-usagefeatures +[15]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#conclusion +[16]:https://www.howtoforge.com/subscription/ +[17]:https://www.howtoforge.com/tutorial/taking-screenshots-in-linux-using-gnome-screenshot/ +[18]:https://en.wikipedia.org/wiki/Scrot +[19]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/scrot.png +[20]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/version.png +[21]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/desktop.png +[22]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/active.png +[23]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/select1.png +[24]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/select2.png +[25]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/border-new.png +[26]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/delay.png +[27]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/countdown.png +[28]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/img-quality.jpg +[29]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/orig.png +[30]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/thmb.png +[31]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/multiple.png +[32]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/exec1.png +[33]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/exec2.png +[34]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/exec3.png +[35]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/f.png +[36]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/n.png +[37]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/s.png From b84b05cfdb83aca0c6e3d28da6e725156c5d2df9 Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Thu, 30 Nov 2017 15:56:17 +0800 Subject: [PATCH 058/344] Translated by qhwdw Translated by qhwdw --- ...lder and Other Image Loading Techniques.md | 238 ++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100644 translated/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md diff --git a/translated/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md b/translated/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md new file mode 100644 index 0000000000..32c24db6dc --- /dev/null +++ b/translated/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md @@ -0,0 +1,238 @@ +怎么去使用 SVG 作为一个占位符,以及其它图像加载技术 +============================================================ + +![](https://cdn-images-1.medium.com/max/1563/0*zJGl1vKLttcJGIL4.jpg) +从被用作占位符的图像中生成 SVGs。继续阅读! + +我对怎么去让 web 性能更优化和图像加载的更快充满了热情。对这些感兴趣的领域中的其中一项研究就是占位符:当图像还没有被加载的时候应该去展示些什么? + +在前此天,我偶然发现了使用 SVG 的一些加载技术,随后,我将在这篇文章中去描述它。 + +在这篇文章中我们将涉及如下的主题: + +* 不同的占位符类型的概述 + +* 基于 SVG 的占位符(边缘、形状、和轮廓) + +* 自动化处理 + +### 不同的占位符类型的概述 + +以前 [我写的关于占位符和图像延迟加载(lazy-loading)][28] 的文章和 [关于它的讨论][29] 中。当进行一个图像的延迟加载时,一个很好的主意是去考虑提供一个东西作为占位符,因为,它可能会很大程序上影响用户的感知体验。以前我提供了几个选项: + + +![](https://cdn-images-1.medium.com/max/1563/0*jlMM144vAhH-0bEn.png) + +在图像被加载之前,有几种办法去填充图像区域。 + +* 在图像区保持空白:在一个响应式设计的环境中,这种方式防止了内容的跳跃。这种布局从用户体验的角度来看是非常差的作法。但是,它是为了性能的考虑,否则,每次为了获取图像尺寸,浏览器被迫进行布局重计算,以为它留下空间。 + +* 占位符:在那里显示一个用户配置的图像。我们可以在背景上显示一个轮廓。它一直显示直到实际的图像被加载,它也被用于当请求失败或者当用户根本没有设置图像的情况下。这些图像一般都是矢量图,并且都选择尺寸非常小的内联图片。 + +* 固定的颜色:从图像中获取颜色,并将其作为占位符的背景颜色。这可能是主导的颜色,最具活力的 … 这个主意是基于你正在加载的图像,并且它将有助于在没有图像和图像加载完成之间进行平滑过渡。 + +* 模糊的图像:也被称为模糊技术。你提供一个极小版本的图像,然后再去过渡到完整的图像。最初的图像的像素和尺寸是极小的。为去除伪影图像(artifacts the image)被放大和模糊化。我在前面写的 [怎么去做中间的渐进加载的图像][1]、[使用 WebP 去创建极小的预览图像][2]、和 [渐进加载图像的更多示例][3] 中讨论过这方面的内容。 + +结果是,还有其它的更多的变化,并且许多聪明的人开发了其它的创建占位符的技术。 + +其中一个就是用梯度图代替固定的颜色。梯度图可以创建一个更精确的最终图像的预览,它整体上非常小(提升了有效载荷)。 + + +![](https://cdn-images-1.medium.com/max/1250/0*ecPkBAl69ayvRctn.jpg) +使用梯度图作为背景。来自 Gradify 的截屏,它现在并不在线,代码 [在 GitHub][4]。 + +其它的技术是使用基于 SVGs 的技术,它在最近的实验和黑客中得到了一些支持。 + +### 基于 SVG 的占位符 + +我们知道 SVGs 是完美的矢量图像。在大多数情况下我们是希望去加载一个位图,所以,问题是怎么去矢量化一个图像。一些选择是使用边缘、形状和轮廓。 + +#### 边缘 + +在 [前面的文章中][30],我解释了怎么去找出一个图像的边缘和创建一个动画。我最初的目标是去尝试绘制区域,矢量化这个图像,但是,我并不知道该怎么去做到。我意识到使用边缘也可能被创新,并且,我决定去让它们动起来,创建一个 “绘制” 的效果。 + +[在以前,使用边缘检测绘制图像和 SVG 动画,在 SVG 中基本上不被使用和支持的。一段时间以后,我们开始用它去作为一个有趣的替代 … medium.com][31][][32] + +#### 形状 + +SVG 也可以用于去从图像中绘制区域而不是边缘/边界。用这种方法,我们可以矢量化一个位图去创建一个占位符。 + +在以前,我尝试去用三角形做类似的事情。你可以在我的 [at CSSConf][33] 和 [Render Conf][34] 的演讲中看到它。 + + +上面的 codepen 是一个由 245 个三角形组成的基于 SVG 占位符的观点的证明。生成的三角形是使用 [Possan’s polyserver][36] 基于 [Delaunay triangulation][35]。正如预期的那样,使用更多的三角形,文件尺寸就更大。 + +#### Primitive 和 SQIP,一个基于 SVG 的 LQIP 技术 + +Tobias Baldauf 正在致力于另一个使用 SVGs 的被称为 [SQIP][37] 的低质量图像占位符技术。在深入研究 SQIP 之前,我先简单了解一下 [Primitive][38],它是基于 SQIP 的一个库。 + +Primitive 是非常吸引人的,我强烈建议你去了解一下。它讲解了一个位图怎么变成由重叠形状组成的 SVG。它尺寸比较小,一个更小的往返,更适合直接放置到页面中,在一个初始的 HTML 载荷中,它是非常有意义的。 + +Primitive 基于像三角形、长方形、和圆形等形状去生成一个图像。在每一步中它增加一个新形状。很多步之后,图像的结果看起来非常接近原始图像。如果你输出的是 SVG,它意味着输出代码的尺寸将很大。 + +为了理解 Primitive 是怎么工作的,我通过几个图像来跑一下它。我用 10 个形状和 100 个形状来为这个插画生成 SVGs: + + ** 此处有Canvas,请手动处理 ** + +![](https://cdn-images-1.medium.com/max/625/1*y4sr9twkh_WyZh6h0yH98Q.png) + + +![](https://cdn-images-1.medium.com/max/625/1*cqyhYnx83LYvhGdmg2dFDw.png) + +![](https://cdn-images-1.medium.com/max/625/1*qQP5160gPKQdysh0gFnNfw.jpeg) +Processing [this picture][5] 使用 Primitive,使用 [10 个形状][6] 和 [100 形状][7]。 + + +![](https://cdn-images-1.medium.com/max/625/1*PWZLlC4lrLO4CVv1GwR7qA.png) + + + +![](https://cdn-images-1.medium.com/max/625/1*khnga22ldJKOZ2z45Srh8A.png) + + +![](https://cdn-images-1.medium.com/max/625/1*N-20rR7YGFXiDSqIeIyOjA.jpeg) +Processing [this picture][8] 使用 Primitive,使用 [10 形状][9] 和 [100 形状][10]。 + +当在图像中使用 10 个形状时,我们基本构画出了原始图像。在图像环境占位符这里我们使用了 SVG 作为潜在的占位符。实际上,使用 10 个形状的 SVG 代码已经很小了,大约是 1030 字节,当通过 SVGO 传输时,它将下降到 ~640 字节。 + +``` + +``` + +使用 100 个形状生成的图像是很大的,正如我们预期的那样,在 SVGO(之前是 8kB)之后,加权大小为 ~5kB。它们在细节上已经很好了,但是仍然是个很小的载荷。使用多少三角形主要取决于图像类型和细腻程序(如,对比度、颜色数量、复杂度)。 + +它还可能去创建一个类似于 [cpeg-dssim][39] 的脚本,去调整所使用的形状的数量,以满足 [结构相似][40] 的阈值(或者最差情况中的最大数量)。 + +这些 SVG 的结果也可以用作背景图像。因为尺寸约束和矢量化,它们在图像和大规模的背景图像中是很好的选择。 + +#### SQIP + +用 [Tobias 自己的话说][41]: + +> SQIP 是尝试在这两个极端之间找到一种平衡:它使用 [Primitive][42] 去生成一个由几种简单图像构成的近似图像的可见特征的 SVG,使用 [SVGO][43] 去优化 SVG,并且为它增加高斯模糊滤镜。产生的最终的 SVG 占位符加权后大小为 ~800–1000 字节,在屏幕上看起来更为平滑,并提供一个可视的图像内容提示。 + +这个结果和使用一个极小的使用了模糊技术的占位符图像类似。(what [Medium][44] and [other sites][45] do)。区别在于它们使用了一个位图图像,如 JPG 或者 WebP,而这里是使用的占位符是 SVG。 + +如果我们使用 SQIP 而不是原始图像,我们将得到这样的效果: + + +![](https://cdn-images-1.medium.com/max/938/0*yUY1ZFP27vFYgj_o.png) + + + +![](https://cdn-images-1.medium.com/max/938/0*DKoZP7DXFvUZJ34E.png) +[第一张图片][11] 和 [第二张][12] 的输出图像使用了 SQIP。 + +输出的 SVG 是 ~900 字节,并且检查代码,我们可以发现 `feGaussianBlur` 过滤应用到形状组上: + +``` + +``` + +SQIP 也可以输出一个 Base 64 编码的 SVG 内容的图像标签: + +``` + +``` + +#### 轮廓 + +我们刚才看了使用了边缘和 primitive 形状的 SVG。另外一种可能是去矢量化图像以 “tracing” 它们。[Mikael 动画][47] 分享的 [a codepen][48],在几天前展示了怎么去使用两色轮廓作为一个占位符。结果非常漂亮: + + +![](https://cdn-images-1.medium.com/max/1250/1*r6HbVnBkISCQp_UVKjOJKQ.gif) + +SVGs 在这种情况下是手工绘制的,但是,这种技术可以用工具快速生成并自动化处理。 + +* [Gatsby][13],一个 React 支持的描绘 SVGs 的静态网站生成器。它使用 [一个 potrace 算法的 JS 端口][14] 去矢量化图像。 + +* [Craft 3 CMS][15],它也增加了对轮廓的支持。它使用 [一个 potrace 算法的 PHP 端口][16]。 + + +* [image-trace-loader][17],一个使用了 Potrace 算法去处理图像的 Webpack 加载器。 + + +如果感兴趣,可以去看一下 Emil 的 webpack 加载器 (基于 potrace) 和 Mikael 的手工绘制 SVGs 之间的比较。 + + +假设我使用一个默认选项的 potrace 生成输出。但是,有可能对它们进行调整。查看 [the options for image-trace-loader][49],它非常漂亮 [the ones passed down to potrace][50]。 + +### 总结 + +我们看到有不同的工具和技术去从图像中生成 SVGs,并且使用它们作为占位符。与 [WebP 是一个奇妙格式的缩略图][51] 方式相同,SVG 也是一个用于占位符的有趣的格式。我们可以控制细节的级别(和它们的大小),它是高可压缩的,并且很容易用 CSS 和 JS 进行处理。 + +#### 额外的资源 + +这篇文章发表于 [the top of Hacker News][52]。我非常感谢它,并且,在页面上的注释中的其它资源的全部有链接。下面是其中一部分。 + +* [Geometrize][18] 是用 Haxe 写的 Primitive 的一个端口。这个也是,[一个 JS 实现][19],你可以直接 [在你的浏览器上][20]尝试。 + +* [Primitive.js][21],它也是在 JS 中的一个 Primitive 端口,[primitive.nextgen][22],它是使用 Primitive.js 和 Electron 的 Primitive 的桌面版应用的一个端口。 + +* 这里有两个 Twitter 帐户,里面你可以看到一些用 Primitive 和 Geometrize 生成的图像示例。访问 [@PrimitivePic][23] 和 [@Geometrizer][24]。 + +* [imagetracerjs][25],它是在 JavaScript 中的光栅图像跟踪和矢量化程序。这里也有为 [Java][26] 和 [Android][27] 提供的端口。 + +-------------------------------------------------------------------------------- + +via: https://medium.freecodecamp.org/using-svg-as-placeholders-more-image-loading-techniques-bed1b810ab2c + +作者:[ José M. Pérez][a] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://medium.freecodecamp.org/@jmperezperez?source=post_header_lockup +[1]:https://medium.com/@jmperezperez/how-medium-does-progressive-image-loading-fd1e4dc1ee3d +[2]:https://medium.com/@jmperezperez/using-webp-to-create-tiny-preview-images-3e9b924f28d6 +[3]:https://medium.com/@jmperezperez/more-examples-of-progressive-image-loading-f258be9f440b +[4]:https://github.com/fraser-hemp/gradify +[5]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-281184-square.jpg +[6]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-281184-square-10.svg +[7]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-281184-square-100.svg +[8]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-618463-square.jpg +[9]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-618463-square-10.svg +[10]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-618463-square-100.svg +[11]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-281184-square-sqip.svg +[12]:https://jmperezperez.com/svg-placeholders/%28/assets/images/posts/svg-placeholders/pexels-photo-618463-square-sqip.svg +[13]:https://www.gatsbyjs.org/ +[14]:https://www.npmjs.com/package/potrace +[15]:https://craftcms.com/ +[16]:https://github.com/nystudio107/craft3-imageoptimize/blob/master/src/lib/Potracio.php +[17]:https://github.com/EmilTholin/image-trace-loader +[18]:https://github.com/Tw1ddle/geometrize-haxe +[19]:https://github.com/Tw1ddle/geometrize-haxe-web +[20]:http://www.samcodes.co.uk/project/geometrize-haxe-web/ +[21]:https://github.com/ondras/primitive.js +[22]:https://github.com/cielito-lindo-productions/primitive.nextgen +[23]:https://twitter.com/PrimitivePic +[24]:https://twitter.com/Geometrizer +[25]:https://github.com/jankovicsandras/imagetracerjs +[26]:https://github.com/jankovicsandras/imagetracerjava +[27]:https://github.com/jankovicsandras/imagetracerandroid +[28]:https://medium.com/@jmperezperez/lazy-loading-images-on-the-web-to-improve-loading-time-and-saving-bandwidth-ec988b710290 +[29]:https://www.youtube.com/watch?v=szmVNOnkwoU +[30]:https://medium.com/@jmperezperez/drawing-images-using-edge-detection-and-svg-animation-16a1a3676d3 +[31]:https://medium.com/@jmperezperez/drawing-images-using-edge-detection-and-svg-animation-16a1a3676d3 +[32]:https://medium.com/@jmperezperez/drawing-images-using-edge-detection-and-svg-animation-16a1a3676d3 +[33]:https://jmperezperez.com/cssconfau16/#/45 +[34]:https://jmperezperez.com/renderconf17/#/46 +[35]:https://en.wikipedia.org/wiki/Delaunay_triangulation +[36]:https://github.com/possan/polyserver +[37]:https://github.com/technopagan/sqip +[38]:https://github.com/fogleman/primitive +[39]:https://github.com/technopagan/cjpeg-dssim +[40]:https://en.wikipedia.org/wiki/Structural_similarity +[41]:https://github.com/technopagan/sqip +[42]:https://github.com/fogleman/primitive +[43]:https://github.com/svg/svgo +[44]:https://medium.com/@jmperezperez/how-medium-does-progressive-image-loading-fd1e4dc1ee3d +[45]:https://medium.com/@jmperezperez/more-examples-of-progressive-image-loading-f258be9f440b +[46]:http://www.w3.org/2000/svg +[47]:https://twitter.com/mikaelainalem +[48]:https://codepen.io/ainalem/full/aLKxjm/ +[49]:https://github.com/EmilTholin/image-trace-loader#options +[50]:https://www.npmjs.com/package/potrace#parameters +[51]:https://medium.com/@jmperezperez/using-webp-to-create-tiny-preview-images-3e9b924f28d6 +[52]:https://news.ycombinator.com/item?id=15696596 From c93a8d14aadf66e49d6089e28edc96e2c73414fe Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Thu, 30 Nov 2017 15:57:02 +0800 Subject: [PATCH 059/344] Translated by qhwdw Translated by qhwdw --- ...lder and Other Image Loading Techniques.md | 240 ------------------ 1 file changed, 240 deletions(-) delete mode 100644 sources/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md diff --git a/sources/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md b/sources/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md deleted file mode 100644 index 20731a03e4..0000000000 --- a/sources/tech/20171031 How to use SVG as a Placeholder and Other Image Loading Techniques.md +++ /dev/null @@ -1,240 +0,0 @@ -Translating by qhwdw -How to use SVG as a Placeholder, and Other Image Loading Techniques -============================================================ - -![](https://cdn-images-1.medium.com/max/1563/0*zJGl1vKLttcJGIL4.jpg) -Generating SVGs from images can be used for placeholders. Keep reading! - -I’m passionate about image performance optimisation and making images load fast on the web. One of the most interesting areas of exploration is placeholders: what to show when the image hasn’t loaded yet. - -During the last days I have come across some loading techniques that use SVG, and I would like to describe them in this post. - -In this post we will go through these topics: - -* Overview of different types of placeholders - -* SVG-based placeholders (edges, shapes and silhouettes) - -* Automating the process. - -### Overview of different types of placeholders - -In the past [I have written about placeholders and lazy-load of images][28], and also [talked about it][29]. When doing lazy-loading of images it’s a good idea to think about what to render as a placeholder, since it can have a big impact in user’s perceived performance. In the past I described several options: - - -![](https://cdn-images-1.medium.com/max/1563/0*jlMM144vAhH-0bEn.png) - -Several strategies to fill the area of an image before it loads. - -* Keeping the space empty for the image: In a world of responsive design, this prevents content from jumping around. Those layout changes are bad from a user’s experience point of view, but also for performance. The browser is forced to do layout re calculations every time it fetches the dimensions of an image, leaving space for it. - -* Placeholder: Imagine that we are displaying a user’s profile image. We might want to display a silhouette in the background. This is shown while the main image is loaded, but also when that request failed or when the user didn’t set any profile picture at all. These images are usually vector-based, and due to their small size are a good candidate to be inlined. - -* Solid colour: Take a colour from the image and use it as the background colour for the placeholder. This can be the dominant colour, the most vibrant… The idea is that it is based on the image you are loading and should help making the transition between no image to image loaded smoother. - -* Blurry image: Also called blur-up technique. You render a tiny version of the image and then transition to the full one. The initial image is tiny both in pixels and kBs. To remove artifacts the image is scaled up and blurred. I have written previously about this on [How Medium does progressive image loading][1], [Using WebP to create tiny preview images][2], and [More examples of Progressive Image Loading][3] . - -Turns out there are many other variations and lots of smart people are developing other techniques to create placeholders. - -One of them is having gradients instead of solid colours. The gradients can create a more accurate preview of the final image, with very little overhead (increase in payload). - - -![](https://cdn-images-1.medium.com/max/1250/0*ecPkBAl69ayvRctn.jpg) -Using gradients as backgrounds. Screenshot from Gradify, which is not online anymore. Code [on GitHub][4]. - -Another technique is using SVGs based on the image, which is getting some traction with recent experiments and hacks. - -### SVG-based placeholders - -We know SVGs are ideal for vector images. In most cases we want to load a bitmap one, so the question is how to vectorise an image. Some options are using edges, shapes and areas. - -#### Edges - -In [a previous post][30] I explained how to find out the edges of an image and create an animation. My initial goal was to try to draw regions, vectorising the image, but I didn’t know how to do it. I realised that using the edges could also be innovative and I decided to animate them creating a “drawing” effect. - -[Drawing images using edge detection and SVG animation -Back in the days SVG was barely used and supported. Some time after we started using them as an alternative to classic…medium.com][31][][32] - -#### Shapes - -SVG can also be used to draw areas from the image instead of edges/borders. In a way, we would vectorise a bitmap image to create a placeholder. - -Back in the days I tried to do something similar with triangles. You can see the result in my talks [at CSSConf][33] and [Render Conf][34]. - - -The codepen above is a proof of concept of a SVG-based placeholder composed of 245 triangles. The generation of the triangles is based on [Delaunay triangulation][35] using [Possan’s polyserver][36]. As expected, the more triangles the SVG uses, the bigger the file size. - -#### Primitive and SQIP, a SVG-based LQIP technique - -Tobias Baldauf has been working on another Low-Quality Image Placeholder technique using SVGs called [SQIP][37]. Before digging into SQIP itself I will give an overview of [Primitive][38], a library on which SQIP is based. - -Primitive is quite fascinating and I definitely recommend you to check it out. It converts a bitmap image into a SVG composed of overlapping shapes. Its small size makes it suitable for inlining it straight into the page. One less roundtrip, and a meaningful placeholder within the initial HTML payload. - -Primitive generates an image based on shapes like triangles, rectangles and circles (and a few others). In every step it adds a new one. The more steps, the resulting image looks closer to the original one. If your output is SVG it also means the size of the output code will be larger. - -In order to understand how Primitive works, I ran it through a couple of images. I generated SVGs for the artwork using 10 shapes and 100 shapes: - - ** 此处有Canvas,请手动处理 ** - -![](https://cdn-images-1.medium.com/max/625/1*y4sr9twkh_WyZh6h0yH98Q.png) - - -![](https://cdn-images-1.medium.com/max/625/1*cqyhYnx83LYvhGdmg2dFDw.png) - -![](https://cdn-images-1.medium.com/max/625/1*qQP5160gPKQdysh0gFnNfw.jpeg) -Processing [this picture][5] using Primitive, using [10 shapes][6] and [100 shapes][7]. - - -![](https://cdn-images-1.medium.com/max/625/1*PWZLlC4lrLO4CVv1GwR7qA.png) - - - -![](https://cdn-images-1.medium.com/max/625/1*khnga22ldJKOZ2z45Srh8A.png) - - -![](https://cdn-images-1.medium.com/max/625/1*N-20rR7YGFXiDSqIeIyOjA.jpeg) -Processing [this picture][8] using Primitive, using [10 shapes][9] and [100 shapes][10]. - -When using 10 shapes the images we start getting a grasp of the original image. In the context of image placeholders there is potential to use this SVG as the placeholder. Actually, the code for the SVG with 10 shapes is really small, around 1030 bytes, which goes down to ~640 bytes when passing the output through SVGO. - -``` - -``` - -The images generated with 100 shapes are larger, as expected, weighting ~5kB after SVGO (8kB before). They have a great level of detail with a still small payload. The decision of how many triangles to use will depend largely on the type of image (eg contrast, amount of colours, complexity) and level of detail. - -It would be possible to create a script similar to [cpeg-dssim][39] that tweaks the amount of shapes used until a [structural similarity][40] threshold is met (or a maximum number of shapes in the worst case). - -These resulting SVGs are great also to use as background images. Being size-constrained and vector-based they are a good candidate for hero images and large backgrounds that otherwise would show artifacts. - -#### SQIP - -In [Tobias’ own words][41]: - -> SQIP is an attempt to find a balance between these two extremes: it makes use of [Primitive][42] to generate a SVG consisting of several simple shapes that approximate the main features visible inside the image, optimizes the SVG using [SVGO][43] and adds a Gaussian Blur filter to it. This produces a SVG placeholder which weighs in at only ~800–1000 bytes, looks smooth on all screens and provides an visual cue of image contents to come. - -The result is similar to using a tiny placeholder image for the blur-up technique (what [Medium][44] and [other sites][45] do). The difference is that instead of using a bitmap image, eg JPG or WebP, the placeholder is SVG. - -If we run SQIP against the original images we’ll get this: - - -![](https://cdn-images-1.medium.com/max/938/0*yUY1ZFP27vFYgj_o.png) - - - -![](https://cdn-images-1.medium.com/max/938/0*DKoZP7DXFvUZJ34E.png) -The output images using SQIP for [the first picture][11] and [the second one][12]. - -The output SVG is ~900 bytes, and inspecting the code we can spot the `feGaussianBlur` filter applied to the group of shapes: - -``` - -``` - -SQIP can also output an image tag with the SVG contents Base 64 encoded: - -``` - -``` - -#### Silhouettes - -We just had a look at using SVGs for edges and primitive shapes. Another possibility is to vectorise the images “tracing” them. [Mikael Ainalem][47] shared [a codepen][48] a few days ago showing how to use a 2-colour silhouette as a placeholder. The result is really pretty: - - -![](https://cdn-images-1.medium.com/max/1250/1*r6HbVnBkISCQp_UVKjOJKQ.gif) - -The SVGs in this case were hand drawn, but the technique quickly spawned integrations with tools to automate the process. - -* [Gatsby][13], a static site generator using React supports these traced SVGs now. It uses [a JS PORT of potrace][14] to vectorise the images. - -* [Craft 3 CMS][15], which also added support for silhouettes. It uses [a PHP port of potrace][16]. - - -* [image-trace-loader][17], a Webpack loader that uses potrace to process the images. - - -It’s also interesting to see a comparison of the output between Emil’s webpack loader (based on potrace) and Mikael’s hand-drawn SVGs. - - -I assume the output generated by potrace is using the default options. However, it’s possible to tweak them. Check [the options for image-trace-loader][49], which are pretty much [the ones passed down to potrace][50]. - -### Summary - -We have seen different tools and techniques to generate SVGs from images and use them as placeholders. The same way [WebP is a fantastic format for thumbnails][51], SVG is also an interesting format to use in placeholders. We can control the level of detail (and thus, size), it’s highly compressible and easy to manipulate with CSS and JS. - -#### Extra Resources - -This post made it to [the top of Hacker News][52]. I’m very grateful for that, and for all the links to other resources that have been shared in the comments on that page. Here are a few of them! - -* [Geometrize][18] is a port of Primitive written in Haxe. There is also [a JS implementation][19] that you can try out directly [on your browser][20]. - -* [Primitive.js][21], which is a port of Primitive in JS. Also, [primitive.nextgen][22], which is a port of the Primitive desktop app using Primitive.js and Electron. - -* There are a couple of Twitter accounts where you can see examples of images generated with Primitive and Geometrize. Check out [@PrimitivePic][23] and [@Geometrizer][24]. - -* [imagetracerjs][25], which is a raster image tracer and vectorizer written in JavaScript. There are also ports for [Java][26] and [Android][27]. - --------------------------------------------------------------------------------- - -via: https://medium.freecodecamp.org/using-svg-as-placeholders-more-image-loading-techniques-bed1b810ab2c - -作者:[ José M. Pérez][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://medium.freecodecamp.org/@jmperezperez?source=post_header_lockup -[1]:https://medium.com/@jmperezperez/how-medium-does-progressive-image-loading-fd1e4dc1ee3d -[2]:https://medium.com/@jmperezperez/using-webp-to-create-tiny-preview-images-3e9b924f28d6 -[3]:https://medium.com/@jmperezperez/more-examples-of-progressive-image-loading-f258be9f440b -[4]:https://github.com/fraser-hemp/gradify -[5]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-281184-square.jpg -[6]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-281184-square-10.svg -[7]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-281184-square-100.svg -[8]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-618463-square.jpg -[9]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-618463-square-10.svg -[10]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-618463-square-100.svg -[11]:https://jmperezperez.com/assets/images/posts/svg-placeholders/pexels-photo-281184-square-sqip.svg -[12]:https://jmperezperez.com/svg-placeholders/%28/assets/images/posts/svg-placeholders/pexels-photo-618463-square-sqip.svg -[13]:https://www.gatsbyjs.org/ -[14]:https://www.npmjs.com/package/potrace -[15]:https://craftcms.com/ -[16]:https://github.com/nystudio107/craft3-imageoptimize/blob/master/src/lib/Potracio.php -[17]:https://github.com/EmilTholin/image-trace-loader -[18]:https://github.com/Tw1ddle/geometrize-haxe -[19]:https://github.com/Tw1ddle/geometrize-haxe-web -[20]:http://www.samcodes.co.uk/project/geometrize-haxe-web/ -[21]:https://github.com/ondras/primitive.js -[22]:https://github.com/cielito-lindo-productions/primitive.nextgen -[23]:https://twitter.com/PrimitivePic -[24]:https://twitter.com/Geometrizer -[25]:https://github.com/jankovicsandras/imagetracerjs -[26]:https://github.com/jankovicsandras/imagetracerjava -[27]:https://github.com/jankovicsandras/imagetracerandroid -[28]:https://medium.com/@jmperezperez/lazy-loading-images-on-the-web-to-improve-loading-time-and-saving-bandwidth-ec988b710290 -[29]:https://www.youtube.com/watch?v=szmVNOnkwoU -[30]:https://medium.com/@jmperezperez/drawing-images-using-edge-detection-and-svg-animation-16a1a3676d3 -[31]:https://medium.com/@jmperezperez/drawing-images-using-edge-detection-and-svg-animation-16a1a3676d3 -[32]:https://medium.com/@jmperezperez/drawing-images-using-edge-detection-and-svg-animation-16a1a3676d3 -[33]:https://jmperezperez.com/cssconfau16/#/45 -[34]:https://jmperezperez.com/renderconf17/#/46 -[35]:https://en.wikipedia.org/wiki/Delaunay_triangulation -[36]:https://github.com/possan/polyserver -[37]:https://github.com/technopagan/sqip -[38]:https://github.com/fogleman/primitive -[39]:https://github.com/technopagan/cjpeg-dssim -[40]:https://en.wikipedia.org/wiki/Structural_similarity -[41]:https://github.com/technopagan/sqip -[42]:https://github.com/fogleman/primitive -[43]:https://github.com/svg/svgo -[44]:https://medium.com/@jmperezperez/how-medium-does-progressive-image-loading-fd1e4dc1ee3d -[45]:https://medium.com/@jmperezperez/more-examples-of-progressive-image-loading-f258be9f440b -[46]:http://www.w3.org/2000/svg -[47]:https://twitter.com/mikaelainalem -[48]:https://codepen.io/ainalem/full/aLKxjm/ -[49]:https://github.com/EmilTholin/image-trace-loader#options -[50]:https://www.npmjs.com/package/potrace#parameters -[51]:https://medium.com/@jmperezperez/using-webp-to-create-tiny-preview-images-3e9b924f28d6 -[52]:https://news.ycombinator.com/item?id=15696596 From 22303b5f33c005773aca72a683d005832fe5cc03 Mon Sep 17 00:00:00 2001 From: wangy325 Date: Thu, 30 Nov 2017 21:28:06 +0800 Subject: [PATCH 060/344] to be revised. --- ...and Certification Are Key for SysAdmins.md | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 translated/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md diff --git a/translated/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md b/translated/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md new file mode 100644 index 0000000000..a3b5e95878 --- /dev/null +++ b/translated/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md @@ -0,0 +1,74 @@ + + +开源云技能和认证—系统管理员的核心竞争力 +========= + +![os jobs](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/open-house-sysadmin.jpg?itok=i5FHc3lu "os jobs") + +[2017年开源工作报告][1](以下简称“报告”)显示,具有开源云技术认证的系统管理员能获得更高的薪酬。报告遵守[CC0][2] *[译注1]*许可协议。 + +> 译注1:CC0,即知识/版权共享协议(Creative Commons Zero),任何人都可以不须经作者同意拷贝,修改,发布,甚至商用 + +报告显示53%的受访者认为系统管理员是雇主们最期望被填补的职位空缺之一,因此,具有良好(开源技能/项目经验)的系统管理员能获得更高的薪酬,但这一职位,并没想象中那么容易胜任。 + +一般来讲,系统管理员主要职责是服务器和其他电脑操作系统的安装、服务支持和维护;预防、及时处理服务中断或其他问题的出现。 + +总的来说,今年的报告发现需求最大的领域有开源云(47%),应用开发(44%),大数据(43%),开发运营和安全(42%) + +此外,报告还发现58%的人事经理计划招聘更多的开源专家,其中67%认为开源人才的需求增长会比业内其他领域更甚。那些认为开源人才将成为最大需求的单位招聘的开源人才数量较去年增加了2个百分点。 + +同时,89%的人事经理认为很难找到颇具天赋的开源人才。 + +### 为什么要获取认证 + +报告显示,对系统管理员的需求刺激着人事经理(为53%的组织机构)提供正规的培训和专业技术认证,而这一比例去年为47%。 + +对系统管理方面感兴趣的IT人才应该考虑Linux认证。随便查看几个知名的招聘网站,你就能发现:[CompTIA Linux+][3]认证是入门Linux系统管理员的必备(最高)认证,[红帽认证工程师(RHCE)][4]和[红帽认证系统管理员(RHCSA)][5]则是胜任高水平职位的主要认证。 + +戴士(Dice)[2017技术行业薪资调查][6]显示,2016年系统管理员的薪水为79,538美元,较上年下降了0.8%;系统架构师的薪水为125,946美元,同比下降4.7%。尽管如此,该调查发现“高水平专业人才仍最受欢迎,特别是那些精通支持产业转型发展所需技术的人才”。 + +在开源技术方面,HBase(一个开源的分布式数据库)技术人才的薪水在戴士2017技术行业薪资调查中排第一。在网络和数据库领域,掌握OpenVSM操作系统技术也能获得高薪。 + +### 成为出色的系统管理员 + +出色的系统管理员须在问题出现时马上处理,这意味着你必须时刻准备以应对可能出现的状况。这个职位追求“零责备的,精益的,流程或技术上交互式改进”的思维方式和善于自我完善的人格,专业系统管理员联盟董事会成员、[开源][7]上为推动系统管理实践发展的一个专业非盈利组织成员Paul English说道。成为一个系统管理员意味着“使用开源软件如Liunx,BSD甚至开源Solaris等已成定局”,他补充道。 + +English还说,现在的系统管理员较以前而言,要更多地与软件打交道,而且要能够编写脚本来协助系统管理。 + +### 展望2018 + + 根据[罗伯特·哈夫2018年技术人才薪资导览][8],预计2018年北美地区许多单位将聘请大量系统管理方面的专业人才。同时,个人软实力和领导力水平也是优秀人才的考量因素,并且越来越受到重视。 + + 报告指出:“良好的聆听能力和批判性思维能力对于理解和解决用户的问题和担忧至关重要,同时,也是IT从业者的重要技能,特别是从事服务台和桌面支持的技术人员。” + + [Linux基金会][9] *译注* 提出不同阶段的系统管理员的所需的基本技能,都包括了强大的分析能力和快速处理问题的能力。 + + 当一个系统管理员想逐渐爬上金字塔顶端,他应该还具备如下技能:系统配置的结构化方法充满兴趣,拥有解决安全问题的经验,用户身份(验证)管理的经验,与非技术人员进行非技术交流的能力,优化系统以满足最新的安全需求的能力。 + + 现在[下载][10]2017年开源工作报告。 + + + + + +----------------------- + +via: https://www.linux.com/blog/open-source-cloud-skills-and-certification-are-key-sysadmins + +作者:[ ][a] +译者:[wangy325](https://github.com/wangy325) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[1]:https://www.linuxfoundation.org/blog/2017-jobs-report-highlights-demand-open-source-skills/ +[2]:https://www.linux.com/licenses/category/creative-commons-zero +[3]:https://certification.comptia.org/certifications/linux?tracking=getCertified/certifications/linux.aspx +[4]:https://www.redhat.com/en/services/certification/rhce +[5]:https://www.redhat.com/en/services/certification/rhcsa +[6]:http://marketing.dice.com/pdf/Dice_TechSalarySurvey_2017.pdf?aliId=105832232 +[7]:https://opensource.com/article/17/7/truth-about-sysadmins +[8]:https://www.roberthalf.com/salary-guide/technology +[9]:https://www.linux.com/learn/10-essential-skills-novice-junior-and-senior-sysadmins%20%20 +[10]:http://bit.ly/2017OSSjobsreport \ No newline at end of file From f1c0ef8dbd050b8b8351e6929ddcaa5a5b74e9ff Mon Sep 17 00:00:00 2001 From: wenwensnow <963555237@qq.com> Date: Thu, 30 Nov 2017 22:35:30 +0800 Subject: [PATCH 061/344] 20171124 How to Install Android File Transfer for Linux.md (#6399) * Create 20171124 How to Install Android File Transfer for Linux.md * Delete 20171124 How to Install Android File Transfer for Linux.md --- ...Install Android File Transfer for Linux.md | 80 ------------------ ...Install Android File Transfer for Linux.md | 82 +++++++++++++++++++ 2 files changed, 82 insertions(+), 80 deletions(-) delete mode 100644 sources/tech/20171124 How to Install Android File Transfer for Linux.md create mode 100644 translated/tech/20171124 How to Install Android File Transfer for Linux.md diff --git a/sources/tech/20171124 How to Install Android File Transfer for Linux.md b/sources/tech/20171124 How to Install Android File Transfer for Linux.md deleted file mode 100644 index 4a9e04b49a..0000000000 --- a/sources/tech/20171124 How to Install Android File Transfer for Linux.md +++ /dev/null @@ -1,80 +0,0 @@ -Translating by wenwensnow -# How to Install Android File Transfer for Linux - -If you’re struggling to mount your Android phone on Ubuntu you might want to give [Android File Transfer for Linux][4] a try. - -Effectively it’s a clone of Google’s [Android File Transfer][6] app for macOS. It’s built with Qt, and has a super simple UI that makes it easy to transfer files and folders to and from your Android smartphone and your Ubuntu machine. - -Now, chances are a few of you will be scratching your head wondering what this app does that Nautilus, the default file manager in Ubuntu, doesn’t — and the answer is nothing. - -When I connect my Nexus 5X (and remember to select the [MTP][7] option) to my Ubuntu machine I can browse, open and manage it using Nautilus, just like my phone was a regular USB drive thanks to [GVfs][8]: - - [![Nautilus MTP integration with a Nexus 5X](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg)][9] - -But  _some_  people experience issues with this, and other MTP implementations, such as directories not loading, directory creation that doesn’t “stick”, and issues using their device inside a media player. - -And it’s for those people whom Android File Transfer for Linux is designed. Consider it an alternative to other methods of mounting MTP devices on Linux. If what you use currently works a-ok, you probably don’t need to try this out (unless you really like trying things out). - -![Android File Transfer Linux App](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/android-file-transfer-for-linux-750x662.jpg) - -The app features: - -* A straightforward user interface - -* Drag and drop support (Linux to Phone) - -* Batch downloading (Phone to Linux) - -* Transfer progress dialogs - -* FUSE wrapper - -* No file size limits - -* Optional CLI tool - -### Install Android File Transfer on Ubuntu - -That’s enough waffle about this alternative way to mount your Android phone, on to the nitty gritty of installing it. - -Helpfully there’s a [PPA available][10] which provides builds for Ubuntu 14.04 LTS, 16.04 LTS and Ubuntu 17.10. - -To add the PPA to your list of software sources run this command: - -``` -sudo add-apt-repository ppa:samoilov-lex/aftl-stable -``` - -Then, to install Android File Transfer for Linux on Ubuntu, run: - -``` -sudo apt-get update && sudo apt install android-file-transfer -``` - -That’s pretty much it. - -You’ll find a launcher for the app in your app menu. - -Before launching it do make make sure that no other devices (such as Nautilus) mount your phone first. If anything is using it the app will report “no MTP device found”. To fix, unmount your device from Nautilus (or whichever app is using it) then relaunch Android File Transfer. - --------------------------------------------------------------------------------- - -via: http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux - -作者:[ JOEY SNEDDON ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://plus.google.com/117485690627814051450/?rel=author -[1]:https://plus.google.com/117485690627814051450/?rel=author -[2]:http://www.omgubuntu.co.uk/category/app -[3]:http://www.omgubuntu.co.uk/category/download -[4]:https://github.com/whoozle/android-file-transfer-linux -[5]:http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux -[6]:http://android.com/filetransfer?linkid=14270770 -[7]:https://en.wikipedia.org/wiki/Media_Transfer_Protocol -[8]:https://en.wikipedia.org/wiki/GVfs -[9]:http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg -[10]:https://launchpad.net/~samoilov-lex/+archive/ubuntu/aftl-stable diff --git a/translated/tech/20171124 How to Install Android File Transfer for Linux.md b/translated/tech/20171124 How to Install Android File Transfer for Linux.md new file mode 100644 index 0000000000..b93429f509 --- /dev/null +++ b/translated/tech/20171124 How to Install Android File Transfer for Linux.md @@ -0,0 +1,82 @@ +Translating by wenwensnow + +# 如何在Linux下安装安卓文件传输助手 + +如果你尝试在Ubuntu下安装你的安卓手机,你也许可以试试Linux下的安卓文件传输助手 + +本质上来说,这个应用是谷歌mac版本的一个复制。它是用Qt编写的,用户界面非常简洁,使得你能轻松在Ubuntu和安卓手机之间传输文件。 + +现在,有可能一部分人想知道有什么是这个应用可以做,而Nautilus(Ubuntu默认的文件资源管理器)不能做的,答案是没有。 + +当我将我的 Nexus 5X(记得选择[MTP][7] 选项)连接在Ubuntu上时,在[GVfs][8](Gnome桌面下的虚拟文件系统)的帮助下,我可以打开,浏览和管理我的手机, 就像它是一个普通的U盘一样。 + + [![Nautilus MTP integration with a Nexus 5X](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg)][9] + +但是一些用户在使用默认的文件管理器时,在MTP的某些功能上会出现问题:比如文件夹没有正确加载,创建新文件夹后此文件夹不存在,或者无法在媒体播放器中使用自己的手机。 + +这就是要为Linux系统用户设计一个安卓文件传输助手应用的原因。将这个应用当做将MTP设备安装在Linux下的另一种选择。如果你使用Linux下的默认应用时一切正常,你也许并不需要尝试使用它 (除非你真的很想尝试新鲜事物)。 + + +![Android File Transfer Linux App](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/android-file-transfer-for-linux-750x662.jpg) + +app特点: + +*   简洁直观的用户界面 + +*   支持文件拖放功能(从Linux系统到手机) + +*   支持批量下载 (从手机到Linux系统) + +*   显示传输进程对话框 + +*   FUSE模块支持 + +*   没有文件大小限制 + +*   可选命令行工具 + +### Ubuntu下安装安卓手机文件助手的步骤 + +以上就是对这个应用的介绍,下面是如何安装它的具体步骤。 + +这有一个[PPA](个人软件包集)源为Ubuntu 14.04 LTS(长期支持版本),16.04LTS 和 Ubuntu17.10 提供可用应用 + +为了将这一PPA加入你的软件资源列表中,执行这条命令: + +``` +sudo add-apt-repository ppa:samoilov-lex/aftl-stable +``` + +接着,为了在Ubuntu下安装Linux版本的安卓文件传输助手,执行: + +``` +sudo apt-get update && sudo apt install android-file-transfer +``` + +这样就行了。 + +你会在你的应用列表中发现这一应用的启动图标。 + +在你启动这一应用之前,要确保没有其他应用(比如Nautilus)已经加载了你的手机.如果其他应用正在使用你的手机,就会显示“无法找到MTP设备”。为了解决这一问题,将你的手机从Nautilus(或者任何正在使用你的手机的应用)上移除,然后再重新启动安卓文件传输助手。 + +-------------------------------------------------------------------------------- + +via: http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux + +作者:[ JOEY SNEDDON ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://plus.google.com/117485690627814051450/?rel=author +[1]:https://plus.google.com/117485690627814051450/?rel=author +[2]:http://www.omgubuntu.co.uk/category/app +[3]:http://www.omgubuntu.co.uk/category/download +[4]:https://github.com/whoozle/android-file-transfer-linux +[5]:http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux +[6]:http://android.com/filetransfer?linkid=14270770 +[7]:https://en.wikipedia.org/wiki/Media_Transfer_Protocol +[8]:https://en.wikipedia.org/wiki/GVfs +[9]:http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg +[10]:https://launchpad.net/~samoilov-lex/+archive/ubuntu/aftl-stable From eb30eb0a270444e7165022ee97ede5e654097b34 Mon Sep 17 00:00:00 2001 From: Ezio Date: Thu, 30 Nov 2017 22:44:44 +0800 Subject: [PATCH 062/344] =?UTF-8?q?20171130-1=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Search DuckDuckGo from the Command Line.md | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 sources/tech/20171130 Search DuckDuckGo from the Command Line.md diff --git a/sources/tech/20171130 Search DuckDuckGo from the Command Line.md b/sources/tech/20171130 Search DuckDuckGo from the Command Line.md new file mode 100644 index 0000000000..a54c292924 --- /dev/null +++ b/sources/tech/20171130 Search DuckDuckGo from the Command Line.md @@ -0,0 +1,101 @@ +# Search DuckDuckGo from the Command Line + + ![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/duckduckgo.png) +When we showed you how to [search Google from the command line][3] a lot of you to say you use [Duck Duck Go][4], the awesome privacy-focused search engine. + +Well, now there’s a tool to search DuckDuckGo from the command line. It’s called [ddgr][6] (pronounced, in my head, as  _dodger_ ) and it’s pretty neat. + +Like [Googler][7], ddgr is totally open-source and totally unofficial. Yup, the app is unaffiliated with DuckDuckGo in any way. So, should it start returning unsavoury search results for innocent terms, make sure you quack in this dev’s direction, and not the search engine’s! + +### DuckDuckGo Terminal App + +![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/ddgr-gif.gif) + +[DuckDuckGo Bangs][8] makes finding stuff on DuckDuckGo super easy (there’s even a bang for  _this_  site) and, dutifully, ddgr supports them. + +Unlike the web interface, you can specify the number of search results you would like to see per page. It’s more convenient than skimming through 30-odd search results per page. The default interface is carefully designed to use minimum space without sacrificing readability. + +`ddgr` has a number of features, including: + +* Choose number of search results to fetch + +* Support for Bash autocomplete + +* Use !bangs + +* Open URLs in a browser + +* “I’m feeling lucky” option + +* Filter by time, region, file type, etc + +* Minimal dependencies + +You can download `ddgr` for various systems direct from the Github project page: + +[Download ‘ddgr’ from Github][9] + +You can also install ddgr on Ubuntu 16.04 LTS and up from a PPA. This repo is maintained by the developer of ddgr and is recommended should you want to stay up-to-date with new releases as and when they appear. + +Do note that at the time of writing the latest version of ddgr is  _not_  in the PPA, but an older version (lacking –num support) is: + +``` +sudo add-apt-repository ppa:twodopeshaggy/jarun +``` + +``` +sudo apt-get update +``` + +### How To Use ddgr to Search DuckDuckGo from the Comand Line + +To use ddgr once you installed all you need to do is pop open your terminal emulator of choice and run: + +``` +ddgr +``` + +Next enter a search term: + +``` +search-term +``` + +To limit the number of results returned run: + +``` +ddgr --num 5 search-term +``` + +To instantly open the first matching result for a search term in your browser run: + +``` +ddgr -j search-term +``` + +You can pass arguments and flags to narrow down your search. To see a comprehensive list inside the terminal run: + +``` +ddgr -h +``` + +-------------------------------------------------------------------------------- + +via: http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app + +作者:[JOEY SNEDDON ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://plus.google.com/117485690627814051450/?rel=author +[1]:https://plus.google.com/117485690627814051450/?rel=author +[2]:http://www.omgubuntu.co.uk/category/download +[3]:http://www.omgubuntu.co.uk/2017/08/search-google-from-the-command-line +[4]:http://duckduckgo.com/ +[5]:http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app +[6]:https://github.com/jarun/ddgr +[7]:https://github.com/jarun/googler +[8]:https://duckduckgo.com/bang +[9]:https://github.com/jarun/ddgr/releases/tag/v1.1 From 5e90fa5893d4af56110960e92941370be4adf641 Mon Sep 17 00:00:00 2001 From: Ezio Date: Thu, 30 Nov 2017 22:46:39 +0800 Subject: [PATCH 063/344] =?UTF-8?q?20171130-2=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ng to Linux Disks Files and Filesystems.md | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 sources/tech/20171127 Migrating to Linux Disks Files and Filesystems.md diff --git a/sources/tech/20171127 Migrating to Linux Disks Files and Filesystems.md b/sources/tech/20171127 Migrating to Linux Disks Files and Filesystems.md new file mode 100644 index 0000000000..5227d5f16e --- /dev/null +++ b/sources/tech/20171127 Migrating to Linux Disks Files and Filesystems.md @@ -0,0 +1,135 @@ +Migrating to Linux: Disks, Files, and Filesystems +============================================================ + +![Migrating to LInux ](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/butterflies-807551_1920.jpg?itok=pxTxwvFO "Migrating to LInux ") +Installing and using Linux on your main desktop will help you quickly become familiar with the methods and tools you need.[Creative Commons Zero][1]Pixabay + +This is the second article in our series on migrating to Linux. If you missed the first one, [you can find it here][4]. As mentioned previously, there are several reasons why you might want to migrate to Linux. You might be using or developing code for Linux in your job, or you might just want to try something new. + +In any case, having Linux on your main desktop will help you quickly become familiar with the methods and tools you’ll need. In this article, I’ll provide an introduction to Linux files, filesystems and disks. + +### Where's My C:\? + +If you are coming from a Mac, Linux should feel fairly familiar to you, as the Mac uses files, filesystems, and disks pretty closely to the way Linux does. On the other hand, if your experience is primarily Windows, accessing disks under Linux may seem a little confusing. Generally, Windows assigns a drive letter (like C:\) to each disk. Linux does not do this. Instead Linux presents a single hierarchy of files and directories for everything in your system. + +Let's look at an example. Suppose you use a computer with a main hard drive, a CD-ROM with folders called  _Books_  and  _Videos_  and a USB thumb drive with a directory called  _Transfer_ . Under Windows, you would see the following: + +``` +C:\ [Hard drive] + +├ System + +├ System32 + +├ Program Files + +├ Program Files (x86) + +└ + +D:\ [CD-ROM] + +├ Books + +└ Videos + +E:\ [USB thumb drive] + +└ Transfer +``` + +A typical Linux system would instead have this: + +``` +/ (the top most directory, called the root directory) [Hard drive] + +├ bin + +├ etc + +├ lib + +├ sbin + +├ usr + +├ + +└ media + + └ + + ├ cdrom [CD-ROM] + + │ ├ Books + + │ └ Videos + + └ Kingme_USB [USB thumb drive] + + └ Transfer +``` + +If you are using a graphical environment, usually, the file manager in Linux will present the CD-ROM and the USB thumb drive with icons that look like the device, so you may not need to know the media's specific directory. + +### Filesystems + +Linux emphasizes these things called filesystems. A filesystem is a set of structures on media (like a hard drive) that keep track of all the files and directories on the media. Without a filesystem we could store information on a hard drive, but all the data would be in a jumbled mess. We wouldn't know which blocks of data belonged to which file. You may have heard of names like Ext4, XFS, and Btrfs. These are Linux filesystem types. + +Every type of media that holds files and directories has a filesystem on it. Different media types may use specific filesystem types that are optimized for the media. So CD-ROMs use ISO9660 or UDF filesystem types. USB thumbdrives typically use FAT32 so they can be easily shared with other computer systems. + +Windows uses filesystems, too. It just doesn't talk about them as much. For example, when you insert a CD-ROM, Windows will read the ISO9660 filesystem structures, assign a drive letter to it and display the files and directories under the letter (D:\ for example). So if you're picky about details, technically Windows assigns a drive letter to a filesystem, not the whole disk. + +Using that same example, Linux will also read the ISO9660 filesystem structures, but instead of a drive letter, it will attach the filesystem to a directory (a process called mounting). Linux will then display the files and directories on the CD-ROM under the attached directory ( _/media//cdrom,_  for example). + +So to answer the question "Where's my C:\?" On Linux, there is no C:\. It works differently. + +### Files + +Windows stores files and directories (also called folders) in its filesystem. Linux, however, lets you put other things into the filesystem as well. These additional types of things are native objects in the filesystem, and they're actually different from regular files. Linux allows you to create and use hard links, symbolic links, named pipes, device nodes, and sockets, in addition to the regular files and directories. We won't get into all the types of filesystem objects here, but there are a few that are useful to know about. + +Hard links are used to create one or more aliases for a file. Each alias is a different name to the same contents on disk. If you edit the file under one file name, the changes appear under the other file names as well. For example. you might have  _MyResume_2017.doc_  also have a hard link called  _JaneDoeResume.doc_ . (Note that you can create a hard link by using the _ln_  command from the command line.) This way you can find and edit  _MyResume_2017.doc_ , then send out  _JaneDoeResume.doc_  to your prospects to help them keep track where it's from -- which will contain all your updates. + +Symbolic links are a little like Windows shortcuts. The filesystem entry contains a path to another file or directory. In a lot of ways, they work like hard links in that they can create an alias to another file. However, symbolic links can alias directories as well as files, and symbolic links can refer to items in a different filesystem on different media where hard links cannot. (Note that you can create symbolic links also with the _ln_ command, but with the  _-s_ option.) + +### Permissions + +Another big difference between Windows and Linux involves the permissions on filesystem objects (files, directories, and others). Windows implements a fairly complex set of permissions on files and directories. For example, users and groups can have permissions to read, write, execute, modify, and more. Users and groups can be given permission to access everything in a directory with exceptions, or they can be given no permission to anything in a directory with exceptions. + +Most folks using Windows don't make use of special permissions, however; so, it's surprising when they discover that a default set of permissions are used and enforced on Linux. Linux can enforce more sophisticated permissions by using SELinux or AppArmor. However most Linux installations just use the built-in default permissions. + +In the default permissions, each item in the filesystem has a set of permissions for the owner of the file, the group for the file, and for everyone else. These permissions allow for: reading, writing, and executing. The permissions have a hierarchy to them. First, it checks whether the user (the login name) is the owner and has permission. If not, then it checks whether your user (login name) is in the group for the file and the group has permission. If not, then it checks whether everyone else has permission. There are other permission settings as well, but the three sets of three are the ones most commonly used. + +If you are using the command line, and you type ls -l, you may see permissions represented as: + +``` +rwxrw-r-- 1 stan dndgrp 25 Oct 33rd 25:01 rolldice.sh +``` + +The letters at the beginning, rwxrw-r--, show the permissions. In this case, the owner (stan) can read, write, and execute the file (the first three letters, rwx); members of the group dndgrp can read and write the file but not execute (the second three letters, rw-); and everyone else can only read the file (the last three letters, r--). + +(Note that on Windows to make a script executable, you make the file's extension something specific, .bat for example. On Linux, the file's extension doesn't mean anything to the operating system. Instead its permissions need to be set so the file is executable.) + +If you get a  _permission denied_  error, chances are you are attempting to run a program or command that requires administrator privilege, or you're trying to access a file that doesn't hold permissions for your user account to access it. If you are trying to do something that requires administrator privilege, you will need to switch to the user account called  _root_  by logging in as root, or by using a helper program called  _sudo_  on the command line, which will allow you to temporarily run as root. The sudo tool will, of course, ask for a password to make sure you really should have permission. + +### Hard Drive Filesystems + +Windows predominately uses a filesystem type called NTFS for hard drives. On Linux, you get to pick which type of filesystem you want to use for the hard drive. Different types of filesystems exhibit different features and different performance characteristics. The main native Linux filesystem used today is Ext4\. However, you can choose from an abundance of filesystem types at installation time, such as: Ext3 (predecessor to Ext4), XFS, Btrfs, UBIFS (for embedded systems), and more. If you're not sure which one to use, Ext4 will work great. + + _Learn more about Linux through the free ["Introduction to Linux" ][2]course from The Linux Foundation and edX._ + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/intro-to-linux/2017/11/migrating-linux-disks-files-and-filesystems + +作者:[JOHN BONESIO][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/johnbonesio +[1]:https://www.linux.com/licenses/category/creative-commons-zero +[2]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux +[3]:https://www.linux.com/files/images/butterflies-8075511920jpg +[4]:https://www.linux.com/blog/learn/intro-to-linux/2017/10/migrating-linux-introduction From 44c0562a198475f7ba840ea3fc3ea448010bb8d8 Mon Sep 17 00:00:00 2001 From: Ezio Date: Thu, 30 Nov 2017 22:51:49 +0800 Subject: [PATCH 064/344] =?UTF-8?q?20171130-3=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ilable on Flathub the Flatpak App Store.md | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md diff --git a/sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md b/sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md new file mode 100644 index 0000000000..1f8dde5784 --- /dev/null +++ b/sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md @@ -0,0 +1,70 @@ +# LibreOffice Is Now Available on Flathub, the Flatpak App Store + +![LibreOffice on Flathub](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/libroffice-on-flathub-750x250.jpeg) + +LibreOffice is now available to install from [Flathub][3], the centralised Flatpak app store. + +Its arrival allows anyone running a modern Linux distribution to install the latest stable release of LibreOffice in a click or two, without having to hunt down a PPA, tussle with tarballs or wait for a distro provider to package it up. + +A [LibreOffice Flatpak][5] has been available for users to download and install since August of last year and the [LibreOffice 5.2][6] release. + +What’s “new” here is the distribution method. Rather than release updates through their own dedicated server The Document Foundation has opted to use Flathub. + +This is  _great_  news for end users as it means there’s one less repo to worry about adding on a fresh install, but it’s also good news for Flatpak advocates too: LibreOffice is open-source software’s most popular productivity suite. Its support for both format and app store is sure to be warmly welcomed. + +At the time of writing you can install LibreOffice 5.4.2 from Flathub. New stable releases will be added as and when they’re released. + +### Enable Flathub on Ubuntu + +![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/flathub-750x495.png) + +Fedora, Arch, and Linux Mint 18.3 users have Flatpak installed, ready to go, out of the box. Mint even comes with the Flathub remote pre-enabled. + +[Install LibreOffice from Flathub][7] + +To get Flatpak up and running on Ubuntu you first have to install it: + +``` +sudo apt install flatpak gnome-software-plugin-flatpak +``` + +To be able to install apps from Flathub you need to add the Flathub remote server: + +``` +flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +``` + +That’s pretty much it. Just log out and back in (so that Ubuntu Software refreshes its cache) and you  _should_  be able to find any Flatpak apps available on Flathub through the Ubuntu Software app. + +In this instance, search for “LibreOffice” and locate the result that has a line of text underneath mentioning Flathub. (Do bear in mind that Ubuntu has tweaked the Software client to shows Snap app results above everything else, so you may need scroll down the list of results to see it). + +There is a [bug with installing Flatpak apps][8] from a flatpakref file, so if the above method doesn’t work you can also install Flatpak apps form Flathub using the command line. + +The Flathub website lists the command needed to install each app. Switch to the “Command Line” tab to see them. + +#### More apps on Flathub + +If you read this site regularly enough you’ll know that I  _love_  Flathub. It’s home to some of my favourite apps (Corebird, Parlatype, GNOME MPV, Peek, Audacity, GIMP… etc). I get the latest, stable versions of these apps (plus any dependencies they need) without compromise. + +And, as I tweeted a week or so back, most Flatpak apps now look great with GTK themes — no more [workarounds][9]required! + +-------------------------------------------------------------------------------- + +via: http://www.omgubuntu.co.uk/2017/11/libreoffice-now-available-flathub-flatpak-app-store + +作者:[ JOEY SNEDDON ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://plus.google.com/117485690627814051450/?rel=author +[1]:https://plus.google.com/117485690627814051450/?rel=author +[2]:http://www.omgubuntu.co.uk/category/news +[3]:http://www.flathub.org/ +[4]:http://www.omgubuntu.co.uk/2017/11/libreoffice-now-available-flathub-flatpak-app-store +[5]:http://www.omgubuntu.co.uk/2016/08/libreoffice-5-2-released-whats-new +[6]:http://www.omgubuntu.co.uk/2016/08/libreoffice-5-2-released-whats-new +[7]:https://flathub.org/repo/appstream/org.libreoffice.LibreOffice.flatpakref +[8]:https://bugs.launchpad.net/ubuntu/+source/gnome-software/+bug/1716409 +[9]:http://www.omgubuntu.co.uk/2017/05/flatpak-theme-issue-fix From 31f640e100ceefaa92750c5dc03e4ad87148f186 Mon Sep 17 00:00:00 2001 From: Ezio Date: Thu, 30 Nov 2017 22:59:10 +0800 Subject: [PATCH 065/344] =?UTF-8?q?20171130-4=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...1109 Concurrent Servers- Part 4 - libuv.md | 492 ++++++++++++++++++ 1 file changed, 492 insertions(+) create mode 100644 sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md diff --git a/sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md b/sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md new file mode 100644 index 0000000000..a41fc008fa --- /dev/null +++ b/sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md @@ -0,0 +1,492 @@ +[Concurrent Servers: Part 4 - libuv][17] +============================================================ + +This is part 4 of a series of posts on writing concurrent network servers. In this part we're going to use libuv to rewrite our server once again, and also talk about handling time-consuming tasks in callbacks using a thread pool. Finally, we're going to look under the hood of libuv for a bit to study how it wraps blocking file-system operations with an asynchronous API. + +All posts in the series: + +* [Part 1 - Introduction][7] + +* [Part 2 - Threads][8] + +* [Part 3 - Event-driven][9] + +* [Part 4 - libuv][10] + +### Abstracting away event-driven loops with libuv + +In [part 3][11], we've seen how similar select-based and epoll-based servers are, and I mentioned it's very tempting to abstract away the minor differences between them. Numerous libraries are already doing this, however, so in this part I'm going to pick one and use it. The library I'm picking is [libuv][12], which was originally designed to serve as the underlying portable platform layer for Node.js, and has since found use in additional projects. libuv is written in C, which makes it highly portable and very suitable for tying into high-level languages like JavaScript and Python. + +While libuv has grown to be a fairly large framework for abstracting low-level platform details, it remains centered on the concept of an  _event loop_ . In our event-driven servers in part 3, the event loop was explicit in the main function; when using libuv, the loop is usually hidden inside the library itself, and user code just registers event handlers (as callback functions) and runs the loop. Furthermore, libuv will use the fastest event loop implementation for a given platform: for Linux this is epoll, etc. + +![libuv loop](https://eli.thegreenplace.net/images/2017/libuvloop.png) + +libuv supports multiple event loops, and thus an event loop is a first class citizen within the library; it has a handle - uv_loop_t, and functions for creating/destroying/starting/stopping loops. That said, I will only use the "default" loop in this post, which libuv makes available via uv_default_loop(); multiple loops are mosly useful for multi-threaded event-driven servers, a more advanced topic I'll leave for future parts in the series. + +### A concurrent server using libuv + +To get a better feel for libuv, let's jump to our trusty protocol server that we've been vigorously reimplementing throughout the series. The structure of this server is going to be somewhat similar to the select and epoll-based servers of part 3, since it also relies on callbacks. The full [code sample is here][13]; we start with setting up the server socket bound to a local port: + +``` +int portnum = 9090; +if (argc >= 2) { + portnum = atoi(argv[1]); +} +printf("Serving on port %d\n", portnum); + +int rc; +uv_tcp_t server_stream; +if ((rc = uv_tcp_init(uv_default_loop(), &server_stream)) < 0) { + die("uv_tcp_init failed: %s", uv_strerror(rc)); +} + +struct sockaddr_in server_address; +if ((rc = uv_ip4_addr("0.0.0.0", portnum, &server_address)) < 0) { + die("uv_ip4_addr failed: %s", uv_strerror(rc)); +} + +if ((rc = uv_tcp_bind(&server_stream, (const struct sockaddr*)&server_address, 0)) < 0) { + die("uv_tcp_bind failed: %s", uv_strerror(rc)); +} +``` + +Fairly standard socket fare here, except that it's all wrapped in libuv APIs. In return we get a portable interface that should work on any platform libuv supports. + +This code also demonstrates conscientious error handling; most libuv functions return an integer status, with a negative number meaning an error. In our server we treat these errors as fatals, but one may imagine a more graceful recovery. + +Now that the socket is bound, it's time to listen on it. Here we run into our first callback registration: + +``` +// Listen on the socket for new peers to connect. When a new peer connects, +// the on_peer_connected callback will be invoked. +if ((rc = uv_listen((uv_stream_t*)&server_stream, N_BACKLOG, on_peer_connected)) < 0) { + die("uv_listen failed: %s", uv_strerror(rc)); +} +``` + +uv_listen registers a callback that the event loop will invoke when new peers connect to the socket. Our callback here is called on_peer_connected, and we'll examine it soon. + +Finally, main runs the libuv loop until it's stopped (uv_run only returns when the loop has stopped or some error occurred). + +``` +// Run the libuv event loop. +uv_run(uv_default_loop(), UV_RUN_DEFAULT); + +// If uv_run returned, close the default loop before exiting. +return uv_loop_close(uv_default_loop()); +``` + +Note that only a single callback was registered by main prior to running the event loop; we'll soon see how additional callbacks are added. It's not a problem to add and remove callbacks throughout the runtime of the event loop - in fact, this is how most servers are expected to be written. + +This is on_peer_connected, which handles new client connections to the server: + +``` +void on_peer_connected(uv_stream_t* server_stream, int status) { + if (status < 0) { + fprintf(stderr, "Peer connection error: %s\n", uv_strerror(status)); + return; + } + + // client will represent this peer; it's allocated on the heap and only + // released when the client disconnects. The client holds a pointer to + // peer_state_t in its data field; this peer state tracks the protocol state + // with this client throughout interaction. + uv_tcp_t* client = (uv_tcp_t*)xmalloc(sizeof(*client)); + int rc; + if ((rc = uv_tcp_init(uv_default_loop(), client)) < 0) { + die("uv_tcp_init failed: %s", uv_strerror(rc)); + } + client->data = NULL; + + if (uv_accept(server_stream, (uv_stream_t*)client) == 0) { + struct sockaddr_storage peername; + int namelen = sizeof(peername); + if ((rc = uv_tcp_getpeername(client, (struct sockaddr*)&peername, + &namelen)) < 0) { + die("uv_tcp_getpeername failed: %s", uv_strerror(rc)); + } + report_peer_connected((const struct sockaddr_in*)&peername, namelen); + + // Initialize the peer state for a new client: we start by sending the peer + // the initial '*' ack. + peer_state_t* peerstate = (peer_state_t*)xmalloc(sizeof(*peerstate)); + peerstate->state = INITIAL_ACK; + peerstate->sendbuf[0] = '*'; + peerstate->sendbuf_end = 1; + peerstate->client = client; + client->data = peerstate; + + // Enqueue the write request to send the ack; when it's done, + // on_wrote_init_ack will be called. The peer state is passed to the write + // request via the data pointer; the write request does not own this peer + // state - it's owned by the client handle. + uv_buf_t writebuf = uv_buf_init(peerstate->sendbuf, peerstate->sendbuf_end); + uv_write_t* req = (uv_write_t*)xmalloc(sizeof(*req)); + req->data = peerstate; + if ((rc = uv_write(req, (uv_stream_t*)client, &writebuf, 1, + on_wrote_init_ack)) < 0) { + die("uv_write failed: %s", uv_strerror(rc)); + } + } else { + uv_close((uv_handle_t*)client, on_client_closed); + } +} +``` + +This code is well commented, but there are a couple of important libuv idioms I'd like to highlight: + +* Passing custom data into callbacks: since C has no closures, this can be challenging. libuv has a void* datafield in all its handle types; these fields can be used to pass user data. For example, note how client->data is made to point to a peer_state_t structure so that the callbacks registered by uv_write and uv_read_start can know which peer data they're dealing with. + +* Memory management: event-driven programming is much easier in languages with garbage collection, because callbacks usually run in a completely different stack frame from where they were registered, making stack-based memory management difficult. It's almost always necessary to pass heap-allocated data to libuv callbacks (except in main, which remains alive on the stack when all callbacks run), and to avoid leaks much care is required about when these data are safe to free(). This is something that comes with a bit of practice [[1]][6]. + +The peer state for this server is: + +``` +typedef struct { + ProcessingState state; + char sendbuf[SENDBUF_SIZE]; + int sendbuf_end; + uv_tcp_t* client; +} peer_state_t; +``` + +It's fairly similar to the state in part 3; we no longer need sendptr, since uv_write will make sure to send the whole buffer it's given before invoking the "done writing" callback. We also keep a pointer to the client for other callbacks to use. Here's on_wrote_init_ack: + +``` +void on_wrote_init_ack(uv_write_t* req, int status) { + if (status) { + die("Write error: %s\n", uv_strerror(status)); + } + peer_state_t* peerstate = (peer_state_t*)req->data; + // Flip the peer state to WAIT_FOR_MSG, and start listening for incoming data + // from this peer. + peerstate->state = WAIT_FOR_MSG; + peerstate->sendbuf_end = 0; + + int rc; + if ((rc = uv_read_start((uv_stream_t*)peerstate->client, on_alloc_buffer, + on_peer_read)) < 0) { + die("uv_read_start failed: %s", uv_strerror(rc)); + } + + // Note: the write request doesn't own the peer state, hence we only free the + // request itself, not the state. + free(req); +} +``` + +Then we know for sure that the initial '*' was sent to the peer, we start listening to incoming data from this peer by calling uv_read_start, which registers a callback (on_peer_read) that will be invoked by the event loop whenever new data is received on the socket from the client: + +``` +void on_peer_read(uv_stream_t* client, ssize_t nread, const uv_buf_t* buf) { + if (nread < 0) { + if (nread != uv_eof) { + fprintf(stderr, "read error: %s\n", uv_strerror(nread)); + } + uv_close((uv_handle_t*)client, on_client_closed); + } else if (nread == 0) { + // from the documentation of uv_read_cb: nread might be 0, which does not + // indicate an error or eof. this is equivalent to eagain or ewouldblock + // under read(2). + } else { + // nread > 0 + assert(buf->len >= nread); + + peer_state_t* peerstate = (peer_state_t*)client->data; + if (peerstate->state == initial_ack) { + // if the initial ack hasn't been sent for some reason, ignore whatever + // the client sends in. + free(buf->base); + return; + } + + // run the protocol state machine. + for (int i = 0; i < nread; ++i) { + switch (peerstate->state) { + case initial_ack: + assert(0 && "can't reach here"); + break; + case wait_for_msg: + if (buf->base[i] == '^') { + peerstate->state = in_msg; + } + break; + case in_msg: + if (buf->base[i] == '$') { + peerstate->state = wait_for_msg; + } else { + assert(peerstate->sendbuf_end < sendbuf_size); + peerstate->sendbuf[peerstate->sendbuf_end++] = buf->base[i] + 1; + } + break; + } + } + + if (peerstate->sendbuf_end > 0) { + // we have data to send. the write buffer will point to the buffer stored + // in the peer state for this client. + uv_buf_t writebuf = + uv_buf_init(peerstate->sendbuf, peerstate->sendbuf_end); + uv_write_t* writereq = (uv_write_t*)xmalloc(sizeof(*writereq)); + writereq->data = peerstate; + int rc; + if ((rc = uv_write(writereq, (uv_stream_t*)client, &writebuf, 1, + on_wrote_buf)) < 0) { + die("uv_write failed: %s", uv_strerror(rc)); + } + } + } + free(buf->base); +} +``` + +The runtime behavior of this server is very similar to the event-driven servers of part 3: all clients are handled concurrently in a single thread. Also similarly, a certain discipline has to be maintained in the server's code: the server's logic is implemented as an ensemble of callbacks, and long-running operations are a big no-no since they block the event loop. Let's explore this issue a bit further. + +### Long-running operations in event-driven loops + +The single-threaded nature of event-driven code makes it very susceptible to a common issue: long-running code blocks the entire loop. Consider this program: + +``` +void on_timer(uv_timer_t* timer) { + uint64_t timestamp = uv_hrtime(); + printf("on_timer [%" PRIu64 " ms]\n", (timestamp / 1000000) % 100000); + + // "Work" + if (random() % 5 == 0) { + printf("Sleeping...\n"); + sleep(3); + } +} + +int main(int argc, const char** argv) { + uv_timer_t timer; + uv_timer_init(uv_default_loop(), &timer); + uv_timer_start(&timer, on_timer, 0, 1000); + return uv_run(uv_default_loop(), UV_RUN_DEFAULT); +} +``` + +It runs a libuv event loop with a single registered callback: on_timer, which is invoked by the loop every second. The callback reports a timestamp, and once in a while simulates some long-running task by sleeping for 3 seconds. Here's a sample run: + +``` +$ ./uv-timer-sleep-demo +on_timer [4840 ms] +on_timer [5842 ms] +on_timer [6843 ms] +on_timer [7844 ms] +Sleeping... +on_timer [11845 ms] +on_timer [12846 ms] +Sleeping... +on_timer [16847 ms] +on_timer [17849 ms] +on_timer [18850 ms] +... +``` + +on_timer dutifully fires every second, until the random sleep hits in. At that point, on_timer is not invoked again until the sleep is over; in fact,  _no other callbacks_  will be invoked in this time frame. The sleep call blocks the current thread, which is the only thread involved and is also the thread the event loop uses. When this thread is blocked, the event loop is blocked. + +This example demonstrates why it's so important for callbacks to never block in event-driven calls, and applies equally to Node.js servers, client-side Javascript, most GUI programming frameworks, and many other asynchronous programming models. + +But sometimes running time-consuming tasks is unavoidable. Not all tasks have asynchronous APIs; for example, we may be dealing with some library that only has a synchronous API, or just have to perform a potentially long computation. How can we combine such code with event-driven programming? Threads to the rescue! + +### Threads for "converting" blocking calls into asynchronous calls + +A thread pool can be used to turn blocking calls into asynchronous calls, by running alongside the event loop and posting events onto it when tasks are completed. Here's how it works, for a given blocking function do_work(): + +1. Instead of directly calling do_work() in a callback, we package it into a "task" and ask the thread pool to execute the task. We also register a callback for the loop to invoke when the task has finished; let's call iton_work_done(). + +2. At this point our callback can return and the event loop keeps spinning; at the same time, a thread in the pool is executing the task. + +3. Once the task has finished executing, the main thread (the one running the event loop) is notified and on_work_done() is invoked by the event loop. + +Let's see how this solves our previous timer/sleep example, using libuv's work scheduling API: + +``` +void on_after_work(uv_work_t* req, int status) { + free(req); +} + +void on_work(uv_work_t* req) { + // "Work" + if (random() % 5 == 0) { + printf("Sleeping...\n"); + sleep(3); + } +} + +void on_timer(uv_timer_t* timer) { + uint64_t timestamp = uv_hrtime(); + printf("on_timer [%" PRIu64 " ms]\n", (timestamp / 1000000) % 100000); + + uv_work_t* work_req = (uv_work_t*)malloc(sizeof(*work_req)); + uv_queue_work(uv_default_loop(), work_req, on_work, on_after_work); +} + +int main(int argc, const char** argv) { + uv_timer_t timer; + uv_timer_init(uv_default_loop(), &timer); + uv_timer_start(&timer, on_timer, 0, 1000); + return uv_run(uv_default_loop(), UV_RUN_DEFAULT); +} +``` + +Instead of calling sleep directly in on_timer, we enqueue a task, represented by a handle of type work_req [[2]][14], the function to run in the task (on_work) and the function to invoke once the task is completed (on_after_work). on_workis where the "work" (the blocking/time-consuming operation) happens. Note a crucial difference between the two callbacks passed into uv_queue_work: on_work runs in the thread pool, while on_after_work runs on the main thread which also runs the event loop - just like any other callback. + +Let's see this version run: + +``` +$ ./uv-timer-work-demo +on_timer [89571 ms] +on_timer [90572 ms] +on_timer [91573 ms] +on_timer [92575 ms] +Sleeping... +on_timer [93576 ms] +on_timer [94577 ms] +Sleeping... +on_timer [95577 ms] +on_timer [96578 ms] +on_timer [97578 ms] +... +``` + +The timer ticks every second, even though the sleeping function is still invoked; sleeping is now done on a separate thread and doesn't block the event loop. + +### A primality-testing server, with exercises + +Since sleep isn't a very exciting way to simulate work, I've prepared a more comprehensive example - a server that accepts numbers from clients over a socket, checks whether these numbers are prime and sends back either "prime" or "composite". The full [code for this server is here][15] - I won't post it here since it's long, but will rather give readers the opportunity to explore it on their own with a couple of exercises. + +The server deliberatly uses a naive primality test algorithm, so for large primes it can take quite a while to return an answer. On my machine it takes ~5 seconds to compute the answer for 2305843009213693951, but YMMV. + +Exercise 1: the server has a setting (via an environment variable named MODE) to either run the primality test in the socket callback (meaning on the main thread) or in the libuv work queue. Play with this setting to observe the server's behavior when multiple clients are connecting simultaneously. In blocking mode, the server will not answer other clients while it's computing a big task; in non-blocking mode it will. + +Exercise 2: libuv has a default thread-pool size, and it can be configured via an environment variable. Can you use multiple clients to discover experimentally what the default size is? Having found the default thread-pool size, play with different settings to see how it affects the server's responsiveness under heavy load. + +### Non-blocking file-system operations using work queues + +Delegating potentially-blocking operations to a thread pool isn't good for just silly demos and CPU-intensive computations; libuv itself makes heavy use of this capability in its file-system APIs. This way, libuv accomplishes the superpower of exposing the file-system with an asynchronous API, in a portable way. + +Let's take uv_fs_read(), for example. This function reads from a file (represented by a uv_fs_t handle) into a buffer [[3]][16], and invokes a callback when the reading is completed. That is, uv_fs_read() always returns immediately, even if the file sits on an NFS-like system and it may take a while for the data to get to the buffer. In other words, this API is asynchronous in the way other libuv APIs are. How does this work? + +At this point we're going to look under the hood of libuv; the internals are actually fairly straightforward, and it's a good exercise. Being a portable library, libuv has different implementations of many of its functions for Windows and Unix systems. We're going to be looking at src/unix/fs.c in the libuv source tree. + +The code for uv_fs_read is: + +``` +int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, + uv_file file, + const uv_buf_t bufs[], + unsigned int nbufs, + int64_t off, + uv_fs_cb cb) { + if (bufs == NULL || nbufs == 0) + return -EINVAL; + + INIT(READ); + req->file = file; + + req->nbufs = nbufs; + req->bufs = req->bufsml; + if (nbufs > ARRAY_SIZE(req->bufsml)) + req->bufs = uv__malloc(nbufs * sizeof(*bufs)); + + if (req->bufs == NULL) { + if (cb != NULL) + uv__req_unregister(loop, req); + return -ENOMEM; + } + + memcpy(req->bufs, bufs, nbufs * sizeof(*bufs)); + + req->off = off; + POST; +} +``` + +It may seem puzzling at first, because it defers the real work to the INIT and POST macros, with some local variable setup for POST. This is done to avoid too much code duplication within the file. + +The INIT macro is: + +``` +#define INIT(subtype) \ + do { \ + req->type = UV_FS; \ + if (cb != NULL) \ + uv__req_init(loop, req, UV_FS); \ + req->fs_type = UV_FS_ ## subtype; \ + req->result = 0; \ + req->ptr = NULL; \ + req->loop = loop; \ + req->path = NULL; \ + req->new_path = NULL; \ + req->cb = cb; \ + } \ + while (0) +``` + +It sets up the request, and most importantly sets the req->fs_type field to the actual FS request type. Since uv_fs_read invokes INIT(READ), it means req->fs_type gets assigned the constant UV_FS_READ. + +The POST macro is: + +``` +#define POST \ + do { \ + if (cb != NULL) { \ + uv__work_submit(loop, &req->work_req, uv__fs_work, uv__fs_done); \ + return 0; \ + } \ + else { \ + uv__fs_work(&req->work_req); \ + return req->result; \ + } \ + } \ + while (0) +``` + +What it does depends on whether the callback is NULL. In libuv file-system APIs, a NULL callback means we actually want to perform the operation  _synchronously_ . In this case POST invokes uv__fs_work directly (we'll get to what this function does in just a bit), whereas for a non-NULL callback, it submits uv__fs_work as a work item to the work queue (which is the thread pool), and registers uv__fs_done as the callback; that function does a bit of book-keeping and invokes the user-provided callback. + +If we look at the code of uv__fs_work, we'll see it uses more macros to route work to the actual file-system call as needed. In our case, for UV_FS_READ the call will be made to uv__fs_read, which (at last!) does the reading using regular POSIX APIs. This function can be safely implemented in a  _blocking_  manner, since it's placed on a thread-pool when called through the asynchronous API. + +In Node.js, the fs.readFile function is mapped to uv_fs_read. Thus, reading files can be done in a non-blocking fashion even though the underlying file-system API is blocking. + +* * * + + +[[1]][1] To ensure that this server doesn't leak memory, I ran it under Valgrind with the leak checker enabled. Since servers are often designed to run forever, this was a bit challenging; to overcome this issue I've added a "kill switch" to the server - a special sequence received from a client makes it stop the event loop and exit. The code for this is in theon_wrote_buf handler. + + +[[2]][2] Here we don't use work_req for much; the primality testing server discussed next will show how it's used to pass context information into the callback. + + +[[3]][3] uv_fs_read() provides a generalized API similar to the preadv Linux system call: it takes multiple buffers which it fills in order, and supports an offset into the file. We can ignore these features for the sake of our discussion. + + +-------------------------------------------------------------------------------- + +via: https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ + +作者:[Eli Bendersky ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://eli.thegreenplace.net/ +[1]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id1 +[2]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id2 +[3]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id3 +[4]:https://eli.thegreenplace.net/tag/concurrency +[5]:https://eli.thegreenplace.net/tag/c-c +[6]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id4 +[7]:http://eli.thegreenplace.net/2017/concurrent-servers-part-1-introduction/ +[8]:http://eli.thegreenplace.net/2017/concurrent-servers-part-2-threads/ +[9]:http://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ +[10]:http://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ +[11]:http://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ +[12]:http://libuv.org/ +[13]:https://github.com/eliben/code-for-blog/blob/master/2017/async-socket-server/uv-server.c +[14]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id5 +[15]:https://github.com/eliben/code-for-blog/blob/master/2017/async-socket-server/uv-isprime-server.c +[16]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id6 +[17]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ From 7bee72d850bb42f37a08ebbe09082b563718b177 Mon Sep 17 00:00:00 2001 From: Yixun Xu Date: Thu, 30 Nov 2017 10:42:15 -0500 Subject: [PATCH 066/344] translation request --- .../tech/20171130 Search DuckDuckGo from the Command Line.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171130 Search DuckDuckGo from the Command Line.md b/sources/tech/20171130 Search DuckDuckGo from the Command Line.md index a54c292924..4ee4fecf37 100644 --- a/sources/tech/20171130 Search DuckDuckGo from the Command Line.md +++ b/sources/tech/20171130 Search DuckDuckGo from the Command Line.md @@ -1,3 +1,5 @@ +yixunx translating + # Search DuckDuckGo from the Command Line ![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/duckduckgo.png) From 76fb4130627f2bbade0d804a0ae2feca71948f6e Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 1 Dec 2017 00:38:20 +0800 Subject: [PATCH 067/344] =?UTF-8?q?20171201=2000=EF=BC=9A38?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 20171201 00:38 --- ...170530 How to Improve a Legacy Codebase.md | 41 ++++++++++++++----- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/sources/tech/20170530 How to Improve a Legacy Codebase.md b/sources/tech/20170530 How to Improve a Legacy Codebase.md index 7e2b257949..cc1bd073a9 100644 --- a/sources/tech/20170530 How to Improve a Legacy Codebase.md +++ b/sources/tech/20170530 How to Improve a Legacy Codebase.md @@ -18,65 +18,84 @@ I’ve been (un)fortunate enough to be in this situation several times and me an ### Backup ### 备份 -在你去做任何事情之前备份与之相关的所有东西。这样可以确保不会丢失任何信息,这些信息可能会在一些地方很重要, +在你去做任何操作之前备份与之相关的所有文件。这样可以确保不会丢失任何信息,这些信息可能会在另外一些地方很重要。一旦改变其中一些文件,你可能花费一天或者更多天都解决不了这个愚蠢的问题,配置数据通常不受版本控制,所以特别容易受到这方面影响,如果定期备份数据时连带着它一起备份了,还是比较幸运的。所以谨慎总比后悔好,复制所有东西到一个绝对安全的地方吧,而且不要轻易动他除非这些文件是只读模式。 Before you start to do anything at all make a backup of  _everything_  that might be relevant. This to make sure that no information is lost that might be of crucial importance somewhere down the line. All it takes is a silly question that you can’t answer to eat up a day or more once the change has been made. Especially configuration data is susceptible to this kind of problem, it is usually not versioned and you’re lucky if it is taken along in the periodic back-up scheme. So better safe than sorry, copy everything to a very safe place and never ever touch that unless it is in read-only mode. ### Important pre-requisite, make sure you have a build process and that it actually produces what runs in production +### 你必须确认他们能够在生产环境下构建运行并产出,这是重要的先决条件。 +这一步显而易见并且已经很到位的情况下我完全错过了这一步,Hacker News 的众多评论者就会指出并且证明他们是对的:第一步是马上确保你知道在生产环境下运行着什么东西,也意味着你需要去在你的设备上构建一个跟生产环境上运行的版本每一个字节都一模一样的版本。如果你找不到实现它的办法,一旦你将它投入生产环境是,你很可能会遭遇一些很糟糕的事情。确保每一部分都尽你最大能力去测试,之后在你足够信任他能够很好的运行的时候将他弄得生产环境下。无论他运行的怎么样都要做好能够马上切换回就版本的准备,并且记录所有情况下的日志,便于接下来不可避免的 “验尸” 。 I totally missed this step on the assumption that it is obvious and likely already in place but many HN commenters pointed this out and they are absolutely right: step one is to make sure that you know what is running in production right now and that means that you need to be able to build a version of the software that is - if your platform works that way - byte-for-byte identical with the current production build. If you can’t find a way to achieve this then likely you will be in for some unpleasant surprises once you commit something to production. Make sure you test this to the best of your ability to make sure that you have all the pieces in place and then, after you’ve gained sufficient confidence that it will work move it to production. Be prepared to switch back immediately to whatever was running before and make sure that you log everything and anything that might come in handy during the - inevitable - post mortem. ### Freeze the DB - +### 冻结数据库 +直到你改善了代码之前尽可能的冻结你的数据库,在你特别熟悉代码库和遗留代码的之后再去修改数据库。在这之前过早的修改数据库的话,你可能会碰到大问题,你会失去让新旧代码和数据库和数据库一起构建稳固的基础的能力。保持数据库完全不变能够比较新的逻辑代码和旧的逻辑代码造成的影响,如果都像通知的那样就没有什么影响了。 If at all possible freeze the database schema until you are done with the first level of improvements, by the time you have a solid understanding of the codebase and the legacy code has been fully left behind you are ready to modify the database schema. Change it any earlier than that and you may have a real problem on your hand, now you’ve lost the ability to run an old and a new codebase side-by-side with the database as the steady foundation to build on. Keeping the DB totally unchanged allows you to compare the effect your new business logic code has compared to the old business logic code, if it all works as advertised there should be no differences. ### Write your tests - +### 写测试 +在你做任何改变之前,尽可能多的写下端到端测试和集成测试。确保这些测试能够正确的输出并且是在你能够清晰的知道旧的是如何工作的假设之下(准备好应对一些突发状况)。这些测试有两个重要的作用,他们能够在较早的阶段帮助你抛弃一些错误观念,在你写新代码替换旧代码的时候也有一定防护作用。 Before you make any changes at all write as many end-to-end and integration tests as you can. Make sure these tests produce the right output and test any and all assumptions that you can come up with about how you  _think_  the old stuff works (be prepared for surprises here). These tests will have two important functions: they will help to clear up any misconceptions at a very early stage and they will function as guardrails once you start writing new code to replace old code. +自动化测试,如果你也有 CI 的使用经验,请使用它并且确保在你提交代码之后能够快速的完成所有测试。 Automate all your testing, if you’re already experienced with CI then use it and make sure your tests run fast enough to run the full set of tests after every commit. ### Instrumentation and logging - +### 日志监控 +如果线上的旧设备需要添加上监控功能。用一个完全新的数据库,为每一个你能想到事件都添加一个简单的计数器,并且根据这些事件的名字添加一个函数增加这些计数器。用一些额外的代码实现一个时间戳事件日志,这是一个好办法知道有多少事件导致了另外一些种类的事件。例如:用户打开 APP ,用户关闭 APP 。如果这两个事件导致后端调用的数量维持长时间的不同,这个数量差就是当前打开的 APP 的数量。如果你看到打开 APP 的比关闭的多的时候,你知道哪些 APP 是关闭的必须的方法(例如崩溃)。每一个事件你会发现有许多不同种类的联系跟其他的一些事件,通常你争取维持这些固定的关系,除非有一个明显的错误在系统上。你的目标是降低那些错误的事件,最大化哪些计数器在向下到初始化的水平在链条中。(例如:用户试着支付应该得到相同数量的跟支付回调)。 If the old platform is still available for development add instrumentation. Do this in a completely new database table, add a simple counter for every event that you can think of and add a single function to increment these counters based on the name of the event. That way you can implement a time-stamped event log with a few extra lines of code and you’ll get a good idea of how many events of one kind lead to events of another kind. One example: User opens app, User closes app. If two events should result in some back-end calls those two counters should over the long term remain at a constant difference, the difference is the number of apps currently open. If you see many more app opens than app closes you know there has to be a way in which apps end (for instance a crash). For each and every event you’ll find there is some kind of relationship to other events, usually you will strive for constant relationships unless there is an obvious error somewhere in the system. You’ll aim to reduce those counters that indicate errors and you’ll aim to maximize counters further down in the chain to the level indicated by the counters at the beginning. (For instance: customers attempting to pay should result in an equal number of actual payments received). +这是非常简单的点子去翻转每一个后端应用到一个就像真实的薄书系统一样 This very simple trick turns every backend application into a bookkeeping system of sorts and just like with a real bookkeeping system the numbers have to match, as long as they don’t you have a problem somewhere. +在构建一个健康的系统的时候,这个系统是很珍贵的,而且它也是一个好伙伴,仅次于使用源码控制修改系统日志,你可以确认 BUG 出现的位置,以及对多种计数器造成的影响。 This system will over time become invaluable in establishing the health of the system and will be a great companion next to the source code control system revision log where you can determine the point in time that a bug was introduced and what the effect was on the various counters. +我通常保持技术差 5 分钟一次(一小时 12 次),如果你的应用生成了更多或者更少的事件,你应该改变这个时间间隔。所有的计数器公用一个数据表,每一个记录都只是简单的一行。 I usually keep these counters at a 5 minute resolution (so 12 buckets for an hour), but if you have an application that generates fewer or more events then you might decide to change the interval at which new buckets are created. All counters share the same database table and so each counter is simply a column in that table. ### Change only one thing at the time +### 一次只修改一处 +不要完全陷入一个陷阱,在提高代码或者平台可用性的同时添加新特性或者是修复 BUG。这会让你头大,现在必须问问你自己每一步操作想要每一步的什么结果并且将会使你早前建立的测试失效。 Do not fall into the trap of improving both the maintainability of the code or the platform it runs on at the same time as adding new features or fixing bugs. This will cause you huge headaches because you now have to ask yourself every step of the way what the desired outcome is of an action and will invalidate some of the tests you made earlier. ### Platform changes - +###改变平台 +如果你决定转移你的应用到另外一个平台,最主要的是跟之前保持一样。如果你觉得你会添加更多的文档和测试,但是不会比那更多,所有的业务逻辑和相互依赖跟从前一样保持不变。 If you’ve decided to migrate the application to another platform then do this first  _but keep everything else exactly the same_ . If you want you can add more documentation or tests, but no more than that, all business logic and interdependencies should remain as before. ### Architecture changes - +###改变架构 +接下来处理的是改变应用的结构(如果需要)。这一点上,你可以自由的去改变代码为更高级的,通常是降低模块间的横向联系,这样可以降低代码活动期间对终端用户造成的影响范围。如果老代码是庞大的,那么现在正是时候让他模块化,大段代码分解成众多小的,不过不要把变量的名字和他的数据结构分开。 The next thing to tackle is to change the architecture of the application (if desired). At this point in time you are free to change the higher level structure of the code, usually by reducing the number of horizontal links between modules, and thus reducing the scope of the code active during any one interaction with the end-user. If the old code was monolithic in nature now would be a good time to make it more modular, break up large functions into smaller ones but leave names of variables and data-structures as they were. - +Hacker News [mannykannot][1] 指出,理所应当的,这一步不总是有必要的,如果你特别不幸的话,你可能为了改变一些架构必须付出沉重的代价。我也赞同这个,我应该加上这个,因此这里有一些更新。我非常想添加的是如果你修改高级代码的时候修改了一点点底层代码试着限制只修改一个文件或者一个不恰当的例子一个子系统,所以你尽可能的限制了修改的范围。其他方面你可能有个困难时期去排查你所做的修改。 HN user [mannykannot][1] points - rightfully - out that this is not always an option, if you’re particularly unlucky then you may have to dig in deep in order to be able to make any architecture changes. I agree with that and I should have included it here so hence this little update. What I would further like to add is if you do both do high level changes and low level changes at least try to limit them to one file or worst case one subsystem so that you limit the scope of your changes as much as possible. Otherwise you might have a very hard time debugging the change you just made. ### Low level refactoring - +### 底层代码的重构 +现在,你应该非常理解每一个模块的作用,准备做一些真正的工作吧:重构代码去提高可维护性和让代码准备添加新功能。这将很可能是项目的一部分消耗大部分时间,记录你做的,不要对模块做改变直到你彻底的记录他并且感觉理解了他。很自由的修改变量名和函数名以及数据结构去提高清晰度和统一性,添加测试(情况需要的话,包括单元测试)。 By now you should have a very good understanding of what each module does and you are ready for the real work: refactoring the code to improve maintainability and to make the code ready for new functionality. This will likely be the part of the project that consumes the most time, document as you go, do not make changes to a module until you have thoroughly documented it and feel you understand it. Feel free to rename variables and functions as well as datastructures to improve clarity and consistency, add tests (also unit tests, if the situation warrants them). ### Fix bugs - +### 修改bugs +现在你准备承担真实用户看到的改变,战斗的第一步将是积累了一整年很多的bugs,像往常一样,第一步证实问题仍然存在,对这个结果做个测试然后修复这个bug,你的 CI 和写的端对端测试应该让你安全在你犯了错误由于不太熟悉或者一些额外的事情。 Now you’re ready to take on actual end-user visible changes, the first order of battle will be the long list of bugs that have accumulated over the years in the ticket queue. As usual, first confirm the problem still exists, write a test to that effect and then fix the bug, your CI and the end-to-end tests written should keep you safe from any mistakes you make due to a lack of understanding or some peripheral issue. ### Database Upgrade - +### 升级数据库 +如果在前面的都所谓之后你需要固定和可维护的数据库再一次你有一个选项去改变数据库或者替换数据库用一个不同的完整的,如果这是你打算做的,做到了所有的这些将能够帮助你通过可靠的方式做修改而不会碰到问题,你会完整的测试新数据库和新代码,所有测试可以确保你顺利的迁移。 If required after all this is done and you are on a solid and maintainable codebase again you have the option to change the database schema or to replace the database with a different make/model altogether if that is what you had planned to do. All the work you’ve done up to this point will help to assist you in making that change in a responsible manner without any surprises, you can completely test the new DB with the new code and all the tests in place to make sure your migration goes off without a hitch. ### Execute on the roadmap - +### 按着路线图执行 +祝贺你脱离的困境并且可以准备添加新功能了。 Congratulations, you are out of the woods and are now ready to implement new functionality. ### Do not ever even attempt a big-bang rewrite +### 任何时候都不要企图推翻重写 +推翻重写是那种注定会失败的项目,之一,你是 A big-bang rewrite is the kind of project that is pretty much guaranteed to fail. For one, you are in uncharted territory to begin with so how would you even know what to build, for another, you are pushing  _all_  the problems to the very last day, the day just before you go ‘live’ with your new system. And that’s when you’ll fail, miserably. Business logic assumptions will turn out to be faulty, suddenly you’ll gain insight into why that old system did certain things the way it did and in general you’ll end up realizing that the guys that put the old system together weren’t maybe idiots after all. If you really do want to wreck the company (and your own reputation to boot) by all means, do a big-bang rewrite, but if you’re smart about it this is not even on the table as an option. ### So, the alternative, work incrementally From e6fa1e146e58e7bb5f8d42b6ceb85d4ca6d6e207 Mon Sep 17 00:00:00 2001 From: Yixun Xu Date: Thu, 30 Nov 2017 16:42:14 -0500 Subject: [PATCH 068/344] Translated: Search DuckDuckGo from the Command Line --- ...Search DuckDuckGo from the Command Line.md | 60 ++++++++++--------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/sources/tech/20171130 Search DuckDuckGo from the Command Line.md b/sources/tech/20171130 Search DuckDuckGo from the Command Line.md index 4ee4fecf37..259a8d7248 100644 --- a/sources/tech/20171130 Search DuckDuckGo from the Command Line.md +++ b/sources/tech/20171130 Search DuckDuckGo from the Command Line.md @@ -1,45 +1,48 @@ yixunx translating -# Search DuckDuckGo from the Command Line - +# 在命令行中使用DuckDuckGo搜索 ![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/duckduckgo.png) -When we showed you how to [search Google from the command line][3] a lot of you to say you use [Duck Duck Go][4], the awesome privacy-focused search engine. -Well, now there’s a tool to search DuckDuckGo from the command line. It’s called [ddgr][6] (pronounced, in my head, as  _dodger_ ) and it’s pretty neat. +此前我们介绍了[如何在命令行中使用 Google 搜索][3]。许多读者反馈说他们平时使用 [Duck Duck Go][4],一个功能强大而且保密性很强的搜索引擎。 -Like [Googler][7], ddgr is totally open-source and totally unofficial. Yup, the app is unaffiliated with DuckDuckGo in any way. So, should it start returning unsavoury search results for innocent terms, make sure you quack in this dev’s direction, and not the search engine’s! +正巧,最近出现了一款能够从命令行搜索 DuckDuckGo 的工具。它叫做 ddgr(我把它读作 _dodger_),非常好用。 -### DuckDuckGo Terminal App +像 [Googler][7] 一样,ddgr 是一个完全开源而且非官方的工具。没错,它并不属于 DuckDuckGo。所以,如果你发现它返回的结果有些奇怪,请先询问这个工具的开发者,而不是搜索引擎的开发者。 + +### DuckDuckGo 命令行应用 ![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/ddgr-gif.gif) -[DuckDuckGo Bangs][8] makes finding stuff on DuckDuckGo super easy (there’s even a bang for  _this_  site) and, dutifully, ddgr supports them. +[DuckDuckGo Bangs(DuckDuckGo 快捷搜索)][8] 可以帮助你轻易地在 DuckDuckGo 上找到想要的信息(甚至 _本网站_ 都有快捷搜索)。ddgr 非常忠实地呈现了这个功能。 -Unlike the web interface, you can specify the number of search results you would like to see per page. It’s more convenient than skimming through 30-odd search results per page. The default interface is carefully designed to use minimum space without sacrificing readability. +和网页版不同的是,你可以更改每页返回多少结果。这比起比起每次查询都要看三十多条结果要方便一些。默认界面经过了精心设计,在不影响可读性的情况下尽量减少了占用空间。 -`ddgr` has a number of features, including: +`ddgr` 有许多功能和亮点,包括: -* Choose number of search results to fetch +* 更改搜索结果数 -* Support for Bash autocomplete +* 支持 Bash 自动补全 -* Use !bangs +* 使用 DuckDuckGo Bangs -* Open URLs in a browser +* 在浏览器中打开链接 -* “I’m feeling lucky” option +* ”手气不错“选项 -* Filter by time, region, file type, etc +* 基于时间、地区、文件类型等的筛选功能 -* Minimal dependencies +* 极少的依赖项 -You can download `ddgr` for various systems direct from the Github project page: -[Download ‘ddgr’ from Github][9] +你可以从 Github 的项目页面上下载支持各种系统的 `ddgr`: -You can also install ddgr on Ubuntu 16.04 LTS and up from a PPA. This repo is maintained by the developer of ddgr and is recommended should you want to stay up-to-date with new releases as and when they appear. +[从 Github 下载 “ddgr”][9] -Do note that at the time of writing the latest version of ddgr is  _not_  in the PPA, but an older version (lacking –num support) is: +另外,在 Ubuntu 16.04 LTS 或更新版本中,你可以使用 PPA 安装 ddgr。这个仓库由 ddgr 的开发者维护。如果你想要保持在最新版本的话,推荐使用这种方式安装。 + +需要提醒的是,在本文创作时,这个 PPA 中的 ddgr _并不是_ 最新版本,而是一个稍旧的版本(缺少 -num 选项)。 + +使用以下命令添加 PPA: ``` sudo add-apt-repository ppa:twodopeshaggy/jarun @@ -49,33 +52,34 @@ sudo add-apt-repository ppa:twodopeshaggy/jarun sudo apt-get update ``` -### How To Use ddgr to Search DuckDuckGo from the Comand Line +### 如何使用 ddgr 在命令行中搜索 DuckDuckGo -To use ddgr once you installed all you need to do is pop open your terminal emulator of choice and run: +安装完毕后,你只需打开你的终端模拟器,并运行: ``` ddgr ``` -Next enter a search term: +然后输入查询内容: ``` search-term ``` -To limit the number of results returned run: +你可以限制搜索结果数: ``` ddgr --num 5 search-term ``` -To instantly open the first matching result for a search term in your browser run: +或者自动在浏览器中打开第一条搜索结果: + ``` ddgr -j search-term ``` -You can pass arguments and flags to narrow down your search. To see a comprehensive list inside the terminal run: +你可以使用参数和选项来提高搜索精确度。使用以下命令来查看所有的参数: ``` ddgr -h @@ -85,8 +89,8 @@ ddgr -h via: http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app -作者:[JOEY SNEDDON ][a] -译者:[译者ID](https://github.com/译者ID) +作者:[JOEY SNEDDON][a] +译者:[yixunx](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 9a601d06963fbabdac4f21d56945081da2ed1209 Mon Sep 17 00:00:00 2001 From: Yixun Xu Date: Thu, 30 Nov 2017 16:43:08 -0500 Subject: [PATCH 069/344] move to translated --- .../tech/20171130 Search DuckDuckGo from the Command Line.md | 2 -- 1 file changed, 2 deletions(-) rename {sources => translated}/tech/20171130 Search DuckDuckGo from the Command Line.md (99%) diff --git a/sources/tech/20171130 Search DuckDuckGo from the Command Line.md b/translated/tech/20171130 Search DuckDuckGo from the Command Line.md similarity index 99% rename from sources/tech/20171130 Search DuckDuckGo from the Command Line.md rename to translated/tech/20171130 Search DuckDuckGo from the Command Line.md index 259a8d7248..e4c47b691b 100644 --- a/sources/tech/20171130 Search DuckDuckGo from the Command Line.md +++ b/translated/tech/20171130 Search DuckDuckGo from the Command Line.md @@ -1,5 +1,3 @@ -yixunx translating - # 在命令行中使用DuckDuckGo搜索 ![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/duckduckgo.png) From 594e7865a7022ccca2b62302de7ac29f984f973f Mon Sep 17 00:00:00 2001 From: Yixun Xu Date: Thu, 30 Nov 2017 16:45:01 -0500 Subject: [PATCH 070/344] fix github link --- .../tech/20171130 Search DuckDuckGo from the Command Line.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20171130 Search DuckDuckGo from the Command Line.md b/translated/tech/20171130 Search DuckDuckGo from the Command Line.md index e4c47b691b..9bf96ecb88 100644 --- a/translated/tech/20171130 Search DuckDuckGo from the Command Line.md +++ b/translated/tech/20171130 Search DuckDuckGo from the Command Line.md @@ -88,7 +88,7 @@ ddgr -h via: http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app 作者:[JOEY SNEDDON][a] -译者:[yixunx](https://github.com/译者ID) +译者:[yixunx](https://github.com/yixunx) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 2ba1eeda720207e3cbda7afc35eb98b5c508d9c2 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 30 Nov 2017 21:51:35 +0800 Subject: [PATCH 071/344] PRF:20161216 Kprobes Event Tracing on ARMv8.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @kimii 翻译的很好,这篇很专业。 --- ...20161216 Kprobes Event Tracing on ARMv8.md | 142 +++++++++--------- 1 file changed, 68 insertions(+), 74 deletions(-) diff --git a/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md b/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md index d4edaf76bd..3c3ab0de5b 100644 --- a/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md +++ b/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md @@ -1,86 +1,82 @@ -# Kprobes Event Tracing on ARMv8 +ARMv8 上的 kprobes 事件跟踪 +============== ![core-dump](http://www.linaro.org/wp-content/uploads/2016/02/core-dump.png) ### 介绍 -Kprobes 是一种内核功能,它允许通过在执行(或模拟)断点指令之前和之后,设置调用开发者提供例程的任意断点来检测内核。可参见 kprobes 文档[[1]][2] 获取更多信息。基本的 kprobes 功能可使用 CONFIG_KPROBEES 来选择。在 arm64 的 v4.8 发行版中, kprobes 支持被添加到主线。 +kprobes 是一种内核功能,它允许通过在执行(或模拟)断点指令之前和之后,设置调用开发者提供例程的任意断点来检测内核。可参见 kprobes 文档^注1 获取更多信息。基本的 kprobes 功能可使用 `CONFIG_KPROBEES` 来选择。在 arm64 的 v4.8 内核发行版中, kprobes 支持被添加到主线。 -在这篇文章中,我们将介绍 kprobes 在 arm64 上的使用,通过在命令行中使用 debugfs 事件追踪接口来收集动态追踪事件。这个功能在一些架构(包括 arm32)上可用已经有段时间,现在在 arm64 上也能使用了。这个功能允许使用 kprobes 而无需编写任何代码。 +在这篇文章中,我们将介绍 kprobes 在 arm64 上的使用,通过在命令行中使用 debugfs 事件追踪接口来收集动态追踪事件。这个功能在一些架构(包括 arm32)上可用已经有段时间,现在在 arm64 上也能使用了。这个功能可以无需编写任何代码就能使用 kprobes。 ### 探针类型 -Kprbes 子系统提供了三种不同类型的动态探针,如下所述。 +kprobes 子系统提供了三种不同类型的动态探针,如下所述。 -### Kprobes +#### kprobes -基本探针是 kprobes 插入的一个软件断点,用以替代你正在探测的指令,当探测点被击中时,它为最终的单步执行(或模拟)保存下原始指令。 +基本探针是 kprobes 插入的一个软件断点,用以替代你正在探测的指令,当探测点被命中时,它为最终的单步执行(或模拟)保存下原始指令。 -### Kretprobes +#### kretprobes -Kretprobes 是 kprobes 的一部分,它允许拦截返回函数,而不必在返回点设置一个探针(或者可能有多个)。对于支持的架构(包括 ARMv8),只要选择 kprobes,就可以选择此功能。 +kretprobes 是 kprobes 的一部分,它允许拦截返回函数,而不必在返回点设置一个探针(或者可能有多个探针)。对于支持的架构(包括 ARMv8),只要选择 kprobes,就可以选择此功能。 -### Jprobes +#### jprobes -Jprobes 允许通过提供一个具有相同调用签名(call signature)的中间函数来拦截对一个函数的调用,这里中间函数将被首先调用。Jprobes 只是一个编程接口,它不能通过 debugfs 事件追踪子系统来使用。因此,我们将不会在这里进一步讨论 jprobes。如果你想使用 jprobes,请参考 kprobes 文档。 +jprobes 允许通过提供一个具有相同调用签名call signature的中间函数来拦截对一个函数的调用,这里中间函数将被首先调用。jprobes 只是一个编程接口,它不能通过 debugfs 事件追踪子系统来使用。因此,我们将不会在这里进一步讨论 jprobes。如果你想使用 jprobes,请参考 kprobes 文档。 -### 调用 Kprobes +### 调用 kprobes -Kprobes 提供一系列能从内核代码中调用的 API 来设置探测点和当探测点被击中时调用的注册函数。在不往内核中添加代码的情况下,Kprobes 也是可用的,这是通过写入特定事件追踪的 debugfs 文件来实现的,需要在文件中设置探针地址和信息,以便在探针被击中时记录到追踪日志中。后者是本文将要讨论的重点。最后 Kprobes 可以通过 perl 命令来使用。 +kprobes 提供一系列能从内核代码中调用的 API 来设置探测点和当探测点被命中时调用的注册函数。在不往内核中添加代码的情况下,kprobes 也是可用的,这是通过写入特定事件追踪的 debugfs 文件来实现的,需要在文件中设置探针地址和信息,以便在探针被命中时记录到追踪日志中。后者是本文将要讨论的重点。最后 kprobes 可以通过 perl 命令来使用。 -### Kprobes API +### kprobes API 内核开发人员可以在内核中编写函数(通常在专用的调试模块中完成)来设置探测点,并且在探测指令执行前和执行后立即执行任何所需操作。这在 kprobes.txt 中有很好的解释。 ### 事件追踪 -事件追踪子系统有自己的自己的文档[[2]][3],对于了解一般追踪事件的背景可能值得一读。事件追踪子系统是追踪点(tracepoints)和 kprobes 事件追踪的基础。事件追踪文档重点关注追踪点,所以请在查阅文档时记住这一点。Kprobes 与追踪点不同的是没有预定义的追踪点列表,而是采用动态创建的用于触发追踪事件信息收集的任意探测点。事件追踪子系统通过一系列 debugfs 文件来控制和监视。事件追踪(CONFIG_EVENT_TRACING)将在被如 kprobe 事件追踪子系统等需要时自动选择。 +事件追踪子系统有自己的自己的文档^注2 ,对于了解一般追踪事件的背景可能值得一读。事件追踪子系统是追踪点tracepoints和 kprobes 事件追踪的基础。事件追踪文档重点关注追踪点,所以请在查阅文档时记住这一点。kprobes 与追踪点不同的是没有预定义的追踪点列表,而是采用动态创建的用于触发追踪事件信息收集的任意探测点。事件追踪子系统通过一系列 debugfs 文件来控制和监视。事件追踪(`CONFIG_EVENT_TRACING`)将在被如 kprobe 事件追踪子系统等需要时自动选择。 -#### Kprobes 事件 +#### kprobes 事件 -使用 kprobes 事件追踪子系统,用户可以在内核任意断点处指定要报告的信息,只需要指定任意现有可探测指令的地址以及格式化信息即可确定。在执行过程中遇到断点时,kprobes 将所请求的信息传递给事件追踪子系统的公共部分,这些部分将数据格式化并追加到追踪日志中,就像追踪点的工作方式一样。Kprobes 使用一个类似的但是大部分是独立的 debugfs 文件来控制和显示追踪事件信息。该功能可使用 CONFIG_KPROBE_EVENT 来选择。Kprobetrace文档[[3]][4] 提供了如何使用 kprobes 事件追踪的基本信息,并且应当被参考用以了解以下介绍示例的详细信息。 +使用 kprobes 事件追踪子系统,用户可以在内核任意断点处指定要报告的信息,只需要指定任意现有可探测指令的地址以及格式化信息即可确定。在执行过程中遇到断点时,kprobes 将所请求的信息传递给事件追踪子系统的公共部分,这些部分将数据格式化并追加到追踪日志中,就像追踪点的工作方式一样。kprobes 使用一个类似的但是大部分是独立的 debugfs 文件来控制和显示追踪事件信息。该功能可使用 `CONFIG_KPROBE_EVENT` 来选择。Kprobetrace 文档^ 注3 提供了如何使用 kprobes 事件追踪的基本信息,并且应当被参考用以了解以下介绍示例的详细信息。 -### Kprobes 和 Perf +### kprobes 和 perf -Perf 工具为 Kprobes 提供了另一个命令行接口。特别地,“perf probe” 允许探测点除了由函数名加偏移量和地址指定外,还可由源文件和行号指定。Perf 接口实际上是使用 kprobes 的 debugfs 接口的封装器。 +perf 工具为 kprobes 提供了另一个命令行接口。特别地,`perf probe` 允许探测点除了由函数名加偏移量和地址指定外,还可由源文件和行号指定。perf 接口实际上是使用 kprobes 的 debugfs 接口的封装器。 -### Arm64 Kprobes +### Arm64 kprobes 上述所有 kprobes 的方面现在都在 arm64 上得到实现,然而实际上与其它架构上的有一些不同: * 注册名称参数当然是依架构而特定的,并且可以在 ARM ARM 中找到。 - -* 目前不是所有的指令类型都可被探测。当前不可探测的指令包括 mrs/msr(除了 DAIF 读),异常生成指令,eret 和 hint(除了 nop 变体)。在这些情况下,只探测一个附近的指令来代替是最简单的。这些指令在探测的黑名单里是因为在 kprobes 单步执行或者指令模拟时它们对处理器状态造成的改变是不安全的,这是由于 kprobes 构造的单步执行上下文和指令所需要的不一致,或者是由于指令不能容忍在 kprobes 中额外的处理时间和异常处理(ldx/stx)。 - +* 目前不是所有的指令类型都可被探测。当前不可探测的指令包括 mrs/msr(除了 DAIF 读取)、异常生成指令、eret 和 hint(除了 nop 变体)。在这些情况下,只探测一个附近的指令来代替是最简单的。这些指令在探测的黑名单里是因为在 kprobes 单步执行或者指令模拟时它们对处理器状态造成的改变是不安全的,这是由于 kprobes 构造的单步执行上下文和指令所需要的不一致,或者是由于指令不能容忍在 kprobes 中额外的处理时间和异常处理(ldx/stx)。 * 试图识别在 ldx/stx 序列中的指令并且防止探测,但是理论上这种检查可能会失败,导致允许探测到的原子序列永远不会成功。当探测原子代码序列附近时应该小心。 - * 注意由于 linux ARM64 调用约定的具体信息,为探测函数可靠地复制栈帧是不可能的,基于此不要试图用 jprobes 这样做,这一点与支持 jprobes 的大多数其它架构不同。这样的原因是被调用者没有足够的信息来确定需要的栈数量。 - -* 注意当探针被击中时,一个探针记录的栈指针信息将反映出使用中的特定栈指针,它是内核栈指针或者中断栈指针。 - +* 注意当探针被命中时,一个探针记录的栈指针信息将反映出使用中的特定栈指针,它是内核栈指针或者中断栈指针。 * 有一组内核函数是不能被探测的,通常因为它们作为 kprobes 处理的一部分被调用。这组函数的一部分是依架构特定的,并且也包含如异常入口代码等。 -### 使用 Kprobes 事件追踪 +### 使用 kprobes 事件追踪 -Kprobes 一个常用的例子是检测函数入口和/或出口。因为只需要使用函数名来作为探针地址,它安装探针特别简单。Kprobes 事件追踪将查看符号名称并且确定地址。ARMv8 调用标准定义了函数参数和返回值的位置,并且这些可以作为 kprobes 事件处理的一部分被打印出来。 +kprobes 的一个常用例子是检测函数入口和/或出口。因为只需要使用函数名来作为探针地址,它安装探针特别简单。kprobes 事件追踪将查看符号名称并且确定地址。ARMv8 调用标准定义了函数参数和返回值的位置,并且这些可以作为 kprobes 事件处理的一部分被打印出来。 ### 例子: 函数入口探测 检测 USB 以太网驱动程序复位功能: ``` -_$ pwd +$ pwd /sys/kernel/debug/tracing $ cat > kprobe_events < events/kprobes/enable_ +$ echo 1 > events/kprobes/enable ``` -此时每次驱动器的 *ax8872_reset()* 函数被调用,追踪事件都将会被记录。这个事件将显示指向通过 作为此函数的唯一参数的 X0(按照 ARMv8 调用标准)传入的 _usbnet_ 结构的指针。插入需要以太网驱动程序的USB加密狗后,我们看见以下追踪信息: +此时每次该驱动的 `ax8872_reset()` 函数被调用,追踪事件都将会被记录。这个事件将显示指向通过作为此函数的唯一参数的 `X0`(按照 ARMv8 调用标准)传入的 `usbnet` 结构的指针。插入需要以太网驱动程序的 USB 加密狗后,我们看见以下追踪信息: ``` -_$ cat trace +$ cat trace # tracer: nop # # entries-in-buffer/entries-written: 1/1 #P:8 @@ -93,27 +89,27 @@ _$ cat trace # TASK-PID CPU# |||| TIMESTAMP FUNCTION # | | | |||| | | kworker/0:0-4 [000] d… 10972.102939: p_ax88772_reset_0: -(ax88772_reset+0x0/0x230) arg1=0xffff800064824c80_ +(ax88772_reset+0x0/0x230) arg1=0xffff800064824c80 ``` -这里我们可以看见传入到我们的探测函数的指针参数的值。由于我们没有使用 kprobes 事件追踪的可选标签功能,我们需要的信息自动被标注为 _arg1_。注意这个指向我们需要 kprobes 记录这个探针的一组值的第一个,而不是函数参数的实际位置。在这个例子中它也只是碰巧是我们探测函数的第一个参数。 +这里我们可以看见传入到我们的探测函数的指针参数的值。由于我们没有使用 kprobes 事件追踪的可选标签功能,我们需要的信息自动被标注为 `arg1`。注意这指向我们需要 kprobes 记录这个探针的一组值的第一个,而不是函数参数的实际位置。在这个例子中它也只是碰巧是我们探测函数的第一个参数。 ### 例子: 函数入口和返回探测 -Kretprobe 功能专门用于探测函数返回。在函数入口 kprobes 子系统将会被调用并且建立钩子以便在函数返回时调用,钩子将记录需求事件信息。对最常见情况,返回信息通常在 X0 寄存器中,这是非常有用的。在 %x0 中返回值也可以被称为 _$retval_。以下例子也演示了如何提供一个可读的标签来展示有趣的信息。 +kretprobe 功能专门用于探测函数返回。在函数入口 kprobes 子系统将会被调用并且建立钩子以便在函数返回时调用,钩子将记录需求事件信息。对最常见情况,返回信息通常在 `X0` 寄存器中,这是非常有用的。在 `%x0` 中返回值也可以被称为 `$retval`。以下例子也演示了如何提供一个可读的标签来展示有趣的信息。 -使用 kprobes 和 kretprobe 检测内核 *_do_fork()* 函数来记录参数和结果的例子: +使用 kprobes 和 kretprobe 检测内核 `do_fork()` 函数来记录参数和结果的例子: ``` -_$ cd /sys/kernel/debug/tracing +$ cd /sys/kernel/debug/tracing $ cat > kprobe_events < events/kprobes/enable_ +$ echo 1 > events/kprobes/enable ``` -此时每次对 _do_fork() 的调用都会产生两个记录到 “_trace_” 文件的 kprobe 事件,一个报告调用参数值,另一个报告返回值。返回值在 trace 文件中将被标记为“_pid_”。这里是三次 fork 系统调用执行后的 trace 文件的内容: +此时每次对 `_do_fork()` 的调用都会产生两个记录到 trace 文件的 kprobe 事件,一个报告调用参数值,另一个报告返回值。返回值在 trace 文件中将被标记为 `pid`。这里是三次 fork 系统调用执行后的 trace 文件的内容: ``` _$ cat trace @@ -143,23 +139,23 @@ _$ cat trace 检测 `_do_wait()` 函数: ``` -_$ cat > kprobe_events < kprobe_events < events/kprobes/enable_ +$ echo 1 > events/kprobes/enable ``` -注意在第一个探针中使用的参数标签是可选的,并且可用于更清晰地识别记录在追踪日志中的信息。带符号的偏移量和括号表明了寄存器参数是指向记录在追踪日志中的内存内容的指针。“_:u32_”表明了内存位置包含一个无符号的4字节宽的数据(在这个例子中指局部定义的结构中的一个 emum 和一个 int) +注意在第一个探针中使用的参数标签是可选的,并且可用于更清晰地识别记录在追踪日志中的信息。带符号的偏移量和括号表明了寄存器参数是指向记录在追踪日志中的内存内容的指针。`:u32` 表明了内存位置包含一个无符号的 4 字节宽的数据(在这个例子中指局部定义的结构中的一个 emum 和一个 int)。 探针标签(冒号后)是可选的,并且将用来识别日志中的探针。对每个探针来说标签必须是独一无二的。如果没有指定,将从附近的符号名称自动生成一个有用的标签,如前面的例子所示。 -也要注意“_$retval_”参数可以只是指定为“_%x0_”。 +也要注意 `$retval` 参数可以只是指定为 `%x0`。 -这里是两次 fork 系统调用执行后的 “_trace_” 文件的内容: +这里是两次 fork 系统调用执行后的 trace 文件的内容: ``` -_$ cat trace +$ cat trace # tracer: nop # # entries-in-buffer/entries-written: 4/4 #P:8 @@ -174,23 +170,23 @@ _$ cat trace bash-1702 [001] d… 175.342074: wait_p: (do_wait+0x0/0x260) wo_type=0x3 wo_flags=0xe bash-1702 [002] d..1 175.347236: wait_r: (SyS_wait4+0x74/0xe4 <- do_wait) arg1=0x757 bash-1702 [002] d… 175.347337: wait_p: (do_wait+0x0/0x260) wo_type=0x3 wo_flags=0xf - bash-1702 [002] d..1 175.347349: wait_r: (SyS_wait4+0x74/0xe4 <- do_wait) arg1=0xfffffffffffffff6_ + bash-1702 [002] d..1 175.347349: wait_r: (SyS_wait4+0x74/0xe4 <- do_wait) arg1=0xfffffffffffffff6 ``` ### 例子: 探测任意指令地址 -在前面的例子中,我们已经为函数的入口和出口插入探针,然而探测一个任意指令(除少数例外)是可能的。如果我们正在 C 函数中放置一个探针,第一步是查看代码的汇编版本以确定我们要放置探针的位置。一种方法是在 vmlinux 文件上使用 gdb,并在要放置探针的函数中展示指令。下面是一个在 arch/arm64/kernel/modules.c 中 _module_alloc_ 函数执行此操作的示例。在这种情况下,因为 gdb 似乎更喜欢使用弱符号定义,并且它是与这个函数关联的存根代码,所以我们从 System.map 中来获取符号值: +在前面的例子中,我们已经为函数的入口和出口插入探针,然而探测一个任意指令(除少数例外)是可能的。如果我们正在 C 函数中放置一个探针,第一步是查看代码的汇编版本以确定我们要放置探针的位置。一种方法是在 vmlinux 文件上使用 gdb,并在要放置探针的函数中展示指令。下面是一个在 `arch/arm64/kernel/modules.c` 中 `module_alloc` 函数执行此操作的示例。在这种情况下,因为 gdb 似乎更喜欢使用弱符号定义,并且它是与这个函数关联的存根代码,所以我们从 System.map 中来获取符号值: ``` -_$ grep module_alloc System.map +$ grep module_alloc System.map ffff2000080951c4 T module_alloc -ffff200008297770 T kasan_module_alloc_ +ffff200008297770 T kasan_module_alloc ``` 在这个例子中我们使用了交叉开发工具,并且在我们的主机系统上调用 gdb 来检查指令包含我们感兴趣函数。 ``` -_$ ${CROSS_COMPILE}gdb vmlinux +$ ${CROSS_COMPILE}gdb vmlinux (gdb) x/30i 0xffff2000080951c4 0xffff2000080951c4 : sub sp, sp, #0x30 0xffff2000080951c8 : adrp x3, 0xffff200008d70000 @@ -218,37 +214,37 @@ _$ ${CROSS_COMPILE}gdb vmlinux 0xffff200008095228 : ldp x19, x20, [sp,#16] 0xffff20000809522c : ldp x29, x30, [sp],#32 0xffff200008095230 : ret 0xffff200008095234 : mov sp, x29 - 0xffff200008095238 : mov x19, #0x0 // #0_ + 0xffff200008095238 : mov x19, #0x0 // #0 ``` 在这种情况下,我们将在此函数中显示以下源代码行的结果: ``` -_p = __vmalloc_node_range(size, MODULE_ALIGN, VMALLOC_START, +p = __vmalloc_node_range(size, MODULE_ALIGN, VMALLOC_START, VMALLOC_END, GFP_KERNEL, PAGE_KERNEL_EXEC, 0, -NUMA_NO_NODE, __builtin_return_address(0));_ +NUMA_NO_NODE, __builtin_return_address(0)); ``` -…以及在此代码行的函数调用的返回值: +……以及在此代码行的函数调用的返回值: ``` -_if (p && (kasan_module_alloc(p, size) < 0)) {_ +if (p && (kasan_module_alloc(p, size) < 0)) { ``` -我们可以在从调用外部函数的汇编代码中识别这些。为了展示这些值,我们将在目标系统上的0xffff20000809520c 和 0xffff20000809521c 处放置探针。 +我们可以在从调用外部函数的汇编代码中识别这些。为了展示这些值,我们将在目标系统上的 `0xffff20000809520c` 和 `0xffff20000809521c` 处放置探针。 ``` -_$ cat > kprobe_events < kprobe_events < events/kprobes/enable_ +$ echo 1 > events/kprobes/enable ``` 现在将一个以太网适配器加密狗插入到 USB 端口后,我们看到以下写入追踪日志的内容: ``` -_$ cat trace +$ cat trace # tracer: nop # # entries-in-buffer/entries-written: 12/12 #P:8 @@ -271,47 +267,45 @@ _$ cat trace modprobe-2097 [002] d… 78.030643: p_0xffff20000809520c: (module_alloc+0x48/0x98) arg1=0xffff2000011b8000 modprobe-2097 [002] d… 78.030761: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0 modprobe-2097 [002] d… 78.031132: p_0xffff20000809520c: (module_alloc+0x48/0x98) arg1=0xffff200001270000 - modprobe-2097 [002] d… 78.031187: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0_ + modprobe-2097 [002] d… 78.031187: p_0xffff20000809521c: (module_alloc+0x58/0x98) arg1=0x0 ``` -Kprobes 事件系统的另一个功能是记录统计信息,这可在 inkprobe_profile 中找到。在以上追踪后,该文件的内容为: +kprobes 事件系统的另一个功能是记录统计信息,这可在 `inkprobe_profile` 中找到。在以上追踪后,该文件的内容为: ``` -_$ cat kprobe_profile +$ cat kprobe_profile p_0xffff20000809520c 6 0 -p_0xffff20000809521c 6 0_ +p_0xffff20000809521c 6 0 ``` -这表明我们设置的两处断点每个共发生了 8 次击中,这当然与追踪日志数据是一致的。在 kprobetrace 文档中有更多 kprobe_profile 的功能描述。 +这表明我们设置的两处断点每个共发生了 8 次命中,这当然与追踪日志数据是一致的。在 kprobetrace 文档中有更多 kprobe_profile 的功能描述。 -也可以进一步过滤 kprobes 事件。用来控制这点的 debugfs 文件在 kprobetrace 文档中被列出,然而他们内容的详细信息大多在 trace events 文档中被描述。 +也可以进一步过滤 kprobes 事件。用来控制这点的 debugfs 文件在 kprobetrace 文档中被列出,然而它们内容的详细信息大多在 trace events 文档中被描述。 ### 总结 -现在,Linux ARMv8 对支持 kprobes 功能也和其它架构相当。有人正在做添加 uprobes 和 systemtap 支持的工作。这些功能/工具和其他已经完成的功能(如: perf, coresight)允许 Linux ARMv8 用户像在其它更老的架构上一样调试和测试性能。 +现在,Linux ARMv8 对支持 kprobes 功能也和其它架构相当。有人正在做添加 uprobes 和 systemtap 支持的工作。这些功能/工具和其他已经完成的功能(如: perf、 coresight)允许 Linux ARMv8 用户像在其它更老的架构上一样调试和测试性能。 * * * 参考文献 -[[1]][5] Jim Keniston, Prasanna S. Panchamukhi, Masami Hiramatsu. “Kernel Probes (Kprobes).” _GitHub_. GitHub, Inc., 15 Aug. 2016\. Web. 13 Dec. 2016. - -[[2]][6] Ts’o, Theodore, Li Zefan, and Tom Zanussi. “Event Tracing.” _GitHub_. GitHub, Inc., 3 Mar. 2016\. Web. 13 Dec. 2016. - -[[3]][7] Hiramatsu, Masami. “Kprobe-based Event Tracing.” _GitHub_. GitHub, Inc., 18 Aug. 2016\. Web. 13 Dec. 2016. +- 注1: Jim Keniston, Prasanna S. Panchamukhi, Masami Hiramatsu. “Kernel Probes (kprobes).” _GitHub_. GitHub, Inc., 15 Aug. 2016\. Web. 13 Dec. 2016. +- 注2: Ts’o, Theodore, Li Zefan, and Tom Zanussi. “Event Tracing.” _GitHub_. GitHub, Inc., 3 Mar. 2016\. Web. 13 Dec. 2016. +- 注3: Hiramatsu, Masami. “Kprobe-based Event Tracing.” _GitHub_. GitHub, Inc., 18 Aug. 2016\. Web. 13 Dec. 2016. ---------------- -作者简介 : [David Long][8] David在 Linaro Kernel - Core Development 团队中担任工程师。 在加入 Linaro 之前,他在商业和国防行业工作了数年,既做嵌入式实时工作又为Unix提供软件开发工具。之后,在 Digital(又名 Compaq)公司工作了十几年,负责 Unix 标准,C 编译器和运行时库的工作。之后 David 又去了一系列初创公司做嵌入式 Linux 和安卓系统,嵌入式定制操作系统和 Xen 虚拟化。他拥有 MIPS,Alpha 和 ARM 平台的经验(等等)。他使用过从 1979 年贝尔实验室 V6 开始的大部分Unix操作系统,并且长期以来一直是 Linux 用户和倡导者。他偶尔也因使用烙铁和数字示波器调试设备驱动而知名。 +作者简介 : [David Long][8] 在 Linaro Kernel - Core Development 团队中担任工程师。 在加入 Linaro 之前,他在商业和国防行业工作了数年,既做嵌入式实时工作又为Unix提供软件开发工具。之后,在 Digital(又名 Compaq)公司工作了十几年,负责 Unix 标准,C 编译器和运行时库的工作。之后 David 又去了一系列初创公司做嵌入式 Linux 和安卓系统,嵌入式定制操作系统和 Xen 虚拟化。他拥有 MIPS,Alpha 和 ARM 平台的经验(等等)。他使用过从 1979 年贝尔实验室 V6 开始的大部分Unix操作系统,并且长期以来一直是 Linux 用户和倡导者。他偶尔也因使用烙铁和数字示波器调试设备驱动而知名。 -------------------------------------------------------------------------------- via: http://www.linaro.org/blog/kprobes-event-tracing-armv8/ -作者:[ David Long][a] +作者:[David Long][a] 译者:[kimii](https://github.com/kimii) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From c6f80c05eb03c8074a13d787f69535d2f639c4bb Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 30 Nov 2017 22:03:00 +0800 Subject: [PATCH 072/344] PRF:20171009 Examining network connections on Linux systems.md @geekpi --- ...ng network connections on Linux systems.md | 50 ++++++------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/translated/tech/20171009 Examining network connections on Linux systems.md b/translated/tech/20171009 Examining network connections on Linux systems.md index 7fc95738e9..1676525e21 100644 --- a/translated/tech/20171009 Examining network connections on Linux systems.md +++ b/translated/tech/20171009 Examining network connections on Linux systems.md @@ -1,21 +1,20 @@ 检查 Linux 系统上的网络连接 ============================================================ -### Linux 系统提供了许多有用的命令来检查网络配置和连接。下面来看几个,包括 ifquery、ifup、ifdown 和 ifconfig。 - +> Linux 系统提供了许多有用的命令来检查网络配置和连接。下面来看几个,包括 `ifquery`、`ifup`、`ifdown` 和 `ifconfig`。 Linux 上有许多可用于查看网络设置和连接的命令。在今天的文章中,我们将会通过一些非常方便的命令来看看它们是如何工作的。 ### ifquery 命令 -一个非常有用的命令是 **ifquery**。这个命令应该会显示一个网络接口列表。但是,你可能只会看到类似这样的内容 - 仅显示回环接口: +一个非常有用的命令是 `ifquery`。这个命令应该会显示一个网络接口列表。但是,你可能只会看到类似这样的内容 - 仅显示回环接口: ``` $ ifquery --list lo ``` -如果是这种情况,那么你的 **/etc/network/interfaces** 不包括除了回环接口之外的网络接口信息。在下面的例子中,假设你使用 DHCP 来分配地址,且如果你希望它更有用的话,你可以添加例子最后的两行。 +如果是这种情况,那说明你的 `/etc/network/interfaces` 不包括除了回环接口之外的网络接口信息。在下面的例子中,假设你使用 DHCP 来分配地址,且如果你希望它更有用的话,你可以添加例子最后的两行。 ``` # interfaces(5) file used by ifup(8) and ifdown(8) @@ -27,14 +26,11 @@ iface eth0 inet dhcp ### ifup 和 ifdown 命令 -可以使用相关的 **ifup** 和 **ifdown** 命令来打开网络连接并根据需要将其关闭,只要该文件具有所需的描述性数据即可。请记住,“if” 在这里意思是“接口” (interface),这与 **ifconfig** 命令中的一样,而不是“如果我只有一个大脑” (if I only had a brain) 中的 “if”。 - - - +可以使用相关的 `ifup` 和 `ifdown` 命令来打开网络连接并根据需要将其关闭,只要该文件具有所需的描述性数据即可。请记住,“if” 在这里意思是接口interface,这与 `ifconfig` 命令中的一样,而不是如果我只有一个大脑if I only had a brain 中的 “if”。 ### ifconfig 命令 -另外,**ifconfig** 命令完全不读取 /etc/network/interfaces,但是在网络接口上仍然提供了相当多的有用信息 - 配置数据以及数据包计数可以告诉你每个接口有多忙。ifconfig 命令也可用于关闭和重新启动网络接口(例如:ifconfig eth0 down)。 +另外,`ifconfig` 命令完全不读取 `/etc/network/interfaces`,但是仍然提供了网络接口相当多的有用信息 —— 配置数据以及可以告诉你每个接口有多忙的数据包计数。`ifconfig` 命令也可用于关闭和重新启动网络接口(例如:`ifconfig eth0 down`)。 ``` $ ifconfig eth0 @@ -49,15 +45,13 @@ eth0 Link encap:Ethernet HWaddr 00:1e:4f:c8:43:fc Interrupt:21 Memory:fe9e0000-fea00000 ``` -输出中的 RX 和 TX 数据包计数很低。此外,没有报告错误或数据包冲突。**uptime** 命令可能会确认此系统最近才重新启动。 +输出中的 RX 和 TX 数据包计数很低。此外,没有报告错误或数据包冲突。或许可以用 `uptime` 命令确认此系统最近才重新启动。 -上面显示的广播 (Bcast) 和网络掩码 (Mask) 地址表明系统运行在 C 类等效网络(默认)上,所以本地地址范围从 192.168.0.1 到 192.168.0.254。 +上面显示的广播 (Bcast) 和网络掩码 (Mask) 地址表明系统运行在 C 类等效网络(默认)上,所以本地地址范围从 `192.168.0.1` 到 `192.168.0.254`。 ### netstat 命令 -**netstat** 命令提供有关路由和网络连接的信息。**netstat -rn** 命令显示系统的路由表。 - - +`netstat` 命令提供有关路由和网络连接的信息。`netstat -rn` 命令显示系统的路由表。192.168.0.1 是本地网关 (Flags=UG)。 ``` $ netstat -rn @@ -68,7 +62,7 @@ Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 ``` -上面输出中的 **169.254.0.0** 条目仅在你正在使用或计划使用本地链路通信时才有必要。如果不是这样的话,你可以在 **/etc/network/if-up.d/avahi-autoipd** 中注释掉相关的行: +上面输出中的 `169.254.0.0` 条目仅在你正在使用或计划使用本地链路通信时才有必要。如果不是这样的话,你可以在 `/etc/network/if-up.d/avahi-autoipd` 中注释掉相关的行: ``` $ tail -12 /etc/network/if-up.d/avahi-autoipd @@ -87,7 +81,7 @@ $ tail -12 /etc/network/if-up.d/avahi-autoipd ### netstat -a 命令 -**netstat -a** 命令将显示 **_所有_** 网络连接。为了将其限制为正在监听和已建立的连接(通常更有用),请改用 **netstat -at** 命令。 +`netstat -a` 命令将显示“所有”网络连接。为了将其限制为显示正在监听和已建立的连接(通常更有用),请改用 `netstat -at` 命令。 ``` $ netstat -at @@ -103,21 +97,9 @@ tcp6 0 0 ip6-localhost:ipp [::]:* LISTEN tcp6 0 0 ip6-localhost:smtp [::]:* LISTEN ``` -### netstat -rn 命令 - -**netstat -rn** 展示系统的路由表。192.168.0.1 是本地网关 (Flags=UG)。 - -``` -$ netstat -rn -Kernel IP routing table -Destination Gateway Genmask Flags MSS Window irtt Iface -0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0 -192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 -``` - ### host 命令 -**host** 命令就像 **nslookup** 一样,用来查询远程系统的 IP 地址,但是还提供系统的邮箱处理地址。 +`host` 命令就像 `nslookup` 一样,用来查询远程系统的 IP 地址,但是还提供系统的邮箱处理地址。 ``` $ host world.std.com @@ -127,7 +109,7 @@ world.std.com mail is handled by 10 smtp.theworld.com. ### nslookup 命令 -**nslookup** 还提供系统中(本例中是本地系统)提供 DNS 查询服务的信息。 +`nslookup` 还提供系统中(本例中是本地系统)提供 DNS 查询服务的信息。 ``` $ nslookup world.std.com @@ -141,7 +123,7 @@ Address: 192.74.137.5 ### dig 命令 -**dig** 命令提供了很多有关连接到远程系统的信息 - 包括与我们通信的名称服务器以及查询需要多长时间进行响应,并经常用于故障排除。 +`dig` 命令提供了很多有关连接到远程系统的信息 - 包括与我们通信的名称服务器以及查询需要多长时间进行响应,并经常用于故障排除。 ``` $ dig world.std.com @@ -168,7 +150,7 @@ world.std.com. 78146 IN A 192.74.137.5 ### nmap 命令 -**nmap** 经常用于探查远程系统,但是同样也用于报告本地系统提供的服务。在下面的输出中,我们可以看到登录可以使用 ssh、smtp 用于电子邮箱、web 站点也是启用的,并且 ipp 打印服务正在运行。 +`nmap` 经常用于探查远程系统,但是同样也用于报告本地系统提供的服务。在下面的输出中,我们可以看到登录可以使用 ssh、smtp 用于电子邮箱、web 站点也是启用的,并且 ipp 打印服务正在运行。 ``` $ nmap localhost @@ -186,7 +168,7 @@ PORT STATE SERVICE Nmap done: 1 IP address (1 host up) scanned in 0.09 seconds ``` -Linux 系统提供了很多有用的命令用于查看网络配置和连接。如果你都探索完了,请记住 **apropos network** 或许会让你了解更多。 +Linux 系统提供了很多有用的命令用于查看网络配置和连接。如果你都探索完了,请记住 `apropos network` 或许会让你了解更多。 -------------------------------------------------------------------------------- @@ -194,7 +176,7 @@ via: https://www.networkworld.com/article/3230519/linux/examining-network-connec 作者:[Sandra Henry-Stocker][a] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 823a4b55042615b40ddb6a704379813d67b86898 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 1 Dec 2017 09:01:08 +0800 Subject: [PATCH 073/344] translated --- ...layer introduction part 1 the bio layer.md | 39 ------------------- ...layer introduction part 1 the bio layer.md | 36 +++++++++++++++++ 2 files changed, 36 insertions(+), 39 deletions(-) delete mode 100644 sources/tech/20171029 A block layer introduction part 1 the bio layer.md create mode 100644 translated/tech/20171029 A block layer introduction part 1 the bio layer.md diff --git a/sources/tech/20171029 A block layer introduction part 1 the bio layer.md b/sources/tech/20171029 A block layer introduction part 1 the bio layer.md deleted file mode 100644 index 065a3720b4..0000000000 --- a/sources/tech/20171029 A block layer introduction part 1 the bio layer.md +++ /dev/null @@ -1,39 +0,0 @@ -translating---geekpi - -A block layer introduction part 1: the bio layer -============================================================ - -### A block layer introduction part 1: the bio layer - -In reply to: [A block layer introduction part 1: the bio layer][1] by amarao -Parent article: [A block layer introduction part 1: the bio layer][2]Hi, -the problem you describe here is not directly related to the block layer. It is probably a driver bug, possible a SCSI-layer bug, but definitely not a block-layer problem. -Reporting bugs against Linux is, unfortunately, a bit of a hit-and-miss affair. Some developers refused to touch bugzilla, some love it, and some (like me) only use it begrudgingly. -The alternative is to send email. For that you need to choose the right list and maybe the right developer, and you need to catch them when they are in a good mood or aren't too busy or not on holidays. Some people will make an effort to respond to everything, others are completely unpredictable - and that is for me who usually sends a patch with any bug report. If you just have a bug that you barely understand yourself, your expected response rate is probably lower. Sad, but true. - -Lots of bugs do get responded to and dealt with, but lots do not. - -I don't think it is fair to say that nobody cares, but it probably is true that nobody sees it as being as important as you do. If you want a solution, then you need to drive it. One way to drive it is to spend money on a consultant or with a support contract from a distributor. I suspect that isn't possible in your situation. Another way is to learn how the code works and find a solution yourself. Lots of people do that, but again it might not be an option for you. Another way is to keep raising the issue on different relevant forums until you get a response. Persistence can bear fruit. You would need to be prepared to perform whatever testing is asked of you, possibly including building a new kernel to test. - -If you are able to reproduce this problem on a recent kernel (4.12 or later) I suggest that you email a report to -linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, and me (neilb@suse.com) (note that you do not need to subscribe to these lists to send mail, just send it). Describe the hardware and how to trigger the problem. -Include the stack trace of any process in "D" state. You can get this with -cat /proc/$PID/stack -where "$PID" is the pid of the process. - -Be sure to avoid complaining or saying how this has been broken for years and how it is grossly inadequate. Nobody cares about that. We do care about bugs and generally want to fix them. So just report the relevant facts. -Try to include all facts in the mail rather than via links to somewhere else. Sometimes links are necessary, but in the case of your script, it is 8 lines long so just include it in the email (and avoid descriptions like "fuckup"; just call it "broken" or similar). Also make sure your email isn't sent as HTML. We like just plain text. HTML is rejected by all @vger.kernel.org mailing lists. You might need to configure your email program to not send HTML. - --------------------------------------------------------------------------------- - -via: https://lwn.net/Articles/737655/ - -作者:[ neilbrown][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://lwn.net/Articles/737655/ -[1]:https://lwn.net/Articles/737588/ -[2]:https://lwn.net/Articles/736534/ diff --git a/translated/tech/20171029 A block layer introduction part 1 the bio layer.md b/translated/tech/20171029 A block layer introduction part 1 the bio layer.md new file mode 100644 index 0000000000..bc3f582259 --- /dev/null +++ b/translated/tech/20171029 A block layer introduction part 1 the bio layer.md @@ -0,0 +1,36 @@ +块层介绍第一部分:块 I/O 层 +============================================================ + +### 块层介绍第一部分:块 I/O 层 + +回复:amarao 在[块层介绍第一部分:块 I/O 层][1] 中提的问题 +先前的文章:[块层介绍第一部分:块 I/O 层][2] + +嗨, +你在这里描述的问题与块层不直接相关。这可能是一个驱动错误、可能是一个 SCSI 层错误,但绝对不是一个块层的问题。 +不幸的是,报告针对 Linux 的错误是一件难事。有些开发者拒绝去看 bugzilla,有些开发者喜欢它,有些(像我这样)只能勉强地使用它。 +另一种方法是发送电子邮件。为此,你需要选择正确的邮件列表,还有也许是正确的开发人员,当他们心情愉快,或者不是太忙或者不是假期时找到它们。有些人会努力回复所有,有些是完全不可预知的 - 这对我来说通常会发送一个补丁,包含一些错误报告。如果你只是有一个你自己几乎都不了解的 bug,那么你的预期响应率可能会更低。很遗憾,但这是是真的。 + +许多 bug 都会得到回应和处理,但很多 bug 都没有。 + +我不认为说没有人关心是公平的,但是没有人认为它如你想的那样重要是有可能的。如果你想要一个解决方案,那么你需要驱动它。一个驱动它的方法是花钱请顾问或者与经销商签订支持合同。我怀疑你的情况没有上面的可能。另一种方法是了解代码如何工作,并自己找到解决方案。很多人都这么做,但是这对你来说可能不是一种选择。另一种方法是在不同的相关论坛上不断提出问题,直到得到回复。坚持可以见效。你需要做好准备去执行任何你所要求的测试,可能包括建立一个新的内核来测试。 + +如果你能在最近的内核(4.12 或者更新)上复现这个 bug,我建议你邮件报告给 linux-kernel@vger.kernel.org、linux-scsi@vger.kernel.org 和我(neilb@suse.com)(注意你不必订阅这些列表来发送邮件,只需要发送就行)。描述你的硬件以及如何触发问题的。 +包含所有进程状态是 “D” 的栈追踪。你可以用 “cat /proc/$PID/stack” 来得到它,这里的 “$PID” 是进程的 pid。 + +确保避免抱怨或者说这个已经坏了好几年了以及这是多么严重不足。没有人关心这个。我们关心的是 bug 以及如何修复它。因此只要报告相关的事实就行。 +尝试在邮件中而不是链接到其他地方的链接中包含所有事实。有时链接是需要的,但是对于你的脚本,它只有 8 行,所以把它包含在邮件中就行(并避免像 “fuckup” 之类的描述。只需称它为“坏的”(broken)或者类似的)。同样确保你的邮件发送的不是 HTML 格式。我们喜欢纯文本。HTML 被所有的 @vger.kernel.org 邮件列表拒绝。你或许需要配置你的邮箱程序不发送 HTML。 + +-------------------------------------------------------------------------------- + +via: https://lwn.net/Articles/737655/ + +作者:[ neilbrown][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://lwn.net/Articles/737655/ +[1]:https://lwn.net/Articles/737588/ +[2]:https://lwn.net/Articles/736534/ From 5d8047c85b8f3bab7084900eebad9921ce850b3c Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 1 Dec 2017 09:11:59 +0800 Subject: [PATCH 074/344] translating --- ...Office Is Now Available on Flathub the Flatpak App Store.md | 3 +++ .../tech/20171130 Search DuckDuckGo from the Command Line.md | 2 ++ 2 files changed, 5 insertions(+) diff --git a/sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md b/sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md index 1f8dde5784..fe72e37128 100644 --- a/sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md +++ b/sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md @@ -1,3 +1,6 @@ +translating---geekpi + + # LibreOffice Is Now Available on Flathub, the Flatpak App Store ![LibreOffice on Flathub](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/libroffice-on-flathub-750x250.jpeg) diff --git a/sources/tech/20171130 Search DuckDuckGo from the Command Line.md b/sources/tech/20171130 Search DuckDuckGo from the Command Line.md index a54c292924..ee451a6172 100644 --- a/sources/tech/20171130 Search DuckDuckGo from the Command Line.md +++ b/sources/tech/20171130 Search DuckDuckGo from the Command Line.md @@ -1,3 +1,5 @@ +translating---geekpi + # Search DuckDuckGo from the Command Line ![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/duckduckgo.png) From 1b2f11519f4469313fae7a9daf273f60452f1d5b Mon Sep 17 00:00:00 2001 From: Yixun Xu Date: Thu, 30 Nov 2017 20:33:09 -0500 Subject: [PATCH 075/344] post merge fix --- ...Search DuckDuckGo from the Command Line.md | 103 ------------------ 1 file changed, 103 deletions(-) delete mode 100644 sources/tech/20171130 Search DuckDuckGo from the Command Line.md diff --git a/sources/tech/20171130 Search DuckDuckGo from the Command Line.md b/sources/tech/20171130 Search DuckDuckGo from the Command Line.md deleted file mode 100644 index ee451a6172..0000000000 --- a/sources/tech/20171130 Search DuckDuckGo from the Command Line.md +++ /dev/null @@ -1,103 +0,0 @@ -translating---geekpi - -# Search DuckDuckGo from the Command Line - - ![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/duckduckgo.png) -When we showed you how to [search Google from the command line][3] a lot of you to say you use [Duck Duck Go][4], the awesome privacy-focused search engine. - -Well, now there’s a tool to search DuckDuckGo from the command line. It’s called [ddgr][6] (pronounced, in my head, as  _dodger_ ) and it’s pretty neat. - -Like [Googler][7], ddgr is totally open-source and totally unofficial. Yup, the app is unaffiliated with DuckDuckGo in any way. So, should it start returning unsavoury search results for innocent terms, make sure you quack in this dev’s direction, and not the search engine’s! - -### DuckDuckGo Terminal App - -![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/ddgr-gif.gif) - -[DuckDuckGo Bangs][8] makes finding stuff on DuckDuckGo super easy (there’s even a bang for  _this_  site) and, dutifully, ddgr supports them. - -Unlike the web interface, you can specify the number of search results you would like to see per page. It’s more convenient than skimming through 30-odd search results per page. The default interface is carefully designed to use minimum space without sacrificing readability. - -`ddgr` has a number of features, including: - -* Choose number of search results to fetch - -* Support for Bash autocomplete - -* Use !bangs - -* Open URLs in a browser - -* “I’m feeling lucky” option - -* Filter by time, region, file type, etc - -* Minimal dependencies - -You can download `ddgr` for various systems direct from the Github project page: - -[Download ‘ddgr’ from Github][9] - -You can also install ddgr on Ubuntu 16.04 LTS and up from a PPA. This repo is maintained by the developer of ddgr and is recommended should you want to stay up-to-date with new releases as and when they appear. - -Do note that at the time of writing the latest version of ddgr is  _not_  in the PPA, but an older version (lacking –num support) is: - -``` -sudo add-apt-repository ppa:twodopeshaggy/jarun -``` - -``` -sudo apt-get update -``` - -### How To Use ddgr to Search DuckDuckGo from the Comand Line - -To use ddgr once you installed all you need to do is pop open your terminal emulator of choice and run: - -``` -ddgr -``` - -Next enter a search term: - -``` -search-term -``` - -To limit the number of results returned run: - -``` -ddgr --num 5 search-term -``` - -To instantly open the first matching result for a search term in your browser run: - -``` -ddgr -j search-term -``` - -You can pass arguments and flags to narrow down your search. To see a comprehensive list inside the terminal run: - -``` -ddgr -h -``` - --------------------------------------------------------------------------------- - -via: http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app - -作者:[JOEY SNEDDON ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://plus.google.com/117485690627814051450/?rel=author -[1]:https://plus.google.com/117485690627814051450/?rel=author -[2]:http://www.omgubuntu.co.uk/category/download -[3]:http://www.omgubuntu.co.uk/2017/08/search-google-from-the-command-line -[4]:http://duckduckgo.com/ -[5]:http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app -[6]:https://github.com/jarun/ddgr -[7]:https://github.com/jarun/googler -[8]:https://duckduckgo.com/bang -[9]:https://github.com/jarun/ddgr/releases/tag/v1.1 From 7cc305ccbb9d43c369748839294246142cd5ee24 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Fri, 1 Dec 2017 09:34:44 +0800 Subject: [PATCH 076/344] Translating by qhwdw --- .../20171127 Migrating to Linux Disks Files and Filesystems.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20171127 Migrating to Linux Disks Files and Filesystems.md b/sources/tech/20171127 Migrating to Linux Disks Files and Filesystems.md index 5227d5f16e..83db5e6fb0 100644 --- a/sources/tech/20171127 Migrating to Linux Disks Files and Filesystems.md +++ b/sources/tech/20171127 Migrating to Linux Disks Files and Filesystems.md @@ -1,4 +1,4 @@ -Migrating to Linux: Disks, Files, and Filesystems +Translating by qhwdw Migrating to Linux: Disks, Files, and Filesystems ============================================================ ![Migrating to LInux ](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/butterflies-807551_1920.jpg?itok=pxTxwvFO "Migrating to LInux ") From 47e01cd4b60f516f4beaf04d33e8a893d8a0d627 Mon Sep 17 00:00:00 2001 From: Yixun Xu Date: Thu, 30 Nov 2017 20:38:15 -0500 Subject: [PATCH 077/344] fix typo --- .../tech/20171130 Search DuckDuckGo from the Command Line.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20171130 Search DuckDuckGo from the Command Line.md b/translated/tech/20171130 Search DuckDuckGo from the Command Line.md index 9bf96ecb88..d550fa75b5 100644 --- a/translated/tech/20171130 Search DuckDuckGo from the Command Line.md +++ b/translated/tech/20171130 Search DuckDuckGo from the Command Line.md @@ -13,7 +13,7 @@ [DuckDuckGo Bangs(DuckDuckGo 快捷搜索)][8] 可以帮助你轻易地在 DuckDuckGo 上找到想要的信息(甚至 _本网站_ 都有快捷搜索)。ddgr 非常忠实地呈现了这个功能。 -和网页版不同的是,你可以更改每页返回多少结果。这比起比起每次查询都要看三十多条结果要方便一些。默认界面经过了精心设计,在不影响可读性的情况下尽量减少了占用空间。 +和网页版不同的是,你可以更改每页返回多少结果。这比起每次查询都要看三十多条结果要方便一些。默认界面经过了精心设计,在不影响可读性的情况下尽量减少了占用空间。 `ddgr` 有许多功能和亮点,包括: From 091d7ad2672ab74ddb01de0a31379e573d75ede7 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Fri, 1 Dec 2017 12:08:33 +0800 Subject: [PATCH 078/344] Translated by qhwdw --- ...ng to Linux Disks Files and Filesystems.md | 135 ------------------ ...ng to Linux Disks Files and Filesystems.md | 135 ++++++++++++++++++ 2 files changed, 135 insertions(+), 135 deletions(-) delete mode 100644 sources/tech/20171127 Migrating to Linux Disks Files and Filesystems.md create mode 100644 translated/tech/20171127 Migrating to Linux Disks Files and Filesystems.md diff --git a/sources/tech/20171127 Migrating to Linux Disks Files and Filesystems.md b/sources/tech/20171127 Migrating to Linux Disks Files and Filesystems.md deleted file mode 100644 index 83db5e6fb0..0000000000 --- a/sources/tech/20171127 Migrating to Linux Disks Files and Filesystems.md +++ /dev/null @@ -1,135 +0,0 @@ -Translating by qhwdw Migrating to Linux: Disks, Files, and Filesystems -============================================================ - -![Migrating to LInux ](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/butterflies-807551_1920.jpg?itok=pxTxwvFO "Migrating to LInux ") -Installing and using Linux on your main desktop will help you quickly become familiar with the methods and tools you need.[Creative Commons Zero][1]Pixabay - -This is the second article in our series on migrating to Linux. If you missed the first one, [you can find it here][4]. As mentioned previously, there are several reasons why you might want to migrate to Linux. You might be using or developing code for Linux in your job, or you might just want to try something new. - -In any case, having Linux on your main desktop will help you quickly become familiar with the methods and tools you’ll need. In this article, I’ll provide an introduction to Linux files, filesystems and disks. - -### Where's My C:\? - -If you are coming from a Mac, Linux should feel fairly familiar to you, as the Mac uses files, filesystems, and disks pretty closely to the way Linux does. On the other hand, if your experience is primarily Windows, accessing disks under Linux may seem a little confusing. Generally, Windows assigns a drive letter (like C:\) to each disk. Linux does not do this. Instead Linux presents a single hierarchy of files and directories for everything in your system. - -Let's look at an example. Suppose you use a computer with a main hard drive, a CD-ROM with folders called  _Books_  and  _Videos_  and a USB thumb drive with a directory called  _Transfer_ . Under Windows, you would see the following: - -``` -C:\ [Hard drive] - -├ System - -├ System32 - -├ Program Files - -├ Program Files (x86) - -└ - -D:\ [CD-ROM] - -├ Books - -└ Videos - -E:\ [USB thumb drive] - -└ Transfer -``` - -A typical Linux system would instead have this: - -``` -/ (the top most directory, called the root directory) [Hard drive] - -├ bin - -├ etc - -├ lib - -├ sbin - -├ usr - -├ - -└ media - - └ - - ├ cdrom [CD-ROM] - - │ ├ Books - - │ └ Videos - - └ Kingme_USB [USB thumb drive] - - └ Transfer -``` - -If you are using a graphical environment, usually, the file manager in Linux will present the CD-ROM and the USB thumb drive with icons that look like the device, so you may not need to know the media's specific directory. - -### Filesystems - -Linux emphasizes these things called filesystems. A filesystem is a set of structures on media (like a hard drive) that keep track of all the files and directories on the media. Without a filesystem we could store information on a hard drive, but all the data would be in a jumbled mess. We wouldn't know which blocks of data belonged to which file. You may have heard of names like Ext4, XFS, and Btrfs. These are Linux filesystem types. - -Every type of media that holds files and directories has a filesystem on it. Different media types may use specific filesystem types that are optimized for the media. So CD-ROMs use ISO9660 or UDF filesystem types. USB thumbdrives typically use FAT32 so they can be easily shared with other computer systems. - -Windows uses filesystems, too. It just doesn't talk about them as much. For example, when you insert a CD-ROM, Windows will read the ISO9660 filesystem structures, assign a drive letter to it and display the files and directories under the letter (D:\ for example). So if you're picky about details, technically Windows assigns a drive letter to a filesystem, not the whole disk. - -Using that same example, Linux will also read the ISO9660 filesystem structures, but instead of a drive letter, it will attach the filesystem to a directory (a process called mounting). Linux will then display the files and directories on the CD-ROM under the attached directory ( _/media//cdrom,_  for example). - -So to answer the question "Where's my C:\?" On Linux, there is no C:\. It works differently. - -### Files - -Windows stores files and directories (also called folders) in its filesystem. Linux, however, lets you put other things into the filesystem as well. These additional types of things are native objects in the filesystem, and they're actually different from regular files. Linux allows you to create and use hard links, symbolic links, named pipes, device nodes, and sockets, in addition to the regular files and directories. We won't get into all the types of filesystem objects here, but there are a few that are useful to know about. - -Hard links are used to create one or more aliases for a file. Each alias is a different name to the same contents on disk. If you edit the file under one file name, the changes appear under the other file names as well. For example. you might have  _MyResume_2017.doc_  also have a hard link called  _JaneDoeResume.doc_ . (Note that you can create a hard link by using the _ln_  command from the command line.) This way you can find and edit  _MyResume_2017.doc_ , then send out  _JaneDoeResume.doc_  to your prospects to help them keep track where it's from -- which will contain all your updates. - -Symbolic links are a little like Windows shortcuts. The filesystem entry contains a path to another file or directory. In a lot of ways, they work like hard links in that they can create an alias to another file. However, symbolic links can alias directories as well as files, and symbolic links can refer to items in a different filesystem on different media where hard links cannot. (Note that you can create symbolic links also with the _ln_ command, but with the  _-s_ option.) - -### Permissions - -Another big difference between Windows and Linux involves the permissions on filesystem objects (files, directories, and others). Windows implements a fairly complex set of permissions on files and directories. For example, users and groups can have permissions to read, write, execute, modify, and more. Users and groups can be given permission to access everything in a directory with exceptions, or they can be given no permission to anything in a directory with exceptions. - -Most folks using Windows don't make use of special permissions, however; so, it's surprising when they discover that a default set of permissions are used and enforced on Linux. Linux can enforce more sophisticated permissions by using SELinux or AppArmor. However most Linux installations just use the built-in default permissions. - -In the default permissions, each item in the filesystem has a set of permissions for the owner of the file, the group for the file, and for everyone else. These permissions allow for: reading, writing, and executing. The permissions have a hierarchy to them. First, it checks whether the user (the login name) is the owner and has permission. If not, then it checks whether your user (login name) is in the group for the file and the group has permission. If not, then it checks whether everyone else has permission. There are other permission settings as well, but the three sets of three are the ones most commonly used. - -If you are using the command line, and you type ls -l, you may see permissions represented as: - -``` -rwxrw-r-- 1 stan dndgrp 25 Oct 33rd 25:01 rolldice.sh -``` - -The letters at the beginning, rwxrw-r--, show the permissions. In this case, the owner (stan) can read, write, and execute the file (the first three letters, rwx); members of the group dndgrp can read and write the file but not execute (the second three letters, rw-); and everyone else can only read the file (the last three letters, r--). - -(Note that on Windows to make a script executable, you make the file's extension something specific, .bat for example. On Linux, the file's extension doesn't mean anything to the operating system. Instead its permissions need to be set so the file is executable.) - -If you get a  _permission denied_  error, chances are you are attempting to run a program or command that requires administrator privilege, or you're trying to access a file that doesn't hold permissions for your user account to access it. If you are trying to do something that requires administrator privilege, you will need to switch to the user account called  _root_  by logging in as root, or by using a helper program called  _sudo_  on the command line, which will allow you to temporarily run as root. The sudo tool will, of course, ask for a password to make sure you really should have permission. - -### Hard Drive Filesystems - -Windows predominately uses a filesystem type called NTFS for hard drives. On Linux, you get to pick which type of filesystem you want to use for the hard drive. Different types of filesystems exhibit different features and different performance characteristics. The main native Linux filesystem used today is Ext4\. However, you can choose from an abundance of filesystem types at installation time, such as: Ext3 (predecessor to Ext4), XFS, Btrfs, UBIFS (for embedded systems), and more. If you're not sure which one to use, Ext4 will work great. - - _Learn more about Linux through the free ["Introduction to Linux" ][2]course from The Linux Foundation and edX._ - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/learn/intro-to-linux/2017/11/migrating-linux-disks-files-and-filesystems - -作者:[JOHN BONESIO][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/johnbonesio -[1]:https://www.linux.com/licenses/category/creative-commons-zero -[2]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux -[3]:https://www.linux.com/files/images/butterflies-8075511920jpg -[4]:https://www.linux.com/blog/learn/intro-to-linux/2017/10/migrating-linux-introduction diff --git a/translated/tech/20171127 Migrating to Linux Disks Files and Filesystems.md b/translated/tech/20171127 Migrating to Linux Disks Files and Filesystems.md new file mode 100644 index 0000000000..438b27a222 --- /dev/null +++ b/translated/tech/20171127 Migrating to Linux Disks Files and Filesystems.md @@ -0,0 +1,135 @@ +迁移到 Linux:磁盘、文件、和文件系统 +============================================================ + +![Migrating to LInux ](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/butterflies-807551_1920.jpg?itok=pxTxwvFO "Migrating to LInux ") +在你的主要桌面上安装和使用 Linux 将帮你快速熟悉你需要的工具和方法。[Creative Commons Zero][1]Pixabay + +这是我们的迁移到 Linux 系列文章的第二篇。如果你错过了第一篇,[你可以在这里找到它][4]。以前提到过,为什么要迁移到 Linux 的几个原因。你可以在你的工作中为 Linux 开发和使用代码,或者,你可能是正想去尝试一下新事物。 + +不论是什么原因,拥有一个 Linux 的主桌面,将帮助你快速熟悉你需要的工具和方法。在这篇文章中,我将介绍 Linux 的文件、文件系统和磁盘。 + +### 我的 C:\ 在哪里? + +如果你是一个 Mac 用户,Linux 对你来说应该非常熟悉,Mac 使用的文件、文件系统、和磁盘与 Linux 是非常接近的。另一方面,如果你的使用经验主要是 Windows,访问 Linux 下的磁盘可能看上去有点困惑。一般,Windows 给每个磁盘分配一个盘符(像 C:\)。而 Linux 并不是这样。而在你的 Linux 系统中它是一个单一的文件和目录的层次结构。 + +让我们看一个示例。假设你的计算机使用了一个主硬盘、一个有 _Books_ 和 _Videos_ 目录的 CD-ROM 、和一个有 _Transfer_ 目录的 U 盘,在你的 WIndows 下,你应该看到的是下面的样子: + +``` +C:\ [Hard drive] + +├ System + +├ System32 + +├ Program Files + +├ Program Files (x86) + +└ + +D:\ [CD-ROM] + +├ Books + +└ Videos + +E:\ [USB thumb drive] + +└ Transfer +``` + +而一个典型的 Linux 系统却是这样: + +``` +/ (the top most directory, called the root directory) [Hard drive] + +├ bin + +├ etc + +├ lib + +├ sbin + +├ usr + +├ + +└ media + + └ + + ├ cdrom [CD-ROM] + + │ ├ Books + + │ └ Videos + + └ Kingme_USB [USB thumb drive] + + └ Transfer +``` + +如果你使用一个图形化环境,通常,Linux 中的文件管理器将出现看起来像驱动器的图标的 CD-ROM 和 USB 便携式驱动器,因此,你根本就无需知道介质所在的目录。 + +### 文件系统 + +Linux 称这些东西为文件系统。一个文件系统是在介质(比如,硬盘)上保持跟踪所有的文件和目录的一组结构。如果没有文件系统,我们存储在硬盘上的信息就会混乱,我们就不知道哪个块属于哪个文件。你可能听到过一些名字,比如,Ext4、XFS、和 Btrfs。这些都是 Linux 文件系统。 + +每个保存有文件和目录的介质都有一个文件系统在上面。不同的介质类型可能使用了为它优化过的特定的文件系统。比如,CD-ROMs 使用 ISO9660 或者 UDF 文件系统类型。USB 便携式驱动器一般使用 FAT32,以便于它们可以很容易去与其它计算机系统共享。 + +Windows 也使用文件系统。不过,我们不过多的讨论它。例如,当你插入一个 CD-ROM,Windows 将读取 ISO9660 文件系统结构,分配一个盘符给它,然后,在盘符(比如,D:\)下显示文件和目录。当然,如果你深究细节,从技术角度说,Windows 是分配一个盘符给一个文件系统,而不是整个驱动器。 + +使用同样的例子,Linux 也读取 ISO9660 文件系统结构,但它不分配盘符,它附加文件系统到一个目录(这个过程被称为加载)。Linux 将随后在附加的目录(比如是, _/media//cdrom_ )下显示 CD-ROM 上的文件和目录。 + +因此,在 Linux 上回答 “我的 C:\ 在哪里?” 这个问题,答案是,这里没有 C:\,它们工作方式不一样。 + +### 文件 + +Windows 在它的文件系统中存在文件和目录(也被称为文件夹)。但是,Linux 也让你将其它的东西放到文件系统中。这些其它类型的东西是文件系统的原生的对象,并且,它们和普通文件实际上是不同的。除普通文件和目录之外,Linux 还允许你去创建和使用硬链接、符号链接、命名管道、设备节点、和套接字。在这里,我们不展开讨论所有的文件系统对象的类型,但是,这里有几种经常使用到的。 + +硬链接是用于为文件创建一个或者多个别名。指向磁盘上同样内容的每个别名的名字是不同的。如果在一个文件名下编辑文件,这个改变也同时出现在其它的文件名上。例如,你有一个 _MyResume_2017.doc_,它还一个被称为 _JaneDoeResume.doc_ 的硬链接。(注意,硬链接是从命令行下,使用 _ln_ 的命令去创建的)。你可以找到并编辑 _MyResume_2017.doc_,然后,然后找到 _JaneDoeResume.doc_,你发现它保持了跟踪 -- 它包含了你所有的更新。 + +符号链接有点像 Windows 中的快捷方式。文件系统的入口包含一个到其它文件或者目录的路径。在很多方面,它们的工作方式和硬链接很相似,它们可以创建一个到其它文件的别名。但是,符号链接也可以像文件一样给目录创建一个别名,并且,符号链接可以指向到不同介质上的不同文件系统,而硬链接做不到这些。(注意,你可以使用带 _-s_ 选项的 _ln_ 命令去创建一个符号链接) + +### 权限 + +另一个很大的区别是文件系统对象上在 Windows 和 Linux 之中涉及的权限(文件、目录、及其它)。Windows 在文件和目录上实现了一套非常复杂的权限。例如,用户和用户组可以有权限去读取、写入、运行、修改、等等。用户和用户组可以授权访问除例外以外的目录中的所有内容,也可以不允许访问除例外的目录中的所有内容。 + +然而,大多数使用 Windows 的人并不去使用一个特定的权限;因此,当他们发现使用一套权限并且在 Linux 上是强制执行的,他们感到非常惊讶!Linux 通过使用 SELinux 或者 AppArmor 可以强制执行一套更复杂的权限。但是,大多数 Linux 安装版都使用了内置的默认权限。 + +在默认的权限中,文件系统中的每个条目都有一套为它的文件所有者、文件所在的组、和其它人的权限。这些权限允许他们:读取、写入、和运行。给它们的权限有一个层次。首先,它检查这个(登入的)用户是否为该文件所有者和它拥有的权限。如果不是,然后检查这个用户是否在文件所在的组中和它拥有的权限。如果不是,然后它再检查其它人拥有的权限。这里设置了其它人的权限。但是,这里设置的三套权限大多数情况下都会使用其中的一套。 + +如果你使用命令行,你输入 `ls -l`,你可以看到如下所表示的权限: + +``` +rwxrw-r-- 1 stan dndgrp 25 Oct 33rd 25:01 rolldice.sh +``` + +最前面的字母,`rwxrw-r--`,展示了权限。在这个例子中,所有者(stan)可以读取、写入、和运行这个文件(前面的三个字母,rwx);dndgrp 组的成员可以读取和写入这个文件,但是不能运行(第二组的三个字母,rw-);其它人仅可以读取这个文件(最后的三个字母,r--)。 + +(注意,在 Windows 中去生成一个可运行的脚本,你生成的文件有一个特定的扩展名,比如 .bat,而在 Linux 中,扩展名在操作系统中没有任何意义。而是需要去设置这个文件可运行的权限) + +如果你收到一个 _permission denied_ 错误,可能是你去尝试运行了一个要求管理员权限的程序或者命令,或者你去尝试访问一个你的帐户没有访问权限的文件。如果你尝试去做一些要求管理员权限的事,你必须切换登入到一个被称为 _root_ 的用户帐户。或者通过使用一个命令行的被称为 _sudo_ 的助理程序。它可以临时允许你以 _root_ 权限运行。当然,_sudo_ 工具,也会要求你输入密码,以确保你真的有权限。 + +### 硬盘文件系统 + +Windows 主要使用一个被称为 `NTFS` 的硬盘文件系统。在 Linux 上,你也可以选一个你希望去使用的硬盘文件系统。不同的文件系统类型呈现不同的特性和不同的性能特征。主要的原生 Linux 的文件系统,现在使用的是 Ext4。但是,在安装 Linux 的时候,你可以有丰富的文件系统类型可供选择,比如,Ext3(Ext4 的前任)、XFS、Btrfs、UBIFS(用于嵌入式系统)、等等。如果你不确定要使用哪一个,Ext4 是一个很好的选择。 + + _通过来自 Linux 基金会和 edX 的 ["Linux 介绍"][2] 上免费学习更多的 Linux 课程。_ + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/intro-to-linux/2017/11/migrating-linux-disks-files-and-filesystems + +作者:[JOHN BONESIO][a] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/johnbonesio +[1]:https://www.linux.com/licenses/category/creative-commons-zero +[2]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux +[3]:https://www.linux.com/files/images/butterflies-8075511920jpg +[4]:https://www.linux.com/blog/learn/intro-to-linux/2017/10/migrating-linux-introduction From e8db2bcab6451433883c063e80edd537f9468353 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Fri, 1 Dec 2017 12:15:36 +0800 Subject: [PATCH 079/344] Translating by qhwdw --- sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md b/sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md index a41fc008fa..94b98cf5c2 100644 --- a/sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md +++ b/sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md @@ -1,4 +1,4 @@ -[Concurrent Servers: Part 4 - libuv][17] +Translating by qhwdw [Concurrent Servers: Part 4 - libuv][17] ============================================================ This is part 4 of a series of posts on writing concurrent network servers. In this part we're going to use libuv to rewrite our server once again, and also talk about handling time-consuming tasks in callbacks using a thread pool. Finally, we're going to look under the hood of libuv for a bit to study how it wraps blocking file-system operations with an asynchronous API. From 76a23530e5dd2aa44def31d964d4b3f51d1224cb Mon Sep 17 00:00:00 2001 From: wangy325 Date: Fri, 1 Dec 2017 13:01:00 +0800 Subject: [PATCH 080/344] add translated doc --- ...and Certification Are Key for SysAdmins.md | 74 ------------------ ...and Certification Are Key for SysAdmins.md | 78 +++++++++++++++++++ 2 files changed, 78 insertions(+), 74 deletions(-) delete mode 100644 translated/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md create mode 100644 translated/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md diff --git a/translated/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md b/translated/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md deleted file mode 100644 index a3b5e95878..0000000000 --- a/translated/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md +++ /dev/null @@ -1,74 +0,0 @@ - - -开源云技能和认证—系统管理员的核心竞争力 -========= - -![os jobs](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/open-house-sysadmin.jpg?itok=i5FHc3lu "os jobs") - -[2017年开源工作报告][1](以下简称“报告”)显示,具有开源云技术认证的系统管理员能获得更高的薪酬。报告遵守[CC0][2] *[译注1]*许可协议。 - -> 译注1:CC0,即知识/版权共享协议(Creative Commons Zero),任何人都可以不须经作者同意拷贝,修改,发布,甚至商用 - -报告显示53%的受访者认为系统管理员是雇主们最期望被填补的职位空缺之一,因此,具有良好(开源技能/项目经验)的系统管理员能获得更高的薪酬,但这一职位,并没想象中那么容易胜任。 - -一般来讲,系统管理员主要职责是服务器和其他电脑操作系统的安装、服务支持和维护;预防、及时处理服务中断或其他问题的出现。 - -总的来说,今年的报告发现需求最大的领域有开源云(47%),应用开发(44%),大数据(43%),开发运营和安全(42%) - -此外,报告还发现58%的人事经理计划招聘更多的开源专家,其中67%认为开源人才的需求增长会比业内其他领域更甚。那些认为开源人才将成为最大需求的单位招聘的开源人才数量较去年增加了2个百分点。 - -同时,89%的人事经理认为很难找到颇具天赋的开源人才。 - -### 为什么要获取认证 - -报告显示,对系统管理员的需求刺激着人事经理(为53%的组织机构)提供正规的培训和专业技术认证,而这一比例去年为47%。 - -对系统管理方面感兴趣的IT人才应该考虑Linux认证。随便查看几个知名的招聘网站,你就能发现:[CompTIA Linux+][3]认证是入门Linux系统管理员的必备(最高)认证,[红帽认证工程师(RHCE)][4]和[红帽认证系统管理员(RHCSA)][5]则是胜任高水平职位的主要认证。 - -戴士(Dice)[2017技术行业薪资调查][6]显示,2016年系统管理员的薪水为79,538美元,较上年下降了0.8%;系统架构师的薪水为125,946美元,同比下降4.7%。尽管如此,该调查发现“高水平专业人才仍最受欢迎,特别是那些精通支持产业转型发展所需技术的人才”。 - -在开源技术方面,HBase(一个开源的分布式数据库)技术人才的薪水在戴士2017技术行业薪资调查中排第一。在网络和数据库领域,掌握OpenVSM操作系统技术也能获得高薪。 - -### 成为出色的系统管理员 - -出色的系统管理员须在问题出现时马上处理,这意味着你必须时刻准备以应对可能出现的状况。这个职位追求“零责备的,精益的,流程或技术上交互式改进”的思维方式和善于自我完善的人格,专业系统管理员联盟董事会成员、[开源][7]上为推动系统管理实践发展的一个专业非盈利组织成员Paul English说道。成为一个系统管理员意味着“使用开源软件如Liunx,BSD甚至开源Solaris等已成定局”,他补充道。 - -English还说,现在的系统管理员较以前而言,要更多地与软件打交道,而且要能够编写脚本来协助系统管理。 - -### 展望2018 - - 根据[罗伯特·哈夫2018年技术人才薪资导览][8],预计2018年北美地区许多单位将聘请大量系统管理方面的专业人才。同时,个人软实力和领导力水平也是优秀人才的考量因素,并且越来越受到重视。 - - 报告指出:“良好的聆听能力和批判性思维能力对于理解和解决用户的问题和担忧至关重要,同时,也是IT从业者的重要技能,特别是从事服务台和桌面支持的技术人员。” - - [Linux基金会][9] *译注* 提出不同阶段的系统管理员的所需的基本技能,都包括了强大的分析能力和快速处理问题的能力。 - - 当一个系统管理员想逐渐爬上金字塔顶端,他应该还具备如下技能:系统配置的结构化方法充满兴趣,拥有解决安全问题的经验,用户身份(验证)管理的经验,与非技术人员进行非技术交流的能力,优化系统以满足最新的安全需求的能力。 - - 现在[下载][10]2017年开源工作报告。 - - - - - ------------------------ - -via: https://www.linux.com/blog/open-source-cloud-skills-and-certification-are-key-sysadmins - -作者:[ ][a] -译者:[wangy325](https://github.com/wangy325) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: -[1]:https://www.linuxfoundation.org/blog/2017-jobs-report-highlights-demand-open-source-skills/ -[2]:https://www.linux.com/licenses/category/creative-commons-zero -[3]:https://certification.comptia.org/certifications/linux?tracking=getCertified/certifications/linux.aspx -[4]:https://www.redhat.com/en/services/certification/rhce -[5]:https://www.redhat.com/en/services/certification/rhcsa -[6]:http://marketing.dice.com/pdf/Dice_TechSalarySurvey_2017.pdf?aliId=105832232 -[7]:https://opensource.com/article/17/7/truth-about-sysadmins -[8]:https://www.roberthalf.com/salary-guide/technology -[9]:https://www.linux.com/learn/10-essential-skills-novice-junior-and-senior-sysadmins%20%20 -[10]:http://bit.ly/2017OSSjobsreport \ No newline at end of file diff --git a/translated/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md b/translated/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md new file mode 100644 index 0000000000..55a42f9289 --- /dev/null +++ b/translated/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md @@ -0,0 +1,78 @@ + + +开源云技能认证—系统管理员的核心竞争力 +========= + +![os jobs](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/open-house-sysadmin.jpg?itok=i5FHc3lu "os jobs") + +[2017年开源工作报告][1](以下简称“报告”)显示,具有开源云技术认证的系统管理员往往能获得更高的薪酬。报告遵守[CC0][2] *译注1*许可协议。 + +> 译注1:CC0,即知识/版权共享协议(Creative Commons Zero),任何人都可拷贝,修改,发布,甚至商用作品而无须征求作者许可 + +报告调查的受访者中,53%认为系统管理员是雇主们最期望被填补的职位空缺之一,因此,技术娴熟的系统管理员更受青睐而收获高薪职位,但这一职位,并没想象中那么容易胜任。 + +系统管理员主要负责服务器和其他电脑操作系统的安装、服务支持和维护,及时处理服务中断和预防其他问题的出现。 + +总的来说,今年的报告指出开源领域人才需求最大的有开源云(47%),应用开发(44%),大数据(43%),开发运营和安全(42%) + +此外,报告对人事经理的调查显示,58%期望招揽更多的开源人才,67%认为开源人才的需求增长会比业内其他领域更甚。有些单位视开源人才为招聘最优选则,它们招聘的开源人才较上年增长了2个百分点。 + +同时,89%的人事经理认为很难找到颇具天赋的开源人才。 + +### 为什么要获取认证 + +报告显示,对系统管理员的需求刺激着人事经理为53%的组织/机构提供正规的培训和专业技术认证,而这一比例去年为47%。 + +对系统管理方面感兴趣的IT人才考虑获取Linux认证已成为行业规律。随便查看几个知名的招聘网站,你就能发现:[CompTIA Linux+][3]认证是入门Linux系统管理员的必备(最高)认证;如果想胜任高级别的系统管理员职位,获取[红帽认证工程师(RHCE)][4]和[红帽认证系统管理员(RHCSA)][5]则是不可或缺的。 + +戴士(Dice)[2017技术行业薪资调查][6]显示,2016年系统管理员的薪水为79,538美元,较上年下降了0.8%;系统架构师的薪水为125,946美元,同比下降4.7%。尽管如此,该调查发现“高水平专业人才仍最受欢迎,特别是那些精通支持产业转型发展所需技术的人才”。 + +在开源技术方面,HBase(一个开源的分布式数据库)技术人才的薪水在戴士2017技术行业薪资调查中排第一。在计算机网络和数据库领域,掌握OpenVSM操作系统技术也能获得高薪。 + +### 成为出色的系统管理员 + +出色的系统管理员须在问题出现时马上处理,这意味着你必须时刻准备应对可能出现的状况。这个职位追求“零责备的,精益的,流程或技术上交互式改进的”思维方式和善于自我完善的人格,成为一个系统管理员意味着“你必将与开源软件如Linux,BSD甚至开源Solaris等结下不解的羁绊”,Paul English*译注2*在[开源][7]上发文指出。 + +Paul English认为,现在的系统管理员较以前而言,要更多地与软件打交道,而且要能够编写脚本来协助系统管理。 + +>译注2:Paul English,计算机科学学士,UNIX/Linux 系统管理员,PreOS Security Inc.公司CEO,2015-2017年于为推动系统管理员发展实践的非盈利组织——专业系统管理员联盟(League of Professional System Administrator)担任董事会成员。 + +### 展望2018 + + [Robert Half 2018年技术人才薪资导览][8]预测2018年北美地区许多单位将聘用大量系统管理方面的专业人才,同时个人软实力和领导力水平作为优秀人才的考量因素,越来越受到重视。 + + 报告指出:“良好的聆听能力和批判性思维能力对于理解和解决用户的问题和担忧至关重要,也是IT从业者必须具备的重要技能,特别是从事服务台和桌面支持工作相关的技术人员。” + + 这与[Linux基金会][9] *译注3* 提出的不同阶段的系统管理员必备技能相一致,都强调了强大的分析能力和快速处理问题的能力。 + + >译注3:Linux基金会(The Linux Foundation),成立于2000年,致力于围绕开源项目构建可持续发展的生态系统,以加速开源项目的技术开发和商业应用;它是世界上最大的开源非盈利组织,在推广、保护和推进Linux发展,协同开发,维护“历史上最大的共享资源”上功勋卓越。 + + 如果想逐渐爬上系统管理员职位的金字塔上层,还应该对系统配置的结构化方法充满兴趣;且拥有解决系统安全问题的经验;用户身份验证管理的经验;与非技术人员进行非技术交流的能力;以及优化系统以满足最新的安全需求的能力。 + + [下载][10]*译注4*2017年开源工作报告全文,以获取更多信息。 + +>译注4:可能需要科学上网 + + + + +----------------------- + +via: https://www.linux.com/blog/open-source-cloud-skills-and-certification-are-key-sysadmins + +作者:[ ][a] +译者:[wangy325](https://github.com/wangy325) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://www.linuxfoundation.org/blog/2017-jobs-report-highlights-demand-open-source-skills/ +[2]:https://www.linux.com/licenses/category/creative-commons-zero +[3]:https://certification.comptia.org/certifications/linux?tracking=getCertified/certifications/linux.aspx +[4]:https://www.redhat.com/en/services/certification/rhce +[5]:https://www.redhat.com/en/services/certification/rhcsa +[6]:http://marketing.dice.com/pdf/Dice_TechSalarySurvey_2017.pdf?aliId=105832232 +[7]:https://opensource.com/article/17/7/truth-about-sysadmins +[8]:https://www.roberthalf.com/salary-guide/technology +[9]:https://www.linux.com/learn/10-essential-skills-novice-junior-and-senior-sysadmins%20%20 +[10]:http://bit.ly/2017OSSjobsreport \ No newline at end of file From c6f0d23e2d60758253a35d225b6770d1d0f84e91 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 1 Dec 2017 19:10:49 +0800 Subject: [PATCH 081/344] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Translate=20Shell?= =?UTF-8?q?=20=E2=80=93=20A=20Tool=20To=20Use=20Google=20Translate=20From?= =?UTF-8?q?=20Command=20Line=20In=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ogle Translate From Command Line In Linux.md | 398 ++++++++++++++++++ 1 file changed, 398 insertions(+) create mode 100644 sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md diff --git a/sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md b/sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md new file mode 100644 index 0000000000..ce372709cf --- /dev/null +++ b/sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md @@ -0,0 +1,398 @@ +Translate Shell – A Tool To Use Google Translate From Command Line In Linux +============================================================ + +I love to work and share about CLI apps since i’m very much interested on CLI applications. Basically i prefer CLI because most of the time i will be sitting in front of the black screen and it’s became habit for me to go with CLI apps instead of GUI. + +We have wrote many articles about CLI applications in past. Recently i came to know about google CLI utilities such as “Google Translator”, “Google Calendar”, and “Google Contacts”. so, i just want to share about it. + +Today we are going to discuss about “Google Translator”. I use many times in a day to know the meanings since my native language is Tamil. + +Google translate is widely used by other language speakers. + +#### What is Translate Shell + +[Translate Shell][2] (formerly known as Google Translate CLI) is a command-line translator powered by Google Translate (default), Bing Translator, Yandex.Translate and Apertium. It allows you to access to one of these translation engines right from your terminal. Translate Shell is designed work on most of the Linux distributions. + +#### How to Install Translate Shell + +We can install the Translate Shell application in three methods. + +* Download self-contained executable file + +* Manual Method + +* Via Package Manager + +#### Method-1 : Download self-contained executable file + +Just Download the self-contained executable file and move into /usr/bin directory. + +``` +$ wget git.io/trans +$ chmod +x ./trans +$ sudo mv trans /usr/bin/ +``` + +#### Method-2 : Manual Method + +Just clone the Translate Shell github repository and compile manually for any distributions. + +``` +$ git clone https://github.com/soimort/translate-shell && cd translate-shell +$ make +$ sudo make install +``` + +#### Method-3 : Via Package Manager + +Translate Shell is available in few of the distribution official repository that can be installed through package manager. + +For Debian/Ubuntu, use [APT-GET Command][3] or [APT Command][4]to install Translate Shell. + +``` +$ sudo apt-get install translate-shell +``` + +For Fedora, use [DNF Command][5] to install Translate Shell. + +``` +$ sudo dnf install translate-shell +``` + +For Arch Linux based systems, use [Yaourt Command][6] or [Packer Command][7] to install Translate Shell from AUR repository. + +``` +$ yaourt -S translate-shell +or +$ packer -S translate-shell +``` + +#### How To Use Translate Shell + +After successfully installed, open your terminal and fire the following command. Google Translate can identify the language of the source text automatically, and Translate Shell by default translates the source text into the language of your locale. + +``` +$ trans [Words] +``` + +I’m going to translated a Tamil word “நன்றி” (Nanri) to English. It’s use to thank people. + +``` +$ trans நன்றி +நன்றி +(Naṉṟi) + +Thanks + +Definitions of நன்றி +[ தமிழ் -> English ] + +noun + gratitude + நன்றி + thanks + நன்றி + +நன்றி + Thanks +``` + +Alternatively translate a word into Tamil using following command. + +``` +$ trans :ta thanks +thanks +/THaNGks/ + +நன்றி +(Naṉṟi) + +Definitions of thanks +[ English -> தமிழ் ] + +noun + நன்றி + gratitude, thanks + +thanks + நன்றி +``` + +To Translate a word into more than one language use following command (In this example, i’m going to translate a word into Tamil & Hindi). + +``` +$ trans :ta+hi thanks +thanks +/THaNGks/ + +நன்றி +(Naṉṟi) + +Definitions of thanks +[ English -> தமிழ் ] + +noun + நன்றி + gratitude, thanks + +thanks + நன்றி + +thanks +/THaNGks/ + +धन्यवाद +(dhanyavaad) + +Definitions of thanks +[ English -> हिन्दी ] + +noun + धन्यवाद + thanks, thank, gratitude, thankfulness, felicitation + +thanks + धन्यवाद, शुक्रिया +``` + +To Translate words into one argument (phrase) use following command (just quote the sentence into one argument). + +``` +$ trans :ta "what is going on your life?" +what is going on your life? + +உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? +(Uṅkaḷ vāḻkkaiyil eṉṉa naṭakkiṟatu?) + +Translations of what is going on your life? +[ English -> தமிழ் ] + +what is going on your life? + உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? +``` + +To Translate Translate each word alone. + +``` +$ trans :ta curios happy +curios + +ஆர்வம் +(Ārvam) + +Translations of curios +[ Română -> தமிழ் ] + +curios + ஆர்வம், அறிவாளிகள், ஆர்வமுள்ள, அறிய, ஆர்வமாக +happy +/ˈhapē/ + +சந்தோஷமாக +(Cantōṣamāka) + +Definitions of happy +[ English -> தமிழ் ] + + மகிழ்ச்சியான + happy, convivial, debonair, gay + திருப்தி உடைய + happy + +adjective + இன்பமான + happy + +happy + சந்தோஷமாக, மகிழ்ச்சி, இனிய, சந்தோஷமா +``` + +Brief Mode : By default, Translate Shell displays translations in a verbose manner. If you prefer to see only the brief information, just add -b option. + +``` +$ trans -b :ta thanks +நன்றி +``` + +Dictionary Mode : To use Translate Shell as a dictionary, just add -d option. + +``` +$ trans -d :en thanks +thanks +/THaNGks/ + +Synonyms + noun + - gratitude, appreciation, acknowledgment, recognition, credit + + exclamation + - thank you, many thanks, thanks very much, thanks a lot, thank you kindly, much obliged, much appreciated, bless you, thanks a million + +Examples + - In short, thanks for everything that makes this city great this Thanksgiving. + + - many thanks + + - There were no thanks in the letter from him, just complaints and accusations. + + - It is a joyful celebration in which Bolivians give thanks for their freedom as a nation. + + - festivals were held to give thanks for the harvest + + - The collection, as usual, received a great response and thanks is extended to all who subscribed. + + - It would be easy to dwell on the animals that Tasmania has lost, but I prefer to give thanks for what remains. + + - thanks for being so helpful + + - It came back on about half an hour earlier than predicted, so I suppose I can give thanks for that. + + - Many thanks for the reply but as much as I tried to follow your advice, it's been a bad week. + + - To them and to those who have supported the office I extend my grateful thanks . + + - We can give thanks and words of appreciation to others for their kind deeds done to us. + + - Adam, thanks for taking time out of your very busy schedule to be with us tonight. + + - a letter of thanks + + - Thank you very much for wanting to go on reading, and thanks for your understanding. + + - Gerry has received a letter of thanks from the charity for his part in helping to raise this much needed cash. + + - So thanks for your reply to that guy who seemed to have a chip on his shoulder about it. + + - Suzanne, thanks for being so supportive with your comments on my blog. + + - She has never once acknowledged my thanks , or existence for that matter. + + - My grateful thanks go to the funders who made it possible for me to travel. + + - festivals were held to give thanks for the harvest + + - All you secretaries who made it this far into the article… thanks for your patience. + + - So, even though I don't think the photos are that good, thanks for the compliments! + + - And thanks for warning us that your secret service requires a motorcade of more than 35 cars. + + - Many thanks for your advice, which as you can see, I have passed on to our readers. + + - Tom Ryan was given a bottle of wine as a thanks for his active involvement in the twinning project. + + - Mr Hill insists he has received no recent complaints and has even been sent a letter of thanks from the forum. + + - Hundreds turned out to pay tribute to a beloved former headteacher at a memorial service to give thanks for her life. + + - Again, thanks for a well written and much deserved tribute to our good friend George. + + - I appreciate your doing so, and thanks also for the compliments about the photos! + +See also + Thanks!, thank, many thanks, thanks to, thanks to you, special thanks, give thanks, thousand thanks, Many thanks!, render thanks, heartfelt thanks, thanks to this +``` + +To Translate a File using Translate Shell, use the following format. + +``` +$ trans :ta file:///home/magi/gtrans.txt +உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? +``` + +To open interactive Translate Shell, run the following command. Make sure you have to specify the source language and the target language(s) before starting an interactive shell. In this example, i’m going to translate a word from English to Tamil. + +``` +$ trans -shell en:ta thanks +Translate Shell +(:q to quit) +thanks +/THaNGks/ + +நன்றி +(Naṉṟi) + +Definitions of thanks +[ English -> தமிழ் ] + +noun + நன்றி + gratitude, thanks + +thanks + நன்றி +``` + +To know the language code, just fire the following command. + +``` +$ trans -R +or +$ trans -T +┌───────────────────────┬───────────────────────┬───────────────────────┐ +│ Afrikaans - af │ Hindi - hi │ Punjabi - pa │ +│ Albanian - sq │ Hmong - hmn │ Querétaro Otomi- otq │ +│ Amharic - am │ Hmong Daw - mww │ Romanian - ro │ +│ Arabic - ar │ Hungarian - hu │ Russian - ru │ +│ Armenian - hy │ Icelandic - is │ Samoan - sm │ +│ Azerbaijani - az │ Igbo - ig │ Scots Gaelic - gd │ +│ Basque - eu │ Indonesian - id │ Serbian (Cyr...-sr-Cyrl +│ Belarusian - be │ Irish - ga │ Serbian (Latin)-sr-Latn +│ Bengali - bn │ Italian - it │ Sesotho - st │ +│ Bosnian - bs │ Japanese - ja │ Shona - sn │ +│ Bulgarian - bg │ Javanese - jv │ Sindhi - sd │ +│ Cantonese - yue │ Kannada - kn │ Sinhala - si │ +│ Catalan - ca │ Kazakh - kk │ Slovak - sk │ +│ Cebuano - ceb │ Khmer - km │ Slovenian - sl │ +│ Chichewa - ny │ Klingon - tlh │ Somali - so │ +│ Chinese Simp...- zh-CN│ Klingon (pIqaD)tlh-Qaak Spanish - es │ +│ Chinese Trad...- zh-TW│ Korean - ko │ Sundanese - su │ +│ Corsican - co │ Kurdish - ku │ Swahili - sw │ +│ Croatian - hr │ Kyrgyz - ky │ Swedish - sv │ +│ Czech - cs │ Lao - lo │ Tahitian - ty │ +│ Danish - da │ Latin - la │ Tajik - tg │ +│ Dutch - nl │ Latvian - lv │ Tamil - ta │ +│ English - en │ Lithuanian - lt │ Tatar - tt │ +│ Esperanto - eo │ Luxembourgish - lb │ Telugu - te │ +│ Estonian - et │ Macedonian - mk │ Thai - th │ +│ Fijian - fj │ Malagasy - mg │ Tongan - to │ +│ Filipino - tl │ Malay - ms │ Turkish - tr │ +│ Finnish - fi │ Malayalam - ml │ Udmurt - udm │ +│ French - fr │ Maltese - mt │ Ukrainian - uk │ +│ Frisian - fy │ Maori - mi │ Urdu - ur │ +│ Galician - gl │ Marathi - mr │ Uzbek - uz │ +│ Georgian - ka │ Mongolian - mn │ Vietnamese - vi │ +│ German - de │ Myanmar - my │ Welsh - cy │ +│ Greek - el │ Nepali - ne │ Xhosa - xh │ +│ Gujarati - gu │ Norwegian - no │ Yiddish - yi │ +│ Haitian Creole - ht │ Pashto - ps │ Yoruba - yo │ +│ Hausa - ha │ Persian - fa │ Yucatec Maya - yua │ +│ Hawaiian - haw │ Polish - pl │ Zulu - zu │ +│ Hebrew - he │ Portuguese - pt │ │ +└───────────────────────┴───────────────────────┴───────────────────────┘ +``` + +To know more options, navigate to man page. + +``` +$ man trans +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/translate-shell-a-tool-to-use-google-translate-from-command-line-in-linux/ + +作者:[ ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.2daygeek.com +[1]:https://www.2daygeek.com/author/magesh/ +[2]:https://github.com/soimort/translate-shell +[3]:https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[4]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[5]:https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ +[6]:https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/ +[7]:https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/ From c932f0bf466ab29f496e50f77928c7dd17fb98b9 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 1 Dec 2017 19:13:53 +0800 Subject: [PATCH 082/344] update author info --- ... Tool To Use Google Translate From Command Line In Linux.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md b/sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md index ce372709cf..dbb687f262 100644 --- a/sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md +++ b/sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md @@ -382,14 +382,13 @@ $ man trans via: https://www.2daygeek.com/translate-shell-a-tool-to-use-google-translate-from-command-line-in-linux/ -作者:[ ][a] +作者:[Magesh Maruthamuthu][a] 译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 -[a]:https://www.2daygeek.com -[1]:https://www.2daygeek.com/author/magesh/ +[a]:https://www.2daygeek.com/author/magesh/ [2]:https://github.com/soimort/translate-shell [3]:https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ [4]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ From f457c3289d6987ba1b5908bef3a1a4a3e0dde41d Mon Sep 17 00:00:00 2001 From: wangy325 Date: Fri, 1 Dec 2017 19:31:08 +0800 Subject: [PATCH 083/344] delete origin doc ..Open source.. --- ...and Certification Are Key for SysAdmins.md | 70 ------------------- 1 file changed, 70 deletions(-) delete mode 100644 sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md diff --git a/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md b/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md deleted file mode 100644 index 27379cbe40..0000000000 --- a/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md +++ /dev/null @@ -1,70 +0,0 @@ -translating by wangy325... - - -Open Source Cloud Skills and Certification Are Key for SysAdmins -============================================================ - - -![os jobs](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/open-house-sysadmin.jpg?itok=i5FHc3lu "os jobs") -Sysadmins with open source skills and certification can command higher pay, according to the 2017 Open Source Jobs Report.[Creative Commons Zero][1] - -System administrator is one of the most common positions employers are looking to fill among 53 percent of respondents to the [2017 Open Source Jobs Report][3]. Consequently, sysadmins with skills in engineering can command higher salaries, as these positions are among the hardest to fill, the report finds. - -Sysadmins are generally responsible for installing, supporting, and maintaining servers or other computer systems, and planning for and responding to service outages and other problems. - -Overall, this year’s report finds the skills most in demand are open source cloud (47 percent), application development (44 percent), Big Data (43 percent) and both DevOps and security (42 percent). - -The report also finds that 58 percent of hiring managers are planning to hire more open source professionals, and 67 percent say hiring of open source professionals will increase more than in other areas of the business. This represents a two-point increase over last year among employers who said open source hiring would be their top field of recruitment. - -At the same time, 89 percent of hiring managers report it is difficult to find open source talent. - -### Why get certified - -The desire for sysadmins is incentivizing hiring managers to offer formal training and/or certifications in the discipline in 53 percent of organizations, compared to 47 percent last year, the Open Source Jobs Report finds. - -IT professionals interested in sysadmin positions should consider Linux certifications. Searches on several of the more well-known job posting sites reveal that the [CompTIA Linux+][4]certification is the top certification for entry-level Linux sysadmin, while [Red Hat Certified Engineer (RHCE)][5] and [Red Hat Certified System Administrator (RHCSA)][6] are the main certifications for higher-level positions. - -In 2016, a sysadmin commanded a salary of $79,583, a change of -0.8 percent from the previous year, according to Dice’s [2017 Tech Salary Survey][7]. The systems architect position paid $125,946, a year-over-year change of -4.7 percent. Yet, the survey observes that “Highly skilled technology professionals remain in the most demand, especially those candidates proficient in the technologies needed to support industry transformation and growth.” - -When it comes to open source skills, HBase (an open-source distributed database), ranked as one that garners among the highest pay for tech pros in the Dice survey. In the networking and database category, the OpenVMS operating system ranked as another high-paying skill. - -### The sysadmin role - -One of a sysadmin’s responsibilities is to be available 24/7 when a problem occurs. The position calls for a mindset that is about “zero-blame, lean, iterative improvement in process or technology,’’ and one that is open to change, writes Paul English, a board member for the League of Professional System Administrators, a non-profit professional association for the advancement of the practice of system administration, in  [opensource.com][8]. He adds that being a sysadmin means “it’s almost a foregone conclusion that you’ll work with open source software like Linux, BSD, and even open source Solaris.” - -Today’s sysadmins will more often work with software rather than hardware, and should be prepared to write small scripts, according to English. - -### Outlook for 2018 - -Expect to see sysadmins among the tech professionals many employers in North America will be hiring in 2018, according to [Robert Half’s 2018 Salary Guide for Technology Professionals][9]. Increasingly, soft skills and leadership qualities are also highly valued. - -“Good listening and critical-thinking skills, which are essential to understanding and resolving customers’ issues and concerns, are important for almost any IT role today, but especially for help desk and desktop support professionals,’’ the report states. - -This jibes with some of the essential skills needed at various stages of the sysadmin position, including strong analytical skills and an ability to solve problems quickly, according to [The Linux Foundation][10]. - -Other skills sysadmins should have as they move up the ladder are: interest in structured approaches to system configuration management; experience in resolving security issues; experience with user identity management; ability to communicate in non-technical terms to non-technical people; and ability to modify system to meet new security requirements. - - _[Download ][11]the full 2017 Open Source Jobs Report now._ - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/open-source-cloud-skills-and-certification-are-key-sysadmins - -作者:[ ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: -[1]:https://www.linux.com/licenses/category/creative-commons-zero -[2]:https://www.linux.com/files/images/open-house-sysadminjpg -[3]:https://www.linuxfoundation.org/blog/2017-jobs-report-highlights-demand-open-source-skills/ -[4]:https://certification.comptia.org/certifications/linux?tracking=getCertified/certifications/linux.aspx -[5]:https://www.redhat.com/en/services/certification/rhce -[6]:https://www.redhat.com/en/services/certification/rhcsa -[7]:http://marketing.dice.com/pdf/Dice_TechSalarySurvey_2017.pdf?aliId=105832232 -[8]:https://opensource.com/article/17/7/truth-about-sysadmins -[9]:https://www.roberthalf.com/salary-guide/technology -[10]:https://www.linux.com/learn/10-essential-skills-novice-junior-and-senior-sysadmins%20%20 -[11]:http://bit.ly/2017OSSjobsreport From 1946828f0da9133814a5516dae4cae2c48115cad Mon Sep 17 00:00:00 2001 From: wxy Date: Fri, 1 Dec 2017 20:06:24 +0800 Subject: [PATCH 084/344] PUB:20161216 Kprobes Event Tracing on ARMv8.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @kimii 恭喜你完成了第一篇翻译! 发布地址: https://linux.cn/article-9098-1.html 你的 LCTT 专页是: https://linux.cn/lctt/kimii --- .../20161216 Kprobes Event Tracing on ARMv8.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) rename {translated/tech => published}/20161216 Kprobes Event Tracing on ARMv8.md (98%) diff --git a/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md b/published/20161216 Kprobes Event Tracing on ARMv8.md similarity index 98% rename from translated/tech/20161216 Kprobes Event Tracing on ARMv8.md rename to published/20161216 Kprobes Event Tracing on ARMv8.md index 3c3ab0de5b..3985f064dc 100644 --- a/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md +++ b/published/20161216 Kprobes Event Tracing on ARMv8.md @@ -29,19 +29,19 @@ jprobes 允许通过提供一个具有相同调用签名call signature kprobes 提供一系列能从内核代码中调用的 API 来设置探测点和当探测点被命中时调用的注册函数。在不往内核中添加代码的情况下,kprobes 也是可用的,这是通过写入特定事件追踪的 debugfs 文件来实现的,需要在文件中设置探针地址和信息,以便在探针被命中时记录到追踪日志中。后者是本文将要讨论的重点。最后 kprobes 可以通过 perl 命令来使用。 -### kprobes API +#### kprobes API 内核开发人员可以在内核中编写函数(通常在专用的调试模块中完成)来设置探测点,并且在探测指令执行前和执行后立即执行任何所需操作。这在 kprobes.txt 中有很好的解释。 -### 事件追踪 +#### 事件追踪 事件追踪子系统有自己的自己的文档^注2 ,对于了解一般追踪事件的背景可能值得一读。事件追踪子系统是追踪点tracepoints和 kprobes 事件追踪的基础。事件追踪文档重点关注追踪点,所以请在查阅文档时记住这一点。kprobes 与追踪点不同的是没有预定义的追踪点列表,而是采用动态创建的用于触发追踪事件信息收集的任意探测点。事件追踪子系统通过一系列 debugfs 文件来控制和监视。事件追踪(`CONFIG_EVENT_TRACING`)将在被如 kprobe 事件追踪子系统等需要时自动选择。 -#### kprobes 事件 +##### kprobes 事件 使用 kprobes 事件追踪子系统,用户可以在内核任意断点处指定要报告的信息,只需要指定任意现有可探测指令的地址以及格式化信息即可确定。在执行过程中遇到断点时,kprobes 将所请求的信息传递给事件追踪子系统的公共部分,这些部分将数据格式化并追加到追踪日志中,就像追踪点的工作方式一样。kprobes 使用一个类似的但是大部分是独立的 debugfs 文件来控制和显示追踪事件信息。该功能可使用 `CONFIG_KPROBE_EVENT` 来选择。Kprobetrace 文档^ 注3 提供了如何使用 kprobes 事件追踪的基本信息,并且应当被参考用以了解以下介绍示例的详细信息。 -### kprobes 和 perf +#### kprobes 和 perf perf 工具为 kprobes 提供了另一个命令行接口。特别地,`perf probe` 允许探测点除了由函数名加偏移量和地址指定外,还可由源文件和行号指定。perf 接口实际上是使用 kprobes 的 debugfs 接口的封装器。 @@ -60,7 +60,7 @@ perf 工具为 kprobes 提供了另一个命令行接口。特别地,`perf pro kprobes 的一个常用例子是检测函数入口和/或出口。因为只需要使用函数名来作为探针地址,它安装探针特别简单。kprobes 事件追踪将查看符号名称并且确定地址。ARMv8 调用标准定义了函数参数和返回值的位置,并且这些可以作为 kprobes 事件处理的一部分被打印出来。 -### 例子: 函数入口探测 +#### 例子: 函数入口探测 检测 USB 以太网驱动程序复位功能: @@ -94,7 +94,7 @@ kworker/0:0-4 [000] d… 10972.102939: p_ax88772_reset_0: 这里我们可以看见传入到我们的探测函数的指针参数的值。由于我们没有使用 kprobes 事件追踪的可选标签功能,我们需要的信息自动被标注为 `arg1`。注意这指向我们需要 kprobes 记录这个探针的一组值的第一个,而不是函数参数的实际位置。在这个例子中它也只是碰巧是我们探测函数的第一个参数。 -### 例子: 函数入口和返回探测 +#### 例子: 函数入口和返回探测 kretprobe 功能专门用于探测函数返回。在函数入口 kprobes 子系统将会被调用并且建立钩子以便在函数返回时调用,钩子将记录需求事件信息。对最常见情况,返回信息通常在 `X0` 寄存器中,这是非常有用的。在 `%x0` 中返回值也可以被称为 `$retval`。以下例子也演示了如何提供一个可读的标签来展示有趣的信息。 @@ -132,7 +132,7 @@ _$ cat trace bash-1671 [001] d..1 214.401975: r__do_fork_0: (SyS_clone+0x18/0x20 <- _do_fork) pid=0x726_ ``` -### 例子: 解引用指针参数 +#### 例子: 解引用指针参数 对于指针值,kprobes 事件处理子系统也允许解引用和打印所需的内存内容,适用于各种基本数据类型。为了展示所需字段,手动计算结构的偏移量是必要的。 @@ -173,7 +173,7 @@ $ cat trace bash-1702 [002] d..1 175.347349: wait_r: (SyS_wait4+0x74/0xe4 <- do_wait) arg1=0xfffffffffffffff6 ``` -### 例子: 探测任意指令地址 +#### 例子: 探测任意指令地址 在前面的例子中,我们已经为函数的入口和出口插入探针,然而探测一个任意指令(除少数例外)是可能的。如果我们正在 C 函数中放置一个探针,第一步是查看代码的汇编版本以确定我们要放置探针的位置。一种方法是在 vmlinux 文件上使用 gdb,并在要放置探针的函数中展示指令。下面是一个在 `arch/arm64/kernel/modules.c` 中 `module_alloc` 函数执行此操作的示例。在这种情况下,因为 gdb 似乎更喜欢使用弱符号定义,并且它是与这个函数关联的存根代码,所以我们从 System.map 中来获取符号值: From b9958b0e9d18b14ddfa3ad5943434ab49d90560b Mon Sep 17 00:00:00 2001 From: wxy Date: Fri, 1 Dec 2017 20:16:01 +0800 Subject: [PATCH 085/344] PUB:20171009 Examining network connections on Linux systems.md @geekpi https://linux.cn/article-9099-1.html --- .../20171009 Examining network connections on Linux systems.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171009 Examining network connections on Linux systems.md (100%) diff --git a/translated/tech/20171009 Examining network connections on Linux systems.md b/published/20171009 Examining network connections on Linux systems.md similarity index 100% rename from translated/tech/20171009 Examining network connections on Linux systems.md rename to published/20171009 Examining network connections on Linux systems.md From 0304f5e3b4ad9243a029253e3e0f5270654ce3ad Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 1 Dec 2017 22:25:26 +0800 Subject: [PATCH 086/344] translate by darksun --- ... A Tool To Use Google Translate From Command Line In Linux.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md b/sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md index dbb687f262..3725fea5df 100644 --- a/sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md +++ b/sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md @@ -1,3 +1,4 @@ +translate by darksun Translate Shell – A Tool To Use Google Translate From Command Line In Linux ============================================================ From 7f62ebb0ce5a9cecd962c814ce3031170757d2ba Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 1 Dec 2017 22:39:39 +0800 Subject: [PATCH 087/344] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20Instal?= =?UTF-8?q?l=20and=20Use=20Wireshark=20on=20Debian=20and=20Ubuntu=2016.04?= =?UTF-8?q?=5F17.10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...eshark on Debian and Ubuntu 16.04_17.10.md | 182 ++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md diff --git a/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md b/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md new file mode 100644 index 0000000000..72fb4b5c99 --- /dev/null +++ b/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md @@ -0,0 +1,182 @@ +How to Install and Use Wireshark on Debian 9 / Ubuntu 16.04 / 17.10 +============================================================ + +by [Pradeep Kumar][1] · Published November 29, 2017 · Updated November 29, 2017 + + [![wireshark-Debian-9-Ubuntu 16.04 -17.10](https://www.linuxtechi.com/wp-content/uploads/2017/11/wireshark-Debian-9-Ubuntu-16.04-17.10.jpg)][2] + +Wireshark is free and open source, cross platform, GUI based Network packet analyzer that is available for Linux, Windows, MacOS, Solaris etc. It captures network packets in real time & presents them in human readable format. Wireshark allows us to monitor the network packets up to microscopic level. Wireshark also has a command line utility called ‘tshark‘ that performs the same functions as Wireshark but through terminal & not through GUI. + +Wireshark can be used for network troubleshooting, analyzing, software & communication protocol development & also for education purposed. Wireshark uses a library called ‘pcap‘ for capturing the network packets. + +Wireshark comes with a lot of features & some those features are; + +* Support for a hundreds of protocols for inspection, + +* Ability to capture packets in real time & save them for later offline analysis, + +* A number of filters to analyzing data, + +* Data captured can be compressed & uncompressed on the fly, + +* Various file formats for data analysis supported, output can also be saved to XML, CSV, plain text formats, + +* data can be captured from a number of interfaces like ethernet, wifi, bluetooth, USB, Frame relay , token rings etc. + +In this article, we will discuss how to install Wireshark on Ubuntu/Debain machines & will also learn to use Wireshark for capturing network packets. + +#### Installation of Wireshark on Ubuntu 16.04 / 17.10 + +Wireshark is available with default Ubuntu repositories & can be simply installed using the following command. But there might be chances that you will not get the latest version of wireshark. + +``` +linuxtechi@nixworld:~$ sudo apt-get update +linuxtechi@nixworld:~$ sudo apt-get install wireshark -y +``` + +So to install latest version of wireshark we have to enable or configure official wireshark repository. + +Use the beneath commands one after the another to configure repository and to install latest version of Wireshark utility + +``` +linuxtechi@nixworld:~$ sudo add-apt-repository ppa:wireshark-dev/stable +linuxtechi@nixworld:~$ sudo apt-get update +linuxtechi@nixworld:~$ sudo apt-get install wireshark -y +``` + +Once the Wireshark is installed execute the below command so that non-root users can capture live packets of interfaces, + +``` +linuxtechi@nixworld:~$ sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' /usr/bin/dumpcap +``` + +#### Installation of Wireshark on Debian 9 + +Wireshark package and its dependencies are already present in the default debian 9 repositories, so to install latest and stable version of Wireshark on Debian 9, use the following command: + +``` +linuxtechi@nixhome:~$ sudo apt-get update +linuxtechi@nixhome:~$ sudo apt-get install wireshark -y +``` + +During the installation, it will prompt us to configure dumpcap for non-superusers, + +Select ‘yes’ and then hit enter. + + [![Configure-Wireshark-Debian9](https://www.linuxtechi.com/wp-content/uploads/2017/11/Configure-Wireshark-Debian9-1024x542.jpg)][3] + +Once the Installation is completed, execute the below command so that non-root users can also capture the live packets of the interfaces. + +``` +linuxtechi@nixhome:~$ sudo chmod +x /usr/bin/dumpcap +``` + +We can also use the latest source package to install the wireshark on Ubuntu/Debain & many other Linux distributions. + +#### Installing Wireshark using source code on Debian / Ubuntu Systems + +Firstly download the latest source package (which is 2.4.2 at the time for writing this article), use the following command, + +``` +linuxtechi@nixhome:~$ wget https://1.as.dl.wireshark.org/src/wireshark-2.4.2.tar.xz +``` + +Next extract the package & enter into the extracted directory, + +``` +linuxtechi@nixhome:~$ tar -xf wireshark-2.4.2.tar.xz -C /tmp +linuxtechi@nixhome:~$ cd /tmp/wireshark-2.4.2 +``` + +Now we will compile the code with the following commands, + +``` +linuxtechi@nixhome:/tmp/wireshark-2.4.2$ ./configure --enable-setcap-install +linuxtechi@nixhome:/tmp/wireshark-2.4.2$ make +``` + +Lastly install the compiled packages to install Wireshark on the system, + +``` +linuxtechi@nixhome:/tmp/wireshark-2.4.2$ sudo make install +linuxtechi@nixhome:/tmp/wireshark-2.4.2$ sudo ldconfig +``` + +Upon installation a separate group for Wireshark will also be created, we will now add our user to the group so that it can work with wireshark otherwise you might get ‘permission denied‘ error when starting wireshark. + +To add the user to the wireshark group, execute the following command, + +``` +linuxtechi@nixhome:~$ sudo usermod -a -G wireshark linuxtechi +``` + +Now we can start wireshark either from GUI Menu or from terminal with this command, + +``` +linuxtechi@nixhome:~$ wireshark +``` + +#### Access Wireshark on Debian 9 System + + [![Access-wireshark-debian9](https://www.linuxtechi.com/wp-content/uploads/2017/11/Access-wireshark-debian9-1024x664.jpg)][4] + +Click on Wireshark icon + + [![Wireshark-window-debian9](https://www.linuxtechi.com/wp-content/uploads/2017/11/Wireshark-window-debian9-1024x664.jpg)][5] + +#### Access Wireshark on Ubuntu 16.04 / 17.10 + + [![Access-wireshark-Ubuntu](https://www.linuxtechi.com/wp-content/uploads/2017/11/Access-wireshark-Ubuntu-1024x664.jpg)][6] + +Click on Wireshark icon + + [![Wireshark-window-Ubuntu](https://www.linuxtechi.com/wp-content/uploads/2017/11/Wireshark-window-Ubuntu-1024x664.jpg)][7] + +#### Capturing and Analyzing packets + +Once the wireshark has been started, we should be presented with the wireshark window, example is shown above for Ubuntu and Debian system. + + [![wireshark-Linux-system](https://www.linuxtechi.com/wp-content/uploads/2017/11/wireshark-Linux-system.jpg)][8] + +All these are the interfaces from where we can capture the network packets. Based on the interfaces you have on your system, this screen might be different for you. + +We are selecting ‘enp0s3’ for capturing the network traffic for that inteface. After selecting the inteface, network packets for all the devices on our network start to populate (refer to screenshot below) + + [![Capturing-Packet-from-enp0s3-Ubuntu-Wireshark](https://www.linuxtechi.com/wp-content/uploads/2017/11/Capturing-Packet-from-enp0s3-Ubuntu-Wireshark-1024x727.jpg)][9] + +First time we see this screen we might get overwhelmed by the data that is presented in this screen & might have thought how to sort out this data but worry not, one the best features of Wireshark is its filters. + +We can sort/filter out the data based on IP address, Port number, can also used source & destination filters, packet size etc & can also combine 2 or more filters together to create more comprehensive searches. We can either write our filters in ‘Apply a Display Filter‘ tab , or we can also select one of already created rules. To select pre-built filter, click on ‘flag‘ icon , next to ‘Apply a Display Filter‘ tab, + + [![Filter-in-wireshark-Ubuntu](https://www.linuxtechi.com/wp-content/uploads/2017/11/Filter-in-wireshark-Ubuntu-1024x727.jpg)][10] + +We can also filter data based on the color coding, By default, light purple is TCP traffic, light blue is UDP traffic, and black identifies packets with errors , to see what these codes mean, click View -> Coloring Rules, also we can change these codes. + + [![Packet-Colouring-Wireshark](https://www.linuxtechi.com/wp-content/uploads/2017/11/Packet-Colouring-Wireshark-1024x682.jpg)][11] + +After we have the results that we need, we can then click on any of the captured packets to get more details about that packet, this will show all the data about that network packet. + +Wireshark is an extremely powerful tool takes some time to getting used to & make a command over it, this tutorial will help you get started. Please feel free to drop in your queries or suggestions in the comment box below. + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com + +作者:[Pradeep Kumar][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linuxtechi.comhttps://www.linuxtechi.com/author/pradeep/ +[1]:https://www.linuxtechi.com/author/pradeep/ +[2]:https://www.linuxtechi.com/wp-content/uploads/2017/11/wireshark-Debian-9-Ubuntu-16.04-17.10.jpg +[3]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Configure-Wireshark-Debian9.jpg +[4]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Access-wireshark-debian9.jpg +[5]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Wireshark-window-debian9.jpg +[6]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Access-wireshark-Ubuntu.jpg +[7]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Wireshark-window-Ubuntu.jpg +[8]:https://www.linuxtechi.com/wp-content/uploads/2017/11/wireshark-Linux-system.jpg +[9]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Capturing-Packet-from-enp0s3-Ubuntu-Wireshark.jpg +[10]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Filter-in-wireshark-Ubuntu.jpg +[11]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Packet-Colouring-Wireshark.jpg From 76192d694f4554ba30a761dab869089d42955561 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 1 Dec 2017 22:40:32 +0800 Subject: [PATCH 088/344] update --- ...nstall and Use Wireshark on Debian and Ubuntu 16.04_17.10.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md b/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md index 72fb4b5c99..ce2ed658a4 100644 --- a/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md +++ b/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md @@ -168,7 +168,7 @@ via: https://www.linuxtechi.com 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 -[a]:https://www.linuxtechi.comhttps://www.linuxtechi.com/author/pradeep/ +[a]:https://www.linuxtechi.com/author/pradeep/ [1]:https://www.linuxtechi.com/author/pradeep/ [2]:https://www.linuxtechi.com/wp-content/uploads/2017/11/wireshark-Debian-9-Ubuntu-16.04-17.10.jpg [3]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Configure-Wireshark-Debian9.jpg From 5c6fafdb4f57ad75f35cc283eef98c5edcfa4012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=88=E6=B0=B8?= Date: Sat, 2 Dec 2017 00:50:35 +0800 Subject: [PATCH 089/344] Update 20170622 A users guide to links in the Linux filesystem.md --- ... guide to links in the Linux filesystem.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/sources/tech/20170622 A users guide to links in the Linux filesystem.md b/sources/tech/20170622 A users guide to links in the Linux filesystem.md index 3cb59aaacb..5dc6f72e35 100644 --- a/sources/tech/20170622 A users guide to links in the Linux filesystem.md +++ b/sources/tech/20170622 A users guide to links in the Linux filesystem.md @@ -1,28 +1,27 @@ Translating by yongshouzhang - -A user's guide to links in the Linux filesystem +linux 文件链接用户指南 ============================================================ -### Learn how to use links, which make tasks easier by providing access to files from multiple locations in the Linux filesystem directory tree. +### 学习如何使用链接,通过提供对 linux 文件系统多个位置的文件访问,来让日常工作变得轻松 ![A user's guide to links in the Linux filesystem](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/links.png?itok=AumNmse7 "A user's guide to links in the Linux filesystem") Image by : [Paul Lewin][8]. Modified by Opensource.com. [CC BY-SA 2.0][9] -In articles I have written about various aspects of Linux filesystems for Opensource.com, including [An introduction to Linux's EXT4 filesystem][10]; [Managing devices in Linux][11]; [An introduction to Linux filesystems][12]; and [A Linux user's guide to Logical Volume Management][13], I have briefly mentioned an interesting feature of Linux filesystems that can make some tasks easier by providing access to files from multiple locations in the filesystem directory tree. +在我为 opensource.com 写过的关于linux文件系统方方面面的文章中,包括 [An introduction to Linux's EXT4 filesystem][10]; [Managing devices in Linux][11]; [An introduction to Linux filesystems][12]; and [A Linux user's guide to Logical Volume Management][13],我曾简要的提到过linux文件系统一个有趣的特性,它允许用户访问linux文件目录树中多个位置的文件来简化一些任务 -There are two types of Linux filesystem links: hard and soft. The difference between the two types of links is significant, but both types are used to solve similar problems. They both provide multiple directory entries (or references) to a single file, but they do it quite differently. Links are powerful and add flexibility to Linux filesystems because [everything is a file][14]. +linux 文件系统中有两种链接:硬链接和软链接。虽然二者差别显著,但都用来解决相似的问题。它们都提供了对单个文件进行多个目录项的访问(引用),但实现却大为不同。链接的强大功能赋予了 linux 文件系统灵活性,因为[一切即文件][14]。 -More Linux resources +更多 linux 资源 -* [What is Linux?][1] +*   [什么是 linux ?][1] -* [What are Linux containers?][2] +*   [什么是 linux 容器?][2] -* [Download Now: Linux commands cheat sheet][3] +*   [现在下载: linux 命令速查表][3] -* [Advanced Linux commands cheat sheet][4] +*   [linux 高级命令速查表][4] * [Our latest Linux articles][5] From 9e36e008d5a2efad6905ef171fcbee939fcd354f Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 2 Dec 2017 09:37:48 +0800 Subject: [PATCH 090/344] PRF:20171124 How to Install Android File Transfer for Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @wenwensnow 恭喜你,完成了第一篇翻译! --- ...Install Android File Transfer for Linux.md | 49 ++++++++----------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/translated/tech/20171124 How to Install Android File Transfer for Linux.md b/translated/tech/20171124 How to Install Android File Transfer for Linux.md index b93429f509..3cdb372c93 100644 --- a/translated/tech/20171124 How to Install Android File Transfer for Linux.md +++ b/translated/tech/20171124 How to Install Android File Transfer for Linux.md @@ -1,53 +1,46 @@ -Translating by wenwensnow +如何在 Linux 下安装安卓文件传输助手 +=============== -# 如何在Linux下安装安卓文件传输助手 +如果你尝试在 Ubuntu 下连接你的安卓手机,你也许可以试试 Linux 下的安卓文件传输助手。 -如果你尝试在Ubuntu下安装你的安卓手机,你也许可以试试Linux下的安卓文件传输助手 +本质上来说,这个应用是谷歌 macOS 版本的一个克隆。它是用 Qt 编写的,用户界面非常简洁,使得你能轻松在 Ubuntu 和安卓手机之间传输文件和文件夹。 -本质上来说,这个应用是谷歌mac版本的一个复制。它是用Qt编写的,用户界面非常简洁,使得你能轻松在Ubuntu和安卓手机之间传输文件。 +现在,有可能一部分人想知道有什么是这个应用可以做,而 Nautilus(Ubuntu 默认的文件资源管理器)不能做的,答案是没有。 -现在,有可能一部分人想知道有什么是这个应用可以做,而Nautilus(Ubuntu默认的文件资源管理器)不能做的,答案是没有。 +当我将我的 Nexus 5X(记得选择 [媒体传输协议 MTP][7] 选项)连接在 Ubuntu 上时,在 [GVfs][8](LCTT 译注: GNOME 桌面下的虚拟文件系统)的帮助下,我可以打开、浏览和管理我的手机,就像它是一个普通的 U 盘一样。 -当我将我的 Nexus 5X(记得选择[MTP][7] 选项)连接在Ubuntu上时,在[GVfs][8](Gnome桌面下的虚拟文件系统)的帮助下,我可以打开,浏览和管理我的手机, 就像它是一个普通的U盘一样。 +[![Nautilus MTP integration with a Nexus 5X](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg)][9] - [![Nautilus MTP integration with a Nexus 5X](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg)][9] +但是*一些*用户在使用默认的文件管理器时,在 MTP 的某些功能上会出现问题:比如文件夹没有正确加载,创建新文件夹后此文件夹不存在,或者无法在媒体播放器中使用自己的手机。 -但是一些用户在使用默认的文件管理器时,在MTP的某些功能上会出现问题:比如文件夹没有正确加载,创建新文件夹后此文件夹不存在,或者无法在媒体播放器中使用自己的手机。 - -这就是要为Linux系统用户设计一个安卓文件传输助手应用的原因。将这个应用当做将MTP设备安装在Linux下的另一种选择。如果你使用Linux下的默认应用时一切正常,你也许并不需要尝试使用它 (除非你真的很想尝试新鲜事物)。 +这就是要为 Linux 系统用户设计一个安卓文件传输助手应用的原因,将这个应用当做将 MTP 设备安装在 Linux 下的另一种选择。如果你使用 Linux 下的默认应用时一切正常,你也许并不需要尝试使用它 (除非你真的很想尝试新鲜事物)。 ![Android File Transfer Linux App](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/android-file-transfer-for-linux-750x662.jpg) -app特点: +该 app 特点: *   简洁直观的用户界面 - -*   支持文件拖放功能(从Linux系统到手机) - -*   支持批量下载 (从手机到Linux系统) - +*   支持文件拖放功能(从 Linux 系统到手机) +*   支持批量下载 (从手机到 Linux系统) *   显示传输进程对话框 - -*   FUSE模块支持 - +*   FUSE 模块支持 *   没有文件大小限制 - *   可选命令行工具 -### Ubuntu下安装安卓手机文件助手的步骤 +### Ubuntu 下安装安卓手机文件助手的步骤 以上就是对这个应用的介绍,下面是如何安装它的具体步骤。 -这有一个[PPA](个人软件包集)源为Ubuntu 14.04 LTS(长期支持版本),16.04LTS 和 Ubuntu17.10 提供可用应用 +这有一个 [PPA](个人软件包集)源为 Ubuntu 14.04 LTS、16.04 LTS 和 Ubuntu 17.10 提供可用应用。 -为了将这一PPA加入你的软件资源列表中,执行这条命令: +为了将这一 PPA 加入你的软件资源列表中,执行这条命令: ``` sudo add-apt-repository ppa:samoilov-lex/aftl-stable ``` -接着,为了在Ubuntu下安装Linux版本的安卓文件传输助手,执行: +接着,为了在 Ubuntu 下安装 Linux版本的安卓文件传输助手,执行: ``` sudo apt-get update && sudo apt install android-file-transfer @@ -57,15 +50,15 @@ sudo apt-get update && sudo apt install android-file-transfer 你会在你的应用列表中发现这一应用的启动图标。 -在你启动这一应用之前,要确保没有其他应用(比如Nautilus)已经加载了你的手机.如果其他应用正在使用你的手机,就会显示“无法找到MTP设备”。为了解决这一问题,将你的手机从Nautilus(或者任何正在使用你的手机的应用)上移除,然后再重新启动安卓文件传输助手。 +在你启动这一应用之前,要确保没有其他应用(比如 Nautilus)已经挂载了你的手机。如果其它应用正在使用你的手机,就会显示“无法找到 MTP 设备”。要解决这一问题,将你的手机从 Nautilus(或者任何正在使用你的手机的应用)上移除,然后再重新启动安卓文件传输助手。 -------------------------------------------------------------------------------- via: http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux -作者:[ JOEY SNEDDON ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +作者:[JOEY SNEDDON][a] +译者:[wenwensnow](https://github.com/wenwensnow) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 44890b335e26807c59e4b4201d4411e2f137f0a9 Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 2 Dec 2017 09:46:23 +0800 Subject: [PATCH 091/344] PRF:20171130 Search DuckDuckGo from the Command Line.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @yixunx 恭喜你完成了第一篇翻译,但是这个流程有点问题:你不应该翻译别人(@geekpi)申领的文章,而且是没有经过申领。 @Vic020 你合并这个 PR 的时候没有注意到这个情况 @geekpi 这是我们的新译者,可能对流程还不熟悉,请你体谅一下,可能造成了你的合并冲突和无用功。 --- ...Search DuckDuckGo from the Command Line.md | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/translated/tech/20171130 Search DuckDuckGo from the Command Line.md b/translated/tech/20171130 Search DuckDuckGo from the Command Line.md index d550fa75b5..48b6fdd830 100644 --- a/translated/tech/20171130 Search DuckDuckGo from the Command Line.md +++ b/translated/tech/20171130 Search DuckDuckGo from the Command Line.md @@ -1,9 +1,11 @@ -# 在命令行中使用DuckDuckGo搜索 - ![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/duckduckgo.png) +在命令行中使用 DuckDuckGo 搜索 +============= -此前我们介绍了[如何在命令行中使用 Google 搜索][3]。许多读者反馈说他们平时使用 [Duck Duck Go][4],一个功能强大而且保密性很强的搜索引擎。 +![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/duckduckgo.png) -正巧,最近出现了一款能够从命令行搜索 DuckDuckGo 的工具。它叫做 ddgr(我把它读作 _dodger_),非常好用。 +此前我们介绍了[如何在命令行中使用 Google 搜索][3]。许多读者反馈说他们平时使用 [Duck Duck Go][4],这是一个功能强大而且保密性很强的搜索引擎。 + +正巧,最近出现了一款能够从命令行搜索 DuckDuckGo 的工具。它叫做 ddgr(我把它读作 “dodger”),非常好用。 像 [Googler][7] 一样,ddgr 是一个完全开源而且非官方的工具。没错,它并不属于 DuckDuckGo。所以,如果你发现它返回的结果有些奇怪,请先询问这个工具的开发者,而不是搜索引擎的开发者。 @@ -11,30 +13,23 @@ ![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/ddgr-gif.gif) -[DuckDuckGo Bangs(DuckDuckGo 快捷搜索)][8] 可以帮助你轻易地在 DuckDuckGo 上找到想要的信息(甚至 _本网站_ 都有快捷搜索)。ddgr 非常忠实地呈现了这个功能。 +[DuckDuckGo Bangs(DuckDuckGo 快捷搜索)][8] 可以帮助你轻易地在 DuckDuckGo 上找到想要的信息(甚至 _本网站 omgubuntu_ 都有快捷搜索)。ddgr 非常忠实地呈现了这个功能。 和网页版不同的是,你可以更改每页返回多少结果。这比起每次查询都要看三十多条结果要方便一些。默认界面经过了精心设计,在不影响可读性的情况下尽量减少了占用空间。 `ddgr` 有许多功能和亮点,包括: * 更改搜索结果数 - * 支持 Bash 自动补全 - * 使用 DuckDuckGo Bangs - * 在浏览器中打开链接 - * ”手气不错“选项 - * 基于时间、地区、文件类型等的筛选功能 - * 极少的依赖项 - 你可以从 Github 的项目页面上下载支持各种系统的 `ddgr`: -[从 Github 下载 “ddgr”][9] +- [从 Github 下载 “ddgr”][9] 另外,在 Ubuntu 16.04 LTS 或更新版本中,你可以使用 PPA 安装 ddgr。这个仓库由 ddgr 的开发者维护。如果你想要保持在最新版本的话,推荐使用这种方式安装。 @@ -44,9 +39,6 @@ ``` sudo add-apt-repository ppa:twodopeshaggy/jarun -``` - -``` sudo apt-get update ``` @@ -89,7 +81,7 @@ via: http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app 作者:[JOEY SNEDDON][a] 译者:[yixunx](https://github.com/yixunx) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 7e1337cf4adee8590a144a5fa6c3953992c2454b Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 2 Dec 2017 10:13:12 +0800 Subject: [PATCH 092/344] PRF:20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @wangy325 恭喜你,完成了第一篇翻译。翻译很用心! --- ...and Certification Are Key for SysAdmins.md | 52 ++++++++----------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/translated/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md b/translated/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md index 55a42f9289..9b6a4f242c 100644 --- a/translated/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md +++ b/translated/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md @@ -1,71 +1,65 @@ - - -开源云技能认证—系统管理员的核心竞争力 +开源云技能认证:系统管理员的核心竞争力 ========= ![os jobs](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/open-house-sysadmin.jpg?itok=i5FHc3lu "os jobs") -[2017年开源工作报告][1](以下简称“报告”)显示,具有开源云技术认证的系统管理员往往能获得更高的薪酬。报告遵守[CC0][2] *译注1*许可协议。 +> [2017年开源工作报告][1](以下简称“报告”)显示,具有开源云技术认证的系统管理员往往能获得更高的薪酬。 -> 译注1:CC0,即知识/版权共享协议(Creative Commons Zero),任何人都可拷贝,修改,发布,甚至商用作品而无须征求作者许可 -报告调查的受访者中,53%认为系统管理员是雇主们最期望被填补的职位空缺之一,因此,技术娴熟的系统管理员更受青睐而收获高薪职位,但这一职位,并没想象中那么容易胜任。 +报告调查的受访者中,53% 认为系统管理员是雇主们最期望被填补的职位空缺之一,因此,技术娴熟的系统管理员更受青睐而收获高薪职位,但这一职位,并没想象中那么容易填补。 系统管理员主要负责服务器和其他电脑操作系统的安装、服务支持和维护,及时处理服务中断和预防其他问题的出现。 -总的来说,今年的报告指出开源领域人才需求最大的有开源云(47%),应用开发(44%),大数据(43%),开发运营和安全(42%) +总的来说,今年的报告指出开源领域人才需求最大的有开源云(47%),应用开发(44%),大数据(43%),开发运营和安全(42%)。 -此外,报告对人事经理的调查显示,58%期望招揽更多的开源人才,67%认为开源人才的需求增长会比业内其他领域更甚。有些单位视开源人才为招聘最优选则,它们招聘的开源人才较上年增长了2个百分点。 +此外,报告对人事经理的调查显示,58% 期望招揽更多的开源人才,67% 认为开源人才的需求增长会比业内其他领域更甚。有些单位视开源人才为招聘最优选则,它们招聘的开源人才较上年增长了 2 个百分点。 -同时,89%的人事经理认为很难找到颇具天赋的开源人才。 +同时,89% 的人事经理认为很难找到颇具天赋的开源人才。 ### 为什么要获取认证 -报告显示,对系统管理员的需求刺激着人事经理为53%的组织/机构提供正规的培训和专业技术认证,而这一比例去年为47%。 +报告显示,对系统管理员的需求刺激着人事经理为 53% 的组织/机构提供正规的培训和专业技术认证,而这一比例去年为 47%。 -对系统管理方面感兴趣的IT人才考虑获取Linux认证已成为行业规律。随便查看几个知名的招聘网站,你就能发现:[CompTIA Linux+][3]认证是入门Linux系统管理员的必备(最高)认证;如果想胜任高级别的系统管理员职位,获取[红帽认证工程师(RHCE)][4]和[红帽认证系统管理员(RHCSA)][5]则是不可或缺的。 +对系统管理方面感兴趣的 IT 人才考虑获取 Linux 认证已成为行业规律。随便查看几个知名的招聘网站,你就能发现:[CompTIA Linux+][3] 认证是入门级 Linux 系统管理员的最高认证;如果想胜任高级别的系统管理员职位,获取[红帽认证工程师(RHCE)][4]和[红帽认证系统管理员(RHCSA)][5]则是不可或缺的。 -戴士(Dice)[2017技术行业薪资调查][6]显示,2016年系统管理员的薪水为79,538美元,较上年下降了0.8%;系统架构师的薪水为125,946美元,同比下降4.7%。尽管如此,该调查发现“高水平专业人才仍最受欢迎,特别是那些精通支持产业转型发展所需技术的人才”。 +戴士(Dice)[2017 技术行业薪资调查][6]显示,2016 年系统管理员的薪水为 79,538 美元,较上年下降了 0.8%;系统架构师的薪水为 125,946 美元,同比下降 4.7%。尽管如此,该调查发现“高水平专业人才仍最受欢迎,特别是那些精通支持产业转型发展所需技术的人才”。 -在开源技术方面,HBase(一个开源的分布式数据库)技术人才的薪水在戴士2017技术行业薪资调查中排第一。在计算机网络和数据库领域,掌握OpenVSM操作系统技术也能获得高薪。 +在开源技术方面,HBase(一个开源的分布式数据库)技术人才的薪水在戴士 2017 技术行业薪资调查中排第一。在计算机网络和数据库领域,掌握 OpenVMS 操作系统技术也能获得高薪。 ### 成为出色的系统管理员 -出色的系统管理员须在问题出现时马上处理,这意味着你必须时刻准备应对可能出现的状况。这个职位追求“零责备的,精益的,流程或技术上交互式改进的”思维方式和善于自我完善的人格,成为一个系统管理员意味着“你必将与开源软件如Linux,BSD甚至开源Solaris等结下不解的羁绊”,Paul English*译注2*在[开源][7]上发文指出。 +出色的系统管理员须在问题出现时马上处理,这意味着你必须时刻准备应对可能出现的状况。这个职位追求“零责备的、精益的、流程或技术上交互式改进的”思维方式和善于自我完善的人格,成为一个系统管理员意味着“你必将与开源软件如 Linux、BSD 甚至开源 Solaris 等结下不解之缘”,Paul English ^译注1 在 [opensource.com][7] 上发文指出。 -Paul English认为,现在的系统管理员较以前而言,要更多地与软件打交道,而且要能够编写脚本来协助系统管理。 +Paul English 认为,现在的系统管理员较以前而言,要更多地与软件打交道,而且要能够编写脚本来协助系统管理。 ->译注2:Paul English,计算机科学学士,UNIX/Linux 系统管理员,PreOS Security Inc.公司CEO,2015-2017年于为推动系统管理员发展实践的非盈利组织——专业系统管理员联盟(League of Professional System Administrator)担任董事会成员。 +>译注1:Paul English,计算机科学学士,UNIX/Linux 系统管理员,PreOS Security Inc. 公司 CEO,2015-2017 年于为推动系统管理员发展实践的非盈利组织——专业系统管理员联盟League of Professional System Administrator担任董事会成员。 -### 展望2018 +### 展望 2018 - [Robert Half 2018年技术人才薪资导览][8]预测2018年北美地区许多单位将聘用大量系统管理方面的专业人才,同时个人软实力和领导力水平作为优秀人才的考量因素,越来越受到重视。 +[Robert Half 2018 年技术人才薪资导览][8]预测 2018 年北美地区许多单位将聘用大量系统管理方面的专业人才,同时个人软实力和领导力水平作为优秀人才的考量因素,越来越受到重视。 - 报告指出:“良好的聆听能力和批判性思维能力对于理解和解决用户的问题和担忧至关重要,也是IT从业者必须具备的重要技能,特别是从事服务台和桌面支持工作相关的技术人员。” +该报告指出:“良好的聆听能力和批判性思维能力对于理解和解决用户的问题和担忧至关重要,也是 IT 从业者必须具备的重要技能,特别是从事服务台和桌面支持工作相关的技术人员。” - 这与[Linux基金会][9] *译注3* 提出的不同阶段的系统管理员必备技能相一致,都强调了强大的分析能力和快速处理问题的能力。 +这与[Linux基金会][9]^译注2 提出的不同阶段的系统管理员必备技能相一致,都强调了强大的分析能力和快速处理问题的能力。 - >译注3:Linux基金会(The Linux Foundation),成立于2000年,致力于围绕开源项目构建可持续发展的生态系统,以加速开源项目的技术开发和商业应用;它是世界上最大的开源非盈利组织,在推广、保护和推进Linux发展,协同开发,维护“历史上最大的共享资源”上功勋卓越。 - - 如果想逐渐爬上系统管理员职位的金字塔上层,还应该对系统配置的结构化方法充满兴趣;且拥有解决系统安全问题的经验;用户身份验证管理的经验;与非技术人员进行非技术交流的能力;以及优化系统以满足最新的安全需求的能力。 - - [下载][10]*译注4*2017年开源工作报告全文,以获取更多信息。 - ->译注4:可能需要科学上网 +>译注2:Linux 基金会The Linux Foundation,成立于 2000 年,致力于围绕开源项目构建可持续发展的生态系统,以加速开源项目的技术开发和商业应用;它是世界上最大的开源非盈利组织,在推广、保护和推进 Linux 发展,协同开发,维护“历史上最大的共享资源”上功勋卓越。 +如果想逐渐爬上系统管理员职位的金字塔上层,还应该对系统配置的结构化方法充满兴趣;且拥有解决系统安全问题的经验;用户身份验证管理的经验;与非技术人员进行非技术交流的能力;以及优化系统以满足最新的安全需求的能力。 +- [下载][10]2017年开源工作报告全文,以获取更多信息。 ----------------------- via: https://www.linux.com/blog/open-source-cloud-skills-and-certification-are-key-sysadmins -作者:[ ][a] +作者:[linux.com][a] 译者:[wangy325](https://github.com/wangy325) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 +[a]:https://www.linux.com/blog/open-source-cloud-skills-and-certification-are-key-sysadmins [1]:https://www.linuxfoundation.org/blog/2017-jobs-report-highlights-demand-open-source-skills/ [2]:https://www.linux.com/licenses/category/creative-commons-zero [3]:https://certification.comptia.org/certifications/linux?tracking=getCertified/certifications/linux.aspx From b30c38ec59c1151abdd4a80a34b806c409428dbd Mon Sep 17 00:00:00 2001 From: filefi Date: Sat, 2 Dec 2017 13:31:59 +0800 Subject: [PATCH 093/344] Update 20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【申请翻译】How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md --- ...stall and Use Wireshark on Debian and Ubuntu 16.04_17.10.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md b/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md index ce2ed658a4..d3ba75da14 100644 --- a/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md +++ b/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md @@ -1,3 +1,6 @@ +Translating by filefi + + How to Install and Use Wireshark on Debian 9 / Ubuntu 16.04 / 17.10 ============================================================ From 04dacceefc624085b61aca9fdc1c30a3e2e7432e Mon Sep 17 00:00:00 2001 From: darksun Date: Sat, 2 Dec 2017 14:54:30 +0800 Subject: [PATCH 094/344] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Undistract-me=20:?= =?UTF-8?q?=20Get=20Notification=20When=20Long=20Running=20Terminal=20Comm?= =?UTF-8?q?ands=20Complete?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Long Running Terminal Commands Complete.md | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md diff --git a/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md b/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md new file mode 100644 index 0000000000..e823acbe44 --- /dev/null +++ b/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md @@ -0,0 +1,154 @@ +Undistract-me : Get Notification When Long Running Terminal Commands Complete +============================================================ + +by [sk][2] · November 30, 2017 + +![Undistract-me](https://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2-720x340.png) + +A while ago, we published how to [get notification when a Terminal activity is done][3]. Today, I found out a similar utility called “undistract-me” that notifies you when long running terminal commands complete. Picture this scenario. You run a command that takes a while to finish. In the mean time, you check your facebook and get so involved in it. After a while, you remembered that you ran a command few minutes ago. You go back to the Terminal and notice that the command has already finished. But you have no idea when the command is completed. Have you ever been in this situation? I bet most of you were in this situation many times. This is where “undistract-me” comes in help. You don’t need to constantly check the terminal to see if a command is completed or not. Undistract-me utility will notify you when a long running command is completed. It will work on Arch Linux, Debian, Ubuntu and other Ubuntu-derivatives. + +#### Installing Undistract-me + +Undistract-me is available in the default repositories of Debian and its variants such as Ubuntu. All you have to do is to run the following command to install it. + +``` +sudo apt-get install undistract-me +``` + +The Arch Linux users can install it from AUR using any helper programs. + +Using [Pacaur][4]: + +``` +pacaur -S undistract-me-git +``` + +Using [Packer][5]: + +``` +packer -S undistract-me-git +``` + +Using [Yaourt][6]: + +``` +yaourt -S undistract-me-git +``` + +Then, run the following command to add “undistract-me” to your Bash. + +``` +echo 'source /etc/profile.d/undistract-me.sh' >> ~/.bashrc +``` + +Alternatively you can run this command to add it to your Bash: + +``` +echo "source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install" >> .bashrc +``` + +If you are in Zsh shell, run this command: + +``` +echo "source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install" >> .zshrc +``` + +Finally update the changes: + +For Bash: + +``` +source ~/.bashrc +``` + +For Zsh: + +``` +source ~/.zshrc +``` + +#### Configure Undistract-me + +By default, Undistract-me will consider any command that takes more than 10 seconds to complete as a long-running command. You can change this time interval by editing /usr/share/undistract-me/long-running.bash file. + +``` +sudo nano /usr/share/undistract-me/long-running.bash +``` + +Find “LONG_RUNNING_COMMAND_TIMEOUT” variable and change the default value (10 seconds) to something else of your choice. + + [![](http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-1.png)][7] + +Save and close the file. Do not forget to update the changes: + +``` +source ~/.bashrc +``` + +Also, you can disable notifications for particular commands. To do so, find the “LONG_RUNNING_IGNORE_LIST” variable and add the commands space-separated like below. + +By default, the notification will only show if the active window is not the window the command is running in. That means, it will notify you only if the command is running in the background Terminal window. If the command is running in active window Terminal, you will not be notified. If you want undistract-me to send notifications either the Terminal window is visible or in the background, you can set IGNORE_WINDOW_CHECK to 1 to skip the window check. + +The other cool feature of Undistract-me is you can set audio notification along with visual notification when a command is done. By default, it will only send a visual notification. You can change this behavior by setting the variable UDM_PLAY_SOUND to a non-zero integer on the command line. However, your Ubuntu system should have pulseaudio-utils and sound-theme-freedesktop utilities installed to enable this functionality. + +Please remember that you need to run the following command to update the changes made. + +For Bash: + +``` +source ~/.bashrc +``` + +For Zsh: + +``` +source ~/.zshrc +``` + +It is time to verify if this really works. + +#### Get Notification When Long Running Terminal Commands Complete + +Now, run any command that takes longer than 10 seconds or the time duration you defined in Undistract-me script. + +I ran the following command on my Arch Linux desktop. + +``` +sudo pacman -Sy +``` + +This command took 32 seconds to complete. After the completion of the above command, I got the following notification. + + [![](http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2.png)][8] + +Please remember Undistract-me script notifies you only if the given command took more than 10 seconds to complete. If the command is completed in less than 10 seconds, you will not be notified. Of course, you can change this time interval settings as I described in the Configuration section above. + +I find this tool very useful. It helped me to get back to the business after I completely lost in some other tasks. I hope this tool will be helpful to you too. + +More good stuffs to come. Stay tuned! + +Cheers! + +Resource: + +* [Undistract-me GitHub Repository][1] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/undistract-get-notification-long-running-terminal-commands-complete/ + +作者:[ ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://github.com/jml/undistract-me +[2]:https://www.ostechnix.com/author/sk/ +[3]:https://www.ostechnix.com/get-notification-terminal-task-done/ +[4]:https://www.ostechnix.com/install-pacaur-arch-linux/ +[5]:https://www.ostechnix.com/install-packer-arch-linux-2/ +[6]:https://www.ostechnix.com/install-yaourt-arch-linux/ +[7]:http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-1.png +[8]:http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2.png From 43547f1f71c845662f0ed2a0ae67d7e1fda7c19d Mon Sep 17 00:00:00 2001 From: darksun Date: Sat, 2 Dec 2017 14:57:25 +0800 Subject: [PATCH 095/344] =?UTF-8?q?=E8=A1=A5=E5=85=85author=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Notification When Long Running Terminal Commands Complete.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md b/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md index e823acbe44..04f07c308c 100644 --- a/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md +++ b/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md @@ -137,7 +137,7 @@ Resource: via: https://www.ostechnix.com/undistract-get-notification-long-running-terminal-commands-complete/ -作者:[ ][a] +作者:[sk][a] 译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) From 53cb9dfea6cfd18c3f3e4f1eb851a791c69d327a Mon Sep 17 00:00:00 2001 From: filefi Date: Sat, 2 Dec 2017 15:03:39 +0800 Subject: [PATCH 096/344] Create 20171202 Scrot Linux command-line screen grabs made simple --- ...inux command-line screen grabs made simple | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 sources/tech/20171202 Scrot Linux command-line screen grabs made simple diff --git a/sources/tech/20171202 Scrot Linux command-line screen grabs made simple b/sources/tech/20171202 Scrot Linux command-line screen grabs made simple new file mode 100644 index 0000000000..979ed86b3c --- /dev/null +++ b/sources/tech/20171202 Scrot Linux command-line screen grabs made simple @@ -0,0 +1,72 @@ +Translating by filefi + +# Scrot: Linux command-line screen grabs made simple + +by [Scott Nesbitt][a] · November 30, 2017 + +> Scrot is a basic, flexible tool that offers a number of handy options for taking screen captures from the Linux command line. + +[![Original photo by Rikki Endsley. CC BY-SA 4.0](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/community-penguins-osdc-lead.png?itok=BmqsAF4A)][1] + + + +There are great tools on the Linux desktop for taking screen captures, such as [KSnapshot][2] and [Shutter][3]. Even the simple utility that comes with the GNOME desktop does a pretty good job of capturing screens. But what if you rarely need to take screen captures? Or you use a Linux distribution without a built-in capture tool, or an older computer with limited resources? + +Turn to the command line and a little utility called [Scrot][4]. It does a fine job of taking simple screen captures, and it includes a few features that might surprise you. + +### Getting started with Scrot +Many Linux distributions come with Scrot already installed—to check, type `which scrot`. If it isn't there, you can install Scrot using your distro's package manager. If you're willing to compile the code, grab it [from GitHub][5]. + +To take a screen capture, crack open a terminal window and type `scrot [filename]`, where `[filename]` is the name of file to which you want to save the image (for example, `desktop.png`). If you don't include a name for the file, Scrot will create one for you, such as `2017-09-24-185009_1687x938_scrot.png`. (That filename isn't as descriptive it could be, is it? That's why it's better to add one to the command.) + +Running Scrot with no options takes a screen capture of your entire desktop. If you don't want to do that, Scrot lets you focus on smaller portions of your screen. + +### Taking a screen capture of a single window + +Tell Scrot to take a screen capture of a single window by typing `scrot -u [filename]`. + +The `-u` option tells Scrot to grab the window currently in focus. That's usually the terminal window you're working in, which might not be the one you want. + +To grab another window on your desktop, type `scrot -s [filename]`. + +The `-s` option lets you do one of two things: + +* select an open window, or + +* draw a rectangle around a window or a portion of a window to capture it. + +You can also set a delay, which gives you a little more time to select the window you want to capture. To do that, type `scrot -u -d [num] [filename]`. + +The `-d` option tells Scrot to wait before grabbing the window, and `[num]` is the number of seconds to wait. Specifying `-d 5` (wait five seconds) should give you enough time to choose a window. + +### More useful options + +Scrot offers a number of additional features (most of which I never use). The ones I find most useful include: + +* `-b` also grabs the window's border + +* `-t` grabs a window and creates a thumbnail of it. This can be useful when you're posting screen captures online. + +* `-c` creates a countdown in your terminal when you use the `-d` option. + +To learn about Scrot's other options, check out the its documentation by typing `man scrot` in a terminal window, or [read it online][6]. Then start snapping images of your screen. + +It's basic, but Scrot gets the job done nicely. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot + +作者:[Scott Nesbitt][a] +译者:[filefi](https://github.com/filefi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/scottnesbitt +[1]:https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/community-penguins-osdc-lead.png?itok=BmqsAF4A +[2]:https://www.kde.org/applications/graphics/ksnapshot/ +[3]:https://launchpad.net/shutter +[4]:https://github.com/dreamer/scrot +[5]:http://manpages.ubuntu.com/manpages/precise/man1/scrot.1.html +[6]:https://github.com/dreamer/scrot From 37918a23787d8bbe185e741dd28c67e9db12869b Mon Sep 17 00:00:00 2001 From: geekpi Date: Sat, 2 Dec 2017 18:19:16 +0800 Subject: [PATCH 097/344] tranlsating --- ...Notification When Long Running Terminal Commands Complete.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md b/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md index 04f07c308c..46afe9b893 100644 --- a/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md +++ b/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md @@ -1,3 +1,5 @@ +translating---geekpi + Undistract-me : Get Notification When Long Running Terminal Commands Complete ============================================================ From 9e364e66e6b4ae58ea230598d9d585e49492c329 Mon Sep 17 00:00:00 2001 From: nodekey Date: Sat, 2 Dec 2017 20:15:32 +0800 Subject: [PATCH 098/344] translated --- ...Could Be Your New Favorite Container OS.md | 149 ------------------ ...Could Be Your New Favorite Container OS.md | 147 +++++++++++++++++ 2 files changed, 147 insertions(+), 149 deletions(-) delete mode 100644 sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md create mode 100644 translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md diff --git a/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md deleted file mode 100644 index 147a2266cc..0000000000 --- a/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md +++ /dev/null @@ -1,149 +0,0 @@ -KeyLD Translating - -Photon Could Be Your New Favorite Container OS -============================================================ - - -![Photon OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon-linux.jpg?itok=jUFHPR_c "Photon OS") -Jack Wallen says Photon OS is an outstanding platform, geared specifically for containers.[Creative Commons Zero][5]Pixabay - -Containers are all the rage, and with good reason. [As discussed previously][13], containers allow you to quickly and easily deploy new services and applications onto your network, without requiring too much in the way of added system resources. Containers are more cost-effective than using dedicated hardware or virtual machines, and they’re easier to update and reuse. - -Best of all, containers love Linux (and vice versa). Without much trouble or time, you can get a Linux server up and running with [Docker][14] and deploying containers. But, which Linux distribution is best suited for the deployment of your containers? There are a _lot_  of options. You could go with a standard Ubuntu Server platform (which makes installing Docker and deploying containers incredibly easy), or you could opt for a lighter weight distribution — one geared specifically for the purpose of deploying containers. - -One such distribution is [Photon][15]. This particular platform was created in 2005 by [VMware][16]; it includes the Docker daemon and works with container frameworks, such as Mesos and Kubernetes. Photon is optimized to work with [VMware vSphere][17], but it can be used on bare metal, [Microsoft Azure][18], [Google Compute Engine][19], [Amazon Elastic Compute Cloud][20], or [VirtualBox][21]. - -Photon manages to stay slim by only installing what is absolutely necessary to run the Docker daemon. In the end, the distribution comes in around 300 MB. This is just enough Linux make it all work. The key features to Photon are: - -* Kernel tuned for performance. - -* Kernel is hardened according to the [Kernel Self-Protection Project][6] (KSPP). - -* All installed packages are built with hardened security flags. - -* Operating system boots with validated trust. - -* Photon management daemon manages firewall, network, packages, and users on remote Photon OS machines. - -* Support for persistent volumes. - -* [Project Lightwave][7] integration. - -* Timely security patches and updates. - -Photon can be used via [ISO][22], [OVA][23], [Amazon Machine Image][24], [Google Compute Engine image][25], and [Azure VHD][26]. I’ll show you how to install Photon on VirtualBox, using an ISO image. The installation takes about five minutes and, in the end, you’ll have a virtual machine, ready to deploy containers. - -### Creating the virtual machine - -Before you deploy that first container, you have to create the virtual machine and install Photon. To do this, open up VirtualBox and click the New button. Walk through the Create Virtual Machine wizard (giving Photon the necessary resources, based on the usage you predict the container server will need). Once you’ve created the virtual machine, you need to first make a change to the settings. Select the newly created virtual machine (in the left pane of the VirtualBox main window) and then click Settings. In the resulting window, click on Network (from the left navigation). - -In the Networking window (Figure 1), you need to change the Attached to drop-down to Bridged Adapter. This will ensure your Photon server is reachable from your network. Once you’ve made that change, click OK. - -### [photon_0.jpg][8] - -![change settings](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_0.jpg?itok=Q0yhOhsZ "change settings") -Figure 1: Changing the VirtualBox network settings for Photon.[Used with permission][1] - -Select your Photon virtual machine from the left navigation and then click Start. You will be prompted to locate and attach the IOS image. Once you’ve done that, Photon will boot up and prompt you to hit Enter to begin the installation. The installation is ncurses based (there is no GUI), but it’s incredibly simple. - -In the next screen (Figure 2), you will be asked if you want to do a Minimal, Full, or OSTree Server. I opted to go the Full route. Select whichever option you require and hit enter. - -### [photon_1.jpg][9] - -![installation type](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_1.jpg?itok=OdnMVpaA "installation type") -Figure 2: Selecting your installation type.[Used with permission][2] - -In the next window, select the disk that will house Photon. Since we’re installing this as a virtual machine, there will be only one disk listed (Figure 3). Tab down to Auto and hit Enter on your keyboard. The installation will then require you to type (and verify) an administrator password. Once you’ve done that, the installation will begin and finish in less than five minutes. - -### [photon_2.jpg][10] - -![Photon ](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_2.jpg?itok=QL1Rs-PH "Photon") -Figure 3: Selecting your hard disk for the Photon installation.[Used with permission][3] - -Once the installation completes, reboot the virtual machine and log in with the username root and the password you created during installation. You are ready to start working. - -Before you begin using Docker on Photon, you’ll want to upgrade the platform. Photon uses the _yum_ package manager, so login as root and issue the command  _yum update_ .If there are any updates available, you’ll be asked to okay the process (Figure 4). - -### [photon_3.jpg][11] - -![Updating](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_3.jpg?itok=vjqrspE2 "Updating") -Figure 4: Updating Photon.[Used with permission][4] - -Usage - -As I mentioned, Photon comes with everything you need to deploy containers or even create a Kubernetes cluster. However, out of the box, there are a few things you’ll need to do. The first thing is to enable the Docker daemon to run at start. To do this, issue the commands: - -``` -systemctl start docker - -systemctl enable docker -``` - -Now we need to create a standard user, so we’re not running the docker command as root. To do this, issue the following commands: - -``` -useradd -m USERNAME - -passwd USERNAME -``` - -Where USERNAME is the name of the user to add. - -Next we need to add the new user to the  _docker_ group with the command: - -``` -usermod -a -G docker USERNAME -``` - -Where USERNAME is the name of the user just created. - -Log out as the root user and log back in as the newly created user. You can now work with the  _docker _ command without having to make use of  _sudo_  or switching to the root user. Pull down an image from Docker Hub and start deploying containers. - -### An outstanding container platform - -Photon is, without a doubt, an outstanding platform, geared specifically for containers. Do note that Photon is an open source project, so there is no paid support to be had. If you find yourself having trouble with Photon, hop on over to the [Issues tab in the Photon Project’s Github page][27], where you can read and post about issues. And if you’re interested in forking Photon, you’ll find the source code on the project’s [official Github page][28]. - -Give Photon a try and see if it doesn’t make deploying Docker containers and/or Kubernetes clusters significantly easier. - - _Learn more about Linux through the free ["Introduction to Linux" ][29]course from The Linux Foundation and edX._ - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2017/11/photon-could-be-your-new-favorite-container-os - -作者:[JACK WALLEN ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/jlwallen -[1]:https://www.linux.com/licenses/category/used-permission -[2]:https://www.linux.com/licenses/category/used-permission -[3]:https://www.linux.com/licenses/category/used-permission -[4]:https://www.linux.com/licenses/category/used-permission -[5]:https://www.linux.com/licenses/category/creative-commons-zero -[6]:https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project -[7]:http://vmware.github.io/lightwave/ -[8]:https://www.linux.com/files/images/photon0jpg -[9]:https://www.linux.com/files/images/photon1jpg -[10]:https://www.linux.com/files/images/photon2jpg -[11]:https://www.linux.com/files/images/photon3jpg -[12]:https://www.linux.com/files/images/photon-linuxjpg -[13]:https://www.linux.com/learn/intro-to-linux/2017/11/how-install-and-use-docker-linux -[14]:https://www.docker.com/ -[15]:https://vmware.github.io/photon/ -[16]:https://www.vmware.com/ -[17]:https://www.vmware.com/products/vsphere.html -[18]:https://azure.microsoft.com/ -[19]:https://cloud.google.com/compute/ -[20]:https://aws.amazon.com/ec2/ -[21]:https://www.virtualbox.org/ -[22]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[23]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[24]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[25]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[26]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[27]:https://github.com/vmware/photon/issues -[28]:https://github.com/vmware/photon -[29]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md new file mode 100644 index 0000000000..32d035334d --- /dev/null +++ b/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md @@ -0,0 +1,147 @@ +Photon也许能成为你最喜爱的容器操作系统 +============================================================ + +![Photon OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon-linux.jpg?itok=jUFHPR_c "Photon OS") + +Phonton OS专注于容器,是一个非常出色的平台。 —— Jack Wallen + +容器在当下的火热,并不是没有原因的。正如[之前][13]讨论的,容器可以使您轻松快捷地将新的服务与应用部署到您的网络上,而且并不耗费太多的系统资源。比起专用硬件和虚拟机,容器都是更加划算的,除此之外,他们更容易更新与重用。 + +更重要的是,容器喜欢Linux(反之亦然)。不需要太多时间和麻烦,你就可以启动一台Linux服务器,运行[Docker][14],再是部署容器。但是,哪种Linux发行版最适合部署容器呢?我们的选择很多。你可以使用标准的Ubuntu服务器平台(更容易安装Docker并部署容器)或者是更轻量级的发行版 —— 专门用于部署容器。 + +[Photon][15]就是这样的一个发行版。这个特殊的版本是由[VMware][16]于2005年创建的,它包含了Docker的守护进程,并与容器框架(如Mesos和Kubernetes)一起使用。Photon经过优化可与[VMware vSphere][17]协同工作,而且可用于裸机,[Microsoft Azure][18], [Google Compute Engine][19], [Amazon Elastic Compute Cloud][20], 或者 [VirtualBox][21]等。 + +Photon通过只安装Docker守护进程所必需的东西来保持它的轻量。而这样做的结果是,这个发行版的大小大约只有300MB。但这足以让Linux的运行一切正常。除此之外,Photon的主要特点还有: + +* 内核调整为性能模式。 + +* 内核根据[内核自防护项目][6](KSPP)进行了加固。 + +* 所有安装的软件包都根据加固的安全标志(hardened security flags)来构建。 + +* 操作系统以信任验证(validated trust)启动。 + +* Photon管理进程管理防火墙,网络,软件包,和远程登录在Photon机子上的用户。 + +* 支持持久卷。 + +* [Project Lightwave][7] 整合。 + +* 及时的安全补丁与更新。 + +Photon可以通过[ISO][22],[OVA][23],[Amazon Machine Image][24],[Google Compute Engine image][25]和[Azure VHD][26]安装使用。现在我将向您展示如何使用ISO镜像在VirtualBox上安装Photon。整个安装过程大概需要五分钟,在最后您将有一台随时可以部署容器的虚拟机。 + +### 创建虚拟机 + +在部署第一台容器之前,您必须先创建一台虚拟机并安装Photon。为此,打开VirtualBox并点击“新建”按钮。跟着创建虚拟机向导进行配置(根据您的容器将需要的用途,为Photon提供必要的资源)。在创建好虚拟机后,您所需要做的第一件事就是更改配置。选择新建的虚拟机(在VirtualBox主窗口的左侧面板中),然后单击“设置”。在弹出的窗口中,点击“网络”(在左侧的导航中)。 + +在“网络”窗口(图1)中,你需要在“连接”的下拉窗口中选择桥接。这可以确保您的Photon服务与您的网络相连。完成更改后,单击确定。 + +### [photon_0.jpg][8] + +![change settings](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_0.jpg?itok=Q0yhOhsZ "change setatings") +图 1: 更改Photon在VirtualBox中的网络设置。[经许可使用][1] + +从左侧的导航选择您的Photon虚拟机,点击启动。系统会提示您去加载IOS镜像。当您完成之后,Photon安装程序将会启动并提示您按回车后开始安装。安装过程基于ncurses(没有GUI),但它非常简单。 + +接下来(图2),系统会询问您是要最小化安装,完整安装还是安装OSTree服务器。我选择了完整安装。选择您所需要的任意选项,然后按回车继续。 + +### [photon_1.jpg][9] + +![installation type](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_2.jpg?itok=QL1Rs-PH "Photon") +图 2: 选择您的安装类型.[经许可使用][2] + +在下一个窗口,选择您要安装Photon的磁盘。由于我们将其安装在虚拟机,因此只有一块磁盘会被列出(图3)。选择“自动”按下回车。然后安装程序会让您输入(并验证)管理员密码。在这之后镜像开始安装在您的磁盘上并在不到5分钟的时间内结束。 + +### [photon_2.jpg][] + +![Photon](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_1.jpg?itok=OdnMVpaA "installation type") +图 3: 选择安装Photon的硬盘.[经许可使用][3] + +安装完成后,重启虚拟机并使用安装时创建的用户root和它的密码登录。一切就绪,你准备好开始工作了。 + +在开始使用Docker之前,您需要更新一下Photon。Photon使用 _yum_ 软件包管理器,因此在以root用户登录后输入命令 _yum update_。如果有任何可用更新,则会询问您是否确认(图4)。 + +### [photon_3.jpg][11] + +![Updating](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_3.jpg?itok=vjqrspE2 "Updating") +图 4: 更新 Photon.[经许可使用][4] + +用法 + +正如我所说的,Photon提供了部署容器甚至创建Kubernetes集群所需要的所有包。但是,在使用之前还要做一些事情。首先要启动Docker守护进程。为此,执行以下命令: + +``` +systemctl start docker + +systemctl enable docker +``` + +现在我们需要创建一个标准用户(standard user),因此我们没有以root去运行docker命令。为此,执行以下命令: + +``` +useradd -m USERNAME + +passwd USERNAME +``` + +其中USERNAME是我们新增的用户的名称。 + +接下来,我们需要将这个新用户添加到 _docker_ 组,执行命令: + +``` +usermod -a -G docker USERNAME +``` + +其中USERNAME是刚刚创建的用户的名称。 + +注销root用户并切换为新增的用户。现在,您已经可以不必使用 _sudo_ 命令或者是切换到root用户来使用 _docker_命令了。从Docker Hub中取出一个镜像开始部署容器吧。 + +### 一个优秀的容器平台 + +在专注于容器方面,Photon毫无疑问是一个出色的平台。请注意,Photon是一个开源项目,因此没有任何付费支持。如果您对Photon有任何的问题,请移步Photon项目的Github下的[Issues][27],那里可以供您阅读相关问题,或者提交您的问题。如果您对Photon感兴趣,您也可以在项目的官方[Github][28]中找到源码。 + +尝试一下Photon吧,看看它是否能够使得Docker容器和Kubernetes集群的部署更加容易。 + +欲了解Linux的更多信息,可以通过学习Linux基金会和edX的免费课程,[“Linux 入门”][29]。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2017/11/photon-could-be-your-new-favorite-container-os + +作者:[JACK WALLEN][a] +译者:[KeyLD](https://github.com/KeyLd) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/jlwallen +[1]:https://www.linux.com/licenses/category/used-permission +[2]:https://www.linux.com/licenses/category/used-permission +[3]:https://www.linux.com/licenses/category/used-permission +[4]:https://www.linux.com/licenses/category/used-permission +[5]:https://www.linux.com/licenses/category/creative-commons-zero +[6]:https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project +[7]:http://vmware.github.io/lightwave/ +[8]:https://www.linux.com/files/images/photon0jpg +[9]:https://www.linux.com/files/images/photon1jpg +[10]:https://www.linux.com/files/images/photon2jpg +[11]:https://www.linux.com/files/images/photon3jpg +[12]:https://www.linux.com/files/images/photon-linuxjpg +[13]:https://www.linux.com/learn/intro-to-linux/2017/11/how-install-and-use-docker-linux +[14]:https://www.docker.com/ +[15]:https://vmware.github.io/photon/ +[16]:https://www.vmware.com/ +[17]:https://www.vmware.com/products/vsphere.html +[18]:https://azure.microsoft.com/ +[19]:https://cloud.google.com/compute/ +[20]:https://aws.amazon.com/ec2/ +[21]:https://www.virtualbox.org/ +[22]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[23]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[24]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[25]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[26]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[27]:https://github.com/vmware/photon/issues +[28]:https://github.com/vmware/photon +[29]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From a6371cb0a767a0a84b335291252b19efdc67c1b6 Mon Sep 17 00:00:00 2001 From: nodekey Date: Sat, 2 Dec 2017 20:22:26 +0800 Subject: [PATCH 099/344] translated --- ...171124 Photon Could Be Your New Favorite Container OS.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md index 32d035334d..e51c580da9 100644 --- a/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md +++ b/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md @@ -17,9 +17,9 @@ Photon通过只安装Docker守护进程所必需的东西来保持它的轻量 * 内核根据[内核自防护项目][6](KSPP)进行了加固。 -* 所有安装的软件包都根据加固的安全标志(hardened security flags)来构建。 +* 所有安装的软件包都根据加固的安全标识来构建。 -* 操作系统以信任验证(validated trust)启动。 +* 操作系统在信任验证后启动。 * Photon管理进程管理防火墙,网络,软件包,和远程登录在Photon机子上的用户。 @@ -77,7 +77,7 @@ systemctl start docker systemctl enable docker ``` -现在我们需要创建一个标准用户(standard user),因此我们没有以root去运行docker命令。为此,执行以下命令: +现在我们需要创建一个标准用户,因此我们没有以root去运行docker命令。为此,执行以下命令: ``` useradd -m USERNAME From 52bd942e462c6b66a0a7cc64d26f8bf2eadda88c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=88=E6=B0=B8?= Date: Sun, 3 Dec 2017 00:19:34 +0800 Subject: [PATCH 100/344] Update 20170622 A users guide to links in the Linux filesystem.md --- ... guide to links in the Linux filesystem.md | 71 +++++++++---------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/sources/tech/20170622 A users guide to links in the Linux filesystem.md b/sources/tech/20170622 A users guide to links in the Linux filesystem.md index 5dc6f72e35..5ee614a216 100644 --- a/sources/tech/20170622 A users guide to links in the Linux filesystem.md +++ b/sources/tech/20170622 A users guide to links in the Linux filesystem.md @@ -23,11 +23,11 @@ linux 文件系统中有两种链接:硬链接和软链接。虽然二者差 *   [linux 高级命令速查表][4] -* [Our latest Linux articles][5] +*   [我们最新的 linux 文章][5] -I have found, for instance, that some programs required a particular version of a library. When a library upgrade replaced the old version, the program would crash with an error specifying the name of the old, now-missing library. Usually, the only change in the library name was the version number. Acting on a hunch, I simply added a link to the new library but named the link after the old library name. I tried the program again and it worked perfectly. And, okay, the program was a game, and everyone knows the lengths that gamers will go to in order to keep their games running. +举个例子,我曾发现一些程序要求特定的版本库方可运行。 当用升级后的库替代旧库后,程序会崩溃,提示就版本库缺失。 同城库中唯一变化是版本号。出于该直觉,我仅仅给程序添加了一个新的库链接,并以旧库名称命名。我试着再次启动程序,运行良好。 程序就是一个游戏,人人都明白,每个玩家都会尽力使游戏进行下去。 -In fact, almost all applications are linked to libraries using a generic name with only a major version number in the link name, while the link points to the actual library file that also has a minor version number. In other instances, required files have been moved from one directory to another to comply with the Linux file specification, and there are links in the old directories for backwards compatibility with those programs that have not yet caught up with the new locations. If you do a long listing of the **/lib64** directory, you can find many examples of both. +事实上,几乎所有的应用程序链接库都使用通用的命名规则,链接名称中包含了住版本号,链接所指文件的文件名中同样包含了最小版本号。再比如,程序的一些必需文件为了迎合 linux 文件系统的规范从一个目录移动到另一个目录中,系统为了向后兼容那些不能获取这些文件新位置的程序在旧的目录中存放了这些文件的链接。如果你对 /lib64 目录做一个长清单列表,你会发现很多这样的例子。 ``` lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.hwm -> ../../usr/share/cracklib/pw_dict.hwm @@ -45,56 +45,56 @@ lrwxrwxrwx. 1 root root 30 Jan 16 16:39 libakonadi-calendar.so.4 -> libak lrwxrwxrwx. 1 root root 29 Jan 16 16:39 libakonadi-contact.so.4 -> libakonadi-contact.so.4.14.26 ``` -A few of the links in the **/lib64** directory +**/lib64** 目录下的一些链接 -The long listing of the **/lib64** directory above shows that the first character in the filemode is the letter "l," which means that each is a soft or symbolic link. +T在上面展示的 **/lib64** 目录清单列表中,文件模式第一个字母 I 表示这是一个符号链接或软链接。 -### Hard links +### 硬链接 -In [An introduction to Linux's EXT4 filesystem][15], I discussed the fact that each file has one inode that contains information about that file, including the location of the data belonging to that file. [Figure 2][16] in that article shows a single directory entry that points to the inode. Every file must have at least one directory entry that points to the inode that describes the file. The directory entry is a hard link, thus every file has at least one hard link. +在 [An introduction to Linux's EXT4 filesystem][15]一文中,我曾探讨过这样一个事实,每个文件都有一个包含该文件信息的节点,包含了该文件的位置信息。上述文章中的[图2][16]展示了一个指向文件节点的单一目录项。每个文件都至少有一个目录项指向描述该文件信息的文件节点,目录项是一个硬链接,因此每个文件至少都有一个硬链接。 -In Figure 1 below, multiple directory entries point to a single inode. These are all hard links. I have abbreviated the locations of three of the directory entries using the tilde (**~**) convention for the home directory, so that **~** is equivalent to **/home/user** in this example. Note that the fourth directory entry is in a completely different directory, **/home/shared**, which might be a location for sharing files between users of the computer. +如下图1所示,多个目录项指向了同一文件节点。这些目录项都是硬链接。我曾使用波浪线 (**~**) 表示三级目录项的缩写,这是用户目录的惯例表示,因此在该例中波浪线等同于 **/home/user** 。值得注意的是,四级目录项是一个完全不同的目录,**/home/shared** 可能是该计算机上用户的共享文件目录。 ![fig1directory_entries.png](https://opensource.com/sites/default/files/images/life/fig1directory_entries.png) Figure 1 -Hard links are limited to files contained within a single filesystem. "Filesystem" is used here in the sense of a partition or logical volume (LV) that is mounted on a specified mount point, in this case **/home**. This is because inode numbers are unique only within each filesystem, and a different filesystem, for example, **/var**or **/opt**, will have inodes with the same number as the inode for our file. +单一文件系统中的文件硬链接数是有限制的。”文件系统“ 是就挂载在特定挂载点上的分区或逻辑卷而言的,此例中是 /home。这是因为文件系统中的节点号都是唯一的。在不同的文件系统中,如 **/var** 或 **/opt**,会有和 **/home** 中相同的节点号。 -Because all the hard links point to the single inode that contains the metadata about the file, all of these attributes are part of the file, such as ownerships, permissions, and the total number of hard links to the inode, and cannot be different for each hard link. It is one file with one set of attributes. The only attribute that can be different is the file name, which is not contained in the inode. Hard links to a single **file/inode** located in the same directory must have different names, due to the fact that there can be no duplicate file names within a single directory. +因为所有的硬链接都指向了包含文件元信息的节点,这些特性都是文件的一部分,像所属关系,权限,节点硬链接数目,这些特性不能区分不同的硬链接。这是一个文件所具有的一组属性。唯一能区分这些文件的是包含在节点信息中的文件名。对单靠 **file/inode** 来定位文件的同一目录中的硬链接必须拥有不同的文件名,基于上述事实,同一目录下不能存在重复的文件名。 -The number of hard links for a file is displayed with the **ls -l** command. If you want to display the actual inode numbers, the command **ls -li** does that. +文件的硬链接数目可通过 **ls -l** 来查看,如果你想查看实际节点号,可使用 **ls -li** 命令。 -### Symbolic (soft) links +### 符号(软)链接 -The difference between a hard link and a soft link, also known as a symbolic link (or symlink), is that, while hard links point directly to the inode belonging to the file, soft links point to a directory entry, i.e., one of the hard links. Because soft links point to a hard link for the file and not the inode, they are not dependent upon the inode number and can work across filesystems, spanning partitions and LVs. +软链接(符号链接)和硬链接的区别在于,硬链接直接指向文件中的节点而软链接直接指向一个目录项,即一个硬链接。因为软链接指向一个文件的硬链接而非该文件的节点信息,所以它们并不依赖于文件节点,这使得它们能在不同的文件系统中起作用,跨越不同的分区和逻辑卷。 -The downside to this is: If the hard link to which the symlink points is deleted or renamed, the symlink is broken. The symlink is still there, but it points to a hard link that no longer exists. Fortunately, the **ls** command highlights broken links with flashing white text on a red background in a long listing. +软链接的缺点是,一旦它所指向的硬链接被删除或重命名后,该软链接就失效了。软链接虽然还在,但所指向的硬链接已不存在。所幸的是,**ls** 命令能以红底白字的方式在其列表中高亮显示失效的软链接。 -### Lab project: experimenting with links +### 实验项目: 链接实验 -I think the easiest way to understand the use of and differences between hard and soft links is with a lab project that you can do. This project should be done in an empty directory as a  _non-root user_ . I created the **~/temp** directory for this project, and you should, too. It creates a safe place to do the project and provides a new, empty directory to work in so that only files associated with this project will be located there. +我认为最容易理解链接用法及其差异的方法即使动手搭建一个项目。这个项目应以非超级用户的身份在一个空目录下进行。我创建了 **~/tmp** 目录做这个实验,你也可以这么做。这么做可为项目创建一个安全的环境且提供一个新的空目录让程序运作,如此以来这儿仅存放和程序有关的文件。 -### **Initial setup** +### **初始工作** -First, create the temporary directory in which you will perform the tasks needed for this project. Ensure that the present working directory (PWD) is your home directory, then enter the following command. +首先,在你要进行实验的目录下为该项目中的任务创建一个临时目录,确保当前工作目录(PWD)是你的主目录,然后键入下列命令。 ``` mkdir temp ``` -Change into **~/temp** to make it the PWD with this command. +使用这个命名将当前工作目录切换到 *~/temp**  ``` cd temp ``` -To get started, we need to create a file we can link to. The following command does that and provides some content as well. +实验开始,我们创建一个能够链接的文件,下列命令可完成该工作并向其填充内容。 ``` du -h > main.file.txt ``` -Use the **ls -l** long list to verify that the file was created correctly. It should look similar to my results. Note that the file size is only 7 bytes, but yours may vary by a byte or two. +使用 *ls -l** 长列表命名确认文件被正确地创建。运行结果应类似于我的。注意文件大小只有 7 字节,但你的可能会有 1~2 字节的变动。 ``` [dboth@david temp]$ ls -l @@ -102,11 +102,11 @@ total 4 -rw-rw-r-- 1 dboth dboth 7 Jun 13 07:34 main.file.txt ``` -Notice the number "1" following the file mode in the listing. That number represents the number of hard links that exist for the file. For now, it should be 1 because we have not created any additional links to our test file. +在列表中,文件模式串后的数字 1 代表存在于该文件上的硬链接数。现在应该是 1 ,因为我们还没有为这个测试文件建立任何硬链接。 -### **Experimenting with hard links** +### **对硬链接进行实验** -Hard links create a new directory entry pointing to the same inode, so when hard links are added to a file, you will see the number of links increase. Ensure that the PWD is still **~/temp**. Create a hard link to the file **main.file.txt**, then do another long list of the directory. +硬链接创建一个指向同一文件节点的目录项,当为文件添加一个硬链接时,你会看到链接数目的增加。确保当前工作目录仍为 **~/temp**。创建一个指向 **main.file.txt** 的硬链接,然后查看该目录下文件列表。 ``` [dboth@david temp]$ ln main.file.txt link1.file.txt @@ -116,7 +116,7 @@ total 8 -rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 main.file.txt ``` -Notice that both files have two links and are exactly the same size. The date stamp is also the same. This is really one file with one inode and two links, i.e., directory entries to it. Create a second hard link to this file and list the directory contents. You can create the link to either of the existing ones: **link1.file.txt** or **main.file.txt**. +目录中两个文件都有两个链接且大小相同,时间戳也一样。这是同一文件节点的两个不同的硬链接,即该文件的目录项。再建立一个该文件的硬链接,并列出目录清单内容,你可以建立 **link1.file.txt** 或 **main.file.txt** 的硬链接。 ``` [dboth@david temp]$ ln link1.file.txt link2.file.txt ; ls -l @@ -126,22 +126,21 @@ total 16 -rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 main.file.txt ``` -Notice that each new hard link in this directory must have a different name because two files—really directory entries—cannot have the same name within the same directory. Try to create another link with a target name the same as one of the existing ones. +注意,该目录下的每个硬链接必须使用不同的名称,因为同一目录下的两个文件不能拥有相同的文件名。试着创建一个和现存链接名称相同的硬链接。 ``` [dboth@david temp]$ ln main.file.txt link2.file.txt ln: failed to create hard link 'link2.file.txt': File exists ``` -Clearly that does not work, because **link2.file.txt** already exists. So far, we have created only hard links in the same directory. So, create a link in your home directory, the parent of the temp directory in which we have been working so far. +显然不行,因为 **link2.file.txt** 已经存在。目前为止我们只在同一目录下创建硬链接,接着在临时目录的父目录,你的主目录中创建一个链接。 ``` [dboth@david temp]$ ln main.file.txt ../main.file.txt ; ls -l ../main* -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt ``` -The **ls** command in the above listing shows that the **main.file.txt** file does exist in the home directory with the same name as the file in the temp directory. Of course, these are not different files; they are the same file with multiple links—directory entries—to the same inode. To help illustrate the next point, add a file that is not a link. - + 上面的 **ls** 命令显示 **main.file.txt** 文件确实存在于主目录中,且与该文件在 temp 目录中的名称一致。当然它们是没有区别的两个文件,它们是同一文件的两个链接,指向了同一文件的目录项。为了帮助说明下一点,在 temp 目录中添加一个非链接文件。 ``` [dboth@david temp]$ touch unlinked.file ; ls -l total 12 @@ -151,7 +150,7 @@ total 12 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file ``` -Look at the inode number of the hard links and that of the new file using the **-i**option to the **ls** command. +使用 **ls** 命令的 **i** 选项查看文件节点的硬链接号和新创建文件的硬链接号。 ``` [dboth@david temp]$ ls -li @@ -162,9 +161,9 @@ total 12 657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file ``` -Notice the number **657024** to the left of the file mode in the example above. That is the inode number, and all three file links point to the same inode. You can use the **-i** option to view the inode number for the link we created in the home directory as well, and that will also show the same value. The inode number of the file that has only one link is different from the others. Note that the inode numbers will be different on your system. +注意上面文件模式左边的数字 **657024** ,这是三个硬链接文件所指的同一文件的节点号,你也可以使用 **i** 选项查看主目录中所创建的链接节点号,和该值相同。只有一个链接的文件节点号和其他的不同,在你的系统上看到的不同于本文中的。 -Let's change the size of one of the hard-linked files. +接着改变其中一个硬链接文件的大小。 ``` [dboth@david temp]$ df -h > link2.file.txt ; ls -li @@ -175,11 +174,11 @@ total 12 657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file ``` -The file size of all the hard-linked files is now larger than before. That is because there is really only one file that is linked to by multiple directory entries. +现在的硬链接文件大小比原来大,因为多个目录项链接着同一文件。 -I know this next experiment will work on my computer because my **/tmp**directory is on a separate LV. If you have a separate LV or a filesystem on a different partition (if you're not using LVs), determine whether or not you have access to that LV or partition. If you don't, you can try to insert a USB memory stick and mount it. If one of those options works for you, you can do this experiment. +我知道下个实验在我的电脑上会成功,因为我的 **/tmp** 目录是一个独立的逻辑卷,如果你有单独的逻辑卷或文件系统在不同的分区上(如果未使用逻辑卷),确定你是否能访问那个分区或逻辑卷,如果不能,你可以在电脑上挂载一个 U盘,如果上述选项适合你,你可以进行这个实验。 -Try to create a link to one of the files in your **~/temp** directory in **/tmp** (or wherever your different filesystem directory is located). +试着在 **/tmp** 目录中建立一个 **~/temp** 目录下文件的链接(或你的文件系统所在的位置) ``` [dboth@david temp]$ ln link2.file.txt /tmp/link3.file.txt @@ -187,7 +186,7 @@ ln: failed to create hard link '/tmp/link3.file.txt' => 'link2.file.txt': Invalid cross-device link ``` -Why does this error occur? The reason is each separate mountable filesystem has its own set of inode numbers. Simply referring to a file by an inode number across the entire Linux directory structure can result in confusion because the same inode number can exist in each mounted filesystem. +为什么会出现这个错误呢? 原因是每一个单独的挂载文件系统都有一套自己的节点号。 Simply referring to a file by an inode number across the entire Linux directory structure can result in confusion because the same inode number can exist in each mounted filesystem. There may be a time when you will want to locate all the hard links that belong to a single inode. You can find the inode number using the **ls -li** command. Then you can use the **find** command to locate all links with that inode number. From 178125fa2fafecc27a5c1d808151434541b7f797 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Sun, 3 Dec 2017 00:44:46 +0800 Subject: [PATCH 101/344] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=AF=95=20?= =?UTF-8?q?(#6416)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * translated * moved to translated directory --- ...ogle Translate From Command Line In Linux.md | 90 ++++++++++--------- 1 file changed, 46 insertions(+), 44 deletions(-) rename {sources => translated}/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md (75%) diff --git a/sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md b/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md similarity index 75% rename from sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md rename to translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md index 3725fea5df..9f905bd496 100644 --- a/sources/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md +++ b/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md @@ -1,82 +1,82 @@ -translate by darksun -Translate Shell – A Tool To Use Google Translate From Command Line In Linux +Translate Shell: 一款在 Linux 命令行中使用 Google Translate的工具 ============================================================ -I love to work and share about CLI apps since i’m very much interested on CLI applications. Basically i prefer CLI because most of the time i will be sitting in front of the black screen and it’s became habit for me to go with CLI apps instead of GUI. +我对 CLI 应用非常感兴趣,因此热衷于使用并分享 CLI 应用。 我之所以更喜欢 CLI 很大原因是因为我在大多数的时候都使用的是字符界面(black screen),已经习惯了使用 CLI 应用而不是 GUI 应用. -We have wrote many articles about CLI applications in past. Recently i came to know about google CLI utilities such as “Google Translator”, “Google Calendar”, and “Google Contacts”. so, i just want to share about it. +我写过很多关于 CLI 应用的文章。 最近我发现了一些 google 的 CLI 工具,像 “Google Translator”, “Google Calendar”, 和 “Google Contacts”。 这里,我想在给大家分享一下。 -Today we are going to discuss about “Google Translator”. I use many times in a day to know the meanings since my native language is Tamil. +今天我们要介绍的是 “Google Translator” 工具。 由于母语是泰米尔语,我在一天内用了很多次才理解了它的意义。 -Google translate is widely used by other language speakers. +`Google translate` 为其他语系的人们所广泛使用。 -#### What is Translate Shell +### 什么是 Translate Shell -[Translate Shell][2] (formerly known as Google Translate CLI) is a command-line translator powered by Google Translate (default), Bing Translator, Yandex.Translate and Apertium. It allows you to access to one of these translation engines right from your terminal. Translate Shell is designed work on most of the Linux distributions. +[Translate Shell][2] (之前叫做 Google Translate CLI) 是一款借助 `Google Translate`(默认), `Bing Translator`, `Yandex.Translate` 以及 `Apertium` 来翻译的命令行翻译器。 +它让你可以在终端访问这些翻译引擎. `Translate Shell` 在大多数Linux发行版中都能使用。 -#### How to Install Translate Shell +### 如何安装 Translate Shell -We can install the Translate Shell application in three methods. +有三种方法安装 `Translate Shell`。 -* Download self-contained executable file +* 下载自包含的可执行文件 -* Manual Method +* 手工安装 -* Via Package Manager +* 通过包挂力气安装 -#### Method-1 : Download self-contained executable file +#### 方法-1 : 下载自包含的可执行文件 -Just Download the self-contained executable file and move into /usr/bin directory. +下载自包含的可执行文件放到 `/usr/bin` 目录中。 -``` +```shell $ wget git.io/trans $ chmod +x ./trans $ sudo mv trans /usr/bin/ ``` -#### Method-2 : Manual Method +#### 方法-2 : 手工安装 -Just clone the Translate Shell github repository and compile manually for any distributions. +克隆 `Translate Shell` github 仓库然后手工编译。 -``` +```shell $ git clone https://github.com/soimort/translate-shell && cd translate-shell $ make $ sudo make install ``` -#### Method-3 : Via Package Manager +#### 方法-3 : Via Package Manager -Translate Shell is available in few of the distribution official repository that can be installed through package manager. +有些发行版的官方仓库中包含了 `Translate Shell`,可以通过包管理器来安装。 -For Debian/Ubuntu, use [APT-GET Command][3] or [APT Command][4]to install Translate Shell. +对于 Debian/Ubuntu, 使用 [APT-GET Command][3] 或者 [APT Command][4]来安装。 -``` +```shell $ sudo apt-get install translate-shell ``` -For Fedora, use [DNF Command][5] to install Translate Shell. +对于 Fedora, 使用 [DNF Command][5] 来安装。 -``` +```shell $ sudo dnf install translate-shell ``` -For Arch Linux based systems, use [Yaourt Command][6] or [Packer Command][7] to install Translate Shell from AUR repository. +对于基于 Arch Linux 的系统, 使用 [Yaourt Command][6] 或 [Packer Command][7] 来从 AUR 仓库中安装。 -``` +```shell $ yaourt -S translate-shell or $ packer -S translate-shell ``` -#### How To Use Translate Shell +### 如何使用 Translate Shell -After successfully installed, open your terminal and fire the following command. Google Translate can identify the language of the source text automatically, and Translate Shell by default translates the source text into the language of your locale. +安装好后,打开终端闭关输入下面命令。 `Google Translate` 会自动探测源文本是哪种语言,并且在默认情况下将之翻译成你的 `locale` 所对应的语言。 ``` $ trans [Words] ``` -I’m going to translated a Tamil word “நன்றி” (Nanri) to English. It’s use to thank people. +下面我将泰米尔语中的单词 “நன்றி” (Nanri) 翻译成英语。 这个单词的意思是感谢别人。 ``` $ trans நன்றி @@ -98,7 +98,7 @@ noun Thanks ``` -Alternatively translate a word into Tamil using following command. +使用下面命令也能将英语翻译成泰米尔语。 ``` $ trans :ta thanks @@ -119,7 +119,7 @@ thanks நன்றி ``` -To Translate a word into more than one language use following command (In this example, i’m going to translate a word into Tamil & Hindi). +要将一个单词翻译到多个语种可以使用下面命令(本例中, 我将单词翻译成泰米尔语以及印地语)。 ``` $ trans :ta+hi thanks @@ -156,7 +156,7 @@ thanks धन्यवाद, शुक्रिया ``` -To Translate words into one argument (phrase) use following command (just quote the sentence into one argument). +使用下面命令可以将多个单词当成一个参数(句子)来进行翻译。(只需要把句子应用起来作为一个参数就行了)。 ``` $ trans :ta "what is going on your life?" @@ -172,7 +172,7 @@ what is going on your life? உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? ``` -To Translate Translate each word alone. +下面命令独立地翻译各个单词。 ``` $ trans :ta curios happy @@ -208,14 +208,14 @@ happy சந்தோஷமாக, மகிழ்ச்சி, இனிய, சந்தோஷமா ``` -Brief Mode : By default, Translate Shell displays translations in a verbose manner. If you prefer to see only the brief information, just add -b option. +简洁模式: 默认情况下,`Translate Shell` 尽可能多的显示翻译信息. 如果你希望只显示简要信息,只需要加上`-b`选项。 ``` $ trans -b :ta thanks நன்றி ``` -Dictionary Mode : To use Translate Shell as a dictionary, just add -d option. +字典模式: 加上 `-d` 可以把 `Translate Shell` 当成字典来用. ``` $ trans -d :en thanks @@ -294,14 +294,14 @@ See also Thanks!, thank, many thanks, thanks to, thanks to you, special thanks, give thanks, thousand thanks, Many thanks!, render thanks, heartfelt thanks, thanks to this ``` -To Translate a File using Translate Shell, use the following format. +使用下面格式可以使用 `Translate Shell` 来翻译文件。 -``` +```shell $ trans :ta file:///home/magi/gtrans.txt உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? ``` -To open interactive Translate Shell, run the following command. Make sure you have to specify the source language and the target language(s) before starting an interactive shell. In this example, i’m going to translate a word from English to Tamil. +下面命令可以让 `Translate Shell` 进入交互模式. 在进入交互模式之前你需要明确指定源语言和目标语言。本例中,我将英文单词翻译成泰米尔语。 ``` $ trans -shell en:ta thanks @@ -324,11 +324,13 @@ thanks நன்றி ``` -To know the language code, just fire the following command. +想知道语言代码,可以执行下面语言。 -``` +```shell $ trans -R -or +``` +或者 +```shell $ trans -T ┌───────────────────────┬───────────────────────┬───────────────────────┐ │ Afrikaans - af │ Hindi - hi │ Punjabi - pa │ @@ -373,9 +375,9 @@ $ trans -T └───────────────────────┴───────────────────────┴───────────────────────┘ ``` -To know more options, navigate to man page. +想了解更多选项的内容,可以查看 `man` 页. -``` +```shell $ man trans ``` From 85b20be1408b3360505dda47d15010362a9d110a Mon Sep 17 00:00:00 2001 From: yunfengHe Date: Sun, 3 Dec 2017 00:45:54 +0800 Subject: [PATCH 102/344] -Containers and Kubernetes: What's next? Translated by YunfengHe (#6417) * translated by yunfengHe * translated, modified * modified v2 * modified v3 * modified yunfengHe final * translated yunfengHe --- ...20 Containers and Kubernetes Whats next.md | 98 ------------------- ...20 Containers and Kubernetes Whats next.md | 80 +++++++++++++++ 2 files changed, 80 insertions(+), 98 deletions(-) delete mode 100644 sources/tech/20171120 Containers and Kubernetes Whats next.md create mode 100644 translated/tech/20171120 Containers and Kubernetes Whats next.md diff --git a/sources/tech/20171120 Containers and Kubernetes Whats next.md b/sources/tech/20171120 Containers and Kubernetes Whats next.md deleted file mode 100644 index b73ccb21c2..0000000000 --- a/sources/tech/20171120 Containers and Kubernetes Whats next.md +++ /dev/null @@ -1,98 +0,0 @@ -YunfengHe Translating -Containers and Kubernetes: What's next? -============================================================ - -### What's ahead for container orchestration and Kubernetes? Here's an expert peek - -![CIO_Big Data Decisions_2](https://enterprisersproject.com/sites/default/files/styles/620x350/public/images/CIO_Big%20Data%20Decisions_2.png?itok=Y5zMHxf8 "CIO_Big Data Decisions_2") - -If you want a basic idea of where containers are headed in the near future, follow the money. There’s a lot of it: 451 Research projects that the overall market for containers will hit roughly [$2.7 billion in 2020][4], a 3.5-fold increase from the $762 million spent on container-related technology in 2016. - -There’s an obvious fundamental factor behind such big numbers: Rapidly increasing containerization. The parallel trend: As container adoption grows, so will container  _orchestration_  adoption. - -As recent survey data from  [_The New Stack_][5]  indicates, container adoption is the most significant catalyst of orchestration adoption: 60 percent of respondents who’ve deployed containers broadly in production report they’re also using Kubernetes widely in production. Another 19 percent of respondents with broad container deployments in production were in the initial stages of broad Kubernetes adoption. Meanwhile, just 5 percent of those in the initial phases of deploying containers in production environments were using Kubernetes broadly – but 58 percent said they were preparing to do so. It’s a chicken-and-egg relationship. - - -Most experts agree that an orchestration tool is essential to the scalable [long-term management of containers][6] – and corresponding developments in the marketplace. “The next trends in container orchestration are all focused on broadening adoption,” says Alex Robinson, software engineer at [Cockroach Labs][7]. - -This is a quickly shifting landscape, one that is just starting to realize its future potential. So we checked in with Robinson and other practitioners to get their boots-on-the-ground perspective on what’s next in container orchestration – and for Kubernetes itself. - -### **Container orchestration shifts to mainstream** - -We’re at the precipice common to most major technology shifts, where we transition from the careful steps of early adoption to cliff-diving into commonplace use. That will create new demand for the plain-vanilla requirements that make mainstream adoption easier, especially in large enterprises. - -“The gold rush phase of early innovation has slowed down and given way to a much stronger focus on stability and usability,” Robinson says. “This means we'll see fewer major announcements of new orchestration systems, and more security options, management tools, and features that make it easier to take advantage of the flexibility already inherent in the major orchestration systems.” - -### **Reduced complexity** - -On a related front, expect an intensifying effort to cut back on the complexity that some organizations face when taking their first plunge into container orchestration. As we’ve covered before, deploying a container might be “easy,” but [managing containers long-term ][8]requires more care. - -“Today, container orchestration is too complex for many users to take full advantage,” says My Karlsson, developer at [Codemill AB][9]. “New users are often struggling just to get single or small-size container configurations running in isolation, especially when applications are not originally designed for it. There are plenty of opportunities to simplify the orchestration of non-trivial applications and make the technology more accessible.” - -### **Increasing focus on hybrid cloud and multi-cloud** - -As adoption of containers and container orchestration grows, more organizations will scale from a starting point of, say, running non-critical workloads in a single environment to more [complex use cases][10] across multiple environments. For many companies, that will mean managing containerized applications (and particularly containerized microservices) across [hybrid cloud][11] and [multi-cloud][12] environments, often globally. - -"Containers and Kubernetes have made hybrid cloud and application portability a reality,” says [Brian Gracely][13], director of [Red Hat][14] OpenShift product strategy. “Combined with the Open Service Broker, we expect to see an explosion of new applications that combine private and public cloud resources." - -“I believe that federation will get a push, enabling much-wanted features such as seamless multi-region and multi-cloud deployments,” says Carlos Sanchez, senior software engineer at [CloudBees][15].  - -**[ Want CIO wisdom on hybrid cloud and multi-cloud strategy? See our related resource, **[**Hybrid Cloud: The IT leader's guide**][16]**. ]** - -### **Continued consolidation of platforms and tools** - -Technology consolidation is common trend; container orchestration is no exception. - -“As containerization goes mainstream, engineers are consolidating on a very small number of technologies to run their [microservices and] containers and Kubernetes will become the dominant container orchestration platform, far outstripping other platforms,” says Ben Newton, analytics lead at [Sumo Logic][17]. “Companies will adopt Kubernetes to drive a cloud-neutral approach as Kubernetes provides a reasonably clear path to reduce dependence on [specific] cloud ecosystems.**”** - -### **Speaking of Kubernetes, what’s next?** - -"Kubernetes is here for the long haul, and the community driving it is doing great job – but there's lots ahead,” says Gadi Naor, CTO and co-founder of [Alcide][18]. Our experts shared several predictions specific to [the increasingly popular Kubernetes platform][19]:  - - **_Gadi Naor at Alcide:_**  “Operators will continue to evolve and mature, to a point where applications running on Kubernetes will become fully self-managed. Deploying and monitoring microservices on top of Kubernetes with [OpenTracing][20] and service mesh frameworks such as [istio][21] will help shape new possibilities.” - - **_Brian Gracely at Red Hat:_**  “Kubernetes continues to expand in terms of the types of applications it can support. When you can run traditional applications, cloud-native applications, big data applications, and HPC or GPU-centric applications on the same platform, it unlocks a ton of architectural flexibility.” - - **_Ben Newton at Sumo Logic: _ “**As Kubernetes becomes more dominant, I would expect to see more normalization of the operational mechanisms – particularly integrations into third-party management and monitoring platforms.” - - **_Carlos Sanchez at CloudBees: _** “In the immediate future there is the ability to run without Docker, using other runtimes...to remove any lock-in. [Editor’s note: [CRI-O][22], for example, offers this ability.] “Also, [look for] storage improvements to support enterprise features like data snapshotting and online volume resizing.” - - - **_Alex Robinson at Cockroach Labs: _ “**One of the bigger developments happening in the Kubernetes community right now is the increased focus on managing [stateful applications][23]. Managing state in Kubernetes right now is very difficult if you aren't running in a cloud that offers remote persistent disks, but there's work being done on multiple fronts [both inside Kubernetes and by external vendors] to improve this.” - --------------------------------------------------------------------------------- - -via: https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next - -作者:[Kevin Casey ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://enterprisersproject.com/user/kevin-casey -[1]:https://enterprisersproject.com/article/2017/11/kubernetes-numbers-10-compelling-stats -[2]:https://enterprisersproject.com/article/2017/11/how-enterprise-it-uses-kubernetes-tame-container-complexity -[3]:https://enterprisersproject.com/article/2017/11/5-kubernetes-success-tips-start-smart?sc_cid=70160000000h0aXAAQ -[4]:https://451research.com/images/Marketing/press_releases/Application-container-market-will-reach-2-7bn-in-2020_final_graphic.pdf -[5]:https://thenewstack.io/ -[6]:https://enterprisersproject.com/article/2017/10/microservices-and-containers-6-management-tips-long-haul -[7]:https://www.cockroachlabs.com/ -[8]:https://enterprisersproject.com/article/2017/10/microservices-and-containers-6-management-tips-long-haul -[9]:https://codemill.se/ -[10]:https://www.redhat.com/en/challenges/integration?intcmp=701f2000000tjyaAAA -[11]:https://enterprisersproject.com/hybrid-cloud -[12]:https://enterprisersproject.com/article/2017/7/multi-cloud-vs-hybrid-cloud-whats-difference -[13]:https://enterprisersproject.com/user/brian-gracely -[14]:https://www.redhat.com/en -[15]:https://www.cloudbees.com/ -[16]:https://enterprisersproject.com/hybrid-cloud?sc_cid=70160000000h0aXAAQ -[17]:https://www.sumologic.com/ -[18]:http://alcide.io/ -[19]:https://enterprisersproject.com/article/2017/10/how-explain-kubernetes-plain-english -[20]:http://opentracing.io/ -[21]:https://istio.io/ -[22]:http://cri-o.io/ -[23]:https://opensource.com/article/17/2/stateful-applications -[24]:https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next?rate=PBQHhF4zPRHcq2KybE1bQgMkS2bzmNzcW2RXSVItmw8 -[25]:https://enterprisersproject.com/user/kevin-casey diff --git a/translated/tech/20171120 Containers and Kubernetes Whats next.md b/translated/tech/20171120 Containers and Kubernetes Whats next.md new file mode 100644 index 0000000000..5ed099c170 --- /dev/null +++ b/translated/tech/20171120 Containers and Kubernetes Whats next.md @@ -0,0 +1,80 @@ +容器技术和 k8s 的下一站: +============================================================ +### 想知道容器编排管理和 K8s 的最新展望么?来看看专家怎么说。 + +![CIO_Big Data Decisions_2](https://enterprisersproject.com/sites/default/files/styles/620x350/public/images/CIO_Big%20Data%20Decisions_2.png?itok=Y5zMHxf8 "CIO_Big Data Decisions_2") + +如果你想对容器在未来的发展方向有一个整体把握,那么你一定要跟着钱走,看看钱都投在了哪里。当然了,有很多很多的钱正在投入容器的进一步发展。相关研究预计 2020 年容器技术的投入将占有 [27 亿美元][4] 的市场份额 。而在 2016 年,容器相关技术投入的总额为 7.62 亿美元,只有 2020 年投入预计的三分之一。巨额投入的背后是一些显而易见的基本因素,包括容器化的迅速增长以及并行化的大趋势。随着容器被大面积推广和使用,容器编排管理也会被理所当然的推广应用起来。 + +来自 [_The new stack_][5] 的调研数据表明,容器的推广使用是编排管理被推广的主要的催化剂。根据调研参与者的反馈数据,在已经将容器技术使用到生产环境中的使用者里,有六成正在将 kubernetes(k8s)编排管理广泛的应用在生产环境中,另外百分之十九的人员则表示他们已经处于部署 k8s 的初级阶段。在容器部署初期的使用者当中,虽然只有百分之五的人员表示已经在使用 K8s ,但是百分之五十八的人员表示他们正在计划和准备使用 K8s。总而言之,容器和 Kuebernetes 的关系就好比是鸡和蛋一样,相辅相成紧密关联。众多专家一致认为编排管理工具对容器的[长周期管理][6] 以及其在市场中的发展有至关重要的作用。正如 [Cockroach 实验室][7] 的 Alex Robinson 所说,容器编排管理被更广泛的拓展和应用是一个总体的大趋势。毫无疑问,这是一个正在快速演变的领域,且未来潜力无穷。鉴于此,我们对罗宾逊和其他的一些容器的实际使用和推介者做了采访,来从他们作为容器技术的践行者的视角上展望一下容器编排以及 k8s 的下一步发展。 + +### **容器编排将被主流接受** + +像任何重要技术的转型一样,我们就像是处在一个高崖之上一般,在经过了初期步履蹒跚的跋涉之后将要来到一望无际的广袤平原。广大的新天地和平实真切的应用需求将会让这种新技术在主流应用中被迅速推广,尤其是在大企业环境中。正如 Alex Robinson 说的那样,容器技术的淘金阶段已经过去,早期的技术革新创新正在减速,随之而来的则是市场对容器技术的稳定性和可用性的强烈需求。这意味着未来我们将不会再见到大量的新的编排管理系统的涌现,而是会看到容器技术方面更多的安全解决方案,更丰富的管理工具,以及基于目前主流容器编排系统的更多的新特性。 + +### **更好的易用性** + +人们将在简化容器的部署方面下大功夫,因为容器部署的初期工作对很多公司和组织来说还是比较复杂的,尤其是容器的[长期管理维护][8]更是需要投入大量的精力。正如 [Codemill AB][9] 公司的 My Karlsson 所说,容器编排技术还是太复杂了,这导致很多使用者难以娴熟驾驭和充分利用容器编排的功能。很多容器技术的新用户都需要花费很多精力,走很多弯路,才能搭建小规模的,单个的,被隔离的容器系统。这种现象在那些没有针对容器技术设计和优化的应用中更为明显。在简化容器编排管理方面有很多优化可以做,这些优化和改造将会使容器技术更加具有可用性。 + +### **在 hybrid cloud 以及 multi-cloud 技术方面会有更多侧重** + +随着容器和容器编排技术被越来越多的使用,更多的组织机构会选择扩展他们现有的容器技术的部署,从之前的把非重要系统部署在单一环境的使用情景逐渐过渡到更加[复杂的使用情景][10]。对很多公司来说,这意味着他们必须开始学会在 [hybrid cloud][11] 和 [muilti-cloud][12] 的环境下,全局化的去管理那些容器化的应用和微服务。正如红帽 [Openshift 部门产品战略总监][14] [Brian Gracely][13] 所说,容器和 k8s 技术的使用使得我们成功的实现了混合云以及应用的可移植性。结合 Open Service Broker API 的使用,越来越多的结合私有云和公有云资源的新应用将会涌现出来。 +据 [CloudBees][15] 公司的高级工程师 Carlos Sanchez 分析,联合服务(Federation)将会得到极大推动,使一些诸如多地区部署和多云部署等的备受期待的新特性成为可能。 + +**[ 想知道 CIO 们对 hybrid cloud 和 multi cloud 的战略构想么? 请参看我们的这条相关资源, **[**Hybrid Cloud: The IT leader's guide**][16]**. ]** + +### **平台和工具的持续整合及加强** + +对任何一种科技来说,持续的整合和加强从来都是大势所趋; 容器编排管理技术在这方面也不例外。来自 [Sumo Logic][17] 的首席分析师 Ben Newton 表示,随着容器化渐成主流,软件工程师们正在很少数的一些技术上做持续整合加固的工作,来满足他们的一些微应用的需求。容器和 K8s 将会毫无疑问的成为容器编排管理方面的主流平台,并轻松碾压其他的一些小众平台方案。因为 K8s 提供了一个相当清晰的可以摆脱各种特有云生态的途径,K8s 将被大量公司使用,逐渐形成一个不依赖于某个特定云服务的“中立云”(cloud-neutral)。 + +### **K8s 的下一站** + +来自 [Alcide][18] 的 CTO 和联合创始人 Gadi Naor 表示,k8s 将会是一个有长期和远景发展的技术,虽然我们的社区正在大力推广和发展 k8s,k8s 仍有很长的路要走。 +专家们对[日益流行的 k8s 平台][19]也作出了以下一些预测: + +**_来自 Alcide 的 Gadi Naor 表示:_** “运营商会持续演进并趋于成熟,直到在 k8s 上运行的应用可以完全自治。利用 [OpenTracing][20] 和诸如 [istio][21] 技术的 service mesh 架构,在 k8s 上部署和监控微应用将会带来很多新的可能性。” + +**_来自 Red Hat 的 Brian Gracely 表示:_** “k8s 所支持的应用的种类越来越多。今后在 k8s 上,你不仅可以运行传统的应用程序,还可以运行原生的云应用,大数据应用以及 HPC 或者基于 GPU 运算的应用程序,这将为灵活的架构设计带来无限可能。” + +**_来自 Sumo Logic 的 Ben Newton 表示:_** “随着 k8s 成为一个具有统治地位的平台,我预计更多的操作机制将会被统一化,尤其是 k8s 将和第三方管理和监控平台融合起来。” + +**_来自 CloudBees 的 Carlos Sanchez 表示:_** “在不久的将来我们就能看到不依赖于 Docker 而使用其他运行时环境的系统,这将会有助于消除任何可能的 lock-in 情景“ [小编提示:[CRI-O][22] 就是一个可以借鉴的例子。]“而且我期待将来会出现更多的针对企业环境的存储服务新特性,包括数据快照以及在线的磁盘容量的扩展。” + +**_来自 Cockroach Labs 的 Alex Robinson 表示:_** “ k8s 社区正在讨论的一个重大发展议题就是加强对[有状态程序][23]的管理。目前在 k8s 平台下,实现状态管理仍然非常困难,除非你所使用的云服务商可以提供远程固定磁盘。现阶段也有很多人在多方面试图改善这个状况,包括在 k8s 平台内部以及在外部服务商一端做出的一些改进。” + +------------------------------------------------------------------------------- + +via: https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next + +作者:[Kevin Casey ][a] +译者:[yunfengHe](https://github.com/yunfengHe) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://enterprisersproject.com/user/kevin-casey +[1]:https://enterprisersproject.com/article/2017/11/kubernetes-numbers-10-compelling-stats +[2]:https://enterprisersproject.com/article/2017/11/how-enterprise-it-uses-kubernetes-tame-container-complexity +[3]:https://enterprisersproject.com/article/2017/11/5-kubernetes-success-tips-start-smart?sc_cid=70160000000h0aXAAQ +[4]:https://451research.com/images/Marketing/press_releases/Application-container-market-will-reach-2-7bn-in-2020_final_graphic.pdf +[5]:https://thenewstack.io/ +[6]:https://enterprisersproject.com/article/2017/10/microservices-and-containers-6-management-tips-long-haul +[7]:https://www.cockroachlabs.com/ +[8]:https://enterprisersproject.com/article/2017/10/microservices-and-containers-6-management-tips-long-haul +[9]:https://codemill.se/ +[10]:https://www.redhat.com/en/challenges/integration?intcmp=701f2000000tjyaAAA +[11]:https://enterprisersproject.com/hybrid-cloud +[12]:https://enterprisersproject.com/article/2017/7/multi-cloud-vs-hybrid-cloud-whats-difference +[13]:https://enterprisersproject.com/user/brian-gracely +[14]:https://www.redhat.com/en +[15]:https://www.cloudbees.com/ +[16]:https://enterprisersproject.com/hybrid-cloud?sc_cid=70160000000h0aXAAQ +[17]:https://www.sumologic.com/ +[18]:http://alcide.io/ +[19]:https://enterprisersproject.com/article/2017/10/how-explain-kubernetes-plain-english +[20]:http://opentracing.io/ +[21]:https://istio.io/ +[22]:http://cri-o.io/ +[23]:https://opensource.com/article/17/2/stateful-applications +[24]:https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next?rate=PBQHhF4zPRHcq2KybE1bQgMkS2bzmNzcW2RXSVItmw8 +[25]:https://enterprisersproject.com/user/kevin-casey From 21881aecbca4e83e6cf1e1257c73ea3bff8b2a19 Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Sun, 3 Dec 2017 10:47:25 +0800 Subject: [PATCH 103/344] =?UTF-8?q?20171203=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ow to Manage Users with Groups in Linux.md | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 sources/tech/20171201 How to Manage Users with Groups in Linux.md diff --git a/sources/tech/20171201 How to Manage Users with Groups in Linux.md b/sources/tech/20171201 How to Manage Users with Groups in Linux.md new file mode 100644 index 0000000000..1ab98d864a --- /dev/null +++ b/sources/tech/20171201 How to Manage Users with Groups in Linux.md @@ -0,0 +1,166 @@ +How to Manage Users with Groups in Linux +============================================================ + +### [group-of-people-1645356_1920.jpg][1] + +![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/group-of-people-1645356_1920.jpg?itok=rJlAxBSV) + +Learn how to work with users, via groups and access control lists in this tutorial. + +[Creative Commons Zero][4] + +Pixabay + +When you administer a Linux machine that houses multiple users, there might be times when you need to take more control over those users than the basic user tools offer. This idea comes to the fore especially when you need to manage permissions for certain users. Say, for example, you have a directory that needs to be accessed with read/write permissions by one group of users and only read permissions for another group. With Linux, this is entirely possible. To make this happen, however, you must first understand how to work with users, via groups and access control lists (ACLs). + +We’ll start from the beginning with users and work our way to the more complex ACLs. Everything you need to make this happen will be included in your Linux distribution of choice. We won’t touch on the basics of users, as the focus on this article is about groups. + +For the purpose of this piece, I’m going to assume the following: + +You need to create two users with usernames: + +* olivia + +* nathan + +You need to create two groups: + +* readers + +* editors + +Olivia needs to be a member of the group editors, while nathan needs to be a member of the group readers. The group readers needs to only have read permission to the directory /DATA, whereas the group editors needs to have both read and write permission to the /DATA directory. This, of course, is very minimal, but it will give you the basic information you need to expand the tasks to fit your much larger needs. + +I’ll be demonstrating on the Ubuntu 16.04 Server platform. The commands will be universal—the only difference would be if your distribution of choice doesn’t make use of sudo. If this is the case, you’ll have to first su to the root user to issue the commands that require sudo in the demonstrations. + +### Creating the users + +The first thing we need to do is create the two users for our experiment. User creation is handled with the useradd command. Instead of just simply creating the users we need to create them both with their own home directories and then give them passwords. + +The first thing we do is create the users. To do this, issue the commands: + +``` +sudo useradd -m olivia + +sudo useradd -m nathan +``` + +Next each user must have a password. To add passwords into the mix, you’d issue the following commands: + +``` +sudo passwd olivia + +sudo passwd nathan +``` + +That’s it, your users are created. + +### Creating groups and adding users + +Now we’re going to create the groups readers and editors and then add users to them. The commands to create our groups are: + +``` +addgroup readers + +addgroup editors +``` + +### [groups_1.jpg][2] + +![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/groups_1.jpg?itok=BKwL89BB) + +Figure 1: Our new groups ready to be used. + +[Used with permission][5] + +With our groups created, we need to add our users. We’ll add user nathan to group readers with the command: + +``` +sudo usermod -a -G readers nathan +``` + +``` +sudo usermod -a -G editors olivia +``` + +### Giving groups permissions to directories + +Let’s say you have the directory /READERS and you need to allow all members of the readers group access to that directory. First, change the group of the folder with the command: + +``` +sudo chown -R :readers /READERS +``` + +``` +sudo chmod -R g-w /READERS +``` + +``` +sudo chmod -R o-x /READERS +``` + +Let’s say you have the directory /EDITORS and you need to give members of the editors group read and write permission to its contents. To do that, the following command would be necessary: + +``` +sudo chown -R :editors /EDITORS + +sudo chmod -R g+w /EDITORS + +sudo chmod -R o-x /EDITORS +``` + +The problem with using this method is you can only add one group to a directory at a time. This is where access control lists come in handy. + +### Using access control lists + +Now, let’s get tricky. Say you have a single folder—/DATA—and you want to give members of the readers group read permission and members of the group editors read/write permissions. To do that, you must take advantage of the setfacl command. The setfacl command sets file access control lists for files and folders. + +The structure of this command looks like this: + +``` +setfacl OPTION X:NAME:Y /DIRECTORY +``` + +``` +sudo setfacl -m g:readers:rx -R /DATA +``` + +To give members of the editors group read/write permissions (while retaining read permissions for the readers group), we’d issue the command; + +``` +sudo setfacl -m g:editors:rwx -R /DATA +``` + +### All the control you need + +And there you have it. You can now add members to groups and control those groups’ access to various directories with all the power and flexibility you need. To read more about the above tools, issue the commands: + +* man usradd + +* man addgroup + +* man usermod + +* man sefacl + +* man chown + +* man chmod + +Learn more about Linux through the free ["Introduction to Linux" ][3]course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2017/12/how-manage-users-groups-linux + +作者:[Jack Wallen ] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://www.linux.com/files/images/group-people-16453561920jpg +[2]:https://www.linux.com/files/images/groups1jpg +[3]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux +[4]:https://www.linux.com/licenses/category/creative-commons-zero +[5]:https://www.linux.com/licenses/category/used-permission From e9da3afc7f91b3a6eb68755b06549b5824f0de54 Mon Sep 17 00:00:00 2001 From: darksun Date: Sun, 3 Dec 2017 10:50:32 +0800 Subject: [PATCH 104/344] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Excellent=20Busin?= =?UTF-8?q?ess=20Software=20Alternatives=20For=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...usiness Software Alternatives For Linux.md | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 sources/tech/20171130 Excellent Business Software Alternatives For Linux.md diff --git a/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md b/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md new file mode 100644 index 0000000000..2ef0571fdb --- /dev/null +++ b/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md @@ -0,0 +1,115 @@ +Excellent Business Software Alternatives For Linux +------- + +Many business owners choose to use Linux as the operating system for their operations for a variety of reasons. + +1. Firstly, they don't have to pay anything for the privilege, and that is a massive bonus during the early stages of a company where money is tight. + +2. Secondly, Linux is a light alternative compared to Windows and other popular operating systems available today. + +Of course, lots of entrepreneurs worry they won't have access to some of the essential software packages if they make that move. However, as you will discover throughout this post, there are plenty of similar tools that will cover all the bases. + + [![](https://4.bp.blogspot.com/-xwLuDRdB6sw/Whxx0Z5pI5I/AAAAAAAADhU/YWHID8GU9AgrXRfeTz4HcDZkG-XWZNbSgCLcBGAs/s400/4444061098_6eeaa7dc1a_z.jpg)][3] + +### Alternatives to Microsoft Word + +All company bosses will require access to a word processing tool if they want to ensure the smooth running of their operation according to + +[the latest article from Fareed Siddiqui][4] + +. You'll need that software to write business plans, letters, and many other jobs within your firm. Thankfully, there are a variety of alternatives you might like to select if you opt for the Linux operating system. Some of the most popular ones include: + +* LibreOffice Writer + +* AbiWord + +* KWord + +* LaTeX + +So, you just need to read some online reviews and then download the best word processor based on your findings. Of course, if you're not satisfied with the solution, you should take a look at some of the other ones on that list. In many instances, any of the programs mentioned above should work well. + +### Alternatives to Microsoft Excel + + [![](https://4.bp.blogspot.com/-XdS6bSLQbOU/WhxyeWZeeCI/AAAAAAAADhc/C3hGY6rgzX4m2emunot80-4URu9-aQx8wCLcBGAs/s400/28929069495_e85d2626ba_z.jpg)][5] + +You need a spreadsheet tool if you want to ensure your business doesn't get into trouble when it comes to bookkeeping and inventory control. There are specialist software packages on the market for both of those tasks, but + +[open-source alternatives][6] + +to Microsoft Excel will give you the most amount of freedom when creating your spreadsheets and editing them. While there are other packages out there, some of the best ones for Linux users include: + +* [LibreOffice Calc][1] + +* KSpread + +* Gnumeric + +Those programs work in much the same way as Microsoft Excel, and so you can use them for issues like accounting and stock control. You might also use that software to monitor employee earnings or punctuality. The possibilities are endless and only limited by your imagination. + +### Alternatives to Adobe Photoshop + + [![](https://3.bp.blogspot.com/-Id9Dm3CIXmc/WhxzGIlv3zI/AAAAAAAADho/VfIRCAbJMjMZzG2M97-uqLV9mOhqN7IWACLcBGAs/s400/32206185926_c69accfcef_z.jpg)][7] + +Company bosses require access to design programs when developing their marketing materials and creating graphics for their websites. You might also use software of that nature to come up with a new business logo at some point. Lots of entrepreneurs spend a fortune on + +[Training Connections Photoshop classes][8] + +and those available from other providers. They do that in the hope of educating their teams and getting the best results. However, people who use Linux can still benefit from that expertise if they select one of the following + +[alternatives][9] + +: + +* GIMP + +* Krita + +* Pixel + +* LightZone + +The last two suggestions on that list require a substantial investment. Still, they function in much the same way as Adobe Photoshop, and so you should manage to achieve the same quality of work. + +### Other software solutions that you'll want to consider + +Alongside those alternatives to some of the most widely-used software packages around today, business owners should take a look at the full range of products they could use with the Linux operating system. Here are some tools you might like to research and consider: + +* Inkscape - similar to Coreldraw + +* LibreOffice Base - similar to Microsoft Access + +* LibreOffice Impress - similar to Microsoft PowerPoint + +* File Roller - siThis is a contributed postmilar to WinZip + +* Linphone - similar to Skype + +There are + +[lots of other programs][10] + + you'll also want to research, and so the best solution is to use the internet to learn more. You will find lots of reviews from people who've used the software in the past, and many of them will compare the tool to its Windows or iOS alternative. So, you shouldn't have to work too hard to identify the best ones and sort the wheat from the chaff. + +Now you have all the right information; it's time to weigh all the pros and cons of Linux and work out if it's suitable for your operation. In most instances, that operating system does not place any limits on your business activities. It's just that you need to use different software compared to some of your competitors. People who use Linux tend to benefit from improved security, speed, and performance. Also, the solution gets regular updates, and so it's growing every single day. Unlike Windows and other solutions; you can customize Linux to meet your requirements. With that in mind, do not make the mistake of overlooking this fantastic system! + +-------------------------------------------------------------------------------- + +via: linuxblog.darkduck.com/2017/11/excellent-business-software.html + +作者:[ ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:linuxblog.darkduck.com/2017/11/excellent-business-software.html +[1]:http://linuxblog.darkduck.com/2015/08/pivot-tables-in-libreoffice-calc.html +[3]:https://4.bp.blogspot.com/-xwLuDRdB6sw/Whxx0Z5pI5I/AAAAAAAADhU/YWHID8GU9AgrXRfeTz4HcDZkG-XWZNbSgCLcBGAs/s1600/4444061098_6eeaa7dc1a_z.jpg +[4]:https://www.linkedin.com/pulse/benefits-using-microsoft-word-fareed/ +[5]:https://4.bp.blogspot.com/-XdS6bSLQbOU/WhxyeWZeeCI/AAAAAAAADhc/C3hGY6rgzX4m2emunot80-4URu9-aQx8wCLcBGAs/s1600/28929069495_e85d2626ba_z.jpg +[6]:http://linuxblog.darkduck.com/2014/03/why-open-software-and-what-are-benefits.html +[7]:https://3.bp.blogspot.com/-Id9Dm3CIXmc/WhxzGIlv3zI/AAAAAAAADho/VfIRCAbJMjMZzG2M97-uqLV9mOhqN7IWACLcBGAs/s1600/32206185926_c69accfcef_z.jpg +[8]:https://www.trainingconnection.com/photoshop-training.php +[9]:http://linuxblog.darkduck.com/2011/10/photoshop-alternatives-for-linux.html +[10]:http://www.makeuseof.com/tag/best-linux-software/ From c1f508ce7e4e5851f9e0b8ac14981a2671bfee01 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 3 Dec 2017 10:53:40 +0800 Subject: [PATCH 105/344] =?UTF-8?q?=E5=BD=92=E6=A1=A3=20201711?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- published/{ => 201711}/20141028 When Does Your OS Run.md | 0 ...170202 Understanding Firewalld in Multi-Zone Configurations.md | 0 published/{ => 201711}/20170227 Ubuntu Core in LXD containers.md | 0 ...E PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md | 0 ...ainer Host vs Container OS for Linux and Windows Containers.md | 0 .../20170608 The Life-Changing Magic of Tidying Up Code.md | 0 .../20170706 Wildcard Certificates Coming January 2018.md | 0 ... to Linux App Is a Handy Tool for Every Level of Linux User.md | 0 .../20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md | 0 .../{ => 201711}/20170928 3 Python web scrapers and crawlers.md | 0 published/{ => 201711}/20171002 Scaling the GitLab database.md | 0 .../20171003 PostgreSQL Hash Indexes Are Now Cool.md | 0 .../20171004 No the Linux desktop hasnt jumped in popularity.md | 0 .../20171007 Instant 100 command line productivity boost.md | 0 published/{ => 201711}/20171008 8 best languages to blog about.md | 0 ...aolin Teaching the Next Generation of Cybersecurity Experts.md | 0 ...Started Analyzing Twitter Data in Apache Kafka through KSQL.md | 0 ...0171011 How to set up a Postgres database on a Raspberry Pi.md | 0 published/{ => 201711}/20171011 Why Linux Works.md | 0 .../20171013 6 reasons open source is good for business.md | 0 .../{ => 201711}/20171013 Best of PostgreSQL 10 for the DBA.md | 0 ...015 How to implement cloud-native computing with Kubernetes.md | 0 .../20171015 Monitoring Slow SQL Queries via Slack.md | 0 .../20171015 Why Use Docker with R A DevOps Perspective.md | 0 published/{ => 201711}/20171016 Introducing CRI-O 1.0.md | 0 published/{ => 201711}/20171017 A tour of Postgres Index Types.md | 0 published/{ => 201711}/20171017 Image Processing on Linux.md | 0 .../20171018 How containers and microservices change security.md | 0 ...arn how to program in Python by building a simple dice game.md | 0 .../20171018 Tips to Secure Your Network in the Wake of KRACK.md | 0 .../20171019 3 Simple Excellent Linux Network Monitors.md | 0 ...019 How to manage Docker containers in Kubernetes with Java.md | 0 .../20171020 3 Tools to Help You Remember Linux Commands.md | 0 .../20171020 Running Android on Top of a Linux Graphics Stack.md | 0 .../{ => 201711}/20171024 Top 5 Linux pain points in 2017.md | 0 ...pen source in 2017 Let s analyze GitHub’s data and find out.md | 0 ...171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md | 0 ...p solution with BorgBackup, Rclone and Wasabi cloud storage.md | 0 .../{ => 201711}/20171026 But I dont know what a container is .md | 0 published/{ => 201711}/20171026 Why is Kubernetes so popular.md | 0 published/{ => 201711}/20171101 How to use cron in Linux.md | 0 ...1101 We re switching to a DCO for source code contributions.md | 0 ...171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md | 0 published/{ => 201711}/20171106 Finding Files with mlocate.md | 0 ...06 Linux Foundation Publishes Enterprise Open Source Guides.md | 0 ...uy an open source community clue. Here s how to do it right.md | 0 .../20171107 AWS adopts home-brewed KVM as new hypervisor.md | 0 .../20171107 How I created my first RPM package in Fedora.md | 0 ...20171108 Build and test applications with Ansible Container.md | 0 .../{ => 201711}/20171110 File better bugs with coredumpctl.md | 0 .../20171114 ​Linux totally dominates supercomputers.md | 0 .../{ => 201711}/20171116 5 Coolest Linux Terminal Emulators.md | 0 .../20171117 How to Easily Remember Linux Commands.md | 0 .../20171118 Getting started with OpenFaaS on minikube.md | 0 ... Instantly Share Your Terminal Session To Anyone In Seconds.md | 0 55 files changed, 0 insertions(+), 0 deletions(-) rename published/{ => 201711}/20141028 When Does Your OS Run.md (100%) rename published/{ => 201711}/20170202 Understanding Firewalld in Multi-Zone Configurations.md (100%) rename published/{ => 201711}/20170227 Ubuntu Core in LXD containers.md (100%) rename published/{ => 201711}/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md (100%) rename published/{ => 201711}/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md (100%) rename published/{ => 201711}/20170608 The Life-Changing Magic of Tidying Up Code.md (100%) rename published/{ => 201711}/20170706 Wildcard Certificates Coming January 2018.md (100%) rename published/{ => 201711}/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md (100%) rename published/{ => 201711}/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md (100%) rename published/{ => 201711}/20170928 3 Python web scrapers and crawlers.md (100%) rename published/{ => 201711}/20171002 Scaling the GitLab database.md (100%) rename published/{ => 201711}/20171003 PostgreSQL Hash Indexes Are Now Cool.md (100%) rename published/{ => 201711}/20171004 No the Linux desktop hasnt jumped in popularity.md (100%) rename published/{ => 201711}/20171007 Instant 100 command line productivity boost.md (100%) rename published/{ => 201711}/20171008 8 best languages to blog about.md (100%) rename published/{ => 201711}/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md (100%) rename published/{ => 201711}/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md (100%) rename published/{ => 201711}/20171011 How to set up a Postgres database on a Raspberry Pi.md (100%) rename published/{ => 201711}/20171011 Why Linux Works.md (100%) rename published/{ => 201711}/20171013 6 reasons open source is good for business.md (100%) rename published/{ => 201711}/20171013 Best of PostgreSQL 10 for the DBA.md (100%) rename published/{ => 201711}/20171015 How to implement cloud-native computing with Kubernetes.md (100%) rename published/{ => 201711}/20171015 Monitoring Slow SQL Queries via Slack.md (100%) rename published/{ => 201711}/20171015 Why Use Docker with R A DevOps Perspective.md (100%) rename published/{ => 201711}/20171016 Introducing CRI-O 1.0.md (100%) rename published/{ => 201711}/20171017 A tour of Postgres Index Types.md (100%) rename published/{ => 201711}/20171017 Image Processing on Linux.md (100%) rename published/{ => 201711}/20171018 How containers and microservices change security.md (100%) rename published/{ => 201711}/20171018 Learn how to program in Python by building a simple dice game.md (100%) rename published/{ => 201711}/20171018 Tips to Secure Your Network in the Wake of KRACK.md (100%) rename published/{ => 201711}/20171019 3 Simple Excellent Linux Network Monitors.md (100%) rename published/{ => 201711}/20171019 How to manage Docker containers in Kubernetes with Java.md (100%) rename published/{ => 201711}/20171020 3 Tools to Help You Remember Linux Commands.md (100%) rename published/{ => 201711}/20171020 Running Android on Top of a Linux Graphics Stack.md (100%) rename published/{ => 201711}/20171024 Top 5 Linux pain points in 2017.md (100%) rename published/{ => 201711}/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md (100%) rename published/{ => 201711}/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md (100%) rename published/{ => 201711}/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md (100%) rename published/{ => 201711}/20171026 But I dont know what a container is .md (100%) rename published/{ => 201711}/20171026 Why is Kubernetes so popular.md (100%) rename published/{ => 201711}/20171101 How to use cron in Linux.md (100%) rename published/{ => 201711}/20171101 We re switching to a DCO for source code contributions.md (100%) rename published/{ => 201711}/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md (100%) rename published/{ => 201711}/20171106 Finding Files with mlocate.md (100%) rename published/{ => 201711}/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md (100%) rename published/{ => 201711}/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md (100%) rename published/{ => 201711}/20171107 AWS adopts home-brewed KVM as new hypervisor.md (100%) rename published/{ => 201711}/20171107 How I created my first RPM package in Fedora.md (100%) rename published/{ => 201711}/20171108 Build and test applications with Ansible Container.md (100%) rename published/{ => 201711}/20171110 File better bugs with coredumpctl.md (100%) rename published/{ => 201711}/20171114 ​Linux totally dominates supercomputers.md (100%) rename published/{ => 201711}/20171116 5 Coolest Linux Terminal Emulators.md (100%) rename published/{ => 201711}/20171117 How to Easily Remember Linux Commands.md (100%) rename published/{ => 201711}/20171118 Getting started with OpenFaaS on minikube.md (100%) rename published/{ => 201711}/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md (100%) diff --git a/published/20141028 When Does Your OS Run.md b/published/201711/20141028 When Does Your OS Run.md similarity index 100% rename from published/20141028 When Does Your OS Run.md rename to published/201711/20141028 When Does Your OS Run.md diff --git a/published/20170202 Understanding Firewalld in Multi-Zone Configurations.md b/published/201711/20170202 Understanding Firewalld in Multi-Zone Configurations.md similarity index 100% rename from published/20170202 Understanding Firewalld in Multi-Zone Configurations.md rename to published/201711/20170202 Understanding Firewalld in Multi-Zone Configurations.md diff --git a/published/20170227 Ubuntu Core in LXD containers.md b/published/201711/20170227 Ubuntu Core in LXD containers.md similarity index 100% rename from published/20170227 Ubuntu Core in LXD containers.md rename to published/201711/20170227 Ubuntu Core in LXD containers.md diff --git a/published/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md b/published/201711/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md similarity index 100% rename from published/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md rename to published/201711/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md diff --git a/published/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md b/published/201711/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md similarity index 100% rename from published/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md rename to published/201711/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md diff --git a/published/20170608 The Life-Changing Magic of Tidying Up Code.md b/published/201711/20170608 The Life-Changing Magic of Tidying Up Code.md similarity index 100% rename from published/20170608 The Life-Changing Magic of Tidying Up Code.md rename to published/201711/20170608 The Life-Changing Magic of Tidying Up Code.md diff --git a/published/20170706 Wildcard Certificates Coming January 2018.md b/published/201711/20170706 Wildcard Certificates Coming January 2018.md similarity index 100% rename from published/20170706 Wildcard Certificates Coming January 2018.md rename to published/201711/20170706 Wildcard Certificates Coming January 2018.md diff --git a/published/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md b/published/201711/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md similarity index 100% rename from published/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md rename to published/201711/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md diff --git a/published/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md b/published/201711/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md similarity index 100% rename from published/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md rename to published/201711/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md diff --git a/published/20170928 3 Python web scrapers and crawlers.md b/published/201711/20170928 3 Python web scrapers and crawlers.md similarity index 100% rename from published/20170928 3 Python web scrapers and crawlers.md rename to published/201711/20170928 3 Python web scrapers and crawlers.md diff --git a/published/20171002 Scaling the GitLab database.md b/published/201711/20171002 Scaling the GitLab database.md similarity index 100% rename from published/20171002 Scaling the GitLab database.md rename to published/201711/20171002 Scaling the GitLab database.md diff --git a/published/20171003 PostgreSQL Hash Indexes Are Now Cool.md b/published/201711/20171003 PostgreSQL Hash Indexes Are Now Cool.md similarity index 100% rename from published/20171003 PostgreSQL Hash Indexes Are Now Cool.md rename to published/201711/20171003 PostgreSQL Hash Indexes Are Now Cool.md diff --git a/published/20171004 No the Linux desktop hasnt jumped in popularity.md b/published/201711/20171004 No the Linux desktop hasnt jumped in popularity.md similarity index 100% rename from published/20171004 No the Linux desktop hasnt jumped in popularity.md rename to published/201711/20171004 No the Linux desktop hasnt jumped in popularity.md diff --git a/published/20171007 Instant 100 command line productivity boost.md b/published/201711/20171007 Instant 100 command line productivity boost.md similarity index 100% rename from published/20171007 Instant 100 command line productivity boost.md rename to published/201711/20171007 Instant 100 command line productivity boost.md diff --git a/published/20171008 8 best languages to blog about.md b/published/201711/20171008 8 best languages to blog about.md similarity index 100% rename from published/20171008 8 best languages to blog about.md rename to published/201711/20171008 8 best languages to blog about.md diff --git a/published/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md b/published/201711/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md similarity index 100% rename from published/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md rename to published/201711/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md diff --git a/published/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md b/published/201711/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md similarity index 100% rename from published/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md rename to published/201711/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md diff --git a/published/20171011 How to set up a Postgres database on a Raspberry Pi.md b/published/201711/20171011 How to set up a Postgres database on a Raspberry Pi.md similarity index 100% rename from published/20171011 How to set up a Postgres database on a Raspberry Pi.md rename to published/201711/20171011 How to set up a Postgres database on a Raspberry Pi.md diff --git a/published/20171011 Why Linux Works.md b/published/201711/20171011 Why Linux Works.md similarity index 100% rename from published/20171011 Why Linux Works.md rename to published/201711/20171011 Why Linux Works.md diff --git a/published/20171013 6 reasons open source is good for business.md b/published/201711/20171013 6 reasons open source is good for business.md similarity index 100% rename from published/20171013 6 reasons open source is good for business.md rename to published/201711/20171013 6 reasons open source is good for business.md diff --git a/published/20171013 Best of PostgreSQL 10 for the DBA.md b/published/201711/20171013 Best of PostgreSQL 10 for the DBA.md similarity index 100% rename from published/20171013 Best of PostgreSQL 10 for the DBA.md rename to published/201711/20171013 Best of PostgreSQL 10 for the DBA.md diff --git a/published/20171015 How to implement cloud-native computing with Kubernetes.md b/published/201711/20171015 How to implement cloud-native computing with Kubernetes.md similarity index 100% rename from published/20171015 How to implement cloud-native computing with Kubernetes.md rename to published/201711/20171015 How to implement cloud-native computing with Kubernetes.md diff --git a/published/20171015 Monitoring Slow SQL Queries via Slack.md b/published/201711/20171015 Monitoring Slow SQL Queries via Slack.md similarity index 100% rename from published/20171015 Monitoring Slow SQL Queries via Slack.md rename to published/201711/20171015 Monitoring Slow SQL Queries via Slack.md diff --git a/published/20171015 Why Use Docker with R A DevOps Perspective.md b/published/201711/20171015 Why Use Docker with R A DevOps Perspective.md similarity index 100% rename from published/20171015 Why Use Docker with R A DevOps Perspective.md rename to published/201711/20171015 Why Use Docker with R A DevOps Perspective.md diff --git a/published/20171016 Introducing CRI-O 1.0.md b/published/201711/20171016 Introducing CRI-O 1.0.md similarity index 100% rename from published/20171016 Introducing CRI-O 1.0.md rename to published/201711/20171016 Introducing CRI-O 1.0.md diff --git a/published/20171017 A tour of Postgres Index Types.md b/published/201711/20171017 A tour of Postgres Index Types.md similarity index 100% rename from published/20171017 A tour of Postgres Index Types.md rename to published/201711/20171017 A tour of Postgres Index Types.md diff --git a/published/20171017 Image Processing on Linux.md b/published/201711/20171017 Image Processing on Linux.md similarity index 100% rename from published/20171017 Image Processing on Linux.md rename to published/201711/20171017 Image Processing on Linux.md diff --git a/published/20171018 How containers and microservices change security.md b/published/201711/20171018 How containers and microservices change security.md similarity index 100% rename from published/20171018 How containers and microservices change security.md rename to published/201711/20171018 How containers and microservices change security.md diff --git a/published/20171018 Learn how to program in Python by building a simple dice game.md b/published/201711/20171018 Learn how to program in Python by building a simple dice game.md similarity index 100% rename from published/20171018 Learn how to program in Python by building a simple dice game.md rename to published/201711/20171018 Learn how to program in Python by building a simple dice game.md diff --git a/published/20171018 Tips to Secure Your Network in the Wake of KRACK.md b/published/201711/20171018 Tips to Secure Your Network in the Wake of KRACK.md similarity index 100% rename from published/20171018 Tips to Secure Your Network in the Wake of KRACK.md rename to published/201711/20171018 Tips to Secure Your Network in the Wake of KRACK.md diff --git a/published/20171019 3 Simple Excellent Linux Network Monitors.md b/published/201711/20171019 3 Simple Excellent Linux Network Monitors.md similarity index 100% rename from published/20171019 3 Simple Excellent Linux Network Monitors.md rename to published/201711/20171019 3 Simple Excellent Linux Network Monitors.md diff --git a/published/20171019 How to manage Docker containers in Kubernetes with Java.md b/published/201711/20171019 How to manage Docker containers in Kubernetes with Java.md similarity index 100% rename from published/20171019 How to manage Docker containers in Kubernetes with Java.md rename to published/201711/20171019 How to manage Docker containers in Kubernetes with Java.md diff --git a/published/20171020 3 Tools to Help You Remember Linux Commands.md b/published/201711/20171020 3 Tools to Help You Remember Linux Commands.md similarity index 100% rename from published/20171020 3 Tools to Help You Remember Linux Commands.md rename to published/201711/20171020 3 Tools to Help You Remember Linux Commands.md diff --git a/published/20171020 Running Android on Top of a Linux Graphics Stack.md b/published/201711/20171020 Running Android on Top of a Linux Graphics Stack.md similarity index 100% rename from published/20171020 Running Android on Top of a Linux Graphics Stack.md rename to published/201711/20171020 Running Android on Top of a Linux Graphics Stack.md diff --git a/published/20171024 Top 5 Linux pain points in 2017.md b/published/201711/20171024 Top 5 Linux pain points in 2017.md similarity index 100% rename from published/20171024 Top 5 Linux pain points in 2017.md rename to published/201711/20171024 Top 5 Linux pain points in 2017.md diff --git a/published/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md b/published/201711/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md similarity index 100% rename from published/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md rename to published/201711/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md diff --git a/published/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md b/published/201711/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md similarity index 100% rename from published/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md rename to published/201711/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md diff --git a/published/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md b/published/201711/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md similarity index 100% rename from published/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md rename to published/201711/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md diff --git a/published/20171026 But I dont know what a container is .md b/published/201711/20171026 But I dont know what a container is .md similarity index 100% rename from published/20171026 But I dont know what a container is .md rename to published/201711/20171026 But I dont know what a container is .md diff --git a/published/20171026 Why is Kubernetes so popular.md b/published/201711/20171026 Why is Kubernetes so popular.md similarity index 100% rename from published/20171026 Why is Kubernetes so popular.md rename to published/201711/20171026 Why is Kubernetes so popular.md diff --git a/published/20171101 How to use cron in Linux.md b/published/201711/20171101 How to use cron in Linux.md similarity index 100% rename from published/20171101 How to use cron in Linux.md rename to published/201711/20171101 How to use cron in Linux.md diff --git a/published/20171101 We re switching to a DCO for source code contributions.md b/published/201711/20171101 We re switching to a DCO for source code contributions.md similarity index 100% rename from published/20171101 We re switching to a DCO for source code contributions.md rename to published/201711/20171101 We re switching to a DCO for source code contributions.md diff --git a/published/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md b/published/201711/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md similarity index 100% rename from published/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md rename to published/201711/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md diff --git a/published/20171106 Finding Files with mlocate.md b/published/201711/20171106 Finding Files with mlocate.md similarity index 100% rename from published/20171106 Finding Files with mlocate.md rename to published/201711/20171106 Finding Files with mlocate.md diff --git a/published/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md b/published/201711/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md similarity index 100% rename from published/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md rename to published/201711/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md diff --git a/published/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md b/published/201711/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md similarity index 100% rename from published/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md rename to published/201711/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md diff --git a/published/20171107 AWS adopts home-brewed KVM as new hypervisor.md b/published/201711/20171107 AWS adopts home-brewed KVM as new hypervisor.md similarity index 100% rename from published/20171107 AWS adopts home-brewed KVM as new hypervisor.md rename to published/201711/20171107 AWS adopts home-brewed KVM as new hypervisor.md diff --git a/published/20171107 How I created my first RPM package in Fedora.md b/published/201711/20171107 How I created my first RPM package in Fedora.md similarity index 100% rename from published/20171107 How I created my first RPM package in Fedora.md rename to published/201711/20171107 How I created my first RPM package in Fedora.md diff --git a/published/20171108 Build and test applications with Ansible Container.md b/published/201711/20171108 Build and test applications with Ansible Container.md similarity index 100% rename from published/20171108 Build and test applications with Ansible Container.md rename to published/201711/20171108 Build and test applications with Ansible Container.md diff --git a/published/20171110 File better bugs with coredumpctl.md b/published/201711/20171110 File better bugs with coredumpctl.md similarity index 100% rename from published/20171110 File better bugs with coredumpctl.md rename to published/201711/20171110 File better bugs with coredumpctl.md diff --git a/published/20171114 ​Linux totally dominates supercomputers.md b/published/201711/20171114 ​Linux totally dominates supercomputers.md similarity index 100% rename from published/20171114 ​Linux totally dominates supercomputers.md rename to published/201711/20171114 ​Linux totally dominates supercomputers.md diff --git a/published/20171116 5 Coolest Linux Terminal Emulators.md b/published/201711/20171116 5 Coolest Linux Terminal Emulators.md similarity index 100% rename from published/20171116 5 Coolest Linux Terminal Emulators.md rename to published/201711/20171116 5 Coolest Linux Terminal Emulators.md diff --git a/published/20171117 How to Easily Remember Linux Commands.md b/published/201711/20171117 How to Easily Remember Linux Commands.md similarity index 100% rename from published/20171117 How to Easily Remember Linux Commands.md rename to published/201711/20171117 How to Easily Remember Linux Commands.md diff --git a/published/20171118 Getting started with OpenFaaS on minikube.md b/published/201711/20171118 Getting started with OpenFaaS on minikube.md similarity index 100% rename from published/20171118 Getting started with OpenFaaS on minikube.md rename to published/201711/20171118 Getting started with OpenFaaS on minikube.md diff --git a/published/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md b/published/201711/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md similarity index 100% rename from published/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md rename to published/201711/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md From 64f93dcc22974d307c9b8a97185b982af05ab2f7 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 3 Dec 2017 10:55:20 +0800 Subject: [PATCH 106/344] PUB:20171124 How to Install Android File Transfer for Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @wenwensnow 文章发布地址:https://linux.cn/article-9100-1.html 你的 LCTT 专页地址: https://linux.cn/lctt/wenwensnow 加油! --- .../20171124 How to Install Android File Transfer for Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171124 How to Install Android File Transfer for Linux.md (100%) diff --git a/translated/tech/20171124 How to Install Android File Transfer for Linux.md b/published/20171124 How to Install Android File Transfer for Linux.md similarity index 100% rename from translated/tech/20171124 How to Install Android File Transfer for Linux.md rename to published/20171124 How to Install Android File Transfer for Linux.md From 28f670d4d53e81c989f6e643fca0cd4553929e32 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 3 Dec 2017 10:58:37 +0800 Subject: [PATCH 107/344] PUB:20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @wangy325 文章发布地址:https://linux.cn/article-9101-1.html 你的 LCTT 专页地址: https://linux.cn/lctt/wangy325 加油! --- ...Source Cloud Skills and Certification Are Key for SysAdmins.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md (100%) diff --git a/translated/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md b/published/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md similarity index 100% rename from translated/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md rename to published/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md From e0b5229535a60623ffedaca21d3373986985874c Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 3 Dec 2017 11:02:11 +0800 Subject: [PATCH 108/344] PUB:20171130 Search DuckDuckGo from the Command Line.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @yixunx 文章发布地址:https://linux.cn/article-9102-1.html 你的 LCTT 专页地址:https://linux.cn/lctt/yixunx 加油! --- .../20171130 Search DuckDuckGo from the Command Line.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171130 Search DuckDuckGo from the Command Line.md (100%) diff --git a/translated/tech/20171130 Search DuckDuckGo from the Command Line.md b/published/20171130 Search DuckDuckGo from the Command Line.md similarity index 100% rename from translated/tech/20171130 Search DuckDuckGo from the Command Line.md rename to published/20171130 Search DuckDuckGo from the Command Line.md From 6770d4998854417e2f9da6727fef1ac37b9610f3 Mon Sep 17 00:00:00 2001 From: darksun Date: Sun, 3 Dec 2017 11:09:26 +0800 Subject: [PATCH 109/344] update author info --- ...30 Excellent Business Software Alternatives For Linux.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md b/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md index 2ef0571fdb..3469c62569 100644 --- a/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md +++ b/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md @@ -95,15 +95,15 @@ Now you have all the right information; it's time to weigh all the pros and cons -------------------------------------------------------------------------------- -via: linuxblog.darkduck.com/2017/11/excellent-business-software.html +via: http://linuxblog.darkduck.com/2017/11/excellent-business-software.html -作者:[ ][a] +作者:[DarkDuck][a] 译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 -[a]:linuxblog.darkduck.com/2017/11/excellent-business-software.html +[a]:http://linuxblog.darkduck.com/ [1]:http://linuxblog.darkduck.com/2015/08/pivot-tables-in-libreoffice-calc.html [3]:https://4.bp.blogspot.com/-xwLuDRdB6sw/Whxx0Z5pI5I/AAAAAAAADhU/YWHID8GU9AgrXRfeTz4HcDZkG-XWZNbSgCLcBGAs/s1600/4444061098_6eeaa7dc1a_z.jpg [4]:https://www.linkedin.com/pulse/benefits-using-microsoft-word-fareed/ From 42316e9e7e284bd3d089bb3a7b419d1e8247ab3c Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 3 Dec 2017 11:15:36 +0800 Subject: [PATCH 110/344] PRF&PUB:20171029 A block layer introduction part 1 the bio layer.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @geekpi 已发布: https://linux.cn/article-9103-1.html @oska874 为什么会有这么一篇没头没尾的文章? --- ...block layer introduction part 1 the bio layer.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) rename {translated/tech => published}/20171029 A block layer introduction part 1 the bio layer.md (95%) diff --git a/translated/tech/20171029 A block layer introduction part 1 the bio layer.md b/published/20171029 A block layer introduction part 1 the bio layer.md similarity index 95% rename from translated/tech/20171029 A block layer introduction part 1 the bio layer.md rename to published/20171029 A block layer introduction part 1 the bio layer.md index bc3f582259..96374c2302 100644 --- a/translated/tech/20171029 A block layer introduction part 1 the bio layer.md +++ b/published/20171029 A block layer introduction part 1 the bio layer.md @@ -1,4 +1,4 @@ -块层介绍第一部分:块 I/O 层 +回复:块层介绍第一部分 - 块 I/O 层 ============================================================ ### 块层介绍第一部分:块 I/O 层 @@ -6,9 +6,14 @@ 回复:amarao 在[块层介绍第一部分:块 I/O 层][1] 中提的问题 先前的文章:[块层介绍第一部分:块 I/O 层][2] +![](https://static.lwn.net/images/2017/neil-blocklayer.png) + 嗨, + 你在这里描述的问题与块层不直接相关。这可能是一个驱动错误、可能是一个 SCSI 层错误,但绝对不是一个块层的问题。 + 不幸的是,报告针对 Linux 的错误是一件难事。有些开发者拒绝去看 bugzilla,有些开发者喜欢它,有些(像我这样)只能勉强地使用它。 + 另一种方法是发送电子邮件。为此,你需要选择正确的邮件列表,还有也许是正确的开发人员,当他们心情愉快,或者不是太忙或者不是假期时找到它们。有些人会努力回复所有,有些是完全不可预知的 - 这对我来说通常会发送一个补丁,包含一些错误报告。如果你只是有一个你自己几乎都不了解的 bug,那么你的预期响应率可能会更低。很遗憾,但这是是真的。 许多 bug 都会得到回应和处理,但很多 bug 都没有。 @@ -16,18 +21,20 @@ 我不认为说没有人关心是公平的,但是没有人认为它如你想的那样重要是有可能的。如果你想要一个解决方案,那么你需要驱动它。一个驱动它的方法是花钱请顾问或者与经销商签订支持合同。我怀疑你的情况没有上面的可能。另一种方法是了解代码如何工作,并自己找到解决方案。很多人都这么做,但是这对你来说可能不是一种选择。另一种方法是在不同的相关论坛上不断提出问题,直到得到回复。坚持可以见效。你需要做好准备去执行任何你所要求的测试,可能包括建立一个新的内核来测试。 如果你能在最近的内核(4.12 或者更新)上复现这个 bug,我建议你邮件报告给 linux-kernel@vger.kernel.org、linux-scsi@vger.kernel.org 和我(neilb@suse.com)(注意你不必订阅这些列表来发送邮件,只需要发送就行)。描述你的硬件以及如何触发问题的。 + 包含所有进程状态是 “D” 的栈追踪。你可以用 “cat /proc/$PID/stack” 来得到它,这里的 “$PID” 是进程的 pid。 确保避免抱怨或者说这个已经坏了好几年了以及这是多么严重不足。没有人关心这个。我们关心的是 bug 以及如何修复它。因此只要报告相关的事实就行。 + 尝试在邮件中而不是链接到其他地方的链接中包含所有事实。有时链接是需要的,但是对于你的脚本,它只有 8 行,所以把它包含在邮件中就行(并避免像 “fuckup” 之类的描述。只需称它为“坏的”(broken)或者类似的)。同样确保你的邮件发送的不是 HTML 格式。我们喜欢纯文本。HTML 被所有的 @vger.kernel.org 邮件列表拒绝。你或许需要配置你的邮箱程序不发送 HTML。 -------------------------------------------------------------------------------- via: https://lwn.net/Articles/737655/ -作者:[ neilbrown][a] +作者:[neilbrown][a] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 8bd3b19ddb17c4157b3006320f882c04e2ae08bf Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Sun, 3 Dec 2017 11:39:21 +0800 Subject: [PATCH 111/344] =?UTF-8?q?20171203=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ux Programs for Drawing and Image Editing.md | 130 +++++++++++++++++ ...stem Logs: Understand Your Linux System.md | 59 ++++++++ ...ke up and Shut Down Linux Automatically.md | 132 ++++++++++++++++++ ...1 Fedora Classroom Session: Ansible 101.md | 71 ++++++++++ 4 files changed, 392 insertions(+) create mode 100644 sources/tech/20171116 Unleash Your Creativity – Linux Programs for Drawing and Image Editing.md create mode 100644 sources/tech/20171117 System Logs: Understand Your Linux System.md create mode 100644 sources/tech/20171130 Wake up and Shut Down Linux Automatically.md create mode 100644 sources/tech/20171201 Fedora Classroom Session: Ansible 101.md diff --git a/sources/tech/20171116 Unleash Your Creativity – Linux Programs for Drawing and Image Editing.md b/sources/tech/20171116 Unleash Your Creativity – Linux Programs for Drawing and Image Editing.md new file mode 100644 index 0000000000..c6c50d9b25 --- /dev/null +++ b/sources/tech/20171116 Unleash Your Creativity – Linux Programs for Drawing and Image Editing.md @@ -0,0 +1,130 @@ +### Unleash Your Creativity – Linux Programs for Drawing and Image Editing + + By: [chabowski][1] + +The following article is part of a series of articles that provide tips and tricks for Linux newbies – or Desktop users that are not yet experienced with regard to certain topics. This series intends to complement the special edition #30 “[Getting Started with Linux][2]” based on [openSUSE Leap][3], recently published by the [Linux Magazine,][4] with valuable additional information. + +![](https://www.suse.com/communities/blog/files/2017/11/DougDeMaio-450x450.jpeg) + +This article has been contributed by Douglas DeMaio, openSUSE PR Expert at SUSE. + +Both Mac OS or Window offer several popular programs for graphics editing, vector drawing and creating and manipulating Portable Document Format (PDF). The good news: users familiar with the Adobe Suite can transition with ease to free, open-source programs available on Linux. + +Programs like [GIMP][5], [InkScape][6] and [Okular][7] are cross platform programs that are available by default in Linux/GNU distributions and are persuasive alternatives to expensive Adobe programs like [Photoshop][8], [Illustrator][9] and [Acrobat][10]. + +These creativity programs on Linux distributions are just as powerful as those for macOS or Window. This article will explain some of the differences and how the programs can be used to make your transition to Linux comfortable. + +### Krita + +The KDE desktop environment comes with tons of cool applications. [Krita][11] is a professional open source painting program. It gives users the freedom to create any artistic image they desire. Krita features tools that are much more extensive than the tool sets of most proprietary programs you might be familiar with. From creating textures to comics, Krita is a must have application for Linux users. + +![](https://www.suse.com/communities/blog/files/2017/11/krita-450x267.png) + +### GIMP + +GNU Image Manipulation Program (GIMP) is a cross-platform image editor. Users of Photoshop will find the User Interface of GIMP to be similar to that of Photoshop. The drop down menu offers colors, layers, filters and tools to help the user with editing graphics. Rulers are located both horizontal and vertical and guide can be dragged across the screen to give exact measurements. The drop down menu gives tool options for resizing or cropping photos; adjustments can be made to the color balance, color levels, brightness and contrast as well as hue and saturation. + +![](https://www.suse.com/communities/blog/files/2017/11/gimp-450x281.png) + +There are multiple filters in GIMP to enhance or distort your images. Filters for artistic expression and animation are available and are more powerful tool options than those found in some proprietary applications. Gradients can be applied through additional layers and the Text Tool offers many fonts, which can be altered in shape and size through the Perspective Tool. + +The cloning tool works exactly like those in other graphics editors, so manipulating images is simple and acurrate given the selection of brush sizes to do the job. + +Perhaps one of the best options available with GIMP is that the images can be saved in a variety of formats like .jpg, .png, .pdf, .eps and .svg. These image options provide high-quality images in a small file. + +### InkScape + +Designing vector imagery with InkScape is simple and free. This cross platform allows for the creation of logos and illustrations that are highly scalable. Whether designing cartoons or creating images for branding, InkScape is a powerful application to get the job done. Like GIMP, InkScape lets you save files in various formats and allows for object manipulation like moving, rotating and skewing text and objects. Shape tools are available with InkScape so making stars, hexagons and other elements will meet the needs of your creative mind. + +![](https://www.suse.com/communities/blog/files/2017/11/inkscape-450x273.png) + +InkScape offers a comprehensive tool set, including a drawing tool, a pen tool and the freehand calligraphy tool that allows for object creation with your own personal style. The color selector gives you the choice of RGB, CMYK and RGBA – using specific colors for branding logos, icons and advertisement is definitely convincing. + +Short cut commands are similar to what users experience in Adobe Illustrator. Making layers and grouping or ungrouping the design elements can turn a blank page into a full-fledged image that can be used for designing technical diagrams for presentations, importing images into a multimedia program or for creating web graphics and software design. + +Inkscape can import vector graphics from multiple other programs. It can even import bitmap images. Inkscape is one of those cross platform, open-source programs that allow users to operate across different operating systems, no matter if they work with macOS, Windows or Linux. + +### Okular and LibreOffice + +LibreOffice, which is a free, open-source Office Suite, allows users to collaborate and interact with documents and important files on Linux, but also on macOS and Window. You can also create PDF files via LibreOffice, and LibreOffice Draw lets you view (and edit) PDF files as images. + +![](https://www.suse.com/communities/blog/files/2017/11/draw-450x273.png) + +However, the Portable Document Format (PDF) is quite different on the three Operating Systems. MacOS offers [Preview][12] by default; Windows has [Edge][13]. Of course, also Adobe Reader can be used for both MacOS and Window. With Linux, and especially the desktop selection of KDE, [Okular][14] is the default program for viewing PDF files. + +![](https://www.suse.com/communities/blog/files/2017/11/okular-450x273.png) + +The functionality of Okular supports different types of documents, like PDF, Postscript, [DjVu][15], [CHM][16], [XPS][17], [ePub][18] and others. Yet the universal document viewer also offers some powerful features that make interacting with a document different from other programs on MacOS and Windows. Okular gives selection and search tools that make accessing the text in PDFs fluid for how users interact with documents. Viewing documents with Okular is also accommodating with the magnification tool that allows for a quick look at small text in a document. + +Okular also provides users with the option to configure it to use more memory if the document is too large and freezes the Operating System. This functionality is convenient for users accessing high-quality print documents for example for advertising. + +For those who want to change locked images and documents, it’s rather easy to do so with LibreOffice Draw. A hypothetical situation would be to take a locked IRS (or tax) form and change it to make the uneditable document editable. Imagine how much fun it could be to transform it to some humorous kind of tax form … + +And indeed, the sky’s the limit on how creative a user wants to be when using programs that are available on Linux distributions. + +![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) + +![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) + +![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) + +![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) + +![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) + +( + + _**2** votes, average: **5.00** out of 5_ + +) + + _You need to be a registered member to rate this post._ + +Tags: [drawing][19], [Getting Started with Linux][20], [GIMP][21], [image editing][22], [Images][23], [InkScape][24], [KDE][25], [Krita][26], [Leap 42.3][27], [LibreOffice][28], [Linux Magazine][29], [Okular][30], [openSUSE][31], [PDF][32] Categories: [Desktop][33], [Expert Views][34], [LibreOffice][35], [openSUSE][36] + +-------------------------------------------------------------------------------- + +via: https://www.suse.com/communities/blog/unleash-creativity-linux-programs-drawing-image-editing/ + +作者:[chabowski ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://www.suse.com/communities/blog/author/chabowski/ +[2]:http://www.linux-magazine.com/Resources/Special-Editions/30-Getting-Started-with-Linux +[3]:https://en.opensuse.org/Portal:42.3 +[4]:http://www.linux-magazine.com/ +[5]:https://www.gimp.org/ +[6]:https://inkscape.org/en/ +[7]:https://okular.kde.org/ +[8]:http://www.adobe.com/products/photoshop.html +[9]:http://www.adobe.com/products/illustrator.html +[10]:https://acrobat.adobe.com/us/en/acrobat/acrobat-pro-cc.html +[11]:https://krita.org/en/ +[12]:https://en.wikipedia.org/wiki/Preview_(macOS) +[13]:https://en.wikipedia.org/wiki/Microsoft_Edge +[14]:https://okular.kde.org/ +[15]:http://djvu.org/ +[16]:https://fileinfo.com/extension/chm +[17]:https://fileinfo.com/extension/xps +[18]:http://idpf.org/epub +[19]:https://www.suse.com/communities/blog/tag/drawing/ +[20]:https://www.suse.com/communities/blog/tag/getting-started-with-linux/ +[21]:https://www.suse.com/communities/blog/tag/gimp/ +[22]:https://www.suse.com/communities/blog/tag/image-editing/ +[23]:https://www.suse.com/communities/blog/tag/images/ +[24]:https://www.suse.com/communities/blog/tag/inkscape/ +[25]:https://www.suse.com/communities/blog/tag/kde/ +[26]:https://www.suse.com/communities/blog/tag/krita/ +[27]:https://www.suse.com/communities/blog/tag/leap-42-3/ +[28]:https://www.suse.com/communities/blog/tag/libreoffice/ +[29]:https://www.suse.com/communities/blog/tag/linux-magazine/ +[30]:https://www.suse.com/communities/blog/tag/okular/ +[31]:https://www.suse.com/communities/blog/tag/opensuse/ +[32]:https://www.suse.com/communities/blog/tag/pdf/ +[33]:https://www.suse.com/communities/blog/category/desktop/ +[34]:https://www.suse.com/communities/blog/category/expert-views/ +[35]:https://www.suse.com/communities/blog/category/libreoffice/ +[36]:https://www.suse.com/communities/blog/category/opensuse/ diff --git a/sources/tech/20171117 System Logs: Understand Your Linux System.md b/sources/tech/20171117 System Logs: Understand Your Linux System.md new file mode 100644 index 0000000000..0dcaa57925 --- /dev/null +++ b/sources/tech/20171117 System Logs: Understand Your Linux System.md @@ -0,0 +1,59 @@ +### System Logs: Understand Your Linux System + +![chabowski](https://www.suse.com/communities/blog/files/2016/03/chabowski_avatar_1457537819-100x100.jpg) + By: [chabowski][1] + +The following article is part of a series of articles that provide tips and tricks for Linux newbies – or Desktop users that are not yet experienced with regard to certain topics). This series intends to complement the special edition #30 “[Getting Started with Linux][2]” based on [openSUSE Leap][3], recently published by the [Linux Magazine,][4] with valuable additional information. + +This article has been contributed by Romeo S. Romeo is a PDX-based enterprise Linux professional specializing in scalable solutions for innovative corporations looking to disrupt the marketplace. + +System logs are incredibly important files in Linux. Special programs that run in the background (usually called daemons or servers) handle most of the tasks on your Linux system. Whenever these daemons do anything, they write the details of the task to a log file as a sort of “history” of what they’ve been up to. These daemons perform actions ranging from syncing your clock with an atomic clock to managing your network connection. All of this is written to log files so that if something goes wrong, you can look into the specific log file and see what happened. + +![](https://www.suse.com/communities/blog/files/2017/11/markus-spiske-153537-300x450.jpg) + +Photo by Markus Spiske on Unsplash + +There are many different logs on your Linux computer. Historically, they were mostly stored in the /var/log directory in a plain text format. Quite a few still are, and you can read them easily with the less pager. On your freshly installed openSUSE Leap 42.3 system, and on most modern systems, important logs are stored by the systemd init system. This is the system that handles starting up daemons and getting the computer ready for use on startup. The logs handled by systemd are stored in a binary format, which means that they take up less space and can more easily be viewed or exported in various formats, but the downside is that you need a special tool to view them. Luckily, this tool comes installed on your system: it’s called journalctl and by default, it records all of the logs from every daemon to one location. + +To take a look at your systemd log, just run the journalctl command. This will open up the combined logs in the less pager. To get a better idea of what you’re looking at, see a single log entry from journalctl here: + +``` +Jul 06 11:53:47 aaathats3as pulseaudio[2216]: [pulseaudio] alsa-util.c: Disabling timer-based scheduling because running inside a VM. +``` + +This individual log entry contains (in order) the date and time of the entry, the hostname of the computer, the name of the process that logged the entry, the PID (process ID number) of the process that logged the entry, and then the log entry itself. + +If a program running on your system is misbehaving, look at the log file and search (with the “/” key followed by the search term) for the name of the program. Chances are that if the program is reporting errors that are causing it to malfunction, then the errors will show up in the system log. Sometimes errors are verbose enough for you to be able to fix them yourself. Other times, you have to search for a solution on the Web. Google is usually the most convenient search engine to use for weird Linux problems +![](https://www.suse.com/communities/blog/files/2017/09/Sunglasses_Emoji-450x450.png) +. However, be sure that you only enter the actual log entry, because the rest of the information at the beginning of the line (date, host name, PID) is unnecessary and could return false positives. + +After you search for the problem, the first few results are usually pages containing various things that you can try for solutions. Of course, you shouldn’t just follow random instructions that you find on the Internet: always be sure to do additional research into what exactly you will be doing and what the effects of it are before following any instructions. With that being said, the results for a specific entry from the system’s log file are usually much more useful than results from searching more generic terms that describe the malfunctioning of the program directly. This is because many different things could cause a program to misbehave, and multiple problems could cause identical misbehaviors. + +For example, a lack of audio on the system could be due to a massive amount of different reasons, ranging from speakers not being plugged in, to back end sound systems misbehaving, to a lack of the proper drivers. If you search for a general problem, you’re likely to see a lot of irrelevant solutions and you’ll end up wasting your time on a wild goose chase. With a specific search of an actual line from a log file, you can see other people who have had the same log entry. See Picture 1 and Picture 2 to compare and contrast between the two types of searching. + +![](https://www.suse.com/communities/blog/files/2017/11/picture1-450x450.png) + +Picture 1 shows generic, unspecific Google results for a general misbehavior of the system. This type of searching generally doesn’t help much. + +![](https://www.suse.com/communities/blog/files/2017/11/picture2-450x450.png) + +Picture 2 shows more specific, helpful Google results for a particular log file line. This type of searching is generally very helpful. + +There are some systems that log their actions outside of journalctl. The most important ones that you may find yourself dealing with on a desktop system are /var/log/zypper.log for openSUSE’s package manager, /var/log/boot.log for those messages that scroll by too fast to be read when you turn your system on, and /var/log/ntp if your Network Time Protocol Daemon is having troubles syncing time. One more important place to look for errors if you’re having problems with specific hardware is the Kernel Ring Buffer, which you can read by typing the dmesg -H command (this opens in the less pager as well). The Kernel Ring Buffer is stored in RAM, so you lose it when you reboot your system, but it contains important messages from the Linux kernel about important events, such as hardware being added, modules being loaded, or strange network errors. + +Hopefully you are prepared now to understand your Linux system better! Have a lot of fun! + +-------------------------------------------------------------------------------- + +via: https://www.suse.com/communities/blog/system-logs-understand-linux-system/ + +作者:[chabowski] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://www.suse.com/communities/blog/author/chabowski/ +[2]:http://www.linux-magazine.com/Resources/Special-Editions/30-Getting-Started-with-Linux +[3]:https://en.opensuse.org/Portal:42.3 +[4]:http://www.linux-magazine.com/ diff --git a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md new file mode 100644 index 0000000000..efb0937695 --- /dev/null +++ b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md @@ -0,0 +1,132 @@ +Wake up and Shut Down Linux Automatically +============================================================ + +### [banner.jpg][1] + +![time keeper](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/banner.jpg?itok=zItspoSb) + +Learn how to configure your Linux computers to watch the time for you, then wake up and shut down automatically. + +[Creative Commons Attribution][6][The Observatory at Delhi][7] + +Don't be a watt-waster. If your computers don't need to be on then shut them down. For convenience and nerd creds, you can configure your Linux computers to wake up and shut down automatically. + +### Precious Uptimes + +Some computers need to be on all the time, which is fine as long as it's not about satisfying an uptime compulsion. Some people are very proud of their lengthy uptimes, and now that we have kernel hot-patching that leaves only hardware failures requiring shutdowns. I think it's better to be practical. Save electricity as well as wear on your moving parts, and shut them down when they're not needed. For example, you can wake up a backup server at a scheduled time, run your backups, and then shut it down until it's time for the next backup. Or, you can configure your Internet gateway to be on only at certain times. Anything that doesn't need to be on all the time can be configured to turn on, do a job, and then shut down. + +### Sleepies + +For computers that don't need to be on all the time, good old cron will shut them down reliably. Use either root's cron, or /etc/crontab. This example creates a root cron job to shut down every night at 11:15 p.m. + +``` +# crontab -e -u root +# m h dom mon dow command +15 23 * * * /sbin/shutdown -h now +``` + +``` +15 23 * * 1-5 /sbin/shutdown -h now +``` + +You may also use /etc/crontab, which is fast and easy, and everything is in one file. You have to specify the user: + +``` +15 23 * * 1-5 root shutdown -h now +``` + +Auto-wakeups are very cool; most of my SUSE colleagues are in Nuremberg, so I am crawling out of bed at 5 a.m. to have a few hours of overlap with their schedules. My work computer turns itself on at 5:30 a.m., and then all I have to do is drag my coffee and myself to my desk to start work. It might not seem like pressing a power button is a big deal, but at that time of day every little thing looms large. + +Waking up your Linux PC can be less reliable than shutting it down, so you may want to try different methods. You can use wakeonlan, RTC wakeups, or your PC's BIOS to set scheduled wakeups. These all work because, when you power off your computer, it's not really all the way off; it is in an extremely low-power state and can receive and respond to signals. You need to use the power supply switch to turn it off completely. + +### BIOS Wakeup + +A BIOS wakeup is the most reliable. My system BIOS has an easy-to-use wakeup scheduler (Figure 1). Chances are yours does, too. Easy peasy. + +### [fig-1.png][2] + +![wake up](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_11.png?itok=8qAeqo1I) + +Figure 1: My system BIOS has an easy-to-use wakeup scheduler. + +[Used with permission][8] + +### wakeonlan + +wakeonlan is the next most reliable method. This requires sending a signal from a second computer to the computer you want to power on. You could use an Arduino or Raspberry Pi to send the wakeup signal, a Linux-based router, or any Linux PC. First, look in your system BIOS to see if wakeonlan is supported -- which it should be -- and then enable it, as it should be disabled by default. + +Then, you'll need an Ethernet network adapter that supports wakeonlan; wireless adapters won't work. You'll need to verify that your Ethernet card supports wakeonlan: + +``` +# ethtool eth0 | grep -i wake-on + Supports Wake-on: pumbg + Wake-on: g +``` + +* d -- all wake ups disabled + +* p -- wake up on physical activity + +* u -- wake up on unicast messages + +* m -- wake up on multicast messages + +* b -- wake up on broadcast messages + +* a -- wake up on ARP messages + +* g -- wake up on magic packet + +* s -- set the Secure On password for the magic packet + +man ethtool is not clear on what the p switch does; it suggests that any signal will cause a wake up. In my testing, however, it doesn't do that. The one that must be enabled is g -- wake up on magic packet, and the Wake-on line shows that it is already enabled. If it is not enabled, you can use ethtool to enable it, using your own device name, of course: + +``` +# ethtool -s eth0 wol g +``` + +``` +@reboot /usr/bin/ethtool -s eth0 wol g +``` + +### [fig-2.png][3] + +![wakeonlan](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-2_7.png?itok=XQAwmHoQ) + +Figure 2: Enable Wake on LAN. + +[Used with permission][9] + +Another option is recent Network Manager versions have a nice little checkbox to enable wakeonlan (Figure 2). + +There is a field for setting a password, but if your network interface doesn't support the Secure On password, it won't work. + +Now you need to configure a second PC to send the wakeup signal. You don't need root privileges, so create a cron job for your user. You need the MAC address of the network interface on the machine you're waking up: + +``` +30 08 * * * /usr/bin/wakeonlan D0:50:99:82:E7:2B +``` + +Using the real-time clock for wakeups is the least reliable method. Check out [Wake Up Linux With an RTC Alarm Clock][4]; this is a bit outdated as most distros use systemd now. Come back next week to learn more about updated ways to use RTC wakeups. + +Learn more about Linux through the free ["Introduction to Linux" ][5]course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2017/11/wake-and-shut-down-linux-automatically + +作者:[Carla Schroder] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://www.linux.com/files/images/bannerjpg +[2]:https://www.linux.com/files/images/fig-1png-11 +[3]:https://www.linux.com/files/images/fig-2png-7 +[4]:https://www.linux.com/learn/wake-linux-rtc-alarm-clock +[5]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux +[6]:https://www.linux.com/licenses/category/creative-commons-attribution +[7]:http://www.columbia.edu/itc/mealac/pritchett/00routesdata/1700_1799/jaipur/delhijantarearly/delhijantarearly.html +[8]:https://www.linux.com/licenses/category/used-permission +[9]:https://www.linux.com/licenses/category/used-permission diff --git a/sources/tech/20171201 Fedora Classroom Session: Ansible 101.md b/sources/tech/20171201 Fedora Classroom Session: Ansible 101.md new file mode 100644 index 0000000000..a74b196663 --- /dev/null +++ b/sources/tech/20171201 Fedora Classroom Session: Ansible 101.md @@ -0,0 +1,71 @@ +### [Fedora Classroom Session: Ansible 101][2] + +### By Sachin S Kamath + +![](https://fedoramagazine.org/wp-content/uploads/2017/07/fedora-classroom-945x400.jpg) + +Fedora Classroom sessions continue this week with an Ansible session. The general schedule for sessions appears [on the wiki][3]. You can also find [resources and recordings from previous sessions][4] there. Here are details about this week’s session on [Thursday, 30th November at 1600 UTC][5]. That link allows you to convert the time to your timezone. + +### Topic: Ansible 101 + +As the Ansible [documentation][6] explains, Ansible is an IT automation tool. It’s primarily used to configure systems, deploy software, and orchestrate more advanced IT tasks. Examples include continuous deployments or zero downtime rolling updates. + +This Classroom session covers the topics listed below: + +1. Introduction to SSH + +2. Understanding different terminologies + +3. Introduction to Ansible + +4. Ansible installation and setup + +5. Establishing password-less connection + +6. Ad-hoc commands + +7. Managing inventory + +8. Playbooks examples + +There will also be a follow-up Ansible 102 session later. That session will cover complex playbooks, roles, dynamic inventory files, control flow and Galaxy. + +### Instructors + +We have two experienced instructors handling this session. + +[Geoffrey Marr][7], also known by his IRC name as “coremodule,” is a Red Hat employee and Fedora contributor with a background in Linux and cloud technologies. While working, he spends his time lurking in the [Fedora QA][8] wiki and test pages. Away from work, he enjoys RaspberryPi projects, especially those focusing on software-defined radio. + +[Vipul Siddharth][9] is an intern at Red Hat who also works on Fedora. He loves to contribute to open source and seeks opportunities to spread the word of free and open source software. + +### Joining the session + +This session takes place on [BlueJeans][10]. The following information will help you join the session: + +* URL: [https://bluejeans.com/3466040121][1] + +* Meeting ID (for Desktop App): 3466040121 + +We hope you attend, learn from, and enjoy this session! If you have any feedback about the sessions, have ideas for a new one or want to host a session, please feel free to comment on this post or edit the [Classroom wiki page][11]. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/fedora-classroom-session-ansible-101/ + +作者:[Sachin S Kamath] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://bluejeans.com/3466040121 +[2]:https://fedoramagazine.org/fedora-classroom-session-ansible-101/ +[3]:https://fedoraproject.org/wiki/Classroom +[4]:https://fedoraproject.org/wiki/Classroom#Previous_Sessions +[5]:https://www.timeanddate.com/worldclock/fixedtime.html?msg=Fedora+Classroom+-+Ansible+101&iso=20171130T16&p1=%3A +[6]:http://docs.ansible.com/ansible/latest/index.html +[7]:https://fedoraproject.org/wiki/User:Coremodule +[8]:https://fedoraproject.org/wiki/QA +[9]:https://fedoraproject.org/wiki/User:Siddharthvipul1 +[10]:https://www.bluejeans.com/downloads +[11]:https://fedoraproject.org/wiki/Classroom From 21b6ea41aa8c7ca57f96f12d12bddf2d4cac40b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=88=E6=B0=B8?= Date: Sun, 3 Dec 2017 13:08:26 +0800 Subject: [PATCH 112/344] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=EF=BC=8C=E6=96=87=E7=90=86=E4=B8=8D=E5=A4=AA=E9=80=9A=E9=A1=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... guide to links in the Linux filesystem.md | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/sources/tech/20170622 A users guide to links in the Linux filesystem.md b/sources/tech/20170622 A users guide to links in the Linux filesystem.md index 5ee614a216..c270ded7df 100644 --- a/sources/tech/20170622 A users guide to links in the Linux filesystem.md +++ b/sources/tech/20170622 A users guide to links in the Linux filesystem.md @@ -6,7 +6,7 @@ linux 文件链接用户指南 ### 学习如何使用链接,通过提供对 linux 文件系统多个位置的文件访问,来让日常工作变得轻松 -![A user's guide to links in the Linux filesystem](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/links.png?itok=AumNmse7 "A user's guide to links in the Linux filesystem") +![linux 文件链接用户指南](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/links.png?itok=AumNmse7 "A user's guide to links in the Linux filesystem") Image by : [Paul Lewin][8]. Modified by Opensource.com. [CC BY-SA 2.0][9] 在我为 opensource.com 写过的关于linux文件系统方方面面的文章中,包括 [An introduction to Linux's EXT4 filesystem][10]; [Managing devices in Linux][11]; [An introduction to Linux filesystems][12]; and [A Linux user's guide to Logical Volume Management][13],我曾简要的提到过linux文件系统一个有趣的特性,它允许用户访问linux文件目录树中多个位置的文件来简化一些任务 @@ -186,9 +186,9 @@ ln: failed to create hard link '/tmp/link3.file.txt' => 'link2.file.txt': Invalid cross-device link ``` -为什么会出现这个错误呢? 原因是每一个单独的挂载文件系统都有一套自己的节点号。 Simply referring to a file by an inode number across the entire Linux directory structure can result in confusion because the same inode number can exist in each mounted filesystem. +为什么会出现这个错误呢? 原因是每一个单独的挂载文件系统都有一套自己的节点号。简单的通过文件节点号来跨越整个文件系统结构引用一个文件会使系统困惑,因为相同的节点号会存在于每个已挂载的文件系统中。 -There may be a time when you will want to locate all the hard links that belong to a single inode. You can find the inode number using the **ls -li** command. Then you can use the **find** command to locate all links with that inode number. +有时你可能会想找到一个文件节点的所有硬链接。你可以使用 **ls -li** 命令。然后使用 **find** 命令找到所有硬链接的节点号。 ``` [dboth@david temp]$ find . -inum 657024 @@ -197,7 +197,7 @@ There may be a time when you will want to locate all the hard links that belong ./link2.file.txt ``` -Note that the **find** command did not find all four of the hard links to this inode because we started at the current directory of **~/temp**. The **find** command only finds files in the PWD and its subdirectories. To find all the links, we can use the following command, which specifies your home directory as the starting place for the search. +注意 **find** 命令不能找到所属该节点的四个硬链接,因为我们在 **~/temp** 目录中查找。 **find** 命令仅在当前工作目录及其子目录中中查找文件。要找到所有的硬链接,我们可以使用下列命令,注定你的主目录作为起始查找条件。 ``` [dboth@david temp]$ find ~ -samefile main.file.txt @@ -207,13 +207,13 @@ Note that the **find** command did not find all four of the hard links to this /home/dboth/main.file.txt ``` -You may see error messages if you do not have permissions as a non-root user. This command also uses the **-samefile** option instead of specifying the inode number. This works the same as using the inode number and can be easier if you know the name of one of the hard links. +如果你是非超级用户没有权限,可能会看到错误信息。这个命令也使用了 **-samefile** 选项而不是指定文件的节点号。这个效果和使用文件节点号一样且更容易,如果你知道其中一个硬链接名称的话。 -### **Experimenting with soft links** +### **对软链接进行实验** -As you have just seen, creating hard links is not possible across filesystem boundaries; that is, from a filesystem on one LV or partition to a filesystem on another. Soft links are a means to answer that problem with hard links. Although they can accomplish the same end, they are very different, and knowing these differences is important. +如你刚才看到的,不能越过文件系统交叉创建硬链接,即在逻辑卷或文件系统中从一个文件系统到另一个文件系统。软链接给出了这个问题的解决方案。虽然他们可以达到相同的目的,但他们是非常不同的,知道这些差异是很重要的。 -Let's start by creating a symlink in our **~/temp** directory to start our exploration. +让我们在 **~/temp** 目录中创建一个符号链接来开始我们的探索。 ``` [dboth@david temp]$ ln -s link2.file.txt link3.file.txt ; ls -li @@ -226,9 +226,9 @@ link2.file.txt 657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file ``` -The hard links, those that have the inode number **657024**, are unchanged, and the number of hard links shown for each has not changed. The newly created symlink has a different inode, number **658270**. The soft link named **link3.file.txt**points to **link2.file.txt**. Use the **cat** command to display the contents of **link3.file.txt**. The file mode information for the symlink starts with the letter "**l**" which indicates that this file is actually a symbolic link. +拥有节点号 **657024** 的那些硬链接没有变化,且硬链接的数目也没有变化。新创建的符号链接有不同的文件节点号 **658270**。 名为**link3.file.txt** 的软链接指向了 **link2.file.txt** 文件。使用 **cat** 命令查看 **link3.file.txt** 文件的内容。符号链接的文件节点信息以字母 "**l**" 开头,意味着这个文件实际是个符号链接。 -The size of the symlink **link3.file.txt** is only 14 bytes in the example above. That is the size of the text **link3.file.txt -> link2.file.txt**, which is the actual content of the directory entry. The directory entry **link3.file.txt** does not point to an inode; it points to another directory entry, which makes it useful for creating links that span file system boundaries. So, let's create that link we tried before from the **/tmp** directory. +上例中软链接文件 **link3.file.txt** 的大小只有 14 字节。这是文本内容 **link3.file.txt -> link2.file.txt** 的大小,实际上是目录项的内容。目录项 **link3.file.txt** 并不指向一个文件节点;它指向了另一个目录项,这在跨越文件系统建立链接时很有帮助。现在试着创建一个软链接,之前在 **/tmp** 目录中尝试过的。 ``` [dboth@david temp]$ ln -s /home/dboth/temp/link2.file.txt @@ -237,11 +237,11 @@ lrwxrwxrwx 1 dboth dboth 31 Jun 14 21:53 /tmp/link3.file.txt -> /home/dboth/temp/link2.file.txt ``` -### **Deleting links** +### **删除链接** -There are some other things that you should consider when you need to delete links or the files to which they point. +当你删除硬链接或硬链接所指的文件时,需要考虑一些问题。 -First, let's delete the link **main.file.txt**. Remember that every directory entry that points to an inode is simply a hard link. +首先,让我们删除硬链接文件 **main.file.txt**。注意每个硬链接都指向了一个文件节点。 ``` [dboth@david temp]$ rm main.file.txt ; ls -li @@ -253,9 +253,9 @@ link2.file.txt 657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file ``` -The link **main.file.txt** was the first link created when the file was created. Deleting it now still leaves the original file and its data on the hard drive along with all the remaining hard links. To delete the file and its data, you would have to delete all the remaining hard links. +**main.file.txt** 是第一个硬链接文件,当该文件被创建时。现在删除它仍然保留原始文件和硬盘上的数据以及所有剩余的硬链接。要删除原始文件,你必须删除它的所有硬链接。 -Now delete the **link2.file.txt** hard link. +现在山村 **link2.file.txt** 硬链接文件。 ``` [dboth@david temp]$ rm link2.file.txt ; ls -li @@ -267,26 +267,26 @@ link2.file.txt 657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file ``` -Notice what happens to the soft link. Deleting the hard link to which the soft link points leaves a broken link. On my system, the broken link is highlighted in colors and the target hard link is flashing. If the broken link needs to be fixed, you can create another hard link in the same directory with the same name as the old one, so long as not all the hard links have been deleted. You could also recreate the link itself, with the link maintaining the same name but pointing to one of the remaining hard links. Of course, if the soft link is no longer needed, it can be deleted with the **rm** command. +注意软链接的变化。删除软链接所指的硬链接会使该软链接失效。在我的系统中,断开的链接用颜色高亮显示,目标硬链接闪烁。如果需要修改软链接,你需要在同一目录下建立一个和旧链接相同名字的硬链接,只要不是所有硬链接都已删除。 您还可以重新创建链接本身,链接保持相同的名称,但指向剩余的硬链接中的一个。当然如果软链接不再需要,可以使用 **rm** 命令删除它们。 -The **unlink** command can also be used to delete files and links. It is very simple and has no options, as the **rm** command does. It does, however, more accurately reflect the underlying process of deletion, in that it removes the link—the directory entry—to the file being deleted. +**unlink** 命令在删除文件和链接时也有用。它非常简单且没有选项,就像 **rm** 命令一样。然而,它更准确地反映了删除的基本过程,因为它删除了目录项与被删除文件的链接。 ### Final thoughts -I worked with both types of links for a long time before I began to understand their capabilities and idiosyncrasies. It took writing a lab project for a Linux class I taught to fully appreciate how links work. This article is a simplification of what I taught in that class, and I hope it speeds your learning curve. +我曾与这两种类型的链接很长一段时间后,我开始了解他们的能力和特质。为我所教的Linux课程编写了一个实验室项目,以充分理解链接是如何工作的,并且我希望增进你的理解。 -------------------------------------------------------------------------------- 作者简介: -David Both - David Both is a Linux and Open Source advocate who resides in Raleigh, North Carolina. He has been in the IT industry for over forty years and taught OS/2 for IBM where he worked for over 20 years. While at IBM, he wrote the first training course for the original IBM PC in 1981. He has taught RHCE classes for Red Hat and has worked at MCI Worldcom, Cisco, and the State of North Carolina. He has been working with Linux and Open Source Software for almost 20 years. +戴维.布斯 - 戴维.布斯是Linux和开源倡导者,居住在Raleigh的北卡罗莱纳。他在IT行业工作了四十年,为IBM工作了20年多的OS 2。在IBM时,他在1981编写了最初的IBM PC的第一个培训课程。他教了RHCE班红帽子和曾在MCI世通公司,思科,和北卡罗莱纳州。他已经用Linux和开源软件工作将近20年了。 --------------------------------- via: https://opensource.com/article/17/6/linking-linux-filesystem 作者:[David Both ][a] -译者:[runningwater](https://github.com/runningwater) +译者:[yongshouzhang](https://github.com/yongshouzhang) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 259baadd5f62c5a00c3247e01d59221e062861f6 Mon Sep 17 00:00:00 2001 From: imquanquan Date: Sun, 3 Dec 2017 13:08:54 +0800 Subject: [PATCH 113/344] translating --- .../tech/20171201 How to Manage Users with Groups in Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171201 How to Manage Users with Groups in Linux.md b/sources/tech/20171201 How to Manage Users with Groups in Linux.md index 1ab98d864a..35350c819f 100644 --- a/sources/tech/20171201 How to Manage Users with Groups in Linux.md +++ b/sources/tech/20171201 How to Manage Users with Groups in Linux.md @@ -1,3 +1,5 @@ +translating---imquanquan + How to Manage Users with Groups in Linux ============================================================ From 0f130c8186d88e0fd09851e97cb9efbcbca62ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=88=E6=B0=B8?= Date: Sun, 3 Dec 2017 13:09:24 +0800 Subject: [PATCH 114/344] Update 20170622 A users guide to links in the Linux filesystem.md --- .../20170622 A users guide to links in the Linux filesystem.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20170622 A users guide to links in the Linux filesystem.md b/sources/tech/20170622 A users guide to links in the Linux filesystem.md index c270ded7df..dec2164d70 100644 --- a/sources/tech/20170622 A users guide to links in the Linux filesystem.md +++ b/sources/tech/20170622 A users guide to links in the Linux filesystem.md @@ -271,7 +271,7 @@ link2.file.txt **unlink** 命令在删除文件和链接时也有用。它非常简单且没有选项,就像 **rm** 命令一样。然而,它更准确地反映了删除的基本过程,因为它删除了目录项与被删除文件的链接。 -### Final thoughts +### 写在最后 我曾与这两种类型的链接很长一段时间后,我开始了解他们的能力和特质。为我所教的Linux课程编写了一个实验室项目,以充分理解链接是如何工作的,并且我希望增进你的理解。 From b345576b88aae0128c7effdeba11321e6f126b8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=88=E6=B0=B8?= Date: Sun, 3 Dec 2017 13:12:01 +0800 Subject: [PATCH 115/344] =?UTF-8?q?=E7=AE=80=E5=8D=95=E6=A0=A1=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20170622 A users guide to links in the Linux filesystem.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20170622 A users guide to links in the Linux filesystem.md b/sources/tech/20170622 A users guide to links in the Linux filesystem.md index dec2164d70..673fc77104 100644 --- a/sources/tech/20170622 A users guide to links in the Linux filesystem.md +++ b/sources/tech/20170622 A users guide to links in the Linux filesystem.md @@ -287,7 +287,7 @@ via: https://opensource.com/article/17/6/linking-linux-filesystem 作者:[David Both ][a] 译者:[yongshouzhang](https://github.com/yongshouzhang) -校对:[校对者ID](https://github.com/校对者ID) +校对:[yongshouzhang](https://github.com/yongshouzhang) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 17094e32cd0b7ece3afb8ebe0902e83c59315164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=88=E6=B0=B8?= Date: Sun, 3 Dec 2017 13:23:00 +0800 Subject: [PATCH 116/344] =?UTF-8?q?=E7=BF=BB=E8=AF=91=20A=20user's=20guide?= =?UTF-8?q?=20to=20links=20in=20the=20Linux=20filesystem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- translated/tech/linux 文件链接用户指南.md | 311 ++++++++++++++++++++++ 1 file changed, 311 insertions(+) create mode 100644 translated/tech/linux 文件链接用户指南.md diff --git a/translated/tech/linux 文件链接用户指南.md b/translated/tech/linux 文件链接用户指南.md new file mode 100644 index 0000000000..84c5756c59 --- /dev/null +++ b/translated/tech/linux 文件链接用户指南.md @@ -0,0 +1,311 @@ + +linux 文件链接用户指南 +============================================================ + +### 学习如何使用链接,通过提供对 linux 文件系统多个位置的文件访问,来让日常工作变得轻松 + + +![linux 文件链接用户指南](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/links.png?itok=AumNmse7 "A user's guide to links in the Linux filesystem") +Image by : [Paul Lewin][8]. Modified by Opensource.com. [CC BY-SA 2.0][9] + +在我为 opensource.com 写过的关于linux文件系统方方面面的文章中,包括 [An introduction to Linux's EXT4 filesystem][10]; [Managing devices in Linux][11]; [An introduction to Linux filesystems][12]; and [A Linux user's guide to Logical Volume Management][13],我曾简要的提到过linux文件系统一个有趣的特性,它允许用户访问linux文件目录树中多个位置的文件来简化一些任务 + +linux 文件系统中有两种链接:硬链接和软链接。虽然二者差别显著,但都用来解决相似的问题。它们都提供了对单个文件进行多个目录项的访问(引用),但实现却大为不同。链接的强大功能赋予了 linux 文件系统灵活性,因为[一切即文件][14]。 + +更多 linux 资源 + +*   [什么是 linux ?][1] + +*   [什么是 linux 容器?][2] + +*   [现在下载: linux 命令速查表][3] + +*   [linux 高级命令速查表][4] + +*   [我们最新的 linux 文章][5] + +举个例子,我曾发现一些程序要求特定的版本库方可运行。 当用升级后的库替代旧库后,程序会崩溃,提示就版本库缺失。 同城库中唯一变化是版本号。出于该直觉,我仅仅给程序添加了一个新的库链接,并以旧库名称命名。我试着再次启动程序,运行良好。 程序就是一个游戏,人人都明白,每个玩家都会尽力使游戏进行下去。 + +事实上,几乎所有的应用程序链接库都使用通用的命名规则,链接名称中包含了住版本号,链接所指文件的文件名中同样包含了最小版本号。再比如,程序的一些必需文件为了迎合 linux 文件系统的规范从一个目录移动到另一个目录中,系统为了向后兼容那些不能获取这些文件新位置的程序在旧的目录中存放了这些文件的链接。如果你对 /lib64 目录做一个长清单列表,你会发现很多这样的例子。 + +``` +lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.hwm -> ../../usr/share/cracklib/pw_dict.hwm +lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.pwd -> ../../usr/share/cracklib/pw_dict.pwd +lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.pwi -> ../../usr/share/cracklib/pw_dict.pwi +lrwxrwxrwx. 1 root root 27 Jun 9 2016 libaccountsservice.so.0 -> libaccountsservice.so.0.0.0 +-rwxr-xr-x. 1 root root 288456 Jun 9 2016 libaccountsservice.so.0.0.0 +lrwxrwxrwx 1 root root 15 May 17 11:47 libacl.so.1 -> libacl.so.1.1.0 +-rwxr-xr-x 1 root root 36472 May 17 11:47 libacl.so.1.1.0 +lrwxrwxrwx. 1 root root 15 Feb 4 2016 libaio.so.1 -> libaio.so.1.0.1 +-rwxr-xr-x. 1 root root 6224 Feb 4 2016 libaio.so.1.0.0 +-rwxr-xr-x. 1 root root 6224 Feb 4 2016 libaio.so.1.0.1 +lrwxrwxrwx. 1 root root 30 Jan 16 16:39 libakonadi-calendar.so.4 -> libakonadi-calendar.so.4.14.26 +-rwxr-xr-x. 1 root root 816160 Jan 16 16:39 libakonadi-calendar.so.4.14.26 +lrwxrwxrwx. 1 root root 29 Jan 16 16:39 libakonadi-contact.so.4 -> libakonadi-contact.so.4.14.26 +``` + +**/lib64** 目录下的一些链接 + +T在上面展示的 **/lib64** 目录清单列表中,文件模式第一个字母 I 表示这是一个符号链接或软链接。 + +### 硬链接 + +在 [An introduction to Linux's EXT4 filesystem][15]一文中,我曾探讨过这样一个事实,每个文件都有一个包含该文件信息的节点,包含了该文件的位置信息。上述文章中的[图2][16]展示了一个指向文件节点的单一目录项。每个文件都至少有一个目录项指向描述该文件信息的文件节点,目录项是一个硬链接,因此每个文件至少都有一个硬链接。 + +如下图1所示,多个目录项指向了同一文件节点。这些目录项都是硬链接。我曾使用波浪线 (**~**) 表示三级目录项的缩写,这是用户目录的惯例表示,因此在该例中波浪线等同于 **/home/user** 。值得注意的是,四级目录项是一个完全不同的目录,**/home/shared** 可能是该计算机上用户的共享文件目录。 + +![fig1directory_entries.png](https://opensource.com/sites/default/files/images/life/fig1directory_entries.png) +Figure 1 + +单一文件系统中的文件硬链接数是有限制的。”文件系统“ 是就挂载在特定挂载点上的分区或逻辑卷而言的,此例中是 /home。这是因为文件系统中的节点号都是唯一的。在不同的文件系统中,如 **/var** 或 **/opt**,会有和 **/home** 中相同的节点号。 + +因为所有的硬链接都指向了包含文件元信息的节点,这些特性都是文件的一部分,像所属关系,权限,节点硬链接数目,这些特性不能区分不同的硬链接。这是一个文件所具有的一组属性。唯一能区分这些文件的是包含在节点信息中的文件名。对单靠 **file/inode** 来定位文件的同一目录中的硬链接必须拥有不同的文件名,基于上述事实,同一目录下不能存在重复的文件名。 + +文件的硬链接数目可通过 **ls -l** 来查看,如果你想查看实际节点号,可使用 **ls -li** 命令。 + +### 符号(软)链接 + +软链接(符号链接)和硬链接的区别在于,硬链接直接指向文件中的节点而软链接直接指向一个目录项,即一个硬链接。因为软链接指向一个文件的硬链接而非该文件的节点信息,所以它们并不依赖于文件节点,这使得它们能在不同的文件系统中起作用,跨越不同的分区和逻辑卷。 + +软链接的缺点是,一旦它所指向的硬链接被删除或重命名后,该软链接就失效了。软链接虽然还在,但所指向的硬链接已不存在。所幸的是,**ls** 命令能以红底白字的方式在其列表中高亮显示失效的软链接。 + +### 实验项目: 链接实验 + +我认为最容易理解链接用法及其差异的方法即使动手搭建一个项目。这个项目应以非超级用户的身份在一个空目录下进行。我创建了 **~/tmp** 目录做这个实验,你也可以这么做。这么做可为项目创建一个安全的环境且提供一个新的空目录让程序运作,如此以来这儿仅存放和程序有关的文件。 + +### **初始工作** + +首先,在你要进行实验的目录下为该项目中的任务创建一个临时目录,确保当前工作目录(PWD)是你的主目录,然后键入下列命令。 + +``` +mkdir temp +``` + +使用这个命名将当前工作目录切换到 *~/temp**  + +``` +cd temp +``` + +实验开始,我们创建一个能够链接的文件,下列命令可完成该工作并向其填充内容。 + +``` +du -h > main.file.txt +``` + +使用 *ls -l** 长列表命名确认文件被正确地创建。运行结果应类似于我的。注意文件大小只有 7 字节,但你的可能会有 1~2 字节的变动。 + +``` +[dboth@david temp]$ ls -l +total 4 +-rw-rw-r-- 1 dboth dboth 7 Jun 13 07:34 main.file.txt +``` + +在列表中,文件模式串后的数字 1 代表存在于该文件上的硬链接数。现在应该是 1 ,因为我们还没有为这个测试文件建立任何硬链接。 + +### **对硬链接进行实验** + +硬链接创建一个指向同一文件节点的目录项,当为文件添加一个硬链接时,你会看到链接数目的增加。确保当前工作目录仍为 **~/temp**。创建一个指向 **main.file.txt** 的硬链接,然后查看该目录下文件列表。 + +``` +[dboth@david temp]$ ln main.file.txt link1.file.txt +[dboth@david temp]$ ls -l +total 8 +-rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 link1.file.txt +-rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 main.file.txt +``` + +目录中两个文件都有两个链接且大小相同,时间戳也一样。这是同一文件节点的两个不同的硬链接,即该文件的目录项。再建立一个该文件的硬链接,并列出目录清单内容,你可以建立 **link1.file.txt** 或 **main.file.txt** 的硬链接。 + +``` +[dboth@david temp]$ ln link1.file.txt link2.file.txt ; ls -l +total 16 +-rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link1.file.txt +-rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link2.file.txt +-rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 main.file.txt +``` + +注意,该目录下的每个硬链接必须使用不同的名称,因为同一目录下的两个文件不能拥有相同的文件名。试着创建一个和现存链接名称相同的硬链接。 + +``` +[dboth@david temp]$ ln main.file.txt link2.file.txt +ln: failed to create hard link 'link2.file.txt': File exists +``` + +显然不行,因为 **link2.file.txt** 已经存在。目前为止我们只在同一目录下创建硬链接,接着在临时目录的父目录,你的主目录中创建一个链接。 + +``` +[dboth@david temp]$ ln main.file.txt ../main.file.txt ; ls -l ../main* +-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt +``` + + 上面的 **ls** 命令显示 **main.file.txt** 文件确实存在于主目录中,且与该文件在 temp 目录中的名称一致。当然它们是没有区别的两个文件,它们是同一文件的两个链接,指向了同一文件的目录项。为了帮助说明下一点,在 temp 目录中添加一个非链接文件。 +``` +[dboth@david temp]$ touch unlinked.file ; ls -l +total 12 +-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt +-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt +-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt +-rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +使用 **ls** 命令的 **i** 选项查看文件节点的硬链接号和新创建文件的硬链接号。 + +``` +[dboth@david temp]$ ls -li +total 12 +657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt +657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt +657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +注意上面文件模式左边的数字 **657024** ,这是三个硬链接文件所指的同一文件的节点号,你也可以使用 **i** 选项查看主目录中所创建的链接节点号,和该值相同。只有一个链接的文件节点号和其他的不同,在你的系统上看到的不同于本文中的。 + +接着改变其中一个硬链接文件的大小。 + +``` +[dboth@david temp]$ df -h > link2.file.txt ; ls -li +total 12 +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +现在的硬链接文件大小比原来大,因为多个目录项链接着同一文件。 + +我知道下个实验在我的电脑上会成功,因为我的 **/tmp** 目录是一个独立的逻辑卷,如果你有单独的逻辑卷或文件系统在不同的分区上(如果未使用逻辑卷),确定你是否能访问那个分区或逻辑卷,如果不能,你可以在电脑上挂载一个 U盘,如果上述选项适合你,你可以进行这个实验。 + +试着在 **/tmp** 目录中建立一个 **~/temp** 目录下文件的链接(或你的文件系统所在的位置) + +``` +[dboth@david temp]$ ln link2.file.txt /tmp/link3.file.txt +ln: failed to create hard link '/tmp/link3.file.txt' => 'link2.file.txt': +Invalid cross-device link +``` + +为什么会出现这个错误呢? 原因是每一个单独的挂载文件系统都有一套自己的节点号。简单的通过文件节点号来跨越整个文件系统结构引用一个文件会使系统困惑,因为相同的节点号会存在于每个已挂载的文件系统中。 + +有时你可能会想找到一个文件节点的所有硬链接。你可以使用 **ls -li** 命令。然后使用 **find** 命令找到所有硬链接的节点号。 + +``` +[dboth@david temp]$ find . -inum 657024 +./main.file.txt +./link1.file.txt +./link2.file.txt +``` + +注意 **find** 命令不能找到所属该节点的四个硬链接,因为我们在 **~/temp** 目录中查找。 **find** 命令仅在当前工作目录及其子目录中中查找文件。要找到所有的硬链接,我们可以使用下列命令,注定你的主目录作为起始查找条件。 + +``` +[dboth@david temp]$ find ~ -samefile main.file.txt +/home/dboth/temp/main.file.txt +/home/dboth/temp/link1.file.txt +/home/dboth/temp/link2.file.txt +/home/dboth/main.file.txt +``` + +如果你是非超级用户没有权限,可能会看到错误信息。这个命令也使用了 **-samefile** 选项而不是指定文件的节点号。这个效果和使用文件节点号一样且更容易,如果你知道其中一个硬链接名称的话。 + +### **对软链接进行实验** + +如你刚才看到的,不能越过文件系统交叉创建硬链接,即在逻辑卷或文件系统中从一个文件系统到另一个文件系统。软链接给出了这个问题的解决方案。虽然他们可以达到相同的目的,但他们是非常不同的,知道这些差异是很重要的。 + +让我们在 **~/temp** 目录中创建一个符号链接来开始我们的探索。 + +``` +[dboth@david temp]$ ln -s link2.file.txt link3.file.txt ; ls -li +total 12 +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt +658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> +link2.file.txt +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +拥有节点号 **657024** 的那些硬链接没有变化,且硬链接的数目也没有变化。新创建的符号链接有不同的文件节点号 **658270**。 名为**link3.file.txt** 的软链接指向了 **link2.file.txt** 文件。使用 **cat** 命令查看 **link3.file.txt** 文件的内容。符号链接的文件节点信息以字母 "**l**" 开头,意味着这个文件实际是个符号链接。 + +上例中软链接文件 **link3.file.txt** 的大小只有 14 字节。这是文本内容 **link3.file.txt -> link2.file.txt** 的大小,实际上是目录项的内容。目录项 **link3.file.txt** 并不指向一个文件节点;它指向了另一个目录项,这在跨越文件系统建立链接时很有帮助。现在试着创建一个软链接,之前在 **/tmp** 目录中尝试过的。 + +``` +[dboth@david temp]$ ln -s /home/dboth/temp/link2.file.txt +/tmp/link3.file.txt ; ls -l /tmp/link* +lrwxrwxrwx 1 dboth dboth 31 Jun 14 21:53 /tmp/link3.file.txt -> +/home/dboth/temp/link2.file.txt +``` + +### **删除链接** + +当你删除硬链接或硬链接所指的文件时,需要考虑一些问题。 + +首先,让我们删除硬链接文件 **main.file.txt**。注意每个硬链接都指向了一个文件节点。 + +``` +[dboth@david temp]$ rm main.file.txt ; ls -li +total 8 +657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link1.file.txt +657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link2.file.txt +658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> +link2.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +**main.file.txt** 是第一个硬链接文件,当该文件被创建时。现在删除它仍然保留原始文件和硬盘上的数据以及所有剩余的硬链接。要删除原始文件,你必须删除它的所有硬链接。 + +现在山村 **link2.file.txt** 硬链接文件。 + +``` +[dboth@david temp]$ rm link2.file.txt ; ls -li +total 8 +657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link1.file.txt +658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> +link2.file.txt +657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 main.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +注意软链接的变化。删除软链接所指的硬链接会使该软链接失效。在我的系统中,断开的链接用颜色高亮显示,目标硬链接闪烁。如果需要修改软链接,你需要在同一目录下建立一个和旧链接相同名字的硬链接,只要不是所有硬链接都已删除。 您还可以重新创建链接本身,链接保持相同的名称,但指向剩余的硬链接中的一个。当然如果软链接不再需要,可以使用 **rm** 命令删除它们。 + +**unlink** 命令在删除文件和链接时也有用。它非常简单且没有选项,就像 **rm** 命令一样。然而,它更准确地反映了删除的基本过程,因为它删除了目录项与被删除文件的链接。 + +### 写在最后 + +我曾与这两种类型的链接很长一段时间后,我开始了解他们的能力和特质。为我所教的Linux课程编写了一个实验室项目,以充分理解链接是如何工作的,并且我希望增进你的理解。 + +-------------------------------------------------------------------------------- + +作者简介: + +戴维.布斯 - 戴维.布斯是Linux和开源倡导者,居住在Raleigh的北卡罗莱纳。他在IT行业工作了四十年,为IBM工作了20年多的OS 2。在IBM时,他在1981编写了最初的IBM PC的第一个培训课程。他教了RHCE班红帽子和曾在MCI世通公司,思科,和北卡罗莱纳州。他已经用Linux和开源软件工作将近20年了。 + +--------------------------------- + +via: https://opensource.com/article/17/6/linking-linux-filesystem + +作者:[David Both ][a] +译者:[yongshouzhang](https://github.com/yongshouzhang) +校对:[yongshouzhang](https://github.com/yongshouzhang) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/dboth +[1]:https://opensource.com/resources/what-is-linux?src=linux_resource_menu +[2]:https://opensource.com/resources/what-are-linux-containers?src=linux_resource_menu +[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=7016000000127cYAAQ +[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?src=linux_resource_menu&intcmp=7016000000127cYAAQ +[5]:https://opensource.com/tags/linux?src=linux_resource_menu +[6]:https://opensource.com/article/17/6/linking-linux-filesystem?rate=YebHxA-zgNopDQKKOyX3_r25hGvnZms_33sYBUq-SMM +[7]:https://opensource.com/user/14106/feed +[8]:https://www.flickr.com/photos/digypho/7905320090 +[9]:https://creativecommons.org/licenses/by/2.0/ +[10]:https://opensource.com/article/17/5/introduction-ext4-filesystem +[11]:https://opensource.com/article/16/11/managing-devices-linux +[12]:https://opensource.com/life/16/10/introduction-linux-filesystems +[13]:https://opensource.com/business/16/9/linux-users-guide-lvm +[14]:https://opensource.com/life/15/9/everything-is-a-file +[15]:https://opensource.com/article/17/5/introduction-ext4-filesystem +[16]:https://opensource.com/article/17/5/introduction-ext4-filesystem#fig2 +[17]:https://opensource.com/users/dboth +[18]:https://opensource.com/article/17/6/linking-linux-filesystem#comments From f0cfdb487094799d0217171a0b9eb5bb6f9b1806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=88=E6=B0=B8?= Date: Sun, 3 Dec 2017 13:25:00 +0800 Subject: [PATCH 117/344] Delete 20170622 A users guide to links in the Linux filesystem.md --- ... guide to links in the Linux filesystem.md | 312 ------------------ 1 file changed, 312 deletions(-) delete mode 100644 sources/tech/20170622 A users guide to links in the Linux filesystem.md diff --git a/sources/tech/20170622 A users guide to links in the Linux filesystem.md b/sources/tech/20170622 A users guide to links in the Linux filesystem.md deleted file mode 100644 index 673fc77104..0000000000 --- a/sources/tech/20170622 A users guide to links in the Linux filesystem.md +++ /dev/null @@ -1,312 +0,0 @@ -Translating by yongshouzhang - -linux 文件链接用户指南 -============================================================ - -### 学习如何使用链接,通过提供对 linux 文件系统多个位置的文件访问,来让日常工作变得轻松 - - -![linux 文件链接用户指南](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/links.png?itok=AumNmse7 "A user's guide to links in the Linux filesystem") -Image by : [Paul Lewin][8]. Modified by Opensource.com. [CC BY-SA 2.0][9] - -在我为 opensource.com 写过的关于linux文件系统方方面面的文章中,包括 [An introduction to Linux's EXT4 filesystem][10]; [Managing devices in Linux][11]; [An introduction to Linux filesystems][12]; and [A Linux user's guide to Logical Volume Management][13],我曾简要的提到过linux文件系统一个有趣的特性,它允许用户访问linux文件目录树中多个位置的文件来简化一些任务 - -linux 文件系统中有两种链接:硬链接和软链接。虽然二者差别显著,但都用来解决相似的问题。它们都提供了对单个文件进行多个目录项的访问(引用),但实现却大为不同。链接的强大功能赋予了 linux 文件系统灵活性,因为[一切即文件][14]。 - -更多 linux 资源 - -*   [什么是 linux ?][1] - -*   [什么是 linux 容器?][2] - -*   [现在下载: linux 命令速查表][3] - -*   [linux 高级命令速查表][4] - -*   [我们最新的 linux 文章][5] - -举个例子,我曾发现一些程序要求特定的版本库方可运行。 当用升级后的库替代旧库后,程序会崩溃,提示就版本库缺失。 同城库中唯一变化是版本号。出于该直觉,我仅仅给程序添加了一个新的库链接,并以旧库名称命名。我试着再次启动程序,运行良好。 程序就是一个游戏,人人都明白,每个玩家都会尽力使游戏进行下去。 - -事实上,几乎所有的应用程序链接库都使用通用的命名规则,链接名称中包含了住版本号,链接所指文件的文件名中同样包含了最小版本号。再比如,程序的一些必需文件为了迎合 linux 文件系统的规范从一个目录移动到另一个目录中,系统为了向后兼容那些不能获取这些文件新位置的程序在旧的目录中存放了这些文件的链接。如果你对 /lib64 目录做一个长清单列表,你会发现很多这样的例子。 - -``` -lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.hwm -> ../../usr/share/cracklib/pw_dict.hwm -lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.pwd -> ../../usr/share/cracklib/pw_dict.pwd -lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.pwi -> ../../usr/share/cracklib/pw_dict.pwi -lrwxrwxrwx. 1 root root 27 Jun 9 2016 libaccountsservice.so.0 -> libaccountsservice.so.0.0.0 --rwxr-xr-x. 1 root root 288456 Jun 9 2016 libaccountsservice.so.0.0.0 -lrwxrwxrwx 1 root root 15 May 17 11:47 libacl.so.1 -> libacl.so.1.1.0 --rwxr-xr-x 1 root root 36472 May 17 11:47 libacl.so.1.1.0 -lrwxrwxrwx. 1 root root 15 Feb 4 2016 libaio.so.1 -> libaio.so.1.0.1 --rwxr-xr-x. 1 root root 6224 Feb 4 2016 libaio.so.1.0.0 --rwxr-xr-x. 1 root root 6224 Feb 4 2016 libaio.so.1.0.1 -lrwxrwxrwx. 1 root root 30 Jan 16 16:39 libakonadi-calendar.so.4 -> libakonadi-calendar.so.4.14.26 --rwxr-xr-x. 1 root root 816160 Jan 16 16:39 libakonadi-calendar.so.4.14.26 -lrwxrwxrwx. 1 root root 29 Jan 16 16:39 libakonadi-contact.so.4 -> libakonadi-contact.so.4.14.26 -``` - -**/lib64** 目录下的一些链接 - -T在上面展示的 **/lib64** 目录清单列表中,文件模式第一个字母 I 表示这是一个符号链接或软链接。 - -### 硬链接 - -在 [An introduction to Linux's EXT4 filesystem][15]一文中,我曾探讨过这样一个事实,每个文件都有一个包含该文件信息的节点,包含了该文件的位置信息。上述文章中的[图2][16]展示了一个指向文件节点的单一目录项。每个文件都至少有一个目录项指向描述该文件信息的文件节点,目录项是一个硬链接,因此每个文件至少都有一个硬链接。 - -如下图1所示,多个目录项指向了同一文件节点。这些目录项都是硬链接。我曾使用波浪线 (**~**) 表示三级目录项的缩写,这是用户目录的惯例表示,因此在该例中波浪线等同于 **/home/user** 。值得注意的是,四级目录项是一个完全不同的目录,**/home/shared** 可能是该计算机上用户的共享文件目录。 - -![fig1directory_entries.png](https://opensource.com/sites/default/files/images/life/fig1directory_entries.png) -Figure 1 - -单一文件系统中的文件硬链接数是有限制的。”文件系统“ 是就挂载在特定挂载点上的分区或逻辑卷而言的,此例中是 /home。这是因为文件系统中的节点号都是唯一的。在不同的文件系统中,如 **/var** 或 **/opt**,会有和 **/home** 中相同的节点号。 - -因为所有的硬链接都指向了包含文件元信息的节点,这些特性都是文件的一部分,像所属关系,权限,节点硬链接数目,这些特性不能区分不同的硬链接。这是一个文件所具有的一组属性。唯一能区分这些文件的是包含在节点信息中的文件名。对单靠 **file/inode** 来定位文件的同一目录中的硬链接必须拥有不同的文件名,基于上述事实,同一目录下不能存在重复的文件名。 - -文件的硬链接数目可通过 **ls -l** 来查看,如果你想查看实际节点号,可使用 **ls -li** 命令。 - -### 符号(软)链接 - -软链接(符号链接)和硬链接的区别在于,硬链接直接指向文件中的节点而软链接直接指向一个目录项,即一个硬链接。因为软链接指向一个文件的硬链接而非该文件的节点信息,所以它们并不依赖于文件节点,这使得它们能在不同的文件系统中起作用,跨越不同的分区和逻辑卷。 - -软链接的缺点是,一旦它所指向的硬链接被删除或重命名后,该软链接就失效了。软链接虽然还在,但所指向的硬链接已不存在。所幸的是,**ls** 命令能以红底白字的方式在其列表中高亮显示失效的软链接。 - -### 实验项目: 链接实验 - -我认为最容易理解链接用法及其差异的方法即使动手搭建一个项目。这个项目应以非超级用户的身份在一个空目录下进行。我创建了 **~/tmp** 目录做这个实验,你也可以这么做。这么做可为项目创建一个安全的环境且提供一个新的空目录让程序运作,如此以来这儿仅存放和程序有关的文件。 - -### **初始工作** - -首先,在你要进行实验的目录下为该项目中的任务创建一个临时目录,确保当前工作目录(PWD)是你的主目录,然后键入下列命令。 - -``` -mkdir temp -``` - -使用这个命名将当前工作目录切换到 *~/temp**  - -``` -cd temp -``` - -实验开始,我们创建一个能够链接的文件,下列命令可完成该工作并向其填充内容。 - -``` -du -h > main.file.txt -``` - -使用 *ls -l** 长列表命名确认文件被正确地创建。运行结果应类似于我的。注意文件大小只有 7 字节,但你的可能会有 1~2 字节的变动。 - -``` -[dboth@david temp]$ ls -l -total 4 --rw-rw-r-- 1 dboth dboth 7 Jun 13 07:34 main.file.txt -``` - -在列表中,文件模式串后的数字 1 代表存在于该文件上的硬链接数。现在应该是 1 ,因为我们还没有为这个测试文件建立任何硬链接。 - -### **对硬链接进行实验** - -硬链接创建一个指向同一文件节点的目录项,当为文件添加一个硬链接时,你会看到链接数目的增加。确保当前工作目录仍为 **~/temp**。创建一个指向 **main.file.txt** 的硬链接,然后查看该目录下文件列表。 - -``` -[dboth@david temp]$ ln main.file.txt link1.file.txt -[dboth@david temp]$ ls -l -total 8 --rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 link1.file.txt --rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 main.file.txt -``` - -目录中两个文件都有两个链接且大小相同,时间戳也一样。这是同一文件节点的两个不同的硬链接,即该文件的目录项。再建立一个该文件的硬链接,并列出目录清单内容,你可以建立 **link1.file.txt** 或 **main.file.txt** 的硬链接。 - -``` -[dboth@david temp]$ ln link1.file.txt link2.file.txt ; ls -l -total 16 --rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link1.file.txt --rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link2.file.txt --rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 main.file.txt -``` - -注意,该目录下的每个硬链接必须使用不同的名称,因为同一目录下的两个文件不能拥有相同的文件名。试着创建一个和现存链接名称相同的硬链接。 - -``` -[dboth@david temp]$ ln main.file.txt link2.file.txt -ln: failed to create hard link 'link2.file.txt': File exists -``` - -显然不行,因为 **link2.file.txt** 已经存在。目前为止我们只在同一目录下创建硬链接,接着在临时目录的父目录,你的主目录中创建一个链接。 - -``` -[dboth@david temp]$ ln main.file.txt ../main.file.txt ; ls -l ../main* --rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt -``` - - 上面的 **ls** 命令显示 **main.file.txt** 文件确实存在于主目录中,且与该文件在 temp 目录中的名称一致。当然它们是没有区别的两个文件,它们是同一文件的两个链接,指向了同一文件的目录项。为了帮助说明下一点,在 temp 目录中添加一个非链接文件。 -``` -[dboth@david temp]$ touch unlinked.file ; ls -l -total 12 --rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt --rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt --rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt --rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -使用 **ls** 命令的 **i** 选项查看文件节点的硬链接号和新创建文件的硬链接号。 - -``` -[dboth@david temp]$ ls -li -total 12 -657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt -657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt -657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -注意上面文件模式左边的数字 **657024** ,这是三个硬链接文件所指的同一文件的节点号,你也可以使用 **i** 选项查看主目录中所创建的链接节点号,和该值相同。只有一个链接的文件节点号和其他的不同,在你的系统上看到的不同于本文中的。 - -接着改变其中一个硬链接文件的大小。 - -``` -[dboth@david temp]$ df -h > link2.file.txt ; ls -li -total 12 -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -现在的硬链接文件大小比原来大,因为多个目录项链接着同一文件。 - -我知道下个实验在我的电脑上会成功,因为我的 **/tmp** 目录是一个独立的逻辑卷,如果你有单独的逻辑卷或文件系统在不同的分区上(如果未使用逻辑卷),确定你是否能访问那个分区或逻辑卷,如果不能,你可以在电脑上挂载一个 U盘,如果上述选项适合你,你可以进行这个实验。 - -试着在 **/tmp** 目录中建立一个 **~/temp** 目录下文件的链接(或你的文件系统所在的位置) - -``` -[dboth@david temp]$ ln link2.file.txt /tmp/link3.file.txt -ln: failed to create hard link '/tmp/link3.file.txt' => 'link2.file.txt': -Invalid cross-device link -``` - -为什么会出现这个错误呢? 原因是每一个单独的挂载文件系统都有一套自己的节点号。简单的通过文件节点号来跨越整个文件系统结构引用一个文件会使系统困惑,因为相同的节点号会存在于每个已挂载的文件系统中。 - -有时你可能会想找到一个文件节点的所有硬链接。你可以使用 **ls -li** 命令。然后使用 **find** 命令找到所有硬链接的节点号。 - -``` -[dboth@david temp]$ find . -inum 657024 -./main.file.txt -./link1.file.txt -./link2.file.txt -``` - -注意 **find** 命令不能找到所属该节点的四个硬链接,因为我们在 **~/temp** 目录中查找。 **find** 命令仅在当前工作目录及其子目录中中查找文件。要找到所有的硬链接,我们可以使用下列命令,注定你的主目录作为起始查找条件。 - -``` -[dboth@david temp]$ find ~ -samefile main.file.txt -/home/dboth/temp/main.file.txt -/home/dboth/temp/link1.file.txt -/home/dboth/temp/link2.file.txt -/home/dboth/main.file.txt -``` - -如果你是非超级用户没有权限,可能会看到错误信息。这个命令也使用了 **-samefile** 选项而不是指定文件的节点号。这个效果和使用文件节点号一样且更容易,如果你知道其中一个硬链接名称的话。 - -### **对软链接进行实验** - -如你刚才看到的,不能越过文件系统交叉创建硬链接,即在逻辑卷或文件系统中从一个文件系统到另一个文件系统。软链接给出了这个问题的解决方案。虽然他们可以达到相同的目的,但他们是非常不同的,知道这些差异是很重要的。 - -让我们在 **~/temp** 目录中创建一个符号链接来开始我们的探索。 - -``` -[dboth@david temp]$ ln -s link2.file.txt link3.file.txt ; ls -li -total 12 -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt -658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> -link2.file.txt -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -拥有节点号 **657024** 的那些硬链接没有变化,且硬链接的数目也没有变化。新创建的符号链接有不同的文件节点号 **658270**。 名为**link3.file.txt** 的软链接指向了 **link2.file.txt** 文件。使用 **cat** 命令查看 **link3.file.txt** 文件的内容。符号链接的文件节点信息以字母 "**l**" 开头,意味着这个文件实际是个符号链接。 - -上例中软链接文件 **link3.file.txt** 的大小只有 14 字节。这是文本内容 **link3.file.txt -> link2.file.txt** 的大小,实际上是目录项的内容。目录项 **link3.file.txt** 并不指向一个文件节点;它指向了另一个目录项,这在跨越文件系统建立链接时很有帮助。现在试着创建一个软链接,之前在 **/tmp** 目录中尝试过的。 - -``` -[dboth@david temp]$ ln -s /home/dboth/temp/link2.file.txt -/tmp/link3.file.txt ; ls -l /tmp/link* -lrwxrwxrwx 1 dboth dboth 31 Jun 14 21:53 /tmp/link3.file.txt -> -/home/dboth/temp/link2.file.txt -``` - -### **删除链接** - -当你删除硬链接或硬链接所指的文件时,需要考虑一些问题。 - -首先,让我们删除硬链接文件 **main.file.txt**。注意每个硬链接都指向了一个文件节点。 - -``` -[dboth@david temp]$ rm main.file.txt ; ls -li -total 8 -657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link1.file.txt -657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link2.file.txt -658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> -link2.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -**main.file.txt** 是第一个硬链接文件,当该文件被创建时。现在删除它仍然保留原始文件和硬盘上的数据以及所有剩余的硬链接。要删除原始文件,你必须删除它的所有硬链接。 - -现在山村 **link2.file.txt** 硬链接文件。 - -``` -[dboth@david temp]$ rm link2.file.txt ; ls -li -total 8 -657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link1.file.txt -658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> -link2.file.txt -657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 main.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -注意软链接的变化。删除软链接所指的硬链接会使该软链接失效。在我的系统中,断开的链接用颜色高亮显示,目标硬链接闪烁。如果需要修改软链接,你需要在同一目录下建立一个和旧链接相同名字的硬链接,只要不是所有硬链接都已删除。 您还可以重新创建链接本身,链接保持相同的名称,但指向剩余的硬链接中的一个。当然如果软链接不再需要,可以使用 **rm** 命令删除它们。 - -**unlink** 命令在删除文件和链接时也有用。它非常简单且没有选项,就像 **rm** 命令一样。然而,它更准确地反映了删除的基本过程,因为它删除了目录项与被删除文件的链接。 - -### 写在最后 - -我曾与这两种类型的链接很长一段时间后,我开始了解他们的能力和特质。为我所教的Linux课程编写了一个实验室项目,以充分理解链接是如何工作的,并且我希望增进你的理解。 - --------------------------------------------------------------------------------- - -作者简介: - -戴维.布斯 - 戴维.布斯是Linux和开源倡导者,居住在Raleigh的北卡罗莱纳。他在IT行业工作了四十年,为IBM工作了20年多的OS 2。在IBM时,他在1981编写了最初的IBM PC的第一个培训课程。他教了RHCE班红帽子和曾在MCI世通公司,思科,和北卡罗莱纳州。他已经用Linux和开源软件工作将近20年了。 - ---------------------------------- - -via: https://opensource.com/article/17/6/linking-linux-filesystem - -作者:[David Both ][a] -译者:[yongshouzhang](https://github.com/yongshouzhang) -校对:[yongshouzhang](https://github.com/yongshouzhang) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/dboth -[1]:https://opensource.com/resources/what-is-linux?src=linux_resource_menu -[2]:https://opensource.com/resources/what-are-linux-containers?src=linux_resource_menu -[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=7016000000127cYAAQ -[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?src=linux_resource_menu&intcmp=7016000000127cYAAQ -[5]:https://opensource.com/tags/linux?src=linux_resource_menu -[6]:https://opensource.com/article/17/6/linking-linux-filesystem?rate=YebHxA-zgNopDQKKOyX3_r25hGvnZms_33sYBUq-SMM -[7]:https://opensource.com/user/14106/feed -[8]:https://www.flickr.com/photos/digypho/7905320090 -[9]:https://creativecommons.org/licenses/by/2.0/ -[10]:https://opensource.com/article/17/5/introduction-ext4-filesystem -[11]:https://opensource.com/article/16/11/managing-devices-linux -[12]:https://opensource.com/life/16/10/introduction-linux-filesystems -[13]:https://opensource.com/business/16/9/linux-users-guide-lvm -[14]:https://opensource.com/life/15/9/everything-is-a-file -[15]:https://opensource.com/article/17/5/introduction-ext4-filesystem -[16]:https://opensource.com/article/17/5/introduction-ext4-filesystem#fig2 -[17]:https://opensource.com/users/dboth -[18]:https://opensource.com/article/17/6/linking-linux-filesystem#comments From 6b2679d16f9d56cf084bb8e0aec26c2ab33f457d Mon Sep 17 00:00:00 2001 From: darksun Date: Sun, 3 Dec 2017 13:33:06 +0800 Subject: [PATCH 118/344] translating by lujun9972 --- .../tech/20171117 System Logs: Understand Your Linux System.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171117 System Logs: Understand Your Linux System.md b/sources/tech/20171117 System Logs: Understand Your Linux System.md index 0dcaa57925..a711ee2c05 100644 --- a/sources/tech/20171117 System Logs: Understand Your Linux System.md +++ b/sources/tech/20171117 System Logs: Understand Your Linux System.md @@ -1,3 +1,4 @@ +translating by lujun9972 ### System Logs: Understand Your Linux System ![chabowski](https://www.suse.com/communities/blog/files/2016/03/chabowski_avatar_1457537819-100x100.jpg) From 9449bcf71d424330396df33eb94092c921c59368 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 3 Dec 2017 14:04:07 +0800 Subject: [PATCH 119/344] tranlsated tranlsated --- ...170530 How to Improve a Legacy Codebase.md | 132 +++++++----------- 1 file changed, 51 insertions(+), 81 deletions(-) diff --git a/sources/tech/20170530 How to Improve a Legacy Codebase.md b/sources/tech/20170530 How to Improve a Legacy Codebase.md index cc1bd073a9..a1869b0449 100644 --- a/sources/tech/20170530 How to Improve a Legacy Codebase.md +++ b/sources/tech/20170530 How to Improve a Legacy Codebase.md @@ -1,131 +1,101 @@ -Translating by aiwhj -# How to Improve a Legacy Codebase # 如何改善遗留的代码库 -It happens at least once in the lifetime of every programmer, project manager or teamleader. You get handed a steaming pile of manure, if you’re lucky only a few million lines worth, the original programmers have long ago left for sunnier places and the documentation - if there is any to begin with - is hopelessly out of sync with what is presently keeping the company afloat. +这在每一个程序员,项目管理员,团队领导的一生中都会至少发生一次。原来的程序员早已离职去度假了,留下了一坨几百万行屎一样的代码和文档(如果有的话),一旦接手这些代码,想要跟上公司的进度简直让人绝望。 -它在每一个程序员,项目管理员,团队领导的一生中都会发生至少一次。原来的程序员离开了这个地方,只留下了文档,和一坨几百万行屎一样的代码。一旦接管这些代码,想要跟上公司的进度简直让人绝望。 +你的工作是带领团队摆脱这个混乱的局面 -Your job: get us out of this mess. -你的任务:让大家摆脱这个混乱的局面 +当你的第一反应过去之后,你开始去熟悉这个项目,公司的管理层都在关注着你,所以项目只能成功,然而,看了一遍代码之后却发现很大的可能会失败。那么该怎么办呢? -当你的第一反应过去之后,你开始去熟悉这个项目,公司的管理层都在关注着,项目只能成功,然而,看了一遍之后却发现了许多的错误。该怎么做呢? -After your first instinctive response (run for the hills) has passed you start on the project knowing full well that the eyes of the company senior leadership are on you. Failure is not an option. And yet, by the looks of what you’ve been given failure is very much in the cards. So what to do? +幸运(不幸)的是我已经遇到好几次这种情况了,我和我的小伙伴发现将这坨热气腾腾的屎变成一个健康可维护的项目是非常值得一试的。下面这些是我们的一些经验: -幸运(不幸)的是我已经遇到好几次这种情况了,我和我的小伙伴发现将这坨热气腾腾的屎变成一个健康可维护的项目是很值得的。下面这些是我使用的一些小技巧: -I’ve been (un)fortunate enough to be in this situation several times and me and a small band of friends have found that it is a lucrative business to be able to take these steaming piles of misery and to turn them into healthy maintainable projects. Here are some of the tricks that we employ: - -### Backup ### 备份 -在你去做任何操作之前备份与之相关的所有文件。这样可以确保不会丢失任何信息,这些信息可能会在另外一些地方很重要。一旦改变其中一些文件,你可能花费一天或者更多天都解决不了这个愚蠢的问题,配置数据通常不受版本控制,所以特别容易受到这方面影响,如果定期备份数据时连带着它一起备份了,还是比较幸运的。所以谨慎总比后悔好,复制所有东西到一个绝对安全的地方吧,而且不要轻易动他除非这些文件是只读模式。 -Before you start to do anything at all make a backup of  _everything_  that might be relevant. This to make sure that no information is lost that might be of crucial importance somewhere down the line. All it takes is a silly question that you can’t answer to eat up a day or more once the change has been made. Especially configuration data is susceptible to this kind of problem, it is usually not versioned and you’re lucky if it is taken along in the periodic back-up scheme. So better safe than sorry, copy everything to a very safe place and never ever touch that unless it is in read-only mode. +在开始做任何事情之前备份与之可能相关的所有文件。这样可以确保不会丢失任何可能会在另外一些地方很重要的信息。一旦修改其中一些文件,你可能花费一天或者更多天都解决不了这个愚蠢的问题,配置数据通常不受版本控制,所以特别容易受到这方面影响,如果定期备份数据时连带着它一起备份了,还是比较幸运的。所以谨慎总比后悔好,复制所有东西到一个绝对安全的地方吧,除非这些文件是只读模式否则不要轻易碰它。 -### Important pre-requisite, make sure you have a build process and that it actually produces what runs in production -### 你必须确认他们能够在生产环境下构建运行并产出,这是重要的先决条件。 +### 必须确保代码能够在生产环境下构建运行并产出,这是重要的先决条件。 -这一步显而易见并且已经很到位的情况下我完全错过了这一步,Hacker News 的众多评论者就会指出并且证明他们是对的:第一步是马上确保你知道在生产环境下运行着什么东西,也意味着你需要去在你的设备上构建一个跟生产环境上运行的版本每一个字节都一模一样的版本。如果你找不到实现它的办法,一旦你将它投入生产环境是,你很可能会遭遇一些很糟糕的事情。确保每一部分都尽你最大能力去测试,之后在你足够信任他能够很好的运行的时候将他弄得生产环境下。无论他运行的怎么样都要做好能够马上切换回就版本的准备,并且记录所有情况下的日志,便于接下来不可避免的 “验尸” 。 -I totally missed this step on the assumption that it is obvious and likely already in place but many HN commenters pointed this out and they are absolutely right: step one is to make sure that you know what is running in production right now and that means that you need to be able to build a version of the software that is - if your platform works that way - byte-for-byte identical with the current production build. If you can’t find a way to achieve this then likely you will be in for some unpleasant surprises once you commit something to production. Make sure you test this to the best of your ability to make sure that you have all the pieces in place and then, after you’ve gained sufficient confidence that it will work move it to production. Be prepared to switch back immediately to whatever was running before and make sure that you log everything and anything that might come in handy during the - inevitable - post mortem. +之前我假设环境已经存在,所以完全丢了这一步,Hacker News 的众多网友指出了这一点并且证明他们是对的:第一步是确认你知道在生产环境下运行着什么东西,也意味着你需要在你的设备上构建一个跟生产环境上运行的版本每一个字节都一模一样的版本。如果你找不到实现它的办法,一旦你将它投入生产环境,你很可能会遭遇一些很糟糕的事情。确保每一部分都尽力测试,之后在你足够信任它能够很好的运行的时候将它部署生产环境下。无论它运行的怎么样都要做好能够马上切换回旧版本的准备,确保日志记录下了所有情况,以便于接下来不可避免的 “验尸” 。 -### Freeze the DB ### 冻结数据库 -直到你改善了代码之前尽可能的冻结你的数据库,在你特别熟悉代码库和遗留代码的之后再去修改数据库。在这之前过早的修改数据库的话,你可能会碰到大问题,你会失去让新旧代码和数据库和数据库一起构建稳固的基础的能力。保持数据库完全不变能够比较新的逻辑代码和旧的逻辑代码造成的影响,如果都像通知的那样就没有什么影响了。 -If at all possible freeze the database schema until you are done with the first level of improvements, by the time you have a solid understanding of the codebase and the legacy code has been fully left behind you are ready to modify the database schema. Change it any earlier than that and you may have a real problem on your hand, now you’ve lost the ability to run an old and a new codebase side-by-side with the database as the steady foundation to build on. Keeping the DB totally unchanged allows you to compare the effect your new business logic code has compared to the old business logic code, if it all works as advertised there should be no differences. -### Write your tests +直到你修改代码之前尽可能冻结你的数据库,在你特别熟悉代码库和遗留代码之后再去修改数据库。在这之前过早的修改数据库的话,你可能会碰到大问题,你会失去让新旧代码和数据库一起构建稳固的基础的能力。保持数据库完全不变,就能比较新的逻辑代码和旧的逻辑代码运行的结果,比较的结果应该跟预期的没有差别。 + ### 写测试 -在你做任何改变之前,尽可能多的写下端到端测试和集成测试。确保这些测试能够正确的输出并且是在你能够清晰的知道旧的是如何工作的假设之下(准备好应对一些突发状况)。这些测试有两个重要的作用,他们能够在较早的阶段帮助你抛弃一些错误观念,在你写新代码替换旧代码的时候也有一定防护作用。 -Before you make any changes at all write as many end-to-end and integration tests as you can. Make sure these tests produce the right output and test any and all assumptions that you can come up with about how you  _think_  the old stuff works (be prepared for surprises here). These tests will have two important functions: they will help to clear up any misconceptions at a very early stage and they will function as guardrails once you start writing new code to replace old code. -自动化测试,如果你也有 CI 的使用经验,请使用它并且确保在你提交代码之后能够快速的完成所有测试。 -Automate all your testing, if you’re already experienced with CI then use it and make sure your tests run fast enough to run the full set of tests after every commit. +在你做任何改变之前,尽可能多的写下端到端测试和集成测试。在你能够清晰的知道旧的是如何工作的情况下确保这些测试能够正确的输出(准备好应对一些突发状况)。这些测试有两个重要的作用,其一,他们能够在早期帮助你抛弃一些错误观念,其二,在你写新代码替换旧代码的时候也有一定防护作用。 + +自动化测试,如果你也有 CI 的使用经验请使用它,并且确保在你提交代码之后能够快速的完成所有测试。 -### Instrumentation and logging ### 日志监控 -如果线上的旧设备需要添加上监控功能。用一个完全新的数据库,为每一个你能想到事件都添加一个简单的计数器,并且根据这些事件的名字添加一个函数增加这些计数器。用一些额外的代码实现一个时间戳事件日志,这是一个好办法知道有多少事件导致了另外一些种类的事件。例如:用户打开 APP ,用户关闭 APP 。如果这两个事件导致后端调用的数量维持长时间的不同,这个数量差就是当前打开的 APP 的数量。如果你看到打开 APP 的比关闭的多的时候,你知道哪些 APP 是关闭的必须的方法(例如崩溃)。每一个事件你会发现有许多不同种类的联系跟其他的一些事件,通常你争取维持这些固定的关系,除非有一个明显的错误在系统上。你的目标是降低那些错误的事件,最大化哪些计数器在向下到初始化的水平在链条中。(例如:用户试着支付应该得到相同数量的跟支付回调)。 -If the old platform is still available for development add instrumentation. Do this in a completely new database table, add a simple counter for every event that you can think of and add a single function to increment these counters based on the name of the event. That way you can implement a time-stamped event log with a few extra lines of code and you’ll get a good idea of how many events of one kind lead to events of another kind. One example: User opens app, User closes app. If two events should result in some back-end calls those two counters should over the long term remain at a constant difference, the difference is the number of apps currently open. If you see many more app opens than app closes you know there has to be a way in which apps end (for instance a crash). For each and every event you’ll find there is some kind of relationship to other events, usually you will strive for constant relationships unless there is an obvious error somewhere in the system. You’ll aim to reduce those counters that indicate errors and you’ll aim to maximize counters further down in the chain to the level indicated by the counters at the beginning. (For instance: customers attempting to pay should result in an equal number of actual payments received). -这是非常简单的点子去翻转每一个后端应用到一个就像真实的薄书系统一样 -This very simple trick turns every backend application into a bookkeeping system of sorts and just like with a real bookkeeping system the numbers have to match, as long as they don’t you have a problem somewhere. +如果旧设备依然可用,那么添加上监控功能。使用一个全新的数据库,为每一个你能想到的事件都添加一个简单的计数器,并且根据这些事件的名字添加一个函数增加这些计数器。用一些额外的代码实现一个带有时间戳的事件日志,这是一个好办法知道有多少事件导致了另外一些种类的事件。例如:用户打开 APP ,用户关闭 APP 。如果这两个事件导致后端调用的数量维持长时间的不同,这个数量差就是当前打开的 APP 的数量。如果你发现打开 APP 比关闭 APP 多的时候,你就必须要知道是什么原因导致 APP 关闭了(例如崩溃)。你会发现每一个事件都跟其他的一些事件有许多不同种类的联系,通常情况下你应该尽量维持这些固定的联系,除非在系统上有一个明显的错误。你的目标是减少那些错误的事件,尽可能多的在开始的时候通过使用计数器在调用链中降低到指定的级别。(例如:用户支付应该得到相同数量的支付回调)。 -在构建一个健康的系统的时候,这个系统是很珍贵的,而且它也是一个好伙伴,仅次于使用源码控制修改系统日志,你可以确认 BUG 出现的位置,以及对多种计数器造成的影响。 -This system will over time become invaluable in establishing the health of the system and will be a great companion next to the source code control system revision log where you can determine the point in time that a bug was introduced and what the effect was on the various counters. +这是简单的技巧去将每一个后端应用变成一个就像真实的簿记系统一样,所有数字必须匹配,只要他们在某个地方都不会有什么问题。 -我通常保持技术差 5 分钟一次(一小时 12 次),如果你的应用生成了更多或者更少的事件,你应该改变这个时间间隔。所有的计数器公用一个数据表,每一个记录都只是简单的一行。 -I usually keep these counters at a 5 minute resolution (so 12 buckets for an hour), but if you have an application that generates fewer or more events then you might decide to change the interval at which new buckets are created. All counters share the same database table and so each counter is simply a column in that table. +随着时间的推移,这个系统在监控健康方面变得非常宝贵,而且它也是使用源码控制修改系统日志的一个好伙伴,你可以使用它确认 BUG 出现的位置,以及对多种计数器造成的影响。 + +我通常保持 5 分钟(一小时 12 次)记录一次计数器,如果你的应用生成了更多或者更少的事件,你应该修改这个时间间隔。所有的计数器公用一个数据表,每一个记录都只是简单的一行。 -### Change only one thing at the time ### 一次只修改一处 -不要完全陷入一个陷阱,在提高代码或者平台可用性的同时添加新特性或者是修复 BUG。这会让你头大,现在必须问问你自己每一步操作想要每一步的什么结果并且将会使你早前建立的测试失效。 -Do not fall into the trap of improving both the maintainability of the code or the platform it runs on at the same time as adding new features or fixing bugs. This will cause you huge headaches because you now have to ask yourself every step of the way what the desired outcome is of an action and will invalidate some of the tests you made earlier. +不要完全陷入在提高代码或者平台可用性的同时添加新特性或者是修复 BUG 的陷阱。这会让你头大而且将会使你之前建立的测试失效,现在必须问问你自己,每一步的操作想要什么样的结果。 -### Platform changes -###改变平台 -如果你决定转移你的应用到另外一个平台,最主要的是跟之前保持一样。如果你觉得你会添加更多的文档和测试,但是不会比那更多,所有的业务逻辑和相互依赖跟从前一样保持不变。 -If you’ve decided to migrate the application to another platform then do this first  _but keep everything else exactly the same_ . If you want you can add more documentation or tests, but no more than that, all business logic and interdependencies should remain as before. +### 修改平台 -### Architecture changes -###改变架构 -接下来处理的是改变应用的结构(如果需要)。这一点上,你可以自由的去改变代码为更高级的,通常是降低模块间的横向联系,这样可以降低代码活动期间对终端用户造成的影响范围。如果老代码是庞大的,那么现在正是时候让他模块化,大段代码分解成众多小的,不过不要把变量的名字和他的数据结构分开。 -The next thing to tackle is to change the architecture of the application (if desired). At this point in time you are free to change the higher level structure of the code, usually by reducing the number of horizontal links between modules, and thus reducing the scope of the code active during any one interaction with the end-user. If the old code was monolithic in nature now would be a good time to make it more modular, break up large functions into smaller ones but leave names of variables and data-structures as they were. -Hacker News [mannykannot][1] 指出,理所应当的,这一步不总是有必要的,如果你特别不幸的话,你可能为了改变一些架构必须付出沉重的代价。我也赞同这个,我应该加上这个,因此这里有一些更新。我非常想添加的是如果你修改高级代码的时候修改了一点点底层代码试着限制只修改一个文件或者一个不恰当的例子一个子系统,所以你尽可能的限制了修改的范围。其他方面你可能有个困难时期去排查你所做的修改。 -HN user [mannykannot][1] points - rightfully - out that this is not always an option, if you’re particularly unlucky then you may have to dig in deep in order to be able to make any architecture changes. I agree with that and I should have included it here so hence this little update. What I would further like to add is if you do both do high level changes and low level changes at least try to limit them to one file or worst case one subsystem so that you limit the scope of your changes as much as possible. Otherwise you might have a very hard time debugging the change you just made. +如果你决定转移你的应用到另外一个平台,最主要的是跟之前保持一样。如果你觉得你会添加更多的文档和测试,但是不要忘记这一点,所有的业务逻辑和相互依赖跟从前一样保持不变。 + +### 修改架构 + +接下来处理的是改变应用的结构(如果需要)。这一点上,你可以自由的修改高层的代码,通常是降低模块间的横向联系,这样可以降低代码活动期间对终端用户造成的影响范围。如果老代码是庞大的,那么现在正是让他模块化的时候,将大段代码分解成众多小的,不过不要把变量的名字和他的数据结构分开。 + +Hacker News [mannykannot][1] 网友指出,修改架构并不总是可行,如果你特别不幸的话,你可能为了改变一些架构必须付出沉重的代价。我也赞同这一点,我应该加上这一点,因此这里有一些补充。我非常想补充的是如果你修改高级代码的时候修改了一点点底层代码,那么试着限制只修改一个文件或者最坏的情况是只修改一个子系统,所以尽可能限制修改的范围。否则你可能很难调试刚才所做的更改。 -### Low level refactoring ### 底层代码的重构 -现在,你应该非常理解每一个模块的作用,准备做一些真正的工作吧:重构代码去提高可维护性和让代码准备添加新功能。这将很可能是项目的一部分消耗大部分时间,记录你做的,不要对模块做改变直到你彻底的记录他并且感觉理解了他。很自由的修改变量名和函数名以及数据结构去提高清晰度和统一性,添加测试(情况需要的话,包括单元测试)。 -By now you should have a very good understanding of what each module does and you are ready for the real work: refactoring the code to improve maintainability and to make the code ready for new functionality. This will likely be the part of the project that consumes the most time, document as you go, do not make changes to a module until you have thoroughly documented it and feel you understand it. Feel free to rename variables and functions as well as datastructures to improve clarity and consistency, add tests (also unit tests, if the situation warrants them). -### Fix bugs -### 修改bugs -现在你准备承担真实用户看到的改变,战斗的第一步将是积累了一整年很多的bugs,像往常一样,第一步证实问题仍然存在,对这个结果做个测试然后修复这个bug,你的 CI 和写的端对端测试应该让你安全在你犯了错误由于不太熟悉或者一些额外的事情。 -Now you’re ready to take on actual end-user visible changes, the first order of battle will be the long list of bugs that have accumulated over the years in the ticket queue. As usual, first confirm the problem still exists, write a test to that effect and then fix the bug, your CI and the end-to-end tests written should keep you safe from any mistakes you make due to a lack of understanding or some peripheral issue. +现在,你应该非常理解每一个模块的作用了,准备做一些真正的工作吧:重构代码以提高其可维护性并且使代码做好添加新功能的准备。这很可能是项目中最消耗时间的部分,记录你所做的任何操作,在你彻底的记录模块并且理解之前不要对它做任何修改。之后你可以自由的修改变量名、函数名以及数据结构以提高代码的清晰度和统一性,然后请做测试(情况允许的话,包括单元测试)。 + +### 修复 bugs + +现在准备做一些用户可见的修改,战斗的第一步是修复很多积累了一整年的bugs,像往常一样,首先证实 bug 仍然存在,然后编写测试并修复这个 bug,你的 CI 和端对端测试应该能避免一些由于不太熟悉或者一些额外的事情而犯的错误。 -### Database Upgrade ### 升级数据库 -如果在前面的都所谓之后你需要固定和可维护的数据库再一次你有一个选项去改变数据库或者替换数据库用一个不同的完整的,如果这是你打算做的,做到了所有的这些将能够帮助你通过可靠的方式做修改而不会碰到问题,你会完整的测试新数据库和新代码,所有测试可以确保你顺利的迁移。 -If required after all this is done and you are on a solid and maintainable codebase again you have the option to change the database schema or to replace the database with a different make/model altogether if that is what you had planned to do. All the work you’ve done up to this point will help to assist you in making that change in a responsible manner without any surprises, you can completely test the new DB with the new code and all the tests in place to make sure your migration goes off without a hitch. -### Execute on the roadmap + +如果在一个坚实且可维护的代码库上完成所有工作,如果你有更改数据库模式的计划,可以使用不同的完全替换数据库。 +把所有的这些都做完将能够帮助你更可靠的修改而不会碰到问题,你会完全的测试新数据库和新代码,所有测试可以确保你顺利的迁移。 + ### 按着路线图执行 + 祝贺你脱离的困境并且可以准备添加新功能了。 -Congratulations, you are out of the woods and are now ready to implement new functionality. -### Do not ever even attempt a big-bang rewrite -### 任何时候都不要企图推翻重写 +### 任何时候都不要尝试彻底重写 -推翻重写是那种注定会失败的项目,之一,你是 -A big-bang rewrite is the kind of project that is pretty much guaranteed to fail. For one, you are in uncharted territory to begin with so how would you even know what to build, for another, you are pushing  _all_  the problems to the very last day, the day just before you go ‘live’ with your new system. And that’s when you’ll fail, miserably. Business logic assumptions will turn out to be faulty, suddenly you’ll gain insight into why that old system did certain things the way it did and in general you’ll end up realizing that the guys that put the old system together weren’t maybe idiots after all. If you really do want to wreck the company (and your own reputation to boot) by all means, do a big-bang rewrite, but if you’re smart about it this is not even on the table as an option. +彻底重写是那种注定会失败的项目,一方面,你在一个未知的领域开始,所以你甚至不知道构建什么,另一方面,你会把所以的问题都推到新系统马上就要上线的前一天,非常不幸的是,这也是你失败的时候,假设业务逻辑存在问题,你会得到异样的眼光,那时您会突然明白为什么旧系统会用某种奇怪的方式来工作,最终也会意识到能将旧系统放在一起工作的人也不都是白痴。在那之后。如果你真的想破坏公司(和你自己的声誉),那就重写吧,但如果你足够聪明,彻底重写系统通常不会成为一个摆到桌上讨论的选项。 -### So, the alternative, work incrementally +### 所以,替代方法是增量迭代工作 -To untangle one of these hairballs the quickest path to safety is to take any element of the code that you do understand (it could be a peripheral bit, but it might also be some core module) and try to incrementally improve it still within the old context. If the old build tools are no longer available you will have to use some tricks (see below) but at least try to leave as much of what is known to work alive while you start with your changes. That way as the codebase improves so does your understanding of what it actually does. A typical commit should be at most a couple of lines. +要解开这些线团最快方法是,使用你熟悉的代码中任何的元素(它可能是外部的,他可以是内核模块),试着使用旧的上下文去增量提升,如果旧的构建工具已经不能用了,你将必须使用一些技巧(看下面)至少当你开始做修改的时候,试着尽力保留已知的工作。那样随着代码库的提升你也对代码的作用更加理解。一个典型的代码提交应该最多两行。 -### Release! +### 发布! -Every change along the way gets released into production, even if the changes are not end-user visible it is important to make the smallest possible steps because as long as you lack understanding of the system there is a fair chance that only the production environment will tell you there is a problem. If that problem arises right after you make a small change you will gain several advantages: +每一次的修改都发布到生产环境,即使一些修改不是用户可见的。使用最少的步骤也是很重要的,因为当你缺乏对系统的了解时,只有生产环境能够告诉你问题在哪里,如果你只做了一个很小的修改之后出了问题,会有一些好处: -* it will probably be trivial to figure out what went wrong +* 很容易弄清楚出了什么问题 +* 这是一个改进流程的好位置 +* 你应该马上更新文档展示你的新见解 -* you will be in an excellent position to improve the process +### 使用代理的好处 +如果你做 web 开发时在旧系统和用户之间加了代理。你能很容易的控制每一个网址哪些请求旧系统,哪些重定向到新系统,从而更轻松更精确的控制运行的内容以及谁能够看到。如果你的代理足够的聪明,你可以使用它发送一定比例的流量到个人的 URL,直到你满意为止,如果你的集成测试也连接到这个接口那就更好了。 -* and you should immediately update the documentation to show the new insights gained - -### Use proxies to your advantage - -If you are doing web development praise the gods and insert a proxy between the end-users and the old system. Now you have per-url control over which requests go to the old system and which you will re-route to the new system allowing much easier and more granular control over what is run and who gets to see it. If your proxy is clever enough you could probably use it to send a percentage of the traffic to the new system for an individual URL until you are satisfied that things work the way they should. If your integration tests also connect to this interface it is even better. - -### Yes, but all this will take too much time! - -Well, that depends on how you look at it. It’s true there is a bit of re-work involved in following these steps. But it  _does_  work, and any kind of optimization of this process makes the assumption that you know more about the system than you probably do. I’ve got a reputation to maintain and I  _really_  do not like negative surprises during work like this. With some luck the company is already on the skids, or maybe there is a real danger of messing things up for the customers. In a situation like that I prefer total control and an iron clad process over saving a couple of days or weeks if that imperils a good outcome. If you’re more into cowboy stuff - and your bosses agree - then maybe it would be acceptable to take more risk, but most companies would rather take the slightly slower but much more sure road to victory. +### 是的,这会花费很多时间 +这取决于你怎样看待它的,这是事实会有一些重复的工作涉及到这些步骤中。但是它确实有效,对于进程的任何一个优化都将使你对这样系统更加熟悉。我会保持声誉,并且我真的不喜欢在工作期间有负面的意外。如果运气好的话,公司系统已经出现问题,而且可能会影响客户。在这样的情况下,如果你更多地是牛仔的做事方式,并且你的老板同意可以接受冒更大的风险,我比较喜欢完全控制整个流程得到好的结果而不是节省两天或者一星期,但是大多数公司宁愿采取稍微慢一点但更确定的胜利之路。 -------------------------------------------------------------------------------- via: https://jacquesmattheij.com/improving-a-legacy-codebase -作者:[Jacques Mattheij ][a] -译者:[译者ID](https://github.com/译者ID) +作者:[Jacques Mattheij][a] +译者:[aiwhj](https://github.com/aiwhj) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 1f1a56c1732741a52b91196dd620c9b4c2dab228 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 3 Dec 2017 15:40:29 +0800 Subject: [PATCH 120/344] translated translated --- .../tech/20170530 How to Improve a Legacy Codebase.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources => translated}/tech/20170530 How to Improve a Legacy Codebase.md (100%) diff --git a/sources/tech/20170530 How to Improve a Legacy Codebase.md b/translated/tech/20170530 How to Improve a Legacy Codebase.md similarity index 100% rename from sources/tech/20170530 How to Improve a Legacy Codebase.md rename to translated/tech/20170530 How to Improve a Legacy Codebase.md From 52263fb8cfab323740f04fbb8cbbc9ae0bf4da3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=91=E9=AD=85=E9=AD=8D=E9=AD=89?= <625310581@qq.com> Date: Sun, 3 Dec 2017 15:47:40 +0800 Subject: [PATCH 121/344] Update 20171130 Wake up and Shut Down Linux Automatically.md --- .../20171130 Wake up and Shut Down Linux Automatically.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md index efb0937695..356bc8feba 100644 --- a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md +++ b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md @@ -1,3 +1,7 @@ + +translating by HardworkFish +============================ + Wake up and Shut Down Linux Automatically ============================================================ From 203cec9c85a04ef78f44303821dc2715b7aaca3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=91=E9=AD=85=E9=AD=8D=E9=AD=89?= <625310581@qq.com> Date: Sun, 3 Dec 2017 15:47:56 +0800 Subject: [PATCH 122/344] Update 20171130 Wake up and Shut Down Linux Automatically.md --- .../tech/20171130 Wake up and Shut Down Linux Automatically.md | 1 - 1 file changed, 1 deletion(-) diff --git a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md index 356bc8feba..048de5a217 100644 --- a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md +++ b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md @@ -1,6 +1,5 @@ translating by HardworkFish -============================ Wake up and Shut Down Linux Automatically ============================================================ From 6a23fd90fe50ea0360dac2895487fe5b0ee4038e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=91=E9=AD=85=E9=AD=8D=E9=AD=89?= <625310581@qq.com> Date: Sun, 3 Dec 2017 15:49:42 +0800 Subject: [PATCH 123/344] translating translating by HardworkFish --- .../tech/20171130 Wake up and Shut Down Linux Automatically.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md index 048de5a217..3a2c20ad52 100644 --- a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md +++ b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md @@ -1,5 +1,5 @@ -translating by HardworkFish + translating by HardworkFish Wake up and Shut Down Linux Automatically ============================================================ From 0d3bf52593cd429317c8d70a506c9cd98266658f Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 3 Dec 2017 16:55:49 +0800 Subject: [PATCH 124/344] =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @yongshouzhang 不能改文件名 --- ...南.md => 20170622 A users guide to links in the Linux filesystem.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/tech/{linux 文件链接用户指南.md => 20170622 A users guide to links in the Linux filesystem.md} (100%) diff --git a/translated/tech/linux 文件链接用户指南.md b/translated/tech/20170622 A users guide to links in the Linux filesystem.md similarity index 100% rename from translated/tech/linux 文件链接用户指南.md rename to translated/tech/20170622 A users guide to links in the Linux filesystem.md From b623203bf829b63371438140c16be8b0a9ea2fe1 Mon Sep 17 00:00:00 2001 From: YOliver <740614279@qq.com> Date: Sun, 3 Dec 2017 16:59:52 +0800 Subject: [PATCH 125/344] Update 20171130 Excellent Business Software Alternatives For Linux.md --- ...0171130 Excellent Business Software Alternatives For Linux.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md b/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md index 3469c62569..195b51423a 100644 --- a/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md +++ b/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md @@ -1,3 +1,4 @@ +Yoliver istranslating. Excellent Business Software Alternatives For Linux ------- From 98b3ef5ff57c6008a2499a1fe452fd877a8d8e1c Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 3 Dec 2017 17:55:47 +0800 Subject: [PATCH 126/344] PRF:20171120 Containers and Kubernetes Whats next.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @yunfengHe 翻译的很专业顺畅。恭喜你,完成了第一篇翻译!接下来,你可以在翻译之余,对帮我做做校对吧~ --- ...20 Containers and Kubernetes Whats next.md | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/translated/tech/20171120 Containers and Kubernetes Whats next.md b/translated/tech/20171120 Containers and Kubernetes Whats next.md index 5ed099c170..57f9379f7b 100644 --- a/translated/tech/20171120 Containers and Kubernetes Whats next.md +++ b/translated/tech/20171120 Containers and Kubernetes Whats next.md @@ -1,54 +1,55 @@ -容器技术和 k8s 的下一站: +容器技术和 K8S 的下一站 ============================================================ -### 想知道容器编排管理和 K8s 的最新展望么?来看看专家怎么说。 +> 想知道容器编排管理和 K8S 的最新展望么?来看看专家怎么说。 ![CIO_Big Data Decisions_2](https://enterprisersproject.com/sites/default/files/styles/620x350/public/images/CIO_Big%20Data%20Decisions_2.png?itok=Y5zMHxf8 "CIO_Big Data Decisions_2") -如果你想对容器在未来的发展方向有一个整体把握,那么你一定要跟着钱走,看看钱都投在了哪里。当然了,有很多很多的钱正在投入容器的进一步发展。相关研究预计 2020 年容器技术的投入将占有 [27 亿美元][4] 的市场份额 。而在 2016 年,容器相关技术投入的总额为 7.62 亿美元,只有 2020 年投入预计的三分之一。巨额投入的背后是一些显而易见的基本因素,包括容器化的迅速增长以及并行化的大趋势。随着容器被大面积推广和使用,容器编排管理也会被理所当然的推广应用起来。 +如果你想对容器在未来的发展方向有一个整体把握,那么你一定要跟着钱走,看看钱都投在了哪里。当然了,有很多很多的钱正在投入容器的进一步发展。相关研究预计 2020 年容器技术的投入将占有 [27 亿美元][4] 的市场份额。而在 2016 年,容器相关技术投入的总额为 7.62 亿美元,只有 2020 年投入预计的三分之一。巨额投入的背后是一些显而易见的基本因素,包括容器化的迅速增长以及并行化的大趋势。随着容器被大面积推广和使用,容器编排管理也会被理所当然的推广应用起来。 -来自 [_The new stack_][5] 的调研数据表明,容器的推广使用是编排管理被推广的主要的催化剂。根据调研参与者的反馈数据,在已经将容器技术使用到生产环境中的使用者里,有六成正在将 kubernetes(k8s)编排管理广泛的应用在生产环境中,另外百分之十九的人员则表示他们已经处于部署 k8s 的初级阶段。在容器部署初期的使用者当中,虽然只有百分之五的人员表示已经在使用 K8s ,但是百分之五十八的人员表示他们正在计划和准备使用 K8s。总而言之,容器和 Kuebernetes 的关系就好比是鸡和蛋一样,相辅相成紧密关联。众多专家一致认为编排管理工具对容器的[长周期管理][6] 以及其在市场中的发展有至关重要的作用。正如 [Cockroach 实验室][7] 的 Alex Robinson 所说,容器编排管理被更广泛的拓展和应用是一个总体的大趋势。毫无疑问,这是一个正在快速演变的领域,且未来潜力无穷。鉴于此,我们对罗宾逊和其他的一些容器的实际使用和推介者做了采访,来从他们作为容器技术的践行者的视角上展望一下容器编排以及 k8s 的下一步发展。 +来自 [The new stack][5] 的调研数据表明,容器的推广使用是编排管理被推广的主要的催化剂。根据调研参与者的反馈数据,在已经将容器技术使用到生产环境中的使用者里,有六成使用者正在将 Kubernetes(K8S)编排管理广泛的应用在生产环境中,另外百分之十九的人员则表示他们已经处于部署 K8S 的初级阶段。在容器部署初期的使用者当中,虽然只有百分之五的人员表示已经在使用 K8S ,但是百分之五十八的人员表示他们正在计划和准备使用 K8S。总而言之,容器和 Kubernetes 的关系就好比是鸡和蛋一样,相辅相成紧密关联。众多专家一致认为编排管理工具对容器的[长周期管理][6] 以及其在市场中的发展有至关重要的作用。正如 [Cockroach 实验室][7] 的 Alex Robinson 所说,容器编排管理被更广泛的拓展和应用是一个总体的大趋势。毫无疑问,这是一个正在快速演变的领域,且未来潜力无穷。鉴于此,我们对 Robinson 和其他的一些容器的实际使用和推介者做了采访,来从他们作为容器技术的践行者的视角上展望一下容器编排以及 K8S 的下一步发展。 -### **容器编排将被主流接受** +### 容器编排将被主流接受 像任何重要技术的转型一样,我们就像是处在一个高崖之上一般,在经过了初期步履蹒跚的跋涉之后将要来到一望无际的广袤平原。广大的新天地和平实真切的应用需求将会让这种新技术在主流应用中被迅速推广,尤其是在大企业环境中。正如 Alex Robinson 说的那样,容器技术的淘金阶段已经过去,早期的技术革新创新正在减速,随之而来的则是市场对容器技术的稳定性和可用性的强烈需求。这意味着未来我们将不会再见到大量的新的编排管理系统的涌现,而是会看到容器技术方面更多的安全解决方案,更丰富的管理工具,以及基于目前主流容器编排系统的更多的新特性。 -### **更好的易用性** +### 更好的易用性 -人们将在简化容器的部署方面下大功夫,因为容器部署的初期工作对很多公司和组织来说还是比较复杂的,尤其是容器的[长期管理维护][8]更是需要投入大量的精力。正如 [Codemill AB][9] 公司的 My Karlsson 所说,容器编排技术还是太复杂了,这导致很多使用者难以娴熟驾驭和充分利用容器编排的功能。很多容器技术的新用户都需要花费很多精力,走很多弯路,才能搭建小规模的,单个的,被隔离的容器系统。这种现象在那些没有针对容器技术设计和优化的应用中更为明显。在简化容器编排管理方面有很多优化可以做,这些优化和改造将会使容器技术更加具有可用性。 +人们将在简化容器的部署方面下大功夫,因为容器部署的初期工作对很多公司和组织来说还是比较复杂的,尤其是容器的[长期管理维护][8]更是需要投入大量的精力。正如 [Codemill AB][9] 公司的 My Karlsson 所说,容器编排技术还是太复杂了,这导致很多使用者难以娴熟驾驭和充分利用容器编排的功能。很多容器技术的新用户都需要花费很多精力,走很多弯路,才能搭建小规模的或单个的以隔离方式运行的容器系统。这种现象在那些没有针对容器技术设计和优化的应用中更为明显。在简化容器编排管理方面有很多优化可以做,这些优化和改造将会使容器技术更加具有可用性。 -### **在 hybrid cloud 以及 multi-cloud 技术方面会有更多侧重** +### 在混合云以及多云技术方面会有更多侧重 -随着容器和容器编排技术被越来越多的使用,更多的组织机构会选择扩展他们现有的容器技术的部署,从之前的把非重要系统部署在单一环境的使用情景逐渐过渡到更加[复杂的使用情景][10]。对很多公司来说,这意味着他们必须开始学会在 [hybrid cloud][11] 和 [muilti-cloud][12] 的环境下,全局化的去管理那些容器化的应用和微服务。正如红帽 [Openshift 部门产品战略总监][14] [Brian Gracely][13] 所说,容器和 k8s 技术的使用使得我们成功的实现了混合云以及应用的可移植性。结合 Open Service Broker API 的使用,越来越多的结合私有云和公有云资源的新应用将会涌现出来。 +随着容器和容器编排技术被越来越多的使用,更多的组织机构会选择扩展他们现有的容器技术的部署,从之前的把非重要系统部署在单一环境的使用情景逐渐过渡到更加[复杂的使用情景][10]。对很多公司来说,这意味着他们必须开始学会在 [混合云][11] 和 [多云][12] 的环境下,全局化的去管理那些容器化的应用和微服务。正如红帽 [Openshift 部门产品战略总监][14] [Brian Gracely][13] 所说,“容器和 K8S 技术的使用使得我们成功的实现了混合云以及应用的可移植性。结合 Open Service Broker API 的使用,越来越多的结合私有云和公有云资源的新应用将会涌现出来。” 据 [CloudBees][15] 公司的高级工程师 Carlos Sanchez 分析,联合服务(Federation)将会得到极大推动,使一些诸如多地区部署和多云部署等的备受期待的新特性成为可能。 -**[ 想知道 CIO 们对 hybrid cloud 和 multi cloud 的战略构想么? 请参看我们的这条相关资源, **[**Hybrid Cloud: The IT leader's guide**][16]**. ]** +**[ 想知道 CIO 们对混合云和多云的战略构想么? 请参看我们的这条相关资源, [Hybrid Cloud: The IT leader's guide][16]。 ]** -### **平台和工具的持续整合及加强** +### 平台和工具的持续整合及加强 -对任何一种科技来说,持续的整合和加强从来都是大势所趋; 容器编排管理技术在这方面也不例外。来自 [Sumo Logic][17] 的首席分析师 Ben Newton 表示,随着容器化渐成主流,软件工程师们正在很少数的一些技术上做持续整合加固的工作,来满足他们的一些微应用的需求。容器和 K8s 将会毫无疑问的成为容器编排管理方面的主流平台,并轻松碾压其他的一些小众平台方案。因为 K8s 提供了一个相当清晰的可以摆脱各种特有云生态的途径,K8s 将被大量公司使用,逐渐形成一个不依赖于某个特定云服务的“中立云”(cloud-neutral)。 +对任何一种科技来说,持续的整合和加强从来都是大势所趋;容器编排管理技术在这方面也不例外。来自 [Sumo Logic][17] 的首席分析师 Ben Newton 表示,随着容器化渐成主流,软件工程师们正在很少数的一些技术上做持续整合加固的工作,来满足他们的一些微应用的需求。容器和 K8S 将会毫无疑问的成为容器编排管理方面的主流平台,并轻松碾压其它的一些小众平台方案。因为 K8S 提供了一个相当清晰的可以摆脱各种特有云生态的途径,K8S 将被大量公司使用,逐渐形成一个不依赖于某个特定云服务的“中立云”cloud-neutral。 -### **K8s 的下一站** +### K8S 的下一站 -来自 [Alcide][18] 的 CTO 和联合创始人 Gadi Naor 表示,k8s 将会是一个有长期和远景发展的技术,虽然我们的社区正在大力推广和发展 k8s,k8s 仍有很长的路要走。 -专家们对[日益流行的 k8s 平台][19]也作出了以下一些预测: +来自 [Alcide][18] 的 CTO 和联合创始人 Gadi Naor 表示,K8S 将会是一个有长期和远景发展的技术,虽然我们的社区正在大力推广和发展 K8S,K8S 仍有很长的路要走。 -**_来自 Alcide 的 Gadi Naor 表示:_** “运营商会持续演进并趋于成熟,直到在 k8s 上运行的应用可以完全自治。利用 [OpenTracing][20] 和诸如 [istio][21] 技术的 service mesh 架构,在 k8s 上部署和监控微应用将会带来很多新的可能性。” +专家们对[日益流行的 K8S 平台][19]也作出了以下一些预测: -**_来自 Red Hat 的 Brian Gracely 表示:_** “k8s 所支持的应用的种类越来越多。今后在 k8s 上,你不仅可以运行传统的应用程序,还可以运行原生的云应用,大数据应用以及 HPC 或者基于 GPU 运算的应用程序,这将为灵活的架构设计带来无限可能。” +**_来自 Alcide 的 Gadi Naor 表示:_** “运营商会持续演进并趋于成熟,直到在 K8S 上运行的应用可以完全自治。利用 [OpenTracing][20] 和诸如 [istio][21] 技术的 service mesh 架构,在 K8S 上部署和监控微应用将会带来很多新的可能性。” -**_来自 Sumo Logic 的 Ben Newton 表示:_** “随着 k8s 成为一个具有统治地位的平台,我预计更多的操作机制将会被统一化,尤其是 k8s 将和第三方管理和监控平台融合起来。” +**_来自 Red Hat 的 Brian Gracely 表示:_** “K8S 所支持的应用的种类越来越多。今后在 K8S 上,你不仅可以运行传统的应用程序,还可以运行原生的云应用、大数据应用以及 HPC 或者基于 GPU 运算的应用程序,这将为灵活的架构设计带来无限可能。” -**_来自 CloudBees 的 Carlos Sanchez 表示:_** “在不久的将来我们就能看到不依赖于 Docker 而使用其他运行时环境的系统,这将会有助于消除任何可能的 lock-in 情景“ [小编提示:[CRI-O][22] 就是一个可以借鉴的例子。]“而且我期待将来会出现更多的针对企业环境的存储服务新特性,包括数据快照以及在线的磁盘容量的扩展。” +**_来自 Sumo Logic 的 Ben Newton 表示:_** “随着 K8S 成为一个具有统治地位的平台,我预计更多的操作机制将会被统一化,尤其是 K8S 将和第三方管理和监控平台融合起来。” -**_来自 Cockroach Labs 的 Alex Robinson 表示:_** “ k8s 社区正在讨论的一个重大发展议题就是加强对[有状态程序][23]的管理。目前在 k8s 平台下,实现状态管理仍然非常困难,除非你所使用的云服务商可以提供远程固定磁盘。现阶段也有很多人在多方面试图改善这个状况,包括在 k8s 平台内部以及在外部服务商一端做出的一些改进。” +**_来自 CloudBees 的 Carlos Sanchez 表示:_** “在不久的将来我们就能看到不依赖于 Docker 而使用其它运行时环境的系统,这将会有助于消除任何可能的 lock-in 情景“ [编辑提示:[CRI-O][22] 就是一个可以借鉴的例子。]“而且我期待将来会出现更多的针对企业环境的存储服务新特性,包括数据快照以及在线的磁盘容量的扩展。” + +**_来自 Cockroach Labs 的 Alex Robinson 表示:_** “ K8S 社区正在讨论的一个重大发展议题就是加强对[有状态程序][23]的管理。目前在 K8S 平台下,实现状态管理仍然非常困难,除非你所使用的云服务商可以提供远程固定磁盘。现阶段也有很多人在多方面试图改善这个状况,包括在 K8S 平台内部以及在外部服务商一端做出的一些改进。” ------------------------------------------------------------------------------- via: https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next -作者:[Kevin Casey ][a] +作者:[Kevin Casey][a] 译者:[yunfengHe](https://github.com/yunfengHe) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From d29e8223e0a74ac10b249a5b58476d42e2419f0c Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 3 Dec 2017 17:56:29 +0800 Subject: [PATCH 127/344] PUB:20171120 Containers and Kubernetes Whats next.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @yunfengHe 文章发布地址:https://linux.cn/article-9104-1.html 你的 LCTT 专页地址: https://linux.cn/lctt/yunfengHe --- .../20171120 Containers and Kubernetes Whats next.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171120 Containers and Kubernetes Whats next.md (100%) diff --git a/translated/tech/20171120 Containers and Kubernetes Whats next.md b/published/20171120 Containers and Kubernetes Whats next.md similarity index 100% rename from translated/tech/20171120 Containers and Kubernetes Whats next.md rename to published/20171120 Containers and Kubernetes Whats next.md From a7326ccd7c410900d884a720c0ad1a13294a059b Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 3 Dec 2017 19:32:19 +0800 Subject: [PATCH 128/344] PRF:20170622 A users guide to links in the Linux filesystem.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @yongshouzhang 恭喜你,完成了第一篇翻译,很用心。我的校对,可以参照 diff。 --- ... guide to links in the Linux filesystem.md | 129 ++++++++---------- 1 file changed, 59 insertions(+), 70 deletions(-) diff --git a/translated/tech/20170622 A users guide to links in the Linux filesystem.md b/translated/tech/20170622 A users guide to links in the Linux filesystem.md index 84c5756c59..7d731693d8 100644 --- a/translated/tech/20170622 A users guide to links in the Linux filesystem.md +++ b/translated/tech/20170622 A users guide to links in the Linux filesystem.md @@ -1,32 +1,19 @@ - -linux 文件链接用户指南 +用户指南:Linux 文件系统的链接 ============================================================ -### 学习如何使用链接,通过提供对 linux 文件系统多个位置的文件访问,来让日常工作变得轻松 +> 学习如何使用链接,通过从 Linux 文件系统多个位置来访问文件,可以让日常工作变得轻松。 +![linux 文件链接用户指南](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/links.png?itok=enaPOi4L "A user's guide to links in the Linux filesystem") -![linux 文件链接用户指南](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/links.png?itok=AumNmse7 "A user's guide to links in the Linux filesystem") Image by : [Paul Lewin][8]. Modified by Opensource.com. [CC BY-SA 2.0][9] -在我为 opensource.com 写过的关于linux文件系统方方面面的文章中,包括 [An introduction to Linux's EXT4 filesystem][10]; [Managing devices in Linux][11]; [An introduction to Linux filesystems][12]; and [A Linux user's guide to Logical Volume Management][13],我曾简要的提到过linux文件系统一个有趣的特性,它允许用户访问linux文件目录树中多个位置的文件来简化一些任务 +在我为 opensource.com 写过的关于 Linux 文件系统方方面面的文章中,包括 [Linux 的 EXT4 文件系统的历史、特性以及最佳实践][10]; [在 Linux 中管理设备][11];[Linux 文件系统概览][12] 和 [用户指南:逻辑卷管理][13],我曾简要的提到过 Linux 文件系统一个有趣的特性,它允许用户从多个位置来访问 Linux 文件目录树中的文件来简化一些任务。 -linux 文件系统中有两种链接:硬链接和软链接。虽然二者差别显著,但都用来解决相似的问题。它们都提供了对单个文件进行多个目录项的访问(引用),但实现却大为不同。链接的强大功能赋予了 linux 文件系统灵活性,因为[一切即文件][14]。 +Linux 文件系统中有两种链接link硬链接hard link软链接soft link。虽然二者差别显著,但都用来解决相似的问题。它们都提供了对单个文件的多个目录项(引用)的访问,但实现却大为不同。链接的强大功能赋予了 Linux 文件系统灵活性,因为[一切皆是文件][14]。 -更多 linux 资源 +举个例子,我曾发现一些程序要求特定的版本库方可运行。 当用升级后的库替代旧库后,程序会崩溃,提示旧版本库缺失。通常,库名的唯一变化就是版本号。出于直觉,我仅仅给程序添加了一个新的库链接,并以旧库名称命名。我试着再次启动程序,运行良好。程序就是一个游戏,人人都明白,每个玩家都会尽力使游戏进行下去。 -*   [什么是 linux ?][1] - -*   [什么是 linux 容器?][2] - -*   [现在下载: linux 命令速查表][3] - -*   [linux 高级命令速查表][4] - -*   [我们最新的 linux 文章][5] - -举个例子,我曾发现一些程序要求特定的版本库方可运行。 当用升级后的库替代旧库后,程序会崩溃,提示就版本库缺失。 同城库中唯一变化是版本号。出于该直觉,我仅仅给程序添加了一个新的库链接,并以旧库名称命名。我试着再次启动程序,运行良好。 程序就是一个游戏,人人都明白,每个玩家都会尽力使游戏进行下去。 - -事实上,几乎所有的应用程序链接库都使用通用的命名规则,链接名称中包含了住版本号,链接所指文件的文件名中同样包含了最小版本号。再比如,程序的一些必需文件为了迎合 linux 文件系统的规范从一个目录移动到另一个目录中,系统为了向后兼容那些不能获取这些文件新位置的程序在旧的目录中存放了这些文件的链接。如果你对 /lib64 目录做一个长清单列表,你会发现很多这样的例子。 +事实上,几乎所有的应用程序链接库都使用通用的命名规则,链接名称中包含了主版本号,链接所指向的文件的文件名中同样包含了小版本号。再比如,程序的一些必需文件为了迎合 Linux 文件系统规范,从一个目录移动到另一个目录中,系统为了向后兼容那些不能获取这些文件新位置的程序在旧的目录中存放了这些文件的链接。如果你对 `/lib64` 目录做一个长清单列表,你会发现很多这样的例子。 ``` lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.hwm -> ../../usr/share/cracklib/pw_dict.hwm @@ -44,36 +31,37 @@ lrwxrwxrwx. 1 root root 30 Jan 16 16:39 libakonadi-calendar.so.4 -> libak lrwxrwxrwx. 1 root root 29 Jan 16 16:39 libakonadi-contact.so.4 -> libakonadi-contact.so.4.14.26 ``` -**/lib64** 目录下的一些链接 +`/lib64` 目录下的一些链接 -T在上面展示的 **/lib64** 目录清单列表中,文件模式第一个字母 I 表示这是一个符号链接或软链接。 +在上面展示的 `/lib64` 目录清单列表中,文件模式第一个字母 `l` (小写字母 l)表示这是一个软链接(又称符号链接)。 ### 硬链接 -在 [An introduction to Linux's EXT4 filesystem][15]一文中,我曾探讨过这样一个事实,每个文件都有一个包含该文件信息的节点,包含了该文件的位置信息。上述文章中的[图2][16]展示了一个指向文件节点的单一目录项。每个文件都至少有一个目录项指向描述该文件信息的文件节点,目录项是一个硬链接,因此每个文件至少都有一个硬链接。 +在 [Linux 的 EXT4 文件系统的历史、特性以及最佳实践][15]一文中,我曾探讨过这样一个事实,每个文件都有一个包含该文件信息的 inode,包含了该文件的位置信息。上述文章中的[图2][16]展示了一个指向 inode 的单一目录项。每个文件都至少有一个目录项指向描述该文件信息的 inode ,目录项是一个硬链接,因此每个文件至少都有一个硬链接。 -如下图1所示,多个目录项指向了同一文件节点。这些目录项都是硬链接。我曾使用波浪线 (**~**) 表示三级目录项的缩写,这是用户目录的惯例表示,因此在该例中波浪线等同于 **/home/user** 。值得注意的是,四级目录项是一个完全不同的目录,**/home/shared** 可能是该计算机上用户的共享文件目录。 +如下图 1 所示,多个目录项指向了同一 inode 。这些目录项都是硬链接。我曾在三个目录项中使用波浪线 (`~`) 的缩写,这是用户目录的惯例表示,因此在该例中波浪线等同于 `/home/user` 。值得注意的是,第四个目录项是一个完全不同的目录,`/home/shared`,可能是该计算机上用户的共享文件目录。 ![fig1directory_entries.png](https://opensource.com/sites/default/files/images/life/fig1directory_entries.png) -Figure 1 -单一文件系统中的文件硬链接数是有限制的。”文件系统“ 是就挂载在特定挂载点上的分区或逻辑卷而言的,此例中是 /home。这是因为文件系统中的节点号都是唯一的。在不同的文件系统中,如 **/var** 或 **/opt**,会有和 **/home** 中相同的节点号。 +*图 1* -因为所有的硬链接都指向了包含文件元信息的节点,这些特性都是文件的一部分,像所属关系,权限,节点硬链接数目,这些特性不能区分不同的硬链接。这是一个文件所具有的一组属性。唯一能区分这些文件的是包含在节点信息中的文件名。对单靠 **file/inode** 来定位文件的同一目录中的硬链接必须拥有不同的文件名,基于上述事实,同一目录下不能存在重复的文件名。 +硬链接被限制在一个单一的文件系统中。此处的“文件系统” 是指挂载在特定挂载点上的分区或逻辑卷,此例中是 `/home`。这是因为在每个文件系统中的 inode 号都是唯一的。而在不同的文件系统中,如 `/var` 或 `/opt`,会有和 `/home` 中相同的 inode 号。 -文件的硬链接数目可通过 **ls -l** 来查看,如果你想查看实际节点号,可使用 **ls -li** 命令。 +因为所有的硬链接都指向了包含文件元信息的单一 inode ,这些属性都是文件的一部分,像所属关系、权限、到该 inode 的硬链接数目,对每个硬链接来说这些特性没有什么不同的。这是一个文件所具有的一组属性。唯一能区分这些文件的是包含在 inode 信息中的文件名。链接到同一目录中的单一文件/ inode 的硬链接必须拥有不同的文件名,这是基于同一目录下不能存在重复的文件名的事实的。 + +文件的硬链接数目可通过 `ls -l` 来查看,如果你想查看实际节点号,可使用 `ls -li` 命令。 ### 符号(软)链接 -软链接(符号链接)和硬链接的区别在于,硬链接直接指向文件中的节点而软链接直接指向一个目录项,即一个硬链接。因为软链接指向一个文件的硬链接而非该文件的节点信息,所以它们并不依赖于文件节点,这使得它们能在不同的文件系统中起作用,跨越不同的分区和逻辑卷。 +硬链接和软链接(也称为符号链接symlink)的区别在于,硬链接直接指向属于该文件的 inode ,而软链接直接指向一个目录项,即指向一个硬链接。因为软链接指向的是一个文件的硬链接而非该文件的 inode ,所以它们并不依赖于 inode 号,这使得它们能跨越不同的文件系统、分区和逻辑卷起作用。 -软链接的缺点是,一旦它所指向的硬链接被删除或重命名后,该软链接就失效了。软链接虽然还在,但所指向的硬链接已不存在。所幸的是,**ls** 命令能以红底白字的方式在其列表中高亮显示失效的软链接。 +软链接的缺点是,一旦它所指向的硬链接被删除或重命名后,该软链接就失效了。软链接虽然还在,但所指向的硬链接已不存在。所幸的是,`ls` 命令能以红底白字的方式在其列表中高亮显示失效的软链接。 ### 实验项目: 链接实验 -我认为最容易理解链接用法及其差异的方法即使动手搭建一个项目。这个项目应以非超级用户的身份在一个空目录下进行。我创建了 **~/tmp** 目录做这个实验,你也可以这么做。这么做可为项目创建一个安全的环境且提供一个新的空目录让程序运作,如此以来这儿仅存放和程序有关的文件。 +我认为最容易理解链接用法及其差异的方法是动手搭建一个项目。这个项目应以非超级用户的身份在一个空目录下进行。我创建了 `~/temp` 目录做这个实验,你也可以这么做。这么做可为项目创建一个安全的环境且提供一个新的空目录让程序运作,如此以来这儿仅存放和程序有关的文件。 -### **初始工作** +#### 初始工作 首先,在你要进行实验的目录下为该项目中的任务创建一个临时目录,确保当前工作目录(PWD)是你的主目录,然后键入下列命令。 @@ -81,19 +69,19 @@ Figure 1 mkdir temp ``` -使用这个命名将当前工作目录切换到 *~/temp**  +使用这个命令将当前工作目录切换到 `~/temp`。 ``` cd temp ``` -实验开始,我们创建一个能够链接的文件,下列命令可完成该工作并向其填充内容。 +实验开始,我们需要创建一个能够链接到的文件,下列命令可完成该工作并向其填充内容。 ``` du -h > main.file.txt ``` -使用 *ls -l** 长列表命名确认文件被正确地创建。运行结果应类似于我的。注意文件大小只有 7 字节,但你的可能会有 1~2 字节的变动。 +使用 `ls -l` 长列表命名确认文件正确地创建了。运行结果应类似于我的。注意文件大小只有 7 字节,但你的可能会有 1~2 字节的变动。 ``` [dboth@david temp]$ ls -l @@ -101,11 +89,11 @@ total 4 -rw-rw-r-- 1 dboth dboth 7 Jun 13 07:34 main.file.txt ``` -在列表中,文件模式串后的数字 1 代表存在于该文件上的硬链接数。现在应该是 1 ,因为我们还没有为这个测试文件建立任何硬链接。 +在列表中,文件模式串后的数字 `1` 代表存在于该文件上的硬链接数。现在应该是 1 ,因为我们还没有为这个测试文件建立任何硬链接。 -### **对硬链接进行实验** +#### 对硬链接进行实验 -硬链接创建一个指向同一文件节点的目录项,当为文件添加一个硬链接时,你会看到链接数目的增加。确保当前工作目录仍为 **~/temp**。创建一个指向 **main.file.txt** 的硬链接,然后查看该目录下文件列表。 +硬链接创建一个指向同一 inode 的新目录项,当为文件添加一个硬链接时,你会看到链接数目的增加。确保当前工作目录仍为 `~/temp`。创建一个指向 `main.file.txt` 的硬链接,然后查看该目录下文件列表。 ``` [dboth@david temp]$ ln main.file.txt link1.file.txt @@ -115,7 +103,7 @@ total 8 -rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 main.file.txt ``` -目录中两个文件都有两个链接且大小相同,时间戳也一样。这是同一文件节点的两个不同的硬链接,即该文件的目录项。再建立一个该文件的硬链接,并列出目录清单内容,你可以建立 **link1.file.txt** 或 **main.file.txt** 的硬链接。 +目录中两个文件都有两个链接且大小相同,时间戳也一样。这就是有一个 inode 和两个硬链接(即该文件的目录项)的一个文件。再建立一个该文件的硬链接,并列出目录清单内容。你可以建立硬链接: `link1.file.txt` 或 `main.file.txt`。 ``` [dboth@david temp]$ ln link1.file.txt link2.file.txt ; ls -l @@ -132,14 +120,15 @@ total 16 ln: failed to create hard link 'link2.file.txt': File exists ``` -显然不行,因为 **link2.file.txt** 已经存在。目前为止我们只在同一目录下创建硬链接,接着在临时目录的父目录,你的主目录中创建一个链接。 +显然不行,因为 `link2.file.txt` 已经存在。目前为止我们只在同一目录下创建硬链接,接着在临时目录的父目录(你的主目录)中创建一个链接。 ``` [dboth@david temp]$ ln main.file.txt ../main.file.txt ; ls -l ../main* -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt ``` - 上面的 **ls** 命令显示 **main.file.txt** 文件确实存在于主目录中,且与该文件在 temp 目录中的名称一致。当然它们是没有区别的两个文件,它们是同一文件的两个链接,指向了同一文件的目录项。为了帮助说明下一点,在 temp 目录中添加一个非链接文件。 +上面的 `ls` 命令显示 `main.file.txt` 文件确实存在于主目录中,且与该文件在 `temp` 目录中的名称一致。当然它们不是不同的文件,它们是同一文件的两个链接,指向了同一文件的目录项。为了帮助说明下一点,在 `temp` 目录中添加一个非链接文件。 + ``` [dboth@david temp]$ touch unlinked.file ; ls -l total 12 @@ -149,7 +138,7 @@ total 12 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file ``` -使用 **ls** 命令的 **i** 选项查看文件节点的硬链接号和新创建文件的硬链接号。 +使用 `ls` 命令的 `i` 选项查看 inode 的硬链接号和新创建文件的硬链接号。 ``` [dboth@david temp]$ ls -li @@ -160,7 +149,7 @@ total 12 657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file ``` -注意上面文件模式左边的数字 **657024** ,这是三个硬链接文件所指的同一文件的节点号,你也可以使用 **i** 选项查看主目录中所创建的链接节点号,和该值相同。只有一个链接的文件节点号和其他的不同,在你的系统上看到的不同于本文中的。 +注意上面文件模式左边的数字 `657024` ,这是三个硬链接文件所指的同一文件的 inode 号,你也可以使用 `i` 选项查看主目录中所创建的链接的节点号,和该值相同。而那个只有一个链接的 inode 号和其他的不同,在你的系统上看到的 inode 号或许不同于本文中的。 接着改变其中一个硬链接文件的大小。 @@ -173,11 +162,11 @@ total 12 657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file ``` -现在的硬链接文件大小比原来大,因为多个目录项链接着同一文件。 +现在所有的硬链接文件大小都比原来大了,因为多个目录项都链接着同一文件。 -我知道下个实验在我的电脑上会成功,因为我的 **/tmp** 目录是一个独立的逻辑卷,如果你有单独的逻辑卷或文件系统在不同的分区上(如果未使用逻辑卷),确定你是否能访问那个分区或逻辑卷,如果不能,你可以在电脑上挂载一个 U盘,如果上述选项适合你,你可以进行这个实验。 +下个实验在我的电脑上会出现这样的结果,是因为我的 `/tmp` 目录在一个独立的逻辑卷上。如果你有单独的逻辑卷或文件系统在不同的分区上(如果未使用逻辑卷),确定你是否能访问那个分区或逻辑卷,如果不能,你可以在电脑上挂载一个 U 盘,如果上述方式适合你,你可以进行这个实验。 -试着在 **/tmp** 目录中建立一个 **~/temp** 目录下文件的链接(或你的文件系统所在的位置) +试着在 `/tmp` 目录中建立一个 `~/temp` 目录下文件的链接(或你的文件系统所在的位置)。 ``` [dboth@david temp]$ ln link2.file.txt /tmp/link3.file.txt @@ -185,9 +174,9 @@ ln: failed to create hard link '/tmp/link3.file.txt' => 'link2.file.txt': Invalid cross-device link ``` -为什么会出现这个错误呢? 原因是每一个单独的挂载文件系统都有一套自己的节点号。简单的通过文件节点号来跨越整个文件系统结构引用一个文件会使系统困惑,因为相同的节点号会存在于每个已挂载的文件系统中。 +为什么会出现这个错误呢? 原因是每一个单独的可挂载文件系统都有一套自己的 inode 号。简单的通过 inode 号来跨越整个 Linux 文件系统结构引用一个文件会使系统困惑,因为相同的节点号会存在于每个已挂载的文件系统中。 -有时你可能会想找到一个文件节点的所有硬链接。你可以使用 **ls -li** 命令。然后使用 **find** 命令找到所有硬链接的节点号。 +有时你可能会想找到一个 inode 的所有硬链接。你可以使用 `ls -li` 命令。然后使用 `find` 命令找到所有硬链接的节点号。 ``` [dboth@david temp]$ find . -inum 657024 @@ -196,7 +185,7 @@ Invalid cross-device link ./link2.file.txt ``` -注意 **find** 命令不能找到所属该节点的四个硬链接,因为我们在 **~/temp** 目录中查找。 **find** 命令仅在当前工作目录及其子目录中中查找文件。要找到所有的硬链接,我们可以使用下列命令,注定你的主目录作为起始查找条件。 +注意 `find` 命令不能找到所属该节点的四个硬链接,因为我们在 `~/temp` 目录中查找。 `find` 命令仅在当前工作目录及其子目录中查找文件。要找到所有的硬链接,我们可以使用下列命令,指定你的主目录作为起始查找条件。 ``` [dboth@david temp]$ find ~ -samefile main.file.txt @@ -206,13 +195,13 @@ Invalid cross-device link /home/dboth/main.file.txt ``` -如果你是非超级用户没有权限,可能会看到错误信息。这个命令也使用了 **-samefile** 选项而不是指定文件的节点号。这个效果和使用文件节点号一样且更容易,如果你知道其中一个硬链接名称的话。 +如果你是非超级用户,没有权限,可能会看到错误信息。这个命令也使用了 `-samefile` 选项而不是指定文件的节点号。这个效果和使用 inode 号一样且更容易,如果你知道其中一个硬链接名称的话。 -### **对软链接进行实验** +#### 对软链接进行实验 -如你刚才看到的,不能越过文件系统交叉创建硬链接,即在逻辑卷或文件系统中从一个文件系统到另一个文件系统。软链接给出了这个问题的解决方案。虽然他们可以达到相同的目的,但他们是非常不同的,知道这些差异是很重要的。 +如你刚才看到的,不能跨越文件系统边界创建硬链接,即在逻辑卷或文件系统中从一个文件系统到另一个文件系统。软链接给出了这个问题的解决方案。虽然它们可以达到相同的目的,但它们是非常不同的,知道这些差异是很重要的。 -让我们在 **~/temp** 目录中创建一个符号链接来开始我们的探索。 +让我们在 `~/temp` 目录中创建一个符号链接来开始我们的探索。 ``` [dboth@david temp]$ ln -s link2.file.txt link3.file.txt ; ls -li @@ -225,9 +214,9 @@ link2.file.txt 657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file ``` -拥有节点号 **657024** 的那些硬链接没有变化,且硬链接的数目也没有变化。新创建的符号链接有不同的文件节点号 **658270**。 名为**link3.file.txt** 的软链接指向了 **link2.file.txt** 文件。使用 **cat** 命令查看 **link3.file.txt** 文件的内容。符号链接的文件节点信息以字母 "**l**" 开头,意味着这个文件实际是个符号链接。 +拥有节点号 `657024` 的那些硬链接没有变化,且硬链接的数目也没有变化。新创建的符号链接有不同的 inode 号 `658270`。 名为 `link3.file.txt` 的软链接指向了 `link2.file.txt` 文件。使用 `cat` 命令查看 `link3.file.txt` 文件的内容。符号链接的 inode 信息以字母 `l` (小写字母 l)开头,意味着这个文件实际是个符号链接。 -上例中软链接文件 **link3.file.txt** 的大小只有 14 字节。这是文本内容 **link3.file.txt -> link2.file.txt** 的大小,实际上是目录项的内容。目录项 **link3.file.txt** 并不指向一个文件节点;它指向了另一个目录项,这在跨越文件系统建立链接时很有帮助。现在试着创建一个软链接,之前在 **/tmp** 目录中尝试过的。 +上例中软链接文件 `link3.file.txt` 的大小只有 14 字节。这是文本内容 `link3.file.txt` 的大小,即该目录项的实际内容。目录项 `link3.file.txt` 并不指向一个 inode ;它指向了另一个目录项,这在跨越文件系统建立链接时很有帮助。现在试着创建一个软链接,之前在 `/tmp` 目录中尝试过的。 ``` [dboth@david temp]$ ln -s /home/dboth/temp/link2.file.txt @@ -236,11 +225,11 @@ lrwxrwxrwx 1 dboth dboth 31 Jun 14 21:53 /tmp/link3.file.txt -> /home/dboth/temp/link2.file.txt ``` -### **删除链接** +#### 删除链接 当你删除硬链接或硬链接所指的文件时,需要考虑一些问题。 -首先,让我们删除硬链接文件 **main.file.txt**。注意每个硬链接都指向了一个文件节点。 +首先,让我们删除硬链接文件 `main.file.txt`。注意指向 inode 的每个目录项就是一个硬链接。 ``` [dboth@david temp]$ rm main.file.txt ; ls -li @@ -252,9 +241,9 @@ link2.file.txt 657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file ``` -**main.file.txt** 是第一个硬链接文件,当该文件被创建时。现在删除它仍然保留原始文件和硬盘上的数据以及所有剩余的硬链接。要删除原始文件,你必须删除它的所有硬链接。 +`main.file.txt` 是该文件被创建时所创建的第一个硬链接。现在删除它,仍然保留着原始文件和硬盘上的数据以及所有剩余的硬链接。要删除原始文件,你必须删除它的所有硬链接。 -现在山村 **link2.file.txt** 硬链接文件。 +现在删除 `link2.file.txt` 硬链接文件。 ``` [dboth@david temp]$ rm link2.file.txt ; ls -li @@ -266,27 +255,27 @@ link2.file.txt 657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file ``` -注意软链接的变化。删除软链接所指的硬链接会使该软链接失效。在我的系统中,断开的链接用颜色高亮显示,目标硬链接闪烁。如果需要修改软链接,你需要在同一目录下建立一个和旧链接相同名字的硬链接,只要不是所有硬链接都已删除。 您还可以重新创建链接本身,链接保持相同的名称,但指向剩余的硬链接中的一个。当然如果软链接不再需要,可以使用 **rm** 命令删除它们。 +注意软链接的变化。删除软链接所指的硬链接会使该软链接失效。在我的系统中,断开的链接用颜色高亮显示,目标的硬链接会闪烁显示。如果需要修复这个损坏的软链接,你需要在同一目录下建立一个和旧链接相同名字的硬链接,只要不是所有硬链接都已删除就行。您还可以重新创建链接本身,链接保持相同的名称,但指向剩余的硬链接中的一个。当然如果软链接不再需要,可以使用 `rm` 命令删除它们。 -**unlink** 命令在删除文件和链接时也有用。它非常简单且没有选项,就像 **rm** 命令一样。然而,它更准确地反映了删除的基本过程,因为它删除了目录项与被删除文件的链接。 +`unlink` 命令在删除文件和链接时也有用。它非常简单且没有选项,就像 `rm` 命令一样。然而,它更准确地反映了删除的基本过程,因为它删除了目录项与被删除文件的链接。 ### 写在最后 -我曾与这两种类型的链接很长一段时间后,我开始了解他们的能力和特质。为我所教的Linux课程编写了一个实验室项目,以充分理解链接是如何工作的,并且我希望增进你的理解。 +我用过这两种类型的链接很长一段时间后,我开始了解它们的能力和特质。我为我所教的 Linux 课程编写了一个实验室项目,以充分理解链接是如何工作的,并且我希望增进你的理解。 -------------------------------------------------------------------------------- 作者简介: -戴维.布斯 - 戴维.布斯是Linux和开源倡导者,居住在Raleigh的北卡罗莱纳。他在IT行业工作了四十年,为IBM工作了20年多的OS 2。在IBM时,他在1981编写了最初的IBM PC的第一个培训课程。他教了RHCE班红帽子和曾在MCI世通公司,思科,和北卡罗莱纳州。他已经用Linux和开源软件工作将近20年了。 +戴维.布斯 - 戴维.布斯是 Linux 和开源倡导者,居住在北卡罗莱纳的罗列 。他在 IT 行业工作了四十年,为 IBM 工作了 20 多年的 OS/2。在 IBM 时,他在 1981 年编写了最初的 IBM PC 的第一个培训课程。他为 RedHat 教授过 RHCE 班,并曾在 MCI Worldcom、思科和北卡罗莱纳州工作。他已经用 Linux 和开源软件工作将近 20 年了。 --------------------------------- via: https://opensource.com/article/17/6/linking-linux-filesystem -作者:[David Both ][a] +作者:[David Both][a] 译者:[yongshouzhang](https://github.com/yongshouzhang) -校对:[yongshouzhang](https://github.com/yongshouzhang) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -300,12 +289,12 @@ via: https://opensource.com/article/17/6/linking-linux-filesystem [7]:https://opensource.com/user/14106/feed [8]:https://www.flickr.com/photos/digypho/7905320090 [9]:https://creativecommons.org/licenses/by/2.0/ -[10]:https://opensource.com/article/17/5/introduction-ext4-filesystem -[11]:https://opensource.com/article/16/11/managing-devices-linux -[12]:https://opensource.com/life/16/10/introduction-linux-filesystems +[10]:https://linux.cn/article-8685-1.html +[11]:https://linux.cn/article-8099-1.html +[12]:https://linux.cn/article-8887-1.html [13]:https://opensource.com/business/16/9/linux-users-guide-lvm [14]:https://opensource.com/life/15/9/everything-is-a-file -[15]:https://opensource.com/article/17/5/introduction-ext4-filesystem -[16]:https://opensource.com/article/17/5/introduction-ext4-filesystem#fig2 +[15]:https://linux.cn/article-8685-1.html +[16]:https://linux.cn/article-8685-1.html#3_19182 [17]:https://opensource.com/users/dboth [18]:https://opensource.com/article/17/6/linking-linux-filesystem#comments From 7d8f1fa3718792ea4433e24f302f6a552fa97f12 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 3 Dec 2017 19:33:11 +0800 Subject: [PATCH 129/344] PUB:20170622 A users guide to links in the Linux filesystem.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @yongshouzhang 文章发布地址:https://linux.cn/article-9105-1.html (公众号明天推送),你的 LCTT 专页地址: https://linux.cn/lctt/yongshouzhang --- .../20170622 A users guide to links in the Linux filesystem.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20170622 A users guide to links in the Linux filesystem.md (100%) diff --git a/translated/tech/20170622 A users guide to links in the Linux filesystem.md b/published/20170622 A users guide to links in the Linux filesystem.md similarity index 100% rename from translated/tech/20170622 A users guide to links in the Linux filesystem.md rename to published/20170622 A users guide to links in the Linux filesystem.md From b918001472fc4f209a74a28506e3e2930930796d Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 19:36:22 +0800 Subject: [PATCH 130/344] =?UTF-8?q?20171203-1=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... and How to Set an Open Source Strategy.md | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 sources/tech/20171115 Why and How to Set an Open Source Strategy.md diff --git a/sources/tech/20171115 Why and How to Set an Open Source Strategy.md b/sources/tech/20171115 Why and How to Set an Open Source Strategy.md new file mode 100644 index 0000000000..79ec071b4d --- /dev/null +++ b/sources/tech/20171115 Why and How to Set an Open Source Strategy.md @@ -0,0 +1,120 @@ +Why and How to Set an Open Source Strategy +============================================================ + +![](https://www.linuxfoundation.org/wp-content/uploads/2017/11/open-source-strategy-1024x576.jpg) + +This article explains how to walk through, measure, and define strategies collaboratively in an open source community. + + _“If you don’t know where you are going, you’ll end up someplace else.” _ _—_  Yogi Berra + +Open source projects are generally started as a way to scratch one’s itch — and frankly that’s one of its greatest attributes. Getting code down provides a tangible method to express an idea, showcase a need, and solve a problem. It avoids over thinking and getting a project stuck in analysis-paralysis, letting the project pragmatically solve the problem at hand. + +Next, a project starts to scale up and gets many varied users and contributions, with plenty of opinions along the way. That leads to the next big challenge — how does a project start to build a strategic vision? In this article, I’ll describe how to walk through, measure, and define strategies collaboratively, in a community. + +Strategy may seem like a buzzword of the corporate world rather something that an open source community would embrace, so I suggest stripping away the negative actions that are sometimes associated with this word (e.g., staff reductions, discontinuations, office closures). Strategy done right isn’t a tool to justify unfortunate actions but to help show focus and where each community member can contribute. + +A good application of strategy achieves the following: + +* Why the project exists? + +* What the project looks to achieve? + +* What is the ideal end state for a project is. + +The key to success is answering these questions as simply as possible, with consensus from your community. Let’s look at some ways to do this. + +### Setting a mission and vision + + _“_ _Efforts and courage are not enough without purpose and direction.”_  — John F. Kennedy + +All strategic planning starts off with setting a course for where the project wants to go. The two tools used here are  _Mission_  and  _Vision_ . They are complementary terms, describing both the reason a project exists (mission) and the ideal end state for a project (vision). + +A great way to start this exercise with the intent of driving consensus is by asking each key community member the following questions: + +* What drove you to join and/or contribute the project? + +* How do you define success for your participation? + +In a company, you’d ask your customers these questions usually. But in open source projects, the customers are the project participants — and their time investment is what makes the project a success. + +Driving consensus means capturing the answers to these questions and looking for themes across them. At R Consortium, for example, I created a shared doc for the board to review each member’s answers to the above questions, and followed up with a meeting to review for specific themes that came from those insights. + +Building a mission flows really well from this exercise. The key thing is to keep the wording of your mission short and concise. Open Mainframe Project has done this really well. Here’s their mission: + + _Build community and adoption of Open Source on the mainframe by:_ + +* _Eliminating barriers to Open Source adoption on the mainframe_ + +* _Demonstrating value of the mainframe on technical and business levels_ + +* _Strengthening collaboration points and resources for the community to thrive_ + +At 40 words, it passes the key eye tests of a good mission statement; it’s clear, concise, and demonstrates the useful value the project aims for. + +The next stage is to reflect on the mission statement and ask yourself this question: What is the ideal outcome if the project accomplishes its mission? That can be a tough one to tackle. Open Mainframe Project put together its vision really well: + + _Linux on the Mainframe as the standard for enterprise class systems and applications._ + +You could read that as a [BHAG][1], but it’s really more of a vision, because it describes a future state that is what would be created by the mission being fully accomplished. It also hits the key pieces to an effective vision — it’s only 13 words, inspirational, clear, memorable, and concise. + +Mission and vision add clarity on the who, what, why, and how for your project. But, how do you set a course for getting there? + +### Goals, Objectives, Actions, and Results + + _“I don’t focus on what I’m up against. I focus on my goals and I try to ignore the rest.”_  — Venus Williams + +Looking at a mission and vision can get overwhelming, so breaking them down into smaller chunks can help the project determine how to get started. This also helps prioritize actions, either by importance or by opportunity. Most importantly, this step gives you guidance on what things to focus on for a period of time, and which to put off. + +There are lots of methods of time bound planning, but the method I think works the best for projects is what I’ve dubbed the GOAR method. It’s an acronym that stands for: + +* Goals define what the project is striving for and likely would align and support the mission. Examples might be “Grow a diverse contributor base” or “Become the leading project for X.” Goals are aspirational and set direction. + +* Objectives show how you measure a goal’s completion, and should be clear and measurable. You might also have multiple objectives to measure the completion of a goal. For example, the goal “Grow a diverse contributor base” might have objectives such as “Have X total contributors monthly” and “Have contributors representing Y different organizations.” + +* Actions are what the project plans to do to complete an objective. This is where you get tactical on exactly what needs done. For example, the objective “Have contributors representing Y different organizations” would like have actions of reaching out to interested organizations using the project, having existing contributors mentor new mentors, and providing incentives for first time contributors. + +* Results come along the way, showing progress both positive and negative from the actions. + +You can put these into a table like this: + +| Goals | Objectives | Actions | Results | +|:--|:--|:--|:--| +| Grow a diverse contributor base     | Have X total contributors monthly | Existing contributors mentor new mentors Providing incentives for first time contributors | | +| | Have contributors representing Y different organizations | Reach out to interested organizations using the project | | + + +In large organizations, monthly or quarterly goals and objectives often make sense; however, on open source projects, these time frames are unrealistic. Six- even 12-month tracking allows the project leadership to focus on driving efforts at a high level by nurturing the community along. + +The end result is a rubric that provides clear vision on where the project is going. It also lets community members more easily find ways to contribute. For example, your project may include someone who knows a few organizations using the project — this person could help introduce those developers to the codebase and guide them through their first commit. + +### What happens if the project doesn’t hit the goals? + + _“I have not failed. I’ve just found 10,000 ways that won’t work.”_  — Thomas A. Edison + +Figuring out what is within the capability of an organization — whether Fortune 500 or a small open source project — is hard. And, sometimes the expectations or market conditions change along the way. Does that make the strategy planning process a failure? Absolutely not! + +Instead, you can use this experience as a way to better understand your project’s velocity, its impact, and its community, and perhaps as a way to prioritize what is important and what’s not. + +-------------------------------------------------------------------------------- + +via: https://www.linuxfoundation.org/blog/set-open-source-strategy/ + +作者:[ John Mertic][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linuxfoundation.org/author/jmertic/ +[1]:https://en.wikipedia.org/wiki/Big_Hairy_Audacious_Goal +[2]:https://www.linuxfoundation.org/author/jmertic/ +[3]:https://www.linuxfoundation.org/category/blog/ +[4]:https://www.linuxfoundation.org/category/audience/c-level/ +[5]:https://www.linuxfoundation.org/category/audience/developer-influencers/ +[6]:https://www.linuxfoundation.org/category/audience/entrepreneurs/ +[7]:https://www.linuxfoundation.org/category/campaigns/membership/how-to/ +[8]:https://www.linuxfoundation.org/category/campaigns/events-campaigns/linux-foundation/ +[9]:https://www.linuxfoundation.org/category/audience/open-source-developers/ +[10]:https://www.linuxfoundation.org/category/audience/open-source-professionals/ +[11]:https://www.linuxfoundation.org/category/audience/open-source-users/ +[12]:https://www.linuxfoundation.org/category/blog/thought-leadership/ From 211611fe715fc2a8be9c446eecbd706652ab13f3 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 19:37:38 +0800 Subject: [PATCH 131/344] =?UTF-8?q?20171203-2=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... millions of Linux users with Snapcraft.md | 321 ++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100644 sources/tech/20171202 Easily control delivery of your Python applications to millions of Linux users with Snapcraft.md diff --git a/sources/tech/20171202 Easily control delivery of your Python applications to millions of Linux users with Snapcraft.md b/sources/tech/20171202 Easily control delivery of your Python applications to millions of Linux users with Snapcraft.md new file mode 100644 index 0000000000..dbdebf63e3 --- /dev/null +++ b/sources/tech/20171202 Easily control delivery of your Python applications to millions of Linux users with Snapcraft.md @@ -0,0 +1,321 @@ +Python +============================================================ + +Python has rich tools for packaging, distributing and sandboxing applications. Snapcraft builds on top of these familiar tools such as `pip`, `setup.py` and `requirements.txt` to create snaps for people to install on Linux. + +### What problems do snaps solve for Python applications? + +Linux install instructions for Python applications often get complicated. System dependencies, which differ from distribution to distribution, must be separately installed. To prevent modules from different Python applications clashing with each other, developer tools like `virtualenv` or `venv` must be used. With snapcraft it’s one command to produce a bundle that works anywhere. + +Here are some snap advantages that will benefit many Python projects: + +* Bundle all the runtime requirements, including the exact versions of system libraries and the Python interpreter. + +* Simplify installation instructions, regardless of distribution, to `snap install mypythonapp`. + +* Directly control the delivery of automatic application updates. + +* Extremely simple creation of daemons. + +### Getting started + +Let’s take a look at offlineimap and youtube-dl by way of examples. Both are command line applications. offlineimap uses Python 2 and only has Python module requirements. youtube-dl uses Python 3 and has system package requirements, in this case `ffmpeg`. + +### offlineimap + +Snaps are defined in a single yaml file placed in the root of your project. The offlineimap example shows the entire `snapcraft.yaml` for an existing project. We’ll break this down. + +``` +name: offlineimap +version: git +summary: OfflineIMAP +description: | + OfflineIMAP is software that downloads your email mailbox(es) as local + Maildirs. OfflineIMAP will synchronize both sides via IMAP. + +grade: devel +confinement: devmode + +apps: + offlineimap: + command: bin/offlineimap + +parts: + offlineimap: + plugin: python + python-version: python2 + source: . + +``` + +#### Metadata + +The `snapcraft.yaml` starts with a small amount of human-readable metadata, which usually can be lifted from the GitHub description or project README.md. This data is used in the presentation of your app in the Snap Store. The `summary:` can not exceed 79 characters. You can use a pipe with the `description:` to declare a multi-line description. + +``` +name: offlineimap +version: git +summary: OfflineIMAP +description: | + OfflineIMAP is software that downloads your email mailbox(es) as local + Maildirs. OfflineIMAP will synchronize both sides via IMAP. + +``` + +#### Confinement + +To get started we won’t confine this application. Unconfined applications, specified with `devmode`, can only be released to the hidden “edge” channel where you and other developers can install them. + +``` +confinement: devmode + +``` + +#### Parts + +Parts define how to build your app. Parts can be anything: programs, libraries, or other assets needed to create and run your application. In this case we have one: the offlineimap source code. In other cases these can point to local directories, remote git repositories, or tarballs. + +The Python plugin will also bundle Python in the snap, so you can be sure that the version of Python you test against is included with your app. Dependencies from `install_requires` in your `setup.py` will also be bundled. Dependencies from a `requirements.txt` file can also be bundled using the `requirements:` option. + +``` +parts: + offlineimap: + plugin: python + python-version: python2 + source: . + +``` + +#### Apps + +Apps are the commands and services exposed to end users. If your command name matches the snap `name`, users will be able run the command directly. If the names differ, then apps are prefixed with the snap `name`(`offlineimap.command-name`, for example). This is to avoid conflicting with apps defined by other installed snaps. + +If you don’t want your command prefixed you can request an alias for it on the [Snapcraft forum][1]. These command aliases are set up automatically when your snap is installed from the Snap Store. + +``` +apps: + offlineimap: + command: bin/offlineimap + +``` + +If your application is intended to run as a service, add the line `daemon: simple` after the command keyword. This will automatically keep the service running on install, update and reboot. + +### Building the snap + +You’ll first need to [install snap support][2], and then install the snapcraft tool: + +``` +sudo snap install --beta --classic snapcraft + +``` + +If you have just installed snap support, start a new shell so your `PATH` is updated to include `/snap/bin`. You can then build this example yourself: + +``` +git clone https://github.com/snapcraft-docs/offlineimap +cd offlineimap +snapcraft + +``` + +The resulting snap can be installed locally. This requires the `--dangerous` flag because the snap is not signed by the Snap Store. The `--devmode` flag acknowledges that you are installing an unconfined application: + +``` +sudo snap install offlineimap_*.snap --devmode --dangerous + +``` + +You can then try it out: + +``` +offlineimap + +``` + +Removing the snap is simple too: + +``` +sudo snap remove offlineimap + +``` + +Jump ahead to [Share with your friends][3] or continue to read another example. + +### youtube-dl + +The youtube-dl example shows a `snapcraft.yaml` using a tarball of a Python application and `ffmpeg` bundled in the snap to satisfy the runtime requirements. Here is the entire `snapcraft.yaml` for youtube-dl. We’ll break this down. + +``` +name: youtube-dl +version: 2017.06.18 +summary: YouTube Downloader. +description: | + youtube-dl is a small command-line program to download videos from + YouTube.com and a few more sites. + +grade: devel +confinement: devmode + +parts: + youtube-dl: + source: https://github.com/rg3/youtube-dl/archive/$SNAPCRAFT_PROJECT_VERSION.tar.gz + plugin: python + python-version: python3 + after: [ffmpeg] + +apps: + youtube-dl: + command: bin/youtube-dl + +``` + +#### Parts + +The `$SNAPCRAFT_PROJECT_VERSION` variable is derived from the `version:` stanza and used here to reference the matching release tarball. Because the `python` plugin is used, snapcraft will bundle a copy of Python in the snap using the version specified in the `python-version:` stanza, in this case Python 3. + +youtube-dl makes use of `ffmpeg` to transcode or otherwise convert the audio and video file it downloads. In this example, youtube-dl is told to build after the `ffmpeg` part. Because the `ffmpeg` part specifies no plugin, it will be fetched from the parts repository. This is a collection of community-contributed definitions which can be used by anyone when building a snap, saving you from needing to specify the source and build rules for each system dependency. You can use `snapcraft search` to find more parts to use and `snapcraft define ` to verify how the part is defined. + +``` +parts: + youtube-dl: + source: https://github.com/rg3/youtube-dl/archive/$SNAPCRAFT_PROJECT_VERSION.tar.gz + plugin: python + python-version: python3 + after: [ffmpeg] + +``` + +### Building the snap + +You can build this example yourself by running the following: + +``` +git clone https://github.com/snapcraft-docs/youtube-dl +cd youtube-dl +snapcraft + +``` + +The resulting snap can be installed locally. This requires the `--dangerous` flag because the snap is not signed by the Snap Store. The `--devmode` flag acknowledges that you are installing an unconfined application: + +``` +sudo snap install youtube-dl_*.snap --devmode --dangerous + +``` + +Run the command: + +``` +youtube-dl “https://www.youtube.com/watch?v=k-laAxucmEQ” + +``` + +Removing the snap is simple too: + +``` +sudo snap remove youtube-dl + +``` + +### Share with your friends + +To share your snaps you need to publish them in the Snap Store. First, create an account on [the dashboard][4]. Here you can customize how your snaps are presented, review your uploads and control publishing. + +You’ll need to choose a unique “developer namespace” as part of the account creation process. This name will be visible by users and associated with your published snaps. + +Make sure the `snapcraft` command is authenticated using the email address attached to your Snap Store account: + +``` +snapcraft login + +``` + +### Reserve a name for your snap + +You can publish your own version of a snap, provided you do so under a name you have rights to. + +``` +snapcraft register mypythonsnap + +``` + +Be sure to update the `name:` in your `snapcraft.yaml` to match this registered name, then run `snapcraft` again. + +### Upload your snap + +Use snapcraft to push the snap to the Snap Store. + +``` +snapcraft push --release=edge mypthonsnap_*.snap + +``` + +If you’re happy with the result, you can commit the snapcraft.yaml to your GitHub repo and [turn on automatic builds][5] so any further commits automatically get released to edge, without requiring you to manually build locally. + +### Further customisations + +Here are all the Python plugin-specific keywords: + +``` +- requirements: + (string) + Path to a requirements.txt file +- constraints: + (string) + Path to a constraints file +- process-dependency-links: + (bool; default: false) + Enable the processing of dependency links in pip, which allow one project + to provide places to look for another project +- python-packages: + (list) + A list of dependencies to get from PyPI +- python-version: + (string; default: python3) + The python version to use. Valid options are: python2 and python3 + +``` + +You can view them locally by running: + +``` +snapcraft help python + +``` + +### Extending and overriding behaviour + +You can [extend the behaviour][6] of any part in your `snapcraft.yaml` with shell commands. These can be run after pulling the source code but before building by using the `prepare` keyword. The build process can be overridden entirely using the `build` keyword and shell commands. The `install` keyword is used to run shell commands after building your code, useful for making post build modifications such as relocating build assets. + +Using the youtube-dl example above, we can run the test suite at the end of the build. If this fails, the snap creation will be terminated: + +``` +parts: + youtube-dl: + source: https://github.com/rg3/youtube-dl/archive/$SNAPCRAFT_PROJECT_VERSION.tar.gz + plugin: python + python-version: python3 + stage-packages: [ffmpeg, python-nose] + install: | + nosetests +``` + +-------------------------------------------------------------------------------- + +via: https://docs.snapcraft.io/build-snaps/python + +作者:[Snapcraft.io ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:Snapcraft.io + +[1]:https://forum.snapcraft.io/t/process-for-reviewing-aliases-auto-connections-and-track-requests/455 +[2]:https://docs.snapcraft.io/core/install +[3]:https://docs.snapcraft.io/build-snaps/python#share-with-your-friends +[4]:https://dashboard.snapcraft.io/openid/login/?next=/dev/snaps/ +[5]:https://build.snapcraft.io/ +[6]:https://docs.snapcraft.io/build-snaps/scriptlets From 19d8719beca49784f5ea274284de3cbbc0c7b6e5 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 19:39:25 +0800 Subject: [PATCH 132/344] =?UTF-8?q?20171203-3=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0171202 docker - Use multi-stage builds.md | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 sources/tech/20171202 docker - Use multi-stage builds.md diff --git a/sources/tech/20171202 docker - Use multi-stage builds.md b/sources/tech/20171202 docker - Use multi-stage builds.md new file mode 100644 index 0000000000..e1a6414862 --- /dev/null +++ b/sources/tech/20171202 docker - Use multi-stage builds.md @@ -0,0 +1,127 @@ +Use multi-stage builds +============================================================ + +Multi-stage builds are a new feature requiring Docker 17.05 or higher on the daemon and client. Multistage builds are useful to anyone who has struggled to optimize Dockerfiles while keeping them easy to read and maintain. + +> Acknowledgment: Special thanks to [Alex Ellis][1] for granting permission to use his blog post [Builder pattern vs. Multi-stage builds in Docker][2] as the basis of the examples below. + +### Before multi-stage builds + +One of the most challenging things about building images is keeping the image size down. Each instruction in the Dockerfile adds a layer to the image, and you need to remember to clean up any artifacts you don’t need before moving on to the next layer. To write a really efficient Dockerfile, you have traditionally needed to employ shell tricks and other logic to keep the layers as small as possible and to ensure that each layer has the artifacts it needs from the previous layer and nothing else. + +It was actually very common to have one Dockerfile to use for development (which contained everything needed to build your application), and a slimmed-down one to use for production, which only contained your application and exactly what was needed to run it. This has been referred to as the “builder pattern”. Maintaining two Dockerfiles is not ideal. + +Here’s an example of a `Dockerfile.build` and `Dockerfile` which adhere to the builder pattern above: + +`Dockerfile.build`: + +``` +FROM golang:1.7.3 +WORKDIR /go/src/github.com/alexellis/href-counter/ +RUN go get -d -v golang.org/x/net/html +COPY app.go . +RUN go get -d -v golang.org/x/net/html \ + && CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . + +``` + +Notice that this example also artificially compresses two `RUN` commands together using the Bash `&&` operator, to avoid creating an additional layer in the image. This is failure-prone and hard to maintain. It’s easy to insert another command and forget to continue the line using the `\` character, for example. + +`Dockerfile`: + +``` +FROM alpine:latest +RUN apk --no-cache add ca-certificates +WORKDIR /root/ +COPY app . +CMD ["./app"] + +``` + +`build.sh`: + +``` +#!/bin/sh +echo Building alexellis2/href-counter:build + +docker build --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy \ + -t alexellis2/href-counter:build . -f Dockerfile.build + +docker create --name extract alexellis2/href-counter:build +docker cp extract:/go/src/github.com/alexellis/href-counter/app ./app +docker rm -f extract + +echo Building alexellis2/href-counter:latest + +docker build --no-cache -t alexellis2/href-counter:latest . +rm ./app + +``` + +When you run the `build.sh` script, it needs to build the first image, create a container from it in order to copy the artifact out, then build the second image. Both images take up room on your system and you still have the `app` artifact on your local disk as well. + +Multi-stage builds vastly simplify this situation! + +### Use multi-stage builds + +With multi-stage builds, you use multiple `FROM` statements in your Dockerfile. Each `FROM` instruction can use a different base, and each of them begins a new stage of the build. You can selectively copy artifacts from one stage to another, leaving behind everything you don’t want in the final image. To show how this works, Let’s adapt the Dockerfile from the previous section to use multi-stage builds. + +`Dockerfile`: + +``` +FROM golang:1.7.3 +WORKDIR /go/src/github.com/alexellis/href-counter/ +RUN go get -d -v golang.org/x/net/html +COPY app.go . +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . + +FROM alpine:latest +RUN apk --no-cache add ca-certificates +WORKDIR /root/ +COPY --from=0 /go/src/github.com/alexellis/href-counter/app . +CMD ["./app"] + +``` + +You only need the single Dockerfile. You don’t need a separate build script, either. Just run `docker build`. + +``` +$ docker build -t alexellis2/href-counter:latest . + +``` + +The end result is the same tiny production image as before, with a significant reduction in complexity. You don’t need to create any intermediate images and you don’t need to extract any artifacts to your local system at all. + +How does it work? The second `FROM` instruction starts a new build stage with the `alpine:latest` image as its base. The `COPY --from=0` line copies just the built artifact from the previous stage into this new stage. The Go SDK and any intermediate artifacts are left behind, and not saved in the final image. + +### Name your build stages + +By default, the stages are not named, and you refer to them by their integer number, starting with 0 for the first `FROM` instruction. However, you can name your stages, by adding an `as ` to the `FROM` instruction. This example improves the previous one by naming the stages and using the name in the `COPY` instruction. This means that even if the instructions in your Dockerfile are re-ordered later, the `COPY` won’t break. + +``` +FROM golang:1.7.3 as builder +WORKDIR /go/src/github.com/alexellis/href-counter/ +RUN go get -d -v golang.org/x/net/html +COPY app.go . +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . + +FROM alpine:latest +RUN apk --no-cache add ca-certificates +WORKDIR /root/ +COPY --from=builder /go/src/github.com/alexellis/href-counter/app . +CMD ["./app"] +``` + +-------------------------------------------------------------------------------- + +via: https://docs.docker.com/engine/userguide/eng-image/multistage-build/#name-your-build-stages + +作者:[docker docs ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://docs.docker.com/engine/userguide/eng-image/multistage-build/ +[1]:https://twitter.com/alexellisuk +[2]:http://blog.alexellis.io/mutli-stage-docker-builds/ From 2f7336de974417f614a8ee8dd5bd12d29b491f2c Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 19:43:14 +0800 Subject: [PATCH 133/344] =?UTF-8?q?20171203-4=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...LEAST PRIVILEGE CONTAINER ORCHESTRATION.md | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 sources/tech/20171011 LEAST PRIVILEGE CONTAINER ORCHESTRATION.md diff --git a/sources/tech/20171011 LEAST PRIVILEGE CONTAINER ORCHESTRATION.md b/sources/tech/20171011 LEAST PRIVILEGE CONTAINER ORCHESTRATION.md new file mode 100644 index 0000000000..7a9b6e817c --- /dev/null +++ b/sources/tech/20171011 LEAST PRIVILEGE CONTAINER ORCHESTRATION.md @@ -0,0 +1,174 @@ +# LEAST PRIVILEGE CONTAINER ORCHESTRATION + + +The Docker platform and the container has become the standard for packaging, deploying, and managing applications. In order to coordinate running containers across multiple nodes in a cluster, a key capability is required: a container orchestrator. + +![container orchestrator](https://i0.wp.com/blog.docker.com/wp-content/uploads/f753d4e8-9e22-4fe2-be9a-80661ef696a8-3.jpg?resize=536%2C312&ssl=1) + +Orchestrators are responsible for critical clustering and scheduling tasks, such as: + +* Managing container scheduling and resource allocation. + +* Support service discovery and hitless application deploys. + +* Distribute the necessary resources that applications need to run. + +Unfortunately, the distributed nature of orchestrators and the ephemeral nature of resources in this environment makes securing orchestrators a challenging task. In this post, we will describe in detail the less-considered—yet vital—aspect of the security model of container orchestrators, and how Docker Enterprise Edition with its built-in orchestration capability, Swarm mode, overcomes these difficulties. + +Motivation and threat model +============================================================ + +One of the primary objectives of Docker EE with swarm mode is to provide an orchestrator with security built-in. To achieve this goal, we developed the first container orchestrator designed with the principle of least privilege in mind. + +In computer science,the principle of least privilege in a distributed system requires that each participant of the system must only have access to  the information and resources that are necessary for its legitimate purpose. No more, no less. + +> #### ”A process must be able to access only the information and resources that are necessary for its legitimate purpose.” + +#### Principle of Least Privilege + +Each node in a Docker EE swarm is assigned role: either manager or worker. These roles define a coarsegrained level of privilege to the nodes: administration and task execution, respectively. However, regardless of its role, a node has access only to the information and resources it needs to perform the necessary tasks, with cryptographically enforced guarantees. As a result, it becomes easier to secure clusters against even the most sophisticated attacker models: attackers that control the underlying communication networks or even compromised cluster nodes. + +# Secure-by-default core + +There is an old security maxim that states: if it doesn’t come by default, no one will use it. Docker Swarm mode takes this notion to heart, and ships with secure-by-default mechanisms to solve three of the hardest and most important aspects of the orchestration lifecycle: + +1. Trust bootstrap and node introduction. + +2. Node identity issuance and management. + +3. Authenticated, Authorized, Encrypted information storage and dissemination. + +Let’s look at each of these aspects individually + +### Trust Bootstrap and Node Introduction + +The first step to a secure cluster is tight control over membership and identity. Without it, administrators cannot rely on the identities of their nodes and enforce strict workload separation between nodes. This means that unauthorized nodes can’t be allowed to join the cluster, and nodes that are already part of the cluster aren’t able to change identities, suddenly pretending to be another node. + +To address this need, nodes managed by Docker EE’s Swarm mode maintain strong, immutable identities. The desired properties are cryptographically guaranteed by using two key building-blocks: + +1. Secure join tokens for cluster membership. + +2. Unique identities embedded in certificates issued from a central certificate authority. + +### Joining the Swarm + +To join the swarm, a node needs a copy of a secure join token. The token is unique to each operational role within the cluster—there are currently two types of nodes: workers and managers. Due to this separation, a node with a copy of a worker token will not be allowed to join the cluster as a manager. The only way to get this special token is for a cluster administrator to interactively request it from the cluster’s manager through the swarm administration API. + +The token is securely and randomly generated, but it also has a special syntax that makes leaks of this token easier to detect: a special prefix that you can easily monitor for in your logs and repositories. Fortunately, even if a leak does occur, tokens are easy to rotate, and we recommend that you rotate them often—particularly in the case where your cluster will not be scaling up for a while. + +![Docker Swarm](https://i1.wp.com/blog.docker.com/wp-content/uploads/92d171d4-52c7-4702-8143-110c6f52017c-2.jpg?resize=547%2C208&ssl=1) + +### Bootstrapping trust + +As part of establishing its identity, a new node will ask for a new identity to be issued by any of the network managers. However, under our threat model, all communications can be intercepted by a third-party. This begs the question: how does a node know that it is talking to a legitimate manager? + +![Docker Security](https://i0.wp.com/blog.docker.com/wp-content/uploads/94e3fef0-5bd2-4970-b9e9-25b566d926ad-2.jpg?resize=528%2C348&ssl=1) + +Fortunately, Docker has a built-in mechanism for preventing this from happening. The join token, which the host uses to join the swarm, includes a hash of the root CA’s certificate. The host can therefore use one-way TLS and use the hash to verify that it’s joining the right swarm: if the manager presents a certificate not signed by a CA that matches the hash, the node knows not to trust it. + +### Node identity issuance and management + +Identities in a swarm are embedded in x509 certificates held by each individual node. In a manifestation of the least privilege principle, the certificates’ private keys are restricted strictly to the hosts where they originate. In particular, managers do not have access to private keys of any certificate but their own. + +### Identity Issuance + +To receive their certificates without sharing their private keys, new hosts begin by issuing a certificate signing request (CSR), which the managers then convert into a certificate. This certificate now becomes the new host’s identity, making the node a full-fledged member of the swarm! + +#### +![](https://i0.wp.com/blog.docker.com/wp-content/uploads/415ae6cf-7e76-4ba8-9d84-6d49bf327d8f-2.jpg?resize=548%2C350&ssl=1) + +When used alongside with the secure bootstrapping mechanism, this mechanism for issuing identities to joining nodes is secure by default: all communicating parties are authenticated, authorized and no sensitive information is ever exchanged in clear-text. + +### Identity Renewal + +However, securely joining nodes to a swarm is only part of the story. To minimize the impact of leaked or stolen certificates and to remove the complexity of managing CRL lists, Swarm mode uses short-lived certificates for the identities. These certificates have a default expiration of three months, but can be configured to expire every hour! + +![Docker secrets](https://i0.wp.com/blog.docker.com/wp-content/uploads/55e2ab9a-19cd-465d-82c6-fa76110e7ecd-2.jpg?resize=556%2C365&ssl=1) + +This short certificate expiration time means that certificate rotation can’t be a manual process, as it usually is for most PKI systems. With swarm, all certificates are rotated automatically and in a hitless fashion. The process is simple: using a mutually authenticated TLS connection to prove ownership over a particular identity, a Swarm node generates regularly a new public/private key pair and sends the corresponding CSR to be signed, creating a completely new certificate, but maintaining the same identity. + +### Authenticated, Authorized, Encrypted information storage and dissemination. + +During the normal operation of a swarm, information about the tasks has to be sent to the worker nodes for execution. This includes not only information on which containers are to be executed by a node;but also, it includes  all the resources that are necessary for the successful execution of that container, including sensitive secrets such as private keys, passwords, and API tokens. + +### Transport Security + +The fact that every node participating in a swarm is in possession of a unique identity in the form of a X509 certificate, communicating securely between nodes is trivial: nodes can use their respective certificates to establish mutually authenticated connections between one another, inheriting the confidentiality, authenticity and integrity properties of TLS. + +![Swarm Mode](https://i0.wp.com/blog.docker.com/wp-content/uploads/972273a3-d9e5-4053-8fcb-a407c8cdcbf6-2.jpg?resize=347%2C271&ssl=1) + +One interesting detail about Swarm mode is the fact that it uses a push model: only managers are allowed to send information to workers—significantly reducing the surface of attack manager nodes expose to the less privileged worker nodes. + +### Strict Workload Separation Into Security Zones + +One of the responsibilities of manager nodes is deciding which tasks to send to each of the workers. Managers make this determination using a variety of strategies; scheduling the workloads across the swarm depending on both the unique properties of each node and each workload. + +In Docker EE with Swarm mode, administrators have the ability of influencing these scheduling decisions by using labels that are securely attached to the individual node identities. These labels allow administrators to group nodes together into different security zones limiting the exposure of particularly sensitive workloads and any secrets related to them. + +![Docker Swarm Security](https://i0.wp.com/blog.docker.com/wp-content/uploads/67ffa551-d4ae-4522-ba13-4a646a158592-2.jpg?resize=546%2C375&ssl=1) + +### Secure Secret Distribution + +In addition to facilitating the identity issuance process, manager nodes have the important task of storing and distributing any resources needed by a worker. Secrets are treated like any other type of resource, and are pushed down from the manager to the worker over the secure mTLS connection. + +![Docker Secrets](https://i1.wp.com/blog.docker.com/wp-content/uploads/4341da98-2f8c-4aed-bb40-607246344dd8-2.jpg?resize=508%2C326&ssl=1) + +On the hosts, Docker EE ensures that secrets are provided only to the containers they are destined for. Other containers on the same host will not have access to them. Docker exposes secrets to a container as a temporary file system, ensuring that secrets are always stored in memory and never written to disk. This method is more secure than competing alternatives, such as [storing them in environment variables][12]. Once a task completes the secret is gone forever. + +### Storing secrets + +On manager hosts secrets are always encrypted at rest. By default, the key that encrypts these secrets (known as the Data Encryption Key, DEK) is also stored in plaintext on disk. This makes it easy for those with minimal security requirements to start using Docker Swarm mode. + +However, once you are running a production cluster, we recommend you enable auto-lock mode. When auto-lock mode is enabled, a newly rotated DEK is encrypted with a separate Key Encryption Key (KEK). This key is never stored on the cluster; the administrator is responsible for storing it securely and providing it when the cluster starts up. This is known as unlocking the swarm. + +Swarm mode supports multiple managers, relying on the Raft Consensus Algorithm for fault tolerance. Secure secret storage scales seamlessly in this scenario. Each manager host has a unique disk encryption key, in addition to the shared key. Furthermore, Raft logs are encrypted on disk and are similarly unavailable without the KEK when in autolock mode. + +### What happens when a node is compromised? + +![Docker Secrets](https://i0.wp.com/blog.docker.com/wp-content/uploads/2a78b37d-bbf0-40ee-a282-eb0900f71ba9-2.jpg?resize=502%2C303&ssl=1) + +In traditional orchestrators, recovering from a compromised host is a slow and complicated process. With Swarm mode, recovery is as easy as running the docker node rm command. This removes the affected node from the cluster, and Docker will take care of the rest, namely re-balancing services and making sure other hosts know not to talk to the affected node. + +As we have seen, thanks to least privilege orchestration, even if the attacker were still active on the host, they would be cut off from the rest of the network. The host’s certificate — its identity — is blacklisted, so the managers will not accept it as valid. + +# Conclusion + +Docker EE with Swarm mode ensures security by default in all key areas of orchestration: + +* Joining the cluster. Prevents malicious nodes from joining the cluster. + +* Organizing hosts into security zones. Prevents lateral movement by attackers. + +* Scheduling tasks. Tasks will be issued only to designated and allowed nodes. + +* Allocating resources. A malicious node cannot “steal” another’s workload or resources. + +* Storing secrets. Never stored in plaintext and never written to disk on worker nodes. + +* Communicating with the workers. Encrypted using mutually authenticated TLS. + +As Swarm mode continues to improve, the Docker team is working to take the principle of least privilege orchestration even further. The task we are tackling is: how can systems remain secure if a manager is compromised? The roadmap is in place, with some of the features already available such as the ability of whitelisting only specific Docker images, preventing managers from executing arbitrary workloads. This is achieved quite naturally using Docker Content Trust. + +-------------------------------------------------------------------------------- + +via: https://blog.docker.com/2017/10/least-privilege-container-orchestration/ + +作者:[Diogo Mónica ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://blog.docker.com/author/diogo/ +[1]:http://www.linkedin.com/shareArticle?mini=true&url=http://dockr.ly/2yZoNdy&title=Least%20Privilege%20Container%20Orchestration&summary=The%20Docker%20platform%20and%20the%20container%20has%20become%20the%20standard%20for%20packaging,%20deploying,%20and%20managing%20applications.%20In%20order%20to%20coordinate%20running%20containers%20across%20multiple%20nodes%20in%20a%20cluster,%20a%20key%20capability%20is%20required:%20a%20container%20orchestrator.Orchestrators%20are%20responsible%20for%20critical%20clustering%20and%20scheduling%20tasks,%20such%20as:%20%20%20%20Managing%20... +[2]:http://www.reddit.com/submit?url=http://dockr.ly/2yZoNdy&title=Least%20Privilege%20Container%20Orchestration +[3]:https://plus.google.com/share?url=http://dockr.ly/2yZoNdy +[4]:http://news.ycombinator.com/submitlink?u=http://dockr.ly/2yZoNdy&t=Least%20Privilege%20Container%20Orchestration +[5]:https://blog.docker.com/author/diogo/ +[6]:https://blog.docker.com/tag/docker-orchestration/ +[7]:https://blog.docker.com/tag/docker-secrets/ +[8]:https://blog.docker.com/tag/docker-security/ +[9]:https://blog.docker.com/tag/docker-swarm/ +[10]:https://blog.docker.com/tag/least-privilege-orchestrator/ +[11]:https://blog.docker.com/tag/tls/ +[12]:https://diogomonica.com/2017/03/27/why-you-shouldnt-use-env-variables-for-secret-data/ From 7a50e85d810122ffdfa095b4d373c2a4cbe38618 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 19:44:32 +0800 Subject: [PATCH 134/344] =?UTF-8?q?20171203-5=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Could Be Your New Favorite Container OS.md | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md diff --git a/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md new file mode 100644 index 0000000000..d282ef5445 --- /dev/null +++ b/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md @@ -0,0 +1,146 @@ +Photon Could Be Your New Favorite Container OS +============================================================ + +![Photon OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon-linux.jpg?itok=jUFHPR_c "Photon OS") +Jack Wallen says Photon OS is an outstanding platform, geared specifically for containers.[Creative Commons Zero][5]Pixabay + +Containers are all the rage, and with good reason. [As discussed previously][13], containers allow you to quickly and easily deploy new services and applications onto your network, without requiring too much in the way of added system resources. Containers are more cost-effective than using dedicated hardware or virtual machines, and they’re easier to update and reuse. + +Best of all, containers love Linux (and vice versa). Without much trouble or time, you can get a Linux server up and running with [Docker][14] and deploying containers. But, which Linux distribution is best suited for the deployment of your containers? There are a _lot_  of options. You could go with a standard Ubuntu Server platform (which makes installing Docker and deploying containers incredibly easy), or you could opt for a lighter weight distribution — one geared specifically for the purpose of deploying containers. + +One such distribution is [Photon][15]. This particular platform was created in 2005 by [VMware][16]; it includes the Docker daemon and works with container frameworks, such as Mesos and Kubernetes. Photon is optimized to work with [VMware vSphere][17], but it can be used on bare metal, [Microsoft Azure][18], [Google Compute Engine][19], [Amazon Elastic Compute Cloud][20], or [VirtualBox][21]. + +Photon manages to stay slim by only installing what is absolutely necessary to run the Docker daemon. In the end, the distribution comes in around 300 MB. This is just enough Linux make it all work. The key features to Photon are: + +* Kernel tuned for performance. + +* Kernel is hardened according to the [Kernel Self-Protection Project][6] (KSPP). + +* All installed packages are built with hardened security flags. + +* Operating system boots with validated trust. + +* Photon management daemon manages firewall, network, packages, and users on remote Photon OS machines. + +* Support for persistent volumes. + +* [Project Lightwave][7] integration. + +* Timely security patches and updates. + +Photon can be used via [ISO][22], [OVA][23], [Amazon Machine Image][24], [Google Compute Engine image][25], and [Azure VHD][26]. I’ll show you how to install Photon on VirtualBox, using an ISO image. The installation takes about five minutes and, in the end, you’ll have a virtual machine, ready to deploy containers. + +### Creating the virtual machine + +Before you deploy that first container, you have to create the virtual machine and install Photon. To do this, open up VirtualBox and click the New button. Walk through the Create Virtual Machine wizard (giving Photon the necessary resources, based on the usage you predict the container server will need). Once you’ve created the virtual machine, you need to first make a change to the settings. Select the newly created virtual machine (in the left pane of the VirtualBox main window) and then click Settings. In the resulting window, click on Network (from the left navigation). + +In the Networking window (Figure 1), you need to change the Attached to drop-down to Bridged Adapter. This will ensure your Photon server is reachable from your network. Once you’ve made that change, click OK. + +### [photon_0.jpg][8] + +![change settings](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_0.jpg?itok=Q0yhOhsZ "change settings") +Figure 1: Changing the VirtualBox network settings for Photon.[Used with permission][1] + +Select your Photon virtual machine from the left navigation and then click Start. You will be prompted to locate and attach the IOS image. Once you’ve done that, Photon will boot up and prompt you to hit Enter to begin the installation. The installation is ncurses based (there is no GUI), but it’s incredibly simple. + +In the next screen (Figure 2), you will be asked if you want to do a Minimal, Full, or OSTree Server. I opted to go the Full route. Select whichever option you require and hit enter. + +### [photon_1.jpg][9] + +![installation type](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_1.jpg?itok=OdnMVpaA "installation type") +Figure 2: Selecting your installation type.[Used with permission][2] + +In the next window, select the disk that will house Photon. Since we’re installing this as a virtual machine, there will be only one disk listed (Figure 3). Tab down to Auto and hit Enter on your keyboard. The installation will then require you to type (and verify) an administrator password. Once you’ve done that, the installation will begin and finish in less than five minutes. + +### [photon_2.jpg][10] + +![Photon ](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_2.jpg?itok=QL1Rs-PH "Photon") +Figure 3: Selecting your hard disk for the Photon installation.[Used with permission][3] + +Once the installation completes, reboot the virtual machine and log in with the username root and the password you created during installation. You are ready to start working. + +Before you begin using Docker on Photon, you’ll want to upgrade the platform. Photon uses the _yum_ package manager, so login as root and issue the command  _yum update_ .If there are any updates available, you’ll be asked to okay the process (Figure 4). + +### [photon_3.jpg][11] + +![Updating](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_3.jpg?itok=vjqrspE2 "Updating") +Figure 4: Updating Photon.[Used with permission][4] + +Usage + +As I mentioned, Photon comes with everything you need to deploy containers or even create a Kubernetes cluster. However, out of the box, there are a few things you’ll need to do. The first thing is to enable the Docker daemon to run at start. To do this, issue the commands: + +``` +systemctl start docker + +systemctl enable docker +``` + +Now we need to create a standard user, so we’re not running the docker command as root. To do this, issue the following commands: + +``` +useradd -m USERNAME + +passwd USERNAME +``` + +Where USERNAME is the name of the user to add. + +Next we need to add the new user to the  _docker_ group with the command: + +``` +usermod -a -G docker USERNAME +``` + +Where USERNAME is the name of the user just created. + +Log out as the root user and log back in as the newly created user. You can now work with the  _docker _ command without having to make use of  _sudo_  or switching to the root user. Pull down an image from Docker Hub and start deploying containers. + +### An outstanding container platform + +Photon is, without a doubt, an outstanding platform, geared specifically for containers. Do note that Photon is an open source project, so there is no paid support to be had. If you find yourself having trouble with Photon, hop on over to the [Issues tab in the Photon Project’s Github page][27], where you can read and post about issues. And if you’re interested in forking Photon, you’ll find the source code on the project’s [official Github page][28]. + +Give Photon a try and see if it doesn’t make deploying Docker containers and/or Kubernetes clusters significantly easier. + + _Learn more about Linux through the free ["Introduction to Linux" ][29]course from The Linux Foundation and edX._ + +-------------------------------------------------------------------------------- + +via: 网址 + +作者:[ JACK WALLEN][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/jlwallen +[1]:https://www.linux.com/licenses/category/used-permission +[2]:https://www.linux.com/licenses/category/used-permission +[3]:https://www.linux.com/licenses/category/used-permission +[4]:https://www.linux.com/licenses/category/used-permission +[5]:https://www.linux.com/licenses/category/creative-commons-zero +[6]:https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project +[7]:http://vmware.github.io/lightwave/ +[8]:https://www.linux.com/files/images/photon0jpg +[9]:https://www.linux.com/files/images/photon1jpg +[10]:https://www.linux.com/files/images/photon2jpg +[11]:https://www.linux.com/files/images/photon3jpg +[12]:https://www.linux.com/files/images/photon-linuxjpg +[13]:https://www.linux.com/learn/intro-to-linux/2017/11/how-install-and-use-docker-linux +[14]:https://www.docker.com/ +[15]:https://vmware.github.io/photon/ +[16]:https://www.vmware.com/ +[17]:https://www.vmware.com/products/vsphere.html +[18]:https://azure.microsoft.com/ +[19]:https://cloud.google.com/compute/ +[20]:https://aws.amazon.com/ec2/ +[21]:https://www.virtualbox.org/ +[22]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[23]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[24]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[25]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[26]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[27]:https://github.com/vmware/photon/issues +[28]:https://github.com/vmware/photon +[29]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From 760de503c0e165082a9e1c2af1ec8020f6e545af Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 19:47:46 +0800 Subject: [PATCH 135/344] =?UTF-8?q?20171203-7=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...n Source Components Ease Learning Curve.md | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 sources/tech/20171129 Inside AGL Familiar Open Source Components Ease Learning Curve.md diff --git a/sources/tech/20171129 Inside AGL Familiar Open Source Components Ease Learning Curve.md b/sources/tech/20171129 Inside AGL Familiar Open Source Components Ease Learning Curve.md new file mode 100644 index 0000000000..9eee39888a --- /dev/null +++ b/sources/tech/20171129 Inside AGL Familiar Open Source Components Ease Learning Curve.md @@ -0,0 +1,70 @@ +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 From 18758b44a858c0c320540410c9fc207bde553316 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 19:52:21 +0800 Subject: [PATCH 136/344] =?UTF-8?q?20171203-9=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...obs Are Hot Get Trained and Get Noticed.md | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 sources/tech/20171115 Security Jobs Are Hot Get Trained and Get Noticed.md diff --git a/sources/tech/20171115 Security Jobs Are Hot Get Trained and Get Noticed.md b/sources/tech/20171115 Security Jobs Are Hot Get Trained and Get Noticed.md new file mode 100644 index 0000000000..a0a6b1ed60 --- /dev/null +++ b/sources/tech/20171115 Security Jobs Are Hot Get Trained and Get Noticed.md @@ -0,0 +1,58 @@ +Security Jobs Are Hot: Get Trained and Get Noticed +============================================================ + +![security skills](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/security-skills.png?itok=IrwppCUw "security skills") +The Open Source Jobs Report, from Dice and The Linux Foundation, found that professionals with security experience are in high demand for the future.[Used with permission][1] + +The demand for security professionals is real. On [Dice.com][4], 15 percent of the more than 75K jobs are security positions. “Every year in the U.S., 40,000 jobs for information security analysts go unfilled, and employers are struggling to fill 200,000 other cyber-security related roles, according to cyber security data tool [CyberSeek][5]” ([Forbes][6]). We know that there is a fast-increasing need for security specialists, but that the interest level is low. + +### Security is the place to be + +In my experience, few students coming out of college are interested in roles in security; so many people see security as niche. Entry-level tech pros are interested in business analyst or system analyst roles, because of a belief that if you want to learn and apply core IT concepts, you have to stick to analyst roles or those closer to product development. That’s simply not the case. + +In fact, if you’re interested in getting in front of your business leaders, security is the place to be – as a security professional, you have to understand the business end-to-end; you have to look at the big picture to give your company the advantage. + +### Be fearless + +Analyst and security roles are not all that different. Companies continue to merge engineering and security roles out of necessity. Businesses are moving faster than ever with infrastructure and code being deployed through automation, which increases the importance of security being a part of all tech pros day to day lives. In our [Open Source Jobs Report with The Linux Foundation][7], 42 percent of hiring managers said professionals with security experience are in high demand for the future. + +There has never been a more exciting time to be in security. If you stay up-to-date with tech news, you’ll see that a huge number of stories are related to security – data breaches, system failures and fraud. The security teams are working in ever-changing, fast-paced environments. A real challenge lies is in the proactive side of security, finding, and eliminating vulnerabilities while maintaining or even improving the end-user experience.   + +### Growth is imminent + +Of any aspect of tech, security is the one that will continue to grow with the cloud. Businesses are moving more and more to the cloud and that’s exposing more security vulnerabilities than organizations are used to. As the cloud matures, security becomes increasingly important.            + +Regulations are also growing – Personally Identifiable Information (PII) is getting broader all the time. Many companies are finding that they must invest in security to stay in compliance and avoid being in the headlines. Companies are beginning to budget more and more for security tooling and staffing due to the risk of heavy fines, reputational damage, and, to be honest, executive job security.   + +### Training and support + +Even if you don’t choose a security-specific role, you’re bound to find yourself needing to code securely, and if you don’t have the skills to do that, you’ll start fighting an uphill battle. There are certainly ways to learn on-the-job if your company offers that option, that’s encouraged but I recommend a combination of training, mentorship and constant practice. Without using your security skills, you’ll lose them fast with how quickly the complexity of malicious attacks evolve. + +My recommendation for those seeking security roles is to find the people in your organization that are the strongest in engineering, development, or architecture areas – interface with them and other teams, do hands-on work, and be sure to keep the big-picture in mind. Be an asset to your organization that stands out – someone that can securely code and also consider strategy and overall infrastructure health. + +### The end game + +More and more companies are investing in security and trying to fill open roles in their tech teams. If you’re interested in management, security is the place to be. Executive leadership wants to know that their company is playing by the rules, that their data is secure, and that they’re safe from breaches and loss. + +Security that is implemented wisely and with strategy in mind will get noticed. Security is paramount for executives and consumers alike – I’d encourage anyone interested in security to train up and contribute. + + _[Download ][2]the full 2017 Open Source Jobs Report now._ + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/os-jobs-report/2017/11/security-jobs-are-hot-get-trained-and-get-noticed + +作者:[ BEN COLLEN][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/bencollen +[1]:https://www.linux.com/licenses/category/used-permission +[2]:http://bit.ly/2017OSSjobsreport +[3]:https://www.linux.com/files/images/security-skillspng +[4]:http://www.dice.com/ +[5]:http://cyberseek.org/index.html#about +[6]:https://www.forbes.com/sites/jeffkauflin/2017/03/16/the-fast-growing-job-with-a-huge-skills-gap-cyber-security/#292f0a675163 +[7]:http://media.dice.com/report/the-2017-open-source-jobs-report-employers-prioritize-hiring-open-source-professionals-with-latest-skills/ From 2a09e5ac1d0a54bdb62e688b7f23408d594fffc6 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 19:54:43 +0800 Subject: [PATCH 137/344] =?UTF-8?q?20171203-10=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...9 INTRODUCING DOCKER SECRETS MANAGEMENT.md | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 sources/tech/20170209 INTRODUCING DOCKER SECRETS MANAGEMENT.md diff --git a/sources/tech/20170209 INTRODUCING DOCKER SECRETS MANAGEMENT.md b/sources/tech/20170209 INTRODUCING DOCKER SECRETS MANAGEMENT.md new file mode 100644 index 0000000000..a3fc2c886e --- /dev/null +++ b/sources/tech/20170209 INTRODUCING DOCKER SECRETS MANAGEMENT.md @@ -0,0 +1,110 @@ +INTRODUCING DOCKER SECRETS MANAGEMENT +============================================================ + +Containers are changing how we view apps and infrastructure. Whether the code inside containers is big or small, container architecture introduces a change to how that code behaves with hardware – it fundamentally abstracts it from the infrastructure. Docker believes that there are three key components to container security and together they result in inherently safer apps. + + ![Docker Security](https://i2.wp.com/blog.docker.com/wp-content/uploads/e12387a1-ab21-4942-8760-5b1677bc656d-1.jpg?w=1140&ssl=1) + +A critical element of building safer apps is having a secure way of communicating with other apps and systems, something that often requires credentials, tokens, passwords and other types of confidential information—usually referred to as application secrets. We are excited to introduce Docker Secrets, a container native solution that strengthens the Trusted Delivery component of container security by integrating secret distribution directly into the container platform. + +With containers, applications are now dynamic and portable across multiple environments. This  made existing secrets distribution solutions inadequate because they were largely designed for static environments. Unfortunately, this led to an increase in mismanagement of application secrets, making it common to find insecure, home-grown solutions, such as embedding secrets into version control systems like GitHub, or other equally bad—bolted on point solutions as an afterthought. + +### Introducing Docker Secrets Management + +We fundamentally believe that apps are safer if there is a standardized interface for accessing secrets. Any good solution will also have to follow security best practices, such as encrypting secrets while in transit; encrypting secrets at rest; preventing secrets from unintentionally leaking when consumed by the final application; and strictly adhere to the principle of least-privilege, where an application only has access to the secrets that it needs—no more, no less. + +By integrating secrets into Docker orchestration, we are able to deliver a solution for the secrets management problem that follows these exact principles. + +The following diagram provides a high-level view of how the Docker swarm mode architecture is applied to securely deliver a new type of object to our containers: a secret object. + + ![Docker Secrets Management](https://i0.wp.com/blog.docker.com/wp-content/uploads/b69d2410-9e25-44d8-aa2d-f67b795ff5e3.jpg?w=1140&ssl=1) + +In Docker, a secret is any blob of data, such as a password, SSH private key, TLS Certificate, or any other piece of data that is sensitive in nature. When you add a secret to the swarm (by running `docker secret create`), Docker sends the secret over to the swarm manager over a mutually authenticated TLS connection, making use of the [built-in Certificate Authority][17] that gets automatically created when bootstrapping a new swarm. + +``` +$ echo "This is a secret" | docker secret create my_secret_data - +``` + +Once the secret reaches a manager node, it gets saved to the internal Raft store, which uses NACL’s Salsa20Poly1305 with a 256-bit key to ensure no data is ever written to disk unencrypted. Writing to the internal store gives secrets the same high availability guarantees that the the rest of the swarm management data gets. + +When a swarm manager starts up, the encrypted Raft logs containing the secrets is decrypted using a data encryption key that is unique per-node. This key, and the node’s TLS credentials used to communicate with the rest of the cluster, can be encrypted with a cluster-wide key encryption key, called the unlock key, which is also propagated using Raft and will be required on manager start. + +When you grant a newly-created or running service access to a secret, one of the manager nodes (only managers have access to all the stored secrets stored) will send it over the already established TLS connection exclusively to the nodes that will be running that specific service. This means that nodes cannot request the secrets themselves, and will only gain access to the secrets when provided to them by a manager – strictly for the services that require them. + +``` +$ docker service  create --name="redis" --secret="my_secret_data" redis:alpine +``` + +The  unencrypted secret is mounted into the container in an in-memory filesystem at /run/secrets/. + +``` +$ docker exec $(docker ps --filter name=redis -q) ls -l /run/secrets +total 4 +-r--r--r--    1 root     root            17 Dec 13 22:48 my_secret_data +``` + +If a service gets deleted, or rescheduled somewhere else, the manager will immediately notify all the nodes that no longer require access to that secret to erase it from memory, and the node will no longer have any access to that application secret. + +``` +$ docker service update --secret-rm="my_secret_data" redis + +$ docker exec -it $(docker ps --filter name=redis -q) cat /run/secrets/my_secret_data + +cat: can't open '/run/secrets/my_secret_data': No such file or directory +``` + +Check out the [Docker secrets docs][18] for more information and examples on how to create and manage your secrets. And a special shout out to Laurens Van Houtven (https://www.lvh.io/[)][19] in collaboration with the Docker security and core engineering team to help make this feature a reality. + +[Get safer apps for dev and ops w/ new #Docker secrets management][5] + +[CLICK TO TWEET][6] + +### +![Docker Security](https://i2.wp.com/blog.docker.com/wp-content/uploads/Screenshot-2017-02-08-23.30.13.png?resize=1032%2C111&ssl=1) + +### Safer Apps with Docker + +Docker secrets is designed to be easily usable by developers and IT ops teams to build and run safer apps. Docker secrets is a container first architecture designed to keep secrets safe and used only when needed by the exact container that needs that secret to operate. From defining apps and secrets with Docker Compose through an IT admin deploying that Compose file directly in Docker Datacenter, the services, secrets, networks and volumes will travel securely, safely with the application. + +Resources to learn more: + +* [Docker Datacenter on 1.13 with Secrets, Security Scanning, Content Cache and More][7] + +* [Download Docker][8] and get started today + +* [Try secrets in Docker Datacenter][9] + +* [Read the Documentation][10] + +* Attend an [upcoming webinar][11] + +-------------------------------------------------------------------------------- + +via: https://blog.docker.com/2017/02/docker-secrets-management/ + +作者:[ Ying Li][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://blog.docker.com/author/yingli/ +[1]:http://www.linkedin.com/shareArticle?mini=true&url=http://dockr.ly/2k6gnOB&title=Introducing%20Docker%20Secrets%20Management&summary=Containers%20are%20changing%20how%20we%20view%20apps%20and%20infrastructure.%20Whether%20the%20code%20inside%20containers%20is%20big%20or%20small,%20container%20architecture%20introduces%20a%20change%20to%20how%20that%20code%20behaves%20with%20hardware%20-%20it%20fundamentally%20abstracts%20it%20from%20the%20infrastructure.%20Docker%20believes%20that%20there%20are%20three%20key%20components%20to%20container%20security%20and%20... +[2]:http://www.reddit.com/submit?url=http://dockr.ly/2k6gnOB&title=Introducing%20Docker%20Secrets%20Management +[3]:https://plus.google.com/share?url=http://dockr.ly/2k6gnOB +[4]:http://news.ycombinator.com/submitlink?u=http://dockr.ly/2k6gnOB&t=Introducing%20Docker%20Secrets%20Management +[5]:https://twitter.com/share?text=Get+safer+apps+for+dev+and+ops+w%2F+new+%23Docker+secrets+management+&via=docker&related=docker&url=http://dockr.ly/2k6gnOB +[6]:https://twitter.com/share?text=Get+safer+apps+for+dev+and+ops+w%2F+new+%23Docker+secrets+management+&via=docker&related=docker&url=http://dockr.ly/2k6gnOB +[7]:http://dockr.ly/AppSecurity +[8]:https://www.docker.com/getdocker +[9]:http://www.docker.com/trial +[10]:https://docs.docker.com/engine/swarm/secrets/ +[11]:http://www.docker.com/webinars +[12]:https://blog.docker.com/author/yingli/ +[13]:https://blog.docker.com/tag/container-security/ +[14]:https://blog.docker.com/tag/docker-security/ +[15]:https://blog.docker.com/tag/secrets-management/ +[16]:https://blog.docker.com/tag/security/ +[17]:https://docs.docker.com/engine/swarm/how-swarm-mode-works/pki/ +[18]:https://docs.docker.com/engine/swarm/secrets/ +[19]:https://lvh.io%29/ From dcd0b04bb2cbef0ee8e288a8d3d6ec7fc313a151 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 19:59:24 +0800 Subject: [PATCH 138/344] =?UTF-8?q?20171203-11=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... to find a publisher for your tech book.md | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 sources/tech/20171201 How to find a publisher for your tech book.md diff --git a/sources/tech/20171201 How to find a publisher for your tech book.md b/sources/tech/20171201 How to find a publisher for your tech book.md new file mode 100644 index 0000000000..76dc8112ca --- /dev/null +++ b/sources/tech/20171201 How to find a publisher for your tech book.md @@ -0,0 +1,76 @@ +How to find a publisher for your tech book +============================================================ + +### Writing a technical book takes more than a good idea. You need to know a bit about how the publishing industry works. + + +![How to find a publisher for your tech book](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDUCATION_colorbooks.png?itok=vNhsYYyC "How to find a publisher for your tech book") +Image by : opensource.com + +You've got an idea for a technical book—congratulations! Like a hiking the Appalachian trail, or learning to cook a soufflé, writing a book is one of those things that people talk about, but never take beyond the idea stage. That makes sense, because the failure rate is pretty high. Making it real involves putting your idea in front of a publisher, and finding out whether it's good enough to become a book. That step is scary enough, but the lack of information about how to do it complicates matters. + +If you want to work with a traditional publisher, you'll need to get your book in front of them and hopefully start on the path to publication. I'm the Managing Editor at the [Pragmatic Bookshelf][4], so I see proposals all the time, as well as helping authors to craft good ones. Some are good, others are bad, but I often see proposals that just aren't right for Pragmatic. I'll help you with the process of finding the right publisher, and how to get your idea noticed. + +### Identify your target + +Your first step is to figure out which publisher is the a good fit for your idea. To start, think about the publishers that you buy books from, and that you enjoy. The odds are pretty good that your book will appeal to people like you, so starting with your favorites makes for a pretty good short list. If you don't have much of a book collection, you can visit a bookstore, or take a look on Amazon. Make a list of a handful of publishers that you personally like to start with. + +Next, winnow your prospects. Although most technical publishers look alike from a distance, they often have distinctive audiences. Some publishers go for broadly popular topics, such as C++ or Java. Your book on Elixir may not be a good fit for that publisher. If your prospective book is about teaching programming to kids, you probably don't want to go with the traditional academic publisher. + +Once you've identified a few targets, do some more research into the publishers' catalogs, either on their own site, or on Amazon. See what books they have that are similar to your idea. If they have a book that's identical, or nearly so, you'll have a tough time convincing them to sign yours. That doesn't necessarily mean you should drop that publisher from your list. You can make some changes to your proposal to differentiate it from the existing book: target a different audience, or a different skill level. Maybe the existing book is outdated, and you could focus on new approaches to the technology. Make your proposal into a book that complements the existing one, rather than competes. + +If your target publisher has no books that are similar, that can be a good sign, or a very bad one. Sometimes publishers choose not to publish on specific technologies, either because they don't believe their audience is interested, or they've had trouble with that technology in the past. New languages and libraries pop up all the time, and publishers have to make informed guesses about which will appeal to their readers. Their assessment may not be the same as yours. Their decision might be final, or they might be waiting for the right proposal. The only way to know is to propose and find out. + +### Work your network + +Identifying a publisher is the first step; now you need to make contact. Unfortunately, publishing is still about  _who_  you know, more than  _what_  you know. The person you want to know is an  _acquisitions editor,_  the editor whose job is to find new markets, authors, and proposals. If you know someone who has connections with a publisher, ask for an introduction to an acquisitions editor. These editors often specialize in particular subject areas, particularly at larger publishers, but you don't need to find the right one yourself. They're usually happy to connect you with the correct person. + +Sometimes you can find an acquisitions editor at a technical conference, especially one where the publisher is a sponsor, and has a booth. Even if there's not an acquisitions editor on site at the time, the staff at the booth can put you in touch with one. If conferences aren't your thing, you'll need to work your network to get an introduction. Use LinkedIn, or your informal contacts, to get in touch with an editor. + +For smaller publishers, you may find acquisitions editors listed on the company website, with contact information if you're lucky. If not, search for the publisher's name on Twitter, and see if you can turn up their editors. You might be nervous about trying to reach out to a stranger over social media to show them your book, but don't worry about it. Making contact is what acquisitions editors do. The worst-case result is they ignore you. + +Once you've made contact, the acquisitions editor will assist you with the next steps. They may have some feedback on your proposal right away, or they may want you to flesh it out according to their guidelines before they'll consider it. After you've put in the effort to find an acquisitions editor, listen to their advice. They know their system better than you do. + +### If all else fails + +If you can't find an acquisitions editor to contact, the publisher almost certainly has a blind proposal alias, usually of the form `proposals@[publisher].com`. Check the web site for instructions on what to send to a proposal alias; some publishers have specific requirements. Follow these instructions. If you don't, you have a good chance of your proposal getting thrown out before anybody looks at it. If you have questions, or aren't sure what the publisher wants, you'll need to try again to find an editor to talk to, because the proposal alias is not the place to get questions answered. Put together what they've asked for (which is a topic for a separate article), send it in, and hope for the best. + +### And ... wait + +No matter how you've gotten in touch with a publisher, you'll probably have to wait. If you submitted to the proposals alias, it's going to take a while before somebody does anything with that proposal, especially at a larger company. Even if you've found an acquisitions editor to work with, you're probably one of many prospects she's working with simultaneously, so you might not get rapid responses. Almost all publishers have a committee that decides on which proposals to accept, so even if your proposal is awesome and ready to go, you'll still need to wait for the committee to meet and discuss it. You might be waiting several weeks, or even a month before you hear anything. + +After a couple of weeks, it's fine to check back in with the editor to see if they need any more information. You want to be polite in this e-mail; if they haven't answered because they're swamped with proposals, being pushy isn't going to get you to the front of the line. It's possible that some publishers will never respond at all instead of sending a rejection notice, but that's uncommon. There's not a lot to do at this point other than be patient. Of course, if it's been months and nobody's returning your e-mails, you're free to approach a different publisher or consider self-publishing. + +### Good luck + +If this process seems somewhat scattered and unscientific, you're right; it is. Getting published depends on being in the right place, at the right time, talking to the right person, and hoping they're in the right mood. You can't control all of those variables, but having a better knowledge of how the industry works, and what publishers are looking for, can help you optimize the ones you can control. + +Finding a publisher is one step in a lengthy process. You need to refine your idea and create the proposal, as well as other considerations. At SeaGL this year [I presented][5] an introduction to the entire process. Check out [the video][6] for more detailed information. + +### About the author + + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/portrait.jpg?itok=b77dlNC4)][7] + + Brian MacDonald - Brian MacDonald is Managing Editor at the Pragmatic Bookshelf. Over the last 20 years in tech publishing, he's been an editor, author, and occasional speaker and trainer. He currently spends a lot of his time talking to new authors about how they can best present their ideas. You can follow him on Twitter at @bmac_editor.[More about me][2] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/12/how-find-publisher-your-book + +作者:[Brian MacDonald ][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/bmacdonald +[1]:https://opensource.com/article/17/12/how-find-publisher-your-book?rate=o42yhdS44MUaykAIRLB3O24FvfWxAxBKa5WAWSnSY0s +[2]:https://opensource.com/users/bmacdonald +[3]:https://opensource.com/user/190176/feed +[4]:https://pragprog.com/ +[5]:https://archive.org/details/SeaGL2017WritingTheNextGreatTechBook +[6]:https://archive.org/details/SeaGL2017WritingTheNextGreatTechBook +[7]:https://opensource.com/users/bmacdonald +[8]:https://opensource.com/users/bmacdonald +[9]:https://opensource.com/users/bmacdonald +[10]:https://opensource.com/article/17/12/how-find-publisher-your-book#comments From aa1c7ad9a987f99345a33c83d5a8c6599296d6d2 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:00:54 +0800 Subject: [PATCH 139/344] =?UTF-8?q?20171203-12=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...x command-line screen grabs made simple.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md diff --git a/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md b/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md new file mode 100644 index 0000000000..2b4d2248b2 --- /dev/null +++ b/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md @@ -0,0 +1,108 @@ +Scrot: Linux command-line screen grabs made simple +============================================================ + +### Scrot is a basic, flexible tool that offers a number of handy options for taking screen captures from the Linux command line. + +![Scrot: Screen grabs made simple](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/community-penguins-osdc-lead.png?itok=BmqsAF4A "Scrot: Screen grabs made simple") +Image credits : Original photo by Rikki Endsley. [CC BY-SA 4.0][13] + +There are great tools on the Linux desktop for taking screen captures, such as [KSnapshot][14] and [Shutter][15]. Even the simple utility that comes with the GNOME desktop does a pretty good job of capturing screens. But what if you rarely need to take screen captures? Or you use a Linux distribution without a built-in capture tool, or an older computer with limited resources? + +Turn to the command line and a little utility called [Scrot][16]. It does a fine job of taking simple screen captures, and it includes a few features that might surprise you. + +### Getting started with Scrot + +More Linux resources + +* [What is Linux?][1] + +* [What are Linux containers?][2] + +* [Download Now: Linux commands cheat sheet][3] + +* [Advanced Linux commands cheat sheet][4] + +* [Our latest Linux articles][5] + +Many Linux distributions come with Scrot already installed—to check, type `which scrot`. If it isn't there, you can install Scrot using your distro's package manager. If you're willing to compile the code, grab it [from GitHub][22]. + +To take a screen capture, crack open a terminal window and type `scrot [filename]`, where `[filename]` is the name of file to which you want to save the image (for example, `desktop.png`). If you don't include a name for the file, Scrot will create one for you, such as `2017-09-24-185009_1687x938_scrot.png`. (That filename isn't as descriptive it could be, is it? That's why it's better to add one to the command.) + +Running Scrot with no options takes a screen capture of your entire desktop. If you don't want to do that, Scrot lets you focus on smaller portions of your screen. + +### Taking a screen capture of a single window + +Tell Scrot to take a screen capture of a single window by typing `scrot -u [filename]`. + +The `-u` option tells Scrot to grab the window currently in focus. That's usually the terminal window you're working in, which might not be the one you want. + +To grab another window on your desktop, type `scrot -s [filename]`. + +The `-s` option lets you do one of two things: + +* select an open window, or + +* draw a rectangle around a window or a portion of a window to capture it. + +You can also set a delay, which gives you a little more time to select the window you want to capture. To do that, type `scrot -u -d [num] [filename]`. + +The `-d` option tells Scrot to wait before grabbing the window, and `[num]` is the number of seconds to wait. Specifying `-d 5` (wait five seconds) should give you enough time to choose a window. + +### More useful options + +Scrot offers a number of additional features (most of which I never use). The ones I find most useful include: + +* `-b` also grabs the window's border + +* `-t` grabs a window and creates a thumbnail of it. This can be useful when you're posting screen captures online. + +* `-c` creates a countdown in your terminal when you use the `-d` option. + +To learn about Scrot's other options, check out the its documentation by typing `man scrot` in a terminal window, or [read it online][17]. Then start snapping images of your screen. + +It's basic, but Scrot gets the job done nicely. + +### Topics + + [Linux][23] + +### About the author + + [![That idiot Scott Nesbitt ...](https://opensource.com/sites/default/files/styles/profile_pictures/public/scottn-cropped.jpg?itok=q4T2J4Ai)][18] + + Scott Nesbitt - I'm a long-time user of free/open source software, and write various things for both fun and profit. I don't take myself too seriously and I do all of my own stunts. You can find me at these fine establishments on the web: [Twitter][7], [Mastodon][8], [GitHub][9], and... [more about Scott Nesbitt][10][More about me][11] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot + +作者:[ Scott Nesbitt  ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/scottnesbitt +[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[6]:https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot?rate=H43kUdawjR0GV9D0dCbpnmOWcqw1WekfrAI_qKo8UwI +[7]:http://www.twitter.com/ScottWNesbitt +[8]:https://mastodon.social/@scottnesbitt +[9]:https://github.com/ScottWNesbitt +[10]:https://opensource.com/users/scottnesbitt +[11]:https://opensource.com/users/scottnesbitt +[12]:https://opensource.com/user/14925/feed +[13]:https://creativecommons.org/licenses/by-sa/4.0/ +[14]:https://www.kde.org/applications/graphics/ksnapshot/ +[15]:https://launchpad.net/shutter +[16]:https://github.com/dreamer/scrot +[17]:http://manpages.ubuntu.com/manpages/precise/man1/scrot.1.html +[18]:https://opensource.com/users/scottnesbitt +[19]:https://opensource.com/users/scottnesbitt +[20]:https://opensource.com/users/scottnesbitt +[21]:https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot#comments +[22]:https://github.com/dreamer/scrot +[23]:https://opensource.com/tags/linux From 5ad4aeb22d6dc01c00daf3cb6178db001472c692 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:02:51 +0800 Subject: [PATCH 140/344] =?UTF-8?q?20171203-12=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... open source technology trends for 2018.md | 140 ++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 sources/tech/20171129 10 open source technology trends for 2018.md diff --git a/sources/tech/20171129 10 open source technology trends for 2018.md b/sources/tech/20171129 10 open source technology trends for 2018.md new file mode 100644 index 0000000000..1e7b137726 --- /dev/null +++ b/sources/tech/20171129 10 open source technology trends for 2018.md @@ -0,0 +1,140 @@ +10 open source technology trends for 2018 +============================================================ + +### What do you think will be the next open source tech trends? Here are 10 predictions. + +![10 open source technology trends for 2018](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fireworks-newyear-celebrate.png?itok=6gXaznov "10 open source technology trends for 2018") +Image by : [Mitch Bennett][10]. Modified by Opensource.com. [CC BY-SA 4.0][11] + +Technology is always evolving. New developments, such as OpenStack, Progressive Web Apps, Rust, R, the cognitive cloud, artificial intelligence (AI), the Internet of Things, and more are putting our usual paradigms on the back burner. Here is a rundown of the top open source trends expected to soar in popularity in 2018. + +### 1\. OpenStack gains increasing acceptance + +[OpenStack][12] is essentially a cloud operating system that offers admins the ability to provision and control huge compute, storage, and networking resources through an intuitive and user-friendly dashboard. + +Many enterprises are using the OpenStack platform to build and manage cloud computing systems. Its popularity rests on its flexible ecosystem, transparency, and speed. It supports mission-critical applications with ease and lower costs compared to alternatives. But, OpenStack's complex structure and its dependency on virtualization, servers, and extensive networking resources has inhibited its adoption by a wider range of enterprises. Using OpenStack also requires a well-oiled machinery of skilled staff and resources. + +The OpenStack Foundation is working overtime to fill the voids. Several innovations, either released or on the anvil, would resolve many of its underlying challenges. As complexities decrease, OpenStack will surge in acceptance. The fact that OpenStack is already backed by many big software development and hosting companies, in addition to thousands of individual members, makes it the future of cloud computing. + +### 2\. Progressive Web Apps become popular + +[Progressive Web Apps][13] (PWA), an aggregation of technologies, design concepts, and web APIs, offer an app-like experience in the mobile browser. + +Traditional websites suffer from many inherent shortcomings. Apps, although offering a more personal and focused engagement than websites, place a huge demand on resources, including needing to be downloaded upfront. PWA delivers the best of both worlds. It delivers an app-like experience to users while being accessible on browsers, indexable on search engines, and responsive to fit any form factor. Like an app, a PWA updates itself to always display the latest real-time information, and, like a website, it is delivered in an ultra-safe HTTPS model. It runs in a standard container and is accessible to anyone who types in the URL, without having to install anything. + +PWAs perfectly suit the needs of today's mobile users, who value convenience and personal engagement over everything else. That this technology is set to soar in popularity is a no-brainer. + +### 3\. Rust to rule the roost + +Most programming languages come with safety vs. control tradeoffs. [Rust][14] is an exception. The language co-opts extensive compile-time checking to offer 100% control without compromising safety. The last [Pwn2Own][15] competition threw up many serious vulnerabilities in Firefox on account of its underlying C++ language. If Firefox had been written in Rust, many of those errors would have manifested as compile-time bugs and resolved before the product rollout stage. + +Rust's unique approach of built-in unit testing has led developers to consider it a viable first-choice open source language. It offers an effective alternative to languages such as C and Python to write secure code without sacrificing expressiveness. Rust has bright days ahead in 2018. + +### 4\. R user community grows + +The [R][16] programming language, a GNU project, is associated with statistical computing and graphics. It offers a wide array of statistical and graphical techniques and is extensible to boot. It starts where [S][17] ends. With the S language already the vehicle of choice for research in statistical methodology, R offers a viable open source route for data manipulation, calculation, and graphical display. An added benefit is R's attention to detail and care for the finer nuances. + +Like Rust, R's fortunes are on the rise. + +### 5\. XaaS expands in scope + +XaaS, an acronym for "anything as a service," stands for the increasing number of services delivered over the internet, rather than on premises. Although software as a service (SaaS), infrastructure as a service (IaaS), and platform as a service (PaaS) are well-entrenched, new cloud-based models, such as network as a service (NaaS), storage as a service (SaaS or StaaS), monitoring as a service (MaaS), and communications as a service (CaaS), are soaring in popularity. A world where anything and everything is available "as a service" is not far away. + +The scope of XaaS now extends to bricks-and-mortar businesses, as well. Good examples are companies such as Uber and Lyft leveraging digital technology to offer transportation as a service and Airbnb offering accommodations as a service. + +High-speed networks and server virtualization that make powerful computing affordable have accelerated the popularity of XaaS, to the point that 2018 may become the "year of XaaS." The unmatched flexibility, agility, and scalability will propel the popularity of XaaS even further. + +### 6\. Containers gain even more acceptance + +Container technology is the approach of packaging pieces of code in a standardized way so they can be "plugged and run" quickly in any environment. Container technology allows enterprises to cut costs and implementation times. While the potential of containers to revolutionize IT infrastructure has been evident for a while, actual container use has remained complex. + +Container technology is still evolving, and the complexities associated with the technology decrease with every advancement. The latest developments make containers quite intuitive and as easy as using a smartphone, not to mention tuned for today's needs, where speed and agility can make or break a business. + +### 7\. Machine learning and artificial intelligence expand in scope + +[Machine learning and AI][18] give machines the ability to learn and improve from experience without a programmer explicitly coding the instruction. + +These technologies are already well entrenched, with several open source technologies leveraging them for cutting-edge services and applications. + +[Gartner predicts][19] the scope of machine learning and artificial intelligence will expand in 2018\. Several greenfield areas, such as data preparation, integration, algorithm selection, training methodology selection, and model creation are all set for big-time enhancements through the infusion of machine learning. + +New open source intelligent solutions are set to change the way people interact with systems and transform the very nature of work. + +* Conversational platforms, such as chatbots, make the question-and-command experience, where a user asks a question and the platform responds, the default medium of interacting with machines. + +* Autonomous vehicles and drones, fancy fads today, are expected to become commonplace by 2018. + +* The scope of immersive experience will expand beyond video games and apply to real-life scenarios such as design, training, and visualization processes. + +### 8\. Blockchain becomes mainstream + +Blockchain has come a long way from Bitcoin. The technology is already in widespread use in finance, secure voting, authenticating academic credentials, and more. In the coming year, healthcare, manufacturing, supply chain logistics, and government services are among the sectors most likely to embrace blockchain technology. + +Blockchain distributes digital information. The information resides on millions of nodes, in shared and reconciled databases. The fact that it's not controlled by any single authority and has no single point of failure makes it very robust, transparent, and incorruptible. It also solves the threat of a middleman manipulating the data. Such inherent strengths account for blockchain's soaring popularity and explain why it is likely to emerge as a mainstream technology in the immediate future. + +### 9\. Cognitive cloud moves to center stage + +Cognitive technologies, such as machine learning and artificial intelligence, are increasingly used to reduce complexity and personalize experiences across multiple sectors. One case in point is gamification apps in the financial sector, which offer investors critical investment insights and reduce the complexities of investment models. Digital trust platforms reduce the identity-verification process for financial institutions by about 80%, improving compliance and reducing chances of fraud. + +Such cognitive cloud technologies are now moving to the cloud, making it even more potent and powerful. IBM Watson is the most well-known example of the cognitive cloud in action. IBM's UIMA architecture was made open source and is maintained by the Apache Foundation. DARPA's DeepDive project mirrors Watson's machine learning abilities to enhance decision-making capabilities over time by learning from human interactions. OpenCog, another open source platform, allows developers and data scientists to develop artificial intelligence apps and programs. + +Considering the high stakes of delivering powerful and customized experiences, these cognitive cloud platforms are set to take center stage over the coming year. + +### 10\. The Internet of Things connects more things + +At its core, the Internet of Things (IoT) is the interconnection of devices through embedded sensors or other computing devices that enable the devices (the "things") to send and receive data. IoT is already predicted to be the next big major disruptor of the tech space, but IoT itself is in a continuous state of flux. + +One innovation likely to gain widespread acceptance within the IoT space is Autonomous Decentralized Peer-to-Peer Telemetry ([ADEPT][20]), which is propelled by IBM and Samsung. It uses a blockchain-type technology to deliver a decentralized network of IoT devices. Freedom from a central control system facilitates autonomous communications between "things" in order to manage software updates, resolve bugs, manage energy, and more. + +### Open source drives innovation + +Digital disruption is the norm in today's tech-centric era. Within the technology space, open source is now pervasive, and in 2018, it will be the driving force behind most of the technology innovations. + +Which open source trends and technologies would you add to this list? Let us know in the comments. + +### Topics + + [Business][25][Yearbook][26][2017 Open Source Yearbook][27] + +### About the author + + [![Sreejith@Fingent](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/sreejith.jpg?itok=sdYNV49V)][21] Sreejith - I have been programming since 2000, and professionally since 2007\. I currently lead the Open Source team at [Fingent][6] as we work on different technology stacks, ranging from the "boring"(read tried and trusted) to the bleeding edge. I like building, tinkering with and breaking things, not necessarily in that order. Hit me up at: [https://www.linkedin.com/in/futuregeek/][7][More about me][8] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/10-open-source-technology-trends-2018 + +作者:[Sreejith ][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/sreejith +[1]:https://opensource.com/resources/what-is-openstack?intcmp=7016000000127cYAAQ +[2]:https://opensource.com/resources/openstack/tutorials?intcmp=7016000000127cYAAQ +[3]:https://opensource.com/tags/openstack?intcmp=7016000000127cYAAQ +[4]:https://www.rdoproject.org/?intcmp=7016000000127cYAAQ +[5]:https://opensource.com/article/17/11/10-open-source-technology-trends-2018?rate=GJqOXhiWvZh0zZ6WVTUzJ2TDJBpVpFhngfuX9V-dz4I +[6]:https://www.fingent.com/ +[7]:https://www.linkedin.com/in/futuregeek/ +[8]:https://opensource.com/users/sreejith +[9]:https://opensource.com/user/185026/feed +[10]:https://www.flickr.com/photos/mitchell3417/9206373620 +[11]:https://creativecommons.org/licenses/by-sa/4.0/ +[12]:https://www.openstack.org/ +[13]:https://developers.google.com/web/progressive-web-apps/ +[14]:https://www.rust-lang.org/ +[15]:https://en.wikipedia.org/wiki/Pwn2Own +[16]:https://en.wikipedia.org/wiki/R_(programming_language) +[17]:https://en.wikipedia.org/wiki/S_(programming_language) +[18]:https://opensource.com/tags/artificial-intelligence +[19]:https://sdtimes.com/gartners-top-10-technology-trends-2018/ +[20]:https://insights.samsung.com/2016/03/17/block-chain-mobile-and-the-internet-of-things/ +[21]:https://opensource.com/users/sreejith +[22]:https://opensource.com/users/sreejith +[23]:https://opensource.com/users/sreejith +[24]:https://opensource.com/article/17/11/10-open-source-technology-trends-2018#comments +[25]:https://opensource.com/tags/business +[26]:https://opensource.com/tags/yearbook +[27]:https://opensource.com/yearbook/2017 From 332a0e4f64b4914ee83824308a780a501dc4489d Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:04:31 +0800 Subject: [PATCH 141/344] =?UTF-8?q?20171203-13=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...actices for getting started with DevOps.md | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 sources/tech/20171129 5 best practices for getting started with DevOps.md diff --git a/sources/tech/20171129 5 best practices for getting started with DevOps.md b/sources/tech/20171129 5 best practices for getting started with DevOps.md new file mode 100644 index 0000000000..962f37aaf4 --- /dev/null +++ b/sources/tech/20171129 5 best practices for getting started with DevOps.md @@ -0,0 +1,94 @@ +5 best practices for getting started with DevOps +============================================================ + +### Are you ready to implement DevOps, but don't know where to begin? Try these five best practices. + + +![5 best practices for getting started with DevOps](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/devops-gears.png?itok=rUejbLQX "5 best practices for getting started with DevOps") +Image by :  + +[Andrew Magill][8]. Modified by Opensource.com. [CC BY 4.0][9] + +DevOps often stymies early adopters with its ambiguity, not to mention its depth and breadth. By the time someone buys into the idea of DevOps, their first questions usually are: "How do I get started?" and "How do I measure success?" These five best practices are a great road map to starting your DevOps journey. + +### 1\. Measure all the things + +You don't know for sure that your efforts are even making things better unless you can quantify the outcomes. Are my features getting out to customers more rapidly? Are fewer defects escaping to them? Are we responding to and recovering more quickly from failure? + +Before you change anything, think about what kinds of outcomes you expect from your DevOps transformation. When you're further into your DevOps journey, you'll enjoy a rich array of near-real-time reports on everything about your service. But consider starting with these two metrics: + +* **Time to market** measures the end-to-end, often customer-facing, business experience. It usually begins when a feature is formally conceived and ends when the customer can consume the feature in production. Time to market is not mainly an engineering team metric; more importantly it shows your business' complete end-to-end efficiency in bringing valuable new features to market and isolates opportunities for system-wide improvement. + +* **Cycle time** measures the engineering team process. Once work on a new feature starts, when does it become available in production? This metric is very useful for understanding the efficiency of the engineering team and isolating opportunities for team-level improvement. + +### 2\. Get your process off the ground + +DevOps success requires an organization to put a regular (and hopefully effective) process in place and relentlessly improve upon it. It doesn't have to start out being effective, but it must be a regular process. Usually that it's some flavor of agile methodology like Scrum or Scrumban; sometimes it's a Lean derivative. Whichever way you go, pick a formal process, start using it, and get the basics right. + +Regular inspect-and-adapt behaviors are key to your DevOps success. Make good use of opportunities like the stakeholder demo, team retrospectives, and daily standups to find opportunities to improve your process. + +A lot of your DevOps success hinges on people working effectively together. People on a team need to work from a common process that they are empowered to improve upon. They also need regular opportunities to share what they are learning with other stakeholders, both upstream and downstream, in the process. + +Good process discipline will help your organization consume the other benefits of DevOps at the great speed that comes as your success builds. + +Although it's common for more development-oriented teams to successfully adopt processes like Scrum, operations-focused teams (or others that are more interrupt-driven) may opt for a process with a more near-term commitment horizon, such as Kanban. + +### 3\. Visualize your end-to-end workflow + +There is tremendous power in being able to see who's working on what part of your service at any given time. Visualizing your workflow will help people know what they need to work on next, how much work is in progress, and where the bottlenecks are in the process. + +You can't effectively limit work in process until you can see it and quantify it. Likewise, you can't effectively eliminate bottlenecks until you can clearly see them. + +Visualizing the entire workflow will help people in all parts of the organization understand how their work contributes to the success of the whole. It can catalyze relationship-building across organizational boundaries to help your teams collaborate more effectively towards a shared sense of success. + +### 4\. Continuous all the things + +DevOps promises a dizzying array of compelling automation. But Rome wasn't built in a day. One of the first areas you can focus your efforts on is [continuous integration][10] (CI). But don't stop there; you'll want to follow quickly with [continuous delivery][11] (CD) and eventually continuous deployment. + +Your CD pipeline is your opportunity to inject all manner of automated quality testing into your process. The moment new code is committed, your CD pipeline should run a battery of tests against the code and the successfully built artifact. The artifact that comes out at the end of this gauntlet is what progresses along your process until eventually it's seen by customers in production. + +Another "continuous" that doesn't get enough attention is continuous improvement. That's as simple as setting some time aside each day to ask your colleagues: "What small thing can we do today to get better at how we do our work?" These small, daily changes compound over time into more profound results. You'll be pleasantly surprised! But it also gets people thinking all the time about how to improve things. + +### 5\. Gherkinize + +Fostering more effective communication across your organization is crucial to fostering the sort of systems thinking prevalent in successful DevOps journeys. One way to help that along is to use a shared language between the business and the engineers to express the desired acceptance criteria for new features. A good product manager can learn [Gherkin][12] in a day and begin using it to express acceptance criteria in an unambiguous, structured form of plain English. Engineers can use this Gherkinized acceptance criteria to write acceptance tests against the criteria, and then develop their feature code until the tests pass. This is a simplification of [acceptance test-driven development][13](ATDD) that can also help kick start your DevOps culture and engineering practice. + +### Start on your journey + +Don't be discouraged by getting started with your DevOps practice. It's a journey. And hopefully these five ideas give you solid ways to get started. + + +### About the author + + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/headshot_4.jpg?itok=jntfDCfX)][14] + + Magnus Hedemark - Magnus has been in the IT industry for over 20 years, and a technology enthusiast for most of his life. He's presently Manager of DevOps Engineering at UnitedHealth Group. In his spare time, Magnus enjoys photography and paddling canoes. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/5-keys-get-started-devops + +作者:[Magnus Hedemark ][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/magnus919 +[1]:https://opensource.com/tags/devops?src=devops_resource_menu1 +[2]:https://opensource.com/resources/devops?src=devops_resource_menu2 +[3]:https://www.openshift.com/promotions/devops-with-openshift.html?intcmp=7016000000127cYAAQ&src=devops_resource_menu3 +[4]:https://enterprisersproject.com/article/2017/5/9-key-phrases-devops?intcmp=7016000000127cYAAQ&src=devops_resource_menu4 +[5]:https://www.redhat.com/en/insights/devops?intcmp=7016000000127cYAAQ&src=devops_resource_menu5 +[6]:https://opensource.com/article/17/11/5-keys-get-started-devops?rate=oEOzMXx1ghbkfl2a5ae6AnvO88iZ3wzkk53K2CzbDWI +[7]:https://opensource.com/user/25739/feed +[8]:https://ccsearch.creativecommons.org/image/detail/7qRx_yrcN5isTMS0u9iKMA== +[9]:https://creativecommons.org/licenses/by-sa/4.0/ +[10]:https://martinfowler.com/articles/continuousIntegration.html +[11]:https://martinfowler.com/bliki/ContinuousDelivery.html +[12]:https://cucumber.io/docs/reference +[13]:https://en.wikipedia.org/wiki/Acceptance_test%E2%80%93driven_development +[14]:https://opensource.com/users/magnus919 +[15]:https://opensource.com/users/magnus919 +[16]:https://opensource.com/users/magnus919 +[17]:https://opensource.com/tags/devops From e242bfb0f18d540f80eb370805bd4b427dda5141 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:06:04 +0800 Subject: [PATCH 142/344] =?UTF-8?q?20171203-14=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...71128 The politics of the Linux desktop.md | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 sources/tech/20171128 The politics of the Linux desktop.md diff --git a/sources/tech/20171128 The politics of the Linux desktop.md b/sources/tech/20171128 The politics of the Linux desktop.md new file mode 100644 index 0000000000..c9117dacfe --- /dev/null +++ b/sources/tech/20171128 The politics of the Linux desktop.md @@ -0,0 +1,110 @@ +The politics of the Linux desktop +============================================================ + +### If you're working in open source, why would you use anything but Linux as your main desktop? + + +![The politics of the Linux desktop](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_networks.png?itok=XasNXxKs "The politics of the Linux desktop") +Image by : opensource.com + +At some point in 1997 or 1998—history does not record exactly when—I made the leap from Windows to the Linux desktop. I went through quite a few distributions, from Red Hat to SUSE to Slackware, then Debian, Debian Experimental, and (for a long time thereafter) Ubuntu. When I accepted a role at Red Hat, I moved to Fedora, and migrated both my kids (then 9 and 11) to Fedora as well. + +More Linux resources + +* [What is Linux?][1] + +* [What are Linux containers?][2] + +* [Download Now: Linux commands cheat sheet][3] + +* [Advanced Linux commands cheat sheet][4] + +* [Our latest Linux articles][5] + +For a few years, I kept Windows as a dual-boot option, and then realised that, if I was going to commit to Linux, then I ought to go for it properly. In losing Windows, I didn't miss much; there were a few games that I couldn't play, but it was around the time that the Civilization franchise was embracing Linux, so that kept me happy. + +The move to Linux wasn't plain sailing, by any stretch of the imagination. If you wanted to use fairly new hardware in the early days, you had to first ensure that there were  _any_  drivers for Linux, then learn how to compile and install them. If they were not quite my friends, **lsmod** and **modprobe** became at least close companions. I taught myself to compile a kernel and tweak the options to make use of (sometimes disastrous) new, "EXPERIMENTAL" features as they came out. Early on, I learned the lesson that you should always keep at least one kernel in your [LILO][12] list that you were  _sure_  booted fully. I cursed NVidia and grew horrified by SCSI. I flirted with early journalling filesystem options and tried to work out whether the different preempt parameters made any noticeable difference to my user experience or not. I began to accept that printers would never print—and then they started to. I discovered that the Bluetooth stack suddenly started to connect to things. + +Over the years, using Linux moved from being an uphill struggle to something that just worked. I moved my mother-in-law and then my father over to Linux so I could help administer their machines. And then I moved them off Linux so they could no longer ask me to help administer their machines. + +Over the years, using Linux moved from being an uphill struggle to something that just worked.It wasn't just at home, either: I decided that I would use Linux as my desktop for work, as well. I even made it a condition of employment for at least one role. Linux desktop support in the workplace caused different sets of problems. The first was the "well, you're on your own: we're not going to support you" email from IT support. VPNs were touch and go, but in the end, usually go. + +The biggest hurdle was Microsoft Office, until I discovered [CrossOver][13], which I bought with my own money, and which allowed me to run company-issued copies of Word, PowerPoint, and the rest on my Linux desktop. Fonts were sometimes a problem, and one company I worked for required Microsoft Lync. For this, and for a few other applications, I would sometimes have to run a Windows virtual machine (VM) on my Linux desktop.  Was this a cop out?  Well, a little bit: but I've always tried to restrict my usage of this approach to the bare minimum. + +### But why? + +"Why?" colleagues would ask. "Why do you bother? Why not just run Windows?" + +"Because I enjoy pain," was usually my initial answer, and then the more honest, "because of the principle of the thing." + +So this is it: I believe in open source. We have a number of very, very good desktop-compatible distributions these days, and most of the time they just work. If you use well-known or supported hardware, they're likely to "just work" pretty much as well as the two obvious alternatives, Windows or Mac. And they just work because many people have put much time into using them, testing them, and improving them. So it's not a case of why wouldn't I use Windows or Mac, but why would I ever consider  _not_  using Linux? If, as I do, you believe in open source, and particularly if you work within the open source community or are employed by an open source organisation, I struggle to see why you would even consider not using Linux. + +So it's not a case of why wouldn't I use Windows or Mac, but why would I ever consider not using Linux?I've spoken to people about this (of course I have), and here are the most common reasons—or excuses—I've heard. + +1. I'm more productive on Windows/Mac. + +2. I can't use app X on Linux, and I need it for my job. + +3. I can't game on Linux. + +4. It's what our customers use, so why we would alienate them? + +5. "Open" means choice, and I prefer a proprietary desktop, so I use that. + +Interestingly, I don't hear "Linux isn't good enough" much anymore, because it's manifestly untrue, and I can show that my own experience—and that of many colleagues—belies that. + +### Rebuttals + +If you believe in open source, then I contest that you should take the time to learn how to use a Linux desktop and the associated applications.Let's go through those answers and rebut them. + +1. **I'm more productive on Windows/Mac.** I'm sure you are. Anyone is more productive when they're using a platform or a system they're used to. If you believe in open source, then I contest that you should take the time to learn how to use a Linux desktop and the associated applications. If you're working for an open source organisation, they'll probably help you along, and you're unlikely to find you're much less productive in the long term. And, you know what? If you are less productive in the long term, then get in touch with the maintainers of the apps that are causing you to be less productive and help improve them. You don't have to be a coder. You could submit bug reports, suggest improvements, write documentation, or just test the most recent versions of the software. And then you're helping yourself and the rest of the community. Welcome to open source. + +1. **I can't use app X on Linux, and I need it for my job.** This may be true. But it's probably less true than you think. The people most often saying this with conviction are audio, video, or graphics experts. It was certainly the case for many years that Linux lagged behind in those areas, but have a look and see what the other options are. And try them, even if they're not perfect, and see how you can improve them. Alternatively, use a VM for that particular app. + +1. **I can't game on Linux.** Well, you probably can, but not all the games that you enjoy. This, to be clear, shouldn't really be an excuse not to use Linux for most of what you do. It might be a reason to keep a dual-boot system or to do what I did (after much soul-searching) and buy a games console (because Elite Dangerous really  _doesn't_  work on Linux, more's the pity). It should also be an excuse to lobby for your favourite games to be ported to Linux. + +1. **It's what our customers use, so why would we alienate them?** I don't get this one. Does Microsoft ban visitors with Macs from their buildings? Does Apple ban Windows users? Does Google allow non-Android phones through their doors? You don't kowtow to the majority when you're the little guy or gal; if you're working in open source, surely you should be proud of that. You're not going to alienate your customer—you're really not. + +1. **"Open" means choice, and I prefer a proprietary desktop, so I use that.**Being open certainly does mean you have a choice. You made that choice by working in open source. For many, including me, that's a moral and philosophical choice. Saying you embrace open source, but rejecting it in practice seems mealy mouthed, even insulting. Using openness to justify your choice is the wrong approach. Saying "I prefer a proprietary desktop, and company policy allows me to do so" is better. I don't agree with your decision, but at least you're not using the principle of openness to justify it. + +Is using open source easy? Not always. But it's getting easier. I think that we should stand up for what we believe in, and if you're reading [Opensource.com][14], then you probably believe in open source. And that, I believe, means that you should run Linux as your main desktop. + + _Note: I welcome comments, and would love to hear different points of view. I would ask that comments don't just list application X or application Y as not working on Linux. I concede that not all apps do. I'm more interested in justifications that I haven't covered above, or (perceived) flaws in my argument. Oh, and support for it, of course._ + + +### About the author + + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/2017-05-10_0129.jpg?itok=Uh-eKFhx)][15] + + Mike Bursell - I've been in and around Open Source since around 1997, and have been running (GNU) Linux as my main desktop at home and work since then: [not always easy][7]...  I'm a security bod and architect, and am currently employed as Chief Security Architect for Red Hat.  I have a blog - "[Alice, Eve & Bob][8]" - where I write (sometimes rather parenthetically) about security.  I live in the UK and... [more about Mike Bursell][9][More about me][10] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/politics-linux-desktop + +作者:[Mike Bursell ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/mikecamel +[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[6]:https://opensource.com/article/17/11/politics-linux-desktop?rate=do69ixoNzK0yg3jzFk0bc6ZOBsIUcqTYv6FwqaVvzUA +[7]:https://opensource.com/article/17/11/politics-linux-desktop +[8]:https://aliceevebob.com/ +[9]:https://opensource.com/users/mikecamel +[10]:https://opensource.com/users/mikecamel +[11]:https://opensource.com/user/105961/feed +[12]:https://en.wikipedia.org/wiki/LILO_(boot_loader) +[13]:https://en.wikipedia.org/wiki/CrossOver_(software) +[14]:https://opensource.com/ +[15]:https://opensource.com/users/mikecamel +[16]:https://opensource.com/users/mikecamel +[17]:https://opensource.com/users/mikecamel +[18]:https://opensource.com/article/17/11/politics-linux-desktop#comments +[19]:https://opensource.com/tags/linux From 81b6d10b3bc957bde328d3586df23607c80d5258 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:07:28 +0800 Subject: [PATCH 143/344] =?UTF-8?q?20171203-15=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... a great pair for beginning programmers.md | 142 ++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md diff --git a/sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md b/sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md new file mode 100644 index 0000000000..479bfb1232 --- /dev/null +++ b/sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md @@ -0,0 +1,142 @@ +Why Python and Pygame are a great pair for beginning programmers +============================================================ + +### We look at three reasons Pygame is a good choice for learning to program. + + +![What's the best game platform for beginning programmers?](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_development_programming.png?itok=M_QDcgz5 "What's the best game platform for beginning programmers?") +Image by :  + +opensource.com + +Last month, [Scott Nesbitt][10] wrote about [Mozilla awarding $500K to support open source projects][11]. Phaser, a HTML/JavaScript game platform, was [awarded $50,000][12]. I’ve been teaching Phaser to my pre-teen daughter for a year, and it's one of the best and easiest HTML game development platforms to learn. [Pygame][13], however, may be a better choice for beginners. Here's why. + +### 1\. One long block of code + +Pygame is based on Python, the [most popular language for introductory computer courses][14]. Python is great for writing out ideas in one long block of code. Kids start off with a single file and with a single block of code. Before they can get to functions or classes, they start with code that will soon resemble spaghetti. It’s like finger-painting, as they throw thoughts onto the page. + +More Python Resources + +* [What is Python?][1] + +* [Top Python IDEs][2] + +* [Top Python GUI frameworks][3] + +* [Latest Python content][4] + +* [More developer resources][5] + +This approach to learning works. Kids will naturally start to break things into functions and classes as their code gets more difficult to manage. By learning the syntax of a language like Python prior to learning about functions, the student will gain basic programming knowledge before using global and local scope. + +Most HTML games separate the structure, style, and programming logic into HTML, CSS, and JavaScript to some degree and require knowledge of CSS and HTML. While the separation is better in the long term, it can be a barrier for beginners. Once kids realize that they can quickly build web pages with HTML and CSS, they may get distracted by the visual excitement of colors, fonts, and graphics. Even those who stay focused on JavaScript coding will still need to learn the basic document structure that the JavaScript code sits in. + +### 2\. Global variables are more obvious + +Both Python and JavaScript use dynamically typed variables, meaning that a variable becomes a string, an integer, or float when it’s assigned; however, making mistakes is easier in JavaScript. Similar to typed variables, both JavaScript and Python have global and local variable scopes. In Python, global variables inside of a function are identified with the global keyword. + +Let’s look at the basic [Making your first Phaser game tutorial][15], by Alvin Ourrad and Richard Davey, to understand the challenge of using Phaser to teach programming to beginners. In JavaScript, global variables—variables that can be accessed anywhere in the program—are difficult to keep track of and often are the source of bugs that are challenging to solve. Richard and Alvin are expert programmers and use global variables intentionally to keep things concise. + +``` +var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }); + +function preload() { + +    game.load.image('sky', 'assets/sky.png'); + +} + +var player; +var platforms; + +function create() { +    game.physics.startSystem(Phaser.Physics.ARCADE); +… +``` + +In their Phaser programming book  [_Interphase_ ,][16] Richard Davey and Ilija Melentijevic explain that global variables are commonly used in many Phaser projects because they make it easier to get things done quickly. + +> “If you’ve ever worked on a game of any significant size then this approach is probably already making you cringe slightly... So why do we do it? The reason is simply because it’s the most concise and least complicated way to demonstrate what Phaser can do.” + +Although structuring a Phaser application to use local variables and split things up nicely into separation of concerns is possible, that’s tough for kids to understand when they’re first learning to program. + +If you’re set on teaching your kids to code with JavaScript, or if they already know how to code in another language like Python, a good Phaser course is [The Complete Mobile Game Development Course][17], by [Pablo Farias Navarro][18]. Although the title focuses on mobile games, the actual course focuses on JavaScript and Phaser. The JavaScript and Phaser apps are moved to a mobile phone with [PhoneGap][19]. + +### 3\. Pygame comes with less assembly required + +Thanks to [Python Wheels][20], Pygame is now super [easy to install][21]. You can also install it on Fedora/Red Hat with the **yum** package manager: + +``` +sudo yum install python3-pygame +``` + +See the official [Pygame installation documentation][22] for more information. + +Although Phaser itself is even easier to install, it does require more knowledge to use. As mentioned previously, the student will need to assemble their JavaScript code within an HTML document with some CSS. In addition to the three languages—HTML, CSS, and JavaScript—Phaser also requires the use of Firefox or Chrome development tools and an editor. The most common editors for JavaScript are Sublime, Atom, VS Code (probably in that order). + +Phaser applications will not run if you open the HTML file in a browser directly, due to [same-origin policy][23]. You must run a web server and access the files by connecting to the web server. Fortunately, you don’t need to run Apache on your local computer; you can run something lightweight like [httpster][24] for most projects. + +### Advantages of Phaser and JavaScript + +With all the challenges of JavaScript and Phaser, why am I teaching them? Honestly, I held off for a long time. I worried about students learning variable hoisting and scope. I developed my own curriculum based on Pygame and Python, then I developed one based on Phaser. Eventually, I decided to use Pablo’s pre-made curriculum as a starting point.  + +There are really two reasons that I moved to JavaScript. First, JavaScript has emerged as a serious language used in serious applications. In addition to web applications, it’s used for mobile and server applications. JavaScript is everywhere, and it’s used widely in applications kids see every day. If their friends code in JavaScript, they'll likely want to as well. As I saw the momentum behind JavaScript, I looked into alternatives that could compile into JavaScript, primarily Dart and TypeScript. I didn’t mind the extra conversion step, but I still looked at JavaScript. + +In the end, I chose to use Phaser and JavaScript because I realized that the problems could be solved with JavaScript and a bit of work. High-quality debugging tools and the work of some exceptionally smart people have made JavaScript a language that is both accessible and useful for teaching kids to code. + +### Final word: Python vs. JavaScript + +When people ask me what language to start their kids with, I immediately suggest Python and Pygame. There are tons of great curriculum options, many of which are free. I used ["Making Games with Python & Pygame"][25] by Al Sweigart with my son. I also used  _[Think Python: How to Think Like a Computer Scientist][7]_ by Allen B. Downey. You can get Pygame on your Android phone with [RAPT Pygame][26] by [Tom Rothamel][27]. + +Despite my recommendation, I always suspect that kids soon move to JavaScript. And that’s okay—JavaScript is a mature language with great tools. They’ll have fun with JavaScript and learn a lot. But after years of helping my daughter’s older brother create cool games in Python, I’ll always have an emotional attachment to Python and Pygame. + +### About the author + + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/craig-head-crop.png?itok=LlMnIq8m)][28] + + Craig Oda - First elected president and co-founder of Tokyo Linux Users Group. Co-author of "Linux Japanese Environment" book published by O'Reilly Japan. Part of core team that established first ISP in Asia. Former VP of product management and product marketing for major Linux company. Partner at Oppkey, developer relations consulting firm in Silicon Valley.[More about me][8] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/pygame + +作者:[Craig Oda ][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/codetricity +[1]:https://opensource.com/resources/python?intcmp=7016000000127cYAAQ +[2]:https://opensource.com/resources/python/ides?intcmp=7016000000127cYAAQ +[3]:https://opensource.com/resources/python/gui-frameworks?intcmp=7016000000127cYAAQ +[4]:https://opensource.com/tags/python?intcmp=7016000000127cYAAQ +[5]:https://developers.redhat.com/?intcmp=7016000000127cYAAQ +[6]:https://opensource.com/article/17/11/pygame?rate=PV7Af00S0QwicZT2iv8xSjJrmJPdpfK1Kcm7LXxl_Xc +[7]:http://greenteapress.com/thinkpython/html/index.html +[8]:https://opensource.com/users/codetricity +[9]:https://opensource.com/user/46031/feed +[10]:https://opensource.com/users/scottnesbitt +[11]:https://opensource.com/article/17/10/news-october-14 +[12]:https://www.patreon.com/photonstorm/posts +[13]:https://www.pygame.org/news +[14]:https://cacm.acm.org/blogs/blog-cacm/176450-python-is-now-the-most-popular-introductory-teaching-language-at-top-u-s-universities/fulltext +[15]:http://phaser.io/tutorials/making-your-first-phaser-game +[16]:https://phaser.io/interphase +[17]:https://academy.zenva.com/product/the-complete-mobile-game-development-course-platinum-edition/ +[18]:https://gamedevacademy.org/author/fariazz/ +[19]:https://phonegap.com/ +[20]:https://pythonwheels.com/ +[21]:https://pypi.python.org/pypi/Pygame +[22]:http://www.pygame.org/wiki/GettingStarted#Pygame%20Installation +[23]:https://blog.chromium.org/2008/12/security-in-depth-local-web-pages.html +[24]:https://simbco.github.io/httpster/ +[25]:https://inventwithpython.com/makinggames.pdf +[26]:https://github.com/renpytom/rapt-pygame-example +[27]:https://github.com/renpytom +[28]:https://opensource.com/users/codetricity +[29]:https://opensource.com/users/codetricity +[30]:https://opensource.com/users/codetricity +[31]:https://opensource.com/article/17/11/pygame#comments +[32]:https://opensource.com/tags/python +[33]:https://opensource.com/tags/programming From 50a3d89c6ba7635e97982aac126395fa76347a43 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:10:14 +0800 Subject: [PATCH 144/344] =?UTF-8?q?20171203-16=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Why microservices are a security issue.md | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 sources/tech/20171123 Why microservices are a security issue.md diff --git a/sources/tech/20171123 Why microservices are a security issue.md b/sources/tech/20171123 Why microservices are a security issue.md new file mode 100644 index 0000000000..d5868faa9e --- /dev/null +++ b/sources/tech/20171123 Why microservices are a security issue.md @@ -0,0 +1,116 @@ +Why microservices are a security issue +============================================================ + +### Maybe you don't want to decompose all your legacy applications into microservices, but you might consider starting with your security functions. + +![Why microservices are a security issue](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003601_05_mech_osyearbook2016_security_cc.png?itok=3V07Lpko "Why microservices are a security issue") +Image by : Opensource.com + +I struggled with writing the title for this post, and I worry that it comes across as clickbait. If you've come to read this because it looked like clickbait, then sorry.[1][5]I hope you'll stay anyway: there are lots of fascinating[2][6] points and many[3][7]footnotes. What I  _didn't_  mean to suggest is that microservices cause [security][15]problems—though like any component, of course, they can—but that microservices are appropriate objects of interest to those involved with security. I'd go further than that: I think they are an excellent architectural construct for those concerned with security. + +And why is that? Well, for those of us with a [systems security][16] bent, the world is an interesting place at the moment. We're seeing a growth in distributed systems, as bandwidth is cheap and latency low. Add to this the ease of deploying to the cloud, and more architects are beginning to realise that they can break up applications, not just into multiple layers, but also into multiple components within the layer. Load balancers, of course, help with this when the various components in a layer are performing the same job, but the ability to expose different services as small components has led to a growth in the design, implementation, and deployment of  _microservices_ . + +More on Microservices + +* [How to explain microservices to your CEO][1] + +* [Free eBook: Microservices vs. service-oriented architecture][2] + +* [Secured DevOps for microservices][3] + +So, [what exactly is a microservice][23]? I quite like [Wikipedia's definition][24], though it's interesting that security isn't mentioned there.[4][17] One of the points that I like about microservices is that, when well-designed, they conform to the first two points of Peter H. Salus' description of the [Unix philosophy][25]: + +1. Write programs that do one thing and do it well. + +2. Write programs to work together. + +3. Write programs to handle text streams, because that is a universal interface. + +The last of the three is slightly less relevant, because the Unix philosophy is generally used to refer to standalone applications, which often have a command instantiation. It does, however, encapsulate one of the basic requirements of microservices: that they must have well-defined interfaces. + +By "well-defined," I don't just mean a description of any externally accessible APIs' methods, but also of the normal operation of the microservice: inputs and outputs—and, if there are any, side-effects. As I described in a previous post, "[5 traits of good systems architecture][18]," data and entity descriptions are crucial if you're going to be able to design a system. Here, in our description of microservices, we get to see why these are so important, because, for me, the key defining feature of a microservices architecture is decomposability. And if you're going to decompose[5][8] your architecture, you need to be very, very clear which "bits" (components) are going to do what. + +And here's where security starts to come in. A clear description of what a particular component should be doing allows you to: + +* Check your design + +* Ensure that your implementation meets the description + +* Come up with reusable unit tests to check functionality + +* Track mistakes in implementation and correct them + +* Test for unexpected outcomes + +* Monitor for misbehaviour + +* Audit actual behaviour for future scrutiny + +Now, are all these things possible in a larger architecture? Yes, they are. But they become increasingly difficult where entities are chained together or combined in more complex configurations. Ensuring  _correct_  implementation and behaviour is much, much easier when you've got smaller pieces to work together. And deriving complex systems behaviours—and misbehaviours—is much more difficult if you can't be sure that the individual components are doing what they ought to be. + +It doesn't stop here, however. As I've mentioned on many [previous occasions][19], writing good security code is difficult.[7][9] Proving that it does what it should do is even more difficult. There is every reason, therefore, to restrict code that has particular security requirements—password checking, encryption, cryptographic key management, authorisation, etc.—to small, well-defined blocks. You can then do all the things that I've mentioned above to try to make sure it's done correctly. + +And yet there's more. We all know that not everybody is great at writing security-related code. By decomposing your architecture such that all security-sensitive code is restricted to well-defined components, you get the chance to put your best security people on that and restrict the danger that J. Random Coder[8][10] will put something in that bypasses or downgrades a key security control. + +It can also act as an opportunity for learning: It's always good to be able to point to a design/implementation/test/monitoring tuple and say: "That's how it should be done. Hear, read, mark, learn, and inwardly digest.[9][11]" + +Should you go about decomposing all of your legacy applications into microservices? Probably not. But given all the benefits you can accrue, you might consider starting with your security functions. + +* * * + +1Well, a little bit—it's always nice to have readers. + +2I know they are: I wrote them. + +3Probably less fascinating. + +4At the time this article was written. It's entirely possible that I—or one of you—may edit the article to change that. + +5This sounds like a gardening term, which is interesting. Not that I really like gardening, but still.[6][12] + +6Amusingly, I first wrote, "…if you're going to decompose your architect…," which sounds like the strapline for an IT-themed murder film. + +7Regular readers may remember a reference to the excellent film  _The Thick of It_ . + +8Other generic personae exist; please take your pick. + +9Not a cryptographic digest: I don't think that's what the original writers had in mind. + + _This article originally appeared on [Alice, Eve, and Bob—a security blog][13] and is republished with permission._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/microservices-are-security-issue + +作者:[Mike Bursell ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/mikecamel +[1]:https://blog.openshift.com/microservices-how-to-explain-them-to-your-ceo/?intcmp=7016000000127cYAAQ&src=microservices_resource_menu1 +[2]:https://www.openshift.com/promotions/microservices.html?intcmp=7016000000127cYAAQ&src=microservices_resource_menu2 +[3]:https://opensource.com/business/16/11/secured-devops-microservices?src=microservices_resource_menu3 +[4]:https://opensource.com/article/17/11/microservices-are-security-issue?rate=GDH4xOWsgYsVnWbjEIoAcT_92b8gum8XmgR6U0T04oM +[5]:https://opensource.com/article/17/11/microservices-are-security-issue#1 +[6]:https://opensource.com/article/17/11/microservices-are-security-issue#2 +[7]:https://opensource.com/article/17/11/microservices-are-security-issue#3 +[8]:https://opensource.com/article/17/11/microservices-are-security-issue#5 +[9]:https://opensource.com/article/17/11/microservices-are-security-issue#7 +[10]:https://opensource.com/article/17/11/microservices-are-security-issue#8 +[11]:https://opensource.com/article/17/11/microservices-are-security-issue#9 +[12]:https://opensource.com/article/17/11/microservices-are-security-issue#6 +[13]:https://aliceevebob.com/2017/10/31/why-microservices-are-a-security-issue/ +[14]:https://opensource.com/user/105961/feed +[15]:https://opensource.com/tags/security +[16]:https://aliceevebob.com/2017/03/14/systems-security-why-it-matters/ +[17]:https://opensource.com/article/17/11/microservices-are-security-issue#4 +[18]:https://opensource.com/article/17/10/systems-architect +[19]:https://opensource.com/users/mikecamel +[20]:https://opensource.com/users/mikecamel +[21]:https://opensource.com/users/mikecamel +[22]:https://opensource.com/article/17/11/microservices-are-security-issue#comments +[23]:https://opensource.com/resources/what-are-microservices +[24]:https://en.wikipedia.org/wiki/Microservices +[25]:https://en.wikipedia.org/wiki/Unix_philosophy From 31a4d191464506482bffafe09a17782a077ff78c Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:16:34 +0800 Subject: [PATCH 145/344] =?UTF-8?q?20171203-17=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...eractive Workflows for Cpp with Jupyter.md | 301 ++++++++++++++++++ 1 file changed, 301 insertions(+) create mode 100644 sources/tech/20171129 Interactive Workflows for Cpp with Jupyter.md diff --git a/sources/tech/20171129 Interactive Workflows for Cpp with Jupyter.md b/sources/tech/20171129 Interactive Workflows for Cpp with Jupyter.md new file mode 100644 index 0000000000..395c901618 --- /dev/null +++ b/sources/tech/20171129 Interactive Workflows for Cpp with Jupyter.md @@ -0,0 +1,301 @@ +Interactive Workflows for C++ with Jupyter +============================================================ + +Scientists, educators and engineers not only use programming languages to build software systems, but also in interactive workflows, using the tools available to  _explore _ a problem and  _reason _ about it. + +Running some code, looking at a visualization, loading data, and running more code. Quick iteration is especially important during the exploratory phase of a project. + +For this kind of workflow, users of the C++ programming language currently have no choice but to use a heterogeneous set of tools that don’t play well with each other, making the whole process cumbersome, and difficult to reproduce. + + _We currently lack a good story for interactive computing in C++_ . + +In our opinion, this hurts the productivity of C++ developers: + +* Most of the progress made in software projects comes from incrementalism. Obstacles to fast iteration hinder progress. + +* This also makes C++ more difficult to teach. The first hours of a C++ class are rarely rewarding as the students must learn how to set up a small project before writing any code. And then, a lot more time is required before their work can result in any visual outcome. + +### Project Jupyter and Interactive Computing + + + +![](https://cdn-images-1.medium.com/max/1200/1*wOHyKy6fl3ltcBMNpCvC6Q.png) + +The goal of Project Jupyter is to provide a consistent set of tools for scientific computing and data science workflows, from the exploratory phase of the analysis to the presentation and the sharing of the results. The Jupyter stack was designed to be agnostic of the programming language, and also to allow alternative implementations of any component of the layered architecture (back-ends for programming languages, custom renderers for file types associated with Jupyter). The stack consists of + +* a low-level specification for messaging protocols, standardized file formats, + +* a reference implementation of these standards, + +* applications built on the top of these libraries: the Notebook, JupyterLab, Binder, JupyterHub + +* and visualization libraries integrated into the Notebook and JupyterLab. + +Adoption of the Jupyter ecosystem has skyrocketed in the past years, with millions of users worldwide, over a million Jupyter notebooks shared on GitHub and large-scale deployments of Jupyter in universities, companies and high-performance computing centers. + +### Jupyter and C++ + +One of the main extension points of the Jupyter stack is the  _kernel_ , the part of the infrastructure responsible for executing the user’s code. Jupyter kernels exist for [numerous programming languages][14]. + +Most Jupyter kernels are implemented in the target programming language: the reference implementation [ipykernel][15] in Python, [IJulia][16] in Julia, leading to a duplication of effort for the implementation of the protocol. A common denominator to a lot of these interpreted languages is that the interpreter generally exposes a C API, allowing the embedding into a native application. In an effort to consolidate these commonalities and save work for future kernel builders, we developed  _xeus_ . + + + +![](https://cdn-images-1.medium.com/max/1200/1*TKrPv5AvFM3NJ6a7VMu8Tw.png) + +[Xeus ][17]is a C++ implementation of the Jupyter kernel protocol. It is not a kernel itself but a library that facilitates the authoring of kernels, and other applications making use of the Jupyter kernel protocol. + +A typical kernel implementation using xeus would in fact make use of the target interpreter _ as a library._ + +There are a number of benefits of using xeus over implementing your kernel in the target language: + +* Xeus provides a complete implementation of the protocol, enabling a lot of features from the start for kernel authors, who only need to deal with the language bindings. + +* Xeus-based kernels can very easily provide a back-end for Jupyter interactive widgets. + +* Finally, xeus can be used to implement kernels for domain-specific languages such as SQL flavors. Existing approaches use a Python wrapper. With xeus, the resulting kernel won't require Python at run-time, leading to large performance benefits. + + + +![](https://cdn-images-1.medium.com/max/1200/1*Cr_cfHdrgFXHlO15qdNK7w.png) + +Interpreted C++ is already a reality at CERN with the [Cling][18]C++ interpreter in the context of the [ROOT][19] data analysis environment. + +As a first example for a kernel based on xeus, we have implemented [xeus-cling][20], a pure C++ kernel. + + + +![](https://cdn-images-1.medium.com/max/1600/1*NnjISpzZtpy5TOurg0S89A.gif) +Redirection of outputs to the Jupyter front-end, with different styling in the front-end. + +Complex features of the C++ programming language such as, polymorphism, templates, lambdas, are supported by the cling interpreter, making the C++ Jupyter notebook a great prototyping and learning platform for the C++ users. See the image below for a demonstration: + + + +![](https://cdn-images-1.medium.com/max/1600/1*lGVLY4fL1ytMfT-eWtoXkw.gif) +Features of the C++ programming language supported by the cling interpreter + +Finally, xeus-cling supports live quick-help, fetching the content on [cppreference][21] in the case of the standard library. + + + +![](https://cdn-images-1.medium.com/max/1600/1*Igegq0xBebuJV8hy0TGpfg.png) +Live help for the C++standard library in the Jupyter notebook + +> We realized that we started using the C++ kernel ourselves very early in the development of the project. For quick experimentation, or reproducing bugs. No need to set up a project with a cpp file and complicated project settings for finding the dependencies… Just write some code and hit Shift+Enter. + +Visual output can also be displayed using the rich display mechanism of the Jupyter protocol. + + + +![](https://cdn-images-1.medium.com/max/1600/1*t_9qAXtdkSXr-0tO9VvOzQ.png) +Using Jupyter's rich display mechanism to display an image inline in the notebook + + +![](https://cdn-images-1.medium.com/max/1200/1*OVfmXFAbfjUtGFXYS9fKRA.png) + +Another important feature of the Jupyter ecosystem are the [Jupyter Interactive Widgets][22]. They allow the user to build graphical interfaces and interactive data visualization inline in the Jupyter notebook. Moreover it is not just a collection of widgets, but a framework that can be built upon, to create arbitrary visual components. Popular interactive widget libraries include + +* [bqplot][1] (2-D plotting with d3.js) + +* [pythreejs][2] (3-D scene visualization with three.js) + +* [ipyleaflet][3] (maps visualization with leaflet.js) + +* [ipyvolume][4] (3-D plotting and volume rendering with three.js) + +* [nglview][5] (molecular visualization) + +Just like the rest of the Jupyter ecosystem, Jupyter interactive widgets were designed as a language-agnostic framework. Other language back-ends can be created reusing the front-end component, which can be installed separately. + +[xwidgets][23], which is still at an early stage of development, is a native C++ implementation of the Jupyter widgets protocol. It already provides an implementation for most of the widget types available in the core Jupyter widgets package. + + + +![](https://cdn-images-1.medium.com/max/1600/1*ro5Ggdstnf0DoqhTUWGq3A.gif) +C++ back-end to the Jupyter interactive widgets + +Just like with ipywidgets, one can build upon xwidgets and implement C++ back-ends for the Jupyter widget libraries listed earlier, effectively enabling them for the C++ programming language and other xeus-based kernels: xplot, xvolume, xthreejs… + + + +![](https://cdn-images-1.medium.com/max/1200/1*yCRYoJFnbtxYkYMRc9AioA.png) + +[xplot][24] is an experimental C++ back-end for the [bqplot][25] 2-D plotting library. It enables an API following the constructs of the  [_Grammar of Graphics_][26]  in C++. + +In xplot, every item in a chart is a separate object that can be modified from the back-end,  _dynamically_ . + +Changing a property of a plot item, a scale, an axis or the figure canvas itself results in the communication of an update message to the front-end, which reflects the new state of the widget visually. + + + +![](https://cdn-images-1.medium.com/max/1600/1*Mx2g3JuTG1Cfvkkv0kqtLA.gif) +Changing the data of a scatter plot dynamically to update the chart + +> Warning: the xplot and xwidgets projects are still at an early stage of development and are changing drastically at each release. + +Interactive computing environments like Jupyter are not the only missing tool in the C++ world. Two key ingredients to the success of Python as the  _lingua franca_  of data science is the existence of libraries like [NumPy][27] and [Pandas][28] at the foundation of the ecosystem. + + + +![](https://cdn-images-1.medium.com/max/1200/1*HsU43Jzp1vJZpX2g8XPJsg.png) + +[xtensor][29] is a C++ library meant for numerical analysis with multi-dimensional array expressions. + +xtensor provides + +* an extensible expression system enabling lazy NumPy-style broadcasting. + +* an API following the  _idioms_  of the C++ standard library. + +* tools to manipulate array expressions and build upon xtensor. + +xtensor exposes an API similar to that of NumPy covering a growing portion of the functionalities. A cheat sheet can be [found in the documentation][30]: + + + +![](https://cdn-images-1.medium.com/max/1600/1*PBrf5vWYC8VTq_7VUOZCpA.gif) +Scrolling the NumPy to xtensor cheat sheet + +However, xtensor internals are very different from NumPy. Using modern C++ techniques (template expressions, closure semantics) xtensor is a lazily evaluated library, avoiding the creation of temporary variables and unnecessary memory allocations, even in the case complex expressions involving broadcasting and language bindings. + +Still, from a user perspective, the combination of xtensor with the C++ notebook provides an experience very similar to that of NumPy in a Python notebook. + + + +![](https://cdn-images-1.medium.com/max/1600/1*ULFpg-ePkdUbqqDLJ9VrDw.png) +Using the xtensor array expression library in a C++ notebook + +In addition to the core library, the xtensor ecosystem has a number of other components + +* [xtensor-blas][6]: the counterpart to the numpy.linalg module. + +* [xtensor-fftw][7]: bindings to the [fftw][8] library. + +* [xtensor-io][9]: APIs to read and write various file formats (images, audio, NumPy's NPZ format). + +* [xtensor-ros][10]: bindings for ROS, the robot operating system. + +* [xtensor-python][11]: bindings for the Python programming language, allowing the use of NumPy arrays in-place, using the NumPy C API and the pybind11 library. + +* [xtensor-julia][12]: bindings for the Julia programming language, allowing the use of Julia arrays in-place, using the C API of the Julia interpreter, and the CxxWrap library. + +* [xtensor-r][13]: bindings for the R programming language, allowing the use of R arrays in-place. + +Detailing further the features of the xtensor framework would be beyond the scope of this post. + +If you are interested in trying the various notebooks presented in this post, there is no need to install anything. You can just use  _binder_ : + +![](https://cdn-images-1.medium.com/max/1200/1*9cy5Mns_I0eScsmDBjvxDQ.png) + +[The Binder project][31], which is part of Project Jupyter, enables the deployment of containerized Jupyter notebooks, from a GitHub repository together with a manifest listing the dependencies (as conda packages). + +All the notebooks in the screenshots above can be run online, by just clicking on one of the following links: + +[xtensor][32]: the C++ N-D array expression library in a C++ notebook + +[xwidgets][33]: the C++ back-end for Jupyter interactive widgets + +[xplot][34]: the C++ back-end to the bqplot 2-D plotting library for Jupyter. + + + +![](https://cdn-images-1.medium.com/max/1200/1*JwqhpMxMJppEepj7U4fV-g.png) + +[JupyterHub][35] is the multi-user infrastructure underlying open wide deployments of Jupyter like Binder but also smaller deployments for authenticated users. + +The modular architecture of JupyterHub enables a great variety of scenarios on how users are authenticated, and what service is made available to them. JupyterHub deployment for several hundreds of users have been done in various universities and institutions, including the Paris-Sud University, where the C++ kernel was also installed for the students to use. + +> In September 2017, the 350 first-year students at Paris-Sud University who took the “[Info 111: Introduction to Computer +>  Science][36]” class wrote their first lines of C++ in a Jupyter notebook. + +The use of Jupyter notebooks in the context of teaching C++ proved especially useful for the first classes, where students can focus on the syntax of the language without distractions such as compiling and linking. + +### Acknowledgements + +The software presented in this post was built upon the work of a large number of people including the Jupyter team and the Cling developers. + +We are especially grateful to [Patrick Bos ][37](who authored xtensor-fftw), Nicolas Thiéry, Min Ragan Kelley, Thomas Kluyver, Yuvi Panda, Kyle Cranmer, Axel Naumann and Vassil Vassilev. + +We thank the [DIANA/HEP][38] organization for supporting travel to CERN and encouraging the collaboration between Project Jupyter and the ROOT team. + +We are also grateful to the team at Paris-Sud University who worked on the JupyterHub deployment and the class materials, notably [Viviane Pons][39]. + +The development of xeus, xtensor, xwidgets and related packages at [QuantStack][40] is sponsored by [Bloomberg][41]. + +### About the authors (alphabetical order) + + [_Sylvain Corlay_][42] _, _ Scientific Software Developer at [QuantStack][43] + + [_Loic Gouarin_][44] _, _ Research Engineer at [Laboratoire de Mathématiques at Orsay][45] + + [_Johan Mabille_][46] _, _ Scientific Software Developer at [QuantStack][47] + + [_Wolf Vollprecht_][48] , Scientific Software Developer at [QuantStack][49] + +Thanks to [Maarten Breddels][50], [Wolf Vollprecht][51], [Brian E. Granger][52], and [Patrick Bos][53]. + +-------------------------------------------------------------------------------- + +via: https://blog.jupyter.org/interactive-workflows-for-c-with-jupyter-fe9b54227d92 + +作者:[QuantStack ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://blog.jupyter.org/@QuantStack?source=post_header_lockup +[1]:https://github.com/bloomberg/bqplot +[2]:https://github.com/jovyan/pythreejs +[3]:https://github.com/ellisonbg/ipyleaflet +[4]:https://github.com/maartenbreddels/ipyvolume +[5]:https://github.com/arose/nglview +[6]:https://github.com/QuantStack/xtensor-blas +[7]:https://github.com/egpbos/xtensor-fftw +[8]:http://www.fftw.org/ +[9]:https://github.com/QuantStack/xtensor-io +[10]:https://github.com/wolfv/xtensor_ros +[11]:https://github.com/QuantStack/xtensor-python +[12]:https://github.com/QuantStack/Xtensor.jl +[13]:https://github.com/QuantStack/xtensor-r +[14]:https://github.com/jupyter/jupyter/wiki/Jupyter-kernels +[15]:https://github.com/ipython/ipykernel +[16]:https://github.com/JuliaLang/IJulia.jl +[17]:https://github.com/QuantStack/xeus +[18]:https://root.cern.ch/cling +[19]:https://root.cern.ch/ +[20]:https://github.com/QuantStack/xeus-cling +[21]:http://en.cppreference.com/w/ +[22]:http://jupyter.org/widgets +[23]:https://github.com/QUantStack/xwidgets +[24]:https://github.com/QuantStack/xplot +[25]:https://github.com/bloomberg/bqplot +[26]:https://dl.acm.org/citation.cfm?id=1088896 +[27]:http://www.numpy.org/ +[28]:https://pandas.pydata.org/ +[29]:https://github.com/QuantStack/xtensor/ +[30]:http://xtensor.readthedocs.io/en/latest/numpy.html +[31]:https://mybinder.org/ +[32]:https://beta.mybinder.org/v2/gh/QuantStack/xtensor/0.14.0-binder2?filepath=notebooks/xtensor.ipynb +[33]:https://beta.mybinder.org/v2/gh/QuantStack/xwidgets/0.6.0-binder?filepath=notebooks/xwidgets.ipynb +[34]:https://beta.mybinder.org/v2/gh/QuantStack/xplot/0.3.0-binder?filepath=notebooks +[35]:https://github.com/jupyterhub/jupyterhub +[36]:http://nicolas.thiery.name/Enseignement/Info111/ +[37]:https://twitter.com/egpbos +[38]:http://diana-hep.org/ +[39]:https://twitter.com/pyviv +[40]:https://twitter.com/QuantStack +[41]:http://www.techatbloomberg.com/ +[42]:https://twitter.com/SylvainCorlay +[43]:https://github.com/QuantStack/ +[44]:https://twitter.com/lgouarin +[45]:https://www.math.u-psud.fr/ +[46]:https://twitter.com/johanmabille?lang=en +[47]:https://github.com/QuantStack/ +[48]:https://twitter.com/wuoulf +[49]:https://github.com/QuantStack/ +[50]:https://medium.com/@maartenbreddels?source=post_page +[51]:https://medium.com/@wolfv?source=post_page +[52]:https://medium.com/@ellisonbg?source=post_page +[53]:https://medium.com/@egpbos?source=post_page From bcb3b04a0a049743df212d0f866099ee4bee3519 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:20:55 +0800 Subject: [PATCH 146/344] =?UTF-8?q?20171203-17=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20171203 How do groups work on Linux.md | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 sources/tech/20171203 How do groups work on Linux.md diff --git a/sources/tech/20171203 How do groups work on Linux.md b/sources/tech/20171203 How do groups work on Linux.md new file mode 100644 index 0000000000..503f83d1d9 --- /dev/null +++ b/sources/tech/20171203 How do groups work on Linux.md @@ -0,0 +1,141 @@ +How do groups work on Linux? +============================================================ + +Hello! Last week, I thought I knew how users and groups worked on Linux. Here is what I thought: + +1. Every process belongs to a user (like `julia`) + +2. When a process tries to read a file owned by a group, Linux a) checks if the user `julia` can access the file, and b) checks which groups `julia` belongs to, and whether any of those groups owns & can access that file + +3. If either of those is true (or if the ‘any’ bits are set right) then the process can access the file + +So, for example, if a process is owned by the `julia` user and `julia` is in the `awesome`group, then the process would be allowed to read this file. + +``` +r--r--r-- 1 root awesome 6872 Sep 24 11:09 file.txt + +``` + +I had not thought carefully about this, but if pressed I would have said that it probably checks the `/etc/group` file at runtime to see what groups you’re in. + +### that is not how groups work + +I found out at work last week that, no, what I describe above is not how groups work. In particular Linux does **not** check which groups a process’s user belongs to every time that process tries to access a file. + +Here is how groups actually work! I learned this by reading Chapter 9 (“Process Credentials”) of [The Linux Programming Interface][1] which is an incredible book. As soon as I realized that I did not understand how users and groups worked, I opened up the table of contents with absolute confidence that it would tell me what’s up, and I was right. + +### how users and groups checks are done + +They key new insight for me was pretty simple! The chapter starts out by saying that user and group IDs are **attributes of the process**: + +* real user ID and group ID; + +* effective user ID and group ID; + +* saved set-user-ID and saved set-group-ID; + +* file-system user ID and group ID (Linux-specific); and + +* supplementary group IDs. + +This means that the way Linux **actually** does group checks to see a process can read a file is: + +* look at the process’s group IDs & supplementary group IDs (from the attributes on the process, **not** by looking them up in `/etc/group`) + +* look at the group on the file + +* see if they match + +Generally when doing access control checks it uses the **effective** user/group ID, not the real user/group ID. Technically when accessing a file it actually uses the **file-system** ids but those are usually the same as the effective uid/gid. + +### Adding a user to a group doesn’t put existing processes in that group + +Here’s another fun example that follows from this: if I create a new `panda` group and add myself (bork) to it, then run `groups` to check my group memberships – I’m not in the panda group! + +``` +bork@kiwi~> sudo addgroup panda +Adding group `panda' (GID 1001) ... +Done. +bork@kiwi~> sudo adduser bork panda +Adding user `bork' to group `panda' ... +Adding user bork to group panda +Done. +bork@kiwi~> groups +bork adm cdrom sudo dip plugdev lpadmin sambashare docker lxd + +``` + +no `panda` in that list! To double check, let’s try making a file owned by the `panda`group and see if I can access it: + +``` +$ touch panda-file.txt +$ sudo chown root:panda panda-file.txt +$ sudo chmod 660 panda-file.txt +$ cat panda-file.txt +cat: panda-file.txt: Permission denied + +``` + +Sure enough, I can’t access `panda-file.txt`. No big surprise there. My shell didn’t have the `panda` group as a supplementary GID before, and running `adduser bork panda` didn’t do anything to change that. + +### how do you get your groups in the first place? + +So this raises kind of a confusing question, right – if processes have groups baked into them, how do you get assigned your groups in the first place? Obviously you can’t assign yourself more groups (that would defeat the purpose of access control). + +It’s relatively clear how processes I **execute** from my shell (bash/fish) get their groups – my shell runs as me, and it has a bunch of group IDs on it. Processes I execute from my shell are forked from the shell so they get the same groups as the shell had. + +So there needs to be some “first” process that has your groups set on it, and all the other processes you set inherit their groups from that. That process is called your **login shell**and it’s run by the `login` program (`/bin/login`) on my laptop. `login` runs as root and calls a C function called `initgroups` to set up your groups (by reading `/etc/group`). It’s allowed to set up your groups because it runs as root. + +### let’s try logging in again! + +So! Let’s say I am running in a shell, and I want to refresh my groups! From what we’ve learned about how groups are initialized, I should be able to run `login` to refresh my groups and start a new login shell! + +Let’s try it: + +``` +$ sudo login bork +$ groups +bork adm cdrom sudo dip plugdev lpadmin sambashare docker lxd panda +$ cat panda-file.txt # it works! I can access the file owned by `panda` now! + +``` + +Sure enough, it works! Now the new shell that `login` spawned is part of the `panda`group! Awesome! This won’t affect any other shells I already have running. If I really want the new `panda` group everywhere, I need to restart my login session completely, which means quitting my window manager and logging in again. + +### newgrp + +Somebody on Twitter told me that if you want to start a new shell with a new group that you’ve been added to, you can use `newgrp`. Like this: + +``` +sudo addgroup panda +sudo adduser bork panda +newgrp panda # starts a new shell, and you don't have to be root to run it! + +``` + +You can accomplish the same(ish) thing with `sg panda bash` which will start a `bash`shell that runs with the `panda` group. + +### setuid sets the effective user ID + +I’ve also always been a little vague about what it means for a process to run as “setuid root”. It turns out that setuid sets the effective user ID! So if I (`julia`) run a setuid root process (like `passwd`), then the **real** user ID will be set to `julia`, and the **effective** user ID will be set to `root`. + +`passwd` needs to run as root, but it can look at its real user ID to see that `julia` started the process, and prevent `julia` from editing any passwords except for `julia`’s password. + +### that’s all! + +There are a bunch more details about all the edge cases and exactly how everything works in The Linux Programming Interface so I will not get into all the details here. That book is amazing. Everything I talked about in this post is from Chapter 9, which is a 17-page chapter inside a 1300-page book. + +The thing I love most about that book is that reading 17 pages about how users and groups work is really approachable, self-contained, super useful, and I don’t have to tackle all 1300 pages of it at once to learn helpful things :) + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/11/20/groups/ + +作者:[Julia Evans ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/about +[1]:http://man7.org/tlpi/ From b2f7a3953dab5943e4c03d808aa4acaceb6a06b9 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:23:24 +0800 Subject: [PATCH 147/344] =?UTF-8?q?20171203-18=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... write fun small web projects instantly.md | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 sources/tech/20171113 Glitch write fun small web projects instantly.md diff --git a/sources/tech/20171113 Glitch write fun small web projects instantly.md b/sources/tech/20171113 Glitch write fun small web projects instantly.md new file mode 100644 index 0000000000..bfed5b9a0b --- /dev/null +++ b/sources/tech/20171113 Glitch write fun small web projects instantly.md @@ -0,0 +1,74 @@ +Glitch: write fun small web projects instantly +============================================================ + +I just wrote about Jupyter Notebooks which are a fun interactive way to write Python code. That reminded me I learned about Glitch recently, which I also love!! I built a small app to [turn of twitter retweets][2] with it. So! + +[Glitch][3] is an easy way to make Javascript webapps. (javascript backend, javascript frontend) + +The fun thing about glitch is: + +1. you start typing Javascript code into their web interface + +2. as soon as you type something, it automagically reloads the backend of your website with the new code. You don’t even have to save!! It autosaves. + +So it’s like Heroku, but even more magical!! Coding like this (you type, and the code runs on the public internet immediately) just feels really **fun** to me. + +It’s kind of like sshing into a server and editing PHP/HTML code on your server and having it instantly available, which I kind of also loved. Now we have “better deployment practices” than “just edit the code and it is instantly on the internet” but we are not talking about Serious Development Practices, we are talking about writing tiny programs for fun. + +### glitch has awesome example apps + +Glitch seems like fun nice way to learn programming! + +For example, there’s a space invaders game (code by [Mary Rose Cook][4]) at [https://space-invaders.glitch.me/][5]. The thing I love about this is that in just a few clicks I can + +1. click “remix this” + +2. start editing the code to make the boxes orange instead of black + +3. have my own space invaders game!! Mine is at [http://julias-space-invaders.glitch.me/][1]. (i just made very tiny edits to make it orange, nothing fancy) + +They have tons of example apps that you can start from – for instance [bots][6], [games][7], and more. + +### awesome actually useful app: tweetstorms + +The way I learned about Glitch was from this app which shows you tweetstorms from a given user: [https://tweetstorms.glitch.me/][8]. + +For example, you can see [@sarahmei][9]’s tweetstorms at [https://tweetstorms.glitch.me/sarahmei][10] (she tweets a lot of good tweetstorms!). + +### my glitch app: turn off retweets + +When I learned about Glitch I wanted to turn off retweets for everyone I follow on Twitter (I know you can do it in Tweetdeck!) and doing it manually was a pain – I had to do it one person at a time. So I wrote a tiny Glitch app to do it for me! + +I liked that I didn’t have to set up a local development environment, I could just start typing and go! + +Glitch only supports Javascript and I don’t really know Javascript that well (I think I’ve never written a Node program before), so the code isn’t awesome. But I had a really good time writing it – being able to type and just see my code running instantly was delightful. Here it is: [https://turn-off-retweets.glitch.me/][11]. + +### that’s all! + +Using Glitch feels really fun and democratic. Usually if I want to fork someone’s web project and make changes I wouldn’t do it – I’d have to fork it, figure out hosting, set up a local dev environment or Heroku or whatever, install the dependencies, etc. I think tasks like installing node.js dependencies used to be interesting, like “cool i am learning something new” and now I just find them tedious. + +So I love being able to just click “remix this!” and have my version on the internet instantly. + + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/11/13/glitch--write-small-web-projects-easily/ + +作者:[Julia Evans ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/ +[1]:http://julias-space-invaders.glitch.me/ +[2]:https://turn-off-retweets.glitch.me/ +[3]:https://glitch.com/ +[4]:https://maryrosecook.com/ +[5]:https://space-invaders.glitch.me/ +[6]:https://glitch.com/handy-bots +[7]:https://glitch.com/games +[8]:https://tweetstorms.glitch.me/ +[9]:https://twitter.com/sarahmei +[10]:https://tweetstorms.glitch.me/sarahmei +[11]:https://turn-off-retweets.glitch.me/ From cb6e94e201f96d7b4f16dedb4cdfd12ae7c17e80 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:25:02 +0800 Subject: [PATCH 148/344] =?UTF-8?q?20171203-19=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...71010 \tOperating a Kubernetes network.md" | 216 ++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 "sources/tech/20171010 \tOperating a Kubernetes network.md" diff --git "a/sources/tech/20171010 \tOperating a Kubernetes network.md" "b/sources/tech/20171010 \tOperating a Kubernetes network.md" new file mode 100644 index 0000000000..9c85e9aa70 --- /dev/null +++ "b/sources/tech/20171010 \tOperating a Kubernetes network.md" @@ -0,0 +1,216 @@ +Operating a Kubernetes network +============================================================ + +I’ve been working on Kubernetes networking a lot recently. One thing I’ve noticed is, while there’s a reasonable amount written about how to **set up** your Kubernetes network, I haven’t seen much about how to **operate** your network and be confident that it won’t create a lot of production incidents for you down the line. + +In this post I’m going to try to convince you of three things: (all I think pretty reasonable :)) + +* Avoiding networking outages in production is important + +* Operating networking software is hard + +* It’s worth thinking critically about major changes to your networking infrastructure and the impact that will have on your reliability, even if very fancy Googlers say “this is what we do at Google”. (google engineers are doing great work on Kubernetes!! But I think it’s important to still look at the architecture and make sure it makes sense for your organization.) + +I’m definitely not a Kubernetes networking expert by any means, but I have run into a few issues while setting things up and definitely know a LOT more about Kubernetes networking than I used to. + +### Operating networking software is hard + +Here I’m not talking about operating physical networks (I don’t know anything about that), but instead about keeping software like DNS servers & load balancers & proxies working correctly. + +I have been working on a team that’s responsible for a lot of networking infrastructure for a year, and I have learned a few things about operating networking infrastructure! (though I still have a lot to learn obviously). 3 overall thoughts before we start: + +* Networking software often relies very heavily on the Linux kernel. So in addition to configuring the software correctly you also need to make sure that a bunch of different sysctls are set correctly, and a misconfigured sysctl can easily be the difference between “everything is 100% fine” and “everything is on fire”. + +* Networking requirements change over time (for example maybe you’re doing 5x more DNS lookups than you were last year! Maybe your DNS server suddenly started returning TCP DNS responses instead of UDP which is a totally different kernel workload!). This means software that was working fine before can suddenly start having issues. + +* To fix a production networking issues you often need a lot of expertise. (for example see this [great post by Sophie Haskins on debugging a kube-dns issue][1]) I’m a lot better at debugging networking issues than I was, but that’s only after spending a huge amount of time investing in my knowledge of Linux networking. + +I am still far from an expert at networking operations but I think it seems important to: + +1. Very rarely make major changes to the production networking infrastructure (because it’s super disruptive) + +2. When you  _are_  making major changes, think really carefully about what the failure modes are for the new network architecture are + +3. Have multiple people who are able to understand your networking setup + +Switching to Kubernetes is obviously a pretty major networking change! So let’s talk about what some of the things that can go wrong are! + +### Kubernetes networking components + +The Kubernetes networking components we’re going to talk about in this post are: + +* Your overlay network backend (like flannel/calico/weave net/romana) + +* `kube-dns` + +* `kube-proxy` + +* Ingress controllers / load balancers + +* The `kubelet` + +If you’re going to set up HTTP services you probably need all of these. I’m not using most of these components yet but I’m trying to understand them, so that’s what this post is about. + +### The simplest way: Use host networking for all your containers + +Let’s start with the simplest possible thing you can do. This won’t let you run HTTP services in Kubernetes. I think it’s pretty safe because there are less moving parts. + +If you use host networking for all your containers I think all you need to do is: + +1. Configure the kubelet to configure DNS correctly inside your containers + +2. That’s it + +If you use host networking for literally every pod you don’t need kube-dns or kube-proxy. You don’t even need a working overlay network. + +In this setup your pods can connect to the outside world (the same way any process on your hosts would talk to the outside world) but the outside world can’t connect to your pods. + +This isn’t super important (I think most people want to run HTTP services inside Kubernetes and actually communicate with those services) but I do think it’s interesting to realize that at some level all of this networking complexity isn’t strictly required and sometimes you can get away without using it. Avoiding networking complexity seems like a good idea to me if you can. + +### Operating an overlay network + +The first networking component we’re going to talk about is your overlay network. Kubernetes assumes that every pod has an IP address and that you can communicate with services inside that pod by using that IP address. When I say “overlay network” this is what I mean (“the system that lets you refer to a pod by its IP address”). + +All other Kubernetes networking stuff relies on the overlay networking working correctly. You can read more about the [kubernetes networking model here][10]. + +The way Kelsey Hightower describes in [kubernetes the hard way][11] seems pretty good but it’s not really viable on AWS for clusters more than 50 nodes or so, so I’m not going to talk about that. + +There are a lot of overlay network backends (calico, flannel, weaveworks, romana) and the landscape is pretty confusing. But as far as I’m concerned an overlay network has 2 responsibilities: + +1. Make sure your pods can send network requests outside your cluster + +2. Keep a stable mapping of nodes to subnets and keep every node in your cluster updated with that mapping. Do the right thing when nodes are added & removed. + +Okay! So! What can go wrong with your overlay network? + +* The overlay network is responsible for setting up iptables rules (basically `iptables -A -t nat POSTROUTING -s $SUBNET -j MASQUERADE`) to ensure that containers can make network requests outside Kubernetes. If something goes wrong with this rule then your containers can’t connect to the external network. This isn’t that hard (it’s just a few iptables rules) but it is important. I made a [pull request][2] because I wanted to make sure this was resilient + +* Something can go wrong with adding or deleting nodes. We’re using the flannel hostgw backend and at the time we started using it, node deletion [did not work][3]. + +* Your overlay network is probably dependent on a distributed database (etcd). If that database has an incident, this can cause issues. For example [https://github.com/coreos/flannel/issues/610][4] says that if you have data loss in your flannel etcd cluster it can result in containers losing network connectivity. (this has now been fixed) + +* You upgrade Docker and everything breaks + +* Probably more things! + +I’m mostly talking about past issues in Flannel here but I promise I’m not picking on Flannel – I actually really **like** Flannel because I feel like it’s relatively simple (for instance the [vxlan backend part of it][12] is like 500 lines of code) and I feel like it’s possible for me to reason through any issues with it. And it’s obviously continuously improving. They’ve been great about reviewing pull requests. + +My approach to operating an overlay network so far has been: + +* Learn how it works in detail and how to debug it (for example the hostgw network backend for Flannel works by creating routes, so you mostly just need to do `sudo ip route list` to see whether it’s doing the correct thing) + +* Maintain an internal build so it’s easy to patch it if needed + +* When there are issues, contribute patches upstream + +I think it’s actually really useful to go through the list of merged PRs and see bugs that have been fixed in the past – it’s a bit time consuming but is a great way to get a concrete list of kinds of issues other people have run into. + +It’s possible that for other people their overlay networks just work but that hasn’t been my experience and I’ve heard other folks report similar issues. If you have an overlay network setup that is a) on AWS and b) works on a cluster more than 50-100 nodes where you feel more confident about operating it I would like to know. + +### Operating kube-proxy and kube-dns? + +Now that we have some thoughts about operating overlay networks, let’s talk about + +There’s a question mark next to this one because I haven’t done this. Here I have more questions than answers. + +Here’s how Kubernetes services work! A service is a collection of pods, which each have their own IP address (like 10.1.0.3, 10.2.3.5, 10.3.5.6) + +1. Every Kubernetes service gets an IP address (like 10.23.1.2) + +2. `kube-dns` resolves Kubernetes service DNS names to IP addresses (so my-svc.my-namespace.svc.cluster.local might map to 10.23.1.2) + +3. `kube-proxy` sets up iptables rules in order to do random load balancing between them. Kube-proxy also has a userspace round-robin load balancer but my impression is that they don’t recommend using it. + +So when you make a request to `my-svc.my-namespace.svc.cluster.local`, it resolves to 10.23.1.2, and then iptables rules on your local host (generated by kube-proxy) redirect it to one of 10.1.0.3 or 10.2.3.5 or 10.3.5.6 at random. + +Some things that I can imagine going wrong with this: + +* `kube-dns` is misconfigured + +* `kube-proxy` dies and your iptables rules don’t get updated + +* Some issue related to maintaining a large number of iptables rules + +Let’s talk about the iptables rules a bit, since doing load balancing by creating a bajillion iptables rules is something I had never heard of before! + +kube-proxy creates one iptables rule per target host like this: (these rules are from [this github issue][13]) + +``` +-A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -m statistic --mode random --probability 0.20000000019 -j KUBE-SEP-E4QKA7SLJRFZZ2DD[b][c] +-A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -m statistic --mode random --probability 0.25000000000 -j KUBE-SEP-LZ7EGMG4DRXMY26H +-A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -m statistic --mode random --probability 0.33332999982 -j KUBE-SEP-RKIFTWKKG3OHTTMI +-A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-CGDKBCNM24SZWCMS +-A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -j KUBE-SEP-RI4SRNQQXWSTGE2Y + +``` + +So kube-proxy creates a **lot** of iptables rules. What does that mean? What are the implications of that in for my network? There’s a great talk from Huawei called [Scale Kubernetes to Support 50,000 services][14] that says if you have 5,000 services in your kubernetes cluster, it takes **11 minutes** to add a new rule. If that happened to your real cluster I think it would be very bad. + +I definitely don’t have 5,000 services in my cluster, but 5,000 isn’t SUCH a bit number. The proposal they give to solve this problem is to replace this iptables backend for kube-proxy with IPVS which is a load balancer that lives in the Linux kernel. + +It seems like kube-proxy is going in the direction of various Linux kernel based load balancers. I think this is partly because they support UDP load balancing, and other load balancers (like HAProxy) don’t support UDP load balancing. + +But I feel comfortable with HAProxy! Is it possible to replace kube-proxy with HAProxy! I googled this and I found this [thread on kubernetes-sig-network][15] saying: + +> kube-proxy is so awesome, we have used in production for almost a year, it works well most of time, but as we have more and more services in our cluster, we found it was getting hard to debug and maintain. There is no iptables expert in our team, we do have HAProxy&LVS experts, as we have used these for several years, so we decided to replace this distributed proxy with a centralized HAProxy. I think this maybe useful for some other people who are considering using HAProxy with kubernetes, so we just update this project and make it open source: [https://github.com/AdoHe/kube2haproxy][5]. If you found it’s useful , please take a look and give a try. + +So that’s an interesting option! I definitely don’t have answers here, but, some thoughts: + +* Load balancers are complicated + +* DNS is also complicated + +* If you already have a lot of experience operating one kind of load balancer (like HAProxy), it might make sense to do some extra work to use that instead of starting to use an entirely new kind of load balancer (like kube-proxy) + +* I’ve been thinking about where we want to be using kube-proxy or kube-dns at all – I think instead it might be better to just invest in Envoy and rely entirely on Envoy for all load balancing & service discovery. So then you just need to be good at operating Envoy. + +As you can see my thoughts on how to operate your Kubernetes internal proxies are still pretty confused and I’m still not super experienced with them. It’s totally possible that kube-proxy and kube-dns are fine and that they will just work fine but I still find it helpful to think through what some of the implications of using them are (for example “you can’t have 5,000 Kubernetes services”). + +### Ingress + +If you’re running a Kubernetes cluster, it’s pretty likely that you actually need HTTP requests to get into your cluster so far. This blog post is already too long and I don’t know much about ingress yet so we’re not going to talk about that. + +### Useful links + +A couple of useful links, to summarize: + +* [The Kubernetes networking model][6] + +* How GKE networking works: [https://www.youtube.com/watch?v=y2bhV81MfKQ][7] + +* The aforementioned talk on `kube-proxy` performance: [https://www.youtube.com/watch?v=4-pawkiazEg][8] + +### I think networking operations is important + +My sense of all this Kubernetes networking software is that it’s all still quite new and I’m not sure we (as a community) really know how to operate all of it well. This makes me worried as an operator because I really want my network to keep working! :) Also I feel like as an organization running your own Kubernetes cluster you need to make a pretty large investment into making sure you understand all the pieces so that you can fix things when they break. Which isn’t a bad thing, it’s just a thing. + +My plan right now is just to keep learning about how things work and reduce the number of moving parts I need to worry about as much as possible. + +As usual I hope this was helpful and I would very much like to know what I got wrong in this post! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/10/10/operating-a-kubernetes-network/ + +作者:[Julia Evans ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/about +[1]:http://blog.sophaskins.net/blog/misadventures-with-kube-dns/ +[2]:https://github.com/coreos/flannel/pull/808 +[3]:https://github.com/coreos/flannel/pull/803 +[4]:https://github.com/coreos/flannel/issues/610 +[5]:https://github.com/AdoHe/kube2haproxy +[6]:https://kubernetes.io/docs/concepts/cluster-administration/networking/#kubernetes-model +[7]:https://www.youtube.com/watch?v=y2bhV81MfKQ +[8]:https://www.youtube.com/watch?v=4-pawkiazEg +[9]:https://jvns.ca/categories/kubernetes +[10]:https://kubernetes.io/docs/concepts/cluster-administration/networking/#kubernetes-model +[11]:https://github.com/kelseyhightower/kubernetes-the-hard-way/blob/master/docs/11-pod-network-routes.md +[12]:https://github.com/coreos/flannel/tree/master/backend/vxlan +[13]:https://github.com/kubernetes/kubernetes/issues/37932 +[14]:https://www.youtube.com/watch?v=4-pawkiazEg +[15]:https://groups.google.com/forum/#!topic/kubernetes-sig-network/3NlBVbTUUU0 From 04548977807f160d3b53b1cd2c2adfdaab9ec928 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:27:45 +0800 Subject: [PATCH 149/344] =?UTF-8?q?20171203-19=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20171005 Reasons Kubernetes is cool.md | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 sources/tech/20171005 Reasons Kubernetes is cool.md diff --git a/sources/tech/20171005 Reasons Kubernetes is cool.md b/sources/tech/20171005 Reasons Kubernetes is cool.md new file mode 100644 index 0000000000..a9d10b9cdb --- /dev/null +++ b/sources/tech/20171005 Reasons Kubernetes is cool.md @@ -0,0 +1,148 @@ +Reasons Kubernetes is cool +============================================================ + +When I first learned about Kubernetes (a year and a half ago?) I really didn’t understand why I should care about it. + +I’ve been working full time with Kubernetes for 3 months or so and now have some thoughts about why I think it’s useful. (I’m still very far from being a Kubernetes expert!) Hopefully this will help a little in your journey to understand what even is going on with Kubernetes! + +I will try to explain some reason I think Kubenetes is interesting without using the words “cloud native”, “orchestration”, “container”, or any Kubernetes-specific terminology :). I’m going to explain this mostly from the perspective of a kubernetes operator / infrastructure engineer, since my job right now is to set up Kubernetes and make it work well. + +I’m not going to try to address the question of “should you use kubernetes for your production systems?” at all, that is a very complicated question. (not least because “in production” has totally different requirements depending on what you’re doing) + +### Kubernetes lets you run code in production without setting up new servers + +The first pitch I got for Kubernetes was the following conversation with my partner Kamal: + +Here’s an approximate transcript: + +* Kamal: With Kubernetes you can set up a new service with a single command + +* Julia: I don’t understand how that’s possible. + +* Kamal: Like, you just write 1 configuration file, apply it, and then you have a HTTP service running in production + +* Julia: But today I need to create new AWS instances, write a puppet manifest, set up service discovery, configure my load balancers, configure our deployment software, and make sure DNS is working, it takes at least 4 hours if nothing goes wrong. + +* Kamal: Yeah. With Kubernetes you don’t have to do any of that, you can set up a new HTTP service in 5 minutes and it’ll just automatically run. As long as you have spare capacity in your cluster it just works! + +* Julia: There must be a trap + +There kind of is a trap, setting up a production Kubernetes cluster is (in my experience) is definitely not easy. (see [Kubernetes The Hard Way][3] for what’s involved to get started). But we’re not going to go into that right now! + +So the first cool thing about Kubernetes is that it has the potential to make life way easier for developers who want to deploy new software into production. That’s cool, and it’s actually true, once you have a working Kubernetes cluster you really can set up a production HTTP service (“run 5 of this application, set up a load balancer, give it this DNS name, done”) with just one configuration file. It’s really fun to see. + +### Kubernetes gives you easy visibility & control of what code you have running in production + +IMO you can’t understand Kubernetes without understanding etcd. So let’s talk about etcd! + +Imagine that I asked you today “hey, tell me every application you have running in production, what host it’s running on, whether it’s healthy or not, and whether or not it has a DNS name attached to it”. I don’t know about you but I would need to go look in a bunch of different places to answer this question and it would take me quite a while to figure out. I definitely can’t query just one API. + +In Kubernetes, all the state in your cluster – applications running (“pods”), nodes, DNS names, cron jobs, and more – is stored in a single database (etcd). Every Kubernetes component is stateless, and basically works by + +* Reading state from etcd (eg “the list of pods assigned to node 1”) + +* Making changes (eg “actually start running pod A on node 1”) + +* Updating the state in etcd (eg “set the state of pod A to ‘running’”) + +This means that if you want to answer a question like “hey, how many nginx pods do I have running right now in that availabliity zone?” you can answer it by querying a single unified API (the Kubernetes API!). And you have exactly the same access to that API that every other Kubernetes component does. + +This also means that you have easy control of everything running in Kubernetes. If you want to, say, + +* Implement a complicated custom rollout strategy for deployments (deploy 1 thing, wait 2 minutes, deploy 5 more, wait 3.7 minutes, etc) + +* Automatically [start a new webserver][1] every time a branch is pushed to github + +* Monitor all your running applications to make sure all of them have a reasonable cgroups memory limit + +all you need to do is to write a program that talks to the Kubernetes API. (a “controller”) + +Another very exciting thing about the Kubernetes API is that you’re not limited to just functionality that Kubernetes provides! If you decide that you have your own opinions about how your software should be deployed / created / monitored, then you can write code that uses the Kubernetes API to do it! It lets you do everything you need. + +### If every Kubernetes component dies, your code will still keep running + +One thing I was originally promised (by various blog posts :)) about Kubernetes was “hey, if the Kubernetes apiserver and everything else dies, it’s ok, your code will just keep running”. I thought this sounded cool in theory but I wasn’t sure if it was actually true. + +So far it seems to be actually true! + +I’ve been through some etcd outages now, and what happens is + +1. All the code that was running keeps running + +2. Nothing  _new_  happens (you can’t deploy new code or make changes, cron jobs will stop working) + +3. When everything comes back, the cluster will catch up on whatever it missed + +This does mean that if etcd goes down and one of your applications crashes or something, it can’t come back up until etcd returns. + +### Kubernetes’ design is pretty resilient to bugs + +Like any piece of software, Kubernetes has bugs. For example right now in our cluster the controller manager has a memory leak, and the scheduler crashes pretty regularly. Bugs obviously aren’t good but so far I’ve found that Kubernetes’ design helps mitigate a lot of the bugs in its core components really well. + +If you restart any component, what happens is: + +* It reads all its relevant state from etcd + +* It starts doing the necessary things it’s supposed to be doing based on that state (scheduling pods, garbage collecting completed pods, scheduling cronjobs, deploying daemonsets, whatever) + +Because all the components don’t keep any state in memory, you can just restart them at any time and that can help mitigate a variety of bugs. + +For example! Let’s say you have a memory leak in your controller manager. Because the controller manager is stateless, you can just periodically restart it every hour or something and feel confident that you won’t cause any consistency issues. Or we ran into a bug in the scheduler where it would sometimes just forget about pods and never schedule them. You can sort of mitigate this just by restarting the scheduler every 10 minutes. (we didn’t do that, we fixed the bug instead, but you  _could_  :) ) + +So I feel like I can trust Kubernetes’ design to help make sure the state in the cluster is consistent even when there are bugs in its core components. And in general I think the software is generally improving over time. The only stateful thing you have to operate is etcd + +Not to harp on this “state” thing too much but – I think it’s cool that in Kubernetes the only thing you have to come up with backup/restore plans for is etcd (unless you use persistent volumes for your pods). I think it makes kubernetes operations a lot easier to think about. + +### Implementing new distributed systems on top of Kubernetes is relatively easy + +Suppose you want to implement a distributed cron job scheduling system! Doing that from scratch is a ton of work. But implementing a distributed cron job scheduling system inside Kubernetes is much easier! (still not trivial, it’s still a distributed system) + +The first time I read the code for the Kubernetes cronjob controller I was really delighted by how simple it was. Here, go read it! The main logic is like 400 lines of Go. Go ahead, read it! => [cronjob_controller.go][4] <= + +Basically what the cronjob controller does is: + +* Every 10 seconds: + * Lists all the cronjobs that exist + + * Checks if any of them need to run right now + + * If so, creates a new Job object to be scheduled & actually run by other Kubernetes controllers + + * Clean up finished jobs + + * Repeat + +The Kubernetes model is pretty constrained (it has this pattern of resources are defined in etcd, controllers read those resources and update etcd), and I think having this relatively opinionated/constrained model makes it easier to develop your own distributed systems inside the Kubernetes framework. + +Kamal introduced me to this idea of “Kubernetes is a good platform for writing your own distributed systems” instead of just “Kubernetes is a distributed system you can use” and I think it’s really interesting. He has a prototype of a [system to run an HTTP service for every branch you push to github][5]. It took him a weekend and is like 800 lines of Go, which I thought was impressive! + +### Kubernetes lets you do some amazing things (but isn’t easy) + +I started out by saying “kubernetes lets you do these magical things, you can just spin up so much infrastructure with a single configuration file, it’s amazing”. And that’s true! + +What I mean by “Kubernetes isn’t easy” is that Kubernetes has a lot of moving parts learning how to successfully operate a highly available Kubernetes cluster is a lot of work. Like I find that with a lot of the abstractions it gives me, I need to understand what is underneath those abstractions in order to debug issues and configure things properly. I love learning new things so this doesn’t make me angry or anything, I just think it’s important to know :) + +One specific example of “I can’t just rely on the abstractions” that I’ve struggled with is that I needed to learn a LOT [about how networking works on Linux][6] to feel confident with setting up Kubernetes networking, way more than I’d ever had to learn about networking before. This was very fun but pretty time consuming. I might write more about what is hard/interesting about setting up Kubernetes networking at some point. + +Or I wrote a [2000 word blog post][7] about everything I had to learn about Kubernetes’ different options for certificate authorities to be able to set up my Kubernetes CAs successfully. + +I think some of these managed Kubernetes systems like GKE (google’s kubernetes product) may be simpler since they make a lot of decisions for you but I haven’t tried any of them. + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/10/05/reasons-kubernetes-is-cool/ + +作者:[ Julia Evans][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/about +[1]:https://github.com/kamalmarhubi/kubereview +[2]:https://jvns.ca/categories/kubernetes +[3]:https://github.com/kelseyhightower/kubernetes-the-hard-way +[4]:https://github.com/kubernetes/kubernetes/blob/e4551d50e57c089aab6f67333412d3ca64bc09ae/pkg/controller/cronjob/cronjob_controller.go +[5]:https://github.com/kamalmarhubi/kubereview +[6]:https://jvns.ca/blog/2016/12/22/container-networking/ +[7]:https://jvns.ca/blog/2017/08/05/how-kubernetes-certificates-work/ From faf6c54a3b5c3833d24e97a476ffa38e215bf496 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:29:44 +0800 Subject: [PATCH 150/344] =?UTF-8?q?20171203-20=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20170910 Cool vim feature sessions.md | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 sources/tech/20170910 Cool vim feature sessions.md diff --git a/sources/tech/20170910 Cool vim feature sessions.md b/sources/tech/20170910 Cool vim feature sessions.md new file mode 100644 index 0000000000..8c0506e086 --- /dev/null +++ b/sources/tech/20170910 Cool vim feature sessions.md @@ -0,0 +1,44 @@ +Cool vim feature: sessions! +============================================================• + +Yesterday I learned about an awesome vim feature while working on my [vimrc][5]! (to add fzf & ripgrep search plugins mainly). It’s a builtin feature, no fancy plugins needed. + +So I drew a comic about it. + +Basically you can save all your open files and current state with + +``` +:mksession ~/.vim/sessions/foo.vim + +``` + +and then later restore it with either `:source ~/.vim/sessions/foo.vim` or `vim -S ~/.vim/sessions/foo.vim`. Super cool! + +Some vim plugins that add extra features to vim sessions: + +* [https://github.com/tpope/vim-obsession][1] + +* [https://github.com/mhinz/vim-startify][2] + +* [https://github.com/xolox/vim-session][3] + +Here’s the comic: + +![](https://jvns.ca/images/vimsessions.png) + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/09/10/vim-sessions/ + +作者:[Julia Evans ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/about +[1]:https://github.com/tpope/vim-obsession +[2]:https://github.com/mhinz/vim-startify +[3]:https://github.com/xolox/vim-session +[4]:https://jvns.ca/categories/vim +[5]:https://github.com/jvns/vimconfig/blob/master/vimrc From 82b925f3cda96476e297a2c10bc98d68d5026cb2 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:31:25 +0800 Subject: [PATCH 151/344] =?UTF-8?q?20171203-22=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ow to answer questions in a helpful way.md | 172 ++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 sources/tech/20170921 How to answer questions in a helpful way.md diff --git a/sources/tech/20170921 How to answer questions in a helpful way.md b/sources/tech/20170921 How to answer questions in a helpful way.md new file mode 100644 index 0000000000..8a3601ed06 --- /dev/null +++ b/sources/tech/20170921 How to answer questions in a helpful way.md @@ -0,0 +1,172 @@ +How to answer questions in a helpful way +============================================================ + +Your coworker asks you a slightly unclear question. How do you answer? I think asking questions is a skill (see [How to ask good questions][1]) and that answering questions in a helpful way is also a skill! Both of them are super useful. + +To start out with – sometimes the people asking you questions don’t respect your time, and that sucks. I’m assuming here throughout that that’s not what happening – we’re going to assume that the person asking you questions is a reasonable person who is trying their best to figure something out and that you want to help them out. Everyone I work with is like that and so that’s the world I live in :) + +Here are a few strategies for answering questions in a helpful way! + +### If they’re not asking clearly, help them clarify + +Often beginners don’t ask clear questions, or ask questions that don’t have the necessary information to answer the questions. Here are some strategies you can use to help them clarify. + +* **Rephrase a more specific question** back at them (“Are you asking X?”) + +* **Ask them for more specific information** they didn’t provide (“are you using IPv6?”) + +* **Ask what prompted their question**. For example, sometimes people come into my team’s channel with questions about how our service discovery works. Usually this is because they’re trying to set up/reconfigure a service. In that case it’s helpful to ask “which service are you working with? Can I see the pull request you’re working on?” + +A lot of these strategies come from the [how to ask good questions][2] post. (though I would never say to someone “oh you need to read this Document On How To Ask Good Questions before asking me a question”) + +### Figure out what they know already + +Before answering a question, it’s very useful to know what the person knows already! + +Harold Treen gave me a great example of this: + +> Someone asked me the other day to explain “Redux Sagas”. Rather than dive in and say “They are like worker threads that listen for actions and let you update the store!”  +> I started figuring out how much they knew about Redux, actions, the store and all these other fundamental concepts. From there it was easier to explain the concept that ties those other concepts together. + +Figuring out what your question-asker knows already is important because they may be confused about fundamental concepts (“What’s Redux?”), or they may be an expert who’s getting at a subtle corner case. An answer building on concepts they don’t know is confusing, and an answer that recaps things they know is tedious. + +One useful trick for asking what people know – instead of “Do you know X?”, maybe try “How familiar are you with X?”. + +### Point them to the documentation + +“RTFM” is the classic unhelpful answer to a question, but pointing someone to a specific piece of documentation can actually be really helpful! When I’m asking a question, I’d honestly rather be pointed to documentation that actually answers my question, because it’s likely to answer other questions I have too. + +I think it’s important here to make sure you’re linking to documentation that actually answers the question, or at least check in afterwards to make sure it helped. Otherwise you can end up with this (pretty common) situation: + +* Ali: How do I do X? + +* Jada: + +* Ali: That doesn’t actually explain how to X, it only explains Y! + +If the documentation I’m linking to is very long, I like to point out the specific part of the documentation I’m talking about. The [bash man page][3] is 44,000 words (really!), so just saying “it’s in the bash man page” is not that helpful :) + +### Point them to a useful search + +Often I find things at work by searching for some Specific Keyword that I know will find me the answer. That keyword might not be obvious to a beginner! So saying “this is the search I’d use to find the answer to that question” can be useful. Again, check in afterwards to make sure the search actually gets them the answer they need :) + +### Write new documentation + +People often come and ask my team the same questions over and over again. This is obviously not the fault of the people (how should  _they_  know that 10 people have asked this already, or what the answer is?). So we’re trying to, instead of answering the questions directly, + +1. Immediately write documentation + +2. Point the person to the new documentation we just wrote + +3. Celebrate! + +Writing documentation sometimes takes more time than just answering the question, but it’s often worth it! Writing documentation is especially worth it if: + +a. It’s a question which is being asked again and again b. The answer doesn’t change too much over time (if the answer changes every week or month, the documentation will just get out of date and be frustrating) + +### Explain what you did + +As a beginner to a subject, it’s really frustrating to have an exchange like this: + +* New person: “hey how do you do X?” + +* More Experienced Person: “I did it, it is done.” + +* New person: ….. but what did you DO?! + +If the person asking you is trying to learn how things work, it’s helpful to: + +* Walk them through how to accomplish a task instead of doing it yourself + +* Tell them the steps for how you got the answer you gave them! + +This might take longer than doing it yourself, but it’s a learning opportunity for the person who asked, so that they’ll be better equipped to solve such problems in the future. + +Then you can have WAY better exchanges, like this: + +* New person: “I’m seeing errors on the site, what’s happening?” + +* More Experienced Person: (2 minutes later) “oh that’s because there’s a database failover happening” + +* New person: how did you know that??!?!? + +* More Experienced Person: “Here’s what I did!”: + 1. Often these errors are due to Service Y being down. I looked at $PLACE and it said Service Y was up. So that wasn’t it. + + 2. Then I looked at dashboard X, and this part of that dashboard showed there was a database failover happening. + + 3. Then I looked in the logs for the service and it showed errors connecting to the database, here’s what those errors look like. + +If you’re explaining how you debugged a problem, it’s useful both to explain how you found out what the problem was, and how you found out what the problem wasn’t. While it might feel good to look like you knew the answer right off the top of your head, it feels even better to help someone improve at learning and diagnosis, and understand the resources available. + +### Solve the underlying problem + +This one is a bit tricky. Sometimes people think they’ve got the right path to a solution, and they just need one more piece of information to implement that solution. But they might not be quite on the right path! For example: + +* George: I’m doing X, and I got this error, how do I fix it + +* Jasminda: Are you actually trying to do Y? If so, you shouldn’t do X, you should do Z instead + +* George: Oh, you’re right!!! Thank you! I will do Z instead. + +Jasminda didn’t answer George’s question at all! Instead she guessed that George didn’t actually want to be doing X, and she was right. That is helpful! + +It’s possible to come off as condescending here though, like + +* George: I’m doing X, and I got this error, how do I fix it? + +* Jasminda: Don’t do that, you’re trying to do Y and you should do Z to accomplish that instead. + +* George: Well, I am not trying to do Y, I actually want to do X because REASONS. How do I do X? + +So don’t be condescending, and keep in mind that some questioners might be attached to the steps they’ve taken so far! It might be appropriate to answer both the question they asked and the one they should have asked: “Well, if you want to do X then you might try this, but if you’re trying to solve problem Y with that, you might have better luck doing this other thing, and here’s why that’ll work better”. + +### Ask “Did that answer your question?” + +I always like to check in after I  _think_  I’ve answered the question and ask “did that answer your question? Do you have more questions?”. + +It’s good to pause and wait after asking this because often people need a minute or two to know whether or not they’ve figured out the answer. I especially find this extra “did this answer your questions?” step helpful after writing documentation! Often when writing documentation about something I know well I’ll leave out something very important without realizing it. + +### Offer to pair program/chat in real life + +I work remote, so many of my conversations at work are text-based. I think of that as the default mode of communication. + +Today, we live in a world of easy video conferencing & screensharing! At work I can at any time click a button and immediately be in a video call/screensharing session with someone. Some problems are easier to talk about using your voices! + +For example, recently someone was asking about capacity planning/autoscaling for their service. I could tell there were a few things we needed to clear up but I wasn’t exactly sure what they were yet. We got on a quick video call and 5 minutes later we’d answered all their questions. + +I think especially if someone is really stuck on how to get started on a task, pair programming for a few minutes can really help, and it can be a lot more efficient than email/instant messaging. + +### Don’t act surprised + +This one’s a rule from the Recurse Center: [no feigning surprise][4]. Here’s a relatively common scenario + +* Human 1: “what’s the Linux kernel?” + +* Human 2: “you don’t know what the LINUX KERNEL is?!!!!?!!!???” + +Human 2’s reaction (regardless of whether they’re  _actually_  surprised or not) is not very helpful. It mostly just serves to make Human 1 feel bad that they don’t know what the Linux kernel is. + +I’ve worked on actually pretending not to be surprised even when I actually am a bit surprised the person doesn’t know the thing and it’s awesome. + +### Answering questions well is awesome + +Obviously not all these strategies are appropriate all the time, but hopefully you will find some of them helpful! I find taking the time to answer questions and teach people can be really rewarding. + +Special thanks to Josh Triplett for suggesting this post and making many helpful additions, and to Harold Treen, Vaibhav Sagar, Peter Bhat Harkins, Wesley Aptekar-Cassels, and Paul Gowder for reading/commenting. + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/answer-questions-well/ + +作者:[ Julia Evans][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/about +[1]:https://jvns.ca/blog/good-questions/ +[2]:https://jvns.ca/blog/good-questions/ +[3]:https://linux.die.net/man/1/bash +[4]:https://jvns.ca/blog/2017/04/27/no-feigning-surprise/ From 8ff377fd749f4147e523832fc8fa1eb46aee1f72 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:34:24 +0800 Subject: [PATCH 152/344] =?UTF-8?q?20171203-23=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Linux containers with Ansible Container.md | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 sources/tech/20171005 How to manage Linux containers with Ansible Container.md diff --git a/sources/tech/20171005 How to manage Linux containers with Ansible Container.md b/sources/tech/20171005 How to manage Linux containers with Ansible Container.md new file mode 100644 index 0000000000..897b793a86 --- /dev/null +++ b/sources/tech/20171005 How to manage Linux containers with Ansible Container.md @@ -0,0 +1,114 @@ +How to manage Linux containers with Ansible Container +============================================================ + +### Ansible Container addresses Dockerfile shortcomings and offers complete management for containerized projects. + +![Ansible Container: A new way to manage containers](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/container-ship.png?itok=pqZYgQ7K "Ansible Container: A new way to manage containers") +Image by : opensource.com + +I love containers and use the technology every day. Even so, containers aren't perfect. Over the past couple of months, however, a set of projects has emerged that addresses some of the problems I've experienced. + +I started using containers with [Docker][11], since this project made the technology so popular. Aside from using the container engine, I learned how to use **[docker-compose][6]** and started managing my projects with it. My productivity skyrocketed! One command to run my project, no matter how complex it was. I was so happy. + +After some time, I started noticing issues. The most apparent were related to the process of creating container images. The Docker tool uses a custom file format as a recipe to produce container images—Dockerfiles. This format is easy to learn, and after a short time you are ready to produce container images on your own. The problems arise once you want to master best practices or have complex scenarios in mind. + +More on Ansible + +* [How Ansible works][1] + +* [Free Ansible eBooks][2] + +* [Ansible quick start video][3] + +* [Download and install Ansible][4] + +Let's take a break and travel to a different land: the world of [Ansible][22]. You know it? It's awesome, right? You don't? Well, it's time to learn something new. Ansible is a project that allows you to manage your infrastructure by writing tasks and executing them inside environments of your choice. No need to install and set up any services; everything can easily run from your laptop. Many people already embrace Ansible. + +Imagine this scenario: You invested in Ansible, you wrote plenty of Ansible roles and playbooks that you use to manage your infrastructure, and you are thinking about investing in containers. What should you do? Start writing container image definitions via shell scripts and Dockerfiles? That doesn't sound right. + +Some people from the Ansible development team asked this question and realized that those same Ansible roles and playbooks that people wrote and use daily can also be used to produce container images. But not just that—they can be used to manage the complete lifecycle of containerized projects. From these ideas, the [Ansible Container][12] project was born. It utilizes existing Ansible roles that can be turned into container images and can even be used for the complete application lifecycle, from build to deploy in production. + +Let's talk about the problems I mentioned regarding best practices in context of Dockerfiles. A word of warning: This is going to be very specific and technical. Here are the top three issues I have: + +### 1\. Shell scripts embedded in Dockerfiles. + +When writing Dockerfiles, you can specify a script that will be interpreted via **/bin/sh -c**. It can be something like: + +``` +RUN dnf install -y nginx +``` + +where RUN is a Dockerfile instruction and the rest are its arguments (which are passed to shell). But imagine a more complex scenario: + +``` +RUN set -eux; \ +    \ +# this "case" statement is generated via "update.sh" +    %%ARCH-CASE%%; \ +    \ +    url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \ +    wget -O go.tgz "$url"; \ +    echo "${goRelSha256} *go.tgz" | sha256sum -c -; \ +``` + +This one is taken from [the official golang image][13]. It doesn't look pretty, right? + +### 2\. You can't parse Dockerfiles easily. + +Dockerfiles are a new format without a formal specification. This is tricky if you need to process Dockerfiles in your infrastructure (e.g., automate the build process a bit). The only specification is [the code][14] that is part of **dockerd**. The problem is that you can't use it as a library. The easiest solution is to write a parser on your own and hope for the best. Wouldn't it be better to use some well-known markup language, such as YAML or JSON? + +### 3\. It's hard to control. + +If you are familiar with the internals of container images, you may know that every image is composed of layers. Once the container is created, the layers are stacked onto each other (like pancakes) using union filesystem technology. The problem is, that you cannot explicitly control this layering—you can't say, "here starts a new layer." You are forced to change your Dockerfile in a way that may hurt readability. The bigger problem is that a set of best practices has to be followed to achieve optimal results—newcomers have a really hard time here. + +### Comparing Ansible language and Dockerfiles + +The biggest shortcoming of Dockerfiles in comparison to Ansible is that Ansible, as a language, is much more powerful. For example, Dockerfiles have no direct concept of variables, whereas Ansible has a complete templating system (variables are just one of its features). Ansible contains a large number of modules that can be easily utilized, such as [**wait_for**][15], which can be used for service readiness checks—e.g., wait until a service is ready before proceeding. With Dockerfiles, everything is a shell script. So if you need to figure out service readiness, it has to be done with shell (or installed separately). The other problem with shell scripts is that, with growing complexity, maintenance becomes a burden. Plenty of people have already figured this out and turned those shell scripts into Ansible. + +If you are interested in this topic and would like to know more, please come to [Open Source Summit][16] in Prague to see [my presentation][17] on Monday, Oct. 23, at 4:20 p.m. in Palmovka room. + + _Learn more in Tomas Tomecek's talk, [From Dockerfiles to Ansible Container][7], at [Open Source Summit EU][8], which will be held October 23-26 in Prague._ + + + +### About the author + + [![human](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/ja.jpeg?itok=4ATUEAbd)][18] Tomas Tomecek - Engineer. Hacker. Speaker. Tinker. Red Hatter. Likes containers, linux, open source, python 3, rust, zsh, tmux.[More about me][9] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/10/dockerfiles-ansible-container + +作者:[Tomas Tomecek ][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/tomastomecek +[1]:https://www.ansible.com/how-ansible-works?intcmp=701f2000000h4RcAAI +[2]:https://www.ansible.com/ebooks?intcmp=701f2000000h4RcAAI +[3]:https://www.ansible.com/quick-start-video?intcmp=701f2000000h4RcAAI +[4]:https://docs.ansible.com/ansible/latest/intro_installation.html?intcmp=701f2000000h4RcAAI +[5]:https://opensource.com/article/17/10/dockerfiles-ansible-container?imm_mid=0f9013&cmp=em-webops-na-na-newsltr_20171201&rate=Wiw_0D6PK_CAjqatYu_YQH0t1sNHEF6q09_9u3sYkCY +[6]:https://github.com/docker/compose +[7]:http://sched.co/BxIW +[8]:http://events.linuxfoundation.org/events/open-source-summit-europe +[9]:https://opensource.com/users/tomastomecek +[10]:https://opensource.com/user/175651/feed +[11]:https://opensource.com/tags/docker +[12]:https://www.ansible.com/ansible-container +[13]:https://github.com/docker-library/golang/blob/master/Dockerfile-debian.template#L14 +[14]:https://github.com/moby/moby/tree/master/builder/dockerfile +[15]:http://docs.ansible.com/wait_for_module.html +[16]:http://events.linuxfoundation.org/events/open-source-summit-europe +[17]:http://events.linuxfoundation.org/events/open-source-summit-europe/program/schedule +[18]:https://opensource.com/users/tomastomecek +[19]:https://opensource.com/users/tomastomecek +[20]:https://opensource.com/users/tomastomecek +[21]:https://opensource.com/article/17/10/dockerfiles-ansible-container?imm_mid=0f9013&cmp=em-webops-na-na-newsltr_20171201#comments +[22]:https://opensource.com/tags/ansible +[23]:https://opensource.com/tags/containers +[24]:https://opensource.com/tags/ansible +[25]:https://opensource.com/tags/docker +[26]:https://opensource.com/tags/open-source-summit From b044202569c43d2657c029d3bb4002e954864477 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:36:38 +0800 Subject: [PATCH 153/344] =?UTF-8?q?20171203-25=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...171120 Adopting Kubernetes step by step.md | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 sources/tech/20171120 Adopting Kubernetes step by step.md diff --git a/sources/tech/20171120 Adopting Kubernetes step by step.md b/sources/tech/20171120 Adopting Kubernetes step by step.md new file mode 100644 index 0000000000..05faf304c8 --- /dev/null +++ b/sources/tech/20171120 Adopting Kubernetes step by step.md @@ -0,0 +1,93 @@ +Adopting Kubernetes step by step +============================================================ + +Why Docker and Kubernetes? + +Containers allow us to build, ship and run distributed applications. They remove the machine constraints from applications and lets us create a complex application in a deterministic fashion. + +Composing applications with containers allows us to make development, QA and production environments closer to each other (if you put the effort in to get there). By doing so, changes can be shipped faster and testing a full system can happen sooner. + +[Docker][1] — the containerization platform — provides this, making software  _independent_  of cloud providers. + +However, even with containers the amount of work needed for shipping your application through any cloud provider (or in a private cloud) is significant. An application usually needs auto scaling groups, persistent remote discs, auto discovery, etc. But each cloud provider has different mechanisms for doing this. If you want to support these features, you very quickly become cloud provider dependent. + +This is where [Kubernetes][2] comes in to play. It is an orchestration system for containers that allows you to manage, scale and deploy different pieces of your application — in a standardised way — with great tooling as part of it. It’s a portable abstraction that’s compatible with the main cloud providers (Google Cloud, Amazon Web Services and Microsoft Azure all have support for Kubernetes). + +A way to visualise your application, containers and Kubernetes is to think about your application as a shark — stay with me — that exists in the ocean (in this example, the ocean is your machine). The ocean may have other precious things you don’t want your shark to interact with, like [clown fish][3]. So you move you shark (your application) into a sealed aquarium (Container). This is great but not very robust. Your aquarium can break or maybe you want to build a tunnel to another aquarium where other fish live. Or maybe you want many copies of that aquarium in case one needs cleaning or maintenance… this is where Kubernetes clusters come to play. + + +![](https://cdn-images-1.medium.com/max/1600/1*OVt8cnY1WWOqdLFycCgdFg.jpeg) +Evolution to Kubernetes + +With Kubernetes being supported by the main cloud providers, it makes it easier for you and your team to have environments from  _development _ to  _production _ that are almost identical to each other. This is because Kubernetes has no reliance on proprietary software, services or infrastructure. + +The fact that you can start your application in your machine with the same pieces as in production closes the gaps between a development and a production environment. This makes developers more aware of how an application is structured together even though they might only be responsible for one piece of it. It also makes it easier for your application to be fully tested earlier in the pipeline. + +How do you work with Kubernetes? + +With more people adopting Kubernetes new questions arise; how should I develop against a cluster based environment? Suppose you have 3 environments — development, QA and production — how do I fit Kubernetes in them? Differences across these environments will still exist, either in terms of development cycle (e.g. time spent to see my code changes in the application I’m running) or in terms of data (e.g. I probably shouldn’t test with production data in my QA environment as it has sensitive information). + +So, should I always try to work inside a Kubernetes cluster, building images, recreating deployments and services while I code? Or maybe I should not try too hard to make my development environment be a Kubernetes cluster (or set of clusters) in development? Or maybe I should work in a hybrid way? + + +![](https://cdn-images-1.medium.com/max/1600/1*MXokxD8Ktte4_vWvTas9uw.jpeg) +Development with a local cluster + +If we carry on with our metaphor, the holes on the side represent a way to make changes to our app while keeping it in a development cluster. This is usually achieved via [volumes][4]. + +A Kubernetes series + +The Kubernetes series repository is open source and available here: + +### [https://github.com/red-gate/ks][5] + +We’ve written this series as we experiment with different ways to build software. We’ve tried to constrain ourselves to use Kubernetes in all environments so that we can explore the impact these technologies will have on the development and management of data and the database. + +The series starts with the basic creation of a React application hooked up to Kubernetes, and evolves to encompass more of our development requirements. By the end we’ll have covered all of our application development needs  _and_  have understood how best to cater for the database lifecycle in this world of containers and clusters. + +Here are the first 5 episodes of this series: + +1. ks1: build a React app with Kubernetes + +2. ks2: make minikube detect React code changes + +3. ks3: add a python web server that hosts an API + +4. ks4: make minikube detect Python code changes + +5. ks5: create a test environment + +The second part of the series will add a database and try to work out the best way to evolve our application alongside it. + +By running Kubernetes in all environments, we’ve been forced to solve new problems as we try to keep the development cycle as fast as possible. The trade-off being that we are constantly exposed to Kubernetes and become more accustomed to it. By doing so, development teams become responsible for production environments, which is no longer difficult as all environments (development through production) are all managed in the same way. + +What’s next? + +We will continue this series by incorporating a database and experimenting to find the best way to have a seamless database lifecycle experience with Kubernetes. + + _This Kubernetes series is brought to you by Foundry, Redgate’s R&D division. We’re working on making it easier to manage data alongside containerised environments, so if you’re working with data and containerised environments, we’d like to hear from you — reach out directly to the development team at _ [_foundry@red-gate.com_][6] + +* * * + + _We’re hiring_ _. Are you interested in uncovering product opportunities, building _ [_future technology_][7] _ and taking a startup-like approach (without the risk)? Take a look at our _ [_Software Engineer — Future Technologies_][8] _ role and read more about what it’s like to work at Redgate in _ [_Cambridge, UK_][9] _._ + +-------------------------------------------------------------------------------- + +via: https://medium.com/ingeniouslysimple/adopting-kubernetes-step-by-step-f93093c13dfe + +作者:[santiago arias][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://medium.com/@santiaago?source=post_header_lockup +[1]:https://www.docker.com/what-docker +[2]:https://kubernetes.io/ +[3]:https://www.google.co.uk/search?biw=723&bih=753&tbm=isch&sa=1&ei=p-YCWpbtN8atkwWc8ZyQAQ&q=nemo+fish&oq=nemo+fish&gs_l=psy-ab.3..0i67k1l2j0l2j0i67k1j0l5.5128.9271.0.9566.9.9.0.0.0.0.81.532.9.9.0....0...1.1.64.psy-ab..0.9.526...0i7i30k1j0i7i10i30k1j0i13k1j0i10k1.0.FbAf9xXxTEM +[4]:https://kubernetes.io/docs/concepts/storage/volumes/ +[5]:https://github.com/red-gate/ks +[6]:mailto:foundry@red-gate.com +[7]:https://www.red-gate.com/foundry/ +[8]:https://www.red-gate.com/our-company/careers/current-opportunities/software-engineer-future-technologies +[9]:https://www.red-gate.com/our-company/careers/living-in-cambridge From a25a01e35c7fd3d3ff2032639bde7f956b86f425 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:38:35 +0800 Subject: [PATCH 154/344] =?UTF-8?q?20171203-26=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20171114 Sysadmin 101 Patch Management.md | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 sources/tech/20171114 Sysadmin 101 Patch Management.md diff --git a/sources/tech/20171114 Sysadmin 101 Patch Management.md b/sources/tech/20171114 Sysadmin 101 Patch Management.md new file mode 100644 index 0000000000..71df51258d --- /dev/null +++ b/sources/tech/20171114 Sysadmin 101 Patch Management.md @@ -0,0 +1,61 @@ +Sysadmin 101: Patch Management +============================================================ + +* [HOW-TOs][1] + +* [Servers][2] + +* [SysAdmin][3] + + +A few articles ago, I started a Sysadmin 101 series to pass down some fundamental knowledge about systems administration that the current generation of junior sysadmins, DevOps engineers or "full stack" developers might not learn otherwise. I had thought that I was done with the series, but then the WannaCry malware came out and exposed some of the poor patch management practices still in place in Windows networks. I imagine some readers that are still stuck in the Linux versus Windows wars of the 2000s might have even smiled with a sense of superiority when they heard about this outbreak. + +The reason I decided to revive my Sysadmin 101 series so soon is I realized that most Linux system administrators are no different from Windows sysadmins when it comes to patch management. Honestly, in some areas (in particular, uptime pride), some Linux sysadmins are even worse than Windows sysadmins regarding patch management. So in this article, I cover some of the fundamentals of patch management under Linux, including what a good patch management system looks like, the tools you will want to put in place and how the overall patching process should work. + +### What Is Patch Management? + +When I say patch management, I'm referring to the systems you have in place to update software already on a server. I'm not just talking about keeping up with the latest-and-greatest bleeding-edge version of a piece of software. Even more conservative distributions like Debian that stick with a particular version of software for its "stable" release still release frequent updates that patch bugs or security holes. + +Of course, if your organization decided to roll its own version of a particular piece of software, either because developers demanded the latest and greatest, you needed to fork the software to apply a custom change, or you just like giving yourself extra work, you now have a problem. Ideally you have put in a system that automatically packages up the custom version of the software for you in the same continuous integration system you use to build and package any other software, but many sysadmins still rely on the outdated method of packaging the software on their local machine based on (hopefully up to date) documentation on their wiki. In either case, you will need to confirm that your particular version has the security flaw, and if so, make sure that the new patch applies cleanly to your custom version. + +### What Good Patch Management Looks Like + +Patch management starts with knowing that there is a software update to begin with. First, for your core software, you should be subscribed to your Linux distribution's security mailing list, so you're notified immediately when there are security patches. If there you use any software that doesn't come from your distribution, you must find out how to be kept up to date on security patches for that software as well. When new security notifications come in, you should review the details so you understand how severe the security flaw is, whether you are affected and gauge a sense of how urgent the patch is. + +Some organizations have a purely manual patch management system. With such a system, when a security patch comes along, the sysadmin figures out which servers are running the software, generally by relying on memory and by logging in to servers and checking. Then the sysadmin uses the server's built-in package management tool to update the software with the latest from the distribution. Then the sysadmin moves on to the next server, and the next, until all of the servers are patched. + +There are many problems with manual patch management. First is the fact that it makes patching a laborious chore. The more work patching is, the more likely a sysadmin will put it off or skip doing it entirely. The second problem is that manual patch management relies too much on the sysadmin's ability to remember and recall all of the servers he or she is responsible for and keep track of which are patched and which aren't. This makes it easy for servers to be forgotten and sit unpatched. + +The faster and easier patch management is, the more likely you are to do it. You should have a system in place that quickly can tell you which servers are running a particular piece of software at which version. Ideally, that system also can push out updates. Personally, I prefer orchestration tools like MCollective for this task, but Red Hat provides Satellite, and Canonical provides Landscape as central tools that let you view software versions across your fleet of servers and apply patches all from a central place. + +Patching should be fault-tolerant as well. You should be able to patch a service and restart it without any overall down time. The same idea goes for kernel patches that require a reboot. My approach is to divide my servers into different high availability groups so that lb1, app1, rabbitmq1 and db1 would all be in one group, and lb2, app2, rabbitmq2 and db2 are in another. Then, I know I can patch one group at a time without it causing downtime anywhere else. + +So, how fast is fast? Your system should be able to roll out a patch to a minor piece of software that doesn't have an accompanying service (such as bash in the case of the ShellShock vulnerability) within a few minutes to an hour at most. For something like OpenSSL that requires you to restart services, the careful process of patching and restarting services in a fault-tolerant way probably will take more time, but this is where orchestration tools come in handy. I gave examples of how to use MCollective to accomplish this in my recent MCollective articles (see the December 2016 and January 2017 issues), but ideally, you should put a system in place that makes it easy to patch and restart services in a fault-tolerant and automated way. + +When patching requires a reboot, such as in the case of kernel patches, it might take a bit more time, but again, automation and orchestration tools can make this go much faster than you might imagine. I can patch and reboot the servers in an environment in a fault-tolerant way within an hour or two, and it would be much faster than that if I didn't need to wait for clusters to sync back up in between reboots. + +Unfortunately, many sysadmins still hold on to the outdated notion that uptime is a badge of pride—given that serious kernel patches tend to come out at least once a year if not more often, to me, it's proof you don't take security seriously. + +Many organizations also still have that single point of failure server that can never go down, and as a result, it never gets patched or rebooted. If you want to be secure, you need to remove these outdated liabilities and create systems that at least can be rebooted during a late-night maintenance window. + +Ultimately, fast and easy patch management is a sign of a mature and professional sysadmin team. Updating software is something all sysadmins have to do as part of their jobs, and investing time into systems that make that process easy and fast pays dividends far beyond security. For one, it helps identify bad architecture decisions that cause single points of failure. For another, it helps identify stagnant, out-of-date legacy systems in an environment and provides you with an incentive to replace them. Finally, when patching is managed well, it frees up sysadmins' time and turns their attention to the things that truly require their expertise. + +______________________ + +Kyle Rankin is senior security and infrastructure architect, the author of many books including Linux Hardening in Hostile Networks, DevOps Troubleshooting and The Official Ubuntu Server Book, and a columnist for Linux Journal. Follow him @kylerankin + +-------------------------------------------------------------------------------- + +via: https://www.linuxjournal.com/content/sysadmin-101-patch-management + +作者:[Kyle Rankin ][a] +译者:[译者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 +[1]:https://www.linuxjournal.com/tag/how-tos +[2]:https://www.linuxjournal.com/tag/servers +[3]:https://www.linuxjournal.com/tag/sysadmin +[4]:https://www.linuxjournal.com/users/kyle-rankin From 8dfd8a3a65a431c652555b7e16b20552050831bc Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:42:04 +0800 Subject: [PATCH 155/344] =?UTF-8?q?20171203-26=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Help Build ONNX Open Source AI Platform.md | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md diff --git a/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md b/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md new file mode 100644 index 0000000000..c09d66bc57 --- /dev/null +++ b/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md @@ -0,0 +1,76 @@ +AWS to Help Build ONNX Open Source AI Platform +============================================================ +![onnx-open-source-ai-platform](https://www.linuxinsider.com/article_images/story_graphics_xlarge/xl-2017-onnx-1.jpg) + + +Amazon Web Services has become the latest tech firm to join the deep learning community's collaboration on the Open Neural Network Exchange, recently launched to advance artificial intelligence in a frictionless and interoperable environment. Facebook and Microsoft led the effort. + +As part of that collaboration, AWS made its open source Python package, ONNX-MxNet, available as a deep learning framework that offers application programming interfaces across multiple languages including Python, Scala and open source statistics software R. + +The ONNX format will help developers build and train models for other frameworks, including PyTorch, Microsoft Cognitive Toolkit or Caffe2, AWS Deep Learning Engineering Manager Hagay Lupesko and Software Developer Roshani Nagmote wrote in an online post last week. It will let developers import those models into MXNet, and run them for inference. + +### Help for Developers + +Facebook and Microsoft this summer launched ONNX to support a shared model of interoperability for the advancement of AI. Microsoft committed its Cognitive Toolkit, Caffe2 and PyTorch to support ONNX. + +Cognitive Toolkit and other frameworks make it easier for developers to construct and run computational graphs that represent neural networks, Microsoft said. + +Initial versions of [ONNX code and documentation][4] were made available on Github. + +AWS and Microsoft last month announced plans for Gluon, a new interface in Apache MXNet that allows developers to build and train deep learning models. + +Gluon "is an extension of their partnership where they are trying to compete with Google's Tensorflow," observed Aditya Kaul, research director at [Tractica][5]. + +"Google's omission from this is quite telling but also speaks to their dominance in the market," he told LinuxInsider. + +"Even Tensorflow is open source, and so open source is not the big catch here -- but the rest of the ecosystem teaming up to compete with Google is what this boils down to," Kaul said. + +The Apache MXNet community earlier this month introduced version 0.12 of MXNet, which extends Gluon functionality to allow for new, cutting-edge research, according to AWS. Among its new features are variational dropout, which allows developers to apply the dropout technique for mitigating overfitting to recurrent neural networks. + +Convolutional RNN, Long Short-Term Memory and gated recurrent unit cells allow datasets to be modeled using time-based sequence and spatial dimensions, AWS noted. + +### Framework-Neutral Method + +"This looks like a great way to deliver inference regardless of which framework generated a model," said Paul Teich, principal analyst at [Tirias Research][6]. + +"This is basically a framework-neutral way to deliver inference," he told LinuxInsider. + +Cloud providers like AWS, Microsoft and others are under pressure from customers to be able to train on one network while delivering on another, in order to advance AI, Teich pointed out. + +"I see this as kind of a baseline way for these vendors to check the interoperability box," he remarked. + +"Framework interoperability is a good thing, and this will only help developers in making sure that models that they build on MXNet or Caffe or CNTK are interoperable," Tractica's Kaul pointed out. + +As to how this interoperability might apply in the real world, Teich noted that technologies such as natural language translation or speech recognition would require that Alexa's voice recognition technology be packaged and delivered to another developer's embedded environment. + +### Thanks, Open Source + +"Despite their competitive differences, these companies all recognize they owe a significant amount of their success to the software development advancements generated by the open source movement," said Jeff Kaplan, managing director of [ThinkStrategies][7]. + +"The Open Neural Network Exchange is committed to producing similar benefits and innovations in AI," he told LinuxInsider. + +A growing number of major technology companies have announced plans to use open source to speed the development of AI collaboration, in order to create more uniform platforms for development and research. + +AT&T just a few weeks ago announced plans [to launch the Acumos Project][8] with TechMahindra and The Linux Foundation. The platform is designed to open up efforts for collaboration in telecommunications, media and technology.  +![](https://www.ectnews.com/images/end-enn.gif) + +-------------------------------------------------------------------------------- + +via: https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html + +作者:[ David Jones ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html#searchbyline +[1]:https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html# +[2]:https://www.linuxinsider.com/perl/mailit/?id=84971 +[3]:https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html +[4]:https://github.com/onnx/onnx +[5]:https://www.tractica.com/ +[6]:http://www.tiriasresearch.com/ +[7]:http://www.thinkstrategies.com/ +[8]:https://www.linuxinsider.com/story/84926.html +[9]:https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html From becb59ff7b40ceddf6c0c949565492df2ddc43a1 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:43:35 +0800 Subject: [PATCH 156/344] =?UTF-8?q?20171203-28=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20171114 Take Linux and Run With It.md | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 sources/tech/20171114 Take Linux and Run With It.md diff --git a/sources/tech/20171114 Take Linux and Run With It.md b/sources/tech/20171114 Take Linux and Run With It.md new file mode 100644 index 0000000000..b7b6cb9663 --- /dev/null +++ b/sources/tech/20171114 Take Linux and Run With It.md @@ -0,0 +1,68 @@ +Take Linux and Run With It +============================================================ + +![](https://www.linuxinsider.com/article_images/story_graphics_xlarge/xl-2016-linux-1.jpg) + +![](https://www.linuxinsider.com/images/2015/image-credit-adobe-stock_130x15.gif) + + +"How do you run an operating system?" may seem like a simple question, since most of us are accustomed to turning on our computers and seeing our system spin up. However, this common model is only one way of running an operating system. As one of Linux's greatest strengths is versatility, Linux offers the most methods and environments for running it. + +To unleash the full power of Linux, and maybe even find a use for it you hadn't thought of, consider some less conventional ways of running it -- specifically, ones that don't even require installation on a computer's hard drive. + +### We'll Do It Live! + +Live-booting is a surprisingly useful and popular way to get the full Linux experience on the fly. While hard drives are where OSes reside most of the time, they actually can be installed to most major storage media, including CDs, DVDs and USB flash drives. + +When an OS is installed to some device other than a computer's onboard hard drive and subsequently booted instead of that onboard drive, it's called "live-booting" or running a "live session." + +At boot time, the user simply selects an external storage source for the hardware to look for boot information. If found, the computer follows the external device's boot instructions, essentially ignoring the onboard drive until the next time the user boots normally. Optical media are increasingly rare these days, so by far the most typical form that an external OS-carrying device takes is a USB stick. + +Most mainstream Linux distributions offer a way to run a live session as a way of trying them out. The live session doesn't save any user activity, and the OS resets to the clean default state after every shutdown. + +Live Linux sessions can be used for more than testing a distro, though. One application is for executing system repair for critically malfunctioning onboard (usually also Linux) systems. If an update or configuration made the onboard system unbootable, a full system backup is required, or the hard drive has sustained serious file corruption, the only recourse is to start up a live system and perform maintenance on the onboard drive. + +In these and similar scenarios, the onboard drive cannot be manipulated or corrected while also keeping the system stored on it running, so a live system takes on those burdens instead, leaving all but the problematic files on the onboard drive at rest. + +Live sessions also are perfectly suited for handling sensitive information. If you don't want a computer to retain any trace of the operations executed or information handled on it, especially if you are using hardware you can't vouch for -- like a public library or hotel business center computer -- a live session will provide you all the desktop computing functions to complete your task while retaining no trace of your session once you're finished. This is great for doing online banking or password input that you don't want a computer to remember. + +### Linux Virtually Anywhere + +Another approach for implementing Linux for more on-demand purposes is to run a virtual machine on another host OS. A virtual machine, or VM, is essentially a small computer running inside another computer and contained in a single large file. + +To run a VM, users simply install a hypervisor program (a kind of launcher for the VM), select a downloaded Linux OS image file (usually ending with a ".iso" file extension), and walk through the setup process. + +Most of the settings can be left at their defaults, but the key ones to configure are the amount of RAM and hard drive storage to lease to the VM. Fortunately, since Linux has a light footprint, you don't have to set these very high: 2 GB of RAM and 16 GB of storage should be plenty for the VM while still letting your host OS thrive. + +So what does this offer that a live system doesn't? First, whereas live systems are ephemeral, VMs can retain the data stored on them. This is great if you want to set up your Linux VM for a special use case, like software development or even security. + +When used for development, a Linux VM gives you the solid foundation of Linux's programming language suites and coding tools, and it lets you save your projects right in the VM to keep everything organized. + +If security is your goal, Linux VMs allow you to impose an extra layer between a potential hazard and your system. If you do your browsing from the VM, a malicious program would have to compromise not only your virtual Linux system, but also the hypervisor -- and  _then_ your host OS, a technical feat beyond all but the most skilled and determined adversaries. + +Second, you can start up your VM on demand from your host system, without having to power it down and start it up again as you would have to with a live session. When you need it, you can quickly bring up the VM, and when you're finished, you just shut it down and go back to what you were doing before. + +Your host system continues running normally while the VM is on, so you can attend to tasks simultaneously in each system. + +### Look Ma, No Installation! + +Just as there is no one form that Linux takes, there's also no one way to run it. Hopefully, this brief primer on the kinds of systems you can run has given you some ideas to expand your use models. + +The best part is that if you're not sure how these can help, live booting and virtual machines don't hurt to try!  +![](https://www.ectnews.com/images/end-enn.gif) + +-------------------------------------------------------------------------------- + +via: https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html + +作者:[ Jonathan Terrasi ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html#searchbyline +[1]:https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html# +[2]:https://www.linuxinsider.com/perl/mailit/?id=84951 +[3]:https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html +[4]:https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html From c91f7e0c107e1e7638285bb4687c2f193699c7fe Mon Sep 17 00:00:00 2001 From: qhwdw Date: Sun, 3 Dec 2017 20:44:35 +0800 Subject: [PATCH 157/344] modified by qhwdw --- core.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core.md b/core.md index da45c009fc..3093f4ae52 100644 --- a/core.md +++ b/core.md @@ -36,4 +36,4 @@ - 除非必要,合并 PR 时不要 squash-merge wxy@LCTT -2016/12/24 \ No newline at end of file +2017/12/24 From 5c74048e32e9b5b426fec5f80b6d23a4f5741a04 Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Sun, 3 Dec 2017 20:47:57 +0800 Subject: [PATCH 158/344] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core.md b/core.md index 3093f4ae52..2ec8aa89cf 100644 --- a/core.md +++ b/core.md @@ -36,4 +36,4 @@ - 除非必要,合并 PR 时不要 squash-merge wxy@LCTT -2017/12/24 +2016/12/24 From 653b2555c65721c0bbaa86a6f50117345ea397ab Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:48:59 +0800 Subject: [PATCH 159/344] Delete 20171203 How do groups work on Linux.md --- .../20171203 How do groups work on Linux.md | 141 ------------------ 1 file changed, 141 deletions(-) delete mode 100644 sources/tech/20171203 How do groups work on Linux.md diff --git a/sources/tech/20171203 How do groups work on Linux.md b/sources/tech/20171203 How do groups work on Linux.md deleted file mode 100644 index 503f83d1d9..0000000000 --- a/sources/tech/20171203 How do groups work on Linux.md +++ /dev/null @@ -1,141 +0,0 @@ -How do groups work on Linux? -============================================================ - -Hello! Last week, I thought I knew how users and groups worked on Linux. Here is what I thought: - -1. Every process belongs to a user (like `julia`) - -2. When a process tries to read a file owned by a group, Linux a) checks if the user `julia` can access the file, and b) checks which groups `julia` belongs to, and whether any of those groups owns & can access that file - -3. If either of those is true (or if the ‘any’ bits are set right) then the process can access the file - -So, for example, if a process is owned by the `julia` user and `julia` is in the `awesome`group, then the process would be allowed to read this file. - -``` -r--r--r-- 1 root awesome 6872 Sep 24 11:09 file.txt - -``` - -I had not thought carefully about this, but if pressed I would have said that it probably checks the `/etc/group` file at runtime to see what groups you’re in. - -### that is not how groups work - -I found out at work last week that, no, what I describe above is not how groups work. In particular Linux does **not** check which groups a process’s user belongs to every time that process tries to access a file. - -Here is how groups actually work! I learned this by reading Chapter 9 (“Process Credentials”) of [The Linux Programming Interface][1] which is an incredible book. As soon as I realized that I did not understand how users and groups worked, I opened up the table of contents with absolute confidence that it would tell me what’s up, and I was right. - -### how users and groups checks are done - -They key new insight for me was pretty simple! The chapter starts out by saying that user and group IDs are **attributes of the process**: - -* real user ID and group ID; - -* effective user ID and group ID; - -* saved set-user-ID and saved set-group-ID; - -* file-system user ID and group ID (Linux-specific); and - -* supplementary group IDs. - -This means that the way Linux **actually** does group checks to see a process can read a file is: - -* look at the process’s group IDs & supplementary group IDs (from the attributes on the process, **not** by looking them up in `/etc/group`) - -* look at the group on the file - -* see if they match - -Generally when doing access control checks it uses the **effective** user/group ID, not the real user/group ID. Technically when accessing a file it actually uses the **file-system** ids but those are usually the same as the effective uid/gid. - -### Adding a user to a group doesn’t put existing processes in that group - -Here’s another fun example that follows from this: if I create a new `panda` group and add myself (bork) to it, then run `groups` to check my group memberships – I’m not in the panda group! - -``` -bork@kiwi~> sudo addgroup panda -Adding group `panda' (GID 1001) ... -Done. -bork@kiwi~> sudo adduser bork panda -Adding user `bork' to group `panda' ... -Adding user bork to group panda -Done. -bork@kiwi~> groups -bork adm cdrom sudo dip plugdev lpadmin sambashare docker lxd - -``` - -no `panda` in that list! To double check, let’s try making a file owned by the `panda`group and see if I can access it: - -``` -$ touch panda-file.txt -$ sudo chown root:panda panda-file.txt -$ sudo chmod 660 panda-file.txt -$ cat panda-file.txt -cat: panda-file.txt: Permission denied - -``` - -Sure enough, I can’t access `panda-file.txt`. No big surprise there. My shell didn’t have the `panda` group as a supplementary GID before, and running `adduser bork panda` didn’t do anything to change that. - -### how do you get your groups in the first place? - -So this raises kind of a confusing question, right – if processes have groups baked into them, how do you get assigned your groups in the first place? Obviously you can’t assign yourself more groups (that would defeat the purpose of access control). - -It’s relatively clear how processes I **execute** from my shell (bash/fish) get their groups – my shell runs as me, and it has a bunch of group IDs on it. Processes I execute from my shell are forked from the shell so they get the same groups as the shell had. - -So there needs to be some “first” process that has your groups set on it, and all the other processes you set inherit their groups from that. That process is called your **login shell**and it’s run by the `login` program (`/bin/login`) on my laptop. `login` runs as root and calls a C function called `initgroups` to set up your groups (by reading `/etc/group`). It’s allowed to set up your groups because it runs as root. - -### let’s try logging in again! - -So! Let’s say I am running in a shell, and I want to refresh my groups! From what we’ve learned about how groups are initialized, I should be able to run `login` to refresh my groups and start a new login shell! - -Let’s try it: - -``` -$ sudo login bork -$ groups -bork adm cdrom sudo dip plugdev lpadmin sambashare docker lxd panda -$ cat panda-file.txt # it works! I can access the file owned by `panda` now! - -``` - -Sure enough, it works! Now the new shell that `login` spawned is part of the `panda`group! Awesome! This won’t affect any other shells I already have running. If I really want the new `panda` group everywhere, I need to restart my login session completely, which means quitting my window manager and logging in again. - -### newgrp - -Somebody on Twitter told me that if you want to start a new shell with a new group that you’ve been added to, you can use `newgrp`. Like this: - -``` -sudo addgroup panda -sudo adduser bork panda -newgrp panda # starts a new shell, and you don't have to be root to run it! - -``` - -You can accomplish the same(ish) thing with `sg panda bash` which will start a `bash`shell that runs with the `panda` group. - -### setuid sets the effective user ID - -I’ve also always been a little vague about what it means for a process to run as “setuid root”. It turns out that setuid sets the effective user ID! So if I (`julia`) run a setuid root process (like `passwd`), then the **real** user ID will be set to `julia`, and the **effective** user ID will be set to `root`. - -`passwd` needs to run as root, but it can look at its real user ID to see that `julia` started the process, and prevent `julia` from editing any passwords except for `julia`’s password. - -### that’s all! - -There are a bunch more details about all the edge cases and exactly how everything works in The Linux Programming Interface so I will not get into all the details here. That book is amazing. Everything I talked about in this post is from Chapter 9, which is a 17-page chapter inside a 1300-page book. - -The thing I love most about that book is that reading 17 pages about how users and groups work is really approachable, self-contained, super useful, and I don’t have to tackle all 1300 pages of it at once to learn helpful things :) - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/2017/11/20/groups/ - -作者:[Julia Evans ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://jvns.ca/about -[1]:http://man7.org/tlpi/ From 87471aa3864d90add9343042cc589f16bd3185e1 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 20:57:51 +0800 Subject: [PATCH 160/344] =?UTF-8?q?20171203-29=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...es Are Hiring Computer Security Experts.md | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 sources/tech/20170607 Why Car Companies Are Hiring Computer Security Experts.md diff --git a/sources/tech/20170607 Why Car Companies Are Hiring Computer Security Experts.md b/sources/tech/20170607 Why Car Companies Are Hiring Computer Security Experts.md new file mode 100644 index 0000000000..4a7d23e5f0 --- /dev/null +++ b/sources/tech/20170607 Why Car Companies Are Hiring Computer Security Experts.md @@ -0,0 +1,91 @@ +Why Car Companies Are Hiring Computer Security Experts +============================================================ + +Photo +![](https://static01.nyt.com/images/2017/06/08/business/08BITS-GURUS1/08BITS-GURUS1-superJumbo.jpg) +The cybersecurity experts Marc Rogers, left, of CloudFlare and Kevin Mahaffey of Lookout were able to control various Tesla functions from their physically connected laptop. They pose in CloudFlare’s lobby in front of Lava Lamps used to generate numbers for encryption.CreditChristie Hemm Klok for The New York Times + +It started about seven years ago. Iran’s top nuclear scientists were being assassinated in a string of similar attacks: Assailants on motorcycles were pulling up to their moving cars, attaching magnetic bombs and detonating them after the motorcyclists had fled the scene. + +In another seven years, security experts warn, assassins won’t need motorcycles or magnetic bombs. All they’ll need is a laptop and code to send driverless cars careering off a bridge, colliding with a driverless truck or coming to an unexpected stop in the middle of fast-moving traffic. + +Automakers may call them self-driving cars. But hackers call them computers that travel over 100 miles an hour. + +“These are no longer cars,” said Marc Rogers, the principal security researcher at the cybersecurity firm CloudFlare. “These are data centers on wheels. Any part of the car that talks to the outside world is a potential inroad for attackers.” + +Those fears came into focus two years ago when two “white hat” hackers — researchers who look for computer vulnerabilities to spot problems and fix them, rather than to commit a crime or cause problems — successfully gained access to a Jeep Cherokee from their computer miles away. They rendered their crash-test dummy (in this case a nervous reporter) powerless over his vehicle and disabling his transmission in the middle of a highway. + +The hackers, Chris Valasek and Charlie Miller (now security researchers respectively at Uber and Didi, an Uber competitor in China), discovered an [electronic route from the Jeep’s entertainment system to its dashboard][10]. From there, they had control of the vehicle’s steering, brakes and transmission — everything they needed to paralyze their crash test dummy in the middle of a highway. + +“Car hacking makes great headlines, but remember: No one has ever had their car hacked by a bad guy,” Mr. Miller wrote on Twitter last Sunday. “It’s only ever been performed by researchers.” + +Still, the research by Mr. Miller and Mr. Valasek came at a steep price for Jeep’s manufacturer, Fiat Chrysler, which was forced to recall 1.4 million of its vehicles as a result of the hacking experiment. + +It is no wonder that Mary Barra, the chief executive of General Motors, called cybersecurity her company’s top priority last year. Now the skills of researchers and so-called white hat hackers are in high demand among automakers and tech companies pushing ahead with driverless car projects. + +Uber, [Tesla][11], Apple and Didi in China have been actively recruiting white hat hackers like Mr. Miller and Mr. Valasek from one another as well as from traditional cybersecurity firms and academia. + +Last year, Tesla poached Aaron Sigel, Apple’s manager of security for its iOS operating system. Uber poached Chris Gates, formerly a white hat hacker at Facebook. Didi poached Mr. Miller from Uber, where he had gone to work after the Jeep hack. And security firms have seen dozens of engineers leave their ranks for autonomous-car projects. + +Mr. Miller said he left Uber for Didi, in part, because his new Chinese employer has given him more freedom to discuss his work. + +“Carmakers seem to be taking the threat of cyberattack more seriously, but I’d still like to see more transparency from them,” Mr. Miller wrote on Twitter on Saturday. + +Like a number of big tech companies, Tesla and Fiat Chrysler started paying out rewards to hackers who turn over flaws the hackers discover in their systems. GM has done something similar, though critics say GM’s program is limited when compared with the ones offered by tech companies, and so far no rewards have been paid out. + +One year after the Jeep hack by Mr. Miller and Mr. Valasek, they demonstrated all the other ways they could mess with a Jeep driver, including hijacking the vehicle’s cruise control, swerving the steering wheel 180 degrees or slamming on the parking brake in high-speed traffic — all from a computer in the back of the car. (Those exploits ended with their test Jeep in a ditch and calls to a local tow company.) + +Granted, they had to be in the Jeep to make all that happen. But it was evidence of what is possible. + +The Jeep penetration was preceded by a [2011 hack by security researchers at the University of Washington][12] and the University of California, San Diego, who were the first to remotely hack a sedan and ultimately control its brakes via Bluetooth. The researchers warned car companies that the more connected cars become, the more likely they are to get hacked. + +Security researchers have also had their way with Tesla’s software-heavy Model S car. In 2015, Mr. Rogers, together with Kevin Mahaffey, the chief technology officer of the cybersecurity company Lookout, found a way to control various Tesla functions from their physically connected laptop. + +One year later, a team of Chinese researchers at Tencent took their research a step further, hacking a moving Tesla Model S and controlling its brakes from 12 miles away. Unlike Chrysler, Tesla was able to dispatch a remote patch to fix the security holes that made the hacks possible. + +In all the cases, the car hacks were the work of well meaning, white hat security researchers. But the lesson for all automakers was clear. + +The motivations to hack vehicles are limitless. When it learned of Mr. Rogers’s and Mr. Mahaffey’s investigation into Tesla’s Model S, a Chinese app-maker asked Mr. Rogers if he would be interested in sharing, or possibly selling, his discovery, he said. (The app maker was looking for a backdoor to secretly install its app on Tesla’s dashboard.) + +Criminals have not yet shown they have found back doors into connected vehicles, though for years, they have been actively developing, trading and deploying tools that can intercept car key communications. + +But as more driverless and semiautonomous cars hit the open roads, they will become a more worthy target. Security experts warn that driverless cars present a far more complex, intriguing and vulnerable “attack surface” for hackers. Each new “connected” car feature introduces greater complexity, and with complexity inevitably comes vulnerability. + +Twenty years ago, cars had, on average, one million lines of code. The General Motors 2010 [Chevrolet Volt][13] had about 10 million lines of code — more than an [F-35 fighter jet][14]. + +Today, an average car has more than 100 million lines of code. Automakers predict it won’t be long before they have 200 million. When you stop to consider that, on average, there are 15 to 50 defects per 1,000 lines of software code, the potentially exploitable weaknesses add up quickly. + +The only difference between computer code and driverless car code is that, “Unlike data center enterprise security — where the biggest threat is loss of data — in automotive security, it’s loss of life,” said David Barzilai, a co-founder of Karamba Security, an Israeli start-up that is working on addressing automotive security. + +To truly secure autonomous vehicles, security experts say, automakers will have to address the inevitable vulnerabilities that pop up in new sensors and car computers, address inherent vulnerabilities in the base car itself and, perhaps most challenging of all, bridge the cultural divide between automakers and software companies. + +“The genie is out of the bottle, and to solve this problem will require a major cultural shift,” said Mr. Mahaffey of the cybersecurity company Lookout. “And an automaker that truly values cybersecurity will treat security vulnerabilities the same they would an airbag recall. We have not seen that industrywide shift yet.” + +There will be winners and losers, Mr. Mahaffey added: “Automakers that transform themselves into software companies will win. Others will get left behind.” + +-------------------------------------------------------------------------------- + +via: https://www.nytimes.com/2017/06/07/technology/why-car-companies-are-hiring-computer-security-experts.html + +作者:[NICOLE PERLROTH ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.nytimes.com/by/nicole-perlroth +[1]:https://www.nytimes.com/2016/06/09/technology/software-as-weaponry-in-a-computer-connected-world.html +[2]:https://www.nytimes.com/2015/08/29/technology/uber-hires-two-engineers-who-showed-cars-could-be-hacked.html +[3]:https://www.nytimes.com/2015/08/11/opinion/zeynep-tufekci-why-smart-objects-may-be-a-dumb-idea.html +[4]:https://www.nytimes.com/by/nicole-perlroth +[5]:https://www.nytimes.com/column/bits +[6]:https://www.nytimes.com/2017/06/07/technology/why-car-companies-are-hiring-computer-security-experts.html?utm_source=wanqu.co&utm_campaign=Wanqu+Daily&utm_medium=website#story-continues-1 +[7]:http://www.nytimes.com/newsletters/sample/bits?pgtype=subscriptionspage&version=business&contentId=TU&eventName=sample&module=newsletter-sign-up +[8]:https://www.nytimes.com/privacy +[9]:https://www.nytimes.com/help/index.html +[10]:https://bits.blogs.nytimes.com/2015/07/21/security-researchers-find-a-way-to-hack-cars/ +[11]:http://www.nytimes.com/topic/company/tesla-motors-inc?inline=nyt-org +[12]:http://www.autosec.org/pubs/cars-usenixsec2011.pdf +[13]:http://autos.nytimes.com/2011/Chevrolet/Volt/238/4117/329463/researchOverview.aspx?inline=nyt-classifier +[14]:http://topics.nytimes.com/top/reference/timestopics/subjects/m/military_aircraft/f35_airplane/index.html?inline=nyt-classifier +[15]:https://www.nytimes.com/2017/06/07/technology/why-car-companies-are-hiring-computer-security-experts.html?utm_source=wanqu.co&utm_campaign=Wanqu+Daily&utm_medium=website#story-continues-3 From 5fa73ba41a012805bdae5de5a9cfae29c560cc79 Mon Sep 17 00:00:00 2001 From: xu0o0 Date: Sun, 3 Dec 2017 21:01:07 +0800 Subject: [PATCH 161/344] translating by @haoqixu --- sources/tech/20171114 Sysadmin 101 Patch Management.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20171114 Sysadmin 101 Patch Management.md b/sources/tech/20171114 Sysadmin 101 Patch Management.md index 71df51258d..55ca09da87 100644 --- a/sources/tech/20171114 Sysadmin 101 Patch Management.md +++ b/sources/tech/20171114 Sysadmin 101 Patch Management.md @@ -1,4 +1,4 @@ -Sysadmin 101: Patch Management +【翻译中 @haoqixu】Sysadmin 101: Patch Management ============================================================ * [HOW-TOs][1] From 64bfa5c3a61a92629bcb53fedf062d2572bcd9c8 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 21:01:46 +0800 Subject: [PATCH 162/344] =?UTF-8?q?20171203-30=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...sers guide to Logical Volume Management.md | 233 ++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100644 sources/tech/20160922 A Linux users guide to Logical Volume Management.md diff --git a/sources/tech/20160922 A Linux users guide to Logical Volume Management.md b/sources/tech/20160922 A Linux users guide to Logical Volume Management.md new file mode 100644 index 0000000000..ff0e390f38 --- /dev/null +++ b/sources/tech/20160922 A Linux users guide to Logical Volume Management.md @@ -0,0 +1,233 @@ +A Linux user's guide to Logical Volume Management +============================================================ + +![Logical Volume Management (LVM)](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_other11x_cc.png?itok=I_kCDYj0 "Logical Volume Management (LVM)") +Image by : opensource.com + +Managing disk space has always been a significant task for sysadmins. Running out of disk space used to be the start of a long and complex series of tasks to increase the space available to a disk partition. It also required taking the system off-line. This usually involved installing a new hard drive, booting to recovery or single-user mode, creating a partition and a filesystem on the new hard drive, using temporary mount points to move the data from the too-small filesystem to the new, larger one, changing the content of the /etc/fstab file to reflect the correct device name for the new partition, and rebooting to remount the new filesystem on the correct mount point. + +I have to tell you that, when LVM (Logical Volume Manager) first made its appearance in Fedora Linux, I resisted it rather strongly. My initial reaction was that I did not need this additional layer of abstraction between me and the hard drives. It turns out that I was wrong, and that logical volume management is very useful. + +LVM allows for very flexible disk space management. It provides features like the ability to add disk space to a logical volume and its filesystem while that filesystem is mounted and active and it allows for the collection of multiple physical hard drives and partitions into a single volume group which can then be divided into logical volumes. + +The volume manager also allows reducing the amount of disk space allocated to a logical volume, but there are a couple requirements. First, the volume must be unmounted. Second, the filesystem itself must be reduced in size before the volume on which it resides can be reduced. + +It is important to note that the filesystem itself must allow resizing for this feature to work. The EXT2, 3, and 4 filesystems all allow both offline (unmounted) and online (mounted) resizing when increasing the size of a filesystem, and offline resizing when reducing the size. You should check the details of the filesystems you intend to use in order to verify whether they can be resized at all and especially whether they can be resized while online. + +### Expanding a filesystem on the fly + +I always like to run new distributions in a VirtualBox virtual machine for a few days or weeks to ensure that I will not run into any devastating problems when I start installing it on my production machines. One morning a couple years ago I started installing a newly released version of Fedora in a virtual machine on my primary workstation. I thought that I had enough disk space allocated to the host filesystem in which the VM was being installed. I did not. About a third of the way through the installation I ran out of space on that filesystem. Fortunately, VirtualBox detected the out-of-space condition and paused the virtual machine, and even displayed an error message indicating the exact cause of the problem. + +Note that this problem was not due to the fact that the virtual disk was too small, it was rather the logical volume on the host computer that was running out of space so that the virtual disk belonging to the virtual machine did not have enough space to expand on the host's logical volume. + +Since most modern distributions use Logical Volume Management by default, and I had some free space available on the volume group, I was able to assign additional disk space to the appropriate logical volume and then expand filesystem of the host on the fly. This means that I did not have to reformat the entire hard drive and reinstall the operating system or even reboot. I simply assigned some of the available space to the appropriate logical volume and resized the filesystem—all while the filesystem was on-line and the running program, The virtual machine was still using the host filesystem. After resizing the logical volume and the filesystem I resumed running the virtual machine and the installation continued as if no problems had occurred. + +Although this type of problem may never have happened to you, running out of disk space while a critical program is running has happened to many people. And while many programs, especially Windows programs, are not as well written and resilient as VirtualBox, Linux Logical Volume Management made it possible to recover without losing any data and without having to restart the time-consuming installation. + +### LVM Structure + +The structure of a Logical Volume Manager disk environment is illustrated by Figure 1, below. Logical Volume Management enables the combining of multiple individual hard drives and/or disk partitions into a single volume group (VG). That volume group can then be subdivided into logical volumes (LV) or used as a single large volume. Regular file systems, such as EXT3 or EXT4, can then be created on a logical volume. + +In Figure 1, two complete physical hard drives and one partition from a third hard drive have been combined into a single volume group. Two logical volumes have been created from the space in the volume group, and a filesystem, such as an EXT3 or EXT4 filesystem has been created on each of the two logical volumes. + +![lvm.png](https://opensource.com/sites/default/files/resize/images/life-uploads/lvm-520x222.png) + + _Figure 1: LVM allows combining partitions and entire hard drives into Volume Groups._ + +Adding disk space to a host is fairly straightforward but, in my experience, is done relatively infrequently. The basic steps needed are listed below. You can either create an entirely new volume group or you can add the new space to an existing volume group and either expand an existing logical volume or create a new one. + +### Adding a new logical volume + +There are times when it is necessary to add a new logical volume to a host. For example, after noticing that the directory containing virtual disks for my VirtualBox virtual machines was filling up the /home filesystem, I decided to create a new logical volume in which to store the virtual machine data, including the virtual disks. This would free up a great deal of space in my /home filesystem and also allow me to manage the disk space for the VMs independently. + +The basic steps for adding a new logical volume are as follows. + +1. If necessary, install a new hard drive. + +2. Optional: Create a partition on the hard drive. + +3. Create a physical volume (PV) of the complete hard drive or a partition on the hard drive. + +4. Assign the new physical volume to an existing volume group (VG) or create a new volume group. + +5. Create a new logical volumes (LV) from the space in the volume group. + +6. Create a filesystem on the new logical volume. + +7. Add appropriate entries to /etc/fstab for mounting the filesystem. + +8. Mount the filesystem. + +Now for the details. The following sequence is taken from an example I used as a lab project when teaching about Linux filesystems. + +### Example + +This example shows how to use the CLI to extend an existing volume group to add more space to it, create a new logical volume in that space, and create a filesystem on the logical volume. This procedure can be performed on a running, mounted filesystem. + +WARNING: Only the EXT3 and EXT4 filesystems can be resized on the fly on a running, mounted filesystem. Many other filesystems including BTRFS and ZFS cannot be resized. + +### Install hard drive + +If there is not enough space in the volume group on the existing hard drive(s) in the system to add the desired amount of space it may be necessary to add a new hard drive and create the space to add to the Logical Volume. First, install the physical hard drive, and then perform the following steps. + +### Create Physical Volume from hard drive + +It is first necessary to create a new Physical Volume (PV). Use the command below, which assumes that the new hard drive is assigned as /dev/hdd. + +``` +pvcreate /dev/hdd +``` + +It is not necessary to create a partition of any kind on the new hard drive. This creation of the Physical Volume which will be recognized by the Logical Volume Manager can be performed on a newly installed raw disk or on a Linux partition of type 83\. If you are going to use the entire hard drive, creating a partition first does not offer any particular advantages and uses disk space for metadata that could otherwise be used as part of the PV. + +### Extend the existing Volume Group + +In this example we will extend an existing volume group rather than creating a new one; you can choose to do it either way. After the Physical Volume has been created, extend the existing Volume Group (VG) to include the space on the new PV. In this example the existing Volume Group is named MyVG01. + +``` +vgextend /dev/MyVG01 /dev/hdd +``` + +### Create the Logical Volume + +First create the Logical Volume (LV) from existing free space within the Volume Group. The command below creates a LV with a size of 50GB. The Volume Group name is MyVG01 and the Logical Volume Name is Stuff. + +``` +lvcreate -L +50G --name Stuff MyVG01 +``` + +### Create the filesystem + +Creating the Logical Volume does not create the filesystem. That task must be performed separately. The command below creates an EXT4 filesystem that fits the newly created Logical Volume. + +``` +mkfs -t ext4 /dev/MyVG01/Stuff +``` + +### Add a filesystem label + +Adding a filesystem label makes it easy to identify the filesystem later in case of a crash or other disk related problems. + +``` +e2label /dev/MyVG01/Stuff Stuff +``` + +### Mount the filesystem + +At this point you can create a mount point, add an appropriate entry to the /etc/fstab file, and mount the filesystem. + +You should also check to verify the volume has been created correctly. You can use the **df**, **lvs,** and **vgs** commands to do this. + +### Resizing a logical volume in an LVM filesystem + +The need to resize a filesystem has been around since the beginning of the first versions of Unix and has not gone away with Linux. It has gotten easier, however, with Logical Volume Management. + +1. If necessary, install a new hard drive. + +2. Optional: Create a partition on the hard drive. + +3. Create a physical volume (PV) of the complete hard drive or a partition on the hard drive. + +4. Assign the new physical volume to an existing volume group (VG) or create a new volume group. + +5. Create one or more logical volumes (LV) from the space in the volume group, or expand an existing logical volume with some or all of the new space in the volume group. + +6. If you created a new logical volume, create a filesystem on it. If adding space to an existing logical volume, use the resize2fs command to enlarge the filesystem to fill the space in the logical volume. + +7. Add appropriate entries to /etc/fstab for mounting the filesystem. + +8. Mount the filesystem. + +### Example + +This example describes how to resize an existing Logical Volume in an LVM environment using the CLI. It adds about 50GB of space to the /Stuff filesystem. This procedure can be used on a mounted, live filesystem only with the Linux 2.6 Kernel (and higher) and EXT3 and EXT4 filesystems. I do not recommend that you do so on any critical system, but it can be done and I have done so many times; even on the root (/) filesystem. Use your judgment. + +WARNING: Only the EXT3 and EXT4 filesystems can be resized on the fly on a running, mounted filesystem. Many other filesystems including BTRFS and ZFS cannot be resized. + +### Install the hard drive + +If there is not enough space on the existing hard drive(s) in the system to add the desired amount of space it may be necessary to add a new hard drive and create the space to add to the Logical Volume. First, install the physical hard drive and then perform the following steps. + +### Create a Physical Volume from the hard drive + +It is first necessary to create a new Physical Volume (PV). Use the command below, which assumes that the new hard drive is assigned as /dev/hdd. + +``` +pvcreate /dev/hdd +``` + +It is not necessary to create a partition of any kind on the new hard drive. This creation of the Physical Volume which will be recognized by the Logical Volume Manager can be performed on a newly installed raw disk or on a Linux partition of type 83\. If you are going to use the entire hard drive, creating a partition first does not offer any particular advantages and uses disk space for metadata that could otherwise be used as part of the PV. + +### Add PV to existing Volume Group + +For this example, we will use the new PV to extend an existing Volume Group. After the Physical Volume has been created, extend the existing Volume Group (VG) to include the space on the new PV. In this example, the existing Volume Group is named MyVG01. + +``` +vgextend /dev/MyVG01 /dev/hdd +``` + +### Extend the Logical Volume + +Extend the Logical Volume (LV) from existing free space within the Volume Group. The command below expands the LV by 50GB. The Volume Group name is MyVG01 and the Logical Volume Name is Stuff. + +``` +lvextend -L +50G /dev/MyVG01/Stuff +``` + +### Expand the filesystem + +Extending the Logical Volume will also expand the filesystem if you use the -r option. If you do not use the -r option, that task must be performed separately. The command below resizes the filesystem to fit the newly resized Logical Volume. + +``` +resize2fs /dev/MyVG01/Stuff +``` + +You should check to verify the resizing has been performed correctly. You can use the **df**, **lvs,** and **vgs** commands to do this. + +### Tips + +Over the years I have learned a few things that can make logical volume management even easier than it already is. Hopefully these tips can prove of some value to you. + +* Use the Extended file systems unless you have a clear reason to use another filesystem. Not all filesystems support resizing but EXT2, 3, and 4 do. The EXT filesystems are also very fast and efficient. In any event, they can be tuned by a knowledgeable sysadmin to meet the needs of most environments if the defaults tuning parameters do not. + +* Use meaningful volume and volume group names. + +* Use EXT filesystem labels. + +I know that, like me, many sysadmins have resisted the change to Logical Volume Management. I hope that this article will encourage you to at least try LVM. I am really glad that I did; my disk management tasks are much easier since I made the switch. + + +### About the author + + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/david-crop.jpg?itok=oePpOpyV)][10] + + David Both - David Both is a Linux and Open Source advocate who resides in Raleigh, North Carolina. He has been in the IT industry for over forty years and taught OS/2 for IBM where he worked for over 20 years. While at IBM, he wrote the first training course for the original IBM PC in 1981\. He has taught RHCE classes for Red Hat and has worked at MCI Worldcom, Cisco, and the State of North Carolina. He has been working with Linux and Open Source Software for almost 20 years. David has written articles for... [more about David Both][7][More about me][8] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/business/16/9/linux-users-guide-lvm + +作者:[ David Both][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/dboth +[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[6]:https://opensource.com/business/16/9/linux-users-guide-lvm?rate=79vf1js7A7rlp-I96YFneopUQqsa2SuB-g-og7eiF1U +[7]:https://opensource.com/users/dboth +[8]:https://opensource.com/users/dboth +[9]:https://opensource.com/user/14106/feed +[10]:https://opensource.com/users/dboth +[11]:https://opensource.com/users/dboth +[12]:https://opensource.com/users/dboth +[13]:https://opensource.com/business/16/9/linux-users-guide-lvm#comments +[14]:https://opensource.com/tags/business +[15]:https://opensource.com/tags/linux +[16]:https://opensource.com/tags/how-tos-and-tutorials +[17]:https://opensource.com/tags/sysadmin From 3822959a7a40586f1e33861e0f9c2f7144a63eac Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Sun, 3 Dec 2017 21:19:34 +0800 Subject: [PATCH 163/344] Create Linux Networking Hardware for Beginners: Think Software --- ...ing Hardware for Beginners: Think Software | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 translated/tech/Linux Networking Hardware for Beginners: Think Software diff --git a/translated/tech/Linux Networking Hardware for Beginners: Think Software b/translated/tech/Linux Networking Hardware for Beginners: Think Software new file mode 100644 index 0000000000..a236a80e97 --- /dev/null +++ b/translated/tech/Linux Networking Hardware for Beginners: Think Software @@ -0,0 +1,89 @@ +Translating by FelixYFZ + +面向初学者的Linux网络硬件: 软件工程思想 +============================================================ + +![island network](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/soderskar-island.jpg?itok=wiMaF66b "island network") + 没有路由和桥接,我们将会成为孤独的小岛,你将会在这个网络教程中学到更多知识。 +Commons Zero][3]Pixabay + + 上周,我们学习了本地网络硬件知识,本周,我们将学习网络互联技术和在移动网络中的一些很酷的黑客技术。 +### Routers:路由器 + + +网络路由器就是计算机网络中的一切,因为路由器连接着网络,没有路由器,我们就会成为孤岛, + +图一展示了一个简单的有线本地网络和一个无线接入点,所有设备都接入到Internet上,本地局域网的计算机连接到一个连接着防火墙或者路由器的以太网交换机上,防火墙或者路由器连接到网络服务供应商提供的电缆箱,调制调节器,卫星上行系统...好像一切都在计算中,就像是一个带着不停闪烁的的小灯的盒子,当你的网络数据包离开你的局域网,进入广阔的互联网,它们穿过一个又一个路由器直到到达自己的目的地。 + + +### [fig-1.png][4] + +![simple LAN](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_7.png?itok=lsazmf3- "simple LAN") + +图一:一个简单的有线局域网和一个无线接入点。 + +一台路由器能连接一切,一个小巧特殊的小盒子只专注于路由,一个大点的盒子将会提供路由,防火墙,域名服务,以及VPN网关功能,一台重新设计的台式电脑或者笔记本,一个树莓派计算机或者一个小模块,体积臃肿矮小的像PC这样的单板计算机,除了苛刻的用途以外,普通的商品硬件都能良好的工作运行。高端的路由器使用特殊设计的硬件每秒能够传输最大量的数据包。 它们有多路数据总线,多个中央处理器和极快的存储。 +可以通过查阅Juniper和思科的路由器来感受一下高端路由器书什么样子的,而且能看看里面是什么样的构造。 +一个接入你的局域网的无线接入点要么作为一个以太网网桥要么作为一个路由器。一个桥接器扩展了这个网络,所以在这个桥接器上的任意一端口上的主机都连接在同一个网络中。 +一台路由器连接的是两个不同的网络。 +### Network Topology:网络拓扑 + + +有多种设置你的局域网的方式,你可以把所有主机接入到一个单独的平面网络,如果你的交换机支持的话,你也可以把它们分配到不同的子网中。 +平面网络是最简单的网络,只需把每一台设备接入到同一个交换机上即可,如果一台交换上的端口不够使用,你可以将更多的交换机连接在一起。 +有些交换机有特殊的上行端口,有些是没有这种特殊限制的上行端口,你可以连接其中的任意端口,你可能需要使用交叉类型的以太网线,所以你要查阅你的交换机的说明文档来设置。平面网络是最容易管理的,你不需要路由器也不需要计算子网,但它也有一些缺点。他们的伸缩性不好,所以当网络规模变得越来越大的时候就会被广播网络所阻塞。 +将你的局域网进行分段将会提升安全保障, 把局域网分成可管理的不同网段将有助于管理更大的网络。 + 图2展示了一个分成两个子网的局域网络:内部的有线和无线主机,和非军事区域(从来不知道所所有的工作上的男性术语都是在计算机上键入的?)因为他被阻挡了所有的内部网络的访问。 + + +### [fig-2.png][5] + +![LAN](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-2_4.png?itok=LpXq7bLf "LAN") + +图2:一个分成两个子网的简单局域网。 +即使像图2那样的小型网络也可以有不同的配置方法。你可以将防火墙和路由器放置在一台单独的设备上。 +你可以为你的非军事区域设置一个专用的网络连接,把它完全从你的内部网络隔离,这将引导我们进入下一个主题:一切基于软件。 + + +### Think Software软件思维 + + +你可能已经注意到在这个简短的系列中我们所讨论的硬件,只有网络接口,交换机,和线缆是特殊用途的硬件。 +其它的都是通用的商用硬件,而且都是软件来定义它的用途。 +网关,虚拟专用网关,以太网桥,网页,邮箱以及文件等等。 +服务器,负载均衡,代理,大量的服务,各种各样的认证,中继,故障转移...你可以在运行着Linux系统的标准硬件上运行你的整个网络。 +你甚至可以使用Linux交换应用和VDE2协议来模拟以太网交换机,像DD-WRT,openWRT 和Rashpberry Pi distros,这些小型的硬件都是有专业的分类的,要记住BSDS和它们的特殊衍生用途如防火墙,路由器,和网络附件存储。 +你知道有些人坚持认为硬件防火墙和软件防火墙有区别?其实是没有区别的,就像说有一台硬件计算机和一台软件计算机。 +### Port Trunking and Ethernet Bonding +端口聚合和以太网绑定 +聚合和绑定,也称链路聚合,是把两条以太网通道绑定在一起成为一条通道。一些交换机支持端口聚合,就是把两个交换机端口绑定在一起成为一个是他们原来带宽之和的一条新的连接。对于一台承载很多业务的服务器来说这是一个增加通道带宽的有效的方式。 +你也可以在以太网口进行同样的配置,而且绑定汇聚的驱动是内置在Linux内核中的,所以不需要任何其他的专门的硬件。 + + +### Bending Mobile Broadband to your Will随心所欲选择你的移动带宽 + +我期望移动带宽能够迅速增长来替代DSL和有线网络。我居住在一个有250,000人口的靠近一个城市的地方,但是在城市以外,要想接入互联网就要靠运气了,即使那里有很大的用户上网需求。我居住的小角落离城镇有20分钟的距离,但对于网络服务供应商来说他们几乎不会考虑到为这个地方提供网络。 我唯一的选择就是移动带宽; 这里没有拨号网络,卫星网络(即使它很糟糕)或者是DSL,电缆,光纤,但却没有阻止网络供应商把那些在我这个区域从没看到过的无限制通信个其他高速网络服务的传单塞进我的邮箱。 +我试用了AT&T,Version,和T-Mobile。Version的信号覆盖范围最广,但是Version和AT&T是最昂贵的。 +我居住的地方在T-Mobile信号覆盖的边缘,但迄今为止他们给了最大的优惠,为了能够能够有效的使用,我必须购买一个WeBoostDe信号放大器和 +一台中兴的移动热点设备。当然你也可以使用一部手机作为热点,但是专用的热点设备有着最强的信号。如果你正在考虑购买一台信号放大器,最好的选择就是WeBoost因为他们的服务支持最棒,而且他们会尽最大努力去帮助你。在一个小小的APP的协助下去设置将会精准的增强 你的网络信号,他们有一个功能较少的免费的版本,但你将一点都不会后悔去花两美元使用专业版。 +那个小巧的中兴热点设备能够支持15台主机而且还有拥有基本的防火墙功能。 但你如果你使用像 Linksys WRT54GL这样的设备,使用Tomato,openWRT,或者DD-WRT来替代普通的固件,这样你就能完全控制你的防护墙规则,路由配置,以及任何其他你想要设置的服务。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2017/10/linux-networking-hardware-beginners-think-software + +作者:[CARLA SCHRODER][a] +译者:[FelixYFZ](https://github.com/FelixYFZ) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/cschroder +[1]:https://www.linux.com/licenses/category/used-permission +[2]:https://www.linux.com/licenses/category/used-permission +[3]:https://www.linux.com/licenses/category/creative-commons-zero +[4]:https://www.linux.com/files/images/fig-1png-7 +[5]:https://www.linux.com/files/images/fig-2png-4 +[6]:https://www.linux.com/files/images/soderskar-islandjpg +[7]:https://www.linux.com/learn/intro-to-linux/2017/10/linux-networking-hardware-beginners-lan-hardware +[8]:http://www.bluelinepc.com/signalcheck/ From c5461dd8bb3457e1dca25237151b09e91385b917 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 22:02:08 +0800 Subject: [PATCH 164/344] =?UTF-8?q?20171203-31=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e your WiFi MAC address on Ubuntu 16.04.md | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md diff --git a/sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md b/sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md new file mode 100644 index 0000000000..b0f8e72018 --- /dev/null +++ b/sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md @@ -0,0 +1,160 @@ +Randomize your WiFi MAC address on Ubuntu 16.04 +============================================================ + + _Your device’s MAC address can be used to track you across the WiFi networks you connect to. That data can be shared and sold, and often identifies you as an individual. It’s possible to limit this tracking by using pseudo-random MAC addresses._ + +![A captive portal screen for a hotel allowing you to log in with social media for an hour of free WiFi](https://www.paulfurley.com/img/captive-portal-our-hotel.gif) + + _Image courtesy of [Cloudessa][4]_ + +Every network device like a WiFi or Ethernet card has a unique identifier called a MAC address, for example `b4:b6:76:31:8c:ff`. It’s how networking works: any time you connect to a WiFi network, the router uses that address to send and receive packets to your machine and distinguish it from other devices in the area. + +The snag with this design is that your unique, unchanging MAC address is just perfect for tracking you. Logged into Starbucks WiFi? Noted. London Underground? Logged. + +If you’ve ever put your real name into one of those Craptive Portals on a WiFi network you’ve now tied your identity to that MAC address. Didn’t read the terms and conditions? You might assume that free airport WiFi is subsidised by flogging ‘customer analytics’ (your personal information) to hotels, restaurant chains and whomever else wants to know about you. + +I don’t subscribe to being tracked and sold by mega-corps, so I spent a few hours hacking a solution. + +### MAC addresses don’t need to stay the same + +Fortunately, it’s possible to spoof your MAC address to a random one without fundamentally breaking networking. + +I wanted to randomize my MAC address, but with three particular caveats: + +1. The MAC should be different across different networks. This means Starbucks WiFi sees a different MAC from London Underground, preventing linking my identity across different providers. + +2. The MAC should change regularly to prevent a network knowing that I’m the same person who walked past 75 times over the last year. + +3. The MAC stays the same throughout each working day. When the MAC address changes, most networks will kick you off, and those with Craptive Portals will usually make you sign in again - annoying. + +### Manipulating NetworkManager + +My first attempt of using the `macchanger` tool was unsuccessful as NetworkManager would override the MAC address according to its own configuration. + +I learned that NetworkManager 1.4.1+ can do MAC address randomization right out the box. If you’re using Ubuntu 17.04 upwards, you can get most of the way with [this config file][7]. You can’t quite achieve all three of my requirements (you must choose  _random_ or  _stable_  but it seems you can’t do  _stable-for-one-day_ ). + +Since I’m sticking with Ubuntu 16.04 which ships with NetworkManager 1.2, I couldn’t make use of the new functionality. Supposedly there is some randomization support but I failed to actually make it work, so I scripted up a solution instead. + +Fortunately NetworkManager 1.2 does allow for spoofing your MAC address. You can see this in the ‘Edit connections’ dialog for a given network: + +![Screenshot of NetworkManager's edit connection dialog, showing a text entry for a cloned mac address](https://www.paulfurley.com/img/network-manager-cloned-mac-address.png) + +NetworkManager also supports hooks - any script placed in `/etc/NetworkManager/dispatcher.d/pre-up.d/` is run before a connection is brought up. + +### Assigning pseudo-random MAC addresses + +To recap, I wanted to generate random MAC addresses based on the  _network_  and the  _date_ . We can use the NetworkManager command line, nmcli, to show a full list of networks: + +``` +> nmcli connection +NAME UUID TYPE DEVICE +Gladstone Guest 618545ca-d81a-11e7-a2a4-271245e11a45 802-11-wireless wlp1s0 +DoESDinky 6e47c080-d81a-11e7-9921-87bc56777256 802-11-wireless -- +PublicWiFi 79282c10-d81a-11e7-87cb-6341829c2a54 802-11-wireless -- +virgintrainswifi 7d0c57de-d81a-11e7-9bae-5be89b161d22 802-11-wireless -- + +``` + +Since each network has a unique identifier, to achieve my scheme I just concatenated the UUID with today’s date and hashed the result: + +``` + +# eg 618545ca-d81a-11e7-a2a4-271245e11a45-2017-12-03 + +> echo -n "${UUID}-$(date +%F)" | md5sum + +53594de990e92f9b914a723208f22b3f - + +``` + +That produced bytes which can be substituted in for the last octets of the MAC address. + +Note that the first byte `02` signifies the address is [locally administered][8]. Real, burned-in MAC addresses start with 3 bytes designing their manufacturer, for example `b4:b6:76` for Intel. + +It’s possible that some routers may reject locally administered MACs but I haven’t encountered that yet. + +On every connection up, the script calls `nmcli` to set the spoofed MAC address for every connection: + +![A terminal window show a number of nmcli command line calls](https://www.paulfurley.com/img/terminal-window-nmcli-commands.png) + +As a final check, if I look at `ifconfig` I can see that the `HWaddr` is the spoofed one, not my real MAC address: + +``` +> ifconfig +wlp1s0 Link encap:Ethernet HWaddr b4:b6:76:45:64:4d + inet addr:192.168.0.86 Bcast:192.168.0.255 Mask:255.255.255.0 + inet6 addr: fe80::648c:aff2:9a9d:764/64 Scope:Link + UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 + RX packets:12107812 errors:0 dropped:2 overruns:0 frame:0 + TX packets:18332141 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:1000 + RX bytes:11627977017 (11.6 GB) TX bytes:20700627733 (20.7 GB) + +``` + +The full script is [available on Github][9]. + +``` +#!/bin/sh + +# /etc/NetworkManager/dispatcher.d/pre-up.d/randomize-mac-addresses + +# Configure every saved WiFi connection in NetworkManager with a spoofed MAC +# address, seeded from the UUID of the connection and the date eg: +# 'c31bbcc4-d6ad-11e7-9a5a-e7e1491a7e20-2017-11-20' + +# This makes your MAC impossible(?) to track across WiFi providers, and +# for one provider to track across days. + +# For craptive portals that authenticate based on MAC, you might want to +# automate logging in :) + +# Note that NetworkManager >= 1.4.1 (Ubuntu 17.04+) can do something similar +# automatically. + +export PATH=$PATH:/usr/bin:/bin + +LOG_FILE=/var/log/randomize-mac-addresses + +echo "$(date): $*" > ${LOG_FILE} + +WIFI_UUIDS=$(nmcli --fields type,uuid connection show |grep 802-11-wireless |cut '-d ' -f3) + +for UUID in ${WIFI_UUIDS} +do + UUID_DAILY_HASH=$(echo "${UUID}-$(date +F)" | md5sum) + + RANDOM_MAC="02:$(echo -n ${UUID_DAILY_HASH} | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5/')" + + CMD="nmcli connection modify ${UUID} wifi.cloned-mac-address ${RANDOM_MAC}" + + echo "$CMD" >> ${LOG_FILE} + $CMD & +done + +wait +``` +Enjoy! + + _Update: [Use locally administered MAC addresses][5] to avoid clashing with real Intel ones. Thanks [@_fink][6]_ + +-------------------------------------------------------------------------------- + +via: https://www.paulfurley.com/randomize-your-wifi-mac-address-on-ubuntu-1604-xenial/ + +作者:[Paul M Furley ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.paulfurley.com/ +[1]:https://gist.github.com/paulfurley/46e0547ce5c5ea7eabeaef50dbacef3f/raw/5f02fc8f6ff7fca5bca6ee4913c63bf6de15abca/randomize-mac-addresses +[2]:https://gist.github.com/paulfurley/46e0547ce5c5ea7eabeaef50dbacef3f#file-randomize-mac-addresses +[3]:https://github.com/ +[4]:http://cloudessa.com/products/cloudessa-aaa-and-captive-portal-cloud-service/ +[5]:https://gist.github.com/paulfurley/46e0547ce5c5ea7eabeaef50dbacef3f/revisions#diff-824d510864d58c07df01102a8f53faef +[6]:https://twitter.com/fink_/status/937305600005943296 +[7]:https://gist.github.com/paulfurley/978d4e2e0cceb41d67d017a668106c53/ +[8]:https://en.wikipedia.org/wiki/MAC_address#Universal_vs._local +[9]:https://gist.github.com/paulfurley/46e0547ce5c5ea7eabeaef50dbacef3f From 821ac6943b79d1470e585966c35dc10d64ed942f Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 22:03:51 +0800 Subject: [PATCH 165/344] =?UTF-8?q?20171203-32=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...every domain someone owns automatically.md | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 sources/tech/20171130 New Feature Find every domain someone owns automatically.md diff --git a/sources/tech/20171130 New Feature Find every domain someone owns automatically.md b/sources/tech/20171130 New Feature Find every domain someone owns automatically.md new file mode 100644 index 0000000000..4b9fedf168 --- /dev/null +++ b/sources/tech/20171130 New Feature Find every domain someone owns automatically.md @@ -0,0 +1,49 @@ +New Feature: Find every domain someone owns automatically +============================================================ + + +Today, we are excited to announce our latest feature which we have been working on for the past weeks. It is the Whois aggregation tool that is now available on [DNSTrails][1]. + +In the past, searching for domain owners took lot of time, because most of the time you needed to have the domain names pointed to an IP address in order to find the rest of the domains owned by the same person. + +Using that old method you could easily lose hours and hours each day by researching and crossing results and data between one tool and another until you got the domain list you wanted. + +Thanks to this new tool and our intelligent [WHOIS database][2], now you can search for any domain name and get the full list of domains registered by that organization or person and get accurate results within seconds. + +### How can I use the Whois aggregation feature? + +Step 1: Open up [DNSTrails.com][3] + +Step 2: Search for any domain name, for example: godaddy.com + +Step 3: After you get the results for the domain name, locate the Whois information block as you see below: + +![Domain name search results](https://securitytrails.com/images/a/a/1/3/f/aa13fa3616b8dc313f925bdbf1da43a54856d463-image1.png) + +Step 4: You will notice there is a phone number and email address associated with the domain name. + +Step 5: Click on the links at the right, you will easily find the rest of the domain names registered with the same telephone and email address. + +![All domain names by the same owner](https://securitytrails.com/images/1/3/4/0/3/134037822d23db4907d421046b11f3cbb872f94f-image2.png) + +This means, that even if the domains doesn't even have IPs pointed at the registrar, we can still discover the rest of the domains if they use the same phone and mail address, pretty useful if you are investigating domain ownership from any individual on the Internet. + +Ever wanted to know which other domains are owned by a person? Try the [WHOIS aggregation feature][4] at [DNStrails][5] yourself or [get in touch with us for API access][6]. + +-------------------------------------------------------------------------------- + +via: https://securitytrails.com/blog/find-every-domain-someone-owns + +作者:[SECURITYTRAILS TEAM ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://securitytrails.com/blog/find-every-domain-someone-owns +[1]:https://dnstrails.com/ +[2]:https://securitytrails.com/forensics +[3]:https://dnstrails.com/ +[4]:http://dnstrails.com/#/domain/domain/ueland.com +[5]:https://dnstrails.com/ +[6]:https://securitytrails.com/contact From 63cd31f06f6f91c6f2cf55c3869dadeb0f5ca5a9 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 22:08:49 +0800 Subject: [PATCH 166/344] =?UTF-8?q?20171203-33=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...6 Introducing security alerts on GitHub.md | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 sources/tech/20171116 Introducing security alerts on GitHub.md diff --git a/sources/tech/20171116 Introducing security alerts on GitHub.md b/sources/tech/20171116 Introducing security alerts on GitHub.md new file mode 100644 index 0000000000..0bfef7757d --- /dev/null +++ b/sources/tech/20171116 Introducing security alerts on GitHub.md @@ -0,0 +1,48 @@ +Introducing security alerts on GitHub +==================================== + + +Last month, we made it easier for you to keep track of the projects your code depends on with the dependency graph, currently supported in Javascript and Ruby. Today, for the over 75 percent of GitHub projects that have dependencies, we’re helping you do more than see those important projects. With your dependency graph enabled, we’ll now notify you when we detect a vulnerability in one of your dependencies and suggest known fixes from the GitHub community. + + [![Security Alerts & Suggested Fix](https://user-images.githubusercontent.com/594029/32851987-76c36e4a-c9eb-11e7-98fc-feb39fddaadb.gif)][1] + +### How to start using security alerts + +Whether your projects are private or public, security alerts get vital vulnerability information to the right people on your team. + +Enable your dependency graph + +Public repositories will automatically have your dependency graph and security alerts enabled. For private repositories, you’ll need to opt in to security alerts in your repository settings or by allowing access in the Dependency graph section of your repository’s Insights tab. + +Set notification preferences + +When your dependency graph is enabled, admins will receive security alerts by default. Admins can also add teams or individuals as recipients for security alerts in the dependency graph settings. + +Respond to alerts + +When we notify you about a potential vulnerability, we’ll highlight any dependencies that we recommend updating. If a known safe version exists, we’ll select one using machine learning and publicly available data, and include it in our suggestion. + +### Vulnerability coverage + +Vulnerabilities that have [CVE IDs][2] (publicly disclosed vulnerabilities from the [National Vulnerability Database][3]) will be included in security alerts. However, not all vulnerabilities have CVE IDs—even many publicly disclosed vulnerabilities don't have them. We'll continue to get better at identifying vulnerabilities as our security data grows. For more help managing security issues, check out our [security partners in the GitHub Marketplace][4]. + +This is the next step in using the world’s largest collection of open source data to help you keep code safer and do your best work. The dependency graph and security alerts currently support Javascript and Ruby—with Python support coming in 2018. + +[Learn more about security alerts][5] + +-------------------------------------------------------------------------------- + +via: https://github.com/blog/2470-introducing-security-alerts-on-github + +作者:[mijuhan ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://github.com/mijuhan +[1]:https://user-images.githubusercontent.com/594029/32851987-76c36e4a-c9eb-11e7-98fc-feb39fddaadb.gif +[2]:https://cve.mitre.org/ +[3]:https://nvd.nist.gov/ +[4]:https://github.com/marketplace/category/security +[5]:https://help.github.com/articles/about-security-alerts-for-vulnerable-dependencies/ From e4ae5272879d67d861874e4ca74ec0f80d5b1180 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 22:11:02 +0800 Subject: [PATCH 167/344] =?UTF-8?q?20171203-34=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20171107 GitHub welcomes all CI tools.md | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 sources/tech/20171107 GitHub welcomes all CI tools.md diff --git a/sources/tech/20171107 GitHub welcomes all CI tools.md b/sources/tech/20171107 GitHub welcomes all CI tools.md new file mode 100644 index 0000000000..f3112d9481 --- /dev/null +++ b/sources/tech/20171107 GitHub welcomes all CI tools.md @@ -0,0 +1,93 @@ +GitHub welcomes all CI tools +==================== + + +[![GitHub and all CI tools](https://user-images.githubusercontent.com/29592817/32509084-2d52c56c-c3a1-11e7-8c49-901f0f601faf.png)][11] + +Continuous Integration ([CI][12]) tools help you stick to your team's quality standards by running tests every time you push a new commit and [reporting the results][13] to a pull request. Combined with continuous delivery ([CD][14]) tools, you can also test your code on multiple configurations, run additional performance tests, and automate every step [until production][15]. + +There are several CI and CD tools that [integrate with GitHub][16], some of which you can install in a few clicks from [GitHub Marketplace][17]. With so many options, you can pick the best tool for the job—even if it's not the one that comes pre-integrated with your system. + +The tools that will work best for you depends on many factors, including: + +* Programming language and application architecture + +* Operating system and browsers you plan to support + +* Your team's experience and skills + +* Scaling capabilities and plans for growth + +* Geographic distribution of dependent systems and the people who use them + +* Packaging and delivery goals + +Of course, it isn't possible to optimize your CI tool for all of these scenarios. The people who build them have to choose which use cases to serve best—and when to prioritize complexity over simplicity. For example, if you like to test small applications written in a particular programming language for one platform, you won't need the complexity of a tool that tests embedded software controllers on dozens of platforms with a broad mix of programming languages and frameworks. + +If you need a little inspiration for which CI tool might work best, take a look at [popular GitHub projects][18]. Many show the status of their integrated CI/CD tools as badges in their README.md. We've also analyzed the use of CI tools across more than 50 million repositories in the GitHub community, and found a lot of variety. The following diagram shows the relative percentage of the top 10 CI tools used with GitHub.com, based on the most used [commit status contexts][19] used within our pull requests. + + _Our analysis also showed that many teams use more than one CI tool in their projects, allowing them to emphasize what each tool does best._ + + [![Top 10 CI systems used with GitHub.com based on most used commit status contexts](https://user-images.githubusercontent.com/7321362/32575895-ea563032-c49a-11e7-9581-e05ec882658b.png)][20] + +If you'd like to check them out, here are the top 10 tools teams use: + +* [Travis CI][1] + +* [Circle CI][2] + +* [Jenkins][3] + +* [AppVeyor][4] + +* [CodeShip][5] + +* [Drone][6] + +* [Semaphore CI][7] + +* [Buildkite][8] + +* [Wercker][9] + +* [TeamCity][10] + +It's tempting to just pick the default, pre-integrated tool without taking the time to research and choose the best one for the job, but there are plenty of [excellent choices][21] built for your specific use cases. And if you change your mind later, no problem. When you choose the best tool for a specific situation, you're guaranteeing tailored performance and the freedom of interchangability when it no longer fits. + +Ready to see how CI tools can fit into your workflow? + +[Browse GitHub Marketplace][22] + +-------------------------------------------------------------------------------- + +via: https://github.com/blog/2463-github-welcomes-all-ci-tools + +作者:[jonico ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://github.com/jonico +[1]:https://travis-ci.org/ +[2]:https://circleci.com/ +[3]:https://jenkins.io/ +[4]:https://www.appveyor.com/ +[5]:https://codeship.com/ +[6]:http://try.drone.io/ +[7]:https://semaphoreci.com/ +[8]:https://buildkite.com/ +[9]:http://www.wercker.com/ +[10]:https://www.jetbrains.com/teamcity/ +[11]:https://user-images.githubusercontent.com/29592817/32509084-2d52c56c-c3a1-11e7-8c49-901f0f601faf.png +[12]:https://en.wikipedia.org/wiki/Continuous_integration +[13]:https://github.com/blog/2051-protected-branches-and-required-status-checks +[14]:https://en.wikipedia.org/wiki/Continuous_delivery +[15]:https://developer.github.com/changes/2014-01-09-preview-the-new-deployments-api/ +[16]:https://github.com/works-with/category/continuous-integration +[17]:https://github.com/marketplace/category/continuous-integration +[18]:https://github.com/explore?trending=repositories#trending +[19]:https://developer.github.com/v3/repos/statuses/ +[20]:https://user-images.githubusercontent.com/7321362/32575895-ea563032-c49a-11e7-9581-e05ec882658b.png +[21]:https://github.com/works-with/category/continuous-integration +[22]:https://github.com/marketplace/category/continuous-integration From 23624193afc75ecf7f0a9f15967d4c8f953fe23b Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 22:12:10 +0800 Subject: [PATCH 168/344] =?UTF-8?q?20171203-35=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tech/20171108 Archiving repositories.md | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 sources/tech/20171108 Archiving repositories.md diff --git a/sources/tech/20171108 Archiving repositories.md b/sources/tech/20171108 Archiving repositories.md new file mode 100644 index 0000000000..3537254131 --- /dev/null +++ b/sources/tech/20171108 Archiving repositories.md @@ -0,0 +1,37 @@ +Archiving repositories +==================== + + +Just because a repository isn't actively developed anymore and you don't want to accept additional contributions doesn't mean you want to delete it. Now archive repositories on GitHub to make them read-only. + + [![archived repository banner](https://user-images.githubusercontent.com/7321362/32558403-450458dc-c46a-11e7-96f9-af31d2206acb.png)][1] + +Archiving a repository makes it read-only to everyone (including repository owners). This includes editing the repository, issues, pull requests, labels, milestones, projects, wiki, releases, commits, tags, branches, reactions and comments. No one can create new issues, pull requests, or comments on an archived repository, but you can still fork archived repositories—allowing development to continue elsewhere for archived open source projects. + +To archive a repository, go to your Repository Settings Page and click Archive this repository. + + [![archive repository button](https://user-images.githubusercontent.com/125011/32273119-0fc5571e-bef9-11e7-9909-d137268a1d6d.png)][2] + +Before archiving your repository, make sure you've changed its settings and consider closing all open issues and pull requests. You should also update your README and description to make it clear to visitors that it's no longer possible to contribute. + +If you change your mind and want to unarchive your repository, click Unarchive this repositoryin the same place. Please note that most archived repository settings are hidden and you'll have to unarchive the repository to change them. + + [![archived labelled repository](https://user-images.githubusercontent.com/125011/32541128-9d67a064-c466-11e7-857e-3834054ba3c9.png)][3] + +To learn more, check out [the documentation][4] on archiving repositories. Happy archiving! + +-------------------------------------------------------------------------------- + +via: https://github.com/blog/2460-archiving-repositories + +作者:[MikeMcQuaid ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://github.com/MikeMcQuaid +[1]:https://user-images.githubusercontent.com/7321362/32558403-450458dc-c46a-11e7-96f9-af31d2206acb.png +[2]:https://user-images.githubusercontent.com/125011/32273119-0fc5571e-bef9-11e7-9909-d137268a1d6d.png +[3]:https://user-images.githubusercontent.com/125011/32541128-9d67a064-c466-11e7-857e-3834054ba3c9.png +[4]:https://help.github.com/articles/about-archiving-repositories/ From 0db2613e0e3d6a6391cf131d365467f5b6b0d325 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 22:15:04 +0800 Subject: [PATCH 169/344] =?UTF-8?q?20171203-36=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...171201 Linux Journal Ceases Publication.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 sources/tech/20171201 Linux Journal Ceases Publication.md diff --git a/sources/tech/20171201 Linux Journal Ceases Publication.md b/sources/tech/20171201 Linux Journal Ceases Publication.md new file mode 100644 index 0000000000..0bb9b3a77b --- /dev/null +++ b/sources/tech/20171201 Linux Journal Ceases Publication.md @@ -0,0 +1,34 @@ +Linux Journal Ceases Publication +============================================================ + +EOF + +It looks like we’re at the end, folks. If all goes according to a plan we’d rather not have, the November issue of Linux Journal was our last. + +The simple fact is that we’ve run out of money, and options along with it. We never had a wealthy corporate parent or deep pockets of our own, and that made us an anomaly among publishers, from start to finish. While we got to be good at flying close to the ground for a long time, we lost what little elevation we had in November, when the scale finally tipped irrevocably to the negative. + +While we see a future like publishing’s past—a time when advertisers sponsor a publication because they value its brand and readers—the advertising world we have today would rather chase eyeballs, preferably by planting tracking beacons in readers' browsers and zapping them with ads anywhere those readers show up. But that future isn’t here, and the past is long gone. + +There is some hope, we suppose, that a savior might come through; but it will have to be one willing to pick up some of our debt, in addition to our brand, our archive, our domains and our subscribers and readers. If you know anyone who can make a serious offer, let us know. Otherwise, watch LinuxJournal.com and hope that at least our legacy archives (which go back to Linux Journal’s birth in April 1994, when Linux hit 1.0) won’t go away. There’s a lot of great stuff here, and a lot of history we’d hate the world to lose. + +Our biggest regret is that we don’t even have enough money to return to the people who have valued us most: our subscribers. For that we could not apologize more deeply or sincerely. What we do have for subscribers: + +Linux Pro Magazine has offered our subscribers six free issues of their magazine, a publication we at Linux Journal have always admired. In our time of need, they were the first ones there for us, and we are thankful for their gracious offer. We also just finished up our 2017 archive today, which includes every issue we’ve ever published, including the first and last ones. Normally we sell that for $25, but obviously subscribers will get it for no cost. Subscribers, watch for an e-mail with details about both. + +We also hope there is some solace in knowing that we worked very, very hard at keeping Linux Journal going, and we’ve been doing that for a long time, running the leanest, smallest possible operation we could. We are a collection mostly of volunteers, and some of our employees haven’t been paid in months. We still owe money to freelancers as well. There is a limit to how long a publisher can maintain those neglects, and that limit has now been reached. + +It has been a great run, folks. A big hats-off to everyone who contributed to our birth, our success and our persistence over these many years. We’d run the credits now, but the list would be too long, and the risk of leaving worthy people out would be too high. You know who you are. Our thanks again. + +-------------------------------------------------------------------------------- + +via: https://www.linuxjournal.com/content/linux-journal-ceases-publication + +作者:[ Carlie Fairchild][a] +译者:[译者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/carlie-fairchild +[1]:https://www.linuxjournal.com/taxonomy/term/29 +[2]:https://www.linuxjournal.com/users/carlie-fairchild From ee49f88702cc478cf892476ce8594ff7fab5c515 Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 22:17:24 +0800 Subject: [PATCH 170/344] =?UTF-8?q?20171203-37=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...an event Introducing eBPF Kernel probes.md | 361 ++++++++++++++++++ 1 file changed, 361 insertions(+) create mode 100644 sources/tech/20160330 How to turn any syscall into an event Introducing eBPF Kernel probes.md diff --git a/sources/tech/20160330 How to turn any syscall into an event Introducing eBPF Kernel probes.md b/sources/tech/20160330 How to turn any syscall into an event Introducing eBPF Kernel probes.md new file mode 100644 index 0000000000..a53270f2d7 --- /dev/null +++ b/sources/tech/20160330 How to turn any syscall into an event Introducing eBPF Kernel probes.md @@ -0,0 +1,361 @@ +How to turn any syscall into an event: Introducing eBPF Kernel probes +============================================================ + + +TL;DR: Using eBPF in recent (>=4.4) Linux kernel, you can turn any kernel function call into a user land event with arbitrary data. This is made easy by bcc. The probe is written in C while the data is handled by python. + +If you are not familiar with eBPF or linux tracing, you really should read the full post. It tries to progressively go through the pitfalls I stumbled unpon while playing around with bcc / eBPF while saving you a lot of the time I spent searching and digging. + +### A note on push vs pull in a Linux world + +When I started to work on containers, I was wondering how we could update a load balancer configuration dynamically based on actual system state. A common strategy, which works, it to let the container orchestrator trigger a load balancer configuration update whenever it starts a container and then let the load balancer poll the container until some health check passes. It may be a simple “SYN” test. + +While this configuration works, it has the downside of making your load balancer waiting for some system to be available while it should be… load balancing. + +Can we do better? + +When you want a program to react to some change in a system there are 2 possible strategies. The program may  _poll_  the system to detect changes or, if the system supports it, the system may  _push_ events and let the program react to them. Wether you want to use push or poll depends on the context. A good rule of the thumb is to use push events when the event rate is low with respect to the processing time and switch to polling when the events are coming fast or the system may become unusable. For example, typical network driver will wait for events from the network card while frameworks like dpdk will actively poll the card for events to achieve the highest throughput and lowest latency. + +In an ideal world, we’d have some kernel interface telling us: + +> * “Hey Mr. ContainerManager, I’ve just created a socket for the Nginx-ware of container  _servestaticfiles_ , maybe you want to update your state?” +> +> * “Sure Mr. OS, Thanks for letting me know” + +While Linux has a wide range of interfaces to deal with events, up to 3 for file events, there is no dedicated interface to get socket event notifications. You can get routing table events, neighbor table events, conntrack events, interface change events. Just, not socket events. Or maybe there is, deep hidden in a Netlink interface. + +Ideally, we’d need a generic way to do it. How? + +### Kernel tracing and eBPF, a bit of history + +Until recently the only way was to patch the kernel or resort on SystemTap. [SytemTap][5] is a tracing Linux system. In a nutshell, it provides a DSL which is then compiled into a kernel module which is then live-loaded into the running kernel. Except that some production system disable dynamic module loading for security reasons. Including the one I was working on at that time. The other way would be to patch the kernel to trigger some events, probably based on netlink. This is not really convenient. Kernel hacking come with downsides including “interesting” new “features” and increased maintenance burden. + +Hopefully, starting with Linux 3.15 the ground was laid to safely transform any traceable kernel function into userland events. “Safely” is common computer science expression referring to “some virtual machine”. This case is no exception. Linux has had one for years. Since Linux 2.1.75 released in 1997 actually. It’s called Berkeley Packet Filter of BPF for short. As its name suggests, it was originally developed for the BSD firewalls. It had only 2 registers and only allowed forward jumps meaning that you could not write loops with it (Well, you can, if you know the maximum iterations and you manually unroll them). The point was to guarantee the program would always terminate and hence never hang the system. Still not sure if it has any use while you have iptables? It serves as the [foundation of CloudFlare’s AntiDDos protection][6]. + +OK, so, with Linux the 3.15, [BPF was extended][7] turning it into eBPF. For “extended” BPF. It upgrades from 2 32 bits registers to 10 64 bits 64 registers and adds backward jumping among others. It has then been [further extended in Linux 3.18][8] moving it out of the networking subsystem, and adding tools like maps. To preserve the safety guarantees, it [introduces a checker][9] which validates all memory accesses and possible code path. If the checker can’t guarantee the code will terminate within fixed boundaries, it will deny the initial insertion of the program. + +For more history, there is [an excellent Oracle presentation on eBPF][10]. + +Let’s get started. + +### Hello from from `inet_listen` + +As writing assembly is not the most convenient task, even for the best of us, we’ll use [bcc][11]. bcc is a collection of tools based on LLVM and Python abstracting the underlying machinery. Probes are written in C and the results can be exploited from python allowing to easily write non trivial applications. + +Start by install bcc. For some of these examples, you may require a recent (read >= 4.4) version of the kernel. If you are willing to actually try these examples, I highly recommend that you setup a VM.  _NOT_  a docker container. You can’t change the kernel in a container. As this is a young and dynamic projects, install instructions are highly platform/version dependant. You can find up to date instructions on [https://github.com/iovisor/bcc/blob/master/INSTALL.md][12] + +So, we want to get an event whenever a program starts to listen on TCP socket. When calling the `listen()` syscall on a `AF_INET` + `SOCK_STREAM` socket, the underlying kernel function is [`inet_listen`][13]. We’ll start by hooking a “Hello World” `kprobe` on it’s entrypoint. + +``` +from bcc import BPF + +# Hello BPF Program +bpf_text = """ +#include +#include + +// 1\. Attach kprobe to "inet_listen" +int kprobe__inet_listen(struct pt_regs *ctx, struct socket *sock, int backlog) +{ + bpf_trace_printk("Hello World!\\n"); + return 0; +}; +""" + +# 2\. Build and Inject program +b = BPF(text=bpf_text) + +# 3\. Print debug output +while True: + print b.trace_readline() + +``` + +This program does 3 things: 1\. It attaches a kernel probe to “inet_listen” using a naming convention. If the function was called, say, “my_probe”, it could be explicitly attached with `b.attach_kprobe("inet_listen", "my_probe"`. 2\. It builds the program using LLVM new BPF backend, inject the resulting bytecode using the (new) `bpf()` syscall and automatically attaches the probes matching the naming convention. 3\. It reads the raw output from the kernel pipe. + +Note: eBPF backend of LLVM is still young. If you think you’ve hit a bug, you may want to upgrade. + +Noticed the `bpf_trace_printk` call? This is a stripped down version of the kernel’s `printk()`debug function. When used, it produces tracing informations to a special kernel pipe in `/sys/kernel/debug/tracing/trace_pipe`. As the name implies, this is a pipe. If multiple readers are consuming it, only 1 will get a given line. This makes it unsuitable for production. + +Fortunately, Linux 3.19 introduced maps for message passing and Linux 4.4 brings arbitrary perf events support. I’ll demo the perf event based approach later in this post. + +``` +# From a first console +ubuntu@bcc:~/dev/listen-evts$ sudo /python tcv4listen.py + nc-4940 [000] d... 22666.991714: : Hello World! + +# From a second console +ubuntu@bcc:~$ nc -l 0 4242 +^C + +``` + +Yay! + +### Grab the backlog + +Now, let’s print some easily accessible data. Say the “backlog”. The backlog is the number of pending established TCP connections, pending to be `accept()`ed. + +Just tweak a bit the `bpf_trace_printk`: + +``` +bpf_trace_printk("Listening with with up to %d pending connections!\\n", backlog); + +``` + +If you re-run the example with this world-changing improvement, you should see something like: + +``` +(bcc)ubuntu@bcc:~/dev/listen-evts$ sudo python tcv4listen.py + nc-5020 [000] d... 25497.154070: : Listening with with up to 1 pending connections! + +``` + +`nc` is a single connection program, hence the backlog of 1\. Nginx or Redis would output 128 here. But that’s another story. + +Easy hue? Now let’s get the port. + +### Grab the port and IP + +Studying `inet_listen` source from the kernel, we know that we need to get the `inet_sock` from the `socket` object. Just copy from the sources, and insert at the beginning of the tracer: + +``` +// cast types. Intermediate cast not needed, kept for readability +struct sock *sk = sock->sk; +struct inet_sock *inet = inet_sk(sk); + +``` + +The port can now be accessed from `inet->inet_sport` in network byte order (aka: Big Endian). Easy! So, we could just replace the `bpf_trace_printk` with: + +``` +bpf_trace_printk("Listening on port %d!\\n", inet->inet_sport); + +``` + +Then run: + +``` +ubuntu@bcc:~/dev/listen-evts$ sudo /python tcv4listen.py +... +R1 invalid mem access 'inv' +... +Exception: Failed to load BPF program kprobe__inet_listen + +``` + +Except that it’s not (yet) so simple. Bcc is improving a  _lot_  currently. While writing this post, a couple of pitfalls had already been addressed. But not yet all. This Error means the in-kernel checker could prove the memory accesses in program are correct. See the explicit cast. We need to help is a little by making the accesses more explicit. We’ll use `bpf_probe_read` trusted function to read an arbitrary memory location while guaranteeing all necessary checks are done with something like: + +``` +// Explicit initialization. The "=0" part is needed to "give life" to the variable on the stack +u16 lport = 0; + +// Explicit arbitrary memory access. Read it: +// Read into 'lport', 'sizeof(lport)' bytes from 'inet->inet_sport' memory location +bpf_probe_read(&lport, sizeof(lport), &(inet->inet_sport)); + +``` + +Reading the bound address for IPv4 is basically the same, using `inet->inet_rcv_saddr`. If we put is all together, we should get the backlog, the port and the bound IP: + +``` +from bcc import BPF + +# BPF Program +bpf_text = """ +#include +#include +#include + +// Send an event for each IPv4 listen with PID, bound address and port +int kprobe__inet_listen(struct pt_regs *ctx, struct socket *sock, int backlog) +{ + // Cast types. Intermediate cast not needed, kept for readability + struct sock *sk = sock->sk; + struct inet_sock *inet = inet_sk(sk); + + // Working values. You *need* to initialize them to give them "life" on the stack and use them afterward + u32 laddr = 0; + u16 lport = 0; + + // Pull in details. As 'inet_sk' is internally a type cast, we need to use 'bpf_probe_read' + // read: load into 'laddr' 'sizeof(laddr)' bytes from address 'inet->inet_rcv_saddr' + bpf_probe_read(&laddr, sizeof(laddr), &(inet->inet_rcv_saddr)); + bpf_probe_read(&lport, sizeof(lport), &(inet->inet_sport)); + + // Push event + bpf_trace_printk("Listening on %x %d with %d pending connections\\n", ntohl(laddr), ntohs(lport), backlog); + return 0; +}; +""" + +# Build and Inject BPF +b = BPF(text=bpf_text) + +# Print debug output +while True: + print b.trace_readline() + +``` + +A test run should output something like: + +``` +(bcc)ubuntu@bcc:~/dev/listen-evts$ sudo python tcv4listen.py + nc-5024 [000] d... 25821.166286: : Listening on 7f000001 4242 with 1 pending connections + +``` + +Provided that you listen on localhost. The address is displayed as hex here to avoid dealing with the IP pretty printing but that’s all wired. And that’s cool. + +Note: you may wonder why `ntohs` and `ntohl` can be called from BPF while they are not trusted. This is because they are macros and inline functions from “.h” files and a small bug was [fixed][14]while writing this post. + +All done, one more piece: We want to get the related container. In the context of networking, that’s means we want the network namespace. The network namespace being the building block of containers allowing them to have isolated networks. + +### Grab the network namespace: a forced introduction to perf events + +On the userland, the network namespace can be determined by checking the target of `/proc/PID/ns/net`. It should look like `net:[4026531957]`. The number between brackets is the inode number of the network namespace. This said, we could grab it by scrapping ‘/proc’ but this is racy, we may be dealing with short-lived processes. And races are never good. We’ll grab the inode number directly from the kernel. Fortunately, that’s an easy one: + +``` +// Create an populate the variable +u32 netns = 0; + +// Read the netns inode number, like /proc does +netns = sk->__sk_common.skc_net.net->ns.inum; + +``` + +Easy. And it works. + +But if you’ve read so far, you may guess there is something wrong somewhere. And there is: + +``` +bpf_trace_printk("Listening on %x %d with %d pending connections in container %d\\n", ntohl(laddr), ntohs(lport), backlog, netns); + +``` + +If you try to run it, you’ll get some cryptic error message: + +``` +(bcc)ubuntu@bcc:~/dev/listen-evts$ sudo python tcv4listen.py +error: in function kprobe__inet_listen i32 (%struct.pt_regs*, %struct.socket*, i32) +too many args to 0x1ba9108: i64 = Constant<6> + +``` + +What clang is trying to tell you is “Hey pal, `bpf_trace_printk` can only take 4 arguments, you’ve just used 5.“. I won’t dive into the details here, but that’s a BPF limitation. If you want to dig it, [here is a good starting point][15]. + +The only way to fix it is to… stop debugging and make it production ready. So let’s get started (and make sure run at least Linux 4.4). We’ll use perf events which supports passing arbitrary sized structures to userland. Additionally, only our reader will get it so that multiple unrelated eBPF programs can produce data concurrently without issues. + +To use it, we need to: + +1. define a structure + +2. declare the event + +3. push the event + +4. re-declare the event on Python’s side (This step should go away in the future) + +5. consume and format the event + +This may seem like a lot, but it ain’t. See: + +``` +// At the begining of the C program, declare our event +struct listen_evt_t { + u64 laddr; + u64 lport; + u64 netns; + u64 backlog; +}; +BPF_PERF_OUTPUT(listen_evt); + +// In kprobe__inet_listen, replace the printk with +struct listen_evt_t evt = { + .laddr = ntohl(laddr), + .lport = ntohs(lport), + .netns = netns, + .backlog = backlog, +}; +listen_evt.perf_submit(ctx, &evt, sizeof(evt)); + +``` + +Python side will require a little more work, though: + +``` +# We need ctypes to parse the event structure +import ctypes + +# Declare data format +class ListenEvt(ctypes.Structure): + _fields_ = [ + ("laddr", ctypes.c_ulonglong), + ("lport", ctypes.c_ulonglong), + ("netns", ctypes.c_ulonglong), + ("backlog", ctypes.c_ulonglong), + ] + +# Declare event printer +def print_event(cpu, data, size): + event = ctypes.cast(data, ctypes.POINTER(ListenEvt)).contents + print("Listening on %x %d with %d pending connections in container %d" % ( + event.laddr, + event.lport, + event.backlog, + event.netns, + )) + +# Replace the event loop +b["listen_evt"].open_perf_buffer(print_event) +while True: + b.kprobe_poll() + +``` + +Give it a try. In this example, I have a redis running in a docker container and nc on the host: + +``` +(bcc)ubuntu@bcc:~/dev/listen-evts$ sudo python tcv4listen.py +Listening on 0 6379 with 128 pending connections in container 4026532165 +Listening on 0 6379 with 128 pending connections in container 4026532165 +Listening on 7f000001 6588 with 1 pending connections in container 4026531957 + +``` + +### Last word + +Absolutely everything is now setup to use trigger events from arbitrary function calls in the kernel using eBPF, and you should have seen most of the common pitfalls I hit while learning eBPF. If you want to see the full version of this tool, along with some more tricks like IPv6 support, have a look at [https://github.com/iovisor/bcc/blob/master/tools/solisten.py][16]. It’s now an official tool, thanks to the support of the bcc team. + +To go further, you may want to checkout Brendan Gregg’s blog, in particular [the post about eBPF maps and statistics][17]. He his one of the project’s main contributor. + + +-------------------------------------------------------------------------------- + +via: https://blog.yadutaf.fr/2016/03/30/turn-any-syscall-into-event-introducing-ebpf-kernel-probes/ + +作者:[Jean-Tiare Le Bigot ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://blog.yadutaf.fr/about +[1]:https://blog.yadutaf.fr/tags/linux +[2]:https://blog.yadutaf.fr/tags/tracing +[3]:https://blog.yadutaf.fr/tags/ebpf +[4]:https://blog.yadutaf.fr/tags/bcc +[5]:https://en.wikipedia.org/wiki/SystemTap +[6]:https://blog.cloudflare.com/bpf-the-forgotten-bytecode/ +[7]:https://blog.yadutaf.fr/2016/03/30/turn-any-syscall-into-event-introducing-ebpf-kernel-probes/TODO +[8]:https://lwn.net/Articles/604043/ +[9]:http://lxr.free-electrons.com/source/kernel/bpf/verifier.c#L21 +[10]:http://events.linuxfoundation.org/sites/events/files/slides/tracing-linux-ezannoni-linuxcon-ja-2015_0.pdf +[11]:https://github.com/iovisor/bcc +[12]:https://github.com/iovisor/bcc/blob/master/INSTALL.md +[13]:http://lxr.free-electrons.com/source/net/ipv4/af_inet.c#L194 +[14]:https://github.com/iovisor/bcc/pull/453 +[15]:http://lxr.free-electrons.com/source/kernel/trace/bpf_trace.c#L86 +[16]:https://github.com/iovisor/bcc/blob/master/tools/solisten.py +[17]:http://www.brendangregg.com/blog/2015-05-15/ebpf-one-small-step.html From 3885eb51ecc1a01a8462f1175d52ff47415fba3d Mon Sep 17 00:00:00 2001 From: Ezio Date: Sun, 3 Dec 2017 22:20:28 +0800 Subject: [PATCH 171/344] =?UTF-8?q?20171203-38=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ive into BPF a list of reading material.md | 711 ++++++++++++++++++ 1 file changed, 711 insertions(+) create mode 100644 sources/tech/20171102 Dive into BPF a list of reading material.md diff --git a/sources/tech/20171102 Dive into BPF a list of reading material.md b/sources/tech/20171102 Dive into BPF a list of reading material.md new file mode 100644 index 0000000000..f4b90bd09d --- /dev/null +++ b/sources/tech/20171102 Dive into BPF a list of reading material.md @@ -0,0 +1,711 @@ +Dive into BPF: a list of reading material +============================================================ + +* [What is BPF?][143] + +* [Dive into the bytecode][144] + +* [Resources][145] + * [Generic presentations][23] + * [About BPF][1] + + * [About XDP][2] + + * [About other components related or based on eBPF][3] + + * [Documentation][24] + * [About BPF][4] + + * [About tc][5] + + * [About XDP][6] + + * [About P4 and BPF][7] + + * [Tutorials][25] + + * [Examples][26] + * [From the kernel][8] + + * [From package iproute2][9] + + * [From bcc set of tools][10] + + * [Manual pages][11] + + * [The code][27] + * [BPF code in the kernel][12] + + * [XDP hooks code][13] + + * [BPF logic in bcc][14] + + * [Code to manage BPF with tc][15] + + * [BPF utilities][16] + + * [Other interesting chunks][17] + + * [LLVM backend][18] + + * [Running in userspace][19] + + * [Commit logs][20] + + * [Troubleshooting][28] + * [Errors at compilation time][21] + + * [Errors at load and run time][22] + + * [And still more!][29] + + _~ [Updated][146] 2017-11-02 ~_ + +# What is BPF? + +BPF, as in **B**erkeley **P**acket **F**ilter, was initially conceived in 1992 so as to provide a way to filter packets and to avoid useless packet copies from kernel to userspace. It initially consisted in a simple bytecode that is injected from userspace into the kernel, where it is checked by a verifier—to prevent kernel crashes or security issues—and attached to a socket, then run on each received packet. It was ported to Linux a couple of years later, and used for a small number of applications (tcpdump for example). The simplicity of the language as well as the existence of an in-kernel Just-In-Time (JIT) compiling machine for BPF were factors for the excellent performances of this tool. + +Then in 2013, Alexei Starovoitov completely reshaped it, started to add new functionalities and to improve the performances of BPF. This new version is designated as eBPF (for “extended BPF”), while the former becomes cBPF (“classic” BPF). New features such as maps and tail calls appeared. The JIT machines were rewritten. The new language is even closer to native machine language than cBPF was. And also, new attach points in the kernel have been created. + +Thanks to those new hooks, eBPF programs can be designed for a variety of use cases, that divide into two fields of applications. One of them is the domain of kernel tracing and event monitoring. BPF programs can be attached to kprobes and they compare with other tracing methods, with many advantages (and sometimes some drawbacks). + +The other application domain remains network programming. In addition to socket filter, eBPF programs can be attached to tc (Linux traffic control tool) ingress or egress interfaces and perform a variety of packet processing tasks, in an efficient way. This opens new perspectives in the domain. + +And eBPF performances are further leveraged through the technologies developed for the IO Visor project: new hooks have also been added for XDP (“eXpress Data Path”), a new fast path recently added to the kernel. XDP works in conjunction with the Linux stack, and relies on BPF to perform very fast packet processing. + +Even some projects such as P4, Open vSwitch, [consider][155] or started to approach BPF. Some others, such as CETH, Cilium, are entirely based on it. BPF is buzzing, so we can expect a lot of tools and projects to orbit around it soon… + +# Dive into the bytecode + +As for me: some of my work (including for [BEBA][156]) is closely related to eBPF, and several future articles on this site will focus on this topic. Logically, I wanted to somehow introduce BPF on this blog before going down to the details—I mean, a real introduction, more developed on BPF functionalities that the brief abstract provided in first section: What are BPF maps? Tail calls? What do the internals look like? And so on. But there are a lot of presentations on this topic available on the web already, and I do not wish to create “yet another BPF introduction” that would come as a duplicate of existing documents. + +So instead, here is what we will do. After all, I spent some time reading and learning about BPF, and while doing so, I gathered a fair amount of material about BPF: introductions, documentation, but also tutorials or examples. There is a lot to read, but in order to read it, one has to  _find_  it first. Therefore, as an attempt to help people who wish to learn and use BPF, the present article introduces a list of resources. These are various kinds of readings, that hopefully will help you dive into the mechanics of this kernel bytecode. + +# Resources + +![](https://qmonnet.github.io/whirl-offload/img/icons/pic.svg) + +### Generic presentations + +The documents linked below provide a generic overview of BPF, or of some closely related topics. If you are very new to BPF, you can try picking a couple of presentation among the first ones and reading the ones you like most. If you know eBPF already, you probably want to target specific topics instead, lower down in the list. + +### About BPF + +Generic presentations about eBPF: + +* [_Making the Kernel’s Networking Data Path Programmable with BPF and XDP_][53]  (Daniel Borkmann, OSSNA17, Los Angeles, September 2017): + One of the best set of slides available to understand quickly all the basics about eBPF and XDP (mostly for network processing). + +* [The BSD Packet Filter][54] (Suchakra Sharma, June 2017):  + A very nice introduction, mostly about the tracing aspects. + +* [_BPF: tracing and more_][55]  (Brendan Gregg, January 2017): + Mostly about the tracing use cases. + +* [_Linux BPF Superpowers_][56]  (Brendan Gregg, March 2016): + With a first part on the use of **flame graphs**. + +* [_IO Visor_][57]  (Brenden Blanco, SCaLE 14x, January 2016): + Also introduces **IO Visor project**. + +* [_eBPF on the Mainframe_][58]  (Michael Holzheu, LinuxCon, Dubin, October 2015) + +* [_New (and Exciting!) Developments in Linux Tracing_][59]  (Elena Zannoni, LinuxCon, Japan, 2015) + +* [_BPF — in-kernel virtual machine_][60]  (Alexei Starovoitov, February 2015): + Presentation by the author of eBPF. + +* [_Extending extended BPF_][61]  (Jonathan Corbet, July 2014) + +**BPF internals**: + +* Daniel Borkmann has been doing an amazing work to present **the internals** of eBPF, in particular about **its use with tc**, through several talks and papers. + * [_Advanced programmability and recent updates with tc’s cls_bpf_][30]  (netdev 1.2, Tokyo, October 2016): + Daniel provides details on eBPF, its use for tunneling and encapsulation, direct packet access, and other features. + + * [_cls_bpf/eBPF updates since netdev 1.1_][31]  (netdev 1.2, Tokyo, October 2016, part of [this tc workshop][32]) + + * [_On getting tc classifier fully programmable with cls_bpf_][33]  (netdev 1.1, Sevilla, February 2016): + After introducing eBPF, this presentation provides insights on many internal BPF mechanisms (map management, tail calls, verifier). A must-read! For the most ambitious, [the full paper is available here][34]. + + * [_Linux tc and eBPF_][35]  (fosdem16, Brussels, Belgium, January 2016) + + * [_eBPF and XDP walkthrough and recent updates_][36]  (fosdem17, Brussels, Belgium, February 2017) + + These presentations are probably one of the best sources of documentation to understand the design and implementation of internal mechanisms of eBPF. + +The [**IO Visor blog**][157] has some interesting technical articles about BPF. Some of them contain a bit of marketing talks. + +**Kernel tracing**: summing up all existing methods, including BPF: + +* [_Meet-cute between eBPF and Kerne Tracing_][62]  (Viller Hsiao, July 2016): + Kprobes, uprobes, ftrace + +* [_Linux Kernel Tracing_][63]  (Viller Hsiao, July 2016): + Systemtap, Kernelshark, trace-cmd, LTTng, perf-tool, ftrace, hist-trigger, perf, function tracer, tracepoint, kprobe/uprobe… + +Regarding **event tracing and monitoring**, Brendan Gregg uses eBPF a lot and does an excellent job at documenting some of his use cases. If you are in kernel tracing, you should see his blog articles related to eBPF or to flame graphs. Most of it are accessible [from this article][158] or by browsing his blog. + +Introducing BPF, but also presenting **generic concepts of Linux networking**: + +* [_Linux Networking Explained_][64]  (Thomas Graf, LinuxCon, Toronto, August 2016) + +* [_Kernel Networking Walkthrough_][65]  (Thomas Graf, LinuxCon, Seattle, August 2015) + +**Hardware offload**: + +* eBPF with tc or XDP supports hardware offload, starting with Linux kernel version 4.9 and introduced by Netronome. Here is a presentation about this feature: + [eBPF/XDP hardware offload to SmartNICs][147] (Jakub Kicinski and Nic Viljoen, netdev 1.2, Tokyo, October 2016) + +About **cBPF**: + +* [_The BSD Packet Filter: A New Architecture for User-level Packet Capture_][66]  (Steven McCanne and Van Jacobson, 1992): + The original paper about (classic) BPF. + +* [The FreeBSD manual page about BPF][67] is a useful resource to understand cBPF programs. + +* Daniel Borkmann realized at least two presentations on cBPF, [one in 2013 on mmap, BPF and Netsniff-NG][68], and [a very complete one in 2014 on tc and cls_bpf][69]. + +* On Cloudflare’s blog, Marek Majkowski presented his [use of BPF bytecode with the `xt_bpf`module for **iptables**][70]. It is worth mentioning that eBPF is also supported by this module, starting with Linux kernel 4.10 (I do not know of any talk or article about this, though). + +* [Libpcap filters syntax][71] + +### About XDP + +* [XDP overview][72] on the IO Visor website. + +* [_eXpress Data Path (XDP)_][73]  (Tom Herbert, Alexei Starovoitov, March 2016): + The first presentation about XDP. + +* [_BoF - What Can BPF Do For You?_][74]  (Brenden Blanco, LinuxCon, Toronto, August 2016). + +* [_eXpress Data Path_][148]  (Brenden Blanco, Linux Meetup at Santa Clara, July 2016): + Contains some (somewhat marketing?) **benchmark results**! With a single core: + * ip routing drop: ~3.6 million packets per second (Mpps) + + * tc (with clsact qdisc) drop using BPF: ~4.2 Mpps + + * XDP drop using BPF: 20 Mpps (<10 % CPU utilization) + + * XDP forward (on port on which the packet was received) with rewrite: 10 Mpps + + (Tests performed with the mlx4 driver). + +* Jesper Dangaard Brouer has several excellent sets of slides, that are essential to fully understand the internals of XDP. + * [_XDP − eXpress Data Path, Intro and future use-cases_][37]  (September 2016): + _“Linux Kernel’s fight against DPDK”_ . **Future plans** (as of this writing) for XDP and comparison with DPDK. + + * [_Network Performance Workshop_][38]  (netdev 1.2, Tokyo, October 2016): + Additional hints about XDP internals and expected evolution. + + * [_XDP – eXpress Data Path, Used for DDoS protection_][39]  (OpenSourceDays, March 2017): + Contains details and use cases about XDP, with **benchmark results**, and **code snippets** for **benchmarking** as well as for **basic DDoS protection** with eBPF/XDP (based on an IP blacklisting scheme). + + * [_Memory vs. Networking, Provoking and fixing memory bottlenecks_][40]  (LSF Memory Management Summit, March 2017): + Provides a lot of details about current **memory issues** faced by XDP developers. Do not start with this one, but if you already know XDP and want to see how it really works on the page allocation side, this is a very helpful resource. + + * [_XDP for the Rest of Us_][41]  (netdev 2.1, Montreal, April 2017), with Andy Gospodarek: + How to get started with eBPF and XDP for normal humans. This presentation was also summarized by Julia Evans on [her blog][42]. + + (Jesper also created and tries to extend some documentation about eBPF and XDP, see [related section][75].) + +* [_XDP workshop — Introduction, experience, and future development_][76]  (Tom Herbert, netdev 1.2, Tokyo, October 2016) — as of this writing, only the video is available, I don’t know if the slides will be added. + +* [_High Speed Packet Filtering on Linux_][149]  (Gilberto Bertin, DEF CON 25, Las Vegas, July 2017) — an excellent introduction to state-of-the-art packet filtering on Linux, oriented towards DDoS protection, talking about packet processing in the kernel, kernel bypass, XDP and eBPF. + +### About other components related or based on eBPF + +* [_P4 on the Edge_][77]  (John Fastabend, May 2016): + Presents the use of **P4**, a description language for packet processing, with BPF to create high-performance programmable switches. + +* If you like audio presentations, there is an associated [OvS Orbit episode (#11), called  _**P4** on the Edge_][78] , dating from August 2016\. OvS Orbit are interviews realized by Ben Pfaff, who is one of the core maintainers of Open vSwitch. In this case, John Fastabend is interviewed. + +* [_P4, EBPF and Linux TC Offload_][79]  (Dinan Gunawardena and Jakub Kicinski, August 2016): + Another presentation on **P4**, with some elements related to eBPF hardware offload on Netronome’s **NFP** (Network Flow Processor) architecture. + +* **Cilium** is a technology initiated by Cisco and relying on BPF and XDP to provide “fast in-kernel networking and security policy enforcement for containers based on eBPF programs generated on the fly”. [The code of this project][150] is available on GitHub. Thomas Graf has been performing a number of presentations of this topic: + * [_Cilium: Networking & Security for Containers with BPF & XDP_][43] , also featuring a load balancer use case (Linux Plumbers conference, Santa Fe, November 2016) + + * [_Cilium: Networking & Security for Containers with BPF & XDP_][44]  (Docker Distributed Systems Summit, October 2016 — [video][45]) + + * [_Cilium: Fast IPv6 container Networking with BPF and XDP_][46]  (LinuxCon, Toronto, August 2016) + + * [_Cilium: BPF & XDP for containers_][47]  (fosdem17, Brussels, Belgium, February 2017) + + A good deal of contents is repeated between the different presentations; if in doubt, just pick the most recent one. Daniel Borkmann has also written [a generic introduction to Cilium][80] as a guest author on Google Open Source blog. + +* There are also podcasts about **Cilium**: an [OvS Orbit episode (#4)][81], in which Ben Pfaff interviews Thomas Graf (May 2016), and [another podcast by Ivan Pepelnjak][82], still with Thomas Graf about eBPF, P4, XDP and Cilium (October 2016). + +* **Open vSwitch** (OvS), and its related project **Open Virtual Network** (OVN, an open source network virtualization solution) are considering to use eBPF at various level, with several proof-of-concept prototypes already implemented: + + * [Offloading OVS Flow Processing using eBPF][48] (William (Cheng-Chun) Tu, OvS conference, San Jose, November 2016) + + * [Coupling the Flexibility of OVN with the Efficiency of IOVisor][49] (Fulvio Risso, Matteo Bertrone and Mauricio Vasquez Bernal, OvS conference, San Jose, November 2016) + + These use cases for eBPF seem to be only at the stage of proposals (nothing merge to OvS main branch) as far as I know, but it will be very interesting to see what comes out of it. + +* XDP is envisioned to be of great help for protection against Distributed Denial-of-Service (DDoS) attacks. More and more presentations focus on this. For example, the talks from people from Cloudflare ( [_XDP in practice: integrating XDP in our DDoS mitigation pipeline_][83] ) or from Facebook ( [_Droplet: DDoS countermeasures powered by BPF + XDP_][84] ) at the netdev 2.1 conference in Montreal, Canada, in April 2017, present such use cases. + +* [_CETH for XDP_][85]  (Yan Chan and Yunsong Lu, Linux Meetup, Santa Clara, July 2016): + **CETH** stands for Common Ethernet Driver Framework for faster network I/O, a technology initiated by Mellanox. + +* [**The VALE switch**][86], another virtual switch that can be used in conjunction with the netmap framework, has [a BPF extension module][87]. + +* **Suricata**, an open source intrusion detection system, [seems to rely on eBPF components][88] for its “capture bypass” features: + [_The adventures of a Suricate in eBPF land_][89]  (Éric Leblond, netdev 1.2, Tokyo, October 2016) + [_eBPF and XDP seen from the eyes of a meerkat_][90]  (Éric Leblond, Kernel Recipes, Paris, September 2017) + +* [InKeV: In-Kernel Distributed Network Virtualization for DCN][91] (Z. Ahmed, M. H. Alizai and A. A. Syed, SIGCOMM, August 2016): + **InKeV** is an eBPF-based datapath architecture for virtual networks, targeting data center networks. It was initiated by PLUMgrid, and claims to achieve better performances than OvS-based OpenStack solutions. + +* [_**gobpf** - utilizing eBPF from Go_][92]  (Michael Schubert, fosdem17, Brussels, Belgium, February 2017): + A “library to create, load and use eBPF programs from Go” + +* [**ply**][93] is a small but flexible open source dynamic **tracer** for Linux, with some features similar to the bcc tools, but with a simpler language inspired by awk and dtrace, written by Tobias Waldekranz. + +* If you read my previous article, you might be interested in this talk I gave about [implementing the OpenState interface with eBPF][151], for stateful packet processing, at fosdem17. + +![](https://qmonnet.github.io/whirl-offload/img/icons/book.svg) + +### Documentation + +Once you managed to get a broad idea of what BPF is, you can put aside generic presentations and start diving into the documentation. Below are the most complete documents about BPF specifications and functioning. Pick the one you need and read them carefully! + +### About BPF + +* The **specification of BPF** (both classic and extended versions) can be found within the documentation of the Linux kernel, and in particular in file[linux/Documentation/networking/filter.txt][94]. The use of BPF as well as its internals are documented there. Also, this is where you can find **information about errors thrown by the verifier** when loading BPF code fails. Can be helpful to troubleshoot obscure error messages. + +* Also in the kernel tree, there is a document about **frequent Questions & Answers** on eBPF design in file [linux/Documentation/bpf/bpf_design_QA.txt][95]. + +* … But the kernel documentation is dense and not especially easy to read. If you look for a simple description of eBPF language, head for [its **summarized description**][96] on the IO Visor GitHub repository instead. + +* By the way, the IO Visor project gathered a lot of **resources about BPF**. Mostly, it is split between[the documentation directory][97] of its bcc repository, and the whole content of [the bpf-docs repository][98], both on GitHub. Note the existence of this excellent [BPF **reference guide**][99] containing a detailed description of BPF C and bcc Python helpers. + +* To hack with BPF, there are some essential **Linux manual pages**. The first one is [the `bpf(2)` man page][100] about the `bpf()` **system call**, which is used to manage BPF programs and maps from userspace. It also contains a description of BPF advanced features (program types, maps and so on). The second one is mostly addressed to people wanting to attach BPF programs to tc interface: it is [the `tc-bpf(8)` man page][101], which is a reference for **using BPF with tc**, and includes some example commands and samples of code. + +* Jesper Dangaard Brouer initiated an attempt to **update eBPF Linux documentation**, including **the different kinds of maps**. [He has a draft][102] to which contributions are welcome. Once ready, this document should be merged into the man pages and into kernel documentation. + +* The Cilium project also has an excellent [**BPF and XDP Reference Guide**][103], written by core eBPF developers, that should prove immensely useful to any eBPF developer. + +* David Miller has sent several enlightening emails about eBPF/XDP internals on the [xdp-newbies][152]mailing list. I could not find a link that gathers them at a single place, so here is a list: + * [bpf.h and you…][50] + + * [Contextually speaking…][51] + + * [BPF Verifier Overview][52] + + The last one is possibly the best existing summary about the verifier at this date. + +* Ferris Ellis started [a **blog post series about eBPF**][104]. As I write this paragraph, the first article is out, with some historical background and future expectations for eBPF. Next posts should be more technical, and look promising. + +* [A **list of BPF features per kernel version**][153] is available in bcc repository. Useful is you want to know the minimal kernel version that is required to run a given feature. I contributed and added the links to the commits that introduced each feature, so you can also easily access the commit logs from there. + +### About tc + +When using BPF for networking purposes in conjunction with tc, the Linux tool for **t**raffic **c**ontrol, one may wish to gather information about tc’s generic functioning. Here are a couple of resources about it. + +* It is difficult to find simple tutorials about **QoS on Linux**. The two links I have are long and quite dense, but if you can find the time to read it you will learn nearly everything there is to know about tc (nothing about BPF, though). There they are:  [_Traffic Control HOWTO_  (Martin A. Brown, 2006)][105], and the  [_Linux Advanced Routing & Traffic Control HOWTO_  (“LARTC”) (Bert Hubert & al., 2002)][106]. + +* **tc manual pages** may not be up-to-date on your system, since several of them have been added lately. If you cannot find the documentation for a particular queuing discipline (qdisc), class or filter, it may be worth checking the latest [manual pages for tc components][107]. + +* Some additional material can be found within the files of iproute2 package itself: the package contains [some documentation][108], including some files that helped me understand better [the functioning of **tc’s actions**][109]. + **Edit:** While still available from the Git history, these files have been deleted from iproute2 in October 2017. + +* Not exactly documentation: there was [a workshop about several tc features][110] (including filtering, BPF, tc offload, …) organized by Jamal Hadi Salim during the netdev 1.2 conference (October 2016). + +* Bonus information—If you use `tc` a lot, here are some good news: I [wrote a bash completion function][111] for this tool, and it should be shipped with package iproute2 coming with kernel version 4.6 and higher! + +### About XDP + +* Some [work-in-progress documentation (including specifications)][112] for XDP started by Jesper Dangaard Brouer, but meant to be a collaborative work. Under progress (September 2016): you should expect it to change, and maybe to be moved at some point (Jesper [called for contribution][113], if you feel like improving it). + +* The [BPF and XDP Reference Guide][114] from Cilium project… Well, the name says it all. + +### About P4 and BPF + +[P4][159] is a language used to specify the behavior of a switch. It can be compiled for a number of hardware or software targets. As you may have guessed, one of these targets is BPF… The support is only partial: some P4 features cannot be translated towards BPF, and in a similar way there are things that BPF can do but that would not be possible to express with P4\. Anyway, the documentation related to **P4 use with BPF** [used to be hidden in bcc repository][160]. This changed with P4_16 version, the p4c reference compiler including [a backend for eBPF][161]. + +![](https://qmonnet.github.io/whirl-offload/img/icons/flask.svg) + +### Tutorials + +Brendan Gregg has produced excellent **tutorials** intended for people who want to **use bcc tools** for tracing and monitoring events in the kernel. [The first tutorial about using bcc itself][162] comes with eleven steps (as of today) to understand how to use the existing tools, while [the one **intended for Python developers**][163] focuses on developing new tools, across seventeen “lessons”. + +Sasha Goldshtein also has some  [_**Linux Tracing Workshops Materials**_][164]  involving the use of several BPF tools for tracing. + +Another post by Jean-Tiare Le Bigot provides a detailed (and instructive!) example of [using perf and eBPF to setup a low-level tracer][165] for ping requests and replies + +Few tutorials exist for network-related eBPF use cases. There are some interesting documents, including an  _eBPF Offload Starting Guide_ , on the [Open NFP][166] platform operated by Netronome. Other than these, the talk from Jesper,  [_XDP for the Rest of Us_][167] , is probably one of the best ways to get started with XDP. + +![](https://qmonnet.github.io/whirl-offload/img/icons/gears.svg) + +### Examples + +It is always nice to have examples. To see how things really work. But BPF program samples are scattered across several projects, so I listed all the ones I know of. The examples do not always use the same helpers (for instance, tc and bcc both have their own set of helpers to make it easier to write BPF programs in C language). + +### From the kernel + +The kernel contains examples for most types of program: filters to bind to sockets or to tc interfaces, event tracing/monitoring, and even XDP. You can find these examples under the [linux/samples/bpf/][168]directory. + +Also do not forget to have a look to the logs related to the (git) commits that introduced a particular feature, they may contain some detailed example of the feature. + +### From package iproute2 + +The iproute2 package provide several examples as well. They are obviously oriented towards network programming, since the programs are to be attached to tc ingress or egress interfaces. The examples dwell under the [iproute2/examples/bpf/][169] directory. + +### From bcc set of tools + +Many examples are [provided with bcc][170]: + +* Some are networking example programs, under the associated directory. They include socket filters, tc filters, and a XDP program. + +* The `tracing` directory include a lot of example **tracing programs**. The tutorials mentioned earlier are based on these. These programs cover a wide range of event monitoring functions, and some of them are production-oriented. Note that on certain Linux distributions (at least for Debian, Ubuntu, Fedora, Arch Linux), these programs have been [packaged][115] and can be “easily” installed by typing e.g. `# apt install bcc-tools`, but as of this writing (and except for Arch Linux), this first requires to set up IO Visor’s own package repository. + +* There are also some examples **using Lua** as a different BPF back-end (that is, BPF programs are written with Lua instead of a subset of C, allowing to use the same language for front-end and back-end), in the third directory. + +### Manual pages + +While bcc is generally the easiest way to inject and run a BPF program in the kernel, attaching programs to tc interfaces can also be performed by the `tc` tool itself. So if you intend to **use BPF with tc**, you can find some example invocations in the [`tc-bpf(8)` manual page][171]. + +![](https://qmonnet.github.io/whirl-offload/img/icons/srcfile.svg) + +### The code + +Sometimes, BPF documentation or examples are not enough, and you may have no other solution that to display the code in your favorite text editor (which should be Vim of course) and to read it. Or you may want to hack into the code so as to patch or add features to the machine. So here are a few pointers to the relevant files, finding the functions you want is up to you! + +### BPF code in the kernel + +* The file [linux/include/linux/bpf.h][116] and its counterpart [linux/include/uapi/bpf.h][117] contain **definitions** related to eBPF, to be used respectively in the kernel and to interface with userspace programs. + +* On the same pattern, files [linux/include/linux/filter.h][118] and [linux/include/uapi/filter.h][119] contain information used to **run the BPF programs**. + +* The **main pieces of code** related to BPF are under [linux/kernel/bpf/][120] directory. **The different operations permitted by the system call**, such as program loading or map management, are implemented in file `syscall.c`, while `core.c` contains the **interpreter**. The other files have self-explanatory names: `verifier.c` contains the **verifier** (no kidding), `arraymap.c` the code used to interact with **maps** of type array, and so on. + +* The **helpers**, as well as several functions related to networking (with tc, XDP…) and available to the user, are implemented in [linux/net/core/filter.c][121]. It also contains the code to migrate cBPF bytecode to eBPF (since all cBPF programs are now translated to eBPF in the kernel before being run). + +* The **JIT compilers** are under the directory of their respective architectures, such as file[linux/arch/x86/net/bpf_jit_comp.c][122] for x86. + +* You will find the code related to **the BPF components of tc** in the [linux/net/sched/][123] directory, and in particular in files `act_bpf.c` (action) and `cls_bpf.c` (filter). + +* I have not hacked with **event tracing** in BPF, so I do not really know about the hooks for such programs. There is some stuff in [linux/kernel/trace/bpf_trace.c][124]. If you are interested in this and want to know more, you may dig on the side of Brendan Gregg’s presentations or blog posts. + +* Nor have I used **seccomp-BPF**. But the code is in [linux/kernel/seccomp.c][125], and some example use cases can be found in [linux/tools/testing/selftests/seccomp/seccomp_bpf.c][126]. + +### XDP hooks code + +Once loaded into the in-kernel BPF virtual machine, **XDP** programs are hooked from userspace into the kernel network path thanks to a Netlink command. On reception, the function `dev_change_xdp_fd()` in file [linux/net/core/dev.c][172] is called and sets a XDP hook. Such hooks are located in the drivers of supported NICs. For example, the mlx4 driver used for some Mellanox hardware has hooks implemented in files under the [drivers/net/ethernet/mellanox/mlx4/][173] directory. File en_netdev.c receives Netlink commands and calls `mlx4_xdp_set()`, which in turns calls for instance `mlx4_en_process_rx_cq()` (for the RX side) implemented in file en_rx.c. + +### BPF logic in bcc + +One can find the code for the **bcc** set of tools [on the bcc GitHub repository][174]. The **Python code**, including the `BPF` class, is initiated in file [bcc/src/python/bcc/__init__.py][175]. But most of the interesting stuff—to my opinion—such as loading the BPF program into the kernel, happens [in the libbcc **C library**][176]. + +### Code to manage BPF with tc + +The code related to BPF **in tc** comes with the iproute2 package, of course. Some of it is under the[iproute2/tc/][177] directory. The files f_bpf.c and m_bpf.c (and e_bpf.c) are used respectively to handle BPF filters and actions (and tc `exec` command, whatever this may be). File q_clsact.c defines the `clsact` qdisc especially created for BPF. But **most of the BPF userspace logic** is implemented in[iproute2/lib/bpf.c][178] library, so this is probably where you should head to if you want to mess up with BPF and tc (it was moved from file iproute2/tc/tc_bpf.c, where you may find the same code in older versions of the package). + +### BPF utilities + +The kernel also ships the sources of three tools (`bpf_asm.c`, `bpf_dbg.c`, `bpf_jit_disasm.c`) related to BPF, under the [linux/tools/net/][179] or [linux/tools/bpf/][180] directory depending on your version: + +* `bpf_asm` is a minimal cBPF assembler. + +* `bpf_dbg` is a small debugger for cBPF programs. + +* `bpf_jit_disasm` is generic for both BPF flavors and could be highly useful for JIT debugging. + +* `bpftool` is a generic utility written by Jakub Kicinski, and that can be used to interact with eBPF programs and maps from userspace, for example to show, dump, pin programs, or to show, create, pin, update, delete maps. + +Read the comments at the top of the source files to get an overview of their usage. + +### Other interesting chunks + +If you are interested the use of less common languages with BPF, bcc contains [a **P4 compiler** for BPF targets][181] as well as [a **Lua front-end**][182] that can be used as alternatives to the C subset and (in the case of Lua) to the Python tools. + +### LLVM backend + +The BPF backend used by clang / LLVM for compiling C into eBPF was added to the LLVM sources in[this commit][183] (and can also be accessed on [the GitHub mirror][184]). + +### Running in userspace + +As far as I know there are at least two eBPF userspace implementations. The first one, [uBPF][185], is written in C. It contains an interpreter, a JIT compiler for x86_64 architecture, an assembler and a disassembler. + +The code of uBPF seems to have been reused to produce a [generic implementation][186], that claims to support FreeBSD kernel, FreeBSD userspace, Linux kernel, Linux userspace and MacOSX userspace. It is used for the [BPF extension module for VALE switch][187]. + +The other userspace implementation is my own work: [rbpf][188], based on uBPF, but written in Rust. The interpreter and JIT-compiler work (both under Linux, only the interpreter for MacOSX and Windows), there may be more in the future. + +### Commit logs + +As stated earlier, do not hesitate to have a look at the commit log that introduced a particular BPF feature if you want to have more information about it. You can search the logs in many places, such as on [git.kernel.org][189], [on GitHub][190], or on your local repository if you have cloned it. If you are not familiar with git, try things like `git blame ` to see what commit introduced a particular line of code, then `git show ` to have details (or search by keyword in `git log` results, but this may be tedious). See also [the list of eBPF features per kernel version][191] on bcc repository, that links to relevant commits. + +![](https://qmonnet.github.io/whirl-offload/img/icons/wand.svg) + +### Troubleshooting + +The enthusiasm about eBPF is quite recent, and so far I have not found a lot of resources intending to help with troubleshooting. So here are the few I have, augmented with my own recollection of pitfalls encountered while working with BPF. + +### Errors at compilation time + +* Make sure you have a recent enough version of the Linux kernel (see also [this document][127]). + +* If you compiled the kernel yourself: make sure you installed correctly all components, including kernel image, headers and libc. + +* When using the `bcc` shell function provided by `tc-bpf` man page (to compile C code into BPF): I once had to add includes to the header for the clang call: + + ``` + __bcc() { + clang -O2 -I "/usr/src/linux-headers-$(uname -r)/include/" \ + -I "/usr/src/linux-headers-$(uname -r)/arch/x86/include/" \ + -emit-llvm -c $1 -o - | \ + llc -march=bpf -filetype=obj -o "`basename $1 .c`.o" + } + + ``` + + (seems fixed as of today). + +* For other problems with `bcc`, do not forget to have a look at [the FAQ][128] of the tool set. + +* If you downloaded the examples from the iproute2 package in a version that does not exactly match your kernel, some errors can be triggered by the headers included in the files. The example snippets indeed assume that the same version of iproute2 package and kernel headers are installed on the system. If this is not the case, download the correct version of iproute2, or edit the path of included files in the examples to point to the headers included in iproute2 (some problems may or may not occur at runtime, depending on the features in use). + +### Errors at load and run time + +* To load a program with tc, make sure you use a tc binary coming from an iproute2 version equivalent to the kernel in use. + +* To load a program with bcc, make sure you have bcc installed on the system (just downloading the sources to run the Python script is not enough). + +* With tc, if the BPF program does not return the expected values, check that you called it in the correct fashion: filter, or action, or filter with “direct-action” mode. + +* With tc still, note that actions cannot be attached directly to qdiscs or interfaces without the use of a filter. + +* The errors thrown by the in-kernel verifier may be hard to interpret. [The kernel documentation][129]may help, so may [the reference guide][130] or, as a last resort, the source code (see above) (good luck!). For this kind of errors it is also important to keep in mind that the verifier  _does not run_  the program. If you get an error about an invalid memory access or about uninitialized data, it does not mean that these problems actually occurred (or sometimes, that they can possibly occur at all). It means that your program is written in such a way that the verifier estimates that such errors could happen, and therefore it rejects the program. + +* Note that `tc` tool has a verbose mode, and that it works well with BPF: try appending `verbose`at the end of your command line. + +* bcc also has verbose options: the `BPF` class has a `debug` argument that can take any combination of the three flags `DEBUG_LLVM_IR`, `DEBUG_BPF` and `DEBUG_PREPROCESSOR` (see details in [the source file][131]). It even embeds [some facilities to print output messages][132] for debugging the code. + +* LLVM v4.0+ [embeds a disassembler][133] for eBPF programs. So if you compile your program with clang, adding the `-g` flag for compiling enables you to later dump your program in the rather human-friendly format used by the kernel verifier. To proceed to the dump, use: + + ``` + $ llvm-objdump -S -no-show-raw-insn bpf_program.o + + ``` + +* Working with maps? You want to have a look at [bpf-map][134], a very userful tool in Go created for the Cilium project, that can be used to dump the contents of kernel eBPF maps. There also exists [a clone][135] in Rust. + +* There is an old [`bpf` tag on **StackOverflow**][136], but as of this writing it has been hardly used—ever (and there is nearly nothing related to the new eBPF version). If you are a reader from the Future though, you may want to check whether there has been more activity on this side. + +![](https://qmonnet.github.io/whirl-offload/img/icons/zoomin.svg) + +### And still more! + +* In case you would like to easily **test XDP**, there is [a Vagrant setup][137] available. You can also **test bcc**[in a Docker container][138]. + +* Wondering where the **development and activities** around BPF occur? Well, the kernel patches always end up [on the netdev mailing list][139] (related to the Linux kernel networking stack development): search for “BPF” or “XDP” keywords. Since April 2017, there is also [a mailing list specially dedicated to XDP programming][140] (both for architecture or for asking for help). Many discussions and debates also occur [on the IO Visor mailing list][141], since BPF is at the heart of the project. If you only want to keep informed from time to time, there is also an [@IOVisor Twitter account][142]. + +And come back on this blog from time to time to see if they are new articles [about BPF][192]! + + _Special thanks to Daniel Borkmann for the numerous [additional documents][154] he pointed to me so that I could complete this collection._ + +-------------------------------------------------------------------------------- + +via: https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/ + +作者:[Quentin Monnet ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://qmonnet.github.io/whirl-offload/about/ +[1]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-bpf +[2]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-xdp +[3]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-other-components-related-or-based-on-ebpf +[4]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-bpf-1 +[5]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-tc +[6]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-xdp-1 +[7]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-p4-and-bpf +[8]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#from-the-kernel +[9]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#from-package-iproute2 +[10]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#from-bcc-set-of-tools +[11]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#manual-pages +[12]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#bpf-code-in-the-kernel +[13]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#xdp-hooks-code +[14]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#bpf-logic-in-bcc +[15]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#code-to-manage-bpf-with-tc +[16]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#bpf-utilities +[17]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#other-interesting-chunks +[18]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#llvm-backend +[19]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#running-in-userspace +[20]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#commit-logs +[21]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#errors-at-compilation-time +[22]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#errors-at-load-and-run-time +[23]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#generic-presentations +[24]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#documentation +[25]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#tutorials +[26]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#examples +[27]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#the-code +[28]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#troubleshooting +[29]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#and-still-more +[30]:http://netdevconf.org/1.2/session.html?daniel-borkmann +[31]:http://netdevconf.org/1.2/slides/oct5/07_tcws_daniel_borkmann_2016_tcws.pdf +[32]:http://netdevconf.org/1.2/session.html?jamal-tc-workshop +[33]:http://www.netdevconf.org/1.1/proceedings/slides/borkmann-tc-classifier-cls-bpf.pdf +[34]:http://www.netdevconf.org/1.1/proceedings/papers/On-getting-tc-classifier-fully-programmable-with-cls-bpf.pdf +[35]:https://archive.fosdem.org/2016/schedule/event/ebpf/attachments/slides/1159/export/events/attachments/ebpf/slides/1159/ebpf.pdf +[36]:https://fosdem.org/2017/schedule/event/ebpf_xdp/ +[37]:http://people.netfilter.org/hawk/presentations/xdp2016/xdp_intro_and_use_cases_sep2016.pdf +[38]:http://netdevconf.org/1.2/session.html?jesper-performance-workshop +[39]:http://people.netfilter.org/hawk/presentations/OpenSourceDays2017/XDP_DDoS_protecting_osd2017.pdf +[40]:http://people.netfilter.org/hawk/presentations/MM-summit2017/MM-summit2017-JesperBrouer.pdf +[41]:http://netdevconf.org/2.1/session.html?gospodarek +[42]:http://jvns.ca/blog/2017/04/07/xdp-bpf-tutorial/ +[43]:http://www.slideshare.net/ThomasGraf5/clium-container-networking-with-bpf-xdp +[44]:http://www.slideshare.net/Docker/cilium-bpf-xdp-for-containers-66969823 +[45]:https://www.youtube.com/watch?v=TnJF7ht3ZYc&list=PLkA60AVN3hh8oPas3cq2VA9xB7WazcIgs +[46]:http://www.slideshare.net/ThomasGraf5/cilium-fast-ipv6-container-networking-with-bpf-and-xdp +[47]:https://fosdem.org/2017/schedule/event/cilium/ +[48]:http://openvswitch.org/support/ovscon2016/7/1120-tu.pdf +[49]:http://openvswitch.org/support/ovscon2016/7/1245-bertrone.pdf +[50]:https://www.spinics.net/lists/xdp-newbies/msg00179.html +[51]:https://www.spinics.net/lists/xdp-newbies/msg00181.html +[52]:https://www.spinics.net/lists/xdp-newbies/msg00185.html +[53]:http://schd.ws/hosted_files/ossna2017/da/BPFandXDP.pdf +[54]:https://speakerdeck.com/tuxology/the-bsd-packet-filter +[55]:http://www.slideshare.net/brendangregg/bpf-tracing-and-more +[56]:http://fr.slideshare.net/brendangregg/linux-bpf-superpowers +[57]:https://www.socallinuxexpo.org/sites/default/files/presentations/Room%20211%20-%20IOVisor%20-%20SCaLE%2014x.pdf +[58]:https://events.linuxfoundation.org/sites/events/files/slides/ebpf_on_the_mainframe_lcon_2015.pdf +[59]:https://events.linuxfoundation.org/sites/events/files/slides/tracing-linux-ezannoni-linuxcon-ja-2015_0.pdf +[60]:https://events.linuxfoundation.org/sites/events/files/slides/bpf_collabsummit_2015feb20.pdf +[61]:https://lwn.net/Articles/603983/ +[62]:http://www.slideshare.net/vh21/meet-cutebetweenebpfandtracing +[63]:http://www.slideshare.net/vh21/linux-kernel-tracing +[64]:http://www.slideshare.net/ThomasGraf5/linux-networking-explained +[65]:http://www.slideshare.net/ThomasGraf5/linuxcon-2015-linux-kernel-networking-walkthrough +[66]:http://www.tcpdump.org/papers/bpf-usenix93.pdf +[67]:http://www.gsp.com/cgi-bin/man.cgi?topic=bpf +[68]:http://borkmann.ch/talks/2013_devconf.pdf +[69]:http://borkmann.ch/talks/2014_devconf.pdf +[70]:https://blog.cloudflare.com/introducing-the-bpf-tools/ +[71]:http://biot.com/capstats/bpf.html +[72]:https://www.iovisor.org/technology/xdp +[73]:https://github.com/iovisor/bpf-docs/raw/master/Express_Data_Path.pdf +[74]:https://events.linuxfoundation.org/sites/events/files/slides/iovisor-lc-bof-2016.pdf +[75]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-xdp-1 +[76]:http://netdevconf.org/1.2/session.html?herbert-xdp-workshop +[77]:https://schd.ws/hosted_files/2016p4workshop/1d/Intel%20Fastabend-P4%20on%20the%20Edge.pdf +[78]:https://ovsorbit.benpfaff.org/#e11 +[79]:http://open-nfp.org/media/pdfs/Open_NFP_P4_EBPF_Linux_TC_Offload_FINAL.pdf +[80]:https://opensource.googleblog.com/2016/11/cilium-networking-and-security.html +[81]:https://ovsorbit.benpfaff.org/ +[82]:http://blog.ipspace.net/2016/10/fast-linux-packet-forwarding-with.html +[83]:http://netdevconf.org/2.1/session.html?bertin +[84]:http://netdevconf.org/2.1/session.html?zhou +[85]:http://www.slideshare.net/IOVisor/ceth-for-xdp-linux-meetup-santa-clara-july-2016 +[86]:http://info.iet.unipi.it/~luigi/vale/ +[87]:https://github.com/YutaroHayakawa/vale-bpf +[88]:https://www.stamus-networks.com/2016/09/28/suricata-bypass-feature/ +[89]:http://netdevconf.org/1.2/slides/oct6/10_suricata_ebpf.pdf +[90]:https://www.slideshare.net/ennael/kernel-recipes-2017-ebpf-and-xdp-eric-leblond +[91]:https://github.com/iovisor/bpf-docs/blob/master/university/sigcomm-ccr-InKev-2016.pdf +[92]:https://fosdem.org/2017/schedule/event/go_bpf/ +[93]:https://wkz.github.io/ply/ +[94]:https://www.kernel.org/doc/Documentation/networking/filter.txt +[95]:https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/Documentation/bpf/bpf_design_QA.txt?id=2e39748a4231a893f057567e9b880ab34ea47aef +[96]:https://github.com/iovisor/bpf-docs/blob/master/eBPF.md +[97]:https://github.com/iovisor/bcc/tree/master/docs +[98]:https://github.com/iovisor/bpf-docs/ +[99]:https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md +[100]:http://man7.org/linux/man-pages/man2/bpf.2.html +[101]:http://man7.org/linux/man-pages/man8/tc-bpf.8.html +[102]:https://prototype-kernel.readthedocs.io/en/latest/bpf/index.html +[103]:http://docs.cilium.io/en/latest/bpf/ +[104]:https://ferrisellis.com/tags/ebpf/ +[105]:http://linux-ip.net/articles/Traffic-Control-HOWTO/ +[106]:http://lartc.org/lartc.html +[107]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/man/man8 +[108]:https://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git/tree/doc?h=v4.13.0 +[109]:https://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git/tree/doc/actions?h=v4.13.0 +[110]:http://netdevconf.org/1.2/session.html?jamal-tc-workshop +[111]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/commit/bash-completion/tc?id=27d44f3a8a4708bcc99995a4d9b6fe6f81e3e15b +[112]:https://prototype-kernel.readthedocs.io/en/latest/networking/XDP/index.html +[113]:https://marc.info/?l=linux-netdev&m=147436253625672 +[114]:http://docs.cilium.io/en/latest/bpf/ +[115]:https://github.com/iovisor/bcc/blob/master/INSTALL.md +[116]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/bpf.h +[117]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/bpf.h +[118]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/filter.h +[119]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/filter.h +[120]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/bpf +[121]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/core/filter.c +[122]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/x86/net/bpf_jit_comp.c +[123]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/sched +[124]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/trace/bpf_trace.c +[125]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/seccomp.c +[126]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/seccomp/seccomp_bpf.c +[127]:https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md +[128]:https://github.com/iovisor/bcc/blob/master/FAQ.txt +[129]:https://www.kernel.org/doc/Documentation/networking/filter.txt +[130]:https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md +[131]:https://github.com/iovisor/bcc/blob/master/src/python/bcc/__init__.py +[132]:https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md#output +[133]:https://www.spinics.net/lists/netdev/msg406926.html +[134]:https://github.com/cilium/bpf-map +[135]:https://github.com/badboy/bpf-map +[136]:https://stackoverflow.com/questions/tagged/bpf +[137]:https://github.com/iovisor/xdp-vagrant +[138]:https://github.com/zlim/bcc-docker +[139]:http://lists.openwall.net/netdev/ +[140]:http://vger.kernel.org/vger-lists.html#xdp-newbies +[141]:http://lists.iovisor.org/pipermail/iovisor-dev/ +[142]:https://twitter.com/IOVisor +[143]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#what-is-bpf +[144]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#dive-into-the-bytecode +[145]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#resources +[146]:https://github.com/qmonnet/whirl-offload/commits/gh-pages/_posts/2016-09-01-dive-into-bpf.md +[147]:http://netdevconf.org/1.2/session.html?jakub-kicinski +[148]:http://www.slideshare.net/IOVisor/express-data-path-linux-meetup-santa-clara-july-2016 +[149]:https://cdn.shopify.com/s/files/1/0177/9886/files/phv2017-gbertin.pdf +[150]:https://github.com/cilium/cilium +[151]:https://fosdem.org/2017/schedule/event/stateful_ebpf/ +[152]:http://vger.kernel.org/vger-lists.html#xdp-newbies +[153]:https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md +[154]:https://github.com/qmonnet/whirl-offload/commit/d694f8081ba00e686e34f86d5ee76abeb4d0e429 +[155]:http://openvswitch.org/pipermail/dev/2014-October/047421.html +[156]:https://qmonnet.github.io/whirl-offload/2016/07/15/beba-research-project/ +[157]:https://www.iovisor.org/resources/blog +[158]:http://www.brendangregg.com/blog/2016-03-05/linux-bpf-superpowers.html +[159]:http://p4.org/ +[160]:https://github.com/iovisor/bcc/tree/master/src/cc/frontends/p4 +[161]:https://github.com/p4lang/p4c/blob/master/backends/ebpf/README.md +[162]:https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md +[163]:https://github.com/iovisor/bcc/blob/master/docs/tutorial_bcc_python_developer.md +[164]:https://github.com/goldshtn/linux-tracing-workshop +[165]:https://blog.yadutaf.fr/2017/07/28/tracing-a-packet-journey-using-linux-tracepoints-perf-ebpf/ +[166]:https://open-nfp.org/dataplanes-ebpf/technical-papers/ +[167]:http://netdevconf.org/2.1/session.html?gospodarek +[168]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/samples/bpf +[169]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/examples/bpf +[170]:https://github.com/iovisor/bcc/tree/master/examples +[171]:http://man7.org/linux/man-pages/man8/tc-bpf.8.html +[172]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/core/dev.c +[173]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/mellanox/mlx4/ +[174]:https://github.com/iovisor/bcc/ +[175]:https://github.com/iovisor/bcc/blob/master/src/python/bcc/__init__.py +[176]:https://github.com/iovisor/bcc/blob/master/src/cc/libbpf.c +[177]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/tc +[178]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/lib/bpf.c +[179]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/tools/net +[180]:https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/tools/bpf +[181]:https://github.com/iovisor/bcc/tree/master/src/cc/frontends/p4/compiler +[182]:https://github.com/iovisor/bcc/tree/master/src/lua +[183]:https://reviews.llvm.org/D6494 +[184]:https://github.com/llvm-mirror/llvm/commit/4fe85c75482f9d11c5a1f92a1863ce30afad8d0d +[185]:https://github.com/iovisor/ubpf/ +[186]:https://github.com/YutaroHayakawa/generic-ebpf +[187]:https://github.com/YutaroHayakawa/vale-bpf +[188]:https://github.com/qmonnet/rbpf +[189]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git +[190]:https://github.com/torvalds/linux +[191]:https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md +[192]:https://qmonnet.github.io/whirl-offload/categories/#BPF From 0c92b01f4268b5893ad7d09ae91e6fc865d00991 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Mon, 4 Dec 2017 00:58:26 +0800 Subject: [PATCH 172/344] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=AF=95=20?= =?UTF-8?q?(#6432)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * take a break * translated * move to translated --- ...stem Logs: Understand Your Linux System.md | 60 ---------------- ...stem Logs: Understand Your Linux System.md | 68 +++++++++++++++++++ 2 files changed, 68 insertions(+), 60 deletions(-) delete mode 100644 sources/tech/20171117 System Logs: Understand Your Linux System.md create mode 100644 translated/tech/20171117 System Logs: Understand Your Linux System.md diff --git a/sources/tech/20171117 System Logs: Understand Your Linux System.md b/sources/tech/20171117 System Logs: Understand Your Linux System.md deleted file mode 100644 index a711ee2c05..0000000000 --- a/sources/tech/20171117 System Logs: Understand Your Linux System.md +++ /dev/null @@ -1,60 +0,0 @@ -translating by lujun9972 -### System Logs: Understand Your Linux System - -![chabowski](https://www.suse.com/communities/blog/files/2016/03/chabowski_avatar_1457537819-100x100.jpg) - By: [chabowski][1] - -The following article is part of a series of articles that provide tips and tricks for Linux newbies – or Desktop users that are not yet experienced with regard to certain topics). This series intends to complement the special edition #30 “[Getting Started with Linux][2]” based on [openSUSE Leap][3], recently published by the [Linux Magazine,][4] with valuable additional information. - -This article has been contributed by Romeo S. Romeo is a PDX-based enterprise Linux professional specializing in scalable solutions for innovative corporations looking to disrupt the marketplace. - -System logs are incredibly important files in Linux. Special programs that run in the background (usually called daemons or servers) handle most of the tasks on your Linux system. Whenever these daemons do anything, they write the details of the task to a log file as a sort of “history” of what they’ve been up to. These daemons perform actions ranging from syncing your clock with an atomic clock to managing your network connection. All of this is written to log files so that if something goes wrong, you can look into the specific log file and see what happened. - -![](https://www.suse.com/communities/blog/files/2017/11/markus-spiske-153537-300x450.jpg) - -Photo by Markus Spiske on Unsplash - -There are many different logs on your Linux computer. Historically, they were mostly stored in the /var/log directory in a plain text format. Quite a few still are, and you can read them easily with the less pager. On your freshly installed openSUSE Leap 42.3 system, and on most modern systems, important logs are stored by the systemd init system. This is the system that handles starting up daemons and getting the computer ready for use on startup. The logs handled by systemd are stored in a binary format, which means that they take up less space and can more easily be viewed or exported in various formats, but the downside is that you need a special tool to view them. Luckily, this tool comes installed on your system: it’s called journalctl and by default, it records all of the logs from every daemon to one location. - -To take a look at your systemd log, just run the journalctl command. This will open up the combined logs in the less pager. To get a better idea of what you’re looking at, see a single log entry from journalctl here: - -``` -Jul 06 11:53:47 aaathats3as pulseaudio[2216]: [pulseaudio] alsa-util.c: Disabling timer-based scheduling because running inside a VM. -``` - -This individual log entry contains (in order) the date and time of the entry, the hostname of the computer, the name of the process that logged the entry, the PID (process ID number) of the process that logged the entry, and then the log entry itself. - -If a program running on your system is misbehaving, look at the log file and search (with the “/” key followed by the search term) for the name of the program. Chances are that if the program is reporting errors that are causing it to malfunction, then the errors will show up in the system log. Sometimes errors are verbose enough for you to be able to fix them yourself. Other times, you have to search for a solution on the Web. Google is usually the most convenient search engine to use for weird Linux problems -![](https://www.suse.com/communities/blog/files/2017/09/Sunglasses_Emoji-450x450.png) -. However, be sure that you only enter the actual log entry, because the rest of the information at the beginning of the line (date, host name, PID) is unnecessary and could return false positives. - -After you search for the problem, the first few results are usually pages containing various things that you can try for solutions. Of course, you shouldn’t just follow random instructions that you find on the Internet: always be sure to do additional research into what exactly you will be doing and what the effects of it are before following any instructions. With that being said, the results for a specific entry from the system’s log file are usually much more useful than results from searching more generic terms that describe the malfunctioning of the program directly. This is because many different things could cause a program to misbehave, and multiple problems could cause identical misbehaviors. - -For example, a lack of audio on the system could be due to a massive amount of different reasons, ranging from speakers not being plugged in, to back end sound systems misbehaving, to a lack of the proper drivers. If you search for a general problem, you’re likely to see a lot of irrelevant solutions and you’ll end up wasting your time on a wild goose chase. With a specific search of an actual line from a log file, you can see other people who have had the same log entry. See Picture 1 and Picture 2 to compare and contrast between the two types of searching. - -![](https://www.suse.com/communities/blog/files/2017/11/picture1-450x450.png) - -Picture 1 shows generic, unspecific Google results for a general misbehavior of the system. This type of searching generally doesn’t help much. - -![](https://www.suse.com/communities/blog/files/2017/11/picture2-450x450.png) - -Picture 2 shows more specific, helpful Google results for a particular log file line. This type of searching is generally very helpful. - -There are some systems that log their actions outside of journalctl. The most important ones that you may find yourself dealing with on a desktop system are /var/log/zypper.log for openSUSE’s package manager, /var/log/boot.log for those messages that scroll by too fast to be read when you turn your system on, and /var/log/ntp if your Network Time Protocol Daemon is having troubles syncing time. One more important place to look for errors if you’re having problems with specific hardware is the Kernel Ring Buffer, which you can read by typing the dmesg -H command (this opens in the less pager as well). The Kernel Ring Buffer is stored in RAM, so you lose it when you reboot your system, but it contains important messages from the Linux kernel about important events, such as hardware being added, modules being loaded, or strange network errors. - -Hopefully you are prepared now to understand your Linux system better! Have a lot of fun! - --------------------------------------------------------------------------------- - -via: https://www.suse.com/communities/blog/system-logs-understand-linux-system/ - -作者:[chabowski] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[1]:https://www.suse.com/communities/blog/author/chabowski/ -[2]:http://www.linux-magazine.com/Resources/Special-Editions/30-Getting-Started-with-Linux -[3]:https://en.opensuse.org/Portal:42.3 -[4]:http://www.linux-magazine.com/ diff --git a/translated/tech/20171117 System Logs: Understand Your Linux System.md b/translated/tech/20171117 System Logs: Understand Your Linux System.md new file mode 100644 index 0000000000..dceea12a63 --- /dev/null +++ b/translated/tech/20171117 System Logs: Understand Your Linux System.md @@ -0,0 +1,68 @@ +### 系统日志: 了解你的Linux系统 + +![chabowski](https://www.suse.com/communities/blog/files/2016/03/chabowski_avatar_1457537819-100x100.jpg) + By: [chabowski][1] + +本文摘自教授Linux小白(或者非资深桌面用户)技巧的系列文章. 该系列文章旨在为由LinuxMagazine基于 [openSUSE Leap][3] 发布的第30期特别版 “[Getting Started with Linux][2]” 提供补充说明. + +本文作者是 Romeo S. Romeo, 他是一名 PDX-based enterprise Linux 专家,转为创新企业提供富有伸缩性的解决方案. + +Linux系统日志非常重要. 后台运行的程序(通常被称为守护进程或者服务进程)处理了你Linux系统中的大部分任务. 当这些守护进程工作时,它们将任务的详细信息记录进日志文件中,作为他们做过什么的历史信息. 这些守护进程的工作内容涵盖从使用原子钟同步时钟到管理网络连接. 所有这些都被记录进日志文件,这样当有错误发生时,你可以通过查阅特定的日志文件来看出发生了什么. + +![](https://www.suse.com/communities/blog/files/2017/11/markus-spiske-153537-300x450.jpg) + +Photo by Markus Spiske on Unsplash + +有很多不同的日志. 历史上, 他们一般以纯文本的格式存储到 `/var/log` 目录中. 现在依然有很多日志这样做, 你可以很方便的使用 `less` 来查看它们. +在新装的 `openSUSE Leap 42.3` 以及大多数现代操作系统上,重要的日志由 `systemd` 初始化系统存储. `systemd`这套系统负责启动守护进程并在系统启动时让计算机做好被使用的准备。 +由 `systemd` 记录的日志以二进制格式存储, 这使地它们消耗的空间更小,更容易被浏览,也更容易被导出成其他各种格式,不过坏处就是你必须使用特定的工具才能查看. +好在, 这个工具已经预安装在你的系统上了: 它的名字叫 `journalctl`,而且默认情况下, 它会将每个守护进程的所有日志都记录到一个地方. + +只需要运行 `journalctl` 命令就能查看你的 `systemd` 日志了. 它会用 `less` 分页器显示各种日志. 为了让你有个直观的感受, 下面是`journalctl` 中摘录的一条日志记录: + +``` +Jul 06 11:53:47 aaathats3as pulseaudio[2216]: [pulseaudio] alsa-util.c: Disabling timer-based scheduling because running inside a VM. +``` + +这条独立的日志记录以此包含了记录的日期和时间, 计算机名, 记录日志的进程名, 记录日志的进程PID, 以及日志内容本身. + +若系统中某个程序运行出问题了, 则可以查看日志文件并搜索(使用 “/” 加上要搜索的关键字)程序名称. 有可能导致该程序出问题的错误会记录到系统日志中. +有时,错误信息会足够详细让你能够修复该问题. 其他时候, 你需要在Web上搜索解决方案. Google就很适合来搜索奇怪的Linux问题. +![](https://www.suse.com/communities/blog/files/2017/09/Sunglasses_Emoji-450x450.png) +不过搜索时请注意你只输入了日志的内容, 行首的那些信息(日期, 主机名, 进程ID) 是无意义的,会干扰搜索结果. + +解决方法一般在搜索结果的前几个连接中就会有了. 当然,你不能只是无脑得运行从互联网上找到的那些命令: 请一定先搞清楚你要做的事情是什么,它的效果会是什么. +据说, 从系统日志中查询日志要比直接搜索描述故障的关键字要有用的多. 因为程序出错有很多原因, 而且同样的故障表现也可能由多种问题引发的. + +比如, 系统无法发声的原因有很多, 可能是播放器没有插好, 也可能是声音系统出故障了, 还可能是缺少合适的驱动程序. +如果你只是泛泛的描述故障表现, 你会找到很多无关的解决方法,而你也会浪费大量的时间. 而指定搜索日志文件中的内容, 你只会查询出他人也有相同日志内容的结果. +你可以对比一下图1和图2. + +![](https://www.suse.com/communities/blog/files/2017/11/picture1-450x450.png) + +图 1 搜索系统的故障表现只会显示泛泛的,不精确的结果. 这种搜索通常没什么用. + +![](https://www.suse.com/communities/blog/files/2017/11/picture2-450x450.png) + +图 2 搜索特定的日志行会显示出精确的,有用的结果. 这种搜索通常很有用. + +也有一些系统不用 `journalctl` 来记录日志. 在桌面系统中最常见的这类日志包括用于 `/var/log/zypper.log` 记录openSUSE包管理器的行为; `/var/log/boot.log` 记录系统启动时的消息,这类消息往往滚动的特别块,根本看不过来; `/var/log/ntp` 用来记录 Network Time Protocol 守护进程同步时间时发生的错误. +另一个存放硬件故障信息的地方是 `Kernel Ring Buffer`(内核环状缓冲区), 你可以输入 `demesg -H` 命令来查看(这条命令也会调用 `less` 分页器来查看). +`Kernel Ring Buffer` 存储在内存中, 因此会在重启电脑后丢失. 不过它包含了Linux内核中的重要事件, 比如新增了硬件, 加载了模块, 以及奇怪的网络错误. + +希望你已经准备好深入了解你的Linux系统了! 祝你玩的开心! + +-------------------------------------------------------------------------------- + +via: https://www.suse.com/communities/blog/system-logs-understand-linux-system/ + +作者:[chabowski] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://www.suse.com/communities/blog/author/chabowski/ +[2]:http://www.linux-magazine.com/Resources/Special-Editions/30-Getting-Started-with-Linux +[3]:https://en.opensuse.org/Portal:42.3 +[4]:http://www.linux-magazine.com/ From 8f52cee72a69ff34f7e887dee439c9ff3f4dac0b Mon Sep 17 00:00:00 2001 From: DarkSun Date: Mon, 4 Dec 2017 01:00:31 +0800 Subject: [PATCH 173/344] =?UTF-8?q?=E9=80=89=E9=A2=98=E5=B9=B6=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E7=BF=BB=E8=AF=91=20How=20To=20Tell=20If=20Your=20Lin?= =?UTF-8?q?ux=20Server=20Has=20Been=20Compromised=20(#6433)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * translated * moved to translated directory * 选题: How To Tell If Your Linux Server Has Been Compromised * 申请翻译 --- ... Your Linux Server Has Been Compromised.md | 156 ++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md diff --git a/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md b/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md new file mode 100644 index 0000000000..dd61ad7a95 --- /dev/null +++ b/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md @@ -0,0 +1,156 @@ +translating by lujun9972 +How To Tell If Your Linux Server Has Been Compromised +-------------- + +A server being compromised or hacked for the purpose of this guide is an unauthorized person or bot logging into the server in order to use it for their own, usually negative ends. + +Disclaimer: If your server has been compromised by a state organization like the NSA or a serious criminal group then you will not notice any problems and the following techniques will not register their presence. + +However, the majority of compromised servers are carried out by bots i.e. automated attack programs, in-experienced attackers e.g. “script kiddies”, or dumb criminals. + +These sorts of attackers will abuse the server for all it’s worth whilst they have access to it and take few precautions to hide what they are doing. + +### Symptoms of a compromised server + +When a server has been compromised by an in-experienced or automated attacker they will usually do something with it that consumes 100% of a resource. This resource will usually be either the CPU for something like crypt-currency mining or email spamming, or bandwidth for launching a DOS attack. + +This means that the first indication that something is amiss is that the server is “going slow”. This could manifest in the website serving pages much slower than usual, or email taking many minutes to deliver or send. + +So what should you look for? + +### Check 1 - Who’s currently logged in? + +The first thing you should look for is who is currently logged into the server. It is not uncommon to find the attacker actually logged into the server and working on it. + +The shell command to do this is w. Running w gives the following output: + +``` + 08:32:55 up 98 days, 5:43, 2 users, load average: 0.05, 0.03, 0.00 +USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT +root pts/0 113.174.161.1 08:26 0.00s 0.03s 0.02s ssh root@coopeaa12 +root pts/1 78.31.109.1 08:26 0.00s 0.01s 0.00s w + +``` + +One of those IP’s is a UK IP and the second is Vietnamese. That’s probably not a good thing. + +Stop and take a breath, don’t panic and simply kill their SSH connection. Unless you can stop then re-entering the server they will do so quickly and quite likely kick you off and stop you getting back in. + +Please see the What should I do if I’ve been compromised section at the end of this guide no how to proceed if you do find evidence of compromise. + +The whois command can be run on IP addresses and will tell you what all the information about the organization that the IP is registered to, including the country. + +### Check 2 - Who has logged in? + +Linux servers keep a record of which users logged in, from what IP, when and for how long. This information is accessed with the last command. + +The output looks like this: + +``` +root pts/1 78.31.109.1 Thu Nov 30 08:26 still logged in +root pts/0 113.174.161.1 Thu Nov 30 08:26 still logged in +root pts/1 78.31.109.1 Thu Nov 30 08:24 - 08:26 (00:01) +root pts/0 113.174.161.1 Wed Nov 29 12:34 - 12:52 (00:18) +root pts/0 14.176.196.1 Mon Nov 27 13:32 - 13:53 (00:21) + +``` + +There is a mix of my UK IP’s and some Vietnamese ones, with the top two still logged in. If you see any IP’s that are not authorized then refer to the final section. + +The login history is contained in a text file at ~/.bash_history and is therefore easily removable. Often, attackers will simply delete this file to try to cover their tracks. Consequently, if you run last and only see your current login, this is a Bad Sign. + +If there is no login history be very, very suspicious and continue looking for indications of compromise. + +### Check 3 - Review the command history + +This level of attacker will frequently take no precautions to leave no command history so running the history command will show you everything they have done. Be on the lookout for wget or curl commands to download out-of-repo software such as spam bots or crypto miners. + +The command history is contained in the ~/.bash_history file so some attackers will delete this file to cover what they have done. Just as with the login history, if you run history and don’t see anything then the history file has been deleted. Again this is a Bad Sign and you should review the server very carefully. + +### Check 4 - What’s using all the CPU? + +The sorts of attackers that you will encounter usually don’t take too many precautions to hide what they are doing. So they will run processes that consume all the CPU. This generally makes it pretty easy to spot them. Simply run top and look at the highest process. + +This will also show people exploiting your server without having logged in. This could be, for example, someone using an unprotected form-mail script to relay spam. + +If you don’t recognize the top process then either Google its name or investigate what it’s doing with losf or strace. + +To use these tools first copy its PID from top and run: + +``` +strace -p PID + +``` + +This will display all the system calls the process is making. It’s a lot of information but looking through it will give you a good idea what’s going on. + +``` +lsof -p PID + +``` + +This program will list the open files that the process has. Again, this will give you a good idea what it’s doing by showing you what files it is accessing. + +### Check 5 - Review the all the system processes + +If an unauthorized process is not consuming enough CPU to get listed noticeably on top it will still get displayed in a full process listing with ps. My proffered command is ps auxf for providing the most information clearly. + +You should be looking for any processes that you don’t recognize. The more times you run ps on your servers (which is a good habit to get into) the more obvious an alien process will stand out. + +### Check 6 - Review network usage by process + +The command iftop functions like top to show a ranked list of processes that are sending and receiving network data along with their source and destination. A process like a DOS attack or spam bot will immediately show itself at the top of the list. + +### Check 7 - What processes are listening for network connections? + +Often an attacker will install a program that doesn’t do anything except listen on the network port for instructions. This does not consume CPU or bandwidth whilst it is waiting so can get overlooked in the top type commands. + +The commands lsof and netstat will both list all networked processes. I use them with the following options: + +``` +lsof -i + +``` + +``` +netstat -plunt + +``` + +You should look for any process that is listed as in the LISTEN or ESTABLISHED status as these processes are either waiting for a connection (LISTEN) or have a connection open (ESTABLISHED). If you don’t recognize these processes use strace or lsof to try to see what they are doing. + +### What should I do if I’ve been compromised? + +The first thing to do is not to panic, especially if the attacker is currently logged in. You need to be able to take back control of the machine before the attacker is aware that you know about them. If they realize you know about them they may well lock you out of your server and start destroying any assets out of spite. + +If you are not very technical then simply shut down the server. Either from the server itself with shutdown -h now or systemctl poweroff. Or log into your hosting provider’s control panel and shut down the server. Once it’s powered off you can work on the needed firewall rules and consult with your provider in your own time. + +If you’re feeling a bit more confident and your hosting provider has an upstream firewall then create and enable the following two rules in this order: + +1. Allow SSH traffic from only your IP address. + +2. Block everything else, not just SSH but every protocol on every port. + +This will immediately kill their SSH session and give only you access to the server. + +If you don’t have access to an upstream firewall then you will have to create and enable these firewall rules on the server itself and then, when they are in place kill the attacker’s ssh session with the kill command. + +A final method, where available, is to log into the server via an out-of-band connection such as the serial console and stop networking with systemctl stop network.service. This will completely stop any network access so you can now enable the firewall rules in your own time. + +Once you have regained control of the server do not trust it. + +Do not attempt to fix things up and continue using the server. You can never be sure what the attacker did and so you can never sure the server is secure. + +The only sensible course of action is to copy off all the data that you need and start again from a fresh install. + +-------------------------------------------------------------------------------- + +via: https://bash-prompt.net/guides/server-hacked/ + +作者:[Elliot Cooper][a] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://bash-prompt.net From 7118ad361c8bdddaba7c66c464737c3b76e44bf2 Mon Sep 17 00:00:00 2001 From: hopefully2333 <787016457@qq.com> Date: Mon, 4 Dec 2017 01:05:04 +0800 Subject: [PATCH 174/344] final version (#6435) * Delete 20090701 The One in Which I Call Out Hacker News.md * final version final version created in 12.3 23:56 --- ...The One in Which I Call Out Hacker News.md | 86 ---------------- ...The One in Which I Call Out Hacker News.md | 99 +++++++++++++++++++ 2 files changed, 99 insertions(+), 86 deletions(-) delete mode 100644 sources/tech/20090701 The One in Which I Call Out Hacker News.md create mode 100644 translated/tech/20090701 The One in Which I Call Out Hacker News.md diff --git a/sources/tech/20090701 The One in Which I Call Out Hacker News.md b/sources/tech/20090701 The One in Which I Call Out Hacker News.md deleted file mode 100644 index 44c751dd5a..0000000000 --- a/sources/tech/20090701 The One in Which I Call Out Hacker News.md +++ /dev/null @@ -1,86 +0,0 @@ -translating by hopefully2333 - -# [The One in Which I Call Out Hacker News][14] - - -> “Implementing caching would take thirty hours. Do you have thirty extra hours? No, you don’t. I actually have no idea how long it would take. Maybe it would take five minutes. Do you have five minutes? No. Why? Because I’m lying. It would take much longer than five minutes. That’s the eternal optimism of programmers.” -> -> — Professor [Owen Astrachan][1] during 23 Feb 2004 lecture for [CPS 108][2] - -[Accusing open-source software of being a royal pain to use][5] is not a new argument; it’s been said before, by those much more eloquent than I, and even by some who are highly sympathetic to the open-source movement. Why go over it again? - -On Hacker News on Monday, I was amused to read some people saying that [writing StackOverflow was hilariously easy][6]—and proceeding to back up their claim by [promising to clone it over July 4th weekend][7]. Others chimed in, pointing to [existing][8] [clones][9] as a good starting point. - -Let’s assume, for sake of argument, that you decide it’s okay to write your StackOverflow clone in ASP.NET MVC, and that I, after being hypnotized with a pocket watch and a small club to the head, have decided to hand you the StackOverflow source code, page by page, so you can retype it verbatim. We’ll also assume you type like me, at a cool 100 WPM ([a smidge over eight characters per second][10]), and unlike me,  _you_  make zero mistakes. StackOverflow’s *.cs, *.sql, *.css, *.js, and *.aspx files come to 2.3 MB. So merely typing the source code back into the computer will take you about eighty hours if you make zero mistakes. - -Except, of course, you’re not doing that; you’re going to implement StackOverflow from scratch. So even assuming that it took you a mere ten times longer to design, type out, and debug your own implementation than it would take you to copy the real one, that already has you coding for several weeks straight—and I don’t know about you, but I am okay admitting I write new code  _considerably_  less than one tenth as fast as I copy existing code. - - _Well, okay_ , I hear you relent. *So not the whole thing. But I can do **most** of it.* - -Okay, so what’s “most”? There’s simply asking and responding to questions—that part’s easy. Well, except you have to implement voting questions and answers up and down, and the questioner should be able to accept a single answer for each question. And you can’t let people upvote or accept their own answers, so you need to block that. And you need to make sure that users don’t upvote or downvote another user too many times in a certain amount of time, to prevent spambots. Probably going to have to implement a spam filter, too, come to think of it, even in the basic design, and you also need to support user icons, and you’re going to have to find a sanitizing HTML library you really trust and that interfaces well with Markdown (provided you do want to reuse [that awesome editor][11] StackOverflow has, of course). You’ll also need to purchase, design, or find widgets for all the controls, plus you need at least a basic administration interface so that moderators can moderate, and you’ll need to implement that scaling karma thing so that you give users steadily increasing power to do things as they go. - -But if you do  _all that_ , you  _will_  be done. - -Except…except, of course, for the full-text search, especially its appearance in the search-as-you-ask feature, which is kind of indispensable. And user bios, and having comments on answers, and having a main page that shows you important questions but that bubbles down steadily à la reddit. Plus you’ll totally need to implement bounties, and support multiple OpenID logins per user, and send out email notifications for pertinent events, and add a tagging system, and allow administrators to configure badges by a nice GUI. And you’ll need to show users’ karma history, upvotes, and downvotes. And the whole thing has to scale really well, since it could be slashdotted/reddited/StackOverflown at any moment. - -But  _then_ ! **Then** you’re done! - -…right after you implement upgrades, internationalization, karma caps, a CSS design that makes your site not look like ass, AJAX versions of most of the above, and G-d knows what else that’s lurking just beneath the surface that you currently take for granted, but that will come to bite you when you start to do a real clone. - -Tell me: which of those features do you feel you can cut and still have a compelling offering? Which ones go under “most” of the site, and which can you punt? - -Developers think cloning a site like StackOverflow is easy for the same reason that open-source software remains such a horrible pain in the ass to use. When you put a developer in front of StackOverflow, they don’t really  _see_ StackOverflow. What they actually  _see_  is this: - -``` -create table QUESTION (ID identity primary key, - TITLE varchar(255), --- why do I know you thought 255? - BODY text, - UPVOTES integer not null default 0, - DOWNVOTES integer not null default 0, - USER integer references USER(ID)); -create table RESPONSE (ID identity primary key, - BODY text, - UPVOTES integer not null default 0, - DOWNVOTES integer not null default 0, - QUESTION integer references QUESTION(ID)) -``` - -If you then tell a developer to replicate StackOverflow, what goes into his head are the above two SQL tables and enough HTML to display them without formatting, and that really  _is_  completely doable in a weekend. The smarter ones will realize that they need to implement login and logout, and comments, and that the votes need to be tied to a user, but that’s still totally doable in a weekend; it’s just a couple more tables in a SQL back-end, and the HTML to show their contents. Use a framework like Django, and you even get basic users and comments for free. - -But that’s  _not_  what StackOverflow is about. Regardless of what your feelings may be on StackOverflow in general, most visitors seem to agree that the user experience is smooth, from start to finish. They feel that they’re interacting with a polished product. Even if I didn’t know better, I would guess that very little of what actually makes StackOverflow a continuing success has to do with the database schema—and having had a chance to read through StackOverflow’s source code, I know how little really does. There is a  _tremendous_  amount of spit and polish that goes into making a major website highly usable. A developer, asked how hard something will be to clone, simply  _does not think about the polish_ , because  _the polish is incidental to the implementation._ - -That is why an open-source clone of StackOverflow will fail. Even if someone were to manage to implement most of StackOverflow “to spec,” there are some key areas that would trip them up. Badges, for example, if you’re targeting end-users, either need a GUI to configure rules, or smart developers to determine which badges are generic enough to go on all installs. What will actually happen is that the developers will bitch and moan about how you can’t implement a really comprehensive GUI for something like badges, and then bikeshed any proposals for standard badges so far into the ground that they’ll hit escape velocity coming out the other side. They’ll ultimately come up with the same solution that bug trackers like Roundup use for their workflow: the developers implement a generic mechanism by which anyone, truly anyone at all, who feels totally comfortable working with the system API in Python or PHP or whatever, can easily add their own customizations. And when PHP and Python are so easy to learn and so much more flexible than a GUI could ever be, why bother with anything else? - -Likewise, the moderation and administration interfaces can be punted. If you’re an admin, you have access to the SQL server, so you can do anything really genuinely administrative-like that way. Moderators can get by with whatever django-admin and similar systems afford you, since, after all, few users are mods, and mods should understand how the sites  _work_ , dammit. And, certainly, none of StackOverflow’s interface failings will be rectified. Even if StackOverflow’s stupid requirement that you have to have and know how to use an OpenID (its worst failing) eventually gets fixed, I’m sure any open-source clones will rabidly follow it—just as GNOME and KDE for years slavishly copied off Windows, instead of trying to fix its most obvious flaws. - -Developers may not care about these parts of the application, but end-users do, and take it into consideration when trying to decide what application to use. Much as a good software company wants to minimize its support costs by ensuring that its products are top-notch before shipping, so, too, savvy consumers want to ensure products are good before they purchase them so that they won’t  _have_  to call support. Open-source products fail hard here. Proprietary solutions, as a rule, do better. - -That’s not to say that open-source doesn’t have its place. This blog runs on Apache, [Django][12], [PostgreSQL][13], and Linux. But let me tell you, configuring that stack is  _not_  for the faint of heart. PostgreSQL needs vacuuming configured on older versions, and, as of recent versions of Ubuntu and FreeBSD, still requires the user set up the first database cluster. MS SQL requires neither of those things. Apache…dear heavens, don’t even get me  _started_  on trying to explain to a novice user how to get virtual hosting, MovableType, a couple Django apps, and WordPress all running comfortably under a single install. Hell, just trying to explain the forking vs. threading variants of Apache to a technically astute non-developer can be a nightmare. IIS 7 and Apache with OS X Server’s very much closed-source GUI manager make setting up those same stacks vastly simpler. Django’s a great a product, but it’s nothing  _but_  infrastructure—exactly the thing that I happen to think open-source  _does_  do well,  _precisely_  because of the motivations that drive developers to contribute. - -The next time you see an application you like, think very long and hard about all the user-oriented details that went into making it a pleasure to use, before decrying how you could trivially reimplement the entire damn thing in a weekend. Nine times out of ten, when you think an application was ridiculously easy to implement, you’re completely missing the user side of the story. - --------------------------------------------------------------------------------- - -via: https://bitquabit.com/post/one-which-i-call-out-hacker-news/ - -作者:[Benjamin Pollack][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://bitquabit.com/meta/about/ -[1]:http://www.cs.duke.edu/~ola/ -[2]:http://www.cs.duke.edu/courses/cps108/spring04/ -[3]:https://bitquabit.com/categories/programming -[4]:https://bitquabit.com/categories/technology -[5]:http://blog.bitquabit.com/2009/06/30/one-which-i-say-open-source-software-sucks/ -[6]:http://news.ycombinator.com/item?id=678501 -[7]:http://news.ycombinator.com/item?id=678704 -[8]:http://code.google.com/p/cnprog/ -[9]:http://code.google.com/p/soclone/ -[10]:http://en.wikipedia.org/wiki/Words_per_minute -[11]:http://github.com/derobins/wmd/tree/master -[12]:http://www.djangoproject.com/ -[13]:http://www.postgresql.org/ -[14]:https://bitquabit.com/post/one-which-i-call-out-hacker-news/ diff --git a/translated/tech/20090701 The One in Which I Call Out Hacker News.md b/translated/tech/20090701 The One in Which I Call Out Hacker News.md new file mode 100644 index 0000000000..670be95353 --- /dev/null +++ b/translated/tech/20090701 The One in Which I Call Out Hacker News.md @@ -0,0 +1,99 @@ +我号召黑客新闻的理由之一 +实现高速缓存会花费 30 个小时,你有额外的 30 个小时吗? +不,你没有。 +我实际上并不知道它会花多少时间,可能它会花五分钟,你有五分钟吗?不,你还是没有。为什么?因为我在撒谎。它会消耗远超五分钟的时间,这是程序员永远的 +乐观主义。 +- Owen Astrachan 教授于 2004 年 2 月 23 日在 CPS 108 上的讲座 + +指责开源软件的使用存在着高昂的代价已经不是一个新论点了,它之前就被提过,而且说的比我更有信服力,即使一些人已经在高度赞扬开源软件的运作。 +这种事为什么会重复发生? + +在周一的黑客新闻上,我愉悦地看着某些人一边说写 Stack Overflow 简单的简直搞笑,一边通过允许七月第四个周末之后的克隆来开始备份他们的提问。 +其他的声明中也指出现存的克隆是一个好的出发点。 + +让我们假设,为了争辩,你觉得将自己的 Stack Overflow 通过 ASP.NET 和 MVC 克隆是正确的,然后被一块廉价的手表和一个小型俱乐部头领忽悠之后, +决定去手动拷贝你 Stack Overflow 的源代码,一页又一页,所以你可以逐字逐句地重新输入,我们同样会假定你像我一样打字,很酷的有 100 WPM +(差不多每秒8个字符),不和我一样的话,你不会犯错。 + + Stack Overflow 的 *.cs、*.sql、*.css、*.js 和 *.aspx 文件大约 2.3 MB,因此如果你想将这些源代码输进电脑里去的话,即使你不犯错也需要大约 80 个小时。 + +除非......当然,你是不会那样做的:你打算从头开始实现 Stack Overflow 。所以即使我们假设,你花了十倍的时间去设计、输出,然后调试你自己的实现而不是去拷 +贝已有的那份,那已经让你已经编译了好几个星期。我不知道你,但是我可以承认我写的新代码大大小于我复制的现有代码的十分之一。 + +好,ok,我听见你松了口气。所以不是全部。但是我可以做大部分。 + +行,所以什么是大部分?这只是询问和回答问题,这个部分很简单。那么,除了你必须实现对问题和答案投票、赞同还是反对,而且提问者应该能够去接收每一个问题的 +单一答案。你不能让人们赞同或者反对他们自己的回答。所以你需要去阻止。你需要去确保用户在一定的时间内不会赞同或反对其他用户太多次。以预防垃圾邮件, +你可能也需要去实现一个垃圾邮件过滤器,即使在一个基本的设计里,也要考虑到这一点。而且还需要去支持用户图标。并且你将不得不寻找一个自己真正信任的并且 +与 markdown 接合很好的 HTML 库(当然,你确实希望重新使用那个令人敬畏的编辑器 Stack Overflow ),你还需要为所有控件购买,设计或查找小部件,此外 +你至少需要一个基本的管理界面,以便用户可以调节,并且你需要实现可扩展的业务量,以便能稳定地给用户越来越多的功能去实现他们想做的。 + +如果你这样做了,你可以完成它。 + +除了...除了全文检索外,特别是它在“寻找问题”功能中的表现,这是必不可少的。然后用户的基本信息,和回答的意见,然后有一个主要展示你的重要问题, +但是它会稳定的冒泡式下降。另外你需要去实现奖励,并支持每个用户的多个 OpenID 登录,然后为相关的事件发送邮件通知,并添加一个标签系统, +接着允许管理员通过一个不错的图形界面配置徽章。你需要去显示用户的 karma 历史,点赞和差评。整个事情的规模都非常好,因为它随时都可以被 + slashdotted、reddited 或是 Stack Overflow 。 + +在这之后!你就已经完成了! + +...在正确地实现升级、国际化、业绩上限和一个 css 设计之后,使你的站点看起来不像是一个屁股,上面的大部分 AJAX 版本和 G-d 知道什么会同样潜伏 +在你所信任的界面下,但是当你开始做一个真正的克隆的时候,就会遇到它。 + +告诉我:这些功能中哪个是你感觉可以削减而让它仍然是一个引人注目的产品,哪些是大部分网站之下的呢?哪个你可以剔除呢? + +开发者因为开源软件的使用是一个可怕的痛苦这样一个相同的理由认为克隆一个像 Stack Overflow 的站点很简单。当你把一个开发者放在 Stack Overflow 前面, +他们并不真的看到 Stack Overflow,他们实际上看的是这些: + +create table QUESTION (ID identity primary key, + TITLE varchar(255), --- 为什么我知道你认为是 255 + BODY text, + UPVOTES integer not null default 0, + DOWNVOTES integer not null default 0, + USER integer references USER(ID)); +create table RESPONSE (ID identity primary key, + BODY text, + UPVOTES integer not null default 0, + DOWNVOTES integer not null default 0, + QUESTION integer references QUESTION(ID)) + +如果你告诉一个开发者去复制 Stack Overflow ,进入他脑海中的就是上面的两个 SQL 表和足够的 HTML 文件来显示它们,而不用格式化,这在一个周末里是完全 +可以实现的,聪明的人会意识到他们需要实现登陆、注销和评论,点赞需要绑定到用户。但是这在一个周末内仍然是完全可行的。这仅仅是在 SQL 后端里加上两张 +左右的表,而 HTML 则用来展示内容,使用像 Django 这样的框架,你甚至可以免费获得基本的用户和评论。 + +但是那不是和 Stack Overflow 相关的,无论你对 Stack Overflow 的感受如何,大多数访问者似乎都认为用户体验从头到尾都很流畅,他们感觉他们和一个 +好产品相互影响。即使我没有更好的了解,我也会猜测 Stack Overflow 在数据库模式方面取得了持续的成功-并且有机会去阅读 Stack Overflow 的源代码, +我知道它实际上有多么的小,这些是一个极大的 spit 和 Polish 的集合,成为了一个具有高可用性的主要网站,一个开发者,问一个东西被克隆有多难, +仅仅不认为和 Polish 相关,因为 Polish 是实现结果附带的。 + +这就是为什么 Stack Overflow 的开放源代码克隆会失败,即使一些人在设法实现大部分 Stack Overflow 的“规范”,也会有一些关键区域会将他们绊倒, +举个例子,如果你把目标市场定在了终端用户上,你要么需要一个图形界面去配置规则,要么聪明的开发者会决定哪些徽章具有足够的通用性,去继续所有的 +安装,实际情况是,开发者发牢骚和抱怨你不能实现一个真实的综合性的像 badges 的图形用户界面,然后 bikeshed 任何的建议,为因为标准的 badges +在范围内太远,他们会迅速避开选择其他方向,他们最后会带着相同的有 bug 追踪器的解决方案赶上,就像他们工作流程的概要使用一样: +开发者通过任意一种方式实现一个通用的机制,任何一个人完全都能轻松地使用 Python、PHP 或任意一门语言中的系统 API 来工作,能简单为他们自己增加 +自定义设置,PHP 和 Python 是学起来很简单的,并且比起曾经的图形界面更加的灵活,为什么还要操心其他事呢? + +同样的,节制和管理界面可以被削减。如果你是一个管理员,你可以进入 SQL 服务器,所以你可以做任何真正的管理-就像这样,管理员可以通过任何的 Django +管理和类似的系统给你提供支持,因为,毕竟只有少数用户是 mods,mods 应该理解网站是怎么运作、停止的。当然,没有 Stack Overflow 的接口失败会被纠正 +,即使 Stack Overflow 的愚蠢的要求,你必须知道如何去使用 openID (它是最糟糕的缺点)最后得到修复。我确信任何的开源的克隆都会狂热地跟随它- +即使 GNOME 和 KDE 多年来亦步亦趋地复制 windows ,而不是尝试去修复它自己最明显的缺陷。 + +开发者可能不会关心应用的这些部分,但是最终用户会,当他们尝试去决定使用哪个应用时会去考虑这些。就好像一家好的软件公司希望通过确保其产品在出货之前 +是一流的来降低其支持成本一样,所以,同样的,懂行的消费者想在他们购买这些产品之前确保产品好用,以便他们不需要去寻求帮助,开源产品就失败在这种地方 +,一般来说,专有解决方案会做得更好。 + +这不是说开源软件没有他们自己的立足之地,这个博客运行在 Apache,Django,PostgreSQL 和 Linux 上。但是让我告诉你,配置这些堆栈不是为了让人心灰意懒 +,PostgreSQL 需要在老版本上移除设置。然后,在 Ubuntu 和 FreeBSD 最新的版本上,仍然要求用户搭建第一个数据库集群,MS SQL不需要这些东西,Apache... +天啊,甚至没有让我开始尝试去向一个初学者用户解释如何去得到虚拟机,MovableType,一对 Django 应用程序,而且所有的 WordPress 都可以在一个单一的安装下 +顺利运行,像在地狱一样,只是试图解释 Apache 的分叉线程变换给技术上精明的非开发人员就是一个噩梦,IIS 7 和操作系统的 Apache 服务器是非常闭源的, +图形界面管理程序配置这些这些相同的堆栈非常的简单,Django 是一个伟大的产品,但是它只是基础架构而已,我认为开源软件做的很好,恰恰是因为推动开发者去 +贡献的动机 + +下次你看见一个你喜欢的应用,认为所有面向用户的细节非常长和辛苦,就会去让它用起来更令人开心,在谴责你如何能普通的实现整个的可恶的事在一个周末, +十分之九之后,当你认为一个应用的实现简单地简直可笑,你就完全的错失了故事另一边的用户 + +via: https://bitquabit.com/post/one-which-i-call-out-hacker-news/ + +作者:Benjamin Pollack 译者:hopefully2333 校对:校对者ID + +本文由 LCTT 原创编译,Linux中国 荣誉推出 From 95d447053943ddccb728cc2a5919f0136827d8ef Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 4 Dec 2017 09:12:25 +0800 Subject: [PATCH 175/344] Update 20170910 Cool vim feature sessions.md --- sources/tech/20170910 Cool vim feature sessions.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20170910 Cool vim feature sessions.md b/sources/tech/20170910 Cool vim feature sessions.md index 8c0506e086..ed101c429c 100644 --- a/sources/tech/20170910 Cool vim feature sessions.md +++ b/sources/tech/20170910 Cool vim feature sessions.md @@ -1,3 +1,5 @@ +translating---geekpi + Cool vim feature: sessions! ============================================================• From dff154b15893a6564e4acec1e8527320ecf4c867 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 4 Dec 2017 09:18:57 +0800 Subject: [PATCH 176/344] translating --- sources/tech/20171108 Archiving repositories.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171108 Archiving repositories.md b/sources/tech/20171108 Archiving repositories.md index 3537254131..4038ca8a9f 100644 --- a/sources/tech/20171108 Archiving repositories.md +++ b/sources/tech/20171108 Archiving repositories.md @@ -1,3 +1,5 @@ +translating---geekpi + Archiving repositories ==================== From de7fe68ba38606a86f38e82bd9f9099368756d1d Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 4 Dec 2017 09:33:40 +0800 Subject: [PATCH 177/344] translating---geekpi --- ...New Feature Find every domain someone owns automatically.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20171130 New Feature Find every domain someone owns automatically.md b/sources/tech/20171130 New Feature Find every domain someone owns automatically.md index 4b9fedf168..c3371b8376 100644 --- a/sources/tech/20171130 New Feature Find every domain someone owns automatically.md +++ b/sources/tech/20171130 New Feature Find every domain someone owns automatically.md @@ -1,3 +1,6 @@ +translating---geekpi + + New Feature: Find every domain someone owns automatically ============================================================ From f486489ac029ea1cea66b4d75fe0518c41041e63 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 4 Dec 2017 09:57:03 +0800 Subject: [PATCH 178/344] translating --- sources/tech/20171116 Introducing security alerts on GitHub.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171116 Introducing security alerts on GitHub.md b/sources/tech/20171116 Introducing security alerts on GitHub.md index 0bfef7757d..1f00b5d4aa 100644 --- a/sources/tech/20171116 Introducing security alerts on GitHub.md +++ b/sources/tech/20171116 Introducing security alerts on GitHub.md @@ -1,3 +1,5 @@ +translating---geekpi + Introducing security alerts on GitHub ==================================== From dd88a35a6df0e8ebc05947ab25b4117dd25712a8 Mon Sep 17 00:00:00 2001 From: Ezio Date: Mon, 4 Dec 2017 10:16:28 +0800 Subject: [PATCH 179/344] =?UTF-8?q?20171204-1=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Unity from the Dead as an Official Spin.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md diff --git a/sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md b/sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md new file mode 100644 index 0000000000..0e38373c3f --- /dev/null +++ b/sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md @@ -0,0 +1,41 @@ +Someone Tries to Bring Back Ubuntu's Unity from the Dead as an Official Spin +============================================================ + + + +> The Ubuntu Unity remix would be supported for nine months + +Canonical's sudden decision of killing its Unity user interface after seven years affected many Ubuntu users, and it looks like someone now tries to bring it back from the dead as an unofficial spin. + +Long-time [Ubuntu][1] member Dale Beaudoin [ran a poll][2] last week on the official Ubuntu forums to take the pulse of the community and see if they are interested in an Ubuntu Unity Remix that would be released alongside Ubuntu 18.04 LTS (Bionic Beaver) next year and be supported for nine months or five years. + +Thirty people voted in the poll, with 67 percent of them opting for an LTS (Long Term Support) release of the so-called Ubuntu Unity Remix, while 33 percent voted for the 9-month supported release. It also looks like this upcoming Ubuntu Unity Spin [looks to become an official flavor][3], yet this means commitment from those developing it. + +"A recent poll voted 2/3rds in favor of Ubuntu Unity to become an LTS distribution. We should try to work this cycle assuming that it will be LTS and an official flavor," said Dale Beaudoin. "We will try and release an updated ISO once every week or 10 days using the current 18.04 daily builds of default Ubuntu Bionic Beaver as a platform." + +### Is Ubuntu Unity making a comeback? + +The last Ubuntu version to ship with Unity by default was Ubuntu 17.04 (Zesty Zapus), which will reach end of life on January 2018\. Ubuntu 17.10 (Artful Artful), the current stable release of the popular operating system, is the first to use the GNOME desktop environment by default for the main Desktop edition as Canonical CEO [announced][4] earlier this year that Unity would no longer be developed. + +However, Canonical is still offering the Unity desktop environment from the official software repositories, so if someone wants to install it, it's one click away. But the bad news is that they'll be supported up until the release of Ubuntu 18.04 LTS (Bionic Beaver) in April 2018, so the developers of the Ubuntu Unity Remix would have to continue to keep in on life support on their a separate repository. + +On the other hand, we don't believe Canonical will change their mind and accept this Ubuntu Unity Spin to become an official flavor, which would mean they failed to continue development of Unity, and now a handful of people can do it. Most probably, if interest in this Ubuntu Unity Remix won't fade away soon, it will be an unofficial spin supported by the nostalgic community. + +Question is, would you be interested in an Ubuntu Unity spin, official or not? + +-------------------------------------------------------------------------------- + +via: http://news.softpedia.com/news/someone-tries-to-bring-back-ubuntu-s-unity-from-the-dead-as-an-unofficial-spin-518778.shtml + +作者:[Marius Nestor ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://news.softpedia.com/editors/browse/marius-nestor +[1]:http://linux.softpedia.com/downloadTag/Ubuntu +[2]:https://community.ubuntu.com/t/poll-unity-7-distro-9-month-spin-or-lts-for-18-04/2066 +[3]:https://community.ubuntu.com/t/unity-maintenance-roadmap/2223 +[4]:http://news.softpedia.com/news/canonical-to-stop-developing-unity-8-ubuntu-18-04-lts-ships-with-gnome-desktop-514604.shtml +[5]:http://news.softpedia.com/editors/browse/marius-nestor From c1a07ebaba40e6ef32d69af2f201a6b6b2cf0151 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 4 Dec 2017 10:20:20 +0800 Subject: [PATCH 180/344] translating --- sources/tech/20171201 Linux Journal Ceases Publication.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171201 Linux Journal Ceases Publication.md b/sources/tech/20171201 Linux Journal Ceases Publication.md index 0bb9b3a77b..8963b183fe 100644 --- a/sources/tech/20171201 Linux Journal Ceases Publication.md +++ b/sources/tech/20171201 Linux Journal Ceases Publication.md @@ -1,3 +1,5 @@ +translating---geekpi + Linux Journal Ceases Publication ============================================================ From c3a2917ebb2e84e06f1c307c4b543ef67b59932e Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 4 Dec 2017 10:30:26 +0800 Subject: [PATCH 181/344] translated --- .../20170910 Cool vim feature sessions.md | 93 ++++++++++--------- 1 file changed, 47 insertions(+), 46 deletions(-) rename {sources => translated}/tech/20170910 Cool vim feature sessions.md (60%) diff --git a/sources/tech/20170910 Cool vim feature sessions.md b/translated/tech/20170910 Cool vim feature sessions.md similarity index 60% rename from sources/tech/20170910 Cool vim feature sessions.md rename to translated/tech/20170910 Cool vim feature sessions.md index ed101c429c..462d6362b2 100644 --- a/sources/tech/20170910 Cool vim feature sessions.md +++ b/translated/tech/20170910 Cool vim feature sessions.md @@ -1,46 +1,47 @@ -translating---geekpi - -Cool vim feature: sessions! -============================================================• - -Yesterday I learned about an awesome vim feature while working on my [vimrc][5]! (to add fzf & ripgrep search plugins mainly). It’s a builtin feature, no fancy plugins needed. - -So I drew a comic about it. - -Basically you can save all your open files and current state with - -``` -:mksession ~/.vim/sessions/foo.vim - -``` - -and then later restore it with either `:source ~/.vim/sessions/foo.vim` or `vim -S ~/.vim/sessions/foo.vim`. Super cool! - -Some vim plugins that add extra features to vim sessions: - -* [https://github.com/tpope/vim-obsession][1] - -* [https://github.com/mhinz/vim-startify][2] - -* [https://github.com/xolox/vim-session][3] - -Here’s the comic: - -![](https://jvns.ca/images/vimsessions.png) - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/2017/09/10/vim-sessions/ - -作者:[Julia Evans ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://jvns.ca/about -[1]:https://github.com/tpope/vim-obsession -[2]:https://github.com/mhinz/vim-startify -[3]:https://github.com/xolox/vim-session -[4]:https://jvns.ca/categories/vim -[5]:https://github.com/jvns/vimconfig/blob/master/vimrc +translating---geekpi + +Cool vim feature: sessions! +vim 的酷功能:会话! +============================================================• + +昨天我在编写我的[vimrc][5]的时候了解到一个很酷的 vim 功能!(主要为了添加 fzf 和 ripgrep 插件)。这是一个内置功能,不需要特别的插件。 + +所以我画了一个漫画。 + +基本上你可以用下面的命令保存所有你打开的文件和当前的状态 + +``` +:mksession ~/.vim/sessions/foo.vim + +``` + +接着用 `:source ~/.vim/sessions/foo.vim` 或者  `vim -S ~/.vim/sessions/foo.vim` 还原会话。非常酷! + +一些 vim 插件给 vim 会话添加了额外的功能: + +* [https://github.com/tpope/vim-obsession][1] + +* [https://github.com/mhinz/vim-startify][2] + +* [https://github.com/xolox/vim-session][3] + +这是漫画: + +![](https://jvns.ca/images/vimsessions.png) + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/09/10/vim-sessions/ + +作者:[Julia Evans ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/about +[1]:https://github.com/tpope/vim-obsession +[2]:https://github.com/mhinz/vim-startify +[3]:https://github.com/xolox/vim-session +[4]:https://jvns.ca/categories/vim +[5]:https://github.com/jvns/vimconfig/blob/master/vimrc From 2e5cee7d444f106081e2d3fc8f3fd7b6de265bc1 Mon Sep 17 00:00:00 2001 From: Ezio Date: Mon, 4 Dec 2017 10:31:45 +0800 Subject: [PATCH 182/344] =?UTF-8?q?20171204-2=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/tech/20171112 Love Your Bugs.md | 311 ++++++++++++++++++++++++ 1 file changed, 311 insertions(+) create mode 100644 sources/tech/20171112 Love Your Bugs.md diff --git a/sources/tech/20171112 Love Your Bugs.md b/sources/tech/20171112 Love Your Bugs.md new file mode 100644 index 0000000000..bf79f27cf7 --- /dev/null +++ b/sources/tech/20171112 Love Your Bugs.md @@ -0,0 +1,311 @@ +Love Your Bugs +============================================================ + +In early October I gave a keynote at [Python Brasil][1] in Belo Horizonte. Here is an aspirational and lightly edited transcript of the talk. There is also a video available [here][2]. + +### I love bugs + +I’m currently a senior engineer at [Pilot.com][3], working on automating bookkeeping for startups. Before that, I worked for [Dropbox][4] on the desktop client team, and I’ll have a few stories about my work there. Earlier, I was a facilitator at the [Recurse Center][5], a writers retreat for programmers in NYC. I studied astrophysics in college and worked in finance for a few years before becoming an engineer. + +But none of that is really important to remember – the only thing you need to know about me is that I love bugs. I love bugs because they’re entertaining. They’re dramatic. The investigation of a great bug can be full of twists and turns. A great bug is like a good joke or a riddle – you’re expecting one outcome, but the result veers off in another direction. + +Over the course of this talk I’m going to tell you about some bugs that I have loved, explain why I love bugs so much, and then convince you that you should love bugs too. + +### Bug #1 + +Ok, straight into bug #1\. This is a bug that I encountered while working at Dropbox. As you may know, Dropbox is a utility that syncs your files from one computer to the cloud and to your other computers. + + + +``` + +--------------+ +---------------+ + | | | | + | METASERVER | | BLOCKSERVER | + | | | | + +-+--+---------+ +---------+-----+ + ^ | ^ + | | | + | | +----------+ | + | +---> | | | + | | CLIENT +--------+ + +--------+ | + +----------+ +``` + + +Here’s a vastly simplified diagram of Dropbox’s architecture. The desktop client runs on your local computer listening for changes in the file system. When it notices a changed file, it reads the file, then hashes the contents in 4MB blocks. These blocks are stored in the backend in a giant key-value store that we call blockserver. The key is the digest of the hashed contents, and the values are the contents themselves. + +Of course, we want to avoid uploading the same block multiple times. You can imagine that if you’re writing a document, you’re probably mostly changing the end – we don’t want to upload the beginning over and over. So before uploading a block to the blockserver the client talks to a different server that’s responsible for managing metadata and permissions, among other things. The client asks metaserver whether it needs the block or has seen it before. The “metaserver” responds with whether or not each block needs to be uploaded. + +So the request and response look roughly like this: The client says, “I have a changed file made up of blocks with hashes `'abcd,deef,efgh'`”. The server responds, “I have those first two, but upload the third.” Then the client sends the block up to the blockserver. + + +``` + +--------------+ +---------------+ + | | | | + | METASERVER | | BLOCKSERVER | + | | | | + +-+--+---------+ +---------+-----+ + ^ | ^ + | | 'ok, ok, need' | +'abcd,deef,efgh' | | +----------+ | efgh: [contents] + | +---> | | | + | | CLIENT +--------+ + +--------+ | + +----------+ +``` + + + +That’s the setup. So here’s the bug. + + + +``` + +--------------+ + | | + | METASERVER | + | | + +-+--+---------+ + ^ | + | | '???' +'abcdldeef,efgh' | | +----------+ + ^ | +---> | | + ^ | | CLIENT + + +--------+ | + +----------+ +``` + +Sometimes the client would make a weird request: each hash value should have been sixteen characters long, but instead it was thirty-three characters long – twice as many plus one. The server wouldn’t know what to do with this and would throw an exception. We’d see this exception get reported, and we’d go look at the log files from the desktop client, and really weird stuff would be going on – the client’s local database had gotten corrupted, or python would be throwing MemoryErrors, and none of it would make sense. + +If you’ve never seen this problem before, it’s totally mystifying. But once you’d seen it once, you can recognize it every time thereafter. Here’s a hint: the middle character of each 33-character string that we’d often see instead of a comma was `l`. These are the other characters we’d see in the middle position: + + +``` +l \x0c < $ ( . - +``` + +The ordinal value for an ascii comma – `,` – is 44\. The ordinal value for `l` is 108\. In binary, here’s how those two are represented: + +``` +bin(ord(',')): 0101100 +bin(ord('l')): 1101100 +``` + +You’ll notice that an `l` is exactly one bit away from a comma. And herein lies your problem: a bitflip. One bit of memory that the desktop client is using has gotten corrupted, and now the desktop client is sending a request to the server that is garbage. + +And here are the other characters we’d frequently see instead of the comma when a different bit had been flipped. + + + +``` +, : 0101100 +l : 1101100 +\x0c : 0001100 +< : 0111100 +$ : 0100100 +( : 0101000 +. : 0101110 +- : 0101101 +``` + + +### Bitflips are real! + +I love this bug because it shows that bitflips are a real thing that can happen, not just a theoretical concern. In fact, there are some domains where they’re more common than others. One such domain is if you’re getting requests from users with low-end or old hardware, which is true for a lot of laptops running Dropbox. Another domain with lots of bitflips is outer space – there’s no atmosphere in space to protect your memory from energetic particles and radiation, so bitflips are pretty common. + +You probably really care about correctness in space – your code might be keeping astronauts alive on the ISS, for example, but even if it’s not mission-critical, it’s hard to do software updates to space. If you really need your application to defend against bitflips, there are a variety of hardware & software approaches you can take, and there’s a [very interesting talk][6] by Katie Betchold about this. + +Dropbox in this context doesn’t really need to protect against bitflips. The machine that is corrupting memory is a user’s machine, so we can detect if the bitflip happens to fall in the comma – but if it’s in a different character we don’t necessarily know it, and if the bitflip is in the actual file data read off of disk, then we have no idea. There’s a pretty limited set of places where we could address this, and instead we decide to basically silence the exception and move on. Often this kind of bug resolves after the client restarts. + +### Unlikely bugs aren’t impossible + +This is one of my favorite bugs for a couple of reasons. The first is that it’s a reminder of the difference between unlikely and impossible. At sufficient scale, unlikely events start to happen at a noticable rate. + +### Social bugs + +My second favorite thing about this bug is that it’s a tremendously social one. This bug can crop up anywhere that the desktop client talks to the server, which is a lot of different endpoints and components in the system. This meant that a lot of different engineers at Dropbox would see versions of the bug. The first time you see it, you can  _really_  scratch your head, but after that it’s easy to diagnose, and the investigation is really quick: you look at the middle character and see if it’s an `l`. + +### Cultural differences + +One interesting side-effect of this bug was that it exposed a cultural difference between the server and client teams. Occasionally this bug would be spotted by a member of the server team and investigated from there. If one of your  _servers_  is flipping bits, that’s probably not random chance – it’s probably memory corruption, and you need to find the affected machine and get it out of the pool as fast as possible or you risk corrupting a lot of user data. That’s an incident, and you need to respond quickly. But if the user’s machine is corrupting data, there’s not a lot you can do. + +### Share your bugs + +So if you’re investigating a confusing bug, especially one in a big system, don’t forget to talk to people about it. Maybe your colleagues have seen a bug shaped like this one before. If they have, you might save a lot of time. And if they haven’t, don’t forget to tell people about the solution once you’ve figured it out – write it up or tell the story in your team meeting. Then the next time your teams hits something similar, you’ll all be more prepared. + +### How bugs can help you learn + +### Recurse Center + +Before I joined Dropbox, I worked for the Recurse Center. The idea behind RC is that it’s a community of self-directed learners spending time together getting better as programmers. That is the full extent of the structure of RC: there’s no curriculum or assignments or deadlines. The only scoping is a shared goal of getting better as a programmer. We’d see people come to participate in the program who had gotten CS degrees but didn’t feel like they had a solid handle on practical programming, or people who had been writing Java for ten years and wanted to learn Clojure or Haskell, and many other profiles as well. + +My job there was as a facilitator, helping people make the most of the lack of structure and providing guidance based on what we’d learned from earlier participants. So my colleagues and I were very interested in the best techniques for learning for self-motivated adults. + +### Deliberate Practice + +There’s a lot of different research in this space, and one of the ones I think is most interesting is the idea of deliberate practice. Deliberate practice is an attempt to explain the difference in performance between experts & amateurs. And the guiding principle here is that if you look just at innate characteristics – genetic or otherwise – they don’t go very far towards explaining the difference in performance. So the researchers, originally Ericsson, Krampe, and Tesch-Romer, set out to discover what did explain the difference. And what they settled on was time spent in deliberate practice. + +Deliberate practice is pretty narrow in their definition: it’s not work for pay, and it’s not playing for fun. You have to be operating on the edge of your ability, doing a project appropriate for your skill level (not so easy that you don’t learn anything and not so hard that you don’t make any progress). You also have to get immediate feedback on whether or not you’ve done the thing correctly. + +This is really exciting, because it’s a framework for how to build expertise. But the challenge is that as programmers this is really hard advice to apply. It’s hard to know whether you’re operating at the edge of your ability. Immediate corrective feedback is very rare – in some cases you’re lucky to get feedback ever, and in other cases maybe it takes months. You can get quick feedback on small things in the REPL and so on, but if you’re making a design decision or picking a technology, you’re not going to get feedback on those things for quite a long time. + +But one category of programming where deliberate practice is a useful model is debugging. If you wrote code, then you had a mental model of how it worked when you wrote it. But your code has a bug, so your mental model isn’t quite right. By definition you’re on the boundary of your understanding – so, great! You’re about to learn something new. And if you can reproduce the bug, that’s a rare case where you can get immediate feedback on whether or not your fix is correct. + +A bug like this might teach you something small about your program, or you might learn something larger about the system your code is running in. Now I’ve got a story for you about a bug like that. + +### Bug #2 + +This bug also one that I encountered at Dropbox. At the time, I was investigating why some desktop client weren’t sending logs as consistently as we expected. I’d started digging into the client logging system and discovered a bunch of interesting bugs. I’ll tell you only the subset of those bugs that is relevant to this story. + +Again here’s a very simplified architecture of the system. + + +``` + +--------------+ + | | + +---+ +----------> | LOG SERVER | + |log| | | | + +---+ | +------+-------+ + | | + +-----+----+ | 200 ok + | | | + | CLIENT | <-----------+ + | | + +-----+----+ + ^ + +--------+--------+--------+ + | ^ ^ | + +--+--+ +--+--+ +--+--+ +--+--+ + | log | | log | | log | | log | + | | | | | | | | + | | | | | | | | + +-----+ +-----+ +-----+ +-----+ +``` + +The desktop client would generate logs. Those logs were compress, encrypted, and written to disk. Then every so often the client would send them up to the server. The client would read a log off of disk and send it to the log server. The server would decrypt it and store it, then respond with a 200. + +If the client couldn’t reach the log server, it wouldn’t let the log directory grow unbounded. After a certain point it would start deleting logs to keep the directory under a maximum size. + +The first two bugs were not a big deal on their own. The first one was that the desktop client sent logs up to the server starting with the oldest one instead of starting with the newest. This isn’t really what you want – for example, the server would tell the client to send logs if the client reported an exception, so probably you care about the logs that just happened and not the oldest logs that happen to be on disk. + +The second bug was similar to the first: if the log directory hit its maximum size, the client would delete the logs starting with the newest instead of starting with the oldest. Again, you lose log files either way, but you probably care less about the older ones. + +The third bug had to do with the encryption. Sometimes, the server would be unable to decrypt a log file. (We generally didn’t figure out why – maybe it was a bitflip.) We weren’t handling this error correctly on the backend, so the server would reply with a 500\. The client would behave reasonably in the face of a 500: it would assume that the server was down. So it would stop sending log files and not try to send up any of the others. + +Returning a 500 on a corrupted log file is clearly not the right behavior. You could consider returning a 400, since it’s a problem with the client request. But the client also can’t fix the problem – if the log file can’t be decrypted now, we’ll never be able to decrypt it in the future. What you really want the client to do is just delete the log and move on. In fact, that’s the default behavior when the client gets a 200 back from the server for a log file that was successfully stored. So we said, ok – if the log file can’t be decrypted, just return a 200. + +All of these bugs were straightforward to fix. The first two bugs were on the client, so we’d fixed them on the alpha build but they hadn’t gone out to the majority of clients. The third bug we fixed on the server and deployed. + +### 📈 + +Suddenly traffic to the log cluster spikes. The serving team reaches out to us to ask if we know what’s going on. It takes me a minute to put all the pieces together. + +Before these fixes, there were four things going on: + +1. Log files were sent up starting with the oldest + +2. Log files were deleted starting with the newest + +3. If the server couldn’t decrypt a log file it would 500 + +4. If the client got a 500 it would stop sending logs + +A client with a corrupted log file would try to send it, the server would 500, the client would give up sending logs. On its next run, it would try to send the same file again, fail again, and give up again. Eventually the log directory would get full, at which point the client would start deleting its newest files, leaving the corrupted one on disk. + +The upshot of these three bugs: if a client ever had a corrupted log file, we would never see logs from that client again. + +The problem is that there were a lot more clients in this state than we thought. Any client with a single corrupted file had been dammed up from sending logs to the server. Now that dam was cleared, and all of them were sending up the rest of the contents of their log directories. + +### Our options + +Ok, there’s a huge flood of traffic coming from machines around the world. What can we do? (This is a fun thing about working at a company with Dropbox’s scale, and particularly Dropbox’s scale of desktop clients: you can trigger a self-DDOS very easily.) + +The first option when you do a deploy and things start going sideways is to rollback. Totally reasonable choice, but in this case, it wouldn’t have helped us. The state that we’d transformed wasn’t the state on the server but the state on the client – we’d deleted those files. Rolling back the server would prevent additional clients from entering this state but it wouldn’t solve the problem. + +What about increasing the size of the logging cluster? We did that – and started getting even more requests, now that we’d increased our capacity. We increased it again, but you can’t do that forever. Why not? This cluster isn’t isolated. It’s making requests into another cluster, in this case to handle exceptions. If you have a DDOS pointed at one cluster, and you keep scaling that cluster, you’re going to knock over its depedencies too, and now you have two problems. + +Another option we considered was shedding load – you don’t need every single log file, so can we just drop requests. One of the challenges here was that we didn’t have an easy way to tell good traffic from bad. We couldn’t quickly differentiate which log files were old and which were new. + +The solution we hit on is one that’s been used at Dropbox on a number of different occassions: we have a custom header, `chillout`, which every client in the world respects. If the client gets a response with this header, then it doesn’t make any requests for the provided number of seconds. Someone very wise added this to the Dropbox client very early on, and it’s come in handy more than once over the years. The logging server didn’t have the ability to set that header, but that’s an easy problem to solve. So two of my colleagues, Isaac Goldberg and John Lai, implemented support for it. We set the logging cluster chillout to two minutes initially and then managed it down as the deluge subsided over the next couple of days. + +### Know your system + +The first lesson from this bug is to know your system. I had a good mental model of the interaction between the client and the server, but I wasn’t thinking about what would happen when the server was interacting with all the clients at once. There was a level of complexity that I hadn’t thought all the way through. + +### Know your tools + +The second lesson is to know your tools. If things go sideways, what options do you have? Can you reverse your migration? How will you know if things are going sideways and how can you discover more? All of those things are great to know before a crisis – but if you don’t, you’ll learn them during a crisis and then never forget. + +### Feature flags & server-side gating + +The third lesson is for you if you’re writing a mobile or a desktop application:  _You need server-side feature gating and server-side flags._  When you discover a problem and you don’t have server-side controls, the resolution might take days or weeks as you push out a new release or submit a new version to the app store. That’s a bad situation to be in. The Dropbox desktop client isn’t going through an app store review process, but just pushing out a build to tens of millions of clients takes time. Compare that to hitting a problem in your feature and flipping a switch on the server: ten minutes later your problem is resolved. + +This strategy is not without its costs. Having a bunch of feature flags in your code adds to the complexity dramatically. You get a combinatoric problem with your testing: what if feature A is enabled and feature B, or just one, or neither – multiplied across N features. It’s extremely difficult to get engineers to clean up their feature flags after the fact (and I was also guilty of this). Then for the desktop client there’s multiple versions in the wild at the same time, so it gets pretty hard to reason about. + +But the benefit – man, when you need it, you really need it. + +# How to love bugs + +I’ve talked about some bugs that I love and I’ve talked about why to love bugs. Now I want to tell you how to love bugs. If you don’t love bugs yet, I know of exactly one way to learn, and that’s to have a growth mindset. + +The sociologist Carol Dweck has done a ton of interesting research about how people think about intelligence. She’s found that there are two different frameworks for thinking about intelligence. The first, which she calls the fixed mindset, holds that intelligence is a fixed trait, and people can’t change how much of it they have. The other mindset is a growth mindset. Under a growth mindset, people believe that intelligence is malleable and can increase with effort. + +Dweck found that a person’s theory of intelligence – whether they hold a fixed or growth mindset – can significantly influence the way they select tasks to work on, the way they respond to challenges, their cognitive performance, and even their honesty. + +[I also talked about a growth mindset in my Kiwi PyCon keynote, so here are just a few excerpts. You can read the full transcript [here][7].] + +Findings about honesty: + +> After this, they had the students write letters to pen pals about the study, saying “We did this study at school, and here’s the score that I got.” They found that  _almost half of the students praised for intelligence lied about their scores_ , and almost no one who was praised for working hard was dishonest. + +On effort: + +> Several studies found that people with a fixed mindset can be reluctant to really exert effort, because they believe it means they’re not good at the thing they’re working hard on. Dweck notes, “It would be hard to maintain confidence in your ability if every time a task requires effort, your intelligence is called into question.” + +On responding to confusion: + +> They found that students with a growth mindset mastered the material about 70% of the time, regardless of whether there was a confusing passage in it. Among students with a fixed mindset, if they read the booklet without the confusing passage, again about 70% of them mastered the material. But the fixed-mindset students who encountered the confusing passage saw their mastery drop to 30%. Students with a fixed mindset were pretty bad at recovering from being confused. + +These findings show that a growth mindset is critical while debugging. We have to recover from confusion, be candid about the limitations of our understanding, and at times really struggle on the way to finding solutions – all of which is easier and less painful with a growth mindset. + +### Love your bugs + +I learned to love bugs by explicitly celebrating challenges while working at the Recurse Center. A participant would sit down next to me and say, “[sigh] I think I’ve got a weird Python bug,” and I’d say, “Awesome, I  _love_  weird Python bugs!” First of all, this is definitely true, but more importantly, it emphasized to the participant that finding something where they struggled an accomplishment, and it was a good thing for them to have done that day. + +As I mentioned, at the Recurse Center there are no deadlines and no assignments, so this attitude is pretty much free. I’d say, “You get to spend a day chasing down this weird bug in Flask, how exciting!” At Dropbox and later at Pilot, where we have a product to ship, deadlines, and users, I’m not always uniformly delighted about spending a day on a weird bug. So I’m sympathetic to the reality of the world where there are deadlines. However, if I have a bug to fix, I have to fix it, and being grumbly about the existence of the bug isn’t going to help me fix it faster. I think that even in a world where deadlines loom, you can still apply this attitude. + +If you love your bugs, you can have more fun while you’re working on a tough problem. You can be less worried and more focused, and end up learning more from them. Finally, you can share a bug with your friends and colleagues, which helps you and your teammates. + +### Obrigada! + +My thanks to folks who gave me feedback on this talk and otherwise contributed to my being there: + +* Sasha Laundy + +* Amy Hanlon + +* Julia Evans + +* Julian Cooper + +* Raphael Passini Diniz and the rest of the Python Brasil organizing team + +-------------------------------------------------------------------------------- + +via: http://akaptur.com/blog/2017/11/12/love-your-bugs/ + +作者:[Allison Kaptur ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://akaptur.com/about/ +[1]:http://2017.pythonbrasil.org.br/# +[2]:http://www.youtube.com/watch?v=h4pZZOmv4Qs +[3]:http://www.pilot.com/ +[4]:http://www.dropbox.com/ +[5]:http://www.recurse.com/ +[6]:http://www.youtube.com/watch?v=ETgNLF_XpEM +[7]:http://akaptur.com/blog/2015/10/10/effective-learning-strategies-for-programmers/ From 83af56b418159200225093801e6e1a72dff8fe76 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 4 Dec 2017 10:31:46 +0800 Subject: [PATCH 183/344] Update 20170910 Cool vim feature sessions.md --- translated/tech/20170910 Cool vim feature sessions.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/translated/tech/20170910 Cool vim feature sessions.md b/translated/tech/20170910 Cool vim feature sessions.md index 462d6362b2..49ee43fda1 100644 --- a/translated/tech/20170910 Cool vim feature sessions.md +++ b/translated/tech/20170910 Cool vim feature sessions.md @@ -1,6 +1,3 @@ -translating---geekpi - -Cool vim feature: sessions! vim 的酷功能:会话! ============================================================• From f2f4b856e7c4d37846ad373a2cb0b031191f648d Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 4 Dec 2017 10:32:41 +0800 Subject: [PATCH 184/344] translated --- .../tech/20171108 Archiving repositories.md | 39 ------------------- .../tech/20171108 Archiving repositories.md | 37 ++++++++++++++++++ 2 files changed, 37 insertions(+), 39 deletions(-) delete mode 100644 sources/tech/20171108 Archiving repositories.md create mode 100644 translated/tech/20171108 Archiving repositories.md diff --git a/sources/tech/20171108 Archiving repositories.md b/sources/tech/20171108 Archiving repositories.md deleted file mode 100644 index 4038ca8a9f..0000000000 --- a/sources/tech/20171108 Archiving repositories.md +++ /dev/null @@ -1,39 +0,0 @@ -translating---geekpi - -Archiving repositories -==================== - - -Just because a repository isn't actively developed anymore and you don't want to accept additional contributions doesn't mean you want to delete it. Now archive repositories on GitHub to make them read-only. - - [![archived repository banner](https://user-images.githubusercontent.com/7321362/32558403-450458dc-c46a-11e7-96f9-af31d2206acb.png)][1] - -Archiving a repository makes it read-only to everyone (including repository owners). This includes editing the repository, issues, pull requests, labels, milestones, projects, wiki, releases, commits, tags, branches, reactions and comments. No one can create new issues, pull requests, or comments on an archived repository, but you can still fork archived repositories—allowing development to continue elsewhere for archived open source projects. - -To archive a repository, go to your Repository Settings Page and click Archive this repository. - - [![archive repository button](https://user-images.githubusercontent.com/125011/32273119-0fc5571e-bef9-11e7-9909-d137268a1d6d.png)][2] - -Before archiving your repository, make sure you've changed its settings and consider closing all open issues and pull requests. You should also update your README and description to make it clear to visitors that it's no longer possible to contribute. - -If you change your mind and want to unarchive your repository, click Unarchive this repositoryin the same place. Please note that most archived repository settings are hidden and you'll have to unarchive the repository to change them. - - [![archived labelled repository](https://user-images.githubusercontent.com/125011/32541128-9d67a064-c466-11e7-857e-3834054ba3c9.png)][3] - -To learn more, check out [the documentation][4] on archiving repositories. Happy archiving! - --------------------------------------------------------------------------------- - -via: https://github.com/blog/2460-archiving-repositories - -作者:[MikeMcQuaid ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://github.com/MikeMcQuaid -[1]:https://user-images.githubusercontent.com/7321362/32558403-450458dc-c46a-11e7-96f9-af31d2206acb.png -[2]:https://user-images.githubusercontent.com/125011/32273119-0fc5571e-bef9-11e7-9909-d137268a1d6d.png -[3]:https://user-images.githubusercontent.com/125011/32541128-9d67a064-c466-11e7-857e-3834054ba3c9.png -[4]:https://help.github.com/articles/about-archiving-repositories/ diff --git a/translated/tech/20171108 Archiving repositories.md b/translated/tech/20171108 Archiving repositories.md new file mode 100644 index 0000000000..3d1a328541 --- /dev/null +++ b/translated/tech/20171108 Archiving repositories.md @@ -0,0 +1,37 @@ +归档仓库 +==================== + + +因为仓库不再活跃开发或者你不想接受额外的贡献并不意味着你想要删除它。现在在 Github 上归档仓库让它变成只读。 + + [![archived repository banner](https://user-images.githubusercontent.com/7321362/32558403-450458dc-c46a-11e7-96f9-af31d2206acb.png)][1] + +归档一个仓库让它对所有人只读(包括仓库拥有者)。这包括编辑仓库、问题、合并请求、标记、里程碑、维基、发布、提交、标签、分支、反馈和评论。没有人可以在一个归档的仓库上创建新的问题、合并请求或者评论,但是你仍可以 fork 仓库-允许归档的仓库在其他地方继续开发。 + +要归档一个仓库,进入仓库设置页面并点在这个仓库上点击归档。 + + [![archive repository button](https://user-images.githubusercontent.com/125011/32273119-0fc5571e-bef9-11e7-9909-d137268a1d6d.png)][2] + +在归档你的仓库前,确保你已经更改了它的设置并考虑关闭所有的开放问题和合并请求。你还应该更新你的 README 和描述来让它让访问者了解他不再能够贡献。 + +如果你改变了主意想要解除归档你的仓库,在相同的地方点击解除归档。请注意大多数归档仓库的设置是隐藏的,并且你需要解除归档来改变它们。 + + [![archived labelled repository](https://user-images.githubusercontent.com/125011/32541128-9d67a064-c466-11e7-857e-3834054ba3c9.png)][3] + +要了解更多,请查看[这份文档][4]中的归档仓库部分。归档快乐! + +-------------------------------------------------------------------------------- + +via: https://github.com/blog/2460-archiving-repositories + +作者:[MikeMcQuaid ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://github.com/MikeMcQuaid +[1]:https://user-images.githubusercontent.com/7321362/32558403-450458dc-c46a-11e7-96f9-af31d2206acb.png +[2]:https://user-images.githubusercontent.com/125011/32273119-0fc5571e-bef9-11e7-9909-d137268a1d6d.png +[3]:https://user-images.githubusercontent.com/125011/32541128-9d67a064-c466-11e7-857e-3834054ba3c9.png +[4]:https://help.github.com/articles/about-archiving-repositories/ From a760d08600f1a53d1fb6276bffec1c998d8da2d9 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 4 Dec 2017 10:35:58 +0800 Subject: [PATCH 185/344] translated --- ...every domain someone owns automatically.md | 52 ------------------- ...every domain someone owns automatically.md | 49 +++++++++++++++++ 2 files changed, 49 insertions(+), 52 deletions(-) delete mode 100644 sources/tech/20171130 New Feature Find every domain someone owns automatically.md create mode 100644 translated/tech/20171130 New Feature Find every domain someone owns automatically.md diff --git a/sources/tech/20171130 New Feature Find every domain someone owns automatically.md b/sources/tech/20171130 New Feature Find every domain someone owns automatically.md deleted file mode 100644 index c3371b8376..0000000000 --- a/sources/tech/20171130 New Feature Find every domain someone owns automatically.md +++ /dev/null @@ -1,52 +0,0 @@ -translating---geekpi - - -New Feature: Find every domain someone owns automatically -============================================================ - - -Today, we are excited to announce our latest feature which we have been working on for the past weeks. It is the Whois aggregation tool that is now available on [DNSTrails][1]. - -In the past, searching for domain owners took lot of time, because most of the time you needed to have the domain names pointed to an IP address in order to find the rest of the domains owned by the same person. - -Using that old method you could easily lose hours and hours each day by researching and crossing results and data between one tool and another until you got the domain list you wanted. - -Thanks to this new tool and our intelligent [WHOIS database][2], now you can search for any domain name and get the full list of domains registered by that organization or person and get accurate results within seconds. - -### How can I use the Whois aggregation feature? - -Step 1: Open up [DNSTrails.com][3] - -Step 2: Search for any domain name, for example: godaddy.com - -Step 3: After you get the results for the domain name, locate the Whois information block as you see below: - -![Domain name search results](https://securitytrails.com/images/a/a/1/3/f/aa13fa3616b8dc313f925bdbf1da43a54856d463-image1.png) - -Step 4: You will notice there is a phone number and email address associated with the domain name. - -Step 5: Click on the links at the right, you will easily find the rest of the domain names registered with the same telephone and email address. - -![All domain names by the same owner](https://securitytrails.com/images/1/3/4/0/3/134037822d23db4907d421046b11f3cbb872f94f-image2.png) - -This means, that even if the domains doesn't even have IPs pointed at the registrar, we can still discover the rest of the domains if they use the same phone and mail address, pretty useful if you are investigating domain ownership from any individual on the Internet. - -Ever wanted to know which other domains are owned by a person? Try the [WHOIS aggregation feature][4] at [DNStrails][5] yourself or [get in touch with us for API access][6]. - --------------------------------------------------------------------------------- - -via: https://securitytrails.com/blog/find-every-domain-someone-owns - -作者:[SECURITYTRAILS TEAM ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://securitytrails.com/blog/find-every-domain-someone-owns -[1]:https://dnstrails.com/ -[2]:https://securitytrails.com/forensics -[3]:https://dnstrails.com/ -[4]:http://dnstrails.com/#/domain/domain/ueland.com -[5]:https://dnstrails.com/ -[6]:https://securitytrails.com/contact diff --git a/translated/tech/20171130 New Feature Find every domain someone owns automatically.md b/translated/tech/20171130 New Feature Find every domain someone owns automatically.md new file mode 100644 index 0000000000..4b72eaae5e --- /dev/null +++ b/translated/tech/20171130 New Feature Find every domain someone owns automatically.md @@ -0,0 +1,49 @@ +新功能:自动找出每个域名的拥有者 +============================================================ + + +今天,我们很高兴地宣布我们最近几周做的新功能。它是 Whois 聚合工具,现在可以在 [DNSTrails][1] 上获得。 + +在过去,查找一个域名的所有者会花费很多时间,因为大部分时间你都需要把域名指向一个 IP 地址,以便找到同一个人拥有的其他域名。 + +使用老的方法,你会很轻易地在一个工具和另外一个工具的研究和交叉比较结果中花费数个小时,直到得到你想要的域名。 + +感谢这个新工具和我们的智能[WHOIS 数据库][2],现在你可以搜索任何域名,并获得组织或个人注册的域名的完整列表,并在几秒钟内获得准确的结果。 + +### 我如何使用Whois聚合功能? + +第一步:打开 [DNSTrails.com][3] + +第二步:搜索任何域名,比如:godaddy.com + +第三步:在得到域名的结果后,如下所见,定位下面的 Whois 信息: + +![Domain name search results](https://securitytrails.com/images/a/a/1/3/f/aa13fa3616b8dc313f925bdbf1da43a54856d463-image1.png) + +第四步:你会看到那里有有关域名的电话和电子邮箱地址。 + +第五步:点击右边的链接,你会轻松地找到用相同电话和邮箱注册的域名。 + +![All domain names by the same owner](https://securitytrails.com/images/1/3/4/0/3/134037822d23db4907d421046b11f3cbb872f94f-image2.png) + +如果你正在调查互联网上任何个人的域名所有权,这意味着即使域名甚至没有指向注册服务商的 IP,如果他们使用相同的电话和邮件地址,我们仍然可以发现其他域名。 + +想知道一个人拥有的其他域名么?亲自试试 [DNStrails][5] 的[ WHOIS 聚合功能][4]或者[使用我们的 API 访问][6]。 + +-------------------------------------------------------------------------------- + +via: https://securitytrails.com/blog/find-every-domain-someone-owns + +作者:[SECURITYTRAILS TEAM ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://securitytrails.com/blog/find-every-domain-someone-owns +[1]:https://dnstrails.com/ +[2]:https://securitytrails.com/forensics +[3]:https://dnstrails.com/ +[4]:http://dnstrails.com/#/domain/domain/ueland.com +[5]:https://dnstrails.com/ +[6]:https://securitytrails.com/contact From 664bae984d13431859ad40f3daf4e3355d8105b0 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 4 Dec 2017 10:38:27 +0800 Subject: [PATCH 186/344] translated --- ...6 Introducing security alerts on GitHub.md | 50 ------------------- ...6 Introducing security alerts on GitHub.md | 48 ++++++++++++++++++ 2 files changed, 48 insertions(+), 50 deletions(-) delete mode 100644 sources/tech/20171116 Introducing security alerts on GitHub.md create mode 100644 translated/tech/20171116 Introducing security alerts on GitHub.md diff --git a/sources/tech/20171116 Introducing security alerts on GitHub.md b/sources/tech/20171116 Introducing security alerts on GitHub.md deleted file mode 100644 index 1f00b5d4aa..0000000000 --- a/sources/tech/20171116 Introducing security alerts on GitHub.md +++ /dev/null @@ -1,50 +0,0 @@ -translating---geekpi - -Introducing security alerts on GitHub -==================================== - - -Last month, we made it easier for you to keep track of the projects your code depends on with the dependency graph, currently supported in Javascript and Ruby. Today, for the over 75 percent of GitHub projects that have dependencies, we’re helping you do more than see those important projects. With your dependency graph enabled, we’ll now notify you when we detect a vulnerability in one of your dependencies and suggest known fixes from the GitHub community. - - [![Security Alerts & Suggested Fix](https://user-images.githubusercontent.com/594029/32851987-76c36e4a-c9eb-11e7-98fc-feb39fddaadb.gif)][1] - -### How to start using security alerts - -Whether your projects are private or public, security alerts get vital vulnerability information to the right people on your team. - -Enable your dependency graph - -Public repositories will automatically have your dependency graph and security alerts enabled. For private repositories, you’ll need to opt in to security alerts in your repository settings or by allowing access in the Dependency graph section of your repository’s Insights tab. - -Set notification preferences - -When your dependency graph is enabled, admins will receive security alerts by default. Admins can also add teams or individuals as recipients for security alerts in the dependency graph settings. - -Respond to alerts - -When we notify you about a potential vulnerability, we’ll highlight any dependencies that we recommend updating. If a known safe version exists, we’ll select one using machine learning and publicly available data, and include it in our suggestion. - -### Vulnerability coverage - -Vulnerabilities that have [CVE IDs][2] (publicly disclosed vulnerabilities from the [National Vulnerability Database][3]) will be included in security alerts. However, not all vulnerabilities have CVE IDs—even many publicly disclosed vulnerabilities don't have them. We'll continue to get better at identifying vulnerabilities as our security data grows. For more help managing security issues, check out our [security partners in the GitHub Marketplace][4]. - -This is the next step in using the world’s largest collection of open source data to help you keep code safer and do your best work. The dependency graph and security alerts currently support Javascript and Ruby—with Python support coming in 2018. - -[Learn more about security alerts][5] - --------------------------------------------------------------------------------- - -via: https://github.com/blog/2470-introducing-security-alerts-on-github - -作者:[mijuhan ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://github.com/mijuhan -[1]:https://user-images.githubusercontent.com/594029/32851987-76c36e4a-c9eb-11e7-98fc-feb39fddaadb.gif -[2]:https://cve.mitre.org/ -[3]:https://nvd.nist.gov/ -[4]:https://github.com/marketplace/category/security -[5]:https://help.github.com/articles/about-security-alerts-for-vulnerable-dependencies/ diff --git a/translated/tech/20171116 Introducing security alerts on GitHub.md b/translated/tech/20171116 Introducing security alerts on GitHub.md new file mode 100644 index 0000000000..b8f0afba17 --- /dev/null +++ b/translated/tech/20171116 Introducing security alerts on GitHub.md @@ -0,0 +1,48 @@ +介绍 GitHub 上的安全警报 +==================================== + + +上个月,我们用依赖关系图让你更容易跟踪你代码依赖的的项目,目前支持 Javascript 和 Ruby。如今,超过 75% 的 GitHub 项目有依赖,我们正在帮助你做更多的事情,而不只是关注那些重要的项目。在启用依赖关系图后,当我们检测到你的依赖中有漏洞或者来自 Github 社区中建议的已知修复时通知你。 + + [![Security Alerts & Suggested Fix](https://user-images.githubusercontent.com/594029/32851987-76c36e4a-c9eb-11e7-98fc-feb39fddaadb.gif)][1] + +### 如何开始使用安全警报 + +无论你的项目时私有还是公有的,安全警报都会为团队中的正确人员提供重要的漏洞信息。 + +启用你的依赖图 + +公开仓库将自动启用依赖关系图和安全警报。对于私人仓库,你需要在仓库设置中添加安全警报,或者在 “Insights” 选项卡中允许访问仓库的 “依赖关系图” 部分。 + +设置通知选项 + +启用依赖关系图后,管理员将默认收到安全警报。管理员还可以在依赖关系图设置中将团队或个人添加为安全警报的收件人。 + +警报响应 + +当我们通知你潜在的漏洞时,我们将突出显示我们建议更新的任何依赖关系。如果存在已知的安全版本,我们将使用机器学习和公开数据中选择一个,并将其包含在我们的建议中。 + +### 漏洞覆盖率 + +有 [CVE ID][2](公开披露的[国家漏洞数据库][3]中的漏洞)的漏洞将包含在安全警报中。但是,并非所有漏洞都有 CVE ID,甚至许多公开披露的漏洞也没有。随着安全数据的增长,我们将继续更好地识别漏洞。如需更多帮助来管理安全问题,请查看我们的[ GitHub Marketplace 中的安全合作伙伴][4]。 + +这是使用世界上最大的开源数据集的下一步,可以帮助你保持代码安全并做到最好。依赖关系图和安全警报目前支持 JavaScript 和 Ruby,并将在 2018 年提供 Python 支持。 + +[了解更多关于安全警报][5] + +-------------------------------------------------------------------------------- + +via: https://github.com/blog/2470-introducing-security-alerts-on-github + +作者:[mijuhan ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://github.com/mijuhan +[1]:https://user-images.githubusercontent.com/594029/32851987-76c36e4a-c9eb-11e7-98fc-feb39fddaadb.gif +[2]:https://cve.mitre.org/ +[3]:https://nvd.nist.gov/ +[4]:https://github.com/marketplace/category/security +[5]:https://help.github.com/articles/about-security-alerts-for-vulnerable-dependencies/ From d1357f6cbfed0ed0fb7744397f48bf90035381f9 Mon Sep 17 00:00:00 2001 From: wangy325 Date: Mon, 4 Dec 2017 10:42:33 +0800 Subject: [PATCH 187/344] wangy325 translating.. --- .../tech/20171129 10 open source technology trends for 2018.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20171129 10 open source technology trends for 2018.md b/sources/tech/20171129 10 open source technology trends for 2018.md index 1e7b137726..eb21c62ec9 100644 --- a/sources/tech/20171129 10 open source technology trends for 2018.md +++ b/sources/tech/20171129 10 open source technology trends for 2018.md @@ -1,3 +1,6 @@ +translating by wangy325... + + 10 open source technology trends for 2018 ============================================================ From f23e6c6877ba738483a16aeee1ae0150714dc29f Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 4 Dec 2017 11:28:07 +0800 Subject: [PATCH 188/344] translated --- ...171201 Linux Journal Ceases Publication.md | 36 ------------------- ...171201 Linux Journal Ceases Publication.md | 34 ++++++++++++++++++ 2 files changed, 34 insertions(+), 36 deletions(-) delete mode 100644 sources/tech/20171201 Linux Journal Ceases Publication.md create mode 100644 translated/tech/20171201 Linux Journal Ceases Publication.md diff --git a/sources/tech/20171201 Linux Journal Ceases Publication.md b/sources/tech/20171201 Linux Journal Ceases Publication.md deleted file mode 100644 index 8963b183fe..0000000000 --- a/sources/tech/20171201 Linux Journal Ceases Publication.md +++ /dev/null @@ -1,36 +0,0 @@ -translating---geekpi - -Linux Journal Ceases Publication -============================================================ - -EOF - -It looks like we’re at the end, folks. If all goes according to a plan we’d rather not have, the November issue of Linux Journal was our last. - -The simple fact is that we’ve run out of money, and options along with it. We never had a wealthy corporate parent or deep pockets of our own, and that made us an anomaly among publishers, from start to finish. While we got to be good at flying close to the ground for a long time, we lost what little elevation we had in November, when the scale finally tipped irrevocably to the negative. - -While we see a future like publishing’s past—a time when advertisers sponsor a publication because they value its brand and readers—the advertising world we have today would rather chase eyeballs, preferably by planting tracking beacons in readers' browsers and zapping them with ads anywhere those readers show up. But that future isn’t here, and the past is long gone. - -There is some hope, we suppose, that a savior might come through; but it will have to be one willing to pick up some of our debt, in addition to our brand, our archive, our domains and our subscribers and readers. If you know anyone who can make a serious offer, let us know. Otherwise, watch LinuxJournal.com and hope that at least our legacy archives (which go back to Linux Journal’s birth in April 1994, when Linux hit 1.0) won’t go away. There’s a lot of great stuff here, and a lot of history we’d hate the world to lose. - -Our biggest regret is that we don’t even have enough money to return to the people who have valued us most: our subscribers. For that we could not apologize more deeply or sincerely. What we do have for subscribers: - -Linux Pro Magazine has offered our subscribers six free issues of their magazine, a publication we at Linux Journal have always admired. In our time of need, they were the first ones there for us, and we are thankful for their gracious offer. We also just finished up our 2017 archive today, which includes every issue we’ve ever published, including the first and last ones. Normally we sell that for $25, but obviously subscribers will get it for no cost. Subscribers, watch for an e-mail with details about both. - -We also hope there is some solace in knowing that we worked very, very hard at keeping Linux Journal going, and we’ve been doing that for a long time, running the leanest, smallest possible operation we could. We are a collection mostly of volunteers, and some of our employees haven’t been paid in months. We still owe money to freelancers as well. There is a limit to how long a publisher can maintain those neglects, and that limit has now been reached. - -It has been a great run, folks. A big hats-off to everyone who contributed to our birth, our success and our persistence over these many years. We’d run the credits now, but the list would be too long, and the risk of leaving worthy people out would be too high. You know who you are. Our thanks again. - --------------------------------------------------------------------------------- - -via: https://www.linuxjournal.com/content/linux-journal-ceases-publication - -作者:[ Carlie Fairchild][a] -译者:[译者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/carlie-fairchild -[1]:https://www.linuxjournal.com/taxonomy/term/29 -[2]:https://www.linuxjournal.com/users/carlie-fairchild diff --git a/translated/tech/20171201 Linux Journal Ceases Publication.md b/translated/tech/20171201 Linux Journal Ceases Publication.md new file mode 100644 index 0000000000..2eb5c82f51 --- /dev/null +++ b/translated/tech/20171201 Linux Journal Ceases Publication.md @@ -0,0 +1,34 @@ +Linux Journal 停止发行 +============================================================ + +EOF + +伙计们,看起来我们要到终点了。如果按照计划而且没有什么其他的话,十一月份的 Linux Journal 将是我们的最后一期。 + +简单的事实是,我们已经用完了钱和期权。我们从来没有一个富有的母公司或者自己深厚的资金,从开始到结束,这使得我们变成一个反常的出版商。虽然我们在很长的一段时间内运营着,但当天平不可恢复地最终向相反方向倾斜时,我们在十一月份失去了最后一点支持。 + +虽然我们像看到出版业的过去那样看到出版业的未来 - 广告商赞助出版物的时代,因为他们重视品牌和读者 - 我们如今的广告宁愿追逐眼球,最好是在读者的浏览器中植入跟踪标记,并随时随地展示那些广告。但是,未来不是这样,过去的已经过去了。 + +我们猜想,有一个希望,那就是救世主可能会会来。但除了我们的品牌、我们的档案,我们的域名、我们的用户和读者之外,还必须是愿意承担我们一部分债务的人。如果你认识任何人能够提供认真的报价,请告诉我们。不然,请观看 LinuxJournal.com,并希望至少我们的遗留归档(可以追溯到 Linux Journal 诞生的 1994 年 4 月,当 Linux 命中 1.0 发布时)将不会消失。这里有很多很棒的东西,还有很多我们会痛恨世界失去的历史。 + +我们最大的遗憾是,我们甚至没有足够的钱回馈最看重我们的人:我们的用户。为此,我们不能更深刻或真诚地道歉。我们对订阅者而言有什么: + +Linux Pro Magazine 为我们的用户提供了六本免费的杂志,我们在 Linux Journal 上一直赞叹这点。在我们需要的时候,他们是我们的第一批人,我们感谢他们的恩惠。我们今天刚刚完成了我们的 2017 年归档,其中包括我们曾经发表过的每一个问题,包括第一个和最后一个。通常我们以 25 美元的价格出售,但显然用户将免费获得。订阅者请注意有关两者的详细信息的电子邮件。 + +我们也希望在知道我们非常非常努力地让 Linux Journal 进行下去后能有一些安慰 ,而且我们已经用最精益、小的可能运营了很长一段时间。我们是一个大多数是自愿者的组织,有些员工已经几个月没有收到工资。我们还欠钱给自由职业者。这时一个限制发行商能够维持多长时间的限制,现在这个限制已经到头了。 + +伙计们,这是一个伟大的运营。乡亲。对每一个为我们的诞生、我们的成功和我们多年的坚持作出贡献的人致敬。我们列了一份名单,但是列表太长了,并且漏掉有价值的人的风险很高。你知道你是谁。我们再次感谢。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxjournal.com/content/linux-journal-ceases-publication + +作者:[ Carlie Fairchild][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linuxjournal.com/users/carlie-fairchild +[1]:https://www.linuxjournal.com/taxonomy/term/29 +[2]:https://www.linuxjournal.com/users/carlie-fairchild From fbeff9160ff5a63622878905fd5c1fe0bcb556f5 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 4 Dec 2017 11:50:36 +0800 Subject: [PATCH 189/344] rename --- .../tech/20171010 Operating a Kubernetes network.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "sources/tech/20171010 \tOperating a Kubernetes network.md" => sources/tech/20171010 Operating a Kubernetes network.md (100%) diff --git "a/sources/tech/20171010 \tOperating a Kubernetes network.md" b/sources/tech/20171010 Operating a Kubernetes network.md similarity index 100% rename from "sources/tech/20171010 \tOperating a Kubernetes network.md" rename to sources/tech/20171010 Operating a Kubernetes network.md From 48ad01745e8d9b7ca0ef74666e42a67a94541fbb Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 4 Dec 2017 11:53:36 +0800 Subject: [PATCH 190/344] translating --- .../20171113 Glitch write fun small web projects instantly.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171113 Glitch write fun small web projects instantly.md b/sources/tech/20171113 Glitch write fun small web projects instantly.md index bfed5b9a0b..734853ce51 100644 --- a/sources/tech/20171113 Glitch write fun small web projects instantly.md +++ b/sources/tech/20171113 Glitch write fun small web projects instantly.md @@ -1,3 +1,5 @@ +translating---geekpi + Glitch: write fun small web projects instantly ============================================================ From d761333ed5c84f319c18d64950d2d5c807e24210 Mon Sep 17 00:00:00 2001 From: smartgrids Date: Mon, 4 Dec 2017 12:15:56 +0800 Subject: [PATCH 191/344] tranlated by smartgrids Signed-off-by: smartgrids --- ...ow Eclipse is advancing IoT development.md | 83 ------------------- ...ow Eclipse is advancing IoT development.md | 77 +++++++++++++++++ 2 files changed, 77 insertions(+), 83 deletions(-) delete mode 100644 sources/tech/20171020 How Eclipse is advancing IoT development.md create mode 100644 translated/tech/20171020 How Eclipse is advancing IoT development.md diff --git a/sources/tech/20171020 How Eclipse is advancing IoT development.md b/sources/tech/20171020 How Eclipse is advancing IoT development.md deleted file mode 100644 index 30fd8eb64d..0000000000 --- a/sources/tech/20171020 How Eclipse is advancing IoT development.md +++ /dev/null @@ -1,83 +0,0 @@ -apply for translating - -How Eclipse is advancing IoT development -============================================================ - -### Open source organization's modular approach to development is a good match for the Internet of Things. - -![How Eclipse is advancing IoT development](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_BUS_ArchitectureOfParticipation_520x292.png?itok=FA0Uuwzv "How Eclipse is advancing IoT development") -Image by : opensource.com - -[Eclipse][3] may not be the first open source organization that pops to mind when thinking about Internet of Things (IoT) projects. After all, the foundation has been around since 2001, long before IoT was a household word, supporting a community for commercially viable open source software development. - -September's Eclipse IoT Day, held in conjunction with RedMonk's [ThingMonk 2017][4] event, emphasized the big role Eclipse is taking in [IoT development][5]. It currently hosts 28 projects that touch a wide range of IoT needs and projects. While at the conference, I talked with [Ian Skerritt][6], who heads marketing for Eclipse, about Eclipse's IoT projects and how Eclipse thinks about IoT more broadly. - -### What's new about IoT? - -I asked Ian how IoT is different from traditional industrial automation, given that sensors and tools have been connected in factories for the past several decades. Ian notes that many factories still are not connected. - -Additionally, he says, "SCADA [supervisory control and data analysis] systems and even the factory floor technology are very proprietary, very siloed. It's hard to change it. It's hard to adapt to it… Right now, when you set up a manufacturing run, you need to manufacture hundreds of thousands of that piece, of that unit. What [manufacturers] want to do is to meet customer demand, to have manufacturing processes that are very flexible, that you can actually do a lot size of one." That's a big piece of what IoT is bringing to manufacturing. - -### Eclipse's approach to IoT - -He describes Eclipse's involvement in IoT by saying: "There's core fundamental technology that every IoT solution needs," and by using open source, "everyone can use it so they can get broader adoption." He says Eclipse see IoT as consisting of three connected software stacks. At a high level, these stacks mirror the (by now familiar) view that IoT can usually be described as spanning three layers. A given implementation may have even more layers, but they still generally map to the functions of this three-layer model: - -* A stack of software for constrained devices (e.g., the device, endpoint, microcontroller unit (MCU), sensor hardware). - -* Some type of gateway that aggregates information and data from the different sensors and sends it to the network. This layer also may take real-time actions based on what the sensors are observing. - -* A software stack for the IoT platform on the backend. This backend cloud stores the data and can provide services based on collected data, such as analysis of historical trends and predictive analytics. - -The three stacks are described in greater detail in Eclipse's whitepaper "[The Three Software Stacks Required for IoT Architectures][7]." - -Ian says that, when developing a solution within those architectures, "there's very specific things that need to be built, but there's a lot of underlying technology that can be used, like messaging protocols, like gateway services. It needs to be a modular approach to scale up to the different use cases that are up there." This encapsulates Eclipse's activities around IoT: Developing modular open source components that can be used to build a range of business-specific services and solutions. - -### Eclipse's IoT projects - -Of Eclipse's many IoT projects currently in use, Ian says two of the most prominent relate to [MQTT][8], a machine-to-machine (M2M) messaging protocol for IoT. Ian describes it as "a publish‑subscribe messaging protocol that was designed specifically for oil and gas pipeline monitoring where power-management network latency is really important. MQTT has been a great success in terms of being a standard that's being widely adopted in IoT." [Eclipse Mosquitto][9] is MQTT's broker and [Eclipse Paho][10] its client. - -[Eclipse Kura][11] is an IoT gateway that, in Ian's words, "provides northbound and southbound connectivity [for] a lot of different protocols" including Bluetooth, Modbus, controller-area network (CAN) bus, and OPC Unified Architecture, with more being added all the time. One benefit, he says, is "instead of you writing your own connectivity, Kura provides that and then connects you to the network via satellite, via Ethernet, or anything." In addition, it handles firewall configuration, network latency, and other functions. "If the network goes down, it will store messages until it comes back up," Ian says. - -A newer project, [Eclipse Kapua][12], is taking a microservices approach to providing different services for an IoT cloud platform. For example, it handles aspects of connectivity, integration, management, storage, and analysis. Ian describes it as "up and coming. It's not being deployed yet, but Eurotech and Red Hat are very active in that." - -Ian says [Eclipse hawkBit][13], which manages software updates, is one of the "most intriguing projects. From a security perspective, if you can't update your device, you've got a huge security hole." Most IoT security disasters are related to non-updated devices, he says. "HawkBit basically manages the backend of how you do scalable updates across your IoT system." - -Indeed, the difficulty of updating software in IoT devices is regularly cited as one of its biggest security challenges. IoT devices aren't always connected and may be numerous, plus update processes for constrained devices can be hard to consistently get right. For this reason, projects relating to updating IoT software are likely to be important going forward. - -### Why IoT is a good fit for Eclipse - -One of the trends we've seen in IoT development has been around building blocks that are integrated and applied to solve particular business problems, rather than monolithic IoT platforms that apply across industries and companies. This is a good fit with Eclipse's approach to IoT, which focuses on a number of modular stacks; projects that provide specific and commonly needed functions; and brokers, gateways, and protocols that can tie together the components needed for a given implementation. - --------------------------------------------------------------------------------- - -作者简介: - -Gordon Haff - Gordon Haff is Red Hat’s cloud evangelist, is a frequent and highly acclaimed speaker at customer and industry events, and helps develop strategy across Red Hat’s full portfolio of cloud solutions. He is the author of Computing Next: How the Cloud Opens the Future in addition to numerous other publications. Prior to Red Hat, Gordon wrote hundreds of research notes, was frequently quoted in publications like The New York Times on a wide range of IT topics, and advised clients on product and... - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/10/eclipse-and-iot - -作者:[Gordon Haff ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/ghaff -[1]:https://opensource.com/article/17/10/eclipse-and-iot?rate=u1Wr-MCMFCF4C45IMoSPUacCatoqzhdKz7NePxHOvwg -[2]:https://opensource.com/user/21220/feed -[3]:https://www.eclipse.org/home/ -[4]:http://thingmonk.com/ -[5]:https://iot.eclipse.org/ -[6]:https://twitter.com/ianskerrett -[7]:https://iot.eclipse.org/resources/white-papers/Eclipse%20IoT%20White%20Paper%20-%20The%20Three%20Software%20Stacks%20Required%20for%20IoT%20Architectures.pdf -[8]:http://mqtt.org/ -[9]:https://projects.eclipse.org/projects/technology.mosquitto -[10]:https://projects.eclipse.org/projects/technology.paho -[11]:https://www.eclipse.org/kura/ -[12]:https://www.eclipse.org/kapua/ -[13]:https://eclipse.org/hawkbit/ -[14]:https://opensource.com/users/ghaff -[15]:https://opensource.com/users/ghaff -[16]:https://opensource.com/article/17/10/eclipse-and-iot#comments diff --git a/translated/tech/20171020 How Eclipse is advancing IoT development.md b/translated/tech/20171020 How Eclipse is advancing IoT development.md new file mode 100644 index 0000000000..0de4f38ea1 --- /dev/null +++ b/translated/tech/20171020 How Eclipse is advancing IoT development.md @@ -0,0 +1,77 @@ +translated by smartgrids +Eclipse 如何助力 IoT 发展 +============================================================ + +### 开源组织的模块发开发方式非常适合物联网。 + +![How Eclipse is advancing IoT development](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_BUS_ArchitectureOfParticipation_520x292.png?itok=FA0Uuwzv "How Eclipse is advancing IoT development") +图片来源: opensource.com + +[Eclipse][3] 可能不是第一个去研究物联网的开源组织。但是,远在 IoT 家喻户晓之前,该基金会在 2001 年左右就开始支持开源软件发展商业化。九月 Eclipse 物联网日和 RedMonk 的 [ThingMonk 2017][4] 一块举行,着重强调了 Eclipse 在 [物联网发展][5] 中的重要作用。它现在已经包含了 28 个项目,覆盖了大部分物联网项目需求。会议过程中,我和负责 Eclipse 市场化运作的 [Ian Skerritt][6] 讨论了 Eclipse 的物联网项目以及如何拓展它。 + +###物联网的最新进展? +我问 Ian 物联网同传统工业自动化,也就是前几十年通过传感器和相应工具来实现工厂互联的方式有什么不同。 Ian 指出很多工厂是还没有互联的。 +另外,他说“ SCADA[监控和数据分析] 系统以及工厂底层技术都是私有、独立性的。我们很难去改变它,也很难去适配它们…… 现在,如果你想运行一套生产系统,你需要设计成百上千的单元。生产线想要的是满足用户需求,使制造过程更灵活,从而可以不断产出。” 这也就是物联网会带给制造业的一个很大的帮助。 + + +###Eclipse 物联网方面的研究 +Ian 对于 Eclipse 在物联网的研究是这样描述的:“满足任何物联网解决方案的核心基础技术” ,通过使用开源技术,“每个人都可以使用从而可以获得更好的适配性。” 他说,Eclipse 将物联网视为包括三层互联的软件栈。从更高的层面上看,这些软件栈(按照大家常见的说法)将物联网描述为跨越三个层面的网络。特定的观念可能认为含有更多的层面,但是他们一直符合这个三层模型的功能的: + +* 一种可以装载设备(例如设备、终端、微控制器、传感器)用软件的堆栈。 +* 将不同的传感器采集到的数据信息聚合起来并传输到网上的一类网关。这一层也可能会针对传感器数据检测做出实时反映。 +* 物联网平台后端的一个软件栈。这个后端云存储数据并能根据采集的数据比如历史趋势、预测分析提供服务。 + +这三个软件栈在 Eclipse 的白皮书 “ [The Three Software Stacks Required for IoT Architectures][7] ”中有更详细的描述。 + +Ian 说在这些架构中开发一种解决方案时,“需要开发一些特殊的东西,但是很多底层的技术是可以借用的,像通信协议、网关服务。需要一种模块化的方式来满足不用的需求场合。” Eclipse 关于物联网方面的研究可以概括为:开发模块化开源组件从而可以被用于开发大量的特定性商业服务和解决方案。 + +###Eclipse 的物联网项目 + +在众多一杯应用的 Eclipse 物联网应用中, Ian 举了两个和 [MQTT][8] 有关联的突出应用,一个设备与设备互联(M2M)的物联网协议。 Ian 把它描述成“一个专为重视电源管理工作的油气传输线监控系统的信息发布/订阅协议。MQTT 已经是众多物联网广泛应用标准中很成功的一个。” [Eclipse Mosquitto][9] 是 MQTT 的代理,[Eclipse Paho][10] 是他的客户端。 +[Eclipse Kura][11] 是一个物联网网关,引用 Ian 的话,“它连接了很多不同的协议间的联系”包括蓝牙、Modbus、CANbus 和 OPC 统一架构协议,以及一直在不断添加的协议。一个优势就是,他说,取代了你自己写你自己的协议, Kura 提供了这个功能并将你通过卫星、网络或其他设备连接到网络。”另外它也提供了防火墙配置、网络延时以及其它功能。Ian 也指出“如果网络不通时,它会存储信息直到网络恢复。” + +最新的一个项目中,[Eclipse Kapua][12] 正尝试通过微服务来为物联网云平台提供不同的服务。比如,它集成了通信、汇聚、管理、存储和分析功能。Ian 说“它正在不断前进,虽然还没被完全开发出来,但是 Eurotech 和 RedHat 在这个项目上非常积极。” +Ian 说 [Eclipse hawkBit][13] ,软件更新管理的软件,是一项“非常有趣的项目。从安全的角度说,如果你不能更新你的设备,你将会面临巨大的安全漏洞。”很多物联网安全事故都和无法更新的设备有关,他说,“ HawkBit 可以基本负责通过物联网系统来完成扩展性更新的后端管理。” + +物联网设备软件升级的难度一直被看作是难度最高的安全挑战之一。物联网设备不是一直连接的,而且数目众多,再加上首先设备的更新程序很难完全正常。正因为这个原因,关于无赖女王软件升级的项目一直是被当作重要内容往前推进。 + +###为什么物联网这么适合 Eclipse + +在物联网发展趋势中的一个方面就是关于构建模块来解决商业问题,而不是宽约工业和公司的大物联网平台。 Eclipse 关于物联网的研究放在一系列模块栈、提供特定和大众化需求功能的项目,还有就是指定目标所需的可捆绑式中间件、网关和协议组件上。 + + +-------------------------------------------------------------------------------- + + + +作者简介: + +Gordon Haff - Gordon Haff 是红帽公司的云营销员,经常在消费者和工业会议上讲话,并且帮助发展红帽全办公云解决方案。他是 计算机前言:云如何如何打开众多出版社未来之门 的作者。在红帽之前, Gordon 写了成百上千的研究报告,经常被引用到公众刊物上,像纽约时报关于 IT 的议题和产品建议等…… + +-------------------------------------------------------------------------------- + +转自: https://opensource.com/article/17/10/eclipse-and-iot + +作者:[Gordon Haff ][a] +译者:[smartgrids](https://github.com/smartgrids) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/ghaff +[1]:https://opensource.com/article/17/10/eclipse-and-iot?rate=u1Wr-MCMFCF4C45IMoSPUacCatoqzhdKz7NePxHOvwg +[2]:https://opensource.com/user/21220/feed +[3]:https://www.eclipse.org/home/ +[4]:http://thingmonk.com/ +[5]:https://iot.eclipse.org/ +[6]:https://twitter.com/ianskerrett +[7]:https://iot.eclipse.org/resources/white-papers/Eclipse%20IoT%20White%20Paper%20-%20The%20Three%20Software%20Stacks%20Required%20for%20IoT%20Architectures.pdf +[8]:http://mqtt.org/ +[9]:https://projects.eclipse.org/projects/technology.mosquitto +[10]:https://projects.eclipse.org/projects/technology.paho +[11]:https://www.eclipse.org/kura/ +[12]:https://www.eclipse.org/kapua/ +[13]:https://eclipse.org/hawkbit/ +[14]:https://opensource.com/users/ghaff +[15]:https://opensource.com/users/ghaff +[16]:https://opensource.com/article/17/10/eclipse-and-iot#comments From 53000863489af8605b3c1362b319dd508303853c Mon Sep 17 00:00:00 2001 From: Sihua Zheng Date: Mon, 4 Dec 2017 13:31:35 +0800 Subject: [PATCH 192/344] translating --- sources/tech/20171107 GitHub welcomes all CI tools.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171107 GitHub welcomes all CI tools.md b/sources/tech/20171107 GitHub welcomes all CI tools.md index f3112d9481..7bef351bd6 100644 --- a/sources/tech/20171107 GitHub welcomes all CI tools.md +++ b/sources/tech/20171107 GitHub welcomes all CI tools.md @@ -1,3 +1,5 @@ +translating---geekpi + GitHub welcomes all CI tools ==================== From db679cf7f234585074f7b0502d44029c43293aec Mon Sep 17 00:00:00 2001 From: Ezio Date: Mon, 4 Dec 2017 14:25:46 +0800 Subject: [PATCH 193/344] =?UTF-8?q?20171204-3=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...nject features and investigate programs.md | 211 ++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 sources/tech/20130402 Dynamic linker tricks Using LD_PRELOAD to cheat inject features and investigate programs.md diff --git a/sources/tech/20130402 Dynamic linker tricks Using LD_PRELOAD to cheat inject features and investigate programs.md b/sources/tech/20130402 Dynamic linker tricks Using LD_PRELOAD to cheat inject features and investigate programs.md new file mode 100644 index 0000000000..2329fadd41 --- /dev/null +++ b/sources/tech/20130402 Dynamic linker tricks Using LD_PRELOAD to cheat inject features and investigate programs.md @@ -0,0 +1,211 @@ +# Dynamic linker tricks: Using LD_PRELOAD to cheat, inject features and investigate programs + +**This post assumes some basic C skills.** + +Linux puts you in full control. This is not always seen from everyone’s perspective, but a power user loves to be in control. I’m going to show you a basic trick that lets you heavily influence the behavior of most applications, which is not only fun, but also, at times, useful. + +#### A motivational example + +Let us begin with a simple example. Fun first, science later. + + +random_num.c: +``` +#include +#include +#include + +int main(){ + srand(time(NULL)); + int i = 10; + while(i--) printf("%d\n",rand()%100); + return 0; +} +``` + +Simple enough, I believe. I compiled it with no special flags, just + +> ``` +> gcc random_num.c -o random_num +> ``` + +I hope the resulting output is obvious – ten randomly selected numbers 0-99, hopefully different each time you run this program. + +Now let’s pretend we don’t really have the source of this executable. Either delete the source file, or move it somewhere – we won’t need it. We will significantly modify this programs behavior, yet without touching it’s source code nor recompiling it. + +For this, lets create another simple C file: + + +unrandom.c: +``` +int rand(){ + return 42; //the most random number in the universe +} +``` + +We’ll compile it into a shared library. + +> ``` +> gcc -shared -fPIC unrandom.c -o unrandom.so +> ``` + +So what we have now is an application that outputs some random data, and a custom library, which implements the rand() function as a constant value of 42\.  Now… just run  _random_num _ this way, and watch the result: + +> ``` +> LD_PRELOAD=$PWD/unrandom.so ./random_nums +> ``` + +If you are lazy and did not do it yourself (and somehow fail to guess what might have happened), I’ll let you know – the output consists of ten 42’s. + +This may be even more impressive it you first: + +> ``` +> export LD_PRELOAD=$PWD/unrandom.so +> ``` + +and then run the program normally. An unchanged app run in an apparently usual manner seems to be affected by what we did in our tiny library… + +###### **Wait, what? What did just happen?** + +Yup, you are right, our program failed to generate random numbers, because it did not use the “real” rand(), but the one we provided – which returns 42 every time. + +###### **But we *told* it to use the real one. We programmed it to use the real one. Besides, at the time we created that program, the fake rand() did not even exist!** + +This is not entirely true. We did not choose which rand() we want our program to use. We told it just to use rand(). + +When our program is started, certain libraries (that provide functionality needed by the program) are loaded. We can learn which are these using  _ldd_ : + +> ``` +> $ ldd random_nums +> linux-vdso.so.1 => (0x00007fff4bdfe000) +> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f48c03ec000) +> /lib64/ld-linux-x86-64.so.2 (0x00007f48c07e3000) +> ``` + +What you see as the output is the list of libs that are needed by  _random_nums_ . This list is built into the executable, and is determined compile time. The exact output might slightly differ on your machine, but a **libc.so** must be there – this is the file which provides core C functionality. That includes the “real” rand(). + +We can have a peek at what functions does libc provide. I used the following to get a full list: + +> ``` +> nm -D /lib/libc.so.6 +> ``` + +The  _nm_  command lists symbols found in a binary file. The -D flag tells it to look for dynamic symbols, which makes sense, as libc.so.6 is a dynamic library. The output is very long, but it indeed lists rand() among many other standard functions. + +Now what happens when we set up the environmental variable LD_PRELOAD? This variable **forces some libraries to be loaded for a program**. In our case, it loads  _unrandom.so_  for  _random_num_ , even though the program itself does not ask for it. The following command may be interesting: + +> ``` +> $ LD_PRELOAD=$PWD/unrandom.so ldd random_nums +> linux-vdso.so.1 => (0x00007fff369dc000) +> /some/path/to/unrandom.so (0x00007f262b439000) +> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f262b044000) +> /lib64/ld-linux-x86-64.so.2 (0x00007f262b63d000) +> ``` + +Note that it lists our custom library. And indeed this is the reason why it’s code get’s executed:  _random_num_  calls rand(), but if  _unrandom.so_  is loaded it is our library that provides implementation for rand(). Neat, isn’t it? + +#### Being transparent + +This is not enough. I’d like to be able to inject some code into an application in a similar manner, but in such way that it will be able to function normally. It’s clear if we implemented open() with a simple “ _return 0;_ “, the application we would like to hack should malfunction. The point is to be **transparent**, and to actually call the original open: + +inspect_open.c: +``` +int open(const char *pathname, int flags){ + /* Some evil injected code goes here. */ + return open(pathname,flags); // Here we call the "real" open function, that is provided to us by libc.so +} +``` + +Hm. Not really. This won’t call the “original” open(…). Obviously, this is an endless recursive call. + +How do we access the “real” open function? It is needed to use the programming interface to the dynamic linker. It’s simpler than it sounds. Have a look at this complete example, and then I’ll explain what happens there: + +inspect_open.c: + +``` +#define _GNU_SOURCE +#include + +typedef int (*orig_open_f_type)(const char *pathname, int flags); + +int open(const char *pathname, int flags, ...) +{ + /* Some evil injected code goes here. */ + + orig_open_f_type orig_open; + orig_open = (orig_open_f_type)dlsym(RTLD_NEXT,"open"); + return orig_open(pathname,flags); +} +``` + +The  _dlfcn.h_  is needed for  _dlsym_  function we use later. That strange  _#define_  directive instructs the compiler to enable some non-standard stuff, we need it to enable  _RTLD_NEXT_  in  _dlfcn.h_ . That typedef is just creating an alias to a complicated pointer-to-function type, with arguments just as the original open – the alias name is  _orig_open_f_type_ , which we’ll use later. + +The body of our custom open(…) consists of some custom code. The last part of it creates a new function pointer  _orig_open_  which will point to the original open(…) function. In order to get the address of that function, we ask  _dlsym_  to find for us the next “open” function on dynamic libraries stack. Finally, we call that function (passing the same arguments as were passed to our fake “open”), and return it’s return value as ours. + +As the “evil injected code” I simply used: + +inspect_open.c (fragment): + +``` +printf("The victim used open(...) to access '%s'!!!\n",pathname); //remember to include stdio.h! +``` + +To compile it, I needed to slightly adjust compiler flags: + +> ``` +> gcc -shared -fPIC  inspect_open.c -o inspect_open.so -ldl +> ``` + +I had to append  _-ldl_ , so that this shared library is linked to  _libdl_ , which provides the  _dlsym_  function. (Nah, I am not going to create a fake version of  _dlsym_ , though this might be fun.) + +So what do I have in result? A shared library, which implements the open(…) function so that it behaves **exactly** as the real open(…)… except it has a side effect of  _printf_ ing the file path :-) + +If you are not convinced this is a powerful trick, it’s the time you tried the following: + +> ``` +> LD_PRELOAD=$PWD/inspect_open.so gnome-calculator +> ``` + +I encourage you to see the result yourself, but basically it lists every file this application accesses. In real time. + +I believe it’s not that hard to imagine why this might be useful for debugging or investigating unknown applications. Please note, however, that this particular trick is not quite complete, because  _open()_  is not the only function that opens files… For example, there is also  _open64()_  in the standard library, and for full investigation you would need to create a fake one too. + +#### **Possible uses** + +If you are still with me and enjoyed the above, let me suggest a bunch of ideas of what can be achieved using this trick. Keep in mind that you can do all the above without to source of the affected app! + +1. ~~Gain root privileges.~~ Not really, don’t even bother, you won’t bypass any security this way. (A quick explanation for pros: no libraries will be preloaded this way if ruid != euid) + +2. Cheat games: **Unrandomize.** This is what I did in the first example. For a fully working case you would need also to implement a custom  _random()_ ,  _rand_r()_ _, random_r()_ . Also some apps may be reading from  _/dev/urandom_  or so, you might redirect them to  _/dev/null_  by running the original  _open()_  with a modified file path. Furthermore, some apps may have their own random number generation algorithm, there is little you can do about that (unless: point 10 below). But this looks like an easy exercise for beginners. + +3. Cheat games: **Bullet time. **Implement all standard time-related functions pretend the time flows two times slower. Or ten times slower. If you correctly calculate new values for time measurement, timed  _sleep_ functions, and others, the affected application will believe the time runs slower (or faster, if you wish), and you can experience awesome bullet-time action. + Or go **even one step further** and let your shared library also be a DBus client, so that you can communicate with it real time. Bind some shortcuts to custom commands, and with some additional calculations in your fake timing functions you will be able to enable&disable the slow-mo or fast-forward anytime you wish. + +4. Investigate apps: **List accessed files.** That’s what my second example does, but this could be also pushed further, by recording and monitoring all app’s file I/O. + +5. Investigate apps: **Monitor internet access.** You might do this with Wireshark or similar software, but with this trick you could actually gain control of what an app sends over the web, and not just look, but also affect the exchanged data. Lots of possibilities here, from detecting spyware, to cheating in multiplayer games, or analyzing & reverse-engineering protocols of closed-source applications. + +6. Investigate apps: **Inspect GTK structures.** Why just limit ourselves to standard library? Let’s inject code in all GTK calls, so that we can learn what widgets does an app use, and how are they structured. This might be then rendered either to an image or even to a gtkbuilder file! Super useful if you want to learn how does some app manage its interface! + +7. **Sandbox unsafe applications.** If you don’t trust some app and are afraid that it may wish to _ rm -rf / _ or do some other unwanted file activities, you might potentially redirect all it’s file IO to e.g. /tmp by appropriately modifying the arguments it passes to all file-related functions (not just  _open_ , but also e.g. removing directories etc.). It’s more difficult trick that a chroot, but it gives you more control. It would be only as safe as complete your “wrapper” was, and unless you really know what you’re doing, don’t actually run any malicious software this way. + +8. **Implement features.** [zlibc][1] is an actual library which is run this precise way; it uncompresses files on the go as they are accessed, so that any application can work on compressed data without even realizing it. + +9. **Fix bugs. **Another real-life example: some time ago (I am not sure this is still the case) Skype – which is closed-source – had problems capturing video from some certain webcams. Because the source could not be modified as Skype is not free software, this was fixed by preloading a library that would correct these problems with video. + +10. Manually **access application’s own memory**. Do note that you can access all app data this way. This may be not impressive if you are familiar with software like CheatEngine/scanmem/GameConqueror, but they all require root privileges to work. LD_PRELOAD does not. In fact, with a number of clever tricks your injected code might access all app memory, because, in fact, it gets executed by that application itself. You might modify everything this application can. You can probably imagine this allows a lot of low-level hacks… but I’ll post an article about it another time. + +These are only the ideas I came up with. I bet you can find some too, if you do – share them by commenting! + +-------------------------------------------------------------------------------- + +via: https://rafalcieslak.wordpress.com/2013/04/02/dynamic-linker-tricks-using-ld_preload-to-cheat-inject-features-and-investigate-programs/ + +作者:[Rafał Cieślak ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://rafalcieslak.wordpress.com/ +[1]:http://www.zlibc.linux.lu/index.html From 46d6e7e4a63873835e64e5302d3c02f1618820e5 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Mon, 4 Dec 2017 15:30:49 +0800 Subject: [PATCH 194/344] Translated by qhwdw --- ...1109 Concurrent Servers- Part 4 - libuv.md | 492 ++++++++++++++++++ 1 file changed, 492 insertions(+) create mode 100644 translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md diff --git a/translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md b/translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md new file mode 100644 index 0000000000..b4db491e4e --- /dev/null +++ b/translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md @@ -0,0 +1,492 @@ +[并发服务器:第四部分 - libuv][17] +============================================================ + +这是写并发网络服务器系列文章的第四部分。在这一部分中,我们将使用 libuv 去再次重写我们的服务器,并且也讨论关于使用一个线程池在回调中去处理耗时任务。最终,我们去看一下底层的 libuv,花一点时间去学习如何用异步 API 对文件系统阻塞操作进行封装。 + +这一系列的所有文章包括: + +* [第一部分 - 简介][7] + +* [第二部分 - 线程][8] + +* [第三部分 - 事件驱动][9] + +* [第四部分 - libuv][10] + +### 使用 Linux 抽象出事件驱动循环 + +在 [第三部分][11] 中,我们看到了基于 `select` 和 `epoll` 的相似之处,并且,我说过,在它们之间抽象出细微的差别是件很有魅力的事。Numerous 库已经做到了这些,但是,因为在这一部分中,我将去选一个并使用它。我选的这个库是 [libuv][12],它最初设计用于 Node.js 底层的轻便的平台层,并且,后来发现在其它的项目中已有使用。libuv 是用 C 写的,因此,它具有很高的可移植性,非常适用嵌入到像 JavaScript 和 Python 这样的高级语言中。 + +虽然 libuv 为抽象出底层平台细节已经有了一个非常大的框架,但它仍然是一个以 _事件循环_ 思想为中心的。在我们第三部分的事件驱动服务器中,事件循环在 main 函数中是很明确的;当使用 libuv 时,循环通常隐藏在库自身中,而用户代码仅需要注册事件句柄(作为一个回调函数)和运行这个循环。此外,libuv 将为给定的平台实现更快的事件循环实现。对于 Linux 它是 epoll,等等。 + +![libuv loop](https://eli.thegreenplace.net/images/2017/libuvloop.png) + +libuv 支持多路事件循环,并且,因此一个事件循环在库中是非常重要的;它有一个句柄 - `uv_loop_t`,和创建/杀死/启动/停止循环的函数。也就是说,在这篇文章中,我将仅需要使用 “默认的” 循环,libuv 可通过 `uv_default_loop()` 提供它;多路循环大多用于多线程事件驱动的服务器,这是一个更高级别的话题,我将留在这一系列文章的以后部分。 + +### 使用 libuv 的并发服务器 + +为了对 libuv 有一个更深的印象,让我们跳转到我们的可靠的协议服务器,它通过我们的这个系列已经有了一个强大的重新实现。这个服务器的结构与第三部分中的基于 select 和 epoll 的服务器有一些相似之处。因为,它也依赖回调。完整的 [示例代码在这里][13];我们开始设置这个服务器的套接字绑定到一个本地端口: + +``` +int portnum = 9090; +if (argc >= 2) { + portnum = atoi(argv[1]); +} +printf("Serving on port %d\n", portnum); + +int rc; +uv_tcp_t server_stream; +if ((rc = uv_tcp_init(uv_default_loop(), &server_stream)) < 0) { + die("uv_tcp_init failed: %s", uv_strerror(rc)); +} + +struct sockaddr_in server_address; +if ((rc = uv_ip4_addr("0.0.0.0", portnum, &server_address)) < 0) { + die("uv_ip4_addr failed: %s", uv_strerror(rc)); +} + +if ((rc = uv_tcp_bind(&server_stream, (const struct sockaddr*)&server_address, 0)) < 0) { + die("uv_tcp_bind failed: %s", uv_strerror(rc)); +} +``` + +除了它被封装进 libuv APIs 中之外,你看到的是一个相当标准的套接字。在它的返回中,我们取得一个可工作于任何 libuv 支持的平台上的轻便的接口。 + +这些代码也很认真负责地演示了错误处理;多数的 libuv 函数返回一个整数状态,返回一个负数意味着出现了一个错误。在我们的服务器中,我们把这些错误按致命的问题处理,但也可以设想为一个更优雅的恢复。 + +现在,那个套接字已经绑定,是时候去监听它了。这里我们运行一个回调注册: + +``` +// Listen on the socket for new peers to connect. When a new peer connects, +// the on_peer_connected callback will be invoked. +if ((rc = uv_listen((uv_stream_t*)&server_stream, N_BACKLOG, on_peer_connected)) < 0) { + die("uv_listen failed: %s", uv_strerror(rc)); +} +``` + +当新的对端连接到这个套接字,`uv_listen` 将被调用去注册一个事件循环回调。我们的回调在这里被称为 `on_peer_connected`,并且我们一会儿将去检测它。 + +最终,main 运行这个 libuv 循环,直到它被停止(`uv_run` 仅在循环被停止或者发生错误时返回) + +``` +// Run the libuv event loop. +uv_run(uv_default_loop(), UV_RUN_DEFAULT); + +// If uv_run returned, close the default loop before exiting. +return uv_loop_close(uv_default_loop()); +``` + +注意,那个仅是一个单一的通过 main 优先去运行的事件循环回调;我们不久将看到怎么去添加更多的另外的回调。在事件循环的整个运行时中,添加和删除回调并不是一个问题 - 事实上,大多数服务器就是这么写的。 + +这是一个 `on_peer_connected`,它处理到服务器的新的客户端连接: + +``` +void on_peer_connected(uv_stream_t* server_stream, int status) { + if (status < 0) { + fprintf(stderr, "Peer connection error: %s\n", uv_strerror(status)); + return; + } + + // client will represent this peer; it's allocated on the heap and only + // released when the client disconnects. The client holds a pointer to + // peer_state_t in its data field; this peer state tracks the protocol state + // with this client throughout interaction. + uv_tcp_t* client = (uv_tcp_t*)xmalloc(sizeof(*client)); + int rc; + if ((rc = uv_tcp_init(uv_default_loop(), client)) < 0) { + die("uv_tcp_init failed: %s", uv_strerror(rc)); + } + client->data = NULL; + + if (uv_accept(server_stream, (uv_stream_t*)client) == 0) { + struct sockaddr_storage peername; + int namelen = sizeof(peername); + if ((rc = uv_tcp_getpeername(client, (struct sockaddr*)&peername, + &namelen)) < 0) { + die("uv_tcp_getpeername failed: %s", uv_strerror(rc)); + } + report_peer_connected((const struct sockaddr_in*)&peername, namelen); + + // Initialize the peer state for a new client: we start by sending the peer + // the initial '*' ack. + peer_state_t* peerstate = (peer_state_t*)xmalloc(sizeof(*peerstate)); + peerstate->state = INITIAL_ACK; + peerstate->sendbuf[0] = '*'; + peerstate->sendbuf_end = 1; + peerstate->client = client; + client->data = peerstate; + + // Enqueue the write request to send the ack; when it's done, + // on_wrote_init_ack will be called. The peer state is passed to the write + // request via the data pointer; the write request does not own this peer + // state - it's owned by the client handle. + uv_buf_t writebuf = uv_buf_init(peerstate->sendbuf, peerstate->sendbuf_end); + uv_write_t* req = (uv_write_t*)xmalloc(sizeof(*req)); + req->data = peerstate; + if ((rc = uv_write(req, (uv_stream_t*)client, &writebuf, 1, + on_wrote_init_ack)) < 0) { + die("uv_write failed: %s", uv_strerror(rc)); + } + } else { + uv_close((uv_handle_t*)client, on_client_closed); + } +} +``` + +这些代码都有很好的注释,但是,这里有一些重要的 libuv 语法我想去强调一下: + +* 进入回调中的自定义数据:因为 C 还没有停用,这可能是个挑战,libuv 在它的处理类型中有一个 `void*` 数据域;这些域可以被用于进入到用户数据。例如,注意 `client->data` 是如何指向到一个 `peer_state_t` 结构上,以便于通过 `uv_write` 和 `uv_read_start` 注册的回调可以知道它们正在处理的是哪个客户端的数据。 + +* 内存管理:事件驱动编程在语言中使用垃圾回收是非常容易的,因为,回调通常运行在一个它们注册的完全不同的栈框架中,使得基于栈的内存管理很困难。它总是需要传递堆分配的数据到 libuv 回调中(当所有回调运行时,除了 main,其它的都运行在栈上),并且,为了避免泄漏,许多情况下都要求这些数据去安全释放。这些都是些需要实践的内容 [[1]][6]。 + +这个服务器上对端的状态如下: + +``` +typedef struct { + ProcessingState state; + char sendbuf[SENDBUF_SIZE]; + int sendbuf_end; + uv_tcp_t* client; +} peer_state_t; +``` + +它与第三部分中的状态非常类似;我们不再需要 sendptr,因为,在调用 "done writing" 回调之前,`uv_write` 将确保去发送它提供的整个缓冲。我们也为其它的回调使用保持了一个到客户端的指针。这里是 `on_wrote_init_ack`: + +``` +void on_wrote_init_ack(uv_write_t* req, int status) { + if (status) { + die("Write error: %s\n", uv_strerror(status)); + } + peer_state_t* peerstate = (peer_state_t*)req->data; + // Flip the peer state to WAIT_FOR_MSG, and start listening for incoming data + // from this peer. + peerstate->state = WAIT_FOR_MSG; + peerstate->sendbuf_end = 0; + + int rc; + if ((rc = uv_read_start((uv_stream_t*)peerstate->client, on_alloc_buffer, + on_peer_read)) < 0) { + die("uv_read_start failed: %s", uv_strerror(rc)); + } + + // Note: the write request doesn't own the peer state, hence we only free the + // request itself, not the state. + free(req); +} +``` + +然后,我们确信知道了这个初始的 '*' 已经被发送到对端,我们通过调用 `uv_read_start` 去监听从这个对端来的入站数据,它注册一个回调(`on_peer_read`)去被调用,不论什么时候,事件循环都在套接字上接收来自客户端的调用: + +``` +void on_peer_read(uv_stream_t* client, ssize_t nread, const uv_buf_t* buf) { + if (nread < 0) { + if (nread != uv_eof) { + fprintf(stderr, "read error: %s\n", uv_strerror(nread)); + } + uv_close((uv_handle_t*)client, on_client_closed); + } else if (nread == 0) { + // from the documentation of uv_read_cb: nread might be 0, which does not + // indicate an error or eof. this is equivalent to eagain or ewouldblock + // under read(2). + } else { + // nread > 0 + assert(buf->len >= nread); + + peer_state_t* peerstate = (peer_state_t*)client->data; + if (peerstate->state == initial_ack) { + // if the initial ack hasn't been sent for some reason, ignore whatever + // the client sends in. + free(buf->base); + return; + } + + // run the protocol state machine. + for (int i = 0; i < nread; ++i) { + switch (peerstate->state) { + case initial_ack: + assert(0 && "can't reach here"); + break; + case wait_for_msg: + if (buf->base[i] == '^') { + peerstate->state = in_msg; + } + break; + case in_msg: + if (buf->base[i] == '$') { + peerstate->state = wait_for_msg; + } else { + assert(peerstate->sendbuf_end < sendbuf_size); + peerstate->sendbuf[peerstate->sendbuf_end++] = buf->base[i] + 1; + } + break; + } + } + + if (peerstate->sendbuf_end > 0) { + // we have data to send. the write buffer will point to the buffer stored + // in the peer state for this client. + uv_buf_t writebuf = + uv_buf_init(peerstate->sendbuf, peerstate->sendbuf_end); + uv_write_t* writereq = (uv_write_t*)xmalloc(sizeof(*writereq)); + writereq->data = peerstate; + int rc; + if ((rc = uv_write(writereq, (uv_stream_t*)client, &writebuf, 1, + on_wrote_buf)) < 0) { + die("uv_write failed: %s", uv_strerror(rc)); + } + } + } + free(buf->base); +} +``` + +这个服务器的运行时行为非常类似于第三部分的事件驱动服务器:所有的客户端都在一个单个的线程中并发处理。并且一些行为被维护在服务器代码中:服务器的逻辑实现为一个集成的回调,并且长周期运行是禁止的,因为它会阻塞事件循环。这一点也很类似。让我们进一步探索这个问题。 + +### 在事件驱动循环中的长周期运行的操作 + +单线程的事件驱动代码使它先天地对一些常见问题非常敏感:整个循环中的长周期运行的代码块。参见如下的程序: + +``` +void on_timer(uv_timer_t* timer) { + uint64_t timestamp = uv_hrtime(); + printf("on_timer [%" PRIu64 " ms]\n", (timestamp / 1000000) % 100000); + + // "Work" + if (random() % 5 == 0) { + printf("Sleeping...\n"); + sleep(3); + } +} + +int main(int argc, const char** argv) { + uv_timer_t timer; + uv_timer_init(uv_default_loop(), &timer); + uv_timer_start(&timer, on_timer, 0, 1000); + return uv_run(uv_default_loop(), UV_RUN_DEFAULT); +} +``` + +它用一个单个注册的回调运行一个 libuv 事件循环:`on_timer`,它被每秒钟循环调用一次。回调报告一个时间戳,并且,偶尔通过睡眠 3 秒去模拟一个长周期运行。这是运行示例: + +``` +$ ./uv-timer-sleep-demo +on_timer [4840 ms] +on_timer [5842 ms] +on_timer [6843 ms] +on_timer [7844 ms] +Sleeping... +on_timer [11845 ms] +on_timer [12846 ms] +Sleeping... +on_timer [16847 ms] +on_timer [17849 ms] +on_timer [18850 ms] +... +``` + +`on_timer` 忠实地每秒执行一次,直到随机出现的睡眠为止。在那个时间点,`on_timer` 不再被调用,直到睡眠时间结束;事实上,_没有其它的回调_  在这个时间帧中被调用。这个睡眠调用阻塞当前线程,它正是被调用的线程,并且也是事件循环使用的线程。当这个线程被阻塞后,事件循环也被阻塞。 + +这个示例演示了在事件驱动的调用中为什么回调不能被阻塞是多少的重要。并且,同样适用于 Node.js 服务器、客户端侧的 Javascript、大多数的 GUI 编程框架、以及许多其它的异步编程模型。 + +但是,有时候运行耗时的任务是不可避免的。并不是所有任务都有一个异步 APIs;例如,我们可能使用一些仅有同步 API 的库去处理,或者,正在执行一个可能的长周期计算。我们如何用事件驱动编程去结合这些代码?线程可以帮到你! + +### “转换” 阻塞调用到异步调用的线程 + +一个线程池可以被用于去转换阻塞调用到异步调用,通过与事件循环并行运行,并且当任务完成时去由它去公布事件。一个给定的阻塞函数 `do_work()`,这里介绍了它是怎么运行的: + +1. 在一个回调中,用 `do_work()` 代表直接调用,我们将它打包进一个 “任务”,并且请求线程池去运行这个任务。当任务完成时,我们也为循环去调用它注册一个回调;我们称它为 `on_work_done()`。 + +2. 在这个时间点,我们的回调可以返回并且事件循环保持运行;在同一时间点,线程池中的一个线程运行这个任务。 + +3. 一旦任务运行完成,通知主线程(指正在运行事件循环的线程),并且,通过事件循环调用 `on_work_done()`。 + +让我们看一下,使用 libuv 的工作调度 API,是怎么去解决我们前面的 timer/sleep 示例中展示的问题的: + +``` +void on_after_work(uv_work_t* req, int status) { + free(req); +} + +void on_work(uv_work_t* req) { + // "Work" + if (random() % 5 == 0) { + printf("Sleeping...\n"); + sleep(3); + } +} + +void on_timer(uv_timer_t* timer) { + uint64_t timestamp = uv_hrtime(); + printf("on_timer [%" PRIu64 " ms]\n", (timestamp / 1000000) % 100000); + + uv_work_t* work_req = (uv_work_t*)malloc(sizeof(*work_req)); + uv_queue_work(uv_default_loop(), work_req, on_work, on_after_work); +} + +int main(int argc, const char** argv) { + uv_timer_t timer; + uv_timer_init(uv_default_loop(), &timer); + uv_timer_start(&timer, on_timer, 0, 1000); + return uv_run(uv_default_loop(), UV_RUN_DEFAULT); +} +``` + +通过一个 work_req [[2]][14] 类型的句柄,我们进入一个任务队列,代替在 `on_timer` 上直接调用 sleep,这个函数在任务中(`on_work`)运行,并且,一旦任务完成(`on_after_work`),这个函数被调用一次。`on_work` 在这里是指发生的 “work”(阻塞中的/耗时的操作)。在这两个回调传递到 `uv_queue_work` 时,注意一个关键的区别:`on_work` 运行在线程池中,而 `on_after_work` 运行在事件循环中的主线程上 - 就好像是其它的回调一样。 + +让我们看一下这种方式的运行: + +``` +$ ./uv-timer-work-demo +on_timer [89571 ms] +on_timer [90572 ms] +on_timer [91573 ms] +on_timer [92575 ms] +Sleeping... +on_timer [93576 ms] +on_timer [94577 ms] +Sleeping... +on_timer [95577 ms] +on_timer [96578 ms] +on_timer [97578 ms] +... +``` + +即便在 sleep 函数被调用时,定时器也每秒钟滴答一下,睡眠(sleeping)现在运行在一个单独的线程中,并且不会阻塞事件循环。 + +### 一个用于练习的素数测试服务器 + +因为通过睡眼去模拟工作并不是件让人兴奋的事,我有一个事先准备好的更综合的一个示例 - 一个基于套接字接受来自客户端的数字的服务器,检查这个数字是否是素数,然后去返回一个 “prime" 或者 “composite”。完整的 [服务器代码在这里][15] - 我不在这里粘贴了,因为它太长了,更希望读者在一些自己的练习中去体会它。 + +这个服务器使用了一个原生的素数测试算法,因此,对于大的素数可能花很长时间才返回一个回答。在我的机器中,对于 2305843009213693951,它花了 ~5 秒钟去计算,但是,你的方法可能不同。 + +练习 1:服务器有一个设置(通过一个名为 MODE 的环境变量)要么去在套接字回调(意味着在主线程上)中运行素数测试,要么在 libuv 工作队列中。当多个客户端同时连接时,使用这个设置来观察服务器的行为。当它计算一个大的任务时,在阻塞模式中,服务器将不回复其它客户端,而在非阻塞模式中,它会回复。 + +练习 2;libuv 有一个缺省大小的线程池,并且线程池的大小可以通过环境变量配置。你可以通过使用多个客户端去实验找出它的缺省值是多少?找到线程池缺省值后,使用不同的设置去看一下,在重负载下怎么去影响服务器的响应能力。 + +### 在非阻塞文件系统中使用工作队列 + +对于仅傻傻的演示和 CPU 密集型的计算来说,将可能的阻塞操作委托给一个线程池并不是明智的;libuv 在它的文件系统 APIs 中本身就大量使用了这种性能。通过这种方式,libuv 使用一个异步 API,在一个轻便的方式中,显示出它强大的文件系统的处理能力。 + +让我们使用 `uv_fs_read()`,例如,这个函数从一个文件中(以一个 `uv_fs_t` 句柄为代表)读取一个文件到一个缓冲中 [[3]][16],并且当读取完成后调用一个回调。换句话说,`uv_fs_read()` 总是立即返回,甚至如果文件在一个类似 NFS 的系统上,并且,数据到达缓冲区可能需要一些时间。换句话说,这个 API 与这种方式中其它的 libuv APIs 是异步的。这是怎么工作的呢? + +在这一点上,我们看一下 libuv 的底层;内部实际上非常简单,并且它是一个很好的练习。作为一个便携的库,libuv 对于 Windows 和 Unix 系统在它的许多函数上有不同的实现。我们去看一下在 libuv 源树中的 src/unix/fs.c。 + +这是 `uv_fs_read` 的代码: + +``` +int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, + uv_file file, + const uv_buf_t bufs[], + unsigned int nbufs, + int64_t off, + uv_fs_cb cb) { + if (bufs == NULL || nbufs == 0) + return -EINVAL; + + INIT(READ); + req->file = file; + + req->nbufs = nbufs; + req->bufs = req->bufsml; + if (nbufs > ARRAY_SIZE(req->bufsml)) + req->bufs = uv__malloc(nbufs * sizeof(*bufs)); + + if (req->bufs == NULL) { + if (cb != NULL) + uv__req_unregister(loop, req); + return -ENOMEM; + } + + memcpy(req->bufs, bufs, nbufs * sizeof(*bufs)); + + req->off = off; + POST; +} +``` + +第一次看可能觉得很困难,因为它延缓真实的工作到 INIT 和 POST 宏中,在 POST 中与一些本地变量一起设置。这样做可以避免了文件中的许多重复代码。 + +这是 INIT 宏: + +``` +#define INIT(subtype) \ + do { \ + req->type = UV_FS; \ + if (cb != NULL) \ + uv__req_init(loop, req, UV_FS); \ + req->fs_type = UV_FS_ ## subtype; \ + req->result = 0; \ + req->ptr = NULL; \ + req->loop = loop; \ + req->path = NULL; \ + req->new_path = NULL; \ + req->cb = cb; \ + } \ + while (0) +``` + +它设置了请求,并且更重要的是,设置 `req->fs_type` 域为真实的 FS 请求类型。因为 `uv_fs_read` 调用 invokes INIT(READ),它意味着 `req->fs_type` 被分配一个常数 `UV_FS_READ`。 + +这是 POST 宏: + +``` +#define POST \ + do { \ + if (cb != NULL) { \ + uv__work_submit(loop, &req->work_req, uv__fs_work, uv__fs_done); \ + return 0; \ + } \ + else { \ + uv__fs_work(&req->work_req); \ + return req->result; \ + } \ + } \ + while (0) +``` + +它做什么取决于回调是否为 NULL。在 libuv 文件系统 APIs 中,一个 NULL 回调意味着我们真实地希望去执行一个 _同步_ 操作。在这种情况下,POST 直接调用 `uv__fs_work`(我们需要了解一下这个函数的功能),而对于一个 non-NULL 回调,它提交 `uv__fs_work` 作为一个工作事项到工作队列(指的是线程池),然后,注册 `uv__fs_done` 作为回调;该函数执行一些登记并调用用户提供的回调。 + +如果我们去看 `uv__fs_work` 的代码,我们将看到它使用很多宏去按需路由工作到真实的文件系统调用。在我们的案例中,对于 `UV_FS_READ` 这个调用将被 `uv__fs_read` 生成,它(最终)使用普通的 POSIX APIs 去读取。这个函数可以在一个 _阻塞_ 方式中很安全地实现。因为,它通过异步 API 调用时被置于一个线程池中。 + +在 Node.js 中,fs.readFile 函数是映射到 `uv_fs_read` 上。因此,可以在一个非阻塞模式中读取文件,甚至是当底层文件系统 API 是阻塞方式时。 + +* * * + + +[[1]][1] 为确保服务器不泄露内存,我在一个启用泄露检查的 Valgrind 中运行它。因为服务器经常是被设计为永久运行,这是一个挑战;为克服这个问题,我在服务器上添加了一个 “kill 开关” - 一个从客户端接收的特定序列,以使它可以停止事件循环并退出。这个代码在 `theon_wrote_buf` 句柄中。 + + +[[2]][2] 在这里我们不过多地使用 `work_req`;讨论的素数测试服务器接下来将展示怎么被用于去传递上下文信息到回调中。 + + +[[3]][3] `uv_fs_read()` 提供了一个类似于 preadv Linux 系统调用的通用 API:它使用多缓冲区用于排序,并且支持一个到文件中的偏移。基于我们讨论的目的可以忽略这些特性。 + + +-------------------------------------------------------------------------------- + +via: https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ + +作者:[Eli Bendersky ][a] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://eli.thegreenplace.net/ +[1]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id1 +[2]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id2 +[3]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id3 +[4]:https://eli.thegreenplace.net/tag/concurrency +[5]:https://eli.thegreenplace.net/tag/c-c +[6]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id4 +[7]:http://eli.thegreenplace.net/2017/concurrent-servers-part-1-introduction/ +[8]:http://eli.thegreenplace.net/2017/concurrent-servers-part-2-threads/ +[9]:http://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ +[10]:http://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ +[11]:http://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ +[12]:http://libuv.org/ +[13]:https://github.com/eliben/code-for-blog/blob/master/2017/async-socket-server/uv-server.c +[14]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id5 +[15]:https://github.com/eliben/code-for-blog/blob/master/2017/async-socket-server/uv-isprime-server.c +[16]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id6 +[17]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ From fb45dbb3d739a5ad577f34bfb7b74af9c5d96686 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Mon, 4 Dec 2017 15:38:10 +0800 Subject: [PATCH 195/344] Translated by qhwdw --- ...1109 Concurrent Servers- Part 4 - libuv.md | 492 ------------------ ...1109 Concurrent Servers- Part 4 - libuv.md | 1 + 2 files changed, 1 insertion(+), 492 deletions(-) delete mode 100644 sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md diff --git a/sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md b/sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md deleted file mode 100644 index 94b98cf5c2..0000000000 --- a/sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md +++ /dev/null @@ -1,492 +0,0 @@ -Translating by qhwdw [Concurrent Servers: Part 4 - libuv][17] -============================================================ - -This is part 4 of a series of posts on writing concurrent network servers. In this part we're going to use libuv to rewrite our server once again, and also talk about handling time-consuming tasks in callbacks using a thread pool. Finally, we're going to look under the hood of libuv for a bit to study how it wraps blocking file-system operations with an asynchronous API. - -All posts in the series: - -* [Part 1 - Introduction][7] - -* [Part 2 - Threads][8] - -* [Part 3 - Event-driven][9] - -* [Part 4 - libuv][10] - -### Abstracting away event-driven loops with libuv - -In [part 3][11], we've seen how similar select-based and epoll-based servers are, and I mentioned it's very tempting to abstract away the minor differences between them. Numerous libraries are already doing this, however, so in this part I'm going to pick one and use it. The library I'm picking is [libuv][12], which was originally designed to serve as the underlying portable platform layer for Node.js, and has since found use in additional projects. libuv is written in C, which makes it highly portable and very suitable for tying into high-level languages like JavaScript and Python. - -While libuv has grown to be a fairly large framework for abstracting low-level platform details, it remains centered on the concept of an  _event loop_ . In our event-driven servers in part 3, the event loop was explicit in the main function; when using libuv, the loop is usually hidden inside the library itself, and user code just registers event handlers (as callback functions) and runs the loop. Furthermore, libuv will use the fastest event loop implementation for a given platform: for Linux this is epoll, etc. - -![libuv loop](https://eli.thegreenplace.net/images/2017/libuvloop.png) - -libuv supports multiple event loops, and thus an event loop is a first class citizen within the library; it has a handle - uv_loop_t, and functions for creating/destroying/starting/stopping loops. That said, I will only use the "default" loop in this post, which libuv makes available via uv_default_loop(); multiple loops are mosly useful for multi-threaded event-driven servers, a more advanced topic I'll leave for future parts in the series. - -### A concurrent server using libuv - -To get a better feel for libuv, let's jump to our trusty protocol server that we've been vigorously reimplementing throughout the series. The structure of this server is going to be somewhat similar to the select and epoll-based servers of part 3, since it also relies on callbacks. The full [code sample is here][13]; we start with setting up the server socket bound to a local port: - -``` -int portnum = 9090; -if (argc >= 2) { - portnum = atoi(argv[1]); -} -printf("Serving on port %d\n", portnum); - -int rc; -uv_tcp_t server_stream; -if ((rc = uv_tcp_init(uv_default_loop(), &server_stream)) < 0) { - die("uv_tcp_init failed: %s", uv_strerror(rc)); -} - -struct sockaddr_in server_address; -if ((rc = uv_ip4_addr("0.0.0.0", portnum, &server_address)) < 0) { - die("uv_ip4_addr failed: %s", uv_strerror(rc)); -} - -if ((rc = uv_tcp_bind(&server_stream, (const struct sockaddr*)&server_address, 0)) < 0) { - die("uv_tcp_bind failed: %s", uv_strerror(rc)); -} -``` - -Fairly standard socket fare here, except that it's all wrapped in libuv APIs. In return we get a portable interface that should work on any platform libuv supports. - -This code also demonstrates conscientious error handling; most libuv functions return an integer status, with a negative number meaning an error. In our server we treat these errors as fatals, but one may imagine a more graceful recovery. - -Now that the socket is bound, it's time to listen on it. Here we run into our first callback registration: - -``` -// Listen on the socket for new peers to connect. When a new peer connects, -// the on_peer_connected callback will be invoked. -if ((rc = uv_listen((uv_stream_t*)&server_stream, N_BACKLOG, on_peer_connected)) < 0) { - die("uv_listen failed: %s", uv_strerror(rc)); -} -``` - -uv_listen registers a callback that the event loop will invoke when new peers connect to the socket. Our callback here is called on_peer_connected, and we'll examine it soon. - -Finally, main runs the libuv loop until it's stopped (uv_run only returns when the loop has stopped or some error occurred). - -``` -// Run the libuv event loop. -uv_run(uv_default_loop(), UV_RUN_DEFAULT); - -// If uv_run returned, close the default loop before exiting. -return uv_loop_close(uv_default_loop()); -``` - -Note that only a single callback was registered by main prior to running the event loop; we'll soon see how additional callbacks are added. It's not a problem to add and remove callbacks throughout the runtime of the event loop - in fact, this is how most servers are expected to be written. - -This is on_peer_connected, which handles new client connections to the server: - -``` -void on_peer_connected(uv_stream_t* server_stream, int status) { - if (status < 0) { - fprintf(stderr, "Peer connection error: %s\n", uv_strerror(status)); - return; - } - - // client will represent this peer; it's allocated on the heap and only - // released when the client disconnects. The client holds a pointer to - // peer_state_t in its data field; this peer state tracks the protocol state - // with this client throughout interaction. - uv_tcp_t* client = (uv_tcp_t*)xmalloc(sizeof(*client)); - int rc; - if ((rc = uv_tcp_init(uv_default_loop(), client)) < 0) { - die("uv_tcp_init failed: %s", uv_strerror(rc)); - } - client->data = NULL; - - if (uv_accept(server_stream, (uv_stream_t*)client) == 0) { - struct sockaddr_storage peername; - int namelen = sizeof(peername); - if ((rc = uv_tcp_getpeername(client, (struct sockaddr*)&peername, - &namelen)) < 0) { - die("uv_tcp_getpeername failed: %s", uv_strerror(rc)); - } - report_peer_connected((const struct sockaddr_in*)&peername, namelen); - - // Initialize the peer state for a new client: we start by sending the peer - // the initial '*' ack. - peer_state_t* peerstate = (peer_state_t*)xmalloc(sizeof(*peerstate)); - peerstate->state = INITIAL_ACK; - peerstate->sendbuf[0] = '*'; - peerstate->sendbuf_end = 1; - peerstate->client = client; - client->data = peerstate; - - // Enqueue the write request to send the ack; when it's done, - // on_wrote_init_ack will be called. The peer state is passed to the write - // request via the data pointer; the write request does not own this peer - // state - it's owned by the client handle. - uv_buf_t writebuf = uv_buf_init(peerstate->sendbuf, peerstate->sendbuf_end); - uv_write_t* req = (uv_write_t*)xmalloc(sizeof(*req)); - req->data = peerstate; - if ((rc = uv_write(req, (uv_stream_t*)client, &writebuf, 1, - on_wrote_init_ack)) < 0) { - die("uv_write failed: %s", uv_strerror(rc)); - } - } else { - uv_close((uv_handle_t*)client, on_client_closed); - } -} -``` - -This code is well commented, but there are a couple of important libuv idioms I'd like to highlight: - -* Passing custom data into callbacks: since C has no closures, this can be challenging. libuv has a void* datafield in all its handle types; these fields can be used to pass user data. For example, note how client->data is made to point to a peer_state_t structure so that the callbacks registered by uv_write and uv_read_start can know which peer data they're dealing with. - -* Memory management: event-driven programming is much easier in languages with garbage collection, because callbacks usually run in a completely different stack frame from where they were registered, making stack-based memory management difficult. It's almost always necessary to pass heap-allocated data to libuv callbacks (except in main, which remains alive on the stack when all callbacks run), and to avoid leaks much care is required about when these data are safe to free(). This is something that comes with a bit of practice [[1]][6]. - -The peer state for this server is: - -``` -typedef struct { - ProcessingState state; - char sendbuf[SENDBUF_SIZE]; - int sendbuf_end; - uv_tcp_t* client; -} peer_state_t; -``` - -It's fairly similar to the state in part 3; we no longer need sendptr, since uv_write will make sure to send the whole buffer it's given before invoking the "done writing" callback. We also keep a pointer to the client for other callbacks to use. Here's on_wrote_init_ack: - -``` -void on_wrote_init_ack(uv_write_t* req, int status) { - if (status) { - die("Write error: %s\n", uv_strerror(status)); - } - peer_state_t* peerstate = (peer_state_t*)req->data; - // Flip the peer state to WAIT_FOR_MSG, and start listening for incoming data - // from this peer. - peerstate->state = WAIT_FOR_MSG; - peerstate->sendbuf_end = 0; - - int rc; - if ((rc = uv_read_start((uv_stream_t*)peerstate->client, on_alloc_buffer, - on_peer_read)) < 0) { - die("uv_read_start failed: %s", uv_strerror(rc)); - } - - // Note: the write request doesn't own the peer state, hence we only free the - // request itself, not the state. - free(req); -} -``` - -Then we know for sure that the initial '*' was sent to the peer, we start listening to incoming data from this peer by calling uv_read_start, which registers a callback (on_peer_read) that will be invoked by the event loop whenever new data is received on the socket from the client: - -``` -void on_peer_read(uv_stream_t* client, ssize_t nread, const uv_buf_t* buf) { - if (nread < 0) { - if (nread != uv_eof) { - fprintf(stderr, "read error: %s\n", uv_strerror(nread)); - } - uv_close((uv_handle_t*)client, on_client_closed); - } else if (nread == 0) { - // from the documentation of uv_read_cb: nread might be 0, which does not - // indicate an error or eof. this is equivalent to eagain or ewouldblock - // under read(2). - } else { - // nread > 0 - assert(buf->len >= nread); - - peer_state_t* peerstate = (peer_state_t*)client->data; - if (peerstate->state == initial_ack) { - // if the initial ack hasn't been sent for some reason, ignore whatever - // the client sends in. - free(buf->base); - return; - } - - // run the protocol state machine. - for (int i = 0; i < nread; ++i) { - switch (peerstate->state) { - case initial_ack: - assert(0 && "can't reach here"); - break; - case wait_for_msg: - if (buf->base[i] == '^') { - peerstate->state = in_msg; - } - break; - case in_msg: - if (buf->base[i] == '$') { - peerstate->state = wait_for_msg; - } else { - assert(peerstate->sendbuf_end < sendbuf_size); - peerstate->sendbuf[peerstate->sendbuf_end++] = buf->base[i] + 1; - } - break; - } - } - - if (peerstate->sendbuf_end > 0) { - // we have data to send. the write buffer will point to the buffer stored - // in the peer state for this client. - uv_buf_t writebuf = - uv_buf_init(peerstate->sendbuf, peerstate->sendbuf_end); - uv_write_t* writereq = (uv_write_t*)xmalloc(sizeof(*writereq)); - writereq->data = peerstate; - int rc; - if ((rc = uv_write(writereq, (uv_stream_t*)client, &writebuf, 1, - on_wrote_buf)) < 0) { - die("uv_write failed: %s", uv_strerror(rc)); - } - } - } - free(buf->base); -} -``` - -The runtime behavior of this server is very similar to the event-driven servers of part 3: all clients are handled concurrently in a single thread. Also similarly, a certain discipline has to be maintained in the server's code: the server's logic is implemented as an ensemble of callbacks, and long-running operations are a big no-no since they block the event loop. Let's explore this issue a bit further. - -### Long-running operations in event-driven loops - -The single-threaded nature of event-driven code makes it very susceptible to a common issue: long-running code blocks the entire loop. Consider this program: - -``` -void on_timer(uv_timer_t* timer) { - uint64_t timestamp = uv_hrtime(); - printf("on_timer [%" PRIu64 " ms]\n", (timestamp / 1000000) % 100000); - - // "Work" - if (random() % 5 == 0) { - printf("Sleeping...\n"); - sleep(3); - } -} - -int main(int argc, const char** argv) { - uv_timer_t timer; - uv_timer_init(uv_default_loop(), &timer); - uv_timer_start(&timer, on_timer, 0, 1000); - return uv_run(uv_default_loop(), UV_RUN_DEFAULT); -} -``` - -It runs a libuv event loop with a single registered callback: on_timer, which is invoked by the loop every second. The callback reports a timestamp, and once in a while simulates some long-running task by sleeping for 3 seconds. Here's a sample run: - -``` -$ ./uv-timer-sleep-demo -on_timer [4840 ms] -on_timer [5842 ms] -on_timer [6843 ms] -on_timer [7844 ms] -Sleeping... -on_timer [11845 ms] -on_timer [12846 ms] -Sleeping... -on_timer [16847 ms] -on_timer [17849 ms] -on_timer [18850 ms] -... -``` - -on_timer dutifully fires every second, until the random sleep hits in. At that point, on_timer is not invoked again until the sleep is over; in fact,  _no other callbacks_  will be invoked in this time frame. The sleep call blocks the current thread, which is the only thread involved and is also the thread the event loop uses. When this thread is blocked, the event loop is blocked. - -This example demonstrates why it's so important for callbacks to never block in event-driven calls, and applies equally to Node.js servers, client-side Javascript, most GUI programming frameworks, and many other asynchronous programming models. - -But sometimes running time-consuming tasks is unavoidable. Not all tasks have asynchronous APIs; for example, we may be dealing with some library that only has a synchronous API, or just have to perform a potentially long computation. How can we combine such code with event-driven programming? Threads to the rescue! - -### Threads for "converting" blocking calls into asynchronous calls - -A thread pool can be used to turn blocking calls into asynchronous calls, by running alongside the event loop and posting events onto it when tasks are completed. Here's how it works, for a given blocking function do_work(): - -1. Instead of directly calling do_work() in a callback, we package it into a "task" and ask the thread pool to execute the task. We also register a callback for the loop to invoke when the task has finished; let's call iton_work_done(). - -2. At this point our callback can return and the event loop keeps spinning; at the same time, a thread in the pool is executing the task. - -3. Once the task has finished executing, the main thread (the one running the event loop) is notified and on_work_done() is invoked by the event loop. - -Let's see how this solves our previous timer/sleep example, using libuv's work scheduling API: - -``` -void on_after_work(uv_work_t* req, int status) { - free(req); -} - -void on_work(uv_work_t* req) { - // "Work" - if (random() % 5 == 0) { - printf("Sleeping...\n"); - sleep(3); - } -} - -void on_timer(uv_timer_t* timer) { - uint64_t timestamp = uv_hrtime(); - printf("on_timer [%" PRIu64 " ms]\n", (timestamp / 1000000) % 100000); - - uv_work_t* work_req = (uv_work_t*)malloc(sizeof(*work_req)); - uv_queue_work(uv_default_loop(), work_req, on_work, on_after_work); -} - -int main(int argc, const char** argv) { - uv_timer_t timer; - uv_timer_init(uv_default_loop(), &timer); - uv_timer_start(&timer, on_timer, 0, 1000); - return uv_run(uv_default_loop(), UV_RUN_DEFAULT); -} -``` - -Instead of calling sleep directly in on_timer, we enqueue a task, represented by a handle of type work_req [[2]][14], the function to run in the task (on_work) and the function to invoke once the task is completed (on_after_work). on_workis where the "work" (the blocking/time-consuming operation) happens. Note a crucial difference between the two callbacks passed into uv_queue_work: on_work runs in the thread pool, while on_after_work runs on the main thread which also runs the event loop - just like any other callback. - -Let's see this version run: - -``` -$ ./uv-timer-work-demo -on_timer [89571 ms] -on_timer [90572 ms] -on_timer [91573 ms] -on_timer [92575 ms] -Sleeping... -on_timer [93576 ms] -on_timer [94577 ms] -Sleeping... -on_timer [95577 ms] -on_timer [96578 ms] -on_timer [97578 ms] -... -``` - -The timer ticks every second, even though the sleeping function is still invoked; sleeping is now done on a separate thread and doesn't block the event loop. - -### A primality-testing server, with exercises - -Since sleep isn't a very exciting way to simulate work, I've prepared a more comprehensive example - a server that accepts numbers from clients over a socket, checks whether these numbers are prime and sends back either "prime" or "composite". The full [code for this server is here][15] - I won't post it here since it's long, but will rather give readers the opportunity to explore it on their own with a couple of exercises. - -The server deliberatly uses a naive primality test algorithm, so for large primes it can take quite a while to return an answer. On my machine it takes ~5 seconds to compute the answer for 2305843009213693951, but YMMV. - -Exercise 1: the server has a setting (via an environment variable named MODE) to either run the primality test in the socket callback (meaning on the main thread) or in the libuv work queue. Play with this setting to observe the server's behavior when multiple clients are connecting simultaneously. In blocking mode, the server will not answer other clients while it's computing a big task; in non-blocking mode it will. - -Exercise 2: libuv has a default thread-pool size, and it can be configured via an environment variable. Can you use multiple clients to discover experimentally what the default size is? Having found the default thread-pool size, play with different settings to see how it affects the server's responsiveness under heavy load. - -### Non-blocking file-system operations using work queues - -Delegating potentially-blocking operations to a thread pool isn't good for just silly demos and CPU-intensive computations; libuv itself makes heavy use of this capability in its file-system APIs. This way, libuv accomplishes the superpower of exposing the file-system with an asynchronous API, in a portable way. - -Let's take uv_fs_read(), for example. This function reads from a file (represented by a uv_fs_t handle) into a buffer [[3]][16], and invokes a callback when the reading is completed. That is, uv_fs_read() always returns immediately, even if the file sits on an NFS-like system and it may take a while for the data to get to the buffer. In other words, this API is asynchronous in the way other libuv APIs are. How does this work? - -At this point we're going to look under the hood of libuv; the internals are actually fairly straightforward, and it's a good exercise. Being a portable library, libuv has different implementations of many of its functions for Windows and Unix systems. We're going to be looking at src/unix/fs.c in the libuv source tree. - -The code for uv_fs_read is: - -``` -int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t off, - uv_fs_cb cb) { - if (bufs == NULL || nbufs == 0) - return -EINVAL; - - INIT(READ); - req->file = file; - - req->nbufs = nbufs; - req->bufs = req->bufsml; - if (nbufs > ARRAY_SIZE(req->bufsml)) - req->bufs = uv__malloc(nbufs * sizeof(*bufs)); - - if (req->bufs == NULL) { - if (cb != NULL) - uv__req_unregister(loop, req); - return -ENOMEM; - } - - memcpy(req->bufs, bufs, nbufs * sizeof(*bufs)); - - req->off = off; - POST; -} -``` - -It may seem puzzling at first, because it defers the real work to the INIT and POST macros, with some local variable setup for POST. This is done to avoid too much code duplication within the file. - -The INIT macro is: - -``` -#define INIT(subtype) \ - do { \ - req->type = UV_FS; \ - if (cb != NULL) \ - uv__req_init(loop, req, UV_FS); \ - req->fs_type = UV_FS_ ## subtype; \ - req->result = 0; \ - req->ptr = NULL; \ - req->loop = loop; \ - req->path = NULL; \ - req->new_path = NULL; \ - req->cb = cb; \ - } \ - while (0) -``` - -It sets up the request, and most importantly sets the req->fs_type field to the actual FS request type. Since uv_fs_read invokes INIT(READ), it means req->fs_type gets assigned the constant UV_FS_READ. - -The POST macro is: - -``` -#define POST \ - do { \ - if (cb != NULL) { \ - uv__work_submit(loop, &req->work_req, uv__fs_work, uv__fs_done); \ - return 0; \ - } \ - else { \ - uv__fs_work(&req->work_req); \ - return req->result; \ - } \ - } \ - while (0) -``` - -What it does depends on whether the callback is NULL. In libuv file-system APIs, a NULL callback means we actually want to perform the operation  _synchronously_ . In this case POST invokes uv__fs_work directly (we'll get to what this function does in just a bit), whereas for a non-NULL callback, it submits uv__fs_work as a work item to the work queue (which is the thread pool), and registers uv__fs_done as the callback; that function does a bit of book-keeping and invokes the user-provided callback. - -If we look at the code of uv__fs_work, we'll see it uses more macros to route work to the actual file-system call as needed. In our case, for UV_FS_READ the call will be made to uv__fs_read, which (at last!) does the reading using regular POSIX APIs. This function can be safely implemented in a  _blocking_  manner, since it's placed on a thread-pool when called through the asynchronous API. - -In Node.js, the fs.readFile function is mapped to uv_fs_read. Thus, reading files can be done in a non-blocking fashion even though the underlying file-system API is blocking. - -* * * - - -[[1]][1] To ensure that this server doesn't leak memory, I ran it under Valgrind with the leak checker enabled. Since servers are often designed to run forever, this was a bit challenging; to overcome this issue I've added a "kill switch" to the server - a special sequence received from a client makes it stop the event loop and exit. The code for this is in theon_wrote_buf handler. - - -[[2]][2] Here we don't use work_req for much; the primality testing server discussed next will show how it's used to pass context information into the callback. - - -[[3]][3] uv_fs_read() provides a generalized API similar to the preadv Linux system call: it takes multiple buffers which it fills in order, and supports an offset into the file. We can ignore these features for the sake of our discussion. - - --------------------------------------------------------------------------------- - -via: https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ - -作者:[Eli Bendersky ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://eli.thegreenplace.net/ -[1]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id1 -[2]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id2 -[3]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id3 -[4]:https://eli.thegreenplace.net/tag/concurrency -[5]:https://eli.thegreenplace.net/tag/c-c -[6]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id4 -[7]:http://eli.thegreenplace.net/2017/concurrent-servers-part-1-introduction/ -[8]:http://eli.thegreenplace.net/2017/concurrent-servers-part-2-threads/ -[9]:http://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ -[10]:http://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ -[11]:http://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ -[12]:http://libuv.org/ -[13]:https://github.com/eliben/code-for-blog/blob/master/2017/async-socket-server/uv-server.c -[14]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id5 -[15]:https://github.com/eliben/code-for-blog/blob/master/2017/async-socket-server/uv-isprime-server.c -[16]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id6 -[17]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ diff --git a/translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md b/translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md index b4db491e4e..07994c67b1 100644 --- a/translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md +++ b/translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md @@ -490,3 +490,4 @@ via: https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ [15]:https://github.com/eliben/code-for-blog/blob/master/2017/async-socket-server/uv-isprime-server.c [16]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id6 [17]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ + From 11e1c8c450f35378d5e24449e15628748ad98053 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 17:21:41 +0800 Subject: [PATCH 196/344] Revert "Merge branch 'master' of https://github.com/LCTT/TranslateProject" This reverts commit 59837a2677e18ebf7eb3c0a586662c72098fd1e1, reversing changes made to fb45dbb3d739a5ad577f34bfb7b74af9c5d96686. --- .../20141028 When Does Your OS Run.md | 0 ... Firewalld in Multi-Zone Configurations.md | 0 .../20170227 Ubuntu Core in LXD containers.md | 0 ... THE SOFTWARE CONTAINERIZATION MOVEMENT.md | 0 ...ner OS for Linux and Windows Containers.md | 0 ... Life-Changing Magic of Tidying Up Code.md | 0 ... guide to links in the Linux filesystem.md | 300 -------- ...ldcard Certificates Coming January 2018.md | 0 ...andy Tool for Every Level of Linux User.md | 0 ...GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md | 0 ...0928 3 Python web scrapers and crawlers.md | 0 .../20171002 Scaling the GitLab database.md | 0 ...3 PostgreSQL Hash Indexes Are Now Cool.md | 0 ...inux desktop hasnt jumped in popularity.md | 0 ...ant 100 command line productivity boost.md | 0 ...20171008 8 best languages to blog about.md | 0 ...ext Generation of Cybersecurity Experts.md | 0 ...itter Data in Apache Kafka through KSQL.md | 0 ...p a Postgres database on a Raspberry Pi.md | 0 .../{201711 => }/20171011 Why Linux Works.md | 0 ...easons open source is good for business.md | 0 ...71013 Best of PostgreSQL 10 for the DBA.md | 0 ... cloud-native computing with Kubernetes.md | 0 ...5 Monitoring Slow SQL Queries via Slack.md | 0 ... Use Docker with R A DevOps Perspective.md | 0 .../20171016 Introducing CRI-O 1.0.md | 0 ...20171017 A tour of Postgres Index Types.md | 0 .../20171017 Image Processing on Linux.md | 0 ...iners and microservices change security.md | 0 ...n Python by building a simple dice game.md | 0 ...ecure Your Network in the Wake of KRACK.md | 0 ...Simple Excellent Linux Network Monitors.md | 0 ...cker containers in Kubernetes with Java.md | 0 ...ols to Help You Remember Linux Commands.md | 0 ...ndroid on Top of a Linux Graphics Stack.md | 0 ...0171024 Top 5 Linux pain points in 2017.md | 0 ...et s analyze GitHub’s data and find out.md | 0 ...u Drop Unity Mark Shuttleworth Explains.md | 0 ...Backup, Rclone and Wasabi cloud storage.md | 0 ...26 But I dont know what a container is .md | 0 .../20171026 Why is Kubernetes so popular.md | 0 .../20171101 How to use cron in Linux.md | 0 ... to a DCO for source code contributions.md | 0 ...nage EXT2 EXT3 and EXT4 Health in Linux.md | 0 .../20171106 Finding Files with mlocate.md | 0 ...Publishes Enterprise Open Source Guides.md | 0 ...mmunity clue. Here s how to do it right.md | 0 ...dopts home-brewed KVM as new hypervisor.md | 0 ... created my first RPM package in Fedora.md | 0 ...est applications with Ansible Container.md | 0 ...71110 File better bugs with coredumpctl.md | 0 ... ​Linux totally dominates supercomputers.md | 0 ...1116 5 Coolest Linux Terminal Emulators.md | 0 ...7 How to Easily Remember Linux Commands.md | 0 ...tting started with OpenFaaS on minikube.md | 0 ...20 Containers and Kubernetes Whats next.md | 81 -- ...Install Android File Transfer for Linux.md | 75 -- ...and Certification Are Key for SysAdmins.md | 72 -- ...our Terminal Session To Anyone In Seconds.md | 0 ...Search DuckDuckGo from the Command Line.md | 97 --- ...The One in Which I Call Out Hacker News.md | 86 +++ ...nject features and investigate programs.md | 211 ------ ...an event Introducing eBPF Kernel probes.md | 361 --------- ...sers guide to Logical Volume Management.md | 233 ------ ...9 INTRODUCING DOCKER SECRETS MANAGEMENT.md | 110 --- ...170530 How to Improve a Legacy Codebase.md | 108 +++ ...es Are Hiring Computer Security Experts.md | 91 --- ... guide to links in the Linux filesystem.md | 314 ++++++++ ...ow to answer questions in a helpful way.md | 172 ----- ...Linux containers with Ansible Container.md | 114 --- .../20171005 Reasons Kubernetes is cool.md | 148 ---- ...20171010 Operating a Kubernetes network.md | 216 ------ ...LEAST PRIVILEGE CONTAINER ORCHESTRATION.md | 174 ----- ...ow Eclipse is advancing IoT development.md | 83 ++ ...ive into BPF a list of reading material.md | 711 ------------------ .../20171107 GitHub welcomes all CI tools.md | 95 --- sources/tech/20171112 Love Your Bugs.md | 311 -------- ... write fun small web projects instantly.md | 76 -- .../20171114 Sysadmin 101 Patch Management.md | 61 -- .../20171114 Take Linux and Run With It.md | 68 -- ...obs Are Hot Get Trained and Get Noticed.md | 58 -- ... and How to Set an Open Source Strategy.md | 120 --- ...ux Programs for Drawing and Image Editing.md | 130 ---- ...171120 Adopting Kubernetes step by step.md | 93 --- ...20 Containers and Kubernetes Whats next.md | 98 +++ ... Why microservices are a security issue.md | 116 --- ...and Certification Are Key for SysAdmins.md | 70 ++ ...Could Be Your New Favorite Container OS.md | 7 +- ...Help Build ONNX Open Source AI Platform.md | 76 -- ... Your Linux Server Has Been Compromised.md | 156 ---- ...71128 The politics of the Linux desktop.md | 110 --- ... a great pair for beginning programmers.md | 142 ---- ... open source technology trends for 2018.md | 143 ---- ...actices for getting started with DevOps.md | 94 --- ...eshark on Debian and Ubuntu 16.04_17.10.md | 185 ----- ...n Source Components Ease Learning Curve.md | 70 -- ...eractive Workflows for Cpp with Jupyter.md | 301 -------- ...Unity from the Dead as an Official Spin.md | 41 - ...usiness Software Alternatives For Linux.md | 116 --- ...x command-line screen grabs made simple.md | 108 --- ...Search DuckDuckGo from the Command Line.md | 103 +++ ...Long Running Terminal Commands Complete.md | 156 ---- ...ke up and Shut Down Linux Automatically.md | 135 ---- ...1 Fedora Classroom Session: Ansible 101.md | 71 -- ...ow to Manage Users with Groups in Linux.md | 168 ----- ... to find a publisher for your tech book.md | 76 -- ...e your WiFi MAC address on Ubuntu 16.04.md | 160 ---- ... millions of Linux users with Snapcraft.md | 321 -------- ...inux command-line screen grabs made simple | 72 -- ...0171202 docker - Use multi-stage builds.md | 127 ---- ...The One in Which I Call Out Hacker News.md | 99 --- ...20161216 Kprobes Event Tracing on ARMv8.md | 16 +- ...170530 How to Improve a Legacy Codebase.md | 104 --- .../20170910 Cool vim feature sessions.md | 44 -- ...ng network connections on Linux systems.md | 0 ...ow Eclipse is advancing IoT development.md | 77 -- ...layer introduction part 1 the bio layer.md | 13 +- .../tech/20171108 Archiving repositories.md | 37 - ...6 Introducing security alerts on GitHub.md | 48 -- ...stem Logs: Understand Your Linux System.md | 68 -- ...Install Android File Transfer for Linux.md | 82 ++ ...Could Be Your New Favorite Container OS.md | 147 ---- ...every domain someone owns automatically.md | 49 -- ...ogle Translate From Command Line In Linux.md | 400 ---------- ...171201 Linux Journal Ceases Publication.md | 34 - ...ing Hardware for Beginners: Think Software | 89 --- 126 files changed, 960 insertions(+), 8338 deletions(-) rename published/{201711 => }/20141028 When Does Your OS Run.md (100%) rename published/{201711 => }/20170202 Understanding Firewalld in Multi-Zone Configurations.md (100%) rename published/{201711 => }/20170227 Ubuntu Core in LXD containers.md (100%) rename published/{201711 => }/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md (100%) rename published/{201711 => }/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md (100%) rename published/{201711 => }/20170608 The Life-Changing Magic of Tidying Up Code.md (100%) delete mode 100644 published/20170622 A users guide to links in the Linux filesystem.md rename published/{201711 => }/20170706 Wildcard Certificates Coming January 2018.md (100%) rename published/{201711 => }/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md (100%) rename published/{201711 => }/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md (100%) rename published/{201711 => }/20170928 3 Python web scrapers and crawlers.md (100%) rename published/{201711 => }/20171002 Scaling the GitLab database.md (100%) rename published/{201711 => }/20171003 PostgreSQL Hash Indexes Are Now Cool.md (100%) rename published/{201711 => }/20171004 No the Linux desktop hasnt jumped in popularity.md (100%) rename published/{201711 => }/20171007 Instant 100 command line productivity boost.md (100%) rename published/{201711 => }/20171008 8 best languages to blog about.md (100%) rename published/{201711 => }/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md (100%) rename published/{201711 => }/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md (100%) rename published/{201711 => }/20171011 How to set up a Postgres database on a Raspberry Pi.md (100%) rename published/{201711 => }/20171011 Why Linux Works.md (100%) rename published/{201711 => }/20171013 6 reasons open source is good for business.md (100%) rename published/{201711 => }/20171013 Best of PostgreSQL 10 for the DBA.md (100%) rename published/{201711 => }/20171015 How to implement cloud-native computing with Kubernetes.md (100%) rename published/{201711 => }/20171015 Monitoring Slow SQL Queries via Slack.md (100%) rename published/{201711 => }/20171015 Why Use Docker with R A DevOps Perspective.md (100%) rename published/{201711 => }/20171016 Introducing CRI-O 1.0.md (100%) rename published/{201711 => }/20171017 A tour of Postgres Index Types.md (100%) rename published/{201711 => }/20171017 Image Processing on Linux.md (100%) rename published/{201711 => }/20171018 How containers and microservices change security.md (100%) rename published/{201711 => }/20171018 Learn how to program in Python by building a simple dice game.md (100%) rename published/{201711 => }/20171018 Tips to Secure Your Network in the Wake of KRACK.md (100%) rename published/{201711 => }/20171019 3 Simple Excellent Linux Network Monitors.md (100%) rename published/{201711 => }/20171019 How to manage Docker containers in Kubernetes with Java.md (100%) rename published/{201711 => }/20171020 3 Tools to Help You Remember Linux Commands.md (100%) rename published/{201711 => }/20171020 Running Android on Top of a Linux Graphics Stack.md (100%) rename published/{201711 => }/20171024 Top 5 Linux pain points in 2017.md (100%) rename published/{201711 => }/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md (100%) rename published/{201711 => }/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md (100%) rename published/{201711 => }/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md (100%) rename published/{201711 => }/20171026 But I dont know what a container is .md (100%) rename published/{201711 => }/20171026 Why is Kubernetes so popular.md (100%) rename published/{201711 => }/20171101 How to use cron in Linux.md (100%) rename published/{201711 => }/20171101 We re switching to a DCO for source code contributions.md (100%) rename published/{201711 => }/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md (100%) rename published/{201711 => }/20171106 Finding Files with mlocate.md (100%) rename published/{201711 => }/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md (100%) rename published/{201711 => }/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md (100%) rename published/{201711 => }/20171107 AWS adopts home-brewed KVM as new hypervisor.md (100%) rename published/{201711 => }/20171107 How I created my first RPM package in Fedora.md (100%) rename published/{201711 => }/20171108 Build and test applications with Ansible Container.md (100%) rename published/{201711 => }/20171110 File better bugs with coredumpctl.md (100%) rename published/{201711 => }/20171114 ​Linux totally dominates supercomputers.md (100%) rename published/{201711 => }/20171116 5 Coolest Linux Terminal Emulators.md (100%) rename published/{201711 => }/20171117 How to Easily Remember Linux Commands.md (100%) rename published/{201711 => }/20171118 Getting started with OpenFaaS on minikube.md (100%) delete mode 100644 published/20171120 Containers and Kubernetes Whats next.md delete mode 100644 published/20171124 How to Install Android File Transfer for Linux.md delete mode 100644 published/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md rename published/{201711 => }/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md (100%) delete mode 100644 published/20171130 Search DuckDuckGo from the Command Line.md create mode 100644 sources/tech/20090701 The One in Which I Call Out Hacker News.md delete mode 100644 sources/tech/20130402 Dynamic linker tricks Using LD_PRELOAD to cheat inject features and investigate programs.md delete mode 100644 sources/tech/20160330 How to turn any syscall into an event Introducing eBPF Kernel probes.md delete mode 100644 sources/tech/20160922 A Linux users guide to Logical Volume Management.md delete mode 100644 sources/tech/20170209 INTRODUCING DOCKER SECRETS MANAGEMENT.md create mode 100644 sources/tech/20170530 How to Improve a Legacy Codebase.md delete mode 100644 sources/tech/20170607 Why Car Companies Are Hiring Computer Security Experts.md create mode 100644 sources/tech/20170622 A users guide to links in the Linux filesystem.md delete mode 100644 sources/tech/20170921 How to answer questions in a helpful way.md delete mode 100644 sources/tech/20171005 How to manage Linux containers with Ansible Container.md delete mode 100644 sources/tech/20171005 Reasons Kubernetes is cool.md delete mode 100644 sources/tech/20171010 Operating a Kubernetes network.md delete mode 100644 sources/tech/20171011 LEAST PRIVILEGE CONTAINER ORCHESTRATION.md create mode 100644 sources/tech/20171020 How Eclipse is advancing IoT development.md delete mode 100644 sources/tech/20171102 Dive into BPF a list of reading material.md delete mode 100644 sources/tech/20171107 GitHub welcomes all CI tools.md delete mode 100644 sources/tech/20171112 Love Your Bugs.md delete mode 100644 sources/tech/20171113 Glitch write fun small web projects instantly.md delete mode 100644 sources/tech/20171114 Sysadmin 101 Patch Management.md delete mode 100644 sources/tech/20171114 Take Linux and Run With It.md delete mode 100644 sources/tech/20171115 Security Jobs Are Hot Get Trained and Get Noticed.md delete mode 100644 sources/tech/20171115 Why and How to Set an Open Source Strategy.md delete mode 100644 sources/tech/20171116 Unleash Your Creativity – Linux Programs for Drawing and Image Editing.md delete mode 100644 sources/tech/20171120 Adopting Kubernetes step by step.md create mode 100644 sources/tech/20171120 Containers and Kubernetes Whats next.md delete mode 100644 sources/tech/20171123 Why microservices are a security issue.md create mode 100644 sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md delete mode 100644 sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md delete mode 100644 sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md delete mode 100644 sources/tech/20171128 The politics of the Linux desktop.md delete mode 100644 sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md delete mode 100644 sources/tech/20171129 10 open source technology trends for 2018.md delete mode 100644 sources/tech/20171129 5 best practices for getting started with DevOps.md delete mode 100644 sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md delete mode 100644 sources/tech/20171129 Inside AGL Familiar Open Source Components Ease Learning Curve.md delete mode 100644 sources/tech/20171129 Interactive Workflows for Cpp with Jupyter.md delete mode 100644 sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md delete mode 100644 sources/tech/20171130 Excellent Business Software Alternatives For Linux.md delete mode 100644 sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md create mode 100644 sources/tech/20171130 Search DuckDuckGo from the Command Line.md delete mode 100644 sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md delete mode 100644 sources/tech/20171130 Wake up and Shut Down Linux Automatically.md delete mode 100644 sources/tech/20171201 Fedora Classroom Session: Ansible 101.md delete mode 100644 sources/tech/20171201 How to Manage Users with Groups in Linux.md delete mode 100644 sources/tech/20171201 How to find a publisher for your tech book.md delete mode 100644 sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md delete mode 100644 sources/tech/20171202 Easily control delivery of your Python applications to millions of Linux users with Snapcraft.md delete mode 100644 sources/tech/20171202 Scrot Linux command-line screen grabs made simple delete mode 100644 sources/tech/20171202 docker - Use multi-stage builds.md delete mode 100644 translated/tech/20090701 The One in Which I Call Out Hacker News.md rename {published => translated/tech}/20161216 Kprobes Event Tracing on ARMv8.md (98%) delete mode 100644 translated/tech/20170530 How to Improve a Legacy Codebase.md delete mode 100644 translated/tech/20170910 Cool vim feature sessions.md rename {published => translated/tech}/20171009 Examining network connections on Linux systems.md (100%) delete mode 100644 translated/tech/20171020 How Eclipse is advancing IoT development.md rename {published => translated/tech}/20171029 A block layer introduction part 1 the bio layer.md (95%) delete mode 100644 translated/tech/20171108 Archiving repositories.md delete mode 100644 translated/tech/20171116 Introducing security alerts on GitHub.md delete mode 100644 translated/tech/20171117 System Logs: Understand Your Linux System.md create mode 100644 translated/tech/20171124 How to Install Android File Transfer for Linux.md delete mode 100644 translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md delete mode 100644 translated/tech/20171130 New Feature Find every domain someone owns automatically.md delete mode 100644 translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md delete mode 100644 translated/tech/20171201 Linux Journal Ceases Publication.md delete mode 100644 translated/tech/Linux Networking Hardware for Beginners: Think Software diff --git a/published/201711/20141028 When Does Your OS Run.md b/published/20141028 When Does Your OS Run.md similarity index 100% rename from published/201711/20141028 When Does Your OS Run.md rename to published/20141028 When Does Your OS Run.md diff --git a/published/201711/20170202 Understanding Firewalld in Multi-Zone Configurations.md b/published/20170202 Understanding Firewalld in Multi-Zone Configurations.md similarity index 100% rename from published/201711/20170202 Understanding Firewalld in Multi-Zone Configurations.md rename to published/20170202 Understanding Firewalld in Multi-Zone Configurations.md diff --git a/published/201711/20170227 Ubuntu Core in LXD containers.md b/published/20170227 Ubuntu Core in LXD containers.md similarity index 100% rename from published/201711/20170227 Ubuntu Core in LXD containers.md rename to published/20170227 Ubuntu Core in LXD containers.md diff --git a/published/201711/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md b/published/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md similarity index 100% rename from published/201711/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md rename to published/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md diff --git a/published/201711/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md b/published/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md similarity index 100% rename from published/201711/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md rename to published/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md diff --git a/published/201711/20170608 The Life-Changing Magic of Tidying Up Code.md b/published/20170608 The Life-Changing Magic of Tidying Up Code.md similarity index 100% rename from published/201711/20170608 The Life-Changing Magic of Tidying Up Code.md rename to published/20170608 The Life-Changing Magic of Tidying Up Code.md diff --git a/published/20170622 A users guide to links in the Linux filesystem.md b/published/20170622 A users guide to links in the Linux filesystem.md deleted file mode 100644 index 7d731693d8..0000000000 --- a/published/20170622 A users guide to links in the Linux filesystem.md +++ /dev/null @@ -1,300 +0,0 @@ -用户指南:Linux 文件系统的链接 -============================================================ - -> 学习如何使用链接,通过从 Linux 文件系统多个位置来访问文件,可以让日常工作变得轻松。 - -![linux 文件链接用户指南](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/links.png?itok=enaPOi4L "A user's guide to links in the Linux filesystem") - -Image by : [Paul Lewin][8]. Modified by Opensource.com. [CC BY-SA 2.0][9] - -在我为 opensource.com 写过的关于 Linux 文件系统方方面面的文章中,包括 [Linux 的 EXT4 文件系统的历史、特性以及最佳实践][10]; [在 Linux 中管理设备][11];[Linux 文件系统概览][12] 和 [用户指南:逻辑卷管理][13],我曾简要的提到过 Linux 文件系统一个有趣的特性,它允许用户从多个位置来访问 Linux 文件目录树中的文件来简化一些任务。 - -Linux 文件系统中有两种链接link硬链接hard link软链接soft link。虽然二者差别显著,但都用来解决相似的问题。它们都提供了对单个文件的多个目录项(引用)的访问,但实现却大为不同。链接的强大功能赋予了 Linux 文件系统灵活性,因为[一切皆是文件][14]。 - -举个例子,我曾发现一些程序要求特定的版本库方可运行。 当用升级后的库替代旧库后,程序会崩溃,提示旧版本库缺失。通常,库名的唯一变化就是版本号。出于直觉,我仅仅给程序添加了一个新的库链接,并以旧库名称命名。我试着再次启动程序,运行良好。程序就是一个游戏,人人都明白,每个玩家都会尽力使游戏进行下去。 - -事实上,几乎所有的应用程序链接库都使用通用的命名规则,链接名称中包含了主版本号,链接所指向的文件的文件名中同样包含了小版本号。再比如,程序的一些必需文件为了迎合 Linux 文件系统规范,从一个目录移动到另一个目录中,系统为了向后兼容那些不能获取这些文件新位置的程序在旧的目录中存放了这些文件的链接。如果你对 `/lib64` 目录做一个长清单列表,你会发现很多这样的例子。 - -``` -lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.hwm -> ../../usr/share/cracklib/pw_dict.hwm -lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.pwd -> ../../usr/share/cracklib/pw_dict.pwd -lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.pwi -> ../../usr/share/cracklib/pw_dict.pwi -lrwxrwxrwx. 1 root root 27 Jun 9 2016 libaccountsservice.so.0 -> libaccountsservice.so.0.0.0 --rwxr-xr-x. 1 root root 288456 Jun 9 2016 libaccountsservice.so.0.0.0 -lrwxrwxrwx 1 root root 15 May 17 11:47 libacl.so.1 -> libacl.so.1.1.0 --rwxr-xr-x 1 root root 36472 May 17 11:47 libacl.so.1.1.0 -lrwxrwxrwx. 1 root root 15 Feb 4 2016 libaio.so.1 -> libaio.so.1.0.1 --rwxr-xr-x. 1 root root 6224 Feb 4 2016 libaio.so.1.0.0 --rwxr-xr-x. 1 root root 6224 Feb 4 2016 libaio.so.1.0.1 -lrwxrwxrwx. 1 root root 30 Jan 16 16:39 libakonadi-calendar.so.4 -> libakonadi-calendar.so.4.14.26 --rwxr-xr-x. 1 root root 816160 Jan 16 16:39 libakonadi-calendar.so.4.14.26 -lrwxrwxrwx. 1 root root 29 Jan 16 16:39 libakonadi-contact.so.4 -> libakonadi-contact.so.4.14.26 -``` - -`/lib64` 目录下的一些链接 - -在上面展示的 `/lib64` 目录清单列表中,文件模式第一个字母 `l` (小写字母 l)表示这是一个软链接(又称符号链接)。 - -### 硬链接 - -在 [Linux 的 EXT4 文件系统的历史、特性以及最佳实践][15]一文中,我曾探讨过这样一个事实,每个文件都有一个包含该文件信息的 inode,包含了该文件的位置信息。上述文章中的[图2][16]展示了一个指向 inode 的单一目录项。每个文件都至少有一个目录项指向描述该文件信息的 inode ,目录项是一个硬链接,因此每个文件至少都有一个硬链接。 - -如下图 1 所示,多个目录项指向了同一 inode 。这些目录项都是硬链接。我曾在三个目录项中使用波浪线 (`~`) 的缩写,这是用户目录的惯例表示,因此在该例中波浪线等同于 `/home/user` 。值得注意的是,第四个目录项是一个完全不同的目录,`/home/shared`,可能是该计算机上用户的共享文件目录。 - -![fig1directory_entries.png](https://opensource.com/sites/default/files/images/life/fig1directory_entries.png) - -*图 1* - -硬链接被限制在一个单一的文件系统中。此处的“文件系统” 是指挂载在特定挂载点上的分区或逻辑卷,此例中是 `/home`。这是因为在每个文件系统中的 inode 号都是唯一的。而在不同的文件系统中,如 `/var` 或 `/opt`,会有和 `/home` 中相同的 inode 号。 - -因为所有的硬链接都指向了包含文件元信息的单一 inode ,这些属性都是文件的一部分,像所属关系、权限、到该 inode 的硬链接数目,对每个硬链接来说这些特性没有什么不同的。这是一个文件所具有的一组属性。唯一能区分这些文件的是包含在 inode 信息中的文件名。链接到同一目录中的单一文件/ inode 的硬链接必须拥有不同的文件名,这是基于同一目录下不能存在重复的文件名的事实的。 - -文件的硬链接数目可通过 `ls -l` 来查看,如果你想查看实际节点号,可使用 `ls -li` 命令。 - -### 符号(软)链接 - -硬链接和软链接(也称为符号链接symlink)的区别在于,硬链接直接指向属于该文件的 inode ,而软链接直接指向一个目录项,即指向一个硬链接。因为软链接指向的是一个文件的硬链接而非该文件的 inode ,所以它们并不依赖于 inode 号,这使得它们能跨越不同的文件系统、分区和逻辑卷起作用。 - -软链接的缺点是,一旦它所指向的硬链接被删除或重命名后,该软链接就失效了。软链接虽然还在,但所指向的硬链接已不存在。所幸的是,`ls` 命令能以红底白字的方式在其列表中高亮显示失效的软链接。 - -### 实验项目: 链接实验 - -我认为最容易理解链接用法及其差异的方法是动手搭建一个项目。这个项目应以非超级用户的身份在一个空目录下进行。我创建了 `~/temp` 目录做这个实验,你也可以这么做。这么做可为项目创建一个安全的环境且提供一个新的空目录让程序运作,如此以来这儿仅存放和程序有关的文件。 - -#### 初始工作 - -首先,在你要进行实验的目录下为该项目中的任务创建一个临时目录,确保当前工作目录(PWD)是你的主目录,然后键入下列命令。 - -``` -mkdir temp -``` - -使用这个命令将当前工作目录切换到 `~/temp`。 - -``` -cd temp -``` - -实验开始,我们需要创建一个能够链接到的文件,下列命令可完成该工作并向其填充内容。 - -``` -du -h > main.file.txt -``` - -使用 `ls -l` 长列表命名确认文件正确地创建了。运行结果应类似于我的。注意文件大小只有 7 字节,但你的可能会有 1~2 字节的变动。 - -``` -[dboth@david temp]$ ls -l -total 4 --rw-rw-r-- 1 dboth dboth 7 Jun 13 07:34 main.file.txt -``` - -在列表中,文件模式串后的数字 `1` 代表存在于该文件上的硬链接数。现在应该是 1 ,因为我们还没有为这个测试文件建立任何硬链接。 - -#### 对硬链接进行实验 - -硬链接创建一个指向同一 inode 的新目录项,当为文件添加一个硬链接时,你会看到链接数目的增加。确保当前工作目录仍为 `~/temp`。创建一个指向 `main.file.txt` 的硬链接,然后查看该目录下文件列表。 - -``` -[dboth@david temp]$ ln main.file.txt link1.file.txt -[dboth@david temp]$ ls -l -total 8 --rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 link1.file.txt --rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 main.file.txt -``` - -目录中两个文件都有两个链接且大小相同,时间戳也一样。这就是有一个 inode 和两个硬链接(即该文件的目录项)的一个文件。再建立一个该文件的硬链接,并列出目录清单内容。你可以建立硬链接: `link1.file.txt` 或 `main.file.txt`。 - -``` -[dboth@david temp]$ ln link1.file.txt link2.file.txt ; ls -l -total 16 --rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link1.file.txt --rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link2.file.txt --rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 main.file.txt -``` - -注意,该目录下的每个硬链接必须使用不同的名称,因为同一目录下的两个文件不能拥有相同的文件名。试着创建一个和现存链接名称相同的硬链接。 - -``` -[dboth@david temp]$ ln main.file.txt link2.file.txt -ln: failed to create hard link 'link2.file.txt': File exists -``` - -显然不行,因为 `link2.file.txt` 已经存在。目前为止我们只在同一目录下创建硬链接,接着在临时目录的父目录(你的主目录)中创建一个链接。 - -``` -[dboth@david temp]$ ln main.file.txt ../main.file.txt ; ls -l ../main* --rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt -``` - -上面的 `ls` 命令显示 `main.file.txt` 文件确实存在于主目录中,且与该文件在 `temp` 目录中的名称一致。当然它们不是不同的文件,它们是同一文件的两个链接,指向了同一文件的目录项。为了帮助说明下一点,在 `temp` 目录中添加一个非链接文件。 - -``` -[dboth@david temp]$ touch unlinked.file ; ls -l -total 12 --rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt --rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt --rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt --rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -使用 `ls` 命令的 `i` 选项查看 inode 的硬链接号和新创建文件的硬链接号。 - -``` -[dboth@david temp]$ ls -li -total 12 -657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt -657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt -657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -注意上面文件模式左边的数字 `657024` ,这是三个硬链接文件所指的同一文件的 inode 号,你也可以使用 `i` 选项查看主目录中所创建的链接的节点号,和该值相同。而那个只有一个链接的 inode 号和其他的不同,在你的系统上看到的 inode 号或许不同于本文中的。 - -接着改变其中一个硬链接文件的大小。 - -``` -[dboth@david temp]$ df -h > link2.file.txt ; ls -li -total 12 -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -现在所有的硬链接文件大小都比原来大了,因为多个目录项都链接着同一文件。 - -下个实验在我的电脑上会出现这样的结果,是因为我的 `/tmp` 目录在一个独立的逻辑卷上。如果你有单独的逻辑卷或文件系统在不同的分区上(如果未使用逻辑卷),确定你是否能访问那个分区或逻辑卷,如果不能,你可以在电脑上挂载一个 U 盘,如果上述方式适合你,你可以进行这个实验。 - -试着在 `/tmp` 目录中建立一个 `~/temp` 目录下文件的链接(或你的文件系统所在的位置)。 - -``` -[dboth@david temp]$ ln link2.file.txt /tmp/link3.file.txt -ln: failed to create hard link '/tmp/link3.file.txt' => 'link2.file.txt': -Invalid cross-device link -``` - -为什么会出现这个错误呢? 原因是每一个单独的可挂载文件系统都有一套自己的 inode 号。简单的通过 inode 号来跨越整个 Linux 文件系统结构引用一个文件会使系统困惑,因为相同的节点号会存在于每个已挂载的文件系统中。 - -有时你可能会想找到一个 inode 的所有硬链接。你可以使用 `ls -li` 命令。然后使用 `find` 命令找到所有硬链接的节点号。 - -``` -[dboth@david temp]$ find . -inum 657024 -./main.file.txt -./link1.file.txt -./link2.file.txt -``` - -注意 `find` 命令不能找到所属该节点的四个硬链接,因为我们在 `~/temp` 目录中查找。 `find` 命令仅在当前工作目录及其子目录中查找文件。要找到所有的硬链接,我们可以使用下列命令,指定你的主目录作为起始查找条件。 - -``` -[dboth@david temp]$ find ~ -samefile main.file.txt -/home/dboth/temp/main.file.txt -/home/dboth/temp/link1.file.txt -/home/dboth/temp/link2.file.txt -/home/dboth/main.file.txt -``` - -如果你是非超级用户,没有权限,可能会看到错误信息。这个命令也使用了 `-samefile` 选项而不是指定文件的节点号。这个效果和使用 inode 号一样且更容易,如果你知道其中一个硬链接名称的话。 - -#### 对软链接进行实验 - -如你刚才看到的,不能跨越文件系统边界创建硬链接,即在逻辑卷或文件系统中从一个文件系统到另一个文件系统。软链接给出了这个问题的解决方案。虽然它们可以达到相同的目的,但它们是非常不同的,知道这些差异是很重要的。 - -让我们在 `~/temp` 目录中创建一个符号链接来开始我们的探索。 - -``` -[dboth@david temp]$ ln -s link2.file.txt link3.file.txt ; ls -li -total 12 -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt -658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> -link2.file.txt -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -拥有节点号 `657024` 的那些硬链接没有变化,且硬链接的数目也没有变化。新创建的符号链接有不同的 inode 号 `658270`。 名为 `link3.file.txt` 的软链接指向了 `link2.file.txt` 文件。使用 `cat` 命令查看 `link3.file.txt` 文件的内容。符号链接的 inode 信息以字母 `l` (小写字母 l)开头,意味着这个文件实际是个符号链接。 - -上例中软链接文件 `link3.file.txt` 的大小只有 14 字节。这是文本内容 `link3.file.txt` 的大小,即该目录项的实际内容。目录项 `link3.file.txt` 并不指向一个 inode ;它指向了另一个目录项,这在跨越文件系统建立链接时很有帮助。现在试着创建一个软链接,之前在 `/tmp` 目录中尝试过的。 - -``` -[dboth@david temp]$ ln -s /home/dboth/temp/link2.file.txt -/tmp/link3.file.txt ; ls -l /tmp/link* -lrwxrwxrwx 1 dboth dboth 31 Jun 14 21:53 /tmp/link3.file.txt -> -/home/dboth/temp/link2.file.txt -``` - -#### 删除链接 - -当你删除硬链接或硬链接所指的文件时,需要考虑一些问题。 - -首先,让我们删除硬链接文件 `main.file.txt`。注意指向 inode 的每个目录项就是一个硬链接。 - -``` -[dboth@david temp]$ rm main.file.txt ; ls -li -total 8 -657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link1.file.txt -657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link2.file.txt -658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> -link2.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -`main.file.txt` 是该文件被创建时所创建的第一个硬链接。现在删除它,仍然保留着原始文件和硬盘上的数据以及所有剩余的硬链接。要删除原始文件,你必须删除它的所有硬链接。 - -现在删除 `link2.file.txt` 硬链接文件。 - -``` -[dboth@david temp]$ rm link2.file.txt ; ls -li -total 8 -657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link1.file.txt -658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> -link2.file.txt -657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 main.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -注意软链接的变化。删除软链接所指的硬链接会使该软链接失效。在我的系统中,断开的链接用颜色高亮显示,目标的硬链接会闪烁显示。如果需要修复这个损坏的软链接,你需要在同一目录下建立一个和旧链接相同名字的硬链接,只要不是所有硬链接都已删除就行。您还可以重新创建链接本身,链接保持相同的名称,但指向剩余的硬链接中的一个。当然如果软链接不再需要,可以使用 `rm` 命令删除它们。 - -`unlink` 命令在删除文件和链接时也有用。它非常简单且没有选项,就像 `rm` 命令一样。然而,它更准确地反映了删除的基本过程,因为它删除了目录项与被删除文件的链接。 - -### 写在最后 - -我用过这两种类型的链接很长一段时间后,我开始了解它们的能力和特质。我为我所教的 Linux 课程编写了一个实验室项目,以充分理解链接是如何工作的,并且我希望增进你的理解。 - --------------------------------------------------------------------------------- - -作者简介: - -戴维.布斯 - 戴维.布斯是 Linux 和开源倡导者,居住在北卡罗莱纳的罗列 。他在 IT 行业工作了四十年,为 IBM 工作了 20 多年的 OS/2。在 IBM 时,他在 1981 年编写了最初的 IBM PC 的第一个培训课程。他为 RedHat 教授过 RHCE 班,并曾在 MCI Worldcom、思科和北卡罗莱纳州工作。他已经用 Linux 和开源软件工作将近 20 年了。 - ---------------------------------- - -via: https://opensource.com/article/17/6/linking-linux-filesystem - -作者:[David Both][a] -译者:[yongshouzhang](https://github.com/yongshouzhang) -校对:[wxy](https://github.com/wxy) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/dboth -[1]:https://opensource.com/resources/what-is-linux?src=linux_resource_menu -[2]:https://opensource.com/resources/what-are-linux-containers?src=linux_resource_menu -[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=7016000000127cYAAQ -[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?src=linux_resource_menu&intcmp=7016000000127cYAAQ -[5]:https://opensource.com/tags/linux?src=linux_resource_menu -[6]:https://opensource.com/article/17/6/linking-linux-filesystem?rate=YebHxA-zgNopDQKKOyX3_r25hGvnZms_33sYBUq-SMM -[7]:https://opensource.com/user/14106/feed -[8]:https://www.flickr.com/photos/digypho/7905320090 -[9]:https://creativecommons.org/licenses/by/2.0/ -[10]:https://linux.cn/article-8685-1.html -[11]:https://linux.cn/article-8099-1.html -[12]:https://linux.cn/article-8887-1.html -[13]:https://opensource.com/business/16/9/linux-users-guide-lvm -[14]:https://opensource.com/life/15/9/everything-is-a-file -[15]:https://linux.cn/article-8685-1.html -[16]:https://linux.cn/article-8685-1.html#3_19182 -[17]:https://opensource.com/users/dboth -[18]:https://opensource.com/article/17/6/linking-linux-filesystem#comments diff --git a/published/201711/20170706 Wildcard Certificates Coming January 2018.md b/published/20170706 Wildcard Certificates Coming January 2018.md similarity index 100% rename from published/201711/20170706 Wildcard Certificates Coming January 2018.md rename to published/20170706 Wildcard Certificates Coming January 2018.md diff --git a/published/201711/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md b/published/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md similarity index 100% rename from published/201711/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md rename to published/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md diff --git a/published/201711/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md b/published/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md similarity index 100% rename from published/201711/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md rename to published/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md diff --git a/published/201711/20170928 3 Python web scrapers and crawlers.md b/published/20170928 3 Python web scrapers and crawlers.md similarity index 100% rename from published/201711/20170928 3 Python web scrapers and crawlers.md rename to published/20170928 3 Python web scrapers and crawlers.md diff --git a/published/201711/20171002 Scaling the GitLab database.md b/published/20171002 Scaling the GitLab database.md similarity index 100% rename from published/201711/20171002 Scaling the GitLab database.md rename to published/20171002 Scaling the GitLab database.md diff --git a/published/201711/20171003 PostgreSQL Hash Indexes Are Now Cool.md b/published/20171003 PostgreSQL Hash Indexes Are Now Cool.md similarity index 100% rename from published/201711/20171003 PostgreSQL Hash Indexes Are Now Cool.md rename to published/20171003 PostgreSQL Hash Indexes Are Now Cool.md diff --git a/published/201711/20171004 No the Linux desktop hasnt jumped in popularity.md b/published/20171004 No the Linux desktop hasnt jumped in popularity.md similarity index 100% rename from published/201711/20171004 No the Linux desktop hasnt jumped in popularity.md rename to published/20171004 No the Linux desktop hasnt jumped in popularity.md diff --git a/published/201711/20171007 Instant 100 command line productivity boost.md b/published/20171007 Instant 100 command line productivity boost.md similarity index 100% rename from published/201711/20171007 Instant 100 command line productivity boost.md rename to published/20171007 Instant 100 command line productivity boost.md diff --git a/published/201711/20171008 8 best languages to blog about.md b/published/20171008 8 best languages to blog about.md similarity index 100% rename from published/201711/20171008 8 best languages to blog about.md rename to published/20171008 8 best languages to blog about.md diff --git a/published/201711/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md b/published/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md similarity index 100% rename from published/201711/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md rename to published/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md diff --git a/published/201711/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md b/published/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md similarity index 100% rename from published/201711/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md rename to published/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md diff --git a/published/201711/20171011 How to set up a Postgres database on a Raspberry Pi.md b/published/20171011 How to set up a Postgres database on a Raspberry Pi.md similarity index 100% rename from published/201711/20171011 How to set up a Postgres database on a Raspberry Pi.md rename to published/20171011 How to set up a Postgres database on a Raspberry Pi.md diff --git a/published/201711/20171011 Why Linux Works.md b/published/20171011 Why Linux Works.md similarity index 100% rename from published/201711/20171011 Why Linux Works.md rename to published/20171011 Why Linux Works.md diff --git a/published/201711/20171013 6 reasons open source is good for business.md b/published/20171013 6 reasons open source is good for business.md similarity index 100% rename from published/201711/20171013 6 reasons open source is good for business.md rename to published/20171013 6 reasons open source is good for business.md diff --git a/published/201711/20171013 Best of PostgreSQL 10 for the DBA.md b/published/20171013 Best of PostgreSQL 10 for the DBA.md similarity index 100% rename from published/201711/20171013 Best of PostgreSQL 10 for the DBA.md rename to published/20171013 Best of PostgreSQL 10 for the DBA.md diff --git a/published/201711/20171015 How to implement cloud-native computing with Kubernetes.md b/published/20171015 How to implement cloud-native computing with Kubernetes.md similarity index 100% rename from published/201711/20171015 How to implement cloud-native computing with Kubernetes.md rename to published/20171015 How to implement cloud-native computing with Kubernetes.md diff --git a/published/201711/20171015 Monitoring Slow SQL Queries via Slack.md b/published/20171015 Monitoring Slow SQL Queries via Slack.md similarity index 100% rename from published/201711/20171015 Monitoring Slow SQL Queries via Slack.md rename to published/20171015 Monitoring Slow SQL Queries via Slack.md diff --git a/published/201711/20171015 Why Use Docker with R A DevOps Perspective.md b/published/20171015 Why Use Docker with R A DevOps Perspective.md similarity index 100% rename from published/201711/20171015 Why Use Docker with R A DevOps Perspective.md rename to published/20171015 Why Use Docker with R A DevOps Perspective.md diff --git a/published/201711/20171016 Introducing CRI-O 1.0.md b/published/20171016 Introducing CRI-O 1.0.md similarity index 100% rename from published/201711/20171016 Introducing CRI-O 1.0.md rename to published/20171016 Introducing CRI-O 1.0.md diff --git a/published/201711/20171017 A tour of Postgres Index Types.md b/published/20171017 A tour of Postgres Index Types.md similarity index 100% rename from published/201711/20171017 A tour of Postgres Index Types.md rename to published/20171017 A tour of Postgres Index Types.md diff --git a/published/201711/20171017 Image Processing on Linux.md b/published/20171017 Image Processing on Linux.md similarity index 100% rename from published/201711/20171017 Image Processing on Linux.md rename to published/20171017 Image Processing on Linux.md diff --git a/published/201711/20171018 How containers and microservices change security.md b/published/20171018 How containers and microservices change security.md similarity index 100% rename from published/201711/20171018 How containers and microservices change security.md rename to published/20171018 How containers and microservices change security.md diff --git a/published/201711/20171018 Learn how to program in Python by building a simple dice game.md b/published/20171018 Learn how to program in Python by building a simple dice game.md similarity index 100% rename from published/201711/20171018 Learn how to program in Python by building a simple dice game.md rename to published/20171018 Learn how to program in Python by building a simple dice game.md diff --git a/published/201711/20171018 Tips to Secure Your Network in the Wake of KRACK.md b/published/20171018 Tips to Secure Your Network in the Wake of KRACK.md similarity index 100% rename from published/201711/20171018 Tips to Secure Your Network in the Wake of KRACK.md rename to published/20171018 Tips to Secure Your Network in the Wake of KRACK.md diff --git a/published/201711/20171019 3 Simple Excellent Linux Network Monitors.md b/published/20171019 3 Simple Excellent Linux Network Monitors.md similarity index 100% rename from published/201711/20171019 3 Simple Excellent Linux Network Monitors.md rename to published/20171019 3 Simple Excellent Linux Network Monitors.md diff --git a/published/201711/20171019 How to manage Docker containers in Kubernetes with Java.md b/published/20171019 How to manage Docker containers in Kubernetes with Java.md similarity index 100% rename from published/201711/20171019 How to manage Docker containers in Kubernetes with Java.md rename to published/20171019 How to manage Docker containers in Kubernetes with Java.md diff --git a/published/201711/20171020 3 Tools to Help You Remember Linux Commands.md b/published/20171020 3 Tools to Help You Remember Linux Commands.md similarity index 100% rename from published/201711/20171020 3 Tools to Help You Remember Linux Commands.md rename to published/20171020 3 Tools to Help You Remember Linux Commands.md diff --git a/published/201711/20171020 Running Android on Top of a Linux Graphics Stack.md b/published/20171020 Running Android on Top of a Linux Graphics Stack.md similarity index 100% rename from published/201711/20171020 Running Android on Top of a Linux Graphics Stack.md rename to published/20171020 Running Android on Top of a Linux Graphics Stack.md diff --git a/published/201711/20171024 Top 5 Linux pain points in 2017.md b/published/20171024 Top 5 Linux pain points in 2017.md similarity index 100% rename from published/201711/20171024 Top 5 Linux pain points in 2017.md rename to published/20171024 Top 5 Linux pain points in 2017.md diff --git a/published/201711/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md b/published/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md similarity index 100% rename from published/201711/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md rename to published/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md diff --git a/published/201711/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md b/published/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md similarity index 100% rename from published/201711/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md rename to published/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md diff --git a/published/201711/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md b/published/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md similarity index 100% rename from published/201711/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md rename to published/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md diff --git a/published/201711/20171026 But I dont know what a container is .md b/published/20171026 But I dont know what a container is .md similarity index 100% rename from published/201711/20171026 But I dont know what a container is .md rename to published/20171026 But I dont know what a container is .md diff --git a/published/201711/20171026 Why is Kubernetes so popular.md b/published/20171026 Why is Kubernetes so popular.md similarity index 100% rename from published/201711/20171026 Why is Kubernetes so popular.md rename to published/20171026 Why is Kubernetes so popular.md diff --git a/published/201711/20171101 How to use cron in Linux.md b/published/20171101 How to use cron in Linux.md similarity index 100% rename from published/201711/20171101 How to use cron in Linux.md rename to published/20171101 How to use cron in Linux.md diff --git a/published/201711/20171101 We re switching to a DCO for source code contributions.md b/published/20171101 We re switching to a DCO for source code contributions.md similarity index 100% rename from published/201711/20171101 We re switching to a DCO for source code contributions.md rename to published/20171101 We re switching to a DCO for source code contributions.md diff --git a/published/201711/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md b/published/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md similarity index 100% rename from published/201711/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md rename to published/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md diff --git a/published/201711/20171106 Finding Files with mlocate.md b/published/20171106 Finding Files with mlocate.md similarity index 100% rename from published/201711/20171106 Finding Files with mlocate.md rename to published/20171106 Finding Files with mlocate.md diff --git a/published/201711/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md b/published/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md similarity index 100% rename from published/201711/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md rename to published/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md diff --git a/published/201711/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md b/published/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md similarity index 100% rename from published/201711/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md rename to published/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md diff --git a/published/201711/20171107 AWS adopts home-brewed KVM as new hypervisor.md b/published/20171107 AWS adopts home-brewed KVM as new hypervisor.md similarity index 100% rename from published/201711/20171107 AWS adopts home-brewed KVM as new hypervisor.md rename to published/20171107 AWS adopts home-brewed KVM as new hypervisor.md diff --git a/published/201711/20171107 How I created my first RPM package in Fedora.md b/published/20171107 How I created my first RPM package in Fedora.md similarity index 100% rename from published/201711/20171107 How I created my first RPM package in Fedora.md rename to published/20171107 How I created my first RPM package in Fedora.md diff --git a/published/201711/20171108 Build and test applications with Ansible Container.md b/published/20171108 Build and test applications with Ansible Container.md similarity index 100% rename from published/201711/20171108 Build and test applications with Ansible Container.md rename to published/20171108 Build and test applications with Ansible Container.md diff --git a/published/201711/20171110 File better bugs with coredumpctl.md b/published/20171110 File better bugs with coredumpctl.md similarity index 100% rename from published/201711/20171110 File better bugs with coredumpctl.md rename to published/20171110 File better bugs with coredumpctl.md diff --git a/published/201711/20171114 ​Linux totally dominates supercomputers.md b/published/20171114 ​Linux totally dominates supercomputers.md similarity index 100% rename from published/201711/20171114 ​Linux totally dominates supercomputers.md rename to published/20171114 ​Linux totally dominates supercomputers.md diff --git a/published/201711/20171116 5 Coolest Linux Terminal Emulators.md b/published/20171116 5 Coolest Linux Terminal Emulators.md similarity index 100% rename from published/201711/20171116 5 Coolest Linux Terminal Emulators.md rename to published/20171116 5 Coolest Linux Terminal Emulators.md diff --git a/published/201711/20171117 How to Easily Remember Linux Commands.md b/published/20171117 How to Easily Remember Linux Commands.md similarity index 100% rename from published/201711/20171117 How to Easily Remember Linux Commands.md rename to published/20171117 How to Easily Remember Linux Commands.md diff --git a/published/201711/20171118 Getting started with OpenFaaS on minikube.md b/published/20171118 Getting started with OpenFaaS on minikube.md similarity index 100% rename from published/201711/20171118 Getting started with OpenFaaS on minikube.md rename to published/20171118 Getting started with OpenFaaS on minikube.md diff --git a/published/20171120 Containers and Kubernetes Whats next.md b/published/20171120 Containers and Kubernetes Whats next.md deleted file mode 100644 index 57f9379f7b..0000000000 --- a/published/20171120 Containers and Kubernetes Whats next.md +++ /dev/null @@ -1,81 +0,0 @@ -容器技术和 K8S 的下一站 -============================================================ -> 想知道容器编排管理和 K8S 的最新展望么?来看看专家怎么说。 - -![CIO_Big Data Decisions_2](https://enterprisersproject.com/sites/default/files/styles/620x350/public/images/CIO_Big%20Data%20Decisions_2.png?itok=Y5zMHxf8 "CIO_Big Data Decisions_2") - -如果你想对容器在未来的发展方向有一个整体把握,那么你一定要跟着钱走,看看钱都投在了哪里。当然了,有很多很多的钱正在投入容器的进一步发展。相关研究预计 2020 年容器技术的投入将占有 [27 亿美元][4] 的市场份额。而在 2016 年,容器相关技术投入的总额为 7.62 亿美元,只有 2020 年投入预计的三分之一。巨额投入的背后是一些显而易见的基本因素,包括容器化的迅速增长以及并行化的大趋势。随着容器被大面积推广和使用,容器编排管理也会被理所当然的推广应用起来。 - -来自 [The new stack][5] 的调研数据表明,容器的推广使用是编排管理被推广的主要的催化剂。根据调研参与者的反馈数据,在已经将容器技术使用到生产环境中的使用者里,有六成使用者正在将 Kubernetes(K8S)编排管理广泛的应用在生产环境中,另外百分之十九的人员则表示他们已经处于部署 K8S 的初级阶段。在容器部署初期的使用者当中,虽然只有百分之五的人员表示已经在使用 K8S ,但是百分之五十八的人员表示他们正在计划和准备使用 K8S。总而言之,容器和 Kubernetes 的关系就好比是鸡和蛋一样,相辅相成紧密关联。众多专家一致认为编排管理工具对容器的[长周期管理][6] 以及其在市场中的发展有至关重要的作用。正如 [Cockroach 实验室][7] 的 Alex Robinson 所说,容器编排管理被更广泛的拓展和应用是一个总体的大趋势。毫无疑问,这是一个正在快速演变的领域,且未来潜力无穷。鉴于此,我们对 Robinson 和其他的一些容器的实际使用和推介者做了采访,来从他们作为容器技术的践行者的视角上展望一下容器编排以及 K8S 的下一步发展。 - -### 容器编排将被主流接受 - -像任何重要技术的转型一样,我们就像是处在一个高崖之上一般,在经过了初期步履蹒跚的跋涉之后将要来到一望无际的广袤平原。广大的新天地和平实真切的应用需求将会让这种新技术在主流应用中被迅速推广,尤其是在大企业环境中。正如 Alex Robinson 说的那样,容器技术的淘金阶段已经过去,早期的技术革新创新正在减速,随之而来的则是市场对容器技术的稳定性和可用性的强烈需求。这意味着未来我们将不会再见到大量的新的编排管理系统的涌现,而是会看到容器技术方面更多的安全解决方案,更丰富的管理工具,以及基于目前主流容器编排系统的更多的新特性。 - -### 更好的易用性 - -人们将在简化容器的部署方面下大功夫,因为容器部署的初期工作对很多公司和组织来说还是比较复杂的,尤其是容器的[长期管理维护][8]更是需要投入大量的精力。正如 [Codemill AB][9] 公司的 My Karlsson 所说,容器编排技术还是太复杂了,这导致很多使用者难以娴熟驾驭和充分利用容器编排的功能。很多容器技术的新用户都需要花费很多精力,走很多弯路,才能搭建小规模的或单个的以隔离方式运行的容器系统。这种现象在那些没有针对容器技术设计和优化的应用中更为明显。在简化容器编排管理方面有很多优化可以做,这些优化和改造将会使容器技术更加具有可用性。 - -### 在混合云以及多云技术方面会有更多侧重 - -随着容器和容器编排技术被越来越多的使用,更多的组织机构会选择扩展他们现有的容器技术的部署,从之前的把非重要系统部署在单一环境的使用情景逐渐过渡到更加[复杂的使用情景][10]。对很多公司来说,这意味着他们必须开始学会在 [混合云][11] 和 [多云][12] 的环境下,全局化的去管理那些容器化的应用和微服务。正如红帽 [Openshift 部门产品战略总监][14] [Brian Gracely][13] 所说,“容器和 K8S 技术的使用使得我们成功的实现了混合云以及应用的可移植性。结合 Open Service Broker API 的使用,越来越多的结合私有云和公有云资源的新应用将会涌现出来。” -据 [CloudBees][15] 公司的高级工程师 Carlos Sanchez 分析,联合服务(Federation)将会得到极大推动,使一些诸如多地区部署和多云部署等的备受期待的新特性成为可能。 - -**[ 想知道 CIO 们对混合云和多云的战略构想么? 请参看我们的这条相关资源, [Hybrid Cloud: The IT leader's guide][16]。 ]** - -### 平台和工具的持续整合及加强 - -对任何一种科技来说,持续的整合和加强从来都是大势所趋;容器编排管理技术在这方面也不例外。来自 [Sumo Logic][17] 的首席分析师 Ben Newton 表示,随着容器化渐成主流,软件工程师们正在很少数的一些技术上做持续整合加固的工作,来满足他们的一些微应用的需求。容器和 K8S 将会毫无疑问的成为容器编排管理方面的主流平台,并轻松碾压其它的一些小众平台方案。因为 K8S 提供了一个相当清晰的可以摆脱各种特有云生态的途径,K8S 将被大量公司使用,逐渐形成一个不依赖于某个特定云服务的“中立云”cloud-neutral。 - -### K8S 的下一站 - -来自 [Alcide][18] 的 CTO 和联合创始人 Gadi Naor 表示,K8S 将会是一个有长期和远景发展的技术,虽然我们的社区正在大力推广和发展 K8S,K8S 仍有很长的路要走。 - -专家们对[日益流行的 K8S 平台][19]也作出了以下一些预测: - -**_来自 Alcide 的 Gadi Naor 表示:_** “运营商会持续演进并趋于成熟,直到在 K8S 上运行的应用可以完全自治。利用 [OpenTracing][20] 和诸如 [istio][21] 技术的 service mesh 架构,在 K8S 上部署和监控微应用将会带来很多新的可能性。” - -**_来自 Red Hat 的 Brian Gracely 表示:_** “K8S 所支持的应用的种类越来越多。今后在 K8S 上,你不仅可以运行传统的应用程序,还可以运行原生的云应用、大数据应用以及 HPC 或者基于 GPU 运算的应用程序,这将为灵活的架构设计带来无限可能。” - -**_来自 Sumo Logic 的 Ben Newton 表示:_** “随着 K8S 成为一个具有统治地位的平台,我预计更多的操作机制将会被统一化,尤其是 K8S 将和第三方管理和监控平台融合起来。” - -**_来自 CloudBees 的 Carlos Sanchez 表示:_** “在不久的将来我们就能看到不依赖于 Docker 而使用其它运行时环境的系统,这将会有助于消除任何可能的 lock-in 情景“ [编辑提示:[CRI-O][22] 就是一个可以借鉴的例子。]“而且我期待将来会出现更多的针对企业环境的存储服务新特性,包括数据快照以及在线的磁盘容量的扩展。” - -**_来自 Cockroach Labs 的 Alex Robinson 表示:_** “ K8S 社区正在讨论的一个重大发展议题就是加强对[有状态程序][23]的管理。目前在 K8S 平台下,实现状态管理仍然非常困难,除非你所使用的云服务商可以提供远程固定磁盘。现阶段也有很多人在多方面试图改善这个状况,包括在 K8S 平台内部以及在外部服务商一端做出的一些改进。” - -------------------------------------------------------------------------------- - -via: https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next - -作者:[Kevin Casey][a] -译者:[yunfengHe](https://github.com/yunfengHe) -校对:[wxy](https://github.com/wxy) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://enterprisersproject.com/user/kevin-casey -[1]:https://enterprisersproject.com/article/2017/11/kubernetes-numbers-10-compelling-stats -[2]:https://enterprisersproject.com/article/2017/11/how-enterprise-it-uses-kubernetes-tame-container-complexity -[3]:https://enterprisersproject.com/article/2017/11/5-kubernetes-success-tips-start-smart?sc_cid=70160000000h0aXAAQ -[4]:https://451research.com/images/Marketing/press_releases/Application-container-market-will-reach-2-7bn-in-2020_final_graphic.pdf -[5]:https://thenewstack.io/ -[6]:https://enterprisersproject.com/article/2017/10/microservices-and-containers-6-management-tips-long-haul -[7]:https://www.cockroachlabs.com/ -[8]:https://enterprisersproject.com/article/2017/10/microservices-and-containers-6-management-tips-long-haul -[9]:https://codemill.se/ -[10]:https://www.redhat.com/en/challenges/integration?intcmp=701f2000000tjyaAAA -[11]:https://enterprisersproject.com/hybrid-cloud -[12]:https://enterprisersproject.com/article/2017/7/multi-cloud-vs-hybrid-cloud-whats-difference -[13]:https://enterprisersproject.com/user/brian-gracely -[14]:https://www.redhat.com/en -[15]:https://www.cloudbees.com/ -[16]:https://enterprisersproject.com/hybrid-cloud?sc_cid=70160000000h0aXAAQ -[17]:https://www.sumologic.com/ -[18]:http://alcide.io/ -[19]:https://enterprisersproject.com/article/2017/10/how-explain-kubernetes-plain-english -[20]:http://opentracing.io/ -[21]:https://istio.io/ -[22]:http://cri-o.io/ -[23]:https://opensource.com/article/17/2/stateful-applications -[24]:https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next?rate=PBQHhF4zPRHcq2KybE1bQgMkS2bzmNzcW2RXSVItmw8 -[25]:https://enterprisersproject.com/user/kevin-casey diff --git a/published/20171124 How to Install Android File Transfer for Linux.md b/published/20171124 How to Install Android File Transfer for Linux.md deleted file mode 100644 index 3cdb372c93..0000000000 --- a/published/20171124 How to Install Android File Transfer for Linux.md +++ /dev/null @@ -1,75 +0,0 @@ -如何在 Linux 下安装安卓文件传输助手 -=============== - -如果你尝试在 Ubuntu 下连接你的安卓手机,你也许可以试试 Linux 下的安卓文件传输助手。 - -本质上来说,这个应用是谷歌 macOS 版本的一个克隆。它是用 Qt 编写的,用户界面非常简洁,使得你能轻松在 Ubuntu 和安卓手机之间传输文件和文件夹。 - -现在,有可能一部分人想知道有什么是这个应用可以做,而 Nautilus(Ubuntu 默认的文件资源管理器)不能做的,答案是没有。 - -当我将我的 Nexus 5X(记得选择 [媒体传输协议 MTP][7] 选项)连接在 Ubuntu 上时,在 [GVfs][8](LCTT 译注: GNOME 桌面下的虚拟文件系统)的帮助下,我可以打开、浏览和管理我的手机,就像它是一个普通的 U 盘一样。 - -[![Nautilus MTP integration with a Nexus 5X](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg)][9] - -但是*一些*用户在使用默认的文件管理器时,在 MTP 的某些功能上会出现问题:比如文件夹没有正确加载,创建新文件夹后此文件夹不存在,或者无法在媒体播放器中使用自己的手机。 - -这就是要为 Linux 系统用户设计一个安卓文件传输助手应用的原因,将这个应用当做将 MTP 设备安装在 Linux 下的另一种选择。如果你使用 Linux 下的默认应用时一切正常,你也许并不需要尝试使用它 (除非你真的很想尝试新鲜事物)。 - - -![Android File Transfer Linux App](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/android-file-transfer-for-linux-750x662.jpg) - -该 app 特点: - -*   简洁直观的用户界面 -*   支持文件拖放功能(从 Linux 系统到手机) -*   支持批量下载 (从手机到 Linux系统) -*   显示传输进程对话框 -*   FUSE 模块支持 -*   没有文件大小限制 -*   可选命令行工具 - -### Ubuntu 下安装安卓手机文件助手的步骤 - -以上就是对这个应用的介绍,下面是如何安装它的具体步骤。 - -这有一个 [PPA](个人软件包集)源为 Ubuntu 14.04 LTS、16.04 LTS 和 Ubuntu 17.10 提供可用应用。 - -为了将这一 PPA 加入你的软件资源列表中,执行这条命令: - -``` -sudo add-apt-repository ppa:samoilov-lex/aftl-stable -``` - -接着,为了在 Ubuntu 下安装 Linux版本的安卓文件传输助手,执行: - -``` -sudo apt-get update && sudo apt install android-file-transfer -``` - -这样就行了。 - -你会在你的应用列表中发现这一应用的启动图标。 - -在你启动这一应用之前,要确保没有其他应用(比如 Nautilus)已经挂载了你的手机。如果其它应用正在使用你的手机,就会显示“无法找到 MTP 设备”。要解决这一问题,将你的手机从 Nautilus(或者任何正在使用你的手机的应用)上移除,然后再重新启动安卓文件传输助手。 - --------------------------------------------------------------------------------- - -via: http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux - -作者:[JOEY SNEDDON][a] -译者:[wenwensnow](https://github.com/wenwensnow) -校对:[wxy](https://github.com/wxy) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://plus.google.com/117485690627814051450/?rel=author -[1]:https://plus.google.com/117485690627814051450/?rel=author -[2]:http://www.omgubuntu.co.uk/category/app -[3]:http://www.omgubuntu.co.uk/category/download -[4]:https://github.com/whoozle/android-file-transfer-linux -[5]:http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux -[6]:http://android.com/filetransfer?linkid=14270770 -[7]:https://en.wikipedia.org/wiki/Media_Transfer_Protocol -[8]:https://en.wikipedia.org/wiki/GVfs -[9]:http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg -[10]:https://launchpad.net/~samoilov-lex/+archive/ubuntu/aftl-stable diff --git a/published/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md b/published/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md deleted file mode 100644 index 9b6a4f242c..0000000000 --- a/published/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md +++ /dev/null @@ -1,72 +0,0 @@ -开源云技能认证:系统管理员的核心竞争力 -========= - -![os jobs](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/open-house-sysadmin.jpg?itok=i5FHc3lu "os jobs") - -> [2017年开源工作报告][1](以下简称“报告”)显示,具有开源云技术认证的系统管理员往往能获得更高的薪酬。 - - -报告调查的受访者中,53% 认为系统管理员是雇主们最期望被填补的职位空缺之一,因此,技术娴熟的系统管理员更受青睐而收获高薪职位,但这一职位,并没想象中那么容易填补。 - -系统管理员主要负责服务器和其他电脑操作系统的安装、服务支持和维护,及时处理服务中断和预防其他问题的出现。 - -总的来说,今年的报告指出开源领域人才需求最大的有开源云(47%),应用开发(44%),大数据(43%),开发运营和安全(42%)。 - -此外,报告对人事经理的调查显示,58% 期望招揽更多的开源人才,67% 认为开源人才的需求增长会比业内其他领域更甚。有些单位视开源人才为招聘最优选则,它们招聘的开源人才较上年增长了 2 个百分点。 - -同时,89% 的人事经理认为很难找到颇具天赋的开源人才。 - -### 为什么要获取认证 - -报告显示,对系统管理员的需求刺激着人事经理为 53% 的组织/机构提供正规的培训和专业技术认证,而这一比例去年为 47%。 - -对系统管理方面感兴趣的 IT 人才考虑获取 Linux 认证已成为行业规律。随便查看几个知名的招聘网站,你就能发现:[CompTIA Linux+][3] 认证是入门级 Linux 系统管理员的最高认证;如果想胜任高级别的系统管理员职位,获取[红帽认证工程师(RHCE)][4]和[红帽认证系统管理员(RHCSA)][5]则是不可或缺的。 - -戴士(Dice)[2017 技术行业薪资调查][6]显示,2016 年系统管理员的薪水为 79,538 美元,较上年下降了 0.8%;系统架构师的薪水为 125,946 美元,同比下降 4.7%。尽管如此,该调查发现“高水平专业人才仍最受欢迎,特别是那些精通支持产业转型发展所需技术的人才”。 - -在开源技术方面,HBase(一个开源的分布式数据库)技术人才的薪水在戴士 2017 技术行业薪资调查中排第一。在计算机网络和数据库领域,掌握 OpenVMS 操作系统技术也能获得高薪。 - -### 成为出色的系统管理员 - -出色的系统管理员须在问题出现时马上处理,这意味着你必须时刻准备应对可能出现的状况。这个职位追求“零责备的、精益的、流程或技术上交互式改进的”思维方式和善于自我完善的人格,成为一个系统管理员意味着“你必将与开源软件如 Linux、BSD 甚至开源 Solaris 等结下不解之缘”,Paul English ^译注1 在 [opensource.com][7] 上发文指出。 - -Paul English 认为,现在的系统管理员较以前而言,要更多地与软件打交道,而且要能够编写脚本来协助系统管理。 - ->译注1:Paul English,计算机科学学士,UNIX/Linux 系统管理员,PreOS Security Inc. 公司 CEO,2015-2017 年于为推动系统管理员发展实践的非盈利组织——专业系统管理员联盟League of Professional System Administrator担任董事会成员。 - -### 展望 2018 - -[Robert Half 2018 年技术人才薪资导览][8]预测 2018 年北美地区许多单位将聘用大量系统管理方面的专业人才,同时个人软实力和领导力水平作为优秀人才的考量因素,越来越受到重视。 - -该报告指出:“良好的聆听能力和批判性思维能力对于理解和解决用户的问题和担忧至关重要,也是 IT 从业者必须具备的重要技能,特别是从事服务台和桌面支持工作相关的技术人员。” - -这与[Linux基金会][9]^译注2 提出的不同阶段的系统管理员必备技能相一致,都强调了强大的分析能力和快速处理问题的能力。 - ->译注2:Linux 基金会The Linux Foundation,成立于 2000 年,致力于围绕开源项目构建可持续发展的生态系统,以加速开源项目的技术开发和商业应用;它是世界上最大的开源非盈利组织,在推广、保护和推进 Linux 发展,协同开发,维护“历史上最大的共享资源”上功勋卓越。 - -如果想逐渐爬上系统管理员职位的金字塔上层,还应该对系统配置的结构化方法充满兴趣;且拥有解决系统安全问题的经验;用户身份验证管理的经验;与非技术人员进行非技术交流的能力;以及优化系统以满足最新的安全需求的能力。 - -- [下载][10]2017年开源工作报告全文,以获取更多信息。 - - ------------------------ - -via: https://www.linux.com/blog/open-source-cloud-skills-and-certification-are-key-sysadmins - -作者:[linux.com][a] -译者:[wangy325](https://github.com/wangy325) -校对:[wxy](https://github.com/wxy) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/blog/open-source-cloud-skills-and-certification-are-key-sysadmins -[1]:https://www.linuxfoundation.org/blog/2017-jobs-report-highlights-demand-open-source-skills/ -[2]:https://www.linux.com/licenses/category/creative-commons-zero -[3]:https://certification.comptia.org/certifications/linux?tracking=getCertified/certifications/linux.aspx -[4]:https://www.redhat.com/en/services/certification/rhce -[5]:https://www.redhat.com/en/services/certification/rhcsa -[6]:http://marketing.dice.com/pdf/Dice_TechSalarySurvey_2017.pdf?aliId=105832232 -[7]:https://opensource.com/article/17/7/truth-about-sysadmins -[8]:https://www.roberthalf.com/salary-guide/technology -[9]:https://www.linux.com/learn/10-essential-skills-novice-junior-and-senior-sysadmins%20%20 -[10]:http://bit.ly/2017OSSjobsreport \ No newline at end of file diff --git a/published/201711/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md b/published/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md similarity index 100% rename from published/201711/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md rename to published/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md diff --git a/published/20171130 Search DuckDuckGo from the Command Line.md b/published/20171130 Search DuckDuckGo from the Command Line.md deleted file mode 100644 index 48b6fdd830..0000000000 --- a/published/20171130 Search DuckDuckGo from the Command Line.md +++ /dev/null @@ -1,97 +0,0 @@ -在命令行中使用 DuckDuckGo 搜索 -============= - -![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/duckduckgo.png) - -此前我们介绍了[如何在命令行中使用 Google 搜索][3]。许多读者反馈说他们平时使用 [Duck Duck Go][4],这是一个功能强大而且保密性很强的搜索引擎。 - -正巧,最近出现了一款能够从命令行搜索 DuckDuckGo 的工具。它叫做 ddgr(我把它读作 “dodger”),非常好用。 - -像 [Googler][7] 一样,ddgr 是一个完全开源而且非官方的工具。没错,它并不属于 DuckDuckGo。所以,如果你发现它返回的结果有些奇怪,请先询问这个工具的开发者,而不是搜索引擎的开发者。 - -### DuckDuckGo 命令行应用 - -![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/ddgr-gif.gif) - -[DuckDuckGo Bangs(DuckDuckGo 快捷搜索)][8] 可以帮助你轻易地在 DuckDuckGo 上找到想要的信息(甚至 _本网站 omgubuntu_ 都有快捷搜索)。ddgr 非常忠实地呈现了这个功能。 - -和网页版不同的是,你可以更改每页返回多少结果。这比起每次查询都要看三十多条结果要方便一些。默认界面经过了精心设计,在不影响可读性的情况下尽量减少了占用空间。 - -`ddgr` 有许多功能和亮点,包括: - -* 更改搜索结果数 -* 支持 Bash 自动补全 -* 使用 DuckDuckGo Bangs -* 在浏览器中打开链接 -* ”手气不错“选项 -* 基于时间、地区、文件类型等的筛选功能 -* 极少的依赖项 - -你可以从 Github 的项目页面上下载支持各种系统的 `ddgr`: - -- [从 Github 下载 “ddgr”][9] - -另外,在 Ubuntu 16.04 LTS 或更新版本中,你可以使用 PPA 安装 ddgr。这个仓库由 ddgr 的开发者维护。如果你想要保持在最新版本的话,推荐使用这种方式安装。 - -需要提醒的是,在本文创作时,这个 PPA 中的 ddgr _并不是_ 最新版本,而是一个稍旧的版本(缺少 -num 选项)。 - -使用以下命令添加 PPA: - -``` -sudo add-apt-repository ppa:twodopeshaggy/jarun -sudo apt-get update -``` - -### 如何使用 ddgr 在命令行中搜索 DuckDuckGo - -安装完毕后,你只需打开你的终端模拟器,并运行: - -``` -ddgr -``` - -然后输入查询内容: - -``` -search-term -``` - -你可以限制搜索结果数: - -``` -ddgr --num 5 search-term -``` - -或者自动在浏览器中打开第一条搜索结果: - - -``` -ddgr -j search-term -``` - -你可以使用参数和选项来提高搜索精确度。使用以下命令来查看所有的参数: - -``` -ddgr -h -``` - --------------------------------------------------------------------------------- - -via: http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app - -作者:[JOEY SNEDDON][a] -译者:[yixunx](https://github.com/yixunx) -校对:[wxy](https://github.com/wxy) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://plus.google.com/117485690627814051450/?rel=author -[1]:https://plus.google.com/117485690627814051450/?rel=author -[2]:http://www.omgubuntu.co.uk/category/download -[3]:http://www.omgubuntu.co.uk/2017/08/search-google-from-the-command-line -[4]:http://duckduckgo.com/ -[5]:http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app -[6]:https://github.com/jarun/ddgr -[7]:https://github.com/jarun/googler -[8]:https://duckduckgo.com/bang -[9]:https://github.com/jarun/ddgr/releases/tag/v1.1 diff --git a/sources/tech/20090701 The One in Which I Call Out Hacker News.md b/sources/tech/20090701 The One in Which I Call Out Hacker News.md new file mode 100644 index 0000000000..44c751dd5a --- /dev/null +++ b/sources/tech/20090701 The One in Which I Call Out Hacker News.md @@ -0,0 +1,86 @@ +translating by hopefully2333 + +# [The One in Which I Call Out Hacker News][14] + + +> “Implementing caching would take thirty hours. Do you have thirty extra hours? No, you don’t. I actually have no idea how long it would take. Maybe it would take five minutes. Do you have five minutes? No. Why? Because I’m lying. It would take much longer than five minutes. That’s the eternal optimism of programmers.” +> +> — Professor [Owen Astrachan][1] during 23 Feb 2004 lecture for [CPS 108][2] + +[Accusing open-source software of being a royal pain to use][5] is not a new argument; it’s been said before, by those much more eloquent than I, and even by some who are highly sympathetic to the open-source movement. Why go over it again? + +On Hacker News on Monday, I was amused to read some people saying that [writing StackOverflow was hilariously easy][6]—and proceeding to back up their claim by [promising to clone it over July 4th weekend][7]. Others chimed in, pointing to [existing][8] [clones][9] as a good starting point. + +Let’s assume, for sake of argument, that you decide it’s okay to write your StackOverflow clone in ASP.NET MVC, and that I, after being hypnotized with a pocket watch and a small club to the head, have decided to hand you the StackOverflow source code, page by page, so you can retype it verbatim. We’ll also assume you type like me, at a cool 100 WPM ([a smidge over eight characters per second][10]), and unlike me,  _you_  make zero mistakes. StackOverflow’s *.cs, *.sql, *.css, *.js, and *.aspx files come to 2.3 MB. So merely typing the source code back into the computer will take you about eighty hours if you make zero mistakes. + +Except, of course, you’re not doing that; you’re going to implement StackOverflow from scratch. So even assuming that it took you a mere ten times longer to design, type out, and debug your own implementation than it would take you to copy the real one, that already has you coding for several weeks straight—and I don’t know about you, but I am okay admitting I write new code  _considerably_  less than one tenth as fast as I copy existing code. + + _Well, okay_ , I hear you relent. *So not the whole thing. But I can do **most** of it.* + +Okay, so what’s “most”? There’s simply asking and responding to questions—that part’s easy. Well, except you have to implement voting questions and answers up and down, and the questioner should be able to accept a single answer for each question. And you can’t let people upvote or accept their own answers, so you need to block that. And you need to make sure that users don’t upvote or downvote another user too many times in a certain amount of time, to prevent spambots. Probably going to have to implement a spam filter, too, come to think of it, even in the basic design, and you also need to support user icons, and you’re going to have to find a sanitizing HTML library you really trust and that interfaces well with Markdown (provided you do want to reuse [that awesome editor][11] StackOverflow has, of course). You’ll also need to purchase, design, or find widgets for all the controls, plus you need at least a basic administration interface so that moderators can moderate, and you’ll need to implement that scaling karma thing so that you give users steadily increasing power to do things as they go. + +But if you do  _all that_ , you  _will_  be done. + +Except…except, of course, for the full-text search, especially its appearance in the search-as-you-ask feature, which is kind of indispensable. And user bios, and having comments on answers, and having a main page that shows you important questions but that bubbles down steadily à la reddit. Plus you’ll totally need to implement bounties, and support multiple OpenID logins per user, and send out email notifications for pertinent events, and add a tagging system, and allow administrators to configure badges by a nice GUI. And you’ll need to show users’ karma history, upvotes, and downvotes. And the whole thing has to scale really well, since it could be slashdotted/reddited/StackOverflown at any moment. + +But  _then_ ! **Then** you’re done! + +…right after you implement upgrades, internationalization, karma caps, a CSS design that makes your site not look like ass, AJAX versions of most of the above, and G-d knows what else that’s lurking just beneath the surface that you currently take for granted, but that will come to bite you when you start to do a real clone. + +Tell me: which of those features do you feel you can cut and still have a compelling offering? Which ones go under “most” of the site, and which can you punt? + +Developers think cloning a site like StackOverflow is easy for the same reason that open-source software remains such a horrible pain in the ass to use. When you put a developer in front of StackOverflow, they don’t really  _see_ StackOverflow. What they actually  _see_  is this: + +``` +create table QUESTION (ID identity primary key, + TITLE varchar(255), --- why do I know you thought 255? + BODY text, + UPVOTES integer not null default 0, + DOWNVOTES integer not null default 0, + USER integer references USER(ID)); +create table RESPONSE (ID identity primary key, + BODY text, + UPVOTES integer not null default 0, + DOWNVOTES integer not null default 0, + QUESTION integer references QUESTION(ID)) +``` + +If you then tell a developer to replicate StackOverflow, what goes into his head are the above two SQL tables and enough HTML to display them without formatting, and that really  _is_  completely doable in a weekend. The smarter ones will realize that they need to implement login and logout, and comments, and that the votes need to be tied to a user, but that’s still totally doable in a weekend; it’s just a couple more tables in a SQL back-end, and the HTML to show their contents. Use a framework like Django, and you even get basic users and comments for free. + +But that’s  _not_  what StackOverflow is about. Regardless of what your feelings may be on StackOverflow in general, most visitors seem to agree that the user experience is smooth, from start to finish. They feel that they’re interacting with a polished product. Even if I didn’t know better, I would guess that very little of what actually makes StackOverflow a continuing success has to do with the database schema—and having had a chance to read through StackOverflow’s source code, I know how little really does. There is a  _tremendous_  amount of spit and polish that goes into making a major website highly usable. A developer, asked how hard something will be to clone, simply  _does not think about the polish_ , because  _the polish is incidental to the implementation._ + +That is why an open-source clone of StackOverflow will fail. Even if someone were to manage to implement most of StackOverflow “to spec,” there are some key areas that would trip them up. Badges, for example, if you’re targeting end-users, either need a GUI to configure rules, or smart developers to determine which badges are generic enough to go on all installs. What will actually happen is that the developers will bitch and moan about how you can’t implement a really comprehensive GUI for something like badges, and then bikeshed any proposals for standard badges so far into the ground that they’ll hit escape velocity coming out the other side. They’ll ultimately come up with the same solution that bug trackers like Roundup use for their workflow: the developers implement a generic mechanism by which anyone, truly anyone at all, who feels totally comfortable working with the system API in Python or PHP or whatever, can easily add their own customizations. And when PHP and Python are so easy to learn and so much more flexible than a GUI could ever be, why bother with anything else? + +Likewise, the moderation and administration interfaces can be punted. If you’re an admin, you have access to the SQL server, so you can do anything really genuinely administrative-like that way. Moderators can get by with whatever django-admin and similar systems afford you, since, after all, few users are mods, and mods should understand how the sites  _work_ , dammit. And, certainly, none of StackOverflow’s interface failings will be rectified. Even if StackOverflow’s stupid requirement that you have to have and know how to use an OpenID (its worst failing) eventually gets fixed, I’m sure any open-source clones will rabidly follow it—just as GNOME and KDE for years slavishly copied off Windows, instead of trying to fix its most obvious flaws. + +Developers may not care about these parts of the application, but end-users do, and take it into consideration when trying to decide what application to use. Much as a good software company wants to minimize its support costs by ensuring that its products are top-notch before shipping, so, too, savvy consumers want to ensure products are good before they purchase them so that they won’t  _have_  to call support. Open-source products fail hard here. Proprietary solutions, as a rule, do better. + +That’s not to say that open-source doesn’t have its place. This blog runs on Apache, [Django][12], [PostgreSQL][13], and Linux. But let me tell you, configuring that stack is  _not_  for the faint of heart. PostgreSQL needs vacuuming configured on older versions, and, as of recent versions of Ubuntu and FreeBSD, still requires the user set up the first database cluster. MS SQL requires neither of those things. Apache…dear heavens, don’t even get me  _started_  on trying to explain to a novice user how to get virtual hosting, MovableType, a couple Django apps, and WordPress all running comfortably under a single install. Hell, just trying to explain the forking vs. threading variants of Apache to a technically astute non-developer can be a nightmare. IIS 7 and Apache with OS X Server’s very much closed-source GUI manager make setting up those same stacks vastly simpler. Django’s a great a product, but it’s nothing  _but_  infrastructure—exactly the thing that I happen to think open-source  _does_  do well,  _precisely_  because of the motivations that drive developers to contribute. + +The next time you see an application you like, think very long and hard about all the user-oriented details that went into making it a pleasure to use, before decrying how you could trivially reimplement the entire damn thing in a weekend. Nine times out of ten, when you think an application was ridiculously easy to implement, you’re completely missing the user side of the story. + +-------------------------------------------------------------------------------- + +via: https://bitquabit.com/post/one-which-i-call-out-hacker-news/ + +作者:[Benjamin Pollack][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://bitquabit.com/meta/about/ +[1]:http://www.cs.duke.edu/~ola/ +[2]:http://www.cs.duke.edu/courses/cps108/spring04/ +[3]:https://bitquabit.com/categories/programming +[4]:https://bitquabit.com/categories/technology +[5]:http://blog.bitquabit.com/2009/06/30/one-which-i-say-open-source-software-sucks/ +[6]:http://news.ycombinator.com/item?id=678501 +[7]:http://news.ycombinator.com/item?id=678704 +[8]:http://code.google.com/p/cnprog/ +[9]:http://code.google.com/p/soclone/ +[10]:http://en.wikipedia.org/wiki/Words_per_minute +[11]:http://github.com/derobins/wmd/tree/master +[12]:http://www.djangoproject.com/ +[13]:http://www.postgresql.org/ +[14]:https://bitquabit.com/post/one-which-i-call-out-hacker-news/ diff --git a/sources/tech/20130402 Dynamic linker tricks Using LD_PRELOAD to cheat inject features and investigate programs.md b/sources/tech/20130402 Dynamic linker tricks Using LD_PRELOAD to cheat inject features and investigate programs.md deleted file mode 100644 index 2329fadd41..0000000000 --- a/sources/tech/20130402 Dynamic linker tricks Using LD_PRELOAD to cheat inject features and investigate programs.md +++ /dev/null @@ -1,211 +0,0 @@ -# Dynamic linker tricks: Using LD_PRELOAD to cheat, inject features and investigate programs - -**This post assumes some basic C skills.** - -Linux puts you in full control. This is not always seen from everyone’s perspective, but a power user loves to be in control. I’m going to show you a basic trick that lets you heavily influence the behavior of most applications, which is not only fun, but also, at times, useful. - -#### A motivational example - -Let us begin with a simple example. Fun first, science later. - - -random_num.c: -``` -#include -#include -#include - -int main(){ - srand(time(NULL)); - int i = 10; - while(i--) printf("%d\n",rand()%100); - return 0; -} -``` - -Simple enough, I believe. I compiled it with no special flags, just - -> ``` -> gcc random_num.c -o random_num -> ``` - -I hope the resulting output is obvious – ten randomly selected numbers 0-99, hopefully different each time you run this program. - -Now let’s pretend we don’t really have the source of this executable. Either delete the source file, or move it somewhere – we won’t need it. We will significantly modify this programs behavior, yet without touching it’s source code nor recompiling it. - -For this, lets create another simple C file: - - -unrandom.c: -``` -int rand(){ - return 42; //the most random number in the universe -} -``` - -We’ll compile it into a shared library. - -> ``` -> gcc -shared -fPIC unrandom.c -o unrandom.so -> ``` - -So what we have now is an application that outputs some random data, and a custom library, which implements the rand() function as a constant value of 42\.  Now… just run  _random_num _ this way, and watch the result: - -> ``` -> LD_PRELOAD=$PWD/unrandom.so ./random_nums -> ``` - -If you are lazy and did not do it yourself (and somehow fail to guess what might have happened), I’ll let you know – the output consists of ten 42’s. - -This may be even more impressive it you first: - -> ``` -> export LD_PRELOAD=$PWD/unrandom.so -> ``` - -and then run the program normally. An unchanged app run in an apparently usual manner seems to be affected by what we did in our tiny library… - -###### **Wait, what? What did just happen?** - -Yup, you are right, our program failed to generate random numbers, because it did not use the “real” rand(), but the one we provided – which returns 42 every time. - -###### **But we *told* it to use the real one. We programmed it to use the real one. Besides, at the time we created that program, the fake rand() did not even exist!** - -This is not entirely true. We did not choose which rand() we want our program to use. We told it just to use rand(). - -When our program is started, certain libraries (that provide functionality needed by the program) are loaded. We can learn which are these using  _ldd_ : - -> ``` -> $ ldd random_nums -> linux-vdso.so.1 => (0x00007fff4bdfe000) -> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f48c03ec000) -> /lib64/ld-linux-x86-64.so.2 (0x00007f48c07e3000) -> ``` - -What you see as the output is the list of libs that are needed by  _random_nums_ . This list is built into the executable, and is determined compile time. The exact output might slightly differ on your machine, but a **libc.so** must be there – this is the file which provides core C functionality. That includes the “real” rand(). - -We can have a peek at what functions does libc provide. I used the following to get a full list: - -> ``` -> nm -D /lib/libc.so.6 -> ``` - -The  _nm_  command lists symbols found in a binary file. The -D flag tells it to look for dynamic symbols, which makes sense, as libc.so.6 is a dynamic library. The output is very long, but it indeed lists rand() among many other standard functions. - -Now what happens when we set up the environmental variable LD_PRELOAD? This variable **forces some libraries to be loaded for a program**. In our case, it loads  _unrandom.so_  for  _random_num_ , even though the program itself does not ask for it. The following command may be interesting: - -> ``` -> $ LD_PRELOAD=$PWD/unrandom.so ldd random_nums -> linux-vdso.so.1 => (0x00007fff369dc000) -> /some/path/to/unrandom.so (0x00007f262b439000) -> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f262b044000) -> /lib64/ld-linux-x86-64.so.2 (0x00007f262b63d000) -> ``` - -Note that it lists our custom library. And indeed this is the reason why it’s code get’s executed:  _random_num_  calls rand(), but if  _unrandom.so_  is loaded it is our library that provides implementation for rand(). Neat, isn’t it? - -#### Being transparent - -This is not enough. I’d like to be able to inject some code into an application in a similar manner, but in such way that it will be able to function normally. It’s clear if we implemented open() with a simple “ _return 0;_ “, the application we would like to hack should malfunction. The point is to be **transparent**, and to actually call the original open: - -inspect_open.c: -``` -int open(const char *pathname, int flags){ - /* Some evil injected code goes here. */ - return open(pathname,flags); // Here we call the "real" open function, that is provided to us by libc.so -} -``` - -Hm. Not really. This won’t call the “original” open(…). Obviously, this is an endless recursive call. - -How do we access the “real” open function? It is needed to use the programming interface to the dynamic linker. It’s simpler than it sounds. Have a look at this complete example, and then I’ll explain what happens there: - -inspect_open.c: - -``` -#define _GNU_SOURCE -#include - -typedef int (*orig_open_f_type)(const char *pathname, int flags); - -int open(const char *pathname, int flags, ...) -{ - /* Some evil injected code goes here. */ - - orig_open_f_type orig_open; - orig_open = (orig_open_f_type)dlsym(RTLD_NEXT,"open"); - return orig_open(pathname,flags); -} -``` - -The  _dlfcn.h_  is needed for  _dlsym_  function we use later. That strange  _#define_  directive instructs the compiler to enable some non-standard stuff, we need it to enable  _RTLD_NEXT_  in  _dlfcn.h_ . That typedef is just creating an alias to a complicated pointer-to-function type, with arguments just as the original open – the alias name is  _orig_open_f_type_ , which we’ll use later. - -The body of our custom open(…) consists of some custom code. The last part of it creates a new function pointer  _orig_open_  which will point to the original open(…) function. In order to get the address of that function, we ask  _dlsym_  to find for us the next “open” function on dynamic libraries stack. Finally, we call that function (passing the same arguments as were passed to our fake “open”), and return it’s return value as ours. - -As the “evil injected code” I simply used: - -inspect_open.c (fragment): - -``` -printf("The victim used open(...) to access '%s'!!!\n",pathname); //remember to include stdio.h! -``` - -To compile it, I needed to slightly adjust compiler flags: - -> ``` -> gcc -shared -fPIC  inspect_open.c -o inspect_open.so -ldl -> ``` - -I had to append  _-ldl_ , so that this shared library is linked to  _libdl_ , which provides the  _dlsym_  function. (Nah, I am not going to create a fake version of  _dlsym_ , though this might be fun.) - -So what do I have in result? A shared library, which implements the open(…) function so that it behaves **exactly** as the real open(…)… except it has a side effect of  _printf_ ing the file path :-) - -If you are not convinced this is a powerful trick, it’s the time you tried the following: - -> ``` -> LD_PRELOAD=$PWD/inspect_open.so gnome-calculator -> ``` - -I encourage you to see the result yourself, but basically it lists every file this application accesses. In real time. - -I believe it’s not that hard to imagine why this might be useful for debugging or investigating unknown applications. Please note, however, that this particular trick is not quite complete, because  _open()_  is not the only function that opens files… For example, there is also  _open64()_  in the standard library, and for full investigation you would need to create a fake one too. - -#### **Possible uses** - -If you are still with me and enjoyed the above, let me suggest a bunch of ideas of what can be achieved using this trick. Keep in mind that you can do all the above without to source of the affected app! - -1. ~~Gain root privileges.~~ Not really, don’t even bother, you won’t bypass any security this way. (A quick explanation for pros: no libraries will be preloaded this way if ruid != euid) - -2. Cheat games: **Unrandomize.** This is what I did in the first example. For a fully working case you would need also to implement a custom  _random()_ ,  _rand_r()_ _, random_r()_ . Also some apps may be reading from  _/dev/urandom_  or so, you might redirect them to  _/dev/null_  by running the original  _open()_  with a modified file path. Furthermore, some apps may have their own random number generation algorithm, there is little you can do about that (unless: point 10 below). But this looks like an easy exercise for beginners. - -3. Cheat games: **Bullet time. **Implement all standard time-related functions pretend the time flows two times slower. Or ten times slower. If you correctly calculate new values for time measurement, timed  _sleep_ functions, and others, the affected application will believe the time runs slower (or faster, if you wish), and you can experience awesome bullet-time action. - Or go **even one step further** and let your shared library also be a DBus client, so that you can communicate with it real time. Bind some shortcuts to custom commands, and with some additional calculations in your fake timing functions you will be able to enable&disable the slow-mo or fast-forward anytime you wish. - -4. Investigate apps: **List accessed files.** That’s what my second example does, but this could be also pushed further, by recording and monitoring all app’s file I/O. - -5. Investigate apps: **Monitor internet access.** You might do this with Wireshark or similar software, but with this trick you could actually gain control of what an app sends over the web, and not just look, but also affect the exchanged data. Lots of possibilities here, from detecting spyware, to cheating in multiplayer games, or analyzing & reverse-engineering protocols of closed-source applications. - -6. Investigate apps: **Inspect GTK structures.** Why just limit ourselves to standard library? Let’s inject code in all GTK calls, so that we can learn what widgets does an app use, and how are they structured. This might be then rendered either to an image or even to a gtkbuilder file! Super useful if you want to learn how does some app manage its interface! - -7. **Sandbox unsafe applications.** If you don’t trust some app and are afraid that it may wish to _ rm -rf / _ or do some other unwanted file activities, you might potentially redirect all it’s file IO to e.g. /tmp by appropriately modifying the arguments it passes to all file-related functions (not just  _open_ , but also e.g. removing directories etc.). It’s more difficult trick that a chroot, but it gives you more control. It would be only as safe as complete your “wrapper” was, and unless you really know what you’re doing, don’t actually run any malicious software this way. - -8. **Implement features.** [zlibc][1] is an actual library which is run this precise way; it uncompresses files on the go as they are accessed, so that any application can work on compressed data without even realizing it. - -9. **Fix bugs. **Another real-life example: some time ago (I am not sure this is still the case) Skype – which is closed-source – had problems capturing video from some certain webcams. Because the source could not be modified as Skype is not free software, this was fixed by preloading a library that would correct these problems with video. - -10. Manually **access application’s own memory**. Do note that you can access all app data this way. This may be not impressive if you are familiar with software like CheatEngine/scanmem/GameConqueror, but they all require root privileges to work. LD_PRELOAD does not. In fact, with a number of clever tricks your injected code might access all app memory, because, in fact, it gets executed by that application itself. You might modify everything this application can. You can probably imagine this allows a lot of low-level hacks… but I’ll post an article about it another time. - -These are only the ideas I came up with. I bet you can find some too, if you do – share them by commenting! - --------------------------------------------------------------------------------- - -via: https://rafalcieslak.wordpress.com/2013/04/02/dynamic-linker-tricks-using-ld_preload-to-cheat-inject-features-and-investigate-programs/ - -作者:[Rafał Cieślak ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://rafalcieslak.wordpress.com/ -[1]:http://www.zlibc.linux.lu/index.html diff --git a/sources/tech/20160330 How to turn any syscall into an event Introducing eBPF Kernel probes.md b/sources/tech/20160330 How to turn any syscall into an event Introducing eBPF Kernel probes.md deleted file mode 100644 index a53270f2d7..0000000000 --- a/sources/tech/20160330 How to turn any syscall into an event Introducing eBPF Kernel probes.md +++ /dev/null @@ -1,361 +0,0 @@ -How to turn any syscall into an event: Introducing eBPF Kernel probes -============================================================ - - -TL;DR: Using eBPF in recent (>=4.4) Linux kernel, you can turn any kernel function call into a user land event with arbitrary data. This is made easy by bcc. The probe is written in C while the data is handled by python. - -If you are not familiar with eBPF or linux tracing, you really should read the full post. It tries to progressively go through the pitfalls I stumbled unpon while playing around with bcc / eBPF while saving you a lot of the time I spent searching and digging. - -### A note on push vs pull in a Linux world - -When I started to work on containers, I was wondering how we could update a load balancer configuration dynamically based on actual system state. A common strategy, which works, it to let the container orchestrator trigger a load balancer configuration update whenever it starts a container and then let the load balancer poll the container until some health check passes. It may be a simple “SYN” test. - -While this configuration works, it has the downside of making your load balancer waiting for some system to be available while it should be… load balancing. - -Can we do better? - -When you want a program to react to some change in a system there are 2 possible strategies. The program may  _poll_  the system to detect changes or, if the system supports it, the system may  _push_ events and let the program react to them. Wether you want to use push or poll depends on the context. A good rule of the thumb is to use push events when the event rate is low with respect to the processing time and switch to polling when the events are coming fast or the system may become unusable. For example, typical network driver will wait for events from the network card while frameworks like dpdk will actively poll the card for events to achieve the highest throughput and lowest latency. - -In an ideal world, we’d have some kernel interface telling us: - -> * “Hey Mr. ContainerManager, I’ve just created a socket for the Nginx-ware of container  _servestaticfiles_ , maybe you want to update your state?” -> -> * “Sure Mr. OS, Thanks for letting me know” - -While Linux has a wide range of interfaces to deal with events, up to 3 for file events, there is no dedicated interface to get socket event notifications. You can get routing table events, neighbor table events, conntrack events, interface change events. Just, not socket events. Or maybe there is, deep hidden in a Netlink interface. - -Ideally, we’d need a generic way to do it. How? - -### Kernel tracing and eBPF, a bit of history - -Until recently the only way was to patch the kernel or resort on SystemTap. [SytemTap][5] is a tracing Linux system. In a nutshell, it provides a DSL which is then compiled into a kernel module which is then live-loaded into the running kernel. Except that some production system disable dynamic module loading for security reasons. Including the one I was working on at that time. The other way would be to patch the kernel to trigger some events, probably based on netlink. This is not really convenient. Kernel hacking come with downsides including “interesting” new “features” and increased maintenance burden. - -Hopefully, starting with Linux 3.15 the ground was laid to safely transform any traceable kernel function into userland events. “Safely” is common computer science expression referring to “some virtual machine”. This case is no exception. Linux has had one for years. Since Linux 2.1.75 released in 1997 actually. It’s called Berkeley Packet Filter of BPF for short. As its name suggests, it was originally developed for the BSD firewalls. It had only 2 registers and only allowed forward jumps meaning that you could not write loops with it (Well, you can, if you know the maximum iterations and you manually unroll them). The point was to guarantee the program would always terminate and hence never hang the system. Still not sure if it has any use while you have iptables? It serves as the [foundation of CloudFlare’s AntiDDos protection][6]. - -OK, so, with Linux the 3.15, [BPF was extended][7] turning it into eBPF. For “extended” BPF. It upgrades from 2 32 bits registers to 10 64 bits 64 registers and adds backward jumping among others. It has then been [further extended in Linux 3.18][8] moving it out of the networking subsystem, and adding tools like maps. To preserve the safety guarantees, it [introduces a checker][9] which validates all memory accesses and possible code path. If the checker can’t guarantee the code will terminate within fixed boundaries, it will deny the initial insertion of the program. - -For more history, there is [an excellent Oracle presentation on eBPF][10]. - -Let’s get started. - -### Hello from from `inet_listen` - -As writing assembly is not the most convenient task, even for the best of us, we’ll use [bcc][11]. bcc is a collection of tools based on LLVM and Python abstracting the underlying machinery. Probes are written in C and the results can be exploited from python allowing to easily write non trivial applications. - -Start by install bcc. For some of these examples, you may require a recent (read >= 4.4) version of the kernel. If you are willing to actually try these examples, I highly recommend that you setup a VM.  _NOT_  a docker container. You can’t change the kernel in a container. As this is a young and dynamic projects, install instructions are highly platform/version dependant. You can find up to date instructions on [https://github.com/iovisor/bcc/blob/master/INSTALL.md][12] - -So, we want to get an event whenever a program starts to listen on TCP socket. When calling the `listen()` syscall on a `AF_INET` + `SOCK_STREAM` socket, the underlying kernel function is [`inet_listen`][13]. We’ll start by hooking a “Hello World” `kprobe` on it’s entrypoint. - -``` -from bcc import BPF - -# Hello BPF Program -bpf_text = """ -#include -#include - -// 1\. Attach kprobe to "inet_listen" -int kprobe__inet_listen(struct pt_regs *ctx, struct socket *sock, int backlog) -{ - bpf_trace_printk("Hello World!\\n"); - return 0; -}; -""" - -# 2\. Build and Inject program -b = BPF(text=bpf_text) - -# 3\. Print debug output -while True: - print b.trace_readline() - -``` - -This program does 3 things: 1\. It attaches a kernel probe to “inet_listen” using a naming convention. If the function was called, say, “my_probe”, it could be explicitly attached with `b.attach_kprobe("inet_listen", "my_probe"`. 2\. It builds the program using LLVM new BPF backend, inject the resulting bytecode using the (new) `bpf()` syscall and automatically attaches the probes matching the naming convention. 3\. It reads the raw output from the kernel pipe. - -Note: eBPF backend of LLVM is still young. If you think you’ve hit a bug, you may want to upgrade. - -Noticed the `bpf_trace_printk` call? This is a stripped down version of the kernel’s `printk()`debug function. When used, it produces tracing informations to a special kernel pipe in `/sys/kernel/debug/tracing/trace_pipe`. As the name implies, this is a pipe. If multiple readers are consuming it, only 1 will get a given line. This makes it unsuitable for production. - -Fortunately, Linux 3.19 introduced maps for message passing and Linux 4.4 brings arbitrary perf events support. I’ll demo the perf event based approach later in this post. - -``` -# From a first console -ubuntu@bcc:~/dev/listen-evts$ sudo /python tcv4listen.py - nc-4940 [000] d... 22666.991714: : Hello World! - -# From a second console -ubuntu@bcc:~$ nc -l 0 4242 -^C - -``` - -Yay! - -### Grab the backlog - -Now, let’s print some easily accessible data. Say the “backlog”. The backlog is the number of pending established TCP connections, pending to be `accept()`ed. - -Just tweak a bit the `bpf_trace_printk`: - -``` -bpf_trace_printk("Listening with with up to %d pending connections!\\n", backlog); - -``` - -If you re-run the example with this world-changing improvement, you should see something like: - -``` -(bcc)ubuntu@bcc:~/dev/listen-evts$ sudo python tcv4listen.py - nc-5020 [000] d... 25497.154070: : Listening with with up to 1 pending connections! - -``` - -`nc` is a single connection program, hence the backlog of 1\. Nginx or Redis would output 128 here. But that’s another story. - -Easy hue? Now let’s get the port. - -### Grab the port and IP - -Studying `inet_listen` source from the kernel, we know that we need to get the `inet_sock` from the `socket` object. Just copy from the sources, and insert at the beginning of the tracer: - -``` -// cast types. Intermediate cast not needed, kept for readability -struct sock *sk = sock->sk; -struct inet_sock *inet = inet_sk(sk); - -``` - -The port can now be accessed from `inet->inet_sport` in network byte order (aka: Big Endian). Easy! So, we could just replace the `bpf_trace_printk` with: - -``` -bpf_trace_printk("Listening on port %d!\\n", inet->inet_sport); - -``` - -Then run: - -``` -ubuntu@bcc:~/dev/listen-evts$ sudo /python tcv4listen.py -... -R1 invalid mem access 'inv' -... -Exception: Failed to load BPF program kprobe__inet_listen - -``` - -Except that it’s not (yet) so simple. Bcc is improving a  _lot_  currently. While writing this post, a couple of pitfalls had already been addressed. But not yet all. This Error means the in-kernel checker could prove the memory accesses in program are correct. See the explicit cast. We need to help is a little by making the accesses more explicit. We’ll use `bpf_probe_read` trusted function to read an arbitrary memory location while guaranteeing all necessary checks are done with something like: - -``` -// Explicit initialization. The "=0" part is needed to "give life" to the variable on the stack -u16 lport = 0; - -// Explicit arbitrary memory access. Read it: -// Read into 'lport', 'sizeof(lport)' bytes from 'inet->inet_sport' memory location -bpf_probe_read(&lport, sizeof(lport), &(inet->inet_sport)); - -``` - -Reading the bound address for IPv4 is basically the same, using `inet->inet_rcv_saddr`. If we put is all together, we should get the backlog, the port and the bound IP: - -``` -from bcc import BPF - -# BPF Program -bpf_text = """ -#include -#include -#include - -// Send an event for each IPv4 listen with PID, bound address and port -int kprobe__inet_listen(struct pt_regs *ctx, struct socket *sock, int backlog) -{ - // Cast types. Intermediate cast not needed, kept for readability - struct sock *sk = sock->sk; - struct inet_sock *inet = inet_sk(sk); - - // Working values. You *need* to initialize them to give them "life" on the stack and use them afterward - u32 laddr = 0; - u16 lport = 0; - - // Pull in details. As 'inet_sk' is internally a type cast, we need to use 'bpf_probe_read' - // read: load into 'laddr' 'sizeof(laddr)' bytes from address 'inet->inet_rcv_saddr' - bpf_probe_read(&laddr, sizeof(laddr), &(inet->inet_rcv_saddr)); - bpf_probe_read(&lport, sizeof(lport), &(inet->inet_sport)); - - // Push event - bpf_trace_printk("Listening on %x %d with %d pending connections\\n", ntohl(laddr), ntohs(lport), backlog); - return 0; -}; -""" - -# Build and Inject BPF -b = BPF(text=bpf_text) - -# Print debug output -while True: - print b.trace_readline() - -``` - -A test run should output something like: - -``` -(bcc)ubuntu@bcc:~/dev/listen-evts$ sudo python tcv4listen.py - nc-5024 [000] d... 25821.166286: : Listening on 7f000001 4242 with 1 pending connections - -``` - -Provided that you listen on localhost. The address is displayed as hex here to avoid dealing with the IP pretty printing but that’s all wired. And that’s cool. - -Note: you may wonder why `ntohs` and `ntohl` can be called from BPF while they are not trusted. This is because they are macros and inline functions from “.h” files and a small bug was [fixed][14]while writing this post. - -All done, one more piece: We want to get the related container. In the context of networking, that’s means we want the network namespace. The network namespace being the building block of containers allowing them to have isolated networks. - -### Grab the network namespace: a forced introduction to perf events - -On the userland, the network namespace can be determined by checking the target of `/proc/PID/ns/net`. It should look like `net:[4026531957]`. The number between brackets is the inode number of the network namespace. This said, we could grab it by scrapping ‘/proc’ but this is racy, we may be dealing with short-lived processes. And races are never good. We’ll grab the inode number directly from the kernel. Fortunately, that’s an easy one: - -``` -// Create an populate the variable -u32 netns = 0; - -// Read the netns inode number, like /proc does -netns = sk->__sk_common.skc_net.net->ns.inum; - -``` - -Easy. And it works. - -But if you’ve read so far, you may guess there is something wrong somewhere. And there is: - -``` -bpf_trace_printk("Listening on %x %d with %d pending connections in container %d\\n", ntohl(laddr), ntohs(lport), backlog, netns); - -``` - -If you try to run it, you’ll get some cryptic error message: - -``` -(bcc)ubuntu@bcc:~/dev/listen-evts$ sudo python tcv4listen.py -error: in function kprobe__inet_listen i32 (%struct.pt_regs*, %struct.socket*, i32) -too many args to 0x1ba9108: i64 = Constant<6> - -``` - -What clang is trying to tell you is “Hey pal, `bpf_trace_printk` can only take 4 arguments, you’ve just used 5.“. I won’t dive into the details here, but that’s a BPF limitation. If you want to dig it, [here is a good starting point][15]. - -The only way to fix it is to… stop debugging and make it production ready. So let’s get started (and make sure run at least Linux 4.4). We’ll use perf events which supports passing arbitrary sized structures to userland. Additionally, only our reader will get it so that multiple unrelated eBPF programs can produce data concurrently without issues. - -To use it, we need to: - -1. define a structure - -2. declare the event - -3. push the event - -4. re-declare the event on Python’s side (This step should go away in the future) - -5. consume and format the event - -This may seem like a lot, but it ain’t. See: - -``` -// At the begining of the C program, declare our event -struct listen_evt_t { - u64 laddr; - u64 lport; - u64 netns; - u64 backlog; -}; -BPF_PERF_OUTPUT(listen_evt); - -// In kprobe__inet_listen, replace the printk with -struct listen_evt_t evt = { - .laddr = ntohl(laddr), - .lport = ntohs(lport), - .netns = netns, - .backlog = backlog, -}; -listen_evt.perf_submit(ctx, &evt, sizeof(evt)); - -``` - -Python side will require a little more work, though: - -``` -# We need ctypes to parse the event structure -import ctypes - -# Declare data format -class ListenEvt(ctypes.Structure): - _fields_ = [ - ("laddr", ctypes.c_ulonglong), - ("lport", ctypes.c_ulonglong), - ("netns", ctypes.c_ulonglong), - ("backlog", ctypes.c_ulonglong), - ] - -# Declare event printer -def print_event(cpu, data, size): - event = ctypes.cast(data, ctypes.POINTER(ListenEvt)).contents - print("Listening on %x %d with %d pending connections in container %d" % ( - event.laddr, - event.lport, - event.backlog, - event.netns, - )) - -# Replace the event loop -b["listen_evt"].open_perf_buffer(print_event) -while True: - b.kprobe_poll() - -``` - -Give it a try. In this example, I have a redis running in a docker container and nc on the host: - -``` -(bcc)ubuntu@bcc:~/dev/listen-evts$ sudo python tcv4listen.py -Listening on 0 6379 with 128 pending connections in container 4026532165 -Listening on 0 6379 with 128 pending connections in container 4026532165 -Listening on 7f000001 6588 with 1 pending connections in container 4026531957 - -``` - -### Last word - -Absolutely everything is now setup to use trigger events from arbitrary function calls in the kernel using eBPF, and you should have seen most of the common pitfalls I hit while learning eBPF. If you want to see the full version of this tool, along with some more tricks like IPv6 support, have a look at [https://github.com/iovisor/bcc/blob/master/tools/solisten.py][16]. It’s now an official tool, thanks to the support of the bcc team. - -To go further, you may want to checkout Brendan Gregg’s blog, in particular [the post about eBPF maps and statistics][17]. He his one of the project’s main contributor. - - --------------------------------------------------------------------------------- - -via: https://blog.yadutaf.fr/2016/03/30/turn-any-syscall-into-event-introducing-ebpf-kernel-probes/ - -作者:[Jean-Tiare Le Bigot ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://blog.yadutaf.fr/about -[1]:https://blog.yadutaf.fr/tags/linux -[2]:https://blog.yadutaf.fr/tags/tracing -[3]:https://blog.yadutaf.fr/tags/ebpf -[4]:https://blog.yadutaf.fr/tags/bcc -[5]:https://en.wikipedia.org/wiki/SystemTap -[6]:https://blog.cloudflare.com/bpf-the-forgotten-bytecode/ -[7]:https://blog.yadutaf.fr/2016/03/30/turn-any-syscall-into-event-introducing-ebpf-kernel-probes/TODO -[8]:https://lwn.net/Articles/604043/ -[9]:http://lxr.free-electrons.com/source/kernel/bpf/verifier.c#L21 -[10]:http://events.linuxfoundation.org/sites/events/files/slides/tracing-linux-ezannoni-linuxcon-ja-2015_0.pdf -[11]:https://github.com/iovisor/bcc -[12]:https://github.com/iovisor/bcc/blob/master/INSTALL.md -[13]:http://lxr.free-electrons.com/source/net/ipv4/af_inet.c#L194 -[14]:https://github.com/iovisor/bcc/pull/453 -[15]:http://lxr.free-electrons.com/source/kernel/trace/bpf_trace.c#L86 -[16]:https://github.com/iovisor/bcc/blob/master/tools/solisten.py -[17]:http://www.brendangregg.com/blog/2015-05-15/ebpf-one-small-step.html diff --git a/sources/tech/20160922 A Linux users guide to Logical Volume Management.md b/sources/tech/20160922 A Linux users guide to Logical Volume Management.md deleted file mode 100644 index ff0e390f38..0000000000 --- a/sources/tech/20160922 A Linux users guide to Logical Volume Management.md +++ /dev/null @@ -1,233 +0,0 @@ -A Linux user's guide to Logical Volume Management -============================================================ - -![Logical Volume Management (LVM)](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_other11x_cc.png?itok=I_kCDYj0 "Logical Volume Management (LVM)") -Image by : opensource.com - -Managing disk space has always been a significant task for sysadmins. Running out of disk space used to be the start of a long and complex series of tasks to increase the space available to a disk partition. It also required taking the system off-line. This usually involved installing a new hard drive, booting to recovery or single-user mode, creating a partition and a filesystem on the new hard drive, using temporary mount points to move the data from the too-small filesystem to the new, larger one, changing the content of the /etc/fstab file to reflect the correct device name for the new partition, and rebooting to remount the new filesystem on the correct mount point. - -I have to tell you that, when LVM (Logical Volume Manager) first made its appearance in Fedora Linux, I resisted it rather strongly. My initial reaction was that I did not need this additional layer of abstraction between me and the hard drives. It turns out that I was wrong, and that logical volume management is very useful. - -LVM allows for very flexible disk space management. It provides features like the ability to add disk space to a logical volume and its filesystem while that filesystem is mounted and active and it allows for the collection of multiple physical hard drives and partitions into a single volume group which can then be divided into logical volumes. - -The volume manager also allows reducing the amount of disk space allocated to a logical volume, but there are a couple requirements. First, the volume must be unmounted. Second, the filesystem itself must be reduced in size before the volume on which it resides can be reduced. - -It is important to note that the filesystem itself must allow resizing for this feature to work. The EXT2, 3, and 4 filesystems all allow both offline (unmounted) and online (mounted) resizing when increasing the size of a filesystem, and offline resizing when reducing the size. You should check the details of the filesystems you intend to use in order to verify whether they can be resized at all and especially whether they can be resized while online. - -### Expanding a filesystem on the fly - -I always like to run new distributions in a VirtualBox virtual machine for a few days or weeks to ensure that I will not run into any devastating problems when I start installing it on my production machines. One morning a couple years ago I started installing a newly released version of Fedora in a virtual machine on my primary workstation. I thought that I had enough disk space allocated to the host filesystem in which the VM was being installed. I did not. About a third of the way through the installation I ran out of space on that filesystem. Fortunately, VirtualBox detected the out-of-space condition and paused the virtual machine, and even displayed an error message indicating the exact cause of the problem. - -Note that this problem was not due to the fact that the virtual disk was too small, it was rather the logical volume on the host computer that was running out of space so that the virtual disk belonging to the virtual machine did not have enough space to expand on the host's logical volume. - -Since most modern distributions use Logical Volume Management by default, and I had some free space available on the volume group, I was able to assign additional disk space to the appropriate logical volume and then expand filesystem of the host on the fly. This means that I did not have to reformat the entire hard drive and reinstall the operating system or even reboot. I simply assigned some of the available space to the appropriate logical volume and resized the filesystem—all while the filesystem was on-line and the running program, The virtual machine was still using the host filesystem. After resizing the logical volume and the filesystem I resumed running the virtual machine and the installation continued as if no problems had occurred. - -Although this type of problem may never have happened to you, running out of disk space while a critical program is running has happened to many people. And while many programs, especially Windows programs, are not as well written and resilient as VirtualBox, Linux Logical Volume Management made it possible to recover without losing any data and without having to restart the time-consuming installation. - -### LVM Structure - -The structure of a Logical Volume Manager disk environment is illustrated by Figure 1, below. Logical Volume Management enables the combining of multiple individual hard drives and/or disk partitions into a single volume group (VG). That volume group can then be subdivided into logical volumes (LV) or used as a single large volume. Regular file systems, such as EXT3 or EXT4, can then be created on a logical volume. - -In Figure 1, two complete physical hard drives and one partition from a third hard drive have been combined into a single volume group. Two logical volumes have been created from the space in the volume group, and a filesystem, such as an EXT3 or EXT4 filesystem has been created on each of the two logical volumes. - -![lvm.png](https://opensource.com/sites/default/files/resize/images/life-uploads/lvm-520x222.png) - - _Figure 1: LVM allows combining partitions and entire hard drives into Volume Groups._ - -Adding disk space to a host is fairly straightforward but, in my experience, is done relatively infrequently. The basic steps needed are listed below. You can either create an entirely new volume group or you can add the new space to an existing volume group and either expand an existing logical volume or create a new one. - -### Adding a new logical volume - -There are times when it is necessary to add a new logical volume to a host. For example, after noticing that the directory containing virtual disks for my VirtualBox virtual machines was filling up the /home filesystem, I decided to create a new logical volume in which to store the virtual machine data, including the virtual disks. This would free up a great deal of space in my /home filesystem and also allow me to manage the disk space for the VMs independently. - -The basic steps for adding a new logical volume are as follows. - -1. If necessary, install a new hard drive. - -2. Optional: Create a partition on the hard drive. - -3. Create a physical volume (PV) of the complete hard drive or a partition on the hard drive. - -4. Assign the new physical volume to an existing volume group (VG) or create a new volume group. - -5. Create a new logical volumes (LV) from the space in the volume group. - -6. Create a filesystem on the new logical volume. - -7. Add appropriate entries to /etc/fstab for mounting the filesystem. - -8. Mount the filesystem. - -Now for the details. The following sequence is taken from an example I used as a lab project when teaching about Linux filesystems. - -### Example - -This example shows how to use the CLI to extend an existing volume group to add more space to it, create a new logical volume in that space, and create a filesystem on the logical volume. This procedure can be performed on a running, mounted filesystem. - -WARNING: Only the EXT3 and EXT4 filesystems can be resized on the fly on a running, mounted filesystem. Many other filesystems including BTRFS and ZFS cannot be resized. - -### Install hard drive - -If there is not enough space in the volume group on the existing hard drive(s) in the system to add the desired amount of space it may be necessary to add a new hard drive and create the space to add to the Logical Volume. First, install the physical hard drive, and then perform the following steps. - -### Create Physical Volume from hard drive - -It is first necessary to create a new Physical Volume (PV). Use the command below, which assumes that the new hard drive is assigned as /dev/hdd. - -``` -pvcreate /dev/hdd -``` - -It is not necessary to create a partition of any kind on the new hard drive. This creation of the Physical Volume which will be recognized by the Logical Volume Manager can be performed on a newly installed raw disk or on a Linux partition of type 83\. If you are going to use the entire hard drive, creating a partition first does not offer any particular advantages and uses disk space for metadata that could otherwise be used as part of the PV. - -### Extend the existing Volume Group - -In this example we will extend an existing volume group rather than creating a new one; you can choose to do it either way. After the Physical Volume has been created, extend the existing Volume Group (VG) to include the space on the new PV. In this example the existing Volume Group is named MyVG01. - -``` -vgextend /dev/MyVG01 /dev/hdd -``` - -### Create the Logical Volume - -First create the Logical Volume (LV) from existing free space within the Volume Group. The command below creates a LV with a size of 50GB. The Volume Group name is MyVG01 and the Logical Volume Name is Stuff. - -``` -lvcreate -L +50G --name Stuff MyVG01 -``` - -### Create the filesystem - -Creating the Logical Volume does not create the filesystem. That task must be performed separately. The command below creates an EXT4 filesystem that fits the newly created Logical Volume. - -``` -mkfs -t ext4 /dev/MyVG01/Stuff -``` - -### Add a filesystem label - -Adding a filesystem label makes it easy to identify the filesystem later in case of a crash or other disk related problems. - -``` -e2label /dev/MyVG01/Stuff Stuff -``` - -### Mount the filesystem - -At this point you can create a mount point, add an appropriate entry to the /etc/fstab file, and mount the filesystem. - -You should also check to verify the volume has been created correctly. You can use the **df**, **lvs,** and **vgs** commands to do this. - -### Resizing a logical volume in an LVM filesystem - -The need to resize a filesystem has been around since the beginning of the first versions of Unix and has not gone away with Linux. It has gotten easier, however, with Logical Volume Management. - -1. If necessary, install a new hard drive. - -2. Optional: Create a partition on the hard drive. - -3. Create a physical volume (PV) of the complete hard drive or a partition on the hard drive. - -4. Assign the new physical volume to an existing volume group (VG) or create a new volume group. - -5. Create one or more logical volumes (LV) from the space in the volume group, or expand an existing logical volume with some or all of the new space in the volume group. - -6. If you created a new logical volume, create a filesystem on it. If adding space to an existing logical volume, use the resize2fs command to enlarge the filesystem to fill the space in the logical volume. - -7. Add appropriate entries to /etc/fstab for mounting the filesystem. - -8. Mount the filesystem. - -### Example - -This example describes how to resize an existing Logical Volume in an LVM environment using the CLI. It adds about 50GB of space to the /Stuff filesystem. This procedure can be used on a mounted, live filesystem only with the Linux 2.6 Kernel (and higher) and EXT3 and EXT4 filesystems. I do not recommend that you do so on any critical system, but it can be done and I have done so many times; even on the root (/) filesystem. Use your judgment. - -WARNING: Only the EXT3 and EXT4 filesystems can be resized on the fly on a running, mounted filesystem. Many other filesystems including BTRFS and ZFS cannot be resized. - -### Install the hard drive - -If there is not enough space on the existing hard drive(s) in the system to add the desired amount of space it may be necessary to add a new hard drive and create the space to add to the Logical Volume. First, install the physical hard drive and then perform the following steps. - -### Create a Physical Volume from the hard drive - -It is first necessary to create a new Physical Volume (PV). Use the command below, which assumes that the new hard drive is assigned as /dev/hdd. - -``` -pvcreate /dev/hdd -``` - -It is not necessary to create a partition of any kind on the new hard drive. This creation of the Physical Volume which will be recognized by the Logical Volume Manager can be performed on a newly installed raw disk or on a Linux partition of type 83\. If you are going to use the entire hard drive, creating a partition first does not offer any particular advantages and uses disk space for metadata that could otherwise be used as part of the PV. - -### Add PV to existing Volume Group - -For this example, we will use the new PV to extend an existing Volume Group. After the Physical Volume has been created, extend the existing Volume Group (VG) to include the space on the new PV. In this example, the existing Volume Group is named MyVG01. - -``` -vgextend /dev/MyVG01 /dev/hdd -``` - -### Extend the Logical Volume - -Extend the Logical Volume (LV) from existing free space within the Volume Group. The command below expands the LV by 50GB. The Volume Group name is MyVG01 and the Logical Volume Name is Stuff. - -``` -lvextend -L +50G /dev/MyVG01/Stuff -``` - -### Expand the filesystem - -Extending the Logical Volume will also expand the filesystem if you use the -r option. If you do not use the -r option, that task must be performed separately. The command below resizes the filesystem to fit the newly resized Logical Volume. - -``` -resize2fs /dev/MyVG01/Stuff -``` - -You should check to verify the resizing has been performed correctly. You can use the **df**, **lvs,** and **vgs** commands to do this. - -### Tips - -Over the years I have learned a few things that can make logical volume management even easier than it already is. Hopefully these tips can prove of some value to you. - -* Use the Extended file systems unless you have a clear reason to use another filesystem. Not all filesystems support resizing but EXT2, 3, and 4 do. The EXT filesystems are also very fast and efficient. In any event, they can be tuned by a knowledgeable sysadmin to meet the needs of most environments if the defaults tuning parameters do not. - -* Use meaningful volume and volume group names. - -* Use EXT filesystem labels. - -I know that, like me, many sysadmins have resisted the change to Logical Volume Management. I hope that this article will encourage you to at least try LVM. I am really glad that I did; my disk management tasks are much easier since I made the switch. - - -### About the author - - [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/david-crop.jpg?itok=oePpOpyV)][10] - - David Both - David Both is a Linux and Open Source advocate who resides in Raleigh, North Carolina. He has been in the IT industry for over forty years and taught OS/2 for IBM where he worked for over 20 years. While at IBM, he wrote the first training course for the original IBM PC in 1981\. He has taught RHCE classes for Red Hat and has worked at MCI Worldcom, Cisco, and the State of North Carolina. He has been working with Linux and Open Source Software for almost 20 years. David has written articles for... [more about David Both][7][More about me][8] - --------------------------------------------------------------------------------- - -via: https://opensource.com/business/16/9/linux-users-guide-lvm - -作者:[ David Both][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/dboth -[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[6]:https://opensource.com/business/16/9/linux-users-guide-lvm?rate=79vf1js7A7rlp-I96YFneopUQqsa2SuB-g-og7eiF1U -[7]:https://opensource.com/users/dboth -[8]:https://opensource.com/users/dboth -[9]:https://opensource.com/user/14106/feed -[10]:https://opensource.com/users/dboth -[11]:https://opensource.com/users/dboth -[12]:https://opensource.com/users/dboth -[13]:https://opensource.com/business/16/9/linux-users-guide-lvm#comments -[14]:https://opensource.com/tags/business -[15]:https://opensource.com/tags/linux -[16]:https://opensource.com/tags/how-tos-and-tutorials -[17]:https://opensource.com/tags/sysadmin diff --git a/sources/tech/20170209 INTRODUCING DOCKER SECRETS MANAGEMENT.md b/sources/tech/20170209 INTRODUCING DOCKER SECRETS MANAGEMENT.md deleted file mode 100644 index a3fc2c886e..0000000000 --- a/sources/tech/20170209 INTRODUCING DOCKER SECRETS MANAGEMENT.md +++ /dev/null @@ -1,110 +0,0 @@ -INTRODUCING DOCKER SECRETS MANAGEMENT -============================================================ - -Containers are changing how we view apps and infrastructure. Whether the code inside containers is big or small, container architecture introduces a change to how that code behaves with hardware – it fundamentally abstracts it from the infrastructure. Docker believes that there are three key components to container security and together they result in inherently safer apps. - - ![Docker Security](https://i2.wp.com/blog.docker.com/wp-content/uploads/e12387a1-ab21-4942-8760-5b1677bc656d-1.jpg?w=1140&ssl=1) - -A critical element of building safer apps is having a secure way of communicating with other apps and systems, something that often requires credentials, tokens, passwords and other types of confidential information—usually referred to as application secrets. We are excited to introduce Docker Secrets, a container native solution that strengthens the Trusted Delivery component of container security by integrating secret distribution directly into the container platform. - -With containers, applications are now dynamic and portable across multiple environments. This  made existing secrets distribution solutions inadequate because they were largely designed for static environments. Unfortunately, this led to an increase in mismanagement of application secrets, making it common to find insecure, home-grown solutions, such as embedding secrets into version control systems like GitHub, or other equally bad—bolted on point solutions as an afterthought. - -### Introducing Docker Secrets Management - -We fundamentally believe that apps are safer if there is a standardized interface for accessing secrets. Any good solution will also have to follow security best practices, such as encrypting secrets while in transit; encrypting secrets at rest; preventing secrets from unintentionally leaking when consumed by the final application; and strictly adhere to the principle of least-privilege, where an application only has access to the secrets that it needs—no more, no less. - -By integrating secrets into Docker orchestration, we are able to deliver a solution for the secrets management problem that follows these exact principles. - -The following diagram provides a high-level view of how the Docker swarm mode architecture is applied to securely deliver a new type of object to our containers: a secret object. - - ![Docker Secrets Management](https://i0.wp.com/blog.docker.com/wp-content/uploads/b69d2410-9e25-44d8-aa2d-f67b795ff5e3.jpg?w=1140&ssl=1) - -In Docker, a secret is any blob of data, such as a password, SSH private key, TLS Certificate, or any other piece of data that is sensitive in nature. When you add a secret to the swarm (by running `docker secret create`), Docker sends the secret over to the swarm manager over a mutually authenticated TLS connection, making use of the [built-in Certificate Authority][17] that gets automatically created when bootstrapping a new swarm. - -``` -$ echo "This is a secret" | docker secret create my_secret_data - -``` - -Once the secret reaches a manager node, it gets saved to the internal Raft store, which uses NACL’s Salsa20Poly1305 with a 256-bit key to ensure no data is ever written to disk unencrypted. Writing to the internal store gives secrets the same high availability guarantees that the the rest of the swarm management data gets. - -When a swarm manager starts up, the encrypted Raft logs containing the secrets is decrypted using a data encryption key that is unique per-node. This key, and the node’s TLS credentials used to communicate with the rest of the cluster, can be encrypted with a cluster-wide key encryption key, called the unlock key, which is also propagated using Raft and will be required on manager start. - -When you grant a newly-created or running service access to a secret, one of the manager nodes (only managers have access to all the stored secrets stored) will send it over the already established TLS connection exclusively to the nodes that will be running that specific service. This means that nodes cannot request the secrets themselves, and will only gain access to the secrets when provided to them by a manager – strictly for the services that require them. - -``` -$ docker service  create --name="redis" --secret="my_secret_data" redis:alpine -``` - -The  unencrypted secret is mounted into the container in an in-memory filesystem at /run/secrets/. - -``` -$ docker exec $(docker ps --filter name=redis -q) ls -l /run/secrets -total 4 --r--r--r--    1 root     root            17 Dec 13 22:48 my_secret_data -``` - -If a service gets deleted, or rescheduled somewhere else, the manager will immediately notify all the nodes that no longer require access to that secret to erase it from memory, and the node will no longer have any access to that application secret. - -``` -$ docker service update --secret-rm="my_secret_data" redis - -$ docker exec -it $(docker ps --filter name=redis -q) cat /run/secrets/my_secret_data - -cat: can't open '/run/secrets/my_secret_data': No such file or directory -``` - -Check out the [Docker secrets docs][18] for more information and examples on how to create and manage your secrets. And a special shout out to Laurens Van Houtven (https://www.lvh.io/[)][19] in collaboration with the Docker security and core engineering team to help make this feature a reality. - -[Get safer apps for dev and ops w/ new #Docker secrets management][5] - -[CLICK TO TWEET][6] - -### -![Docker Security](https://i2.wp.com/blog.docker.com/wp-content/uploads/Screenshot-2017-02-08-23.30.13.png?resize=1032%2C111&ssl=1) - -### Safer Apps with Docker - -Docker secrets is designed to be easily usable by developers and IT ops teams to build and run safer apps. Docker secrets is a container first architecture designed to keep secrets safe and used only when needed by the exact container that needs that secret to operate. From defining apps and secrets with Docker Compose through an IT admin deploying that Compose file directly in Docker Datacenter, the services, secrets, networks and volumes will travel securely, safely with the application. - -Resources to learn more: - -* [Docker Datacenter on 1.13 with Secrets, Security Scanning, Content Cache and More][7] - -* [Download Docker][8] and get started today - -* [Try secrets in Docker Datacenter][9] - -* [Read the Documentation][10] - -* Attend an [upcoming webinar][11] - --------------------------------------------------------------------------------- - -via: https://blog.docker.com/2017/02/docker-secrets-management/ - -作者:[ Ying Li][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://blog.docker.com/author/yingli/ -[1]:http://www.linkedin.com/shareArticle?mini=true&url=http://dockr.ly/2k6gnOB&title=Introducing%20Docker%20Secrets%20Management&summary=Containers%20are%20changing%20how%20we%20view%20apps%20and%20infrastructure.%20Whether%20the%20code%20inside%20containers%20is%20big%20or%20small,%20container%20architecture%20introduces%20a%20change%20to%20how%20that%20code%20behaves%20with%20hardware%20-%20it%20fundamentally%20abstracts%20it%20from%20the%20infrastructure.%20Docker%20believes%20that%20there%20are%20three%20key%20components%20to%20container%20security%20and%20... -[2]:http://www.reddit.com/submit?url=http://dockr.ly/2k6gnOB&title=Introducing%20Docker%20Secrets%20Management -[3]:https://plus.google.com/share?url=http://dockr.ly/2k6gnOB -[4]:http://news.ycombinator.com/submitlink?u=http://dockr.ly/2k6gnOB&t=Introducing%20Docker%20Secrets%20Management -[5]:https://twitter.com/share?text=Get+safer+apps+for+dev+and+ops+w%2F+new+%23Docker+secrets+management+&via=docker&related=docker&url=http://dockr.ly/2k6gnOB -[6]:https://twitter.com/share?text=Get+safer+apps+for+dev+and+ops+w%2F+new+%23Docker+secrets+management+&via=docker&related=docker&url=http://dockr.ly/2k6gnOB -[7]:http://dockr.ly/AppSecurity -[8]:https://www.docker.com/getdocker -[9]:http://www.docker.com/trial -[10]:https://docs.docker.com/engine/swarm/secrets/ -[11]:http://www.docker.com/webinars -[12]:https://blog.docker.com/author/yingli/ -[13]:https://blog.docker.com/tag/container-security/ -[14]:https://blog.docker.com/tag/docker-security/ -[15]:https://blog.docker.com/tag/secrets-management/ -[16]:https://blog.docker.com/tag/security/ -[17]:https://docs.docker.com/engine/swarm/how-swarm-mode-works/pki/ -[18]:https://docs.docker.com/engine/swarm/secrets/ -[19]:https://lvh.io%29/ diff --git a/sources/tech/20170530 How to Improve a Legacy Codebase.md b/sources/tech/20170530 How to Improve a Legacy Codebase.md new file mode 100644 index 0000000000..cff5e70538 --- /dev/null +++ b/sources/tech/20170530 How to Improve a Legacy Codebase.md @@ -0,0 +1,108 @@ +Translating by aiwhj +# How to Improve a Legacy Codebase + + +It happens at least once in the lifetime of every programmer, project manager or teamleader. You get handed a steaming pile of manure, if you’re lucky only a few million lines worth, the original programmers have long ago left for sunnier places and the documentation - if there is any to begin with - is hopelessly out of sync with what is presently keeping the company afloat. + +Your job: get us out of this mess. + +After your first instinctive response (run for the hills) has passed you start on the project knowing full well that the eyes of the company senior leadership are on you. Failure is not an option. And yet, by the looks of what you’ve been given failure is very much in the cards. So what to do? + +I’ve been (un)fortunate enough to be in this situation several times and me and a small band of friends have found that it is a lucrative business to be able to take these steaming piles of misery and to turn them into healthy maintainable projects. Here are some of the tricks that we employ: + +### Backup + +Before you start to do anything at all make a backup of  _everything_  that might be relevant. This to make sure that no information is lost that might be of crucial importance somewhere down the line. All it takes is a silly question that you can’t answer to eat up a day or more once the change has been made. Especially configuration data is susceptible to this kind of problem, it is usually not versioned and you’re lucky if it is taken along in the periodic back-up scheme. So better safe than sorry, copy everything to a very safe place and never ever touch that unless it is in read-only mode. + +### Important pre-requisite, make sure you have a build process and that it actually produces what runs in production + +I totally missed this step on the assumption that it is obvious and likely already in place but many HN commenters pointed this out and they are absolutely right: step one is to make sure that you know what is running in production right now and that means that you need to be able to build a version of the software that is - if your platform works that way - byte-for-byte identical with the current production build. If you can’t find a way to achieve this then likely you will be in for some unpleasant surprises once you commit something to production. Make sure you test this to the best of your ability to make sure that you have all the pieces in place and then, after you’ve gained sufficient confidence that it will work move it to production. Be prepared to switch back immediately to whatever was running before and make sure that you log everything and anything that might come in handy during the - inevitable - post mortem. + +### Freeze the DB + +If at all possible freeze the database schema until you are done with the first level of improvements, by the time you have a solid understanding of the codebase and the legacy code has been fully left behind you are ready to modify the database schema. Change it any earlier than that and you may have a real problem on your hand, now you’ve lost the ability to run an old and a new codebase side-by-side with the database as the steady foundation to build on. Keeping the DB totally unchanged allows you to compare the effect your new business logic code has compared to the old business logic code, if it all works as advertised there should be no differences. + +### Write your tests + +Before you make any changes at all write as many end-to-end and integration tests as you can. Make sure these tests produce the right output and test any and all assumptions that you can come up with about how you  _think_  the old stuff works (be prepared for surprises here). These tests will have two important functions: they will help to clear up any misconceptions at a very early stage and they will function as guardrails once you start writing new code to replace old code. + +Automate all your testing, if you’re already experienced with CI then use it and make sure your tests run fast enough to run the full set of tests after every commit. + +### Instrumentation and logging + +If the old platform is still available for development add instrumentation. Do this in a completely new database table, add a simple counter for every event that you can think of and add a single function to increment these counters based on the name of the event. That way you can implement a time-stamped event log with a few extra lines of code and you’ll get a good idea of how many events of one kind lead to events of another kind. One example: User opens app, User closes app. If two events should result in some back-end calls those two counters should over the long term remain at a constant difference, the difference is the number of apps currently open. If you see many more app opens than app closes you know there has to be a way in which apps end (for instance a crash). For each and every event you’ll find there is some kind of relationship to other events, usually you will strive for constant relationships unless there is an obvious error somewhere in the system. You’ll aim to reduce those counters that indicate errors and you’ll aim to maximize counters further down in the chain to the level indicated by the counters at the beginning. (For instance: customers attempting to pay should result in an equal number of actual payments received). + +This very simple trick turns every backend application into a bookkeeping system of sorts and just like with a real bookkeeping system the numbers have to match, as long as they don’t you have a problem somewhere. + +This system will over time become invaluable in establishing the health of the system and will be a great companion next to the source code control system revision log where you can determine the point in time that a bug was introduced and what the effect was on the various counters. + +I usually keep these counters at a 5 minute resolution (so 12 buckets for an hour), but if you have an application that generates fewer or more events then you might decide to change the interval at which new buckets are created. All counters share the same database table and so each counter is simply a column in that table. + +### Change only one thing at the time + +Do not fall into the trap of improving both the maintainability of the code or the platform it runs on at the same time as adding new features or fixing bugs. This will cause you huge headaches because you now have to ask yourself every step of the way what the desired outcome is of an action and will invalidate some of the tests you made earlier. + +### Platform changes + +If you’ve decided to migrate the application to another platform then do this first  _but keep everything else exactly the same_ . If you want you can add more documentation or tests, but no more than that, all business logic and interdependencies should remain as before. + +### Architecture changes + +The next thing to tackle is to change the architecture of the application (if desired). At this point in time you are free to change the higher level structure of the code, usually by reducing the number of horizontal links between modules, and thus reducing the scope of the code active during any one interaction with the end-user. If the old code was monolithic in nature now would be a good time to make it more modular, break up large functions into smaller ones but leave names of variables and data-structures as they were. + +HN user [mannykannot][1] points - rightfully - out that this is not always an option, if you’re particularly unlucky then you may have to dig in deep in order to be able to make any architecture changes. I agree with that and I should have included it here so hence this little update. What I would further like to add is if you do both do high level changes and low level changes at least try to limit them to one file or worst case one subsystem so that you limit the scope of your changes as much as possible. Otherwise you might have a very hard time debugging the change you just made. + +### Low level refactoring + +By now you should have a very good understanding of what each module does and you are ready for the real work: refactoring the code to improve maintainability and to make the code ready for new functionality. This will likely be the part of the project that consumes the most time, document as you go, do not make changes to a module until you have thoroughly documented it and feel you understand it. Feel free to rename variables and functions as well as datastructures to improve clarity and consistency, add tests (also unit tests, if the situation warrants them). + +### Fix bugs + +Now you’re ready to take on actual end-user visible changes, the first order of battle will be the long list of bugs that have accumulated over the years in the ticket queue. As usual, first confirm the problem still exists, write a test to that effect and then fix the bug, your CI and the end-to-end tests written should keep you safe from any mistakes you make due to a lack of understanding or some peripheral issue. + +### Database Upgrade + +If required after all this is done and you are on a solid and maintainable codebase again you have the option to change the database schema or to replace the database with a different make/model altogether if that is what you had planned to do. All the work you’ve done up to this point will help to assist you in making that change in a responsible manner without any surprises, you can completely test the new DB with the new code and all the tests in place to make sure your migration goes off without a hitch. + +### Execute on the roadmap + +Congratulations, you are out of the woods and are now ready to implement new functionality. + +### Do not ever even attempt a big-bang rewrite + +A big-bang rewrite is the kind of project that is pretty much guaranteed to fail. For one, you are in uncharted territory to begin with so how would you even know what to build, for another, you are pushing  _all_  the problems to the very last day, the day just before you go ‘live’ with your new system. And that’s when you’ll fail, miserably. Business logic assumptions will turn out to be faulty, suddenly you’ll gain insight into why that old system did certain things the way it did and in general you’ll end up realizing that the guys that put the old system together weren’t maybe idiots after all. If you really do want to wreck the company (and your own reputation to boot) by all means, do a big-bang rewrite, but if you’re smart about it this is not even on the table as an option. + +### So, the alternative, work incrementally + +To untangle one of these hairballs the quickest path to safety is to take any element of the code that you do understand (it could be a peripheral bit, but it might also be some core module) and try to incrementally improve it still within the old context. If the old build tools are no longer available you will have to use some tricks (see below) but at least try to leave as much of what is known to work alive while you start with your changes. That way as the codebase improves so does your understanding of what it actually does. A typical commit should be at most a couple of lines. + +### Release! + +Every change along the way gets released into production, even if the changes are not end-user visible it is important to make the smallest possible steps because as long as you lack understanding of the system there is a fair chance that only the production environment will tell you there is a problem. If that problem arises right after you make a small change you will gain several advantages: + +* it will probably be trivial to figure out what went wrong + +* you will be in an excellent position to improve the process + +* and you should immediately update the documentation to show the new insights gained + +### Use proxies to your advantage + +If you are doing web development praise the gods and insert a proxy between the end-users and the old system. Now you have per-url control over which requests go to the old system and which you will re-route to the new system allowing much easier and more granular control over what is run and who gets to see it. If your proxy is clever enough you could probably use it to send a percentage of the traffic to the new system for an individual URL until you are satisfied that things work the way they should. If your integration tests also connect to this interface it is even better. + +### Yes, but all this will take too much time! + +Well, that depends on how you look at it. It’s true there is a bit of re-work involved in following these steps. But it  _does_  work, and any kind of optimization of this process makes the assumption that you know more about the system than you probably do. I’ve got a reputation to maintain and I  _really_  do not like negative surprises during work like this. With some luck the company is already on the skids, or maybe there is a real danger of messing things up for the customers. In a situation like that I prefer total control and an iron clad process over saving a couple of days or weeks if that imperils a good outcome. If you’re more into cowboy stuff - and your bosses agree - then maybe it would be acceptable to take more risk, but most companies would rather take the slightly slower but much more sure road to victory. + +-------------------------------------------------------------------------------- + +via: https://jacquesmattheij.com/improving-a-legacy-codebase + +作者:[Jacques Mattheij ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jacquesmattheij.com/ +[1]:https://news.ycombinator.com/item?id=14445661 diff --git a/sources/tech/20170607 Why Car Companies Are Hiring Computer Security Experts.md b/sources/tech/20170607 Why Car Companies Are Hiring Computer Security Experts.md deleted file mode 100644 index 4a7d23e5f0..0000000000 --- a/sources/tech/20170607 Why Car Companies Are Hiring Computer Security Experts.md +++ /dev/null @@ -1,91 +0,0 @@ -Why Car Companies Are Hiring Computer Security Experts -============================================================ - -Photo -![](https://static01.nyt.com/images/2017/06/08/business/08BITS-GURUS1/08BITS-GURUS1-superJumbo.jpg) -The cybersecurity experts Marc Rogers, left, of CloudFlare and Kevin Mahaffey of Lookout were able to control various Tesla functions from their physically connected laptop. They pose in CloudFlare’s lobby in front of Lava Lamps used to generate numbers for encryption.CreditChristie Hemm Klok for The New York Times - -It started about seven years ago. Iran’s top nuclear scientists were being assassinated in a string of similar attacks: Assailants on motorcycles were pulling up to their moving cars, attaching magnetic bombs and detonating them after the motorcyclists had fled the scene. - -In another seven years, security experts warn, assassins won’t need motorcycles or magnetic bombs. All they’ll need is a laptop and code to send driverless cars careering off a bridge, colliding with a driverless truck or coming to an unexpected stop in the middle of fast-moving traffic. - -Automakers may call them self-driving cars. But hackers call them computers that travel over 100 miles an hour. - -“These are no longer cars,” said Marc Rogers, the principal security researcher at the cybersecurity firm CloudFlare. “These are data centers on wheels. Any part of the car that talks to the outside world is a potential inroad for attackers.” - -Those fears came into focus two years ago when two “white hat” hackers — researchers who look for computer vulnerabilities to spot problems and fix them, rather than to commit a crime or cause problems — successfully gained access to a Jeep Cherokee from their computer miles away. They rendered their crash-test dummy (in this case a nervous reporter) powerless over his vehicle and disabling his transmission in the middle of a highway. - -The hackers, Chris Valasek and Charlie Miller (now security researchers respectively at Uber and Didi, an Uber competitor in China), discovered an [electronic route from the Jeep’s entertainment system to its dashboard][10]. From there, they had control of the vehicle’s steering, brakes and transmission — everything they needed to paralyze their crash test dummy in the middle of a highway. - -“Car hacking makes great headlines, but remember: No one has ever had their car hacked by a bad guy,” Mr. Miller wrote on Twitter last Sunday. “It’s only ever been performed by researchers.” - -Still, the research by Mr. Miller and Mr. Valasek came at a steep price for Jeep’s manufacturer, Fiat Chrysler, which was forced to recall 1.4 million of its vehicles as a result of the hacking experiment. - -It is no wonder that Mary Barra, the chief executive of General Motors, called cybersecurity her company’s top priority last year. Now the skills of researchers and so-called white hat hackers are in high demand among automakers and tech companies pushing ahead with driverless car projects. - -Uber, [Tesla][11], Apple and Didi in China have been actively recruiting white hat hackers like Mr. Miller and Mr. Valasek from one another as well as from traditional cybersecurity firms and academia. - -Last year, Tesla poached Aaron Sigel, Apple’s manager of security for its iOS operating system. Uber poached Chris Gates, formerly a white hat hacker at Facebook. Didi poached Mr. Miller from Uber, where he had gone to work after the Jeep hack. And security firms have seen dozens of engineers leave their ranks for autonomous-car projects. - -Mr. Miller said he left Uber for Didi, in part, because his new Chinese employer has given him more freedom to discuss his work. - -“Carmakers seem to be taking the threat of cyberattack more seriously, but I’d still like to see more transparency from them,” Mr. Miller wrote on Twitter on Saturday. - -Like a number of big tech companies, Tesla and Fiat Chrysler started paying out rewards to hackers who turn over flaws the hackers discover in their systems. GM has done something similar, though critics say GM’s program is limited when compared with the ones offered by tech companies, and so far no rewards have been paid out. - -One year after the Jeep hack by Mr. Miller and Mr. Valasek, they demonstrated all the other ways they could mess with a Jeep driver, including hijacking the vehicle’s cruise control, swerving the steering wheel 180 degrees or slamming on the parking brake in high-speed traffic — all from a computer in the back of the car. (Those exploits ended with their test Jeep in a ditch and calls to a local tow company.) - -Granted, they had to be in the Jeep to make all that happen. But it was evidence of what is possible. - -The Jeep penetration was preceded by a [2011 hack by security researchers at the University of Washington][12] and the University of California, San Diego, who were the first to remotely hack a sedan and ultimately control its brakes via Bluetooth. The researchers warned car companies that the more connected cars become, the more likely they are to get hacked. - -Security researchers have also had their way with Tesla’s software-heavy Model S car. In 2015, Mr. Rogers, together with Kevin Mahaffey, the chief technology officer of the cybersecurity company Lookout, found a way to control various Tesla functions from their physically connected laptop. - -One year later, a team of Chinese researchers at Tencent took their research a step further, hacking a moving Tesla Model S and controlling its brakes from 12 miles away. Unlike Chrysler, Tesla was able to dispatch a remote patch to fix the security holes that made the hacks possible. - -In all the cases, the car hacks were the work of well meaning, white hat security researchers. But the lesson for all automakers was clear. - -The motivations to hack vehicles are limitless. When it learned of Mr. Rogers’s and Mr. Mahaffey’s investigation into Tesla’s Model S, a Chinese app-maker asked Mr. Rogers if he would be interested in sharing, or possibly selling, his discovery, he said. (The app maker was looking for a backdoor to secretly install its app on Tesla’s dashboard.) - -Criminals have not yet shown they have found back doors into connected vehicles, though for years, they have been actively developing, trading and deploying tools that can intercept car key communications. - -But as more driverless and semiautonomous cars hit the open roads, they will become a more worthy target. Security experts warn that driverless cars present a far more complex, intriguing and vulnerable “attack surface” for hackers. Each new “connected” car feature introduces greater complexity, and with complexity inevitably comes vulnerability. - -Twenty years ago, cars had, on average, one million lines of code. The General Motors 2010 [Chevrolet Volt][13] had about 10 million lines of code — more than an [F-35 fighter jet][14]. - -Today, an average car has more than 100 million lines of code. Automakers predict it won’t be long before they have 200 million. When you stop to consider that, on average, there are 15 to 50 defects per 1,000 lines of software code, the potentially exploitable weaknesses add up quickly. - -The only difference between computer code and driverless car code is that, “Unlike data center enterprise security — where the biggest threat is loss of data — in automotive security, it’s loss of life,” said David Barzilai, a co-founder of Karamba Security, an Israeli start-up that is working on addressing automotive security. - -To truly secure autonomous vehicles, security experts say, automakers will have to address the inevitable vulnerabilities that pop up in new sensors and car computers, address inherent vulnerabilities in the base car itself and, perhaps most challenging of all, bridge the cultural divide between automakers and software companies. - -“The genie is out of the bottle, and to solve this problem will require a major cultural shift,” said Mr. Mahaffey of the cybersecurity company Lookout. “And an automaker that truly values cybersecurity will treat security vulnerabilities the same they would an airbag recall. We have not seen that industrywide shift yet.” - -There will be winners and losers, Mr. Mahaffey added: “Automakers that transform themselves into software companies will win. Others will get left behind.” - --------------------------------------------------------------------------------- - -via: https://www.nytimes.com/2017/06/07/technology/why-car-companies-are-hiring-computer-security-experts.html - -作者:[NICOLE PERLROTH ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.nytimes.com/by/nicole-perlroth -[1]:https://www.nytimes.com/2016/06/09/technology/software-as-weaponry-in-a-computer-connected-world.html -[2]:https://www.nytimes.com/2015/08/29/technology/uber-hires-two-engineers-who-showed-cars-could-be-hacked.html -[3]:https://www.nytimes.com/2015/08/11/opinion/zeynep-tufekci-why-smart-objects-may-be-a-dumb-idea.html -[4]:https://www.nytimes.com/by/nicole-perlroth -[5]:https://www.nytimes.com/column/bits -[6]:https://www.nytimes.com/2017/06/07/technology/why-car-companies-are-hiring-computer-security-experts.html?utm_source=wanqu.co&utm_campaign=Wanqu+Daily&utm_medium=website#story-continues-1 -[7]:http://www.nytimes.com/newsletters/sample/bits?pgtype=subscriptionspage&version=business&contentId=TU&eventName=sample&module=newsletter-sign-up -[8]:https://www.nytimes.com/privacy -[9]:https://www.nytimes.com/help/index.html -[10]:https://bits.blogs.nytimes.com/2015/07/21/security-researchers-find-a-way-to-hack-cars/ -[11]:http://www.nytimes.com/topic/company/tesla-motors-inc?inline=nyt-org -[12]:http://www.autosec.org/pubs/cars-usenixsec2011.pdf -[13]:http://autos.nytimes.com/2011/Chevrolet/Volt/238/4117/329463/researchOverview.aspx?inline=nyt-classifier -[14]:http://topics.nytimes.com/top/reference/timestopics/subjects/m/military_aircraft/f35_airplane/index.html?inline=nyt-classifier -[15]:https://www.nytimes.com/2017/06/07/technology/why-car-companies-are-hiring-computer-security-experts.html?utm_source=wanqu.co&utm_campaign=Wanqu+Daily&utm_medium=website#story-continues-3 diff --git a/sources/tech/20170622 A users guide to links in the Linux filesystem.md b/sources/tech/20170622 A users guide to links in the Linux filesystem.md new file mode 100644 index 0000000000..3cb59aaacb --- /dev/null +++ b/sources/tech/20170622 A users guide to links in the Linux filesystem.md @@ -0,0 +1,314 @@ +Translating by yongshouzhang + + +A user's guide to links in the Linux filesystem +============================================================ + +### Learn how to use links, which make tasks easier by providing access to files from multiple locations in the Linux filesystem directory tree. + + +![A user's guide to links in the Linux filesystem](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/links.png?itok=AumNmse7 "A user's guide to links in the Linux filesystem") +Image by : [Paul Lewin][8]. Modified by Opensource.com. [CC BY-SA 2.0][9] + +In articles I have written about various aspects of Linux filesystems for Opensource.com, including [An introduction to Linux's EXT4 filesystem][10]; [Managing devices in Linux][11]; [An introduction to Linux filesystems][12]; and [A Linux user's guide to Logical Volume Management][13], I have briefly mentioned an interesting feature of Linux filesystems that can make some tasks easier by providing access to files from multiple locations in the filesystem directory tree. + +There are two types of Linux filesystem links: hard and soft. The difference between the two types of links is significant, but both types are used to solve similar problems. They both provide multiple directory entries (or references) to a single file, but they do it quite differently. Links are powerful and add flexibility to Linux filesystems because [everything is a file][14]. + +More Linux resources + +* [What is Linux?][1] + +* [What are Linux containers?][2] + +* [Download Now: Linux commands cheat sheet][3] + +* [Advanced Linux commands cheat sheet][4] + +* [Our latest Linux articles][5] + +I have found, for instance, that some programs required a particular version of a library. When a library upgrade replaced the old version, the program would crash with an error specifying the name of the old, now-missing library. Usually, the only change in the library name was the version number. Acting on a hunch, I simply added a link to the new library but named the link after the old library name. I tried the program again and it worked perfectly. And, okay, the program was a game, and everyone knows the lengths that gamers will go to in order to keep their games running. + +In fact, almost all applications are linked to libraries using a generic name with only a major version number in the link name, while the link points to the actual library file that also has a minor version number. In other instances, required files have been moved from one directory to another to comply with the Linux file specification, and there are links in the old directories for backwards compatibility with those programs that have not yet caught up with the new locations. If you do a long listing of the **/lib64** directory, you can find many examples of both. + +``` +lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.hwm -> ../../usr/share/cracklib/pw_dict.hwm +lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.pwd -> ../../usr/share/cracklib/pw_dict.pwd +lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.pwi -> ../../usr/share/cracklib/pw_dict.pwi +lrwxrwxrwx. 1 root root 27 Jun 9 2016 libaccountsservice.so.0 -> libaccountsservice.so.0.0.0 +-rwxr-xr-x. 1 root root 288456 Jun 9 2016 libaccountsservice.so.0.0.0 +lrwxrwxrwx 1 root root 15 May 17 11:47 libacl.so.1 -> libacl.so.1.1.0 +-rwxr-xr-x 1 root root 36472 May 17 11:47 libacl.so.1.1.0 +lrwxrwxrwx. 1 root root 15 Feb 4 2016 libaio.so.1 -> libaio.so.1.0.1 +-rwxr-xr-x. 1 root root 6224 Feb 4 2016 libaio.so.1.0.0 +-rwxr-xr-x. 1 root root 6224 Feb 4 2016 libaio.so.1.0.1 +lrwxrwxrwx. 1 root root 30 Jan 16 16:39 libakonadi-calendar.so.4 -> libakonadi-calendar.so.4.14.26 +-rwxr-xr-x. 1 root root 816160 Jan 16 16:39 libakonadi-calendar.so.4.14.26 +lrwxrwxrwx. 1 root root 29 Jan 16 16:39 libakonadi-contact.so.4 -> libakonadi-contact.so.4.14.26 +``` + +A few of the links in the **/lib64** directory + +The long listing of the **/lib64** directory above shows that the first character in the filemode is the letter "l," which means that each is a soft or symbolic link. + +### Hard links + +In [An introduction to Linux's EXT4 filesystem][15], I discussed the fact that each file has one inode that contains information about that file, including the location of the data belonging to that file. [Figure 2][16] in that article shows a single directory entry that points to the inode. Every file must have at least one directory entry that points to the inode that describes the file. The directory entry is a hard link, thus every file has at least one hard link. + +In Figure 1 below, multiple directory entries point to a single inode. These are all hard links. I have abbreviated the locations of three of the directory entries using the tilde (**~**) convention for the home directory, so that **~** is equivalent to **/home/user** in this example. Note that the fourth directory entry is in a completely different directory, **/home/shared**, which might be a location for sharing files between users of the computer. + +![fig1directory_entries.png](https://opensource.com/sites/default/files/images/life/fig1directory_entries.png) +Figure 1 + +Hard links are limited to files contained within a single filesystem. "Filesystem" is used here in the sense of a partition or logical volume (LV) that is mounted on a specified mount point, in this case **/home**. This is because inode numbers are unique only within each filesystem, and a different filesystem, for example, **/var**or **/opt**, will have inodes with the same number as the inode for our file. + +Because all the hard links point to the single inode that contains the metadata about the file, all of these attributes are part of the file, such as ownerships, permissions, and the total number of hard links to the inode, and cannot be different for each hard link. It is one file with one set of attributes. The only attribute that can be different is the file name, which is not contained in the inode. Hard links to a single **file/inode** located in the same directory must have different names, due to the fact that there can be no duplicate file names within a single directory. + +The number of hard links for a file is displayed with the **ls -l** command. If you want to display the actual inode numbers, the command **ls -li** does that. + +### Symbolic (soft) links + +The difference between a hard link and a soft link, also known as a symbolic link (or symlink), is that, while hard links point directly to the inode belonging to the file, soft links point to a directory entry, i.e., one of the hard links. Because soft links point to a hard link for the file and not the inode, they are not dependent upon the inode number and can work across filesystems, spanning partitions and LVs. + +The downside to this is: If the hard link to which the symlink points is deleted or renamed, the symlink is broken. The symlink is still there, but it points to a hard link that no longer exists. Fortunately, the **ls** command highlights broken links with flashing white text on a red background in a long listing. + +### Lab project: experimenting with links + +I think the easiest way to understand the use of and differences between hard and soft links is with a lab project that you can do. This project should be done in an empty directory as a  _non-root user_ . I created the **~/temp** directory for this project, and you should, too. It creates a safe place to do the project and provides a new, empty directory to work in so that only files associated with this project will be located there. + +### **Initial setup** + +First, create the temporary directory in which you will perform the tasks needed for this project. Ensure that the present working directory (PWD) is your home directory, then enter the following command. + +``` +mkdir temp +``` + +Change into **~/temp** to make it the PWD with this command. + +``` +cd temp +``` + +To get started, we need to create a file we can link to. The following command does that and provides some content as well. + +``` +du -h > main.file.txt +``` + +Use the **ls -l** long list to verify that the file was created correctly. It should look similar to my results. Note that the file size is only 7 bytes, but yours may vary by a byte or two. + +``` +[dboth@david temp]$ ls -l +total 4 +-rw-rw-r-- 1 dboth dboth 7 Jun 13 07:34 main.file.txt +``` + +Notice the number "1" following the file mode in the listing. That number represents the number of hard links that exist for the file. For now, it should be 1 because we have not created any additional links to our test file. + +### **Experimenting with hard links** + +Hard links create a new directory entry pointing to the same inode, so when hard links are added to a file, you will see the number of links increase. Ensure that the PWD is still **~/temp**. Create a hard link to the file **main.file.txt**, then do another long list of the directory. + +``` +[dboth@david temp]$ ln main.file.txt link1.file.txt +[dboth@david temp]$ ls -l +total 8 +-rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 link1.file.txt +-rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 main.file.txt +``` + +Notice that both files have two links and are exactly the same size. The date stamp is also the same. This is really one file with one inode and two links, i.e., directory entries to it. Create a second hard link to this file and list the directory contents. You can create the link to either of the existing ones: **link1.file.txt** or **main.file.txt**. + +``` +[dboth@david temp]$ ln link1.file.txt link2.file.txt ; ls -l +total 16 +-rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link1.file.txt +-rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link2.file.txt +-rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 main.file.txt +``` + +Notice that each new hard link in this directory must have a different name because two files—really directory entries—cannot have the same name within the same directory. Try to create another link with a target name the same as one of the existing ones. + +``` +[dboth@david temp]$ ln main.file.txt link2.file.txt +ln: failed to create hard link 'link2.file.txt': File exists +``` + +Clearly that does not work, because **link2.file.txt** already exists. So far, we have created only hard links in the same directory. So, create a link in your home directory, the parent of the temp directory in which we have been working so far. + +``` +[dboth@david temp]$ ln main.file.txt ../main.file.txt ; ls -l ../main* +-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt +``` + +The **ls** command in the above listing shows that the **main.file.txt** file does exist in the home directory with the same name as the file in the temp directory. Of course, these are not different files; they are the same file with multiple links—directory entries—to the same inode. To help illustrate the next point, add a file that is not a link. + +``` +[dboth@david temp]$ touch unlinked.file ; ls -l +total 12 +-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt +-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt +-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt +-rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +Look at the inode number of the hard links and that of the new file using the **-i**option to the **ls** command. + +``` +[dboth@david temp]$ ls -li +total 12 +657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt +657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt +657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +Notice the number **657024** to the left of the file mode in the example above. That is the inode number, and all three file links point to the same inode. You can use the **-i** option to view the inode number for the link we created in the home directory as well, and that will also show the same value. The inode number of the file that has only one link is different from the others. Note that the inode numbers will be different on your system. + +Let's change the size of one of the hard-linked files. + +``` +[dboth@david temp]$ df -h > link2.file.txt ; ls -li +total 12 +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +The file size of all the hard-linked files is now larger than before. That is because there is really only one file that is linked to by multiple directory entries. + +I know this next experiment will work on my computer because my **/tmp**directory is on a separate LV. If you have a separate LV or a filesystem on a different partition (if you're not using LVs), determine whether or not you have access to that LV or partition. If you don't, you can try to insert a USB memory stick and mount it. If one of those options works for you, you can do this experiment. + +Try to create a link to one of the files in your **~/temp** directory in **/tmp** (or wherever your different filesystem directory is located). + +``` +[dboth@david temp]$ ln link2.file.txt /tmp/link3.file.txt +ln: failed to create hard link '/tmp/link3.file.txt' => 'link2.file.txt': +Invalid cross-device link +``` + +Why does this error occur? The reason is each separate mountable filesystem has its own set of inode numbers. Simply referring to a file by an inode number across the entire Linux directory structure can result in confusion because the same inode number can exist in each mounted filesystem. + +There may be a time when you will want to locate all the hard links that belong to a single inode. You can find the inode number using the **ls -li** command. Then you can use the **find** command to locate all links with that inode number. + +``` +[dboth@david temp]$ find . -inum 657024 +./main.file.txt +./link1.file.txt +./link2.file.txt +``` + +Note that the **find** command did not find all four of the hard links to this inode because we started at the current directory of **~/temp**. The **find** command only finds files in the PWD and its subdirectories. To find all the links, we can use the following command, which specifies your home directory as the starting place for the search. + +``` +[dboth@david temp]$ find ~ -samefile main.file.txt +/home/dboth/temp/main.file.txt +/home/dboth/temp/link1.file.txt +/home/dboth/temp/link2.file.txt +/home/dboth/main.file.txt +``` + +You may see error messages if you do not have permissions as a non-root user. This command also uses the **-samefile** option instead of specifying the inode number. This works the same as using the inode number and can be easier if you know the name of one of the hard links. + +### **Experimenting with soft links** + +As you have just seen, creating hard links is not possible across filesystem boundaries; that is, from a filesystem on one LV or partition to a filesystem on another. Soft links are a means to answer that problem with hard links. Although they can accomplish the same end, they are very different, and knowing these differences is important. + +Let's start by creating a symlink in our **~/temp** directory to start our exploration. + +``` +[dboth@david temp]$ ln -s link2.file.txt link3.file.txt ; ls -li +total 12 +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt +658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> +link2.file.txt +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +The hard links, those that have the inode number **657024**, are unchanged, and the number of hard links shown for each has not changed. The newly created symlink has a different inode, number **658270**. The soft link named **link3.file.txt**points to **link2.file.txt**. Use the **cat** command to display the contents of **link3.file.txt**. The file mode information for the symlink starts with the letter "**l**" which indicates that this file is actually a symbolic link. + +The size of the symlink **link3.file.txt** is only 14 bytes in the example above. That is the size of the text **link3.file.txt -> link2.file.txt**, which is the actual content of the directory entry. The directory entry **link3.file.txt** does not point to an inode; it points to another directory entry, which makes it useful for creating links that span file system boundaries. So, let's create that link we tried before from the **/tmp** directory. + +``` +[dboth@david temp]$ ln -s /home/dboth/temp/link2.file.txt +/tmp/link3.file.txt ; ls -l /tmp/link* +lrwxrwxrwx 1 dboth dboth 31 Jun 14 21:53 /tmp/link3.file.txt -> +/home/dboth/temp/link2.file.txt +``` + +### **Deleting links** + +There are some other things that you should consider when you need to delete links or the files to which they point. + +First, let's delete the link **main.file.txt**. Remember that every directory entry that points to an inode is simply a hard link. + +``` +[dboth@david temp]$ rm main.file.txt ; ls -li +total 8 +657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link1.file.txt +657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link2.file.txt +658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> +link2.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +The link **main.file.txt** was the first link created when the file was created. Deleting it now still leaves the original file and its data on the hard drive along with all the remaining hard links. To delete the file and its data, you would have to delete all the remaining hard links. + +Now delete the **link2.file.txt** hard link. + +``` +[dboth@david temp]$ rm link2.file.txt ; ls -li +total 8 +657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link1.file.txt +658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> +link2.file.txt +657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 main.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +Notice what happens to the soft link. Deleting the hard link to which the soft link points leaves a broken link. On my system, the broken link is highlighted in colors and the target hard link is flashing. If the broken link needs to be fixed, you can create another hard link in the same directory with the same name as the old one, so long as not all the hard links have been deleted. You could also recreate the link itself, with the link maintaining the same name but pointing to one of the remaining hard links. Of course, if the soft link is no longer needed, it can be deleted with the **rm** command. + +The **unlink** command can also be used to delete files and links. It is very simple and has no options, as the **rm** command does. It does, however, more accurately reflect the underlying process of deletion, in that it removes the link—the directory entry—to the file being deleted. + +### Final thoughts + +I worked with both types of links for a long time before I began to understand their capabilities and idiosyncrasies. It took writing a lab project for a Linux class I taught to fully appreciate how links work. This article is a simplification of what I taught in that class, and I hope it speeds your learning curve. + +-------------------------------------------------------------------------------- + +作者简介: + +David Both - David Both is a Linux and Open Source advocate who resides in Raleigh, North Carolina. He has been in the IT industry for over forty years and taught OS/2 for IBM where he worked for over 20 years. While at IBM, he wrote the first training course for the original IBM PC in 1981. He has taught RHCE classes for Red Hat and has worked at MCI Worldcom, Cisco, and the State of North Carolina. He has been working with Linux and Open Source Software for almost 20 years. + +--------------------------------- + +via: https://opensource.com/article/17/6/linking-linux-filesystem + +作者:[David Both ][a] +译者:[runningwater](https://github.com/runningwater) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/dboth +[1]:https://opensource.com/resources/what-is-linux?src=linux_resource_menu +[2]:https://opensource.com/resources/what-are-linux-containers?src=linux_resource_menu +[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=7016000000127cYAAQ +[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?src=linux_resource_menu&intcmp=7016000000127cYAAQ +[5]:https://opensource.com/tags/linux?src=linux_resource_menu +[6]:https://opensource.com/article/17/6/linking-linux-filesystem?rate=YebHxA-zgNopDQKKOyX3_r25hGvnZms_33sYBUq-SMM +[7]:https://opensource.com/user/14106/feed +[8]:https://www.flickr.com/photos/digypho/7905320090 +[9]:https://creativecommons.org/licenses/by/2.0/ +[10]:https://opensource.com/article/17/5/introduction-ext4-filesystem +[11]:https://opensource.com/article/16/11/managing-devices-linux +[12]:https://opensource.com/life/16/10/introduction-linux-filesystems +[13]:https://opensource.com/business/16/9/linux-users-guide-lvm +[14]:https://opensource.com/life/15/9/everything-is-a-file +[15]:https://opensource.com/article/17/5/introduction-ext4-filesystem +[16]:https://opensource.com/article/17/5/introduction-ext4-filesystem#fig2 +[17]:https://opensource.com/users/dboth +[18]:https://opensource.com/article/17/6/linking-linux-filesystem#comments diff --git a/sources/tech/20170921 How to answer questions in a helpful way.md b/sources/tech/20170921 How to answer questions in a helpful way.md deleted file mode 100644 index 8a3601ed06..0000000000 --- a/sources/tech/20170921 How to answer questions in a helpful way.md +++ /dev/null @@ -1,172 +0,0 @@ -How to answer questions in a helpful way -============================================================ - -Your coworker asks you a slightly unclear question. How do you answer? I think asking questions is a skill (see [How to ask good questions][1]) and that answering questions in a helpful way is also a skill! Both of them are super useful. - -To start out with – sometimes the people asking you questions don’t respect your time, and that sucks. I’m assuming here throughout that that’s not what happening – we’re going to assume that the person asking you questions is a reasonable person who is trying their best to figure something out and that you want to help them out. Everyone I work with is like that and so that’s the world I live in :) - -Here are a few strategies for answering questions in a helpful way! - -### If they’re not asking clearly, help them clarify - -Often beginners don’t ask clear questions, or ask questions that don’t have the necessary information to answer the questions. Here are some strategies you can use to help them clarify. - -* **Rephrase a more specific question** back at them (“Are you asking X?”) - -* **Ask them for more specific information** they didn’t provide (“are you using IPv6?”) - -* **Ask what prompted their question**. For example, sometimes people come into my team’s channel with questions about how our service discovery works. Usually this is because they’re trying to set up/reconfigure a service. In that case it’s helpful to ask “which service are you working with? Can I see the pull request you’re working on?” - -A lot of these strategies come from the [how to ask good questions][2] post. (though I would never say to someone “oh you need to read this Document On How To Ask Good Questions before asking me a question”) - -### Figure out what they know already - -Before answering a question, it’s very useful to know what the person knows already! - -Harold Treen gave me a great example of this: - -> Someone asked me the other day to explain “Redux Sagas”. Rather than dive in and say “They are like worker threads that listen for actions and let you update the store!”  -> I started figuring out how much they knew about Redux, actions, the store and all these other fundamental concepts. From there it was easier to explain the concept that ties those other concepts together. - -Figuring out what your question-asker knows already is important because they may be confused about fundamental concepts (“What’s Redux?”), or they may be an expert who’s getting at a subtle corner case. An answer building on concepts they don’t know is confusing, and an answer that recaps things they know is tedious. - -One useful trick for asking what people know – instead of “Do you know X?”, maybe try “How familiar are you with X?”. - -### Point them to the documentation - -“RTFM” is the classic unhelpful answer to a question, but pointing someone to a specific piece of documentation can actually be really helpful! When I’m asking a question, I’d honestly rather be pointed to documentation that actually answers my question, because it’s likely to answer other questions I have too. - -I think it’s important here to make sure you’re linking to documentation that actually answers the question, or at least check in afterwards to make sure it helped. Otherwise you can end up with this (pretty common) situation: - -* Ali: How do I do X? - -* Jada: - -* Ali: That doesn’t actually explain how to X, it only explains Y! - -If the documentation I’m linking to is very long, I like to point out the specific part of the documentation I’m talking about. The [bash man page][3] is 44,000 words (really!), so just saying “it’s in the bash man page” is not that helpful :) - -### Point them to a useful search - -Often I find things at work by searching for some Specific Keyword that I know will find me the answer. That keyword might not be obvious to a beginner! So saying “this is the search I’d use to find the answer to that question” can be useful. Again, check in afterwards to make sure the search actually gets them the answer they need :) - -### Write new documentation - -People often come and ask my team the same questions over and over again. This is obviously not the fault of the people (how should  _they_  know that 10 people have asked this already, or what the answer is?). So we’re trying to, instead of answering the questions directly, - -1. Immediately write documentation - -2. Point the person to the new documentation we just wrote - -3. Celebrate! - -Writing documentation sometimes takes more time than just answering the question, but it’s often worth it! Writing documentation is especially worth it if: - -a. It’s a question which is being asked again and again b. The answer doesn’t change too much over time (if the answer changes every week or month, the documentation will just get out of date and be frustrating) - -### Explain what you did - -As a beginner to a subject, it’s really frustrating to have an exchange like this: - -* New person: “hey how do you do X?” - -* More Experienced Person: “I did it, it is done.” - -* New person: ….. but what did you DO?! - -If the person asking you is trying to learn how things work, it’s helpful to: - -* Walk them through how to accomplish a task instead of doing it yourself - -* Tell them the steps for how you got the answer you gave them! - -This might take longer than doing it yourself, but it’s a learning opportunity for the person who asked, so that they’ll be better equipped to solve such problems in the future. - -Then you can have WAY better exchanges, like this: - -* New person: “I’m seeing errors on the site, what’s happening?” - -* More Experienced Person: (2 minutes later) “oh that’s because there’s a database failover happening” - -* New person: how did you know that??!?!? - -* More Experienced Person: “Here’s what I did!”: - 1. Often these errors are due to Service Y being down. I looked at $PLACE and it said Service Y was up. So that wasn’t it. - - 2. Then I looked at dashboard X, and this part of that dashboard showed there was a database failover happening. - - 3. Then I looked in the logs for the service and it showed errors connecting to the database, here’s what those errors look like. - -If you’re explaining how you debugged a problem, it’s useful both to explain how you found out what the problem was, and how you found out what the problem wasn’t. While it might feel good to look like you knew the answer right off the top of your head, it feels even better to help someone improve at learning and diagnosis, and understand the resources available. - -### Solve the underlying problem - -This one is a bit tricky. Sometimes people think they’ve got the right path to a solution, and they just need one more piece of information to implement that solution. But they might not be quite on the right path! For example: - -* George: I’m doing X, and I got this error, how do I fix it - -* Jasminda: Are you actually trying to do Y? If so, you shouldn’t do X, you should do Z instead - -* George: Oh, you’re right!!! Thank you! I will do Z instead. - -Jasminda didn’t answer George’s question at all! Instead she guessed that George didn’t actually want to be doing X, and she was right. That is helpful! - -It’s possible to come off as condescending here though, like - -* George: I’m doing X, and I got this error, how do I fix it? - -* Jasminda: Don’t do that, you’re trying to do Y and you should do Z to accomplish that instead. - -* George: Well, I am not trying to do Y, I actually want to do X because REASONS. How do I do X? - -So don’t be condescending, and keep in mind that some questioners might be attached to the steps they’ve taken so far! It might be appropriate to answer both the question they asked and the one they should have asked: “Well, if you want to do X then you might try this, but if you’re trying to solve problem Y with that, you might have better luck doing this other thing, and here’s why that’ll work better”. - -### Ask “Did that answer your question?” - -I always like to check in after I  _think_  I’ve answered the question and ask “did that answer your question? Do you have more questions?”. - -It’s good to pause and wait after asking this because often people need a minute or two to know whether or not they’ve figured out the answer. I especially find this extra “did this answer your questions?” step helpful after writing documentation! Often when writing documentation about something I know well I’ll leave out something very important without realizing it. - -### Offer to pair program/chat in real life - -I work remote, so many of my conversations at work are text-based. I think of that as the default mode of communication. - -Today, we live in a world of easy video conferencing & screensharing! At work I can at any time click a button and immediately be in a video call/screensharing session with someone. Some problems are easier to talk about using your voices! - -For example, recently someone was asking about capacity planning/autoscaling for their service. I could tell there were a few things we needed to clear up but I wasn’t exactly sure what they were yet. We got on a quick video call and 5 minutes later we’d answered all their questions. - -I think especially if someone is really stuck on how to get started on a task, pair programming for a few minutes can really help, and it can be a lot more efficient than email/instant messaging. - -### Don’t act surprised - -This one’s a rule from the Recurse Center: [no feigning surprise][4]. Here’s a relatively common scenario - -* Human 1: “what’s the Linux kernel?” - -* Human 2: “you don’t know what the LINUX KERNEL is?!!!!?!!!???” - -Human 2’s reaction (regardless of whether they’re  _actually_  surprised or not) is not very helpful. It mostly just serves to make Human 1 feel bad that they don’t know what the Linux kernel is. - -I’ve worked on actually pretending not to be surprised even when I actually am a bit surprised the person doesn’t know the thing and it’s awesome. - -### Answering questions well is awesome - -Obviously not all these strategies are appropriate all the time, but hopefully you will find some of them helpful! I find taking the time to answer questions and teach people can be really rewarding. - -Special thanks to Josh Triplett for suggesting this post and making many helpful additions, and to Harold Treen, Vaibhav Sagar, Peter Bhat Harkins, Wesley Aptekar-Cassels, and Paul Gowder for reading/commenting. - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/answer-questions-well/ - -作者:[ Julia Evans][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://jvns.ca/about -[1]:https://jvns.ca/blog/good-questions/ -[2]:https://jvns.ca/blog/good-questions/ -[3]:https://linux.die.net/man/1/bash -[4]:https://jvns.ca/blog/2017/04/27/no-feigning-surprise/ diff --git a/sources/tech/20171005 How to manage Linux containers with Ansible Container.md b/sources/tech/20171005 How to manage Linux containers with Ansible Container.md deleted file mode 100644 index 897b793a86..0000000000 --- a/sources/tech/20171005 How to manage Linux containers with Ansible Container.md +++ /dev/null @@ -1,114 +0,0 @@ -How to manage Linux containers with Ansible Container -============================================================ - -### Ansible Container addresses Dockerfile shortcomings and offers complete management for containerized projects. - -![Ansible Container: A new way to manage containers](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/container-ship.png?itok=pqZYgQ7K "Ansible Container: A new way to manage containers") -Image by : opensource.com - -I love containers and use the technology every day. Even so, containers aren't perfect. Over the past couple of months, however, a set of projects has emerged that addresses some of the problems I've experienced. - -I started using containers with [Docker][11], since this project made the technology so popular. Aside from using the container engine, I learned how to use **[docker-compose][6]** and started managing my projects with it. My productivity skyrocketed! One command to run my project, no matter how complex it was. I was so happy. - -After some time, I started noticing issues. The most apparent were related to the process of creating container images. The Docker tool uses a custom file format as a recipe to produce container images—Dockerfiles. This format is easy to learn, and after a short time you are ready to produce container images on your own. The problems arise once you want to master best practices or have complex scenarios in mind. - -More on Ansible - -* [How Ansible works][1] - -* [Free Ansible eBooks][2] - -* [Ansible quick start video][3] - -* [Download and install Ansible][4] - -Let's take a break and travel to a different land: the world of [Ansible][22]. You know it? It's awesome, right? You don't? Well, it's time to learn something new. Ansible is a project that allows you to manage your infrastructure by writing tasks and executing them inside environments of your choice. No need to install and set up any services; everything can easily run from your laptop. Many people already embrace Ansible. - -Imagine this scenario: You invested in Ansible, you wrote plenty of Ansible roles and playbooks that you use to manage your infrastructure, and you are thinking about investing in containers. What should you do? Start writing container image definitions via shell scripts and Dockerfiles? That doesn't sound right. - -Some people from the Ansible development team asked this question and realized that those same Ansible roles and playbooks that people wrote and use daily can also be used to produce container images. But not just that—they can be used to manage the complete lifecycle of containerized projects. From these ideas, the [Ansible Container][12] project was born. It utilizes existing Ansible roles that can be turned into container images and can even be used for the complete application lifecycle, from build to deploy in production. - -Let's talk about the problems I mentioned regarding best practices in context of Dockerfiles. A word of warning: This is going to be very specific and technical. Here are the top three issues I have: - -### 1\. Shell scripts embedded in Dockerfiles. - -When writing Dockerfiles, you can specify a script that will be interpreted via **/bin/sh -c**. It can be something like: - -``` -RUN dnf install -y nginx -``` - -where RUN is a Dockerfile instruction and the rest are its arguments (which are passed to shell). But imagine a more complex scenario: - -``` -RUN set -eux; \ -    \ -# this "case" statement is generated via "update.sh" -    %%ARCH-CASE%%; \ -    \ -    url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \ -    wget -O go.tgz "$url"; \ -    echo "${goRelSha256} *go.tgz" | sha256sum -c -; \ -``` - -This one is taken from [the official golang image][13]. It doesn't look pretty, right? - -### 2\. You can't parse Dockerfiles easily. - -Dockerfiles are a new format without a formal specification. This is tricky if you need to process Dockerfiles in your infrastructure (e.g., automate the build process a bit). The only specification is [the code][14] that is part of **dockerd**. The problem is that you can't use it as a library. The easiest solution is to write a parser on your own and hope for the best. Wouldn't it be better to use some well-known markup language, such as YAML or JSON? - -### 3\. It's hard to control. - -If you are familiar with the internals of container images, you may know that every image is composed of layers. Once the container is created, the layers are stacked onto each other (like pancakes) using union filesystem technology. The problem is, that you cannot explicitly control this layering—you can't say, "here starts a new layer." You are forced to change your Dockerfile in a way that may hurt readability. The bigger problem is that a set of best practices has to be followed to achieve optimal results—newcomers have a really hard time here. - -### Comparing Ansible language and Dockerfiles - -The biggest shortcoming of Dockerfiles in comparison to Ansible is that Ansible, as a language, is much more powerful. For example, Dockerfiles have no direct concept of variables, whereas Ansible has a complete templating system (variables are just one of its features). Ansible contains a large number of modules that can be easily utilized, such as [**wait_for**][15], which can be used for service readiness checks—e.g., wait until a service is ready before proceeding. With Dockerfiles, everything is a shell script. So if you need to figure out service readiness, it has to be done with shell (or installed separately). The other problem with shell scripts is that, with growing complexity, maintenance becomes a burden. Plenty of people have already figured this out and turned those shell scripts into Ansible. - -If you are interested in this topic and would like to know more, please come to [Open Source Summit][16] in Prague to see [my presentation][17] on Monday, Oct. 23, at 4:20 p.m. in Palmovka room. - - _Learn more in Tomas Tomecek's talk, [From Dockerfiles to Ansible Container][7], at [Open Source Summit EU][8], which will be held October 23-26 in Prague._ - - - -### About the author - - [![human](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/ja.jpeg?itok=4ATUEAbd)][18] Tomas Tomecek - Engineer. Hacker. Speaker. Tinker. Red Hatter. Likes containers, linux, open source, python 3, rust, zsh, tmux.[More about me][9] - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/10/dockerfiles-ansible-container - -作者:[Tomas Tomecek ][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/tomastomecek -[1]:https://www.ansible.com/how-ansible-works?intcmp=701f2000000h4RcAAI -[2]:https://www.ansible.com/ebooks?intcmp=701f2000000h4RcAAI -[3]:https://www.ansible.com/quick-start-video?intcmp=701f2000000h4RcAAI -[4]:https://docs.ansible.com/ansible/latest/intro_installation.html?intcmp=701f2000000h4RcAAI -[5]:https://opensource.com/article/17/10/dockerfiles-ansible-container?imm_mid=0f9013&cmp=em-webops-na-na-newsltr_20171201&rate=Wiw_0D6PK_CAjqatYu_YQH0t1sNHEF6q09_9u3sYkCY -[6]:https://github.com/docker/compose -[7]:http://sched.co/BxIW -[8]:http://events.linuxfoundation.org/events/open-source-summit-europe -[9]:https://opensource.com/users/tomastomecek -[10]:https://opensource.com/user/175651/feed -[11]:https://opensource.com/tags/docker -[12]:https://www.ansible.com/ansible-container -[13]:https://github.com/docker-library/golang/blob/master/Dockerfile-debian.template#L14 -[14]:https://github.com/moby/moby/tree/master/builder/dockerfile -[15]:http://docs.ansible.com/wait_for_module.html -[16]:http://events.linuxfoundation.org/events/open-source-summit-europe -[17]:http://events.linuxfoundation.org/events/open-source-summit-europe/program/schedule -[18]:https://opensource.com/users/tomastomecek -[19]:https://opensource.com/users/tomastomecek -[20]:https://opensource.com/users/tomastomecek -[21]:https://opensource.com/article/17/10/dockerfiles-ansible-container?imm_mid=0f9013&cmp=em-webops-na-na-newsltr_20171201#comments -[22]:https://opensource.com/tags/ansible -[23]:https://opensource.com/tags/containers -[24]:https://opensource.com/tags/ansible -[25]:https://opensource.com/tags/docker -[26]:https://opensource.com/tags/open-source-summit diff --git a/sources/tech/20171005 Reasons Kubernetes is cool.md b/sources/tech/20171005 Reasons Kubernetes is cool.md deleted file mode 100644 index a9d10b9cdb..0000000000 --- a/sources/tech/20171005 Reasons Kubernetes is cool.md +++ /dev/null @@ -1,148 +0,0 @@ -Reasons Kubernetes is cool -============================================================ - -When I first learned about Kubernetes (a year and a half ago?) I really didn’t understand why I should care about it. - -I’ve been working full time with Kubernetes for 3 months or so and now have some thoughts about why I think it’s useful. (I’m still very far from being a Kubernetes expert!) Hopefully this will help a little in your journey to understand what even is going on with Kubernetes! - -I will try to explain some reason I think Kubenetes is interesting without using the words “cloud native”, “orchestration”, “container”, or any Kubernetes-specific terminology :). I’m going to explain this mostly from the perspective of a kubernetes operator / infrastructure engineer, since my job right now is to set up Kubernetes and make it work well. - -I’m not going to try to address the question of “should you use kubernetes for your production systems?” at all, that is a very complicated question. (not least because “in production” has totally different requirements depending on what you’re doing) - -### Kubernetes lets you run code in production without setting up new servers - -The first pitch I got for Kubernetes was the following conversation with my partner Kamal: - -Here’s an approximate transcript: - -* Kamal: With Kubernetes you can set up a new service with a single command - -* Julia: I don’t understand how that’s possible. - -* Kamal: Like, you just write 1 configuration file, apply it, and then you have a HTTP service running in production - -* Julia: But today I need to create new AWS instances, write a puppet manifest, set up service discovery, configure my load balancers, configure our deployment software, and make sure DNS is working, it takes at least 4 hours if nothing goes wrong. - -* Kamal: Yeah. With Kubernetes you don’t have to do any of that, you can set up a new HTTP service in 5 minutes and it’ll just automatically run. As long as you have spare capacity in your cluster it just works! - -* Julia: There must be a trap - -There kind of is a trap, setting up a production Kubernetes cluster is (in my experience) is definitely not easy. (see [Kubernetes The Hard Way][3] for what’s involved to get started). But we’re not going to go into that right now! - -So the first cool thing about Kubernetes is that it has the potential to make life way easier for developers who want to deploy new software into production. That’s cool, and it’s actually true, once you have a working Kubernetes cluster you really can set up a production HTTP service (“run 5 of this application, set up a load balancer, give it this DNS name, done”) with just one configuration file. It’s really fun to see. - -### Kubernetes gives you easy visibility & control of what code you have running in production - -IMO you can’t understand Kubernetes without understanding etcd. So let’s talk about etcd! - -Imagine that I asked you today “hey, tell me every application you have running in production, what host it’s running on, whether it’s healthy or not, and whether or not it has a DNS name attached to it”. I don’t know about you but I would need to go look in a bunch of different places to answer this question and it would take me quite a while to figure out. I definitely can’t query just one API. - -In Kubernetes, all the state in your cluster – applications running (“pods”), nodes, DNS names, cron jobs, and more – is stored in a single database (etcd). Every Kubernetes component is stateless, and basically works by - -* Reading state from etcd (eg “the list of pods assigned to node 1”) - -* Making changes (eg “actually start running pod A on node 1”) - -* Updating the state in etcd (eg “set the state of pod A to ‘running’”) - -This means that if you want to answer a question like “hey, how many nginx pods do I have running right now in that availabliity zone?” you can answer it by querying a single unified API (the Kubernetes API!). And you have exactly the same access to that API that every other Kubernetes component does. - -This also means that you have easy control of everything running in Kubernetes. If you want to, say, - -* Implement a complicated custom rollout strategy for deployments (deploy 1 thing, wait 2 minutes, deploy 5 more, wait 3.7 minutes, etc) - -* Automatically [start a new webserver][1] every time a branch is pushed to github - -* Monitor all your running applications to make sure all of them have a reasonable cgroups memory limit - -all you need to do is to write a program that talks to the Kubernetes API. (a “controller”) - -Another very exciting thing about the Kubernetes API is that you’re not limited to just functionality that Kubernetes provides! If you decide that you have your own opinions about how your software should be deployed / created / monitored, then you can write code that uses the Kubernetes API to do it! It lets you do everything you need. - -### If every Kubernetes component dies, your code will still keep running - -One thing I was originally promised (by various blog posts :)) about Kubernetes was “hey, if the Kubernetes apiserver and everything else dies, it’s ok, your code will just keep running”. I thought this sounded cool in theory but I wasn’t sure if it was actually true. - -So far it seems to be actually true! - -I’ve been through some etcd outages now, and what happens is - -1. All the code that was running keeps running - -2. Nothing  _new_  happens (you can’t deploy new code or make changes, cron jobs will stop working) - -3. When everything comes back, the cluster will catch up on whatever it missed - -This does mean that if etcd goes down and one of your applications crashes or something, it can’t come back up until etcd returns. - -### Kubernetes’ design is pretty resilient to bugs - -Like any piece of software, Kubernetes has bugs. For example right now in our cluster the controller manager has a memory leak, and the scheduler crashes pretty regularly. Bugs obviously aren’t good but so far I’ve found that Kubernetes’ design helps mitigate a lot of the bugs in its core components really well. - -If you restart any component, what happens is: - -* It reads all its relevant state from etcd - -* It starts doing the necessary things it’s supposed to be doing based on that state (scheduling pods, garbage collecting completed pods, scheduling cronjobs, deploying daemonsets, whatever) - -Because all the components don’t keep any state in memory, you can just restart them at any time and that can help mitigate a variety of bugs. - -For example! Let’s say you have a memory leak in your controller manager. Because the controller manager is stateless, you can just periodically restart it every hour or something and feel confident that you won’t cause any consistency issues. Or we ran into a bug in the scheduler where it would sometimes just forget about pods and never schedule them. You can sort of mitigate this just by restarting the scheduler every 10 minutes. (we didn’t do that, we fixed the bug instead, but you  _could_  :) ) - -So I feel like I can trust Kubernetes’ design to help make sure the state in the cluster is consistent even when there are bugs in its core components. And in general I think the software is generally improving over time. The only stateful thing you have to operate is etcd - -Not to harp on this “state” thing too much but – I think it’s cool that in Kubernetes the only thing you have to come up with backup/restore plans for is etcd (unless you use persistent volumes for your pods). I think it makes kubernetes operations a lot easier to think about. - -### Implementing new distributed systems on top of Kubernetes is relatively easy - -Suppose you want to implement a distributed cron job scheduling system! Doing that from scratch is a ton of work. But implementing a distributed cron job scheduling system inside Kubernetes is much easier! (still not trivial, it’s still a distributed system) - -The first time I read the code for the Kubernetes cronjob controller I was really delighted by how simple it was. Here, go read it! The main logic is like 400 lines of Go. Go ahead, read it! => [cronjob_controller.go][4] <= - -Basically what the cronjob controller does is: - -* Every 10 seconds: - * Lists all the cronjobs that exist - - * Checks if any of them need to run right now - - * If so, creates a new Job object to be scheduled & actually run by other Kubernetes controllers - - * Clean up finished jobs - - * Repeat - -The Kubernetes model is pretty constrained (it has this pattern of resources are defined in etcd, controllers read those resources and update etcd), and I think having this relatively opinionated/constrained model makes it easier to develop your own distributed systems inside the Kubernetes framework. - -Kamal introduced me to this idea of “Kubernetes is a good platform for writing your own distributed systems” instead of just “Kubernetes is a distributed system you can use” and I think it’s really interesting. He has a prototype of a [system to run an HTTP service for every branch you push to github][5]. It took him a weekend and is like 800 lines of Go, which I thought was impressive! - -### Kubernetes lets you do some amazing things (but isn’t easy) - -I started out by saying “kubernetes lets you do these magical things, you can just spin up so much infrastructure with a single configuration file, it’s amazing”. And that’s true! - -What I mean by “Kubernetes isn’t easy” is that Kubernetes has a lot of moving parts learning how to successfully operate a highly available Kubernetes cluster is a lot of work. Like I find that with a lot of the abstractions it gives me, I need to understand what is underneath those abstractions in order to debug issues and configure things properly. I love learning new things so this doesn’t make me angry or anything, I just think it’s important to know :) - -One specific example of “I can’t just rely on the abstractions” that I’ve struggled with is that I needed to learn a LOT [about how networking works on Linux][6] to feel confident with setting up Kubernetes networking, way more than I’d ever had to learn about networking before. This was very fun but pretty time consuming. I might write more about what is hard/interesting about setting up Kubernetes networking at some point. - -Or I wrote a [2000 word blog post][7] about everything I had to learn about Kubernetes’ different options for certificate authorities to be able to set up my Kubernetes CAs successfully. - -I think some of these managed Kubernetes systems like GKE (google’s kubernetes product) may be simpler since they make a lot of decisions for you but I haven’t tried any of them. - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/2017/10/05/reasons-kubernetes-is-cool/ - -作者:[ Julia Evans][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://jvns.ca/about -[1]:https://github.com/kamalmarhubi/kubereview -[2]:https://jvns.ca/categories/kubernetes -[3]:https://github.com/kelseyhightower/kubernetes-the-hard-way -[4]:https://github.com/kubernetes/kubernetes/blob/e4551d50e57c089aab6f67333412d3ca64bc09ae/pkg/controller/cronjob/cronjob_controller.go -[5]:https://github.com/kamalmarhubi/kubereview -[6]:https://jvns.ca/blog/2016/12/22/container-networking/ -[7]:https://jvns.ca/blog/2017/08/05/how-kubernetes-certificates-work/ diff --git a/sources/tech/20171010 Operating a Kubernetes network.md b/sources/tech/20171010 Operating a Kubernetes network.md deleted file mode 100644 index 9c85e9aa70..0000000000 --- a/sources/tech/20171010 Operating a Kubernetes network.md +++ /dev/null @@ -1,216 +0,0 @@ -Operating a Kubernetes network -============================================================ - -I’ve been working on Kubernetes networking a lot recently. One thing I’ve noticed is, while there’s a reasonable amount written about how to **set up** your Kubernetes network, I haven’t seen much about how to **operate** your network and be confident that it won’t create a lot of production incidents for you down the line. - -In this post I’m going to try to convince you of three things: (all I think pretty reasonable :)) - -* Avoiding networking outages in production is important - -* Operating networking software is hard - -* It’s worth thinking critically about major changes to your networking infrastructure and the impact that will have on your reliability, even if very fancy Googlers say “this is what we do at Google”. (google engineers are doing great work on Kubernetes!! But I think it’s important to still look at the architecture and make sure it makes sense for your organization.) - -I’m definitely not a Kubernetes networking expert by any means, but I have run into a few issues while setting things up and definitely know a LOT more about Kubernetes networking than I used to. - -### Operating networking software is hard - -Here I’m not talking about operating physical networks (I don’t know anything about that), but instead about keeping software like DNS servers & load balancers & proxies working correctly. - -I have been working on a team that’s responsible for a lot of networking infrastructure for a year, and I have learned a few things about operating networking infrastructure! (though I still have a lot to learn obviously). 3 overall thoughts before we start: - -* Networking software often relies very heavily on the Linux kernel. So in addition to configuring the software correctly you also need to make sure that a bunch of different sysctls are set correctly, and a misconfigured sysctl can easily be the difference between “everything is 100% fine” and “everything is on fire”. - -* Networking requirements change over time (for example maybe you’re doing 5x more DNS lookups than you were last year! Maybe your DNS server suddenly started returning TCP DNS responses instead of UDP which is a totally different kernel workload!). This means software that was working fine before can suddenly start having issues. - -* To fix a production networking issues you often need a lot of expertise. (for example see this [great post by Sophie Haskins on debugging a kube-dns issue][1]) I’m a lot better at debugging networking issues than I was, but that’s only after spending a huge amount of time investing in my knowledge of Linux networking. - -I am still far from an expert at networking operations but I think it seems important to: - -1. Very rarely make major changes to the production networking infrastructure (because it’s super disruptive) - -2. When you  _are_  making major changes, think really carefully about what the failure modes are for the new network architecture are - -3. Have multiple people who are able to understand your networking setup - -Switching to Kubernetes is obviously a pretty major networking change! So let’s talk about what some of the things that can go wrong are! - -### Kubernetes networking components - -The Kubernetes networking components we’re going to talk about in this post are: - -* Your overlay network backend (like flannel/calico/weave net/romana) - -* `kube-dns` - -* `kube-proxy` - -* Ingress controllers / load balancers - -* The `kubelet` - -If you’re going to set up HTTP services you probably need all of these. I’m not using most of these components yet but I’m trying to understand them, so that’s what this post is about. - -### The simplest way: Use host networking for all your containers - -Let’s start with the simplest possible thing you can do. This won’t let you run HTTP services in Kubernetes. I think it’s pretty safe because there are less moving parts. - -If you use host networking for all your containers I think all you need to do is: - -1. Configure the kubelet to configure DNS correctly inside your containers - -2. That’s it - -If you use host networking for literally every pod you don’t need kube-dns or kube-proxy. You don’t even need a working overlay network. - -In this setup your pods can connect to the outside world (the same way any process on your hosts would talk to the outside world) but the outside world can’t connect to your pods. - -This isn’t super important (I think most people want to run HTTP services inside Kubernetes and actually communicate with those services) but I do think it’s interesting to realize that at some level all of this networking complexity isn’t strictly required and sometimes you can get away without using it. Avoiding networking complexity seems like a good idea to me if you can. - -### Operating an overlay network - -The first networking component we’re going to talk about is your overlay network. Kubernetes assumes that every pod has an IP address and that you can communicate with services inside that pod by using that IP address. When I say “overlay network” this is what I mean (“the system that lets you refer to a pod by its IP address”). - -All other Kubernetes networking stuff relies on the overlay networking working correctly. You can read more about the [kubernetes networking model here][10]. - -The way Kelsey Hightower describes in [kubernetes the hard way][11] seems pretty good but it’s not really viable on AWS for clusters more than 50 nodes or so, so I’m not going to talk about that. - -There are a lot of overlay network backends (calico, flannel, weaveworks, romana) and the landscape is pretty confusing. But as far as I’m concerned an overlay network has 2 responsibilities: - -1. Make sure your pods can send network requests outside your cluster - -2. Keep a stable mapping of nodes to subnets and keep every node in your cluster updated with that mapping. Do the right thing when nodes are added & removed. - -Okay! So! What can go wrong with your overlay network? - -* The overlay network is responsible for setting up iptables rules (basically `iptables -A -t nat POSTROUTING -s $SUBNET -j MASQUERADE`) to ensure that containers can make network requests outside Kubernetes. If something goes wrong with this rule then your containers can’t connect to the external network. This isn’t that hard (it’s just a few iptables rules) but it is important. I made a [pull request][2] because I wanted to make sure this was resilient - -* Something can go wrong with adding or deleting nodes. We’re using the flannel hostgw backend and at the time we started using it, node deletion [did not work][3]. - -* Your overlay network is probably dependent on a distributed database (etcd). If that database has an incident, this can cause issues. For example [https://github.com/coreos/flannel/issues/610][4] says that if you have data loss in your flannel etcd cluster it can result in containers losing network connectivity. (this has now been fixed) - -* You upgrade Docker and everything breaks - -* Probably more things! - -I’m mostly talking about past issues in Flannel here but I promise I’m not picking on Flannel – I actually really **like** Flannel because I feel like it’s relatively simple (for instance the [vxlan backend part of it][12] is like 500 lines of code) and I feel like it’s possible for me to reason through any issues with it. And it’s obviously continuously improving. They’ve been great about reviewing pull requests. - -My approach to operating an overlay network so far has been: - -* Learn how it works in detail and how to debug it (for example the hostgw network backend for Flannel works by creating routes, so you mostly just need to do `sudo ip route list` to see whether it’s doing the correct thing) - -* Maintain an internal build so it’s easy to patch it if needed - -* When there are issues, contribute patches upstream - -I think it’s actually really useful to go through the list of merged PRs and see bugs that have been fixed in the past – it’s a bit time consuming but is a great way to get a concrete list of kinds of issues other people have run into. - -It’s possible that for other people their overlay networks just work but that hasn’t been my experience and I’ve heard other folks report similar issues. If you have an overlay network setup that is a) on AWS and b) works on a cluster more than 50-100 nodes where you feel more confident about operating it I would like to know. - -### Operating kube-proxy and kube-dns? - -Now that we have some thoughts about operating overlay networks, let’s talk about - -There’s a question mark next to this one because I haven’t done this. Here I have more questions than answers. - -Here’s how Kubernetes services work! A service is a collection of pods, which each have their own IP address (like 10.1.0.3, 10.2.3.5, 10.3.5.6) - -1. Every Kubernetes service gets an IP address (like 10.23.1.2) - -2. `kube-dns` resolves Kubernetes service DNS names to IP addresses (so my-svc.my-namespace.svc.cluster.local might map to 10.23.1.2) - -3. `kube-proxy` sets up iptables rules in order to do random load balancing between them. Kube-proxy also has a userspace round-robin load balancer but my impression is that they don’t recommend using it. - -So when you make a request to `my-svc.my-namespace.svc.cluster.local`, it resolves to 10.23.1.2, and then iptables rules on your local host (generated by kube-proxy) redirect it to one of 10.1.0.3 or 10.2.3.5 or 10.3.5.6 at random. - -Some things that I can imagine going wrong with this: - -* `kube-dns` is misconfigured - -* `kube-proxy` dies and your iptables rules don’t get updated - -* Some issue related to maintaining a large number of iptables rules - -Let’s talk about the iptables rules a bit, since doing load balancing by creating a bajillion iptables rules is something I had never heard of before! - -kube-proxy creates one iptables rule per target host like this: (these rules are from [this github issue][13]) - -``` --A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -m statistic --mode random --probability 0.20000000019 -j KUBE-SEP-E4QKA7SLJRFZZ2DD[b][c] --A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -m statistic --mode random --probability 0.25000000000 -j KUBE-SEP-LZ7EGMG4DRXMY26H --A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -m statistic --mode random --probability 0.33332999982 -j KUBE-SEP-RKIFTWKKG3OHTTMI --A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-CGDKBCNM24SZWCMS --A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -j KUBE-SEP-RI4SRNQQXWSTGE2Y - -``` - -So kube-proxy creates a **lot** of iptables rules. What does that mean? What are the implications of that in for my network? There’s a great talk from Huawei called [Scale Kubernetes to Support 50,000 services][14] that says if you have 5,000 services in your kubernetes cluster, it takes **11 minutes** to add a new rule. If that happened to your real cluster I think it would be very bad. - -I definitely don’t have 5,000 services in my cluster, but 5,000 isn’t SUCH a bit number. The proposal they give to solve this problem is to replace this iptables backend for kube-proxy with IPVS which is a load balancer that lives in the Linux kernel. - -It seems like kube-proxy is going in the direction of various Linux kernel based load balancers. I think this is partly because they support UDP load balancing, and other load balancers (like HAProxy) don’t support UDP load balancing. - -But I feel comfortable with HAProxy! Is it possible to replace kube-proxy with HAProxy! I googled this and I found this [thread on kubernetes-sig-network][15] saying: - -> kube-proxy is so awesome, we have used in production for almost a year, it works well most of time, but as we have more and more services in our cluster, we found it was getting hard to debug and maintain. There is no iptables expert in our team, we do have HAProxy&LVS experts, as we have used these for several years, so we decided to replace this distributed proxy with a centralized HAProxy. I think this maybe useful for some other people who are considering using HAProxy with kubernetes, so we just update this project and make it open source: [https://github.com/AdoHe/kube2haproxy][5]. If you found it’s useful , please take a look and give a try. - -So that’s an interesting option! I definitely don’t have answers here, but, some thoughts: - -* Load balancers are complicated - -* DNS is also complicated - -* If you already have a lot of experience operating one kind of load balancer (like HAProxy), it might make sense to do some extra work to use that instead of starting to use an entirely new kind of load balancer (like kube-proxy) - -* I’ve been thinking about where we want to be using kube-proxy or kube-dns at all – I think instead it might be better to just invest in Envoy and rely entirely on Envoy for all load balancing & service discovery. So then you just need to be good at operating Envoy. - -As you can see my thoughts on how to operate your Kubernetes internal proxies are still pretty confused and I’m still not super experienced with them. It’s totally possible that kube-proxy and kube-dns are fine and that they will just work fine but I still find it helpful to think through what some of the implications of using them are (for example “you can’t have 5,000 Kubernetes services”). - -### Ingress - -If you’re running a Kubernetes cluster, it’s pretty likely that you actually need HTTP requests to get into your cluster so far. This blog post is already too long and I don’t know much about ingress yet so we’re not going to talk about that. - -### Useful links - -A couple of useful links, to summarize: - -* [The Kubernetes networking model][6] - -* How GKE networking works: [https://www.youtube.com/watch?v=y2bhV81MfKQ][7] - -* The aforementioned talk on `kube-proxy` performance: [https://www.youtube.com/watch?v=4-pawkiazEg][8] - -### I think networking operations is important - -My sense of all this Kubernetes networking software is that it’s all still quite new and I’m not sure we (as a community) really know how to operate all of it well. This makes me worried as an operator because I really want my network to keep working! :) Also I feel like as an organization running your own Kubernetes cluster you need to make a pretty large investment into making sure you understand all the pieces so that you can fix things when they break. Which isn’t a bad thing, it’s just a thing. - -My plan right now is just to keep learning about how things work and reduce the number of moving parts I need to worry about as much as possible. - -As usual I hope this was helpful and I would very much like to know what I got wrong in this post! - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/2017/10/10/operating-a-kubernetes-network/ - -作者:[Julia Evans ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://jvns.ca/about -[1]:http://blog.sophaskins.net/blog/misadventures-with-kube-dns/ -[2]:https://github.com/coreos/flannel/pull/808 -[3]:https://github.com/coreos/flannel/pull/803 -[4]:https://github.com/coreos/flannel/issues/610 -[5]:https://github.com/AdoHe/kube2haproxy -[6]:https://kubernetes.io/docs/concepts/cluster-administration/networking/#kubernetes-model -[7]:https://www.youtube.com/watch?v=y2bhV81MfKQ -[8]:https://www.youtube.com/watch?v=4-pawkiazEg -[9]:https://jvns.ca/categories/kubernetes -[10]:https://kubernetes.io/docs/concepts/cluster-administration/networking/#kubernetes-model -[11]:https://github.com/kelseyhightower/kubernetes-the-hard-way/blob/master/docs/11-pod-network-routes.md -[12]:https://github.com/coreos/flannel/tree/master/backend/vxlan -[13]:https://github.com/kubernetes/kubernetes/issues/37932 -[14]:https://www.youtube.com/watch?v=4-pawkiazEg -[15]:https://groups.google.com/forum/#!topic/kubernetes-sig-network/3NlBVbTUUU0 diff --git a/sources/tech/20171011 LEAST PRIVILEGE CONTAINER ORCHESTRATION.md b/sources/tech/20171011 LEAST PRIVILEGE CONTAINER ORCHESTRATION.md deleted file mode 100644 index 7a9b6e817c..0000000000 --- a/sources/tech/20171011 LEAST PRIVILEGE CONTAINER ORCHESTRATION.md +++ /dev/null @@ -1,174 +0,0 @@ -# LEAST PRIVILEGE CONTAINER ORCHESTRATION - - -The Docker platform and the container has become the standard for packaging, deploying, and managing applications. In order to coordinate running containers across multiple nodes in a cluster, a key capability is required: a container orchestrator. - -![container orchestrator](https://i0.wp.com/blog.docker.com/wp-content/uploads/f753d4e8-9e22-4fe2-be9a-80661ef696a8-3.jpg?resize=536%2C312&ssl=1) - -Orchestrators are responsible for critical clustering and scheduling tasks, such as: - -* Managing container scheduling and resource allocation. - -* Support service discovery and hitless application deploys. - -* Distribute the necessary resources that applications need to run. - -Unfortunately, the distributed nature of orchestrators and the ephemeral nature of resources in this environment makes securing orchestrators a challenging task. In this post, we will describe in detail the less-considered—yet vital—aspect of the security model of container orchestrators, and how Docker Enterprise Edition with its built-in orchestration capability, Swarm mode, overcomes these difficulties. - -Motivation and threat model -============================================================ - -One of the primary objectives of Docker EE with swarm mode is to provide an orchestrator with security built-in. To achieve this goal, we developed the first container orchestrator designed with the principle of least privilege in mind. - -In computer science,the principle of least privilege in a distributed system requires that each participant of the system must only have access to  the information and resources that are necessary for its legitimate purpose. No more, no less. - -> #### ”A process must be able to access only the information and resources that are necessary for its legitimate purpose.” - -#### Principle of Least Privilege - -Each node in a Docker EE swarm is assigned role: either manager or worker. These roles define a coarsegrained level of privilege to the nodes: administration and task execution, respectively. However, regardless of its role, a node has access only to the information and resources it needs to perform the necessary tasks, with cryptographically enforced guarantees. As a result, it becomes easier to secure clusters against even the most sophisticated attacker models: attackers that control the underlying communication networks or even compromised cluster nodes. - -# Secure-by-default core - -There is an old security maxim that states: if it doesn’t come by default, no one will use it. Docker Swarm mode takes this notion to heart, and ships with secure-by-default mechanisms to solve three of the hardest and most important aspects of the orchestration lifecycle: - -1. Trust bootstrap and node introduction. - -2. Node identity issuance and management. - -3. Authenticated, Authorized, Encrypted information storage and dissemination. - -Let’s look at each of these aspects individually - -### Trust Bootstrap and Node Introduction - -The first step to a secure cluster is tight control over membership and identity. Without it, administrators cannot rely on the identities of their nodes and enforce strict workload separation between nodes. This means that unauthorized nodes can’t be allowed to join the cluster, and nodes that are already part of the cluster aren’t able to change identities, suddenly pretending to be another node. - -To address this need, nodes managed by Docker EE’s Swarm mode maintain strong, immutable identities. The desired properties are cryptographically guaranteed by using two key building-blocks: - -1. Secure join tokens for cluster membership. - -2. Unique identities embedded in certificates issued from a central certificate authority. - -### Joining the Swarm - -To join the swarm, a node needs a copy of a secure join token. The token is unique to each operational role within the cluster—there are currently two types of nodes: workers and managers. Due to this separation, a node with a copy of a worker token will not be allowed to join the cluster as a manager. The only way to get this special token is for a cluster administrator to interactively request it from the cluster’s manager through the swarm administration API. - -The token is securely and randomly generated, but it also has a special syntax that makes leaks of this token easier to detect: a special prefix that you can easily monitor for in your logs and repositories. Fortunately, even if a leak does occur, tokens are easy to rotate, and we recommend that you rotate them often—particularly in the case where your cluster will not be scaling up for a while. - -![Docker Swarm](https://i1.wp.com/blog.docker.com/wp-content/uploads/92d171d4-52c7-4702-8143-110c6f52017c-2.jpg?resize=547%2C208&ssl=1) - -### Bootstrapping trust - -As part of establishing its identity, a new node will ask for a new identity to be issued by any of the network managers. However, under our threat model, all communications can be intercepted by a third-party. This begs the question: how does a node know that it is talking to a legitimate manager? - -![Docker Security](https://i0.wp.com/blog.docker.com/wp-content/uploads/94e3fef0-5bd2-4970-b9e9-25b566d926ad-2.jpg?resize=528%2C348&ssl=1) - -Fortunately, Docker has a built-in mechanism for preventing this from happening. The join token, which the host uses to join the swarm, includes a hash of the root CA’s certificate. The host can therefore use one-way TLS and use the hash to verify that it’s joining the right swarm: if the manager presents a certificate not signed by a CA that matches the hash, the node knows not to trust it. - -### Node identity issuance and management - -Identities in a swarm are embedded in x509 certificates held by each individual node. In a manifestation of the least privilege principle, the certificates’ private keys are restricted strictly to the hosts where they originate. In particular, managers do not have access to private keys of any certificate but their own. - -### Identity Issuance - -To receive their certificates without sharing their private keys, new hosts begin by issuing a certificate signing request (CSR), which the managers then convert into a certificate. This certificate now becomes the new host’s identity, making the node a full-fledged member of the swarm! - -#### -![](https://i0.wp.com/blog.docker.com/wp-content/uploads/415ae6cf-7e76-4ba8-9d84-6d49bf327d8f-2.jpg?resize=548%2C350&ssl=1) - -When used alongside with the secure bootstrapping mechanism, this mechanism for issuing identities to joining nodes is secure by default: all communicating parties are authenticated, authorized and no sensitive information is ever exchanged in clear-text. - -### Identity Renewal - -However, securely joining nodes to a swarm is only part of the story. To minimize the impact of leaked or stolen certificates and to remove the complexity of managing CRL lists, Swarm mode uses short-lived certificates for the identities. These certificates have a default expiration of three months, but can be configured to expire every hour! - -![Docker secrets](https://i0.wp.com/blog.docker.com/wp-content/uploads/55e2ab9a-19cd-465d-82c6-fa76110e7ecd-2.jpg?resize=556%2C365&ssl=1) - -This short certificate expiration time means that certificate rotation can’t be a manual process, as it usually is for most PKI systems. With swarm, all certificates are rotated automatically and in a hitless fashion. The process is simple: using a mutually authenticated TLS connection to prove ownership over a particular identity, a Swarm node generates regularly a new public/private key pair and sends the corresponding CSR to be signed, creating a completely new certificate, but maintaining the same identity. - -### Authenticated, Authorized, Encrypted information storage and dissemination. - -During the normal operation of a swarm, information about the tasks has to be sent to the worker nodes for execution. This includes not only information on which containers are to be executed by a node;but also, it includes  all the resources that are necessary for the successful execution of that container, including sensitive secrets such as private keys, passwords, and API tokens. - -### Transport Security - -The fact that every node participating in a swarm is in possession of a unique identity in the form of a X509 certificate, communicating securely between nodes is trivial: nodes can use their respective certificates to establish mutually authenticated connections between one another, inheriting the confidentiality, authenticity and integrity properties of TLS. - -![Swarm Mode](https://i0.wp.com/blog.docker.com/wp-content/uploads/972273a3-d9e5-4053-8fcb-a407c8cdcbf6-2.jpg?resize=347%2C271&ssl=1) - -One interesting detail about Swarm mode is the fact that it uses a push model: only managers are allowed to send information to workers—significantly reducing the surface of attack manager nodes expose to the less privileged worker nodes. - -### Strict Workload Separation Into Security Zones - -One of the responsibilities of manager nodes is deciding which tasks to send to each of the workers. Managers make this determination using a variety of strategies; scheduling the workloads across the swarm depending on both the unique properties of each node and each workload. - -In Docker EE with Swarm mode, administrators have the ability of influencing these scheduling decisions by using labels that are securely attached to the individual node identities. These labels allow administrators to group nodes together into different security zones limiting the exposure of particularly sensitive workloads and any secrets related to them. - -![Docker Swarm Security](https://i0.wp.com/blog.docker.com/wp-content/uploads/67ffa551-d4ae-4522-ba13-4a646a158592-2.jpg?resize=546%2C375&ssl=1) - -### Secure Secret Distribution - -In addition to facilitating the identity issuance process, manager nodes have the important task of storing and distributing any resources needed by a worker. Secrets are treated like any other type of resource, and are pushed down from the manager to the worker over the secure mTLS connection. - -![Docker Secrets](https://i1.wp.com/blog.docker.com/wp-content/uploads/4341da98-2f8c-4aed-bb40-607246344dd8-2.jpg?resize=508%2C326&ssl=1) - -On the hosts, Docker EE ensures that secrets are provided only to the containers they are destined for. Other containers on the same host will not have access to them. Docker exposes secrets to a container as a temporary file system, ensuring that secrets are always stored in memory and never written to disk. This method is more secure than competing alternatives, such as [storing them in environment variables][12]. Once a task completes the secret is gone forever. - -### Storing secrets - -On manager hosts secrets are always encrypted at rest. By default, the key that encrypts these secrets (known as the Data Encryption Key, DEK) is also stored in plaintext on disk. This makes it easy for those with minimal security requirements to start using Docker Swarm mode. - -However, once you are running a production cluster, we recommend you enable auto-lock mode. When auto-lock mode is enabled, a newly rotated DEK is encrypted with a separate Key Encryption Key (KEK). This key is never stored on the cluster; the administrator is responsible for storing it securely and providing it when the cluster starts up. This is known as unlocking the swarm. - -Swarm mode supports multiple managers, relying on the Raft Consensus Algorithm for fault tolerance. Secure secret storage scales seamlessly in this scenario. Each manager host has a unique disk encryption key, in addition to the shared key. Furthermore, Raft logs are encrypted on disk and are similarly unavailable without the KEK when in autolock mode. - -### What happens when a node is compromised? - -![Docker Secrets](https://i0.wp.com/blog.docker.com/wp-content/uploads/2a78b37d-bbf0-40ee-a282-eb0900f71ba9-2.jpg?resize=502%2C303&ssl=1) - -In traditional orchestrators, recovering from a compromised host is a slow and complicated process. With Swarm mode, recovery is as easy as running the docker node rm command. This removes the affected node from the cluster, and Docker will take care of the rest, namely re-balancing services and making sure other hosts know not to talk to the affected node. - -As we have seen, thanks to least privilege orchestration, even if the attacker were still active on the host, they would be cut off from the rest of the network. The host’s certificate — its identity — is blacklisted, so the managers will not accept it as valid. - -# Conclusion - -Docker EE with Swarm mode ensures security by default in all key areas of orchestration: - -* Joining the cluster. Prevents malicious nodes from joining the cluster. - -* Organizing hosts into security zones. Prevents lateral movement by attackers. - -* Scheduling tasks. Tasks will be issued only to designated and allowed nodes. - -* Allocating resources. A malicious node cannot “steal” another’s workload or resources. - -* Storing secrets. Never stored in plaintext and never written to disk on worker nodes. - -* Communicating with the workers. Encrypted using mutually authenticated TLS. - -As Swarm mode continues to improve, the Docker team is working to take the principle of least privilege orchestration even further. The task we are tackling is: how can systems remain secure if a manager is compromised? The roadmap is in place, with some of the features already available such as the ability of whitelisting only specific Docker images, preventing managers from executing arbitrary workloads. This is achieved quite naturally using Docker Content Trust. - --------------------------------------------------------------------------------- - -via: https://blog.docker.com/2017/10/least-privilege-container-orchestration/ - -作者:[Diogo Mónica ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://blog.docker.com/author/diogo/ -[1]:http://www.linkedin.com/shareArticle?mini=true&url=http://dockr.ly/2yZoNdy&title=Least%20Privilege%20Container%20Orchestration&summary=The%20Docker%20platform%20and%20the%20container%20has%20become%20the%20standard%20for%20packaging,%20deploying,%20and%20managing%20applications.%20In%20order%20to%20coordinate%20running%20containers%20across%20multiple%20nodes%20in%20a%20cluster,%20a%20key%20capability%20is%20required:%20a%20container%20orchestrator.Orchestrators%20are%20responsible%20for%20critical%20clustering%20and%20scheduling%20tasks,%20such%20as:%20%20%20%20Managing%20... -[2]:http://www.reddit.com/submit?url=http://dockr.ly/2yZoNdy&title=Least%20Privilege%20Container%20Orchestration -[3]:https://plus.google.com/share?url=http://dockr.ly/2yZoNdy -[4]:http://news.ycombinator.com/submitlink?u=http://dockr.ly/2yZoNdy&t=Least%20Privilege%20Container%20Orchestration -[5]:https://blog.docker.com/author/diogo/ -[6]:https://blog.docker.com/tag/docker-orchestration/ -[7]:https://blog.docker.com/tag/docker-secrets/ -[8]:https://blog.docker.com/tag/docker-security/ -[9]:https://blog.docker.com/tag/docker-swarm/ -[10]:https://blog.docker.com/tag/least-privilege-orchestrator/ -[11]:https://blog.docker.com/tag/tls/ -[12]:https://diogomonica.com/2017/03/27/why-you-shouldnt-use-env-variables-for-secret-data/ diff --git a/sources/tech/20171020 How Eclipse is advancing IoT development.md b/sources/tech/20171020 How Eclipse is advancing IoT development.md new file mode 100644 index 0000000000..30fd8eb64d --- /dev/null +++ b/sources/tech/20171020 How Eclipse is advancing IoT development.md @@ -0,0 +1,83 @@ +apply for translating + +How Eclipse is advancing IoT development +============================================================ + +### Open source organization's modular approach to development is a good match for the Internet of Things. + +![How Eclipse is advancing IoT development](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_BUS_ArchitectureOfParticipation_520x292.png?itok=FA0Uuwzv "How Eclipse is advancing IoT development") +Image by : opensource.com + +[Eclipse][3] may not be the first open source organization that pops to mind when thinking about Internet of Things (IoT) projects. After all, the foundation has been around since 2001, long before IoT was a household word, supporting a community for commercially viable open source software development. + +September's Eclipse IoT Day, held in conjunction with RedMonk's [ThingMonk 2017][4] event, emphasized the big role Eclipse is taking in [IoT development][5]. It currently hosts 28 projects that touch a wide range of IoT needs and projects. While at the conference, I talked with [Ian Skerritt][6], who heads marketing for Eclipse, about Eclipse's IoT projects and how Eclipse thinks about IoT more broadly. + +### What's new about IoT? + +I asked Ian how IoT is different from traditional industrial automation, given that sensors and tools have been connected in factories for the past several decades. Ian notes that many factories still are not connected. + +Additionally, he says, "SCADA [supervisory control and data analysis] systems and even the factory floor technology are very proprietary, very siloed. It's hard to change it. It's hard to adapt to it… Right now, when you set up a manufacturing run, you need to manufacture hundreds of thousands of that piece, of that unit. What [manufacturers] want to do is to meet customer demand, to have manufacturing processes that are very flexible, that you can actually do a lot size of one." That's a big piece of what IoT is bringing to manufacturing. + +### Eclipse's approach to IoT + +He describes Eclipse's involvement in IoT by saying: "There's core fundamental technology that every IoT solution needs," and by using open source, "everyone can use it so they can get broader adoption." He says Eclipse see IoT as consisting of three connected software stacks. At a high level, these stacks mirror the (by now familiar) view that IoT can usually be described as spanning three layers. A given implementation may have even more layers, but they still generally map to the functions of this three-layer model: + +* A stack of software for constrained devices (e.g., the device, endpoint, microcontroller unit (MCU), sensor hardware). + +* Some type of gateway that aggregates information and data from the different sensors and sends it to the network. This layer also may take real-time actions based on what the sensors are observing. + +* A software stack for the IoT platform on the backend. This backend cloud stores the data and can provide services based on collected data, such as analysis of historical trends and predictive analytics. + +The three stacks are described in greater detail in Eclipse's whitepaper "[The Three Software Stacks Required for IoT Architectures][7]." + +Ian says that, when developing a solution within those architectures, "there's very specific things that need to be built, but there's a lot of underlying technology that can be used, like messaging protocols, like gateway services. It needs to be a modular approach to scale up to the different use cases that are up there." This encapsulates Eclipse's activities around IoT: Developing modular open source components that can be used to build a range of business-specific services and solutions. + +### Eclipse's IoT projects + +Of Eclipse's many IoT projects currently in use, Ian says two of the most prominent relate to [MQTT][8], a machine-to-machine (M2M) messaging protocol for IoT. Ian describes it as "a publish‑subscribe messaging protocol that was designed specifically for oil and gas pipeline monitoring where power-management network latency is really important. MQTT has been a great success in terms of being a standard that's being widely adopted in IoT." [Eclipse Mosquitto][9] is MQTT's broker and [Eclipse Paho][10] its client. + +[Eclipse Kura][11] is an IoT gateway that, in Ian's words, "provides northbound and southbound connectivity [for] a lot of different protocols" including Bluetooth, Modbus, controller-area network (CAN) bus, and OPC Unified Architecture, with more being added all the time. One benefit, he says, is "instead of you writing your own connectivity, Kura provides that and then connects you to the network via satellite, via Ethernet, or anything." In addition, it handles firewall configuration, network latency, and other functions. "If the network goes down, it will store messages until it comes back up," Ian says. + +A newer project, [Eclipse Kapua][12], is taking a microservices approach to providing different services for an IoT cloud platform. For example, it handles aspects of connectivity, integration, management, storage, and analysis. Ian describes it as "up and coming. It's not being deployed yet, but Eurotech and Red Hat are very active in that." + +Ian says [Eclipse hawkBit][13], which manages software updates, is one of the "most intriguing projects. From a security perspective, if you can't update your device, you've got a huge security hole." Most IoT security disasters are related to non-updated devices, he says. "HawkBit basically manages the backend of how you do scalable updates across your IoT system." + +Indeed, the difficulty of updating software in IoT devices is regularly cited as one of its biggest security challenges. IoT devices aren't always connected and may be numerous, plus update processes for constrained devices can be hard to consistently get right. For this reason, projects relating to updating IoT software are likely to be important going forward. + +### Why IoT is a good fit for Eclipse + +One of the trends we've seen in IoT development has been around building blocks that are integrated and applied to solve particular business problems, rather than monolithic IoT platforms that apply across industries and companies. This is a good fit with Eclipse's approach to IoT, which focuses on a number of modular stacks; projects that provide specific and commonly needed functions; and brokers, gateways, and protocols that can tie together the components needed for a given implementation. + +-------------------------------------------------------------------------------- + +作者简介: + +Gordon Haff - Gordon Haff is Red Hat’s cloud evangelist, is a frequent and highly acclaimed speaker at customer and industry events, and helps develop strategy across Red Hat’s full portfolio of cloud solutions. He is the author of Computing Next: How the Cloud Opens the Future in addition to numerous other publications. Prior to Red Hat, Gordon wrote hundreds of research notes, was frequently quoted in publications like The New York Times on a wide range of IT topics, and advised clients on product and... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/10/eclipse-and-iot + +作者:[Gordon Haff ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/ghaff +[1]:https://opensource.com/article/17/10/eclipse-and-iot?rate=u1Wr-MCMFCF4C45IMoSPUacCatoqzhdKz7NePxHOvwg +[2]:https://opensource.com/user/21220/feed +[3]:https://www.eclipse.org/home/ +[4]:http://thingmonk.com/ +[5]:https://iot.eclipse.org/ +[6]:https://twitter.com/ianskerrett +[7]:https://iot.eclipse.org/resources/white-papers/Eclipse%20IoT%20White%20Paper%20-%20The%20Three%20Software%20Stacks%20Required%20for%20IoT%20Architectures.pdf +[8]:http://mqtt.org/ +[9]:https://projects.eclipse.org/projects/technology.mosquitto +[10]:https://projects.eclipse.org/projects/technology.paho +[11]:https://www.eclipse.org/kura/ +[12]:https://www.eclipse.org/kapua/ +[13]:https://eclipse.org/hawkbit/ +[14]:https://opensource.com/users/ghaff +[15]:https://opensource.com/users/ghaff +[16]:https://opensource.com/article/17/10/eclipse-and-iot#comments diff --git a/sources/tech/20171102 Dive into BPF a list of reading material.md b/sources/tech/20171102 Dive into BPF a list of reading material.md deleted file mode 100644 index f4b90bd09d..0000000000 --- a/sources/tech/20171102 Dive into BPF a list of reading material.md +++ /dev/null @@ -1,711 +0,0 @@ -Dive into BPF: a list of reading material -============================================================ - -* [What is BPF?][143] - -* [Dive into the bytecode][144] - -* [Resources][145] - * [Generic presentations][23] - * [About BPF][1] - - * [About XDP][2] - - * [About other components related or based on eBPF][3] - - * [Documentation][24] - * [About BPF][4] - - * [About tc][5] - - * [About XDP][6] - - * [About P4 and BPF][7] - - * [Tutorials][25] - - * [Examples][26] - * [From the kernel][8] - - * [From package iproute2][9] - - * [From bcc set of tools][10] - - * [Manual pages][11] - - * [The code][27] - * [BPF code in the kernel][12] - - * [XDP hooks code][13] - - * [BPF logic in bcc][14] - - * [Code to manage BPF with tc][15] - - * [BPF utilities][16] - - * [Other interesting chunks][17] - - * [LLVM backend][18] - - * [Running in userspace][19] - - * [Commit logs][20] - - * [Troubleshooting][28] - * [Errors at compilation time][21] - - * [Errors at load and run time][22] - - * [And still more!][29] - - _~ [Updated][146] 2017-11-02 ~_ - -# What is BPF? - -BPF, as in **B**erkeley **P**acket **F**ilter, was initially conceived in 1992 so as to provide a way to filter packets and to avoid useless packet copies from kernel to userspace. It initially consisted in a simple bytecode that is injected from userspace into the kernel, where it is checked by a verifier—to prevent kernel crashes or security issues—and attached to a socket, then run on each received packet. It was ported to Linux a couple of years later, and used for a small number of applications (tcpdump for example). The simplicity of the language as well as the existence of an in-kernel Just-In-Time (JIT) compiling machine for BPF were factors for the excellent performances of this tool. - -Then in 2013, Alexei Starovoitov completely reshaped it, started to add new functionalities and to improve the performances of BPF. This new version is designated as eBPF (for “extended BPF”), while the former becomes cBPF (“classic” BPF). New features such as maps and tail calls appeared. The JIT machines were rewritten. The new language is even closer to native machine language than cBPF was. And also, new attach points in the kernel have been created. - -Thanks to those new hooks, eBPF programs can be designed for a variety of use cases, that divide into two fields of applications. One of them is the domain of kernel tracing and event monitoring. BPF programs can be attached to kprobes and they compare with other tracing methods, with many advantages (and sometimes some drawbacks). - -The other application domain remains network programming. In addition to socket filter, eBPF programs can be attached to tc (Linux traffic control tool) ingress or egress interfaces and perform a variety of packet processing tasks, in an efficient way. This opens new perspectives in the domain. - -And eBPF performances are further leveraged through the technologies developed for the IO Visor project: new hooks have also been added for XDP (“eXpress Data Path”), a new fast path recently added to the kernel. XDP works in conjunction with the Linux stack, and relies on BPF to perform very fast packet processing. - -Even some projects such as P4, Open vSwitch, [consider][155] or started to approach BPF. Some others, such as CETH, Cilium, are entirely based on it. BPF is buzzing, so we can expect a lot of tools and projects to orbit around it soon… - -# Dive into the bytecode - -As for me: some of my work (including for [BEBA][156]) is closely related to eBPF, and several future articles on this site will focus on this topic. Logically, I wanted to somehow introduce BPF on this blog before going down to the details—I mean, a real introduction, more developed on BPF functionalities that the brief abstract provided in first section: What are BPF maps? Tail calls? What do the internals look like? And so on. But there are a lot of presentations on this topic available on the web already, and I do not wish to create “yet another BPF introduction” that would come as a duplicate of existing documents. - -So instead, here is what we will do. After all, I spent some time reading and learning about BPF, and while doing so, I gathered a fair amount of material about BPF: introductions, documentation, but also tutorials or examples. There is a lot to read, but in order to read it, one has to  _find_  it first. Therefore, as an attempt to help people who wish to learn and use BPF, the present article introduces a list of resources. These are various kinds of readings, that hopefully will help you dive into the mechanics of this kernel bytecode. - -# Resources - -![](https://qmonnet.github.io/whirl-offload/img/icons/pic.svg) - -### Generic presentations - -The documents linked below provide a generic overview of BPF, or of some closely related topics. If you are very new to BPF, you can try picking a couple of presentation among the first ones and reading the ones you like most. If you know eBPF already, you probably want to target specific topics instead, lower down in the list. - -### About BPF - -Generic presentations about eBPF: - -* [_Making the Kernel’s Networking Data Path Programmable with BPF and XDP_][53]  (Daniel Borkmann, OSSNA17, Los Angeles, September 2017): - One of the best set of slides available to understand quickly all the basics about eBPF and XDP (mostly for network processing). - -* [The BSD Packet Filter][54] (Suchakra Sharma, June 2017):  - A very nice introduction, mostly about the tracing aspects. - -* [_BPF: tracing and more_][55]  (Brendan Gregg, January 2017): - Mostly about the tracing use cases. - -* [_Linux BPF Superpowers_][56]  (Brendan Gregg, March 2016): - With a first part on the use of **flame graphs**. - -* [_IO Visor_][57]  (Brenden Blanco, SCaLE 14x, January 2016): - Also introduces **IO Visor project**. - -* [_eBPF on the Mainframe_][58]  (Michael Holzheu, LinuxCon, Dubin, October 2015) - -* [_New (and Exciting!) Developments in Linux Tracing_][59]  (Elena Zannoni, LinuxCon, Japan, 2015) - -* [_BPF — in-kernel virtual machine_][60]  (Alexei Starovoitov, February 2015): - Presentation by the author of eBPF. - -* [_Extending extended BPF_][61]  (Jonathan Corbet, July 2014) - -**BPF internals**: - -* Daniel Borkmann has been doing an amazing work to present **the internals** of eBPF, in particular about **its use with tc**, through several talks and papers. - * [_Advanced programmability and recent updates with tc’s cls_bpf_][30]  (netdev 1.2, Tokyo, October 2016): - Daniel provides details on eBPF, its use for tunneling and encapsulation, direct packet access, and other features. - - * [_cls_bpf/eBPF updates since netdev 1.1_][31]  (netdev 1.2, Tokyo, October 2016, part of [this tc workshop][32]) - - * [_On getting tc classifier fully programmable with cls_bpf_][33]  (netdev 1.1, Sevilla, February 2016): - After introducing eBPF, this presentation provides insights on many internal BPF mechanisms (map management, tail calls, verifier). A must-read! For the most ambitious, [the full paper is available here][34]. - - * [_Linux tc and eBPF_][35]  (fosdem16, Brussels, Belgium, January 2016) - - * [_eBPF and XDP walkthrough and recent updates_][36]  (fosdem17, Brussels, Belgium, February 2017) - - These presentations are probably one of the best sources of documentation to understand the design and implementation of internal mechanisms of eBPF. - -The [**IO Visor blog**][157] has some interesting technical articles about BPF. Some of them contain a bit of marketing talks. - -**Kernel tracing**: summing up all existing methods, including BPF: - -* [_Meet-cute between eBPF and Kerne Tracing_][62]  (Viller Hsiao, July 2016): - Kprobes, uprobes, ftrace - -* [_Linux Kernel Tracing_][63]  (Viller Hsiao, July 2016): - Systemtap, Kernelshark, trace-cmd, LTTng, perf-tool, ftrace, hist-trigger, perf, function tracer, tracepoint, kprobe/uprobe… - -Regarding **event tracing and monitoring**, Brendan Gregg uses eBPF a lot and does an excellent job at documenting some of his use cases. If you are in kernel tracing, you should see his blog articles related to eBPF or to flame graphs. Most of it are accessible [from this article][158] or by browsing his blog. - -Introducing BPF, but also presenting **generic concepts of Linux networking**: - -* [_Linux Networking Explained_][64]  (Thomas Graf, LinuxCon, Toronto, August 2016) - -* [_Kernel Networking Walkthrough_][65]  (Thomas Graf, LinuxCon, Seattle, August 2015) - -**Hardware offload**: - -* eBPF with tc or XDP supports hardware offload, starting with Linux kernel version 4.9 and introduced by Netronome. Here is a presentation about this feature: - [eBPF/XDP hardware offload to SmartNICs][147] (Jakub Kicinski and Nic Viljoen, netdev 1.2, Tokyo, October 2016) - -About **cBPF**: - -* [_The BSD Packet Filter: A New Architecture for User-level Packet Capture_][66]  (Steven McCanne and Van Jacobson, 1992): - The original paper about (classic) BPF. - -* [The FreeBSD manual page about BPF][67] is a useful resource to understand cBPF programs. - -* Daniel Borkmann realized at least two presentations on cBPF, [one in 2013 on mmap, BPF and Netsniff-NG][68], and [a very complete one in 2014 on tc and cls_bpf][69]. - -* On Cloudflare’s blog, Marek Majkowski presented his [use of BPF bytecode with the `xt_bpf`module for **iptables**][70]. It is worth mentioning that eBPF is also supported by this module, starting with Linux kernel 4.10 (I do not know of any talk or article about this, though). - -* [Libpcap filters syntax][71] - -### About XDP - -* [XDP overview][72] on the IO Visor website. - -* [_eXpress Data Path (XDP)_][73]  (Tom Herbert, Alexei Starovoitov, March 2016): - The first presentation about XDP. - -* [_BoF - What Can BPF Do For You?_][74]  (Brenden Blanco, LinuxCon, Toronto, August 2016). - -* [_eXpress Data Path_][148]  (Brenden Blanco, Linux Meetup at Santa Clara, July 2016): - Contains some (somewhat marketing?) **benchmark results**! With a single core: - * ip routing drop: ~3.6 million packets per second (Mpps) - - * tc (with clsact qdisc) drop using BPF: ~4.2 Mpps - - * XDP drop using BPF: 20 Mpps (<10 % CPU utilization) - - * XDP forward (on port on which the packet was received) with rewrite: 10 Mpps - - (Tests performed with the mlx4 driver). - -* Jesper Dangaard Brouer has several excellent sets of slides, that are essential to fully understand the internals of XDP. - * [_XDP − eXpress Data Path, Intro and future use-cases_][37]  (September 2016): - _“Linux Kernel’s fight against DPDK”_ . **Future plans** (as of this writing) for XDP and comparison with DPDK. - - * [_Network Performance Workshop_][38]  (netdev 1.2, Tokyo, October 2016): - Additional hints about XDP internals and expected evolution. - - * [_XDP – eXpress Data Path, Used for DDoS protection_][39]  (OpenSourceDays, March 2017): - Contains details and use cases about XDP, with **benchmark results**, and **code snippets** for **benchmarking** as well as for **basic DDoS protection** with eBPF/XDP (based on an IP blacklisting scheme). - - * [_Memory vs. Networking, Provoking and fixing memory bottlenecks_][40]  (LSF Memory Management Summit, March 2017): - Provides a lot of details about current **memory issues** faced by XDP developers. Do not start with this one, but if you already know XDP and want to see how it really works on the page allocation side, this is a very helpful resource. - - * [_XDP for the Rest of Us_][41]  (netdev 2.1, Montreal, April 2017), with Andy Gospodarek: - How to get started with eBPF and XDP for normal humans. This presentation was also summarized by Julia Evans on [her blog][42]. - - (Jesper also created and tries to extend some documentation about eBPF and XDP, see [related section][75].) - -* [_XDP workshop — Introduction, experience, and future development_][76]  (Tom Herbert, netdev 1.2, Tokyo, October 2016) — as of this writing, only the video is available, I don’t know if the slides will be added. - -* [_High Speed Packet Filtering on Linux_][149]  (Gilberto Bertin, DEF CON 25, Las Vegas, July 2017) — an excellent introduction to state-of-the-art packet filtering on Linux, oriented towards DDoS protection, talking about packet processing in the kernel, kernel bypass, XDP and eBPF. - -### About other components related or based on eBPF - -* [_P4 on the Edge_][77]  (John Fastabend, May 2016): - Presents the use of **P4**, a description language for packet processing, with BPF to create high-performance programmable switches. - -* If you like audio presentations, there is an associated [OvS Orbit episode (#11), called  _**P4** on the Edge_][78] , dating from August 2016\. OvS Orbit are interviews realized by Ben Pfaff, who is one of the core maintainers of Open vSwitch. In this case, John Fastabend is interviewed. - -* [_P4, EBPF and Linux TC Offload_][79]  (Dinan Gunawardena and Jakub Kicinski, August 2016): - Another presentation on **P4**, with some elements related to eBPF hardware offload on Netronome’s **NFP** (Network Flow Processor) architecture. - -* **Cilium** is a technology initiated by Cisco and relying on BPF and XDP to provide “fast in-kernel networking and security policy enforcement for containers based on eBPF programs generated on the fly”. [The code of this project][150] is available on GitHub. Thomas Graf has been performing a number of presentations of this topic: - * [_Cilium: Networking & Security for Containers with BPF & XDP_][43] , also featuring a load balancer use case (Linux Plumbers conference, Santa Fe, November 2016) - - * [_Cilium: Networking & Security for Containers with BPF & XDP_][44]  (Docker Distributed Systems Summit, October 2016 — [video][45]) - - * [_Cilium: Fast IPv6 container Networking with BPF and XDP_][46]  (LinuxCon, Toronto, August 2016) - - * [_Cilium: BPF & XDP for containers_][47]  (fosdem17, Brussels, Belgium, February 2017) - - A good deal of contents is repeated between the different presentations; if in doubt, just pick the most recent one. Daniel Borkmann has also written [a generic introduction to Cilium][80] as a guest author on Google Open Source blog. - -* There are also podcasts about **Cilium**: an [OvS Orbit episode (#4)][81], in which Ben Pfaff interviews Thomas Graf (May 2016), and [another podcast by Ivan Pepelnjak][82], still with Thomas Graf about eBPF, P4, XDP and Cilium (October 2016). - -* **Open vSwitch** (OvS), and its related project **Open Virtual Network** (OVN, an open source network virtualization solution) are considering to use eBPF at various level, with several proof-of-concept prototypes already implemented: - - * [Offloading OVS Flow Processing using eBPF][48] (William (Cheng-Chun) Tu, OvS conference, San Jose, November 2016) - - * [Coupling the Flexibility of OVN with the Efficiency of IOVisor][49] (Fulvio Risso, Matteo Bertrone and Mauricio Vasquez Bernal, OvS conference, San Jose, November 2016) - - These use cases for eBPF seem to be only at the stage of proposals (nothing merge to OvS main branch) as far as I know, but it will be very interesting to see what comes out of it. - -* XDP is envisioned to be of great help for protection against Distributed Denial-of-Service (DDoS) attacks. More and more presentations focus on this. For example, the talks from people from Cloudflare ( [_XDP in practice: integrating XDP in our DDoS mitigation pipeline_][83] ) or from Facebook ( [_Droplet: DDoS countermeasures powered by BPF + XDP_][84] ) at the netdev 2.1 conference in Montreal, Canada, in April 2017, present such use cases. - -* [_CETH for XDP_][85]  (Yan Chan and Yunsong Lu, Linux Meetup, Santa Clara, July 2016): - **CETH** stands for Common Ethernet Driver Framework for faster network I/O, a technology initiated by Mellanox. - -* [**The VALE switch**][86], another virtual switch that can be used in conjunction with the netmap framework, has [a BPF extension module][87]. - -* **Suricata**, an open source intrusion detection system, [seems to rely on eBPF components][88] for its “capture bypass” features: - [_The adventures of a Suricate in eBPF land_][89]  (Éric Leblond, netdev 1.2, Tokyo, October 2016) - [_eBPF and XDP seen from the eyes of a meerkat_][90]  (Éric Leblond, Kernel Recipes, Paris, September 2017) - -* [InKeV: In-Kernel Distributed Network Virtualization for DCN][91] (Z. Ahmed, M. H. Alizai and A. A. Syed, SIGCOMM, August 2016): - **InKeV** is an eBPF-based datapath architecture for virtual networks, targeting data center networks. It was initiated by PLUMgrid, and claims to achieve better performances than OvS-based OpenStack solutions. - -* [_**gobpf** - utilizing eBPF from Go_][92]  (Michael Schubert, fosdem17, Brussels, Belgium, February 2017): - A “library to create, load and use eBPF programs from Go” - -* [**ply**][93] is a small but flexible open source dynamic **tracer** for Linux, with some features similar to the bcc tools, but with a simpler language inspired by awk and dtrace, written by Tobias Waldekranz. - -* If you read my previous article, you might be interested in this talk I gave about [implementing the OpenState interface with eBPF][151], for stateful packet processing, at fosdem17. - -![](https://qmonnet.github.io/whirl-offload/img/icons/book.svg) - -### Documentation - -Once you managed to get a broad idea of what BPF is, you can put aside generic presentations and start diving into the documentation. Below are the most complete documents about BPF specifications and functioning. Pick the one you need and read them carefully! - -### About BPF - -* The **specification of BPF** (both classic and extended versions) can be found within the documentation of the Linux kernel, and in particular in file[linux/Documentation/networking/filter.txt][94]. The use of BPF as well as its internals are documented there. Also, this is where you can find **information about errors thrown by the verifier** when loading BPF code fails. Can be helpful to troubleshoot obscure error messages. - -* Also in the kernel tree, there is a document about **frequent Questions & Answers** on eBPF design in file [linux/Documentation/bpf/bpf_design_QA.txt][95]. - -* … But the kernel documentation is dense and not especially easy to read. If you look for a simple description of eBPF language, head for [its **summarized description**][96] on the IO Visor GitHub repository instead. - -* By the way, the IO Visor project gathered a lot of **resources about BPF**. Mostly, it is split between[the documentation directory][97] of its bcc repository, and the whole content of [the bpf-docs repository][98], both on GitHub. Note the existence of this excellent [BPF **reference guide**][99] containing a detailed description of BPF C and bcc Python helpers. - -* To hack with BPF, there are some essential **Linux manual pages**. The first one is [the `bpf(2)` man page][100] about the `bpf()` **system call**, which is used to manage BPF programs and maps from userspace. It also contains a description of BPF advanced features (program types, maps and so on). The second one is mostly addressed to people wanting to attach BPF programs to tc interface: it is [the `tc-bpf(8)` man page][101], which is a reference for **using BPF with tc**, and includes some example commands and samples of code. - -* Jesper Dangaard Brouer initiated an attempt to **update eBPF Linux documentation**, including **the different kinds of maps**. [He has a draft][102] to which contributions are welcome. Once ready, this document should be merged into the man pages and into kernel documentation. - -* The Cilium project also has an excellent [**BPF and XDP Reference Guide**][103], written by core eBPF developers, that should prove immensely useful to any eBPF developer. - -* David Miller has sent several enlightening emails about eBPF/XDP internals on the [xdp-newbies][152]mailing list. I could not find a link that gathers them at a single place, so here is a list: - * [bpf.h and you…][50] - - * [Contextually speaking…][51] - - * [BPF Verifier Overview][52] - - The last one is possibly the best existing summary about the verifier at this date. - -* Ferris Ellis started [a **blog post series about eBPF**][104]. As I write this paragraph, the first article is out, with some historical background and future expectations for eBPF. Next posts should be more technical, and look promising. - -* [A **list of BPF features per kernel version**][153] is available in bcc repository. Useful is you want to know the minimal kernel version that is required to run a given feature. I contributed and added the links to the commits that introduced each feature, so you can also easily access the commit logs from there. - -### About tc - -When using BPF for networking purposes in conjunction with tc, the Linux tool for **t**raffic **c**ontrol, one may wish to gather information about tc’s generic functioning. Here are a couple of resources about it. - -* It is difficult to find simple tutorials about **QoS on Linux**. The two links I have are long and quite dense, but if you can find the time to read it you will learn nearly everything there is to know about tc (nothing about BPF, though). There they are:  [_Traffic Control HOWTO_  (Martin A. Brown, 2006)][105], and the  [_Linux Advanced Routing & Traffic Control HOWTO_  (“LARTC”) (Bert Hubert & al., 2002)][106]. - -* **tc manual pages** may not be up-to-date on your system, since several of them have been added lately. If you cannot find the documentation for a particular queuing discipline (qdisc), class or filter, it may be worth checking the latest [manual pages for tc components][107]. - -* Some additional material can be found within the files of iproute2 package itself: the package contains [some documentation][108], including some files that helped me understand better [the functioning of **tc’s actions**][109]. - **Edit:** While still available from the Git history, these files have been deleted from iproute2 in October 2017. - -* Not exactly documentation: there was [a workshop about several tc features][110] (including filtering, BPF, tc offload, …) organized by Jamal Hadi Salim during the netdev 1.2 conference (October 2016). - -* Bonus information—If you use `tc` a lot, here are some good news: I [wrote a bash completion function][111] for this tool, and it should be shipped with package iproute2 coming with kernel version 4.6 and higher! - -### About XDP - -* Some [work-in-progress documentation (including specifications)][112] for XDP started by Jesper Dangaard Brouer, but meant to be a collaborative work. Under progress (September 2016): you should expect it to change, and maybe to be moved at some point (Jesper [called for contribution][113], if you feel like improving it). - -* The [BPF and XDP Reference Guide][114] from Cilium project… Well, the name says it all. - -### About P4 and BPF - -[P4][159] is a language used to specify the behavior of a switch. It can be compiled for a number of hardware or software targets. As you may have guessed, one of these targets is BPF… The support is only partial: some P4 features cannot be translated towards BPF, and in a similar way there are things that BPF can do but that would not be possible to express with P4\. Anyway, the documentation related to **P4 use with BPF** [used to be hidden in bcc repository][160]. This changed with P4_16 version, the p4c reference compiler including [a backend for eBPF][161]. - -![](https://qmonnet.github.io/whirl-offload/img/icons/flask.svg) - -### Tutorials - -Brendan Gregg has produced excellent **tutorials** intended for people who want to **use bcc tools** for tracing and monitoring events in the kernel. [The first tutorial about using bcc itself][162] comes with eleven steps (as of today) to understand how to use the existing tools, while [the one **intended for Python developers**][163] focuses on developing new tools, across seventeen “lessons”. - -Sasha Goldshtein also has some  [_**Linux Tracing Workshops Materials**_][164]  involving the use of several BPF tools for tracing. - -Another post by Jean-Tiare Le Bigot provides a detailed (and instructive!) example of [using perf and eBPF to setup a low-level tracer][165] for ping requests and replies - -Few tutorials exist for network-related eBPF use cases. There are some interesting documents, including an  _eBPF Offload Starting Guide_ , on the [Open NFP][166] platform operated by Netronome. Other than these, the talk from Jesper,  [_XDP for the Rest of Us_][167] , is probably one of the best ways to get started with XDP. - -![](https://qmonnet.github.io/whirl-offload/img/icons/gears.svg) - -### Examples - -It is always nice to have examples. To see how things really work. But BPF program samples are scattered across several projects, so I listed all the ones I know of. The examples do not always use the same helpers (for instance, tc and bcc both have their own set of helpers to make it easier to write BPF programs in C language). - -### From the kernel - -The kernel contains examples for most types of program: filters to bind to sockets or to tc interfaces, event tracing/monitoring, and even XDP. You can find these examples under the [linux/samples/bpf/][168]directory. - -Also do not forget to have a look to the logs related to the (git) commits that introduced a particular feature, they may contain some detailed example of the feature. - -### From package iproute2 - -The iproute2 package provide several examples as well. They are obviously oriented towards network programming, since the programs are to be attached to tc ingress or egress interfaces. The examples dwell under the [iproute2/examples/bpf/][169] directory. - -### From bcc set of tools - -Many examples are [provided with bcc][170]: - -* Some are networking example programs, under the associated directory. They include socket filters, tc filters, and a XDP program. - -* The `tracing` directory include a lot of example **tracing programs**. The tutorials mentioned earlier are based on these. These programs cover a wide range of event monitoring functions, and some of them are production-oriented. Note that on certain Linux distributions (at least for Debian, Ubuntu, Fedora, Arch Linux), these programs have been [packaged][115] and can be “easily” installed by typing e.g. `# apt install bcc-tools`, but as of this writing (and except for Arch Linux), this first requires to set up IO Visor’s own package repository. - -* There are also some examples **using Lua** as a different BPF back-end (that is, BPF programs are written with Lua instead of a subset of C, allowing to use the same language for front-end and back-end), in the third directory. - -### Manual pages - -While bcc is generally the easiest way to inject and run a BPF program in the kernel, attaching programs to tc interfaces can also be performed by the `tc` tool itself. So if you intend to **use BPF with tc**, you can find some example invocations in the [`tc-bpf(8)` manual page][171]. - -![](https://qmonnet.github.io/whirl-offload/img/icons/srcfile.svg) - -### The code - -Sometimes, BPF documentation or examples are not enough, and you may have no other solution that to display the code in your favorite text editor (which should be Vim of course) and to read it. Or you may want to hack into the code so as to patch or add features to the machine. So here are a few pointers to the relevant files, finding the functions you want is up to you! - -### BPF code in the kernel - -* The file [linux/include/linux/bpf.h][116] and its counterpart [linux/include/uapi/bpf.h][117] contain **definitions** related to eBPF, to be used respectively in the kernel and to interface with userspace programs. - -* On the same pattern, files [linux/include/linux/filter.h][118] and [linux/include/uapi/filter.h][119] contain information used to **run the BPF programs**. - -* The **main pieces of code** related to BPF are under [linux/kernel/bpf/][120] directory. **The different operations permitted by the system call**, such as program loading or map management, are implemented in file `syscall.c`, while `core.c` contains the **interpreter**. The other files have self-explanatory names: `verifier.c` contains the **verifier** (no kidding), `arraymap.c` the code used to interact with **maps** of type array, and so on. - -* The **helpers**, as well as several functions related to networking (with tc, XDP…) and available to the user, are implemented in [linux/net/core/filter.c][121]. It also contains the code to migrate cBPF bytecode to eBPF (since all cBPF programs are now translated to eBPF in the kernel before being run). - -* The **JIT compilers** are under the directory of their respective architectures, such as file[linux/arch/x86/net/bpf_jit_comp.c][122] for x86. - -* You will find the code related to **the BPF components of tc** in the [linux/net/sched/][123] directory, and in particular in files `act_bpf.c` (action) and `cls_bpf.c` (filter). - -* I have not hacked with **event tracing** in BPF, so I do not really know about the hooks for such programs. There is some stuff in [linux/kernel/trace/bpf_trace.c][124]. If you are interested in this and want to know more, you may dig on the side of Brendan Gregg’s presentations or blog posts. - -* Nor have I used **seccomp-BPF**. But the code is in [linux/kernel/seccomp.c][125], and some example use cases can be found in [linux/tools/testing/selftests/seccomp/seccomp_bpf.c][126]. - -### XDP hooks code - -Once loaded into the in-kernel BPF virtual machine, **XDP** programs are hooked from userspace into the kernel network path thanks to a Netlink command. On reception, the function `dev_change_xdp_fd()` in file [linux/net/core/dev.c][172] is called and sets a XDP hook. Such hooks are located in the drivers of supported NICs. For example, the mlx4 driver used for some Mellanox hardware has hooks implemented in files under the [drivers/net/ethernet/mellanox/mlx4/][173] directory. File en_netdev.c receives Netlink commands and calls `mlx4_xdp_set()`, which in turns calls for instance `mlx4_en_process_rx_cq()` (for the RX side) implemented in file en_rx.c. - -### BPF logic in bcc - -One can find the code for the **bcc** set of tools [on the bcc GitHub repository][174]. The **Python code**, including the `BPF` class, is initiated in file [bcc/src/python/bcc/__init__.py][175]. But most of the interesting stuff—to my opinion—such as loading the BPF program into the kernel, happens [in the libbcc **C library**][176]. - -### Code to manage BPF with tc - -The code related to BPF **in tc** comes with the iproute2 package, of course. Some of it is under the[iproute2/tc/][177] directory. The files f_bpf.c and m_bpf.c (and e_bpf.c) are used respectively to handle BPF filters and actions (and tc `exec` command, whatever this may be). File q_clsact.c defines the `clsact` qdisc especially created for BPF. But **most of the BPF userspace logic** is implemented in[iproute2/lib/bpf.c][178] library, so this is probably where you should head to if you want to mess up with BPF and tc (it was moved from file iproute2/tc/tc_bpf.c, where you may find the same code in older versions of the package). - -### BPF utilities - -The kernel also ships the sources of three tools (`bpf_asm.c`, `bpf_dbg.c`, `bpf_jit_disasm.c`) related to BPF, under the [linux/tools/net/][179] or [linux/tools/bpf/][180] directory depending on your version: - -* `bpf_asm` is a minimal cBPF assembler. - -* `bpf_dbg` is a small debugger for cBPF programs. - -* `bpf_jit_disasm` is generic for both BPF flavors and could be highly useful for JIT debugging. - -* `bpftool` is a generic utility written by Jakub Kicinski, and that can be used to interact with eBPF programs and maps from userspace, for example to show, dump, pin programs, or to show, create, pin, update, delete maps. - -Read the comments at the top of the source files to get an overview of their usage. - -### Other interesting chunks - -If you are interested the use of less common languages with BPF, bcc contains [a **P4 compiler** for BPF targets][181] as well as [a **Lua front-end**][182] that can be used as alternatives to the C subset and (in the case of Lua) to the Python tools. - -### LLVM backend - -The BPF backend used by clang / LLVM for compiling C into eBPF was added to the LLVM sources in[this commit][183] (and can also be accessed on [the GitHub mirror][184]). - -### Running in userspace - -As far as I know there are at least two eBPF userspace implementations. The first one, [uBPF][185], is written in C. It contains an interpreter, a JIT compiler for x86_64 architecture, an assembler and a disassembler. - -The code of uBPF seems to have been reused to produce a [generic implementation][186], that claims to support FreeBSD kernel, FreeBSD userspace, Linux kernel, Linux userspace and MacOSX userspace. It is used for the [BPF extension module for VALE switch][187]. - -The other userspace implementation is my own work: [rbpf][188], based on uBPF, but written in Rust. The interpreter and JIT-compiler work (both under Linux, only the interpreter for MacOSX and Windows), there may be more in the future. - -### Commit logs - -As stated earlier, do not hesitate to have a look at the commit log that introduced a particular BPF feature if you want to have more information about it. You can search the logs in many places, such as on [git.kernel.org][189], [on GitHub][190], or on your local repository if you have cloned it. If you are not familiar with git, try things like `git blame ` to see what commit introduced a particular line of code, then `git show ` to have details (or search by keyword in `git log` results, but this may be tedious). See also [the list of eBPF features per kernel version][191] on bcc repository, that links to relevant commits. - -![](https://qmonnet.github.io/whirl-offload/img/icons/wand.svg) - -### Troubleshooting - -The enthusiasm about eBPF is quite recent, and so far I have not found a lot of resources intending to help with troubleshooting. So here are the few I have, augmented with my own recollection of pitfalls encountered while working with BPF. - -### Errors at compilation time - -* Make sure you have a recent enough version of the Linux kernel (see also [this document][127]). - -* If you compiled the kernel yourself: make sure you installed correctly all components, including kernel image, headers and libc. - -* When using the `bcc` shell function provided by `tc-bpf` man page (to compile C code into BPF): I once had to add includes to the header for the clang call: - - ``` - __bcc() { - clang -O2 -I "/usr/src/linux-headers-$(uname -r)/include/" \ - -I "/usr/src/linux-headers-$(uname -r)/arch/x86/include/" \ - -emit-llvm -c $1 -o - | \ - llc -march=bpf -filetype=obj -o "`basename $1 .c`.o" - } - - ``` - - (seems fixed as of today). - -* For other problems with `bcc`, do not forget to have a look at [the FAQ][128] of the tool set. - -* If you downloaded the examples from the iproute2 package in a version that does not exactly match your kernel, some errors can be triggered by the headers included in the files. The example snippets indeed assume that the same version of iproute2 package and kernel headers are installed on the system. If this is not the case, download the correct version of iproute2, or edit the path of included files in the examples to point to the headers included in iproute2 (some problems may or may not occur at runtime, depending on the features in use). - -### Errors at load and run time - -* To load a program with tc, make sure you use a tc binary coming from an iproute2 version equivalent to the kernel in use. - -* To load a program with bcc, make sure you have bcc installed on the system (just downloading the sources to run the Python script is not enough). - -* With tc, if the BPF program does not return the expected values, check that you called it in the correct fashion: filter, or action, or filter with “direct-action” mode. - -* With tc still, note that actions cannot be attached directly to qdiscs or interfaces without the use of a filter. - -* The errors thrown by the in-kernel verifier may be hard to interpret. [The kernel documentation][129]may help, so may [the reference guide][130] or, as a last resort, the source code (see above) (good luck!). For this kind of errors it is also important to keep in mind that the verifier  _does not run_  the program. If you get an error about an invalid memory access or about uninitialized data, it does not mean that these problems actually occurred (or sometimes, that they can possibly occur at all). It means that your program is written in such a way that the verifier estimates that such errors could happen, and therefore it rejects the program. - -* Note that `tc` tool has a verbose mode, and that it works well with BPF: try appending `verbose`at the end of your command line. - -* bcc also has verbose options: the `BPF` class has a `debug` argument that can take any combination of the three flags `DEBUG_LLVM_IR`, `DEBUG_BPF` and `DEBUG_PREPROCESSOR` (see details in [the source file][131]). It even embeds [some facilities to print output messages][132] for debugging the code. - -* LLVM v4.0+ [embeds a disassembler][133] for eBPF programs. So if you compile your program with clang, adding the `-g` flag for compiling enables you to later dump your program in the rather human-friendly format used by the kernel verifier. To proceed to the dump, use: - - ``` - $ llvm-objdump -S -no-show-raw-insn bpf_program.o - - ``` - -* Working with maps? You want to have a look at [bpf-map][134], a very userful tool in Go created for the Cilium project, that can be used to dump the contents of kernel eBPF maps. There also exists [a clone][135] in Rust. - -* There is an old [`bpf` tag on **StackOverflow**][136], but as of this writing it has been hardly used—ever (and there is nearly nothing related to the new eBPF version). If you are a reader from the Future though, you may want to check whether there has been more activity on this side. - -![](https://qmonnet.github.io/whirl-offload/img/icons/zoomin.svg) - -### And still more! - -* In case you would like to easily **test XDP**, there is [a Vagrant setup][137] available. You can also **test bcc**[in a Docker container][138]. - -* Wondering where the **development and activities** around BPF occur? Well, the kernel patches always end up [on the netdev mailing list][139] (related to the Linux kernel networking stack development): search for “BPF” or “XDP” keywords. Since April 2017, there is also [a mailing list specially dedicated to XDP programming][140] (both for architecture or for asking for help). Many discussions and debates also occur [on the IO Visor mailing list][141], since BPF is at the heart of the project. If you only want to keep informed from time to time, there is also an [@IOVisor Twitter account][142]. - -And come back on this blog from time to time to see if they are new articles [about BPF][192]! - - _Special thanks to Daniel Borkmann for the numerous [additional documents][154] he pointed to me so that I could complete this collection._ - --------------------------------------------------------------------------------- - -via: https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/ - -作者:[Quentin Monnet ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://qmonnet.github.io/whirl-offload/about/ -[1]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-bpf -[2]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-xdp -[3]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-other-components-related-or-based-on-ebpf -[4]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-bpf-1 -[5]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-tc -[6]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-xdp-1 -[7]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-p4-and-bpf -[8]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#from-the-kernel -[9]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#from-package-iproute2 -[10]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#from-bcc-set-of-tools -[11]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#manual-pages -[12]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#bpf-code-in-the-kernel -[13]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#xdp-hooks-code -[14]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#bpf-logic-in-bcc -[15]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#code-to-manage-bpf-with-tc -[16]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#bpf-utilities -[17]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#other-interesting-chunks -[18]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#llvm-backend -[19]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#running-in-userspace -[20]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#commit-logs -[21]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#errors-at-compilation-time -[22]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#errors-at-load-and-run-time -[23]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#generic-presentations -[24]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#documentation -[25]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#tutorials -[26]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#examples -[27]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#the-code -[28]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#troubleshooting -[29]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#and-still-more -[30]:http://netdevconf.org/1.2/session.html?daniel-borkmann -[31]:http://netdevconf.org/1.2/slides/oct5/07_tcws_daniel_borkmann_2016_tcws.pdf -[32]:http://netdevconf.org/1.2/session.html?jamal-tc-workshop -[33]:http://www.netdevconf.org/1.1/proceedings/slides/borkmann-tc-classifier-cls-bpf.pdf -[34]:http://www.netdevconf.org/1.1/proceedings/papers/On-getting-tc-classifier-fully-programmable-with-cls-bpf.pdf -[35]:https://archive.fosdem.org/2016/schedule/event/ebpf/attachments/slides/1159/export/events/attachments/ebpf/slides/1159/ebpf.pdf -[36]:https://fosdem.org/2017/schedule/event/ebpf_xdp/ -[37]:http://people.netfilter.org/hawk/presentations/xdp2016/xdp_intro_and_use_cases_sep2016.pdf -[38]:http://netdevconf.org/1.2/session.html?jesper-performance-workshop -[39]:http://people.netfilter.org/hawk/presentations/OpenSourceDays2017/XDP_DDoS_protecting_osd2017.pdf -[40]:http://people.netfilter.org/hawk/presentations/MM-summit2017/MM-summit2017-JesperBrouer.pdf -[41]:http://netdevconf.org/2.1/session.html?gospodarek -[42]:http://jvns.ca/blog/2017/04/07/xdp-bpf-tutorial/ -[43]:http://www.slideshare.net/ThomasGraf5/clium-container-networking-with-bpf-xdp -[44]:http://www.slideshare.net/Docker/cilium-bpf-xdp-for-containers-66969823 -[45]:https://www.youtube.com/watch?v=TnJF7ht3ZYc&list=PLkA60AVN3hh8oPas3cq2VA9xB7WazcIgs -[46]:http://www.slideshare.net/ThomasGraf5/cilium-fast-ipv6-container-networking-with-bpf-and-xdp -[47]:https://fosdem.org/2017/schedule/event/cilium/ -[48]:http://openvswitch.org/support/ovscon2016/7/1120-tu.pdf -[49]:http://openvswitch.org/support/ovscon2016/7/1245-bertrone.pdf -[50]:https://www.spinics.net/lists/xdp-newbies/msg00179.html -[51]:https://www.spinics.net/lists/xdp-newbies/msg00181.html -[52]:https://www.spinics.net/lists/xdp-newbies/msg00185.html -[53]:http://schd.ws/hosted_files/ossna2017/da/BPFandXDP.pdf -[54]:https://speakerdeck.com/tuxology/the-bsd-packet-filter -[55]:http://www.slideshare.net/brendangregg/bpf-tracing-and-more -[56]:http://fr.slideshare.net/brendangregg/linux-bpf-superpowers -[57]:https://www.socallinuxexpo.org/sites/default/files/presentations/Room%20211%20-%20IOVisor%20-%20SCaLE%2014x.pdf -[58]:https://events.linuxfoundation.org/sites/events/files/slides/ebpf_on_the_mainframe_lcon_2015.pdf -[59]:https://events.linuxfoundation.org/sites/events/files/slides/tracing-linux-ezannoni-linuxcon-ja-2015_0.pdf -[60]:https://events.linuxfoundation.org/sites/events/files/slides/bpf_collabsummit_2015feb20.pdf -[61]:https://lwn.net/Articles/603983/ -[62]:http://www.slideshare.net/vh21/meet-cutebetweenebpfandtracing -[63]:http://www.slideshare.net/vh21/linux-kernel-tracing -[64]:http://www.slideshare.net/ThomasGraf5/linux-networking-explained -[65]:http://www.slideshare.net/ThomasGraf5/linuxcon-2015-linux-kernel-networking-walkthrough -[66]:http://www.tcpdump.org/papers/bpf-usenix93.pdf -[67]:http://www.gsp.com/cgi-bin/man.cgi?topic=bpf -[68]:http://borkmann.ch/talks/2013_devconf.pdf -[69]:http://borkmann.ch/talks/2014_devconf.pdf -[70]:https://blog.cloudflare.com/introducing-the-bpf-tools/ -[71]:http://biot.com/capstats/bpf.html -[72]:https://www.iovisor.org/technology/xdp -[73]:https://github.com/iovisor/bpf-docs/raw/master/Express_Data_Path.pdf -[74]:https://events.linuxfoundation.org/sites/events/files/slides/iovisor-lc-bof-2016.pdf -[75]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-xdp-1 -[76]:http://netdevconf.org/1.2/session.html?herbert-xdp-workshop -[77]:https://schd.ws/hosted_files/2016p4workshop/1d/Intel%20Fastabend-P4%20on%20the%20Edge.pdf -[78]:https://ovsorbit.benpfaff.org/#e11 -[79]:http://open-nfp.org/media/pdfs/Open_NFP_P4_EBPF_Linux_TC_Offload_FINAL.pdf -[80]:https://opensource.googleblog.com/2016/11/cilium-networking-and-security.html -[81]:https://ovsorbit.benpfaff.org/ -[82]:http://blog.ipspace.net/2016/10/fast-linux-packet-forwarding-with.html -[83]:http://netdevconf.org/2.1/session.html?bertin -[84]:http://netdevconf.org/2.1/session.html?zhou -[85]:http://www.slideshare.net/IOVisor/ceth-for-xdp-linux-meetup-santa-clara-july-2016 -[86]:http://info.iet.unipi.it/~luigi/vale/ -[87]:https://github.com/YutaroHayakawa/vale-bpf -[88]:https://www.stamus-networks.com/2016/09/28/suricata-bypass-feature/ -[89]:http://netdevconf.org/1.2/slides/oct6/10_suricata_ebpf.pdf -[90]:https://www.slideshare.net/ennael/kernel-recipes-2017-ebpf-and-xdp-eric-leblond -[91]:https://github.com/iovisor/bpf-docs/blob/master/university/sigcomm-ccr-InKev-2016.pdf -[92]:https://fosdem.org/2017/schedule/event/go_bpf/ -[93]:https://wkz.github.io/ply/ -[94]:https://www.kernel.org/doc/Documentation/networking/filter.txt -[95]:https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/Documentation/bpf/bpf_design_QA.txt?id=2e39748a4231a893f057567e9b880ab34ea47aef -[96]:https://github.com/iovisor/bpf-docs/blob/master/eBPF.md -[97]:https://github.com/iovisor/bcc/tree/master/docs -[98]:https://github.com/iovisor/bpf-docs/ -[99]:https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md -[100]:http://man7.org/linux/man-pages/man2/bpf.2.html -[101]:http://man7.org/linux/man-pages/man8/tc-bpf.8.html -[102]:https://prototype-kernel.readthedocs.io/en/latest/bpf/index.html -[103]:http://docs.cilium.io/en/latest/bpf/ -[104]:https://ferrisellis.com/tags/ebpf/ -[105]:http://linux-ip.net/articles/Traffic-Control-HOWTO/ -[106]:http://lartc.org/lartc.html -[107]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/man/man8 -[108]:https://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git/tree/doc?h=v4.13.0 -[109]:https://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git/tree/doc/actions?h=v4.13.0 -[110]:http://netdevconf.org/1.2/session.html?jamal-tc-workshop -[111]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/commit/bash-completion/tc?id=27d44f3a8a4708bcc99995a4d9b6fe6f81e3e15b -[112]:https://prototype-kernel.readthedocs.io/en/latest/networking/XDP/index.html -[113]:https://marc.info/?l=linux-netdev&m=147436253625672 -[114]:http://docs.cilium.io/en/latest/bpf/ -[115]:https://github.com/iovisor/bcc/blob/master/INSTALL.md -[116]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/bpf.h -[117]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/bpf.h -[118]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/filter.h -[119]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/filter.h -[120]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/bpf -[121]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/core/filter.c -[122]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/x86/net/bpf_jit_comp.c -[123]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/sched -[124]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/trace/bpf_trace.c -[125]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/seccomp.c -[126]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/seccomp/seccomp_bpf.c -[127]:https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md -[128]:https://github.com/iovisor/bcc/blob/master/FAQ.txt -[129]:https://www.kernel.org/doc/Documentation/networking/filter.txt -[130]:https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md -[131]:https://github.com/iovisor/bcc/blob/master/src/python/bcc/__init__.py -[132]:https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md#output -[133]:https://www.spinics.net/lists/netdev/msg406926.html -[134]:https://github.com/cilium/bpf-map -[135]:https://github.com/badboy/bpf-map -[136]:https://stackoverflow.com/questions/tagged/bpf -[137]:https://github.com/iovisor/xdp-vagrant -[138]:https://github.com/zlim/bcc-docker -[139]:http://lists.openwall.net/netdev/ -[140]:http://vger.kernel.org/vger-lists.html#xdp-newbies -[141]:http://lists.iovisor.org/pipermail/iovisor-dev/ -[142]:https://twitter.com/IOVisor -[143]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#what-is-bpf -[144]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#dive-into-the-bytecode -[145]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#resources -[146]:https://github.com/qmonnet/whirl-offload/commits/gh-pages/_posts/2016-09-01-dive-into-bpf.md -[147]:http://netdevconf.org/1.2/session.html?jakub-kicinski -[148]:http://www.slideshare.net/IOVisor/express-data-path-linux-meetup-santa-clara-july-2016 -[149]:https://cdn.shopify.com/s/files/1/0177/9886/files/phv2017-gbertin.pdf -[150]:https://github.com/cilium/cilium -[151]:https://fosdem.org/2017/schedule/event/stateful_ebpf/ -[152]:http://vger.kernel.org/vger-lists.html#xdp-newbies -[153]:https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md -[154]:https://github.com/qmonnet/whirl-offload/commit/d694f8081ba00e686e34f86d5ee76abeb4d0e429 -[155]:http://openvswitch.org/pipermail/dev/2014-October/047421.html -[156]:https://qmonnet.github.io/whirl-offload/2016/07/15/beba-research-project/ -[157]:https://www.iovisor.org/resources/blog -[158]:http://www.brendangregg.com/blog/2016-03-05/linux-bpf-superpowers.html -[159]:http://p4.org/ -[160]:https://github.com/iovisor/bcc/tree/master/src/cc/frontends/p4 -[161]:https://github.com/p4lang/p4c/blob/master/backends/ebpf/README.md -[162]:https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md -[163]:https://github.com/iovisor/bcc/blob/master/docs/tutorial_bcc_python_developer.md -[164]:https://github.com/goldshtn/linux-tracing-workshop -[165]:https://blog.yadutaf.fr/2017/07/28/tracing-a-packet-journey-using-linux-tracepoints-perf-ebpf/ -[166]:https://open-nfp.org/dataplanes-ebpf/technical-papers/ -[167]:http://netdevconf.org/2.1/session.html?gospodarek -[168]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/samples/bpf -[169]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/examples/bpf -[170]:https://github.com/iovisor/bcc/tree/master/examples -[171]:http://man7.org/linux/man-pages/man8/tc-bpf.8.html -[172]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/core/dev.c -[173]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/mellanox/mlx4/ -[174]:https://github.com/iovisor/bcc/ -[175]:https://github.com/iovisor/bcc/blob/master/src/python/bcc/__init__.py -[176]:https://github.com/iovisor/bcc/blob/master/src/cc/libbpf.c -[177]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/tc -[178]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/lib/bpf.c -[179]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/tools/net -[180]:https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/tools/bpf -[181]:https://github.com/iovisor/bcc/tree/master/src/cc/frontends/p4/compiler -[182]:https://github.com/iovisor/bcc/tree/master/src/lua -[183]:https://reviews.llvm.org/D6494 -[184]:https://github.com/llvm-mirror/llvm/commit/4fe85c75482f9d11c5a1f92a1863ce30afad8d0d -[185]:https://github.com/iovisor/ubpf/ -[186]:https://github.com/YutaroHayakawa/generic-ebpf -[187]:https://github.com/YutaroHayakawa/vale-bpf -[188]:https://github.com/qmonnet/rbpf -[189]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git -[190]:https://github.com/torvalds/linux -[191]:https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md -[192]:https://qmonnet.github.io/whirl-offload/categories/#BPF diff --git a/sources/tech/20171107 GitHub welcomes all CI tools.md b/sources/tech/20171107 GitHub welcomes all CI tools.md deleted file mode 100644 index 7bef351bd6..0000000000 --- a/sources/tech/20171107 GitHub welcomes all CI tools.md +++ /dev/null @@ -1,95 +0,0 @@ -translating---geekpi - -GitHub welcomes all CI tools -==================== - - -[![GitHub and all CI tools](https://user-images.githubusercontent.com/29592817/32509084-2d52c56c-c3a1-11e7-8c49-901f0f601faf.png)][11] - -Continuous Integration ([CI][12]) tools help you stick to your team's quality standards by running tests every time you push a new commit and [reporting the results][13] to a pull request. Combined with continuous delivery ([CD][14]) tools, you can also test your code on multiple configurations, run additional performance tests, and automate every step [until production][15]. - -There are several CI and CD tools that [integrate with GitHub][16], some of which you can install in a few clicks from [GitHub Marketplace][17]. With so many options, you can pick the best tool for the job—even if it's not the one that comes pre-integrated with your system. - -The tools that will work best for you depends on many factors, including: - -* Programming language and application architecture - -* Operating system and browsers you plan to support - -* Your team's experience and skills - -* Scaling capabilities and plans for growth - -* Geographic distribution of dependent systems and the people who use them - -* Packaging and delivery goals - -Of course, it isn't possible to optimize your CI tool for all of these scenarios. The people who build them have to choose which use cases to serve best—and when to prioritize complexity over simplicity. For example, if you like to test small applications written in a particular programming language for one platform, you won't need the complexity of a tool that tests embedded software controllers on dozens of platforms with a broad mix of programming languages and frameworks. - -If you need a little inspiration for which CI tool might work best, take a look at [popular GitHub projects][18]. Many show the status of their integrated CI/CD tools as badges in their README.md. We've also analyzed the use of CI tools across more than 50 million repositories in the GitHub community, and found a lot of variety. The following diagram shows the relative percentage of the top 10 CI tools used with GitHub.com, based on the most used [commit status contexts][19] used within our pull requests. - - _Our analysis also showed that many teams use more than one CI tool in their projects, allowing them to emphasize what each tool does best._ - - [![Top 10 CI systems used with GitHub.com based on most used commit status contexts](https://user-images.githubusercontent.com/7321362/32575895-ea563032-c49a-11e7-9581-e05ec882658b.png)][20] - -If you'd like to check them out, here are the top 10 tools teams use: - -* [Travis CI][1] - -* [Circle CI][2] - -* [Jenkins][3] - -* [AppVeyor][4] - -* [CodeShip][5] - -* [Drone][6] - -* [Semaphore CI][7] - -* [Buildkite][8] - -* [Wercker][9] - -* [TeamCity][10] - -It's tempting to just pick the default, pre-integrated tool without taking the time to research and choose the best one for the job, but there are plenty of [excellent choices][21] built for your specific use cases. And if you change your mind later, no problem. When you choose the best tool for a specific situation, you're guaranteeing tailored performance and the freedom of interchangability when it no longer fits. - -Ready to see how CI tools can fit into your workflow? - -[Browse GitHub Marketplace][22] - --------------------------------------------------------------------------------- - -via: https://github.com/blog/2463-github-welcomes-all-ci-tools - -作者:[jonico ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://github.com/jonico -[1]:https://travis-ci.org/ -[2]:https://circleci.com/ -[3]:https://jenkins.io/ -[4]:https://www.appveyor.com/ -[5]:https://codeship.com/ -[6]:http://try.drone.io/ -[7]:https://semaphoreci.com/ -[8]:https://buildkite.com/ -[9]:http://www.wercker.com/ -[10]:https://www.jetbrains.com/teamcity/ -[11]:https://user-images.githubusercontent.com/29592817/32509084-2d52c56c-c3a1-11e7-8c49-901f0f601faf.png -[12]:https://en.wikipedia.org/wiki/Continuous_integration -[13]:https://github.com/blog/2051-protected-branches-and-required-status-checks -[14]:https://en.wikipedia.org/wiki/Continuous_delivery -[15]:https://developer.github.com/changes/2014-01-09-preview-the-new-deployments-api/ -[16]:https://github.com/works-with/category/continuous-integration -[17]:https://github.com/marketplace/category/continuous-integration -[18]:https://github.com/explore?trending=repositories#trending -[19]:https://developer.github.com/v3/repos/statuses/ -[20]:https://user-images.githubusercontent.com/7321362/32575895-ea563032-c49a-11e7-9581-e05ec882658b.png -[21]:https://github.com/works-with/category/continuous-integration -[22]:https://github.com/marketplace/category/continuous-integration diff --git a/sources/tech/20171112 Love Your Bugs.md b/sources/tech/20171112 Love Your Bugs.md deleted file mode 100644 index bf79f27cf7..0000000000 --- a/sources/tech/20171112 Love Your Bugs.md +++ /dev/null @@ -1,311 +0,0 @@ -Love Your Bugs -============================================================ - -In early October I gave a keynote at [Python Brasil][1] in Belo Horizonte. Here is an aspirational and lightly edited transcript of the talk. There is also a video available [here][2]. - -### I love bugs - -I’m currently a senior engineer at [Pilot.com][3], working on automating bookkeeping for startups. Before that, I worked for [Dropbox][4] on the desktop client team, and I’ll have a few stories about my work there. Earlier, I was a facilitator at the [Recurse Center][5], a writers retreat for programmers in NYC. I studied astrophysics in college and worked in finance for a few years before becoming an engineer. - -But none of that is really important to remember – the only thing you need to know about me is that I love bugs. I love bugs because they’re entertaining. They’re dramatic. The investigation of a great bug can be full of twists and turns. A great bug is like a good joke or a riddle – you’re expecting one outcome, but the result veers off in another direction. - -Over the course of this talk I’m going to tell you about some bugs that I have loved, explain why I love bugs so much, and then convince you that you should love bugs too. - -### Bug #1 - -Ok, straight into bug #1\. This is a bug that I encountered while working at Dropbox. As you may know, Dropbox is a utility that syncs your files from one computer to the cloud and to your other computers. - - - -``` - +--------------+ +---------------+ - | | | | - | METASERVER | | BLOCKSERVER | - | | | | - +-+--+---------+ +---------+-----+ - ^ | ^ - | | | - | | +----------+ | - | +---> | | | - | | CLIENT +--------+ - +--------+ | - +----------+ -``` - - -Here’s a vastly simplified diagram of Dropbox’s architecture. The desktop client runs on your local computer listening for changes in the file system. When it notices a changed file, it reads the file, then hashes the contents in 4MB blocks. These blocks are stored in the backend in a giant key-value store that we call blockserver. The key is the digest of the hashed contents, and the values are the contents themselves. - -Of course, we want to avoid uploading the same block multiple times. You can imagine that if you’re writing a document, you’re probably mostly changing the end – we don’t want to upload the beginning over and over. So before uploading a block to the blockserver the client talks to a different server that’s responsible for managing metadata and permissions, among other things. The client asks metaserver whether it needs the block or has seen it before. The “metaserver” responds with whether or not each block needs to be uploaded. - -So the request and response look roughly like this: The client says, “I have a changed file made up of blocks with hashes `'abcd,deef,efgh'`”. The server responds, “I have those first two, but upload the third.” Then the client sends the block up to the blockserver. - - -``` - +--------------+ +---------------+ - | | | | - | METASERVER | | BLOCKSERVER | - | | | | - +-+--+---------+ +---------+-----+ - ^ | ^ - | | 'ok, ok, need' | -'abcd,deef,efgh' | | +----------+ | efgh: [contents] - | +---> | | | - | | CLIENT +--------+ - +--------+ | - +----------+ -``` - - - -That’s the setup. So here’s the bug. - - - -``` - +--------------+ - | | - | METASERVER | - | | - +-+--+---------+ - ^ | - | | '???' -'abcdldeef,efgh' | | +----------+ - ^ | +---> | | - ^ | | CLIENT + - +--------+ | - +----------+ -``` - -Sometimes the client would make a weird request: each hash value should have been sixteen characters long, but instead it was thirty-three characters long – twice as many plus one. The server wouldn’t know what to do with this and would throw an exception. We’d see this exception get reported, and we’d go look at the log files from the desktop client, and really weird stuff would be going on – the client’s local database had gotten corrupted, or python would be throwing MemoryErrors, and none of it would make sense. - -If you’ve never seen this problem before, it’s totally mystifying. But once you’d seen it once, you can recognize it every time thereafter. Here’s a hint: the middle character of each 33-character string that we’d often see instead of a comma was `l`. These are the other characters we’d see in the middle position: - - -``` -l \x0c < $ ( . - -``` - -The ordinal value for an ascii comma – `,` – is 44\. The ordinal value for `l` is 108\. In binary, here’s how those two are represented: - -``` -bin(ord(',')): 0101100 -bin(ord('l')): 1101100 -``` - -You’ll notice that an `l` is exactly one bit away from a comma. And herein lies your problem: a bitflip. One bit of memory that the desktop client is using has gotten corrupted, and now the desktop client is sending a request to the server that is garbage. - -And here are the other characters we’d frequently see instead of the comma when a different bit had been flipped. - - - -``` -, : 0101100 -l : 1101100 -\x0c : 0001100 -< : 0111100 -$ : 0100100 -( : 0101000 -. : 0101110 -- : 0101101 -``` - - -### Bitflips are real! - -I love this bug because it shows that bitflips are a real thing that can happen, not just a theoretical concern. In fact, there are some domains where they’re more common than others. One such domain is if you’re getting requests from users with low-end or old hardware, which is true for a lot of laptops running Dropbox. Another domain with lots of bitflips is outer space – there’s no atmosphere in space to protect your memory from energetic particles and radiation, so bitflips are pretty common. - -You probably really care about correctness in space – your code might be keeping astronauts alive on the ISS, for example, but even if it’s not mission-critical, it’s hard to do software updates to space. If you really need your application to defend against bitflips, there are a variety of hardware & software approaches you can take, and there’s a [very interesting talk][6] by Katie Betchold about this. - -Dropbox in this context doesn’t really need to protect against bitflips. The machine that is corrupting memory is a user’s machine, so we can detect if the bitflip happens to fall in the comma – but if it’s in a different character we don’t necessarily know it, and if the bitflip is in the actual file data read off of disk, then we have no idea. There’s a pretty limited set of places where we could address this, and instead we decide to basically silence the exception and move on. Often this kind of bug resolves after the client restarts. - -### Unlikely bugs aren’t impossible - -This is one of my favorite bugs for a couple of reasons. The first is that it’s a reminder of the difference between unlikely and impossible. At sufficient scale, unlikely events start to happen at a noticable rate. - -### Social bugs - -My second favorite thing about this bug is that it’s a tremendously social one. This bug can crop up anywhere that the desktop client talks to the server, which is a lot of different endpoints and components in the system. This meant that a lot of different engineers at Dropbox would see versions of the bug. The first time you see it, you can  _really_  scratch your head, but after that it’s easy to diagnose, and the investigation is really quick: you look at the middle character and see if it’s an `l`. - -### Cultural differences - -One interesting side-effect of this bug was that it exposed a cultural difference between the server and client teams. Occasionally this bug would be spotted by a member of the server team and investigated from there. If one of your  _servers_  is flipping bits, that’s probably not random chance – it’s probably memory corruption, and you need to find the affected machine and get it out of the pool as fast as possible or you risk corrupting a lot of user data. That’s an incident, and you need to respond quickly. But if the user’s machine is corrupting data, there’s not a lot you can do. - -### Share your bugs - -So if you’re investigating a confusing bug, especially one in a big system, don’t forget to talk to people about it. Maybe your colleagues have seen a bug shaped like this one before. If they have, you might save a lot of time. And if they haven’t, don’t forget to tell people about the solution once you’ve figured it out – write it up or tell the story in your team meeting. Then the next time your teams hits something similar, you’ll all be more prepared. - -### How bugs can help you learn - -### Recurse Center - -Before I joined Dropbox, I worked for the Recurse Center. The idea behind RC is that it’s a community of self-directed learners spending time together getting better as programmers. That is the full extent of the structure of RC: there’s no curriculum or assignments or deadlines. The only scoping is a shared goal of getting better as a programmer. We’d see people come to participate in the program who had gotten CS degrees but didn’t feel like they had a solid handle on practical programming, or people who had been writing Java for ten years and wanted to learn Clojure or Haskell, and many other profiles as well. - -My job there was as a facilitator, helping people make the most of the lack of structure and providing guidance based on what we’d learned from earlier participants. So my colleagues and I were very interested in the best techniques for learning for self-motivated adults. - -### Deliberate Practice - -There’s a lot of different research in this space, and one of the ones I think is most interesting is the idea of deliberate practice. Deliberate practice is an attempt to explain the difference in performance between experts & amateurs. And the guiding principle here is that if you look just at innate characteristics – genetic or otherwise – they don’t go very far towards explaining the difference in performance. So the researchers, originally Ericsson, Krampe, and Tesch-Romer, set out to discover what did explain the difference. And what they settled on was time spent in deliberate practice. - -Deliberate practice is pretty narrow in their definition: it’s not work for pay, and it’s not playing for fun. You have to be operating on the edge of your ability, doing a project appropriate for your skill level (not so easy that you don’t learn anything and not so hard that you don’t make any progress). You also have to get immediate feedback on whether or not you’ve done the thing correctly. - -This is really exciting, because it’s a framework for how to build expertise. But the challenge is that as programmers this is really hard advice to apply. It’s hard to know whether you’re operating at the edge of your ability. Immediate corrective feedback is very rare – in some cases you’re lucky to get feedback ever, and in other cases maybe it takes months. You can get quick feedback on small things in the REPL and so on, but if you’re making a design decision or picking a technology, you’re not going to get feedback on those things for quite a long time. - -But one category of programming where deliberate practice is a useful model is debugging. If you wrote code, then you had a mental model of how it worked when you wrote it. But your code has a bug, so your mental model isn’t quite right. By definition you’re on the boundary of your understanding – so, great! You’re about to learn something new. And if you can reproduce the bug, that’s a rare case where you can get immediate feedback on whether or not your fix is correct. - -A bug like this might teach you something small about your program, or you might learn something larger about the system your code is running in. Now I’ve got a story for you about a bug like that. - -### Bug #2 - -This bug also one that I encountered at Dropbox. At the time, I was investigating why some desktop client weren’t sending logs as consistently as we expected. I’d started digging into the client logging system and discovered a bunch of interesting bugs. I’ll tell you only the subset of those bugs that is relevant to this story. - -Again here’s a very simplified architecture of the system. - - -``` - +--------------+ - | | - +---+ +----------> | LOG SERVER | - |log| | | | - +---+ | +------+-------+ - | | - +-----+----+ | 200 ok - | | | - | CLIENT | <-----------+ - | | - +-----+----+ - ^ - +--------+--------+--------+ - | ^ ^ | - +--+--+ +--+--+ +--+--+ +--+--+ - | log | | log | | log | | log | - | | | | | | | | - | | | | | | | | - +-----+ +-----+ +-----+ +-----+ -``` - -The desktop client would generate logs. Those logs were compress, encrypted, and written to disk. Then every so often the client would send them up to the server. The client would read a log off of disk and send it to the log server. The server would decrypt it and store it, then respond with a 200. - -If the client couldn’t reach the log server, it wouldn’t let the log directory grow unbounded. After a certain point it would start deleting logs to keep the directory under a maximum size. - -The first two bugs were not a big deal on their own. The first one was that the desktop client sent logs up to the server starting with the oldest one instead of starting with the newest. This isn’t really what you want – for example, the server would tell the client to send logs if the client reported an exception, so probably you care about the logs that just happened and not the oldest logs that happen to be on disk. - -The second bug was similar to the first: if the log directory hit its maximum size, the client would delete the logs starting with the newest instead of starting with the oldest. Again, you lose log files either way, but you probably care less about the older ones. - -The third bug had to do with the encryption. Sometimes, the server would be unable to decrypt a log file. (We generally didn’t figure out why – maybe it was a bitflip.) We weren’t handling this error correctly on the backend, so the server would reply with a 500\. The client would behave reasonably in the face of a 500: it would assume that the server was down. So it would stop sending log files and not try to send up any of the others. - -Returning a 500 on a corrupted log file is clearly not the right behavior. You could consider returning a 400, since it’s a problem with the client request. But the client also can’t fix the problem – if the log file can’t be decrypted now, we’ll never be able to decrypt it in the future. What you really want the client to do is just delete the log and move on. In fact, that’s the default behavior when the client gets a 200 back from the server for a log file that was successfully stored. So we said, ok – if the log file can’t be decrypted, just return a 200. - -All of these bugs were straightforward to fix. The first two bugs were on the client, so we’d fixed them on the alpha build but they hadn’t gone out to the majority of clients. The third bug we fixed on the server and deployed. - -### 📈 - -Suddenly traffic to the log cluster spikes. The serving team reaches out to us to ask if we know what’s going on. It takes me a minute to put all the pieces together. - -Before these fixes, there were four things going on: - -1. Log files were sent up starting with the oldest - -2. Log files were deleted starting with the newest - -3. If the server couldn’t decrypt a log file it would 500 - -4. If the client got a 500 it would stop sending logs - -A client with a corrupted log file would try to send it, the server would 500, the client would give up sending logs. On its next run, it would try to send the same file again, fail again, and give up again. Eventually the log directory would get full, at which point the client would start deleting its newest files, leaving the corrupted one on disk. - -The upshot of these three bugs: if a client ever had a corrupted log file, we would never see logs from that client again. - -The problem is that there were a lot more clients in this state than we thought. Any client with a single corrupted file had been dammed up from sending logs to the server. Now that dam was cleared, and all of them were sending up the rest of the contents of their log directories. - -### Our options - -Ok, there’s a huge flood of traffic coming from machines around the world. What can we do? (This is a fun thing about working at a company with Dropbox’s scale, and particularly Dropbox’s scale of desktop clients: you can trigger a self-DDOS very easily.) - -The first option when you do a deploy and things start going sideways is to rollback. Totally reasonable choice, but in this case, it wouldn’t have helped us. The state that we’d transformed wasn’t the state on the server but the state on the client – we’d deleted those files. Rolling back the server would prevent additional clients from entering this state but it wouldn’t solve the problem. - -What about increasing the size of the logging cluster? We did that – and started getting even more requests, now that we’d increased our capacity. We increased it again, but you can’t do that forever. Why not? This cluster isn’t isolated. It’s making requests into another cluster, in this case to handle exceptions. If you have a DDOS pointed at one cluster, and you keep scaling that cluster, you’re going to knock over its depedencies too, and now you have two problems. - -Another option we considered was shedding load – you don’t need every single log file, so can we just drop requests. One of the challenges here was that we didn’t have an easy way to tell good traffic from bad. We couldn’t quickly differentiate which log files were old and which were new. - -The solution we hit on is one that’s been used at Dropbox on a number of different occassions: we have a custom header, `chillout`, which every client in the world respects. If the client gets a response with this header, then it doesn’t make any requests for the provided number of seconds. Someone very wise added this to the Dropbox client very early on, and it’s come in handy more than once over the years. The logging server didn’t have the ability to set that header, but that’s an easy problem to solve. So two of my colleagues, Isaac Goldberg and John Lai, implemented support for it. We set the logging cluster chillout to two minutes initially and then managed it down as the deluge subsided over the next couple of days. - -### Know your system - -The first lesson from this bug is to know your system. I had a good mental model of the interaction between the client and the server, but I wasn’t thinking about what would happen when the server was interacting with all the clients at once. There was a level of complexity that I hadn’t thought all the way through. - -### Know your tools - -The second lesson is to know your tools. If things go sideways, what options do you have? Can you reverse your migration? How will you know if things are going sideways and how can you discover more? All of those things are great to know before a crisis – but if you don’t, you’ll learn them during a crisis and then never forget. - -### Feature flags & server-side gating - -The third lesson is for you if you’re writing a mobile or a desktop application:  _You need server-side feature gating and server-side flags._  When you discover a problem and you don’t have server-side controls, the resolution might take days or weeks as you push out a new release or submit a new version to the app store. That’s a bad situation to be in. The Dropbox desktop client isn’t going through an app store review process, but just pushing out a build to tens of millions of clients takes time. Compare that to hitting a problem in your feature and flipping a switch on the server: ten minutes later your problem is resolved. - -This strategy is not without its costs. Having a bunch of feature flags in your code adds to the complexity dramatically. You get a combinatoric problem with your testing: what if feature A is enabled and feature B, or just one, or neither – multiplied across N features. It’s extremely difficult to get engineers to clean up their feature flags after the fact (and I was also guilty of this). Then for the desktop client there’s multiple versions in the wild at the same time, so it gets pretty hard to reason about. - -But the benefit – man, when you need it, you really need it. - -# How to love bugs - -I’ve talked about some bugs that I love and I’ve talked about why to love bugs. Now I want to tell you how to love bugs. If you don’t love bugs yet, I know of exactly one way to learn, and that’s to have a growth mindset. - -The sociologist Carol Dweck has done a ton of interesting research about how people think about intelligence. She’s found that there are two different frameworks for thinking about intelligence. The first, which she calls the fixed mindset, holds that intelligence is a fixed trait, and people can’t change how much of it they have. The other mindset is a growth mindset. Under a growth mindset, people believe that intelligence is malleable and can increase with effort. - -Dweck found that a person’s theory of intelligence – whether they hold a fixed or growth mindset – can significantly influence the way they select tasks to work on, the way they respond to challenges, their cognitive performance, and even their honesty. - -[I also talked about a growth mindset in my Kiwi PyCon keynote, so here are just a few excerpts. You can read the full transcript [here][7].] - -Findings about honesty: - -> After this, they had the students write letters to pen pals about the study, saying “We did this study at school, and here’s the score that I got.” They found that  _almost half of the students praised for intelligence lied about their scores_ , and almost no one who was praised for working hard was dishonest. - -On effort: - -> Several studies found that people with a fixed mindset can be reluctant to really exert effort, because they believe it means they’re not good at the thing they’re working hard on. Dweck notes, “It would be hard to maintain confidence in your ability if every time a task requires effort, your intelligence is called into question.” - -On responding to confusion: - -> They found that students with a growth mindset mastered the material about 70% of the time, regardless of whether there was a confusing passage in it. Among students with a fixed mindset, if they read the booklet without the confusing passage, again about 70% of them mastered the material. But the fixed-mindset students who encountered the confusing passage saw their mastery drop to 30%. Students with a fixed mindset were pretty bad at recovering from being confused. - -These findings show that a growth mindset is critical while debugging. We have to recover from confusion, be candid about the limitations of our understanding, and at times really struggle on the way to finding solutions – all of which is easier and less painful with a growth mindset. - -### Love your bugs - -I learned to love bugs by explicitly celebrating challenges while working at the Recurse Center. A participant would sit down next to me and say, “[sigh] I think I’ve got a weird Python bug,” and I’d say, “Awesome, I  _love_  weird Python bugs!” First of all, this is definitely true, but more importantly, it emphasized to the participant that finding something where they struggled an accomplishment, and it was a good thing for them to have done that day. - -As I mentioned, at the Recurse Center there are no deadlines and no assignments, so this attitude is pretty much free. I’d say, “You get to spend a day chasing down this weird bug in Flask, how exciting!” At Dropbox and later at Pilot, where we have a product to ship, deadlines, and users, I’m not always uniformly delighted about spending a day on a weird bug. So I’m sympathetic to the reality of the world where there are deadlines. However, if I have a bug to fix, I have to fix it, and being grumbly about the existence of the bug isn’t going to help me fix it faster. I think that even in a world where deadlines loom, you can still apply this attitude. - -If you love your bugs, you can have more fun while you’re working on a tough problem. You can be less worried and more focused, and end up learning more from them. Finally, you can share a bug with your friends and colleagues, which helps you and your teammates. - -### Obrigada! - -My thanks to folks who gave me feedback on this talk and otherwise contributed to my being there: - -* Sasha Laundy - -* Amy Hanlon - -* Julia Evans - -* Julian Cooper - -* Raphael Passini Diniz and the rest of the Python Brasil organizing team - --------------------------------------------------------------------------------- - -via: http://akaptur.com/blog/2017/11/12/love-your-bugs/ - -作者:[Allison Kaptur ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://akaptur.com/about/ -[1]:http://2017.pythonbrasil.org.br/# -[2]:http://www.youtube.com/watch?v=h4pZZOmv4Qs -[3]:http://www.pilot.com/ -[4]:http://www.dropbox.com/ -[5]:http://www.recurse.com/ -[6]:http://www.youtube.com/watch?v=ETgNLF_XpEM -[7]:http://akaptur.com/blog/2015/10/10/effective-learning-strategies-for-programmers/ diff --git a/sources/tech/20171113 Glitch write fun small web projects instantly.md b/sources/tech/20171113 Glitch write fun small web projects instantly.md deleted file mode 100644 index 734853ce51..0000000000 --- a/sources/tech/20171113 Glitch write fun small web projects instantly.md +++ /dev/null @@ -1,76 +0,0 @@ -translating---geekpi - -Glitch: write fun small web projects instantly -============================================================ - -I just wrote about Jupyter Notebooks which are a fun interactive way to write Python code. That reminded me I learned about Glitch recently, which I also love!! I built a small app to [turn of twitter retweets][2] with it. So! - -[Glitch][3] is an easy way to make Javascript webapps. (javascript backend, javascript frontend) - -The fun thing about glitch is: - -1. you start typing Javascript code into their web interface - -2. as soon as you type something, it automagically reloads the backend of your website with the new code. You don’t even have to save!! It autosaves. - -So it’s like Heroku, but even more magical!! Coding like this (you type, and the code runs on the public internet immediately) just feels really **fun** to me. - -It’s kind of like sshing into a server and editing PHP/HTML code on your server and having it instantly available, which I kind of also loved. Now we have “better deployment practices” than “just edit the code and it is instantly on the internet” but we are not talking about Serious Development Practices, we are talking about writing tiny programs for fun. - -### glitch has awesome example apps - -Glitch seems like fun nice way to learn programming! - -For example, there’s a space invaders game (code by [Mary Rose Cook][4]) at [https://space-invaders.glitch.me/][5]. The thing I love about this is that in just a few clicks I can - -1. click “remix this” - -2. start editing the code to make the boxes orange instead of black - -3. have my own space invaders game!! Mine is at [http://julias-space-invaders.glitch.me/][1]. (i just made very tiny edits to make it orange, nothing fancy) - -They have tons of example apps that you can start from – for instance [bots][6], [games][7], and more. - -### awesome actually useful app: tweetstorms - -The way I learned about Glitch was from this app which shows you tweetstorms from a given user: [https://tweetstorms.glitch.me/][8]. - -For example, you can see [@sarahmei][9]’s tweetstorms at [https://tweetstorms.glitch.me/sarahmei][10] (she tweets a lot of good tweetstorms!). - -### my glitch app: turn off retweets - -When I learned about Glitch I wanted to turn off retweets for everyone I follow on Twitter (I know you can do it in Tweetdeck!) and doing it manually was a pain – I had to do it one person at a time. So I wrote a tiny Glitch app to do it for me! - -I liked that I didn’t have to set up a local development environment, I could just start typing and go! - -Glitch only supports Javascript and I don’t really know Javascript that well (I think I’ve never written a Node program before), so the code isn’t awesome. But I had a really good time writing it – being able to type and just see my code running instantly was delightful. Here it is: [https://turn-off-retweets.glitch.me/][11]. - -### that’s all! - -Using Glitch feels really fun and democratic. Usually if I want to fork someone’s web project and make changes I wouldn’t do it – I’d have to fork it, figure out hosting, set up a local dev environment or Heroku or whatever, install the dependencies, etc. I think tasks like installing node.js dependencies used to be interesting, like “cool i am learning something new” and now I just find them tedious. - -So I love being able to just click “remix this!” and have my version on the internet instantly. - - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/2017/11/13/glitch--write-small-web-projects-easily/ - -作者:[Julia Evans ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://jvns.ca/ -[1]:http://julias-space-invaders.glitch.me/ -[2]:https://turn-off-retweets.glitch.me/ -[3]:https://glitch.com/ -[4]:https://maryrosecook.com/ -[5]:https://space-invaders.glitch.me/ -[6]:https://glitch.com/handy-bots -[7]:https://glitch.com/games -[8]:https://tweetstorms.glitch.me/ -[9]:https://twitter.com/sarahmei -[10]:https://tweetstorms.glitch.me/sarahmei -[11]:https://turn-off-retweets.glitch.me/ diff --git a/sources/tech/20171114 Sysadmin 101 Patch Management.md b/sources/tech/20171114 Sysadmin 101 Patch Management.md deleted file mode 100644 index 55ca09da87..0000000000 --- a/sources/tech/20171114 Sysadmin 101 Patch Management.md +++ /dev/null @@ -1,61 +0,0 @@ -【翻译中 @haoqixu】Sysadmin 101: Patch Management -============================================================ - -* [HOW-TOs][1] - -* [Servers][2] - -* [SysAdmin][3] - - -A few articles ago, I started a Sysadmin 101 series to pass down some fundamental knowledge about systems administration that the current generation of junior sysadmins, DevOps engineers or "full stack" developers might not learn otherwise. I had thought that I was done with the series, but then the WannaCry malware came out and exposed some of the poor patch management practices still in place in Windows networks. I imagine some readers that are still stuck in the Linux versus Windows wars of the 2000s might have even smiled with a sense of superiority when they heard about this outbreak. - -The reason I decided to revive my Sysadmin 101 series so soon is I realized that most Linux system administrators are no different from Windows sysadmins when it comes to patch management. Honestly, in some areas (in particular, uptime pride), some Linux sysadmins are even worse than Windows sysadmins regarding patch management. So in this article, I cover some of the fundamentals of patch management under Linux, including what a good patch management system looks like, the tools you will want to put in place and how the overall patching process should work. - -### What Is Patch Management? - -When I say patch management, I'm referring to the systems you have in place to update software already on a server. I'm not just talking about keeping up with the latest-and-greatest bleeding-edge version of a piece of software. Even more conservative distributions like Debian that stick with a particular version of software for its "stable" release still release frequent updates that patch bugs or security holes. - -Of course, if your organization decided to roll its own version of a particular piece of software, either because developers demanded the latest and greatest, you needed to fork the software to apply a custom change, or you just like giving yourself extra work, you now have a problem. Ideally you have put in a system that automatically packages up the custom version of the software for you in the same continuous integration system you use to build and package any other software, but many sysadmins still rely on the outdated method of packaging the software on their local machine based on (hopefully up to date) documentation on their wiki. In either case, you will need to confirm that your particular version has the security flaw, and if so, make sure that the new patch applies cleanly to your custom version. - -### What Good Patch Management Looks Like - -Patch management starts with knowing that there is a software update to begin with. First, for your core software, you should be subscribed to your Linux distribution's security mailing list, so you're notified immediately when there are security patches. If there you use any software that doesn't come from your distribution, you must find out how to be kept up to date on security patches for that software as well. When new security notifications come in, you should review the details so you understand how severe the security flaw is, whether you are affected and gauge a sense of how urgent the patch is. - -Some organizations have a purely manual patch management system. With such a system, when a security patch comes along, the sysadmin figures out which servers are running the software, generally by relying on memory and by logging in to servers and checking. Then the sysadmin uses the server's built-in package management tool to update the software with the latest from the distribution. Then the sysadmin moves on to the next server, and the next, until all of the servers are patched. - -There are many problems with manual patch management. First is the fact that it makes patching a laborious chore. The more work patching is, the more likely a sysadmin will put it off or skip doing it entirely. The second problem is that manual patch management relies too much on the sysadmin's ability to remember and recall all of the servers he or she is responsible for and keep track of which are patched and which aren't. This makes it easy for servers to be forgotten and sit unpatched. - -The faster and easier patch management is, the more likely you are to do it. You should have a system in place that quickly can tell you which servers are running a particular piece of software at which version. Ideally, that system also can push out updates. Personally, I prefer orchestration tools like MCollective for this task, but Red Hat provides Satellite, and Canonical provides Landscape as central tools that let you view software versions across your fleet of servers and apply patches all from a central place. - -Patching should be fault-tolerant as well. You should be able to patch a service and restart it without any overall down time. The same idea goes for kernel patches that require a reboot. My approach is to divide my servers into different high availability groups so that lb1, app1, rabbitmq1 and db1 would all be in one group, and lb2, app2, rabbitmq2 and db2 are in another. Then, I know I can patch one group at a time without it causing downtime anywhere else. - -So, how fast is fast? Your system should be able to roll out a patch to a minor piece of software that doesn't have an accompanying service (such as bash in the case of the ShellShock vulnerability) within a few minutes to an hour at most. For something like OpenSSL that requires you to restart services, the careful process of patching and restarting services in a fault-tolerant way probably will take more time, but this is where orchestration tools come in handy. I gave examples of how to use MCollective to accomplish this in my recent MCollective articles (see the December 2016 and January 2017 issues), but ideally, you should put a system in place that makes it easy to patch and restart services in a fault-tolerant and automated way. - -When patching requires a reboot, such as in the case of kernel patches, it might take a bit more time, but again, automation and orchestration tools can make this go much faster than you might imagine. I can patch and reboot the servers in an environment in a fault-tolerant way within an hour or two, and it would be much faster than that if I didn't need to wait for clusters to sync back up in between reboots. - -Unfortunately, many sysadmins still hold on to the outdated notion that uptime is a badge of pride—given that serious kernel patches tend to come out at least once a year if not more often, to me, it's proof you don't take security seriously. - -Many organizations also still have that single point of failure server that can never go down, and as a result, it never gets patched or rebooted. If you want to be secure, you need to remove these outdated liabilities and create systems that at least can be rebooted during a late-night maintenance window. - -Ultimately, fast and easy patch management is a sign of a mature and professional sysadmin team. Updating software is something all sysadmins have to do as part of their jobs, and investing time into systems that make that process easy and fast pays dividends far beyond security. For one, it helps identify bad architecture decisions that cause single points of failure. For another, it helps identify stagnant, out-of-date legacy systems in an environment and provides you with an incentive to replace them. Finally, when patching is managed well, it frees up sysadmins' time and turns their attention to the things that truly require their expertise. - -______________________ - -Kyle Rankin is senior security and infrastructure architect, the author of many books including Linux Hardening in Hostile Networks, DevOps Troubleshooting and The Official Ubuntu Server Book, and a columnist for Linux Journal. Follow him @kylerankin - --------------------------------------------------------------------------------- - -via: https://www.linuxjournal.com/content/sysadmin-101-patch-management - -作者:[Kyle Rankin ][a] -译者:[译者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 -[1]:https://www.linuxjournal.com/tag/how-tos -[2]:https://www.linuxjournal.com/tag/servers -[3]:https://www.linuxjournal.com/tag/sysadmin -[4]:https://www.linuxjournal.com/users/kyle-rankin diff --git a/sources/tech/20171114 Take Linux and Run With It.md b/sources/tech/20171114 Take Linux and Run With It.md deleted file mode 100644 index b7b6cb9663..0000000000 --- a/sources/tech/20171114 Take Linux and Run With It.md +++ /dev/null @@ -1,68 +0,0 @@ -Take Linux and Run With It -============================================================ - -![](https://www.linuxinsider.com/article_images/story_graphics_xlarge/xl-2016-linux-1.jpg) - -![](https://www.linuxinsider.com/images/2015/image-credit-adobe-stock_130x15.gif) - - -"How do you run an operating system?" may seem like a simple question, since most of us are accustomed to turning on our computers and seeing our system spin up. However, this common model is only one way of running an operating system. As one of Linux's greatest strengths is versatility, Linux offers the most methods and environments for running it. - -To unleash the full power of Linux, and maybe even find a use for it you hadn't thought of, consider some less conventional ways of running it -- specifically, ones that don't even require installation on a computer's hard drive. - -### We'll Do It Live! - -Live-booting is a surprisingly useful and popular way to get the full Linux experience on the fly. While hard drives are where OSes reside most of the time, they actually can be installed to most major storage media, including CDs, DVDs and USB flash drives. - -When an OS is installed to some device other than a computer's onboard hard drive and subsequently booted instead of that onboard drive, it's called "live-booting" or running a "live session." - -At boot time, the user simply selects an external storage source for the hardware to look for boot information. If found, the computer follows the external device's boot instructions, essentially ignoring the onboard drive until the next time the user boots normally. Optical media are increasingly rare these days, so by far the most typical form that an external OS-carrying device takes is a USB stick. - -Most mainstream Linux distributions offer a way to run a live session as a way of trying them out. The live session doesn't save any user activity, and the OS resets to the clean default state after every shutdown. - -Live Linux sessions can be used for more than testing a distro, though. One application is for executing system repair for critically malfunctioning onboard (usually also Linux) systems. If an update or configuration made the onboard system unbootable, a full system backup is required, or the hard drive has sustained serious file corruption, the only recourse is to start up a live system and perform maintenance on the onboard drive. - -In these and similar scenarios, the onboard drive cannot be manipulated or corrected while also keeping the system stored on it running, so a live system takes on those burdens instead, leaving all but the problematic files on the onboard drive at rest. - -Live sessions also are perfectly suited for handling sensitive information. If you don't want a computer to retain any trace of the operations executed or information handled on it, especially if you are using hardware you can't vouch for -- like a public library or hotel business center computer -- a live session will provide you all the desktop computing functions to complete your task while retaining no trace of your session once you're finished. This is great for doing online banking or password input that you don't want a computer to remember. - -### Linux Virtually Anywhere - -Another approach for implementing Linux for more on-demand purposes is to run a virtual machine on another host OS. A virtual machine, or VM, is essentially a small computer running inside another computer and contained in a single large file. - -To run a VM, users simply install a hypervisor program (a kind of launcher for the VM), select a downloaded Linux OS image file (usually ending with a ".iso" file extension), and walk through the setup process. - -Most of the settings can be left at their defaults, but the key ones to configure are the amount of RAM and hard drive storage to lease to the VM. Fortunately, since Linux has a light footprint, you don't have to set these very high: 2 GB of RAM and 16 GB of storage should be plenty for the VM while still letting your host OS thrive. - -So what does this offer that a live system doesn't? First, whereas live systems are ephemeral, VMs can retain the data stored on them. This is great if you want to set up your Linux VM for a special use case, like software development or even security. - -When used for development, a Linux VM gives you the solid foundation of Linux's programming language suites and coding tools, and it lets you save your projects right in the VM to keep everything organized. - -If security is your goal, Linux VMs allow you to impose an extra layer between a potential hazard and your system. If you do your browsing from the VM, a malicious program would have to compromise not only your virtual Linux system, but also the hypervisor -- and  _then_ your host OS, a technical feat beyond all but the most skilled and determined adversaries. - -Second, you can start up your VM on demand from your host system, without having to power it down and start it up again as you would have to with a live session. When you need it, you can quickly bring up the VM, and when you're finished, you just shut it down and go back to what you were doing before. - -Your host system continues running normally while the VM is on, so you can attend to tasks simultaneously in each system. - -### Look Ma, No Installation! - -Just as there is no one form that Linux takes, there's also no one way to run it. Hopefully, this brief primer on the kinds of systems you can run has given you some ideas to expand your use models. - -The best part is that if you're not sure how these can help, live booting and virtual machines don't hurt to try!  -![](https://www.ectnews.com/images/end-enn.gif) - --------------------------------------------------------------------------------- - -via: https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html - -作者:[ Jonathan Terrasi ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html#searchbyline -[1]:https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html# -[2]:https://www.linuxinsider.com/perl/mailit/?id=84951 -[3]:https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html -[4]:https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html diff --git a/sources/tech/20171115 Security Jobs Are Hot Get Trained and Get Noticed.md b/sources/tech/20171115 Security Jobs Are Hot Get Trained and Get Noticed.md deleted file mode 100644 index a0a6b1ed60..0000000000 --- a/sources/tech/20171115 Security Jobs Are Hot Get Trained and Get Noticed.md +++ /dev/null @@ -1,58 +0,0 @@ -Security Jobs Are Hot: Get Trained and Get Noticed -============================================================ - -![security skills](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/security-skills.png?itok=IrwppCUw "security skills") -The Open Source Jobs Report, from Dice and The Linux Foundation, found that professionals with security experience are in high demand for the future.[Used with permission][1] - -The demand for security professionals is real. On [Dice.com][4], 15 percent of the more than 75K jobs are security positions. “Every year in the U.S., 40,000 jobs for information security analysts go unfilled, and employers are struggling to fill 200,000 other cyber-security related roles, according to cyber security data tool [CyberSeek][5]” ([Forbes][6]). We know that there is a fast-increasing need for security specialists, but that the interest level is low. - -### Security is the place to be - -In my experience, few students coming out of college are interested in roles in security; so many people see security as niche. Entry-level tech pros are interested in business analyst or system analyst roles, because of a belief that if you want to learn and apply core IT concepts, you have to stick to analyst roles or those closer to product development. That’s simply not the case. - -In fact, if you’re interested in getting in front of your business leaders, security is the place to be – as a security professional, you have to understand the business end-to-end; you have to look at the big picture to give your company the advantage. - -### Be fearless - -Analyst and security roles are not all that different. Companies continue to merge engineering and security roles out of necessity. Businesses are moving faster than ever with infrastructure and code being deployed through automation, which increases the importance of security being a part of all tech pros day to day lives. In our [Open Source Jobs Report with The Linux Foundation][7], 42 percent of hiring managers said professionals with security experience are in high demand for the future. - -There has never been a more exciting time to be in security. If you stay up-to-date with tech news, you’ll see that a huge number of stories are related to security – data breaches, system failures and fraud. The security teams are working in ever-changing, fast-paced environments. A real challenge lies is in the proactive side of security, finding, and eliminating vulnerabilities while maintaining or even improving the end-user experience.   - -### Growth is imminent - -Of any aspect of tech, security is the one that will continue to grow with the cloud. Businesses are moving more and more to the cloud and that’s exposing more security vulnerabilities than organizations are used to. As the cloud matures, security becomes increasingly important.            - -Regulations are also growing – Personally Identifiable Information (PII) is getting broader all the time. Many companies are finding that they must invest in security to stay in compliance and avoid being in the headlines. Companies are beginning to budget more and more for security tooling and staffing due to the risk of heavy fines, reputational damage, and, to be honest, executive job security.   - -### Training and support - -Even if you don’t choose a security-specific role, you’re bound to find yourself needing to code securely, and if you don’t have the skills to do that, you’ll start fighting an uphill battle. There are certainly ways to learn on-the-job if your company offers that option, that’s encouraged but I recommend a combination of training, mentorship and constant practice. Without using your security skills, you’ll lose them fast with how quickly the complexity of malicious attacks evolve. - -My recommendation for those seeking security roles is to find the people in your organization that are the strongest in engineering, development, or architecture areas – interface with them and other teams, do hands-on work, and be sure to keep the big-picture in mind. Be an asset to your organization that stands out – someone that can securely code and also consider strategy and overall infrastructure health. - -### The end game - -More and more companies are investing in security and trying to fill open roles in their tech teams. If you’re interested in management, security is the place to be. Executive leadership wants to know that their company is playing by the rules, that their data is secure, and that they’re safe from breaches and loss. - -Security that is implemented wisely and with strategy in mind will get noticed. Security is paramount for executives and consumers alike – I’d encourage anyone interested in security to train up and contribute. - - _[Download ][2]the full 2017 Open Source Jobs Report now._ - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/os-jobs-report/2017/11/security-jobs-are-hot-get-trained-and-get-noticed - -作者:[ BEN COLLEN][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/bencollen -[1]:https://www.linux.com/licenses/category/used-permission -[2]:http://bit.ly/2017OSSjobsreport -[3]:https://www.linux.com/files/images/security-skillspng -[4]:http://www.dice.com/ -[5]:http://cyberseek.org/index.html#about -[6]:https://www.forbes.com/sites/jeffkauflin/2017/03/16/the-fast-growing-job-with-a-huge-skills-gap-cyber-security/#292f0a675163 -[7]:http://media.dice.com/report/the-2017-open-source-jobs-report-employers-prioritize-hiring-open-source-professionals-with-latest-skills/ diff --git a/sources/tech/20171115 Why and How to Set an Open Source Strategy.md b/sources/tech/20171115 Why and How to Set an Open Source Strategy.md deleted file mode 100644 index 79ec071b4d..0000000000 --- a/sources/tech/20171115 Why and How to Set an Open Source Strategy.md +++ /dev/null @@ -1,120 +0,0 @@ -Why and How to Set an Open Source Strategy -============================================================ - -![](https://www.linuxfoundation.org/wp-content/uploads/2017/11/open-source-strategy-1024x576.jpg) - -This article explains how to walk through, measure, and define strategies collaboratively in an open source community. - - _“If you don’t know where you are going, you’ll end up someplace else.” _ _—_  Yogi Berra - -Open source projects are generally started as a way to scratch one’s itch — and frankly that’s one of its greatest attributes. Getting code down provides a tangible method to express an idea, showcase a need, and solve a problem. It avoids over thinking and getting a project stuck in analysis-paralysis, letting the project pragmatically solve the problem at hand. - -Next, a project starts to scale up and gets many varied users and contributions, with plenty of opinions along the way. That leads to the next big challenge — how does a project start to build a strategic vision? In this article, I’ll describe how to walk through, measure, and define strategies collaboratively, in a community. - -Strategy may seem like a buzzword of the corporate world rather something that an open source community would embrace, so I suggest stripping away the negative actions that are sometimes associated with this word (e.g., staff reductions, discontinuations, office closures). Strategy done right isn’t a tool to justify unfortunate actions but to help show focus and where each community member can contribute. - -A good application of strategy achieves the following: - -* Why the project exists? - -* What the project looks to achieve? - -* What is the ideal end state for a project is. - -The key to success is answering these questions as simply as possible, with consensus from your community. Let’s look at some ways to do this. - -### Setting a mission and vision - - _“_ _Efforts and courage are not enough without purpose and direction.”_  — John F. Kennedy - -All strategic planning starts off with setting a course for where the project wants to go. The two tools used here are  _Mission_  and  _Vision_ . They are complementary terms, describing both the reason a project exists (mission) and the ideal end state for a project (vision). - -A great way to start this exercise with the intent of driving consensus is by asking each key community member the following questions: - -* What drove you to join and/or contribute the project? - -* How do you define success for your participation? - -In a company, you’d ask your customers these questions usually. But in open source projects, the customers are the project participants — and their time investment is what makes the project a success. - -Driving consensus means capturing the answers to these questions and looking for themes across them. At R Consortium, for example, I created a shared doc for the board to review each member’s answers to the above questions, and followed up with a meeting to review for specific themes that came from those insights. - -Building a mission flows really well from this exercise. The key thing is to keep the wording of your mission short and concise. Open Mainframe Project has done this really well. Here’s their mission: - - _Build community and adoption of Open Source on the mainframe by:_ - -* _Eliminating barriers to Open Source adoption on the mainframe_ - -* _Demonstrating value of the mainframe on technical and business levels_ - -* _Strengthening collaboration points and resources for the community to thrive_ - -At 40 words, it passes the key eye tests of a good mission statement; it’s clear, concise, and demonstrates the useful value the project aims for. - -The next stage is to reflect on the mission statement and ask yourself this question: What is the ideal outcome if the project accomplishes its mission? That can be a tough one to tackle. Open Mainframe Project put together its vision really well: - - _Linux on the Mainframe as the standard for enterprise class systems and applications._ - -You could read that as a [BHAG][1], but it’s really more of a vision, because it describes a future state that is what would be created by the mission being fully accomplished. It also hits the key pieces to an effective vision — it’s only 13 words, inspirational, clear, memorable, and concise. - -Mission and vision add clarity on the who, what, why, and how for your project. But, how do you set a course for getting there? - -### Goals, Objectives, Actions, and Results - - _“I don’t focus on what I’m up against. I focus on my goals and I try to ignore the rest.”_  — Venus Williams - -Looking at a mission and vision can get overwhelming, so breaking them down into smaller chunks can help the project determine how to get started. This also helps prioritize actions, either by importance or by opportunity. Most importantly, this step gives you guidance on what things to focus on for a period of time, and which to put off. - -There are lots of methods of time bound planning, but the method I think works the best for projects is what I’ve dubbed the GOAR method. It’s an acronym that stands for: - -* Goals define what the project is striving for and likely would align and support the mission. Examples might be “Grow a diverse contributor base” or “Become the leading project for X.” Goals are aspirational and set direction. - -* Objectives show how you measure a goal’s completion, and should be clear and measurable. You might also have multiple objectives to measure the completion of a goal. For example, the goal “Grow a diverse contributor base” might have objectives such as “Have X total contributors monthly” and “Have contributors representing Y different organizations.” - -* Actions are what the project plans to do to complete an objective. This is where you get tactical on exactly what needs done. For example, the objective “Have contributors representing Y different organizations” would like have actions of reaching out to interested organizations using the project, having existing contributors mentor new mentors, and providing incentives for first time contributors. - -* Results come along the way, showing progress both positive and negative from the actions. - -You can put these into a table like this: - -| Goals | Objectives | Actions | Results | -|:--|:--|:--|:--| -| Grow a diverse contributor base     | Have X total contributors monthly | Existing contributors mentor new mentors Providing incentives for first time contributors | | -| | Have contributors representing Y different organizations | Reach out to interested organizations using the project | | - - -In large organizations, monthly or quarterly goals and objectives often make sense; however, on open source projects, these time frames are unrealistic. Six- even 12-month tracking allows the project leadership to focus on driving efforts at a high level by nurturing the community along. - -The end result is a rubric that provides clear vision on where the project is going. It also lets community members more easily find ways to contribute. For example, your project may include someone who knows a few organizations using the project — this person could help introduce those developers to the codebase and guide them through their first commit. - -### What happens if the project doesn’t hit the goals? - - _“I have not failed. I’ve just found 10,000 ways that won’t work.”_  — Thomas A. Edison - -Figuring out what is within the capability of an organization — whether Fortune 500 or a small open source project — is hard. And, sometimes the expectations or market conditions change along the way. Does that make the strategy planning process a failure? Absolutely not! - -Instead, you can use this experience as a way to better understand your project’s velocity, its impact, and its community, and perhaps as a way to prioritize what is important and what’s not. - --------------------------------------------------------------------------------- - -via: https://www.linuxfoundation.org/blog/set-open-source-strategy/ - -作者:[ John Mertic][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linuxfoundation.org/author/jmertic/ -[1]:https://en.wikipedia.org/wiki/Big_Hairy_Audacious_Goal -[2]:https://www.linuxfoundation.org/author/jmertic/ -[3]:https://www.linuxfoundation.org/category/blog/ -[4]:https://www.linuxfoundation.org/category/audience/c-level/ -[5]:https://www.linuxfoundation.org/category/audience/developer-influencers/ -[6]:https://www.linuxfoundation.org/category/audience/entrepreneurs/ -[7]:https://www.linuxfoundation.org/category/campaigns/membership/how-to/ -[8]:https://www.linuxfoundation.org/category/campaigns/events-campaigns/linux-foundation/ -[9]:https://www.linuxfoundation.org/category/audience/open-source-developers/ -[10]:https://www.linuxfoundation.org/category/audience/open-source-professionals/ -[11]:https://www.linuxfoundation.org/category/audience/open-source-users/ -[12]:https://www.linuxfoundation.org/category/blog/thought-leadership/ diff --git a/sources/tech/20171116 Unleash Your Creativity – Linux Programs for Drawing and Image Editing.md b/sources/tech/20171116 Unleash Your Creativity – Linux Programs for Drawing and Image Editing.md deleted file mode 100644 index c6c50d9b25..0000000000 --- a/sources/tech/20171116 Unleash Your Creativity – Linux Programs for Drawing and Image Editing.md +++ /dev/null @@ -1,130 +0,0 @@ -### Unleash Your Creativity – Linux Programs for Drawing and Image Editing - - By: [chabowski][1] - -The following article is part of a series of articles that provide tips and tricks for Linux newbies – or Desktop users that are not yet experienced with regard to certain topics. This series intends to complement the special edition #30 “[Getting Started with Linux][2]” based on [openSUSE Leap][3], recently published by the [Linux Magazine,][4] with valuable additional information. - -![](https://www.suse.com/communities/blog/files/2017/11/DougDeMaio-450x450.jpeg) - -This article has been contributed by Douglas DeMaio, openSUSE PR Expert at SUSE. - -Both Mac OS or Window offer several popular programs for graphics editing, vector drawing and creating and manipulating Portable Document Format (PDF). The good news: users familiar with the Adobe Suite can transition with ease to free, open-source programs available on Linux. - -Programs like [GIMP][5], [InkScape][6] and [Okular][7] are cross platform programs that are available by default in Linux/GNU distributions and are persuasive alternatives to expensive Adobe programs like [Photoshop][8], [Illustrator][9] and [Acrobat][10]. - -These creativity programs on Linux distributions are just as powerful as those for macOS or Window. This article will explain some of the differences and how the programs can be used to make your transition to Linux comfortable. - -### Krita - -The KDE desktop environment comes with tons of cool applications. [Krita][11] is a professional open source painting program. It gives users the freedom to create any artistic image they desire. Krita features tools that are much more extensive than the tool sets of most proprietary programs you might be familiar with. From creating textures to comics, Krita is a must have application for Linux users. - -![](https://www.suse.com/communities/blog/files/2017/11/krita-450x267.png) - -### GIMP - -GNU Image Manipulation Program (GIMP) is a cross-platform image editor. Users of Photoshop will find the User Interface of GIMP to be similar to that of Photoshop. The drop down menu offers colors, layers, filters and tools to help the user with editing graphics. Rulers are located both horizontal and vertical and guide can be dragged across the screen to give exact measurements. The drop down menu gives tool options for resizing or cropping photos; adjustments can be made to the color balance, color levels, brightness and contrast as well as hue and saturation. - -![](https://www.suse.com/communities/blog/files/2017/11/gimp-450x281.png) - -There are multiple filters in GIMP to enhance or distort your images. Filters for artistic expression and animation are available and are more powerful tool options than those found in some proprietary applications. Gradients can be applied through additional layers and the Text Tool offers many fonts, which can be altered in shape and size through the Perspective Tool. - -The cloning tool works exactly like those in other graphics editors, so manipulating images is simple and acurrate given the selection of brush sizes to do the job. - -Perhaps one of the best options available with GIMP is that the images can be saved in a variety of formats like .jpg, .png, .pdf, .eps and .svg. These image options provide high-quality images in a small file. - -### InkScape - -Designing vector imagery with InkScape is simple and free. This cross platform allows for the creation of logos and illustrations that are highly scalable. Whether designing cartoons or creating images for branding, InkScape is a powerful application to get the job done. Like GIMP, InkScape lets you save files in various formats and allows for object manipulation like moving, rotating and skewing text and objects. Shape tools are available with InkScape so making stars, hexagons and other elements will meet the needs of your creative mind. - -![](https://www.suse.com/communities/blog/files/2017/11/inkscape-450x273.png) - -InkScape offers a comprehensive tool set, including a drawing tool, a pen tool and the freehand calligraphy tool that allows for object creation with your own personal style. The color selector gives you the choice of RGB, CMYK and RGBA – using specific colors for branding logos, icons and advertisement is definitely convincing. - -Short cut commands are similar to what users experience in Adobe Illustrator. Making layers and grouping or ungrouping the design elements can turn a blank page into a full-fledged image that can be used for designing technical diagrams for presentations, importing images into a multimedia program or for creating web graphics and software design. - -Inkscape can import vector graphics from multiple other programs. It can even import bitmap images. Inkscape is one of those cross platform, open-source programs that allow users to operate across different operating systems, no matter if they work with macOS, Windows or Linux. - -### Okular and LibreOffice - -LibreOffice, which is a free, open-source Office Suite, allows users to collaborate and interact with documents and important files on Linux, but also on macOS and Window. You can also create PDF files via LibreOffice, and LibreOffice Draw lets you view (and edit) PDF files as images. - -![](https://www.suse.com/communities/blog/files/2017/11/draw-450x273.png) - -However, the Portable Document Format (PDF) is quite different on the three Operating Systems. MacOS offers [Preview][12] by default; Windows has [Edge][13]. Of course, also Adobe Reader can be used for both MacOS and Window. With Linux, and especially the desktop selection of KDE, [Okular][14] is the default program for viewing PDF files. - -![](https://www.suse.com/communities/blog/files/2017/11/okular-450x273.png) - -The functionality of Okular supports different types of documents, like PDF, Postscript, [DjVu][15], [CHM][16], [XPS][17], [ePub][18] and others. Yet the universal document viewer also offers some powerful features that make interacting with a document different from other programs on MacOS and Windows. Okular gives selection and search tools that make accessing the text in PDFs fluid for how users interact with documents. Viewing documents with Okular is also accommodating with the magnification tool that allows for a quick look at small text in a document. - -Okular also provides users with the option to configure it to use more memory if the document is too large and freezes the Operating System. This functionality is convenient for users accessing high-quality print documents for example for advertising. - -For those who want to change locked images and documents, it’s rather easy to do so with LibreOffice Draw. A hypothetical situation would be to take a locked IRS (or tax) form and change it to make the uneditable document editable. Imagine how much fun it could be to transform it to some humorous kind of tax form … - -And indeed, the sky’s the limit on how creative a user wants to be when using programs that are available on Linux distributions. - -![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) - -![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) - -![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) - -![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) - -![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) - -( - - _**2** votes, average: **5.00** out of 5_ - -) - - _You need to be a registered member to rate this post._ - -Tags: [drawing][19], [Getting Started with Linux][20], [GIMP][21], [image editing][22], [Images][23], [InkScape][24], [KDE][25], [Krita][26], [Leap 42.3][27], [LibreOffice][28], [Linux Magazine][29], [Okular][30], [openSUSE][31], [PDF][32] Categories: [Desktop][33], [Expert Views][34], [LibreOffice][35], [openSUSE][36] - --------------------------------------------------------------------------------- - -via: https://www.suse.com/communities/blog/unleash-creativity-linux-programs-drawing-image-editing/ - -作者:[chabowski ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[1]:https://www.suse.com/communities/blog/author/chabowski/ -[2]:http://www.linux-magazine.com/Resources/Special-Editions/30-Getting-Started-with-Linux -[3]:https://en.opensuse.org/Portal:42.3 -[4]:http://www.linux-magazine.com/ -[5]:https://www.gimp.org/ -[6]:https://inkscape.org/en/ -[7]:https://okular.kde.org/ -[8]:http://www.adobe.com/products/photoshop.html -[9]:http://www.adobe.com/products/illustrator.html -[10]:https://acrobat.adobe.com/us/en/acrobat/acrobat-pro-cc.html -[11]:https://krita.org/en/ -[12]:https://en.wikipedia.org/wiki/Preview_(macOS) -[13]:https://en.wikipedia.org/wiki/Microsoft_Edge -[14]:https://okular.kde.org/ -[15]:http://djvu.org/ -[16]:https://fileinfo.com/extension/chm -[17]:https://fileinfo.com/extension/xps -[18]:http://idpf.org/epub -[19]:https://www.suse.com/communities/blog/tag/drawing/ -[20]:https://www.suse.com/communities/blog/tag/getting-started-with-linux/ -[21]:https://www.suse.com/communities/blog/tag/gimp/ -[22]:https://www.suse.com/communities/blog/tag/image-editing/ -[23]:https://www.suse.com/communities/blog/tag/images/ -[24]:https://www.suse.com/communities/blog/tag/inkscape/ -[25]:https://www.suse.com/communities/blog/tag/kde/ -[26]:https://www.suse.com/communities/blog/tag/krita/ -[27]:https://www.suse.com/communities/blog/tag/leap-42-3/ -[28]:https://www.suse.com/communities/blog/tag/libreoffice/ -[29]:https://www.suse.com/communities/blog/tag/linux-magazine/ -[30]:https://www.suse.com/communities/blog/tag/okular/ -[31]:https://www.suse.com/communities/blog/tag/opensuse/ -[32]:https://www.suse.com/communities/blog/tag/pdf/ -[33]:https://www.suse.com/communities/blog/category/desktop/ -[34]:https://www.suse.com/communities/blog/category/expert-views/ -[35]:https://www.suse.com/communities/blog/category/libreoffice/ -[36]:https://www.suse.com/communities/blog/category/opensuse/ diff --git a/sources/tech/20171120 Adopting Kubernetes step by step.md b/sources/tech/20171120 Adopting Kubernetes step by step.md deleted file mode 100644 index 05faf304c8..0000000000 --- a/sources/tech/20171120 Adopting Kubernetes step by step.md +++ /dev/null @@ -1,93 +0,0 @@ -Adopting Kubernetes step by step -============================================================ - -Why Docker and Kubernetes? - -Containers allow us to build, ship and run distributed applications. They remove the machine constraints from applications and lets us create a complex application in a deterministic fashion. - -Composing applications with containers allows us to make development, QA and production environments closer to each other (if you put the effort in to get there). By doing so, changes can be shipped faster and testing a full system can happen sooner. - -[Docker][1] — the containerization platform — provides this, making software  _independent_  of cloud providers. - -However, even with containers the amount of work needed for shipping your application through any cloud provider (or in a private cloud) is significant. An application usually needs auto scaling groups, persistent remote discs, auto discovery, etc. But each cloud provider has different mechanisms for doing this. If you want to support these features, you very quickly become cloud provider dependent. - -This is where [Kubernetes][2] comes in to play. It is an orchestration system for containers that allows you to manage, scale and deploy different pieces of your application — in a standardised way — with great tooling as part of it. It’s a portable abstraction that’s compatible with the main cloud providers (Google Cloud, Amazon Web Services and Microsoft Azure all have support for Kubernetes). - -A way to visualise your application, containers and Kubernetes is to think about your application as a shark — stay with me — that exists in the ocean (in this example, the ocean is your machine). The ocean may have other precious things you don’t want your shark to interact with, like [clown fish][3]. So you move you shark (your application) into a sealed aquarium (Container). This is great but not very robust. Your aquarium can break or maybe you want to build a tunnel to another aquarium where other fish live. Or maybe you want many copies of that aquarium in case one needs cleaning or maintenance… this is where Kubernetes clusters come to play. - - -![](https://cdn-images-1.medium.com/max/1600/1*OVt8cnY1WWOqdLFycCgdFg.jpeg) -Evolution to Kubernetes - -With Kubernetes being supported by the main cloud providers, it makes it easier for you and your team to have environments from  _development _ to  _production _ that are almost identical to each other. This is because Kubernetes has no reliance on proprietary software, services or infrastructure. - -The fact that you can start your application in your machine with the same pieces as in production closes the gaps between a development and a production environment. This makes developers more aware of how an application is structured together even though they might only be responsible for one piece of it. It also makes it easier for your application to be fully tested earlier in the pipeline. - -How do you work with Kubernetes? - -With more people adopting Kubernetes new questions arise; how should I develop against a cluster based environment? Suppose you have 3 environments — development, QA and production — how do I fit Kubernetes in them? Differences across these environments will still exist, either in terms of development cycle (e.g. time spent to see my code changes in the application I’m running) or in terms of data (e.g. I probably shouldn’t test with production data in my QA environment as it has sensitive information). - -So, should I always try to work inside a Kubernetes cluster, building images, recreating deployments and services while I code? Or maybe I should not try too hard to make my development environment be a Kubernetes cluster (or set of clusters) in development? Or maybe I should work in a hybrid way? - - -![](https://cdn-images-1.medium.com/max/1600/1*MXokxD8Ktte4_vWvTas9uw.jpeg) -Development with a local cluster - -If we carry on with our metaphor, the holes on the side represent a way to make changes to our app while keeping it in a development cluster. This is usually achieved via [volumes][4]. - -A Kubernetes series - -The Kubernetes series repository is open source and available here: - -### [https://github.com/red-gate/ks][5] - -We’ve written this series as we experiment with different ways to build software. We’ve tried to constrain ourselves to use Kubernetes in all environments so that we can explore the impact these technologies will have on the development and management of data and the database. - -The series starts with the basic creation of a React application hooked up to Kubernetes, and evolves to encompass more of our development requirements. By the end we’ll have covered all of our application development needs  _and_  have understood how best to cater for the database lifecycle in this world of containers and clusters. - -Here are the first 5 episodes of this series: - -1. ks1: build a React app with Kubernetes - -2. ks2: make minikube detect React code changes - -3. ks3: add a python web server that hosts an API - -4. ks4: make minikube detect Python code changes - -5. ks5: create a test environment - -The second part of the series will add a database and try to work out the best way to evolve our application alongside it. - -By running Kubernetes in all environments, we’ve been forced to solve new problems as we try to keep the development cycle as fast as possible. The trade-off being that we are constantly exposed to Kubernetes and become more accustomed to it. By doing so, development teams become responsible for production environments, which is no longer difficult as all environments (development through production) are all managed in the same way. - -What’s next? - -We will continue this series by incorporating a database and experimenting to find the best way to have a seamless database lifecycle experience with Kubernetes. - - _This Kubernetes series is brought to you by Foundry, Redgate’s R&D division. We’re working on making it easier to manage data alongside containerised environments, so if you’re working with data and containerised environments, we’d like to hear from you — reach out directly to the development team at _ [_foundry@red-gate.com_][6] - -* * * - - _We’re hiring_ _. Are you interested in uncovering product opportunities, building _ [_future technology_][7] _ and taking a startup-like approach (without the risk)? Take a look at our _ [_Software Engineer — Future Technologies_][8] _ role and read more about what it’s like to work at Redgate in _ [_Cambridge, UK_][9] _._ - --------------------------------------------------------------------------------- - -via: https://medium.com/ingeniouslysimple/adopting-kubernetes-step-by-step-f93093c13dfe - -作者:[santiago arias][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://medium.com/@santiaago?source=post_header_lockup -[1]:https://www.docker.com/what-docker -[2]:https://kubernetes.io/ -[3]:https://www.google.co.uk/search?biw=723&bih=753&tbm=isch&sa=1&ei=p-YCWpbtN8atkwWc8ZyQAQ&q=nemo+fish&oq=nemo+fish&gs_l=psy-ab.3..0i67k1l2j0l2j0i67k1j0l5.5128.9271.0.9566.9.9.0.0.0.0.81.532.9.9.0....0...1.1.64.psy-ab..0.9.526...0i7i30k1j0i7i10i30k1j0i13k1j0i10k1.0.FbAf9xXxTEM -[4]:https://kubernetes.io/docs/concepts/storage/volumes/ -[5]:https://github.com/red-gate/ks -[6]:mailto:foundry@red-gate.com -[7]:https://www.red-gate.com/foundry/ -[8]:https://www.red-gate.com/our-company/careers/current-opportunities/software-engineer-future-technologies -[9]:https://www.red-gate.com/our-company/careers/living-in-cambridge diff --git a/sources/tech/20171120 Containers and Kubernetes Whats next.md b/sources/tech/20171120 Containers and Kubernetes Whats next.md new file mode 100644 index 0000000000..b73ccb21c2 --- /dev/null +++ b/sources/tech/20171120 Containers and Kubernetes Whats next.md @@ -0,0 +1,98 @@ +YunfengHe Translating +Containers and Kubernetes: What's next? +============================================================ + +### What's ahead for container orchestration and Kubernetes? Here's an expert peek + +![CIO_Big Data Decisions_2](https://enterprisersproject.com/sites/default/files/styles/620x350/public/images/CIO_Big%20Data%20Decisions_2.png?itok=Y5zMHxf8 "CIO_Big Data Decisions_2") + +If you want a basic idea of where containers are headed in the near future, follow the money. There’s a lot of it: 451 Research projects that the overall market for containers will hit roughly [$2.7 billion in 2020][4], a 3.5-fold increase from the $762 million spent on container-related technology in 2016. + +There’s an obvious fundamental factor behind such big numbers: Rapidly increasing containerization. The parallel trend: As container adoption grows, so will container  _orchestration_  adoption. + +As recent survey data from  [_The New Stack_][5]  indicates, container adoption is the most significant catalyst of orchestration adoption: 60 percent of respondents who’ve deployed containers broadly in production report they’re also using Kubernetes widely in production. Another 19 percent of respondents with broad container deployments in production were in the initial stages of broad Kubernetes adoption. Meanwhile, just 5 percent of those in the initial phases of deploying containers in production environments were using Kubernetes broadly – but 58 percent said they were preparing to do so. It’s a chicken-and-egg relationship. + + +Most experts agree that an orchestration tool is essential to the scalable [long-term management of containers][6] – and corresponding developments in the marketplace. “The next trends in container orchestration are all focused on broadening adoption,” says Alex Robinson, software engineer at [Cockroach Labs][7]. + +This is a quickly shifting landscape, one that is just starting to realize its future potential. So we checked in with Robinson and other practitioners to get their boots-on-the-ground perspective on what’s next in container orchestration – and for Kubernetes itself. + +### **Container orchestration shifts to mainstream** + +We’re at the precipice common to most major technology shifts, where we transition from the careful steps of early adoption to cliff-diving into commonplace use. That will create new demand for the plain-vanilla requirements that make mainstream adoption easier, especially in large enterprises. + +“The gold rush phase of early innovation has slowed down and given way to a much stronger focus on stability and usability,” Robinson says. “This means we'll see fewer major announcements of new orchestration systems, and more security options, management tools, and features that make it easier to take advantage of the flexibility already inherent in the major orchestration systems.” + +### **Reduced complexity** + +On a related front, expect an intensifying effort to cut back on the complexity that some organizations face when taking their first plunge into container orchestration. As we’ve covered before, deploying a container might be “easy,” but [managing containers long-term ][8]requires more care. + +“Today, container orchestration is too complex for many users to take full advantage,” says My Karlsson, developer at [Codemill AB][9]. “New users are often struggling just to get single or small-size container configurations running in isolation, especially when applications are not originally designed for it. There are plenty of opportunities to simplify the orchestration of non-trivial applications and make the technology more accessible.” + +### **Increasing focus on hybrid cloud and multi-cloud** + +As adoption of containers and container orchestration grows, more organizations will scale from a starting point of, say, running non-critical workloads in a single environment to more [complex use cases][10] across multiple environments. For many companies, that will mean managing containerized applications (and particularly containerized microservices) across [hybrid cloud][11] and [multi-cloud][12] environments, often globally. + +"Containers and Kubernetes have made hybrid cloud and application portability a reality,” says [Brian Gracely][13], director of [Red Hat][14] OpenShift product strategy. “Combined with the Open Service Broker, we expect to see an explosion of new applications that combine private and public cloud resources." + +“I believe that federation will get a push, enabling much-wanted features such as seamless multi-region and multi-cloud deployments,” says Carlos Sanchez, senior software engineer at [CloudBees][15].  + +**[ Want CIO wisdom on hybrid cloud and multi-cloud strategy? See our related resource, **[**Hybrid Cloud: The IT leader's guide**][16]**. ]** + +### **Continued consolidation of platforms and tools** + +Technology consolidation is common trend; container orchestration is no exception. + +“As containerization goes mainstream, engineers are consolidating on a very small number of technologies to run their [microservices and] containers and Kubernetes will become the dominant container orchestration platform, far outstripping other platforms,” says Ben Newton, analytics lead at [Sumo Logic][17]. “Companies will adopt Kubernetes to drive a cloud-neutral approach as Kubernetes provides a reasonably clear path to reduce dependence on [specific] cloud ecosystems.**”** + +### **Speaking of Kubernetes, what’s next?** + +"Kubernetes is here for the long haul, and the community driving it is doing great job – but there's lots ahead,” says Gadi Naor, CTO and co-founder of [Alcide][18]. Our experts shared several predictions specific to [the increasingly popular Kubernetes platform][19]:  + + **_Gadi Naor at Alcide:_**  “Operators will continue to evolve and mature, to a point where applications running on Kubernetes will become fully self-managed. Deploying and monitoring microservices on top of Kubernetes with [OpenTracing][20] and service mesh frameworks such as [istio][21] will help shape new possibilities.” + + **_Brian Gracely at Red Hat:_**  “Kubernetes continues to expand in terms of the types of applications it can support. When you can run traditional applications, cloud-native applications, big data applications, and HPC or GPU-centric applications on the same platform, it unlocks a ton of architectural flexibility.” + + **_Ben Newton at Sumo Logic: _ “**As Kubernetes becomes more dominant, I would expect to see more normalization of the operational mechanisms – particularly integrations into third-party management and monitoring platforms.” + + **_Carlos Sanchez at CloudBees: _** “In the immediate future there is the ability to run without Docker, using other runtimes...to remove any lock-in. [Editor’s note: [CRI-O][22], for example, offers this ability.] “Also, [look for] storage improvements to support enterprise features like data snapshotting and online volume resizing.” + + + **_Alex Robinson at Cockroach Labs: _ “**One of the bigger developments happening in the Kubernetes community right now is the increased focus on managing [stateful applications][23]. Managing state in Kubernetes right now is very difficult if you aren't running in a cloud that offers remote persistent disks, but there's work being done on multiple fronts [both inside Kubernetes and by external vendors] to improve this.” + +-------------------------------------------------------------------------------- + +via: https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next + +作者:[Kevin Casey ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://enterprisersproject.com/user/kevin-casey +[1]:https://enterprisersproject.com/article/2017/11/kubernetes-numbers-10-compelling-stats +[2]:https://enterprisersproject.com/article/2017/11/how-enterprise-it-uses-kubernetes-tame-container-complexity +[3]:https://enterprisersproject.com/article/2017/11/5-kubernetes-success-tips-start-smart?sc_cid=70160000000h0aXAAQ +[4]:https://451research.com/images/Marketing/press_releases/Application-container-market-will-reach-2-7bn-in-2020_final_graphic.pdf +[5]:https://thenewstack.io/ +[6]:https://enterprisersproject.com/article/2017/10/microservices-and-containers-6-management-tips-long-haul +[7]:https://www.cockroachlabs.com/ +[8]:https://enterprisersproject.com/article/2017/10/microservices-and-containers-6-management-tips-long-haul +[9]:https://codemill.se/ +[10]:https://www.redhat.com/en/challenges/integration?intcmp=701f2000000tjyaAAA +[11]:https://enterprisersproject.com/hybrid-cloud +[12]:https://enterprisersproject.com/article/2017/7/multi-cloud-vs-hybrid-cloud-whats-difference +[13]:https://enterprisersproject.com/user/brian-gracely +[14]:https://www.redhat.com/en +[15]:https://www.cloudbees.com/ +[16]:https://enterprisersproject.com/hybrid-cloud?sc_cid=70160000000h0aXAAQ +[17]:https://www.sumologic.com/ +[18]:http://alcide.io/ +[19]:https://enterprisersproject.com/article/2017/10/how-explain-kubernetes-plain-english +[20]:http://opentracing.io/ +[21]:https://istio.io/ +[22]:http://cri-o.io/ +[23]:https://opensource.com/article/17/2/stateful-applications +[24]:https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next?rate=PBQHhF4zPRHcq2KybE1bQgMkS2bzmNzcW2RXSVItmw8 +[25]:https://enterprisersproject.com/user/kevin-casey diff --git a/sources/tech/20171123 Why microservices are a security issue.md b/sources/tech/20171123 Why microservices are a security issue.md deleted file mode 100644 index d5868faa9e..0000000000 --- a/sources/tech/20171123 Why microservices are a security issue.md +++ /dev/null @@ -1,116 +0,0 @@ -Why microservices are a security issue -============================================================ - -### Maybe you don't want to decompose all your legacy applications into microservices, but you might consider starting with your security functions. - -![Why microservices are a security issue](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003601_05_mech_osyearbook2016_security_cc.png?itok=3V07Lpko "Why microservices are a security issue") -Image by : Opensource.com - -I struggled with writing the title for this post, and I worry that it comes across as clickbait. If you've come to read this because it looked like clickbait, then sorry.[1][5]I hope you'll stay anyway: there are lots of fascinating[2][6] points and many[3][7]footnotes. What I  _didn't_  mean to suggest is that microservices cause [security][15]problems—though like any component, of course, they can—but that microservices are appropriate objects of interest to those involved with security. I'd go further than that: I think they are an excellent architectural construct for those concerned with security. - -And why is that? Well, for those of us with a [systems security][16] bent, the world is an interesting place at the moment. We're seeing a growth in distributed systems, as bandwidth is cheap and latency low. Add to this the ease of deploying to the cloud, and more architects are beginning to realise that they can break up applications, not just into multiple layers, but also into multiple components within the layer. Load balancers, of course, help with this when the various components in a layer are performing the same job, but the ability to expose different services as small components has led to a growth in the design, implementation, and deployment of  _microservices_ . - -More on Microservices - -* [How to explain microservices to your CEO][1] - -* [Free eBook: Microservices vs. service-oriented architecture][2] - -* [Secured DevOps for microservices][3] - -So, [what exactly is a microservice][23]? I quite like [Wikipedia's definition][24], though it's interesting that security isn't mentioned there.[4][17] One of the points that I like about microservices is that, when well-designed, they conform to the first two points of Peter H. Salus' description of the [Unix philosophy][25]: - -1. Write programs that do one thing and do it well. - -2. Write programs to work together. - -3. Write programs to handle text streams, because that is a universal interface. - -The last of the three is slightly less relevant, because the Unix philosophy is generally used to refer to standalone applications, which often have a command instantiation. It does, however, encapsulate one of the basic requirements of microservices: that they must have well-defined interfaces. - -By "well-defined," I don't just mean a description of any externally accessible APIs' methods, but also of the normal operation of the microservice: inputs and outputs—and, if there are any, side-effects. As I described in a previous post, "[5 traits of good systems architecture][18]," data and entity descriptions are crucial if you're going to be able to design a system. Here, in our description of microservices, we get to see why these are so important, because, for me, the key defining feature of a microservices architecture is decomposability. And if you're going to decompose[5][8] your architecture, you need to be very, very clear which "bits" (components) are going to do what. - -And here's where security starts to come in. A clear description of what a particular component should be doing allows you to: - -* Check your design - -* Ensure that your implementation meets the description - -* Come up with reusable unit tests to check functionality - -* Track mistakes in implementation and correct them - -* Test for unexpected outcomes - -* Monitor for misbehaviour - -* Audit actual behaviour for future scrutiny - -Now, are all these things possible in a larger architecture? Yes, they are. But they become increasingly difficult where entities are chained together or combined in more complex configurations. Ensuring  _correct_  implementation and behaviour is much, much easier when you've got smaller pieces to work together. And deriving complex systems behaviours—and misbehaviours—is much more difficult if you can't be sure that the individual components are doing what they ought to be. - -It doesn't stop here, however. As I've mentioned on many [previous occasions][19], writing good security code is difficult.[7][9] Proving that it does what it should do is even more difficult. There is every reason, therefore, to restrict code that has particular security requirements—password checking, encryption, cryptographic key management, authorisation, etc.—to small, well-defined blocks. You can then do all the things that I've mentioned above to try to make sure it's done correctly. - -And yet there's more. We all know that not everybody is great at writing security-related code. By decomposing your architecture such that all security-sensitive code is restricted to well-defined components, you get the chance to put your best security people on that and restrict the danger that J. Random Coder[8][10] will put something in that bypasses or downgrades a key security control. - -It can also act as an opportunity for learning: It's always good to be able to point to a design/implementation/test/monitoring tuple and say: "That's how it should be done. Hear, read, mark, learn, and inwardly digest.[9][11]" - -Should you go about decomposing all of your legacy applications into microservices? Probably not. But given all the benefits you can accrue, you might consider starting with your security functions. - -* * * - -1Well, a little bit—it's always nice to have readers. - -2I know they are: I wrote them. - -3Probably less fascinating. - -4At the time this article was written. It's entirely possible that I—or one of you—may edit the article to change that. - -5This sounds like a gardening term, which is interesting. Not that I really like gardening, but still.[6][12] - -6Amusingly, I first wrote, "…if you're going to decompose your architect…," which sounds like the strapline for an IT-themed murder film. - -7Regular readers may remember a reference to the excellent film  _The Thick of It_ . - -8Other generic personae exist; please take your pick. - -9Not a cryptographic digest: I don't think that's what the original writers had in mind. - - _This article originally appeared on [Alice, Eve, and Bob—a security blog][13] and is republished with permission._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/11/microservices-are-security-issue - -作者:[Mike Bursell ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/mikecamel -[1]:https://blog.openshift.com/microservices-how-to-explain-them-to-your-ceo/?intcmp=7016000000127cYAAQ&src=microservices_resource_menu1 -[2]:https://www.openshift.com/promotions/microservices.html?intcmp=7016000000127cYAAQ&src=microservices_resource_menu2 -[3]:https://opensource.com/business/16/11/secured-devops-microservices?src=microservices_resource_menu3 -[4]:https://opensource.com/article/17/11/microservices-are-security-issue?rate=GDH4xOWsgYsVnWbjEIoAcT_92b8gum8XmgR6U0T04oM -[5]:https://opensource.com/article/17/11/microservices-are-security-issue#1 -[6]:https://opensource.com/article/17/11/microservices-are-security-issue#2 -[7]:https://opensource.com/article/17/11/microservices-are-security-issue#3 -[8]:https://opensource.com/article/17/11/microservices-are-security-issue#5 -[9]:https://opensource.com/article/17/11/microservices-are-security-issue#7 -[10]:https://opensource.com/article/17/11/microservices-are-security-issue#8 -[11]:https://opensource.com/article/17/11/microservices-are-security-issue#9 -[12]:https://opensource.com/article/17/11/microservices-are-security-issue#6 -[13]:https://aliceevebob.com/2017/10/31/why-microservices-are-a-security-issue/ -[14]:https://opensource.com/user/105961/feed -[15]:https://opensource.com/tags/security -[16]:https://aliceevebob.com/2017/03/14/systems-security-why-it-matters/ -[17]:https://opensource.com/article/17/11/microservices-are-security-issue#4 -[18]:https://opensource.com/article/17/10/systems-architect -[19]:https://opensource.com/users/mikecamel -[20]:https://opensource.com/users/mikecamel -[21]:https://opensource.com/users/mikecamel -[22]:https://opensource.com/article/17/11/microservices-are-security-issue#comments -[23]:https://opensource.com/resources/what-are-microservices -[24]:https://en.wikipedia.org/wiki/Microservices -[25]:https://en.wikipedia.org/wiki/Unix_philosophy diff --git a/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md b/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md new file mode 100644 index 0000000000..27379cbe40 --- /dev/null +++ b/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md @@ -0,0 +1,70 @@ +translating by wangy325... + + +Open Source Cloud Skills and Certification Are Key for SysAdmins +============================================================ + + +![os jobs](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/open-house-sysadmin.jpg?itok=i5FHc3lu "os jobs") +Sysadmins with open source skills and certification can command higher pay, according to the 2017 Open Source Jobs Report.[Creative Commons Zero][1] + +System administrator is one of the most common positions employers are looking to fill among 53 percent of respondents to the [2017 Open Source Jobs Report][3]. Consequently, sysadmins with skills in engineering can command higher salaries, as these positions are among the hardest to fill, the report finds. + +Sysadmins are generally responsible for installing, supporting, and maintaining servers or other computer systems, and planning for and responding to service outages and other problems. + +Overall, this year’s report finds the skills most in demand are open source cloud (47 percent), application development (44 percent), Big Data (43 percent) and both DevOps and security (42 percent). + +The report also finds that 58 percent of hiring managers are planning to hire more open source professionals, and 67 percent say hiring of open source professionals will increase more than in other areas of the business. This represents a two-point increase over last year among employers who said open source hiring would be their top field of recruitment. + +At the same time, 89 percent of hiring managers report it is difficult to find open source talent. + +### Why get certified + +The desire for sysadmins is incentivizing hiring managers to offer formal training and/or certifications in the discipline in 53 percent of organizations, compared to 47 percent last year, the Open Source Jobs Report finds. + +IT professionals interested in sysadmin positions should consider Linux certifications. Searches on several of the more well-known job posting sites reveal that the [CompTIA Linux+][4]certification is the top certification for entry-level Linux sysadmin, while [Red Hat Certified Engineer (RHCE)][5] and [Red Hat Certified System Administrator (RHCSA)][6] are the main certifications for higher-level positions. + +In 2016, a sysadmin commanded a salary of $79,583, a change of -0.8 percent from the previous year, according to Dice’s [2017 Tech Salary Survey][7]. The systems architect position paid $125,946, a year-over-year change of -4.7 percent. Yet, the survey observes that “Highly skilled technology professionals remain in the most demand, especially those candidates proficient in the technologies needed to support industry transformation and growth.” + +When it comes to open source skills, HBase (an open-source distributed database), ranked as one that garners among the highest pay for tech pros in the Dice survey. In the networking and database category, the OpenVMS operating system ranked as another high-paying skill. + +### The sysadmin role + +One of a sysadmin’s responsibilities is to be available 24/7 when a problem occurs. The position calls for a mindset that is about “zero-blame, lean, iterative improvement in process or technology,’’ and one that is open to change, writes Paul English, a board member for the League of Professional System Administrators, a non-profit professional association for the advancement of the practice of system administration, in  [opensource.com][8]. He adds that being a sysadmin means “it’s almost a foregone conclusion that you’ll work with open source software like Linux, BSD, and even open source Solaris.” + +Today’s sysadmins will more often work with software rather than hardware, and should be prepared to write small scripts, according to English. + +### Outlook for 2018 + +Expect to see sysadmins among the tech professionals many employers in North America will be hiring in 2018, according to [Robert Half’s 2018 Salary Guide for Technology Professionals][9]. Increasingly, soft skills and leadership qualities are also highly valued. + +“Good listening and critical-thinking skills, which are essential to understanding and resolving customers’ issues and concerns, are important for almost any IT role today, but especially for help desk and desktop support professionals,’’ the report states. + +This jibes with some of the essential skills needed at various stages of the sysadmin position, including strong analytical skills and an ability to solve problems quickly, according to [The Linux Foundation][10]. + +Other skills sysadmins should have as they move up the ladder are: interest in structured approaches to system configuration management; experience in resolving security issues; experience with user identity management; ability to communicate in non-technical terms to non-technical people; and ability to modify system to meet new security requirements. + + _[Download ][11]the full 2017 Open Source Jobs Report now._ + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/open-source-cloud-skills-and-certification-are-key-sysadmins + +作者:[ ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[1]:https://www.linux.com/licenses/category/creative-commons-zero +[2]:https://www.linux.com/files/images/open-house-sysadminjpg +[3]:https://www.linuxfoundation.org/blog/2017-jobs-report-highlights-demand-open-source-skills/ +[4]:https://certification.comptia.org/certifications/linux?tracking=getCertified/certifications/linux.aspx +[5]:https://www.redhat.com/en/services/certification/rhce +[6]:https://www.redhat.com/en/services/certification/rhcsa +[7]:http://marketing.dice.com/pdf/Dice_TechSalarySurvey_2017.pdf?aliId=105832232 +[8]:https://opensource.com/article/17/7/truth-about-sysadmins +[9]:https://www.roberthalf.com/salary-guide/technology +[10]:https://www.linux.com/learn/10-essential-skills-novice-junior-and-senior-sysadmins%20%20 +[11]:http://bit.ly/2017OSSjobsreport diff --git a/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md index d282ef5445..147a2266cc 100644 --- a/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md +++ b/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md @@ -1,6 +1,9 @@ +KeyLD Translating + Photon Could Be Your New Favorite Container OS ============================================================ + ![Photon OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon-linux.jpg?itok=jUFHPR_c "Photon OS") Jack Wallen says Photon OS is an outstanding platform, geared specifically for containers.[Creative Commons Zero][5]Pixabay @@ -106,9 +109,9 @@ Give Photon a try and see if it doesn’t make deploying Docker containers and/o -------------------------------------------------------------------------------- -via: 网址 +via: https://www.linux.com/learn/intro-to-linux/2017/11/photon-could-be-your-new-favorite-container-os -作者:[ JACK WALLEN][a] +作者:[JACK WALLEN ][a] 译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) diff --git a/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md b/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md deleted file mode 100644 index c09d66bc57..0000000000 --- a/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md +++ /dev/null @@ -1,76 +0,0 @@ -AWS to Help Build ONNX Open Source AI Platform -============================================================ -![onnx-open-source-ai-platform](https://www.linuxinsider.com/article_images/story_graphics_xlarge/xl-2017-onnx-1.jpg) - - -Amazon Web Services has become the latest tech firm to join the deep learning community's collaboration on the Open Neural Network Exchange, recently launched to advance artificial intelligence in a frictionless and interoperable environment. Facebook and Microsoft led the effort. - -As part of that collaboration, AWS made its open source Python package, ONNX-MxNet, available as a deep learning framework that offers application programming interfaces across multiple languages including Python, Scala and open source statistics software R. - -The ONNX format will help developers build and train models for other frameworks, including PyTorch, Microsoft Cognitive Toolkit or Caffe2, AWS Deep Learning Engineering Manager Hagay Lupesko and Software Developer Roshani Nagmote wrote in an online post last week. It will let developers import those models into MXNet, and run them for inference. - -### Help for Developers - -Facebook and Microsoft this summer launched ONNX to support a shared model of interoperability for the advancement of AI. Microsoft committed its Cognitive Toolkit, Caffe2 and PyTorch to support ONNX. - -Cognitive Toolkit and other frameworks make it easier for developers to construct and run computational graphs that represent neural networks, Microsoft said. - -Initial versions of [ONNX code and documentation][4] were made available on Github. - -AWS and Microsoft last month announced plans for Gluon, a new interface in Apache MXNet that allows developers to build and train deep learning models. - -Gluon "is an extension of their partnership where they are trying to compete with Google's Tensorflow," observed Aditya Kaul, research director at [Tractica][5]. - -"Google's omission from this is quite telling but also speaks to their dominance in the market," he told LinuxInsider. - -"Even Tensorflow is open source, and so open source is not the big catch here -- but the rest of the ecosystem teaming up to compete with Google is what this boils down to," Kaul said. - -The Apache MXNet community earlier this month introduced version 0.12 of MXNet, which extends Gluon functionality to allow for new, cutting-edge research, according to AWS. Among its new features are variational dropout, which allows developers to apply the dropout technique for mitigating overfitting to recurrent neural networks. - -Convolutional RNN, Long Short-Term Memory and gated recurrent unit cells allow datasets to be modeled using time-based sequence and spatial dimensions, AWS noted. - -### Framework-Neutral Method - -"This looks like a great way to deliver inference regardless of which framework generated a model," said Paul Teich, principal analyst at [Tirias Research][6]. - -"This is basically a framework-neutral way to deliver inference," he told LinuxInsider. - -Cloud providers like AWS, Microsoft and others are under pressure from customers to be able to train on one network while delivering on another, in order to advance AI, Teich pointed out. - -"I see this as kind of a baseline way for these vendors to check the interoperability box," he remarked. - -"Framework interoperability is a good thing, and this will only help developers in making sure that models that they build on MXNet or Caffe or CNTK are interoperable," Tractica's Kaul pointed out. - -As to how this interoperability might apply in the real world, Teich noted that technologies such as natural language translation or speech recognition would require that Alexa's voice recognition technology be packaged and delivered to another developer's embedded environment. - -### Thanks, Open Source - -"Despite their competitive differences, these companies all recognize they owe a significant amount of their success to the software development advancements generated by the open source movement," said Jeff Kaplan, managing director of [ThinkStrategies][7]. - -"The Open Neural Network Exchange is committed to producing similar benefits and innovations in AI," he told LinuxInsider. - -A growing number of major technology companies have announced plans to use open source to speed the development of AI collaboration, in order to create more uniform platforms for development and research. - -AT&T just a few weeks ago announced plans [to launch the Acumos Project][8] with TechMahindra and The Linux Foundation. The platform is designed to open up efforts for collaboration in telecommunications, media and technology.  -![](https://www.ectnews.com/images/end-enn.gif) - --------------------------------------------------------------------------------- - -via: https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html - -作者:[ David Jones ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html#searchbyline -[1]:https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html# -[2]:https://www.linuxinsider.com/perl/mailit/?id=84971 -[3]:https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html -[4]:https://github.com/onnx/onnx -[5]:https://www.tractica.com/ -[6]:http://www.tiriasresearch.com/ -[7]:http://www.thinkstrategies.com/ -[8]:https://www.linuxinsider.com/story/84926.html -[9]:https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html diff --git a/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md b/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md deleted file mode 100644 index dd61ad7a95..0000000000 --- a/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md +++ /dev/null @@ -1,156 +0,0 @@ -translating by lujun9972 -How To Tell If Your Linux Server Has Been Compromised --------------- - -A server being compromised or hacked for the purpose of this guide is an unauthorized person or bot logging into the server in order to use it for their own, usually negative ends. - -Disclaimer: If your server has been compromised by a state organization like the NSA or a serious criminal group then you will not notice any problems and the following techniques will not register their presence. - -However, the majority of compromised servers are carried out by bots i.e. automated attack programs, in-experienced attackers e.g. “script kiddies”, or dumb criminals. - -These sorts of attackers will abuse the server for all it’s worth whilst they have access to it and take few precautions to hide what they are doing. - -### Symptoms of a compromised server - -When a server has been compromised by an in-experienced or automated attacker they will usually do something with it that consumes 100% of a resource. This resource will usually be either the CPU for something like crypt-currency mining or email spamming, or bandwidth for launching a DOS attack. - -This means that the first indication that something is amiss is that the server is “going slow”. This could manifest in the website serving pages much slower than usual, or email taking many minutes to deliver or send. - -So what should you look for? - -### Check 1 - Who’s currently logged in? - -The first thing you should look for is who is currently logged into the server. It is not uncommon to find the attacker actually logged into the server and working on it. - -The shell command to do this is w. Running w gives the following output: - -``` - 08:32:55 up 98 days, 5:43, 2 users, load average: 0.05, 0.03, 0.00 -USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT -root pts/0 113.174.161.1 08:26 0.00s 0.03s 0.02s ssh root@coopeaa12 -root pts/1 78.31.109.1 08:26 0.00s 0.01s 0.00s w - -``` - -One of those IP’s is a UK IP and the second is Vietnamese. That’s probably not a good thing. - -Stop and take a breath, don’t panic and simply kill their SSH connection. Unless you can stop then re-entering the server they will do so quickly and quite likely kick you off and stop you getting back in. - -Please see the What should I do if I’ve been compromised section at the end of this guide no how to proceed if you do find evidence of compromise. - -The whois command can be run on IP addresses and will tell you what all the information about the organization that the IP is registered to, including the country. - -### Check 2 - Who has logged in? - -Linux servers keep a record of which users logged in, from what IP, when and for how long. This information is accessed with the last command. - -The output looks like this: - -``` -root pts/1 78.31.109.1 Thu Nov 30 08:26 still logged in -root pts/0 113.174.161.1 Thu Nov 30 08:26 still logged in -root pts/1 78.31.109.1 Thu Nov 30 08:24 - 08:26 (00:01) -root pts/0 113.174.161.1 Wed Nov 29 12:34 - 12:52 (00:18) -root pts/0 14.176.196.1 Mon Nov 27 13:32 - 13:53 (00:21) - -``` - -There is a mix of my UK IP’s and some Vietnamese ones, with the top two still logged in. If you see any IP’s that are not authorized then refer to the final section. - -The login history is contained in a text file at ~/.bash_history and is therefore easily removable. Often, attackers will simply delete this file to try to cover their tracks. Consequently, if you run last and only see your current login, this is a Bad Sign. - -If there is no login history be very, very suspicious and continue looking for indications of compromise. - -### Check 3 - Review the command history - -This level of attacker will frequently take no precautions to leave no command history so running the history command will show you everything they have done. Be on the lookout for wget or curl commands to download out-of-repo software such as spam bots or crypto miners. - -The command history is contained in the ~/.bash_history file so some attackers will delete this file to cover what they have done. Just as with the login history, if you run history and don’t see anything then the history file has been deleted. Again this is a Bad Sign and you should review the server very carefully. - -### Check 4 - What’s using all the CPU? - -The sorts of attackers that you will encounter usually don’t take too many precautions to hide what they are doing. So they will run processes that consume all the CPU. This generally makes it pretty easy to spot them. Simply run top and look at the highest process. - -This will also show people exploiting your server without having logged in. This could be, for example, someone using an unprotected form-mail script to relay spam. - -If you don’t recognize the top process then either Google its name or investigate what it’s doing with losf or strace. - -To use these tools first copy its PID from top and run: - -``` -strace -p PID - -``` - -This will display all the system calls the process is making. It’s a lot of information but looking through it will give you a good idea what’s going on. - -``` -lsof -p PID - -``` - -This program will list the open files that the process has. Again, this will give you a good idea what it’s doing by showing you what files it is accessing. - -### Check 5 - Review the all the system processes - -If an unauthorized process is not consuming enough CPU to get listed noticeably on top it will still get displayed in a full process listing with ps. My proffered command is ps auxf for providing the most information clearly. - -You should be looking for any processes that you don’t recognize. The more times you run ps on your servers (which is a good habit to get into) the more obvious an alien process will stand out. - -### Check 6 - Review network usage by process - -The command iftop functions like top to show a ranked list of processes that are sending and receiving network data along with their source and destination. A process like a DOS attack or spam bot will immediately show itself at the top of the list. - -### Check 7 - What processes are listening for network connections? - -Often an attacker will install a program that doesn’t do anything except listen on the network port for instructions. This does not consume CPU or bandwidth whilst it is waiting so can get overlooked in the top type commands. - -The commands lsof and netstat will both list all networked processes. I use them with the following options: - -``` -lsof -i - -``` - -``` -netstat -plunt - -``` - -You should look for any process that is listed as in the LISTEN or ESTABLISHED status as these processes are either waiting for a connection (LISTEN) or have a connection open (ESTABLISHED). If you don’t recognize these processes use strace or lsof to try to see what they are doing. - -### What should I do if I’ve been compromised? - -The first thing to do is not to panic, especially if the attacker is currently logged in. You need to be able to take back control of the machine before the attacker is aware that you know about them. If they realize you know about them they may well lock you out of your server and start destroying any assets out of spite. - -If you are not very technical then simply shut down the server. Either from the server itself with shutdown -h now or systemctl poweroff. Or log into your hosting provider’s control panel and shut down the server. Once it’s powered off you can work on the needed firewall rules and consult with your provider in your own time. - -If you’re feeling a bit more confident and your hosting provider has an upstream firewall then create and enable the following two rules in this order: - -1. Allow SSH traffic from only your IP address. - -2. Block everything else, not just SSH but every protocol on every port. - -This will immediately kill their SSH session and give only you access to the server. - -If you don’t have access to an upstream firewall then you will have to create and enable these firewall rules on the server itself and then, when they are in place kill the attacker’s ssh session with the kill command. - -A final method, where available, is to log into the server via an out-of-band connection such as the serial console and stop networking with systemctl stop network.service. This will completely stop any network access so you can now enable the firewall rules in your own time. - -Once you have regained control of the server do not trust it. - -Do not attempt to fix things up and continue using the server. You can never be sure what the attacker did and so you can never sure the server is secure. - -The only sensible course of action is to copy off all the data that you need and start again from a fresh install. - --------------------------------------------------------------------------------- - -via: https://bash-prompt.net/guides/server-hacked/ - -作者:[Elliot Cooper][a] -译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://bash-prompt.net diff --git a/sources/tech/20171128 The politics of the Linux desktop.md b/sources/tech/20171128 The politics of the Linux desktop.md deleted file mode 100644 index c9117dacfe..0000000000 --- a/sources/tech/20171128 The politics of the Linux desktop.md +++ /dev/null @@ -1,110 +0,0 @@ -The politics of the Linux desktop -============================================================ - -### If you're working in open source, why would you use anything but Linux as your main desktop? - - -![The politics of the Linux desktop](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_networks.png?itok=XasNXxKs "The politics of the Linux desktop") -Image by : opensource.com - -At some point in 1997 or 1998—history does not record exactly when—I made the leap from Windows to the Linux desktop. I went through quite a few distributions, from Red Hat to SUSE to Slackware, then Debian, Debian Experimental, and (for a long time thereafter) Ubuntu. When I accepted a role at Red Hat, I moved to Fedora, and migrated both my kids (then 9 and 11) to Fedora as well. - -More Linux resources - -* [What is Linux?][1] - -* [What are Linux containers?][2] - -* [Download Now: Linux commands cheat sheet][3] - -* [Advanced Linux commands cheat sheet][4] - -* [Our latest Linux articles][5] - -For a few years, I kept Windows as a dual-boot option, and then realised that, if I was going to commit to Linux, then I ought to go for it properly. In losing Windows, I didn't miss much; there were a few games that I couldn't play, but it was around the time that the Civilization franchise was embracing Linux, so that kept me happy. - -The move to Linux wasn't plain sailing, by any stretch of the imagination. If you wanted to use fairly new hardware in the early days, you had to first ensure that there were  _any_  drivers for Linux, then learn how to compile and install them. If they were not quite my friends, **lsmod** and **modprobe** became at least close companions. I taught myself to compile a kernel and tweak the options to make use of (sometimes disastrous) new, "EXPERIMENTAL" features as they came out. Early on, I learned the lesson that you should always keep at least one kernel in your [LILO][12] list that you were  _sure_  booted fully. I cursed NVidia and grew horrified by SCSI. I flirted with early journalling filesystem options and tried to work out whether the different preempt parameters made any noticeable difference to my user experience or not. I began to accept that printers would never print—and then they started to. I discovered that the Bluetooth stack suddenly started to connect to things. - -Over the years, using Linux moved from being an uphill struggle to something that just worked. I moved my mother-in-law and then my father over to Linux so I could help administer their machines. And then I moved them off Linux so they could no longer ask me to help administer their machines. - -Over the years, using Linux moved from being an uphill struggle to something that just worked.It wasn't just at home, either: I decided that I would use Linux as my desktop for work, as well. I even made it a condition of employment for at least one role. Linux desktop support in the workplace caused different sets of problems. The first was the "well, you're on your own: we're not going to support you" email from IT support. VPNs were touch and go, but in the end, usually go. - -The biggest hurdle was Microsoft Office, until I discovered [CrossOver][13], which I bought with my own money, and which allowed me to run company-issued copies of Word, PowerPoint, and the rest on my Linux desktop. Fonts were sometimes a problem, and one company I worked for required Microsoft Lync. For this, and for a few other applications, I would sometimes have to run a Windows virtual machine (VM) on my Linux desktop.  Was this a cop out?  Well, a little bit: but I've always tried to restrict my usage of this approach to the bare minimum. - -### But why? - -"Why?" colleagues would ask. "Why do you bother? Why not just run Windows?" - -"Because I enjoy pain," was usually my initial answer, and then the more honest, "because of the principle of the thing." - -So this is it: I believe in open source. We have a number of very, very good desktop-compatible distributions these days, and most of the time they just work. If you use well-known or supported hardware, they're likely to "just work" pretty much as well as the two obvious alternatives, Windows or Mac. And they just work because many people have put much time into using them, testing them, and improving them. So it's not a case of why wouldn't I use Windows or Mac, but why would I ever consider  _not_  using Linux? If, as I do, you believe in open source, and particularly if you work within the open source community or are employed by an open source organisation, I struggle to see why you would even consider not using Linux. - -So it's not a case of why wouldn't I use Windows or Mac, but why would I ever consider not using Linux?I've spoken to people about this (of course I have), and here are the most common reasons—or excuses—I've heard. - -1. I'm more productive on Windows/Mac. - -2. I can't use app X on Linux, and I need it for my job. - -3. I can't game on Linux. - -4. It's what our customers use, so why we would alienate them? - -5. "Open" means choice, and I prefer a proprietary desktop, so I use that. - -Interestingly, I don't hear "Linux isn't good enough" much anymore, because it's manifestly untrue, and I can show that my own experience—and that of many colleagues—belies that. - -### Rebuttals - -If you believe in open source, then I contest that you should take the time to learn how to use a Linux desktop and the associated applications.Let's go through those answers and rebut them. - -1. **I'm more productive on Windows/Mac.** I'm sure you are. Anyone is more productive when they're using a platform or a system they're used to. If you believe in open source, then I contest that you should take the time to learn how to use a Linux desktop and the associated applications. If you're working for an open source organisation, they'll probably help you along, and you're unlikely to find you're much less productive in the long term. And, you know what? If you are less productive in the long term, then get in touch with the maintainers of the apps that are causing you to be less productive and help improve them. You don't have to be a coder. You could submit bug reports, suggest improvements, write documentation, or just test the most recent versions of the software. And then you're helping yourself and the rest of the community. Welcome to open source. - -1. **I can't use app X on Linux, and I need it for my job.** This may be true. But it's probably less true than you think. The people most often saying this with conviction are audio, video, or graphics experts. It was certainly the case for many years that Linux lagged behind in those areas, but have a look and see what the other options are. And try them, even if they're not perfect, and see how you can improve them. Alternatively, use a VM for that particular app. - -1. **I can't game on Linux.** Well, you probably can, but not all the games that you enjoy. This, to be clear, shouldn't really be an excuse not to use Linux for most of what you do. It might be a reason to keep a dual-boot system or to do what I did (after much soul-searching) and buy a games console (because Elite Dangerous really  _doesn't_  work on Linux, more's the pity). It should also be an excuse to lobby for your favourite games to be ported to Linux. - -1. **It's what our customers use, so why would we alienate them?** I don't get this one. Does Microsoft ban visitors with Macs from their buildings? Does Apple ban Windows users? Does Google allow non-Android phones through their doors? You don't kowtow to the majority when you're the little guy or gal; if you're working in open source, surely you should be proud of that. You're not going to alienate your customer—you're really not. - -1. **"Open" means choice, and I prefer a proprietary desktop, so I use that.**Being open certainly does mean you have a choice. You made that choice by working in open source. For many, including me, that's a moral and philosophical choice. Saying you embrace open source, but rejecting it in practice seems mealy mouthed, even insulting. Using openness to justify your choice is the wrong approach. Saying "I prefer a proprietary desktop, and company policy allows me to do so" is better. I don't agree with your decision, but at least you're not using the principle of openness to justify it. - -Is using open source easy? Not always. But it's getting easier. I think that we should stand up for what we believe in, and if you're reading [Opensource.com][14], then you probably believe in open source. And that, I believe, means that you should run Linux as your main desktop. - - _Note: I welcome comments, and would love to hear different points of view. I would ask that comments don't just list application X or application Y as not working on Linux. I concede that not all apps do. I'm more interested in justifications that I haven't covered above, or (perceived) flaws in my argument. Oh, and support for it, of course._ - - -### About the author - - [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/2017-05-10_0129.jpg?itok=Uh-eKFhx)][15] - - Mike Bursell - I've been in and around Open Source since around 1997, and have been running (GNU) Linux as my main desktop at home and work since then: [not always easy][7]...  I'm a security bod and architect, and am currently employed as Chief Security Architect for Red Hat.  I have a blog - "[Alice, Eve & Bob][8]" - where I write (sometimes rather parenthetically) about security.  I live in the UK and... [more about Mike Bursell][9][More about me][10] - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/11/politics-linux-desktop - -作者:[Mike Bursell ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/mikecamel -[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[6]:https://opensource.com/article/17/11/politics-linux-desktop?rate=do69ixoNzK0yg3jzFk0bc6ZOBsIUcqTYv6FwqaVvzUA -[7]:https://opensource.com/article/17/11/politics-linux-desktop -[8]:https://aliceevebob.com/ -[9]:https://opensource.com/users/mikecamel -[10]:https://opensource.com/users/mikecamel -[11]:https://opensource.com/user/105961/feed -[12]:https://en.wikipedia.org/wiki/LILO_(boot_loader) -[13]:https://en.wikipedia.org/wiki/CrossOver_(software) -[14]:https://opensource.com/ -[15]:https://opensource.com/users/mikecamel -[16]:https://opensource.com/users/mikecamel -[17]:https://opensource.com/users/mikecamel -[18]:https://opensource.com/article/17/11/politics-linux-desktop#comments -[19]:https://opensource.com/tags/linux diff --git a/sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md b/sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md deleted file mode 100644 index 479bfb1232..0000000000 --- a/sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md +++ /dev/null @@ -1,142 +0,0 @@ -Why Python and Pygame are a great pair for beginning programmers -============================================================ - -### We look at three reasons Pygame is a good choice for learning to program. - - -![What's the best game platform for beginning programmers?](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_development_programming.png?itok=M_QDcgz5 "What's the best game platform for beginning programmers?") -Image by :  - -opensource.com - -Last month, [Scott Nesbitt][10] wrote about [Mozilla awarding $500K to support open source projects][11]. Phaser, a HTML/JavaScript game platform, was [awarded $50,000][12]. I’ve been teaching Phaser to my pre-teen daughter for a year, and it's one of the best and easiest HTML game development platforms to learn. [Pygame][13], however, may be a better choice for beginners. Here's why. - -### 1\. One long block of code - -Pygame is based on Python, the [most popular language for introductory computer courses][14]. Python is great for writing out ideas in one long block of code. Kids start off with a single file and with a single block of code. Before they can get to functions or classes, they start with code that will soon resemble spaghetti. It’s like finger-painting, as they throw thoughts onto the page. - -More Python Resources - -* [What is Python?][1] - -* [Top Python IDEs][2] - -* [Top Python GUI frameworks][3] - -* [Latest Python content][4] - -* [More developer resources][5] - -This approach to learning works. Kids will naturally start to break things into functions and classes as their code gets more difficult to manage. By learning the syntax of a language like Python prior to learning about functions, the student will gain basic programming knowledge before using global and local scope. - -Most HTML games separate the structure, style, and programming logic into HTML, CSS, and JavaScript to some degree and require knowledge of CSS and HTML. While the separation is better in the long term, it can be a barrier for beginners. Once kids realize that they can quickly build web pages with HTML and CSS, they may get distracted by the visual excitement of colors, fonts, and graphics. Even those who stay focused on JavaScript coding will still need to learn the basic document structure that the JavaScript code sits in. - -### 2\. Global variables are more obvious - -Both Python and JavaScript use dynamically typed variables, meaning that a variable becomes a string, an integer, or float when it’s assigned; however, making mistakes is easier in JavaScript. Similar to typed variables, both JavaScript and Python have global and local variable scopes. In Python, global variables inside of a function are identified with the global keyword. - -Let’s look at the basic [Making your first Phaser game tutorial][15], by Alvin Ourrad and Richard Davey, to understand the challenge of using Phaser to teach programming to beginners. In JavaScript, global variables—variables that can be accessed anywhere in the program—are difficult to keep track of and often are the source of bugs that are challenging to solve. Richard and Alvin are expert programmers and use global variables intentionally to keep things concise. - -``` -var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }); - -function preload() { - -    game.load.image('sky', 'assets/sky.png'); - -} - -var player; -var platforms; - -function create() { -    game.physics.startSystem(Phaser.Physics.ARCADE); -… -``` - -In their Phaser programming book  [_Interphase_ ,][16] Richard Davey and Ilija Melentijevic explain that global variables are commonly used in many Phaser projects because they make it easier to get things done quickly. - -> “If you’ve ever worked on a game of any significant size then this approach is probably already making you cringe slightly... So why do we do it? The reason is simply because it’s the most concise and least complicated way to demonstrate what Phaser can do.” - -Although structuring a Phaser application to use local variables and split things up nicely into separation of concerns is possible, that’s tough for kids to understand when they’re first learning to program. - -If you’re set on teaching your kids to code with JavaScript, or if they already know how to code in another language like Python, a good Phaser course is [The Complete Mobile Game Development Course][17], by [Pablo Farias Navarro][18]. Although the title focuses on mobile games, the actual course focuses on JavaScript and Phaser. The JavaScript and Phaser apps are moved to a mobile phone with [PhoneGap][19]. - -### 3\. Pygame comes with less assembly required - -Thanks to [Python Wheels][20], Pygame is now super [easy to install][21]. You can also install it on Fedora/Red Hat with the **yum** package manager: - -``` -sudo yum install python3-pygame -``` - -See the official [Pygame installation documentation][22] for more information. - -Although Phaser itself is even easier to install, it does require more knowledge to use. As mentioned previously, the student will need to assemble their JavaScript code within an HTML document with some CSS. In addition to the three languages—HTML, CSS, and JavaScript—Phaser also requires the use of Firefox or Chrome development tools and an editor. The most common editors for JavaScript are Sublime, Atom, VS Code (probably in that order). - -Phaser applications will not run if you open the HTML file in a browser directly, due to [same-origin policy][23]. You must run a web server and access the files by connecting to the web server. Fortunately, you don’t need to run Apache on your local computer; you can run something lightweight like [httpster][24] for most projects. - -### Advantages of Phaser and JavaScript - -With all the challenges of JavaScript and Phaser, why am I teaching them? Honestly, I held off for a long time. I worried about students learning variable hoisting and scope. I developed my own curriculum based on Pygame and Python, then I developed one based on Phaser. Eventually, I decided to use Pablo’s pre-made curriculum as a starting point.  - -There are really two reasons that I moved to JavaScript. First, JavaScript has emerged as a serious language used in serious applications. In addition to web applications, it’s used for mobile and server applications. JavaScript is everywhere, and it’s used widely in applications kids see every day. If their friends code in JavaScript, they'll likely want to as well. As I saw the momentum behind JavaScript, I looked into alternatives that could compile into JavaScript, primarily Dart and TypeScript. I didn’t mind the extra conversion step, but I still looked at JavaScript. - -In the end, I chose to use Phaser and JavaScript because I realized that the problems could be solved with JavaScript and a bit of work. High-quality debugging tools and the work of some exceptionally smart people have made JavaScript a language that is both accessible and useful for teaching kids to code. - -### Final word: Python vs. JavaScript - -When people ask me what language to start their kids with, I immediately suggest Python and Pygame. There are tons of great curriculum options, many of which are free. I used ["Making Games with Python & Pygame"][25] by Al Sweigart with my son. I also used  _[Think Python: How to Think Like a Computer Scientist][7]_ by Allen B. Downey. You can get Pygame on your Android phone with [RAPT Pygame][26] by [Tom Rothamel][27]. - -Despite my recommendation, I always suspect that kids soon move to JavaScript. And that’s okay—JavaScript is a mature language with great tools. They’ll have fun with JavaScript and learn a lot. But after years of helping my daughter’s older brother create cool games in Python, I’ll always have an emotional attachment to Python and Pygame. - -### About the author - - [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/craig-head-crop.png?itok=LlMnIq8m)][28] - - Craig Oda - First elected president and co-founder of Tokyo Linux Users Group. Co-author of "Linux Japanese Environment" book published by O'Reilly Japan. Part of core team that established first ISP in Asia. Former VP of product management and product marketing for major Linux company. Partner at Oppkey, developer relations consulting firm in Silicon Valley.[More about me][8] - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/11/pygame - -作者:[Craig Oda ][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/codetricity -[1]:https://opensource.com/resources/python?intcmp=7016000000127cYAAQ -[2]:https://opensource.com/resources/python/ides?intcmp=7016000000127cYAAQ -[3]:https://opensource.com/resources/python/gui-frameworks?intcmp=7016000000127cYAAQ -[4]:https://opensource.com/tags/python?intcmp=7016000000127cYAAQ -[5]:https://developers.redhat.com/?intcmp=7016000000127cYAAQ -[6]:https://opensource.com/article/17/11/pygame?rate=PV7Af00S0QwicZT2iv8xSjJrmJPdpfK1Kcm7LXxl_Xc -[7]:http://greenteapress.com/thinkpython/html/index.html -[8]:https://opensource.com/users/codetricity -[9]:https://opensource.com/user/46031/feed -[10]:https://opensource.com/users/scottnesbitt -[11]:https://opensource.com/article/17/10/news-october-14 -[12]:https://www.patreon.com/photonstorm/posts -[13]:https://www.pygame.org/news -[14]:https://cacm.acm.org/blogs/blog-cacm/176450-python-is-now-the-most-popular-introductory-teaching-language-at-top-u-s-universities/fulltext -[15]:http://phaser.io/tutorials/making-your-first-phaser-game -[16]:https://phaser.io/interphase -[17]:https://academy.zenva.com/product/the-complete-mobile-game-development-course-platinum-edition/ -[18]:https://gamedevacademy.org/author/fariazz/ -[19]:https://phonegap.com/ -[20]:https://pythonwheels.com/ -[21]:https://pypi.python.org/pypi/Pygame -[22]:http://www.pygame.org/wiki/GettingStarted#Pygame%20Installation -[23]:https://blog.chromium.org/2008/12/security-in-depth-local-web-pages.html -[24]:https://simbco.github.io/httpster/ -[25]:https://inventwithpython.com/makinggames.pdf -[26]:https://github.com/renpytom/rapt-pygame-example -[27]:https://github.com/renpytom -[28]:https://opensource.com/users/codetricity -[29]:https://opensource.com/users/codetricity -[30]:https://opensource.com/users/codetricity -[31]:https://opensource.com/article/17/11/pygame#comments -[32]:https://opensource.com/tags/python -[33]:https://opensource.com/tags/programming diff --git a/sources/tech/20171129 10 open source technology trends for 2018.md b/sources/tech/20171129 10 open source technology trends for 2018.md deleted file mode 100644 index eb21c62ec9..0000000000 --- a/sources/tech/20171129 10 open source technology trends for 2018.md +++ /dev/null @@ -1,143 +0,0 @@ -translating by wangy325... - - -10 open source technology trends for 2018 -============================================================ - -### What do you think will be the next open source tech trends? Here are 10 predictions. - -![10 open source technology trends for 2018](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fireworks-newyear-celebrate.png?itok=6gXaznov "10 open source technology trends for 2018") -Image by : [Mitch Bennett][10]. Modified by Opensource.com. [CC BY-SA 4.0][11] - -Technology is always evolving. New developments, such as OpenStack, Progressive Web Apps, Rust, R, the cognitive cloud, artificial intelligence (AI), the Internet of Things, and more are putting our usual paradigms on the back burner. Here is a rundown of the top open source trends expected to soar in popularity in 2018. - -### 1\. OpenStack gains increasing acceptance - -[OpenStack][12] is essentially a cloud operating system that offers admins the ability to provision and control huge compute, storage, and networking resources through an intuitive and user-friendly dashboard. - -Many enterprises are using the OpenStack platform to build and manage cloud computing systems. Its popularity rests on its flexible ecosystem, transparency, and speed. It supports mission-critical applications with ease and lower costs compared to alternatives. But, OpenStack's complex structure and its dependency on virtualization, servers, and extensive networking resources has inhibited its adoption by a wider range of enterprises. Using OpenStack also requires a well-oiled machinery of skilled staff and resources. - -The OpenStack Foundation is working overtime to fill the voids. Several innovations, either released or on the anvil, would resolve many of its underlying challenges. As complexities decrease, OpenStack will surge in acceptance. The fact that OpenStack is already backed by many big software development and hosting companies, in addition to thousands of individual members, makes it the future of cloud computing. - -### 2\. Progressive Web Apps become popular - -[Progressive Web Apps][13] (PWA), an aggregation of technologies, design concepts, and web APIs, offer an app-like experience in the mobile browser. - -Traditional websites suffer from many inherent shortcomings. Apps, although offering a more personal and focused engagement than websites, place a huge demand on resources, including needing to be downloaded upfront. PWA delivers the best of both worlds. It delivers an app-like experience to users while being accessible on browsers, indexable on search engines, and responsive to fit any form factor. Like an app, a PWA updates itself to always display the latest real-time information, and, like a website, it is delivered in an ultra-safe HTTPS model. It runs in a standard container and is accessible to anyone who types in the URL, without having to install anything. - -PWAs perfectly suit the needs of today's mobile users, who value convenience and personal engagement over everything else. That this technology is set to soar in popularity is a no-brainer. - -### 3\. Rust to rule the roost - -Most programming languages come with safety vs. control tradeoffs. [Rust][14] is an exception. The language co-opts extensive compile-time checking to offer 100% control without compromising safety. The last [Pwn2Own][15] competition threw up many serious vulnerabilities in Firefox on account of its underlying C++ language. If Firefox had been written in Rust, many of those errors would have manifested as compile-time bugs and resolved before the product rollout stage. - -Rust's unique approach of built-in unit testing has led developers to consider it a viable first-choice open source language. It offers an effective alternative to languages such as C and Python to write secure code without sacrificing expressiveness. Rust has bright days ahead in 2018. - -### 4\. R user community grows - -The [R][16] programming language, a GNU project, is associated with statistical computing and graphics. It offers a wide array of statistical and graphical techniques and is extensible to boot. It starts where [S][17] ends. With the S language already the vehicle of choice for research in statistical methodology, R offers a viable open source route for data manipulation, calculation, and graphical display. An added benefit is R's attention to detail and care for the finer nuances. - -Like Rust, R's fortunes are on the rise. - -### 5\. XaaS expands in scope - -XaaS, an acronym for "anything as a service," stands for the increasing number of services delivered over the internet, rather than on premises. Although software as a service (SaaS), infrastructure as a service (IaaS), and platform as a service (PaaS) are well-entrenched, new cloud-based models, such as network as a service (NaaS), storage as a service (SaaS or StaaS), monitoring as a service (MaaS), and communications as a service (CaaS), are soaring in popularity. A world where anything and everything is available "as a service" is not far away. - -The scope of XaaS now extends to bricks-and-mortar businesses, as well. Good examples are companies such as Uber and Lyft leveraging digital technology to offer transportation as a service and Airbnb offering accommodations as a service. - -High-speed networks and server virtualization that make powerful computing affordable have accelerated the popularity of XaaS, to the point that 2018 may become the "year of XaaS." The unmatched flexibility, agility, and scalability will propel the popularity of XaaS even further. - -### 6\. Containers gain even more acceptance - -Container technology is the approach of packaging pieces of code in a standardized way so they can be "plugged and run" quickly in any environment. Container technology allows enterprises to cut costs and implementation times. While the potential of containers to revolutionize IT infrastructure has been evident for a while, actual container use has remained complex. - -Container technology is still evolving, and the complexities associated with the technology decrease with every advancement. The latest developments make containers quite intuitive and as easy as using a smartphone, not to mention tuned for today's needs, where speed and agility can make or break a business. - -### 7\. Machine learning and artificial intelligence expand in scope - -[Machine learning and AI][18] give machines the ability to learn and improve from experience without a programmer explicitly coding the instruction. - -These technologies are already well entrenched, with several open source technologies leveraging them for cutting-edge services and applications. - -[Gartner predicts][19] the scope of machine learning and artificial intelligence will expand in 2018\. Several greenfield areas, such as data preparation, integration, algorithm selection, training methodology selection, and model creation are all set for big-time enhancements through the infusion of machine learning. - -New open source intelligent solutions are set to change the way people interact with systems and transform the very nature of work. - -* Conversational platforms, such as chatbots, make the question-and-command experience, where a user asks a question and the platform responds, the default medium of interacting with machines. - -* Autonomous vehicles and drones, fancy fads today, are expected to become commonplace by 2018. - -* The scope of immersive experience will expand beyond video games and apply to real-life scenarios such as design, training, and visualization processes. - -### 8\. Blockchain becomes mainstream - -Blockchain has come a long way from Bitcoin. The technology is already in widespread use in finance, secure voting, authenticating academic credentials, and more. In the coming year, healthcare, manufacturing, supply chain logistics, and government services are among the sectors most likely to embrace blockchain technology. - -Blockchain distributes digital information. The information resides on millions of nodes, in shared and reconciled databases. The fact that it's not controlled by any single authority and has no single point of failure makes it very robust, transparent, and incorruptible. It also solves the threat of a middleman manipulating the data. Such inherent strengths account for blockchain's soaring popularity and explain why it is likely to emerge as a mainstream technology in the immediate future. - -### 9\. Cognitive cloud moves to center stage - -Cognitive technologies, such as machine learning and artificial intelligence, are increasingly used to reduce complexity and personalize experiences across multiple sectors. One case in point is gamification apps in the financial sector, which offer investors critical investment insights and reduce the complexities of investment models. Digital trust platforms reduce the identity-verification process for financial institutions by about 80%, improving compliance and reducing chances of fraud. - -Such cognitive cloud technologies are now moving to the cloud, making it even more potent and powerful. IBM Watson is the most well-known example of the cognitive cloud in action. IBM's UIMA architecture was made open source and is maintained by the Apache Foundation. DARPA's DeepDive project mirrors Watson's machine learning abilities to enhance decision-making capabilities over time by learning from human interactions. OpenCog, another open source platform, allows developers and data scientists to develop artificial intelligence apps and programs. - -Considering the high stakes of delivering powerful and customized experiences, these cognitive cloud platforms are set to take center stage over the coming year. - -### 10\. The Internet of Things connects more things - -At its core, the Internet of Things (IoT) is the interconnection of devices through embedded sensors or other computing devices that enable the devices (the "things") to send and receive data. IoT is already predicted to be the next big major disruptor of the tech space, but IoT itself is in a continuous state of flux. - -One innovation likely to gain widespread acceptance within the IoT space is Autonomous Decentralized Peer-to-Peer Telemetry ([ADEPT][20]), which is propelled by IBM and Samsung. It uses a blockchain-type technology to deliver a decentralized network of IoT devices. Freedom from a central control system facilitates autonomous communications between "things" in order to manage software updates, resolve bugs, manage energy, and more. - -### Open source drives innovation - -Digital disruption is the norm in today's tech-centric era. Within the technology space, open source is now pervasive, and in 2018, it will be the driving force behind most of the technology innovations. - -Which open source trends and technologies would you add to this list? Let us know in the comments. - -### Topics - - [Business][25][Yearbook][26][2017 Open Source Yearbook][27] - -### About the author - - [![Sreejith@Fingent](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/sreejith.jpg?itok=sdYNV49V)][21] Sreejith - I have been programming since 2000, and professionally since 2007\. I currently lead the Open Source team at [Fingent][6] as we work on different technology stacks, ranging from the "boring"(read tried and trusted) to the bleeding edge. I like building, tinkering with and breaking things, not necessarily in that order. Hit me up at: [https://www.linkedin.com/in/futuregeek/][7][More about me][8] - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/11/10-open-source-technology-trends-2018 - -作者:[Sreejith ][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/sreejith -[1]:https://opensource.com/resources/what-is-openstack?intcmp=7016000000127cYAAQ -[2]:https://opensource.com/resources/openstack/tutorials?intcmp=7016000000127cYAAQ -[3]:https://opensource.com/tags/openstack?intcmp=7016000000127cYAAQ -[4]:https://www.rdoproject.org/?intcmp=7016000000127cYAAQ -[5]:https://opensource.com/article/17/11/10-open-source-technology-trends-2018?rate=GJqOXhiWvZh0zZ6WVTUzJ2TDJBpVpFhngfuX9V-dz4I -[6]:https://www.fingent.com/ -[7]:https://www.linkedin.com/in/futuregeek/ -[8]:https://opensource.com/users/sreejith -[9]:https://opensource.com/user/185026/feed -[10]:https://www.flickr.com/photos/mitchell3417/9206373620 -[11]:https://creativecommons.org/licenses/by-sa/4.0/ -[12]:https://www.openstack.org/ -[13]:https://developers.google.com/web/progressive-web-apps/ -[14]:https://www.rust-lang.org/ -[15]:https://en.wikipedia.org/wiki/Pwn2Own -[16]:https://en.wikipedia.org/wiki/R_(programming_language) -[17]:https://en.wikipedia.org/wiki/S_(programming_language) -[18]:https://opensource.com/tags/artificial-intelligence -[19]:https://sdtimes.com/gartners-top-10-technology-trends-2018/ -[20]:https://insights.samsung.com/2016/03/17/block-chain-mobile-and-the-internet-of-things/ -[21]:https://opensource.com/users/sreejith -[22]:https://opensource.com/users/sreejith -[23]:https://opensource.com/users/sreejith -[24]:https://opensource.com/article/17/11/10-open-source-technology-trends-2018#comments -[25]:https://opensource.com/tags/business -[26]:https://opensource.com/tags/yearbook -[27]:https://opensource.com/yearbook/2017 diff --git a/sources/tech/20171129 5 best practices for getting started with DevOps.md b/sources/tech/20171129 5 best practices for getting started with DevOps.md deleted file mode 100644 index 962f37aaf4..0000000000 --- a/sources/tech/20171129 5 best practices for getting started with DevOps.md +++ /dev/null @@ -1,94 +0,0 @@ -5 best practices for getting started with DevOps -============================================================ - -### Are you ready to implement DevOps, but don't know where to begin? Try these five best practices. - - -![5 best practices for getting started with DevOps](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/devops-gears.png?itok=rUejbLQX "5 best practices for getting started with DevOps") -Image by :  - -[Andrew Magill][8]. Modified by Opensource.com. [CC BY 4.0][9] - -DevOps often stymies early adopters with its ambiguity, not to mention its depth and breadth. By the time someone buys into the idea of DevOps, their first questions usually are: "How do I get started?" and "How do I measure success?" These five best practices are a great road map to starting your DevOps journey. - -### 1\. Measure all the things - -You don't know for sure that your efforts are even making things better unless you can quantify the outcomes. Are my features getting out to customers more rapidly? Are fewer defects escaping to them? Are we responding to and recovering more quickly from failure? - -Before you change anything, think about what kinds of outcomes you expect from your DevOps transformation. When you're further into your DevOps journey, you'll enjoy a rich array of near-real-time reports on everything about your service. But consider starting with these two metrics: - -* **Time to market** measures the end-to-end, often customer-facing, business experience. It usually begins when a feature is formally conceived and ends when the customer can consume the feature in production. Time to market is not mainly an engineering team metric; more importantly it shows your business' complete end-to-end efficiency in bringing valuable new features to market and isolates opportunities for system-wide improvement. - -* **Cycle time** measures the engineering team process. Once work on a new feature starts, when does it become available in production? This metric is very useful for understanding the efficiency of the engineering team and isolating opportunities for team-level improvement. - -### 2\. Get your process off the ground - -DevOps success requires an organization to put a regular (and hopefully effective) process in place and relentlessly improve upon it. It doesn't have to start out being effective, but it must be a regular process. Usually that it's some flavor of agile methodology like Scrum or Scrumban; sometimes it's a Lean derivative. Whichever way you go, pick a formal process, start using it, and get the basics right. - -Regular inspect-and-adapt behaviors are key to your DevOps success. Make good use of opportunities like the stakeholder demo, team retrospectives, and daily standups to find opportunities to improve your process. - -A lot of your DevOps success hinges on people working effectively together. People on a team need to work from a common process that they are empowered to improve upon. They also need regular opportunities to share what they are learning with other stakeholders, both upstream and downstream, in the process. - -Good process discipline will help your organization consume the other benefits of DevOps at the great speed that comes as your success builds. - -Although it's common for more development-oriented teams to successfully adopt processes like Scrum, operations-focused teams (or others that are more interrupt-driven) may opt for a process with a more near-term commitment horizon, such as Kanban. - -### 3\. Visualize your end-to-end workflow - -There is tremendous power in being able to see who's working on what part of your service at any given time. Visualizing your workflow will help people know what they need to work on next, how much work is in progress, and where the bottlenecks are in the process. - -You can't effectively limit work in process until you can see it and quantify it. Likewise, you can't effectively eliminate bottlenecks until you can clearly see them. - -Visualizing the entire workflow will help people in all parts of the organization understand how their work contributes to the success of the whole. It can catalyze relationship-building across organizational boundaries to help your teams collaborate more effectively towards a shared sense of success. - -### 4\. Continuous all the things - -DevOps promises a dizzying array of compelling automation. But Rome wasn't built in a day. One of the first areas you can focus your efforts on is [continuous integration][10] (CI). But don't stop there; you'll want to follow quickly with [continuous delivery][11] (CD) and eventually continuous deployment. - -Your CD pipeline is your opportunity to inject all manner of automated quality testing into your process. The moment new code is committed, your CD pipeline should run a battery of tests against the code and the successfully built artifact. The artifact that comes out at the end of this gauntlet is what progresses along your process until eventually it's seen by customers in production. - -Another "continuous" that doesn't get enough attention is continuous improvement. That's as simple as setting some time aside each day to ask your colleagues: "What small thing can we do today to get better at how we do our work?" These small, daily changes compound over time into more profound results. You'll be pleasantly surprised! But it also gets people thinking all the time about how to improve things. - -### 5\. Gherkinize - -Fostering more effective communication across your organization is crucial to fostering the sort of systems thinking prevalent in successful DevOps journeys. One way to help that along is to use a shared language between the business and the engineers to express the desired acceptance criteria for new features. A good product manager can learn [Gherkin][12] in a day and begin using it to express acceptance criteria in an unambiguous, structured form of plain English. Engineers can use this Gherkinized acceptance criteria to write acceptance tests against the criteria, and then develop their feature code until the tests pass. This is a simplification of [acceptance test-driven development][13](ATDD) that can also help kick start your DevOps culture and engineering practice. - -### Start on your journey - -Don't be discouraged by getting started with your DevOps practice. It's a journey. And hopefully these five ideas give you solid ways to get started. - - -### About the author - - [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/headshot_4.jpg?itok=jntfDCfX)][14] - - Magnus Hedemark - Magnus has been in the IT industry for over 20 years, and a technology enthusiast for most of his life. He's presently Manager of DevOps Engineering at UnitedHealth Group. In his spare time, Magnus enjoys photography and paddling canoes. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/11/5-keys-get-started-devops - -作者:[Magnus Hedemark ][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/magnus919 -[1]:https://opensource.com/tags/devops?src=devops_resource_menu1 -[2]:https://opensource.com/resources/devops?src=devops_resource_menu2 -[3]:https://www.openshift.com/promotions/devops-with-openshift.html?intcmp=7016000000127cYAAQ&src=devops_resource_menu3 -[4]:https://enterprisersproject.com/article/2017/5/9-key-phrases-devops?intcmp=7016000000127cYAAQ&src=devops_resource_menu4 -[5]:https://www.redhat.com/en/insights/devops?intcmp=7016000000127cYAAQ&src=devops_resource_menu5 -[6]:https://opensource.com/article/17/11/5-keys-get-started-devops?rate=oEOzMXx1ghbkfl2a5ae6AnvO88iZ3wzkk53K2CzbDWI -[7]:https://opensource.com/user/25739/feed -[8]:https://ccsearch.creativecommons.org/image/detail/7qRx_yrcN5isTMS0u9iKMA== -[9]:https://creativecommons.org/licenses/by-sa/4.0/ -[10]:https://martinfowler.com/articles/continuousIntegration.html -[11]:https://martinfowler.com/bliki/ContinuousDelivery.html -[12]:https://cucumber.io/docs/reference -[13]:https://en.wikipedia.org/wiki/Acceptance_test%E2%80%93driven_development -[14]:https://opensource.com/users/magnus919 -[15]:https://opensource.com/users/magnus919 -[16]:https://opensource.com/users/magnus919 -[17]:https://opensource.com/tags/devops diff --git a/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md b/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md deleted file mode 100644 index d3ba75da14..0000000000 --- a/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md +++ /dev/null @@ -1,185 +0,0 @@ -Translating by filefi - - -How to Install and Use Wireshark on Debian 9 / Ubuntu 16.04 / 17.10 -============================================================ - -by [Pradeep Kumar][1] · Published November 29, 2017 · Updated November 29, 2017 - - [![wireshark-Debian-9-Ubuntu 16.04 -17.10](https://www.linuxtechi.com/wp-content/uploads/2017/11/wireshark-Debian-9-Ubuntu-16.04-17.10.jpg)][2] - -Wireshark is free and open source, cross platform, GUI based Network packet analyzer that is available for Linux, Windows, MacOS, Solaris etc. It captures network packets in real time & presents them in human readable format. Wireshark allows us to monitor the network packets up to microscopic level. Wireshark also has a command line utility called ‘tshark‘ that performs the same functions as Wireshark but through terminal & not through GUI. - -Wireshark can be used for network troubleshooting, analyzing, software & communication protocol development & also for education purposed. Wireshark uses a library called ‘pcap‘ for capturing the network packets. - -Wireshark comes with a lot of features & some those features are; - -* Support for a hundreds of protocols for inspection, - -* Ability to capture packets in real time & save them for later offline analysis, - -* A number of filters to analyzing data, - -* Data captured can be compressed & uncompressed on the fly, - -* Various file formats for data analysis supported, output can also be saved to XML, CSV, plain text formats, - -* data can be captured from a number of interfaces like ethernet, wifi, bluetooth, USB, Frame relay , token rings etc. - -In this article, we will discuss how to install Wireshark on Ubuntu/Debain machines & will also learn to use Wireshark for capturing network packets. - -#### Installation of Wireshark on Ubuntu 16.04 / 17.10 - -Wireshark is available with default Ubuntu repositories & can be simply installed using the following command. But there might be chances that you will not get the latest version of wireshark. - -``` -linuxtechi@nixworld:~$ sudo apt-get update -linuxtechi@nixworld:~$ sudo apt-get install wireshark -y -``` - -So to install latest version of wireshark we have to enable or configure official wireshark repository. - -Use the beneath commands one after the another to configure repository and to install latest version of Wireshark utility - -``` -linuxtechi@nixworld:~$ sudo add-apt-repository ppa:wireshark-dev/stable -linuxtechi@nixworld:~$ sudo apt-get update -linuxtechi@nixworld:~$ sudo apt-get install wireshark -y -``` - -Once the Wireshark is installed execute the below command so that non-root users can capture live packets of interfaces, - -``` -linuxtechi@nixworld:~$ sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' /usr/bin/dumpcap -``` - -#### Installation of Wireshark on Debian 9 - -Wireshark package and its dependencies are already present in the default debian 9 repositories, so to install latest and stable version of Wireshark on Debian 9, use the following command: - -``` -linuxtechi@nixhome:~$ sudo apt-get update -linuxtechi@nixhome:~$ sudo apt-get install wireshark -y -``` - -During the installation, it will prompt us to configure dumpcap for non-superusers, - -Select ‘yes’ and then hit enter. - - [![Configure-Wireshark-Debian9](https://www.linuxtechi.com/wp-content/uploads/2017/11/Configure-Wireshark-Debian9-1024x542.jpg)][3] - -Once the Installation is completed, execute the below command so that non-root users can also capture the live packets of the interfaces. - -``` -linuxtechi@nixhome:~$ sudo chmod +x /usr/bin/dumpcap -``` - -We can also use the latest source package to install the wireshark on Ubuntu/Debain & many other Linux distributions. - -#### Installing Wireshark using source code on Debian / Ubuntu Systems - -Firstly download the latest source package (which is 2.4.2 at the time for writing this article), use the following command, - -``` -linuxtechi@nixhome:~$ wget https://1.as.dl.wireshark.org/src/wireshark-2.4.2.tar.xz -``` - -Next extract the package & enter into the extracted directory, - -``` -linuxtechi@nixhome:~$ tar -xf wireshark-2.4.2.tar.xz -C /tmp -linuxtechi@nixhome:~$ cd /tmp/wireshark-2.4.2 -``` - -Now we will compile the code with the following commands, - -``` -linuxtechi@nixhome:/tmp/wireshark-2.4.2$ ./configure --enable-setcap-install -linuxtechi@nixhome:/tmp/wireshark-2.4.2$ make -``` - -Lastly install the compiled packages to install Wireshark on the system, - -``` -linuxtechi@nixhome:/tmp/wireshark-2.4.2$ sudo make install -linuxtechi@nixhome:/tmp/wireshark-2.4.2$ sudo ldconfig -``` - -Upon installation a separate group for Wireshark will also be created, we will now add our user to the group so that it can work with wireshark otherwise you might get ‘permission denied‘ error when starting wireshark. - -To add the user to the wireshark group, execute the following command, - -``` -linuxtechi@nixhome:~$ sudo usermod -a -G wireshark linuxtechi -``` - -Now we can start wireshark either from GUI Menu or from terminal with this command, - -``` -linuxtechi@nixhome:~$ wireshark -``` - -#### Access Wireshark on Debian 9 System - - [![Access-wireshark-debian9](https://www.linuxtechi.com/wp-content/uploads/2017/11/Access-wireshark-debian9-1024x664.jpg)][4] - -Click on Wireshark icon - - [![Wireshark-window-debian9](https://www.linuxtechi.com/wp-content/uploads/2017/11/Wireshark-window-debian9-1024x664.jpg)][5] - -#### Access Wireshark on Ubuntu 16.04 / 17.10 - - [![Access-wireshark-Ubuntu](https://www.linuxtechi.com/wp-content/uploads/2017/11/Access-wireshark-Ubuntu-1024x664.jpg)][6] - -Click on Wireshark icon - - [![Wireshark-window-Ubuntu](https://www.linuxtechi.com/wp-content/uploads/2017/11/Wireshark-window-Ubuntu-1024x664.jpg)][7] - -#### Capturing and Analyzing packets - -Once the wireshark has been started, we should be presented with the wireshark window, example is shown above for Ubuntu and Debian system. - - [![wireshark-Linux-system](https://www.linuxtechi.com/wp-content/uploads/2017/11/wireshark-Linux-system.jpg)][8] - -All these are the interfaces from where we can capture the network packets. Based on the interfaces you have on your system, this screen might be different for you. - -We are selecting ‘enp0s3’ for capturing the network traffic for that inteface. After selecting the inteface, network packets for all the devices on our network start to populate (refer to screenshot below) - - [![Capturing-Packet-from-enp0s3-Ubuntu-Wireshark](https://www.linuxtechi.com/wp-content/uploads/2017/11/Capturing-Packet-from-enp0s3-Ubuntu-Wireshark-1024x727.jpg)][9] - -First time we see this screen we might get overwhelmed by the data that is presented in this screen & might have thought how to sort out this data but worry not, one the best features of Wireshark is its filters. - -We can sort/filter out the data based on IP address, Port number, can also used source & destination filters, packet size etc & can also combine 2 or more filters together to create more comprehensive searches. We can either write our filters in ‘Apply a Display Filter‘ tab , or we can also select one of already created rules. To select pre-built filter, click on ‘flag‘ icon , next to ‘Apply a Display Filter‘ tab, - - [![Filter-in-wireshark-Ubuntu](https://www.linuxtechi.com/wp-content/uploads/2017/11/Filter-in-wireshark-Ubuntu-1024x727.jpg)][10] - -We can also filter data based on the color coding, By default, light purple is TCP traffic, light blue is UDP traffic, and black identifies packets with errors , to see what these codes mean, click View -> Coloring Rules, also we can change these codes. - - [![Packet-Colouring-Wireshark](https://www.linuxtechi.com/wp-content/uploads/2017/11/Packet-Colouring-Wireshark-1024x682.jpg)][11] - -After we have the results that we need, we can then click on any of the captured packets to get more details about that packet, this will show all the data about that network packet. - -Wireshark is an extremely powerful tool takes some time to getting used to & make a command over it, this tutorial will help you get started. Please feel free to drop in your queries or suggestions in the comment box below. - --------------------------------------------------------------------------------- - -via: https://www.linuxtechi.com - -作者:[Pradeep Kumar][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linuxtechi.com/author/pradeep/ -[1]:https://www.linuxtechi.com/author/pradeep/ -[2]:https://www.linuxtechi.com/wp-content/uploads/2017/11/wireshark-Debian-9-Ubuntu-16.04-17.10.jpg -[3]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Configure-Wireshark-Debian9.jpg -[4]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Access-wireshark-debian9.jpg -[5]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Wireshark-window-debian9.jpg -[6]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Access-wireshark-Ubuntu.jpg -[7]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Wireshark-window-Ubuntu.jpg -[8]:https://www.linuxtechi.com/wp-content/uploads/2017/11/wireshark-Linux-system.jpg -[9]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Capturing-Packet-from-enp0s3-Ubuntu-Wireshark.jpg -[10]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Filter-in-wireshark-Ubuntu.jpg -[11]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Packet-Colouring-Wireshark.jpg diff --git a/sources/tech/20171129 Inside AGL Familiar Open Source Components Ease Learning Curve.md b/sources/tech/20171129 Inside AGL Familiar Open Source Components Ease Learning Curve.md deleted file mode 100644 index 9eee39888a..0000000000 --- a/sources/tech/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/tech/20171129 Interactive Workflows for Cpp with Jupyter.md b/sources/tech/20171129 Interactive Workflows for Cpp with Jupyter.md deleted file mode 100644 index 395c901618..0000000000 --- a/sources/tech/20171129 Interactive Workflows for Cpp with Jupyter.md +++ /dev/null @@ -1,301 +0,0 @@ -Interactive Workflows for C++ with Jupyter -============================================================ - -Scientists, educators and engineers not only use programming languages to build software systems, but also in interactive workflows, using the tools available to  _explore _ a problem and  _reason _ about it. - -Running some code, looking at a visualization, loading data, and running more code. Quick iteration is especially important during the exploratory phase of a project. - -For this kind of workflow, users of the C++ programming language currently have no choice but to use a heterogeneous set of tools that don’t play well with each other, making the whole process cumbersome, and difficult to reproduce. - - _We currently lack a good story for interactive computing in C++_ . - -In our opinion, this hurts the productivity of C++ developers: - -* Most of the progress made in software projects comes from incrementalism. Obstacles to fast iteration hinder progress. - -* This also makes C++ more difficult to teach. The first hours of a C++ class are rarely rewarding as the students must learn how to set up a small project before writing any code. And then, a lot more time is required before their work can result in any visual outcome. - -### Project Jupyter and Interactive Computing - - - -![](https://cdn-images-1.medium.com/max/1200/1*wOHyKy6fl3ltcBMNpCvC6Q.png) - -The goal of Project Jupyter is to provide a consistent set of tools for scientific computing and data science workflows, from the exploratory phase of the analysis to the presentation and the sharing of the results. The Jupyter stack was designed to be agnostic of the programming language, and also to allow alternative implementations of any component of the layered architecture (back-ends for programming languages, custom renderers for file types associated with Jupyter). The stack consists of - -* a low-level specification for messaging protocols, standardized file formats, - -* a reference implementation of these standards, - -* applications built on the top of these libraries: the Notebook, JupyterLab, Binder, JupyterHub - -* and visualization libraries integrated into the Notebook and JupyterLab. - -Adoption of the Jupyter ecosystem has skyrocketed in the past years, with millions of users worldwide, over a million Jupyter notebooks shared on GitHub and large-scale deployments of Jupyter in universities, companies and high-performance computing centers. - -### Jupyter and C++ - -One of the main extension points of the Jupyter stack is the  _kernel_ , the part of the infrastructure responsible for executing the user’s code. Jupyter kernels exist for [numerous programming languages][14]. - -Most Jupyter kernels are implemented in the target programming language: the reference implementation [ipykernel][15] in Python, [IJulia][16] in Julia, leading to a duplication of effort for the implementation of the protocol. A common denominator to a lot of these interpreted languages is that the interpreter generally exposes a C API, allowing the embedding into a native application. In an effort to consolidate these commonalities and save work for future kernel builders, we developed  _xeus_ . - - - -![](https://cdn-images-1.medium.com/max/1200/1*TKrPv5AvFM3NJ6a7VMu8Tw.png) - -[Xeus ][17]is a C++ implementation of the Jupyter kernel protocol. It is not a kernel itself but a library that facilitates the authoring of kernels, and other applications making use of the Jupyter kernel protocol. - -A typical kernel implementation using xeus would in fact make use of the target interpreter _ as a library._ - -There are a number of benefits of using xeus over implementing your kernel in the target language: - -* Xeus provides a complete implementation of the protocol, enabling a lot of features from the start for kernel authors, who only need to deal with the language bindings. - -* Xeus-based kernels can very easily provide a back-end for Jupyter interactive widgets. - -* Finally, xeus can be used to implement kernels for domain-specific languages such as SQL flavors. Existing approaches use a Python wrapper. With xeus, the resulting kernel won't require Python at run-time, leading to large performance benefits. - - - -![](https://cdn-images-1.medium.com/max/1200/1*Cr_cfHdrgFXHlO15qdNK7w.png) - -Interpreted C++ is already a reality at CERN with the [Cling][18]C++ interpreter in the context of the [ROOT][19] data analysis environment. - -As a first example for a kernel based on xeus, we have implemented [xeus-cling][20], a pure C++ kernel. - - - -![](https://cdn-images-1.medium.com/max/1600/1*NnjISpzZtpy5TOurg0S89A.gif) -Redirection of outputs to the Jupyter front-end, with different styling in the front-end. - -Complex features of the C++ programming language such as, polymorphism, templates, lambdas, are supported by the cling interpreter, making the C++ Jupyter notebook a great prototyping and learning platform for the C++ users. See the image below for a demonstration: - - - -![](https://cdn-images-1.medium.com/max/1600/1*lGVLY4fL1ytMfT-eWtoXkw.gif) -Features of the C++ programming language supported by the cling interpreter - -Finally, xeus-cling supports live quick-help, fetching the content on [cppreference][21] in the case of the standard library. - - - -![](https://cdn-images-1.medium.com/max/1600/1*Igegq0xBebuJV8hy0TGpfg.png) -Live help for the C++standard library in the Jupyter notebook - -> We realized that we started using the C++ kernel ourselves very early in the development of the project. For quick experimentation, or reproducing bugs. No need to set up a project with a cpp file and complicated project settings for finding the dependencies… Just write some code and hit Shift+Enter. - -Visual output can also be displayed using the rich display mechanism of the Jupyter protocol. - - - -![](https://cdn-images-1.medium.com/max/1600/1*t_9qAXtdkSXr-0tO9VvOzQ.png) -Using Jupyter's rich display mechanism to display an image inline in the notebook - - -![](https://cdn-images-1.medium.com/max/1200/1*OVfmXFAbfjUtGFXYS9fKRA.png) - -Another important feature of the Jupyter ecosystem are the [Jupyter Interactive Widgets][22]. They allow the user to build graphical interfaces and interactive data visualization inline in the Jupyter notebook. Moreover it is not just a collection of widgets, but a framework that can be built upon, to create arbitrary visual components. Popular interactive widget libraries include - -* [bqplot][1] (2-D plotting with d3.js) - -* [pythreejs][2] (3-D scene visualization with three.js) - -* [ipyleaflet][3] (maps visualization with leaflet.js) - -* [ipyvolume][4] (3-D plotting and volume rendering with three.js) - -* [nglview][5] (molecular visualization) - -Just like the rest of the Jupyter ecosystem, Jupyter interactive widgets were designed as a language-agnostic framework. Other language back-ends can be created reusing the front-end component, which can be installed separately. - -[xwidgets][23], which is still at an early stage of development, is a native C++ implementation of the Jupyter widgets protocol. It already provides an implementation for most of the widget types available in the core Jupyter widgets package. - - - -![](https://cdn-images-1.medium.com/max/1600/1*ro5Ggdstnf0DoqhTUWGq3A.gif) -C++ back-end to the Jupyter interactive widgets - -Just like with ipywidgets, one can build upon xwidgets and implement C++ back-ends for the Jupyter widget libraries listed earlier, effectively enabling them for the C++ programming language and other xeus-based kernels: xplot, xvolume, xthreejs… - - - -![](https://cdn-images-1.medium.com/max/1200/1*yCRYoJFnbtxYkYMRc9AioA.png) - -[xplot][24] is an experimental C++ back-end for the [bqplot][25] 2-D plotting library. It enables an API following the constructs of the  [_Grammar of Graphics_][26]  in C++. - -In xplot, every item in a chart is a separate object that can be modified from the back-end,  _dynamically_ . - -Changing a property of a plot item, a scale, an axis or the figure canvas itself results in the communication of an update message to the front-end, which reflects the new state of the widget visually. - - - -![](https://cdn-images-1.medium.com/max/1600/1*Mx2g3JuTG1Cfvkkv0kqtLA.gif) -Changing the data of a scatter plot dynamically to update the chart - -> Warning: the xplot and xwidgets projects are still at an early stage of development and are changing drastically at each release. - -Interactive computing environments like Jupyter are not the only missing tool in the C++ world. Two key ingredients to the success of Python as the  _lingua franca_  of data science is the existence of libraries like [NumPy][27] and [Pandas][28] at the foundation of the ecosystem. - - - -![](https://cdn-images-1.medium.com/max/1200/1*HsU43Jzp1vJZpX2g8XPJsg.png) - -[xtensor][29] is a C++ library meant for numerical analysis with multi-dimensional array expressions. - -xtensor provides - -* an extensible expression system enabling lazy NumPy-style broadcasting. - -* an API following the  _idioms_  of the C++ standard library. - -* tools to manipulate array expressions and build upon xtensor. - -xtensor exposes an API similar to that of NumPy covering a growing portion of the functionalities. A cheat sheet can be [found in the documentation][30]: - - - -![](https://cdn-images-1.medium.com/max/1600/1*PBrf5vWYC8VTq_7VUOZCpA.gif) -Scrolling the NumPy to xtensor cheat sheet - -However, xtensor internals are very different from NumPy. Using modern C++ techniques (template expressions, closure semantics) xtensor is a lazily evaluated library, avoiding the creation of temporary variables and unnecessary memory allocations, even in the case complex expressions involving broadcasting and language bindings. - -Still, from a user perspective, the combination of xtensor with the C++ notebook provides an experience very similar to that of NumPy in a Python notebook. - - - -![](https://cdn-images-1.medium.com/max/1600/1*ULFpg-ePkdUbqqDLJ9VrDw.png) -Using the xtensor array expression library in a C++ notebook - -In addition to the core library, the xtensor ecosystem has a number of other components - -* [xtensor-blas][6]: the counterpart to the numpy.linalg module. - -* [xtensor-fftw][7]: bindings to the [fftw][8] library. - -* [xtensor-io][9]: APIs to read and write various file formats (images, audio, NumPy's NPZ format). - -* [xtensor-ros][10]: bindings for ROS, the robot operating system. - -* [xtensor-python][11]: bindings for the Python programming language, allowing the use of NumPy arrays in-place, using the NumPy C API and the pybind11 library. - -* [xtensor-julia][12]: bindings for the Julia programming language, allowing the use of Julia arrays in-place, using the C API of the Julia interpreter, and the CxxWrap library. - -* [xtensor-r][13]: bindings for the R programming language, allowing the use of R arrays in-place. - -Detailing further the features of the xtensor framework would be beyond the scope of this post. - -If you are interested in trying the various notebooks presented in this post, there is no need to install anything. You can just use  _binder_ : - -![](https://cdn-images-1.medium.com/max/1200/1*9cy5Mns_I0eScsmDBjvxDQ.png) - -[The Binder project][31], which is part of Project Jupyter, enables the deployment of containerized Jupyter notebooks, from a GitHub repository together with a manifest listing the dependencies (as conda packages). - -All the notebooks in the screenshots above can be run online, by just clicking on one of the following links: - -[xtensor][32]: the C++ N-D array expression library in a C++ notebook - -[xwidgets][33]: the C++ back-end for Jupyter interactive widgets - -[xplot][34]: the C++ back-end to the bqplot 2-D plotting library for Jupyter. - - - -![](https://cdn-images-1.medium.com/max/1200/1*JwqhpMxMJppEepj7U4fV-g.png) - -[JupyterHub][35] is the multi-user infrastructure underlying open wide deployments of Jupyter like Binder but also smaller deployments for authenticated users. - -The modular architecture of JupyterHub enables a great variety of scenarios on how users are authenticated, and what service is made available to them. JupyterHub deployment for several hundreds of users have been done in various universities and institutions, including the Paris-Sud University, where the C++ kernel was also installed for the students to use. - -> In September 2017, the 350 first-year students at Paris-Sud University who took the “[Info 111: Introduction to Computer ->  Science][36]” class wrote their first lines of C++ in a Jupyter notebook. - -The use of Jupyter notebooks in the context of teaching C++ proved especially useful for the first classes, where students can focus on the syntax of the language without distractions such as compiling and linking. - -### Acknowledgements - -The software presented in this post was built upon the work of a large number of people including the Jupyter team and the Cling developers. - -We are especially grateful to [Patrick Bos ][37](who authored xtensor-fftw), Nicolas Thiéry, Min Ragan Kelley, Thomas Kluyver, Yuvi Panda, Kyle Cranmer, Axel Naumann and Vassil Vassilev. - -We thank the [DIANA/HEP][38] organization for supporting travel to CERN and encouraging the collaboration between Project Jupyter and the ROOT team. - -We are also grateful to the team at Paris-Sud University who worked on the JupyterHub deployment and the class materials, notably [Viviane Pons][39]. - -The development of xeus, xtensor, xwidgets and related packages at [QuantStack][40] is sponsored by [Bloomberg][41]. - -### About the authors (alphabetical order) - - [_Sylvain Corlay_][42] _, _ Scientific Software Developer at [QuantStack][43] - - [_Loic Gouarin_][44] _, _ Research Engineer at [Laboratoire de Mathématiques at Orsay][45] - - [_Johan Mabille_][46] _, _ Scientific Software Developer at [QuantStack][47] - - [_Wolf Vollprecht_][48] , Scientific Software Developer at [QuantStack][49] - -Thanks to [Maarten Breddels][50], [Wolf Vollprecht][51], [Brian E. Granger][52], and [Patrick Bos][53]. - --------------------------------------------------------------------------------- - -via: https://blog.jupyter.org/interactive-workflows-for-c-with-jupyter-fe9b54227d92 - -作者:[QuantStack ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://blog.jupyter.org/@QuantStack?source=post_header_lockup -[1]:https://github.com/bloomberg/bqplot -[2]:https://github.com/jovyan/pythreejs -[3]:https://github.com/ellisonbg/ipyleaflet -[4]:https://github.com/maartenbreddels/ipyvolume -[5]:https://github.com/arose/nglview -[6]:https://github.com/QuantStack/xtensor-blas -[7]:https://github.com/egpbos/xtensor-fftw -[8]:http://www.fftw.org/ -[9]:https://github.com/QuantStack/xtensor-io -[10]:https://github.com/wolfv/xtensor_ros -[11]:https://github.com/QuantStack/xtensor-python -[12]:https://github.com/QuantStack/Xtensor.jl -[13]:https://github.com/QuantStack/xtensor-r -[14]:https://github.com/jupyter/jupyter/wiki/Jupyter-kernels -[15]:https://github.com/ipython/ipykernel -[16]:https://github.com/JuliaLang/IJulia.jl -[17]:https://github.com/QuantStack/xeus -[18]:https://root.cern.ch/cling -[19]:https://root.cern.ch/ -[20]:https://github.com/QuantStack/xeus-cling -[21]:http://en.cppreference.com/w/ -[22]:http://jupyter.org/widgets -[23]:https://github.com/QUantStack/xwidgets -[24]:https://github.com/QuantStack/xplot -[25]:https://github.com/bloomberg/bqplot -[26]:https://dl.acm.org/citation.cfm?id=1088896 -[27]:http://www.numpy.org/ -[28]:https://pandas.pydata.org/ -[29]:https://github.com/QuantStack/xtensor/ -[30]:http://xtensor.readthedocs.io/en/latest/numpy.html -[31]:https://mybinder.org/ -[32]:https://beta.mybinder.org/v2/gh/QuantStack/xtensor/0.14.0-binder2?filepath=notebooks/xtensor.ipynb -[33]:https://beta.mybinder.org/v2/gh/QuantStack/xwidgets/0.6.0-binder?filepath=notebooks/xwidgets.ipynb -[34]:https://beta.mybinder.org/v2/gh/QuantStack/xplot/0.3.0-binder?filepath=notebooks -[35]:https://github.com/jupyterhub/jupyterhub -[36]:http://nicolas.thiery.name/Enseignement/Info111/ -[37]:https://twitter.com/egpbos -[38]:http://diana-hep.org/ -[39]:https://twitter.com/pyviv -[40]:https://twitter.com/QuantStack -[41]:http://www.techatbloomberg.com/ -[42]:https://twitter.com/SylvainCorlay -[43]:https://github.com/QuantStack/ -[44]:https://twitter.com/lgouarin -[45]:https://www.math.u-psud.fr/ -[46]:https://twitter.com/johanmabille?lang=en -[47]:https://github.com/QuantStack/ -[48]:https://twitter.com/wuoulf -[49]:https://github.com/QuantStack/ -[50]:https://medium.com/@maartenbreddels?source=post_page -[51]:https://medium.com/@wolfv?source=post_page -[52]:https://medium.com/@ellisonbg?source=post_page -[53]:https://medium.com/@egpbos?source=post_page diff --git a/sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md b/sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md deleted file mode 100644 index 0e38373c3f..0000000000 --- a/sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md +++ /dev/null @@ -1,41 +0,0 @@ -Someone Tries to Bring Back Ubuntu's Unity from the Dead as an Official Spin -============================================================ - - - -> The Ubuntu Unity remix would be supported for nine months - -Canonical's sudden decision of killing its Unity user interface after seven years affected many Ubuntu users, and it looks like someone now tries to bring it back from the dead as an unofficial spin. - -Long-time [Ubuntu][1] member Dale Beaudoin [ran a poll][2] last week on the official Ubuntu forums to take the pulse of the community and see if they are interested in an Ubuntu Unity Remix that would be released alongside Ubuntu 18.04 LTS (Bionic Beaver) next year and be supported for nine months or five years. - -Thirty people voted in the poll, with 67 percent of them opting for an LTS (Long Term Support) release of the so-called Ubuntu Unity Remix, while 33 percent voted for the 9-month supported release. It also looks like this upcoming Ubuntu Unity Spin [looks to become an official flavor][3], yet this means commitment from those developing it. - -"A recent poll voted 2/3rds in favor of Ubuntu Unity to become an LTS distribution. We should try to work this cycle assuming that it will be LTS and an official flavor," said Dale Beaudoin. "We will try and release an updated ISO once every week or 10 days using the current 18.04 daily builds of default Ubuntu Bionic Beaver as a platform." - -### Is Ubuntu Unity making a comeback? - -The last Ubuntu version to ship with Unity by default was Ubuntu 17.04 (Zesty Zapus), which will reach end of life on January 2018\. Ubuntu 17.10 (Artful Artful), the current stable release of the popular operating system, is the first to use the GNOME desktop environment by default for the main Desktop edition as Canonical CEO [announced][4] earlier this year that Unity would no longer be developed. - -However, Canonical is still offering the Unity desktop environment from the official software repositories, so if someone wants to install it, it's one click away. But the bad news is that they'll be supported up until the release of Ubuntu 18.04 LTS (Bionic Beaver) in April 2018, so the developers of the Ubuntu Unity Remix would have to continue to keep in on life support on their a separate repository. - -On the other hand, we don't believe Canonical will change their mind and accept this Ubuntu Unity Spin to become an official flavor, which would mean they failed to continue development of Unity, and now a handful of people can do it. Most probably, if interest in this Ubuntu Unity Remix won't fade away soon, it will be an unofficial spin supported by the nostalgic community. - -Question is, would you be interested in an Ubuntu Unity spin, official or not? - --------------------------------------------------------------------------------- - -via: http://news.softpedia.com/news/someone-tries-to-bring-back-ubuntu-s-unity-from-the-dead-as-an-unofficial-spin-518778.shtml - -作者:[Marius Nestor ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://news.softpedia.com/editors/browse/marius-nestor -[1]:http://linux.softpedia.com/downloadTag/Ubuntu -[2]:https://community.ubuntu.com/t/poll-unity-7-distro-9-month-spin-or-lts-for-18-04/2066 -[3]:https://community.ubuntu.com/t/unity-maintenance-roadmap/2223 -[4]:http://news.softpedia.com/news/canonical-to-stop-developing-unity-8-ubuntu-18-04-lts-ships-with-gnome-desktop-514604.shtml -[5]:http://news.softpedia.com/editors/browse/marius-nestor diff --git a/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md b/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md deleted file mode 100644 index 195b51423a..0000000000 --- a/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md +++ /dev/null @@ -1,116 +0,0 @@ -Yoliver istranslating. -Excellent Business Software Alternatives For Linux -------- - -Many business owners choose to use Linux as the operating system for their operations for a variety of reasons. - -1. Firstly, they don't have to pay anything for the privilege, and that is a massive bonus during the early stages of a company where money is tight. - -2. Secondly, Linux is a light alternative compared to Windows and other popular operating systems available today. - -Of course, lots of entrepreneurs worry they won't have access to some of the essential software packages if they make that move. However, as you will discover throughout this post, there are plenty of similar tools that will cover all the bases. - - [![](https://4.bp.blogspot.com/-xwLuDRdB6sw/Whxx0Z5pI5I/AAAAAAAADhU/YWHID8GU9AgrXRfeTz4HcDZkG-XWZNbSgCLcBGAs/s400/4444061098_6eeaa7dc1a_z.jpg)][3] - -### Alternatives to Microsoft Word - -All company bosses will require access to a word processing tool if they want to ensure the smooth running of their operation according to - -[the latest article from Fareed Siddiqui][4] - -. You'll need that software to write business plans, letters, and many other jobs within your firm. Thankfully, there are a variety of alternatives you might like to select if you opt for the Linux operating system. Some of the most popular ones include: - -* LibreOffice Writer - -* AbiWord - -* KWord - -* LaTeX - -So, you just need to read some online reviews and then download the best word processor based on your findings. Of course, if you're not satisfied with the solution, you should take a look at some of the other ones on that list. In many instances, any of the programs mentioned above should work well. - -### Alternatives to Microsoft Excel - - [![](https://4.bp.blogspot.com/-XdS6bSLQbOU/WhxyeWZeeCI/AAAAAAAADhc/C3hGY6rgzX4m2emunot80-4URu9-aQx8wCLcBGAs/s400/28929069495_e85d2626ba_z.jpg)][5] - -You need a spreadsheet tool if you want to ensure your business doesn't get into trouble when it comes to bookkeeping and inventory control. There are specialist software packages on the market for both of those tasks, but - -[open-source alternatives][6] - -to Microsoft Excel will give you the most amount of freedom when creating your spreadsheets and editing them. While there are other packages out there, some of the best ones for Linux users include: - -* [LibreOffice Calc][1] - -* KSpread - -* Gnumeric - -Those programs work in much the same way as Microsoft Excel, and so you can use them for issues like accounting and stock control. You might also use that software to monitor employee earnings or punctuality. The possibilities are endless and only limited by your imagination. - -### Alternatives to Adobe Photoshop - - [![](https://3.bp.blogspot.com/-Id9Dm3CIXmc/WhxzGIlv3zI/AAAAAAAADho/VfIRCAbJMjMZzG2M97-uqLV9mOhqN7IWACLcBGAs/s400/32206185926_c69accfcef_z.jpg)][7] - -Company bosses require access to design programs when developing their marketing materials and creating graphics for their websites. You might also use software of that nature to come up with a new business logo at some point. Lots of entrepreneurs spend a fortune on - -[Training Connections Photoshop classes][8] - -and those available from other providers. They do that in the hope of educating their teams and getting the best results. However, people who use Linux can still benefit from that expertise if they select one of the following - -[alternatives][9] - -: - -* GIMP - -* Krita - -* Pixel - -* LightZone - -The last two suggestions on that list require a substantial investment. Still, they function in much the same way as Adobe Photoshop, and so you should manage to achieve the same quality of work. - -### Other software solutions that you'll want to consider - -Alongside those alternatives to some of the most widely-used software packages around today, business owners should take a look at the full range of products they could use with the Linux operating system. Here are some tools you might like to research and consider: - -* Inkscape - similar to Coreldraw - -* LibreOffice Base - similar to Microsoft Access - -* LibreOffice Impress - similar to Microsoft PowerPoint - -* File Roller - siThis is a contributed postmilar to WinZip - -* Linphone - similar to Skype - -There are - -[lots of other programs][10] - - you'll also want to research, and so the best solution is to use the internet to learn more. You will find lots of reviews from people who've used the software in the past, and many of them will compare the tool to its Windows or iOS alternative. So, you shouldn't have to work too hard to identify the best ones and sort the wheat from the chaff. - -Now you have all the right information; it's time to weigh all the pros and cons of Linux and work out if it's suitable for your operation. In most instances, that operating system does not place any limits on your business activities. It's just that you need to use different software compared to some of your competitors. People who use Linux tend to benefit from improved security, speed, and performance. Also, the solution gets regular updates, and so it's growing every single day. Unlike Windows and other solutions; you can customize Linux to meet your requirements. With that in mind, do not make the mistake of overlooking this fantastic system! - --------------------------------------------------------------------------------- - -via: http://linuxblog.darkduck.com/2017/11/excellent-business-software.html - -作者:[DarkDuck][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://linuxblog.darkduck.com/ -[1]:http://linuxblog.darkduck.com/2015/08/pivot-tables-in-libreoffice-calc.html -[3]:https://4.bp.blogspot.com/-xwLuDRdB6sw/Whxx0Z5pI5I/AAAAAAAADhU/YWHID8GU9AgrXRfeTz4HcDZkG-XWZNbSgCLcBGAs/s1600/4444061098_6eeaa7dc1a_z.jpg -[4]:https://www.linkedin.com/pulse/benefits-using-microsoft-word-fareed/ -[5]:https://4.bp.blogspot.com/-XdS6bSLQbOU/WhxyeWZeeCI/AAAAAAAADhc/C3hGY6rgzX4m2emunot80-4URu9-aQx8wCLcBGAs/s1600/28929069495_e85d2626ba_z.jpg -[6]:http://linuxblog.darkduck.com/2014/03/why-open-software-and-what-are-benefits.html -[7]:https://3.bp.blogspot.com/-Id9Dm3CIXmc/WhxzGIlv3zI/AAAAAAAADho/VfIRCAbJMjMZzG2M97-uqLV9mOhqN7IWACLcBGAs/s1600/32206185926_c69accfcef_z.jpg -[8]:https://www.trainingconnection.com/photoshop-training.php -[9]:http://linuxblog.darkduck.com/2011/10/photoshop-alternatives-for-linux.html -[10]:http://www.makeuseof.com/tag/best-linux-software/ diff --git a/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md b/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md deleted file mode 100644 index 2b4d2248b2..0000000000 --- a/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md +++ /dev/null @@ -1,108 +0,0 @@ -Scrot: Linux command-line screen grabs made simple -============================================================ - -### Scrot is a basic, flexible tool that offers a number of handy options for taking screen captures from the Linux command line. - -![Scrot: Screen grabs made simple](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/community-penguins-osdc-lead.png?itok=BmqsAF4A "Scrot: Screen grabs made simple") -Image credits : Original photo by Rikki Endsley. [CC BY-SA 4.0][13] - -There are great tools on the Linux desktop for taking screen captures, such as [KSnapshot][14] and [Shutter][15]. Even the simple utility that comes with the GNOME desktop does a pretty good job of capturing screens. But what if you rarely need to take screen captures? Or you use a Linux distribution without a built-in capture tool, or an older computer with limited resources? - -Turn to the command line and a little utility called [Scrot][16]. It does a fine job of taking simple screen captures, and it includes a few features that might surprise you. - -### Getting started with Scrot - -More Linux resources - -* [What is Linux?][1] - -* [What are Linux containers?][2] - -* [Download Now: Linux commands cheat sheet][3] - -* [Advanced Linux commands cheat sheet][4] - -* [Our latest Linux articles][5] - -Many Linux distributions come with Scrot already installed—to check, type `which scrot`. If it isn't there, you can install Scrot using your distro's package manager. If you're willing to compile the code, grab it [from GitHub][22]. - -To take a screen capture, crack open a terminal window and type `scrot [filename]`, where `[filename]` is the name of file to which you want to save the image (for example, `desktop.png`). If you don't include a name for the file, Scrot will create one for you, such as `2017-09-24-185009_1687x938_scrot.png`. (That filename isn't as descriptive it could be, is it? That's why it's better to add one to the command.) - -Running Scrot with no options takes a screen capture of your entire desktop. If you don't want to do that, Scrot lets you focus on smaller portions of your screen. - -### Taking a screen capture of a single window - -Tell Scrot to take a screen capture of a single window by typing `scrot -u [filename]`. - -The `-u` option tells Scrot to grab the window currently in focus. That's usually the terminal window you're working in, which might not be the one you want. - -To grab another window on your desktop, type `scrot -s [filename]`. - -The `-s` option lets you do one of two things: - -* select an open window, or - -* draw a rectangle around a window or a portion of a window to capture it. - -You can also set a delay, which gives you a little more time to select the window you want to capture. To do that, type `scrot -u -d [num] [filename]`. - -The `-d` option tells Scrot to wait before grabbing the window, and `[num]` is the number of seconds to wait. Specifying `-d 5` (wait five seconds) should give you enough time to choose a window. - -### More useful options - -Scrot offers a number of additional features (most of which I never use). The ones I find most useful include: - -* `-b` also grabs the window's border - -* `-t` grabs a window and creates a thumbnail of it. This can be useful when you're posting screen captures online. - -* `-c` creates a countdown in your terminal when you use the `-d` option. - -To learn about Scrot's other options, check out the its documentation by typing `man scrot` in a terminal window, or [read it online][17]. Then start snapping images of your screen. - -It's basic, but Scrot gets the job done nicely. - -### Topics - - [Linux][23] - -### About the author - - [![That idiot Scott Nesbitt ...](https://opensource.com/sites/default/files/styles/profile_pictures/public/scottn-cropped.jpg?itok=q4T2J4Ai)][18] - - Scott Nesbitt - I'm a long-time user of free/open source software, and write various things for both fun and profit. I don't take myself too seriously and I do all of my own stunts. You can find me at these fine establishments on the web: [Twitter][7], [Mastodon][8], [GitHub][9], and... [more about Scott Nesbitt][10][More about me][11] - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot - -作者:[ Scott Nesbitt  ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/scottnesbitt -[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[6]:https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot?rate=H43kUdawjR0GV9D0dCbpnmOWcqw1WekfrAI_qKo8UwI -[7]:http://www.twitter.com/ScottWNesbitt -[8]:https://mastodon.social/@scottnesbitt -[9]:https://github.com/ScottWNesbitt -[10]:https://opensource.com/users/scottnesbitt -[11]:https://opensource.com/users/scottnesbitt -[12]:https://opensource.com/user/14925/feed -[13]:https://creativecommons.org/licenses/by-sa/4.0/ -[14]:https://www.kde.org/applications/graphics/ksnapshot/ -[15]:https://launchpad.net/shutter -[16]:https://github.com/dreamer/scrot -[17]:http://manpages.ubuntu.com/manpages/precise/man1/scrot.1.html -[18]:https://opensource.com/users/scottnesbitt -[19]:https://opensource.com/users/scottnesbitt -[20]:https://opensource.com/users/scottnesbitt -[21]:https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot#comments -[22]:https://github.com/dreamer/scrot -[23]:https://opensource.com/tags/linux diff --git a/sources/tech/20171130 Search DuckDuckGo from the Command Line.md b/sources/tech/20171130 Search DuckDuckGo from the Command Line.md new file mode 100644 index 0000000000..ee451a6172 --- /dev/null +++ b/sources/tech/20171130 Search DuckDuckGo from the Command Line.md @@ -0,0 +1,103 @@ +translating---geekpi + +# Search DuckDuckGo from the Command Line + + ![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/duckduckgo.png) +When we showed you how to [search Google from the command line][3] a lot of you to say you use [Duck Duck Go][4], the awesome privacy-focused search engine. + +Well, now there’s a tool to search DuckDuckGo from the command line. It’s called [ddgr][6] (pronounced, in my head, as  _dodger_ ) and it’s pretty neat. + +Like [Googler][7], ddgr is totally open-source and totally unofficial. Yup, the app is unaffiliated with DuckDuckGo in any way. So, should it start returning unsavoury search results for innocent terms, make sure you quack in this dev’s direction, and not the search engine’s! + +### DuckDuckGo Terminal App + +![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/ddgr-gif.gif) + +[DuckDuckGo Bangs][8] makes finding stuff on DuckDuckGo super easy (there’s even a bang for  _this_  site) and, dutifully, ddgr supports them. + +Unlike the web interface, you can specify the number of search results you would like to see per page. It’s more convenient than skimming through 30-odd search results per page. The default interface is carefully designed to use minimum space without sacrificing readability. + +`ddgr` has a number of features, including: + +* Choose number of search results to fetch + +* Support for Bash autocomplete + +* Use !bangs + +* Open URLs in a browser + +* “I’m feeling lucky” option + +* Filter by time, region, file type, etc + +* Minimal dependencies + +You can download `ddgr` for various systems direct from the Github project page: + +[Download ‘ddgr’ from Github][9] + +You can also install ddgr on Ubuntu 16.04 LTS and up from a PPA. This repo is maintained by the developer of ddgr and is recommended should you want to stay up-to-date with new releases as and when they appear. + +Do note that at the time of writing the latest version of ddgr is  _not_  in the PPA, but an older version (lacking –num support) is: + +``` +sudo add-apt-repository ppa:twodopeshaggy/jarun +``` + +``` +sudo apt-get update +``` + +### How To Use ddgr to Search DuckDuckGo from the Comand Line + +To use ddgr once you installed all you need to do is pop open your terminal emulator of choice and run: + +``` +ddgr +``` + +Next enter a search term: + +``` +search-term +``` + +To limit the number of results returned run: + +``` +ddgr --num 5 search-term +``` + +To instantly open the first matching result for a search term in your browser run: + +``` +ddgr -j search-term +``` + +You can pass arguments and flags to narrow down your search. To see a comprehensive list inside the terminal run: + +``` +ddgr -h +``` + +-------------------------------------------------------------------------------- + +via: http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app + +作者:[JOEY SNEDDON ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://plus.google.com/117485690627814051450/?rel=author +[1]:https://plus.google.com/117485690627814051450/?rel=author +[2]:http://www.omgubuntu.co.uk/category/download +[3]:http://www.omgubuntu.co.uk/2017/08/search-google-from-the-command-line +[4]:http://duckduckgo.com/ +[5]:http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app +[6]:https://github.com/jarun/ddgr +[7]:https://github.com/jarun/googler +[8]:https://duckduckgo.com/bang +[9]:https://github.com/jarun/ddgr/releases/tag/v1.1 diff --git a/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md b/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md deleted file mode 100644 index 46afe9b893..0000000000 --- a/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md +++ /dev/null @@ -1,156 +0,0 @@ -translating---geekpi - -Undistract-me : Get Notification When Long Running Terminal Commands Complete -============================================================ - -by [sk][2] · November 30, 2017 - -![Undistract-me](https://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2-720x340.png) - -A while ago, we published how to [get notification when a Terminal activity is done][3]. Today, I found out a similar utility called “undistract-me” that notifies you when long running terminal commands complete. Picture this scenario. You run a command that takes a while to finish. In the mean time, you check your facebook and get so involved in it. After a while, you remembered that you ran a command few minutes ago. You go back to the Terminal and notice that the command has already finished. But you have no idea when the command is completed. Have you ever been in this situation? I bet most of you were in this situation many times. This is where “undistract-me” comes in help. You don’t need to constantly check the terminal to see if a command is completed or not. Undistract-me utility will notify you when a long running command is completed. It will work on Arch Linux, Debian, Ubuntu and other Ubuntu-derivatives. - -#### Installing Undistract-me - -Undistract-me is available in the default repositories of Debian and its variants such as Ubuntu. All you have to do is to run the following command to install it. - -``` -sudo apt-get install undistract-me -``` - -The Arch Linux users can install it from AUR using any helper programs. - -Using [Pacaur][4]: - -``` -pacaur -S undistract-me-git -``` - -Using [Packer][5]: - -``` -packer -S undistract-me-git -``` - -Using [Yaourt][6]: - -``` -yaourt -S undistract-me-git -``` - -Then, run the following command to add “undistract-me” to your Bash. - -``` -echo 'source /etc/profile.d/undistract-me.sh' >> ~/.bashrc -``` - -Alternatively you can run this command to add it to your Bash: - -``` -echo "source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install" >> .bashrc -``` - -If you are in Zsh shell, run this command: - -``` -echo "source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install" >> .zshrc -``` - -Finally update the changes: - -For Bash: - -``` -source ~/.bashrc -``` - -For Zsh: - -``` -source ~/.zshrc -``` - -#### Configure Undistract-me - -By default, Undistract-me will consider any command that takes more than 10 seconds to complete as a long-running command. You can change this time interval by editing /usr/share/undistract-me/long-running.bash file. - -``` -sudo nano /usr/share/undistract-me/long-running.bash -``` - -Find “LONG_RUNNING_COMMAND_TIMEOUT” variable and change the default value (10 seconds) to something else of your choice. - - [![](http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-1.png)][7] - -Save and close the file. Do not forget to update the changes: - -``` -source ~/.bashrc -``` - -Also, you can disable notifications for particular commands. To do so, find the “LONG_RUNNING_IGNORE_LIST” variable and add the commands space-separated like below. - -By default, the notification will only show if the active window is not the window the command is running in. That means, it will notify you only if the command is running in the background Terminal window. If the command is running in active window Terminal, you will not be notified. If you want undistract-me to send notifications either the Terminal window is visible or in the background, you can set IGNORE_WINDOW_CHECK to 1 to skip the window check. - -The other cool feature of Undistract-me is you can set audio notification along with visual notification when a command is done. By default, it will only send a visual notification. You can change this behavior by setting the variable UDM_PLAY_SOUND to a non-zero integer on the command line. However, your Ubuntu system should have pulseaudio-utils and sound-theme-freedesktop utilities installed to enable this functionality. - -Please remember that you need to run the following command to update the changes made. - -For Bash: - -``` -source ~/.bashrc -``` - -For Zsh: - -``` -source ~/.zshrc -``` - -It is time to verify if this really works. - -#### Get Notification When Long Running Terminal Commands Complete - -Now, run any command that takes longer than 10 seconds or the time duration you defined in Undistract-me script. - -I ran the following command on my Arch Linux desktop. - -``` -sudo pacman -Sy -``` - -This command took 32 seconds to complete. After the completion of the above command, I got the following notification. - - [![](http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2.png)][8] - -Please remember Undistract-me script notifies you only if the given command took more than 10 seconds to complete. If the command is completed in less than 10 seconds, you will not be notified. Of course, you can change this time interval settings as I described in the Configuration section above. - -I find this tool very useful. It helped me to get back to the business after I completely lost in some other tasks. I hope this tool will be helpful to you too. - -More good stuffs to come. Stay tuned! - -Cheers! - -Resource: - -* [Undistract-me GitHub Repository][1] - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/undistract-get-notification-long-running-terminal-commands-complete/ - -作者:[sk][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.ostechnix.com/author/sk/ -[1]:https://github.com/jml/undistract-me -[2]:https://www.ostechnix.com/author/sk/ -[3]:https://www.ostechnix.com/get-notification-terminal-task-done/ -[4]:https://www.ostechnix.com/install-pacaur-arch-linux/ -[5]:https://www.ostechnix.com/install-packer-arch-linux-2/ -[6]:https://www.ostechnix.com/install-yaourt-arch-linux/ -[7]:http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-1.png -[8]:http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2.png diff --git a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md deleted file mode 100644 index 3a2c20ad52..0000000000 --- a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md +++ /dev/null @@ -1,135 +0,0 @@ - - translating by HardworkFish - -Wake up and Shut Down Linux Automatically -============================================================ - -### [banner.jpg][1] - -![time keeper](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/banner.jpg?itok=zItspoSb) - -Learn how to configure your Linux computers to watch the time for you, then wake up and shut down automatically. - -[Creative Commons Attribution][6][The Observatory at Delhi][7] - -Don't be a watt-waster. If your computers don't need to be on then shut them down. For convenience and nerd creds, you can configure your Linux computers to wake up and shut down automatically. - -### Precious Uptimes - -Some computers need to be on all the time, which is fine as long as it's not about satisfying an uptime compulsion. Some people are very proud of their lengthy uptimes, and now that we have kernel hot-patching that leaves only hardware failures requiring shutdowns. I think it's better to be practical. Save electricity as well as wear on your moving parts, and shut them down when they're not needed. For example, you can wake up a backup server at a scheduled time, run your backups, and then shut it down until it's time for the next backup. Or, you can configure your Internet gateway to be on only at certain times. Anything that doesn't need to be on all the time can be configured to turn on, do a job, and then shut down. - -### Sleepies - -For computers that don't need to be on all the time, good old cron will shut them down reliably. Use either root's cron, or /etc/crontab. This example creates a root cron job to shut down every night at 11:15 p.m. - -``` -# crontab -e -u root -# m h dom mon dow command -15 23 * * * /sbin/shutdown -h now -``` - -``` -15 23 * * 1-5 /sbin/shutdown -h now -``` - -You may also use /etc/crontab, which is fast and easy, and everything is in one file. You have to specify the user: - -``` -15 23 * * 1-5 root shutdown -h now -``` - -Auto-wakeups are very cool; most of my SUSE colleagues are in Nuremberg, so I am crawling out of bed at 5 a.m. to have a few hours of overlap with their schedules. My work computer turns itself on at 5:30 a.m., and then all I have to do is drag my coffee and myself to my desk to start work. It might not seem like pressing a power button is a big deal, but at that time of day every little thing looms large. - -Waking up your Linux PC can be less reliable than shutting it down, so you may want to try different methods. You can use wakeonlan, RTC wakeups, or your PC's BIOS to set scheduled wakeups. These all work because, when you power off your computer, it's not really all the way off; it is in an extremely low-power state and can receive and respond to signals. You need to use the power supply switch to turn it off completely. - -### BIOS Wakeup - -A BIOS wakeup is the most reliable. My system BIOS has an easy-to-use wakeup scheduler (Figure 1). Chances are yours does, too. Easy peasy. - -### [fig-1.png][2] - -![wake up](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_11.png?itok=8qAeqo1I) - -Figure 1: My system BIOS has an easy-to-use wakeup scheduler. - -[Used with permission][8] - -### wakeonlan - -wakeonlan is the next most reliable method. This requires sending a signal from a second computer to the computer you want to power on. You could use an Arduino or Raspberry Pi to send the wakeup signal, a Linux-based router, or any Linux PC. First, look in your system BIOS to see if wakeonlan is supported -- which it should be -- and then enable it, as it should be disabled by default. - -Then, you'll need an Ethernet network adapter that supports wakeonlan; wireless adapters won't work. You'll need to verify that your Ethernet card supports wakeonlan: - -``` -# ethtool eth0 | grep -i wake-on - Supports Wake-on: pumbg - Wake-on: g -``` - -* d -- all wake ups disabled - -* p -- wake up on physical activity - -* u -- wake up on unicast messages - -* m -- wake up on multicast messages - -* b -- wake up on broadcast messages - -* a -- wake up on ARP messages - -* g -- wake up on magic packet - -* s -- set the Secure On password for the magic packet - -man ethtool is not clear on what the p switch does; it suggests that any signal will cause a wake up. In my testing, however, it doesn't do that. The one that must be enabled is g -- wake up on magic packet, and the Wake-on line shows that it is already enabled. If it is not enabled, you can use ethtool to enable it, using your own device name, of course: - -``` -# ethtool -s eth0 wol g -``` - -``` -@reboot /usr/bin/ethtool -s eth0 wol g -``` - -### [fig-2.png][3] - -![wakeonlan](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-2_7.png?itok=XQAwmHoQ) - -Figure 2: Enable Wake on LAN. - -[Used with permission][9] - -Another option is recent Network Manager versions have a nice little checkbox to enable wakeonlan (Figure 2). - -There is a field for setting a password, but if your network interface doesn't support the Secure On password, it won't work. - -Now you need to configure a second PC to send the wakeup signal. You don't need root privileges, so create a cron job for your user. You need the MAC address of the network interface on the machine you're waking up: - -``` -30 08 * * * /usr/bin/wakeonlan D0:50:99:82:E7:2B -``` - -Using the real-time clock for wakeups is the least reliable method. Check out [Wake Up Linux With an RTC Alarm Clock][4]; this is a bit outdated as most distros use systemd now. Come back next week to learn more about updated ways to use RTC wakeups. - -Learn more about Linux through the free ["Introduction to Linux" ][5]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2017/11/wake-and-shut-down-linux-automatically - -作者:[Carla Schroder] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[1]:https://www.linux.com/files/images/bannerjpg -[2]:https://www.linux.com/files/images/fig-1png-11 -[3]:https://www.linux.com/files/images/fig-2png-7 -[4]:https://www.linux.com/learn/wake-linux-rtc-alarm-clock -[5]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux -[6]:https://www.linux.com/licenses/category/creative-commons-attribution -[7]:http://www.columbia.edu/itc/mealac/pritchett/00routesdata/1700_1799/jaipur/delhijantarearly/delhijantarearly.html -[8]:https://www.linux.com/licenses/category/used-permission -[9]:https://www.linux.com/licenses/category/used-permission diff --git a/sources/tech/20171201 Fedora Classroom Session: Ansible 101.md b/sources/tech/20171201 Fedora Classroom Session: Ansible 101.md deleted file mode 100644 index a74b196663..0000000000 --- a/sources/tech/20171201 Fedora Classroom Session: Ansible 101.md +++ /dev/null @@ -1,71 +0,0 @@ -### [Fedora Classroom Session: Ansible 101][2] - -### By Sachin S Kamath - -![](https://fedoramagazine.org/wp-content/uploads/2017/07/fedora-classroom-945x400.jpg) - -Fedora Classroom sessions continue this week with an Ansible session. The general schedule for sessions appears [on the wiki][3]. You can also find [resources and recordings from previous sessions][4] there. Here are details about this week’s session on [Thursday, 30th November at 1600 UTC][5]. That link allows you to convert the time to your timezone. - -### Topic: Ansible 101 - -As the Ansible [documentation][6] explains, Ansible is an IT automation tool. It’s primarily used to configure systems, deploy software, and orchestrate more advanced IT tasks. Examples include continuous deployments or zero downtime rolling updates. - -This Classroom session covers the topics listed below: - -1. Introduction to SSH - -2. Understanding different terminologies - -3. Introduction to Ansible - -4. Ansible installation and setup - -5. Establishing password-less connection - -6. Ad-hoc commands - -7. Managing inventory - -8. Playbooks examples - -There will also be a follow-up Ansible 102 session later. That session will cover complex playbooks, roles, dynamic inventory files, control flow and Galaxy. - -### Instructors - -We have two experienced instructors handling this session. - -[Geoffrey Marr][7], also known by his IRC name as “coremodule,” is a Red Hat employee and Fedora contributor with a background in Linux and cloud technologies. While working, he spends his time lurking in the [Fedora QA][8] wiki and test pages. Away from work, he enjoys RaspberryPi projects, especially those focusing on software-defined radio. - -[Vipul Siddharth][9] is an intern at Red Hat who also works on Fedora. He loves to contribute to open source and seeks opportunities to spread the word of free and open source software. - -### Joining the session - -This session takes place on [BlueJeans][10]. The following information will help you join the session: - -* URL: [https://bluejeans.com/3466040121][1] - -* Meeting ID (for Desktop App): 3466040121 - -We hope you attend, learn from, and enjoy this session! If you have any feedback about the sessions, have ideas for a new one or want to host a session, please feel free to comment on this post or edit the [Classroom wiki page][11]. - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/fedora-classroom-session-ansible-101/ - -作者:[Sachin S Kamath] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[1]:https://bluejeans.com/3466040121 -[2]:https://fedoramagazine.org/fedora-classroom-session-ansible-101/ -[3]:https://fedoraproject.org/wiki/Classroom -[4]:https://fedoraproject.org/wiki/Classroom#Previous_Sessions -[5]:https://www.timeanddate.com/worldclock/fixedtime.html?msg=Fedora+Classroom+-+Ansible+101&iso=20171130T16&p1=%3A -[6]:http://docs.ansible.com/ansible/latest/index.html -[7]:https://fedoraproject.org/wiki/User:Coremodule -[8]:https://fedoraproject.org/wiki/QA -[9]:https://fedoraproject.org/wiki/User:Siddharthvipul1 -[10]:https://www.bluejeans.com/downloads -[11]:https://fedoraproject.org/wiki/Classroom diff --git a/sources/tech/20171201 How to Manage Users with Groups in Linux.md b/sources/tech/20171201 How to Manage Users with Groups in Linux.md deleted file mode 100644 index 35350c819f..0000000000 --- a/sources/tech/20171201 How to Manage Users with Groups in Linux.md +++ /dev/null @@ -1,168 +0,0 @@ -translating---imquanquan - -How to Manage Users with Groups in Linux -============================================================ - -### [group-of-people-1645356_1920.jpg][1] - -![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/group-of-people-1645356_1920.jpg?itok=rJlAxBSV) - -Learn how to work with users, via groups and access control lists in this tutorial. - -[Creative Commons Zero][4] - -Pixabay - -When you administer a Linux machine that houses multiple users, there might be times when you need to take more control over those users than the basic user tools offer. This idea comes to the fore especially when you need to manage permissions for certain users. Say, for example, you have a directory that needs to be accessed with read/write permissions by one group of users and only read permissions for another group. With Linux, this is entirely possible. To make this happen, however, you must first understand how to work with users, via groups and access control lists (ACLs). - -We’ll start from the beginning with users and work our way to the more complex ACLs. Everything you need to make this happen will be included in your Linux distribution of choice. We won’t touch on the basics of users, as the focus on this article is about groups. - -For the purpose of this piece, I’m going to assume the following: - -You need to create two users with usernames: - -* olivia - -* nathan - -You need to create two groups: - -* readers - -* editors - -Olivia needs to be a member of the group editors, while nathan needs to be a member of the group readers. The group readers needs to only have read permission to the directory /DATA, whereas the group editors needs to have both read and write permission to the /DATA directory. This, of course, is very minimal, but it will give you the basic information you need to expand the tasks to fit your much larger needs. - -I’ll be demonstrating on the Ubuntu 16.04 Server platform. The commands will be universal—the only difference would be if your distribution of choice doesn’t make use of sudo. If this is the case, you’ll have to first su to the root user to issue the commands that require sudo in the demonstrations. - -### Creating the users - -The first thing we need to do is create the two users for our experiment. User creation is handled with the useradd command. Instead of just simply creating the users we need to create them both with their own home directories and then give them passwords. - -The first thing we do is create the users. To do this, issue the commands: - -``` -sudo useradd -m olivia - -sudo useradd -m nathan -``` - -Next each user must have a password. To add passwords into the mix, you’d issue the following commands: - -``` -sudo passwd olivia - -sudo passwd nathan -``` - -That’s it, your users are created. - -### Creating groups and adding users - -Now we’re going to create the groups readers and editors and then add users to them. The commands to create our groups are: - -``` -addgroup readers - -addgroup editors -``` - -### [groups_1.jpg][2] - -![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/groups_1.jpg?itok=BKwL89BB) - -Figure 1: Our new groups ready to be used. - -[Used with permission][5] - -With our groups created, we need to add our users. We’ll add user nathan to group readers with the command: - -``` -sudo usermod -a -G readers nathan -``` - -``` -sudo usermod -a -G editors olivia -``` - -### Giving groups permissions to directories - -Let’s say you have the directory /READERS and you need to allow all members of the readers group access to that directory. First, change the group of the folder with the command: - -``` -sudo chown -R :readers /READERS -``` - -``` -sudo chmod -R g-w /READERS -``` - -``` -sudo chmod -R o-x /READERS -``` - -Let’s say you have the directory /EDITORS and you need to give members of the editors group read and write permission to its contents. To do that, the following command would be necessary: - -``` -sudo chown -R :editors /EDITORS - -sudo chmod -R g+w /EDITORS - -sudo chmod -R o-x /EDITORS -``` - -The problem with using this method is you can only add one group to a directory at a time. This is where access control lists come in handy. - -### Using access control lists - -Now, let’s get tricky. Say you have a single folder—/DATA—and you want to give members of the readers group read permission and members of the group editors read/write permissions. To do that, you must take advantage of the setfacl command. The setfacl command sets file access control lists for files and folders. - -The structure of this command looks like this: - -``` -setfacl OPTION X:NAME:Y /DIRECTORY -``` - -``` -sudo setfacl -m g:readers:rx -R /DATA -``` - -To give members of the editors group read/write permissions (while retaining read permissions for the readers group), we’d issue the command; - -``` -sudo setfacl -m g:editors:rwx -R /DATA -``` - -### All the control you need - -And there you have it. You can now add members to groups and control those groups’ access to various directories with all the power and flexibility you need. To read more about the above tools, issue the commands: - -* man usradd - -* man addgroup - -* man usermod - -* man sefacl - -* man chown - -* man chmod - -Learn more about Linux through the free ["Introduction to Linux" ][3]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2017/12/how-manage-users-groups-linux - -作者:[Jack Wallen ] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[1]:https://www.linux.com/files/images/group-people-16453561920jpg -[2]:https://www.linux.com/files/images/groups1jpg -[3]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux -[4]:https://www.linux.com/licenses/category/creative-commons-zero -[5]:https://www.linux.com/licenses/category/used-permission diff --git a/sources/tech/20171201 How to find a publisher for your tech book.md b/sources/tech/20171201 How to find a publisher for your tech book.md deleted file mode 100644 index 76dc8112ca..0000000000 --- a/sources/tech/20171201 How to find a publisher for your tech book.md +++ /dev/null @@ -1,76 +0,0 @@ -How to find a publisher for your tech book -============================================================ - -### Writing a technical book takes more than a good idea. You need to know a bit about how the publishing industry works. - - -![How to find a publisher for your tech book](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDUCATION_colorbooks.png?itok=vNhsYYyC "How to find a publisher for your tech book") -Image by : opensource.com - -You've got an idea for a technical book—congratulations! Like a hiking the Appalachian trail, or learning to cook a soufflé, writing a book is one of those things that people talk about, but never take beyond the idea stage. That makes sense, because the failure rate is pretty high. Making it real involves putting your idea in front of a publisher, and finding out whether it's good enough to become a book. That step is scary enough, but the lack of information about how to do it complicates matters. - -If you want to work with a traditional publisher, you'll need to get your book in front of them and hopefully start on the path to publication. I'm the Managing Editor at the [Pragmatic Bookshelf][4], so I see proposals all the time, as well as helping authors to craft good ones. Some are good, others are bad, but I often see proposals that just aren't right for Pragmatic. I'll help you with the process of finding the right publisher, and how to get your idea noticed. - -### Identify your target - -Your first step is to figure out which publisher is the a good fit for your idea. To start, think about the publishers that you buy books from, and that you enjoy. The odds are pretty good that your book will appeal to people like you, so starting with your favorites makes for a pretty good short list. If you don't have much of a book collection, you can visit a bookstore, or take a look on Amazon. Make a list of a handful of publishers that you personally like to start with. - -Next, winnow your prospects. Although most technical publishers look alike from a distance, they often have distinctive audiences. Some publishers go for broadly popular topics, such as C++ or Java. Your book on Elixir may not be a good fit for that publisher. If your prospective book is about teaching programming to kids, you probably don't want to go with the traditional academic publisher. - -Once you've identified a few targets, do some more research into the publishers' catalogs, either on their own site, or on Amazon. See what books they have that are similar to your idea. If they have a book that's identical, or nearly so, you'll have a tough time convincing them to sign yours. That doesn't necessarily mean you should drop that publisher from your list. You can make some changes to your proposal to differentiate it from the existing book: target a different audience, or a different skill level. Maybe the existing book is outdated, and you could focus on new approaches to the technology. Make your proposal into a book that complements the existing one, rather than competes. - -If your target publisher has no books that are similar, that can be a good sign, or a very bad one. Sometimes publishers choose not to publish on specific technologies, either because they don't believe their audience is interested, or they've had trouble with that technology in the past. New languages and libraries pop up all the time, and publishers have to make informed guesses about which will appeal to their readers. Their assessment may not be the same as yours. Their decision might be final, or they might be waiting for the right proposal. The only way to know is to propose and find out. - -### Work your network - -Identifying a publisher is the first step; now you need to make contact. Unfortunately, publishing is still about  _who_  you know, more than  _what_  you know. The person you want to know is an  _acquisitions editor,_  the editor whose job is to find new markets, authors, and proposals. If you know someone who has connections with a publisher, ask for an introduction to an acquisitions editor. These editors often specialize in particular subject areas, particularly at larger publishers, but you don't need to find the right one yourself. They're usually happy to connect you with the correct person. - -Sometimes you can find an acquisitions editor at a technical conference, especially one where the publisher is a sponsor, and has a booth. Even if there's not an acquisitions editor on site at the time, the staff at the booth can put you in touch with one. If conferences aren't your thing, you'll need to work your network to get an introduction. Use LinkedIn, or your informal contacts, to get in touch with an editor. - -For smaller publishers, you may find acquisitions editors listed on the company website, with contact information if you're lucky. If not, search for the publisher's name on Twitter, and see if you can turn up their editors. You might be nervous about trying to reach out to a stranger over social media to show them your book, but don't worry about it. Making contact is what acquisitions editors do. The worst-case result is they ignore you. - -Once you've made contact, the acquisitions editor will assist you with the next steps. They may have some feedback on your proposal right away, or they may want you to flesh it out according to their guidelines before they'll consider it. After you've put in the effort to find an acquisitions editor, listen to their advice. They know their system better than you do. - -### If all else fails - -If you can't find an acquisitions editor to contact, the publisher almost certainly has a blind proposal alias, usually of the form `proposals@[publisher].com`. Check the web site for instructions on what to send to a proposal alias; some publishers have specific requirements. Follow these instructions. If you don't, you have a good chance of your proposal getting thrown out before anybody looks at it. If you have questions, or aren't sure what the publisher wants, you'll need to try again to find an editor to talk to, because the proposal alias is not the place to get questions answered. Put together what they've asked for (which is a topic for a separate article), send it in, and hope for the best. - -### And ... wait - -No matter how you've gotten in touch with a publisher, you'll probably have to wait. If you submitted to the proposals alias, it's going to take a while before somebody does anything with that proposal, especially at a larger company. Even if you've found an acquisitions editor to work with, you're probably one of many prospects she's working with simultaneously, so you might not get rapid responses. Almost all publishers have a committee that decides on which proposals to accept, so even if your proposal is awesome and ready to go, you'll still need to wait for the committee to meet and discuss it. You might be waiting several weeks, or even a month before you hear anything. - -After a couple of weeks, it's fine to check back in with the editor to see if they need any more information. You want to be polite in this e-mail; if they haven't answered because they're swamped with proposals, being pushy isn't going to get you to the front of the line. It's possible that some publishers will never respond at all instead of sending a rejection notice, but that's uncommon. There's not a lot to do at this point other than be patient. Of course, if it's been months and nobody's returning your e-mails, you're free to approach a different publisher or consider self-publishing. - -### Good luck - -If this process seems somewhat scattered and unscientific, you're right; it is. Getting published depends on being in the right place, at the right time, talking to the right person, and hoping they're in the right mood. You can't control all of those variables, but having a better knowledge of how the industry works, and what publishers are looking for, can help you optimize the ones you can control. - -Finding a publisher is one step in a lengthy process. You need to refine your idea and create the proposal, as well as other considerations. At SeaGL this year [I presented][5] an introduction to the entire process. Check out [the video][6] for more detailed information. - -### About the author - - [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/portrait.jpg?itok=b77dlNC4)][7] - - Brian MacDonald - Brian MacDonald is Managing Editor at the Pragmatic Bookshelf. Over the last 20 years in tech publishing, he's been an editor, author, and occasional speaker and trainer. He currently spends a lot of his time talking to new authors about how they can best present their ideas. You can follow him on Twitter at @bmac_editor.[More about me][2] - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/12/how-find-publisher-your-book - -作者:[Brian MacDonald ][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/bmacdonald -[1]:https://opensource.com/article/17/12/how-find-publisher-your-book?rate=o42yhdS44MUaykAIRLB3O24FvfWxAxBKa5WAWSnSY0s -[2]:https://opensource.com/users/bmacdonald -[3]:https://opensource.com/user/190176/feed -[4]:https://pragprog.com/ -[5]:https://archive.org/details/SeaGL2017WritingTheNextGreatTechBook -[6]:https://archive.org/details/SeaGL2017WritingTheNextGreatTechBook -[7]:https://opensource.com/users/bmacdonald -[8]:https://opensource.com/users/bmacdonald -[9]:https://opensource.com/users/bmacdonald -[10]:https://opensource.com/article/17/12/how-find-publisher-your-book#comments diff --git a/sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md b/sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md deleted file mode 100644 index b0f8e72018..0000000000 --- a/sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md +++ /dev/null @@ -1,160 +0,0 @@ -Randomize your WiFi MAC address on Ubuntu 16.04 -============================================================ - - _Your device’s MAC address can be used to track you across the WiFi networks you connect to. That data can be shared and sold, and often identifies you as an individual. It’s possible to limit this tracking by using pseudo-random MAC addresses._ - -![A captive portal screen for a hotel allowing you to log in with social media for an hour of free WiFi](https://www.paulfurley.com/img/captive-portal-our-hotel.gif) - - _Image courtesy of [Cloudessa][4]_ - -Every network device like a WiFi or Ethernet card has a unique identifier called a MAC address, for example `b4:b6:76:31:8c:ff`. It’s how networking works: any time you connect to a WiFi network, the router uses that address to send and receive packets to your machine and distinguish it from other devices in the area. - -The snag with this design is that your unique, unchanging MAC address is just perfect for tracking you. Logged into Starbucks WiFi? Noted. London Underground? Logged. - -If you’ve ever put your real name into one of those Craptive Portals on a WiFi network you’ve now tied your identity to that MAC address. Didn’t read the terms and conditions? You might assume that free airport WiFi is subsidised by flogging ‘customer analytics’ (your personal information) to hotels, restaurant chains and whomever else wants to know about you. - -I don’t subscribe to being tracked and sold by mega-corps, so I spent a few hours hacking a solution. - -### MAC addresses don’t need to stay the same - -Fortunately, it’s possible to spoof your MAC address to a random one without fundamentally breaking networking. - -I wanted to randomize my MAC address, but with three particular caveats: - -1. The MAC should be different across different networks. This means Starbucks WiFi sees a different MAC from London Underground, preventing linking my identity across different providers. - -2. The MAC should change regularly to prevent a network knowing that I’m the same person who walked past 75 times over the last year. - -3. The MAC stays the same throughout each working day. When the MAC address changes, most networks will kick you off, and those with Craptive Portals will usually make you sign in again - annoying. - -### Manipulating NetworkManager - -My first attempt of using the `macchanger` tool was unsuccessful as NetworkManager would override the MAC address according to its own configuration. - -I learned that NetworkManager 1.4.1+ can do MAC address randomization right out the box. If you’re using Ubuntu 17.04 upwards, you can get most of the way with [this config file][7]. You can’t quite achieve all three of my requirements (you must choose  _random_ or  _stable_  but it seems you can’t do  _stable-for-one-day_ ). - -Since I’m sticking with Ubuntu 16.04 which ships with NetworkManager 1.2, I couldn’t make use of the new functionality. Supposedly there is some randomization support but I failed to actually make it work, so I scripted up a solution instead. - -Fortunately NetworkManager 1.2 does allow for spoofing your MAC address. You can see this in the ‘Edit connections’ dialog for a given network: - -![Screenshot of NetworkManager's edit connection dialog, showing a text entry for a cloned mac address](https://www.paulfurley.com/img/network-manager-cloned-mac-address.png) - -NetworkManager also supports hooks - any script placed in `/etc/NetworkManager/dispatcher.d/pre-up.d/` is run before a connection is brought up. - -### Assigning pseudo-random MAC addresses - -To recap, I wanted to generate random MAC addresses based on the  _network_  and the  _date_ . We can use the NetworkManager command line, nmcli, to show a full list of networks: - -``` -> nmcli connection -NAME UUID TYPE DEVICE -Gladstone Guest 618545ca-d81a-11e7-a2a4-271245e11a45 802-11-wireless wlp1s0 -DoESDinky 6e47c080-d81a-11e7-9921-87bc56777256 802-11-wireless -- -PublicWiFi 79282c10-d81a-11e7-87cb-6341829c2a54 802-11-wireless -- -virgintrainswifi 7d0c57de-d81a-11e7-9bae-5be89b161d22 802-11-wireless -- - -``` - -Since each network has a unique identifier, to achieve my scheme I just concatenated the UUID with today’s date and hashed the result: - -``` - -# eg 618545ca-d81a-11e7-a2a4-271245e11a45-2017-12-03 - -> echo -n "${UUID}-$(date +%F)" | md5sum - -53594de990e92f9b914a723208f22b3f - - -``` - -That produced bytes which can be substituted in for the last octets of the MAC address. - -Note that the first byte `02` signifies the address is [locally administered][8]. Real, burned-in MAC addresses start with 3 bytes designing their manufacturer, for example `b4:b6:76` for Intel. - -It’s possible that some routers may reject locally administered MACs but I haven’t encountered that yet. - -On every connection up, the script calls `nmcli` to set the spoofed MAC address for every connection: - -![A terminal window show a number of nmcli command line calls](https://www.paulfurley.com/img/terminal-window-nmcli-commands.png) - -As a final check, if I look at `ifconfig` I can see that the `HWaddr` is the spoofed one, not my real MAC address: - -``` -> ifconfig -wlp1s0 Link encap:Ethernet HWaddr b4:b6:76:45:64:4d - inet addr:192.168.0.86 Bcast:192.168.0.255 Mask:255.255.255.0 - inet6 addr: fe80::648c:aff2:9a9d:764/64 Scope:Link - UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 - RX packets:12107812 errors:0 dropped:2 overruns:0 frame:0 - TX packets:18332141 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:11627977017 (11.6 GB) TX bytes:20700627733 (20.7 GB) - -``` - -The full script is [available on Github][9]. - -``` -#!/bin/sh - -# /etc/NetworkManager/dispatcher.d/pre-up.d/randomize-mac-addresses - -# Configure every saved WiFi connection in NetworkManager with a spoofed MAC -# address, seeded from the UUID of the connection and the date eg: -# 'c31bbcc4-d6ad-11e7-9a5a-e7e1491a7e20-2017-11-20' - -# This makes your MAC impossible(?) to track across WiFi providers, and -# for one provider to track across days. - -# For craptive portals that authenticate based on MAC, you might want to -# automate logging in :) - -# Note that NetworkManager >= 1.4.1 (Ubuntu 17.04+) can do something similar -# automatically. - -export PATH=$PATH:/usr/bin:/bin - -LOG_FILE=/var/log/randomize-mac-addresses - -echo "$(date): $*" > ${LOG_FILE} - -WIFI_UUIDS=$(nmcli --fields type,uuid connection show |grep 802-11-wireless |cut '-d ' -f3) - -for UUID in ${WIFI_UUIDS} -do - UUID_DAILY_HASH=$(echo "${UUID}-$(date +F)" | md5sum) - - RANDOM_MAC="02:$(echo -n ${UUID_DAILY_HASH} | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5/')" - - CMD="nmcli connection modify ${UUID} wifi.cloned-mac-address ${RANDOM_MAC}" - - echo "$CMD" >> ${LOG_FILE} - $CMD & -done - -wait -``` -Enjoy! - - _Update: [Use locally administered MAC addresses][5] to avoid clashing with real Intel ones. Thanks [@_fink][6]_ - --------------------------------------------------------------------------------- - -via: https://www.paulfurley.com/randomize-your-wifi-mac-address-on-ubuntu-1604-xenial/ - -作者:[Paul M Furley ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.paulfurley.com/ -[1]:https://gist.github.com/paulfurley/46e0547ce5c5ea7eabeaef50dbacef3f/raw/5f02fc8f6ff7fca5bca6ee4913c63bf6de15abca/randomize-mac-addresses -[2]:https://gist.github.com/paulfurley/46e0547ce5c5ea7eabeaef50dbacef3f#file-randomize-mac-addresses -[3]:https://github.com/ -[4]:http://cloudessa.com/products/cloudessa-aaa-and-captive-portal-cloud-service/ -[5]:https://gist.github.com/paulfurley/46e0547ce5c5ea7eabeaef50dbacef3f/revisions#diff-824d510864d58c07df01102a8f53faef -[6]:https://twitter.com/fink_/status/937305600005943296 -[7]:https://gist.github.com/paulfurley/978d4e2e0cceb41d67d017a668106c53/ -[8]:https://en.wikipedia.org/wiki/MAC_address#Universal_vs._local -[9]:https://gist.github.com/paulfurley/46e0547ce5c5ea7eabeaef50dbacef3f diff --git a/sources/tech/20171202 Easily control delivery of your Python applications to millions of Linux users with Snapcraft.md b/sources/tech/20171202 Easily control delivery of your Python applications to millions of Linux users with Snapcraft.md deleted file mode 100644 index dbdebf63e3..0000000000 --- a/sources/tech/20171202 Easily control delivery of your Python applications to millions of Linux users with Snapcraft.md +++ /dev/null @@ -1,321 +0,0 @@ -Python -============================================================ - -Python has rich tools for packaging, distributing and sandboxing applications. Snapcraft builds on top of these familiar tools such as `pip`, `setup.py` and `requirements.txt` to create snaps for people to install on Linux. - -### What problems do snaps solve for Python applications? - -Linux install instructions for Python applications often get complicated. System dependencies, which differ from distribution to distribution, must be separately installed. To prevent modules from different Python applications clashing with each other, developer tools like `virtualenv` or `venv` must be used. With snapcraft it’s one command to produce a bundle that works anywhere. - -Here are some snap advantages that will benefit many Python projects: - -* Bundle all the runtime requirements, including the exact versions of system libraries and the Python interpreter. - -* Simplify installation instructions, regardless of distribution, to `snap install mypythonapp`. - -* Directly control the delivery of automatic application updates. - -* Extremely simple creation of daemons. - -### Getting started - -Let’s take a look at offlineimap and youtube-dl by way of examples. Both are command line applications. offlineimap uses Python 2 and only has Python module requirements. youtube-dl uses Python 3 and has system package requirements, in this case `ffmpeg`. - -### offlineimap - -Snaps are defined in a single yaml file placed in the root of your project. The offlineimap example shows the entire `snapcraft.yaml` for an existing project. We’ll break this down. - -``` -name: offlineimap -version: git -summary: OfflineIMAP -description: | - OfflineIMAP is software that downloads your email mailbox(es) as local - Maildirs. OfflineIMAP will synchronize both sides via IMAP. - -grade: devel -confinement: devmode - -apps: - offlineimap: - command: bin/offlineimap - -parts: - offlineimap: - plugin: python - python-version: python2 - source: . - -``` - -#### Metadata - -The `snapcraft.yaml` starts with a small amount of human-readable metadata, which usually can be lifted from the GitHub description or project README.md. This data is used in the presentation of your app in the Snap Store. The `summary:` can not exceed 79 characters. You can use a pipe with the `description:` to declare a multi-line description. - -``` -name: offlineimap -version: git -summary: OfflineIMAP -description: | - OfflineIMAP is software that downloads your email mailbox(es) as local - Maildirs. OfflineIMAP will synchronize both sides via IMAP. - -``` - -#### Confinement - -To get started we won’t confine this application. Unconfined applications, specified with `devmode`, can only be released to the hidden “edge” channel where you and other developers can install them. - -``` -confinement: devmode - -``` - -#### Parts - -Parts define how to build your app. Parts can be anything: programs, libraries, or other assets needed to create and run your application. In this case we have one: the offlineimap source code. In other cases these can point to local directories, remote git repositories, or tarballs. - -The Python plugin will also bundle Python in the snap, so you can be sure that the version of Python you test against is included with your app. Dependencies from `install_requires` in your `setup.py` will also be bundled. Dependencies from a `requirements.txt` file can also be bundled using the `requirements:` option. - -``` -parts: - offlineimap: - plugin: python - python-version: python2 - source: . - -``` - -#### Apps - -Apps are the commands and services exposed to end users. If your command name matches the snap `name`, users will be able run the command directly. If the names differ, then apps are prefixed with the snap `name`(`offlineimap.command-name`, for example). This is to avoid conflicting with apps defined by other installed snaps. - -If you don’t want your command prefixed you can request an alias for it on the [Snapcraft forum][1]. These command aliases are set up automatically when your snap is installed from the Snap Store. - -``` -apps: - offlineimap: - command: bin/offlineimap - -``` - -If your application is intended to run as a service, add the line `daemon: simple` after the command keyword. This will automatically keep the service running on install, update and reboot. - -### Building the snap - -You’ll first need to [install snap support][2], and then install the snapcraft tool: - -``` -sudo snap install --beta --classic snapcraft - -``` - -If you have just installed snap support, start a new shell so your `PATH` is updated to include `/snap/bin`. You can then build this example yourself: - -``` -git clone https://github.com/snapcraft-docs/offlineimap -cd offlineimap -snapcraft - -``` - -The resulting snap can be installed locally. This requires the `--dangerous` flag because the snap is not signed by the Snap Store. The `--devmode` flag acknowledges that you are installing an unconfined application: - -``` -sudo snap install offlineimap_*.snap --devmode --dangerous - -``` - -You can then try it out: - -``` -offlineimap - -``` - -Removing the snap is simple too: - -``` -sudo snap remove offlineimap - -``` - -Jump ahead to [Share with your friends][3] or continue to read another example. - -### youtube-dl - -The youtube-dl example shows a `snapcraft.yaml` using a tarball of a Python application and `ffmpeg` bundled in the snap to satisfy the runtime requirements. Here is the entire `snapcraft.yaml` for youtube-dl. We’ll break this down. - -``` -name: youtube-dl -version: 2017.06.18 -summary: YouTube Downloader. -description: | - youtube-dl is a small command-line program to download videos from - YouTube.com and a few more sites. - -grade: devel -confinement: devmode - -parts: - youtube-dl: - source: https://github.com/rg3/youtube-dl/archive/$SNAPCRAFT_PROJECT_VERSION.tar.gz - plugin: python - python-version: python3 - after: [ffmpeg] - -apps: - youtube-dl: - command: bin/youtube-dl - -``` - -#### Parts - -The `$SNAPCRAFT_PROJECT_VERSION` variable is derived from the `version:` stanza and used here to reference the matching release tarball. Because the `python` plugin is used, snapcraft will bundle a copy of Python in the snap using the version specified in the `python-version:` stanza, in this case Python 3. - -youtube-dl makes use of `ffmpeg` to transcode or otherwise convert the audio and video file it downloads. In this example, youtube-dl is told to build after the `ffmpeg` part. Because the `ffmpeg` part specifies no plugin, it will be fetched from the parts repository. This is a collection of community-contributed definitions which can be used by anyone when building a snap, saving you from needing to specify the source and build rules for each system dependency. You can use `snapcraft search` to find more parts to use and `snapcraft define ` to verify how the part is defined. - -``` -parts: - youtube-dl: - source: https://github.com/rg3/youtube-dl/archive/$SNAPCRAFT_PROJECT_VERSION.tar.gz - plugin: python - python-version: python3 - after: [ffmpeg] - -``` - -### Building the snap - -You can build this example yourself by running the following: - -``` -git clone https://github.com/snapcraft-docs/youtube-dl -cd youtube-dl -snapcraft - -``` - -The resulting snap can be installed locally. This requires the `--dangerous` flag because the snap is not signed by the Snap Store. The `--devmode` flag acknowledges that you are installing an unconfined application: - -``` -sudo snap install youtube-dl_*.snap --devmode --dangerous - -``` - -Run the command: - -``` -youtube-dl “https://www.youtube.com/watch?v=k-laAxucmEQ” - -``` - -Removing the snap is simple too: - -``` -sudo snap remove youtube-dl - -``` - -### Share with your friends - -To share your snaps you need to publish them in the Snap Store. First, create an account on [the dashboard][4]. Here you can customize how your snaps are presented, review your uploads and control publishing. - -You’ll need to choose a unique “developer namespace” as part of the account creation process. This name will be visible by users and associated with your published snaps. - -Make sure the `snapcraft` command is authenticated using the email address attached to your Snap Store account: - -``` -snapcraft login - -``` - -### Reserve a name for your snap - -You can publish your own version of a snap, provided you do so under a name you have rights to. - -``` -snapcraft register mypythonsnap - -``` - -Be sure to update the `name:` in your `snapcraft.yaml` to match this registered name, then run `snapcraft` again. - -### Upload your snap - -Use snapcraft to push the snap to the Snap Store. - -``` -snapcraft push --release=edge mypthonsnap_*.snap - -``` - -If you’re happy with the result, you can commit the snapcraft.yaml to your GitHub repo and [turn on automatic builds][5] so any further commits automatically get released to edge, without requiring you to manually build locally. - -### Further customisations - -Here are all the Python plugin-specific keywords: - -``` -- requirements: - (string) - Path to a requirements.txt file -- constraints: - (string) - Path to a constraints file -- process-dependency-links: - (bool; default: false) - Enable the processing of dependency links in pip, which allow one project - to provide places to look for another project -- python-packages: - (list) - A list of dependencies to get from PyPI -- python-version: - (string; default: python3) - The python version to use. Valid options are: python2 and python3 - -``` - -You can view them locally by running: - -``` -snapcraft help python - -``` - -### Extending and overriding behaviour - -You can [extend the behaviour][6] of any part in your `snapcraft.yaml` with shell commands. These can be run after pulling the source code but before building by using the `prepare` keyword. The build process can be overridden entirely using the `build` keyword and shell commands. The `install` keyword is used to run shell commands after building your code, useful for making post build modifications such as relocating build assets. - -Using the youtube-dl example above, we can run the test suite at the end of the build. If this fails, the snap creation will be terminated: - -``` -parts: - youtube-dl: - source: https://github.com/rg3/youtube-dl/archive/$SNAPCRAFT_PROJECT_VERSION.tar.gz - plugin: python - python-version: python3 - stage-packages: [ffmpeg, python-nose] - install: | - nosetests -``` - --------------------------------------------------------------------------------- - -via: https://docs.snapcraft.io/build-snaps/python - -作者:[Snapcraft.io ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:Snapcraft.io - -[1]:https://forum.snapcraft.io/t/process-for-reviewing-aliases-auto-connections-and-track-requests/455 -[2]:https://docs.snapcraft.io/core/install -[3]:https://docs.snapcraft.io/build-snaps/python#share-with-your-friends -[4]:https://dashboard.snapcraft.io/openid/login/?next=/dev/snaps/ -[5]:https://build.snapcraft.io/ -[6]:https://docs.snapcraft.io/build-snaps/scriptlets diff --git a/sources/tech/20171202 Scrot Linux command-line screen grabs made simple b/sources/tech/20171202 Scrot Linux command-line screen grabs made simple deleted file mode 100644 index 979ed86b3c..0000000000 --- a/sources/tech/20171202 Scrot Linux command-line screen grabs made simple +++ /dev/null @@ -1,72 +0,0 @@ -Translating by filefi - -# Scrot: Linux command-line screen grabs made simple - -by [Scott Nesbitt][a] · November 30, 2017 - -> Scrot is a basic, flexible tool that offers a number of handy options for taking screen captures from the Linux command line. - -[![Original photo by Rikki Endsley. CC BY-SA 4.0](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/community-penguins-osdc-lead.png?itok=BmqsAF4A)][1] - - - -There are great tools on the Linux desktop for taking screen captures, such as [KSnapshot][2] and [Shutter][3]. Even the simple utility that comes with the GNOME desktop does a pretty good job of capturing screens. But what if you rarely need to take screen captures? Or you use a Linux distribution without a built-in capture tool, or an older computer with limited resources? - -Turn to the command line and a little utility called [Scrot][4]. It does a fine job of taking simple screen captures, and it includes a few features that might surprise you. - -### Getting started with Scrot -Many Linux distributions come with Scrot already installed—to check, type `which scrot`. If it isn't there, you can install Scrot using your distro's package manager. If you're willing to compile the code, grab it [from GitHub][5]. - -To take a screen capture, crack open a terminal window and type `scrot [filename]`, where `[filename]` is the name of file to which you want to save the image (for example, `desktop.png`). If you don't include a name for the file, Scrot will create one for you, such as `2017-09-24-185009_1687x938_scrot.png`. (That filename isn't as descriptive it could be, is it? That's why it's better to add one to the command.) - -Running Scrot with no options takes a screen capture of your entire desktop. If you don't want to do that, Scrot lets you focus on smaller portions of your screen. - -### Taking a screen capture of a single window - -Tell Scrot to take a screen capture of a single window by typing `scrot -u [filename]`. - -The `-u` option tells Scrot to grab the window currently in focus. That's usually the terminal window you're working in, which might not be the one you want. - -To grab another window on your desktop, type `scrot -s [filename]`. - -The `-s` option lets you do one of two things: - -* select an open window, or - -* draw a rectangle around a window or a portion of a window to capture it. - -You can also set a delay, which gives you a little more time to select the window you want to capture. To do that, type `scrot -u -d [num] [filename]`. - -The `-d` option tells Scrot to wait before grabbing the window, and `[num]` is the number of seconds to wait. Specifying `-d 5` (wait five seconds) should give you enough time to choose a window. - -### More useful options - -Scrot offers a number of additional features (most of which I never use). The ones I find most useful include: - -* `-b` also grabs the window's border - -* `-t` grabs a window and creates a thumbnail of it. This can be useful when you're posting screen captures online. - -* `-c` creates a countdown in your terminal when you use the `-d` option. - -To learn about Scrot's other options, check out the its documentation by typing `man scrot` in a terminal window, or [read it online][6]. Then start snapping images of your screen. - -It's basic, but Scrot gets the job done nicely. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot - -作者:[Scott Nesbitt][a] -译者:[filefi](https://github.com/filefi) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/scottnesbitt -[1]:https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/community-penguins-osdc-lead.png?itok=BmqsAF4A -[2]:https://www.kde.org/applications/graphics/ksnapshot/ -[3]:https://launchpad.net/shutter -[4]:https://github.com/dreamer/scrot -[5]:http://manpages.ubuntu.com/manpages/precise/man1/scrot.1.html -[6]:https://github.com/dreamer/scrot diff --git a/sources/tech/20171202 docker - Use multi-stage builds.md b/sources/tech/20171202 docker - Use multi-stage builds.md deleted file mode 100644 index e1a6414862..0000000000 --- a/sources/tech/20171202 docker - Use multi-stage builds.md +++ /dev/null @@ -1,127 +0,0 @@ -Use multi-stage builds -============================================================ - -Multi-stage builds are a new feature requiring Docker 17.05 or higher on the daemon and client. Multistage builds are useful to anyone who has struggled to optimize Dockerfiles while keeping them easy to read and maintain. - -> Acknowledgment: Special thanks to [Alex Ellis][1] for granting permission to use his blog post [Builder pattern vs. Multi-stage builds in Docker][2] as the basis of the examples below. - -### Before multi-stage builds - -One of the most challenging things about building images is keeping the image size down. Each instruction in the Dockerfile adds a layer to the image, and you need to remember to clean up any artifacts you don’t need before moving on to the next layer. To write a really efficient Dockerfile, you have traditionally needed to employ shell tricks and other logic to keep the layers as small as possible and to ensure that each layer has the artifacts it needs from the previous layer and nothing else. - -It was actually very common to have one Dockerfile to use for development (which contained everything needed to build your application), and a slimmed-down one to use for production, which only contained your application and exactly what was needed to run it. This has been referred to as the “builder pattern”. Maintaining two Dockerfiles is not ideal. - -Here’s an example of a `Dockerfile.build` and `Dockerfile` which adhere to the builder pattern above: - -`Dockerfile.build`: - -``` -FROM golang:1.7.3 -WORKDIR /go/src/github.com/alexellis/href-counter/ -RUN go get -d -v golang.org/x/net/html -COPY app.go . -RUN go get -d -v golang.org/x/net/html \ - && CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . - -``` - -Notice that this example also artificially compresses two `RUN` commands together using the Bash `&&` operator, to avoid creating an additional layer in the image. This is failure-prone and hard to maintain. It’s easy to insert another command and forget to continue the line using the `\` character, for example. - -`Dockerfile`: - -``` -FROM alpine:latest -RUN apk --no-cache add ca-certificates -WORKDIR /root/ -COPY app . -CMD ["./app"] - -``` - -`build.sh`: - -``` -#!/bin/sh -echo Building alexellis2/href-counter:build - -docker build --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy \ - -t alexellis2/href-counter:build . -f Dockerfile.build - -docker create --name extract alexellis2/href-counter:build -docker cp extract:/go/src/github.com/alexellis/href-counter/app ./app -docker rm -f extract - -echo Building alexellis2/href-counter:latest - -docker build --no-cache -t alexellis2/href-counter:latest . -rm ./app - -``` - -When you run the `build.sh` script, it needs to build the first image, create a container from it in order to copy the artifact out, then build the second image. Both images take up room on your system and you still have the `app` artifact on your local disk as well. - -Multi-stage builds vastly simplify this situation! - -### Use multi-stage builds - -With multi-stage builds, you use multiple `FROM` statements in your Dockerfile. Each `FROM` instruction can use a different base, and each of them begins a new stage of the build. You can selectively copy artifacts from one stage to another, leaving behind everything you don’t want in the final image. To show how this works, Let’s adapt the Dockerfile from the previous section to use multi-stage builds. - -`Dockerfile`: - -``` -FROM golang:1.7.3 -WORKDIR /go/src/github.com/alexellis/href-counter/ -RUN go get -d -v golang.org/x/net/html -COPY app.go . -RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . - -FROM alpine:latest -RUN apk --no-cache add ca-certificates -WORKDIR /root/ -COPY --from=0 /go/src/github.com/alexellis/href-counter/app . -CMD ["./app"] - -``` - -You only need the single Dockerfile. You don’t need a separate build script, either. Just run `docker build`. - -``` -$ docker build -t alexellis2/href-counter:latest . - -``` - -The end result is the same tiny production image as before, with a significant reduction in complexity. You don’t need to create any intermediate images and you don’t need to extract any artifacts to your local system at all. - -How does it work? The second `FROM` instruction starts a new build stage with the `alpine:latest` image as its base. The `COPY --from=0` line copies just the built artifact from the previous stage into this new stage. The Go SDK and any intermediate artifacts are left behind, and not saved in the final image. - -### Name your build stages - -By default, the stages are not named, and you refer to them by their integer number, starting with 0 for the first `FROM` instruction. However, you can name your stages, by adding an `as ` to the `FROM` instruction. This example improves the previous one by naming the stages and using the name in the `COPY` instruction. This means that even if the instructions in your Dockerfile are re-ordered later, the `COPY` won’t break. - -``` -FROM golang:1.7.3 as builder -WORKDIR /go/src/github.com/alexellis/href-counter/ -RUN go get -d -v golang.org/x/net/html -COPY app.go . -RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . - -FROM alpine:latest -RUN apk --no-cache add ca-certificates -WORKDIR /root/ -COPY --from=builder /go/src/github.com/alexellis/href-counter/app . -CMD ["./app"] -``` - --------------------------------------------------------------------------------- - -via: https://docs.docker.com/engine/userguide/eng-image/multistage-build/#name-your-build-stages - -作者:[docker docs ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://docs.docker.com/engine/userguide/eng-image/multistage-build/ -[1]:https://twitter.com/alexellisuk -[2]:http://blog.alexellis.io/mutli-stage-docker-builds/ diff --git a/translated/tech/20090701 The One in Which I Call Out Hacker News.md b/translated/tech/20090701 The One in Which I Call Out Hacker News.md deleted file mode 100644 index 670be95353..0000000000 --- a/translated/tech/20090701 The One in Which I Call Out Hacker News.md +++ /dev/null @@ -1,99 +0,0 @@ -我号召黑客新闻的理由之一 -实现高速缓存会花费 30 个小时,你有额外的 30 个小时吗? -不,你没有。 -我实际上并不知道它会花多少时间,可能它会花五分钟,你有五分钟吗?不,你还是没有。为什么?因为我在撒谎。它会消耗远超五分钟的时间,这是程序员永远的 -乐观主义。 -- Owen Astrachan 教授于 2004 年 2 月 23 日在 CPS 108 上的讲座 - -指责开源软件的使用存在着高昂的代价已经不是一个新论点了,它之前就被提过,而且说的比我更有信服力,即使一些人已经在高度赞扬开源软件的运作。 -这种事为什么会重复发生? - -在周一的黑客新闻上,我愉悦地看着某些人一边说写 Stack Overflow 简单的简直搞笑,一边通过允许七月第四个周末之后的克隆来开始备份他们的提问。 -其他的声明中也指出现存的克隆是一个好的出发点。 - -让我们假设,为了争辩,你觉得将自己的 Stack Overflow 通过 ASP.NET 和 MVC 克隆是正确的,然后被一块廉价的手表和一个小型俱乐部头领忽悠之后, -决定去手动拷贝你 Stack Overflow 的源代码,一页又一页,所以你可以逐字逐句地重新输入,我们同样会假定你像我一样打字,很酷的有 100 WPM -(差不多每秒8个字符),不和我一样的话,你不会犯错。 - - Stack Overflow 的 *.cs、*.sql、*.css、*.js 和 *.aspx 文件大约 2.3 MB,因此如果你想将这些源代码输进电脑里去的话,即使你不犯错也需要大约 80 个小时。 - -除非......当然,你是不会那样做的:你打算从头开始实现 Stack Overflow 。所以即使我们假设,你花了十倍的时间去设计、输出,然后调试你自己的实现而不是去拷 -贝已有的那份,那已经让你已经编译了好几个星期。我不知道你,但是我可以承认我写的新代码大大小于我复制的现有代码的十分之一。 - -好,ok,我听见你松了口气。所以不是全部。但是我可以做大部分。 - -行,所以什么是大部分?这只是询问和回答问题,这个部分很简单。那么,除了你必须实现对问题和答案投票、赞同还是反对,而且提问者应该能够去接收每一个问题的 -单一答案。你不能让人们赞同或者反对他们自己的回答。所以你需要去阻止。你需要去确保用户在一定的时间内不会赞同或反对其他用户太多次。以预防垃圾邮件, -你可能也需要去实现一个垃圾邮件过滤器,即使在一个基本的设计里,也要考虑到这一点。而且还需要去支持用户图标。并且你将不得不寻找一个自己真正信任的并且 -与 markdown 接合很好的 HTML 库(当然,你确实希望重新使用那个令人敬畏的编辑器 Stack Overflow ),你还需要为所有控件购买,设计或查找小部件,此外 -你至少需要一个基本的管理界面,以便用户可以调节,并且你需要实现可扩展的业务量,以便能稳定地给用户越来越多的功能去实现他们想做的。 - -如果你这样做了,你可以完成它。 - -除了...除了全文检索外,特别是它在“寻找问题”功能中的表现,这是必不可少的。然后用户的基本信息,和回答的意见,然后有一个主要展示你的重要问题, -但是它会稳定的冒泡式下降。另外你需要去实现奖励,并支持每个用户的多个 OpenID 登录,然后为相关的事件发送邮件通知,并添加一个标签系统, -接着允许管理员通过一个不错的图形界面配置徽章。你需要去显示用户的 karma 历史,点赞和差评。整个事情的规模都非常好,因为它随时都可以被 - slashdotted、reddited 或是 Stack Overflow 。 - -在这之后!你就已经完成了! - -...在正确地实现升级、国际化、业绩上限和一个 css 设计之后,使你的站点看起来不像是一个屁股,上面的大部分 AJAX 版本和 G-d 知道什么会同样潜伏 -在你所信任的界面下,但是当你开始做一个真正的克隆的时候,就会遇到它。 - -告诉我:这些功能中哪个是你感觉可以削减而让它仍然是一个引人注目的产品,哪些是大部分网站之下的呢?哪个你可以剔除呢? - -开发者因为开源软件的使用是一个可怕的痛苦这样一个相同的理由认为克隆一个像 Stack Overflow 的站点很简单。当你把一个开发者放在 Stack Overflow 前面, -他们并不真的看到 Stack Overflow,他们实际上看的是这些: - -create table QUESTION (ID identity primary key, - TITLE varchar(255), --- 为什么我知道你认为是 255 - BODY text, - UPVOTES integer not null default 0, - DOWNVOTES integer not null default 0, - USER integer references USER(ID)); -create table RESPONSE (ID identity primary key, - BODY text, - UPVOTES integer not null default 0, - DOWNVOTES integer not null default 0, - QUESTION integer references QUESTION(ID)) - -如果你告诉一个开发者去复制 Stack Overflow ,进入他脑海中的就是上面的两个 SQL 表和足够的 HTML 文件来显示它们,而不用格式化,这在一个周末里是完全 -可以实现的,聪明的人会意识到他们需要实现登陆、注销和评论,点赞需要绑定到用户。但是这在一个周末内仍然是完全可行的。这仅仅是在 SQL 后端里加上两张 -左右的表,而 HTML 则用来展示内容,使用像 Django 这样的框架,你甚至可以免费获得基本的用户和评论。 - -但是那不是和 Stack Overflow 相关的,无论你对 Stack Overflow 的感受如何,大多数访问者似乎都认为用户体验从头到尾都很流畅,他们感觉他们和一个 -好产品相互影响。即使我没有更好的了解,我也会猜测 Stack Overflow 在数据库模式方面取得了持续的成功-并且有机会去阅读 Stack Overflow 的源代码, -我知道它实际上有多么的小,这些是一个极大的 spit 和 Polish 的集合,成为了一个具有高可用性的主要网站,一个开发者,问一个东西被克隆有多难, -仅仅不认为和 Polish 相关,因为 Polish 是实现结果附带的。 - -这就是为什么 Stack Overflow 的开放源代码克隆会失败,即使一些人在设法实现大部分 Stack Overflow 的“规范”,也会有一些关键区域会将他们绊倒, -举个例子,如果你把目标市场定在了终端用户上,你要么需要一个图形界面去配置规则,要么聪明的开发者会决定哪些徽章具有足够的通用性,去继续所有的 -安装,实际情况是,开发者发牢骚和抱怨你不能实现一个真实的综合性的像 badges 的图形用户界面,然后 bikeshed 任何的建议,为因为标准的 badges -在范围内太远,他们会迅速避开选择其他方向,他们最后会带着相同的有 bug 追踪器的解决方案赶上,就像他们工作流程的概要使用一样: -开发者通过任意一种方式实现一个通用的机制,任何一个人完全都能轻松地使用 Python、PHP 或任意一门语言中的系统 API 来工作,能简单为他们自己增加 -自定义设置,PHP 和 Python 是学起来很简单的,并且比起曾经的图形界面更加的灵活,为什么还要操心其他事呢? - -同样的,节制和管理界面可以被削减。如果你是一个管理员,你可以进入 SQL 服务器,所以你可以做任何真正的管理-就像这样,管理员可以通过任何的 Django -管理和类似的系统给你提供支持,因为,毕竟只有少数用户是 mods,mods 应该理解网站是怎么运作、停止的。当然,没有 Stack Overflow 的接口失败会被纠正 -,即使 Stack Overflow 的愚蠢的要求,你必须知道如何去使用 openID (它是最糟糕的缺点)最后得到修复。我确信任何的开源的克隆都会狂热地跟随它- -即使 GNOME 和 KDE 多年来亦步亦趋地复制 windows ,而不是尝试去修复它自己最明显的缺陷。 - -开发者可能不会关心应用的这些部分,但是最终用户会,当他们尝试去决定使用哪个应用时会去考虑这些。就好像一家好的软件公司希望通过确保其产品在出货之前 -是一流的来降低其支持成本一样,所以,同样的,懂行的消费者想在他们购买这些产品之前确保产品好用,以便他们不需要去寻求帮助,开源产品就失败在这种地方 -,一般来说,专有解决方案会做得更好。 - -这不是说开源软件没有他们自己的立足之地,这个博客运行在 Apache,Django,PostgreSQL 和 Linux 上。但是让我告诉你,配置这些堆栈不是为了让人心灰意懒 -,PostgreSQL 需要在老版本上移除设置。然后,在 Ubuntu 和 FreeBSD 最新的版本上,仍然要求用户搭建第一个数据库集群,MS SQL不需要这些东西,Apache... -天啊,甚至没有让我开始尝试去向一个初学者用户解释如何去得到虚拟机,MovableType,一对 Django 应用程序,而且所有的 WordPress 都可以在一个单一的安装下 -顺利运行,像在地狱一样,只是试图解释 Apache 的分叉线程变换给技术上精明的非开发人员就是一个噩梦,IIS 7 和操作系统的 Apache 服务器是非常闭源的, -图形界面管理程序配置这些这些相同的堆栈非常的简单,Django 是一个伟大的产品,但是它只是基础架构而已,我认为开源软件做的很好,恰恰是因为推动开发者去 -贡献的动机 - -下次你看见一个你喜欢的应用,认为所有面向用户的细节非常长和辛苦,就会去让它用起来更令人开心,在谴责你如何能普通的实现整个的可恶的事在一个周末, -十分之九之后,当你认为一个应用的实现简单地简直可笑,你就完全的错失了故事另一边的用户 - -via: https://bitquabit.com/post/one-which-i-call-out-hacker-news/ - -作者:Benjamin Pollack 译者:hopefully2333 校对:校对者ID - -本文由 LCTT 原创编译,Linux中国 荣誉推出 diff --git a/published/20161216 Kprobes Event Tracing on ARMv8.md b/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md similarity index 98% rename from published/20161216 Kprobes Event Tracing on ARMv8.md rename to translated/tech/20161216 Kprobes Event Tracing on ARMv8.md index 3985f064dc..3c3ab0de5b 100644 --- a/published/20161216 Kprobes Event Tracing on ARMv8.md +++ b/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md @@ -29,19 +29,19 @@ jprobes 允许通过提供一个具有相同调用签名call signature kprobes 提供一系列能从内核代码中调用的 API 来设置探测点和当探测点被命中时调用的注册函数。在不往内核中添加代码的情况下,kprobes 也是可用的,这是通过写入特定事件追踪的 debugfs 文件来实现的,需要在文件中设置探针地址和信息,以便在探针被命中时记录到追踪日志中。后者是本文将要讨论的重点。最后 kprobes 可以通过 perl 命令来使用。 -#### kprobes API +### kprobes API 内核开发人员可以在内核中编写函数(通常在专用的调试模块中完成)来设置探测点,并且在探测指令执行前和执行后立即执行任何所需操作。这在 kprobes.txt 中有很好的解释。 -#### 事件追踪 +### 事件追踪 事件追踪子系统有自己的自己的文档^注2 ,对于了解一般追踪事件的背景可能值得一读。事件追踪子系统是追踪点tracepoints和 kprobes 事件追踪的基础。事件追踪文档重点关注追踪点,所以请在查阅文档时记住这一点。kprobes 与追踪点不同的是没有预定义的追踪点列表,而是采用动态创建的用于触发追踪事件信息收集的任意探测点。事件追踪子系统通过一系列 debugfs 文件来控制和监视。事件追踪(`CONFIG_EVENT_TRACING`)将在被如 kprobe 事件追踪子系统等需要时自动选择。 -##### kprobes 事件 +#### kprobes 事件 使用 kprobes 事件追踪子系统,用户可以在内核任意断点处指定要报告的信息,只需要指定任意现有可探测指令的地址以及格式化信息即可确定。在执行过程中遇到断点时,kprobes 将所请求的信息传递给事件追踪子系统的公共部分,这些部分将数据格式化并追加到追踪日志中,就像追踪点的工作方式一样。kprobes 使用一个类似的但是大部分是独立的 debugfs 文件来控制和显示追踪事件信息。该功能可使用 `CONFIG_KPROBE_EVENT` 来选择。Kprobetrace 文档^ 注3 提供了如何使用 kprobes 事件追踪的基本信息,并且应当被参考用以了解以下介绍示例的详细信息。 -#### kprobes 和 perf +### kprobes 和 perf perf 工具为 kprobes 提供了另一个命令行接口。特别地,`perf probe` 允许探测点除了由函数名加偏移量和地址指定外,还可由源文件和行号指定。perf 接口实际上是使用 kprobes 的 debugfs 接口的封装器。 @@ -60,7 +60,7 @@ perf 工具为 kprobes 提供了另一个命令行接口。特别地,`perf pro kprobes 的一个常用例子是检测函数入口和/或出口。因为只需要使用函数名来作为探针地址,它安装探针特别简单。kprobes 事件追踪将查看符号名称并且确定地址。ARMv8 调用标准定义了函数参数和返回值的位置,并且这些可以作为 kprobes 事件处理的一部分被打印出来。 -#### 例子: 函数入口探测 +### 例子: 函数入口探测 检测 USB 以太网驱动程序复位功能: @@ -94,7 +94,7 @@ kworker/0:0-4 [000] d… 10972.102939: p_ax88772_reset_0: 这里我们可以看见传入到我们的探测函数的指针参数的值。由于我们没有使用 kprobes 事件追踪的可选标签功能,我们需要的信息自动被标注为 `arg1`。注意这指向我们需要 kprobes 记录这个探针的一组值的第一个,而不是函数参数的实际位置。在这个例子中它也只是碰巧是我们探测函数的第一个参数。 -#### 例子: 函数入口和返回探测 +### 例子: 函数入口和返回探测 kretprobe 功能专门用于探测函数返回。在函数入口 kprobes 子系统将会被调用并且建立钩子以便在函数返回时调用,钩子将记录需求事件信息。对最常见情况,返回信息通常在 `X0` 寄存器中,这是非常有用的。在 `%x0` 中返回值也可以被称为 `$retval`。以下例子也演示了如何提供一个可读的标签来展示有趣的信息。 @@ -132,7 +132,7 @@ _$ cat trace bash-1671 [001] d..1 214.401975: r__do_fork_0: (SyS_clone+0x18/0x20 <- _do_fork) pid=0x726_ ``` -#### 例子: 解引用指针参数 +### 例子: 解引用指针参数 对于指针值,kprobes 事件处理子系统也允许解引用和打印所需的内存内容,适用于各种基本数据类型。为了展示所需字段,手动计算结构的偏移量是必要的。 @@ -173,7 +173,7 @@ $ cat trace bash-1702 [002] d..1 175.347349: wait_r: (SyS_wait4+0x74/0xe4 <- do_wait) arg1=0xfffffffffffffff6 ``` -#### 例子: 探测任意指令地址 +### 例子: 探测任意指令地址 在前面的例子中,我们已经为函数的入口和出口插入探针,然而探测一个任意指令(除少数例外)是可能的。如果我们正在 C 函数中放置一个探针,第一步是查看代码的汇编版本以确定我们要放置探针的位置。一种方法是在 vmlinux 文件上使用 gdb,并在要放置探针的函数中展示指令。下面是一个在 `arch/arm64/kernel/modules.c` 中 `module_alloc` 函数执行此操作的示例。在这种情况下,因为 gdb 似乎更喜欢使用弱符号定义,并且它是与这个函数关联的存根代码,所以我们从 System.map 中来获取符号值: diff --git a/translated/tech/20170530 How to Improve a Legacy Codebase.md b/translated/tech/20170530 How to Improve a Legacy Codebase.md deleted file mode 100644 index a1869b0449..0000000000 --- a/translated/tech/20170530 How to Improve a Legacy Codebase.md +++ /dev/null @@ -1,104 +0,0 @@ -# 如何改善遗留的代码库 - -这在每一个程序员,项目管理员,团队领导的一生中都会至少发生一次。原来的程序员早已离职去度假了,留下了一坨几百万行屎一样的代码和文档(如果有的话),一旦接手这些代码,想要跟上公司的进度简直让人绝望。 - -你的工作是带领团队摆脱这个混乱的局面 - -当你的第一反应过去之后,你开始去熟悉这个项目,公司的管理层都在关注着你,所以项目只能成功,然而,看了一遍代码之后却发现很大的可能会失败。那么该怎么办呢? - -幸运(不幸)的是我已经遇到好几次这种情况了,我和我的小伙伴发现将这坨热气腾腾的屎变成一个健康可维护的项目是非常值得一试的。下面这些是我们的一些经验: - -### 备份 - -在开始做任何事情之前备份与之可能相关的所有文件。这样可以确保不会丢失任何可能会在另外一些地方很重要的信息。一旦修改其中一些文件,你可能花费一天或者更多天都解决不了这个愚蠢的问题,配置数据通常不受版本控制,所以特别容易受到这方面影响,如果定期备份数据时连带着它一起备份了,还是比较幸运的。所以谨慎总比后悔好,复制所有东西到一个绝对安全的地方吧,除非这些文件是只读模式否则不要轻易碰它。 - -### 必须确保代码能够在生产环境下构建运行并产出,这是重要的先决条件。 - -之前我假设环境已经存在,所以完全丢了这一步,Hacker News 的众多网友指出了这一点并且证明他们是对的:第一步是确认你知道在生产环境下运行着什么东西,也意味着你需要在你的设备上构建一个跟生产环境上运行的版本每一个字节都一模一样的版本。如果你找不到实现它的办法,一旦你将它投入生产环境,你很可能会遭遇一些很糟糕的事情。确保每一部分都尽力测试,之后在你足够信任它能够很好的运行的时候将它部署生产环境下。无论它运行的怎么样都要做好能够马上切换回旧版本的准备,确保日志记录下了所有情况,以便于接下来不可避免的 “验尸” 。 - -### 冻结数据库 - -直到你修改代码之前尽可能冻结你的数据库,在你特别熟悉代码库和遗留代码之后再去修改数据库。在这之前过早的修改数据库的话,你可能会碰到大问题,你会失去让新旧代码和数据库一起构建稳固的基础的能力。保持数据库完全不变,就能比较新的逻辑代码和旧的逻辑代码运行的结果,比较的结果应该跟预期的没有差别。 - -### 写测试 - -在你做任何改变之前,尽可能多的写下端到端测试和集成测试。在你能够清晰的知道旧的是如何工作的情况下确保这些测试能够正确的输出(准备好应对一些突发状况)。这些测试有两个重要的作用,其一,他们能够在早期帮助你抛弃一些错误观念,其二,在你写新代码替换旧代码的时候也有一定防护作用。 - -自动化测试,如果你也有 CI 的使用经验请使用它,并且确保在你提交代码之后能够快速的完成所有测试。 - -### 日志监控 - -如果旧设备依然可用,那么添加上监控功能。使用一个全新的数据库,为每一个你能想到的事件都添加一个简单的计数器,并且根据这些事件的名字添加一个函数增加这些计数器。用一些额外的代码实现一个带有时间戳的事件日志,这是一个好办法知道有多少事件导致了另外一些种类的事件。例如:用户打开 APP ,用户关闭 APP 。如果这两个事件导致后端调用的数量维持长时间的不同,这个数量差就是当前打开的 APP 的数量。如果你发现打开 APP 比关闭 APP 多的时候,你就必须要知道是什么原因导致 APP 关闭了(例如崩溃)。你会发现每一个事件都跟其他的一些事件有许多不同种类的联系,通常情况下你应该尽量维持这些固定的联系,除非在系统上有一个明显的错误。你的目标是减少那些错误的事件,尽可能多的在开始的时候通过使用计数器在调用链中降低到指定的级别。(例如:用户支付应该得到相同数量的支付回调)。 - -这是简单的技巧去将每一个后端应用变成一个就像真实的簿记系统一样,所有数字必须匹配,只要他们在某个地方都不会有什么问题。 - -随着时间的推移,这个系统在监控健康方面变得非常宝贵,而且它也是使用源码控制修改系统日志的一个好伙伴,你可以使用它确认 BUG 出现的位置,以及对多种计数器造成的影响。 - -我通常保持 5 分钟(一小时 12 次)记录一次计数器,如果你的应用生成了更多或者更少的事件,你应该修改这个时间间隔。所有的计数器公用一个数据表,每一个记录都只是简单的一行。 - -### 一次只修改一处 - -不要完全陷入在提高代码或者平台可用性的同时添加新特性或者是修复 BUG 的陷阱。这会让你头大而且将会使你之前建立的测试失效,现在必须问问你自己,每一步的操作想要什么样的结果。 - -### 修改平台 - -如果你决定转移你的应用到另外一个平台,最主要的是跟之前保持一样。如果你觉得你会添加更多的文档和测试,但是不要忘记这一点,所有的业务逻辑和相互依赖跟从前一样保持不变。 - -### 修改架构 - -接下来处理的是改变应用的结构(如果需要)。这一点上,你可以自由的修改高层的代码,通常是降低模块间的横向联系,这样可以降低代码活动期间对终端用户造成的影响范围。如果老代码是庞大的,那么现在正是让他模块化的时候,将大段代码分解成众多小的,不过不要把变量的名字和他的数据结构分开。 - -Hacker News [mannykannot][1] 网友指出,修改架构并不总是可行,如果你特别不幸的话,你可能为了改变一些架构必须付出沉重的代价。我也赞同这一点,我应该加上这一点,因此这里有一些补充。我非常想补充的是如果你修改高级代码的时候修改了一点点底层代码,那么试着限制只修改一个文件或者最坏的情况是只修改一个子系统,所以尽可能限制修改的范围。否则你可能很难调试刚才所做的更改。 - -### 底层代码的重构 - -现在,你应该非常理解每一个模块的作用了,准备做一些真正的工作吧:重构代码以提高其可维护性并且使代码做好添加新功能的准备。这很可能是项目中最消耗时间的部分,记录你所做的任何操作,在你彻底的记录模块并且理解之前不要对它做任何修改。之后你可以自由的修改变量名、函数名以及数据结构以提高代码的清晰度和统一性,然后请做测试(情况允许的话,包括单元测试)。 - -### 修复 bugs - -现在准备做一些用户可见的修改,战斗的第一步是修复很多积累了一整年的bugs,像往常一样,首先证实 bug 仍然存在,然后编写测试并修复这个 bug,你的 CI 和端对端测试应该能避免一些由于不太熟悉或者一些额外的事情而犯的错误。 - -### 升级数据库 - - -如果在一个坚实且可维护的代码库上完成所有工作,如果你有更改数据库模式的计划,可以使用不同的完全替换数据库。 -把所有的这些都做完将能够帮助你更可靠的修改而不会碰到问题,你会完全的测试新数据库和新代码,所有测试可以确保你顺利的迁移。 - -### 按着路线图执行 - -祝贺你脱离的困境并且可以准备添加新功能了。 - -### 任何时候都不要尝试彻底重写 - -彻底重写是那种注定会失败的项目,一方面,你在一个未知的领域开始,所以你甚至不知道构建什么,另一方面,你会把所以的问题都推到新系统马上就要上线的前一天,非常不幸的是,这也是你失败的时候,假设业务逻辑存在问题,你会得到异样的眼光,那时您会突然明白为什么旧系统会用某种奇怪的方式来工作,最终也会意识到能将旧系统放在一起工作的人也不都是白痴。在那之后。如果你真的想破坏公司(和你自己的声誉),那就重写吧,但如果你足够聪明,彻底重写系统通常不会成为一个摆到桌上讨论的选项。 - -### 所以,替代方法是增量迭代工作 - -要解开这些线团最快方法是,使用你熟悉的代码中任何的元素(它可能是外部的,他可以是内核模块),试着使用旧的上下文去增量提升,如果旧的构建工具已经不能用了,你将必须使用一些技巧(看下面)至少当你开始做修改的时候,试着尽力保留已知的工作。那样随着代码库的提升你也对代码的作用更加理解。一个典型的代码提交应该最多两行。 - -### 发布! - -每一次的修改都发布到生产环境,即使一些修改不是用户可见的。使用最少的步骤也是很重要的,因为当你缺乏对系统的了解时,只有生产环境能够告诉你问题在哪里,如果你只做了一个很小的修改之后出了问题,会有一些好处: - -* 很容易弄清楚出了什么问题 -* 这是一个改进流程的好位置 -* 你应该马上更新文档展示你的新见解 - -### 使用代理的好处 -如果你做 web 开发时在旧系统和用户之间加了代理。你能很容易的控制每一个网址哪些请求旧系统,哪些重定向到新系统,从而更轻松更精确的控制运行的内容以及谁能够看到。如果你的代理足够的聪明,你可以使用它发送一定比例的流量到个人的 URL,直到你满意为止,如果你的集成测试也连接到这个接口那就更好了。 - -### 是的,这会花费很多时间 -这取决于你怎样看待它的,这是事实会有一些重复的工作涉及到这些步骤中。但是它确实有效,对于进程的任何一个优化都将使你对这样系统更加熟悉。我会保持声誉,并且我真的不喜欢在工作期间有负面的意外。如果运气好的话,公司系统已经出现问题,而且可能会影响客户。在这样的情况下,如果你更多地是牛仔的做事方式,并且你的老板同意可以接受冒更大的风险,我比较喜欢完全控制整个流程得到好的结果而不是节省两天或者一星期,但是大多数公司宁愿采取稍微慢一点但更确定的胜利之路。 - --------------------------------------------------------------------------------- - -via: https://jacquesmattheij.com/improving-a-legacy-codebase - -作者:[Jacques Mattheij][a] -译者:[aiwhj](https://github.com/aiwhj) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://jacquesmattheij.com/ -[1]:https://news.ycombinator.com/item?id=14445661 diff --git a/translated/tech/20170910 Cool vim feature sessions.md b/translated/tech/20170910 Cool vim feature sessions.md deleted file mode 100644 index 49ee43fda1..0000000000 --- a/translated/tech/20170910 Cool vim feature sessions.md +++ /dev/null @@ -1,44 +0,0 @@ -vim 的酷功能:会话! -============================================================• - -昨天我在编写我的[vimrc][5]的时候了解到一个很酷的 vim 功能!(主要为了添加 fzf 和 ripgrep 插件)。这是一个内置功能,不需要特别的插件。 - -所以我画了一个漫画。 - -基本上你可以用下面的命令保存所有你打开的文件和当前的状态 - -``` -:mksession ~/.vim/sessions/foo.vim - -``` - -接着用 `:source ~/.vim/sessions/foo.vim` 或者  `vim -S ~/.vim/sessions/foo.vim` 还原会话。非常酷! - -一些 vim 插件给 vim 会话添加了额外的功能: - -* [https://github.com/tpope/vim-obsession][1] - -* [https://github.com/mhinz/vim-startify][2] - -* [https://github.com/xolox/vim-session][3] - -这是漫画: - -![](https://jvns.ca/images/vimsessions.png) - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/2017/09/10/vim-sessions/ - -作者:[Julia Evans ][a] -译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://jvns.ca/about -[1]:https://github.com/tpope/vim-obsession -[2]:https://github.com/mhinz/vim-startify -[3]:https://github.com/xolox/vim-session -[4]:https://jvns.ca/categories/vim -[5]:https://github.com/jvns/vimconfig/blob/master/vimrc diff --git a/published/20171009 Examining network connections on Linux systems.md b/translated/tech/20171009 Examining network connections on Linux systems.md similarity index 100% rename from published/20171009 Examining network connections on Linux systems.md rename to translated/tech/20171009 Examining network connections on Linux systems.md diff --git a/translated/tech/20171020 How Eclipse is advancing IoT development.md b/translated/tech/20171020 How Eclipse is advancing IoT development.md deleted file mode 100644 index 0de4f38ea1..0000000000 --- a/translated/tech/20171020 How Eclipse is advancing IoT development.md +++ /dev/null @@ -1,77 +0,0 @@ -translated by smartgrids -Eclipse 如何助力 IoT 发展 -============================================================ - -### 开源组织的模块发开发方式非常适合物联网。 - -![How Eclipse is advancing IoT development](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_BUS_ArchitectureOfParticipation_520x292.png?itok=FA0Uuwzv "How Eclipse is advancing IoT development") -图片来源: opensource.com - -[Eclipse][3] 可能不是第一个去研究物联网的开源组织。但是,远在 IoT 家喻户晓之前,该基金会在 2001 年左右就开始支持开源软件发展商业化。九月 Eclipse 物联网日和 RedMonk 的 [ThingMonk 2017][4] 一块举行,着重强调了 Eclipse 在 [物联网发展][5] 中的重要作用。它现在已经包含了 28 个项目,覆盖了大部分物联网项目需求。会议过程中,我和负责 Eclipse 市场化运作的 [Ian Skerritt][6] 讨论了 Eclipse 的物联网项目以及如何拓展它。 - -###物联网的最新进展? -我问 Ian 物联网同传统工业自动化,也就是前几十年通过传感器和相应工具来实现工厂互联的方式有什么不同。 Ian 指出很多工厂是还没有互联的。 -另外,他说“ SCADA[监控和数据分析] 系统以及工厂底层技术都是私有、独立性的。我们很难去改变它,也很难去适配它们…… 现在,如果你想运行一套生产系统,你需要设计成百上千的单元。生产线想要的是满足用户需求,使制造过程更灵活,从而可以不断产出。” 这也就是物联网会带给制造业的一个很大的帮助。 - - -###Eclipse 物联网方面的研究 -Ian 对于 Eclipse 在物联网的研究是这样描述的:“满足任何物联网解决方案的核心基础技术” ,通过使用开源技术,“每个人都可以使用从而可以获得更好的适配性。” 他说,Eclipse 将物联网视为包括三层互联的软件栈。从更高的层面上看,这些软件栈(按照大家常见的说法)将物联网描述为跨越三个层面的网络。特定的观念可能认为含有更多的层面,但是他们一直符合这个三层模型的功能的: - -* 一种可以装载设备(例如设备、终端、微控制器、传感器)用软件的堆栈。 -* 将不同的传感器采集到的数据信息聚合起来并传输到网上的一类网关。这一层也可能会针对传感器数据检测做出实时反映。 -* 物联网平台后端的一个软件栈。这个后端云存储数据并能根据采集的数据比如历史趋势、预测分析提供服务。 - -这三个软件栈在 Eclipse 的白皮书 “ [The Three Software Stacks Required for IoT Architectures][7] ”中有更详细的描述。 - -Ian 说在这些架构中开发一种解决方案时,“需要开发一些特殊的东西,但是很多底层的技术是可以借用的,像通信协议、网关服务。需要一种模块化的方式来满足不用的需求场合。” Eclipse 关于物联网方面的研究可以概括为:开发模块化开源组件从而可以被用于开发大量的特定性商业服务和解决方案。 - -###Eclipse 的物联网项目 - -在众多一杯应用的 Eclipse 物联网应用中, Ian 举了两个和 [MQTT][8] 有关联的突出应用,一个设备与设备互联(M2M)的物联网协议。 Ian 把它描述成“一个专为重视电源管理工作的油气传输线监控系统的信息发布/订阅协议。MQTT 已经是众多物联网广泛应用标准中很成功的一个。” [Eclipse Mosquitto][9] 是 MQTT 的代理,[Eclipse Paho][10] 是他的客户端。 -[Eclipse Kura][11] 是一个物联网网关,引用 Ian 的话,“它连接了很多不同的协议间的联系”包括蓝牙、Modbus、CANbus 和 OPC 统一架构协议,以及一直在不断添加的协议。一个优势就是,他说,取代了你自己写你自己的协议, Kura 提供了这个功能并将你通过卫星、网络或其他设备连接到网络。”另外它也提供了防火墙配置、网络延时以及其它功能。Ian 也指出“如果网络不通时,它会存储信息直到网络恢复。” - -最新的一个项目中,[Eclipse Kapua][12] 正尝试通过微服务来为物联网云平台提供不同的服务。比如,它集成了通信、汇聚、管理、存储和分析功能。Ian 说“它正在不断前进,虽然还没被完全开发出来,但是 Eurotech 和 RedHat 在这个项目上非常积极。” -Ian 说 [Eclipse hawkBit][13] ,软件更新管理的软件,是一项“非常有趣的项目。从安全的角度说,如果你不能更新你的设备,你将会面临巨大的安全漏洞。”很多物联网安全事故都和无法更新的设备有关,他说,“ HawkBit 可以基本负责通过物联网系统来完成扩展性更新的后端管理。” - -物联网设备软件升级的难度一直被看作是难度最高的安全挑战之一。物联网设备不是一直连接的,而且数目众多,再加上首先设备的更新程序很难完全正常。正因为这个原因,关于无赖女王软件升级的项目一直是被当作重要内容往前推进。 - -###为什么物联网这么适合 Eclipse - -在物联网发展趋势中的一个方面就是关于构建模块来解决商业问题,而不是宽约工业和公司的大物联网平台。 Eclipse 关于物联网的研究放在一系列模块栈、提供特定和大众化需求功能的项目,还有就是指定目标所需的可捆绑式中间件、网关和协议组件上。 - - --------------------------------------------------------------------------------- - - - -作者简介: - -Gordon Haff - Gordon Haff 是红帽公司的云营销员,经常在消费者和工业会议上讲话,并且帮助发展红帽全办公云解决方案。他是 计算机前言:云如何如何打开众多出版社未来之门 的作者。在红帽之前, Gordon 写了成百上千的研究报告,经常被引用到公众刊物上,像纽约时报关于 IT 的议题和产品建议等…… - --------------------------------------------------------------------------------- - -转自: https://opensource.com/article/17/10/eclipse-and-iot - -作者:[Gordon Haff ][a] -译者:[smartgrids](https://github.com/smartgrids) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/ghaff -[1]:https://opensource.com/article/17/10/eclipse-and-iot?rate=u1Wr-MCMFCF4C45IMoSPUacCatoqzhdKz7NePxHOvwg -[2]:https://opensource.com/user/21220/feed -[3]:https://www.eclipse.org/home/ -[4]:http://thingmonk.com/ -[5]:https://iot.eclipse.org/ -[6]:https://twitter.com/ianskerrett -[7]:https://iot.eclipse.org/resources/white-papers/Eclipse%20IoT%20White%20Paper%20-%20The%20Three%20Software%20Stacks%20Required%20for%20IoT%20Architectures.pdf -[8]:http://mqtt.org/ -[9]:https://projects.eclipse.org/projects/technology.mosquitto -[10]:https://projects.eclipse.org/projects/technology.paho -[11]:https://www.eclipse.org/kura/ -[12]:https://www.eclipse.org/kapua/ -[13]:https://eclipse.org/hawkbit/ -[14]:https://opensource.com/users/ghaff -[15]:https://opensource.com/users/ghaff -[16]:https://opensource.com/article/17/10/eclipse-and-iot#comments diff --git a/published/20171029 A block layer introduction part 1 the bio layer.md b/translated/tech/20171029 A block layer introduction part 1 the bio layer.md similarity index 95% rename from published/20171029 A block layer introduction part 1 the bio layer.md rename to translated/tech/20171029 A block layer introduction part 1 the bio layer.md index 96374c2302..bc3f582259 100644 --- a/published/20171029 A block layer introduction part 1 the bio layer.md +++ b/translated/tech/20171029 A block layer introduction part 1 the bio layer.md @@ -1,4 +1,4 @@ -回复:块层介绍第一部分 - 块 I/O 层 +块层介绍第一部分:块 I/O 层 ============================================================ ### 块层介绍第一部分:块 I/O 层 @@ -6,14 +6,9 @@ 回复:amarao 在[块层介绍第一部分:块 I/O 层][1] 中提的问题 先前的文章:[块层介绍第一部分:块 I/O 层][2] -![](https://static.lwn.net/images/2017/neil-blocklayer.png) - 嗨, - 你在这里描述的问题与块层不直接相关。这可能是一个驱动错误、可能是一个 SCSI 层错误,但绝对不是一个块层的问题。 - 不幸的是,报告针对 Linux 的错误是一件难事。有些开发者拒绝去看 bugzilla,有些开发者喜欢它,有些(像我这样)只能勉强地使用它。 - 另一种方法是发送电子邮件。为此,你需要选择正确的邮件列表,还有也许是正确的开发人员,当他们心情愉快,或者不是太忙或者不是假期时找到它们。有些人会努力回复所有,有些是完全不可预知的 - 这对我来说通常会发送一个补丁,包含一些错误报告。如果你只是有一个你自己几乎都不了解的 bug,那么你的预期响应率可能会更低。很遗憾,但这是是真的。 许多 bug 都会得到回应和处理,但很多 bug 都没有。 @@ -21,20 +16,18 @@ 我不认为说没有人关心是公平的,但是没有人认为它如你想的那样重要是有可能的。如果你想要一个解决方案,那么你需要驱动它。一个驱动它的方法是花钱请顾问或者与经销商签订支持合同。我怀疑你的情况没有上面的可能。另一种方法是了解代码如何工作,并自己找到解决方案。很多人都这么做,但是这对你来说可能不是一种选择。另一种方法是在不同的相关论坛上不断提出问题,直到得到回复。坚持可以见效。你需要做好准备去执行任何你所要求的测试,可能包括建立一个新的内核来测试。 如果你能在最近的内核(4.12 或者更新)上复现这个 bug,我建议你邮件报告给 linux-kernel@vger.kernel.org、linux-scsi@vger.kernel.org 和我(neilb@suse.com)(注意你不必订阅这些列表来发送邮件,只需要发送就行)。描述你的硬件以及如何触发问题的。 - 包含所有进程状态是 “D” 的栈追踪。你可以用 “cat /proc/$PID/stack” 来得到它,这里的 “$PID” 是进程的 pid。 确保避免抱怨或者说这个已经坏了好几年了以及这是多么严重不足。没有人关心这个。我们关心的是 bug 以及如何修复它。因此只要报告相关的事实就行。 - 尝试在邮件中而不是链接到其他地方的链接中包含所有事实。有时链接是需要的,但是对于你的脚本,它只有 8 行,所以把它包含在邮件中就行(并避免像 “fuckup” 之类的描述。只需称它为“坏的”(broken)或者类似的)。同样确保你的邮件发送的不是 HTML 格式。我们喜欢纯文本。HTML 被所有的 @vger.kernel.org 邮件列表拒绝。你或许需要配置你的邮箱程序不发送 HTML。 -------------------------------------------------------------------------------- via: https://lwn.net/Articles/737655/ -作者:[neilbrown][a] +作者:[ neilbrown][a] 译者:[geekpi](https://github.com/geekpi) -校对:[wxy](https://github.com/wxy) +校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/translated/tech/20171108 Archiving repositories.md b/translated/tech/20171108 Archiving repositories.md deleted file mode 100644 index 3d1a328541..0000000000 --- a/translated/tech/20171108 Archiving repositories.md +++ /dev/null @@ -1,37 +0,0 @@ -归档仓库 -==================== - - -因为仓库不再活跃开发或者你不想接受额外的贡献并不意味着你想要删除它。现在在 Github 上归档仓库让它变成只读。 - - [![archived repository banner](https://user-images.githubusercontent.com/7321362/32558403-450458dc-c46a-11e7-96f9-af31d2206acb.png)][1] - -归档一个仓库让它对所有人只读(包括仓库拥有者)。这包括编辑仓库、问题、合并请求、标记、里程碑、维基、发布、提交、标签、分支、反馈和评论。没有人可以在一个归档的仓库上创建新的问题、合并请求或者评论,但是你仍可以 fork 仓库-允许归档的仓库在其他地方继续开发。 - -要归档一个仓库,进入仓库设置页面并点在这个仓库上点击归档。 - - [![archive repository button](https://user-images.githubusercontent.com/125011/32273119-0fc5571e-bef9-11e7-9909-d137268a1d6d.png)][2] - -在归档你的仓库前,确保你已经更改了它的设置并考虑关闭所有的开放问题和合并请求。你还应该更新你的 README 和描述来让它让访问者了解他不再能够贡献。 - -如果你改变了主意想要解除归档你的仓库,在相同的地方点击解除归档。请注意大多数归档仓库的设置是隐藏的,并且你需要解除归档来改变它们。 - - [![archived labelled repository](https://user-images.githubusercontent.com/125011/32541128-9d67a064-c466-11e7-857e-3834054ba3c9.png)][3] - -要了解更多,请查看[这份文档][4]中的归档仓库部分。归档快乐! - --------------------------------------------------------------------------------- - -via: https://github.com/blog/2460-archiving-repositories - -作者:[MikeMcQuaid ][a] -译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://github.com/MikeMcQuaid -[1]:https://user-images.githubusercontent.com/7321362/32558403-450458dc-c46a-11e7-96f9-af31d2206acb.png -[2]:https://user-images.githubusercontent.com/125011/32273119-0fc5571e-bef9-11e7-9909-d137268a1d6d.png -[3]:https://user-images.githubusercontent.com/125011/32541128-9d67a064-c466-11e7-857e-3834054ba3c9.png -[4]:https://help.github.com/articles/about-archiving-repositories/ diff --git a/translated/tech/20171116 Introducing security alerts on GitHub.md b/translated/tech/20171116 Introducing security alerts on GitHub.md deleted file mode 100644 index b8f0afba17..0000000000 --- a/translated/tech/20171116 Introducing security alerts on GitHub.md +++ /dev/null @@ -1,48 +0,0 @@ -介绍 GitHub 上的安全警报 -==================================== - - -上个月,我们用依赖关系图让你更容易跟踪你代码依赖的的项目,目前支持 Javascript 和 Ruby。如今,超过 75% 的 GitHub 项目有依赖,我们正在帮助你做更多的事情,而不只是关注那些重要的项目。在启用依赖关系图后,当我们检测到你的依赖中有漏洞或者来自 Github 社区中建议的已知修复时通知你。 - - [![Security Alerts & Suggested Fix](https://user-images.githubusercontent.com/594029/32851987-76c36e4a-c9eb-11e7-98fc-feb39fddaadb.gif)][1] - -### 如何开始使用安全警报 - -无论你的项目时私有还是公有的,安全警报都会为团队中的正确人员提供重要的漏洞信息。 - -启用你的依赖图 - -公开仓库将自动启用依赖关系图和安全警报。对于私人仓库,你需要在仓库设置中添加安全警报,或者在 “Insights” 选项卡中允许访问仓库的 “依赖关系图” 部分。 - -设置通知选项 - -启用依赖关系图后,管理员将默认收到安全警报。管理员还可以在依赖关系图设置中将团队或个人添加为安全警报的收件人。 - -警报响应 - -当我们通知你潜在的漏洞时,我们将突出显示我们建议更新的任何依赖关系。如果存在已知的安全版本,我们将使用机器学习和公开数据中选择一个,并将其包含在我们的建议中。 - -### 漏洞覆盖率 - -有 [CVE ID][2](公开披露的[国家漏洞数据库][3]中的漏洞)的漏洞将包含在安全警报中。但是,并非所有漏洞都有 CVE ID,甚至许多公开披露的漏洞也没有。随着安全数据的增长,我们将继续更好地识别漏洞。如需更多帮助来管理安全问题,请查看我们的[ GitHub Marketplace 中的安全合作伙伴][4]。 - -这是使用世界上最大的开源数据集的下一步,可以帮助你保持代码安全并做到最好。依赖关系图和安全警报目前支持 JavaScript 和 Ruby,并将在 2018 年提供 Python 支持。 - -[了解更多关于安全警报][5] - --------------------------------------------------------------------------------- - -via: https://github.com/blog/2470-introducing-security-alerts-on-github - -作者:[mijuhan ][a] -译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://github.com/mijuhan -[1]:https://user-images.githubusercontent.com/594029/32851987-76c36e4a-c9eb-11e7-98fc-feb39fddaadb.gif -[2]:https://cve.mitre.org/ -[3]:https://nvd.nist.gov/ -[4]:https://github.com/marketplace/category/security -[5]:https://help.github.com/articles/about-security-alerts-for-vulnerable-dependencies/ diff --git a/translated/tech/20171117 System Logs: Understand Your Linux System.md b/translated/tech/20171117 System Logs: Understand Your Linux System.md deleted file mode 100644 index dceea12a63..0000000000 --- a/translated/tech/20171117 System Logs: Understand Your Linux System.md +++ /dev/null @@ -1,68 +0,0 @@ -### 系统日志: 了解你的Linux系统 - -![chabowski](https://www.suse.com/communities/blog/files/2016/03/chabowski_avatar_1457537819-100x100.jpg) - By: [chabowski][1] - -本文摘自教授Linux小白(或者非资深桌面用户)技巧的系列文章. 该系列文章旨在为由LinuxMagazine基于 [openSUSE Leap][3] 发布的第30期特别版 “[Getting Started with Linux][2]” 提供补充说明. - -本文作者是 Romeo S. Romeo, 他是一名 PDX-based enterprise Linux 专家,转为创新企业提供富有伸缩性的解决方案. - -Linux系统日志非常重要. 后台运行的程序(通常被称为守护进程或者服务进程)处理了你Linux系统中的大部分任务. 当这些守护进程工作时,它们将任务的详细信息记录进日志文件中,作为他们做过什么的历史信息. 这些守护进程的工作内容涵盖从使用原子钟同步时钟到管理网络连接. 所有这些都被记录进日志文件,这样当有错误发生时,你可以通过查阅特定的日志文件来看出发生了什么. - -![](https://www.suse.com/communities/blog/files/2017/11/markus-spiske-153537-300x450.jpg) - -Photo by Markus Spiske on Unsplash - -有很多不同的日志. 历史上, 他们一般以纯文本的格式存储到 `/var/log` 目录中. 现在依然有很多日志这样做, 你可以很方便的使用 `less` 来查看它们. -在新装的 `openSUSE Leap 42.3` 以及大多数现代操作系统上,重要的日志由 `systemd` 初始化系统存储. `systemd`这套系统负责启动守护进程并在系统启动时让计算机做好被使用的准备。 -由 `systemd` 记录的日志以二进制格式存储, 这使地它们消耗的空间更小,更容易被浏览,也更容易被导出成其他各种格式,不过坏处就是你必须使用特定的工具才能查看. -好在, 这个工具已经预安装在你的系统上了: 它的名字叫 `journalctl`,而且默认情况下, 它会将每个守护进程的所有日志都记录到一个地方. - -只需要运行 `journalctl` 命令就能查看你的 `systemd` 日志了. 它会用 `less` 分页器显示各种日志. 为了让你有个直观的感受, 下面是`journalctl` 中摘录的一条日志记录: - -``` -Jul 06 11:53:47 aaathats3as pulseaudio[2216]: [pulseaudio] alsa-util.c: Disabling timer-based scheduling because running inside a VM. -``` - -这条独立的日志记录以此包含了记录的日期和时间, 计算机名, 记录日志的进程名, 记录日志的进程PID, 以及日志内容本身. - -若系统中某个程序运行出问题了, 则可以查看日志文件并搜索(使用 “/” 加上要搜索的关键字)程序名称. 有可能导致该程序出问题的错误会记录到系统日志中. -有时,错误信息会足够详细让你能够修复该问题. 其他时候, 你需要在Web上搜索解决方案. Google就很适合来搜索奇怪的Linux问题. -![](https://www.suse.com/communities/blog/files/2017/09/Sunglasses_Emoji-450x450.png) -不过搜索时请注意你只输入了日志的内容, 行首的那些信息(日期, 主机名, 进程ID) 是无意义的,会干扰搜索结果. - -解决方法一般在搜索结果的前几个连接中就会有了. 当然,你不能只是无脑得运行从互联网上找到的那些命令: 请一定先搞清楚你要做的事情是什么,它的效果会是什么. -据说, 从系统日志中查询日志要比直接搜索描述故障的关键字要有用的多. 因为程序出错有很多原因, 而且同样的故障表现也可能由多种问题引发的. - -比如, 系统无法发声的原因有很多, 可能是播放器没有插好, 也可能是声音系统出故障了, 还可能是缺少合适的驱动程序. -如果你只是泛泛的描述故障表现, 你会找到很多无关的解决方法,而你也会浪费大量的时间. 而指定搜索日志文件中的内容, 你只会查询出他人也有相同日志内容的结果. -你可以对比一下图1和图2. - -![](https://www.suse.com/communities/blog/files/2017/11/picture1-450x450.png) - -图 1 搜索系统的故障表现只会显示泛泛的,不精确的结果. 这种搜索通常没什么用. - -![](https://www.suse.com/communities/blog/files/2017/11/picture2-450x450.png) - -图 2 搜索特定的日志行会显示出精确的,有用的结果. 这种搜索通常很有用. - -也有一些系统不用 `journalctl` 来记录日志. 在桌面系统中最常见的这类日志包括用于 `/var/log/zypper.log` 记录openSUSE包管理器的行为; `/var/log/boot.log` 记录系统启动时的消息,这类消息往往滚动的特别块,根本看不过来; `/var/log/ntp` 用来记录 Network Time Protocol 守护进程同步时间时发生的错误. -另一个存放硬件故障信息的地方是 `Kernel Ring Buffer`(内核环状缓冲区), 你可以输入 `demesg -H` 命令来查看(这条命令也会调用 `less` 分页器来查看). -`Kernel Ring Buffer` 存储在内存中, 因此会在重启电脑后丢失. 不过它包含了Linux内核中的重要事件, 比如新增了硬件, 加载了模块, 以及奇怪的网络错误. - -希望你已经准备好深入了解你的Linux系统了! 祝你玩的开心! - --------------------------------------------------------------------------------- - -via: https://www.suse.com/communities/blog/system-logs-understand-linux-system/ - -作者:[chabowski] -译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[1]:https://www.suse.com/communities/blog/author/chabowski/ -[2]:http://www.linux-magazine.com/Resources/Special-Editions/30-Getting-Started-with-Linux -[3]:https://en.opensuse.org/Portal:42.3 -[4]:http://www.linux-magazine.com/ diff --git a/translated/tech/20171124 How to Install Android File Transfer for Linux.md b/translated/tech/20171124 How to Install Android File Transfer for Linux.md new file mode 100644 index 0000000000..b93429f509 --- /dev/null +++ b/translated/tech/20171124 How to Install Android File Transfer for Linux.md @@ -0,0 +1,82 @@ +Translating by wenwensnow + +# 如何在Linux下安装安卓文件传输助手 + +如果你尝试在Ubuntu下安装你的安卓手机,你也许可以试试Linux下的安卓文件传输助手 + +本质上来说,这个应用是谷歌mac版本的一个复制。它是用Qt编写的,用户界面非常简洁,使得你能轻松在Ubuntu和安卓手机之间传输文件。 + +现在,有可能一部分人想知道有什么是这个应用可以做,而Nautilus(Ubuntu默认的文件资源管理器)不能做的,答案是没有。 + +当我将我的 Nexus 5X(记得选择[MTP][7] 选项)连接在Ubuntu上时,在[GVfs][8](Gnome桌面下的虚拟文件系统)的帮助下,我可以打开,浏览和管理我的手机, 就像它是一个普通的U盘一样。 + + [![Nautilus MTP integration with a Nexus 5X](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg)][9] + +但是一些用户在使用默认的文件管理器时,在MTP的某些功能上会出现问题:比如文件夹没有正确加载,创建新文件夹后此文件夹不存在,或者无法在媒体播放器中使用自己的手机。 + +这就是要为Linux系统用户设计一个安卓文件传输助手应用的原因。将这个应用当做将MTP设备安装在Linux下的另一种选择。如果你使用Linux下的默认应用时一切正常,你也许并不需要尝试使用它 (除非你真的很想尝试新鲜事物)。 + + +![Android File Transfer Linux App](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/android-file-transfer-for-linux-750x662.jpg) + +app特点: + +*   简洁直观的用户界面 + +*   支持文件拖放功能(从Linux系统到手机) + +*   支持批量下载 (从手机到Linux系统) + +*   显示传输进程对话框 + +*   FUSE模块支持 + +*   没有文件大小限制 + +*   可选命令行工具 + +### Ubuntu下安装安卓手机文件助手的步骤 + +以上就是对这个应用的介绍,下面是如何安装它的具体步骤。 + +这有一个[PPA](个人软件包集)源为Ubuntu 14.04 LTS(长期支持版本),16.04LTS 和 Ubuntu17.10 提供可用应用 + +为了将这一PPA加入你的软件资源列表中,执行这条命令: + +``` +sudo add-apt-repository ppa:samoilov-lex/aftl-stable +``` + +接着,为了在Ubuntu下安装Linux版本的安卓文件传输助手,执行: + +``` +sudo apt-get update && sudo apt install android-file-transfer +``` + +这样就行了。 + +你会在你的应用列表中发现这一应用的启动图标。 + +在你启动这一应用之前,要确保没有其他应用(比如Nautilus)已经加载了你的手机.如果其他应用正在使用你的手机,就会显示“无法找到MTP设备”。为了解决这一问题,将你的手机从Nautilus(或者任何正在使用你的手机的应用)上移除,然后再重新启动安卓文件传输助手。 + +-------------------------------------------------------------------------------- + +via: http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux + +作者:[ JOEY SNEDDON ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://plus.google.com/117485690627814051450/?rel=author +[1]:https://plus.google.com/117485690627814051450/?rel=author +[2]:http://www.omgubuntu.co.uk/category/app +[3]:http://www.omgubuntu.co.uk/category/download +[4]:https://github.com/whoozle/android-file-transfer-linux +[5]:http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux +[6]:http://android.com/filetransfer?linkid=14270770 +[7]:https://en.wikipedia.org/wiki/Media_Transfer_Protocol +[8]:https://en.wikipedia.org/wiki/GVfs +[9]:http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg +[10]:https://launchpad.net/~samoilov-lex/+archive/ubuntu/aftl-stable diff --git a/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md deleted file mode 100644 index e51c580da9..0000000000 --- a/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md +++ /dev/null @@ -1,147 +0,0 @@ -Photon也许能成为你最喜爱的容器操作系统 -============================================================ - -![Photon OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon-linux.jpg?itok=jUFHPR_c "Photon OS") - -Phonton OS专注于容器,是一个非常出色的平台。 —— Jack Wallen - -容器在当下的火热,并不是没有原因的。正如[之前][13]讨论的,容器可以使您轻松快捷地将新的服务与应用部署到您的网络上,而且并不耗费太多的系统资源。比起专用硬件和虚拟机,容器都是更加划算的,除此之外,他们更容易更新与重用。 - -更重要的是,容器喜欢Linux(反之亦然)。不需要太多时间和麻烦,你就可以启动一台Linux服务器,运行[Docker][14],再是部署容器。但是,哪种Linux发行版最适合部署容器呢?我们的选择很多。你可以使用标准的Ubuntu服务器平台(更容易安装Docker并部署容器)或者是更轻量级的发行版 —— 专门用于部署容器。 - -[Photon][15]就是这样的一个发行版。这个特殊的版本是由[VMware][16]于2005年创建的,它包含了Docker的守护进程,并与容器框架(如Mesos和Kubernetes)一起使用。Photon经过优化可与[VMware vSphere][17]协同工作,而且可用于裸机,[Microsoft Azure][18], [Google Compute Engine][19], [Amazon Elastic Compute Cloud][20], 或者 [VirtualBox][21]等。 - -Photon通过只安装Docker守护进程所必需的东西来保持它的轻量。而这样做的结果是,这个发行版的大小大约只有300MB。但这足以让Linux的运行一切正常。除此之外,Photon的主要特点还有: - -* 内核调整为性能模式。 - -* 内核根据[内核自防护项目][6](KSPP)进行了加固。 - -* 所有安装的软件包都根据加固的安全标识来构建。 - -* 操作系统在信任验证后启动。 - -* Photon管理进程管理防火墙,网络,软件包,和远程登录在Photon机子上的用户。 - -* 支持持久卷。 - -* [Project Lightwave][7] 整合。 - -* 及时的安全补丁与更新。 - -Photon可以通过[ISO][22],[OVA][23],[Amazon Machine Image][24],[Google Compute Engine image][25]和[Azure VHD][26]安装使用。现在我将向您展示如何使用ISO镜像在VirtualBox上安装Photon。整个安装过程大概需要五分钟,在最后您将有一台随时可以部署容器的虚拟机。 - -### 创建虚拟机 - -在部署第一台容器之前,您必须先创建一台虚拟机并安装Photon。为此,打开VirtualBox并点击“新建”按钮。跟着创建虚拟机向导进行配置(根据您的容器将需要的用途,为Photon提供必要的资源)。在创建好虚拟机后,您所需要做的第一件事就是更改配置。选择新建的虚拟机(在VirtualBox主窗口的左侧面板中),然后单击“设置”。在弹出的窗口中,点击“网络”(在左侧的导航中)。 - -在“网络”窗口(图1)中,你需要在“连接”的下拉窗口中选择桥接。这可以确保您的Photon服务与您的网络相连。完成更改后,单击确定。 - -### [photon_0.jpg][8] - -![change settings](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_0.jpg?itok=Q0yhOhsZ "change setatings") -图 1: 更改Photon在VirtualBox中的网络设置。[经许可使用][1] - -从左侧的导航选择您的Photon虚拟机,点击启动。系统会提示您去加载IOS镜像。当您完成之后,Photon安装程序将会启动并提示您按回车后开始安装。安装过程基于ncurses(没有GUI),但它非常简单。 - -接下来(图2),系统会询问您是要最小化安装,完整安装还是安装OSTree服务器。我选择了完整安装。选择您所需要的任意选项,然后按回车继续。 - -### [photon_1.jpg][9] - -![installation type](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_2.jpg?itok=QL1Rs-PH "Photon") -图 2: 选择您的安装类型.[经许可使用][2] - -在下一个窗口,选择您要安装Photon的磁盘。由于我们将其安装在虚拟机,因此只有一块磁盘会被列出(图3)。选择“自动”按下回车。然后安装程序会让您输入(并验证)管理员密码。在这之后镜像开始安装在您的磁盘上并在不到5分钟的时间内结束。 - -### [photon_2.jpg][] - -![Photon](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_1.jpg?itok=OdnMVpaA "installation type") -图 3: 选择安装Photon的硬盘.[经许可使用][3] - -安装完成后,重启虚拟机并使用安装时创建的用户root和它的密码登录。一切就绪,你准备好开始工作了。 - -在开始使用Docker之前,您需要更新一下Photon。Photon使用 _yum_ 软件包管理器,因此在以root用户登录后输入命令 _yum update_。如果有任何可用更新,则会询问您是否确认(图4)。 - -### [photon_3.jpg][11] - -![Updating](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_3.jpg?itok=vjqrspE2 "Updating") -图 4: 更新 Photon.[经许可使用][4] - -用法 - -正如我所说的,Photon提供了部署容器甚至创建Kubernetes集群所需要的所有包。但是,在使用之前还要做一些事情。首先要启动Docker守护进程。为此,执行以下命令: - -``` -systemctl start docker - -systemctl enable docker -``` - -现在我们需要创建一个标准用户,因此我们没有以root去运行docker命令。为此,执行以下命令: - -``` -useradd -m USERNAME - -passwd USERNAME -``` - -其中USERNAME是我们新增的用户的名称。 - -接下来,我们需要将这个新用户添加到 _docker_ 组,执行命令: - -``` -usermod -a -G docker USERNAME -``` - -其中USERNAME是刚刚创建的用户的名称。 - -注销root用户并切换为新增的用户。现在,您已经可以不必使用 _sudo_ 命令或者是切换到root用户来使用 _docker_命令了。从Docker Hub中取出一个镜像开始部署容器吧。 - -### 一个优秀的容器平台 - -在专注于容器方面,Photon毫无疑问是一个出色的平台。请注意,Photon是一个开源项目,因此没有任何付费支持。如果您对Photon有任何的问题,请移步Photon项目的Github下的[Issues][27],那里可以供您阅读相关问题,或者提交您的问题。如果您对Photon感兴趣,您也可以在项目的官方[Github][28]中找到源码。 - -尝试一下Photon吧,看看它是否能够使得Docker容器和Kubernetes集群的部署更加容易。 - -欲了解Linux的更多信息,可以通过学习Linux基金会和edX的免费课程,[“Linux 入门”][29]。 - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2017/11/photon-could-be-your-new-favorite-container-os - -作者:[JACK WALLEN][a] -译者:[KeyLD](https://github.com/KeyLd) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/jlwallen -[1]:https://www.linux.com/licenses/category/used-permission -[2]:https://www.linux.com/licenses/category/used-permission -[3]:https://www.linux.com/licenses/category/used-permission -[4]:https://www.linux.com/licenses/category/used-permission -[5]:https://www.linux.com/licenses/category/creative-commons-zero -[6]:https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project -[7]:http://vmware.github.io/lightwave/ -[8]:https://www.linux.com/files/images/photon0jpg -[9]:https://www.linux.com/files/images/photon1jpg -[10]:https://www.linux.com/files/images/photon2jpg -[11]:https://www.linux.com/files/images/photon3jpg -[12]:https://www.linux.com/files/images/photon-linuxjpg -[13]:https://www.linux.com/learn/intro-to-linux/2017/11/how-install-and-use-docker-linux -[14]:https://www.docker.com/ -[15]:https://vmware.github.io/photon/ -[16]:https://www.vmware.com/ -[17]:https://www.vmware.com/products/vsphere.html -[18]:https://azure.microsoft.com/ -[19]:https://cloud.google.com/compute/ -[20]:https://aws.amazon.com/ec2/ -[21]:https://www.virtualbox.org/ -[22]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[23]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[24]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[25]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[26]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[27]:https://github.com/vmware/photon/issues -[28]:https://github.com/vmware/photon -[29]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/translated/tech/20171130 New Feature Find every domain someone owns automatically.md b/translated/tech/20171130 New Feature Find every domain someone owns automatically.md deleted file mode 100644 index 4b72eaae5e..0000000000 --- a/translated/tech/20171130 New Feature Find every domain someone owns automatically.md +++ /dev/null @@ -1,49 +0,0 @@ -新功能:自动找出每个域名的拥有者 -============================================================ - - -今天,我们很高兴地宣布我们最近几周做的新功能。它是 Whois 聚合工具,现在可以在 [DNSTrails][1] 上获得。 - -在过去,查找一个域名的所有者会花费很多时间,因为大部分时间你都需要把域名指向一个 IP 地址,以便找到同一个人拥有的其他域名。 - -使用老的方法,你会很轻易地在一个工具和另外一个工具的研究和交叉比较结果中花费数个小时,直到得到你想要的域名。 - -感谢这个新工具和我们的智能[WHOIS 数据库][2],现在你可以搜索任何域名,并获得组织或个人注册的域名的完整列表,并在几秒钟内获得准确的结果。 - -### 我如何使用Whois聚合功能? - -第一步:打开 [DNSTrails.com][3] - -第二步:搜索任何域名,比如:godaddy.com - -第三步:在得到域名的结果后,如下所见,定位下面的 Whois 信息: - -![Domain name search results](https://securitytrails.com/images/a/a/1/3/f/aa13fa3616b8dc313f925bdbf1da43a54856d463-image1.png) - -第四步:你会看到那里有有关域名的电话和电子邮箱地址。 - -第五步:点击右边的链接,你会轻松地找到用相同电话和邮箱注册的域名。 - -![All domain names by the same owner](https://securitytrails.com/images/1/3/4/0/3/134037822d23db4907d421046b11f3cbb872f94f-image2.png) - -如果你正在调查互联网上任何个人的域名所有权,这意味着即使域名甚至没有指向注册服务商的 IP,如果他们使用相同的电话和邮件地址,我们仍然可以发现其他域名。 - -想知道一个人拥有的其他域名么?亲自试试 [DNStrails][5] 的[ WHOIS 聚合功能][4]或者[使用我们的 API 访问][6]。 - --------------------------------------------------------------------------------- - -via: https://securitytrails.com/blog/find-every-domain-someone-owns - -作者:[SECURITYTRAILS TEAM ][a] -译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://securitytrails.com/blog/find-every-domain-someone-owns -[1]:https://dnstrails.com/ -[2]:https://securitytrails.com/forensics -[3]:https://dnstrails.com/ -[4]:http://dnstrails.com/#/domain/domain/ueland.com -[5]:https://dnstrails.com/ -[6]:https://securitytrails.com/contact diff --git a/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md b/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md deleted file mode 100644 index 9f905bd496..0000000000 --- a/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md +++ /dev/null @@ -1,400 +0,0 @@ -Translate Shell: 一款在 Linux 命令行中使用 Google Translate的工具 -============================================================ - -我对 CLI 应用非常感兴趣,因此热衷于使用并分享 CLI 应用。 我之所以更喜欢 CLI 很大原因是因为我在大多数的时候都使用的是字符界面(black screen),已经习惯了使用 CLI 应用而不是 GUI 应用. - -我写过很多关于 CLI 应用的文章。 最近我发现了一些 google 的 CLI 工具,像 “Google Translator”, “Google Calendar”, 和 “Google Contacts”。 这里,我想在给大家分享一下。 - -今天我们要介绍的是 “Google Translator” 工具。 由于母语是泰米尔语,我在一天内用了很多次才理解了它的意义。 - -`Google translate` 为其他语系的人们所广泛使用。 - -### 什么是 Translate Shell - -[Translate Shell][2] (之前叫做 Google Translate CLI) 是一款借助 `Google Translate`(默认), `Bing Translator`, `Yandex.Translate` 以及 `Apertium` 来翻译的命令行翻译器。 -它让你可以在终端访问这些翻译引擎. `Translate Shell` 在大多数Linux发行版中都能使用。 - -### 如何安装 Translate Shell - -有三种方法安装 `Translate Shell`。 - -* 下载自包含的可执行文件 - -* 手工安装 - -* 通过包挂力气安装 - -#### 方法-1 : 下载自包含的可执行文件 - -下载自包含的可执行文件放到 `/usr/bin` 目录中。 - -```shell -$ wget git.io/trans -$ chmod +x ./trans -$ sudo mv trans /usr/bin/ -``` - -#### 方法-2 : 手工安装 - -克隆 `Translate Shell` github 仓库然后手工编译。 - -```shell -$ git clone https://github.com/soimort/translate-shell && cd translate-shell -$ make -$ sudo make install -``` - -#### 方法-3 : Via Package Manager - -有些发行版的官方仓库中包含了 `Translate Shell`,可以通过包管理器来安装。 - -对于 Debian/Ubuntu, 使用 [APT-GET Command][3] 或者 [APT Command][4]来安装。 - -```shell -$ sudo apt-get install translate-shell -``` - -对于 Fedora, 使用 [DNF Command][5] 来安装。 - -```shell -$ sudo dnf install translate-shell -``` - -对于基于 Arch Linux 的系统, 使用 [Yaourt Command][6] 或 [Packer Command][7] 来从 AUR 仓库中安装。 - -```shell -$ yaourt -S translate-shell -or -$ packer -S translate-shell -``` - -### 如何使用 Translate Shell - -安装好后,打开终端闭关输入下面命令。 `Google Translate` 会自动探测源文本是哪种语言,并且在默认情况下将之翻译成你的 `locale` 所对应的语言。 - -``` -$ trans [Words] -``` - -下面我将泰米尔语中的单词 “நன்றி” (Nanri) 翻译成英语。 这个单词的意思是感谢别人。 - -``` -$ trans நன்றி -நன்றி -(Naṉṟi) - -Thanks - -Definitions of நன்றி -[ தமிழ் -> English ] - -noun - gratitude - நன்றி - thanks - நன்றி - -நன்றி - Thanks -``` - -使用下面命令也能将英语翻译成泰米尔语。 - -``` -$ trans :ta thanks -thanks -/THaNGks/ - -நன்றி -(Naṉṟi) - -Definitions of thanks -[ English -> தமிழ் ] - -noun - நன்றி - gratitude, thanks - -thanks - நன்றி -``` - -要将一个单词翻译到多个语种可以使用下面命令(本例中, 我将单词翻译成泰米尔语以及印地语)。 - -``` -$ trans :ta+hi thanks -thanks -/THaNGks/ - -நன்றி -(Naṉṟi) - -Definitions of thanks -[ English -> தமிழ் ] - -noun - நன்றி - gratitude, thanks - -thanks - நன்றி - -thanks -/THaNGks/ - -धन्यवाद -(dhanyavaad) - -Definitions of thanks -[ English -> हिन्दी ] - -noun - धन्यवाद - thanks, thank, gratitude, thankfulness, felicitation - -thanks - धन्यवाद, शुक्रिया -``` - -使用下面命令可以将多个单词当成一个参数(句子)来进行翻译。(只需要把句子应用起来作为一个参数就行了)。 - -``` -$ trans :ta "what is going on your life?" -what is going on your life? - -உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? -(Uṅkaḷ vāḻkkaiyil eṉṉa naṭakkiṟatu?) - -Translations of what is going on your life? -[ English -> தமிழ் ] - -what is going on your life? - உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? -``` - -下面命令独立地翻译各个单词。 - -``` -$ trans :ta curios happy -curios - -ஆர்வம் -(Ārvam) - -Translations of curios -[ Română -> தமிழ் ] - -curios - ஆர்வம், அறிவாளிகள், ஆர்வமுள்ள, அறிய, ஆர்வமாக -happy -/ˈhapē/ - -சந்தோஷமாக -(Cantōṣamāka) - -Definitions of happy -[ English -> தமிழ் ] - - மகிழ்ச்சியான - happy, convivial, debonair, gay - திருப்தி உடைய - happy - -adjective - இன்பமான - happy - -happy - சந்தோஷமாக, மகிழ்ச்சி, இனிய, சந்தோஷமா -``` - -简洁模式: 默认情况下,`Translate Shell` 尽可能多的显示翻译信息. 如果你希望只显示简要信息,只需要加上`-b`选项。 - -``` -$ trans -b :ta thanks -நன்றி -``` - -字典模式: 加上 `-d` 可以把 `Translate Shell` 当成字典来用. - -``` -$ trans -d :en thanks -thanks -/THaNGks/ - -Synonyms - noun - - gratitude, appreciation, acknowledgment, recognition, credit - - exclamation - - thank you, many thanks, thanks very much, thanks a lot, thank you kindly, much obliged, much appreciated, bless you, thanks a million - -Examples - - In short, thanks for everything that makes this city great this Thanksgiving. - - - many thanks - - - There were no thanks in the letter from him, just complaints and accusations. - - - It is a joyful celebration in which Bolivians give thanks for their freedom as a nation. - - - festivals were held to give thanks for the harvest - - - The collection, as usual, received a great response and thanks is extended to all who subscribed. - - - It would be easy to dwell on the animals that Tasmania has lost, but I prefer to give thanks for what remains. - - - thanks for being so helpful - - - It came back on about half an hour earlier than predicted, so I suppose I can give thanks for that. - - - Many thanks for the reply but as much as I tried to follow your advice, it's been a bad week. - - - To them and to those who have supported the office I extend my grateful thanks . - - - We can give thanks and words of appreciation to others for their kind deeds done to us. - - - Adam, thanks for taking time out of your very busy schedule to be with us tonight. - - - a letter of thanks - - - Thank you very much for wanting to go on reading, and thanks for your understanding. - - - Gerry has received a letter of thanks from the charity for his part in helping to raise this much needed cash. - - - So thanks for your reply to that guy who seemed to have a chip on his shoulder about it. - - - Suzanne, thanks for being so supportive with your comments on my blog. - - - She has never once acknowledged my thanks , or existence for that matter. - - - My grateful thanks go to the funders who made it possible for me to travel. - - - festivals were held to give thanks for the harvest - - - All you secretaries who made it this far into the article… thanks for your patience. - - - So, even though I don't think the photos are that good, thanks for the compliments! - - - And thanks for warning us that your secret service requires a motorcade of more than 35 cars. - - - Many thanks for your advice, which as you can see, I have passed on to our readers. - - - Tom Ryan was given a bottle of wine as a thanks for his active involvement in the twinning project. - - - Mr Hill insists he has received no recent complaints and has even been sent a letter of thanks from the forum. - - - Hundreds turned out to pay tribute to a beloved former headteacher at a memorial service to give thanks for her life. - - - Again, thanks for a well written and much deserved tribute to our good friend George. - - - I appreciate your doing so, and thanks also for the compliments about the photos! - -See also - Thanks!, thank, many thanks, thanks to, thanks to you, special thanks, give thanks, thousand thanks, Many thanks!, render thanks, heartfelt thanks, thanks to this -``` - -使用下面格式可以使用 `Translate Shell` 来翻译文件。 - -```shell -$ trans :ta file:///home/magi/gtrans.txt -உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? -``` - -下面命令可以让 `Translate Shell` 进入交互模式. 在进入交互模式之前你需要明确指定源语言和目标语言。本例中,我将英文单词翻译成泰米尔语。 - -``` -$ trans -shell en:ta thanks -Translate Shell -(:q to quit) -thanks -/THaNGks/ - -நன்றி -(Naṉṟi) - -Definitions of thanks -[ English -> தமிழ் ] - -noun - நன்றி - gratitude, thanks - -thanks - நன்றி -``` - -想知道语言代码,可以执行下面语言。 - -```shell -$ trans -R -``` -或者 -```shell -$ trans -T -┌───────────────────────┬───────────────────────┬───────────────────────┐ -│ Afrikaans - af │ Hindi - hi │ Punjabi - pa │ -│ Albanian - sq │ Hmong - hmn │ Querétaro Otomi- otq │ -│ Amharic - am │ Hmong Daw - mww │ Romanian - ro │ -│ Arabic - ar │ Hungarian - hu │ Russian - ru │ -│ Armenian - hy │ Icelandic - is │ Samoan - sm │ -│ Azerbaijani - az │ Igbo - ig │ Scots Gaelic - gd │ -│ Basque - eu │ Indonesian - id │ Serbian (Cyr...-sr-Cyrl -│ Belarusian - be │ Irish - ga │ Serbian (Latin)-sr-Latn -│ Bengali - bn │ Italian - it │ Sesotho - st │ -│ Bosnian - bs │ Japanese - ja │ Shona - sn │ -│ Bulgarian - bg │ Javanese - jv │ Sindhi - sd │ -│ Cantonese - yue │ Kannada - kn │ Sinhala - si │ -│ Catalan - ca │ Kazakh - kk │ Slovak - sk │ -│ Cebuano - ceb │ Khmer - km │ Slovenian - sl │ -│ Chichewa - ny │ Klingon - tlh │ Somali - so │ -│ Chinese Simp...- zh-CN│ Klingon (pIqaD)tlh-Qaak Spanish - es │ -│ Chinese Trad...- zh-TW│ Korean - ko │ Sundanese - su │ -│ Corsican - co │ Kurdish - ku │ Swahili - sw │ -│ Croatian - hr │ Kyrgyz - ky │ Swedish - sv │ -│ Czech - cs │ Lao - lo │ Tahitian - ty │ -│ Danish - da │ Latin - la │ Tajik - tg │ -│ Dutch - nl │ Latvian - lv │ Tamil - ta │ -│ English - en │ Lithuanian - lt │ Tatar - tt │ -│ Esperanto - eo │ Luxembourgish - lb │ Telugu - te │ -│ Estonian - et │ Macedonian - mk │ Thai - th │ -│ Fijian - fj │ Malagasy - mg │ Tongan - to │ -│ Filipino - tl │ Malay - ms │ Turkish - tr │ -│ Finnish - fi │ Malayalam - ml │ Udmurt - udm │ -│ French - fr │ Maltese - mt │ Ukrainian - uk │ -│ Frisian - fy │ Maori - mi │ Urdu - ur │ -│ Galician - gl │ Marathi - mr │ Uzbek - uz │ -│ Georgian - ka │ Mongolian - mn │ Vietnamese - vi │ -│ German - de │ Myanmar - my │ Welsh - cy │ -│ Greek - el │ Nepali - ne │ Xhosa - xh │ -│ Gujarati - gu │ Norwegian - no │ Yiddish - yi │ -│ Haitian Creole - ht │ Pashto - ps │ Yoruba - yo │ -│ Hausa - ha │ Persian - fa │ Yucatec Maya - yua │ -│ Hawaiian - haw │ Polish - pl │ Zulu - zu │ -│ Hebrew - he │ Portuguese - pt │ │ -└───────────────────────┴───────────────────────┴───────────────────────┘ -``` - -想了解更多选项的内容,可以查看 `man` 页. - -```shell -$ man trans -``` - --------------------------------------------------------------------------------- - -via: https://www.2daygeek.com/translate-shell-a-tool-to-use-google-translate-from-command-line-in-linux/ - -作者:[Magesh Maruthamuthu][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.2daygeek.com/author/magesh/ -[2]:https://github.com/soimort/translate-shell -[3]:https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ -[4]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ -[5]:https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ -[6]:https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/ -[7]:https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/ diff --git a/translated/tech/20171201 Linux Journal Ceases Publication.md b/translated/tech/20171201 Linux Journal Ceases Publication.md deleted file mode 100644 index 2eb5c82f51..0000000000 --- a/translated/tech/20171201 Linux Journal Ceases Publication.md +++ /dev/null @@ -1,34 +0,0 @@ -Linux Journal 停止发行 -============================================================ - -EOF - -伙计们,看起来我们要到终点了。如果按照计划而且没有什么其他的话,十一月份的 Linux Journal 将是我们的最后一期。 - -简单的事实是,我们已经用完了钱和期权。我们从来没有一个富有的母公司或者自己深厚的资金,从开始到结束,这使得我们变成一个反常的出版商。虽然我们在很长的一段时间内运营着,但当天平不可恢复地最终向相反方向倾斜时,我们在十一月份失去了最后一点支持。 - -虽然我们像看到出版业的过去那样看到出版业的未来 - 广告商赞助出版物的时代,因为他们重视品牌和读者 - 我们如今的广告宁愿追逐眼球,最好是在读者的浏览器中植入跟踪标记,并随时随地展示那些广告。但是,未来不是这样,过去的已经过去了。 - -我们猜想,有一个希望,那就是救世主可能会会来。但除了我们的品牌、我们的档案,我们的域名、我们的用户和读者之外,还必须是愿意承担我们一部分债务的人。如果你认识任何人能够提供认真的报价,请告诉我们。不然,请观看 LinuxJournal.com,并希望至少我们的遗留归档(可以追溯到 Linux Journal 诞生的 1994 年 4 月,当 Linux 命中 1.0 发布时)将不会消失。这里有很多很棒的东西,还有很多我们会痛恨世界失去的历史。 - -我们最大的遗憾是,我们甚至没有足够的钱回馈最看重我们的人:我们的用户。为此,我们不能更深刻或真诚地道歉。我们对订阅者而言有什么: - -Linux Pro Magazine 为我们的用户提供了六本免费的杂志,我们在 Linux Journal 上一直赞叹这点。在我们需要的时候,他们是我们的第一批人,我们感谢他们的恩惠。我们今天刚刚完成了我们的 2017 年归档,其中包括我们曾经发表过的每一个问题,包括第一个和最后一个。通常我们以 25 美元的价格出售,但显然用户将免费获得。订阅者请注意有关两者的详细信息的电子邮件。 - -我们也希望在知道我们非常非常努力地让 Linux Journal 进行下去后能有一些安慰 ,而且我们已经用最精益、小的可能运营了很长一段时间。我们是一个大多数是自愿者的组织,有些员工已经几个月没有收到工资。我们还欠钱给自由职业者。这时一个限制发行商能够维持多长时间的限制,现在这个限制已经到头了。 - -伙计们,这是一个伟大的运营。乡亲。对每一个为我们的诞生、我们的成功和我们多年的坚持作出贡献的人致敬。我们列了一份名单,但是列表太长了,并且漏掉有价值的人的风险很高。你知道你是谁。我们再次感谢。 - --------------------------------------------------------------------------------- - -via: https://www.linuxjournal.com/content/linux-journal-ceases-publication - -作者:[ Carlie Fairchild][a] -译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linuxjournal.com/users/carlie-fairchild -[1]:https://www.linuxjournal.com/taxonomy/term/29 -[2]:https://www.linuxjournal.com/users/carlie-fairchild diff --git a/translated/tech/Linux Networking Hardware for Beginners: Think Software b/translated/tech/Linux Networking Hardware for Beginners: Think Software deleted file mode 100644 index a236a80e97..0000000000 --- a/translated/tech/Linux Networking Hardware for Beginners: Think Software +++ /dev/null @@ -1,89 +0,0 @@ -Translating by FelixYFZ - -面向初学者的Linux网络硬件: 软件工程思想 -============================================================ - -![island network](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/soderskar-island.jpg?itok=wiMaF66b "island network") - 没有路由和桥接,我们将会成为孤独的小岛,你将会在这个网络教程中学到更多知识。 -Commons Zero][3]Pixabay - - 上周,我们学习了本地网络硬件知识,本周,我们将学习网络互联技术和在移动网络中的一些很酷的黑客技术。 -### Routers:路由器 - - -网络路由器就是计算机网络中的一切,因为路由器连接着网络,没有路由器,我们就会成为孤岛, - -图一展示了一个简单的有线本地网络和一个无线接入点,所有设备都接入到Internet上,本地局域网的计算机连接到一个连接着防火墙或者路由器的以太网交换机上,防火墙或者路由器连接到网络服务供应商提供的电缆箱,调制调节器,卫星上行系统...好像一切都在计算中,就像是一个带着不停闪烁的的小灯的盒子,当你的网络数据包离开你的局域网,进入广阔的互联网,它们穿过一个又一个路由器直到到达自己的目的地。 - - -### [fig-1.png][4] - -![simple LAN](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_7.png?itok=lsazmf3- "simple LAN") - -图一:一个简单的有线局域网和一个无线接入点。 - -一台路由器能连接一切,一个小巧特殊的小盒子只专注于路由,一个大点的盒子将会提供路由,防火墙,域名服务,以及VPN网关功能,一台重新设计的台式电脑或者笔记本,一个树莓派计算机或者一个小模块,体积臃肿矮小的像PC这样的单板计算机,除了苛刻的用途以外,普通的商品硬件都能良好的工作运行。高端的路由器使用特殊设计的硬件每秒能够传输最大量的数据包。 它们有多路数据总线,多个中央处理器和极快的存储。 -可以通过查阅Juniper和思科的路由器来感受一下高端路由器书什么样子的,而且能看看里面是什么样的构造。 -一个接入你的局域网的无线接入点要么作为一个以太网网桥要么作为一个路由器。一个桥接器扩展了这个网络,所以在这个桥接器上的任意一端口上的主机都连接在同一个网络中。 -一台路由器连接的是两个不同的网络。 -### Network Topology:网络拓扑 - - -有多种设置你的局域网的方式,你可以把所有主机接入到一个单独的平面网络,如果你的交换机支持的话,你也可以把它们分配到不同的子网中。 -平面网络是最简单的网络,只需把每一台设备接入到同一个交换机上即可,如果一台交换上的端口不够使用,你可以将更多的交换机连接在一起。 -有些交换机有特殊的上行端口,有些是没有这种特殊限制的上行端口,你可以连接其中的任意端口,你可能需要使用交叉类型的以太网线,所以你要查阅你的交换机的说明文档来设置。平面网络是最容易管理的,你不需要路由器也不需要计算子网,但它也有一些缺点。他们的伸缩性不好,所以当网络规模变得越来越大的时候就会被广播网络所阻塞。 -将你的局域网进行分段将会提升安全保障, 把局域网分成可管理的不同网段将有助于管理更大的网络。 - 图2展示了一个分成两个子网的局域网络:内部的有线和无线主机,和非军事区域(从来不知道所所有的工作上的男性术语都是在计算机上键入的?)因为他被阻挡了所有的内部网络的访问。 - - -### [fig-2.png][5] - -![LAN](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-2_4.png?itok=LpXq7bLf "LAN") - -图2:一个分成两个子网的简单局域网。 -即使像图2那样的小型网络也可以有不同的配置方法。你可以将防火墙和路由器放置在一台单独的设备上。 -你可以为你的非军事区域设置一个专用的网络连接,把它完全从你的内部网络隔离,这将引导我们进入下一个主题:一切基于软件。 - - -### Think Software软件思维 - - -你可能已经注意到在这个简短的系列中我们所讨论的硬件,只有网络接口,交换机,和线缆是特殊用途的硬件。 -其它的都是通用的商用硬件,而且都是软件来定义它的用途。 -网关,虚拟专用网关,以太网桥,网页,邮箱以及文件等等。 -服务器,负载均衡,代理,大量的服务,各种各样的认证,中继,故障转移...你可以在运行着Linux系统的标准硬件上运行你的整个网络。 -你甚至可以使用Linux交换应用和VDE2协议来模拟以太网交换机,像DD-WRT,openWRT 和Rashpberry Pi distros,这些小型的硬件都是有专业的分类的,要记住BSDS和它们的特殊衍生用途如防火墙,路由器,和网络附件存储。 -你知道有些人坚持认为硬件防火墙和软件防火墙有区别?其实是没有区别的,就像说有一台硬件计算机和一台软件计算机。 -### Port Trunking and Ethernet Bonding -端口聚合和以太网绑定 -聚合和绑定,也称链路聚合,是把两条以太网通道绑定在一起成为一条通道。一些交换机支持端口聚合,就是把两个交换机端口绑定在一起成为一个是他们原来带宽之和的一条新的连接。对于一台承载很多业务的服务器来说这是一个增加通道带宽的有效的方式。 -你也可以在以太网口进行同样的配置,而且绑定汇聚的驱动是内置在Linux内核中的,所以不需要任何其他的专门的硬件。 - - -### Bending Mobile Broadband to your Will随心所欲选择你的移动带宽 - -我期望移动带宽能够迅速增长来替代DSL和有线网络。我居住在一个有250,000人口的靠近一个城市的地方,但是在城市以外,要想接入互联网就要靠运气了,即使那里有很大的用户上网需求。我居住的小角落离城镇有20分钟的距离,但对于网络服务供应商来说他们几乎不会考虑到为这个地方提供网络。 我唯一的选择就是移动带宽; 这里没有拨号网络,卫星网络(即使它很糟糕)或者是DSL,电缆,光纤,但却没有阻止网络供应商把那些在我这个区域从没看到过的无限制通信个其他高速网络服务的传单塞进我的邮箱。 -我试用了AT&T,Version,和T-Mobile。Version的信号覆盖范围最广,但是Version和AT&T是最昂贵的。 -我居住的地方在T-Mobile信号覆盖的边缘,但迄今为止他们给了最大的优惠,为了能够能够有效的使用,我必须购买一个WeBoostDe信号放大器和 -一台中兴的移动热点设备。当然你也可以使用一部手机作为热点,但是专用的热点设备有着最强的信号。如果你正在考虑购买一台信号放大器,最好的选择就是WeBoost因为他们的服务支持最棒,而且他们会尽最大努力去帮助你。在一个小小的APP的协助下去设置将会精准的增强 你的网络信号,他们有一个功能较少的免费的版本,但你将一点都不会后悔去花两美元使用专业版。 -那个小巧的中兴热点设备能够支持15台主机而且还有拥有基本的防火墙功能。 但你如果你使用像 Linksys WRT54GL这样的设备,使用Tomato,openWRT,或者DD-WRT来替代普通的固件,这样你就能完全控制你的防护墙规则,路由配置,以及任何其他你想要设置的服务。 - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2017/10/linux-networking-hardware-beginners-think-software - -作者:[CARLA SCHRODER][a] -译者:[FelixYFZ](https://github.com/FelixYFZ) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/cschroder -[1]:https://www.linux.com/licenses/category/used-permission -[2]:https://www.linux.com/licenses/category/used-permission -[3]:https://www.linux.com/licenses/category/creative-commons-zero -[4]:https://www.linux.com/files/images/fig-1png-7 -[5]:https://www.linux.com/files/images/fig-2png-4 -[6]:https://www.linux.com/files/images/soderskar-islandjpg -[7]:https://www.linux.com/learn/intro-to-linux/2017/10/linux-networking-hardware-beginners-lan-hardware -[8]:http://www.bluelinepc.com/signalcheck/ From 5d8ab1f319782bf857b58e73cbdc5fa942176a68 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 17:23:04 +0800 Subject: [PATCH 197/344] Revert "Revert "Merge branch 'master' of https://github.com/LCTT/TranslateProject"" This reverts commit 11e1c8c450f35378d5e24449e15628748ad98053. --- ...20161216 Kprobes Event Tracing on ARMv8.md | 16 +- ... guide to links in the Linux filesystem.md | 300 ++++++++ ...ng network connections on Linux systems.md | 0 ...layer introduction part 1 the bio layer.md | 13 +- .../20141028 When Does Your OS Run.md | 0 ... Firewalld in Multi-Zone Configurations.md | 0 .../20170227 Ubuntu Core in LXD containers.md | 0 ... THE SOFTWARE CONTAINERIZATION MOVEMENT.md | 0 ...ner OS for Linux and Windows Containers.md | 0 ... Life-Changing Magic of Tidying Up Code.md | 0 ...ldcard Certificates Coming January 2018.md | 0 ...andy Tool for Every Level of Linux User.md | 0 ...GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md | 0 ...0928 3 Python web scrapers and crawlers.md | 0 .../20171002 Scaling the GitLab database.md | 0 ...3 PostgreSQL Hash Indexes Are Now Cool.md | 0 ...inux desktop hasnt jumped in popularity.md | 0 ...ant 100 command line productivity boost.md | 0 ...20171008 8 best languages to blog about.md | 0 ...ext Generation of Cybersecurity Experts.md | 0 ...itter Data in Apache Kafka through KSQL.md | 0 ...p a Postgres database on a Raspberry Pi.md | 0 .../{ => 201711}/20171011 Why Linux Works.md | 0 ...easons open source is good for business.md | 0 ...71013 Best of PostgreSQL 10 for the DBA.md | 0 ... cloud-native computing with Kubernetes.md | 0 ...5 Monitoring Slow SQL Queries via Slack.md | 0 ... Use Docker with R A DevOps Perspective.md | 0 .../20171016 Introducing CRI-O 1.0.md | 0 ...20171017 A tour of Postgres Index Types.md | 0 .../20171017 Image Processing on Linux.md | 0 ...iners and microservices change security.md | 0 ...n Python by building a simple dice game.md | 0 ...ecure Your Network in the Wake of KRACK.md | 0 ...Simple Excellent Linux Network Monitors.md | 0 ...cker containers in Kubernetes with Java.md | 0 ...ols to Help You Remember Linux Commands.md | 0 ...ndroid on Top of a Linux Graphics Stack.md | 0 ...0171024 Top 5 Linux pain points in 2017.md | 0 ...et s analyze GitHub’s data and find out.md | 0 ...u Drop Unity Mark Shuttleworth Explains.md | 0 ...Backup, Rclone and Wasabi cloud storage.md | 0 ...26 But I dont know what a container is .md | 0 .../20171026 Why is Kubernetes so popular.md | 0 .../20171101 How to use cron in Linux.md | 0 ... to a DCO for source code contributions.md | 0 ...nage EXT2 EXT3 and EXT4 Health in Linux.md | 0 .../20171106 Finding Files with mlocate.md | 0 ...Publishes Enterprise Open Source Guides.md | 0 ...mmunity clue. Here s how to do it right.md | 0 ...dopts home-brewed KVM as new hypervisor.md | 0 ... created my first RPM package in Fedora.md | 0 ...est applications with Ansible Container.md | 0 ...71110 File better bugs with coredumpctl.md | 0 ... ​Linux totally dominates supercomputers.md | 0 ...1116 5 Coolest Linux Terminal Emulators.md | 0 ...7 How to Easily Remember Linux Commands.md | 0 ...tting started with OpenFaaS on minikube.md | 0 ...our Terminal Session To Anyone In Seconds.md | 0 ...20 Containers and Kubernetes Whats next.md | 81 ++ ...Install Android File Transfer for Linux.md | 75 ++ ...and Certification Are Key for SysAdmins.md | 72 ++ ...Search DuckDuckGo from the Command Line.md | 97 +++ ...The One in Which I Call Out Hacker News.md | 86 --- ...nject features and investigate programs.md | 211 ++++++ ...an event Introducing eBPF Kernel probes.md | 361 +++++++++ ...sers guide to Logical Volume Management.md | 233 ++++++ ...9 INTRODUCING DOCKER SECRETS MANAGEMENT.md | 110 +++ ...170530 How to Improve a Legacy Codebase.md | 108 --- ...es Are Hiring Computer Security Experts.md | 91 +++ ... guide to links in the Linux filesystem.md | 314 -------- ...ow to answer questions in a helpful way.md | 172 +++++ ...Linux containers with Ansible Container.md | 114 +++ .../20171005 Reasons Kubernetes is cool.md | 148 ++++ ...20171010 Operating a Kubernetes network.md | 216 ++++++ ...LEAST PRIVILEGE CONTAINER ORCHESTRATION.md | 174 +++++ ...ow Eclipse is advancing IoT development.md | 83 -- ...ive into BPF a list of reading material.md | 711 ++++++++++++++++++ .../20171107 GitHub welcomes all CI tools.md | 95 +++ sources/tech/20171112 Love Your Bugs.md | 311 ++++++++ ... write fun small web projects instantly.md | 76 ++ .../20171114 Sysadmin 101 Patch Management.md | 61 ++ .../20171114 Take Linux and Run With It.md | 68 ++ ...obs Are Hot Get Trained and Get Noticed.md | 58 ++ ... and How to Set an Open Source Strategy.md | 120 +++ ...ux Programs for Drawing and Image Editing.md | 130 ++++ ...171120 Adopting Kubernetes step by step.md | 93 +++ ...20 Containers and Kubernetes Whats next.md | 98 --- ... Why microservices are a security issue.md | 116 +++ ...and Certification Are Key for SysAdmins.md | 70 -- ...Could Be Your New Favorite Container OS.md | 7 +- ...Help Build ONNX Open Source AI Platform.md | 76 ++ ... Your Linux Server Has Been Compromised.md | 156 ++++ ...71128 The politics of the Linux desktop.md | 110 +++ ... a great pair for beginning programmers.md | 142 ++++ ... open source technology trends for 2018.md | 143 ++++ ...actices for getting started with DevOps.md | 94 +++ ...eshark on Debian and Ubuntu 16.04_17.10.md | 185 +++++ ...n Source Components Ease Learning Curve.md | 70 ++ ...eractive Workflows for Cpp with Jupyter.md | 301 ++++++++ ...Unity from the Dead as an Official Spin.md | 41 + ...usiness Software Alternatives For Linux.md | 116 +++ ...x command-line screen grabs made simple.md | 108 +++ ...Search DuckDuckGo from the Command Line.md | 103 --- ...Long Running Terminal Commands Complete.md | 156 ++++ ...ke up and Shut Down Linux Automatically.md | 135 ++++ ...1 Fedora Classroom Session: Ansible 101.md | 71 ++ ...ow to Manage Users with Groups in Linux.md | 168 +++++ ... to find a publisher for your tech book.md | 76 ++ ...e your WiFi MAC address on Ubuntu 16.04.md | 160 ++++ ... millions of Linux users with Snapcraft.md | 321 ++++++++ ...inux command-line screen grabs made simple | 72 ++ ...0171202 docker - Use multi-stage builds.md | 127 ++++ ...The One in Which I Call Out Hacker News.md | 99 +++ ...170530 How to Improve a Legacy Codebase.md | 104 +++ .../20170910 Cool vim feature sessions.md | 44 ++ ...ow Eclipse is advancing IoT development.md | 77 ++ .../tech/20171108 Archiving repositories.md | 37 + ...6 Introducing security alerts on GitHub.md | 48 ++ ...stem Logs: Understand Your Linux System.md | 68 ++ ...Install Android File Transfer for Linux.md | 82 -- ...Could Be Your New Favorite Container OS.md | 147 ++++ ...every domain someone owns automatically.md | 49 ++ ...ogle Translate From Command Line In Linux.md | 400 ++++++++++ ...171201 Linux Journal Ceases Publication.md | 34 + ...ing Hardware for Beginners: Think Software | 89 +++ 126 files changed, 8338 insertions(+), 960 deletions(-) rename {translated/tech => published}/20161216 Kprobes Event Tracing on ARMv8.md (98%) create mode 100644 published/20170622 A users guide to links in the Linux filesystem.md rename {translated/tech => published}/20171009 Examining network connections on Linux systems.md (100%) rename {translated/tech => published}/20171029 A block layer introduction part 1 the bio layer.md (95%) rename published/{ => 201711}/20141028 When Does Your OS Run.md (100%) rename published/{ => 201711}/20170202 Understanding Firewalld in Multi-Zone Configurations.md (100%) rename published/{ => 201711}/20170227 Ubuntu Core in LXD containers.md (100%) rename published/{ => 201711}/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md (100%) rename published/{ => 201711}/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md (100%) rename published/{ => 201711}/20170608 The Life-Changing Magic of Tidying Up Code.md (100%) rename published/{ => 201711}/20170706 Wildcard Certificates Coming January 2018.md (100%) rename published/{ => 201711}/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md (100%) rename published/{ => 201711}/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md (100%) rename published/{ => 201711}/20170928 3 Python web scrapers and crawlers.md (100%) rename published/{ => 201711}/20171002 Scaling the GitLab database.md (100%) rename published/{ => 201711}/20171003 PostgreSQL Hash Indexes Are Now Cool.md (100%) rename published/{ => 201711}/20171004 No the Linux desktop hasnt jumped in popularity.md (100%) rename published/{ => 201711}/20171007 Instant 100 command line productivity boost.md (100%) rename published/{ => 201711}/20171008 8 best languages to blog about.md (100%) rename published/{ => 201711}/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md (100%) rename published/{ => 201711}/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md (100%) rename published/{ => 201711}/20171011 How to set up a Postgres database on a Raspberry Pi.md (100%) rename published/{ => 201711}/20171011 Why Linux Works.md (100%) rename published/{ => 201711}/20171013 6 reasons open source is good for business.md (100%) rename published/{ => 201711}/20171013 Best of PostgreSQL 10 for the DBA.md (100%) rename published/{ => 201711}/20171015 How to implement cloud-native computing with Kubernetes.md (100%) rename published/{ => 201711}/20171015 Monitoring Slow SQL Queries via Slack.md (100%) rename published/{ => 201711}/20171015 Why Use Docker with R A DevOps Perspective.md (100%) rename published/{ => 201711}/20171016 Introducing CRI-O 1.0.md (100%) rename published/{ => 201711}/20171017 A tour of Postgres Index Types.md (100%) rename published/{ => 201711}/20171017 Image Processing on Linux.md (100%) rename published/{ => 201711}/20171018 How containers and microservices change security.md (100%) rename published/{ => 201711}/20171018 Learn how to program in Python by building a simple dice game.md (100%) rename published/{ => 201711}/20171018 Tips to Secure Your Network in the Wake of KRACK.md (100%) rename published/{ => 201711}/20171019 3 Simple Excellent Linux Network Monitors.md (100%) rename published/{ => 201711}/20171019 How to manage Docker containers in Kubernetes with Java.md (100%) rename published/{ => 201711}/20171020 3 Tools to Help You Remember Linux Commands.md (100%) rename published/{ => 201711}/20171020 Running Android on Top of a Linux Graphics Stack.md (100%) rename published/{ => 201711}/20171024 Top 5 Linux pain points in 2017.md (100%) rename published/{ => 201711}/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md (100%) rename published/{ => 201711}/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md (100%) rename published/{ => 201711}/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md (100%) rename published/{ => 201711}/20171026 But I dont know what a container is .md (100%) rename published/{ => 201711}/20171026 Why is Kubernetes so popular.md (100%) rename published/{ => 201711}/20171101 How to use cron in Linux.md (100%) rename published/{ => 201711}/20171101 We re switching to a DCO for source code contributions.md (100%) rename published/{ => 201711}/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md (100%) rename published/{ => 201711}/20171106 Finding Files with mlocate.md (100%) rename published/{ => 201711}/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md (100%) rename published/{ => 201711}/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md (100%) rename published/{ => 201711}/20171107 AWS adopts home-brewed KVM as new hypervisor.md (100%) rename published/{ => 201711}/20171107 How I created my first RPM package in Fedora.md (100%) rename published/{ => 201711}/20171108 Build and test applications with Ansible Container.md (100%) rename published/{ => 201711}/20171110 File better bugs with coredumpctl.md (100%) rename published/{ => 201711}/20171114 ​Linux totally dominates supercomputers.md (100%) rename published/{ => 201711}/20171116 5 Coolest Linux Terminal Emulators.md (100%) rename published/{ => 201711}/20171117 How to Easily Remember Linux Commands.md (100%) rename published/{ => 201711}/20171118 Getting started with OpenFaaS on minikube.md (100%) rename published/{ => 201711}/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md (100%) create mode 100644 published/20171120 Containers and Kubernetes Whats next.md create mode 100644 published/20171124 How to Install Android File Transfer for Linux.md create mode 100644 published/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md create mode 100644 published/20171130 Search DuckDuckGo from the Command Line.md delete mode 100644 sources/tech/20090701 The One in Which I Call Out Hacker News.md create mode 100644 sources/tech/20130402 Dynamic linker tricks Using LD_PRELOAD to cheat inject features and investigate programs.md create mode 100644 sources/tech/20160330 How to turn any syscall into an event Introducing eBPF Kernel probes.md create mode 100644 sources/tech/20160922 A Linux users guide to Logical Volume Management.md create mode 100644 sources/tech/20170209 INTRODUCING DOCKER SECRETS MANAGEMENT.md delete mode 100644 sources/tech/20170530 How to Improve a Legacy Codebase.md create mode 100644 sources/tech/20170607 Why Car Companies Are Hiring Computer Security Experts.md delete mode 100644 sources/tech/20170622 A users guide to links in the Linux filesystem.md create mode 100644 sources/tech/20170921 How to answer questions in a helpful way.md create mode 100644 sources/tech/20171005 How to manage Linux containers with Ansible Container.md create mode 100644 sources/tech/20171005 Reasons Kubernetes is cool.md create mode 100644 sources/tech/20171010 Operating a Kubernetes network.md create mode 100644 sources/tech/20171011 LEAST PRIVILEGE CONTAINER ORCHESTRATION.md delete mode 100644 sources/tech/20171020 How Eclipse is advancing IoT development.md create mode 100644 sources/tech/20171102 Dive into BPF a list of reading material.md create mode 100644 sources/tech/20171107 GitHub welcomes all CI tools.md create mode 100644 sources/tech/20171112 Love Your Bugs.md create mode 100644 sources/tech/20171113 Glitch write fun small web projects instantly.md create mode 100644 sources/tech/20171114 Sysadmin 101 Patch Management.md create mode 100644 sources/tech/20171114 Take Linux and Run With It.md create mode 100644 sources/tech/20171115 Security Jobs Are Hot Get Trained and Get Noticed.md create mode 100644 sources/tech/20171115 Why and How to Set an Open Source Strategy.md create mode 100644 sources/tech/20171116 Unleash Your Creativity – Linux Programs for Drawing and Image Editing.md create mode 100644 sources/tech/20171120 Adopting Kubernetes step by step.md delete mode 100644 sources/tech/20171120 Containers and Kubernetes Whats next.md create mode 100644 sources/tech/20171123 Why microservices are a security issue.md delete mode 100644 sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md create mode 100644 sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md create mode 100644 sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md create mode 100644 sources/tech/20171128 The politics of the Linux desktop.md create mode 100644 sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md create mode 100644 sources/tech/20171129 10 open source technology trends for 2018.md create mode 100644 sources/tech/20171129 5 best practices for getting started with DevOps.md create mode 100644 sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md create mode 100644 sources/tech/20171129 Inside AGL Familiar Open Source Components Ease Learning Curve.md create mode 100644 sources/tech/20171129 Interactive Workflows for Cpp with Jupyter.md create mode 100644 sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md create mode 100644 sources/tech/20171130 Excellent Business Software Alternatives For Linux.md create mode 100644 sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md delete mode 100644 sources/tech/20171130 Search DuckDuckGo from the Command Line.md create mode 100644 sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md create mode 100644 sources/tech/20171130 Wake up and Shut Down Linux Automatically.md create mode 100644 sources/tech/20171201 Fedora Classroom Session: Ansible 101.md create mode 100644 sources/tech/20171201 How to Manage Users with Groups in Linux.md create mode 100644 sources/tech/20171201 How to find a publisher for your tech book.md create mode 100644 sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md create mode 100644 sources/tech/20171202 Easily control delivery of your Python applications to millions of Linux users with Snapcraft.md create mode 100644 sources/tech/20171202 Scrot Linux command-line screen grabs made simple create mode 100644 sources/tech/20171202 docker - Use multi-stage builds.md create mode 100644 translated/tech/20090701 The One in Which I Call Out Hacker News.md create mode 100644 translated/tech/20170530 How to Improve a Legacy Codebase.md create mode 100644 translated/tech/20170910 Cool vim feature sessions.md create mode 100644 translated/tech/20171020 How Eclipse is advancing IoT development.md create mode 100644 translated/tech/20171108 Archiving repositories.md create mode 100644 translated/tech/20171116 Introducing security alerts on GitHub.md create mode 100644 translated/tech/20171117 System Logs: Understand Your Linux System.md delete mode 100644 translated/tech/20171124 How to Install Android File Transfer for Linux.md create mode 100644 translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md create mode 100644 translated/tech/20171130 New Feature Find every domain someone owns automatically.md create mode 100644 translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md create mode 100644 translated/tech/20171201 Linux Journal Ceases Publication.md create mode 100644 translated/tech/Linux Networking Hardware for Beginners: Think Software diff --git a/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md b/published/20161216 Kprobes Event Tracing on ARMv8.md similarity index 98% rename from translated/tech/20161216 Kprobes Event Tracing on ARMv8.md rename to published/20161216 Kprobes Event Tracing on ARMv8.md index 3c3ab0de5b..3985f064dc 100644 --- a/translated/tech/20161216 Kprobes Event Tracing on ARMv8.md +++ b/published/20161216 Kprobes Event Tracing on ARMv8.md @@ -29,19 +29,19 @@ jprobes 允许通过提供一个具有相同调用签名call signature kprobes 提供一系列能从内核代码中调用的 API 来设置探测点和当探测点被命中时调用的注册函数。在不往内核中添加代码的情况下,kprobes 也是可用的,这是通过写入特定事件追踪的 debugfs 文件来实现的,需要在文件中设置探针地址和信息,以便在探针被命中时记录到追踪日志中。后者是本文将要讨论的重点。最后 kprobes 可以通过 perl 命令来使用。 -### kprobes API +#### kprobes API 内核开发人员可以在内核中编写函数(通常在专用的调试模块中完成)来设置探测点,并且在探测指令执行前和执行后立即执行任何所需操作。这在 kprobes.txt 中有很好的解释。 -### 事件追踪 +#### 事件追踪 事件追踪子系统有自己的自己的文档^注2 ,对于了解一般追踪事件的背景可能值得一读。事件追踪子系统是追踪点tracepoints和 kprobes 事件追踪的基础。事件追踪文档重点关注追踪点,所以请在查阅文档时记住这一点。kprobes 与追踪点不同的是没有预定义的追踪点列表,而是采用动态创建的用于触发追踪事件信息收集的任意探测点。事件追踪子系统通过一系列 debugfs 文件来控制和监视。事件追踪(`CONFIG_EVENT_TRACING`)将在被如 kprobe 事件追踪子系统等需要时自动选择。 -#### kprobes 事件 +##### kprobes 事件 使用 kprobes 事件追踪子系统,用户可以在内核任意断点处指定要报告的信息,只需要指定任意现有可探测指令的地址以及格式化信息即可确定。在执行过程中遇到断点时,kprobes 将所请求的信息传递给事件追踪子系统的公共部分,这些部分将数据格式化并追加到追踪日志中,就像追踪点的工作方式一样。kprobes 使用一个类似的但是大部分是独立的 debugfs 文件来控制和显示追踪事件信息。该功能可使用 `CONFIG_KPROBE_EVENT` 来选择。Kprobetrace 文档^ 注3 提供了如何使用 kprobes 事件追踪的基本信息,并且应当被参考用以了解以下介绍示例的详细信息。 -### kprobes 和 perf +#### kprobes 和 perf perf 工具为 kprobes 提供了另一个命令行接口。特别地,`perf probe` 允许探测点除了由函数名加偏移量和地址指定外,还可由源文件和行号指定。perf 接口实际上是使用 kprobes 的 debugfs 接口的封装器。 @@ -60,7 +60,7 @@ perf 工具为 kprobes 提供了另一个命令行接口。特别地,`perf pro kprobes 的一个常用例子是检测函数入口和/或出口。因为只需要使用函数名来作为探针地址,它安装探针特别简单。kprobes 事件追踪将查看符号名称并且确定地址。ARMv8 调用标准定义了函数参数和返回值的位置,并且这些可以作为 kprobes 事件处理的一部分被打印出来。 -### 例子: 函数入口探测 +#### 例子: 函数入口探测 检测 USB 以太网驱动程序复位功能: @@ -94,7 +94,7 @@ kworker/0:0-4 [000] d… 10972.102939: p_ax88772_reset_0: 这里我们可以看见传入到我们的探测函数的指针参数的值。由于我们没有使用 kprobes 事件追踪的可选标签功能,我们需要的信息自动被标注为 `arg1`。注意这指向我们需要 kprobes 记录这个探针的一组值的第一个,而不是函数参数的实际位置。在这个例子中它也只是碰巧是我们探测函数的第一个参数。 -### 例子: 函数入口和返回探测 +#### 例子: 函数入口和返回探测 kretprobe 功能专门用于探测函数返回。在函数入口 kprobes 子系统将会被调用并且建立钩子以便在函数返回时调用,钩子将记录需求事件信息。对最常见情况,返回信息通常在 `X0` 寄存器中,这是非常有用的。在 `%x0` 中返回值也可以被称为 `$retval`。以下例子也演示了如何提供一个可读的标签来展示有趣的信息。 @@ -132,7 +132,7 @@ _$ cat trace bash-1671 [001] d..1 214.401975: r__do_fork_0: (SyS_clone+0x18/0x20 <- _do_fork) pid=0x726_ ``` -### 例子: 解引用指针参数 +#### 例子: 解引用指针参数 对于指针值,kprobes 事件处理子系统也允许解引用和打印所需的内存内容,适用于各种基本数据类型。为了展示所需字段,手动计算结构的偏移量是必要的。 @@ -173,7 +173,7 @@ $ cat trace bash-1702 [002] d..1 175.347349: wait_r: (SyS_wait4+0x74/0xe4 <- do_wait) arg1=0xfffffffffffffff6 ``` -### 例子: 探测任意指令地址 +#### 例子: 探测任意指令地址 在前面的例子中,我们已经为函数的入口和出口插入探针,然而探测一个任意指令(除少数例外)是可能的。如果我们正在 C 函数中放置一个探针,第一步是查看代码的汇编版本以确定我们要放置探针的位置。一种方法是在 vmlinux 文件上使用 gdb,并在要放置探针的函数中展示指令。下面是一个在 `arch/arm64/kernel/modules.c` 中 `module_alloc` 函数执行此操作的示例。在这种情况下,因为 gdb 似乎更喜欢使用弱符号定义,并且它是与这个函数关联的存根代码,所以我们从 System.map 中来获取符号值: diff --git a/published/20170622 A users guide to links in the Linux filesystem.md b/published/20170622 A users guide to links in the Linux filesystem.md new file mode 100644 index 0000000000..7d731693d8 --- /dev/null +++ b/published/20170622 A users guide to links in the Linux filesystem.md @@ -0,0 +1,300 @@ +用户指南:Linux 文件系统的链接 +============================================================ + +> 学习如何使用链接,通过从 Linux 文件系统多个位置来访问文件,可以让日常工作变得轻松。 + +![linux 文件链接用户指南](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/links.png?itok=enaPOi4L "A user's guide to links in the Linux filesystem") + +Image by : [Paul Lewin][8]. Modified by Opensource.com. [CC BY-SA 2.0][9] + +在我为 opensource.com 写过的关于 Linux 文件系统方方面面的文章中,包括 [Linux 的 EXT4 文件系统的历史、特性以及最佳实践][10]; [在 Linux 中管理设备][11];[Linux 文件系统概览][12] 和 [用户指南:逻辑卷管理][13],我曾简要的提到过 Linux 文件系统一个有趣的特性,它允许用户从多个位置来访问 Linux 文件目录树中的文件来简化一些任务。 + +Linux 文件系统中有两种链接link硬链接hard link软链接soft link。虽然二者差别显著,但都用来解决相似的问题。它们都提供了对单个文件的多个目录项(引用)的访问,但实现却大为不同。链接的强大功能赋予了 Linux 文件系统灵活性,因为[一切皆是文件][14]。 + +举个例子,我曾发现一些程序要求特定的版本库方可运行。 当用升级后的库替代旧库后,程序会崩溃,提示旧版本库缺失。通常,库名的唯一变化就是版本号。出于直觉,我仅仅给程序添加了一个新的库链接,并以旧库名称命名。我试着再次启动程序,运行良好。程序就是一个游戏,人人都明白,每个玩家都会尽力使游戏进行下去。 + +事实上,几乎所有的应用程序链接库都使用通用的命名规则,链接名称中包含了主版本号,链接所指向的文件的文件名中同样包含了小版本号。再比如,程序的一些必需文件为了迎合 Linux 文件系统规范,从一个目录移动到另一个目录中,系统为了向后兼容那些不能获取这些文件新位置的程序在旧的目录中存放了这些文件的链接。如果你对 `/lib64` 目录做一个长清单列表,你会发现很多这样的例子。 + +``` +lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.hwm -> ../../usr/share/cracklib/pw_dict.hwm +lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.pwd -> ../../usr/share/cracklib/pw_dict.pwd +lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.pwi -> ../../usr/share/cracklib/pw_dict.pwi +lrwxrwxrwx. 1 root root 27 Jun 9 2016 libaccountsservice.so.0 -> libaccountsservice.so.0.0.0 +-rwxr-xr-x. 1 root root 288456 Jun 9 2016 libaccountsservice.so.0.0.0 +lrwxrwxrwx 1 root root 15 May 17 11:47 libacl.so.1 -> libacl.so.1.1.0 +-rwxr-xr-x 1 root root 36472 May 17 11:47 libacl.so.1.1.0 +lrwxrwxrwx. 1 root root 15 Feb 4 2016 libaio.so.1 -> libaio.so.1.0.1 +-rwxr-xr-x. 1 root root 6224 Feb 4 2016 libaio.so.1.0.0 +-rwxr-xr-x. 1 root root 6224 Feb 4 2016 libaio.so.1.0.1 +lrwxrwxrwx. 1 root root 30 Jan 16 16:39 libakonadi-calendar.so.4 -> libakonadi-calendar.so.4.14.26 +-rwxr-xr-x. 1 root root 816160 Jan 16 16:39 libakonadi-calendar.so.4.14.26 +lrwxrwxrwx. 1 root root 29 Jan 16 16:39 libakonadi-contact.so.4 -> libakonadi-contact.so.4.14.26 +``` + +`/lib64` 目录下的一些链接 + +在上面展示的 `/lib64` 目录清单列表中,文件模式第一个字母 `l` (小写字母 l)表示这是一个软链接(又称符号链接)。 + +### 硬链接 + +在 [Linux 的 EXT4 文件系统的历史、特性以及最佳实践][15]一文中,我曾探讨过这样一个事实,每个文件都有一个包含该文件信息的 inode,包含了该文件的位置信息。上述文章中的[图2][16]展示了一个指向 inode 的单一目录项。每个文件都至少有一个目录项指向描述该文件信息的 inode ,目录项是一个硬链接,因此每个文件至少都有一个硬链接。 + +如下图 1 所示,多个目录项指向了同一 inode 。这些目录项都是硬链接。我曾在三个目录项中使用波浪线 (`~`) 的缩写,这是用户目录的惯例表示,因此在该例中波浪线等同于 `/home/user` 。值得注意的是,第四个目录项是一个完全不同的目录,`/home/shared`,可能是该计算机上用户的共享文件目录。 + +![fig1directory_entries.png](https://opensource.com/sites/default/files/images/life/fig1directory_entries.png) + +*图 1* + +硬链接被限制在一个单一的文件系统中。此处的“文件系统” 是指挂载在特定挂载点上的分区或逻辑卷,此例中是 `/home`。这是因为在每个文件系统中的 inode 号都是唯一的。而在不同的文件系统中,如 `/var` 或 `/opt`,会有和 `/home` 中相同的 inode 号。 + +因为所有的硬链接都指向了包含文件元信息的单一 inode ,这些属性都是文件的一部分,像所属关系、权限、到该 inode 的硬链接数目,对每个硬链接来说这些特性没有什么不同的。这是一个文件所具有的一组属性。唯一能区分这些文件的是包含在 inode 信息中的文件名。链接到同一目录中的单一文件/ inode 的硬链接必须拥有不同的文件名,这是基于同一目录下不能存在重复的文件名的事实的。 + +文件的硬链接数目可通过 `ls -l` 来查看,如果你想查看实际节点号,可使用 `ls -li` 命令。 + +### 符号(软)链接 + +硬链接和软链接(也称为符号链接symlink)的区别在于,硬链接直接指向属于该文件的 inode ,而软链接直接指向一个目录项,即指向一个硬链接。因为软链接指向的是一个文件的硬链接而非该文件的 inode ,所以它们并不依赖于 inode 号,这使得它们能跨越不同的文件系统、分区和逻辑卷起作用。 + +软链接的缺点是,一旦它所指向的硬链接被删除或重命名后,该软链接就失效了。软链接虽然还在,但所指向的硬链接已不存在。所幸的是,`ls` 命令能以红底白字的方式在其列表中高亮显示失效的软链接。 + +### 实验项目: 链接实验 + +我认为最容易理解链接用法及其差异的方法是动手搭建一个项目。这个项目应以非超级用户的身份在一个空目录下进行。我创建了 `~/temp` 目录做这个实验,你也可以这么做。这么做可为项目创建一个安全的环境且提供一个新的空目录让程序运作,如此以来这儿仅存放和程序有关的文件。 + +#### 初始工作 + +首先,在你要进行实验的目录下为该项目中的任务创建一个临时目录,确保当前工作目录(PWD)是你的主目录,然后键入下列命令。 + +``` +mkdir temp +``` + +使用这个命令将当前工作目录切换到 `~/temp`。 + +``` +cd temp +``` + +实验开始,我们需要创建一个能够链接到的文件,下列命令可完成该工作并向其填充内容。 + +``` +du -h > main.file.txt +``` + +使用 `ls -l` 长列表命名确认文件正确地创建了。运行结果应类似于我的。注意文件大小只有 7 字节,但你的可能会有 1~2 字节的变动。 + +``` +[dboth@david temp]$ ls -l +total 4 +-rw-rw-r-- 1 dboth dboth 7 Jun 13 07:34 main.file.txt +``` + +在列表中,文件模式串后的数字 `1` 代表存在于该文件上的硬链接数。现在应该是 1 ,因为我们还没有为这个测试文件建立任何硬链接。 + +#### 对硬链接进行实验 + +硬链接创建一个指向同一 inode 的新目录项,当为文件添加一个硬链接时,你会看到链接数目的增加。确保当前工作目录仍为 `~/temp`。创建一个指向 `main.file.txt` 的硬链接,然后查看该目录下文件列表。 + +``` +[dboth@david temp]$ ln main.file.txt link1.file.txt +[dboth@david temp]$ ls -l +total 8 +-rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 link1.file.txt +-rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 main.file.txt +``` + +目录中两个文件都有两个链接且大小相同,时间戳也一样。这就是有一个 inode 和两个硬链接(即该文件的目录项)的一个文件。再建立一个该文件的硬链接,并列出目录清单内容。你可以建立硬链接: `link1.file.txt` 或 `main.file.txt`。 + +``` +[dboth@david temp]$ ln link1.file.txt link2.file.txt ; ls -l +total 16 +-rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link1.file.txt +-rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link2.file.txt +-rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 main.file.txt +``` + +注意,该目录下的每个硬链接必须使用不同的名称,因为同一目录下的两个文件不能拥有相同的文件名。试着创建一个和现存链接名称相同的硬链接。 + +``` +[dboth@david temp]$ ln main.file.txt link2.file.txt +ln: failed to create hard link 'link2.file.txt': File exists +``` + +显然不行,因为 `link2.file.txt` 已经存在。目前为止我们只在同一目录下创建硬链接,接着在临时目录的父目录(你的主目录)中创建一个链接。 + +``` +[dboth@david temp]$ ln main.file.txt ../main.file.txt ; ls -l ../main* +-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt +``` + +上面的 `ls` 命令显示 `main.file.txt` 文件确实存在于主目录中,且与该文件在 `temp` 目录中的名称一致。当然它们不是不同的文件,它们是同一文件的两个链接,指向了同一文件的目录项。为了帮助说明下一点,在 `temp` 目录中添加一个非链接文件。 + +``` +[dboth@david temp]$ touch unlinked.file ; ls -l +total 12 +-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt +-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt +-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt +-rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +使用 `ls` 命令的 `i` 选项查看 inode 的硬链接号和新创建文件的硬链接号。 + +``` +[dboth@david temp]$ ls -li +total 12 +657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt +657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt +657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +注意上面文件模式左边的数字 `657024` ,这是三个硬链接文件所指的同一文件的 inode 号,你也可以使用 `i` 选项查看主目录中所创建的链接的节点号,和该值相同。而那个只有一个链接的 inode 号和其他的不同,在你的系统上看到的 inode 号或许不同于本文中的。 + +接着改变其中一个硬链接文件的大小。 + +``` +[dboth@david temp]$ df -h > link2.file.txt ; ls -li +total 12 +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +现在所有的硬链接文件大小都比原来大了,因为多个目录项都链接着同一文件。 + +下个实验在我的电脑上会出现这样的结果,是因为我的 `/tmp` 目录在一个独立的逻辑卷上。如果你有单独的逻辑卷或文件系统在不同的分区上(如果未使用逻辑卷),确定你是否能访问那个分区或逻辑卷,如果不能,你可以在电脑上挂载一个 U 盘,如果上述方式适合你,你可以进行这个实验。 + +试着在 `/tmp` 目录中建立一个 `~/temp` 目录下文件的链接(或你的文件系统所在的位置)。 + +``` +[dboth@david temp]$ ln link2.file.txt /tmp/link3.file.txt +ln: failed to create hard link '/tmp/link3.file.txt' => 'link2.file.txt': +Invalid cross-device link +``` + +为什么会出现这个错误呢? 原因是每一个单独的可挂载文件系统都有一套自己的 inode 号。简单的通过 inode 号来跨越整个 Linux 文件系统结构引用一个文件会使系统困惑,因为相同的节点号会存在于每个已挂载的文件系统中。 + +有时你可能会想找到一个 inode 的所有硬链接。你可以使用 `ls -li` 命令。然后使用 `find` 命令找到所有硬链接的节点号。 + +``` +[dboth@david temp]$ find . -inum 657024 +./main.file.txt +./link1.file.txt +./link2.file.txt +``` + +注意 `find` 命令不能找到所属该节点的四个硬链接,因为我们在 `~/temp` 目录中查找。 `find` 命令仅在当前工作目录及其子目录中查找文件。要找到所有的硬链接,我们可以使用下列命令,指定你的主目录作为起始查找条件。 + +``` +[dboth@david temp]$ find ~ -samefile main.file.txt +/home/dboth/temp/main.file.txt +/home/dboth/temp/link1.file.txt +/home/dboth/temp/link2.file.txt +/home/dboth/main.file.txt +``` + +如果你是非超级用户,没有权限,可能会看到错误信息。这个命令也使用了 `-samefile` 选项而不是指定文件的节点号。这个效果和使用 inode 号一样且更容易,如果你知道其中一个硬链接名称的话。 + +#### 对软链接进行实验 + +如你刚才看到的,不能跨越文件系统边界创建硬链接,即在逻辑卷或文件系统中从一个文件系统到另一个文件系统。软链接给出了这个问题的解决方案。虽然它们可以达到相同的目的,但它们是非常不同的,知道这些差异是很重要的。 + +让我们在 `~/temp` 目录中创建一个符号链接来开始我们的探索。 + +``` +[dboth@david temp]$ ln -s link2.file.txt link3.file.txt ; ls -li +total 12 +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt +658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> +link2.file.txt +657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +拥有节点号 `657024` 的那些硬链接没有变化,且硬链接的数目也没有变化。新创建的符号链接有不同的 inode 号 `658270`。 名为 `link3.file.txt` 的软链接指向了 `link2.file.txt` 文件。使用 `cat` 命令查看 `link3.file.txt` 文件的内容。符号链接的 inode 信息以字母 `l` (小写字母 l)开头,意味着这个文件实际是个符号链接。 + +上例中软链接文件 `link3.file.txt` 的大小只有 14 字节。这是文本内容 `link3.file.txt` 的大小,即该目录项的实际内容。目录项 `link3.file.txt` 并不指向一个 inode ;它指向了另一个目录项,这在跨越文件系统建立链接时很有帮助。现在试着创建一个软链接,之前在 `/tmp` 目录中尝试过的。 + +``` +[dboth@david temp]$ ln -s /home/dboth/temp/link2.file.txt +/tmp/link3.file.txt ; ls -l /tmp/link* +lrwxrwxrwx 1 dboth dboth 31 Jun 14 21:53 /tmp/link3.file.txt -> +/home/dboth/temp/link2.file.txt +``` + +#### 删除链接 + +当你删除硬链接或硬链接所指的文件时,需要考虑一些问题。 + +首先,让我们删除硬链接文件 `main.file.txt`。注意指向 inode 的每个目录项就是一个硬链接。 + +``` +[dboth@david temp]$ rm main.file.txt ; ls -li +total 8 +657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link1.file.txt +657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link2.file.txt +658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> +link2.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +`main.file.txt` 是该文件被创建时所创建的第一个硬链接。现在删除它,仍然保留着原始文件和硬盘上的数据以及所有剩余的硬链接。要删除原始文件,你必须删除它的所有硬链接。 + +现在删除 `link2.file.txt` 硬链接文件。 + +``` +[dboth@david temp]$ rm link2.file.txt ; ls -li +total 8 +657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link1.file.txt +658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> +link2.file.txt +657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 main.file.txt +657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file +``` + +注意软链接的变化。删除软链接所指的硬链接会使该软链接失效。在我的系统中,断开的链接用颜色高亮显示,目标的硬链接会闪烁显示。如果需要修复这个损坏的软链接,你需要在同一目录下建立一个和旧链接相同名字的硬链接,只要不是所有硬链接都已删除就行。您还可以重新创建链接本身,链接保持相同的名称,但指向剩余的硬链接中的一个。当然如果软链接不再需要,可以使用 `rm` 命令删除它们。 + +`unlink` 命令在删除文件和链接时也有用。它非常简单且没有选项,就像 `rm` 命令一样。然而,它更准确地反映了删除的基本过程,因为它删除了目录项与被删除文件的链接。 + +### 写在最后 + +我用过这两种类型的链接很长一段时间后,我开始了解它们的能力和特质。我为我所教的 Linux 课程编写了一个实验室项目,以充分理解链接是如何工作的,并且我希望增进你的理解。 + +-------------------------------------------------------------------------------- + +作者简介: + +戴维.布斯 - 戴维.布斯是 Linux 和开源倡导者,居住在北卡罗莱纳的罗列 。他在 IT 行业工作了四十年,为 IBM 工作了 20 多年的 OS/2。在 IBM 时,他在 1981 年编写了最初的 IBM PC 的第一个培训课程。他为 RedHat 教授过 RHCE 班,并曾在 MCI Worldcom、思科和北卡罗莱纳州工作。他已经用 Linux 和开源软件工作将近 20 年了。 + +--------------------------------- + +via: https://opensource.com/article/17/6/linking-linux-filesystem + +作者:[David Both][a] +译者:[yongshouzhang](https://github.com/yongshouzhang) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/dboth +[1]:https://opensource.com/resources/what-is-linux?src=linux_resource_menu +[2]:https://opensource.com/resources/what-are-linux-containers?src=linux_resource_menu +[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=7016000000127cYAAQ +[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?src=linux_resource_menu&intcmp=7016000000127cYAAQ +[5]:https://opensource.com/tags/linux?src=linux_resource_menu +[6]:https://opensource.com/article/17/6/linking-linux-filesystem?rate=YebHxA-zgNopDQKKOyX3_r25hGvnZms_33sYBUq-SMM +[7]:https://opensource.com/user/14106/feed +[8]:https://www.flickr.com/photos/digypho/7905320090 +[9]:https://creativecommons.org/licenses/by/2.0/ +[10]:https://linux.cn/article-8685-1.html +[11]:https://linux.cn/article-8099-1.html +[12]:https://linux.cn/article-8887-1.html +[13]:https://opensource.com/business/16/9/linux-users-guide-lvm +[14]:https://opensource.com/life/15/9/everything-is-a-file +[15]:https://linux.cn/article-8685-1.html +[16]:https://linux.cn/article-8685-1.html#3_19182 +[17]:https://opensource.com/users/dboth +[18]:https://opensource.com/article/17/6/linking-linux-filesystem#comments diff --git a/translated/tech/20171009 Examining network connections on Linux systems.md b/published/20171009 Examining network connections on Linux systems.md similarity index 100% rename from translated/tech/20171009 Examining network connections on Linux systems.md rename to published/20171009 Examining network connections on Linux systems.md diff --git a/translated/tech/20171029 A block layer introduction part 1 the bio layer.md b/published/20171029 A block layer introduction part 1 the bio layer.md similarity index 95% rename from translated/tech/20171029 A block layer introduction part 1 the bio layer.md rename to published/20171029 A block layer introduction part 1 the bio layer.md index bc3f582259..96374c2302 100644 --- a/translated/tech/20171029 A block layer introduction part 1 the bio layer.md +++ b/published/20171029 A block layer introduction part 1 the bio layer.md @@ -1,4 +1,4 @@ -块层介绍第一部分:块 I/O 层 +回复:块层介绍第一部分 - 块 I/O 层 ============================================================ ### 块层介绍第一部分:块 I/O 层 @@ -6,9 +6,14 @@ 回复:amarao 在[块层介绍第一部分:块 I/O 层][1] 中提的问题 先前的文章:[块层介绍第一部分:块 I/O 层][2] +![](https://static.lwn.net/images/2017/neil-blocklayer.png) + 嗨, + 你在这里描述的问题与块层不直接相关。这可能是一个驱动错误、可能是一个 SCSI 层错误,但绝对不是一个块层的问题。 + 不幸的是,报告针对 Linux 的错误是一件难事。有些开发者拒绝去看 bugzilla,有些开发者喜欢它,有些(像我这样)只能勉强地使用它。 + 另一种方法是发送电子邮件。为此,你需要选择正确的邮件列表,还有也许是正确的开发人员,当他们心情愉快,或者不是太忙或者不是假期时找到它们。有些人会努力回复所有,有些是完全不可预知的 - 这对我来说通常会发送一个补丁,包含一些错误报告。如果你只是有一个你自己几乎都不了解的 bug,那么你的预期响应率可能会更低。很遗憾,但这是是真的。 许多 bug 都会得到回应和处理,但很多 bug 都没有。 @@ -16,18 +21,20 @@ 我不认为说没有人关心是公平的,但是没有人认为它如你想的那样重要是有可能的。如果你想要一个解决方案,那么你需要驱动它。一个驱动它的方法是花钱请顾问或者与经销商签订支持合同。我怀疑你的情况没有上面的可能。另一种方法是了解代码如何工作,并自己找到解决方案。很多人都这么做,但是这对你来说可能不是一种选择。另一种方法是在不同的相关论坛上不断提出问题,直到得到回复。坚持可以见效。你需要做好准备去执行任何你所要求的测试,可能包括建立一个新的内核来测试。 如果你能在最近的内核(4.12 或者更新)上复现这个 bug,我建议你邮件报告给 linux-kernel@vger.kernel.org、linux-scsi@vger.kernel.org 和我(neilb@suse.com)(注意你不必订阅这些列表来发送邮件,只需要发送就行)。描述你的硬件以及如何触发问题的。 + 包含所有进程状态是 “D” 的栈追踪。你可以用 “cat /proc/$PID/stack” 来得到它,这里的 “$PID” 是进程的 pid。 确保避免抱怨或者说这个已经坏了好几年了以及这是多么严重不足。没有人关心这个。我们关心的是 bug 以及如何修复它。因此只要报告相关的事实就行。 + 尝试在邮件中而不是链接到其他地方的链接中包含所有事实。有时链接是需要的,但是对于你的脚本,它只有 8 行,所以把它包含在邮件中就行(并避免像 “fuckup” 之类的描述。只需称它为“坏的”(broken)或者类似的)。同样确保你的邮件发送的不是 HTML 格式。我们喜欢纯文本。HTML 被所有的 @vger.kernel.org 邮件列表拒绝。你或许需要配置你的邮箱程序不发送 HTML。 -------------------------------------------------------------------------------- via: https://lwn.net/Articles/737655/ -作者:[ neilbrown][a] +作者:[neilbrown][a] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20141028 When Does Your OS Run.md b/published/201711/20141028 When Does Your OS Run.md similarity index 100% rename from published/20141028 When Does Your OS Run.md rename to published/201711/20141028 When Does Your OS Run.md diff --git a/published/20170202 Understanding Firewalld in Multi-Zone Configurations.md b/published/201711/20170202 Understanding Firewalld in Multi-Zone Configurations.md similarity index 100% rename from published/20170202 Understanding Firewalld in Multi-Zone Configurations.md rename to published/201711/20170202 Understanding Firewalld in Multi-Zone Configurations.md diff --git a/published/20170227 Ubuntu Core in LXD containers.md b/published/201711/20170227 Ubuntu Core in LXD containers.md similarity index 100% rename from published/20170227 Ubuntu Core in LXD containers.md rename to published/201711/20170227 Ubuntu Core in LXD containers.md diff --git a/published/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md b/published/201711/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md similarity index 100% rename from published/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md rename to published/201711/20170418 INTRODUCING MOBY PROJECT A NEW OPEN-SOURCE PROJECT TO ADVANCE THE SOFTWARE CONTAINERIZATION MOVEMENT.md diff --git a/published/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md b/published/201711/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md similarity index 100% rename from published/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md rename to published/201711/20170531 Understanding Docker Container Host vs Container OS for Linux and Windows Containers.md diff --git a/published/20170608 The Life-Changing Magic of Tidying Up Code.md b/published/201711/20170608 The Life-Changing Magic of Tidying Up Code.md similarity index 100% rename from published/20170608 The Life-Changing Magic of Tidying Up Code.md rename to published/201711/20170608 The Life-Changing Magic of Tidying Up Code.md diff --git a/published/20170706 Wildcard Certificates Coming January 2018.md b/published/201711/20170706 Wildcard Certificates Coming January 2018.md similarity index 100% rename from published/20170706 Wildcard Certificates Coming January 2018.md rename to published/201711/20170706 Wildcard Certificates Coming January 2018.md diff --git a/published/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md b/published/201711/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md similarity index 100% rename from published/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md rename to published/201711/20170825 Guide to Linux App Is a Handy Tool for Every Level of Linux User.md diff --git a/published/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md b/published/201711/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md similarity index 100% rename from published/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md rename to published/201711/20170905 GIVE AWAY YOUR CODE BUT NEVER YOUR TIME.md diff --git a/published/20170928 3 Python web scrapers and crawlers.md b/published/201711/20170928 3 Python web scrapers and crawlers.md similarity index 100% rename from published/20170928 3 Python web scrapers and crawlers.md rename to published/201711/20170928 3 Python web scrapers and crawlers.md diff --git a/published/20171002 Scaling the GitLab database.md b/published/201711/20171002 Scaling the GitLab database.md similarity index 100% rename from published/20171002 Scaling the GitLab database.md rename to published/201711/20171002 Scaling the GitLab database.md diff --git a/published/20171003 PostgreSQL Hash Indexes Are Now Cool.md b/published/201711/20171003 PostgreSQL Hash Indexes Are Now Cool.md similarity index 100% rename from published/20171003 PostgreSQL Hash Indexes Are Now Cool.md rename to published/201711/20171003 PostgreSQL Hash Indexes Are Now Cool.md diff --git a/published/20171004 No the Linux desktop hasnt jumped in popularity.md b/published/201711/20171004 No the Linux desktop hasnt jumped in popularity.md similarity index 100% rename from published/20171004 No the Linux desktop hasnt jumped in popularity.md rename to published/201711/20171004 No the Linux desktop hasnt jumped in popularity.md diff --git a/published/20171007 Instant 100 command line productivity boost.md b/published/201711/20171007 Instant 100 command line productivity boost.md similarity index 100% rename from published/20171007 Instant 100 command line productivity boost.md rename to published/201711/20171007 Instant 100 command line productivity boost.md diff --git a/published/20171008 8 best languages to blog about.md b/published/201711/20171008 8 best languages to blog about.md similarity index 100% rename from published/20171008 8 best languages to blog about.md rename to published/201711/20171008 8 best languages to blog about.md diff --git a/published/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md b/published/201711/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md similarity index 100% rename from published/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md rename to published/201711/20171009 CyberShaolin Teaching the Next Generation of Cybersecurity Experts.md diff --git a/published/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md b/published/201711/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md similarity index 100% rename from published/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md rename to published/201711/20171010 Getting Started Analyzing Twitter Data in Apache Kafka through KSQL.md diff --git a/published/20171011 How to set up a Postgres database on a Raspberry Pi.md b/published/201711/20171011 How to set up a Postgres database on a Raspberry Pi.md similarity index 100% rename from published/20171011 How to set up a Postgres database on a Raspberry Pi.md rename to published/201711/20171011 How to set up a Postgres database on a Raspberry Pi.md diff --git a/published/20171011 Why Linux Works.md b/published/201711/20171011 Why Linux Works.md similarity index 100% rename from published/20171011 Why Linux Works.md rename to published/201711/20171011 Why Linux Works.md diff --git a/published/20171013 6 reasons open source is good for business.md b/published/201711/20171013 6 reasons open source is good for business.md similarity index 100% rename from published/20171013 6 reasons open source is good for business.md rename to published/201711/20171013 6 reasons open source is good for business.md diff --git a/published/20171013 Best of PostgreSQL 10 for the DBA.md b/published/201711/20171013 Best of PostgreSQL 10 for the DBA.md similarity index 100% rename from published/20171013 Best of PostgreSQL 10 for the DBA.md rename to published/201711/20171013 Best of PostgreSQL 10 for the DBA.md diff --git a/published/20171015 How to implement cloud-native computing with Kubernetes.md b/published/201711/20171015 How to implement cloud-native computing with Kubernetes.md similarity index 100% rename from published/20171015 How to implement cloud-native computing with Kubernetes.md rename to published/201711/20171015 How to implement cloud-native computing with Kubernetes.md diff --git a/published/20171015 Monitoring Slow SQL Queries via Slack.md b/published/201711/20171015 Monitoring Slow SQL Queries via Slack.md similarity index 100% rename from published/20171015 Monitoring Slow SQL Queries via Slack.md rename to published/201711/20171015 Monitoring Slow SQL Queries via Slack.md diff --git a/published/20171015 Why Use Docker with R A DevOps Perspective.md b/published/201711/20171015 Why Use Docker with R A DevOps Perspective.md similarity index 100% rename from published/20171015 Why Use Docker with R A DevOps Perspective.md rename to published/201711/20171015 Why Use Docker with R A DevOps Perspective.md diff --git a/published/20171016 Introducing CRI-O 1.0.md b/published/201711/20171016 Introducing CRI-O 1.0.md similarity index 100% rename from published/20171016 Introducing CRI-O 1.0.md rename to published/201711/20171016 Introducing CRI-O 1.0.md diff --git a/published/20171017 A tour of Postgres Index Types.md b/published/201711/20171017 A tour of Postgres Index Types.md similarity index 100% rename from published/20171017 A tour of Postgres Index Types.md rename to published/201711/20171017 A tour of Postgres Index Types.md diff --git a/published/20171017 Image Processing on Linux.md b/published/201711/20171017 Image Processing on Linux.md similarity index 100% rename from published/20171017 Image Processing on Linux.md rename to published/201711/20171017 Image Processing on Linux.md diff --git a/published/20171018 How containers and microservices change security.md b/published/201711/20171018 How containers and microservices change security.md similarity index 100% rename from published/20171018 How containers and microservices change security.md rename to published/201711/20171018 How containers and microservices change security.md diff --git a/published/20171018 Learn how to program in Python by building a simple dice game.md b/published/201711/20171018 Learn how to program in Python by building a simple dice game.md similarity index 100% rename from published/20171018 Learn how to program in Python by building a simple dice game.md rename to published/201711/20171018 Learn how to program in Python by building a simple dice game.md diff --git a/published/20171018 Tips to Secure Your Network in the Wake of KRACK.md b/published/201711/20171018 Tips to Secure Your Network in the Wake of KRACK.md similarity index 100% rename from published/20171018 Tips to Secure Your Network in the Wake of KRACK.md rename to published/201711/20171018 Tips to Secure Your Network in the Wake of KRACK.md diff --git a/published/20171019 3 Simple Excellent Linux Network Monitors.md b/published/201711/20171019 3 Simple Excellent Linux Network Monitors.md similarity index 100% rename from published/20171019 3 Simple Excellent Linux Network Monitors.md rename to published/201711/20171019 3 Simple Excellent Linux Network Monitors.md diff --git a/published/20171019 How to manage Docker containers in Kubernetes with Java.md b/published/201711/20171019 How to manage Docker containers in Kubernetes with Java.md similarity index 100% rename from published/20171019 How to manage Docker containers in Kubernetes with Java.md rename to published/201711/20171019 How to manage Docker containers in Kubernetes with Java.md diff --git a/published/20171020 3 Tools to Help You Remember Linux Commands.md b/published/201711/20171020 3 Tools to Help You Remember Linux Commands.md similarity index 100% rename from published/20171020 3 Tools to Help You Remember Linux Commands.md rename to published/201711/20171020 3 Tools to Help You Remember Linux Commands.md diff --git a/published/20171020 Running Android on Top of a Linux Graphics Stack.md b/published/201711/20171020 Running Android on Top of a Linux Graphics Stack.md similarity index 100% rename from published/20171020 Running Android on Top of a Linux Graphics Stack.md rename to published/201711/20171020 Running Android on Top of a Linux Graphics Stack.md diff --git a/published/20171024 Top 5 Linux pain points in 2017.md b/published/201711/20171024 Top 5 Linux pain points in 2017.md similarity index 100% rename from published/20171024 Top 5 Linux pain points in 2017.md rename to published/201711/20171024 Top 5 Linux pain points in 2017.md diff --git a/published/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md b/published/201711/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md similarity index 100% rename from published/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md rename to published/201711/20171024 Who contributed the most to open source in 2017 Let s analyze GitHub’s data and find out.md diff --git a/published/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md b/published/201711/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md similarity index 100% rename from published/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md rename to published/201711/20171024 Why Did Ubuntu Drop Unity Mark Shuttleworth Explains.md diff --git a/published/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md b/published/201711/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md similarity index 100% rename from published/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md rename to published/201711/20171025 How to roll your own backup solution with BorgBackup, Rclone and Wasabi cloud storage.md diff --git a/published/20171026 But I dont know what a container is .md b/published/201711/20171026 But I dont know what a container is .md similarity index 100% rename from published/20171026 But I dont know what a container is .md rename to published/201711/20171026 But I dont know what a container is .md diff --git a/published/20171026 Why is Kubernetes so popular.md b/published/201711/20171026 Why is Kubernetes so popular.md similarity index 100% rename from published/20171026 Why is Kubernetes so popular.md rename to published/201711/20171026 Why is Kubernetes so popular.md diff --git a/published/20171101 How to use cron in Linux.md b/published/201711/20171101 How to use cron in Linux.md similarity index 100% rename from published/20171101 How to use cron in Linux.md rename to published/201711/20171101 How to use cron in Linux.md diff --git a/published/20171101 We re switching to a DCO for source code contributions.md b/published/201711/20171101 We re switching to a DCO for source code contributions.md similarity index 100% rename from published/20171101 We re switching to a DCO for source code contributions.md rename to published/201711/20171101 We re switching to a DCO for source code contributions.md diff --git a/published/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md b/published/201711/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md similarity index 100% rename from published/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md rename to published/201711/20171106 4 Tools to Manage EXT2 EXT3 and EXT4 Health in Linux.md diff --git a/published/20171106 Finding Files with mlocate.md b/published/201711/20171106 Finding Files with mlocate.md similarity index 100% rename from published/20171106 Finding Files with mlocate.md rename to published/201711/20171106 Finding Files with mlocate.md diff --git a/published/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md b/published/201711/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md similarity index 100% rename from published/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md rename to published/201711/20171106 Linux Foundation Publishes Enterprise Open Source Guides.md diff --git a/published/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md b/published/201711/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md similarity index 100% rename from published/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md rename to published/201711/20171106 Most companies can t buy an open source community clue. Here s how to do it right.md diff --git a/published/20171107 AWS adopts home-brewed KVM as new hypervisor.md b/published/201711/20171107 AWS adopts home-brewed KVM as new hypervisor.md similarity index 100% rename from published/20171107 AWS adopts home-brewed KVM as new hypervisor.md rename to published/201711/20171107 AWS adopts home-brewed KVM as new hypervisor.md diff --git a/published/20171107 How I created my first RPM package in Fedora.md b/published/201711/20171107 How I created my first RPM package in Fedora.md similarity index 100% rename from published/20171107 How I created my first RPM package in Fedora.md rename to published/201711/20171107 How I created my first RPM package in Fedora.md diff --git a/published/20171108 Build and test applications with Ansible Container.md b/published/201711/20171108 Build and test applications with Ansible Container.md similarity index 100% rename from published/20171108 Build and test applications with Ansible Container.md rename to published/201711/20171108 Build and test applications with Ansible Container.md diff --git a/published/20171110 File better bugs with coredumpctl.md b/published/201711/20171110 File better bugs with coredumpctl.md similarity index 100% rename from published/20171110 File better bugs with coredumpctl.md rename to published/201711/20171110 File better bugs with coredumpctl.md diff --git a/published/20171114 ​Linux totally dominates supercomputers.md b/published/201711/20171114 ​Linux totally dominates supercomputers.md similarity index 100% rename from published/20171114 ​Linux totally dominates supercomputers.md rename to published/201711/20171114 ​Linux totally dominates supercomputers.md diff --git a/published/20171116 5 Coolest Linux Terminal Emulators.md b/published/201711/20171116 5 Coolest Linux Terminal Emulators.md similarity index 100% rename from published/20171116 5 Coolest Linux Terminal Emulators.md rename to published/201711/20171116 5 Coolest Linux Terminal Emulators.md diff --git a/published/20171117 How to Easily Remember Linux Commands.md b/published/201711/20171117 How to Easily Remember Linux Commands.md similarity index 100% rename from published/20171117 How to Easily Remember Linux Commands.md rename to published/201711/20171117 How to Easily Remember Linux Commands.md diff --git a/published/20171118 Getting started with OpenFaaS on minikube.md b/published/201711/20171118 Getting started with OpenFaaS on minikube.md similarity index 100% rename from published/20171118 Getting started with OpenFaaS on minikube.md rename to published/201711/20171118 Getting started with OpenFaaS on minikube.md diff --git a/published/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md b/published/201711/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md similarity index 100% rename from published/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md rename to published/201711/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md diff --git a/published/20171120 Containers and Kubernetes Whats next.md b/published/20171120 Containers and Kubernetes Whats next.md new file mode 100644 index 0000000000..57f9379f7b --- /dev/null +++ b/published/20171120 Containers and Kubernetes Whats next.md @@ -0,0 +1,81 @@ +容器技术和 K8S 的下一站 +============================================================ +> 想知道容器编排管理和 K8S 的最新展望么?来看看专家怎么说。 + +![CIO_Big Data Decisions_2](https://enterprisersproject.com/sites/default/files/styles/620x350/public/images/CIO_Big%20Data%20Decisions_2.png?itok=Y5zMHxf8 "CIO_Big Data Decisions_2") + +如果你想对容器在未来的发展方向有一个整体把握,那么你一定要跟着钱走,看看钱都投在了哪里。当然了,有很多很多的钱正在投入容器的进一步发展。相关研究预计 2020 年容器技术的投入将占有 [27 亿美元][4] 的市场份额。而在 2016 年,容器相关技术投入的总额为 7.62 亿美元,只有 2020 年投入预计的三分之一。巨额投入的背后是一些显而易见的基本因素,包括容器化的迅速增长以及并行化的大趋势。随着容器被大面积推广和使用,容器编排管理也会被理所当然的推广应用起来。 + +来自 [The new stack][5] 的调研数据表明,容器的推广使用是编排管理被推广的主要的催化剂。根据调研参与者的反馈数据,在已经将容器技术使用到生产环境中的使用者里,有六成使用者正在将 Kubernetes(K8S)编排管理广泛的应用在生产环境中,另外百分之十九的人员则表示他们已经处于部署 K8S 的初级阶段。在容器部署初期的使用者当中,虽然只有百分之五的人员表示已经在使用 K8S ,但是百分之五十八的人员表示他们正在计划和准备使用 K8S。总而言之,容器和 Kubernetes 的关系就好比是鸡和蛋一样,相辅相成紧密关联。众多专家一致认为编排管理工具对容器的[长周期管理][6] 以及其在市场中的发展有至关重要的作用。正如 [Cockroach 实验室][7] 的 Alex Robinson 所说,容器编排管理被更广泛的拓展和应用是一个总体的大趋势。毫无疑问,这是一个正在快速演变的领域,且未来潜力无穷。鉴于此,我们对 Robinson 和其他的一些容器的实际使用和推介者做了采访,来从他们作为容器技术的践行者的视角上展望一下容器编排以及 K8S 的下一步发展。 + +### 容器编排将被主流接受 + +像任何重要技术的转型一样,我们就像是处在一个高崖之上一般,在经过了初期步履蹒跚的跋涉之后将要来到一望无际的广袤平原。广大的新天地和平实真切的应用需求将会让这种新技术在主流应用中被迅速推广,尤其是在大企业环境中。正如 Alex Robinson 说的那样,容器技术的淘金阶段已经过去,早期的技术革新创新正在减速,随之而来的则是市场对容器技术的稳定性和可用性的强烈需求。这意味着未来我们将不会再见到大量的新的编排管理系统的涌现,而是会看到容器技术方面更多的安全解决方案,更丰富的管理工具,以及基于目前主流容器编排系统的更多的新特性。 + +### 更好的易用性 + +人们将在简化容器的部署方面下大功夫,因为容器部署的初期工作对很多公司和组织来说还是比较复杂的,尤其是容器的[长期管理维护][8]更是需要投入大量的精力。正如 [Codemill AB][9] 公司的 My Karlsson 所说,容器编排技术还是太复杂了,这导致很多使用者难以娴熟驾驭和充分利用容器编排的功能。很多容器技术的新用户都需要花费很多精力,走很多弯路,才能搭建小规模的或单个的以隔离方式运行的容器系统。这种现象在那些没有针对容器技术设计和优化的应用中更为明显。在简化容器编排管理方面有很多优化可以做,这些优化和改造将会使容器技术更加具有可用性。 + +### 在混合云以及多云技术方面会有更多侧重 + +随着容器和容器编排技术被越来越多的使用,更多的组织机构会选择扩展他们现有的容器技术的部署,从之前的把非重要系统部署在单一环境的使用情景逐渐过渡到更加[复杂的使用情景][10]。对很多公司来说,这意味着他们必须开始学会在 [混合云][11] 和 [多云][12] 的环境下,全局化的去管理那些容器化的应用和微服务。正如红帽 [Openshift 部门产品战略总监][14] [Brian Gracely][13] 所说,“容器和 K8S 技术的使用使得我们成功的实现了混合云以及应用的可移植性。结合 Open Service Broker API 的使用,越来越多的结合私有云和公有云资源的新应用将会涌现出来。” +据 [CloudBees][15] 公司的高级工程师 Carlos Sanchez 分析,联合服务(Federation)将会得到极大推动,使一些诸如多地区部署和多云部署等的备受期待的新特性成为可能。 + +**[ 想知道 CIO 们对混合云和多云的战略构想么? 请参看我们的这条相关资源, [Hybrid Cloud: The IT leader's guide][16]。 ]** + +### 平台和工具的持续整合及加强 + +对任何一种科技来说,持续的整合和加强从来都是大势所趋;容器编排管理技术在这方面也不例外。来自 [Sumo Logic][17] 的首席分析师 Ben Newton 表示,随着容器化渐成主流,软件工程师们正在很少数的一些技术上做持续整合加固的工作,来满足他们的一些微应用的需求。容器和 K8S 将会毫无疑问的成为容器编排管理方面的主流平台,并轻松碾压其它的一些小众平台方案。因为 K8S 提供了一个相当清晰的可以摆脱各种特有云生态的途径,K8S 将被大量公司使用,逐渐形成一个不依赖于某个特定云服务的“中立云”cloud-neutral。 + +### K8S 的下一站 + +来自 [Alcide][18] 的 CTO 和联合创始人 Gadi Naor 表示,K8S 将会是一个有长期和远景发展的技术,虽然我们的社区正在大力推广和发展 K8S,K8S 仍有很长的路要走。 + +专家们对[日益流行的 K8S 平台][19]也作出了以下一些预测: + +**_来自 Alcide 的 Gadi Naor 表示:_** “运营商会持续演进并趋于成熟,直到在 K8S 上运行的应用可以完全自治。利用 [OpenTracing][20] 和诸如 [istio][21] 技术的 service mesh 架构,在 K8S 上部署和监控微应用将会带来很多新的可能性。” + +**_来自 Red Hat 的 Brian Gracely 表示:_** “K8S 所支持的应用的种类越来越多。今后在 K8S 上,你不仅可以运行传统的应用程序,还可以运行原生的云应用、大数据应用以及 HPC 或者基于 GPU 运算的应用程序,这将为灵活的架构设计带来无限可能。” + +**_来自 Sumo Logic 的 Ben Newton 表示:_** “随着 K8S 成为一个具有统治地位的平台,我预计更多的操作机制将会被统一化,尤其是 K8S 将和第三方管理和监控平台融合起来。” + +**_来自 CloudBees 的 Carlos Sanchez 表示:_** “在不久的将来我们就能看到不依赖于 Docker 而使用其它运行时环境的系统,这将会有助于消除任何可能的 lock-in 情景“ [编辑提示:[CRI-O][22] 就是一个可以借鉴的例子。]“而且我期待将来会出现更多的针对企业环境的存储服务新特性,包括数据快照以及在线的磁盘容量的扩展。” + +**_来自 Cockroach Labs 的 Alex Robinson 表示:_** “ K8S 社区正在讨论的一个重大发展议题就是加强对[有状态程序][23]的管理。目前在 K8S 平台下,实现状态管理仍然非常困难,除非你所使用的云服务商可以提供远程固定磁盘。现阶段也有很多人在多方面试图改善这个状况,包括在 K8S 平台内部以及在外部服务商一端做出的一些改进。” + +------------------------------------------------------------------------------- + +via: https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next + +作者:[Kevin Casey][a] +译者:[yunfengHe](https://github.com/yunfengHe) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://enterprisersproject.com/user/kevin-casey +[1]:https://enterprisersproject.com/article/2017/11/kubernetes-numbers-10-compelling-stats +[2]:https://enterprisersproject.com/article/2017/11/how-enterprise-it-uses-kubernetes-tame-container-complexity +[3]:https://enterprisersproject.com/article/2017/11/5-kubernetes-success-tips-start-smart?sc_cid=70160000000h0aXAAQ +[4]:https://451research.com/images/Marketing/press_releases/Application-container-market-will-reach-2-7bn-in-2020_final_graphic.pdf +[5]:https://thenewstack.io/ +[6]:https://enterprisersproject.com/article/2017/10/microservices-and-containers-6-management-tips-long-haul +[7]:https://www.cockroachlabs.com/ +[8]:https://enterprisersproject.com/article/2017/10/microservices-and-containers-6-management-tips-long-haul +[9]:https://codemill.se/ +[10]:https://www.redhat.com/en/challenges/integration?intcmp=701f2000000tjyaAAA +[11]:https://enterprisersproject.com/hybrid-cloud +[12]:https://enterprisersproject.com/article/2017/7/multi-cloud-vs-hybrid-cloud-whats-difference +[13]:https://enterprisersproject.com/user/brian-gracely +[14]:https://www.redhat.com/en +[15]:https://www.cloudbees.com/ +[16]:https://enterprisersproject.com/hybrid-cloud?sc_cid=70160000000h0aXAAQ +[17]:https://www.sumologic.com/ +[18]:http://alcide.io/ +[19]:https://enterprisersproject.com/article/2017/10/how-explain-kubernetes-plain-english +[20]:http://opentracing.io/ +[21]:https://istio.io/ +[22]:http://cri-o.io/ +[23]:https://opensource.com/article/17/2/stateful-applications +[24]:https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next?rate=PBQHhF4zPRHcq2KybE1bQgMkS2bzmNzcW2RXSVItmw8 +[25]:https://enterprisersproject.com/user/kevin-casey diff --git a/published/20171124 How to Install Android File Transfer for Linux.md b/published/20171124 How to Install Android File Transfer for Linux.md new file mode 100644 index 0000000000..3cdb372c93 --- /dev/null +++ b/published/20171124 How to Install Android File Transfer for Linux.md @@ -0,0 +1,75 @@ +如何在 Linux 下安装安卓文件传输助手 +=============== + +如果你尝试在 Ubuntu 下连接你的安卓手机,你也许可以试试 Linux 下的安卓文件传输助手。 + +本质上来说,这个应用是谷歌 macOS 版本的一个克隆。它是用 Qt 编写的,用户界面非常简洁,使得你能轻松在 Ubuntu 和安卓手机之间传输文件和文件夹。 + +现在,有可能一部分人想知道有什么是这个应用可以做,而 Nautilus(Ubuntu 默认的文件资源管理器)不能做的,答案是没有。 + +当我将我的 Nexus 5X(记得选择 [媒体传输协议 MTP][7] 选项)连接在 Ubuntu 上时,在 [GVfs][8](LCTT 译注: GNOME 桌面下的虚拟文件系统)的帮助下,我可以打开、浏览和管理我的手机,就像它是一个普通的 U 盘一样。 + +[![Nautilus MTP integration with a Nexus 5X](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg)][9] + +但是*一些*用户在使用默认的文件管理器时,在 MTP 的某些功能上会出现问题:比如文件夹没有正确加载,创建新文件夹后此文件夹不存在,或者无法在媒体播放器中使用自己的手机。 + +这就是要为 Linux 系统用户设计一个安卓文件传输助手应用的原因,将这个应用当做将 MTP 设备安装在 Linux 下的另一种选择。如果你使用 Linux 下的默认应用时一切正常,你也许并不需要尝试使用它 (除非你真的很想尝试新鲜事物)。 + + +![Android File Transfer Linux App](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/android-file-transfer-for-linux-750x662.jpg) + +该 app 特点: + +*   简洁直观的用户界面 +*   支持文件拖放功能(从 Linux 系统到手机) +*   支持批量下载 (从手机到 Linux系统) +*   显示传输进程对话框 +*   FUSE 模块支持 +*   没有文件大小限制 +*   可选命令行工具 + +### Ubuntu 下安装安卓手机文件助手的步骤 + +以上就是对这个应用的介绍,下面是如何安装它的具体步骤。 + +这有一个 [PPA](个人软件包集)源为 Ubuntu 14.04 LTS、16.04 LTS 和 Ubuntu 17.10 提供可用应用。 + +为了将这一 PPA 加入你的软件资源列表中,执行这条命令: + +``` +sudo add-apt-repository ppa:samoilov-lex/aftl-stable +``` + +接着,为了在 Ubuntu 下安装 Linux版本的安卓文件传输助手,执行: + +``` +sudo apt-get update && sudo apt install android-file-transfer +``` + +这样就行了。 + +你会在你的应用列表中发现这一应用的启动图标。 + +在你启动这一应用之前,要确保没有其他应用(比如 Nautilus)已经挂载了你的手机。如果其它应用正在使用你的手机,就会显示“无法找到 MTP 设备”。要解决这一问题,将你的手机从 Nautilus(或者任何正在使用你的手机的应用)上移除,然后再重新启动安卓文件传输助手。 + +-------------------------------------------------------------------------------- + +via: http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux + +作者:[JOEY SNEDDON][a] +译者:[wenwensnow](https://github.com/wenwensnow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://plus.google.com/117485690627814051450/?rel=author +[1]:https://plus.google.com/117485690627814051450/?rel=author +[2]:http://www.omgubuntu.co.uk/category/app +[3]:http://www.omgubuntu.co.uk/category/download +[4]:https://github.com/whoozle/android-file-transfer-linux +[5]:http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux +[6]:http://android.com/filetransfer?linkid=14270770 +[7]:https://en.wikipedia.org/wiki/Media_Transfer_Protocol +[8]:https://en.wikipedia.org/wiki/GVfs +[9]:http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg +[10]:https://launchpad.net/~samoilov-lex/+archive/ubuntu/aftl-stable diff --git a/published/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md b/published/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md new file mode 100644 index 0000000000..9b6a4f242c --- /dev/null +++ b/published/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md @@ -0,0 +1,72 @@ +开源云技能认证:系统管理员的核心竞争力 +========= + +![os jobs](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/open-house-sysadmin.jpg?itok=i5FHc3lu "os jobs") + +> [2017年开源工作报告][1](以下简称“报告”)显示,具有开源云技术认证的系统管理员往往能获得更高的薪酬。 + + +报告调查的受访者中,53% 认为系统管理员是雇主们最期望被填补的职位空缺之一,因此,技术娴熟的系统管理员更受青睐而收获高薪职位,但这一职位,并没想象中那么容易填补。 + +系统管理员主要负责服务器和其他电脑操作系统的安装、服务支持和维护,及时处理服务中断和预防其他问题的出现。 + +总的来说,今年的报告指出开源领域人才需求最大的有开源云(47%),应用开发(44%),大数据(43%),开发运营和安全(42%)。 + +此外,报告对人事经理的调查显示,58% 期望招揽更多的开源人才,67% 认为开源人才的需求增长会比业内其他领域更甚。有些单位视开源人才为招聘最优选则,它们招聘的开源人才较上年增长了 2 个百分点。 + +同时,89% 的人事经理认为很难找到颇具天赋的开源人才。 + +### 为什么要获取认证 + +报告显示,对系统管理员的需求刺激着人事经理为 53% 的组织/机构提供正规的培训和专业技术认证,而这一比例去年为 47%。 + +对系统管理方面感兴趣的 IT 人才考虑获取 Linux 认证已成为行业规律。随便查看几个知名的招聘网站,你就能发现:[CompTIA Linux+][3] 认证是入门级 Linux 系统管理员的最高认证;如果想胜任高级别的系统管理员职位,获取[红帽认证工程师(RHCE)][4]和[红帽认证系统管理员(RHCSA)][5]则是不可或缺的。 + +戴士(Dice)[2017 技术行业薪资调查][6]显示,2016 年系统管理员的薪水为 79,538 美元,较上年下降了 0.8%;系统架构师的薪水为 125,946 美元,同比下降 4.7%。尽管如此,该调查发现“高水平专业人才仍最受欢迎,特别是那些精通支持产业转型发展所需技术的人才”。 + +在开源技术方面,HBase(一个开源的分布式数据库)技术人才的薪水在戴士 2017 技术行业薪资调查中排第一。在计算机网络和数据库领域,掌握 OpenVMS 操作系统技术也能获得高薪。 + +### 成为出色的系统管理员 + +出色的系统管理员须在问题出现时马上处理,这意味着你必须时刻准备应对可能出现的状况。这个职位追求“零责备的、精益的、流程或技术上交互式改进的”思维方式和善于自我完善的人格,成为一个系统管理员意味着“你必将与开源软件如 Linux、BSD 甚至开源 Solaris 等结下不解之缘”,Paul English ^译注1 在 [opensource.com][7] 上发文指出。 + +Paul English 认为,现在的系统管理员较以前而言,要更多地与软件打交道,而且要能够编写脚本来协助系统管理。 + +>译注1:Paul English,计算机科学学士,UNIX/Linux 系统管理员,PreOS Security Inc. 公司 CEO,2015-2017 年于为推动系统管理员发展实践的非盈利组织——专业系统管理员联盟League of Professional System Administrator担任董事会成员。 + +### 展望 2018 + +[Robert Half 2018 年技术人才薪资导览][8]预测 2018 年北美地区许多单位将聘用大量系统管理方面的专业人才,同时个人软实力和领导力水平作为优秀人才的考量因素,越来越受到重视。 + +该报告指出:“良好的聆听能力和批判性思维能力对于理解和解决用户的问题和担忧至关重要,也是 IT 从业者必须具备的重要技能,特别是从事服务台和桌面支持工作相关的技术人员。” + +这与[Linux基金会][9]^译注2 提出的不同阶段的系统管理员必备技能相一致,都强调了强大的分析能力和快速处理问题的能力。 + +>译注2:Linux 基金会The Linux Foundation,成立于 2000 年,致力于围绕开源项目构建可持续发展的生态系统,以加速开源项目的技术开发和商业应用;它是世界上最大的开源非盈利组织,在推广、保护和推进 Linux 发展,协同开发,维护“历史上最大的共享资源”上功勋卓越。 + +如果想逐渐爬上系统管理员职位的金字塔上层,还应该对系统配置的结构化方法充满兴趣;且拥有解决系统安全问题的经验;用户身份验证管理的经验;与非技术人员进行非技术交流的能力;以及优化系统以满足最新的安全需求的能力。 + +- [下载][10]2017年开源工作报告全文,以获取更多信息。 + + +----------------------- + +via: https://www.linux.com/blog/open-source-cloud-skills-and-certification-are-key-sysadmins + +作者:[linux.com][a] +译者:[wangy325](https://github.com/wangy325) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/blog/open-source-cloud-skills-and-certification-are-key-sysadmins +[1]:https://www.linuxfoundation.org/blog/2017-jobs-report-highlights-demand-open-source-skills/ +[2]:https://www.linux.com/licenses/category/creative-commons-zero +[3]:https://certification.comptia.org/certifications/linux?tracking=getCertified/certifications/linux.aspx +[4]:https://www.redhat.com/en/services/certification/rhce +[5]:https://www.redhat.com/en/services/certification/rhcsa +[6]:http://marketing.dice.com/pdf/Dice_TechSalarySurvey_2017.pdf?aliId=105832232 +[7]:https://opensource.com/article/17/7/truth-about-sysadmins +[8]:https://www.roberthalf.com/salary-guide/technology +[9]:https://www.linux.com/learn/10-essential-skills-novice-junior-and-senior-sysadmins%20%20 +[10]:http://bit.ly/2017OSSjobsreport \ No newline at end of file diff --git a/published/20171130 Search DuckDuckGo from the Command Line.md b/published/20171130 Search DuckDuckGo from the Command Line.md new file mode 100644 index 0000000000..48b6fdd830 --- /dev/null +++ b/published/20171130 Search DuckDuckGo from the Command Line.md @@ -0,0 +1,97 @@ +在命令行中使用 DuckDuckGo 搜索 +============= + +![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/duckduckgo.png) + +此前我们介绍了[如何在命令行中使用 Google 搜索][3]。许多读者反馈说他们平时使用 [Duck Duck Go][4],这是一个功能强大而且保密性很强的搜索引擎。 + +正巧,最近出现了一款能够从命令行搜索 DuckDuckGo 的工具。它叫做 ddgr(我把它读作 “dodger”),非常好用。 + +像 [Googler][7] 一样,ddgr 是一个完全开源而且非官方的工具。没错,它并不属于 DuckDuckGo。所以,如果你发现它返回的结果有些奇怪,请先询问这个工具的开发者,而不是搜索引擎的开发者。 + +### DuckDuckGo 命令行应用 + +![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/ddgr-gif.gif) + +[DuckDuckGo Bangs(DuckDuckGo 快捷搜索)][8] 可以帮助你轻易地在 DuckDuckGo 上找到想要的信息(甚至 _本网站 omgubuntu_ 都有快捷搜索)。ddgr 非常忠实地呈现了这个功能。 + +和网页版不同的是,你可以更改每页返回多少结果。这比起每次查询都要看三十多条结果要方便一些。默认界面经过了精心设计,在不影响可读性的情况下尽量减少了占用空间。 + +`ddgr` 有许多功能和亮点,包括: + +* 更改搜索结果数 +* 支持 Bash 自动补全 +* 使用 DuckDuckGo Bangs +* 在浏览器中打开链接 +* ”手气不错“选项 +* 基于时间、地区、文件类型等的筛选功能 +* 极少的依赖项 + +你可以从 Github 的项目页面上下载支持各种系统的 `ddgr`: + +- [从 Github 下载 “ddgr”][9] + +另外,在 Ubuntu 16.04 LTS 或更新版本中,你可以使用 PPA 安装 ddgr。这个仓库由 ddgr 的开发者维护。如果你想要保持在最新版本的话,推荐使用这种方式安装。 + +需要提醒的是,在本文创作时,这个 PPA 中的 ddgr _并不是_ 最新版本,而是一个稍旧的版本(缺少 -num 选项)。 + +使用以下命令添加 PPA: + +``` +sudo add-apt-repository ppa:twodopeshaggy/jarun +sudo apt-get update +``` + +### 如何使用 ddgr 在命令行中搜索 DuckDuckGo + +安装完毕后,你只需打开你的终端模拟器,并运行: + +``` +ddgr +``` + +然后输入查询内容: + +``` +search-term +``` + +你可以限制搜索结果数: + +``` +ddgr --num 5 search-term +``` + +或者自动在浏览器中打开第一条搜索结果: + + +``` +ddgr -j search-term +``` + +你可以使用参数和选项来提高搜索精确度。使用以下命令来查看所有的参数: + +``` +ddgr -h +``` + +-------------------------------------------------------------------------------- + +via: http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app + +作者:[JOEY SNEDDON][a] +译者:[yixunx](https://github.com/yixunx) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://plus.google.com/117485690627814051450/?rel=author +[1]:https://plus.google.com/117485690627814051450/?rel=author +[2]:http://www.omgubuntu.co.uk/category/download +[3]:http://www.omgubuntu.co.uk/2017/08/search-google-from-the-command-line +[4]:http://duckduckgo.com/ +[5]:http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app +[6]:https://github.com/jarun/ddgr +[7]:https://github.com/jarun/googler +[8]:https://duckduckgo.com/bang +[9]:https://github.com/jarun/ddgr/releases/tag/v1.1 diff --git a/sources/tech/20090701 The One in Which I Call Out Hacker News.md b/sources/tech/20090701 The One in Which I Call Out Hacker News.md deleted file mode 100644 index 44c751dd5a..0000000000 --- a/sources/tech/20090701 The One in Which I Call Out Hacker News.md +++ /dev/null @@ -1,86 +0,0 @@ -translating by hopefully2333 - -# [The One in Which I Call Out Hacker News][14] - - -> “Implementing caching would take thirty hours. Do you have thirty extra hours? No, you don’t. I actually have no idea how long it would take. Maybe it would take five minutes. Do you have five minutes? No. Why? Because I’m lying. It would take much longer than five minutes. That’s the eternal optimism of programmers.” -> -> — Professor [Owen Astrachan][1] during 23 Feb 2004 lecture for [CPS 108][2] - -[Accusing open-source software of being a royal pain to use][5] is not a new argument; it’s been said before, by those much more eloquent than I, and even by some who are highly sympathetic to the open-source movement. Why go over it again? - -On Hacker News on Monday, I was amused to read some people saying that [writing StackOverflow was hilariously easy][6]—and proceeding to back up their claim by [promising to clone it over July 4th weekend][7]. Others chimed in, pointing to [existing][8] [clones][9] as a good starting point. - -Let’s assume, for sake of argument, that you decide it’s okay to write your StackOverflow clone in ASP.NET MVC, and that I, after being hypnotized with a pocket watch and a small club to the head, have decided to hand you the StackOverflow source code, page by page, so you can retype it verbatim. We’ll also assume you type like me, at a cool 100 WPM ([a smidge over eight characters per second][10]), and unlike me,  _you_  make zero mistakes. StackOverflow’s *.cs, *.sql, *.css, *.js, and *.aspx files come to 2.3 MB. So merely typing the source code back into the computer will take you about eighty hours if you make zero mistakes. - -Except, of course, you’re not doing that; you’re going to implement StackOverflow from scratch. So even assuming that it took you a mere ten times longer to design, type out, and debug your own implementation than it would take you to copy the real one, that already has you coding for several weeks straight—and I don’t know about you, but I am okay admitting I write new code  _considerably_  less than one tenth as fast as I copy existing code. - - _Well, okay_ , I hear you relent. *So not the whole thing. But I can do **most** of it.* - -Okay, so what’s “most”? There’s simply asking and responding to questions—that part’s easy. Well, except you have to implement voting questions and answers up and down, and the questioner should be able to accept a single answer for each question. And you can’t let people upvote or accept their own answers, so you need to block that. And you need to make sure that users don’t upvote or downvote another user too many times in a certain amount of time, to prevent spambots. Probably going to have to implement a spam filter, too, come to think of it, even in the basic design, and you also need to support user icons, and you’re going to have to find a sanitizing HTML library you really trust and that interfaces well with Markdown (provided you do want to reuse [that awesome editor][11] StackOverflow has, of course). You’ll also need to purchase, design, or find widgets for all the controls, plus you need at least a basic administration interface so that moderators can moderate, and you’ll need to implement that scaling karma thing so that you give users steadily increasing power to do things as they go. - -But if you do  _all that_ , you  _will_  be done. - -Except…except, of course, for the full-text search, especially its appearance in the search-as-you-ask feature, which is kind of indispensable. And user bios, and having comments on answers, and having a main page that shows you important questions but that bubbles down steadily à la reddit. Plus you’ll totally need to implement bounties, and support multiple OpenID logins per user, and send out email notifications for pertinent events, and add a tagging system, and allow administrators to configure badges by a nice GUI. And you’ll need to show users’ karma history, upvotes, and downvotes. And the whole thing has to scale really well, since it could be slashdotted/reddited/StackOverflown at any moment. - -But  _then_ ! **Then** you’re done! - -…right after you implement upgrades, internationalization, karma caps, a CSS design that makes your site not look like ass, AJAX versions of most of the above, and G-d knows what else that’s lurking just beneath the surface that you currently take for granted, but that will come to bite you when you start to do a real clone. - -Tell me: which of those features do you feel you can cut and still have a compelling offering? Which ones go under “most” of the site, and which can you punt? - -Developers think cloning a site like StackOverflow is easy for the same reason that open-source software remains such a horrible pain in the ass to use. When you put a developer in front of StackOverflow, they don’t really  _see_ StackOverflow. What they actually  _see_  is this: - -``` -create table QUESTION (ID identity primary key, - TITLE varchar(255), --- why do I know you thought 255? - BODY text, - UPVOTES integer not null default 0, - DOWNVOTES integer not null default 0, - USER integer references USER(ID)); -create table RESPONSE (ID identity primary key, - BODY text, - UPVOTES integer not null default 0, - DOWNVOTES integer not null default 0, - QUESTION integer references QUESTION(ID)) -``` - -If you then tell a developer to replicate StackOverflow, what goes into his head are the above two SQL tables and enough HTML to display them without formatting, and that really  _is_  completely doable in a weekend. The smarter ones will realize that they need to implement login and logout, and comments, and that the votes need to be tied to a user, but that’s still totally doable in a weekend; it’s just a couple more tables in a SQL back-end, and the HTML to show their contents. Use a framework like Django, and you even get basic users and comments for free. - -But that’s  _not_  what StackOverflow is about. Regardless of what your feelings may be on StackOverflow in general, most visitors seem to agree that the user experience is smooth, from start to finish. They feel that they’re interacting with a polished product. Even if I didn’t know better, I would guess that very little of what actually makes StackOverflow a continuing success has to do with the database schema—and having had a chance to read through StackOverflow’s source code, I know how little really does. There is a  _tremendous_  amount of spit and polish that goes into making a major website highly usable. A developer, asked how hard something will be to clone, simply  _does not think about the polish_ , because  _the polish is incidental to the implementation._ - -That is why an open-source clone of StackOverflow will fail. Even if someone were to manage to implement most of StackOverflow “to spec,” there are some key areas that would trip them up. Badges, for example, if you’re targeting end-users, either need a GUI to configure rules, or smart developers to determine which badges are generic enough to go on all installs. What will actually happen is that the developers will bitch and moan about how you can’t implement a really comprehensive GUI for something like badges, and then bikeshed any proposals for standard badges so far into the ground that they’ll hit escape velocity coming out the other side. They’ll ultimately come up with the same solution that bug trackers like Roundup use for their workflow: the developers implement a generic mechanism by which anyone, truly anyone at all, who feels totally comfortable working with the system API in Python or PHP or whatever, can easily add their own customizations. And when PHP and Python are so easy to learn and so much more flexible than a GUI could ever be, why bother with anything else? - -Likewise, the moderation and administration interfaces can be punted. If you’re an admin, you have access to the SQL server, so you can do anything really genuinely administrative-like that way. Moderators can get by with whatever django-admin and similar systems afford you, since, after all, few users are mods, and mods should understand how the sites  _work_ , dammit. And, certainly, none of StackOverflow’s interface failings will be rectified. Even if StackOverflow’s stupid requirement that you have to have and know how to use an OpenID (its worst failing) eventually gets fixed, I’m sure any open-source clones will rabidly follow it—just as GNOME and KDE for years slavishly copied off Windows, instead of trying to fix its most obvious flaws. - -Developers may not care about these parts of the application, but end-users do, and take it into consideration when trying to decide what application to use. Much as a good software company wants to minimize its support costs by ensuring that its products are top-notch before shipping, so, too, savvy consumers want to ensure products are good before they purchase them so that they won’t  _have_  to call support. Open-source products fail hard here. Proprietary solutions, as a rule, do better. - -That’s not to say that open-source doesn’t have its place. This blog runs on Apache, [Django][12], [PostgreSQL][13], and Linux. But let me tell you, configuring that stack is  _not_  for the faint of heart. PostgreSQL needs vacuuming configured on older versions, and, as of recent versions of Ubuntu and FreeBSD, still requires the user set up the first database cluster. MS SQL requires neither of those things. Apache…dear heavens, don’t even get me  _started_  on trying to explain to a novice user how to get virtual hosting, MovableType, a couple Django apps, and WordPress all running comfortably under a single install. Hell, just trying to explain the forking vs. threading variants of Apache to a technically astute non-developer can be a nightmare. IIS 7 and Apache with OS X Server’s very much closed-source GUI manager make setting up those same stacks vastly simpler. Django’s a great a product, but it’s nothing  _but_  infrastructure—exactly the thing that I happen to think open-source  _does_  do well,  _precisely_  because of the motivations that drive developers to contribute. - -The next time you see an application you like, think very long and hard about all the user-oriented details that went into making it a pleasure to use, before decrying how you could trivially reimplement the entire damn thing in a weekend. Nine times out of ten, when you think an application was ridiculously easy to implement, you’re completely missing the user side of the story. - --------------------------------------------------------------------------------- - -via: https://bitquabit.com/post/one-which-i-call-out-hacker-news/ - -作者:[Benjamin Pollack][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://bitquabit.com/meta/about/ -[1]:http://www.cs.duke.edu/~ola/ -[2]:http://www.cs.duke.edu/courses/cps108/spring04/ -[3]:https://bitquabit.com/categories/programming -[4]:https://bitquabit.com/categories/technology -[5]:http://blog.bitquabit.com/2009/06/30/one-which-i-say-open-source-software-sucks/ -[6]:http://news.ycombinator.com/item?id=678501 -[7]:http://news.ycombinator.com/item?id=678704 -[8]:http://code.google.com/p/cnprog/ -[9]:http://code.google.com/p/soclone/ -[10]:http://en.wikipedia.org/wiki/Words_per_minute -[11]:http://github.com/derobins/wmd/tree/master -[12]:http://www.djangoproject.com/ -[13]:http://www.postgresql.org/ -[14]:https://bitquabit.com/post/one-which-i-call-out-hacker-news/ diff --git a/sources/tech/20130402 Dynamic linker tricks Using LD_PRELOAD to cheat inject features and investigate programs.md b/sources/tech/20130402 Dynamic linker tricks Using LD_PRELOAD to cheat inject features and investigate programs.md new file mode 100644 index 0000000000..2329fadd41 --- /dev/null +++ b/sources/tech/20130402 Dynamic linker tricks Using LD_PRELOAD to cheat inject features and investigate programs.md @@ -0,0 +1,211 @@ +# Dynamic linker tricks: Using LD_PRELOAD to cheat, inject features and investigate programs + +**This post assumes some basic C skills.** + +Linux puts you in full control. This is not always seen from everyone’s perspective, but a power user loves to be in control. I’m going to show you a basic trick that lets you heavily influence the behavior of most applications, which is not only fun, but also, at times, useful. + +#### A motivational example + +Let us begin with a simple example. Fun first, science later. + + +random_num.c: +``` +#include +#include +#include + +int main(){ + srand(time(NULL)); + int i = 10; + while(i--) printf("%d\n",rand()%100); + return 0; +} +``` + +Simple enough, I believe. I compiled it with no special flags, just + +> ``` +> gcc random_num.c -o random_num +> ``` + +I hope the resulting output is obvious – ten randomly selected numbers 0-99, hopefully different each time you run this program. + +Now let’s pretend we don’t really have the source of this executable. Either delete the source file, or move it somewhere – we won’t need it. We will significantly modify this programs behavior, yet without touching it’s source code nor recompiling it. + +For this, lets create another simple C file: + + +unrandom.c: +``` +int rand(){ + return 42; //the most random number in the universe +} +``` + +We’ll compile it into a shared library. + +> ``` +> gcc -shared -fPIC unrandom.c -o unrandom.so +> ``` + +So what we have now is an application that outputs some random data, and a custom library, which implements the rand() function as a constant value of 42\.  Now… just run  _random_num _ this way, and watch the result: + +> ``` +> LD_PRELOAD=$PWD/unrandom.so ./random_nums +> ``` + +If you are lazy and did not do it yourself (and somehow fail to guess what might have happened), I’ll let you know – the output consists of ten 42’s. + +This may be even more impressive it you first: + +> ``` +> export LD_PRELOAD=$PWD/unrandom.so +> ``` + +and then run the program normally. An unchanged app run in an apparently usual manner seems to be affected by what we did in our tiny library… + +###### **Wait, what? What did just happen?** + +Yup, you are right, our program failed to generate random numbers, because it did not use the “real” rand(), but the one we provided – which returns 42 every time. + +###### **But we *told* it to use the real one. We programmed it to use the real one. Besides, at the time we created that program, the fake rand() did not even exist!** + +This is not entirely true. We did not choose which rand() we want our program to use. We told it just to use rand(). + +When our program is started, certain libraries (that provide functionality needed by the program) are loaded. We can learn which are these using  _ldd_ : + +> ``` +> $ ldd random_nums +> linux-vdso.so.1 => (0x00007fff4bdfe000) +> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f48c03ec000) +> /lib64/ld-linux-x86-64.so.2 (0x00007f48c07e3000) +> ``` + +What you see as the output is the list of libs that are needed by  _random_nums_ . This list is built into the executable, and is determined compile time. The exact output might slightly differ on your machine, but a **libc.so** must be there – this is the file which provides core C functionality. That includes the “real” rand(). + +We can have a peek at what functions does libc provide. I used the following to get a full list: + +> ``` +> nm -D /lib/libc.so.6 +> ``` + +The  _nm_  command lists symbols found in a binary file. The -D flag tells it to look for dynamic symbols, which makes sense, as libc.so.6 is a dynamic library. The output is very long, but it indeed lists rand() among many other standard functions. + +Now what happens when we set up the environmental variable LD_PRELOAD? This variable **forces some libraries to be loaded for a program**. In our case, it loads  _unrandom.so_  for  _random_num_ , even though the program itself does not ask for it. The following command may be interesting: + +> ``` +> $ LD_PRELOAD=$PWD/unrandom.so ldd random_nums +> linux-vdso.so.1 => (0x00007fff369dc000) +> /some/path/to/unrandom.so (0x00007f262b439000) +> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f262b044000) +> /lib64/ld-linux-x86-64.so.2 (0x00007f262b63d000) +> ``` + +Note that it lists our custom library. And indeed this is the reason why it’s code get’s executed:  _random_num_  calls rand(), but if  _unrandom.so_  is loaded it is our library that provides implementation for rand(). Neat, isn’t it? + +#### Being transparent + +This is not enough. I’d like to be able to inject some code into an application in a similar manner, but in such way that it will be able to function normally. It’s clear if we implemented open() with a simple “ _return 0;_ “, the application we would like to hack should malfunction. The point is to be **transparent**, and to actually call the original open: + +inspect_open.c: +``` +int open(const char *pathname, int flags){ + /* Some evil injected code goes here. */ + return open(pathname,flags); // Here we call the "real" open function, that is provided to us by libc.so +} +``` + +Hm. Not really. This won’t call the “original” open(…). Obviously, this is an endless recursive call. + +How do we access the “real” open function? It is needed to use the programming interface to the dynamic linker. It’s simpler than it sounds. Have a look at this complete example, and then I’ll explain what happens there: + +inspect_open.c: + +``` +#define _GNU_SOURCE +#include + +typedef int (*orig_open_f_type)(const char *pathname, int flags); + +int open(const char *pathname, int flags, ...) +{ + /* Some evil injected code goes here. */ + + orig_open_f_type orig_open; + orig_open = (orig_open_f_type)dlsym(RTLD_NEXT,"open"); + return orig_open(pathname,flags); +} +``` + +The  _dlfcn.h_  is needed for  _dlsym_  function we use later. That strange  _#define_  directive instructs the compiler to enable some non-standard stuff, we need it to enable  _RTLD_NEXT_  in  _dlfcn.h_ . That typedef is just creating an alias to a complicated pointer-to-function type, with arguments just as the original open – the alias name is  _orig_open_f_type_ , which we’ll use later. + +The body of our custom open(…) consists of some custom code. The last part of it creates a new function pointer  _orig_open_  which will point to the original open(…) function. In order to get the address of that function, we ask  _dlsym_  to find for us the next “open” function on dynamic libraries stack. Finally, we call that function (passing the same arguments as were passed to our fake “open”), and return it’s return value as ours. + +As the “evil injected code” I simply used: + +inspect_open.c (fragment): + +``` +printf("The victim used open(...) to access '%s'!!!\n",pathname); //remember to include stdio.h! +``` + +To compile it, I needed to slightly adjust compiler flags: + +> ``` +> gcc -shared -fPIC  inspect_open.c -o inspect_open.so -ldl +> ``` + +I had to append  _-ldl_ , so that this shared library is linked to  _libdl_ , which provides the  _dlsym_  function. (Nah, I am not going to create a fake version of  _dlsym_ , though this might be fun.) + +So what do I have in result? A shared library, which implements the open(…) function so that it behaves **exactly** as the real open(…)… except it has a side effect of  _printf_ ing the file path :-) + +If you are not convinced this is a powerful trick, it’s the time you tried the following: + +> ``` +> LD_PRELOAD=$PWD/inspect_open.so gnome-calculator +> ``` + +I encourage you to see the result yourself, but basically it lists every file this application accesses. In real time. + +I believe it’s not that hard to imagine why this might be useful for debugging or investigating unknown applications. Please note, however, that this particular trick is not quite complete, because  _open()_  is not the only function that opens files… For example, there is also  _open64()_  in the standard library, and for full investigation you would need to create a fake one too. + +#### **Possible uses** + +If you are still with me and enjoyed the above, let me suggest a bunch of ideas of what can be achieved using this trick. Keep in mind that you can do all the above without to source of the affected app! + +1. ~~Gain root privileges.~~ Not really, don’t even bother, you won’t bypass any security this way. (A quick explanation for pros: no libraries will be preloaded this way if ruid != euid) + +2. Cheat games: **Unrandomize.** This is what I did in the first example. For a fully working case you would need also to implement a custom  _random()_ ,  _rand_r()_ _, random_r()_ . Also some apps may be reading from  _/dev/urandom_  or so, you might redirect them to  _/dev/null_  by running the original  _open()_  with a modified file path. Furthermore, some apps may have their own random number generation algorithm, there is little you can do about that (unless: point 10 below). But this looks like an easy exercise for beginners. + +3. Cheat games: **Bullet time. **Implement all standard time-related functions pretend the time flows two times slower. Or ten times slower. If you correctly calculate new values for time measurement, timed  _sleep_ functions, and others, the affected application will believe the time runs slower (or faster, if you wish), and you can experience awesome bullet-time action. + Or go **even one step further** and let your shared library also be a DBus client, so that you can communicate with it real time. Bind some shortcuts to custom commands, and with some additional calculations in your fake timing functions you will be able to enable&disable the slow-mo or fast-forward anytime you wish. + +4. Investigate apps: **List accessed files.** That’s what my second example does, but this could be also pushed further, by recording and monitoring all app’s file I/O. + +5. Investigate apps: **Monitor internet access.** You might do this with Wireshark or similar software, but with this trick you could actually gain control of what an app sends over the web, and not just look, but also affect the exchanged data. Lots of possibilities here, from detecting spyware, to cheating in multiplayer games, or analyzing & reverse-engineering protocols of closed-source applications. + +6. Investigate apps: **Inspect GTK structures.** Why just limit ourselves to standard library? Let’s inject code in all GTK calls, so that we can learn what widgets does an app use, and how are they structured. This might be then rendered either to an image or even to a gtkbuilder file! Super useful if you want to learn how does some app manage its interface! + +7. **Sandbox unsafe applications.** If you don’t trust some app and are afraid that it may wish to _ rm -rf / _ or do some other unwanted file activities, you might potentially redirect all it’s file IO to e.g. /tmp by appropriately modifying the arguments it passes to all file-related functions (not just  _open_ , but also e.g. removing directories etc.). It’s more difficult trick that a chroot, but it gives you more control. It would be only as safe as complete your “wrapper” was, and unless you really know what you’re doing, don’t actually run any malicious software this way. + +8. **Implement features.** [zlibc][1] is an actual library which is run this precise way; it uncompresses files on the go as they are accessed, so that any application can work on compressed data without even realizing it. + +9. **Fix bugs. **Another real-life example: some time ago (I am not sure this is still the case) Skype – which is closed-source – had problems capturing video from some certain webcams. Because the source could not be modified as Skype is not free software, this was fixed by preloading a library that would correct these problems with video. + +10. Manually **access application’s own memory**. Do note that you can access all app data this way. This may be not impressive if you are familiar with software like CheatEngine/scanmem/GameConqueror, but they all require root privileges to work. LD_PRELOAD does not. In fact, with a number of clever tricks your injected code might access all app memory, because, in fact, it gets executed by that application itself. You might modify everything this application can. You can probably imagine this allows a lot of low-level hacks… but I’ll post an article about it another time. + +These are only the ideas I came up with. I bet you can find some too, if you do – share them by commenting! + +-------------------------------------------------------------------------------- + +via: https://rafalcieslak.wordpress.com/2013/04/02/dynamic-linker-tricks-using-ld_preload-to-cheat-inject-features-and-investigate-programs/ + +作者:[Rafał Cieślak ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://rafalcieslak.wordpress.com/ +[1]:http://www.zlibc.linux.lu/index.html diff --git a/sources/tech/20160330 How to turn any syscall into an event Introducing eBPF Kernel probes.md b/sources/tech/20160330 How to turn any syscall into an event Introducing eBPF Kernel probes.md new file mode 100644 index 0000000000..a53270f2d7 --- /dev/null +++ b/sources/tech/20160330 How to turn any syscall into an event Introducing eBPF Kernel probes.md @@ -0,0 +1,361 @@ +How to turn any syscall into an event: Introducing eBPF Kernel probes +============================================================ + + +TL;DR: Using eBPF in recent (>=4.4) Linux kernel, you can turn any kernel function call into a user land event with arbitrary data. This is made easy by bcc. The probe is written in C while the data is handled by python. + +If you are not familiar with eBPF or linux tracing, you really should read the full post. It tries to progressively go through the pitfalls I stumbled unpon while playing around with bcc / eBPF while saving you a lot of the time I spent searching and digging. + +### A note on push vs pull in a Linux world + +When I started to work on containers, I was wondering how we could update a load balancer configuration dynamically based on actual system state. A common strategy, which works, it to let the container orchestrator trigger a load balancer configuration update whenever it starts a container and then let the load balancer poll the container until some health check passes. It may be a simple “SYN” test. + +While this configuration works, it has the downside of making your load balancer waiting for some system to be available while it should be… load balancing. + +Can we do better? + +When you want a program to react to some change in a system there are 2 possible strategies. The program may  _poll_  the system to detect changes or, if the system supports it, the system may  _push_ events and let the program react to them. Wether you want to use push or poll depends on the context. A good rule of the thumb is to use push events when the event rate is low with respect to the processing time and switch to polling when the events are coming fast or the system may become unusable. For example, typical network driver will wait for events from the network card while frameworks like dpdk will actively poll the card for events to achieve the highest throughput and lowest latency. + +In an ideal world, we’d have some kernel interface telling us: + +> * “Hey Mr. ContainerManager, I’ve just created a socket for the Nginx-ware of container  _servestaticfiles_ , maybe you want to update your state?” +> +> * “Sure Mr. OS, Thanks for letting me know” + +While Linux has a wide range of interfaces to deal with events, up to 3 for file events, there is no dedicated interface to get socket event notifications. You can get routing table events, neighbor table events, conntrack events, interface change events. Just, not socket events. Or maybe there is, deep hidden in a Netlink interface. + +Ideally, we’d need a generic way to do it. How? + +### Kernel tracing and eBPF, a bit of history + +Until recently the only way was to patch the kernel or resort on SystemTap. [SytemTap][5] is a tracing Linux system. In a nutshell, it provides a DSL which is then compiled into a kernel module which is then live-loaded into the running kernel. Except that some production system disable dynamic module loading for security reasons. Including the one I was working on at that time. The other way would be to patch the kernel to trigger some events, probably based on netlink. This is not really convenient. Kernel hacking come with downsides including “interesting” new “features” and increased maintenance burden. + +Hopefully, starting with Linux 3.15 the ground was laid to safely transform any traceable kernel function into userland events. “Safely” is common computer science expression referring to “some virtual machine”. This case is no exception. Linux has had one for years. Since Linux 2.1.75 released in 1997 actually. It’s called Berkeley Packet Filter of BPF for short. As its name suggests, it was originally developed for the BSD firewalls. It had only 2 registers and only allowed forward jumps meaning that you could not write loops with it (Well, you can, if you know the maximum iterations and you manually unroll them). The point was to guarantee the program would always terminate and hence never hang the system. Still not sure if it has any use while you have iptables? It serves as the [foundation of CloudFlare’s AntiDDos protection][6]. + +OK, so, with Linux the 3.15, [BPF was extended][7] turning it into eBPF. For “extended” BPF. It upgrades from 2 32 bits registers to 10 64 bits 64 registers and adds backward jumping among others. It has then been [further extended in Linux 3.18][8] moving it out of the networking subsystem, and adding tools like maps. To preserve the safety guarantees, it [introduces a checker][9] which validates all memory accesses and possible code path. If the checker can’t guarantee the code will terminate within fixed boundaries, it will deny the initial insertion of the program. + +For more history, there is [an excellent Oracle presentation on eBPF][10]. + +Let’s get started. + +### Hello from from `inet_listen` + +As writing assembly is not the most convenient task, even for the best of us, we’ll use [bcc][11]. bcc is a collection of tools based on LLVM and Python abstracting the underlying machinery. Probes are written in C and the results can be exploited from python allowing to easily write non trivial applications. + +Start by install bcc. For some of these examples, you may require a recent (read >= 4.4) version of the kernel. If you are willing to actually try these examples, I highly recommend that you setup a VM.  _NOT_  a docker container. You can’t change the kernel in a container. As this is a young and dynamic projects, install instructions are highly platform/version dependant. You can find up to date instructions on [https://github.com/iovisor/bcc/blob/master/INSTALL.md][12] + +So, we want to get an event whenever a program starts to listen on TCP socket. When calling the `listen()` syscall on a `AF_INET` + `SOCK_STREAM` socket, the underlying kernel function is [`inet_listen`][13]. We’ll start by hooking a “Hello World” `kprobe` on it’s entrypoint. + +``` +from bcc import BPF + +# Hello BPF Program +bpf_text = """ +#include +#include + +// 1\. Attach kprobe to "inet_listen" +int kprobe__inet_listen(struct pt_regs *ctx, struct socket *sock, int backlog) +{ + bpf_trace_printk("Hello World!\\n"); + return 0; +}; +""" + +# 2\. Build and Inject program +b = BPF(text=bpf_text) + +# 3\. Print debug output +while True: + print b.trace_readline() + +``` + +This program does 3 things: 1\. It attaches a kernel probe to “inet_listen” using a naming convention. If the function was called, say, “my_probe”, it could be explicitly attached with `b.attach_kprobe("inet_listen", "my_probe"`. 2\. It builds the program using LLVM new BPF backend, inject the resulting bytecode using the (new) `bpf()` syscall and automatically attaches the probes matching the naming convention. 3\. It reads the raw output from the kernel pipe. + +Note: eBPF backend of LLVM is still young. If you think you’ve hit a bug, you may want to upgrade. + +Noticed the `bpf_trace_printk` call? This is a stripped down version of the kernel’s `printk()`debug function. When used, it produces tracing informations to a special kernel pipe in `/sys/kernel/debug/tracing/trace_pipe`. As the name implies, this is a pipe. If multiple readers are consuming it, only 1 will get a given line. This makes it unsuitable for production. + +Fortunately, Linux 3.19 introduced maps for message passing and Linux 4.4 brings arbitrary perf events support. I’ll demo the perf event based approach later in this post. + +``` +# From a first console +ubuntu@bcc:~/dev/listen-evts$ sudo /python tcv4listen.py + nc-4940 [000] d... 22666.991714: : Hello World! + +# From a second console +ubuntu@bcc:~$ nc -l 0 4242 +^C + +``` + +Yay! + +### Grab the backlog + +Now, let’s print some easily accessible data. Say the “backlog”. The backlog is the number of pending established TCP connections, pending to be `accept()`ed. + +Just tweak a bit the `bpf_trace_printk`: + +``` +bpf_trace_printk("Listening with with up to %d pending connections!\\n", backlog); + +``` + +If you re-run the example with this world-changing improvement, you should see something like: + +``` +(bcc)ubuntu@bcc:~/dev/listen-evts$ sudo python tcv4listen.py + nc-5020 [000] d... 25497.154070: : Listening with with up to 1 pending connections! + +``` + +`nc` is a single connection program, hence the backlog of 1\. Nginx or Redis would output 128 here. But that’s another story. + +Easy hue? Now let’s get the port. + +### Grab the port and IP + +Studying `inet_listen` source from the kernel, we know that we need to get the `inet_sock` from the `socket` object. Just copy from the sources, and insert at the beginning of the tracer: + +``` +// cast types. Intermediate cast not needed, kept for readability +struct sock *sk = sock->sk; +struct inet_sock *inet = inet_sk(sk); + +``` + +The port can now be accessed from `inet->inet_sport` in network byte order (aka: Big Endian). Easy! So, we could just replace the `bpf_trace_printk` with: + +``` +bpf_trace_printk("Listening on port %d!\\n", inet->inet_sport); + +``` + +Then run: + +``` +ubuntu@bcc:~/dev/listen-evts$ sudo /python tcv4listen.py +... +R1 invalid mem access 'inv' +... +Exception: Failed to load BPF program kprobe__inet_listen + +``` + +Except that it’s not (yet) so simple. Bcc is improving a  _lot_  currently. While writing this post, a couple of pitfalls had already been addressed. But not yet all. This Error means the in-kernel checker could prove the memory accesses in program are correct. See the explicit cast. We need to help is a little by making the accesses more explicit. We’ll use `bpf_probe_read` trusted function to read an arbitrary memory location while guaranteeing all necessary checks are done with something like: + +``` +// Explicit initialization. The "=0" part is needed to "give life" to the variable on the stack +u16 lport = 0; + +// Explicit arbitrary memory access. Read it: +// Read into 'lport', 'sizeof(lport)' bytes from 'inet->inet_sport' memory location +bpf_probe_read(&lport, sizeof(lport), &(inet->inet_sport)); + +``` + +Reading the bound address for IPv4 is basically the same, using `inet->inet_rcv_saddr`. If we put is all together, we should get the backlog, the port and the bound IP: + +``` +from bcc import BPF + +# BPF Program +bpf_text = """ +#include +#include +#include + +// Send an event for each IPv4 listen with PID, bound address and port +int kprobe__inet_listen(struct pt_regs *ctx, struct socket *sock, int backlog) +{ + // Cast types. Intermediate cast not needed, kept for readability + struct sock *sk = sock->sk; + struct inet_sock *inet = inet_sk(sk); + + // Working values. You *need* to initialize them to give them "life" on the stack and use them afterward + u32 laddr = 0; + u16 lport = 0; + + // Pull in details. As 'inet_sk' is internally a type cast, we need to use 'bpf_probe_read' + // read: load into 'laddr' 'sizeof(laddr)' bytes from address 'inet->inet_rcv_saddr' + bpf_probe_read(&laddr, sizeof(laddr), &(inet->inet_rcv_saddr)); + bpf_probe_read(&lport, sizeof(lport), &(inet->inet_sport)); + + // Push event + bpf_trace_printk("Listening on %x %d with %d pending connections\\n", ntohl(laddr), ntohs(lport), backlog); + return 0; +}; +""" + +# Build and Inject BPF +b = BPF(text=bpf_text) + +# Print debug output +while True: + print b.trace_readline() + +``` + +A test run should output something like: + +``` +(bcc)ubuntu@bcc:~/dev/listen-evts$ sudo python tcv4listen.py + nc-5024 [000] d... 25821.166286: : Listening on 7f000001 4242 with 1 pending connections + +``` + +Provided that you listen on localhost. The address is displayed as hex here to avoid dealing with the IP pretty printing but that’s all wired. And that’s cool. + +Note: you may wonder why `ntohs` and `ntohl` can be called from BPF while they are not trusted. This is because they are macros and inline functions from “.h” files and a small bug was [fixed][14]while writing this post. + +All done, one more piece: We want to get the related container. In the context of networking, that’s means we want the network namespace. The network namespace being the building block of containers allowing them to have isolated networks. + +### Grab the network namespace: a forced introduction to perf events + +On the userland, the network namespace can be determined by checking the target of `/proc/PID/ns/net`. It should look like `net:[4026531957]`. The number between brackets is the inode number of the network namespace. This said, we could grab it by scrapping ‘/proc’ but this is racy, we may be dealing with short-lived processes. And races are never good. We’ll grab the inode number directly from the kernel. Fortunately, that’s an easy one: + +``` +// Create an populate the variable +u32 netns = 0; + +// Read the netns inode number, like /proc does +netns = sk->__sk_common.skc_net.net->ns.inum; + +``` + +Easy. And it works. + +But if you’ve read so far, you may guess there is something wrong somewhere. And there is: + +``` +bpf_trace_printk("Listening on %x %d with %d pending connections in container %d\\n", ntohl(laddr), ntohs(lport), backlog, netns); + +``` + +If you try to run it, you’ll get some cryptic error message: + +``` +(bcc)ubuntu@bcc:~/dev/listen-evts$ sudo python tcv4listen.py +error: in function kprobe__inet_listen i32 (%struct.pt_regs*, %struct.socket*, i32) +too many args to 0x1ba9108: i64 = Constant<6> + +``` + +What clang is trying to tell you is “Hey pal, `bpf_trace_printk` can only take 4 arguments, you’ve just used 5.“. I won’t dive into the details here, but that’s a BPF limitation. If you want to dig it, [here is a good starting point][15]. + +The only way to fix it is to… stop debugging and make it production ready. So let’s get started (and make sure run at least Linux 4.4). We’ll use perf events which supports passing arbitrary sized structures to userland. Additionally, only our reader will get it so that multiple unrelated eBPF programs can produce data concurrently without issues. + +To use it, we need to: + +1. define a structure + +2. declare the event + +3. push the event + +4. re-declare the event on Python’s side (This step should go away in the future) + +5. consume and format the event + +This may seem like a lot, but it ain’t. See: + +``` +// At the begining of the C program, declare our event +struct listen_evt_t { + u64 laddr; + u64 lport; + u64 netns; + u64 backlog; +}; +BPF_PERF_OUTPUT(listen_evt); + +// In kprobe__inet_listen, replace the printk with +struct listen_evt_t evt = { + .laddr = ntohl(laddr), + .lport = ntohs(lport), + .netns = netns, + .backlog = backlog, +}; +listen_evt.perf_submit(ctx, &evt, sizeof(evt)); + +``` + +Python side will require a little more work, though: + +``` +# We need ctypes to parse the event structure +import ctypes + +# Declare data format +class ListenEvt(ctypes.Structure): + _fields_ = [ + ("laddr", ctypes.c_ulonglong), + ("lport", ctypes.c_ulonglong), + ("netns", ctypes.c_ulonglong), + ("backlog", ctypes.c_ulonglong), + ] + +# Declare event printer +def print_event(cpu, data, size): + event = ctypes.cast(data, ctypes.POINTER(ListenEvt)).contents + print("Listening on %x %d with %d pending connections in container %d" % ( + event.laddr, + event.lport, + event.backlog, + event.netns, + )) + +# Replace the event loop +b["listen_evt"].open_perf_buffer(print_event) +while True: + b.kprobe_poll() + +``` + +Give it a try. In this example, I have a redis running in a docker container and nc on the host: + +``` +(bcc)ubuntu@bcc:~/dev/listen-evts$ sudo python tcv4listen.py +Listening on 0 6379 with 128 pending connections in container 4026532165 +Listening on 0 6379 with 128 pending connections in container 4026532165 +Listening on 7f000001 6588 with 1 pending connections in container 4026531957 + +``` + +### Last word + +Absolutely everything is now setup to use trigger events from arbitrary function calls in the kernel using eBPF, and you should have seen most of the common pitfalls I hit while learning eBPF. If you want to see the full version of this tool, along with some more tricks like IPv6 support, have a look at [https://github.com/iovisor/bcc/blob/master/tools/solisten.py][16]. It’s now an official tool, thanks to the support of the bcc team. + +To go further, you may want to checkout Brendan Gregg’s blog, in particular [the post about eBPF maps and statistics][17]. He his one of the project’s main contributor. + + +-------------------------------------------------------------------------------- + +via: https://blog.yadutaf.fr/2016/03/30/turn-any-syscall-into-event-introducing-ebpf-kernel-probes/ + +作者:[Jean-Tiare Le Bigot ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://blog.yadutaf.fr/about +[1]:https://blog.yadutaf.fr/tags/linux +[2]:https://blog.yadutaf.fr/tags/tracing +[3]:https://blog.yadutaf.fr/tags/ebpf +[4]:https://blog.yadutaf.fr/tags/bcc +[5]:https://en.wikipedia.org/wiki/SystemTap +[6]:https://blog.cloudflare.com/bpf-the-forgotten-bytecode/ +[7]:https://blog.yadutaf.fr/2016/03/30/turn-any-syscall-into-event-introducing-ebpf-kernel-probes/TODO +[8]:https://lwn.net/Articles/604043/ +[9]:http://lxr.free-electrons.com/source/kernel/bpf/verifier.c#L21 +[10]:http://events.linuxfoundation.org/sites/events/files/slides/tracing-linux-ezannoni-linuxcon-ja-2015_0.pdf +[11]:https://github.com/iovisor/bcc +[12]:https://github.com/iovisor/bcc/blob/master/INSTALL.md +[13]:http://lxr.free-electrons.com/source/net/ipv4/af_inet.c#L194 +[14]:https://github.com/iovisor/bcc/pull/453 +[15]:http://lxr.free-electrons.com/source/kernel/trace/bpf_trace.c#L86 +[16]:https://github.com/iovisor/bcc/blob/master/tools/solisten.py +[17]:http://www.brendangregg.com/blog/2015-05-15/ebpf-one-small-step.html diff --git a/sources/tech/20160922 A Linux users guide to Logical Volume Management.md b/sources/tech/20160922 A Linux users guide to Logical Volume Management.md new file mode 100644 index 0000000000..ff0e390f38 --- /dev/null +++ b/sources/tech/20160922 A Linux users guide to Logical Volume Management.md @@ -0,0 +1,233 @@ +A Linux user's guide to Logical Volume Management +============================================================ + +![Logical Volume Management (LVM)](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_other11x_cc.png?itok=I_kCDYj0 "Logical Volume Management (LVM)") +Image by : opensource.com + +Managing disk space has always been a significant task for sysadmins. Running out of disk space used to be the start of a long and complex series of tasks to increase the space available to a disk partition. It also required taking the system off-line. This usually involved installing a new hard drive, booting to recovery or single-user mode, creating a partition and a filesystem on the new hard drive, using temporary mount points to move the data from the too-small filesystem to the new, larger one, changing the content of the /etc/fstab file to reflect the correct device name for the new partition, and rebooting to remount the new filesystem on the correct mount point. + +I have to tell you that, when LVM (Logical Volume Manager) first made its appearance in Fedora Linux, I resisted it rather strongly. My initial reaction was that I did not need this additional layer of abstraction between me and the hard drives. It turns out that I was wrong, and that logical volume management is very useful. + +LVM allows for very flexible disk space management. It provides features like the ability to add disk space to a logical volume and its filesystem while that filesystem is mounted and active and it allows for the collection of multiple physical hard drives and partitions into a single volume group which can then be divided into logical volumes. + +The volume manager also allows reducing the amount of disk space allocated to a logical volume, but there are a couple requirements. First, the volume must be unmounted. Second, the filesystem itself must be reduced in size before the volume on which it resides can be reduced. + +It is important to note that the filesystem itself must allow resizing for this feature to work. The EXT2, 3, and 4 filesystems all allow both offline (unmounted) and online (mounted) resizing when increasing the size of a filesystem, and offline resizing when reducing the size. You should check the details of the filesystems you intend to use in order to verify whether they can be resized at all and especially whether they can be resized while online. + +### Expanding a filesystem on the fly + +I always like to run new distributions in a VirtualBox virtual machine for a few days or weeks to ensure that I will not run into any devastating problems when I start installing it on my production machines. One morning a couple years ago I started installing a newly released version of Fedora in a virtual machine on my primary workstation. I thought that I had enough disk space allocated to the host filesystem in which the VM was being installed. I did not. About a third of the way through the installation I ran out of space on that filesystem. Fortunately, VirtualBox detected the out-of-space condition and paused the virtual machine, and even displayed an error message indicating the exact cause of the problem. + +Note that this problem was not due to the fact that the virtual disk was too small, it was rather the logical volume on the host computer that was running out of space so that the virtual disk belonging to the virtual machine did not have enough space to expand on the host's logical volume. + +Since most modern distributions use Logical Volume Management by default, and I had some free space available on the volume group, I was able to assign additional disk space to the appropriate logical volume and then expand filesystem of the host on the fly. This means that I did not have to reformat the entire hard drive and reinstall the operating system or even reboot. I simply assigned some of the available space to the appropriate logical volume and resized the filesystem—all while the filesystem was on-line and the running program, The virtual machine was still using the host filesystem. After resizing the logical volume and the filesystem I resumed running the virtual machine and the installation continued as if no problems had occurred. + +Although this type of problem may never have happened to you, running out of disk space while a critical program is running has happened to many people. And while many programs, especially Windows programs, are not as well written and resilient as VirtualBox, Linux Logical Volume Management made it possible to recover without losing any data and without having to restart the time-consuming installation. + +### LVM Structure + +The structure of a Logical Volume Manager disk environment is illustrated by Figure 1, below. Logical Volume Management enables the combining of multiple individual hard drives and/or disk partitions into a single volume group (VG). That volume group can then be subdivided into logical volumes (LV) or used as a single large volume. Regular file systems, such as EXT3 or EXT4, can then be created on a logical volume. + +In Figure 1, two complete physical hard drives and one partition from a third hard drive have been combined into a single volume group. Two logical volumes have been created from the space in the volume group, and a filesystem, such as an EXT3 or EXT4 filesystem has been created on each of the two logical volumes. + +![lvm.png](https://opensource.com/sites/default/files/resize/images/life-uploads/lvm-520x222.png) + + _Figure 1: LVM allows combining partitions and entire hard drives into Volume Groups._ + +Adding disk space to a host is fairly straightforward but, in my experience, is done relatively infrequently. The basic steps needed are listed below. You can either create an entirely new volume group or you can add the new space to an existing volume group and either expand an existing logical volume or create a new one. + +### Adding a new logical volume + +There are times when it is necessary to add a new logical volume to a host. For example, after noticing that the directory containing virtual disks for my VirtualBox virtual machines was filling up the /home filesystem, I decided to create a new logical volume in which to store the virtual machine data, including the virtual disks. This would free up a great deal of space in my /home filesystem and also allow me to manage the disk space for the VMs independently. + +The basic steps for adding a new logical volume are as follows. + +1. If necessary, install a new hard drive. + +2. Optional: Create a partition on the hard drive. + +3. Create a physical volume (PV) of the complete hard drive or a partition on the hard drive. + +4. Assign the new physical volume to an existing volume group (VG) or create a new volume group. + +5. Create a new logical volumes (LV) from the space in the volume group. + +6. Create a filesystem on the new logical volume. + +7. Add appropriate entries to /etc/fstab for mounting the filesystem. + +8. Mount the filesystem. + +Now for the details. The following sequence is taken from an example I used as a lab project when teaching about Linux filesystems. + +### Example + +This example shows how to use the CLI to extend an existing volume group to add more space to it, create a new logical volume in that space, and create a filesystem on the logical volume. This procedure can be performed on a running, mounted filesystem. + +WARNING: Only the EXT3 and EXT4 filesystems can be resized on the fly on a running, mounted filesystem. Many other filesystems including BTRFS and ZFS cannot be resized. + +### Install hard drive + +If there is not enough space in the volume group on the existing hard drive(s) in the system to add the desired amount of space it may be necessary to add a new hard drive and create the space to add to the Logical Volume. First, install the physical hard drive, and then perform the following steps. + +### Create Physical Volume from hard drive + +It is first necessary to create a new Physical Volume (PV). Use the command below, which assumes that the new hard drive is assigned as /dev/hdd. + +``` +pvcreate /dev/hdd +``` + +It is not necessary to create a partition of any kind on the new hard drive. This creation of the Physical Volume which will be recognized by the Logical Volume Manager can be performed on a newly installed raw disk or on a Linux partition of type 83\. If you are going to use the entire hard drive, creating a partition first does not offer any particular advantages and uses disk space for metadata that could otherwise be used as part of the PV. + +### Extend the existing Volume Group + +In this example we will extend an existing volume group rather than creating a new one; you can choose to do it either way. After the Physical Volume has been created, extend the existing Volume Group (VG) to include the space on the new PV. In this example the existing Volume Group is named MyVG01. + +``` +vgextend /dev/MyVG01 /dev/hdd +``` + +### Create the Logical Volume + +First create the Logical Volume (LV) from existing free space within the Volume Group. The command below creates a LV with a size of 50GB. The Volume Group name is MyVG01 and the Logical Volume Name is Stuff. + +``` +lvcreate -L +50G --name Stuff MyVG01 +``` + +### Create the filesystem + +Creating the Logical Volume does not create the filesystem. That task must be performed separately. The command below creates an EXT4 filesystem that fits the newly created Logical Volume. + +``` +mkfs -t ext4 /dev/MyVG01/Stuff +``` + +### Add a filesystem label + +Adding a filesystem label makes it easy to identify the filesystem later in case of a crash or other disk related problems. + +``` +e2label /dev/MyVG01/Stuff Stuff +``` + +### Mount the filesystem + +At this point you can create a mount point, add an appropriate entry to the /etc/fstab file, and mount the filesystem. + +You should also check to verify the volume has been created correctly. You can use the **df**, **lvs,** and **vgs** commands to do this. + +### Resizing a logical volume in an LVM filesystem + +The need to resize a filesystem has been around since the beginning of the first versions of Unix and has not gone away with Linux. It has gotten easier, however, with Logical Volume Management. + +1. If necessary, install a new hard drive. + +2. Optional: Create a partition on the hard drive. + +3. Create a physical volume (PV) of the complete hard drive or a partition on the hard drive. + +4. Assign the new physical volume to an existing volume group (VG) or create a new volume group. + +5. Create one or more logical volumes (LV) from the space in the volume group, or expand an existing logical volume with some or all of the new space in the volume group. + +6. If you created a new logical volume, create a filesystem on it. If adding space to an existing logical volume, use the resize2fs command to enlarge the filesystem to fill the space in the logical volume. + +7. Add appropriate entries to /etc/fstab for mounting the filesystem. + +8. Mount the filesystem. + +### Example + +This example describes how to resize an existing Logical Volume in an LVM environment using the CLI. It adds about 50GB of space to the /Stuff filesystem. This procedure can be used on a mounted, live filesystem only with the Linux 2.6 Kernel (and higher) and EXT3 and EXT4 filesystems. I do not recommend that you do so on any critical system, but it can be done and I have done so many times; even on the root (/) filesystem. Use your judgment. + +WARNING: Only the EXT3 and EXT4 filesystems can be resized on the fly on a running, mounted filesystem. Many other filesystems including BTRFS and ZFS cannot be resized. + +### Install the hard drive + +If there is not enough space on the existing hard drive(s) in the system to add the desired amount of space it may be necessary to add a new hard drive and create the space to add to the Logical Volume. First, install the physical hard drive and then perform the following steps. + +### Create a Physical Volume from the hard drive + +It is first necessary to create a new Physical Volume (PV). Use the command below, which assumes that the new hard drive is assigned as /dev/hdd. + +``` +pvcreate /dev/hdd +``` + +It is not necessary to create a partition of any kind on the new hard drive. This creation of the Physical Volume which will be recognized by the Logical Volume Manager can be performed on a newly installed raw disk or on a Linux partition of type 83\. If you are going to use the entire hard drive, creating a partition first does not offer any particular advantages and uses disk space for metadata that could otherwise be used as part of the PV. + +### Add PV to existing Volume Group + +For this example, we will use the new PV to extend an existing Volume Group. After the Physical Volume has been created, extend the existing Volume Group (VG) to include the space on the new PV. In this example, the existing Volume Group is named MyVG01. + +``` +vgextend /dev/MyVG01 /dev/hdd +``` + +### Extend the Logical Volume + +Extend the Logical Volume (LV) from existing free space within the Volume Group. The command below expands the LV by 50GB. The Volume Group name is MyVG01 and the Logical Volume Name is Stuff. + +``` +lvextend -L +50G /dev/MyVG01/Stuff +``` + +### Expand the filesystem + +Extending the Logical Volume will also expand the filesystem if you use the -r option. If you do not use the -r option, that task must be performed separately. The command below resizes the filesystem to fit the newly resized Logical Volume. + +``` +resize2fs /dev/MyVG01/Stuff +``` + +You should check to verify the resizing has been performed correctly. You can use the **df**, **lvs,** and **vgs** commands to do this. + +### Tips + +Over the years I have learned a few things that can make logical volume management even easier than it already is. Hopefully these tips can prove of some value to you. + +* Use the Extended file systems unless you have a clear reason to use another filesystem. Not all filesystems support resizing but EXT2, 3, and 4 do. The EXT filesystems are also very fast and efficient. In any event, they can be tuned by a knowledgeable sysadmin to meet the needs of most environments if the defaults tuning parameters do not. + +* Use meaningful volume and volume group names. + +* Use EXT filesystem labels. + +I know that, like me, many sysadmins have resisted the change to Logical Volume Management. I hope that this article will encourage you to at least try LVM. I am really glad that I did; my disk management tasks are much easier since I made the switch. + + +### About the author + + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/david-crop.jpg?itok=oePpOpyV)][10] + + David Both - David Both is a Linux and Open Source advocate who resides in Raleigh, North Carolina. He has been in the IT industry for over forty years and taught OS/2 for IBM where he worked for over 20 years. While at IBM, he wrote the first training course for the original IBM PC in 1981\. He has taught RHCE classes for Red Hat and has worked at MCI Worldcom, Cisco, and the State of North Carolina. He has been working with Linux and Open Source Software for almost 20 years. David has written articles for... [more about David Both][7][More about me][8] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/business/16/9/linux-users-guide-lvm + +作者:[ David Both][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/dboth +[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[6]:https://opensource.com/business/16/9/linux-users-guide-lvm?rate=79vf1js7A7rlp-I96YFneopUQqsa2SuB-g-og7eiF1U +[7]:https://opensource.com/users/dboth +[8]:https://opensource.com/users/dboth +[9]:https://opensource.com/user/14106/feed +[10]:https://opensource.com/users/dboth +[11]:https://opensource.com/users/dboth +[12]:https://opensource.com/users/dboth +[13]:https://opensource.com/business/16/9/linux-users-guide-lvm#comments +[14]:https://opensource.com/tags/business +[15]:https://opensource.com/tags/linux +[16]:https://opensource.com/tags/how-tos-and-tutorials +[17]:https://opensource.com/tags/sysadmin diff --git a/sources/tech/20170209 INTRODUCING DOCKER SECRETS MANAGEMENT.md b/sources/tech/20170209 INTRODUCING DOCKER SECRETS MANAGEMENT.md new file mode 100644 index 0000000000..a3fc2c886e --- /dev/null +++ b/sources/tech/20170209 INTRODUCING DOCKER SECRETS MANAGEMENT.md @@ -0,0 +1,110 @@ +INTRODUCING DOCKER SECRETS MANAGEMENT +============================================================ + +Containers are changing how we view apps and infrastructure. Whether the code inside containers is big or small, container architecture introduces a change to how that code behaves with hardware – it fundamentally abstracts it from the infrastructure. Docker believes that there are three key components to container security and together they result in inherently safer apps. + + ![Docker Security](https://i2.wp.com/blog.docker.com/wp-content/uploads/e12387a1-ab21-4942-8760-5b1677bc656d-1.jpg?w=1140&ssl=1) + +A critical element of building safer apps is having a secure way of communicating with other apps and systems, something that often requires credentials, tokens, passwords and other types of confidential information—usually referred to as application secrets. We are excited to introduce Docker Secrets, a container native solution that strengthens the Trusted Delivery component of container security by integrating secret distribution directly into the container platform. + +With containers, applications are now dynamic and portable across multiple environments. This  made existing secrets distribution solutions inadequate because they were largely designed for static environments. Unfortunately, this led to an increase in mismanagement of application secrets, making it common to find insecure, home-grown solutions, such as embedding secrets into version control systems like GitHub, or other equally bad—bolted on point solutions as an afterthought. + +### Introducing Docker Secrets Management + +We fundamentally believe that apps are safer if there is a standardized interface for accessing secrets. Any good solution will also have to follow security best practices, such as encrypting secrets while in transit; encrypting secrets at rest; preventing secrets from unintentionally leaking when consumed by the final application; and strictly adhere to the principle of least-privilege, where an application only has access to the secrets that it needs—no more, no less. + +By integrating secrets into Docker orchestration, we are able to deliver a solution for the secrets management problem that follows these exact principles. + +The following diagram provides a high-level view of how the Docker swarm mode architecture is applied to securely deliver a new type of object to our containers: a secret object. + + ![Docker Secrets Management](https://i0.wp.com/blog.docker.com/wp-content/uploads/b69d2410-9e25-44d8-aa2d-f67b795ff5e3.jpg?w=1140&ssl=1) + +In Docker, a secret is any blob of data, such as a password, SSH private key, TLS Certificate, or any other piece of data that is sensitive in nature. When you add a secret to the swarm (by running `docker secret create`), Docker sends the secret over to the swarm manager over a mutually authenticated TLS connection, making use of the [built-in Certificate Authority][17] that gets automatically created when bootstrapping a new swarm. + +``` +$ echo "This is a secret" | docker secret create my_secret_data - +``` + +Once the secret reaches a manager node, it gets saved to the internal Raft store, which uses NACL’s Salsa20Poly1305 with a 256-bit key to ensure no data is ever written to disk unencrypted. Writing to the internal store gives secrets the same high availability guarantees that the the rest of the swarm management data gets. + +When a swarm manager starts up, the encrypted Raft logs containing the secrets is decrypted using a data encryption key that is unique per-node. This key, and the node’s TLS credentials used to communicate with the rest of the cluster, can be encrypted with a cluster-wide key encryption key, called the unlock key, which is also propagated using Raft and will be required on manager start. + +When you grant a newly-created or running service access to a secret, one of the manager nodes (only managers have access to all the stored secrets stored) will send it over the already established TLS connection exclusively to the nodes that will be running that specific service. This means that nodes cannot request the secrets themselves, and will only gain access to the secrets when provided to them by a manager – strictly for the services that require them. + +``` +$ docker service  create --name="redis" --secret="my_secret_data" redis:alpine +``` + +The  unencrypted secret is mounted into the container in an in-memory filesystem at /run/secrets/. + +``` +$ docker exec $(docker ps --filter name=redis -q) ls -l /run/secrets +total 4 +-r--r--r--    1 root     root            17 Dec 13 22:48 my_secret_data +``` + +If a service gets deleted, or rescheduled somewhere else, the manager will immediately notify all the nodes that no longer require access to that secret to erase it from memory, and the node will no longer have any access to that application secret. + +``` +$ docker service update --secret-rm="my_secret_data" redis + +$ docker exec -it $(docker ps --filter name=redis -q) cat /run/secrets/my_secret_data + +cat: can't open '/run/secrets/my_secret_data': No such file or directory +``` + +Check out the [Docker secrets docs][18] for more information and examples on how to create and manage your secrets. And a special shout out to Laurens Van Houtven (https://www.lvh.io/[)][19] in collaboration with the Docker security and core engineering team to help make this feature a reality. + +[Get safer apps for dev and ops w/ new #Docker secrets management][5] + +[CLICK TO TWEET][6] + +### +![Docker Security](https://i2.wp.com/blog.docker.com/wp-content/uploads/Screenshot-2017-02-08-23.30.13.png?resize=1032%2C111&ssl=1) + +### Safer Apps with Docker + +Docker secrets is designed to be easily usable by developers and IT ops teams to build and run safer apps. Docker secrets is a container first architecture designed to keep secrets safe and used only when needed by the exact container that needs that secret to operate. From defining apps and secrets with Docker Compose through an IT admin deploying that Compose file directly in Docker Datacenter, the services, secrets, networks and volumes will travel securely, safely with the application. + +Resources to learn more: + +* [Docker Datacenter on 1.13 with Secrets, Security Scanning, Content Cache and More][7] + +* [Download Docker][8] and get started today + +* [Try secrets in Docker Datacenter][9] + +* [Read the Documentation][10] + +* Attend an [upcoming webinar][11] + +-------------------------------------------------------------------------------- + +via: https://blog.docker.com/2017/02/docker-secrets-management/ + +作者:[ Ying Li][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://blog.docker.com/author/yingli/ +[1]:http://www.linkedin.com/shareArticle?mini=true&url=http://dockr.ly/2k6gnOB&title=Introducing%20Docker%20Secrets%20Management&summary=Containers%20are%20changing%20how%20we%20view%20apps%20and%20infrastructure.%20Whether%20the%20code%20inside%20containers%20is%20big%20or%20small,%20container%20architecture%20introduces%20a%20change%20to%20how%20that%20code%20behaves%20with%20hardware%20-%20it%20fundamentally%20abstracts%20it%20from%20the%20infrastructure.%20Docker%20believes%20that%20there%20are%20three%20key%20components%20to%20container%20security%20and%20... +[2]:http://www.reddit.com/submit?url=http://dockr.ly/2k6gnOB&title=Introducing%20Docker%20Secrets%20Management +[3]:https://plus.google.com/share?url=http://dockr.ly/2k6gnOB +[4]:http://news.ycombinator.com/submitlink?u=http://dockr.ly/2k6gnOB&t=Introducing%20Docker%20Secrets%20Management +[5]:https://twitter.com/share?text=Get+safer+apps+for+dev+and+ops+w%2F+new+%23Docker+secrets+management+&via=docker&related=docker&url=http://dockr.ly/2k6gnOB +[6]:https://twitter.com/share?text=Get+safer+apps+for+dev+and+ops+w%2F+new+%23Docker+secrets+management+&via=docker&related=docker&url=http://dockr.ly/2k6gnOB +[7]:http://dockr.ly/AppSecurity +[8]:https://www.docker.com/getdocker +[9]:http://www.docker.com/trial +[10]:https://docs.docker.com/engine/swarm/secrets/ +[11]:http://www.docker.com/webinars +[12]:https://blog.docker.com/author/yingli/ +[13]:https://blog.docker.com/tag/container-security/ +[14]:https://blog.docker.com/tag/docker-security/ +[15]:https://blog.docker.com/tag/secrets-management/ +[16]:https://blog.docker.com/tag/security/ +[17]:https://docs.docker.com/engine/swarm/how-swarm-mode-works/pki/ +[18]:https://docs.docker.com/engine/swarm/secrets/ +[19]:https://lvh.io%29/ diff --git a/sources/tech/20170530 How to Improve a Legacy Codebase.md b/sources/tech/20170530 How to Improve a Legacy Codebase.md deleted file mode 100644 index cff5e70538..0000000000 --- a/sources/tech/20170530 How to Improve a Legacy Codebase.md +++ /dev/null @@ -1,108 +0,0 @@ -Translating by aiwhj -# How to Improve a Legacy Codebase - - -It happens at least once in the lifetime of every programmer, project manager or teamleader. You get handed a steaming pile of manure, if you’re lucky only a few million lines worth, the original programmers have long ago left for sunnier places and the documentation - if there is any to begin with - is hopelessly out of sync with what is presently keeping the company afloat. - -Your job: get us out of this mess. - -After your first instinctive response (run for the hills) has passed you start on the project knowing full well that the eyes of the company senior leadership are on you. Failure is not an option. And yet, by the looks of what you’ve been given failure is very much in the cards. So what to do? - -I’ve been (un)fortunate enough to be in this situation several times and me and a small band of friends have found that it is a lucrative business to be able to take these steaming piles of misery and to turn them into healthy maintainable projects. Here are some of the tricks that we employ: - -### Backup - -Before you start to do anything at all make a backup of  _everything_  that might be relevant. This to make sure that no information is lost that might be of crucial importance somewhere down the line. All it takes is a silly question that you can’t answer to eat up a day or more once the change has been made. Especially configuration data is susceptible to this kind of problem, it is usually not versioned and you’re lucky if it is taken along in the periodic back-up scheme. So better safe than sorry, copy everything to a very safe place and never ever touch that unless it is in read-only mode. - -### Important pre-requisite, make sure you have a build process and that it actually produces what runs in production - -I totally missed this step on the assumption that it is obvious and likely already in place but many HN commenters pointed this out and they are absolutely right: step one is to make sure that you know what is running in production right now and that means that you need to be able to build a version of the software that is - if your platform works that way - byte-for-byte identical with the current production build. If you can’t find a way to achieve this then likely you will be in for some unpleasant surprises once you commit something to production. Make sure you test this to the best of your ability to make sure that you have all the pieces in place and then, after you’ve gained sufficient confidence that it will work move it to production. Be prepared to switch back immediately to whatever was running before and make sure that you log everything and anything that might come in handy during the - inevitable - post mortem. - -### Freeze the DB - -If at all possible freeze the database schema until you are done with the first level of improvements, by the time you have a solid understanding of the codebase and the legacy code has been fully left behind you are ready to modify the database schema. Change it any earlier than that and you may have a real problem on your hand, now you’ve lost the ability to run an old and a new codebase side-by-side with the database as the steady foundation to build on. Keeping the DB totally unchanged allows you to compare the effect your new business logic code has compared to the old business logic code, if it all works as advertised there should be no differences. - -### Write your tests - -Before you make any changes at all write as many end-to-end and integration tests as you can. Make sure these tests produce the right output and test any and all assumptions that you can come up with about how you  _think_  the old stuff works (be prepared for surprises here). These tests will have two important functions: they will help to clear up any misconceptions at a very early stage and they will function as guardrails once you start writing new code to replace old code. - -Automate all your testing, if you’re already experienced with CI then use it and make sure your tests run fast enough to run the full set of tests after every commit. - -### Instrumentation and logging - -If the old platform is still available for development add instrumentation. Do this in a completely new database table, add a simple counter for every event that you can think of and add a single function to increment these counters based on the name of the event. That way you can implement a time-stamped event log with a few extra lines of code and you’ll get a good idea of how many events of one kind lead to events of another kind. One example: User opens app, User closes app. If two events should result in some back-end calls those two counters should over the long term remain at a constant difference, the difference is the number of apps currently open. If you see many more app opens than app closes you know there has to be a way in which apps end (for instance a crash). For each and every event you’ll find there is some kind of relationship to other events, usually you will strive for constant relationships unless there is an obvious error somewhere in the system. You’ll aim to reduce those counters that indicate errors and you’ll aim to maximize counters further down in the chain to the level indicated by the counters at the beginning. (For instance: customers attempting to pay should result in an equal number of actual payments received). - -This very simple trick turns every backend application into a bookkeeping system of sorts and just like with a real bookkeeping system the numbers have to match, as long as they don’t you have a problem somewhere. - -This system will over time become invaluable in establishing the health of the system and will be a great companion next to the source code control system revision log where you can determine the point in time that a bug was introduced and what the effect was on the various counters. - -I usually keep these counters at a 5 minute resolution (so 12 buckets for an hour), but if you have an application that generates fewer or more events then you might decide to change the interval at which new buckets are created. All counters share the same database table and so each counter is simply a column in that table. - -### Change only one thing at the time - -Do not fall into the trap of improving both the maintainability of the code or the platform it runs on at the same time as adding new features or fixing bugs. This will cause you huge headaches because you now have to ask yourself every step of the way what the desired outcome is of an action and will invalidate some of the tests you made earlier. - -### Platform changes - -If you’ve decided to migrate the application to another platform then do this first  _but keep everything else exactly the same_ . If you want you can add more documentation or tests, but no more than that, all business logic and interdependencies should remain as before. - -### Architecture changes - -The next thing to tackle is to change the architecture of the application (if desired). At this point in time you are free to change the higher level structure of the code, usually by reducing the number of horizontal links between modules, and thus reducing the scope of the code active during any one interaction with the end-user. If the old code was monolithic in nature now would be a good time to make it more modular, break up large functions into smaller ones but leave names of variables and data-structures as they were. - -HN user [mannykannot][1] points - rightfully - out that this is not always an option, if you’re particularly unlucky then you may have to dig in deep in order to be able to make any architecture changes. I agree with that and I should have included it here so hence this little update. What I would further like to add is if you do both do high level changes and low level changes at least try to limit them to one file or worst case one subsystem so that you limit the scope of your changes as much as possible. Otherwise you might have a very hard time debugging the change you just made. - -### Low level refactoring - -By now you should have a very good understanding of what each module does and you are ready for the real work: refactoring the code to improve maintainability and to make the code ready for new functionality. This will likely be the part of the project that consumes the most time, document as you go, do not make changes to a module until you have thoroughly documented it and feel you understand it. Feel free to rename variables and functions as well as datastructures to improve clarity and consistency, add tests (also unit tests, if the situation warrants them). - -### Fix bugs - -Now you’re ready to take on actual end-user visible changes, the first order of battle will be the long list of bugs that have accumulated over the years in the ticket queue. As usual, first confirm the problem still exists, write a test to that effect and then fix the bug, your CI and the end-to-end tests written should keep you safe from any mistakes you make due to a lack of understanding or some peripheral issue. - -### Database Upgrade - -If required after all this is done and you are on a solid and maintainable codebase again you have the option to change the database schema or to replace the database with a different make/model altogether if that is what you had planned to do. All the work you’ve done up to this point will help to assist you in making that change in a responsible manner without any surprises, you can completely test the new DB with the new code and all the tests in place to make sure your migration goes off without a hitch. - -### Execute on the roadmap - -Congratulations, you are out of the woods and are now ready to implement new functionality. - -### Do not ever even attempt a big-bang rewrite - -A big-bang rewrite is the kind of project that is pretty much guaranteed to fail. For one, you are in uncharted territory to begin with so how would you even know what to build, for another, you are pushing  _all_  the problems to the very last day, the day just before you go ‘live’ with your new system. And that’s when you’ll fail, miserably. Business logic assumptions will turn out to be faulty, suddenly you’ll gain insight into why that old system did certain things the way it did and in general you’ll end up realizing that the guys that put the old system together weren’t maybe idiots after all. If you really do want to wreck the company (and your own reputation to boot) by all means, do a big-bang rewrite, but if you’re smart about it this is not even on the table as an option. - -### So, the alternative, work incrementally - -To untangle one of these hairballs the quickest path to safety is to take any element of the code that you do understand (it could be a peripheral bit, but it might also be some core module) and try to incrementally improve it still within the old context. If the old build tools are no longer available you will have to use some tricks (see below) but at least try to leave as much of what is known to work alive while you start with your changes. That way as the codebase improves so does your understanding of what it actually does. A typical commit should be at most a couple of lines. - -### Release! - -Every change along the way gets released into production, even if the changes are not end-user visible it is important to make the smallest possible steps because as long as you lack understanding of the system there is a fair chance that only the production environment will tell you there is a problem. If that problem arises right after you make a small change you will gain several advantages: - -* it will probably be trivial to figure out what went wrong - -* you will be in an excellent position to improve the process - -* and you should immediately update the documentation to show the new insights gained - -### Use proxies to your advantage - -If you are doing web development praise the gods and insert a proxy between the end-users and the old system. Now you have per-url control over which requests go to the old system and which you will re-route to the new system allowing much easier and more granular control over what is run and who gets to see it. If your proxy is clever enough you could probably use it to send a percentage of the traffic to the new system for an individual URL until you are satisfied that things work the way they should. If your integration tests also connect to this interface it is even better. - -### Yes, but all this will take too much time! - -Well, that depends on how you look at it. It’s true there is a bit of re-work involved in following these steps. But it  _does_  work, and any kind of optimization of this process makes the assumption that you know more about the system than you probably do. I’ve got a reputation to maintain and I  _really_  do not like negative surprises during work like this. With some luck the company is already on the skids, or maybe there is a real danger of messing things up for the customers. In a situation like that I prefer total control and an iron clad process over saving a couple of days or weeks if that imperils a good outcome. If you’re more into cowboy stuff - and your bosses agree - then maybe it would be acceptable to take more risk, but most companies would rather take the slightly slower but much more sure road to victory. - --------------------------------------------------------------------------------- - -via: https://jacquesmattheij.com/improving-a-legacy-codebase - -作者:[Jacques Mattheij ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://jacquesmattheij.com/ -[1]:https://news.ycombinator.com/item?id=14445661 diff --git a/sources/tech/20170607 Why Car Companies Are Hiring Computer Security Experts.md b/sources/tech/20170607 Why Car Companies Are Hiring Computer Security Experts.md new file mode 100644 index 0000000000..4a7d23e5f0 --- /dev/null +++ b/sources/tech/20170607 Why Car Companies Are Hiring Computer Security Experts.md @@ -0,0 +1,91 @@ +Why Car Companies Are Hiring Computer Security Experts +============================================================ + +Photo +![](https://static01.nyt.com/images/2017/06/08/business/08BITS-GURUS1/08BITS-GURUS1-superJumbo.jpg) +The cybersecurity experts Marc Rogers, left, of CloudFlare and Kevin Mahaffey of Lookout were able to control various Tesla functions from their physically connected laptop. They pose in CloudFlare’s lobby in front of Lava Lamps used to generate numbers for encryption.CreditChristie Hemm Klok for The New York Times + +It started about seven years ago. Iran’s top nuclear scientists were being assassinated in a string of similar attacks: Assailants on motorcycles were pulling up to their moving cars, attaching magnetic bombs and detonating them after the motorcyclists had fled the scene. + +In another seven years, security experts warn, assassins won’t need motorcycles or magnetic bombs. All they’ll need is a laptop and code to send driverless cars careering off a bridge, colliding with a driverless truck or coming to an unexpected stop in the middle of fast-moving traffic. + +Automakers may call them self-driving cars. But hackers call them computers that travel over 100 miles an hour. + +“These are no longer cars,” said Marc Rogers, the principal security researcher at the cybersecurity firm CloudFlare. “These are data centers on wheels. Any part of the car that talks to the outside world is a potential inroad for attackers.” + +Those fears came into focus two years ago when two “white hat” hackers — researchers who look for computer vulnerabilities to spot problems and fix them, rather than to commit a crime or cause problems — successfully gained access to a Jeep Cherokee from their computer miles away. They rendered their crash-test dummy (in this case a nervous reporter) powerless over his vehicle and disabling his transmission in the middle of a highway. + +The hackers, Chris Valasek and Charlie Miller (now security researchers respectively at Uber and Didi, an Uber competitor in China), discovered an [electronic route from the Jeep’s entertainment system to its dashboard][10]. From there, they had control of the vehicle’s steering, brakes and transmission — everything they needed to paralyze their crash test dummy in the middle of a highway. + +“Car hacking makes great headlines, but remember: No one has ever had their car hacked by a bad guy,” Mr. Miller wrote on Twitter last Sunday. “It’s only ever been performed by researchers.” + +Still, the research by Mr. Miller and Mr. Valasek came at a steep price for Jeep’s manufacturer, Fiat Chrysler, which was forced to recall 1.4 million of its vehicles as a result of the hacking experiment. + +It is no wonder that Mary Barra, the chief executive of General Motors, called cybersecurity her company’s top priority last year. Now the skills of researchers and so-called white hat hackers are in high demand among automakers and tech companies pushing ahead with driverless car projects. + +Uber, [Tesla][11], Apple and Didi in China have been actively recruiting white hat hackers like Mr. Miller and Mr. Valasek from one another as well as from traditional cybersecurity firms and academia. + +Last year, Tesla poached Aaron Sigel, Apple’s manager of security for its iOS operating system. Uber poached Chris Gates, formerly a white hat hacker at Facebook. Didi poached Mr. Miller from Uber, where he had gone to work after the Jeep hack. And security firms have seen dozens of engineers leave their ranks for autonomous-car projects. + +Mr. Miller said he left Uber for Didi, in part, because his new Chinese employer has given him more freedom to discuss his work. + +“Carmakers seem to be taking the threat of cyberattack more seriously, but I’d still like to see more transparency from them,” Mr. Miller wrote on Twitter on Saturday. + +Like a number of big tech companies, Tesla and Fiat Chrysler started paying out rewards to hackers who turn over flaws the hackers discover in their systems. GM has done something similar, though critics say GM’s program is limited when compared with the ones offered by tech companies, and so far no rewards have been paid out. + +One year after the Jeep hack by Mr. Miller and Mr. Valasek, they demonstrated all the other ways they could mess with a Jeep driver, including hijacking the vehicle’s cruise control, swerving the steering wheel 180 degrees or slamming on the parking brake in high-speed traffic — all from a computer in the back of the car. (Those exploits ended with their test Jeep in a ditch and calls to a local tow company.) + +Granted, they had to be in the Jeep to make all that happen. But it was evidence of what is possible. + +The Jeep penetration was preceded by a [2011 hack by security researchers at the University of Washington][12] and the University of California, San Diego, who were the first to remotely hack a sedan and ultimately control its brakes via Bluetooth. The researchers warned car companies that the more connected cars become, the more likely they are to get hacked. + +Security researchers have also had their way with Tesla’s software-heavy Model S car. In 2015, Mr. Rogers, together with Kevin Mahaffey, the chief technology officer of the cybersecurity company Lookout, found a way to control various Tesla functions from their physically connected laptop. + +One year later, a team of Chinese researchers at Tencent took their research a step further, hacking a moving Tesla Model S and controlling its brakes from 12 miles away. Unlike Chrysler, Tesla was able to dispatch a remote patch to fix the security holes that made the hacks possible. + +In all the cases, the car hacks were the work of well meaning, white hat security researchers. But the lesson for all automakers was clear. + +The motivations to hack vehicles are limitless. When it learned of Mr. Rogers’s and Mr. Mahaffey’s investigation into Tesla’s Model S, a Chinese app-maker asked Mr. Rogers if he would be interested in sharing, or possibly selling, his discovery, he said. (The app maker was looking for a backdoor to secretly install its app on Tesla’s dashboard.) + +Criminals have not yet shown they have found back doors into connected vehicles, though for years, they have been actively developing, trading and deploying tools that can intercept car key communications. + +But as more driverless and semiautonomous cars hit the open roads, they will become a more worthy target. Security experts warn that driverless cars present a far more complex, intriguing and vulnerable “attack surface” for hackers. Each new “connected” car feature introduces greater complexity, and with complexity inevitably comes vulnerability. + +Twenty years ago, cars had, on average, one million lines of code. The General Motors 2010 [Chevrolet Volt][13] had about 10 million lines of code — more than an [F-35 fighter jet][14]. + +Today, an average car has more than 100 million lines of code. Automakers predict it won’t be long before they have 200 million. When you stop to consider that, on average, there are 15 to 50 defects per 1,000 lines of software code, the potentially exploitable weaknesses add up quickly. + +The only difference between computer code and driverless car code is that, “Unlike data center enterprise security — where the biggest threat is loss of data — in automotive security, it’s loss of life,” said David Barzilai, a co-founder of Karamba Security, an Israeli start-up that is working on addressing automotive security. + +To truly secure autonomous vehicles, security experts say, automakers will have to address the inevitable vulnerabilities that pop up in new sensors and car computers, address inherent vulnerabilities in the base car itself and, perhaps most challenging of all, bridge the cultural divide between automakers and software companies. + +“The genie is out of the bottle, and to solve this problem will require a major cultural shift,” said Mr. Mahaffey of the cybersecurity company Lookout. “And an automaker that truly values cybersecurity will treat security vulnerabilities the same they would an airbag recall. We have not seen that industrywide shift yet.” + +There will be winners and losers, Mr. Mahaffey added: “Automakers that transform themselves into software companies will win. Others will get left behind.” + +-------------------------------------------------------------------------------- + +via: https://www.nytimes.com/2017/06/07/technology/why-car-companies-are-hiring-computer-security-experts.html + +作者:[NICOLE PERLROTH ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.nytimes.com/by/nicole-perlroth +[1]:https://www.nytimes.com/2016/06/09/technology/software-as-weaponry-in-a-computer-connected-world.html +[2]:https://www.nytimes.com/2015/08/29/technology/uber-hires-two-engineers-who-showed-cars-could-be-hacked.html +[3]:https://www.nytimes.com/2015/08/11/opinion/zeynep-tufekci-why-smart-objects-may-be-a-dumb-idea.html +[4]:https://www.nytimes.com/by/nicole-perlroth +[5]:https://www.nytimes.com/column/bits +[6]:https://www.nytimes.com/2017/06/07/technology/why-car-companies-are-hiring-computer-security-experts.html?utm_source=wanqu.co&utm_campaign=Wanqu+Daily&utm_medium=website#story-continues-1 +[7]:http://www.nytimes.com/newsletters/sample/bits?pgtype=subscriptionspage&version=business&contentId=TU&eventName=sample&module=newsletter-sign-up +[8]:https://www.nytimes.com/privacy +[9]:https://www.nytimes.com/help/index.html +[10]:https://bits.blogs.nytimes.com/2015/07/21/security-researchers-find-a-way-to-hack-cars/ +[11]:http://www.nytimes.com/topic/company/tesla-motors-inc?inline=nyt-org +[12]:http://www.autosec.org/pubs/cars-usenixsec2011.pdf +[13]:http://autos.nytimes.com/2011/Chevrolet/Volt/238/4117/329463/researchOverview.aspx?inline=nyt-classifier +[14]:http://topics.nytimes.com/top/reference/timestopics/subjects/m/military_aircraft/f35_airplane/index.html?inline=nyt-classifier +[15]:https://www.nytimes.com/2017/06/07/technology/why-car-companies-are-hiring-computer-security-experts.html?utm_source=wanqu.co&utm_campaign=Wanqu+Daily&utm_medium=website#story-continues-3 diff --git a/sources/tech/20170622 A users guide to links in the Linux filesystem.md b/sources/tech/20170622 A users guide to links in the Linux filesystem.md deleted file mode 100644 index 3cb59aaacb..0000000000 --- a/sources/tech/20170622 A users guide to links in the Linux filesystem.md +++ /dev/null @@ -1,314 +0,0 @@ -Translating by yongshouzhang - - -A user's guide to links in the Linux filesystem -============================================================ - -### Learn how to use links, which make tasks easier by providing access to files from multiple locations in the Linux filesystem directory tree. - - -![A user's guide to links in the Linux filesystem](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/links.png?itok=AumNmse7 "A user's guide to links in the Linux filesystem") -Image by : [Paul Lewin][8]. Modified by Opensource.com. [CC BY-SA 2.0][9] - -In articles I have written about various aspects of Linux filesystems for Opensource.com, including [An introduction to Linux's EXT4 filesystem][10]; [Managing devices in Linux][11]; [An introduction to Linux filesystems][12]; and [A Linux user's guide to Logical Volume Management][13], I have briefly mentioned an interesting feature of Linux filesystems that can make some tasks easier by providing access to files from multiple locations in the filesystem directory tree. - -There are two types of Linux filesystem links: hard and soft. The difference between the two types of links is significant, but both types are used to solve similar problems. They both provide multiple directory entries (or references) to a single file, but they do it quite differently. Links are powerful and add flexibility to Linux filesystems because [everything is a file][14]. - -More Linux resources - -* [What is Linux?][1] - -* [What are Linux containers?][2] - -* [Download Now: Linux commands cheat sheet][3] - -* [Advanced Linux commands cheat sheet][4] - -* [Our latest Linux articles][5] - -I have found, for instance, that some programs required a particular version of a library. When a library upgrade replaced the old version, the program would crash with an error specifying the name of the old, now-missing library. Usually, the only change in the library name was the version number. Acting on a hunch, I simply added a link to the new library but named the link after the old library name. I tried the program again and it worked perfectly. And, okay, the program was a game, and everyone knows the lengths that gamers will go to in order to keep their games running. - -In fact, almost all applications are linked to libraries using a generic name with only a major version number in the link name, while the link points to the actual library file that also has a minor version number. In other instances, required files have been moved from one directory to another to comply with the Linux file specification, and there are links in the old directories for backwards compatibility with those programs that have not yet caught up with the new locations. If you do a long listing of the **/lib64** directory, you can find many examples of both. - -``` -lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.hwm -> ../../usr/share/cracklib/pw_dict.hwm -lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.pwd -> ../../usr/share/cracklib/pw_dict.pwd -lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.pwi -> ../../usr/share/cracklib/pw_dict.pwi -lrwxrwxrwx. 1 root root 27 Jun 9 2016 libaccountsservice.so.0 -> libaccountsservice.so.0.0.0 --rwxr-xr-x. 1 root root 288456 Jun 9 2016 libaccountsservice.so.0.0.0 -lrwxrwxrwx 1 root root 15 May 17 11:47 libacl.so.1 -> libacl.so.1.1.0 --rwxr-xr-x 1 root root 36472 May 17 11:47 libacl.so.1.1.0 -lrwxrwxrwx. 1 root root 15 Feb 4 2016 libaio.so.1 -> libaio.so.1.0.1 --rwxr-xr-x. 1 root root 6224 Feb 4 2016 libaio.so.1.0.0 --rwxr-xr-x. 1 root root 6224 Feb 4 2016 libaio.so.1.0.1 -lrwxrwxrwx. 1 root root 30 Jan 16 16:39 libakonadi-calendar.so.4 -> libakonadi-calendar.so.4.14.26 --rwxr-xr-x. 1 root root 816160 Jan 16 16:39 libakonadi-calendar.so.4.14.26 -lrwxrwxrwx. 1 root root 29 Jan 16 16:39 libakonadi-contact.so.4 -> libakonadi-contact.so.4.14.26 -``` - -A few of the links in the **/lib64** directory - -The long listing of the **/lib64** directory above shows that the first character in the filemode is the letter "l," which means that each is a soft or symbolic link. - -### Hard links - -In [An introduction to Linux's EXT4 filesystem][15], I discussed the fact that each file has one inode that contains information about that file, including the location of the data belonging to that file. [Figure 2][16] in that article shows a single directory entry that points to the inode. Every file must have at least one directory entry that points to the inode that describes the file. The directory entry is a hard link, thus every file has at least one hard link. - -In Figure 1 below, multiple directory entries point to a single inode. These are all hard links. I have abbreviated the locations of three of the directory entries using the tilde (**~**) convention for the home directory, so that **~** is equivalent to **/home/user** in this example. Note that the fourth directory entry is in a completely different directory, **/home/shared**, which might be a location for sharing files between users of the computer. - -![fig1directory_entries.png](https://opensource.com/sites/default/files/images/life/fig1directory_entries.png) -Figure 1 - -Hard links are limited to files contained within a single filesystem. "Filesystem" is used here in the sense of a partition or logical volume (LV) that is mounted on a specified mount point, in this case **/home**. This is because inode numbers are unique only within each filesystem, and a different filesystem, for example, **/var**or **/opt**, will have inodes with the same number as the inode for our file. - -Because all the hard links point to the single inode that contains the metadata about the file, all of these attributes are part of the file, such as ownerships, permissions, and the total number of hard links to the inode, and cannot be different for each hard link. It is one file with one set of attributes. The only attribute that can be different is the file name, which is not contained in the inode. Hard links to a single **file/inode** located in the same directory must have different names, due to the fact that there can be no duplicate file names within a single directory. - -The number of hard links for a file is displayed with the **ls -l** command. If you want to display the actual inode numbers, the command **ls -li** does that. - -### Symbolic (soft) links - -The difference between a hard link and a soft link, also known as a symbolic link (or symlink), is that, while hard links point directly to the inode belonging to the file, soft links point to a directory entry, i.e., one of the hard links. Because soft links point to a hard link for the file and not the inode, they are not dependent upon the inode number and can work across filesystems, spanning partitions and LVs. - -The downside to this is: If the hard link to which the symlink points is deleted or renamed, the symlink is broken. The symlink is still there, but it points to a hard link that no longer exists. Fortunately, the **ls** command highlights broken links with flashing white text on a red background in a long listing. - -### Lab project: experimenting with links - -I think the easiest way to understand the use of and differences between hard and soft links is with a lab project that you can do. This project should be done in an empty directory as a  _non-root user_ . I created the **~/temp** directory for this project, and you should, too. It creates a safe place to do the project and provides a new, empty directory to work in so that only files associated with this project will be located there. - -### **Initial setup** - -First, create the temporary directory in which you will perform the tasks needed for this project. Ensure that the present working directory (PWD) is your home directory, then enter the following command. - -``` -mkdir temp -``` - -Change into **~/temp** to make it the PWD with this command. - -``` -cd temp -``` - -To get started, we need to create a file we can link to. The following command does that and provides some content as well. - -``` -du -h > main.file.txt -``` - -Use the **ls -l** long list to verify that the file was created correctly. It should look similar to my results. Note that the file size is only 7 bytes, but yours may vary by a byte or two. - -``` -[dboth@david temp]$ ls -l -total 4 --rw-rw-r-- 1 dboth dboth 7 Jun 13 07:34 main.file.txt -``` - -Notice the number "1" following the file mode in the listing. That number represents the number of hard links that exist for the file. For now, it should be 1 because we have not created any additional links to our test file. - -### **Experimenting with hard links** - -Hard links create a new directory entry pointing to the same inode, so when hard links are added to a file, you will see the number of links increase. Ensure that the PWD is still **~/temp**. Create a hard link to the file **main.file.txt**, then do another long list of the directory. - -``` -[dboth@david temp]$ ln main.file.txt link1.file.txt -[dboth@david temp]$ ls -l -total 8 --rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 link1.file.txt --rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 main.file.txt -``` - -Notice that both files have two links and are exactly the same size. The date stamp is also the same. This is really one file with one inode and two links, i.e., directory entries to it. Create a second hard link to this file and list the directory contents. You can create the link to either of the existing ones: **link1.file.txt** or **main.file.txt**. - -``` -[dboth@david temp]$ ln link1.file.txt link2.file.txt ; ls -l -total 16 --rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link1.file.txt --rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link2.file.txt --rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 main.file.txt -``` - -Notice that each new hard link in this directory must have a different name because two files—really directory entries—cannot have the same name within the same directory. Try to create another link with a target name the same as one of the existing ones. - -``` -[dboth@david temp]$ ln main.file.txt link2.file.txt -ln: failed to create hard link 'link2.file.txt': File exists -``` - -Clearly that does not work, because **link2.file.txt** already exists. So far, we have created only hard links in the same directory. So, create a link in your home directory, the parent of the temp directory in which we have been working so far. - -``` -[dboth@david temp]$ ln main.file.txt ../main.file.txt ; ls -l ../main* --rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt -``` - -The **ls** command in the above listing shows that the **main.file.txt** file does exist in the home directory with the same name as the file in the temp directory. Of course, these are not different files; they are the same file with multiple links—directory entries—to the same inode. To help illustrate the next point, add a file that is not a link. - -``` -[dboth@david temp]$ touch unlinked.file ; ls -l -total 12 --rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt --rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt --rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt --rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -Look at the inode number of the hard links and that of the new file using the **-i**option to the **ls** command. - -``` -[dboth@david temp]$ ls -li -total 12 -657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt -657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt -657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -Notice the number **657024** to the left of the file mode in the example above. That is the inode number, and all three file links point to the same inode. You can use the **-i** option to view the inode number for the link we created in the home directory as well, and that will also show the same value. The inode number of the file that has only one link is different from the others. Note that the inode numbers will be different on your system. - -Let's change the size of one of the hard-linked files. - -``` -[dboth@david temp]$ df -h > link2.file.txt ; ls -li -total 12 -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -The file size of all the hard-linked files is now larger than before. That is because there is really only one file that is linked to by multiple directory entries. - -I know this next experiment will work on my computer because my **/tmp**directory is on a separate LV. If you have a separate LV or a filesystem on a different partition (if you're not using LVs), determine whether or not you have access to that LV or partition. If you don't, you can try to insert a USB memory stick and mount it. If one of those options works for you, you can do this experiment. - -Try to create a link to one of the files in your **~/temp** directory in **/tmp** (or wherever your different filesystem directory is located). - -``` -[dboth@david temp]$ ln link2.file.txt /tmp/link3.file.txt -ln: failed to create hard link '/tmp/link3.file.txt' => 'link2.file.txt': -Invalid cross-device link -``` - -Why does this error occur? The reason is each separate mountable filesystem has its own set of inode numbers. Simply referring to a file by an inode number across the entire Linux directory structure can result in confusion because the same inode number can exist in each mounted filesystem. - -There may be a time when you will want to locate all the hard links that belong to a single inode. You can find the inode number using the **ls -li** command. Then you can use the **find** command to locate all links with that inode number. - -``` -[dboth@david temp]$ find . -inum 657024 -./main.file.txt -./link1.file.txt -./link2.file.txt -``` - -Note that the **find** command did not find all four of the hard links to this inode because we started at the current directory of **~/temp**. The **find** command only finds files in the PWD and its subdirectories. To find all the links, we can use the following command, which specifies your home directory as the starting place for the search. - -``` -[dboth@david temp]$ find ~ -samefile main.file.txt -/home/dboth/temp/main.file.txt -/home/dboth/temp/link1.file.txt -/home/dboth/temp/link2.file.txt -/home/dboth/main.file.txt -``` - -You may see error messages if you do not have permissions as a non-root user. This command also uses the **-samefile** option instead of specifying the inode number. This works the same as using the inode number and can be easier if you know the name of one of the hard links. - -### **Experimenting with soft links** - -As you have just seen, creating hard links is not possible across filesystem boundaries; that is, from a filesystem on one LV or partition to a filesystem on another. Soft links are a means to answer that problem with hard links. Although they can accomplish the same end, they are very different, and knowing these differences is important. - -Let's start by creating a symlink in our **~/temp** directory to start our exploration. - -``` -[dboth@david temp]$ ln -s link2.file.txt link3.file.txt ; ls -li -total 12 -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt -658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> -link2.file.txt -657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -The hard links, those that have the inode number **657024**, are unchanged, and the number of hard links shown for each has not changed. The newly created symlink has a different inode, number **658270**. The soft link named **link3.file.txt**points to **link2.file.txt**. Use the **cat** command to display the contents of **link3.file.txt**. The file mode information for the symlink starts with the letter "**l**" which indicates that this file is actually a symbolic link. - -The size of the symlink **link3.file.txt** is only 14 bytes in the example above. That is the size of the text **link3.file.txt -> link2.file.txt**, which is the actual content of the directory entry. The directory entry **link3.file.txt** does not point to an inode; it points to another directory entry, which makes it useful for creating links that span file system boundaries. So, let's create that link we tried before from the **/tmp** directory. - -``` -[dboth@david temp]$ ln -s /home/dboth/temp/link2.file.txt -/tmp/link3.file.txt ; ls -l /tmp/link* -lrwxrwxrwx 1 dboth dboth 31 Jun 14 21:53 /tmp/link3.file.txt -> -/home/dboth/temp/link2.file.txt -``` - -### **Deleting links** - -There are some other things that you should consider when you need to delete links or the files to which they point. - -First, let's delete the link **main.file.txt**. Remember that every directory entry that points to an inode is simply a hard link. - -``` -[dboth@david temp]$ rm main.file.txt ; ls -li -total 8 -657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link1.file.txt -657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link2.file.txt -658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> -link2.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -The link **main.file.txt** was the first link created when the file was created. Deleting it now still leaves the original file and its data on the hard drive along with all the remaining hard links. To delete the file and its data, you would have to delete all the remaining hard links. - -Now delete the **link2.file.txt** hard link. - -``` -[dboth@david temp]$ rm link2.file.txt ; ls -li -total 8 -657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link1.file.txt -658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt -> -link2.file.txt -657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 main.file.txt -657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file -``` - -Notice what happens to the soft link. Deleting the hard link to which the soft link points leaves a broken link. On my system, the broken link is highlighted in colors and the target hard link is flashing. If the broken link needs to be fixed, you can create another hard link in the same directory with the same name as the old one, so long as not all the hard links have been deleted. You could also recreate the link itself, with the link maintaining the same name but pointing to one of the remaining hard links. Of course, if the soft link is no longer needed, it can be deleted with the **rm** command. - -The **unlink** command can also be used to delete files and links. It is very simple and has no options, as the **rm** command does. It does, however, more accurately reflect the underlying process of deletion, in that it removes the link—the directory entry—to the file being deleted. - -### Final thoughts - -I worked with both types of links for a long time before I began to understand their capabilities and idiosyncrasies. It took writing a lab project for a Linux class I taught to fully appreciate how links work. This article is a simplification of what I taught in that class, and I hope it speeds your learning curve. - --------------------------------------------------------------------------------- - -作者简介: - -David Both - David Both is a Linux and Open Source advocate who resides in Raleigh, North Carolina. He has been in the IT industry for over forty years and taught OS/2 for IBM where he worked for over 20 years. While at IBM, he wrote the first training course for the original IBM PC in 1981. He has taught RHCE classes for Red Hat and has worked at MCI Worldcom, Cisco, and the State of North Carolina. He has been working with Linux and Open Source Software for almost 20 years. - ---------------------------------- - -via: https://opensource.com/article/17/6/linking-linux-filesystem - -作者:[David Both ][a] -译者:[runningwater](https://github.com/runningwater) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/dboth -[1]:https://opensource.com/resources/what-is-linux?src=linux_resource_menu -[2]:https://opensource.com/resources/what-are-linux-containers?src=linux_resource_menu -[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=7016000000127cYAAQ -[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?src=linux_resource_menu&intcmp=7016000000127cYAAQ -[5]:https://opensource.com/tags/linux?src=linux_resource_menu -[6]:https://opensource.com/article/17/6/linking-linux-filesystem?rate=YebHxA-zgNopDQKKOyX3_r25hGvnZms_33sYBUq-SMM -[7]:https://opensource.com/user/14106/feed -[8]:https://www.flickr.com/photos/digypho/7905320090 -[9]:https://creativecommons.org/licenses/by/2.0/ -[10]:https://opensource.com/article/17/5/introduction-ext4-filesystem -[11]:https://opensource.com/article/16/11/managing-devices-linux -[12]:https://opensource.com/life/16/10/introduction-linux-filesystems -[13]:https://opensource.com/business/16/9/linux-users-guide-lvm -[14]:https://opensource.com/life/15/9/everything-is-a-file -[15]:https://opensource.com/article/17/5/introduction-ext4-filesystem -[16]:https://opensource.com/article/17/5/introduction-ext4-filesystem#fig2 -[17]:https://opensource.com/users/dboth -[18]:https://opensource.com/article/17/6/linking-linux-filesystem#comments diff --git a/sources/tech/20170921 How to answer questions in a helpful way.md b/sources/tech/20170921 How to answer questions in a helpful way.md new file mode 100644 index 0000000000..8a3601ed06 --- /dev/null +++ b/sources/tech/20170921 How to answer questions in a helpful way.md @@ -0,0 +1,172 @@ +How to answer questions in a helpful way +============================================================ + +Your coworker asks you a slightly unclear question. How do you answer? I think asking questions is a skill (see [How to ask good questions][1]) and that answering questions in a helpful way is also a skill! Both of them are super useful. + +To start out with – sometimes the people asking you questions don’t respect your time, and that sucks. I’m assuming here throughout that that’s not what happening – we’re going to assume that the person asking you questions is a reasonable person who is trying their best to figure something out and that you want to help them out. Everyone I work with is like that and so that’s the world I live in :) + +Here are a few strategies for answering questions in a helpful way! + +### If they’re not asking clearly, help them clarify + +Often beginners don’t ask clear questions, or ask questions that don’t have the necessary information to answer the questions. Here are some strategies you can use to help them clarify. + +* **Rephrase a more specific question** back at them (“Are you asking X?”) + +* **Ask them for more specific information** they didn’t provide (“are you using IPv6?”) + +* **Ask what prompted their question**. For example, sometimes people come into my team’s channel with questions about how our service discovery works. Usually this is because they’re trying to set up/reconfigure a service. In that case it’s helpful to ask “which service are you working with? Can I see the pull request you’re working on?” + +A lot of these strategies come from the [how to ask good questions][2] post. (though I would never say to someone “oh you need to read this Document On How To Ask Good Questions before asking me a question”) + +### Figure out what they know already + +Before answering a question, it’s very useful to know what the person knows already! + +Harold Treen gave me a great example of this: + +> Someone asked me the other day to explain “Redux Sagas”. Rather than dive in and say “They are like worker threads that listen for actions and let you update the store!”  +> I started figuring out how much they knew about Redux, actions, the store and all these other fundamental concepts. From there it was easier to explain the concept that ties those other concepts together. + +Figuring out what your question-asker knows already is important because they may be confused about fundamental concepts (“What’s Redux?”), or they may be an expert who’s getting at a subtle corner case. An answer building on concepts they don’t know is confusing, and an answer that recaps things they know is tedious. + +One useful trick for asking what people know – instead of “Do you know X?”, maybe try “How familiar are you with X?”. + +### Point them to the documentation + +“RTFM” is the classic unhelpful answer to a question, but pointing someone to a specific piece of documentation can actually be really helpful! When I’m asking a question, I’d honestly rather be pointed to documentation that actually answers my question, because it’s likely to answer other questions I have too. + +I think it’s important here to make sure you’re linking to documentation that actually answers the question, or at least check in afterwards to make sure it helped. Otherwise you can end up with this (pretty common) situation: + +* Ali: How do I do X? + +* Jada: + +* Ali: That doesn’t actually explain how to X, it only explains Y! + +If the documentation I’m linking to is very long, I like to point out the specific part of the documentation I’m talking about. The [bash man page][3] is 44,000 words (really!), so just saying “it’s in the bash man page” is not that helpful :) + +### Point them to a useful search + +Often I find things at work by searching for some Specific Keyword that I know will find me the answer. That keyword might not be obvious to a beginner! So saying “this is the search I’d use to find the answer to that question” can be useful. Again, check in afterwards to make sure the search actually gets them the answer they need :) + +### Write new documentation + +People often come and ask my team the same questions over and over again. This is obviously not the fault of the people (how should  _they_  know that 10 people have asked this already, or what the answer is?). So we’re trying to, instead of answering the questions directly, + +1. Immediately write documentation + +2. Point the person to the new documentation we just wrote + +3. Celebrate! + +Writing documentation sometimes takes more time than just answering the question, but it’s often worth it! Writing documentation is especially worth it if: + +a. It’s a question which is being asked again and again b. The answer doesn’t change too much over time (if the answer changes every week or month, the documentation will just get out of date and be frustrating) + +### Explain what you did + +As a beginner to a subject, it’s really frustrating to have an exchange like this: + +* New person: “hey how do you do X?” + +* More Experienced Person: “I did it, it is done.” + +* New person: ….. but what did you DO?! + +If the person asking you is trying to learn how things work, it’s helpful to: + +* Walk them through how to accomplish a task instead of doing it yourself + +* Tell them the steps for how you got the answer you gave them! + +This might take longer than doing it yourself, but it’s a learning opportunity for the person who asked, so that they’ll be better equipped to solve such problems in the future. + +Then you can have WAY better exchanges, like this: + +* New person: “I’m seeing errors on the site, what’s happening?” + +* More Experienced Person: (2 minutes later) “oh that’s because there’s a database failover happening” + +* New person: how did you know that??!?!? + +* More Experienced Person: “Here’s what I did!”: + 1. Often these errors are due to Service Y being down. I looked at $PLACE and it said Service Y was up. So that wasn’t it. + + 2. Then I looked at dashboard X, and this part of that dashboard showed there was a database failover happening. + + 3. Then I looked in the logs for the service and it showed errors connecting to the database, here’s what those errors look like. + +If you’re explaining how you debugged a problem, it’s useful both to explain how you found out what the problem was, and how you found out what the problem wasn’t. While it might feel good to look like you knew the answer right off the top of your head, it feels even better to help someone improve at learning and diagnosis, and understand the resources available. + +### Solve the underlying problem + +This one is a bit tricky. Sometimes people think they’ve got the right path to a solution, and they just need one more piece of information to implement that solution. But they might not be quite on the right path! For example: + +* George: I’m doing X, and I got this error, how do I fix it + +* Jasminda: Are you actually trying to do Y? If so, you shouldn’t do X, you should do Z instead + +* George: Oh, you’re right!!! Thank you! I will do Z instead. + +Jasminda didn’t answer George’s question at all! Instead she guessed that George didn’t actually want to be doing X, and she was right. That is helpful! + +It’s possible to come off as condescending here though, like + +* George: I’m doing X, and I got this error, how do I fix it? + +* Jasminda: Don’t do that, you’re trying to do Y and you should do Z to accomplish that instead. + +* George: Well, I am not trying to do Y, I actually want to do X because REASONS. How do I do X? + +So don’t be condescending, and keep in mind that some questioners might be attached to the steps they’ve taken so far! It might be appropriate to answer both the question they asked and the one they should have asked: “Well, if you want to do X then you might try this, but if you’re trying to solve problem Y with that, you might have better luck doing this other thing, and here’s why that’ll work better”. + +### Ask “Did that answer your question?” + +I always like to check in after I  _think_  I’ve answered the question and ask “did that answer your question? Do you have more questions?”. + +It’s good to pause and wait after asking this because often people need a minute or two to know whether or not they’ve figured out the answer. I especially find this extra “did this answer your questions?” step helpful after writing documentation! Often when writing documentation about something I know well I’ll leave out something very important without realizing it. + +### Offer to pair program/chat in real life + +I work remote, so many of my conversations at work are text-based. I think of that as the default mode of communication. + +Today, we live in a world of easy video conferencing & screensharing! At work I can at any time click a button and immediately be in a video call/screensharing session with someone. Some problems are easier to talk about using your voices! + +For example, recently someone was asking about capacity planning/autoscaling for their service. I could tell there were a few things we needed to clear up but I wasn’t exactly sure what they were yet. We got on a quick video call and 5 minutes later we’d answered all their questions. + +I think especially if someone is really stuck on how to get started on a task, pair programming for a few minutes can really help, and it can be a lot more efficient than email/instant messaging. + +### Don’t act surprised + +This one’s a rule from the Recurse Center: [no feigning surprise][4]. Here’s a relatively common scenario + +* Human 1: “what’s the Linux kernel?” + +* Human 2: “you don’t know what the LINUX KERNEL is?!!!!?!!!???” + +Human 2’s reaction (regardless of whether they’re  _actually_  surprised or not) is not very helpful. It mostly just serves to make Human 1 feel bad that they don’t know what the Linux kernel is. + +I’ve worked on actually pretending not to be surprised even when I actually am a bit surprised the person doesn’t know the thing and it’s awesome. + +### Answering questions well is awesome + +Obviously not all these strategies are appropriate all the time, but hopefully you will find some of them helpful! I find taking the time to answer questions and teach people can be really rewarding. + +Special thanks to Josh Triplett for suggesting this post and making many helpful additions, and to Harold Treen, Vaibhav Sagar, Peter Bhat Harkins, Wesley Aptekar-Cassels, and Paul Gowder for reading/commenting. + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/answer-questions-well/ + +作者:[ Julia Evans][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/about +[1]:https://jvns.ca/blog/good-questions/ +[2]:https://jvns.ca/blog/good-questions/ +[3]:https://linux.die.net/man/1/bash +[4]:https://jvns.ca/blog/2017/04/27/no-feigning-surprise/ diff --git a/sources/tech/20171005 How to manage Linux containers with Ansible Container.md b/sources/tech/20171005 How to manage Linux containers with Ansible Container.md new file mode 100644 index 0000000000..897b793a86 --- /dev/null +++ b/sources/tech/20171005 How to manage Linux containers with Ansible Container.md @@ -0,0 +1,114 @@ +How to manage Linux containers with Ansible Container +============================================================ + +### Ansible Container addresses Dockerfile shortcomings and offers complete management for containerized projects. + +![Ansible Container: A new way to manage containers](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/container-ship.png?itok=pqZYgQ7K "Ansible Container: A new way to manage containers") +Image by : opensource.com + +I love containers and use the technology every day. Even so, containers aren't perfect. Over the past couple of months, however, a set of projects has emerged that addresses some of the problems I've experienced. + +I started using containers with [Docker][11], since this project made the technology so popular. Aside from using the container engine, I learned how to use **[docker-compose][6]** and started managing my projects with it. My productivity skyrocketed! One command to run my project, no matter how complex it was. I was so happy. + +After some time, I started noticing issues. The most apparent were related to the process of creating container images. The Docker tool uses a custom file format as a recipe to produce container images—Dockerfiles. This format is easy to learn, and after a short time you are ready to produce container images on your own. The problems arise once you want to master best practices or have complex scenarios in mind. + +More on Ansible + +* [How Ansible works][1] + +* [Free Ansible eBooks][2] + +* [Ansible quick start video][3] + +* [Download and install Ansible][4] + +Let's take a break and travel to a different land: the world of [Ansible][22]. You know it? It's awesome, right? You don't? Well, it's time to learn something new. Ansible is a project that allows you to manage your infrastructure by writing tasks and executing them inside environments of your choice. No need to install and set up any services; everything can easily run from your laptop. Many people already embrace Ansible. + +Imagine this scenario: You invested in Ansible, you wrote plenty of Ansible roles and playbooks that you use to manage your infrastructure, and you are thinking about investing in containers. What should you do? Start writing container image definitions via shell scripts and Dockerfiles? That doesn't sound right. + +Some people from the Ansible development team asked this question and realized that those same Ansible roles and playbooks that people wrote and use daily can also be used to produce container images. But not just that—they can be used to manage the complete lifecycle of containerized projects. From these ideas, the [Ansible Container][12] project was born. It utilizes existing Ansible roles that can be turned into container images and can even be used for the complete application lifecycle, from build to deploy in production. + +Let's talk about the problems I mentioned regarding best practices in context of Dockerfiles. A word of warning: This is going to be very specific and technical. Here are the top three issues I have: + +### 1\. Shell scripts embedded in Dockerfiles. + +When writing Dockerfiles, you can specify a script that will be interpreted via **/bin/sh -c**. It can be something like: + +``` +RUN dnf install -y nginx +``` + +where RUN is a Dockerfile instruction and the rest are its arguments (which are passed to shell). But imagine a more complex scenario: + +``` +RUN set -eux; \ +    \ +# this "case" statement is generated via "update.sh" +    %%ARCH-CASE%%; \ +    \ +    url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \ +    wget -O go.tgz "$url"; \ +    echo "${goRelSha256} *go.tgz" | sha256sum -c -; \ +``` + +This one is taken from [the official golang image][13]. It doesn't look pretty, right? + +### 2\. You can't parse Dockerfiles easily. + +Dockerfiles are a new format without a formal specification. This is tricky if you need to process Dockerfiles in your infrastructure (e.g., automate the build process a bit). The only specification is [the code][14] that is part of **dockerd**. The problem is that you can't use it as a library. The easiest solution is to write a parser on your own and hope for the best. Wouldn't it be better to use some well-known markup language, such as YAML or JSON? + +### 3\. It's hard to control. + +If you are familiar with the internals of container images, you may know that every image is composed of layers. Once the container is created, the layers are stacked onto each other (like pancakes) using union filesystem technology. The problem is, that you cannot explicitly control this layering—you can't say, "here starts a new layer." You are forced to change your Dockerfile in a way that may hurt readability. The bigger problem is that a set of best practices has to be followed to achieve optimal results—newcomers have a really hard time here. + +### Comparing Ansible language and Dockerfiles + +The biggest shortcoming of Dockerfiles in comparison to Ansible is that Ansible, as a language, is much more powerful. For example, Dockerfiles have no direct concept of variables, whereas Ansible has a complete templating system (variables are just one of its features). Ansible contains a large number of modules that can be easily utilized, such as [**wait_for**][15], which can be used for service readiness checks—e.g., wait until a service is ready before proceeding. With Dockerfiles, everything is a shell script. So if you need to figure out service readiness, it has to be done with shell (or installed separately). The other problem with shell scripts is that, with growing complexity, maintenance becomes a burden. Plenty of people have already figured this out and turned those shell scripts into Ansible. + +If you are interested in this topic and would like to know more, please come to [Open Source Summit][16] in Prague to see [my presentation][17] on Monday, Oct. 23, at 4:20 p.m. in Palmovka room. + + _Learn more in Tomas Tomecek's talk, [From Dockerfiles to Ansible Container][7], at [Open Source Summit EU][8], which will be held October 23-26 in Prague._ + + + +### About the author + + [![human](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/ja.jpeg?itok=4ATUEAbd)][18] Tomas Tomecek - Engineer. Hacker. Speaker. Tinker. Red Hatter. Likes containers, linux, open source, python 3, rust, zsh, tmux.[More about me][9] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/10/dockerfiles-ansible-container + +作者:[Tomas Tomecek ][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/tomastomecek +[1]:https://www.ansible.com/how-ansible-works?intcmp=701f2000000h4RcAAI +[2]:https://www.ansible.com/ebooks?intcmp=701f2000000h4RcAAI +[3]:https://www.ansible.com/quick-start-video?intcmp=701f2000000h4RcAAI +[4]:https://docs.ansible.com/ansible/latest/intro_installation.html?intcmp=701f2000000h4RcAAI +[5]:https://opensource.com/article/17/10/dockerfiles-ansible-container?imm_mid=0f9013&cmp=em-webops-na-na-newsltr_20171201&rate=Wiw_0D6PK_CAjqatYu_YQH0t1sNHEF6q09_9u3sYkCY +[6]:https://github.com/docker/compose +[7]:http://sched.co/BxIW +[8]:http://events.linuxfoundation.org/events/open-source-summit-europe +[9]:https://opensource.com/users/tomastomecek +[10]:https://opensource.com/user/175651/feed +[11]:https://opensource.com/tags/docker +[12]:https://www.ansible.com/ansible-container +[13]:https://github.com/docker-library/golang/blob/master/Dockerfile-debian.template#L14 +[14]:https://github.com/moby/moby/tree/master/builder/dockerfile +[15]:http://docs.ansible.com/wait_for_module.html +[16]:http://events.linuxfoundation.org/events/open-source-summit-europe +[17]:http://events.linuxfoundation.org/events/open-source-summit-europe/program/schedule +[18]:https://opensource.com/users/tomastomecek +[19]:https://opensource.com/users/tomastomecek +[20]:https://opensource.com/users/tomastomecek +[21]:https://opensource.com/article/17/10/dockerfiles-ansible-container?imm_mid=0f9013&cmp=em-webops-na-na-newsltr_20171201#comments +[22]:https://opensource.com/tags/ansible +[23]:https://opensource.com/tags/containers +[24]:https://opensource.com/tags/ansible +[25]:https://opensource.com/tags/docker +[26]:https://opensource.com/tags/open-source-summit diff --git a/sources/tech/20171005 Reasons Kubernetes is cool.md b/sources/tech/20171005 Reasons Kubernetes is cool.md new file mode 100644 index 0000000000..a9d10b9cdb --- /dev/null +++ b/sources/tech/20171005 Reasons Kubernetes is cool.md @@ -0,0 +1,148 @@ +Reasons Kubernetes is cool +============================================================ + +When I first learned about Kubernetes (a year and a half ago?) I really didn’t understand why I should care about it. + +I’ve been working full time with Kubernetes for 3 months or so and now have some thoughts about why I think it’s useful. (I’m still very far from being a Kubernetes expert!) Hopefully this will help a little in your journey to understand what even is going on with Kubernetes! + +I will try to explain some reason I think Kubenetes is interesting without using the words “cloud native”, “orchestration”, “container”, or any Kubernetes-specific terminology :). I’m going to explain this mostly from the perspective of a kubernetes operator / infrastructure engineer, since my job right now is to set up Kubernetes and make it work well. + +I’m not going to try to address the question of “should you use kubernetes for your production systems?” at all, that is a very complicated question. (not least because “in production” has totally different requirements depending on what you’re doing) + +### Kubernetes lets you run code in production without setting up new servers + +The first pitch I got for Kubernetes was the following conversation with my partner Kamal: + +Here’s an approximate transcript: + +* Kamal: With Kubernetes you can set up a new service with a single command + +* Julia: I don’t understand how that’s possible. + +* Kamal: Like, you just write 1 configuration file, apply it, and then you have a HTTP service running in production + +* Julia: But today I need to create new AWS instances, write a puppet manifest, set up service discovery, configure my load balancers, configure our deployment software, and make sure DNS is working, it takes at least 4 hours if nothing goes wrong. + +* Kamal: Yeah. With Kubernetes you don’t have to do any of that, you can set up a new HTTP service in 5 minutes and it’ll just automatically run. As long as you have spare capacity in your cluster it just works! + +* Julia: There must be a trap + +There kind of is a trap, setting up a production Kubernetes cluster is (in my experience) is definitely not easy. (see [Kubernetes The Hard Way][3] for what’s involved to get started). But we’re not going to go into that right now! + +So the first cool thing about Kubernetes is that it has the potential to make life way easier for developers who want to deploy new software into production. That’s cool, and it’s actually true, once you have a working Kubernetes cluster you really can set up a production HTTP service (“run 5 of this application, set up a load balancer, give it this DNS name, done”) with just one configuration file. It’s really fun to see. + +### Kubernetes gives you easy visibility & control of what code you have running in production + +IMO you can’t understand Kubernetes without understanding etcd. So let’s talk about etcd! + +Imagine that I asked you today “hey, tell me every application you have running in production, what host it’s running on, whether it’s healthy or not, and whether or not it has a DNS name attached to it”. I don’t know about you but I would need to go look in a bunch of different places to answer this question and it would take me quite a while to figure out. I definitely can’t query just one API. + +In Kubernetes, all the state in your cluster – applications running (“pods”), nodes, DNS names, cron jobs, and more – is stored in a single database (etcd). Every Kubernetes component is stateless, and basically works by + +* Reading state from etcd (eg “the list of pods assigned to node 1”) + +* Making changes (eg “actually start running pod A on node 1”) + +* Updating the state in etcd (eg “set the state of pod A to ‘running’”) + +This means that if you want to answer a question like “hey, how many nginx pods do I have running right now in that availabliity zone?” you can answer it by querying a single unified API (the Kubernetes API!). And you have exactly the same access to that API that every other Kubernetes component does. + +This also means that you have easy control of everything running in Kubernetes. If you want to, say, + +* Implement a complicated custom rollout strategy for deployments (deploy 1 thing, wait 2 minutes, deploy 5 more, wait 3.7 minutes, etc) + +* Automatically [start a new webserver][1] every time a branch is pushed to github + +* Monitor all your running applications to make sure all of them have a reasonable cgroups memory limit + +all you need to do is to write a program that talks to the Kubernetes API. (a “controller”) + +Another very exciting thing about the Kubernetes API is that you’re not limited to just functionality that Kubernetes provides! If you decide that you have your own opinions about how your software should be deployed / created / monitored, then you can write code that uses the Kubernetes API to do it! It lets you do everything you need. + +### If every Kubernetes component dies, your code will still keep running + +One thing I was originally promised (by various blog posts :)) about Kubernetes was “hey, if the Kubernetes apiserver and everything else dies, it’s ok, your code will just keep running”. I thought this sounded cool in theory but I wasn’t sure if it was actually true. + +So far it seems to be actually true! + +I’ve been through some etcd outages now, and what happens is + +1. All the code that was running keeps running + +2. Nothing  _new_  happens (you can’t deploy new code or make changes, cron jobs will stop working) + +3. When everything comes back, the cluster will catch up on whatever it missed + +This does mean that if etcd goes down and one of your applications crashes or something, it can’t come back up until etcd returns. + +### Kubernetes’ design is pretty resilient to bugs + +Like any piece of software, Kubernetes has bugs. For example right now in our cluster the controller manager has a memory leak, and the scheduler crashes pretty regularly. Bugs obviously aren’t good but so far I’ve found that Kubernetes’ design helps mitigate a lot of the bugs in its core components really well. + +If you restart any component, what happens is: + +* It reads all its relevant state from etcd + +* It starts doing the necessary things it’s supposed to be doing based on that state (scheduling pods, garbage collecting completed pods, scheduling cronjobs, deploying daemonsets, whatever) + +Because all the components don’t keep any state in memory, you can just restart them at any time and that can help mitigate a variety of bugs. + +For example! Let’s say you have a memory leak in your controller manager. Because the controller manager is stateless, you can just periodically restart it every hour or something and feel confident that you won’t cause any consistency issues. Or we ran into a bug in the scheduler where it would sometimes just forget about pods and never schedule them. You can sort of mitigate this just by restarting the scheduler every 10 minutes. (we didn’t do that, we fixed the bug instead, but you  _could_  :) ) + +So I feel like I can trust Kubernetes’ design to help make sure the state in the cluster is consistent even when there are bugs in its core components. And in general I think the software is generally improving over time. The only stateful thing you have to operate is etcd + +Not to harp on this “state” thing too much but – I think it’s cool that in Kubernetes the only thing you have to come up with backup/restore plans for is etcd (unless you use persistent volumes for your pods). I think it makes kubernetes operations a lot easier to think about. + +### Implementing new distributed systems on top of Kubernetes is relatively easy + +Suppose you want to implement a distributed cron job scheduling system! Doing that from scratch is a ton of work. But implementing a distributed cron job scheduling system inside Kubernetes is much easier! (still not trivial, it’s still a distributed system) + +The first time I read the code for the Kubernetes cronjob controller I was really delighted by how simple it was. Here, go read it! The main logic is like 400 lines of Go. Go ahead, read it! => [cronjob_controller.go][4] <= + +Basically what the cronjob controller does is: + +* Every 10 seconds: + * Lists all the cronjobs that exist + + * Checks if any of them need to run right now + + * If so, creates a new Job object to be scheduled & actually run by other Kubernetes controllers + + * Clean up finished jobs + + * Repeat + +The Kubernetes model is pretty constrained (it has this pattern of resources are defined in etcd, controllers read those resources and update etcd), and I think having this relatively opinionated/constrained model makes it easier to develop your own distributed systems inside the Kubernetes framework. + +Kamal introduced me to this idea of “Kubernetes is a good platform for writing your own distributed systems” instead of just “Kubernetes is a distributed system you can use” and I think it’s really interesting. He has a prototype of a [system to run an HTTP service for every branch you push to github][5]. It took him a weekend and is like 800 lines of Go, which I thought was impressive! + +### Kubernetes lets you do some amazing things (but isn’t easy) + +I started out by saying “kubernetes lets you do these magical things, you can just spin up so much infrastructure with a single configuration file, it’s amazing”. And that’s true! + +What I mean by “Kubernetes isn’t easy” is that Kubernetes has a lot of moving parts learning how to successfully operate a highly available Kubernetes cluster is a lot of work. Like I find that with a lot of the abstractions it gives me, I need to understand what is underneath those abstractions in order to debug issues and configure things properly. I love learning new things so this doesn’t make me angry or anything, I just think it’s important to know :) + +One specific example of “I can’t just rely on the abstractions” that I’ve struggled with is that I needed to learn a LOT [about how networking works on Linux][6] to feel confident with setting up Kubernetes networking, way more than I’d ever had to learn about networking before. This was very fun but pretty time consuming. I might write more about what is hard/interesting about setting up Kubernetes networking at some point. + +Or I wrote a [2000 word blog post][7] about everything I had to learn about Kubernetes’ different options for certificate authorities to be able to set up my Kubernetes CAs successfully. + +I think some of these managed Kubernetes systems like GKE (google’s kubernetes product) may be simpler since they make a lot of decisions for you but I haven’t tried any of them. + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/10/05/reasons-kubernetes-is-cool/ + +作者:[ Julia Evans][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/about +[1]:https://github.com/kamalmarhubi/kubereview +[2]:https://jvns.ca/categories/kubernetes +[3]:https://github.com/kelseyhightower/kubernetes-the-hard-way +[4]:https://github.com/kubernetes/kubernetes/blob/e4551d50e57c089aab6f67333412d3ca64bc09ae/pkg/controller/cronjob/cronjob_controller.go +[5]:https://github.com/kamalmarhubi/kubereview +[6]:https://jvns.ca/blog/2016/12/22/container-networking/ +[7]:https://jvns.ca/blog/2017/08/05/how-kubernetes-certificates-work/ diff --git a/sources/tech/20171010 Operating a Kubernetes network.md b/sources/tech/20171010 Operating a Kubernetes network.md new file mode 100644 index 0000000000..9c85e9aa70 --- /dev/null +++ b/sources/tech/20171010 Operating a Kubernetes network.md @@ -0,0 +1,216 @@ +Operating a Kubernetes network +============================================================ + +I’ve been working on Kubernetes networking a lot recently. One thing I’ve noticed is, while there’s a reasonable amount written about how to **set up** your Kubernetes network, I haven’t seen much about how to **operate** your network and be confident that it won’t create a lot of production incidents for you down the line. + +In this post I’m going to try to convince you of three things: (all I think pretty reasonable :)) + +* Avoiding networking outages in production is important + +* Operating networking software is hard + +* It’s worth thinking critically about major changes to your networking infrastructure and the impact that will have on your reliability, even if very fancy Googlers say “this is what we do at Google”. (google engineers are doing great work on Kubernetes!! But I think it’s important to still look at the architecture and make sure it makes sense for your organization.) + +I’m definitely not a Kubernetes networking expert by any means, but I have run into a few issues while setting things up and definitely know a LOT more about Kubernetes networking than I used to. + +### Operating networking software is hard + +Here I’m not talking about operating physical networks (I don’t know anything about that), but instead about keeping software like DNS servers & load balancers & proxies working correctly. + +I have been working on a team that’s responsible for a lot of networking infrastructure for a year, and I have learned a few things about operating networking infrastructure! (though I still have a lot to learn obviously). 3 overall thoughts before we start: + +* Networking software often relies very heavily on the Linux kernel. So in addition to configuring the software correctly you also need to make sure that a bunch of different sysctls are set correctly, and a misconfigured sysctl can easily be the difference between “everything is 100% fine” and “everything is on fire”. + +* Networking requirements change over time (for example maybe you’re doing 5x more DNS lookups than you were last year! Maybe your DNS server suddenly started returning TCP DNS responses instead of UDP which is a totally different kernel workload!). This means software that was working fine before can suddenly start having issues. + +* To fix a production networking issues you often need a lot of expertise. (for example see this [great post by Sophie Haskins on debugging a kube-dns issue][1]) I’m a lot better at debugging networking issues than I was, but that’s only after spending a huge amount of time investing in my knowledge of Linux networking. + +I am still far from an expert at networking operations but I think it seems important to: + +1. Very rarely make major changes to the production networking infrastructure (because it’s super disruptive) + +2. When you  _are_  making major changes, think really carefully about what the failure modes are for the new network architecture are + +3. Have multiple people who are able to understand your networking setup + +Switching to Kubernetes is obviously a pretty major networking change! So let’s talk about what some of the things that can go wrong are! + +### Kubernetes networking components + +The Kubernetes networking components we’re going to talk about in this post are: + +* Your overlay network backend (like flannel/calico/weave net/romana) + +* `kube-dns` + +* `kube-proxy` + +* Ingress controllers / load balancers + +* The `kubelet` + +If you’re going to set up HTTP services you probably need all of these. I’m not using most of these components yet but I’m trying to understand them, so that’s what this post is about. + +### The simplest way: Use host networking for all your containers + +Let’s start with the simplest possible thing you can do. This won’t let you run HTTP services in Kubernetes. I think it’s pretty safe because there are less moving parts. + +If you use host networking for all your containers I think all you need to do is: + +1. Configure the kubelet to configure DNS correctly inside your containers + +2. That’s it + +If you use host networking for literally every pod you don’t need kube-dns or kube-proxy. You don’t even need a working overlay network. + +In this setup your pods can connect to the outside world (the same way any process on your hosts would talk to the outside world) but the outside world can’t connect to your pods. + +This isn’t super important (I think most people want to run HTTP services inside Kubernetes and actually communicate with those services) but I do think it’s interesting to realize that at some level all of this networking complexity isn’t strictly required and sometimes you can get away without using it. Avoiding networking complexity seems like a good idea to me if you can. + +### Operating an overlay network + +The first networking component we’re going to talk about is your overlay network. Kubernetes assumes that every pod has an IP address and that you can communicate with services inside that pod by using that IP address. When I say “overlay network” this is what I mean (“the system that lets you refer to a pod by its IP address”). + +All other Kubernetes networking stuff relies on the overlay networking working correctly. You can read more about the [kubernetes networking model here][10]. + +The way Kelsey Hightower describes in [kubernetes the hard way][11] seems pretty good but it’s not really viable on AWS for clusters more than 50 nodes or so, so I’m not going to talk about that. + +There are a lot of overlay network backends (calico, flannel, weaveworks, romana) and the landscape is pretty confusing. But as far as I’m concerned an overlay network has 2 responsibilities: + +1. Make sure your pods can send network requests outside your cluster + +2. Keep a stable mapping of nodes to subnets and keep every node in your cluster updated with that mapping. Do the right thing when nodes are added & removed. + +Okay! So! What can go wrong with your overlay network? + +* The overlay network is responsible for setting up iptables rules (basically `iptables -A -t nat POSTROUTING -s $SUBNET -j MASQUERADE`) to ensure that containers can make network requests outside Kubernetes. If something goes wrong with this rule then your containers can’t connect to the external network. This isn’t that hard (it’s just a few iptables rules) but it is important. I made a [pull request][2] because I wanted to make sure this was resilient + +* Something can go wrong with adding or deleting nodes. We’re using the flannel hostgw backend and at the time we started using it, node deletion [did not work][3]. + +* Your overlay network is probably dependent on a distributed database (etcd). If that database has an incident, this can cause issues. For example [https://github.com/coreos/flannel/issues/610][4] says that if you have data loss in your flannel etcd cluster it can result in containers losing network connectivity. (this has now been fixed) + +* You upgrade Docker and everything breaks + +* Probably more things! + +I’m mostly talking about past issues in Flannel here but I promise I’m not picking on Flannel – I actually really **like** Flannel because I feel like it’s relatively simple (for instance the [vxlan backend part of it][12] is like 500 lines of code) and I feel like it’s possible for me to reason through any issues with it. And it’s obviously continuously improving. They’ve been great about reviewing pull requests. + +My approach to operating an overlay network so far has been: + +* Learn how it works in detail and how to debug it (for example the hostgw network backend for Flannel works by creating routes, so you mostly just need to do `sudo ip route list` to see whether it’s doing the correct thing) + +* Maintain an internal build so it’s easy to patch it if needed + +* When there are issues, contribute patches upstream + +I think it’s actually really useful to go through the list of merged PRs and see bugs that have been fixed in the past – it’s a bit time consuming but is a great way to get a concrete list of kinds of issues other people have run into. + +It’s possible that for other people their overlay networks just work but that hasn’t been my experience and I’ve heard other folks report similar issues. If you have an overlay network setup that is a) on AWS and b) works on a cluster more than 50-100 nodes where you feel more confident about operating it I would like to know. + +### Operating kube-proxy and kube-dns? + +Now that we have some thoughts about operating overlay networks, let’s talk about + +There’s a question mark next to this one because I haven’t done this. Here I have more questions than answers. + +Here’s how Kubernetes services work! A service is a collection of pods, which each have their own IP address (like 10.1.0.3, 10.2.3.5, 10.3.5.6) + +1. Every Kubernetes service gets an IP address (like 10.23.1.2) + +2. `kube-dns` resolves Kubernetes service DNS names to IP addresses (so my-svc.my-namespace.svc.cluster.local might map to 10.23.1.2) + +3. `kube-proxy` sets up iptables rules in order to do random load balancing between them. Kube-proxy also has a userspace round-robin load balancer but my impression is that they don’t recommend using it. + +So when you make a request to `my-svc.my-namespace.svc.cluster.local`, it resolves to 10.23.1.2, and then iptables rules on your local host (generated by kube-proxy) redirect it to one of 10.1.0.3 or 10.2.3.5 or 10.3.5.6 at random. + +Some things that I can imagine going wrong with this: + +* `kube-dns` is misconfigured + +* `kube-proxy` dies and your iptables rules don’t get updated + +* Some issue related to maintaining a large number of iptables rules + +Let’s talk about the iptables rules a bit, since doing load balancing by creating a bajillion iptables rules is something I had never heard of before! + +kube-proxy creates one iptables rule per target host like this: (these rules are from [this github issue][13]) + +``` +-A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -m statistic --mode random --probability 0.20000000019 -j KUBE-SEP-E4QKA7SLJRFZZ2DD[b][c] +-A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -m statistic --mode random --probability 0.25000000000 -j KUBE-SEP-LZ7EGMG4DRXMY26H +-A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -m statistic --mode random --probability 0.33332999982 -j KUBE-SEP-RKIFTWKKG3OHTTMI +-A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-CGDKBCNM24SZWCMS +-A KUBE-SVC-LI77LBOOMGYET5US -m comment --comment "default/showreadiness:showreadiness" -j KUBE-SEP-RI4SRNQQXWSTGE2Y + +``` + +So kube-proxy creates a **lot** of iptables rules. What does that mean? What are the implications of that in for my network? There’s a great talk from Huawei called [Scale Kubernetes to Support 50,000 services][14] that says if you have 5,000 services in your kubernetes cluster, it takes **11 minutes** to add a new rule. If that happened to your real cluster I think it would be very bad. + +I definitely don’t have 5,000 services in my cluster, but 5,000 isn’t SUCH a bit number. The proposal they give to solve this problem is to replace this iptables backend for kube-proxy with IPVS which is a load balancer that lives in the Linux kernel. + +It seems like kube-proxy is going in the direction of various Linux kernel based load balancers. I think this is partly because they support UDP load balancing, and other load balancers (like HAProxy) don’t support UDP load balancing. + +But I feel comfortable with HAProxy! Is it possible to replace kube-proxy with HAProxy! I googled this and I found this [thread on kubernetes-sig-network][15] saying: + +> kube-proxy is so awesome, we have used in production for almost a year, it works well most of time, but as we have more and more services in our cluster, we found it was getting hard to debug and maintain. There is no iptables expert in our team, we do have HAProxy&LVS experts, as we have used these for several years, so we decided to replace this distributed proxy with a centralized HAProxy. I think this maybe useful for some other people who are considering using HAProxy with kubernetes, so we just update this project and make it open source: [https://github.com/AdoHe/kube2haproxy][5]. If you found it’s useful , please take a look and give a try. + +So that’s an interesting option! I definitely don’t have answers here, but, some thoughts: + +* Load balancers are complicated + +* DNS is also complicated + +* If you already have a lot of experience operating one kind of load balancer (like HAProxy), it might make sense to do some extra work to use that instead of starting to use an entirely new kind of load balancer (like kube-proxy) + +* I’ve been thinking about where we want to be using kube-proxy or kube-dns at all – I think instead it might be better to just invest in Envoy and rely entirely on Envoy for all load balancing & service discovery. So then you just need to be good at operating Envoy. + +As you can see my thoughts on how to operate your Kubernetes internal proxies are still pretty confused and I’m still not super experienced with them. It’s totally possible that kube-proxy and kube-dns are fine and that they will just work fine but I still find it helpful to think through what some of the implications of using them are (for example “you can’t have 5,000 Kubernetes services”). + +### Ingress + +If you’re running a Kubernetes cluster, it’s pretty likely that you actually need HTTP requests to get into your cluster so far. This blog post is already too long and I don’t know much about ingress yet so we’re not going to talk about that. + +### Useful links + +A couple of useful links, to summarize: + +* [The Kubernetes networking model][6] + +* How GKE networking works: [https://www.youtube.com/watch?v=y2bhV81MfKQ][7] + +* The aforementioned talk on `kube-proxy` performance: [https://www.youtube.com/watch?v=4-pawkiazEg][8] + +### I think networking operations is important + +My sense of all this Kubernetes networking software is that it’s all still quite new and I’m not sure we (as a community) really know how to operate all of it well. This makes me worried as an operator because I really want my network to keep working! :) Also I feel like as an organization running your own Kubernetes cluster you need to make a pretty large investment into making sure you understand all the pieces so that you can fix things when they break. Which isn’t a bad thing, it’s just a thing. + +My plan right now is just to keep learning about how things work and reduce the number of moving parts I need to worry about as much as possible. + +As usual I hope this was helpful and I would very much like to know what I got wrong in this post! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/10/10/operating-a-kubernetes-network/ + +作者:[Julia Evans ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/about +[1]:http://blog.sophaskins.net/blog/misadventures-with-kube-dns/ +[2]:https://github.com/coreos/flannel/pull/808 +[3]:https://github.com/coreos/flannel/pull/803 +[4]:https://github.com/coreos/flannel/issues/610 +[5]:https://github.com/AdoHe/kube2haproxy +[6]:https://kubernetes.io/docs/concepts/cluster-administration/networking/#kubernetes-model +[7]:https://www.youtube.com/watch?v=y2bhV81MfKQ +[8]:https://www.youtube.com/watch?v=4-pawkiazEg +[9]:https://jvns.ca/categories/kubernetes +[10]:https://kubernetes.io/docs/concepts/cluster-administration/networking/#kubernetes-model +[11]:https://github.com/kelseyhightower/kubernetes-the-hard-way/blob/master/docs/11-pod-network-routes.md +[12]:https://github.com/coreos/flannel/tree/master/backend/vxlan +[13]:https://github.com/kubernetes/kubernetes/issues/37932 +[14]:https://www.youtube.com/watch?v=4-pawkiazEg +[15]:https://groups.google.com/forum/#!topic/kubernetes-sig-network/3NlBVbTUUU0 diff --git a/sources/tech/20171011 LEAST PRIVILEGE CONTAINER ORCHESTRATION.md b/sources/tech/20171011 LEAST PRIVILEGE CONTAINER ORCHESTRATION.md new file mode 100644 index 0000000000..7a9b6e817c --- /dev/null +++ b/sources/tech/20171011 LEAST PRIVILEGE CONTAINER ORCHESTRATION.md @@ -0,0 +1,174 @@ +# LEAST PRIVILEGE CONTAINER ORCHESTRATION + + +The Docker platform and the container has become the standard for packaging, deploying, and managing applications. In order to coordinate running containers across multiple nodes in a cluster, a key capability is required: a container orchestrator. + +![container orchestrator](https://i0.wp.com/blog.docker.com/wp-content/uploads/f753d4e8-9e22-4fe2-be9a-80661ef696a8-3.jpg?resize=536%2C312&ssl=1) + +Orchestrators are responsible for critical clustering and scheduling tasks, such as: + +* Managing container scheduling and resource allocation. + +* Support service discovery and hitless application deploys. + +* Distribute the necessary resources that applications need to run. + +Unfortunately, the distributed nature of orchestrators and the ephemeral nature of resources in this environment makes securing orchestrators a challenging task. In this post, we will describe in detail the less-considered—yet vital—aspect of the security model of container orchestrators, and how Docker Enterprise Edition with its built-in orchestration capability, Swarm mode, overcomes these difficulties. + +Motivation and threat model +============================================================ + +One of the primary objectives of Docker EE with swarm mode is to provide an orchestrator with security built-in. To achieve this goal, we developed the first container orchestrator designed with the principle of least privilege in mind. + +In computer science,the principle of least privilege in a distributed system requires that each participant of the system must only have access to  the information and resources that are necessary for its legitimate purpose. No more, no less. + +> #### ”A process must be able to access only the information and resources that are necessary for its legitimate purpose.” + +#### Principle of Least Privilege + +Each node in a Docker EE swarm is assigned role: either manager or worker. These roles define a coarsegrained level of privilege to the nodes: administration and task execution, respectively. However, regardless of its role, a node has access only to the information and resources it needs to perform the necessary tasks, with cryptographically enforced guarantees. As a result, it becomes easier to secure clusters against even the most sophisticated attacker models: attackers that control the underlying communication networks or even compromised cluster nodes. + +# Secure-by-default core + +There is an old security maxim that states: if it doesn’t come by default, no one will use it. Docker Swarm mode takes this notion to heart, and ships with secure-by-default mechanisms to solve three of the hardest and most important aspects of the orchestration lifecycle: + +1. Trust bootstrap and node introduction. + +2. Node identity issuance and management. + +3. Authenticated, Authorized, Encrypted information storage and dissemination. + +Let’s look at each of these aspects individually + +### Trust Bootstrap and Node Introduction + +The first step to a secure cluster is tight control over membership and identity. Without it, administrators cannot rely on the identities of their nodes and enforce strict workload separation between nodes. This means that unauthorized nodes can’t be allowed to join the cluster, and nodes that are already part of the cluster aren’t able to change identities, suddenly pretending to be another node. + +To address this need, nodes managed by Docker EE’s Swarm mode maintain strong, immutable identities. The desired properties are cryptographically guaranteed by using two key building-blocks: + +1. Secure join tokens for cluster membership. + +2. Unique identities embedded in certificates issued from a central certificate authority. + +### Joining the Swarm + +To join the swarm, a node needs a copy of a secure join token. The token is unique to each operational role within the cluster—there are currently two types of nodes: workers and managers. Due to this separation, a node with a copy of a worker token will not be allowed to join the cluster as a manager. The only way to get this special token is for a cluster administrator to interactively request it from the cluster’s manager through the swarm administration API. + +The token is securely and randomly generated, but it also has a special syntax that makes leaks of this token easier to detect: a special prefix that you can easily monitor for in your logs and repositories. Fortunately, even if a leak does occur, tokens are easy to rotate, and we recommend that you rotate them often—particularly in the case where your cluster will not be scaling up for a while. + +![Docker Swarm](https://i1.wp.com/blog.docker.com/wp-content/uploads/92d171d4-52c7-4702-8143-110c6f52017c-2.jpg?resize=547%2C208&ssl=1) + +### Bootstrapping trust + +As part of establishing its identity, a new node will ask for a new identity to be issued by any of the network managers. However, under our threat model, all communications can be intercepted by a third-party. This begs the question: how does a node know that it is talking to a legitimate manager? + +![Docker Security](https://i0.wp.com/blog.docker.com/wp-content/uploads/94e3fef0-5bd2-4970-b9e9-25b566d926ad-2.jpg?resize=528%2C348&ssl=1) + +Fortunately, Docker has a built-in mechanism for preventing this from happening. The join token, which the host uses to join the swarm, includes a hash of the root CA’s certificate. The host can therefore use one-way TLS and use the hash to verify that it’s joining the right swarm: if the manager presents a certificate not signed by a CA that matches the hash, the node knows not to trust it. + +### Node identity issuance and management + +Identities in a swarm are embedded in x509 certificates held by each individual node. In a manifestation of the least privilege principle, the certificates’ private keys are restricted strictly to the hosts where they originate. In particular, managers do not have access to private keys of any certificate but their own. + +### Identity Issuance + +To receive their certificates without sharing their private keys, new hosts begin by issuing a certificate signing request (CSR), which the managers then convert into a certificate. This certificate now becomes the new host’s identity, making the node a full-fledged member of the swarm! + +#### +![](https://i0.wp.com/blog.docker.com/wp-content/uploads/415ae6cf-7e76-4ba8-9d84-6d49bf327d8f-2.jpg?resize=548%2C350&ssl=1) + +When used alongside with the secure bootstrapping mechanism, this mechanism for issuing identities to joining nodes is secure by default: all communicating parties are authenticated, authorized and no sensitive information is ever exchanged in clear-text. + +### Identity Renewal + +However, securely joining nodes to a swarm is only part of the story. To minimize the impact of leaked or stolen certificates and to remove the complexity of managing CRL lists, Swarm mode uses short-lived certificates for the identities. These certificates have a default expiration of three months, but can be configured to expire every hour! + +![Docker secrets](https://i0.wp.com/blog.docker.com/wp-content/uploads/55e2ab9a-19cd-465d-82c6-fa76110e7ecd-2.jpg?resize=556%2C365&ssl=1) + +This short certificate expiration time means that certificate rotation can’t be a manual process, as it usually is for most PKI systems. With swarm, all certificates are rotated automatically and in a hitless fashion. The process is simple: using a mutually authenticated TLS connection to prove ownership over a particular identity, a Swarm node generates regularly a new public/private key pair and sends the corresponding CSR to be signed, creating a completely new certificate, but maintaining the same identity. + +### Authenticated, Authorized, Encrypted information storage and dissemination. + +During the normal operation of a swarm, information about the tasks has to be sent to the worker nodes for execution. This includes not only information on which containers are to be executed by a node;but also, it includes  all the resources that are necessary for the successful execution of that container, including sensitive secrets such as private keys, passwords, and API tokens. + +### Transport Security + +The fact that every node participating in a swarm is in possession of a unique identity in the form of a X509 certificate, communicating securely between nodes is trivial: nodes can use their respective certificates to establish mutually authenticated connections between one another, inheriting the confidentiality, authenticity and integrity properties of TLS. + +![Swarm Mode](https://i0.wp.com/blog.docker.com/wp-content/uploads/972273a3-d9e5-4053-8fcb-a407c8cdcbf6-2.jpg?resize=347%2C271&ssl=1) + +One interesting detail about Swarm mode is the fact that it uses a push model: only managers are allowed to send information to workers—significantly reducing the surface of attack manager nodes expose to the less privileged worker nodes. + +### Strict Workload Separation Into Security Zones + +One of the responsibilities of manager nodes is deciding which tasks to send to each of the workers. Managers make this determination using a variety of strategies; scheduling the workloads across the swarm depending on both the unique properties of each node and each workload. + +In Docker EE with Swarm mode, administrators have the ability of influencing these scheduling decisions by using labels that are securely attached to the individual node identities. These labels allow administrators to group nodes together into different security zones limiting the exposure of particularly sensitive workloads and any secrets related to them. + +![Docker Swarm Security](https://i0.wp.com/blog.docker.com/wp-content/uploads/67ffa551-d4ae-4522-ba13-4a646a158592-2.jpg?resize=546%2C375&ssl=1) + +### Secure Secret Distribution + +In addition to facilitating the identity issuance process, manager nodes have the important task of storing and distributing any resources needed by a worker. Secrets are treated like any other type of resource, and are pushed down from the manager to the worker over the secure mTLS connection. + +![Docker Secrets](https://i1.wp.com/blog.docker.com/wp-content/uploads/4341da98-2f8c-4aed-bb40-607246344dd8-2.jpg?resize=508%2C326&ssl=1) + +On the hosts, Docker EE ensures that secrets are provided only to the containers they are destined for. Other containers on the same host will not have access to them. Docker exposes secrets to a container as a temporary file system, ensuring that secrets are always stored in memory and never written to disk. This method is more secure than competing alternatives, such as [storing them in environment variables][12]. Once a task completes the secret is gone forever. + +### Storing secrets + +On manager hosts secrets are always encrypted at rest. By default, the key that encrypts these secrets (known as the Data Encryption Key, DEK) is also stored in plaintext on disk. This makes it easy for those with minimal security requirements to start using Docker Swarm mode. + +However, once you are running a production cluster, we recommend you enable auto-lock mode. When auto-lock mode is enabled, a newly rotated DEK is encrypted with a separate Key Encryption Key (KEK). This key is never stored on the cluster; the administrator is responsible for storing it securely and providing it when the cluster starts up. This is known as unlocking the swarm. + +Swarm mode supports multiple managers, relying on the Raft Consensus Algorithm for fault tolerance. Secure secret storage scales seamlessly in this scenario. Each manager host has a unique disk encryption key, in addition to the shared key. Furthermore, Raft logs are encrypted on disk and are similarly unavailable without the KEK when in autolock mode. + +### What happens when a node is compromised? + +![Docker Secrets](https://i0.wp.com/blog.docker.com/wp-content/uploads/2a78b37d-bbf0-40ee-a282-eb0900f71ba9-2.jpg?resize=502%2C303&ssl=1) + +In traditional orchestrators, recovering from a compromised host is a slow and complicated process. With Swarm mode, recovery is as easy as running the docker node rm command. This removes the affected node from the cluster, and Docker will take care of the rest, namely re-balancing services and making sure other hosts know not to talk to the affected node. + +As we have seen, thanks to least privilege orchestration, even if the attacker were still active on the host, they would be cut off from the rest of the network. The host’s certificate — its identity — is blacklisted, so the managers will not accept it as valid. + +# Conclusion + +Docker EE with Swarm mode ensures security by default in all key areas of orchestration: + +* Joining the cluster. Prevents malicious nodes from joining the cluster. + +* Organizing hosts into security zones. Prevents lateral movement by attackers. + +* Scheduling tasks. Tasks will be issued only to designated and allowed nodes. + +* Allocating resources. A malicious node cannot “steal” another’s workload or resources. + +* Storing secrets. Never stored in plaintext and never written to disk on worker nodes. + +* Communicating with the workers. Encrypted using mutually authenticated TLS. + +As Swarm mode continues to improve, the Docker team is working to take the principle of least privilege orchestration even further. The task we are tackling is: how can systems remain secure if a manager is compromised? The roadmap is in place, with some of the features already available such as the ability of whitelisting only specific Docker images, preventing managers from executing arbitrary workloads. This is achieved quite naturally using Docker Content Trust. + +-------------------------------------------------------------------------------- + +via: https://blog.docker.com/2017/10/least-privilege-container-orchestration/ + +作者:[Diogo Mónica ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://blog.docker.com/author/diogo/ +[1]:http://www.linkedin.com/shareArticle?mini=true&url=http://dockr.ly/2yZoNdy&title=Least%20Privilege%20Container%20Orchestration&summary=The%20Docker%20platform%20and%20the%20container%20has%20become%20the%20standard%20for%20packaging,%20deploying,%20and%20managing%20applications.%20In%20order%20to%20coordinate%20running%20containers%20across%20multiple%20nodes%20in%20a%20cluster,%20a%20key%20capability%20is%20required:%20a%20container%20orchestrator.Orchestrators%20are%20responsible%20for%20critical%20clustering%20and%20scheduling%20tasks,%20such%20as:%20%20%20%20Managing%20... +[2]:http://www.reddit.com/submit?url=http://dockr.ly/2yZoNdy&title=Least%20Privilege%20Container%20Orchestration +[3]:https://plus.google.com/share?url=http://dockr.ly/2yZoNdy +[4]:http://news.ycombinator.com/submitlink?u=http://dockr.ly/2yZoNdy&t=Least%20Privilege%20Container%20Orchestration +[5]:https://blog.docker.com/author/diogo/ +[6]:https://blog.docker.com/tag/docker-orchestration/ +[7]:https://blog.docker.com/tag/docker-secrets/ +[8]:https://blog.docker.com/tag/docker-security/ +[9]:https://blog.docker.com/tag/docker-swarm/ +[10]:https://blog.docker.com/tag/least-privilege-orchestrator/ +[11]:https://blog.docker.com/tag/tls/ +[12]:https://diogomonica.com/2017/03/27/why-you-shouldnt-use-env-variables-for-secret-data/ diff --git a/sources/tech/20171020 How Eclipse is advancing IoT development.md b/sources/tech/20171020 How Eclipse is advancing IoT development.md deleted file mode 100644 index 30fd8eb64d..0000000000 --- a/sources/tech/20171020 How Eclipse is advancing IoT development.md +++ /dev/null @@ -1,83 +0,0 @@ -apply for translating - -How Eclipse is advancing IoT development -============================================================ - -### Open source organization's modular approach to development is a good match for the Internet of Things. - -![How Eclipse is advancing IoT development](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_BUS_ArchitectureOfParticipation_520x292.png?itok=FA0Uuwzv "How Eclipse is advancing IoT development") -Image by : opensource.com - -[Eclipse][3] may not be the first open source organization that pops to mind when thinking about Internet of Things (IoT) projects. After all, the foundation has been around since 2001, long before IoT was a household word, supporting a community for commercially viable open source software development. - -September's Eclipse IoT Day, held in conjunction with RedMonk's [ThingMonk 2017][4] event, emphasized the big role Eclipse is taking in [IoT development][5]. It currently hosts 28 projects that touch a wide range of IoT needs and projects. While at the conference, I talked with [Ian Skerritt][6], who heads marketing for Eclipse, about Eclipse's IoT projects and how Eclipse thinks about IoT more broadly. - -### What's new about IoT? - -I asked Ian how IoT is different from traditional industrial automation, given that sensors and tools have been connected in factories for the past several decades. Ian notes that many factories still are not connected. - -Additionally, he says, "SCADA [supervisory control and data analysis] systems and even the factory floor technology are very proprietary, very siloed. It's hard to change it. It's hard to adapt to it… Right now, when you set up a manufacturing run, you need to manufacture hundreds of thousands of that piece, of that unit. What [manufacturers] want to do is to meet customer demand, to have manufacturing processes that are very flexible, that you can actually do a lot size of one." That's a big piece of what IoT is bringing to manufacturing. - -### Eclipse's approach to IoT - -He describes Eclipse's involvement in IoT by saying: "There's core fundamental technology that every IoT solution needs," and by using open source, "everyone can use it so they can get broader adoption." He says Eclipse see IoT as consisting of three connected software stacks. At a high level, these stacks mirror the (by now familiar) view that IoT can usually be described as spanning three layers. A given implementation may have even more layers, but they still generally map to the functions of this three-layer model: - -* A stack of software for constrained devices (e.g., the device, endpoint, microcontroller unit (MCU), sensor hardware). - -* Some type of gateway that aggregates information and data from the different sensors and sends it to the network. This layer also may take real-time actions based on what the sensors are observing. - -* A software stack for the IoT platform on the backend. This backend cloud stores the data and can provide services based on collected data, such as analysis of historical trends and predictive analytics. - -The three stacks are described in greater detail in Eclipse's whitepaper "[The Three Software Stacks Required for IoT Architectures][7]." - -Ian says that, when developing a solution within those architectures, "there's very specific things that need to be built, but there's a lot of underlying technology that can be used, like messaging protocols, like gateway services. It needs to be a modular approach to scale up to the different use cases that are up there." This encapsulates Eclipse's activities around IoT: Developing modular open source components that can be used to build a range of business-specific services and solutions. - -### Eclipse's IoT projects - -Of Eclipse's many IoT projects currently in use, Ian says two of the most prominent relate to [MQTT][8], a machine-to-machine (M2M) messaging protocol for IoT. Ian describes it as "a publish‑subscribe messaging protocol that was designed specifically for oil and gas pipeline monitoring where power-management network latency is really important. MQTT has been a great success in terms of being a standard that's being widely adopted in IoT." [Eclipse Mosquitto][9] is MQTT's broker and [Eclipse Paho][10] its client. - -[Eclipse Kura][11] is an IoT gateway that, in Ian's words, "provides northbound and southbound connectivity [for] a lot of different protocols" including Bluetooth, Modbus, controller-area network (CAN) bus, and OPC Unified Architecture, with more being added all the time. One benefit, he says, is "instead of you writing your own connectivity, Kura provides that and then connects you to the network via satellite, via Ethernet, or anything." In addition, it handles firewall configuration, network latency, and other functions. "If the network goes down, it will store messages until it comes back up," Ian says. - -A newer project, [Eclipse Kapua][12], is taking a microservices approach to providing different services for an IoT cloud platform. For example, it handles aspects of connectivity, integration, management, storage, and analysis. Ian describes it as "up and coming. It's not being deployed yet, but Eurotech and Red Hat are very active in that." - -Ian says [Eclipse hawkBit][13], which manages software updates, is one of the "most intriguing projects. From a security perspective, if you can't update your device, you've got a huge security hole." Most IoT security disasters are related to non-updated devices, he says. "HawkBit basically manages the backend of how you do scalable updates across your IoT system." - -Indeed, the difficulty of updating software in IoT devices is regularly cited as one of its biggest security challenges. IoT devices aren't always connected and may be numerous, plus update processes for constrained devices can be hard to consistently get right. For this reason, projects relating to updating IoT software are likely to be important going forward. - -### Why IoT is a good fit for Eclipse - -One of the trends we've seen in IoT development has been around building blocks that are integrated and applied to solve particular business problems, rather than monolithic IoT platforms that apply across industries and companies. This is a good fit with Eclipse's approach to IoT, which focuses on a number of modular stacks; projects that provide specific and commonly needed functions; and brokers, gateways, and protocols that can tie together the components needed for a given implementation. - --------------------------------------------------------------------------------- - -作者简介: - -Gordon Haff - Gordon Haff is Red Hat’s cloud evangelist, is a frequent and highly acclaimed speaker at customer and industry events, and helps develop strategy across Red Hat’s full portfolio of cloud solutions. He is the author of Computing Next: How the Cloud Opens the Future in addition to numerous other publications. Prior to Red Hat, Gordon wrote hundreds of research notes, was frequently quoted in publications like The New York Times on a wide range of IT topics, and advised clients on product and... - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/10/eclipse-and-iot - -作者:[Gordon Haff ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/ghaff -[1]:https://opensource.com/article/17/10/eclipse-and-iot?rate=u1Wr-MCMFCF4C45IMoSPUacCatoqzhdKz7NePxHOvwg -[2]:https://opensource.com/user/21220/feed -[3]:https://www.eclipse.org/home/ -[4]:http://thingmonk.com/ -[5]:https://iot.eclipse.org/ -[6]:https://twitter.com/ianskerrett -[7]:https://iot.eclipse.org/resources/white-papers/Eclipse%20IoT%20White%20Paper%20-%20The%20Three%20Software%20Stacks%20Required%20for%20IoT%20Architectures.pdf -[8]:http://mqtt.org/ -[9]:https://projects.eclipse.org/projects/technology.mosquitto -[10]:https://projects.eclipse.org/projects/technology.paho -[11]:https://www.eclipse.org/kura/ -[12]:https://www.eclipse.org/kapua/ -[13]:https://eclipse.org/hawkbit/ -[14]:https://opensource.com/users/ghaff -[15]:https://opensource.com/users/ghaff -[16]:https://opensource.com/article/17/10/eclipse-and-iot#comments diff --git a/sources/tech/20171102 Dive into BPF a list of reading material.md b/sources/tech/20171102 Dive into BPF a list of reading material.md new file mode 100644 index 0000000000..f4b90bd09d --- /dev/null +++ b/sources/tech/20171102 Dive into BPF a list of reading material.md @@ -0,0 +1,711 @@ +Dive into BPF: a list of reading material +============================================================ + +* [What is BPF?][143] + +* [Dive into the bytecode][144] + +* [Resources][145] + * [Generic presentations][23] + * [About BPF][1] + + * [About XDP][2] + + * [About other components related or based on eBPF][3] + + * [Documentation][24] + * [About BPF][4] + + * [About tc][5] + + * [About XDP][6] + + * [About P4 and BPF][7] + + * [Tutorials][25] + + * [Examples][26] + * [From the kernel][8] + + * [From package iproute2][9] + + * [From bcc set of tools][10] + + * [Manual pages][11] + + * [The code][27] + * [BPF code in the kernel][12] + + * [XDP hooks code][13] + + * [BPF logic in bcc][14] + + * [Code to manage BPF with tc][15] + + * [BPF utilities][16] + + * [Other interesting chunks][17] + + * [LLVM backend][18] + + * [Running in userspace][19] + + * [Commit logs][20] + + * [Troubleshooting][28] + * [Errors at compilation time][21] + + * [Errors at load and run time][22] + + * [And still more!][29] + + _~ [Updated][146] 2017-11-02 ~_ + +# What is BPF? + +BPF, as in **B**erkeley **P**acket **F**ilter, was initially conceived in 1992 so as to provide a way to filter packets and to avoid useless packet copies from kernel to userspace. It initially consisted in a simple bytecode that is injected from userspace into the kernel, where it is checked by a verifier—to prevent kernel crashes or security issues—and attached to a socket, then run on each received packet. It was ported to Linux a couple of years later, and used for a small number of applications (tcpdump for example). The simplicity of the language as well as the existence of an in-kernel Just-In-Time (JIT) compiling machine for BPF were factors for the excellent performances of this tool. + +Then in 2013, Alexei Starovoitov completely reshaped it, started to add new functionalities and to improve the performances of BPF. This new version is designated as eBPF (for “extended BPF”), while the former becomes cBPF (“classic” BPF). New features such as maps and tail calls appeared. The JIT machines were rewritten. The new language is even closer to native machine language than cBPF was. And also, new attach points in the kernel have been created. + +Thanks to those new hooks, eBPF programs can be designed for a variety of use cases, that divide into two fields of applications. One of them is the domain of kernel tracing and event monitoring. BPF programs can be attached to kprobes and they compare with other tracing methods, with many advantages (and sometimes some drawbacks). + +The other application domain remains network programming. In addition to socket filter, eBPF programs can be attached to tc (Linux traffic control tool) ingress or egress interfaces and perform a variety of packet processing tasks, in an efficient way. This opens new perspectives in the domain. + +And eBPF performances are further leveraged through the technologies developed for the IO Visor project: new hooks have also been added for XDP (“eXpress Data Path”), a new fast path recently added to the kernel. XDP works in conjunction with the Linux stack, and relies on BPF to perform very fast packet processing. + +Even some projects such as P4, Open vSwitch, [consider][155] or started to approach BPF. Some others, such as CETH, Cilium, are entirely based on it. BPF is buzzing, so we can expect a lot of tools and projects to orbit around it soon… + +# Dive into the bytecode + +As for me: some of my work (including for [BEBA][156]) is closely related to eBPF, and several future articles on this site will focus on this topic. Logically, I wanted to somehow introduce BPF on this blog before going down to the details—I mean, a real introduction, more developed on BPF functionalities that the brief abstract provided in first section: What are BPF maps? Tail calls? What do the internals look like? And so on. But there are a lot of presentations on this topic available on the web already, and I do not wish to create “yet another BPF introduction” that would come as a duplicate of existing documents. + +So instead, here is what we will do. After all, I spent some time reading and learning about BPF, and while doing so, I gathered a fair amount of material about BPF: introductions, documentation, but also tutorials or examples. There is a lot to read, but in order to read it, one has to  _find_  it first. Therefore, as an attempt to help people who wish to learn and use BPF, the present article introduces a list of resources. These are various kinds of readings, that hopefully will help you dive into the mechanics of this kernel bytecode. + +# Resources + +![](https://qmonnet.github.io/whirl-offload/img/icons/pic.svg) + +### Generic presentations + +The documents linked below provide a generic overview of BPF, or of some closely related topics. If you are very new to BPF, you can try picking a couple of presentation among the first ones and reading the ones you like most. If you know eBPF already, you probably want to target specific topics instead, lower down in the list. + +### About BPF + +Generic presentations about eBPF: + +* [_Making the Kernel’s Networking Data Path Programmable with BPF and XDP_][53]  (Daniel Borkmann, OSSNA17, Los Angeles, September 2017): + One of the best set of slides available to understand quickly all the basics about eBPF and XDP (mostly for network processing). + +* [The BSD Packet Filter][54] (Suchakra Sharma, June 2017):  + A very nice introduction, mostly about the tracing aspects. + +* [_BPF: tracing and more_][55]  (Brendan Gregg, January 2017): + Mostly about the tracing use cases. + +* [_Linux BPF Superpowers_][56]  (Brendan Gregg, March 2016): + With a first part on the use of **flame graphs**. + +* [_IO Visor_][57]  (Brenden Blanco, SCaLE 14x, January 2016): + Also introduces **IO Visor project**. + +* [_eBPF on the Mainframe_][58]  (Michael Holzheu, LinuxCon, Dubin, October 2015) + +* [_New (and Exciting!) Developments in Linux Tracing_][59]  (Elena Zannoni, LinuxCon, Japan, 2015) + +* [_BPF — in-kernel virtual machine_][60]  (Alexei Starovoitov, February 2015): + Presentation by the author of eBPF. + +* [_Extending extended BPF_][61]  (Jonathan Corbet, July 2014) + +**BPF internals**: + +* Daniel Borkmann has been doing an amazing work to present **the internals** of eBPF, in particular about **its use with tc**, through several talks and papers. + * [_Advanced programmability and recent updates with tc’s cls_bpf_][30]  (netdev 1.2, Tokyo, October 2016): + Daniel provides details on eBPF, its use for tunneling and encapsulation, direct packet access, and other features. + + * [_cls_bpf/eBPF updates since netdev 1.1_][31]  (netdev 1.2, Tokyo, October 2016, part of [this tc workshop][32]) + + * [_On getting tc classifier fully programmable with cls_bpf_][33]  (netdev 1.1, Sevilla, February 2016): + After introducing eBPF, this presentation provides insights on many internal BPF mechanisms (map management, tail calls, verifier). A must-read! For the most ambitious, [the full paper is available here][34]. + + * [_Linux tc and eBPF_][35]  (fosdem16, Brussels, Belgium, January 2016) + + * [_eBPF and XDP walkthrough and recent updates_][36]  (fosdem17, Brussels, Belgium, February 2017) + + These presentations are probably one of the best sources of documentation to understand the design and implementation of internal mechanisms of eBPF. + +The [**IO Visor blog**][157] has some interesting technical articles about BPF. Some of them contain a bit of marketing talks. + +**Kernel tracing**: summing up all existing methods, including BPF: + +* [_Meet-cute between eBPF and Kerne Tracing_][62]  (Viller Hsiao, July 2016): + Kprobes, uprobes, ftrace + +* [_Linux Kernel Tracing_][63]  (Viller Hsiao, July 2016): + Systemtap, Kernelshark, trace-cmd, LTTng, perf-tool, ftrace, hist-trigger, perf, function tracer, tracepoint, kprobe/uprobe… + +Regarding **event tracing and monitoring**, Brendan Gregg uses eBPF a lot and does an excellent job at documenting some of his use cases. If you are in kernel tracing, you should see his blog articles related to eBPF or to flame graphs. Most of it are accessible [from this article][158] or by browsing his blog. + +Introducing BPF, but also presenting **generic concepts of Linux networking**: + +* [_Linux Networking Explained_][64]  (Thomas Graf, LinuxCon, Toronto, August 2016) + +* [_Kernel Networking Walkthrough_][65]  (Thomas Graf, LinuxCon, Seattle, August 2015) + +**Hardware offload**: + +* eBPF with tc or XDP supports hardware offload, starting with Linux kernel version 4.9 and introduced by Netronome. Here is a presentation about this feature: + [eBPF/XDP hardware offload to SmartNICs][147] (Jakub Kicinski and Nic Viljoen, netdev 1.2, Tokyo, October 2016) + +About **cBPF**: + +* [_The BSD Packet Filter: A New Architecture for User-level Packet Capture_][66]  (Steven McCanne and Van Jacobson, 1992): + The original paper about (classic) BPF. + +* [The FreeBSD manual page about BPF][67] is a useful resource to understand cBPF programs. + +* Daniel Borkmann realized at least two presentations on cBPF, [one in 2013 on mmap, BPF and Netsniff-NG][68], and [a very complete one in 2014 on tc and cls_bpf][69]. + +* On Cloudflare’s blog, Marek Majkowski presented his [use of BPF bytecode with the `xt_bpf`module for **iptables**][70]. It is worth mentioning that eBPF is also supported by this module, starting with Linux kernel 4.10 (I do not know of any talk or article about this, though). + +* [Libpcap filters syntax][71] + +### About XDP + +* [XDP overview][72] on the IO Visor website. + +* [_eXpress Data Path (XDP)_][73]  (Tom Herbert, Alexei Starovoitov, March 2016): + The first presentation about XDP. + +* [_BoF - What Can BPF Do For You?_][74]  (Brenden Blanco, LinuxCon, Toronto, August 2016). + +* [_eXpress Data Path_][148]  (Brenden Blanco, Linux Meetup at Santa Clara, July 2016): + Contains some (somewhat marketing?) **benchmark results**! With a single core: + * ip routing drop: ~3.6 million packets per second (Mpps) + + * tc (with clsact qdisc) drop using BPF: ~4.2 Mpps + + * XDP drop using BPF: 20 Mpps (<10 % CPU utilization) + + * XDP forward (on port on which the packet was received) with rewrite: 10 Mpps + + (Tests performed with the mlx4 driver). + +* Jesper Dangaard Brouer has several excellent sets of slides, that are essential to fully understand the internals of XDP. + * [_XDP − eXpress Data Path, Intro and future use-cases_][37]  (September 2016): + _“Linux Kernel’s fight against DPDK”_ . **Future plans** (as of this writing) for XDP and comparison with DPDK. + + * [_Network Performance Workshop_][38]  (netdev 1.2, Tokyo, October 2016): + Additional hints about XDP internals and expected evolution. + + * [_XDP – eXpress Data Path, Used for DDoS protection_][39]  (OpenSourceDays, March 2017): + Contains details and use cases about XDP, with **benchmark results**, and **code snippets** for **benchmarking** as well as for **basic DDoS protection** with eBPF/XDP (based on an IP blacklisting scheme). + + * [_Memory vs. Networking, Provoking and fixing memory bottlenecks_][40]  (LSF Memory Management Summit, March 2017): + Provides a lot of details about current **memory issues** faced by XDP developers. Do not start with this one, but if you already know XDP and want to see how it really works on the page allocation side, this is a very helpful resource. + + * [_XDP for the Rest of Us_][41]  (netdev 2.1, Montreal, April 2017), with Andy Gospodarek: + How to get started with eBPF and XDP for normal humans. This presentation was also summarized by Julia Evans on [her blog][42]. + + (Jesper also created and tries to extend some documentation about eBPF and XDP, see [related section][75].) + +* [_XDP workshop — Introduction, experience, and future development_][76]  (Tom Herbert, netdev 1.2, Tokyo, October 2016) — as of this writing, only the video is available, I don’t know if the slides will be added. + +* [_High Speed Packet Filtering on Linux_][149]  (Gilberto Bertin, DEF CON 25, Las Vegas, July 2017) — an excellent introduction to state-of-the-art packet filtering on Linux, oriented towards DDoS protection, talking about packet processing in the kernel, kernel bypass, XDP and eBPF. + +### About other components related or based on eBPF + +* [_P4 on the Edge_][77]  (John Fastabend, May 2016): + Presents the use of **P4**, a description language for packet processing, with BPF to create high-performance programmable switches. + +* If you like audio presentations, there is an associated [OvS Orbit episode (#11), called  _**P4** on the Edge_][78] , dating from August 2016\. OvS Orbit are interviews realized by Ben Pfaff, who is one of the core maintainers of Open vSwitch. In this case, John Fastabend is interviewed. + +* [_P4, EBPF and Linux TC Offload_][79]  (Dinan Gunawardena and Jakub Kicinski, August 2016): + Another presentation on **P4**, with some elements related to eBPF hardware offload on Netronome’s **NFP** (Network Flow Processor) architecture. + +* **Cilium** is a technology initiated by Cisco and relying on BPF and XDP to provide “fast in-kernel networking and security policy enforcement for containers based on eBPF programs generated on the fly”. [The code of this project][150] is available on GitHub. Thomas Graf has been performing a number of presentations of this topic: + * [_Cilium: Networking & Security for Containers with BPF & XDP_][43] , also featuring a load balancer use case (Linux Plumbers conference, Santa Fe, November 2016) + + * [_Cilium: Networking & Security for Containers with BPF & XDP_][44]  (Docker Distributed Systems Summit, October 2016 — [video][45]) + + * [_Cilium: Fast IPv6 container Networking with BPF and XDP_][46]  (LinuxCon, Toronto, August 2016) + + * [_Cilium: BPF & XDP for containers_][47]  (fosdem17, Brussels, Belgium, February 2017) + + A good deal of contents is repeated between the different presentations; if in doubt, just pick the most recent one. Daniel Borkmann has also written [a generic introduction to Cilium][80] as a guest author on Google Open Source blog. + +* There are also podcasts about **Cilium**: an [OvS Orbit episode (#4)][81], in which Ben Pfaff interviews Thomas Graf (May 2016), and [another podcast by Ivan Pepelnjak][82], still with Thomas Graf about eBPF, P4, XDP and Cilium (October 2016). + +* **Open vSwitch** (OvS), and its related project **Open Virtual Network** (OVN, an open source network virtualization solution) are considering to use eBPF at various level, with several proof-of-concept prototypes already implemented: + + * [Offloading OVS Flow Processing using eBPF][48] (William (Cheng-Chun) Tu, OvS conference, San Jose, November 2016) + + * [Coupling the Flexibility of OVN with the Efficiency of IOVisor][49] (Fulvio Risso, Matteo Bertrone and Mauricio Vasquez Bernal, OvS conference, San Jose, November 2016) + + These use cases for eBPF seem to be only at the stage of proposals (nothing merge to OvS main branch) as far as I know, but it will be very interesting to see what comes out of it. + +* XDP is envisioned to be of great help for protection against Distributed Denial-of-Service (DDoS) attacks. More and more presentations focus on this. For example, the talks from people from Cloudflare ( [_XDP in practice: integrating XDP in our DDoS mitigation pipeline_][83] ) or from Facebook ( [_Droplet: DDoS countermeasures powered by BPF + XDP_][84] ) at the netdev 2.1 conference in Montreal, Canada, in April 2017, present such use cases. + +* [_CETH for XDP_][85]  (Yan Chan and Yunsong Lu, Linux Meetup, Santa Clara, July 2016): + **CETH** stands for Common Ethernet Driver Framework for faster network I/O, a technology initiated by Mellanox. + +* [**The VALE switch**][86], another virtual switch that can be used in conjunction with the netmap framework, has [a BPF extension module][87]. + +* **Suricata**, an open source intrusion detection system, [seems to rely on eBPF components][88] for its “capture bypass” features: + [_The adventures of a Suricate in eBPF land_][89]  (Éric Leblond, netdev 1.2, Tokyo, October 2016) + [_eBPF and XDP seen from the eyes of a meerkat_][90]  (Éric Leblond, Kernel Recipes, Paris, September 2017) + +* [InKeV: In-Kernel Distributed Network Virtualization for DCN][91] (Z. Ahmed, M. H. Alizai and A. A. Syed, SIGCOMM, August 2016): + **InKeV** is an eBPF-based datapath architecture for virtual networks, targeting data center networks. It was initiated by PLUMgrid, and claims to achieve better performances than OvS-based OpenStack solutions. + +* [_**gobpf** - utilizing eBPF from Go_][92]  (Michael Schubert, fosdem17, Brussels, Belgium, February 2017): + A “library to create, load and use eBPF programs from Go” + +* [**ply**][93] is a small but flexible open source dynamic **tracer** for Linux, with some features similar to the bcc tools, but with a simpler language inspired by awk and dtrace, written by Tobias Waldekranz. + +* If you read my previous article, you might be interested in this talk I gave about [implementing the OpenState interface with eBPF][151], for stateful packet processing, at fosdem17. + +![](https://qmonnet.github.io/whirl-offload/img/icons/book.svg) + +### Documentation + +Once you managed to get a broad idea of what BPF is, you can put aside generic presentations and start diving into the documentation. Below are the most complete documents about BPF specifications and functioning. Pick the one you need and read them carefully! + +### About BPF + +* The **specification of BPF** (both classic and extended versions) can be found within the documentation of the Linux kernel, and in particular in file[linux/Documentation/networking/filter.txt][94]. The use of BPF as well as its internals are documented there. Also, this is where you can find **information about errors thrown by the verifier** when loading BPF code fails. Can be helpful to troubleshoot obscure error messages. + +* Also in the kernel tree, there is a document about **frequent Questions & Answers** on eBPF design in file [linux/Documentation/bpf/bpf_design_QA.txt][95]. + +* … But the kernel documentation is dense and not especially easy to read. If you look for a simple description of eBPF language, head for [its **summarized description**][96] on the IO Visor GitHub repository instead. + +* By the way, the IO Visor project gathered a lot of **resources about BPF**. Mostly, it is split between[the documentation directory][97] of its bcc repository, and the whole content of [the bpf-docs repository][98], both on GitHub. Note the existence of this excellent [BPF **reference guide**][99] containing a detailed description of BPF C and bcc Python helpers. + +* To hack with BPF, there are some essential **Linux manual pages**. The first one is [the `bpf(2)` man page][100] about the `bpf()` **system call**, which is used to manage BPF programs and maps from userspace. It also contains a description of BPF advanced features (program types, maps and so on). The second one is mostly addressed to people wanting to attach BPF programs to tc interface: it is [the `tc-bpf(8)` man page][101], which is a reference for **using BPF with tc**, and includes some example commands and samples of code. + +* Jesper Dangaard Brouer initiated an attempt to **update eBPF Linux documentation**, including **the different kinds of maps**. [He has a draft][102] to which contributions are welcome. Once ready, this document should be merged into the man pages and into kernel documentation. + +* The Cilium project also has an excellent [**BPF and XDP Reference Guide**][103], written by core eBPF developers, that should prove immensely useful to any eBPF developer. + +* David Miller has sent several enlightening emails about eBPF/XDP internals on the [xdp-newbies][152]mailing list. I could not find a link that gathers them at a single place, so here is a list: + * [bpf.h and you…][50] + + * [Contextually speaking…][51] + + * [BPF Verifier Overview][52] + + The last one is possibly the best existing summary about the verifier at this date. + +* Ferris Ellis started [a **blog post series about eBPF**][104]. As I write this paragraph, the first article is out, with some historical background and future expectations for eBPF. Next posts should be more technical, and look promising. + +* [A **list of BPF features per kernel version**][153] is available in bcc repository. Useful is you want to know the minimal kernel version that is required to run a given feature. I contributed and added the links to the commits that introduced each feature, so you can also easily access the commit logs from there. + +### About tc + +When using BPF for networking purposes in conjunction with tc, the Linux tool for **t**raffic **c**ontrol, one may wish to gather information about tc’s generic functioning. Here are a couple of resources about it. + +* It is difficult to find simple tutorials about **QoS on Linux**. The two links I have are long and quite dense, but if you can find the time to read it you will learn nearly everything there is to know about tc (nothing about BPF, though). There they are:  [_Traffic Control HOWTO_  (Martin A. Brown, 2006)][105], and the  [_Linux Advanced Routing & Traffic Control HOWTO_  (“LARTC”) (Bert Hubert & al., 2002)][106]. + +* **tc manual pages** may not be up-to-date on your system, since several of them have been added lately. If you cannot find the documentation for a particular queuing discipline (qdisc), class or filter, it may be worth checking the latest [manual pages for tc components][107]. + +* Some additional material can be found within the files of iproute2 package itself: the package contains [some documentation][108], including some files that helped me understand better [the functioning of **tc’s actions**][109]. + **Edit:** While still available from the Git history, these files have been deleted from iproute2 in October 2017. + +* Not exactly documentation: there was [a workshop about several tc features][110] (including filtering, BPF, tc offload, …) organized by Jamal Hadi Salim during the netdev 1.2 conference (October 2016). + +* Bonus information—If you use `tc` a lot, here are some good news: I [wrote a bash completion function][111] for this tool, and it should be shipped with package iproute2 coming with kernel version 4.6 and higher! + +### About XDP + +* Some [work-in-progress documentation (including specifications)][112] for XDP started by Jesper Dangaard Brouer, but meant to be a collaborative work. Under progress (September 2016): you should expect it to change, and maybe to be moved at some point (Jesper [called for contribution][113], if you feel like improving it). + +* The [BPF and XDP Reference Guide][114] from Cilium project… Well, the name says it all. + +### About P4 and BPF + +[P4][159] is a language used to specify the behavior of a switch. It can be compiled for a number of hardware or software targets. As you may have guessed, one of these targets is BPF… The support is only partial: some P4 features cannot be translated towards BPF, and in a similar way there are things that BPF can do but that would not be possible to express with P4\. Anyway, the documentation related to **P4 use with BPF** [used to be hidden in bcc repository][160]. This changed with P4_16 version, the p4c reference compiler including [a backend for eBPF][161]. + +![](https://qmonnet.github.io/whirl-offload/img/icons/flask.svg) + +### Tutorials + +Brendan Gregg has produced excellent **tutorials** intended for people who want to **use bcc tools** for tracing and monitoring events in the kernel. [The first tutorial about using bcc itself][162] comes with eleven steps (as of today) to understand how to use the existing tools, while [the one **intended for Python developers**][163] focuses on developing new tools, across seventeen “lessons”. + +Sasha Goldshtein also has some  [_**Linux Tracing Workshops Materials**_][164]  involving the use of several BPF tools for tracing. + +Another post by Jean-Tiare Le Bigot provides a detailed (and instructive!) example of [using perf and eBPF to setup a low-level tracer][165] for ping requests and replies + +Few tutorials exist for network-related eBPF use cases. There are some interesting documents, including an  _eBPF Offload Starting Guide_ , on the [Open NFP][166] platform operated by Netronome. Other than these, the talk from Jesper,  [_XDP for the Rest of Us_][167] , is probably one of the best ways to get started with XDP. + +![](https://qmonnet.github.io/whirl-offload/img/icons/gears.svg) + +### Examples + +It is always nice to have examples. To see how things really work. But BPF program samples are scattered across several projects, so I listed all the ones I know of. The examples do not always use the same helpers (for instance, tc and bcc both have their own set of helpers to make it easier to write BPF programs in C language). + +### From the kernel + +The kernel contains examples for most types of program: filters to bind to sockets or to tc interfaces, event tracing/monitoring, and even XDP. You can find these examples under the [linux/samples/bpf/][168]directory. + +Also do not forget to have a look to the logs related to the (git) commits that introduced a particular feature, they may contain some detailed example of the feature. + +### From package iproute2 + +The iproute2 package provide several examples as well. They are obviously oriented towards network programming, since the programs are to be attached to tc ingress or egress interfaces. The examples dwell under the [iproute2/examples/bpf/][169] directory. + +### From bcc set of tools + +Many examples are [provided with bcc][170]: + +* Some are networking example programs, under the associated directory. They include socket filters, tc filters, and a XDP program. + +* The `tracing` directory include a lot of example **tracing programs**. The tutorials mentioned earlier are based on these. These programs cover a wide range of event monitoring functions, and some of them are production-oriented. Note that on certain Linux distributions (at least for Debian, Ubuntu, Fedora, Arch Linux), these programs have been [packaged][115] and can be “easily” installed by typing e.g. `# apt install bcc-tools`, but as of this writing (and except for Arch Linux), this first requires to set up IO Visor’s own package repository. + +* There are also some examples **using Lua** as a different BPF back-end (that is, BPF programs are written with Lua instead of a subset of C, allowing to use the same language for front-end and back-end), in the third directory. + +### Manual pages + +While bcc is generally the easiest way to inject and run a BPF program in the kernel, attaching programs to tc interfaces can also be performed by the `tc` tool itself. So if you intend to **use BPF with tc**, you can find some example invocations in the [`tc-bpf(8)` manual page][171]. + +![](https://qmonnet.github.io/whirl-offload/img/icons/srcfile.svg) + +### The code + +Sometimes, BPF documentation or examples are not enough, and you may have no other solution that to display the code in your favorite text editor (which should be Vim of course) and to read it. Or you may want to hack into the code so as to patch or add features to the machine. So here are a few pointers to the relevant files, finding the functions you want is up to you! + +### BPF code in the kernel + +* The file [linux/include/linux/bpf.h][116] and its counterpart [linux/include/uapi/bpf.h][117] contain **definitions** related to eBPF, to be used respectively in the kernel and to interface with userspace programs. + +* On the same pattern, files [linux/include/linux/filter.h][118] and [linux/include/uapi/filter.h][119] contain information used to **run the BPF programs**. + +* The **main pieces of code** related to BPF are under [linux/kernel/bpf/][120] directory. **The different operations permitted by the system call**, such as program loading or map management, are implemented in file `syscall.c`, while `core.c` contains the **interpreter**. The other files have self-explanatory names: `verifier.c` contains the **verifier** (no kidding), `arraymap.c` the code used to interact with **maps** of type array, and so on. + +* The **helpers**, as well as several functions related to networking (with tc, XDP…) and available to the user, are implemented in [linux/net/core/filter.c][121]. It also contains the code to migrate cBPF bytecode to eBPF (since all cBPF programs are now translated to eBPF in the kernel before being run). + +* The **JIT compilers** are under the directory of their respective architectures, such as file[linux/arch/x86/net/bpf_jit_comp.c][122] for x86. + +* You will find the code related to **the BPF components of tc** in the [linux/net/sched/][123] directory, and in particular in files `act_bpf.c` (action) and `cls_bpf.c` (filter). + +* I have not hacked with **event tracing** in BPF, so I do not really know about the hooks for such programs. There is some stuff in [linux/kernel/trace/bpf_trace.c][124]. If you are interested in this and want to know more, you may dig on the side of Brendan Gregg’s presentations or blog posts. + +* Nor have I used **seccomp-BPF**. But the code is in [linux/kernel/seccomp.c][125], and some example use cases can be found in [linux/tools/testing/selftests/seccomp/seccomp_bpf.c][126]. + +### XDP hooks code + +Once loaded into the in-kernel BPF virtual machine, **XDP** programs are hooked from userspace into the kernel network path thanks to a Netlink command. On reception, the function `dev_change_xdp_fd()` in file [linux/net/core/dev.c][172] is called and sets a XDP hook. Such hooks are located in the drivers of supported NICs. For example, the mlx4 driver used for some Mellanox hardware has hooks implemented in files under the [drivers/net/ethernet/mellanox/mlx4/][173] directory. File en_netdev.c receives Netlink commands and calls `mlx4_xdp_set()`, which in turns calls for instance `mlx4_en_process_rx_cq()` (for the RX side) implemented in file en_rx.c. + +### BPF logic in bcc + +One can find the code for the **bcc** set of tools [on the bcc GitHub repository][174]. The **Python code**, including the `BPF` class, is initiated in file [bcc/src/python/bcc/__init__.py][175]. But most of the interesting stuff—to my opinion—such as loading the BPF program into the kernel, happens [in the libbcc **C library**][176]. + +### Code to manage BPF with tc + +The code related to BPF **in tc** comes with the iproute2 package, of course. Some of it is under the[iproute2/tc/][177] directory. The files f_bpf.c and m_bpf.c (and e_bpf.c) are used respectively to handle BPF filters and actions (and tc `exec` command, whatever this may be). File q_clsact.c defines the `clsact` qdisc especially created for BPF. But **most of the BPF userspace logic** is implemented in[iproute2/lib/bpf.c][178] library, so this is probably where you should head to if you want to mess up with BPF and tc (it was moved from file iproute2/tc/tc_bpf.c, where you may find the same code in older versions of the package). + +### BPF utilities + +The kernel also ships the sources of three tools (`bpf_asm.c`, `bpf_dbg.c`, `bpf_jit_disasm.c`) related to BPF, under the [linux/tools/net/][179] or [linux/tools/bpf/][180] directory depending on your version: + +* `bpf_asm` is a minimal cBPF assembler. + +* `bpf_dbg` is a small debugger for cBPF programs. + +* `bpf_jit_disasm` is generic for both BPF flavors and could be highly useful for JIT debugging. + +* `bpftool` is a generic utility written by Jakub Kicinski, and that can be used to interact with eBPF programs and maps from userspace, for example to show, dump, pin programs, or to show, create, pin, update, delete maps. + +Read the comments at the top of the source files to get an overview of their usage. + +### Other interesting chunks + +If you are interested the use of less common languages with BPF, bcc contains [a **P4 compiler** for BPF targets][181] as well as [a **Lua front-end**][182] that can be used as alternatives to the C subset and (in the case of Lua) to the Python tools. + +### LLVM backend + +The BPF backend used by clang / LLVM for compiling C into eBPF was added to the LLVM sources in[this commit][183] (and can also be accessed on [the GitHub mirror][184]). + +### Running in userspace + +As far as I know there are at least two eBPF userspace implementations. The first one, [uBPF][185], is written in C. It contains an interpreter, a JIT compiler for x86_64 architecture, an assembler and a disassembler. + +The code of uBPF seems to have been reused to produce a [generic implementation][186], that claims to support FreeBSD kernel, FreeBSD userspace, Linux kernel, Linux userspace and MacOSX userspace. It is used for the [BPF extension module for VALE switch][187]. + +The other userspace implementation is my own work: [rbpf][188], based on uBPF, but written in Rust. The interpreter and JIT-compiler work (both under Linux, only the interpreter for MacOSX and Windows), there may be more in the future. + +### Commit logs + +As stated earlier, do not hesitate to have a look at the commit log that introduced a particular BPF feature if you want to have more information about it. You can search the logs in many places, such as on [git.kernel.org][189], [on GitHub][190], or on your local repository if you have cloned it. If you are not familiar with git, try things like `git blame ` to see what commit introduced a particular line of code, then `git show ` to have details (or search by keyword in `git log` results, but this may be tedious). See also [the list of eBPF features per kernel version][191] on bcc repository, that links to relevant commits. + +![](https://qmonnet.github.io/whirl-offload/img/icons/wand.svg) + +### Troubleshooting + +The enthusiasm about eBPF is quite recent, and so far I have not found a lot of resources intending to help with troubleshooting. So here are the few I have, augmented with my own recollection of pitfalls encountered while working with BPF. + +### Errors at compilation time + +* Make sure you have a recent enough version of the Linux kernel (see also [this document][127]). + +* If you compiled the kernel yourself: make sure you installed correctly all components, including kernel image, headers and libc. + +* When using the `bcc` shell function provided by `tc-bpf` man page (to compile C code into BPF): I once had to add includes to the header for the clang call: + + ``` + __bcc() { + clang -O2 -I "/usr/src/linux-headers-$(uname -r)/include/" \ + -I "/usr/src/linux-headers-$(uname -r)/arch/x86/include/" \ + -emit-llvm -c $1 -o - | \ + llc -march=bpf -filetype=obj -o "`basename $1 .c`.o" + } + + ``` + + (seems fixed as of today). + +* For other problems with `bcc`, do not forget to have a look at [the FAQ][128] of the tool set. + +* If you downloaded the examples from the iproute2 package in a version that does not exactly match your kernel, some errors can be triggered by the headers included in the files. The example snippets indeed assume that the same version of iproute2 package and kernel headers are installed on the system. If this is not the case, download the correct version of iproute2, or edit the path of included files in the examples to point to the headers included in iproute2 (some problems may or may not occur at runtime, depending on the features in use). + +### Errors at load and run time + +* To load a program with tc, make sure you use a tc binary coming from an iproute2 version equivalent to the kernel in use. + +* To load a program with bcc, make sure you have bcc installed on the system (just downloading the sources to run the Python script is not enough). + +* With tc, if the BPF program does not return the expected values, check that you called it in the correct fashion: filter, or action, or filter with “direct-action” mode. + +* With tc still, note that actions cannot be attached directly to qdiscs or interfaces without the use of a filter. + +* The errors thrown by the in-kernel verifier may be hard to interpret. [The kernel documentation][129]may help, so may [the reference guide][130] or, as a last resort, the source code (see above) (good luck!). For this kind of errors it is also important to keep in mind that the verifier  _does not run_  the program. If you get an error about an invalid memory access or about uninitialized data, it does not mean that these problems actually occurred (or sometimes, that they can possibly occur at all). It means that your program is written in such a way that the verifier estimates that such errors could happen, and therefore it rejects the program. + +* Note that `tc` tool has a verbose mode, and that it works well with BPF: try appending `verbose`at the end of your command line. + +* bcc also has verbose options: the `BPF` class has a `debug` argument that can take any combination of the three flags `DEBUG_LLVM_IR`, `DEBUG_BPF` and `DEBUG_PREPROCESSOR` (see details in [the source file][131]). It even embeds [some facilities to print output messages][132] for debugging the code. + +* LLVM v4.0+ [embeds a disassembler][133] for eBPF programs. So if you compile your program with clang, adding the `-g` flag for compiling enables you to later dump your program in the rather human-friendly format used by the kernel verifier. To proceed to the dump, use: + + ``` + $ llvm-objdump -S -no-show-raw-insn bpf_program.o + + ``` + +* Working with maps? You want to have a look at [bpf-map][134], a very userful tool in Go created for the Cilium project, that can be used to dump the contents of kernel eBPF maps. There also exists [a clone][135] in Rust. + +* There is an old [`bpf` tag on **StackOverflow**][136], but as of this writing it has been hardly used—ever (and there is nearly nothing related to the new eBPF version). If you are a reader from the Future though, you may want to check whether there has been more activity on this side. + +![](https://qmonnet.github.io/whirl-offload/img/icons/zoomin.svg) + +### And still more! + +* In case you would like to easily **test XDP**, there is [a Vagrant setup][137] available. You can also **test bcc**[in a Docker container][138]. + +* Wondering where the **development and activities** around BPF occur? Well, the kernel patches always end up [on the netdev mailing list][139] (related to the Linux kernel networking stack development): search for “BPF” or “XDP” keywords. Since April 2017, there is also [a mailing list specially dedicated to XDP programming][140] (both for architecture or for asking for help). Many discussions and debates also occur [on the IO Visor mailing list][141], since BPF is at the heart of the project. If you only want to keep informed from time to time, there is also an [@IOVisor Twitter account][142]. + +And come back on this blog from time to time to see if they are new articles [about BPF][192]! + + _Special thanks to Daniel Borkmann for the numerous [additional documents][154] he pointed to me so that I could complete this collection._ + +-------------------------------------------------------------------------------- + +via: https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/ + +作者:[Quentin Monnet ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://qmonnet.github.io/whirl-offload/about/ +[1]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-bpf +[2]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-xdp +[3]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-other-components-related-or-based-on-ebpf +[4]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-bpf-1 +[5]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-tc +[6]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-xdp-1 +[7]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-p4-and-bpf +[8]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#from-the-kernel +[9]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#from-package-iproute2 +[10]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#from-bcc-set-of-tools +[11]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#manual-pages +[12]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#bpf-code-in-the-kernel +[13]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#xdp-hooks-code +[14]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#bpf-logic-in-bcc +[15]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#code-to-manage-bpf-with-tc +[16]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#bpf-utilities +[17]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#other-interesting-chunks +[18]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#llvm-backend +[19]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#running-in-userspace +[20]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#commit-logs +[21]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#errors-at-compilation-time +[22]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#errors-at-load-and-run-time +[23]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#generic-presentations +[24]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#documentation +[25]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#tutorials +[26]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#examples +[27]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#the-code +[28]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#troubleshooting +[29]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#and-still-more +[30]:http://netdevconf.org/1.2/session.html?daniel-borkmann +[31]:http://netdevconf.org/1.2/slides/oct5/07_tcws_daniel_borkmann_2016_tcws.pdf +[32]:http://netdevconf.org/1.2/session.html?jamal-tc-workshop +[33]:http://www.netdevconf.org/1.1/proceedings/slides/borkmann-tc-classifier-cls-bpf.pdf +[34]:http://www.netdevconf.org/1.1/proceedings/papers/On-getting-tc-classifier-fully-programmable-with-cls-bpf.pdf +[35]:https://archive.fosdem.org/2016/schedule/event/ebpf/attachments/slides/1159/export/events/attachments/ebpf/slides/1159/ebpf.pdf +[36]:https://fosdem.org/2017/schedule/event/ebpf_xdp/ +[37]:http://people.netfilter.org/hawk/presentations/xdp2016/xdp_intro_and_use_cases_sep2016.pdf +[38]:http://netdevconf.org/1.2/session.html?jesper-performance-workshop +[39]:http://people.netfilter.org/hawk/presentations/OpenSourceDays2017/XDP_DDoS_protecting_osd2017.pdf +[40]:http://people.netfilter.org/hawk/presentations/MM-summit2017/MM-summit2017-JesperBrouer.pdf +[41]:http://netdevconf.org/2.1/session.html?gospodarek +[42]:http://jvns.ca/blog/2017/04/07/xdp-bpf-tutorial/ +[43]:http://www.slideshare.net/ThomasGraf5/clium-container-networking-with-bpf-xdp +[44]:http://www.slideshare.net/Docker/cilium-bpf-xdp-for-containers-66969823 +[45]:https://www.youtube.com/watch?v=TnJF7ht3ZYc&list=PLkA60AVN3hh8oPas3cq2VA9xB7WazcIgs +[46]:http://www.slideshare.net/ThomasGraf5/cilium-fast-ipv6-container-networking-with-bpf-and-xdp +[47]:https://fosdem.org/2017/schedule/event/cilium/ +[48]:http://openvswitch.org/support/ovscon2016/7/1120-tu.pdf +[49]:http://openvswitch.org/support/ovscon2016/7/1245-bertrone.pdf +[50]:https://www.spinics.net/lists/xdp-newbies/msg00179.html +[51]:https://www.spinics.net/lists/xdp-newbies/msg00181.html +[52]:https://www.spinics.net/lists/xdp-newbies/msg00185.html +[53]:http://schd.ws/hosted_files/ossna2017/da/BPFandXDP.pdf +[54]:https://speakerdeck.com/tuxology/the-bsd-packet-filter +[55]:http://www.slideshare.net/brendangregg/bpf-tracing-and-more +[56]:http://fr.slideshare.net/brendangregg/linux-bpf-superpowers +[57]:https://www.socallinuxexpo.org/sites/default/files/presentations/Room%20211%20-%20IOVisor%20-%20SCaLE%2014x.pdf +[58]:https://events.linuxfoundation.org/sites/events/files/slides/ebpf_on_the_mainframe_lcon_2015.pdf +[59]:https://events.linuxfoundation.org/sites/events/files/slides/tracing-linux-ezannoni-linuxcon-ja-2015_0.pdf +[60]:https://events.linuxfoundation.org/sites/events/files/slides/bpf_collabsummit_2015feb20.pdf +[61]:https://lwn.net/Articles/603983/ +[62]:http://www.slideshare.net/vh21/meet-cutebetweenebpfandtracing +[63]:http://www.slideshare.net/vh21/linux-kernel-tracing +[64]:http://www.slideshare.net/ThomasGraf5/linux-networking-explained +[65]:http://www.slideshare.net/ThomasGraf5/linuxcon-2015-linux-kernel-networking-walkthrough +[66]:http://www.tcpdump.org/papers/bpf-usenix93.pdf +[67]:http://www.gsp.com/cgi-bin/man.cgi?topic=bpf +[68]:http://borkmann.ch/talks/2013_devconf.pdf +[69]:http://borkmann.ch/talks/2014_devconf.pdf +[70]:https://blog.cloudflare.com/introducing-the-bpf-tools/ +[71]:http://biot.com/capstats/bpf.html +[72]:https://www.iovisor.org/technology/xdp +[73]:https://github.com/iovisor/bpf-docs/raw/master/Express_Data_Path.pdf +[74]:https://events.linuxfoundation.org/sites/events/files/slides/iovisor-lc-bof-2016.pdf +[75]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-xdp-1 +[76]:http://netdevconf.org/1.2/session.html?herbert-xdp-workshop +[77]:https://schd.ws/hosted_files/2016p4workshop/1d/Intel%20Fastabend-P4%20on%20the%20Edge.pdf +[78]:https://ovsorbit.benpfaff.org/#e11 +[79]:http://open-nfp.org/media/pdfs/Open_NFP_P4_EBPF_Linux_TC_Offload_FINAL.pdf +[80]:https://opensource.googleblog.com/2016/11/cilium-networking-and-security.html +[81]:https://ovsorbit.benpfaff.org/ +[82]:http://blog.ipspace.net/2016/10/fast-linux-packet-forwarding-with.html +[83]:http://netdevconf.org/2.1/session.html?bertin +[84]:http://netdevconf.org/2.1/session.html?zhou +[85]:http://www.slideshare.net/IOVisor/ceth-for-xdp-linux-meetup-santa-clara-july-2016 +[86]:http://info.iet.unipi.it/~luigi/vale/ +[87]:https://github.com/YutaroHayakawa/vale-bpf +[88]:https://www.stamus-networks.com/2016/09/28/suricata-bypass-feature/ +[89]:http://netdevconf.org/1.2/slides/oct6/10_suricata_ebpf.pdf +[90]:https://www.slideshare.net/ennael/kernel-recipes-2017-ebpf-and-xdp-eric-leblond +[91]:https://github.com/iovisor/bpf-docs/blob/master/university/sigcomm-ccr-InKev-2016.pdf +[92]:https://fosdem.org/2017/schedule/event/go_bpf/ +[93]:https://wkz.github.io/ply/ +[94]:https://www.kernel.org/doc/Documentation/networking/filter.txt +[95]:https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/Documentation/bpf/bpf_design_QA.txt?id=2e39748a4231a893f057567e9b880ab34ea47aef +[96]:https://github.com/iovisor/bpf-docs/blob/master/eBPF.md +[97]:https://github.com/iovisor/bcc/tree/master/docs +[98]:https://github.com/iovisor/bpf-docs/ +[99]:https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md +[100]:http://man7.org/linux/man-pages/man2/bpf.2.html +[101]:http://man7.org/linux/man-pages/man8/tc-bpf.8.html +[102]:https://prototype-kernel.readthedocs.io/en/latest/bpf/index.html +[103]:http://docs.cilium.io/en/latest/bpf/ +[104]:https://ferrisellis.com/tags/ebpf/ +[105]:http://linux-ip.net/articles/Traffic-Control-HOWTO/ +[106]:http://lartc.org/lartc.html +[107]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/man/man8 +[108]:https://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git/tree/doc?h=v4.13.0 +[109]:https://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git/tree/doc/actions?h=v4.13.0 +[110]:http://netdevconf.org/1.2/session.html?jamal-tc-workshop +[111]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/commit/bash-completion/tc?id=27d44f3a8a4708bcc99995a4d9b6fe6f81e3e15b +[112]:https://prototype-kernel.readthedocs.io/en/latest/networking/XDP/index.html +[113]:https://marc.info/?l=linux-netdev&m=147436253625672 +[114]:http://docs.cilium.io/en/latest/bpf/ +[115]:https://github.com/iovisor/bcc/blob/master/INSTALL.md +[116]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/bpf.h +[117]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/bpf.h +[118]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/filter.h +[119]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/filter.h +[120]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/bpf +[121]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/core/filter.c +[122]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/x86/net/bpf_jit_comp.c +[123]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/sched +[124]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/trace/bpf_trace.c +[125]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/seccomp.c +[126]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/seccomp/seccomp_bpf.c +[127]:https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md +[128]:https://github.com/iovisor/bcc/blob/master/FAQ.txt +[129]:https://www.kernel.org/doc/Documentation/networking/filter.txt +[130]:https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md +[131]:https://github.com/iovisor/bcc/blob/master/src/python/bcc/__init__.py +[132]:https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md#output +[133]:https://www.spinics.net/lists/netdev/msg406926.html +[134]:https://github.com/cilium/bpf-map +[135]:https://github.com/badboy/bpf-map +[136]:https://stackoverflow.com/questions/tagged/bpf +[137]:https://github.com/iovisor/xdp-vagrant +[138]:https://github.com/zlim/bcc-docker +[139]:http://lists.openwall.net/netdev/ +[140]:http://vger.kernel.org/vger-lists.html#xdp-newbies +[141]:http://lists.iovisor.org/pipermail/iovisor-dev/ +[142]:https://twitter.com/IOVisor +[143]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#what-is-bpf +[144]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#dive-into-the-bytecode +[145]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#resources +[146]:https://github.com/qmonnet/whirl-offload/commits/gh-pages/_posts/2016-09-01-dive-into-bpf.md +[147]:http://netdevconf.org/1.2/session.html?jakub-kicinski +[148]:http://www.slideshare.net/IOVisor/express-data-path-linux-meetup-santa-clara-july-2016 +[149]:https://cdn.shopify.com/s/files/1/0177/9886/files/phv2017-gbertin.pdf +[150]:https://github.com/cilium/cilium +[151]:https://fosdem.org/2017/schedule/event/stateful_ebpf/ +[152]:http://vger.kernel.org/vger-lists.html#xdp-newbies +[153]:https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md +[154]:https://github.com/qmonnet/whirl-offload/commit/d694f8081ba00e686e34f86d5ee76abeb4d0e429 +[155]:http://openvswitch.org/pipermail/dev/2014-October/047421.html +[156]:https://qmonnet.github.io/whirl-offload/2016/07/15/beba-research-project/ +[157]:https://www.iovisor.org/resources/blog +[158]:http://www.brendangregg.com/blog/2016-03-05/linux-bpf-superpowers.html +[159]:http://p4.org/ +[160]:https://github.com/iovisor/bcc/tree/master/src/cc/frontends/p4 +[161]:https://github.com/p4lang/p4c/blob/master/backends/ebpf/README.md +[162]:https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md +[163]:https://github.com/iovisor/bcc/blob/master/docs/tutorial_bcc_python_developer.md +[164]:https://github.com/goldshtn/linux-tracing-workshop +[165]:https://blog.yadutaf.fr/2017/07/28/tracing-a-packet-journey-using-linux-tracepoints-perf-ebpf/ +[166]:https://open-nfp.org/dataplanes-ebpf/technical-papers/ +[167]:http://netdevconf.org/2.1/session.html?gospodarek +[168]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/samples/bpf +[169]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/examples/bpf +[170]:https://github.com/iovisor/bcc/tree/master/examples +[171]:http://man7.org/linux/man-pages/man8/tc-bpf.8.html +[172]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/core/dev.c +[173]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/mellanox/mlx4/ +[174]:https://github.com/iovisor/bcc/ +[175]:https://github.com/iovisor/bcc/blob/master/src/python/bcc/__init__.py +[176]:https://github.com/iovisor/bcc/blob/master/src/cc/libbpf.c +[177]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/tc +[178]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/lib/bpf.c +[179]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/tools/net +[180]:https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/tools/bpf +[181]:https://github.com/iovisor/bcc/tree/master/src/cc/frontends/p4/compiler +[182]:https://github.com/iovisor/bcc/tree/master/src/lua +[183]:https://reviews.llvm.org/D6494 +[184]:https://github.com/llvm-mirror/llvm/commit/4fe85c75482f9d11c5a1f92a1863ce30afad8d0d +[185]:https://github.com/iovisor/ubpf/ +[186]:https://github.com/YutaroHayakawa/generic-ebpf +[187]:https://github.com/YutaroHayakawa/vale-bpf +[188]:https://github.com/qmonnet/rbpf +[189]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git +[190]:https://github.com/torvalds/linux +[191]:https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md +[192]:https://qmonnet.github.io/whirl-offload/categories/#BPF diff --git a/sources/tech/20171107 GitHub welcomes all CI tools.md b/sources/tech/20171107 GitHub welcomes all CI tools.md new file mode 100644 index 0000000000..7bef351bd6 --- /dev/null +++ b/sources/tech/20171107 GitHub welcomes all CI tools.md @@ -0,0 +1,95 @@ +translating---geekpi + +GitHub welcomes all CI tools +==================== + + +[![GitHub and all CI tools](https://user-images.githubusercontent.com/29592817/32509084-2d52c56c-c3a1-11e7-8c49-901f0f601faf.png)][11] + +Continuous Integration ([CI][12]) tools help you stick to your team's quality standards by running tests every time you push a new commit and [reporting the results][13] to a pull request. Combined with continuous delivery ([CD][14]) tools, you can also test your code on multiple configurations, run additional performance tests, and automate every step [until production][15]. + +There are several CI and CD tools that [integrate with GitHub][16], some of which you can install in a few clicks from [GitHub Marketplace][17]. With so many options, you can pick the best tool for the job—even if it's not the one that comes pre-integrated with your system. + +The tools that will work best for you depends on many factors, including: + +* Programming language and application architecture + +* Operating system and browsers you plan to support + +* Your team's experience and skills + +* Scaling capabilities and plans for growth + +* Geographic distribution of dependent systems and the people who use them + +* Packaging and delivery goals + +Of course, it isn't possible to optimize your CI tool for all of these scenarios. The people who build them have to choose which use cases to serve best—and when to prioritize complexity over simplicity. For example, if you like to test small applications written in a particular programming language for one platform, you won't need the complexity of a tool that tests embedded software controllers on dozens of platforms with a broad mix of programming languages and frameworks. + +If you need a little inspiration for which CI tool might work best, take a look at [popular GitHub projects][18]. Many show the status of their integrated CI/CD tools as badges in their README.md. We've also analyzed the use of CI tools across more than 50 million repositories in the GitHub community, and found a lot of variety. The following diagram shows the relative percentage of the top 10 CI tools used with GitHub.com, based on the most used [commit status contexts][19] used within our pull requests. + + _Our analysis also showed that many teams use more than one CI tool in their projects, allowing them to emphasize what each tool does best._ + + [![Top 10 CI systems used with GitHub.com based on most used commit status contexts](https://user-images.githubusercontent.com/7321362/32575895-ea563032-c49a-11e7-9581-e05ec882658b.png)][20] + +If you'd like to check them out, here are the top 10 tools teams use: + +* [Travis CI][1] + +* [Circle CI][2] + +* [Jenkins][3] + +* [AppVeyor][4] + +* [CodeShip][5] + +* [Drone][6] + +* [Semaphore CI][7] + +* [Buildkite][8] + +* [Wercker][9] + +* [TeamCity][10] + +It's tempting to just pick the default, pre-integrated tool without taking the time to research and choose the best one for the job, but there are plenty of [excellent choices][21] built for your specific use cases. And if you change your mind later, no problem. When you choose the best tool for a specific situation, you're guaranteeing tailored performance and the freedom of interchangability when it no longer fits. + +Ready to see how CI tools can fit into your workflow? + +[Browse GitHub Marketplace][22] + +-------------------------------------------------------------------------------- + +via: https://github.com/blog/2463-github-welcomes-all-ci-tools + +作者:[jonico ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://github.com/jonico +[1]:https://travis-ci.org/ +[2]:https://circleci.com/ +[3]:https://jenkins.io/ +[4]:https://www.appveyor.com/ +[5]:https://codeship.com/ +[6]:http://try.drone.io/ +[7]:https://semaphoreci.com/ +[8]:https://buildkite.com/ +[9]:http://www.wercker.com/ +[10]:https://www.jetbrains.com/teamcity/ +[11]:https://user-images.githubusercontent.com/29592817/32509084-2d52c56c-c3a1-11e7-8c49-901f0f601faf.png +[12]:https://en.wikipedia.org/wiki/Continuous_integration +[13]:https://github.com/blog/2051-protected-branches-and-required-status-checks +[14]:https://en.wikipedia.org/wiki/Continuous_delivery +[15]:https://developer.github.com/changes/2014-01-09-preview-the-new-deployments-api/ +[16]:https://github.com/works-with/category/continuous-integration +[17]:https://github.com/marketplace/category/continuous-integration +[18]:https://github.com/explore?trending=repositories#trending +[19]:https://developer.github.com/v3/repos/statuses/ +[20]:https://user-images.githubusercontent.com/7321362/32575895-ea563032-c49a-11e7-9581-e05ec882658b.png +[21]:https://github.com/works-with/category/continuous-integration +[22]:https://github.com/marketplace/category/continuous-integration diff --git a/sources/tech/20171112 Love Your Bugs.md b/sources/tech/20171112 Love Your Bugs.md new file mode 100644 index 0000000000..bf79f27cf7 --- /dev/null +++ b/sources/tech/20171112 Love Your Bugs.md @@ -0,0 +1,311 @@ +Love Your Bugs +============================================================ + +In early October I gave a keynote at [Python Brasil][1] in Belo Horizonte. Here is an aspirational and lightly edited transcript of the talk. There is also a video available [here][2]. + +### I love bugs + +I’m currently a senior engineer at [Pilot.com][3], working on automating bookkeeping for startups. Before that, I worked for [Dropbox][4] on the desktop client team, and I’ll have a few stories about my work there. Earlier, I was a facilitator at the [Recurse Center][5], a writers retreat for programmers in NYC. I studied astrophysics in college and worked in finance for a few years before becoming an engineer. + +But none of that is really important to remember – the only thing you need to know about me is that I love bugs. I love bugs because they’re entertaining. They’re dramatic. The investigation of a great bug can be full of twists and turns. A great bug is like a good joke or a riddle – you’re expecting one outcome, but the result veers off in another direction. + +Over the course of this talk I’m going to tell you about some bugs that I have loved, explain why I love bugs so much, and then convince you that you should love bugs too. + +### Bug #1 + +Ok, straight into bug #1\. This is a bug that I encountered while working at Dropbox. As you may know, Dropbox is a utility that syncs your files from one computer to the cloud and to your other computers. + + + +``` + +--------------+ +---------------+ + | | | | + | METASERVER | | BLOCKSERVER | + | | | | + +-+--+---------+ +---------+-----+ + ^ | ^ + | | | + | | +----------+ | + | +---> | | | + | | CLIENT +--------+ + +--------+ | + +----------+ +``` + + +Here’s a vastly simplified diagram of Dropbox’s architecture. The desktop client runs on your local computer listening for changes in the file system. When it notices a changed file, it reads the file, then hashes the contents in 4MB blocks. These blocks are stored in the backend in a giant key-value store that we call blockserver. The key is the digest of the hashed contents, and the values are the contents themselves. + +Of course, we want to avoid uploading the same block multiple times. You can imagine that if you’re writing a document, you’re probably mostly changing the end – we don’t want to upload the beginning over and over. So before uploading a block to the blockserver the client talks to a different server that’s responsible for managing metadata and permissions, among other things. The client asks metaserver whether it needs the block or has seen it before. The “metaserver” responds with whether or not each block needs to be uploaded. + +So the request and response look roughly like this: The client says, “I have a changed file made up of blocks with hashes `'abcd,deef,efgh'`”. The server responds, “I have those first two, but upload the third.” Then the client sends the block up to the blockserver. + + +``` + +--------------+ +---------------+ + | | | | + | METASERVER | | BLOCKSERVER | + | | | | + +-+--+---------+ +---------+-----+ + ^ | ^ + | | 'ok, ok, need' | +'abcd,deef,efgh' | | +----------+ | efgh: [contents] + | +---> | | | + | | CLIENT +--------+ + +--------+ | + +----------+ +``` + + + +That’s the setup. So here’s the bug. + + + +``` + +--------------+ + | | + | METASERVER | + | | + +-+--+---------+ + ^ | + | | '???' +'abcdldeef,efgh' | | +----------+ + ^ | +---> | | + ^ | | CLIENT + + +--------+ | + +----------+ +``` + +Sometimes the client would make a weird request: each hash value should have been sixteen characters long, but instead it was thirty-three characters long – twice as many plus one. The server wouldn’t know what to do with this and would throw an exception. We’d see this exception get reported, and we’d go look at the log files from the desktop client, and really weird stuff would be going on – the client’s local database had gotten corrupted, or python would be throwing MemoryErrors, and none of it would make sense. + +If you’ve never seen this problem before, it’s totally mystifying. But once you’d seen it once, you can recognize it every time thereafter. Here’s a hint: the middle character of each 33-character string that we’d often see instead of a comma was `l`. These are the other characters we’d see in the middle position: + + +``` +l \x0c < $ ( . - +``` + +The ordinal value for an ascii comma – `,` – is 44\. The ordinal value for `l` is 108\. In binary, here’s how those two are represented: + +``` +bin(ord(',')): 0101100 +bin(ord('l')): 1101100 +``` + +You’ll notice that an `l` is exactly one bit away from a comma. And herein lies your problem: a bitflip. One bit of memory that the desktop client is using has gotten corrupted, and now the desktop client is sending a request to the server that is garbage. + +And here are the other characters we’d frequently see instead of the comma when a different bit had been flipped. + + + +``` +, : 0101100 +l : 1101100 +\x0c : 0001100 +< : 0111100 +$ : 0100100 +( : 0101000 +. : 0101110 +- : 0101101 +``` + + +### Bitflips are real! + +I love this bug because it shows that bitflips are a real thing that can happen, not just a theoretical concern. In fact, there are some domains where they’re more common than others. One such domain is if you’re getting requests from users with low-end or old hardware, which is true for a lot of laptops running Dropbox. Another domain with lots of bitflips is outer space – there’s no atmosphere in space to protect your memory from energetic particles and radiation, so bitflips are pretty common. + +You probably really care about correctness in space – your code might be keeping astronauts alive on the ISS, for example, but even if it’s not mission-critical, it’s hard to do software updates to space. If you really need your application to defend against bitflips, there are a variety of hardware & software approaches you can take, and there’s a [very interesting talk][6] by Katie Betchold about this. + +Dropbox in this context doesn’t really need to protect against bitflips. The machine that is corrupting memory is a user’s machine, so we can detect if the bitflip happens to fall in the comma – but if it’s in a different character we don’t necessarily know it, and if the bitflip is in the actual file data read off of disk, then we have no idea. There’s a pretty limited set of places where we could address this, and instead we decide to basically silence the exception and move on. Often this kind of bug resolves after the client restarts. + +### Unlikely bugs aren’t impossible + +This is one of my favorite bugs for a couple of reasons. The first is that it’s a reminder of the difference between unlikely and impossible. At sufficient scale, unlikely events start to happen at a noticable rate. + +### Social bugs + +My second favorite thing about this bug is that it’s a tremendously social one. This bug can crop up anywhere that the desktop client talks to the server, which is a lot of different endpoints and components in the system. This meant that a lot of different engineers at Dropbox would see versions of the bug. The first time you see it, you can  _really_  scratch your head, but after that it’s easy to diagnose, and the investigation is really quick: you look at the middle character and see if it’s an `l`. + +### Cultural differences + +One interesting side-effect of this bug was that it exposed a cultural difference between the server and client teams. Occasionally this bug would be spotted by a member of the server team and investigated from there. If one of your  _servers_  is flipping bits, that’s probably not random chance – it’s probably memory corruption, and you need to find the affected machine and get it out of the pool as fast as possible or you risk corrupting a lot of user data. That’s an incident, and you need to respond quickly. But if the user’s machine is corrupting data, there’s not a lot you can do. + +### Share your bugs + +So if you’re investigating a confusing bug, especially one in a big system, don’t forget to talk to people about it. Maybe your colleagues have seen a bug shaped like this one before. If they have, you might save a lot of time. And if they haven’t, don’t forget to tell people about the solution once you’ve figured it out – write it up or tell the story in your team meeting. Then the next time your teams hits something similar, you’ll all be more prepared. + +### How bugs can help you learn + +### Recurse Center + +Before I joined Dropbox, I worked for the Recurse Center. The idea behind RC is that it’s a community of self-directed learners spending time together getting better as programmers. That is the full extent of the structure of RC: there’s no curriculum or assignments or deadlines. The only scoping is a shared goal of getting better as a programmer. We’d see people come to participate in the program who had gotten CS degrees but didn’t feel like they had a solid handle on practical programming, or people who had been writing Java for ten years and wanted to learn Clojure or Haskell, and many other profiles as well. + +My job there was as a facilitator, helping people make the most of the lack of structure and providing guidance based on what we’d learned from earlier participants. So my colleagues and I were very interested in the best techniques for learning for self-motivated adults. + +### Deliberate Practice + +There’s a lot of different research in this space, and one of the ones I think is most interesting is the idea of deliberate practice. Deliberate practice is an attempt to explain the difference in performance between experts & amateurs. And the guiding principle here is that if you look just at innate characteristics – genetic or otherwise – they don’t go very far towards explaining the difference in performance. So the researchers, originally Ericsson, Krampe, and Tesch-Romer, set out to discover what did explain the difference. And what they settled on was time spent in deliberate practice. + +Deliberate practice is pretty narrow in their definition: it’s not work for pay, and it’s not playing for fun. You have to be operating on the edge of your ability, doing a project appropriate for your skill level (not so easy that you don’t learn anything and not so hard that you don’t make any progress). You also have to get immediate feedback on whether or not you’ve done the thing correctly. + +This is really exciting, because it’s a framework for how to build expertise. But the challenge is that as programmers this is really hard advice to apply. It’s hard to know whether you’re operating at the edge of your ability. Immediate corrective feedback is very rare – in some cases you’re lucky to get feedback ever, and in other cases maybe it takes months. You can get quick feedback on small things in the REPL and so on, but if you’re making a design decision or picking a technology, you’re not going to get feedback on those things for quite a long time. + +But one category of programming where deliberate practice is a useful model is debugging. If you wrote code, then you had a mental model of how it worked when you wrote it. But your code has a bug, so your mental model isn’t quite right. By definition you’re on the boundary of your understanding – so, great! You’re about to learn something new. And if you can reproduce the bug, that’s a rare case where you can get immediate feedback on whether or not your fix is correct. + +A bug like this might teach you something small about your program, or you might learn something larger about the system your code is running in. Now I’ve got a story for you about a bug like that. + +### Bug #2 + +This bug also one that I encountered at Dropbox. At the time, I was investigating why some desktop client weren’t sending logs as consistently as we expected. I’d started digging into the client logging system and discovered a bunch of interesting bugs. I’ll tell you only the subset of those bugs that is relevant to this story. + +Again here’s a very simplified architecture of the system. + + +``` + +--------------+ + | | + +---+ +----------> | LOG SERVER | + |log| | | | + +---+ | +------+-------+ + | | + +-----+----+ | 200 ok + | | | + | CLIENT | <-----------+ + | | + +-----+----+ + ^ + +--------+--------+--------+ + | ^ ^ | + +--+--+ +--+--+ +--+--+ +--+--+ + | log | | log | | log | | log | + | | | | | | | | + | | | | | | | | + +-----+ +-----+ +-----+ +-----+ +``` + +The desktop client would generate logs. Those logs were compress, encrypted, and written to disk. Then every so often the client would send them up to the server. The client would read a log off of disk and send it to the log server. The server would decrypt it and store it, then respond with a 200. + +If the client couldn’t reach the log server, it wouldn’t let the log directory grow unbounded. After a certain point it would start deleting logs to keep the directory under a maximum size. + +The first two bugs were not a big deal on their own. The first one was that the desktop client sent logs up to the server starting with the oldest one instead of starting with the newest. This isn’t really what you want – for example, the server would tell the client to send logs if the client reported an exception, so probably you care about the logs that just happened and not the oldest logs that happen to be on disk. + +The second bug was similar to the first: if the log directory hit its maximum size, the client would delete the logs starting with the newest instead of starting with the oldest. Again, you lose log files either way, but you probably care less about the older ones. + +The third bug had to do with the encryption. Sometimes, the server would be unable to decrypt a log file. (We generally didn’t figure out why – maybe it was a bitflip.) We weren’t handling this error correctly on the backend, so the server would reply with a 500\. The client would behave reasonably in the face of a 500: it would assume that the server was down. So it would stop sending log files and not try to send up any of the others. + +Returning a 500 on a corrupted log file is clearly not the right behavior. You could consider returning a 400, since it’s a problem with the client request. But the client also can’t fix the problem – if the log file can’t be decrypted now, we’ll never be able to decrypt it in the future. What you really want the client to do is just delete the log and move on. In fact, that’s the default behavior when the client gets a 200 back from the server for a log file that was successfully stored. So we said, ok – if the log file can’t be decrypted, just return a 200. + +All of these bugs were straightforward to fix. The first two bugs were on the client, so we’d fixed them on the alpha build but they hadn’t gone out to the majority of clients. The third bug we fixed on the server and deployed. + +### 📈 + +Suddenly traffic to the log cluster spikes. The serving team reaches out to us to ask if we know what’s going on. It takes me a minute to put all the pieces together. + +Before these fixes, there were four things going on: + +1. Log files were sent up starting with the oldest + +2. Log files were deleted starting with the newest + +3. If the server couldn’t decrypt a log file it would 500 + +4. If the client got a 500 it would stop sending logs + +A client with a corrupted log file would try to send it, the server would 500, the client would give up sending logs. On its next run, it would try to send the same file again, fail again, and give up again. Eventually the log directory would get full, at which point the client would start deleting its newest files, leaving the corrupted one on disk. + +The upshot of these three bugs: if a client ever had a corrupted log file, we would never see logs from that client again. + +The problem is that there were a lot more clients in this state than we thought. Any client with a single corrupted file had been dammed up from sending logs to the server. Now that dam was cleared, and all of them were sending up the rest of the contents of their log directories. + +### Our options + +Ok, there’s a huge flood of traffic coming from machines around the world. What can we do? (This is a fun thing about working at a company with Dropbox’s scale, and particularly Dropbox’s scale of desktop clients: you can trigger a self-DDOS very easily.) + +The first option when you do a deploy and things start going sideways is to rollback. Totally reasonable choice, but in this case, it wouldn’t have helped us. The state that we’d transformed wasn’t the state on the server but the state on the client – we’d deleted those files. Rolling back the server would prevent additional clients from entering this state but it wouldn’t solve the problem. + +What about increasing the size of the logging cluster? We did that – and started getting even more requests, now that we’d increased our capacity. We increased it again, but you can’t do that forever. Why not? This cluster isn’t isolated. It’s making requests into another cluster, in this case to handle exceptions. If you have a DDOS pointed at one cluster, and you keep scaling that cluster, you’re going to knock over its depedencies too, and now you have two problems. + +Another option we considered was shedding load – you don’t need every single log file, so can we just drop requests. One of the challenges here was that we didn’t have an easy way to tell good traffic from bad. We couldn’t quickly differentiate which log files were old and which were new. + +The solution we hit on is one that’s been used at Dropbox on a number of different occassions: we have a custom header, `chillout`, which every client in the world respects. If the client gets a response with this header, then it doesn’t make any requests for the provided number of seconds. Someone very wise added this to the Dropbox client very early on, and it’s come in handy more than once over the years. The logging server didn’t have the ability to set that header, but that’s an easy problem to solve. So two of my colleagues, Isaac Goldberg and John Lai, implemented support for it. We set the logging cluster chillout to two minutes initially and then managed it down as the deluge subsided over the next couple of days. + +### Know your system + +The first lesson from this bug is to know your system. I had a good mental model of the interaction between the client and the server, but I wasn’t thinking about what would happen when the server was interacting with all the clients at once. There was a level of complexity that I hadn’t thought all the way through. + +### Know your tools + +The second lesson is to know your tools. If things go sideways, what options do you have? Can you reverse your migration? How will you know if things are going sideways and how can you discover more? All of those things are great to know before a crisis – but if you don’t, you’ll learn them during a crisis and then never forget. + +### Feature flags & server-side gating + +The third lesson is for you if you’re writing a mobile or a desktop application:  _You need server-side feature gating and server-side flags._  When you discover a problem and you don’t have server-side controls, the resolution might take days or weeks as you push out a new release or submit a new version to the app store. That’s a bad situation to be in. The Dropbox desktop client isn’t going through an app store review process, but just pushing out a build to tens of millions of clients takes time. Compare that to hitting a problem in your feature and flipping a switch on the server: ten minutes later your problem is resolved. + +This strategy is not without its costs. Having a bunch of feature flags in your code adds to the complexity dramatically. You get a combinatoric problem with your testing: what if feature A is enabled and feature B, or just one, or neither – multiplied across N features. It’s extremely difficult to get engineers to clean up their feature flags after the fact (and I was also guilty of this). Then for the desktop client there’s multiple versions in the wild at the same time, so it gets pretty hard to reason about. + +But the benefit – man, when you need it, you really need it. + +# How to love bugs + +I’ve talked about some bugs that I love and I’ve talked about why to love bugs. Now I want to tell you how to love bugs. If you don’t love bugs yet, I know of exactly one way to learn, and that’s to have a growth mindset. + +The sociologist Carol Dweck has done a ton of interesting research about how people think about intelligence. She’s found that there are two different frameworks for thinking about intelligence. The first, which she calls the fixed mindset, holds that intelligence is a fixed trait, and people can’t change how much of it they have. The other mindset is a growth mindset. Under a growth mindset, people believe that intelligence is malleable and can increase with effort. + +Dweck found that a person’s theory of intelligence – whether they hold a fixed or growth mindset – can significantly influence the way they select tasks to work on, the way they respond to challenges, their cognitive performance, and even their honesty. + +[I also talked about a growth mindset in my Kiwi PyCon keynote, so here are just a few excerpts. You can read the full transcript [here][7].] + +Findings about honesty: + +> After this, they had the students write letters to pen pals about the study, saying “We did this study at school, and here’s the score that I got.” They found that  _almost half of the students praised for intelligence lied about their scores_ , and almost no one who was praised for working hard was dishonest. + +On effort: + +> Several studies found that people with a fixed mindset can be reluctant to really exert effort, because they believe it means they’re not good at the thing they’re working hard on. Dweck notes, “It would be hard to maintain confidence in your ability if every time a task requires effort, your intelligence is called into question.” + +On responding to confusion: + +> They found that students with a growth mindset mastered the material about 70% of the time, regardless of whether there was a confusing passage in it. Among students with a fixed mindset, if they read the booklet without the confusing passage, again about 70% of them mastered the material. But the fixed-mindset students who encountered the confusing passage saw their mastery drop to 30%. Students with a fixed mindset were pretty bad at recovering from being confused. + +These findings show that a growth mindset is critical while debugging. We have to recover from confusion, be candid about the limitations of our understanding, and at times really struggle on the way to finding solutions – all of which is easier and less painful with a growth mindset. + +### Love your bugs + +I learned to love bugs by explicitly celebrating challenges while working at the Recurse Center. A participant would sit down next to me and say, “[sigh] I think I’ve got a weird Python bug,” and I’d say, “Awesome, I  _love_  weird Python bugs!” First of all, this is definitely true, but more importantly, it emphasized to the participant that finding something where they struggled an accomplishment, and it was a good thing for them to have done that day. + +As I mentioned, at the Recurse Center there are no deadlines and no assignments, so this attitude is pretty much free. I’d say, “You get to spend a day chasing down this weird bug in Flask, how exciting!” At Dropbox and later at Pilot, where we have a product to ship, deadlines, and users, I’m not always uniformly delighted about spending a day on a weird bug. So I’m sympathetic to the reality of the world where there are deadlines. However, if I have a bug to fix, I have to fix it, and being grumbly about the existence of the bug isn’t going to help me fix it faster. I think that even in a world where deadlines loom, you can still apply this attitude. + +If you love your bugs, you can have more fun while you’re working on a tough problem. You can be less worried and more focused, and end up learning more from them. Finally, you can share a bug with your friends and colleagues, which helps you and your teammates. + +### Obrigada! + +My thanks to folks who gave me feedback on this talk and otherwise contributed to my being there: + +* Sasha Laundy + +* Amy Hanlon + +* Julia Evans + +* Julian Cooper + +* Raphael Passini Diniz and the rest of the Python Brasil organizing team + +-------------------------------------------------------------------------------- + +via: http://akaptur.com/blog/2017/11/12/love-your-bugs/ + +作者:[Allison Kaptur ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://akaptur.com/about/ +[1]:http://2017.pythonbrasil.org.br/# +[2]:http://www.youtube.com/watch?v=h4pZZOmv4Qs +[3]:http://www.pilot.com/ +[4]:http://www.dropbox.com/ +[5]:http://www.recurse.com/ +[6]:http://www.youtube.com/watch?v=ETgNLF_XpEM +[7]:http://akaptur.com/blog/2015/10/10/effective-learning-strategies-for-programmers/ diff --git a/sources/tech/20171113 Glitch write fun small web projects instantly.md b/sources/tech/20171113 Glitch write fun small web projects instantly.md new file mode 100644 index 0000000000..734853ce51 --- /dev/null +++ b/sources/tech/20171113 Glitch write fun small web projects instantly.md @@ -0,0 +1,76 @@ +translating---geekpi + +Glitch: write fun small web projects instantly +============================================================ + +I just wrote about Jupyter Notebooks which are a fun interactive way to write Python code. That reminded me I learned about Glitch recently, which I also love!! I built a small app to [turn of twitter retweets][2] with it. So! + +[Glitch][3] is an easy way to make Javascript webapps. (javascript backend, javascript frontend) + +The fun thing about glitch is: + +1. you start typing Javascript code into their web interface + +2. as soon as you type something, it automagically reloads the backend of your website with the new code. You don’t even have to save!! It autosaves. + +So it’s like Heroku, but even more magical!! Coding like this (you type, and the code runs on the public internet immediately) just feels really **fun** to me. + +It’s kind of like sshing into a server and editing PHP/HTML code on your server and having it instantly available, which I kind of also loved. Now we have “better deployment practices” than “just edit the code and it is instantly on the internet” but we are not talking about Serious Development Practices, we are talking about writing tiny programs for fun. + +### glitch has awesome example apps + +Glitch seems like fun nice way to learn programming! + +For example, there’s a space invaders game (code by [Mary Rose Cook][4]) at [https://space-invaders.glitch.me/][5]. The thing I love about this is that in just a few clicks I can + +1. click “remix this” + +2. start editing the code to make the boxes orange instead of black + +3. have my own space invaders game!! Mine is at [http://julias-space-invaders.glitch.me/][1]. (i just made very tiny edits to make it orange, nothing fancy) + +They have tons of example apps that you can start from – for instance [bots][6], [games][7], and more. + +### awesome actually useful app: tweetstorms + +The way I learned about Glitch was from this app which shows you tweetstorms from a given user: [https://tweetstorms.glitch.me/][8]. + +For example, you can see [@sarahmei][9]’s tweetstorms at [https://tweetstorms.glitch.me/sarahmei][10] (she tweets a lot of good tweetstorms!). + +### my glitch app: turn off retweets + +When I learned about Glitch I wanted to turn off retweets for everyone I follow on Twitter (I know you can do it in Tweetdeck!) and doing it manually was a pain – I had to do it one person at a time. So I wrote a tiny Glitch app to do it for me! + +I liked that I didn’t have to set up a local development environment, I could just start typing and go! + +Glitch only supports Javascript and I don’t really know Javascript that well (I think I’ve never written a Node program before), so the code isn’t awesome. But I had a really good time writing it – being able to type and just see my code running instantly was delightful. Here it is: [https://turn-off-retweets.glitch.me/][11]. + +### that’s all! + +Using Glitch feels really fun and democratic. Usually if I want to fork someone’s web project and make changes I wouldn’t do it – I’d have to fork it, figure out hosting, set up a local dev environment or Heroku or whatever, install the dependencies, etc. I think tasks like installing node.js dependencies used to be interesting, like “cool i am learning something new” and now I just find them tedious. + +So I love being able to just click “remix this!” and have my version on the internet instantly. + + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/11/13/glitch--write-small-web-projects-easily/ + +作者:[Julia Evans ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/ +[1]:http://julias-space-invaders.glitch.me/ +[2]:https://turn-off-retweets.glitch.me/ +[3]:https://glitch.com/ +[4]:https://maryrosecook.com/ +[5]:https://space-invaders.glitch.me/ +[6]:https://glitch.com/handy-bots +[7]:https://glitch.com/games +[8]:https://tweetstorms.glitch.me/ +[9]:https://twitter.com/sarahmei +[10]:https://tweetstorms.glitch.me/sarahmei +[11]:https://turn-off-retweets.glitch.me/ diff --git a/sources/tech/20171114 Sysadmin 101 Patch Management.md b/sources/tech/20171114 Sysadmin 101 Patch Management.md new file mode 100644 index 0000000000..55ca09da87 --- /dev/null +++ b/sources/tech/20171114 Sysadmin 101 Patch Management.md @@ -0,0 +1,61 @@ +【翻译中 @haoqixu】Sysadmin 101: Patch Management +============================================================ + +* [HOW-TOs][1] + +* [Servers][2] + +* [SysAdmin][3] + + +A few articles ago, I started a Sysadmin 101 series to pass down some fundamental knowledge about systems administration that the current generation of junior sysadmins, DevOps engineers or "full stack" developers might not learn otherwise. I had thought that I was done with the series, but then the WannaCry malware came out and exposed some of the poor patch management practices still in place in Windows networks. I imagine some readers that are still stuck in the Linux versus Windows wars of the 2000s might have even smiled with a sense of superiority when they heard about this outbreak. + +The reason I decided to revive my Sysadmin 101 series so soon is I realized that most Linux system administrators are no different from Windows sysadmins when it comes to patch management. Honestly, in some areas (in particular, uptime pride), some Linux sysadmins are even worse than Windows sysadmins regarding patch management. So in this article, I cover some of the fundamentals of patch management under Linux, including what a good patch management system looks like, the tools you will want to put in place and how the overall patching process should work. + +### What Is Patch Management? + +When I say patch management, I'm referring to the systems you have in place to update software already on a server. I'm not just talking about keeping up with the latest-and-greatest bleeding-edge version of a piece of software. Even more conservative distributions like Debian that stick with a particular version of software for its "stable" release still release frequent updates that patch bugs or security holes. + +Of course, if your organization decided to roll its own version of a particular piece of software, either because developers demanded the latest and greatest, you needed to fork the software to apply a custom change, or you just like giving yourself extra work, you now have a problem. Ideally you have put in a system that automatically packages up the custom version of the software for you in the same continuous integration system you use to build and package any other software, but many sysadmins still rely on the outdated method of packaging the software on their local machine based on (hopefully up to date) documentation on their wiki. In either case, you will need to confirm that your particular version has the security flaw, and if so, make sure that the new patch applies cleanly to your custom version. + +### What Good Patch Management Looks Like + +Patch management starts with knowing that there is a software update to begin with. First, for your core software, you should be subscribed to your Linux distribution's security mailing list, so you're notified immediately when there are security patches. If there you use any software that doesn't come from your distribution, you must find out how to be kept up to date on security patches for that software as well. When new security notifications come in, you should review the details so you understand how severe the security flaw is, whether you are affected and gauge a sense of how urgent the patch is. + +Some organizations have a purely manual patch management system. With such a system, when a security patch comes along, the sysadmin figures out which servers are running the software, generally by relying on memory and by logging in to servers and checking. Then the sysadmin uses the server's built-in package management tool to update the software with the latest from the distribution. Then the sysadmin moves on to the next server, and the next, until all of the servers are patched. + +There are many problems with manual patch management. First is the fact that it makes patching a laborious chore. The more work patching is, the more likely a sysadmin will put it off or skip doing it entirely. The second problem is that manual patch management relies too much on the sysadmin's ability to remember and recall all of the servers he or she is responsible for and keep track of which are patched and which aren't. This makes it easy for servers to be forgotten and sit unpatched. + +The faster and easier patch management is, the more likely you are to do it. You should have a system in place that quickly can tell you which servers are running a particular piece of software at which version. Ideally, that system also can push out updates. Personally, I prefer orchestration tools like MCollective for this task, but Red Hat provides Satellite, and Canonical provides Landscape as central tools that let you view software versions across your fleet of servers and apply patches all from a central place. + +Patching should be fault-tolerant as well. You should be able to patch a service and restart it without any overall down time. The same idea goes for kernel patches that require a reboot. My approach is to divide my servers into different high availability groups so that lb1, app1, rabbitmq1 and db1 would all be in one group, and lb2, app2, rabbitmq2 and db2 are in another. Then, I know I can patch one group at a time without it causing downtime anywhere else. + +So, how fast is fast? Your system should be able to roll out a patch to a minor piece of software that doesn't have an accompanying service (such as bash in the case of the ShellShock vulnerability) within a few minutes to an hour at most. For something like OpenSSL that requires you to restart services, the careful process of patching and restarting services in a fault-tolerant way probably will take more time, but this is where orchestration tools come in handy. I gave examples of how to use MCollective to accomplish this in my recent MCollective articles (see the December 2016 and January 2017 issues), but ideally, you should put a system in place that makes it easy to patch and restart services in a fault-tolerant and automated way. + +When patching requires a reboot, such as in the case of kernel patches, it might take a bit more time, but again, automation and orchestration tools can make this go much faster than you might imagine. I can patch and reboot the servers in an environment in a fault-tolerant way within an hour or two, and it would be much faster than that if I didn't need to wait for clusters to sync back up in between reboots. + +Unfortunately, many sysadmins still hold on to the outdated notion that uptime is a badge of pride—given that serious kernel patches tend to come out at least once a year if not more often, to me, it's proof you don't take security seriously. + +Many organizations also still have that single point of failure server that can never go down, and as a result, it never gets patched or rebooted. If you want to be secure, you need to remove these outdated liabilities and create systems that at least can be rebooted during a late-night maintenance window. + +Ultimately, fast and easy patch management is a sign of a mature and professional sysadmin team. Updating software is something all sysadmins have to do as part of their jobs, and investing time into systems that make that process easy and fast pays dividends far beyond security. For one, it helps identify bad architecture decisions that cause single points of failure. For another, it helps identify stagnant, out-of-date legacy systems in an environment and provides you with an incentive to replace them. Finally, when patching is managed well, it frees up sysadmins' time and turns their attention to the things that truly require their expertise. + +______________________ + +Kyle Rankin is senior security and infrastructure architect, the author of many books including Linux Hardening in Hostile Networks, DevOps Troubleshooting and The Official Ubuntu Server Book, and a columnist for Linux Journal. Follow him @kylerankin + +-------------------------------------------------------------------------------- + +via: https://www.linuxjournal.com/content/sysadmin-101-patch-management + +作者:[Kyle Rankin ][a] +译者:[译者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 +[1]:https://www.linuxjournal.com/tag/how-tos +[2]:https://www.linuxjournal.com/tag/servers +[3]:https://www.linuxjournal.com/tag/sysadmin +[4]:https://www.linuxjournal.com/users/kyle-rankin diff --git a/sources/tech/20171114 Take Linux and Run With It.md b/sources/tech/20171114 Take Linux and Run With It.md new file mode 100644 index 0000000000..b7b6cb9663 --- /dev/null +++ b/sources/tech/20171114 Take Linux and Run With It.md @@ -0,0 +1,68 @@ +Take Linux and Run With It +============================================================ + +![](https://www.linuxinsider.com/article_images/story_graphics_xlarge/xl-2016-linux-1.jpg) + +![](https://www.linuxinsider.com/images/2015/image-credit-adobe-stock_130x15.gif) + + +"How do you run an operating system?" may seem like a simple question, since most of us are accustomed to turning on our computers and seeing our system spin up. However, this common model is only one way of running an operating system. As one of Linux's greatest strengths is versatility, Linux offers the most methods and environments for running it. + +To unleash the full power of Linux, and maybe even find a use for it you hadn't thought of, consider some less conventional ways of running it -- specifically, ones that don't even require installation on a computer's hard drive. + +### We'll Do It Live! + +Live-booting is a surprisingly useful and popular way to get the full Linux experience on the fly. While hard drives are where OSes reside most of the time, they actually can be installed to most major storage media, including CDs, DVDs and USB flash drives. + +When an OS is installed to some device other than a computer's onboard hard drive and subsequently booted instead of that onboard drive, it's called "live-booting" or running a "live session." + +At boot time, the user simply selects an external storage source for the hardware to look for boot information. If found, the computer follows the external device's boot instructions, essentially ignoring the onboard drive until the next time the user boots normally. Optical media are increasingly rare these days, so by far the most typical form that an external OS-carrying device takes is a USB stick. + +Most mainstream Linux distributions offer a way to run a live session as a way of trying them out. The live session doesn't save any user activity, and the OS resets to the clean default state after every shutdown. + +Live Linux sessions can be used for more than testing a distro, though. One application is for executing system repair for critically malfunctioning onboard (usually also Linux) systems. If an update or configuration made the onboard system unbootable, a full system backup is required, or the hard drive has sustained serious file corruption, the only recourse is to start up a live system and perform maintenance on the onboard drive. + +In these and similar scenarios, the onboard drive cannot be manipulated or corrected while also keeping the system stored on it running, so a live system takes on those burdens instead, leaving all but the problematic files on the onboard drive at rest. + +Live sessions also are perfectly suited for handling sensitive information. If you don't want a computer to retain any trace of the operations executed or information handled on it, especially if you are using hardware you can't vouch for -- like a public library or hotel business center computer -- a live session will provide you all the desktop computing functions to complete your task while retaining no trace of your session once you're finished. This is great for doing online banking or password input that you don't want a computer to remember. + +### Linux Virtually Anywhere + +Another approach for implementing Linux for more on-demand purposes is to run a virtual machine on another host OS. A virtual machine, or VM, is essentially a small computer running inside another computer and contained in a single large file. + +To run a VM, users simply install a hypervisor program (a kind of launcher for the VM), select a downloaded Linux OS image file (usually ending with a ".iso" file extension), and walk through the setup process. + +Most of the settings can be left at their defaults, but the key ones to configure are the amount of RAM and hard drive storage to lease to the VM. Fortunately, since Linux has a light footprint, you don't have to set these very high: 2 GB of RAM and 16 GB of storage should be plenty for the VM while still letting your host OS thrive. + +So what does this offer that a live system doesn't? First, whereas live systems are ephemeral, VMs can retain the data stored on them. This is great if you want to set up your Linux VM for a special use case, like software development or even security. + +When used for development, a Linux VM gives you the solid foundation of Linux's programming language suites and coding tools, and it lets you save your projects right in the VM to keep everything organized. + +If security is your goal, Linux VMs allow you to impose an extra layer between a potential hazard and your system. If you do your browsing from the VM, a malicious program would have to compromise not only your virtual Linux system, but also the hypervisor -- and  _then_ your host OS, a technical feat beyond all but the most skilled and determined adversaries. + +Second, you can start up your VM on demand from your host system, without having to power it down and start it up again as you would have to with a live session. When you need it, you can quickly bring up the VM, and when you're finished, you just shut it down and go back to what you were doing before. + +Your host system continues running normally while the VM is on, so you can attend to tasks simultaneously in each system. + +### Look Ma, No Installation! + +Just as there is no one form that Linux takes, there's also no one way to run it. Hopefully, this brief primer on the kinds of systems you can run has given you some ideas to expand your use models. + +The best part is that if you're not sure how these can help, live booting and virtual machines don't hurt to try!  +![](https://www.ectnews.com/images/end-enn.gif) + +-------------------------------------------------------------------------------- + +via: https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html + +作者:[ Jonathan Terrasi ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html#searchbyline +[1]:https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html# +[2]:https://www.linuxinsider.com/perl/mailit/?id=84951 +[3]:https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html +[4]:https://www.linuxinsider.com/story/Take-Linux-and-Run-With-It-84951.html diff --git a/sources/tech/20171115 Security Jobs Are Hot Get Trained and Get Noticed.md b/sources/tech/20171115 Security Jobs Are Hot Get Trained and Get Noticed.md new file mode 100644 index 0000000000..a0a6b1ed60 --- /dev/null +++ b/sources/tech/20171115 Security Jobs Are Hot Get Trained and Get Noticed.md @@ -0,0 +1,58 @@ +Security Jobs Are Hot: Get Trained and Get Noticed +============================================================ + +![security skills](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/security-skills.png?itok=IrwppCUw "security skills") +The Open Source Jobs Report, from Dice and The Linux Foundation, found that professionals with security experience are in high demand for the future.[Used with permission][1] + +The demand for security professionals is real. On [Dice.com][4], 15 percent of the more than 75K jobs are security positions. “Every year in the U.S., 40,000 jobs for information security analysts go unfilled, and employers are struggling to fill 200,000 other cyber-security related roles, according to cyber security data tool [CyberSeek][5]” ([Forbes][6]). We know that there is a fast-increasing need for security specialists, but that the interest level is low. + +### Security is the place to be + +In my experience, few students coming out of college are interested in roles in security; so many people see security as niche. Entry-level tech pros are interested in business analyst or system analyst roles, because of a belief that if you want to learn and apply core IT concepts, you have to stick to analyst roles or those closer to product development. That’s simply not the case. + +In fact, if you’re interested in getting in front of your business leaders, security is the place to be – as a security professional, you have to understand the business end-to-end; you have to look at the big picture to give your company the advantage. + +### Be fearless + +Analyst and security roles are not all that different. Companies continue to merge engineering and security roles out of necessity. Businesses are moving faster than ever with infrastructure and code being deployed through automation, which increases the importance of security being a part of all tech pros day to day lives. In our [Open Source Jobs Report with The Linux Foundation][7], 42 percent of hiring managers said professionals with security experience are in high demand for the future. + +There has never been a more exciting time to be in security. If you stay up-to-date with tech news, you’ll see that a huge number of stories are related to security – data breaches, system failures and fraud. The security teams are working in ever-changing, fast-paced environments. A real challenge lies is in the proactive side of security, finding, and eliminating vulnerabilities while maintaining or even improving the end-user experience.   + +### Growth is imminent + +Of any aspect of tech, security is the one that will continue to grow with the cloud. Businesses are moving more and more to the cloud and that’s exposing more security vulnerabilities than organizations are used to. As the cloud matures, security becomes increasingly important.            + +Regulations are also growing – Personally Identifiable Information (PII) is getting broader all the time. Many companies are finding that they must invest in security to stay in compliance and avoid being in the headlines. Companies are beginning to budget more and more for security tooling and staffing due to the risk of heavy fines, reputational damage, and, to be honest, executive job security.   + +### Training and support + +Even if you don’t choose a security-specific role, you’re bound to find yourself needing to code securely, and if you don’t have the skills to do that, you’ll start fighting an uphill battle. There are certainly ways to learn on-the-job if your company offers that option, that’s encouraged but I recommend a combination of training, mentorship and constant practice. Without using your security skills, you’ll lose them fast with how quickly the complexity of malicious attacks evolve. + +My recommendation for those seeking security roles is to find the people in your organization that are the strongest in engineering, development, or architecture areas – interface with them and other teams, do hands-on work, and be sure to keep the big-picture in mind. Be an asset to your organization that stands out – someone that can securely code and also consider strategy and overall infrastructure health. + +### The end game + +More and more companies are investing in security and trying to fill open roles in their tech teams. If you’re interested in management, security is the place to be. Executive leadership wants to know that their company is playing by the rules, that their data is secure, and that they’re safe from breaches and loss. + +Security that is implemented wisely and with strategy in mind will get noticed. Security is paramount for executives and consumers alike – I’d encourage anyone interested in security to train up and contribute. + + _[Download ][2]the full 2017 Open Source Jobs Report now._ + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/os-jobs-report/2017/11/security-jobs-are-hot-get-trained-and-get-noticed + +作者:[ BEN COLLEN][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/bencollen +[1]:https://www.linux.com/licenses/category/used-permission +[2]:http://bit.ly/2017OSSjobsreport +[3]:https://www.linux.com/files/images/security-skillspng +[4]:http://www.dice.com/ +[5]:http://cyberseek.org/index.html#about +[6]:https://www.forbes.com/sites/jeffkauflin/2017/03/16/the-fast-growing-job-with-a-huge-skills-gap-cyber-security/#292f0a675163 +[7]:http://media.dice.com/report/the-2017-open-source-jobs-report-employers-prioritize-hiring-open-source-professionals-with-latest-skills/ diff --git a/sources/tech/20171115 Why and How to Set an Open Source Strategy.md b/sources/tech/20171115 Why and How to Set an Open Source Strategy.md new file mode 100644 index 0000000000..79ec071b4d --- /dev/null +++ b/sources/tech/20171115 Why and How to Set an Open Source Strategy.md @@ -0,0 +1,120 @@ +Why and How to Set an Open Source Strategy +============================================================ + +![](https://www.linuxfoundation.org/wp-content/uploads/2017/11/open-source-strategy-1024x576.jpg) + +This article explains how to walk through, measure, and define strategies collaboratively in an open source community. + + _“If you don’t know where you are going, you’ll end up someplace else.” _ _—_  Yogi Berra + +Open source projects are generally started as a way to scratch one’s itch — and frankly that’s one of its greatest attributes. Getting code down provides a tangible method to express an idea, showcase a need, and solve a problem. It avoids over thinking and getting a project stuck in analysis-paralysis, letting the project pragmatically solve the problem at hand. + +Next, a project starts to scale up and gets many varied users and contributions, with plenty of opinions along the way. That leads to the next big challenge — how does a project start to build a strategic vision? In this article, I’ll describe how to walk through, measure, and define strategies collaboratively, in a community. + +Strategy may seem like a buzzword of the corporate world rather something that an open source community would embrace, so I suggest stripping away the negative actions that are sometimes associated with this word (e.g., staff reductions, discontinuations, office closures). Strategy done right isn’t a tool to justify unfortunate actions but to help show focus and where each community member can contribute. + +A good application of strategy achieves the following: + +* Why the project exists? + +* What the project looks to achieve? + +* What is the ideal end state for a project is. + +The key to success is answering these questions as simply as possible, with consensus from your community. Let’s look at some ways to do this. + +### Setting a mission and vision + + _“_ _Efforts and courage are not enough without purpose and direction.”_  — John F. Kennedy + +All strategic planning starts off with setting a course for where the project wants to go. The two tools used here are  _Mission_  and  _Vision_ . They are complementary terms, describing both the reason a project exists (mission) and the ideal end state for a project (vision). + +A great way to start this exercise with the intent of driving consensus is by asking each key community member the following questions: + +* What drove you to join and/or contribute the project? + +* How do you define success for your participation? + +In a company, you’d ask your customers these questions usually. But in open source projects, the customers are the project participants — and their time investment is what makes the project a success. + +Driving consensus means capturing the answers to these questions and looking for themes across them. At R Consortium, for example, I created a shared doc for the board to review each member’s answers to the above questions, and followed up with a meeting to review for specific themes that came from those insights. + +Building a mission flows really well from this exercise. The key thing is to keep the wording of your mission short and concise. Open Mainframe Project has done this really well. Here’s their mission: + + _Build community and adoption of Open Source on the mainframe by:_ + +* _Eliminating barriers to Open Source adoption on the mainframe_ + +* _Demonstrating value of the mainframe on technical and business levels_ + +* _Strengthening collaboration points and resources for the community to thrive_ + +At 40 words, it passes the key eye tests of a good mission statement; it’s clear, concise, and demonstrates the useful value the project aims for. + +The next stage is to reflect on the mission statement and ask yourself this question: What is the ideal outcome if the project accomplishes its mission? That can be a tough one to tackle. Open Mainframe Project put together its vision really well: + + _Linux on the Mainframe as the standard for enterprise class systems and applications._ + +You could read that as a [BHAG][1], but it’s really more of a vision, because it describes a future state that is what would be created by the mission being fully accomplished. It also hits the key pieces to an effective vision — it’s only 13 words, inspirational, clear, memorable, and concise. + +Mission and vision add clarity on the who, what, why, and how for your project. But, how do you set a course for getting there? + +### Goals, Objectives, Actions, and Results + + _“I don’t focus on what I’m up against. I focus on my goals and I try to ignore the rest.”_  — Venus Williams + +Looking at a mission and vision can get overwhelming, so breaking them down into smaller chunks can help the project determine how to get started. This also helps prioritize actions, either by importance or by opportunity. Most importantly, this step gives you guidance on what things to focus on for a period of time, and which to put off. + +There are lots of methods of time bound planning, but the method I think works the best for projects is what I’ve dubbed the GOAR method. It’s an acronym that stands for: + +* Goals define what the project is striving for and likely would align and support the mission. Examples might be “Grow a diverse contributor base” or “Become the leading project for X.” Goals are aspirational and set direction. + +* Objectives show how you measure a goal’s completion, and should be clear and measurable. You might also have multiple objectives to measure the completion of a goal. For example, the goal “Grow a diverse contributor base” might have objectives such as “Have X total contributors monthly” and “Have contributors representing Y different organizations.” + +* Actions are what the project plans to do to complete an objective. This is where you get tactical on exactly what needs done. For example, the objective “Have contributors representing Y different organizations” would like have actions of reaching out to interested organizations using the project, having existing contributors mentor new mentors, and providing incentives for first time contributors. + +* Results come along the way, showing progress both positive and negative from the actions. + +You can put these into a table like this: + +| Goals | Objectives | Actions | Results | +|:--|:--|:--|:--| +| Grow a diverse contributor base     | Have X total contributors monthly | Existing contributors mentor new mentors Providing incentives for first time contributors | | +| | Have contributors representing Y different organizations | Reach out to interested organizations using the project | | + + +In large organizations, monthly or quarterly goals and objectives often make sense; however, on open source projects, these time frames are unrealistic. Six- even 12-month tracking allows the project leadership to focus on driving efforts at a high level by nurturing the community along. + +The end result is a rubric that provides clear vision on where the project is going. It also lets community members more easily find ways to contribute. For example, your project may include someone who knows a few organizations using the project — this person could help introduce those developers to the codebase and guide them through their first commit. + +### What happens if the project doesn’t hit the goals? + + _“I have not failed. I’ve just found 10,000 ways that won’t work.”_  — Thomas A. Edison + +Figuring out what is within the capability of an organization — whether Fortune 500 or a small open source project — is hard. And, sometimes the expectations or market conditions change along the way. Does that make the strategy planning process a failure? Absolutely not! + +Instead, you can use this experience as a way to better understand your project’s velocity, its impact, and its community, and perhaps as a way to prioritize what is important and what’s not. + +-------------------------------------------------------------------------------- + +via: https://www.linuxfoundation.org/blog/set-open-source-strategy/ + +作者:[ John Mertic][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linuxfoundation.org/author/jmertic/ +[1]:https://en.wikipedia.org/wiki/Big_Hairy_Audacious_Goal +[2]:https://www.linuxfoundation.org/author/jmertic/ +[3]:https://www.linuxfoundation.org/category/blog/ +[4]:https://www.linuxfoundation.org/category/audience/c-level/ +[5]:https://www.linuxfoundation.org/category/audience/developer-influencers/ +[6]:https://www.linuxfoundation.org/category/audience/entrepreneurs/ +[7]:https://www.linuxfoundation.org/category/campaigns/membership/how-to/ +[8]:https://www.linuxfoundation.org/category/campaigns/events-campaigns/linux-foundation/ +[9]:https://www.linuxfoundation.org/category/audience/open-source-developers/ +[10]:https://www.linuxfoundation.org/category/audience/open-source-professionals/ +[11]:https://www.linuxfoundation.org/category/audience/open-source-users/ +[12]:https://www.linuxfoundation.org/category/blog/thought-leadership/ diff --git a/sources/tech/20171116 Unleash Your Creativity – Linux Programs for Drawing and Image Editing.md b/sources/tech/20171116 Unleash Your Creativity – Linux Programs for Drawing and Image Editing.md new file mode 100644 index 0000000000..c6c50d9b25 --- /dev/null +++ b/sources/tech/20171116 Unleash Your Creativity – Linux Programs for Drawing and Image Editing.md @@ -0,0 +1,130 @@ +### Unleash Your Creativity – Linux Programs for Drawing and Image Editing + + By: [chabowski][1] + +The following article is part of a series of articles that provide tips and tricks for Linux newbies – or Desktop users that are not yet experienced with regard to certain topics. This series intends to complement the special edition #30 “[Getting Started with Linux][2]” based on [openSUSE Leap][3], recently published by the [Linux Magazine,][4] with valuable additional information. + +![](https://www.suse.com/communities/blog/files/2017/11/DougDeMaio-450x450.jpeg) + +This article has been contributed by Douglas DeMaio, openSUSE PR Expert at SUSE. + +Both Mac OS or Window offer several popular programs for graphics editing, vector drawing and creating and manipulating Portable Document Format (PDF). The good news: users familiar with the Adobe Suite can transition with ease to free, open-source programs available on Linux. + +Programs like [GIMP][5], [InkScape][6] and [Okular][7] are cross platform programs that are available by default in Linux/GNU distributions and are persuasive alternatives to expensive Adobe programs like [Photoshop][8], [Illustrator][9] and [Acrobat][10]. + +These creativity programs on Linux distributions are just as powerful as those for macOS or Window. This article will explain some of the differences and how the programs can be used to make your transition to Linux comfortable. + +### Krita + +The KDE desktop environment comes with tons of cool applications. [Krita][11] is a professional open source painting program. It gives users the freedom to create any artistic image they desire. Krita features tools that are much more extensive than the tool sets of most proprietary programs you might be familiar with. From creating textures to comics, Krita is a must have application for Linux users. + +![](https://www.suse.com/communities/blog/files/2017/11/krita-450x267.png) + +### GIMP + +GNU Image Manipulation Program (GIMP) is a cross-platform image editor. Users of Photoshop will find the User Interface of GIMP to be similar to that of Photoshop. The drop down menu offers colors, layers, filters and tools to help the user with editing graphics. Rulers are located both horizontal and vertical and guide can be dragged across the screen to give exact measurements. The drop down menu gives tool options for resizing or cropping photos; adjustments can be made to the color balance, color levels, brightness and contrast as well as hue and saturation. + +![](https://www.suse.com/communities/blog/files/2017/11/gimp-450x281.png) + +There are multiple filters in GIMP to enhance or distort your images. Filters for artistic expression and animation are available and are more powerful tool options than those found in some proprietary applications. Gradients can be applied through additional layers and the Text Tool offers many fonts, which can be altered in shape and size through the Perspective Tool. + +The cloning tool works exactly like those in other graphics editors, so manipulating images is simple and acurrate given the selection of brush sizes to do the job. + +Perhaps one of the best options available with GIMP is that the images can be saved in a variety of formats like .jpg, .png, .pdf, .eps and .svg. These image options provide high-quality images in a small file. + +### InkScape + +Designing vector imagery with InkScape is simple and free. This cross platform allows for the creation of logos and illustrations that are highly scalable. Whether designing cartoons or creating images for branding, InkScape is a powerful application to get the job done. Like GIMP, InkScape lets you save files in various formats and allows for object manipulation like moving, rotating and skewing text and objects. Shape tools are available with InkScape so making stars, hexagons and other elements will meet the needs of your creative mind. + +![](https://www.suse.com/communities/blog/files/2017/11/inkscape-450x273.png) + +InkScape offers a comprehensive tool set, including a drawing tool, a pen tool and the freehand calligraphy tool that allows for object creation with your own personal style. The color selector gives you the choice of RGB, CMYK and RGBA – using specific colors for branding logos, icons and advertisement is definitely convincing. + +Short cut commands are similar to what users experience in Adobe Illustrator. Making layers and grouping or ungrouping the design elements can turn a blank page into a full-fledged image that can be used for designing technical diagrams for presentations, importing images into a multimedia program or for creating web graphics and software design. + +Inkscape can import vector graphics from multiple other programs. It can even import bitmap images. Inkscape is one of those cross platform, open-source programs that allow users to operate across different operating systems, no matter if they work with macOS, Windows or Linux. + +### Okular and LibreOffice + +LibreOffice, which is a free, open-source Office Suite, allows users to collaborate and interact with documents and important files on Linux, but also on macOS and Window. You can also create PDF files via LibreOffice, and LibreOffice Draw lets you view (and edit) PDF files as images. + +![](https://www.suse.com/communities/blog/files/2017/11/draw-450x273.png) + +However, the Portable Document Format (PDF) is quite different on the three Operating Systems. MacOS offers [Preview][12] by default; Windows has [Edge][13]. Of course, also Adobe Reader can be used for both MacOS and Window. With Linux, and especially the desktop selection of KDE, [Okular][14] is the default program for viewing PDF files. + +![](https://www.suse.com/communities/blog/files/2017/11/okular-450x273.png) + +The functionality of Okular supports different types of documents, like PDF, Postscript, [DjVu][15], [CHM][16], [XPS][17], [ePub][18] and others. Yet the universal document viewer also offers some powerful features that make interacting with a document different from other programs on MacOS and Windows. Okular gives selection and search tools that make accessing the text in PDFs fluid for how users interact with documents. Viewing documents with Okular is also accommodating with the magnification tool that allows for a quick look at small text in a document. + +Okular also provides users with the option to configure it to use more memory if the document is too large and freezes the Operating System. This functionality is convenient for users accessing high-quality print documents for example for advertising. + +For those who want to change locked images and documents, it’s rather easy to do so with LibreOffice Draw. A hypothetical situation would be to take a locked IRS (or tax) form and change it to make the uneditable document editable. Imagine how much fun it could be to transform it to some humorous kind of tax form … + +And indeed, the sky’s the limit on how creative a user wants to be when using programs that are available on Linux distributions. + +![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) + +![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) + +![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) + +![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) + +![2 votes, average: 5.00 out of 5](https://www.suse.com/communities/blog/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif) + +( + + _**2** votes, average: **5.00** out of 5_ + +) + + _You need to be a registered member to rate this post._ + +Tags: [drawing][19], [Getting Started with Linux][20], [GIMP][21], [image editing][22], [Images][23], [InkScape][24], [KDE][25], [Krita][26], [Leap 42.3][27], [LibreOffice][28], [Linux Magazine][29], [Okular][30], [openSUSE][31], [PDF][32] Categories: [Desktop][33], [Expert Views][34], [LibreOffice][35], [openSUSE][36] + +-------------------------------------------------------------------------------- + +via: https://www.suse.com/communities/blog/unleash-creativity-linux-programs-drawing-image-editing/ + +作者:[chabowski ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://www.suse.com/communities/blog/author/chabowski/ +[2]:http://www.linux-magazine.com/Resources/Special-Editions/30-Getting-Started-with-Linux +[3]:https://en.opensuse.org/Portal:42.3 +[4]:http://www.linux-magazine.com/ +[5]:https://www.gimp.org/ +[6]:https://inkscape.org/en/ +[7]:https://okular.kde.org/ +[8]:http://www.adobe.com/products/photoshop.html +[9]:http://www.adobe.com/products/illustrator.html +[10]:https://acrobat.adobe.com/us/en/acrobat/acrobat-pro-cc.html +[11]:https://krita.org/en/ +[12]:https://en.wikipedia.org/wiki/Preview_(macOS) +[13]:https://en.wikipedia.org/wiki/Microsoft_Edge +[14]:https://okular.kde.org/ +[15]:http://djvu.org/ +[16]:https://fileinfo.com/extension/chm +[17]:https://fileinfo.com/extension/xps +[18]:http://idpf.org/epub +[19]:https://www.suse.com/communities/blog/tag/drawing/ +[20]:https://www.suse.com/communities/blog/tag/getting-started-with-linux/ +[21]:https://www.suse.com/communities/blog/tag/gimp/ +[22]:https://www.suse.com/communities/blog/tag/image-editing/ +[23]:https://www.suse.com/communities/blog/tag/images/ +[24]:https://www.suse.com/communities/blog/tag/inkscape/ +[25]:https://www.suse.com/communities/blog/tag/kde/ +[26]:https://www.suse.com/communities/blog/tag/krita/ +[27]:https://www.suse.com/communities/blog/tag/leap-42-3/ +[28]:https://www.suse.com/communities/blog/tag/libreoffice/ +[29]:https://www.suse.com/communities/blog/tag/linux-magazine/ +[30]:https://www.suse.com/communities/blog/tag/okular/ +[31]:https://www.suse.com/communities/blog/tag/opensuse/ +[32]:https://www.suse.com/communities/blog/tag/pdf/ +[33]:https://www.suse.com/communities/blog/category/desktop/ +[34]:https://www.suse.com/communities/blog/category/expert-views/ +[35]:https://www.suse.com/communities/blog/category/libreoffice/ +[36]:https://www.suse.com/communities/blog/category/opensuse/ diff --git a/sources/tech/20171120 Adopting Kubernetes step by step.md b/sources/tech/20171120 Adopting Kubernetes step by step.md new file mode 100644 index 0000000000..05faf304c8 --- /dev/null +++ b/sources/tech/20171120 Adopting Kubernetes step by step.md @@ -0,0 +1,93 @@ +Adopting Kubernetes step by step +============================================================ + +Why Docker and Kubernetes? + +Containers allow us to build, ship and run distributed applications. They remove the machine constraints from applications and lets us create a complex application in a deterministic fashion. + +Composing applications with containers allows us to make development, QA and production environments closer to each other (if you put the effort in to get there). By doing so, changes can be shipped faster and testing a full system can happen sooner. + +[Docker][1] — the containerization platform — provides this, making software  _independent_  of cloud providers. + +However, even with containers the amount of work needed for shipping your application through any cloud provider (or in a private cloud) is significant. An application usually needs auto scaling groups, persistent remote discs, auto discovery, etc. But each cloud provider has different mechanisms for doing this. If you want to support these features, you very quickly become cloud provider dependent. + +This is where [Kubernetes][2] comes in to play. It is an orchestration system for containers that allows you to manage, scale and deploy different pieces of your application — in a standardised way — with great tooling as part of it. It’s a portable abstraction that’s compatible with the main cloud providers (Google Cloud, Amazon Web Services and Microsoft Azure all have support for Kubernetes). + +A way to visualise your application, containers and Kubernetes is to think about your application as a shark — stay with me — that exists in the ocean (in this example, the ocean is your machine). The ocean may have other precious things you don’t want your shark to interact with, like [clown fish][3]. So you move you shark (your application) into a sealed aquarium (Container). This is great but not very robust. Your aquarium can break or maybe you want to build a tunnel to another aquarium where other fish live. Or maybe you want many copies of that aquarium in case one needs cleaning or maintenance… this is where Kubernetes clusters come to play. + + +![](https://cdn-images-1.medium.com/max/1600/1*OVt8cnY1WWOqdLFycCgdFg.jpeg) +Evolution to Kubernetes + +With Kubernetes being supported by the main cloud providers, it makes it easier for you and your team to have environments from  _development _ to  _production _ that are almost identical to each other. This is because Kubernetes has no reliance on proprietary software, services or infrastructure. + +The fact that you can start your application in your machine with the same pieces as in production closes the gaps between a development and a production environment. This makes developers more aware of how an application is structured together even though they might only be responsible for one piece of it. It also makes it easier for your application to be fully tested earlier in the pipeline. + +How do you work with Kubernetes? + +With more people adopting Kubernetes new questions arise; how should I develop against a cluster based environment? Suppose you have 3 environments — development, QA and production — how do I fit Kubernetes in them? Differences across these environments will still exist, either in terms of development cycle (e.g. time spent to see my code changes in the application I’m running) or in terms of data (e.g. I probably shouldn’t test with production data in my QA environment as it has sensitive information). + +So, should I always try to work inside a Kubernetes cluster, building images, recreating deployments and services while I code? Or maybe I should not try too hard to make my development environment be a Kubernetes cluster (or set of clusters) in development? Or maybe I should work in a hybrid way? + + +![](https://cdn-images-1.medium.com/max/1600/1*MXokxD8Ktte4_vWvTas9uw.jpeg) +Development with a local cluster + +If we carry on with our metaphor, the holes on the side represent a way to make changes to our app while keeping it in a development cluster. This is usually achieved via [volumes][4]. + +A Kubernetes series + +The Kubernetes series repository is open source and available here: + +### [https://github.com/red-gate/ks][5] + +We’ve written this series as we experiment with different ways to build software. We’ve tried to constrain ourselves to use Kubernetes in all environments so that we can explore the impact these technologies will have on the development and management of data and the database. + +The series starts with the basic creation of a React application hooked up to Kubernetes, and evolves to encompass more of our development requirements. By the end we’ll have covered all of our application development needs  _and_  have understood how best to cater for the database lifecycle in this world of containers and clusters. + +Here are the first 5 episodes of this series: + +1. ks1: build a React app with Kubernetes + +2. ks2: make minikube detect React code changes + +3. ks3: add a python web server that hosts an API + +4. ks4: make minikube detect Python code changes + +5. ks5: create a test environment + +The second part of the series will add a database and try to work out the best way to evolve our application alongside it. + +By running Kubernetes in all environments, we’ve been forced to solve new problems as we try to keep the development cycle as fast as possible. The trade-off being that we are constantly exposed to Kubernetes and become more accustomed to it. By doing so, development teams become responsible for production environments, which is no longer difficult as all environments (development through production) are all managed in the same way. + +What’s next? + +We will continue this series by incorporating a database and experimenting to find the best way to have a seamless database lifecycle experience with Kubernetes. + + _This Kubernetes series is brought to you by Foundry, Redgate’s R&D division. We’re working on making it easier to manage data alongside containerised environments, so if you’re working with data and containerised environments, we’d like to hear from you — reach out directly to the development team at _ [_foundry@red-gate.com_][6] + +* * * + + _We’re hiring_ _. Are you interested in uncovering product opportunities, building _ [_future technology_][7] _ and taking a startup-like approach (without the risk)? Take a look at our _ [_Software Engineer — Future Technologies_][8] _ role and read more about what it’s like to work at Redgate in _ [_Cambridge, UK_][9] _._ + +-------------------------------------------------------------------------------- + +via: https://medium.com/ingeniouslysimple/adopting-kubernetes-step-by-step-f93093c13dfe + +作者:[santiago arias][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://medium.com/@santiaago?source=post_header_lockup +[1]:https://www.docker.com/what-docker +[2]:https://kubernetes.io/ +[3]:https://www.google.co.uk/search?biw=723&bih=753&tbm=isch&sa=1&ei=p-YCWpbtN8atkwWc8ZyQAQ&q=nemo+fish&oq=nemo+fish&gs_l=psy-ab.3..0i67k1l2j0l2j0i67k1j0l5.5128.9271.0.9566.9.9.0.0.0.0.81.532.9.9.0....0...1.1.64.psy-ab..0.9.526...0i7i30k1j0i7i10i30k1j0i13k1j0i10k1.0.FbAf9xXxTEM +[4]:https://kubernetes.io/docs/concepts/storage/volumes/ +[5]:https://github.com/red-gate/ks +[6]:mailto:foundry@red-gate.com +[7]:https://www.red-gate.com/foundry/ +[8]:https://www.red-gate.com/our-company/careers/current-opportunities/software-engineer-future-technologies +[9]:https://www.red-gate.com/our-company/careers/living-in-cambridge diff --git a/sources/tech/20171120 Containers and Kubernetes Whats next.md b/sources/tech/20171120 Containers and Kubernetes Whats next.md deleted file mode 100644 index b73ccb21c2..0000000000 --- a/sources/tech/20171120 Containers and Kubernetes Whats next.md +++ /dev/null @@ -1,98 +0,0 @@ -YunfengHe Translating -Containers and Kubernetes: What's next? -============================================================ - -### What's ahead for container orchestration and Kubernetes? Here's an expert peek - -![CIO_Big Data Decisions_2](https://enterprisersproject.com/sites/default/files/styles/620x350/public/images/CIO_Big%20Data%20Decisions_2.png?itok=Y5zMHxf8 "CIO_Big Data Decisions_2") - -If you want a basic idea of where containers are headed in the near future, follow the money. There’s a lot of it: 451 Research projects that the overall market for containers will hit roughly [$2.7 billion in 2020][4], a 3.5-fold increase from the $762 million spent on container-related technology in 2016. - -There’s an obvious fundamental factor behind such big numbers: Rapidly increasing containerization. The parallel trend: As container adoption grows, so will container  _orchestration_  adoption. - -As recent survey data from  [_The New Stack_][5]  indicates, container adoption is the most significant catalyst of orchestration adoption: 60 percent of respondents who’ve deployed containers broadly in production report they’re also using Kubernetes widely in production. Another 19 percent of respondents with broad container deployments in production were in the initial stages of broad Kubernetes adoption. Meanwhile, just 5 percent of those in the initial phases of deploying containers in production environments were using Kubernetes broadly – but 58 percent said they were preparing to do so. It’s a chicken-and-egg relationship. - - -Most experts agree that an orchestration tool is essential to the scalable [long-term management of containers][6] – and corresponding developments in the marketplace. “The next trends in container orchestration are all focused on broadening adoption,” says Alex Robinson, software engineer at [Cockroach Labs][7]. - -This is a quickly shifting landscape, one that is just starting to realize its future potential. So we checked in with Robinson and other practitioners to get their boots-on-the-ground perspective on what’s next in container orchestration – and for Kubernetes itself. - -### **Container orchestration shifts to mainstream** - -We’re at the precipice common to most major technology shifts, where we transition from the careful steps of early adoption to cliff-diving into commonplace use. That will create new demand for the plain-vanilla requirements that make mainstream adoption easier, especially in large enterprises. - -“The gold rush phase of early innovation has slowed down and given way to a much stronger focus on stability and usability,” Robinson says. “This means we'll see fewer major announcements of new orchestration systems, and more security options, management tools, and features that make it easier to take advantage of the flexibility already inherent in the major orchestration systems.” - -### **Reduced complexity** - -On a related front, expect an intensifying effort to cut back on the complexity that some organizations face when taking their first plunge into container orchestration. As we’ve covered before, deploying a container might be “easy,” but [managing containers long-term ][8]requires more care. - -“Today, container orchestration is too complex for many users to take full advantage,” says My Karlsson, developer at [Codemill AB][9]. “New users are often struggling just to get single or small-size container configurations running in isolation, especially when applications are not originally designed for it. There are plenty of opportunities to simplify the orchestration of non-trivial applications and make the technology more accessible.” - -### **Increasing focus on hybrid cloud and multi-cloud** - -As adoption of containers and container orchestration grows, more organizations will scale from a starting point of, say, running non-critical workloads in a single environment to more [complex use cases][10] across multiple environments. For many companies, that will mean managing containerized applications (and particularly containerized microservices) across [hybrid cloud][11] and [multi-cloud][12] environments, often globally. - -"Containers and Kubernetes have made hybrid cloud and application portability a reality,” says [Brian Gracely][13], director of [Red Hat][14] OpenShift product strategy. “Combined with the Open Service Broker, we expect to see an explosion of new applications that combine private and public cloud resources." - -“I believe that federation will get a push, enabling much-wanted features such as seamless multi-region and multi-cloud deployments,” says Carlos Sanchez, senior software engineer at [CloudBees][15].  - -**[ Want CIO wisdom on hybrid cloud and multi-cloud strategy? See our related resource, **[**Hybrid Cloud: The IT leader's guide**][16]**. ]** - -### **Continued consolidation of platforms and tools** - -Technology consolidation is common trend; container orchestration is no exception. - -“As containerization goes mainstream, engineers are consolidating on a very small number of technologies to run their [microservices and] containers and Kubernetes will become the dominant container orchestration platform, far outstripping other platforms,” says Ben Newton, analytics lead at [Sumo Logic][17]. “Companies will adopt Kubernetes to drive a cloud-neutral approach as Kubernetes provides a reasonably clear path to reduce dependence on [specific] cloud ecosystems.**”** - -### **Speaking of Kubernetes, what’s next?** - -"Kubernetes is here for the long haul, and the community driving it is doing great job – but there's lots ahead,” says Gadi Naor, CTO and co-founder of [Alcide][18]. Our experts shared several predictions specific to [the increasingly popular Kubernetes platform][19]:  - - **_Gadi Naor at Alcide:_**  “Operators will continue to evolve and mature, to a point where applications running on Kubernetes will become fully self-managed. Deploying and monitoring microservices on top of Kubernetes with [OpenTracing][20] and service mesh frameworks such as [istio][21] will help shape new possibilities.” - - **_Brian Gracely at Red Hat:_**  “Kubernetes continues to expand in terms of the types of applications it can support. When you can run traditional applications, cloud-native applications, big data applications, and HPC or GPU-centric applications on the same platform, it unlocks a ton of architectural flexibility.” - - **_Ben Newton at Sumo Logic: _ “**As Kubernetes becomes more dominant, I would expect to see more normalization of the operational mechanisms – particularly integrations into third-party management and monitoring platforms.” - - **_Carlos Sanchez at CloudBees: _** “In the immediate future there is the ability to run without Docker, using other runtimes...to remove any lock-in. [Editor’s note: [CRI-O][22], for example, offers this ability.] “Also, [look for] storage improvements to support enterprise features like data snapshotting and online volume resizing.” - - - **_Alex Robinson at Cockroach Labs: _ “**One of the bigger developments happening in the Kubernetes community right now is the increased focus on managing [stateful applications][23]. Managing state in Kubernetes right now is very difficult if you aren't running in a cloud that offers remote persistent disks, but there's work being done on multiple fronts [both inside Kubernetes and by external vendors] to improve this.” - --------------------------------------------------------------------------------- - -via: https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next - -作者:[Kevin Casey ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://enterprisersproject.com/user/kevin-casey -[1]:https://enterprisersproject.com/article/2017/11/kubernetes-numbers-10-compelling-stats -[2]:https://enterprisersproject.com/article/2017/11/how-enterprise-it-uses-kubernetes-tame-container-complexity -[3]:https://enterprisersproject.com/article/2017/11/5-kubernetes-success-tips-start-smart?sc_cid=70160000000h0aXAAQ -[4]:https://451research.com/images/Marketing/press_releases/Application-container-market-will-reach-2-7bn-in-2020_final_graphic.pdf -[5]:https://thenewstack.io/ -[6]:https://enterprisersproject.com/article/2017/10/microservices-and-containers-6-management-tips-long-haul -[7]:https://www.cockroachlabs.com/ -[8]:https://enterprisersproject.com/article/2017/10/microservices-and-containers-6-management-tips-long-haul -[9]:https://codemill.se/ -[10]:https://www.redhat.com/en/challenges/integration?intcmp=701f2000000tjyaAAA -[11]:https://enterprisersproject.com/hybrid-cloud -[12]:https://enterprisersproject.com/article/2017/7/multi-cloud-vs-hybrid-cloud-whats-difference -[13]:https://enterprisersproject.com/user/brian-gracely -[14]:https://www.redhat.com/en -[15]:https://www.cloudbees.com/ -[16]:https://enterprisersproject.com/hybrid-cloud?sc_cid=70160000000h0aXAAQ -[17]:https://www.sumologic.com/ -[18]:http://alcide.io/ -[19]:https://enterprisersproject.com/article/2017/10/how-explain-kubernetes-plain-english -[20]:http://opentracing.io/ -[21]:https://istio.io/ -[22]:http://cri-o.io/ -[23]:https://opensource.com/article/17/2/stateful-applications -[24]:https://enterprisersproject.com/article/2017/11/containers-and-kubernetes-whats-next?rate=PBQHhF4zPRHcq2KybE1bQgMkS2bzmNzcW2RXSVItmw8 -[25]:https://enterprisersproject.com/user/kevin-casey diff --git a/sources/tech/20171123 Why microservices are a security issue.md b/sources/tech/20171123 Why microservices are a security issue.md new file mode 100644 index 0000000000..d5868faa9e --- /dev/null +++ b/sources/tech/20171123 Why microservices are a security issue.md @@ -0,0 +1,116 @@ +Why microservices are a security issue +============================================================ + +### Maybe you don't want to decompose all your legacy applications into microservices, but you might consider starting with your security functions. + +![Why microservices are a security issue](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003601_05_mech_osyearbook2016_security_cc.png?itok=3V07Lpko "Why microservices are a security issue") +Image by : Opensource.com + +I struggled with writing the title for this post, and I worry that it comes across as clickbait. If you've come to read this because it looked like clickbait, then sorry.[1][5]I hope you'll stay anyway: there are lots of fascinating[2][6] points and many[3][7]footnotes. What I  _didn't_  mean to suggest is that microservices cause [security][15]problems—though like any component, of course, they can—but that microservices are appropriate objects of interest to those involved with security. I'd go further than that: I think they are an excellent architectural construct for those concerned with security. + +And why is that? Well, for those of us with a [systems security][16] bent, the world is an interesting place at the moment. We're seeing a growth in distributed systems, as bandwidth is cheap and latency low. Add to this the ease of deploying to the cloud, and more architects are beginning to realise that they can break up applications, not just into multiple layers, but also into multiple components within the layer. Load balancers, of course, help with this when the various components in a layer are performing the same job, but the ability to expose different services as small components has led to a growth in the design, implementation, and deployment of  _microservices_ . + +More on Microservices + +* [How to explain microservices to your CEO][1] + +* [Free eBook: Microservices vs. service-oriented architecture][2] + +* [Secured DevOps for microservices][3] + +So, [what exactly is a microservice][23]? I quite like [Wikipedia's definition][24], though it's interesting that security isn't mentioned there.[4][17] One of the points that I like about microservices is that, when well-designed, they conform to the first two points of Peter H. Salus' description of the [Unix philosophy][25]: + +1. Write programs that do one thing and do it well. + +2. Write programs to work together. + +3. Write programs to handle text streams, because that is a universal interface. + +The last of the three is slightly less relevant, because the Unix philosophy is generally used to refer to standalone applications, which often have a command instantiation. It does, however, encapsulate one of the basic requirements of microservices: that they must have well-defined interfaces. + +By "well-defined," I don't just mean a description of any externally accessible APIs' methods, but also of the normal operation of the microservice: inputs and outputs—and, if there are any, side-effects. As I described in a previous post, "[5 traits of good systems architecture][18]," data and entity descriptions are crucial if you're going to be able to design a system. Here, in our description of microservices, we get to see why these are so important, because, for me, the key defining feature of a microservices architecture is decomposability. And if you're going to decompose[5][8] your architecture, you need to be very, very clear which "bits" (components) are going to do what. + +And here's where security starts to come in. A clear description of what a particular component should be doing allows you to: + +* Check your design + +* Ensure that your implementation meets the description + +* Come up with reusable unit tests to check functionality + +* Track mistakes in implementation and correct them + +* Test for unexpected outcomes + +* Monitor for misbehaviour + +* Audit actual behaviour for future scrutiny + +Now, are all these things possible in a larger architecture? Yes, they are. But they become increasingly difficult where entities are chained together or combined in more complex configurations. Ensuring  _correct_  implementation and behaviour is much, much easier when you've got smaller pieces to work together. And deriving complex systems behaviours—and misbehaviours—is much more difficult if you can't be sure that the individual components are doing what they ought to be. + +It doesn't stop here, however. As I've mentioned on many [previous occasions][19], writing good security code is difficult.[7][9] Proving that it does what it should do is even more difficult. There is every reason, therefore, to restrict code that has particular security requirements—password checking, encryption, cryptographic key management, authorisation, etc.—to small, well-defined blocks. You can then do all the things that I've mentioned above to try to make sure it's done correctly. + +And yet there's more. We all know that not everybody is great at writing security-related code. By decomposing your architecture such that all security-sensitive code is restricted to well-defined components, you get the chance to put your best security people on that and restrict the danger that J. Random Coder[8][10] will put something in that bypasses or downgrades a key security control. + +It can also act as an opportunity for learning: It's always good to be able to point to a design/implementation/test/monitoring tuple and say: "That's how it should be done. Hear, read, mark, learn, and inwardly digest.[9][11]" + +Should you go about decomposing all of your legacy applications into microservices? Probably not. But given all the benefits you can accrue, you might consider starting with your security functions. + +* * * + +1Well, a little bit—it's always nice to have readers. + +2I know they are: I wrote them. + +3Probably less fascinating. + +4At the time this article was written. It's entirely possible that I—or one of you—may edit the article to change that. + +5This sounds like a gardening term, which is interesting. Not that I really like gardening, but still.[6][12] + +6Amusingly, I first wrote, "…if you're going to decompose your architect…," which sounds like the strapline for an IT-themed murder film. + +7Regular readers may remember a reference to the excellent film  _The Thick of It_ . + +8Other generic personae exist; please take your pick. + +9Not a cryptographic digest: I don't think that's what the original writers had in mind. + + _This article originally appeared on [Alice, Eve, and Bob—a security blog][13] and is republished with permission._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/microservices-are-security-issue + +作者:[Mike Bursell ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/mikecamel +[1]:https://blog.openshift.com/microservices-how-to-explain-them-to-your-ceo/?intcmp=7016000000127cYAAQ&src=microservices_resource_menu1 +[2]:https://www.openshift.com/promotions/microservices.html?intcmp=7016000000127cYAAQ&src=microservices_resource_menu2 +[3]:https://opensource.com/business/16/11/secured-devops-microservices?src=microservices_resource_menu3 +[4]:https://opensource.com/article/17/11/microservices-are-security-issue?rate=GDH4xOWsgYsVnWbjEIoAcT_92b8gum8XmgR6U0T04oM +[5]:https://opensource.com/article/17/11/microservices-are-security-issue#1 +[6]:https://opensource.com/article/17/11/microservices-are-security-issue#2 +[7]:https://opensource.com/article/17/11/microservices-are-security-issue#3 +[8]:https://opensource.com/article/17/11/microservices-are-security-issue#5 +[9]:https://opensource.com/article/17/11/microservices-are-security-issue#7 +[10]:https://opensource.com/article/17/11/microservices-are-security-issue#8 +[11]:https://opensource.com/article/17/11/microservices-are-security-issue#9 +[12]:https://opensource.com/article/17/11/microservices-are-security-issue#6 +[13]:https://aliceevebob.com/2017/10/31/why-microservices-are-a-security-issue/ +[14]:https://opensource.com/user/105961/feed +[15]:https://opensource.com/tags/security +[16]:https://aliceevebob.com/2017/03/14/systems-security-why-it-matters/ +[17]:https://opensource.com/article/17/11/microservices-are-security-issue#4 +[18]:https://opensource.com/article/17/10/systems-architect +[19]:https://opensource.com/users/mikecamel +[20]:https://opensource.com/users/mikecamel +[21]:https://opensource.com/users/mikecamel +[22]:https://opensource.com/article/17/11/microservices-are-security-issue#comments +[23]:https://opensource.com/resources/what-are-microservices +[24]:https://en.wikipedia.org/wiki/Microservices +[25]:https://en.wikipedia.org/wiki/Unix_philosophy diff --git a/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md b/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md deleted file mode 100644 index 27379cbe40..0000000000 --- a/sources/tech/20171124 Open Source Cloud Skills and Certification Are Key for SysAdmins.md +++ /dev/null @@ -1,70 +0,0 @@ -translating by wangy325... - - -Open Source Cloud Skills and Certification Are Key for SysAdmins -============================================================ - - -![os jobs](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/open-house-sysadmin.jpg?itok=i5FHc3lu "os jobs") -Sysadmins with open source skills and certification can command higher pay, according to the 2017 Open Source Jobs Report.[Creative Commons Zero][1] - -System administrator is one of the most common positions employers are looking to fill among 53 percent of respondents to the [2017 Open Source Jobs Report][3]. Consequently, sysadmins with skills in engineering can command higher salaries, as these positions are among the hardest to fill, the report finds. - -Sysadmins are generally responsible for installing, supporting, and maintaining servers or other computer systems, and planning for and responding to service outages and other problems. - -Overall, this year’s report finds the skills most in demand are open source cloud (47 percent), application development (44 percent), Big Data (43 percent) and both DevOps and security (42 percent). - -The report also finds that 58 percent of hiring managers are planning to hire more open source professionals, and 67 percent say hiring of open source professionals will increase more than in other areas of the business. This represents a two-point increase over last year among employers who said open source hiring would be their top field of recruitment. - -At the same time, 89 percent of hiring managers report it is difficult to find open source talent. - -### Why get certified - -The desire for sysadmins is incentivizing hiring managers to offer formal training and/or certifications in the discipline in 53 percent of organizations, compared to 47 percent last year, the Open Source Jobs Report finds. - -IT professionals interested in sysadmin positions should consider Linux certifications. Searches on several of the more well-known job posting sites reveal that the [CompTIA Linux+][4]certification is the top certification for entry-level Linux sysadmin, while [Red Hat Certified Engineer (RHCE)][5] and [Red Hat Certified System Administrator (RHCSA)][6] are the main certifications for higher-level positions. - -In 2016, a sysadmin commanded a salary of $79,583, a change of -0.8 percent from the previous year, according to Dice’s [2017 Tech Salary Survey][7]. The systems architect position paid $125,946, a year-over-year change of -4.7 percent. Yet, the survey observes that “Highly skilled technology professionals remain in the most demand, especially those candidates proficient in the technologies needed to support industry transformation and growth.” - -When it comes to open source skills, HBase (an open-source distributed database), ranked as one that garners among the highest pay for tech pros in the Dice survey. In the networking and database category, the OpenVMS operating system ranked as another high-paying skill. - -### The sysadmin role - -One of a sysadmin’s responsibilities is to be available 24/7 when a problem occurs. The position calls for a mindset that is about “zero-blame, lean, iterative improvement in process or technology,’’ and one that is open to change, writes Paul English, a board member for the League of Professional System Administrators, a non-profit professional association for the advancement of the practice of system administration, in  [opensource.com][8]. He adds that being a sysadmin means “it’s almost a foregone conclusion that you’ll work with open source software like Linux, BSD, and even open source Solaris.” - -Today’s sysadmins will more often work with software rather than hardware, and should be prepared to write small scripts, according to English. - -### Outlook for 2018 - -Expect to see sysadmins among the tech professionals many employers in North America will be hiring in 2018, according to [Robert Half’s 2018 Salary Guide for Technology Professionals][9]. Increasingly, soft skills and leadership qualities are also highly valued. - -“Good listening and critical-thinking skills, which are essential to understanding and resolving customers’ issues and concerns, are important for almost any IT role today, but especially for help desk and desktop support professionals,’’ the report states. - -This jibes with some of the essential skills needed at various stages of the sysadmin position, including strong analytical skills and an ability to solve problems quickly, according to [The Linux Foundation][10]. - -Other skills sysadmins should have as they move up the ladder are: interest in structured approaches to system configuration management; experience in resolving security issues; experience with user identity management; ability to communicate in non-technical terms to non-technical people; and ability to modify system to meet new security requirements. - - _[Download ][11]the full 2017 Open Source Jobs Report now._ - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/open-source-cloud-skills-and-certification-are-key-sysadmins - -作者:[ ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: -[1]:https://www.linux.com/licenses/category/creative-commons-zero -[2]:https://www.linux.com/files/images/open-house-sysadminjpg -[3]:https://www.linuxfoundation.org/blog/2017-jobs-report-highlights-demand-open-source-skills/ -[4]:https://certification.comptia.org/certifications/linux?tracking=getCertified/certifications/linux.aspx -[5]:https://www.redhat.com/en/services/certification/rhce -[6]:https://www.redhat.com/en/services/certification/rhcsa -[7]:http://marketing.dice.com/pdf/Dice_TechSalarySurvey_2017.pdf?aliId=105832232 -[8]:https://opensource.com/article/17/7/truth-about-sysadmins -[9]:https://www.roberthalf.com/salary-guide/technology -[10]:https://www.linux.com/learn/10-essential-skills-novice-junior-and-senior-sysadmins%20%20 -[11]:http://bit.ly/2017OSSjobsreport diff --git a/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md index 147a2266cc..d282ef5445 100644 --- a/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md +++ b/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md @@ -1,9 +1,6 @@ -KeyLD Translating - Photon Could Be Your New Favorite Container OS ============================================================ - ![Photon OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon-linux.jpg?itok=jUFHPR_c "Photon OS") Jack Wallen says Photon OS is an outstanding platform, geared specifically for containers.[Creative Commons Zero][5]Pixabay @@ -109,9 +106,9 @@ Give Photon a try and see if it doesn’t make deploying Docker containers and/o -------------------------------------------------------------------------------- -via: https://www.linux.com/learn/intro-to-linux/2017/11/photon-could-be-your-new-favorite-container-os +via: 网址 -作者:[JACK WALLEN ][a] +作者:[ JACK WALLEN][a] 译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) diff --git a/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md b/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md new file mode 100644 index 0000000000..c09d66bc57 --- /dev/null +++ b/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md @@ -0,0 +1,76 @@ +AWS to Help Build ONNX Open Source AI Platform +============================================================ +![onnx-open-source-ai-platform](https://www.linuxinsider.com/article_images/story_graphics_xlarge/xl-2017-onnx-1.jpg) + + +Amazon Web Services has become the latest tech firm to join the deep learning community's collaboration on the Open Neural Network Exchange, recently launched to advance artificial intelligence in a frictionless and interoperable environment. Facebook and Microsoft led the effort. + +As part of that collaboration, AWS made its open source Python package, ONNX-MxNet, available as a deep learning framework that offers application programming interfaces across multiple languages including Python, Scala and open source statistics software R. + +The ONNX format will help developers build and train models for other frameworks, including PyTorch, Microsoft Cognitive Toolkit or Caffe2, AWS Deep Learning Engineering Manager Hagay Lupesko and Software Developer Roshani Nagmote wrote in an online post last week. It will let developers import those models into MXNet, and run them for inference. + +### Help for Developers + +Facebook and Microsoft this summer launched ONNX to support a shared model of interoperability for the advancement of AI. Microsoft committed its Cognitive Toolkit, Caffe2 and PyTorch to support ONNX. + +Cognitive Toolkit and other frameworks make it easier for developers to construct and run computational graphs that represent neural networks, Microsoft said. + +Initial versions of [ONNX code and documentation][4] were made available on Github. + +AWS and Microsoft last month announced plans for Gluon, a new interface in Apache MXNet that allows developers to build and train deep learning models. + +Gluon "is an extension of their partnership where they are trying to compete with Google's Tensorflow," observed Aditya Kaul, research director at [Tractica][5]. + +"Google's omission from this is quite telling but also speaks to their dominance in the market," he told LinuxInsider. + +"Even Tensorflow is open source, and so open source is not the big catch here -- but the rest of the ecosystem teaming up to compete with Google is what this boils down to," Kaul said. + +The Apache MXNet community earlier this month introduced version 0.12 of MXNet, which extends Gluon functionality to allow for new, cutting-edge research, according to AWS. Among its new features are variational dropout, which allows developers to apply the dropout technique for mitigating overfitting to recurrent neural networks. + +Convolutional RNN, Long Short-Term Memory and gated recurrent unit cells allow datasets to be modeled using time-based sequence and spatial dimensions, AWS noted. + +### Framework-Neutral Method + +"This looks like a great way to deliver inference regardless of which framework generated a model," said Paul Teich, principal analyst at [Tirias Research][6]. + +"This is basically a framework-neutral way to deliver inference," he told LinuxInsider. + +Cloud providers like AWS, Microsoft and others are under pressure from customers to be able to train on one network while delivering on another, in order to advance AI, Teich pointed out. + +"I see this as kind of a baseline way for these vendors to check the interoperability box," he remarked. + +"Framework interoperability is a good thing, and this will only help developers in making sure that models that they build on MXNet or Caffe or CNTK are interoperable," Tractica's Kaul pointed out. + +As to how this interoperability might apply in the real world, Teich noted that technologies such as natural language translation or speech recognition would require that Alexa's voice recognition technology be packaged and delivered to another developer's embedded environment. + +### Thanks, Open Source + +"Despite their competitive differences, these companies all recognize they owe a significant amount of their success to the software development advancements generated by the open source movement," said Jeff Kaplan, managing director of [ThinkStrategies][7]. + +"The Open Neural Network Exchange is committed to producing similar benefits and innovations in AI," he told LinuxInsider. + +A growing number of major technology companies have announced plans to use open source to speed the development of AI collaboration, in order to create more uniform platforms for development and research. + +AT&T just a few weeks ago announced plans [to launch the Acumos Project][8] with TechMahindra and The Linux Foundation. The platform is designed to open up efforts for collaboration in telecommunications, media and technology.  +![](https://www.ectnews.com/images/end-enn.gif) + +-------------------------------------------------------------------------------- + +via: https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html + +作者:[ David Jones ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html#searchbyline +[1]:https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html# +[2]:https://www.linuxinsider.com/perl/mailit/?id=84971 +[3]:https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html +[4]:https://github.com/onnx/onnx +[5]:https://www.tractica.com/ +[6]:http://www.tiriasresearch.com/ +[7]:http://www.thinkstrategies.com/ +[8]:https://www.linuxinsider.com/story/84926.html +[9]:https://www.linuxinsider.com/story/AWS-to-Help-Build-ONNX-Open-Source-AI-Platform-84971.html diff --git a/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md b/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md new file mode 100644 index 0000000000..dd61ad7a95 --- /dev/null +++ b/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md @@ -0,0 +1,156 @@ +translating by lujun9972 +How To Tell If Your Linux Server Has Been Compromised +-------------- + +A server being compromised or hacked for the purpose of this guide is an unauthorized person or bot logging into the server in order to use it for their own, usually negative ends. + +Disclaimer: If your server has been compromised by a state organization like the NSA or a serious criminal group then you will not notice any problems and the following techniques will not register their presence. + +However, the majority of compromised servers are carried out by bots i.e. automated attack programs, in-experienced attackers e.g. “script kiddies”, or dumb criminals. + +These sorts of attackers will abuse the server for all it’s worth whilst they have access to it and take few precautions to hide what they are doing. + +### Symptoms of a compromised server + +When a server has been compromised by an in-experienced or automated attacker they will usually do something with it that consumes 100% of a resource. This resource will usually be either the CPU for something like crypt-currency mining or email spamming, or bandwidth for launching a DOS attack. + +This means that the first indication that something is amiss is that the server is “going slow”. This could manifest in the website serving pages much slower than usual, or email taking many minutes to deliver or send. + +So what should you look for? + +### Check 1 - Who’s currently logged in? + +The first thing you should look for is who is currently logged into the server. It is not uncommon to find the attacker actually logged into the server and working on it. + +The shell command to do this is w. Running w gives the following output: + +``` + 08:32:55 up 98 days, 5:43, 2 users, load average: 0.05, 0.03, 0.00 +USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT +root pts/0 113.174.161.1 08:26 0.00s 0.03s 0.02s ssh root@coopeaa12 +root pts/1 78.31.109.1 08:26 0.00s 0.01s 0.00s w + +``` + +One of those IP’s is a UK IP and the second is Vietnamese. That’s probably not a good thing. + +Stop and take a breath, don’t panic and simply kill their SSH connection. Unless you can stop then re-entering the server they will do so quickly and quite likely kick you off and stop you getting back in. + +Please see the What should I do if I’ve been compromised section at the end of this guide no how to proceed if you do find evidence of compromise. + +The whois command can be run on IP addresses and will tell you what all the information about the organization that the IP is registered to, including the country. + +### Check 2 - Who has logged in? + +Linux servers keep a record of which users logged in, from what IP, when and for how long. This information is accessed with the last command. + +The output looks like this: + +``` +root pts/1 78.31.109.1 Thu Nov 30 08:26 still logged in +root pts/0 113.174.161.1 Thu Nov 30 08:26 still logged in +root pts/1 78.31.109.1 Thu Nov 30 08:24 - 08:26 (00:01) +root pts/0 113.174.161.1 Wed Nov 29 12:34 - 12:52 (00:18) +root pts/0 14.176.196.1 Mon Nov 27 13:32 - 13:53 (00:21) + +``` + +There is a mix of my UK IP’s and some Vietnamese ones, with the top two still logged in. If you see any IP’s that are not authorized then refer to the final section. + +The login history is contained in a text file at ~/.bash_history and is therefore easily removable. Often, attackers will simply delete this file to try to cover their tracks. Consequently, if you run last and only see your current login, this is a Bad Sign. + +If there is no login history be very, very suspicious and continue looking for indications of compromise. + +### Check 3 - Review the command history + +This level of attacker will frequently take no precautions to leave no command history so running the history command will show you everything they have done. Be on the lookout for wget or curl commands to download out-of-repo software such as spam bots or crypto miners. + +The command history is contained in the ~/.bash_history file so some attackers will delete this file to cover what they have done. Just as with the login history, if you run history and don’t see anything then the history file has been deleted. Again this is a Bad Sign and you should review the server very carefully. + +### Check 4 - What’s using all the CPU? + +The sorts of attackers that you will encounter usually don’t take too many precautions to hide what they are doing. So they will run processes that consume all the CPU. This generally makes it pretty easy to spot them. Simply run top and look at the highest process. + +This will also show people exploiting your server without having logged in. This could be, for example, someone using an unprotected form-mail script to relay spam. + +If you don’t recognize the top process then either Google its name or investigate what it’s doing with losf or strace. + +To use these tools first copy its PID from top and run: + +``` +strace -p PID + +``` + +This will display all the system calls the process is making. It’s a lot of information but looking through it will give you a good idea what’s going on. + +``` +lsof -p PID + +``` + +This program will list the open files that the process has. Again, this will give you a good idea what it’s doing by showing you what files it is accessing. + +### Check 5 - Review the all the system processes + +If an unauthorized process is not consuming enough CPU to get listed noticeably on top it will still get displayed in a full process listing with ps. My proffered command is ps auxf for providing the most information clearly. + +You should be looking for any processes that you don’t recognize. The more times you run ps on your servers (which is a good habit to get into) the more obvious an alien process will stand out. + +### Check 6 - Review network usage by process + +The command iftop functions like top to show a ranked list of processes that are sending and receiving network data along with their source and destination. A process like a DOS attack or spam bot will immediately show itself at the top of the list. + +### Check 7 - What processes are listening for network connections? + +Often an attacker will install a program that doesn’t do anything except listen on the network port for instructions. This does not consume CPU or bandwidth whilst it is waiting so can get overlooked in the top type commands. + +The commands lsof and netstat will both list all networked processes. I use them with the following options: + +``` +lsof -i + +``` + +``` +netstat -plunt + +``` + +You should look for any process that is listed as in the LISTEN or ESTABLISHED status as these processes are either waiting for a connection (LISTEN) or have a connection open (ESTABLISHED). If you don’t recognize these processes use strace or lsof to try to see what they are doing. + +### What should I do if I’ve been compromised? + +The first thing to do is not to panic, especially if the attacker is currently logged in. You need to be able to take back control of the machine before the attacker is aware that you know about them. If they realize you know about them they may well lock you out of your server and start destroying any assets out of spite. + +If you are not very technical then simply shut down the server. Either from the server itself with shutdown -h now or systemctl poweroff. Or log into your hosting provider’s control panel and shut down the server. Once it’s powered off you can work on the needed firewall rules and consult with your provider in your own time. + +If you’re feeling a bit more confident and your hosting provider has an upstream firewall then create and enable the following two rules in this order: + +1. Allow SSH traffic from only your IP address. + +2. Block everything else, not just SSH but every protocol on every port. + +This will immediately kill their SSH session and give only you access to the server. + +If you don’t have access to an upstream firewall then you will have to create and enable these firewall rules on the server itself and then, when they are in place kill the attacker’s ssh session with the kill command. + +A final method, where available, is to log into the server via an out-of-band connection such as the serial console and stop networking with systemctl stop network.service. This will completely stop any network access so you can now enable the firewall rules in your own time. + +Once you have regained control of the server do not trust it. + +Do not attempt to fix things up and continue using the server. You can never be sure what the attacker did and so you can never sure the server is secure. + +The only sensible course of action is to copy off all the data that you need and start again from a fresh install. + +-------------------------------------------------------------------------------- + +via: https://bash-prompt.net/guides/server-hacked/ + +作者:[Elliot Cooper][a] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://bash-prompt.net diff --git a/sources/tech/20171128 The politics of the Linux desktop.md b/sources/tech/20171128 The politics of the Linux desktop.md new file mode 100644 index 0000000000..c9117dacfe --- /dev/null +++ b/sources/tech/20171128 The politics of the Linux desktop.md @@ -0,0 +1,110 @@ +The politics of the Linux desktop +============================================================ + +### If you're working in open source, why would you use anything but Linux as your main desktop? + + +![The politics of the Linux desktop](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_networks.png?itok=XasNXxKs "The politics of the Linux desktop") +Image by : opensource.com + +At some point in 1997 or 1998—history does not record exactly when—I made the leap from Windows to the Linux desktop. I went through quite a few distributions, from Red Hat to SUSE to Slackware, then Debian, Debian Experimental, and (for a long time thereafter) Ubuntu. When I accepted a role at Red Hat, I moved to Fedora, and migrated both my kids (then 9 and 11) to Fedora as well. + +More Linux resources + +* [What is Linux?][1] + +* [What are Linux containers?][2] + +* [Download Now: Linux commands cheat sheet][3] + +* [Advanced Linux commands cheat sheet][4] + +* [Our latest Linux articles][5] + +For a few years, I kept Windows as a dual-boot option, and then realised that, if I was going to commit to Linux, then I ought to go for it properly. In losing Windows, I didn't miss much; there were a few games that I couldn't play, but it was around the time that the Civilization franchise was embracing Linux, so that kept me happy. + +The move to Linux wasn't plain sailing, by any stretch of the imagination. If you wanted to use fairly new hardware in the early days, you had to first ensure that there were  _any_  drivers for Linux, then learn how to compile and install them. If they were not quite my friends, **lsmod** and **modprobe** became at least close companions. I taught myself to compile a kernel and tweak the options to make use of (sometimes disastrous) new, "EXPERIMENTAL" features as they came out. Early on, I learned the lesson that you should always keep at least one kernel in your [LILO][12] list that you were  _sure_  booted fully. I cursed NVidia and grew horrified by SCSI. I flirted with early journalling filesystem options and tried to work out whether the different preempt parameters made any noticeable difference to my user experience or not. I began to accept that printers would never print—and then they started to. I discovered that the Bluetooth stack suddenly started to connect to things. + +Over the years, using Linux moved from being an uphill struggle to something that just worked. I moved my mother-in-law and then my father over to Linux so I could help administer their machines. And then I moved them off Linux so they could no longer ask me to help administer their machines. + +Over the years, using Linux moved from being an uphill struggle to something that just worked.It wasn't just at home, either: I decided that I would use Linux as my desktop for work, as well. I even made it a condition of employment for at least one role. Linux desktop support in the workplace caused different sets of problems. The first was the "well, you're on your own: we're not going to support you" email from IT support. VPNs were touch and go, but in the end, usually go. + +The biggest hurdle was Microsoft Office, until I discovered [CrossOver][13], which I bought with my own money, and which allowed me to run company-issued copies of Word, PowerPoint, and the rest on my Linux desktop. Fonts were sometimes a problem, and one company I worked for required Microsoft Lync. For this, and for a few other applications, I would sometimes have to run a Windows virtual machine (VM) on my Linux desktop.  Was this a cop out?  Well, a little bit: but I've always tried to restrict my usage of this approach to the bare minimum. + +### But why? + +"Why?" colleagues would ask. "Why do you bother? Why not just run Windows?" + +"Because I enjoy pain," was usually my initial answer, and then the more honest, "because of the principle of the thing." + +So this is it: I believe in open source. We have a number of very, very good desktop-compatible distributions these days, and most of the time they just work. If you use well-known or supported hardware, they're likely to "just work" pretty much as well as the two obvious alternatives, Windows or Mac. And they just work because many people have put much time into using them, testing them, and improving them. So it's not a case of why wouldn't I use Windows or Mac, but why would I ever consider  _not_  using Linux? If, as I do, you believe in open source, and particularly if you work within the open source community or are employed by an open source organisation, I struggle to see why you would even consider not using Linux. + +So it's not a case of why wouldn't I use Windows or Mac, but why would I ever consider not using Linux?I've spoken to people about this (of course I have), and here are the most common reasons—or excuses—I've heard. + +1. I'm more productive on Windows/Mac. + +2. I can't use app X on Linux, and I need it for my job. + +3. I can't game on Linux. + +4. It's what our customers use, so why we would alienate them? + +5. "Open" means choice, and I prefer a proprietary desktop, so I use that. + +Interestingly, I don't hear "Linux isn't good enough" much anymore, because it's manifestly untrue, and I can show that my own experience—and that of many colleagues—belies that. + +### Rebuttals + +If you believe in open source, then I contest that you should take the time to learn how to use a Linux desktop and the associated applications.Let's go through those answers and rebut them. + +1. **I'm more productive on Windows/Mac.** I'm sure you are. Anyone is more productive when they're using a platform or a system they're used to. If you believe in open source, then I contest that you should take the time to learn how to use a Linux desktop and the associated applications. If you're working for an open source organisation, they'll probably help you along, and you're unlikely to find you're much less productive in the long term. And, you know what? If you are less productive in the long term, then get in touch with the maintainers of the apps that are causing you to be less productive and help improve them. You don't have to be a coder. You could submit bug reports, suggest improvements, write documentation, or just test the most recent versions of the software. And then you're helping yourself and the rest of the community. Welcome to open source. + +1. **I can't use app X on Linux, and I need it for my job.** This may be true. But it's probably less true than you think. The people most often saying this with conviction are audio, video, or graphics experts. It was certainly the case for many years that Linux lagged behind in those areas, but have a look and see what the other options are. And try them, even if they're not perfect, and see how you can improve them. Alternatively, use a VM for that particular app. + +1. **I can't game on Linux.** Well, you probably can, but not all the games that you enjoy. This, to be clear, shouldn't really be an excuse not to use Linux for most of what you do. It might be a reason to keep a dual-boot system or to do what I did (after much soul-searching) and buy a games console (because Elite Dangerous really  _doesn't_  work on Linux, more's the pity). It should also be an excuse to lobby for your favourite games to be ported to Linux. + +1. **It's what our customers use, so why would we alienate them?** I don't get this one. Does Microsoft ban visitors with Macs from their buildings? Does Apple ban Windows users? Does Google allow non-Android phones through their doors? You don't kowtow to the majority when you're the little guy or gal; if you're working in open source, surely you should be proud of that. You're not going to alienate your customer—you're really not. + +1. **"Open" means choice, and I prefer a proprietary desktop, so I use that.**Being open certainly does mean you have a choice. You made that choice by working in open source. For many, including me, that's a moral and philosophical choice. Saying you embrace open source, but rejecting it in practice seems mealy mouthed, even insulting. Using openness to justify your choice is the wrong approach. Saying "I prefer a proprietary desktop, and company policy allows me to do so" is better. I don't agree with your decision, but at least you're not using the principle of openness to justify it. + +Is using open source easy? Not always. But it's getting easier. I think that we should stand up for what we believe in, and if you're reading [Opensource.com][14], then you probably believe in open source. And that, I believe, means that you should run Linux as your main desktop. + + _Note: I welcome comments, and would love to hear different points of view. I would ask that comments don't just list application X or application Y as not working on Linux. I concede that not all apps do. I'm more interested in justifications that I haven't covered above, or (perceived) flaws in my argument. Oh, and support for it, of course._ + + +### About the author + + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/2017-05-10_0129.jpg?itok=Uh-eKFhx)][15] + + Mike Bursell - I've been in and around Open Source since around 1997, and have been running (GNU) Linux as my main desktop at home and work since then: [not always easy][7]...  I'm a security bod and architect, and am currently employed as Chief Security Architect for Red Hat.  I have a blog - "[Alice, Eve & Bob][8]" - where I write (sometimes rather parenthetically) about security.  I live in the UK and... [more about Mike Bursell][9][More about me][10] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/politics-linux-desktop + +作者:[Mike Bursell ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/mikecamel +[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[6]:https://opensource.com/article/17/11/politics-linux-desktop?rate=do69ixoNzK0yg3jzFk0bc6ZOBsIUcqTYv6FwqaVvzUA +[7]:https://opensource.com/article/17/11/politics-linux-desktop +[8]:https://aliceevebob.com/ +[9]:https://opensource.com/users/mikecamel +[10]:https://opensource.com/users/mikecamel +[11]:https://opensource.com/user/105961/feed +[12]:https://en.wikipedia.org/wiki/LILO_(boot_loader) +[13]:https://en.wikipedia.org/wiki/CrossOver_(software) +[14]:https://opensource.com/ +[15]:https://opensource.com/users/mikecamel +[16]:https://opensource.com/users/mikecamel +[17]:https://opensource.com/users/mikecamel +[18]:https://opensource.com/article/17/11/politics-linux-desktop#comments +[19]:https://opensource.com/tags/linux diff --git a/sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md b/sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md new file mode 100644 index 0000000000..479bfb1232 --- /dev/null +++ b/sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md @@ -0,0 +1,142 @@ +Why Python and Pygame are a great pair for beginning programmers +============================================================ + +### We look at three reasons Pygame is a good choice for learning to program. + + +![What's the best game platform for beginning programmers?](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_development_programming.png?itok=M_QDcgz5 "What's the best game platform for beginning programmers?") +Image by :  + +opensource.com + +Last month, [Scott Nesbitt][10] wrote about [Mozilla awarding $500K to support open source projects][11]. Phaser, a HTML/JavaScript game platform, was [awarded $50,000][12]. I’ve been teaching Phaser to my pre-teen daughter for a year, and it's one of the best and easiest HTML game development platforms to learn. [Pygame][13], however, may be a better choice for beginners. Here's why. + +### 1\. One long block of code + +Pygame is based on Python, the [most popular language for introductory computer courses][14]. Python is great for writing out ideas in one long block of code. Kids start off with a single file and with a single block of code. Before they can get to functions or classes, they start with code that will soon resemble spaghetti. It’s like finger-painting, as they throw thoughts onto the page. + +More Python Resources + +* [What is Python?][1] + +* [Top Python IDEs][2] + +* [Top Python GUI frameworks][3] + +* [Latest Python content][4] + +* [More developer resources][5] + +This approach to learning works. Kids will naturally start to break things into functions and classes as their code gets more difficult to manage. By learning the syntax of a language like Python prior to learning about functions, the student will gain basic programming knowledge before using global and local scope. + +Most HTML games separate the structure, style, and programming logic into HTML, CSS, and JavaScript to some degree and require knowledge of CSS and HTML. While the separation is better in the long term, it can be a barrier for beginners. Once kids realize that they can quickly build web pages with HTML and CSS, they may get distracted by the visual excitement of colors, fonts, and graphics. Even those who stay focused on JavaScript coding will still need to learn the basic document structure that the JavaScript code sits in. + +### 2\. Global variables are more obvious + +Both Python and JavaScript use dynamically typed variables, meaning that a variable becomes a string, an integer, or float when it’s assigned; however, making mistakes is easier in JavaScript. Similar to typed variables, both JavaScript and Python have global and local variable scopes. In Python, global variables inside of a function are identified with the global keyword. + +Let’s look at the basic [Making your first Phaser game tutorial][15], by Alvin Ourrad and Richard Davey, to understand the challenge of using Phaser to teach programming to beginners. In JavaScript, global variables—variables that can be accessed anywhere in the program—are difficult to keep track of and often are the source of bugs that are challenging to solve. Richard and Alvin are expert programmers and use global variables intentionally to keep things concise. + +``` +var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }); + +function preload() { + +    game.load.image('sky', 'assets/sky.png'); + +} + +var player; +var platforms; + +function create() { +    game.physics.startSystem(Phaser.Physics.ARCADE); +… +``` + +In their Phaser programming book  [_Interphase_ ,][16] Richard Davey and Ilija Melentijevic explain that global variables are commonly used in many Phaser projects because they make it easier to get things done quickly. + +> “If you’ve ever worked on a game of any significant size then this approach is probably already making you cringe slightly... So why do we do it? The reason is simply because it’s the most concise and least complicated way to demonstrate what Phaser can do.” + +Although structuring a Phaser application to use local variables and split things up nicely into separation of concerns is possible, that’s tough for kids to understand when they’re first learning to program. + +If you’re set on teaching your kids to code with JavaScript, or if they already know how to code in another language like Python, a good Phaser course is [The Complete Mobile Game Development Course][17], by [Pablo Farias Navarro][18]. Although the title focuses on mobile games, the actual course focuses on JavaScript and Phaser. The JavaScript and Phaser apps are moved to a mobile phone with [PhoneGap][19]. + +### 3\. Pygame comes with less assembly required + +Thanks to [Python Wheels][20], Pygame is now super [easy to install][21]. You can also install it on Fedora/Red Hat with the **yum** package manager: + +``` +sudo yum install python3-pygame +``` + +See the official [Pygame installation documentation][22] for more information. + +Although Phaser itself is even easier to install, it does require more knowledge to use. As mentioned previously, the student will need to assemble their JavaScript code within an HTML document with some CSS. In addition to the three languages—HTML, CSS, and JavaScript—Phaser also requires the use of Firefox or Chrome development tools and an editor. The most common editors for JavaScript are Sublime, Atom, VS Code (probably in that order). + +Phaser applications will not run if you open the HTML file in a browser directly, due to [same-origin policy][23]. You must run a web server and access the files by connecting to the web server. Fortunately, you don’t need to run Apache on your local computer; you can run something lightweight like [httpster][24] for most projects. + +### Advantages of Phaser and JavaScript + +With all the challenges of JavaScript and Phaser, why am I teaching them? Honestly, I held off for a long time. I worried about students learning variable hoisting and scope. I developed my own curriculum based on Pygame and Python, then I developed one based on Phaser. Eventually, I decided to use Pablo’s pre-made curriculum as a starting point.  + +There are really two reasons that I moved to JavaScript. First, JavaScript has emerged as a serious language used in serious applications. In addition to web applications, it’s used for mobile and server applications. JavaScript is everywhere, and it’s used widely in applications kids see every day. If their friends code in JavaScript, they'll likely want to as well. As I saw the momentum behind JavaScript, I looked into alternatives that could compile into JavaScript, primarily Dart and TypeScript. I didn’t mind the extra conversion step, but I still looked at JavaScript. + +In the end, I chose to use Phaser and JavaScript because I realized that the problems could be solved with JavaScript and a bit of work. High-quality debugging tools and the work of some exceptionally smart people have made JavaScript a language that is both accessible and useful for teaching kids to code. + +### Final word: Python vs. JavaScript + +When people ask me what language to start their kids with, I immediately suggest Python and Pygame. There are tons of great curriculum options, many of which are free. I used ["Making Games with Python & Pygame"][25] by Al Sweigart with my son. I also used  _[Think Python: How to Think Like a Computer Scientist][7]_ by Allen B. Downey. You can get Pygame on your Android phone with [RAPT Pygame][26] by [Tom Rothamel][27]. + +Despite my recommendation, I always suspect that kids soon move to JavaScript. And that’s okay—JavaScript is a mature language with great tools. They’ll have fun with JavaScript and learn a lot. But after years of helping my daughter’s older brother create cool games in Python, I’ll always have an emotional attachment to Python and Pygame. + +### About the author + + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/craig-head-crop.png?itok=LlMnIq8m)][28] + + Craig Oda - First elected president and co-founder of Tokyo Linux Users Group. Co-author of "Linux Japanese Environment" book published by O'Reilly Japan. Part of core team that established first ISP in Asia. Former VP of product management and product marketing for major Linux company. Partner at Oppkey, developer relations consulting firm in Silicon Valley.[More about me][8] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/pygame + +作者:[Craig Oda ][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/codetricity +[1]:https://opensource.com/resources/python?intcmp=7016000000127cYAAQ +[2]:https://opensource.com/resources/python/ides?intcmp=7016000000127cYAAQ +[3]:https://opensource.com/resources/python/gui-frameworks?intcmp=7016000000127cYAAQ +[4]:https://opensource.com/tags/python?intcmp=7016000000127cYAAQ +[5]:https://developers.redhat.com/?intcmp=7016000000127cYAAQ +[6]:https://opensource.com/article/17/11/pygame?rate=PV7Af00S0QwicZT2iv8xSjJrmJPdpfK1Kcm7LXxl_Xc +[7]:http://greenteapress.com/thinkpython/html/index.html +[8]:https://opensource.com/users/codetricity +[9]:https://opensource.com/user/46031/feed +[10]:https://opensource.com/users/scottnesbitt +[11]:https://opensource.com/article/17/10/news-october-14 +[12]:https://www.patreon.com/photonstorm/posts +[13]:https://www.pygame.org/news +[14]:https://cacm.acm.org/blogs/blog-cacm/176450-python-is-now-the-most-popular-introductory-teaching-language-at-top-u-s-universities/fulltext +[15]:http://phaser.io/tutorials/making-your-first-phaser-game +[16]:https://phaser.io/interphase +[17]:https://academy.zenva.com/product/the-complete-mobile-game-development-course-platinum-edition/ +[18]:https://gamedevacademy.org/author/fariazz/ +[19]:https://phonegap.com/ +[20]:https://pythonwheels.com/ +[21]:https://pypi.python.org/pypi/Pygame +[22]:http://www.pygame.org/wiki/GettingStarted#Pygame%20Installation +[23]:https://blog.chromium.org/2008/12/security-in-depth-local-web-pages.html +[24]:https://simbco.github.io/httpster/ +[25]:https://inventwithpython.com/makinggames.pdf +[26]:https://github.com/renpytom/rapt-pygame-example +[27]:https://github.com/renpytom +[28]:https://opensource.com/users/codetricity +[29]:https://opensource.com/users/codetricity +[30]:https://opensource.com/users/codetricity +[31]:https://opensource.com/article/17/11/pygame#comments +[32]:https://opensource.com/tags/python +[33]:https://opensource.com/tags/programming diff --git a/sources/tech/20171129 10 open source technology trends for 2018.md b/sources/tech/20171129 10 open source technology trends for 2018.md new file mode 100644 index 0000000000..eb21c62ec9 --- /dev/null +++ b/sources/tech/20171129 10 open source technology trends for 2018.md @@ -0,0 +1,143 @@ +translating by wangy325... + + +10 open source technology trends for 2018 +============================================================ + +### What do you think will be the next open source tech trends? Here are 10 predictions. + +![10 open source technology trends for 2018](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fireworks-newyear-celebrate.png?itok=6gXaznov "10 open source technology trends for 2018") +Image by : [Mitch Bennett][10]. Modified by Opensource.com. [CC BY-SA 4.0][11] + +Technology is always evolving. New developments, such as OpenStack, Progressive Web Apps, Rust, R, the cognitive cloud, artificial intelligence (AI), the Internet of Things, and more are putting our usual paradigms on the back burner. Here is a rundown of the top open source trends expected to soar in popularity in 2018. + +### 1\. OpenStack gains increasing acceptance + +[OpenStack][12] is essentially a cloud operating system that offers admins the ability to provision and control huge compute, storage, and networking resources through an intuitive and user-friendly dashboard. + +Many enterprises are using the OpenStack platform to build and manage cloud computing systems. Its popularity rests on its flexible ecosystem, transparency, and speed. It supports mission-critical applications with ease and lower costs compared to alternatives. But, OpenStack's complex structure and its dependency on virtualization, servers, and extensive networking resources has inhibited its adoption by a wider range of enterprises. Using OpenStack also requires a well-oiled machinery of skilled staff and resources. + +The OpenStack Foundation is working overtime to fill the voids. Several innovations, either released or on the anvil, would resolve many of its underlying challenges. As complexities decrease, OpenStack will surge in acceptance. The fact that OpenStack is already backed by many big software development and hosting companies, in addition to thousands of individual members, makes it the future of cloud computing. + +### 2\. Progressive Web Apps become popular + +[Progressive Web Apps][13] (PWA), an aggregation of technologies, design concepts, and web APIs, offer an app-like experience in the mobile browser. + +Traditional websites suffer from many inherent shortcomings. Apps, although offering a more personal and focused engagement than websites, place a huge demand on resources, including needing to be downloaded upfront. PWA delivers the best of both worlds. It delivers an app-like experience to users while being accessible on browsers, indexable on search engines, and responsive to fit any form factor. Like an app, a PWA updates itself to always display the latest real-time information, and, like a website, it is delivered in an ultra-safe HTTPS model. It runs in a standard container and is accessible to anyone who types in the URL, without having to install anything. + +PWAs perfectly suit the needs of today's mobile users, who value convenience and personal engagement over everything else. That this technology is set to soar in popularity is a no-brainer. + +### 3\. Rust to rule the roost + +Most programming languages come with safety vs. control tradeoffs. [Rust][14] is an exception. The language co-opts extensive compile-time checking to offer 100% control without compromising safety. The last [Pwn2Own][15] competition threw up many serious vulnerabilities in Firefox on account of its underlying C++ language. If Firefox had been written in Rust, many of those errors would have manifested as compile-time bugs and resolved before the product rollout stage. + +Rust's unique approach of built-in unit testing has led developers to consider it a viable first-choice open source language. It offers an effective alternative to languages such as C and Python to write secure code without sacrificing expressiveness. Rust has bright days ahead in 2018. + +### 4\. R user community grows + +The [R][16] programming language, a GNU project, is associated with statistical computing and graphics. It offers a wide array of statistical and graphical techniques and is extensible to boot. It starts where [S][17] ends. With the S language already the vehicle of choice for research in statistical methodology, R offers a viable open source route for data manipulation, calculation, and graphical display. An added benefit is R's attention to detail and care for the finer nuances. + +Like Rust, R's fortunes are on the rise. + +### 5\. XaaS expands in scope + +XaaS, an acronym for "anything as a service," stands for the increasing number of services delivered over the internet, rather than on premises. Although software as a service (SaaS), infrastructure as a service (IaaS), and platform as a service (PaaS) are well-entrenched, new cloud-based models, such as network as a service (NaaS), storage as a service (SaaS or StaaS), monitoring as a service (MaaS), and communications as a service (CaaS), are soaring in popularity. A world where anything and everything is available "as a service" is not far away. + +The scope of XaaS now extends to bricks-and-mortar businesses, as well. Good examples are companies such as Uber and Lyft leveraging digital technology to offer transportation as a service and Airbnb offering accommodations as a service. + +High-speed networks and server virtualization that make powerful computing affordable have accelerated the popularity of XaaS, to the point that 2018 may become the "year of XaaS." The unmatched flexibility, agility, and scalability will propel the popularity of XaaS even further. + +### 6\. Containers gain even more acceptance + +Container technology is the approach of packaging pieces of code in a standardized way so they can be "plugged and run" quickly in any environment. Container technology allows enterprises to cut costs and implementation times. While the potential of containers to revolutionize IT infrastructure has been evident for a while, actual container use has remained complex. + +Container technology is still evolving, and the complexities associated with the technology decrease with every advancement. The latest developments make containers quite intuitive and as easy as using a smartphone, not to mention tuned for today's needs, where speed and agility can make or break a business. + +### 7\. Machine learning and artificial intelligence expand in scope + +[Machine learning and AI][18] give machines the ability to learn and improve from experience without a programmer explicitly coding the instruction. + +These technologies are already well entrenched, with several open source technologies leveraging them for cutting-edge services and applications. + +[Gartner predicts][19] the scope of machine learning and artificial intelligence will expand in 2018\. Several greenfield areas, such as data preparation, integration, algorithm selection, training methodology selection, and model creation are all set for big-time enhancements through the infusion of machine learning. + +New open source intelligent solutions are set to change the way people interact with systems and transform the very nature of work. + +* Conversational platforms, such as chatbots, make the question-and-command experience, where a user asks a question and the platform responds, the default medium of interacting with machines. + +* Autonomous vehicles and drones, fancy fads today, are expected to become commonplace by 2018. + +* The scope of immersive experience will expand beyond video games and apply to real-life scenarios such as design, training, and visualization processes. + +### 8\. Blockchain becomes mainstream + +Blockchain has come a long way from Bitcoin. The technology is already in widespread use in finance, secure voting, authenticating academic credentials, and more. In the coming year, healthcare, manufacturing, supply chain logistics, and government services are among the sectors most likely to embrace blockchain technology. + +Blockchain distributes digital information. The information resides on millions of nodes, in shared and reconciled databases. The fact that it's not controlled by any single authority and has no single point of failure makes it very robust, transparent, and incorruptible. It also solves the threat of a middleman manipulating the data. Such inherent strengths account for blockchain's soaring popularity and explain why it is likely to emerge as a mainstream technology in the immediate future. + +### 9\. Cognitive cloud moves to center stage + +Cognitive technologies, such as machine learning and artificial intelligence, are increasingly used to reduce complexity and personalize experiences across multiple sectors. One case in point is gamification apps in the financial sector, which offer investors critical investment insights and reduce the complexities of investment models. Digital trust platforms reduce the identity-verification process for financial institutions by about 80%, improving compliance and reducing chances of fraud. + +Such cognitive cloud technologies are now moving to the cloud, making it even more potent and powerful. IBM Watson is the most well-known example of the cognitive cloud in action. IBM's UIMA architecture was made open source and is maintained by the Apache Foundation. DARPA's DeepDive project mirrors Watson's machine learning abilities to enhance decision-making capabilities over time by learning from human interactions. OpenCog, another open source platform, allows developers and data scientists to develop artificial intelligence apps and programs. + +Considering the high stakes of delivering powerful and customized experiences, these cognitive cloud platforms are set to take center stage over the coming year. + +### 10\. The Internet of Things connects more things + +At its core, the Internet of Things (IoT) is the interconnection of devices through embedded sensors or other computing devices that enable the devices (the "things") to send and receive data. IoT is already predicted to be the next big major disruptor of the tech space, but IoT itself is in a continuous state of flux. + +One innovation likely to gain widespread acceptance within the IoT space is Autonomous Decentralized Peer-to-Peer Telemetry ([ADEPT][20]), which is propelled by IBM and Samsung. It uses a blockchain-type technology to deliver a decentralized network of IoT devices. Freedom from a central control system facilitates autonomous communications between "things" in order to manage software updates, resolve bugs, manage energy, and more. + +### Open source drives innovation + +Digital disruption is the norm in today's tech-centric era. Within the technology space, open source is now pervasive, and in 2018, it will be the driving force behind most of the technology innovations. + +Which open source trends and technologies would you add to this list? Let us know in the comments. + +### Topics + + [Business][25][Yearbook][26][2017 Open Source Yearbook][27] + +### About the author + + [![Sreejith@Fingent](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/sreejith.jpg?itok=sdYNV49V)][21] Sreejith - I have been programming since 2000, and professionally since 2007\. I currently lead the Open Source team at [Fingent][6] as we work on different technology stacks, ranging from the "boring"(read tried and trusted) to the bleeding edge. I like building, tinkering with and breaking things, not necessarily in that order. Hit me up at: [https://www.linkedin.com/in/futuregeek/][7][More about me][8] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/10-open-source-technology-trends-2018 + +作者:[Sreejith ][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/sreejith +[1]:https://opensource.com/resources/what-is-openstack?intcmp=7016000000127cYAAQ +[2]:https://opensource.com/resources/openstack/tutorials?intcmp=7016000000127cYAAQ +[3]:https://opensource.com/tags/openstack?intcmp=7016000000127cYAAQ +[4]:https://www.rdoproject.org/?intcmp=7016000000127cYAAQ +[5]:https://opensource.com/article/17/11/10-open-source-technology-trends-2018?rate=GJqOXhiWvZh0zZ6WVTUzJ2TDJBpVpFhngfuX9V-dz4I +[6]:https://www.fingent.com/ +[7]:https://www.linkedin.com/in/futuregeek/ +[8]:https://opensource.com/users/sreejith +[9]:https://opensource.com/user/185026/feed +[10]:https://www.flickr.com/photos/mitchell3417/9206373620 +[11]:https://creativecommons.org/licenses/by-sa/4.0/ +[12]:https://www.openstack.org/ +[13]:https://developers.google.com/web/progressive-web-apps/ +[14]:https://www.rust-lang.org/ +[15]:https://en.wikipedia.org/wiki/Pwn2Own +[16]:https://en.wikipedia.org/wiki/R_(programming_language) +[17]:https://en.wikipedia.org/wiki/S_(programming_language) +[18]:https://opensource.com/tags/artificial-intelligence +[19]:https://sdtimes.com/gartners-top-10-technology-trends-2018/ +[20]:https://insights.samsung.com/2016/03/17/block-chain-mobile-and-the-internet-of-things/ +[21]:https://opensource.com/users/sreejith +[22]:https://opensource.com/users/sreejith +[23]:https://opensource.com/users/sreejith +[24]:https://opensource.com/article/17/11/10-open-source-technology-trends-2018#comments +[25]:https://opensource.com/tags/business +[26]:https://opensource.com/tags/yearbook +[27]:https://opensource.com/yearbook/2017 diff --git a/sources/tech/20171129 5 best practices for getting started with DevOps.md b/sources/tech/20171129 5 best practices for getting started with DevOps.md new file mode 100644 index 0000000000..962f37aaf4 --- /dev/null +++ b/sources/tech/20171129 5 best practices for getting started with DevOps.md @@ -0,0 +1,94 @@ +5 best practices for getting started with DevOps +============================================================ + +### Are you ready to implement DevOps, but don't know where to begin? Try these five best practices. + + +![5 best practices for getting started with DevOps](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/devops-gears.png?itok=rUejbLQX "5 best practices for getting started with DevOps") +Image by :  + +[Andrew Magill][8]. Modified by Opensource.com. [CC BY 4.0][9] + +DevOps often stymies early adopters with its ambiguity, not to mention its depth and breadth. By the time someone buys into the idea of DevOps, their first questions usually are: "How do I get started?" and "How do I measure success?" These five best practices are a great road map to starting your DevOps journey. + +### 1\. Measure all the things + +You don't know for sure that your efforts are even making things better unless you can quantify the outcomes. Are my features getting out to customers more rapidly? Are fewer defects escaping to them? Are we responding to and recovering more quickly from failure? + +Before you change anything, think about what kinds of outcomes you expect from your DevOps transformation. When you're further into your DevOps journey, you'll enjoy a rich array of near-real-time reports on everything about your service. But consider starting with these two metrics: + +* **Time to market** measures the end-to-end, often customer-facing, business experience. It usually begins when a feature is formally conceived and ends when the customer can consume the feature in production. Time to market is not mainly an engineering team metric; more importantly it shows your business' complete end-to-end efficiency in bringing valuable new features to market and isolates opportunities for system-wide improvement. + +* **Cycle time** measures the engineering team process. Once work on a new feature starts, when does it become available in production? This metric is very useful for understanding the efficiency of the engineering team and isolating opportunities for team-level improvement. + +### 2\. Get your process off the ground + +DevOps success requires an organization to put a regular (and hopefully effective) process in place and relentlessly improve upon it. It doesn't have to start out being effective, but it must be a regular process. Usually that it's some flavor of agile methodology like Scrum or Scrumban; sometimes it's a Lean derivative. Whichever way you go, pick a formal process, start using it, and get the basics right. + +Regular inspect-and-adapt behaviors are key to your DevOps success. Make good use of opportunities like the stakeholder demo, team retrospectives, and daily standups to find opportunities to improve your process. + +A lot of your DevOps success hinges on people working effectively together. People on a team need to work from a common process that they are empowered to improve upon. They also need regular opportunities to share what they are learning with other stakeholders, both upstream and downstream, in the process. + +Good process discipline will help your organization consume the other benefits of DevOps at the great speed that comes as your success builds. + +Although it's common for more development-oriented teams to successfully adopt processes like Scrum, operations-focused teams (or others that are more interrupt-driven) may opt for a process with a more near-term commitment horizon, such as Kanban. + +### 3\. Visualize your end-to-end workflow + +There is tremendous power in being able to see who's working on what part of your service at any given time. Visualizing your workflow will help people know what they need to work on next, how much work is in progress, and where the bottlenecks are in the process. + +You can't effectively limit work in process until you can see it and quantify it. Likewise, you can't effectively eliminate bottlenecks until you can clearly see them. + +Visualizing the entire workflow will help people in all parts of the organization understand how their work contributes to the success of the whole. It can catalyze relationship-building across organizational boundaries to help your teams collaborate more effectively towards a shared sense of success. + +### 4\. Continuous all the things + +DevOps promises a dizzying array of compelling automation. But Rome wasn't built in a day. One of the first areas you can focus your efforts on is [continuous integration][10] (CI). But don't stop there; you'll want to follow quickly with [continuous delivery][11] (CD) and eventually continuous deployment. + +Your CD pipeline is your opportunity to inject all manner of automated quality testing into your process. The moment new code is committed, your CD pipeline should run a battery of tests against the code and the successfully built artifact. The artifact that comes out at the end of this gauntlet is what progresses along your process until eventually it's seen by customers in production. + +Another "continuous" that doesn't get enough attention is continuous improvement. That's as simple as setting some time aside each day to ask your colleagues: "What small thing can we do today to get better at how we do our work?" These small, daily changes compound over time into more profound results. You'll be pleasantly surprised! But it also gets people thinking all the time about how to improve things. + +### 5\. Gherkinize + +Fostering more effective communication across your organization is crucial to fostering the sort of systems thinking prevalent in successful DevOps journeys. One way to help that along is to use a shared language between the business and the engineers to express the desired acceptance criteria for new features. A good product manager can learn [Gherkin][12] in a day and begin using it to express acceptance criteria in an unambiguous, structured form of plain English. Engineers can use this Gherkinized acceptance criteria to write acceptance tests against the criteria, and then develop their feature code until the tests pass. This is a simplification of [acceptance test-driven development][13](ATDD) that can also help kick start your DevOps culture and engineering practice. + +### Start on your journey + +Don't be discouraged by getting started with your DevOps practice. It's a journey. And hopefully these five ideas give you solid ways to get started. + + +### About the author + + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/headshot_4.jpg?itok=jntfDCfX)][14] + + Magnus Hedemark - Magnus has been in the IT industry for over 20 years, and a technology enthusiast for most of his life. He's presently Manager of DevOps Engineering at UnitedHealth Group. In his spare time, Magnus enjoys photography and paddling canoes. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/5-keys-get-started-devops + +作者:[Magnus Hedemark ][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/magnus919 +[1]:https://opensource.com/tags/devops?src=devops_resource_menu1 +[2]:https://opensource.com/resources/devops?src=devops_resource_menu2 +[3]:https://www.openshift.com/promotions/devops-with-openshift.html?intcmp=7016000000127cYAAQ&src=devops_resource_menu3 +[4]:https://enterprisersproject.com/article/2017/5/9-key-phrases-devops?intcmp=7016000000127cYAAQ&src=devops_resource_menu4 +[5]:https://www.redhat.com/en/insights/devops?intcmp=7016000000127cYAAQ&src=devops_resource_menu5 +[6]:https://opensource.com/article/17/11/5-keys-get-started-devops?rate=oEOzMXx1ghbkfl2a5ae6AnvO88iZ3wzkk53K2CzbDWI +[7]:https://opensource.com/user/25739/feed +[8]:https://ccsearch.creativecommons.org/image/detail/7qRx_yrcN5isTMS0u9iKMA== +[9]:https://creativecommons.org/licenses/by-sa/4.0/ +[10]:https://martinfowler.com/articles/continuousIntegration.html +[11]:https://martinfowler.com/bliki/ContinuousDelivery.html +[12]:https://cucumber.io/docs/reference +[13]:https://en.wikipedia.org/wiki/Acceptance_test%E2%80%93driven_development +[14]:https://opensource.com/users/magnus919 +[15]:https://opensource.com/users/magnus919 +[16]:https://opensource.com/users/magnus919 +[17]:https://opensource.com/tags/devops diff --git a/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md b/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md new file mode 100644 index 0000000000..d3ba75da14 --- /dev/null +++ b/sources/tech/20171129 How to Install and Use Wireshark on Debian and Ubuntu 16.04_17.10.md @@ -0,0 +1,185 @@ +Translating by filefi + + +How to Install and Use Wireshark on Debian 9 / Ubuntu 16.04 / 17.10 +============================================================ + +by [Pradeep Kumar][1] · Published November 29, 2017 · Updated November 29, 2017 + + [![wireshark-Debian-9-Ubuntu 16.04 -17.10](https://www.linuxtechi.com/wp-content/uploads/2017/11/wireshark-Debian-9-Ubuntu-16.04-17.10.jpg)][2] + +Wireshark is free and open source, cross platform, GUI based Network packet analyzer that is available for Linux, Windows, MacOS, Solaris etc. It captures network packets in real time & presents them in human readable format. Wireshark allows us to monitor the network packets up to microscopic level. Wireshark also has a command line utility called ‘tshark‘ that performs the same functions as Wireshark but through terminal & not through GUI. + +Wireshark can be used for network troubleshooting, analyzing, software & communication protocol development & also for education purposed. Wireshark uses a library called ‘pcap‘ for capturing the network packets. + +Wireshark comes with a lot of features & some those features are; + +* Support for a hundreds of protocols for inspection, + +* Ability to capture packets in real time & save them for later offline analysis, + +* A number of filters to analyzing data, + +* Data captured can be compressed & uncompressed on the fly, + +* Various file formats for data analysis supported, output can also be saved to XML, CSV, plain text formats, + +* data can be captured from a number of interfaces like ethernet, wifi, bluetooth, USB, Frame relay , token rings etc. + +In this article, we will discuss how to install Wireshark on Ubuntu/Debain machines & will also learn to use Wireshark for capturing network packets. + +#### Installation of Wireshark on Ubuntu 16.04 / 17.10 + +Wireshark is available with default Ubuntu repositories & can be simply installed using the following command. But there might be chances that you will not get the latest version of wireshark. + +``` +linuxtechi@nixworld:~$ sudo apt-get update +linuxtechi@nixworld:~$ sudo apt-get install wireshark -y +``` + +So to install latest version of wireshark we have to enable or configure official wireshark repository. + +Use the beneath commands one after the another to configure repository and to install latest version of Wireshark utility + +``` +linuxtechi@nixworld:~$ sudo add-apt-repository ppa:wireshark-dev/stable +linuxtechi@nixworld:~$ sudo apt-get update +linuxtechi@nixworld:~$ sudo apt-get install wireshark -y +``` + +Once the Wireshark is installed execute the below command so that non-root users can capture live packets of interfaces, + +``` +linuxtechi@nixworld:~$ sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' /usr/bin/dumpcap +``` + +#### Installation of Wireshark on Debian 9 + +Wireshark package and its dependencies are already present in the default debian 9 repositories, so to install latest and stable version of Wireshark on Debian 9, use the following command: + +``` +linuxtechi@nixhome:~$ sudo apt-get update +linuxtechi@nixhome:~$ sudo apt-get install wireshark -y +``` + +During the installation, it will prompt us to configure dumpcap for non-superusers, + +Select ‘yes’ and then hit enter. + + [![Configure-Wireshark-Debian9](https://www.linuxtechi.com/wp-content/uploads/2017/11/Configure-Wireshark-Debian9-1024x542.jpg)][3] + +Once the Installation is completed, execute the below command so that non-root users can also capture the live packets of the interfaces. + +``` +linuxtechi@nixhome:~$ sudo chmod +x /usr/bin/dumpcap +``` + +We can also use the latest source package to install the wireshark on Ubuntu/Debain & many other Linux distributions. + +#### Installing Wireshark using source code on Debian / Ubuntu Systems + +Firstly download the latest source package (which is 2.4.2 at the time for writing this article), use the following command, + +``` +linuxtechi@nixhome:~$ wget https://1.as.dl.wireshark.org/src/wireshark-2.4.2.tar.xz +``` + +Next extract the package & enter into the extracted directory, + +``` +linuxtechi@nixhome:~$ tar -xf wireshark-2.4.2.tar.xz -C /tmp +linuxtechi@nixhome:~$ cd /tmp/wireshark-2.4.2 +``` + +Now we will compile the code with the following commands, + +``` +linuxtechi@nixhome:/tmp/wireshark-2.4.2$ ./configure --enable-setcap-install +linuxtechi@nixhome:/tmp/wireshark-2.4.2$ make +``` + +Lastly install the compiled packages to install Wireshark on the system, + +``` +linuxtechi@nixhome:/tmp/wireshark-2.4.2$ sudo make install +linuxtechi@nixhome:/tmp/wireshark-2.4.2$ sudo ldconfig +``` + +Upon installation a separate group for Wireshark will also be created, we will now add our user to the group so that it can work with wireshark otherwise you might get ‘permission denied‘ error when starting wireshark. + +To add the user to the wireshark group, execute the following command, + +``` +linuxtechi@nixhome:~$ sudo usermod -a -G wireshark linuxtechi +``` + +Now we can start wireshark either from GUI Menu or from terminal with this command, + +``` +linuxtechi@nixhome:~$ wireshark +``` + +#### Access Wireshark on Debian 9 System + + [![Access-wireshark-debian9](https://www.linuxtechi.com/wp-content/uploads/2017/11/Access-wireshark-debian9-1024x664.jpg)][4] + +Click on Wireshark icon + + [![Wireshark-window-debian9](https://www.linuxtechi.com/wp-content/uploads/2017/11/Wireshark-window-debian9-1024x664.jpg)][5] + +#### Access Wireshark on Ubuntu 16.04 / 17.10 + + [![Access-wireshark-Ubuntu](https://www.linuxtechi.com/wp-content/uploads/2017/11/Access-wireshark-Ubuntu-1024x664.jpg)][6] + +Click on Wireshark icon + + [![Wireshark-window-Ubuntu](https://www.linuxtechi.com/wp-content/uploads/2017/11/Wireshark-window-Ubuntu-1024x664.jpg)][7] + +#### Capturing and Analyzing packets + +Once the wireshark has been started, we should be presented with the wireshark window, example is shown above for Ubuntu and Debian system. + + [![wireshark-Linux-system](https://www.linuxtechi.com/wp-content/uploads/2017/11/wireshark-Linux-system.jpg)][8] + +All these are the interfaces from where we can capture the network packets. Based on the interfaces you have on your system, this screen might be different for you. + +We are selecting ‘enp0s3’ for capturing the network traffic for that inteface. After selecting the inteface, network packets for all the devices on our network start to populate (refer to screenshot below) + + [![Capturing-Packet-from-enp0s3-Ubuntu-Wireshark](https://www.linuxtechi.com/wp-content/uploads/2017/11/Capturing-Packet-from-enp0s3-Ubuntu-Wireshark-1024x727.jpg)][9] + +First time we see this screen we might get overwhelmed by the data that is presented in this screen & might have thought how to sort out this data but worry not, one the best features of Wireshark is its filters. + +We can sort/filter out the data based on IP address, Port number, can also used source & destination filters, packet size etc & can also combine 2 or more filters together to create more comprehensive searches. We can either write our filters in ‘Apply a Display Filter‘ tab , or we can also select one of already created rules. To select pre-built filter, click on ‘flag‘ icon , next to ‘Apply a Display Filter‘ tab, + + [![Filter-in-wireshark-Ubuntu](https://www.linuxtechi.com/wp-content/uploads/2017/11/Filter-in-wireshark-Ubuntu-1024x727.jpg)][10] + +We can also filter data based on the color coding, By default, light purple is TCP traffic, light blue is UDP traffic, and black identifies packets with errors , to see what these codes mean, click View -> Coloring Rules, also we can change these codes. + + [![Packet-Colouring-Wireshark](https://www.linuxtechi.com/wp-content/uploads/2017/11/Packet-Colouring-Wireshark-1024x682.jpg)][11] + +After we have the results that we need, we can then click on any of the captured packets to get more details about that packet, this will show all the data about that network packet. + +Wireshark is an extremely powerful tool takes some time to getting used to & make a command over it, this tutorial will help you get started. Please feel free to drop in your queries or suggestions in the comment box below. + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com + +作者:[Pradeep Kumar][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linuxtechi.com/author/pradeep/ +[1]:https://www.linuxtechi.com/author/pradeep/ +[2]:https://www.linuxtechi.com/wp-content/uploads/2017/11/wireshark-Debian-9-Ubuntu-16.04-17.10.jpg +[3]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Configure-Wireshark-Debian9.jpg +[4]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Access-wireshark-debian9.jpg +[5]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Wireshark-window-debian9.jpg +[6]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Access-wireshark-Ubuntu.jpg +[7]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Wireshark-window-Ubuntu.jpg +[8]:https://www.linuxtechi.com/wp-content/uploads/2017/11/wireshark-Linux-system.jpg +[9]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Capturing-Packet-from-enp0s3-Ubuntu-Wireshark.jpg +[10]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Filter-in-wireshark-Ubuntu.jpg +[11]:https://www.linuxtechi.com/wp-content/uploads/2017/11/Packet-Colouring-Wireshark.jpg diff --git a/sources/tech/20171129 Inside AGL Familiar Open Source Components Ease Learning Curve.md b/sources/tech/20171129 Inside AGL Familiar Open Source Components Ease Learning Curve.md new file mode 100644 index 0000000000..9eee39888a --- /dev/null +++ b/sources/tech/20171129 Inside AGL Familiar Open Source Components Ease Learning Curve.md @@ -0,0 +1,70 @@ +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/tech/20171129 Interactive Workflows for Cpp with Jupyter.md b/sources/tech/20171129 Interactive Workflows for Cpp with Jupyter.md new file mode 100644 index 0000000000..395c901618 --- /dev/null +++ b/sources/tech/20171129 Interactive Workflows for Cpp with Jupyter.md @@ -0,0 +1,301 @@ +Interactive Workflows for C++ with Jupyter +============================================================ + +Scientists, educators and engineers not only use programming languages to build software systems, but also in interactive workflows, using the tools available to  _explore _ a problem and  _reason _ about it. + +Running some code, looking at a visualization, loading data, and running more code. Quick iteration is especially important during the exploratory phase of a project. + +For this kind of workflow, users of the C++ programming language currently have no choice but to use a heterogeneous set of tools that don’t play well with each other, making the whole process cumbersome, and difficult to reproduce. + + _We currently lack a good story for interactive computing in C++_ . + +In our opinion, this hurts the productivity of C++ developers: + +* Most of the progress made in software projects comes from incrementalism. Obstacles to fast iteration hinder progress. + +* This also makes C++ more difficult to teach. The first hours of a C++ class are rarely rewarding as the students must learn how to set up a small project before writing any code. And then, a lot more time is required before their work can result in any visual outcome. + +### Project Jupyter and Interactive Computing + + + +![](https://cdn-images-1.medium.com/max/1200/1*wOHyKy6fl3ltcBMNpCvC6Q.png) + +The goal of Project Jupyter is to provide a consistent set of tools for scientific computing and data science workflows, from the exploratory phase of the analysis to the presentation and the sharing of the results. The Jupyter stack was designed to be agnostic of the programming language, and also to allow alternative implementations of any component of the layered architecture (back-ends for programming languages, custom renderers for file types associated with Jupyter). The stack consists of + +* a low-level specification for messaging protocols, standardized file formats, + +* a reference implementation of these standards, + +* applications built on the top of these libraries: the Notebook, JupyterLab, Binder, JupyterHub + +* and visualization libraries integrated into the Notebook and JupyterLab. + +Adoption of the Jupyter ecosystem has skyrocketed in the past years, with millions of users worldwide, over a million Jupyter notebooks shared on GitHub and large-scale deployments of Jupyter in universities, companies and high-performance computing centers. + +### Jupyter and C++ + +One of the main extension points of the Jupyter stack is the  _kernel_ , the part of the infrastructure responsible for executing the user’s code. Jupyter kernels exist for [numerous programming languages][14]. + +Most Jupyter kernels are implemented in the target programming language: the reference implementation [ipykernel][15] in Python, [IJulia][16] in Julia, leading to a duplication of effort for the implementation of the protocol. A common denominator to a lot of these interpreted languages is that the interpreter generally exposes a C API, allowing the embedding into a native application. In an effort to consolidate these commonalities and save work for future kernel builders, we developed  _xeus_ . + + + +![](https://cdn-images-1.medium.com/max/1200/1*TKrPv5AvFM3NJ6a7VMu8Tw.png) + +[Xeus ][17]is a C++ implementation of the Jupyter kernel protocol. It is not a kernel itself but a library that facilitates the authoring of kernels, and other applications making use of the Jupyter kernel protocol. + +A typical kernel implementation using xeus would in fact make use of the target interpreter _ as a library._ + +There are a number of benefits of using xeus over implementing your kernel in the target language: + +* Xeus provides a complete implementation of the protocol, enabling a lot of features from the start for kernel authors, who only need to deal with the language bindings. + +* Xeus-based kernels can very easily provide a back-end for Jupyter interactive widgets. + +* Finally, xeus can be used to implement kernels for domain-specific languages such as SQL flavors. Existing approaches use a Python wrapper. With xeus, the resulting kernel won't require Python at run-time, leading to large performance benefits. + + + +![](https://cdn-images-1.medium.com/max/1200/1*Cr_cfHdrgFXHlO15qdNK7w.png) + +Interpreted C++ is already a reality at CERN with the [Cling][18]C++ interpreter in the context of the [ROOT][19] data analysis environment. + +As a first example for a kernel based on xeus, we have implemented [xeus-cling][20], a pure C++ kernel. + + + +![](https://cdn-images-1.medium.com/max/1600/1*NnjISpzZtpy5TOurg0S89A.gif) +Redirection of outputs to the Jupyter front-end, with different styling in the front-end. + +Complex features of the C++ programming language such as, polymorphism, templates, lambdas, are supported by the cling interpreter, making the C++ Jupyter notebook a great prototyping and learning platform for the C++ users. See the image below for a demonstration: + + + +![](https://cdn-images-1.medium.com/max/1600/1*lGVLY4fL1ytMfT-eWtoXkw.gif) +Features of the C++ programming language supported by the cling interpreter + +Finally, xeus-cling supports live quick-help, fetching the content on [cppreference][21] in the case of the standard library. + + + +![](https://cdn-images-1.medium.com/max/1600/1*Igegq0xBebuJV8hy0TGpfg.png) +Live help for the C++standard library in the Jupyter notebook + +> We realized that we started using the C++ kernel ourselves very early in the development of the project. For quick experimentation, or reproducing bugs. No need to set up a project with a cpp file and complicated project settings for finding the dependencies… Just write some code and hit Shift+Enter. + +Visual output can also be displayed using the rich display mechanism of the Jupyter protocol. + + + +![](https://cdn-images-1.medium.com/max/1600/1*t_9qAXtdkSXr-0tO9VvOzQ.png) +Using Jupyter's rich display mechanism to display an image inline in the notebook + + +![](https://cdn-images-1.medium.com/max/1200/1*OVfmXFAbfjUtGFXYS9fKRA.png) + +Another important feature of the Jupyter ecosystem are the [Jupyter Interactive Widgets][22]. They allow the user to build graphical interfaces and interactive data visualization inline in the Jupyter notebook. Moreover it is not just a collection of widgets, but a framework that can be built upon, to create arbitrary visual components. Popular interactive widget libraries include + +* [bqplot][1] (2-D plotting with d3.js) + +* [pythreejs][2] (3-D scene visualization with three.js) + +* [ipyleaflet][3] (maps visualization with leaflet.js) + +* [ipyvolume][4] (3-D plotting and volume rendering with three.js) + +* [nglview][5] (molecular visualization) + +Just like the rest of the Jupyter ecosystem, Jupyter interactive widgets were designed as a language-agnostic framework. Other language back-ends can be created reusing the front-end component, which can be installed separately. + +[xwidgets][23], which is still at an early stage of development, is a native C++ implementation of the Jupyter widgets protocol. It already provides an implementation for most of the widget types available in the core Jupyter widgets package. + + + +![](https://cdn-images-1.medium.com/max/1600/1*ro5Ggdstnf0DoqhTUWGq3A.gif) +C++ back-end to the Jupyter interactive widgets + +Just like with ipywidgets, one can build upon xwidgets and implement C++ back-ends for the Jupyter widget libraries listed earlier, effectively enabling them for the C++ programming language and other xeus-based kernels: xplot, xvolume, xthreejs… + + + +![](https://cdn-images-1.medium.com/max/1200/1*yCRYoJFnbtxYkYMRc9AioA.png) + +[xplot][24] is an experimental C++ back-end for the [bqplot][25] 2-D plotting library. It enables an API following the constructs of the  [_Grammar of Graphics_][26]  in C++. + +In xplot, every item in a chart is a separate object that can be modified from the back-end,  _dynamically_ . + +Changing a property of a plot item, a scale, an axis or the figure canvas itself results in the communication of an update message to the front-end, which reflects the new state of the widget visually. + + + +![](https://cdn-images-1.medium.com/max/1600/1*Mx2g3JuTG1Cfvkkv0kqtLA.gif) +Changing the data of a scatter plot dynamically to update the chart + +> Warning: the xplot and xwidgets projects are still at an early stage of development and are changing drastically at each release. + +Interactive computing environments like Jupyter are not the only missing tool in the C++ world. Two key ingredients to the success of Python as the  _lingua franca_  of data science is the existence of libraries like [NumPy][27] and [Pandas][28] at the foundation of the ecosystem. + + + +![](https://cdn-images-1.medium.com/max/1200/1*HsU43Jzp1vJZpX2g8XPJsg.png) + +[xtensor][29] is a C++ library meant for numerical analysis with multi-dimensional array expressions. + +xtensor provides + +* an extensible expression system enabling lazy NumPy-style broadcasting. + +* an API following the  _idioms_  of the C++ standard library. + +* tools to manipulate array expressions and build upon xtensor. + +xtensor exposes an API similar to that of NumPy covering a growing portion of the functionalities. A cheat sheet can be [found in the documentation][30]: + + + +![](https://cdn-images-1.medium.com/max/1600/1*PBrf5vWYC8VTq_7VUOZCpA.gif) +Scrolling the NumPy to xtensor cheat sheet + +However, xtensor internals are very different from NumPy. Using modern C++ techniques (template expressions, closure semantics) xtensor is a lazily evaluated library, avoiding the creation of temporary variables and unnecessary memory allocations, even in the case complex expressions involving broadcasting and language bindings. + +Still, from a user perspective, the combination of xtensor with the C++ notebook provides an experience very similar to that of NumPy in a Python notebook. + + + +![](https://cdn-images-1.medium.com/max/1600/1*ULFpg-ePkdUbqqDLJ9VrDw.png) +Using the xtensor array expression library in a C++ notebook + +In addition to the core library, the xtensor ecosystem has a number of other components + +* [xtensor-blas][6]: the counterpart to the numpy.linalg module. + +* [xtensor-fftw][7]: bindings to the [fftw][8] library. + +* [xtensor-io][9]: APIs to read and write various file formats (images, audio, NumPy's NPZ format). + +* [xtensor-ros][10]: bindings for ROS, the robot operating system. + +* [xtensor-python][11]: bindings for the Python programming language, allowing the use of NumPy arrays in-place, using the NumPy C API and the pybind11 library. + +* [xtensor-julia][12]: bindings for the Julia programming language, allowing the use of Julia arrays in-place, using the C API of the Julia interpreter, and the CxxWrap library. + +* [xtensor-r][13]: bindings for the R programming language, allowing the use of R arrays in-place. + +Detailing further the features of the xtensor framework would be beyond the scope of this post. + +If you are interested in trying the various notebooks presented in this post, there is no need to install anything. You can just use  _binder_ : + +![](https://cdn-images-1.medium.com/max/1200/1*9cy5Mns_I0eScsmDBjvxDQ.png) + +[The Binder project][31], which is part of Project Jupyter, enables the deployment of containerized Jupyter notebooks, from a GitHub repository together with a manifest listing the dependencies (as conda packages). + +All the notebooks in the screenshots above can be run online, by just clicking on one of the following links: + +[xtensor][32]: the C++ N-D array expression library in a C++ notebook + +[xwidgets][33]: the C++ back-end for Jupyter interactive widgets + +[xplot][34]: the C++ back-end to the bqplot 2-D plotting library for Jupyter. + + + +![](https://cdn-images-1.medium.com/max/1200/1*JwqhpMxMJppEepj7U4fV-g.png) + +[JupyterHub][35] is the multi-user infrastructure underlying open wide deployments of Jupyter like Binder but also smaller deployments for authenticated users. + +The modular architecture of JupyterHub enables a great variety of scenarios on how users are authenticated, and what service is made available to them. JupyterHub deployment for several hundreds of users have been done in various universities and institutions, including the Paris-Sud University, where the C++ kernel was also installed for the students to use. + +> In September 2017, the 350 first-year students at Paris-Sud University who took the “[Info 111: Introduction to Computer +>  Science][36]” class wrote their first lines of C++ in a Jupyter notebook. + +The use of Jupyter notebooks in the context of teaching C++ proved especially useful for the first classes, where students can focus on the syntax of the language without distractions such as compiling and linking. + +### Acknowledgements + +The software presented in this post was built upon the work of a large number of people including the Jupyter team and the Cling developers. + +We are especially grateful to [Patrick Bos ][37](who authored xtensor-fftw), Nicolas Thiéry, Min Ragan Kelley, Thomas Kluyver, Yuvi Panda, Kyle Cranmer, Axel Naumann and Vassil Vassilev. + +We thank the [DIANA/HEP][38] organization for supporting travel to CERN and encouraging the collaboration between Project Jupyter and the ROOT team. + +We are also grateful to the team at Paris-Sud University who worked on the JupyterHub deployment and the class materials, notably [Viviane Pons][39]. + +The development of xeus, xtensor, xwidgets and related packages at [QuantStack][40] is sponsored by [Bloomberg][41]. + +### About the authors (alphabetical order) + + [_Sylvain Corlay_][42] _, _ Scientific Software Developer at [QuantStack][43] + + [_Loic Gouarin_][44] _, _ Research Engineer at [Laboratoire de Mathématiques at Orsay][45] + + [_Johan Mabille_][46] _, _ Scientific Software Developer at [QuantStack][47] + + [_Wolf Vollprecht_][48] , Scientific Software Developer at [QuantStack][49] + +Thanks to [Maarten Breddels][50], [Wolf Vollprecht][51], [Brian E. Granger][52], and [Patrick Bos][53]. + +-------------------------------------------------------------------------------- + +via: https://blog.jupyter.org/interactive-workflows-for-c-with-jupyter-fe9b54227d92 + +作者:[QuantStack ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://blog.jupyter.org/@QuantStack?source=post_header_lockup +[1]:https://github.com/bloomberg/bqplot +[2]:https://github.com/jovyan/pythreejs +[3]:https://github.com/ellisonbg/ipyleaflet +[4]:https://github.com/maartenbreddels/ipyvolume +[5]:https://github.com/arose/nglview +[6]:https://github.com/QuantStack/xtensor-blas +[7]:https://github.com/egpbos/xtensor-fftw +[8]:http://www.fftw.org/ +[9]:https://github.com/QuantStack/xtensor-io +[10]:https://github.com/wolfv/xtensor_ros +[11]:https://github.com/QuantStack/xtensor-python +[12]:https://github.com/QuantStack/Xtensor.jl +[13]:https://github.com/QuantStack/xtensor-r +[14]:https://github.com/jupyter/jupyter/wiki/Jupyter-kernels +[15]:https://github.com/ipython/ipykernel +[16]:https://github.com/JuliaLang/IJulia.jl +[17]:https://github.com/QuantStack/xeus +[18]:https://root.cern.ch/cling +[19]:https://root.cern.ch/ +[20]:https://github.com/QuantStack/xeus-cling +[21]:http://en.cppreference.com/w/ +[22]:http://jupyter.org/widgets +[23]:https://github.com/QUantStack/xwidgets +[24]:https://github.com/QuantStack/xplot +[25]:https://github.com/bloomberg/bqplot +[26]:https://dl.acm.org/citation.cfm?id=1088896 +[27]:http://www.numpy.org/ +[28]:https://pandas.pydata.org/ +[29]:https://github.com/QuantStack/xtensor/ +[30]:http://xtensor.readthedocs.io/en/latest/numpy.html +[31]:https://mybinder.org/ +[32]:https://beta.mybinder.org/v2/gh/QuantStack/xtensor/0.14.0-binder2?filepath=notebooks/xtensor.ipynb +[33]:https://beta.mybinder.org/v2/gh/QuantStack/xwidgets/0.6.0-binder?filepath=notebooks/xwidgets.ipynb +[34]:https://beta.mybinder.org/v2/gh/QuantStack/xplot/0.3.0-binder?filepath=notebooks +[35]:https://github.com/jupyterhub/jupyterhub +[36]:http://nicolas.thiery.name/Enseignement/Info111/ +[37]:https://twitter.com/egpbos +[38]:http://diana-hep.org/ +[39]:https://twitter.com/pyviv +[40]:https://twitter.com/QuantStack +[41]:http://www.techatbloomberg.com/ +[42]:https://twitter.com/SylvainCorlay +[43]:https://github.com/QuantStack/ +[44]:https://twitter.com/lgouarin +[45]:https://www.math.u-psud.fr/ +[46]:https://twitter.com/johanmabille?lang=en +[47]:https://github.com/QuantStack/ +[48]:https://twitter.com/wuoulf +[49]:https://github.com/QuantStack/ +[50]:https://medium.com/@maartenbreddels?source=post_page +[51]:https://medium.com/@wolfv?source=post_page +[52]:https://medium.com/@ellisonbg?source=post_page +[53]:https://medium.com/@egpbos?source=post_page diff --git a/sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md b/sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md new file mode 100644 index 0000000000..0e38373c3f --- /dev/null +++ b/sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md @@ -0,0 +1,41 @@ +Someone Tries to Bring Back Ubuntu's Unity from the Dead as an Official Spin +============================================================ + + + +> The Ubuntu Unity remix would be supported for nine months + +Canonical's sudden decision of killing its Unity user interface after seven years affected many Ubuntu users, and it looks like someone now tries to bring it back from the dead as an unofficial spin. + +Long-time [Ubuntu][1] member Dale Beaudoin [ran a poll][2] last week on the official Ubuntu forums to take the pulse of the community and see if they are interested in an Ubuntu Unity Remix that would be released alongside Ubuntu 18.04 LTS (Bionic Beaver) next year and be supported for nine months or five years. + +Thirty people voted in the poll, with 67 percent of them opting for an LTS (Long Term Support) release of the so-called Ubuntu Unity Remix, while 33 percent voted for the 9-month supported release. It also looks like this upcoming Ubuntu Unity Spin [looks to become an official flavor][3], yet this means commitment from those developing it. + +"A recent poll voted 2/3rds in favor of Ubuntu Unity to become an LTS distribution. We should try to work this cycle assuming that it will be LTS and an official flavor," said Dale Beaudoin. "We will try and release an updated ISO once every week or 10 days using the current 18.04 daily builds of default Ubuntu Bionic Beaver as a platform." + +### Is Ubuntu Unity making a comeback? + +The last Ubuntu version to ship with Unity by default was Ubuntu 17.04 (Zesty Zapus), which will reach end of life on January 2018\. Ubuntu 17.10 (Artful Artful), the current stable release of the popular operating system, is the first to use the GNOME desktop environment by default for the main Desktop edition as Canonical CEO [announced][4] earlier this year that Unity would no longer be developed. + +However, Canonical is still offering the Unity desktop environment from the official software repositories, so if someone wants to install it, it's one click away. But the bad news is that they'll be supported up until the release of Ubuntu 18.04 LTS (Bionic Beaver) in April 2018, so the developers of the Ubuntu Unity Remix would have to continue to keep in on life support on their a separate repository. + +On the other hand, we don't believe Canonical will change their mind and accept this Ubuntu Unity Spin to become an official flavor, which would mean they failed to continue development of Unity, and now a handful of people can do it. Most probably, if interest in this Ubuntu Unity Remix won't fade away soon, it will be an unofficial spin supported by the nostalgic community. + +Question is, would you be interested in an Ubuntu Unity spin, official or not? + +-------------------------------------------------------------------------------- + +via: http://news.softpedia.com/news/someone-tries-to-bring-back-ubuntu-s-unity-from-the-dead-as-an-unofficial-spin-518778.shtml + +作者:[Marius Nestor ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://news.softpedia.com/editors/browse/marius-nestor +[1]:http://linux.softpedia.com/downloadTag/Ubuntu +[2]:https://community.ubuntu.com/t/poll-unity-7-distro-9-month-spin-or-lts-for-18-04/2066 +[3]:https://community.ubuntu.com/t/unity-maintenance-roadmap/2223 +[4]:http://news.softpedia.com/news/canonical-to-stop-developing-unity-8-ubuntu-18-04-lts-ships-with-gnome-desktop-514604.shtml +[5]:http://news.softpedia.com/editors/browse/marius-nestor diff --git a/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md b/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md new file mode 100644 index 0000000000..195b51423a --- /dev/null +++ b/sources/tech/20171130 Excellent Business Software Alternatives For Linux.md @@ -0,0 +1,116 @@ +Yoliver istranslating. +Excellent Business Software Alternatives For Linux +------- + +Many business owners choose to use Linux as the operating system for their operations for a variety of reasons. + +1. Firstly, they don't have to pay anything for the privilege, and that is a massive bonus during the early stages of a company where money is tight. + +2. Secondly, Linux is a light alternative compared to Windows and other popular operating systems available today. + +Of course, lots of entrepreneurs worry they won't have access to some of the essential software packages if they make that move. However, as you will discover throughout this post, there are plenty of similar tools that will cover all the bases. + + [![](https://4.bp.blogspot.com/-xwLuDRdB6sw/Whxx0Z5pI5I/AAAAAAAADhU/YWHID8GU9AgrXRfeTz4HcDZkG-XWZNbSgCLcBGAs/s400/4444061098_6eeaa7dc1a_z.jpg)][3] + +### Alternatives to Microsoft Word + +All company bosses will require access to a word processing tool if they want to ensure the smooth running of their operation according to + +[the latest article from Fareed Siddiqui][4] + +. You'll need that software to write business plans, letters, and many other jobs within your firm. Thankfully, there are a variety of alternatives you might like to select if you opt for the Linux operating system. Some of the most popular ones include: + +* LibreOffice Writer + +* AbiWord + +* KWord + +* LaTeX + +So, you just need to read some online reviews and then download the best word processor based on your findings. Of course, if you're not satisfied with the solution, you should take a look at some of the other ones on that list. In many instances, any of the programs mentioned above should work well. + +### Alternatives to Microsoft Excel + + [![](https://4.bp.blogspot.com/-XdS6bSLQbOU/WhxyeWZeeCI/AAAAAAAADhc/C3hGY6rgzX4m2emunot80-4URu9-aQx8wCLcBGAs/s400/28929069495_e85d2626ba_z.jpg)][5] + +You need a spreadsheet tool if you want to ensure your business doesn't get into trouble when it comes to bookkeeping and inventory control. There are specialist software packages on the market for both of those tasks, but + +[open-source alternatives][6] + +to Microsoft Excel will give you the most amount of freedom when creating your spreadsheets and editing them. While there are other packages out there, some of the best ones for Linux users include: + +* [LibreOffice Calc][1] + +* KSpread + +* Gnumeric + +Those programs work in much the same way as Microsoft Excel, and so you can use them for issues like accounting and stock control. You might also use that software to monitor employee earnings or punctuality. The possibilities are endless and only limited by your imagination. + +### Alternatives to Adobe Photoshop + + [![](https://3.bp.blogspot.com/-Id9Dm3CIXmc/WhxzGIlv3zI/AAAAAAAADho/VfIRCAbJMjMZzG2M97-uqLV9mOhqN7IWACLcBGAs/s400/32206185926_c69accfcef_z.jpg)][7] + +Company bosses require access to design programs when developing their marketing materials and creating graphics for their websites. You might also use software of that nature to come up with a new business logo at some point. Lots of entrepreneurs spend a fortune on + +[Training Connections Photoshop classes][8] + +and those available from other providers. They do that in the hope of educating their teams and getting the best results. However, people who use Linux can still benefit from that expertise if they select one of the following + +[alternatives][9] + +: + +* GIMP + +* Krita + +* Pixel + +* LightZone + +The last two suggestions on that list require a substantial investment. Still, they function in much the same way as Adobe Photoshop, and so you should manage to achieve the same quality of work. + +### Other software solutions that you'll want to consider + +Alongside those alternatives to some of the most widely-used software packages around today, business owners should take a look at the full range of products they could use with the Linux operating system. Here are some tools you might like to research and consider: + +* Inkscape - similar to Coreldraw + +* LibreOffice Base - similar to Microsoft Access + +* LibreOffice Impress - similar to Microsoft PowerPoint + +* File Roller - siThis is a contributed postmilar to WinZip + +* Linphone - similar to Skype + +There are + +[lots of other programs][10] + + you'll also want to research, and so the best solution is to use the internet to learn more. You will find lots of reviews from people who've used the software in the past, and many of them will compare the tool to its Windows or iOS alternative. So, you shouldn't have to work too hard to identify the best ones and sort the wheat from the chaff. + +Now you have all the right information; it's time to weigh all the pros and cons of Linux and work out if it's suitable for your operation. In most instances, that operating system does not place any limits on your business activities. It's just that you need to use different software compared to some of your competitors. People who use Linux tend to benefit from improved security, speed, and performance. Also, the solution gets regular updates, and so it's growing every single day. Unlike Windows and other solutions; you can customize Linux to meet your requirements. With that in mind, do not make the mistake of overlooking this fantastic system! + +-------------------------------------------------------------------------------- + +via: http://linuxblog.darkduck.com/2017/11/excellent-business-software.html + +作者:[DarkDuck][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://linuxblog.darkduck.com/ +[1]:http://linuxblog.darkduck.com/2015/08/pivot-tables-in-libreoffice-calc.html +[3]:https://4.bp.blogspot.com/-xwLuDRdB6sw/Whxx0Z5pI5I/AAAAAAAADhU/YWHID8GU9AgrXRfeTz4HcDZkG-XWZNbSgCLcBGAs/s1600/4444061098_6eeaa7dc1a_z.jpg +[4]:https://www.linkedin.com/pulse/benefits-using-microsoft-word-fareed/ +[5]:https://4.bp.blogspot.com/-XdS6bSLQbOU/WhxyeWZeeCI/AAAAAAAADhc/C3hGY6rgzX4m2emunot80-4URu9-aQx8wCLcBGAs/s1600/28929069495_e85d2626ba_z.jpg +[6]:http://linuxblog.darkduck.com/2014/03/why-open-software-and-what-are-benefits.html +[7]:https://3.bp.blogspot.com/-Id9Dm3CIXmc/WhxzGIlv3zI/AAAAAAAADho/VfIRCAbJMjMZzG2M97-uqLV9mOhqN7IWACLcBGAs/s1600/32206185926_c69accfcef_z.jpg +[8]:https://www.trainingconnection.com/photoshop-training.php +[9]:http://linuxblog.darkduck.com/2011/10/photoshop-alternatives-for-linux.html +[10]:http://www.makeuseof.com/tag/best-linux-software/ diff --git a/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md b/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md new file mode 100644 index 0000000000..2b4d2248b2 --- /dev/null +++ b/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md @@ -0,0 +1,108 @@ +Scrot: Linux command-line screen grabs made simple +============================================================ + +### Scrot is a basic, flexible tool that offers a number of handy options for taking screen captures from the Linux command line. + +![Scrot: Screen grabs made simple](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/community-penguins-osdc-lead.png?itok=BmqsAF4A "Scrot: Screen grabs made simple") +Image credits : Original photo by Rikki Endsley. [CC BY-SA 4.0][13] + +There are great tools on the Linux desktop for taking screen captures, such as [KSnapshot][14] and [Shutter][15]. Even the simple utility that comes with the GNOME desktop does a pretty good job of capturing screens. But what if you rarely need to take screen captures? Or you use a Linux distribution without a built-in capture tool, or an older computer with limited resources? + +Turn to the command line and a little utility called [Scrot][16]. It does a fine job of taking simple screen captures, and it includes a few features that might surprise you. + +### Getting started with Scrot + +More Linux resources + +* [What is Linux?][1] + +* [What are Linux containers?][2] + +* [Download Now: Linux commands cheat sheet][3] + +* [Advanced Linux commands cheat sheet][4] + +* [Our latest Linux articles][5] + +Many Linux distributions come with Scrot already installed—to check, type `which scrot`. If it isn't there, you can install Scrot using your distro's package manager. If you're willing to compile the code, grab it [from GitHub][22]. + +To take a screen capture, crack open a terminal window and type `scrot [filename]`, where `[filename]` is the name of file to which you want to save the image (for example, `desktop.png`). If you don't include a name for the file, Scrot will create one for you, such as `2017-09-24-185009_1687x938_scrot.png`. (That filename isn't as descriptive it could be, is it? That's why it's better to add one to the command.) + +Running Scrot with no options takes a screen capture of your entire desktop. If you don't want to do that, Scrot lets you focus on smaller portions of your screen. + +### Taking a screen capture of a single window + +Tell Scrot to take a screen capture of a single window by typing `scrot -u [filename]`. + +The `-u` option tells Scrot to grab the window currently in focus. That's usually the terminal window you're working in, which might not be the one you want. + +To grab another window on your desktop, type `scrot -s [filename]`. + +The `-s` option lets you do one of two things: + +* select an open window, or + +* draw a rectangle around a window or a portion of a window to capture it. + +You can also set a delay, which gives you a little more time to select the window you want to capture. To do that, type `scrot -u -d [num] [filename]`. + +The `-d` option tells Scrot to wait before grabbing the window, and `[num]` is the number of seconds to wait. Specifying `-d 5` (wait five seconds) should give you enough time to choose a window. + +### More useful options + +Scrot offers a number of additional features (most of which I never use). The ones I find most useful include: + +* `-b` also grabs the window's border + +* `-t` grabs a window and creates a thumbnail of it. This can be useful when you're posting screen captures online. + +* `-c` creates a countdown in your terminal when you use the `-d` option. + +To learn about Scrot's other options, check out the its documentation by typing `man scrot` in a terminal window, or [read it online][17]. Then start snapping images of your screen. + +It's basic, but Scrot gets the job done nicely. + +### Topics + + [Linux][23] + +### About the author + + [![That idiot Scott Nesbitt ...](https://opensource.com/sites/default/files/styles/profile_pictures/public/scottn-cropped.jpg?itok=q4T2J4Ai)][18] + + Scott Nesbitt - I'm a long-time user of free/open source software, and write various things for both fun and profit. I don't take myself too seriously and I do all of my own stunts. You can find me at these fine establishments on the web: [Twitter][7], [Mastodon][8], [GitHub][9], and... [more about Scott Nesbitt][10][More about me][11] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot + +作者:[ Scott Nesbitt  ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/scottnesbitt +[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[6]:https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot?rate=H43kUdawjR0GV9D0dCbpnmOWcqw1WekfrAI_qKo8UwI +[7]:http://www.twitter.com/ScottWNesbitt +[8]:https://mastodon.social/@scottnesbitt +[9]:https://github.com/ScottWNesbitt +[10]:https://opensource.com/users/scottnesbitt +[11]:https://opensource.com/users/scottnesbitt +[12]:https://opensource.com/user/14925/feed +[13]:https://creativecommons.org/licenses/by-sa/4.0/ +[14]:https://www.kde.org/applications/graphics/ksnapshot/ +[15]:https://launchpad.net/shutter +[16]:https://github.com/dreamer/scrot +[17]:http://manpages.ubuntu.com/manpages/precise/man1/scrot.1.html +[18]:https://opensource.com/users/scottnesbitt +[19]:https://opensource.com/users/scottnesbitt +[20]:https://opensource.com/users/scottnesbitt +[21]:https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot#comments +[22]:https://github.com/dreamer/scrot +[23]:https://opensource.com/tags/linux diff --git a/sources/tech/20171130 Search DuckDuckGo from the Command Line.md b/sources/tech/20171130 Search DuckDuckGo from the Command Line.md deleted file mode 100644 index ee451a6172..0000000000 --- a/sources/tech/20171130 Search DuckDuckGo from the Command Line.md +++ /dev/null @@ -1,103 +0,0 @@ -translating---geekpi - -# Search DuckDuckGo from the Command Line - - ![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/duckduckgo.png) -When we showed you how to [search Google from the command line][3] a lot of you to say you use [Duck Duck Go][4], the awesome privacy-focused search engine. - -Well, now there’s a tool to search DuckDuckGo from the command line. It’s called [ddgr][6] (pronounced, in my head, as  _dodger_ ) and it’s pretty neat. - -Like [Googler][7], ddgr is totally open-source and totally unofficial. Yup, the app is unaffiliated with DuckDuckGo in any way. So, should it start returning unsavoury search results for innocent terms, make sure you quack in this dev’s direction, and not the search engine’s! - -### DuckDuckGo Terminal App - -![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/ddgr-gif.gif) - -[DuckDuckGo Bangs][8] makes finding stuff on DuckDuckGo super easy (there’s even a bang for  _this_  site) and, dutifully, ddgr supports them. - -Unlike the web interface, you can specify the number of search results you would like to see per page. It’s more convenient than skimming through 30-odd search results per page. The default interface is carefully designed to use minimum space without sacrificing readability. - -`ddgr` has a number of features, including: - -* Choose number of search results to fetch - -* Support for Bash autocomplete - -* Use !bangs - -* Open URLs in a browser - -* “I’m feeling lucky” option - -* Filter by time, region, file type, etc - -* Minimal dependencies - -You can download `ddgr` for various systems direct from the Github project page: - -[Download ‘ddgr’ from Github][9] - -You can also install ddgr on Ubuntu 16.04 LTS and up from a PPA. This repo is maintained by the developer of ddgr and is recommended should you want to stay up-to-date with new releases as and when they appear. - -Do note that at the time of writing the latest version of ddgr is  _not_  in the PPA, but an older version (lacking –num support) is: - -``` -sudo add-apt-repository ppa:twodopeshaggy/jarun -``` - -``` -sudo apt-get update -``` - -### How To Use ddgr to Search DuckDuckGo from the Comand Line - -To use ddgr once you installed all you need to do is pop open your terminal emulator of choice and run: - -``` -ddgr -``` - -Next enter a search term: - -``` -search-term -``` - -To limit the number of results returned run: - -``` -ddgr --num 5 search-term -``` - -To instantly open the first matching result for a search term in your browser run: - -``` -ddgr -j search-term -``` - -You can pass arguments and flags to narrow down your search. To see a comprehensive list inside the terminal run: - -``` -ddgr -h -``` - --------------------------------------------------------------------------------- - -via: http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app - -作者:[JOEY SNEDDON ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://plus.google.com/117485690627814051450/?rel=author -[1]:https://plus.google.com/117485690627814051450/?rel=author -[2]:http://www.omgubuntu.co.uk/category/download -[3]:http://www.omgubuntu.co.uk/2017/08/search-google-from-the-command-line -[4]:http://duckduckgo.com/ -[5]:http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app -[6]:https://github.com/jarun/ddgr -[7]:https://github.com/jarun/googler -[8]:https://duckduckgo.com/bang -[9]:https://github.com/jarun/ddgr/releases/tag/v1.1 diff --git a/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md b/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md new file mode 100644 index 0000000000..46afe9b893 --- /dev/null +++ b/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md @@ -0,0 +1,156 @@ +translating---geekpi + +Undistract-me : Get Notification When Long Running Terminal Commands Complete +============================================================ + +by [sk][2] · November 30, 2017 + +![Undistract-me](https://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2-720x340.png) + +A while ago, we published how to [get notification when a Terminal activity is done][3]. Today, I found out a similar utility called “undistract-me” that notifies you when long running terminal commands complete. Picture this scenario. You run a command that takes a while to finish. In the mean time, you check your facebook and get so involved in it. After a while, you remembered that you ran a command few minutes ago. You go back to the Terminal and notice that the command has already finished. But you have no idea when the command is completed. Have you ever been in this situation? I bet most of you were in this situation many times. This is where “undistract-me” comes in help. You don’t need to constantly check the terminal to see if a command is completed or not. Undistract-me utility will notify you when a long running command is completed. It will work on Arch Linux, Debian, Ubuntu and other Ubuntu-derivatives. + +#### Installing Undistract-me + +Undistract-me is available in the default repositories of Debian and its variants such as Ubuntu. All you have to do is to run the following command to install it. + +``` +sudo apt-get install undistract-me +``` + +The Arch Linux users can install it from AUR using any helper programs. + +Using [Pacaur][4]: + +``` +pacaur -S undistract-me-git +``` + +Using [Packer][5]: + +``` +packer -S undistract-me-git +``` + +Using [Yaourt][6]: + +``` +yaourt -S undistract-me-git +``` + +Then, run the following command to add “undistract-me” to your Bash. + +``` +echo 'source /etc/profile.d/undistract-me.sh' >> ~/.bashrc +``` + +Alternatively you can run this command to add it to your Bash: + +``` +echo "source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install" >> .bashrc +``` + +If you are in Zsh shell, run this command: + +``` +echo "source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install" >> .zshrc +``` + +Finally update the changes: + +For Bash: + +``` +source ~/.bashrc +``` + +For Zsh: + +``` +source ~/.zshrc +``` + +#### Configure Undistract-me + +By default, Undistract-me will consider any command that takes more than 10 seconds to complete as a long-running command. You can change this time interval by editing /usr/share/undistract-me/long-running.bash file. + +``` +sudo nano /usr/share/undistract-me/long-running.bash +``` + +Find “LONG_RUNNING_COMMAND_TIMEOUT” variable and change the default value (10 seconds) to something else of your choice. + + [![](http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-1.png)][7] + +Save and close the file. Do not forget to update the changes: + +``` +source ~/.bashrc +``` + +Also, you can disable notifications for particular commands. To do so, find the “LONG_RUNNING_IGNORE_LIST” variable and add the commands space-separated like below. + +By default, the notification will only show if the active window is not the window the command is running in. That means, it will notify you only if the command is running in the background Terminal window. If the command is running in active window Terminal, you will not be notified. If you want undistract-me to send notifications either the Terminal window is visible or in the background, you can set IGNORE_WINDOW_CHECK to 1 to skip the window check. + +The other cool feature of Undistract-me is you can set audio notification along with visual notification when a command is done. By default, it will only send a visual notification. You can change this behavior by setting the variable UDM_PLAY_SOUND to a non-zero integer on the command line. However, your Ubuntu system should have pulseaudio-utils and sound-theme-freedesktop utilities installed to enable this functionality. + +Please remember that you need to run the following command to update the changes made. + +For Bash: + +``` +source ~/.bashrc +``` + +For Zsh: + +``` +source ~/.zshrc +``` + +It is time to verify if this really works. + +#### Get Notification When Long Running Terminal Commands Complete + +Now, run any command that takes longer than 10 seconds or the time duration you defined in Undistract-me script. + +I ran the following command on my Arch Linux desktop. + +``` +sudo pacman -Sy +``` + +This command took 32 seconds to complete. After the completion of the above command, I got the following notification. + + [![](http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2.png)][8] + +Please remember Undistract-me script notifies you only if the given command took more than 10 seconds to complete. If the command is completed in less than 10 seconds, you will not be notified. Of course, you can change this time interval settings as I described in the Configuration section above. + +I find this tool very useful. It helped me to get back to the business after I completely lost in some other tasks. I hope this tool will be helpful to you too. + +More good stuffs to come. Stay tuned! + +Cheers! + +Resource: + +* [Undistract-me GitHub Repository][1] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/undistract-get-notification-long-running-terminal-commands-complete/ + +作者:[sk][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://github.com/jml/undistract-me +[2]:https://www.ostechnix.com/author/sk/ +[3]:https://www.ostechnix.com/get-notification-terminal-task-done/ +[4]:https://www.ostechnix.com/install-pacaur-arch-linux/ +[5]:https://www.ostechnix.com/install-packer-arch-linux-2/ +[6]:https://www.ostechnix.com/install-yaourt-arch-linux/ +[7]:http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-1.png +[8]:http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2.png diff --git a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md new file mode 100644 index 0000000000..3a2c20ad52 --- /dev/null +++ b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md @@ -0,0 +1,135 @@ + + translating by HardworkFish + +Wake up and Shut Down Linux Automatically +============================================================ + +### [banner.jpg][1] + +![time keeper](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/banner.jpg?itok=zItspoSb) + +Learn how to configure your Linux computers to watch the time for you, then wake up and shut down automatically. + +[Creative Commons Attribution][6][The Observatory at Delhi][7] + +Don't be a watt-waster. If your computers don't need to be on then shut them down. For convenience and nerd creds, you can configure your Linux computers to wake up and shut down automatically. + +### Precious Uptimes + +Some computers need to be on all the time, which is fine as long as it's not about satisfying an uptime compulsion. Some people are very proud of their lengthy uptimes, and now that we have kernel hot-patching that leaves only hardware failures requiring shutdowns. I think it's better to be practical. Save electricity as well as wear on your moving parts, and shut them down when they're not needed. For example, you can wake up a backup server at a scheduled time, run your backups, and then shut it down until it's time for the next backup. Or, you can configure your Internet gateway to be on only at certain times. Anything that doesn't need to be on all the time can be configured to turn on, do a job, and then shut down. + +### Sleepies + +For computers that don't need to be on all the time, good old cron will shut them down reliably. Use either root's cron, or /etc/crontab. This example creates a root cron job to shut down every night at 11:15 p.m. + +``` +# crontab -e -u root +# m h dom mon dow command +15 23 * * * /sbin/shutdown -h now +``` + +``` +15 23 * * 1-5 /sbin/shutdown -h now +``` + +You may also use /etc/crontab, which is fast and easy, and everything is in one file. You have to specify the user: + +``` +15 23 * * 1-5 root shutdown -h now +``` + +Auto-wakeups are very cool; most of my SUSE colleagues are in Nuremberg, so I am crawling out of bed at 5 a.m. to have a few hours of overlap with their schedules. My work computer turns itself on at 5:30 a.m., and then all I have to do is drag my coffee and myself to my desk to start work. It might not seem like pressing a power button is a big deal, but at that time of day every little thing looms large. + +Waking up your Linux PC can be less reliable than shutting it down, so you may want to try different methods. You can use wakeonlan, RTC wakeups, or your PC's BIOS to set scheduled wakeups. These all work because, when you power off your computer, it's not really all the way off; it is in an extremely low-power state and can receive and respond to signals. You need to use the power supply switch to turn it off completely. + +### BIOS Wakeup + +A BIOS wakeup is the most reliable. My system BIOS has an easy-to-use wakeup scheduler (Figure 1). Chances are yours does, too. Easy peasy. + +### [fig-1.png][2] + +![wake up](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_11.png?itok=8qAeqo1I) + +Figure 1: My system BIOS has an easy-to-use wakeup scheduler. + +[Used with permission][8] + +### wakeonlan + +wakeonlan is the next most reliable method. This requires sending a signal from a second computer to the computer you want to power on. You could use an Arduino or Raspberry Pi to send the wakeup signal, a Linux-based router, or any Linux PC. First, look in your system BIOS to see if wakeonlan is supported -- which it should be -- and then enable it, as it should be disabled by default. + +Then, you'll need an Ethernet network adapter that supports wakeonlan; wireless adapters won't work. You'll need to verify that your Ethernet card supports wakeonlan: + +``` +# ethtool eth0 | grep -i wake-on + Supports Wake-on: pumbg + Wake-on: g +``` + +* d -- all wake ups disabled + +* p -- wake up on physical activity + +* u -- wake up on unicast messages + +* m -- wake up on multicast messages + +* b -- wake up on broadcast messages + +* a -- wake up on ARP messages + +* g -- wake up on magic packet + +* s -- set the Secure On password for the magic packet + +man ethtool is not clear on what the p switch does; it suggests that any signal will cause a wake up. In my testing, however, it doesn't do that. The one that must be enabled is g -- wake up on magic packet, and the Wake-on line shows that it is already enabled. If it is not enabled, you can use ethtool to enable it, using your own device name, of course: + +``` +# ethtool -s eth0 wol g +``` + +``` +@reboot /usr/bin/ethtool -s eth0 wol g +``` + +### [fig-2.png][3] + +![wakeonlan](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-2_7.png?itok=XQAwmHoQ) + +Figure 2: Enable Wake on LAN. + +[Used with permission][9] + +Another option is recent Network Manager versions have a nice little checkbox to enable wakeonlan (Figure 2). + +There is a field for setting a password, but if your network interface doesn't support the Secure On password, it won't work. + +Now you need to configure a second PC to send the wakeup signal. You don't need root privileges, so create a cron job for your user. You need the MAC address of the network interface on the machine you're waking up: + +``` +30 08 * * * /usr/bin/wakeonlan D0:50:99:82:E7:2B +``` + +Using the real-time clock for wakeups is the least reliable method. Check out [Wake Up Linux With an RTC Alarm Clock][4]; this is a bit outdated as most distros use systemd now. Come back next week to learn more about updated ways to use RTC wakeups. + +Learn more about Linux through the free ["Introduction to Linux" ][5]course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2017/11/wake-and-shut-down-linux-automatically + +作者:[Carla Schroder] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://www.linux.com/files/images/bannerjpg +[2]:https://www.linux.com/files/images/fig-1png-11 +[3]:https://www.linux.com/files/images/fig-2png-7 +[4]:https://www.linux.com/learn/wake-linux-rtc-alarm-clock +[5]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux +[6]:https://www.linux.com/licenses/category/creative-commons-attribution +[7]:http://www.columbia.edu/itc/mealac/pritchett/00routesdata/1700_1799/jaipur/delhijantarearly/delhijantarearly.html +[8]:https://www.linux.com/licenses/category/used-permission +[9]:https://www.linux.com/licenses/category/used-permission diff --git a/sources/tech/20171201 Fedora Classroom Session: Ansible 101.md b/sources/tech/20171201 Fedora Classroom Session: Ansible 101.md new file mode 100644 index 0000000000..a74b196663 --- /dev/null +++ b/sources/tech/20171201 Fedora Classroom Session: Ansible 101.md @@ -0,0 +1,71 @@ +### [Fedora Classroom Session: Ansible 101][2] + +### By Sachin S Kamath + +![](https://fedoramagazine.org/wp-content/uploads/2017/07/fedora-classroom-945x400.jpg) + +Fedora Classroom sessions continue this week with an Ansible session. The general schedule for sessions appears [on the wiki][3]. You can also find [resources and recordings from previous sessions][4] there. Here are details about this week’s session on [Thursday, 30th November at 1600 UTC][5]. That link allows you to convert the time to your timezone. + +### Topic: Ansible 101 + +As the Ansible [documentation][6] explains, Ansible is an IT automation tool. It’s primarily used to configure systems, deploy software, and orchestrate more advanced IT tasks. Examples include continuous deployments or zero downtime rolling updates. + +This Classroom session covers the topics listed below: + +1. Introduction to SSH + +2. Understanding different terminologies + +3. Introduction to Ansible + +4. Ansible installation and setup + +5. Establishing password-less connection + +6. Ad-hoc commands + +7. Managing inventory + +8. Playbooks examples + +There will also be a follow-up Ansible 102 session later. That session will cover complex playbooks, roles, dynamic inventory files, control flow and Galaxy. + +### Instructors + +We have two experienced instructors handling this session. + +[Geoffrey Marr][7], also known by his IRC name as “coremodule,” is a Red Hat employee and Fedora contributor with a background in Linux and cloud technologies. While working, he spends his time lurking in the [Fedora QA][8] wiki and test pages. Away from work, he enjoys RaspberryPi projects, especially those focusing on software-defined radio. + +[Vipul Siddharth][9] is an intern at Red Hat who also works on Fedora. He loves to contribute to open source and seeks opportunities to spread the word of free and open source software. + +### Joining the session + +This session takes place on [BlueJeans][10]. The following information will help you join the session: + +* URL: [https://bluejeans.com/3466040121][1] + +* Meeting ID (for Desktop App): 3466040121 + +We hope you attend, learn from, and enjoy this session! If you have any feedback about the sessions, have ideas for a new one or want to host a session, please feel free to comment on this post or edit the [Classroom wiki page][11]. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/fedora-classroom-session-ansible-101/ + +作者:[Sachin S Kamath] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://bluejeans.com/3466040121 +[2]:https://fedoramagazine.org/fedora-classroom-session-ansible-101/ +[3]:https://fedoraproject.org/wiki/Classroom +[4]:https://fedoraproject.org/wiki/Classroom#Previous_Sessions +[5]:https://www.timeanddate.com/worldclock/fixedtime.html?msg=Fedora+Classroom+-+Ansible+101&iso=20171130T16&p1=%3A +[6]:http://docs.ansible.com/ansible/latest/index.html +[7]:https://fedoraproject.org/wiki/User:Coremodule +[8]:https://fedoraproject.org/wiki/QA +[9]:https://fedoraproject.org/wiki/User:Siddharthvipul1 +[10]:https://www.bluejeans.com/downloads +[11]:https://fedoraproject.org/wiki/Classroom diff --git a/sources/tech/20171201 How to Manage Users with Groups in Linux.md b/sources/tech/20171201 How to Manage Users with Groups in Linux.md new file mode 100644 index 0000000000..35350c819f --- /dev/null +++ b/sources/tech/20171201 How to Manage Users with Groups in Linux.md @@ -0,0 +1,168 @@ +translating---imquanquan + +How to Manage Users with Groups in Linux +============================================================ + +### [group-of-people-1645356_1920.jpg][1] + +![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/group-of-people-1645356_1920.jpg?itok=rJlAxBSV) + +Learn how to work with users, via groups and access control lists in this tutorial. + +[Creative Commons Zero][4] + +Pixabay + +When you administer a Linux machine that houses multiple users, there might be times when you need to take more control over those users than the basic user tools offer. This idea comes to the fore especially when you need to manage permissions for certain users. Say, for example, you have a directory that needs to be accessed with read/write permissions by one group of users and only read permissions for another group. With Linux, this is entirely possible. To make this happen, however, you must first understand how to work with users, via groups and access control lists (ACLs). + +We’ll start from the beginning with users and work our way to the more complex ACLs. Everything you need to make this happen will be included in your Linux distribution of choice. We won’t touch on the basics of users, as the focus on this article is about groups. + +For the purpose of this piece, I’m going to assume the following: + +You need to create two users with usernames: + +* olivia + +* nathan + +You need to create two groups: + +* readers + +* editors + +Olivia needs to be a member of the group editors, while nathan needs to be a member of the group readers. The group readers needs to only have read permission to the directory /DATA, whereas the group editors needs to have both read and write permission to the /DATA directory. This, of course, is very minimal, but it will give you the basic information you need to expand the tasks to fit your much larger needs. + +I’ll be demonstrating on the Ubuntu 16.04 Server platform. The commands will be universal—the only difference would be if your distribution of choice doesn’t make use of sudo. If this is the case, you’ll have to first su to the root user to issue the commands that require sudo in the demonstrations. + +### Creating the users + +The first thing we need to do is create the two users for our experiment. User creation is handled with the useradd command. Instead of just simply creating the users we need to create them both with their own home directories and then give them passwords. + +The first thing we do is create the users. To do this, issue the commands: + +``` +sudo useradd -m olivia + +sudo useradd -m nathan +``` + +Next each user must have a password. To add passwords into the mix, you’d issue the following commands: + +``` +sudo passwd olivia + +sudo passwd nathan +``` + +That’s it, your users are created. + +### Creating groups and adding users + +Now we’re going to create the groups readers and editors and then add users to them. The commands to create our groups are: + +``` +addgroup readers + +addgroup editors +``` + +### [groups_1.jpg][2] + +![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/groups_1.jpg?itok=BKwL89BB) + +Figure 1: Our new groups ready to be used. + +[Used with permission][5] + +With our groups created, we need to add our users. We’ll add user nathan to group readers with the command: + +``` +sudo usermod -a -G readers nathan +``` + +``` +sudo usermod -a -G editors olivia +``` + +### Giving groups permissions to directories + +Let’s say you have the directory /READERS and you need to allow all members of the readers group access to that directory. First, change the group of the folder with the command: + +``` +sudo chown -R :readers /READERS +``` + +``` +sudo chmod -R g-w /READERS +``` + +``` +sudo chmod -R o-x /READERS +``` + +Let’s say you have the directory /EDITORS and you need to give members of the editors group read and write permission to its contents. To do that, the following command would be necessary: + +``` +sudo chown -R :editors /EDITORS + +sudo chmod -R g+w /EDITORS + +sudo chmod -R o-x /EDITORS +``` + +The problem with using this method is you can only add one group to a directory at a time. This is where access control lists come in handy. + +### Using access control lists + +Now, let’s get tricky. Say you have a single folder—/DATA—and you want to give members of the readers group read permission and members of the group editors read/write permissions. To do that, you must take advantage of the setfacl command. The setfacl command sets file access control lists for files and folders. + +The structure of this command looks like this: + +``` +setfacl OPTION X:NAME:Y /DIRECTORY +``` + +``` +sudo setfacl -m g:readers:rx -R /DATA +``` + +To give members of the editors group read/write permissions (while retaining read permissions for the readers group), we’d issue the command; + +``` +sudo setfacl -m g:editors:rwx -R /DATA +``` + +### All the control you need + +And there you have it. You can now add members to groups and control those groups’ access to various directories with all the power and flexibility you need. To read more about the above tools, issue the commands: + +* man usradd + +* man addgroup + +* man usermod + +* man sefacl + +* man chown + +* man chmod + +Learn more about Linux through the free ["Introduction to Linux" ][3]course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2017/12/how-manage-users-groups-linux + +作者:[Jack Wallen ] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://www.linux.com/files/images/group-people-16453561920jpg +[2]:https://www.linux.com/files/images/groups1jpg +[3]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux +[4]:https://www.linux.com/licenses/category/creative-commons-zero +[5]:https://www.linux.com/licenses/category/used-permission diff --git a/sources/tech/20171201 How to find a publisher for your tech book.md b/sources/tech/20171201 How to find a publisher for your tech book.md new file mode 100644 index 0000000000..76dc8112ca --- /dev/null +++ b/sources/tech/20171201 How to find a publisher for your tech book.md @@ -0,0 +1,76 @@ +How to find a publisher for your tech book +============================================================ + +### Writing a technical book takes more than a good idea. You need to know a bit about how the publishing industry works. + + +![How to find a publisher for your tech book](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDUCATION_colorbooks.png?itok=vNhsYYyC "How to find a publisher for your tech book") +Image by : opensource.com + +You've got an idea for a technical book—congratulations! Like a hiking the Appalachian trail, or learning to cook a soufflé, writing a book is one of those things that people talk about, but never take beyond the idea stage. That makes sense, because the failure rate is pretty high. Making it real involves putting your idea in front of a publisher, and finding out whether it's good enough to become a book. That step is scary enough, but the lack of information about how to do it complicates matters. + +If you want to work with a traditional publisher, you'll need to get your book in front of them and hopefully start on the path to publication. I'm the Managing Editor at the [Pragmatic Bookshelf][4], so I see proposals all the time, as well as helping authors to craft good ones. Some are good, others are bad, but I often see proposals that just aren't right for Pragmatic. I'll help you with the process of finding the right publisher, and how to get your idea noticed. + +### Identify your target + +Your first step is to figure out which publisher is the a good fit for your idea. To start, think about the publishers that you buy books from, and that you enjoy. The odds are pretty good that your book will appeal to people like you, so starting with your favorites makes for a pretty good short list. If you don't have much of a book collection, you can visit a bookstore, or take a look on Amazon. Make a list of a handful of publishers that you personally like to start with. + +Next, winnow your prospects. Although most technical publishers look alike from a distance, they often have distinctive audiences. Some publishers go for broadly popular topics, such as C++ or Java. Your book on Elixir may not be a good fit for that publisher. If your prospective book is about teaching programming to kids, you probably don't want to go with the traditional academic publisher. + +Once you've identified a few targets, do some more research into the publishers' catalogs, either on their own site, or on Amazon. See what books they have that are similar to your idea. If they have a book that's identical, or nearly so, you'll have a tough time convincing them to sign yours. That doesn't necessarily mean you should drop that publisher from your list. You can make some changes to your proposal to differentiate it from the existing book: target a different audience, or a different skill level. Maybe the existing book is outdated, and you could focus on new approaches to the technology. Make your proposal into a book that complements the existing one, rather than competes. + +If your target publisher has no books that are similar, that can be a good sign, or a very bad one. Sometimes publishers choose not to publish on specific technologies, either because they don't believe their audience is interested, or they've had trouble with that technology in the past. New languages and libraries pop up all the time, and publishers have to make informed guesses about which will appeal to their readers. Their assessment may not be the same as yours. Their decision might be final, or they might be waiting for the right proposal. The only way to know is to propose and find out. + +### Work your network + +Identifying a publisher is the first step; now you need to make contact. Unfortunately, publishing is still about  _who_  you know, more than  _what_  you know. The person you want to know is an  _acquisitions editor,_  the editor whose job is to find new markets, authors, and proposals. If you know someone who has connections with a publisher, ask for an introduction to an acquisitions editor. These editors often specialize in particular subject areas, particularly at larger publishers, but you don't need to find the right one yourself. They're usually happy to connect you with the correct person. + +Sometimes you can find an acquisitions editor at a technical conference, especially one where the publisher is a sponsor, and has a booth. Even if there's not an acquisitions editor on site at the time, the staff at the booth can put you in touch with one. If conferences aren't your thing, you'll need to work your network to get an introduction. Use LinkedIn, or your informal contacts, to get in touch with an editor. + +For smaller publishers, you may find acquisitions editors listed on the company website, with contact information if you're lucky. If not, search for the publisher's name on Twitter, and see if you can turn up their editors. You might be nervous about trying to reach out to a stranger over social media to show them your book, but don't worry about it. Making contact is what acquisitions editors do. The worst-case result is they ignore you. + +Once you've made contact, the acquisitions editor will assist you with the next steps. They may have some feedback on your proposal right away, or they may want you to flesh it out according to their guidelines before they'll consider it. After you've put in the effort to find an acquisitions editor, listen to their advice. They know their system better than you do. + +### If all else fails + +If you can't find an acquisitions editor to contact, the publisher almost certainly has a blind proposal alias, usually of the form `proposals@[publisher].com`. Check the web site for instructions on what to send to a proposal alias; some publishers have specific requirements. Follow these instructions. If you don't, you have a good chance of your proposal getting thrown out before anybody looks at it. If you have questions, or aren't sure what the publisher wants, you'll need to try again to find an editor to talk to, because the proposal alias is not the place to get questions answered. Put together what they've asked for (which is a topic for a separate article), send it in, and hope for the best. + +### And ... wait + +No matter how you've gotten in touch with a publisher, you'll probably have to wait. If you submitted to the proposals alias, it's going to take a while before somebody does anything with that proposal, especially at a larger company. Even if you've found an acquisitions editor to work with, you're probably one of many prospects she's working with simultaneously, so you might not get rapid responses. Almost all publishers have a committee that decides on which proposals to accept, so even if your proposal is awesome and ready to go, you'll still need to wait for the committee to meet and discuss it. You might be waiting several weeks, or even a month before you hear anything. + +After a couple of weeks, it's fine to check back in with the editor to see if they need any more information. You want to be polite in this e-mail; if they haven't answered because they're swamped with proposals, being pushy isn't going to get you to the front of the line. It's possible that some publishers will never respond at all instead of sending a rejection notice, but that's uncommon. There's not a lot to do at this point other than be patient. Of course, if it's been months and nobody's returning your e-mails, you're free to approach a different publisher or consider self-publishing. + +### Good luck + +If this process seems somewhat scattered and unscientific, you're right; it is. Getting published depends on being in the right place, at the right time, talking to the right person, and hoping they're in the right mood. You can't control all of those variables, but having a better knowledge of how the industry works, and what publishers are looking for, can help you optimize the ones you can control. + +Finding a publisher is one step in a lengthy process. You need to refine your idea and create the proposal, as well as other considerations. At SeaGL this year [I presented][5] an introduction to the entire process. Check out [the video][6] for more detailed information. + +### About the author + + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/portrait.jpg?itok=b77dlNC4)][7] + + Brian MacDonald - Brian MacDonald is Managing Editor at the Pragmatic Bookshelf. Over the last 20 years in tech publishing, he's been an editor, author, and occasional speaker and trainer. He currently spends a lot of his time talking to new authors about how they can best present their ideas. You can follow him on Twitter at @bmac_editor.[More about me][2] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/12/how-find-publisher-your-book + +作者:[Brian MacDonald ][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/bmacdonald +[1]:https://opensource.com/article/17/12/how-find-publisher-your-book?rate=o42yhdS44MUaykAIRLB3O24FvfWxAxBKa5WAWSnSY0s +[2]:https://opensource.com/users/bmacdonald +[3]:https://opensource.com/user/190176/feed +[4]:https://pragprog.com/ +[5]:https://archive.org/details/SeaGL2017WritingTheNextGreatTechBook +[6]:https://archive.org/details/SeaGL2017WritingTheNextGreatTechBook +[7]:https://opensource.com/users/bmacdonald +[8]:https://opensource.com/users/bmacdonald +[9]:https://opensource.com/users/bmacdonald +[10]:https://opensource.com/article/17/12/how-find-publisher-your-book#comments diff --git a/sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md b/sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md new file mode 100644 index 0000000000..b0f8e72018 --- /dev/null +++ b/sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md @@ -0,0 +1,160 @@ +Randomize your WiFi MAC address on Ubuntu 16.04 +============================================================ + + _Your device’s MAC address can be used to track you across the WiFi networks you connect to. That data can be shared and sold, and often identifies you as an individual. It’s possible to limit this tracking by using pseudo-random MAC addresses._ + +![A captive portal screen for a hotel allowing you to log in with social media for an hour of free WiFi](https://www.paulfurley.com/img/captive-portal-our-hotel.gif) + + _Image courtesy of [Cloudessa][4]_ + +Every network device like a WiFi or Ethernet card has a unique identifier called a MAC address, for example `b4:b6:76:31:8c:ff`. It’s how networking works: any time you connect to a WiFi network, the router uses that address to send and receive packets to your machine and distinguish it from other devices in the area. + +The snag with this design is that your unique, unchanging MAC address is just perfect for tracking you. Logged into Starbucks WiFi? Noted. London Underground? Logged. + +If you’ve ever put your real name into one of those Craptive Portals on a WiFi network you’ve now tied your identity to that MAC address. Didn’t read the terms and conditions? You might assume that free airport WiFi is subsidised by flogging ‘customer analytics’ (your personal information) to hotels, restaurant chains and whomever else wants to know about you. + +I don’t subscribe to being tracked and sold by mega-corps, so I spent a few hours hacking a solution. + +### MAC addresses don’t need to stay the same + +Fortunately, it’s possible to spoof your MAC address to a random one without fundamentally breaking networking. + +I wanted to randomize my MAC address, but with three particular caveats: + +1. The MAC should be different across different networks. This means Starbucks WiFi sees a different MAC from London Underground, preventing linking my identity across different providers. + +2. The MAC should change regularly to prevent a network knowing that I’m the same person who walked past 75 times over the last year. + +3. The MAC stays the same throughout each working day. When the MAC address changes, most networks will kick you off, and those with Craptive Portals will usually make you sign in again - annoying. + +### Manipulating NetworkManager + +My first attempt of using the `macchanger` tool was unsuccessful as NetworkManager would override the MAC address according to its own configuration. + +I learned that NetworkManager 1.4.1+ can do MAC address randomization right out the box. If you’re using Ubuntu 17.04 upwards, you can get most of the way with [this config file][7]. You can’t quite achieve all three of my requirements (you must choose  _random_ or  _stable_  but it seems you can’t do  _stable-for-one-day_ ). + +Since I’m sticking with Ubuntu 16.04 which ships with NetworkManager 1.2, I couldn’t make use of the new functionality. Supposedly there is some randomization support but I failed to actually make it work, so I scripted up a solution instead. + +Fortunately NetworkManager 1.2 does allow for spoofing your MAC address. You can see this in the ‘Edit connections’ dialog for a given network: + +![Screenshot of NetworkManager's edit connection dialog, showing a text entry for a cloned mac address](https://www.paulfurley.com/img/network-manager-cloned-mac-address.png) + +NetworkManager also supports hooks - any script placed in `/etc/NetworkManager/dispatcher.d/pre-up.d/` is run before a connection is brought up. + +### Assigning pseudo-random MAC addresses + +To recap, I wanted to generate random MAC addresses based on the  _network_  and the  _date_ . We can use the NetworkManager command line, nmcli, to show a full list of networks: + +``` +> nmcli connection +NAME UUID TYPE DEVICE +Gladstone Guest 618545ca-d81a-11e7-a2a4-271245e11a45 802-11-wireless wlp1s0 +DoESDinky 6e47c080-d81a-11e7-9921-87bc56777256 802-11-wireless -- +PublicWiFi 79282c10-d81a-11e7-87cb-6341829c2a54 802-11-wireless -- +virgintrainswifi 7d0c57de-d81a-11e7-9bae-5be89b161d22 802-11-wireless -- + +``` + +Since each network has a unique identifier, to achieve my scheme I just concatenated the UUID with today’s date and hashed the result: + +``` + +# eg 618545ca-d81a-11e7-a2a4-271245e11a45-2017-12-03 + +> echo -n "${UUID}-$(date +%F)" | md5sum + +53594de990e92f9b914a723208f22b3f - + +``` + +That produced bytes which can be substituted in for the last octets of the MAC address. + +Note that the first byte `02` signifies the address is [locally administered][8]. Real, burned-in MAC addresses start with 3 bytes designing their manufacturer, for example `b4:b6:76` for Intel. + +It’s possible that some routers may reject locally administered MACs but I haven’t encountered that yet. + +On every connection up, the script calls `nmcli` to set the spoofed MAC address for every connection: + +![A terminal window show a number of nmcli command line calls](https://www.paulfurley.com/img/terminal-window-nmcli-commands.png) + +As a final check, if I look at `ifconfig` I can see that the `HWaddr` is the spoofed one, not my real MAC address: + +``` +> ifconfig +wlp1s0 Link encap:Ethernet HWaddr b4:b6:76:45:64:4d + inet addr:192.168.0.86 Bcast:192.168.0.255 Mask:255.255.255.0 + inet6 addr: fe80::648c:aff2:9a9d:764/64 Scope:Link + UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 + RX packets:12107812 errors:0 dropped:2 overruns:0 frame:0 + TX packets:18332141 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:1000 + RX bytes:11627977017 (11.6 GB) TX bytes:20700627733 (20.7 GB) + +``` + +The full script is [available on Github][9]. + +``` +#!/bin/sh + +# /etc/NetworkManager/dispatcher.d/pre-up.d/randomize-mac-addresses + +# Configure every saved WiFi connection in NetworkManager with a spoofed MAC +# address, seeded from the UUID of the connection and the date eg: +# 'c31bbcc4-d6ad-11e7-9a5a-e7e1491a7e20-2017-11-20' + +# This makes your MAC impossible(?) to track across WiFi providers, and +# for one provider to track across days. + +# For craptive portals that authenticate based on MAC, you might want to +# automate logging in :) + +# Note that NetworkManager >= 1.4.1 (Ubuntu 17.04+) can do something similar +# automatically. + +export PATH=$PATH:/usr/bin:/bin + +LOG_FILE=/var/log/randomize-mac-addresses + +echo "$(date): $*" > ${LOG_FILE} + +WIFI_UUIDS=$(nmcli --fields type,uuid connection show |grep 802-11-wireless |cut '-d ' -f3) + +for UUID in ${WIFI_UUIDS} +do + UUID_DAILY_HASH=$(echo "${UUID}-$(date +F)" | md5sum) + + RANDOM_MAC="02:$(echo -n ${UUID_DAILY_HASH} | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5/')" + + CMD="nmcli connection modify ${UUID} wifi.cloned-mac-address ${RANDOM_MAC}" + + echo "$CMD" >> ${LOG_FILE} + $CMD & +done + +wait +``` +Enjoy! + + _Update: [Use locally administered MAC addresses][5] to avoid clashing with real Intel ones. Thanks [@_fink][6]_ + +-------------------------------------------------------------------------------- + +via: https://www.paulfurley.com/randomize-your-wifi-mac-address-on-ubuntu-1604-xenial/ + +作者:[Paul M Furley ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.paulfurley.com/ +[1]:https://gist.github.com/paulfurley/46e0547ce5c5ea7eabeaef50dbacef3f/raw/5f02fc8f6ff7fca5bca6ee4913c63bf6de15abca/randomize-mac-addresses +[2]:https://gist.github.com/paulfurley/46e0547ce5c5ea7eabeaef50dbacef3f#file-randomize-mac-addresses +[3]:https://github.com/ +[4]:http://cloudessa.com/products/cloudessa-aaa-and-captive-portal-cloud-service/ +[5]:https://gist.github.com/paulfurley/46e0547ce5c5ea7eabeaef50dbacef3f/revisions#diff-824d510864d58c07df01102a8f53faef +[6]:https://twitter.com/fink_/status/937305600005943296 +[7]:https://gist.github.com/paulfurley/978d4e2e0cceb41d67d017a668106c53/ +[8]:https://en.wikipedia.org/wiki/MAC_address#Universal_vs._local +[9]:https://gist.github.com/paulfurley/46e0547ce5c5ea7eabeaef50dbacef3f diff --git a/sources/tech/20171202 Easily control delivery of your Python applications to millions of Linux users with Snapcraft.md b/sources/tech/20171202 Easily control delivery of your Python applications to millions of Linux users with Snapcraft.md new file mode 100644 index 0000000000..dbdebf63e3 --- /dev/null +++ b/sources/tech/20171202 Easily control delivery of your Python applications to millions of Linux users with Snapcraft.md @@ -0,0 +1,321 @@ +Python +============================================================ + +Python has rich tools for packaging, distributing and sandboxing applications. Snapcraft builds on top of these familiar tools such as `pip`, `setup.py` and `requirements.txt` to create snaps for people to install on Linux. + +### What problems do snaps solve for Python applications? + +Linux install instructions for Python applications often get complicated. System dependencies, which differ from distribution to distribution, must be separately installed. To prevent modules from different Python applications clashing with each other, developer tools like `virtualenv` or `venv` must be used. With snapcraft it’s one command to produce a bundle that works anywhere. + +Here are some snap advantages that will benefit many Python projects: + +* Bundle all the runtime requirements, including the exact versions of system libraries and the Python interpreter. + +* Simplify installation instructions, regardless of distribution, to `snap install mypythonapp`. + +* Directly control the delivery of automatic application updates. + +* Extremely simple creation of daemons. + +### Getting started + +Let’s take a look at offlineimap and youtube-dl by way of examples. Both are command line applications. offlineimap uses Python 2 and only has Python module requirements. youtube-dl uses Python 3 and has system package requirements, in this case `ffmpeg`. + +### offlineimap + +Snaps are defined in a single yaml file placed in the root of your project. The offlineimap example shows the entire `snapcraft.yaml` for an existing project. We’ll break this down. + +``` +name: offlineimap +version: git +summary: OfflineIMAP +description: | + OfflineIMAP is software that downloads your email mailbox(es) as local + Maildirs. OfflineIMAP will synchronize both sides via IMAP. + +grade: devel +confinement: devmode + +apps: + offlineimap: + command: bin/offlineimap + +parts: + offlineimap: + plugin: python + python-version: python2 + source: . + +``` + +#### Metadata + +The `snapcraft.yaml` starts with a small amount of human-readable metadata, which usually can be lifted from the GitHub description or project README.md. This data is used in the presentation of your app in the Snap Store. The `summary:` can not exceed 79 characters. You can use a pipe with the `description:` to declare a multi-line description. + +``` +name: offlineimap +version: git +summary: OfflineIMAP +description: | + OfflineIMAP is software that downloads your email mailbox(es) as local + Maildirs. OfflineIMAP will synchronize both sides via IMAP. + +``` + +#### Confinement + +To get started we won’t confine this application. Unconfined applications, specified with `devmode`, can only be released to the hidden “edge” channel where you and other developers can install them. + +``` +confinement: devmode + +``` + +#### Parts + +Parts define how to build your app. Parts can be anything: programs, libraries, or other assets needed to create and run your application. In this case we have one: the offlineimap source code. In other cases these can point to local directories, remote git repositories, or tarballs. + +The Python plugin will also bundle Python in the snap, so you can be sure that the version of Python you test against is included with your app. Dependencies from `install_requires` in your `setup.py` will also be bundled. Dependencies from a `requirements.txt` file can also be bundled using the `requirements:` option. + +``` +parts: + offlineimap: + plugin: python + python-version: python2 + source: . + +``` + +#### Apps + +Apps are the commands and services exposed to end users. If your command name matches the snap `name`, users will be able run the command directly. If the names differ, then apps are prefixed with the snap `name`(`offlineimap.command-name`, for example). This is to avoid conflicting with apps defined by other installed snaps. + +If you don’t want your command prefixed you can request an alias for it on the [Snapcraft forum][1]. These command aliases are set up automatically when your snap is installed from the Snap Store. + +``` +apps: + offlineimap: + command: bin/offlineimap + +``` + +If your application is intended to run as a service, add the line `daemon: simple` after the command keyword. This will automatically keep the service running on install, update and reboot. + +### Building the snap + +You’ll first need to [install snap support][2], and then install the snapcraft tool: + +``` +sudo snap install --beta --classic snapcraft + +``` + +If you have just installed snap support, start a new shell so your `PATH` is updated to include `/snap/bin`. You can then build this example yourself: + +``` +git clone https://github.com/snapcraft-docs/offlineimap +cd offlineimap +snapcraft + +``` + +The resulting snap can be installed locally. This requires the `--dangerous` flag because the snap is not signed by the Snap Store. The `--devmode` flag acknowledges that you are installing an unconfined application: + +``` +sudo snap install offlineimap_*.snap --devmode --dangerous + +``` + +You can then try it out: + +``` +offlineimap + +``` + +Removing the snap is simple too: + +``` +sudo snap remove offlineimap + +``` + +Jump ahead to [Share with your friends][3] or continue to read another example. + +### youtube-dl + +The youtube-dl example shows a `snapcraft.yaml` using a tarball of a Python application and `ffmpeg` bundled in the snap to satisfy the runtime requirements. Here is the entire `snapcraft.yaml` for youtube-dl. We’ll break this down. + +``` +name: youtube-dl +version: 2017.06.18 +summary: YouTube Downloader. +description: | + youtube-dl is a small command-line program to download videos from + YouTube.com and a few more sites. + +grade: devel +confinement: devmode + +parts: + youtube-dl: + source: https://github.com/rg3/youtube-dl/archive/$SNAPCRAFT_PROJECT_VERSION.tar.gz + plugin: python + python-version: python3 + after: [ffmpeg] + +apps: + youtube-dl: + command: bin/youtube-dl + +``` + +#### Parts + +The `$SNAPCRAFT_PROJECT_VERSION` variable is derived from the `version:` stanza and used here to reference the matching release tarball. Because the `python` plugin is used, snapcraft will bundle a copy of Python in the snap using the version specified in the `python-version:` stanza, in this case Python 3. + +youtube-dl makes use of `ffmpeg` to transcode or otherwise convert the audio and video file it downloads. In this example, youtube-dl is told to build after the `ffmpeg` part. Because the `ffmpeg` part specifies no plugin, it will be fetched from the parts repository. This is a collection of community-contributed definitions which can be used by anyone when building a snap, saving you from needing to specify the source and build rules for each system dependency. You can use `snapcraft search` to find more parts to use and `snapcraft define ` to verify how the part is defined. + +``` +parts: + youtube-dl: + source: https://github.com/rg3/youtube-dl/archive/$SNAPCRAFT_PROJECT_VERSION.tar.gz + plugin: python + python-version: python3 + after: [ffmpeg] + +``` + +### Building the snap + +You can build this example yourself by running the following: + +``` +git clone https://github.com/snapcraft-docs/youtube-dl +cd youtube-dl +snapcraft + +``` + +The resulting snap can be installed locally. This requires the `--dangerous` flag because the snap is not signed by the Snap Store. The `--devmode` flag acknowledges that you are installing an unconfined application: + +``` +sudo snap install youtube-dl_*.snap --devmode --dangerous + +``` + +Run the command: + +``` +youtube-dl “https://www.youtube.com/watch?v=k-laAxucmEQ” + +``` + +Removing the snap is simple too: + +``` +sudo snap remove youtube-dl + +``` + +### Share with your friends + +To share your snaps you need to publish them in the Snap Store. First, create an account on [the dashboard][4]. Here you can customize how your snaps are presented, review your uploads and control publishing. + +You’ll need to choose a unique “developer namespace” as part of the account creation process. This name will be visible by users and associated with your published snaps. + +Make sure the `snapcraft` command is authenticated using the email address attached to your Snap Store account: + +``` +snapcraft login + +``` + +### Reserve a name for your snap + +You can publish your own version of a snap, provided you do so under a name you have rights to. + +``` +snapcraft register mypythonsnap + +``` + +Be sure to update the `name:` in your `snapcraft.yaml` to match this registered name, then run `snapcraft` again. + +### Upload your snap + +Use snapcraft to push the snap to the Snap Store. + +``` +snapcraft push --release=edge mypthonsnap_*.snap + +``` + +If you’re happy with the result, you can commit the snapcraft.yaml to your GitHub repo and [turn on automatic builds][5] so any further commits automatically get released to edge, without requiring you to manually build locally. + +### Further customisations + +Here are all the Python plugin-specific keywords: + +``` +- requirements: + (string) + Path to a requirements.txt file +- constraints: + (string) + Path to a constraints file +- process-dependency-links: + (bool; default: false) + Enable the processing of dependency links in pip, which allow one project + to provide places to look for another project +- python-packages: + (list) + A list of dependencies to get from PyPI +- python-version: + (string; default: python3) + The python version to use. Valid options are: python2 and python3 + +``` + +You can view them locally by running: + +``` +snapcraft help python + +``` + +### Extending and overriding behaviour + +You can [extend the behaviour][6] of any part in your `snapcraft.yaml` with shell commands. These can be run after pulling the source code but before building by using the `prepare` keyword. The build process can be overridden entirely using the `build` keyword and shell commands. The `install` keyword is used to run shell commands after building your code, useful for making post build modifications such as relocating build assets. + +Using the youtube-dl example above, we can run the test suite at the end of the build. If this fails, the snap creation will be terminated: + +``` +parts: + youtube-dl: + source: https://github.com/rg3/youtube-dl/archive/$SNAPCRAFT_PROJECT_VERSION.tar.gz + plugin: python + python-version: python3 + stage-packages: [ffmpeg, python-nose] + install: | + nosetests +``` + +-------------------------------------------------------------------------------- + +via: https://docs.snapcraft.io/build-snaps/python + +作者:[Snapcraft.io ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:Snapcraft.io + +[1]:https://forum.snapcraft.io/t/process-for-reviewing-aliases-auto-connections-and-track-requests/455 +[2]:https://docs.snapcraft.io/core/install +[3]:https://docs.snapcraft.io/build-snaps/python#share-with-your-friends +[4]:https://dashboard.snapcraft.io/openid/login/?next=/dev/snaps/ +[5]:https://build.snapcraft.io/ +[6]:https://docs.snapcraft.io/build-snaps/scriptlets diff --git a/sources/tech/20171202 Scrot Linux command-line screen grabs made simple b/sources/tech/20171202 Scrot Linux command-line screen grabs made simple new file mode 100644 index 0000000000..979ed86b3c --- /dev/null +++ b/sources/tech/20171202 Scrot Linux command-line screen grabs made simple @@ -0,0 +1,72 @@ +Translating by filefi + +# Scrot: Linux command-line screen grabs made simple + +by [Scott Nesbitt][a] · November 30, 2017 + +> Scrot is a basic, flexible tool that offers a number of handy options for taking screen captures from the Linux command line. + +[![Original photo by Rikki Endsley. CC BY-SA 4.0](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/community-penguins-osdc-lead.png?itok=BmqsAF4A)][1] + + + +There are great tools on the Linux desktop for taking screen captures, such as [KSnapshot][2] and [Shutter][3]. Even the simple utility that comes with the GNOME desktop does a pretty good job of capturing screens. But what if you rarely need to take screen captures? Or you use a Linux distribution without a built-in capture tool, or an older computer with limited resources? + +Turn to the command line and a little utility called [Scrot][4]. It does a fine job of taking simple screen captures, and it includes a few features that might surprise you. + +### Getting started with Scrot +Many Linux distributions come with Scrot already installed—to check, type `which scrot`. If it isn't there, you can install Scrot using your distro's package manager. If you're willing to compile the code, grab it [from GitHub][5]. + +To take a screen capture, crack open a terminal window and type `scrot [filename]`, where `[filename]` is the name of file to which you want to save the image (for example, `desktop.png`). If you don't include a name for the file, Scrot will create one for you, such as `2017-09-24-185009_1687x938_scrot.png`. (That filename isn't as descriptive it could be, is it? That's why it's better to add one to the command.) + +Running Scrot with no options takes a screen capture of your entire desktop. If you don't want to do that, Scrot lets you focus on smaller portions of your screen. + +### Taking a screen capture of a single window + +Tell Scrot to take a screen capture of a single window by typing `scrot -u [filename]`. + +The `-u` option tells Scrot to grab the window currently in focus. That's usually the terminal window you're working in, which might not be the one you want. + +To grab another window on your desktop, type `scrot -s [filename]`. + +The `-s` option lets you do one of two things: + +* select an open window, or + +* draw a rectangle around a window or a portion of a window to capture it. + +You can also set a delay, which gives you a little more time to select the window you want to capture. To do that, type `scrot -u -d [num] [filename]`. + +The `-d` option tells Scrot to wait before grabbing the window, and `[num]` is the number of seconds to wait. Specifying `-d 5` (wait five seconds) should give you enough time to choose a window. + +### More useful options + +Scrot offers a number of additional features (most of which I never use). The ones I find most useful include: + +* `-b` also grabs the window's border + +* `-t` grabs a window and creates a thumbnail of it. This can be useful when you're posting screen captures online. + +* `-c` creates a countdown in your terminal when you use the `-d` option. + +To learn about Scrot's other options, check out the its documentation by typing `man scrot` in a terminal window, or [read it online][6]. Then start snapping images of your screen. + +It's basic, but Scrot gets the job done nicely. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot + +作者:[Scott Nesbitt][a] +译者:[filefi](https://github.com/filefi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/scottnesbitt +[1]:https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/community-penguins-osdc-lead.png?itok=BmqsAF4A +[2]:https://www.kde.org/applications/graphics/ksnapshot/ +[3]:https://launchpad.net/shutter +[4]:https://github.com/dreamer/scrot +[5]:http://manpages.ubuntu.com/manpages/precise/man1/scrot.1.html +[6]:https://github.com/dreamer/scrot diff --git a/sources/tech/20171202 docker - Use multi-stage builds.md b/sources/tech/20171202 docker - Use multi-stage builds.md new file mode 100644 index 0000000000..e1a6414862 --- /dev/null +++ b/sources/tech/20171202 docker - Use multi-stage builds.md @@ -0,0 +1,127 @@ +Use multi-stage builds +============================================================ + +Multi-stage builds are a new feature requiring Docker 17.05 or higher on the daemon and client. Multistage builds are useful to anyone who has struggled to optimize Dockerfiles while keeping them easy to read and maintain. + +> Acknowledgment: Special thanks to [Alex Ellis][1] for granting permission to use his blog post [Builder pattern vs. Multi-stage builds in Docker][2] as the basis of the examples below. + +### Before multi-stage builds + +One of the most challenging things about building images is keeping the image size down. Each instruction in the Dockerfile adds a layer to the image, and you need to remember to clean up any artifacts you don’t need before moving on to the next layer. To write a really efficient Dockerfile, you have traditionally needed to employ shell tricks and other logic to keep the layers as small as possible and to ensure that each layer has the artifacts it needs from the previous layer and nothing else. + +It was actually very common to have one Dockerfile to use for development (which contained everything needed to build your application), and a slimmed-down one to use for production, which only contained your application and exactly what was needed to run it. This has been referred to as the “builder pattern”. Maintaining two Dockerfiles is not ideal. + +Here’s an example of a `Dockerfile.build` and `Dockerfile` which adhere to the builder pattern above: + +`Dockerfile.build`: + +``` +FROM golang:1.7.3 +WORKDIR /go/src/github.com/alexellis/href-counter/ +RUN go get -d -v golang.org/x/net/html +COPY app.go . +RUN go get -d -v golang.org/x/net/html \ + && CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . + +``` + +Notice that this example also artificially compresses two `RUN` commands together using the Bash `&&` operator, to avoid creating an additional layer in the image. This is failure-prone and hard to maintain. It’s easy to insert another command and forget to continue the line using the `\` character, for example. + +`Dockerfile`: + +``` +FROM alpine:latest +RUN apk --no-cache add ca-certificates +WORKDIR /root/ +COPY app . +CMD ["./app"] + +``` + +`build.sh`: + +``` +#!/bin/sh +echo Building alexellis2/href-counter:build + +docker build --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy \ + -t alexellis2/href-counter:build . -f Dockerfile.build + +docker create --name extract alexellis2/href-counter:build +docker cp extract:/go/src/github.com/alexellis/href-counter/app ./app +docker rm -f extract + +echo Building alexellis2/href-counter:latest + +docker build --no-cache -t alexellis2/href-counter:latest . +rm ./app + +``` + +When you run the `build.sh` script, it needs to build the first image, create a container from it in order to copy the artifact out, then build the second image. Both images take up room on your system and you still have the `app` artifact on your local disk as well. + +Multi-stage builds vastly simplify this situation! + +### Use multi-stage builds + +With multi-stage builds, you use multiple `FROM` statements in your Dockerfile. Each `FROM` instruction can use a different base, and each of them begins a new stage of the build. You can selectively copy artifacts from one stage to another, leaving behind everything you don’t want in the final image. To show how this works, Let’s adapt the Dockerfile from the previous section to use multi-stage builds. + +`Dockerfile`: + +``` +FROM golang:1.7.3 +WORKDIR /go/src/github.com/alexellis/href-counter/ +RUN go get -d -v golang.org/x/net/html +COPY app.go . +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . + +FROM alpine:latest +RUN apk --no-cache add ca-certificates +WORKDIR /root/ +COPY --from=0 /go/src/github.com/alexellis/href-counter/app . +CMD ["./app"] + +``` + +You only need the single Dockerfile. You don’t need a separate build script, either. Just run `docker build`. + +``` +$ docker build -t alexellis2/href-counter:latest . + +``` + +The end result is the same tiny production image as before, with a significant reduction in complexity. You don’t need to create any intermediate images and you don’t need to extract any artifacts to your local system at all. + +How does it work? The second `FROM` instruction starts a new build stage with the `alpine:latest` image as its base. The `COPY --from=0` line copies just the built artifact from the previous stage into this new stage. The Go SDK and any intermediate artifacts are left behind, and not saved in the final image. + +### Name your build stages + +By default, the stages are not named, and you refer to them by their integer number, starting with 0 for the first `FROM` instruction. However, you can name your stages, by adding an `as ` to the `FROM` instruction. This example improves the previous one by naming the stages and using the name in the `COPY` instruction. This means that even if the instructions in your Dockerfile are re-ordered later, the `COPY` won’t break. + +``` +FROM golang:1.7.3 as builder +WORKDIR /go/src/github.com/alexellis/href-counter/ +RUN go get -d -v golang.org/x/net/html +COPY app.go . +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . + +FROM alpine:latest +RUN apk --no-cache add ca-certificates +WORKDIR /root/ +COPY --from=builder /go/src/github.com/alexellis/href-counter/app . +CMD ["./app"] +``` + +-------------------------------------------------------------------------------- + +via: https://docs.docker.com/engine/userguide/eng-image/multistage-build/#name-your-build-stages + +作者:[docker docs ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://docs.docker.com/engine/userguide/eng-image/multistage-build/ +[1]:https://twitter.com/alexellisuk +[2]:http://blog.alexellis.io/mutli-stage-docker-builds/ diff --git a/translated/tech/20090701 The One in Which I Call Out Hacker News.md b/translated/tech/20090701 The One in Which I Call Out Hacker News.md new file mode 100644 index 0000000000..670be95353 --- /dev/null +++ b/translated/tech/20090701 The One in Which I Call Out Hacker News.md @@ -0,0 +1,99 @@ +我号召黑客新闻的理由之一 +实现高速缓存会花费 30 个小时,你有额外的 30 个小时吗? +不,你没有。 +我实际上并不知道它会花多少时间,可能它会花五分钟,你有五分钟吗?不,你还是没有。为什么?因为我在撒谎。它会消耗远超五分钟的时间,这是程序员永远的 +乐观主义。 +- Owen Astrachan 教授于 2004 年 2 月 23 日在 CPS 108 上的讲座 + +指责开源软件的使用存在着高昂的代价已经不是一个新论点了,它之前就被提过,而且说的比我更有信服力,即使一些人已经在高度赞扬开源软件的运作。 +这种事为什么会重复发生? + +在周一的黑客新闻上,我愉悦地看着某些人一边说写 Stack Overflow 简单的简直搞笑,一边通过允许七月第四个周末之后的克隆来开始备份他们的提问。 +其他的声明中也指出现存的克隆是一个好的出发点。 + +让我们假设,为了争辩,你觉得将自己的 Stack Overflow 通过 ASP.NET 和 MVC 克隆是正确的,然后被一块廉价的手表和一个小型俱乐部头领忽悠之后, +决定去手动拷贝你 Stack Overflow 的源代码,一页又一页,所以你可以逐字逐句地重新输入,我们同样会假定你像我一样打字,很酷的有 100 WPM +(差不多每秒8个字符),不和我一样的话,你不会犯错。 + + Stack Overflow 的 *.cs、*.sql、*.css、*.js 和 *.aspx 文件大约 2.3 MB,因此如果你想将这些源代码输进电脑里去的话,即使你不犯错也需要大约 80 个小时。 + +除非......当然,你是不会那样做的:你打算从头开始实现 Stack Overflow 。所以即使我们假设,你花了十倍的时间去设计、输出,然后调试你自己的实现而不是去拷 +贝已有的那份,那已经让你已经编译了好几个星期。我不知道你,但是我可以承认我写的新代码大大小于我复制的现有代码的十分之一。 + +好,ok,我听见你松了口气。所以不是全部。但是我可以做大部分。 + +行,所以什么是大部分?这只是询问和回答问题,这个部分很简单。那么,除了你必须实现对问题和答案投票、赞同还是反对,而且提问者应该能够去接收每一个问题的 +单一答案。你不能让人们赞同或者反对他们自己的回答。所以你需要去阻止。你需要去确保用户在一定的时间内不会赞同或反对其他用户太多次。以预防垃圾邮件, +你可能也需要去实现一个垃圾邮件过滤器,即使在一个基本的设计里,也要考虑到这一点。而且还需要去支持用户图标。并且你将不得不寻找一个自己真正信任的并且 +与 markdown 接合很好的 HTML 库(当然,你确实希望重新使用那个令人敬畏的编辑器 Stack Overflow ),你还需要为所有控件购买,设计或查找小部件,此外 +你至少需要一个基本的管理界面,以便用户可以调节,并且你需要实现可扩展的业务量,以便能稳定地给用户越来越多的功能去实现他们想做的。 + +如果你这样做了,你可以完成它。 + +除了...除了全文检索外,特别是它在“寻找问题”功能中的表现,这是必不可少的。然后用户的基本信息,和回答的意见,然后有一个主要展示你的重要问题, +但是它会稳定的冒泡式下降。另外你需要去实现奖励,并支持每个用户的多个 OpenID 登录,然后为相关的事件发送邮件通知,并添加一个标签系统, +接着允许管理员通过一个不错的图形界面配置徽章。你需要去显示用户的 karma 历史,点赞和差评。整个事情的规模都非常好,因为它随时都可以被 + slashdotted、reddited 或是 Stack Overflow 。 + +在这之后!你就已经完成了! + +...在正确地实现升级、国际化、业绩上限和一个 css 设计之后,使你的站点看起来不像是一个屁股,上面的大部分 AJAX 版本和 G-d 知道什么会同样潜伏 +在你所信任的界面下,但是当你开始做一个真正的克隆的时候,就会遇到它。 + +告诉我:这些功能中哪个是你感觉可以削减而让它仍然是一个引人注目的产品,哪些是大部分网站之下的呢?哪个你可以剔除呢? + +开发者因为开源软件的使用是一个可怕的痛苦这样一个相同的理由认为克隆一个像 Stack Overflow 的站点很简单。当你把一个开发者放在 Stack Overflow 前面, +他们并不真的看到 Stack Overflow,他们实际上看的是这些: + +create table QUESTION (ID identity primary key, + TITLE varchar(255), --- 为什么我知道你认为是 255 + BODY text, + UPVOTES integer not null default 0, + DOWNVOTES integer not null default 0, + USER integer references USER(ID)); +create table RESPONSE (ID identity primary key, + BODY text, + UPVOTES integer not null default 0, + DOWNVOTES integer not null default 0, + QUESTION integer references QUESTION(ID)) + +如果你告诉一个开发者去复制 Stack Overflow ,进入他脑海中的就是上面的两个 SQL 表和足够的 HTML 文件来显示它们,而不用格式化,这在一个周末里是完全 +可以实现的,聪明的人会意识到他们需要实现登陆、注销和评论,点赞需要绑定到用户。但是这在一个周末内仍然是完全可行的。这仅仅是在 SQL 后端里加上两张 +左右的表,而 HTML 则用来展示内容,使用像 Django 这样的框架,你甚至可以免费获得基本的用户和评论。 + +但是那不是和 Stack Overflow 相关的,无论你对 Stack Overflow 的感受如何,大多数访问者似乎都认为用户体验从头到尾都很流畅,他们感觉他们和一个 +好产品相互影响。即使我没有更好的了解,我也会猜测 Stack Overflow 在数据库模式方面取得了持续的成功-并且有机会去阅读 Stack Overflow 的源代码, +我知道它实际上有多么的小,这些是一个极大的 spit 和 Polish 的集合,成为了一个具有高可用性的主要网站,一个开发者,问一个东西被克隆有多难, +仅仅不认为和 Polish 相关,因为 Polish 是实现结果附带的。 + +这就是为什么 Stack Overflow 的开放源代码克隆会失败,即使一些人在设法实现大部分 Stack Overflow 的“规范”,也会有一些关键区域会将他们绊倒, +举个例子,如果你把目标市场定在了终端用户上,你要么需要一个图形界面去配置规则,要么聪明的开发者会决定哪些徽章具有足够的通用性,去继续所有的 +安装,实际情况是,开发者发牢骚和抱怨你不能实现一个真实的综合性的像 badges 的图形用户界面,然后 bikeshed 任何的建议,为因为标准的 badges +在范围内太远,他们会迅速避开选择其他方向,他们最后会带着相同的有 bug 追踪器的解决方案赶上,就像他们工作流程的概要使用一样: +开发者通过任意一种方式实现一个通用的机制,任何一个人完全都能轻松地使用 Python、PHP 或任意一门语言中的系统 API 来工作,能简单为他们自己增加 +自定义设置,PHP 和 Python 是学起来很简单的,并且比起曾经的图形界面更加的灵活,为什么还要操心其他事呢? + +同样的,节制和管理界面可以被削减。如果你是一个管理员,你可以进入 SQL 服务器,所以你可以做任何真正的管理-就像这样,管理员可以通过任何的 Django +管理和类似的系统给你提供支持,因为,毕竟只有少数用户是 mods,mods 应该理解网站是怎么运作、停止的。当然,没有 Stack Overflow 的接口失败会被纠正 +,即使 Stack Overflow 的愚蠢的要求,你必须知道如何去使用 openID (它是最糟糕的缺点)最后得到修复。我确信任何的开源的克隆都会狂热地跟随它- +即使 GNOME 和 KDE 多年来亦步亦趋地复制 windows ,而不是尝试去修复它自己最明显的缺陷。 + +开发者可能不会关心应用的这些部分,但是最终用户会,当他们尝试去决定使用哪个应用时会去考虑这些。就好像一家好的软件公司希望通过确保其产品在出货之前 +是一流的来降低其支持成本一样,所以,同样的,懂行的消费者想在他们购买这些产品之前确保产品好用,以便他们不需要去寻求帮助,开源产品就失败在这种地方 +,一般来说,专有解决方案会做得更好。 + +这不是说开源软件没有他们自己的立足之地,这个博客运行在 Apache,Django,PostgreSQL 和 Linux 上。但是让我告诉你,配置这些堆栈不是为了让人心灰意懒 +,PostgreSQL 需要在老版本上移除设置。然后,在 Ubuntu 和 FreeBSD 最新的版本上,仍然要求用户搭建第一个数据库集群,MS SQL不需要这些东西,Apache... +天啊,甚至没有让我开始尝试去向一个初学者用户解释如何去得到虚拟机,MovableType,一对 Django 应用程序,而且所有的 WordPress 都可以在一个单一的安装下 +顺利运行,像在地狱一样,只是试图解释 Apache 的分叉线程变换给技术上精明的非开发人员就是一个噩梦,IIS 7 和操作系统的 Apache 服务器是非常闭源的, +图形界面管理程序配置这些这些相同的堆栈非常的简单,Django 是一个伟大的产品,但是它只是基础架构而已,我认为开源软件做的很好,恰恰是因为推动开发者去 +贡献的动机 + +下次你看见一个你喜欢的应用,认为所有面向用户的细节非常长和辛苦,就会去让它用起来更令人开心,在谴责你如何能普通的实现整个的可恶的事在一个周末, +十分之九之后,当你认为一个应用的实现简单地简直可笑,你就完全的错失了故事另一边的用户 + +via: https://bitquabit.com/post/one-which-i-call-out-hacker-news/ + +作者:Benjamin Pollack 译者:hopefully2333 校对:校对者ID + +本文由 LCTT 原创编译,Linux中国 荣誉推出 diff --git a/translated/tech/20170530 How to Improve a Legacy Codebase.md b/translated/tech/20170530 How to Improve a Legacy Codebase.md new file mode 100644 index 0000000000..a1869b0449 --- /dev/null +++ b/translated/tech/20170530 How to Improve a Legacy Codebase.md @@ -0,0 +1,104 @@ +# 如何改善遗留的代码库 + +这在每一个程序员,项目管理员,团队领导的一生中都会至少发生一次。原来的程序员早已离职去度假了,留下了一坨几百万行屎一样的代码和文档(如果有的话),一旦接手这些代码,想要跟上公司的进度简直让人绝望。 + +你的工作是带领团队摆脱这个混乱的局面 + +当你的第一反应过去之后,你开始去熟悉这个项目,公司的管理层都在关注着你,所以项目只能成功,然而,看了一遍代码之后却发现很大的可能会失败。那么该怎么办呢? + +幸运(不幸)的是我已经遇到好几次这种情况了,我和我的小伙伴发现将这坨热气腾腾的屎变成一个健康可维护的项目是非常值得一试的。下面这些是我们的一些经验: + +### 备份 + +在开始做任何事情之前备份与之可能相关的所有文件。这样可以确保不会丢失任何可能会在另外一些地方很重要的信息。一旦修改其中一些文件,你可能花费一天或者更多天都解决不了这个愚蠢的问题,配置数据通常不受版本控制,所以特别容易受到这方面影响,如果定期备份数据时连带着它一起备份了,还是比较幸运的。所以谨慎总比后悔好,复制所有东西到一个绝对安全的地方吧,除非这些文件是只读模式否则不要轻易碰它。 + +### 必须确保代码能够在生产环境下构建运行并产出,这是重要的先决条件。 + +之前我假设环境已经存在,所以完全丢了这一步,Hacker News 的众多网友指出了这一点并且证明他们是对的:第一步是确认你知道在生产环境下运行着什么东西,也意味着你需要在你的设备上构建一个跟生产环境上运行的版本每一个字节都一模一样的版本。如果你找不到实现它的办法,一旦你将它投入生产环境,你很可能会遭遇一些很糟糕的事情。确保每一部分都尽力测试,之后在你足够信任它能够很好的运行的时候将它部署生产环境下。无论它运行的怎么样都要做好能够马上切换回旧版本的准备,确保日志记录下了所有情况,以便于接下来不可避免的 “验尸” 。 + +### 冻结数据库 + +直到你修改代码之前尽可能冻结你的数据库,在你特别熟悉代码库和遗留代码之后再去修改数据库。在这之前过早的修改数据库的话,你可能会碰到大问题,你会失去让新旧代码和数据库一起构建稳固的基础的能力。保持数据库完全不变,就能比较新的逻辑代码和旧的逻辑代码运行的结果,比较的结果应该跟预期的没有差别。 + +### 写测试 + +在你做任何改变之前,尽可能多的写下端到端测试和集成测试。在你能够清晰的知道旧的是如何工作的情况下确保这些测试能够正确的输出(准备好应对一些突发状况)。这些测试有两个重要的作用,其一,他们能够在早期帮助你抛弃一些错误观念,其二,在你写新代码替换旧代码的时候也有一定防护作用。 + +自动化测试,如果你也有 CI 的使用经验请使用它,并且确保在你提交代码之后能够快速的完成所有测试。 + +### 日志监控 + +如果旧设备依然可用,那么添加上监控功能。使用一个全新的数据库,为每一个你能想到的事件都添加一个简单的计数器,并且根据这些事件的名字添加一个函数增加这些计数器。用一些额外的代码实现一个带有时间戳的事件日志,这是一个好办法知道有多少事件导致了另外一些种类的事件。例如:用户打开 APP ,用户关闭 APP 。如果这两个事件导致后端调用的数量维持长时间的不同,这个数量差就是当前打开的 APP 的数量。如果你发现打开 APP 比关闭 APP 多的时候,你就必须要知道是什么原因导致 APP 关闭了(例如崩溃)。你会发现每一个事件都跟其他的一些事件有许多不同种类的联系,通常情况下你应该尽量维持这些固定的联系,除非在系统上有一个明显的错误。你的目标是减少那些错误的事件,尽可能多的在开始的时候通过使用计数器在调用链中降低到指定的级别。(例如:用户支付应该得到相同数量的支付回调)。 + +这是简单的技巧去将每一个后端应用变成一个就像真实的簿记系统一样,所有数字必须匹配,只要他们在某个地方都不会有什么问题。 + +随着时间的推移,这个系统在监控健康方面变得非常宝贵,而且它也是使用源码控制修改系统日志的一个好伙伴,你可以使用它确认 BUG 出现的位置,以及对多种计数器造成的影响。 + +我通常保持 5 分钟(一小时 12 次)记录一次计数器,如果你的应用生成了更多或者更少的事件,你应该修改这个时间间隔。所有的计数器公用一个数据表,每一个记录都只是简单的一行。 + +### 一次只修改一处 + +不要完全陷入在提高代码或者平台可用性的同时添加新特性或者是修复 BUG 的陷阱。这会让你头大而且将会使你之前建立的测试失效,现在必须问问你自己,每一步的操作想要什么样的结果。 + +### 修改平台 + +如果你决定转移你的应用到另外一个平台,最主要的是跟之前保持一样。如果你觉得你会添加更多的文档和测试,但是不要忘记这一点,所有的业务逻辑和相互依赖跟从前一样保持不变。 + +### 修改架构 + +接下来处理的是改变应用的结构(如果需要)。这一点上,你可以自由的修改高层的代码,通常是降低模块间的横向联系,这样可以降低代码活动期间对终端用户造成的影响范围。如果老代码是庞大的,那么现在正是让他模块化的时候,将大段代码分解成众多小的,不过不要把变量的名字和他的数据结构分开。 + +Hacker News [mannykannot][1] 网友指出,修改架构并不总是可行,如果你特别不幸的话,你可能为了改变一些架构必须付出沉重的代价。我也赞同这一点,我应该加上这一点,因此这里有一些补充。我非常想补充的是如果你修改高级代码的时候修改了一点点底层代码,那么试着限制只修改一个文件或者最坏的情况是只修改一个子系统,所以尽可能限制修改的范围。否则你可能很难调试刚才所做的更改。 + +### 底层代码的重构 + +现在,你应该非常理解每一个模块的作用了,准备做一些真正的工作吧:重构代码以提高其可维护性并且使代码做好添加新功能的准备。这很可能是项目中最消耗时间的部分,记录你所做的任何操作,在你彻底的记录模块并且理解之前不要对它做任何修改。之后你可以自由的修改变量名、函数名以及数据结构以提高代码的清晰度和统一性,然后请做测试(情况允许的话,包括单元测试)。 + +### 修复 bugs + +现在准备做一些用户可见的修改,战斗的第一步是修复很多积累了一整年的bugs,像往常一样,首先证实 bug 仍然存在,然后编写测试并修复这个 bug,你的 CI 和端对端测试应该能避免一些由于不太熟悉或者一些额外的事情而犯的错误。 + +### 升级数据库 + + +如果在一个坚实且可维护的代码库上完成所有工作,如果你有更改数据库模式的计划,可以使用不同的完全替换数据库。 +把所有的这些都做完将能够帮助你更可靠的修改而不会碰到问题,你会完全的测试新数据库和新代码,所有测试可以确保你顺利的迁移。 + +### 按着路线图执行 + +祝贺你脱离的困境并且可以准备添加新功能了。 + +### 任何时候都不要尝试彻底重写 + +彻底重写是那种注定会失败的项目,一方面,你在一个未知的领域开始,所以你甚至不知道构建什么,另一方面,你会把所以的问题都推到新系统马上就要上线的前一天,非常不幸的是,这也是你失败的时候,假设业务逻辑存在问题,你会得到异样的眼光,那时您会突然明白为什么旧系统会用某种奇怪的方式来工作,最终也会意识到能将旧系统放在一起工作的人也不都是白痴。在那之后。如果你真的想破坏公司(和你自己的声誉),那就重写吧,但如果你足够聪明,彻底重写系统通常不会成为一个摆到桌上讨论的选项。 + +### 所以,替代方法是增量迭代工作 + +要解开这些线团最快方法是,使用你熟悉的代码中任何的元素(它可能是外部的,他可以是内核模块),试着使用旧的上下文去增量提升,如果旧的构建工具已经不能用了,你将必须使用一些技巧(看下面)至少当你开始做修改的时候,试着尽力保留已知的工作。那样随着代码库的提升你也对代码的作用更加理解。一个典型的代码提交应该最多两行。 + +### 发布! + +每一次的修改都发布到生产环境,即使一些修改不是用户可见的。使用最少的步骤也是很重要的,因为当你缺乏对系统的了解时,只有生产环境能够告诉你问题在哪里,如果你只做了一个很小的修改之后出了问题,会有一些好处: + +* 很容易弄清楚出了什么问题 +* 这是一个改进流程的好位置 +* 你应该马上更新文档展示你的新见解 + +### 使用代理的好处 +如果你做 web 开发时在旧系统和用户之间加了代理。你能很容易的控制每一个网址哪些请求旧系统,哪些重定向到新系统,从而更轻松更精确的控制运行的内容以及谁能够看到。如果你的代理足够的聪明,你可以使用它发送一定比例的流量到个人的 URL,直到你满意为止,如果你的集成测试也连接到这个接口那就更好了。 + +### 是的,这会花费很多时间 +这取决于你怎样看待它的,这是事实会有一些重复的工作涉及到这些步骤中。但是它确实有效,对于进程的任何一个优化都将使你对这样系统更加熟悉。我会保持声誉,并且我真的不喜欢在工作期间有负面的意外。如果运气好的话,公司系统已经出现问题,而且可能会影响客户。在这样的情况下,如果你更多地是牛仔的做事方式,并且你的老板同意可以接受冒更大的风险,我比较喜欢完全控制整个流程得到好的结果而不是节省两天或者一星期,但是大多数公司宁愿采取稍微慢一点但更确定的胜利之路。 + +-------------------------------------------------------------------------------- + +via: https://jacquesmattheij.com/improving-a-legacy-codebase + +作者:[Jacques Mattheij][a] +译者:[aiwhj](https://github.com/aiwhj) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jacquesmattheij.com/ +[1]:https://news.ycombinator.com/item?id=14445661 diff --git a/translated/tech/20170910 Cool vim feature sessions.md b/translated/tech/20170910 Cool vim feature sessions.md new file mode 100644 index 0000000000..49ee43fda1 --- /dev/null +++ b/translated/tech/20170910 Cool vim feature sessions.md @@ -0,0 +1,44 @@ +vim 的酷功能:会话! +============================================================• + +昨天我在编写我的[vimrc][5]的时候了解到一个很酷的 vim 功能!(主要为了添加 fzf 和 ripgrep 插件)。这是一个内置功能,不需要特别的插件。 + +所以我画了一个漫画。 + +基本上你可以用下面的命令保存所有你打开的文件和当前的状态 + +``` +:mksession ~/.vim/sessions/foo.vim + +``` + +接着用 `:source ~/.vim/sessions/foo.vim` 或者  `vim -S ~/.vim/sessions/foo.vim` 还原会话。非常酷! + +一些 vim 插件给 vim 会话添加了额外的功能: + +* [https://github.com/tpope/vim-obsession][1] + +* [https://github.com/mhinz/vim-startify][2] + +* [https://github.com/xolox/vim-session][3] + +这是漫画: + +![](https://jvns.ca/images/vimsessions.png) + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/09/10/vim-sessions/ + +作者:[Julia Evans ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/about +[1]:https://github.com/tpope/vim-obsession +[2]:https://github.com/mhinz/vim-startify +[3]:https://github.com/xolox/vim-session +[4]:https://jvns.ca/categories/vim +[5]:https://github.com/jvns/vimconfig/blob/master/vimrc diff --git a/translated/tech/20171020 How Eclipse is advancing IoT development.md b/translated/tech/20171020 How Eclipse is advancing IoT development.md new file mode 100644 index 0000000000..0de4f38ea1 --- /dev/null +++ b/translated/tech/20171020 How Eclipse is advancing IoT development.md @@ -0,0 +1,77 @@ +translated by smartgrids +Eclipse 如何助力 IoT 发展 +============================================================ + +### 开源组织的模块发开发方式非常适合物联网。 + +![How Eclipse is advancing IoT development](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_BUS_ArchitectureOfParticipation_520x292.png?itok=FA0Uuwzv "How Eclipse is advancing IoT development") +图片来源: opensource.com + +[Eclipse][3] 可能不是第一个去研究物联网的开源组织。但是,远在 IoT 家喻户晓之前,该基金会在 2001 年左右就开始支持开源软件发展商业化。九月 Eclipse 物联网日和 RedMonk 的 [ThingMonk 2017][4] 一块举行,着重强调了 Eclipse 在 [物联网发展][5] 中的重要作用。它现在已经包含了 28 个项目,覆盖了大部分物联网项目需求。会议过程中,我和负责 Eclipse 市场化运作的 [Ian Skerritt][6] 讨论了 Eclipse 的物联网项目以及如何拓展它。 + +###物联网的最新进展? +我问 Ian 物联网同传统工业自动化,也就是前几十年通过传感器和相应工具来实现工厂互联的方式有什么不同。 Ian 指出很多工厂是还没有互联的。 +另外,他说“ SCADA[监控和数据分析] 系统以及工厂底层技术都是私有、独立性的。我们很难去改变它,也很难去适配它们…… 现在,如果你想运行一套生产系统,你需要设计成百上千的单元。生产线想要的是满足用户需求,使制造过程更灵活,从而可以不断产出。” 这也就是物联网会带给制造业的一个很大的帮助。 + + +###Eclipse 物联网方面的研究 +Ian 对于 Eclipse 在物联网的研究是这样描述的:“满足任何物联网解决方案的核心基础技术” ,通过使用开源技术,“每个人都可以使用从而可以获得更好的适配性。” 他说,Eclipse 将物联网视为包括三层互联的软件栈。从更高的层面上看,这些软件栈(按照大家常见的说法)将物联网描述为跨越三个层面的网络。特定的观念可能认为含有更多的层面,但是他们一直符合这个三层模型的功能的: + +* 一种可以装载设备(例如设备、终端、微控制器、传感器)用软件的堆栈。 +* 将不同的传感器采集到的数据信息聚合起来并传输到网上的一类网关。这一层也可能会针对传感器数据检测做出实时反映。 +* 物联网平台后端的一个软件栈。这个后端云存储数据并能根据采集的数据比如历史趋势、预测分析提供服务。 + +这三个软件栈在 Eclipse 的白皮书 “ [The Three Software Stacks Required for IoT Architectures][7] ”中有更详细的描述。 + +Ian 说在这些架构中开发一种解决方案时,“需要开发一些特殊的东西,但是很多底层的技术是可以借用的,像通信协议、网关服务。需要一种模块化的方式来满足不用的需求场合。” Eclipse 关于物联网方面的研究可以概括为:开发模块化开源组件从而可以被用于开发大量的特定性商业服务和解决方案。 + +###Eclipse 的物联网项目 + +在众多一杯应用的 Eclipse 物联网应用中, Ian 举了两个和 [MQTT][8] 有关联的突出应用,一个设备与设备互联(M2M)的物联网协议。 Ian 把它描述成“一个专为重视电源管理工作的油气传输线监控系统的信息发布/订阅协议。MQTT 已经是众多物联网广泛应用标准中很成功的一个。” [Eclipse Mosquitto][9] 是 MQTT 的代理,[Eclipse Paho][10] 是他的客户端。 +[Eclipse Kura][11] 是一个物联网网关,引用 Ian 的话,“它连接了很多不同的协议间的联系”包括蓝牙、Modbus、CANbus 和 OPC 统一架构协议,以及一直在不断添加的协议。一个优势就是,他说,取代了你自己写你自己的协议, Kura 提供了这个功能并将你通过卫星、网络或其他设备连接到网络。”另外它也提供了防火墙配置、网络延时以及其它功能。Ian 也指出“如果网络不通时,它会存储信息直到网络恢复。” + +最新的一个项目中,[Eclipse Kapua][12] 正尝试通过微服务来为物联网云平台提供不同的服务。比如,它集成了通信、汇聚、管理、存储和分析功能。Ian 说“它正在不断前进,虽然还没被完全开发出来,但是 Eurotech 和 RedHat 在这个项目上非常积极。” +Ian 说 [Eclipse hawkBit][13] ,软件更新管理的软件,是一项“非常有趣的项目。从安全的角度说,如果你不能更新你的设备,你将会面临巨大的安全漏洞。”很多物联网安全事故都和无法更新的设备有关,他说,“ HawkBit 可以基本负责通过物联网系统来完成扩展性更新的后端管理。” + +物联网设备软件升级的难度一直被看作是难度最高的安全挑战之一。物联网设备不是一直连接的,而且数目众多,再加上首先设备的更新程序很难完全正常。正因为这个原因,关于无赖女王软件升级的项目一直是被当作重要内容往前推进。 + +###为什么物联网这么适合 Eclipse + +在物联网发展趋势中的一个方面就是关于构建模块来解决商业问题,而不是宽约工业和公司的大物联网平台。 Eclipse 关于物联网的研究放在一系列模块栈、提供特定和大众化需求功能的项目,还有就是指定目标所需的可捆绑式中间件、网关和协议组件上。 + + +-------------------------------------------------------------------------------- + + + +作者简介: + +Gordon Haff - Gordon Haff 是红帽公司的云营销员,经常在消费者和工业会议上讲话,并且帮助发展红帽全办公云解决方案。他是 计算机前言:云如何如何打开众多出版社未来之门 的作者。在红帽之前, Gordon 写了成百上千的研究报告,经常被引用到公众刊物上,像纽约时报关于 IT 的议题和产品建议等…… + +-------------------------------------------------------------------------------- + +转自: https://opensource.com/article/17/10/eclipse-and-iot + +作者:[Gordon Haff ][a] +译者:[smartgrids](https://github.com/smartgrids) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/ghaff +[1]:https://opensource.com/article/17/10/eclipse-and-iot?rate=u1Wr-MCMFCF4C45IMoSPUacCatoqzhdKz7NePxHOvwg +[2]:https://opensource.com/user/21220/feed +[3]:https://www.eclipse.org/home/ +[4]:http://thingmonk.com/ +[5]:https://iot.eclipse.org/ +[6]:https://twitter.com/ianskerrett +[7]:https://iot.eclipse.org/resources/white-papers/Eclipse%20IoT%20White%20Paper%20-%20The%20Three%20Software%20Stacks%20Required%20for%20IoT%20Architectures.pdf +[8]:http://mqtt.org/ +[9]:https://projects.eclipse.org/projects/technology.mosquitto +[10]:https://projects.eclipse.org/projects/technology.paho +[11]:https://www.eclipse.org/kura/ +[12]:https://www.eclipse.org/kapua/ +[13]:https://eclipse.org/hawkbit/ +[14]:https://opensource.com/users/ghaff +[15]:https://opensource.com/users/ghaff +[16]:https://opensource.com/article/17/10/eclipse-and-iot#comments diff --git a/translated/tech/20171108 Archiving repositories.md b/translated/tech/20171108 Archiving repositories.md new file mode 100644 index 0000000000..3d1a328541 --- /dev/null +++ b/translated/tech/20171108 Archiving repositories.md @@ -0,0 +1,37 @@ +归档仓库 +==================== + + +因为仓库不再活跃开发或者你不想接受额外的贡献并不意味着你想要删除它。现在在 Github 上归档仓库让它变成只读。 + + [![archived repository banner](https://user-images.githubusercontent.com/7321362/32558403-450458dc-c46a-11e7-96f9-af31d2206acb.png)][1] + +归档一个仓库让它对所有人只读(包括仓库拥有者)。这包括编辑仓库、问题、合并请求、标记、里程碑、维基、发布、提交、标签、分支、反馈和评论。没有人可以在一个归档的仓库上创建新的问题、合并请求或者评论,但是你仍可以 fork 仓库-允许归档的仓库在其他地方继续开发。 + +要归档一个仓库,进入仓库设置页面并点在这个仓库上点击归档。 + + [![archive repository button](https://user-images.githubusercontent.com/125011/32273119-0fc5571e-bef9-11e7-9909-d137268a1d6d.png)][2] + +在归档你的仓库前,确保你已经更改了它的设置并考虑关闭所有的开放问题和合并请求。你还应该更新你的 README 和描述来让它让访问者了解他不再能够贡献。 + +如果你改变了主意想要解除归档你的仓库,在相同的地方点击解除归档。请注意大多数归档仓库的设置是隐藏的,并且你需要解除归档来改变它们。 + + [![archived labelled repository](https://user-images.githubusercontent.com/125011/32541128-9d67a064-c466-11e7-857e-3834054ba3c9.png)][3] + +要了解更多,请查看[这份文档][4]中的归档仓库部分。归档快乐! + +-------------------------------------------------------------------------------- + +via: https://github.com/blog/2460-archiving-repositories + +作者:[MikeMcQuaid ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://github.com/MikeMcQuaid +[1]:https://user-images.githubusercontent.com/7321362/32558403-450458dc-c46a-11e7-96f9-af31d2206acb.png +[2]:https://user-images.githubusercontent.com/125011/32273119-0fc5571e-bef9-11e7-9909-d137268a1d6d.png +[3]:https://user-images.githubusercontent.com/125011/32541128-9d67a064-c466-11e7-857e-3834054ba3c9.png +[4]:https://help.github.com/articles/about-archiving-repositories/ diff --git a/translated/tech/20171116 Introducing security alerts on GitHub.md b/translated/tech/20171116 Introducing security alerts on GitHub.md new file mode 100644 index 0000000000..b8f0afba17 --- /dev/null +++ b/translated/tech/20171116 Introducing security alerts on GitHub.md @@ -0,0 +1,48 @@ +介绍 GitHub 上的安全警报 +==================================== + + +上个月,我们用依赖关系图让你更容易跟踪你代码依赖的的项目,目前支持 Javascript 和 Ruby。如今,超过 75% 的 GitHub 项目有依赖,我们正在帮助你做更多的事情,而不只是关注那些重要的项目。在启用依赖关系图后,当我们检测到你的依赖中有漏洞或者来自 Github 社区中建议的已知修复时通知你。 + + [![Security Alerts & Suggested Fix](https://user-images.githubusercontent.com/594029/32851987-76c36e4a-c9eb-11e7-98fc-feb39fddaadb.gif)][1] + +### 如何开始使用安全警报 + +无论你的项目时私有还是公有的,安全警报都会为团队中的正确人员提供重要的漏洞信息。 + +启用你的依赖图 + +公开仓库将自动启用依赖关系图和安全警报。对于私人仓库,你需要在仓库设置中添加安全警报,或者在 “Insights” 选项卡中允许访问仓库的 “依赖关系图” 部分。 + +设置通知选项 + +启用依赖关系图后,管理员将默认收到安全警报。管理员还可以在依赖关系图设置中将团队或个人添加为安全警报的收件人。 + +警报响应 + +当我们通知你潜在的漏洞时,我们将突出显示我们建议更新的任何依赖关系。如果存在已知的安全版本,我们将使用机器学习和公开数据中选择一个,并将其包含在我们的建议中。 + +### 漏洞覆盖率 + +有 [CVE ID][2](公开披露的[国家漏洞数据库][3]中的漏洞)的漏洞将包含在安全警报中。但是,并非所有漏洞都有 CVE ID,甚至许多公开披露的漏洞也没有。随着安全数据的增长,我们将继续更好地识别漏洞。如需更多帮助来管理安全问题,请查看我们的[ GitHub Marketplace 中的安全合作伙伴][4]。 + +这是使用世界上最大的开源数据集的下一步,可以帮助你保持代码安全并做到最好。依赖关系图和安全警报目前支持 JavaScript 和 Ruby,并将在 2018 年提供 Python 支持。 + +[了解更多关于安全警报][5] + +-------------------------------------------------------------------------------- + +via: https://github.com/blog/2470-introducing-security-alerts-on-github + +作者:[mijuhan ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://github.com/mijuhan +[1]:https://user-images.githubusercontent.com/594029/32851987-76c36e4a-c9eb-11e7-98fc-feb39fddaadb.gif +[2]:https://cve.mitre.org/ +[3]:https://nvd.nist.gov/ +[4]:https://github.com/marketplace/category/security +[5]:https://help.github.com/articles/about-security-alerts-for-vulnerable-dependencies/ diff --git a/translated/tech/20171117 System Logs: Understand Your Linux System.md b/translated/tech/20171117 System Logs: Understand Your Linux System.md new file mode 100644 index 0000000000..dceea12a63 --- /dev/null +++ b/translated/tech/20171117 System Logs: Understand Your Linux System.md @@ -0,0 +1,68 @@ +### 系统日志: 了解你的Linux系统 + +![chabowski](https://www.suse.com/communities/blog/files/2016/03/chabowski_avatar_1457537819-100x100.jpg) + By: [chabowski][1] + +本文摘自教授Linux小白(或者非资深桌面用户)技巧的系列文章. 该系列文章旨在为由LinuxMagazine基于 [openSUSE Leap][3] 发布的第30期特别版 “[Getting Started with Linux][2]” 提供补充说明. + +本文作者是 Romeo S. Romeo, 他是一名 PDX-based enterprise Linux 专家,转为创新企业提供富有伸缩性的解决方案. + +Linux系统日志非常重要. 后台运行的程序(通常被称为守护进程或者服务进程)处理了你Linux系统中的大部分任务. 当这些守护进程工作时,它们将任务的详细信息记录进日志文件中,作为他们做过什么的历史信息. 这些守护进程的工作内容涵盖从使用原子钟同步时钟到管理网络连接. 所有这些都被记录进日志文件,这样当有错误发生时,你可以通过查阅特定的日志文件来看出发生了什么. + +![](https://www.suse.com/communities/blog/files/2017/11/markus-spiske-153537-300x450.jpg) + +Photo by Markus Spiske on Unsplash + +有很多不同的日志. 历史上, 他们一般以纯文本的格式存储到 `/var/log` 目录中. 现在依然有很多日志这样做, 你可以很方便的使用 `less` 来查看它们. +在新装的 `openSUSE Leap 42.3` 以及大多数现代操作系统上,重要的日志由 `systemd` 初始化系统存储. `systemd`这套系统负责启动守护进程并在系统启动时让计算机做好被使用的准备。 +由 `systemd` 记录的日志以二进制格式存储, 这使地它们消耗的空间更小,更容易被浏览,也更容易被导出成其他各种格式,不过坏处就是你必须使用特定的工具才能查看. +好在, 这个工具已经预安装在你的系统上了: 它的名字叫 `journalctl`,而且默认情况下, 它会将每个守护进程的所有日志都记录到一个地方. + +只需要运行 `journalctl` 命令就能查看你的 `systemd` 日志了. 它会用 `less` 分页器显示各种日志. 为了让你有个直观的感受, 下面是`journalctl` 中摘录的一条日志记录: + +``` +Jul 06 11:53:47 aaathats3as pulseaudio[2216]: [pulseaudio] alsa-util.c: Disabling timer-based scheduling because running inside a VM. +``` + +这条独立的日志记录以此包含了记录的日期和时间, 计算机名, 记录日志的进程名, 记录日志的进程PID, 以及日志内容本身. + +若系统中某个程序运行出问题了, 则可以查看日志文件并搜索(使用 “/” 加上要搜索的关键字)程序名称. 有可能导致该程序出问题的错误会记录到系统日志中. +有时,错误信息会足够详细让你能够修复该问题. 其他时候, 你需要在Web上搜索解决方案. Google就很适合来搜索奇怪的Linux问题. +![](https://www.suse.com/communities/blog/files/2017/09/Sunglasses_Emoji-450x450.png) +不过搜索时请注意你只输入了日志的内容, 行首的那些信息(日期, 主机名, 进程ID) 是无意义的,会干扰搜索结果. + +解决方法一般在搜索结果的前几个连接中就会有了. 当然,你不能只是无脑得运行从互联网上找到的那些命令: 请一定先搞清楚你要做的事情是什么,它的效果会是什么. +据说, 从系统日志中查询日志要比直接搜索描述故障的关键字要有用的多. 因为程序出错有很多原因, 而且同样的故障表现也可能由多种问题引发的. + +比如, 系统无法发声的原因有很多, 可能是播放器没有插好, 也可能是声音系统出故障了, 还可能是缺少合适的驱动程序. +如果你只是泛泛的描述故障表现, 你会找到很多无关的解决方法,而你也会浪费大量的时间. 而指定搜索日志文件中的内容, 你只会查询出他人也有相同日志内容的结果. +你可以对比一下图1和图2. + +![](https://www.suse.com/communities/blog/files/2017/11/picture1-450x450.png) + +图 1 搜索系统的故障表现只会显示泛泛的,不精确的结果. 这种搜索通常没什么用. + +![](https://www.suse.com/communities/blog/files/2017/11/picture2-450x450.png) + +图 2 搜索特定的日志行会显示出精确的,有用的结果. 这种搜索通常很有用. + +也有一些系统不用 `journalctl` 来记录日志. 在桌面系统中最常见的这类日志包括用于 `/var/log/zypper.log` 记录openSUSE包管理器的行为; `/var/log/boot.log` 记录系统启动时的消息,这类消息往往滚动的特别块,根本看不过来; `/var/log/ntp` 用来记录 Network Time Protocol 守护进程同步时间时发生的错误. +另一个存放硬件故障信息的地方是 `Kernel Ring Buffer`(内核环状缓冲区), 你可以输入 `demesg -H` 命令来查看(这条命令也会调用 `less` 分页器来查看). +`Kernel Ring Buffer` 存储在内存中, 因此会在重启电脑后丢失. 不过它包含了Linux内核中的重要事件, 比如新增了硬件, 加载了模块, 以及奇怪的网络错误. + +希望你已经准备好深入了解你的Linux系统了! 祝你玩的开心! + +-------------------------------------------------------------------------------- + +via: https://www.suse.com/communities/blog/system-logs-understand-linux-system/ + +作者:[chabowski] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://www.suse.com/communities/blog/author/chabowski/ +[2]:http://www.linux-magazine.com/Resources/Special-Editions/30-Getting-Started-with-Linux +[3]:https://en.opensuse.org/Portal:42.3 +[4]:http://www.linux-magazine.com/ diff --git a/translated/tech/20171124 How to Install Android File Transfer for Linux.md b/translated/tech/20171124 How to Install Android File Transfer for Linux.md deleted file mode 100644 index b93429f509..0000000000 --- a/translated/tech/20171124 How to Install Android File Transfer for Linux.md +++ /dev/null @@ -1,82 +0,0 @@ -Translating by wenwensnow - -# 如何在Linux下安装安卓文件传输助手 - -如果你尝试在Ubuntu下安装你的安卓手机,你也许可以试试Linux下的安卓文件传输助手 - -本质上来说,这个应用是谷歌mac版本的一个复制。它是用Qt编写的,用户界面非常简洁,使得你能轻松在Ubuntu和安卓手机之间传输文件。 - -现在,有可能一部分人想知道有什么是这个应用可以做,而Nautilus(Ubuntu默认的文件资源管理器)不能做的,答案是没有。 - -当我将我的 Nexus 5X(记得选择[MTP][7] 选项)连接在Ubuntu上时,在[GVfs][8](Gnome桌面下的虚拟文件系统)的帮助下,我可以打开,浏览和管理我的手机, 就像它是一个普通的U盘一样。 - - [![Nautilus MTP integration with a Nexus 5X](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg)][9] - -但是一些用户在使用默认的文件管理器时,在MTP的某些功能上会出现问题:比如文件夹没有正确加载,创建新文件夹后此文件夹不存在,或者无法在媒体播放器中使用自己的手机。 - -这就是要为Linux系统用户设计一个安卓文件传输助手应用的原因。将这个应用当做将MTP设备安装在Linux下的另一种选择。如果你使用Linux下的默认应用时一切正常,你也许并不需要尝试使用它 (除非你真的很想尝试新鲜事物)。 - - -![Android File Transfer Linux App](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/android-file-transfer-for-linux-750x662.jpg) - -app特点: - -*   简洁直观的用户界面 - -*   支持文件拖放功能(从Linux系统到手机) - -*   支持批量下载 (从手机到Linux系统) - -*   显示传输进程对话框 - -*   FUSE模块支持 - -*   没有文件大小限制 - -*   可选命令行工具 - -### Ubuntu下安装安卓手机文件助手的步骤 - -以上就是对这个应用的介绍,下面是如何安装它的具体步骤。 - -这有一个[PPA](个人软件包集)源为Ubuntu 14.04 LTS(长期支持版本),16.04LTS 和 Ubuntu17.10 提供可用应用 - -为了将这一PPA加入你的软件资源列表中,执行这条命令: - -``` -sudo add-apt-repository ppa:samoilov-lex/aftl-stable -``` - -接着,为了在Ubuntu下安装Linux版本的安卓文件传输助手,执行: - -``` -sudo apt-get update && sudo apt install android-file-transfer -``` - -这样就行了。 - -你会在你的应用列表中发现这一应用的启动图标。 - -在你启动这一应用之前,要确保没有其他应用(比如Nautilus)已经加载了你的手机.如果其他应用正在使用你的手机,就会显示“无法找到MTP设备”。为了解决这一问题,将你的手机从Nautilus(或者任何正在使用你的手机的应用)上移除,然后再重新启动安卓文件传输助手。 - --------------------------------------------------------------------------------- - -via: http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux - -作者:[ JOEY SNEDDON ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://plus.google.com/117485690627814051450/?rel=author -[1]:https://plus.google.com/117485690627814051450/?rel=author -[2]:http://www.omgubuntu.co.uk/category/app -[3]:http://www.omgubuntu.co.uk/category/download -[4]:https://github.com/whoozle/android-file-transfer-linux -[5]:http://www.omgubuntu.co.uk/2017/11/android-file-transfer-app-linux -[6]:http://android.com/filetransfer?linkid=14270770 -[7]:https://en.wikipedia.org/wiki/Media_Transfer_Protocol -[8]:https://en.wikipedia.org/wiki/GVfs -[9]:http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/browsing-android-mtp-nautilus.jpg -[10]:https://launchpad.net/~samoilov-lex/+archive/ubuntu/aftl-stable diff --git a/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md new file mode 100644 index 0000000000..e51c580da9 --- /dev/null +++ b/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md @@ -0,0 +1,147 @@ +Photon也许能成为你最喜爱的容器操作系统 +============================================================ + +![Photon OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon-linux.jpg?itok=jUFHPR_c "Photon OS") + +Phonton OS专注于容器,是一个非常出色的平台。 —— Jack Wallen + +容器在当下的火热,并不是没有原因的。正如[之前][13]讨论的,容器可以使您轻松快捷地将新的服务与应用部署到您的网络上,而且并不耗费太多的系统资源。比起专用硬件和虚拟机,容器都是更加划算的,除此之外,他们更容易更新与重用。 + +更重要的是,容器喜欢Linux(反之亦然)。不需要太多时间和麻烦,你就可以启动一台Linux服务器,运行[Docker][14],再是部署容器。但是,哪种Linux发行版最适合部署容器呢?我们的选择很多。你可以使用标准的Ubuntu服务器平台(更容易安装Docker并部署容器)或者是更轻量级的发行版 —— 专门用于部署容器。 + +[Photon][15]就是这样的一个发行版。这个特殊的版本是由[VMware][16]于2005年创建的,它包含了Docker的守护进程,并与容器框架(如Mesos和Kubernetes)一起使用。Photon经过优化可与[VMware vSphere][17]协同工作,而且可用于裸机,[Microsoft Azure][18], [Google Compute Engine][19], [Amazon Elastic Compute Cloud][20], 或者 [VirtualBox][21]等。 + +Photon通过只安装Docker守护进程所必需的东西来保持它的轻量。而这样做的结果是,这个发行版的大小大约只有300MB。但这足以让Linux的运行一切正常。除此之外,Photon的主要特点还有: + +* 内核调整为性能模式。 + +* 内核根据[内核自防护项目][6](KSPP)进行了加固。 + +* 所有安装的软件包都根据加固的安全标识来构建。 + +* 操作系统在信任验证后启动。 + +* Photon管理进程管理防火墙,网络,软件包,和远程登录在Photon机子上的用户。 + +* 支持持久卷。 + +* [Project Lightwave][7] 整合。 + +* 及时的安全补丁与更新。 + +Photon可以通过[ISO][22],[OVA][23],[Amazon Machine Image][24],[Google Compute Engine image][25]和[Azure VHD][26]安装使用。现在我将向您展示如何使用ISO镜像在VirtualBox上安装Photon。整个安装过程大概需要五分钟,在最后您将有一台随时可以部署容器的虚拟机。 + +### 创建虚拟机 + +在部署第一台容器之前,您必须先创建一台虚拟机并安装Photon。为此,打开VirtualBox并点击“新建”按钮。跟着创建虚拟机向导进行配置(根据您的容器将需要的用途,为Photon提供必要的资源)。在创建好虚拟机后,您所需要做的第一件事就是更改配置。选择新建的虚拟机(在VirtualBox主窗口的左侧面板中),然后单击“设置”。在弹出的窗口中,点击“网络”(在左侧的导航中)。 + +在“网络”窗口(图1)中,你需要在“连接”的下拉窗口中选择桥接。这可以确保您的Photon服务与您的网络相连。完成更改后,单击确定。 + +### [photon_0.jpg][8] + +![change settings](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_0.jpg?itok=Q0yhOhsZ "change setatings") +图 1: 更改Photon在VirtualBox中的网络设置。[经许可使用][1] + +从左侧的导航选择您的Photon虚拟机,点击启动。系统会提示您去加载IOS镜像。当您完成之后,Photon安装程序将会启动并提示您按回车后开始安装。安装过程基于ncurses(没有GUI),但它非常简单。 + +接下来(图2),系统会询问您是要最小化安装,完整安装还是安装OSTree服务器。我选择了完整安装。选择您所需要的任意选项,然后按回车继续。 + +### [photon_1.jpg][9] + +![installation type](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_2.jpg?itok=QL1Rs-PH "Photon") +图 2: 选择您的安装类型.[经许可使用][2] + +在下一个窗口,选择您要安装Photon的磁盘。由于我们将其安装在虚拟机,因此只有一块磁盘会被列出(图3)。选择“自动”按下回车。然后安装程序会让您输入(并验证)管理员密码。在这之后镜像开始安装在您的磁盘上并在不到5分钟的时间内结束。 + +### [photon_2.jpg][] + +![Photon](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_1.jpg?itok=OdnMVpaA "installation type") +图 3: 选择安装Photon的硬盘.[经许可使用][3] + +安装完成后,重启虚拟机并使用安装时创建的用户root和它的密码登录。一切就绪,你准备好开始工作了。 + +在开始使用Docker之前,您需要更新一下Photon。Photon使用 _yum_ 软件包管理器,因此在以root用户登录后输入命令 _yum update_。如果有任何可用更新,则会询问您是否确认(图4)。 + +### [photon_3.jpg][11] + +![Updating](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_3.jpg?itok=vjqrspE2 "Updating") +图 4: 更新 Photon.[经许可使用][4] + +用法 + +正如我所说的,Photon提供了部署容器甚至创建Kubernetes集群所需要的所有包。但是,在使用之前还要做一些事情。首先要启动Docker守护进程。为此,执行以下命令: + +``` +systemctl start docker + +systemctl enable docker +``` + +现在我们需要创建一个标准用户,因此我们没有以root去运行docker命令。为此,执行以下命令: + +``` +useradd -m USERNAME + +passwd USERNAME +``` + +其中USERNAME是我们新增的用户的名称。 + +接下来,我们需要将这个新用户添加到 _docker_ 组,执行命令: + +``` +usermod -a -G docker USERNAME +``` + +其中USERNAME是刚刚创建的用户的名称。 + +注销root用户并切换为新增的用户。现在,您已经可以不必使用 _sudo_ 命令或者是切换到root用户来使用 _docker_命令了。从Docker Hub中取出一个镜像开始部署容器吧。 + +### 一个优秀的容器平台 + +在专注于容器方面,Photon毫无疑问是一个出色的平台。请注意,Photon是一个开源项目,因此没有任何付费支持。如果您对Photon有任何的问题,请移步Photon项目的Github下的[Issues][27],那里可以供您阅读相关问题,或者提交您的问题。如果您对Photon感兴趣,您也可以在项目的官方[Github][28]中找到源码。 + +尝试一下Photon吧,看看它是否能够使得Docker容器和Kubernetes集群的部署更加容易。 + +欲了解Linux的更多信息,可以通过学习Linux基金会和edX的免费课程,[“Linux 入门”][29]。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2017/11/photon-could-be-your-new-favorite-container-os + +作者:[JACK WALLEN][a] +译者:[KeyLD](https://github.com/KeyLd) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/jlwallen +[1]:https://www.linux.com/licenses/category/used-permission +[2]:https://www.linux.com/licenses/category/used-permission +[3]:https://www.linux.com/licenses/category/used-permission +[4]:https://www.linux.com/licenses/category/used-permission +[5]:https://www.linux.com/licenses/category/creative-commons-zero +[6]:https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project +[7]:http://vmware.github.io/lightwave/ +[8]:https://www.linux.com/files/images/photon0jpg +[9]:https://www.linux.com/files/images/photon1jpg +[10]:https://www.linux.com/files/images/photon2jpg +[11]:https://www.linux.com/files/images/photon3jpg +[12]:https://www.linux.com/files/images/photon-linuxjpg +[13]:https://www.linux.com/learn/intro-to-linux/2017/11/how-install-and-use-docker-linux +[14]:https://www.docker.com/ +[15]:https://vmware.github.io/photon/ +[16]:https://www.vmware.com/ +[17]:https://www.vmware.com/products/vsphere.html +[18]:https://azure.microsoft.com/ +[19]:https://cloud.google.com/compute/ +[20]:https://aws.amazon.com/ec2/ +[21]:https://www.virtualbox.org/ +[22]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[23]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[24]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[25]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[26]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS +[27]:https://github.com/vmware/photon/issues +[28]:https://github.com/vmware/photon +[29]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/translated/tech/20171130 New Feature Find every domain someone owns automatically.md b/translated/tech/20171130 New Feature Find every domain someone owns automatically.md new file mode 100644 index 0000000000..4b72eaae5e --- /dev/null +++ b/translated/tech/20171130 New Feature Find every domain someone owns automatically.md @@ -0,0 +1,49 @@ +新功能:自动找出每个域名的拥有者 +============================================================ + + +今天,我们很高兴地宣布我们最近几周做的新功能。它是 Whois 聚合工具,现在可以在 [DNSTrails][1] 上获得。 + +在过去,查找一个域名的所有者会花费很多时间,因为大部分时间你都需要把域名指向一个 IP 地址,以便找到同一个人拥有的其他域名。 + +使用老的方法,你会很轻易地在一个工具和另外一个工具的研究和交叉比较结果中花费数个小时,直到得到你想要的域名。 + +感谢这个新工具和我们的智能[WHOIS 数据库][2],现在你可以搜索任何域名,并获得组织或个人注册的域名的完整列表,并在几秒钟内获得准确的结果。 + +### 我如何使用Whois聚合功能? + +第一步:打开 [DNSTrails.com][3] + +第二步:搜索任何域名,比如:godaddy.com + +第三步:在得到域名的结果后,如下所见,定位下面的 Whois 信息: + +![Domain name search results](https://securitytrails.com/images/a/a/1/3/f/aa13fa3616b8dc313f925bdbf1da43a54856d463-image1.png) + +第四步:你会看到那里有有关域名的电话和电子邮箱地址。 + +第五步:点击右边的链接,你会轻松地找到用相同电话和邮箱注册的域名。 + +![All domain names by the same owner](https://securitytrails.com/images/1/3/4/0/3/134037822d23db4907d421046b11f3cbb872f94f-image2.png) + +如果你正在调查互联网上任何个人的域名所有权,这意味着即使域名甚至没有指向注册服务商的 IP,如果他们使用相同的电话和邮件地址,我们仍然可以发现其他域名。 + +想知道一个人拥有的其他域名么?亲自试试 [DNStrails][5] 的[ WHOIS 聚合功能][4]或者[使用我们的 API 访问][6]。 + +-------------------------------------------------------------------------------- + +via: https://securitytrails.com/blog/find-every-domain-someone-owns + +作者:[SECURITYTRAILS TEAM ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://securitytrails.com/blog/find-every-domain-someone-owns +[1]:https://dnstrails.com/ +[2]:https://securitytrails.com/forensics +[3]:https://dnstrails.com/ +[4]:http://dnstrails.com/#/domain/domain/ueland.com +[5]:https://dnstrails.com/ +[6]:https://securitytrails.com/contact diff --git a/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md b/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md new file mode 100644 index 0000000000..9f905bd496 --- /dev/null +++ b/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md @@ -0,0 +1,400 @@ +Translate Shell: 一款在 Linux 命令行中使用 Google Translate的工具 +============================================================ + +我对 CLI 应用非常感兴趣,因此热衷于使用并分享 CLI 应用。 我之所以更喜欢 CLI 很大原因是因为我在大多数的时候都使用的是字符界面(black screen),已经习惯了使用 CLI 应用而不是 GUI 应用. + +我写过很多关于 CLI 应用的文章。 最近我发现了一些 google 的 CLI 工具,像 “Google Translator”, “Google Calendar”, 和 “Google Contacts”。 这里,我想在给大家分享一下。 + +今天我们要介绍的是 “Google Translator” 工具。 由于母语是泰米尔语,我在一天内用了很多次才理解了它的意义。 + +`Google translate` 为其他语系的人们所广泛使用。 + +### 什么是 Translate Shell + +[Translate Shell][2] (之前叫做 Google Translate CLI) 是一款借助 `Google Translate`(默认), `Bing Translator`, `Yandex.Translate` 以及 `Apertium` 来翻译的命令行翻译器。 +它让你可以在终端访问这些翻译引擎. `Translate Shell` 在大多数Linux发行版中都能使用。 + +### 如何安装 Translate Shell + +有三种方法安装 `Translate Shell`。 + +* 下载自包含的可执行文件 + +* 手工安装 + +* 通过包挂力气安装 + +#### 方法-1 : 下载自包含的可执行文件 + +下载自包含的可执行文件放到 `/usr/bin` 目录中。 + +```shell +$ wget git.io/trans +$ chmod +x ./trans +$ sudo mv trans /usr/bin/ +``` + +#### 方法-2 : 手工安装 + +克隆 `Translate Shell` github 仓库然后手工编译。 + +```shell +$ git clone https://github.com/soimort/translate-shell && cd translate-shell +$ make +$ sudo make install +``` + +#### 方法-3 : Via Package Manager + +有些发行版的官方仓库中包含了 `Translate Shell`,可以通过包管理器来安装。 + +对于 Debian/Ubuntu, 使用 [APT-GET Command][3] 或者 [APT Command][4]来安装。 + +```shell +$ sudo apt-get install translate-shell +``` + +对于 Fedora, 使用 [DNF Command][5] 来安装。 + +```shell +$ sudo dnf install translate-shell +``` + +对于基于 Arch Linux 的系统, 使用 [Yaourt Command][6] 或 [Packer Command][7] 来从 AUR 仓库中安装。 + +```shell +$ yaourt -S translate-shell +or +$ packer -S translate-shell +``` + +### 如何使用 Translate Shell + +安装好后,打开终端闭关输入下面命令。 `Google Translate` 会自动探测源文本是哪种语言,并且在默认情况下将之翻译成你的 `locale` 所对应的语言。 + +``` +$ trans [Words] +``` + +下面我将泰米尔语中的单词 “நன்றி” (Nanri) 翻译成英语。 这个单词的意思是感谢别人。 + +``` +$ trans நன்றி +நன்றி +(Naṉṟi) + +Thanks + +Definitions of நன்றி +[ தமிழ் -> English ] + +noun + gratitude + நன்றி + thanks + நன்றி + +நன்றி + Thanks +``` + +使用下面命令也能将英语翻译成泰米尔语。 + +``` +$ trans :ta thanks +thanks +/THaNGks/ + +நன்றி +(Naṉṟi) + +Definitions of thanks +[ English -> தமிழ் ] + +noun + நன்றி + gratitude, thanks + +thanks + நன்றி +``` + +要将一个单词翻译到多个语种可以使用下面命令(本例中, 我将单词翻译成泰米尔语以及印地语)。 + +``` +$ trans :ta+hi thanks +thanks +/THaNGks/ + +நன்றி +(Naṉṟi) + +Definitions of thanks +[ English -> தமிழ் ] + +noun + நன்றி + gratitude, thanks + +thanks + நன்றி + +thanks +/THaNGks/ + +धन्यवाद +(dhanyavaad) + +Definitions of thanks +[ English -> हिन्दी ] + +noun + धन्यवाद + thanks, thank, gratitude, thankfulness, felicitation + +thanks + धन्यवाद, शुक्रिया +``` + +使用下面命令可以将多个单词当成一个参数(句子)来进行翻译。(只需要把句子应用起来作为一个参数就行了)。 + +``` +$ trans :ta "what is going on your life?" +what is going on your life? + +உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? +(Uṅkaḷ vāḻkkaiyil eṉṉa naṭakkiṟatu?) + +Translations of what is going on your life? +[ English -> தமிழ் ] + +what is going on your life? + உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? +``` + +下面命令独立地翻译各个单词。 + +``` +$ trans :ta curios happy +curios + +ஆர்வம் +(Ārvam) + +Translations of curios +[ Română -> தமிழ் ] + +curios + ஆர்வம், அறிவாளிகள், ஆர்வமுள்ள, அறிய, ஆர்வமாக +happy +/ˈhapē/ + +சந்தோஷமாக +(Cantōṣamāka) + +Definitions of happy +[ English -> தமிழ் ] + + மகிழ்ச்சியான + happy, convivial, debonair, gay + திருப்தி உடைய + happy + +adjective + இன்பமான + happy + +happy + சந்தோஷமாக, மகிழ்ச்சி, இனிய, சந்தோஷமா +``` + +简洁模式: 默认情况下,`Translate Shell` 尽可能多的显示翻译信息. 如果你希望只显示简要信息,只需要加上`-b`选项。 + +``` +$ trans -b :ta thanks +நன்றி +``` + +字典模式: 加上 `-d` 可以把 `Translate Shell` 当成字典来用. + +``` +$ trans -d :en thanks +thanks +/THaNGks/ + +Synonyms + noun + - gratitude, appreciation, acknowledgment, recognition, credit + + exclamation + - thank you, many thanks, thanks very much, thanks a lot, thank you kindly, much obliged, much appreciated, bless you, thanks a million + +Examples + - In short, thanks for everything that makes this city great this Thanksgiving. + + - many thanks + + - There were no thanks in the letter from him, just complaints and accusations. + + - It is a joyful celebration in which Bolivians give thanks for their freedom as a nation. + + - festivals were held to give thanks for the harvest + + - The collection, as usual, received a great response and thanks is extended to all who subscribed. + + - It would be easy to dwell on the animals that Tasmania has lost, but I prefer to give thanks for what remains. + + - thanks for being so helpful + + - It came back on about half an hour earlier than predicted, so I suppose I can give thanks for that. + + - Many thanks for the reply but as much as I tried to follow your advice, it's been a bad week. + + - To them and to those who have supported the office I extend my grateful thanks . + + - We can give thanks and words of appreciation to others for their kind deeds done to us. + + - Adam, thanks for taking time out of your very busy schedule to be with us tonight. + + - a letter of thanks + + - Thank you very much for wanting to go on reading, and thanks for your understanding. + + - Gerry has received a letter of thanks from the charity for his part in helping to raise this much needed cash. + + - So thanks for your reply to that guy who seemed to have a chip on his shoulder about it. + + - Suzanne, thanks for being so supportive with your comments on my blog. + + - She has never once acknowledged my thanks , or existence for that matter. + + - My grateful thanks go to the funders who made it possible for me to travel. + + - festivals were held to give thanks for the harvest + + - All you secretaries who made it this far into the article… thanks for your patience. + + - So, even though I don't think the photos are that good, thanks for the compliments! + + - And thanks for warning us that your secret service requires a motorcade of more than 35 cars. + + - Many thanks for your advice, which as you can see, I have passed on to our readers. + + - Tom Ryan was given a bottle of wine as a thanks for his active involvement in the twinning project. + + - Mr Hill insists he has received no recent complaints and has even been sent a letter of thanks from the forum. + + - Hundreds turned out to pay tribute to a beloved former headteacher at a memorial service to give thanks for her life. + + - Again, thanks for a well written and much deserved tribute to our good friend George. + + - I appreciate your doing so, and thanks also for the compliments about the photos! + +See also + Thanks!, thank, many thanks, thanks to, thanks to you, special thanks, give thanks, thousand thanks, Many thanks!, render thanks, heartfelt thanks, thanks to this +``` + +使用下面格式可以使用 `Translate Shell` 来翻译文件。 + +```shell +$ trans :ta file:///home/magi/gtrans.txt +உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? +``` + +下面命令可以让 `Translate Shell` 进入交互模式. 在进入交互模式之前你需要明确指定源语言和目标语言。本例中,我将英文单词翻译成泰米尔语。 + +``` +$ trans -shell en:ta thanks +Translate Shell +(:q to quit) +thanks +/THaNGks/ + +நன்றி +(Naṉṟi) + +Definitions of thanks +[ English -> தமிழ் ] + +noun + நன்றி + gratitude, thanks + +thanks + நன்றி +``` + +想知道语言代码,可以执行下面语言。 + +```shell +$ trans -R +``` +或者 +```shell +$ trans -T +┌───────────────────────┬───────────────────────┬───────────────────────┐ +│ Afrikaans - af │ Hindi - hi │ Punjabi - pa │ +│ Albanian - sq │ Hmong - hmn │ Querétaro Otomi- otq │ +│ Amharic - am │ Hmong Daw - mww │ Romanian - ro │ +│ Arabic - ar │ Hungarian - hu │ Russian - ru │ +│ Armenian - hy │ Icelandic - is │ Samoan - sm │ +│ Azerbaijani - az │ Igbo - ig │ Scots Gaelic - gd │ +│ Basque - eu │ Indonesian - id │ Serbian (Cyr...-sr-Cyrl +│ Belarusian - be │ Irish - ga │ Serbian (Latin)-sr-Latn +│ Bengali - bn │ Italian - it │ Sesotho - st │ +│ Bosnian - bs │ Japanese - ja │ Shona - sn │ +│ Bulgarian - bg │ Javanese - jv │ Sindhi - sd │ +│ Cantonese - yue │ Kannada - kn │ Sinhala - si │ +│ Catalan - ca │ Kazakh - kk │ Slovak - sk │ +│ Cebuano - ceb │ Khmer - km │ Slovenian - sl │ +│ Chichewa - ny │ Klingon - tlh │ Somali - so │ +│ Chinese Simp...- zh-CN│ Klingon (pIqaD)tlh-Qaak Spanish - es │ +│ Chinese Trad...- zh-TW│ Korean - ko │ Sundanese - su │ +│ Corsican - co │ Kurdish - ku │ Swahili - sw │ +│ Croatian - hr │ Kyrgyz - ky │ Swedish - sv │ +│ Czech - cs │ Lao - lo │ Tahitian - ty │ +│ Danish - da │ Latin - la │ Tajik - tg │ +│ Dutch - nl │ Latvian - lv │ Tamil - ta │ +│ English - en │ Lithuanian - lt │ Tatar - tt │ +│ Esperanto - eo │ Luxembourgish - lb │ Telugu - te │ +│ Estonian - et │ Macedonian - mk │ Thai - th │ +│ Fijian - fj │ Malagasy - mg │ Tongan - to │ +│ Filipino - tl │ Malay - ms │ Turkish - tr │ +│ Finnish - fi │ Malayalam - ml │ Udmurt - udm │ +│ French - fr │ Maltese - mt │ Ukrainian - uk │ +│ Frisian - fy │ Maori - mi │ Urdu - ur │ +│ Galician - gl │ Marathi - mr │ Uzbek - uz │ +│ Georgian - ka │ Mongolian - mn │ Vietnamese - vi │ +│ German - de │ Myanmar - my │ Welsh - cy │ +│ Greek - el │ Nepali - ne │ Xhosa - xh │ +│ Gujarati - gu │ Norwegian - no │ Yiddish - yi │ +│ Haitian Creole - ht │ Pashto - ps │ Yoruba - yo │ +│ Hausa - ha │ Persian - fa │ Yucatec Maya - yua │ +│ Hawaiian - haw │ Polish - pl │ Zulu - zu │ +│ Hebrew - he │ Portuguese - pt │ │ +└───────────────────────┴───────────────────────┴───────────────────────┘ +``` + +想了解更多选项的内容,可以查看 `man` 页. + +```shell +$ man trans +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/translate-shell-a-tool-to-use-google-translate-from-command-line-in-linux/ + +作者:[Magesh Maruthamuthu][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.2daygeek.com/author/magesh/ +[2]:https://github.com/soimort/translate-shell +[3]:https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[4]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[5]:https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ +[6]:https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/ +[7]:https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/ diff --git a/translated/tech/20171201 Linux Journal Ceases Publication.md b/translated/tech/20171201 Linux Journal Ceases Publication.md new file mode 100644 index 0000000000..2eb5c82f51 --- /dev/null +++ b/translated/tech/20171201 Linux Journal Ceases Publication.md @@ -0,0 +1,34 @@ +Linux Journal 停止发行 +============================================================ + +EOF + +伙计们,看起来我们要到终点了。如果按照计划而且没有什么其他的话,十一月份的 Linux Journal 将是我们的最后一期。 + +简单的事实是,我们已经用完了钱和期权。我们从来没有一个富有的母公司或者自己深厚的资金,从开始到结束,这使得我们变成一个反常的出版商。虽然我们在很长的一段时间内运营着,但当天平不可恢复地最终向相反方向倾斜时,我们在十一月份失去了最后一点支持。 + +虽然我们像看到出版业的过去那样看到出版业的未来 - 广告商赞助出版物的时代,因为他们重视品牌和读者 - 我们如今的广告宁愿追逐眼球,最好是在读者的浏览器中植入跟踪标记,并随时随地展示那些广告。但是,未来不是这样,过去的已经过去了。 + +我们猜想,有一个希望,那就是救世主可能会会来。但除了我们的品牌、我们的档案,我们的域名、我们的用户和读者之外,还必须是愿意承担我们一部分债务的人。如果你认识任何人能够提供认真的报价,请告诉我们。不然,请观看 LinuxJournal.com,并希望至少我们的遗留归档(可以追溯到 Linux Journal 诞生的 1994 年 4 月,当 Linux 命中 1.0 发布时)将不会消失。这里有很多很棒的东西,还有很多我们会痛恨世界失去的历史。 + +我们最大的遗憾是,我们甚至没有足够的钱回馈最看重我们的人:我们的用户。为此,我们不能更深刻或真诚地道歉。我们对订阅者而言有什么: + +Linux Pro Magazine 为我们的用户提供了六本免费的杂志,我们在 Linux Journal 上一直赞叹这点。在我们需要的时候,他们是我们的第一批人,我们感谢他们的恩惠。我们今天刚刚完成了我们的 2017 年归档,其中包括我们曾经发表过的每一个问题,包括第一个和最后一个。通常我们以 25 美元的价格出售,但显然用户将免费获得。订阅者请注意有关两者的详细信息的电子邮件。 + +我们也希望在知道我们非常非常努力地让 Linux Journal 进行下去后能有一些安慰 ,而且我们已经用最精益、小的可能运营了很长一段时间。我们是一个大多数是自愿者的组织,有些员工已经几个月没有收到工资。我们还欠钱给自由职业者。这时一个限制发行商能够维持多长时间的限制,现在这个限制已经到头了。 + +伙计们,这是一个伟大的运营。乡亲。对每一个为我们的诞生、我们的成功和我们多年的坚持作出贡献的人致敬。我们列了一份名单,但是列表太长了,并且漏掉有价值的人的风险很高。你知道你是谁。我们再次感谢。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxjournal.com/content/linux-journal-ceases-publication + +作者:[ Carlie Fairchild][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linuxjournal.com/users/carlie-fairchild +[1]:https://www.linuxjournal.com/taxonomy/term/29 +[2]:https://www.linuxjournal.com/users/carlie-fairchild diff --git a/translated/tech/Linux Networking Hardware for Beginners: Think Software b/translated/tech/Linux Networking Hardware for Beginners: Think Software new file mode 100644 index 0000000000..a236a80e97 --- /dev/null +++ b/translated/tech/Linux Networking Hardware for Beginners: Think Software @@ -0,0 +1,89 @@ +Translating by FelixYFZ + +面向初学者的Linux网络硬件: 软件工程思想 +============================================================ + +![island network](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/soderskar-island.jpg?itok=wiMaF66b "island network") + 没有路由和桥接,我们将会成为孤独的小岛,你将会在这个网络教程中学到更多知识。 +Commons Zero][3]Pixabay + + 上周,我们学习了本地网络硬件知识,本周,我们将学习网络互联技术和在移动网络中的一些很酷的黑客技术。 +### Routers:路由器 + + +网络路由器就是计算机网络中的一切,因为路由器连接着网络,没有路由器,我们就会成为孤岛, + +图一展示了一个简单的有线本地网络和一个无线接入点,所有设备都接入到Internet上,本地局域网的计算机连接到一个连接着防火墙或者路由器的以太网交换机上,防火墙或者路由器连接到网络服务供应商提供的电缆箱,调制调节器,卫星上行系统...好像一切都在计算中,就像是一个带着不停闪烁的的小灯的盒子,当你的网络数据包离开你的局域网,进入广阔的互联网,它们穿过一个又一个路由器直到到达自己的目的地。 + + +### [fig-1.png][4] + +![simple LAN](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_7.png?itok=lsazmf3- "simple LAN") + +图一:一个简单的有线局域网和一个无线接入点。 + +一台路由器能连接一切,一个小巧特殊的小盒子只专注于路由,一个大点的盒子将会提供路由,防火墙,域名服务,以及VPN网关功能,一台重新设计的台式电脑或者笔记本,一个树莓派计算机或者一个小模块,体积臃肿矮小的像PC这样的单板计算机,除了苛刻的用途以外,普通的商品硬件都能良好的工作运行。高端的路由器使用特殊设计的硬件每秒能够传输最大量的数据包。 它们有多路数据总线,多个中央处理器和极快的存储。 +可以通过查阅Juniper和思科的路由器来感受一下高端路由器书什么样子的,而且能看看里面是什么样的构造。 +一个接入你的局域网的无线接入点要么作为一个以太网网桥要么作为一个路由器。一个桥接器扩展了这个网络,所以在这个桥接器上的任意一端口上的主机都连接在同一个网络中。 +一台路由器连接的是两个不同的网络。 +### Network Topology:网络拓扑 + + +有多种设置你的局域网的方式,你可以把所有主机接入到一个单独的平面网络,如果你的交换机支持的话,你也可以把它们分配到不同的子网中。 +平面网络是最简单的网络,只需把每一台设备接入到同一个交换机上即可,如果一台交换上的端口不够使用,你可以将更多的交换机连接在一起。 +有些交换机有特殊的上行端口,有些是没有这种特殊限制的上行端口,你可以连接其中的任意端口,你可能需要使用交叉类型的以太网线,所以你要查阅你的交换机的说明文档来设置。平面网络是最容易管理的,你不需要路由器也不需要计算子网,但它也有一些缺点。他们的伸缩性不好,所以当网络规模变得越来越大的时候就会被广播网络所阻塞。 +将你的局域网进行分段将会提升安全保障, 把局域网分成可管理的不同网段将有助于管理更大的网络。 + 图2展示了一个分成两个子网的局域网络:内部的有线和无线主机,和非军事区域(从来不知道所所有的工作上的男性术语都是在计算机上键入的?)因为他被阻挡了所有的内部网络的访问。 + + +### [fig-2.png][5] + +![LAN](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-2_4.png?itok=LpXq7bLf "LAN") + +图2:一个分成两个子网的简单局域网。 +即使像图2那样的小型网络也可以有不同的配置方法。你可以将防火墙和路由器放置在一台单独的设备上。 +你可以为你的非军事区域设置一个专用的网络连接,把它完全从你的内部网络隔离,这将引导我们进入下一个主题:一切基于软件。 + + +### Think Software软件思维 + + +你可能已经注意到在这个简短的系列中我们所讨论的硬件,只有网络接口,交换机,和线缆是特殊用途的硬件。 +其它的都是通用的商用硬件,而且都是软件来定义它的用途。 +网关,虚拟专用网关,以太网桥,网页,邮箱以及文件等等。 +服务器,负载均衡,代理,大量的服务,各种各样的认证,中继,故障转移...你可以在运行着Linux系统的标准硬件上运行你的整个网络。 +你甚至可以使用Linux交换应用和VDE2协议来模拟以太网交换机,像DD-WRT,openWRT 和Rashpberry Pi distros,这些小型的硬件都是有专业的分类的,要记住BSDS和它们的特殊衍生用途如防火墙,路由器,和网络附件存储。 +你知道有些人坚持认为硬件防火墙和软件防火墙有区别?其实是没有区别的,就像说有一台硬件计算机和一台软件计算机。 +### Port Trunking and Ethernet Bonding +端口聚合和以太网绑定 +聚合和绑定,也称链路聚合,是把两条以太网通道绑定在一起成为一条通道。一些交换机支持端口聚合,就是把两个交换机端口绑定在一起成为一个是他们原来带宽之和的一条新的连接。对于一台承载很多业务的服务器来说这是一个增加通道带宽的有效的方式。 +你也可以在以太网口进行同样的配置,而且绑定汇聚的驱动是内置在Linux内核中的,所以不需要任何其他的专门的硬件。 + + +### Bending Mobile Broadband to your Will随心所欲选择你的移动带宽 + +我期望移动带宽能够迅速增长来替代DSL和有线网络。我居住在一个有250,000人口的靠近一个城市的地方,但是在城市以外,要想接入互联网就要靠运气了,即使那里有很大的用户上网需求。我居住的小角落离城镇有20分钟的距离,但对于网络服务供应商来说他们几乎不会考虑到为这个地方提供网络。 我唯一的选择就是移动带宽; 这里没有拨号网络,卫星网络(即使它很糟糕)或者是DSL,电缆,光纤,但却没有阻止网络供应商把那些在我这个区域从没看到过的无限制通信个其他高速网络服务的传单塞进我的邮箱。 +我试用了AT&T,Version,和T-Mobile。Version的信号覆盖范围最广,但是Version和AT&T是最昂贵的。 +我居住的地方在T-Mobile信号覆盖的边缘,但迄今为止他们给了最大的优惠,为了能够能够有效的使用,我必须购买一个WeBoostDe信号放大器和 +一台中兴的移动热点设备。当然你也可以使用一部手机作为热点,但是专用的热点设备有着最强的信号。如果你正在考虑购买一台信号放大器,最好的选择就是WeBoost因为他们的服务支持最棒,而且他们会尽最大努力去帮助你。在一个小小的APP的协助下去设置将会精准的增强 你的网络信号,他们有一个功能较少的免费的版本,但你将一点都不会后悔去花两美元使用专业版。 +那个小巧的中兴热点设备能够支持15台主机而且还有拥有基本的防火墙功能。 但你如果你使用像 Linksys WRT54GL这样的设备,使用Tomato,openWRT,或者DD-WRT来替代普通的固件,这样你就能完全控制你的防护墙规则,路由配置,以及任何其他你想要设置的服务。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2017/10/linux-networking-hardware-beginners-think-software + +作者:[CARLA SCHRODER][a] +译者:[FelixYFZ](https://github.com/FelixYFZ) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/cschroder +[1]:https://www.linux.com/licenses/category/used-permission +[2]:https://www.linux.com/licenses/category/used-permission +[3]:https://www.linux.com/licenses/category/creative-commons-zero +[4]:https://www.linux.com/files/images/fig-1png-7 +[5]:https://www.linux.com/files/images/fig-2png-4 +[6]:https://www.linux.com/files/images/soderskar-islandjpg +[7]:https://www.linux.com/learn/intro-to-linux/2017/10/linux-networking-hardware-beginners-lan-hardware +[8]:http://www.bluelinepc.com/signalcheck/ From 1a976208331c92480f576c4f7df65fa67135973a Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 17:28:56 +0800 Subject: [PATCH 198/344] =?UTF-8?q?=E8=A1=A5=E5=AE=8C=20PR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @FelixYFZ 你的 PR 有问题,需要删除原文,并且不能修改文件名,要保留文件名前的日期和扩展名。我帮你修复了。 --- ...g Hardware for Beginners Think Software.md | 79 ------------------- ... Hardware for Beginners Think Software.md} | 0 2 files changed, 79 deletions(-) delete mode 100644 sources/tech/20171012 Linux Networking Hardware for Beginners Think Software.md rename translated/tech/{Linux Networking Hardware for Beginners: Think Software => 20171012 Linux Networking Hardware for Beginners Think Software.md} (100%) diff --git a/sources/tech/20171012 Linux Networking Hardware for Beginners Think Software.md b/sources/tech/20171012 Linux Networking Hardware for Beginners Think Software.md deleted file mode 100644 index 661f5bc2df..0000000000 --- a/sources/tech/20171012 Linux Networking Hardware for Beginners Think Software.md +++ /dev/null @@ -1,79 +0,0 @@ -Translating by FelixYFZ - -Linux Networking Hardware for Beginners: Think Software -============================================================ - -![island network](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/soderskar-island.jpg?itok=wiMaF66b "island network") -Without routers and bridges, we would be lonely little islands; learn more in this networking tutorial.[Creative Commons Zero][3]Pixabay - -Last week, we learned about [LAN (local area network) hardware][7]. This week, we'll learn about connecting networks to each other, and some cool hacks for mobile broadband. - -### Routers - -Network routers are everything in computer networking, because routers connect networks. Without routers we would be lonely little islands. Figure 1 shows a simple wired LAN (local area network) with a wireless access point, all connected to the Internet. Computers on the LAN connect to an Ethernet switch, which connects to a combination firewall/router, which connects to the big bad Internet through whatever interface your Internet service provider (ISP) provides, such as cable box, DSL modem, satellite uplink...like everything in computing, it's likely to be a box with blinky lights. When your packets leave your LAN and venture forth into the great wide Internet, they travel from router to router until they reach their destination. - -### [fig-1.png][4] - -![simple LAN](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_7.png?itok=lsazmf3- "simple LAN") -Figure 1: A simple wired LAN with a wireless access point.[Used with permission][1] - -A router can look like pretty much anything: a nice little specialized box that does only routing and nothing else, a bigger box that provides routing, firewall, name services, and VPN gateway, a re-purposed PC or laptop, a Raspberry Pi or Arduino, stout little single-board computers like PC Engines...for all but the most demanding uses, ordinary commodity hardware works fine. The highest-end routers use specialized hardware that is designed to move the maximum number of packets per second. They have multiple fat data buses, multiple CPUs, and super-fast memory. (Look up Juniper and Cisco routers to see what high-end routers look like, and what's inside.) - -A wireless access point connects to your LAN either as an Ethernet bridge or a router. A bridge extends the network, so hosts on both sides of the bridge are on the same network. A router connects two different networks. - -### Network Topology - -There are multitudes of ways to set up your LAN. You can put all hosts on a single flat network. You can divide it up into different subnets. You can divide it into virtual LANs, if your switch supports this. - -A flat network is the simplest; just plug everyone into the same switch. If one switch isn't enough you can connect switches to each other. Some switches have special uplink ports, some don't care which ports you connect, and you may need to use a crossover Ethernet cable, so check your switch documentation. - -Flat networks are the easiest to administer. You don't need routers and don't have to calculate subnets, but there are some downsides. They don't scale, so when they get too large they get bogged down by broadcast traffic. Segmenting your LAN provides a bit of security, and makes it easier to manage larger networks by dividing it into manageable chunks. Figure 2 shows a simplified LAN divided into two subnets: internal wired and wireless hosts, and one for servers that host public services. The subnet that contains the public-facing servers is called a DMZ, demilitarized zone (ever notice all the macho terminology for jobs that are mostly typing on a computer?) because it is blocked from all internal access. - -### [fig-2.png][5] - -![LAN](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-2_4.png?itok=LpXq7bLf "LAN") -Figure 2: A simplified LAN divided into two subnets.[Used with permission][2] - -Even in a network as small as Figure 2 there are several ways to set it up. You can put your firewall and router on a single device. You could have a dedicated Internet link for the DMZ, divorcing it completely from your internal network. Which brings us to our next topic: it's all software. - -### Think Software - -You may have noticed that of the hardware we have discussed in this little series, only network interfaces, switches, and cabling are special-purpose hardware. Everything else is general-purpose commodity hardware, and it's the software that defines its purpose. Linux is a true networking operating system, and it supports a multitude of network operations: VLANs, firewall, router, Internet gateway, VPN gateway, Ethernet bridge, Web/mail/file/etc. servers, load-balancer, proxy, quality of service, multiple authenticators, trunking, failover...you can run your entire network on commodity hardware with Linux. You can even use Linux to simulate an Ethernet switch with LISA (LInux Switching Appliance) and vde2. - -There are specialized distributions for small hardware like DD-WRT, OpenWRT, and the Raspberry Pi distros, and don't forget the BSDs and their specialized offshoots like the pfSense firewall/router, and the FreeNAS network-attached storage server. - -You know how some people insist there is a difference between a hardware firewall and a software firewall? There isn't. That's like saying there is a hardware computer and a software computer. - -### Port Trunking and Ethernet Bonding - -Trunking and bonding, also called link aggregation, is combining two Ethernet channels into one. Some Ethernet switches support port trunking, which is combining two switch ports to combine their bandwidth into a single link. This is a nice way to make a bigger pipe to a busy server. - -You can do the same thing with Ethernet interfaces, and the bonding driver is built-in to the Linux kernel, so you don't need any special hardware. - -### Bending Mobile Broadband to your Will - -I expect that mobile broadband is going to grow in the place of DSL and cable Internet. I live near a city of 250,000 population, but outside the city limits good luck getting Internet, even though there is a large population to serve. My little corner of the world is 20 minutes from town, but it might as well be the moon as far as Internet service providers are concerned. My only option is mobile broadband; there is no dialup, satellite Internet is sold out (and it sucks), and haha lol DSL, cable, or fiber. That doesn't stop ISPs from stuffing my mailbox with flyers for Xfinity and other high-speed services my area will never see. - -I tried AT&T, Verizon, and T-Mobile. Verizon has the strongest coverage, but Verizon and AT&T are expensive. I'm at the edge of T-Mobile coverage, but they give the best deal by far. To make it work, I had to buy a weBoost signal booster and ZTE mobile hotspot. Yes, you can use a smartphone as a hotspot, but the little dedicated hotspots have stronger radios. If you're thinking you might want a signal booster, I have nothing but praise for weBoost because their customer support is superb, and they will do their best to help you. Set it up with the help of a great little app that accurately measures signal strength, [SignalCheck Pro][8]. They have a free version with fewer features; spend the two bucks to get the pro version, you won't be sorry. - -The little ZTE hotspots serve up to 15 hosts and have rudimentary firewalls. But we can do better: get something like the Linksys WRT54GL, replace the stock firmware with Tomato, OpenWRT, or DD-WRT, and then you have complete control of your firewall rules, routing, and any other services you want to set up. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2017/10/linux-networking-hardware-beginners-think-software - -作者:[CARLA SCHRODER][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/cschroder -[1]:https://www.linux.com/licenses/category/used-permission -[2]:https://www.linux.com/licenses/category/used-permission -[3]:https://www.linux.com/licenses/category/creative-commons-zero -[4]:https://www.linux.com/files/images/fig-1png-7 -[5]:https://www.linux.com/files/images/fig-2png-4 -[6]:https://www.linux.com/files/images/soderskar-islandjpg -[7]:https://www.linux.com/learn/intro-to-linux/2017/10/linux-networking-hardware-beginners-lan-hardware -[8]:http://www.bluelinepc.com/signalcheck/ diff --git a/translated/tech/Linux Networking Hardware for Beginners: Think Software b/translated/tech/20171012 Linux Networking Hardware for Beginners Think Software.md similarity index 100% rename from translated/tech/Linux Networking Hardware for Beginners: Think Software rename to translated/tech/20171012 Linux Networking Hardware for Beginners Think Software.md From 79f337b4547d29d3a20f49e373be479fe3bd3625 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 17:29:41 +0800 Subject: [PATCH 199/344] =?UTF-8?q?=E8=A1=A5=E5=AE=8C=20PR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @filefi 不要丢掉扩展名。 --- ...20171202 Scrot Linux command-line screen grabs made simple.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sources/tech/{20171202 Scrot Linux command-line screen grabs made simple => 20171202 Scrot Linux command-line screen grabs made simple.md} (100%) diff --git a/sources/tech/20171202 Scrot Linux command-line screen grabs made simple b/sources/tech/20171202 Scrot Linux command-line screen grabs made simple.md similarity index 100% rename from sources/tech/20171202 Scrot Linux command-line screen grabs made simple rename to sources/tech/20171202 Scrot Linux command-line screen grabs made simple.md From 557c2e97ab8c3c218fb6fb21544eb71bbe78879c Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 17:31:40 +0800 Subject: [PATCH 200/344] =?UTF-8?q?=E5=B7=B2=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @geekpi --- .../20171201 Linux Journal Ceases Publication.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171201 Linux Journal Ceases Publication.md (100%) diff --git a/translated/tech/20171201 Linux Journal Ceases Publication.md b/published/20171201 Linux Journal Ceases Publication.md similarity index 100% rename from translated/tech/20171201 Linux Journal Ceases Publication.md rename to published/20171201 Linux Journal Ceases Publication.md From b1848c52a3a76ad92f3f6dbe17a88ddfb4659d14 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 21:38:41 +0800 Subject: [PATCH 201/344] =?UTF-8?q?PRF:20171130=20Translate=20Shell=20?= =?UTF-8?q?=E2=80=93=20A=20Tool=20To=20Use=20Google=20Translate=20From=20C?= =?UTF-8?q?ommand=20Line=20In=20Linux.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @lujun9972 译者没署名,我找了半天 /cry --- ...ogle Translate From Command Line In Linux.md | 76 +++++++++---------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md b/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md index 9f905bd496..aeae003532 100644 --- a/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md +++ b/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md @@ -1,68 +1,65 @@ -Translate Shell: 一款在 Linux 命令行中使用 Google Translate的工具 +Translate Shell :一款在 Linux 命令行中使用谷歌翻译的工具 ============================================================ -我对 CLI 应用非常感兴趣,因此热衷于使用并分享 CLI 应用。 我之所以更喜欢 CLI 很大原因是因为我在大多数的时候都使用的是字符界面(black screen),已经习惯了使用 CLI 应用而不是 GUI 应用. +我对 CLI 应用非常感兴趣,因此热衷于使用并分享 CLI 应用。 我之所以更喜欢 CLI 很大原因是因为我在大多数的时候都使用的是字符界面(black screen),已经习惯了使用 CLI 应用而不是 GUI 应用。 -我写过很多关于 CLI 应用的文章。 最近我发现了一些 google 的 CLI 工具,像 “Google Translator”, “Google Calendar”, 和 “Google Contacts”。 这里,我想在给大家分享一下。 +我写过很多关于 CLI 应用的文章。 最近我发现了一些谷歌的 CLI 工具,像 “Google Translator”、“Google Calendar” 和 “Google Contacts”。 这里,我想在给大家分享一下。 -今天我们要介绍的是 “Google Translator” 工具。 由于母语是泰米尔语,我在一天内用了很多次才理解了它的意义。 +今天我们要介绍的是 “Google Translator” 工具。 由于我的母语是泰米尔语,我在一天内用了很多次才理解了它的意义。 -`Google translate` 为其他语系的人们所广泛使用。 +谷歌翻译为其它语系的人们所广泛使用。 ### 什么是 Translate Shell -[Translate Shell][2] (之前叫做 Google Translate CLI) 是一款借助 `Google Translate`(默认), `Bing Translator`, `Yandex.Translate` 以及 `Apertium` 来翻译的命令行翻译器。 -它让你可以在终端访问这些翻译引擎. `Translate Shell` 在大多数Linux发行版中都能使用。 +[Translate Shell][2] (之前叫做 Google Translate CLI) 是一款借助谷歌翻译(默认)、必应翻译、Yandex.Translate 以及 Apertium 来翻译的命令行翻译器。它让你可以在终端访问这些翻译引擎。 Translate Shell 在大多数 Linux 发行版中都能使用。 ### 如何安装 Translate Shell -有三种方法安装 `Translate Shell`。 +有三种方法安装 Translate Shell。 * 下载自包含的可执行文件 - * 手工安装 +* 通过包管理器安装 -* 通过包挂力气安装 - -#### 方法-1 : 下载自包含的可执行文件 +#### 方法 1 : 下载自包含的可执行文件 下载自包含的可执行文件放到 `/usr/bin` 目录中。 -```shell +``` $ wget git.io/trans $ chmod +x ./trans $ sudo mv trans /usr/bin/ ``` -#### 方法-2 : 手工安装 +#### 方法 2 : 手工安装 -克隆 `Translate Shell` github 仓库然后手工编译。 +克隆 Translate Shell 的 GitHub 仓库然后手工编译。 -```shell +``` $ git clone https://github.com/soimort/translate-shell && cd translate-shell $ make $ sudo make install ``` -#### 方法-3 : Via Package Manager +#### 方法 3 : 通过包管理器 -有些发行版的官方仓库中包含了 `Translate Shell`,可以通过包管理器来安装。 +有些发行版的官方仓库中包含了 Translate Shell,可以通过包管理器来安装。 -对于 Debian/Ubuntu, 使用 [APT-GET Command][3] 或者 [APT Command][4]来安装。 +对于 Debian/Ubuntu, 使用 [APT-GET 命令][3] 或者 [APT 命令][4]来安装。 -```shell +``` $ sudo apt-get install translate-shell ``` -对于 Fedora, 使用 [DNF Command][5] 来安装。 +对于 Fedora, 使用 [DNF 命令][5] 来安装。 -```shell +``` $ sudo dnf install translate-shell ``` -对于基于 Arch Linux 的系统, 使用 [Yaourt Command][6] 或 [Packer Command][7] 来从 AUR 仓库中安装。 +对于基于 Arch Linux 的系统, 使用 [Yaourt 命令][6] 或 [Packer 明快][7] 来从 AUR 仓库中安装。 -```shell +``` $ yaourt -S translate-shell or $ packer -S translate-shell @@ -70,7 +67,7 @@ $ packer -S translate-shell ### 如何使用 Translate Shell -安装好后,打开终端闭关输入下面命令。 `Google Translate` 会自动探测源文本是哪种语言,并且在默认情况下将之翻译成你的 `locale` 所对应的语言。 +安装好后,打开终端闭关输入下面命令。 谷歌翻译会自动探测源文本是哪种语言,并且在默认情况下将之翻译成你的 `locale` 所对应的语言。 ``` $ trans [Words] @@ -119,7 +116,7 @@ thanks நன்றி ``` -要将一个单词翻译到多个语种可以使用下面命令(本例中, 我将单词翻译成泰米尔语以及印地语)。 +要将一个单词翻译到多个语种可以使用下面命令(本例中,我将单词翻译成泰米尔语以及印地语)。 ``` $ trans :ta+hi thanks @@ -172,7 +169,7 @@ what is going on your life? உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? ``` -下面命令独立地翻译各个单词。 +下面命令单独地翻译各个单词。 ``` $ trans :ta curios happy @@ -208,14 +205,14 @@ happy சந்தோஷமாக, மகிழ்ச்சி, இனிய, சந்தோஷமா ``` -简洁模式: 默认情况下,`Translate Shell` 尽可能多的显示翻译信息. 如果你希望只显示简要信息,只需要加上`-b`选项。 +简洁模式:默认情况下,Translate Shell 尽可能多的显示翻译信息。如果你希望只显示简要信息,只需要加上 `-b`选项。 ``` $ trans -b :ta thanks நன்றி ``` -字典模式: 加上 `-d` 可以把 `Translate Shell` 当成字典来用. +字典模式:加上 `-d` 可以把 Translate Shell 当成字典来用。 ``` $ trans -d :en thanks @@ -294,14 +291,14 @@ See also Thanks!, thank, many thanks, thanks to, thanks to you, special thanks, give thanks, thousand thanks, Many thanks!, render thanks, heartfelt thanks, thanks to this ``` -使用下面格式可以使用 `Translate Shell` 来翻译文件。 +使用下面格式可以使用 Translate Shell 来翻译文件。 -```shell +``` $ trans :ta file:///home/magi/gtrans.txt உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? ``` -下面命令可以让 `Translate Shell` 进入交互模式. 在进入交互模式之前你需要明确指定源语言和目标语言。本例中,我将英文单词翻译成泰米尔语。 +下面命令可以让 Translate Shell 进入交互模式。 在进入交互模式之前你需要明确指定源语言和目标语言。本例中,我将英文单词翻译成泰米尔语。 ``` $ trans -shell en:ta thanks @@ -324,13 +321,14 @@ thanks நன்றி ``` -想知道语言代码,可以执行下面语言。 +想知道语言代码,可以执行下面命令。 -```shell +``` $ trans -R ``` 或者 -```shell + +``` $ trans -T ┌───────────────────────┬───────────────────────┬───────────────────────┐ │ Afrikaans - af │ Hindi - hi │ Punjabi - pa │ @@ -375,9 +373,9 @@ $ trans -T └───────────────────────┴───────────────────────┴───────────────────────┘ ``` -想了解更多选项的内容,可以查看 `man` 页. +想了解更多选项的内容,可以查看其 man 手册。 -```shell +``` $ man trans ``` @@ -386,8 +384,8 @@ $ man trans via: https://www.2daygeek.com/translate-shell-a-tool-to-use-google-translate-from-command-line-in-linux/ 作者:[Magesh Maruthamuthu][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[lujun9972](https://github.com/lujun9972 ) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From a30b1c69ad66a0dcbc6e6cc67b6dffbe55e04c88 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 21:38:57 +0800 Subject: [PATCH 202/344] =?UTF-8?q?PUB:20171130=20Translate=20Shell=20?= =?UTF-8?q?=E2=80=93=20A=20Tool=20To=20Use=20Google=20Translate=20From=20C?= =?UTF-8?q?ommand=20Line=20In=20Linux.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @lujun9972 https://linux.cn/article-9107-1.html --- ...– A Tool To Use Google Translate From Command Line In Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md (100%) diff --git a/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md b/published/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md similarity index 100% rename from translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md rename to published/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md From 8a5b20e9ad5362f9deb8f934fde1a0b37f82a1e0 Mon Sep 17 00:00:00 2001 From: iron0x <2727586680@qq.com> Date: Mon, 4 Dec 2017 21:40:05 +0800 Subject: [PATCH 203/344] Update 20171202 docker - Use multi-stage builds.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译中 --- sources/tech/20171202 docker - Use multi-stage builds.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171202 docker - Use multi-stage builds.md b/sources/tech/20171202 docker - Use multi-stage builds.md index e1a6414862..8cc8af1c94 100644 --- a/sources/tech/20171202 docker - Use multi-stage builds.md +++ b/sources/tech/20171202 docker - Use multi-stage builds.md @@ -1,3 +1,5 @@ +【iron0x翻译中】 + Use multi-stage builds ============================================================ From 6d9411106201719c2a58e43176454b2b5f07062d Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 22:02:54 +0800 Subject: [PATCH 204/344] PRF&PUB:20171130 New Feature Find every domain someone owns automatically.md @geekpi --- ...d every domain someone owns automatically.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) rename {translated/tech => published}/20171130 New Feature Find every domain someone owns automatically.md (69%) diff --git a/translated/tech/20171130 New Feature Find every domain someone owns automatically.md b/published/20171130 New Feature Find every domain someone owns automatically.md similarity index 69% rename from translated/tech/20171130 New Feature Find every domain someone owns automatically.md rename to published/20171130 New Feature Find every domain someone owns automatically.md index 4b72eaae5e..e8866a5ce5 100644 --- a/translated/tech/20171130 New Feature Find every domain someone owns automatically.md +++ b/published/20171130 New Feature Find every domain someone owns automatically.md @@ -1,16 +1,15 @@ -新功能:自动找出每个域名的拥有者 +使用 DNSTrails 自动找出每个域名的拥有者 ============================================================ - 今天,我们很高兴地宣布我们最近几周做的新功能。它是 Whois 聚合工具,现在可以在 [DNSTrails][1] 上获得。 -在过去,查找一个域名的所有者会花费很多时间,因为大部分时间你都需要把域名指向一个 IP 地址,以便找到同一个人拥有的其他域名。 +在过去,查找一个域名的所有者会花费很多时间,因为大部分时间你都需要把域名翻译为一个 IP 地址,以便找到同一个人拥有的其他域名。 -使用老的方法,你会很轻易地在一个工具和另外一个工具的研究和交叉比较结果中花费数个小时,直到得到你想要的域名。 +使用老的方法,在得到你想要的域名列表之前,你在一个工具和另外一个工具的一日又一日的研究和交叉比较结果中经常会花费数个小时。 -感谢这个新工具和我们的智能[WHOIS 数据库][2],现在你可以搜索任何域名,并获得组织或个人注册的域名的完整列表,并在几秒钟内获得准确的结果。 +感谢这个新工具和我们的智能 [WHOIS 数据库][2],现在你可以搜索任何域名,并获得组织或个人注册的域名的完整列表,并在几秒钟内获得准确的结果。 -### 我如何使用Whois聚合功能? +### 我如何使用 Whois 聚合功能? 第一步:打开 [DNSTrails.com][3] @@ -28,15 +27,15 @@ 如果你正在调查互联网上任何个人的域名所有权,这意味着即使域名甚至没有指向注册服务商的 IP,如果他们使用相同的电话和邮件地址,我们仍然可以发现其他域名。 -想知道一个人拥有的其他域名么?亲自试试 [DNStrails][5] 的[ WHOIS 聚合功能][4]或者[使用我们的 API 访问][6]。 +想知道一个人拥有的其他域名么?亲自试试 [DNStrails][5] 的 [WHOIS 聚合功能][4]或者[使用我们的 API 访问][6]。 -------------------------------------------------------------------------------- via: https://securitytrails.com/blog/find-every-domain-someone-owns -作者:[SECURITYTRAILS TEAM ][a] +作者:[SECURITYTRAILS TEAM][a] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 40e85e02d0860ba5071128b76793eec19fefcbfd Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 22:08:09 +0800 Subject: [PATCH 205/344] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @oska874 @lujun9972 --- ...em.md => 20171117 System Logs Understand Your Linux System.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/tech/{20171117 System Logs: Understand Your Linux System.md => 20171117 System Logs Understand Your Linux System.md} (100%) diff --git a/translated/tech/20171117 System Logs: Understand Your Linux System.md b/translated/tech/20171117 System Logs Understand Your Linux System.md similarity index 100% rename from translated/tech/20171117 System Logs: Understand Your Linux System.md rename to translated/tech/20171117 System Logs Understand Your Linux System.md From ca2175631b518a9ee619aa0aea6727694b016cfe Mon Sep 17 00:00:00 2001 From: imquanquan Date: Mon, 4 Dec 2017 22:13:28 +0800 Subject: [PATCH 206/344] translated --- ...ow to Manage Users with Groups in Linux.md | 183 ++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 translated/tech/20171201 How to Manage Users with Groups in Linux.md diff --git a/translated/tech/20171201 How to Manage Users with Groups in Linux.md b/translated/tech/20171201 How to Manage Users with Groups in Linux.md new file mode 100644 index 0000000000..8baac8707b --- /dev/null +++ b/translated/tech/20171201 How to Manage Users with Groups in Linux.md @@ -0,0 +1,183 @@ +如何在 Linux 系统中用用户组来管理用户 +============================================================ + +### [group-of-people-1645356_1920.jpg][1] + +![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/group-of-people-1645356_1920.jpg?itok=rJlAxBSV) + +在本教程中了解如何通过用户组和访问控制表(ACL)来管理用户。 + +[创意共享协议][4] + +当你需要管理一台容纳多个用户的 Linux 机器时,比起一些基本的用户管理工具所提供的方法,有时候你需要对这些用户采取更多的用户权限管理方式。特别是当你要管理某些用户的权限时,这个想法尤为重要。比如说,你有一个目录,一个用户组中的用户可以通过读和写的权限访问这个目录,而其他用户组中的用户对这个目录只有读的权限。通过 Linux 这是完全可以实现的。但是你首先必须了解如何通过用户组和访问控制表(ACL)来管理用户。 + +我们将从简单的用户开始,逐渐深入到复杂的访问控制表(ACL)。你所需要做的一切都将在你选择的 Linux 发行版中完成。本文的重点是用户组,所以不会涉及到关于用户的基础知识。 + +为了达到演示的目的,我将假设: + +你需要用下面两个用户名新建两个用户: + +* olivia + +* nathan + +你需要新建以下两个用户组: + +* readers + +* editors + +olivia 属于 editors 用户组,而 nathan 属于 readers 用户组。reader 用户组对 ``/DATA`` 目录只有读的权限,而 editors 用户组则对 ``/DATA`` 目录同时有读和写的权限。当然,这是个非常小的任务,但它会给你基本的用法。你可以扩展这个任务以适应你其他更大的需求。 + +我将在 Ubuntu 16.04 Server 平台上进行演示。这些命令都是通用的,唯一不同的是,要是在你的发行版中不使用 sudo 命令,你必须切换到 root 用户来执行这些命令。 + +### 创建用户 + +我们需要做的第一件事是为我们的实验创建两个用户。可以用 ``useradd`` 命令来创建用户,我们不只是简单地创建一个用户,而需要同时创建用户和属于他们的家目录,然后给他们设置密码。 + +``` +sudo useradd -m olivia + +sudo useradd -m nathan +``` + +我们现在创建了两个用户,如果你看看 ``/home`` 目录,你可以发现他们的家目录(因为我们用了 -m 选项,可以帮在创建用户的同时创建他们的家目录。 + +之后,我们可以用以下命令给他们设置密码: + +``` +sudo passwd olivia + +sudo passwd nathan +``` + +就这样,我们创建了两个用户。 + +### 创建用户组并添加用户 + +现在我们将创建 readers 和 editors 用户组,然后给它们添加用户。创建用户组的命令是: + +``` +addgroup readers + +addgroup editors +``` + +(译者注:当你使用 CentOS 等一些 Linux 发行版时,可能系统没有 addgroup 这个命令,推荐使用 groupadd 命令来替换 addgroup 命令以达到同样的效果) + + +### [groups_1.jpg][2] + +![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/groups_1.jpg?itok=BKwL89BB) + +图一:我们可以使用刚创建的新用户组了。 + +[Used with permission][5] + +创建用户组后,我们需要给他们添加用户。我们用以下命令来将 nathan 添加到 readers 用户组: + +``` +sudo usermod -a -G readers nathan +``` +用以下命令将 olivia 添加到 editors 用户组: + +``` +sudo usermod -a -G editors olivia +``` + +现在我们已经准备好用用户组来管理用户了。 + +### 给用户组授予目录的权限 + +假设你有个目录 ``/READERS``,允许 readers 用户组的所有成员访问这个目录。首先,我们执行以下命令来更改目录所属用户组: + +``` +sudo chown -R :readers /READERS +``` + +接下来,执行以下命令收回目录所属用户组的写入权限: + +``` +sudo chmod -R g-w /READERS +``` + +然后我们执行下面的命令来收回其他用户对这个目录的访问权限(以防止任何不在读者组中的用户访问这个目录里的文件): + +``` +sudo chmod -R o-x /READERS +``` + +这时候,只有目录的所有者(root)和用户组 reader 中的用户可以访问 ``/READES`` 中的文件。 + +假设你有个目录 ``/EDITORS`` ,你需要给用户组 editors 里的成员这个目录的读和写的权限。为了达到这个目的,执行下面的这些命令是必要的: + +``` +sudo chown -R :editors /EDITORS + +sudo chmod -R g+w /EDITORS + +sudo chmod -R o-x /EDITORS +``` + +此时 editors 用户组的所有成员都可以访问和修改其中的文件。除此之外其他用户(除了 root 之外)无法访问 ``/EDITORS`` 中的任何文件。 + +使用这个方法的问题在于,你一次只能操作一个组和一个目录而已。这时候访问控制表(ACL)就可以派得上用场了。 + + +### 使用访问控制表(ACL) + +现在,让我们把这个问题变得棘手一点。假设你有一个目录 ``/DATA`` 并且你想给 readers 用户组的成员读取权限同时给 editors 用户组的成员读和写的权限。为此,你必须要用到 setfacl 命令。setfacl 命令可以为文件或文件夹设置一个访问控制表(ACL)。 + +这个命令的结构如下: + +``` +setfacl OPTION X:NAME:Y /DIRECTORY +``` + +其中 OPTION 是可选选项,X 可以是 u(用户)或者是 g (用户组),NAME 是用户或者用户组的名字,/DIRECTORY 是要用到的目录。我们将使用 -m 选项进行修改(modify)。因此,我们给 readers 用户组添加读取权限的命令是: + +``` +sudo setfacl -m g:readers:rx -R /DATA +``` + +现在 readers 用户组里面的每一个用户都可以读取 /DATA 目录里的文件了,但是他们不能修改里面的内容。 + +为了给 editors 用户组里面的用户读写权限,我们执行了以下的命令: + +``` +sudo setfacl -m g:editors:rwx -R /DATA +``` +上述命令将赋予 editors 用户组中的任何成员读取权限,同时保留 readers 用户组的只读权限。 + +### 更多的权限控制 + +使用访问控制表(ACL),你可以实现你所需的权限控制。你可以实现将用户添加到用户组,并且可靠灵活地控制这些用户组对每个目录的权限以达到你的需求。想要了解上述工具的更多信息,可以执行下列的命令: + +* man usradd + +* man addgroup + +* man usermod + +* man sefacl + +* man chown + +* man chmod + + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2017/12/how-manage-users-groups-linux + +作者:[Jack Wallen ] +译者:[imquanquan](https://github.com/imquanquan) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://www.linux.com/files/images/group-people-16453561920jpg +[2]:https://www.linux.com/files/images/groups1jpg +[3]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux +[4]:https://www.linux.com/licenses/category/creative-commons-zero +[5]:https://www.linux.com/licenses/category/used-permission From 96a54dd193bec2b9eb8bb945766b13087f101179 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 22:20:54 +0800 Subject: [PATCH 207/344] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @oska874 --- ...x command-line screen grabs made simple.md | 108 ------------------ 1 file changed, 108 deletions(-) delete mode 100644 sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md diff --git a/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md b/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md deleted file mode 100644 index 2b4d2248b2..0000000000 --- a/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md +++ /dev/null @@ -1,108 +0,0 @@ -Scrot: Linux command-line screen grabs made simple -============================================================ - -### Scrot is a basic, flexible tool that offers a number of handy options for taking screen captures from the Linux command line. - -![Scrot: Screen grabs made simple](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/community-penguins-osdc-lead.png?itok=BmqsAF4A "Scrot: Screen grabs made simple") -Image credits : Original photo by Rikki Endsley. [CC BY-SA 4.0][13] - -There are great tools on the Linux desktop for taking screen captures, such as [KSnapshot][14] and [Shutter][15]. Even the simple utility that comes with the GNOME desktop does a pretty good job of capturing screens. But what if you rarely need to take screen captures? Or you use a Linux distribution without a built-in capture tool, or an older computer with limited resources? - -Turn to the command line and a little utility called [Scrot][16]. It does a fine job of taking simple screen captures, and it includes a few features that might surprise you. - -### Getting started with Scrot - -More Linux resources - -* [What is Linux?][1] - -* [What are Linux containers?][2] - -* [Download Now: Linux commands cheat sheet][3] - -* [Advanced Linux commands cheat sheet][4] - -* [Our latest Linux articles][5] - -Many Linux distributions come with Scrot already installed—to check, type `which scrot`. If it isn't there, you can install Scrot using your distro's package manager. If you're willing to compile the code, grab it [from GitHub][22]. - -To take a screen capture, crack open a terminal window and type `scrot [filename]`, where `[filename]` is the name of file to which you want to save the image (for example, `desktop.png`). If you don't include a name for the file, Scrot will create one for you, such as `2017-09-24-185009_1687x938_scrot.png`. (That filename isn't as descriptive it could be, is it? That's why it's better to add one to the command.) - -Running Scrot with no options takes a screen capture of your entire desktop. If you don't want to do that, Scrot lets you focus on smaller portions of your screen. - -### Taking a screen capture of a single window - -Tell Scrot to take a screen capture of a single window by typing `scrot -u [filename]`. - -The `-u` option tells Scrot to grab the window currently in focus. That's usually the terminal window you're working in, which might not be the one you want. - -To grab another window on your desktop, type `scrot -s [filename]`. - -The `-s` option lets you do one of two things: - -* select an open window, or - -* draw a rectangle around a window or a portion of a window to capture it. - -You can also set a delay, which gives you a little more time to select the window you want to capture. To do that, type `scrot -u -d [num] [filename]`. - -The `-d` option tells Scrot to wait before grabbing the window, and `[num]` is the number of seconds to wait. Specifying `-d 5` (wait five seconds) should give you enough time to choose a window. - -### More useful options - -Scrot offers a number of additional features (most of which I never use). The ones I find most useful include: - -* `-b` also grabs the window's border - -* `-t` grabs a window and creates a thumbnail of it. This can be useful when you're posting screen captures online. - -* `-c` creates a countdown in your terminal when you use the `-d` option. - -To learn about Scrot's other options, check out the its documentation by typing `man scrot` in a terminal window, or [read it online][17]. Then start snapping images of your screen. - -It's basic, but Scrot gets the job done nicely. - -### Topics - - [Linux][23] - -### About the author - - [![That idiot Scott Nesbitt ...](https://opensource.com/sites/default/files/styles/profile_pictures/public/scottn-cropped.jpg?itok=q4T2J4Ai)][18] - - Scott Nesbitt - I'm a long-time user of free/open source software, and write various things for both fun and profit. I don't take myself too seriously and I do all of my own stunts. You can find me at these fine establishments on the web: [Twitter][7], [Mastodon][8], [GitHub][9], and... [more about Scott Nesbitt][10][More about me][11] - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot - -作者:[ Scott Nesbitt  ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/scottnesbitt -[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[6]:https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot?rate=H43kUdawjR0GV9D0dCbpnmOWcqw1WekfrAI_qKo8UwI -[7]:http://www.twitter.com/ScottWNesbitt -[8]:https://mastodon.social/@scottnesbitt -[9]:https://github.com/ScottWNesbitt -[10]:https://opensource.com/users/scottnesbitt -[11]:https://opensource.com/users/scottnesbitt -[12]:https://opensource.com/user/14925/feed -[13]:https://creativecommons.org/licenses/by-sa/4.0/ -[14]:https://www.kde.org/applications/graphics/ksnapshot/ -[15]:https://launchpad.net/shutter -[16]:https://github.com/dreamer/scrot -[17]:http://manpages.ubuntu.com/manpages/precise/man1/scrot.1.html -[18]:https://opensource.com/users/scottnesbitt -[19]:https://opensource.com/users/scottnesbitt -[20]:https://opensource.com/users/scottnesbitt -[21]:https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot#comments -[22]:https://github.com/dreamer/scrot -[23]:https://opensource.com/tags/linux From 1e5d60f56f5695b538bc5c8d0448a69b6cf0db57 Mon Sep 17 00:00:00 2001 From: imquanquan Date: Mon, 4 Dec 2017 22:33:42 +0800 Subject: [PATCH 208/344] Delete 20171201 How to Manage Users with Groups in Linux.md --- ...ow to Manage Users with Groups in Linux.md | 168 ------------------ 1 file changed, 168 deletions(-) delete mode 100644 sources/tech/20171201 How to Manage Users with Groups in Linux.md diff --git a/sources/tech/20171201 How to Manage Users with Groups in Linux.md b/sources/tech/20171201 How to Manage Users with Groups in Linux.md deleted file mode 100644 index 35350c819f..0000000000 --- a/sources/tech/20171201 How to Manage Users with Groups in Linux.md +++ /dev/null @@ -1,168 +0,0 @@ -translating---imquanquan - -How to Manage Users with Groups in Linux -============================================================ - -### [group-of-people-1645356_1920.jpg][1] - -![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/group-of-people-1645356_1920.jpg?itok=rJlAxBSV) - -Learn how to work with users, via groups and access control lists in this tutorial. - -[Creative Commons Zero][4] - -Pixabay - -When you administer a Linux machine that houses multiple users, there might be times when you need to take more control over those users than the basic user tools offer. This idea comes to the fore especially when you need to manage permissions for certain users. Say, for example, you have a directory that needs to be accessed with read/write permissions by one group of users and only read permissions for another group. With Linux, this is entirely possible. To make this happen, however, you must first understand how to work with users, via groups and access control lists (ACLs). - -We’ll start from the beginning with users and work our way to the more complex ACLs. Everything you need to make this happen will be included in your Linux distribution of choice. We won’t touch on the basics of users, as the focus on this article is about groups. - -For the purpose of this piece, I’m going to assume the following: - -You need to create two users with usernames: - -* olivia - -* nathan - -You need to create two groups: - -* readers - -* editors - -Olivia needs to be a member of the group editors, while nathan needs to be a member of the group readers. The group readers needs to only have read permission to the directory /DATA, whereas the group editors needs to have both read and write permission to the /DATA directory. This, of course, is very minimal, but it will give you the basic information you need to expand the tasks to fit your much larger needs. - -I’ll be demonstrating on the Ubuntu 16.04 Server platform. The commands will be universal—the only difference would be if your distribution of choice doesn’t make use of sudo. If this is the case, you’ll have to first su to the root user to issue the commands that require sudo in the demonstrations. - -### Creating the users - -The first thing we need to do is create the two users for our experiment. User creation is handled with the useradd command. Instead of just simply creating the users we need to create them both with their own home directories and then give them passwords. - -The first thing we do is create the users. To do this, issue the commands: - -``` -sudo useradd -m olivia - -sudo useradd -m nathan -``` - -Next each user must have a password. To add passwords into the mix, you’d issue the following commands: - -``` -sudo passwd olivia - -sudo passwd nathan -``` - -That’s it, your users are created. - -### Creating groups and adding users - -Now we’re going to create the groups readers and editors and then add users to them. The commands to create our groups are: - -``` -addgroup readers - -addgroup editors -``` - -### [groups_1.jpg][2] - -![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/groups_1.jpg?itok=BKwL89BB) - -Figure 1: Our new groups ready to be used. - -[Used with permission][5] - -With our groups created, we need to add our users. We’ll add user nathan to group readers with the command: - -``` -sudo usermod -a -G readers nathan -``` - -``` -sudo usermod -a -G editors olivia -``` - -### Giving groups permissions to directories - -Let’s say you have the directory /READERS and you need to allow all members of the readers group access to that directory. First, change the group of the folder with the command: - -``` -sudo chown -R :readers /READERS -``` - -``` -sudo chmod -R g-w /READERS -``` - -``` -sudo chmod -R o-x /READERS -``` - -Let’s say you have the directory /EDITORS and you need to give members of the editors group read and write permission to its contents. To do that, the following command would be necessary: - -``` -sudo chown -R :editors /EDITORS - -sudo chmod -R g+w /EDITORS - -sudo chmod -R o-x /EDITORS -``` - -The problem with using this method is you can only add one group to a directory at a time. This is where access control lists come in handy. - -### Using access control lists - -Now, let’s get tricky. Say you have a single folder—/DATA—and you want to give members of the readers group read permission and members of the group editors read/write permissions. To do that, you must take advantage of the setfacl command. The setfacl command sets file access control lists for files and folders. - -The structure of this command looks like this: - -``` -setfacl OPTION X:NAME:Y /DIRECTORY -``` - -``` -sudo setfacl -m g:readers:rx -R /DATA -``` - -To give members of the editors group read/write permissions (while retaining read permissions for the readers group), we’d issue the command; - -``` -sudo setfacl -m g:editors:rwx -R /DATA -``` - -### All the control you need - -And there you have it. You can now add members to groups and control those groups’ access to various directories with all the power and flexibility you need. To read more about the above tools, issue the commands: - -* man usradd - -* man addgroup - -* man usermod - -* man sefacl - -* man chown - -* man chmod - -Learn more about Linux through the free ["Introduction to Linux" ][3]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2017/12/how-manage-users-groups-linux - -作者:[Jack Wallen ] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[1]:https://www.linux.com/files/images/group-people-16453561920jpg -[2]:https://www.linux.com/files/images/groups1jpg -[3]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux -[4]:https://www.linux.com/licenses/category/creative-commons-zero -[5]:https://www.linux.com/licenses/category/used-permission From 18ae29fedefe613992f4c3c98b15fb6a4c7a121c Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 22:38:01 +0800 Subject: [PATCH 209/344] PRF:20171124 Photon Could Be Your New Favorite Container OS.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @KeyLD 恭喜你,完成了第一篇翻译! 不过,按照流程,翻译前应该发起申请的 PR,翻译完提交时,要将原文删除。 --- ...Could Be Your New Favorite Container OS.md | 146 ------------------ ...Could Be Your New Favorite Container OS.md | 77 ++++----- 2 files changed, 32 insertions(+), 191 deletions(-) delete mode 100644 sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md diff --git a/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md deleted file mode 100644 index d282ef5445..0000000000 --- a/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md +++ /dev/null @@ -1,146 +0,0 @@ -Photon Could Be Your New Favorite Container OS -============================================================ - -![Photon OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon-linux.jpg?itok=jUFHPR_c "Photon OS") -Jack Wallen says Photon OS is an outstanding platform, geared specifically for containers.[Creative Commons Zero][5]Pixabay - -Containers are all the rage, and with good reason. [As discussed previously][13], containers allow you to quickly and easily deploy new services and applications onto your network, without requiring too much in the way of added system resources. Containers are more cost-effective than using dedicated hardware or virtual machines, and they’re easier to update and reuse. - -Best of all, containers love Linux (and vice versa). Without much trouble or time, you can get a Linux server up and running with [Docker][14] and deploying containers. But, which Linux distribution is best suited for the deployment of your containers? There are a _lot_  of options. You could go with a standard Ubuntu Server platform (which makes installing Docker and deploying containers incredibly easy), or you could opt for a lighter weight distribution — one geared specifically for the purpose of deploying containers. - -One such distribution is [Photon][15]. This particular platform was created in 2005 by [VMware][16]; it includes the Docker daemon and works with container frameworks, such as Mesos and Kubernetes. Photon is optimized to work with [VMware vSphere][17], but it can be used on bare metal, [Microsoft Azure][18], [Google Compute Engine][19], [Amazon Elastic Compute Cloud][20], or [VirtualBox][21]. - -Photon manages to stay slim by only installing what is absolutely necessary to run the Docker daemon. In the end, the distribution comes in around 300 MB. This is just enough Linux make it all work. The key features to Photon are: - -* Kernel tuned for performance. - -* Kernel is hardened according to the [Kernel Self-Protection Project][6] (KSPP). - -* All installed packages are built with hardened security flags. - -* Operating system boots with validated trust. - -* Photon management daemon manages firewall, network, packages, and users on remote Photon OS machines. - -* Support for persistent volumes. - -* [Project Lightwave][7] integration. - -* Timely security patches and updates. - -Photon can be used via [ISO][22], [OVA][23], [Amazon Machine Image][24], [Google Compute Engine image][25], and [Azure VHD][26]. I’ll show you how to install Photon on VirtualBox, using an ISO image. The installation takes about five minutes and, in the end, you’ll have a virtual machine, ready to deploy containers. - -### Creating the virtual machine - -Before you deploy that first container, you have to create the virtual machine and install Photon. To do this, open up VirtualBox and click the New button. Walk through the Create Virtual Machine wizard (giving Photon the necessary resources, based on the usage you predict the container server will need). Once you’ve created the virtual machine, you need to first make a change to the settings. Select the newly created virtual machine (in the left pane of the VirtualBox main window) and then click Settings. In the resulting window, click on Network (from the left navigation). - -In the Networking window (Figure 1), you need to change the Attached to drop-down to Bridged Adapter. This will ensure your Photon server is reachable from your network. Once you’ve made that change, click OK. - -### [photon_0.jpg][8] - -![change settings](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_0.jpg?itok=Q0yhOhsZ "change settings") -Figure 1: Changing the VirtualBox network settings for Photon.[Used with permission][1] - -Select your Photon virtual machine from the left navigation and then click Start. You will be prompted to locate and attach the IOS image. Once you’ve done that, Photon will boot up and prompt you to hit Enter to begin the installation. The installation is ncurses based (there is no GUI), but it’s incredibly simple. - -In the next screen (Figure 2), you will be asked if you want to do a Minimal, Full, or OSTree Server. I opted to go the Full route. Select whichever option you require and hit enter. - -### [photon_1.jpg][9] - -![installation type](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_1.jpg?itok=OdnMVpaA "installation type") -Figure 2: Selecting your installation type.[Used with permission][2] - -In the next window, select the disk that will house Photon. Since we’re installing this as a virtual machine, there will be only one disk listed (Figure 3). Tab down to Auto and hit Enter on your keyboard. The installation will then require you to type (and verify) an administrator password. Once you’ve done that, the installation will begin and finish in less than five minutes. - -### [photon_2.jpg][10] - -![Photon ](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_2.jpg?itok=QL1Rs-PH "Photon") -Figure 3: Selecting your hard disk for the Photon installation.[Used with permission][3] - -Once the installation completes, reboot the virtual machine and log in with the username root and the password you created during installation. You are ready to start working. - -Before you begin using Docker on Photon, you’ll want to upgrade the platform. Photon uses the _yum_ package manager, so login as root and issue the command  _yum update_ .If there are any updates available, you’ll be asked to okay the process (Figure 4). - -### [photon_3.jpg][11] - -![Updating](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_3.jpg?itok=vjqrspE2 "Updating") -Figure 4: Updating Photon.[Used with permission][4] - -Usage - -As I mentioned, Photon comes with everything you need to deploy containers or even create a Kubernetes cluster. However, out of the box, there are a few things you’ll need to do. The first thing is to enable the Docker daemon to run at start. To do this, issue the commands: - -``` -systemctl start docker - -systemctl enable docker -``` - -Now we need to create a standard user, so we’re not running the docker command as root. To do this, issue the following commands: - -``` -useradd -m USERNAME - -passwd USERNAME -``` - -Where USERNAME is the name of the user to add. - -Next we need to add the new user to the  _docker_ group with the command: - -``` -usermod -a -G docker USERNAME -``` - -Where USERNAME is the name of the user just created. - -Log out as the root user and log back in as the newly created user. You can now work with the  _docker _ command without having to make use of  _sudo_  or switching to the root user. Pull down an image from Docker Hub and start deploying containers. - -### An outstanding container platform - -Photon is, without a doubt, an outstanding platform, geared specifically for containers. Do note that Photon is an open source project, so there is no paid support to be had. If you find yourself having trouble with Photon, hop on over to the [Issues tab in the Photon Project’s Github page][27], where you can read and post about issues. And if you’re interested in forking Photon, you’ll find the source code on the project’s [official Github page][28]. - -Give Photon a try and see if it doesn’t make deploying Docker containers and/or Kubernetes clusters significantly easier. - - _Learn more about Linux through the free ["Introduction to Linux" ][29]course from The Linux Foundation and edX._ - --------------------------------------------------------------------------------- - -via: 网址 - -作者:[ JACK WALLEN][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/jlwallen -[1]:https://www.linux.com/licenses/category/used-permission -[2]:https://www.linux.com/licenses/category/used-permission -[3]:https://www.linux.com/licenses/category/used-permission -[4]:https://www.linux.com/licenses/category/used-permission -[5]:https://www.linux.com/licenses/category/creative-commons-zero -[6]:https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project -[7]:http://vmware.github.io/lightwave/ -[8]:https://www.linux.com/files/images/photon0jpg -[9]:https://www.linux.com/files/images/photon1jpg -[10]:https://www.linux.com/files/images/photon2jpg -[11]:https://www.linux.com/files/images/photon3jpg -[12]:https://www.linux.com/files/images/photon-linuxjpg -[13]:https://www.linux.com/learn/intro-to-linux/2017/11/how-install-and-use-docker-linux -[14]:https://www.docker.com/ -[15]:https://vmware.github.io/photon/ -[16]:https://www.vmware.com/ -[17]:https://www.vmware.com/products/vsphere.html -[18]:https://azure.microsoft.com/ -[19]:https://cloud.google.com/compute/ -[20]:https://aws.amazon.com/ec2/ -[21]:https://www.virtualbox.org/ -[22]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[23]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[24]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[25]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[26]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[27]:https://github.com/vmware/photon/issues -[28]:https://github.com/vmware/photon -[29]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md index e51c580da9..3496f22f4a 100644 --- a/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md +++ b/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md @@ -1,109 +1,96 @@ -Photon也许能成为你最喜爱的容器操作系统 +Photon 也许能成为你最喜爱的容器操作系统 ============================================================ ![Photon OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon-linux.jpg?itok=jUFHPR_c "Photon OS") -Phonton OS专注于容器,是一个非常出色的平台。 —— Jack Wallen +>Phonton OS 专注于容器,是一个非常出色的平台。 —— Jack Wallen 容器在当下的火热,并不是没有原因的。正如[之前][13]讨论的,容器可以使您轻松快捷地将新的服务与应用部署到您的网络上,而且并不耗费太多的系统资源。比起专用硬件和虚拟机,容器都是更加划算的,除此之外,他们更容易更新与重用。 -更重要的是,容器喜欢Linux(反之亦然)。不需要太多时间和麻烦,你就可以启动一台Linux服务器,运行[Docker][14],再是部署容器。但是,哪种Linux发行版最适合部署容器呢?我们的选择很多。你可以使用标准的Ubuntu服务器平台(更容易安装Docker并部署容器)或者是更轻量级的发行版 —— 专门用于部署容器。 +更重要的是,容器喜欢 Linux(反之亦然)。不需要太多时间和麻烦,你就可以启动一台 Linux 服务器,运行[Docker][14],然后部署容器。但是,哪种 Linux 发行版最适合部署容器呢?我们的选择很多。你可以使用标准的 Ubuntu 服务器平台(更容易安装 Docker 并部署容器)或者是更轻量级的发行版 —— 专门用于部署容器。 -[Photon][15]就是这样的一个发行版。这个特殊的版本是由[VMware][16]于2005年创建的,它包含了Docker的守护进程,并与容器框架(如Mesos和Kubernetes)一起使用。Photon经过优化可与[VMware vSphere][17]协同工作,而且可用于裸机,[Microsoft Azure][18], [Google Compute Engine][19], [Amazon Elastic Compute Cloud][20], 或者 [VirtualBox][21]等。 +[Photon][15] 就是这样的一个发行版。这个特殊的版本是由 [VMware][16] 于 2005 年创建的,它包含了 Docker 的守护进程,并可与容器框架(如 Mesos 和 Kubernetes )一起使用。Photon 经过优化可与 [VMware vSphere][17] 协同工作,而且可用于裸机、[Microsoft Azure][18]、 [Google Compute Engine][19]、 [Amazon Elastic Compute Cloud][20] 或者 [VirtualBox][21] 等。 -Photon通过只安装Docker守护进程所必需的东西来保持它的轻量。而这样做的结果是,这个发行版的大小大约只有300MB。但这足以让Linux的运行一切正常。除此之外,Photon的主要特点还有: - -* 内核调整为性能模式。 - -* 内核根据[内核自防护项目][6](KSPP)进行了加固。 +Photon 通过只安装 Docker 守护进程所必需的东西来保持它的轻量。而这样做的结果是,这个发行版的大小大约只有 300MB。但这足以让 Linux 的运行一切正常。除此之外,Photon 的主要特点还有: +* 内核为性能而调整。 +* 内核根据[内核自防护项目][6](KSPP)进行了加固。 * 所有安装的软件包都根据加固的安全标识来构建。 - * 操作系统在信任验证后启动。 - -* Photon管理进程管理防火墙,网络,软件包,和远程登录在Photon机子上的用户。 - +* Photon 的管理进程可以管理防火墙、网络、软件包,和远程登录在 Photon 机器上的用户。 * 支持持久卷。 - * [Project Lightwave][7] 整合。 - * 及时的安全补丁与更新。 -Photon可以通过[ISO][22],[OVA][23],[Amazon Machine Image][24],[Google Compute Engine image][25]和[Azure VHD][26]安装使用。现在我将向您展示如何使用ISO镜像在VirtualBox上安装Photon。整个安装过程大概需要五分钟,在最后您将有一台随时可以部署容器的虚拟机。 +Photon 可以通过 [ISO 镜像][22]、[OVA][23]、[Amazon Machine Image][24]、[Google Compute Engine 镜像][25] 和 [Azure VHD][26] 安装使用。现在我将向您展示如何使用 ISO 镜像在 VirtualBox 上安装 Photon。整个安装过程大概需要五分钟,在最后您将有一台随时可以部署容器的虚拟机。 ### 创建虚拟机 -在部署第一台容器之前,您必须先创建一台虚拟机并安装Photon。为此,打开VirtualBox并点击“新建”按钮。跟着创建虚拟机向导进行配置(根据您的容器将需要的用途,为Photon提供必要的资源)。在创建好虚拟机后,您所需要做的第一件事就是更改配置。选择新建的虚拟机(在VirtualBox主窗口的左侧面板中),然后单击“设置”。在弹出的窗口中,点击“网络”(在左侧的导航中)。 +在部署第一台容器之前,您必须先创建一台虚拟机并安装 Photon。为此,打开 VirtualBox 并点击“新建”按钮。跟着创建虚拟机向导进行配置(根据您的容器将需要的用途,为 Photon 提供必要的资源)。在创建好虚拟机后,您所需要做的第一件事就是更改配置。选择新建的虚拟机(在 VirtualBox 主窗口的左侧面板中),然后单击“设置”。在弹出的窗口中,点击“网络”(在左侧的导航中)。 -在“网络”窗口(图1)中,你需要在“连接”的下拉窗口中选择桥接。这可以确保您的Photon服务与您的网络相连。完成更改后,单击确定。 - -### [photon_0.jpg][8] +在“网络”窗口(图1)中,你需要在“连接”的下拉窗口中选择桥接。这可以确保您的 Photon 服务与您的网络相连。完成更改后,单击确定。 ![change settings](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_0.jpg?itok=Q0yhOhsZ "change setatings") -图 1: 更改Photon在VirtualBox中的网络设置。[经许可使用][1] -从左侧的导航选择您的Photon虚拟机,点击启动。系统会提示您去加载IOS镜像。当您完成之后,Photon安装程序将会启动并提示您按回车后开始安装。安装过程基于ncurses(没有GUI),但它非常简单。 +*图 1: 更改 Photon 在 VirtualBox 中的网络设置。[经许可使用][1]* -接下来(图2),系统会询问您是要最小化安装,完整安装还是安装OSTree服务器。我选择了完整安装。选择您所需要的任意选项,然后按回车继续。 +从左侧的导航选择您的 Photon 虚拟机,点击启动。系统会提示您去加载 ISO 镜像。当您完成之后,Photon 安装程序将会启动并提示您按回车后开始安装。安装过程基于 ncurses(没有 GUI),但它非常简单。 -### [photon_1.jpg][9] +接下来(图2),系统会询问您是要最小化安装,完整安装还是安装 OSTree 服务器。我选择了完整安装。选择您所需要的任意选项,然后按回车继续。 ![installation type](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_2.jpg?itok=QL1Rs-PH "Photon") -图 2: 选择您的安装类型.[经许可使用][2] -在下一个窗口,选择您要安装Photon的磁盘。由于我们将其安装在虚拟机,因此只有一块磁盘会被列出(图3)。选择“自动”按下回车。然后安装程序会让您输入(并验证)管理员密码。在这之后镜像开始安装在您的磁盘上并在不到5分钟的时间内结束。 +*图 2: 选择您的安装类型。[经许可使用][2]* -### [photon_2.jpg][] +在下一个窗口,选择您要安装 Photon 的磁盘。由于我们将其安装在虚拟机,因此只有一块磁盘会被列出(图3)。选择“自动”按下回车。然后安装程序会让您输入(并验证)管理员密码。在这之后镜像开始安装在您的磁盘上并在不到 5 分钟的时间内结束。 ![Photon](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_1.jpg?itok=OdnMVpaA "installation type") -图 3: 选择安装Photon的硬盘.[经许可使用][3] -安装完成后,重启虚拟机并使用安装时创建的用户root和它的密码登录。一切就绪,你准备好开始工作了。 +*图 3: 选择安装 Photon 的硬盘。[经许可使用][3]* -在开始使用Docker之前,您需要更新一下Photon。Photon使用 _yum_ 软件包管理器,因此在以root用户登录后输入命令 _yum update_。如果有任何可用更新,则会询问您是否确认(图4)。 +安装完成后,重启虚拟机并使用安装时创建的用户 root 和它的密码登录。一切就绪,你准备好开始工作了。 -### [photon_3.jpg][11] +在开始使用 Docker 之前,您需要更新一下 Photon。Photon 使用 `yum` 软件包管理器,因此在以 root 用户登录后输入命令 `yum update`。如果有任何可用更新,则会询问您是否确认(图4)。 ![Updating](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_3.jpg?itok=vjqrspE2 "Updating") -图 4: 更新 Photon.[经许可使用][4] -用法 +*图 4: 更新 Photon。[经许可使用][4]* -正如我所说的,Photon提供了部署容器甚至创建Kubernetes集群所需要的所有包。但是,在使用之前还要做一些事情。首先要启动Docker守护进程。为此,执行以下命令: +### 用法 + +正如我所说的,Photon 提供了部署容器甚至创建 Kubernetes 集群所需要的所有包。但是,在使用之前还要做一些事情。首先要启动 Docker 守护进程。为此,执行以下命令: ``` systemctl start docker - systemctl enable docker ``` -现在我们需要创建一个标准用户,因此我们没有以root去运行docker命令。为此,执行以下命令: +现在我们需要创建一个标准用户,以便我们可以不用 root 去运行 `docker` 命令。为此,执行以下命令: ``` useradd -m USERNAME - passwd USERNAME ``` -其中USERNAME是我们新增的用户的名称。 +其中 “USERNAME” 是我们新增的用户的名称。 -接下来,我们需要将这个新用户添加到 _docker_ 组,执行命令: +接下来,我们需要将这个新用户添加到 “docker” 组,执行命令: ``` usermod -a -G docker USERNAME ``` -其中USERNAME是刚刚创建的用户的名称。 +其中 “USERNAME” 是刚刚创建的用户的名称。 -注销root用户并切换为新增的用户。现在,您已经可以不必使用 _sudo_ 命令或者是切换到root用户来使用 _docker_命令了。从Docker Hub中取出一个镜像开始部署容器吧。 +注销 root 用户并切换为新增的用户。现在,您已经可以不必使用 `sudo` 命令或者切换到 root 用户来使用 `docker` 命令了。从 Docker Hub 中取出一个镜像开始部署容器吧。 ### 一个优秀的容器平台 -在专注于容器方面,Photon毫无疑问是一个出色的平台。请注意,Photon是一个开源项目,因此没有任何付费支持。如果您对Photon有任何的问题,请移步Photon项目的Github下的[Issues][27],那里可以供您阅读相关问题,或者提交您的问题。如果您对Photon感兴趣,您也可以在项目的官方[Github][28]中找到源码。 +在专注于容器方面,Photon 毫无疑问是一个出色的平台。请注意,Photon 是一个开源项目,因此没有任何付费支持。如果您对 Photon 有任何的问题,请移步 Photon 项目的 GitHub 下的 [Issues][27],那里可以供您阅读相关问题,或者提交您的问题。如果您对 Photon 感兴趣,您也可以在该项目的官方 [GitHub][28]中找到源码。 -尝试一下Photon吧,看看它是否能够使得Docker容器和Kubernetes集群的部署更加容易。 +尝试一下 Photon 吧,看看它是否能够使得 Docker 容器和 Kubernetes 集群的部署更加容易。 -欲了解Linux的更多信息,可以通过学习Linux基金会和edX的免费课程,[“Linux 入门”][29]。 +欲了解 Linux 的更多信息,可以通过学习 Linux 基金会和 edX 的免费课程,[“Linux 入门”][29]。 -------------------------------------------------------------------------------- @@ -111,7 +98,7 @@ via: https://www.linux.com/learn/intro-to-linux/2017/11/photon-could-be-your-new 作者:[JACK WALLEN][a] 译者:[KeyLD](https://github.com/KeyLd) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From d533874817e9245d849b7a7d4d2c91eadb2c62c6 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 22:38:59 +0800 Subject: [PATCH 210/344] PUB:20171124 Photon Could Be Your New Favorite Container OS.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @KeyLD 文章的发布地址:https://linux.cn/article-9110-1.html 你的 LCTT 专页地址: https://linux.cn/lctt/KeyLD --- .../20171124 Photon Could Be Your New Favorite Container OS.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171124 Photon Could Be Your New Favorite Container OS.md (100%) diff --git a/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/published/20171124 Photon Could Be Your New Favorite Container OS.md similarity index 100% rename from translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md rename to published/20171124 Photon Could Be Your New Favorite Container OS.md From 17255c900268bf1c6bd669bbed53a5ab58b038e2 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Mon, 4 Dec 2017 22:48:12 +0800 Subject: [PATCH 211/344] Translating by qhwdw --- ...20160922 A Linux users guide to Logical Volume Management.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20160922 A Linux users guide to Logical Volume Management.md b/sources/tech/20160922 A Linux users guide to Logical Volume Management.md index ff0e390f38..baed1b3976 100644 --- a/sources/tech/20160922 A Linux users guide to Logical Volume Management.md +++ b/sources/tech/20160922 A Linux users guide to Logical Volume Management.md @@ -1,4 +1,4 @@ -A Linux user's guide to Logical Volume Management +Translating by qhwdw A Linux user's guide to Logical Volume Management ============================================================ ![Logical Volume Management (LVM)](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_other11x_cc.png?itok=I_kCDYj0 "Logical Volume Management (LVM)") From 2746612bf85dcef35f6133b35b47f226dee9f147 Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Mon, 4 Dec 2017 23:14:31 +0800 Subject: [PATCH 212/344] Revert "Translating by qhwdw" --- core.md | 2 +- ...20160922 A Linux users guide to Logical Volume Management.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core.md b/core.md index 2ec8aa89cf..da45c009fc 100644 --- a/core.md +++ b/core.md @@ -36,4 +36,4 @@ - 除非必要,合并 PR 时不要 squash-merge wxy@LCTT -2016/12/24 +2016/12/24 \ No newline at end of file diff --git a/sources/tech/20160922 A Linux users guide to Logical Volume Management.md b/sources/tech/20160922 A Linux users guide to Logical Volume Management.md index baed1b3976..ff0e390f38 100644 --- a/sources/tech/20160922 A Linux users guide to Logical Volume Management.md +++ b/sources/tech/20160922 A Linux users guide to Logical Volume Management.md @@ -1,4 +1,4 @@ -Translating by qhwdw A Linux user's guide to Logical Volume Management +A Linux user's guide to Logical Volume Management ============================================================ ![Logical Volume Management (LVM)](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_other11x_cc.png?itok=I_kCDYj0 "Logical Volume Management (LVM)") From 0d97d9c993bf939edfa0d62f07c7d39ec919a0f7 Mon Sep 17 00:00:00 2001 From: imquanquan Date: Mon, 4 Dec 2017 23:15:21 +0800 Subject: [PATCH 213/344] fix errors based on the previous translations --- ...ow to Manage Users with Groups in Linux.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/translated/tech/20171201 How to Manage Users with Groups in Linux.md b/translated/tech/20171201 How to Manage Users with Groups in Linux.md index 8baac8707b..1927de6817 100644 --- a/translated/tech/20171201 How to Manage Users with Groups in Linux.md +++ b/translated/tech/20171201 How to Manage Users with Groups in Linux.md @@ -5,13 +5,13 @@ ![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/group-of-people-1645356_1920.jpg?itok=rJlAxBSV) -在本教程中了解如何通过用户组和访问控制表(ACL)来管理用户。 +本教程可以了解如何通过用户组和访问控制表(ACL)来管理用户。 [创意共享协议][4] -当你需要管理一台容纳多个用户的 Linux 机器时,比起一些基本的用户管理工具所提供的方法,有时候你需要对这些用户采取更多的用户权限管理方式。特别是当你要管理某些用户的权限时,这个想法尤为重要。比如说,你有一个目录,一个用户组中的用户可以通过读和写的权限访问这个目录,而其他用户组中的用户对这个目录只有读的权限。通过 Linux 这是完全可以实现的。但是你首先必须了解如何通过用户组和访问控制表(ACL)来管理用户。 +当你需要管理一台容纳多个用户的 Linux 机器时,比起一些基本的用户管理工具所提供的方法,有时候你需要对这些用户采取更多的用户权限管理方式。特别是当你要管理某些用户的权限时,这个想法尤为重要。比如说,你有一个目录,某个用户组中的用户可以通过读和写的权限访问这个目录,而其他用户组中的用户对这个目录只有读的权限。在 Linux 中,这是完全可以实现的。但前提是你必须先了解如何通过用户组和访问控制表(ACL)来管理用户。 -我们将从简单的用户开始,逐渐深入到复杂的访问控制表(ACL)。你所需要做的一切都将在你选择的 Linux 发行版中完成。本文的重点是用户组,所以不会涉及到关于用户的基础知识。 +我们将从简单的用户开始,逐渐深入到复杂的访问控制表(ACL)。你可以在你所选择的 Linux 发行版完成你所需要做的一切。本文的重点是用户组,所以不会涉及到关于用户的基础知识。 为了达到演示的目的,我将假设: @@ -27,7 +27,7 @@ * editors -olivia 属于 editors 用户组,而 nathan 属于 readers 用户组。reader 用户组对 ``/DATA`` 目录只有读的权限,而 editors 用户组则对 ``/DATA`` 目录同时有读和写的权限。当然,这是个非常小的任务,但它会给你基本的用法。你可以扩展这个任务以适应你其他更大的需求。 +olivia 属于 editors 用户组,而 nathan 属于 readers 用户组。reader 用户组对 ``/DATA`` 目录只有读的权限,而 editors 用户组则对 ``/DATA`` 目录同时有读和写的权限。当然,这是个非常小的任务,但它会给你基本的信息·。你可以扩展这个任务以适应你其他更大的需求。 我将在 Ubuntu 16.04 Server 平台上进行演示。这些命令都是通用的,唯一不同的是,要是在你的发行版中不使用 sudo 命令,你必须切换到 root 用户来执行这些命令。 @@ -74,7 +74,7 @@ addgroup editors [Used with permission][5] -创建用户组后,我们需要给他们添加用户。我们用以下命令来将 nathan 添加到 readers 用户组: +创建用户组后,我们需要添加我们的用户到这两个用户组。我们用以下命令来将 nathan 用户添加到 readers 用户组: ``` sudo usermod -a -G readers nathan @@ -85,11 +85,11 @@ sudo usermod -a -G readers nathan sudo usermod -a -G editors olivia ``` -现在我们已经准备好用用户组来管理用户了。 +现在我们可以通过用户组来管理用户了。 ### 给用户组授予目录的权限 -假设你有个目录 ``/READERS``,允许 readers 用户组的所有成员访问这个目录。首先,我们执行以下命令来更改目录所属用户组: +假设你有个目录 ``/READERS`` 且允许 readers 用户组的所有成员访问这个目录。首先,我们执行以下命令来更改目录所属用户组: ``` sudo chown -R :readers /READERS @@ -101,7 +101,7 @@ sudo chown -R :readers /READERS sudo chmod -R g-w /READERS ``` -然后我们执行下面的命令来收回其他用户对这个目录的访问权限(以防止任何不在读者组中的用户访问这个目录里的文件): +然后我们执行下面的命令来收回其他用户对这个目录的访问权限(以防止任何不在 readers 组中的用户访问这个目录里的文件): ``` sudo chmod -R o-x /READERS @@ -126,7 +126,7 @@ sudo chmod -R o-x /EDITORS ### 使用访问控制表(ACL) -现在,让我们把这个问题变得棘手一点。假设你有一个目录 ``/DATA`` 并且你想给 readers 用户组的成员读取权限同时给 editors 用户组的成员读和写的权限。为此,你必须要用到 setfacl 命令。setfacl 命令可以为文件或文件夹设置一个访问控制表(ACL)。 +现在,让我们把这个问题变得棘手一点。假设你有一个目录 ``/DATA`` 并且你想给 readers 用户组的成员读取权限并同时给 editors 用户组的成员读和写的权限。为此,你必须要用到 setfacl 命令。setfacl 命令可以为文件或文件夹设置一个访问控制表(ACL)。 这个命令的结构如下: @@ -142,7 +142,7 @@ sudo setfacl -m g:readers:rx -R /DATA 现在 readers 用户组里面的每一个用户都可以读取 /DATA 目录里的文件了,但是他们不能修改里面的内容。 -为了给 editors 用户组里面的用户读写权限,我们执行了以下的命令: +为了给 editors 用户组里面的用户读写权限,我们执行了以下命令: ``` sudo setfacl -m g:editors:rwx -R /DATA @@ -151,7 +151,7 @@ sudo setfacl -m g:editors:rwx -R /DATA ### 更多的权限控制 -使用访问控制表(ACL),你可以实现你所需的权限控制。你可以实现将用户添加到用户组,并且可靠灵活地控制这些用户组对每个目录的权限以达到你的需求。想要了解上述工具的更多信息,可以执行下列的命令: +使用访问控制表(ACL),你可以实现你所需的权限控制。你可以添加用户到用户组,并且灵活地控制这些用户组对每个目录的权限以达到你的需求。如果想了解上述工具的更多信息,可以执行下列的命令: * man usradd From 832f9e7fe8a42e4bd8b588f52a434f33a673542d Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 5 Dec 2017 07:22:51 +0800 Subject: [PATCH 214/344] translating by aiwhj translating by aiwhj --- .../20171129 5 best practices for getting started with DevOps.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171129 5 best practices for getting started with DevOps.md b/sources/tech/20171129 5 best practices for getting started with DevOps.md index 962f37aaf4..7694180c14 100644 --- a/sources/tech/20171129 5 best practices for getting started with DevOps.md +++ b/sources/tech/20171129 5 best practices for getting started with DevOps.md @@ -1,3 +1,4 @@ +translating---aiwhj 5 best practices for getting started with DevOps ============================================================ From a94f1fca1bfa0c9150da7656dce9685b31bec345 Mon Sep 17 00:00:00 2001 From: Sihua Zheng Date: Tue, 5 Dec 2017 09:12:33 +0800 Subject: [PATCH 215/344] translated --- ...ilable on Flathub the Flatpak App Store.md | 73 ------------------- ...ilable on Flathub the Flatpak App Store.md | 70 ++++++++++++++++++ 2 files changed, 70 insertions(+), 73 deletions(-) delete mode 100644 sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md create mode 100644 translated/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md diff --git a/sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md b/sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md deleted file mode 100644 index fe72e37128..0000000000 --- a/sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md +++ /dev/null @@ -1,73 +0,0 @@ -translating---geekpi - - -# LibreOffice Is Now Available on Flathub, the Flatpak App Store - -![LibreOffice on Flathub](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/libroffice-on-flathub-750x250.jpeg) - -LibreOffice is now available to install from [Flathub][3], the centralised Flatpak app store. - -Its arrival allows anyone running a modern Linux distribution to install the latest stable release of LibreOffice in a click or two, without having to hunt down a PPA, tussle with tarballs or wait for a distro provider to package it up. - -A [LibreOffice Flatpak][5] has been available for users to download and install since August of last year and the [LibreOffice 5.2][6] release. - -What’s “new” here is the distribution method. Rather than release updates through their own dedicated server The Document Foundation has opted to use Flathub. - -This is  _great_  news for end users as it means there’s one less repo to worry about adding on a fresh install, but it’s also good news for Flatpak advocates too: LibreOffice is open-source software’s most popular productivity suite. Its support for both format and app store is sure to be warmly welcomed. - -At the time of writing you can install LibreOffice 5.4.2 from Flathub. New stable releases will be added as and when they’re released. - -### Enable Flathub on Ubuntu - -![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/flathub-750x495.png) - -Fedora, Arch, and Linux Mint 18.3 users have Flatpak installed, ready to go, out of the box. Mint even comes with the Flathub remote pre-enabled. - -[Install LibreOffice from Flathub][7] - -To get Flatpak up and running on Ubuntu you first have to install it: - -``` -sudo apt install flatpak gnome-software-plugin-flatpak -``` - -To be able to install apps from Flathub you need to add the Flathub remote server: - -``` -flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo -``` - -That’s pretty much it. Just log out and back in (so that Ubuntu Software refreshes its cache) and you  _should_  be able to find any Flatpak apps available on Flathub through the Ubuntu Software app. - -In this instance, search for “LibreOffice” and locate the result that has a line of text underneath mentioning Flathub. (Do bear in mind that Ubuntu has tweaked the Software client to shows Snap app results above everything else, so you may need scroll down the list of results to see it). - -There is a [bug with installing Flatpak apps][8] from a flatpakref file, so if the above method doesn’t work you can also install Flatpak apps form Flathub using the command line. - -The Flathub website lists the command needed to install each app. Switch to the “Command Line” tab to see them. - -#### More apps on Flathub - -If you read this site regularly enough you’ll know that I  _love_  Flathub. It’s home to some of my favourite apps (Corebird, Parlatype, GNOME MPV, Peek, Audacity, GIMP… etc). I get the latest, stable versions of these apps (plus any dependencies they need) without compromise. - -And, as I tweeted a week or so back, most Flatpak apps now look great with GTK themes — no more [workarounds][9]required! - --------------------------------------------------------------------------------- - -via: http://www.omgubuntu.co.uk/2017/11/libreoffice-now-available-flathub-flatpak-app-store - -作者:[ JOEY SNEDDON ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://plus.google.com/117485690627814051450/?rel=author -[1]:https://plus.google.com/117485690627814051450/?rel=author -[2]:http://www.omgubuntu.co.uk/category/news -[3]:http://www.flathub.org/ -[4]:http://www.omgubuntu.co.uk/2017/11/libreoffice-now-available-flathub-flatpak-app-store -[5]:http://www.omgubuntu.co.uk/2016/08/libreoffice-5-2-released-whats-new -[6]:http://www.omgubuntu.co.uk/2016/08/libreoffice-5-2-released-whats-new -[7]:https://flathub.org/repo/appstream/org.libreoffice.LibreOffice.flatpakref -[8]:https://bugs.launchpad.net/ubuntu/+source/gnome-software/+bug/1716409 -[9]:http://www.omgubuntu.co.uk/2017/05/flatpak-theme-issue-fix diff --git a/translated/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md b/translated/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md new file mode 100644 index 0000000000..4edb744098 --- /dev/null +++ b/translated/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md @@ -0,0 +1,70 @@ +# LibreOffice 现在在 Flatpak 的 Flathub 应用商店提供 + +![LibreOffice on Flathub](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/libroffice-on-flathub-750x250.jpeg) + +LibreOffice 现在可以从集中化的 Flatpak 应用商店 [Flathub][3] 进行安装。 + +它的到来使任何运行现代 Linux 发行版的人都能只点击一两次安装 LibreOffice 的最新稳定版本,而无需搜索 PPA,纠缠 tar 包或等待发行商将其打包。 + +自去年 8 月份以来,[LibreOffice Flatpak][5] 已经可供用户下载和安装 [LibreOffice 5.2][6]。 + +这里“新”的是发行方法。文档基金会选择使用 Flathub 而不是专门的服务器来发布更新。 + +这对于终端用户来说是一个_很好_的消息,因为这意味着不需要在新安装时担心仓库,但对于 Flatpak 的倡议者来说也是一个好消息:LibreOffice 是开源软件最流行的生产力套件。它对格式和应用商店的支持肯定会受到热烈的欢迎。 + +在撰写本文时,你可以从 Flathub 安装 LibreOffice 5.4.2。新的稳定版本将在发布时添加。 + +### 在 Ubuntu 上启用 Flathub + +![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/flathub-750x495.png) + +Fedora、Arch 和 Linux Mint 18.3 用户已经安装了 Flatpak,随时可以开箱即用。Mint 甚至预启用了 Flathub remote。 + +[从 Flathub 安装 LibreOffice][7] + +要在 Ubuntu 上启动并运行 Flatpak,首先必须安装它: + +``` +sudo apt install flatpak gnome-software-plugin-flatpak +``` + +为了能够从 Flathub 安装应用程序,你需要添加 Flathub 远程服务器: + +``` +flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +``` + +这就行了。只需注销并返回(以便 Ubuntu Software 刷新其缓存),之后你应该能够通过 Ubuntu Software 看到 Flathub 上的任何 Flatpak 程序了。 + +在本例中,搜索 “LibreOffice” 并在结果中找到下面有 Flathub 提示的结果。(请记住,Ubuntu 已经调整了客户端,来将 Snap 程序显示在最上面,所以你可能需要向下滚动列表来查看它)。 + +从 flatpakref 中[安装 Flatpak 程序有一个 bug][8],所以如果上面的方法不起作用,你也可以使用命令行从 Flathub 中安装 Flathub 程序。 + +Flathub 网站列出了安装每个程序所需的命令。切换到“命令行”选项卡来查看它们。 + +#### Flathub 上更多的应用 + +如果你经常看这个网站,你就会知道我喜欢 Flathub。这是我最喜欢的一些应用(Corebird、Parlatype、GNOME MPV、Peek、Audacity、GIMP 等)的家园。我无需折衷就能获得这些应用程序的最新,稳定版本(加上它们需要的所有依赖)。 + +而且,在我 twiiter 上发布一周左右后,大多数 Flatpak 应用现在看起来有很棒 GTK 主题 - 不再需要[临时方案][9]了! + +-------------------------------------------------------------------------------- + +via: http://www.omgubuntu.co.uk/2017/11/libreoffice-now-available-flathub-flatpak-app-store + +作者:[ JOEY SNEDDON ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://plus.google.com/117485690627814051450/?rel=author +[1]:https://plus.google.com/117485690627814051450/?rel=author +[2]:http://www.omgubuntu.co.uk/category/news +[3]:http://www.flathub.org/ +[4]:http://www.omgubuntu.co.uk/2017/11/libreoffice-now-available-flathub-flatpak-app-store +[5]:http://www.omgubuntu.co.uk/2016/08/libreoffice-5-2-released-whats-new +[6]:http://www.omgubuntu.co.uk/2016/08/libreoffice-5-2-released-whats-new +[7]:https://flathub.org/repo/appstream/org.libreoffice.LibreOffice.flatpakref +[8]:https://bugs.launchpad.net/ubuntu/+source/gnome-software/+bug/1716409 +[9]:http://www.omgubuntu.co.uk/2017/05/flatpak-theme-issue-fix From 7af7dee62e699dcbcc64adf28af774f350f9d67e Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 5 Dec 2017 09:16:46 +0800 Subject: [PATCH 216/344] translating --- .../20171125 AWS to Help Build ONNX Open Source AI Platform.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md b/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md index c09d66bc57..1e9424178e 100644 --- a/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md +++ b/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md @@ -1,3 +1,5 @@ +translating---geekpi + AWS to Help Build ONNX Open Source AI Platform ============================================================ ![onnx-open-source-ai-platform](https://www.linuxinsider.com/article_images/story_graphics_xlarge/xl-2017-onnx-1.jpg) From 5f2c9586bd9a97ca81f749f1ede5e543e507e26a Mon Sep 17 00:00:00 2001 From: qhwdw Date: Mon, 4 Dec 2017 15:30:49 +0800 Subject: [PATCH 217/344] Translated by qhwdw --- ...1109 Concurrent Servers- Part 4 - libuv.md | 492 ++++++++++++++++++ 1 file changed, 492 insertions(+) create mode 100644 translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md diff --git a/translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md b/translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md new file mode 100644 index 0000000000..b4db491e4e --- /dev/null +++ b/translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md @@ -0,0 +1,492 @@ +[并发服务器:第四部分 - libuv][17] +============================================================ + +这是写并发网络服务器系列文章的第四部分。在这一部分中,我们将使用 libuv 去再次重写我们的服务器,并且也讨论关于使用一个线程池在回调中去处理耗时任务。最终,我们去看一下底层的 libuv,花一点时间去学习如何用异步 API 对文件系统阻塞操作进行封装。 + +这一系列的所有文章包括: + +* [第一部分 - 简介][7] + +* [第二部分 - 线程][8] + +* [第三部分 - 事件驱动][9] + +* [第四部分 - libuv][10] + +### 使用 Linux 抽象出事件驱动循环 + +在 [第三部分][11] 中,我们看到了基于 `select` 和 `epoll` 的相似之处,并且,我说过,在它们之间抽象出细微的差别是件很有魅力的事。Numerous 库已经做到了这些,但是,因为在这一部分中,我将去选一个并使用它。我选的这个库是 [libuv][12],它最初设计用于 Node.js 底层的轻便的平台层,并且,后来发现在其它的项目中已有使用。libuv 是用 C 写的,因此,它具有很高的可移植性,非常适用嵌入到像 JavaScript 和 Python 这样的高级语言中。 + +虽然 libuv 为抽象出底层平台细节已经有了一个非常大的框架,但它仍然是一个以 _事件循环_ 思想为中心的。在我们第三部分的事件驱动服务器中,事件循环在 main 函数中是很明确的;当使用 libuv 时,循环通常隐藏在库自身中,而用户代码仅需要注册事件句柄(作为一个回调函数)和运行这个循环。此外,libuv 将为给定的平台实现更快的事件循环实现。对于 Linux 它是 epoll,等等。 + +![libuv loop](https://eli.thegreenplace.net/images/2017/libuvloop.png) + +libuv 支持多路事件循环,并且,因此一个事件循环在库中是非常重要的;它有一个句柄 - `uv_loop_t`,和创建/杀死/启动/停止循环的函数。也就是说,在这篇文章中,我将仅需要使用 “默认的” 循环,libuv 可通过 `uv_default_loop()` 提供它;多路循环大多用于多线程事件驱动的服务器,这是一个更高级别的话题,我将留在这一系列文章的以后部分。 + +### 使用 libuv 的并发服务器 + +为了对 libuv 有一个更深的印象,让我们跳转到我们的可靠的协议服务器,它通过我们的这个系列已经有了一个强大的重新实现。这个服务器的结构与第三部分中的基于 select 和 epoll 的服务器有一些相似之处。因为,它也依赖回调。完整的 [示例代码在这里][13];我们开始设置这个服务器的套接字绑定到一个本地端口: + +``` +int portnum = 9090; +if (argc >= 2) { + portnum = atoi(argv[1]); +} +printf("Serving on port %d\n", portnum); + +int rc; +uv_tcp_t server_stream; +if ((rc = uv_tcp_init(uv_default_loop(), &server_stream)) < 0) { + die("uv_tcp_init failed: %s", uv_strerror(rc)); +} + +struct sockaddr_in server_address; +if ((rc = uv_ip4_addr("0.0.0.0", portnum, &server_address)) < 0) { + die("uv_ip4_addr failed: %s", uv_strerror(rc)); +} + +if ((rc = uv_tcp_bind(&server_stream, (const struct sockaddr*)&server_address, 0)) < 0) { + die("uv_tcp_bind failed: %s", uv_strerror(rc)); +} +``` + +除了它被封装进 libuv APIs 中之外,你看到的是一个相当标准的套接字。在它的返回中,我们取得一个可工作于任何 libuv 支持的平台上的轻便的接口。 + +这些代码也很认真负责地演示了错误处理;多数的 libuv 函数返回一个整数状态,返回一个负数意味着出现了一个错误。在我们的服务器中,我们把这些错误按致命的问题处理,但也可以设想为一个更优雅的恢复。 + +现在,那个套接字已经绑定,是时候去监听它了。这里我们运行一个回调注册: + +``` +// Listen on the socket for new peers to connect. When a new peer connects, +// the on_peer_connected callback will be invoked. +if ((rc = uv_listen((uv_stream_t*)&server_stream, N_BACKLOG, on_peer_connected)) < 0) { + die("uv_listen failed: %s", uv_strerror(rc)); +} +``` + +当新的对端连接到这个套接字,`uv_listen` 将被调用去注册一个事件循环回调。我们的回调在这里被称为 `on_peer_connected`,并且我们一会儿将去检测它。 + +最终,main 运行这个 libuv 循环,直到它被停止(`uv_run` 仅在循环被停止或者发生错误时返回) + +``` +// Run the libuv event loop. +uv_run(uv_default_loop(), UV_RUN_DEFAULT); + +// If uv_run returned, close the default loop before exiting. +return uv_loop_close(uv_default_loop()); +``` + +注意,那个仅是一个单一的通过 main 优先去运行的事件循环回调;我们不久将看到怎么去添加更多的另外的回调。在事件循环的整个运行时中,添加和删除回调并不是一个问题 - 事实上,大多数服务器就是这么写的。 + +这是一个 `on_peer_connected`,它处理到服务器的新的客户端连接: + +``` +void on_peer_connected(uv_stream_t* server_stream, int status) { + if (status < 0) { + fprintf(stderr, "Peer connection error: %s\n", uv_strerror(status)); + return; + } + + // client will represent this peer; it's allocated on the heap and only + // released when the client disconnects. The client holds a pointer to + // peer_state_t in its data field; this peer state tracks the protocol state + // with this client throughout interaction. + uv_tcp_t* client = (uv_tcp_t*)xmalloc(sizeof(*client)); + int rc; + if ((rc = uv_tcp_init(uv_default_loop(), client)) < 0) { + die("uv_tcp_init failed: %s", uv_strerror(rc)); + } + client->data = NULL; + + if (uv_accept(server_stream, (uv_stream_t*)client) == 0) { + struct sockaddr_storage peername; + int namelen = sizeof(peername); + if ((rc = uv_tcp_getpeername(client, (struct sockaddr*)&peername, + &namelen)) < 0) { + die("uv_tcp_getpeername failed: %s", uv_strerror(rc)); + } + report_peer_connected((const struct sockaddr_in*)&peername, namelen); + + // Initialize the peer state for a new client: we start by sending the peer + // the initial '*' ack. + peer_state_t* peerstate = (peer_state_t*)xmalloc(sizeof(*peerstate)); + peerstate->state = INITIAL_ACK; + peerstate->sendbuf[0] = '*'; + peerstate->sendbuf_end = 1; + peerstate->client = client; + client->data = peerstate; + + // Enqueue the write request to send the ack; when it's done, + // on_wrote_init_ack will be called. The peer state is passed to the write + // request via the data pointer; the write request does not own this peer + // state - it's owned by the client handle. + uv_buf_t writebuf = uv_buf_init(peerstate->sendbuf, peerstate->sendbuf_end); + uv_write_t* req = (uv_write_t*)xmalloc(sizeof(*req)); + req->data = peerstate; + if ((rc = uv_write(req, (uv_stream_t*)client, &writebuf, 1, + on_wrote_init_ack)) < 0) { + die("uv_write failed: %s", uv_strerror(rc)); + } + } else { + uv_close((uv_handle_t*)client, on_client_closed); + } +} +``` + +这些代码都有很好的注释,但是,这里有一些重要的 libuv 语法我想去强调一下: + +* 进入回调中的自定义数据:因为 C 还没有停用,这可能是个挑战,libuv 在它的处理类型中有一个 `void*` 数据域;这些域可以被用于进入到用户数据。例如,注意 `client->data` 是如何指向到一个 `peer_state_t` 结构上,以便于通过 `uv_write` 和 `uv_read_start` 注册的回调可以知道它们正在处理的是哪个客户端的数据。 + +* 内存管理:事件驱动编程在语言中使用垃圾回收是非常容易的,因为,回调通常运行在一个它们注册的完全不同的栈框架中,使得基于栈的内存管理很困难。它总是需要传递堆分配的数据到 libuv 回调中(当所有回调运行时,除了 main,其它的都运行在栈上),并且,为了避免泄漏,许多情况下都要求这些数据去安全释放。这些都是些需要实践的内容 [[1]][6]。 + +这个服务器上对端的状态如下: + +``` +typedef struct { + ProcessingState state; + char sendbuf[SENDBUF_SIZE]; + int sendbuf_end; + uv_tcp_t* client; +} peer_state_t; +``` + +它与第三部分中的状态非常类似;我们不再需要 sendptr,因为,在调用 "done writing" 回调之前,`uv_write` 将确保去发送它提供的整个缓冲。我们也为其它的回调使用保持了一个到客户端的指针。这里是 `on_wrote_init_ack`: + +``` +void on_wrote_init_ack(uv_write_t* req, int status) { + if (status) { + die("Write error: %s\n", uv_strerror(status)); + } + peer_state_t* peerstate = (peer_state_t*)req->data; + // Flip the peer state to WAIT_FOR_MSG, and start listening for incoming data + // from this peer. + peerstate->state = WAIT_FOR_MSG; + peerstate->sendbuf_end = 0; + + int rc; + if ((rc = uv_read_start((uv_stream_t*)peerstate->client, on_alloc_buffer, + on_peer_read)) < 0) { + die("uv_read_start failed: %s", uv_strerror(rc)); + } + + // Note: the write request doesn't own the peer state, hence we only free the + // request itself, not the state. + free(req); +} +``` + +然后,我们确信知道了这个初始的 '*' 已经被发送到对端,我们通过调用 `uv_read_start` 去监听从这个对端来的入站数据,它注册一个回调(`on_peer_read`)去被调用,不论什么时候,事件循环都在套接字上接收来自客户端的调用: + +``` +void on_peer_read(uv_stream_t* client, ssize_t nread, const uv_buf_t* buf) { + if (nread < 0) { + if (nread != uv_eof) { + fprintf(stderr, "read error: %s\n", uv_strerror(nread)); + } + uv_close((uv_handle_t*)client, on_client_closed); + } else if (nread == 0) { + // from the documentation of uv_read_cb: nread might be 0, which does not + // indicate an error or eof. this is equivalent to eagain or ewouldblock + // under read(2). + } else { + // nread > 0 + assert(buf->len >= nread); + + peer_state_t* peerstate = (peer_state_t*)client->data; + if (peerstate->state == initial_ack) { + // if the initial ack hasn't been sent for some reason, ignore whatever + // the client sends in. + free(buf->base); + return; + } + + // run the protocol state machine. + for (int i = 0; i < nread; ++i) { + switch (peerstate->state) { + case initial_ack: + assert(0 && "can't reach here"); + break; + case wait_for_msg: + if (buf->base[i] == '^') { + peerstate->state = in_msg; + } + break; + case in_msg: + if (buf->base[i] == '$') { + peerstate->state = wait_for_msg; + } else { + assert(peerstate->sendbuf_end < sendbuf_size); + peerstate->sendbuf[peerstate->sendbuf_end++] = buf->base[i] + 1; + } + break; + } + } + + if (peerstate->sendbuf_end > 0) { + // we have data to send. the write buffer will point to the buffer stored + // in the peer state for this client. + uv_buf_t writebuf = + uv_buf_init(peerstate->sendbuf, peerstate->sendbuf_end); + uv_write_t* writereq = (uv_write_t*)xmalloc(sizeof(*writereq)); + writereq->data = peerstate; + int rc; + if ((rc = uv_write(writereq, (uv_stream_t*)client, &writebuf, 1, + on_wrote_buf)) < 0) { + die("uv_write failed: %s", uv_strerror(rc)); + } + } + } + free(buf->base); +} +``` + +这个服务器的运行时行为非常类似于第三部分的事件驱动服务器:所有的客户端都在一个单个的线程中并发处理。并且一些行为被维护在服务器代码中:服务器的逻辑实现为一个集成的回调,并且长周期运行是禁止的,因为它会阻塞事件循环。这一点也很类似。让我们进一步探索这个问题。 + +### 在事件驱动循环中的长周期运行的操作 + +单线程的事件驱动代码使它先天地对一些常见问题非常敏感:整个循环中的长周期运行的代码块。参见如下的程序: + +``` +void on_timer(uv_timer_t* timer) { + uint64_t timestamp = uv_hrtime(); + printf("on_timer [%" PRIu64 " ms]\n", (timestamp / 1000000) % 100000); + + // "Work" + if (random() % 5 == 0) { + printf("Sleeping...\n"); + sleep(3); + } +} + +int main(int argc, const char** argv) { + uv_timer_t timer; + uv_timer_init(uv_default_loop(), &timer); + uv_timer_start(&timer, on_timer, 0, 1000); + return uv_run(uv_default_loop(), UV_RUN_DEFAULT); +} +``` + +它用一个单个注册的回调运行一个 libuv 事件循环:`on_timer`,它被每秒钟循环调用一次。回调报告一个时间戳,并且,偶尔通过睡眠 3 秒去模拟一个长周期运行。这是运行示例: + +``` +$ ./uv-timer-sleep-demo +on_timer [4840 ms] +on_timer [5842 ms] +on_timer [6843 ms] +on_timer [7844 ms] +Sleeping... +on_timer [11845 ms] +on_timer [12846 ms] +Sleeping... +on_timer [16847 ms] +on_timer [17849 ms] +on_timer [18850 ms] +... +``` + +`on_timer` 忠实地每秒执行一次,直到随机出现的睡眠为止。在那个时间点,`on_timer` 不再被调用,直到睡眠时间结束;事实上,_没有其它的回调_  在这个时间帧中被调用。这个睡眠调用阻塞当前线程,它正是被调用的线程,并且也是事件循环使用的线程。当这个线程被阻塞后,事件循环也被阻塞。 + +这个示例演示了在事件驱动的调用中为什么回调不能被阻塞是多少的重要。并且,同样适用于 Node.js 服务器、客户端侧的 Javascript、大多数的 GUI 编程框架、以及许多其它的异步编程模型。 + +但是,有时候运行耗时的任务是不可避免的。并不是所有任务都有一个异步 APIs;例如,我们可能使用一些仅有同步 API 的库去处理,或者,正在执行一个可能的长周期计算。我们如何用事件驱动编程去结合这些代码?线程可以帮到你! + +### “转换” 阻塞调用到异步调用的线程 + +一个线程池可以被用于去转换阻塞调用到异步调用,通过与事件循环并行运行,并且当任务完成时去由它去公布事件。一个给定的阻塞函数 `do_work()`,这里介绍了它是怎么运行的: + +1. 在一个回调中,用 `do_work()` 代表直接调用,我们将它打包进一个 “任务”,并且请求线程池去运行这个任务。当任务完成时,我们也为循环去调用它注册一个回调;我们称它为 `on_work_done()`。 + +2. 在这个时间点,我们的回调可以返回并且事件循环保持运行;在同一时间点,线程池中的一个线程运行这个任务。 + +3. 一旦任务运行完成,通知主线程(指正在运行事件循环的线程),并且,通过事件循环调用 `on_work_done()`。 + +让我们看一下,使用 libuv 的工作调度 API,是怎么去解决我们前面的 timer/sleep 示例中展示的问题的: + +``` +void on_after_work(uv_work_t* req, int status) { + free(req); +} + +void on_work(uv_work_t* req) { + // "Work" + if (random() % 5 == 0) { + printf("Sleeping...\n"); + sleep(3); + } +} + +void on_timer(uv_timer_t* timer) { + uint64_t timestamp = uv_hrtime(); + printf("on_timer [%" PRIu64 " ms]\n", (timestamp / 1000000) % 100000); + + uv_work_t* work_req = (uv_work_t*)malloc(sizeof(*work_req)); + uv_queue_work(uv_default_loop(), work_req, on_work, on_after_work); +} + +int main(int argc, const char** argv) { + uv_timer_t timer; + uv_timer_init(uv_default_loop(), &timer); + uv_timer_start(&timer, on_timer, 0, 1000); + return uv_run(uv_default_loop(), UV_RUN_DEFAULT); +} +``` + +通过一个 work_req [[2]][14] 类型的句柄,我们进入一个任务队列,代替在 `on_timer` 上直接调用 sleep,这个函数在任务中(`on_work`)运行,并且,一旦任务完成(`on_after_work`),这个函数被调用一次。`on_work` 在这里是指发生的 “work”(阻塞中的/耗时的操作)。在这两个回调传递到 `uv_queue_work` 时,注意一个关键的区别:`on_work` 运行在线程池中,而 `on_after_work` 运行在事件循环中的主线程上 - 就好像是其它的回调一样。 + +让我们看一下这种方式的运行: + +``` +$ ./uv-timer-work-demo +on_timer [89571 ms] +on_timer [90572 ms] +on_timer [91573 ms] +on_timer [92575 ms] +Sleeping... +on_timer [93576 ms] +on_timer [94577 ms] +Sleeping... +on_timer [95577 ms] +on_timer [96578 ms] +on_timer [97578 ms] +... +``` + +即便在 sleep 函数被调用时,定时器也每秒钟滴答一下,睡眠(sleeping)现在运行在一个单独的线程中,并且不会阻塞事件循环。 + +### 一个用于练习的素数测试服务器 + +因为通过睡眼去模拟工作并不是件让人兴奋的事,我有一个事先准备好的更综合的一个示例 - 一个基于套接字接受来自客户端的数字的服务器,检查这个数字是否是素数,然后去返回一个 “prime" 或者 “composite”。完整的 [服务器代码在这里][15] - 我不在这里粘贴了,因为它太长了,更希望读者在一些自己的练习中去体会它。 + +这个服务器使用了一个原生的素数测试算法,因此,对于大的素数可能花很长时间才返回一个回答。在我的机器中,对于 2305843009213693951,它花了 ~5 秒钟去计算,但是,你的方法可能不同。 + +练习 1:服务器有一个设置(通过一个名为 MODE 的环境变量)要么去在套接字回调(意味着在主线程上)中运行素数测试,要么在 libuv 工作队列中。当多个客户端同时连接时,使用这个设置来观察服务器的行为。当它计算一个大的任务时,在阻塞模式中,服务器将不回复其它客户端,而在非阻塞模式中,它会回复。 + +练习 2;libuv 有一个缺省大小的线程池,并且线程池的大小可以通过环境变量配置。你可以通过使用多个客户端去实验找出它的缺省值是多少?找到线程池缺省值后,使用不同的设置去看一下,在重负载下怎么去影响服务器的响应能力。 + +### 在非阻塞文件系统中使用工作队列 + +对于仅傻傻的演示和 CPU 密集型的计算来说,将可能的阻塞操作委托给一个线程池并不是明智的;libuv 在它的文件系统 APIs 中本身就大量使用了这种性能。通过这种方式,libuv 使用一个异步 API,在一个轻便的方式中,显示出它强大的文件系统的处理能力。 + +让我们使用 `uv_fs_read()`,例如,这个函数从一个文件中(以一个 `uv_fs_t` 句柄为代表)读取一个文件到一个缓冲中 [[3]][16],并且当读取完成后调用一个回调。换句话说,`uv_fs_read()` 总是立即返回,甚至如果文件在一个类似 NFS 的系统上,并且,数据到达缓冲区可能需要一些时间。换句话说,这个 API 与这种方式中其它的 libuv APIs 是异步的。这是怎么工作的呢? + +在这一点上,我们看一下 libuv 的底层;内部实际上非常简单,并且它是一个很好的练习。作为一个便携的库,libuv 对于 Windows 和 Unix 系统在它的许多函数上有不同的实现。我们去看一下在 libuv 源树中的 src/unix/fs.c。 + +这是 `uv_fs_read` 的代码: + +``` +int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, + uv_file file, + const uv_buf_t bufs[], + unsigned int nbufs, + int64_t off, + uv_fs_cb cb) { + if (bufs == NULL || nbufs == 0) + return -EINVAL; + + INIT(READ); + req->file = file; + + req->nbufs = nbufs; + req->bufs = req->bufsml; + if (nbufs > ARRAY_SIZE(req->bufsml)) + req->bufs = uv__malloc(nbufs * sizeof(*bufs)); + + if (req->bufs == NULL) { + if (cb != NULL) + uv__req_unregister(loop, req); + return -ENOMEM; + } + + memcpy(req->bufs, bufs, nbufs * sizeof(*bufs)); + + req->off = off; + POST; +} +``` + +第一次看可能觉得很困难,因为它延缓真实的工作到 INIT 和 POST 宏中,在 POST 中与一些本地变量一起设置。这样做可以避免了文件中的许多重复代码。 + +这是 INIT 宏: + +``` +#define INIT(subtype) \ + do { \ + req->type = UV_FS; \ + if (cb != NULL) \ + uv__req_init(loop, req, UV_FS); \ + req->fs_type = UV_FS_ ## subtype; \ + req->result = 0; \ + req->ptr = NULL; \ + req->loop = loop; \ + req->path = NULL; \ + req->new_path = NULL; \ + req->cb = cb; \ + } \ + while (0) +``` + +它设置了请求,并且更重要的是,设置 `req->fs_type` 域为真实的 FS 请求类型。因为 `uv_fs_read` 调用 invokes INIT(READ),它意味着 `req->fs_type` 被分配一个常数 `UV_FS_READ`。 + +这是 POST 宏: + +``` +#define POST \ + do { \ + if (cb != NULL) { \ + uv__work_submit(loop, &req->work_req, uv__fs_work, uv__fs_done); \ + return 0; \ + } \ + else { \ + uv__fs_work(&req->work_req); \ + return req->result; \ + } \ + } \ + while (0) +``` + +它做什么取决于回调是否为 NULL。在 libuv 文件系统 APIs 中,一个 NULL 回调意味着我们真实地希望去执行一个 _同步_ 操作。在这种情况下,POST 直接调用 `uv__fs_work`(我们需要了解一下这个函数的功能),而对于一个 non-NULL 回调,它提交 `uv__fs_work` 作为一个工作事项到工作队列(指的是线程池),然后,注册 `uv__fs_done` 作为回调;该函数执行一些登记并调用用户提供的回调。 + +如果我们去看 `uv__fs_work` 的代码,我们将看到它使用很多宏去按需路由工作到真实的文件系统调用。在我们的案例中,对于 `UV_FS_READ` 这个调用将被 `uv__fs_read` 生成,它(最终)使用普通的 POSIX APIs 去读取。这个函数可以在一个 _阻塞_ 方式中很安全地实现。因为,它通过异步 API 调用时被置于一个线程池中。 + +在 Node.js 中,fs.readFile 函数是映射到 `uv_fs_read` 上。因此,可以在一个非阻塞模式中读取文件,甚至是当底层文件系统 API 是阻塞方式时。 + +* * * + + +[[1]][1] 为确保服务器不泄露内存,我在一个启用泄露检查的 Valgrind 中运行它。因为服务器经常是被设计为永久运行,这是一个挑战;为克服这个问题,我在服务器上添加了一个 “kill 开关” - 一个从客户端接收的特定序列,以使它可以停止事件循环并退出。这个代码在 `theon_wrote_buf` 句柄中。 + + +[[2]][2] 在这里我们不过多地使用 `work_req`;讨论的素数测试服务器接下来将展示怎么被用于去传递上下文信息到回调中。 + + +[[3]][3] `uv_fs_read()` 提供了一个类似于 preadv Linux 系统调用的通用 API:它使用多缓冲区用于排序,并且支持一个到文件中的偏移。基于我们讨论的目的可以忽略这些特性。 + + +-------------------------------------------------------------------------------- + +via: https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ + +作者:[Eli Bendersky ][a] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://eli.thegreenplace.net/ +[1]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id1 +[2]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id2 +[3]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id3 +[4]:https://eli.thegreenplace.net/tag/concurrency +[5]:https://eli.thegreenplace.net/tag/c-c +[6]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id4 +[7]:http://eli.thegreenplace.net/2017/concurrent-servers-part-1-introduction/ +[8]:http://eli.thegreenplace.net/2017/concurrent-servers-part-2-threads/ +[9]:http://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ +[10]:http://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ +[11]:http://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ +[12]:http://libuv.org/ +[13]:https://github.com/eliben/code-for-blog/blob/master/2017/async-socket-server/uv-server.c +[14]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id5 +[15]:https://github.com/eliben/code-for-blog/blob/master/2017/async-socket-server/uv-isprime-server.c +[16]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id6 +[17]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ From 3142dd94f1a309a240da88dc66e3b16321722f0d Mon Sep 17 00:00:00 2001 From: qhwdw Date: Mon, 4 Dec 2017 15:38:10 +0800 Subject: [PATCH 218/344] Translated by qhwdw --- ...1109 Concurrent Servers- Part 4 - libuv.md | 492 ------------------ ...1109 Concurrent Servers- Part 4 - libuv.md | 1 + 2 files changed, 1 insertion(+), 492 deletions(-) delete mode 100644 sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md diff --git a/sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md b/sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md deleted file mode 100644 index 94b98cf5c2..0000000000 --- a/sources/tech/20171109 Concurrent Servers- Part 4 - libuv.md +++ /dev/null @@ -1,492 +0,0 @@ -Translating by qhwdw [Concurrent Servers: Part 4 - libuv][17] -============================================================ - -This is part 4 of a series of posts on writing concurrent network servers. In this part we're going to use libuv to rewrite our server once again, and also talk about handling time-consuming tasks in callbacks using a thread pool. Finally, we're going to look under the hood of libuv for a bit to study how it wraps blocking file-system operations with an asynchronous API. - -All posts in the series: - -* [Part 1 - Introduction][7] - -* [Part 2 - Threads][8] - -* [Part 3 - Event-driven][9] - -* [Part 4 - libuv][10] - -### Abstracting away event-driven loops with libuv - -In [part 3][11], we've seen how similar select-based and epoll-based servers are, and I mentioned it's very tempting to abstract away the minor differences between them. Numerous libraries are already doing this, however, so in this part I'm going to pick one and use it. The library I'm picking is [libuv][12], which was originally designed to serve as the underlying portable platform layer for Node.js, and has since found use in additional projects. libuv is written in C, which makes it highly portable and very suitable for tying into high-level languages like JavaScript and Python. - -While libuv has grown to be a fairly large framework for abstracting low-level platform details, it remains centered on the concept of an  _event loop_ . In our event-driven servers in part 3, the event loop was explicit in the main function; when using libuv, the loop is usually hidden inside the library itself, and user code just registers event handlers (as callback functions) and runs the loop. Furthermore, libuv will use the fastest event loop implementation for a given platform: for Linux this is epoll, etc. - -![libuv loop](https://eli.thegreenplace.net/images/2017/libuvloop.png) - -libuv supports multiple event loops, and thus an event loop is a first class citizen within the library; it has a handle - uv_loop_t, and functions for creating/destroying/starting/stopping loops. That said, I will only use the "default" loop in this post, which libuv makes available via uv_default_loop(); multiple loops are mosly useful for multi-threaded event-driven servers, a more advanced topic I'll leave for future parts in the series. - -### A concurrent server using libuv - -To get a better feel for libuv, let's jump to our trusty protocol server that we've been vigorously reimplementing throughout the series. The structure of this server is going to be somewhat similar to the select and epoll-based servers of part 3, since it also relies on callbacks. The full [code sample is here][13]; we start with setting up the server socket bound to a local port: - -``` -int portnum = 9090; -if (argc >= 2) { - portnum = atoi(argv[1]); -} -printf("Serving on port %d\n", portnum); - -int rc; -uv_tcp_t server_stream; -if ((rc = uv_tcp_init(uv_default_loop(), &server_stream)) < 0) { - die("uv_tcp_init failed: %s", uv_strerror(rc)); -} - -struct sockaddr_in server_address; -if ((rc = uv_ip4_addr("0.0.0.0", portnum, &server_address)) < 0) { - die("uv_ip4_addr failed: %s", uv_strerror(rc)); -} - -if ((rc = uv_tcp_bind(&server_stream, (const struct sockaddr*)&server_address, 0)) < 0) { - die("uv_tcp_bind failed: %s", uv_strerror(rc)); -} -``` - -Fairly standard socket fare here, except that it's all wrapped in libuv APIs. In return we get a portable interface that should work on any platform libuv supports. - -This code also demonstrates conscientious error handling; most libuv functions return an integer status, with a negative number meaning an error. In our server we treat these errors as fatals, but one may imagine a more graceful recovery. - -Now that the socket is bound, it's time to listen on it. Here we run into our first callback registration: - -``` -// Listen on the socket for new peers to connect. When a new peer connects, -// the on_peer_connected callback will be invoked. -if ((rc = uv_listen((uv_stream_t*)&server_stream, N_BACKLOG, on_peer_connected)) < 0) { - die("uv_listen failed: %s", uv_strerror(rc)); -} -``` - -uv_listen registers a callback that the event loop will invoke when new peers connect to the socket. Our callback here is called on_peer_connected, and we'll examine it soon. - -Finally, main runs the libuv loop until it's stopped (uv_run only returns when the loop has stopped or some error occurred). - -``` -// Run the libuv event loop. -uv_run(uv_default_loop(), UV_RUN_DEFAULT); - -// If uv_run returned, close the default loop before exiting. -return uv_loop_close(uv_default_loop()); -``` - -Note that only a single callback was registered by main prior to running the event loop; we'll soon see how additional callbacks are added. It's not a problem to add and remove callbacks throughout the runtime of the event loop - in fact, this is how most servers are expected to be written. - -This is on_peer_connected, which handles new client connections to the server: - -``` -void on_peer_connected(uv_stream_t* server_stream, int status) { - if (status < 0) { - fprintf(stderr, "Peer connection error: %s\n", uv_strerror(status)); - return; - } - - // client will represent this peer; it's allocated on the heap and only - // released when the client disconnects. The client holds a pointer to - // peer_state_t in its data field; this peer state tracks the protocol state - // with this client throughout interaction. - uv_tcp_t* client = (uv_tcp_t*)xmalloc(sizeof(*client)); - int rc; - if ((rc = uv_tcp_init(uv_default_loop(), client)) < 0) { - die("uv_tcp_init failed: %s", uv_strerror(rc)); - } - client->data = NULL; - - if (uv_accept(server_stream, (uv_stream_t*)client) == 0) { - struct sockaddr_storage peername; - int namelen = sizeof(peername); - if ((rc = uv_tcp_getpeername(client, (struct sockaddr*)&peername, - &namelen)) < 0) { - die("uv_tcp_getpeername failed: %s", uv_strerror(rc)); - } - report_peer_connected((const struct sockaddr_in*)&peername, namelen); - - // Initialize the peer state for a new client: we start by sending the peer - // the initial '*' ack. - peer_state_t* peerstate = (peer_state_t*)xmalloc(sizeof(*peerstate)); - peerstate->state = INITIAL_ACK; - peerstate->sendbuf[0] = '*'; - peerstate->sendbuf_end = 1; - peerstate->client = client; - client->data = peerstate; - - // Enqueue the write request to send the ack; when it's done, - // on_wrote_init_ack will be called. The peer state is passed to the write - // request via the data pointer; the write request does not own this peer - // state - it's owned by the client handle. - uv_buf_t writebuf = uv_buf_init(peerstate->sendbuf, peerstate->sendbuf_end); - uv_write_t* req = (uv_write_t*)xmalloc(sizeof(*req)); - req->data = peerstate; - if ((rc = uv_write(req, (uv_stream_t*)client, &writebuf, 1, - on_wrote_init_ack)) < 0) { - die("uv_write failed: %s", uv_strerror(rc)); - } - } else { - uv_close((uv_handle_t*)client, on_client_closed); - } -} -``` - -This code is well commented, but there are a couple of important libuv idioms I'd like to highlight: - -* Passing custom data into callbacks: since C has no closures, this can be challenging. libuv has a void* datafield in all its handle types; these fields can be used to pass user data. For example, note how client->data is made to point to a peer_state_t structure so that the callbacks registered by uv_write and uv_read_start can know which peer data they're dealing with. - -* Memory management: event-driven programming is much easier in languages with garbage collection, because callbacks usually run in a completely different stack frame from where they were registered, making stack-based memory management difficult. It's almost always necessary to pass heap-allocated data to libuv callbacks (except in main, which remains alive on the stack when all callbacks run), and to avoid leaks much care is required about when these data are safe to free(). This is something that comes with a bit of practice [[1]][6]. - -The peer state for this server is: - -``` -typedef struct { - ProcessingState state; - char sendbuf[SENDBUF_SIZE]; - int sendbuf_end; - uv_tcp_t* client; -} peer_state_t; -``` - -It's fairly similar to the state in part 3; we no longer need sendptr, since uv_write will make sure to send the whole buffer it's given before invoking the "done writing" callback. We also keep a pointer to the client for other callbacks to use. Here's on_wrote_init_ack: - -``` -void on_wrote_init_ack(uv_write_t* req, int status) { - if (status) { - die("Write error: %s\n", uv_strerror(status)); - } - peer_state_t* peerstate = (peer_state_t*)req->data; - // Flip the peer state to WAIT_FOR_MSG, and start listening for incoming data - // from this peer. - peerstate->state = WAIT_FOR_MSG; - peerstate->sendbuf_end = 0; - - int rc; - if ((rc = uv_read_start((uv_stream_t*)peerstate->client, on_alloc_buffer, - on_peer_read)) < 0) { - die("uv_read_start failed: %s", uv_strerror(rc)); - } - - // Note: the write request doesn't own the peer state, hence we only free the - // request itself, not the state. - free(req); -} -``` - -Then we know for sure that the initial '*' was sent to the peer, we start listening to incoming data from this peer by calling uv_read_start, which registers a callback (on_peer_read) that will be invoked by the event loop whenever new data is received on the socket from the client: - -``` -void on_peer_read(uv_stream_t* client, ssize_t nread, const uv_buf_t* buf) { - if (nread < 0) { - if (nread != uv_eof) { - fprintf(stderr, "read error: %s\n", uv_strerror(nread)); - } - uv_close((uv_handle_t*)client, on_client_closed); - } else if (nread == 0) { - // from the documentation of uv_read_cb: nread might be 0, which does not - // indicate an error or eof. this is equivalent to eagain or ewouldblock - // under read(2). - } else { - // nread > 0 - assert(buf->len >= nread); - - peer_state_t* peerstate = (peer_state_t*)client->data; - if (peerstate->state == initial_ack) { - // if the initial ack hasn't been sent for some reason, ignore whatever - // the client sends in. - free(buf->base); - return; - } - - // run the protocol state machine. - for (int i = 0; i < nread; ++i) { - switch (peerstate->state) { - case initial_ack: - assert(0 && "can't reach here"); - break; - case wait_for_msg: - if (buf->base[i] == '^') { - peerstate->state = in_msg; - } - break; - case in_msg: - if (buf->base[i] == '$') { - peerstate->state = wait_for_msg; - } else { - assert(peerstate->sendbuf_end < sendbuf_size); - peerstate->sendbuf[peerstate->sendbuf_end++] = buf->base[i] + 1; - } - break; - } - } - - if (peerstate->sendbuf_end > 0) { - // we have data to send. the write buffer will point to the buffer stored - // in the peer state for this client. - uv_buf_t writebuf = - uv_buf_init(peerstate->sendbuf, peerstate->sendbuf_end); - uv_write_t* writereq = (uv_write_t*)xmalloc(sizeof(*writereq)); - writereq->data = peerstate; - int rc; - if ((rc = uv_write(writereq, (uv_stream_t*)client, &writebuf, 1, - on_wrote_buf)) < 0) { - die("uv_write failed: %s", uv_strerror(rc)); - } - } - } - free(buf->base); -} -``` - -The runtime behavior of this server is very similar to the event-driven servers of part 3: all clients are handled concurrently in a single thread. Also similarly, a certain discipline has to be maintained in the server's code: the server's logic is implemented as an ensemble of callbacks, and long-running operations are a big no-no since they block the event loop. Let's explore this issue a bit further. - -### Long-running operations in event-driven loops - -The single-threaded nature of event-driven code makes it very susceptible to a common issue: long-running code blocks the entire loop. Consider this program: - -``` -void on_timer(uv_timer_t* timer) { - uint64_t timestamp = uv_hrtime(); - printf("on_timer [%" PRIu64 " ms]\n", (timestamp / 1000000) % 100000); - - // "Work" - if (random() % 5 == 0) { - printf("Sleeping...\n"); - sleep(3); - } -} - -int main(int argc, const char** argv) { - uv_timer_t timer; - uv_timer_init(uv_default_loop(), &timer); - uv_timer_start(&timer, on_timer, 0, 1000); - return uv_run(uv_default_loop(), UV_RUN_DEFAULT); -} -``` - -It runs a libuv event loop with a single registered callback: on_timer, which is invoked by the loop every second. The callback reports a timestamp, and once in a while simulates some long-running task by sleeping for 3 seconds. Here's a sample run: - -``` -$ ./uv-timer-sleep-demo -on_timer [4840 ms] -on_timer [5842 ms] -on_timer [6843 ms] -on_timer [7844 ms] -Sleeping... -on_timer [11845 ms] -on_timer [12846 ms] -Sleeping... -on_timer [16847 ms] -on_timer [17849 ms] -on_timer [18850 ms] -... -``` - -on_timer dutifully fires every second, until the random sleep hits in. At that point, on_timer is not invoked again until the sleep is over; in fact,  _no other callbacks_  will be invoked in this time frame. The sleep call blocks the current thread, which is the only thread involved and is also the thread the event loop uses. When this thread is blocked, the event loop is blocked. - -This example demonstrates why it's so important for callbacks to never block in event-driven calls, and applies equally to Node.js servers, client-side Javascript, most GUI programming frameworks, and many other asynchronous programming models. - -But sometimes running time-consuming tasks is unavoidable. Not all tasks have asynchronous APIs; for example, we may be dealing with some library that only has a synchronous API, or just have to perform a potentially long computation. How can we combine such code with event-driven programming? Threads to the rescue! - -### Threads for "converting" blocking calls into asynchronous calls - -A thread pool can be used to turn blocking calls into asynchronous calls, by running alongside the event loop and posting events onto it when tasks are completed. Here's how it works, for a given blocking function do_work(): - -1. Instead of directly calling do_work() in a callback, we package it into a "task" and ask the thread pool to execute the task. We also register a callback for the loop to invoke when the task has finished; let's call iton_work_done(). - -2. At this point our callback can return and the event loop keeps spinning; at the same time, a thread in the pool is executing the task. - -3. Once the task has finished executing, the main thread (the one running the event loop) is notified and on_work_done() is invoked by the event loop. - -Let's see how this solves our previous timer/sleep example, using libuv's work scheduling API: - -``` -void on_after_work(uv_work_t* req, int status) { - free(req); -} - -void on_work(uv_work_t* req) { - // "Work" - if (random() % 5 == 0) { - printf("Sleeping...\n"); - sleep(3); - } -} - -void on_timer(uv_timer_t* timer) { - uint64_t timestamp = uv_hrtime(); - printf("on_timer [%" PRIu64 " ms]\n", (timestamp / 1000000) % 100000); - - uv_work_t* work_req = (uv_work_t*)malloc(sizeof(*work_req)); - uv_queue_work(uv_default_loop(), work_req, on_work, on_after_work); -} - -int main(int argc, const char** argv) { - uv_timer_t timer; - uv_timer_init(uv_default_loop(), &timer); - uv_timer_start(&timer, on_timer, 0, 1000); - return uv_run(uv_default_loop(), UV_RUN_DEFAULT); -} -``` - -Instead of calling sleep directly in on_timer, we enqueue a task, represented by a handle of type work_req [[2]][14], the function to run in the task (on_work) and the function to invoke once the task is completed (on_after_work). on_workis where the "work" (the blocking/time-consuming operation) happens. Note a crucial difference between the two callbacks passed into uv_queue_work: on_work runs in the thread pool, while on_after_work runs on the main thread which also runs the event loop - just like any other callback. - -Let's see this version run: - -``` -$ ./uv-timer-work-demo -on_timer [89571 ms] -on_timer [90572 ms] -on_timer [91573 ms] -on_timer [92575 ms] -Sleeping... -on_timer [93576 ms] -on_timer [94577 ms] -Sleeping... -on_timer [95577 ms] -on_timer [96578 ms] -on_timer [97578 ms] -... -``` - -The timer ticks every second, even though the sleeping function is still invoked; sleeping is now done on a separate thread and doesn't block the event loop. - -### A primality-testing server, with exercises - -Since sleep isn't a very exciting way to simulate work, I've prepared a more comprehensive example - a server that accepts numbers from clients over a socket, checks whether these numbers are prime and sends back either "prime" or "composite". The full [code for this server is here][15] - I won't post it here since it's long, but will rather give readers the opportunity to explore it on their own with a couple of exercises. - -The server deliberatly uses a naive primality test algorithm, so for large primes it can take quite a while to return an answer. On my machine it takes ~5 seconds to compute the answer for 2305843009213693951, but YMMV. - -Exercise 1: the server has a setting (via an environment variable named MODE) to either run the primality test in the socket callback (meaning on the main thread) or in the libuv work queue. Play with this setting to observe the server's behavior when multiple clients are connecting simultaneously. In blocking mode, the server will not answer other clients while it's computing a big task; in non-blocking mode it will. - -Exercise 2: libuv has a default thread-pool size, and it can be configured via an environment variable. Can you use multiple clients to discover experimentally what the default size is? Having found the default thread-pool size, play with different settings to see how it affects the server's responsiveness under heavy load. - -### Non-blocking file-system operations using work queues - -Delegating potentially-blocking operations to a thread pool isn't good for just silly demos and CPU-intensive computations; libuv itself makes heavy use of this capability in its file-system APIs. This way, libuv accomplishes the superpower of exposing the file-system with an asynchronous API, in a portable way. - -Let's take uv_fs_read(), for example. This function reads from a file (represented by a uv_fs_t handle) into a buffer [[3]][16], and invokes a callback when the reading is completed. That is, uv_fs_read() always returns immediately, even if the file sits on an NFS-like system and it may take a while for the data to get to the buffer. In other words, this API is asynchronous in the way other libuv APIs are. How does this work? - -At this point we're going to look under the hood of libuv; the internals are actually fairly straightforward, and it's a good exercise. Being a portable library, libuv has different implementations of many of its functions for Windows and Unix systems. We're going to be looking at src/unix/fs.c in the libuv source tree. - -The code for uv_fs_read is: - -``` -int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t off, - uv_fs_cb cb) { - if (bufs == NULL || nbufs == 0) - return -EINVAL; - - INIT(READ); - req->file = file; - - req->nbufs = nbufs; - req->bufs = req->bufsml; - if (nbufs > ARRAY_SIZE(req->bufsml)) - req->bufs = uv__malloc(nbufs * sizeof(*bufs)); - - if (req->bufs == NULL) { - if (cb != NULL) - uv__req_unregister(loop, req); - return -ENOMEM; - } - - memcpy(req->bufs, bufs, nbufs * sizeof(*bufs)); - - req->off = off; - POST; -} -``` - -It may seem puzzling at first, because it defers the real work to the INIT and POST macros, with some local variable setup for POST. This is done to avoid too much code duplication within the file. - -The INIT macro is: - -``` -#define INIT(subtype) \ - do { \ - req->type = UV_FS; \ - if (cb != NULL) \ - uv__req_init(loop, req, UV_FS); \ - req->fs_type = UV_FS_ ## subtype; \ - req->result = 0; \ - req->ptr = NULL; \ - req->loop = loop; \ - req->path = NULL; \ - req->new_path = NULL; \ - req->cb = cb; \ - } \ - while (0) -``` - -It sets up the request, and most importantly sets the req->fs_type field to the actual FS request type. Since uv_fs_read invokes INIT(READ), it means req->fs_type gets assigned the constant UV_FS_READ. - -The POST macro is: - -``` -#define POST \ - do { \ - if (cb != NULL) { \ - uv__work_submit(loop, &req->work_req, uv__fs_work, uv__fs_done); \ - return 0; \ - } \ - else { \ - uv__fs_work(&req->work_req); \ - return req->result; \ - } \ - } \ - while (0) -``` - -What it does depends on whether the callback is NULL. In libuv file-system APIs, a NULL callback means we actually want to perform the operation  _synchronously_ . In this case POST invokes uv__fs_work directly (we'll get to what this function does in just a bit), whereas for a non-NULL callback, it submits uv__fs_work as a work item to the work queue (which is the thread pool), and registers uv__fs_done as the callback; that function does a bit of book-keeping and invokes the user-provided callback. - -If we look at the code of uv__fs_work, we'll see it uses more macros to route work to the actual file-system call as needed. In our case, for UV_FS_READ the call will be made to uv__fs_read, which (at last!) does the reading using regular POSIX APIs. This function can be safely implemented in a  _blocking_  manner, since it's placed on a thread-pool when called through the asynchronous API. - -In Node.js, the fs.readFile function is mapped to uv_fs_read. Thus, reading files can be done in a non-blocking fashion even though the underlying file-system API is blocking. - -* * * - - -[[1]][1] To ensure that this server doesn't leak memory, I ran it under Valgrind with the leak checker enabled. Since servers are often designed to run forever, this was a bit challenging; to overcome this issue I've added a "kill switch" to the server - a special sequence received from a client makes it stop the event loop and exit. The code for this is in theon_wrote_buf handler. - - -[[2]][2] Here we don't use work_req for much; the primality testing server discussed next will show how it's used to pass context information into the callback. - - -[[3]][3] uv_fs_read() provides a generalized API similar to the preadv Linux system call: it takes multiple buffers which it fills in order, and supports an offset into the file. We can ignore these features for the sake of our discussion. - - --------------------------------------------------------------------------------- - -via: https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ - -作者:[Eli Bendersky ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://eli.thegreenplace.net/ -[1]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id1 -[2]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id2 -[3]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id3 -[4]:https://eli.thegreenplace.net/tag/concurrency -[5]:https://eli.thegreenplace.net/tag/c-c -[6]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id4 -[7]:http://eli.thegreenplace.net/2017/concurrent-servers-part-1-introduction/ -[8]:http://eli.thegreenplace.net/2017/concurrent-servers-part-2-threads/ -[9]:http://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ -[10]:http://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ -[11]:http://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ -[12]:http://libuv.org/ -[13]:https://github.com/eliben/code-for-blog/blob/master/2017/async-socket-server/uv-server.c -[14]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id5 -[15]:https://github.com/eliben/code-for-blog/blob/master/2017/async-socket-server/uv-isprime-server.c -[16]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id6 -[17]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ diff --git a/translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md b/translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md index b4db491e4e..07994c67b1 100644 --- a/translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md +++ b/translated/tech/20171109 Concurrent Servers- Part 4 - libuv.md @@ -490,3 +490,4 @@ via: https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ [15]:https://github.com/eliben/code-for-blog/blob/master/2017/async-socket-server/uv-isprime-server.c [16]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/#id6 [17]:https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/ + From cc7e3342f64fc88d581ee721b2e71db2bbef0501 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 17:28:56 +0800 Subject: [PATCH 219/344] =?UTF-8?q?=E8=A1=A5=E5=AE=8C=20PR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @FelixYFZ 你的 PR 有问题,需要删除原文,并且不能修改文件名,要保留文件名前的日期和扩展名。我帮你修复了。 --- ...g Hardware for Beginners Think Software.md | 79 ------------------- ... Hardware for Beginners Think Software.md} | 0 2 files changed, 79 deletions(-) delete mode 100644 sources/tech/20171012 Linux Networking Hardware for Beginners Think Software.md rename translated/tech/{Linux Networking Hardware for Beginners: Think Software => 20171012 Linux Networking Hardware for Beginners Think Software.md} (100%) diff --git a/sources/tech/20171012 Linux Networking Hardware for Beginners Think Software.md b/sources/tech/20171012 Linux Networking Hardware for Beginners Think Software.md deleted file mode 100644 index 661f5bc2df..0000000000 --- a/sources/tech/20171012 Linux Networking Hardware for Beginners Think Software.md +++ /dev/null @@ -1,79 +0,0 @@ -Translating by FelixYFZ - -Linux Networking Hardware for Beginners: Think Software -============================================================ - -![island network](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/soderskar-island.jpg?itok=wiMaF66b "island network") -Without routers and bridges, we would be lonely little islands; learn more in this networking tutorial.[Creative Commons Zero][3]Pixabay - -Last week, we learned about [LAN (local area network) hardware][7]. This week, we'll learn about connecting networks to each other, and some cool hacks for mobile broadband. - -### Routers - -Network routers are everything in computer networking, because routers connect networks. Without routers we would be lonely little islands. Figure 1 shows a simple wired LAN (local area network) with a wireless access point, all connected to the Internet. Computers on the LAN connect to an Ethernet switch, which connects to a combination firewall/router, which connects to the big bad Internet through whatever interface your Internet service provider (ISP) provides, such as cable box, DSL modem, satellite uplink...like everything in computing, it's likely to be a box with blinky lights. When your packets leave your LAN and venture forth into the great wide Internet, they travel from router to router until they reach their destination. - -### [fig-1.png][4] - -![simple LAN](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_7.png?itok=lsazmf3- "simple LAN") -Figure 1: A simple wired LAN with a wireless access point.[Used with permission][1] - -A router can look like pretty much anything: a nice little specialized box that does only routing and nothing else, a bigger box that provides routing, firewall, name services, and VPN gateway, a re-purposed PC or laptop, a Raspberry Pi or Arduino, stout little single-board computers like PC Engines...for all but the most demanding uses, ordinary commodity hardware works fine. The highest-end routers use specialized hardware that is designed to move the maximum number of packets per second. They have multiple fat data buses, multiple CPUs, and super-fast memory. (Look up Juniper and Cisco routers to see what high-end routers look like, and what's inside.) - -A wireless access point connects to your LAN either as an Ethernet bridge or a router. A bridge extends the network, so hosts on both sides of the bridge are on the same network. A router connects two different networks. - -### Network Topology - -There are multitudes of ways to set up your LAN. You can put all hosts on a single flat network. You can divide it up into different subnets. You can divide it into virtual LANs, if your switch supports this. - -A flat network is the simplest; just plug everyone into the same switch. If one switch isn't enough you can connect switches to each other. Some switches have special uplink ports, some don't care which ports you connect, and you may need to use a crossover Ethernet cable, so check your switch documentation. - -Flat networks are the easiest to administer. You don't need routers and don't have to calculate subnets, but there are some downsides. They don't scale, so when they get too large they get bogged down by broadcast traffic. Segmenting your LAN provides a bit of security, and makes it easier to manage larger networks by dividing it into manageable chunks. Figure 2 shows a simplified LAN divided into two subnets: internal wired and wireless hosts, and one for servers that host public services. The subnet that contains the public-facing servers is called a DMZ, demilitarized zone (ever notice all the macho terminology for jobs that are mostly typing on a computer?) because it is blocked from all internal access. - -### [fig-2.png][5] - -![LAN](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-2_4.png?itok=LpXq7bLf "LAN") -Figure 2: A simplified LAN divided into two subnets.[Used with permission][2] - -Even in a network as small as Figure 2 there are several ways to set it up. You can put your firewall and router on a single device. You could have a dedicated Internet link for the DMZ, divorcing it completely from your internal network. Which brings us to our next topic: it's all software. - -### Think Software - -You may have noticed that of the hardware we have discussed in this little series, only network interfaces, switches, and cabling are special-purpose hardware. Everything else is general-purpose commodity hardware, and it's the software that defines its purpose. Linux is a true networking operating system, and it supports a multitude of network operations: VLANs, firewall, router, Internet gateway, VPN gateway, Ethernet bridge, Web/mail/file/etc. servers, load-balancer, proxy, quality of service, multiple authenticators, trunking, failover...you can run your entire network on commodity hardware with Linux. You can even use Linux to simulate an Ethernet switch with LISA (LInux Switching Appliance) and vde2. - -There are specialized distributions for small hardware like DD-WRT, OpenWRT, and the Raspberry Pi distros, and don't forget the BSDs and their specialized offshoots like the pfSense firewall/router, and the FreeNAS network-attached storage server. - -You know how some people insist there is a difference between a hardware firewall and a software firewall? There isn't. That's like saying there is a hardware computer and a software computer. - -### Port Trunking and Ethernet Bonding - -Trunking and bonding, also called link aggregation, is combining two Ethernet channels into one. Some Ethernet switches support port trunking, which is combining two switch ports to combine their bandwidth into a single link. This is a nice way to make a bigger pipe to a busy server. - -You can do the same thing with Ethernet interfaces, and the bonding driver is built-in to the Linux kernel, so you don't need any special hardware. - -### Bending Mobile Broadband to your Will - -I expect that mobile broadband is going to grow in the place of DSL and cable Internet. I live near a city of 250,000 population, but outside the city limits good luck getting Internet, even though there is a large population to serve. My little corner of the world is 20 minutes from town, but it might as well be the moon as far as Internet service providers are concerned. My only option is mobile broadband; there is no dialup, satellite Internet is sold out (and it sucks), and haha lol DSL, cable, or fiber. That doesn't stop ISPs from stuffing my mailbox with flyers for Xfinity and other high-speed services my area will never see. - -I tried AT&T, Verizon, and T-Mobile. Verizon has the strongest coverage, but Verizon and AT&T are expensive. I'm at the edge of T-Mobile coverage, but they give the best deal by far. To make it work, I had to buy a weBoost signal booster and ZTE mobile hotspot. Yes, you can use a smartphone as a hotspot, but the little dedicated hotspots have stronger radios. If you're thinking you might want a signal booster, I have nothing but praise for weBoost because their customer support is superb, and they will do their best to help you. Set it up with the help of a great little app that accurately measures signal strength, [SignalCheck Pro][8]. They have a free version with fewer features; spend the two bucks to get the pro version, you won't be sorry. - -The little ZTE hotspots serve up to 15 hosts and have rudimentary firewalls. But we can do better: get something like the Linksys WRT54GL, replace the stock firmware with Tomato, OpenWRT, or DD-WRT, and then you have complete control of your firewall rules, routing, and any other services you want to set up. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2017/10/linux-networking-hardware-beginners-think-software - -作者:[CARLA SCHRODER][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/cschroder -[1]:https://www.linux.com/licenses/category/used-permission -[2]:https://www.linux.com/licenses/category/used-permission -[3]:https://www.linux.com/licenses/category/creative-commons-zero -[4]:https://www.linux.com/files/images/fig-1png-7 -[5]:https://www.linux.com/files/images/fig-2png-4 -[6]:https://www.linux.com/files/images/soderskar-islandjpg -[7]:https://www.linux.com/learn/intro-to-linux/2017/10/linux-networking-hardware-beginners-lan-hardware -[8]:http://www.bluelinepc.com/signalcheck/ diff --git a/translated/tech/Linux Networking Hardware for Beginners: Think Software b/translated/tech/20171012 Linux Networking Hardware for Beginners Think Software.md similarity index 100% rename from translated/tech/Linux Networking Hardware for Beginners: Think Software rename to translated/tech/20171012 Linux Networking Hardware for Beginners Think Software.md From dd648ed53ae15ced3ff13219b97f1c51edcaa4de Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 17:29:41 +0800 Subject: [PATCH 220/344] =?UTF-8?q?=E8=A1=A5=E5=AE=8C=20PR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @filefi 不要丢掉扩展名。 --- ...20171202 Scrot Linux command-line screen grabs made simple.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sources/tech/{20171202 Scrot Linux command-line screen grabs made simple => 20171202 Scrot Linux command-line screen grabs made simple.md} (100%) diff --git a/sources/tech/20171202 Scrot Linux command-line screen grabs made simple b/sources/tech/20171202 Scrot Linux command-line screen grabs made simple.md similarity index 100% rename from sources/tech/20171202 Scrot Linux command-line screen grabs made simple rename to sources/tech/20171202 Scrot Linux command-line screen grabs made simple.md From 5154aec58e578757c4efd7782ba5a498824d9175 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 17:31:40 +0800 Subject: [PATCH 221/344] =?UTF-8?q?=E5=B7=B2=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @geekpi --- .../20171201 Linux Journal Ceases Publication.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171201 Linux Journal Ceases Publication.md (100%) diff --git a/translated/tech/20171201 Linux Journal Ceases Publication.md b/published/20171201 Linux Journal Ceases Publication.md similarity index 100% rename from translated/tech/20171201 Linux Journal Ceases Publication.md rename to published/20171201 Linux Journal Ceases Publication.md From f6d529c21c047d9f139928498ee6069dfe396314 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 21:38:41 +0800 Subject: [PATCH 222/344] =?UTF-8?q?PRF:20171130=20Translate=20Shell=20?= =?UTF-8?q?=E2=80=93=20A=20Tool=20To=20Use=20Google=20Translate=20From=20C?= =?UTF-8?q?ommand=20Line=20In=20Linux.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @lujun9972 译者没署名,我找了半天 /cry --- ...ogle Translate From Command Line In Linux.md | 76 +++++++++---------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md b/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md index 9f905bd496..aeae003532 100644 --- a/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md +++ b/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md @@ -1,68 +1,65 @@ -Translate Shell: 一款在 Linux 命令行中使用 Google Translate的工具 +Translate Shell :一款在 Linux 命令行中使用谷歌翻译的工具 ============================================================ -我对 CLI 应用非常感兴趣,因此热衷于使用并分享 CLI 应用。 我之所以更喜欢 CLI 很大原因是因为我在大多数的时候都使用的是字符界面(black screen),已经习惯了使用 CLI 应用而不是 GUI 应用. +我对 CLI 应用非常感兴趣,因此热衷于使用并分享 CLI 应用。 我之所以更喜欢 CLI 很大原因是因为我在大多数的时候都使用的是字符界面(black screen),已经习惯了使用 CLI 应用而不是 GUI 应用。 -我写过很多关于 CLI 应用的文章。 最近我发现了一些 google 的 CLI 工具,像 “Google Translator”, “Google Calendar”, 和 “Google Contacts”。 这里,我想在给大家分享一下。 +我写过很多关于 CLI 应用的文章。 最近我发现了一些谷歌的 CLI 工具,像 “Google Translator”、“Google Calendar” 和 “Google Contacts”。 这里,我想在给大家分享一下。 -今天我们要介绍的是 “Google Translator” 工具。 由于母语是泰米尔语,我在一天内用了很多次才理解了它的意义。 +今天我们要介绍的是 “Google Translator” 工具。 由于我的母语是泰米尔语,我在一天内用了很多次才理解了它的意义。 -`Google translate` 为其他语系的人们所广泛使用。 +谷歌翻译为其它语系的人们所广泛使用。 ### 什么是 Translate Shell -[Translate Shell][2] (之前叫做 Google Translate CLI) 是一款借助 `Google Translate`(默认), `Bing Translator`, `Yandex.Translate` 以及 `Apertium` 来翻译的命令行翻译器。 -它让你可以在终端访问这些翻译引擎. `Translate Shell` 在大多数Linux发行版中都能使用。 +[Translate Shell][2] (之前叫做 Google Translate CLI) 是一款借助谷歌翻译(默认)、必应翻译、Yandex.Translate 以及 Apertium 来翻译的命令行翻译器。它让你可以在终端访问这些翻译引擎。 Translate Shell 在大多数 Linux 发行版中都能使用。 ### 如何安装 Translate Shell -有三种方法安装 `Translate Shell`。 +有三种方法安装 Translate Shell。 * 下载自包含的可执行文件 - * 手工安装 +* 通过包管理器安装 -* 通过包挂力气安装 - -#### 方法-1 : 下载自包含的可执行文件 +#### 方法 1 : 下载自包含的可执行文件 下载自包含的可执行文件放到 `/usr/bin` 目录中。 -```shell +``` $ wget git.io/trans $ chmod +x ./trans $ sudo mv trans /usr/bin/ ``` -#### 方法-2 : 手工安装 +#### 方法 2 : 手工安装 -克隆 `Translate Shell` github 仓库然后手工编译。 +克隆 Translate Shell 的 GitHub 仓库然后手工编译。 -```shell +``` $ git clone https://github.com/soimort/translate-shell && cd translate-shell $ make $ sudo make install ``` -#### 方法-3 : Via Package Manager +#### 方法 3 : 通过包管理器 -有些发行版的官方仓库中包含了 `Translate Shell`,可以通过包管理器来安装。 +有些发行版的官方仓库中包含了 Translate Shell,可以通过包管理器来安装。 -对于 Debian/Ubuntu, 使用 [APT-GET Command][3] 或者 [APT Command][4]来安装。 +对于 Debian/Ubuntu, 使用 [APT-GET 命令][3] 或者 [APT 命令][4]来安装。 -```shell +``` $ sudo apt-get install translate-shell ``` -对于 Fedora, 使用 [DNF Command][5] 来安装。 +对于 Fedora, 使用 [DNF 命令][5] 来安装。 -```shell +``` $ sudo dnf install translate-shell ``` -对于基于 Arch Linux 的系统, 使用 [Yaourt Command][6] 或 [Packer Command][7] 来从 AUR 仓库中安装。 +对于基于 Arch Linux 的系统, 使用 [Yaourt 命令][6] 或 [Packer 明快][7] 来从 AUR 仓库中安装。 -```shell +``` $ yaourt -S translate-shell or $ packer -S translate-shell @@ -70,7 +67,7 @@ $ packer -S translate-shell ### 如何使用 Translate Shell -安装好后,打开终端闭关输入下面命令。 `Google Translate` 会自动探测源文本是哪种语言,并且在默认情况下将之翻译成你的 `locale` 所对应的语言。 +安装好后,打开终端闭关输入下面命令。 谷歌翻译会自动探测源文本是哪种语言,并且在默认情况下将之翻译成你的 `locale` 所对应的语言。 ``` $ trans [Words] @@ -119,7 +116,7 @@ thanks நன்றி ``` -要将一个单词翻译到多个语种可以使用下面命令(本例中, 我将单词翻译成泰米尔语以及印地语)。 +要将一个单词翻译到多个语种可以使用下面命令(本例中,我将单词翻译成泰米尔语以及印地语)。 ``` $ trans :ta+hi thanks @@ -172,7 +169,7 @@ what is going on your life? உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? ``` -下面命令独立地翻译各个单词。 +下面命令单独地翻译各个单词。 ``` $ trans :ta curios happy @@ -208,14 +205,14 @@ happy சந்தோஷமாக, மகிழ்ச்சி, இனிய, சந்தோஷமா ``` -简洁模式: 默认情况下,`Translate Shell` 尽可能多的显示翻译信息. 如果你希望只显示简要信息,只需要加上`-b`选项。 +简洁模式:默认情况下,Translate Shell 尽可能多的显示翻译信息。如果你希望只显示简要信息,只需要加上 `-b`选项。 ``` $ trans -b :ta thanks நன்றி ``` -字典模式: 加上 `-d` 可以把 `Translate Shell` 当成字典来用. +字典模式:加上 `-d` 可以把 Translate Shell 当成字典来用。 ``` $ trans -d :en thanks @@ -294,14 +291,14 @@ See also Thanks!, thank, many thanks, thanks to, thanks to you, special thanks, give thanks, thousand thanks, Many thanks!, render thanks, heartfelt thanks, thanks to this ``` -使用下面格式可以使用 `Translate Shell` 来翻译文件。 +使用下面格式可以使用 Translate Shell 来翻译文件。 -```shell +``` $ trans :ta file:///home/magi/gtrans.txt உங்கள் வாழ்க்கையில் என்ன நடக்கிறது? ``` -下面命令可以让 `Translate Shell` 进入交互模式. 在进入交互模式之前你需要明确指定源语言和目标语言。本例中,我将英文单词翻译成泰米尔语。 +下面命令可以让 Translate Shell 进入交互模式。 在进入交互模式之前你需要明确指定源语言和目标语言。本例中,我将英文单词翻译成泰米尔语。 ``` $ trans -shell en:ta thanks @@ -324,13 +321,14 @@ thanks நன்றி ``` -想知道语言代码,可以执行下面语言。 +想知道语言代码,可以执行下面命令。 -```shell +``` $ trans -R ``` 或者 -```shell + +``` $ trans -T ┌───────────────────────┬───────────────────────┬───────────────────────┐ │ Afrikaans - af │ Hindi - hi │ Punjabi - pa │ @@ -375,9 +373,9 @@ $ trans -T └───────────────────────┴───────────────────────┴───────────────────────┘ ``` -想了解更多选项的内容,可以查看 `man` 页. +想了解更多选项的内容,可以查看其 man 手册。 -```shell +``` $ man trans ``` @@ -386,8 +384,8 @@ $ man trans via: https://www.2daygeek.com/translate-shell-a-tool-to-use-google-translate-from-command-line-in-linux/ 作者:[Magesh Maruthamuthu][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[lujun9972](https://github.com/lujun9972 ) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From c1e67497811606b56c944b0b5ca0c24c156b3561 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 21:38:57 +0800 Subject: [PATCH 223/344] =?UTF-8?q?PUB:20171130=20Translate=20Shell=20?= =?UTF-8?q?=E2=80=93=20A=20Tool=20To=20Use=20Google=20Translate=20From=20C?= =?UTF-8?q?ommand=20Line=20In=20Linux.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @lujun9972 https://linux.cn/article-9107-1.html --- ...– A Tool To Use Google Translate From Command Line In Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md (100%) diff --git a/translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md b/published/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md similarity index 100% rename from translated/tech/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md rename to published/20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md From ed1e163307f8a62567b184db20647731116a4272 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 22:02:54 +0800 Subject: [PATCH 224/344] PRF&PUB:20171130 New Feature Find every domain someone owns automatically.md @geekpi --- ...d every domain someone owns automatically.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) rename {translated/tech => published}/20171130 New Feature Find every domain someone owns automatically.md (69%) diff --git a/translated/tech/20171130 New Feature Find every domain someone owns automatically.md b/published/20171130 New Feature Find every domain someone owns automatically.md similarity index 69% rename from translated/tech/20171130 New Feature Find every domain someone owns automatically.md rename to published/20171130 New Feature Find every domain someone owns automatically.md index 4b72eaae5e..e8866a5ce5 100644 --- a/translated/tech/20171130 New Feature Find every domain someone owns automatically.md +++ b/published/20171130 New Feature Find every domain someone owns automatically.md @@ -1,16 +1,15 @@ -新功能:自动找出每个域名的拥有者 +使用 DNSTrails 自动找出每个域名的拥有者 ============================================================ - 今天,我们很高兴地宣布我们最近几周做的新功能。它是 Whois 聚合工具,现在可以在 [DNSTrails][1] 上获得。 -在过去,查找一个域名的所有者会花费很多时间,因为大部分时间你都需要把域名指向一个 IP 地址,以便找到同一个人拥有的其他域名。 +在过去,查找一个域名的所有者会花费很多时间,因为大部分时间你都需要把域名翻译为一个 IP 地址,以便找到同一个人拥有的其他域名。 -使用老的方法,你会很轻易地在一个工具和另外一个工具的研究和交叉比较结果中花费数个小时,直到得到你想要的域名。 +使用老的方法,在得到你想要的域名列表之前,你在一个工具和另外一个工具的一日又一日的研究和交叉比较结果中经常会花费数个小时。 -感谢这个新工具和我们的智能[WHOIS 数据库][2],现在你可以搜索任何域名,并获得组织或个人注册的域名的完整列表,并在几秒钟内获得准确的结果。 +感谢这个新工具和我们的智能 [WHOIS 数据库][2],现在你可以搜索任何域名,并获得组织或个人注册的域名的完整列表,并在几秒钟内获得准确的结果。 -### 我如何使用Whois聚合功能? +### 我如何使用 Whois 聚合功能? 第一步:打开 [DNSTrails.com][3] @@ -28,15 +27,15 @@ 如果你正在调查互联网上任何个人的域名所有权,这意味着即使域名甚至没有指向注册服务商的 IP,如果他们使用相同的电话和邮件地址,我们仍然可以发现其他域名。 -想知道一个人拥有的其他域名么?亲自试试 [DNStrails][5] 的[ WHOIS 聚合功能][4]或者[使用我们的 API 访问][6]。 +想知道一个人拥有的其他域名么?亲自试试 [DNStrails][5] 的 [WHOIS 聚合功能][4]或者[使用我们的 API 访问][6]。 -------------------------------------------------------------------------------- via: https://securitytrails.com/blog/find-every-domain-someone-owns -作者:[SECURITYTRAILS TEAM ][a] +作者:[SECURITYTRAILS TEAM][a] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From aed468f37aacda80ae789a9757c2e615489374cc Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 22:08:09 +0800 Subject: [PATCH 225/344] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @oska874 @lujun9972 --- ...em.md => 20171117 System Logs Understand Your Linux System.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/tech/{20171117 System Logs: Understand Your Linux System.md => 20171117 System Logs Understand Your Linux System.md} (100%) diff --git a/translated/tech/20171117 System Logs: Understand Your Linux System.md b/translated/tech/20171117 System Logs Understand Your Linux System.md similarity index 100% rename from translated/tech/20171117 System Logs: Understand Your Linux System.md rename to translated/tech/20171117 System Logs Understand Your Linux System.md From ebff11487ce2def13b890ed292ff21432173eb50 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 22:20:54 +0800 Subject: [PATCH 226/344] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @oska874 --- ...x command-line screen grabs made simple.md | 108 ------------------ 1 file changed, 108 deletions(-) delete mode 100644 sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md diff --git a/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md b/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md deleted file mode 100644 index 2b4d2248b2..0000000000 --- a/sources/tech/20171130 Scrot Linux command-line screen grabs made simple.md +++ /dev/null @@ -1,108 +0,0 @@ -Scrot: Linux command-line screen grabs made simple -============================================================ - -### Scrot is a basic, flexible tool that offers a number of handy options for taking screen captures from the Linux command line. - -![Scrot: Screen grabs made simple](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/community-penguins-osdc-lead.png?itok=BmqsAF4A "Scrot: Screen grabs made simple") -Image credits : Original photo by Rikki Endsley. [CC BY-SA 4.0][13] - -There are great tools on the Linux desktop for taking screen captures, such as [KSnapshot][14] and [Shutter][15]. Even the simple utility that comes with the GNOME desktop does a pretty good job of capturing screens. But what if you rarely need to take screen captures? Or you use a Linux distribution without a built-in capture tool, or an older computer with limited resources? - -Turn to the command line and a little utility called [Scrot][16]. It does a fine job of taking simple screen captures, and it includes a few features that might surprise you. - -### Getting started with Scrot - -More Linux resources - -* [What is Linux?][1] - -* [What are Linux containers?][2] - -* [Download Now: Linux commands cheat sheet][3] - -* [Advanced Linux commands cheat sheet][4] - -* [Our latest Linux articles][5] - -Many Linux distributions come with Scrot already installed—to check, type `which scrot`. If it isn't there, you can install Scrot using your distro's package manager. If you're willing to compile the code, grab it [from GitHub][22]. - -To take a screen capture, crack open a terminal window and type `scrot [filename]`, where `[filename]` is the name of file to which you want to save the image (for example, `desktop.png`). If you don't include a name for the file, Scrot will create one for you, such as `2017-09-24-185009_1687x938_scrot.png`. (That filename isn't as descriptive it could be, is it? That's why it's better to add one to the command.) - -Running Scrot with no options takes a screen capture of your entire desktop. If you don't want to do that, Scrot lets you focus on smaller portions of your screen. - -### Taking a screen capture of a single window - -Tell Scrot to take a screen capture of a single window by typing `scrot -u [filename]`. - -The `-u` option tells Scrot to grab the window currently in focus. That's usually the terminal window you're working in, which might not be the one you want. - -To grab another window on your desktop, type `scrot -s [filename]`. - -The `-s` option lets you do one of two things: - -* select an open window, or - -* draw a rectangle around a window or a portion of a window to capture it. - -You can also set a delay, which gives you a little more time to select the window you want to capture. To do that, type `scrot -u -d [num] [filename]`. - -The `-d` option tells Scrot to wait before grabbing the window, and `[num]` is the number of seconds to wait. Specifying `-d 5` (wait five seconds) should give you enough time to choose a window. - -### More useful options - -Scrot offers a number of additional features (most of which I never use). The ones I find most useful include: - -* `-b` also grabs the window's border - -* `-t` grabs a window and creates a thumbnail of it. This can be useful when you're posting screen captures online. - -* `-c` creates a countdown in your terminal when you use the `-d` option. - -To learn about Scrot's other options, check out the its documentation by typing `man scrot` in a terminal window, or [read it online][17]. Then start snapping images of your screen. - -It's basic, but Scrot gets the job done nicely. - -### Topics - - [Linux][23] - -### About the author - - [![That idiot Scott Nesbitt ...](https://opensource.com/sites/default/files/styles/profile_pictures/public/scottn-cropped.jpg?itok=q4T2J4Ai)][18] - - Scott Nesbitt - I'm a long-time user of free/open source software, and write various things for both fun and profit. I don't take myself too seriously and I do all of my own stunts. You can find me at these fine establishments on the web: [Twitter][7], [Mastodon][8], [GitHub][9], and... [more about Scott Nesbitt][10][More about me][11] - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot - -作者:[ Scott Nesbitt  ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/scottnesbitt -[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[6]:https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot?rate=H43kUdawjR0GV9D0dCbpnmOWcqw1WekfrAI_qKo8UwI -[7]:http://www.twitter.com/ScottWNesbitt -[8]:https://mastodon.social/@scottnesbitt -[9]:https://github.com/ScottWNesbitt -[10]:https://opensource.com/users/scottnesbitt -[11]:https://opensource.com/users/scottnesbitt -[12]:https://opensource.com/user/14925/feed -[13]:https://creativecommons.org/licenses/by-sa/4.0/ -[14]:https://www.kde.org/applications/graphics/ksnapshot/ -[15]:https://launchpad.net/shutter -[16]:https://github.com/dreamer/scrot -[17]:http://manpages.ubuntu.com/manpages/precise/man1/scrot.1.html -[18]:https://opensource.com/users/scottnesbitt -[19]:https://opensource.com/users/scottnesbitt -[20]:https://opensource.com/users/scottnesbitt -[21]:https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot#comments -[22]:https://github.com/dreamer/scrot -[23]:https://opensource.com/tags/linux From 2cc70c5ed7fa4d4629bed29e652baa634c6b223b Mon Sep 17 00:00:00 2001 From: iron0x <2727586680@qq.com> Date: Mon, 4 Dec 2017 21:40:05 +0800 Subject: [PATCH 227/344] Update 20171202 docker - Use multi-stage builds.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译中 --- sources/tech/20171202 docker - Use multi-stage builds.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171202 docker - Use multi-stage builds.md b/sources/tech/20171202 docker - Use multi-stage builds.md index e1a6414862..8cc8af1c94 100644 --- a/sources/tech/20171202 docker - Use multi-stage builds.md +++ b/sources/tech/20171202 docker - Use multi-stage builds.md @@ -1,3 +1,5 @@ +【iron0x翻译中】 + Use multi-stage builds ============================================================ From 3331a8b0f6aff4b8cafbe021a6a4c00f33b0e5e6 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 22:38:01 +0800 Subject: [PATCH 228/344] PRF:20171124 Photon Could Be Your New Favorite Container OS.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @KeyLD 恭喜你,完成了第一篇翻译! 不过,按照流程,翻译前应该发起申请的 PR,翻译完提交时,要将原文删除。 --- ...Could Be Your New Favorite Container OS.md | 146 ------------------ ...Could Be Your New Favorite Container OS.md | 77 ++++----- 2 files changed, 32 insertions(+), 191 deletions(-) delete mode 100644 sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md diff --git a/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md deleted file mode 100644 index d282ef5445..0000000000 --- a/sources/tech/20171124 Photon Could Be Your New Favorite Container OS.md +++ /dev/null @@ -1,146 +0,0 @@ -Photon Could Be Your New Favorite Container OS -============================================================ - -![Photon OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon-linux.jpg?itok=jUFHPR_c "Photon OS") -Jack Wallen says Photon OS is an outstanding platform, geared specifically for containers.[Creative Commons Zero][5]Pixabay - -Containers are all the rage, and with good reason. [As discussed previously][13], containers allow you to quickly and easily deploy new services and applications onto your network, without requiring too much in the way of added system resources. Containers are more cost-effective than using dedicated hardware or virtual machines, and they’re easier to update and reuse. - -Best of all, containers love Linux (and vice versa). Without much trouble or time, you can get a Linux server up and running with [Docker][14] and deploying containers. But, which Linux distribution is best suited for the deployment of your containers? There are a _lot_  of options. You could go with a standard Ubuntu Server platform (which makes installing Docker and deploying containers incredibly easy), or you could opt for a lighter weight distribution — one geared specifically for the purpose of deploying containers. - -One such distribution is [Photon][15]. This particular platform was created in 2005 by [VMware][16]; it includes the Docker daemon and works with container frameworks, such as Mesos and Kubernetes. Photon is optimized to work with [VMware vSphere][17], but it can be used on bare metal, [Microsoft Azure][18], [Google Compute Engine][19], [Amazon Elastic Compute Cloud][20], or [VirtualBox][21]. - -Photon manages to stay slim by only installing what is absolutely necessary to run the Docker daemon. In the end, the distribution comes in around 300 MB. This is just enough Linux make it all work. The key features to Photon are: - -* Kernel tuned for performance. - -* Kernel is hardened according to the [Kernel Self-Protection Project][6] (KSPP). - -* All installed packages are built with hardened security flags. - -* Operating system boots with validated trust. - -* Photon management daemon manages firewall, network, packages, and users on remote Photon OS machines. - -* Support for persistent volumes. - -* [Project Lightwave][7] integration. - -* Timely security patches and updates. - -Photon can be used via [ISO][22], [OVA][23], [Amazon Machine Image][24], [Google Compute Engine image][25], and [Azure VHD][26]. I’ll show you how to install Photon on VirtualBox, using an ISO image. The installation takes about five minutes and, in the end, you’ll have a virtual machine, ready to deploy containers. - -### Creating the virtual machine - -Before you deploy that first container, you have to create the virtual machine and install Photon. To do this, open up VirtualBox and click the New button. Walk through the Create Virtual Machine wizard (giving Photon the necessary resources, based on the usage you predict the container server will need). Once you’ve created the virtual machine, you need to first make a change to the settings. Select the newly created virtual machine (in the left pane of the VirtualBox main window) and then click Settings. In the resulting window, click on Network (from the left navigation). - -In the Networking window (Figure 1), you need to change the Attached to drop-down to Bridged Adapter. This will ensure your Photon server is reachable from your network. Once you’ve made that change, click OK. - -### [photon_0.jpg][8] - -![change settings](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_0.jpg?itok=Q0yhOhsZ "change settings") -Figure 1: Changing the VirtualBox network settings for Photon.[Used with permission][1] - -Select your Photon virtual machine from the left navigation and then click Start. You will be prompted to locate and attach the IOS image. Once you’ve done that, Photon will boot up and prompt you to hit Enter to begin the installation. The installation is ncurses based (there is no GUI), but it’s incredibly simple. - -In the next screen (Figure 2), you will be asked if you want to do a Minimal, Full, or OSTree Server. I opted to go the Full route. Select whichever option you require and hit enter. - -### [photon_1.jpg][9] - -![installation type](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_1.jpg?itok=OdnMVpaA "installation type") -Figure 2: Selecting your installation type.[Used with permission][2] - -In the next window, select the disk that will house Photon. Since we’re installing this as a virtual machine, there will be only one disk listed (Figure 3). Tab down to Auto and hit Enter on your keyboard. The installation will then require you to type (and verify) an administrator password. Once you’ve done that, the installation will begin and finish in less than five minutes. - -### [photon_2.jpg][10] - -![Photon ](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_2.jpg?itok=QL1Rs-PH "Photon") -Figure 3: Selecting your hard disk for the Photon installation.[Used with permission][3] - -Once the installation completes, reboot the virtual machine and log in with the username root and the password you created during installation. You are ready to start working. - -Before you begin using Docker on Photon, you’ll want to upgrade the platform. Photon uses the _yum_ package manager, so login as root and issue the command  _yum update_ .If there are any updates available, you’ll be asked to okay the process (Figure 4). - -### [photon_3.jpg][11] - -![Updating](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_3.jpg?itok=vjqrspE2 "Updating") -Figure 4: Updating Photon.[Used with permission][4] - -Usage - -As I mentioned, Photon comes with everything you need to deploy containers or even create a Kubernetes cluster. However, out of the box, there are a few things you’ll need to do. The first thing is to enable the Docker daemon to run at start. To do this, issue the commands: - -``` -systemctl start docker - -systemctl enable docker -``` - -Now we need to create a standard user, so we’re not running the docker command as root. To do this, issue the following commands: - -``` -useradd -m USERNAME - -passwd USERNAME -``` - -Where USERNAME is the name of the user to add. - -Next we need to add the new user to the  _docker_ group with the command: - -``` -usermod -a -G docker USERNAME -``` - -Where USERNAME is the name of the user just created. - -Log out as the root user and log back in as the newly created user. You can now work with the  _docker _ command without having to make use of  _sudo_  or switching to the root user. Pull down an image from Docker Hub and start deploying containers. - -### An outstanding container platform - -Photon is, without a doubt, an outstanding platform, geared specifically for containers. Do note that Photon is an open source project, so there is no paid support to be had. If you find yourself having trouble with Photon, hop on over to the [Issues tab in the Photon Project’s Github page][27], where you can read and post about issues. And if you’re interested in forking Photon, you’ll find the source code on the project’s [official Github page][28]. - -Give Photon a try and see if it doesn’t make deploying Docker containers and/or Kubernetes clusters significantly easier. - - _Learn more about Linux through the free ["Introduction to Linux" ][29]course from The Linux Foundation and edX._ - --------------------------------------------------------------------------------- - -via: 网址 - -作者:[ JACK WALLEN][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/jlwallen -[1]:https://www.linux.com/licenses/category/used-permission -[2]:https://www.linux.com/licenses/category/used-permission -[3]:https://www.linux.com/licenses/category/used-permission -[4]:https://www.linux.com/licenses/category/used-permission -[5]:https://www.linux.com/licenses/category/creative-commons-zero -[6]:https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project -[7]:http://vmware.github.io/lightwave/ -[8]:https://www.linux.com/files/images/photon0jpg -[9]:https://www.linux.com/files/images/photon1jpg -[10]:https://www.linux.com/files/images/photon2jpg -[11]:https://www.linux.com/files/images/photon3jpg -[12]:https://www.linux.com/files/images/photon-linuxjpg -[13]:https://www.linux.com/learn/intro-to-linux/2017/11/how-install-and-use-docker-linux -[14]:https://www.docker.com/ -[15]:https://vmware.github.io/photon/ -[16]:https://www.vmware.com/ -[17]:https://www.vmware.com/products/vsphere.html -[18]:https://azure.microsoft.com/ -[19]:https://cloud.google.com/compute/ -[20]:https://aws.amazon.com/ec2/ -[21]:https://www.virtualbox.org/ -[22]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[23]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[24]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[25]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[26]:https://github.com/vmware/photon/wiki/Downloading-Photon-OS -[27]:https://github.com/vmware/photon/issues -[28]:https://github.com/vmware/photon -[29]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md index e51c580da9..3496f22f4a 100644 --- a/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md +++ b/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md @@ -1,109 +1,96 @@ -Photon也许能成为你最喜爱的容器操作系统 +Photon 也许能成为你最喜爱的容器操作系统 ============================================================ ![Photon OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon-linux.jpg?itok=jUFHPR_c "Photon OS") -Phonton OS专注于容器,是一个非常出色的平台。 —— Jack Wallen +>Phonton OS 专注于容器,是一个非常出色的平台。 —— Jack Wallen 容器在当下的火热,并不是没有原因的。正如[之前][13]讨论的,容器可以使您轻松快捷地将新的服务与应用部署到您的网络上,而且并不耗费太多的系统资源。比起专用硬件和虚拟机,容器都是更加划算的,除此之外,他们更容易更新与重用。 -更重要的是,容器喜欢Linux(反之亦然)。不需要太多时间和麻烦,你就可以启动一台Linux服务器,运行[Docker][14],再是部署容器。但是,哪种Linux发行版最适合部署容器呢?我们的选择很多。你可以使用标准的Ubuntu服务器平台(更容易安装Docker并部署容器)或者是更轻量级的发行版 —— 专门用于部署容器。 +更重要的是,容器喜欢 Linux(反之亦然)。不需要太多时间和麻烦,你就可以启动一台 Linux 服务器,运行[Docker][14],然后部署容器。但是,哪种 Linux 发行版最适合部署容器呢?我们的选择很多。你可以使用标准的 Ubuntu 服务器平台(更容易安装 Docker 并部署容器)或者是更轻量级的发行版 —— 专门用于部署容器。 -[Photon][15]就是这样的一个发行版。这个特殊的版本是由[VMware][16]于2005年创建的,它包含了Docker的守护进程,并与容器框架(如Mesos和Kubernetes)一起使用。Photon经过优化可与[VMware vSphere][17]协同工作,而且可用于裸机,[Microsoft Azure][18], [Google Compute Engine][19], [Amazon Elastic Compute Cloud][20], 或者 [VirtualBox][21]等。 +[Photon][15] 就是这样的一个发行版。这个特殊的版本是由 [VMware][16] 于 2005 年创建的,它包含了 Docker 的守护进程,并可与容器框架(如 Mesos 和 Kubernetes )一起使用。Photon 经过优化可与 [VMware vSphere][17] 协同工作,而且可用于裸机、[Microsoft Azure][18]、 [Google Compute Engine][19]、 [Amazon Elastic Compute Cloud][20] 或者 [VirtualBox][21] 等。 -Photon通过只安装Docker守护进程所必需的东西来保持它的轻量。而这样做的结果是,这个发行版的大小大约只有300MB。但这足以让Linux的运行一切正常。除此之外,Photon的主要特点还有: - -* 内核调整为性能模式。 - -* 内核根据[内核自防护项目][6](KSPP)进行了加固。 +Photon 通过只安装 Docker 守护进程所必需的东西来保持它的轻量。而这样做的结果是,这个发行版的大小大约只有 300MB。但这足以让 Linux 的运行一切正常。除此之外,Photon 的主要特点还有: +* 内核为性能而调整。 +* 内核根据[内核自防护项目][6](KSPP)进行了加固。 * 所有安装的软件包都根据加固的安全标识来构建。 - * 操作系统在信任验证后启动。 - -* Photon管理进程管理防火墙,网络,软件包,和远程登录在Photon机子上的用户。 - +* Photon 的管理进程可以管理防火墙、网络、软件包,和远程登录在 Photon 机器上的用户。 * 支持持久卷。 - * [Project Lightwave][7] 整合。 - * 及时的安全补丁与更新。 -Photon可以通过[ISO][22],[OVA][23],[Amazon Machine Image][24],[Google Compute Engine image][25]和[Azure VHD][26]安装使用。现在我将向您展示如何使用ISO镜像在VirtualBox上安装Photon。整个安装过程大概需要五分钟,在最后您将有一台随时可以部署容器的虚拟机。 +Photon 可以通过 [ISO 镜像][22]、[OVA][23]、[Amazon Machine Image][24]、[Google Compute Engine 镜像][25] 和 [Azure VHD][26] 安装使用。现在我将向您展示如何使用 ISO 镜像在 VirtualBox 上安装 Photon。整个安装过程大概需要五分钟,在最后您将有一台随时可以部署容器的虚拟机。 ### 创建虚拟机 -在部署第一台容器之前,您必须先创建一台虚拟机并安装Photon。为此,打开VirtualBox并点击“新建”按钮。跟着创建虚拟机向导进行配置(根据您的容器将需要的用途,为Photon提供必要的资源)。在创建好虚拟机后,您所需要做的第一件事就是更改配置。选择新建的虚拟机(在VirtualBox主窗口的左侧面板中),然后单击“设置”。在弹出的窗口中,点击“网络”(在左侧的导航中)。 +在部署第一台容器之前,您必须先创建一台虚拟机并安装 Photon。为此,打开 VirtualBox 并点击“新建”按钮。跟着创建虚拟机向导进行配置(根据您的容器将需要的用途,为 Photon 提供必要的资源)。在创建好虚拟机后,您所需要做的第一件事就是更改配置。选择新建的虚拟机(在 VirtualBox 主窗口的左侧面板中),然后单击“设置”。在弹出的窗口中,点击“网络”(在左侧的导航中)。 -在“网络”窗口(图1)中,你需要在“连接”的下拉窗口中选择桥接。这可以确保您的Photon服务与您的网络相连。完成更改后,单击确定。 - -### [photon_0.jpg][8] +在“网络”窗口(图1)中,你需要在“连接”的下拉窗口中选择桥接。这可以确保您的 Photon 服务与您的网络相连。完成更改后,单击确定。 ![change settings](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_0.jpg?itok=Q0yhOhsZ "change setatings") -图 1: 更改Photon在VirtualBox中的网络设置。[经许可使用][1] -从左侧的导航选择您的Photon虚拟机,点击启动。系统会提示您去加载IOS镜像。当您完成之后,Photon安装程序将会启动并提示您按回车后开始安装。安装过程基于ncurses(没有GUI),但它非常简单。 +*图 1: 更改 Photon 在 VirtualBox 中的网络设置。[经许可使用][1]* -接下来(图2),系统会询问您是要最小化安装,完整安装还是安装OSTree服务器。我选择了完整安装。选择您所需要的任意选项,然后按回车继续。 +从左侧的导航选择您的 Photon 虚拟机,点击启动。系统会提示您去加载 ISO 镜像。当您完成之后,Photon 安装程序将会启动并提示您按回车后开始安装。安装过程基于 ncurses(没有 GUI),但它非常简单。 -### [photon_1.jpg][9] +接下来(图2),系统会询问您是要最小化安装,完整安装还是安装 OSTree 服务器。我选择了完整安装。选择您所需要的任意选项,然后按回车继续。 ![installation type](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_2.jpg?itok=QL1Rs-PH "Photon") -图 2: 选择您的安装类型.[经许可使用][2] -在下一个窗口,选择您要安装Photon的磁盘。由于我们将其安装在虚拟机,因此只有一块磁盘会被列出(图3)。选择“自动”按下回车。然后安装程序会让您输入(并验证)管理员密码。在这之后镜像开始安装在您的磁盘上并在不到5分钟的时间内结束。 +*图 2: 选择您的安装类型。[经许可使用][2]* -### [photon_2.jpg][] +在下一个窗口,选择您要安装 Photon 的磁盘。由于我们将其安装在虚拟机,因此只有一块磁盘会被列出(图3)。选择“自动”按下回车。然后安装程序会让您输入(并验证)管理员密码。在这之后镜像开始安装在您的磁盘上并在不到 5 分钟的时间内结束。 ![Photon](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_1.jpg?itok=OdnMVpaA "installation type") -图 3: 选择安装Photon的硬盘.[经许可使用][3] -安装完成后,重启虚拟机并使用安装时创建的用户root和它的密码登录。一切就绪,你准备好开始工作了。 +*图 3: 选择安装 Photon 的硬盘。[经许可使用][3]* -在开始使用Docker之前,您需要更新一下Photon。Photon使用 _yum_ 软件包管理器,因此在以root用户登录后输入命令 _yum update_。如果有任何可用更新,则会询问您是否确认(图4)。 +安装完成后,重启虚拟机并使用安装时创建的用户 root 和它的密码登录。一切就绪,你准备好开始工作了。 -### [photon_3.jpg][11] +在开始使用 Docker 之前,您需要更新一下 Photon。Photon 使用 `yum` 软件包管理器,因此在以 root 用户登录后输入命令 `yum update`。如果有任何可用更新,则会询问您是否确认(图4)。 ![Updating](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/photon_3.jpg?itok=vjqrspE2 "Updating") -图 4: 更新 Photon.[经许可使用][4] -用法 +*图 4: 更新 Photon。[经许可使用][4]* -正如我所说的,Photon提供了部署容器甚至创建Kubernetes集群所需要的所有包。但是,在使用之前还要做一些事情。首先要启动Docker守护进程。为此,执行以下命令: +### 用法 + +正如我所说的,Photon 提供了部署容器甚至创建 Kubernetes 集群所需要的所有包。但是,在使用之前还要做一些事情。首先要启动 Docker 守护进程。为此,执行以下命令: ``` systemctl start docker - systemctl enable docker ``` -现在我们需要创建一个标准用户,因此我们没有以root去运行docker命令。为此,执行以下命令: +现在我们需要创建一个标准用户,以便我们可以不用 root 去运行 `docker` 命令。为此,执行以下命令: ``` useradd -m USERNAME - passwd USERNAME ``` -其中USERNAME是我们新增的用户的名称。 +其中 “USERNAME” 是我们新增的用户的名称。 -接下来,我们需要将这个新用户添加到 _docker_ 组,执行命令: +接下来,我们需要将这个新用户添加到 “docker” 组,执行命令: ``` usermod -a -G docker USERNAME ``` -其中USERNAME是刚刚创建的用户的名称。 +其中 “USERNAME” 是刚刚创建的用户的名称。 -注销root用户并切换为新增的用户。现在,您已经可以不必使用 _sudo_ 命令或者是切换到root用户来使用 _docker_命令了。从Docker Hub中取出一个镜像开始部署容器吧。 +注销 root 用户并切换为新增的用户。现在,您已经可以不必使用 `sudo` 命令或者切换到 root 用户来使用 `docker` 命令了。从 Docker Hub 中取出一个镜像开始部署容器吧。 ### 一个优秀的容器平台 -在专注于容器方面,Photon毫无疑问是一个出色的平台。请注意,Photon是一个开源项目,因此没有任何付费支持。如果您对Photon有任何的问题,请移步Photon项目的Github下的[Issues][27],那里可以供您阅读相关问题,或者提交您的问题。如果您对Photon感兴趣,您也可以在项目的官方[Github][28]中找到源码。 +在专注于容器方面,Photon 毫无疑问是一个出色的平台。请注意,Photon 是一个开源项目,因此没有任何付费支持。如果您对 Photon 有任何的问题,请移步 Photon 项目的 GitHub 下的 [Issues][27],那里可以供您阅读相关问题,或者提交您的问题。如果您对 Photon 感兴趣,您也可以在该项目的官方 [GitHub][28]中找到源码。 -尝试一下Photon吧,看看它是否能够使得Docker容器和Kubernetes集群的部署更加容易。 +尝试一下 Photon 吧,看看它是否能够使得 Docker 容器和 Kubernetes 集群的部署更加容易。 -欲了解Linux的更多信息,可以通过学习Linux基金会和edX的免费课程,[“Linux 入门”][29]。 +欲了解 Linux 的更多信息,可以通过学习 Linux 基金会和 edX 的免费课程,[“Linux 入门”][29]。 -------------------------------------------------------------------------------- @@ -111,7 +98,7 @@ via: https://www.linux.com/learn/intro-to-linux/2017/11/photon-could-be-your-new 作者:[JACK WALLEN][a] 译者:[KeyLD](https://github.com/KeyLd) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 394b86f17475663803cffffd4e97ed80dfea392e Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 4 Dec 2017 22:38:59 +0800 Subject: [PATCH 229/344] PUB:20171124 Photon Could Be Your New Favorite Container OS.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @KeyLD 文章的发布地址:https://linux.cn/article-9110-1.html 你的 LCTT 专页地址: https://linux.cn/lctt/KeyLD --- .../20171124 Photon Could Be Your New Favorite Container OS.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171124 Photon Could Be Your New Favorite Container OS.md (100%) diff --git a/translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md b/published/20171124 Photon Could Be Your New Favorite Container OS.md similarity index 100% rename from translated/tech/20171124 Photon Could Be Your New Favorite Container OS.md rename to published/20171124 Photon Could Be Your New Favorite Container OS.md From 0d47bc6d19f6194cf93a19dfd69fce276f3ec130 Mon Sep 17 00:00:00 2001 From: imquanquan Date: Mon, 4 Dec 2017 22:13:28 +0800 Subject: [PATCH 230/344] translated --- ...ow to Manage Users with Groups in Linux.md | 183 ++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 translated/tech/20171201 How to Manage Users with Groups in Linux.md diff --git a/translated/tech/20171201 How to Manage Users with Groups in Linux.md b/translated/tech/20171201 How to Manage Users with Groups in Linux.md new file mode 100644 index 0000000000..8baac8707b --- /dev/null +++ b/translated/tech/20171201 How to Manage Users with Groups in Linux.md @@ -0,0 +1,183 @@ +如何在 Linux 系统中用用户组来管理用户 +============================================================ + +### [group-of-people-1645356_1920.jpg][1] + +![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/group-of-people-1645356_1920.jpg?itok=rJlAxBSV) + +在本教程中了解如何通过用户组和访问控制表(ACL)来管理用户。 + +[创意共享协议][4] + +当你需要管理一台容纳多个用户的 Linux 机器时,比起一些基本的用户管理工具所提供的方法,有时候你需要对这些用户采取更多的用户权限管理方式。特别是当你要管理某些用户的权限时,这个想法尤为重要。比如说,你有一个目录,一个用户组中的用户可以通过读和写的权限访问这个目录,而其他用户组中的用户对这个目录只有读的权限。通过 Linux 这是完全可以实现的。但是你首先必须了解如何通过用户组和访问控制表(ACL)来管理用户。 + +我们将从简单的用户开始,逐渐深入到复杂的访问控制表(ACL)。你所需要做的一切都将在你选择的 Linux 发行版中完成。本文的重点是用户组,所以不会涉及到关于用户的基础知识。 + +为了达到演示的目的,我将假设: + +你需要用下面两个用户名新建两个用户: + +* olivia + +* nathan + +你需要新建以下两个用户组: + +* readers + +* editors + +olivia 属于 editors 用户组,而 nathan 属于 readers 用户组。reader 用户组对 ``/DATA`` 目录只有读的权限,而 editors 用户组则对 ``/DATA`` 目录同时有读和写的权限。当然,这是个非常小的任务,但它会给你基本的用法。你可以扩展这个任务以适应你其他更大的需求。 + +我将在 Ubuntu 16.04 Server 平台上进行演示。这些命令都是通用的,唯一不同的是,要是在你的发行版中不使用 sudo 命令,你必须切换到 root 用户来执行这些命令。 + +### 创建用户 + +我们需要做的第一件事是为我们的实验创建两个用户。可以用 ``useradd`` 命令来创建用户,我们不只是简单地创建一个用户,而需要同时创建用户和属于他们的家目录,然后给他们设置密码。 + +``` +sudo useradd -m olivia + +sudo useradd -m nathan +``` + +我们现在创建了两个用户,如果你看看 ``/home`` 目录,你可以发现他们的家目录(因为我们用了 -m 选项,可以帮在创建用户的同时创建他们的家目录。 + +之后,我们可以用以下命令给他们设置密码: + +``` +sudo passwd olivia + +sudo passwd nathan +``` + +就这样,我们创建了两个用户。 + +### 创建用户组并添加用户 + +现在我们将创建 readers 和 editors 用户组,然后给它们添加用户。创建用户组的命令是: + +``` +addgroup readers + +addgroup editors +``` + +(译者注:当你使用 CentOS 等一些 Linux 发行版时,可能系统没有 addgroup 这个命令,推荐使用 groupadd 命令来替换 addgroup 命令以达到同样的效果) + + +### [groups_1.jpg][2] + +![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/groups_1.jpg?itok=BKwL89BB) + +图一:我们可以使用刚创建的新用户组了。 + +[Used with permission][5] + +创建用户组后,我们需要给他们添加用户。我们用以下命令来将 nathan 添加到 readers 用户组: + +``` +sudo usermod -a -G readers nathan +``` +用以下命令将 olivia 添加到 editors 用户组: + +``` +sudo usermod -a -G editors olivia +``` + +现在我们已经准备好用用户组来管理用户了。 + +### 给用户组授予目录的权限 + +假设你有个目录 ``/READERS``,允许 readers 用户组的所有成员访问这个目录。首先,我们执行以下命令来更改目录所属用户组: + +``` +sudo chown -R :readers /READERS +``` + +接下来,执行以下命令收回目录所属用户组的写入权限: + +``` +sudo chmod -R g-w /READERS +``` + +然后我们执行下面的命令来收回其他用户对这个目录的访问权限(以防止任何不在读者组中的用户访问这个目录里的文件): + +``` +sudo chmod -R o-x /READERS +``` + +这时候,只有目录的所有者(root)和用户组 reader 中的用户可以访问 ``/READES`` 中的文件。 + +假设你有个目录 ``/EDITORS`` ,你需要给用户组 editors 里的成员这个目录的读和写的权限。为了达到这个目的,执行下面的这些命令是必要的: + +``` +sudo chown -R :editors /EDITORS + +sudo chmod -R g+w /EDITORS + +sudo chmod -R o-x /EDITORS +``` + +此时 editors 用户组的所有成员都可以访问和修改其中的文件。除此之外其他用户(除了 root 之外)无法访问 ``/EDITORS`` 中的任何文件。 + +使用这个方法的问题在于,你一次只能操作一个组和一个目录而已。这时候访问控制表(ACL)就可以派得上用场了。 + + +### 使用访问控制表(ACL) + +现在,让我们把这个问题变得棘手一点。假设你有一个目录 ``/DATA`` 并且你想给 readers 用户组的成员读取权限同时给 editors 用户组的成员读和写的权限。为此,你必须要用到 setfacl 命令。setfacl 命令可以为文件或文件夹设置一个访问控制表(ACL)。 + +这个命令的结构如下: + +``` +setfacl OPTION X:NAME:Y /DIRECTORY +``` + +其中 OPTION 是可选选项,X 可以是 u(用户)或者是 g (用户组),NAME 是用户或者用户组的名字,/DIRECTORY 是要用到的目录。我们将使用 -m 选项进行修改(modify)。因此,我们给 readers 用户组添加读取权限的命令是: + +``` +sudo setfacl -m g:readers:rx -R /DATA +``` + +现在 readers 用户组里面的每一个用户都可以读取 /DATA 目录里的文件了,但是他们不能修改里面的内容。 + +为了给 editors 用户组里面的用户读写权限,我们执行了以下的命令: + +``` +sudo setfacl -m g:editors:rwx -R /DATA +``` +上述命令将赋予 editors 用户组中的任何成员读取权限,同时保留 readers 用户组的只读权限。 + +### 更多的权限控制 + +使用访问控制表(ACL),你可以实现你所需的权限控制。你可以实现将用户添加到用户组,并且可靠灵活地控制这些用户组对每个目录的权限以达到你的需求。想要了解上述工具的更多信息,可以执行下列的命令: + +* man usradd + +* man addgroup + +* man usermod + +* man sefacl + +* man chown + +* man chmod + + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2017/12/how-manage-users-groups-linux + +作者:[Jack Wallen ] +译者:[imquanquan](https://github.com/imquanquan) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://www.linux.com/files/images/group-people-16453561920jpg +[2]:https://www.linux.com/files/images/groups1jpg +[3]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux +[4]:https://www.linux.com/licenses/category/creative-commons-zero +[5]:https://www.linux.com/licenses/category/used-permission From 05c023a7ee532f3119e59a69bedf317008b3a6d5 Mon Sep 17 00:00:00 2001 From: imquanquan Date: Mon, 4 Dec 2017 22:33:42 +0800 Subject: [PATCH 231/344] Delete 20171201 How to Manage Users with Groups in Linux.md --- ...ow to Manage Users with Groups in Linux.md | 168 ------------------ 1 file changed, 168 deletions(-) delete mode 100644 sources/tech/20171201 How to Manage Users with Groups in Linux.md diff --git a/sources/tech/20171201 How to Manage Users with Groups in Linux.md b/sources/tech/20171201 How to Manage Users with Groups in Linux.md deleted file mode 100644 index 35350c819f..0000000000 --- a/sources/tech/20171201 How to Manage Users with Groups in Linux.md +++ /dev/null @@ -1,168 +0,0 @@ -translating---imquanquan - -How to Manage Users with Groups in Linux -============================================================ - -### [group-of-people-1645356_1920.jpg][1] - -![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/group-of-people-1645356_1920.jpg?itok=rJlAxBSV) - -Learn how to work with users, via groups and access control lists in this tutorial. - -[Creative Commons Zero][4] - -Pixabay - -When you administer a Linux machine that houses multiple users, there might be times when you need to take more control over those users than the basic user tools offer. This idea comes to the fore especially when you need to manage permissions for certain users. Say, for example, you have a directory that needs to be accessed with read/write permissions by one group of users and only read permissions for another group. With Linux, this is entirely possible. To make this happen, however, you must first understand how to work with users, via groups and access control lists (ACLs). - -We’ll start from the beginning with users and work our way to the more complex ACLs. Everything you need to make this happen will be included in your Linux distribution of choice. We won’t touch on the basics of users, as the focus on this article is about groups. - -For the purpose of this piece, I’m going to assume the following: - -You need to create two users with usernames: - -* olivia - -* nathan - -You need to create two groups: - -* readers - -* editors - -Olivia needs to be a member of the group editors, while nathan needs to be a member of the group readers. The group readers needs to only have read permission to the directory /DATA, whereas the group editors needs to have both read and write permission to the /DATA directory. This, of course, is very minimal, but it will give you the basic information you need to expand the tasks to fit your much larger needs. - -I’ll be demonstrating on the Ubuntu 16.04 Server platform. The commands will be universal—the only difference would be if your distribution of choice doesn’t make use of sudo. If this is the case, you’ll have to first su to the root user to issue the commands that require sudo in the demonstrations. - -### Creating the users - -The first thing we need to do is create the two users for our experiment. User creation is handled with the useradd command. Instead of just simply creating the users we need to create them both with their own home directories and then give them passwords. - -The first thing we do is create the users. To do this, issue the commands: - -``` -sudo useradd -m olivia - -sudo useradd -m nathan -``` - -Next each user must have a password. To add passwords into the mix, you’d issue the following commands: - -``` -sudo passwd olivia - -sudo passwd nathan -``` - -That’s it, your users are created. - -### Creating groups and adding users - -Now we’re going to create the groups readers and editors and then add users to them. The commands to create our groups are: - -``` -addgroup readers - -addgroup editors -``` - -### [groups_1.jpg][2] - -![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/groups_1.jpg?itok=BKwL89BB) - -Figure 1: Our new groups ready to be used. - -[Used with permission][5] - -With our groups created, we need to add our users. We’ll add user nathan to group readers with the command: - -``` -sudo usermod -a -G readers nathan -``` - -``` -sudo usermod -a -G editors olivia -``` - -### Giving groups permissions to directories - -Let’s say you have the directory /READERS and you need to allow all members of the readers group access to that directory. First, change the group of the folder with the command: - -``` -sudo chown -R :readers /READERS -``` - -``` -sudo chmod -R g-w /READERS -``` - -``` -sudo chmod -R o-x /READERS -``` - -Let’s say you have the directory /EDITORS and you need to give members of the editors group read and write permission to its contents. To do that, the following command would be necessary: - -``` -sudo chown -R :editors /EDITORS - -sudo chmod -R g+w /EDITORS - -sudo chmod -R o-x /EDITORS -``` - -The problem with using this method is you can only add one group to a directory at a time. This is where access control lists come in handy. - -### Using access control lists - -Now, let’s get tricky. Say you have a single folder—/DATA—and you want to give members of the readers group read permission and members of the group editors read/write permissions. To do that, you must take advantage of the setfacl command. The setfacl command sets file access control lists for files and folders. - -The structure of this command looks like this: - -``` -setfacl OPTION X:NAME:Y /DIRECTORY -``` - -``` -sudo setfacl -m g:readers:rx -R /DATA -``` - -To give members of the editors group read/write permissions (while retaining read permissions for the readers group), we’d issue the command; - -``` -sudo setfacl -m g:editors:rwx -R /DATA -``` - -### All the control you need - -And there you have it. You can now add members to groups and control those groups’ access to various directories with all the power and flexibility you need. To read more about the above tools, issue the commands: - -* man usradd - -* man addgroup - -* man usermod - -* man sefacl - -* man chown - -* man chmod - -Learn more about Linux through the free ["Introduction to Linux" ][3]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2017/12/how-manage-users-groups-linux - -作者:[Jack Wallen ] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[1]:https://www.linux.com/files/images/group-people-16453561920jpg -[2]:https://www.linux.com/files/images/groups1jpg -[3]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux -[4]:https://www.linux.com/licenses/category/creative-commons-zero -[5]:https://www.linux.com/licenses/category/used-permission From 1cf098441ad2c87f765b01cf53657a78524494b6 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Sun, 3 Dec 2017 20:44:35 +0800 Subject: [PATCH 232/344] modified by qhwdw --- core.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core.md b/core.md index da45c009fc..3093f4ae52 100644 --- a/core.md +++ b/core.md @@ -36,4 +36,4 @@ - 除非必要,合并 PR 时不要 squash-merge wxy@LCTT -2016/12/24 \ No newline at end of file +2017/12/24 From c0ea07298e5302ab39aacdd1acbc671dcb401ad7 Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Sun, 3 Dec 2017 20:47:57 +0800 Subject: [PATCH 233/344] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core.md b/core.md index 3093f4ae52..2ec8aa89cf 100644 --- a/core.md +++ b/core.md @@ -36,4 +36,4 @@ - 除非必要,合并 PR 时不要 squash-merge wxy@LCTT -2017/12/24 +2016/12/24 From e81680b74e189e056f5a35751b2bbb256c3d2e28 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Mon, 4 Dec 2017 22:48:12 +0800 Subject: [PATCH 234/344] Translating by qhwdw --- ...20160922 A Linux users guide to Logical Volume Management.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20160922 A Linux users guide to Logical Volume Management.md b/sources/tech/20160922 A Linux users guide to Logical Volume Management.md index ff0e390f38..baed1b3976 100644 --- a/sources/tech/20160922 A Linux users guide to Logical Volume Management.md +++ b/sources/tech/20160922 A Linux users guide to Logical Volume Management.md @@ -1,4 +1,4 @@ -A Linux user's guide to Logical Volume Management +Translating by qhwdw A Linux user's guide to Logical Volume Management ============================================================ ![Logical Volume Management (LVM)](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_other11x_cc.png?itok=I_kCDYj0 "Logical Volume Management (LVM)") From d69030fc577d9d34f8cae427bd5f3362b4947669 Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Mon, 4 Dec 2017 23:14:31 +0800 Subject: [PATCH 235/344] Revert "Translating by qhwdw" --- core.md | 2 +- ...20160922 A Linux users guide to Logical Volume Management.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core.md b/core.md index 2ec8aa89cf..da45c009fc 100644 --- a/core.md +++ b/core.md @@ -36,4 +36,4 @@ - 除非必要,合并 PR 时不要 squash-merge wxy@LCTT -2016/12/24 +2016/12/24 \ No newline at end of file diff --git a/sources/tech/20160922 A Linux users guide to Logical Volume Management.md b/sources/tech/20160922 A Linux users guide to Logical Volume Management.md index baed1b3976..ff0e390f38 100644 --- a/sources/tech/20160922 A Linux users guide to Logical Volume Management.md +++ b/sources/tech/20160922 A Linux users guide to Logical Volume Management.md @@ -1,4 +1,4 @@ -Translating by qhwdw A Linux user's guide to Logical Volume Management +A Linux user's guide to Logical Volume Management ============================================================ ![Logical Volume Management (LVM)](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_other11x_cc.png?itok=I_kCDYj0 "Logical Volume Management (LVM)") From 068f19be89218a9006cfab8e6483416f31f6a0ea Mon Sep 17 00:00:00 2001 From: imquanquan Date: Mon, 4 Dec 2017 23:15:21 +0800 Subject: [PATCH 236/344] fix errors based on the previous translations --- ...ow to Manage Users with Groups in Linux.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/translated/tech/20171201 How to Manage Users with Groups in Linux.md b/translated/tech/20171201 How to Manage Users with Groups in Linux.md index 8baac8707b..1927de6817 100644 --- a/translated/tech/20171201 How to Manage Users with Groups in Linux.md +++ b/translated/tech/20171201 How to Manage Users with Groups in Linux.md @@ -5,13 +5,13 @@ ![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/group-of-people-1645356_1920.jpg?itok=rJlAxBSV) -在本教程中了解如何通过用户组和访问控制表(ACL)来管理用户。 +本教程可以了解如何通过用户组和访问控制表(ACL)来管理用户。 [创意共享协议][4] -当你需要管理一台容纳多个用户的 Linux 机器时,比起一些基本的用户管理工具所提供的方法,有时候你需要对这些用户采取更多的用户权限管理方式。特别是当你要管理某些用户的权限时,这个想法尤为重要。比如说,你有一个目录,一个用户组中的用户可以通过读和写的权限访问这个目录,而其他用户组中的用户对这个目录只有读的权限。通过 Linux 这是完全可以实现的。但是你首先必须了解如何通过用户组和访问控制表(ACL)来管理用户。 +当你需要管理一台容纳多个用户的 Linux 机器时,比起一些基本的用户管理工具所提供的方法,有时候你需要对这些用户采取更多的用户权限管理方式。特别是当你要管理某些用户的权限时,这个想法尤为重要。比如说,你有一个目录,某个用户组中的用户可以通过读和写的权限访问这个目录,而其他用户组中的用户对这个目录只有读的权限。在 Linux 中,这是完全可以实现的。但前提是你必须先了解如何通过用户组和访问控制表(ACL)来管理用户。 -我们将从简单的用户开始,逐渐深入到复杂的访问控制表(ACL)。你所需要做的一切都将在你选择的 Linux 发行版中完成。本文的重点是用户组,所以不会涉及到关于用户的基础知识。 +我们将从简单的用户开始,逐渐深入到复杂的访问控制表(ACL)。你可以在你所选择的 Linux 发行版完成你所需要做的一切。本文的重点是用户组,所以不会涉及到关于用户的基础知识。 为了达到演示的目的,我将假设: @@ -27,7 +27,7 @@ * editors -olivia 属于 editors 用户组,而 nathan 属于 readers 用户组。reader 用户组对 ``/DATA`` 目录只有读的权限,而 editors 用户组则对 ``/DATA`` 目录同时有读和写的权限。当然,这是个非常小的任务,但它会给你基本的用法。你可以扩展这个任务以适应你其他更大的需求。 +olivia 属于 editors 用户组,而 nathan 属于 readers 用户组。reader 用户组对 ``/DATA`` 目录只有读的权限,而 editors 用户组则对 ``/DATA`` 目录同时有读和写的权限。当然,这是个非常小的任务,但它会给你基本的信息·。你可以扩展这个任务以适应你其他更大的需求。 我将在 Ubuntu 16.04 Server 平台上进行演示。这些命令都是通用的,唯一不同的是,要是在你的发行版中不使用 sudo 命令,你必须切换到 root 用户来执行这些命令。 @@ -74,7 +74,7 @@ addgroup editors [Used with permission][5] -创建用户组后,我们需要给他们添加用户。我们用以下命令来将 nathan 添加到 readers 用户组: +创建用户组后,我们需要添加我们的用户到这两个用户组。我们用以下命令来将 nathan 用户添加到 readers 用户组: ``` sudo usermod -a -G readers nathan @@ -85,11 +85,11 @@ sudo usermod -a -G readers nathan sudo usermod -a -G editors olivia ``` -现在我们已经准备好用用户组来管理用户了。 +现在我们可以通过用户组来管理用户了。 ### 给用户组授予目录的权限 -假设你有个目录 ``/READERS``,允许 readers 用户组的所有成员访问这个目录。首先,我们执行以下命令来更改目录所属用户组: +假设你有个目录 ``/READERS`` 且允许 readers 用户组的所有成员访问这个目录。首先,我们执行以下命令来更改目录所属用户组: ``` sudo chown -R :readers /READERS @@ -101,7 +101,7 @@ sudo chown -R :readers /READERS sudo chmod -R g-w /READERS ``` -然后我们执行下面的命令来收回其他用户对这个目录的访问权限(以防止任何不在读者组中的用户访问这个目录里的文件): +然后我们执行下面的命令来收回其他用户对这个目录的访问权限(以防止任何不在 readers 组中的用户访问这个目录里的文件): ``` sudo chmod -R o-x /READERS @@ -126,7 +126,7 @@ sudo chmod -R o-x /EDITORS ### 使用访问控制表(ACL) -现在,让我们把这个问题变得棘手一点。假设你有一个目录 ``/DATA`` 并且你想给 readers 用户组的成员读取权限同时给 editors 用户组的成员读和写的权限。为此,你必须要用到 setfacl 命令。setfacl 命令可以为文件或文件夹设置一个访问控制表(ACL)。 +现在,让我们把这个问题变得棘手一点。假设你有一个目录 ``/DATA`` 并且你想给 readers 用户组的成员读取权限并同时给 editors 用户组的成员读和写的权限。为此,你必须要用到 setfacl 命令。setfacl 命令可以为文件或文件夹设置一个访问控制表(ACL)。 这个命令的结构如下: @@ -142,7 +142,7 @@ sudo setfacl -m g:readers:rx -R /DATA 现在 readers 用户组里面的每一个用户都可以读取 /DATA 目录里的文件了,但是他们不能修改里面的内容。 -为了给 editors 用户组里面的用户读写权限,我们执行了以下的命令: +为了给 editors 用户组里面的用户读写权限,我们执行了以下命令: ``` sudo setfacl -m g:editors:rwx -R /DATA @@ -151,7 +151,7 @@ sudo setfacl -m g:editors:rwx -R /DATA ### 更多的权限控制 -使用访问控制表(ACL),你可以实现你所需的权限控制。你可以实现将用户添加到用户组,并且可靠灵活地控制这些用户组对每个目录的权限以达到你的需求。想要了解上述工具的更多信息,可以执行下列的命令: +使用访问控制表(ACL),你可以实现你所需的权限控制。你可以添加用户到用户组,并且灵活地控制这些用户组对每个目录的权限以达到你的需求。如果想了解上述工具的更多信息,可以执行下列的命令: * man usradd From 05f95c0e67b3a3176a3c9b1008dccb3a8a00c205 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 5 Dec 2017 07:22:51 +0800 Subject: [PATCH 237/344] translating by aiwhj translating by aiwhj --- .../20171129 5 best practices for getting started with DevOps.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171129 5 best practices for getting started with DevOps.md b/sources/tech/20171129 5 best practices for getting started with DevOps.md index 962f37aaf4..7694180c14 100644 --- a/sources/tech/20171129 5 best practices for getting started with DevOps.md +++ b/sources/tech/20171129 5 best practices for getting started with DevOps.md @@ -1,3 +1,4 @@ +translating---aiwhj 5 best practices for getting started with DevOps ============================================================ From f4a223025abc1b3d13b99264dcd4c7e89ed7b156 Mon Sep 17 00:00:00 2001 From: Sihua Zheng Date: Tue, 5 Dec 2017 09:12:33 +0800 Subject: [PATCH 238/344] translated --- ...ilable on Flathub the Flatpak App Store.md | 73 ------------------- ...ilable on Flathub the Flatpak App Store.md | 70 ++++++++++++++++++ 2 files changed, 70 insertions(+), 73 deletions(-) delete mode 100644 sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md create mode 100644 translated/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md diff --git a/sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md b/sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md deleted file mode 100644 index fe72e37128..0000000000 --- a/sources/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md +++ /dev/null @@ -1,73 +0,0 @@ -translating---geekpi - - -# LibreOffice Is Now Available on Flathub, the Flatpak App Store - -![LibreOffice on Flathub](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/libroffice-on-flathub-750x250.jpeg) - -LibreOffice is now available to install from [Flathub][3], the centralised Flatpak app store. - -Its arrival allows anyone running a modern Linux distribution to install the latest stable release of LibreOffice in a click or two, without having to hunt down a PPA, tussle with tarballs or wait for a distro provider to package it up. - -A [LibreOffice Flatpak][5] has been available for users to download and install since August of last year and the [LibreOffice 5.2][6] release. - -What’s “new” here is the distribution method. Rather than release updates through their own dedicated server The Document Foundation has opted to use Flathub. - -This is  _great_  news for end users as it means there’s one less repo to worry about adding on a fresh install, but it’s also good news for Flatpak advocates too: LibreOffice is open-source software’s most popular productivity suite. Its support for both format and app store is sure to be warmly welcomed. - -At the time of writing you can install LibreOffice 5.4.2 from Flathub. New stable releases will be added as and when they’re released. - -### Enable Flathub on Ubuntu - -![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/flathub-750x495.png) - -Fedora, Arch, and Linux Mint 18.3 users have Flatpak installed, ready to go, out of the box. Mint even comes with the Flathub remote pre-enabled. - -[Install LibreOffice from Flathub][7] - -To get Flatpak up and running on Ubuntu you first have to install it: - -``` -sudo apt install flatpak gnome-software-plugin-flatpak -``` - -To be able to install apps from Flathub you need to add the Flathub remote server: - -``` -flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo -``` - -That’s pretty much it. Just log out and back in (so that Ubuntu Software refreshes its cache) and you  _should_  be able to find any Flatpak apps available on Flathub through the Ubuntu Software app. - -In this instance, search for “LibreOffice” and locate the result that has a line of text underneath mentioning Flathub. (Do bear in mind that Ubuntu has tweaked the Software client to shows Snap app results above everything else, so you may need scroll down the list of results to see it). - -There is a [bug with installing Flatpak apps][8] from a flatpakref file, so if the above method doesn’t work you can also install Flatpak apps form Flathub using the command line. - -The Flathub website lists the command needed to install each app. Switch to the “Command Line” tab to see them. - -#### More apps on Flathub - -If you read this site regularly enough you’ll know that I  _love_  Flathub. It’s home to some of my favourite apps (Corebird, Parlatype, GNOME MPV, Peek, Audacity, GIMP… etc). I get the latest, stable versions of these apps (plus any dependencies they need) without compromise. - -And, as I tweeted a week or so back, most Flatpak apps now look great with GTK themes — no more [workarounds][9]required! - --------------------------------------------------------------------------------- - -via: http://www.omgubuntu.co.uk/2017/11/libreoffice-now-available-flathub-flatpak-app-store - -作者:[ JOEY SNEDDON ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://plus.google.com/117485690627814051450/?rel=author -[1]:https://plus.google.com/117485690627814051450/?rel=author -[2]:http://www.omgubuntu.co.uk/category/news -[3]:http://www.flathub.org/ -[4]:http://www.omgubuntu.co.uk/2017/11/libreoffice-now-available-flathub-flatpak-app-store -[5]:http://www.omgubuntu.co.uk/2016/08/libreoffice-5-2-released-whats-new -[6]:http://www.omgubuntu.co.uk/2016/08/libreoffice-5-2-released-whats-new -[7]:https://flathub.org/repo/appstream/org.libreoffice.LibreOffice.flatpakref -[8]:https://bugs.launchpad.net/ubuntu/+source/gnome-software/+bug/1716409 -[9]:http://www.omgubuntu.co.uk/2017/05/flatpak-theme-issue-fix diff --git a/translated/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md b/translated/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md new file mode 100644 index 0000000000..4edb744098 --- /dev/null +++ b/translated/tech/20171121 LibreOffice Is Now Available on Flathub the Flatpak App Store.md @@ -0,0 +1,70 @@ +# LibreOffice 现在在 Flatpak 的 Flathub 应用商店提供 + +![LibreOffice on Flathub](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/libroffice-on-flathub-750x250.jpeg) + +LibreOffice 现在可以从集中化的 Flatpak 应用商店 [Flathub][3] 进行安装。 + +它的到来使任何运行现代 Linux 发行版的人都能只点击一两次安装 LibreOffice 的最新稳定版本,而无需搜索 PPA,纠缠 tar 包或等待发行商将其打包。 + +自去年 8 月份以来,[LibreOffice Flatpak][5] 已经可供用户下载和安装 [LibreOffice 5.2][6]。 + +这里“新”的是发行方法。文档基金会选择使用 Flathub 而不是专门的服务器来发布更新。 + +这对于终端用户来说是一个_很好_的消息,因为这意味着不需要在新安装时担心仓库,但对于 Flatpak 的倡议者来说也是一个好消息:LibreOffice 是开源软件最流行的生产力套件。它对格式和应用商店的支持肯定会受到热烈的欢迎。 + +在撰写本文时,你可以从 Flathub 安装 LibreOffice 5.4.2。新的稳定版本将在发布时添加。 + +### 在 Ubuntu 上启用 Flathub + +![](http://www.omgubuntu.co.uk/wp-content/uploads/2017/11/flathub-750x495.png) + +Fedora、Arch 和 Linux Mint 18.3 用户已经安装了 Flatpak,随时可以开箱即用。Mint 甚至预启用了 Flathub remote。 + +[从 Flathub 安装 LibreOffice][7] + +要在 Ubuntu 上启动并运行 Flatpak,首先必须安装它: + +``` +sudo apt install flatpak gnome-software-plugin-flatpak +``` + +为了能够从 Flathub 安装应用程序,你需要添加 Flathub 远程服务器: + +``` +flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +``` + +这就行了。只需注销并返回(以便 Ubuntu Software 刷新其缓存),之后你应该能够通过 Ubuntu Software 看到 Flathub 上的任何 Flatpak 程序了。 + +在本例中,搜索 “LibreOffice” 并在结果中找到下面有 Flathub 提示的结果。(请记住,Ubuntu 已经调整了客户端,来将 Snap 程序显示在最上面,所以你可能需要向下滚动列表来查看它)。 + +从 flatpakref 中[安装 Flatpak 程序有一个 bug][8],所以如果上面的方法不起作用,你也可以使用命令行从 Flathub 中安装 Flathub 程序。 + +Flathub 网站列出了安装每个程序所需的命令。切换到“命令行”选项卡来查看它们。 + +#### Flathub 上更多的应用 + +如果你经常看这个网站,你就会知道我喜欢 Flathub。这是我最喜欢的一些应用(Corebird、Parlatype、GNOME MPV、Peek、Audacity、GIMP 等)的家园。我无需折衷就能获得这些应用程序的最新,稳定版本(加上它们需要的所有依赖)。 + +而且,在我 twiiter 上发布一周左右后,大多数 Flatpak 应用现在看起来有很棒 GTK 主题 - 不再需要[临时方案][9]了! + +-------------------------------------------------------------------------------- + +via: http://www.omgubuntu.co.uk/2017/11/libreoffice-now-available-flathub-flatpak-app-store + +作者:[ JOEY SNEDDON ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://plus.google.com/117485690627814051450/?rel=author +[1]:https://plus.google.com/117485690627814051450/?rel=author +[2]:http://www.omgubuntu.co.uk/category/news +[3]:http://www.flathub.org/ +[4]:http://www.omgubuntu.co.uk/2017/11/libreoffice-now-available-flathub-flatpak-app-store +[5]:http://www.omgubuntu.co.uk/2016/08/libreoffice-5-2-released-whats-new +[6]:http://www.omgubuntu.co.uk/2016/08/libreoffice-5-2-released-whats-new +[7]:https://flathub.org/repo/appstream/org.libreoffice.LibreOffice.flatpakref +[8]:https://bugs.launchpad.net/ubuntu/+source/gnome-software/+bug/1716409 +[9]:http://www.omgubuntu.co.uk/2017/05/flatpak-theme-issue-fix From c600cfb37b2b05a5466c28e4f44632f121c1fada Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 5 Dec 2017 09:16:46 +0800 Subject: [PATCH 239/344] translating --- .../20171125 AWS to Help Build ONNX Open Source AI Platform.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md b/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md index c09d66bc57..1e9424178e 100644 --- a/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md +++ b/sources/tech/20171125 AWS to Help Build ONNX Open Source AI Platform.md @@ -1,3 +1,5 @@ +translating---geekpi + AWS to Help Build ONNX Open Source AI Platform ============================================================ ![onnx-open-source-ai-platform](https://www.linuxinsider.com/article_images/story_graphics_xlarge/xl-2017-onnx-1.jpg) From 06092620560a75c22c0289edc8badced8995d96e Mon Sep 17 00:00:00 2001 From: runningwater Date: Tue, 5 Dec 2017 09:32:57 +0800 Subject: [PATCH 240/344] Update 20171128 Why Python and Pygame are a great pair for beginning programmers.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译中 --- ...on and Pygame are a great pair for beginning programmers.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md b/sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md index 479bfb1232..9afdfbb2b1 100644 --- a/sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md +++ b/sources/tech/20171128 Why Python and Pygame are a great pair for beginning programmers.md @@ -1,3 +1,4 @@ +(translating by runningwater) Why Python and Pygame are a great pair for beginning programmers ============================================================ @@ -101,7 +102,7 @@ Despite my recommendation, I always suspect that kids soon move to JavaScript. A via: https://opensource.com/article/17/11/pygame 作者:[Craig Oda ][a] -译者:[译者ID](https://github.com/译者ID) +译者:[runningwater](https://github.com/runningwater) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 945cbd4020c60a13c7c7d8ad21ce39bdfc893db1 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 4 Dec 2017 23:22:15 +0800 Subject: [PATCH 241/344] take a break --- ... Your Linux Server Has Been Compromised.md | 78 ++++++++++--------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md b/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md index dd61ad7a95..a7af1098c7 100644 --- a/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md +++ b/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md @@ -1,28 +1,27 @@ -translating by lujun9972 -How To Tell If Your Linux Server Has Been Compromised +如何判断Linux服务器是否被入侵 -------------- -A server being compromised or hacked for the purpose of this guide is an unauthorized person or bot logging into the server in order to use it for their own, usually negative ends. +本指南中所谓的服务器被入侵或者说被黑了的意思是指未经认证的人或程序为了自己的目的登录到服务器上去并使用其计算资源, 通常会产生不好的影响. -Disclaimer: If your server has been compromised by a state organization like the NSA or a serious criminal group then you will not notice any problems and the following techniques will not register their presence. +免责声明: 若你的服务器被类似NSA这样的国家机关或者某个犯罪集团如请,那么你并不会发现有任何问题,这些技术也无法发觉他们的存在. -However, the majority of compromised servers are carried out by bots i.e. automated attack programs, in-experienced attackers e.g. “script kiddies”, or dumb criminals. +然而, 大多数被攻破的服务器都是被类似自动攻击程序这样的程序或者类似“脚本小子”这样的廉价攻击者,以及蠢蛋犯罪所入侵的. -These sorts of attackers will abuse the server for all it’s worth whilst they have access to it and take few precautions to hide what they are doing. +这类攻击者会在访问服务器的同时滥用服务器资源,并且不怎么会采取措施来隐藏他们正在做的事情. -### Symptoms of a compromised server +### 入侵服务器的症状 -When a server has been compromised by an in-experienced or automated attacker they will usually do something with it that consumes 100% of a resource. This resource will usually be either the CPU for something like crypt-currency mining or email spamming, or bandwidth for launching a DOS attack. +当服务器被没有经验攻击者或者自动攻击程序入侵了的话,他们往往会消耗100%的资源. 他们可能消耗CPU资源来进行数字货币的采矿或者发送垃圾邮件,也可能消耗带宽来发动 `DoS` 攻击. -This means that the first indication that something is amiss is that the server is “going slow”. This could manifest in the website serving pages much slower than usual, or email taking many minutes to deliver or send. +因此出现问题的第一个表现就是服务器 “变慢了”. 这可能表现在网站的页面打开的很慢, 或者电子邮件要花很长时间才能发送出去. -So what should you look for? +那么你应该查看那些东西呢? -### Check 1 - Who’s currently logged in? +#### 检查 1 - 当前都有谁在登录? -The first thing you should look for is who is currently logged into the server. It is not uncommon to find the attacker actually logged into the server and working on it. +你首先要查看当前都有谁登录在服务器上. 发现攻击者登录到服务器上进行操作并不罕见. -The shell command to do this is w. Running w gives the following output: +其对应的命令是 `w`. 运行 `w` 会输出如下结果: ``` 08:32:55 up 98 days, 5:43, 2 users, load average: 0.05, 0.03, 0.00 @@ -32,19 +31,19 @@ root pts/1 78.31.109.1 08:26 0.00s 0.01s 0.00s w ``` -One of those IP’s is a UK IP and the second is Vietnamese. That’s probably not a good thing. +第一个IP是英国IP,而第二个IP是越南IP. 这个不是个好兆头. -Stop and take a breath, don’t panic and simply kill their SSH connection. Unless you can stop then re-entering the server they will do so quickly and quite likely kick you off and stop you getting back in. +停下来做个深呼吸, 不要紧,只需要杀掉他们的SSH连接就好了. Unless you can stop then re-entering the server they will do so quickly and quite likely kick you off and stop you getting back in. -Please see the What should I do if I’ve been compromised section at the end of this guide no how to proceed if you do find evidence of compromise. +请参阅本文最后的 `入侵之后怎么办` 这一章节来看发现被入侵的证据后应该怎么办. -The whois command can be run on IP addresses and will tell you what all the information about the organization that the IP is registered to, including the country. +`whois` 命令可以接一个IP地址然后告诉你IP注册的组织的所有信息, 当然就包括所在国家的信息. -### Check 2 - Who has logged in? +#### 检查 2 - 谁曾经登录过? -Linux servers keep a record of which users logged in, from what IP, when and for how long. This information is accessed with the last command. +Linux 服务器会记录下哪些用户,从哪个IP,在什么时候登录的以及登陆了多长时间这些信息. 使用 `last` 命令可以查看这些信息. -The output looks like this: +输出类似这样: ``` root pts/1 78.31.109.1 Thu Nov 30 08:26 still logged in @@ -55,53 +54,56 @@ root pts/0 14.176.196.1 Mon Nov 27 13:32 - 13:53 (00:21) ``` -There is a mix of my UK IP’s and some Vietnamese ones, with the top two still logged in. If you see any IP’s that are not authorized then refer to the final section. +这里可以看到英国IP和越南IP交替出现, 而且最上面两个IP现在还处于登录状态. 如果你看到任何未经授权的IP,那么请参阅最后章节. -The login history is contained in a text file at ~/.bash_history and is therefore easily removable. Often, attackers will simply delete this file to try to cover their tracks. Consequently, if you run last and only see your current login, this is a Bad Sign. +登录历史记录会以文本格式记录到 `~/.bash_history`(注:这里作者应该写错了)中,因此很容易被删除. +通常攻击者会直接把这个文件删掉,以掩盖他们的攻击行为. 因此, 若你运行了 `last` 命令却只看得见你的当前登录,那么这就是个不妙的信号. -If there is no login history be very, very suspicious and continue looking for indications of compromise. +如果没有登录历史的话,请一定小心,继续留意入侵的其他线索. -### Check 3 - Review the command history +#### 检查 3 - 回顾命令历史 -This level of attacker will frequently take no precautions to leave no command history so running the history command will show you everything they have done. Be on the lookout for wget or curl commands to download out-of-repo software such as spam bots or crypto miners. +这个层次的攻击者通常不会注意掩盖命令的历史记录,因此运行 `history` 命令会显示出他们曾经做过的所有事情. +一定留意有没有用 `wget` 或 `curl` 命令来下载类似垃圾邮件机器人或者挖矿程序之类的软件. -The command history is contained in the ~/.bash_history file so some attackers will delete this file to cover what they have done. Just as with the login history, if you run history and don’t see anything then the history file has been deleted. Again this is a Bad Sign and you should review the server very carefully. +命令历史存储在 `~/.bash_history` 文件中,因此有些攻击者会删除该文件以掩盖他们的所作所为. +跟登录历史一样, 若你运行 `history` 命令却没有输出任何东西那就表示历史文件被删掉了. 这也是个不妙的信号,你需要很小心地检查一下服务器了. -### Check 4 - What’s using all the CPU? +#### 检查 4 - 哪些进程在消耗CPU? -The sorts of attackers that you will encounter usually don’t take too many precautions to hide what they are doing. So they will run processes that consume all the CPU. This generally makes it pretty easy to spot them. Simply run top and look at the highest process. +你常遇到的这类攻击者通常不怎么会去掩盖他们做的事情. 他们会运行一些特别消耗CPU的进程. 这就很容易发着这些进程了. 只需要运行 `top` 然后看最前的那几个进程就行了. -This will also show people exploiting your server without having logged in. This could be, for example, someone using an unprotected form-mail script to relay spam. +这也能显示出那些未登录的攻击者来. 比如,可能有人在用未受保护的邮件脚本来发送垃圾邮件. -If you don’t recognize the top process then either Google its name or investigate what it’s doing with losf or strace. +如果你最上面的进程对不了解,那么你可以google一下进程名称,或者通过 `losf` 和 `strace` 来看看它做的事情是什么. -To use these tools first copy its PID from top and run: +使用这些工具,第一步从 `top` 中拷贝出进程的 PID,然后运行: -``` +```shell strace -p PID ``` -This will display all the system calls the process is making. It’s a lot of information but looking through it will give you a good idea what’s going on. +这会显示出进程调用的所有系统调用. 它产生的内容会很多,但这些信息能告诉你这个进程在做什么. ``` lsof -p PID ``` -This program will list the open files that the process has. Again, this will give you a good idea what it’s doing by showing you what files it is accessing. +这个程序会列出进程打开的文件. 通过查看它访问的文件可以很好的理解它在做的事情. -### Check 5 - Review the all the system processes +#### Check 5 - Review the all the system processes If an unauthorized process is not consuming enough CPU to get listed noticeably on top it will still get displayed in a full process listing with ps. My proffered command is ps auxf for providing the most information clearly. -You should be looking for any processes that you don’t recognize. The more times you run ps on your servers (which is a good habit to get into) the more obvious an alien process will stand out. +You should be looking for any processes that you don’t recognize. The more times you run ps on your servers (which is a good habikkt to get into) the more obvious an alien process will stand out. -### Check 6 - Review network usage by process +#### Check 6 - Review network usage by process The command iftop functions like top to show a ranked list of processes that are sending and receiving network data along with their source and destination. A process like a DOS attack or spam bot will immediately show itself at the top of the list. -### Check 7 - What processes are listening for network connections? +#### Check 7 - What processes are listening for network connections? Often an attacker will install a program that doesn’t do anything except listen on the network port for instructions. This does not consume CPU or bandwidth whilst it is waiting so can get overlooked in the top type commands. From fbe498d3aa1b03e3881fcb3be891245fc2626866 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 4 Dec 2017 23:31:15 +0800 Subject: [PATCH 242/344] take a break --- ... Tell If Your Linux Server Has Been Compromised.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md b/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md index a7af1098c7..cfd60d4753 100644 --- a/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md +++ b/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md @@ -93,15 +93,16 @@ lsof -p PID 这个程序会列出进程打开的文件. 通过查看它访问的文件可以很好的理解它在做的事情. -#### Check 5 - Review the all the system processes +#### 检查 5 - 检查所有的系统进程 -If an unauthorized process is not consuming enough CPU to get listed noticeably on top it will still get displayed in a full process listing with ps. My proffered command is ps auxf for providing the most information clearly. +消耗CPU不严重的未认证进程可能不会在 `top` 中显露出来,不过它依然可以通过 `ps` 列出来. 命令 `ps auxf` 就能显示足够清晰的信息了。 -You should be looking for any processes that you don’t recognize. The more times you run ps on your servers (which is a good habikkt to get into) the more obvious an alien process will stand out. +你需要检查一下每个不认识的进程. 经常运行 `ps` (这是个好习惯) 能帮助你发现奇怪的进程. -#### Check 6 - Review network usage by process +#### 检查 6 - 检查进程的网络使用情况 -The command iftop functions like top to show a ranked list of processes that are sending and receiving network data along with their source and destination. A process like a DOS attack or spam bot will immediately show itself at the top of the list. +`iftop` 的功能类似 `top`,他会显示一系列收发网络数据的进程以及他们的源地址和目的地址. +类似 `DoS` 攻击或垃圾制造器这样的进程很容易显示在列表的最顶端. #### Check 7 - What processes are listening for network connections? From 7d33d921317637b7d070b78d290e82d81270f29d Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 5 Dec 2017 09:52:38 +0800 Subject: [PATCH 243/344] translated --- ... Your Linux Server Has Been Compromised.md | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md b/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md index cfd60d4753..f027d46292 100644 --- a/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md +++ b/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md @@ -104,11 +104,11 @@ lsof -p PID `iftop` 的功能类似 `top`,他会显示一系列收发网络数据的进程以及他们的源地址和目的地址. 类似 `DoS` 攻击或垃圾制造器这样的进程很容易显示在列表的最顶端. -#### Check 7 - What processes are listening for network connections? +#### 检查 7 - 哪些进程在监听网络连接? -Often an attacker will install a program that doesn’t do anything except listen on the network port for instructions. This does not consume CPU or bandwidth whilst it is waiting so can get overlooked in the top type commands. +通常攻击者会安装一个后门程序专门监听网络端口接受指令. 该进程等待期间是不会消耗CPU和带宽的,因此也就不容易通过 `top` 之类的命令发现. -The commands lsof and netstat will both list all networked processes. I use them with the following options: +`lsof` 和 `netstat` 命令都会列出所有的联网进程. 我通常会让他们带上下面这些参数: ``` lsof -i @@ -120,31 +120,35 @@ netstat -plunt ``` -You should look for any process that is listed as in the LISTEN or ESTABLISHED status as these processes are either waiting for a connection (LISTEN) or have a connection open (ESTABLISHED). If you don’t recognize these processes use strace or lsof to try to see what they are doing. +你需要留意那些处于 `LISTEN` 和 `ESTABLISHED` 状态的进程,这些进程要么正在等待连接(LISTEN),要么已经连接(ESTABLISHED). +如果遇到不认识的进程,使用 `strace` 和 `lsof` 来看看它们在做什么东西. -### What should I do if I’ve been compromised? +### 被入侵之后该怎么办呢? -The first thing to do is not to panic, especially if the attacker is currently logged in. You need to be able to take back control of the machine before the attacker is aware that you know about them. If they realize you know about them they may well lock you out of your server and start destroying any assets out of spite. +首先,不要紧张, 尤其当攻击者正处于登陆状态时更不能紧张. 你需要在攻击者警觉到你已经发现他之前夺回机器的控制权. +如果他发现你已经发觉到他了,那么他可能会锁死你不让你登陆服务器,然后开始毁尸灭迹. -If you are not very technical then simply shut down the server. Either from the server itself with shutdown -h now or systemctl poweroff. Or log into your hosting provider’s control panel and shut down the server. Once it’s powered off you can work on the needed firewall rules and consult with your provider in your own time. +如果你技术不太好那么就直接关机吧. 你可以在服务器上运行 `shutdown -h now` 或者 `systemctl poweroff` 这两条命令. 也可以登陆主机提供商的控制面板中关闭服务器. +关机后,你就可以开始配置防火墙或者咨询一下供应商的意见. -If you’re feeling a bit more confident and your hosting provider has an upstream firewall then create and enable the following two rules in this order: +如果你对自己颇有自信,而你的主机提供商也有提供上游防火墙,那么你只需要以此创建并启用下面两条规则就行了: -1. Allow SSH traffic from only your IP address. +1. 只允许从你的IP地址登陆SSH -2. Block everything else, not just SSH but every protocol on every port. +2. 封禁除此之外的任何东西,不仅仅是SSH,还包括任何端口上的任何协议. -This will immediately kill their SSH session and give only you access to the server. +这样会立即关闭攻击者的SSH会话,而只留下你访问服务器. -If you don’t have access to an upstream firewall then you will have to create and enable these firewall rules on the server itself and then, when they are in place kill the attacker’s ssh session with the kill command. +如果你无法访问上游防火墙,那么你就需要在服务器本身创建并启用这些防火墙策略,然后在防火墙规则起效后使用 `kill` 命令关闭攻击者的ssh会话. -A final method, where available, is to log into the server via an out-of-band connection such as the serial console and stop networking with systemctl stop network.service. This will completely stop any network access so you can now enable the firewall rules in your own time. +最后还有一种方法, 就是通过诸如串行控制台之类的带外连接登陆服务器,然后通过 `systemctl stop network.service` 停止网络功能. +这会关闭所有服务器上的网络连接,这样你就可以慢慢的配置那些防火墙规则了. -Once you have regained control of the server do not trust it. +重夺服务器的控制权后,也不要以为就万事大吉了. -Do not attempt to fix things up and continue using the server. You can never be sure what the attacker did and so you can never sure the server is secure. +不要试着修复这台服务器,让后接着用. 你永远不知道攻击者做过什么因此你也永远无法保证这台服务器还是安全的. -The only sensible course of action is to copy off all the data that you need and start again from a fresh install. +最好的方法就是拷贝出所有的资料,然后重装系统. -------------------------------------------------------------------------------- From fd99a177e1d55af9866961dfa44ab76cf2dca666 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 5 Dec 2017 09:53:22 +0800 Subject: [PATCH 244/344] change to translated --- ...71128 How To Tell If Your Linux Server Has Been Compromised.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources => translated}/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md (100%) diff --git a/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md b/translated/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md similarity index 100% rename from sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md rename to translated/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md From 76d717030288c4d77dec6fa2dcd9ede81a7b0f85 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 5 Dec 2017 11:06:08 +0800 Subject: [PATCH 245/344] reformat --- ... Your Linux Server Has Been Compromised.md | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/translated/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md b/translated/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md index f027d46292..29fe95d868 100644 --- a/translated/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md +++ b/translated/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md @@ -1,25 +1,25 @@ 如何判断Linux服务器是否被入侵 -------------- -本指南中所谓的服务器被入侵或者说被黑了的意思是指未经认证的人或程序为了自己的目的登录到服务器上去并使用其计算资源, 通常会产生不好的影响. +本指南中所谓的服务器被入侵或者说被黑了的意思是指未经认证的人或程序为了自己的目的登录到服务器上去并使用其计算资源, 通常会产生不好的影响。 -免责声明: 若你的服务器被类似NSA这样的国家机关或者某个犯罪集团如请,那么你并不会发现有任何问题,这些技术也无法发觉他们的存在. +免责声明: 若你的服务器被类似NSA这样的国家机关或者某个犯罪集团如请,那么你并不会发现有任何问题,这些技术也无法发觉他们的存在。 -然而, 大多数被攻破的服务器都是被类似自动攻击程序这样的程序或者类似“脚本小子”这样的廉价攻击者,以及蠢蛋犯罪所入侵的. +然而, 大多数被攻破的服务器都是被类似自动攻击程序这样的程序或者类似“脚本小子”这样的廉价攻击者,以及蠢蛋犯罪所入侵的。 -这类攻击者会在访问服务器的同时滥用服务器资源,并且不怎么会采取措施来隐藏他们正在做的事情. +这类攻击者会在访问服务器的同时滥用服务器资源,并且不怎么会采取措施来隐藏他们正在做的事情。 ### 入侵服务器的症状 -当服务器被没有经验攻击者或者自动攻击程序入侵了的话,他们往往会消耗100%的资源. 他们可能消耗CPU资源来进行数字货币的采矿或者发送垃圾邮件,也可能消耗带宽来发动 `DoS` 攻击. +当服务器被没有经验攻击者或者自动攻击程序入侵了的话,他们往往会消耗100%的资源. 他们可能消耗CPU资源来进行数字货币的采矿或者发送垃圾邮件,也可能消耗带宽来发动 `DoS` 攻击。 -因此出现问题的第一个表现就是服务器 “变慢了”. 这可能表现在网站的页面打开的很慢, 或者电子邮件要花很长时间才能发送出去. +因此出现问题的第一个表现就是服务器 “变慢了”. 这可能表现在网站的页面打开的很慢, 或者电子邮件要花很长时间才能发送出去。 那么你应该查看那些东西呢? #### 检查 1 - 当前都有谁在登录? -你首先要查看当前都有谁登录在服务器上. 发现攻击者登录到服务器上进行操作并不罕见. +你首先要查看当前都有谁登录在服务器上. 发现攻击者登录到服务器上进行操作并不罕见。 其对应的命令是 `w`. 运行 `w` 会输出如下结果: @@ -31,17 +31,17 @@ root pts/1 78.31.109.1 08:26 0.00s 0.01s 0.00s w ``` -第一个IP是英国IP,而第二个IP是越南IP. 这个不是个好兆头. +第一个IP是英国IP,而第二个IP是越南IP. 这个不是个好兆头。 -停下来做个深呼吸, 不要紧,只需要杀掉他们的SSH连接就好了. Unless you can stop then re-entering the server they will do so quickly and quite likely kick you off and stop you getting back in. +停下来做个深呼吸, 不要紧,只需要杀掉他们的SSH连接就好了. Unless you can stop then re-entering the server they will do so quickly and quite likely kick you off and stop you getting back in。 -请参阅本文最后的 `入侵之后怎么办` 这一章节来看发现被入侵的证据后应该怎么办. +请参阅本文最后的 `入侵之后怎么办` 这一章节来看发现被入侵的证据后应该怎么办。 -`whois` 命令可以接一个IP地址然后告诉你IP注册的组织的所有信息, 当然就包括所在国家的信息. +`whois` 命令可以接一个IP地址然后告诉你IP注册的组织的所有信息, 当然就包括所在国家的信息。 #### 检查 2 - 谁曾经登录过? -Linux 服务器会记录下哪些用户,从哪个IP,在什么时候登录的以及登陆了多长时间这些信息. 使用 `last` 命令可以查看这些信息. +Linux 服务器会记录下哪些用户,从哪个IP,在什么时候登录的以及登陆了多长时间这些信息. 使用 `last` 命令可以查看这些信息。 输出类似这样: @@ -54,28 +54,28 @@ root pts/0 14.176.196.1 Mon Nov 27 13:32 - 13:53 (00:21) ``` -这里可以看到英国IP和越南IP交替出现, 而且最上面两个IP现在还处于登录状态. 如果你看到任何未经授权的IP,那么请参阅最后章节. +这里可以看到英国IP和越南IP交替出现, 而且最上面两个IP现在还处于登录状态. 如果你看到任何未经授权的IP,那么请参阅最后章节。 -登录历史记录会以文本格式记录到 `~/.bash_history`(注:这里作者应该写错了)中,因此很容易被删除. -通常攻击者会直接把这个文件删掉,以掩盖他们的攻击行为. 因此, 若你运行了 `last` 命令却只看得见你的当前登录,那么这就是个不妙的信号. +登录历史记录会以文本格式记录到 `~/.bash_history`(注:这里作者应该写错了)中,因此很容易被删除。 +通常攻击者会直接把这个文件删掉,以掩盖他们的攻击行为. 因此, 若你运行了 `last` 命令却只看得见你的当前登录,那么这就是个不妙的信号。 -如果没有登录历史的话,请一定小心,继续留意入侵的其他线索. +如果没有登录历史的话,请一定小心,继续留意入侵的其他线索。 #### 检查 3 - 回顾命令历史 -这个层次的攻击者通常不会注意掩盖命令的历史记录,因此运行 `history` 命令会显示出他们曾经做过的所有事情. -一定留意有没有用 `wget` 或 `curl` 命令来下载类似垃圾邮件机器人或者挖矿程序之类的软件. +这个层次的攻击者通常不会注意掩盖命令的历史记录,因此运行 `history` 命令会显示出他们曾经做过的所有事情。 +一定留意有没有用 `wget` 或 `curl` 命令来下载类似垃圾邮件机器人或者挖矿程序之类的软件。 -命令历史存储在 `~/.bash_history` 文件中,因此有些攻击者会删除该文件以掩盖他们的所作所为. -跟登录历史一样, 若你运行 `history` 命令却没有输出任何东西那就表示历史文件被删掉了. 这也是个不妙的信号,你需要很小心地检查一下服务器了. +命令历史存储在 `~/.bash_history` 文件中,因此有些攻击者会删除该文件以掩盖他们的所作所为。 +跟登录历史一样, 若你运行 `history` 命令却没有输出任何东西那就表示历史文件被删掉了. 这也是个不妙的信号,你需要很小心地检查一下服务器了。 #### 检查 4 - 哪些进程在消耗CPU? -你常遇到的这类攻击者通常不怎么会去掩盖他们做的事情. 他们会运行一些特别消耗CPU的进程. 这就很容易发着这些进程了. 只需要运行 `top` 然后看最前的那几个进程就行了. +你常遇到的这类攻击者通常不怎么会去掩盖他们做的事情. 他们会运行一些特别消耗CPU的进程. 这就很容易发着这些进程了. 只需要运行 `top` 然后看最前的那几个进程就行了。 -这也能显示出那些未登录的攻击者来. 比如,可能有人在用未受保护的邮件脚本来发送垃圾邮件. +这也能显示出那些未登录的攻击者来. 比如,可能有人在用未受保护的邮件脚本来发送垃圾邮件。 -如果你最上面的进程对不了解,那么你可以google一下进程名称,或者通过 `losf` 和 `strace` 来看看它做的事情是什么. +如果你最上面的进程对不了解,那么你可以google一下进程名称,或者通过 `losf` 和 `strace` 来看看它做的事情是什么。 使用这些工具,第一步从 `top` 中拷贝出进程的 PID,然后运行: @@ -84,29 +84,29 @@ strace -p PID ``` -这会显示出进程调用的所有系统调用. 它产生的内容会很多,但这些信息能告诉你这个进程在做什么. +这会显示出进程调用的所有系统调用. 它产生的内容会很多,但这些信息能告诉你这个进程在做什么。 ``` lsof -p PID ``` -这个程序会列出进程打开的文件. 通过查看它访问的文件可以很好的理解它在做的事情. +这个程序会列出进程打开的文件. 通过查看它访问的文件可以很好的理解它在做的事情。 #### 检查 5 - 检查所有的系统进程 消耗CPU不严重的未认证进程可能不会在 `top` 中显露出来,不过它依然可以通过 `ps` 列出来. 命令 `ps auxf` 就能显示足够清晰的信息了。 -你需要检查一下每个不认识的进程. 经常运行 `ps` (这是个好习惯) 能帮助你发现奇怪的进程. +你需要检查一下每个不认识的进程. 经常运行 `ps` (这是个好习惯) 能帮助你发现奇怪的进程。 #### 检查 6 - 检查进程的网络使用情况 -`iftop` 的功能类似 `top`,他会显示一系列收发网络数据的进程以及他们的源地址和目的地址. -类似 `DoS` 攻击或垃圾制造器这样的进程很容易显示在列表的最顶端. +`iftop` 的功能类似 `top`,他会显示一系列收发网络数据的进程以及他们的源地址和目的地址。 +类似 `DoS` 攻击或垃圾制造器这样的进程很容易显示在列表的最顶端。 #### 检查 7 - 哪些进程在监听网络连接? -通常攻击者会安装一个后门程序专门监听网络端口接受指令. 该进程等待期间是不会消耗CPU和带宽的,因此也就不容易通过 `top` 之类的命令发现. +通常攻击者会安装一个后门程序专门监听网络端口接受指令. 该进程等待期间是不会消耗CPU和带宽的,因此也就不容易通过 `top` 之类的命令发现。 `lsof` 和 `netstat` 命令都会列出所有的联网进程. 我通常会让他们带上下面这些参数: @@ -120,35 +120,35 @@ netstat -plunt ``` -你需要留意那些处于 `LISTEN` 和 `ESTABLISHED` 状态的进程,这些进程要么正在等待连接(LISTEN),要么已经连接(ESTABLISHED). -如果遇到不认识的进程,使用 `strace` 和 `lsof` 来看看它们在做什么东西. +你需要留意那些处于 `LISTEN` 和 `ESTABLISHED` 状态的进程,这些进程要么正在等待连接(LISTEN),要么已经连接(ESTABLISHED)。 +如果遇到不认识的进程,使用 `strace` 和 `lsof` 来看看它们在做什么东西。 ### 被入侵之后该怎么办呢? -首先,不要紧张, 尤其当攻击者正处于登陆状态时更不能紧张. 你需要在攻击者警觉到你已经发现他之前夺回机器的控制权. -如果他发现你已经发觉到他了,那么他可能会锁死你不让你登陆服务器,然后开始毁尸灭迹. +首先,不要紧张, 尤其当攻击者正处于登陆状态时更不能紧张. 你需要在攻击者警觉到你已经发现他之前夺回机器的控制权。 +如果他发现你已经发觉到他了,那么他可能会锁死你不让你登陆服务器,然后开始毁尸灭迹。 -如果你技术不太好那么就直接关机吧. 你可以在服务器上运行 `shutdown -h now` 或者 `systemctl poweroff` 这两条命令. 也可以登陆主机提供商的控制面板中关闭服务器. -关机后,你就可以开始配置防火墙或者咨询一下供应商的意见. +如果你技术不太好那么就直接关机吧. 你可以在服务器上运行 `shutdown -h now` 或者 `systemctl poweroff` 这两条命令. 也可以登陆主机提供商的控制面板中关闭服务器。 +关机后,你就可以开始配置防火墙或者咨询一下供应商的意见。 如果你对自己颇有自信,而你的主机提供商也有提供上游防火墙,那么你只需要以此创建并启用下面两条规则就行了: 1. 只允许从你的IP地址登陆SSH -2. 封禁除此之外的任何东西,不仅仅是SSH,还包括任何端口上的任何协议. +2. 封禁除此之外的任何东西,不仅仅是SSH,还包括任何端口上的任何协议。 -这样会立即关闭攻击者的SSH会话,而只留下你访问服务器. +这样会立即关闭攻击者的SSH会话,而只留下你访问服务器。 -如果你无法访问上游防火墙,那么你就需要在服务器本身创建并启用这些防火墙策略,然后在防火墙规则起效后使用 `kill` 命令关闭攻击者的ssh会话. +如果你无法访问上游防火墙,那么你就需要在服务器本身创建并启用这些防火墙策略,然后在防火墙规则起效后使用 `kill` 命令关闭攻击者的ssh会话。 -最后还有一种方法, 就是通过诸如串行控制台之类的带外连接登陆服务器,然后通过 `systemctl stop network.service` 停止网络功能. -这会关闭所有服务器上的网络连接,这样你就可以慢慢的配置那些防火墙规则了. +最后还有一种方法, 就是通过诸如串行控制台之类的带外连接登陆服务器,然后通过 `systemctl stop network.service` 停止网络功能。 +这会关闭所有服务器上的网络连接,这样你就可以慢慢的配置那些防火墙规则了。 -重夺服务器的控制权后,也不要以为就万事大吉了. +重夺服务器的控制权后,也不要以为就万事大吉了。 -不要试着修复这台服务器,让后接着用. 你永远不知道攻击者做过什么因此你也永远无法保证这台服务器还是安全的. +不要试着修复这台服务器,让后接着用. 你永远不知道攻击者做过什么因此你也永远无法保证这台服务器还是安全的。 -最好的方法就是拷贝出所有的资料,然后重装系统. +最好的方法就是拷贝出所有的资料,然后重装系统。 -------------------------------------------------------------------------------- From 3b22bdfdf8077159865a73b683f15f68e6daac9f Mon Sep 17 00:00:00 2001 From: Valonia Kim <34000495+Valoniakim@users.noreply.github.com> Date: Mon, 4 Dec 2017 15:55:46 +0800 Subject: [PATCH 246/344] Delete 20171118 Language engineering for great justice.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除源文件 --- ... Language engineering for great justice.md | 60 ------------------- 1 file changed, 60 deletions(-) delete mode 100644 sources/tech/20171118 Language engineering for great justice.md diff --git a/sources/tech/20171118 Language engineering for great justice.md b/sources/tech/20171118 Language engineering for great justice.md deleted file mode 100644 index 35d9bd854f..0000000000 --- a/sources/tech/20171118 Language engineering for great justice.md +++ /dev/null @@ -1,60 +0,0 @@ -Translating by ValoniaKim -Language engineering for great justice -============================================================ - -Whole-systems engineering, when you get good at it, goes beyond being entirely or even mostly about technical optimizations. Every artifact we make is situated in a context of human action that widens out to the economics of its use, the sociology of its users, and the entirety of what Austrian economists call “praxeology”, the science of purposeful human behavior in its widest scope. - -This isn’t just abstract theory for me. When I wrote my papers on open-source development, they were exactly praxeology – they weren’t about any specific software technology or objective but about the context of human action within which technology is worked. An increase in praxeological understanding of technology can reframe it, leading to tremendous increases in human productivity and satisfaction, not so much because of changes in our tools but because of changes in the way we grasp them. - -In this, the third of my unplanned series of posts about the twilight of C and the huge changes coming as we actually begin to see forward into a new era of systems programming, I’m going to try to cash that general insight out into some more specific and generative ideas about the design of computer languages, why they succeed, and why they fail. - -In my last post I noted that every computer language is an embodiment of a relative-value claim, an assertion about the optimal tradeoff between spending machine resources and spending programmer time, all of this in a context where the cost of computing power steadily falls over time while programmer-time costs remain relatively stable or may even rise. I also highlighted the additional role of transition costs in pinning old tradeoff assertions into place. I described what language designers do as seeking a new optimum for present and near-future conditions. - -Now I’m going to focus on that last concept. A language designer has lots of possible moves in language-design space from where the state of the art is now. What kind of type system? GC or manual allocation? What mix of imperative, functional, or OO approaches? But in praxeological terms his choice is, I think, usually much simpler: attack a near problem or a far problem? - -“Near” and “far” are measured along the curves of falling hardware costs, rising software complexity, and increasing transition costs from existing languages. A near problem is one the designer can see right in front of him; a far problem is a set of conditions that can be seen coming but won’t necessarily arrive for some time. A near solution can be deployed immediately, to great practical effect, but may age badly as conditions change. A far solution is a bold bet that may smother under the weight of its own overhead before its future arrives, or never be adopted at all because moving to it is too expensive. - -Back at the dawn of computing, FORTRAN was a near-problem design, LISP a far-problem one. Assemblers are near solutions. Illustrating that the categories apply to non-general-purpose languages, also roff markup. Later in the game, PHP and Javascript. Far solutions? Oberon. Ocaml. ML. XML-Docbook. Academic languages tend to be far because the incentive structure around them rewards originality and intellectual boldness (note that this is a praxeological cause, not a technical one!). The failure mode of academic languages is predictable; high inward transition costs, nobody goes there, failure to achieve community critical mass sufficient for mainstream adoption, isolation, and stagnation. (That’s a potted history of LISP in one sentence, and I say that as an old LISP-head with a deep love for the language…) - -The failure modes of near designs are uglier. The best outcome to hope for is a graceful death and transition to a newer design. If they hang on (most likely to happen when transition costs out are high) features often get piled on them to keep them relevant, increasing complexity until they become teetering piles of cruft. Yes, C++, I’m looking at you. You too, Javascript. And (alas) Perl, though Larry Wall’s good taste mitigated the problem for many years – but that same good taste eventually moved him to blow up the whole thing for Perl 6. - -This way of thinking about language design encourages reframing the designer’s task in terms of two objectives. (1) Picking a sweet spot on the near-far axis away from you into the projected future; and (2) Minimizing inward transition costs from one or more existing languages so you co-opt their userbases. And now let’s talk about about how C took over the world. - -There is no more more breathtaking example than C than of nailing the near-far sweet spot in the entire history of computing. All I need to do to prove this is point at its extreme longevity as a practical, mainstream language that successfully saw off many competitors for its roles over much of its range. That timespan has now passed about 35 years (counting from when it swamped its early competitors) and is not yet with certainty ended. - -OK, you can attribute some of C’s persistence to inertia if you want, but what are you really adding to the explanation if you use the word “inertia”? What it means is exactly that nobody made an offer that actually covered the transition costs out of the language! - -Conversely, an underappreciated strength of the language was the low inward transition costs. C is an almost uniquely protean tool that, even at the beginning of its long reign, could readily accommodate programming habits acquired from languages as diverse as FORTRAN, Pascal, assemblers and LISP. I noticed back in the 1980s that I could often spot a new C programmer’s last language by his coding style, which was just the flip side of saying that C was damn good at gathering all those tribes unto itself. - -C++ also benefited from having low transition costs in. Later, most new languages at least partly copied C syntax in order to minimize them.Notice what this does to the context of future language designs: it raises the value of being a C-like as possible in order to minimize inward transition costs from anywhere. - -Another way to minimize inward transition costs is to simply be ridiculously easy to learn, even to people with no prior programming experience. This, however, is remarkably hard to pull off. I evaluate that only one language – Python – has made the major leagues by relying on this quality. I mention it only in passing because it’s not a strategy I expect to see a  _systems_  language execute successfully, though I’d be delighted to be wrong about that. - -So here we are in late 2017, and…the next part is going to sound to some easily-annoyed people like Go advocacy, but it isn’t. Go, itself, could turn out to fail in several easily imaginable ways. It’s troubling that the Go team is so impervious to some changes their user community is near-unanimously and rightly (I think) insisting it needs. Worst-case GC latency, or the throughput sacrifices made to lower it, could still turn out to drastically narrow the language’s application range. - -That said, there is a grand strategy expressed in the Go design that I think is right. To understand it, we need to review what the near problem for a C replacement is. As I noted in the prequels, it is rising defect rates as systems projects scale up – and specifically memory-management bugs because that category so dominates crash bugs and security exploits. - -We’ve now identified two really powerful imperatives for a C replacement: (1) solve the memory-management problem, and (2) minimize inward-transition costs from C. And the history – the praxeological context – of programming languages tells us that if a C successor candidate don’t address the transition-cost problem effectively enough, it almost doesn’t matter how good a job it does on anything else. Conversely, a C successor that  _does_  address transition costs well buys itself a lot of slack for not being perfect in other ways. - -This is what Go does. It’s not a theoretical jewel; it has annoying limitations; GC latency presently limits how far down the stack it can be pushed. But what it is doing is replicating the Unix/C infective strategy of being easy-entry and  _good enough_  to propagate faster than alternatives that, if it didn’t exist, would look like better far bets. - -Of course, the proboscid in the room when I say that is Rust. Which is, in fact, positioning itself as the better far bet. I’ve explained in previous installments why I don’t think it’s really ready to compete yet. The TIOBE and PYPL indices agree; it’s never made the TIOBE top 20 and on both indices does quite poorly against Go. - -Where Rust will be in five years is a different question, of course. My advice to the Rust community, if they care, is to pay some serious attention to the transition-cost problem. My personal experience says the C to Rust energy barrier is  _[nasty][2]_ . Code-lifting tools like Corrode won’t solve it if all they do is map C to unsafe Rust, and if there were an easy way to automate ownership/lifetime annotations they wouldn’t be needed at all – the compiler would just do that for you. I don’t know what a solution would look like, here, but I think they better find one. - -I will finally note that Ken Thompson has a history of designs that look like minimal solutions to near problems but turn out to have an amazing quality of openness to the future, the capability to  _be improved_ . Unix is like this, of course. It makes me very cautious about supposing that any of the obvious annoyances in Go that look like future-blockers to me (like, say, the lack of generics) actually are. Because for that to be true, I’d have to be smarter than Ken, which is not an easy thing to believe. - --------------------------------------------------------------------------------- - -via: http://esr.ibiblio.org/?p=7745 - -作者:[Eric Raymond ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://esr.ibiblio.org/?author=2 -[1]:http://esr.ibiblio.org/?author=2 -[2]:http://esr.ibiblio.org/?p=7711&cpage=1#comment-1913931 -[3]:http://esr.ibiblio.org/?p=7745 From 7dcccf46774a40fb98c5e7486f350deefba98722 Mon Sep 17 00:00:00 2001 From: Valonia Kim <34000495+Valoniakim@users.noreply.github.com> Date: Mon, 4 Dec 2017 16:02:20 +0800 Subject: [PATCH 247/344] Create Language engineering for great justice Translated by ValoniaK --- .../Language engineering for great justice | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 translated/tech/Language engineering for great justice diff --git a/translated/tech/Language engineering for great justice b/translated/tech/Language engineering for great justice new file mode 100644 index 0000000000..d26f9319bd --- /dev/null +++ b/translated/tech/Language engineering for great justice @@ -0,0 +1,24 @@ +最合理的语言工程模式 +当你熟练掌握一体化工程技术时,你就会发现它逐渐超过了技术优化的层面。我们制作的每件手工艺品都在一个大环境背景下,在这个环境中,人类的行为逐渐突破了经济意义,社会学意义,达到了奥地利经济学家所称的“人类行为学”,这是目的明确的人类行为所能达到的最大范围。 +对我来说这并不只是抽象理论。当我在开源发展项目中编写时,我的行为就十分符合人类行为学的理论,这行为不是针对任何特定的软件技术或某个客观事物,它指的是在开发科技的过程中人类行为的背景环境。从人类行为学角度对科技进行的解读不断增加,大量的这种解读可以重塑科技框架,带来人类生产力和满足感的极大幅度增长,而这并不是由于我们换了工具,而是在于我们改变了掌握它们的方式。 +在这个背景下,我在第三篇额外的文章中谈到了 C 语言的衰退和正在到来的巨大改变,而我们也确实能够感受到系统编程的新时代的到来,在这个时刻,我决定把我之前有的大体的预感具象化为更加具体的,更实用的点子,它们主要是关于计算机语言设计的分析,例如为什么他们会成功,或为什么他们会失败。 +在我最近的一篇文章中,我写道:所有计算机语言都是对机器资源的成本和程序员工作成本的相对权衡的结果,和对其相对价值的体现。这些都是在一个计算能力成本不断下降但程序员工作成本不减反增的背景下产生的。我还强调了转化成本在使原有交易主张适用于当下环境中的新增角色。在文中我将编程人员描述为一个寻找今后最适方案的探索者。 +现在我要讲一讲最后一点。以现有水平为起点,一个语言工程师有极大可能通过多种方式推动语言设计的发展。通过什么系统呢? GC 还是人工分配?使用何种配置,命令式语言,函数程式语言或是面向对象语言?但是从人类行为学的角度来说,我认为它的形式会更简洁,也许只是选择解决长期问题还是短期问题? +所谓的“远”“近”之分,是指硬件成本的逐渐降低,软件复杂程度的上升和由现有语言向其他语言转化的成本的增加,根据它们的变化曲线所做出的判断。短期问题指编程人员眼下发现的问题,长期问题指可预见的一系列情况,但它们一段时间内不会到来。针对近期问题所做出的部署需要非常及时且有效,但随着情况的变化,短期解决方案有可能很快就不适用了。而长期的解决方案可能因其过于超前而夭折,或因其代价过高无法被接受。 +在计算机刚刚面世的时候, FORTRAN 是近期亟待解决的问题, LISP 是远期问题。汇编语言是短期解决方案,图解说明非通用语言的分类应用,还有关门电阻不断上涨的成本。随着计算机技术的发展,PHP 和 Javascript逐渐应用于游戏中。至于长期的解决方案? Oberon , Ocaml , ML , XML-Docbook 都可以。 他们形成的激励机制带来了大量具有突破性和原创性的想法,事态蓬勃但未形成体系,那个时候距离专业语言的面世还很远,(值得注意的是这些想法的出现都是人类行为学中的因果,并非由于某种技术)。专业语言会失败,这是显而易见的,它的转入成本高昂,让大部分人望而却步,因此不能没能达到能够让主流群体接受的水平,被孤立,被搁置。这也是 LISP 不为人知的的过去,作为前 LISP 管理层人员,出于对它深深的爱,我为你们讲述了这段历史。 +如果短期解决方案出现故障,它的后果更加惨不忍睹,最好的结果是期待一个相对体面的失败,好转换到另一个设计方案。(通常在转化成本较高时)如果他们执意继续,通常造成众多方案相互之间藕断丝连,形成一个不断扩张的复合体,一直维持到不能运转下去,变成一堆摇摇欲坠的杂物。是的,我说的就是 C++ 语言,还有 Java 描述语言,(唉)还有 Perl,虽然 Larry Wall 的好品味成功地让他维持了很多年,问题一直没有爆发,但在 Perl 6 发行时,他的好品味最终引爆了整个问题。 +这种思考角度激励了编程人员向着两个不同的目的重新塑造语言设计: ①以远近为轴,在自身和预计的未来之间选取一个最适点,然后 ②降低由一种或多种语言转化为自身语言的转入成本,这样你就可以吸纳他们的用户群。接下来我会讲讲 C 语言是怎样占领全世界的。 +在整个计算机发展史中,没有谁能比 C 语言完美地把握最适点的选取了,我要做的只是证明这一点,作为一种实用的主流语言, C 语言有着更长的寿命,它目睹了无数个竞争者的兴衰,但它的地位仍旧不可取代。从淘汰它的第一个竞争者到现在已经过了 35 年,但看起来C语言的终结仍旧不会到来。 +当然,如果你愿意的话,可以把 C 语言的持久存在归功于人类的文化惰性,但那是对“文化惰性”这个词的曲解, C 语言一直得以延续的真正原因是没有人提供足够的转化费用! +相反的, C 语言低廉的内部转化费用未得到应有的重视,C 语言是如此的千变万化,从它漫长统治时期的初期开始,它就可以适用于多种语言如 FORTRAN , Pascal , 汇编语言和 LISP 的编程习惯。在二十世纪八十年代我就注意到,我可以根据编程人员的编码风格判断出他的母语是什么,这也从另一方面证明了C 语言的魅力能够吸引全世界的人使用它。 +C++ 语言同样胜在它低廉的转化费用。很快,大部分新兴的语言为了降低自身转化费用,纷纷参考 C 语言语法。请注意这给未来的语言设计环境带来了什么影响:它尽可能地提高了 C-like 语言的价值,以此来降低其他语言转化为 C 语言的转化成本。 +另一种降低转入成本的方法十分简单,即使没接触过编程的人都能学会,但这种方法很难完成。我认为唯一使用了这种方法的 Python就是靠这种方法进入了职业比赛。对这个方法我一带而过,是因为它并不是我希望看到的,顺利执行的系统语言战略,虽然我很希望它不是那样的。 +今天我们在2017年年底聚集在这里,下一项我们应该为某些暴躁的团体发声,如 Go 团队,但事实并非如此。 Go 这个项目漏洞百出,我甚至可以想象出它失败的各种可能,Go 团队太过固执独断,即使几乎整个用户群体都认为 Go 需要做出改变了,Go 团队也无动于衷,这是个大问题。 一旦发生故障, GC 发生延迟或者用牺牲生产量来弥补延迟,但无论如何,它都会严重影响到这种语言的应用,大幅缩小这种语言的适用范围。 +即便如此,在 Go 的设计中,还是有一个我颇为认同的远大战略目标,想要理解这个目标,我们需要回想一下如果想要取代 C 语言,要面临的短期问题是什么。同我之前提到的,随着项目计划的不断扩张,故障率也在持续上升,这其中内存管理方面的故障尤其多,而内存管理一直是崩溃漏洞和安全漏洞的高发领域。 +我们现在已经知道了两件十分中重要的紧急任务,要想取代 C 语言,首先要先做到这两点:(1)解决内存管理问题;(2)降低由 C 语言向本语言转化时所需的转入成本。纵观编程语言的历史——从人类行为学的角度来看,作为 C 语言的准替代者,如果不能有效解决转入成本过高这个问题,那他们所做的其他部分做得再好都不算数。相反的,如果他们把转入成本过高这个问题解决地很好,即使他们其他部分做的不是最好的,人们也不会对他们吹毛求疵。 +这正是 Go 的做法,但这个理论并不是完美无瑕的,它也有局限性。目前 GC 延迟限制了它的发展,但 Go 现在选择照搬 Unix 下 C 语言的传染战略,让自身语言变成易于转入,便于传播的语言,其繁殖速度甚至快于替代品。但从长远角度看,这并不是个好办法。 +当然, Rust 语言的不足是个十分明显的问题,我们不应当回避它。而它,正将自己定位为适用于长远计划的选择。在之前的部分中我已经谈到了为什么我觉得它还不完美,Rust 语言在 TIBOE 和PYPL 指数上的成就也证明了我的说法,在 TIBOE 上 Rust 从来没有进过前20名,在 PYPL 指数上它的成就也比 Go 差很多。 +五年后 Rust 能发展的怎样还是个问题,如果他们愿意改变,我建议他们重视转入成本问题。以我个人经历来说,由 C 语言转入 Rust 语言的能量壁垒使人望而却步。如果编码提升工具比如 Corrode 只能把 C 语言映射为不稳定的 Rust 语言,但不能解决能量壁垒的问题;或者如果有更简单的方法能够自动注释所有权或试用期,人们也不再需要它们了——这些问题编译器就能够解决。目前我不知道怎样解决这个问题,但我觉得他们最好找出解决方案。 +在最后我想强调一下,虽然在 Ken Thompson 的设计经历中,他看起来很少解决短期问题,但他对未来有着极大的包容性,并且这种包容性还在不断提升。当然 Unix 也是这样的, 它让我不禁暗自揣测,让我认为 Go 语言中令人不快的地方都其实是他们未来事业的基石(例如缺乏泛型)。如果要确认这件事是真假,我需要比 Ken 还要聪明,但这并不是一件容易让人相信的事情。 + + From cd6d66fe6f58d5adcba7341a874dc048e04daab6 Mon Sep 17 00:00:00 2001 From: Valonia Kim <34000495+Valoniakim@users.noreply.github.com> Date: Mon, 4 Dec 2017 19:09:44 +0800 Subject: [PATCH 248/344] Language engineering for great justice. Translated by Valoniakim --- .../Language engineering for great justice. | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 translated/tech/Language engineering for great justice. diff --git a/translated/tech/Language engineering for great justice. b/translated/tech/Language engineering for great justice. new file mode 100644 index 0000000000..7f982e0d19 --- /dev/null +++ b/translated/tech/Language engineering for great justice. @@ -0,0 +1,24 @@ +# 最合理的语言工程模式 +## 当你熟练掌握一体化工程技术时,你就会发现它逐渐超过了技术优化的层面。我们制作的每件手工艺品都在一个大环境背景下,在这个环境中,人类的行为逐渐突破了经济意义,社会学意义,达到了奥地利经济学家所称的“人类行为学”,这是目的明确的人类行为所能达到的最大范围。 +## 对我来说这并不只是抽象理论。当我在开源发展项目中编写时,我的行为就十分符合人类行为学的理论,这行为不是针对任何特定的软件技术或某个客观事物,它指的是在开发科技的过程中人类行为的背景环境。从人类行为学角度对科技进行的解读不断增加,大量的这种解读可以重塑科技框架,带来人类生产力和满足感的极大幅度增长,而这并不是由于我们换了工具,而是在于我们改变了掌握它们的方式。 +## 在这个背景下,我在第三篇额外的文章中谈到了 C 语言的衰退和正在到来的巨大改变,而我们也确实能够感受到系统编程的新时代的到来,在这个时刻,我决定把我之前有的大体的预感具象化为更加具体的,更实用的点子,它们主要是关于计算机语言设计的分析,例如为什么他们会成功,或为什么他们会失败。 +## 在我最近的一篇文章中,我写道:所有计算机语言都是对机器资源的成本和程序员工作成本的相对权衡的结果,和对其相对价值的体现。这些都是在一个计算能力成本不断下降但程序员工作成本不减反增的背景下产生的。我还强调了转化成本在使原有交易主张适用于当下环境中的新增角色。在文中我将编程人员描述为一个寻找今后最适方案的探索者。 +## 现在我要讲一讲最后一点。以现有水平为起点,一个语言工程师有极大可能通过多种方式推动语言设计的发展。通过什么系统呢? GC 还是人工分配?使用何种配置,命令式语言,函数程式语言或是面向对象语言?但是从人类行为学的角度来说,我认为它的形式会更简洁,也许只是选择解决长期问题还是短期问题? +## 所谓的“远”“近”之分,是指硬件成本的逐渐降低,软件复杂程度的上升和由现有语言向其他语言转化的成本的增加,根据它们的变化曲线所做出的判断。短期问题指编程人员眼下发现的问题,长期问题指可预见的一系列情况,但它们一段时间内不会到来。针对近期问题所做出的部署需要非常及时且有效,但随着情况的变化,短期解决方案有可能很快就不适用了。而长期的解决方案可能因其过于超前而夭折,或因其代价过高无法被接受。 +## 在计算机刚刚面世的时候, FORTRAN 是近期亟待解决的问题, LISP 是远期问题。汇编语言是短期解决方案,图解说明非通用语言的分类应用,还有关门电阻不断上涨的成本。随着计算机技术的发展,PHP 和 Javascript逐渐应用于游戏中。至于长期的解决方案? Oberon , Ocaml , ML , XML-Docbook 都可以。 他们形成的激励机制带来了大量具有突破性和原创性的想法,事态蓬勃但未形成体系,那个时候距离专业语言的面世还很远,(值得注意的是这些想法的出现都是人类行为学中的因果,并非由于某种技术)。专业语言会失败,这是显而易见的,它的转入成本高昂,让大部分人望而却步,因此不能没能达到能够让主流群体接受的水平,被孤立,被搁置。这也是 LISP 不为人知的的过去,作为前 LISP 管理层人员,出于对它深深的爱,我为你们讲述了这段历史。 +## 如果短期解决方案出现故障,它的后果更加惨不忍睹,最好的结果是期待一个相对体面的失败,好转换到另一个设计方案。(通常在转化成本较高时)如果他们执意继续,通常造成众多方案相互之间藕断丝连,形成一个不断扩张的复合体,一直维持到不能运转下去,变成一堆摇摇欲坠的杂物。是的,我说的就是 C++ 语言,还有 Java 描述语言,(唉)还有 Perl,虽然 Larry Wall 的好品味成功地让他维持了很多年,问题一直没有爆发,但在 Perl 6 发行时,他的好品味最终引爆了整个问题。 +## 这种思考角度激励了编程人员向着两个不同的目的重新塑造语言设计: ①以远近为轴,在自身和预计的未来之间选取一个最适点,然后 ②降低由一种或多种语言转化为自身语言的转入成本,这样你就可以吸纳他们的用户群。接下来我会讲讲 C 语言是怎样占领全世界的。 +## 在整个计算机发展史中,没有谁能比 C 语言完美地把握最适点的选取了,我要做的只是证明这一点,作为一种实用的主流语言, C 语言有着更长的寿命,它目睹了无数个竞争者的兴衰,但它的地位仍旧不可取代。从淘汰它的第一个竞争者到现在已经过了 35 年,但看起来C语言的终结仍旧不会到来。 +## 当然,如果你愿意的话,可以把 C 语言的持久存在归功于人类的文化惰性,但那是对“文化惰性”这个词的曲解, C 语言一直得以延续的真正原因是没有人提供足够的转化费用! +## 相反的, C 语言低廉的内部转化费用未得到应有的重视,C 语言是如此的千变万化,从它漫长统治时期的初期开始,它就可以适用于多种语言如 FORTRAN , Pascal , 汇编语言和 LISP 的编程习惯。在二十世纪八十年代我就注意到,我可以根据编程人员的编码风格判断出他的母语是什么,这也从另一方面证明了C 语言的魅力能够吸引全世界的人使用它。 +## C++ 语言同样胜在它低廉的转化费用。很快,大部分新兴的语言为了降低自身转化费用,纷纷参考 C 语言语法。请注意这给未来的语言设计环境带来了什么影响:它尽可能地提高了 C-like 语言的价值,以此来降低其他语言转化为 C 语言的转化成本。 +## 另一种降低转入成本的方法十分简单,即使没接触过编程的人都能学会,但这种方法很难完成。我认为唯一使用了这种方法的 Python就是靠这种方法进入了职业比赛。对这个方法我一带而过,是因为它并不是我希望看到的,顺利执行的系统语言战略,虽然我很希望它不是那样的。 +## 今天我们在2017年年底聚集在这里,下一项我们应该为某些暴躁的团体发声,如 Go 团队,但事实并非如此。 Go 这个项目漏洞百出,我甚至可以想象出它失败的各种可能,Go 团队太过固执独断,即使几乎整个用户群体都认为 Go 需要做出改变了,Go 团队也无动于衷,这是个大问题。 一旦发生故障, GC 发生延迟或者用牺牲生产量来弥补延迟,但无论如何,它都会严重影响到这种语言的应用,大幅缩小这种语言的适用范围。 +## 即便如此,在 Go 的设计中,还是有一个我颇为认同的远大战略目标,想要理解这个目标,我们需要回想一下如果想要取代 C 语言,要面临的短期问题是什么。同我之前提到的,随着项目计划的不断扩张,故障率也在持续上升,这其中内存管理方面的故障尤其多,而内存管理一直是崩溃漏洞和安全漏洞的高发领域。 +## 我们现在已经知道了两件十分中重要的紧急任务,要想取代 C 语言,首先要先做到这两点:(1)解决内存管理问题;(2)降低由 C 语言向本语言转化时所需的转入成本。纵观编程语言的历史——从人类行为学的角度来看,作为 C 语言的准替代者,如果不能有效解决转入成本过高这个问题,那他们所做的其他部分做得再好都不算数。相反的,如果他们把转入成本过高这个问题解决地很好,即使他们其他部分做的不是最好的,人们也不会对他们吹毛求疵。 +## 这正是 Go 的做法,但这个理论并不是完美无瑕的,它也有局限性。目前 GC 延迟限制了它的发展,但 Go 现在选择照搬 Unix 下 C 语言的传染战略,让自身语言变成易于转入,便于传播的语言,其繁殖速度甚至快于替代品。但从长远角度看,这并不是个好办法。 +## 当然, Rust 语言的不足是个十分明显的问题,我们不应当回避它。而它,正将自己定位为适用于长远计划的选择。在之前的部分中我已经谈到了为什么我觉得它还不完美,Rust 语言在 TIBOE 和PYPL 指数上的成就也证明了我的说法,在 TIBOE 上 Rust 从来没有进过前20名,在 PYPL 指数上它的成就也比 Go 差很多。 +## 五年后 Rust 能发展的怎样还是个问题,如果他们愿意改变,我建议他们重视转入成本问题。以我个人经历来说,由 C 语言转入 Rust 语言的能量壁垒使人望而却步。如果编码提升工具比如 Corrode 只能把 C 语言映射为不稳定的 Rust 语言,但不能解决能量壁垒的问题;或者如果有更简单的方法能够自动注释所有权或试用期,人们也不再需要它们了——这些问题编译器就能够解决。目前我不知道怎样解决这个问题,但我觉得他们最好找出解决方案。 +## 在最后我想强调一下,虽然在 Ken Thompson 的设计经历中,他看起来很少解决短期问题,但他对未来有着极大的包容性,并且这种包容性还在不断提升。当然 Unix 也是这样的, 它让我不禁暗自揣测,让我认为 Go 语言中令人不快的地方都其实是他们未来事业的基石(例如缺乏泛型)。如果要确认这件事是真假,我需要比 Ken 还要聪明,但这并不是一件容易让人相信的事情。 + + From adb1eaa60d0c60f2b0ba14d36f52109cffa3be9e Mon Sep 17 00:00:00 2001 From: Valonia Kim <34000495+Valoniakim@users.noreply.github.com> Date: Mon, 4 Dec 2017 20:11:40 +0800 Subject: [PATCH 249/344] Update Language engineering for great justice. Translated by Valoniakim --- .../Language engineering for great justice. | 83 +++++++++++++------ 1 file changed, 59 insertions(+), 24 deletions(-) diff --git a/translated/tech/Language engineering for great justice. b/translated/tech/Language engineering for great justice. index 7f982e0d19..301337b11c 100644 --- a/translated/tech/Language engineering for great justice. +++ b/translated/tech/Language engineering for great justice. @@ -1,24 +1,59 @@ -# 最合理的语言工程模式 -## 当你熟练掌握一体化工程技术时,你就会发现它逐渐超过了技术优化的层面。我们制作的每件手工艺品都在一个大环境背景下,在这个环境中,人类的行为逐渐突破了经济意义,社会学意义,达到了奥地利经济学家所称的“人类行为学”,这是目的明确的人类行为所能达到的最大范围。 -## 对我来说这并不只是抽象理论。当我在开源发展项目中编写时,我的行为就十分符合人类行为学的理论,这行为不是针对任何特定的软件技术或某个客观事物,它指的是在开发科技的过程中人类行为的背景环境。从人类行为学角度对科技进行的解读不断增加,大量的这种解读可以重塑科技框架,带来人类生产力和满足感的极大幅度增长,而这并不是由于我们换了工具,而是在于我们改变了掌握它们的方式。 -## 在这个背景下,我在第三篇额外的文章中谈到了 C 语言的衰退和正在到来的巨大改变,而我们也确实能够感受到系统编程的新时代的到来,在这个时刻,我决定把我之前有的大体的预感具象化为更加具体的,更实用的点子,它们主要是关于计算机语言设计的分析,例如为什么他们会成功,或为什么他们会失败。 -## 在我最近的一篇文章中,我写道:所有计算机语言都是对机器资源的成本和程序员工作成本的相对权衡的结果,和对其相对价值的体现。这些都是在一个计算能力成本不断下降但程序员工作成本不减反增的背景下产生的。我还强调了转化成本在使原有交易主张适用于当下环境中的新增角色。在文中我将编程人员描述为一个寻找今后最适方案的探索者。 -## 现在我要讲一讲最后一点。以现有水平为起点,一个语言工程师有极大可能通过多种方式推动语言设计的发展。通过什么系统呢? GC 还是人工分配?使用何种配置,命令式语言,函数程式语言或是面向对象语言?但是从人类行为学的角度来说,我认为它的形式会更简洁,也许只是选择解决长期问题还是短期问题? -## 所谓的“远”“近”之分,是指硬件成本的逐渐降低,软件复杂程度的上升和由现有语言向其他语言转化的成本的增加,根据它们的变化曲线所做出的判断。短期问题指编程人员眼下发现的问题,长期问题指可预见的一系列情况,但它们一段时间内不会到来。针对近期问题所做出的部署需要非常及时且有效,但随着情况的变化,短期解决方案有可能很快就不适用了。而长期的解决方案可能因其过于超前而夭折,或因其代价过高无法被接受。 -## 在计算机刚刚面世的时候, FORTRAN 是近期亟待解决的问题, LISP 是远期问题。汇编语言是短期解决方案,图解说明非通用语言的分类应用,还有关门电阻不断上涨的成本。随着计算机技术的发展,PHP 和 Javascript逐渐应用于游戏中。至于长期的解决方案? Oberon , Ocaml , ML , XML-Docbook 都可以。 他们形成的激励机制带来了大量具有突破性和原创性的想法,事态蓬勃但未形成体系,那个时候距离专业语言的面世还很远,(值得注意的是这些想法的出现都是人类行为学中的因果,并非由于某种技术)。专业语言会失败,这是显而易见的,它的转入成本高昂,让大部分人望而却步,因此不能没能达到能够让主流群体接受的水平,被孤立,被搁置。这也是 LISP 不为人知的的过去,作为前 LISP 管理层人员,出于对它深深的爱,我为你们讲述了这段历史。 -## 如果短期解决方案出现故障,它的后果更加惨不忍睹,最好的结果是期待一个相对体面的失败,好转换到另一个设计方案。(通常在转化成本较高时)如果他们执意继续,通常造成众多方案相互之间藕断丝连,形成一个不断扩张的复合体,一直维持到不能运转下去,变成一堆摇摇欲坠的杂物。是的,我说的就是 C++ 语言,还有 Java 描述语言,(唉)还有 Perl,虽然 Larry Wall 的好品味成功地让他维持了很多年,问题一直没有爆发,但在 Perl 6 发行时,他的好品味最终引爆了整个问题。 -## 这种思考角度激励了编程人员向着两个不同的目的重新塑造语言设计: ①以远近为轴,在自身和预计的未来之间选取一个最适点,然后 ②降低由一种或多种语言转化为自身语言的转入成本,这样你就可以吸纳他们的用户群。接下来我会讲讲 C 语言是怎样占领全世界的。 -## 在整个计算机发展史中,没有谁能比 C 语言完美地把握最适点的选取了,我要做的只是证明这一点,作为一种实用的主流语言, C 语言有着更长的寿命,它目睹了无数个竞争者的兴衰,但它的地位仍旧不可取代。从淘汰它的第一个竞争者到现在已经过了 35 年,但看起来C语言的终结仍旧不会到来。 -## 当然,如果你愿意的话,可以把 C 语言的持久存在归功于人类的文化惰性,但那是对“文化惰性”这个词的曲解, C 语言一直得以延续的真正原因是没有人提供足够的转化费用! -## 相反的, C 语言低廉的内部转化费用未得到应有的重视,C 语言是如此的千变万化,从它漫长统治时期的初期开始,它就可以适用于多种语言如 FORTRAN , Pascal , 汇编语言和 LISP 的编程习惯。在二十世纪八十年代我就注意到,我可以根据编程人员的编码风格判断出他的母语是什么,这也从另一方面证明了C 语言的魅力能够吸引全世界的人使用它。 -## C++ 语言同样胜在它低廉的转化费用。很快,大部分新兴的语言为了降低自身转化费用,纷纷参考 C 语言语法。请注意这给未来的语言设计环境带来了什么影响:它尽可能地提高了 C-like 语言的价值,以此来降低其他语言转化为 C 语言的转化成本。 -## 另一种降低转入成本的方法十分简单,即使没接触过编程的人都能学会,但这种方法很难完成。我认为唯一使用了这种方法的 Python就是靠这种方法进入了职业比赛。对这个方法我一带而过,是因为它并不是我希望看到的,顺利执行的系统语言战略,虽然我很希望它不是那样的。 -## 今天我们在2017年年底聚集在这里,下一项我们应该为某些暴躁的团体发声,如 Go 团队,但事实并非如此。 Go 这个项目漏洞百出,我甚至可以想象出它失败的各种可能,Go 团队太过固执独断,即使几乎整个用户群体都认为 Go 需要做出改变了,Go 团队也无动于衷,这是个大问题。 一旦发生故障, GC 发生延迟或者用牺牲生产量来弥补延迟,但无论如何,它都会严重影响到这种语言的应用,大幅缩小这种语言的适用范围。 -## 即便如此,在 Go 的设计中,还是有一个我颇为认同的远大战略目标,想要理解这个目标,我们需要回想一下如果想要取代 C 语言,要面临的短期问题是什么。同我之前提到的,随着项目计划的不断扩张,故障率也在持续上升,这其中内存管理方面的故障尤其多,而内存管理一直是崩溃漏洞和安全漏洞的高发领域。 -## 我们现在已经知道了两件十分中重要的紧急任务,要想取代 C 语言,首先要先做到这两点:(1)解决内存管理问题;(2)降低由 C 语言向本语言转化时所需的转入成本。纵观编程语言的历史——从人类行为学的角度来看,作为 C 语言的准替代者,如果不能有效解决转入成本过高这个问题,那他们所做的其他部分做得再好都不算数。相反的,如果他们把转入成本过高这个问题解决地很好,即使他们其他部分做的不是最好的,人们也不会对他们吹毛求疵。 -## 这正是 Go 的做法,但这个理论并不是完美无瑕的,它也有局限性。目前 GC 延迟限制了它的发展,但 Go 现在选择照搬 Unix 下 C 语言的传染战略,让自身语言变成易于转入,便于传播的语言,其繁殖速度甚至快于替代品。但从长远角度看,这并不是个好办法。 -## 当然, Rust 语言的不足是个十分明显的问题,我们不应当回避它。而它,正将自己定位为适用于长远计划的选择。在之前的部分中我已经谈到了为什么我觉得它还不完美,Rust 语言在 TIBOE 和PYPL 指数上的成就也证明了我的说法,在 TIBOE 上 Rust 从来没有进过前20名,在 PYPL 指数上它的成就也比 Go 差很多。 -## 五年后 Rust 能发展的怎样还是个问题,如果他们愿意改变,我建议他们重视转入成本问题。以我个人经历来说,由 C 语言转入 Rust 语言的能量壁垒使人望而却步。如果编码提升工具比如 Corrode 只能把 C 语言映射为不稳定的 Rust 语言,但不能解决能量壁垒的问题;或者如果有更简单的方法能够自动注释所有权或试用期,人们也不再需要它们了——这些问题编译器就能够解决。目前我不知道怎样解决这个问题,但我觉得他们最好找出解决方案。 -## 在最后我想强调一下,虽然在 Ken Thompson 的设计经历中,他看起来很少解决短期问题,但他对未来有着极大的包容性,并且这种包容性还在不断提升。当然 Unix 也是这样的, 它让我不禁暗自揣测,让我认为 Go 语言中令人不快的地方都其实是他们未来事业的基石(例如缺乏泛型)。如果要确认这件事是真假,我需要比 Ken 还要聪明,但这并不是一件容易让人相信的事情。 - - + -最合理的语言工程模式 + -============================================================ + - + -当你熟练掌握一体化工程技术时,你就会发现它逐渐超过了技术优化的层面。我们制作的每件手工艺品都在一个大环境背景下,在这个环境中,人类的行为逐渐突破了经济意义,社会学意义,达到了奥地利经济学家所称的“人类行为学”,这是目的明确的人类行为所能达到的最大范围。 + - + -对我来说这并不只是抽象理论。当我在开源发展项目中编写时,我的行为就十分符合人类行为学的理论,这行为不是针对任何特定的软件技术或某个客观事物,它指的是在开发科技的过程中人类行为的背景环境。从人类行为学角度对科技进行的解读不断增加,大量的这种解读可以重塑科技框架,带来人类生产力和满足感的极大幅度增长,而这并不是由于我们换了工具,而是在于我们改变了掌握它们的方式。 + - + -在这个背景下,我在第三篇额外的文章中谈到了 C 语言的衰退和正在到来的巨大改变,而我们也确实能够感受到系统编程的新时代的到来,在这个时刻,我决定把我之前有的大体的预感具象化为更加具体的,更实用的点子,它们主要是关于计算机语言设计的分析,例如为什么他们会成功,或为什么他们会失败。 + - + -在我最近的一篇文章中,我写道:所有计算机语言都是对机器资源的成本和程序员工作成本的相对权衡的结果,和对其相对价值的体现。这些都是在一个计算能力成本不断下降但程序员工作成本不减反增的背景下产生的。我还强调了转化成本在使原有交易主张适用于当下环境中的新增角色。在文中我将编程人员描述为一个寻找今后最适方案的探索者。 + - + -现在我要讲一讲最后一点。以现有水平为起点,一个语言工程师有极大可能通过多种方式推动语言设计的发展。通过什么系统呢? GC 还是人工分配?使用何种配置,命令式语言,函数程式语言或是面向对象语言?但是从人类行为学的角度来说,我认为它的形式会更简洁,也许只是选择解决长期问题还是短期问题? + - + -所谓的“远”“近”之分,是指硬件成本的逐渐降低,软件复杂程度的上升和由现有语言向其他语言转化的成本的增加,根据它们的变化曲线所做出的判断。短期问题指编程人员眼下发现的问题,长期问题指可预见的一系列情况,但它们一段时间内不会到来。针对近期问题所做出的部署需要非常及时且有效,但随着情况的变化,短期解决方案有可能很快就不适用了。而长期的解决方案可能因其过于超前而夭折,或因其代价过高无法被接受。 + - + -在计算机刚刚面世的时候, FORTRAN 是近期亟待解决的问题, LISP 是远期问题。汇编语言是短期解决方案,图解说明非通用语言的分类应用,还有关门电阻不断上涨的成本。随着计算机技术的发展,PHP 和 Javascript逐渐应用于游戏中。至于长期的解决方案? Oberon , Ocaml , ML , XML-Docbook 都可以。 他们形成的激励机制带来了大量具有突破性和原创性的想法,事态蓬勃但未形成体系,那个时候距离专业语言的面世还很远,(值得注意的是这些想法的出现都是人类行为学中的因果,并非由于某种技术)。专业语言会失败,这是显而易见的,它的转入成本高昂,让大部分人望而却步,因此不能没能达到能够让主流群体接受的水平,被孤立,被搁置。这也是 LISP 不为人知的的过去,作为前 LISP 管理层人员,出于对它深深的爱,我为你们讲述了这段历史。 + - + -如果短期解决方案出现故障,它的后果更加惨不忍睹,最好的结果是期待一个相对体面的失败,好转换到另一个设计方案。(通常在转化成本较高时)如果他们执意继续,通常造成众多方案相互之间藕断丝连,形成一个不断扩张的复合体,一直维持到不能运转下去,变成一堆摇摇欲坠的杂物。是的,我说的就是 C++ 语言,还有 Java 描述语言,(唉)还有 Perl,虽然 Larry Wall 的好品味成功地让他维持了很多年,问题一直没有爆发,但在 Perl 6 发行时,他的好品味最终引爆了整个问题。 + - + -这种思考角度激励了编程人员向着两个不同的目的重新塑造语言设计: ①以远近为轴,在自身和预计的未来之间选取一个最适点,然后 ②降低由一种或多种语言转化为自身语言的转入成本,这样你就可以吸纳他们的用户群。接下来我会讲讲 C 语言是怎样占领全世界的。 + - + -在整个计算机发展史中,没有谁能比 C 语言完美地把握最适点的选取了,我要做的只是证明这一点,作为一种实用的主流语言, C 语言有着更长的寿命,它目睹了无数个竞争者的兴衰,但它的地位仍旧不可取代。从淘汰它的第一个竞争者到现在已经过了 35 年,但看起来C语言的终结仍旧不会到来。 + - + -当然,如果你愿意的话,可以把 C 语言的持久存在归功于人类的文化惰性,但那是对“文化惰性”这个词的曲解, C 语言一直得以延续的真正原因是没有人提供足够的转化费用! + - + -相反的, C 语言低廉的内部转化费用未得到应有的重视,C 语言是如此的千变万化,从它漫长统治时期的初期开始,它就可以适用于多种语言如 FORTRAN , Pascal , 汇编语言和 LISP 的编程习惯。在二十世纪八十年代我就注意到,我可以根据编程人员的编码风格判断出他的母语是什么,这也从另一方面证明了C 语言的魅力能够吸引全世界的人使用它。 + - + -C++ 语言同样胜在它低廉的转化费用。很快,大部分新兴的语言为了降低自身转化费用,纷纷参考 C 语言语法。请注意这给未来的语言设计环境带来了什么影响:它尽可能地提高了 C-like 语言的价值,以此来降低其他语言转化为 C 语言的转化成本。 + - + -另一种降低转入成本的方法十分简单,即使没接触过编程的人都能学会,但这种方法很难完成。我认为唯一使用了这种方法的 Python就是靠这种方法进入了职业比赛。对这个方法我一带而过,是因为它并不是我希望看到的,顺利执行的系统语言战略,虽然我很希望它不是那样的。 + - + -今天我们在2017年年底聚集在这里,下一项我们应该为某些暴躁的团体发声,如 Go 团队,但事实并非如此。 Go 这个项目漏洞百出,我甚至可以想象出它失败的各种可能,Go 团队太过固执独断,即使几乎整个用户群体都认为 Go 需要做出改变了,Go 团队也无动于衷,这是个大问题。 一旦发生故障, GC 发生延迟或者用牺牲生产量来弥补延迟,但无论如何,它都会严重影响到这种语言的应用,大幅缩小这种语言的适用范围。 + - + -即便如此,在 Go 的设计中,还是有一个我颇为认同的远大战略目标,想要理解这个目标,我们需要回想一下如果想要取代 C 语言,要面临的短期问题是什么。同我之前提到的,随着项目计划的不断扩张,故障率也在持续上升,这其中内存管理方面的故障尤其多,而内存管理一直是崩溃漏洞和安全漏洞的高发领域。 + - + -我们现在已经知道了两件十分中重要的紧急任务,要想取代 C 语言,首先要先做到这两点:(1)解决内存管理问题;(2)降低由 C 语言向本语言转化时所需的转入成本。纵观编程语言的历史——从人类行为学的角度来看,作为 C 语言的准替代者,如果不能有效解决转入成本过高这个问题,那他们所做的其他部分做得再好都不算数。相反的,如果他们把转入成本过高这个问题解决地很好,即使他们其他部分做的不是最好的,人们也不会对他们吹毛求疵。 + - + -这正是 Go 的做法,但这个理论并不是完美无瑕的,它也有局限性。目前 GC 延迟限制了它的发展,但 Go 现在选择照搬 Unix 下 C 语言的传染战略,让自身语言变成易于转入,便于传播的语言,其繁殖速度甚至快于替代品。但从长远角度看,这并不是个好办法。 + - + -当然, Rust 语言的不足是个十分明显的问题,我们不应当回避它。而它,正将自己定位为适用于长远计划的选择。在之前的部分中我已经谈到了为什么我觉得它还不完美,Rust 语言在 TIBOE 和PYPL 指数上的成就也证明了我的说法,在 TIBOE 上 Rust 从来没有进过前20名,在 PYPL 指数上它的成就也比 Go 差很多。 + - + -五年后 Rust 能发展的怎样还是个问题,如果他们愿意改变,我建议他们重视转入成本问题。以我个人经历来说,由 C 语言转入 Rust 语言的能量壁垒使人望而却步。如果编码提升工具比如 Corrode 只能把 C 语言映射为不稳定的 Rust 语言,但不能解决能量壁垒的问题;或者如果有更简单的方法能够自动注释所有权或试用期,人们也不再需要它们了——这些问题编译器就能够解决。目前我不知道怎样解决这个问题,但我觉得他们最好找出解决方案。 + - + -在最后我想强调一下,虽然在 Ken Thompson 的设计经历中,他看起来很少解决短期问题,但他对未来有着极大的包容性,并且这种包容性还在不断提升。当然 Unix 也是这样的, 它让我不禁暗自揣测,让我认为 Go 语言中令人不快的地方都其实是他们未来事业的基石(例如缺乏泛型)。如果要确认这件事是真假,我需要比 Ken 还要聪明,但这并不是一件容易让人相信的事情。 + - + --------------------------------------------------------------------------------- + - + -via: http://esr.ibiblio.org/?p=7745 + - + -作者:[Eric Raymond ][a] + -译者:[Valoniakim](https://github.com/Valoniakim) + -校对:[校对者ID](https://github.com/校对者ID) + - + -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + - + -[a]:http://esr.ibiblio.org/?author=2 + -[1]:http://esr.ibiblio.org/?author=2 + -[2]:http://esr.ibiblio.org/?p=7711&cpage=1#comment-1913931 + -[3]:http://esr.ibiblio.org/?p=7745 From 277126294de3bab1b6ecd65c4ba45c0f176bc06e Mon Sep 17 00:00:00 2001 From: Valonia Kim <34000495+Valoniakim@users.noreply.github.com> Date: Mon, 4 Dec 2017 20:40:38 +0800 Subject: [PATCH 250/344] Rename Language engineering for great justice. to 20171118 Language engineering for great justice. --- ... justice. => 20171118 Language engineering for great justice.} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/tech/{Language engineering for great justice. => 20171118 Language engineering for great justice.} (100%) diff --git a/translated/tech/Language engineering for great justice. b/translated/tech/20171118 Language engineering for great justice. similarity index 100% rename from translated/tech/Language engineering for great justice. rename to translated/tech/20171118 Language engineering for great justice. From 5712675cd58b52c444ff552300ac34981c59040b Mon Sep 17 00:00:00 2001 From: Valonia Kim <34000495+Valoniakim@users.noreply.github.com> Date: Tue, 5 Dec 2017 13:01:06 +0800 Subject: [PATCH 251/344] Delete Language engineering for great justice --- .../Language engineering for great justice | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 translated/tech/Language engineering for great justice diff --git a/translated/tech/Language engineering for great justice b/translated/tech/Language engineering for great justice deleted file mode 100644 index d26f9319bd..0000000000 --- a/translated/tech/Language engineering for great justice +++ /dev/null @@ -1,24 +0,0 @@ -最合理的语言工程模式 -当你熟练掌握一体化工程技术时,你就会发现它逐渐超过了技术优化的层面。我们制作的每件手工艺品都在一个大环境背景下,在这个环境中,人类的行为逐渐突破了经济意义,社会学意义,达到了奥地利经济学家所称的“人类行为学”,这是目的明确的人类行为所能达到的最大范围。 -对我来说这并不只是抽象理论。当我在开源发展项目中编写时,我的行为就十分符合人类行为学的理论,这行为不是针对任何特定的软件技术或某个客观事物,它指的是在开发科技的过程中人类行为的背景环境。从人类行为学角度对科技进行的解读不断增加,大量的这种解读可以重塑科技框架,带来人类生产力和满足感的极大幅度增长,而这并不是由于我们换了工具,而是在于我们改变了掌握它们的方式。 -在这个背景下,我在第三篇额外的文章中谈到了 C 语言的衰退和正在到来的巨大改变,而我们也确实能够感受到系统编程的新时代的到来,在这个时刻,我决定把我之前有的大体的预感具象化为更加具体的,更实用的点子,它们主要是关于计算机语言设计的分析,例如为什么他们会成功,或为什么他们会失败。 -在我最近的一篇文章中,我写道:所有计算机语言都是对机器资源的成本和程序员工作成本的相对权衡的结果,和对其相对价值的体现。这些都是在一个计算能力成本不断下降但程序员工作成本不减反增的背景下产生的。我还强调了转化成本在使原有交易主张适用于当下环境中的新增角色。在文中我将编程人员描述为一个寻找今后最适方案的探索者。 -现在我要讲一讲最后一点。以现有水平为起点,一个语言工程师有极大可能通过多种方式推动语言设计的发展。通过什么系统呢? GC 还是人工分配?使用何种配置,命令式语言,函数程式语言或是面向对象语言?但是从人类行为学的角度来说,我认为它的形式会更简洁,也许只是选择解决长期问题还是短期问题? -所谓的“远”“近”之分,是指硬件成本的逐渐降低,软件复杂程度的上升和由现有语言向其他语言转化的成本的增加,根据它们的变化曲线所做出的判断。短期问题指编程人员眼下发现的问题,长期问题指可预见的一系列情况,但它们一段时间内不会到来。针对近期问题所做出的部署需要非常及时且有效,但随着情况的变化,短期解决方案有可能很快就不适用了。而长期的解决方案可能因其过于超前而夭折,或因其代价过高无法被接受。 -在计算机刚刚面世的时候, FORTRAN 是近期亟待解决的问题, LISP 是远期问题。汇编语言是短期解决方案,图解说明非通用语言的分类应用,还有关门电阻不断上涨的成本。随着计算机技术的发展,PHP 和 Javascript逐渐应用于游戏中。至于长期的解决方案? Oberon , Ocaml , ML , XML-Docbook 都可以。 他们形成的激励机制带来了大量具有突破性和原创性的想法,事态蓬勃但未形成体系,那个时候距离专业语言的面世还很远,(值得注意的是这些想法的出现都是人类行为学中的因果,并非由于某种技术)。专业语言会失败,这是显而易见的,它的转入成本高昂,让大部分人望而却步,因此不能没能达到能够让主流群体接受的水平,被孤立,被搁置。这也是 LISP 不为人知的的过去,作为前 LISP 管理层人员,出于对它深深的爱,我为你们讲述了这段历史。 -如果短期解决方案出现故障,它的后果更加惨不忍睹,最好的结果是期待一个相对体面的失败,好转换到另一个设计方案。(通常在转化成本较高时)如果他们执意继续,通常造成众多方案相互之间藕断丝连,形成一个不断扩张的复合体,一直维持到不能运转下去,变成一堆摇摇欲坠的杂物。是的,我说的就是 C++ 语言,还有 Java 描述语言,(唉)还有 Perl,虽然 Larry Wall 的好品味成功地让他维持了很多年,问题一直没有爆发,但在 Perl 6 发行时,他的好品味最终引爆了整个问题。 -这种思考角度激励了编程人员向着两个不同的目的重新塑造语言设计: ①以远近为轴,在自身和预计的未来之间选取一个最适点,然后 ②降低由一种或多种语言转化为自身语言的转入成本,这样你就可以吸纳他们的用户群。接下来我会讲讲 C 语言是怎样占领全世界的。 -在整个计算机发展史中,没有谁能比 C 语言完美地把握最适点的选取了,我要做的只是证明这一点,作为一种实用的主流语言, C 语言有着更长的寿命,它目睹了无数个竞争者的兴衰,但它的地位仍旧不可取代。从淘汰它的第一个竞争者到现在已经过了 35 年,但看起来C语言的终结仍旧不会到来。 -当然,如果你愿意的话,可以把 C 语言的持久存在归功于人类的文化惰性,但那是对“文化惰性”这个词的曲解, C 语言一直得以延续的真正原因是没有人提供足够的转化费用! -相反的, C 语言低廉的内部转化费用未得到应有的重视,C 语言是如此的千变万化,从它漫长统治时期的初期开始,它就可以适用于多种语言如 FORTRAN , Pascal , 汇编语言和 LISP 的编程习惯。在二十世纪八十年代我就注意到,我可以根据编程人员的编码风格判断出他的母语是什么,这也从另一方面证明了C 语言的魅力能够吸引全世界的人使用它。 -C++ 语言同样胜在它低廉的转化费用。很快,大部分新兴的语言为了降低自身转化费用,纷纷参考 C 语言语法。请注意这给未来的语言设计环境带来了什么影响:它尽可能地提高了 C-like 语言的价值,以此来降低其他语言转化为 C 语言的转化成本。 -另一种降低转入成本的方法十分简单,即使没接触过编程的人都能学会,但这种方法很难完成。我认为唯一使用了这种方法的 Python就是靠这种方法进入了职业比赛。对这个方法我一带而过,是因为它并不是我希望看到的,顺利执行的系统语言战略,虽然我很希望它不是那样的。 -今天我们在2017年年底聚集在这里,下一项我们应该为某些暴躁的团体发声,如 Go 团队,但事实并非如此。 Go 这个项目漏洞百出,我甚至可以想象出它失败的各种可能,Go 团队太过固执独断,即使几乎整个用户群体都认为 Go 需要做出改变了,Go 团队也无动于衷,这是个大问题。 一旦发生故障, GC 发生延迟或者用牺牲生产量来弥补延迟,但无论如何,它都会严重影响到这种语言的应用,大幅缩小这种语言的适用范围。 -即便如此,在 Go 的设计中,还是有一个我颇为认同的远大战略目标,想要理解这个目标,我们需要回想一下如果想要取代 C 语言,要面临的短期问题是什么。同我之前提到的,随着项目计划的不断扩张,故障率也在持续上升,这其中内存管理方面的故障尤其多,而内存管理一直是崩溃漏洞和安全漏洞的高发领域。 -我们现在已经知道了两件十分中重要的紧急任务,要想取代 C 语言,首先要先做到这两点:(1)解决内存管理问题;(2)降低由 C 语言向本语言转化时所需的转入成本。纵观编程语言的历史——从人类行为学的角度来看,作为 C 语言的准替代者,如果不能有效解决转入成本过高这个问题,那他们所做的其他部分做得再好都不算数。相反的,如果他们把转入成本过高这个问题解决地很好,即使他们其他部分做的不是最好的,人们也不会对他们吹毛求疵。 -这正是 Go 的做法,但这个理论并不是完美无瑕的,它也有局限性。目前 GC 延迟限制了它的发展,但 Go 现在选择照搬 Unix 下 C 语言的传染战略,让自身语言变成易于转入,便于传播的语言,其繁殖速度甚至快于替代品。但从长远角度看,这并不是个好办法。 -当然, Rust 语言的不足是个十分明显的问题,我们不应当回避它。而它,正将自己定位为适用于长远计划的选择。在之前的部分中我已经谈到了为什么我觉得它还不完美,Rust 语言在 TIBOE 和PYPL 指数上的成就也证明了我的说法,在 TIBOE 上 Rust 从来没有进过前20名,在 PYPL 指数上它的成就也比 Go 差很多。 -五年后 Rust 能发展的怎样还是个问题,如果他们愿意改变,我建议他们重视转入成本问题。以我个人经历来说,由 C 语言转入 Rust 语言的能量壁垒使人望而却步。如果编码提升工具比如 Corrode 只能把 C 语言映射为不稳定的 Rust 语言,但不能解决能量壁垒的问题;或者如果有更简单的方法能够自动注释所有权或试用期,人们也不再需要它们了——这些问题编译器就能够解决。目前我不知道怎样解决这个问题,但我觉得他们最好找出解决方案。 -在最后我想强调一下,虽然在 Ken Thompson 的设计经历中,他看起来很少解决短期问题,但他对未来有着极大的包容性,并且这种包容性还在不断提升。当然 Unix 也是这样的, 它让我不禁暗自揣测,让我认为 Go 语言中令人不快的地方都其实是他们未来事业的基石(例如缺乏泛型)。如果要确认这件事是真假,我需要比 Ken 还要聪明,但这并不是一件容易让人相信的事情。 - - From 0879b0fb09b66f8c82b5dd9e5b1bce26845b8528 Mon Sep 17 00:00:00 2001 From: Valonia Kim <34000495+Valoniakim@users.noreply.github.com> Date: Tue, 5 Dec 2017 13:13:33 +0800 Subject: [PATCH 252/344] Translated --- ...ustice. => 20171118 Language engineering for great justice.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/tech/{20171118 Language engineering for great justice. => 20171118 Language engineering for great justice.md} (100%) diff --git a/translated/tech/20171118 Language engineering for great justice. b/translated/tech/20171118 Language engineering for great justice.md similarity index 100% rename from translated/tech/20171118 Language engineering for great justice. rename to translated/tech/20171118 Language engineering for great justice.md From 5d591b422d56be45c975559af2bb952003de6aa5 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 5 Dec 2017 14:53:29 +0800 Subject: [PATCH 253/344] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Best=20Network=20?= =?UTF-8?q?Monitoring=20Tools=20For=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Best Network Monitoring Tools For Linux.md | 186 ++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 sources/tech/20171203 Best Network Monitoring Tools For Linux.md diff --git a/sources/tech/20171203 Best Network Monitoring Tools For Linux.md b/sources/tech/20171203 Best Network Monitoring Tools For Linux.md new file mode 100644 index 0000000000..70ee1d651e --- /dev/null +++ b/sources/tech/20171203 Best Network Monitoring Tools For Linux.md @@ -0,0 +1,186 @@ +Best Network Monitoring Tools For Linux +--------- +Keeping control of our network is vital to prevent any program from overusing it and slows down the overall system operation. There are several + +**network monitoring tools** + +for different operating systems today. In this article, we will talk about + +**10 network monitoring tools for Linux** + +that will run from a terminal, ideal for users who do not use GUI or for those who want to keep a control of the network use of a server through from ssh. + +### Iftop + + [![iftop network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iftop_orig.png)][2] + +Linux users are generally familiar with Top. This tool is a system monitor that allows us to know in real time all the processes that are running in our system and can manage them easily. Iftop is an application similar to Top but specialized in the monitoring of the network, being able to know a multitude of details regarding the network and all the processes that are making use of it. + +We can obtain more information about this tool and download the necessary packages from the + +[following link][3] + +. + +### Vnstat + + [![vnstat network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/editor/vnstat.png?1511885309)][4] **Vnstat** + +is a network monitor that is included, by default, in most Linux distributions. It allows us to obtain a real-time control of the traffic sent and received in a period of time, chosen by the user. + +​ + +We can obtain more information about this tool and download the necessary packages from the + +[following link.][5] + +### Iptraf + + [![iptraf monitoring tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iptraf_orig.gif)][6] **IPTraf** + +is a console-based, real-time network monitoring utility for Linux. (IP LAN) - Collects a wide variety of information as an IP traffic monitor that passes through the network, including TCP flags information, ICMP details, TCP / UDP traffic faults, TCP connection packet and Byne account. It also collects statistics information from the general and detailed interface of TCP, UDP,,, checksum errors IP not IP ICMP IP, interface activity, etc. + +​ + +We can obtain more information about this tool and download the necessary packages from the + +[following link.][7] + +### Monitorix - System and Monitoring Network + + [![monitorix system monitoring tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/monitorix_orig.png)][8] + +Monitorix is a lightweight free utility that is designed to run and monitor system and network resources with as many Linux / Unix servers as possible. An HTTP web server has been added that regularly collects system and network information and displays them in the graphs. It will track the average system load and its usage, memory allocation, disk health, system services, network ports, mail statistics (Sendmail, Postfix, Dovecot, etc.), MySQL statistics and many more. It is designed to control the overall performance of the system and helps in detecting faults, bottlenecks, abnormal activities, etc. + +​ + +Download and more + +[information here][9] + +. + +### Dstat + + [![dstat network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/dstat_orig.png)][10] + +A monitor is somewhat less known than the previous ones but also usually comes by default in many distributions. + +​ + +We can obtain more information about this tool and download the necessary packages from the + +[following link][11] + +. + +### Bwm-ng + + [![bwm-ng monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/bwm-ng_orig.png)][12] + +One of the simplest tools. It allows you to get data from the connection interactively and, at the same time, export them to a certain format for easier reference on another device. + +​ + +We can obtain more information about this tool and download the necessary packages from the + +[following link][13] + +. + +### Ibmonitor + + [![ibmonitor tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/ibmonitor_orig.jpg)][14] + +Similar to the above, it shows network traffic filtered by connection interface and clearly separates the traffic sent from the received traffic. + +​ + +We can obtain more information about this tool and download the necessary packages from the + +[following link​][15] + +. + +### Htop - Linux Process Tracking + + [![htop linux processes monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/htop_orig.png)][16] + +Htop is a much more advanced, interactive and real-time Linux tool for tracking processes. It is similar to the top Linux command but has some advanced features such as an easy-to-use interface for process management, shortcut keys, vertical and horizontal view of processes and much more. Htop is a third-party tool and is not included on Linux systems, you must install it using + +**YUM** + +(or + +**APT-GET)** + +or whatever your package management tool. For more information on installation, read + +[this article][17] + +. + +We can obtain more information about this tool and download the necessary packages from the + +[following link.][18] + +### Arpwatch - Ethernet Activity Monitor + + [![arpwatch ethernet monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/arpwatch_orig.png)][19] + +Arpwatch is a program that is designed to control the resolution of addresses (MAC and changes in the IP address) of Ethernet network traffic in a Linux network. It is continuously monitoring the Ethernet traffic and records the changes in the IP addresses and MAC addresses, the changes of pairs along with the timestamps in a network. It also has a function to send an e-mail notifying the administrator, when a couple is added or changes. It is very useful in detecting ARP impersonation in a network. + +We can obtain more information about this tool and download the necessary packages from the + +[following link.​][20] + +### Wireshark - Network Monitoring tool + + [![wireshark network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/editor/how-to-use-wireshark_1.jpg?1512299583)][21] **[Wireshark][1]** + +is a free application that enables you to catch and view the information going forward and backward on your system, giving the capacity to bore down and read the substance of every parcel – separated to meet your particular needs. It is generally used to investigate arrange issues and additionally to create and test programming. This open-source convention analyzer is generally acknowledged as the business standard, prevailing upon what's coming to it's of honors the years. + +Initially known as Ethereal, Wireshark highlights an easy to understand interface that can show information from many diverse conventions on all real system sorts. + +### Conclusion + +​In this article, we have taken a gander at a few open source network monitoring tools. Because we concentrated on these instruments as the "best" does not really mean they are the best for your need. For instance, there are numerous other open source monitoring apparatuses that exist, for example, OpenNMS, Cacti, and Zennos and you need to consider the advantages of everyone from the point of view of your prerequisite. + +Additionally, there are different apparatuses that might be more good for your need that is not open source. + +​ + +What more network monitors do you use or know to use in Linux in terminal format? + +-------------------------------------------------------------------------------- + +via: http://www.linuxandubuntu.com/home/best-network-monitoring-tools-for-linux + +作者:[​​LinuxAndUbuntu][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://www.linuxandubuntu.com +[1]:https://www.wireshark.org/ +[2]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iftop_orig.png +[3]:http://www.ex-parrot.com/pdw/iftop/ +[4]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/edited/vnstat.png +[5]:http://humdi.net/vnstat/ +[6]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iptraf_orig.gif +[7]:http://iptraf.seul.org/ +[8]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/monitorix_orig.png +[9]:http://www.monitorix.org +[10]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/dstat_orig.png +[11]:http://dag.wiee.rs/home-made/dstat/ +[12]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/bwm-ng_orig.png +[13]:http://sourceforge.net/projects/bwmng/ +[14]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/ibmonitor_orig.jpg +[15]:http://ibmonitor.sourceforge.net/ +[16]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/htop_orig.png +[17]:http://wesharethis.com/knowledgebase/htop-and-atop/ +[18]:http://hisham.hm/htop/ +[19]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/arpwatch_orig.png +[20]:http://linux.softpedia.com/get/System/Monitoring/arpwatch-NG-7612.shtml +[21]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/how-to-use-wireshark_1_orig.jpg From bf4e786ff1a491f1daf98105d7581e9bc05e7276 Mon Sep 17 00:00:00 2001 From: Ezio Date: Tue, 5 Dec 2017 15:06:16 +0800 Subject: [PATCH 254/344] =?UTF-8?q?=E6=A0=87=E9=A2=98=E6=9C=89=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E5=B7=B2=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tech/20171203 Best Network Monitoring Tools For Linux.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sources/tech/20171203 Best Network Monitoring Tools For Linux.md b/sources/tech/20171203 Best Network Monitoring Tools For Linux.md index 70ee1d651e..aec39b9822 100644 --- a/sources/tech/20171203 Best Network Monitoring Tools For Linux.md +++ b/sources/tech/20171203 Best Network Monitoring Tools For Linux.md @@ -1,5 +1,7 @@ Best Network Monitoring Tools For Linux ---------- +=============================== + + Keeping control of our network is vital to prevent any program from overusing it and slows down the overall system operation. There are several **network monitoring tools** From 375651a0ed8fe98bef9094ff057740b046d7acdf Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 5 Dec 2017 14:32:23 +0800 Subject: [PATCH 255/344] =?UTF-8?q?=E9=80=89=E9=A2=98:=2030=20Best=20Linux?= =?UTF-8?q?=20Games=20On=20Steam=20You=20Should=20Play=20in=202017?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Your Linux Server Has Been Compromised.md | 163 +++++++++ ... Games On Steam You Should Play in 2017.md | 310 ++++++++++++++++++ 2 files changed, 473 insertions(+) create mode 100644 sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md create mode 100644 sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md diff --git a/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md b/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md new file mode 100644 index 0000000000..29fe95d868 --- /dev/null +++ b/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md @@ -0,0 +1,163 @@ +如何判断Linux服务器是否被入侵 +-------------- + +本指南中所谓的服务器被入侵或者说被黑了的意思是指未经认证的人或程序为了自己的目的登录到服务器上去并使用其计算资源, 通常会产生不好的影响。 + +免责声明: 若你的服务器被类似NSA这样的国家机关或者某个犯罪集团如请,那么你并不会发现有任何问题,这些技术也无法发觉他们的存在。 + +然而, 大多数被攻破的服务器都是被类似自动攻击程序这样的程序或者类似“脚本小子”这样的廉价攻击者,以及蠢蛋犯罪所入侵的。 + +这类攻击者会在访问服务器的同时滥用服务器资源,并且不怎么会采取措施来隐藏他们正在做的事情。 + +### 入侵服务器的症状 + +当服务器被没有经验攻击者或者自动攻击程序入侵了的话,他们往往会消耗100%的资源. 他们可能消耗CPU资源来进行数字货币的采矿或者发送垃圾邮件,也可能消耗带宽来发动 `DoS` 攻击。 + +因此出现问题的第一个表现就是服务器 “变慢了”. 这可能表现在网站的页面打开的很慢, 或者电子邮件要花很长时间才能发送出去。 + +那么你应该查看那些东西呢? + +#### 检查 1 - 当前都有谁在登录? + +你首先要查看当前都有谁登录在服务器上. 发现攻击者登录到服务器上进行操作并不罕见。 + +其对应的命令是 `w`. 运行 `w` 会输出如下结果: + +``` + 08:32:55 up 98 days, 5:43, 2 users, load average: 0.05, 0.03, 0.00 +USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT +root pts/0 113.174.161.1 08:26 0.00s 0.03s 0.02s ssh root@coopeaa12 +root pts/1 78.31.109.1 08:26 0.00s 0.01s 0.00s w + +``` + +第一个IP是英国IP,而第二个IP是越南IP. 这个不是个好兆头。 + +停下来做个深呼吸, 不要紧,只需要杀掉他们的SSH连接就好了. Unless you can stop then re-entering the server they will do so quickly and quite likely kick you off and stop you getting back in。 + +请参阅本文最后的 `入侵之后怎么办` 这一章节来看发现被入侵的证据后应该怎么办。 + +`whois` 命令可以接一个IP地址然后告诉你IP注册的组织的所有信息, 当然就包括所在国家的信息。 + +#### 检查 2 - 谁曾经登录过? + +Linux 服务器会记录下哪些用户,从哪个IP,在什么时候登录的以及登陆了多长时间这些信息. 使用 `last` 命令可以查看这些信息。 + +输出类似这样: + +``` +root pts/1 78.31.109.1 Thu Nov 30 08:26 still logged in +root pts/0 113.174.161.1 Thu Nov 30 08:26 still logged in +root pts/1 78.31.109.1 Thu Nov 30 08:24 - 08:26 (00:01) +root pts/0 113.174.161.1 Wed Nov 29 12:34 - 12:52 (00:18) +root pts/0 14.176.196.1 Mon Nov 27 13:32 - 13:53 (00:21) + +``` + +这里可以看到英国IP和越南IP交替出现, 而且最上面两个IP现在还处于登录状态. 如果你看到任何未经授权的IP,那么请参阅最后章节。 + +登录历史记录会以文本格式记录到 `~/.bash_history`(注:这里作者应该写错了)中,因此很容易被删除。 +通常攻击者会直接把这个文件删掉,以掩盖他们的攻击行为. 因此, 若你运行了 `last` 命令却只看得见你的当前登录,那么这就是个不妙的信号。 + +如果没有登录历史的话,请一定小心,继续留意入侵的其他线索。 + +#### 检查 3 - 回顾命令历史 + +这个层次的攻击者通常不会注意掩盖命令的历史记录,因此运行 `history` 命令会显示出他们曾经做过的所有事情。 +一定留意有没有用 `wget` 或 `curl` 命令来下载类似垃圾邮件机器人或者挖矿程序之类的软件。 + +命令历史存储在 `~/.bash_history` 文件中,因此有些攻击者会删除该文件以掩盖他们的所作所为。 +跟登录历史一样, 若你运行 `history` 命令却没有输出任何东西那就表示历史文件被删掉了. 这也是个不妙的信号,你需要很小心地检查一下服务器了。 + +#### 检查 4 - 哪些进程在消耗CPU? + +你常遇到的这类攻击者通常不怎么会去掩盖他们做的事情. 他们会运行一些特别消耗CPU的进程. 这就很容易发着这些进程了. 只需要运行 `top` 然后看最前的那几个进程就行了。 + +这也能显示出那些未登录的攻击者来. 比如,可能有人在用未受保护的邮件脚本来发送垃圾邮件。 + +如果你最上面的进程对不了解,那么你可以google一下进程名称,或者通过 `losf` 和 `strace` 来看看它做的事情是什么。 + +使用这些工具,第一步从 `top` 中拷贝出进程的 PID,然后运行: + +```shell +strace -p PID + +``` + +这会显示出进程调用的所有系统调用. 它产生的内容会很多,但这些信息能告诉你这个进程在做什么。 + +``` +lsof -p PID + +``` + +这个程序会列出进程打开的文件. 通过查看它访问的文件可以很好的理解它在做的事情。 + +#### 检查 5 - 检查所有的系统进程 + +消耗CPU不严重的未认证进程可能不会在 `top` 中显露出来,不过它依然可以通过 `ps` 列出来. 命令 `ps auxf` 就能显示足够清晰的信息了。 + +你需要检查一下每个不认识的进程. 经常运行 `ps` (这是个好习惯) 能帮助你发现奇怪的进程。 + +#### 检查 6 - 检查进程的网络使用情况 + +`iftop` 的功能类似 `top`,他会显示一系列收发网络数据的进程以及他们的源地址和目的地址。 +类似 `DoS` 攻击或垃圾制造器这样的进程很容易显示在列表的最顶端。 + +#### 检查 7 - 哪些进程在监听网络连接? + +通常攻击者会安装一个后门程序专门监听网络端口接受指令. 该进程等待期间是不会消耗CPU和带宽的,因此也就不容易通过 `top` 之类的命令发现。 + +`lsof` 和 `netstat` 命令都会列出所有的联网进程. 我通常会让他们带上下面这些参数: + +``` +lsof -i + +``` + +``` +netstat -plunt + +``` + +你需要留意那些处于 `LISTEN` 和 `ESTABLISHED` 状态的进程,这些进程要么正在等待连接(LISTEN),要么已经连接(ESTABLISHED)。 +如果遇到不认识的进程,使用 `strace` 和 `lsof` 来看看它们在做什么东西。 + +### 被入侵之后该怎么办呢? + +首先,不要紧张, 尤其当攻击者正处于登陆状态时更不能紧张. 你需要在攻击者警觉到你已经发现他之前夺回机器的控制权。 +如果他发现你已经发觉到他了,那么他可能会锁死你不让你登陆服务器,然后开始毁尸灭迹。 + +如果你技术不太好那么就直接关机吧. 你可以在服务器上运行 `shutdown -h now` 或者 `systemctl poweroff` 这两条命令. 也可以登陆主机提供商的控制面板中关闭服务器。 +关机后,你就可以开始配置防火墙或者咨询一下供应商的意见。 + +如果你对自己颇有自信,而你的主机提供商也有提供上游防火墙,那么你只需要以此创建并启用下面两条规则就行了: + +1. 只允许从你的IP地址登陆SSH + +2. 封禁除此之外的任何东西,不仅仅是SSH,还包括任何端口上的任何协议。 + +这样会立即关闭攻击者的SSH会话,而只留下你访问服务器。 + +如果你无法访问上游防火墙,那么你就需要在服务器本身创建并启用这些防火墙策略,然后在防火墙规则起效后使用 `kill` 命令关闭攻击者的ssh会话。 + +最后还有一种方法, 就是通过诸如串行控制台之类的带外连接登陆服务器,然后通过 `systemctl stop network.service` 停止网络功能。 +这会关闭所有服务器上的网络连接,这样你就可以慢慢的配置那些防火墙规则了。 + +重夺服务器的控制权后,也不要以为就万事大吉了。 + +不要试着修复这台服务器,让后接着用. 你永远不知道攻击者做过什么因此你也永远无法保证这台服务器还是安全的。 + +最好的方法就是拷贝出所有的资料,然后重装系统。 + +-------------------------------------------------------------------------------- + +via: https://bash-prompt.net/guides/server-hacked/ + +作者:[Elliot Cooper][a] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://bash-prompt.net diff --git a/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md b/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md new file mode 100644 index 0000000000..550083bf0a --- /dev/null +++ b/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md @@ -0,0 +1,310 @@ +30 Best Linux Games On Steam You Should Play in 2017 +============================================================ + +Last updated December 4, 2017 By [Ankush Das][1] + + + +When it comes to Gaming, a system running on Windows platform is what anyone would recommend. It still is a superior choice for gamers with better graphics driver support and perfect hardware compatibility. But, what about the thought of [gaming on a Linux system][9]? Well, yes, of course – it is possible – maybe you thought of it at some point in time but the collection of Linux games on [Steam for Linux][10] platform wasn’t appealing at all few years back. + +However, that’s not true at all for the current scene. The Steam store now has a lot of great games listed for Linux platform (including a lot of major titles). So, in this article, we’ll be taking a look at the best Linux games on Steam. + +But before we do that, let me tell you a money saving trick. If you are an avid gamer who spends plenty of time and money on gaming, you should subscribe to Humble Monthly. This monthly subscription program from [Humble Bundle][11] gives you $100 in games for just $12 each month. + +Not all games might be available on Linux though but it is still a good deal because you get additional 10% discount on any games or books you buy from [Humble Bundle website][12]. + +The best thing here is that every purchase you make supports a charity organization. So, you are not just gaming, you are also making a difference to the world. + +### Best Linux games on Steam + +The list of best Linux games on steam is in no particular ranking order. + +Additional Note: While there’s a lot of games available on Steam for Linux, there are still a lot of problems you would face as a Linux gamer. You can refer to one of our articles to know about the [annoying experiences every Linux gamer encounters][14]. + +Jump Directly to your preferred genre of Games: + +* [Action Games][3] + +* [RPG Games][4] + +* [Racing/Sports/Simulation Games][5] + +* [Adventure Games][6] + +* [Indie Games][7] + +* [Strategy Games][8] + +### Best Action Games for Linux On Steam + +### 1\. Counter-Strike: Global Offensive (Multiplayer) + +CS GO is definitely one of the best FPS games for Linux on Steam. I don’t think this game needs an introduction but in case you are unaware of it – I must mention that it is one of the most enjoyable FPS multiplayer game you would ever play. You’ll observe CS GO is one of the games contributing a major part to the e-sports scene. To up your rank – you need to play competitive matches. In either case, you can continue playing casual matches. + +I could have listed Rainbow Six siege instead of Counter-Strike, but we still don’t have it for Linux/Steam OS. + +[CS: GO (Purchase)][15] + +### 2\. Left 4 Dead 2 (Multiplayer/Singleplayer) + +One of the most loved first-person zombie shooter multiplayer game. You may get it for as low as 1.3 USD on a Steam sale. It is an interesting game which gives you the chills and thrills you’d expect from a zombie game. The game features swamps, cities, cemetries, and a lot more environments to keep things interesting and horrific. The guns aren’t super techy but definitely provides a realistic experience considering it’s an old game. + +[Left 4 Dead 2 (Purchase)][16] + +### 3\. Borderlands 2 (Singleplayer/Co-op) + +Borderlands 2 is an interesting take on FPS games for PC. It isn’t anything like you experienced before. The graphics look sketchy and cartoony but that does not let you miss the real action you always look for in a first-person shooter game. You can trust me on that! + +If you are looking for one of the best Linux games with tons of DLC – Borderlands 2 will definitely suffice. + +[Borderlands 2 (Purchase)][17] + +### 4\. Insurgency (Multiplayer) + +Insurgency is yet another impressive FPS game available on Steam for Linux machines. It takes a different approach by eliminating the HUD or the ammo counter. As most of the reviewers mentioned – pure shooting game focusing on the weapon and the tactics of your team. It may not be the best FPS game – but it surely is one of them if you like – Delta Force kinda shooters along with your squad. + +[Insurgency (Purchase)][18] + +### 5\. Bioshock: Infinite (Singleplayer) + +Bioshock Infinite would definitely remain as one of the best singleplayer FPS games ever developed for PC. You get unrealistic powers to kill your enemies. And, so do your enemies have a lot of tricks up in the sleeves. It is a story-rich FPS game which you should not miss playing on your Linux system! + +[BioShock: Infinite (Purchase)][19] + +### 6\. HITMAN – Game of the Year Edition (Singleplayer) + +The Hitman series is obviously one of the most loved game series for a PC gamer. The recent iteration of HITMAN series saw an episodic release which wasn’t appreciated much but now with Square Enix gone, the GOTY edition announced with a few more additions is back to the spotlight. Make sure to get creative with your assassinations in the game Agent 47! + +[HITMAN (GOTY)][20] + +### 7\. Portal 2 + +Portal 2 is the perfect blend of action and adventure. It is a puzzle game which lets you join co-op sessions and create interesting puzzles. The co-op mode features a completely different campaign when compared to the single player mode. + +[Portal 2 (Purchase)][21] + +### 8\. Deux Ex: Mankind Divided + +If you are on the lookout for a shooter game focused on stealth skills – Deux Ex would be the perfect addition to your Steam library. It is indeed a very beautiful game with some state-of-the-art weapons and crazy fighting mechanics. + +[Deus Ex: Mankind Divided (Purchase)][22] + +### 9\. Metro 2033 Redux / Metro Last Light Redux + +Both Metro 2033 Redux and the Last Light are the definitive editions of the classic hit Metro 2033 and Last Light. The game has a post-apocalyptic setting. You need to eliminate all the mutants in order to ensure the survival of mankind. You should explore the rest when you get to play it! + +[Metro 2033 Redux (Purchase)][23] + +[Metro Last Light Redux (Purchase)][24] + +### 10\. Tannenberg (Multiplayer) + +Tannenberg is a brand new game – announced a month before this article was published. The game is based on the Eastern Front (1914-1918) as a part of World War I. It is a multiplayer-only game. So, if you want to experience WWI gameplay experience, look no further! + +[Tannenberg (Purchase)][25] + +### Best RPG Games for Linux on Steam + +### 11\. Shadow of Mordor + +Shadow of Mordor is one of the most exciting open world RPG game you will find listed on Steam for Linux systems. You have to fight as a ranger (Talion) with the bright master (Celebrimbor) to defeat Sauron’s army (and then approach killing him). The fighting mechanics are very impressive. It is a must try game! + +[SOM (Purchase)][26] + +### 12\. Divinity: Original Sin – Enhanced Edition + +Divinity: Original is a kick-ass Indie-RPG game that’s unique in itself and very much enjoyable. It is probably one of the highest rated RPG games with a mixture of Adventure & Strategy. The enhanced edition includes new game modes and a complete revamp of voice-overs, controller support, co-op sessions, and so much more. + +[Divinity: Original Sin (Purchase)][27] + +### 13\. Wasteland 2: Director’s Cut + +Wasteland 2 is an amazing CRPG game. If Fallout 4 was to be ported down as a CRPG as well – this is what we would have expected it to be. The director’s cut edition includes a complete visual overhaul with hundred new characters. + +[Wasteland 2 (Purchase)][28] + +### 14\. Darkwood + +A horror-filled top-down view RPG game. You get to explore the world, scavenging materials, and craft weapons to survive. + +[Darkwood (Purchase)][29] + +### Best Racing/Sports/Simulation Games + +### 15\. Rocket League + +Rocket League is an action-packed soccer game conceptualized by rocket-powered battle cars. Not just driving the car and heading to the goal – you can even make your opponents go – kaboom! + +A fantastic sports-action game every gamer must have installed! + +[Rocket League (Purchase)][30] + +### 16\. Road Redemption + +Missing Road Rash? Well, Road Redemption will quench your thirst as a spiritual successor to Road Rash. Ofcourse, it is not officially “Road Rash II” – but it is equally enjoyable. If you loved Road Rash, you’ll like it too. + +[Road Redemption (Purchase)][31] + +### 17\. Dirt Rally + +Dirt Rally is for the gamers who want to experience off-road and on-road racing game. The visuals are breathtaking and the game is enjoyable with near to perfect driving mechanics. + +[Dirt Rally (Purchase)][32] + +### 18\. F1 2017 + +F1 2017 is yet another impressive car racing game from the developers of Dirt Rally (Codemasters & Feral Interactive). It features all of the iconic F1 racing cars that you need to experience. + +[F1 2017 (Purchase)][33] + +### 19. GRID Autosport + +GRID is one of the most underrated car racing games available out there. GRID Autosport is the sequel to GRID 2\. The gameplay seems stunning to me. With even better cars than GRID 2, the GRID Autosport is a recommended racing game for every PC gamer out there. The game also supports a multiplayer mode where you can play with your friends – representing as a team. + +[GRID Autosport (Purchase)][34] + +### Best Adventure Games + +### 20\. ARK: Survival Evolved + +ARK Survival Evolved is a quite decent survival game with exciting adventures following in the due course. You find yourself in the middle of nowhere (ARK Island) and have got no choice except training the dinosaurs, teaming up with other players, hunt someone to get the required resources, and craft items to maximize your chances to survive and escape the Island. + +[ARK: Survival Evolved (Purchase)][35] + +### 21\. This War of Mine + +A unique game where you aren’t a soldier but a civilian facing the hardships of wartime. You’ve to make your way through highly-skilled enemies and help out other survivors as well. + +[This War of Mine (Purchase)][36] + +### 22\. Mad Max + +Mad Max is all about survival and brutality. It includes powerful cars, an open-world setting, weapons, and hand-to-hand combat. You need to keep exploring the place and also focus on upgrading your vehicle to prepare for the worst. You need to think carefully and have a strategy before you make a decision. + +[Mad Max (Purchase)][37] + +### Best Indie Games + +### 23\. Terraria + +It is a 2D game which has received overwhelmingly positive reviews on Steam. Dig, fight, explore, and build to keep your journey going. The environments are automatically generated. So, it isn’t anything static. You might encounter something first and your friend might encounter the same after a while. You’ll also get to experience creative 2D action-packed sequences. + +[Terraria (Purchase)][38] + +### 24\. Kingdoms and Castles + +With Kingdoms and Castles, you get to build your own kingdom. You have to manage your kingdom by collecting tax (as funds necessary) from the people, take care of the forests, handle the city + +design, and also make sure no one raids your kingdom by implementing proper defences. + +It is a fairly new game but quite trending among the Indie genre of games. + +[Kingdoms and Castles][39] + +### Best Strategy Games on Steam For Linux Machines + +### 25\. Sid Meier’s Civilization V + +Sid Meier’s Civilization V is one of the best-rated strategy game available for PC. You could opt for Civilization VI – if you want. But, the gamers still root for Sid Meier’s Civilization V because of its originality and creative implementation. + +[Civilization V (Purchase)][40] + +### 26\. Total War: Warhammer + +Total War: Warhammer is an incredible turn-based strategy game available for PC. Sadly, the Warhammer II isn’t available for Linux as of yet. But 2016’s Warhammer is still a great choice if you like real-time battles that involve building/destroying empires with flying creatures and magical powers. + +[Warhammer I (Purchase)][41] + +### 27\. Bomber Crew + +Wanted a strategy simulation game that’s equally fun to play? Bomber Crew is the answer to it. You need to choose the right crew and maintain it in order to win it all. + +[Bomber Crew (Purchase)][42] + +### 28\. Age of Wonders III + +A very popular strategy title with a mixture of empire building, role playing, and warfare. A polished turn-based strategy game you must try! + +[Age of Wonders III (Purchase)][43] + +### 29\. Cities: Skylines + +A pretty straightforward strategy game to build a city from scratch and manage everything in it. You’ll experience the thrills and hardships of building and maintaining a city. I wouldn’t expect every gamer to like this game – it has a very specific userbase. + +[Cities: Skylines (Purchase)][44] + +### 30\. XCOM 2 + +XCOM 2 is one of the best turn-based strategy game available for PC. I wonder how crazy it could have been to have XCOM 2 as a first person shooter game. However, it’s still a masterpiece with an overwhelming response from almost everyone who bought the game. If you have the budget to spend more on this game, do get the – “War of the Chosen” – DLC. + +[XCOM 2 (Purchase)][45] + +### Wrapping Up + +Among all the games available for Linux, we did include most of the major titles and some the latest games with an overwhelming response from the gamers. + +Do you think we missed any of your favorite Linux game available on Steam? Also, what are the games that you would like to see on Steam for Linux platform? + +Let us know your thoughts in the comments below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/best-linux-games-steam/ + +作者:[Ankush Das][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://itsfoss.com/author/ankush/ +[1]:https://itsfoss.com/author/ankush/ +[2]:https://itsfoss.com/best-linux-games-steam/#comments +[3]:https://itsfoss.com/best-linux-games-steam/#action +[4]:https://itsfoss.com/best-linux-games-steam/#rpg +[5]:https://itsfoss.com/best-linux-games-steam/#racing +[6]:https://itsfoss.com/best-linux-games-steam/#adv +[7]:https://itsfoss.com/best-linux-games-steam/#indie +[8]:https://itsfoss.com/best-linux-games-steam/#strategy +[9]:https://itsfoss.com/linux-gaming-guide/ +[10]:https://itsfoss.com/install-steam-ubuntu-linux/ +[11]:https://www.humblebundle.com/?partner=itsfoss +[12]:https://www.humblebundle.com/store?partner=itsfoss +[13]:https://www.humblebundle.com/monthly?partner=itsfoss +[14]:https://itsfoss.com/linux-gaming-problems/ +[15]:http://store.steampowered.com/app/730/CounterStrike_Global_Offensive/ +[16]:http://store.steampowered.com/app/550/Left_4_Dead_2/ +[17]:http://store.steampowered.com/app/49520/?snr=1_5_9__205 +[18]:http://store.steampowered.com/app/222880/?snr=1_5_9__205 +[19]:http://store.steampowered.com/agecheck/app/8870/ +[20]:http://store.steampowered.com/app/236870/?snr=1_5_9__205 +[21]:http://store.steampowered.com/app/620/?snr=1_5_9__205 +[22]:http://store.steampowered.com/app/337000/?snr=1_5_9__205 +[23]:http://store.steampowered.com/app/286690/?snr=1_5_9__205 +[24]:http://store.steampowered.com/app/287390/?snr=1_5_9__205 +[25]:http://store.steampowered.com/app/633460/?snr=1_5_9__205 +[26]:http://store.steampowered.com/app/241930/?snr=1_5_9__205 +[27]:http://store.steampowered.com/app/373420/?snr=1_5_9__205 +[28]:http://store.steampowered.com/app/240760/?snr=1_5_9__205 +[29]:http://store.steampowered.com/app/274520/?snr=1_5_9__205 +[30]:http://store.steampowered.com/app/252950/?snr=1_5_9__205 +[31]:http://store.steampowered.com/app/300380/?snr=1_5_9__205 +[32]:http://store.steampowered.com/app/310560/?snr=1_5_9__205 +[33]:http://store.steampowered.com/app/515220/?snr=1_5_9__205 +[34]:http://store.steampowered.com/app/255220/?snr=1_5_9__205 +[35]:http://store.steampowered.com/app/346110/?snr=1_5_9__205 +[36]:http://store.steampowered.com/app/282070/?snr=1_5_9__205 +[37]:http://store.steampowered.com/app/234140/?snr=1_5_9__205 +[38]:http://store.steampowered.com/app/105600/?snr=1_5_9__205 +[39]:http://store.steampowered.com/app/569480/?snr=1_5_9__205 +[40]:http://store.steampowered.com/app/8930/?snr=1_5_9__205 +[41]:http://store.steampowered.com/app/364360/?snr=1_5_9__205 +[42]:http://store.steampowered.com/app/537800/?snr=1_5_9__205 +[43]:http://store.steampowered.com/app/226840/?snr=1_5_9__205 +[44]:http://store.steampowered.com/app/255710/?snr=1_5_9__205 +[45]:http://store.steampowered.com/app/268500/?snr=1_5_9__205 +[46]:https://www.facebook.com/share.php?u=https%3A%2F%2Fitsfoss.com%2Fbest-linux-games-steam%2F%3Futm_source%3Dfacebook%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare +[47]:https://twitter.com/share?original_referer=/&text=30+Best+Linux+Games+On+Steam+You+Should+Play+in+2017&url=https://itsfoss.com/best-linux-games-steam/%3Futm_source%3Dtwitter%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare&via=ankushdas9 +[48]:https://plus.google.com/share?url=https%3A%2F%2Fitsfoss.com%2Fbest-linux-games-steam%2F%3Futm_source%3DgooglePlus%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare +[49]:https://www.linkedin.com/cws/share?url=https%3A%2F%2Fitsfoss.com%2Fbest-linux-games-steam%2F%3Futm_source%3DlinkedIn%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare +[50]:https://www.reddit.com/submit?url=https://itsfoss.com/best-linux-games-steam/&title=30+Best+Linux+Games+On+Steam+You+Should+Play+in+2017 From dc79d8f774a883f0b4ca31a35859dd02aa6ba9b9 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 5 Dec 2017 14:34:35 +0800 Subject: [PATCH 256/344] remove useless file --- ... Your Linux Server Has Been Compromised.md | 163 ------------------ 1 file changed, 163 deletions(-) delete mode 100644 sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md diff --git a/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md b/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md deleted file mode 100644 index 29fe95d868..0000000000 --- a/sources/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md +++ /dev/null @@ -1,163 +0,0 @@ -如何判断Linux服务器是否被入侵 --------------- - -本指南中所谓的服务器被入侵或者说被黑了的意思是指未经认证的人或程序为了自己的目的登录到服务器上去并使用其计算资源, 通常会产生不好的影响。 - -免责声明: 若你的服务器被类似NSA这样的国家机关或者某个犯罪集团如请,那么你并不会发现有任何问题,这些技术也无法发觉他们的存在。 - -然而, 大多数被攻破的服务器都是被类似自动攻击程序这样的程序或者类似“脚本小子”这样的廉价攻击者,以及蠢蛋犯罪所入侵的。 - -这类攻击者会在访问服务器的同时滥用服务器资源,并且不怎么会采取措施来隐藏他们正在做的事情。 - -### 入侵服务器的症状 - -当服务器被没有经验攻击者或者自动攻击程序入侵了的话,他们往往会消耗100%的资源. 他们可能消耗CPU资源来进行数字货币的采矿或者发送垃圾邮件,也可能消耗带宽来发动 `DoS` 攻击。 - -因此出现问题的第一个表现就是服务器 “变慢了”. 这可能表现在网站的页面打开的很慢, 或者电子邮件要花很长时间才能发送出去。 - -那么你应该查看那些东西呢? - -#### 检查 1 - 当前都有谁在登录? - -你首先要查看当前都有谁登录在服务器上. 发现攻击者登录到服务器上进行操作并不罕见。 - -其对应的命令是 `w`. 运行 `w` 会输出如下结果: - -``` - 08:32:55 up 98 days, 5:43, 2 users, load average: 0.05, 0.03, 0.00 -USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT -root pts/0 113.174.161.1 08:26 0.00s 0.03s 0.02s ssh root@coopeaa12 -root pts/1 78.31.109.1 08:26 0.00s 0.01s 0.00s w - -``` - -第一个IP是英国IP,而第二个IP是越南IP. 这个不是个好兆头。 - -停下来做个深呼吸, 不要紧,只需要杀掉他们的SSH连接就好了. Unless you can stop then re-entering the server they will do so quickly and quite likely kick you off and stop you getting back in。 - -请参阅本文最后的 `入侵之后怎么办` 这一章节来看发现被入侵的证据后应该怎么办。 - -`whois` 命令可以接一个IP地址然后告诉你IP注册的组织的所有信息, 当然就包括所在国家的信息。 - -#### 检查 2 - 谁曾经登录过? - -Linux 服务器会记录下哪些用户,从哪个IP,在什么时候登录的以及登陆了多长时间这些信息. 使用 `last` 命令可以查看这些信息。 - -输出类似这样: - -``` -root pts/1 78.31.109.1 Thu Nov 30 08:26 still logged in -root pts/0 113.174.161.1 Thu Nov 30 08:26 still logged in -root pts/1 78.31.109.1 Thu Nov 30 08:24 - 08:26 (00:01) -root pts/0 113.174.161.1 Wed Nov 29 12:34 - 12:52 (00:18) -root pts/0 14.176.196.1 Mon Nov 27 13:32 - 13:53 (00:21) - -``` - -这里可以看到英国IP和越南IP交替出现, 而且最上面两个IP现在还处于登录状态. 如果你看到任何未经授权的IP,那么请参阅最后章节。 - -登录历史记录会以文本格式记录到 `~/.bash_history`(注:这里作者应该写错了)中,因此很容易被删除。 -通常攻击者会直接把这个文件删掉,以掩盖他们的攻击行为. 因此, 若你运行了 `last` 命令却只看得见你的当前登录,那么这就是个不妙的信号。 - -如果没有登录历史的话,请一定小心,继续留意入侵的其他线索。 - -#### 检查 3 - 回顾命令历史 - -这个层次的攻击者通常不会注意掩盖命令的历史记录,因此运行 `history` 命令会显示出他们曾经做过的所有事情。 -一定留意有没有用 `wget` 或 `curl` 命令来下载类似垃圾邮件机器人或者挖矿程序之类的软件。 - -命令历史存储在 `~/.bash_history` 文件中,因此有些攻击者会删除该文件以掩盖他们的所作所为。 -跟登录历史一样, 若你运行 `history` 命令却没有输出任何东西那就表示历史文件被删掉了. 这也是个不妙的信号,你需要很小心地检查一下服务器了。 - -#### 检查 4 - 哪些进程在消耗CPU? - -你常遇到的这类攻击者通常不怎么会去掩盖他们做的事情. 他们会运行一些特别消耗CPU的进程. 这就很容易发着这些进程了. 只需要运行 `top` 然后看最前的那几个进程就行了。 - -这也能显示出那些未登录的攻击者来. 比如,可能有人在用未受保护的邮件脚本来发送垃圾邮件。 - -如果你最上面的进程对不了解,那么你可以google一下进程名称,或者通过 `losf` 和 `strace` 来看看它做的事情是什么。 - -使用这些工具,第一步从 `top` 中拷贝出进程的 PID,然后运行: - -```shell -strace -p PID - -``` - -这会显示出进程调用的所有系统调用. 它产生的内容会很多,但这些信息能告诉你这个进程在做什么。 - -``` -lsof -p PID - -``` - -这个程序会列出进程打开的文件. 通过查看它访问的文件可以很好的理解它在做的事情。 - -#### 检查 5 - 检查所有的系统进程 - -消耗CPU不严重的未认证进程可能不会在 `top` 中显露出来,不过它依然可以通过 `ps` 列出来. 命令 `ps auxf` 就能显示足够清晰的信息了。 - -你需要检查一下每个不认识的进程. 经常运行 `ps` (这是个好习惯) 能帮助你发现奇怪的进程。 - -#### 检查 6 - 检查进程的网络使用情况 - -`iftop` 的功能类似 `top`,他会显示一系列收发网络数据的进程以及他们的源地址和目的地址。 -类似 `DoS` 攻击或垃圾制造器这样的进程很容易显示在列表的最顶端。 - -#### 检查 7 - 哪些进程在监听网络连接? - -通常攻击者会安装一个后门程序专门监听网络端口接受指令. 该进程等待期间是不会消耗CPU和带宽的,因此也就不容易通过 `top` 之类的命令发现。 - -`lsof` 和 `netstat` 命令都会列出所有的联网进程. 我通常会让他们带上下面这些参数: - -``` -lsof -i - -``` - -``` -netstat -plunt - -``` - -你需要留意那些处于 `LISTEN` 和 `ESTABLISHED` 状态的进程,这些进程要么正在等待连接(LISTEN),要么已经连接(ESTABLISHED)。 -如果遇到不认识的进程,使用 `strace` 和 `lsof` 来看看它们在做什么东西。 - -### 被入侵之后该怎么办呢? - -首先,不要紧张, 尤其当攻击者正处于登陆状态时更不能紧张. 你需要在攻击者警觉到你已经发现他之前夺回机器的控制权。 -如果他发现你已经发觉到他了,那么他可能会锁死你不让你登陆服务器,然后开始毁尸灭迹。 - -如果你技术不太好那么就直接关机吧. 你可以在服务器上运行 `shutdown -h now` 或者 `systemctl poweroff` 这两条命令. 也可以登陆主机提供商的控制面板中关闭服务器。 -关机后,你就可以开始配置防火墙或者咨询一下供应商的意见。 - -如果你对自己颇有自信,而你的主机提供商也有提供上游防火墙,那么你只需要以此创建并启用下面两条规则就行了: - -1. 只允许从你的IP地址登陆SSH - -2. 封禁除此之外的任何东西,不仅仅是SSH,还包括任何端口上的任何协议。 - -这样会立即关闭攻击者的SSH会话,而只留下你访问服务器。 - -如果你无法访问上游防火墙,那么你就需要在服务器本身创建并启用这些防火墙策略,然后在防火墙规则起效后使用 `kill` 命令关闭攻击者的ssh会话。 - -最后还有一种方法, 就是通过诸如串行控制台之类的带外连接登陆服务器,然后通过 `systemctl stop network.service` 停止网络功能。 -这会关闭所有服务器上的网络连接,这样你就可以慢慢的配置那些防火墙规则了。 - -重夺服务器的控制权后,也不要以为就万事大吉了。 - -不要试着修复这台服务器,让后接着用. 你永远不知道攻击者做过什么因此你也永远无法保证这台服务器还是安全的。 - -最好的方法就是拷贝出所有的资料,然后重装系统。 - --------------------------------------------------------------------------------- - -via: https://bash-prompt.net/guides/server-hacked/ - -作者:[Elliot Cooper][a] -译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://bash-prompt.net From caa83b13bc5419b1a3f292f02fddaad032210c76 Mon Sep 17 00:00:00 2001 From: Ezio Date: Tue, 5 Dec 2017 15:14:15 +0800 Subject: [PATCH 257/344] =?UTF-8?q?=E5=B0=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...04 30 Best Linux Games On Steam You Should Play in 2017.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md b/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md index 550083bf0a..3248358b37 100644 --- a/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md +++ b/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md @@ -1,10 +1,6 @@ 30 Best Linux Games On Steam You Should Play in 2017 ============================================================ -Last updated December 4, 2017 By [Ankush Das][1] - - - When it comes to Gaming, a system running on Windows platform is what anyone would recommend. It still is a superior choice for gamers with better graphics driver support and perfect hardware compatibility. But, what about the thought of [gaming on a Linux system][9]? Well, yes, of course – it is possible – maybe you thought of it at some point in time but the collection of Linux games on [Steam for Linux][10] platform wasn’t appealing at all few years back. However, that’s not true at all for the current scene. The Steam store now has a lot of great games listed for Linux platform (including a lot of major titles). So, in this article, we’ll be taking a look at the best Linux games on Steam. From 00acb86f2057a974e2ef614fe98e6a09704f3282 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 5 Dec 2017 16:21:28 +0800 Subject: [PATCH 258/344] PRF&PUB:20170215 How to take screenshots on Linux using Scrot.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @zpl1025 由于内容安排,本篇预计发布在下周一。 --- ...o take screenshots on Linux using Scrot.md | 112 ++++++++++-------- 1 file changed, 61 insertions(+), 51 deletions(-) diff --git a/translated/tech/20170215 How to take screenshots on Linux using Scrot.md b/translated/tech/20170215 How to take screenshots on Linux using Scrot.md index 1ddefb37eb..7dd59aeaf4 100644 --- a/translated/tech/20170215 How to take screenshots on Linux using Scrot.md +++ b/translated/tech/20170215 How to take screenshots on Linux using Scrot.md @@ -1,41 +1,27 @@ 如何在 Linux 系统里用 Scrot 截屏 ============================================================ -### 文章主要内容 - -1. [关于 Scrot][12] -2. [安装 Scrot][13] -3. [Scrot 的使用和特点][14] - 1. [获取程序版本][1] - 2. [抓取当前窗口][2] - 3. [抓取选定窗口][3] - 4. [在截屏时包含窗口边框][4] - 5. [延时截屏][5] - 6. [截屏前倒数][6] - 7. [图片质量][7] - 8. [生成缩略图][8] - 9. [拼接多显示器截屏][9] - 10. [在保存截图后执行操作][10] - 11. [特殊字符串][11] -4. [结论][15] - -最近,我们介绍过 [gnome-screenshot][17] 工具,这是一个很优秀的屏幕抓取工具。但如果你想找一个在命令行运行的更好用的截屏工具,你一定要试试 Scrot。这个工具有一些 gnome-screenshot 没有的独特功能。在这片文章里,我们会通过简单易懂的例子来详细介绍 Scrot。 +最近,我们介绍过 [gnome-screenshot][17] 工具,这是一个很优秀的屏幕抓取工具。但如果你想找一个在命令行运行的更好用的截屏工具,你一定要试试 Scrot。这个工具有一些 gnome-screenshot 没有的独特功能。在这篇文章里,我们会通过简单易懂的例子来详细介绍 Scrot。 请注意一下,这篇文章里的所有例子都在 Ubuntu 16.04 LTS 上测试过,我们用的 scrot 版本是 0.8。 ### 关于 Scrot -[Scrot][18] (**SCR**eensh**OT**) 是一个屏幕抓取工具,使用 imlib2 库来获取和保存图片。由 Tom Gilbert 用 C 语言开发完成,通过 BSD 协议授权。 +[Scrot][18] (**SCR**eensh**OT**) 是一个屏幕抓取工具,使用 imlib2 库来获取和保存图片。由 Tom Gilbert 用 C 语言开发完成,通过 BSD 协议授权。 ### 安装 Scrot scort 工具可能在你的 Ubuntu 系统里预装了,不过如果没有的话,你可以用下面的命令安装: +``` sudo apt-get install scrot +``` 安装完成后,你可以通过下面的命令来使用: +``` scrot [options] [filename] +``` **注意**:方括号里的参数是可选的。 @@ -51,13 +37,17 @@ scrot [options] [filename] 默认情况下,抓取的截图会用带时间戳的文件名保存到当前目录下,不过你也可以在运行命令时指定截图文件名。比如: +``` scrot [image-name].png +``` ### 获取程序版本 -你想的话,可以用 -v 选项来查看 scrot 的版本。 +你想的话,可以用 `-v` 选项来查看 scrot 的版本。 +``` scrot -v +``` 这是例子: @@ -67,10 +57,11 @@ scrot -v ### 抓取当前窗口 -这个工具可以限制抓取当前的焦点窗口。这个功能可以通过 -u 选项打开。 +这个工具可以限制抓取当前的焦点窗口。这个功能可以通过 `-u` 选项打开。 +``` scrot -u - +``` 例如,这是我在命令行执行上边命令时的桌面: [ @@ -85,9 +76,11 @@ scrot -u ### 抓取选定窗口 -这个工具还可以让你抓取任意用鼠标点击的窗口。这个功能可以用 -s 选项打开。 +这个工具还可以让你抓取任意用鼠标点击的窗口。这个功能可以用 `-s` 选项打开。 +``` scrot -s +``` 例如,在下面的截图里你可以看到,我有两个互相重叠的终端窗口。我在上层的窗口里执行上面的命令。 @@ -95,7 +88,7 @@ scrot -s ![选择窗口](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/select1.png) ][23] -现在假如我想抓取下层的终端窗口。这样我只要在执行命令后点击窗口就可以了 - 在你用鼠标点击之前,命令的执行不会结束。 +现在假如我想抓取下层的终端窗口。这样我只要在执行命令后点击窗口就可以了 —— 在你用鼠标点击之前,命令的执行不会结束。 这是我点击了下层终端窗口后的截图: @@ -107,9 +100,11 @@ scrot -s ### 在截屏时包含窗口边框 -我们之前介绍的 -u 选项在截屏时不会包含窗口边框。不过,需要的话你也可以在截屏时包含窗口边框。这个功能可以通过 -b 选项打开(当然要和 -u 选项一起)。 +我们之前介绍的 `-u` 选项在截屏时不会包含窗口边框。不过,需要的话你也可以在截屏时包含窗口边框。这个功能可以通过 `-b` 选项打开(当然要和 `-u` 选项一起)。 +``` scrot -ub +``` 下面是示例截图: @@ -121,11 +116,13 @@ scrot -ub ### 延时截屏 -你可以在开始截屏时增加一点延时。需要在 --delay 或 -d 选项后设定一个时间值参数。 +你可以在开始截屏时增加一点延时。需要在 `--delay` 或 `-d` 选项后设定一个时间值参数。 +``` scrot --delay [NUM] scrot --delay 5 +``` 例如: @@ -137,11 +134,13 @@ scrot --delay 5 ### 截屏前倒数 -这个工具也可以在你使用延时功能后显示一个倒计时。这个功能可以通过 -c 选项打开。 +这个工具也可以在你使用延时功能后显示一个倒计时。这个功能可以通过 `-c` 选项打开。 +``` scrot –delay [NUM] -c scrot -d 5 -c +``` 下面是示例截图: @@ -153,11 +152,13 @@ scrot -d 5 -c 你可以使用这个工具来调整截图的图片质量,范围是 1-100 之间。较大的值意味着更大的文件大小以及更低的压缩率。默认值是 75,不过最终效果根据选择的文件类型也会有一些差异。 -这个功能可以通过 --quality 或 -q 选项打开,但是你必须提供一个 1-100 之间的数值作为参数。 +这个功能可以通过 `--quality` 或 `-q` 选项打开,但是你必须提供一个 1 - 100 之间的数值作为参数。 +``` scrot –quality [NUM] scrot –quality 10 +``` 下面是示例截图: @@ -165,17 +166,19 @@ scrot –quality 10 ![截屏质量](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/img-quality.jpg) ][28] -你可以看到,-q 选项的参数更靠近 1 让图片质量下降了很多。 +你可以看到,`-q` 选项的参数更靠近 1 让图片质量下降了很多。 ### 生成缩略图 -scort 工具还可以生成截屏的缩略图。这个功能可以通过 --thumb 选项打开。这个选项也需要一个 NUM 数值作为参数,基本上是指定原图大小的百分比。 +scort 工具还可以生成截屏的缩略图。这个功能可以通过 `--thumb` 选项打开。这个选项也需要一个 NUM 数值作为参数,基本上是指定原图大小的百分比。 +``` scrot --thumb NUM scrot --thumb 50 +``` -**注意**:加上 --thumb 选项也会同时保存原始截图文件。 +**注意**:加上 `--thumb` 选项也会同时保存原始截图文件。 例如,下面是我测试的原始截图: @@ -191,9 +194,11 @@ scrot --thumb 50 ### 拼接多显示器截屏 -如果你的电脑接了多个显示设备,你可以用 scort 抓取并拼接这些显示设备的截图。这个功能可以通过 -m 选项打开。 +如果你的电脑接了多个显示设备,你可以用 scort 抓取并拼接这些显示设备的截图。这个功能可以通过 `-m` 选项打开。 +``` scrot -m +``` 下面是示例截图: @@ -203,9 +208,11 @@ scrot -m ### 在保存截图后执行操作 -使用这个工具,你可以在保存截图后执行各种操作 - 例如,用像 gThumb 这样的图片编辑器打开截图。这个功能可以通过 -e 选项打开。下面是例子: +使用这个工具,你可以在保存截图后执行各种操作 —— 例如,用像 gThumb 这样的图片编辑器打开截图。这个功能可以通过 `-e` 选项打开。下面是例子: -scrot abc.png -e ‘gthumb abc.png’ +``` +scrot abc.png -e 'gthumb abc.png' +``` 这个命令里的 gthumb 是一个图片编辑器,上面的命令在执行后会自动打开。 @@ -223,29 +230,33 @@ scrot abc.png -e ‘gthumb abc.png’ 你可以看到 scrot 抓取了屏幕截图,然后再启动了 gThumb 图片编辑器打开刚才保存的截图图片。 -如果你截图时没有指定文件名,截图将会用带有时间戳的文件名保存到当前目录 - 这是 scrot 的默认设定,我们前面已经说过。 +如果你截图时没有指定文件名,截图将会用带有时间戳的文件名保存到当前目录 —— 这是 scrot 的默认设定,我们前面已经说过。 -下面是一个使用默认名字并且加上 -e 选项来截图的例子: +下面是一个使用默认名字并且加上 `-e` 选项来截图的例子: -scrot -e ‘gthumb $n’ +``` +scrot -e 'gthumb $n' +``` [ ![scrot 截屏后运行 gthumb](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/exec3.png) ][34] -有个地方要注意的是 $n 是一个特殊字符串,用来获取当前截图的文件名。关于特殊字符串的更多细节,请继续看下个小节。 +有个地方要注意的是 `$n` 是一个特殊字符串,用来获取当前截图的文件名。关于特殊字符串的更多细节,请继续看下个小节。 ### 特殊字符串 -scrot 的 -e(或 --exec)选项和文件名参数可以使用格式说明符。有两种类型格式。第一种是以 '%' 加字母组成,用来表示日期和时间,第二种以 '$' 开头,scrot 内部使用。 +scrot 的 `-e`(或 `--exec`)选项和文件名参数可以使用格式说明符。有两种类型格式。第一种是以 `%` 加字母组成,用来表示日期和时间,第二种以 `$` 开头,scrot 内部使用。 -下面介绍几个 --exec 和文件名参数接受的说明符。 +下面介绍几个 `--exec` 和文件名参数接受的说明符。 -**$f** – 让你可以使用截图的全路径(包括文件名)。 +`$f` – 让你可以使用截图的全路径(包括文件名)。 -例如 +例如: +``` scrot ashu.jpg -e ‘mv $f ~/Pictures/Scrot/ashish/’ +``` 下面是示例截图: @@ -253,17 +264,19 @@ scrot ashu.jpg -e ‘mv $f ~/Pictures/Scrot/ashish/’ ![示例](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/f.png) ][35] -如果你没有指定文件名,scrot 默认会用日期格式的文件名保存截图。这个是 scrot 的默认文件名格式:%yy-%mm-%dd-%hhmmss_$wx$h_scrot.png。 +如果你没有指定文件名,scrot 默认会用日期格式的文件名保存截图。这个是 scrot 的默认文件名格式:`%yy-%mm-%dd-%hhmmss_$wx$h_scrot.png`。 -**$n** – 提供截图文件名。下面是示例截图: +`$n` – 提供截图文件名。下面是示例截图: [ ![scrot $n variable](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/n.png) ][36] -**$s** – 获取截图的文件大小。这个功能可以像下面这样使用。 +`$s` – 获取截图的文件大小。这个功能可以像下面这样使用。 +``` scrot abc.jpg -e ‘echo $s’ +``` 下面是示例截图: @@ -271,22 +284,19 @@ scrot abc.jpg -e ‘echo $s’ ![scrot $s 变量](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/s.png) ][37] -类似的,你也可以使用其他格式字符串 **$p**, **$w**, **$h**, **$t**, **$$** 以及 **\n** 来分别获取图片像素大小,图像宽度,图像高度,图像格式,输入 $ 字符,以及换行。你可以像上面介绍的 **$s** 格式那样使用这些字符串。 +类似的,你也可以使用其他格式字符串 `$p`、`$w`、 `$h`、`$t`、`$$` 以及 `\n` 来分别获取图片像素大小、图像宽度、图像高度、图像格式、输入 `$` 字符、以及换行。你可以像上面介绍的 `$s` 格式那样使用这些字符串。 ### 结论 这个应用能轻松地安装在 Ubuntu 系统上,对初学者比较友好。scrot 也提供了一些高级功能,比如支持格式化字符串,方便专业用户用脚本处理。当然,如果你想用起来的话有一点轻微的学习曲线。 - ![](https://www.howtoforge.com/images/pdficon_small.png) - [vie][16] - -------------------------------------------------------------------------------- via: https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/ 作者:[Himanshu Arora][a] 译者:[zpl1025](https://github.com/zpl1025) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 29d62751dd3511ce61617ac7481a82369d6943ca Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 5 Dec 2017 16:21:57 +0800 Subject: [PATCH 259/344] PRF&PUB:20170910 Cool vim feature sessions.md @geekpi https://linux.cn/article-9112-1.html --- translated/tech/20170910 Cool vim feature sessions.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/translated/tech/20170910 Cool vim feature sessions.md b/translated/tech/20170910 Cool vim feature sessions.md index 49ee43fda1..7855bc6ea0 100644 --- a/translated/tech/20170910 Cool vim feature sessions.md +++ b/translated/tech/20170910 Cool vim feature sessions.md @@ -1,5 +1,5 @@ vim 的酷功能:会话! -============================================================• +============================================================ 昨天我在编写我的[vimrc][5]的时候了解到一个很酷的 vim 功能!(主要为了添加 fzf 和 ripgrep 插件)。这是一个内置功能,不需要特别的插件。 @@ -17,9 +17,7 @@ vim 的酷功能:会话! 一些 vim 插件给 vim 会话添加了额外的功能: * [https://github.com/tpope/vim-obsession][1] - * [https://github.com/mhinz/vim-startify][2] - * [https://github.com/xolox/vim-session][3] 这是漫画: @@ -30,9 +28,9 @@ vim 的酷功能:会话! via: https://jvns.ca/blog/2017/09/10/vim-sessions/ -作者:[Julia Evans ][a] +作者:[Julia Evans][a] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 870b32c2959fc8e92ec0eee9e7a749878c72d0a7 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Tue, 5 Dec 2017 17:05:22 +0800 Subject: [PATCH 260/344] Translated by qhwdw --- ...sers guide to Logical Volume Management.md | 233 ------------------ ...sers guide to Logical Volume Management.md | 167 +++++++++++++ 2 files changed, 167 insertions(+), 233 deletions(-) delete mode 100644 sources/tech/20160922 A Linux users guide to Logical Volume Management.md create mode 100644 translated/tech/20160922 A Linux users guide to Logical Volume Management.md diff --git a/sources/tech/20160922 A Linux users guide to Logical Volume Management.md b/sources/tech/20160922 A Linux users guide to Logical Volume Management.md deleted file mode 100644 index ff0e390f38..0000000000 --- a/sources/tech/20160922 A Linux users guide to Logical Volume Management.md +++ /dev/null @@ -1,233 +0,0 @@ -A Linux user's guide to Logical Volume Management -============================================================ - -![Logical Volume Management (LVM)](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_other11x_cc.png?itok=I_kCDYj0 "Logical Volume Management (LVM)") -Image by : opensource.com - -Managing disk space has always been a significant task for sysadmins. Running out of disk space used to be the start of a long and complex series of tasks to increase the space available to a disk partition. It also required taking the system off-line. This usually involved installing a new hard drive, booting to recovery or single-user mode, creating a partition and a filesystem on the new hard drive, using temporary mount points to move the data from the too-small filesystem to the new, larger one, changing the content of the /etc/fstab file to reflect the correct device name for the new partition, and rebooting to remount the new filesystem on the correct mount point. - -I have to tell you that, when LVM (Logical Volume Manager) first made its appearance in Fedora Linux, I resisted it rather strongly. My initial reaction was that I did not need this additional layer of abstraction between me and the hard drives. It turns out that I was wrong, and that logical volume management is very useful. - -LVM allows for very flexible disk space management. It provides features like the ability to add disk space to a logical volume and its filesystem while that filesystem is mounted and active and it allows for the collection of multiple physical hard drives and partitions into a single volume group which can then be divided into logical volumes. - -The volume manager also allows reducing the amount of disk space allocated to a logical volume, but there are a couple requirements. First, the volume must be unmounted. Second, the filesystem itself must be reduced in size before the volume on which it resides can be reduced. - -It is important to note that the filesystem itself must allow resizing for this feature to work. The EXT2, 3, and 4 filesystems all allow both offline (unmounted) and online (mounted) resizing when increasing the size of a filesystem, and offline resizing when reducing the size. You should check the details of the filesystems you intend to use in order to verify whether they can be resized at all and especially whether they can be resized while online. - -### Expanding a filesystem on the fly - -I always like to run new distributions in a VirtualBox virtual machine for a few days or weeks to ensure that I will not run into any devastating problems when I start installing it on my production machines. One morning a couple years ago I started installing a newly released version of Fedora in a virtual machine on my primary workstation. I thought that I had enough disk space allocated to the host filesystem in which the VM was being installed. I did not. About a third of the way through the installation I ran out of space on that filesystem. Fortunately, VirtualBox detected the out-of-space condition and paused the virtual machine, and even displayed an error message indicating the exact cause of the problem. - -Note that this problem was not due to the fact that the virtual disk was too small, it was rather the logical volume on the host computer that was running out of space so that the virtual disk belonging to the virtual machine did not have enough space to expand on the host's logical volume. - -Since most modern distributions use Logical Volume Management by default, and I had some free space available on the volume group, I was able to assign additional disk space to the appropriate logical volume and then expand filesystem of the host on the fly. This means that I did not have to reformat the entire hard drive and reinstall the operating system or even reboot. I simply assigned some of the available space to the appropriate logical volume and resized the filesystem—all while the filesystem was on-line and the running program, The virtual machine was still using the host filesystem. After resizing the logical volume and the filesystem I resumed running the virtual machine and the installation continued as if no problems had occurred. - -Although this type of problem may never have happened to you, running out of disk space while a critical program is running has happened to many people. And while many programs, especially Windows programs, are not as well written and resilient as VirtualBox, Linux Logical Volume Management made it possible to recover without losing any data and without having to restart the time-consuming installation. - -### LVM Structure - -The structure of a Logical Volume Manager disk environment is illustrated by Figure 1, below. Logical Volume Management enables the combining of multiple individual hard drives and/or disk partitions into a single volume group (VG). That volume group can then be subdivided into logical volumes (LV) or used as a single large volume. Regular file systems, such as EXT3 or EXT4, can then be created on a logical volume. - -In Figure 1, two complete physical hard drives and one partition from a third hard drive have been combined into a single volume group. Two logical volumes have been created from the space in the volume group, and a filesystem, such as an EXT3 or EXT4 filesystem has been created on each of the two logical volumes. - -![lvm.png](https://opensource.com/sites/default/files/resize/images/life-uploads/lvm-520x222.png) - - _Figure 1: LVM allows combining partitions and entire hard drives into Volume Groups._ - -Adding disk space to a host is fairly straightforward but, in my experience, is done relatively infrequently. The basic steps needed are listed below. You can either create an entirely new volume group or you can add the new space to an existing volume group and either expand an existing logical volume or create a new one. - -### Adding a new logical volume - -There are times when it is necessary to add a new logical volume to a host. For example, after noticing that the directory containing virtual disks for my VirtualBox virtual machines was filling up the /home filesystem, I decided to create a new logical volume in which to store the virtual machine data, including the virtual disks. This would free up a great deal of space in my /home filesystem and also allow me to manage the disk space for the VMs independently. - -The basic steps for adding a new logical volume are as follows. - -1. If necessary, install a new hard drive. - -2. Optional: Create a partition on the hard drive. - -3. Create a physical volume (PV) of the complete hard drive or a partition on the hard drive. - -4. Assign the new physical volume to an existing volume group (VG) or create a new volume group. - -5. Create a new logical volumes (LV) from the space in the volume group. - -6. Create a filesystem on the new logical volume. - -7. Add appropriate entries to /etc/fstab for mounting the filesystem. - -8. Mount the filesystem. - -Now for the details. The following sequence is taken from an example I used as a lab project when teaching about Linux filesystems. - -### Example - -This example shows how to use the CLI to extend an existing volume group to add more space to it, create a new logical volume in that space, and create a filesystem on the logical volume. This procedure can be performed on a running, mounted filesystem. - -WARNING: Only the EXT3 and EXT4 filesystems can be resized on the fly on a running, mounted filesystem. Many other filesystems including BTRFS and ZFS cannot be resized. - -### Install hard drive - -If there is not enough space in the volume group on the existing hard drive(s) in the system to add the desired amount of space it may be necessary to add a new hard drive and create the space to add to the Logical Volume. First, install the physical hard drive, and then perform the following steps. - -### Create Physical Volume from hard drive - -It is first necessary to create a new Physical Volume (PV). Use the command below, which assumes that the new hard drive is assigned as /dev/hdd. - -``` -pvcreate /dev/hdd -``` - -It is not necessary to create a partition of any kind on the new hard drive. This creation of the Physical Volume which will be recognized by the Logical Volume Manager can be performed on a newly installed raw disk or on a Linux partition of type 83\. If you are going to use the entire hard drive, creating a partition first does not offer any particular advantages and uses disk space for metadata that could otherwise be used as part of the PV. - -### Extend the existing Volume Group - -In this example we will extend an existing volume group rather than creating a new one; you can choose to do it either way. After the Physical Volume has been created, extend the existing Volume Group (VG) to include the space on the new PV. In this example the existing Volume Group is named MyVG01. - -``` -vgextend /dev/MyVG01 /dev/hdd -``` - -### Create the Logical Volume - -First create the Logical Volume (LV) from existing free space within the Volume Group. The command below creates a LV with a size of 50GB. The Volume Group name is MyVG01 and the Logical Volume Name is Stuff. - -``` -lvcreate -L +50G --name Stuff MyVG01 -``` - -### Create the filesystem - -Creating the Logical Volume does not create the filesystem. That task must be performed separately. The command below creates an EXT4 filesystem that fits the newly created Logical Volume. - -``` -mkfs -t ext4 /dev/MyVG01/Stuff -``` - -### Add a filesystem label - -Adding a filesystem label makes it easy to identify the filesystem later in case of a crash or other disk related problems. - -``` -e2label /dev/MyVG01/Stuff Stuff -``` - -### Mount the filesystem - -At this point you can create a mount point, add an appropriate entry to the /etc/fstab file, and mount the filesystem. - -You should also check to verify the volume has been created correctly. You can use the **df**, **lvs,** and **vgs** commands to do this. - -### Resizing a logical volume in an LVM filesystem - -The need to resize a filesystem has been around since the beginning of the first versions of Unix and has not gone away with Linux. It has gotten easier, however, with Logical Volume Management. - -1. If necessary, install a new hard drive. - -2. Optional: Create a partition on the hard drive. - -3. Create a physical volume (PV) of the complete hard drive or a partition on the hard drive. - -4. Assign the new physical volume to an existing volume group (VG) or create a new volume group. - -5. Create one or more logical volumes (LV) from the space in the volume group, or expand an existing logical volume with some or all of the new space in the volume group. - -6. If you created a new logical volume, create a filesystem on it. If adding space to an existing logical volume, use the resize2fs command to enlarge the filesystem to fill the space in the logical volume. - -7. Add appropriate entries to /etc/fstab for mounting the filesystem. - -8. Mount the filesystem. - -### Example - -This example describes how to resize an existing Logical Volume in an LVM environment using the CLI. It adds about 50GB of space to the /Stuff filesystem. This procedure can be used on a mounted, live filesystem only with the Linux 2.6 Kernel (and higher) and EXT3 and EXT4 filesystems. I do not recommend that you do so on any critical system, but it can be done and I have done so many times; even on the root (/) filesystem. Use your judgment. - -WARNING: Only the EXT3 and EXT4 filesystems can be resized on the fly on a running, mounted filesystem. Many other filesystems including BTRFS and ZFS cannot be resized. - -### Install the hard drive - -If there is not enough space on the existing hard drive(s) in the system to add the desired amount of space it may be necessary to add a new hard drive and create the space to add to the Logical Volume. First, install the physical hard drive and then perform the following steps. - -### Create a Physical Volume from the hard drive - -It is first necessary to create a new Physical Volume (PV). Use the command below, which assumes that the new hard drive is assigned as /dev/hdd. - -``` -pvcreate /dev/hdd -``` - -It is not necessary to create a partition of any kind on the new hard drive. This creation of the Physical Volume which will be recognized by the Logical Volume Manager can be performed on a newly installed raw disk or on a Linux partition of type 83\. If you are going to use the entire hard drive, creating a partition first does not offer any particular advantages and uses disk space for metadata that could otherwise be used as part of the PV. - -### Add PV to existing Volume Group - -For this example, we will use the new PV to extend an existing Volume Group. After the Physical Volume has been created, extend the existing Volume Group (VG) to include the space on the new PV. In this example, the existing Volume Group is named MyVG01. - -``` -vgextend /dev/MyVG01 /dev/hdd -``` - -### Extend the Logical Volume - -Extend the Logical Volume (LV) from existing free space within the Volume Group. The command below expands the LV by 50GB. The Volume Group name is MyVG01 and the Logical Volume Name is Stuff. - -``` -lvextend -L +50G /dev/MyVG01/Stuff -``` - -### Expand the filesystem - -Extending the Logical Volume will also expand the filesystem if you use the -r option. If you do not use the -r option, that task must be performed separately. The command below resizes the filesystem to fit the newly resized Logical Volume. - -``` -resize2fs /dev/MyVG01/Stuff -``` - -You should check to verify the resizing has been performed correctly. You can use the **df**, **lvs,** and **vgs** commands to do this. - -### Tips - -Over the years I have learned a few things that can make logical volume management even easier than it already is. Hopefully these tips can prove of some value to you. - -* Use the Extended file systems unless you have a clear reason to use another filesystem. Not all filesystems support resizing but EXT2, 3, and 4 do. The EXT filesystems are also very fast and efficient. In any event, they can be tuned by a knowledgeable sysadmin to meet the needs of most environments if the defaults tuning parameters do not. - -* Use meaningful volume and volume group names. - -* Use EXT filesystem labels. - -I know that, like me, many sysadmins have resisted the change to Logical Volume Management. I hope that this article will encourage you to at least try LVM. I am really glad that I did; my disk management tasks are much easier since I made the switch. - - -### About the author - - [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/david-crop.jpg?itok=oePpOpyV)][10] - - David Both - David Both is a Linux and Open Source advocate who resides in Raleigh, North Carolina. He has been in the IT industry for over forty years and taught OS/2 for IBM where he worked for over 20 years. While at IBM, he wrote the first training course for the original IBM PC in 1981\. He has taught RHCE classes for Red Hat and has worked at MCI Worldcom, Cisco, and the State of North Carolina. He has been working with Linux and Open Source Software for almost 20 years. David has written articles for... [more about David Both][7][More about me][8] - --------------------------------------------------------------------------------- - -via: https://opensource.com/business/16/9/linux-users-guide-lvm - -作者:[ David Both][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/dboth -[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[6]:https://opensource.com/business/16/9/linux-users-guide-lvm?rate=79vf1js7A7rlp-I96YFneopUQqsa2SuB-g-og7eiF1U -[7]:https://opensource.com/users/dboth -[8]:https://opensource.com/users/dboth -[9]:https://opensource.com/user/14106/feed -[10]:https://opensource.com/users/dboth -[11]:https://opensource.com/users/dboth -[12]:https://opensource.com/users/dboth -[13]:https://opensource.com/business/16/9/linux-users-guide-lvm#comments -[14]:https://opensource.com/tags/business -[15]:https://opensource.com/tags/linux -[16]:https://opensource.com/tags/how-tos-and-tutorials -[17]:https://opensource.com/tags/sysadmin diff --git a/translated/tech/20160922 A Linux users guide to Logical Volume Management.md b/translated/tech/20160922 A Linux users guide to Logical Volume Management.md new file mode 100644 index 0000000000..18b42e9e69 --- /dev/null +++ b/translated/tech/20160922 A Linux users guide to Logical Volume Management.md @@ -0,0 +1,167 @@ +Linux 用户的逻辑卷管理指南 +============================================================ + +![Logical Volume Management (LVM)](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_other11x_cc.png?itok=I_kCDYj0 "Logical Volume Management (LVM)") +Image by : opensource.com + +管理磁盘空间对系统管理员来说是一件重要的日常工作。因为磁盘空间耗尽而去启动一系列的耗时而又复杂的任务,来提升磁盘分区中可用的磁盘空间。它会要求系统离线。通常会涉及到安装一个新的硬盘、引导至恢复模式或者单用户模式、在新硬盘上创建一个分区和一个文件系统、挂载到临时挂载点去从一个太小的文件系统中移动数据到较大的新位置、修改 /etc/fstab 文件内容去反映出新分区的正确设备名、以及重新引导去重新挂载新的文件系统到正确的挂载点。 + +我想告诉你的是,当 LVM (逻辑卷管理)首次出现在 Fedora Linux 中时,我是非常抗拒它的。我最初的反应是,我并不需要在我和我的设备之间有这种额外的抽象层。结果是我错了,逻辑卷管理是非常有用的。 + +LVM 让磁盘空间管理非常灵活。它提供的功能诸如在文件系统已挂载和活动时,很可靠地增加磁盘空间到一个逻辑卷和它的文件系统中,并且,它允许你将多个物理磁盘和分区融合进一个可以分割成逻辑卷的单个卷组中。 + +卷管理也允许你去减少分配给一个逻辑卷的磁盘空间数量,但是,这里有两个要求,第一,卷必须是未挂载的。第二,在卷空间调整之前,文件系统本身的空间大小必须被减少。 + +有一个重要的提示是,文件系统本身必须允许重新调整大小的操作。当重新提升文件系统大小的时候,EXT2、3、和 4 文件系统都允许离线(未挂载状态)或者在线(挂载状态)重新调整大小。你应该去认真了解你打算去调整的文件系统的详细情况,去验证它们是否可以完全调整大小,尤其是否可以在线调整大小。 + +### 在使用中扩展一个文件系统 + +在我安装一个新的发行版到我的生产用机器中之前,我总是喜欢在一个 VirtualBox 虚拟机中运行这个新的发行版一段时间,以确保它没有任何的致命的问题存在。在几年前的一个早晨,我在我的主要使用的工作站上的虚拟机中安装一个新发行的 Fedora 版本。我认为我有足够的磁盘空间分配给安装虚拟机的主文件系统。但是,我错了,大约在第三个安装时,我耗尽了我的文件系统的空间。幸运的是,VirtualBox 检测到了磁盘空间不足的状态,并且暂停了虚拟机,然后显示了一个明确指出问题所在的错误信息。 + +请注意,这个问题并不是虚拟机磁盘太小造成的,而是由于宿主机上空间不足,导致虚拟机上的虚拟磁盘在宿主机上的逻辑卷中没有足够的空间去扩展。 + +因为许多现在的发行版都缺省使用了逻辑卷管理,并且在我的卷组中有一些可用的空余空间,我可以分配额外的磁盘空间到适当的逻辑卷,然后在使用中扩展宿主机的文件系统。这意味着我不需要去重新格式化整个硬盘,以及重新安装操作系统或者甚至是重启机器。我不过是分配了一些可用空间到适当的逻辑卷中,并且重新调整了文件系统的大小 — 所有的这些操作都在文件系统在线并且运行着程序的状态下进行的,虚拟机也一直使用着宿主机文件系统。在调整完逻辑卷和文件系统的大小之后,我恢复了虚拟机的运行,并且继续进行安装过程,就像什么问题都没有发生过一样。 + +虽然这种问题你可能从来也没有遇到过,但是,许多人都遇到过重要程序在运行过程中发生磁盘空间不足的问题。而且,虽然许多程序,尤其是 Windows 程序,并不像 VirtualBox 一样写的很好,且富有弹性,Linux 逻辑卷管理可以使它在不丢失数据的情况下去恢复,也不需要去进行耗时的安装过程。 + +### LVM 结构 + +逻辑卷管理的磁盘环境结构如下面的图 1 所示。逻辑卷管理允许多个单独的硬盘和/或磁盘分区组合成一个单个的卷组(VG)。卷组然后可以再划分为逻辑卷(LV)或者被用于分配成一个大的单一的卷。普通的文件系统,如EXT3 或者 EXT4,可以创建在一个逻辑卷上。 + +在图 1 中,两个完整的物理硬盘和一个第三块硬盘的一个分区组合成一个单个的卷组。在这个卷组中创建了两个逻辑卷,和一个文件系统,比如,可以在每个逻辑卷上创建一个 EXT3 或者 EXT4 的文件系统。 + +![lvm.png](https://opensource.com/sites/default/files/resize/images/life-uploads/lvm-520x222.png) + + _图 1: LVM 允许组合分区和整个硬盘到卷组中_ + +在一个主机上增加磁盘空间是非常简单的,在我的经历中,这种事情是很少的。下面列出了基本的步骤。你也可以创建一个完整的新卷组或者增加新的空间到一个已存在的逻辑卷中,或者创建一个新的逻辑卷。 + +### 增加一个新的逻辑卷 + +有时候需要在主机上增加一个新的逻辑卷。例如,在被提示包含我的 VirtualBox 虚拟机的虚拟磁盘的 /home 文件系统被填满时,我决定去创建一个新的逻辑卷,用于去存储虚拟机数据,包含虚拟磁盘。这将在我的 /home 文件系统中释放大量的空间,并且也允许我去独立地管理虚拟机的磁盘空间。 + +增加一个新的逻辑卷的基本步骤如下: + +1. 如有需要,安装一个新硬盘。 + +2. 可选 1: 在硬盘上创建一个分区 + +3. 在硬盘上创建一个完整的物理卷(PV)或者一个分区。 + +4. 分配新的物理卷到一个已存在的卷组(VG)中,或者创建一个新的卷组。 + +5. 从卷空间中创建一个新的逻辑卷(LV)。 + +6. 在新的逻辑卷中创建一个文件系统。 + +7. 在 /etc/fstab 中增加适当的条目以挂载文件系统。 + +8. 挂载文件系统。 + +为了更详细的介绍,接下来将使用一个示例作为一个实验去教授关于 Linux 文件系统的知识。 + +### 示例 + +这个示例展示了怎么用命令行去扩展一个已存在的卷组,并给它增加更多的空间,在那个空间上创建一个新的逻辑卷,然后在逻辑卷上创建一个文件系统。这个过程一直在运行和挂载的文件系统上执行。 + +警告:仅 EXT3 和 EXT4 文件系统可以在运行和挂载状态下调整大小。许多其它的文件系统,包括 BTRFS 和 ZFS 是不能这样做的。 + +### 安装硬盘 + +如果在系统中现有硬盘上的卷组中没有足够的空间去增加,那么可能需要去增加一块新的硬盘,然后去创建空间增加到逻辑卷中。首先,安装物理硬盘,然后,接着执行后面的步骤。 + +### 从硬盘上创建物理卷 + +首先需要去创建一个新的物理卷(PV)。使用下面的命令,它假设新硬盘已经分配为 /dev/hdd。 + +``` +pvcreate /dev/hdd +``` + +在新硬盘上创建一个任意分区并不是必需的。创建的物理卷将被逻辑卷管理器识别为一个新安装的未处理的磁盘或者一个类型为 83 的Linux 分区。如果你想去使用整个硬盘,创建一个分区并没有什么特别的好处,以及另外的物理卷部分的元数据所使用的磁盘空间。 + +### 扩展已存在的卷组 + +在这个示例中,我将扩展一个已存在的卷组,而不是创建一个新的;你可以选择其它的方式。在物理磁盘已经创建之后,扩展已存在的卷组(VG)去包含新 PV 的空间。在这个示例中,已存在的卷组命名为:MyVG01。 + +``` +vgextend /dev/MyVG01 /dev/hdd +``` + +### 创建一个逻辑卷 + +首先,在卷组中从已存在的空余空间中创建逻辑卷。下面的命令创建了一个 50 GB 大小的 LV。这个卷组的名字为 MyVG01,然后,逻辑卷的名字为 Stuff。 + +``` +lvcreate -L +50G --name Stuff MyVG01 +``` + +### 创建文件系统 + +创建逻辑卷并不会创建文件系统。这个任务必须被单独执行。下面的命令在新创建的逻辑卷中创建了一个 EXT4 文件系统。 + +``` +mkfs -t ext4 /dev/MyVG01/Stuff +``` + +### 增加一个文件系统卷标 + +增加一个文件系统卷标,更易于在文件系统以后出现问题时识别它。 + +``` +e2label /dev/MyVG01/Stuff Stuff +``` + +### 挂载文件系统 + +在这个时候,你可以创建一个挂载点,并在 /etc/fstab 文件系统中添加合适的条目,以挂载文件系统。 + +你也可以去检查并校验创建的卷是否正确。你可以使用 **df**、**lvs**、和 **vgs** 命令去做这些工作。 + +### 提示 + +过去几年来,我学习了怎么去做让逻辑卷管理更加容易的一些知识,希望这些提示对你有价值。 + +* 除非你有一个明确的原因去使用其它的文件系统外,推荐使用可扩展的文件系统。除了 EXT2、3、和 4 外,并不是所有的文件系统都支持调整大小。EXT 文件系统不但速度快,而且它很高效。在任何情况下,如果默认的参数不能满足你的需要,它们(指的是文件系统参数)可以通过一位知识丰富的系统管理员来调优它。 + +* 使用有意义的卷和卷组名字。 + +* 使用 EXT 文件系统标签 + +我知道,像我一样,大多数的系统管理员都抗拒逻辑卷管理。我希望这篇文章能够鼓励你至少去尝试一个 LVM。如果你能那样做,我很高兴;因为,自从我使用它之后,我的硬盘管理任务变得如此的简单。 + + +### 关于作者 + + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/david-crop.jpg?itok=oePpOpyV)][10] + + David Both - 是一位 Linux 和开源软件的倡导者,住在 Raleigh, North Carolina。他在 IT 行业工作了 40 多年,在 IBM 工作了 20 多年。在 IBM 期间,他在 1981 年为最初的 IBM PC 编写了第一个培训课程。他曾教授红帽的 RHCE 课程,并在 MCI Worldcom、Cisco和 North Carolina 工作。他已经使用 Linux 和开源软件工作了将近 20 年。... [more about David Both][7][More about me][8] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/business/16/9/linux-users-guide-lvm + +作者:[David Both](a) +译者:[qhwdw](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/dboth +[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[6]:https://opensource.com/business/16/9/linux-users-guide-lvm?rate=79vf1js7A7rlp-I96YFneopUQqsa2SuB-g-og7eiF1U +[7]:https://opensource.com/users/dboth +[8]:https://opensource.com/users/dboth +[9]:https://opensource.com/user/14106/feed +[10]:https://opensource.com/users/dboth +[11]:https://opensource.com/users/dboth +[12]:https://opensource.com/users/dboth +[13]:https://opensource.com/business/16/9/linux-users-guide-lvm#comments +[14]:https://opensource.com/tags/business +[15]:https://opensource.com/tags/linux +[16]:https://opensource.com/tags/how-tos-and-tutorials +[17]:https://opensource.com/tags/sysadmin From 24aba7f38f3373d86c8250297298716e05c9ef39 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Tue, 5 Dec 2017 17:12:48 +0800 Subject: [PATCH 261/344] Translated by qhwdw --- ...20160922 A Linux users guide to Logical Volume Management.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20160922 A Linux users guide to Logical Volume Management.md b/translated/tech/20160922 A Linux users guide to Logical Volume Management.md index 18b42e9e69..c43a8777e1 100644 --- a/translated/tech/20160922 A Linux users guide to Logical Volume Management.md +++ b/translated/tech/20160922 A Linux users guide to Logical Volume Management.md @@ -142,7 +142,7 @@ e2label /dev/MyVG01/Stuff Stuff via: https://opensource.com/business/16/9/linux-users-guide-lvm 作者:[David Both](a) -译者:[qhwdw](https://github.com/译者ID) +译者:[qhwdw](https://github.com/qhwdw) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 5eba6f6260c4fa3a6f856198e97136e819b45e4d Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 5 Dec 2017 18:31:06 +0800 Subject: [PATCH 262/344] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20find?= =?UTF-8?q?=20all=20files=20with=20a=20specific=20text=20using=20Linux=20s?= =?UTF-8?q?hell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...with a specific text using Linux shell .md | 294 ++++++++++++++++++ 1 file changed, 294 insertions(+) create mode 100644 sources/tech/20171130 How to find all files with a specific text using Linux shell .md diff --git a/sources/tech/20171130 How to find all files with a specific text using Linux shell .md b/sources/tech/20171130 How to find all files with a specific text using Linux shell .md new file mode 100644 index 0000000000..f5909c27c9 --- /dev/null +++ b/sources/tech/20171130 How to find all files with a specific text using Linux shell .md @@ -0,0 +1,294 @@ +translating by lujun9972 +How to find all files with a specific text using Linux shell +------ +### Objective + +The following article provides some useful tips on how to find all files within any specific directory or entire file-system containing any specific word or string. + +### Difficulty + +EASY + +### Conventions + +* # - requires given command to be executed with root privileges either directly as a root user or by use of sudo command + +* $ - given command to be executed as a regular non-privileged user + +### Examples + +### Find all files with a specific string non-recursively + +The first command example will search for a string + +`stretch` + +in all files within + +`/etc/` + +directory while excluding any sub-directories: + +``` +# grep -s stretch /etc/* +/etc/os-release:PRETTY_NAME="Debian GNU/Linux 9 (stretch)" +/etc/os-release:VERSION="9 (stretch)" +``` +`-s` + +grep option will suppress error messages about nonexistent or unreadable files. The output shows filenames as well as prints the actual line containing requested string. + +### Find all files with a specific string recursively + +The above command omitted all sub-directories. To search recursively means to also traverse all sub-directories. The following command will search for a string + +`stretch` + +in all files within + +`/etc/` + +directory including all sub-directories: + +``` +# grep -R stretch /etc/* +/etc/apt/sources.list:# deb cdrom:[Debian GNU/Linux testing _Stretch_ - Official Snapshot amd64 NETINST Binary-1 20170109-05:56]/ stretch main +/etc/apt/sources.list:#deb cdrom:[Debian GNU/Linux testing _Stretch_ - Official Snapshot amd64 NETINST Binary-1 20170109-05:56]/ stretch main +/etc/apt/sources.list:deb http://ftp.au.debian.org/debian/ stretch main +/etc/apt/sources.list:deb-src http://ftp.au.debian.org/debian/ stretch main +/etc/apt/sources.list:deb http://security.debian.org/debian-security stretch/updates main +/etc/apt/sources.list:deb-src http://security.debian.org/debian-security stretch/updates main +/etc/dictionaries-common/words:backstretch +/etc/dictionaries-common/words:backstretch's +/etc/dictionaries-common/words:backstretches +/etc/dictionaries-common/words:homestretch +/etc/dictionaries-common/words:homestretch's +/etc/dictionaries-common/words:homestretches +/etc/dictionaries-common/words:outstretch +/etc/dictionaries-common/words:outstretched +/etc/dictionaries-common/words:outstretches +/etc/dictionaries-common/words:outstretching +/etc/dictionaries-common/words:stretch +/etc/dictionaries-common/words:stretch's +/etc/dictionaries-common/words:stretched +/etc/dictionaries-common/words:stretcher +/etc/dictionaries-common/words:stretcher's +/etc/dictionaries-common/words:stretchers +/etc/dictionaries-common/words:stretches +/etc/dictionaries-common/words:stretchier +/etc/dictionaries-common/words:stretchiest +/etc/dictionaries-common/words:stretching +/etc/dictionaries-common/words:stretchy +/etc/grub.d/00_header:background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"` +/etc/os-release:PRETTY_NAME="Debian GNU/Linux 9 (stretch)" +/etc/os-release:VERSION="9 (stretch)" +``` + +The above + +`grep` + +command example lists all files containing string + +`stretch` + +. Meaning the lines with + +`stretches` + +, + +`stretched` + +etc. are also shown. Use grep's + +`-w` + +option to show only a specific word: + +``` +# grep -Rw stretch /etc/* +/etc/apt/sources.list:# deb cdrom:[Debian GNU/Linux testing _Stretch_ - Official Snapshot amd64 NETINST Binary-1 20170109-05:56]/ stretch main +/etc/apt/sources.list:#deb cdrom:[Debian GNU/Linux testing _Stretch_ - Official Snapshot amd64 NETINST Binary-1 20170109-05:56]/ stretch main +/etc/apt/sources.list:deb http://ftp.au.debian.org/debian/ stretch main +/etc/apt/sources.list:deb-src http://ftp.au.debian.org/debian/ stretch main +/etc/apt/sources.list:deb http://security.debian.org/debian-security stretch/updates main +/etc/apt/sources.list:deb-src http://security.debian.org/debian-security stretch/updates main +/etc/dictionaries-common/words:stretch +/etc/dictionaries-common/words:stretch's +/etc/grub.d/00_header:background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"` +/etc/os-release:PRETTY_NAME="Debian GNU/Linux 9 (stretch)" +/etc/os-release:VERSION="9 (stretch)" +``` + +The above commands may produce an unnecessary output. The next example will only show all file names containing string + +`stretch` + +within + +`/etc/` + +directory recursively: + +``` +# grep -Rl stretch /etc/* +/etc/apt/sources.list +/etc/dictionaries-common/words +/etc/grub.d/00_header +/etc/os-release +``` + +All searches are by default case sensitive which means that any search for a string + +`stretch` + +will only show files containing the exact uppercase and lowercase match. By using grep's + +`-i` + +option the command will also list any lines containing + +`Stretch` + +, + +`STRETCH` + +, + +`StReTcH` + +etc., hence, to perform case-insensitive search. + +``` +# grep -Ril stretch /etc/* +/etc/apt/sources.list +/etc/dictionaries-common/default.hash +/etc/dictionaries-common/words +/etc/grub.d/00_header +/etc/os-release +``` + +Using + +`grep` + +command it is also possible to include only specific files as part of the search. For example we only would like to search for a specific text/string within configuration files with extension + +`.conf` + +. The next example will find all files with extension + +`.conf` + +within + +`/etc` + +directory containing string + +`bash` + +: + +``` +# grep -Ril bash /etc/*.conf +OR +# grep -Ril --include=\*.conf bash /etc/* +/etc/adduser.conf +``` +`--exclude` + +option we can exclude any specific filenames: + +``` +# grep -Ril --exclude=\*.conf bash /etc/* +/etc/alternatives/view +/etc/alternatives/vim +/etc/alternatives/vi +/etc/alternatives/vimdiff +/etc/alternatives/rvim +/etc/alternatives/ex +/etc/alternatives/rview +/etc/bash.bashrc +/etc/bash_completion.d/grub +/etc/cron.daily/apt-compat +/etc/cron.daily/exim4-base +/etc/dictionaries-common/default.hash +/etc/dictionaries-common/words +/etc/inputrc +/etc/passwd +/etc/passwd- +/etc/profile +/etc/shells +/etc/skel/.profile +/etc/skel/.bashrc +/etc/skel/.bash_logout +``` + +Same as with files grep can also exclude specific directories from the search. Use + +`--exclude-dir` + +option to exclude directory from search. The following search example will find all files containing string + +`stretch` + +within + +`/etc` + +directory and exclude + +`/etc/grub.d` + +from search: + +``` +# grep --exclude-dir=/etc/grub.d -Rwl stretch /etc/* +/etc/apt/sources.list +/etc/dictionaries-common/words +/etc/os-release +``` + +By using + +`-n` + +option grep will also provide an information regarding a line number where the specific string was found: + +``` +# grep -Rni bash /etc/*.conf +/etc/adduser.conf:6:DSHELL=/bin/bash +``` + +The last example will use + +`-v` + +option to list all files NOT containing a specific keyword. For example the following search will list all files within + +`/etc/` + +directory which do not contain string + +`stretch` + +: + +``` +# grep -Rlv stretch /etc/* +``` + +-------------------------------------------------------------------------------- + +via: https://linuxconfig.org/how-to-find-all-files-with-a-specific-text-using-linux-shell + +作者:[Lubos Rendek][a] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://linuxconfig.org From eec7eafcdddc0416053e6547a5e2ea0576b9d8d4 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Tue, 5 Dec 2017 19:18:45 +0800 Subject: [PATCH 263/344] Translating by qhwdw --- ...005 How to manage Linux containers with Ansible Container.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20171005 How to manage Linux containers with Ansible Container.md b/sources/tech/20171005 How to manage Linux containers with Ansible Container.md index 897b793a86..0f200d73a8 100644 --- a/sources/tech/20171005 How to manage Linux containers with Ansible Container.md +++ b/sources/tech/20171005 How to manage Linux containers with Ansible Container.md @@ -1,4 +1,4 @@ -How to manage Linux containers with Ansible Container +Translating by qhwdw How to manage Linux containers with Ansible Container ============================================================ ### Ansible Container addresses Dockerfile shortcomings and offers complete management for containerized projects. From 57252987000dc1f3968a790330119a1afc0182a9 Mon Sep 17 00:00:00 2001 From: TRsky <625310581@qq.com> Date: Tue, 5 Dec 2017 20:02:08 +0800 Subject: [PATCH 264/344] translate the passage --- ...ke up and Shut Down Linux Automatically.md | 75 ++++++++++--------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md index 3a2c20ad52..5ed3f2bf10 100644 --- a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md +++ b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md @@ -1,26 +1,24 @@ - translating by HardworkFish - -Wake up and Shut Down Linux Automatically -============================================================ +自动唤醒和关闭 Linux +===================== ### [banner.jpg][1] -![time keeper](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/banner.jpg?itok=zItspoSb) - -Learn how to configure your Linux computers to watch the time for you, then wake up and shut down automatically. +![timekeeper](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/banner.jpg?itok=zItspoSb) +了解如何通过配置 Linux 计算机来查看时间,并实现自动唤醒和关闭 Linux + [Creative Commons Attribution][6][The Observatory at Delhi][7] -Don't be a watt-waster. If your computers don't need to be on then shut them down. For convenience and nerd creds, you can configure your Linux computers to wake up and shut down automatically. +不要成为一个电能浪费者。如果你的电脑不需要开机就请把他们关机。出于方便和计算机宅的考虑,你可以通过配置你的 Linux 计算机实现自动唤醒和关闭 Linux 。 -### Precious Uptimes +### 系统运行时间 -Some computers need to be on all the time, which is fine as long as it's not about satisfying an uptime compulsion. Some people are very proud of their lengthy uptimes, and now that we have kernel hot-patching that leaves only hardware failures requiring shutdowns. I think it's better to be practical. Save electricity as well as wear on your moving parts, and shut them down when they're not needed. For example, you can wake up a backup server at a scheduled time, run your backups, and then shut it down until it's time for the next backup. Or, you can configure your Internet gateway to be on only at certain times. Anything that doesn't need to be on all the time can be configured to turn on, do a job, and then shut down. +有时候有些电脑需要一直处在开机状态,在不超过电脑运行时间的限制下这种情况是被允许的。有些人为他们的计算机可以长时间的正常运行而感到自豪,且现在我们有内核热补丁能够实现只有在硬件发生故障时才允许机器关机。我认为比较实际可行的是能够在机器需要节省电能以及在移动硬件发生磨损的情况下,且在不需要机器运行的情况下将其关机。比如,你可以在规定的时间内唤醒备份服务器,执行备份,然后关闭它直到下一次进行备份时间。或者,你可以只在特定时间内配置网卡。任何不需要一直运行的东西都可以将其配置成在其需要工作的时候打开,待其完成工作后将其关闭。 -### Sleepies +### 系统休眠 -For computers that don't need to be on all the time, good old cron will shut them down reliably. Use either root's cron, or /etc/crontab. This example creates a root cron job to shut down every night at 11:15 p.m. +对于不需要一直运行的电脑,使用 root 的 cron 定时任务 或者 /etc/crontab 文件 可以可靠地关闭电脑。这个例子创建一个 root 定时任务实现每天下午 11点15分 定时关机。 ``` # crontab -e -u root @@ -32,33 +30,34 @@ For computers that don't need to be on all the time, good old cron will shut the 15 23 * * 1-5 /sbin/shutdown -h now ``` -You may also use /etc/crontab, which is fast and easy, and everything is in one file. You have to specify the user: +一个快速、容易的方式是,使用 /etc/crontab 文件。你必须指定用户: ``` 15 23 * * 1-5 root shutdown -h now ``` -Auto-wakeups are very cool; most of my SUSE colleagues are in Nuremberg, so I am crawling out of bed at 5 a.m. to have a few hours of overlap with their schedules. My work computer turns itself on at 5:30 a.m., and then all I have to do is drag my coffee and myself to my desk to start work. It might not seem like pressing a power button is a big deal, but at that time of day every little thing looms large. +实现自动唤醒是一件很酷的事情;我的大多数 SUSE (SUSE Linux)同事都在纽伦堡,因此,为了能够跟同事的计划有几小时的重叠时间我需要在凌晨5点起床。我的计算机早上 5点半自动开始工作,而我只需要将自己和咖啡拖到我的桌子上就可以开始工作了。按下电源按钮看起来好像并不是什么大事,但是在每天的那个时候每件小事都会变得很大。 -Waking up your Linux PC can be less reliable than shutting it down, so you may want to try different methods. You can use wakeonlan, RTC wakeups, or your PC's BIOS to set scheduled wakeups. These all work because, when you power off your computer, it's not really all the way off; it is in an extremely low-power state and can receive and respond to signals. You need to use the power supply switch to turn it off completely. +唤醒 Linux 计算机可能不比关闭它可靠,因此你可能需要尝试不同的办法。你可以使用 远程唤醒(Wake-On-LAN)、RTC 唤醒或者个人电脑的 BIOS 设置预定的唤醒。做这些工作的原因是,当你关闭电脑时,这并不是真正关闭了计算机;此时计算机处在极低功耗状态且还可以接受和响应信号。你需要使用电源开关将其彻底关闭。 -### BIOS Wakeup +### BIOS 唤醒 -A BIOS wakeup is the most reliable. My system BIOS has an easy-to-use wakeup scheduler (Figure 1). Chances are yours does, too. Easy peasy. +BIOS 唤醒是最可靠的。我的系统主板 BIOS 有一个易于使用的唤醒调度程序。(Figure 1). Chances are yours does, too. Easy peasy. ### [fig-1.png][2] -![wake up](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_11.png?itok=8qAeqo1I) +![wakeup](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_11.png?itok=8qAeqo1I) Figure 1: My system BIOS has an easy-to-use wakeup scheduler. [Used with permission][8] -### wakeonlan -wakeonlan is the next most reliable method. This requires sending a signal from a second computer to the computer you want to power on. You could use an Arduino or Raspberry Pi to send the wakeup signal, a Linux-based router, or any Linux PC. First, look in your system BIOS to see if wakeonlan is supported -- which it should be -- and then enable it, as it should be disabled by default. +### 主机远程唤醒(Wake-On-LAN) -Then, you'll need an Ethernet network adapter that supports wakeonlan; wireless adapters won't work. You'll need to verify that your Ethernet card supports wakeonlan: +远程唤醒是仅次于 BIOS 唤醒的又一种可靠的唤醒方法。这需要你从第二台计算机发送信号到所要打开的计算机。可以使用 Arduino 或 树莓派(Raspberry Pi) 发送基于 Linux 的路由器或者任何Linux 计算机的唤醒信号。首先,查看系统主板 BIOS 是否支持 Wake-On-LAN –如果支持—然后启动它,因为它被默认为禁用。 + +然后,需要一个支持 Wake-On-LAN 的网卡;无线网卡并不支持。你需要运行 ethtool 命令查看网卡是否支持 Wake-On-LAN : ``` # ethtool eth0 | grep -i wake-on @@ -66,23 +65,23 @@ Then, you'll need an Ethernet network adapter that supports wakeonlan; wireless Wake-on: g ``` -* d -- all wake ups disabled +* d -- 禁用 -* p -- wake up on physical activity +* p -- 物理活动唤醒 -* u -- wake up on unicast messages +* u -- 单播消息唤醒 -* m -- wake up on multicast messages +* m -- 多播(组播)消息唤醒 -* b -- wake up on broadcast messages +* b -- 广播消息唤醒 -* a -- wake up on ARP messages +* a -- ARP(Address Resolution Protocol)唤醒 -* g -- wake up on magic packet +* g -- magic packet 唤醒 -* s -- set the Secure On password for the magic packet +* s -- magic packet 设置安全密码 -man ethtool is not clear on what the p switch does; it suggests that any signal will cause a wake up. In my testing, however, it doesn't do that. The one that must be enabled is g -- wake up on magic packet, and the Wake-on line shows that it is already enabled. If it is not enabled, you can use ethtool to enable it, using your own device name, of course: +man ethtool 并不清楚开关 p 的作用;这表明任何信号都会导致唤醒。在我的测试中,然而,它并没有这么做。Wake-On-Lan 被启动的 Wake-on 参数是 g –- magic packet 唤醒,且当 Wake-On 值已经为 g 时表示网卡已支持 Wake-On-Lan 。如果它没有被启用,你可以通过 ethtool 命令来启用它。 ``` # ethtool -s eth0 wol g @@ -100,26 +99,26 @@ Figure 2: Enable Wake on LAN. [Used with permission][9] -Another option is recent Network Manager versions have a nice little checkbox to enable wakeonlan (Figure 2). +另外一个选择是最近的网络管理器版本有一个很好的小复选框能够唤醒局域网(图2)。 -There is a field for setting a password, but if your network interface doesn't support the Secure On password, it won't work. +这里有一个可以用于设置密码的地方,但是如果你的网络接口不支持 Secure On password,它就不起作用。 -Now you need to configure a second PC to send the wakeup signal. You don't need root privileges, so create a cron job for your user. You need the MAC address of the network interface on the machine you're waking up: +现在你需要配置第二台计算机来发送唤醒信号。你并不需要 root 权限,所以你可以为你的用户创建 cron 任务。你需要正在唤醒的机器上的网络接口和MAC地址。 ``` 30 08 * * * /usr/bin/wakeonlan D0:50:99:82:E7:2B ``` -Using the real-time clock for wakeups is the least reliable method. Check out [Wake Up Linux With an RTC Alarm Clock][4]; this is a bit outdated as most distros use systemd now. Come back next week to learn more about updated ways to use RTC wakeups. +通过使用实时闹钟来唤醒计算机是最不可靠的方法。查看 [Wake Up Linux With an RTC Alarm Clock][4] ;对于现在的大多数发行版来说这种方法已经有点过时了。下周继续了解更多关于使用RTC唤醒的方法。 -Learn more about Linux through the free ["Introduction to Linux" ][5]course from The Linux Foundation and edX. +通过 Linux 基金会和 edX 可以学习更多关于 Linux 的免费 [ Linux 入门][5]教程。 -------------------------------------------------------------------------------- -via: https://www.linux.com/learn/intro-to-linux/2017/11/wake-and-shut-down-linux-automatically +via:https://www.linux.com/learn/intro-to-linux/2017/11/wake-and-shut-down-linux-automatically 作者:[Carla Schroder] -译者:[译者ID](https://github.com/译者ID) +译者:[译者ID](https://github.com/HardworkFish) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -133,3 +132,5 @@ via: https://www.linux.com/learn/intro-to-linux/2017/11/wake-and-shut-down-linux [7]:http://www.columbia.edu/itc/mealac/pritchett/00routesdata/1700_1799/jaipur/delhijantarearly/delhijantarearly.html [8]:https://www.linux.com/licenses/category/used-permission [9]:https://www.linux.com/licenses/category/used-permission + + From 2fa592a2cb1e9994ed40a207cde287b8efb19657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E8=8D=A3=E5=8D=87?= Date: Tue, 5 Dec 2017 20:04:00 +0800 Subject: [PATCH 265/344] Update 20171120 Mark McIntyre How Do You Fedora.md --- sources/tech/20171120 Mark McIntyre How Do You Fedora.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171120 Mark McIntyre How Do You Fedora.md b/sources/tech/20171120 Mark McIntyre How Do You Fedora.md index bfd19e1eda..40af7eba2f 100644 --- a/sources/tech/20171120 Mark McIntyre How Do You Fedora.md +++ b/sources/tech/20171120 Mark McIntyre How Do You Fedora.md @@ -1,5 +1,6 @@ translating by zrszrszrs # [Mark McIntyre: How Do You Fedora?][1] +# [Mark McIntyre: 你是如何使用Fedora的?][1] ![](https://fedoramagazine.org/wp-content/uploads/2017/11/mock-couch-945w-945x400.jpg) From 76fbbbde563baf68ff3f74227b524684bdcd7eda Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 5 Dec 2017 20:18:00 +0800 Subject: [PATCH 266/344] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20Encryp?= =?UTF-8?q?t=20and=20Decrypt=20Individual=20Files=20With=20GPG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...t and Decrypt Individual Files With GPG.md | 145 ++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 sources/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md diff --git a/sources/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md b/sources/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md new file mode 100644 index 0000000000..eea4b569bf --- /dev/null +++ b/sources/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md @@ -0,0 +1,145 @@ +translating by lujun9972 +How to Encrypt and Decrypt Individual Files With GPG +------ +### Objective + +Encrypt individual files with GPG. + +### Distributions + +This will work with any Linux distribution. + +### Requirements + +A working Linux install with GPG installed or root privileges to install it. + +### Difficulty + +Easy + +### Conventions + +* # - requires given command to be executed with root privileges either directly as a root user or by use of sudo command + +* $ - given command to be executed as a regular non-privileged user + +### Introduction + +Encryption is important. It's absolutely vital to protecting sensitive information. Your personal files are worth encrypting, and GPG provides the perfect solution. + +### Install GPG + +GPG is a widely used piece of software. You can find it in nearly every distribution's repositories. If you don't have it already, install it on your computer. + +### Debian/Ubuntu + +``` +$ sudo apt install gnupg +``` + +``` +# dnf install gnupg2 +``` + +``` +# pacman -S gnupg +``` + +``` +# emerge --ask app-crypt/gnupg +``` + +You need a key pair to be able to encrypt and decrypt files. If you already have a key pair that you generated for SSH, you can actually use those here. If not, GPG includes a utility to generate them. + +``` +$ gpg --full-generate-key +``` + +The first thing GPG will ask for is the type of key. Use the default, if there isn't anything specific that you need. + +The next thing that you'll need to set is the key size. + +`4096` + +is probably best. + +After that, you can set an expiration date. Set it to + +`0` + +if you want the key to be permanent. + +Then, it will ask you for your name. + +Finally, it asks for your email address. + +You can add a comment if you need to too. + +When it has everything, GPG will ask you to verify the information. + +GPG will ask if you want a password for your key. This is optional, but adds a degree of protection. As it's doing that, GPG will collect entropy from your actions to increase the strength of your key. When it's done, GPG will print out the information pertaining to the key you just created. + +### Basic Encryption + +Now that you have your key, encrypting files is very easy. Create a blank text file in your + +`/tmp` + +directory to practice with. + +``` +$ touch /tmp/test.txt +``` +`-e` + +flag tells GPG that you'll be encrypting a file, and the + +`-r` + +flag specifies a recipient. + +``` +$ gpg -e -r "Your Name" /tmp/test.txt +``` + +### Basic Decryption + +You have an encrypted file. Try decrypting it. You don't need to specify any keys. That information is encoded with the file. GPG will try the keys that it has to decrypt it. + +``` +$ gpg -d /tmp/test.txt.gpg +``` + +Say you + + _do_ + +need to send the file. You need to have the recipient's public key. How you get that from them is up to you. You can ask them to send it to you, or it may be publicly available on a keyserver. + +Once you have it, import the key into GPG. + +``` +$ gpg --import yourfriends.key +``` + +``` +gpg --export -a "Your Name" > your.key +``` + +``` +$ gpg -e -u "Your Name" -r "Their Name" /tmp/test.txt +``` + +That's mostly it. There are some more advanced options available, but you won't need them ninety-nine percent of the time. GPG is that easy to use. You can also use the key pair that you created to send and receive encrypted email in much the same way as this, though most email clients automate the process once they have the keys. + +-------------------------------------------------------------------------------- + +via: https://linuxconfig.org/how-to-encrypt-and-decrypt-individual-files-with-gpg + +作者:[Nick Congleton][a] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://linuxconfig.org From 21a2999ba0fc513fbc3d344f5d22979960f07c6e Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 5 Dec 2017 21:41:32 +0800 Subject: [PATCH 267/344] translated --- ...t and Decrypt Individual Files With GPG.md | 132 ++++++++---------- 1 file changed, 62 insertions(+), 70 deletions(-) diff --git a/sources/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md b/sources/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md index eea4b569bf..d28e36e358 100644 --- a/sources/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md +++ b/sources/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md @@ -1,136 +1,128 @@ -translating by lujun9972 -How to Encrypt and Decrypt Individual Files With GPG +如何使用 GPG 加解密文件 ------ -### Objective +### 目标 -Encrypt individual files with GPG. +使用 GPG 加密文件 -### Distributions +### 发行版 -This will work with any Linux distribution. +适用于任何发行版 -### Requirements +### 要求 -A working Linux install with GPG installed or root privileges to install it. +安装了 GPG 的Linux 或者拥有 root 权限来安装它. -### Difficulty +### 难度 -Easy +简单 -### Conventions +### 约定 -* # - requires given command to be executed with root privileges either directly as a root user or by use of sudo command +* # - 需要使用root权限来执行指定命令,可以直接使用root用户来执行也可以使用sudo命令 -* $ - given command to be executed as a regular non-privileged user +* $ - 可以使用普通用户来执行指定命令 -### Introduction +### 介绍 -Encryption is important. It's absolutely vital to protecting sensitive information. Your personal files are worth encrypting, and GPG provides the perfect solution. +加密非常重要. 它对于保护敏感信息来说是必不可少的. +你的私人文件应该要被加密, 而 GPG 提供了很好的解决方案. -### Install GPG +### 安装 GPG -GPG is a widely used piece of software. You can find it in nearly every distribution's repositories. If you don't have it already, install it on your computer. +GPG 的使用非常广泛. 你在几乎每个发行版的仓库中都能找到它. +如果你还没有安装它,那现在就来安装一下吧. -### Debian/Ubuntu +#### Debian/Ubuntu -``` +```shell $ sudo apt install gnupg ``` - -``` +#### Fedora +```shell # dnf install gnupg2 ``` - -``` +#### Arch +```shell # pacman -S gnupg ``` - -``` +#### Gentoo +```shell # emerge --ask app-crypt/gnupg ``` +### Create a Key +你需要一个密钥对来加解密文件. 如果你为 SSH 已经生成过了密钥对,那么你可以直接使用它. +如果没有,GPG包含工具来生成密钥对. -You need a key pair to be able to encrypt and decrypt files. If you already have a key pair that you generated for SSH, you can actually use those here. If not, GPG includes a utility to generate them. - -``` +```shell $ gpg --full-generate-key ``` +GPG 有一个命令行程序帮你一步一步的生成密钥. 它还有一个简单得多的工具,但是这个工具不能让你设置密钥类型,密钥的长度以及过期时间,因此不推荐使用这个工具. -The first thing GPG will ask for is the type of key. Use the default, if there isn't anything specific that you need. +GPG 首先会询问你密钥的类型. 没什么特别的话选择默认值就好. -The next thing that you'll need to set is the key size. +下一步需要设置密钥长度. `4096` 是一个不错的选择. -`4096` +之后, 可以设置过期的日期. 如果希望密钥永不过期则设置为 `0` -is probably best. +然后,输入你的名称. -After that, you can set an expiration date. Set it to +最后, 输入电子邮件地址. -`0` +如果你需要的话,还能添加一个注释. -if you want the key to be permanent. +所有这些都完成后, GPG 会让你校验一下这些信息. -Then, it will ask you for your name. +GPG 还会问你是否需要为密钥设置密码. 这一步是可选的, 但是会增加保护的程度. +若需要设置密码,则 GPG 会收集你的操作信息来增加密钥的健壮性. 所有这些都完成后, GPG 会显示密钥相关的信息. -Finally, it asks for your email address. +### 加密的基本方法 -You can add a comment if you need to too. +现在你拥有了自己的密钥, 加密文件非常简单. 使用虾米那命令在 `/tmp` 目录中创建一个空白文本文件. -When it has everything, GPG will ask you to verify the information. - -GPG will ask if you want a password for your key. This is optional, but adds a degree of protection. As it's doing that, GPG will collect entropy from your actions to increase the strength of your key. When it's done, GPG will print out the information pertaining to the key you just created. - -### Basic Encryption - -Now that you have your key, encrypting files is very easy. Create a blank text file in your - -`/tmp` - -directory to practice with. - -``` +```shell $ touch /tmp/test.txt ``` -`-e` -flag tells GPG that you'll be encrypting a file, and the +然后用 GPG 来加密它. 这里 `-e` 标志告诉 GPG 你想要加密文件, `-r` 标志指定接收者. -`-r` - -flag specifies a recipient. - -``` +```shell $ gpg -e -r "Your Name" /tmp/test.txt ``` -### Basic Decryption +GPG 需要知道这个文件的接收者和发送者. 由于这个文件给是你的,因此无需指定发送者,而接收者就是你自己. -You have an encrypted file. Try decrypting it. You don't need to specify any keys. That information is encoded with the file. GPG will try the keys that it has to decrypt it. +### 解密的基本方法 -``` +你收到加密文件后,就需要对它进行解密. 你无需指定解密用的密钥. 这个信息被编码在文件中. GPG 会尝试用其中的密钥进行解密. + +```shel $ gpg -d /tmp/test.txt.gpg ``` -Say you +### 发送文件 +假设你需要发送文件给别人. 你需要有接收者的公钥. 具体怎么获得密钥由你自己决定. 你可以让他们直接把公钥发送给你, 也可以通过密钥服务器来获取. - _do_ +收到对方公钥后, 导入公钥到GPG 中. -need to send the file. You need to have the recipient's public key. How you get that from them is up to you. You can ask them to send it to you, or it may be publicly available on a keyserver. - -Once you have it, import the key into GPG. - -``` +```shell $ gpg --import yourfriends.key ``` -``` +这些公钥与你自己创建的密钥一样,自带了名称和电子邮件地址的信息. +记住,为了让别人能解密你的文件,别人也需要你的公钥. 因此导出公钥并将之发送出去. + +```shell gpg --export -a "Your Name" > your.key ``` +现在可以开始加密要发送的文件了. 它跟之前的步骤差不多, 只是需要指定你自己为发送人. ``` $ gpg -e -u "Your Name" -r "Their Name" /tmp/test.txt ``` -That's mostly it. There are some more advanced options available, but you won't need them ninety-nine percent of the time. GPG is that easy to use. You can also use the key pair that you created to send and receive encrypted email in much the same way as this, though most email clients automate the process once they have the keys. +### 结语 +就这样了. GPG 还有一些高级选项, 不过你在 99% 的时间内都不会用到这些高级选项. GPG 就是这么易于使用. +你也可以使用创建的密钥对来发送和接受加密邮件,其步骤跟上面演示的差不多, 不过大多数的电子邮件客户端在拥有密钥的情况下会自动帮你做这个动作. -------------------------------------------------------------------------------- From 35a7f43a8fa8a02581bffaca2025fcd6fff0ad83 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 5 Dec 2017 21:42:32 +0800 Subject: [PATCH 268/344] change to translated --- ...171024 How to Encrypt and Decrypt Individual Files With GPG.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources => translated}/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md (100%) diff --git a/sources/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md b/translated/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md similarity index 100% rename from sources/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md rename to translated/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md From 93395794ecbfcb4ade7d71e1e5c07ae46ac28c09 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 5 Dec 2017 21:50:49 +0800 Subject: [PATCH 269/344] reformat --- ...t and Decrypt Individual Files With GPG.md | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/translated/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md b/translated/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md index d28e36e358..6b534be640 100644 --- a/translated/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md +++ b/translated/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md @@ -10,7 +10,7 @@ ### 要求 -安装了 GPG 的Linux 或者拥有 root 权限来安装它. +安装了 GPG 的 Linux 或者拥有 root 权限来安装它。 ### 难度 @@ -18,19 +18,19 @@ ### 约定 -* # - 需要使用root权限来执行指定命令,可以直接使用root用户来执行也可以使用sudo命令 +* # - 需要使用 root 权限来执行指定命令,可以直接使用 root 用户来执行也可以使用 sudo 命令 * $ - 可以使用普通用户来执行指定命令 ### 介绍 -加密非常重要. 它对于保护敏感信息来说是必不可少的. -你的私人文件应该要被加密, 而 GPG 提供了很好的解决方案. +加密非常重要。它对于保护敏感信息来说是必不可少的。 +你的私人文件应该要被加密,而 GPG 提供了很好的解决方案。 ### 安装 GPG -GPG 的使用非常广泛. 你在几乎每个发行版的仓库中都能找到它. -如果你还没有安装它,那现在就来安装一下吧. +GPG 的使用非常广泛。你在几乎每个发行版的仓库中都能找到它。 +如果你还没有安装它,那现在就来安装一下吧。 #### Debian/Ubuntu @@ -50,79 +50,79 @@ $ sudo apt install gnupg # emerge --ask app-crypt/gnupg ``` ### Create a Key -你需要一个密钥对来加解密文件. 如果你为 SSH 已经生成过了密钥对,那么你可以直接使用它. -如果没有,GPG包含工具来生成密钥对. +你需要一个密钥对来加解密文件。如果你为 SSH 已经生成过了密钥对,那么你可以直接使用它。 +如果没有,GPG 包含工具来生成密钥对。 ```shell $ gpg --full-generate-key ``` -GPG 有一个命令行程序帮你一步一步的生成密钥. 它还有一个简单得多的工具,但是这个工具不能让你设置密钥类型,密钥的长度以及过期时间,因此不推荐使用这个工具. +GPG 有一个命令行程序帮你一步一步的生成密钥。它还有一个简单得多的工具,但是这个工具不能让你设置密钥类型,密钥的长度以及过期时间,因此不推荐使用这个工具。 -GPG 首先会询问你密钥的类型. 没什么特别的话选择默认值就好. +GPG 首先会询问你密钥的类型。没什么特别的话选择默认值就好。 -下一步需要设置密钥长度. `4096` 是一个不错的选择. +下一步需要设置密钥长度。`4096` 是一个不错的选择。 -之后, 可以设置过期的日期. 如果希望密钥永不过期则设置为 `0` +之后,可以设置过期的日期。 如果希望密钥永不过期则设置为 `0` -然后,输入你的名称. +然后,输入你的名称。 -最后, 输入电子邮件地址. +最后,输入电子邮件地址。 -如果你需要的话,还能添加一个注释. +如果你需要的话,还能添加一个注释。 -所有这些都完成后, GPG 会让你校验一下这些信息. +所有这些都完成后,GPG 会让你校验一下这些信息。 -GPG 还会问你是否需要为密钥设置密码. 这一步是可选的, 但是会增加保护的程度. -若需要设置密码,则 GPG 会收集你的操作信息来增加密钥的健壮性. 所有这些都完成后, GPG 会显示密钥相关的信息. +GPG 还会问你是否需要为密钥设置密码。这一步是可选的, 但是会增加保护的程度。 +若需要设置密码,则 GPG 会收集你的操作信息来增加密钥的健壮性。 所有这些都完成后, GPG 会显示密钥相关的信息。 ### 加密的基本方法 -现在你拥有了自己的密钥, 加密文件非常简单. 使用虾米那命令在 `/tmp` 目录中创建一个空白文本文件. +现在你拥有了自己的密钥,加密文件非常简单。 使用虾米那命令在 `/tmp` 目录中创建一个空白文本文件。 ```shell $ touch /tmp/test.txt ``` -然后用 GPG 来加密它. 这里 `-e` 标志告诉 GPG 你想要加密文件, `-r` 标志指定接收者. +然后用 GPG 来加密它。这里 `-e` 标志告诉 GPG 你想要加密文件, `-r` 标志指定接收者。 ```shell $ gpg -e -r "Your Name" /tmp/test.txt ``` -GPG 需要知道这个文件的接收者和发送者. 由于这个文件给是你的,因此无需指定发送者,而接收者就是你自己. +GPG 需要知道这个文件的接收者和发送者。由于这个文件给是你的,因此无需指定发送者,而接收者就是你自己。 ### 解密的基本方法 -你收到加密文件后,就需要对它进行解密. 你无需指定解密用的密钥. 这个信息被编码在文件中. GPG 会尝试用其中的密钥进行解密. +你收到加密文件后,就需要对它进行解密。 你无需指定解密用的密钥。 这个信息被编码在文件中。 GPG 会尝试用其中的密钥进行解密。 ```shel $ gpg -d /tmp/test.txt.gpg ``` ### 发送文件 -假设你需要发送文件给别人. 你需要有接收者的公钥. 具体怎么获得密钥由你自己决定. 你可以让他们直接把公钥发送给你, 也可以通过密钥服务器来获取. +假设你需要发送文件给别人。你需要有接收者的公钥。 具体怎么获得密钥由你自己决定。 你可以让他们直接把公钥发送给你, 也可以通过密钥服务器来获取。 -收到对方公钥后, 导入公钥到GPG 中. +收到对方公钥后,导入公钥到 GPG 中。 ```shell $ gpg --import yourfriends.key ``` -这些公钥与你自己创建的密钥一样,自带了名称和电子邮件地址的信息. -记住,为了让别人能解密你的文件,别人也需要你的公钥. 因此导出公钥并将之发送出去. +这些公钥与你自己创建的密钥一样,自带了名称和电子邮件地址的信息。 +记住,为了让别人能解密你的文件,别人也需要你的公钥。 因此导出公钥并将之发送出去。 ```shell gpg --export -a "Your Name" > your.key ``` -现在可以开始加密要发送的文件了. 它跟之前的步骤差不多, 只是需要指定你自己为发送人. +现在可以开始加密要发送的文件了。它跟之前的步骤差不多, 只是需要指定你自己为发送人。 ``` $ gpg -e -u "Your Name" -r "Their Name" /tmp/test.txt ``` ### 结语 -就这样了. GPG 还有一些高级选项, 不过你在 99% 的时间内都不会用到这些高级选项. GPG 就是这么易于使用. -你也可以使用创建的密钥对来发送和接受加密邮件,其步骤跟上面演示的差不多, 不过大多数的电子邮件客户端在拥有密钥的情况下会自动帮你做这个动作. +就这样了。GPG 还有一些高级选项, 不过你在 99% 的时间内都不会用到这些高级选项。 GPG 就是这么易于使用。 +你也可以使用创建的密钥对来发送和接受加密邮件,其步骤跟上面演示的差不多, 不过大多数的电子邮件客户端在拥有密钥的情况下会自动帮你做这个动作。 -------------------------------------------------------------------------------- @@ -130,8 +130,8 @@ via: https://linuxconfig.org/how-to-encrypt-and-decrypt-individual-files-with-gp 作者:[Nick Congleton][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/) 荣誉推出 +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux 中国](https://linux.cn/) 荣誉推出 [a]:https://linuxconfig.org From 3265fe318b500cc11c783c26fe9785980c796dd0 Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Tue, 5 Dec 2017 21:53:27 +0800 Subject: [PATCH 270/344] Update 20171201 How to find a publisher for your tech book.md --- .../tech/20171201 How to find a publisher for your tech book.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171201 How to find a publisher for your tech book.md b/sources/tech/20171201 How to find a publisher for your tech book.md index 76dc8112ca..6c7cfeecc1 100644 --- a/sources/tech/20171201 How to find a publisher for your tech book.md +++ b/sources/tech/20171201 How to find a publisher for your tech book.md @@ -1,3 +1,5 @@ + +Translating by FelixYFZ How to find a publisher for your tech book ============================================================ From b776726f813e461a8016c29112b091270baa8480 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 5 Dec 2017 22:20:03 +0800 Subject: [PATCH 271/344] PRF:20171012 Linux Networking Hardware for Beginners Think Software.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @FelixYFZ 恭喜你,完成了第一篇翻译! --- ...g Hardware for Beginners Think Software.md | 87 +++++++++---------- 1 file changed, 39 insertions(+), 48 deletions(-) diff --git a/translated/tech/20171012 Linux Networking Hardware for Beginners Think Software.md b/translated/tech/20171012 Linux Networking Hardware for Beginners Think Software.md index a236a80e97..af79b1e9f0 100644 --- a/translated/tech/20171012 Linux Networking Hardware for Beginners Think Software.md +++ b/translated/tech/20171012 Linux Networking Hardware for Beginners Think Software.md @@ -1,72 +1,63 @@ -Translating by FelixYFZ - -面向初学者的Linux网络硬件: 软件工程思想 -============================================================ +面向初学者的 Linux 网络硬件:软件思维 +=========================================================== ![island network](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/soderskar-island.jpg?itok=wiMaF66b "island network") - 没有路由和桥接,我们将会成为孤独的小岛,你将会在这个网络教程中学到更多知识。 -Commons Zero][3]Pixabay - 上周,我们学习了本地网络硬件知识,本周,我们将学习网络互联技术和在移动网络中的一些很酷的黑客技术。 -### Routers:路由器 +> 没有路由和桥接,我们将会成为孤独的小岛,你将会在这个网络教程中学到更多知识。 +[Commons Zero][3]Pixabay + +上周,我们学习了本地网络硬件知识,本周,我们将学习网络互联技术和在移动网络中的一些很酷的黑客技术。 + +### 路由器 -网络路由器就是计算机网络中的一切,因为路由器连接着网络,没有路由器,我们就会成为孤岛, - -图一展示了一个简单的有线本地网络和一个无线接入点,所有设备都接入到Internet上,本地局域网的计算机连接到一个连接着防火墙或者路由器的以太网交换机上,防火墙或者路由器连接到网络服务供应商提供的电缆箱,调制调节器,卫星上行系统...好像一切都在计算中,就像是一个带着不停闪烁的的小灯的盒子,当你的网络数据包离开你的局域网,进入广阔的互联网,它们穿过一个又一个路由器直到到达自己的目的地。 - - -### [fig-1.png][4] +网络路由器就是计算机网络中的一切,因为路由器连接着网络,没有路由器,我们就会成为孤岛。图一展示了一个简单的有线本地网络和一个无线接入点,所有设备都接入到互联网上,本地局域网的计算机连接到一个连接着防火墙或者路由器的以太网交换机上,防火墙或者路由器连接到网络服务供应商(ISP)提供的电缆箱、调制调节器、卫星上行系统……好像一切都在计算中,就像是一个带着不停闪烁的的小灯的盒子。当你的网络数据包离开你的局域网,进入广阔的互联网,它们穿过一个又一个路由器直到到达自己的目的地。 ![simple LAN](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_7.png?itok=lsazmf3- "simple LAN") -图一:一个简单的有线局域网和一个无线接入点。 +*图一:一个简单的有线局域网和一个无线接入点。* -一台路由器能连接一切,一个小巧特殊的小盒子只专注于路由,一个大点的盒子将会提供路由,防火墙,域名服务,以及VPN网关功能,一台重新设计的台式电脑或者笔记本,一个树莓派计算机或者一个小模块,体积臃肿矮小的像PC这样的单板计算机,除了苛刻的用途以外,普通的商品硬件都能良好的工作运行。高端的路由器使用特殊设计的硬件每秒能够传输最大量的数据包。 它们有多路数据总线,多个中央处理器和极快的存储。 -可以通过查阅Juniper和思科的路由器来感受一下高端路由器书什么样子的,而且能看看里面是什么样的构造。 -一个接入你的局域网的无线接入点要么作为一个以太网网桥要么作为一个路由器。一个桥接器扩展了这个网络,所以在这个桥接器上的任意一端口上的主机都连接在同一个网络中。 -一台路由器连接的是两个不同的网络。 -### Network Topology:网络拓扑 +路由器可以是各种样式:一个只专注于路由的小巧特殊的小盒子,一个将会提供路由、防火墙、域名服务,以及 VPN 网关功能的大点的盒子,一台重新设计的台式电脑或者笔记本,一个树莓派计算机或者一个 Arduino,体积臃肿矮小的像 PC Engines 这样的单板计算机,除了苛刻的用途以外,普通的商品硬件都能良好的工作运行。高端的路由器使用特殊设计的硬件每秒能够传输最大量的数据包。它们有多路数据总线,多个中央处理器和极快的存储。(可以通过了解 Juniper 和思科的路由器来感受一下高端路由器书什么样子的,而且能看看里面是什么样的构造。) - -有多种设置你的局域网的方式,你可以把所有主机接入到一个单独的平面网络,如果你的交换机支持的话,你也可以把它们分配到不同的子网中。 -平面网络是最简单的网络,只需把每一台设备接入到同一个交换机上即可,如果一台交换上的端口不够使用,你可以将更多的交换机连接在一起。 -有些交换机有特殊的上行端口,有些是没有这种特殊限制的上行端口,你可以连接其中的任意端口,你可能需要使用交叉类型的以太网线,所以你要查阅你的交换机的说明文档来设置。平面网络是最容易管理的,你不需要路由器也不需要计算子网,但它也有一些缺点。他们的伸缩性不好,所以当网络规模变得越来越大的时候就会被广播网络所阻塞。 -将你的局域网进行分段将会提升安全保障, 把局域网分成可管理的不同网段将有助于管理更大的网络。 - 图2展示了一个分成两个子网的局域网络:内部的有线和无线主机,和非军事区域(从来不知道所所有的工作上的男性术语都是在计算机上键入的?)因为他被阻挡了所有的内部网络的访问。 +接入你的局域网的无线接入点要么作为一个以太网网桥,要么作为一个路由器。桥接器扩展了这个网络,所以在这个桥接器上的任意一端口上的主机都连接在同一个网络中。一台路由器连接的是两个不同的网络。 +### 网络拓扑 -### [fig-2.png][5] +有多种设置你的局域网的方式,你可以把所有主机接入到一个单独的平面网络flat network,也可以把它们划分为不同的子网。如果你的交换机支持 VLAN 的话,你也可以把它们分配到不同的 VLAN 中。 + +平面网络是最简单的网络,只需把每一台设备接入到同一个交换机上即可,如果一台交换上的端口不够使用,你可以将更多的交换机连接在一起。有些交换机有特殊的上行端口,有些是没有这种特殊限制的上行端口,你可以连接其中的任意端口,你可能需要使用交叉类型的以太网线,所以你要查阅你的交换机的说明文档来设置。 + +平面网络是最容易管理的,你不需要路由器也不需要计算子网,但它也有一些缺点。它们的伸缩性不好,所以当网络规模变得越来越大的时候就会被广播网络所阻塞。将你的局域网进行分段将会提升安全保障, 把局域网分成可管理的不同网段将有助于管理更大的网络。图二展示了一个分成两个子网的局域网络:内部的有线和无线主机,和一个托管公开服务的主机。包含面向公共的服务器的子网称作非军事区域 DMZ,(你有没有注意到那些都是主要在电脑上打字的男人们的术语?)因为它被阻挡了所有的内部网络的访问。 ![LAN](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-2_4.png?itok=LpXq7bLf "LAN") -图2:一个分成两个子网的简单局域网。 -即使像图2那样的小型网络也可以有不同的配置方法。你可以将防火墙和路由器放置在一台单独的设备上。 -你可以为你的非军事区域设置一个专用的网络连接,把它完全从你的内部网络隔离,这将引导我们进入下一个主题:一切基于软件。 +*图二:一个分成两个子网的简单局域网。* +即使像图二那样的小型网络也可以有不同的配置方法。你可以将防火墙和路由器放置在一台单独的设备上。你可以为你的非军事区域设置一个专用的网络连接,把它完全从你的内部网络隔离,这将引导我们进入下一个主题:一切基于软件。 -### Think Software软件思维 +### 软件思维 +你可能已经注意到在这个简短的系列中我们所讨论的硬件,只有网络接口、交换机,和线缆是特殊用途的硬件。 +其它的都是通用的商用硬件,而且都是软件来定义它的用途。Linux 是一个真实的网络操作系统,它支持大量的网络操作:网关、虚拟专用网关、以太网桥、网页、邮箱以及文件等等服务器、负载均衡、代理、服务质量、多种认证、中继、故障转移……你可以在运行着 Linux 系统的标准硬件上运行你的整个网络。你甚至可以使用 Linux 交换应用(LISA)和VDE2 协议来模拟以太网交换机。 -你可能已经注意到在这个简短的系列中我们所讨论的硬件,只有网络接口,交换机,和线缆是特殊用途的硬件。 -其它的都是通用的商用硬件,而且都是软件来定义它的用途。 -网关,虚拟专用网关,以太网桥,网页,邮箱以及文件等等。 -服务器,负载均衡,代理,大量的服务,各种各样的认证,中继,故障转移...你可以在运行着Linux系统的标准硬件上运行你的整个网络。 -你甚至可以使用Linux交换应用和VDE2协议来模拟以太网交换机,像DD-WRT,openWRT 和Rashpberry Pi distros,这些小型的硬件都是有专业的分类的,要记住BSDS和它们的特殊衍生用途如防火墙,路由器,和网络附件存储。 -你知道有些人坚持认为硬件防火墙和软件防火墙有区别?其实是没有区别的,就像说有一台硬件计算机和一台软件计算机。 -### Port Trunking and Ethernet Bonding -端口聚合和以太网绑定 -聚合和绑定,也称链路聚合,是把两条以太网通道绑定在一起成为一条通道。一些交换机支持端口聚合,就是把两个交换机端口绑定在一起成为一个是他们原来带宽之和的一条新的连接。对于一台承载很多业务的服务器来说这是一个增加通道带宽的有效的方式。 -你也可以在以太网口进行同样的配置,而且绑定汇聚的驱动是内置在Linux内核中的,所以不需要任何其他的专门的硬件。 +有一些用于小型硬件的特殊发行版,如 DD-WRT、OpenWRT,以及树莓派发行版,也不要忘记 BSD 们和它们的特殊衍生用途如 pfSense 防火墙/路由器,和 FreeNAS 网络存储服务器。 +你知道有些人坚持认为硬件防火墙和软件防火墙有区别?其实是没有区别的,就像说硬件计算机和软件计算机一样。 -### Bending Mobile Broadband to your Will随心所欲选择你的移动带宽 +### 端口聚合和以太网绑定 -我期望移动带宽能够迅速增长来替代DSL和有线网络。我居住在一个有250,000人口的靠近一个城市的地方,但是在城市以外,要想接入互联网就要靠运气了,即使那里有很大的用户上网需求。我居住的小角落离城镇有20分钟的距离,但对于网络服务供应商来说他们几乎不会考虑到为这个地方提供网络。 我唯一的选择就是移动带宽; 这里没有拨号网络,卫星网络(即使它很糟糕)或者是DSL,电缆,光纤,但却没有阻止网络供应商把那些在我这个区域从没看到过的无限制通信个其他高速网络服务的传单塞进我的邮箱。 -我试用了AT&T,Version,和T-Mobile。Version的信号覆盖范围最广,但是Version和AT&T是最昂贵的。 -我居住的地方在T-Mobile信号覆盖的边缘,但迄今为止他们给了最大的优惠,为了能够能够有效的使用,我必须购买一个WeBoostDe信号放大器和 -一台中兴的移动热点设备。当然你也可以使用一部手机作为热点,但是专用的热点设备有着最强的信号。如果你正在考虑购买一台信号放大器,最好的选择就是WeBoost因为他们的服务支持最棒,而且他们会尽最大努力去帮助你。在一个小小的APP的协助下去设置将会精准的增强 你的网络信号,他们有一个功能较少的免费的版本,但你将一点都不会后悔去花两美元使用专业版。 -那个小巧的中兴热点设备能够支持15台主机而且还有拥有基本的防火墙功能。 但你如果你使用像 Linksys WRT54GL这样的设备,使用Tomato,openWRT,或者DD-WRT来替代普通的固件,这样你就能完全控制你的防护墙规则,路由配置,以及任何其他你想要设置的服务。 +聚合和绑定,也称链路聚合,是把两条以太网通道绑定在一起成为一条通道。一些交换机支持端口聚合,就是把两个交换机端口绑定在一起,成为一个是它们原来带宽之和的一条新的连接。对于一台承载很多业务的服务器来说这是一个增加通道带宽的有效的方式。 + +你也可以在以太网口进行同样的配置,而且绑定汇聚的驱动是内置在 Linux 内核中的,所以不需要任何其他的专门的硬件。 + +### 随心所欲选择你的移动宽带 + +我期望移动宽带能够迅速增长来替代 DSL 和有线网络。我居住在一个有 25 万人口的靠近一个城市的地方,但是在城市以外,要想接入互联网就要靠运气了,即使那里有很大的用户上网需求。我居住的小角落离城镇有 20 分钟的距离,但对于网络服务供应商来说他们几乎不会考虑到为这个地方提供网络。 我唯一的选择就是移动宽带;这里没有拨号网络、卫星网络(即使它很糟糕)或者是 DSL、电缆、光纤,但却没有阻止网络供应商把那些我在这个区域从没看到过的 Xfinity 和其它高速网络服务的传单塞进我的邮箱。 + +我试用了 AT&T、Version 和 T-Mobile。Version 的信号覆盖范围最广,但是 Version 和 AT&T 是最昂贵的。 +我居住的地方在 T-Mobile 信号覆盖的边缘,但迄今为止他们给了最大的优惠,为了能够能够有效的使用,我必须购买一个 WeBoost 信号放大器和一台中兴的移动热点设备。当然你也可以使用一部手机作为热点,但是专用的热点设备有着最强的信号。如果你正在考虑购买一台信号放大器,最好的选择就是 WeBoost,因为他们的服务支持最棒,而且他们会尽最大努力去帮助你。在一个小小的 APP [SignalCheck Pro][8] 的协助下设置将会精准的增强你的网络信号,他们有一个功能较少的免费的版本,但你将一点都不会后悔去花两美元使用专业版。 + +那个小巧的中兴热点设备能够支持 15 台主机,而且还有拥有基本的防火墙功能。 但你如果你使用像 Linksys WRT54GL这样的设备,可以使用 Tomato、OpenWRT,或者 DD-WRT 来替代普通的固件,这样你就能完全控制你的防护墙规则、路由配置,以及任何其它你想要设置的服务。 -------------------------------------------------------------------------------- @@ -74,7 +65,7 @@ via: https://www.linux.com/learn/intro-to-linux/2017/10/linux-networking-hardwar 作者:[CARLA SCHRODER][a] 译者:[FelixYFZ](https://github.com/FelixYFZ) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 498e48cb8397fc6ed84161a6cc861b50ac4145e2 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 5 Dec 2017 22:20:51 +0800 Subject: [PATCH 272/344] PUB:20171012 Linux Networking Hardware for Beginners Think Software.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @FelixYFZ 文章发布地址:https://linux.cn/article-9113-1.html 你的 LCTT 专页地址: https://linux.cn/lctt/FelixYFZ --- ...1012 Linux Networking Hardware for Beginners Think Software.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171012 Linux Networking Hardware for Beginners Think Software.md (100%) diff --git a/translated/tech/20171012 Linux Networking Hardware for Beginners Think Software.md b/published/20171012 Linux Networking Hardware for Beginners Think Software.md similarity index 100% rename from translated/tech/20171012 Linux Networking Hardware for Beginners Think Software.md rename to published/20171012 Linux Networking Hardware for Beginners Think Software.md From 13c499ec00cb26f1fb6f263f95de3f7cb3528564 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 5 Dec 2017 22:43:09 +0800 Subject: [PATCH 273/344] PRF:20171201 How to Manage Users with Groups in Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @imquanquan 翻译的很好,我基本没调整。 --- ...ow to Manage Users with Groups in Linux.md | 70 +++++++------------ 1 file changed, 25 insertions(+), 45 deletions(-) diff --git a/translated/tech/20171201 How to Manage Users with Groups in Linux.md b/translated/tech/20171201 How to Manage Users with Groups in Linux.md index 1927de6817..c9bbf066cd 100644 --- a/translated/tech/20171201 How to Manage Users with Groups in Linux.md +++ b/translated/tech/20171201 How to Manage Users with Groups in Linux.md @@ -1,13 +1,9 @@ -如何在 Linux 系统中用用户组来管理用户 +如何在 Linux 系统中通过用户组来管理用户 ============================================================ -### [group-of-people-1645356_1920.jpg][1] - ![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/group-of-people-1645356_1920.jpg?itok=rJlAxBSV) -本教程可以了解如何通过用户组和访问控制表(ACL)来管理用户。 - -[创意共享协议][4] +> 本教程可以了解如何通过用户组和访问控制表(ACL)来管理用户。 当你需要管理一台容纳多个用户的 Linux 机器时,比起一些基本的用户管理工具所提供的方法,有时候你需要对这些用户采取更多的用户权限管理方式。特别是当你要管理某些用户的权限时,这个想法尤为重要。比如说,你有一个目录,某个用户组中的用户可以通过读和写的权限访问这个目录,而其他用户组中的用户对这个目录只有读的权限。在 Linux 中,这是完全可以实现的。但前提是你必须先了解如何通过用户组和访问控制表(ACL)来管理用户。 @@ -18,36 +14,32 @@ 你需要用下面两个用户名新建两个用户: * olivia - * nathan 你需要新建以下两个用户组: * readers - * editors -olivia 属于 editors 用户组,而 nathan 属于 readers 用户组。reader 用户组对 ``/DATA`` 目录只有读的权限,而 editors 用户组则对 ``/DATA`` 目录同时有读和写的权限。当然,这是个非常小的任务,但它会给你基本的信息·。你可以扩展这个任务以适应你其他更大的需求。 +olivia 属于 editors 用户组,而 nathan 属于 readers 用户组。reader 用户组对 `/DATA` 目录只有读的权限,而 editors 用户组则对 `/DATA` 目录同时有读和写的权限。当然,这是个非常小的任务,但它会给你基本的信息,你可以扩展这个任务以适应你其他更大的需求。 -我将在 Ubuntu 16.04 Server 平台上进行演示。这些命令都是通用的,唯一不同的是,要是在你的发行版中不使用 sudo 命令,你必须切换到 root 用户来执行这些命令。 +我将在 Ubuntu 16.04 Server 平台上进行演示。这些命令都是通用的,唯一不同的是,要是在你的发行版中不使用 `sudo` 命令,你必须切换到 root 用户来执行这些命令。 ### 创建用户 -我们需要做的第一件事是为我们的实验创建两个用户。可以用 ``useradd`` 命令来创建用户,我们不只是简单地创建一个用户,而需要同时创建用户和属于他们的家目录,然后给他们设置密码。 +我们需要做的第一件事是为我们的实验创建两个用户。可以用 `useradd` 命令来创建用户,我们不只是简单地创建一个用户,而需要同时创建用户和属于他们的家目录,然后给他们设置密码。 ``` sudo useradd -m olivia - sudo useradd -m nathan ``` -我们现在创建了两个用户,如果你看看 ``/home`` 目录,你可以发现他们的家目录(因为我们用了 -m 选项,可以帮在创建用户的同时创建他们的家目录。 +我们现在创建了两个用户,如果你看看 `/home` 目录,你可以发现他们的家目录(因为我们用了 `-m` 选项,可以在创建用户的同时创建他们的家目录。 之后,我们可以用以下命令给他们设置密码: ``` sudo passwd olivia - sudo passwd nathan ``` @@ -59,26 +51,21 @@ sudo passwd nathan ``` addgroup readers - addgroup editors ``` -(译者注:当你使用 CentOS 等一些 Linux 发行版时,可能系统没有 addgroup 这个命令,推荐使用 groupadd 命令来替换 addgroup 命令以达到同样的效果) - - -### [groups_1.jpg][2] +(LCTT 译注:当你使用 CentOS 等一些 Linux 发行版时,可能系统没有 `addgroup` 这个命令,推荐使用 `groupadd` 命令来替换 `addgroup` 命令以达到同样的效果) ![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/groups_1.jpg?itok=BKwL89BB) -图一:我们可以使用刚创建的新用户组了。 - -[Used with permission][5] +*图一:我们可以使用刚创建的新用户组了。* 创建用户组后,我们需要添加我们的用户到这两个用户组。我们用以下命令来将 nathan 用户添加到 readers 用户组: ``` sudo usermod -a -G readers nathan ``` + 用以下命令将 olivia 添加到 editors 用户组: ``` @@ -89,7 +76,7 @@ sudo usermod -a -G editors olivia ### 给用户组授予目录的权限 -假设你有个目录 ``/READERS`` 且允许 readers 用户组的所有成员访问这个目录。首先,我们执行以下命令来更改目录所属用户组: +假设你有个目录 `/READERS` 且允许 readers 用户组的所有成员访问这个目录。首先,我们执行以下命令来更改目录所属用户组: ``` sudo chown -R :readers /READERS @@ -107,26 +94,23 @@ sudo chmod -R g-w /READERS sudo chmod -R o-x /READERS ``` -这时候,只有目录的所有者(root)和用户组 reader 中的用户可以访问 ``/READES`` 中的文件。 +这时候,只有目录的所有者(root)和用户组 reader 中的用户可以访问 `/READES` 中的文件。 -假设你有个目录 ``/EDITORS`` ,你需要给用户组 editors 里的成员这个目录的读和写的权限。为了达到这个目的,执行下面的这些命令是必要的: +假设你有个目录 `/EDITORS` ,你需要给用户组 editors 里的成员这个目录的读和写的权限。为了达到这个目的,执行下面的这些命令是必要的: ``` sudo chown -R :editors /EDITORS - sudo chmod -R g+w /EDITORS - sudo chmod -R o-x /EDITORS ``` -此时 editors 用户组的所有成员都可以访问和修改其中的文件。除此之外其他用户(除了 root 之外)无法访问 ``/EDITORS`` 中的任何文件。 +此时 editors 用户组的所有成员都可以访问和修改其中的文件。除此之外其他用户(除了 root 之外)无法访问 `/EDITORS` 中的任何文件。 使用这个方法的问题在于,你一次只能操作一个组和一个目录而已。这时候访问控制表(ACL)就可以派得上用场了。 - ### 使用访问控制表(ACL) -现在,让我们把这个问题变得棘手一点。假设你有一个目录 ``/DATA`` 并且你想给 readers 用户组的成员读取权限并同时给 editors 用户组的成员读和写的权限。为此,你必须要用到 setfacl 命令。setfacl 命令可以为文件或文件夹设置一个访问控制表(ACL)。 +现在,让我们把这个问题变得棘手一点。假设你有一个目录 `/DATA` 并且你想给 readers 用户组的成员读取权限,并同时给 editors 用户组的成员读和写的权限。为此,你必须要用到 `setfacl` 命令。`setfacl` 命令可以为文件或文件夹设置一个访问控制表(ACL)。 这个命令的结构如下: @@ -134,45 +118,41 @@ sudo chmod -R o-x /EDITORS setfacl OPTION X:NAME:Y /DIRECTORY ``` -其中 OPTION 是可选选项,X 可以是 u(用户)或者是 g (用户组),NAME 是用户或者用户组的名字,/DIRECTORY 是要用到的目录。我们将使用 -m 选项进行修改(modify)。因此,我们给 readers 用户组添加读取权限的命令是: +其中 OPTION 是可选选项,X 可以是 `u`(用户)或者是 `g` (用户组),NAME 是用户或者用户组的名字,/DIRECTORY 是要用到的目录。我们将使用 `-m` 选项进行修改。因此,我们给 readers 用户组添加读取权限的命令是: ``` sudo setfacl -m g:readers:rx -R /DATA ``` -现在 readers 用户组里面的每一个用户都可以读取 /DATA 目录里的文件了,但是他们不能修改里面的内容。 +现在 readers 用户组里面的每一个用户都可以读取 `/DATA` 目录里的文件了,但是他们不能修改里面的内容。 为了给 editors 用户组里面的用户读写权限,我们执行了以下命令: ``` sudo setfacl -m g:editors:rwx -R /DATA ``` + 上述命令将赋予 editors 用户组中的任何成员读取权限,同时保留 readers 用户组的只读权限。 ### 更多的权限控制 使用访问控制表(ACL),你可以实现你所需的权限控制。你可以添加用户到用户组,并且灵活地控制这些用户组对每个目录的权限以达到你的需求。如果想了解上述工具的更多信息,可以执行下列的命令: -* man usradd - -* man addgroup - -* man usermod - -* man sefacl - -* man chown - -* man chmod +* `man usradd` +* `man addgroup` +* `man usermod` +* `man sefacl` +* `man chown` +* `man chmod` -------------------------------------------------------------------------------- via: https://www.linux.com/learn/intro-to-linux/2017/12/how-manage-users-groups-linux -作者:[Jack Wallen ] +作者:[Jack Wallen] 译者:[imquanquan](https://github.com/imquanquan) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From c66ccc52bdb0a841bac206168980061a76188e12 Mon Sep 17 00:00:00 2001 From: wenwensnow <963555237@qq.com> Date: Tue, 5 Dec 2017 22:43:32 +0800 Subject: [PATCH 274/344] Update 20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md --- .../20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md b/sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md index b0f8e72018..3f0b8a0f50 100644 --- a/sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md +++ b/sources/tech/20171201 Randomize your WiFi MAC address on Ubuntu 16.04.md @@ -1,3 +1,4 @@ +translating by wenwensnow Randomize your WiFi MAC address on Ubuntu 16.04 ============================================================ From cec664010fec9e893946cc0cfb7b0bd794b82cbe Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 5 Dec 2017 22:43:55 +0800 Subject: [PATCH 275/344] PUB:20171201 How to Manage Users with Groups in Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @imquanquan 文章发布地址:https://linux.cn/article-9114-1.html 你的 LCTT 专页地址: https://linux.cn/lctt/imquanquan --- .../20171201 How to Manage Users with Groups in Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171201 How to Manage Users with Groups in Linux.md (100%) diff --git a/translated/tech/20171201 How to Manage Users with Groups in Linux.md b/published/20171201 How to Manage Users with Groups in Linux.md similarity index 100% rename from translated/tech/20171201 How to Manage Users with Groups in Linux.md rename to published/20171201 How to Manage Users with Groups in Linux.md From b89313e03b88e6234feff0ac3d1d6a929b3c7da9 Mon Sep 17 00:00:00 2001 From: TRsky <625310581@qq.com> Date: Tue, 5 Dec 2017 22:49:08 +0800 Subject: [PATCH 276/344] update --- ...ke up and Shut Down Linux Automatically.md | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md index 5ed3f2bf10..68e49f1e1b 100644 --- a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md +++ b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md @@ -10,35 +10,38 @@ [Creative Commons Attribution][6][The Observatory at Delhi][7] -不要成为一个电能浪费者。如果你的电脑不需要开机就请把他们关机。出于方便和计算机宅的考虑,你可以通过配置你的 Linux 计算机实现自动唤醒和关闭 Linux 。 +不要成为一个电能浪费者。如果你的电脑不需要开机就请把它们关机。出于方便和计算机宅的考虑,你可以通过配置你的 Linux 计算机实现自动唤醒和关闭 Linux 。 ### 系统运行时间 -有时候有些电脑需要一直处在开机状态,在不超过电脑运行时间的限制下这种情况是被允许的。有些人为他们的计算机可以长时间的正常运行而感到自豪,且现在我们有内核热补丁能够实现只有在硬件发生故障时才允许机器关机。我认为比较实际可行的是能够在机器需要节省电能以及在移动硬件发生磨损的情况下,且在不需要机器运行的情况下将其关机。比如,你可以在规定的时间内唤醒备份服务器,执行备份,然后关闭它直到下一次进行备份时间。或者,你可以只在特定时间内配置网卡。任何不需要一直运行的东西都可以将其配置成在其需要工作的时候打开,待其完成工作后将其关闭。 +有时候有些电脑需要一直处在开机状态,在不超过电脑运行时间的限制下这种情况是被允许的。有些人为他们的计算机可以长时间的正常运行而感到自豪,且现在我们有内核热补丁能够实现只有在硬件发生故障时才允许机器关机。我认为比较实际可行的是能够在机器需要节省电能以及在移动硬件发生磨损的情况下,且在不需要机器运行的情况下将其关机。比如,你可以在规定的时间内唤醒备份服务器,执行备份,然后关闭它直到它要进行下一次备份。或者,你可以设置你的 Internet 网关只在特定的时间运行。任何不需要一直运行的东西都可以将其配置成在其需要工作的时候打开,待其完成工作后将其关闭。 ### 系统休眠 -对于不需要一直运行的电脑,使用 root 的 cron 定时任务 或者 /etc/crontab 文件 可以可靠地关闭电脑。这个例子创建一个 root 定时任务实现每天下午 11点15分 定时关机。 +对于不需要一直运行的电脑,使用 root 的 cron 定时任务或者 /etc/crontab 文件 可以可靠地关闭电脑。这个例子创建一个 root 定时任务实现每天下午 11点15分 定时关机。 ``` # crontab -e -u root # m h dom mon dow command 15 23 * * * /sbin/shutdown -h now ``` - +以下示例仅在周一至周五运行: ``` 15 23 * * 1-5 /sbin/shutdown -h now ``` +您可以为不同的日期和时间创建多个cron作业。 通过命令 ``man 5 crontab`` 可以了解所有时间和日期的字段。 -一个快速、容易的方式是,使用 /etc/crontab 文件。你必须指定用户: +一个快速、容易的方式是,使用 /etc/crontab 文件。但这样你必须指定用户: ``` 15 23 * * 1-5 root shutdown -h now ``` -实现自动唤醒是一件很酷的事情;我的大多数 SUSE (SUSE Linux)同事都在纽伦堡,因此,为了能够跟同事的计划有几小时的重叠时间我需要在凌晨5点起床。我的计算机早上 5点半自动开始工作,而我只需要将自己和咖啡拖到我的桌子上就可以开始工作了。按下电源按钮看起来好像并不是什么大事,但是在每天的那个时候每件小事都会变得很大。 +### 自动唤醒 -唤醒 Linux 计算机可能不比关闭它可靠,因此你可能需要尝试不同的办法。你可以使用 远程唤醒(Wake-On-LAN)、RTC 唤醒或者个人电脑的 BIOS 设置预定的唤醒。做这些工作的原因是,当你关闭电脑时,这并不是真正关闭了计算机;此时计算机处在极低功耗状态且还可以接受和响应信号。你需要使用电源开关将其彻底关闭。 +实现自动唤醒是一件很酷的事情; 我大多数使用 SUSE (SUSE Linux)的同事都在纽伦堡,因此,为了能够跟同事的计划有几小时的重叠时间我需要在凌晨5点起床。我的计算机早上 5点半自动开始工作,而我只需要将自己和咖啡拖到我的桌子上就可以开始工作了。按下电源按钮看起来好像并不是什么大事,但是在每天的那个时候每件小事都会变得很大。 + +唤醒 Linux 计算机可能不比关闭它稳当,因此你可能需要尝试不同的办法。你可以使用远程唤醒(Wake-On-LAN)、RTC 唤醒或者个人电脑的 BIOS 设置预定的唤醒这些方式。做这些工作的原因是,当你关闭电脑时,这并不是真正关闭了计算机;此时计算机处在极低功耗状态且还可以接受和响应信号。你需要拔掉电源开关将其彻底关闭。 ### BIOS 唤醒 @@ -55,7 +58,7 @@ Figure 1: My system BIOS has an easy-to-use wakeup scheduler. ### 主机远程唤醒(Wake-On-LAN) -远程唤醒是仅次于 BIOS 唤醒的又一种可靠的唤醒方法。这需要你从第二台计算机发送信号到所要打开的计算机。可以使用 Arduino 或 树莓派(Raspberry Pi) 发送基于 Linux 的路由器或者任何Linux 计算机的唤醒信号。首先,查看系统主板 BIOS 是否支持 Wake-On-LAN –如果支持—然后启动它,因为它被默认为禁用。 +远程唤醒是仅次于 BIOS 唤醒的又一种可靠的唤醒方法。这需要你从第二台计算机发送信号到所要打开的计算机。可以使用 Arduino 或 树莓派(Raspberry Pi) 发送基于 Linux 的路由器或者任何 Linux 计算机的唤醒信号。首先,查看系统主板 BIOS 是否支持 Wake-On-LAN ,要是支持的话,必须先启动它,因为它被默认为禁用。 然后,需要一个支持 Wake-On-LAN 的网卡;无线网卡并不支持。你需要运行 ethtool 命令查看网卡是否支持 Wake-On-LAN : @@ -64,7 +67,8 @@ Figure 1: My system BIOS has an easy-to-use wakeup scheduler. Supports Wake-on: pumbg Wake-on: g ``` - +这条命令输出的 Supports Wake-on字段会告诉你你的网卡现在开启了哪些功能: +    * d -- 禁用 * p -- 物理活动唤醒 @@ -79,14 +83,14 @@ Figure 1: My system BIOS has an easy-to-use wakeup scheduler. * g -- magic packet 唤醒 -* s -- magic packet 设置安全密码 +* s -- 设有密码的 magic packet 唤醒 -man ethtool 并不清楚开关 p 的作用;这表明任何信号都会导致唤醒。在我的测试中,然而,它并没有这么做。Wake-On-Lan 被启动的 Wake-on 参数是 g –- magic packet 唤醒,且当 Wake-On 值已经为 g 时表示网卡已支持 Wake-On-Lan 。如果它没有被启用,你可以通过 ethtool 命令来启用它。 +man ethtool 命令并没说清楚 p 选项的作用;这表明任何信号都会导致唤醒。然而,在我的测试中它并没有这么做。想要实现远程唤醒主机,必须支持的功能是g -- magic packet 唤醒,而且显示这个功能已经在启用了。如果它没有被启用,你可以通过 ethtool 命令来启用它。 ``` # ethtool -s eth0 wol g ``` - +这条命令可能会在重启后失效,所以为了确保万无一失,你可以创建个 root 用户的定时任务(cron)在每次重启的时候来执行这条命令。 ``` @reboot /usr/bin/ethtool -s eth0 wol g ``` @@ -99,17 +103,20 @@ Figure 2: Enable Wake on LAN. [Used with permission][9] -另外一个选择是最近的网络管理器版本有一个很好的小复选框能够唤醒局域网(图2)。 +另一个选择是最近的网络管理器版本有一个很好的小复选框来启用Wake-On-LAN(图2)。 这里有一个可以用于设置密码的地方,但是如果你的网络接口不支持 Secure On password,它就不起作用。 -现在你需要配置第二台计算机来发送唤醒信号。你并不需要 root 权限,所以你可以为你的用户创建 cron 任务。你需要正在唤醒的机器上的网络接口和MAC地址。 +现在你需要配置第二台计算机来发送唤醒信号。你并不需要 root 权限,所以你可以为你的用户创建 cron 任务。你需要用到的是想要唤醒的机器的网络接口和MAC地址信息。 ``` 30 08 * * * /usr/bin/wakeonlan D0:50:99:82:E7:2B ``` +### RTC 唤醒(RTC Alarm Clock) -通过使用实时闹钟来唤醒计算机是最不可靠的方法。查看 [Wake Up Linux With an RTC Alarm Clock][4] ;对于现在的大多数发行版来说这种方法已经有点过时了。下周继续了解更多关于使用RTC唤醒的方法。 +通过使用实时闹钟来唤醒计算机是最不可靠的方法。对于这个方法,可以参看 [Wake Up Linux With an RTC Alarm Clock][4] ;对于现在的大多数发行版来说这种方法已经有点过时了。 + +下周继续了解更多关于使用RTC唤醒的方法。 通过 Linux 基金会和 edX 可以学习更多关于 Linux 的免费 [ Linux 入门][5]教程。 @@ -133,4 +140,3 @@ via:https://www.linux.com/learn/intro-to-linux/2017/11/wake-and-shut-down-linux- [8]:https://www.linux.com/licenses/category/used-permission [9]:https://www.linux.com/licenses/category/used-permission - From 204fb18a8d66db22104a0e8ce9d2fd7c4c86fb90 Mon Sep 17 00:00:00 2001 From: TRsky <625310581@qq.com> Date: Tue, 5 Dec 2017 23:00:52 +0800 Subject: [PATCH 277/344] update --- .../20171130 Wake up and Shut Down Linux Automatically.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md index 68e49f1e1b..9c02d113e9 100644 --- a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md +++ b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md @@ -18,7 +18,7 @@ ### 系统休眠 -对于不需要一直运行的电脑,使用 root 的 cron 定时任务或者 /etc/crontab 文件 可以可靠地关闭电脑。这个例子创建一个 root 定时任务实现每天下午 11点15分 定时关机。 +对于不需要一直运行的电脑,使用 root 的 cron 定时任务或者 `/etc/crontab` 文件 可以可靠地关闭电脑。这个例子创建一个 root 定时任务实现每天下午 11点15分 定时关机。 ``` # crontab -e -u root @@ -39,7 +39,7 @@ ### 自动唤醒 -实现自动唤醒是一件很酷的事情; 我大多数使用 SUSE (SUSE Linux)的同事都在纽伦堡,因此,为了能够跟同事的计划有几小时的重叠时间我需要在凌晨5点起床。我的计算机早上 5点半自动开始工作,而我只需要将自己和咖啡拖到我的桌子上就可以开始工作了。按下电源按钮看起来好像并不是什么大事,但是在每天的那个时候每件小事都会变得很大。 +实现自动唤醒是一件很酷的事情; 我大多数使用 SUSE (SUSE Linux)的同事都在纽伦堡,因此,因此为了跟同事能有几小时一起工作的时间,我不得不需要在凌晨五点起床。我的计算机早上 5点半自动开始工作,而我只需要将自己和咖啡拖到我的桌子上就可以开始工作了。按下电源按钮看起来好像并不是什么大事,但是在每天的那个时候每件小事都会变得很大。 唤醒 Linux 计算机可能不比关闭它稳当,因此你可能需要尝试不同的办法。你可以使用远程唤醒(Wake-On-LAN)、RTC 唤醒或者个人电脑的 BIOS 设置预定的唤醒这些方式。做这些工作的原因是,当你关闭电脑时,这并不是真正关闭了计算机;此时计算机处在极低功耗状态且还可以接受和响应信号。你需要拔掉电源开关将其彻底关闭。 @@ -79,7 +79,7 @@ Figure 1: My system BIOS has an easy-to-use wakeup scheduler. * b -- 广播消息唤醒 -* a -- ARP(Address Resolution Protocol)唤醒 +* a -- ARP(Address Resolution Protocol) 唤醒 * g -- magic packet 唤醒 From 8b0e3c185d7b2c03894396db28c6a8ab657c02dd Mon Sep 17 00:00:00 2001 From: TRsky <625310581@qq.com> Date: Tue, 5 Dec 2017 23:04:43 +0800 Subject: [PATCH 278/344] translated by HardworkFish --- ...ke up and Shut Down Linux Automatically.md | 142 ++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 translated/tech/20171130 Wake up and Shut Down Linux Automatically.md diff --git a/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md b/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md new file mode 100644 index 0000000000..9c02d113e9 --- /dev/null +++ b/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md @@ -0,0 +1,142 @@ + +自动唤醒和关闭 Linux +===================== + +### [banner.jpg][1] + +![timekeeper](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/banner.jpg?itok=zItspoSb) + +了解如何通过配置 Linux 计算机来查看时间,并实现自动唤醒和关闭 Linux + +[Creative Commons Attribution][6][The Observatory at Delhi][7] + +不要成为一个电能浪费者。如果你的电脑不需要开机就请把它们关机。出于方便和计算机宅的考虑,你可以通过配置你的 Linux 计算机实现自动唤醒和关闭 Linux 。 + +### 系统运行时间 + +有时候有些电脑需要一直处在开机状态,在不超过电脑运行时间的限制下这种情况是被允许的。有些人为他们的计算机可以长时间的正常运行而感到自豪,且现在我们有内核热补丁能够实现只有在硬件发生故障时才允许机器关机。我认为比较实际可行的是能够在机器需要节省电能以及在移动硬件发生磨损的情况下,且在不需要机器运行的情况下将其关机。比如,你可以在规定的时间内唤醒备份服务器,执行备份,然后关闭它直到它要进行下一次备份。或者,你可以设置你的 Internet 网关只在特定的时间运行。任何不需要一直运行的东西都可以将其配置成在其需要工作的时候打开,待其完成工作后将其关闭。 + +### 系统休眠 + +对于不需要一直运行的电脑,使用 root 的 cron 定时任务或者 `/etc/crontab` 文件 可以可靠地关闭电脑。这个例子创建一个 root 定时任务实现每天下午 11点15分 定时关机。 + +``` +# crontab -e -u root +# m h dom mon dow command +15 23 * * * /sbin/shutdown -h now +``` +以下示例仅在周一至周五运行: +``` +15 23 * * 1-5 /sbin/shutdown -h now +``` +您可以为不同的日期和时间创建多个cron作业。 通过命令 ``man 5 crontab`` 可以了解所有时间和日期的字段。 + +一个快速、容易的方式是,使用 /etc/crontab 文件。但这样你必须指定用户: + +``` +15 23 * * 1-5 root shutdown -h now +``` + +### 自动唤醒 + +实现自动唤醒是一件很酷的事情; 我大多数使用 SUSE (SUSE Linux)的同事都在纽伦堡,因此,因此为了跟同事能有几小时一起工作的时间,我不得不需要在凌晨五点起床。我的计算机早上 5点半自动开始工作,而我只需要将自己和咖啡拖到我的桌子上就可以开始工作了。按下电源按钮看起来好像并不是什么大事,但是在每天的那个时候每件小事都会变得很大。 + +唤醒 Linux 计算机可能不比关闭它稳当,因此你可能需要尝试不同的办法。你可以使用远程唤醒(Wake-On-LAN)、RTC 唤醒或者个人电脑的 BIOS 设置预定的唤醒这些方式。做这些工作的原因是,当你关闭电脑时,这并不是真正关闭了计算机;此时计算机处在极低功耗状态且还可以接受和响应信号。你需要拔掉电源开关将其彻底关闭。 + +### BIOS 唤醒 + +BIOS 唤醒是最可靠的。我的系统主板 BIOS 有一个易于使用的唤醒调度程序。(Figure 1). Chances are yours does, too. Easy peasy. + +### [fig-1.png][2] + +![wakeup](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_11.png?itok=8qAeqo1I) + +Figure 1: My system BIOS has an easy-to-use wakeup scheduler. + +[Used with permission][8] + + +### 主机远程唤醒(Wake-On-LAN) + +远程唤醒是仅次于 BIOS 唤醒的又一种可靠的唤醒方法。这需要你从第二台计算机发送信号到所要打开的计算机。可以使用 Arduino 或 树莓派(Raspberry Pi) 发送基于 Linux 的路由器或者任何 Linux 计算机的唤醒信号。首先,查看系统主板 BIOS 是否支持 Wake-On-LAN ,要是支持的话,必须先启动它,因为它被默认为禁用。 + +然后,需要一个支持 Wake-On-LAN 的网卡;无线网卡并不支持。你需要运行 ethtool 命令查看网卡是否支持 Wake-On-LAN : + +``` +# ethtool eth0 | grep -i wake-on + Supports Wake-on: pumbg + Wake-on: g +``` +这条命令输出的 Supports Wake-on字段会告诉你你的网卡现在开启了哪些功能: +    +* d -- 禁用 + +* p -- 物理活动唤醒 + +* u -- 单播消息唤醒 + +* m -- 多播(组播)消息唤醒 + +* b -- 广播消息唤醒 + +* a -- ARP(Address Resolution Protocol) 唤醒 + +* g -- magic packet 唤醒 + +* s -- 设有密码的 magic packet 唤醒 + +man ethtool 命令并没说清楚 p 选项的作用;这表明任何信号都会导致唤醒。然而,在我的测试中它并没有这么做。想要实现远程唤醒主机,必须支持的功能是g -- magic packet 唤醒,而且显示这个功能已经在启用了。如果它没有被启用,你可以通过 ethtool 命令来启用它。 + +``` +# ethtool -s eth0 wol g +``` +这条命令可能会在重启后失效,所以为了确保万无一失,你可以创建个 root 用户的定时任务(cron)在每次重启的时候来执行这条命令。 +``` +@reboot /usr/bin/ethtool -s eth0 wol g +``` + +### [fig-2.png][3] + +![wakeonlan](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-2_7.png?itok=XQAwmHoQ) + +Figure 2: Enable Wake on LAN. + +[Used with permission][9] + +另一个选择是最近的网络管理器版本有一个很好的小复选框来启用Wake-On-LAN(图2)。 + +这里有一个可以用于设置密码的地方,但是如果你的网络接口不支持 Secure On password,它就不起作用。 + +现在你需要配置第二台计算机来发送唤醒信号。你并不需要 root 权限,所以你可以为你的用户创建 cron 任务。你需要用到的是想要唤醒的机器的网络接口和MAC地址信息。 + +``` +30 08 * * * /usr/bin/wakeonlan D0:50:99:82:E7:2B +``` +### RTC 唤醒(RTC Alarm Clock) + +通过使用实时闹钟来唤醒计算机是最不可靠的方法。对于这个方法,可以参看 [Wake Up Linux With an RTC Alarm Clock][4] ;对于现在的大多数发行版来说这种方法已经有点过时了。 + +下周继续了解更多关于使用RTC唤醒的方法。 + +通过 Linux 基金会和 edX 可以学习更多关于 Linux 的免费 [ Linux 入门][5]教程。 + +-------------------------------------------------------------------------------- + +via:https://www.linux.com/learn/intro-to-linux/2017/11/wake-and-shut-down-linux-automatically + +作者:[Carla Schroder] +译者:[译者ID](https://github.com/HardworkFish) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://www.linux.com/files/images/bannerjpg +[2]:https://www.linux.com/files/images/fig-1png-11 +[3]:https://www.linux.com/files/images/fig-2png-7 +[4]:https://www.linux.com/learn/wake-linux-rtc-alarm-clock +[5]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux +[6]:https://www.linux.com/licenses/category/creative-commons-attribution +[7]:http://www.columbia.edu/itc/mealac/pritchett/00routesdata/1700_1799/jaipur/delhijantarearly/delhijantarearly.html +[8]:https://www.linux.com/licenses/category/used-permission +[9]:https://www.linux.com/licenses/category/used-permission + From 1e85ca2c64981a4ecdfc7566b44986ae7754dd35 Mon Sep 17 00:00:00 2001 From: TRsky <625310581@qq.com> Date: Tue, 5 Dec 2017 23:25:06 +0800 Subject: [PATCH 279/344] translated by HardworkFish --- .../20171130 Wake up and Shut Down Linux Automatically.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md b/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md index 9c02d113e9..4b02fce189 100644 --- a/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md +++ b/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md @@ -60,7 +60,7 @@ Figure 1: My system BIOS has an easy-to-use wakeup scheduler. 远程唤醒是仅次于 BIOS 唤醒的又一种可靠的唤醒方法。这需要你从第二台计算机发送信号到所要打开的计算机。可以使用 Arduino 或 树莓派(Raspberry Pi) 发送基于 Linux 的路由器或者任何 Linux 计算机的唤醒信号。首先,查看系统主板 BIOS 是否支持 Wake-On-LAN ,要是支持的话,必须先启动它,因为它被默认为禁用。 -然后,需要一个支持 Wake-On-LAN 的网卡;无线网卡并不支持。你需要运行 ethtool 命令查看网卡是否支持 Wake-On-LAN : +然后,需要一个支持 Wake-On-LAN 的网卡;无线网卡并不支持。你需要运行 `ethtool` 命令查看网卡是否支持 Wake-On-LAN : ``` # ethtool eth0 | grep -i wake-on @@ -85,7 +85,7 @@ Figure 1: My system BIOS has an easy-to-use wakeup scheduler. * s -- 设有密码的 magic packet 唤醒 -man ethtool 命令并没说清楚 p 选项的作用;这表明任何信号都会导致唤醒。然而,在我的测试中它并没有这么做。想要实现远程唤醒主机,必须支持的功能是g -- magic packet 唤醒,而且显示这个功能已经在启用了。如果它没有被启用,你可以通过 ethtool 命令来启用它。 +man ethtool 命令并没说清楚 p 选项的作用;这表明任何信号都会导致唤醒。然而,在我的测试中它并没有这么做。想要实现远程唤醒主机,必须支持的功能是 `g -- magic packet` 唤醒,而且显示这个功能已经在启用了。如果它没有被启用,你可以通过 `ethtool` 命令来启用它。 ``` # ethtool -s eth0 wol g From a07b81629d52df95574f23a897e49a0ada5ace96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=91=E9=AD=85=E9=AD=8D=E9=AD=89?= <625310581@qq.com> Date: Tue, 5 Dec 2017 23:32:38 +0800 Subject: [PATCH 280/344] translated by HardworkFish --- .../20171130 Wake up and Shut Down Linux Automatically.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md b/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md index 4b02fce189..a4b829620f 100644 --- a/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md +++ b/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md @@ -31,7 +31,7 @@ ``` 您可以为不同的日期和时间创建多个cron作业。 通过命令 ``man 5 crontab`` 可以了解所有时间和日期的字段。 -一个快速、容易的方式是,使用 /etc/crontab 文件。但这样你必须指定用户: +一个快速、容易的方式是,使用 `/etc/crontab ` 文件。但这样你必须指定用户: ``` 15 23 * * 1-5 root shutdown -h now @@ -67,7 +67,7 @@ Figure 1: My system BIOS has an easy-to-use wakeup scheduler. Supports Wake-on: pumbg Wake-on: g ``` -这条命令输出的 Supports Wake-on字段会告诉你你的网卡现在开启了哪些功能: +这条命令输出的 Supports Wake-on 字段会告诉你你的网卡现在开启了哪些功能:     * d -- 禁用 @@ -103,9 +103,9 @@ Figure 2: Enable Wake on LAN. [Used with permission][9] -另一个选择是最近的网络管理器版本有一个很好的小复选框来启用Wake-On-LAN(图2)。 +另一个选择是最近的网络管理器版本有一个很好的小复选框来启用 Wake-On-LAN(图2)。 -这里有一个可以用于设置密码的地方,但是如果你的网络接口不支持 Secure On password,它就不起作用。 +这里有一个可以用于设置密码的地方,但是如果你的网络接口不支持安全密码,它就不起作用。 现在你需要配置第二台计算机来发送唤醒信号。你并不需要 root 权限,所以你可以为你的用户创建 cron 任务。你需要用到的是想要唤醒的机器的网络接口和MAC地址信息。 From 7d8fba497f003426ad862860bb9ad9f6de586b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=91=E9=AD=85=E9=AD=8D=E9=AD=89?= <625310581@qq.com> Date: Tue, 5 Dec 2017 23:35:17 +0800 Subject: [PATCH 281/344] finish translation by HardworkFish --- ...ke up and Shut Down Linux Automatically.md | 142 ------------------ 1 file changed, 142 deletions(-) delete mode 100644 sources/tech/20171130 Wake up and Shut Down Linux Automatically.md diff --git a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md b/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md deleted file mode 100644 index 9c02d113e9..0000000000 --- a/sources/tech/20171130 Wake up and Shut Down Linux Automatically.md +++ /dev/null @@ -1,142 +0,0 @@ - -自动唤醒和关闭 Linux -===================== - -### [banner.jpg][1] - -![timekeeper](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/banner.jpg?itok=zItspoSb) - -了解如何通过配置 Linux 计算机来查看时间,并实现自动唤醒和关闭 Linux - -[Creative Commons Attribution][6][The Observatory at Delhi][7] - -不要成为一个电能浪费者。如果你的电脑不需要开机就请把它们关机。出于方便和计算机宅的考虑,你可以通过配置你的 Linux 计算机实现自动唤醒和关闭 Linux 。 - -### 系统运行时间 - -有时候有些电脑需要一直处在开机状态,在不超过电脑运行时间的限制下这种情况是被允许的。有些人为他们的计算机可以长时间的正常运行而感到自豪,且现在我们有内核热补丁能够实现只有在硬件发生故障时才允许机器关机。我认为比较实际可行的是能够在机器需要节省电能以及在移动硬件发生磨损的情况下,且在不需要机器运行的情况下将其关机。比如,你可以在规定的时间内唤醒备份服务器,执行备份,然后关闭它直到它要进行下一次备份。或者,你可以设置你的 Internet 网关只在特定的时间运行。任何不需要一直运行的东西都可以将其配置成在其需要工作的时候打开,待其完成工作后将其关闭。 - -### 系统休眠 - -对于不需要一直运行的电脑,使用 root 的 cron 定时任务或者 `/etc/crontab` 文件 可以可靠地关闭电脑。这个例子创建一个 root 定时任务实现每天下午 11点15分 定时关机。 - -``` -# crontab -e -u root -# m h dom mon dow command -15 23 * * * /sbin/shutdown -h now -``` -以下示例仅在周一至周五运行: -``` -15 23 * * 1-5 /sbin/shutdown -h now -``` -您可以为不同的日期和时间创建多个cron作业。 通过命令 ``man 5 crontab`` 可以了解所有时间和日期的字段。 - -一个快速、容易的方式是,使用 /etc/crontab 文件。但这样你必须指定用户: - -``` -15 23 * * 1-5 root shutdown -h now -``` - -### 自动唤醒 - -实现自动唤醒是一件很酷的事情; 我大多数使用 SUSE (SUSE Linux)的同事都在纽伦堡,因此,因此为了跟同事能有几小时一起工作的时间,我不得不需要在凌晨五点起床。我的计算机早上 5点半自动开始工作,而我只需要将自己和咖啡拖到我的桌子上就可以开始工作了。按下电源按钮看起来好像并不是什么大事,但是在每天的那个时候每件小事都会变得很大。 - -唤醒 Linux 计算机可能不比关闭它稳当,因此你可能需要尝试不同的办法。你可以使用远程唤醒(Wake-On-LAN)、RTC 唤醒或者个人电脑的 BIOS 设置预定的唤醒这些方式。做这些工作的原因是,当你关闭电脑时,这并不是真正关闭了计算机;此时计算机处在极低功耗状态且还可以接受和响应信号。你需要拔掉电源开关将其彻底关闭。 - -### BIOS 唤醒 - -BIOS 唤醒是最可靠的。我的系统主板 BIOS 有一个易于使用的唤醒调度程序。(Figure 1). Chances are yours does, too. Easy peasy. - -### [fig-1.png][2] - -![wakeup](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_11.png?itok=8qAeqo1I) - -Figure 1: My system BIOS has an easy-to-use wakeup scheduler. - -[Used with permission][8] - - -### 主机远程唤醒(Wake-On-LAN) - -远程唤醒是仅次于 BIOS 唤醒的又一种可靠的唤醒方法。这需要你从第二台计算机发送信号到所要打开的计算机。可以使用 Arduino 或 树莓派(Raspberry Pi) 发送基于 Linux 的路由器或者任何 Linux 计算机的唤醒信号。首先,查看系统主板 BIOS 是否支持 Wake-On-LAN ,要是支持的话,必须先启动它,因为它被默认为禁用。 - -然后,需要一个支持 Wake-On-LAN 的网卡;无线网卡并不支持。你需要运行 ethtool 命令查看网卡是否支持 Wake-On-LAN : - -``` -# ethtool eth0 | grep -i wake-on - Supports Wake-on: pumbg - Wake-on: g -``` -这条命令输出的 Supports Wake-on字段会告诉你你的网卡现在开启了哪些功能: -    -* d -- 禁用 - -* p -- 物理活动唤醒 - -* u -- 单播消息唤醒 - -* m -- 多播(组播)消息唤醒 - -* b -- 广播消息唤醒 - -* a -- ARP(Address Resolution Protocol) 唤醒 - -* g -- magic packet 唤醒 - -* s -- 设有密码的 magic packet 唤醒 - -man ethtool 命令并没说清楚 p 选项的作用;这表明任何信号都会导致唤醒。然而,在我的测试中它并没有这么做。想要实现远程唤醒主机,必须支持的功能是g -- magic packet 唤醒,而且显示这个功能已经在启用了。如果它没有被启用,你可以通过 ethtool 命令来启用它。 - -``` -# ethtool -s eth0 wol g -``` -这条命令可能会在重启后失效,所以为了确保万无一失,你可以创建个 root 用户的定时任务(cron)在每次重启的时候来执行这条命令。 -``` -@reboot /usr/bin/ethtool -s eth0 wol g -``` - -### [fig-2.png][3] - -![wakeonlan](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-2_7.png?itok=XQAwmHoQ) - -Figure 2: Enable Wake on LAN. - -[Used with permission][9] - -另一个选择是最近的网络管理器版本有一个很好的小复选框来启用Wake-On-LAN(图2)。 - -这里有一个可以用于设置密码的地方,但是如果你的网络接口不支持 Secure On password,它就不起作用。 - -现在你需要配置第二台计算机来发送唤醒信号。你并不需要 root 权限,所以你可以为你的用户创建 cron 任务。你需要用到的是想要唤醒的机器的网络接口和MAC地址信息。 - -``` -30 08 * * * /usr/bin/wakeonlan D0:50:99:82:E7:2B -``` -### RTC 唤醒(RTC Alarm Clock) - -通过使用实时闹钟来唤醒计算机是最不可靠的方法。对于这个方法,可以参看 [Wake Up Linux With an RTC Alarm Clock][4] ;对于现在的大多数发行版来说这种方法已经有点过时了。 - -下周继续了解更多关于使用RTC唤醒的方法。 - -通过 Linux 基金会和 edX 可以学习更多关于 Linux 的免费 [ Linux 入门][5]教程。 - --------------------------------------------------------------------------------- - -via:https://www.linux.com/learn/intro-to-linux/2017/11/wake-and-shut-down-linux-automatically - -作者:[Carla Schroder] -译者:[译者ID](https://github.com/HardworkFish) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[1]:https://www.linux.com/files/images/bannerjpg -[2]:https://www.linux.com/files/images/fig-1png-11 -[3]:https://www.linux.com/files/images/fig-2png-7 -[4]:https://www.linux.com/learn/wake-linux-rtc-alarm-clock -[5]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux -[6]:https://www.linux.com/licenses/category/creative-commons-attribution -[7]:http://www.columbia.edu/itc/mealac/pritchett/00routesdata/1700_1799/jaipur/delhijantarearly/delhijantarearly.html -[8]:https://www.linux.com/licenses/category/used-permission -[9]:https://www.linux.com/licenses/category/used-permission - From f01eac69d05de4a92aebdf0602feaa280338616a Mon Sep 17 00:00:00 2001 From: Yixun Xu Date: Tue, 5 Dec 2017 10:40:50 -0500 Subject: [PATCH 282/344] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E8=AE=A4=E9=A2=86=20?= =?UTF-8?q?30=20Best=20Linux=20Games...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...1204 30 Best Linux Games On Steam You Should Play in 2017.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md b/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md index 3248358b37..7a14f92847 100644 --- a/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md +++ b/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md @@ -1,3 +1,5 @@ +yixunx translating + 30 Best Linux Games On Steam You Should Play in 2017 ============================================================ From 7f54fbf12e9ce45dc7859ed0eb323fa79d3be37e Mon Sep 17 00:00:00 2001 From: aiwhj Date: Wed, 6 Dec 2017 01:40:45 +0800 Subject: [PATCH 283/344] translated --- ...actices for getting started with DevOps.md | 95 ------------------- ...actices for getting started with DevOps.md | 92 ++++++++++++++++++ 2 files changed, 92 insertions(+), 95 deletions(-) delete mode 100644 sources/tech/20171129 5 best practices for getting started with DevOps.md create mode 100644 translated/tech/20171129 5 best practices for getting started with DevOps.md diff --git a/sources/tech/20171129 5 best practices for getting started with DevOps.md b/sources/tech/20171129 5 best practices for getting started with DevOps.md deleted file mode 100644 index 7694180c14..0000000000 --- a/sources/tech/20171129 5 best practices for getting started with DevOps.md +++ /dev/null @@ -1,95 +0,0 @@ -translating---aiwhj -5 best practices for getting started with DevOps -============================================================ - -### Are you ready to implement DevOps, but don't know where to begin? Try these five best practices. - - -![5 best practices for getting started with DevOps](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/devops-gears.png?itok=rUejbLQX "5 best practices for getting started with DevOps") -Image by :  - -[Andrew Magill][8]. Modified by Opensource.com. [CC BY 4.0][9] - -DevOps often stymies early adopters with its ambiguity, not to mention its depth and breadth. By the time someone buys into the idea of DevOps, their first questions usually are: "How do I get started?" and "How do I measure success?" These five best practices are a great road map to starting your DevOps journey. - -### 1\. Measure all the things - -You don't know for sure that your efforts are even making things better unless you can quantify the outcomes. Are my features getting out to customers more rapidly? Are fewer defects escaping to them? Are we responding to and recovering more quickly from failure? - -Before you change anything, think about what kinds of outcomes you expect from your DevOps transformation. When you're further into your DevOps journey, you'll enjoy a rich array of near-real-time reports on everything about your service. But consider starting with these two metrics: - -* **Time to market** measures the end-to-end, often customer-facing, business experience. It usually begins when a feature is formally conceived and ends when the customer can consume the feature in production. Time to market is not mainly an engineering team metric; more importantly it shows your business' complete end-to-end efficiency in bringing valuable new features to market and isolates opportunities for system-wide improvement. - -* **Cycle time** measures the engineering team process. Once work on a new feature starts, when does it become available in production? This metric is very useful for understanding the efficiency of the engineering team and isolating opportunities for team-level improvement. - -### 2\. Get your process off the ground - -DevOps success requires an organization to put a regular (and hopefully effective) process in place and relentlessly improve upon it. It doesn't have to start out being effective, but it must be a regular process. Usually that it's some flavor of agile methodology like Scrum or Scrumban; sometimes it's a Lean derivative. Whichever way you go, pick a formal process, start using it, and get the basics right. - -Regular inspect-and-adapt behaviors are key to your DevOps success. Make good use of opportunities like the stakeholder demo, team retrospectives, and daily standups to find opportunities to improve your process. - -A lot of your DevOps success hinges on people working effectively together. People on a team need to work from a common process that they are empowered to improve upon. They also need regular opportunities to share what they are learning with other stakeholders, both upstream and downstream, in the process. - -Good process discipline will help your organization consume the other benefits of DevOps at the great speed that comes as your success builds. - -Although it's common for more development-oriented teams to successfully adopt processes like Scrum, operations-focused teams (or others that are more interrupt-driven) may opt for a process with a more near-term commitment horizon, such as Kanban. - -### 3\. Visualize your end-to-end workflow - -There is tremendous power in being able to see who's working on what part of your service at any given time. Visualizing your workflow will help people know what they need to work on next, how much work is in progress, and where the bottlenecks are in the process. - -You can't effectively limit work in process until you can see it and quantify it. Likewise, you can't effectively eliminate bottlenecks until you can clearly see them. - -Visualizing the entire workflow will help people in all parts of the organization understand how their work contributes to the success of the whole. It can catalyze relationship-building across organizational boundaries to help your teams collaborate more effectively towards a shared sense of success. - -### 4\. Continuous all the things - -DevOps promises a dizzying array of compelling automation. But Rome wasn't built in a day. One of the first areas you can focus your efforts on is [continuous integration][10] (CI). But don't stop there; you'll want to follow quickly with [continuous delivery][11] (CD) and eventually continuous deployment. - -Your CD pipeline is your opportunity to inject all manner of automated quality testing into your process. The moment new code is committed, your CD pipeline should run a battery of tests against the code and the successfully built artifact. The artifact that comes out at the end of this gauntlet is what progresses along your process until eventually it's seen by customers in production. - -Another "continuous" that doesn't get enough attention is continuous improvement. That's as simple as setting some time aside each day to ask your colleagues: "What small thing can we do today to get better at how we do our work?" These small, daily changes compound over time into more profound results. You'll be pleasantly surprised! But it also gets people thinking all the time about how to improve things. - -### 5\. Gherkinize - -Fostering more effective communication across your organization is crucial to fostering the sort of systems thinking prevalent in successful DevOps journeys. One way to help that along is to use a shared language between the business and the engineers to express the desired acceptance criteria for new features. A good product manager can learn [Gherkin][12] in a day and begin using it to express acceptance criteria in an unambiguous, structured form of plain English. Engineers can use this Gherkinized acceptance criteria to write acceptance tests against the criteria, and then develop their feature code until the tests pass. This is a simplification of [acceptance test-driven development][13](ATDD) that can also help kick start your DevOps culture and engineering practice. - -### Start on your journey - -Don't be discouraged by getting started with your DevOps practice. It's a journey. And hopefully these five ideas give you solid ways to get started. - - -### About the author - - [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/headshot_4.jpg?itok=jntfDCfX)][14] - - Magnus Hedemark - Magnus has been in the IT industry for over 20 years, and a technology enthusiast for most of his life. He's presently Manager of DevOps Engineering at UnitedHealth Group. In his spare time, Magnus enjoys photography and paddling canoes. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/11/5-keys-get-started-devops - -作者:[Magnus Hedemark ][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/magnus919 -[1]:https://opensource.com/tags/devops?src=devops_resource_menu1 -[2]:https://opensource.com/resources/devops?src=devops_resource_menu2 -[3]:https://www.openshift.com/promotions/devops-with-openshift.html?intcmp=7016000000127cYAAQ&src=devops_resource_menu3 -[4]:https://enterprisersproject.com/article/2017/5/9-key-phrases-devops?intcmp=7016000000127cYAAQ&src=devops_resource_menu4 -[5]:https://www.redhat.com/en/insights/devops?intcmp=7016000000127cYAAQ&src=devops_resource_menu5 -[6]:https://opensource.com/article/17/11/5-keys-get-started-devops?rate=oEOzMXx1ghbkfl2a5ae6AnvO88iZ3wzkk53K2CzbDWI -[7]:https://opensource.com/user/25739/feed -[8]:https://ccsearch.creativecommons.org/image/detail/7qRx_yrcN5isTMS0u9iKMA== -[9]:https://creativecommons.org/licenses/by-sa/4.0/ -[10]:https://martinfowler.com/articles/continuousIntegration.html -[11]:https://martinfowler.com/bliki/ContinuousDelivery.html -[12]:https://cucumber.io/docs/reference -[13]:https://en.wikipedia.org/wiki/Acceptance_test%E2%80%93driven_development -[14]:https://opensource.com/users/magnus919 -[15]:https://opensource.com/users/magnus919 -[16]:https://opensource.com/users/magnus919 -[17]:https://opensource.com/tags/devops diff --git a/translated/tech/20171129 5 best practices for getting started with DevOps.md b/translated/tech/20171129 5 best practices for getting started with DevOps.md new file mode 100644 index 0000000000..3fa96176d5 --- /dev/null +++ b/translated/tech/20171129 5 best practices for getting started with DevOps.md @@ -0,0 +1,92 @@ +5 个最佳实践开始你的 DevOps 之旅 +============================================================ + +### 想要实现 DevOps 但是不知道如何开始吗?试试这 5 个最佳实践吧。 + + +![5 best practices for getting started with DevOps](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/devops-gears.png?itok=rUejbLQX "5 best practices for getting started with DevOps") + +Image by : [Andrew Magill][8]. Modified by Opensource.com. [CC BY 4.0][9] + +想要采用 DevOps 的人通常会过早的被它的歧义性给吓跑,更不要说更加深入的使用了。当一些人开始使用 DevOps 的时候都会问:“如何开始使用呢?”,”怎么才算使用了呢?“。这 5 个最佳实践是很好的路线图来指导你的 DevOps 之旅。 + +### 1\. 衡量所有的事情 + +除非你能量化输出结果,否则你并不能确认你的努力能否使事情变得更好。新功能能否快速的输出给客户?有更少的漏洞泄漏给他们吗?出错了能快速应对和恢复吗? + +在你开始做任何修改之前,思考一下你切换到 DevOps 之后想要一些什么样的输出。随着你的 DevOps 之旅,将享受到服务的所有内容的丰富的实时报告,从这两个指标考虑一下: + +* **上架时间** 衡量端到端,通常是面向客户的业务经验。这通常从一个功能被正式提出而开始,客户在产品中开始使用这个功能而结束。上架时间不是团队的主要指标;更加重要的是,当开发出一个有价值的新功能时,它表明了你完成业务的效率,为系统改进提供了一个机会。 + +* **时间周期** 衡量工程团队的进度。从开始开发一个新功能开始,到在产品中运行需要多久?这个指标对于你理解团队的效率是非常有用的,为团队等级的提升提供了一个机会。 + +### 2\. 放飞你的流程 + +DevOps 的成功需要团队布置一个定期流程并且持续提升它。这不总是有效的,但是必须是一个定期(希望有效)的流程。通常它有一些敏捷开发的味道,就像 Scrum 或者 Scrumban 一样;一些时候它也像精益开发。不论你用的什么方法,挑选一个正式的流程,开始使用它,并且做好这些基础。 + +定期检查和调整流程是 DevOps 成功的关键,抓住相关演示,团队回顾,每日会议的机会来提升你的流程。 + +DevOps 的成功取决于大家一起有效的工作。团队的成员需要在一个有权改进的公共流程中工作。他们也需要定期找机会分享从这个流程中上游或下游的其他人那里学到的东西。 + +随着你构建成功。好的流程规范能帮助你的团队以很快的速度体会到 DevOps 其他的好处 + +尽管更多面向开发的团队采用 Scrum 是常见的,但是以运营为中心的团队(或者其他中断驱动的团队)可能选用一个更短期的流程,例如 Kanban。 + +### 3\. 可视化工作流程 +这是很强大的,能够看到哪个人在给定的时间做哪一部分工作,可视化你的工作流程能帮助大家知道接下来应该做什么,流程中有多少工作以及流程中的瓶颈在哪里。 + +在你看到和衡量之前你并不能有效的限制流程中的工作。同样的,你也不能有效的排除瓶颈直到你清楚的看到它。 + +全部工作可视化能帮助团队中的成员了解他们在整个工作中的贡献。这样可以促进跨组织边界的关系建设,帮助您的团队更有效地协作,实现共同的成就感。 + +### 4\. 持续化所有的事情 + +DevOps 应该是强制自动化的。然而罗马不是一日建成的。你应该注意的第一个事情应该是努力的持续集成(CI),但是不要停留到这里;紧接着的是持续交付(CD)以及最终的持续部署。 + +持续部署的过程中是个注入自动测试的好时机。这个时候新代码刚被提交,你的持续部署应该运行测试代码来测试你的代码和构建成功的加工品。这个加工品经受流程的考验被产出直到最终被客户看到。 + +另一个“持续”是不太引人注意的持续改进。一个简单的场景是每天询问你旁边的同事:“今天做些什么能使工作变得更好?”,随着时间的推移,这些日常的小改进融合到一起会引起很大的结果,你将很惊喜!但是这也会让人一直思考着如何改进。 + +### 5\. Gherkinize + +促进组织间更有效的沟通对于成功的 DevOps 的系统思想至关重要。在程序员和业务员之间直接使用共享语言来描述新功能的需求文档对于沟通是个好办法。一个好的产品经理能在一天内学会 [Gherkin][12] 然后使用它构造出明确的英语来描述需求文档,工程师会使用 Gherkin 描述的需求文档来写功能测试,之后开发功能代码直到代码通过测试。这是一个简化的 [验收测试驱动开发][13](ATDD),这样就开始了你的 DevOps 文化和开发实践。 + +### 开始你旅程 + +不要自馁哦。希望这五个想法给你坚实的入门方法。 + + +### 关于作者 + + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/headshot_4.jpg?itok=jntfDCfX)][14] + + Magnus Hedemark - Magnus 在IT行业已有20多年,并且一直热衷于技术。他目前是 nitedHealth Group 的 DevOps 工程师。在业余时间,Magnus 喜欢摄影和划独木舟。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/5-keys-get-started-devops + +作者:[Magnus Hedemark ][a] +译者:[aiwhj](https://github.com/aiwhj) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/magnus919 +[1]:https://opensource.com/tags/devops?src=devops_resource_menu1 +[2]:https://opensource.com/resources/devops?src=devops_resource_menu2 +[3]:https://www.openshift.com/promotions/devops-with-openshift.html?intcmp=7016000000127cYAAQ&src=devops_resource_menu3 +[4]:https://enterprisersproject.com/article/2017/5/9-key-phrases-devops?intcmp=7016000000127cYAAQ&src=devops_resource_menu4 +[5]:https://www.redhat.com/en/insights/devops?intcmp=7016000000127cYAAQ&src=devops_resource_menu5 +[6]:https://opensource.com/article/17/11/5-keys-get-started-devops?rate=oEOzMXx1ghbkfl2a5ae6AnvO88iZ3wzkk53K2CzbDWI +[7]:https://opensource.com/user/25739/feed +[8]:https://ccsearch.creativecommons.org/image/detail/7qRx_yrcN5isTMS0u9iKMA== +[9]:https://creativecommons.org/licenses/by-sa/4.0/ +[10]:https://martinfowler.com/articles/continuousIntegration.html +[11]:https://martinfowler.com/bliki/ContinuousDelivery.html +[12]:https://cucumber.io/docs/reference +[13]:https://en.wikipedia.org/wiki/Acceptance_test%E2%80%93driven_development +[14]:https://opensource.com/users/magnus919 +[15]:https://opensource.com/users/magnus919 +[16]:https://opensource.com/users/magnus919 +[17]:https://opensource.com/tags/devops From 9c85d472b21dbf1d0e3218b148826bff21d867d4 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 6 Dec 2017 09:11:52 +0800 Subject: [PATCH 284/344] PRF:20171118 Language engineering for great justice.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 初步校对,@Valoniakim @yunfengHe 再帮着过一遍~ --- ... Language engineering for great justice.md | 118 +++++++++--------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/translated/tech/20171118 Language engineering for great justice.md b/translated/tech/20171118 Language engineering for great justice.md index 301337b11c..fc116e2e18 100644 --- a/translated/tech/20171118 Language engineering for great justice.md +++ b/translated/tech/20171118 Language engineering for great justice.md @@ -1,59 +1,59 @@ - -最合理的语言工程模式 - -============================================================ - - - -当你熟练掌握一体化工程技术时,你就会发现它逐渐超过了技术优化的层面。我们制作的每件手工艺品都在一个大环境背景下,在这个环境中,人类的行为逐渐突破了经济意义,社会学意义,达到了奥地利经济学家所称的“人类行为学”,这是目的明确的人类行为所能达到的最大范围。 - - - -对我来说这并不只是抽象理论。当我在开源发展项目中编写时,我的行为就十分符合人类行为学的理论,这行为不是针对任何特定的软件技术或某个客观事物,它指的是在开发科技的过程中人类行为的背景环境。从人类行为学角度对科技进行的解读不断增加,大量的这种解读可以重塑科技框架,带来人类生产力和满足感的极大幅度增长,而这并不是由于我们换了工具,而是在于我们改变了掌握它们的方式。 - - - -在这个背景下,我在第三篇额外的文章中谈到了 C 语言的衰退和正在到来的巨大改变,而我们也确实能够感受到系统编程的新时代的到来,在这个时刻,我决定把我之前有的大体的预感具象化为更加具体的,更实用的点子,它们主要是关于计算机语言设计的分析,例如为什么他们会成功,或为什么他们会失败。 - - - -在我最近的一篇文章中,我写道:所有计算机语言都是对机器资源的成本和程序员工作成本的相对权衡的结果,和对其相对价值的体现。这些都是在一个计算能力成本不断下降但程序员工作成本不减反增的背景下产生的。我还强调了转化成本在使原有交易主张适用于当下环境中的新增角色。在文中我将编程人员描述为一个寻找今后最适方案的探索者。 - - - -现在我要讲一讲最后一点。以现有水平为起点,一个语言工程师有极大可能通过多种方式推动语言设计的发展。通过什么系统呢? GC 还是人工分配?使用何种配置,命令式语言,函数程式语言或是面向对象语言?但是从人类行为学的角度来说,我认为它的形式会更简洁,也许只是选择解决长期问题还是短期问题? - - - -所谓的“远”“近”之分,是指硬件成本的逐渐降低,软件复杂程度的上升和由现有语言向其他语言转化的成本的增加,根据它们的变化曲线所做出的判断。短期问题指编程人员眼下发现的问题,长期问题指可预见的一系列情况,但它们一段时间内不会到来。针对近期问题所做出的部署需要非常及时且有效,但随着情况的变化,短期解决方案有可能很快就不适用了。而长期的解决方案可能因其过于超前而夭折,或因其代价过高无法被接受。 - - - -在计算机刚刚面世的时候, FORTRAN 是近期亟待解决的问题, LISP 是远期问题。汇编语言是短期解决方案,图解说明非通用语言的分类应用,还有关门电阻不断上涨的成本。随着计算机技术的发展,PHP 和 Javascript逐渐应用于游戏中。至于长期的解决方案? Oberon , Ocaml , ML , XML-Docbook 都可以。 他们形成的激励机制带来了大量具有突破性和原创性的想法,事态蓬勃但未形成体系,那个时候距离专业语言的面世还很远,(值得注意的是这些想法的出现都是人类行为学中的因果,并非由于某种技术)。专业语言会失败,这是显而易见的,它的转入成本高昂,让大部分人望而却步,因此不能没能达到能够让主流群体接受的水平,被孤立,被搁置。这也是 LISP 不为人知的的过去,作为前 LISP 管理层人员,出于对它深深的爱,我为你们讲述了这段历史。 - - - -如果短期解决方案出现故障,它的后果更加惨不忍睹,最好的结果是期待一个相对体面的失败,好转换到另一个设计方案。(通常在转化成本较高时)如果他们执意继续,通常造成众多方案相互之间藕断丝连,形成一个不断扩张的复合体,一直维持到不能运转下去,变成一堆摇摇欲坠的杂物。是的,我说的就是 C++ 语言,还有 Java 描述语言,(唉)还有 Perl,虽然 Larry Wall 的好品味成功地让他维持了很多年,问题一直没有爆发,但在 Perl 6 发行时,他的好品味最终引爆了整个问题。 - - - -这种思考角度激励了编程人员向着两个不同的目的重新塑造语言设计: ①以远近为轴,在自身和预计的未来之间选取一个最适点,然后 ②降低由一种或多种语言转化为自身语言的转入成本,这样你就可以吸纳他们的用户群。接下来我会讲讲 C 语言是怎样占领全世界的。 - - - -在整个计算机发展史中,没有谁能比 C 语言完美地把握最适点的选取了,我要做的只是证明这一点,作为一种实用的主流语言, C 语言有着更长的寿命,它目睹了无数个竞争者的兴衰,但它的地位仍旧不可取代。从淘汰它的第一个竞争者到现在已经过了 35 年,但看起来C语言的终结仍旧不会到来。 - - - -当然,如果你愿意的话,可以把 C 语言的持久存在归功于人类的文化惰性,但那是对“文化惰性”这个词的曲解, C 语言一直得以延续的真正原因是没有人提供足够的转化费用! - - - -相反的, C 语言低廉的内部转化费用未得到应有的重视,C 语言是如此的千变万化,从它漫长统治时期的初期开始,它就可以适用于多种语言如 FORTRAN , Pascal , 汇编语言和 LISP 的编程习惯。在二十世纪八十年代我就注意到,我可以根据编程人员的编码风格判断出他的母语是什么,这也从另一方面证明了C 语言的魅力能够吸引全世界的人使用它。 - - - -C++ 语言同样胜在它低廉的转化费用。很快,大部分新兴的语言为了降低自身转化费用,纷纷参考 C 语言语法。请注意这给未来的语言设计环境带来了什么影响:它尽可能地提高了 C-like 语言的价值,以此来降低其他语言转化为 C 语言的转化成本。 - - - -另一种降低转入成本的方法十分简单,即使没接触过编程的人都能学会,但这种方法很难完成。我认为唯一使用了这种方法的 Python就是靠这种方法进入了职业比赛。对这个方法我一带而过,是因为它并不是我希望看到的,顺利执行的系统语言战略,虽然我很希望它不是那样的。 - - - -今天我们在2017年年底聚集在这里,下一项我们应该为某些暴躁的团体发声,如 Go 团队,但事实并非如此。 Go 这个项目漏洞百出,我甚至可以想象出它失败的各种可能,Go 团队太过固执独断,即使几乎整个用户群体都认为 Go 需要做出改变了,Go 团队也无动于衷,这是个大问题。 一旦发生故障, GC 发生延迟或者用牺牲生产量来弥补延迟,但无论如何,它都会严重影响到这种语言的应用,大幅缩小这种语言的适用范围。 - - - -即便如此,在 Go 的设计中,还是有一个我颇为认同的远大战略目标,想要理解这个目标,我们需要回想一下如果想要取代 C 语言,要面临的短期问题是什么。同我之前提到的,随着项目计划的不断扩张,故障率也在持续上升,这其中内存管理方面的故障尤其多,而内存管理一直是崩溃漏洞和安全漏洞的高发领域。 - - - -我们现在已经知道了两件十分中重要的紧急任务,要想取代 C 语言,首先要先做到这两点:(1)解决内存管理问题;(2)降低由 C 语言向本语言转化时所需的转入成本。纵观编程语言的历史——从人类行为学的角度来看,作为 C 语言的准替代者,如果不能有效解决转入成本过高这个问题,那他们所做的其他部分做得再好都不算数。相反的,如果他们把转入成本过高这个问题解决地很好,即使他们其他部分做的不是最好的,人们也不会对他们吹毛求疵。 - - - -这正是 Go 的做法,但这个理论并不是完美无瑕的,它也有局限性。目前 GC 延迟限制了它的发展,但 Go 现在选择照搬 Unix 下 C 语言的传染战略,让自身语言变成易于转入,便于传播的语言,其繁殖速度甚至快于替代品。但从长远角度看,这并不是个好办法。 - - - -当然, Rust 语言的不足是个十分明显的问题,我们不应当回避它。而它,正将自己定位为适用于长远计划的选择。在之前的部分中我已经谈到了为什么我觉得它还不完美,Rust 语言在 TIBOE 和PYPL 指数上的成就也证明了我的说法,在 TIBOE 上 Rust 从来没有进过前20名,在 PYPL 指数上它的成就也比 Go 差很多。 - - - -五年后 Rust 能发展的怎样还是个问题,如果他们愿意改变,我建议他们重视转入成本问题。以我个人经历来说,由 C 语言转入 Rust 语言的能量壁垒使人望而却步。如果编码提升工具比如 Corrode 只能把 C 语言映射为不稳定的 Rust 语言,但不能解决能量壁垒的问题;或者如果有更简单的方法能够自动注释所有权或试用期,人们也不再需要它们了——这些问题编译器就能够解决。目前我不知道怎样解决这个问题,但我觉得他们最好找出解决方案。 - - - -在最后我想强调一下,虽然在 Ken Thompson 的设计经历中,他看起来很少解决短期问题,但他对未来有着极大的包容性,并且这种包容性还在不断提升。当然 Unix 也是这样的, 它让我不禁暗自揣测,让我认为 Go 语言中令人不快的地方都其实是他们未来事业的基石(例如缺乏泛型)。如果要确认这件事是真假,我需要比 Ken 还要聪明,但这并不是一件容易让人相信的事情。 - - - --------------------------------------------------------------------------------- - - - -via: http://esr.ibiblio.org/?p=7745 - - - -作者:[Eric Raymond ][a] - -译者:[Valoniakim](https://github.com/Valoniakim) - -校对:[校对者ID](https://github.com/校对者ID) - - - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - - - -[a]:http://esr.ibiblio.org/?author=2 - -[1]:http://esr.ibiblio.org/?author=2 - -[2]:http://esr.ibiblio.org/?p=7711&cpage=1#comment-1913931 - -[3]:http://esr.ibiblio.org/?p=7745 +ESR:最合理的语言工程模式 +============================================================ + +当你熟练掌握一体化工程技术时,你就会发现它逐渐超过了技术优化的层面。我们制作的每件手工艺品都在一个大环境背景下,在这个环境中,人类的行为逐渐突破了经济意义、社会学意义,达到了奥地利经济学家所称的“人类行为学praxeology”,这是目的明确的人类行为所能达到的最大范围。 + +对我来说这并不只是抽象理论。当我在开源开发项目中编写论文时,我的行为就十分符合人类行为学的理论,这行为不是针对任何特定的软件技术或某个客观事物,它指的是在开发科技的过程中人类行为的背景环境。从人类行为学角度对科技进行的解读不断增加,大量的这种解读可以重塑科技框架,带来人类生产力和满足感的极大幅度增长,而这并不是由于我们换了工具,而是在于我们改变了掌握它们的方式。 + +在这个背景下,我的计划之外的文章系列的第三篇中谈到了 C 语言的衰退和正在到来的巨大改变,而我们也确实能够感受到系统编程的新时代的到来,在这个时刻,我决定把我之前有的大体的预感具象化为更加具体的、更实用的想法,它们主要是关于计算机语言设计的分析,例如为什么它们会成功,或为什么它们会失败。 + +在我最近的一篇文章中,我写道:所有计算机语言都是对机器资源的成本和程序员工作成本的相对权衡的结果,和对其相对价值的体现。这些都是在一个计算能力成本不断下降但程序员工作成本不减反增的背景下产生的。我还强调了转化成本在使原有交易主张适用于当下环境中的新增角色。在文中我将编程人员描述为一个寻找今后最适方案的探索者。 + +现在我要讲一讲最后一点。以现有水平为起点,一个语言工程师有极大可能通过多种方式推动语言设计的发展。通过什么系统呢? GC 还是人工分配?使用何种配置,命令式语言、函数程式语言或是面向对象语言?但是从人类行为学的角度来说,我认为它的形式会更简洁,也许只是选择解决长期问题还是短期问题? + +所谓的“远”、“近”之分,是指硬件成本的逐渐降低,软件复杂程度的上升和由现有语言向其他语言转化的成本的增加,根据它们的变化曲线所做出的判断。短期问题指编程人员眼下发现的问题,长期问题指可预见的一系列情况,但它们一段时间内不会到来。针对近期问题所做出的部署需要非常及时且有效,但随着情况的变化,短期解决方案有可能很快就不适用了。而长期的解决方案可能因其过于超前而夭折,或因其代价过高无法被接受。 + +在计算机刚刚面世的时候, FORTRAN 是近期亟待解决的问题, LISP 是远期问题,汇编语言是短期解决方案。说明这种分类适用于非通用语言,还有 roff 标记语言。随着计算机技术的发展,PHP 和 Javascript 逐渐参与到这场游戏中。至于长期的解决方案? Oberon、Ocaml、ML、XML-Docbook 都可以。 它们形成的激励机制带来了大量具有突破性和原创性的想法,事态蓬勃但未形成体系,那个时候距离专业语言的面世还很远,(值得注意的是这些想法的出现都是人类行为学中的因果,并非由于某种技术)。专业语言会失败,这是显而易见的,它的转入成本高昂,让大部分人望而却步,因此不能达到能够让主流群体接受的水平,被孤立,被搁置。这也是 LISP 不为人知的的过去,作为前 LISP 管理层人员,出于对它深深的爱,我为你们讲述了这段历史。 + +如果短期解决方案出现故障,它的后果更加惨不忍睹,最好的结果是期待一个相对体面的失败,好转换到另一个设计方案。(通常在转化成本较高时)如果他们执意继续,通常造成众多方案相互之间藕断丝连,形成一个不断扩张的复合体,一直维持到不能运转下去,变成一堆摇摇欲坠的杂物。是的,我说的就是 C++ 语言,还有 Java 描述语言,(唉)还有 Perl,虽然 Larry Wall 的好品味成功地让他维持了很多年,问题一直没有爆发,但在 Perl 6 发行时,他的好品味最终引爆了整个问题。 + +这种思考角度激励了编程人员向着两个不同的目的重新塑造语言设计: (1)以远近为轴,在自身和预计的未来之间选取一个最适点,然后(2)降低由一种或多种语言转化为自身语言的转入成本,这样你就可以吸纳他们的用户群。接下来我会讲讲 C 语言是怎样占领全世界的。 + +在整个计算机发展史中,没有谁能比 C 语言完美地把握最适点的选取了,我要做的只是证明这一点,作为一种实用的主流语言, C 语言有着更长的寿命,它目睹了无数个竞争者的兴衰,但它的地位仍旧不可取代。从淘汰它的第一个竞争者到现在已经过了 35 年,但看起来C语言的终结仍旧不会到来。 + +当然,如果你愿意的话,可以把 C 语言的持久存在归功于人类的文化惰性,但那是对“文化惰性”这个词的曲解, C 语言一直得以延续的真正原因是没有人提供足够的转化费用! + +相反的, C 语言低廉的内部转化成本未得到应有的重视,C 语言是如此的千变万化,从它漫长统治时期的初期开始,它就可以适用于多种语言如 FORTRAN、Pascal 、汇编语言和 LISP 的编程习惯。在二十世纪八十年代我就注意到,我可以根据编程人员的编码风格判断出他的母语是什么,这也从另一方面证明了C 语言的魅力能够吸引全世界的人使用它。 + +C++ 语言同样胜在它低廉的转化成本。很快,大部分新兴的语言为了降低自身转化成本,纷纷参考 C 语言语法。请注意这给未来的语言设计环境带来了什么影响:它尽可能地提高了类 C 语言的价值,以此来降低其他语言转化为 C 语言的转化成本。 + +另一种降低转入成本的方法十分简单,即使没接触过编程的人都能学会,但这种方法很难完成。我认为唯一使用了这种方法的 Python 就是靠这种方法进入了职业比赛。对这个方法我一带而过,是因为它并不是我希望看到的,顺利执行的系统语言战略,虽然我很希望它不是那样的。 + +今天我们在 2017 年底聚集在这里,下一项我们应该为某些暴躁的团体发声,如 Go 团队,但事实并非如此。 Go 这个项目漏洞百出,我甚至可以想象出它失败的各种可能,Go 团队太过固执独断,即使几乎整个用户群体都认为 Go 需要做出改变了,Go 团队也无动于衷,这是个大问题。 一旦发生故障, GC 发生延迟或者用牺牲生产量来弥补延迟,但无论如何,它都会严重影响到这种语言的应用,大幅缩小这种语言的适用范围。 + +即便如此,在 Go 的设计中,还是有一个我颇为认同的远大战略目标,想要理解这个目标,我们需要回想一下如果想要取代 C 语言,要面临的短期问题是什么。同我之前提到的,随着项目计划的不断扩张,故障率也在持续上升,这其中内存管理方面的故障尤其多,而内存管理一直是崩溃漏洞和安全漏洞的高发领域。 + +我们现在已经知道了两件十分重要的紧急任务,要想取代 C 语言,首先要先做到这两点:(1)解决内存管理问题;(2)降低由 C 语言向本语言转化时所需的转入成本。纵观编程语言的历史——从人类行为学的角度来看,作为 C 语言的准替代者,如果不能有效解决转入成本过高这个问题,那他们所做的其他部分做得再好都不算数。相反的,如果他们把转入成本过高这个问题解决地很好,即使他们其他部分做的不是最好的,人们也不会对他们吹毛求疵。 + +这正是 Go 的做法,但这个理论并不是完美无瑕的,它也有局限性。目前 GC 延迟限制了它的发展,但 Go 现在选择照搬 Unix 下 C 语言的传染战略,让自身语言变成易于转入,便于传播的语言,其繁殖速度甚至快于替代品。但从长远角度看,这并不是个好办法。 + +当然, Rust 语言的不足是个十分明显的问题,我们不应当回避它。而它,正将自己定位为适用于长远计划的选择。在之前的部分中我已经谈到了为什么我觉得它还不完美,Rust 语言在 TIBOE 和PYPL 指数上的成就也证明了我的说法,在 TIBOE 上 Rust 从来没有进过前 20 名,在 PYPL 指数上它的成就也比 Go 差很多。 + +五年后 Rust 能发展的怎样还是个问题,如果他们愿意改变,我建议他们重视转入成本问题。以我个人经历来说,由 C 语言转入 Rust 语言的能量壁垒使人望而却步。如果编码提升工具比如 Corrode 只能把 C 语言映射为不稳定的 Rust 语言,但不能解决能量壁垒的问题;或者如果有更简单的方法能够自动注释所有权或试用期,人们也不再需要它们了——这些问题编译器就能够解决。目前我不知道怎样解决这个问题,但我觉得他们最好找出解决方案。 + +在最后我想强调一下,虽然在 Ken Thompson 的设计经历中,他看起来很少解决短期问题,但他对未来有着极大的包容性,并且这种包容性还在不断提升。当然 Unix 也是这样的, 它让我不禁暗自揣测,让我认为 Go 语言中令人不快的地方都其实是他们未来事业的基石(例如缺乏泛型)。如果要确认这件事是真假,我需要比 Ken 还要聪明,但这并不是一件容易让人相信的事情。 + +-------------------------------------------------------------------------------- + +via: http://esr.ibiblio.org/?p=7745 + +作者:[Eric Raymond][a] +译者:[Valoniakim](https://github.com/Valoniakim) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://esr.ibiblio.org/?author=2 +[1]:http://esr.ibiblio.org/?author=2 +[2]:http://esr.ibiblio.org/?p=7711&cpage=1#comment-1913931 +[3]:http://esr.ibiblio.org/?p=7745 From 01dcb3137581c8f23b9f6377e584d5180958775f Mon Sep 17 00:00:00 2001 From: Sihua Zheng Date: Wed, 6 Dec 2017 09:20:11 +0800 Subject: [PATCH 285/344] translated --- ... write fun small web projects instantly.md | 76 ------------------- ... write fun small web projects instantly.md | 73 ++++++++++++++++++ 2 files changed, 73 insertions(+), 76 deletions(-) delete mode 100644 sources/tech/20171113 Glitch write fun small web projects instantly.md create mode 100644 translated/tech/20171113 Glitch write fun small web projects instantly.md diff --git a/sources/tech/20171113 Glitch write fun small web projects instantly.md b/sources/tech/20171113 Glitch write fun small web projects instantly.md deleted file mode 100644 index 734853ce51..0000000000 --- a/sources/tech/20171113 Glitch write fun small web projects instantly.md +++ /dev/null @@ -1,76 +0,0 @@ -translating---geekpi - -Glitch: write fun small web projects instantly -============================================================ - -I just wrote about Jupyter Notebooks which are a fun interactive way to write Python code. That reminded me I learned about Glitch recently, which I also love!! I built a small app to [turn of twitter retweets][2] with it. So! - -[Glitch][3] is an easy way to make Javascript webapps. (javascript backend, javascript frontend) - -The fun thing about glitch is: - -1. you start typing Javascript code into their web interface - -2. as soon as you type something, it automagically reloads the backend of your website with the new code. You don’t even have to save!! It autosaves. - -So it’s like Heroku, but even more magical!! Coding like this (you type, and the code runs on the public internet immediately) just feels really **fun** to me. - -It’s kind of like sshing into a server and editing PHP/HTML code on your server and having it instantly available, which I kind of also loved. Now we have “better deployment practices” than “just edit the code and it is instantly on the internet” but we are not talking about Serious Development Practices, we are talking about writing tiny programs for fun. - -### glitch has awesome example apps - -Glitch seems like fun nice way to learn programming! - -For example, there’s a space invaders game (code by [Mary Rose Cook][4]) at [https://space-invaders.glitch.me/][5]. The thing I love about this is that in just a few clicks I can - -1. click “remix this” - -2. start editing the code to make the boxes orange instead of black - -3. have my own space invaders game!! Mine is at [http://julias-space-invaders.glitch.me/][1]. (i just made very tiny edits to make it orange, nothing fancy) - -They have tons of example apps that you can start from – for instance [bots][6], [games][7], and more. - -### awesome actually useful app: tweetstorms - -The way I learned about Glitch was from this app which shows you tweetstorms from a given user: [https://tweetstorms.glitch.me/][8]. - -For example, you can see [@sarahmei][9]’s tweetstorms at [https://tweetstorms.glitch.me/sarahmei][10] (she tweets a lot of good tweetstorms!). - -### my glitch app: turn off retweets - -When I learned about Glitch I wanted to turn off retweets for everyone I follow on Twitter (I know you can do it in Tweetdeck!) and doing it manually was a pain – I had to do it one person at a time. So I wrote a tiny Glitch app to do it for me! - -I liked that I didn’t have to set up a local development environment, I could just start typing and go! - -Glitch only supports Javascript and I don’t really know Javascript that well (I think I’ve never written a Node program before), so the code isn’t awesome. But I had a really good time writing it – being able to type and just see my code running instantly was delightful. Here it is: [https://turn-off-retweets.glitch.me/][11]. - -### that’s all! - -Using Glitch feels really fun and democratic. Usually if I want to fork someone’s web project and make changes I wouldn’t do it – I’d have to fork it, figure out hosting, set up a local dev environment or Heroku or whatever, install the dependencies, etc. I think tasks like installing node.js dependencies used to be interesting, like “cool i am learning something new” and now I just find them tedious. - -So I love being able to just click “remix this!” and have my version on the internet instantly. - - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/2017/11/13/glitch--write-small-web-projects-easily/ - -作者:[Julia Evans ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://jvns.ca/ -[1]:http://julias-space-invaders.glitch.me/ -[2]:https://turn-off-retweets.glitch.me/ -[3]:https://glitch.com/ -[4]:https://maryrosecook.com/ -[5]:https://space-invaders.glitch.me/ -[6]:https://glitch.com/handy-bots -[7]:https://glitch.com/games -[8]:https://tweetstorms.glitch.me/ -[9]:https://twitter.com/sarahmei -[10]:https://tweetstorms.glitch.me/sarahmei -[11]:https://turn-off-retweets.glitch.me/ diff --git a/translated/tech/20171113 Glitch write fun small web projects instantly.md b/translated/tech/20171113 Glitch write fun small web projects instantly.md new file mode 100644 index 0000000000..fde7d7f880 --- /dev/null +++ b/translated/tech/20171113 Glitch write fun small web projects instantly.md @@ -0,0 +1,73 @@ +Glitch:立即写出有趣的小型网站项目 +============================================================ + +我刚写了一篇关于 Jupyter Notebooks 是一个有趣的交互式写 Python 代码的方式。这让我想起我最近学习了 Glitch,这个我同样喜爱!我构建了一个小的程序来用于[关闭转发 twitter][2]。因此有了这篇文章! + +[Glitch][3] 是一个简单的构建 Javascript web 程序的方式(javascript 后端、javascript 前端) + +关于 glitch 有趣的事有: + +1. 你在他们的网站输入 Javascript 代码 + +2. 只要输入了任何代码,它会自动用你的新代码重载你的网站。你甚至不必保存!它会自动保存。 + +所以这就像 Heroku,但更神奇!像这样的编码(你输入代码,代码立即在公共网络上运行)对我而言感觉很**有趣**。 + +这有点像 ssh 登录服务器,编辑服务器上的 PHP/HTML 代码,并让它立即可用,这也是我所喜爱的。现在我们有了“更好的部署实践”,而不是“编辑代码,它立即出现在互联网上”,但我们并不是在谈论严肃的开发实践,而是在讨论编写微型程序的乐趣。 + +### Glitch 有很棒的示例应用程序 + +Glitch 似乎是学习编程的好方式! + +比如,这有一个太空侵略者游戏(由 [Mary Rose Cook][4] 编写):[https://space-invaders.glitch.me/][5]。我喜欢的是我只需要点击几下。 + +1. 点击 “remix this” + +2. 开始编辑代码使箱子变成橘色而不是黑色 + +3. 制作我自己太空侵略者游戏!我的在这:[http://julias-space-invaders.glitch.me/][1]。(我只做了很小的更改使其变成橘色,没什么神奇的) + +他们有大量的示例程序,你可以从中启动 - 例如[机器人][6]、[游戏][7]等等。 + +### 实际有用的非常好的程序:tweetstorms + +我学习 Glitch 的方式是从这个程序:[https://tweetstorms.glitch.me/][8],它会向你展示给定用户的 tweetstorm。 + +比如,你可以在 [https://tweetstorms.glitch.me/sarahmei][10] 看到 [@sarahmei][9] 的 tweetstorm(她发布了很多好的 tweetstorm!)。 + +### 我的 Glitch 程序: 关闭转推 + +当我了解到 Glitch 的时候,我想关闭在 Twitter 上关注的所有人的转推(我知道可以在 Tweetdeck 中做这件事),而且手动做这件事是一件很痛苦的事 - 我一次只能设置一个人。所以我写了一个 Glitch 程序来为我做! + +我喜欢我不必设置一个本地开发环境,我可以直接开始输入然后开始! + +Glitch 只支持 Javascript,我不非常了解 Javascript(我之前从没写过一个 Node 程序),所以代码不是很好。但是编写它很愉快 - 能够输入并立即看到我的代码运行是令人愉快的。这是我的项目:[https://turn-off-retweets.glitch.me/][11]。 + +### 就是这些! + +使用 Glitch 感觉真的很有趣和民主。通常情况下,如果我想 fork 某人的 Web 项目,并做出更改,我不会这样做 - 我必须 fork,找一个托管,设置本地开发环境或者 Heroku 或其他,安装依赖项等。我认为像安装 node.js 依赖关系这样的任务过去很有趣,就像“我正在学习新东西很酷”,现在我觉得它们很乏味。 + +所以我喜欢只需点击 “remix this!” 并立即在互联网上能有我的版本。 + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/11/13/glitch--write-small-web-projects-easily/ + +作者:[Julia Evans ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/ +[1]:http://julias-space-invaders.glitch.me/ +[2]:https://turn-off-retweets.glitch.me/ +[3]:https://glitch.com/ +[4]:https://maryrosecook.com/ +[5]:https://space-invaders.glitch.me/ +[6]:https://glitch.com/handy-bots +[7]:https://glitch.com/games +[8]:https://tweetstorms.glitch.me/ +[9]:https://twitter.com/sarahmei +[10]:https://tweetstorms.glitch.me/sarahmei +[11]:https://turn-off-retweets.glitch.me/ From 042a92d63f97636d7e760bbdc464a6d7d8053167 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 6 Dec 2017 09:45:43 +0800 Subject: [PATCH 286/344] rename --- ...Long Running Terminal Commands Complete.md | 156 ------------------ 1 file changed, 156 deletions(-) delete mode 100644 sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md diff --git a/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md b/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md deleted file mode 100644 index 46afe9b893..0000000000 --- a/sources/tech/20171130 Undistract-me : Get Notification When Long Running Terminal Commands Complete.md +++ /dev/null @@ -1,156 +0,0 @@ -translating---geekpi - -Undistract-me : Get Notification When Long Running Terminal Commands Complete -============================================================ - -by [sk][2] · November 30, 2017 - -![Undistract-me](https://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2-720x340.png) - -A while ago, we published how to [get notification when a Terminal activity is done][3]. Today, I found out a similar utility called “undistract-me” that notifies you when long running terminal commands complete. Picture this scenario. You run a command that takes a while to finish. In the mean time, you check your facebook and get so involved in it. After a while, you remembered that you ran a command few minutes ago. You go back to the Terminal and notice that the command has already finished. But you have no idea when the command is completed. Have you ever been in this situation? I bet most of you were in this situation many times. This is where “undistract-me” comes in help. You don’t need to constantly check the terminal to see if a command is completed or not. Undistract-me utility will notify you when a long running command is completed. It will work on Arch Linux, Debian, Ubuntu and other Ubuntu-derivatives. - -#### Installing Undistract-me - -Undistract-me is available in the default repositories of Debian and its variants such as Ubuntu. All you have to do is to run the following command to install it. - -``` -sudo apt-get install undistract-me -``` - -The Arch Linux users can install it from AUR using any helper programs. - -Using [Pacaur][4]: - -``` -pacaur -S undistract-me-git -``` - -Using [Packer][5]: - -``` -packer -S undistract-me-git -``` - -Using [Yaourt][6]: - -``` -yaourt -S undistract-me-git -``` - -Then, run the following command to add “undistract-me” to your Bash. - -``` -echo 'source /etc/profile.d/undistract-me.sh' >> ~/.bashrc -``` - -Alternatively you can run this command to add it to your Bash: - -``` -echo "source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install" >> .bashrc -``` - -If you are in Zsh shell, run this command: - -``` -echo "source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install" >> .zshrc -``` - -Finally update the changes: - -For Bash: - -``` -source ~/.bashrc -``` - -For Zsh: - -``` -source ~/.zshrc -``` - -#### Configure Undistract-me - -By default, Undistract-me will consider any command that takes more than 10 seconds to complete as a long-running command. You can change this time interval by editing /usr/share/undistract-me/long-running.bash file. - -``` -sudo nano /usr/share/undistract-me/long-running.bash -``` - -Find “LONG_RUNNING_COMMAND_TIMEOUT” variable and change the default value (10 seconds) to something else of your choice. - - [![](http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-1.png)][7] - -Save and close the file. Do not forget to update the changes: - -``` -source ~/.bashrc -``` - -Also, you can disable notifications for particular commands. To do so, find the “LONG_RUNNING_IGNORE_LIST” variable and add the commands space-separated like below. - -By default, the notification will only show if the active window is not the window the command is running in. That means, it will notify you only if the command is running in the background Terminal window. If the command is running in active window Terminal, you will not be notified. If you want undistract-me to send notifications either the Terminal window is visible or in the background, you can set IGNORE_WINDOW_CHECK to 1 to skip the window check. - -The other cool feature of Undistract-me is you can set audio notification along with visual notification when a command is done. By default, it will only send a visual notification. You can change this behavior by setting the variable UDM_PLAY_SOUND to a non-zero integer on the command line. However, your Ubuntu system should have pulseaudio-utils and sound-theme-freedesktop utilities installed to enable this functionality. - -Please remember that you need to run the following command to update the changes made. - -For Bash: - -``` -source ~/.bashrc -``` - -For Zsh: - -``` -source ~/.zshrc -``` - -It is time to verify if this really works. - -#### Get Notification When Long Running Terminal Commands Complete - -Now, run any command that takes longer than 10 seconds or the time duration you defined in Undistract-me script. - -I ran the following command on my Arch Linux desktop. - -``` -sudo pacman -Sy -``` - -This command took 32 seconds to complete. After the completion of the above command, I got the following notification. - - [![](http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2.png)][8] - -Please remember Undistract-me script notifies you only if the given command took more than 10 seconds to complete. If the command is completed in less than 10 seconds, you will not be notified. Of course, you can change this time interval settings as I described in the Configuration section above. - -I find this tool very useful. It helped me to get back to the business after I completely lost in some other tasks. I hope this tool will be helpful to you too. - -More good stuffs to come. Stay tuned! - -Cheers! - -Resource: - -* [Undistract-me GitHub Repository][1] - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/undistract-get-notification-long-running-terminal-commands-complete/ - -作者:[sk][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.ostechnix.com/author/sk/ -[1]:https://github.com/jml/undistract-me -[2]:https://www.ostechnix.com/author/sk/ -[3]:https://www.ostechnix.com/get-notification-terminal-task-done/ -[4]:https://www.ostechnix.com/install-pacaur-arch-linux/ -[5]:https://www.ostechnix.com/install-packer-arch-linux-2/ -[6]:https://www.ostechnix.com/install-yaourt-arch-linux/ -[7]:http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-1.png -[8]:http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2.png From 675e5cf6af6f303e757912ac0751b7d09684d4bf Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 6 Dec 2017 09:55:46 +0800 Subject: [PATCH 287/344] Revert "merge" --- ... write fun small web projects instantly.md | 76 ++++++++ ...actices for getting started with DevOps.md | 95 --------- ...g Hardware for Beginners Think Software.md | 89 --------- ... write fun small web projects instantly.md | 73 ------- ...ow to Manage Users with Groups in Linux.md | 183 ------------------ 5 files changed, 76 insertions(+), 440 deletions(-) create mode 100644 sources/tech/20171113 Glitch write fun small web projects instantly.md delete mode 100644 sources/tech/20171129 5 best practices for getting started with DevOps.md delete mode 100644 translated/tech/20171012 Linux Networking Hardware for Beginners Think Software.md delete mode 100644 translated/tech/20171113 Glitch write fun small web projects instantly.md delete mode 100644 translated/tech/20171201 How to Manage Users with Groups in Linux.md diff --git a/sources/tech/20171113 Glitch write fun small web projects instantly.md b/sources/tech/20171113 Glitch write fun small web projects instantly.md new file mode 100644 index 0000000000..734853ce51 --- /dev/null +++ b/sources/tech/20171113 Glitch write fun small web projects instantly.md @@ -0,0 +1,76 @@ +translating---geekpi + +Glitch: write fun small web projects instantly +============================================================ + +I just wrote about Jupyter Notebooks which are a fun interactive way to write Python code. That reminded me I learned about Glitch recently, which I also love!! I built a small app to [turn of twitter retweets][2] with it. So! + +[Glitch][3] is an easy way to make Javascript webapps. (javascript backend, javascript frontend) + +The fun thing about glitch is: + +1. you start typing Javascript code into their web interface + +2. as soon as you type something, it automagically reloads the backend of your website with the new code. You don’t even have to save!! It autosaves. + +So it’s like Heroku, but even more magical!! Coding like this (you type, and the code runs on the public internet immediately) just feels really **fun** to me. + +It’s kind of like sshing into a server and editing PHP/HTML code on your server and having it instantly available, which I kind of also loved. Now we have “better deployment practices” than “just edit the code and it is instantly on the internet” but we are not talking about Serious Development Practices, we are talking about writing tiny programs for fun. + +### glitch has awesome example apps + +Glitch seems like fun nice way to learn programming! + +For example, there’s a space invaders game (code by [Mary Rose Cook][4]) at [https://space-invaders.glitch.me/][5]. The thing I love about this is that in just a few clicks I can + +1. click “remix this” + +2. start editing the code to make the boxes orange instead of black + +3. have my own space invaders game!! Mine is at [http://julias-space-invaders.glitch.me/][1]. (i just made very tiny edits to make it orange, nothing fancy) + +They have tons of example apps that you can start from – for instance [bots][6], [games][7], and more. + +### awesome actually useful app: tweetstorms + +The way I learned about Glitch was from this app which shows you tweetstorms from a given user: [https://tweetstorms.glitch.me/][8]. + +For example, you can see [@sarahmei][9]’s tweetstorms at [https://tweetstorms.glitch.me/sarahmei][10] (she tweets a lot of good tweetstorms!). + +### my glitch app: turn off retweets + +When I learned about Glitch I wanted to turn off retweets for everyone I follow on Twitter (I know you can do it in Tweetdeck!) and doing it manually was a pain – I had to do it one person at a time. So I wrote a tiny Glitch app to do it for me! + +I liked that I didn’t have to set up a local development environment, I could just start typing and go! + +Glitch only supports Javascript and I don’t really know Javascript that well (I think I’ve never written a Node program before), so the code isn’t awesome. But I had a really good time writing it – being able to type and just see my code running instantly was delightful. Here it is: [https://turn-off-retweets.glitch.me/][11]. + +### that’s all! + +Using Glitch feels really fun and democratic. Usually if I want to fork someone’s web project and make changes I wouldn’t do it – I’d have to fork it, figure out hosting, set up a local dev environment or Heroku or whatever, install the dependencies, etc. I think tasks like installing node.js dependencies used to be interesting, like “cool i am learning something new” and now I just find them tedious. + +So I love being able to just click “remix this!” and have my version on the internet instantly. + + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/11/13/glitch--write-small-web-projects-easily/ + +作者:[Julia Evans ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/ +[1]:http://julias-space-invaders.glitch.me/ +[2]:https://turn-off-retweets.glitch.me/ +[3]:https://glitch.com/ +[4]:https://maryrosecook.com/ +[5]:https://space-invaders.glitch.me/ +[6]:https://glitch.com/handy-bots +[7]:https://glitch.com/games +[8]:https://tweetstorms.glitch.me/ +[9]:https://twitter.com/sarahmei +[10]:https://tweetstorms.glitch.me/sarahmei +[11]:https://turn-off-retweets.glitch.me/ diff --git a/sources/tech/20171129 5 best practices for getting started with DevOps.md b/sources/tech/20171129 5 best practices for getting started with DevOps.md deleted file mode 100644 index 7694180c14..0000000000 --- a/sources/tech/20171129 5 best practices for getting started with DevOps.md +++ /dev/null @@ -1,95 +0,0 @@ -translating---aiwhj -5 best practices for getting started with DevOps -============================================================ - -### Are you ready to implement DevOps, but don't know where to begin? Try these five best practices. - - -![5 best practices for getting started with DevOps](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/devops-gears.png?itok=rUejbLQX "5 best practices for getting started with DevOps") -Image by :  - -[Andrew Magill][8]. Modified by Opensource.com. [CC BY 4.0][9] - -DevOps often stymies early adopters with its ambiguity, not to mention its depth and breadth. By the time someone buys into the idea of DevOps, their first questions usually are: "How do I get started?" and "How do I measure success?" These five best practices are a great road map to starting your DevOps journey. - -### 1\. Measure all the things - -You don't know for sure that your efforts are even making things better unless you can quantify the outcomes. Are my features getting out to customers more rapidly? Are fewer defects escaping to them? Are we responding to and recovering more quickly from failure? - -Before you change anything, think about what kinds of outcomes you expect from your DevOps transformation. When you're further into your DevOps journey, you'll enjoy a rich array of near-real-time reports on everything about your service. But consider starting with these two metrics: - -* **Time to market** measures the end-to-end, often customer-facing, business experience. It usually begins when a feature is formally conceived and ends when the customer can consume the feature in production. Time to market is not mainly an engineering team metric; more importantly it shows your business' complete end-to-end efficiency in bringing valuable new features to market and isolates opportunities for system-wide improvement. - -* **Cycle time** measures the engineering team process. Once work on a new feature starts, when does it become available in production? This metric is very useful for understanding the efficiency of the engineering team and isolating opportunities for team-level improvement. - -### 2\. Get your process off the ground - -DevOps success requires an organization to put a regular (and hopefully effective) process in place and relentlessly improve upon it. It doesn't have to start out being effective, but it must be a regular process. Usually that it's some flavor of agile methodology like Scrum or Scrumban; sometimes it's a Lean derivative. Whichever way you go, pick a formal process, start using it, and get the basics right. - -Regular inspect-and-adapt behaviors are key to your DevOps success. Make good use of opportunities like the stakeholder demo, team retrospectives, and daily standups to find opportunities to improve your process. - -A lot of your DevOps success hinges on people working effectively together. People on a team need to work from a common process that they are empowered to improve upon. They also need regular opportunities to share what they are learning with other stakeholders, both upstream and downstream, in the process. - -Good process discipline will help your organization consume the other benefits of DevOps at the great speed that comes as your success builds. - -Although it's common for more development-oriented teams to successfully adopt processes like Scrum, operations-focused teams (or others that are more interrupt-driven) may opt for a process with a more near-term commitment horizon, such as Kanban. - -### 3\. Visualize your end-to-end workflow - -There is tremendous power in being able to see who's working on what part of your service at any given time. Visualizing your workflow will help people know what they need to work on next, how much work is in progress, and where the bottlenecks are in the process. - -You can't effectively limit work in process until you can see it and quantify it. Likewise, you can't effectively eliminate bottlenecks until you can clearly see them. - -Visualizing the entire workflow will help people in all parts of the organization understand how their work contributes to the success of the whole. It can catalyze relationship-building across organizational boundaries to help your teams collaborate more effectively towards a shared sense of success. - -### 4\. Continuous all the things - -DevOps promises a dizzying array of compelling automation. But Rome wasn't built in a day. One of the first areas you can focus your efforts on is [continuous integration][10] (CI). But don't stop there; you'll want to follow quickly with [continuous delivery][11] (CD) and eventually continuous deployment. - -Your CD pipeline is your opportunity to inject all manner of automated quality testing into your process. The moment new code is committed, your CD pipeline should run a battery of tests against the code and the successfully built artifact. The artifact that comes out at the end of this gauntlet is what progresses along your process until eventually it's seen by customers in production. - -Another "continuous" that doesn't get enough attention is continuous improvement. That's as simple as setting some time aside each day to ask your colleagues: "What small thing can we do today to get better at how we do our work?" These small, daily changes compound over time into more profound results. You'll be pleasantly surprised! But it also gets people thinking all the time about how to improve things. - -### 5\. Gherkinize - -Fostering more effective communication across your organization is crucial to fostering the sort of systems thinking prevalent in successful DevOps journeys. One way to help that along is to use a shared language between the business and the engineers to express the desired acceptance criteria for new features. A good product manager can learn [Gherkin][12] in a day and begin using it to express acceptance criteria in an unambiguous, structured form of plain English. Engineers can use this Gherkinized acceptance criteria to write acceptance tests against the criteria, and then develop their feature code until the tests pass. This is a simplification of [acceptance test-driven development][13](ATDD) that can also help kick start your DevOps culture and engineering practice. - -### Start on your journey - -Don't be discouraged by getting started with your DevOps practice. It's a journey. And hopefully these five ideas give you solid ways to get started. - - -### About the author - - [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/headshot_4.jpg?itok=jntfDCfX)][14] - - Magnus Hedemark - Magnus has been in the IT industry for over 20 years, and a technology enthusiast for most of his life. He's presently Manager of DevOps Engineering at UnitedHealth Group. In his spare time, Magnus enjoys photography and paddling canoes. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/11/5-keys-get-started-devops - -作者:[Magnus Hedemark ][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/magnus919 -[1]:https://opensource.com/tags/devops?src=devops_resource_menu1 -[2]:https://opensource.com/resources/devops?src=devops_resource_menu2 -[3]:https://www.openshift.com/promotions/devops-with-openshift.html?intcmp=7016000000127cYAAQ&src=devops_resource_menu3 -[4]:https://enterprisersproject.com/article/2017/5/9-key-phrases-devops?intcmp=7016000000127cYAAQ&src=devops_resource_menu4 -[5]:https://www.redhat.com/en/insights/devops?intcmp=7016000000127cYAAQ&src=devops_resource_menu5 -[6]:https://opensource.com/article/17/11/5-keys-get-started-devops?rate=oEOzMXx1ghbkfl2a5ae6AnvO88iZ3wzkk53K2CzbDWI -[7]:https://opensource.com/user/25739/feed -[8]:https://ccsearch.creativecommons.org/image/detail/7qRx_yrcN5isTMS0u9iKMA== -[9]:https://creativecommons.org/licenses/by-sa/4.0/ -[10]:https://martinfowler.com/articles/continuousIntegration.html -[11]:https://martinfowler.com/bliki/ContinuousDelivery.html -[12]:https://cucumber.io/docs/reference -[13]:https://en.wikipedia.org/wiki/Acceptance_test%E2%80%93driven_development -[14]:https://opensource.com/users/magnus919 -[15]:https://opensource.com/users/magnus919 -[16]:https://opensource.com/users/magnus919 -[17]:https://opensource.com/tags/devops diff --git a/translated/tech/20171012 Linux Networking Hardware for Beginners Think Software.md b/translated/tech/20171012 Linux Networking Hardware for Beginners Think Software.md deleted file mode 100644 index a236a80e97..0000000000 --- a/translated/tech/20171012 Linux Networking Hardware for Beginners Think Software.md +++ /dev/null @@ -1,89 +0,0 @@ -Translating by FelixYFZ - -面向初学者的Linux网络硬件: 软件工程思想 -============================================================ - -![island network](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/soderskar-island.jpg?itok=wiMaF66b "island network") - 没有路由和桥接,我们将会成为孤独的小岛,你将会在这个网络教程中学到更多知识。 -Commons Zero][3]Pixabay - - 上周,我们学习了本地网络硬件知识,本周,我们将学习网络互联技术和在移动网络中的一些很酷的黑客技术。 -### Routers:路由器 - - -网络路由器就是计算机网络中的一切,因为路由器连接着网络,没有路由器,我们就会成为孤岛, - -图一展示了一个简单的有线本地网络和一个无线接入点,所有设备都接入到Internet上,本地局域网的计算机连接到一个连接着防火墙或者路由器的以太网交换机上,防火墙或者路由器连接到网络服务供应商提供的电缆箱,调制调节器,卫星上行系统...好像一切都在计算中,就像是一个带着不停闪烁的的小灯的盒子,当你的网络数据包离开你的局域网,进入广阔的互联网,它们穿过一个又一个路由器直到到达自己的目的地。 - - -### [fig-1.png][4] - -![simple LAN](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_7.png?itok=lsazmf3- "simple LAN") - -图一:一个简单的有线局域网和一个无线接入点。 - -一台路由器能连接一切,一个小巧特殊的小盒子只专注于路由,一个大点的盒子将会提供路由,防火墙,域名服务,以及VPN网关功能,一台重新设计的台式电脑或者笔记本,一个树莓派计算机或者一个小模块,体积臃肿矮小的像PC这样的单板计算机,除了苛刻的用途以外,普通的商品硬件都能良好的工作运行。高端的路由器使用特殊设计的硬件每秒能够传输最大量的数据包。 它们有多路数据总线,多个中央处理器和极快的存储。 -可以通过查阅Juniper和思科的路由器来感受一下高端路由器书什么样子的,而且能看看里面是什么样的构造。 -一个接入你的局域网的无线接入点要么作为一个以太网网桥要么作为一个路由器。一个桥接器扩展了这个网络,所以在这个桥接器上的任意一端口上的主机都连接在同一个网络中。 -一台路由器连接的是两个不同的网络。 -### Network Topology:网络拓扑 - - -有多种设置你的局域网的方式,你可以把所有主机接入到一个单独的平面网络,如果你的交换机支持的话,你也可以把它们分配到不同的子网中。 -平面网络是最简单的网络,只需把每一台设备接入到同一个交换机上即可,如果一台交换上的端口不够使用,你可以将更多的交换机连接在一起。 -有些交换机有特殊的上行端口,有些是没有这种特殊限制的上行端口,你可以连接其中的任意端口,你可能需要使用交叉类型的以太网线,所以你要查阅你的交换机的说明文档来设置。平面网络是最容易管理的,你不需要路由器也不需要计算子网,但它也有一些缺点。他们的伸缩性不好,所以当网络规模变得越来越大的时候就会被广播网络所阻塞。 -将你的局域网进行分段将会提升安全保障, 把局域网分成可管理的不同网段将有助于管理更大的网络。 - 图2展示了一个分成两个子网的局域网络:内部的有线和无线主机,和非军事区域(从来不知道所所有的工作上的男性术语都是在计算机上键入的?)因为他被阻挡了所有的内部网络的访问。 - - -### [fig-2.png][5] - -![LAN](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-2_4.png?itok=LpXq7bLf "LAN") - -图2:一个分成两个子网的简单局域网。 -即使像图2那样的小型网络也可以有不同的配置方法。你可以将防火墙和路由器放置在一台单独的设备上。 -你可以为你的非军事区域设置一个专用的网络连接,把它完全从你的内部网络隔离,这将引导我们进入下一个主题:一切基于软件。 - - -### Think Software软件思维 - - -你可能已经注意到在这个简短的系列中我们所讨论的硬件,只有网络接口,交换机,和线缆是特殊用途的硬件。 -其它的都是通用的商用硬件,而且都是软件来定义它的用途。 -网关,虚拟专用网关,以太网桥,网页,邮箱以及文件等等。 -服务器,负载均衡,代理,大量的服务,各种各样的认证,中继,故障转移...你可以在运行着Linux系统的标准硬件上运行你的整个网络。 -你甚至可以使用Linux交换应用和VDE2协议来模拟以太网交换机,像DD-WRT,openWRT 和Rashpberry Pi distros,这些小型的硬件都是有专业的分类的,要记住BSDS和它们的特殊衍生用途如防火墙,路由器,和网络附件存储。 -你知道有些人坚持认为硬件防火墙和软件防火墙有区别?其实是没有区别的,就像说有一台硬件计算机和一台软件计算机。 -### Port Trunking and Ethernet Bonding -端口聚合和以太网绑定 -聚合和绑定,也称链路聚合,是把两条以太网通道绑定在一起成为一条通道。一些交换机支持端口聚合,就是把两个交换机端口绑定在一起成为一个是他们原来带宽之和的一条新的连接。对于一台承载很多业务的服务器来说这是一个增加通道带宽的有效的方式。 -你也可以在以太网口进行同样的配置,而且绑定汇聚的驱动是内置在Linux内核中的,所以不需要任何其他的专门的硬件。 - - -### Bending Mobile Broadband to your Will随心所欲选择你的移动带宽 - -我期望移动带宽能够迅速增长来替代DSL和有线网络。我居住在一个有250,000人口的靠近一个城市的地方,但是在城市以外,要想接入互联网就要靠运气了,即使那里有很大的用户上网需求。我居住的小角落离城镇有20分钟的距离,但对于网络服务供应商来说他们几乎不会考虑到为这个地方提供网络。 我唯一的选择就是移动带宽; 这里没有拨号网络,卫星网络(即使它很糟糕)或者是DSL,电缆,光纤,但却没有阻止网络供应商把那些在我这个区域从没看到过的无限制通信个其他高速网络服务的传单塞进我的邮箱。 -我试用了AT&T,Version,和T-Mobile。Version的信号覆盖范围最广,但是Version和AT&T是最昂贵的。 -我居住的地方在T-Mobile信号覆盖的边缘,但迄今为止他们给了最大的优惠,为了能够能够有效的使用,我必须购买一个WeBoostDe信号放大器和 -一台中兴的移动热点设备。当然你也可以使用一部手机作为热点,但是专用的热点设备有着最强的信号。如果你正在考虑购买一台信号放大器,最好的选择就是WeBoost因为他们的服务支持最棒,而且他们会尽最大努力去帮助你。在一个小小的APP的协助下去设置将会精准的增强 你的网络信号,他们有一个功能较少的免费的版本,但你将一点都不会后悔去花两美元使用专业版。 -那个小巧的中兴热点设备能够支持15台主机而且还有拥有基本的防火墙功能。 但你如果你使用像 Linksys WRT54GL这样的设备,使用Tomato,openWRT,或者DD-WRT来替代普通的固件,这样你就能完全控制你的防护墙规则,路由配置,以及任何其他你想要设置的服务。 - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2017/10/linux-networking-hardware-beginners-think-software - -作者:[CARLA SCHRODER][a] -译者:[FelixYFZ](https://github.com/FelixYFZ) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/cschroder -[1]:https://www.linux.com/licenses/category/used-permission -[2]:https://www.linux.com/licenses/category/used-permission -[3]:https://www.linux.com/licenses/category/creative-commons-zero -[4]:https://www.linux.com/files/images/fig-1png-7 -[5]:https://www.linux.com/files/images/fig-2png-4 -[6]:https://www.linux.com/files/images/soderskar-islandjpg -[7]:https://www.linux.com/learn/intro-to-linux/2017/10/linux-networking-hardware-beginners-lan-hardware -[8]:http://www.bluelinepc.com/signalcheck/ diff --git a/translated/tech/20171113 Glitch write fun small web projects instantly.md b/translated/tech/20171113 Glitch write fun small web projects instantly.md deleted file mode 100644 index fde7d7f880..0000000000 --- a/translated/tech/20171113 Glitch write fun small web projects instantly.md +++ /dev/null @@ -1,73 +0,0 @@ -Glitch:立即写出有趣的小型网站项目 -============================================================ - -我刚写了一篇关于 Jupyter Notebooks 是一个有趣的交互式写 Python 代码的方式。这让我想起我最近学习了 Glitch,这个我同样喜爱!我构建了一个小的程序来用于[关闭转发 twitter][2]。因此有了这篇文章! - -[Glitch][3] 是一个简单的构建 Javascript web 程序的方式(javascript 后端、javascript 前端) - -关于 glitch 有趣的事有: - -1. 你在他们的网站输入 Javascript 代码 - -2. 只要输入了任何代码,它会自动用你的新代码重载你的网站。你甚至不必保存!它会自动保存。 - -所以这就像 Heroku,但更神奇!像这样的编码(你输入代码,代码立即在公共网络上运行)对我而言感觉很**有趣**。 - -这有点像 ssh 登录服务器,编辑服务器上的 PHP/HTML 代码,并让它立即可用,这也是我所喜爱的。现在我们有了“更好的部署实践”,而不是“编辑代码,它立即出现在互联网上”,但我们并不是在谈论严肃的开发实践,而是在讨论编写微型程序的乐趣。 - -### Glitch 有很棒的示例应用程序 - -Glitch 似乎是学习编程的好方式! - -比如,这有一个太空侵略者游戏(由 [Mary Rose Cook][4] 编写):[https://space-invaders.glitch.me/][5]。我喜欢的是我只需要点击几下。 - -1. 点击 “remix this” - -2. 开始编辑代码使箱子变成橘色而不是黑色 - -3. 制作我自己太空侵略者游戏!我的在这:[http://julias-space-invaders.glitch.me/][1]。(我只做了很小的更改使其变成橘色,没什么神奇的) - -他们有大量的示例程序,你可以从中启动 - 例如[机器人][6]、[游戏][7]等等。 - -### 实际有用的非常好的程序:tweetstorms - -我学习 Glitch 的方式是从这个程序:[https://tweetstorms.glitch.me/][8],它会向你展示给定用户的 tweetstorm。 - -比如,你可以在 [https://tweetstorms.glitch.me/sarahmei][10] 看到 [@sarahmei][9] 的 tweetstorm(她发布了很多好的 tweetstorm!)。 - -### 我的 Glitch 程序: 关闭转推 - -当我了解到 Glitch 的时候,我想关闭在 Twitter 上关注的所有人的转推(我知道可以在 Tweetdeck 中做这件事),而且手动做这件事是一件很痛苦的事 - 我一次只能设置一个人。所以我写了一个 Glitch 程序来为我做! - -我喜欢我不必设置一个本地开发环境,我可以直接开始输入然后开始! - -Glitch 只支持 Javascript,我不非常了解 Javascript(我之前从没写过一个 Node 程序),所以代码不是很好。但是编写它很愉快 - 能够输入并立即看到我的代码运行是令人愉快的。这是我的项目:[https://turn-off-retweets.glitch.me/][11]。 - -### 就是这些! - -使用 Glitch 感觉真的很有趣和民主。通常情况下,如果我想 fork 某人的 Web 项目,并做出更改,我不会这样做 - 我必须 fork,找一个托管,设置本地开发环境或者 Heroku 或其他,安装依赖项等。我认为像安装 node.js 依赖关系这样的任务过去很有趣,就像“我正在学习新东西很酷”,现在我觉得它们很乏味。 - -所以我喜欢只需点击 “remix this!” 并立即在互联网上能有我的版本。 - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/2017/11/13/glitch--write-small-web-projects-easily/ - -作者:[Julia Evans ][a] -译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://jvns.ca/ -[1]:http://julias-space-invaders.glitch.me/ -[2]:https://turn-off-retweets.glitch.me/ -[3]:https://glitch.com/ -[4]:https://maryrosecook.com/ -[5]:https://space-invaders.glitch.me/ -[6]:https://glitch.com/handy-bots -[7]:https://glitch.com/games -[8]:https://tweetstorms.glitch.me/ -[9]:https://twitter.com/sarahmei -[10]:https://tweetstorms.glitch.me/sarahmei -[11]:https://turn-off-retweets.glitch.me/ diff --git a/translated/tech/20171201 How to Manage Users with Groups in Linux.md b/translated/tech/20171201 How to Manage Users with Groups in Linux.md deleted file mode 100644 index 1927de6817..0000000000 --- a/translated/tech/20171201 How to Manage Users with Groups in Linux.md +++ /dev/null @@ -1,183 +0,0 @@ -如何在 Linux 系统中用用户组来管理用户 -============================================================ - -### [group-of-people-1645356_1920.jpg][1] - -![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/group-of-people-1645356_1920.jpg?itok=rJlAxBSV) - -本教程可以了解如何通过用户组和访问控制表(ACL)来管理用户。 - -[创意共享协议][4] - -当你需要管理一台容纳多个用户的 Linux 机器时,比起一些基本的用户管理工具所提供的方法,有时候你需要对这些用户采取更多的用户权限管理方式。特别是当你要管理某些用户的权限时,这个想法尤为重要。比如说,你有一个目录,某个用户组中的用户可以通过读和写的权限访问这个目录,而其他用户组中的用户对这个目录只有读的权限。在 Linux 中,这是完全可以实现的。但前提是你必须先了解如何通过用户组和访问控制表(ACL)来管理用户。 - -我们将从简单的用户开始,逐渐深入到复杂的访问控制表(ACL)。你可以在你所选择的 Linux 发行版完成你所需要做的一切。本文的重点是用户组,所以不会涉及到关于用户的基础知识。 - -为了达到演示的目的,我将假设: - -你需要用下面两个用户名新建两个用户: - -* olivia - -* nathan - -你需要新建以下两个用户组: - -* readers - -* editors - -olivia 属于 editors 用户组,而 nathan 属于 readers 用户组。reader 用户组对 ``/DATA`` 目录只有读的权限,而 editors 用户组则对 ``/DATA`` 目录同时有读和写的权限。当然,这是个非常小的任务,但它会给你基本的信息·。你可以扩展这个任务以适应你其他更大的需求。 - -我将在 Ubuntu 16.04 Server 平台上进行演示。这些命令都是通用的,唯一不同的是,要是在你的发行版中不使用 sudo 命令,你必须切换到 root 用户来执行这些命令。 - -### 创建用户 - -我们需要做的第一件事是为我们的实验创建两个用户。可以用 ``useradd`` 命令来创建用户,我们不只是简单地创建一个用户,而需要同时创建用户和属于他们的家目录,然后给他们设置密码。 - -``` -sudo useradd -m olivia - -sudo useradd -m nathan -``` - -我们现在创建了两个用户,如果你看看 ``/home`` 目录,你可以发现他们的家目录(因为我们用了 -m 选项,可以帮在创建用户的同时创建他们的家目录。 - -之后,我们可以用以下命令给他们设置密码: - -``` -sudo passwd olivia - -sudo passwd nathan -``` - -就这样,我们创建了两个用户。 - -### 创建用户组并添加用户 - -现在我们将创建 readers 和 editors 用户组,然后给它们添加用户。创建用户组的命令是: - -``` -addgroup readers - -addgroup editors -``` - -(译者注:当你使用 CentOS 等一些 Linux 发行版时,可能系统没有 addgroup 这个命令,推荐使用 groupadd 命令来替换 addgroup 命令以达到同样的效果) - - -### [groups_1.jpg][2] - -![groups](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/groups_1.jpg?itok=BKwL89BB) - -图一:我们可以使用刚创建的新用户组了。 - -[Used with permission][5] - -创建用户组后,我们需要添加我们的用户到这两个用户组。我们用以下命令来将 nathan 用户添加到 readers 用户组: - -``` -sudo usermod -a -G readers nathan -``` -用以下命令将 olivia 添加到 editors 用户组: - -``` -sudo usermod -a -G editors olivia -``` - -现在我们可以通过用户组来管理用户了。 - -### 给用户组授予目录的权限 - -假设你有个目录 ``/READERS`` 且允许 readers 用户组的所有成员访问这个目录。首先,我们执行以下命令来更改目录所属用户组: - -``` -sudo chown -R :readers /READERS -``` - -接下来,执行以下命令收回目录所属用户组的写入权限: - -``` -sudo chmod -R g-w /READERS -``` - -然后我们执行下面的命令来收回其他用户对这个目录的访问权限(以防止任何不在 readers 组中的用户访问这个目录里的文件): - -``` -sudo chmod -R o-x /READERS -``` - -这时候,只有目录的所有者(root)和用户组 reader 中的用户可以访问 ``/READES`` 中的文件。 - -假设你有个目录 ``/EDITORS`` ,你需要给用户组 editors 里的成员这个目录的读和写的权限。为了达到这个目的,执行下面的这些命令是必要的: - -``` -sudo chown -R :editors /EDITORS - -sudo chmod -R g+w /EDITORS - -sudo chmod -R o-x /EDITORS -``` - -此时 editors 用户组的所有成员都可以访问和修改其中的文件。除此之外其他用户(除了 root 之外)无法访问 ``/EDITORS`` 中的任何文件。 - -使用这个方法的问题在于,你一次只能操作一个组和一个目录而已。这时候访问控制表(ACL)就可以派得上用场了。 - - -### 使用访问控制表(ACL) - -现在,让我们把这个问题变得棘手一点。假设你有一个目录 ``/DATA`` 并且你想给 readers 用户组的成员读取权限并同时给 editors 用户组的成员读和写的权限。为此,你必须要用到 setfacl 命令。setfacl 命令可以为文件或文件夹设置一个访问控制表(ACL)。 - -这个命令的结构如下: - -``` -setfacl OPTION X:NAME:Y /DIRECTORY -``` - -其中 OPTION 是可选选项,X 可以是 u(用户)或者是 g (用户组),NAME 是用户或者用户组的名字,/DIRECTORY 是要用到的目录。我们将使用 -m 选项进行修改(modify)。因此,我们给 readers 用户组添加读取权限的命令是: - -``` -sudo setfacl -m g:readers:rx -R /DATA -``` - -现在 readers 用户组里面的每一个用户都可以读取 /DATA 目录里的文件了,但是他们不能修改里面的内容。 - -为了给 editors 用户组里面的用户读写权限,我们执行了以下命令: - -``` -sudo setfacl -m g:editors:rwx -R /DATA -``` -上述命令将赋予 editors 用户组中的任何成员读取权限,同时保留 readers 用户组的只读权限。 - -### 更多的权限控制 - -使用访问控制表(ACL),你可以实现你所需的权限控制。你可以添加用户到用户组,并且灵活地控制这些用户组对每个目录的权限以达到你的需求。如果想了解上述工具的更多信息,可以执行下列的命令: - -* man usradd - -* man addgroup - -* man usermod - -* man sefacl - -* man chown - -* man chmod - - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2017/12/how-manage-users-groups-linux - -作者:[Jack Wallen ] -译者:[imquanquan](https://github.com/imquanquan) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[1]:https://www.linux.com/files/images/group-people-16453561920jpg -[2]:https://www.linux.com/files/images/groups1jpg -[3]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux -[4]:https://www.linux.com/licenses/category/creative-commons-zero -[5]:https://www.linux.com/licenses/category/used-permission From 0783a0be6e2a322d3455eda0ee19001fa02240be Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 6 Dec 2017 10:03:52 +0800 Subject: [PATCH 288/344] PRF:20171130 Wake up and Shut Down Linux Automatically.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @HardworkFish 恭喜你,完成了第一篇翻译! --- ...ke up and Shut Down Linux Automatically.md | 86 ++++++++----------- 1 file changed, 38 insertions(+), 48 deletions(-) diff --git a/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md b/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md index a4b829620f..d1c2167a35 100644 --- a/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md +++ b/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md @@ -1,37 +1,36 @@ - -自动唤醒和关闭 Linux +如何自动唤醒和关闭 Linux ===================== -### [banner.jpg][1] - ![timekeeper](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/banner.jpg?itok=zItspoSb) -了解如何通过配置 Linux 计算机来查看时间,并实现自动唤醒和关闭 Linux +> 了解如何通过配置 Linux 计算机来根据时间自动唤醒和关闭。 -[Creative Commons Attribution][6][The Observatory at Delhi][7] -不要成为一个电能浪费者。如果你的电脑不需要开机就请把它们关机。出于方便和计算机宅的考虑,你可以通过配置你的 Linux 计算机实现自动唤醒和关闭 Linux 。 +不要成为一个电能浪费者。如果你的电脑不需要开机就请把它们关机。出于方便和计算机宅的考虑,你可以通过配置你的 Linux 计算机实现自动唤醒和关闭。 -### 系统运行时间 +### 宝贵的系统运行时间 -有时候有些电脑需要一直处在开机状态,在不超过电脑运行时间的限制下这种情况是被允许的。有些人为他们的计算机可以长时间的正常运行而感到自豪,且现在我们有内核热补丁能够实现只有在硬件发生故障时才允许机器关机。我认为比较实际可行的是能够在机器需要节省电能以及在移动硬件发生磨损的情况下,且在不需要机器运行的情况下将其关机。比如,你可以在规定的时间内唤醒备份服务器,执行备份,然后关闭它直到它要进行下一次备份。或者,你可以设置你的 Internet 网关只在特定的时间运行。任何不需要一直运行的东西都可以将其配置成在其需要工作的时候打开,待其完成工作后将其关闭。 +有时候有些电脑需要一直处在开机状态,在不超过电脑运行时间的限制下这种情况是被允许的。有些人为他们的计算机可以长时间的正常运行而感到自豪,且现在我们有内核热补丁能够实现只有在硬件发生故障时才需要机器关机。我认为比较实际可行的是,像减少移动部件磨损一样节省电能,且在不需要机器运行的情况下将其关机。比如,你可以在规定的时间内唤醒备份服务器,执行备份,然后关闭它直到它要进行下一次备份。或者,你可以设置你的互联网网关只在特定的时间运行。任何不需要一直运行的东西都可以将其配置成在其需要工作的时候打开,待其完成工作后将其关闭。 ### 系统休眠 -对于不需要一直运行的电脑,使用 root 的 cron 定时任务或者 `/etc/crontab` 文件 可以可靠地关闭电脑。这个例子创建一个 root 定时任务实现每天下午 11点15分 定时关机。 +对于不需要一直运行的电脑,使用 root 的 cron 定时任务(即 `/etc/crontab`)可以可靠地关闭电脑。这个例子创建一个 root 定时任务实现每天晚上 11 点 15 分定时关机。 ``` # crontab -e -u root # m h dom mon dow command 15 23 * * * /sbin/shutdown -h now ``` + 以下示例仅在周一至周五运行: + ``` 15 23 * * 1-5 /sbin/shutdown -h now ``` -您可以为不同的日期和时间创建多个cron作业。 通过命令 ``man 5 crontab`` 可以了解所有时间和日期的字段。 -一个快速、容易的方式是,使用 `/etc/crontab ` 文件。但这样你必须指定用户: +您可以为不同的日期和时间创建多个 cron 作业。 通过命令 `man 5 crontab` 可以了解所有时间和日期的字段。 + +一个快速、容易的方式是,使用 `/etc/crontab` 文件。但这样你必须指定用户: ``` 15 23 * * 1-5 root shutdown -h now @@ -39,26 +38,21 @@ ### 自动唤醒 -实现自动唤醒是一件很酷的事情; 我大多数使用 SUSE (SUSE Linux)的同事都在纽伦堡,因此,因此为了跟同事能有几小时一起工作的时间,我不得不需要在凌晨五点起床。我的计算机早上 5点半自动开始工作,而我只需要将自己和咖啡拖到我的桌子上就可以开始工作了。按下电源按钮看起来好像并不是什么大事,但是在每天的那个时候每件小事都会变得很大。 +实现自动唤醒是一件很酷的事情;我大多数 SUSE (SUSE Linux)的同事都在纽伦堡,因此,因此为了跟同事能有几小时一起工作的时间,我不得不需要在凌晨五点起床。我的计算机早上 5 点半自动开始工作,而我只需要将自己和咖啡拖到我的桌子上就可以开始工作了。按下电源按钮看起来好像并不是什么大事,但是在每天的那个时候每件小事都会变得很大。 -唤醒 Linux 计算机可能不比关闭它稳当,因此你可能需要尝试不同的办法。你可以使用远程唤醒(Wake-On-LAN)、RTC 唤醒或者个人电脑的 BIOS 设置预定的唤醒这些方式。做这些工作的原因是,当你关闭电脑时,这并不是真正关闭了计算机;此时计算机处在极低功耗状态且还可以接受和响应信号。你需要拔掉电源开关将其彻底关闭。 +唤醒 Linux 计算机可能不如关闭它可靠,因此你可能需要尝试不同的办法。你可以使用远程唤醒(Wake-On-LAN)、RTC 唤醒或者个人电脑的 BIOS 设置预定的唤醒这些方式。这些方式可行的原因是,当你关闭电脑时,这并不是真正关闭了计算机;此时计算机处在极低功耗状态且还可以接受和响应信号。只有在你拔掉电源开关时其才彻底关闭。 ### BIOS 唤醒 -BIOS 唤醒是最可靠的。我的系统主板 BIOS 有一个易于使用的唤醒调度程序。(Figure 1). Chances are yours does, too. Easy peasy. - -### [fig-1.png][2] +BIOS 唤醒是最可靠的。我的系统主板 BIOS 有一个易于使用的唤醒调度程序 (图 1)。对你来说也是一样的容易。 ![wakeup](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-1_11.png?itok=8qAeqo1I) -Figure 1: My system BIOS has an easy-to-use wakeup scheduler. - -[Used with permission][8] - +*图 1:我的系统 BIOS 有个易用的唤醒定时器。* ### 主机远程唤醒(Wake-On-LAN) -远程唤醒是仅次于 BIOS 唤醒的又一种可靠的唤醒方法。这需要你从第二台计算机发送信号到所要打开的计算机。可以使用 Arduino 或 树莓派(Raspberry Pi) 发送基于 Linux 的路由器或者任何 Linux 计算机的唤醒信号。首先,查看系统主板 BIOS 是否支持 Wake-On-LAN ,要是支持的话,必须先启动它,因为它被默认为禁用。 +远程唤醒是仅次于 BIOS 唤醒的又一种可靠的唤醒方法。这需要你从第二台计算机发送信号到所要打开的计算机。可以使用 Arduino 或树莓派Raspberry Pi发送给基于 Linux 的路由器或者任何 Linux 计算机的唤醒信号。首先,查看系统主板 BIOS 是否支持 Wake-On-LAN ,要是支持的话,必须先启动它,因为它被默认为禁用。 然后,需要一个支持 Wake-On-LAN 的网卡;无线网卡并不支持。你需要运行 `ethtool` 命令查看网卡是否支持 Wake-On-LAN : @@ -67,69 +61,65 @@ Figure 1: My system BIOS has an easy-to-use wakeup scheduler. Supports Wake-on: pumbg Wake-on: g ``` -这条命令输出的 Supports Wake-on 字段会告诉你你的网卡现在开启了哪些功能: + +这条命令输出的 “Supports Wake-on” 字段会告诉你你的网卡现在开启了哪些功能:     * d -- 禁用 - * p -- 物理活动唤醒 - * u -- 单播消息唤醒 - * m -- 多播(组播)消息唤醒 - * b -- 广播消息唤醒 +* a -- ARP 唤醒 +* g -- 特定数据包magic packet唤醒 +* s -- 设有密码的特定数据包magic packet唤醒 -* a -- ARP(Address Resolution Protocol) 唤醒 - -* g -- magic packet 唤醒 - -* s -- 设有密码的 magic packet 唤醒 - -man ethtool 命令并没说清楚 p 选项的作用;这表明任何信号都会导致唤醒。然而,在我的测试中它并没有这么做。想要实现远程唤醒主机,必须支持的功能是 `g -- magic packet` 唤醒,而且显示这个功能已经在启用了。如果它没有被启用,你可以通过 `ethtool` 命令来启用它。 +`ethtool` 命令的 man 手册并没说清楚 `p` 选项的作用;这表明任何信号都会导致唤醒。然而,在我的测试中它并没有这么做。想要实现远程唤醒主机,必须支持的功能是 `g` —— 特定数据包magic packet唤醒,而且下面的“Wake-on” 行显示这个功能已经在启用了。如果它没有被启用,你可以通过 `ethtool` 命令来启用它。 ``` # ethtool -s eth0 wol g ``` + 这条命令可能会在重启后失效,所以为了确保万无一失,你可以创建个 root 用户的定时任务(cron)在每次重启的时候来执行这条命令。 + ``` @reboot /usr/bin/ethtool -s eth0 wol g ``` -### [fig-2.png][3] +另一个选择是最近的网络管理器Network Manager版本有一个很好的小复选框来启用 Wake-On-LAN(图 2)。 ![wakeonlan](https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig-2_7.png?itok=XQAwmHoQ) -Figure 2: Enable Wake on LAN. +*图 2:启用 Wake on LAN* -[Used with permission][9] +这里有一个可以用于设置密码的地方,但是如果你的网络接口不支持安全开机Secure On密码,它就不起作用。 -另一个选择是最近的网络管理器版本有一个很好的小复选框来启用 Wake-On-LAN(图2)。 - -这里有一个可以用于设置密码的地方,但是如果你的网络接口不支持安全密码,它就不起作用。 - -现在你需要配置第二台计算机来发送唤醒信号。你并不需要 root 权限,所以你可以为你的用户创建 cron 任务。你需要用到的是想要唤醒的机器的网络接口和MAC地址信息。 +现在你需要配置第二台计算机来发送唤醒信号。你并不需要 root 权限,所以你可以为你的普通用户创建 cron 任务。你需要用到的是想要唤醒的机器的网络接口和MAC地址信息。 ``` 30 08 * * * /usr/bin/wakeonlan D0:50:99:82:E7:2B ``` -### RTC 唤醒(RTC Alarm Clock) + +### RTC 唤醒 通过使用实时闹钟来唤醒计算机是最不可靠的方法。对于这个方法,可以参看 [Wake Up Linux With an RTC Alarm Clock][4] ;对于现在的大多数发行版来说这种方法已经有点过时了。 -下周继续了解更多关于使用RTC唤醒的方法。 +下周继续了解更多关于使用 RTC 唤醒的方法。 -通过 Linux 基金会和 edX 可以学习更多关于 Linux 的免费 [ Linux 入门][5]教程。 +通过 Linux 基金会和 edX 可以学习更多关于 Linux 的免费 [Linux 入门][5]教程。 + +(题图:[The Observatory at Delhi][7]) -------------------------------------------------------------------------------- via:https://www.linux.com/learn/intro-to-linux/2017/11/wake-and-shut-down-linux-automatically -作者:[Carla Schroder] -译者:[译者ID](https://github.com/HardworkFish) -校对:[校对者ID](https://github.com/校对者ID) +作者:[Carla Schroder][a] +译者:[HardworkFish](https://github.com/HardworkFish) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 +[a]:https://www.linux.com/users/cschroder [1]:https://www.linux.com/files/images/bannerjpg [2]:https://www.linux.com/files/images/fig-1png-11 [3]:https://www.linux.com/files/images/fig-2png-7 From cc4ba2f3b8da76146ec6d33db86935a887ed69e8 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 6 Dec 2017 10:04:35 +0800 Subject: [PATCH 289/344] PUB:20171130 Wake up and Shut Down Linux Automatically.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @HardworkFish 文章发布地址:https://linux.cn/article-9115-1.html LCTT 专页地址:https://linux.cn/lctt/HardworkFish --- .../20171130 Wake up and Shut Down Linux Automatically.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171130 Wake up and Shut Down Linux Automatically.md (100%) diff --git a/translated/tech/20171130 Wake up and Shut Down Linux Automatically.md b/published/20171130 Wake up and Shut Down Linux Automatically.md similarity index 100% rename from translated/tech/20171130 Wake up and Shut Down Linux Automatically.md rename to published/20171130 Wake up and Shut Down Linux Automatically.md From ccbb494a35afac3934b0b673580b8ebdebcc3a8c Mon Sep 17 00:00:00 2001 From: root Date: Wed, 6 Dec 2017 10:15:56 +0800 Subject: [PATCH 290/344] rename --- ...Long Running Terminal Commands Complete.md | 156 ++++++++++++++++++ ...1 Fedora Classroom Session_Ansible 101.md} | 0 2 files changed, 156 insertions(+) create mode 100644 sources/tech/20171130 Undistract-me_Get Notification When Long Running Terminal Commands Complete.md rename sources/tech/{20171201 Fedora Classroom Session: Ansible 101.md => 20171201 Fedora Classroom Session_Ansible 101.md} (100%) diff --git a/sources/tech/20171130 Undistract-me_Get Notification When Long Running Terminal Commands Complete.md b/sources/tech/20171130 Undistract-me_Get Notification When Long Running Terminal Commands Complete.md new file mode 100644 index 0000000000..46afe9b893 --- /dev/null +++ b/sources/tech/20171130 Undistract-me_Get Notification When Long Running Terminal Commands Complete.md @@ -0,0 +1,156 @@ +translating---geekpi + +Undistract-me : Get Notification When Long Running Terminal Commands Complete +============================================================ + +by [sk][2] · November 30, 2017 + +![Undistract-me](https://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2-720x340.png) + +A while ago, we published how to [get notification when a Terminal activity is done][3]. Today, I found out a similar utility called “undistract-me” that notifies you when long running terminal commands complete. Picture this scenario. You run a command that takes a while to finish. In the mean time, you check your facebook and get so involved in it. After a while, you remembered that you ran a command few minutes ago. You go back to the Terminal and notice that the command has already finished. But you have no idea when the command is completed. Have you ever been in this situation? I bet most of you were in this situation many times. This is where “undistract-me” comes in help. You don’t need to constantly check the terminal to see if a command is completed or not. Undistract-me utility will notify you when a long running command is completed. It will work on Arch Linux, Debian, Ubuntu and other Ubuntu-derivatives. + +#### Installing Undistract-me + +Undistract-me is available in the default repositories of Debian and its variants such as Ubuntu. All you have to do is to run the following command to install it. + +``` +sudo apt-get install undistract-me +``` + +The Arch Linux users can install it from AUR using any helper programs. + +Using [Pacaur][4]: + +``` +pacaur -S undistract-me-git +``` + +Using [Packer][5]: + +``` +packer -S undistract-me-git +``` + +Using [Yaourt][6]: + +``` +yaourt -S undistract-me-git +``` + +Then, run the following command to add “undistract-me” to your Bash. + +``` +echo 'source /etc/profile.d/undistract-me.sh' >> ~/.bashrc +``` + +Alternatively you can run this command to add it to your Bash: + +``` +echo "source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install" >> .bashrc +``` + +If you are in Zsh shell, run this command: + +``` +echo "source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install" >> .zshrc +``` + +Finally update the changes: + +For Bash: + +``` +source ~/.bashrc +``` + +For Zsh: + +``` +source ~/.zshrc +``` + +#### Configure Undistract-me + +By default, Undistract-me will consider any command that takes more than 10 seconds to complete as a long-running command. You can change this time interval by editing /usr/share/undistract-me/long-running.bash file. + +``` +sudo nano /usr/share/undistract-me/long-running.bash +``` + +Find “LONG_RUNNING_COMMAND_TIMEOUT” variable and change the default value (10 seconds) to something else of your choice. + + [![](http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-1.png)][7] + +Save and close the file. Do not forget to update the changes: + +``` +source ~/.bashrc +``` + +Also, you can disable notifications for particular commands. To do so, find the “LONG_RUNNING_IGNORE_LIST” variable and add the commands space-separated like below. + +By default, the notification will only show if the active window is not the window the command is running in. That means, it will notify you only if the command is running in the background Terminal window. If the command is running in active window Terminal, you will not be notified. If you want undistract-me to send notifications either the Terminal window is visible or in the background, you can set IGNORE_WINDOW_CHECK to 1 to skip the window check. + +The other cool feature of Undistract-me is you can set audio notification along with visual notification when a command is done. By default, it will only send a visual notification. You can change this behavior by setting the variable UDM_PLAY_SOUND to a non-zero integer on the command line. However, your Ubuntu system should have pulseaudio-utils and sound-theme-freedesktop utilities installed to enable this functionality. + +Please remember that you need to run the following command to update the changes made. + +For Bash: + +``` +source ~/.bashrc +``` + +For Zsh: + +``` +source ~/.zshrc +``` + +It is time to verify if this really works. + +#### Get Notification When Long Running Terminal Commands Complete + +Now, run any command that takes longer than 10 seconds or the time duration you defined in Undistract-me script. + +I ran the following command on my Arch Linux desktop. + +``` +sudo pacman -Sy +``` + +This command took 32 seconds to complete. After the completion of the above command, I got the following notification. + + [![](http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2.png)][8] + +Please remember Undistract-me script notifies you only if the given command took more than 10 seconds to complete. If the command is completed in less than 10 seconds, you will not be notified. Of course, you can change this time interval settings as I described in the Configuration section above. + +I find this tool very useful. It helped me to get back to the business after I completely lost in some other tasks. I hope this tool will be helpful to you too. + +More good stuffs to come. Stay tuned! + +Cheers! + +Resource: + +* [Undistract-me GitHub Repository][1] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/undistract-get-notification-long-running-terminal-commands-complete/ + +作者:[sk][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://github.com/jml/undistract-me +[2]:https://www.ostechnix.com/author/sk/ +[3]:https://www.ostechnix.com/get-notification-terminal-task-done/ +[4]:https://www.ostechnix.com/install-pacaur-arch-linux/ +[5]:https://www.ostechnix.com/install-packer-arch-linux-2/ +[6]:https://www.ostechnix.com/install-yaourt-arch-linux/ +[7]:http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-1.png +[8]:http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2.png diff --git a/sources/tech/20171201 Fedora Classroom Session: Ansible 101.md b/sources/tech/20171201 Fedora Classroom Session_Ansible 101.md similarity index 100% rename from sources/tech/20171201 Fedora Classroom Session: Ansible 101.md rename to sources/tech/20171201 Fedora Classroom Session_Ansible 101.md From 9e42cbb031b688a1e732dbbc8405b70b425bff97 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 6 Dec 2017 10:42:43 +0800 Subject: [PATCH 291/344] translated --- ... write fun small web projects instantly.md | 76 ------------------- ... write fun small web projects instantly.md | 73 ++++++++++++++++++ 2 files changed, 73 insertions(+), 76 deletions(-) delete mode 100644 sources/tech/20171113 Glitch write fun small web projects instantly.md create mode 100644 translated/tech/20171113 Glitch write fun small web projects instantly.md diff --git a/sources/tech/20171113 Glitch write fun small web projects instantly.md b/sources/tech/20171113 Glitch write fun small web projects instantly.md deleted file mode 100644 index 734853ce51..0000000000 --- a/sources/tech/20171113 Glitch write fun small web projects instantly.md +++ /dev/null @@ -1,76 +0,0 @@ -translating---geekpi - -Glitch: write fun small web projects instantly -============================================================ - -I just wrote about Jupyter Notebooks which are a fun interactive way to write Python code. That reminded me I learned about Glitch recently, which I also love!! I built a small app to [turn of twitter retweets][2] with it. So! - -[Glitch][3] is an easy way to make Javascript webapps. (javascript backend, javascript frontend) - -The fun thing about glitch is: - -1. you start typing Javascript code into their web interface - -2. as soon as you type something, it automagically reloads the backend of your website with the new code. You don’t even have to save!! It autosaves. - -So it’s like Heroku, but even more magical!! Coding like this (you type, and the code runs on the public internet immediately) just feels really **fun** to me. - -It’s kind of like sshing into a server and editing PHP/HTML code on your server and having it instantly available, which I kind of also loved. Now we have “better deployment practices” than “just edit the code and it is instantly on the internet” but we are not talking about Serious Development Practices, we are talking about writing tiny programs for fun. - -### glitch has awesome example apps - -Glitch seems like fun nice way to learn programming! - -For example, there’s a space invaders game (code by [Mary Rose Cook][4]) at [https://space-invaders.glitch.me/][5]. The thing I love about this is that in just a few clicks I can - -1. click “remix this” - -2. start editing the code to make the boxes orange instead of black - -3. have my own space invaders game!! Mine is at [http://julias-space-invaders.glitch.me/][1]. (i just made very tiny edits to make it orange, nothing fancy) - -They have tons of example apps that you can start from – for instance [bots][6], [games][7], and more. - -### awesome actually useful app: tweetstorms - -The way I learned about Glitch was from this app which shows you tweetstorms from a given user: [https://tweetstorms.glitch.me/][8]. - -For example, you can see [@sarahmei][9]’s tweetstorms at [https://tweetstorms.glitch.me/sarahmei][10] (she tweets a lot of good tweetstorms!). - -### my glitch app: turn off retweets - -When I learned about Glitch I wanted to turn off retweets for everyone I follow on Twitter (I know you can do it in Tweetdeck!) and doing it manually was a pain – I had to do it one person at a time. So I wrote a tiny Glitch app to do it for me! - -I liked that I didn’t have to set up a local development environment, I could just start typing and go! - -Glitch only supports Javascript and I don’t really know Javascript that well (I think I’ve never written a Node program before), so the code isn’t awesome. But I had a really good time writing it – being able to type and just see my code running instantly was delightful. Here it is: [https://turn-off-retweets.glitch.me/][11]. - -### that’s all! - -Using Glitch feels really fun and democratic. Usually if I want to fork someone’s web project and make changes I wouldn’t do it – I’d have to fork it, figure out hosting, set up a local dev environment or Heroku or whatever, install the dependencies, etc. I think tasks like installing node.js dependencies used to be interesting, like “cool i am learning something new” and now I just find them tedious. - -So I love being able to just click “remix this!” and have my version on the internet instantly. - - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/2017/11/13/glitch--write-small-web-projects-easily/ - -作者:[Julia Evans ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://jvns.ca/ -[1]:http://julias-space-invaders.glitch.me/ -[2]:https://turn-off-retweets.glitch.me/ -[3]:https://glitch.com/ -[4]:https://maryrosecook.com/ -[5]:https://space-invaders.glitch.me/ -[6]:https://glitch.com/handy-bots -[7]:https://glitch.com/games -[8]:https://tweetstorms.glitch.me/ -[9]:https://twitter.com/sarahmei -[10]:https://tweetstorms.glitch.me/sarahmei -[11]:https://turn-off-retweets.glitch.me/ diff --git a/translated/tech/20171113 Glitch write fun small web projects instantly.md b/translated/tech/20171113 Glitch write fun small web projects instantly.md new file mode 100644 index 0000000000..fde7d7f880 --- /dev/null +++ b/translated/tech/20171113 Glitch write fun small web projects instantly.md @@ -0,0 +1,73 @@ +Glitch:立即写出有趣的小型网站项目 +============================================================ + +我刚写了一篇关于 Jupyter Notebooks 是一个有趣的交互式写 Python 代码的方式。这让我想起我最近学习了 Glitch,这个我同样喜爱!我构建了一个小的程序来用于[关闭转发 twitter][2]。因此有了这篇文章! + +[Glitch][3] 是一个简单的构建 Javascript web 程序的方式(javascript 后端、javascript 前端) + +关于 glitch 有趣的事有: + +1. 你在他们的网站输入 Javascript 代码 + +2. 只要输入了任何代码,它会自动用你的新代码重载你的网站。你甚至不必保存!它会自动保存。 + +所以这就像 Heroku,但更神奇!像这样的编码(你输入代码,代码立即在公共网络上运行)对我而言感觉很**有趣**。 + +这有点像 ssh 登录服务器,编辑服务器上的 PHP/HTML 代码,并让它立即可用,这也是我所喜爱的。现在我们有了“更好的部署实践”,而不是“编辑代码,它立即出现在互联网上”,但我们并不是在谈论严肃的开发实践,而是在讨论编写微型程序的乐趣。 + +### Glitch 有很棒的示例应用程序 + +Glitch 似乎是学习编程的好方式! + +比如,这有一个太空侵略者游戏(由 [Mary Rose Cook][4] 编写):[https://space-invaders.glitch.me/][5]。我喜欢的是我只需要点击几下。 + +1. 点击 “remix this” + +2. 开始编辑代码使箱子变成橘色而不是黑色 + +3. 制作我自己太空侵略者游戏!我的在这:[http://julias-space-invaders.glitch.me/][1]。(我只做了很小的更改使其变成橘色,没什么神奇的) + +他们有大量的示例程序,你可以从中启动 - 例如[机器人][6]、[游戏][7]等等。 + +### 实际有用的非常好的程序:tweetstorms + +我学习 Glitch 的方式是从这个程序:[https://tweetstorms.glitch.me/][8],它会向你展示给定用户的 tweetstorm。 + +比如,你可以在 [https://tweetstorms.glitch.me/sarahmei][10] 看到 [@sarahmei][9] 的 tweetstorm(她发布了很多好的 tweetstorm!)。 + +### 我的 Glitch 程序: 关闭转推 + +当我了解到 Glitch 的时候,我想关闭在 Twitter 上关注的所有人的转推(我知道可以在 Tweetdeck 中做这件事),而且手动做这件事是一件很痛苦的事 - 我一次只能设置一个人。所以我写了一个 Glitch 程序来为我做! + +我喜欢我不必设置一个本地开发环境,我可以直接开始输入然后开始! + +Glitch 只支持 Javascript,我不非常了解 Javascript(我之前从没写过一个 Node 程序),所以代码不是很好。但是编写它很愉快 - 能够输入并立即看到我的代码运行是令人愉快的。这是我的项目:[https://turn-off-retweets.glitch.me/][11]。 + +### 就是这些! + +使用 Glitch 感觉真的很有趣和民主。通常情况下,如果我想 fork 某人的 Web 项目,并做出更改,我不会这样做 - 我必须 fork,找一个托管,设置本地开发环境或者 Heroku 或其他,安装依赖项等。我认为像安装 node.js 依赖关系这样的任务过去很有趣,就像“我正在学习新东西很酷”,现在我觉得它们很乏味。 + +所以我喜欢只需点击 “remix this!” 并立即在互联网上能有我的版本。 + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/11/13/glitch--write-small-web-projects-easily/ + +作者:[Julia Evans ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://jvns.ca/ +[1]:http://julias-space-invaders.glitch.me/ +[2]:https://turn-off-retweets.glitch.me/ +[3]:https://glitch.com/ +[4]:https://maryrosecook.com/ +[5]:https://space-invaders.glitch.me/ +[6]:https://glitch.com/handy-bots +[7]:https://glitch.com/games +[8]:https://tweetstorms.glitch.me/ +[9]:https://twitter.com/sarahmei +[10]:https://tweetstorms.glitch.me/sarahmei +[11]:https://turn-off-retweets.glitch.me/ From 8391d9321c5fba682cfffa41436516aae1e171f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E8=8D=A3=E5=8D=87?= Date: Wed, 6 Dec 2017 10:43:15 +0800 Subject: [PATCH 292/344] Update 20171120 Mark McIntyre How Do You Fedora.md --- ...0171120 Mark McIntyre How Do You Fedora.md | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/sources/tech/20171120 Mark McIntyre How Do You Fedora.md b/sources/tech/20171120 Mark McIntyre How Do You Fedora.md index 40af7eba2f..76606f74dc 100644 --- a/sources/tech/20171120 Mark McIntyre How Do You Fedora.md +++ b/sources/tech/20171120 Mark McIntyre How Do You Fedora.md @@ -1,54 +1,52 @@ -translating by zrszrszrs -# [Mark McIntyre: How Do You Fedora?][1] # [Mark McIntyre: 你是如何使用Fedora的?][1] ![](https://fedoramagazine.org/wp-content/uploads/2017/11/mock-couch-945w-945x400.jpg) -We recently interviewed Mark McIntyre on how he uses Fedora. This is [part of a series][2] on the Fedora Magazine. The series profiles Fedora users and how they use Fedora to get things done. Contact us on the [feedback form][3] to express your interest in becoming a interviewee. +最近我们采访了 Mark McIntyre,谈来他是如何使用 Fedora 系统的。这也是Fedora 杂志上[本系列的一部分][2]。该系列简要介绍了 Fedora 用户,以及他们是如何用 Fedora 把事情做好的。通过[反馈表][3]与我们联系,表达你想成为采访对象的意愿。 -### Who is Mark McIntyre? +### Mark McIntyre 是谁? -Mark McIntyre is a geek by birth and Linux by choice. “I started coding at the early age of 13 learning BASIC on my own and finding the excitement of programming which led me down a path of becoming a professional coder,” he says. McIntyre and his niece are big fans of pizza. “My niece and I started a quest last fall to try as many of the pizza joints in Knoxville. You can read about our progress at [https://knox-pizza-quest.blogspot.com/][4]” Mark is also an amateur photographer and [publishes his images][5] on Flickr. +Mark McIntyre 是一个天生的极客,后天的 Linux 爱好者。他说:“我在 13 岁开始编程,当时自学 BASIC 语言,我体会到其中的乐趣,并在乐趣的引导下,一步步成为专业的码农。”Mark 和他的侄女都是披萨饼的死忠粉。“去年秋天,我和我的侄女尽可能多地光顾了诺克斯维尔的披萨饼连锁店。 点击 [https://knox-pizza-quest.blogspot.com/][4] 可以了解我们的进展情况。”Mark 也是一名业余的摄影爱好者,并且在 Flickr 上 [发布自己的作品][5]。 ![](https://fedoramagazine.org/wp-content/uploads/2017/11/31456893222_553b3cac4d_k-1024x575.jpg) -Mark has a diverse background as a developer. He has worked with Visual Basic for Applications, LotusScript, Oracle’s PL/SQL, Tcl/Tk and Python with Django as the framework. His strongest skill is Python which he uses in his current job as a systems engineer. “I am using Python on a regular basis. As my job is morphing into more of an automation engineer, that became more frequent.” +作为一名开发者,Mark 有着丰富的工作背景。他用过 Visual Basic 编写应用程序,用过 LotusScript、 PL/SQL(Oracle)、 Tcl/TK 编写代码,也用过基于 Python 的 Django 框架。他的强项是 Python。这也是目前他作为系统工程师的工作语言。“我用 Python 比较规律。但当我的工作变得更像是自动化工程师时,Python 用得就更频繁了。” -McIntyre is a self-described nerd and loves sci-fi movies, but his favorite movie falls out of that genre. “As much as I am a nerd and love the Star Trek and Star Wars and related movies, the movie Glory is probably my favorite of all time.” He also mentioned that Serenity was a fantastic follow-up to a great TV series. +McIntyre 自称是个书呆子,喜欢科幻电影,但他最喜欢的一部电影却不是科幻片。“尽管我是个书呆子,喜欢看《星际迷航》、《星球大战》之类的影片,但《光荣战役》或许才是我最喜欢的电影。”他还提到,电影《冲出宁静号》实属著名电视剧《萤火虫》的精彩后续。 -Mark values humility, knowledge and graciousness in others. He appreciates people who act based on understanding the situation that other people are in. “If you add a decision to serve another, you have the basis for someone you’d want to be around instead of someone who you have to tolerate.” +Mark 比较看重他人的谦逊、知识与和气。他欣赏能够设身处地为他人着想的人。“如果你决定为另一个人服务,那么你会选择自己愿意亲近的人,而不是让自己备受折磨的人。” -McIntyre works for [Scripps Networks Interactive][6], which is the parent company for HGTV, Food Network, Travel Channel, DIY, GAC, and several other cable channels. “Currently, I function as a systems engineer for the non-linear video content, which is all the media purposed for online consumption.” He supports a few development teams who write applications to publish the linear video from cable TV into the online formats such as Amazon and Hulu. The systems include both on-premise and cloud systems. Mark also develops automation tools for deploying these applications primarily to a cloud infrastructure. +McIntyre 目前在 [Scripps Networks Interactive][6] 工作,这家公司是 HGTV、Food Network、Travel Channel、DIY、GAC 以及其他几个有线电视频道的母公司。“我现在是一名系统工程师,负责非线性视频内容,这是全部媒体开展线上消费的计划。”他支持一些开发团队编写应用程序,将线性视频从有线电视发布到线上平台,比如亚马逊、葫芦。这些系统既包含预置系统,也包含云系统。Mark 还开发了一些自动化工具,将这些应用程序主要部署到云基础结构中。 -### The Fedora community +### Fedora 社区 -Mark describes the Fedora community as an active community filled with people who enjoy life as Fedora users. “From designers to packagers, this group is still very active and feels alive.” McIntyre continues, “That gives me a sense of confidence in the operating system.” +Mark 形容 Fedora 社区是一个富有活力的社区,充满着像 Fedora 用户一样热爱生活的人。“从设计师到包装师,这个团体依然非常活跃,生机勃勃。” 他继续说道:“这使我对操作系统抱有一种信心。” -He started frequenting the #fedora channel on IRC around 2002: “Back then, Wi-Fi functionality was still done a lot by hand in starting the adapter and configuring the modules.” In order to get his Wi-Fi working he had to recompile the Fedora kernel. Shortly after, he started helping others in the #fedora channel. +2002年左右,Mark 开始经常使用 IRC 上的 #fedora 频道:“那时候,Wi-Fi 在启用适配器和配置模块功能时,有许多还是靠手工实现的。”为了让他的 Wi-Fi 能够工作,他不得不重新去编译 Fedora 内核。 -McIntyre encourages others to get involved in the Fedora Community. “There are many different areas of opportunity in which to be involved. Front-end design, testing deployments, development, packaging of applications, and new technology implementation.” He recommends picking an area of interest and asking questions of that group. “There are many opportunities available to jump in to contribute.” +McIntyre 鼓励他人参与 Fedora 社区。“这里有许多来自不同领域的机会。前端设计、测试部署、开发、应用程序包装以及新型技术实现。”他建议选择一个感兴趣的领域,然后向那个团体提出疑问。“这里有许多机会去奉献自己。” -He credits a fellow community member with helping him get started: “Ben Williams was very helpful in my first encounters with Fedora, helping me with some of my first installation rough patches in the #fedora support channel.” Ben also encouraged Mark to become an [Ambassador][7]. +对于帮助他起步的社区成员,Mark 赞道:“Ben Williams 非常乐于助人。在我第一次接触Fedora时,他帮我搞定了一些#fedora支持频道中的安装补丁。”Ben 也鼓励 Mark 去做 Fedora [代表][7]。 -### What hardware and software? +### 什么样的硬件和软件? -McIntyre uses Fedora Linux on all his laptops and desktops. On servers he chooses CentOS, due to the longer support lifecycle. His current desktop is self-built and equipped with an Intel Core i5 processor, 32 GB of RAM and 2 TB of disk space. “I have a 4K monitor attached which gives me plenty of room for viewing all my applications at once.” His current work laptop is a Dell Inspiron 2-in-1 13-inch laptop with 16 GB RAM and a 525 GB m.2 SSD. +McIntyre 将 Fedora Linux 系统用在他的笔记本和台式机上。在服务器上他选择了 CentOS,因为它有更长的生命周期支持。他现在的台式机是自己组装的,配有 Intel 酷睿 i5 处理器,32GB 的内存和2TB 的硬盘。“我装了个 4K 的显示屏,有足够大的地方来同时查看所有的应用。”他目前工作用的笔记本是戴尔灵越二合一,配备 13 英寸的屏,16 GB 的内存和 525 GB 的 m.2 固态硬盘。 ![](https://fedoramagazine.org/wp-content/uploads/2017/11/Screenshot-from-2017-10-26-08-51-41-1024x640.png) -Mark currently runs Fedora 26 on any box he setup in the past few months. When it comes to new versions he likes to avoid the rush when the version is officially released. “I usually try to get the latest version as soon as it goes gold, with the exception of one of my workstations running the next version’s beta when it is closer to release.” He usually upgrades in place: “The in-place upgrade using  _dnf system-upgrade_  works very well these days.” +Mark 现在将 Fedora 26 运行在他过去几个月装配的所有盒子中。当一个新版本正式发布的时候,他倾向于避开这个高峰期。“除非在它即将发行的时候,我的工作站中有个正在运行下一代测试版本,通常情况下,一旦它发展成熟,我都会试着去获取最新的版本。”他经常采取就地更新:“这种就地更新方法利用 dnf 系统升级插件,目前表现得非常好。” -To handle his photography, McIntyre uses [GIMP][8] and [Darktable][9], along with a few other photo viewing and quick editing packages. When not using web-based email, he uses [Geary][10] along with [GNOME Calendar][11]. Mark’s IRC client of choice is [HexChat][12] connecting to a [ZNC bouncer][13]running on a Fedora Server instance. His department’s communication is handled via Slack. +为了搞摄影,McIntyre 用上了 [GIMP][8]、[Darktable][9],以及其他一些照片查看包和快速编辑包。当不启用网络电子邮件时,Mark 会使用 [Geary][10],还有[GNOME Calendar][11]。Mark 选用 HexChat 作为 IRC 客户端,[HexChat][12] 与在 Fedora 服务器实例上运行的 [ZNC bouncer][13] 联机。他的部门通过 Slave 进行沟通交流。 -“I have never really been a big IDE fan, so I spend time in [vim][14] for most of my editing.” Occasionally, he opens up a simple text editor like [gedit][15] or [xed][16]. Mark uses [GPaste][17] for  copying and pasting. “I have become a big fan of [Tilix][18] for my terminal choice.” McIntyre manages the podcasts he likes with [Rhythmbox][19], and uses [Epiphany][20] for quick web lookups. +“我从来都不是 IDE 粉,所以大多数的编辑任务都是在 [vim][14] 上完成的。”Mark 偶尔也会打开一个简单的文本编辑器,如 [gedit][15],或者 [xed][16]。他用 [GPaste][17] 做复制和粘贴工作。“对于终端的选择,我已经变成 [Tilix][18] 的忠粉。” McIntyre 通过 [Rhythmbox][19] 来管理他喜欢的播客,并用 [Epiphany][20] 实现快速网络查询。 -------------------------------------------------------------------------------- via: https://fedoramagazine.org/mark-mcintyre-fedora/ 作者:[Charles Profitt][a] -译者:[译者ID](https://github.com/译者ID) +译者:[zrszrs](https://github.com/zrszrszrs) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 9906fd3a107cf8b38291b23164e012191f3b4cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E8=8D=A3=E5=8D=87?= Date: Wed, 6 Dec 2017 11:05:45 +0800 Subject: [PATCH 293/344] Update 20171120 Mark McIntyre How Do You Fedora.md --- .../tech/20171120 Mark McIntyre How Do You Fedora.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sources/tech/20171120 Mark McIntyre How Do You Fedora.md b/sources/tech/20171120 Mark McIntyre How Do You Fedora.md index 76606f74dc..e89527a377 100644 --- a/sources/tech/20171120 Mark McIntyre How Do You Fedora.md +++ b/sources/tech/20171120 Mark McIntyre How Do You Fedora.md @@ -3,7 +3,7 @@ ![](https://fedoramagazine.org/wp-content/uploads/2017/11/mock-couch-945w-945x400.jpg) -最近我们采访了 Mark McIntyre,谈来他是如何使用 Fedora 系统的。这也是Fedora 杂志上[本系列的一部分][2]。该系列简要介绍了 Fedora 用户,以及他们是如何用 Fedora 把事情做好的。通过[反馈表][3]与我们联系,表达你想成为采访对象的意愿。 +最近我们采访了 Mark McIntyre,谈来他是如何使用 Fedora 系统的。这也是 Fedora 杂志上[本系列的一部分][2]。该系列简要介绍了 Fedora 用户,以及他们是如何用 Fedora 把事情做好的。通过[反馈表][3]与我们联系,表达你想成为采访对象的意愿。 ### Mark McIntyre 是谁? @@ -11,7 +11,7 @@ Mark McIntyre 是一个天生的极客,后天的 Linux 爱好者。他说: ![](https://fedoramagazine.org/wp-content/uploads/2017/11/31456893222_553b3cac4d_k-1024x575.jpg) -作为一名开发者,Mark 有着丰富的工作背景。他用过 Visual Basic 编写应用程序,用过 LotusScript、 PL/SQL(Oracle)、 Tcl/TK 编写代码,也用过基于 Python 的 Django 框架。他的强项是 Python。这也是目前他作为系统工程师的工作语言。“我用 Python 比较规律。但当我的工作变得更像是自动化工程师时,Python 用得就更频繁了。” +作为一名开发者,Mark 有着丰富的工作背景。他用过 Visual Basic 编写应用程序,用过 LotusScript、 PL/SQL(Oracle)、 Tcl/TK 编写代码,也用过基于 Python 的 Django 框架。他的强项是 Python。这也是目前他作为系统工程师的工作语言。“我用 Python 比较规律。但当我的工作变得更像是自动化工程师时, Python 用得就更频繁了。” McIntyre 自称是个书呆子,喜欢科幻电影,但他最喜欢的一部电影却不是科幻片。“尽管我是个书呆子,喜欢看《星际迷航》、《星球大战》之类的影片,但《光荣战役》或许才是我最喜欢的电影。”他还提到,电影《冲出宁静号》实属著名电视剧《萤火虫》的精彩后续。 @@ -27,11 +27,11 @@ Mark 形容 Fedora 社区是一个富有活力的社区,充满着像 Fedora McIntyre 鼓励他人参与 Fedora 社区。“这里有许多来自不同领域的机会。前端设计、测试部署、开发、应用程序包装以及新型技术实现。”他建议选择一个感兴趣的领域,然后向那个团体提出疑问。“这里有许多机会去奉献自己。” -对于帮助他起步的社区成员,Mark 赞道:“Ben Williams 非常乐于助人。在我第一次接触Fedora时,他帮我搞定了一些#fedora支持频道中的安装补丁。”Ben 也鼓励 Mark 去做 Fedora [代表][7]。 +对于帮助他起步的社区成员,Mark 赞道:“Ben Williams 非常乐于助人。在我第一次接触 Fedora 时,他帮我搞定了一些 #fedora 支持频道中的安装补丁。” Ben 也鼓励 Mark 去做 Fedora [代表][7]。 ### 什么样的硬件和软件? -McIntyre 将 Fedora Linux 系统用在他的笔记本和台式机上。在服务器上他选择了 CentOS,因为它有更长的生命周期支持。他现在的台式机是自己组装的,配有 Intel 酷睿 i5 处理器,32GB 的内存和2TB 的硬盘。“我装了个 4K 的显示屏,有足够大的地方来同时查看所有的应用。”他目前工作用的笔记本是戴尔灵越二合一,配备 13 英寸的屏,16 GB 的内存和 525 GB 的 m.2 固态硬盘。 +McIntyre 将 Fedora Linux 系统用在他的笔记本和台式机上。在服务器上他选择了 CentOS,因为它有更长的生命周期支持。他现在的台式机是自己组装的,配有 Intel 酷睿 i5 处理器,32GB 的内存和2TB 的硬盘。“我装了个 4K 的显示屏,有足够大的,地方来同时查看所有的应用。”他目前工作用的笔记本是戴尔灵越二合一,配备 13 英寸的屏,16 GB 的内存和 525 GB 的 m.2 固态硬盘。 ![](https://fedoramagazine.org/wp-content/uploads/2017/11/Screenshot-from-2017-10-26-08-51-41-1024x640.png) @@ -39,7 +39,7 @@ Mark 现在将 Fedora 26 运行在他过去几个月装配的所有盒子中。 为了搞摄影,McIntyre 用上了 [GIMP][8]、[Darktable][9],以及其他一些照片查看包和快速编辑包。当不启用网络电子邮件时,Mark 会使用 [Geary][10],还有[GNOME Calendar][11]。Mark 选用 HexChat 作为 IRC 客户端,[HexChat][12] 与在 Fedora 服务器实例上运行的 [ZNC bouncer][13] 联机。他的部门通过 Slave 进行沟通交流。 -“我从来都不是 IDE 粉,所以大多数的编辑任务都是在 [vim][14] 上完成的。”Mark 偶尔也会打开一个简单的文本编辑器,如 [gedit][15],或者 [xed][16]。他用 [GPaste][17] 做复制和粘贴工作。“对于终端的选择,我已经变成 [Tilix][18] 的忠粉。” McIntyre 通过 [Rhythmbox][19] 来管理他喜欢的播客,并用 [Epiphany][20] 实现快速网络查询。 +“我从来都不是 IDE 粉,所以大多数的编辑任务都是在 [vim][14] 上完成的。”Mark 偶尔也会打开一个简单的文本编辑器,如 [gedit][15],或者 [xed][16]。他用 [GPaste][17] 做复制和粘贴工作。“对于终端的选择,我已经变成 [Tilix][18] 的忠粉。”McIntyre 通过 [Rhythmbox][19] 来管理他喜欢的播客,并用 [Epiphany][20] 实现快速网络查询。 -------------------------------------------------------------------------------- From cde0a112fc36619879e0772c81843e14ce8a3c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E8=8D=A3=E5=8D=87?= Date: Wed, 6 Dec 2017 11:06:15 +0800 Subject: [PATCH 294/344] Update 20171120 Mark McIntyre How Do You Fedora.md --- sources/tech/20171120 Mark McIntyre How Do You Fedora.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20171120 Mark McIntyre How Do You Fedora.md b/sources/tech/20171120 Mark McIntyre How Do You Fedora.md index e89527a377..4fe315eb07 100644 --- a/sources/tech/20171120 Mark McIntyre How Do You Fedora.md +++ b/sources/tech/20171120 Mark McIntyre How Do You Fedora.md @@ -3,7 +3,7 @@ ![](https://fedoramagazine.org/wp-content/uploads/2017/11/mock-couch-945w-945x400.jpg) -最近我们采访了 Mark McIntyre,谈来他是如何使用 Fedora 系统的。这也是 Fedora 杂志上[本系列的一部分][2]。该系列简要介绍了 Fedora 用户,以及他们是如何用 Fedora 把事情做好的。通过[反馈表][3]与我们联系,表达你想成为采访对象的意愿。 +最近我们采访了 Mark McIntyre,谈了他是如何使用 Fedora 系统的。这也是 Fedora 杂志上[本系列的一部分][2]。该系列简要介绍了 Fedora 用户,以及他们是如何用 Fedora 把事情做好的。通过[反馈表][3]与我们联系,表达你想成为采访对象的意愿。 ### Mark McIntyre 是谁? From 0422527c893f226ab6c0395f395104ab8a91e233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E8=8D=A3=E5=8D=87?= Date: Wed, 6 Dec 2017 11:24:30 +0800 Subject: [PATCH 295/344] 333 translated --- translated/tech/233 | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 translated/tech/233 diff --git a/translated/tech/233 b/translated/tech/233 new file mode 100644 index 0000000000..4fe315eb07 --- /dev/null +++ b/translated/tech/233 @@ -0,0 +1,74 @@ +# [Mark McIntyre: 你是如何使用Fedora的?][1] + + +![](https://fedoramagazine.org/wp-content/uploads/2017/11/mock-couch-945w-945x400.jpg) + +最近我们采访了 Mark McIntyre,谈了他是如何使用 Fedora 系统的。这也是 Fedora 杂志上[本系列的一部分][2]。该系列简要介绍了 Fedora 用户,以及他们是如何用 Fedora 把事情做好的。通过[反馈表][3]与我们联系,表达你想成为采访对象的意愿。 + +### Mark McIntyre 是谁? + +Mark McIntyre 是一个天生的极客,后天的 Linux 爱好者。他说:“我在 13 岁开始编程,当时自学 BASIC 语言,我体会到其中的乐趣,并在乐趣的引导下,一步步成为专业的码农。”Mark 和他的侄女都是披萨饼的死忠粉。“去年秋天,我和我的侄女尽可能多地光顾了诺克斯维尔的披萨饼连锁店。 点击 [https://knox-pizza-quest.blogspot.com/][4] 可以了解我们的进展情况。”Mark 也是一名业余的摄影爱好者,并且在 Flickr 上 [发布自己的作品][5]。 + +![](https://fedoramagazine.org/wp-content/uploads/2017/11/31456893222_553b3cac4d_k-1024x575.jpg) + +作为一名开发者,Mark 有着丰富的工作背景。他用过 Visual Basic 编写应用程序,用过 LotusScript、 PL/SQL(Oracle)、 Tcl/TK 编写代码,也用过基于 Python 的 Django 框架。他的强项是 Python。这也是目前他作为系统工程师的工作语言。“我用 Python 比较规律。但当我的工作变得更像是自动化工程师时, Python 用得就更频繁了。” + +McIntyre 自称是个书呆子,喜欢科幻电影,但他最喜欢的一部电影却不是科幻片。“尽管我是个书呆子,喜欢看《星际迷航》、《星球大战》之类的影片,但《光荣战役》或许才是我最喜欢的电影。”他还提到,电影《冲出宁静号》实属著名电视剧《萤火虫》的精彩后续。 + +Mark 比较看重他人的谦逊、知识与和气。他欣赏能够设身处地为他人着想的人。“如果你决定为另一个人服务,那么你会选择自己愿意亲近的人,而不是让自己备受折磨的人。” + +McIntyre 目前在 [Scripps Networks Interactive][6] 工作,这家公司是 HGTV、Food Network、Travel Channel、DIY、GAC 以及其他几个有线电视频道的母公司。“我现在是一名系统工程师,负责非线性视频内容,这是全部媒体开展线上消费的计划。”他支持一些开发团队编写应用程序,将线性视频从有线电视发布到线上平台,比如亚马逊、葫芦。这些系统既包含预置系统,也包含云系统。Mark 还开发了一些自动化工具,将这些应用程序主要部署到云基础结构中。 + +### Fedora 社区 + +Mark 形容 Fedora 社区是一个富有活力的社区,充满着像 Fedora 用户一样热爱生活的人。“从设计师到包装师,这个团体依然非常活跃,生机勃勃。” 他继续说道:“这使我对操作系统抱有一种信心。” + +2002年左右,Mark 开始经常使用 IRC 上的 #fedora 频道:“那时候,Wi-Fi 在启用适配器和配置模块功能时,有许多还是靠手工实现的。”为了让他的 Wi-Fi 能够工作,他不得不重新去编译 Fedora 内核。 + +McIntyre 鼓励他人参与 Fedora 社区。“这里有许多来自不同领域的机会。前端设计、测试部署、开发、应用程序包装以及新型技术实现。”他建议选择一个感兴趣的领域,然后向那个团体提出疑问。“这里有许多机会去奉献自己。” + +对于帮助他起步的社区成员,Mark 赞道:“Ben Williams 非常乐于助人。在我第一次接触 Fedora 时,他帮我搞定了一些 #fedora 支持频道中的安装补丁。” Ben 也鼓励 Mark 去做 Fedora [代表][7]。 + +### 什么样的硬件和软件? + +McIntyre 将 Fedora Linux 系统用在他的笔记本和台式机上。在服务器上他选择了 CentOS,因为它有更长的生命周期支持。他现在的台式机是自己组装的,配有 Intel 酷睿 i5 处理器,32GB 的内存和2TB 的硬盘。“我装了个 4K 的显示屏,有足够大的,地方来同时查看所有的应用。”他目前工作用的笔记本是戴尔灵越二合一,配备 13 英寸的屏,16 GB 的内存和 525 GB 的 m.2 固态硬盘。 + +![](https://fedoramagazine.org/wp-content/uploads/2017/11/Screenshot-from-2017-10-26-08-51-41-1024x640.png) + +Mark 现在将 Fedora 26 运行在他过去几个月装配的所有盒子中。当一个新版本正式发布的时候,他倾向于避开这个高峰期。“除非在它即将发行的时候,我的工作站中有个正在运行下一代测试版本,通常情况下,一旦它发展成熟,我都会试着去获取最新的版本。”他经常采取就地更新:“这种就地更新方法利用 dnf 系统升级插件,目前表现得非常好。” + +为了搞摄影,McIntyre 用上了 [GIMP][8]、[Darktable][9],以及其他一些照片查看包和快速编辑包。当不启用网络电子邮件时,Mark 会使用 [Geary][10],还有[GNOME Calendar][11]。Mark 选用 HexChat 作为 IRC 客户端,[HexChat][12] 与在 Fedora 服务器实例上运行的 [ZNC bouncer][13] 联机。他的部门通过 Slave 进行沟通交流。 + +“我从来都不是 IDE 粉,所以大多数的编辑任务都是在 [vim][14] 上完成的。”Mark 偶尔也会打开一个简单的文本编辑器,如 [gedit][15],或者 [xed][16]。他用 [GPaste][17] 做复制和粘贴工作。“对于终端的选择,我已经变成 [Tilix][18] 的忠粉。”McIntyre 通过 [Rhythmbox][19] 来管理他喜欢的播客,并用 [Epiphany][20] 实现快速网络查询。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/mark-mcintyre-fedora/ + +作者:[Charles Profitt][a] +译者:[zrszrs](https://github.com/zrszrszrs) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://fedoramagazine.org/author/cprofitt/ +[1]:https://fedoramagazine.org/mark-mcintyre-fedora/ +[2]:https://fedoramagazine.org/tag/how-do-you-fedora/ +[3]:https://fedoramagazine.org/submit-an-idea-or-tip/ +[4]:https://knox-pizza-quest.blogspot.com/ +[5]:https://www.flickr.com/photos/mockgeek/ +[6]:http://www.scrippsnetworksinteractive.com/ +[7]:https://fedoraproject.org/wiki/Ambassadors +[8]:https://www.gimp.org/ +[9]:http://www.darktable.org/ +[10]:https://wiki.gnome.org/Apps/Geary +[11]:https://wiki.gnome.org/Apps/Calendar +[12]:https://hexchat.github.io/ +[13]:https://wiki.znc.in/ZNC +[14]:http://www.vim.org/ +[15]:https://wiki.gnome.org/Apps/Gedit +[16]:https://github.com/linuxmint/xed +[17]:https://github.com/Keruspe/GPaste +[18]:https://fedoramagazine.org/try-tilix-new-terminal-emulator-fedora/ +[19]:https://wiki.gnome.org/Apps/Rhythmbox +[20]:https://wiki.gnome.org/Apps/Web From e37682381fa433386398d867ef7cb25ef9f32bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E8=8D=A3=E5=8D=87?= Date: Wed, 6 Dec 2017 11:25:16 +0800 Subject: [PATCH 296/344] Delete 233 --- translated/tech/233 | 74 --------------------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 translated/tech/233 diff --git a/translated/tech/233 b/translated/tech/233 deleted file mode 100644 index 4fe315eb07..0000000000 --- a/translated/tech/233 +++ /dev/null @@ -1,74 +0,0 @@ -# [Mark McIntyre: 你是如何使用Fedora的?][1] - - -![](https://fedoramagazine.org/wp-content/uploads/2017/11/mock-couch-945w-945x400.jpg) - -最近我们采访了 Mark McIntyre,谈了他是如何使用 Fedora 系统的。这也是 Fedora 杂志上[本系列的一部分][2]。该系列简要介绍了 Fedora 用户,以及他们是如何用 Fedora 把事情做好的。通过[反馈表][3]与我们联系,表达你想成为采访对象的意愿。 - -### Mark McIntyre 是谁? - -Mark McIntyre 是一个天生的极客,后天的 Linux 爱好者。他说:“我在 13 岁开始编程,当时自学 BASIC 语言,我体会到其中的乐趣,并在乐趣的引导下,一步步成为专业的码农。”Mark 和他的侄女都是披萨饼的死忠粉。“去年秋天,我和我的侄女尽可能多地光顾了诺克斯维尔的披萨饼连锁店。 点击 [https://knox-pizza-quest.blogspot.com/][4] 可以了解我们的进展情况。”Mark 也是一名业余的摄影爱好者,并且在 Flickr 上 [发布自己的作品][5]。 - -![](https://fedoramagazine.org/wp-content/uploads/2017/11/31456893222_553b3cac4d_k-1024x575.jpg) - -作为一名开发者,Mark 有着丰富的工作背景。他用过 Visual Basic 编写应用程序,用过 LotusScript、 PL/SQL(Oracle)、 Tcl/TK 编写代码,也用过基于 Python 的 Django 框架。他的强项是 Python。这也是目前他作为系统工程师的工作语言。“我用 Python 比较规律。但当我的工作变得更像是自动化工程师时, Python 用得就更频繁了。” - -McIntyre 自称是个书呆子,喜欢科幻电影,但他最喜欢的一部电影却不是科幻片。“尽管我是个书呆子,喜欢看《星际迷航》、《星球大战》之类的影片,但《光荣战役》或许才是我最喜欢的电影。”他还提到,电影《冲出宁静号》实属著名电视剧《萤火虫》的精彩后续。 - -Mark 比较看重他人的谦逊、知识与和气。他欣赏能够设身处地为他人着想的人。“如果你决定为另一个人服务,那么你会选择自己愿意亲近的人,而不是让自己备受折磨的人。” - -McIntyre 目前在 [Scripps Networks Interactive][6] 工作,这家公司是 HGTV、Food Network、Travel Channel、DIY、GAC 以及其他几个有线电视频道的母公司。“我现在是一名系统工程师,负责非线性视频内容,这是全部媒体开展线上消费的计划。”他支持一些开发团队编写应用程序,将线性视频从有线电视发布到线上平台,比如亚马逊、葫芦。这些系统既包含预置系统,也包含云系统。Mark 还开发了一些自动化工具,将这些应用程序主要部署到云基础结构中。 - -### Fedora 社区 - -Mark 形容 Fedora 社区是一个富有活力的社区,充满着像 Fedora 用户一样热爱生活的人。“从设计师到包装师,这个团体依然非常活跃,生机勃勃。” 他继续说道:“这使我对操作系统抱有一种信心。” - -2002年左右,Mark 开始经常使用 IRC 上的 #fedora 频道:“那时候,Wi-Fi 在启用适配器和配置模块功能时,有许多还是靠手工实现的。”为了让他的 Wi-Fi 能够工作,他不得不重新去编译 Fedora 内核。 - -McIntyre 鼓励他人参与 Fedora 社区。“这里有许多来自不同领域的机会。前端设计、测试部署、开发、应用程序包装以及新型技术实现。”他建议选择一个感兴趣的领域,然后向那个团体提出疑问。“这里有许多机会去奉献自己。” - -对于帮助他起步的社区成员,Mark 赞道:“Ben Williams 非常乐于助人。在我第一次接触 Fedora 时,他帮我搞定了一些 #fedora 支持频道中的安装补丁。” Ben 也鼓励 Mark 去做 Fedora [代表][7]。 - -### 什么样的硬件和软件? - -McIntyre 将 Fedora Linux 系统用在他的笔记本和台式机上。在服务器上他选择了 CentOS,因为它有更长的生命周期支持。他现在的台式机是自己组装的,配有 Intel 酷睿 i5 处理器,32GB 的内存和2TB 的硬盘。“我装了个 4K 的显示屏,有足够大的,地方来同时查看所有的应用。”他目前工作用的笔记本是戴尔灵越二合一,配备 13 英寸的屏,16 GB 的内存和 525 GB 的 m.2 固态硬盘。 - -![](https://fedoramagazine.org/wp-content/uploads/2017/11/Screenshot-from-2017-10-26-08-51-41-1024x640.png) - -Mark 现在将 Fedora 26 运行在他过去几个月装配的所有盒子中。当一个新版本正式发布的时候,他倾向于避开这个高峰期。“除非在它即将发行的时候,我的工作站中有个正在运行下一代测试版本,通常情况下,一旦它发展成熟,我都会试着去获取最新的版本。”他经常采取就地更新:“这种就地更新方法利用 dnf 系统升级插件,目前表现得非常好。” - -为了搞摄影,McIntyre 用上了 [GIMP][8]、[Darktable][9],以及其他一些照片查看包和快速编辑包。当不启用网络电子邮件时,Mark 会使用 [Geary][10],还有[GNOME Calendar][11]。Mark 选用 HexChat 作为 IRC 客户端,[HexChat][12] 与在 Fedora 服务器实例上运行的 [ZNC bouncer][13] 联机。他的部门通过 Slave 进行沟通交流。 - -“我从来都不是 IDE 粉,所以大多数的编辑任务都是在 [vim][14] 上完成的。”Mark 偶尔也会打开一个简单的文本编辑器,如 [gedit][15],或者 [xed][16]。他用 [GPaste][17] 做复制和粘贴工作。“对于终端的选择,我已经变成 [Tilix][18] 的忠粉。”McIntyre 通过 [Rhythmbox][19] 来管理他喜欢的播客,并用 [Epiphany][20] 实现快速网络查询。 - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/mark-mcintyre-fedora/ - -作者:[Charles Profitt][a] -译者:[zrszrs](https://github.com/zrszrszrs) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://fedoramagazine.org/author/cprofitt/ -[1]:https://fedoramagazine.org/mark-mcintyre-fedora/ -[2]:https://fedoramagazine.org/tag/how-do-you-fedora/ -[3]:https://fedoramagazine.org/submit-an-idea-or-tip/ -[4]:https://knox-pizza-quest.blogspot.com/ -[5]:https://www.flickr.com/photos/mockgeek/ -[6]:http://www.scrippsnetworksinteractive.com/ -[7]:https://fedoraproject.org/wiki/Ambassadors -[8]:https://www.gimp.org/ -[9]:http://www.darktable.org/ -[10]:https://wiki.gnome.org/Apps/Geary -[11]:https://wiki.gnome.org/Apps/Calendar -[12]:https://hexchat.github.io/ -[13]:https://wiki.znc.in/ZNC -[14]:http://www.vim.org/ -[15]:https://wiki.gnome.org/Apps/Gedit -[16]:https://github.com/linuxmint/xed -[17]:https://github.com/Keruspe/GPaste -[18]:https://fedoramagazine.org/try-tilix-new-terminal-emulator-fedora/ -[19]:https://wiki.gnome.org/Apps/Rhythmbox -[20]:https://wiki.gnome.org/Apps/Web From c36a27b4a041c378eef871c7875e504cbb965b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E8=8D=A3=E5=8D=87?= Date: Wed, 6 Dec 2017 11:25:47 +0800 Subject: [PATCH 297/344] Add files via upload --- ...0171120 Mark McIntyre How Do You Fedora.md | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 translated/tech/20171120 Mark McIntyre How Do You Fedora.md diff --git a/translated/tech/20171120 Mark McIntyre How Do You Fedora.md b/translated/tech/20171120 Mark McIntyre How Do You Fedora.md new file mode 100644 index 0000000000..4fe315eb07 --- /dev/null +++ b/translated/tech/20171120 Mark McIntyre How Do You Fedora.md @@ -0,0 +1,74 @@ +# [Mark McIntyre: 你是如何使用Fedora的?][1] + + +![](https://fedoramagazine.org/wp-content/uploads/2017/11/mock-couch-945w-945x400.jpg) + +最近我们采访了 Mark McIntyre,谈了他是如何使用 Fedora 系统的。这也是 Fedora 杂志上[本系列的一部分][2]。该系列简要介绍了 Fedora 用户,以及他们是如何用 Fedora 把事情做好的。通过[反馈表][3]与我们联系,表达你想成为采访对象的意愿。 + +### Mark McIntyre 是谁? + +Mark McIntyre 是一个天生的极客,后天的 Linux 爱好者。他说:“我在 13 岁开始编程,当时自学 BASIC 语言,我体会到其中的乐趣,并在乐趣的引导下,一步步成为专业的码农。”Mark 和他的侄女都是披萨饼的死忠粉。“去年秋天,我和我的侄女尽可能多地光顾了诺克斯维尔的披萨饼连锁店。 点击 [https://knox-pizza-quest.blogspot.com/][4] 可以了解我们的进展情况。”Mark 也是一名业余的摄影爱好者,并且在 Flickr 上 [发布自己的作品][5]。 + +![](https://fedoramagazine.org/wp-content/uploads/2017/11/31456893222_553b3cac4d_k-1024x575.jpg) + +作为一名开发者,Mark 有着丰富的工作背景。他用过 Visual Basic 编写应用程序,用过 LotusScript、 PL/SQL(Oracle)、 Tcl/TK 编写代码,也用过基于 Python 的 Django 框架。他的强项是 Python。这也是目前他作为系统工程师的工作语言。“我用 Python 比较规律。但当我的工作变得更像是自动化工程师时, Python 用得就更频繁了。” + +McIntyre 自称是个书呆子,喜欢科幻电影,但他最喜欢的一部电影却不是科幻片。“尽管我是个书呆子,喜欢看《星际迷航》、《星球大战》之类的影片,但《光荣战役》或许才是我最喜欢的电影。”他还提到,电影《冲出宁静号》实属著名电视剧《萤火虫》的精彩后续。 + +Mark 比较看重他人的谦逊、知识与和气。他欣赏能够设身处地为他人着想的人。“如果你决定为另一个人服务,那么你会选择自己愿意亲近的人,而不是让自己备受折磨的人。” + +McIntyre 目前在 [Scripps Networks Interactive][6] 工作,这家公司是 HGTV、Food Network、Travel Channel、DIY、GAC 以及其他几个有线电视频道的母公司。“我现在是一名系统工程师,负责非线性视频内容,这是全部媒体开展线上消费的计划。”他支持一些开发团队编写应用程序,将线性视频从有线电视发布到线上平台,比如亚马逊、葫芦。这些系统既包含预置系统,也包含云系统。Mark 还开发了一些自动化工具,将这些应用程序主要部署到云基础结构中。 + +### Fedora 社区 + +Mark 形容 Fedora 社区是一个富有活力的社区,充满着像 Fedora 用户一样热爱生活的人。“从设计师到包装师,这个团体依然非常活跃,生机勃勃。” 他继续说道:“这使我对操作系统抱有一种信心。” + +2002年左右,Mark 开始经常使用 IRC 上的 #fedora 频道:“那时候,Wi-Fi 在启用适配器和配置模块功能时,有许多还是靠手工实现的。”为了让他的 Wi-Fi 能够工作,他不得不重新去编译 Fedora 内核。 + +McIntyre 鼓励他人参与 Fedora 社区。“这里有许多来自不同领域的机会。前端设计、测试部署、开发、应用程序包装以及新型技术实现。”他建议选择一个感兴趣的领域,然后向那个团体提出疑问。“这里有许多机会去奉献自己。” + +对于帮助他起步的社区成员,Mark 赞道:“Ben Williams 非常乐于助人。在我第一次接触 Fedora 时,他帮我搞定了一些 #fedora 支持频道中的安装补丁。” Ben 也鼓励 Mark 去做 Fedora [代表][7]。 + +### 什么样的硬件和软件? + +McIntyre 将 Fedora Linux 系统用在他的笔记本和台式机上。在服务器上他选择了 CentOS,因为它有更长的生命周期支持。他现在的台式机是自己组装的,配有 Intel 酷睿 i5 处理器,32GB 的内存和2TB 的硬盘。“我装了个 4K 的显示屏,有足够大的,地方来同时查看所有的应用。”他目前工作用的笔记本是戴尔灵越二合一,配备 13 英寸的屏,16 GB 的内存和 525 GB 的 m.2 固态硬盘。 + +![](https://fedoramagazine.org/wp-content/uploads/2017/11/Screenshot-from-2017-10-26-08-51-41-1024x640.png) + +Mark 现在将 Fedora 26 运行在他过去几个月装配的所有盒子中。当一个新版本正式发布的时候,他倾向于避开这个高峰期。“除非在它即将发行的时候,我的工作站中有个正在运行下一代测试版本,通常情况下,一旦它发展成熟,我都会试着去获取最新的版本。”他经常采取就地更新:“这种就地更新方法利用 dnf 系统升级插件,目前表现得非常好。” + +为了搞摄影,McIntyre 用上了 [GIMP][8]、[Darktable][9],以及其他一些照片查看包和快速编辑包。当不启用网络电子邮件时,Mark 会使用 [Geary][10],还有[GNOME Calendar][11]。Mark 选用 HexChat 作为 IRC 客户端,[HexChat][12] 与在 Fedora 服务器实例上运行的 [ZNC bouncer][13] 联机。他的部门通过 Slave 进行沟通交流。 + +“我从来都不是 IDE 粉,所以大多数的编辑任务都是在 [vim][14] 上完成的。”Mark 偶尔也会打开一个简单的文本编辑器,如 [gedit][15],或者 [xed][16]。他用 [GPaste][17] 做复制和粘贴工作。“对于终端的选择,我已经变成 [Tilix][18] 的忠粉。”McIntyre 通过 [Rhythmbox][19] 来管理他喜欢的播客,并用 [Epiphany][20] 实现快速网络查询。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/mark-mcintyre-fedora/ + +作者:[Charles Profitt][a] +译者:[zrszrs](https://github.com/zrszrszrs) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://fedoramagazine.org/author/cprofitt/ +[1]:https://fedoramagazine.org/mark-mcintyre-fedora/ +[2]:https://fedoramagazine.org/tag/how-do-you-fedora/ +[3]:https://fedoramagazine.org/submit-an-idea-or-tip/ +[4]:https://knox-pizza-quest.blogspot.com/ +[5]:https://www.flickr.com/photos/mockgeek/ +[6]:http://www.scrippsnetworksinteractive.com/ +[7]:https://fedoraproject.org/wiki/Ambassadors +[8]:https://www.gimp.org/ +[9]:http://www.darktable.org/ +[10]:https://wiki.gnome.org/Apps/Geary +[11]:https://wiki.gnome.org/Apps/Calendar +[12]:https://hexchat.github.io/ +[13]:https://wiki.znc.in/ZNC +[14]:http://www.vim.org/ +[15]:https://wiki.gnome.org/Apps/Gedit +[16]:https://github.com/linuxmint/xed +[17]:https://github.com/Keruspe/GPaste +[18]:https://fedoramagazine.org/try-tilix-new-terminal-emulator-fedora/ +[19]:https://wiki.gnome.org/Apps/Rhythmbox +[20]:https://wiki.gnome.org/Apps/Web From 3214c62240e148a862536689968d2a4c36efddf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E8=8D=A3=E5=8D=87?= Date: Wed, 6 Dec 2017 11:27:39 +0800 Subject: [PATCH 298/344] Delete 20171120 Mark McIntyre How Do You Fedora.md --- ...0171120 Mark McIntyre How Do You Fedora.md | 74 ------------------- 1 file changed, 74 deletions(-) delete mode 100644 sources/tech/20171120 Mark McIntyre How Do You Fedora.md diff --git a/sources/tech/20171120 Mark McIntyre How Do You Fedora.md b/sources/tech/20171120 Mark McIntyre How Do You Fedora.md deleted file mode 100644 index 4fe315eb07..0000000000 --- a/sources/tech/20171120 Mark McIntyre How Do You Fedora.md +++ /dev/null @@ -1,74 +0,0 @@ -# [Mark McIntyre: 你是如何使用Fedora的?][1] - - -![](https://fedoramagazine.org/wp-content/uploads/2017/11/mock-couch-945w-945x400.jpg) - -最近我们采访了 Mark McIntyre,谈了他是如何使用 Fedora 系统的。这也是 Fedora 杂志上[本系列的一部分][2]。该系列简要介绍了 Fedora 用户,以及他们是如何用 Fedora 把事情做好的。通过[反馈表][3]与我们联系,表达你想成为采访对象的意愿。 - -### Mark McIntyre 是谁? - -Mark McIntyre 是一个天生的极客,后天的 Linux 爱好者。他说:“我在 13 岁开始编程,当时自学 BASIC 语言,我体会到其中的乐趣,并在乐趣的引导下,一步步成为专业的码农。”Mark 和他的侄女都是披萨饼的死忠粉。“去年秋天,我和我的侄女尽可能多地光顾了诺克斯维尔的披萨饼连锁店。 点击 [https://knox-pizza-quest.blogspot.com/][4] 可以了解我们的进展情况。”Mark 也是一名业余的摄影爱好者,并且在 Flickr 上 [发布自己的作品][5]。 - -![](https://fedoramagazine.org/wp-content/uploads/2017/11/31456893222_553b3cac4d_k-1024x575.jpg) - -作为一名开发者,Mark 有着丰富的工作背景。他用过 Visual Basic 编写应用程序,用过 LotusScript、 PL/SQL(Oracle)、 Tcl/TK 编写代码,也用过基于 Python 的 Django 框架。他的强项是 Python。这也是目前他作为系统工程师的工作语言。“我用 Python 比较规律。但当我的工作变得更像是自动化工程师时, Python 用得就更频繁了。” - -McIntyre 自称是个书呆子,喜欢科幻电影,但他最喜欢的一部电影却不是科幻片。“尽管我是个书呆子,喜欢看《星际迷航》、《星球大战》之类的影片,但《光荣战役》或许才是我最喜欢的电影。”他还提到,电影《冲出宁静号》实属著名电视剧《萤火虫》的精彩后续。 - -Mark 比较看重他人的谦逊、知识与和气。他欣赏能够设身处地为他人着想的人。“如果你决定为另一个人服务,那么你会选择自己愿意亲近的人,而不是让自己备受折磨的人。” - -McIntyre 目前在 [Scripps Networks Interactive][6] 工作,这家公司是 HGTV、Food Network、Travel Channel、DIY、GAC 以及其他几个有线电视频道的母公司。“我现在是一名系统工程师,负责非线性视频内容,这是全部媒体开展线上消费的计划。”他支持一些开发团队编写应用程序,将线性视频从有线电视发布到线上平台,比如亚马逊、葫芦。这些系统既包含预置系统,也包含云系统。Mark 还开发了一些自动化工具,将这些应用程序主要部署到云基础结构中。 - -### Fedora 社区 - -Mark 形容 Fedora 社区是一个富有活力的社区,充满着像 Fedora 用户一样热爱生活的人。“从设计师到包装师,这个团体依然非常活跃,生机勃勃。” 他继续说道:“这使我对操作系统抱有一种信心。” - -2002年左右,Mark 开始经常使用 IRC 上的 #fedora 频道:“那时候,Wi-Fi 在启用适配器和配置模块功能时,有许多还是靠手工实现的。”为了让他的 Wi-Fi 能够工作,他不得不重新去编译 Fedora 内核。 - -McIntyre 鼓励他人参与 Fedora 社区。“这里有许多来自不同领域的机会。前端设计、测试部署、开发、应用程序包装以及新型技术实现。”他建议选择一个感兴趣的领域,然后向那个团体提出疑问。“这里有许多机会去奉献自己。” - -对于帮助他起步的社区成员,Mark 赞道:“Ben Williams 非常乐于助人。在我第一次接触 Fedora 时,他帮我搞定了一些 #fedora 支持频道中的安装补丁。” Ben 也鼓励 Mark 去做 Fedora [代表][7]。 - -### 什么样的硬件和软件? - -McIntyre 将 Fedora Linux 系统用在他的笔记本和台式机上。在服务器上他选择了 CentOS,因为它有更长的生命周期支持。他现在的台式机是自己组装的,配有 Intel 酷睿 i5 处理器,32GB 的内存和2TB 的硬盘。“我装了个 4K 的显示屏,有足够大的,地方来同时查看所有的应用。”他目前工作用的笔记本是戴尔灵越二合一,配备 13 英寸的屏,16 GB 的内存和 525 GB 的 m.2 固态硬盘。 - -![](https://fedoramagazine.org/wp-content/uploads/2017/11/Screenshot-from-2017-10-26-08-51-41-1024x640.png) - -Mark 现在将 Fedora 26 运行在他过去几个月装配的所有盒子中。当一个新版本正式发布的时候,他倾向于避开这个高峰期。“除非在它即将发行的时候,我的工作站中有个正在运行下一代测试版本,通常情况下,一旦它发展成熟,我都会试着去获取最新的版本。”他经常采取就地更新:“这种就地更新方法利用 dnf 系统升级插件,目前表现得非常好。” - -为了搞摄影,McIntyre 用上了 [GIMP][8]、[Darktable][9],以及其他一些照片查看包和快速编辑包。当不启用网络电子邮件时,Mark 会使用 [Geary][10],还有[GNOME Calendar][11]。Mark 选用 HexChat 作为 IRC 客户端,[HexChat][12] 与在 Fedora 服务器实例上运行的 [ZNC bouncer][13] 联机。他的部门通过 Slave 进行沟通交流。 - -“我从来都不是 IDE 粉,所以大多数的编辑任务都是在 [vim][14] 上完成的。”Mark 偶尔也会打开一个简单的文本编辑器,如 [gedit][15],或者 [xed][16]。他用 [GPaste][17] 做复制和粘贴工作。“对于终端的选择,我已经变成 [Tilix][18] 的忠粉。”McIntyre 通过 [Rhythmbox][19] 来管理他喜欢的播客,并用 [Epiphany][20] 实现快速网络查询。 - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/mark-mcintyre-fedora/ - -作者:[Charles Profitt][a] -译者:[zrszrs](https://github.com/zrszrszrs) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://fedoramagazine.org/author/cprofitt/ -[1]:https://fedoramagazine.org/mark-mcintyre-fedora/ -[2]:https://fedoramagazine.org/tag/how-do-you-fedora/ -[3]:https://fedoramagazine.org/submit-an-idea-or-tip/ -[4]:https://knox-pizza-quest.blogspot.com/ -[5]:https://www.flickr.com/photos/mockgeek/ -[6]:http://www.scrippsnetworksinteractive.com/ -[7]:https://fedoraproject.org/wiki/Ambassadors -[8]:https://www.gimp.org/ -[9]:http://www.darktable.org/ -[10]:https://wiki.gnome.org/Apps/Geary -[11]:https://wiki.gnome.org/Apps/Calendar -[12]:https://hexchat.github.io/ -[13]:https://wiki.znc.in/ZNC -[14]:http://www.vim.org/ -[15]:https://wiki.gnome.org/Apps/Gedit -[16]:https://github.com/linuxmint/xed -[17]:https://github.com/Keruspe/GPaste -[18]:https://fedoramagazine.org/try-tilix-new-terminal-emulator-fedora/ -[19]:https://wiki.gnome.org/Apps/Rhythmbox -[20]:https://wiki.gnome.org/Apps/Web From 78162279e7912c78582a2f42a05e7f930836a139 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Wed, 6 Dec 2017 11:58:01 +0800 Subject: [PATCH 299/344] Translated by qhwdw --- ...Linux containers with Ansible Container.md | 114 ----------------- ...Linux containers with Ansible Container.md | 116 ++++++++++++++++++ 2 files changed, 116 insertions(+), 114 deletions(-) delete mode 100644 sources/tech/20171005 How to manage Linux containers with Ansible Container.md create mode 100644 translated/tech/20171005 How to manage Linux containers with Ansible Container.md diff --git a/sources/tech/20171005 How to manage Linux containers with Ansible Container.md b/sources/tech/20171005 How to manage Linux containers with Ansible Container.md deleted file mode 100644 index 0f200d73a8..0000000000 --- a/sources/tech/20171005 How to manage Linux containers with Ansible Container.md +++ /dev/null @@ -1,114 +0,0 @@ -Translating by qhwdw How to manage Linux containers with Ansible Container -============================================================ - -### Ansible Container addresses Dockerfile shortcomings and offers complete management for containerized projects. - -![Ansible Container: A new way to manage containers](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/container-ship.png?itok=pqZYgQ7K "Ansible Container: A new way to manage containers") -Image by : opensource.com - -I love containers and use the technology every day. Even so, containers aren't perfect. Over the past couple of months, however, a set of projects has emerged that addresses some of the problems I've experienced. - -I started using containers with [Docker][11], since this project made the technology so popular. Aside from using the container engine, I learned how to use **[docker-compose][6]** and started managing my projects with it. My productivity skyrocketed! One command to run my project, no matter how complex it was. I was so happy. - -After some time, I started noticing issues. The most apparent were related to the process of creating container images. The Docker tool uses a custom file format as a recipe to produce container images—Dockerfiles. This format is easy to learn, and after a short time you are ready to produce container images on your own. The problems arise once you want to master best practices or have complex scenarios in mind. - -More on Ansible - -* [How Ansible works][1] - -* [Free Ansible eBooks][2] - -* [Ansible quick start video][3] - -* [Download and install Ansible][4] - -Let's take a break and travel to a different land: the world of [Ansible][22]. You know it? It's awesome, right? You don't? Well, it's time to learn something new. Ansible is a project that allows you to manage your infrastructure by writing tasks and executing them inside environments of your choice. No need to install and set up any services; everything can easily run from your laptop. Many people already embrace Ansible. - -Imagine this scenario: You invested in Ansible, you wrote plenty of Ansible roles and playbooks that you use to manage your infrastructure, and you are thinking about investing in containers. What should you do? Start writing container image definitions via shell scripts and Dockerfiles? That doesn't sound right. - -Some people from the Ansible development team asked this question and realized that those same Ansible roles and playbooks that people wrote and use daily can also be used to produce container images. But not just that—they can be used to manage the complete lifecycle of containerized projects. From these ideas, the [Ansible Container][12] project was born. It utilizes existing Ansible roles that can be turned into container images and can even be used for the complete application lifecycle, from build to deploy in production. - -Let's talk about the problems I mentioned regarding best practices in context of Dockerfiles. A word of warning: This is going to be very specific and technical. Here are the top three issues I have: - -### 1\. Shell scripts embedded in Dockerfiles. - -When writing Dockerfiles, you can specify a script that will be interpreted via **/bin/sh -c**. It can be something like: - -``` -RUN dnf install -y nginx -``` - -where RUN is a Dockerfile instruction and the rest are its arguments (which are passed to shell). But imagine a more complex scenario: - -``` -RUN set -eux; \ -    \ -# this "case" statement is generated via "update.sh" -    %%ARCH-CASE%%; \ -    \ -    url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \ -    wget -O go.tgz "$url"; \ -    echo "${goRelSha256} *go.tgz" | sha256sum -c -; \ -``` - -This one is taken from [the official golang image][13]. It doesn't look pretty, right? - -### 2\. You can't parse Dockerfiles easily. - -Dockerfiles are a new format without a formal specification. This is tricky if you need to process Dockerfiles in your infrastructure (e.g., automate the build process a bit). The only specification is [the code][14] that is part of **dockerd**. The problem is that you can't use it as a library. The easiest solution is to write a parser on your own and hope for the best. Wouldn't it be better to use some well-known markup language, such as YAML or JSON? - -### 3\. It's hard to control. - -If you are familiar with the internals of container images, you may know that every image is composed of layers. Once the container is created, the layers are stacked onto each other (like pancakes) using union filesystem technology. The problem is, that you cannot explicitly control this layering—you can't say, "here starts a new layer." You are forced to change your Dockerfile in a way that may hurt readability. The bigger problem is that a set of best practices has to be followed to achieve optimal results—newcomers have a really hard time here. - -### Comparing Ansible language and Dockerfiles - -The biggest shortcoming of Dockerfiles in comparison to Ansible is that Ansible, as a language, is much more powerful. For example, Dockerfiles have no direct concept of variables, whereas Ansible has a complete templating system (variables are just one of its features). Ansible contains a large number of modules that can be easily utilized, such as [**wait_for**][15], which can be used for service readiness checks—e.g., wait until a service is ready before proceeding. With Dockerfiles, everything is a shell script. So if you need to figure out service readiness, it has to be done with shell (or installed separately). The other problem with shell scripts is that, with growing complexity, maintenance becomes a burden. Plenty of people have already figured this out and turned those shell scripts into Ansible. - -If you are interested in this topic and would like to know more, please come to [Open Source Summit][16] in Prague to see [my presentation][17] on Monday, Oct. 23, at 4:20 p.m. in Palmovka room. - - _Learn more in Tomas Tomecek's talk, [From Dockerfiles to Ansible Container][7], at [Open Source Summit EU][8], which will be held October 23-26 in Prague._ - - - -### About the author - - [![human](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/ja.jpeg?itok=4ATUEAbd)][18] Tomas Tomecek - Engineer. Hacker. Speaker. Tinker. Red Hatter. Likes containers, linux, open source, python 3, rust, zsh, tmux.[More about me][9] - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/10/dockerfiles-ansible-container - -作者:[Tomas Tomecek ][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/tomastomecek -[1]:https://www.ansible.com/how-ansible-works?intcmp=701f2000000h4RcAAI -[2]:https://www.ansible.com/ebooks?intcmp=701f2000000h4RcAAI -[3]:https://www.ansible.com/quick-start-video?intcmp=701f2000000h4RcAAI -[4]:https://docs.ansible.com/ansible/latest/intro_installation.html?intcmp=701f2000000h4RcAAI -[5]:https://opensource.com/article/17/10/dockerfiles-ansible-container?imm_mid=0f9013&cmp=em-webops-na-na-newsltr_20171201&rate=Wiw_0D6PK_CAjqatYu_YQH0t1sNHEF6q09_9u3sYkCY -[6]:https://github.com/docker/compose -[7]:http://sched.co/BxIW -[8]:http://events.linuxfoundation.org/events/open-source-summit-europe -[9]:https://opensource.com/users/tomastomecek -[10]:https://opensource.com/user/175651/feed -[11]:https://opensource.com/tags/docker -[12]:https://www.ansible.com/ansible-container -[13]:https://github.com/docker-library/golang/blob/master/Dockerfile-debian.template#L14 -[14]:https://github.com/moby/moby/tree/master/builder/dockerfile -[15]:http://docs.ansible.com/wait_for_module.html -[16]:http://events.linuxfoundation.org/events/open-source-summit-europe -[17]:http://events.linuxfoundation.org/events/open-source-summit-europe/program/schedule -[18]:https://opensource.com/users/tomastomecek -[19]:https://opensource.com/users/tomastomecek -[20]:https://opensource.com/users/tomastomecek -[21]:https://opensource.com/article/17/10/dockerfiles-ansible-container?imm_mid=0f9013&cmp=em-webops-na-na-newsltr_20171201#comments -[22]:https://opensource.com/tags/ansible -[23]:https://opensource.com/tags/containers -[24]:https://opensource.com/tags/ansible -[25]:https://opensource.com/tags/docker -[26]:https://opensource.com/tags/open-source-summit diff --git a/translated/tech/20171005 How to manage Linux containers with Ansible Container.md b/translated/tech/20171005 How to manage Linux containers with Ansible Container.md new file mode 100644 index 0000000000..624d25694a --- /dev/null +++ b/translated/tech/20171005 How to manage Linux containers with Ansible Container.md @@ -0,0 +1,116 @@ +怎么去使用 Ansible Container 去管理 Linux 容器 +============================================================ + +### Ansible Container 处理 Dockerfile 的不足和对容器化项目提供完整的管理。 + +![Ansible Container: A new way to manage containers](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/container-ship.png?itok=pqZYgQ7K "Ansible Container: A new way to manage containers") +Image by : opensource.com + +我喜欢容器,并且每天都使用这个技术。在过去几个月,在一组项目中已经解决了我遇到的问题,即便如此,容器并不完美。 + +我刚开始时,用 [Docker][11] 使用容器,因为这个项目使这个技术非常流行。除此之外,使用这个容器引擎,我学到了怎么去使用 **[docker-compose][6]** 以及怎么去用它管理我的项目。使用它使我的生产力猛增!一个命令去运行我的项目,而不管它有多复杂。因此,我太高兴了。 + +使用一段时间之后,我发现了一些问题。最明显的问题是创建窗口镜像的过程。Docker 工具使用一个定制的文件格式作为一个 Recipe 去制作容器镜像 — Dockerfiles。这个格式很容易学会,并且很短的一段时间之后,你就可以为你自己制作容器镜像了。但是,一旦你希望去掌握最佳实践或者有复杂场景的想法,问题就会出现。 + +Ansible 的更多资源 + +* [Ansible 是怎么工作的][1] + +* [免费的 Ansible 电子书][2] + +* [Ansible 快速上手视频][3] + +* [下载和安装 Ansible][4] + +让我们先休息一会儿,先去了解一个不同的东西:[Ansible][22] 的世界。你知道它吗?它棒极了,是吗?你不这么认为?好吧,是时候去学习一些新事物了。Ansible 是一个项目,它允许你通过写一些任务去管理你的基础设施,并在你选择的环境中运行它们。不需要去安装和设置任何的服务;你可以从你的笔记本电脑中去很很容易地做任何事情。许多人已经接受 Ansible 了。 + +想像一下这样的场景:你在 Ansible 中,你写了很多的 Ansible 角色和 playbooks,你可以用它们去管理你的基础设施,并且想把它们运用到容器中。你应该怎么做?开始通过 shell 脚本和 Dockerfiles 去写容器镜像定义?听起来好像不对。 + +来自 Ansible 开发团队的一些人问到这个问题,并且它们意识到,人们每天使用那些同样的 Ansible 角色和 playbooks 也可以用来制作容器镜像。但是 Ansible 能做到的不止这些 — 它可以被用于去管理容器化项目的完整的生命周期。从这些想法中,[Ansible Container][12] 项目诞生了。它使用已有的可以变成容器镜像的 Ansible 角色,甚至可以被用于应用程序在生产系统中从构建到部署的完整生命周期。 + +现在让我们讨论一下,在 Dockerfiles 环境中关于最佳实践时可能存在的问题。这里有一个警告:这将是非常具体且技术性的。出现最多的三个问题有: + +### 1\. 在 Dockerfiles 中内嵌的 Shell 脚本。 + +当写 Dockerfiles 时,你可以通过 **/bin/sh -c** 解释指定的脚本。它可以做类似这样的事情: + +``` +RUN dnf install -y nginx +``` + +RUN 处是一个 Dockerfile 指令并且其它的都是参数(它传递给 shell)。但是,想像一个更复杂的场景: + +``` +RUN set -eux; \ +    \ +# this "case" statement is generated via "update.sh" +    %%ARCH-CASE%%; \ +    \ +    url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \ +    wget -O go.tgz "$url"; \ +    echo "${goRelSha256} *go.tgz" | sha256sum -c -; \ +``` + +这仅是从 [the official golang image][13] 中拿来的一个。它看起来并不好看,是不是? + +### 2\. 你解析 Dockerfiles 并不容易。 + +Dockerfiles 是一个没有正式规范的新格式。如果你需要在你的基础设施(比如,让构建过程自动化一点)中去处理 Dockerfiles 将会很复杂。仅有的规划是 [这个代码][14],它是 **dockerd** 的一部分。问题是你不能使用它作为一个库(library)。最容易的解决方案是你自己写一个解析器,然后祈祷它运行的很好。使用一些众所周知的标记语言不是更好吗?比如,YAML 或者 JSON。 + +### 3\. 管理困难。 + +如果你熟悉容器镜像的内部结构,你可能知道每个镜像是由层(layers)构成的。一旦容器被创建,这些层就使用联合文件系统技术堆叠在一起(像煎饼一样)。问题是,你并不能显式地管理这些层 — 你不能说,“这儿开始一个新层”,你被迫使用一种可读性不好的方法去改变你的 Dockerfile。最大的问题是,必须遵循一套最佳实践以去达到最优结果 — 新来的人在这个地方可能很困难。 + +### Ansible 语言和 Dockerfiles 比较 + +相比 Ansible,Dockerfiles 的最大缺点,也是 Ansible 的优点,作为一个语言,Ansible 更强大。例如,Dockerfiles 没有直接的变量概念,而 Ansible 有一个完整的模板系统(变量只是它其中的一个特性)。Ansible 包含了很多更易于使用的模块,比如,[**wait_for**][15],它可以被用于服务就绪检查,比如,在处理之前等待服务准备就绪。在 Dockerfiles 中,做任何事情都通过一个 shell 脚本。因此,如果你想去找出已准备好的服务,它必须使用 shell(或者独立安装)去做。使用 shell 脚本的其它问题是,它会变得很复杂,维护成为一种负担。很多人已经找到了这个问题,并将这些 shell 脚本转到 Ansible。 + +如果你对这个主题感兴趣,并且想去了解更多内容,请访问 [Open Source Summit][16],在 Prague 去看 [我的演讲][17],时间是 10 月 23 日,星期一,4:20 p.m. 在 Palmovka room 中。 + + _看更多的 Tomas Tomecek 演讲,[从 Dockerfiles 到 Ansible Container][7],在 [Open Source Summit EU][8],它将在 10 月 23-26 日在 Prague 召开。_ + + + +### 关于作者 + + [![human](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/ja.jpeg?itok=4ATUEAbd)][18] Tomas Tomecek - 工程师、Hacker、演讲者、Tinker、Red Hatter。喜欢容器、linux、开源软件、python 3、rust、zsh、tmux。[More about me][9] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/10/dockerfiles-ansible-container + +作者:[Tomas Tomecek][a] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/tomastomecek +[1]:https://www.ansible.com/how-ansible-works?intcmp=701f2000000h4RcAAI +[2]:https://www.ansible.com/ebooks?intcmp=701f2000000h4RcAAI +[3]:https://www.ansible.com/quick-start-video?intcmp=701f2000000h4RcAAI +[4]:https://docs.ansible.com/ansible/latest/intro_installation.html?intcmp=701f2000000h4RcAAI +[5]:https://opensource.com/article/17/10/dockerfiles-ansible-container?imm_mid=0f9013&cmp=em-webops-na-na-newsltr_20171201&rate=Wiw_0D6PK_CAjqatYu_YQH0t1sNHEF6q09_9u3sYkCY +[6]:https://github.com/docker/compose +[7]:http://sched.co/BxIW +[8]:http://events.linuxfoundation.org/events/open-source-summit-europe +[9]:https://opensource.com/users/tomastomecek +[10]:https://opensource.com/user/175651/feed +[11]:https://opensource.com/tags/docker +[12]:https://www.ansible.com/ansible-container +[13]:https://github.com/docker-library/golang/blob/master/Dockerfile-debian.template#L14 +[14]:https://github.com/moby/moby/tree/master/builder/dockerfile +[15]:http://docs.ansible.com/wait_for_module.html +[16]:http://events.linuxfoundation.org/events/open-source-summit-europe +[17]:http://events.linuxfoundation.org/events/open-source-summit-europe/program/schedule +[18]:https://opensource.com/users/tomastomecek +[19]:https://opensource.com/users/tomastomecek +[20]:https://opensource.com/users/tomastomecek +[21]:https://opensource.com/article/17/10/dockerfiles-ansible-container?imm_mid=0f9013&cmp=em-webops-na-na-newsltr_20171201#comments +[22]:https://opensource.com/tags/ansible +[23]:https://opensource.com/tags/containers +[24]:https://opensource.com/tags/ansible +[25]:https://opensource.com/tags/docker +[26]:https://opensource.com/tags/open-source-summit + + From f2f1ab9ebebe43b2044f89025b5929f246db693b Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 6 Dec 2017 15:32:23 +0800 Subject: [PATCH 300/344] PRF:20171128 How To Tell If Your Linux Server Has Been Compromised.md @lujun9972 --- ... Your Linux Server Has Been Compromised.md | 108 ++++++++---------- 1 file changed, 47 insertions(+), 61 deletions(-) diff --git a/translated/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md b/translated/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md index 29fe95d868..3ce5f449e3 100644 --- a/translated/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md +++ b/translated/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md @@ -1,49 +1,48 @@ -如何判断Linux服务器是否被入侵 --------------- +如何判断 Linux 服务器是否被入侵? +========================= -本指南中所谓的服务器被入侵或者说被黑了的意思是指未经认证的人或程序为了自己的目的登录到服务器上去并使用其计算资源, 通常会产生不好的影响。 +本指南中所谓的服务器被入侵或者说被黑了的意思,是指未经授权的人或程序为了自己的目的登录到服务器上去并使用其计算资源,通常会产生不好的影响。 -免责声明: 若你的服务器被类似NSA这样的国家机关或者某个犯罪集团如请,那么你并不会发现有任何问题,这些技术也无法发觉他们的存在。 +免责声明:若你的服务器被类似 NSA 这样的国家机关或者某个犯罪集团入侵,那么你并不会注意到有任何问题,这些技术也无法发觉他们的存在。 -然而, 大多数被攻破的服务器都是被类似自动攻击程序这样的程序或者类似“脚本小子”这样的廉价攻击者,以及蠢蛋犯罪所入侵的。 +然而,大多数被攻破的服务器都是被类似自动攻击程序这样的程序或者类似“脚本小子”这样的廉价攻击者,以及蠢蛋罪犯所入侵的。 这类攻击者会在访问服务器的同时滥用服务器资源,并且不怎么会采取措施来隐藏他们正在做的事情。 -### 入侵服务器的症状 +### 被入侵服务器的症状 -当服务器被没有经验攻击者或者自动攻击程序入侵了的话,他们往往会消耗100%的资源. 他们可能消耗CPU资源来进行数字货币的采矿或者发送垃圾邮件,也可能消耗带宽来发动 `DoS` 攻击。 +当服务器被没有经验攻击者或者自动攻击程序入侵了的话,他们往往会消耗 100% 的资源。他们可能消耗 CPU 资源来进行数字货币的采矿或者发送垃圾邮件,也可能消耗带宽来发动 DoS 攻击。 -因此出现问题的第一个表现就是服务器 “变慢了”. 这可能表现在网站的页面打开的很慢, 或者电子邮件要花很长时间才能发送出去。 +因此出现问题的第一个表现就是服务器 “变慢了”。这可能表现在网站的页面打开的很慢,或者电子邮件要花很长时间才能发送出去。 那么你应该查看那些东西呢? #### 检查 1 - 当前都有谁在登录? -你首先要查看当前都有谁登录在服务器上. 发现攻击者登录到服务器上进行操作并不罕见。 +你首先要查看当前都有谁登录在服务器上。发现攻击者登录到服务器上进行操作并不复杂。 -其对应的命令是 `w`. 运行 `w` 会输出如下结果: +其对应的命令是 `w`。运行 `w` 会输出如下结果: ``` 08:32:55 up 98 days, 5:43, 2 users, load average: 0.05, 0.03, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 113.174.161.1 08:26 0.00s 0.03s 0.02s ssh root@coopeaa12 root pts/1 78.31.109.1 08:26 0.00s 0.01s 0.00s w - ``` -第一个IP是英国IP,而第二个IP是越南IP. 这个不是个好兆头。 +第一个 IP 是英国 IP,而第二个 IP 是越南 IP。这个不是个好兆头。 -停下来做个深呼吸, 不要紧,只需要杀掉他们的SSH连接就好了. Unless you can stop then re-entering the server they will do so quickly and quite likely kick you off and stop you getting back in。 +停下来做个深呼吸, 不要恐慌之下只是干掉他们的 SSH 连接。除非你能够防止他们再次进入服务器,否则他们会很快进来并踢掉你,以防你再次回去。 -请参阅本文最后的 `入侵之后怎么办` 这一章节来看发现被入侵的证据后应该怎么办。 +请参阅本文最后的“被入侵之后怎么办”这一章节来看找到了被入侵的证据后应该怎么办。 -`whois` 命令可以接一个IP地址然后告诉你IP注册的组织的所有信息, 当然就包括所在国家的信息。 +`whois` 命令可以接一个 IP 地址然后告诉你该 IP 所注册的组织的所有信息,当然就包括所在国家的信息。 #### 检查 2 - 谁曾经登录过? -Linux 服务器会记录下哪些用户,从哪个IP,在什么时候登录的以及登陆了多长时间这些信息. 使用 `last` 命令可以查看这些信息。 +Linux 服务器会记录下哪些用户,从哪个 IP,在什么时候登录的以及登录了多长时间这些信息。使用 `last` 命令可以查看这些信息。 -输出类似这样: +输出类似这样: ``` root pts/1 78.31.109.1 Thu Nov 30 08:26 still logged in @@ -51,104 +50,91 @@ root pts/0 113.174.161.1 Thu Nov 30 08:26 still logged in root pts/1 78.31.109.1 Thu Nov 30 08:24 - 08:26 (00:01) root pts/0 113.174.161.1 Wed Nov 29 12:34 - 12:52 (00:18) root pts/0 14.176.196.1 Mon Nov 27 13:32 - 13:53 (00:21) - ``` -这里可以看到英国IP和越南IP交替出现, 而且最上面两个IP现在还处于登录状态. 如果你看到任何未经授权的IP,那么请参阅最后章节。 +这里可以看到英国 IP 和越南 IP 交替出现,而且最上面两个 IP 现在还处于登录状态。如果你看到任何未经授权的 IP,那么请参阅最后章节。 -登录历史记录会以文本格式记录到 `~/.bash_history`(注:这里作者应该写错了)中,因此很容易被删除。 -通常攻击者会直接把这个文件删掉,以掩盖他们的攻击行为. 因此, 若你运行了 `last` 命令却只看得见你的当前登录,那么这就是个不妙的信号。 +登录后的历史记录会记录到二进制的 `/var/log/wtmp` 文件中(LCTT 译注:这里作者应该写错了,根据实际情况修改),因此很容易被删除。通常攻击者会直接把这个文件删掉,以掩盖他们的攻击行为。 因此, 若你运行了 `last` 命令却只看得见你的当前登录,那么这就是个不妙的信号。 如果没有登录历史的话,请一定小心,继续留意入侵的其他线索。 #### 检查 3 - 回顾命令历史 -这个层次的攻击者通常不会注意掩盖命令的历史记录,因此运行 `history` 命令会显示出他们曾经做过的所有事情。 -一定留意有没有用 `wget` 或 `curl` 命令来下载类似垃圾邮件机器人或者挖矿程序之类的软件。 +这个层次的攻击者通常不会注意掩盖命令的历史记录,因此运行 `history` 命令会显示出他们曾经做过的所有事情。 +一定留意有没有用 `wget` 或 `curl` 命令来下载类似垃圾邮件机器人或者挖矿程序之类的非常规软件。 -命令历史存储在 `~/.bash_history` 文件中,因此有些攻击者会删除该文件以掩盖他们的所作所为。 -跟登录历史一样, 若你运行 `history` 命令却没有输出任何东西那就表示历史文件被删掉了. 这也是个不妙的信号,你需要很小心地检查一下服务器了。 +命令历史存储在 `~/.bash_history` 文件中,因此有些攻击者会删除该文件以掩盖他们的所作所为。跟登录历史一样,若你运行 `history` 命令却没有输出任何东西那就表示历史文件被删掉了。这也是个不妙的信号,你需要很小心地检查一下服务器了。(LCTT 译注,如果没有命令历史,也有可能是你的配置错误。) -#### 检查 4 - 哪些进程在消耗CPU? +#### 检查 4 - 哪些进程在消耗 CPU? -你常遇到的这类攻击者通常不怎么会去掩盖他们做的事情. 他们会运行一些特别消耗CPU的进程. 这就很容易发着这些进程了. 只需要运行 `top` 然后看最前的那几个进程就行了。 +你常遇到的这类攻击者通常不怎么会去掩盖他们做的事情。他们会运行一些特别消耗 CPU 的进程。这就很容易发现这些进程了。只需要运行 `top` 然后看最前的那几个进程就行了。 -这也能显示出那些未登录的攻击者来. 比如,可能有人在用未受保护的邮件脚本来发送垃圾邮件。 +这也能显示出那些未登录进来的攻击者。比如,可能有人在用未受保护的邮件脚本来发送垃圾邮件。 -如果你最上面的进程对不了解,那么你可以google一下进程名称,或者通过 `losf` 和 `strace` 来看看它做的事情是什么。 +如果你最上面的进程对不了解,那么你可以 Google 一下进程名称,或者通过 `losf` 和 `strace` 来看看它做的事情是什么。 -使用这些工具,第一步从 `top` 中拷贝出进程的 PID,然后运行: - -```shell -strace -p PID +使用这些工具,第一步从 `top` 中拷贝出进程的 PID,然后运行: +``` +strace -p PID ``` -这会显示出进程调用的所有系统调用. 它产生的内容会很多,但这些信息能告诉你这个进程在做什么。 +这会显示出该进程调用的所有系统调用。它产生的内容会很多,但这些信息能告诉你这个进程在做什么。 ``` lsof -p PID - ``` -这个程序会列出进程打开的文件. 通过查看它访问的文件可以很好的理解它在做的事情。 +这个程序会列出该进程打开的文件。通过查看它访问的文件可以很好的理解它在做的事情。 #### 检查 5 - 检查所有的系统进程 -消耗CPU不严重的未认证进程可能不会在 `top` 中显露出来,不过它依然可以通过 `ps` 列出来. 命令 `ps auxf` 就能显示足够清晰的信息了。 +消耗 CPU 不严重的未授权进程可能不会在 `top` 中显露出来,不过它依然可以通过 `ps` 列出来。命令 `ps auxf` 就能显示足够清晰的信息了。 -你需要检查一下每个不认识的进程. 经常运行 `ps` (这是个好习惯) 能帮助你发现奇怪的进程。 +你需要检查一下每个不认识的进程。经常运行 `ps` (这是个好习惯)能帮助你发现奇怪的进程。 #### 检查 6 - 检查进程的网络使用情况 -`iftop` 的功能类似 `top`,他会显示一系列收发网络数据的进程以及他们的源地址和目的地址。 -类似 `DoS` 攻击或垃圾制造器这样的进程很容易显示在列表的最顶端。 +`iftop` 的功能类似 `top`,它会排列显示收发网络数据的进程以及它们的源地址和目的地址。类似 DoS 攻击或垃圾机器人这样的进程很容易显示在列表的最顶端。 #### 检查 7 - 哪些进程在监听网络连接? -通常攻击者会安装一个后门程序专门监听网络端口接受指令. 该进程等待期间是不会消耗CPU和带宽的,因此也就不容易通过 `top` 之类的命令发现。 +通常攻击者会安装一个后门程序专门监听网络端口接受指令。该进程等待期间是不会消耗 CPU 和带宽的,因此也就不容易通过 `top` 之类的命令发现。 -`lsof` 和 `netstat` 命令都会列出所有的联网进程. 我通常会让他们带上下面这些参数: +`lsof` 和 `netstat` 命令都会列出所有的联网进程。我通常会让它们带上下面这些参数: ``` lsof -i - ``` ``` netstat -plunt - ``` -你需要留意那些处于 `LISTEN` 和 `ESTABLISHED` 状态的进程,这些进程要么正在等待连接(LISTEN),要么已经连接(ESTABLISHED)。 -如果遇到不认识的进程,使用 `strace` 和 `lsof` 来看看它们在做什么东西。 +你需要留意那些处于 `LISTEN` 和 `ESTABLISHED` 状态的进程,这些进程要么正在等待连接(LISTEN),要么已经连接(ESTABLISHED)。如果遇到不认识的进程,使用 `strace` 和 `lsof` 来看看它们在做什么东西。 ### 被入侵之后该怎么办呢? -首先,不要紧张, 尤其当攻击者正处于登陆状态时更不能紧张. 你需要在攻击者警觉到你已经发现他之前夺回机器的控制权。 -如果他发现你已经发觉到他了,那么他可能会锁死你不让你登陆服务器,然后开始毁尸灭迹。 +首先,不要紧张,尤其当攻击者正处于登录状态时更不能紧张。**你需要在攻击者警觉到你已经发现他之前夺回机器的控制权。**如果他发现你已经发觉到他了,那么他可能会锁死你不让你登陆服务器,然后开始毁尸灭迹。 -如果你技术不太好那么就直接关机吧. 你可以在服务器上运行 `shutdown -h now` 或者 `systemctl poweroff` 这两条命令. 也可以登陆主机提供商的控制面板中关闭服务器。 -关机后,你就可以开始配置防火墙或者咨询一下供应商的意见。 +如果你技术不太好那么就直接关机吧。你可以在服务器上运行 `shutdown -h now` 或者 `systemctl poweroff` 这两条命令之一。也可以登录主机提供商的控制面板中关闭服务器。关机后,你就可以开始配置防火墙或者咨询一下供应商的意见。 -如果你对自己颇有自信,而你的主机提供商也有提供上游防火墙,那么你只需要以此创建并启用下面两条规则就行了: +如果你对自己颇有自信,而你的主机提供商也有提供上游防火墙,那么你只需要以此创建并启用下面两条规则就行了: -1. 只允许从你的IP地址登陆SSH +1. 只允许从你的 IP 地址登录 SSH。 +2. 封禁除此之外的任何东西,不仅仅是 SSH,还包括任何端口上的任何协议。 -2. 封禁除此之外的任何东西,不仅仅是SSH,还包括任何端口上的任何协议。 +这样会立即关闭攻击者的 SSH 会话,而只留下你可以访问服务器。 -这样会立即关闭攻击者的SSH会话,而只留下你访问服务器。 +如果你无法访问上游防火墙,那么你就需要在服务器本身创建并启用这些防火墙策略,然后在防火墙规则起效后使用 `kill` 命令关闭攻击者的 SSH 会话。(LCTT 译注:本地防火墙规则 有可能不会阻止已经建立的 SSH 会话,所以保险起见,你需要手工杀死该会话。) -如果你无法访问上游防火墙,那么你就需要在服务器本身创建并启用这些防火墙策略,然后在防火墙规则起效后使用 `kill` 命令关闭攻击者的ssh会话。 - -最后还有一种方法, 就是通过诸如串行控制台之类的带外连接登陆服务器,然后通过 `systemctl stop network.service` 停止网络功能。 -这会关闭所有服务器上的网络连接,这样你就可以慢慢的配置那些防火墙规则了。 +最后还有一种方法,如果支持的话,就是通过诸如串行控制台之类的带外连接登录服务器,然后通过 `systemctl stop network.service` 停止网络功能。这会关闭所有服务器上的网络连接,这样你就可以慢慢的配置那些防火墙规则了。 重夺服务器的控制权后,也不要以为就万事大吉了。 -不要试着修复这台服务器,让后接着用. 你永远不知道攻击者做过什么因此你也永远无法保证这台服务器还是安全的。 +不要试着修复这台服务器,然后接着用。你永远不知道攻击者做过什么,因此你也永远无法保证这台服务器还是安全的。 -最好的方法就是拷贝出所有的资料,然后重装系统。 +最好的方法就是拷贝出所有的数据,然后重装系统。(LCTT 译注:你的程序这时已经不可信了,但是数据一般来说没问题。) -------------------------------------------------------------------------------- @@ -156,7 +142,7 @@ via: https://bash-prompt.net/guides/server-hacked/ 作者:[Elliot Cooper][a] 译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 1244a3c6b4497768bc21ded74d948d82ea3ad0b8 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 6 Dec 2017 15:32:44 +0800 Subject: [PATCH 301/344] PUB:20171128 How To Tell If Your Linux Server Has Been Compromised.md @lujun9972 https://linux.cn/article-9116-1.html --- ...71128 How To Tell If Your Linux Server Has Been Compromised.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171128 How To Tell If Your Linux Server Has Been Compromised.md (100%) diff --git a/translated/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md b/published/20171128 How To Tell If Your Linux Server Has Been Compromised.md similarity index 100% rename from translated/tech/20171128 How To Tell If Your Linux Server Has Been Compromised.md rename to published/20171128 How To Tell If Your Linux Server Has Been Compromised.md From b8190d86deb4bb182bc3a11a23d2465d94c7b70e Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 6 Dec 2017 16:22:31 +0800 Subject: [PATCH 302/344] PRF:20171006 Concurrent Servers Part 3 - Event-driven.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @GitFuture 很辛苦, 这么长,这么专业的文章。 --- ...oncurrent Servers Part 3 - Event-driven.md | 105 ++++++++---------- 1 file changed, 44 insertions(+), 61 deletions(-) diff --git a/translated/tech/20171006 Concurrent Servers Part 3 - Event-driven.md b/translated/tech/20171006 Concurrent Servers Part 3 - Event-driven.md index 01c1d74112..1c0a0a329f 100644 --- a/translated/tech/20171006 Concurrent Servers Part 3 - Event-driven.md +++ b/translated/tech/20171006 Concurrent Servers Part 3 - Event-driven.md @@ -1,9 +1,9 @@ -并发服务器(3) —— 事件驱动 +并发服务器(三):事件驱动 ============================================================ -这是《并发服务器》系列的第三节。[第一节][26] 介绍了阻塞式编程,[第二节 —— 线程][27] 探讨了多线程,将其作为一种可行的方法来实现服务器并发编程。 +这是并发服务器系列的第三节。[第一节][26] 介绍了阻塞式编程,[第二节:线程][27] 探讨了多线程,将其作为一种可行的方法来实现服务器并发编程。 -另一种常见的实现并发的方法叫做 _事件驱动编程_,也可以叫做 _异步_ 编程 [^注1][28]。这种方法变化万千,因此我们会从最基本的开始,使用一些基本的 APIs 而非从封装好的高级方法开始。本系列以后的文章会讲高层次抽象,还有各种混合的方法。 +另一种常见的实现并发的方法叫做 _事件驱动编程_,也可以叫做 _异步_ 编程 ^注1 。这种方法变化万千,因此我们会从最基本的开始,使用一些基本的 API 而非从封装好的高级方法开始。本系列以后的文章会讲高层次抽象,还有各种混合的方法。 本系列的所有文章: @@ -13,13 +13,13 @@ ### 阻塞式 vs. 非阻塞式 I/O -要介绍这个标题,我们先讲讲阻塞和非阻塞 I/O 的区别。阻塞式 I/O 更好理解,因为这是我们使用 I/O 相关 API 时的“标准”方式。从套接字接收数据的时候,调用 `recv` 函数会发生 _阻塞_,直到它从端口上接收到了来自另一端套接字的数据。这恰恰是第一部分讲到的顺序服务器的问题。 +作为本篇的介绍,我们先讲讲阻塞和非阻塞 I/O 的区别。阻塞式 I/O 更好理解,因为这是我们使用 I/O 相关 API 时的“标准”方式。从套接字接收数据的时候,调用 `recv` 函数会发生 _阻塞_,直到它从端口上接收到了来自另一端套接字的数据。这恰恰是第一部分讲到的顺序服务器的问题。 因此阻塞式 I/O 存在着固有的性能问题。第二节里我们讲过一种解决方法,就是用多线程。哪怕一个线程的 I/O 阻塞了,别的线程仍然可以使用 CPU 资源。实际上,阻塞 I/O 通常在利用资源方面非常高效,因为线程就等待着 —— 操作系统将线程变成休眠状态,只有满足了线程需要的条件才会被唤醒。 -_非阻塞式_ I/O 是另一种思路。把套接字设成非阻塞模式时,调用 `recv` 时(还有 `send`,但是我们现在只考虑接收),函数返回地会很快,哪怕没有数据要接收。这时,就会返回一个特殊的错误状态 ^[注2][15] 来通知调用者,此时没有数据传进来。调用者可以去做其他的事情,或者尝试再次调用 `recv` 函数。 +_非阻塞式_ I/O 是另一种思路。把套接字设成非阻塞模式时,调用 `recv` 时(还有 `send`,但是我们现在只考虑接收),函数返回的会很快,哪怕没有接收到数据。这时,就会返回一个特殊的错误状态 ^注2 来通知调用者,此时没有数据传进来。调用者可以去做其他的事情,或者尝试再次调用 `recv` 函数。 -证明阻塞式和非阻塞式的 `recv` 区别的最好方式就是贴一段示例代码。这里有个监听套接字的小程序,一直在 `recv` 这里阻塞着;当 `recv` 返回了数据,程序就报告接收到了多少个字节 ^[注3][16]: +示范阻塞式和非阻塞式的 `recv` 区别的最好方式就是贴一段示例代码。这里有个监听套接字的小程序,一直在 `recv` 这里阻塞着;当 `recv` 返回了数据,程序就报告接收到了多少个字节 ^注3 : ``` int main(int argc, const char** argv) { @@ -69,8 +69,7 @@ hello # wait for 2 seconds after typing this socket world ^D # to end the connection> ``` - -The listening program will print the following: + 监听程序会输出以下内容: ``` @@ -144,7 +143,6 @@ int main(int argc, const char** argv) { 这里与阻塞版本有些差异,值得注意: 1. `accept` 函数返回的 `newsocktfd` 套接字因调用了 `fcntl`, 被设置成非阻塞的模式。 - 2. 检查 `recv` 的返回状态时,我们对 `errno` 进行了检查,判断它是否被设置成表示没有可供接收的数据的状态。这时,我们仅仅是休眠了 200 毫秒然后进入到下一轮循环。 同样用 `nc` 进行测试,以下是非阻塞监听器的输出: @@ -183,19 +181,19 @@ Peer disconnected; I'm done. 作为练习,给输出添加一个时间戳,确认调用 `recv` 得到结果之间花费的时间是比输入到 `nc` 中所用的多还是少(每一轮是 200 ms)。 -这里就实现了使用非阻塞的 `recv` 让监听者检查套接字变为可能,并且在没有数据的时候重新获得控制权。换句话说,这就是 _polling(轮询)_ —— 主程序周期性的查询套接字以便读取数据。 +这里就实现了使用非阻塞的 `recv` 让监听者检查套接字变为可能,并且在没有数据的时候重新获得控制权。换句话说,用编程的语言说这就是 轮询polling —— 主程序周期性的查询套接字以便读取数据。 对于顺序响应的问题,这似乎是个可行的方法。非阻塞的 `recv` 让同时与多个套接字通信变成可能,轮询这些套接字,仅当有新数据到来时才处理。就是这样,这种方式 _可以_ 用来写并发服务器;但实际上一般不这么做,因为轮询的方式很难扩展。 -首先,我在代码中引入的 200 ms 延迟对于记录非常好(监听器在我输入 `nc` 之间只打印几行 “Calling recv...”,但实际上应该有上千行)。但它也增加了多达 200 ms 的服务器响应时间,这几乎是意料不到的。实际的程序中,延迟会低得多,休眠时间越短,进程占用的 CPU 资源就越多。有些时钟周期只是浪费在等待,这并不好,尤其是在移动设备上,这些设备的电量往往有限。 +首先,我在代码中引入的 200ms 延迟对于演示非常好(监听器在我输入 `nc` 之间只打印几行 “Calling recv...”,但实际上应该有上千行)。但它也增加了多达 200ms 的服务器响应时间,这无意是不必要的。实际的程序中,延迟会低得多,休眠时间越短,进程占用的 CPU 资源就越多。有些时钟周期只是浪费在等待,这并不好,尤其是在移动设备上,这些设备的电量往往有限。 -但是当我们实际这样来使用多个套接字的时候,更严重的问题出现了。想像下监听器正在同时处理 1000 个 客户端。这意味着每一个循环迭代里面,它都得为 _这 1000 个套接字中的每一个_ 执行一遍非阻塞的 `recv`,找到其中准备好了数据的那一个。这非常低效,并且极大的限制了服务器能够并发处理的客户端数。这里有个准则:每次轮询之间等待的间隔越久,服务器响应性越差;而等待的时间越少,CPU 在无用的轮询上耗费的资源越多。 +但是当我们实际这样来使用多个套接字的时候,更严重的问题出现了。想像下监听器正在同时处理 1000 个客户端。这意味着每一个循环迭代里面,它都得为 _这 1000 个套接字中的每一个_ 执行一遍非阻塞的 `recv`,找到其中准备好了数据的那一个。这非常低效,并且极大的限制了服务器能够并发处理的客户端数。这里有个准则:每次轮询之间等待的间隔越久,服务器响应性越差;而等待的时间越少,CPU 在无用的轮询上耗费的资源越多。 -讲真,所有的轮询都像是无用功。当然操作系统应该是知道哪个套接字是准备好了数据的,因此没必要逐个扫描。事实上,就是这样,接下来就会讲一些API,让我们可以更优雅地处理多个客户端。 +讲真,所有的轮询都像是无用功。当然操作系统应该是知道哪个套接字是准备好了数据的,因此没必要逐个扫描。事实上,就是这样,接下来就会讲一些 API,让我们可以更优雅地处理多个客户端。 ### select -`select` 的系统调用是轻便的(POSIX),标准 Unix API 中常有的部分。它是为上一节最后一部分描述的问题而设计的 —— 允许一个线程可以监视许多文件描述符 ^[注4][17] 的变化,不用在轮询中执行不必要的代码。我并不打算在这里引入一个关于 `select` 的理解性的教程,有很多网站和书籍讲这个,但是在涉及到问题的相关内容时,我会介绍一下它的 API,然后再展示一个非常复杂的例子。 +`select` 的系统调用是可移植的(POSIX),是标准 Unix API 中常有的部分。它是为上一节最后一部分描述的问题而设计的 —— 允许一个线程可以监视许多文件描述符 ^注4 的变化,而不用在轮询中执行不必要的代码。我并不打算在这里引入一个关于 `select` 的全面教程,有很多网站和书籍讲这个,但是在涉及到问题的相关内容时,我会介绍一下它的 API,然后再展示一个非常复杂的例子。 `select` 允许 _多路 I/O_,监视多个文件描述符,查看其中任何一个的 I/O 是否可用。 @@ -209,30 +207,25 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, `select` 的调用过程如下: 1. 在调用之前,用户先要为所有不同种类的要监视的文件描述符创建 `fd_set` 实例。如果想要同时监视读取和写入事件,`readfds` 和 `writefds` 都要被创建并且引用。 - 2. 用户可以使用 `FD_SET` 来设置集合中想要监视的特殊描述符。例如,如果想要监视描述符 2、7 和 10 的读取事件,在 `readfds` 这里调用三次 `FD_SET`,分别设置 2、7 和 10。 - 3. `select` 被调用。 - 4. 当 `select` 返回时(现在先不管超时),就是说集合中有多少个文件描述符已经就绪了。它也修改 `readfds` 和 `writefds` 集合,来标记这些准备好的描述符。其它所有的描述符都会被清空。 - 5. 这时用户需要遍历 `readfds` 和 `writefds`,找到哪个描述符就绪了(使用 `FD_ISSET`)。 -作为完整的例子,我在并发的服务器程序上使用 `select`,重新实现了我们之前的协议。[完整的代码在这里][18];接下来的是代码中的高亮,还有注释。警告:示例代码非常复杂,因此第一次看的时候,如果没有足够的时间,快速浏览也没有关系。 +作为完整的例子,我在并发的服务器程序上使用 `select`,重新实现了我们之前的协议。[完整的代码在这里][18];接下来的是代码中的重点部分及注释。警告:示例代码非常复杂,因此第一次看的时候,如果没有足够的时间,快速浏览也没有关系。 ### 使用 select 的并发服务器 使用 I/O 的多发 API 诸如 `select` 会给我们服务器的设计带来一些限制;这不会马上显现出来,但这值得探讨,因为它们是理解事件驱动编程到底是什么的关键。 -最重要的是,要记住这种方法本质上是单线程的 ^[注5][19]。服务器实际上在 _同一时刻只能做一件事_。因为我们想要同时处理多个客户端请求,我们需要换一种方式重构代码。 +最重要的是,要记住这种方法本质上是单线程的 ^注5 。服务器实际上在 _同一时刻只能做一件事_。因为我们想要同时处理多个客户端请求,我们需要换一种方式重构代码。 首先,让我们谈谈主循环。它看起来是什么样的呢?先让我们想象一下服务器有一堆任务,它应该监视哪些东西呢?两种类型的套接字活动: 1. 新客户端尝试连接。这些客户端应该被 `accept`。 - 2. 已连接的客户端发送数据。这个数据要用 [第一节][11] 中所讲到的协议进行传输,有可能会有一些数据要被回送给客户端。 -尽管这两种活动在本质上有所区别,我们还是要把他们放在一个循环里,因为只能有一个主循环。循环会包含 `select` 的调用。这个 `select` 的调用会监视上述的两种活动。 +尽管这两种活动在本质上有所区别,我们还是要把它们放在一个循环里,因为只能有一个主循环。循环会包含 `select` 的调用。这个 `select` 的调用会监视上述的两种活动。 这里是部分代码,设置了文件描述符集合,并在主循环里转到被调用的 `select` 部分。 @@ -264,9 +257,7 @@ while (1) { 这里的一些要点: 1. 由于每次调用 `select` 都会重写传递给函数的集合,调用器就得维护一个 “master” 集合,在循环迭代中,保持对所监视的所有活跃的套接字的追踪。 - 2. 注意我们所关心的,最开始的唯一那个套接字是怎么变成 `listener_sockfd` 的,这就是最开始的套接字,服务器借此来接收新客户端的连接。 - 3. `select` 的返回值,是在作为参数传递的集合中,那些已经就绪的描述符的个数。`select` 修改这个集合,用来标记就绪的描述符。下一步是在这些描述符中进行迭代。 ``` @@ -298,7 +289,7 @@ for (int fd = 0; fd <= fdset_max && nready > 0; fd++) { } ``` -这部分循环检查 _可读的_ 描述符。让我们跳过监听器套接字(要浏览所有内容,[看这个代码][20]) 然后看看当其中一个客户端准备好了之后会发生什么。出现了这种情况后,我们调用一个叫做 `on_peer_ready_recv` 的 _回调_ 函数,传入相应的文件描述符。这个调用意味着客户端连接到套接字上,发送某些数据,并且对套接字上 `recv` 的调用不会被阻塞 ^[注6][21]。这个回调函数返回结构体 `fd_status_t`。 +这部分循环检查 _可读的_ 描述符。让我们跳过监听器套接字(要浏览所有内容,[看这个代码][20]) 然后看看当其中一个客户端准备好了之后会发生什么。出现了这种情况后,我们调用一个叫做 `on_peer_ready_recv` 的 _回调_ 函数,传入相应的文件描述符。这个调用意味着客户端连接到套接字上,发送某些数据,并且对套接字上 `recv` 的调用不会被阻塞 ^注6 。这个回调函数返回结构体 `fd_status_t`。 ``` typedef struct { @@ -307,7 +298,7 @@ typedef struct { } fd_status_t; ``` -这个结构体告诉主循环,是否应该监视套接字的读取事件,写入事件,或者两者都监视。上述代码展示了 `FD_SET` 和 `FD_CLR` 是怎么在合适的描述符集合中被调用的。对于主循环中某个准备好了写入数据的描述符,代码是类似的,除了它所调用的回调函数,这个回调函数叫做 `on_peer_ready_send`。 +这个结构体告诉主循环,是否应该监视套接字的读取事件、写入事件,或者两者都监视。上述代码展示了 `FD_SET` 和 `FD_CLR` 是怎么在合适的描述符集合中被调用的。对于主循环中某个准备好了写入数据的描述符,代码是类似的,除了它所调用的回调函数,这个回调函数叫做 `on_peer_ready_send`。 现在来花点时间看看这个回调: @@ -464,37 +455,36 @@ INFO:2017-09-26 05:29:18,070:conn0 disconnecting INFO:2017-09-26 05:29:18,070:conn2 disconnecting ``` -和线程的情况相似,客户端之间没有延迟,他们被同时处理。而且在 `select-server` 也没有用线程!主循环 _多路_ 处理所有的客户端,通过高效使用 `select` 轮询多个套接字。回想下 [第二节中][22] 顺序的 vs 多线程的客户端处理过程的图片。对于我们的 `select-server`,三个客户端的处理流程像这样: +和线程的情况相似,客户端之间没有延迟,它们被同时处理。而且在 `select-server` 也没有用线程!主循环 _多路_ 处理所有的客户端,通过高效使用 `select` 轮询多个套接字。回想下 [第二节中][22] 顺序的 vs 多线程的客户端处理过程的图片。对于我们的 `select-server`,三个客户端的处理流程像这样: ![多客户端处理流程](https://eli.thegreenplace.net/images/2017/multiplexed-flow.png) 所有的客户端在同一个线程中同时被处理,通过乘积,做一点这个客户端的任务,然后切换到另一个,再切换到下一个,最后切换回到最开始的那个客户端。注意,这里没有什么循环调度,客户端在它们发送数据的时候被客户端处理,这实际上是受客户端左右的。 -### 同步,异步,事件驱动,回调 +### 同步、异步、事件驱动、回调 -`select-server` 示例代码为讨论什么是异步编程,它和事件驱动及基于回调的编程有何联系,提供了一个良好的背景。因为这些词汇在并发服务器的(非常矛盾的)讨论中很常见。 +`select-server` 示例代码为讨论什么是异步编程、它和事件驱动及基于回调的编程有何联系,提供了一个良好的背景。因为这些词汇在并发服务器的(非常矛盾的)讨论中很常见。 -让我们从一段 `select` 的手册页面中引用的一句好开始: +让我们从一段 `select` 的手册页面中引用的一句话开始: -> select,pselect,FD_CLR,FD_ISSET,FD_SET,FD_ZERO - 同步 I/O 处理 +> select,pselect,FD\_CLR,FD\_ISSET,FD\_SET,FD\_ZERO - 同步 I/O 处理 因此 `select` 是 _同步_ 处理。但我刚刚演示了大量代码的例子,使用 `select` 作为 _异步_ 处理服务器的例子。有哪些东西? -答案是:这取决于你的观查角度。同步常用作阻塞处理,并且对 `select` 的调用实际上是阻塞的。和第 1、2 节中讲到的顺序的、多线程的服务器中对 `send` 和 `recv` 是一样的。因此说 `select` 是 _同步的_ API 是有道理的。可是,服务器的设计却可以是 _异步的_,或是 _基于回调的_,或是 _事件驱动的_,尽管其中有对 `select` 的使用。注意这里的 `on_peer_*` 函数是回调函数;它们永远不会阻塞,并且只有网络事件触发的时候才会被调用。它们可以获得部分数据,并能够在调用过程中保持稳定的状态。 +答案是:这取决于你的观察角度。同步常用作阻塞处理,并且对 `select` 的调用实际上是阻塞的。和第 1、2 节中讲到的顺序的、多线程的服务器中对 `send` 和 `recv` 是一样的。因此说 `select` 是 _同步的_ API 是有道理的。可是,服务器的设计却可以是 _异步的_,或是 _基于回调的_,或是 _事件驱动的_,尽管其中有对 `select` 的使用。注意这里的 `on_peer_*` 函数是回调函数;它们永远不会阻塞,并且只有网络事件触发的时候才会被调用。它们可以获得部分数据,并能够在调用过程中保持稳定的状态。 -如果你曾经做过一些 GUI 编程,这些东西对你来说应该很亲切。有个 “事件循环”,常常完全隐藏在框架里,应用的 “业务逻辑” 建立在回调上,这些回调会在各种事件触发后被调用,用户点击鼠标,选择菜单,定时器到时间,数据到达套接字,等等。曾经最常见的编程模型是客户端的 JavaScript,这里面有一堆回调函数,它们在浏览网页时用户的行为被触发。 +如果你曾经做过一些 GUI 编程,这些东西对你来说应该很亲切。有个 “事件循环”,常常完全隐藏在框架里,应用的 “业务逻辑” 建立在回调上,这些回调会在各种事件触发后被调用,用户点击鼠标、选择菜单、定时器触发、数据到达套接字等等。曾经最常见的编程模型是客户端的 JavaScript,这里面有一堆回调函数,它们在浏览网页时用户的行为被触发。 ### select 的局限 -使用 `select` 作为第一个异步服务器的例子对于说明这个概念很有用,而且由于 `select` 是很常见,可移植的 API。但是它也有一些严重的缺陷,在监视的文件描述符非常大的时候就会出现。 +使用 `select` 作为第一个异步服务器的例子对于说明这个概念很有用,而且由于 `select` 是很常见、可移植的 API。但是它也有一些严重的缺陷,在监视的文件描述符非常大的时候就会出现。 1. 有限的文件描述符的集合大小。 - 2. 糟糕的性能。 -从文件描述符的大小开始。`FD_SETSIZE` 是一个编译期常数,在如今的操作系统中,它的值通常是 1024。它被硬编码在 `glibc` 的头文件里,并且不容易修改。它把 `select` 能够监视的文件描述符的数量限制在 1024 以内。曾有些分支想要写出能够处理上万个并发访问的客户端请求的服务器,这个问题很有现实意义。有一些方法,但是不可移植,也很难用。 +从文件描述符的大小开始。`FD_SETSIZE` 是一个编译期常数,在如今的操作系统中,它的值通常是 1024。它被硬编码在 `glibc` 的头文件里,并且不容易修改。它把 `select` 能够监视的文件描述符的数量限制在 1024 以内。曾有些人想要写出能够处理上万个并发访问的客户端请求的服务器,所以这个问题很有现实意义。有一些方法,但是不可移植,也很难用。 -糟糕的性能问题就好解决的多,但是依然非常严重。注意当 `select` 返回的时候,它向调用者提供的信息是 “就绪的” 描述符的个数,还有被修改过的描述符集合。描述符集映射着描述符 就绪/未就绪”,但是并没有提供什么有效的方法去遍历所有就绪的描述符。如果只有一个描述符是就绪的,最坏的情况是调用者需要遍历 _整个集合_ 来找到那个描述符。这在监视的描述符数量比较少的时候还行,但是如果数量变的很大的时候,这种方法弊端就凸显出了 ^[注7][23]。 +糟糕的性能问题就好解决的多,但是依然非常严重。注意当 `select` 返回的时候,它向调用者提供的信息是 “就绪的” 描述符的个数,还有被修改过的描述符集合。描述符集映射着描述符“就绪/未就绪”,但是并没有提供什么有效的方法去遍历所有就绪的描述符。如果只有一个描述符是就绪的,最坏的情况是调用者需要遍历 _整个集合_ 来找到那个描述符。这在监视的描述符数量比较少的时候还行,但是如果数量变的很大的时候,这种方法弊端就凸显出了 ^注7 。 由于这些原因,为了写出高性能的并发服务器, `select` 已经不怎么用了。每一个流行的操作系统有独特的不可移植的 API,允许用户写出非常高效的事件循环;像框架这样的高级结构还有高级语言通常在一个可移植的接口中包含这些 API。 @@ -541,30 +531,23 @@ while (1) { } ``` -通过调用 `epoll_ctl` 来配置 `epoll`。这时,配置监听的套接字数量,也就是 `epoll` 监听的描述符的数量。然后分配一个缓冲区,把就绪的事件传给 `epoll` 以供修改。在主循环里对 `epoll_wait` 的调用是魅力所在。它阻塞着,直到某个描述符就绪了(或者超时),返回就绪的描述符数量。但这时,不少盲目地迭代所有监视的集合,我们知道 `epoll_write` 会修改传给它的 `events` 缓冲区,缓冲区中有就绪的事件,从 0 到 `nready-1`,因此我们只需迭代必要的次数。 +通过调用 `epoll_ctl` 来配置 `epoll`。这时,配置监听的套接字数量,也就是 `epoll` 监听的描述符的数量。然后分配一个缓冲区,把就绪的事件传给 `epoll` 以供修改。在主循环里对 `epoll_wait` 的调用是魅力所在。它阻塞着,直到某个描述符就绪了(或者超时),返回就绪的描述符数量。但这时,不要盲目地迭代所有监视的集合,我们知道 `epoll_write` 会修改传给它的 `events` 缓冲区,缓冲区中有就绪的事件,从 0 到 `nready-1`,因此我们只需迭代必要的次数。 要在 `select` 里面重新遍历,有明显的差异:如果在监视着 1000 个描述符,只有两个就绪, `epoll_waits` 返回的是 `nready=2`,然后修改 `events` 缓冲区最前面的两个元素,因此我们只需要“遍历”两个描述符。用 `select` 我们就需要遍历 1000 个描述符,找出哪个是就绪的。因此,在繁忙的服务器上,有许多活跃的套接字时 `epoll` 比 `select` 更加容易扩展。 -剩下的代码很直观,因为我们已经很熟悉 `select 服务器` 了。实际上,`epoll 服务器` 中的所有“业务逻辑”和 `select 服务器` 是一样的,回调构成相同的代码。 +剩下的代码很直观,因为我们已经很熟悉 “select 服务器” 了。实际上,“epoll 服务器” 中的所有“业务逻辑”和 “select 服务器” 是一样的,回调构成相同的代码。 -这种相似是通过将事件循环抽象分离到一个库/框架中。我将会详述这些内容,因为很多优秀的程序员曾经也是这样做的。相反,下一篇文章里我们会了解 `libuv`,一个最近出现的更加受欢迎的时间循环抽象层。像 `libuv` 这样的库让我们能够写出并发的异步服务器,并且不用考虑系统调用下繁琐的细节。 +这种相似是通过将事件循环抽象分离到一个库/框架中。我将会详述这些内容,因为很多优秀的程序员曾经也是这样做的。相反,下一篇文章里我们会了解 libuv,一个最近出现的更加受欢迎的时间循环抽象层。像 libuv 这样的库让我们能够写出并发的异步服务器,并且不用考虑系统调用下繁琐的细节。 * * * - -[注1][1] 我试着在两件事的实际差别中突显自己,一件是做一些网络浏览和阅读,但经常做得头疼。有很多不同的选项,从“他们是一样的东西”到“一个是另一个的子集”,再到“他们是完全不同的东西”。在面临这样主观的观点时,最好是完全放弃这个问题,专注特殊的例子和用例。 - -[注2][2] POSIX 表示这可以是 `EAGAIN`,也可以是 `EWOULDBLOCK`,可移植应用应该对这两个都进行检查。 - -[注3][3] 和这个系列所有的 C 示例类似,代码中用到了某些助手工具来设置监听套接字。这些工具的完整代码在这个 [仓库][4] 的 `utils` 模块里。 - -[注4][5] `select` 不是网络/套接字专用的函数,它可以监视任意的文件描述符,有可能是硬盘文件,管道,终端,套接字或者 Unix 系统中用到的任何文件描述符。这篇文章里,我们主要关注它在套接字方面的应用。 - -[注5][6] 有多种方式用多线程来实现事件驱动,我会把它放在稍后的文章中进行讨论。 - -[注6][7] 由于各种非实验因素,它 _仍然_ 可以阻塞,即使是在 `select` 说它就绪了之后。因此服务器上打开的所有套接字都被设置成非阻塞模式,如果对 `recv` 或 `send` 的调用返回了 `EAGAIN` 或者 `EWOULDBLOCK`,回调函数就装作没有事件发生。阅读示例代码的注释可以了解更多细节。 - -[注7][8] 注意这比该文章前面所讲的异步 polling 例子要稍好一点。polling 需要 _一直_ 发生,而 `select` 实际上会阻塞到有一个或多个套接字准备好读取/写入;`select` 会比一直询问浪费少得多的 CPU 时间。 +- 注1:我试着在做网络浏览和阅读这两件事的实际差别中突显自己,但经常做得头疼。有很多不同的选项,从“它们是一样的东西”到“一个是另一个的子集”,再到“它们是完全不同的东西”。在面临这样主观的观点时,最好是完全放弃这个问题,专注特殊的例子和用例。 +- 注2:POSIX 表示这可以是 `EAGAIN`,也可以是 `EWOULDBLOCK`,可移植应用应该对这两个都进行检查。 +- 注3:和这个系列所有的 C 示例类似,代码中用到了某些助手工具来设置监听套接字。这些工具的完整代码在这个 [仓库][4] 的 `utils` 模块里。 +- 注4:`select` 不是网络/套接字专用的函数,它可以监视任意的文件描述符,有可能是硬盘文件、管道、终端、套接字或者 Unix 系统中用到的任何文件描述符。这篇文章里,我们主要关注它在套接字方面的应用。 +- 注5:有多种方式用多线程来实现事件驱动,我会把它放在稍后的文章中进行讨论。 +- 注6:由于各种非实验因素,它 _仍然_ 可以阻塞,即使是在 `select` 说它就绪了之后。因此服务器上打开的所有套接字都被设置成非阻塞模式,如果对 `recv` 或 `send` 的调用返回了 `EAGAIN` 或者 `EWOULDBLOCK`,回调函数就装作没有事件发生。阅读示例代码的注释可以了解更多细节。 +- 注7:注意这比该文章前面所讲的异步轮询的例子要稍好一点。轮询需要 _一直_ 发生,而 `select` 实际上会阻塞到有一个或多个套接字准备好读取/写入;`select` 会比一直询问浪费少得多的 CPU 时间。 -------------------------------------------------------------------------------- @@ -572,7 +555,7 @@ via: https://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ 作者:[Eli Bendersky][a] 译者:[GitFuture](https://github.com/GitFuture) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -587,9 +570,9 @@ via: https://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ [8]:https://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/#id9 [9]:https://eli.thegreenplace.net/tag/concurrency [10]:https://eli.thegreenplace.net/tag/c-c -[11]:http://eli.thegreenplace.net/2017/concurrent-servers-part-1-introduction/ -[12]:http://eli.thegreenplace.net/2017/concurrent-servers-part-1-introduction/ -[13]:http://eli.thegreenplace.net/2017/concurrent-servers-part-2-threads/ +[11]:https://linux.cn/article-8993-1.html +[12]:https://linux.cn/article-8993-1.html +[13]:https://linux.cn/article-9002-1.html [14]:http://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ [15]:https://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/#id11 [16]:https://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/#id12 @@ -598,10 +581,10 @@ via: https://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ [19]:https://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/#id14 [20]:https://github.com/eliben/code-for-blog/blob/master/2017/async-socket-server/select-server.c [21]:https://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/#id15 -[22]:http://eli.thegreenplace.net/2017/concurrent-servers-part-2-threads/ +[22]:https://linux.cn/article-9002-1.html [23]:https://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/#id16 [24]:https://github.com/eliben/code-for-blog/blob/master/2017/async-socket-server/epoll-server.c [25]:https://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/ -[26]:http://eli.thegreenplace.net/2017/concurrent-servers-part-1-introduction/ -[27]:http://eli.thegreenplace.net/2017/concurrent-servers-part-2-threads/ +[26]:https://linux.cn/article-8993-1.html +[27]:https://linux.cn/article-9002-1.html [28]:https://eli.thegreenplace.net/2017/concurrent-servers-part-3-event-driven/#id10 From 2b113411066140b6e613b7755741010bfd7ff31f Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 6 Dec 2017 16:23:03 +0800 Subject: [PATCH 303/344] PUB:20171006 Concurrent Servers Part 3 - Event-driven.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @GitFuture 定时发布于周五 https://linux.cn/article-9117-1.html --- .../20171006 Concurrent Servers Part 3 - Event-driven.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171006 Concurrent Servers Part 3 - Event-driven.md (100%) diff --git a/translated/tech/20171006 Concurrent Servers Part 3 - Event-driven.md b/published/20171006 Concurrent Servers Part 3 - Event-driven.md similarity index 100% rename from translated/tech/20171006 Concurrent Servers Part 3 - Event-driven.md rename to published/20171006 Concurrent Servers Part 3 - Event-driven.md From 11b7923d41f1afeec677b6fe4d24ea1245107777 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 6 Dec 2017 17:20:20 +0800 Subject: [PATCH 304/344] =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=B8=8D=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E7=9A=84=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...with a specific text using Linux shell .md | 180 ++++-------------- 1 file changed, 34 insertions(+), 146 deletions(-) diff --git a/sources/tech/20171130 How to find all files with a specific text using Linux shell .md b/sources/tech/20171130 How to find all files with a specific text using Linux shell .md index f5909c27c9..d518dd48db 100644 --- a/sources/tech/20171130 How to find all files with a specific text using Linux shell .md +++ b/sources/tech/20171130 How to find all files with a specific text using Linux shell .md @@ -1,56 +1,38 @@ translating by lujun9972 How to find all files with a specific text using Linux shell ------ -### Objective +### 目标 The following article provides some useful tips on how to find all files within any specific directory or entire file-system containing any specific word or string. -### Difficulty +### 难度 EASY -### Conventions +### 约定 * # - requires given command to be executed with root privileges either directly as a root user or by use of sudo command * $ - given command to be executed as a regular non-privileged user -### Examples +### 案例 -### Find all files with a specific string non-recursively +#### Find all files with a specific string non-recursively -The first command example will search for a string +The first command example will search for a string `stretch` in all files within `/etc/` directory while excluding any sub-directories: -`stretch` - -in all files within - -`/etc/` - -directory while excluding any sub-directories: - -``` +```shell # grep -s stretch /etc/* /etc/os-release:PRETTY_NAME="Debian GNU/Linux 9 (stretch)" /etc/os-release:VERSION="9 (stretch)" ``` -`-s` +The `-s` grep option will suppress error messages about nonexistent or unreadable files. The output shows filenames as well as prints the actual line containing requested string. -grep option will suppress error messages about nonexistent or unreadable files. The output shows filenames as well as prints the actual line containing requested string. +#### Find all files with a specific string recursively -### Find all files with a specific string recursively +The above command omitted all sub-directories. To search recursively means to also traverse all sub-directories. The following command will search for a string `stretch` in all files within `/etc/` directory including all sub-directories: -The above command omitted all sub-directories. To search recursively means to also traverse all sub-directories. The following command will search for a string - -`stretch` - -in all files within - -`/etc/` - -directory including all sub-directories: - -``` +```shell # grep -R stretch /etc/* /etc/apt/sources.list:# deb cdrom:[Debian GNU/Linux testing _Stretch_ - Official Snapshot amd64 NETINST Binary-1 20170109-05:56]/ stretch main /etc/apt/sources.list:#deb cdrom:[Debian GNU/Linux testing _Stretch_ - Official Snapshot amd64 NETINST Binary-1 20170109-05:56]/ stretch main @@ -84,29 +66,10 @@ directory including all sub-directories: /etc/os-release:VERSION="9 (stretch)" ``` -The above +#### Search for all files containing a specific word +The above `grep` command example lists all files containing string `stretch` . Meaning the lines with `stretches` , `stretched` etc. are also shown. Use grep's `-w` option to show only a specific word: -`grep` - -command example lists all files containing string - -`stretch` - -. Meaning the lines with - -`stretches` - -, - -`stretched` - -etc. are also shown. Use grep's - -`-w` - -option to show only a specific word: - -``` +```shell # grep -Rw stretch /etc/* /etc/apt/sources.list:# deb cdrom:[Debian GNU/Linux testing _Stretch_ - Official Snapshot amd64 NETINST Binary-1 20170109-05:56]/ stretch main /etc/apt/sources.list:#deb cdrom:[Debian GNU/Linux testing _Stretch_ - Official Snapshot amd64 NETINST Binary-1 20170109-05:56]/ stretch main @@ -121,17 +84,10 @@ option to show only a specific word: /etc/os-release:VERSION="9 (stretch)" ``` -The above commands may produce an unnecessary output. The next example will only show all file names containing string +#### List only files names containing a specific text +The above commands may produce an unnecessary output. The next example will only show all file names containing string `stretch` within `/etc/` directory recursively: -`stretch` - -within - -`/etc/` - -directory recursively: - -``` +```shell # grep -Rl stretch /etc/* /etc/apt/sources.list /etc/dictionaries-common/words @@ -139,29 +95,10 @@ directory recursively: /etc/os-release ``` -All searches are by default case sensitive which means that any search for a string +#### Perform case-insensitive search +All searches are by default case sensitive which means that any search for a string `stretch` will only show files containing the exact uppercase and lowercase match. By using grep's `-i` option the command will also list any lines containing `Stretch` , `STRETCH` , `StReTcH` etc., hence, to perform case-insensitive search. -`stretch` - -will only show files containing the exact uppercase and lowercase match. By using grep's - -`-i` - -option the command will also list any lines containing - -`Stretch` - -, - -`STRETCH` - -, - -`StReTcH` - -etc., hence, to perform case-insensitive search. - -``` +```shell # grep -Ril stretch /etc/* /etc/apt/sources.list /etc/dictionaries-common/default.hash @@ -170,39 +107,19 @@ etc., hence, to perform case-insensitive search. /etc/os-release ``` -Using +#### Include or Exclude specific files names from search +Using `grep` command it is also possible to include only specific files as part of the search. For example we only would like to search for a specific text/string within configuration files with extension `.conf` . The next example will find all files with extension `.conf` within `/etc` directory containing string `bash` : -`grep` - -command it is also possible to include only specific files as part of the search. For example we only would like to search for a specific text/string within configuration files with extension - -`.conf` - -. The next example will find all files with extension - -`.conf` - -within - -`/etc` - -directory containing string - -`bash` - -: - -``` +```shell # grep -Ril bash /etc/*.conf OR # grep -Ril --include=\*.conf bash /etc/* /etc/adduser.conf ``` -`--exclude` -option we can exclude any specific filenames: +Similarly, using `--exclude` option we can exclude any specific filenames: -``` +```shell # grep -Ril --exclude=\*.conf bash /etc/* /etc/alternatives/view /etc/alternatives/vim @@ -227,57 +144,28 @@ option we can exclude any specific filenames: /etc/skel/.bash_logout ``` -Same as with files grep can also exclude specific directories from the search. Use +#### Exclude specific Directories from search +Same as with files grep can also exclude specific directories from the search. Use `--exclude-dir` option to exclude directory from search. The following search example will find all files containing string `stretch` within `/etc` directory and exclude `/etc/grub.d` from search: -`--exclude-dir` - -option to exclude directory from search. The following search example will find all files containing string - -`stretch` - -within - -`/etc` - -directory and exclude - -`/etc/grub.d` - -from search: - -``` +```shell # grep --exclude-dir=/etc/grub.d -Rwl stretch /etc/* /etc/apt/sources.list /etc/dictionaries-common/words /etc/os-release ``` -By using +#### Display a line number containing searched string +By using `-n` option grep will also provide an information regarding a line number where the specific string was found: -`-n` - -option grep will also provide an information regarding a line number where the specific string was found: - -``` +```shell # grep -Rni bash /etc/*.conf /etc/adduser.conf:6:DSHELL=/bin/bash ``` -The last example will use +#### Find all files not containing a specific string +The last example will use `-v` option to list all files NOT containing a specific keyword. For example the following search will list all files within `/etc/` directory which do not contain string `stretch` : -`-v` - -option to list all files NOT containing a specific keyword. For example the following search will list all files within - -`/etc/` - -directory which do not contain string - -`stretch` - -: - -``` +```shell # grep -Rlv stretch /etc/* ``` From 30ff78e85b4449e1ffd9763af8daf97e052164de Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 6 Dec 2017 19:37:10 +0800 Subject: [PATCH 305/344] translated --- ...with a specific text using Linux shell .md | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/sources/tech/20171130 How to find all files with a specific text using Linux shell .md b/sources/tech/20171130 How to find all files with a specific text using Linux shell .md index d518dd48db..81938b79fc 100644 --- a/sources/tech/20171130 How to find all files with a specific text using Linux shell .md +++ b/sources/tech/20171130 How to find all files with a specific text using Linux shell .md @@ -1,36 +1,36 @@ -translating by lujun9972 -How to find all files with a specific text using Linux shell +如何在Linux shell中找出所有包含指定文本的文件 ------ ### 目标 -The following article provides some useful tips on how to find all files within any specific directory or entire file-system containing any specific word or string. +本文提供一些关于如何搜索出指定目录或整个文件系统中那些包含指定单词或字符串的文件. ### 难度 -EASY +容易 ### 约定 -* # - requires given command to be executed with root privileges either directly as a root user or by use of sudo command +* \# - 需要使用 root 权限来执行指定命令,可以直接使用 root 用户来执行也可以使用 sudo 命令 -* $ - given command to be executed as a regular non-privileged user +* \$ - 可以使用普通用户来执行指定命令 ### 案例 -#### Find all files with a specific string non-recursively +#### 非递归搜索包含指定字符串的文件 -The first command example will search for a string `stretch` in all files within `/etc/` directory while excluding any sub-directories: +第一个例子让我们来搜索 `/etc/` 目录下所有包含 `stretch` 字符串的文件,但不去搜索其中的子目录: ```shell # grep -s stretch /etc/* /etc/os-release:PRETTY_NAME="Debian GNU/Linux 9 (stretch)" /etc/os-release:VERSION="9 (stretch)" ``` -The `-s` grep option will suppress error messages about nonexistent or unreadable files. The output shows filenames as well as prints the actual line containing requested string. +grep 的 `-s` 选项会在发现不能存在或者不能读取的文件时抑制报错信息. 结果现实除了文件名外还有包含请求字符串的行也被一起输出了. -#### Find all files with a specific string recursively +#### 递归地搜索包含指定字符串的文件 -The above command omitted all sub-directories. To search recursively means to also traverse all sub-directories. The following command will search for a string `stretch` in all files within `/etc/` directory including all sub-directories: +上面案例中忽略了所有的子目录. 所谓递归搜索就是指同时搜索所有的子目录. +下面的命令会在 `/etc/` 及其子目录中搜索包含 `stretch` 字符串的文件: ```shell # grep -R stretch /etc/* @@ -66,8 +66,8 @@ The above command omitted all sub-directories. To search recursively means to al /etc/os-release:VERSION="9 (stretch)" ``` -#### Search for all files containing a specific word -The above `grep` command example lists all files containing string `stretch` . Meaning the lines with `stretches` , `stretched` etc. are also shown. Use grep's `-w` option to show only a specific word: +#### 搜索所有包含特定单词的文件 +上面 `grep` 命令的案例中列出的是所有包含字符串 `stretch` 的文件. 也就是说包含 `stretches` , `stretched` 等内容的行也会被显示. 使用 grep 的 `-w` 选项会只显示包含特定单词的行: ```shell # grep -Rw stretch /etc/* @@ -84,8 +84,8 @@ The above `grep` command example lists all files containing string `stretch` . M /etc/os-release:VERSION="9 (stretch)" ``` -#### List only files names containing a specific text -The above commands may produce an unnecessary output. The next example will only show all file names containing string `stretch` within `/etc/` directory recursively: +#### 显示包含特定文本文件的文件名 +上面的命令都会产生多余的输出. 下一个案例则会递归地搜索 `etc` 目录中包含 `stretch` 的文件并只输出文件名: ```shell # grep -Rl stretch /etc/* @@ -95,8 +95,9 @@ The above commands may produce an unnecessary output. The next example will only /etc/os-release ``` -#### Perform case-insensitive search -All searches are by default case sensitive which means that any search for a string `stretch` will only show files containing the exact uppercase and lowercase match. By using grep's `-i` option the command will also list any lines containing `Stretch` , `STRETCH` , `StReTcH` etc., hence, to perform case-insensitive search. +#### 大小写不敏感的搜索 +默认情况下搜索hi大小写敏感的,也就是说当搜索字符串 `stretch` 时只会包含大小写一致内容的文件. +通过使用 grep 的 `-i` 选项,grep 命令还会列出所有包含 `Stretch` , `STRETCH` , `StReTcH` 等内容的文件,也就是说进行的是大小写不敏感的搜索. ```shell # grep -Ril stretch /etc/* @@ -107,8 +108,8 @@ All searches are by default case sensitive which means that any search for a str /etc/os-release ``` -#### Include or Exclude specific files names from search -Using `grep` command it is also possible to include only specific files as part of the search. For example we only would like to search for a specific text/string within configuration files with extension `.conf` . The next example will find all files with extension `.conf` within `/etc` directory containing string `bash` : +#### 搜索是包含/排除指定文件 +`grep` 命令也可以只在指定文件中进行搜索. 比如,我们可以只在配置文件(扩展名为`.conf`)中搜索指定的文本/字符串. 下面这个例子就会在 `/etc` 目录中搜索带字符串 `bash` 且所有扩展名为 `.conf` 的文件: ```shell # grep -Ril bash /etc/*.conf @@ -117,7 +118,7 @@ OR /etc/adduser.conf ``` -Similarly, using `--exclude` option we can exclude any specific filenames: +类似的, 也可以使用 `--exclude` 来排除特定的文件: ```shell # grep -Ril --exclude=\*.conf bash /etc/* @@ -144,8 +145,9 @@ Similarly, using `--exclude` option we can exclude any specific filenames: /etc/skel/.bash_logout ``` -#### Exclude specific Directories from search -Same as with files grep can also exclude specific directories from the search. Use `--exclude-dir` option to exclude directory from search. The following search example will find all files containing string `stretch` within `/etc` directory and exclude `/etc/grub.d` from search: +#### 搜索时排除指定目录 +跟文件一样,grep 也能在搜索时排除指定目录. 使用 `--exclude-dir` 选项就行. +下面这个例子会搜索 `/etc` 目录中搜有包含字符串 `stretch` 的文件,但不包括 `/etc/grub.d` 目录下的文件: ```shell # grep --exclude-dir=/etc/grub.d -Rwl stretch /etc/* @@ -154,16 +156,17 @@ Same as with files grep can also exclude specific directories from the search. U /etc/os-release ``` -#### Display a line number containing searched string -By using `-n` option grep will also provide an information regarding a line number where the specific string was found: +#### 显示包含搜索字符串的行号 +`-n` 选项还会显示指定字符串所在行的行号: ```shell # grep -Rni bash /etc/*.conf /etc/adduser.conf:6:DSHELL=/bin/bash ``` -#### Find all files not containing a specific string -The last example will use `-v` option to list all files NOT containing a specific keyword. For example the following search will list all files within `/etc/` directory which do not contain string `stretch` : +#### 寻找不包含指定字符串的文件 +最后这个例子使用 `-v` 来列出所有 *不* 包含指定字符串的文件. +例如下面命令会搜索 `/etc` 目录中不包含 `stretch` 的所有文件: ```shell # grep -Rlv stretch /etc/* From 05bf1048b2b032bac519880665bbd25d3e0f54a6 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 6 Dec 2017 19:39:15 +0800 Subject: [PATCH 306/344] reformat --- ...with a specific text using Linux shell .md | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sources/tech/20171130 How to find all files with a specific text using Linux shell .md b/sources/tech/20171130 How to find all files with a specific text using Linux shell .md index 81938b79fc..41b02fc989 100644 --- a/sources/tech/20171130 How to find all files with a specific text using Linux shell .md +++ b/sources/tech/20171130 How to find all files with a specific text using Linux shell .md @@ -1,8 +1,8 @@ -如何在Linux shell中找出所有包含指定文本的文件 +如何在 Linux shell 中找出所有包含指定文本的文件 ------ ### 目标 -本文提供一些关于如何搜索出指定目录或整个文件系统中那些包含指定单词或字符串的文件. +本文提供一些关于如何搜索出指定目录或整个文件系统中那些包含指定单词或字符串的文件。 ### 难度 @@ -25,11 +25,11 @@ /etc/os-release:PRETTY_NAME="Debian GNU/Linux 9 (stretch)" /etc/os-release:VERSION="9 (stretch)" ``` -grep 的 `-s` 选项会在发现不能存在或者不能读取的文件时抑制报错信息. 结果现实除了文件名外还有包含请求字符串的行也被一起输出了. +grep 的 `-s` 选项会在发现不能存在或者不能读取的文件时抑制报错信息。结果现实除了文件名外还有包含请求字符串的行也被一起输出了。 #### 递归地搜索包含指定字符串的文件 -上面案例中忽略了所有的子目录. 所谓递归搜索就是指同时搜索所有的子目录. +上面案例中忽略了所有的子目录。所谓递归搜索就是指同时搜索所有的子目录。 下面的命令会在 `/etc/` 及其子目录中搜索包含 `stretch` 字符串的文件: ```shell @@ -67,7 +67,7 @@ grep 的 `-s` 选项会在发现不能存在或者不能读取的文件时抑制 ``` #### 搜索所有包含特定单词的文件 -上面 `grep` 命令的案例中列出的是所有包含字符串 `stretch` 的文件. 也就是说包含 `stretches` , `stretched` 等内容的行也会被显示. 使用 grep 的 `-w` 选项会只显示包含特定单词的行: +上面 `grep` 命令的案例中列出的是所有包含字符串 `stretch` 的文件。也就是说包含 `stretches` , `stretched` 等内容的行也会被显示。 使用 grep 的 `-w` 选项会只显示包含特定单词的行: ```shell # grep -Rw stretch /etc/* @@ -85,7 +85,7 @@ grep 的 `-s` 选项会在发现不能存在或者不能读取的文件时抑制 ``` #### 显示包含特定文本文件的文件名 -上面的命令都会产生多余的输出. 下一个案例则会递归地搜索 `etc` 目录中包含 `stretch` 的文件并只输出文件名: +上面的命令都会产生多余的输出。下一个案例则会递归地搜索 `etc` 目录中包含 `stretch` 的文件并只输出文件名: ```shell # grep -Rl stretch /etc/* @@ -96,8 +96,8 @@ grep 的 `-s` 选项会在发现不能存在或者不能读取的文件时抑制 ``` #### 大小写不敏感的搜索 -默认情况下搜索hi大小写敏感的,也就是说当搜索字符串 `stretch` 时只会包含大小写一致内容的文件. -通过使用 grep 的 `-i` 选项,grep 命令还会列出所有包含 `Stretch` , `STRETCH` , `StReTcH` 等内容的文件,也就是说进行的是大小写不敏感的搜索. +默认情况下搜索 hi 大小写敏感的,也就是说当搜索字符串 `stretch` 时只会包含大小写一致内容的文件。 +通过使用 grep 的 `-i` 选项,grep 命令还会列出所有包含 `Stretch` , `STRETCH` , `StReTcH` 等内容的文件,也就是说进行的是大小写不敏感的搜索。 ```shell # grep -Ril stretch /etc/* @@ -109,7 +109,7 @@ grep 的 `-s` 选项会在发现不能存在或者不能读取的文件时抑制 ``` #### 搜索是包含/排除指定文件 -`grep` 命令也可以只在指定文件中进行搜索. 比如,我们可以只在配置文件(扩展名为`.conf`)中搜索指定的文本/字符串. 下面这个例子就会在 `/etc` 目录中搜索带字符串 `bash` 且所有扩展名为 `.conf` 的文件: +`grep` 命令也可以只在指定文件中进行搜索。比如,我们可以只在配置文件(扩展名为`.conf`)中搜索指定的文本/字符串。 下面这个例子就会在 `/etc` 目录中搜索带字符串 `bash` 且所有扩展名为 `.conf` 的文件: ```shell # grep -Ril bash /etc/*.conf @@ -118,7 +118,7 @@ OR /etc/adduser.conf ``` -类似的, 也可以使用 `--exclude` 来排除特定的文件: +类似的,也可以使用 `--exclude` 来排除特定的文件: ```shell # grep -Ril --exclude=\*.conf bash /etc/* @@ -146,7 +146,7 @@ OR ``` #### 搜索时排除指定目录 -跟文件一样,grep 也能在搜索时排除指定目录. 使用 `--exclude-dir` 选项就行. +跟文件一样,grep 也能在搜索时排除指定目录。 使用 `--exclude-dir` 选项就行。 下面这个例子会搜索 `/etc` 目录中搜有包含字符串 `stretch` 的文件,但不包括 `/etc/grub.d` 目录下的文件: ```shell @@ -165,7 +165,7 @@ OR ``` #### 寻找不包含指定字符串的文件 -最后这个例子使用 `-v` 来列出所有 *不* 包含指定字符串的文件. +最后这个例子使用 `-v` 来列出所有 *不* 包含指定字符串的文件。 例如下面命令会搜索 `/etc` 目录中不包含 `stretch` 的所有文件: ```shell @@ -178,7 +178,7 @@ via: https://linuxconfig.org/how-to-find-all-files-with-a-specific-text-using-li 作者:[Lubos Rendek][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/) 荣誉推出 From 772f3f418786300abf49a2f89391ab9f21d6aa95 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Wed, 6 Dec 2017 19:46:58 +0800 Subject: [PATCH 307/344] Translating by qhwdw --- sources/tech/20171005 Reasons Kubernetes is cool.md | 1 + sources/tech/20171203 Best Network Monitoring Tools For Linux.md | 1 + 2 files changed, 2 insertions(+) diff --git a/sources/tech/20171005 Reasons Kubernetes is cool.md b/sources/tech/20171005 Reasons Kubernetes is cool.md index a9d10b9cdb..e1e63e77e8 100644 --- a/sources/tech/20171005 Reasons Kubernetes is cool.md +++ b/sources/tech/20171005 Reasons Kubernetes is cool.md @@ -1,3 +1,4 @@ +Translating by qhwdw Reasons Kubernetes is cool ============================================================ diff --git a/sources/tech/20171203 Best Network Monitoring Tools For Linux.md b/sources/tech/20171203 Best Network Monitoring Tools For Linux.md index aec39b9822..d53e4e0534 100644 --- a/sources/tech/20171203 Best Network Monitoring Tools For Linux.md +++ b/sources/tech/20171203 Best Network Monitoring Tools For Linux.md @@ -1,3 +1,4 @@ +Translating by qhwdw Best Network Monitoring Tools For Linux =============================== From 15da7e58d9374ee09679e0445d62817dca010b88 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 6 Dec 2017 19:54:17 +0800 Subject: [PATCH 308/344] =?UTF-8?q?update=20at=202017=E5=B9=B4=2012?= =?UTF-8?q?=E6=9C=88=2006=E6=97=A5=20=E6=98=9F=E6=9C=9F=E4=B8=89=2019:54:1?= =?UTF-8?q?7=20CST?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...w to find all files with a specific text using Linux shell .md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources => translated}/tech/20171130 How to find all files with a specific text using Linux shell .md (100%) diff --git a/sources/tech/20171130 How to find all files with a specific text using Linux shell .md b/translated/tech/20171130 How to find all files with a specific text using Linux shell .md similarity index 100% rename from sources/tech/20171130 How to find all files with a specific text using Linux shell .md rename to translated/tech/20171130 How to find all files with a specific text using Linux shell .md From 297bddfde76917b37ed614afb498cf4ac0cf06fb Mon Sep 17 00:00:00 2001 From: imquanquan Date: Wed, 6 Dec 2017 20:55:41 +0800 Subject: [PATCH 309/344] translating --- sources/tech/20171201 Fedora Classroom Session_Ansible 101.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171201 Fedora Classroom Session_Ansible 101.md b/sources/tech/20171201 Fedora Classroom Session_Ansible 101.md index a74b196663..9e41edb393 100644 --- a/sources/tech/20171201 Fedora Classroom Session_Ansible 101.md +++ b/sources/tech/20171201 Fedora Classroom Session_Ansible 101.md @@ -1,3 +1,5 @@ +translating---geekpi + ### [Fedora Classroom Session: Ansible 101][2] ### By Sachin S Kamath From b44d24ca6bd4a55839e4030c4a61333d0bb9f751 Mon Sep 17 00:00:00 2001 From: imquanquan Date: Wed, 6 Dec 2017 20:57:08 +0800 Subject: [PATCH 310/344] translating --- sources/tech/20171201 Fedora Classroom Session_Ansible 101.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20171201 Fedora Classroom Session_Ansible 101.md b/sources/tech/20171201 Fedora Classroom Session_Ansible 101.md index 9e41edb393..628cd79497 100644 --- a/sources/tech/20171201 Fedora Classroom Session_Ansible 101.md +++ b/sources/tech/20171201 Fedora Classroom Session_Ansible 101.md @@ -1,4 +1,4 @@ -translating---geekpi +translating---imquanquan ### [Fedora Classroom Session: Ansible 101][2] From 3d25b5016c700f367ccd7da6a468d3396e033d1d Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 6 Dec 2017 21:38:27 +0800 Subject: [PATCH 311/344] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Using=20sudo=20to?= =?UTF-8?q?=20delegate=20permissions=20in=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...g sudo to delegate permissions in Linux.md | 229 ++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 sources/tech/20171205 Using sudo to delegate permissions in Linux.md diff --git a/sources/tech/20171205 Using sudo to delegate permissions in Linux.md b/sources/tech/20171205 Using sudo to delegate permissions in Linux.md new file mode 100644 index 0000000000..46a807c7a4 --- /dev/null +++ b/sources/tech/20171205 Using sudo to delegate permissions in Linux.md @@ -0,0 +1,229 @@ +translating by lujun9972 +Using sudo to delegate permissions in Linux +====== +I recently wrote a short Bash program to copy MP3 files from a USB thumb drive on one network host to another network host. The files are copied to a specific directory on the server that I run for a volunteer organization, from where the files can be downloaded and played. + +My program does a few other things, such as changing the name of the files before they are copied so they are automatically sorted by date on the webpage. It also deletes all the files on the USB drive after verifying that the transfer completed correctly. This nice little program has a few options, such as -h to display help, -t for test mode, and a couple of others. + +My program, as wonderful as it is, must run as root to perform its primary functions. Unfortunately, this organization has only a few people who have any interest in administering our audio and computer systems, which puts me in the position of finding semi-technical people and training them to log into the computer used to perform the transfer and run this little program. + +It is not that I cannot run the program myself, but for various reasons, including travel and illness, I am not always there. Even when I am present, as the "lazy sysadmin," I like to have others do my work for me. So, I write scripts to automate those tasks and use sudo to anoint a couple of users to run the scripts. Many Linux commands require the user to be root in order to run. This protects the system against accidental damage, such as that caused by my own stupidity, and intentional damage by a user with malicious intent. + +### Do that sudo that you do so well + +The sudo program is a handy tool that allows me as a sysadmin with root access to delegate responsibility for all or a few administrative tasks to other users of the computer. It allows me to perform that delegation without compromising the root password, thus maintaining a high level of security on the host. + +Let's assume, for example, that I have given regular user, "ruser," access to my Bash program, "myprog," which must be run as root to perform parts of its functions. First, the user logs in as ruser with their own password, then uses the following command to run myprog. + +``` + sudo myprog +``` + +I find it helpful to have the log of each command run by sudo for training. I can see who did what and whether they entered the command correctly. + +I have done this to delegate authority to myself and one other user to run a single program; however, sudo can be used to do so much more. It can allow the sysadmin to delegate authority for managing network functions or specific services to a single person or to a group of trusted users. It allows these functions to be delegated while protecting the security of the root password. + +### Configuring the sudoers file + +As a sysadmin, I can use the /etc/sudoers file to allow users or groups of users access to a single command, defined groups of commands, or all commands. This flexibility is key to both the power and the simplicity of using sudo for delegation. + +I found the sudoers file very confusing at first, so below I have copied and deconstructed the entire sudoers file from the host on which I am using it. Hopefully it won't be quite so obscure for you by the time you get through this analysis. Incidentally, I've found that the default configuration files in Red Hat-based distributions tend to have lots of comments and examples to provide guidance, which makes things easier, with less online searching required. + +Do not use your standard editor to modify the sudoers file. Use the visudo command because it is designed to enable any changes as soon as the file is saved and you exit the editor. It is possible to use editors besides Vi in the same way as visudo. + +Let's start analyzing this file at the beginning with a couple types of aliases. + +### Host aliases + +The host aliases section is used to create groups of hosts on which commands or command aliases can be used to provide access. The basic idea is that this single file will be maintained for all hosts in an organization and copied to /etc of each host. Some hosts, such as servers, can thus be configured as a group to give some users access to specific commands, such as the ability to start and stop services like HTTPD, DNS, and networking; to mount filesystems; and so on. + +IP addresses can be used instead of host names in the host aliases. + +``` +## Sudoers allows particular users to run various commands as +## the root user, without needing the root password. +## +## Examples are provided at the bottom of the file for collections +## of related commands, which can then be delegated out to particular +## users or groups. +## +## This file must be edited with the 'visudo' command. + +## Host Aliases +## Groups of machines. You may prefer to use hostnames (perhaps using +## wildcards for entire domains) or IP addresses instead. +# Host_Alias FILESERVERS = fs1, fs2 +# Host_Alias MAILSERVERS = smtp, smtp2 + +## User Aliases +## These aren't often necessary, as you can use regular groups +## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname +## rather than USERALIAS +# User_Alias ADMINS = jsmith, mikem +User_Alias AUDIO = dboth, ruser + +## Command Aliases +## These are groups of related commands... + +## Networking +# Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, + /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, +/usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool + +## Installation and management of software +# Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum + +## Services +# Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig + +## Updating the locate database +# Cmnd_Alias LOCATE = /usr/bin/updatedb + +## Storage +# Cmnd_Alias STORAGE = /sbin/fdisk, /sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount + +## Delegating permissions +# Cmnd_Alias DELEGATING = /usr/sbin/visudo, /bin/chown, /bin/chmod, /bin/chgrp + +## Processes +# Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall + +## Drivers +# Cmnd_Alias DRIVERS = /sbin/modprobe + +# Defaults specification + +# +# Refuse to run if unable to disable echo on the tty. +# +Defaults !visiblepw + +Defaults env_reset +Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS" +Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE" +Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES" +Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE" +Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY" + +Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin + +## Next comes the main part: which users can run what software on +## which machines (the sudoers file can be shared between multiple +## systems). +## Syntax: +## +## user MACHINE=COMMANDS +## +## The COMMANDS section may have other options added to it. +## +## Allow root to run any commands anywhere +root ALL=(ALL) ALL + +## Allows members of the 'sys' group to run networking, software, +## service management apps and more. +# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS + +## Allows people in group wheel to run all commands +%wheel ALL=(ALL) ALL + +## Same thing without a password +# %wheel ALL=(ALL) NOPASSWD: ALL + +## Allows members of the users group to mount and unmount the +## cdrom as root +# %users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom + +## Allows members of the users group to shutdown this system +# %users localhost=/sbin/shutdown -h now + +## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment) +#includedir /etc/sudoers.d + +################################################################################ +# Added by David Both, 11/04/2017 to provide limited access to myprog # +################################################################################ +# +AUDIO guest1=/usr/local/bin/myprog +``` + +### User aliases + +The user alias configuration allows root to sort users into aliased groups so that an entire group can have access to certain root capabilities. This is the section to which I have added the line User_Alias AUDIO = dboth, ruser, which defines the alias AUDIO and assigns two users to that alias. + +It is possible, as stated in the sudoers file, to simply use groups defined in the /etc/groups file instead of aliases. If you already have a group defined there that meets your needs, such as "audio," use that group name preceded by a % sign like so: %audio when assigning commands that will be made available to groups later in the sudoers file. + +### Command aliases + +Further down in the sudoers file is a command aliases section. These aliases are lists of related commands, such as networking commands or commands required to install updates or new RPM packages. These aliases allow the sysadmin to easily permit access to groups of commands. + +A number of aliases are already set up in this section that make it easy to delegate access to specific types of commands. + +### Environment defaults + +The next section sets some default environment variables. The item that is most interesting in this section is the !visiblepw line, which prevents sudo from running if the user environment is set to show the password. This is a security precaution that should not be overridden. + +### Command section + +The command section is the main part of the sudoers file. Everything you need to do can be done without all the aliases by adding enough entries here. The aliases just make it a whole lot easier. + +This section uses the aliases you've already defined to tell sudo who can do what on which hosts. The examples are self-explanatory once you understand the syntax in this section. Let's look at the syntax that we find in the command section. + +``` +ruser ALL=(ALL) ALL +``` + +This is a generic entry for our user, ruser. The first ALL in the line indicates that this rule applies on all hosts. The second ALL allows ruser to run commands as any other user. By default, commands are run as root user, but ruser can specify on the sudo command line that a program be run as any other user. The last ALL means that ruser can run all commands without restriction. This would effectively make ruser root. + +Note that there is an entry for root, as shown below. This allows root to have all-encompassing access to all commands on all hosts. + +``` +root ALL=(ALL) ALL +``` + +To try this out, I commented out the line and, as root, tried to run chown without sudo. That did work—much to my surprise. Then I used sudo chown and that failed with the message, "Root is not in the sudoers file. This incident will be reported." This means that root can run everything as root, but nothing when using the sudo command. This would prevent root from running commands as other users via the sudo command, but root has plenty of ways around that restriction. + +The code below is the one I added to control access to myprog. It specifies that users who are listed in the AUDIO group, as defined near the top of the sudoers file, have access to only one program, myprog, on one host, guest1. + +``` +AUDIO guest1=/usr/local/bin/myprog +``` + +Note that the syntax of the line above specifies only the host on which this access is to be allowed and the program. It does not specify that the user may run the program as any other user. + +### Bypassing passwords + +You can also use NOPASSWORD to allow the users specified in the group AUDIO to run myprog without the need for entering their passwords. Here's how: + +``` +AUDIO guest1=NOPASSWORD : /usr/local/bin/myprog +``` + +I did not do this for my program, because I believe that users with sudo access must stop and think about what they are doing, and this may help a bit with that. I used the entry for my little program as an example. + +### wheel + +The wheel specification in the command section of the sudoers file, as shown below, allows all users in the "wheel" group to run all commands on any host. The wheel group is defined in the /etc/group file, and users must be added to the group there for this to work. The % sign preceding the group name means that sudo should look for that group in the /etc/group file. + +``` +%wheel ALL = (ALL) ALL +``` + +This is a good way to delegate full root access to multiple users without providing the root password. Just adding a user to the wheel group gives them access to full root powers. It also provides a means to monitor their activities via the log entries created by sudo. Some distributions, such as Ubuntu, add users' IDs to the wheel group in /etc/group, which allows them to use the sudo command for all privileged commands. + +### Final thoughts + +I have used sudo here for a very limited objective—providing one or two users with access to a single command. I accomplished this with two lines (if you ignore my own comments). Delegating authority to perform certain tasks to users who do not have root access is simple and can save you, as a sysadmin, a good deal of time. It also generates log entries that can help detect problems. + +The sudoers file offers a plethora of capabilities and options for configuration. Check the man files for sudo and sudoers for the down-and-dirty details. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/12/using-sudo-delegate + +作者:[David Both][a] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/dboth From 5b7e80a1b469c3e1fad329e4aac0847a4f0a4938 Mon Sep 17 00:00:00 2001 From: imquanquan Date: Wed, 6 Dec 2017 22:55:39 +0800 Subject: [PATCH 312/344] translated --- ...01 Fedora Classroom Session_Ansible 101.md | 73 ------------------- ...01 Fedora Classroom Session_Ansible 101.md | 71 ++++++++++++++++++ 2 files changed, 71 insertions(+), 73 deletions(-) delete mode 100644 sources/tech/20171201 Fedora Classroom Session_Ansible 101.md create mode 100644 translated/tech/20171201 Fedora Classroom Session_Ansible 101.md diff --git a/sources/tech/20171201 Fedora Classroom Session_Ansible 101.md b/sources/tech/20171201 Fedora Classroom Session_Ansible 101.md deleted file mode 100644 index 628cd79497..0000000000 --- a/sources/tech/20171201 Fedora Classroom Session_Ansible 101.md +++ /dev/null @@ -1,73 +0,0 @@ -translating---imquanquan - -### [Fedora Classroom Session: Ansible 101][2] - -### By Sachin S Kamath - -![](https://fedoramagazine.org/wp-content/uploads/2017/07/fedora-classroom-945x400.jpg) - -Fedora Classroom sessions continue this week with an Ansible session. The general schedule for sessions appears [on the wiki][3]. You can also find [resources and recordings from previous sessions][4] there. Here are details about this week’s session on [Thursday, 30th November at 1600 UTC][5]. That link allows you to convert the time to your timezone. - -### Topic: Ansible 101 - -As the Ansible [documentation][6] explains, Ansible is an IT automation tool. It’s primarily used to configure systems, deploy software, and orchestrate more advanced IT tasks. Examples include continuous deployments or zero downtime rolling updates. - -This Classroom session covers the topics listed below: - -1. Introduction to SSH - -2. Understanding different terminologies - -3. Introduction to Ansible - -4. Ansible installation and setup - -5. Establishing password-less connection - -6. Ad-hoc commands - -7. Managing inventory - -8. Playbooks examples - -There will also be a follow-up Ansible 102 session later. That session will cover complex playbooks, roles, dynamic inventory files, control flow and Galaxy. - -### Instructors - -We have two experienced instructors handling this session. - -[Geoffrey Marr][7], also known by his IRC name as “coremodule,” is a Red Hat employee and Fedora contributor with a background in Linux and cloud technologies. While working, he spends his time lurking in the [Fedora QA][8] wiki and test pages. Away from work, he enjoys RaspberryPi projects, especially those focusing on software-defined radio. - -[Vipul Siddharth][9] is an intern at Red Hat who also works on Fedora. He loves to contribute to open source and seeks opportunities to spread the word of free and open source software. - -### Joining the session - -This session takes place on [BlueJeans][10]. The following information will help you join the session: - -* URL: [https://bluejeans.com/3466040121][1] - -* Meeting ID (for Desktop App): 3466040121 - -We hope you attend, learn from, and enjoy this session! If you have any feedback about the sessions, have ideas for a new one or want to host a session, please feel free to comment on this post or edit the [Classroom wiki page][11]. - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/fedora-classroom-session-ansible-101/ - -作者:[Sachin S Kamath] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[1]:https://bluejeans.com/3466040121 -[2]:https://fedoramagazine.org/fedora-classroom-session-ansible-101/ -[3]:https://fedoraproject.org/wiki/Classroom -[4]:https://fedoraproject.org/wiki/Classroom#Previous_Sessions -[5]:https://www.timeanddate.com/worldclock/fixedtime.html?msg=Fedora+Classroom+-+Ansible+101&iso=20171130T16&p1=%3A -[6]:http://docs.ansible.com/ansible/latest/index.html -[7]:https://fedoraproject.org/wiki/User:Coremodule -[8]:https://fedoraproject.org/wiki/QA -[9]:https://fedoraproject.org/wiki/User:Siddharthvipul1 -[10]:https://www.bluejeans.com/downloads -[11]:https://fedoraproject.org/wiki/Classroom diff --git a/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md b/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md new file mode 100644 index 0000000000..094bc6e044 --- /dev/null +++ b/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md @@ -0,0 +1,71 @@ +### [Fedora 课堂会议: Ansible 101][2] + +### By Sachin S Kamath + +![](https://fedoramagazine.org/wp-content/uploads/2017/07/fedora-classroom-945x400.jpg) + +Fedora 课堂会议本周继续进行本周的主题是 Ansible。 会议的时间安排表发布在 [on the wiki][3]。你还可以从那里找到[之前会议的资源和录像][4]。以下是本周[11月30日星期四 1600 UTC][5]。该链接可以将这个时间转换为您的时区上的时间。 + +### 主题: Ansible 101 + +正如 Ansible [文档][6] 所说, Ansible 是一个 IT 自动化工具。它主要用于配置系统,部署软件和编排更高级的 IT 任务。示例包括持续交付与零停机滚动升级。 + +本课堂课程涵盖以下主题: + +1. SSH 简介 + +2. 了解不同的术语 + +3. Ansible 简介 + +4. Ansible 安装和设置 + +5. 建立无密码连接 + +6. Ad-hoc 命令 + +7. 管理 inventory + +8. Playbooks 示例 + +稍后还将有 Ansible 102 的后续会议。该会议将涵盖复杂的 playbooks,playbooks 角色(roles),动态 inventory 文件,流程控制和 Ansible Galaxy 命令行工具. + +### 讲师 + +我们有两位经验丰富的讲师进行这次会议。 + +[Geoffrey Marr][7],IRC 聊天室中名字叫 coremodule,是 Red Hat 的一名员工和 Fedora 的贡献者,拥有 Linux 和云技术的背景。工作时, 他潜心于 [Fedora QA][8] wiki 和测试页面下。业余时间, 他热衷于 RaspberryPi 项目, 尤其是专注于那些软件无线电(Software-defined radio)项目。 + +[Vipul Siddharth][9] 是Red Hat的实习生,他也在Fedora上工作。他喜欢贡献开源,借此机会传播自由开源软件。 + +### 加入会议 + +本次会议将在 [BlueJeans][10] 上进行。下面的信息可以帮你加入到会议: + +* 网址: [https://bluejeans.com/3466040121][1] + +* 会议 ID (桌面版): 3466040121 + +我们希望您可以参加,学习,并享受这个会议!如果您对会议有任何反馈意见,有什么新的想法或者想要主持一个会议, 可以随时在这篇文章发表评论或者查看[课堂 wiki 页面][11]. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/fedora-classroom-session-ansible-101/ + +作者:[Sachin S Kamath] +译者:[imquanquan](https://github.com/imquanquan) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[1]:https://bluejeans.com/3466040121 +[2]:https://fedoramagazine.org/fedora-classroom-session-ansible-101/ +[3]:https://fedoraproject.org/wiki/Classroom +[4]:https://fedoraproject.org/wiki/Classroom#Previous_Sessions +[5]:https://www.timeanddate.com/worldclock/fixedtime.html?msg=Fedora+Classroom+-+Ansible+101&iso=20171130T16&p1=%3A +[6]:http://docs.ansible.com/ansible/latest/index.html +[7]:https://fedoraproject.org/wiki/User:Coremodule +[8]:https://fedoraproject.org/wiki/QA +[9]:https://fedoraproject.org/wiki/User:Siddharthvipul1 +[10]:https://www.bluejeans.com/downloads +[11]:https://fedoraproject.org/wiki/Classroom From 437740dee3a014494349b2c94ee0aa405b73621b Mon Sep 17 00:00:00 2001 From: imquanquan Date: Wed, 6 Dec 2017 22:58:25 +0800 Subject: [PATCH 313/344] translated --- .../tech/20171201 Fedora Classroom Session_Ansible 101.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md b/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md index 094bc6e044..c57a20afd7 100644 --- a/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md +++ b/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md @@ -4,7 +4,7 @@ ![](https://fedoramagazine.org/wp-content/uploads/2017/07/fedora-classroom-945x400.jpg) -Fedora 课堂会议本周继续进行本周的主题是 Ansible。 会议的时间安排表发布在 [on the wiki][3]。你还可以从那里找到[之前会议的资源和录像][4]。以下是本周[11月30日星期四 1600 UTC][5]。该链接可以将这个时间转换为您的时区上的时间。 +Fedora 课堂会议本周继续进行本周的主题是 Ansible。 会议的时间安排表发布在 [wiki][3] 上。你还可以从那里找到[之前会议的资源和录像][4]。以下是本周[11月30日星期四 1600 UTC][5]。该链接可以将这个时间转换为您的时区上的时间。 ### 主题: Ansible 101 From 112fd9d835bff132820bfde31355b18f674ed329 Mon Sep 17 00:00:00 2001 From: imquanquan Date: Wed, 6 Dec 2017 23:00:07 +0800 Subject: [PATCH 314/344] fix errors --- .../tech/20171201 Fedora Classroom Session_Ansible 101.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md b/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md index c57a20afd7..3941b8b702 100644 --- a/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md +++ b/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md @@ -4,7 +4,7 @@ ![](https://fedoramagazine.org/wp-content/uploads/2017/07/fedora-classroom-945x400.jpg) -Fedora 课堂会议本周继续进行本周的主题是 Ansible。 会议的时间安排表发布在 [wiki][3] 上。你还可以从那里找到[之前会议的资源和录像][4]。以下是本周[11月30日星期四 1600 UTC][5]。该链接可以将这个时间转换为您的时区上的时间。 +Fedora 课堂会议本周继续进行本周的主题是 Ansible。 会议的时间安排表发布在 [wiki][3] 上。你还可以从那里找到[之前会议的资源和录像][4]。以下是会议的具体时间 [本周11月30日星期四 1600 UTC][5]。该链接可以将这个时间转换为您的时区上的时间。 ### 主题: Ansible 101 From 4bb45667cf341c8cb5b15c4241422ee1d1bd2753 Mon Sep 17 00:00:00 2001 From: imquanquan Date: Wed, 6 Dec 2017 23:04:10 +0800 Subject: [PATCH 315/344] translated --- .../tech/20171201 Fedora Classroom Session_Ansible 101.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md b/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md index 3941b8b702..184671cdff 100644 --- a/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md +++ b/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md @@ -34,7 +34,7 @@ Fedora 课堂会议本周继续进行本周的主题是 Ansible。 会议的时 我们有两位经验丰富的讲师进行这次会议。 -[Geoffrey Marr][7],IRC 聊天室中名字叫 coremodule,是 Red Hat 的一名员工和 Fedora 的贡献者,拥有 Linux 和云技术的背景。工作时, 他潜心于 [Fedora QA][8] wiki 和测试页面下。业余时间, 他热衷于 RaspberryPi 项目, 尤其是专注于那些软件无线电(Software-defined radio)项目。 +[Geoffrey Marr][7],IRC 聊天室中名字叫 coremodule,是 Red Hat 的一名员工和 Fedora 的贡献者,拥有 Linux 和云技术的背景。工作时,他潜心于 [Fedora QA][8] wiki 和测试页面下。业余时间, 他热衷于 RaspberryPi 项目,尤其是专注于那些软件无线电(Software-defined radio)项目。 [Vipul Siddharth][9] 是Red Hat的实习生,他也在Fedora上工作。他喜欢贡献开源,借此机会传播自由开源软件。 From e6d475a5c54411eb1bdae568d168db54fa451cb9 Mon Sep 17 00:00:00 2001 From: imquanquan Date: Wed, 6 Dec 2017 23:04:59 +0800 Subject: [PATCH 316/344] Update 20171201 Fedora Classroom Session_Ansible 101.md --- .../tech/20171201 Fedora Classroom Session_Ansible 101.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md b/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md index 184671cdff..26b3f1c42e 100644 --- a/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md +++ b/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md @@ -4,11 +4,11 @@ ![](https://fedoramagazine.org/wp-content/uploads/2017/07/fedora-classroom-945x400.jpg) -Fedora 课堂会议本周继续进行本周的主题是 Ansible。 会议的时间安排表发布在 [wiki][3] 上。你还可以从那里找到[之前会议的资源和录像][4]。以下是会议的具体时间 [本周11月30日星期四 1600 UTC][5]。该链接可以将这个时间转换为您的时区上的时间。 +Fedora 课堂会议本周继续进行本周的主题是 Ansible。 会议的时间安排表发布在 [wiki][3] 上。你还可以从那里找到[之前会议的资源和录像][4]。以下是会议的具体时间 [11月30日本周星期四 1600 UTC][5]。该链接可以将这个时间转换为您的时区上的时间。 ### 主题: Ansible 101 -正如 Ansible [文档][6] 所说, Ansible 是一个 IT 自动化工具。它主要用于配置系统,部署软件和编排更高级的 IT 任务。示例包括持续交付与零停机滚动升级。 +正如 Ansible [文档][6] 所说,Ansible 是一个 IT 自动化工具。它主要用于配置系统,部署软件和编排更高级的 IT 任务。示例包括持续交付与零停机滚动升级。 本课堂课程涵盖以下主题: From 3297f7cda45030951ae6af5eb614863ea4e35f2c Mon Sep 17 00:00:00 2001 From: imquanquan Date: Wed, 6 Dec 2017 23:15:52 +0800 Subject: [PATCH 317/344] translated --- .../tech/20171201 Fedora Classroom Session_Ansible 101.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md b/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md index 26b3f1c42e..1ebee40a44 100644 --- a/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md +++ b/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md @@ -28,13 +28,13 @@ Fedora 课堂会议本周继续进行本周的主题是 Ansible。 会议的时 8. Playbooks 示例 -稍后还将有 Ansible 102 的后续会议。该会议将涵盖复杂的 playbooks,playbooks 角色(roles),动态 inventory 文件,流程控制和 Ansible Galaxy 命令行工具. +之后还将有 Ansible 102 的后续会议。该会议将涵盖复杂的 playbooks,playbooks 角色(roles),动态 inventory 文件,流程控制和 Ansible Galaxy 命令行工具. ### 讲师 我们有两位经验丰富的讲师进行这次会议。 -[Geoffrey Marr][7],IRC 聊天室中名字叫 coremodule,是 Red Hat 的一名员工和 Fedora 的贡献者,拥有 Linux 和云技术的背景。工作时,他潜心于 [Fedora QA][8] wiki 和测试页面下。业余时间, 他热衷于 RaspberryPi 项目,尤其是专注于那些软件无线电(Software-defined radio)项目。 +[Geoffrey Marr][7],IRC 聊天室中名字叫 coremodule,是 Red Hat 的一名员工和 Fedora 的贡献者,拥有 Linux 和云技术的背景。工作时,他潜心于 [Fedora QA][8] wiki 和测试页面中。业余时间, 他热衷于 RaspberryPi 项目,尤其是专注于那些软件无线电(Software-defined radio)项目。 [Vipul Siddharth][9] 是Red Hat的实习生,他也在Fedora上工作。他喜欢贡献开源,借此机会传播自由开源软件。 From fdb26b4cc65630c85a8c2017584fcf58ab42dbb4 Mon Sep 17 00:00:00 2001 From: imquanquan Date: Wed, 6 Dec 2017 23:24:38 +0800 Subject: [PATCH 318/344] translated --- .../tech/20171201 Fedora Classroom Session_Ansible 101.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md b/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md index 1ebee40a44..4a4c5514ba 100644 --- a/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md +++ b/translated/tech/20171201 Fedora Classroom Session_Ansible 101.md @@ -4,7 +4,7 @@ ![](https://fedoramagazine.org/wp-content/uploads/2017/07/fedora-classroom-945x400.jpg) -Fedora 课堂会议本周继续进行本周的主题是 Ansible。 会议的时间安排表发布在 [wiki][3] 上。你还可以从那里找到[之前会议的资源和录像][4]。以下是会议的具体时间 [11月30日本周星期四 1600 UTC][5]。该链接可以将这个时间转换为您的时区上的时间。 +Fedora 课堂会议本周继续进行,本周的主题是 Ansible。 会议的时间安排表发布在 [wiki][3] 上。你还可以从那里找到[之前会议的资源和录像][4]。以下是会议的具体时间 [11月30日本周星期四 1600 UTC][5]。该链接可以将这个时间转换为您的时区上的时间。 ### 主题: Ansible 101 From 8cb7cea13716d0435eab2defbf903febfe3d3bcf Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 6 Dec 2017 23:38:32 +0800 Subject: [PATCH 319/344] PUB:20170910 Cool vim feature sessions.md @geekpi --- .../tech => published}/20170910 Cool vim feature sessions.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20170910 Cool vim feature sessions.md (100%) diff --git a/translated/tech/20170910 Cool vim feature sessions.md b/published/20170910 Cool vim feature sessions.md similarity index 100% rename from translated/tech/20170910 Cool vim feature sessions.md rename to published/20170910 Cool vim feature sessions.md From 3d2b8967e59276ccf7bc7382a44939a8b971ca90 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 6 Dec 2017 23:51:22 +0800 Subject: [PATCH 320/344] PRF&PUB:20171024 How to Encrypt and Decrypt Individual Files With GPG.md @lujun9972 https://linux.cn/article-9118-1.html --- ...t and Decrypt Individual Files With GPG.md | 92 +++++++++---------- 1 file changed, 45 insertions(+), 47 deletions(-) rename {translated/tech => published}/20171024 How to Encrypt and Decrypt Individual Files With GPG.md (60%) diff --git a/translated/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md b/published/20171024 How to Encrypt and Decrypt Individual Files With GPG.md similarity index 60% rename from translated/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md rename to published/20171024 How to Encrypt and Decrypt Individual Files With GPG.md index 6b534be640..dffab516ac 100644 --- a/translated/tech/20171024 How to Encrypt and Decrypt Individual Files With GPG.md +++ b/published/20171024 How to Encrypt and Decrypt Individual Files With GPG.md @@ -1,68 +1,66 @@ 如何使用 GPG 加解密文件 ------- -### 目标 +================= -使用 GPG 加密文件 +目标:使用 GPG 加密文件 -### 发行版 +发行版:适用于任何发行版 -适用于任何发行版 +要求:安装了 GPG 的 Linux 或者拥有 root 权限来安装它。 -### 要求 +难度:简单 -安装了 GPG 的 Linux 或者拥有 root 权限来安装它。 +约定: -### 难度 - -简单 - -### 约定 - -* # - 需要使用 root 权限来执行指定命令,可以直接使用 root 用户来执行也可以使用 sudo 命令 - -* $ - 可以使用普通用户来执行指定命令 +* `#` - 需要使用 root 权限来执行指定命令,可以直接使用 root 用户来执行,也可以使用 `sudo` 命令 +* `$` - 可以使用普通用户来执行指定命令 ### 介绍 -加密非常重要。它对于保护敏感信息来说是必不可少的。 -你的私人文件应该要被加密,而 GPG 提供了很好的解决方案。 +加密非常重要。它对于保护敏感信息来说是必不可少的。你的私人文件应该要被加密,而 GPG 提供了很好的解决方案。 ### 安装 GPG -GPG 的使用非常广泛。你在几乎每个发行版的仓库中都能找到它。 -如果你还没有安装它,那现在就来安装一下吧。 +GPG 的使用非常广泛。你在几乎每个发行版的仓库中都能找到它。如果你还没有安装它,那现在就来安装一下吧。 -#### Debian/Ubuntu +**Debian/Ubuntu** -```shell +``` $ sudo apt install gnupg ``` -#### Fedora -```shell + +**Fedora** + +``` # dnf install gnupg2 ``` -#### Arch -```shell + +**Arch** + +``` # pacman -S gnupg ``` -#### Gentoo -```shell + +**Gentoo** + +``` # emerge --ask app-crypt/gnupg ``` -### Create a Key -你需要一个密钥对来加解密文件。如果你为 SSH 已经生成过了密钥对,那么你可以直接使用它。 -如果没有,GPG 包含工具来生成密钥对。 -```shell +### 创建密钥 + +你需要一个密钥对来加解密文件。如果你为 SSH 已经生成过了密钥对,那么你可以直接使用它。如果没有,GPG 包含工具来生成密钥对。 + +``` $ gpg --full-generate-key ``` -GPG 有一个命令行程序帮你一步一步的生成密钥。它还有一个简单得多的工具,但是这个工具不能让你设置密钥类型,密钥的长度以及过期时间,因此不推荐使用这个工具。 + +GPG 有一个命令行程序可以帮你一步一步的生成密钥。它还有一个简单得多的工具,但是这个工具不能让你设置密钥类型,密钥的长度以及过期时间,因此不推荐使用这个工具。 GPG 首先会询问你密钥的类型。没什么特别的话选择默认值就好。 下一步需要设置密钥长度。`4096` 是一个不错的选择。 -之后,可以设置过期的日期。 如果希望密钥永不过期则设置为 `0` +之后,可以设置过期的日期。 如果希望密钥永不过期则设置为 `0`。 然后,输入你的名称。 @@ -72,20 +70,19 @@ GPG 首先会询问你密钥的类型。没什么特别的话选择默认值就 所有这些都完成后,GPG 会让你校验一下这些信息。 -GPG 还会问你是否需要为密钥设置密码。这一步是可选的, 但是会增加保护的程度。 -若需要设置密码,则 GPG 会收集你的操作信息来增加密钥的健壮性。 所有这些都完成后, GPG 会显示密钥相关的信息。 +GPG 还会问你是否需要为密钥设置密码。这一步是可选的, 但是会增加保护的程度。若需要设置密码,则 GPG 会收集你的操作信息来增加密钥的健壮性。 所有这些都完成后, GPG 会显示密钥相关的信息。 ### 加密的基本方法 -现在你拥有了自己的密钥,加密文件非常简单。 使用虾米那命令在 `/tmp` 目录中创建一个空白文本文件。 +现在你拥有了自己的密钥,加密文件非常简单。 使用下面的命令在 `/tmp` 目录中创建一个空白文本文件。 -```shell +``` $ touch /tmp/test.txt ``` 然后用 GPG 来加密它。这里 `-e` 标志告诉 GPG 你想要加密文件, `-r` 标志指定接收者。 -```shell +``` $ gpg -e -r "Your Name" /tmp/test.txt ``` @@ -95,34 +92,35 @@ GPG 需要知道这个文件的接收者和发送者。由于这个文件给是 你收到加密文件后,就需要对它进行解密。 你无需指定解密用的密钥。 这个信息被编码在文件中。 GPG 会尝试用其中的密钥进行解密。 -```shel +``` $ gpg -d /tmp/test.txt.gpg ``` ### 发送文件 + 假设你需要发送文件给别人。你需要有接收者的公钥。 具体怎么获得密钥由你自己决定。 你可以让他们直接把公钥发送给你, 也可以通过密钥服务器来获取。 收到对方公钥后,导入公钥到 GPG 中。 -```shell +``` $ gpg --import yourfriends.key ``` -这些公钥与你自己创建的密钥一样,自带了名称和电子邮件地址的信息。 -记住,为了让别人能解密你的文件,别人也需要你的公钥。 因此导出公钥并将之发送出去。 +这些公钥与你自己创建的密钥一样,自带了名称和电子邮件地址的信息。 记住,为了让别人能解密你的文件,别人也需要你的公钥。 因此导出公钥并将之发送出去。 -```shell +``` gpg --export -a "Your Name" > your.key ``` 现在可以开始加密要发送的文件了。它跟之前的步骤差不多, 只是需要指定你自己为发送人。 + ``` $ gpg -e -u "Your Name" -r "Their Name" /tmp/test.txt ``` ### 结语 -就这样了。GPG 还有一些高级选项, 不过你在 99% 的时间内都不会用到这些高级选项。 GPG 就是这么易于使用。 -你也可以使用创建的密钥对来发送和接受加密邮件,其步骤跟上面演示的差不多, 不过大多数的电子邮件客户端在拥有密钥的情况下会自动帮你做这个动作。 + +就这样了。GPG 还有一些高级选项, 不过你在 99% 的时间内都不会用到这些高级选项。 GPG 就是这么易于使用。你也可以使用创建的密钥对来发送和接受加密邮件,其步骤跟上面演示的差不多, 不过大多数的电子邮件客户端在拥有密钥的情况下会自动帮你做这个动作。 -------------------------------------------------------------------------------- @@ -130,7 +128,7 @@ via: https://linuxconfig.org/how-to-encrypt-and-decrypt-individual-files-with-gp 作者:[Nick Congleton][a] 译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者 ID](https://github.com/校对者 ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux 中国](https://linux.cn/) 荣誉推出 From 9277e93482a6e4634e07dd2ba1d4b84eead43473 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 6 Dec 2017 23:53:42 +0800 Subject: [PATCH 321/344] PUB:20170215 How to take screenshots on Linux using Scrot.md @zpl1025 --- .../20170215 How to take screenshots on Linux using Scrot.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20170215 How to take screenshots on Linux using Scrot.md (100%) diff --git a/translated/tech/20170215 How to take screenshots on Linux using Scrot.md b/published/20170215 How to take screenshots on Linux using Scrot.md similarity index 100% rename from translated/tech/20170215 How to take screenshots on Linux using Scrot.md rename to published/20170215 How to take screenshots on Linux using Scrot.md From 39c021864df47484a4e8fab0b63b383341212051 Mon Sep 17 00:00:00 2001 From: Yixun Xu Date: Wed, 6 Dec 2017 16:30:58 -0500 Subject: [PATCH 322/344] Translated - Linux games --- ... Games On Steam You Should Play in 2017.md | 246 +++++++++--------- 1 file changed, 121 insertions(+), 125 deletions(-) diff --git a/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md b/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md index 7a14f92847..f9fadae4ec 100644 --- a/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md +++ b/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md @@ -1,256 +1,252 @@ -yixunx translating - -30 Best Linux Games On Steam You Should Play in 2017 +2017 年最好的 30 款支持 Linux 的 Steam 游戏 ============================================================ -When it comes to Gaming, a system running on Windows platform is what anyone would recommend. It still is a superior choice for gamers with better graphics driver support and perfect hardware compatibility. But, what about the thought of [gaming on a Linux system][9]? Well, yes, of course – it is possible – maybe you thought of it at some point in time but the collection of Linux games on [Steam for Linux][10] platform wasn’t appealing at all few years back. +说到游戏,人们一般都会推荐使用 Windows 系统。Windows 能提供更好的显卡支持和硬件兼容性,所以对于游戏爱好者来说的确是个更好的选择。但你是否想过[在 Linux 系统上玩游戏][9]?这的确是可能的,也许你以前还曾经考虑过。但在几年之前, [Steam for Linux][10] 上可玩的游戏并不是很吸引人。 -However, that’s not true at all for the current scene. The Steam store now has a lot of great games listed for Linux platform (including a lot of major titles). So, in this article, we’ll be taking a look at the best Linux games on Steam. +但现在情况完全不一样了。Steam 商店里现在有许多支持 Linux 平台的游戏(包括很多主流大作)。我们在本文中将介绍 Steam 上最好的一些 Linux 游戏。 -But before we do that, let me tell you a money saving trick. If you are an avid gamer who spends plenty of time and money on gaming, you should subscribe to Humble Monthly. This monthly subscription program from [Humble Bundle][11] gives you $100 in games for just $12 each month. +在进入正题之前,先介绍一个省钱小窍门。如果你是个狂热的游戏爱好者,在游戏上花费很多时间和金钱的话,我建议你订阅 [Humble 每月包(Humble Monthly)][11]。这是个每月收费的订阅服务,每月只用 12 美元就能获得价值 100 美元的游戏。 -Not all games might be available on Linux though but it is still a good deal because you get additional 10% discount on any games or books you buy from [Humble Bundle website][12]. +这个游戏包中可能有些游戏不支持 Linux,但除了 Steam 游戏之外,它还会让 [Humble Bundle 网站][12]上所有的游戏和书籍都打九折,所以这依然是个不错的优惠。 -The best thing here is that every purchase you make supports a charity organization. So, you are not just gaming, you are also making a difference to the world. +更棒的是,你在 Humble Bundle 上所有的消费都会捐出一部分给慈善机构。所以你在享受游戏的同时还在帮助改变世界。 -### Best Linux games on Steam +### Steam 上最好的 Linux 游戏 -The list of best Linux games on steam is in no particular ranking order. +以下排名无先后顺序。 -Additional Note: While there’s a lot of games available on Steam for Linux, there are still a lot of problems you would face as a Linux gamer. You can refer to one of our articles to know about the [annoying experiences every Linux gamer encounters][14]. +额外提示:虽然在 Steam 上有很多支持 Linux 的游戏,但你在 Linux 上玩游戏时依然可能会遇到各种问题。你可以阅读我们之前的文章:[每个 Linux 游戏玩家都会遇到的烦人问题][14] -Jump Directly to your preferred genre of Games: +可以点击以下链接跳转到你喜欢的游戏类型: -* [Action Games][3] +* [动作类游戏][3] -* [RPG Games][4] +* [角色扮演类游戏][4] -* [Racing/Sports/Simulation Games][5] +* [赛车/运动/模拟类游戏][5] -* [Adventure Games][6] +* [冒险类游戏][6] -* [Indie Games][7] +* [独立游戏][7] -* [Strategy Games][8] +* [策略类游戏][8] -### Best Action Games for Linux On Steam +### Steam 上最佳 Linux 动作类游戏 -### 1\. Counter-Strike: Global Offensive (Multiplayer) +### 1\. 反恐精英:全球攻势(Counter-Strike: Global Offensive)(多人) -CS GO is definitely one of the best FPS games for Linux on Steam. I don’t think this game needs an introduction but in case you are unaware of it – I must mention that it is one of the most enjoyable FPS multiplayer game you would ever play. You’ll observe CS GO is one of the games contributing a major part to the e-sports scene. To up your rank – you need to play competitive matches. In either case, you can continue playing casual matches. +《CS:GO》毫无疑问是 Steam 上支持 Linux 的最好的 FPS 游戏之一。我觉得这款游戏无需介绍,但如果你没有听说过它,我要告诉你这将会是你玩过的最好玩的多人 FPS 游戏之一。《CS:GO》还是电子竞技中的一个主流项目。想要提升等级的话,你需要在天梯上和其他玩家同台竞技。但你也可以选择更加轻松的休闲模式。 -I could have listed Rainbow Six siege instead of Counter-Strike, but we still don’t have it for Linux/Steam OS. +我本想写《彩虹六号:围攻行动》,但它目前还不支持 Linux 或 Steam OS。 -[CS: GO (Purchase)][15] +[购买《CS: GO》][15] -### 2\. Left 4 Dead 2 (Multiplayer/Singleplayer) +### 2\. 求生之路 2(多人/单机) -One of the most loved first-person zombie shooter multiplayer game. You may get it for as low as 1.3 USD on a Steam sale. It is an interesting game which gives you the chills and thrills you’d expect from a zombie game. The game features swamps, cities, cemetries, and a lot more environments to keep things interesting and horrific. The guns aren’t super techy but definitely provides a realistic experience considering it’s an old game. +这是最受欢迎的僵尸主题多人 FPS 游戏之一。在 Steam 优惠时,价格可以低至 1.3 美元。这是个有趣的游戏,能让你体会到你在僵尸游戏中期待的寒意和紧张感。游戏中的环境包括了沼泽、城市、墓地等等,让游戏既有趣又吓人。游戏中的枪械并不是非常先进,但作为一个老游戏来说,它已经提供了足够真实的体验。 -[Left 4 Dead 2 (Purchase)][16] +[购买《求生之路 2》][16] -### 3\. Borderlands 2 (Singleplayer/Co-op) +### 3\. 无主之地 2(Borderlands 2)(单机/协作) -Borderlands 2 is an interesting take on FPS games for PC. It isn’t anything like you experienced before. The graphics look sketchy and cartoony but that does not let you miss the real action you always look for in a first-person shooter game. You can trust me on that! +《无主之地 2》是个很有意思的 FPS 游戏。它和你以前玩过的游戏完全不同。画风看上去有些诡异和卡通化,但我可以保证,游戏体验可一点也不逊色! -If you are looking for one of the best Linux games with tons of DLC – Borderlands 2 will definitely suffice. +如果你在寻找一个好玩而且有很多 DLC 的 Linux 游戏,《无主之地 2》绝对是个不错的选择。 -[Borderlands 2 (Purchase)][17] +[购买《无主之地 2》][17] -### 4\. Insurgency (Multiplayer) +### 4\. 叛乱(Insurgency)(多人) -Insurgency is yet another impressive FPS game available on Steam for Linux machines. It takes a different approach by eliminating the HUD or the ammo counter. As most of the reviewers mentioned – pure shooting game focusing on the weapon and the tactics of your team. It may not be the best FPS game – but it surely is one of them if you like – Delta Force kinda shooters along with your squad. +《叛乱》是 Steam 上又一款支持 Linux 的优秀的 FPS 游戏。它剑走偏锋,从屏幕上去掉了 HUD 和弹药数量指示。如同许多评论者所说,这是款注重武器和团队战术的纯粹的射击游戏。这也许不是最好的 FPS 游戏,但如果你想玩和《三角洲部队》类似的多人游戏的话,这绝对是最好的游戏之一。 -[Insurgency (Purchase)][18] +[购买《叛乱》][18] -### 5\. Bioshock: Infinite (Singleplayer) +### 5\. 生化奇兵:无限(Bioshock: Infinite)(单机) -Bioshock Infinite would definitely remain as one of the best singleplayer FPS games ever developed for PC. You get unrealistic powers to kill your enemies. And, so do your enemies have a lot of tricks up in the sleeves. It is a story-rich FPS game which you should not miss playing on your Linux system! +《生化奇兵:无限》毫无疑问将会作为 PC 平台最好的单机 FPS 游戏之一而载入史册。你可以利用很多强大的能力来杀死你的敌人。同时你的敌人也各个身怀绝技。游戏的剧情也非常丰富。你不容错过! -[BioShock: Infinite (Purchase)][19] +[购买《生化奇兵:无限》][19] -### 6\. HITMAN – Game of the Year Edition (Singleplayer) +### 6\. 《杀手(年度版)》(HITMAN - Game of the Year Edition)(单机) -The Hitman series is obviously one of the most loved game series for a PC gamer. The recent iteration of HITMAN series saw an episodic release which wasn’t appreciated much but now with Square Enix gone, the GOTY edition announced with a few more additions is back to the spotlight. Make sure to get creative with your assassinations in the game Agent 47! +《杀手》系列无疑是 PC 游戏爱好者们的最爱之一。本系列的最新作开始按章节发布,让很多玩家觉得不满。但现在 Square Enix 撤出了开发,而最新的年度版带着新的内容重返舞台。在游戏中发挥你的想象力暗杀你的目标吧,杀手47! -[HITMAN (GOTY)][20] +[购买(杀手(年度版))][20] -### 7\. Portal 2 +### 7\. 传送门 2 -Portal 2 is the perfect blend of action and adventure. It is a puzzle game which lets you join co-op sessions and create interesting puzzles. The co-op mode features a completely different campaign when compared to the single player mode. +《传送门 2》完美地结合了动作与冒险。这是款解谜类游戏,你可以与其他玩家协作,并开发有趣的谜题。协作模式提供了和单机模式截然不同的游戏内容。 -[Portal 2 (Purchase)][21] +[购买《传送门2》][21] -### 8\. Deux Ex: Mankind Divided +### 8\. 杀出重围:人类分裂 -If you are on the lookout for a shooter game focused on stealth skills – Deux Ex would be the perfect addition to your Steam library. It is indeed a very beautiful game with some state-of-the-art weapons and crazy fighting mechanics. +如果你在寻找隐蔽类的射击游戏,《杀出重围》是个完美的选择。这是个非常华丽的游戏,有着最先进的武器和超乎寻常的战斗机制。 -[Deus Ex: Mankind Divided (Purchase)][22] +[购买《杀出重围:人类分裂》][22] -### 9\. Metro 2033 Redux / Metro Last Light Redux +### 9\. 地铁 2033 重置版(Metro 2033 Redux) / 地铁:最后曙光 重置版(Metro Last Light Redux) -Both Metro 2033 Redux and the Last Light are the definitive editions of the classic hit Metro 2033 and Last Light. The game has a post-apocalyptic setting. You need to eliminate all the mutants in order to ensure the survival of mankind. You should explore the rest when you get to play it! +《地铁 2033 重置版》和《地铁:最后曙光 重置版》是经典的《地铁 2033》和《地铁:最后曙光》的最终版本。故事发生在世界末日之后。你需要消灭所有的变种人来保证人类的生存。剩下的就交给你自己去探索了! -[Metro 2033 Redux (Purchase)][23] +[购买《地铁 2033 重置版》][23] -[Metro Last Light Redux (Purchase)][24] +[购买《地铁:最后曙光 重置版》][24] -### 10\. Tannenberg (Multiplayer) +### 10\. 坦能堡(Tannenberg)(多人) -Tannenberg is a brand new game – announced a month before this article was published. The game is based on the Eastern Front (1914-1918) as a part of World War I. It is a multiplayer-only game. So, if you want to experience WWI gameplay experience, look no further! +《坦能堡》是个全新的游戏 - 在本文发表一个月前刚刚发售。游戏背景是第一次世界大战的东线战场(1914-1918)。这款游戏只有多人模式。如果你想要在游戏中体验第一次世界大战,不要错过这款游戏! -[Tannenberg (Purchase)][25] +[购买《坦能堡》][25] -### Best RPG Games for Linux on Steam +### Steam 上最佳 Linux 角色扮演类游戏 -### 11\. Shadow of Mordor +### 11\. 中土世界:暗影魔多(Shadow of Mordor) -Shadow of Mordor is one of the most exciting open world RPG game you will find listed on Steam for Linux systems. You have to fight as a ranger (Talion) with the bright master (Celebrimbor) to defeat Sauron’s army (and then approach killing him). The fighting mechanics are very impressive. It is a must try game! +《中土世界:暗影魔多》 是 Steam 上支持 Linux 的最好的开放式角色扮演类游戏之一。你将扮演一个游侠(塔里昂),和光明领主(凯勒布理鹏)并肩作战击败索隆的军队(并最终和他直接交手)。战斗机制非常出色。这是款不得不玩的游戏! -[SOM (Purchase)][26] +[购买《中土世界:暗影魔多》][26] -### 12\. Divinity: Original Sin – Enhanced Edition +### 12\. 神界:原罪加强版(Divinity: Original Sin – Enhanced Edition) -Divinity: Original is a kick-ass Indie-RPG game that’s unique in itself and very much enjoyable. It is probably one of the highest rated RPG games with a mixture of Adventure & Strategy. The enhanced edition includes new game modes and a complete revamp of voice-overs, controller support, co-op sessions, and so much more. +《神界:原罪》是一款极其优秀的角色扮演类独立游戏。它非常独特而又引人入胜。这或许是评分最高的带有冒险和策略元素的角色扮演游戏。加强版添加了新的游戏模式,并且完全重做了配音、手柄支持、协作任务等等。 -[Divinity: Original Sin (Purchase)][27] +[购买《神界:原罪加强版》][27] -### 13\. Wasteland 2: Director’s Cut +### 13\. 废土 2:导演剪辑版(Wasteland 2: Director’s Cut) -Wasteland 2 is an amazing CRPG game. If Fallout 4 was to be ported down as a CRPG as well – this is what we would have expected it to be. The director’s cut edition includes a complete visual overhaul with hundred new characters. +《废土 2》是一款出色的 CRPG 游戏。如果《辐射 4》被移植成 CRPG 游戏,大概就是这种感觉。导演剪辑版完全重做了画面,并且增加了一百多名新人物。 -[Wasteland 2 (Purchase)][28] +[购买《废土 2》][28] -### 14\. Darkwood +### 14\. 阴暗森林(Darkwood) -A horror-filled top-down view RPG game. You get to explore the world, scavenging materials, and craft weapons to survive. +一个充满恐怖的俯视角角色扮演类游戏。你将探索世界、搜集材料、制作武器来生存下去。 -[Darkwood (Purchase)][29] +[购买《阴暗森林》][29] -### Best Racing/Sports/Simulation Games +### 最佳赛车 / 运动 / 模拟类游戏 -### 15\. Rocket League +### 15\. 火箭联盟(Rocket League) -Rocket League is an action-packed soccer game conceptualized by rocket-powered battle cars. Not just driving the car and heading to the goal – you can even make your opponents go – kaboom! +《火箭联盟》是一款充满刺激的足球游戏。游戏中你将驾驶用火箭助推的战斗赛车。你不仅是要驾车把球带进对方球门,你甚至还可以让你的对手化为灰烬! -A fantastic sports-action game every gamer must have installed! +这是款超棒的体育动作类游戏,每个游戏爱好者都值得拥有! -[Rocket League (Purchase)][30] +[购买《火箭联盟》][30] -### 16\. Road Redemption +### 16\. 公路救赎(Road Redemption) -Missing Road Rash? Well, Road Redemption will quench your thirst as a spiritual successor to Road Rash. Ofcourse, it is not officially “Road Rash II” – but it is equally enjoyable. If you loved Road Rash, you’ll like it too. +想念《暴力摩托》了?作为它精神上的续作,《公路救赎》可以缓解你的饥渴。当然,这并不是真正的《暴力摩托 2》,但它一样有趣。如果你喜欢《暴力摩托》,你也会喜欢这款游戏。 -[Road Redemption (Purchase)][31] +[购买《公路救赎》][31] -### 17\. Dirt Rally +### 17\. 尘埃拉力赛(Dirt Rally) -Dirt Rally is for the gamers who want to experience off-road and on-road racing game. The visuals are breathtaking and the game is enjoyable with near to perfect driving mechanics. +《尘埃拉力赛》是为想要体验公路和越野赛车的玩家准备的。画面非常有魄力,驾驶手感也近乎完美。 -[Dirt Rally (Purchase)][32] +[购买《尘埃拉力赛》][32] ### 18\. F1 2017 -F1 2017 is yet another impressive car racing game from the developers of Dirt Rally (Codemasters & Feral Interactive). It features all of the iconic F1 racing cars that you need to experience. +《F1 2017》是另一款令人印象深刻的赛车游戏。由《尘埃拉力赛》的开发者 Codemasters & Feral Interactive 制作。游戏中包含了所有标志性的 F1 赛车,值得你去体验。 -[F1 2017 (Purchase)][33] +[购买《F1 2017》][33] -### 19. GRID Autosport +### 19. 超级房车赛:汽车运动(GRID Autosport) -GRID is one of the most underrated car racing games available out there. GRID Autosport is the sequel to GRID 2\. The gameplay seems stunning to me. With even better cars than GRID 2, the GRID Autosport is a recommended racing game for every PC gamer out there. The game also supports a multiplayer mode where you can play with your friends – representing as a team. +《超级房车赛》是最被低估的赛车游戏之一。《超级房车赛:汽车运动》是《超级房车赛》的续作。这款游戏的可玩性令人惊艳。游戏中的赛车也比前作更好。推荐所有的 PC 游戏玩家尝试这款赛车游戏。游戏还支持多人模式,你可以和你的朋友组队参赛。 -[GRID Autosport (Purchase)][34] +[购买《超级房车赛:汽车运动》][34] -### Best Adventure Games +### 最好的冒险游戏 -### 20\. ARK: Survival Evolved +### 20\. 方舟:生存进化(ARK: Survival Evolved) -ARK Survival Evolved is a quite decent survival game with exciting adventures following in the due course. You find yourself in the middle of nowhere (ARK Island) and have got no choice except training the dinosaurs, teaming up with other players, hunt someone to get the required resources, and craft items to maximize your chances to survive and escape the Island. +《方舟:生存进化》是一款不错的生存游戏,里面有着激动人心的冒险。你发现自己身处一个未知孤岛(方舟岛),为了生存下去并逃离这个孤岛,你必须去驯服恐龙、与其他玩家合作、猎杀其他人来抢夺资源、以及制作物品。 -[ARK: Survival Evolved (Purchase)][35] +[购买《方舟:生存进化》][35] -### 21\. This War of Mine +### 21\. 这是我的战争(This War of Mine) -A unique game where you aren’t a soldier but a civilian facing the hardships of wartime. You’ve to make your way through highly-skilled enemies and help out other survivors as well. +一款独特的战争游戏。你不是扮演士兵,而是要作为一个平民来面对战争带来的艰难。你需要在身经百战的敌人手下逃生,并帮助其他的幸存者。 -[This War of Mine (Purchase)][36] +[购买《这是我的战争》][36] -### 22\. Mad Max +### 22\. 疯狂的麦克斯(Mad Max) -Mad Max is all about survival and brutality. It includes powerful cars, an open-world setting, weapons, and hand-to-hand combat. You need to keep exploring the place and also focus on upgrading your vehicle to prepare for the worst. You need to think carefully and have a strategy before you make a decision. +生存和暴力概括了《疯狂的麦克斯》的全部内容。游戏中有性能强大的汽车,开放性的世界,各种武器,以及徒手肉搏。你要不断地探索世界,并注意升级你的汽车来防患于未然。在做决定之前,你要仔细思考并设计好策略。 -[Mad Max (Purchase)][37] +[购买《疯狂的麦克斯》][37] -### Best Indie Games +### 最佳独立游戏 -### 23\. Terraria +### 23\. 泰拉瑞亚(Terraria) -It is a 2D game which has received overwhelmingly positive reviews on Steam. Dig, fight, explore, and build to keep your journey going. The environments are automatically generated. So, it isn’t anything static. You might encounter something first and your friend might encounter the same after a while. You’ll also get to experience creative 2D action-packed sequences. +这是款在 Steam 上广受好评的 2D 游戏。你在旅途中需要去挖掘、战斗、探索、建造。游戏地图是自动生成的,而不是静止的。也许你刚刚遇到的东西,你的朋友过一会儿才会遇到。你还将体验到富有新意的 2D 动作场景。 -[Terraria (Purchase)][38] +[购买《泰拉瑞亚》][38] -### 24\. Kingdoms and Castles +### 24\. 王国与城堡(Kingdoms and Castles) -With Kingdoms and Castles, you get to build your own kingdom. You have to manage your kingdom by collecting tax (as funds necessary) from the people, take care of the forests, handle the city +在《王国与城堡》中,你将建造你自己的王国。在管理你的王国的过程中,你需要收税、保护森林、规划城市,并且发展国防来防止别人入侵你的王国。 -design, and also make sure no one raids your kingdom by implementing proper defences. +这是款比较新的游戏,但在独立游戏中已经相对获得了比较高的人气。 -It is a fairly new game but quite trending among the Indie genre of games. +[购买《王国与城堡》][39] -[Kingdoms and Castles][39] +### Steam 上最佳 Linux 策略类游戏 -### Best Strategy Games on Steam For Linux Machines +### 25\. 文明 5(Sid Meier’s Civilization V) -### 25\. Sid Meier’s Civilization V +《文明 5》是 PC 上评价最高的策略游戏之一。如果你想的话,你可以去玩《文明 6》。但是依然有许多玩家喜欢《文明 5》,觉得它更有独创性,游戏细节也更富有创造力。 -Sid Meier’s Civilization V is one of the best-rated strategy game available for PC. You could opt for Civilization VI – if you want. But, the gamers still root for Sid Meier’s Civilization V because of its originality and creative implementation. +[购买《文明 5》][40] -[Civilization V (Purchase)][40] +### 26\. 全面战争:战锤(Total War: Warhammer) -### 26\. Total War: Warhammer +《全面战争:战锤》是 PC 平台上一款非常出色的回合制策略游戏。可惜的是,新作《战锤 2》依然不支持Linux。但如果你喜欢使用飞龙和魔法来建造与毁灭帝国的话,2016 年的《战锤》依然是个不错的选择。 -Total War: Warhammer is an incredible turn-based strategy game available for PC. Sadly, the Warhammer II isn’t available for Linux as of yet. But 2016’s Warhammer is still a great choice if you like real-time battles that involve building/destroying empires with flying creatures and magical powers. +[购买《全面战争:战锤》][41] -[Warhammer I (Purchase)][41] +### 27\. 轰炸小队《Bomber Crew》 -### 27\. Bomber Crew +想要一款充满乐趣的策略游戏?《轰炸小队》就是为你准备的。你需要选择合适的队员并且让你的队伍稳定运转来取得最终的胜利。 -Wanted a strategy simulation game that’s equally fun to play? Bomber Crew is the answer to it. You need to choose the right crew and maintain it in order to win it all. +[购买《轰炸小队》][42] -[Bomber Crew (Purchase)][42] +### 28\. 奇迹时代 3(Age of Wonders III) -### 28\. Age of Wonders III +非常流行的策略游戏,包含帝国建造、角色扮演、以及战争元素。这是款精致的回合制策略游戏,请一定要试试! -A very popular strategy title with a mixture of empire building, role playing, and warfare. A polished turn-based strategy game you must try! +[购买《奇迹时代 3》][43] -[Age of Wonders III (Purchase)][43] +### 29\. 城市:天际线(Cities: Skylines) -### 29\. Cities: Skylines +一款非常简洁的游戏。你要从零开始建造一座城市,并且管理它的全部运作。你将体验建造和管理城市带来的愉悦与困难。我不觉得每个玩家都会喜欢这款游戏——它的用户群体非常明确。 -A pretty straightforward strategy game to build a city from scratch and manage everything in it. You’ll experience the thrills and hardships of building and maintaining a city. I wouldn’t expect every gamer to like this game – it has a very specific userbase. +[购买《城市:天际线》][44] -[Cities: Skylines (Purchase)][44] +### 30\. 幽浮 2(XCOM 2) -### 30\. XCOM 2 +《幽浮 2》是 PC 上最好的回合制策略游戏之一。我在想如果《幽浮 2》能够被制作成 FPS 游戏的话该有多棒。不过它现在已经是一款好评如潮的杰作了。如果你有多余的预算能花在这款游戏上,建议你购买“天选之战(War of the Chosen)“ DLC。 -XCOM 2 is one of the best turn-based strategy game available for PC. I wonder how crazy it could have been to have XCOM 2 as a first person shooter game. However, it’s still a masterpiece with an overwhelming response from almost everyone who bought the game. If you have the budget to spend more on this game, do get the – “War of the Chosen” – DLC. +[购买《幽浮 2》][45] -[XCOM 2 (Purchase)][45] +### 总结 -### Wrapping Up +我们从所有支持 Linux 的游戏中挑选了大部分的主流大作以及一些评价很高的新作。 -Among all the games available for Linux, we did include most of the major titles and some the latest games with an overwhelming response from the gamers. +你觉得我们遗漏了你最喜欢的支持 Linux 的 Steam 游戏么?另外,你还希望哪些 Steam 游戏开始支持 Linux 平台? -Do you think we missed any of your favorite Linux game available on Steam? Also, what are the games that you would like to see on Steam for Linux platform? - -Let us know your thoughts in the comments below. +请在下面的回复中告诉我们你的想法。 -------------------------------------------------------------------------------- via: https://itsfoss.com/best-linux-games-steam/ 作者:[Ankush Das][a] -译者:[译者ID](https://github.com/译者ID) +译者:[yixunx](https://github.com/yixunx) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 40603fd2d9115fb502aa45e6f5be9d7c7f9aa6b8 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 7 Dec 2017 08:58:45 +0800 Subject: [PATCH 323/344] translated --- ...Long Running Terminal Commands Complete.md | 156 ------------------ ...Long Running Terminal Commands Complete.md | 154 +++++++++++++++++ 2 files changed, 154 insertions(+), 156 deletions(-) delete mode 100644 sources/tech/20171130 Undistract-me_Get Notification When Long Running Terminal Commands Complete.md create mode 100644 translated/tech/20171130 Undistract-me_Get Notification When Long Running Terminal Commands Complete.md diff --git a/sources/tech/20171130 Undistract-me_Get Notification When Long Running Terminal Commands Complete.md b/sources/tech/20171130 Undistract-me_Get Notification When Long Running Terminal Commands Complete.md deleted file mode 100644 index 46afe9b893..0000000000 --- a/sources/tech/20171130 Undistract-me_Get Notification When Long Running Terminal Commands Complete.md +++ /dev/null @@ -1,156 +0,0 @@ -translating---geekpi - -Undistract-me : Get Notification When Long Running Terminal Commands Complete -============================================================ - -by [sk][2] · November 30, 2017 - -![Undistract-me](https://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2-720x340.png) - -A while ago, we published how to [get notification when a Terminal activity is done][3]. Today, I found out a similar utility called “undistract-me” that notifies you when long running terminal commands complete. Picture this scenario. You run a command that takes a while to finish. In the mean time, you check your facebook and get so involved in it. After a while, you remembered that you ran a command few minutes ago. You go back to the Terminal and notice that the command has already finished. But you have no idea when the command is completed. Have you ever been in this situation? I bet most of you were in this situation many times. This is where “undistract-me” comes in help. You don’t need to constantly check the terminal to see if a command is completed or not. Undistract-me utility will notify you when a long running command is completed. It will work on Arch Linux, Debian, Ubuntu and other Ubuntu-derivatives. - -#### Installing Undistract-me - -Undistract-me is available in the default repositories of Debian and its variants such as Ubuntu. All you have to do is to run the following command to install it. - -``` -sudo apt-get install undistract-me -``` - -The Arch Linux users can install it from AUR using any helper programs. - -Using [Pacaur][4]: - -``` -pacaur -S undistract-me-git -``` - -Using [Packer][5]: - -``` -packer -S undistract-me-git -``` - -Using [Yaourt][6]: - -``` -yaourt -S undistract-me-git -``` - -Then, run the following command to add “undistract-me” to your Bash. - -``` -echo 'source /etc/profile.d/undistract-me.sh' >> ~/.bashrc -``` - -Alternatively you can run this command to add it to your Bash: - -``` -echo "source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install" >> .bashrc -``` - -If you are in Zsh shell, run this command: - -``` -echo "source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install" >> .zshrc -``` - -Finally update the changes: - -For Bash: - -``` -source ~/.bashrc -``` - -For Zsh: - -``` -source ~/.zshrc -``` - -#### Configure Undistract-me - -By default, Undistract-me will consider any command that takes more than 10 seconds to complete as a long-running command. You can change this time interval by editing /usr/share/undistract-me/long-running.bash file. - -``` -sudo nano /usr/share/undistract-me/long-running.bash -``` - -Find “LONG_RUNNING_COMMAND_TIMEOUT” variable and change the default value (10 seconds) to something else of your choice. - - [![](http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-1.png)][7] - -Save and close the file. Do not forget to update the changes: - -``` -source ~/.bashrc -``` - -Also, you can disable notifications for particular commands. To do so, find the “LONG_RUNNING_IGNORE_LIST” variable and add the commands space-separated like below. - -By default, the notification will only show if the active window is not the window the command is running in. That means, it will notify you only if the command is running in the background Terminal window. If the command is running in active window Terminal, you will not be notified. If you want undistract-me to send notifications either the Terminal window is visible or in the background, you can set IGNORE_WINDOW_CHECK to 1 to skip the window check. - -The other cool feature of Undistract-me is you can set audio notification along with visual notification when a command is done. By default, it will only send a visual notification. You can change this behavior by setting the variable UDM_PLAY_SOUND to a non-zero integer on the command line. However, your Ubuntu system should have pulseaudio-utils and sound-theme-freedesktop utilities installed to enable this functionality. - -Please remember that you need to run the following command to update the changes made. - -For Bash: - -``` -source ~/.bashrc -``` - -For Zsh: - -``` -source ~/.zshrc -``` - -It is time to verify if this really works. - -#### Get Notification When Long Running Terminal Commands Complete - -Now, run any command that takes longer than 10 seconds or the time duration you defined in Undistract-me script. - -I ran the following command on my Arch Linux desktop. - -``` -sudo pacman -Sy -``` - -This command took 32 seconds to complete. After the completion of the above command, I got the following notification. - - [![](http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2.png)][8] - -Please remember Undistract-me script notifies you only if the given command took more than 10 seconds to complete. If the command is completed in less than 10 seconds, you will not be notified. Of course, you can change this time interval settings as I described in the Configuration section above. - -I find this tool very useful. It helped me to get back to the business after I completely lost in some other tasks. I hope this tool will be helpful to you too. - -More good stuffs to come. Stay tuned! - -Cheers! - -Resource: - -* [Undistract-me GitHub Repository][1] - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/undistract-get-notification-long-running-terminal-commands-complete/ - -作者:[sk][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.ostechnix.com/author/sk/ -[1]:https://github.com/jml/undistract-me -[2]:https://www.ostechnix.com/author/sk/ -[3]:https://www.ostechnix.com/get-notification-terminal-task-done/ -[4]:https://www.ostechnix.com/install-pacaur-arch-linux/ -[5]:https://www.ostechnix.com/install-packer-arch-linux-2/ -[6]:https://www.ostechnix.com/install-yaourt-arch-linux/ -[7]:http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-1.png -[8]:http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2.png diff --git a/translated/tech/20171130 Undistract-me_Get Notification When Long Running Terminal Commands Complete.md b/translated/tech/20171130 Undistract-me_Get Notification When Long Running Terminal Commands Complete.md new file mode 100644 index 0000000000..26a087d440 --- /dev/null +++ b/translated/tech/20171130 Undistract-me_Get Notification When Long Running Terminal Commands Complete.md @@ -0,0 +1,154 @@ +Undistract-me:当长时间运行的终端命令完成时获取通知 +============================================================ + +作者:[sk][2],时间:2017.11.30 + +![Undistract-me](https://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2-720x340.png) + +前一段时间,我们发表了如何[在终端活动完成时获取通知][3]。今天,我发现了一个叫做 “undistract-me” 的类似工具,它可以在长时间运行的终端命令完成时通知你。想象这个场景。你运行着一个需要一段时间才能完成的命令。与此同时,你查看你的 Facebook,并参与其中。过了一会儿,你记得你几分钟前执行了一个命令。你回到终端,注意到这个命令已经完成了。但是你不知道命令何时完成。你有没有遇到这种情况?我敢打赌,你们大多数人遇到过许多次这种情况。这就是 “undistract-me” 能帮助的了。你不需要经常检查终端,查看命令是否完成。长时间运行的命令完成后,undistract-me 会通知你。它能在 Arch Linux、Debian、Ubuntu 和其他 Ubuntu 衍生版上运行。 + +#### 安装 Undistract-me + +Undistract-me 可以在 Debian 及其衍生版(如 Ubuntu)的默认仓库中使用。你要做的就是运行下面的命令来安装它。 + +``` +sudo apt-get install undistract-me +``` + +Arch Linux 用户可以使用任何帮助程序从 AUR 安装它。 + +使用 [Pacaur][4]: + +``` +pacaur -S undistract-me-git +``` + +使用 [Packer][5]: + +``` +packer -S undistract-me-git +``` + +使用 [Yaourt][6]: + +``` +yaourt -S undistract-me-git +``` + +然后,运行以下命令将 “undistract-me” 添加到 Bash 中。 + +``` +echo 'source /etc/profile.d/undistract-me.sh' >> ~/.bashrc +``` + +或者,你可以运行此命令将其添加到你的 Bash: + +``` +echo "source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install" >> .bashrc +``` + +如果你在 Zsh shell 中,请运行以下命令: + +``` +echo "source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install" >> .zshrc +``` + +最后更新更改: + +对于 Bash: + +``` +source ~/.bashrc +``` + +对于 Zsh: + +``` +source ~/.zshrc +``` + +#### 配置 Undistract-me + +默认情况下,Undistract-me 会将任何超过 10 秒的命令视为长时间运行的命令。你可以通过编辑 /usr/share/undistract-me/long-running.bash 来更改此时间间隔。 + +``` +sudo nano /usr/share/undistract-me/long-running.bash +``` + +找到 “LONG_RUNNING_COMMAND_TIMEOUT” 变量并将默认值(10 秒)更改为你所选择的其他值。 + + [![](http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-1.png)][7] + +保存并关闭文件。不要忘记更新更改: + +``` +source ~/.bashrc +``` + +此外,你可以禁用特定命令的通知。为此,找到 “LONG_RUNNING_IGNORE_LIST” 变量并像下面那样用空格分隔命令。 + +默认情况下,只有当活动窗口不是命令运行的窗口时才会显示通知。也就是说,只有当命令在后台“终端”窗口中运行时,它才会通知你。如果该命令在活动窗口终端中运行,则不会收到通知。如果你希望无论终端窗口可见还是在后台都发送通知,你可以将 IGNORE_WINDOW_CHECK 设置为 1 以跳过窗口检查。 + +Undistract-me 的另一个很酷的功能是当命令完成时,你可以设置音频通知和可视通知。默认情况下,它只会发送一个可视通知。你可以通过在命令行上将变量 UDM_PLAY_SOUND 设置为非零整数来更改此行为。但是,你的 Ubuntu 系统应该安装 pulseaudio-utils 和 sound-theme-freedesktop 程序来启用此功能。 + +请记住,你需要运行以下命令来更新所做的更改。 + +对于 Bash: + +``` +source ~/.bashrc +``` + +对于 Zsh: + +``` +source ~/.zshrc +``` + +现在是时候来验证这是否真的有效。 + +#### 在长时间运行的终端命令完成时获取通知 + +现在,运行任何需要超过 10 秒或者你在 Undistract-me 脚本中定义的时间的命令 + +我在 Arch Linux 桌面上运行以下命令。 + +``` +sudo pacman -Sy +``` + +这个命令花了 32 秒完成。上述命令完成后,我收到以下通知。 + + [![](http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2.png)][8] + +请记住,只有当给定的命令花了超过 10 秒才能完成,Undistract-me 脚本才会通知你。如果命令在 10 秒内完成,你将不会收到通知。当然,你可以按照上面的“配置”部分所述更改此时间间隔设置。 + +我发现这个工具非常有用。在我迷失在其他任务上时,它帮助我回到正事。我希望这个工具也能对你有帮助。 + +还有更多的工具。保持耐心! + +干杯! + +资源: + +* [Undistract-me GitHub 仓库][1] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/undistract-get-notification-long-running-terminal-commands-complete/ + +作者:[sk][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://github.com/jml/undistract-me +[2]:https://www.ostechnix.com/author/sk/ +[3]:https://www.ostechnix.com/get-notification-terminal-task-done/ +[4]:https://www.ostechnix.com/install-pacaur-arch-linux/ +[5]:https://www.ostechnix.com/install-packer-arch-linux-2/ +[6]:https://www.ostechnix.com/install-yaourt-arch-linux/ +[7]:http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-1.png +[8]:http://www.ostechnix.com/wp-content/uploads/2017/11/undistract-me-2.png From fe8423d9ceeac4937cf7afa33c3855929190ca0e Mon Sep 17 00:00:00 2001 From: Yixun Xu Date: Wed, 6 Dec 2017 20:00:27 -0500 Subject: [PATCH 324/344] move --- ...171204 30 Best Linux Games On Steam You Should Play in 2017.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources => translated}/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md (100%) diff --git a/sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md b/translated/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md similarity index 100% rename from sources/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md rename to translated/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md From bf1ea7f4add16a5c401bfb48c2a29162673fe2bf Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 7 Dec 2017 09:03:21 +0800 Subject: [PATCH 325/344] translating --- ...ring Back Ubuntus Unity from the Dead as an Official Spin.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md b/sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md index 0e38373c3f..d50a3cdfc5 100644 --- a/sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md +++ b/sources/tech/20171129 Someone Tries to Bring Back Ubuntus Unity from the Dead as an Official Spin.md @@ -1,3 +1,5 @@ +translating---geekpi + Someone Tries to Bring Back Ubuntu's Unity from the Dead as an Official Spin ============================================================ From fce8b5278170fab547440db18d8ae42074993826 Mon Sep 17 00:00:00 2001 From: Yixun Xu Date: Wed, 6 Dec 2017 20:18:29 -0500 Subject: [PATCH 326/344] translation request: Love Your Bugs --- sources/tech/20171112 Love Your Bugs.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171112 Love Your Bugs.md b/sources/tech/20171112 Love Your Bugs.md index bf79f27cf7..0404875a25 100644 --- a/sources/tech/20171112 Love Your Bugs.md +++ b/sources/tech/20171112 Love Your Bugs.md @@ -1,3 +1,5 @@ +yixunx translating + Love Your Bugs ============================================================ From eead636c96ef94637dfd3f1d2b2b1afa0f9862ea Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 7 Dec 2017 09:36:04 +0800 Subject: [PATCH 327/344] PRF:20171120 Mark McIntyre How Do You Fedora.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @zrszrszrs 恭喜你,完成了第一篇翻译! --- ...0171120 Mark McIntyre How Do You Fedora.md | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/translated/tech/20171120 Mark McIntyre How Do You Fedora.md b/translated/tech/20171120 Mark McIntyre How Do You Fedora.md index 4fe315eb07..3ce32fd266 100644 --- a/translated/tech/20171120 Mark McIntyre How Do You Fedora.md +++ b/translated/tech/20171120 Mark McIntyre How Do You Fedora.md @@ -1,43 +1,43 @@ -# [Mark McIntyre: 你是如何使用Fedora的?][1] - +Mark McIntyre:与 Fedora 的那些事 +=========================== ![](https://fedoramagazine.org/wp-content/uploads/2017/11/mock-couch-945w-945x400.jpg) -最近我们采访了 Mark McIntyre,谈了他是如何使用 Fedora 系统的。这也是 Fedora 杂志上[本系列的一部分][2]。该系列简要介绍了 Fedora 用户,以及他们是如何用 Fedora 把事情做好的。通过[反馈表][3]与我们联系,表达你想成为采访对象的意愿。 +最近我们采访了 Mark McIntyre,谈了他是如何使用 Fedora 系统的。这也是 Fedora 杂志上[系列文章的一部分][2]。该系列简要介绍了 Fedora 用户,以及他们是如何用 Fedora 把事情做好的。如果你想成为采访对象,请通过[反馈表][3]与我们联系。 ### Mark McIntyre 是谁? -Mark McIntyre 是一个天生的极客,后天的 Linux 爱好者。他说:“我在 13 岁开始编程,当时自学 BASIC 语言,我体会到其中的乐趣,并在乐趣的引导下,一步步成为专业的码农。”Mark 和他的侄女都是披萨饼的死忠粉。“去年秋天,我和我的侄女尽可能多地光顾了诺克斯维尔的披萨饼连锁店。 点击 [https://knox-pizza-quest.blogspot.com/][4] 可以了解我们的进展情况。”Mark 也是一名业余的摄影爱好者,并且在 Flickr 上 [发布自己的作品][5]。 +Mark McIntyre 为极客而生,以 Linux 为乐趣。他说:“我在 13 岁开始编程,当时自学 BASIC 语言,我体会到其中的乐趣,并在乐趣的引导下,一步步成为专业的码农。” Mark 和他的侄女都是披萨饼的死忠粉。“去年秋天,我和我的侄女开始了一个任务,去尝试诺克斯维尔的许多披萨饼连锁店。点击[这里][4]可以了解我们的进展情况。”Mark 也是一名业余的摄影爱好者,并且在 Flickr 上 [发布自己的作品][5]。 ![](https://fedoramagazine.org/wp-content/uploads/2017/11/31456893222_553b3cac4d_k-1024x575.jpg) -作为一名开发者,Mark 有着丰富的工作背景。他用过 Visual Basic 编写应用程序,用过 LotusScript、 PL/SQL(Oracle)、 Tcl/TK 编写代码,也用过基于 Python 的 Django 框架。他的强项是 Python。这也是目前他作为系统工程师的工作语言。“我用 Python 比较规律。但当我的工作变得更像是自动化工程师时, Python 用得就更频繁了。” +作为一名开发者,Mark 有着丰富的工作背景。他用过 Visual Basic 编写应用程序,用过 LotusScript、 PL/SQL(Oracle)、 Tcl/TK 编写代码,也用过基于 Python 的 Django 框架。他的强项是 Python。这也是目前他作为系统工程师的工作语言。“我经常使用 Python。由于我的工作变得更像是自动化工程师, Python 用得就更频繁了。” -McIntyre 自称是个书呆子,喜欢科幻电影,但他最喜欢的一部电影却不是科幻片。“尽管我是个书呆子,喜欢看《星际迷航》、《星球大战》之类的影片,但《光荣战役》或许才是我最喜欢的电影。”他还提到,电影《冲出宁静号》实属著名电视剧《萤火虫》的精彩后续。 +McIntyre 自称是个书呆子,喜欢科幻电影,但他最喜欢的一部电影却不是科幻片。“尽管我是个书呆子,喜欢看《星际迷航Star Trek》、《星球大战Star Wars》之类的影片,但《光荣战役Glory》或许才是我最喜欢的电影。”他还提到,电影《冲出宁静号Serenity》是一个著名电视剧的精彩后续(指《萤火虫》)。 Mark 比较看重他人的谦逊、知识与和气。他欣赏能够设身处地为他人着想的人。“如果你决定为另一个人服务,那么你会选择自己愿意亲近的人,而不是让自己备受折磨的人。” -McIntyre 目前在 [Scripps Networks Interactive][6] 工作,这家公司是 HGTV、Food Network、Travel Channel、DIY、GAC 以及其他几个有线电视频道的母公司。“我现在是一名系统工程师,负责非线性视频内容,这是全部媒体开展线上消费的计划。”他支持一些开发团队编写应用程序,将线性视频从有线电视发布到线上平台,比如亚马逊、葫芦。这些系统既包含预置系统,也包含云系统。Mark 还开发了一些自动化工具,将这些应用程序主要部署到云基础结构中。 +McIntyre 目前在 [Scripps Networks Interactive][6] 工作,这家公司是 HGTV、Food Network、Travel Channel、DIY、GAC 以及其他几个有线电视频道的母公司。“我现在是一名系统工程师,负责非线性视频内容,这是所有媒体要开展线上消费所需要的。”他为一些开发团队提供支持,他们编写应用程序,将线性视频从有线电视发布到线上平台,比如亚马逊、葫芦。这些系统既包含预置系统,也包含云系统。Mark 还开发了一些自动化工具,将这些应用程序主要部署到云基础结构中。 ### Fedora 社区 -Mark 形容 Fedora 社区是一个富有活力的社区,充满着像 Fedora 用户一样热爱生活的人。“从设计师到包装师,这个团体依然非常活跃,生机勃勃。” 他继续说道:“这使我对操作系统抱有一种信心。” +Mark 形容 Fedora 社区是一个富有活力的社区,充满着像 Fedora 用户一样热爱生活的人。“从设计师到封包人,这个团体依然非常活跃,生机勃勃。” 他继续说道:“这使我对该操作系统抱有一种信心。” -2002年左右,Mark 开始经常使用 IRC 上的 #fedora 频道:“那时候,Wi-Fi 在启用适配器和配置模块功能时,有许多还是靠手工实现的。”为了让他的 Wi-Fi 能够工作,他不得不重新去编译 Fedora 内核。 +2002 年左右,Mark 开始经常使用 IRC 上的 #fedora 频道:“那时候,Wi-Fi 在启用适配器和配置模块功能时,有许多还是靠手工实现的。”为了让他的 Wi-Fi 能够工作,他不得不重新去编译 Fedora 内核。 -McIntyre 鼓励他人参与 Fedora 社区。“这里有许多来自不同领域的机会。前端设计、测试部署、开发、应用程序包装以及新型技术实现。”他建议选择一个感兴趣的领域,然后向那个团体提出疑问。“这里有许多机会去奉献自己。” +McIntyre 鼓励他人参与 Fedora 社区。“这里有许多来自不同领域的机会。前端设计、测试部署、开发、应用程序打包以及新技术实现。”他建议选择一个感兴趣的领域,然后向那个团体提出疑问。“这里有许多机会去奉献自己。” -对于帮助他起步的社区成员,Mark 赞道:“Ben Williams 非常乐于助人。在我第一次接触 Fedora 时,他帮我搞定了一些 #fedora 支持频道中的安装补丁。” Ben 也鼓励 Mark 去做 Fedora [代表][7]。 +对于帮助他起步的社区成员,Mark 赞道:“Ben Williams 非常乐于助人。在我第一次接触 Fedora 时,他帮我搞定了一些 #fedora 支持频道中的安装补丁。” Ben 也鼓励 Mark 去做 Fedora [大使][7]。 ### 什么样的硬件和软件? -McIntyre 将 Fedora Linux 系统用在他的笔记本和台式机上。在服务器上他选择了 CentOS,因为它有更长的生命周期支持。他现在的台式机是自己组装的,配有 Intel 酷睿 i5 处理器,32GB 的内存和2TB 的硬盘。“我装了个 4K 的显示屏,有足够大的,地方来同时查看所有的应用。”他目前工作用的笔记本是戴尔灵越二合一,配备 13 英寸的屏,16 GB 的内存和 525 GB 的 m.2 固态硬盘。 +McIntyre 将 Fedora Linux 系统用在他的笔记本和台式机上。在服务器上他选择了 CentOS,因为它有更长的生命周期支持。他现在的台式机是自己组装的,配有 Intel 酷睿 i5 处理器,32GB 的内存和2TB 的硬盘。“我装了个 4K 的显示屏,有足够大的地方来同时查看所有的应用。”他目前工作用的笔记本是戴尔灵越二合一,配备 13 英寸的屏,16 GB 的内存和 525 GB 的 m.2 固态硬盘。 ![](https://fedoramagazine.org/wp-content/uploads/2017/11/Screenshot-from-2017-10-26-08-51-41-1024x640.png) -Mark 现在将 Fedora 26 运行在他过去几个月装配的所有盒子中。当一个新版本正式发布的时候,他倾向于避开这个高峰期。“除非在它即将发行的时候,我的工作站中有个正在运行下一代测试版本,通常情况下,一旦它发展成熟,我都会试着去获取最新的版本。”他经常采取就地更新:“这种就地更新方法利用 dnf 系统升级插件,目前表现得非常好。” +Mark 现在将 Fedora 26 运行在他过去几个月装配的所有机器中。当一个新版本正式发布的时候,他倾向于避开这个高峰期。“除非在它即将发行的时候,我的工作站中有个正在运行下一代测试版本,通常情况下,一旦它发展成熟,我都会试着去获取最新的版本。”他经常采取就地更新:“这种就地更新方法利用 dnf 系统升级插件,目前表现得非常好。” -为了搞摄影,McIntyre 用上了 [GIMP][8]、[Darktable][9],以及其他一些照片查看包和快速编辑包。当不启用网络电子邮件时,Mark 会使用 [Geary][10],还有[GNOME Calendar][11]。Mark 选用 HexChat 作为 IRC 客户端,[HexChat][12] 与在 Fedora 服务器实例上运行的 [ZNC bouncer][13] 联机。他的部门通过 Slave 进行沟通交流。 +为了搞摄影,McIntyre 用上了 [GIMP][8]、[Darktable][9],以及其他一些照片查看包和快速编辑包。当不用 Web 电子邮件时,Mark 会使用 [Geary][10],还有[GNOME Calendar][11]。Mark 选用 HexChat 作为 IRC 客户端,[HexChat][12] 与在 Fedora 服务器实例上运行的 [ZNC bouncer][13] 联机。他的部门通过 Slave 进行沟通交流。 “我从来都不是 IDE 粉,所以大多数的编辑任务都是在 [vim][14] 上完成的。”Mark 偶尔也会打开一个简单的文本编辑器,如 [gedit][15],或者 [xed][16]。他用 [GPaste][17] 做复制和粘贴工作。“对于终端的选择,我已经变成 [Tilix][18] 的忠粉。”McIntyre 通过 [Rhythmbox][19] 来管理他喜欢的播客,并用 [Epiphany][20] 实现快速网络查询。 @@ -46,8 +46,8 @@ Mark 现在将 Fedora 26 运行在他过去几个月装配的所有盒子中。 via: https://fedoramagazine.org/mark-mcintyre-fedora/ 作者:[Charles Profitt][a] -译者:[zrszrs](https://github.com/zrszrszrs) -校对:[校对者ID](https://github.com/校对者ID) +译者:[zrszrszrs](https://github.com/zrszrszrs) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From a27c82b2254cb4f264df4785c3fd8d9be00b651a Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 7 Dec 2017 09:36:45 +0800 Subject: [PATCH 328/344] PUB:20171120 Mark McIntyre How Do You Fedora.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @zrszrszrs 文章发布地址:https://linux.cn/article-9119-1.html 你的 LCTT 专页地址:https://linux.cn/lctt/zrszrszrs --- .../20171120 Mark McIntyre How Do You Fedora.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171120 Mark McIntyre How Do You Fedora.md (100%) diff --git a/translated/tech/20171120 Mark McIntyre How Do You Fedora.md b/published/20171120 Mark McIntyre How Do You Fedora.md similarity index 100% rename from translated/tech/20171120 Mark McIntyre How Do You Fedora.md rename to published/20171120 Mark McIntyre How Do You Fedora.md From 9523efd34a083f9f9066333ef1ee7b6116d7c9e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=91=E9=AD=85=E9=AD=8D=E9=AD=89?= <625310581@qq.com> Date: Thu, 7 Dec 2017 10:10:32 +0800 Subject: [PATCH 329/344] apply for translation --- .../tech/20170921 How to answer questions in a helpful way.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20170921 How to answer questions in a helpful way.md b/sources/tech/20170921 How to answer questions in a helpful way.md index 8a3601ed06..31d6be1046 100644 --- a/sources/tech/20170921 How to answer questions in a helpful way.md +++ b/sources/tech/20170921 How to answer questions in a helpful way.md @@ -1,3 +1,6 @@ + +translating by HardworkFish + How to answer questions in a helpful way ============================================================ From 9364f777e7f16c425f77b4f0370191243eb1c993 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Thu, 7 Dec 2017 11:35:31 +0800 Subject: [PATCH 330/344] Translated by qhwdw --- ...Best Network Monitoring Tools For Linux.md | 188 ------------------ ...Best Network Monitoring Tools For Linux.md | 127 ++++++++++++ 2 files changed, 127 insertions(+), 188 deletions(-) delete mode 100644 sources/tech/20171203 Best Network Monitoring Tools For Linux.md create mode 100644 translated/tech/20171203 Best Network Monitoring Tools For Linux.md diff --git a/sources/tech/20171203 Best Network Monitoring Tools For Linux.md b/sources/tech/20171203 Best Network Monitoring Tools For Linux.md deleted file mode 100644 index aec39b9822..0000000000 --- a/sources/tech/20171203 Best Network Monitoring Tools For Linux.md +++ /dev/null @@ -1,188 +0,0 @@ -Best Network Monitoring Tools For Linux -=============================== - - -Keeping control of our network is vital to prevent any program from overusing it and slows down the overall system operation. There are several - -**network monitoring tools** - -for different operating systems today. In this article, we will talk about - -**10 network monitoring tools for Linux** - -that will run from a terminal, ideal for users who do not use GUI or for those who want to keep a control of the network use of a server through from ssh. - -### Iftop - - [![iftop network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iftop_orig.png)][2] - -Linux users are generally familiar with Top. This tool is a system monitor that allows us to know in real time all the processes that are running in our system and can manage them easily. Iftop is an application similar to Top but specialized in the monitoring of the network, being able to know a multitude of details regarding the network and all the processes that are making use of it. - -We can obtain more information about this tool and download the necessary packages from the - -[following link][3] - -. - -### Vnstat - - [![vnstat network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/editor/vnstat.png?1511885309)][4] **Vnstat** - -is a network monitor that is included, by default, in most Linux distributions. It allows us to obtain a real-time control of the traffic sent and received in a period of time, chosen by the user. - -​ - -We can obtain more information about this tool and download the necessary packages from the - -[following link.][5] - -### Iptraf - - [![iptraf monitoring tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iptraf_orig.gif)][6] **IPTraf** - -is a console-based, real-time network monitoring utility for Linux. (IP LAN) - Collects a wide variety of information as an IP traffic monitor that passes through the network, including TCP flags information, ICMP details, TCP / UDP traffic faults, TCP connection packet and Byne account. It also collects statistics information from the general and detailed interface of TCP, UDP,,, checksum errors IP not IP ICMP IP, interface activity, etc. - -​ - -We can obtain more information about this tool and download the necessary packages from the - -[following link.][7] - -### Monitorix - System and Monitoring Network - - [![monitorix system monitoring tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/monitorix_orig.png)][8] - -Monitorix is a lightweight free utility that is designed to run and monitor system and network resources with as many Linux / Unix servers as possible. An HTTP web server has been added that regularly collects system and network information and displays them in the graphs. It will track the average system load and its usage, memory allocation, disk health, system services, network ports, mail statistics (Sendmail, Postfix, Dovecot, etc.), MySQL statistics and many more. It is designed to control the overall performance of the system and helps in detecting faults, bottlenecks, abnormal activities, etc. - -​ - -Download and more - -[information here][9] - -. - -### Dstat - - [![dstat network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/dstat_orig.png)][10] - -A monitor is somewhat less known than the previous ones but also usually comes by default in many distributions. - -​ - -We can obtain more information about this tool and download the necessary packages from the - -[following link][11] - -. - -### Bwm-ng - - [![bwm-ng monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/bwm-ng_orig.png)][12] - -One of the simplest tools. It allows you to get data from the connection interactively and, at the same time, export them to a certain format for easier reference on another device. - -​ - -We can obtain more information about this tool and download the necessary packages from the - -[following link][13] - -. - -### Ibmonitor - - [![ibmonitor tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/ibmonitor_orig.jpg)][14] - -Similar to the above, it shows network traffic filtered by connection interface and clearly separates the traffic sent from the received traffic. - -​ - -We can obtain more information about this tool and download the necessary packages from the - -[following link​][15] - -. - -### Htop - Linux Process Tracking - - [![htop linux processes monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/htop_orig.png)][16] - -Htop is a much more advanced, interactive and real-time Linux tool for tracking processes. It is similar to the top Linux command but has some advanced features such as an easy-to-use interface for process management, shortcut keys, vertical and horizontal view of processes and much more. Htop is a third-party tool and is not included on Linux systems, you must install it using - -**YUM** - -(or - -**APT-GET)** - -or whatever your package management tool. For more information on installation, read - -[this article][17] - -. - -We can obtain more information about this tool and download the necessary packages from the - -[following link.][18] - -### Arpwatch - Ethernet Activity Monitor - - [![arpwatch ethernet monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/arpwatch_orig.png)][19] - -Arpwatch is a program that is designed to control the resolution of addresses (MAC and changes in the IP address) of Ethernet network traffic in a Linux network. It is continuously monitoring the Ethernet traffic and records the changes in the IP addresses and MAC addresses, the changes of pairs along with the timestamps in a network. It also has a function to send an e-mail notifying the administrator, when a couple is added or changes. It is very useful in detecting ARP impersonation in a network. - -We can obtain more information about this tool and download the necessary packages from the - -[following link.​][20] - -### Wireshark - Network Monitoring tool - - [![wireshark network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/editor/how-to-use-wireshark_1.jpg?1512299583)][21] **[Wireshark][1]** - -is a free application that enables you to catch and view the information going forward and backward on your system, giving the capacity to bore down and read the substance of every parcel – separated to meet your particular needs. It is generally used to investigate arrange issues and additionally to create and test programming. This open-source convention analyzer is generally acknowledged as the business standard, prevailing upon what's coming to it's of honors the years. - -Initially known as Ethereal, Wireshark highlights an easy to understand interface that can show information from many diverse conventions on all real system sorts. - -### Conclusion - -​In this article, we have taken a gander at a few open source network monitoring tools. Because we concentrated on these instruments as the "best" does not really mean they are the best for your need. For instance, there are numerous other open source monitoring apparatuses that exist, for example, OpenNMS, Cacti, and Zennos and you need to consider the advantages of everyone from the point of view of your prerequisite. - -Additionally, there are different apparatuses that might be more good for your need that is not open source. - -​ - -What more network monitors do you use or know to use in Linux in terminal format? - --------------------------------------------------------------------------------- - -via: http://www.linuxandubuntu.com/home/best-network-monitoring-tools-for-linux - -作者:[​​LinuxAndUbuntu][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://www.linuxandubuntu.com -[1]:https://www.wireshark.org/ -[2]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iftop_orig.png -[3]:http://www.ex-parrot.com/pdw/iftop/ -[4]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/edited/vnstat.png -[5]:http://humdi.net/vnstat/ -[6]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iptraf_orig.gif -[7]:http://iptraf.seul.org/ -[8]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/monitorix_orig.png -[9]:http://www.monitorix.org -[10]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/dstat_orig.png -[11]:http://dag.wiee.rs/home-made/dstat/ -[12]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/bwm-ng_orig.png -[13]:http://sourceforge.net/projects/bwmng/ -[14]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/ibmonitor_orig.jpg -[15]:http://ibmonitor.sourceforge.net/ -[16]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/htop_orig.png -[17]:http://wesharethis.com/knowledgebase/htop-and-atop/ -[18]:http://hisham.hm/htop/ -[19]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/arpwatch_orig.png -[20]:http://linux.softpedia.com/get/System/Monitoring/arpwatch-NG-7612.shtml -[21]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/how-to-use-wireshark_1_orig.jpg diff --git a/translated/tech/20171203 Best Network Monitoring Tools For Linux.md b/translated/tech/20171203 Best Network Monitoring Tools For Linux.md new file mode 100644 index 0000000000..8fc2cd25e3 --- /dev/null +++ b/translated/tech/20171203 Best Network Monitoring Tools For Linux.md @@ -0,0 +1,127 @@ +Linux 中最佳的网络监视工具 +=============================== + +保持对我们的网络的管理,防止任何程序过度使用网络、导致整个系统操作变慢,对管理员来说是至关重要的。对不同的系统操作,这是有几个网络监视工具。在这篇文章中,我们将讨论从 Linux 终端中运行的 10 个网络监视工具。它对不使用 GUI 而希望通过 SSH 来保持对网络管理的用户来说是非常理想的。 + +### Iftop + + [![iftop network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iftop_orig.png)][2] + +与 Linux 用户经常使用的 Top 是非常类似的。这是一个系统监视工具,它允许我们知道在我们的系统中实时运行的进程,并可以很容易地管理它们。Iftop 与 Top 应用程序类似,但它是专门监视网络的,通过它可以知道更多的关于网络的详细情况和使用网络的所有进程。 + +我们可以从 [这个链接][3] 获取关于这个工具的更多信息以及下载必要的包。 + +### Vnstat + + [![vnstat network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/editor/vnstat.png?1511885309)][4] + +**Vnstat** 是一个缺省包含在大多数 Linux 发行版中的网络监视工具。它允许我们在一个用户选择的时间周期内获取一个实时管理的发送和接收的流量。 + +我们可以从 [这个链接][5] 获取关于这个工具的更多信息以及下载必要的包。 + +### Iptraf + + [![iptraf monitoring tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iptraf_orig.gif)][6] + +**IPTraf** 是一个 Linux 的、基于控制台的、实时网络监视程序。(IP LAN) - 收集经过这个网络的各种各样的信息作为一个 IP 流量监视器,包括 TCP 标志信息、ICMP 详细情况、TCP / UDP 流量故障、TCP 连接包和 Byne 报告。它也收集接口上全部的 TCP、UDP、…… 校验和错误、接口活动等等的详细情况。 + +我们可以从 [这个链接][7] 获取这个工具的更多信息以及下载必要的包。 + +### Monitorix - 系统和网络监视 + + [![monitorix system monitoring tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/monitorix_orig.png)][8] + +Monitorix 是一个轻量级的免费应用程序,它设计用于去监视尽可能多的 Linux / Unix 服务器的系统和网络资源。一个 HTTP web 服务器可以被添加到它里面,定期去收集系统和网络信息,并且在一个图表中显示它们。它跟踪平均的系统负载、内存分配、磁盘健康状态、系统服务、网络端口、邮件统计信息(Sendmail、Postfix、Dovecot、等等)、MySQL 统计信息以及其它的更多内容。它设计用于去管理系统的整体性能,以及帮助检测故障、瓶颈、异常活动、等等。 + +下载及更多 [信息在这里][9]。 + +### Dstat + + [![dstat network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/dstat_orig.png)][10] + +这个监视器相比前面的几个知名度低一些,但是,在一些发行版中已经缺省包含了。 + +我们可以从 [这个链接][11] 获取这个工具的更多信息以及下载必要的包。 + +### Bwm-ng + + [![bwm-ng monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/bwm-ng_orig.png)][12] + +这是最简化的工具中的一个。它允许你去从交互式连接中取得数据,并且,为了便于其它设备使用,在取得数据的同时,能以某些格式导出它们。 + +我们可以从 [这个链接][13] 获取这个工具的更多信息以及下载必要的包。 + +### Ibmonitor + + [![ibmonitor tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/ibmonitor_orig.jpg)][14] + +与上面的类似,它显示连接接口上过滤后的网络流量,并且,从接收到的流量中明确地区分区开发送流量。 + +我们可以从 [这个链接][15] 获取这个工具的更多信息以及下载必要的包。 +​ +### Htop - Linux 进程跟踪 + + [![htop linux processes monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/htop_orig.png)][16] + +Htop 是一个更高级的、交互式的、实时的 Linux 进程跟踪工具。它类似于 Linux 的 top 命令,但是有一些更高级的特性,比如,一个更易于使用的进程管理接口、快捷键、水平和垂直的进程视图、等更多特性。Htop 是一个第三方工具,它不包含在 Linux 系统中,你必须使用 **YUM** 或者 **APT-GET** 或者其它的包管理工具去安装它。关于安装它的更多信息,读[这篇文章][17]。 + +我们可以从 [这个链接][18] 获取这个工具的更多信息以及下载必要的包。 + +### Arpwatch - 以太网活动监视器 + + [![arpwatch ethernet monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/arpwatch_orig.png)][19] + +Arpwatch 是一个设计用于在 Linux 网络中去管理以太网通讯的地址解析的程序。它持续监视以太网通讯并记录 IP 地址和 MAC 地址的变化。在一个网络中,它们的变化同时伴随记录一个时间戳。它也有一个功能是当一对 IP 和 MAC 地址被添加或者发生变化时,发送一封邮件给系统管理员。在一个网络中发生 ARP 攻击时,这个功能非常有用。 + +我们可以从 [这个链接][20] 获取这个工具的更多信息以及下载必要的包。 + +### Wireshark - 网络监视工具 + + [![wireshark network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/editor/how-to-use-wireshark_1.jpg?1512299583)][21] + +**[Wireshark][1]** 是一个免费的应用程序,它允许你去捕获和查看前往你的系统和从你的系统中返回的信息,它可以去深入到通讯包中并查看每个包的内容 – 分开它们来满足你的特殊需要。它一般用于去研究协议问题和去创建和测试程序的特别情况。这个开源分析器是一个被公认的分析器商业标准,它的流行是因为纪念那些年的荣誉。 + +最初它被认识是因为 Ethereal,Wireshark 有轻量化的、易于去理解的界面,它能分类显示来自不同的真实系统上的协议信息。 + +### 结论 + +​在这篇文章中,我们看了几个开源的网络监视工具。由于我们从这些工具中挑选出来的认为是“最佳的”,并不意味着它们都是最适合你的需要的。例如,现在有很多的开源监视工具,比如,OpenNMS、Cacti、和 Zennos,并且,你需要去从你的个体情况考虑它们的每个工具的优势。 + +另外,还有不同的、更适合你的需要的不开源的工具。 + +你知道的或者使用的在 Linux 终端中的更多网络监视工具还有哪些? + +-------------------------------------------------------------------------------- + +via: http://www.linuxandubuntu.com/home/best-network-monitoring-tools-for-linux + +作者:[​​LinuxAndUbuntu][a] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://www.linuxandubuntu.com +[1]:https://www.wireshark.org/ +[2]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iftop_orig.png +[3]:http://www.ex-parrot.com/pdw/iftop/ +[4]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/edited/vnstat.png +[5]:http://humdi.net/vnstat/ +[6]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iptraf_orig.gif +[7]:http://iptraf.seul.org/ +[8]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/monitorix_orig.png +[9]:http://www.monitorix.org +[10]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/dstat_orig.png +[11]:http://dag.wiee.rs/home-made/dstat/ +[12]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/bwm-ng_orig.png +[13]:http://sourceforge.net/projects/bwmng/ +[14]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/ibmonitor_orig.jpg +[15]:http://ibmonitor.sourceforge.net/ +[16]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/htop_orig.png +[17]:http://wesharethis.com/knowledgebase/htop-and-atop/ +[18]:http://hisham.hm/htop/ +[19]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/arpwatch_orig.png +[20]:http://linux.softpedia.com/get/System/Monitoring/arpwatch-NG-7612.shtml +[21]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/how-to-use-wireshark_1_orig.jpg + + From 7a2ab51c29191ca888798df33faf2250853b0ffe Mon Sep 17 00:00:00 2001 From: qhwdw Date: Thu, 7 Dec 2017 11:44:08 +0800 Subject: [PATCH 331/344] Translated by qhwdw --- ...Best Network Monitoring Tools For Linux.md | 189 ------------------ ...Best Network Monitoring Tools For Linux.md | 127 ++++++++++++ 2 files changed, 127 insertions(+), 189 deletions(-) delete mode 100644 sources/tech/20171203 Best Network Monitoring Tools For Linux.md create mode 100644 translated/tech/20171203 Best Network Monitoring Tools For Linux.md diff --git a/sources/tech/20171203 Best Network Monitoring Tools For Linux.md b/sources/tech/20171203 Best Network Monitoring Tools For Linux.md deleted file mode 100644 index d53e4e0534..0000000000 --- a/sources/tech/20171203 Best Network Monitoring Tools For Linux.md +++ /dev/null @@ -1,189 +0,0 @@ -Translating by qhwdw -Best Network Monitoring Tools For Linux -=============================== - - -Keeping control of our network is vital to prevent any program from overusing it and slows down the overall system operation. There are several - -**network monitoring tools** - -for different operating systems today. In this article, we will talk about - -**10 network monitoring tools for Linux** - -that will run from a terminal, ideal for users who do not use GUI or for those who want to keep a control of the network use of a server through from ssh. - -### Iftop - - [![iftop network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iftop_orig.png)][2] - -Linux users are generally familiar with Top. This tool is a system monitor that allows us to know in real time all the processes that are running in our system and can manage them easily. Iftop is an application similar to Top but specialized in the monitoring of the network, being able to know a multitude of details regarding the network and all the processes that are making use of it. - -We can obtain more information about this tool and download the necessary packages from the - -[following link][3] - -. - -### Vnstat - - [![vnstat network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/editor/vnstat.png?1511885309)][4] **Vnstat** - -is a network monitor that is included, by default, in most Linux distributions. It allows us to obtain a real-time control of the traffic sent and received in a period of time, chosen by the user. - -​ - -We can obtain more information about this tool and download the necessary packages from the - -[following link.][5] - -### Iptraf - - [![iptraf monitoring tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iptraf_orig.gif)][6] **IPTraf** - -is a console-based, real-time network monitoring utility for Linux. (IP LAN) - Collects a wide variety of information as an IP traffic monitor that passes through the network, including TCP flags information, ICMP details, TCP / UDP traffic faults, TCP connection packet and Byne account. It also collects statistics information from the general and detailed interface of TCP, UDP,,, checksum errors IP not IP ICMP IP, interface activity, etc. - -​ - -We can obtain more information about this tool and download the necessary packages from the - -[following link.][7] - -### Monitorix - System and Monitoring Network - - [![monitorix system monitoring tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/monitorix_orig.png)][8] - -Monitorix is a lightweight free utility that is designed to run and monitor system and network resources with as many Linux / Unix servers as possible. An HTTP web server has been added that regularly collects system and network information and displays them in the graphs. It will track the average system load and its usage, memory allocation, disk health, system services, network ports, mail statistics (Sendmail, Postfix, Dovecot, etc.), MySQL statistics and many more. It is designed to control the overall performance of the system and helps in detecting faults, bottlenecks, abnormal activities, etc. - -​ - -Download and more - -[information here][9] - -. - -### Dstat - - [![dstat network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/dstat_orig.png)][10] - -A monitor is somewhat less known than the previous ones but also usually comes by default in many distributions. - -​ - -We can obtain more information about this tool and download the necessary packages from the - -[following link][11] - -. - -### Bwm-ng - - [![bwm-ng monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/bwm-ng_orig.png)][12] - -One of the simplest tools. It allows you to get data from the connection interactively and, at the same time, export them to a certain format for easier reference on another device. - -​ - -We can obtain more information about this tool and download the necessary packages from the - -[following link][13] - -. - -### Ibmonitor - - [![ibmonitor tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/ibmonitor_orig.jpg)][14] - -Similar to the above, it shows network traffic filtered by connection interface and clearly separates the traffic sent from the received traffic. - -​ - -We can obtain more information about this tool and download the necessary packages from the - -[following link​][15] - -. - -### Htop - Linux Process Tracking - - [![htop linux processes monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/htop_orig.png)][16] - -Htop is a much more advanced, interactive and real-time Linux tool for tracking processes. It is similar to the top Linux command but has some advanced features such as an easy-to-use interface for process management, shortcut keys, vertical and horizontal view of processes and much more. Htop is a third-party tool and is not included on Linux systems, you must install it using - -**YUM** - -(or - -**APT-GET)** - -or whatever your package management tool. For more information on installation, read - -[this article][17] - -. - -We can obtain more information about this tool and download the necessary packages from the - -[following link.][18] - -### Arpwatch - Ethernet Activity Monitor - - [![arpwatch ethernet monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/arpwatch_orig.png)][19] - -Arpwatch is a program that is designed to control the resolution of addresses (MAC and changes in the IP address) of Ethernet network traffic in a Linux network. It is continuously monitoring the Ethernet traffic and records the changes in the IP addresses and MAC addresses, the changes of pairs along with the timestamps in a network. It also has a function to send an e-mail notifying the administrator, when a couple is added or changes. It is very useful in detecting ARP impersonation in a network. - -We can obtain more information about this tool and download the necessary packages from the - -[following link.​][20] - -### Wireshark - Network Monitoring tool - - [![wireshark network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/editor/how-to-use-wireshark_1.jpg?1512299583)][21] **[Wireshark][1]** - -is a free application that enables you to catch and view the information going forward and backward on your system, giving the capacity to bore down and read the substance of every parcel – separated to meet your particular needs. It is generally used to investigate arrange issues and additionally to create and test programming. This open-source convention analyzer is generally acknowledged as the business standard, prevailing upon what's coming to it's of honors the years. - -Initially known as Ethereal, Wireshark highlights an easy to understand interface that can show information from many diverse conventions on all real system sorts. - -### Conclusion - -​In this article, we have taken a gander at a few open source network monitoring tools. Because we concentrated on these instruments as the "best" does not really mean they are the best for your need. For instance, there are numerous other open source monitoring apparatuses that exist, for example, OpenNMS, Cacti, and Zennos and you need to consider the advantages of everyone from the point of view of your prerequisite. - -Additionally, there are different apparatuses that might be more good for your need that is not open source. - -​ - -What more network monitors do you use or know to use in Linux in terminal format? - --------------------------------------------------------------------------------- - -via: http://www.linuxandubuntu.com/home/best-network-monitoring-tools-for-linux - -作者:[​​LinuxAndUbuntu][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://www.linuxandubuntu.com -[1]:https://www.wireshark.org/ -[2]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iftop_orig.png -[3]:http://www.ex-parrot.com/pdw/iftop/ -[4]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/edited/vnstat.png -[5]:http://humdi.net/vnstat/ -[6]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iptraf_orig.gif -[7]:http://iptraf.seul.org/ -[8]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/monitorix_orig.png -[9]:http://www.monitorix.org -[10]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/dstat_orig.png -[11]:http://dag.wiee.rs/home-made/dstat/ -[12]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/bwm-ng_orig.png -[13]:http://sourceforge.net/projects/bwmng/ -[14]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/ibmonitor_orig.jpg -[15]:http://ibmonitor.sourceforge.net/ -[16]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/htop_orig.png -[17]:http://wesharethis.com/knowledgebase/htop-and-atop/ -[18]:http://hisham.hm/htop/ -[19]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/arpwatch_orig.png -[20]:http://linux.softpedia.com/get/System/Monitoring/arpwatch-NG-7612.shtml -[21]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/how-to-use-wireshark_1_orig.jpg diff --git a/translated/tech/20171203 Best Network Monitoring Tools For Linux.md b/translated/tech/20171203 Best Network Monitoring Tools For Linux.md new file mode 100644 index 0000000000..8fc2cd25e3 --- /dev/null +++ b/translated/tech/20171203 Best Network Monitoring Tools For Linux.md @@ -0,0 +1,127 @@ +Linux 中最佳的网络监视工具 +=============================== + +保持对我们的网络的管理,防止任何程序过度使用网络、导致整个系统操作变慢,对管理员来说是至关重要的。对不同的系统操作,这是有几个网络监视工具。在这篇文章中,我们将讨论从 Linux 终端中运行的 10 个网络监视工具。它对不使用 GUI 而希望通过 SSH 来保持对网络管理的用户来说是非常理想的。 + +### Iftop + + [![iftop network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iftop_orig.png)][2] + +与 Linux 用户经常使用的 Top 是非常类似的。这是一个系统监视工具,它允许我们知道在我们的系统中实时运行的进程,并可以很容易地管理它们。Iftop 与 Top 应用程序类似,但它是专门监视网络的,通过它可以知道更多的关于网络的详细情况和使用网络的所有进程。 + +我们可以从 [这个链接][3] 获取关于这个工具的更多信息以及下载必要的包。 + +### Vnstat + + [![vnstat network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/editor/vnstat.png?1511885309)][4] + +**Vnstat** 是一个缺省包含在大多数 Linux 发行版中的网络监视工具。它允许我们在一个用户选择的时间周期内获取一个实时管理的发送和接收的流量。 + +我们可以从 [这个链接][5] 获取关于这个工具的更多信息以及下载必要的包。 + +### Iptraf + + [![iptraf monitoring tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iptraf_orig.gif)][6] + +**IPTraf** 是一个 Linux 的、基于控制台的、实时网络监视程序。(IP LAN) - 收集经过这个网络的各种各样的信息作为一个 IP 流量监视器,包括 TCP 标志信息、ICMP 详细情况、TCP / UDP 流量故障、TCP 连接包和 Byne 报告。它也收集接口上全部的 TCP、UDP、…… 校验和错误、接口活动等等的详细情况。 + +我们可以从 [这个链接][7] 获取这个工具的更多信息以及下载必要的包。 + +### Monitorix - 系统和网络监视 + + [![monitorix system monitoring tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/monitorix_orig.png)][8] + +Monitorix 是一个轻量级的免费应用程序,它设计用于去监视尽可能多的 Linux / Unix 服务器的系统和网络资源。一个 HTTP web 服务器可以被添加到它里面,定期去收集系统和网络信息,并且在一个图表中显示它们。它跟踪平均的系统负载、内存分配、磁盘健康状态、系统服务、网络端口、邮件统计信息(Sendmail、Postfix、Dovecot、等等)、MySQL 统计信息以及其它的更多内容。它设计用于去管理系统的整体性能,以及帮助检测故障、瓶颈、异常活动、等等。 + +下载及更多 [信息在这里][9]。 + +### Dstat + + [![dstat network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/dstat_orig.png)][10] + +这个监视器相比前面的几个知名度低一些,但是,在一些发行版中已经缺省包含了。 + +我们可以从 [这个链接][11] 获取这个工具的更多信息以及下载必要的包。 + +### Bwm-ng + + [![bwm-ng monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/bwm-ng_orig.png)][12] + +这是最简化的工具中的一个。它允许你去从交互式连接中取得数据,并且,为了便于其它设备使用,在取得数据的同时,能以某些格式导出它们。 + +我们可以从 [这个链接][13] 获取这个工具的更多信息以及下载必要的包。 + +### Ibmonitor + + [![ibmonitor tool for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/ibmonitor_orig.jpg)][14] + +与上面的类似,它显示连接接口上过滤后的网络流量,并且,从接收到的流量中明确地区分区开发送流量。 + +我们可以从 [这个链接][15] 获取这个工具的更多信息以及下载必要的包。 +​ +### Htop - Linux 进程跟踪 + + [![htop linux processes monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/htop_orig.png)][16] + +Htop 是一个更高级的、交互式的、实时的 Linux 进程跟踪工具。它类似于 Linux 的 top 命令,但是有一些更高级的特性,比如,一个更易于使用的进程管理接口、快捷键、水平和垂直的进程视图、等更多特性。Htop 是一个第三方工具,它不包含在 Linux 系统中,你必须使用 **YUM** 或者 **APT-GET** 或者其它的包管理工具去安装它。关于安装它的更多信息,读[这篇文章][17]。 + +我们可以从 [这个链接][18] 获取这个工具的更多信息以及下载必要的包。 + +### Arpwatch - 以太网活动监视器 + + [![arpwatch ethernet monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/arpwatch_orig.png)][19] + +Arpwatch 是一个设计用于在 Linux 网络中去管理以太网通讯的地址解析的程序。它持续监视以太网通讯并记录 IP 地址和 MAC 地址的变化。在一个网络中,它们的变化同时伴随记录一个时间戳。它也有一个功能是当一对 IP 和 MAC 地址被添加或者发生变化时,发送一封邮件给系统管理员。在一个网络中发生 ARP 攻击时,这个功能非常有用。 + +我们可以从 [这个链接][20] 获取这个工具的更多信息以及下载必要的包。 + +### Wireshark - 网络监视工具 + + [![wireshark network monitoring tool](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/editor/how-to-use-wireshark_1.jpg?1512299583)][21] + +**[Wireshark][1]** 是一个免费的应用程序,它允许你去捕获和查看前往你的系统和从你的系统中返回的信息,它可以去深入到通讯包中并查看每个包的内容 – 分开它们来满足你的特殊需要。它一般用于去研究协议问题和去创建和测试程序的特别情况。这个开源分析器是一个被公认的分析器商业标准,它的流行是因为纪念那些年的荣誉。 + +最初它被认识是因为 Ethereal,Wireshark 有轻量化的、易于去理解的界面,它能分类显示来自不同的真实系统上的协议信息。 + +### 结论 + +​在这篇文章中,我们看了几个开源的网络监视工具。由于我们从这些工具中挑选出来的认为是“最佳的”,并不意味着它们都是最适合你的需要的。例如,现在有很多的开源监视工具,比如,OpenNMS、Cacti、和 Zennos,并且,你需要去从你的个体情况考虑它们的每个工具的优势。 + +另外,还有不同的、更适合你的需要的不开源的工具。 + +你知道的或者使用的在 Linux 终端中的更多网络监视工具还有哪些? + +-------------------------------------------------------------------------------- + +via: http://www.linuxandubuntu.com/home/best-network-monitoring-tools-for-linux + +作者:[​​LinuxAndUbuntu][a] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://www.linuxandubuntu.com +[1]:https://www.wireshark.org/ +[2]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iftop_orig.png +[3]:http://www.ex-parrot.com/pdw/iftop/ +[4]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/edited/vnstat.png +[5]:http://humdi.net/vnstat/ +[6]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/iptraf_orig.gif +[7]:http://iptraf.seul.org/ +[8]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/monitorix_orig.png +[9]:http://www.monitorix.org +[10]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/dstat_orig.png +[11]:http://dag.wiee.rs/home-made/dstat/ +[12]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/bwm-ng_orig.png +[13]:http://sourceforge.net/projects/bwmng/ +[14]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/ibmonitor_orig.jpg +[15]:http://ibmonitor.sourceforge.net/ +[16]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/htop_orig.png +[17]:http://wesharethis.com/knowledgebase/htop-and-atop/ +[18]:http://hisham.hm/htop/ +[19]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/arpwatch_orig.png +[20]:http://linux.softpedia.com/get/System/Monitoring/arpwatch-NG-7612.shtml +[21]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/how-to-use-wireshark_1_orig.jpg + + From c9fc207e958fafa2041b4d41f5c4657865151c7f Mon Sep 17 00:00:00 2001 From: qhwdw Date: Thu, 7 Dec 2017 11:53:53 +0800 Subject: [PATCH 332/344] Translating by qhwdw --- ...Linux containers with Ansible Container.md | 62 ++++++++++--------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/sources/tech/20171005 How to manage Linux containers with Ansible Container.md b/sources/tech/20171005 How to manage Linux containers with Ansible Container.md index 0f200d73a8..624d25694a 100644 --- a/sources/tech/20171005 How to manage Linux containers with Ansible Container.md +++ b/sources/tech/20171005 How to manage Linux containers with Ansible Container.md @@ -1,44 +1,44 @@ -Translating by qhwdw How to manage Linux containers with Ansible Container +怎么去使用 Ansible Container 去管理 Linux 容器 ============================================================ -### Ansible Container addresses Dockerfile shortcomings and offers complete management for containerized projects. +### Ansible Container 处理 Dockerfile 的不足和对容器化项目提供完整的管理。 ![Ansible Container: A new way to manage containers](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/container-ship.png?itok=pqZYgQ7K "Ansible Container: A new way to manage containers") Image by : opensource.com -I love containers and use the technology every day. Even so, containers aren't perfect. Over the past couple of months, however, a set of projects has emerged that addresses some of the problems I've experienced. +我喜欢容器,并且每天都使用这个技术。在过去几个月,在一组项目中已经解决了我遇到的问题,即便如此,容器并不完美。 -I started using containers with [Docker][11], since this project made the technology so popular. Aside from using the container engine, I learned how to use **[docker-compose][6]** and started managing my projects with it. My productivity skyrocketed! One command to run my project, no matter how complex it was. I was so happy. +我刚开始时,用 [Docker][11] 使用容器,因为这个项目使这个技术非常流行。除此之外,使用这个容器引擎,我学到了怎么去使用 **[docker-compose][6]** 以及怎么去用它管理我的项目。使用它使我的生产力猛增!一个命令去运行我的项目,而不管它有多复杂。因此,我太高兴了。 -After some time, I started noticing issues. The most apparent were related to the process of creating container images. The Docker tool uses a custom file format as a recipe to produce container images—Dockerfiles. This format is easy to learn, and after a short time you are ready to produce container images on your own. The problems arise once you want to master best practices or have complex scenarios in mind. +使用一段时间之后,我发现了一些问题。最明显的问题是创建窗口镜像的过程。Docker 工具使用一个定制的文件格式作为一个 Recipe 去制作容器镜像 — Dockerfiles。这个格式很容易学会,并且很短的一段时间之后,你就可以为你自己制作容器镜像了。但是,一旦你希望去掌握最佳实践或者有复杂场景的想法,问题就会出现。 -More on Ansible +Ansible 的更多资源 -* [How Ansible works][1] +* [Ansible 是怎么工作的][1] -* [Free Ansible eBooks][2] +* [免费的 Ansible 电子书][2] -* [Ansible quick start video][3] +* [Ansible 快速上手视频][3] -* [Download and install Ansible][4] +* [下载和安装 Ansible][4] -Let's take a break and travel to a different land: the world of [Ansible][22]. You know it? It's awesome, right? You don't? Well, it's time to learn something new. Ansible is a project that allows you to manage your infrastructure by writing tasks and executing them inside environments of your choice. No need to install and set up any services; everything can easily run from your laptop. Many people already embrace Ansible. +让我们先休息一会儿,先去了解一个不同的东西:[Ansible][22] 的世界。你知道它吗?它棒极了,是吗?你不这么认为?好吧,是时候去学习一些新事物了。Ansible 是一个项目,它允许你通过写一些任务去管理你的基础设施,并在你选择的环境中运行它们。不需要去安装和设置任何的服务;你可以从你的笔记本电脑中去很很容易地做任何事情。许多人已经接受 Ansible 了。 -Imagine this scenario: You invested in Ansible, you wrote plenty of Ansible roles and playbooks that you use to manage your infrastructure, and you are thinking about investing in containers. What should you do? Start writing container image definitions via shell scripts and Dockerfiles? That doesn't sound right. +想像一下这样的场景:你在 Ansible 中,你写了很多的 Ansible 角色和 playbooks,你可以用它们去管理你的基础设施,并且想把它们运用到容器中。你应该怎么做?开始通过 shell 脚本和 Dockerfiles 去写容器镜像定义?听起来好像不对。 -Some people from the Ansible development team asked this question and realized that those same Ansible roles and playbooks that people wrote and use daily can also be used to produce container images. But not just that—they can be used to manage the complete lifecycle of containerized projects. From these ideas, the [Ansible Container][12] project was born. It utilizes existing Ansible roles that can be turned into container images and can even be used for the complete application lifecycle, from build to deploy in production. +来自 Ansible 开发团队的一些人问到这个问题,并且它们意识到,人们每天使用那些同样的 Ansible 角色和 playbooks 也可以用来制作容器镜像。但是 Ansible 能做到的不止这些 — 它可以被用于去管理容器化项目的完整的生命周期。从这些想法中,[Ansible Container][12] 项目诞生了。它使用已有的可以变成容器镜像的 Ansible 角色,甚至可以被用于应用程序在生产系统中从构建到部署的完整生命周期。 -Let's talk about the problems I mentioned regarding best practices in context of Dockerfiles. A word of warning: This is going to be very specific and technical. Here are the top three issues I have: +现在让我们讨论一下,在 Dockerfiles 环境中关于最佳实践时可能存在的问题。这里有一个警告:这将是非常具体且技术性的。出现最多的三个问题有: -### 1\. Shell scripts embedded in Dockerfiles. +### 1\. 在 Dockerfiles 中内嵌的 Shell 脚本。 -When writing Dockerfiles, you can specify a script that will be interpreted via **/bin/sh -c**. It can be something like: +当写 Dockerfiles 时,你可以通过 **/bin/sh -c** 解释指定的脚本。它可以做类似这样的事情: ``` RUN dnf install -y nginx ``` -where RUN is a Dockerfile instruction and the rest are its arguments (which are passed to shell). But imagine a more complex scenario: +RUN 处是一个 Dockerfile 指令并且其它的都是参数(它传递给 shell)。但是,想像一个更复杂的场景: ``` RUN set -eux; \ @@ -51,36 +51,36 @@ RUN set -eux; \     echo "${goRelSha256} *go.tgz" | sha256sum -c -; \ ``` -This one is taken from [the official golang image][13]. It doesn't look pretty, right? +这仅是从 [the official golang image][13] 中拿来的一个。它看起来并不好看,是不是? -### 2\. You can't parse Dockerfiles easily. +### 2\. 你解析 Dockerfiles 并不容易。 -Dockerfiles are a new format without a formal specification. This is tricky if you need to process Dockerfiles in your infrastructure (e.g., automate the build process a bit). The only specification is [the code][14] that is part of **dockerd**. The problem is that you can't use it as a library. The easiest solution is to write a parser on your own and hope for the best. Wouldn't it be better to use some well-known markup language, such as YAML or JSON? +Dockerfiles 是一个没有正式规范的新格式。如果你需要在你的基础设施(比如,让构建过程自动化一点)中去处理 Dockerfiles 将会很复杂。仅有的规划是 [这个代码][14],它是 **dockerd** 的一部分。问题是你不能使用它作为一个库(library)。最容易的解决方案是你自己写一个解析器,然后祈祷它运行的很好。使用一些众所周知的标记语言不是更好吗?比如,YAML 或者 JSON。 -### 3\. It's hard to control. +### 3\. 管理困难。 -If you are familiar with the internals of container images, you may know that every image is composed of layers. Once the container is created, the layers are stacked onto each other (like pancakes) using union filesystem technology. The problem is, that you cannot explicitly control this layering—you can't say, "here starts a new layer." You are forced to change your Dockerfile in a way that may hurt readability. The bigger problem is that a set of best practices has to be followed to achieve optimal results—newcomers have a really hard time here. +如果你熟悉容器镜像的内部结构,你可能知道每个镜像是由层(layers)构成的。一旦容器被创建,这些层就使用联合文件系统技术堆叠在一起(像煎饼一样)。问题是,你并不能显式地管理这些层 — 你不能说,“这儿开始一个新层”,你被迫使用一种可读性不好的方法去改变你的 Dockerfile。最大的问题是,必须遵循一套最佳实践以去达到最优结果 — 新来的人在这个地方可能很困难。 -### Comparing Ansible language and Dockerfiles +### Ansible 语言和 Dockerfiles 比较 -The biggest shortcoming of Dockerfiles in comparison to Ansible is that Ansible, as a language, is much more powerful. For example, Dockerfiles have no direct concept of variables, whereas Ansible has a complete templating system (variables are just one of its features). Ansible contains a large number of modules that can be easily utilized, such as [**wait_for**][15], which can be used for service readiness checks—e.g., wait until a service is ready before proceeding. With Dockerfiles, everything is a shell script. So if you need to figure out service readiness, it has to be done with shell (or installed separately). The other problem with shell scripts is that, with growing complexity, maintenance becomes a burden. Plenty of people have already figured this out and turned those shell scripts into Ansible. +相比 Ansible,Dockerfiles 的最大缺点,也是 Ansible 的优点,作为一个语言,Ansible 更强大。例如,Dockerfiles 没有直接的变量概念,而 Ansible 有一个完整的模板系统(变量只是它其中的一个特性)。Ansible 包含了很多更易于使用的模块,比如,[**wait_for**][15],它可以被用于服务就绪检查,比如,在处理之前等待服务准备就绪。在 Dockerfiles 中,做任何事情都通过一个 shell 脚本。因此,如果你想去找出已准备好的服务,它必须使用 shell(或者独立安装)去做。使用 shell 脚本的其它问题是,它会变得很复杂,维护成为一种负担。很多人已经找到了这个问题,并将这些 shell 脚本转到 Ansible。 -If you are interested in this topic and would like to know more, please come to [Open Source Summit][16] in Prague to see [my presentation][17] on Monday, Oct. 23, at 4:20 p.m. in Palmovka room. +如果你对这个主题感兴趣,并且想去了解更多内容,请访问 [Open Source Summit][16],在 Prague 去看 [我的演讲][17],时间是 10 月 23 日,星期一,4:20 p.m. 在 Palmovka room 中。 - _Learn more in Tomas Tomecek's talk, [From Dockerfiles to Ansible Container][7], at [Open Source Summit EU][8], which will be held October 23-26 in Prague._ + _看更多的 Tomas Tomecek 演讲,[从 Dockerfiles 到 Ansible Container][7],在 [Open Source Summit EU][8],它将在 10 月 23-26 日在 Prague 召开。_ -### About the author +### 关于作者 - [![human](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/ja.jpeg?itok=4ATUEAbd)][18] Tomas Tomecek - Engineer. Hacker. Speaker. Tinker. Red Hatter. Likes containers, linux, open source, python 3, rust, zsh, tmux.[More about me][9] + [![human](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/ja.jpeg?itok=4ATUEAbd)][18] Tomas Tomecek - 工程师、Hacker、演讲者、Tinker、Red Hatter。喜欢容器、linux、开源软件、python 3、rust、zsh、tmux。[More about me][9] -------------------------------------------------------------------------------- via: https://opensource.com/article/17/10/dockerfiles-ansible-container -作者:[Tomas Tomecek ][a] -译者:[译者ID](https://github.com/译者ID) +作者:[Tomas Tomecek][a] +译者:[qhwdw](https://github.com/qhwdw) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -112,3 +112,5 @@ via: https://opensource.com/article/17/10/dockerfiles-ansible-container [24]:https://opensource.com/tags/ansible [25]:https://opensource.com/tags/docker [26]:https://opensource.com/tags/open-source-summit + + From e31ce8ddd46f89f003949149a80b6997b0528cac Mon Sep 17 00:00:00 2001 From: qhwdw Date: Thu, 7 Dec 2017 12:10:15 +0800 Subject: [PATCH 333/344] Translated by qhwdw --- ...Linux containers with Ansible Container.md | 116 ------------------ 1 file changed, 116 deletions(-) delete mode 100644 sources/tech/20171005 How to manage Linux containers with Ansible Container.md diff --git a/sources/tech/20171005 How to manage Linux containers with Ansible Container.md b/sources/tech/20171005 How to manage Linux containers with Ansible Container.md deleted file mode 100644 index 624d25694a..0000000000 --- a/sources/tech/20171005 How to manage Linux containers with Ansible Container.md +++ /dev/null @@ -1,116 +0,0 @@ -怎么去使用 Ansible Container 去管理 Linux 容器 -============================================================ - -### Ansible Container 处理 Dockerfile 的不足和对容器化项目提供完整的管理。 - -![Ansible Container: A new way to manage containers](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/container-ship.png?itok=pqZYgQ7K "Ansible Container: A new way to manage containers") -Image by : opensource.com - -我喜欢容器,并且每天都使用这个技术。在过去几个月,在一组项目中已经解决了我遇到的问题,即便如此,容器并不完美。 - -我刚开始时,用 [Docker][11] 使用容器,因为这个项目使这个技术非常流行。除此之外,使用这个容器引擎,我学到了怎么去使用 **[docker-compose][6]** 以及怎么去用它管理我的项目。使用它使我的生产力猛增!一个命令去运行我的项目,而不管它有多复杂。因此,我太高兴了。 - -使用一段时间之后,我发现了一些问题。最明显的问题是创建窗口镜像的过程。Docker 工具使用一个定制的文件格式作为一个 Recipe 去制作容器镜像 — Dockerfiles。这个格式很容易学会,并且很短的一段时间之后,你就可以为你自己制作容器镜像了。但是,一旦你希望去掌握最佳实践或者有复杂场景的想法,问题就会出现。 - -Ansible 的更多资源 - -* [Ansible 是怎么工作的][1] - -* [免费的 Ansible 电子书][2] - -* [Ansible 快速上手视频][3] - -* [下载和安装 Ansible][4] - -让我们先休息一会儿,先去了解一个不同的东西:[Ansible][22] 的世界。你知道它吗?它棒极了,是吗?你不这么认为?好吧,是时候去学习一些新事物了。Ansible 是一个项目,它允许你通过写一些任务去管理你的基础设施,并在你选择的环境中运行它们。不需要去安装和设置任何的服务;你可以从你的笔记本电脑中去很很容易地做任何事情。许多人已经接受 Ansible 了。 - -想像一下这样的场景:你在 Ansible 中,你写了很多的 Ansible 角色和 playbooks,你可以用它们去管理你的基础设施,并且想把它们运用到容器中。你应该怎么做?开始通过 shell 脚本和 Dockerfiles 去写容器镜像定义?听起来好像不对。 - -来自 Ansible 开发团队的一些人问到这个问题,并且它们意识到,人们每天使用那些同样的 Ansible 角色和 playbooks 也可以用来制作容器镜像。但是 Ansible 能做到的不止这些 — 它可以被用于去管理容器化项目的完整的生命周期。从这些想法中,[Ansible Container][12] 项目诞生了。它使用已有的可以变成容器镜像的 Ansible 角色,甚至可以被用于应用程序在生产系统中从构建到部署的完整生命周期。 - -现在让我们讨论一下,在 Dockerfiles 环境中关于最佳实践时可能存在的问题。这里有一个警告:这将是非常具体且技术性的。出现最多的三个问题有: - -### 1\. 在 Dockerfiles 中内嵌的 Shell 脚本。 - -当写 Dockerfiles 时,你可以通过 **/bin/sh -c** 解释指定的脚本。它可以做类似这样的事情: - -``` -RUN dnf install -y nginx -``` - -RUN 处是一个 Dockerfile 指令并且其它的都是参数(它传递给 shell)。但是,想像一个更复杂的场景: - -``` -RUN set -eux; \ -    \ -# this "case" statement is generated via "update.sh" -    %%ARCH-CASE%%; \ -    \ -    url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \ -    wget -O go.tgz "$url"; \ -    echo "${goRelSha256} *go.tgz" | sha256sum -c -; \ -``` - -这仅是从 [the official golang image][13] 中拿来的一个。它看起来并不好看,是不是? - -### 2\. 你解析 Dockerfiles 并不容易。 - -Dockerfiles 是一个没有正式规范的新格式。如果你需要在你的基础设施(比如,让构建过程自动化一点)中去处理 Dockerfiles 将会很复杂。仅有的规划是 [这个代码][14],它是 **dockerd** 的一部分。问题是你不能使用它作为一个库(library)。最容易的解决方案是你自己写一个解析器,然后祈祷它运行的很好。使用一些众所周知的标记语言不是更好吗?比如,YAML 或者 JSON。 - -### 3\. 管理困难。 - -如果你熟悉容器镜像的内部结构,你可能知道每个镜像是由层(layers)构成的。一旦容器被创建,这些层就使用联合文件系统技术堆叠在一起(像煎饼一样)。问题是,你并不能显式地管理这些层 — 你不能说,“这儿开始一个新层”,你被迫使用一种可读性不好的方法去改变你的 Dockerfile。最大的问题是,必须遵循一套最佳实践以去达到最优结果 — 新来的人在这个地方可能很困难。 - -### Ansible 语言和 Dockerfiles 比较 - -相比 Ansible,Dockerfiles 的最大缺点,也是 Ansible 的优点,作为一个语言,Ansible 更强大。例如,Dockerfiles 没有直接的变量概念,而 Ansible 有一个完整的模板系统(变量只是它其中的一个特性)。Ansible 包含了很多更易于使用的模块,比如,[**wait_for**][15],它可以被用于服务就绪检查,比如,在处理之前等待服务准备就绪。在 Dockerfiles 中,做任何事情都通过一个 shell 脚本。因此,如果你想去找出已准备好的服务,它必须使用 shell(或者独立安装)去做。使用 shell 脚本的其它问题是,它会变得很复杂,维护成为一种负担。很多人已经找到了这个问题,并将这些 shell 脚本转到 Ansible。 - -如果你对这个主题感兴趣,并且想去了解更多内容,请访问 [Open Source Summit][16],在 Prague 去看 [我的演讲][17],时间是 10 月 23 日,星期一,4:20 p.m. 在 Palmovka room 中。 - - _看更多的 Tomas Tomecek 演讲,[从 Dockerfiles 到 Ansible Container][7],在 [Open Source Summit EU][8],它将在 10 月 23-26 日在 Prague 召开。_ - - - -### 关于作者 - - [![human](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/ja.jpeg?itok=4ATUEAbd)][18] Tomas Tomecek - 工程师、Hacker、演讲者、Tinker、Red Hatter。喜欢容器、linux、开源软件、python 3、rust、zsh、tmux。[More about me][9] - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/10/dockerfiles-ansible-container - -作者:[Tomas Tomecek][a] -译者:[qhwdw](https://github.com/qhwdw) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/tomastomecek -[1]:https://www.ansible.com/how-ansible-works?intcmp=701f2000000h4RcAAI -[2]:https://www.ansible.com/ebooks?intcmp=701f2000000h4RcAAI -[3]:https://www.ansible.com/quick-start-video?intcmp=701f2000000h4RcAAI -[4]:https://docs.ansible.com/ansible/latest/intro_installation.html?intcmp=701f2000000h4RcAAI -[5]:https://opensource.com/article/17/10/dockerfiles-ansible-container?imm_mid=0f9013&cmp=em-webops-na-na-newsltr_20171201&rate=Wiw_0D6PK_CAjqatYu_YQH0t1sNHEF6q09_9u3sYkCY -[6]:https://github.com/docker/compose -[7]:http://sched.co/BxIW -[8]:http://events.linuxfoundation.org/events/open-source-summit-europe -[9]:https://opensource.com/users/tomastomecek -[10]:https://opensource.com/user/175651/feed -[11]:https://opensource.com/tags/docker -[12]:https://www.ansible.com/ansible-container -[13]:https://github.com/docker-library/golang/blob/master/Dockerfile-debian.template#L14 -[14]:https://github.com/moby/moby/tree/master/builder/dockerfile -[15]:http://docs.ansible.com/wait_for_module.html -[16]:http://events.linuxfoundation.org/events/open-source-summit-europe -[17]:http://events.linuxfoundation.org/events/open-source-summit-europe/program/schedule -[18]:https://opensource.com/users/tomastomecek -[19]:https://opensource.com/users/tomastomecek -[20]:https://opensource.com/users/tomastomecek -[21]:https://opensource.com/article/17/10/dockerfiles-ansible-container?imm_mid=0f9013&cmp=em-webops-na-na-newsltr_20171201#comments -[22]:https://opensource.com/tags/ansible -[23]:https://opensource.com/tags/containers -[24]:https://opensource.com/tags/ansible -[25]:https://opensource.com/tags/docker -[26]:https://opensource.com/tags/open-source-summit - - From b416b110fbb92f3599ded2d4743cec220accc8a8 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 7 Dec 2017 12:56:18 +0800 Subject: [PATCH 334/344] PRF:20171204 30 Best Linux Games On Steam You Should Play in 2017.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @yixunx 翻译的很棒! --- ... Games On Steam You Should Play in 2017.md | 152 +++++++++--------- 1 file changed, 73 insertions(+), 79 deletions(-) diff --git a/translated/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md b/translated/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md index f9fadae4ec..0588e1f88c 100644 --- a/translated/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md +++ b/translated/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md @@ -1,11 +1,11 @@ -2017 年最好的 30 款支持 Linux 的 Steam 游戏 +2017 年 30 款最好的支持 Linux 的 Steam 游戏 ============================================================ -说到游戏,人们一般都会推荐使用 Windows 系统。Windows 能提供更好的显卡支持和硬件兼容性,所以对于游戏爱好者来说的确是个更好的选择。但你是否想过[在 Linux 系统上玩游戏][9]?这的确是可能的,也许你以前还曾经考虑过。但在几年之前, [Steam for Linux][10] 上可玩的游戏并不是很吸引人。 +说到游戏,人们一般都会推荐使用 Windows 系统。Windows 能提供更好的显卡支持和硬件兼容性,所以对于游戏爱好者来说的确是个更好的选择。但你是否想过[在 Linux 系统上玩游戏][9]?这的确是可以的,也许你以前还曾经考虑过。但在几年之前, [Steam for Linux][10] 上可玩的游戏并不是很吸引人。 但现在情况完全不一样了。Steam 商店里现在有许多支持 Linux 平台的游戏(包括很多主流大作)。我们在本文中将介绍 Steam 上最好的一些 Linux 游戏。 -在进入正题之前,先介绍一个省钱小窍门。如果你是个狂热的游戏爱好者,在游戏上花费很多时间和金钱的话,我建议你订阅 [Humble 每月包(Humble Monthly)][11]。这是个每月收费的订阅服务,每月只用 12 美元就能获得价值 100 美元的游戏。 +在进入正题之前,先介绍一个省钱小窍门。如果你是个狂热的游戏爱好者,在游戏上花费很多时间和金钱的话,我建议你订阅 [Humble 每月包Humble Monthly][11]。这是个每月收费的订阅服务,每月只用 12 美元就能获得价值 100 美元的游戏。 这个游戏包中可能有些游戏不支持 Linux,但除了 Steam 游戏之外,它还会让 [Humble Bundle 网站][12]上所有的游戏和书籍都打九折,所以这依然是个不错的优惠。 @@ -20,218 +20,212 @@ 可以点击以下链接跳转到你喜欢的游戏类型: * [动作类游戏][3] - * [角色扮演类游戏][4] - * [赛车/运动/模拟类游戏][5] - * [冒险类游戏][6] - * [独立游戏][7] - * [策略类游戏][8] ### Steam 上最佳 Linux 动作类游戏 -### 1\. 反恐精英:全球攻势(Counter-Strike: Global Offensive)(多人) +#### 1、 《反恐精英:全球攻势Counter-Strike: Global Offensive》(多人) 《CS:GO》毫无疑问是 Steam 上支持 Linux 的最好的 FPS 游戏之一。我觉得这款游戏无需介绍,但如果你没有听说过它,我要告诉你这将会是你玩过的最好玩的多人 FPS 游戏之一。《CS:GO》还是电子竞技中的一个主流项目。想要提升等级的话,你需要在天梯上和其他玩家同台竞技。但你也可以选择更加轻松的休闲模式。 我本想写《彩虹六号:围攻行动》,但它目前还不支持 Linux 或 Steam OS。 -[购买《CS: GO》][15] +- [购买《CS: GO》][15] -### 2\. 求生之路 2(多人/单机) +#### 2、 《求生之路 2Left 4 Dead 2》(多人/单机) -这是最受欢迎的僵尸主题多人 FPS 游戏之一。在 Steam 优惠时,价格可以低至 1.3 美元。这是个有趣的游戏,能让你体会到你在僵尸游戏中期待的寒意和紧张感。游戏中的环境包括了沼泽、城市、墓地等等,让游戏既有趣又吓人。游戏中的枪械并不是非常先进,但作为一个老游戏来说,它已经提供了足够真实的体验。 +这是最受欢迎的僵尸主题多人 FPS 游戏之一。在 Steam 优惠时,价格可以低至 1.3 美元。这是个有趣的游戏,能让你体会到你在僵尸游戏中期待的战栗和刺激。游戏中的环境包括了沼泽、城市、墓地等等,让游戏既有趣又吓人。游戏中的枪械并不是非常先进,但作为一个老游戏来说,它已经提供了足够真实的体验。 -[购买《求生之路 2》][16] +- [购买《求生之路 2》][16] -### 3\. 无主之地 2(Borderlands 2)(单机/协作) +#### 3、 《无主之地 2Borderlands 2》(单机/协作) -《无主之地 2》是个很有意思的 FPS 游戏。它和你以前玩过的游戏完全不同。画风看上去有些诡异和卡通化,但我可以保证,游戏体验可一点也不逊色! +《无主之地 2》是个很有意思的 FPS 游戏。它和你以前玩过的游戏完全不同。画风看上去有些诡异和卡通化,如果你正在寻找一个第一视角的射击游戏,我可以保证,游戏体验可一点也不逊色! 如果你在寻找一个好玩而且有很多 DLC 的 Linux 游戏,《无主之地 2》绝对是个不错的选择。 -[购买《无主之地 2》][17] +- [购买《无主之地 2》][17] -### 4\. 叛乱(Insurgency)(多人) +#### 4、 《叛乱Insurgency》(多人) 《叛乱》是 Steam 上又一款支持 Linux 的优秀的 FPS 游戏。它剑走偏锋,从屏幕上去掉了 HUD 和弹药数量指示。如同许多评论者所说,这是款注重武器和团队战术的纯粹的射击游戏。这也许不是最好的 FPS 游戏,但如果你想玩和《三角洲部队》类似的多人游戏的话,这绝对是最好的游戏之一。 -[购买《叛乱》][18] +- [购买《叛乱》][18] -### 5\. 生化奇兵:无限(Bioshock: Infinite)(单机) +#### 5、 《生化奇兵:无限Bioshock: Infinite》(单机) 《生化奇兵:无限》毫无疑问将会作为 PC 平台最好的单机 FPS 游戏之一而载入史册。你可以利用很多强大的能力来杀死你的敌人。同时你的敌人也各个身怀绝技。游戏的剧情也非常丰富。你不容错过! -[购买《生化奇兵:无限》][19] +- [购买《生化奇兵:无限》][19] -### 6\. 《杀手(年度版)》(HITMAN - Game of the Year Edition)(单机) +#### 6、 《杀手(年度版)HITMAN - Game of the Year Edition》(单机) 《杀手》系列无疑是 PC 游戏爱好者们的最爱之一。本系列的最新作开始按章节发布,让很多玩家觉得不满。但现在 Square Enix 撤出了开发,而最新的年度版带着新的内容重返舞台。在游戏中发挥你的想象力暗杀你的目标吧,杀手47! -[购买(杀手(年度版))][20] +- [购买(杀手(年度版))][20] -### 7\. 传送门 2 +#### 7、 《传送门 2Portal 2》 《传送门 2》完美地结合了动作与冒险。这是款解谜类游戏,你可以与其他玩家协作,并开发有趣的谜题。协作模式提供了和单机模式截然不同的游戏内容。 -[购买《传送门2》][21] +- [购买《传送门2》][21] -### 8\. 杀出重围:人类分裂 +#### 8、 《杀出重围:人类分裂Deux Ex: Mankind Divided》 -如果你在寻找隐蔽类的射击游戏,《杀出重围》是个完美的选择。这是个非常华丽的游戏,有着最先进的武器和超乎寻常的战斗机制。 +如果你在寻找隐蔽类的射击游戏,《杀出重围》是个填充你的 Steam 游戏库的完美选择。这是个非常华丽的游戏,有着最先进的武器和超乎寻常的战斗机制。 -[购买《杀出重围:人类分裂》][22] +- [购买《杀出重围:人类分裂》][22] -### 9\. 地铁 2033 重置版(Metro 2033 Redux) / 地铁:最后曙光 重置版(Metro Last Light Redux) +#### 9、 《地铁 2033 重置版Metro 2033 Redux》 / 《地铁:最后曙光 重置版Metro Last Light Redux》 《地铁 2033 重置版》和《地铁:最后曙光 重置版》是经典的《地铁 2033》和《地铁:最后曙光》的最终版本。故事发生在世界末日之后。你需要消灭所有的变种人来保证人类的生存。剩下的就交给你自己去探索了! -[购买《地铁 2033 重置版》][23] +- [购买《地铁 2033 重置版》][23] +- [购买《地铁:最后曙光 重置版》][24] -[购买《地铁:最后曙光 重置版》][24] - -### 10\. 坦能堡(Tannenberg)(多人) +#### 10、 《坦能堡Tannenberg》(多人) 《坦能堡》是个全新的游戏 - 在本文发表一个月前刚刚发售。游戏背景是第一次世界大战的东线战场(1914-1918)。这款游戏只有多人模式。如果你想要在游戏中体验第一次世界大战,不要错过这款游戏! -[购买《坦能堡》][25] +- [购买《坦能堡》][25] ### Steam 上最佳 Linux 角色扮演类游戏 -### 11\. 中土世界:暗影魔多(Shadow of Mordor) +#### 11、 《中土世界:暗影魔多Shadow of Mordor》 《中土世界:暗影魔多》 是 Steam 上支持 Linux 的最好的开放式角色扮演类游戏之一。你将扮演一个游侠(塔里昂),和光明领主(凯勒布理鹏)并肩作战击败索隆的军队(并最终和他直接交手)。战斗机制非常出色。这是款不得不玩的游戏! -[购买《中土世界:暗影魔多》][26] +- [购买《中土世界:暗影魔多》][26] -### 12\. 神界:原罪加强版(Divinity: Original Sin – Enhanced Edition) +#### 12、 《神界:原罪加强版Divinity: Original Sin – Enhanced Edition》 《神界:原罪》是一款极其优秀的角色扮演类独立游戏。它非常独特而又引人入胜。这或许是评分最高的带有冒险和策略元素的角色扮演游戏。加强版添加了新的游戏模式,并且完全重做了配音、手柄支持、协作任务等等。 -[购买《神界:原罪加强版》][27] +- [购买《神界:原罪加强版》][27] -### 13\. 废土 2:导演剪辑版(Wasteland 2: Director’s Cut) +#### 13、 《废土 2:导演剪辑版Wasteland 2: Director’s Cut》 《废土 2》是一款出色的 CRPG 游戏。如果《辐射 4》被移植成 CRPG 游戏,大概就是这种感觉。导演剪辑版完全重做了画面,并且增加了一百多名新人物。 -[购买《废土 2》][28] +- [购买《废土 2》][28] -### 14\. 阴暗森林(Darkwood) +#### 14、 《阴暗森林Darkwood》 一个充满恐怖的俯视角角色扮演类游戏。你将探索世界、搜集材料、制作武器来生存下去。 -[购买《阴暗森林》][29] +- [购买《阴暗森林》][29] ### 最佳赛车 / 运动 / 模拟类游戏 -### 15\. 火箭联盟(Rocket League) +#### 15、 《火箭联盟Rocket League》 《火箭联盟》是一款充满刺激的足球游戏。游戏中你将驾驶用火箭助推的战斗赛车。你不仅是要驾车把球带进对方球门,你甚至还可以让你的对手化为灰烬! 这是款超棒的体育动作类游戏,每个游戏爱好者都值得拥有! -[购买《火箭联盟》][30] +- [购买《火箭联盟》][30] -### 16\. 公路救赎(Road Redemption) +#### 16、 《公路救赎Road Redemption》 想念《暴力摩托》了?作为它精神上的续作,《公路救赎》可以缓解你的饥渴。当然,这并不是真正的《暴力摩托 2》,但它一样有趣。如果你喜欢《暴力摩托》,你也会喜欢这款游戏。 -[购买《公路救赎》][31] +- [购买《公路救赎》][31] -### 17\. 尘埃拉力赛(Dirt Rally) +#### 17、 《尘埃拉力赛Dirt Rally》 《尘埃拉力赛》是为想要体验公路和越野赛车的玩家准备的。画面非常有魄力,驾驶手感也近乎完美。 -[购买《尘埃拉力赛》][32] +- [购买《尘埃拉力赛》][32] -### 18\. F1 2017 +#### 18、 《F1 2017》 《F1 2017》是另一款令人印象深刻的赛车游戏。由《尘埃拉力赛》的开发者 Codemasters & Feral Interactive 制作。游戏中包含了所有标志性的 F1 赛车,值得你去体验。 -[购买《F1 2017》][33] +- [购买《F1 2017》][33] -### 19. 超级房车赛:汽车运动(GRID Autosport) +#### 19、 《超级房车赛:汽车运动GRID Autosport》 《超级房车赛》是最被低估的赛车游戏之一。《超级房车赛:汽车运动》是《超级房车赛》的续作。这款游戏的可玩性令人惊艳。游戏中的赛车也比前作更好。推荐所有的 PC 游戏玩家尝试这款赛车游戏。游戏还支持多人模式,你可以和你的朋友组队参赛。 -[购买《超级房车赛:汽车运动》][34] +- [购买《超级房车赛:汽车运动》][34] ### 最好的冒险游戏 -### 20\. 方舟:生存进化(ARK: Survival Evolved) +#### 20、 《方舟:生存进化ARK: Survival Evolved》 《方舟:生存进化》是一款不错的生存游戏,里面有着激动人心的冒险。你发现自己身处一个未知孤岛(方舟岛),为了生存下去并逃离这个孤岛,你必须去驯服恐龙、与其他玩家合作、猎杀其他人来抢夺资源、以及制作物品。 -[购买《方舟:生存进化》][35] +- [购买《方舟:生存进化》][35] -### 21\. 这是我的战争(This War of Mine) +#### 21、 《这是我的战争This War of Mine》 一款独特的战争游戏。你不是扮演士兵,而是要作为一个平民来面对战争带来的艰难。你需要在身经百战的敌人手下逃生,并帮助其他的幸存者。 -[购买《这是我的战争》][36] +- [购买《这是我的战争》][36] -### 22\. 疯狂的麦克斯(Mad Max) +#### 22、 《疯狂的麦克斯Mad Max》 生存和暴力概括了《疯狂的麦克斯》的全部内容。游戏中有性能强大的汽车,开放性的世界,各种武器,以及徒手肉搏。你要不断地探索世界,并注意升级你的汽车来防患于未然。在做决定之前,你要仔细思考并设计好策略。 -[购买《疯狂的麦克斯》][37] +- [购买《疯狂的麦克斯》][37] ### 最佳独立游戏 -### 23\. 泰拉瑞亚(Terraria) +#### 23、 《泰拉瑞亚Terraria》 -这是款在 Steam 上广受好评的 2D 游戏。你在旅途中需要去挖掘、战斗、探索、建造。游戏地图是自动生成的,而不是静止的。也许你刚刚遇到的东西,你的朋友过一会儿才会遇到。你还将体验到富有新意的 2D 动作场景。 +这是款在 Steam 上广受好评的 2D 游戏。你在旅途中需要去挖掘、战斗、探索、建造。游戏地图是自动生成的,而不是固定不变的。也许你刚刚遇到的东西,你的朋友过一会儿才会遇到。你还将体验到富有新意的 2D 动作场景。 -[购买《泰拉瑞亚》][38] +- [购买《泰拉瑞亚》][38] -### 24\. 王国与城堡(Kingdoms and Castles) +#### 24、 《王国与城堡Kingdoms and Castles》 在《王国与城堡》中,你将建造你自己的王国。在管理你的王国的过程中,你需要收税、保护森林、规划城市,并且发展国防来防止别人入侵你的王国。 这是款比较新的游戏,但在独立游戏中已经相对获得了比较高的人气。 -[购买《王国与城堡》][39] +- [购买《王国与城堡》][39] ### Steam 上最佳 Linux 策略类游戏 -### 25\. 文明 5(Sid Meier’s Civilization V) +#### 25、 《文明 5Sid Meier’s Civilization V》 《文明 5》是 PC 上评价最高的策略游戏之一。如果你想的话,你可以去玩《文明 6》。但是依然有许多玩家喜欢《文明 5》,觉得它更有独创性,游戏细节也更富有创造力。 -[购买《文明 5》][40] +- [购买《文明 5》][40] -### 26\. 全面战争:战锤(Total War: Warhammer) +#### 26、 《全面战争:战锤Total War: Warhammer》 -《全面战争:战锤》是 PC 平台上一款非常出色的回合制策略游戏。可惜的是,新作《战锤 2》依然不支持Linux。但如果你喜欢使用飞龙和魔法来建造与毁灭帝国的话,2016 年的《战锤》依然是个不错的选择。 +《全面战争:战锤》是 PC 平台上一款非常出色的回合制策略游戏。可惜的是,新作《战锤 2》依然不支持 Linux。但如果你喜欢使用飞龙和魔法来建造与毁灭帝国的话,2016 年的《战锤》依然是个不错的选择。 -[购买《全面战争:战锤》][41] +- [购买《全面战争:战锤》][41] -### 27\. 轰炸小队《Bomber Crew》 +#### 27、 《轰炸小队Bomber Crew》 想要一款充满乐趣的策略游戏?《轰炸小队》就是为你准备的。你需要选择合适的队员并且让你的队伍稳定运转来取得最终的胜利。 -[购买《轰炸小队》][42] +- [购买《轰炸小队》][42] -### 28\. 奇迹时代 3(Age of Wonders III) +#### 28、 《奇迹时代 3Age of Wonders III》 非常流行的策略游戏,包含帝国建造、角色扮演、以及战争元素。这是款精致的回合制策略游戏,请一定要试试! -[购买《奇迹时代 3》][43] +- [购买《奇迹时代 3》][43] -### 29\. 城市:天际线(Cities: Skylines) +#### 29、 《城市:天际线Cities: Skylines》 -一款非常简洁的游戏。你要从零开始建造一座城市,并且管理它的全部运作。你将体验建造和管理城市带来的愉悦与困难。我不觉得每个玩家都会喜欢这款游戏——它的用户群体非常明确。 +一款非常简洁的策略游戏。你要从零开始建造一座城市,并且管理它的全部运作。你将体验建造和管理城市带来的愉悦与困难。我不觉得每个玩家都会喜欢这款游戏——它的用户群体非常明确。 -[购买《城市:天际线》][44] +- [购买《城市:天际线》][44] -### 30\. 幽浮 2(XCOM 2) +#### 30、 《幽浮 2XCOM 2》 -《幽浮 2》是 PC 上最好的回合制策略游戏之一。我在想如果《幽浮 2》能够被制作成 FPS 游戏的话该有多棒。不过它现在已经是一款好评如潮的杰作了。如果你有多余的预算能花在这款游戏上,建议你购买“天选之战(War of the Chosen)“ DLC。 +《幽浮 2》是 PC 上最好的回合制策略游戏之一。我在想如果《幽浮 2》能够被制作成 FPS 游戏的话该有多棒。不过它现在已经是一款好评如潮的杰作了。如果你有多余的预算能花在这款游戏上,建议你购买“天选之战War of the Chosen“ DLC。 -[购买《幽浮 2》][45] +- [购买《幽浮 2》][45] ### 总结 @@ -247,7 +241,7 @@ via: https://itsfoss.com/best-linux-games-steam/ 作者:[Ankush Das][a] 译者:[yixunx](https://github.com/yixunx) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -260,7 +254,7 @@ via: https://itsfoss.com/best-linux-games-steam/ [6]:https://itsfoss.com/best-linux-games-steam/#adv [7]:https://itsfoss.com/best-linux-games-steam/#indie [8]:https://itsfoss.com/best-linux-games-steam/#strategy -[9]:https://itsfoss.com/linux-gaming-guide/ +[9]:https://linux.cn/article-7316-1.html [10]:https://itsfoss.com/install-steam-ubuntu-linux/ [11]:https://www.humblebundle.com/?partner=itsfoss [12]:https://www.humblebundle.com/store?partner=itsfoss From 10f3feb64991c0ceeece73b048672c712e027020 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 7 Dec 2017 12:57:05 +0800 Subject: [PATCH 335/344] PUB:20171204 30 Best Linux Games On Steam You Should Play in 2017.md @yixunx https://linux.cn/article-9120-1.html --- ...171204 30 Best Linux Games On Steam You Should Play in 2017.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171204 30 Best Linux Games On Steam You Should Play in 2017.md (100%) diff --git a/translated/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md b/published/20171204 30 Best Linux Games On Steam You Should Play in 2017.md similarity index 100% rename from translated/tech/20171204 30 Best Linux Games On Steam You Should Play in 2017.md rename to published/20171204 30 Best Linux Games On Steam You Should Play in 2017.md From 94241be9d25d7a55a406798877481977fd8b5345 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 7 Dec 2017 15:59:31 +0800 Subject: [PATCH 336/344] translated --- ...g sudo to delegate permissions in Linux.md | 150 +++++++++--------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/sources/tech/20171205 Using sudo to delegate permissions in Linux.md b/sources/tech/20171205 Using sudo to delegate permissions in Linux.md index 46a807c7a4..0f24ae5a90 100644 --- a/sources/tech/20171205 Using sudo to delegate permissions in Linux.md +++ b/sources/tech/20171205 Using sudo to delegate permissions in Linux.md @@ -1,92 +1,91 @@ -translating by lujun9972 -Using sudo to delegate permissions in Linux +Linux下使用sudo进行赋权 ====== -I recently wrote a short Bash program to copy MP3 files from a USB thumb drive on one network host to another network host. The files are copied to a specific directory on the server that I run for a volunteer organization, from where the files can be downloaded and played. +我最近写了一个简短的 Bash 程序来将 MP3 文件从一台网络主机的 UBS 盘中拷贝到另一台网络主机上去。拷贝出来的文件存放在一台志愿者组织所属服务器的特定目录下, 在那里,这些文件可以被下载和播放。 -My program does a few other things, such as changing the name of the files before they are copied so they are automatically sorted by date on the webpage. It also deletes all the files on the USB drive after verifying that the transfer completed correctly. This nice little program has a few options, such as -h to display help, -t for test mode, and a couple of others. +我的程序还会做些其他事情,比如为了自动在网页上根据日期排序,在拷贝文件之前会先对这些文件重命名。 在验证拷贝完成后,还会删掉 USB 盘中的所有文件。 这个小程序还有一些其他选项,比如 `-h` 会显示帮助, `-t` 进入测试模式等等。 -My program, as wonderful as it is, must run as root to perform its primary functions. Unfortunately, this organization has only a few people who have any interest in administering our audio and computer systems, which puts me in the position of finding semi-technical people and training them to log into the computer used to perform the transfer and run this little program. +我的程序需要以 root 运行才能发挥作用。然而, 这个组织中之后很少的人对管理音频和计算机系统有兴趣的,这使得我不得不找那些半吊子的科技人员来,并培训他们登陆用于传输的计算机,运行这个小程序。 -It is not that I cannot run the program myself, but for various reasons, including travel and illness, I am not always there. Even when I am present, as the "lazy sysadmin," I like to have others do my work for me. So, I write scripts to automate those tasks and use sudo to anoint a couple of users to run the scripts. Many Linux commands require the user to be root in order to run. This protects the system against accidental damage, such as that caused by my own stupidity, and intentional damage by a user with malicious intent. +倒不是说我不能亲自运行这个程序,但由于外出和疾病等等各种原因, 我不是时常在场的。 即使我在场, 作为一名 "懒惰的系统管理员", 我也希望别人能替我把事情给做了。 因此我写了一些脚本来自动完成这些人物并通过 sudo 来指定某些人来运行这些脚本。 很多 Linux 命令都需要用户以 root 身份来运行。 sudo 能够保护系统免遭一时糊涂造成的意外损坏以及恶意用户的故意破坏。 ### Do that sudo that you do so well -The sudo program is a handy tool that allows me as a sysadmin with root access to delegate responsibility for all or a few administrative tasks to other users of the computer. It allows me to perform that delegation without compromising the root password, thus maintaining a high level of security on the host. +sudo 是一个很方便的工具,它让我一个 root 管理员可以分配所有或者部分管理性的任务给其他用户, 而且还无需告诉他们 root 密码, 从而保证主机的高安全性。 -Let's assume, for example, that I have given regular user, "ruser," access to my Bash program, "myprog," which must be run as root to perform parts of its functions. First, the user logs in as ruser with their own password, then uses the following command to run myprog. +假设,我给了普通用户 "ruser" 访问我 Bash 程序 "myprog" 的权限, 而这个程序的部分功能需要 root 权限。 那么该用户可以以 ruser 的身份登陆,然后通过以下命令运行 myprog。 -``` - sudo myprog +```shell +sudo myprog ``` -I find it helpful to have the log of each command run by sudo for training. I can see who did what and whether they entered the command correctly. +我发现在训练时记录下每个用 sudo 执行的命令会很有帮助。我可以看到谁执行了哪些命令,他们是否输对了。 -I have done this to delegate authority to myself and one other user to run a single program; however, sudo can be used to do so much more. It can allow the sysadmin to delegate authority for managing network functions or specific services to a single person or to a group of trusted users. It allows these functions to be delegated while protecting the security of the root password. +我委派了权限给自己和另一个人来运行那个程序; 然而,sudo 可以做更多的事情。 它允许系统管理员委派网络管理或特定的服务器权限给某个人或某组人,以此来保护 root 密码的安全性。 -### Configuring the sudoers file +### 配置 sudoers 文件 -As a sysadmin, I can use the /etc/sudoers file to allow users or groups of users access to a single command, defined groups of commands, or all commands. This flexibility is key to both the power and the simplicity of using sudo for delegation. +作为一名系统管理员,我使用 `/etc/sudoers` 文件来设置某些用户或某些用户组可以访问某个命令,或某组命令,或所有命令。 这种灵活性是使用 sudo 进行委派时能兼顾功能与简易性的关键。 -I found the sudoers file very confusing at first, so below I have copied and deconstructed the entire sudoers file from the host on which I am using it. Hopefully it won't be quite so obscure for you by the time you get through this analysis. Incidentally, I've found that the default configuration files in Red Hat-based distributions tend to have lots of comments and examples to provide guidance, which makes things easier, with less online searching required. +我一开始对 `sudoers` 文件感到很困惑,因此下面我会拷贝并分解我所使用主机上的完整 `sudoers` 文件。 希望在分析的过程中不会让你感到困惑。 我意外地发现, 基于 Red Hat 的发行版中默认的配置文件都会很多注释以及例子来指导你如何做出修改,这使得修改配置文件变得简单了很多,也不需要在互联网上搜索那么多东西了。 -Do not use your standard editor to modify the sudoers file. Use the visudo command because it is designed to enable any changes as soon as the file is saved and you exit the editor. It is possible to use editors besides Vi in the same way as visudo. +不要直接用编辑起来修改 sudoers 文件,而应该用 `visudo` 命令,因为该命令会在你保存并退出编辑器后就立即生效这些变更。 visudo 也可以使用除了 `Vi` 之外的其他编辑器。 -Let's start analyzing this file at the beginning with a couple types of aliases. +让我们首先来分析一下文件中的各种别名。 -### Host aliases +#### Host aliases(主机别名) -The host aliases section is used to create groups of hosts on which commands or command aliases can be used to provide access. The basic idea is that this single file will be maintained for all hosts in an organization and copied to /etc of each host. Some hosts, such as servers, can thus be configured as a group to give some users access to specific commands, such as the ability to start and stop services like HTTPD, DNS, and networking; to mount filesystems; and so on. +host aliases 用于创建主机分组,在不同主机上可以设置允许访问不同的命令或命令别名 (command aliases)。 它的基本思想是,该文件由组织中的所有主机共同维护,然后拷贝到每台主机中的 `/etc` 中。 其中有些主机, 例如各种服务器, 可以配置成一个组来赋予用户访问特定命令的权限, 比如可以启停类似 HTTPD, DNS, 以及网络服务; 可以挂载文件系统等等。 -IP addresses can be used instead of host names in the host aliases. +在设置主机别名时也可以用 IP 地址替代主机名。 ``` ## Sudoers allows particular users to run various commands as -## the root user, without needing the root password. +## the root user,without needing the root password。 ## ## Examples are provided at the bottom of the file for collections -## of related commands, which can then be delegated out to particular -## users or groups. +## of related commands,which can then be delegated out to particular +## users or groups。 ## -## This file must be edited with the 'visudo' command. +## This file must be edited with the 'visudo' command。 ## Host Aliases -## Groups of machines. You may prefer to use hostnames (perhaps using -## wildcards for entire domains) or IP addresses instead. -# Host_Alias FILESERVERS = fs1, fs2 -# Host_Alias MAILSERVERS = smtp, smtp2 +## Groups of machines。You may prefer to use hostnames (perhaps using +## wildcards for entire domains) or IP addresses instead。 +# Host_Alias FILESERVERS = fs1,fs2 +# Host_Alias MAILSERVERS = smtp,smtp2 ## User Aliases -## These aren't often necessary, as you can use regular groups -## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname +## These aren't often necessary,as you can use regular groups +## (ie,from files, LDAP, NIS, etc) in this file - just use %groupname ## rather than USERALIAS -# User_Alias ADMINS = jsmith, mikem -User_Alias AUDIO = dboth, ruser +# User_Alias ADMINS = jsmith,mikem +User_Alias AUDIO = dboth,ruser ## Command Aliases -## These are groups of related commands... +## These are groups of related commands。.。 ## Networking -# Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, - /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, -/usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool +# Cmnd_Alias NETWORKING = /sbin/route,/sbin/ifconfig, + /bin/ping,/sbin/dhclient, /usr/bin/net, /sbin/iptables, +/usr/bin/rfcomm,/usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool ## Installation and management of software -# Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum +# Cmnd_Alias SOFTWARE = /bin/rpm,/usr/bin/up2date, /usr/bin/yum ## Services -# Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig +# Cmnd_Alias SERVICES = /sbin/service,/sbin/chkconfig ## Updating the locate database # Cmnd_Alias LOCATE = /usr/bin/updatedb ## Storage -# Cmnd_Alias STORAGE = /sbin/fdisk, /sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount +# Cmnd_Alias STORAGE = /sbin/fdisk,/sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount ## Delegating permissions -# Cmnd_Alias DELEGATING = /usr/sbin/visudo, /bin/chown, /bin/chmod, /bin/chgrp +# Cmnd_Alias DELEGATING = /usr/sbin/visudo,/bin/chown, /bin/chmod, /bin/chgrp ## Processes -# Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall +# Cmnd_Alias PROCESSES = /bin/nice,/bin/kill, /usr/bin/kill, /usr/bin/killall ## Drivers # Cmnd_Alias DRIVERS = /sbin/modprobe @@ -94,9 +93,9 @@ User_Alias AUDIO = dboth, ruser # Defaults specification # -# Refuse to run if unable to disable echo on the tty. +# Refuse to run if unable to disable echo on the tty。 # -Defaults !visiblepw +Defaults!visiblepw Defaults env_reset Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS" @@ -109,19 +108,19 @@ Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin ## Next comes the main part: which users can run what software on ## which machines (the sudoers file can be shared between multiple -## systems). +## systems)。 ## Syntax: ## ## user MACHINE=COMMANDS ## -## The COMMANDS section may have other options added to it. +## The COMMANDS section may have other options added to it。 ## ## Allow root to run any commands anywhere root ALL=(ALL) ALL -## Allows members of the 'sys' group to run networking, software, -## service management apps and more. -# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS +## Allows members of the 'sys' group to run networking,software, +## service management apps and more。 +# %sys ALL = NETWORKING,SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS ## Allows people in group wheel to run all commands %wheel ALL=(ALL) ALL @@ -131,7 +130,7 @@ root ALL=(ALL) ALL ## Allows members of the users group to mount and unmount the ## cdrom as root -# %users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom +# %users ALL=/sbin/mount /mnt/cdrom,/sbin/umount /mnt/cdrom ## Allows members of the users group to shutdown this system # %users localhost=/sbin/shutdown -h now @@ -140,81 +139,82 @@ root ALL=(ALL) ALL #includedir /etc/sudoers.d ################################################################################ -# Added by David Both, 11/04/2017 to provide limited access to myprog # +# Added by David Both,11/04/2017 to provide limited access to myprog # ################################################################################ # AUDIO guest1=/usr/local/bin/myprog ``` -### User aliases +#### User aliases(用户别名) -The user alias configuration allows root to sort users into aliased groups so that an entire group can have access to certain root capabilities. This is the section to which I have added the line User_Alias AUDIO = dboth, ruser, which defines the alias AUDIO and assigns two users to that alias. +user alias 允许 root 将用户整理成组并按组来分配权限。在这部分内容中我加了一行 `User_Alias AUDIO = dboth, ruser`,他定义了一个别名 `AUDIO` 用来指代了两个用户。 -It is possible, as stated in the sudoers file, to simply use groups defined in the /etc/groups file instead of aliases. If you already have a group defined there that meets your needs, such as "audio," use that group name preceded by a % sign like so: %audio when assigning commands that will be made available to groups later in the sudoers file. +正如 `sudoers` 文件中所阐明的,也可以直接使用 `/etc/groups` 中定义的组而不用自己设置别名。 如果你定义好的组(假设组名为 "audio")已经能满足要求了, 那么在后面分配命令时只需要在组名前加上 `%` 号,像这样: %audio。 -### Command aliases +#### Command aliases(命令别名) -Further down in the sudoers file is a command aliases section. These aliases are lists of related commands, such as networking commands or commands required to install updates or new RPM packages. These aliases allow the sysadmin to easily permit access to groups of commands. +再后面是 command aliases 部分。这些别名表示的是一系列相关的命令, 比如网络相关命令,或者 RPM 包管理命令。 这些别名允许系统管理员方便地为一组命令分配权限。 -A number of aliases are already set up in this section that make it easy to delegate access to specific types of commands. +该部分内容已经设置好了许多别名,这使得分配权限给某类命令变得方便很多。 -### Environment defaults +#### Environment defaults(环境默认值) -The next section sets some default environment variables. The item that is most interesting in this section is the !visiblepw line, which prevents sudo from running if the user environment is set to show the password. This is a security precaution that should not be overridden. +下部分内容设置默认的环境变量。这部分最值得关注的是 `!visiblepw` 这一行, 它表示当用户环境设置成显示密码时禁止 `sudo` 的运行。 这个安全措施不应该被修改掉。 -### Command section +#### Command section(命令部分) -The command section is the main part of the sudoers file. Everything you need to do can be done without all the aliases by adding enough entries here. The aliases just make it a whole lot easier. +command 部分是 `sudoers` 文件的主体。不使用别名并不会影响你完成要实现 的效果。 它只是让整个配置工作大幅简化而已。 -This section uses the aliases you've already defined to tell sudo who can do what on which hosts. The examples are self-explanatory once you understand the syntax in this section. Let's look at the syntax that we find in the command section. +这部分使用之前定义的别名来告诉 `sudo` 哪些人可以在哪些机器上执行哪些操作。一旦你理解了这部分内容的语法,你会发现这些例子都非常的直观。 下面我们来看看它的语法。 ``` ruser ALL=(ALL) ALL ``` -This is a generic entry for our user, ruser. The first ALL in the line indicates that this rule applies on all hosts. The second ALL allows ruser to run commands as any other user. By default, commands are run as root user, but ruser can specify on the sudo command line that a program be run as any other user. The last ALL means that ruser can run all commands without restriction. This would effectively make ruser root. +这是一条为用户 ruser 做出的配置。行中第一个 `ALL` 表示该条规则在所有主机上生效。 第二个 `ALL` 允许 ruser 以其他用户的身份运行命令。 默认情况下, 命令以 root 用户的身份运行, 但 ruser 可以在 sudo 命令行指定程序以其他用户的身份运行。 最后这个 ALL 表示 ruser 可以运行所有命令而不受限制。 这让 ruser 实际上就变成了 root。 -Note that there is an entry for root, as shown below. This allows root to have all-encompassing access to all commands on all hosts. +注意到下面还有一条针对 root 的配置。这允许 root 能通过 sudo 在任何主机上运行任何命令。 ``` root ALL=(ALL) ALL ``` -To try this out, I commented out the line and, as root, tried to run chown without sudo. That did work—much to my surprise. Then I used sudo chown and that failed with the message, "Root is not in the sudoers file. This incident will be reported." This means that root can run everything as root, but nothing when using the sudo command. This would prevent root from running commands as other users via the sudo command, but root has plenty of ways around that restriction. +为了实验一下效果,我注释掉了这行, 然后以 root 的身份, 试着直接运行 chown。 出乎意料的是这样是能成功的。 然后我试了下 sudo chown,结果失败了,提示信息 "Root is not in the sudoers file。 This incident will be reported"。 也就是说 root 可以直接运行任何命令, 但当加上 sudo 时则不行。 这会阻止 root 像其他用户一样使用 sudo 命令来运行其他命令, 但是 root 有太多中方法可以绕过这个约束了。 -The code below is the one I added to control access to myprog. It specifies that users who are listed in the AUDIO group, as defined near the top of the sudoers file, have access to only one program, myprog, on one host, guest1. +下面这行是我新增来控制访问 myprog 的。它指定了只有上面定义的 AUDIO 组中的用户才能在 guest1 这台主机上使用 myprog 这个命令。 ``` AUDIO guest1=/usr/local/bin/myprog ``` -Note that the syntax of the line above specifies only the host on which this access is to be allowed and the program. It does not specify that the user may run the program as any other user. +注意,上面这一行只指定了允许访问的主机名和程序, 而没有说用户可以以其他用户的身份来运行该程序。 -### Bypassing passwords +#### 省略密码 -You can also use NOPASSWORD to allow the users specified in the group AUDIO to run myprog without the need for entering their passwords. Here's how: +你也可以通过 NOPASSWORD 来让 AUDIO 组中的用户无需密码就能运行 myprog。像这样 Here's how: ``` AUDIO guest1=NOPASSWORD : /usr/local/bin/myprog ``` -I did not do this for my program, because I believe that users with sudo access must stop and think about what they are doing, and this may help a bit with that. I used the entry for my little program as an example. +我并没有这样做,因为哦我觉得使用 sudo 的用户必须要停下来想清楚他们正在做的事情,这对他们有好处。 我这里只是举个例子。 -### wheel +#### wheel -The wheel specification in the command section of the sudoers file, as shown below, allows all users in the "wheel" group to run all commands on any host. The wheel group is defined in the /etc/group file, and users must be added to the group there for this to work. The % sign preceding the group name means that sudo should look for that group in the /etc/group file. +`sudoers` 文件中命令部分的 `wheel` 说明(如下所示)允许所有在 "wheel" 组中的用户在任何机器上运行任何命令。wheel 组在 `/etc/group` 文件中定义, 用户必须加入该组后才能工作。 组名前面的 % 符号表示 sudo 应该去 `/etc/group` 文件中查找该组。 ``` %wheel ALL = (ALL) ALL ``` -This is a good way to delegate full root access to multiple users without providing the root password. Just adding a user to the wheel group gives them access to full root powers. It also provides a means to monitor their activities via the log entries created by sudo. Some distributions, such as Ubuntu, add users' IDs to the wheel group in /etc/group, which allows them to use the sudo command for all privileged commands. +这种方法很好的实现了为多个用户赋予完全的 root 权限而不用提供 root 密码。只需要把哦嗯虎加入 wheel 组中就能给他们提供完整的 root 的能力。 它也提供了一个种通过 sudo 创建的日志来监控他们行为的途径。 有些 Linux 发行版, 比如 Ubuntu, 会自动将用户的 ID 加入 `/etc/group` 中的 wheel 组中, 这使得他们能够用 sudo 命令运行所有的特权命令。 -### Final thoughts +### 结语 -I have used sudo here for a very limited objective—providing one or two users with access to a single command. I accomplished this with two lines (if you ignore my own comments). Delegating authority to perform certain tasks to users who do not have root access is simple and can save you, as a sysadmin, a good deal of time. It also generates log entries that can help detect problems. +我这里只是小试了一把 sudo — 我只是给一到两个用户以 root 权限运行单个命令的权限。完成这些只添加了两行配置(不考虑注释)。 将某项任务的权限委派给其他非 root 用户非常简单,而且可以节省你大量的时间。 同时它还会产生日志来帮你发现问题。 + +`sudoers` 文件还有许多其他的配置和能力。查看 sudo 和 sudoers 的 man 手册可以深入了解详细信息。 -The sudoers file offers a plethora of capabilities and options for configuration. Check the man files for sudo and sudoers for the down-and-dirty details. -------------------------------------------------------------------------------- From f48e6defcc1040148bf099b5ffe986f08c029e52 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 7 Dec 2017 16:00:20 +0800 Subject: [PATCH 337/344] move to translated --- .../tech/20171205 Using sudo to delegate permissions in Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources => translated}/tech/20171205 Using sudo to delegate permissions in Linux.md (100%) diff --git a/sources/tech/20171205 Using sudo to delegate permissions in Linux.md b/translated/tech/20171205 Using sudo to delegate permissions in Linux.md similarity index 100% rename from sources/tech/20171205 Using sudo to delegate permissions in Linux.md rename to translated/tech/20171205 Using sudo to delegate permissions in Linux.md From 2a75d325e3a725248eabf27f2d78f5512e399cd6 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 7 Dec 2017 16:12:11 +0800 Subject: [PATCH 338/344] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Suplemon=20-=20Mo?= =?UTF-8?q?dern=20CLI=20Text=20Editor=20with=20Multi=20Cursor=20Support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...I Text Editor with Multi Cursor Support.md | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 sources/tech/20171129 Suplemon - Modern CLI Text Editor with Multi Cursor Support.md diff --git a/sources/tech/20171129 Suplemon - Modern CLI Text Editor with Multi Cursor Support.md b/sources/tech/20171129 Suplemon - Modern CLI Text Editor with Multi Cursor Support.md new file mode 100644 index 0000000000..2b82be93ba --- /dev/null +++ b/sources/tech/20171129 Suplemon - Modern CLI Text Editor with Multi Cursor Support.md @@ -0,0 +1,151 @@ +Suplemon - Modern CLI Text Editor with Multi Cursor Support +====== +Suplemon is a modern text editor for CLI that emulates the multi cursor behavior and other features of [Sublime Text][1]. It's lightweight and really easy to use, just as Nano is. + +One of the benefits of using a CLI editor is that you can use it whether the Linux distribution that you're using has a GUI or not. This type of text editors also stands out as being simple, fast and powerful. + +You can find useful information and the source code in the [official repository][2]. + +### Features + +These are some of its interesting features: + +* Multi cursor support + +* Undo / Redo + +* Copy and Paste, with multi line support + +* Mouse support + +* Extensions + +* Find, find all, find next + +* Syntax highlighting + +* Autocomplete + +* Custom keyboard shortcuts + +### Installation + +First, make sure you have the latest version of python3 and pip3 installed. + +Then type in a terminal: + +``` +$ sudo pip3 install suplemon +``` + +Create a new file in the current directory + +Open a terminal and type: + +``` +$ suplemon +``` + +![suplemon new file](https://linoxide.com/wp-content/uploads/2017/11/suplemon-new-file.png) + +Open one or multiple files + +Open a terminal and type: + +``` +$ suplemon ... +``` + +``` +$ suplemon example1.c example2.c +``` + +Main configuration + +You can find the configuration file at ~/.config/suplemon/suplemon-config.json. + +Editing this file is easy, you just have to enter command mode (once you are inside suplemon) and run the config command. You can view the default configuration by running config defaults. + +Keymap configuration + +I'll show you the default key mappings for suplemon. If you want to edit them, just run keymap command. Run keymap default to view the default keymap file. + +* Exit: Ctrl + Q + +* Copy line(s) to buffer: Ctrl + C + +* Cut line(s) to buffer: Ctrl + X + +* Insert buffer: Ctrl + V + +* Duplicate line: Ctrl + K + +* Goto: Ctrl + G. You can go to a line or to a file (just type the beginning of a file name). Also, it is possible to type something like 'exam:50' to go to the line 50 of the file example.c at line 50. + +* Search for string or regular expression: Ctrl + F + +* Search next: Ctrl + D + +* Trim whitespace: Ctrl + T + +* Add new cursor in arrow direction: Alt + Arrow key + +* Jump to previous or next word or line: Ctrl + Left / Right + +* Revert to single cursor / Cancel input prompt: Esc + +* Move line(s) up / down: Page Up / Page Down + +* Save file: Ctrl + S + +* Save file with new name: F1 + +* Reload current file: F2 + +* Open file: Ctrl + O + +* Close file: Ctrl + W + +* Switch to next/previous file: Ctrl + Page Up / Ctrl + Page Down + +* Run a command: Ctrl + E + +* Undo: Ctrl + Z + +* Redo: Ctrl + Y + +* Toggle visible whitespace: F7 + +* Toggle mouse mode: F8 + +* Toggle line numbers: F9 + +* Toggle Full screen: F11 + +Mouse shortcuts + +* Set cursor at pointer position: Left Click + +* Add a cursor at pointer position: Right Click + +* Scroll vertically: Scroll Wheel Up / Down + +### Wrapping up + +After trying Suplemon for some time, I have changed my opinion about CLI text editors. I had tried Nano before, and yes, I liked its simplicity, but its modern-feature lack made it non-practical for my everyday use. + +This tool has the best of both CLI and GUI worlds... Simplicity and feature-richness! So I suggest you give it a try, and write your thoughts in the comments :-) + +-------------------------------------------------------------------------------- + +via: https://linoxide.com/tools/suplemon-cli-text-editor-multi-cursor/ + +作者:[Ivo Ursino][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://linoxide.com/author/ursinov/ +[1]:https://linoxide.com/tools/install-sublime-text-editor-linux/ +[2]:https://github.com/richrd/suplemon/ From b9e0afd5b4a9f60575a442f5c179faa1f77c9655 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 7 Dec 2017 16:17:49 +0800 Subject: [PATCH 339/344] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Know?= =?UTF-8?q?=20What=20A=20Command=20Or=20Program=20Will=20Exactly=20Do=20Be?= =?UTF-8?q?fore=20Executing=20It?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ram Will Exactly Do Before Executing It.md | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 sources/tech/20171204 How To Know What A Command Or Program Will Exactly Do Before Executing It.md diff --git a/sources/tech/20171204 How To Know What A Command Or Program Will Exactly Do Before Executing It.md b/sources/tech/20171204 How To Know What A Command Or Program Will Exactly Do Before Executing It.md new file mode 100644 index 0000000000..417be5b294 --- /dev/null +++ b/sources/tech/20171204 How To Know What A Command Or Program Will Exactly Do Before Executing It.md @@ -0,0 +1,143 @@ +How To Know What A Command Or Program Will Exactly Do Before Executing It +====== +Ever wondered what a Unix command will do before executing it? Not everyone knows what a particular command or program will do. Of course, you can check it with [Explainshell][2]. You need to copy/paste the command in Explainshell website and it let you know what each part of a Linux command does. However, it is not necessary. Now, we can easily know what a command or program will exactly do before executing it, right from the Terminal. Say hello to “maybe”, a simple tool that allows you to run a command and see what it does to your files without actually doing it! After reviewing the output listed, you can then decide whether you really want to run it or not. + +#### How “maybe” works? + +According to the developer, + +> “maybe” runs processes under the control of ptrace with the help of python-ptrace library. When it intercepts a system call that is about to make changes to the file system, it logs that call, and then modifies CPU registers to both redirect the call to an invalid syscall ID (effectively turning it into a no-op) and set the return value of that no-op call to one indicating success of the original call. As a result, the process believes that everything it is trying to do is actually happening, when in reality nothing is. + +Warning: You should be very very careful when using this utility in a production system or in any systems you care about. It can still do serious damages, because it will block only a handful of syscalls. + +#### Installing “maybe” + +Make sure you have installed pip in your Linux system. If not, install it as shown below depending upon the distribution you use. + +On Arch Linux and its derivatives like Antergos, Manjaro Linux, install pip using the following command: + +``` +sudo pacman -S python-pip +``` + +On RHEL, CentOS: + +``` +sudo yum install epel-release +``` + +``` +sudo yum install python-pip +``` + +On Fedora: + +``` +sudo dnf install epel-release +``` + +``` +sudo dnf install python-pip +``` + +On Debian, Ubuntu, Linux Mint: + +``` +sudo apt-get install python-pip +``` + +On SUSE, openSUSE: + +``` +sudo zypper install python-pip +``` + +Once pip installed, run the following command to install “maybe”. + +``` +sudo pip install maybe +``` + +#### Know What A Command Or Program Will Exactly Do Before Executing It + +Usage is absolutely easy! Just add “maybe” in front of a command that you want to execute. + +Allow me to show you an example. + +``` +$ maybe rm -r ostechnix/ +``` + +As you can see, I am going to delete a folder called “ostechnix” from my system. Here is the sample output. + +``` +maybe has prevented rm -r ostechnix/ from performing 5 file system operations: + + delete /home/sk/inboxer-0.4.0-x86_64.AppImage + delete /home/sk/Docker.pdf + delete /home/sk/Idhayathai Oru Nodi.mp3 + delete /home/sk/dThmLbB334_1398236878432.jpg + delete /home/sk/ostechnix + +Do you want to rerun rm -r ostechnix/ and permit these operations? [y/N] y +``` + + [![](http://www.ostechnix.com/wp-content/uploads/2017/12/maybe-1.png)][3] + +The “maybe” tool performs 5 file system operations and shows me what this command (rm -r ostechnix/) will exactly do. Now I can decide whether I should perform this operation or not. Cool, yeah? Indeed! + +Here is another example. I am going to install [Inboxer][4] desktop client for Gmail. This is what I got. + +``` +$ maybe ./inboxer-0.4.0-x86_64.AppImage +fuse: bad mount point `/tmp/.mount_inboxemDzuGV': No such file or directory +squashfuse 0.1.100 (c) 2012 Dave Vasilevsky + +Usage: /home/sk/Downloads/inboxer-0.4.0-x86_64.AppImage [options] ARCHIVE MOUNTPOINT + +FUSE options: + -d -o debug enable debug output (implies -f) + -f foreground operation + -s disable multi-threaded operation + +open dir error: No such file or directory +maybe has prevented ./inboxer-0.4.0-x86_64.AppImage from performing 1 file system operations: + +create directory /tmp/.mount_inboxemDzuGV + +Do you want to rerun ./inboxer-0.4.0-x86_64.AppImage and permit these operations? [y/N] +``` + +If it not detects any file system operations, then it will simply display a result something like below. + +For instance, I run this command to update my Arch Linux. + +``` +$ maybe sudo pacman -Syu +sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges? +maybe has not detected any file system operations from sudo pacman -Syu. +``` + +See? It didn’t detect any file system operations, so there were no warnings. This is absolutely brilliant and exactly what I was looking for. From now on, I can easily know what a command or a program will do even before executing it. I hope this will be useful to you too. More good stuffs to come. Stay tuned! + +Cheers! + +Resource: + +* [“maybe” GitHub page][1] + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/know-command-program-will-exactly-executing/ + +作者:[SK][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://github.com/p-e-w/maybe +[2]:https://www.ostechnix.com/explainshell-find-part-linux-command/ +[3]:http://www.ostechnix.com/wp-content/uploads/2017/12/maybe-1.png +[4]:https://www.ostechnix.com/inboxer-unofficial-google-inbox-desktop-client/ From 512ed82739b4a794f83043a20bdd314f157b1e7d Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 7 Dec 2017 16:25:33 +0800 Subject: [PATCH 340/344] =?UTF-8?q?=E9=80=89=E9=A2=98:=20NETSTAT=20Command?= =?UTF-8?q?:=20Learn=20to=20use=20netstat=20with=20examples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...mand Learn to use netstat with examples.md | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 sources/tech/20171205 NETSTAT Command Learn to use netstat with examples.md diff --git a/sources/tech/20171205 NETSTAT Command Learn to use netstat with examples.md b/sources/tech/20171205 NETSTAT Command Learn to use netstat with examples.md new file mode 100644 index 0000000000..1f3b8976b1 --- /dev/null +++ b/sources/tech/20171205 NETSTAT Command Learn to use netstat with examples.md @@ -0,0 +1,112 @@ +translating by lujun9972 +NETSTAT Command: Learn to use netstat with examples +====== +Netstat is a command line utility that tells us about all the tcp/udp/unix socket connections on our system. It provides list of all connections that are currently established or are in waiting state. This tool is extremely useful in identifying the port numbers on which an application is working and we can also make sure if an application is working or not on the port it is supposed to work. + +Netstat command also displays various other network related information such as routing tables, interface statistics, masquerade connections, multicast memberships etc., + +In this tutorial, we will learn about Netstat with examples. + +(Recommended Read: [Learn to use CURL command with examples][1] ) + +Netstat with examples +============================================================ + +### 1- Checking all connections + +To list out all the connections on a system, we can use ‘a’ option with netstat command, + +$ netstat -a + +This will produce all tcp, udp & unix connections from the system. + +### 2- Checking all tcp or udp or unix socket connections + +To list only the tcp connections our system, use ‘t’ options with netstat, + +$ netstat -at + +Similarly to list out only the udp connections on our system, we can use ‘u’ option with netstat, + +$ netstat -au + +To only list out Unix socket connections, we can use ‘x’ options, + +$ netstat -ax + +### 3- List process id/Process Name with + +To get list of all connections along with PID or process name, we can use ‘p’ option & it can be used in combination with any other netstat option, + +$ netstat -ap + +### 4- List only port number & not the name + +To speed up our output, we can use ‘n’ option as it will perform any reverse lookup & produce output with only numbers. Since no lookup is performed, our output will much faster. + +$ netstat -an + +### 5- Print only listening ports + +To print only the listening ports , we will use ‘l’ option with netstat. It will not be used with ‘a’ as it prints all ports, + +$ netstat -l + +### 6- Print network stats + +To print network statistics of each protocol like packet received or transmitted, we can use ‘s’ options with netstat, + +$ netstat -s + +### 7- Print interfaces stats + +To display only the statistics on network interfaces, use ‘I’ option, + +$ netstat -i + +### 8-Display multicast group information + +With option ‘g’ , we can print the multicast group information for IPV4 & IPV6, + +$ netstat -g + +### 9- Display the network routing information + +To print the network routing information, use ‘r’ option, + +$ netstat -r + +### 10- Continuous output + +To get continuous output of netstat, use ‘c’ option + +$ netstat -c + +### 11- Filtering a single port + +To filter a single port connections, we can combine ‘grep’ command with netstat, + +$ netstat -anp | grep 3306 + +### 12- Count number of connections + +To count the number of connections from port, we can further add ‘wc’ command with netstat & grep command, + +$ netstat -anp | grep 3306 | wc -l + +This will print the number of connections for the port mysql port i.e. 3306. + +This was our brief tutorial on Netstat with examples, hope it was informative enough. If you have any query or suggestion, please mention it in the comment box below. + +-------------------------------------------------------------------------------- + +via: http://linuxtechlab.com/learn-use-netstat-with-examples/ + +作者:[Shusain][a] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://linuxtechlab.com/author/shsuain/ +[1]:http://linuxtechlab.com/learn-use-curl-command-examples/ From 01e5f3c72ac28a29ddd55716eba723a58e9ef48f Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 7 Dec 2017 18:28:36 +0800 Subject: [PATCH 341/344] translating by lujun9972 --- ...0171205 NETSTAT Command Learn to use netstat with examples.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171205 NETSTAT Command Learn to use netstat with examples.md b/sources/tech/20171205 NETSTAT Command Learn to use netstat with examples.md index 1f3b8976b1..4001ab5c08 100644 --- a/sources/tech/20171205 NETSTAT Command Learn to use netstat with examples.md +++ b/sources/tech/20171205 NETSTAT Command Learn to use netstat with examples.md @@ -1,4 +1,5 @@ translating by lujun9972 +translating by lujun9972 NETSTAT Command: Learn to use netstat with examples ====== Netstat is a command line utility that tells us about all the tcp/udp/unix socket connections on our system. It provides list of all connections that are currently established or are in waiting state. This tool is extremely useful in identifying the port numbers on which an application is working and we can also make sure if an application is working or not on the port it is supposed to work. From 28d7268898251b27cfa2db99875ad3fde8f12e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=88=E6=B0=B8?= Date: Thu, 7 Dec 2017 19:38:02 +0800 Subject: [PATCH 342/344] =?UTF-8?q?=E9=80=89=E9=A2=98=20How=20to=20use=20c?= =?UTF-8?q?ron=20in=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20171207 How to use cron in Linux.md | 288 ++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 sources/tech/20171207 How to use cron in Linux.md diff --git a/sources/tech/20171207 How to use cron in Linux.md b/sources/tech/20171207 How to use cron in Linux.md new file mode 100644 index 0000000000..3165aa8139 --- /dev/null +++ b/sources/tech/20171207 How to use cron in Linux.md @@ -0,0 +1,288 @@ +translating by yongshouzhang + +How to use cron in Linux +============================================================ + +### No time for commands? Scheduling tasks with cron means programs can run but you don't have to stay up late. + + [![](https://opensource.com/sites/default/files/styles/byline_thumbnail/public/david-crop.jpg?itok=Wnz6HdS0)][10] 06 Nov 2017 [David Both][11] [Feed][12] + +27[up][13] + + [9 comments][14] +![How to use cron in Linux](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux-penguins.png?itok=yKOpaJM_) + +Image by : + +[Internet Archive Book Images][15]. Modified by Opensource.com. [CC BY-SA 4.0][16] + +One of the challenges (among the many advantages) of being a sysadmin is running tasks when you'd rather be sleeping. For example, some tasks (including regularly recurring tasks) need to run overnight or on weekends, when no one is expected to be using computer resources. I have no time to spare in the evenings to run commands and scripts that have to operate during off-hours. And I don't want to have to get up at oh-dark-hundred to start a backup or major update. + +Instead, I use two service utilities that allow me to run commands, programs, and tasks at predetermined times. The [cron][17] and at services enable sysadmins to schedule tasks to run at a specific time in the future. The at service specifies a one-time task that runs at a certain time. The cron service can schedule tasks on a repetitive basis, such as daily, weekly, or monthly. + +In this article, I'll introduce the cron service and how to use it. + +### Common (and uncommon) cron uses + +I use the cron service to schedule obvious things, such as regular backups that occur daily at 2 a.m. I also use it for less obvious things. + +* The system times (i.e., the operating system time) on my many computers are set using the Network Time Protocol (NTP). While NTP sets the system time, it does not set the hardware time, which can drift. I use cron to set the hardware time based on the system time. + +* I also have a Bash program I run early every morning that creates a new "message of the day" (MOTD) on each computer. It contains information, such as disk usage, that should be current in order to be useful. + +* Many system processes and services, like [Logwatch][1], [logrotate][2], and [Rootkit Hunter][3], use the cron service to schedule tasks and run programs every day. + +The crond daemon is the background service that enables cron functionality. + +The cron service checks for files in the /var/spool/cron and /etc/cron.d directories and the /etc/anacrontab file. The contents of these files define cron jobs that are to be run at various intervals. The individual user cron files are located in /var/spool/cron, and system services and applications generally add cron job files in the /etc/cron.ddirectory. The /etc/anacrontab is a special case that will be covered later in this article. + +### Using crontab + +The cron utility runs based on commands specified in a cron table (crontab). Each user, including root, can have a cron file. These files don't exist by default, but can be created in the /var/spool/cron directory using the crontab -e command that's also used to edit a cron file (see the script below). I strongly recommend that you not use a standard editor (such as Vi, Vim, Emacs, Nano, or any of the many other editors that are available). Using the crontab command not only allows you to edit the command, it also restarts the crond daemon when you save and exit the editor. The crontabcommand uses Vi as its underlying editor, because Vi is always present (on even the most basic of installations). + +New cron files are empty, so commands must be added from scratch. I added the job definition example below to my own cron files, just as a quick reference, so I know what the various parts of a command mean. Feel free to copy it for your own use. + +``` +# crontab -e +SHELL=/bin/bash +MAILTO=root@example.com +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin + +# For details see man 4 crontabs + +# Example of job definition: +# .---------------- minute (0 - 59) +# | .------------- hour (0 - 23) +# | | .---------- day of month (1 - 31) +# | | | .------- month (1 - 12) OR jan,feb,mar,apr ... +# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat +# | | | | | +# * * * * * user-name command to be executed + +# backup using the rsbu program to the internal 4TB HDD and then 4TB external +01 01 * * * /usr/local/bin/rsbu -vbd1 ; /usr/local/bin/rsbu -vbd2 + +# Set the hardware clock to keep it in sync with the more accurate system clock +03 05 * * * /sbin/hwclock --systohc + +# Perform monthly updates on the first of the month +# 25 04 1 * * /usr/bin/dnf -y update +``` + +The first three lines in the code above set up a default environment. The environment must be set to whatever is necessary for a given user because cron does not provide an environment of any kind. The SHELL variable specifies the shell to use when commands are executed. This example specifies the Bash shell. The MAILTO variable sets the email address where cron job results will be sent. These emails can provide the status of the cron job (backups, updates, etc.) and consist of the output you would see if you ran the program manually from the command line. The third line sets up the PATH for the environment. Even though the path is set here, I always prepend the fully qualified path to each executable. + +There are several comment lines in the example above that detail the syntax required to define a cron job. I'll break those commands down, then add a few more to show you some more advanced capabilities of crontab files. + +``` +01 01 * * * /usr/local/bin/rsbu -vbd1 ; /usr/local/bin/rsbu -vbd2 +``` + +This line runs my self-written Bash shell script, rsbu, that backs up all my systems. This job kicks off at 1:01 a.m. (01 01) every day. The asterisks (*) in positions three, four, and five of the time specification are like file globs, or wildcards, for other time divisions; they specify "every day of the month," "every month," and "every day of the week." This line runs my backups twice; one backs up to an internal dedicated backup hard drive, and the other backs up to an external USB drive that I can take to the safe deposit box. + +The following line sets the hardware clock on the computer using the system clock as the source of an accurate time. This line is set to run at 5:03 a.m. (03 05) every day. + +``` +03 05 * * * /sbin/hwclock --systohc +``` + +I was using the third and final cron job (commented out) to perform a dnf or yumupdate at 04:25 a.m. on the first day of each month, but I commented it out so it no longer runs. + +``` +# 25 04 1 * * /usr/bin/dnf -y update +``` + +### Other scheduling tricks + +Now let's do some things that are a little more interesting than these basics. Suppose you want to run a particular job every Thursday at 3 p.m.: + +``` +00 15 * * Thu /usr/local/bin/mycronjob.sh +``` + +Or, maybe you need to run quarterly reports after the end of each quarter. The cron service has no option for "The last day of the month," so instead you can use the first day of the following month, as shown below. (This assumes that the data needed for the reports will be ready when the job is set to run.) + +``` +02 03 1 1,4,7,10 * /usr/local/bin/reports.sh +``` + +The following shows a job that runs one minute past every hour between 9:01 a.m. and 5:01 p.m. + +``` +01 09-17 * * * /usr/local/bin/hourlyreminder.sh +``` + +I have encountered situations where I need to run a job every two, three, or four hours. That can be accomplished by dividing the hours by the desired interval, such as */3 for every three hours, or 6-18/3 to run every three hours between 6 a.m. and 6 p.m. Other intervals can be divided similarly; for example, the expression */15 in the minutes position means "run the job every 15 minutes." + +``` +*/5 08-18/2 * * * /usr/local/bin/mycronjob.sh +``` + +One thing to note: The division expressions must result in a remainder of zero for the job to run. That's why, in this example, the job is set to run every five minutes (08:05, 08:10, 08:15, etc.) during even-numbered hours from 8 a.m. to 6 p.m., but not during any odd-numbered hours. For example, the job will not run at all from 9 p.m. to 9:59 a.m. + +I am sure you can come up with many other possibilities based on these examples. + +### Limiting cron access + +More Linux resources + +* [What is Linux?][4] + +* [What are Linux containers?][5] + +* [Download Now: Linux commands cheat sheet][6] + +* [Advanced Linux commands cheat sheet][7] + +* [Our latest Linux articles][8] + +Regular users with cron access could make mistakes that, for example, might cause system resources (such as memory and CPU time) to be swamped. To prevent possible misuse, the sysadmin can limit user access by creating a + +**/etc/cron.allow** + + file that contains a list of all users with permission to create cron jobs. The root user cannot be prevented from using cron. + +By preventing non-root users from creating their own cron jobs, it may be necessary for root to add their cron jobs to the root crontab. "But wait!" you say. "Doesn't that run those jobs as root?" Not necessarily. In the first example in this article, the username field shown in the comments can be used to specify the user ID a job is to have when it runs. This prevents the specified non-root user's jobs from running as root. The following example shows a job definition that runs a job as the user "student": + +``` +04 07 * * * student /usr/local/bin/mycronjob.sh +``` + +### cron.d + +The directory /etc/cron.d is where some applications, such as [SpamAssassin][18] and [sysstat][19], install cron files. Because there is no spamassassin or sysstat user, these programs need a place to locate cron files, so they are placed in /etc/cron.d. + +The /etc/cron.d/sysstat file below contains cron jobs that relate to system activity reporting (SAR). These cron files have the same format as a user cron file. + +``` +# Run system activity accounting tool every 10 minutes +*/10 * * * * root /usr/lib64/sa/sa1 1 1 +# Generate a daily summary of process accounting at 23:53 +53 23 * * * root /usr/lib64/sa/sa2 -A +``` + +The sysstat cron file has two lines that perform tasks. The first line runs the sa1program every 10 minutes to collect data stored in special binary files in the /var/log/sadirectory. Then, every night at 23:53, the sa2 program runs to create a daily summary. + +### Scheduling tips + +Some of the times I set in the crontab files seem rather random—and to some extent they are. Trying to schedule cron jobs can be challenging, especially as the number of jobs increases. I usually have only a few tasks to schedule on each of my computers, which is simpler than in some of the production and lab environments where I have worked. + +One system I administered had around a dozen cron jobs that ran every night and an additional three or four that ran on weekends or the first of the month. That was a challenge, because if too many jobs ran at the same time—especially the backups and compiles—the system would run out of RAM and nearly fill the swap file, which resulted in system thrashing while performance tanked, so nothing got done. We added more memory and improved how we scheduled tasks. We also removed a task that was very poorly written and used large amounts of memory. + +The crond service assumes that the host computer runs all the time. That means that if the computer is turned off during a period when cron jobs were scheduled to run, they will not run until the next time they are scheduled. This might cause problems if they are critical cron jobs. Fortunately, there is another option for running jobs at regular intervals: anacron. + +### anacron + +The [anacron][20] program performs the same function as crond, but it adds the ability to run jobs that were skipped, such as if the computer was off or otherwise unable to run the job for one or more cycles. This is very useful for laptops and other computers that are turned off or put into sleep mode. + +As soon as the computer is turned on and booted, anacron checks to see whether configured jobs missed their last scheduled run. If they have, those jobs run immediately, but only once (no matter how many cycles have been missed). For example, if a weekly job was not run for three weeks because the system was shut down while you were on vacation, it would be run soon after you turn the computer on, but only once, not three times. + +The anacron program provides some easy options for running regularly scheduled tasks. Just install your scripts in the /etc/cron.[hourly|daily|weekly|monthly]directories, depending how frequently they need to be run. + +How does this work? The sequence is simpler than it first appears. + +1. The crond service runs the cron job specified in /etc/cron.d/0hourly. + +``` +# Run the hourly jobs +SHELL=/bin/bash +PATH=/sbin:/bin:/usr/sbin:/usr/bin +MAILTO=root +01 * * * * root run-parts /etc/cron.hourly +``` + +1. The cron job specified in /etc/cron.d/0hourly runs the run-parts program once per hour. + +2. The run-parts program runs all the scripts located in the /etc/cron.hourlydirectory. + +3. The /etc/cron.hourly directory contains the 0anacron script, which runs the anacron program using the /etdc/anacrontab configuration file shown here. + +``` +# /etc/anacrontab: configuration file for anacron + +# See anacron(8) and anacrontab(5) for details. + +SHELL=/bin/sh +PATH=/sbin:/bin:/usr/sbin:/usr/bin +MAILTO=root +# the maximal random delay added to the base delay of the jobs +RANDOM_DELAY=45 +# the jobs will be started during the following hours only +START_HOURS_RANGE=3-22 + +#period in days delay in minutes job-identifier command +1 5 cron.daily nice run-parts /etc/cron.daily +7 25 cron.weekly nice run-parts /etc/cron.weekly +@monthly 45 cron.monthly nice run-parts /etc/cron.monthly +``` + +1. The anacron program runs the programs located in /etc/cron.daily once per day; it runs the jobs located in /etc/cron.weekly once per week, and the jobs in cron.monthly once per month. Note the specified delay times in each line that help prevent these jobs from overlapping themselves and other cron jobs. + +Instead of placing complete Bash programs in the cron.X directories, I install them in the /usr/local/bin directory, which allows me to run them easily from the command line. Then I add a symlink in the appropriate cron directory, such as /etc/cron.daily. + +The anacron program is not designed to run programs at specific times. Rather, it is intended to run programs at intervals that begin at the specified times, such as 3 a.m. (see the START_HOURS_RANGE line in the script just above) of each day, on Sunday (to begin the week), and on the first day of the month. If any one or more cycles are missed, anacron will run the missed jobs once, as soon as possible. + +### More on setting limits + +I use most of these methods for scheduling tasks to run on my computers. All those tasks are ones that need to run with root privileges. It's rare in my experience that regular users really need a cron job. One case was a developer user who needed a cron job to kick off a daily compile in a development lab. + +It is important to restrict access to cron functions by non-root users. However, there are circumstances when a user needs to set a task to run at pre-specified times, and cron can allow them to do that. Many users do not understand how to properly configure these tasks using cron and they make mistakes. Those mistakes may be harmless, but, more often than not, they can cause problems. By setting functional policies that cause users to interact with the sysadmin, individual cron jobs are much less likely to interfere with other users and other system functions. + +It is possible to set limits on the total resources that can be allocated to individual users or groups, but that is an article for another time. + +For more information, the man pages for [cron][21], [crontab][22], [anacron][23], [anacrontab][24], and [run-parts][25] all have excellent information and descriptions of how the cron system works. + +### Topics + + [Linux][26][SysAdmin][27] + +### About the author + + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/david-crop.jpg?itok=oePpOpyV)][28] David Both + +- + + David Both is a Linux and Open Source advocate who resides in Raleigh, North Carolina. He has been in the IT industry for over forty years and taught OS/2 for IBM where he worked for over 20 years. While at IBM, he wrote the first training course for the original IBM PC in 1981\. He has taught RHCE classes for Red Hat and has worked at MCI Worldcom, Cisco, and the State of North Carolina. He has been working with Linux and Open Source Software for almost 20 years. David has written articles for... [more about David Both][29][More about me][30] + +* [Learn how you can contribute][9] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/how-use-cron-linux + +作者:[David Both ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[1]:https://sourceforge.net/projects/logwatch/files/ +[2]:https://github.com/logrotate/logrotate +[3]:http://rkhunter.sourceforge.net/ +[4]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[5]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[6]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[7]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[8]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[9]:https://opensource.com/participate +[10]:https://opensource.com/users/dboth +[11]:https://opensource.com/users/dboth +[12]:https://opensource.com/user/14106/feed +[13]:https://opensource.com/article/17/11/how-use-cron-linux?rate=9R7lrdQXsne44wxIh0Wu91ytYaxxi86zT1-uHo1a1IU +[14]:https://opensource.com/article/17/11/how-use-cron-linux#comments +[15]:https://www.flickr.com/photos/internetarchivebookimages/20570945848/in/photolist-xkMtw9-xA5zGL-tEQLWZ-wFwzFM-aNwxgn-aFdWBj-uyFKYv-7ZCCBU-obY1yX-UAPafA-otBzDF-ovdDo6-7doxUH-obYkeH-9XbHKV-8Zk4qi-apz7Ky-apz8Qu-8ZoaWG-orziEy-aNwxC6-od8NTv-apwpMr-8Zk4vn-UAP9Sb-otVa3R-apz6Cb-9EMPj6-eKfyEL-cv5mwu-otTtHk-7YjK1J-ovhxf6-otCg2K-8ZoaJf-UAPakL-8Zo8j7-8Zk74v-otp4Ls-8Zo8h7-i7xvpR-otSosT-9EMPja-8Zk6Zi-XHpSDB-hLkuF3-of24Gf-ouN1Gv-fJzkJS-icfbY9 +[16]:https://creativecommons.org/licenses/by-sa/4.0/ +[17]:https://en.wikipedia.org/wiki/Cron +[18]:http://spamassassin.apache.org/ +[19]:https://github.com/sysstat/sysstat +[20]:https://en.wikipedia.org/wiki/Anacron +[21]:http://man7.org/linux/man-pages/man8/cron.8.html +[22]:http://man7.org/linux/man-pages/man5/crontab.5.html +[23]:http://man7.org/linux/man-pages/man8/anacron.8.html +[24]:http://man7.org/linux/man-pages/man5/anacrontab.5.html +[25]:http://manpages.ubuntu.com/manpages/zesty/man8/run-parts.8.html +[26]:https://opensource.com/tags/linux +[27]:https://opensource.com/tags/sysadmin +[28]:https://opensource.com/users/dboth +[29]:https://opensource.com/users/dboth +[30]:https://opensource.com/users/dboth From 62f0b7686a710da078c84e24922bc6dd828429fe Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 7 Dec 2017 20:48:57 +0800 Subject: [PATCH 343/344] translated --- ...mand Learn to use netstat with examples.md | 99 ++++++++++++------- 1 file changed, 62 insertions(+), 37 deletions(-) diff --git a/sources/tech/20171205 NETSTAT Command Learn to use netstat with examples.md b/sources/tech/20171205 NETSTAT Command Learn to use netstat with examples.md index 4001ab5c08..b2b7175749 100644 --- a/sources/tech/20171205 NETSTAT Command Learn to use netstat with examples.md +++ b/sources/tech/20171205 NETSTAT Command Learn to use netstat with examples.md @@ -1,103 +1,128 @@ -translating by lujun9972 -translating by lujun9972 -NETSTAT Command: Learn to use netstat with examples +NETSTAT 命令: 通过案例学习使用 netstate ====== -Netstat is a command line utility that tells us about all the tcp/udp/unix socket connections on our system. It provides list of all connections that are currently established or are in waiting state. This tool is extremely useful in identifying the port numbers on which an application is working and we can also make sure if an application is working or not on the port it is supposed to work. +Netstat 是一个告诉我们系统中所有 tcp/udp/unix socket 连接状态的命令行工具。它会列出所有已经连接或者等待连接状态的连接。 该工具在识别某个应用监听哪个端口时特别有用,我们也能用它来判断某个应用是否正常的在监听某个端口。 -Netstat command also displays various other network related information such as routing tables, interface statistics, masquerade connections, multicast memberships etc., +Netstat 命令还能显示其他各种各样的网络相关信息,例如路由表, 网卡统计信息, 虚假连接以及多播成员等。 -In this tutorial, we will learn about Netstat with examples. +本文中,我们会通过几个例子来学习 Netstat。 -(Recommended Read: [Learn to use CURL command with examples][1] ) +(推荐阅读: [Learn to use CURL command with examples][1] ) Netstat with examples ============================================================ -### 1- Checking all connections - -To list out all the connections on a system, we can use ‘a’ option with netstat command, +### 1- 检查所有的连接 +使用 `a` 选项可以列出系统中的所有连接, +```shell $ netstat -a +``` -This will produce all tcp, udp & unix connections from the system. +这会显示系统所有的 tcp,udp 以及 unix 连接。 -### 2- Checking all tcp or udp or unix socket connections +### 2- 检查所有的 tcp/udp/unix socket 连接 -To list only the tcp connections our system, use ‘t’ options with netstat, +使用 `t` 选项只列出 tcp 连接, +```shell $ netstat -at +``` -Similarly to list out only the udp connections on our system, we can use ‘u’ option with netstat, +类似的,使用 `u` 选项只列出 udp 连接 to list out only the udp connections on our system, we can use ‘u’ option with netstat, +```shell $ netstat -au +``` -To only list out Unix socket connections, we can use ‘x’ options, +使用 `x` 选项只列出 Unix socket 连接,we can use ‘x’ options, +```shell $ netstat -ax +``` -### 3- List process id/Process Name with +### 3- 同时列出进程 ID/进程名称 -To get list of all connections along with PID or process name, we can use ‘p’ option & it can be used in combination with any other netstat option, +使用 `p` 选项可以在列出连接的同时也显示 PID 或者进程名称,而且它还能与其他选项连用, +```shell $ netstat -ap +``` -### 4- List only port number & not the name +### 4- 列出端口号而不是服务名 -To speed up our output, we can use ‘n’ option as it will perform any reverse lookup & produce output with only numbers. Since no lookup is performed, our output will much faster. +使用 `n` 选项可以加快输出,它不会执行任何反向查询(译者注:这里原文说的是 "it will perform any reverse lookup",应该是写错了),而是直接输出数字。 由于无需查询,因此结果输出会快很多。 +```shell $ netstat -an +``` -### 5- Print only listening ports +### 5- 只输出监听端口 -To print only the listening ports , we will use ‘l’ option with netstat. It will not be used with ‘a’ as it prints all ports, +使用 `l` 选项只输出监听端口。它不能与 `a` 选项连用,因为 `a` 会输出所有端口, +```shell $ netstat -l +``` -### 6- Print network stats +### 6- 输出网络状态 -To print network statistics of each protocol like packet received or transmitted, we can use ‘s’ options with netstat, +使用 `s` 选项输出每个协议的统计信息,包括接收/发送的包数量 +```shell $ netstat -s +``` -### 7- Print interfaces stats +### 7- 输出网卡状态 -To display only the statistics on network interfaces, use ‘I’ option, +使用 `I` 选项只显示网卡的统计信息, +```shell $ netstat -i +``` -### 8-Display multicast group information +### 8- 显示多播组(multicast group)信息 -With option ‘g’ , we can print the multicast group information for IPV4 & IPV6, +使用 `g` 选项输出 IPV4 以及 IPV6 的多播组信息, +```shell $ netstat -g +``` -### 9- Display the network routing information +### 9- 显示网络路由信息 -To print the network routing information, use ‘r’ option, +使用 `r` 输出网络路由信息, +```shell $ netstat -r +``` -### 10- Continuous output +### 10- 持续输出 -To get continuous output of netstat, use ‘c’ option +使用 `c` 选项持续输出结果 +```shell $ netstat -c +``` -### 11- Filtering a single port +### 11- 过滤出某个端口 -To filter a single port connections, we can combine ‘grep’ command with netstat, +与 `grep` 连用来过滤出某个端口的连接, +```shell $ netstat -anp | grep 3306 +``` -### 12- Count number of connections +### 12- 统计连接个数 -To count the number of connections from port, we can further add ‘wc’ command with netstat & grep command, +通过与 wc 和 grep 命令连用,可以统计指定端口的连接数量 +```shell $ netstat -anp | grep 3306 | wc -l +``` -This will print the number of connections for the port mysql port i.e. 3306. +这回输出 mysql 服务端口(即 3306)的连接数。 -This was our brief tutorial on Netstat with examples, hope it was informative enough. If you have any query or suggestion, please mention it in the comment box below. +这就是我们间断的案例指南了,希望它带给你的信息量足够。 有任何疑问欢迎提出。 -------------------------------------------------------------------------------- From fac25d49bafe4d827dccd879e1a9e70eaa57d840 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 7 Dec 2017 20:50:31 +0800 Subject: [PATCH 344/344] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...20171205 NETSTAT Command Learn to use netstat with examples.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources => translated}/tech/20171205 NETSTAT Command Learn to use netstat with examples.md (100%) diff --git a/sources/tech/20171205 NETSTAT Command Learn to use netstat with examples.md b/translated/tech/20171205 NETSTAT Command Learn to use netstat with examples.md similarity index 100% rename from sources/tech/20171205 NETSTAT Command Learn to use netstat with examples.md rename to translated/tech/20171205 NETSTAT Command Learn to use netstat with examples.md